,a),{_src:n,_glob:e})}get options(){return this.#a}toRegExpSource(e){const n=e??!!this.#a.dot;if(this.#o===this\u0026\u0026(this.#f(),this.#d()),!cfn(this)){const A=this.isStart()\u0026\u0026this.isEnd()\u0026\u0026!this.#t.some(h=\u003etypeof h!=\"string\"),c=this.#t.map(h=\u003e{const[d,p,m,_]=typeof h==\"string\"?n3.#E(h,this.#n,A):h.toRegExpSource(e);return this.#n=this.#n||m,this.#i=this.#i||_,d}).join(\"\");let l=\"\";if(this.isStart()\u0026\u0026typeof this.#t[0]==\"string\"\u0026\u0026!(this.#t.length===1\u0026\u0026aji.has(this.#t[0]))){const d=sji,p=n\u0026\u0026d.has(c.charAt(0))||c.startsWith(\"\\\\.\")\u0026\u0026d.has(c.charAt(2))||c.startsWith(\"\\\\.\\\\.\")\u0026\u0026d.has(c.charAt(4)),m=!n\u0026\u0026!e\u0026\u0026d.has(c.charAt(0));l=p?rji:m?Zfe:\"\"}let u=\"\";return this.isEnd()\u0026\u0026this.#o.#c\u0026\u0026this.#e?.type===\"!\"\u0026\u0026(u=\"(?:$|\\\\/)\"),[l+c+u,Lee(c),this.#n=!!this.#n,this.#i]}const o=this.type===\"*\"||this.type===\"+\",i=this.type===\"!\"?\"(?:(?!(?:\":\"(?:\";let r=this.#I(n);if(this.isStart()\u0026\u0026this.isEnd()\u0026\u0026!r\u0026\u0026this.type!==\"!\"){const A=this.toString(),c=this;return c.#t=[A],c.type=null,c.#n=void 0,[A,Lee(this.toString()),!1,!1]}let s=!o||e||n||!Zfe?\"\":this.#I(!0);s===r\u0026\u0026(s=\"\"),s\u0026\u0026(r=`(?:${r})(?:${s})*?`);let a=\"\";if(this.type===\"!\"\u0026\u0026this.#g)a=(this.isStart()\u0026\u0026!n?Zfe:\"\")+gfn;else{const A=this.type===\"!\"?\"))\"+(this.isStart()\u0026\u0026!n\u0026\u0026!e?Zfe:\"\")+ufn+\")\":this.type===\"@\"?\")\":this.type===\"?\"?\")?\":this.type===\"+\"\u0026\u0026s?\")\":this.type===\"*\"\u0026\u0026s?\")?\":`)${this.type}`;a=i+r+A}return[a,Lee(r),this.#n=!!this.#n,this.#i]}#f(){if(cfn(this)){let e=0,n=!1;do{n=!0;for(let o=0;o\u003cthis.#t.length;o++){const i=this.#t[o];typeof i==\"object\"\u0026\u0026(i.#f(),this.#_(i)?(n=!1,this.#p(i,o)):this.#m(i)?(n=!1,this.#h(i,o)):this.#y(i)\u0026\u0026(n=!1,this.#x(i)))}}while(!n\u0026\u0026++e\u003c10)}else for(const e of this.#t)typeof e==\"object\"\u0026\u0026e.#f();this.#l=void 0}#I(e){return this.#t.map(n=\u003e{if(typeof n==\"string\")throw new Error(\"string type in extglob ast??\");const[o,i,r,s]=n.toRegExpSource(e);return this.#i=this.#i||s,o}).filter(n=\u003e!(this.isStart()\u0026\u0026this.isEnd())||!!n).join(\"|\")}static#E(e,n,o=!1){let i=!1,r=\"\",s=!1,a=!1;for(let A=0;A\u003ce.length;A++){const c=e.charAt(A);if(i){i=!1,r+=(Aji.has(c)?\"\\\\\":\"\")+c;continue}if(c===\"*\"){if(a)continue;a=!0,r+=o\u0026\u0026/^[*]+$/.test(e)?gfn:ufn,n=!0;continue}else a=!1;if(c===\"\\\\\"){A===e.length-1?r+=\"\\\\\\\\\":i=!0;continue}if(c===\"[\"){const[l,u,g,h]=eji(e,A);if(g){r+=l,s=s||u,A+=g-1,n=n||h;continue}}if(c===\"?\"){r+=cXe,n=!0;continue}r+=cji(c)}return[r,Lee(e),!!n,s]}}n3=lXe;const uji=(t,{windowsPathsNoEscape:e=!1,magicalBraces:n=!1}={})=\u003en?e?t.replace(/[?*()[\\]{}]/g,\"[$\u0026]\"):t.replace(/[?*()[\\]\\\\{}]/g,\"\\\\$\u0026\"):e?t.replace(/[?*()[\\]]/g,\"[$\u0026]\"):t.replace(/[?*()[\\]\\\\]/g,\"\\\\$\u0026\");var nK={env:{}};const d2=(t,e,n={})=\u003e(Xfe(e),!n.nocomment\u0026\u0026e.charAt(0)===\"#\"?!1:new Hee(e,n).match(t)),gji=/^\\*+([^+@!?*[(]*)$/,dji=t=\u003ee=\u003e!e.startsWith(\".\")\u0026\u0026e.endsWith(t),hji=t=\u003ee=\u003ee.endsWith(t),pji=t=\u003e(t=t.toLowerCase(),e=\u003e!e.startsWith(\".\")\u0026\u0026e.toLowerCase().endsWith(t)),mji=t=\u003e(t=t.toLowerCase(),e=\u003ee.toLowerCase().endsWith(t)),_ji=/^\\*+\\.\\*+$/,fji=t=\u003e!t.startsWith(\".\")\u0026\u0026t.includes(\".\"),Iji=t=\u003et!==\".\"\u0026\u0026t!==\"..\"\u0026\u0026t.includes(\".\"),Cji=/^\\.\\*+$/,yji=t=\u003et!==\".\"\u0026\u0026t!==\"..\"\u0026\u0026t.startsWith(\".\"),xji=/^\\*+$/,Eji=t=\u003et.length!==0\u0026\u0026!t.startsWith(\".\"),Bji=t=\u003et.length!==0\u0026\u0026t!==\".\"\u0026\u0026t!==\"..\",bji=/^\\?+([^+@!?*[(]*)?$/,Sji=([t,e=\"\"])=\u003e{const n=dfn([t]);return e?(e=e.toLowerCase(),o=\u003en(o)\u0026\u0026o.toLowerCase().endsWith(e)):n},Qji=([t,e=\"\"])=\u003e{const n=hfn([t]);return e?(e=e.toLowerCase(),o=\u003en(o)\u0026\u0026o.toLowerCase().endsWith(e)):n},vji=([t,e=\"\"])=\u003e{const n=hfn([t]);return e?o=\u003en(o)\u0026\u0026o.endsWith(e):n},wji=([t,e=\"\"])=\u003e{const n=dfn([t]);return e?o=\u003en(o)\u0026\u0026o.endsWith(e):n},dfn=([t])=\u003e{const e=t.length;return n=\u003en.length===e\u0026\u0026!n.startsWith(\".\")},hfn=([t])=\u003e{const e=t.length;return n=\u003en.length===e\u0026\u0026n!==\".\"\u0026\u0026n!==\"..\"},pfn=typeof nK==\"object\"\u0026\u0026nK?typeof nK.env==\"object\"\u0026\u0026nK.env\u0026\u0026nK.env.__MINIMATCH_TESTING_PLATFORM__||nK.platform:\"posix\",mfn={win32:{sep:\"\\\\\"},posix:{sep:\"/\"}},Pji=pfn===\"win32\"?mfn.win32.sep:mfn.posix.sep;d2.sep=Pji;const kC=Symbol(\"globstar **\");d2.GLOBSTAR=kC;const Mji=\"[^/]\"+\"*?\",Dji=\"(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?\",Nji=\"(?:(?!(?:\\\\/|^)\\\\.).)*?\",Rji=(t,e={})=\u003en=\u003ed2(n,t,e);d2.filter=Rji;const x4=(t,e={})=\u003eObject.assign({},t,e),Tji=t=\u003e{if(!t||typeof t!=\"object\"||!Object.keys(t).length)return d2;const e=d2;return Object.assign((o,i,r={})=\u003ee(o,i,x4(t,r)),{Minimatch:class extends e.Minimatch{constructor(i,r={}){super(i,x4(t,r))}static defaults(i){return e.defaults(x4(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,r,s={}){super(i,r,x4(t,s))}static fromGlob(i,r={}){return e.AST.fromGlob(i,x4(t,r))}},unescape:(o,i={})=\u003ee.unescape(o,x4(t,i)),escape:(o,i={})=\u003ee.escape(o,x4(t,i)),filter:(o,i={})=\u003ee.filter(o,x4(t,i)),defaults:o=\u003ee.defaults(x4(t,o)),makeRe:(o,i={})=\u003ee.makeRe(o,x4(t,i)),braceExpand:(o,i={})=\u003ee.braceExpand(o,x4(t,i)),match:(o,i,r={})=\u003ee.match(o,i,x4(t,r)),sep:e.sep,GLOBSTAR:kC})};d2.defaults=Tji;const _fn=(t,e={})=\u003e(Xfe(t),e.nobrace||!/\\{(?:(?!\\{).)*\\}/.test(t)?[t]:VWi(t,{max:e.braceExpandMax}));d2.braceExpand=_fn;const kji=(t,e={})=\u003enew Hee(t,e).makeRe();d2.makeRe=kji;const Fji=(t,e,n={})=\u003e{const o=new Hee(e,n);return t=t.filter(i=\u003eo.match(i)),o.options.nonull\u0026\u0026!t.length\u0026\u0026t.push(e),t};d2.match=Fji;const ffn=/[?*]|[+@!]\\(.*?\\)|\\[|\\]/,Lji=t=\u003et.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g,\"\\\\$\u0026\");class Hee{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,n={}){Xfe(e),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=e,this.platform=n.platform||pfn,this.isWindows=this.platform===\"win32\";const o=\"allowWindowsEscape\";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[o]===!1,this.windowsPathsNoEscape\u0026\u0026(this.pattern=this.pattern.replace(/\\\\/g,\"/\")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows\u0026\u0026this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces\u0026\u0026this.set.length\u003e1)return!0;for(const e of this.set)for(const n of e)if(typeof n!=\"string\")return!0;return!1}debug(...e){}make(){const e=this.pattern,n=this.options;if(!n.nocomment\u0026\u0026e.charAt(0)===\"#\"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug\u0026\u0026(this.debug=(...r)=\u003econsole.error(...r)),this.debug(this.pattern,this.globSet);const o=this.globSet.map(r=\u003ethis.slashSplit(r));this.globParts=this.preprocess(o),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,s,a)=\u003e{if(this.isWindows\u0026\u0026this.windowsNoMagicRoot){const A=r[0]===\"\"\u0026\u0026r[1]===\"\"\u0026\u0026(r[2]===\"?\"||!ffn.test(r[2]))\u0026\u0026!ffn.test(r[3]),c=/^[a-z]:/i.test(r[0]);if(A)return[...r.slice(0,4),...r.slice(4).map(l=\u003ethis.parse(l))];if(c)return[r[0],...r.slice(1).map(l=\u003ethis.parse(l))]}return r.map(A=\u003ethis.parse(A))});if(this.debug(this.pattern,i),this.set=i.filter(r=\u003er.indexOf(!1)===-1),this.isWindows)for(let r=0;r\u003cthis.set.length;r++){const s=this.set[r];s[0]===\"\"\u0026\u0026s[1]===\"\"\u0026\u0026this.globParts[r][2]===\"?\"\u0026\u0026typeof s[3]==\"string\"\u0026\u0026/^[a-z]:$/i.test(s[3])\u0026\u0026(s[2]=\"?\")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(const o of e)for(let i=0;i\u003co.length;i++)o[i]===\"**\"\u0026\u0026(o[i]=\"*\");const{optimizationLevel:n=1}=this.options;return n\u003e=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):n\u003e=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(n=\u003e{let o=-1;for(;(o=n.indexOf(\"**\",o+1))!==-1;){let i=o;for(;n[i+1]===\"**\";)i++;i!==o\u0026\u0026n.splice(o,i-o)}return n})}levelOneOptimize(e){return e.map(n=\u003e(n=n.reduce((o,i)=\u003e{const r=o[o.length-1];return i===\"**\"\u0026\u0026r===\"**\"?o:i===\"..\"\u0026\u0026r\u0026\u0026r!==\"..\"\u0026\u0026r!==\".\"\u0026\u0026r!==\"**\"?(o.pop(),o):(o.push(i),o)},[]),n.length===0?[\"\"]:n))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i\u003ce.length-1;i++){const r=e[i];i===1\u0026\u0026r===\"\"\u0026\u0026e[0]===\"\"||(r===\".\"||r===\"\")\u0026\u0026(n=!0,e.splice(i,1),i--)}e[0]===\".\"\u0026\u0026e.length===2\u0026\u0026(e[1]===\".\"||e[1]===\"\")\u0026\u0026(n=!0,e.pop())}let o=0;for(;(o=e.indexOf(\"..\",o+1))!==-1;){const i=e[o-1];i\u0026\u0026i!==\".\"\u0026\u0026i!==\"..\"\u0026\u0026i!==\"**\"\u0026\u0026!(this.isWindows\u0026\u0026/^[a-z]:$/i.test(i))\u0026\u0026(n=!0,e.splice(o-1,2),o-=2)}}while(n);return e.length===0?[\"\"]:e}firstPhasePreProcess(e){let n=!1;do{n=!1;for(let o of e){let i=-1;for(;(i=o.indexOf(\"**\",i+1))!==-1;){let s=i;for(;o[s+1]===\"**\";)s++;s\u003ei\u0026\u0026o.splice(i+1,s-i);let a=o[i+1];const A=o[i+2],c=o[i+3];if(a!==\"..\"||!A||A===\".\"||A===\"..\"||!c||c===\".\"||c===\"..\")continue;n=!0,o.splice(i,1);const l=o.slice(0);l[i]=\"**\",e.push(l),i--}if(!this.preserveMultipleSlashes){for(let s=1;s\u003co.length-1;s++){const a=o[s];s===1\u0026\u0026a===\"\"\u0026\u0026o[0]===\"\"||(a===\".\"||a===\"\")\u0026\u0026(n=!0,o.splice(s,1),s--)}o[0]===\".\"\u0026\u0026o.length===2\u0026\u0026(o[1]===\".\"||o[1]===\"\")\u0026\u0026(n=!0,o.pop())}let r=0;for(;(r=o.indexOf(\"..\",r+1))!==-1;){const s=o[r-1];if(s\u0026\u0026s!==\".\"\u0026\u0026s!==\"..\"\u0026\u0026s!==\"**\"){n=!0;const A=r===1\u0026\u0026o[r+1]===\"**\"?[\".\"]:[];o.splice(r-1,2,...A),o.length===0\u0026\u0026o.push(\"\"),r-=2}}}}while(n);return e}secondPhasePreProcess(e){for(let n=0;n\u003ce.length-1;n++)for(let o=n+1;o\u003ce.length;o++){const i=this.partsMatch(e[n],e[o],!this.preserveMultipleSlashes);if(i){e[n]=[],e[o]=i;break}}return e.filter(n=\u003en.length)}partsMatch(e,n,o=!1){let i=0,r=0,s=[],a=\"\";for(;i\u003ce.length\u0026\u0026r\u003cn.length;)if(e[i]===n[r])s.push(a===\"b\"?n[r]:e[i]),i++,r++;else if(o\u0026\u0026e[i]===\"**\"\u0026\u0026n[r]===e[i+1])s.push(e[i]),i++;else if(o\u0026\u0026n[r]===\"**\"\u0026\u0026e[i]===n[r+1])s.push(n[r]),r++;else if(e[i]===\"*\"\u0026\u0026n[r]\u0026\u0026(this.options.dot||!n[r].startsWith(\".\"))\u0026\u0026n[r]!==\"**\"){if(a===\"b\")return!1;a=\"a\",s.push(e[i]),i++,r++}else if(n[r]===\"*\"\u0026\u0026e[i]\u0026\u0026(this.options.dot||!e[i].startsWith(\".\"))\u0026\u0026e[i]!==\"**\"){if(a===\"a\")return!1;a=\"b\",s.push(n[r]),i++,r++}else return!1;return e.length===n.length\u0026\u0026s}parseNegate(){if(this.nonegate)return;const e=this.pattern;let n=!1,o=0;for(let i=0;i\u003ce.length\u0026\u0026e.charAt(i)===\"!\";i++)n=!n,o++;o\u0026\u0026(this.pattern=e.slice(o)),this.negate=n}matchOne(e,n,o=!1){let i=0,r=0;if(this.isWindows){const a=typeof e[0]==\"string\"\u0026\u0026/^[a-z]:$/i.test(e[0]),A=!a\u0026\u0026e[0]===\"\"\u0026\u0026e[1]===\"\"\u0026\u0026e[2]===\"?\"\u0026\u0026/^[a-z]:$/i.test(e[3]),c=typeof n[0]==\"string\"\u0026\u0026/^[a-z]:$/i.test(n[0]),l=!c\u0026\u0026n[0]===\"\"\u0026\u0026n[1]===\"\"\u0026\u0026n[2]===\"?\"\u0026\u0026typeof n[3]==\"string\"\u0026\u0026/^[a-z]:$/i.test(n[3]),u=A?3:a?0:void 0,g=l?3:c?0:void 0;if(typeof u==\"number\"\u0026\u0026typeof g==\"number\"){const[h,d]=[e[u],n[g]];h.toLowerCase()===d.toLowerCase()\u0026\u0026(n[g]=h,r=g,i=u)}}const{optimizationLevel:s=1}=this.options;return s\u003e=2\u0026\u0026(e=this.levelTwoFileOptimize(e)),n.includes(kC)?this.#o(e,n,o,i,r):this.#i(e,n,o,i,r)}#o(e,n,o,i,r){const s=n.indexOf(kC,r),a=n.lastIndexOf(kC),[A,c,l]=o?[n.slice(r,s),n.slice(s+1),[]]:[n.slice(r,s),n.slice(s+1,a),n.slice(a+1)];if(A.length){const f=e.slice(i,i+A.length);if(!this.#i(f,A,o,0,0))return!1;i+=A.length,r+=A.length}let u=0;if(l.length){if(l.length+i\u003ee.length)return!1;let f=e.length-l.length;if(this.#i(e,l,o,f,0))u=l.length;else{if(e[e.length-1]!==\"\"||i+l.length===e.length||(f--,!this.#i(e,l,o,f,0)))return!1;u=l.length+1}}if(!c.length){let f=!!u;for(let I=i;I\u003ce.length-u;I++){const C=String(e[I]);if(f=!0,C===\".\"||C===\"..\"||!this.options.dot\u0026\u0026C.startsWith(\".\"))return!1}return o||f}const g=[[[],0]];let h=g[0],d=0;const p=[0];for(const f of c)f===kC?(p.push(d),h=[[],0],g.push(h)):(h[0].push(f),d++);let m=g.length-1;const _=e.length-u;for(const f of g)f[1]=_-(p[m--]+f[0].length);return!!this.#n(e,g,i,0,o,0,!!u)}#n(e,n,o,i,r,s,a){const A=n[i];if(!A){for(let u=o;u\u003ce.length;u++){a=!0;const g=e[u];if(g===\".\"||g===\"..\"||!this.options.dot\u0026\u0026g.startsWith(\".\"))return!1}return a}const[c,l]=A;for(;o\u003c=l;){if(this.#i(e.slice(0,o+c.length),c,r,o,0)\u0026\u0026s\u003cthis.maxGlobstarRecursion){const h=this.#n(e,n,o+c.length,i+1,r,s+1,a);if(h!==!1)return h}const g=e[o];if(g===\".\"||g===\"..\"||!this.options.dot\u0026\u0026g.startsWith(\".\"))return!1;o++}return r||null}#i(e,n,o,i,r){let s,a,A,c;for(s=i,a=r,c=e.length,A=n.length;s\u003cc\u0026\u0026a\u003cA;s++,a++){this.debug(\"matchOne loop\");let l=n[a],u=e[s];if(this.debug(n,l,u),l===!1||l===kC)return!1;let g;if(typeof l==\"string\"?(g=u===l,this.debug(\"string match\",l,u,g)):(g=l.test(u),this.debug(\"pattern match\",l,u,g)),!g)return!1}if(s===c\u0026\u0026a===A)return!0;if(s===c)return o;if(a===A)return s===c-1\u0026\u0026e[s]===\"\";throw new Error(\"wtf?\")}braceExpand(){return _fn(this.pattern,this.options)}parse(e){Xfe(e);const n=this.options;if(e===\"**\")return kC;if(e===\"\")return\"\";let o,i=null;(o=e.match(xji))?i=n.dot?Bji:Eji:(o=e.match(gji))?i=(n.nocase?n.dot?mji:pji:n.dot?hji:dji)(o[1]):(o=e.match(bji))?i=(n.nocase?n.dot?Qji:Sji:n.dot?vji:wji)(o):(o=e.match(_ji))?i=n.dot?Iji:fji:(o=e.match(Cji))\u0026\u0026(i=yji);const r=lXe.fromGlob(e,this.options).toMMPattern();return i\u0026\u0026typeof r==\"object\"\u0026\u0026Reflect.defineProperty(r,\"test\",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const e=this.set;if(!e.length)return this.regexp=!1,this.regexp;const n=this.options,o=n.noglobstar?Mji:n.dot?Dji:Nji,i=new Set(n.nocase?[\"i\"]:[]);let r=e.map(A=\u003e{const c=A.map(u=\u003e{if(u instanceof RegExp)for(const g of u.flags.split(\"\"))i.add(g);return typeof u==\"string\"?Lji(u):u===kC?kC:u._src});c.forEach((u,g)=\u003e{const h=c[g+1],d=c[g-1];u!==kC||d===kC||(d===void 0?h!==void 0\u0026\u0026h!==kC?c[g+1]=\"(?:\\\\/|\"+o+\"\\\\/)?\"+h:c[g]=o:h===void 0?c[g-1]=d+\"(?:\\\\/|\\\\/\"+o+\")?\":h!==kC\u0026\u0026(c[g-1]=d+\"(?:\\\\/|\\\\/\"+o+\"\\\\/)\"+h,c[g+1]=kC))});const l=c.filter(u=\u003eu!==kC);if(this.partial\u0026\u0026l.length\u003e=1){const u=[];for(let g=1;g\u003c=l.length;g++)u.push(l.slice(0,g).join(\"/\"));return\"(?:\"+u.join(\"|\")+\")\"}return l.join(\"/\")}).join(\"|\");const[s,a]=e.length\u003e1?[\"(?:\",\")\"]:[\"\",\"\"];r=\"^\"+s+r+a+\"$\",this.partial\u0026\u0026(r=\"^(?:\\\\/|\"+s+r.slice(1,-1)+a+\")$\"),this.negate\u0026\u0026(r=\"^(?!\"+r+\").+$\");try{this.regexp=new RegExp(r,[...i].join(\"\"))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(\"/\"):this.isWindows\u0026\u0026/^\\/\\/[^/]+/.test(e)?[\"\",...e.split(/\\/+/)]:e.split(/\\/+/)}match(e,n=this.partial){if(this.debug(\"match\",e,this.pattern),this.comment)return!1;if(this.empty)return e===\"\";if(e===\"/\"\u0026\u0026n)return!0;const o=this.options;this.isWindows\u0026\u0026(e=e.split(\"\\\\\").join(\"/\"));const i=this.slashSplit(e);this.debug(this.pattern,\"split\",i);const r=this.set;this.debug(this.pattern,\"set\",r);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s\u0026\u0026a\u003e=0;a--)s=i[a];for(const a of r){let A=i;if(o.matchBase\u0026\u0026a.length===1\u0026\u0026(A=[s]),this.matchOne(A,a,n))return o.flipNegate?!0:!this.negate}return o.flipNegate?!1:this.negate}static defaults(e){return d2.defaults(e).Minimatch}}d2.AST=lXe,d2.Minimatch=Hee,d2.escape=uji,d2.unescape=Lee;const Hji=t=\u003e(t.endsWith(\".tsx\")||t.endsWith(\".ts\")||t.endsWith(\".jsx\")||t.endsWith(\".js\")||$fe(t))\u0026\u0026!t.endsWith(\".d.ts\"),Oji=t=\u003e{if(!t)return null;try{const e=JSON.parse(t);return LDn.parse(e)}catch(e){return console.warn(\"Failed to parse tscircuit.config.json\",e),null}},Gji=(t,e)=\u003e{const o=Oji(e)?.includeBoardFiles?.filter(Boolean);if(o\u0026\u0026o.length\u003e0){const i=o.map(r=\u003enew Hee(r,{dot:!0}));return t.filter(r=\u003ei.some(s=\u003es.match(r)))}return t.filter(Hji)},uXe=vc(\"run-frame:RunFrameWithApi\"),Yji=()=\u003e{const e=!!md(o=\u003eo.error),n=e?\"Dev server disconnected\":\"Dev server connected\";return K.jsx(Fqe,{children:K.jsxs(Lqe,{children:[K.jsx(Hqe,{asChild:!0,children:K.jsx(\"button\",{type:\"button\",\"aria-label\":n,className:\"rf-inline-flex rf-items-center rf-justify-center rf-p-2 rf-rounded-full rf-outline-none\",children:K.jsx(\"span\",{className:Oi(\"rf-inline-flex rf-size-2 rf-rounded-full rf-flex-shrink-0\",e?\"rf-bg-red-600\":\"rf-bg-green-600 rf-opacity-50\"),\"aria-hidden\":\"true\"})})}),K.jsx(Kfe,{side:\"right\",children:n})]})})},Ifn=t=\u003et.find(e=\u003ee.includes(\"entrypoint.\"))??t.find(e=\u003ee.includes(\"index.\"))??t.find(e=\u003ee.includes(\"main.\"))??t.find(e=\u003ee.endsWith(\".tsx\")),Uji=t=\u003et.find(e=\u003ee.includes(\"manual-edits.\"))??t.find(e=\u003ee.includes(\"manual-edit.\"))??t.find(e=\u003ee.endsWith(\".json\")),Cfn=t=\u003e{const{apiBaseUrl:e,leftHeaderContent:n}=t;ee.useEffect(()=\u003e{t.debug\u0026\u0026vc.enable(\"run-frame*\")},[t.debug]);const o=md(k=\u003ek.startPolling),i=md(k=\u003ek.stopPolling),r=md(k=\u003ek.setCurrentMainComponentPath),s=md(k=\u003ek.pushEvent),a=zFo(),A=md(k=\u003ek.fsMap),c=md(k=\u003ek.recentlySavedFiles),l=ee.useMemo(()=\u003eArray.from(A.keys()),[A]),u=ee.useMemo(()=\u003e{const k=A.get(\"tscircuit.config.json\");return typeof k==\"string\"?k:void 0},[A]),g=ee.useMemo(()=\u003eGji(l,u),[l,u]),h=md(k=\u003ek.circuitJson),[d,p]=ee.useState(()=\u003etypeof window\u003e\"u\"?t.initialMainComponentPath??\"\":new URLSearchParams(window.location.hash.slice(1)).get(\"file\")??t.initialMainComponentPath??\"\"),[m,_]=OO(\"runframe:favorites\",[]),f=!a,I=ee.useCallback(k=\u003e{_(R=\u003eR.includes(k)?R.filter(F=\u003eF!==k):[...R,k])},[_]),C=t.fileFilter??aJi,y=ee.useMemo(()=\u003eg.filter(C),[g,C]);ee.useEffect(()=\u003e{if(d\u0026\u0026(y.includes(d)||g.includes(d)))return;if(d){const U=d.includes(\"/\")?d.substring(0,d.lastIndexOf(\"/\")):\"\",Y=y.find(W=\u003e(W.includes(\"/\")?W.substring(0,W.lastIndexOf(\"/\")):\"\")===U);if(Y){p(Y);return}}const k=window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,R=[t.initialMainComponentPath,k].filter(U=\u003e!!U);for(const U of R)if(y.includes(U)){p(U);return}const O=(y.length\u003e0?y:g)[0];O\u0026\u0026p(O)},[y,g,t.initialMainComponentPath,d]);const x=ee.useCallback(k=\u003e{if(typeof window\u003e\"u\")return;const R=new URLSearchParams(window.location.hash.slice(1));if(R.get(\"file\")===k)return;R.set(\"file\",k);const F=R.toString(),O=`${window.location.pathname}${window.location.search}${F.length\u003e0?`#${F}`:\"\"}`;window.history.replaceState(null,\"\",O)},[]);ee.useEffect(()=\u003e{d\u0026\u0026(x(d),t.onMainComponentPathChange?.(d),r(d))},[d,t.onMainComponentPathChange,x,r]),SWi();const{editEventsForRender:E,pushEditEvent:B,markRenderStarted:S,markRenderComplete:Q}=VFo();ee.useEffect(()=\u003e{e\u0026\u0026(window.TSCIRCUIT_FILESERVER_API_BASE_URL=e)},[e]),ee.useEffect(()=\u003e(o(),()=\u003ei()),[o,i]);const w=ee.useMemo(()=\u003eString(d).length\u003e0?{mainComponentPath:d}:{},[d]),M=ee.useCallback(async k=\u003e{try{await s({event_type:\"RUN_COMPLETED\",initiator:\"runframe\",...k})}catch(R){uXe(\"Failed to push RUN_COMPLETED event\",R)}},[s]);return K.jsx(P_n,{fsMap:A,showFileMenu:t.showFileMenu,shouldLoadLatestEval:t.shouldLoadLatestEval,onChangeShouldLoadLatestEval:t.onChangeShouldLoadLatestEval,isCli:t.isCli,schematicSvgOptions:t.schematicSvgOptions,isLoadingFiles:f,evalVersion:t.evalVersion,forceLatestEvalVersion:t.forceLatestEvalVersion,evalWebWorkerBlobUrl:t.evalWebWorkerBlobUrl??t.workerBlobUrl,platformConfig:t.platformConfig,enableFetchProxy:t.enableFetchProxy,leftHeaderContent:K.jsxs(\"div\",{className:\"rf-flex rf-items-center rf-justify-between rf-w-full\",children:[K.jsxs(\"div\",{className:\"rf-flex rf-items-center rf-gap-2\",children:[t.leftHeaderContent,K.jsx(Yji,{})]}),t.showFilesSwitch\u0026\u0026K.jsx(\"div\",{className:\"rf-absolute rf-left-1/2 rf-transform rf--translate-x-1/2\",children:K.jsx(Z_n,{currentFile:d,files:y,onFileChange:k=\u003e{typeof A.get(k)==\"string\"\u0026\u0026p(k)},pinnedFiles:m,onToggleFavorite:I,fileFilter:C,recentlySavedFiles:c})})]}),defaultToFullScreen:t.defaultToFullScreen,showToggleFullScreen:t.showToggleFullScreen,onInitialRender:()=\u003e{uXe(\"onInitialRender / markRenderStarted\"),S()},onRenderFinished:()=\u003e{uXe(\"onRenderFinished / markRenderComplete\"),Q()},onRunCompleted:M,editEvents:E,onEditEvent:k=\u003e{B(k),fetch(`${QC}/events/create`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({event_type:\"USER_CREATED_MANUAL_EDIT\",...k})});const R=Uji(Array.from(A.keys()))??\"manual-edits.json\",F=A.get(R),O=JSON.parse(F??\"{}\");VRt({circuitJson:h,editEvents:[k],manualEditsFile:O}),fetch(`${QC}/files/upsert`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({file_path:R,text_content:JSON.stringify(O),initiator:\"runframe\"})})},onLoginRequired:t.onLoginRequired,easyEdaProxyConfig:{proxyEndpointUrl:`${QC}/proxy`},...w})},Kji=()=\u003enew Promise(t=\u003e{document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",()=\u003et()):t()}),Vji=()=\u003e{const t=window.location.hash.slice(1),n=new URLSearchParams(t).get(\"tab\")?.toLowerCase()?.trim();return n\u0026\u0026[\"pcb\",\"schematic\",\"cad\"].includes(n)?n:\"pcb\"},zji=()=\u003e{const t=document.getElementById(\"root\");if(t)return t;const e=document.createElement(\"div\");return e.id=\"root\",e.style.height=\"100vh\",document.body.appendChild(e),e},Jji=async()=\u003e{const t=Array.from(document.querySelectorAll(\"script[type='tscircuit-tsx']\")),e=new Map;return await Promise.all(t.map(async(n,o)=\u003e{const i=n.dataset.path||n.getAttribute(\"data-file-path\")||`script${o?o+1:\"\"}.tsx`;if(n.src){const s=await(await fetch(n.src)).text();e.set(i,s)}else e.set(i,n.textContent||\"\")})),{fsMap:e}},yfn=\"\u003c--INJECT_TSCIRCUIT_EVAL_WEB_WORKER_BLOB_URL--\u003e\",gXe={evalWebWorkerBlobUrl:yfn.includes(\"\u003c--\")?void 0:yfn,enableFetchProxy:\"\u003c--INJECT_ENABLE_FETCH_PROXY--\u003e\".includes(\"\u003c--\")?void 0:!0};(async()=\u003e{await Kji();const t=H4n.createRoot(zji()),e=window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST,n=window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,o=window.TSCIRCUIT_PACKAGE_NAME;if(Array.isArray(e)){const i=Vji();t.render(K.jsx(bWi,{files:e,initialCircuitPath:n,tabSelected:i,projectName:o}))}else if(window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI)t.render(K.jsx(yJi,{...gXe}));else{const{fsMap:i}=await Jji();i.size\u003e0?t.render(K.jsx(P_n,{...gXe,fsMap:i})):t.render(K.jsx(Cfn,{...gXe}))}})();const xfn=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:\"Module\"}));var Wji=0,o8=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(t={}){this.hasExplicitNodeId=t.nodeId!==void 0,this._nodeId=t.nodeId??Efn(t.sourceLocation,this.constructor.name)??`altium-node-${(++Wji).toString(36)}`,this._sourceLocation=t.sourceLocation}get document(){let t=this;for(;t.parent;)t=t.parent;return t}get nodeId(){return this._nodeId}get isDirty(){return this._dirty}get parent(){return this._parent}get revision(){return this._revision}get sourceLocation(){return this._sourceLocation}setParent(t){return this._parent=t,this}setSourceLocation(t){return this._sourceLocation=t,this.hasExplicitNodeId||(this._nodeId=Efn(t,this.constructor.name)??this._nodeId),this}adoptChildren(t){for(const e of t)e.setParent(this)}markDirty(){this._dirty=!0,this._revision++,this.parent?.markDirty()}clearDirty(t=!1){if(this._dirty=!1,t)for(const e of this.getChildren())e.clearDirty(!0)}*walk(t=!0){t\u0026\u0026(yield this);for(const e of this.getChildren())yield*e.walk(!0)}visit(t){const e=(n,o,i)=\u003e{if(t(n,{depth:i,parent:o})!==!1)for(const s of n.getChildren())e(s,n,i+1)};e(this,this.parent,0)}findAll(t,e=!0){return[...this.walk(e)].filter(t)}deepEquals(t){if(this.type!==t.type||this.getString()!==t.getString())return!1;const e=this.getChildren(),n=t.getChildren();return e.length===n.length\u0026\u0026e.every((o,i)=\u003e{const r=n[i];return r!==void 0\u0026\u0026o.deepEquals(r)})}getStructuralHash(){let t=2166136261;const e=`${this.type}\\0${this.getString()}`;for(let n=0;n\u003ce.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t\u003e\u003e\u003e0).toString(16).padStart(8,\"0\")}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,text:this.getString(),children:this.getChildren().map(t=\u003et.toJSON())}}};function Efn(t,e){if(!t)return;const n=t.streamPath!==void 0?[t.streamPath,t.recordIndex??\"\",t.fieldIndex??\"\",t.byteOffset??\"\"].join(\":\"):t.startOffset!==void 0?`text:${t.startOffset}`:t.byteOffset!==void 0?`byte:${t.byteOffset}`:void 0;return n===void 0?void 0:`${n}:${e}`}var ek=class extends Error{code;constructor(t,e=\"ALTIUM_ERROR\",n){super(t,n),this.name=new.target.name,this.code=e}},eM=class extends ek{excerpt;fieldName;location;recordKind;constructor(t,e={}){super(t,\"ALTIUM_SYNTAX\",{cause:e.cause}),this.excerpt=e.excerpt,this.fieldName=e.fieldName,this.location=e.location,this.recordKind=e.recordKind}},yI=class extends ek{constructor(t,e){super(t,\"ALTIUM_FORMAT_DETECTION\",e)}},aA=class extends ek{byteOffset;constructor(t,e={}){super(t,\"ALTIUM_CORRUPT_CONTAINER\",{cause:e.cause}),this.byteOffset=e.byteOffset}},jji=class extends ek{constructor(t,e){super(t,\"ALTIUM_UNSUPPORTED_VERSION\",e)}},dXe=class extends ek{constructor(t,e){super(t,\"ALTIUM_UNSUPPORTED_FEATURE\",e)}},Yg=class extends ek{constructor(t,e){super(t,\"ALTIUM_SERIALIZATION\",e)}},hh=class extends ek{byteOffset;constructor(t,e,n){super(t,\"ALTIUM_TRUNCATED_RECORD\",n),this.byteOffset=e}},$ji=class extends o8{type=\"embedded-model\";index;record;stream;constructor(t){super({sourceLocation:t.stream.sourceLocation}),this.index=t.index,this.record=t.record,this.stream=t.stream}get compressedSize(){return this.stream.metadata.size}get isCompressedDataLoaded(){return this.stream.isContentLoaded}getCompressedBytes(){return this.stream.content.slice()}async getDecompressedBytes(t={}){return qji(this.stream.content,t)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function qji(t,e={}){const n=e.maximumOutputSize??67108864;if(!Number.isSafeInteger(n)||n\u003c=0)throw new RangeError(\"maximumOutputSize must be a positive safe integer number of bytes\");const o=[];let i=0;try{const a=new Lce(c=\u003e{if(i+=c.byteLength,i\u003en)throw new aA(`Embedded model expands beyond the ${n}-byte limit`);o.push(c)}),A=64*1024;for(let c=0;c\u003ct.byteLength;){const l=Math.min(c+A,t.byteLength);a.push(t.subarray(c,l),l===t.byteLength),c=l}}catch(a){throw a instanceof aA?a:new aA(`Embedded model zlib decompression failed: ${a instanceof Error?a.message:String(a)}`)}const r=new Uint8Array(i);let s=0;for(const a of o)r.set(a,s),s+=a.byteLength;return r}function xI(t){if(!Number.isFinite(t))return t;const e=(t%360+360)%360;return Object.is(e,-0)?0:e}function hXe(t,e,n=1e-9){return Math.abs(t.x-e.x)\u003c=n\u0026\u0026Math.abs(t.y-e.y)\u003c=n}function Xji(t){if(t.length===0)return;let e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of t)!Number.isFinite(r.x)||!Number.isFinite(r.y)||(e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x),i=Math.max(i,r.y));return Number.isFinite(e)?{minX:e,minY:n,maxX:o,maxY:i}:void 0}function Zji(t){if(t.length\u003c3)return 0;let e=0;for(let n=0;n\u003ct.length;n++){const o=t[n],i=t[(n+1)%t.length];!o||!i||(e+=o.x*i.y-i.x*o.y)}return e/2}function e$i(t){const e=Zji(t);return Math.abs(e)\u003c=Number.EPSILON?\"degenerate\":e\u003c0?\"clockwise\":\"counterclockwise\"}var pXe=class extends o8{terminator;constructor(t={}){super(t),this.terminator=t.terminator??\"\"}},a9=class extends o8{type=\"field\";_key;_value;constructor(t){super(t),Bfn(t.key),bfn(t.value??\"\"),this._key=t.key,this._value=t.value??\"\"}get key(){return this._key}set key(t){Bfn(t),t!==this._key\u0026\u0026(this._key=t,this.markDirty())}get value(){return this._value}set value(t){bfn(t),t!==this._value\u0026\u0026(this._value=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.key}=${this.value}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,key:this.key,value:this.value}}};function Bfn(t){if(t.length===0||/[=|\\r\\n]/u.test(t))throw new Error(`Invalid Altium field key: ${JSON.stringify(t)}`)}function bfn(t){if(/[|\\r\\n]/u.test(t))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(t)}`)}var t$i={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},n$i=/^([+-]?(?:\\d+\\.\\d*|\\d+|\\.\\d+)(?:e[+-]?\\d+)?)([a-z]+)?$/iu,Oee=class S4n{unit;value;#o;constructor(e){if(!Number.isFinite(e.value))throw new RangeError(\"Altium measurement value must be finite\");this.value=e.value,this.unit=e.unit,this.#o=e.raw??`${r$i(e.value)}${e.unit===void 0?\"\":e.unit}`}static parse(e){const n=n$i.exec(e.trim());if(!n?.[1])return;const o=Number(n[1]);if(Number.isFinite(o))return new S4n({raw:e,unit:n[2],value:o})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#o}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(t$i[this.normalizedUnit]??1)}toMillimeters(){return this.toMils()*.0254}to(e){const n=this.toMils();return e===\"mil\"?n:e===\"mm\"?n*.0254:e===\"cm\"?n*.00254:n/1e3}equals(e,n=0){return Math.abs(this.toMils()-e.toMils())\u003c=n}toString(){return this.raw}toJSON(){return{raw:this.raw,unit:this.unit,value:this.value}}};function oK(t){return t===void 0?void 0:Oee.parse(t)}function Gee(t){return oK(t)?.toMils()}function o$i(t,e=\"mil\"){if(t instanceof Oee)return t;if(typeof t==\"string\"){const n=Oee.parse(t);if(!n)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(t)}`);return n}return typeof t==\"number\"?new Oee({unit:e,value:t}):new Oee(t)}function i$i(t,e=\"mil\"){return o$i(t,e).toString()}function r$i(t){return Object.is(t,-0)?\"-0\":String(t)}var Ol=class extends pXe{type=\"record\";items;_originalBinaryPayload;constructor(t={}){super(t),this.items=t.items??[],this._originalBinaryPayload=t.originalBinaryPayload?.slice(),this.adoptChildren(this.items)}get originalBinaryPayload(){return this._originalBinaryPayload?.slice()}setOriginalBinaryPayload(t){return this._originalBinaryPayload=t?.slice(),this}getAltiumMeasurement(t){return oK(this.getCaseInsensitive(t))}get recordKind(){return this.get(\"RECORD\")}get fields(){return this.items.filter(t=\u003et instanceof a9)}get(t){return this.fields.find(e=\u003ee.key===t)?.value}getCaseInsensitive(t){const e=t.toUpperCase();return this.fields.find(n=\u003en.key.toUpperCase()===e)?.value}getDecoded(t){const e=this.getCaseInsensitive(`%UTF8%${t}`);return e===void 0?this.getCaseInsensitive(t):A$i(e)}getAll(t){return this.fields.filter(e=\u003ee.key===t).map(e=\u003ee.value)}getFirstField(t){return this.fields.find(e=\u003ee.key===t)}getLastField(t){return this.fields.findLast(e=\u003ee.key===t)}getAllFields(t){return this.fields.filter(e=\u003ee.key===t)}getBoolean(t){const e=this.getCaseInsensitive(t)?.toUpperCase();if(e===\"TRUE\"||e===\"T\")return!0;if(e===\"FALSE\"||e===\"F\")return!1}getNumber(t){const e=this.getCaseInsensitive(t);if(!(e===void 0||!s$i(e)))return Number(e)}getMeasurement(t){const e=this.getCaseInsensitive(t);if(e===void 0)return;const n=/^\\s*([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?)\\s*([a-z]+)?\\s*$/iu.exec(e);if(!n?.[1])return;const o=n[2];return o===void 0?{value:Number(n[1])}:{value:Number(n[1]),unit:o}}set(t,e){const n=this.fields.find(o=\u003eo.key===t);if(n)n.value=e;else{const o=new a9({key:t,value:e}).setParent(this);this.items.push(o),this.markDirty()}return this}setMeasurement(t,e,n=\"mil\"){return this.set(t,i$i(e,n))}setPoint(t,e,n=\"mil\"){return this.setMeasurement(t.x,e.x,n),this.setMeasurement(t.y,e.y,n),this}setSize(t,e,n=\"mil\"){return this.setMeasurement(t.width,e.width,n),this.setMeasurement(t.height,e.height,n),this}setAngle(t,e){if(!Number.isFinite(e))throw new RangeError(\"Altium angles must be finite\");return this.set(t,String(xI(e)))}insertField(t,e,n={}){const o=new a9({key:t,value:e}).setParent(this);let i=n.index;if(i===void 0\u0026\u0026n.beforeKey!==void 0\u0026\u0026(i=this.items.findIndex(s=\u003es instanceof a9\u0026\u0026s.key===n.beforeKey)),i===void 0\u0026\u0026n.afterKey!==void 0){const s=this.items.findLastIndex(a=\u003ea instanceof a9\u0026\u0026a.key===n.afterKey);i=s\u003c0?this.items.length:s+1}const r=i===void 0?this.items.length:Math.min(Math.max(i,0),this.items.length);return this.items.splice(r,0,o),this.markDirty(),o}replaceFieldOccurrence(t,e,n){if(!Number.isInteger(e)||e\u003c0)return!1;const o=this.getAllFields(t)[e];return o?(o.value=n,!0):!1}delete(t){const e=this.items.length;this.items=this.items.filter(o=\u003e!(o instanceof a9\u0026\u0026o.key===t));const n=e-this.items.length;return n\u003e0\u0026\u0026this.markDirty(),n}getChildren(){return[...this.items]}getString(){return`|${this.items.map(t=\u003et.getString()).join(\"|\")}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,recordKind:this.recordKind,originalBinaryPayloadLength:this._originalBinaryPayload?.byteLength,fields:this.fields.map(t=\u003e({key:t.key,value:t.value})),items:this.items.map(t=\u003et.toJSON())}}};function s$i(t){return/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?$/iu.test(t.trim())}var a$i=new Map([[\"€\",128],[\"‚\",130],[\"ƒ\",131],[\"„\",132],[\"…\",133],[\"†\",134],[\"‡\",135],[\"ˆ\",136],[\"‰\",137],[\"Š\",138],[\"‹\",139],[\"Œ\",140],[\"Ž\",142],[\"‘\",145],[\"’\",146],[\"“\",147],[\"”\",148],[\"•\",149],[\"–\",150],[\"—\",151],[\"˜\",152],[\"™\",153],[\"š\",154],[\"›\",155],[\"œ\",156],[\"ž\",158],[\"Ÿ\",159]]);function A$i(t){const e=[];for(const n of t){const o=a$i.get(n);if(o!==void 0){e.push(o);continue}const i=n.codePointAt(0);if(i===void 0||i\u003e255)return t;e.push(i)}try{return new TextDecoder(\"utf-8\",{fatal:!0}).decode(Uint8Array.from(e))}catch{return t}}function tc(t,...e){for(const n of e){const o=Gee(t.getCaseInsensitive(n));if(o!==void 0)return o}}function qh(t,e,n){const o=tc(t,...e),i=tc(t,...n);return o===void 0||i===void 0?void 0:{x:o,y:i}}function Yee(t,e,n){const o=tc(t,...e),i=tc(t,...n);return o===void 0||i===void 0?void 0:{width:o,height:i}}function pi(t,...e){for(const n of e){const o=t.getDecoded(n);if(o!==void 0)return o}}function c$i(t,...e){for(const n of e){const o=t.getNumber(n);if(o!==void 0)return o}}var e1e=class extends Ol{type=\"component-record\";constructor(t={}){super(t)}get id(){return this.getNumber(\"ID\")}get designator(){return pi(this,\"SOURCEDESIGNATOR\",\"DESIGNATOR\")}get comment(){return pi(this,\"SOURCECOMMENT\",\"COMMENT\")}get footprint(){return pi(this,\"PATTERN\",\"FOOTPRINT\")}get footprintLibrary(){return pi(this,\"SOURCEFOOTPRINTLIBRARY\")}get sourceLibrary(){return pi(this,\"SOURCECOMPONENTLIBRARY\")}get sourceLibraryReference(){return pi(this,\"SOURCELIBREFERENCE\")}get sourceUniqueId(){return pi(this,\"SOURCEUNIQUEID\")}get sourceHierarchicalPath(){return pi(this,\"SOURCEHIERARCHICALPATH\")}get position(){return qh(this,[\"X\",\"LOCATION.X\"],[\"Y\",\"LOCATION.Y\"])}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get side(){const t=this.getCaseInsensitive(\"LAYER\")?.toUpperCase();return t===\"TOP\"||t===\"TOP LAYER\"?\"top\":t===\"BOTTOM\"||t===\"BOTTOM LAYER\"?\"bottom\":\"unknown\"}get mirrored(){return this.side===\"bottom\"}get locked(){return this.getBoolean(\"LOCKED\")}get selected(){return this.getBoolean(\"SELECTION\")}get unionIndex(){return this.getNumber(\"UNIONINDEX\")}get channelOffset(){return this.getNumber(\"CHANNELOFFSET\")}get heightMils(){return tc(this,\"HEIGHT\")}getOwnedPrimitives(t){return t.getRecordsOwnedByComponent(this)}getBounds(t,e){return t.getComponentBounds(this,e)}},t1e=class extends Ol{type=\"net-record\";constructor(t={}){super(t)}get id(){return this.getNumber(\"ID\")}get name(){return pi(this,\"NAME\")}get visible(){return this.getBoolean(\"VISIBLE\")}get color(){return this.getNumber(\"COLOR\")}},l$i=65535,Sfn=new WeakMap,u$i=class{constructor(t){this.document=t,this.components=t.getRecordsByKind(\"Component\").filter(e=\u003ee instanceof e1e),this.nets=t.getRecordsByKind(\"Net\").filter(e=\u003ee instanceof t1e),this.polygons=t.getRecordsByKind(\"Polygon\"),this.rules=[...t.getRecordsByKind(\"Rule\"),...t.getRecordsByKind(\"DXPRule\")],this.componentTargets=o1e(this.components),this.netTargets=o1e(this.nets),this.polygonTargets=o1e(this.polygons),this.ruleTargets=o1e(this.rules);for(const e of t.records){fXe(this.byKind,e.recordKind??\"Unknown\",e);const n=e.getDecoded(\"LAYER\");n!==void 0\u0026\u0026fXe(this.byLayer,n.toUpperCase(),e),i1e(this.byComponent,e,\"COMPONENT\"),i1e(this.byNet,e,\"NET\"),i1e(this.byPolygon,e,\"POLYGON\"),i1e(this.byRule,e,\"RULE\");const o=e.getDecoded(\"UNIQUEID\");if(!o)continue;const i=o.toUpperCase(),r=this.uniqueIds.get(i);if(!r){this.uniqueIds.set(i,e);continue}const s=this.duplicateUniqueIds.get(i)??[r];s.push(e),this.duplicateUniqueIds.set(i,s)}}document;byComponent=new Map;byKind=new Map;byLayer=new Map;byNet=new Map;byPolygon=new Map;byRule=new Map;components;duplicateUniqueIds=new Map;nets;polygons;rules;uniqueIds=new Map;componentTargets;netTargets;polygonTargets;ruleTargets;getComponent(t){return nk(t)?this.componentTargets.get(t):void 0}getNet(t){return nk(t)?this.netTargets.get(t):void 0}getPolygon(t){return nk(t)?this.polygonTargets.get(t):void 0}getRule(t){return nk(t)?this.ruleTargets.get(t):void 0}getRecordByUniqueId(t){return this.uniqueIds.get(t.toUpperCase())}getDanglingReferences(){const t=[],e=[[\"COMPONENT\",this.componentTargets],[\"NET\",this.netTargets],[\"POLYGON\",this.polygonTargets],[\"RULE\",this.ruleTargets]];for(const n of this.document.records)for(const[o,i]of e){const r=tk(n,o);r!==void 0\u0026\u0026!i.has(r)\u0026\u0026t.push({field:o,index:r,record:n})}return t}};function rg(t){const e=Sfn.get(t);if(e?.revision===t.revision)return e.index;const n=new u$i(t);return Sfn.set(t,{index:n,revision:t.revision}),n}function Qfn(t,e){return rg(t).getComponent(e)}function vfn(t,e){return rg(t).getNet(e)}function wfn(t,e){return rg(t).getPolygon(e)}function Pfn(t,e){return rg(t).getRule(e)}function mXe(t,e){return e instanceof e1e?tM(rg(t).components,e):tk(e,\"COMPONENT\")}function _Xe(t,e){return e instanceof t1e?tM(rg(t).nets,e):tk(e,\"NET\")}function g$i(t,e){return e.recordKind===\"Polygon\"?tM(rg(t).polygons,e):tk(e,\"POLYGON\")}function d$i(t,e){return e.recordKind===\"Rule\"||e.recordKind===\"DXPRule\"?tM(rg(t).rules,e):tk(e,\"RULE\")??tk(e,\"RULEINDEX\")}function Mfn(t,e){const n=mXe(t,e);return n===void 0?void 0:rg(t).getComponent(n)}function Dfn(t,e){const n=_Xe(t,e);return n===void 0?void 0:rg(t).getNet(n)}function Nfn(t,e){const n=g$i(t,e);return n===void 0?void 0:rg(t).getPolygon(n)}function Rfn(t,e){const n=d$i(t,e);return n===void 0?void 0:rg(t).getRule(n)}function n1e(t,e){const n=typeof e==\"number\"?e:tM(rg(t).components,e);return n===void 0?[]:[...rg(t).byComponent.get(n)??[]]}function Tfn(t,e){const n=typeof e==\"number\"?e:tM(rg(t).nets,e);return n===void 0?[]:[...rg(t).byNet.get(n)??[]]}function kfn(t,e){const n=typeof e==\"number\"?e:tM(rg(t).polygons,e);return n===void 0?[]:[...rg(t).byPolygon.get(n)??[]]}function Ffn(t,e){const n=typeof e==\"number\"?e:tM(rg(t).rules,e);return n===void 0?[]:[...rg(t).byRule.get(n)??[]]}function o1e(t){const e=new Map,n=t.some(o=\u003eo.getNumber(\"ID\")!==void 0);return t.forEach((o,i)=\u003e{const r=n?o.getNumber(\"ID\"):i;r!==void 0\u0026\u0026nk(r)\u0026\u0026e.set(r,o)}),e}function tM(t,e){if(t.some(i=\u003ei.getNumber(\"ID\")!==void 0)){const i=e.getNumber(\"ID\");return i!==void 0\u0026\u0026nk(i)?i:void 0}const o=t.indexOf(e);return o\u003e=0?o:void 0}function i1e(t,e,n){const o=tk(e,n);o!==void 0\u0026\u0026fXe(t,o,e)}function fXe(t,e,n){const o=t.get(e);o?o.push(n):t.set(e,[n])}function tk(t,e){const n=t.getNumber(e);return n!==void 0\u0026\u0026nk(n)?n:void 0}function nk(t){return Number.isInteger(t)\u0026\u0026t\u003e=0\u0026\u0026t\u003cl$i}var Lfn=1e5,h$i=1e4;function IXe(t){return a1e(p$i(t))}function p$i(t){return Hfn(Ufn(t))}function Hfn(t){const e=[];for(let n=0;n\u003cLfn;n++){const o=ok(t,`VX${n}`),i=ok(t,`VY${n}`);if(o===void 0||i===void 0)break;const r=yXe(t,`KIND${n}`),s={x:o,y:i};if(r!==1){e.push({index:n,kind:r===void 0||r===0?\"line\":\"unknown\",position:s,rawKind:r});continue}const a=ok(t,`CX${n}`),A=ok(t,`CY${n}`),c=ok(t,`R${n}`),l=yXe(t,`SA${n}`),u=yXe(t,`EA${n}`),g=a!==void 0\u0026\u0026A!==void 0\u0026\u0026c!==void 0\u0026\u0026c\u003e0\u0026\u0026l!==void 0\u0026\u0026u!==void 0?{center:{x:a,y:A},endAngleDegrees:u,radiusMils:c,startAngleDegrees:l}:void 0;e.push({arc:g,index:n,kind:g?\"arc\":\"unknown\",position:s,rawKind:r})}return e}function r1e(t){const e=Ufn(t),n=[],o=Kfn(e.get(\"HOLECOUNT\"),h$i);for(let i=0;i\u003co;i++){const r=Kfn(e.get(`HOLE${i}COUNT`),Lfn),s=[];for(let a=0;a\u003cr;a++){const A=ok(e,`HOLE${i}VX${a}`),c=ok(e,`HOLE${i}VY${a}`);if(A===void 0||c===void 0)break;s.push({index:a,kind:\"line\",position:{x:A,y:c},rawKind:0})}s.length\u003e=3\u0026\u0026n.push(a1e(s))}return{holes:n,outline:a1e(Hfn(e)),record:t}}function Ofn(t){const e=t.board?IXe(t.board):a1e([]),n=t.records.filter(o=\u003eo.recordKind===\"BoardRegion\"||o.recordKind===\"Region\");return{cutouts:n.filter(o=\u003es1e(o)===\"BOARD_CUTOUT\").map(r1e),layerStackRegions:n.filter(o=\u003es1e(o)===\"LAYER_STACK_REGION\").map(r1e),outline:e,polygonCutouts:n.filter(o=\u003es1e(o)===\"POLYGON_CUTOUT\").map(r1e)}}function s1e(t){if(t.recordKind===\"BoardRegion\"||t.getDecoded(\"OBJECTKIND\")?.toUpperCase()===\"BOARDREGION\"||t.getDecoded(\"LAYERSTACKID\")!==void 0)return\"LAYER_STACK_REGION\";const n=(t.getDecoded(\"REGIONKIND\")??t.getDecoded(\"KIND\")??void 0)?.replace(/[\\s-]+/gu,\"_\").toUpperCase();return n===\"0\"?t.getBoolean(\"ISBOARDCUTOUT\")===!0?\"BOARD_CUTOUT\":\"COPPER\":n===\"1\"?\"POLYGON_CUTOUT\":n===\"2\"?\"DASHED_OUTLINE\":n===\"3\"?\"UNKNOWN_3\":n===\"4\"?\"CAVITY_DEFINITION\":n}function a1e(t){const e=[];for(const i of t){if(!i.arc){Yfn(e,i.position);continue}for(const r of m$i(i.position,i.arc))Yfn(e,r)}const n=e[0],o=e.at(-1);return{bounds:Xji(e),isExplicitlyClosed:n!==void 0\u0026\u0026o!==void 0\u0026\u0026hXe(n,o,1e-4),points:e,vertices:t,winding:e$i(e)}}function m$i(t,e){const n=CXe(e.center,e.radiusMils,e.startAngleDegrees),o=CXe(e.center,e.radiusMils,e.endAngleDegrees),i=_$i(e.endAngleDegrees-e.startAngleDegrees)||360,r=Gfn(t,n)\u003c=Gfn(t,o),s=r?e.startAngleDegrees:e.endAngleDegrees,a=r?i:-i,A=Math.max(2,Math.ceil(Math.abs(a)/7.5)),c=[];for(let l=0;l\u003c=A;l++)c.push(CXe(e.center,e.radiusMils,s+a*l/A));return c}function CXe(t,e,n){const o=n*Math.PI/180;return{x:t.x+Math.cos(o)*e,y:t.y+Math.sin(o)*e}}function _$i(t){return(t%360+360)%360}function Gfn(t,e){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o}function Yfn(t,e){const n=t.at(-1);n\u0026\u0026hXe(n,e,1e-4)||t.push(e)}function Ufn(t){const e=new Map;for(const n of t.fields){const o=n.key.toUpperCase();e.has(o)||e.set(o,n.value)}return e}function ok(t,e){return Gee(t.get(e.toUpperCase()))}function yXe(t,e){const n=Number(t.get(e.toUpperCase()));return Number.isFinite(n)?n:void 0}function Kfn(t,e){const n=Number(t??0);return Number.isInteger(n)?Math.min(Math.max(n,0),e):0}var Vfn=class extends Ol{type=\"dimension-record\";constructor(t={}){super(t)}get dimensionKind(){return pi(this,\"DIMENSIONKIND\",\"KIND\")}get start(){return this.referencePoints[0]??qh(this,[\"X1\"],[\"Y1\"])}get end(){return this.referencePoints[1]??qh(this,[\"X2\"],[\"Y2\"])}get dimensionLineAnchor(){return qh(this,[\"X1\"],[\"Y1\"])}get referencePoints(){return zfn({pointInfix:\"POINT\",prefix:\"REFERENCE\",record:this})}get textPoints(){const t=qh(this,[\"TEXTX\"],[\"TEXTY\"]);return t?[t]:zfn({pointInfix:\"\",prefix:\"TEXT\",record:this})}get unit(){return pi(this,\"TEXTDIMENSIONUNIT\",\"DIMENSIONUNIT\",\"UNIT\")}get precision(){return c$i(this,\"TEXTPRECISION\",\"PRECISION\")??tc(this,\"TEXTPRECISION\",\"PRECISION\")}get prefix(){return pi(this,\"TEXTPREFIX\",\"PREFIX\")}get suffix(){return pi(this,\"TEXTSUFFIX\",\"SUFFIX\")}get lineWidthMils(){return tc(this,\"LINEWIDTH\",\"ARROWLINEWIDTH\",\"WIDTH\")}get textHeightMils(){return tc(this,\"TEXTHEIGHT\",\"HEIGHT\")}};function zfn({pointInfix:t,prefix:e,record:n}){const o=[],i=e===\"REFERENCE\"?n.getNumber(\"REFERENCES_COUNT\"):void 0,r=Math.min(Math.max(i??100,0),1e4),s=e===\"REFERENCE\"?0:1;for(let a=s;a\u003cs+r;a++){const A=qh(n,[`${e}${a}${t}X`],[`${e}${a}${t}Y`]);if(!A)break;o.push(A)}return o}var f$i=class extends Ol{type=\"coordinate-record\";get position(){return qh(this,[\"X\",\"LOCATION.X\"],[\"Y\",\"LOCATION.Y\"])}};function I$i(t){return t.replace(/[\\s_-]/gu,\"\").toUpperCase()}function iK(t){return Gee(t)}function Md(t,e,n=0){return iK(t.getCaseInsensitive(e))??n}function C$i(t){return IXe(t).points}function y$i(t){if(!(t instanceof Vfn))return;const e=t,n=e.start,o=e.end;if(!n||!o)return;const i=o.x-n.x,r=o.y-n.y,s=Math.hypot(i,r);if(s===0)return;const a=-r/s,A=i/s,c=e.dimensionLineAnchor??n,l=(c.x-n.x)*a+(c.y-n.y)*A,u={x:n.x+a*l,y:n.y+A*l},g={x:o.x+a*l,y:o.y+A*l},h=e.textPoints[0]??{x:(u.x+g.x)/2,y:(u.y+g.y)/2},d=x$i({dimension:e,measuredDistanceMils:s}),p=e.textHeightMils??50,m=Jfn({fallbackMils:10,fieldName:\"TEXTGAP\",record:t});return{arrowSize:Jfn({fallbackMils:40,fieldName:\"ARROWSIZE\",record:t}),dimensionEnd:g,dimensionStart:u,estimatedTextHalfWidth:d.length*p*.3+m,label:d,lineWidth:e.lineWidthMils??8,referenceEnd:o,referenceStart:n,textHeight:p,textPosition:h}}function x$i({dimension:t,measuredDistanceMils:e}){const n=t.getDecoded(\"TEXTFORMAT\")?.trim();if(n\u0026\u0026n!==\"\u003c\u003e\")return n;const o=Math.min(Math.max(t.precision??2,0),6),i=t.unit?.toUpperCase()??\"MILS\",{amount:r,unitLabel:s}=E$i({measuredDistanceMils:e,normalizedUnit:i}),a=t.prefix??\"\",A=t.suffix??` ${s}`;return`${a}${r.toFixed(o)}${A}`}function E$i({measuredDistanceMils:t,normalizedUnit:e}){return e.includes(\"MILLIMETER\")?{amount:t*.0254,unitLabel:\"mm\"}:e.includes(\"CENTIMETER\")?{amount:t*.00254,unitLabel:\"cm\"}:e.includes(\"INCH\")?{amount:t/1e3,unitLabel:\"in\"}:{amount:t,unitLabel:\"mil\"}}function Jfn({fallbackMils:t,fieldName:e,record:n}){return n.getAltiumMeasurement(e)?.toMils()??t}var xXe=I$i;function B$i(t,e){const n=S$i(t,e),o=t.getNumber(\"PADMODE\")??0,i=b$i(t,n,o),r=t.getCaseInsensitive(`LAYER${n}ALTSHAPE`)?.toUpperCase(),s=Number(t.getCaseInsensitive(`LAYER${n}CORNERRADIUS`)??0),a=r===\"ROUNDRECT\"\u0026\u0026Number.isFinite(s)?Math.min(i.width,i.height)*s/200:0,A=t.getNumber(\"HOLETYPE\"),c=t.getCaseInsensitive(\"HOLESHAPE\")?.toUpperCase()??(A===1?\"SQUARE\":A===2?\"SLOT\":\"ROUND\"),l=Md(t,\"HOLESIZE\"),u=iK(t.getCaseInsensitive(\"SLOTLENGTH\"))??(c===\"SLOT\"?iK(t.getCaseInsensitive(\"HOLEWIDTH\")):void 0)??l;return{cornerRadius:a,height:i.height,holeOffsetX:Md(t,`LAYER${n}HOLEXOFFSET`,Md(t,`PADXOFFSET${n}`)),holeOffsetY:Md(t,`LAYER${n}HOLEYOFFSET`,Md(t,`PADYOFFSET${n}`)),holeRotation:Number(t.getCaseInsensitive(\"SLOTROTATION\")??t.getCaseInsensitive(\"HOLEROTATION\")??0),holeShape:c,holeSize:l,layerOrdinal:n,plated:t.getBoolean(\"PLATED\")!==!1,rotation:Number(t.getCaseInsensitive(\"ROTATION\")??0),shape:r===\"ROUNDRECT\"?r:i.shape,slotLength:u,width:i.width,x:Md(t,\"X\"),y:Md(t,\"Y\")}}function b$i(t,e,n){if(!(xXe(t.getCaseInsensitive(\"LAYER\")??\"\")===\"MULTILAYER\")||n===0||e===0)return{height:FS(t,[\"YSIZE\",\"TOPYSIZE\"])??FS(t,[\"XSIZE\",\"TOPXSIZE\"])??20,shape:A1e(t,[\"SHAPE\",\"TOPSHAPE\"])?.toUpperCase()??\"ROUND\",width:FS(t,[\"XSIZE\",\"TOPXSIZE\"])??20};if(e===31){const s=FS(t,[\"BOTTOMXSIZE\",\"BOTXSIZE\",\"XSIZE\",\"TOPXSIZE\"])??20;return{height:FS(t,[\"BOTTOMYSIZE\",\"BOTYSIZE\",\"YSIZE\",\"TOPYSIZE\"])??s,shape:A1e(t,[\"BOTTOMSHAPE\",\"BOTSHAPE\",\"SHAPE\",\"TOPSHAPE\"])?.toUpperCase()??\"ROUND\",width:s}}if(n===2\u0026\u0026e\u003e=2){const s=FS(t,[`LAYER${e}XSIZE`,\"MIDXSIZE\",\"XSIZE\"])??20;return{height:FS(t,[`LAYER${e}YSIZE`,\"MIDYSIZE\",\"YSIZE\"])??s,shape:A1e(t,[`LAYER${e}SHAPE`,\"MIDSHAPE\",\"SHAPE\"])?.toUpperCase()??\"ROUND\",width:s}}const r=FS(t,[\"MIDXSIZE\",\"XSIZE\",\"TOPXSIZE\"])??20;return{height:FS(t,[\"MIDYSIZE\",\"YSIZE\",\"TOPYSIZE\"])??r,shape:A1e(t,[\"MIDSHAPE\",\"SHAPE\",\"TOPSHAPE\"])?.toUpperCase()??\"ROUND\",width:r}}function S$i(t,e){const n=e?.length===1?xXe(e[0]??\"\"):xXe(t.getCaseInsensitive(\"LAYER\")??\"\");if(n===\"BOTTOM\")return 31;if(n===\"TOP\")return 0;const o=/^(?:MIDLAYER|MID|INTERNALPLANE)(\\d+)$/u.exec(n);return o?.[1]?Math.min(Math.max(Number(o[1]),1),30):0}function FS(t,e){for(const n of e){const o=iK(t.getCaseInsensitive(n));if(o!==void 0)return o}}function A1e(t,e){for(const n of e){const o=t.getCaseInsensitive(n);if(o!==void 0)return o}}function EXe(t){if(t.length!==0)return{minX:Math.min(...t.map(e=\u003ee.x)),minY:Math.min(...t.map(e=\u003ee.y)),maxX:Math.max(...t.map(e=\u003ee.x)),maxY:Math.max(...t.map(e=\u003ee.y))}}function Q$i(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e}function BXe(t,e){return{minX:t.minX-e,minY:t.minY-e,maxX:t.maxX+e,maxY:t.maxY+e}}function v$i(t,e){const n=t.recordKind;if(n===\"Dimension\"){const o=y$i(t);if(!o)return;const i=o.dimensionEnd.x-o.dimensionStart.x,r=o.dimensionEnd.y-o.dimensionStart.y,s=Math.hypot(i,r),a={x:i/s,y:r/s},A=EXe([o.referenceStart,o.referenceEnd,o.dimensionStart,o.dimensionEnd,o.textPosition,{x:o.textPosition.x-a.x*o.estimatedTextHalfWidth,y:o.textPosition.y-a.y*o.estimatedTextHalfWidth},{x:o.textPosition.x+a.x*o.estimatedTextHalfWidth,y:o.textPosition.y+a.y*o.estimatedTextHalfWidth}]);return A?BXe(A,Math.max(o.arrowSize,o.textHeight)):void 0}if(n===\"Track\"){const o=EXe([{x:Md(t,\"X1\"),y:Md(t,\"Y1\")},{x:Md(t,\"X2\"),y:Md(t,\"Y2\")}]),i=Md(t,\"WIDTH\");return o\u0026\u0026i\u003e0?BXe(o,i/2):o}if(n===\"Pad\"){const o=B$i(t,e),i=o.rotation*Math.PI/180,r=o.width/2,s=o.height/2,a=Math.abs(Math.cos(i))*r+Math.abs(Math.sin(i))*s,A=Math.abs(Math.sin(i))*r+Math.abs(Math.cos(i))*s;return{minX:o.x-a,minY:o.y-A,maxX:o.x+a,maxY:o.y+A}}if(n===\"Via\"){const o=Md(t,\"X\"),i=Md(t,\"Y\"),r=iK(t.getCaseInsensitive(\"DIAMETER\"))??iK(t.getCaseInsensitive(\"TOPLAYERSIZE\"))??20;return{minX:o-r/2,minY:i-r/2,maxX:o+r/2,maxY:i+r/2}}if(n===\"Arc\"){const o=Md(t,\"LOCATION.X\"),i=Md(t,\"LOCATION.Y\"),r=Md(t,\"RADIUS\"),s=Md(t,\"WIDTH\"),a=r+Math.max(s/2,0);return{minX:o-a,minY:i-a,maxX:o+a,maxY:i+a}}if(n===\"ComponentBody\"||n===\"Region\"||n===\"Polygon\"||n===\"Board\")return EXe(C$i(t));if(n===\"Text\"){const o=Md(t,\"X\"),i=Md(t,\"Y\"),r=Md(t,\"HEIGHT\",30);return BXe({minX:o,minY:i,maxX:o,maxY:i},r)}if(n===\"Fill\"){const o=Md(t,\"X1\"),i=Md(t,\"Y1\"),r=Md(t,\"X2\"),s=Md(t,\"Y2\"),a=(o+r)/2,A=(i+s)/2,c=Math.abs(r-o)/2,l=Math.abs(s-i)/2,u=Number(t.getCaseInsensitive(\"ROTATION\")??0)*Math.PI/180,g=Math.abs(Math.cos(u))*c+Math.abs(Math.sin(u))*l,h=Math.abs(Math.sin(u))*c+Math.abs(Math.cos(u))*l;return{minX:a-g,minY:A-h,maxX:a+g,maxY:A+h}}}var Wfn=new WeakMap,w$i=class{constructor(t){this.document=t;const e=rg(t);this.edges=e.nets.flatMap((n,o)=\u003e{const i=n.getNumber(\"ID\")??o,r=e.byNet.get(i)??[],s=new Map;for(const a of r){const A=mXe(t,a),c=s.get(A);c?c.push(a):s.set(A,[a])}return[...s].map(([a,A])=\u003e({component:a===void 0?void 0:e.getComponent(a),net:n,primitives:A}))})}document;edges;getConnectedRecords(t){const e=_Xe(this.document,t);return e===void 0?[]:[...rg(this.document).byNet.get(e)??[]].filter(n=\u003en!==t)}getNetsForComponent(t){const e=rg(this.document),n=new Set;for(const o of n1e(this.document,t)){const i=_Xe(this.document,o),r=i===void 0?void 0:e.getNet(i);r\u0026\u0026n.add(r)}return[...n]}getComponentsForNet(t){const e=rg(this.document),n=typeof t==\"number\"?t:t.getNumber(\"ID\")??e.nets.indexOf(t);if(n\u003c0)return[];const o=new Set;for(const i of e.byNet.get(n)??[]){const r=mXe(this.document,i),s=r===void 0?void 0:e.getComponent(r);s\u0026\u0026o.add(s)}return[...o]}getConnectedComponents(t){const e=new Set,n=typeof t==\"number\"?rg(this.document).getComponent(t):t;for(const o of this.getNetsForComponent(t))for(const i of this.getComponentsForNet(o))i!==n\u0026\u0026e.add(i);return[...e]}};function jfn(t){const e=Wfn.get(t);if(e?.revision===t.revision)return e.graph;const n=new w$i(t);return Wfn.set(t,{graph:n,revision:t.revision}),n}function $fn(t,e,n){let o;for(const i of n1e(t,e))o=Q$i(o,v$i(i,n));return o}var P$i=class extends o8{type=\"binary-pcb-document\";compoundFile;embeddedModels;primitiveRecords;propertyRecords;streamSummaries;wideStrings;constructor(t){super({sourceLocation:{byteOffset:0,streamPath:\"/\"}}),this.compoundFile=t.compoundFile,this.primitiveRecords=t.primitiveRecords,this.propertyRecords=t.propertyRecords,this.streamSummaries=t.streamSummaries,this.wideStrings=t.wideStrings??new Map,this.embeddedModels=this.models.flatMap((e,n)=\u003e{const o=this.compoundFile.getStream([\"Models\",String(n)]);return o?[new $ji({index:n,record:e,stream:o})]:[]}),this.adoptChildren([this.compoundFile,...this.records]),this.clearDirty(!0)}get records(){return[...this.propertyRecords.values(),...this.primitiveRecords.values()].flat()}get board(){return this.propertyRecords.get(\"Board6\")?.[0]}get components(){return this.propertyRecords.get(\"Components6\")??[]}get componentBodies(){return this.primitiveRecords.get(\"ShapeBasedComponentBodies6\")??this.primitiveRecords.get(\"ComponentBodies6\")??[]}get legacyComponentBodies(){return this.primitiveRecords.get(\"ComponentBodies6\")??[]}get nets(){return this.propertyRecords.get(\"Nets6\")??[]}get index(){return rg(this)}get connectivity(){return jfn(this)}get boardGeometry(){return Ofn(this)}get polygons(){return this.propertyRecords.get(\"Polygons6\")??[]}get rules(){return this.propertyRecords.get(\"Rules6\")??[]}getComponentByIndex(t){return Qfn(this,t)}getNetByIndex(t){return vfn(this,t)}getPolygonByIndex(t){return wfn(this,t)}getRuleByIndex(t){return Pfn(this,t)}getComponentForRecord(t){return Mfn(this,t)}getNetForRecord(t){return Dfn(this,t)}getPolygonForRecord(t){return Nfn(this,t)}getRuleForRecord(t){return Rfn(this,t)}getRecordsOwnedByComponent(t){return n1e(this,t)}getRecordsOnNet(t){return Tfn(this,t)}getRecordsForPolygon(t){return kfn(this,t)}getRecordsForRule(t){return Ffn(this,t)}getRecordsByLayer(t){return[...this.index.byLayer.get(t.toUpperCase())??[]]}getComponentBounds(t,e){return $fn(this,t,e)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}get models(){return this.propertyRecords.get(\"Models\")??[]}getModelsById(t){const e=t.toUpperCase();return this.models.filter(n=\u003en.getDecoded(\"ID\")?.toUpperCase()===e)}getModelForComponentBody(t){const e=t.getDecoded(\"MODELID\");if(!e)return;const n=this.getModelsById(e);return n.length\u003c=1?n[0]:n.find(o=\u003ebXe(o.getNumber(\"ROTX\"),t.getNumber(\"MODEL.3D.ROTX\"))\u0026\u0026bXe(o.getNumber(\"ROTY\"),t.getNumber(\"MODEL.3D.ROTY\"))\u0026\u0026bXe(o.getNumber(\"ROTZ\"),t.getNumber(\"MODEL.3D.ROTZ\")))??n[0]}getEmbeddedModelForComponentBody(t){const e=this.getModelForComponentBody(t);return this.embeddedModels.find(n=\u003en.record===e)}get tracks(){return this.primitiveRecords.get(\"Tracks6\")??[]}get arcs(){return this.primitiveRecords.get(\"Arcs6\")??[]}get vias(){return this.primitiveRecords.get(\"Vias6\")??[]}get pads(){return this.primitiveRecords.get(\"Pads6\")??[]}get fills(){return this.primitiveRecords.get(\"Fills6\")??[]}get regions(){return this.primitiveRecords.get(\"ShapeBasedRegions6\")??this.primitiveRecords.get(\"Regions6\")??[]}get regionFills(){return this.primitiveRecords.get(\"Regions6\")??[]}get boardRegions(){return this.primitiveRecords.get(\"BoardRegions\")??[]}get texts(){return this.primitiveRecords.get(\"Texts6\")??[]}getRecordsByKind(t){return this.records.filter(e=\u003ee.recordKind===t)}getStreamSummary(t){return this.streamSummaries.find(e=\u003ee.family.toLowerCase()===t.toLowerCase())}getBytes(){if(this.isDirty)throw new Yg(\"Modified binary PCB documents cannot yet be serialized safely\");return this.compoundFile.getBytes()}getChildren(){return[this.compoundFile,...this.records]}getString(){return this.records.map(t=\u003et.getString()).join(`\n`)}};function bXe(t,e){return t!==void 0\u0026\u0026e!==void 0\u0026\u0026Math.abs(t-e)\u003cNumber.EPSILON}function SXe(t,e){if(e!==void 0)return{encoding:e,text:e===\"utf-16le\"?l1e(t,!0):e===\"utf-16be\"?l1e(t,!1):new TextDecoder(e,{fatal:e===\"utf-8\"}).decode(t)};if(t[0]===239\u0026\u0026t[1]===187\u0026\u0026t[2]===191)return{encoding:\"utf-8-bom\",text:`\\uFEFF${new TextDecoder().decode(t.subarray(3))}`};if(t[0]===255\u0026\u0026t[1]===254)return{encoding:\"utf-16le-bom\",text:`\\uFEFF${l1e(t.subarray(2),!0)}`};if(t[0]===254\u0026\u0026t[1]===255)return{encoding:\"utf-16be-bom\",text:`\\uFEFF${l1e(t.subarray(2),!1)}`};try{return{encoding:\"utf-8\",text:new TextDecoder(\"utf-8\",{fatal:!0}).decode(t)}}catch{return{encoding:\"windows-1252\",text:new TextDecoder(\"windows-1252\").decode(t)}}}function c1e(t,e=\"utf-8\"){const n=e.endsWith(\"-bom\"),o=n\u0026\u0026t.startsWith(\"\\uFEFF\")?t.slice(1):t;if(e===\"utf-8\"||e===\"utf-8-bom\"){const c=new TextEncoder().encode(o);return n?Uint8Array.from([239,187,191,...c]):c}if(e===\"windows-1252\")return D$i(o);const i=e===\"utf-16le\"||e===\"utf-16le-bom\",r=o.length*2+(n?2:0),s=new Uint8Array(r),a=new DataView(s.buffer);let A=0;n\u0026\u0026(s[0]=i?255:254,s[1]=i?254:255,A=2);for(let c=0;c\u003co.length;c++)a.setUint16(A,o.charCodeAt(c),i),A+=2;return s}function l1e(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=[],i=8192;for(let r=0;r+2\u003c=t.byteLength;r+=i*2){const s=Math.min(r+i*2,t.byteLength),a=[];for(let A=r;A+2\u003c=s;A+=2)a.push(n.getUint16(A,e));o.push(String.fromCharCode(...a))}return o.join(\"\")}var M$i=new Map([[\"€\",128],[\"‚\",130],[\"ƒ\",131],[\"„\",132],[\"…\",133],[\"†\",134],[\"‡\",135],[\"ˆ\",136],[\"‰\",137],[\"Š\",138],[\"‹\",139],[\"Œ\",140],[\"Ž\",142],[\"‘\",145],[\"’\",146],[\"“\",147],[\"”\",148],[\"•\",149],[\"–\",150],[\"—\",151],[\"˜\",152],[\"™\",153],[\"š\",154],[\"›\",155],[\"œ\",156],[\"ž\",158],[\"Ÿ\",159]]);function D$i(t){const e=[];for(const n of t){const o=M$i.get(n);if(o!==void 0){e.push(o);continue}const i=n.codePointAt(0);if(i===void 0||i\u003e255)throw new RangeError(`Character ${JSON.stringify(n)} cannot be encoded as Windows-1252`);e.push(i)}return Uint8Array.from(e)}function N$i(t){const e=new Map(t.fields.map(r=\u003e[r.key.toUpperCase(),r.value])),n=[...QXe(e,\"LAYER_V8_\",\"v8\"),...QXe(e,\"LAYERV7_\",\"v7\")];n.length===0\u0026\u0026n.push(...QXe(e,\"LAYER\",\"legacy\"));const o=e.has(\"V9_MASTERSTACK_ID\")?\"V9_MASTERSTACK_\":\"LAYERMASTERSTACK_V8\",i=T$i(e);return{entries:n.sort((r,s)=\u003er.index-s.index),id:EI(e,`${o}ID`),impedanceProfiles:R$i(e,i),isFlex:h2(EI(e,`${o}ISFLEX`)),layerPairs:F$i(e),name:EI(e,`${o}NAME`),style:EI(e,`${o}STYLE`)??EI(e,\"LAYERSTACKSTYLE\"),subStacks:k$i(e),traceImpedanceConfigurations:i}}function R$i(t,e){return[...Uee(t,/^V9_IMPEDANCEPROFILE(\\d+)_ID$/u)].sort((n,o)=\u003en-o).map(n=\u003e{const o=`V9_IMPEDANCEPROFILE${n}_`,i=EI(t,`${o}ID`);return{displayName:EI(t,`${o}DISPLAY_NAME`),id:i,index:n,isDifferentialPair:h2(EI(t,`${o}ISDIFFPAIR`)),name:EI(t,`${o}NAME`),targetImpedanceOhms:nM(EI(t,`${o}IMPEDANCE`)),traceConfigurations:e.filter(({profileId:r})=\u003ei!==void 0\u0026\u0026r?.toUpperCase()===i.toUpperCase())}})}function T$i(t){return[...Uee(t,/^V9_TRACEIMPEDANCE(\\d+)_PROFILE_ID$/u)].sort((e,n)=\u003ee-n).map(e=\u003e{const n=`V9_TRACEIMPEDANCE${e}_`,o=r=\u003eEI(t,`${n}${r}`),i=r=\u003eGee(o(r));return{calculatedImpedanceOhms:nM(o(\"CALC_IMPEDANCE\")),differentialPairGapMils:i(\"DIFF_PAIR_GAP\"),differentialPairMaximumGapMils:i(\"DIFF_PAIR_MAXGAP\"),differentialPairMinimumGapMils:i(\"DIFF_PAIR_MINGAP\"),enabled:h2(o(\"ENABLED\")),etchFactor:nM(o(\"ETCH_FACTOR\")),impedanceErrorPercent:nM(o(\"IMPEDANCE_ERR\")),index:e,layerId:o(\"LAYER_V7ID\"),profileId:o(\"PROFILE_ID\"),propagationSpeed:nM(o(\"PROPAGATION_SPEED\")),referenceBottomLayerId:o(\"REF_BOT_V7ID\"),referenceTopLayerId:o(\"REF_TOP_V7ID\"),subStackId:o(\"SUBSTACK_ID\"),traceGapLocked:h2(o(\"TRACEGAP_LOCKED\")),traceMaximumWidthMils:i(\"TRACE_MAXWIDTH\"),traceMinimumWidthMils:i(\"TRACE_MINWIDTH\"),traceWidthLocked:h2(o(\"TRACEWIDTH_LOCKED\")),traceWidthMils:i(\"TRACE_WIDTH\")}})}function k$i(t){const e=Uee(t,/^V9_SUBSTACK(\\d+)_ID$/u),n=e.size\u003e0?\"v9\":\"v8\";return[...n===\"v9\"?e:Uee(t,/^LAYERSUBSTACK_V8_(\\d+)ID$/u)].sort((i,r)=\u003ei-r).map(i=\u003e{const r=n===\"v9\"?`V9_SUBSTACK${i}_`:`LAYERSUBSTACK_V8_${i}`,s=a=\u003eEI(t,`${r}${a}`);return{id:s(\"ID\"),index:i,isFlex:h2(s(\"ISFLEX\")),name:s(\"NAME\"),service:h2(s(\"SERVICE\")),showBottomDielectric:h2(s(\"SHOWBOTTOMDIELECTRIC\")),showTopDielectric:h2(s(\"SHOWTOPDIELECTRIC\")),source:n,type:nM(s(\"TYPE\")),usedByPrimitives:h2(s(\"USEDBYPRIMS\"))}})}function F$i(t){return[...Uee(t,/^LAYERPAIR(\\d+)LOW$/u)].sort((n,o)=\u003en-o).map(n=\u003e{const o=`LAYERPAIR${n}`,i=`${o}SUBSTACK_`,r=[...t].flatMap(([s,a])=\u003e{if(!s.startsWith(i))return[];const A=s.slice(i.length);return/^\\d+$/u.test(A)?[{index:Number(A),value:a}]:[]}).sort((s,a)=\u003es.index-a.index).map(({value:s})=\u003es);return{drillDrawing:h2(EI(t,`${o}DRILLDRAWING`)),drillGuide:h2(EI(t,`${o}DRILLGUIDE`)),highLayer:EI(t,`${o}HIGH`),index:n,lowLayer:EI(t,`${o}LOW`),subStackIds:r}})}function Uee(t,e){const n=new Set;for(const o of t.keys()){const i=e.exec(o)?.[1];i!==void 0\u0026\u0026n.add(Number(i))}return n}function QXe(t,e,n){const o=new Set,i=n===\"legacy\"?/^LAYER(\\d+)NAME$/u:new RegExp(`^${L$i(e)}(\\\\d+)(?:_|)(?:ID|NAME|LAYERID) dist/viewer-part-09.txt - astra/am3352-sbc - tscircuit ,\"u\");for(const r of t.keys()){const s=i.exec(r);s?.[1]\u0026\u0026o.add(Number(s[1]))}return[...o].map(r=\u003e{const s=`${e}${r}`,a=c=\u003eEI(t,`${s}${c}`),A={index:r,source:n};return n===\"v8\"?(A.id=a(\"ID\"),A.name=a(\"NAME\"),A.layerId=a(\"LAYERID\"),A.usedByPrimitives=h2(a(\"USEDBYPRIMS\")),A.mechanicalEnabled=h2(a(\"MECHENABLED\")),A.copperThickness=oK(a(\"COPTHICK\")??\"\"),A.dielectricType=a(\"DIELTYPE\"),A.dielectricConstant=nM(a(\"DIELCONST\")),A.dielectricHeight=oK(a(\"DIELHEIGHT\")??\"\"),A.dielectricMaterial=a(\"DIELMATERIAL\"),A):(A.layerId=a(\"LAYERID\"),A.name=a(\"NAME\"),A.previous=a(\"PREV\"),A.next=a(\"NEXT\"),A.mechanicalEnabled=h2(a(\"MECHENABLED\")),A.copperThickness=oK(a(\"COPTHICK\")??\"\"),A.dielectricType=a(\"DIELTYPE\"),A.dielectricConstant=nM(a(\"DIELCONST\")),A.dielectricHeight=oK(a(\"DIELHEIGHT\")??\"\"),A.dielectricMaterial=a(\"DIELMATERIAL\"),A)})}function EI(t,e){return t.get(e.toUpperCase())}function h2(t){if(t!==void 0){if(/^(?:T|TRUE|1)$/iu.test(t))return!0;if(/^(?:F|FALSE|0)$/iu.test(t))return!1}}function nM(t){if(t===void 0)return;const e=Number(t);return Number.isFinite(e)?e:void 0}function L$i(t){return t.replace(/[.*+?^${}()|[\\]\\\\]/gu,\"\\\\$\u0026\")}var qfn=class extends Ol{type=\"board-record\";constructor(t={}){super(t)}get fileName(){return pi(this,\"FILENAME\")}get version(){return pi(this,\"VERSION\")}get date(){return pi(this,\"DATE\")}get time(){return pi(this,\"TIME\")}get displayUnit(){return pi(this,\"DISPLAYUNIT\")}get origin(){return qh(this,[\"ORIGINX\",\"ORIGIN.X\"],[\"ORIGINY\",\"ORIGIN.Y\"])}get sheetOrigin(){return qh(this,[\"SHEETX\"],[\"SHEETY\"])}get sheetSize(){return Yee(this,[\"SHEETWIDTH\"],[\"SHEETHEIGHT\"])}get uniqueId(){return pi(this,\"UNIQUEID\")}get grid(){return{dotGrid:this.getBoolean(\"DOTGRID\"),electricalGridEnabled:this.getBoolean(\"ELECTRICALGRIDENABLED\"),electricalGridRangeMils:tc(this,\"ELECTRICALGRIDRANGE\"),largeVisibleGridMultiplier:this.getNumber(\"BIGVISIBLEGRIDMULTFACTOR\"),largeVisibleGridSize:this.getNumber(\"BIGVISIBLEGRIDSIZE\"),snapEnabled:this.getBoolean(\"GRIDSNAPENABLED\"),snapSizeMils:tc(this,\"GRIDSIZE\"),visibleGridMultiplier:this.getNumber(\"VISIBLEGRIDMULTFACTOR\"),visibleGridSize:this.getNumber(\"VISIBLEGRIDSIZE\")}}get outline(){return IXe(this)}get layerStack(){return N$i(this)}},vXe=class extends Ol{type=\"class-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get classKind(){return pi(this,\"KIND\")}get superClass(){return this.getBoolean(\"SUPERCLASS\")}get uniqueId(){return pi(this,\"UNIQUEID\")}get members(){const t=[];for(let e=0;e\u003c1e5;e++){const n=pi(this,`M${e}`);if(n===void 0)break;t.push(n)}return t}},H$i=class extends vXe{type=\"signal-class-record\"},Xfn=class extends Ol{type=\"polygon-record\";constructor(t={}){super(t)}get id(){return this.getNumber(\"ID\")}get name(){return pi(this,\"NAME\")}get layer(){return pi(this,\"LAYER\")}get netIndex(){return this.getNumber(\"NET\")}get polygonType(){return pi(this,\"POLYGONTYPE\")}get pourOverStyle(){return pi(this,\"POUROVERSTYLE\",\"POUROVER\")}get hatchStyle(){return pi(this,\"HATCHSTYLE\")}get pourIndex(){return this.getNumber(\"POURINDEX\")}get priority(){return this.getNumber(\"POURORDER\")??this.getNumber(\"PRIORITY\")}get shelved(){return this.getBoolean(\"SHELVED\")}get removeDeadCopper(){return this.getBoolean(\"REMOVEDEAD\")}get trackWidthMils(){return tc(this,\"TRACKWIDTH\")}get gridSizeMils(){return tc(this,\"GRIDSIZE\")}},wXe=class extends Ol{type=\"rule-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get ruleKind(){return pi(this,\"RULEKIND\")}get priority(){return this.getNumber(\"PRIORITY\")??this.getNumber(\"INDEXFORSAVE\")}get enabled(){return this.getBoolean(\"ENABLED\")}get scope1Expression(){return pi(this,\"SCOPE1EXPRESSION\")}get scope2Expression(){return pi(this,\"SCOPE2EXPRESSION\")}get comment(){return pi(this,\"COMMENT\")}get uniqueId(){return pi(this,\"UNIQUEID\")}get category(){const t=this.ruleKind?.toUpperCase();return t?[\"BOARDOUTLINECLEARANCE\",\"CLEARANCE\",\"COMPONENTCLEARANCE\",\"HOLETOHOLECLEARANCE\",\"PLANECLEARANCE\"].includes(t)?\"clearance\":t===\"WIDTH\"?\"routing-width\":t===\"ROUTINGVIAS\"?\"via-style\":t===\"ROUTINGLAYERS\"?\"routing-layer\":t===\"DIFFPAIRSROUTING\"?\"differential-pair\":t===\"LENGTH\"||t===\"MATCHEDLENGTHS\"?\"length\":t===\"PLANECONNECT\"?\"plane-connect\":t===\"POLYGONCONNECT\"?\"polygon-connect\":t===\"SOLDERMASKEXPANSION\"||t===\"PASTEMASKEXPANSION\"?\"mask\":/(?:ASSEMBLY|FABRICATION|HEIGHT|HOLE|SILK|SLIVER|TESTPOINT)/u.test(t)?\"manufacturing\":\"unknown\":\"unknown\"}get clearanceMils(){if(this.category===\"clearance\")return tc(this,\"GAP\",\"GENERICCLEARANCE\",\"CLEARANCE\")}get verticalClearanceMils(){if(this.category===\"clearance\")return tc(this,\"VERTICALGAP\")}get widthConstraint(){if(this.normalizedRuleKind===\"WIDTH\")return oM(this,[\"MINLIMIT\"],[\"PREFEREDWIDTH\",\"PREFERREDWIDTH\"],[\"MAXLIMIT\"])}get layerConstraints(){if(![\"DIFFPAIRSROUTING\",\"WIDTH\"].includes(this.normalizedRuleKind??\"\"))return[];const t=new Map;for(const e of this.fields){const n=/^(TOPLAYER|BOTTOMLAYER|MIDLAYER(\\d+))_(MINWIDTH|PREFWIDTH|MAXWIDTH|MINGAP|PREFGAP|MAXGAP)$/u.exec(e.key.toUpperCase());if(!n?.[1]||!n[3])continue;const o=O$i(n[1],n[2]),i=t.get(o)??{layer:o},r=tc(this,e.key);r!==void 0\u0026\u0026(n[3].endsWith(\"GAP\")?(i.gap??={},e1n(i.gap,n[3],r)):e1n(i,n[3],r),t.set(o,i))}return[...t.values()]}get viaDiameterConstraint(){if(this.normalizedRuleKind===\"ROUTINGVIAS\")return oM(this,[\"MINWIDTH\"],[\"WIDTH\",\"PREFEREDWIDTH\"],[\"MAXWIDTH\"])}get viaHoleConstraint(){if(this.normalizedRuleKind===\"ROUTINGVIAS\")return oM(this,[\"MINHOLEWIDTH\"],[\"HOLEWIDTH\",\"PREFEREDHOLEWIDTH\"],[\"MAXHOLEWIDTH\"])}get viaStyle(){if(this.normalizedRuleKind===\"ROUTINGVIAS\")return pi(this,\"VIASTYLE\")}get routingLayers(){if(this.normalizedRuleKind!==\"ROUTINGLAYERS\")return[];const t=new Map;for(const e of this.fields){const n=/^(TOP LAYER|BOTTOM LAYER|MID LAYER (\\d+))(_V5)?$/u.exec(e.key.toUpperCase());if(!n?.[1])continue;const o=G$i(n[1],n[2]),i=t.get(o)??{layer:o};n[3]?i.enabled=Y$i(e.value):i.mode=e.value,t.set(o,i)}return[...t.values()]}get differentialPairGap(){if(this.normalizedRuleKind===\"DIFFPAIRSROUTING\")return oM(this,[\"MINLIMIT\"],[\"MOSTFREQGAP\",\"PREFEREDGAP\",\"PREFERREDGAP\"],[\"MAXLIMIT\"])}get maximumUncoupledLengthMils(){if(this.normalizedRuleKind===\"DIFFPAIRSROUTING\")return tc(this,\"MAXUNCOUPLEDLENGTH\")}get matchedLengthToleranceMils(){if([\"LENGTH\",\"MATCHEDLENGTHS\"].includes(this.normalizedRuleKind??\"\"))return tc(this,\"TOLERANCE\")}get impedanceConstraint(){if(this.normalizedRuleKind!==\"WIDTH\")return;const t={maximum:this.getNumber(\"MAXIMP\"),minimum:this.getNumber(\"MINIMP\"),preferred:this.getNumber(\"FAVIMP\")};return u1e(t)?t:void 0}get thermalRelief(){if(![\"PLANECONNECT\",\"POLYGONCONNECT\"].includes(this.normalizedRuleKind??\"\"))return;const t={airGapMils:tc(this,\"AIRGAPWIDTH\",\"RELIEFAIRGAP\"),angle:pi(this,\"POLYGONRELIEFANGLE\"),conductorWidthMils:tc(this,\"RELIEFCONDUCTORWIDTH\"),connectionStyle:pi(this,\"CONNECTSTYLE\",\"PLANECONNECTSTYLE\"),expansionMils:tc(this,\"RELIEFEXPANSION\"),spokeCount:this.getNumber(\"RELIEFENTRIES\")};return u1e(t)?t:void 0}get maskExpansionMils(){if([\"PASTEMASKEXPANSION\",\"SOLDERMASKEXPANSION\"].includes(this.normalizedRuleKind??\"\"))return tc(this,\"EXPANSION\")}get heightConstraint(){if(this.normalizedRuleKind===\"HEIGHT\")return oM(this,[\"MINHEIGHT\"],[\"PREFHEIGHT\",\"PREFEREDHEIGHT\"],[\"MAXHEIGHT\"])}get holeSizeConstraint(){if(this.normalizedRuleKind===\"HOLESIZE\")return oM(this,[\"MINLIMIT\"],[],[\"MAXLIMIT\"])}get minimumSolderMaskSliverMils(){if(this.normalizedRuleKind===\"MINIMUMSOLDERMASKSLIVER\")return tc(this,\"MINSOLDERMASKWIDTH\")}get minimumSilkClearanceMils(){if([\"SILKTOBOARDREGIONCLEARANCE\",\"SILKTOSILKCLEARANCE\",\"SILKTOSOLDERMASKCLEARANCE\"].includes(this.normalizedRuleKind??\"\"))return tc(this,\"MINSILKSCREENTOMASKGAP\",\"SILKTOSILKCLEARANCE\")}get testPointSettings(){if(!this.normalizedRuleKind?.includes(\"TESTPOINT\"))return;const t={allowBottom:this.getBoolean(\"ALLOWSIDEBOTTOM\"),allowTop:this.getBoolean(\"ALLOWSIDETOP\"),gridMils:tc(this,\"TESTPOINTGRID\"),holeSize:oM(this,[\"MINHOLESIZE\"],[\"PREFEREDHOLESIZE\",\"PREFERREDHOLESIZE\"],[\"MAXHOLESIZE\"]),padSize:oM(this,[\"MINSIZE\"],[\"PREFEREDSIZE\",\"PREFERREDSIZE\"],[\"MAXSIZE\"]),underComponent:this.getBoolean(\"TESTPOINTUNDERCOMPONENT\"),useGrid:this.getBoolean(\"USEGRID\")};return u1e(t)?t:void 0}get normalizedRuleKind(){return this.ruleKind?.toUpperCase()}},Zfn=class extends wXe{type=\"dxp-rule-record\"};function oM(t,e,n,o){const i={maximumMils:tc(t,...o),minimumMils:tc(t,...e),preferredMils:tc(t,...n)};return u1e(i)?i:void 0}function e1n(t,e,n){e.startsWith(\"MIN\")?t.minimumMils=n:e.startsWith(\"MAX\")?t.maximumMils=n:t.preferredMils=n}function O$i(t,e){return t===\"TOPLAYER\"?\"TOP\":t===\"BOTTOMLAYER\"?\"BOTTOM\":`MID-LAYER${e??\"\"}`}function G$i(t,e){return t===\"TOP LAYER\"?\"TOP\":t===\"BOTTOM LAYER\"?\"BOTTOM\":`MID-LAYER${e??\"\"}`}function Y$i(t){if(/^(?:TRUE|T|1)$/iu.test(t))return!0;if(/^(?:FALSE|F|0)$/iu.test(t))return!1}function u1e(t){return Object.values(t).some(e=\u003ee!==void 0)}var U$i=class extends o8{type=\"pcb-document\";_lines;originalBytes;originalSource;sourceEncoding;constructor(t={}){super({sourceLocation:{column:1,endOffset:t.originalSource?.length,line:1,startOffset:0}}),this._lines=t.lines??[],this.originalBytes=t.originalBytes?.slice(),this.originalSource=t.originalSource,this.sourceEncoding=t.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(t,e){return this.originalBytes=t.slice(),this.sourceEncoding=e,this}getBytes(){return!this.isDirty\u0026\u0026this.originalBytes?this.originalBytes.slice():c1e(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(t){t!==this._lines\u0026\u0026(this._lines=t,this.adoptChildren(t),this.markDirty())}get records(){return this.lines.filter(t=\u003et instanceof Ol)}get board(){return this.records.find(t=\u003et instanceof qfn)}get components(){return this.records.filter(t=\u003et instanceof e1e)}get nets(){return this.records.filter(t=\u003et instanceof t1e)}get classes(){return this.records.filter(t=\u003et instanceof vXe)}get index(){return rg(this)}get connectivity(){return jfn(this)}get boardGeometry(){return Ofn(this)}get polygons(){return this.records.filter(t=\u003et instanceof Xfn)}get rules(){return this.records.filter(t=\u003et instanceof wXe||t instanceof Zfn)}getComponentByIndex(t){return Qfn(this,t)}getNetByIndex(t){return vfn(this,t)}getPolygonByIndex(t){return wfn(this,t)}getRuleByIndex(t){return Pfn(this,t)}getComponentForRecord(t){return Mfn(this,t)}getNetForRecord(t){return Dfn(this,t)}getPolygonForRecord(t){return Nfn(this,t)}getRuleForRecord(t){return Rfn(this,t)}getRecordsOwnedByComponent(t){return n1e(this,t)}getRecordsOnNet(t){return Tfn(this,t)}getRecordsForPolygon(t){return kfn(this,t)}getRecordsForRule(t){return Ffn(this,t)}getRecordsByLayer(t){return[...this.index.byLayer.get(t.toUpperCase())??[]]}getComponentBounds(t,e){return $fn(this,t,e)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}getRecordsByKind(t){return this.records.filter(e=\u003ee.recordKind===t)}insertRecord(t,e=this.lines.length){const n=Math.min(Math.max(e,0),this.lines.length);return t.setParent(this),this.lines.splice(n,0,t),this.markDirty(),this}removeRecord(t){const e=this.lines.indexOf(t);return e\u003c0?!1:(this.lines.splice(e,1),t.setParent(void 0),this.markDirty(),!0)}allocateRecordId(t,e=\"ID\"){const n=new Set(this.getRecordsByKind(t).map(i=\u003ei.getNumber(e)).filter(i=\u003ei!==void 0));let o=0;for(;n.has(o);)o++;return o}getChildren(){return[...this.lines]}getString(){return!this.isDirty\u0026\u0026this.originalSource!==void 0?this.originalSource:this.lines.map(t=\u003e`${t.getString()}${t.terminator}`).join(\"\")}},K$i=class{index;name;record;storage;compressedBytes;decodedPayload;constructor(t){this.compressedBytes=t.compressedBytes,this.index=t.index,this.name=t.name,this.record=t.record,this.storage=t.storage}get compressedSize(){return this.compressedBytes.byteLength}getCompressedBytes(){return this.compressedBytes.slice()}getBitmapBytes(t={}){return this.getPayload(t).bitmapBytes.slice()}getEnhancedMetafileBytes(t={}){return this.getPayload(t).enhancedMetafileBytes?.slice()}getNativePngBytes(t={}){return this.getPayload(t).nativePngBytes?.slice()}getDataUrl(t={}){return`data:image/png;base64,${X$i(this.getPngBytes(t))}`}getPngBytes(t={}){const e=this.getPayload(t);return e.nativePngBytes?.slice()??$i(e.bitmapBytes)}getPayload(t){return Object.keys(t).length\u003e0?t1n(this.compressedBytes,t):(this.decodedPayload??=t1n(this.compressedBytes),this.decodedPayload)}};function V$i(t,e){if(!t||e.length===0)return[];const n=z$i(t.content),o=new Set(n);return e.flatMap((i,r)=\u003e{const s=o1n(i.fileName),a=n.find(A=\u003eo.has(A)\u0026\u0026o1n(A.name)===s)??n.find(A=\u003eo.has(A));return a?(o.delete(a),[new K$i({compressedBytes:a.compressedBytes,index:r,name:a.name,record:i,storage:t})]):[]})}function z$i(t){if(t.byteLength\u003c4)throw new aA(\"Schematic image storage header is truncated\");const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=4+e.getUint32(0,!0);if(o\u003et.byteLength)throw new aA(\"Schematic image storage header exceeds the stream\");const i=[];for(;o\u003ct.byteLength;){if(o+4\u003et.byteLength)throw new aA(\"Schematic image storage frame length is truncated\");const r=e.getUint32(o,!0)\u002616777215,s=o+4,a=s+r;if(r===0||a\u003et.byteLength)throw new aA(`Invalid schematic image storage frame length ${r}`);if(s+2\u003ea||t[s]!==208)throw new aA(\"Schematic image storage entry header is invalid\");const A=t[s+1]??0,c=s+2,l=c+A;if(l+4\u003ea)throw new aA(\"Schematic image storage entry name is truncated\");const u=e.getUint32(l,!0),g=l+4,h=g+u;if(h\u003ea)throw new aA(\"Schematic image storage compressed payload is truncated\");i.push({compressedBytes:t.subarray(g,h),name:new TextDecoder(\"windows-1252\").decode(t.subarray(c,l))}),o=a}return i}function t1n(t,e={}){const n=e.maximumBitmapSize??33554432,o=e.maximumMetafileSize??32*1024*1024,i=e.maximumNativeImageSize??32*1024*1024,r=e.maximumOutputSize??64*1024*1024;for(const[g,h]of[[\"maximumBitmapSize\",n],[\"maximumMetafileSize\",o],[\"maximumNativeImageSize\",i],[\"maximumOutputSize\",r]])if(!Number.isSafeInteger(h)||h\u003c=0)throw new RangeError(`${g} must be a positive safe integer`);let s=0;const a=[];try{const g=new Lce(d=\u003e{if(s+=d.byteLength,s\u003er)throw new aA(`Schematic image expands beyond the ${r}-byte limit`);a.push(d.slice())}),h=64*1024;for(let d=0;d\u003ct.byteLength;){const p=Math.min(d+h,t.byteLength);g.push(t.subarray(d,p),p===t.byteLength),d=p}}catch(g){throw g instanceof aA?g:new aA(`Schematic image zlib decompression failed: ${g instanceof Error?g.message:String(g)}`)}const A=n1n(a);if(A.byteLength\u003c6||A[0]!==66||A[1]!==77)throw new aA(\"Embedded schematic image is not a Windows bitmap\");const l=new DataView(A.buffer,A.byteOffset,A.byteLength).getUint32(2,!0);if(l\u003c14||l\u003en)throw new aA(`Embedded schematic bitmap declares invalid size ${l}`);if(l\u003eA.byteLength)throw new aA(\"Embedded schematic bitmap payload is truncated\");const u=J$i(A,l,o,i);return{bitmapBytes:A.slice(0,l),...u}}function J$i(t,e,n,o){if(e\u003e=t.byteLength)return{};const i=t[e]??0,r=e+1,s=r+i;if(s\u003et.byteLength)return{};const a=new TextDecoder(\"windows-1252\").decode(t.subarray(r,s));if(a===\"TdxPNGImage\"){const d=j$i(t.subarray(s),o);return d?{nativePngBytes:d}:{}}if(a!==\"TMetafile\"||s+88\u003et.byteLength)return{};const A=new DataView(t.buffer,t.byteOffset+s,t.byteLength-s),c=A.getUint32(0,!0),l=A.getUint32(4,!0),u=A.getUint32(40,!0),g=A.getUint32(48,!0);if(c!==1||![88,100,108].includes(l)||u!==1179469088||g\u003cl||g%4!==0||g\u003en||s+g\u003et.byteLength)return{};const h=t.slice(s,s+g);return W$i(h,l)?{enhancedMetafileBytes:h}:{}}function W$i(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=e;for(;o+8\u003c=t.byteLength;){const i=n.getUint32(o,!0),r=n.getUint32(o+4,!0),s=o+r;if(r\u003c8||r%4!==0||s\u003c=o||s\u003et.byteLength)return!1;if(i===14)return r\u003e=20\u0026\u0026s===t.byteLength;o=s}return!1}function j$i(t,e){const n=[137,80,78,71,13,10,26,10];if(t.byteLength\u003c20||t.byteLength\u003ee||!n.every((s,a)=\u003et[a]===s))return;const o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=n.length,r=!1;for(;i+12\u003c=t.byteLength;){const s=o.getUint32(i),a=i+12+s;if(s\u003ee||a\u003et.byteLength||a\u003ee)return;const A=new TextDecoder().decode(t.subarray(i+4,i+8));if(!r){if(A!==\"IHDR\"||s!==13)return;r=!0}if(A===\"IEND\")return s!==0?void 0:t.slice(0,a);i=a}}function $i(t){if(t.byteLength\u003c54||t[0]!==66||t[1]!==77)throw new aA(\"Embedded schematic image is not a supported Windows bitmap\");const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(10,!0),o=e.getUint32(14,!0),i=e.getInt32(18,!0),r=e.getInt32(22,!0),s=e.getUint16(26,!0),a=e.getUint16(28,!0),A=e.getUint32(30,!0),c=Math.abs(r);if(o\u003c40||i\u003c=0||c\u003c=0||i\u003e16384||c\u003e16384||s!==1||a!==24\u0026\u0026a!==32||A!==0)throw new aA(`Unsupported schematic bitmap (${i}x${r}, ${a}-bit, compression ${A})`);const l=a/8,u=Math.ceil(i*l/4)*4,g=u*c;if(!Number.isSafeInteger(g)||n\u003c14+o||n+g\u003et.byteLength)throw new aA(\"Embedded schematic bitmap pixel payload is truncated\");const h=1+i*4,d=new Uint8Array(h*c),p=r\u003c0;for(let f=0;f\u003cc;f++){const I=p?f:c-f-1,C=n+I*u,y=f*h;d[y]=0;for(let x=0;x\u003ci;x++){const E=C+x*l,B=y+1+x*4;d[B]=t[E+2]??0,d[B+1]=t[E+1]??0,d[B+2]=t[E]??0,d[B+3]=a===32?t[E+3]??255:255}}const m=new Uint8Array(13),_=new DataView(m.buffer);return _.setUint32(0,i),_.setUint32(4,c),m[8]=8,m[9]=6,n1n([new Uint8Array([137,80,78,71,13,10,26,10]),PXe(\"IHDR\",m),PXe(\"IDAT\",w8t(d,{level:6})),PXe(\"IEND\",new Uint8Array)])}function PXe(t,e){const n=new TextEncoder().encode(t),o=new Uint8Array(12+e.byteLength),i=new DataView(o.buffer);return i.setUint32(0,e.byteLength),o.set(n,4),o.set(e,8),i.setUint32(8+e.byteLength,q$i(o.subarray(4,8+e.byteLength))),o}function q$i(t){let e=4294967295;for(const n of t){e^=n;for(let o=0;o\u003c8;o++)e=e\u003e\u003e\u003e1^(e\u00261?3988292384:0)}return(e^4294967295)\u003e\u003e\u003e0}function n1n(t){const e=new Uint8Array(t.reduce((o,i)=\u003eo+i.byteLength,0));let n=0;for(const o of t)e.set(o,n),n+=o.byteLength;return e}function o1n(t){return t?.replace(/\\\\/gu,\"/\").split(\"/\").at(-1)?.toLowerCase()}function X$i(t){const e=[];for(let o=0;o\u003ct.byteLength;o+=32768)e.push(String.fromCharCode(...t.subarray(o,o+32768)));return btoa(e.join(\"\"))}var ol=class extends Ol{type=\"schematic-record\";constructor(t={}){super(t)}get ownerIndex(){return this.getNumber(\"OWNERINDEX\")}get ownerPartId(){return this.getNumber(\"OWNERPARTID\")}get indexInSheet(){return this.getNumber(\"INDEXINSHEET\")}get uniqueId(){return pi(this,\"UNIQUEID\")}get position(){const t=l1n(this,\"LOCATION.X\"),e=l1n(this,\"LOCATION.Y\");return t===void 0||e===void 0?void 0:{x:t,y:e}}},i1n=class extends ol{type=\"schematic-component-record\";get libraryReference(){return pi(this,\"LIBREFERENCE\")}},MXe=class extends ol{type=\"schematic-pin-record\";get name(){return pi(this,\"NAME\")}get designator(){return pi(this,\"DESIGNATOR\")}get electricalType(){return this.getNumber(\"ELECTRICAL\")}get hidden(){return this.getBoolean(\"ISHIDDEN\")}},DXe=class extends ol{type=\"schematic-label-record\";get text(){return pi(this,\"TEXT\")}},Z$i=class extends ol{type=\"schematic-bezier-record\"},eqi=class extends ol{type=\"schematic-polyline-record\"},tqi=class extends ol{type=\"schematic-polygon-record\"},nqi=class extends ol{type=\"schematic-ellipse-record\"},oqi=class extends ol{type=\"schematic-rounded-rectangle-record\"},iqi=class extends ol{type=\"schematic-elliptical-arc-record\"},rqi=class extends ol{type=\"schematic-arc-record\"},sqi=class extends ol{type=\"schematic-line-record\"},aqi=class extends ol{type=\"schematic-rectangle-record\"},r1n=class extends ol{type=\"schematic-sheet-symbol-record\";get fileName(){return pi(this,\"FILENAME\")}},Aqi=class extends ol{type=\"schematic-sheet-entry-record\";get name(){return pi(this,\"NAME\")}},NXe=class extends ol{type=\"schematic-power-port-record\";get text(){return pi(this,\"TEXT\")}},RXe=class extends ol{type=\"schematic-port-record\";get name(){return pi(this,\"NAME\")}},TXe=class extends ol{type=\"schematic-net-label-record\";get text(){return pi(this,\"TEXT\")}},cqi=class extends ol{type=\"schematic-bus-record\"},lqi=class extends ol{type=\"schematic-bus-entry-record\"},s1n=class extends ol{type=\"schematic-wire-record\"},uqi=class extends ol{type=\"schematic-no-erc-record\"},gqi=class extends ol{type=\"schematic-text-frame-record\";get text(){return pi(this,\"TEXT\")}},dqi=class extends ol{type=\"schematic-junction-record\"},a1n=class extends ol{type=\"schematic-image-record\";get fileName(){return pi(this,\"FILENAME\")}},hqi=class extends ol{type=\"schematic-sheet-record\"},A1n=class extends ol{type=\"schematic-sheet-name-record\"},c1n=class extends ol{type=\"schematic-sheet-file-name-record\"},pqi=class extends ol{type=\"schematic-designator-record\";get text(){return pi(this,\"TEXT\")}},mqi=class extends ol{type=\"schematic-template-record\";get fileName(){return pi(this,\"FILENAME\")}},_qi=class extends ol{type=\"schematic-parameter-record\";get name(){return pi(this,\"NAME\")}get text(){return pi(this,\"TEXT\")}},fqi=class extends ol{type=\"schematic-implementation-list-record\"},Iqi=class extends ol{type=\"schematic-implementation-record\";get modelName(){return pi(this,\"MODELNAME\")}get modelType(){return pi(this,\"MODELTYPE\")}},Cqi=class extends ol{type=\"schematic-implementation-map-record\"},yqi=class extends ol{type=\"schematic-implementation-parameter-record\"},xqi=class extends ol{type=\"schematic-note-record\";get text(){return pi(this,\"TEXT\")}};function l1n(t,e){const n=t.getCaseInsensitive(e);if(n===void 0)return;const o=Number(n);if(!Number.isFinite(o))return;const i=t.getCaseInsensitive(`${e}_FRAC`);if(i===void 0)return o;const r=+`0.${i.replace(/^[+-]/u,\"\")}`;return Number.isFinite(r)?o\u003c0?o-r:o+r:o}var u1n=new WeakMap,g1n=new WeakMap,Eqi=class{constructor(t){this.document=t,this.records=t.records;for(const e of this.records){const n=e.getNumber(\"OWNERINDEX\");if(n!==void 0\u0026\u0026n\u003e=0){const a=this.byOwner.get(n);a?a.push(e):this.byOwner.set(n,[e])}const o=e.getDecoded(\"UNIQUEID\");if(!o)continue;const i=o.toUpperCase(),r=this.uniqueIds.get(i);if(!r){this.uniqueIds.set(i,e);continue}const s=this.duplicateUniqueIds.get(i)??[r];s.push(e),this.duplicateUniqueIds.set(i,s)}}document;byOwner=new Map;duplicateUniqueIds=new Map;records;uniqueIds=new Map;getParent(t){const e=t.getNumber(\"OWNERINDEX\");return e===void 0||e\u003c0?void 0:this.records[e]}getOwnedRecords(t){const e=typeof t==\"number\"?t:this.records.indexOf(t);return e\u003c0?[]:[...this.byOwner.get(e)??[]]}getRecordByUniqueId(t){return this.uniqueIds.get(t.toUpperCase())}getOwnershipCycles(){const t=[],e=new Set;for(const n of this.records){if(e.has(n))continue;const o=[],i=new Map;let r=n;for(;r;){const s=i.get(r);if(s!==void 0){t.push(o.slice(s));break}if(e.has(r))break;i.set(r,o.length),o.push(r),r=this.getParent(r)}for(const s of o)e.add(s)}return t}},Bqi=class{constructor(t){this.document=t;const e=new wqi,n=new Map,o=new Map;for(const a of t.wires){const A=Qqi(a);for(const c of A){const l=g1e(c);e.add(l),o.set(l,c),p1n(n,l,a)}for(let c=1;c\u003cA.length;c++){const l=A[c-1],u=A[c];l\u0026\u0026u\u0026\u0026e.union(g1e(l),g1e(u))}}const i=[...t.pins,...t.labels,...t.netLabels,...t.ports,...t.powerPorts];for(const a of i){const A=a.position;if(!A)continue;const c=g1e(A);e.add(c),o.set(c,A),p1n(n,c,a)}const r=new Map;for(const[a,A]of n){const c=e.find(a),l=r.get(c)??{names:new Set,points:new Map,records:new Set},u=o.get(a);u\u0026\u0026l.points.set(a,u);for(const g of A){l.records.add(g);const h=vqi(g);h\u0026\u0026l.names.add(h)}r.set(c,l)}const s=[];for(const[a,A]of r){const c=new Set([...A.names].map(g=\u003eg.toUpperCase())),l=s.filter(g=\u003e[...g.names].some(h=\u003ec.has(h.toUpperCase())));if(l.length===0||c.size===0){s.push({id:a,...A});continue}const u=l[0];if(u){m1n(u,A);for(const g of l.slice(1)){m1n(u,g);const h=s.indexOf(g);h\u003e=0\u0026\u0026s.splice(h,1)}}}this.nets=s.map(a=\u003e({id:a.id,names:[...a.names],points:[...a.points.values()],records:[...a.records]}));for(const a of this.nets)for(const A of a.records)this.recordNets.set(A,a)}document;nets;recordNets=new Map;getNetForRecord(t){return this.recordNets.get(t)}getNetsByName(t){const e=t.toUpperCase();return this.nets.filter(n=\u003en.names.some(o=\u003eo.toUpperCase()===e))}getPinsForComponent(t){return kXe(this.document).getOwnedRecords(t).filter(e=\u003ee instanceof MXe)}};function kXe(t){const e=u1n.get(t);if(e?.revision===t.revision)return e.index;const n=new Eqi(t);return u1n.set(t,{index:n,revision:t.revision}),n}function bqi(t){const e=g1n.get(t);if(e?.revision===t.revision)return e.graph;const n=new Bqi(t);return g1n.set(t,{graph:n,revision:t.revision}),n}function Sqi(t){const e=kXe(t);return t.sheetSymbols.map(n=\u003e{const o=e.getOwnedRecords(n),i=o.find(s=\u003es instanceof A1n),r=o.find(s=\u003es instanceof c1n);return{fileName:r?.getDecoded(\"TEXT\"),fileNameRecord:r,name:i?.getDecoded(\"TEXT\"),nameRecord:i,symbol:n}})}function Qqi(t){const e=t.getNumber(\"LOCATIONCOUNT\"),n=e===void 0?1e5:Math.min(Math.max(e,0),1e5),o=[];for(let i=1;i\u003c=n;i++){const r=d1n(t,`X${i}`),s=d1n(t,`Y${i}`);if(r===void 0||s===void 0)break;o.push({x:r,y:s})}return o}function vqi(t){if(t instanceof TXe||t instanceof DXe||t instanceof NXe)return t.getDecoded(\"TEXT\");if(t instanceof RXe)return t.getDecoded(\"NAME\")}function d1n(t,e){const n=t.getCaseInsensitive(e);if(n===void 0)return;const o=Number(n);if(!Number.isFinite(o))return;const i=t.getCaseInsensitive(`${e}_FRAC`);if(i===void 0)return o;const r=+`0.${i.replace(/^[+-]/u,\"\")}`;return Number.isFinite(r)?o\u003c0?o-r:o+r:o}function g1e(t){return`${h1n(t.x)},${h1n(t.y)}`}function h1n(t){return t.toFixed(6).replace(/\\.?0+$/u,\"\")}function p1n(t,e,n){const o=t.get(e);o?o.push(n):t.set(e,[n])}function m1n(t,e){for(const n of e.names)t.names.add(n);for(const[n,o]of e.points)t.points.set(n,o);for(const n of e.records)t.records.add(n)}var wqi=class{parents=new Map;add(t){this.parents.has(t)||this.parents.set(t,t)}find(t){this.add(t);const e=this.parents.get(t);if(e===void 0||e===t)return t;const n=this.find(e);return this.parents.set(t,n),n}union(t,e){const n=this.find(t),o=this.find(e);n!==o\u0026\u0026this.parents.set(o,n)}},d1e=class extends o8{type=\"schematic-document\";compoundFile;embeddedImages;originalBytes;originalText;sourceEncoding;sourceFormat;_lines;constructor(t){super({sourceLocation:t.sourceFormat===\"binary\"?{byteOffset:0,streamPath:\"/\"}:{column:1,endOffset:t.originalText?.length,line:1,startOffset:0}}),this.compoundFile=t.compoundFile,this._lines=t.lines??[],this.originalBytes=t.originalBytes,this.originalText=t.originalText,this.sourceEncoding=t.sourceEncoding,this.sourceFormat=t.sourceFormat,this.embeddedImages=V$i(this.compoundFile?.getStream(\"/Storage\"),this.records.filter(e=\u003ee instanceof a1n)),this.adoptChildren([...this.compoundFile?[this.compoundFile]:[],...this._lines]),this.clearDirty(!0)}get lines(){return this._lines}set lines(t){t!==this._lines\u0026\u0026(this._lines=t,this.adoptChildren(t),this.markDirty())}get header(){return this.lines.find(t=\u003et instanceof Ol\u0026\u0026t.getCaseInsensitive(\"HEADER\")!==void 0)}get records(){return this.lines.filter(t=\u003et instanceof Ol\u0026\u0026t.recordKind!==void 0)}get index(){return kXe(this)}get netGraph(){return bqi(this)}get components(){return this.records.filter(t=\u003et instanceof i1n)}get pins(){return this.records.filter(t=\u003et instanceof MXe)}get wires(){return this.records.filter(t=\u003et instanceof s1n)}get labels(){return this.records.filter(t=\u003et instanceof DXe)}get netLabels(){return this.records.filter(t=\u003et instanceof TXe)}get ports(){return this.records.filter(t=\u003et instanceof RXe)}get powerPorts(){return this.records.filter(t=\u003et instanceof NXe)}get sheetSymbols(){return this.records.filter(t=\u003et instanceof r1n)}get sheetLinks(){return Sqi(this)}getEmbeddedImageForRecord(t){return this.embeddedImages.find(e=\u003ee.record===t)}getRecordsByKind(t){return this.records.filter(e=\u003ee.recordKind===t)}getParent(t){return this.index.getParent(t)}getOwnedRecords(t){return this.index.getOwnedRecords(t)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}getBytes(){if(!this.isDirty\u0026\u0026this.originalBytes)return this.originalBytes.slice();if(this.sourceFormat===\"binary\")throw new Yg(\"Modified binary schematic documents cannot yet be serialized safely\");return c1e(this.getString(),this.sourceEncoding)}getChildren(){return[...this.compoundFile?[this.compoundFile]:[],...this.lines]}getString(){return!this.isDirty\u0026\u0026this.originalText!==void 0?this.originalText:this.lines.map(t=\u003e`${t.getString()}${t.terminator}`).join(\"\")}},_1n=class extends o8{metadata;path;constructor(t,e){super(),this.metadata=t,this.path=e,this.setSourceLocation({recordIndex:t.id,streamPath:`/${e.join(\"/\")}`})}get name(){return this.metadata.name}get pathString(){return`/${this.path.join(\"/\")}`}getString(){return this.pathString}},FXe=class extends _1n{type=\"compound-stream\";contentSource;loadedContent;constructor(t,e,n){super(t,e),this.contentSource=n,n instanceof Uint8Array\u0026\u0026(this.loadedContent=n)}get content(){return this.loadedContent??=typeof this.contentSource==\"function\"?this.contentSource():this.contentSource,this.loadedContent}get isContentLoaded(){return this.loadedContent!==void 0}replaceContent(t){this.loadedContent=t.slice(),this.markDirty()}getChildren(){return[]}},f1n=class Q4n extends _1n{type=\"compound-storage\";entries;constructor(e,n,o){super(e,n),this.entries=o,this.adoptChildren(o)}get storages(){return this.entries.filter(e=\u003ee instanceof Q4n)}get streams(){return this.entries.filter(e=\u003ee instanceof FXe)}getChildren(){return[...this.entries]}},Pqi=class extends o8{type=\"compound-file\";header;originalBytes;root;constructor(t){super({sourceLocation:{byteOffset:0,streamPath:\"/\"}}),this.header=t.header,this.originalBytes=t.originalBytes,this.root=t.root,this.adoptChildren([this.root]),this.clearDirty(!0)}get entries(){const t=[],e=n=\u003e{for(const o of n.entries)t.push(o),o instanceof f1n\u0026\u0026e(o)};return e(this.root),t}get streams(){return this.entries.filter(t=\u003et instanceof FXe)}getStream(t){const e=Mqi(t);return this.streams.find(n=\u003en.path.length===e.length\u0026\u0026n.path.every((o,i)=\u003eo.toLowerCase()===e[i]?.toLowerCase()))}getBytes(){if(this.isDirty)throw new Yg(\"Modified compound files cannot yet be serialized safely\");return this.originalBytes.slice()}getChildren(){return[this.root]}getString(){return this.entries.map(t=\u003et.pathString).join(`\n`)}};function Mqi(t){return(Array.isArray(t)?t:t.split(/[\\\\/]/u)).filter(Boolean)}var LXe=class extends pXe{},Kee=class extends LXe{type=\"ini-section-line\";_name;leading;trailing;constructor(t){super(t),this._name=t.name,this.leading=t.leading??\"\",this.trailing=t.trailing??\"\"}get name(){return this._name}set name(t){if(/[\\]\\r\\n]/u.test(t))throw new Error(\"INI section names cannot contain closing brackets\");t!==this._name\u0026\u0026(this._name=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}[${this.name}]${this.trailing}`}},HXe=class extends LXe{type=\"ini-key-value-line\";_key;_value;afterEquals;beforeEquals;leading;constructor(t){super(t),this._key=t.key,this._value=t.value??\"\",this.leading=t.leading??\"\",this.beforeEquals=t.beforeEquals??\"\",this.afterEquals=t.afterEquals??\"\"}get key(){return this._key}set key(t){if(t.length===0||/[=\\r\\n]/u.test(t))throw new Error(\"INI keys must be non-empty and cannot contain '='\");t!==this._key\u0026\u0026(this._key=t,this.markDirty())}get value(){return this._value}set value(t){if(/[\\r\\n]/u.test(t))throw new Error(\"INI values cannot contain line terminators\");t!==this._value\u0026\u0026(this._value=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}${this.key}${this.beforeEquals}=${this.afterEquals}${this.value}`}},I1n=class extends LXe{type=\"ini-comment-line\";_raw;constructor(t){super(t),this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[\\r\\n]/u.test(t))throw new Error(\"INI comments cannot contain line terminators\");t!==this._raw\u0026\u0026(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}},Dqi=class extends I1n{type=\"ini-raw-line\"},h1e=class extends o8{type=\"ini-document\";_lines;originalBytes;originalSource;sourceEncoding;constructor(t={}){super({sourceLocation:{column:1,endOffset:t.originalSource?.length,line:1,startOffset:0}}),this._lines=t.lines??[],this.originalBytes=t.originalBytes?.slice(),this.originalSource=t.originalSource,this.sourceEncoding=t.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(t,e){return this.originalBytes=t.slice(),this.sourceEncoding=e,this}getBytes(){return!this.isDirty\u0026\u0026this.originalBytes?this.originalBytes.slice():c1e(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(t){t!==this._lines\u0026\u0026(this._lines=t,this.adoptChildren(t),this.markDirty())}get sections(){const t=[{entries:[],name:\"\"}];for(const e of this.lines)e instanceof Kee?t.push({entries:[],header:e,name:e.name}):e instanceof HXe\u0026\u0026t.at(-1)?.entries.push(e);return t}getSection(t){const e=t.toUpperCase();return this.sections.find(n=\u003en.name.toUpperCase()===e)}getAll(t,e){const n=e.toUpperCase();return this.getSection(t)?.entries.filter(o=\u003eo.key.toUpperCase()===n).map(o=\u003eo.value)??[]}get(t,e){return this.getAll(t,e)[0]}set(t,e,n){const o=this.getSection(t),i=e.toUpperCase(),r=o?.entries.find(A=\u003eA.key.toUpperCase()===i);if(r)return r.value=n,this;let s=this.lines.length;if(o){const A=o.header?this.lines.indexOf(o.header):-1,c=this.lines.findIndex((l,u)=\u003eu\u003eA\u0026\u0026l instanceof Kee);s=c\u003c0?this.lines.length:c}else{const A=C1n(this),c=this.lines.at(-1);c\u0026\u0026c.terminator===\"\"\u0026\u0026(c.terminator=A,c.markDirty());const l=new Kee({name:t,terminator:A}).setParent(this);this.lines.push(l),s=this.lines.length}const a=new HXe({key:e,terminator:C1n(this),value:n}).setParent(this);return this.lines.splice(s,0,a),this.markDirty(),this}removeSection(t){const e=this.getSection(t);if(!e)return!1;const n=e.header?this.lines.indexOf(e.header):0,o=this.lines.findIndex((s,a)=\u003ea\u003en\u0026\u0026s instanceof Kee),i=(o\u003c0?this.lines.length:o)-n,r=this.lines.splice(n,i);for(const s of r)s.setParent(void 0);return this.markDirty(),!0}getChildren(){return[...this.lines]}getString(){return!this.isDirty\u0026\u0026this.originalSource!==void 0?this.originalSource:this.lines.map(t=\u003e`${t.getString()}${t.terminator}`).join(\"\")}};function Nqi(t){return new h1e({lines:p1e(t),originalSource:t})}function p1e(t){return Rqi(t).map(({content:e,lineNumber:n,startOffset:o,terminator:i})=\u003e{const r={column:1,endColumn:e.length+1,endLine:n,endOffset:o+e.length,line:n,startOffset:o},s={nodeId:`ini:${o}`,sourceLocation:r,terminator:i},a=/^(\\s*)\\[([^\\]]*)\\](\\s*)$/u.exec(e);if(a?.[2]!==void 0)return new Kee({...s,leading:a[1],name:a[2],trailing:a[3]});if(/^\\s*[;#]/u.test(e))return new I1n({...s,raw:e});const A=e.indexOf(\"=\");if(A\u003e0){const c=e.slice(0,A),l=/^\\s*/u.exec(c)?.[0]??\"\",u=c.slice(l.length),g=u.trimEnd(),h=u.slice(g.length),d=e.slice(A+1),p=/^\\s*/u.exec(d)?.[0]??\"\";return new HXe({...s,afterEquals:p,beforeEquals:h,key:g,leading:l,value:d.slice(p.length)})}return new Dqi({...s,raw:e})})}function Rqi(t){const e=[];let n=0,o=1;for(let i=0;i\u003ct.length;i++){const r=t[i];if(r!==\"\\r\"\u0026\u0026r!==`\n`)continue;const s=r===\"\\r\"\u0026\u0026t[i+1]===`\n`;e.push({content:t.slice(n,i),lineNumber:o,startOffset:n,terminator:s?`\\r\n`:r}),s\u0026\u0026i++,n=i+1,o++}return n\u003ct.length\u0026\u0026e.push({content:t.slice(n),lineNumber:o,startOffset:n,terminator:\"\"}),e}function C1n(t){return t.lines.find(e=\u003ee.terminator!==\"\")?.terminator??`\n`}var Tqi=class extends h1e{type=\"output-job-document\";constructor(t={}){super(t)}get outputs(){return this.sections.flatMap(t=\u003e{const e=rK(t,\"OUTPUTTYPE\")??rK(t,\"OUTPUTGENERATOR\")??rK(t,\"OUTPUTNAME\");return e===void 0?[]:[{category:Lqi(e),dataSource:rK(t,\"DATASOURCE\")??rK(t,\"SOURCE\"),outputType:e,section:t,settings:Fqi(t),variant:rK(t,\"VARIANT\")}]})}get containers(){return this.sections.filter(t=\u003et.entries.some(e=\u003e/^(?:CONTAINERTYPE|OUTPUTMEDIUM|OUTPUTCONTAINER)$/iu.test(e.key)))}get fabricationOutputs(){return this.outputs.filter(t=\u003et.category===\"fabrication\")}get drillOutputs(){return this.outputs.filter(t=\u003et.category===\"drill\")}get pickAndPlaceOutputs(){return this.outputs.filter(t=\u003et.category===\"pick-and-place\")}get bomOutputs(){return this.outputs.filter(t=\u003et.category===\"bom\")}get drawingOutputs(){return this.outputs.filter(t=\u003et.category===\"drawing\")}get reportOutputs(){return this.outputs.filter(t=\u003et.category===\"report\")}};function kqi(t){return new Tqi({lines:p1e(t),originalSource:t})}function rK(t,e){const n=e.toUpperCase();return t.entries.find(o=\u003eo.key.toUpperCase()===n)?.value}function Fqi(t){const e={};for(const n of t.entries){const o=n.key.toUpperCase(),i=e[o];i?i.push(n.value):e[o]=[n.value]}return e}function Lqi(t){return/GERBER|ODB|IPC.?2581/iu.test(t)?\"fabrication\":/DRILL|NC\\b/iu.test(t)?\"drill\":/PICK.?AND.?PLACE|PICK.?PLACE|PICKPLACE|CENTROID/iu.test(t)?\"pick-and-place\":/\\bBOM\\b|BILL OF MATERIAL/iu.test(t)?\"bom\":/DRAWING|PDF|DRAFTSMAN|PRINT/iu.test(t)?\"drawing\":/ASSEMBLY/iu.test(t)?\"assembly\":/REPORT|VALIDATION|DESIGN RULE|ERC|DRC/iu.test(t)?\"report\":\"unknown\"}var Hqi=class{constructor(t,e){this.project=t,this.baseDirectory=e,this.nodes=t.documents.map(n=\u003e({kind:n.kind,path:n.path,reference:n,resolvedPath:OXe(e,n.path),uniqueId:n.uniqueId}));for(const n of this.nodes)this.byPath.set(m1e(n.resolvedPath).toUpperCase(),n),n.uniqueId\u0026\u0026this.byUniqueId.set(n.uniqueId.toUpperCase(),n)}project;baseDirectory;byPath=new Map;byUniqueId=new Map;nodes;getByKind(t){const e=t.toUpperCase();return this.nodes.filter(n=\u003en.kind?.toUpperCase()===e)}getByPath(t){return this.byPath.get(m1e(t).toUpperCase())}getByUniqueId(t){return this.byUniqueId.get(t.toUpperCase())}},Oqi=class extends h1e{type=\"project-document\";constructor(t={}){super(t)}get documents(){return this.sections.flatMap(t=\u003e{const e=sK(t,\"DOCUMENTPATH\");return e?[{kind:sK(t,\"DOCUMENTKIND\")??E1n(e),path:e,section:t,uniqueId:sK(t,\"DOCUMENTUNIQUEID\")}]:[]})}get variants(){return this.sections.flatMap(t=\u003e{if(!t.name.toUpperCase().includes(\"VARIANT\"))return[];const e=sK(t,\"VARIANTNAME\")??sK(t,\"NAME\")??t.name;return[{alternateParts:GXe(t,/ALTERNATE|PARTCHOICE/iu),description:sK(t,\"DESCRIPTION\"),name:e,parameters:GXe(t,/PARAMETER/iu),section:t}]})}get projectOptions(){return this.sections.filter(t=\u003e/^(?:DESIGN|PROJECTOPTIONS?|OPTIONS?|PREFERENCES)$/iu.test(t.name))}get projectParameters(){return this.sections.flatMap(t=\u003eGXe(t,/PARAMETER/iu,/PARAMETER|PARAMETERS/iu.test(t.name)))}get compilerSettings(){return this.sections.filter(t=\u003e/COMPILER|COMPILATION/iu.test(t.name))}get ecoSettings(){return this.sections.filter(t=\u003e/\\bECO\\b/iu.test(t.name))}resolveDocumentPaths(t){return this.documents.map(e=\u003eOXe(t,e.path))}getDocumentGraph(t){return new Hqi(this,t)}addDocument(t,e={}){if(t.trim().length===0||t.includes(\"\\0\")||/[\\r\\n]/u.test(t))throw new TypeError(\"Project document paths must be non-empty single-line values\");const n=B1n(this,\"Document\");this.set(n,\"DocumentPath\",t);const o=e.kind??E1n(t);o\u0026\u0026this.set(n,\"DocumentKind\",o),e.uniqueId\u0026\u0026this.set(n,\"DocumentUniqueId\",e.uniqueId);const i=this.documents.find(r=\u003er.section.name===n);if(!i)throw new Error(\"Failed to create project document reference\");return i}removeDocument(t){const e=typeof t==\"string\"?this.documents.find(n=\u003en.path===t||n.uniqueId===t):t;return e?this.removeSection(e.section.name):!1}addVariant(t,e={}){if(t.trim().length===0||t.includes(\"\\0\")||/[\\r\\n]/u.test(t))throw new TypeError(\"Project variant names must be non-empty single-line values\");const n=B1n(this,\"Variant\");this.set(n,\"VariantName\",t),e.description\u0026\u0026this.set(n,\"Description\",e.description);const o=this.variants.find(i=\u003ei.section.name===n);if(!o)throw new Error(\"Failed to create project variant\");return o}removeVariant(t){const e=typeof t==\"string\"?this.variants.find(n=\u003en.name===t):t;return e?this.removeSection(e.section.name):!1}};function y1n(t){return new Oqi({lines:p1e(t),originalSource:t})}function OXe(t,e){if(Gqi(e))return m1e(e);const n=/\\\\/u.test(t)?\"\\\\\":\"/\",o=`${x1n(t)}${n}${e}`;return m1e(o,n)}function Gqi(t){return/^(?:[a-z]:[\\\\/]|\\\\\\\\|\\/)/iu.test(t)}function m1e(t,e){const n=e??(/\\\\/u.test(t)\u0026\u0026!/\\//u.test(t)?\"\\\\\":\"/\"),o=/^([a-z]:|\\\\\\\\[^\\\\/]+[\\\\/][^\\\\/]+|\\/)/iu.exec(t)?.[0]??\"\",i=t.slice(o.length).split(/[\\\\/]+/u).filter(Boolean),r=[];for(const A of i)A!==\".\"\u0026\u0026(A===\"..\"\u0026\u0026r.length\u003e0?r.pop():A!==\"..\"\u0026\u0026r.push(A));const s=x1n(o),a=r.join(n);return o===\"/\"?`/${a}`:s?a?`${s}${n}${a}`:s:a}function x1n(t){let e=t.length;for(;e\u003e0;){const n=t[e-1];if(n!==\"/\"\u0026\u0026n!==\"\\\\\")break;e--}return t.slice(0,e)}function E1n(t){const e=/\\.([^.\\\\/]+)$/u.exec(t)?.[1]?.toLowerCase();return e===void 0?void 0:{outjob:\"output-job\",pcbdoc:\"pcb-document\",pcblib:\"pcb-library\",schdoc:\"schematic-document\",schlib:\"schematic-library\"}[e]}function sK(t,e){const n=e.toUpperCase();return t.entries.find(o=\u003eo.key.toUpperCase()===n)?.value}function GXe(t,e,n=!1){return t.entries.filter(o=\u003en||e.test(o.key)).map(o=\u003e({key:o.key,section:t,value:o.value}))}function B1n(t,e){const n=new Set(t.sections.map(i=\u003ei.name.toUpperCase()));let o=1;for(;n.has(`${e}${o}`.toUpperCase());)o++;return`${e}${o}`}var Yqi=class extends h1e{type=\"workspace-document\";constructor(t={}){super(t)}get projects(){return this.sections.flatMap(t=\u003e/SESSION|WINDOW|VIEW|RECENT|UI/iu.test(t.name)?[]:t.entries.filter(e=\u003e/PROJECT/iu.test(e.key)\u0026\u0026/\\.PRJPCB(?:$|[?#])/iu.test(e.value.trim())).map(e=\u003e({key:e.key,path:e.value,section:t})))}get sessionSections(){return this.sections.filter(t=\u003e/SESSION|WINDOW|VIEW|RECENT|UI/iu.test(t.name))}resolveProjectPaths(t){return this.projects.map(e=\u003eOXe(t,e.path))}};function Uqi(t){return new Yqi({lines:p1e(t),originalSource:t})}var b1n=new Uint8Array([208,207,17,224,161,177,26,225]),S1n=4294967290,Q1n=4294967294,_1e=4294967295,v1n=4294967295;function f1e(t){return t.byteLength\u003e=b1n.byteLength\u0026\u0026b1n.every((e,n)=\u003et[n]===e)}function Vee(t,e={}){const n=e.maxFileSize??268435456,o=e.maxChainLength??1e6,i=e.maxDirectoryEntries??1e5;if(t.byteLength\u003en)throw new aA(`Compound file is ${t.byteLength} bytes, exceeding the ${n}-byte limit`);if(t.byteLength\u003c512)throw new aA(\"Compound file header is truncated\",{byteOffset:t.byteLength});if(!f1e(t))throw new aA(\"Input does not begin with the OLE/CFB signature\",{byteOffset:0});const r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=r.getUint16(24,!0),a=r.getUint16(26,!0),A=r.getUint16(28,!0),c=r.getUint16(30,!0),l=r.getUint16(32,!0);if(a!==3\u0026\u0026a!==4)throw new jji(`Unsupported CFB major version ${a}`);const u=a===3?9:12;if(c!==u)throw new aA(`CFB version ${a} must use sector shift ${u}, got ${c}`,{byteOffset:30});if(A!==65534)throw new aA(`Unsupported CFB byte order 0x${A.toString(16)}`,{byteOffset:28});const g=2**c,h=2**l,d=Math.floor(t.byteLength/g)-1;if(d\u003c0)throw new aA(\"Compound file has no sectors\");const p=r.getUint32(40,!0),m=r.getUint32(44,!0),_=r.getUint32(48,!0),f=r.getUint32(56,!0),I=r.getUint32(60,!0),C=r.getUint32(64,!0),y=r.getUint32(68,!0),x=r.getUint32(72,!0),E={byteOrder:A,directorySectorCount:p,fatSectorCount:m,majorVersion:a,miniFatSectorCount:C,miniSectorSize:h,miniStreamCutoffSize:f,minorVersion:s,sectorSize:g},B=ne=\u003e{zqi(ne,d);const le=(ne+1)*g,ge=le+g;if(ge\u003et.byteLength)throw new aA(`Sector ${ne} extends beyond the file`,{byteOffset:le});return t.subarray(le,ge)},S=[];for(let ne=0;ne\u003c109;ne++){const le=r.getUint32(76+ne*4,!0);le!==_1e\u0026\u0026S.push(le)}let Q=y;const w=new Set;for(let ne=0;ne\u003cx;ne++){if(Q===Q1n||Q===_1e)throw new aA(`DIFAT chain ended after ${ne} of ${x} sectors`);if(w.has(Q))throw new aA(`DIFAT chain contains a loop at sector ${Q}`);w.add(Q);const le=B(Q),ge=zee(le),_e=g/4-1;for(let ue=0;ue\u003c_e;ue++){const fe=ge.getUint32(ue*4,!0);fe!==_1e\u0026\u0026S.push(fe)}Q=ge.getUint32(g-4,!0)}if(S.length\u003cm)throw new aA(`Header declares ${m} FAT sectors, but DIFAT contains ${S.length}`);S.length=m;const M=[];for(const ne of S){const le=B(ne),ge=zee(le);for(let _e=0;_e\u003cle.byteLength;_e+=4)M.push(ge.getUint32(_e,!0))}const k=(ne,le)=\u003ew1n({allocationTable:M,expectedSize:le,maxChainLength:o,readUnit:B,startSector:ne,unitSize:g}),R=k(_),F=Kqi(R,a,i),O=F[0];if(O?.rawType!==5)throw new aA(\"Directory entry 0 is not a root storage\");const U=k(O.metadata.startSector,O.metadata.size),Y=C===0?new Uint8Array:k(I,C*g),W=zee(Y),te=[];for(let ne=0;ne+4\u003c=Y.byteLength;ne+=4)te.push(W.getUint32(ne,!0));const j=ne=\u003e{const le=ne*h,ge=le+h;if(ne\u003c0||ge\u003eU.byteLength)throw new aA(`Mini sector ${ne} extends beyond the root mini stream`);return U.subarray(le,ge)},J=ne=\u003e{if(ne.size===0)return new Uint8Array;if(ne.size\u003cf){if(te.length===0)throw new aA(`Stream ${JSON.stringify(ne.name)} requires a MiniFAT`);return w1n({allocationTable:te,expectedSize:ne.size,maxChainLength:o,readUnit:j,startSector:ne.startSector,unitSize:h})}return k(ne.startSector,ne.size)},oe=new Set([0]),ie=(ne,le)=\u003e{const ge=ne.rawType===5?le:[...le,ne.metadata.name],_e=[],ue=Vqi(ne.metadata.childId,F);for(const fe of ue){if(oe.has(fe))throw new aA(`Directory entry ${fe} is referenced more than once`);oe.add(fe);const pe=F[fe];!pe||pe.rawType===0||(pe.rawType===1?_e.push(ie(pe,ge)):pe.rawType===2\u0026\u0026_e.push(new FXe(pe.metadata,[...ge,pe.metadata.name],()=\u003eJ(pe.metadata))))}return new f1n(ne.metadata,ge,_e)};return new Pqi({header:E,originalBytes:t.slice(),root:ie(O,[])})}function Kqi(t,e,n){const o=Math.floor(t.byteLength/128);if(o\u003en)throw new aA(`Directory contains ${o} entries, exceeding the ${n}-entry limit`);const i=[],r=zee(t);for(let s=0;s\u003co;s++){const a=s*128,A=r.getUint16(a+64,!0),c=r.getUint8(a+66);if(A\u003e64||A%2!==0)throw new aA(`Directory entry ${s} has invalid UTF-16 name length ${A}`,{byteOffset:a+64});const l=t.subarray(a,a+Math.max(A-2,0)),u=r.getBigUint64(a+120,!0),g=Number(e===3?u\u00260xffffffffn:u);if(!Number.isSafeInteger(g))throw new aA(`Directory entry ${s} stream size exceeds JavaScript's safe integer range`);i.push({metadata:{childId:r.getUint32(a+76,!0),clsid:Wqi(t.subarray(a+80,a+96)),color:r.getUint8(a+67),creationTime:r.getBigUint64(a+100,!0),id:s,leftSiblingId:r.getUint32(a+68,!0),modifiedTime:r.getBigUint64(a+108,!0),name:l.byteLength===0?\"\":jqi(l),rightSiblingId:r.getUint32(a+72,!0),size:g,startSector:r.getUint32(a+116,!0),stateBits:r.getUint32(a+96,!0),type:Jqi(c)},rawType:c})}return i}function Vqi(t,e){if(t===v1n)return[];const n=[],o=new Set,i=r=\u003e{if(r===v1n)return;if(r\u003e=e.length)throw new aA(`Directory sibling tree references missing entry ${r}`);if(o.has(r))throw new aA(`Directory sibling tree contains a loop at entry ${r}`);o.add(r);const s=e[r];s\u0026\u0026(i(s.metadata.leftSiblingId),n.push(r),i(s.metadata.rightSiblingId))};return i(t),n}function w1n(t){if(t.expectedSize===0)return new Uint8Array;const e=[],n=new Set;let o=t.startSector;for(;o!==Q1n;){if(o\u003e=S1n||o\u003e=t.allocationTable.length)throw new aA(`Sector chain references invalid sector ${o}`);if(n.has(o))throw new aA(`Sector chain contains a loop at sector ${o}`);if(e.length\u003e=t.maxChainLength)throw new aA(`Sector chain exceeds the ${t.maxChainLength}-sector limit`);n.add(o),e.push(o),o=t.allocationTable[o]??_1e}const i=e.length*t.unitSize;if(t.expectedSize!==void 0\u0026\u0026i\u003ct.expectedSize)throw new aA(`Sector chain contains ${i} bytes, expected ${t.expectedSize}`);const r=t.expectedSize??i,s=new Uint8Array(r);let a=0;for(const A of e){if(a\u003e=r)break;const c=t.readUnit(A),l=r-a;s.set(c.subarray(0,Math.min(c.byteLength,l)),a),a+=Math.min(c.byteLength,l)}return s}function zqi(t,e){if(t\u003e=S1n||t\u003e=e)throw new aA(`Invalid regular sector ${t}; file contains ${e} sectors`)}function zee(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Jqi(t){return t===1?\"storage\":t===2?\"stream\":t===5?\"root\":\"stream\"}function Wqi(t){return[...t].map(e=\u003ee.toString(16).padStart(2,\"0\")).join(\"\")}function jqi(t){const e=zee(t),n=[];for(let o=0;o+2\u003c=t.byteLength;o+=2)n.push(e.getUint16(o,!0));return String.fromCharCode(...n)}function $qi(t,e={}){const n=e.maxFileSize??268435456;if(!Number.isSafeInteger(n)||n\u003c=0)throw new RangeError(\"maxFileSize must be a positive safe integer\");if(t.byteLength\u003en)throw new RangeError(`Altium file is ${t.byteLength} bytes, exceeding the ${n}-byte detection limit`);if(t.byteLength\u003e=4\u0026\u0026t[0]===80\u0026\u0026t[1]===75\u0026\u0026(t[2]===3||t[2]===5||t[2]===7)\u0026\u0026(t[3]===4||t[3]===6||t[3]===8))return{confidence:1,container:\"zip\",documentKind:\"zip-container\",encoding:\"binary\",evidence:[\"ZIP local-file or directory signature\"]};if(f1e(t)){const a=Vee(t,e),A=[\"OLE/CFB signature\"];if(a.getStream(\"/Board6/Data\")\u0026\u0026a.getStream(\"/Board6/Header\"))return A.push(\"Board6/Data and Board6/Header streams\"),{confidence:1,container:\"cfb\",documentKind:\"pcb-document\",encoding:\"binary\",evidence:A};const c=a.getStream(\"/FileHeader\"),u=(c?qqi(c.content):void 0)?.toLowerCase();return u?.includes(\"schematic library\")?(A.push(\"schematic library FileHeader stream\"),{confidence:.95,container:\"cfb\",documentKind:\"schematic-library\",encoding:\"binary\",evidence:A}):u?.includes(\"pcb library\")?(A.push(\"PCB library FileHeader stream\"),{confidence:.95,container:\"cfb\",documentKind:\"pcb-library\",encoding:\"binary\",evidence:A}):u?.includes(\"integrated library\")?(A.push(\"integrated library FileHeader stream\"),{confidence:.9,container:\"cfb\",documentKind:\"integrated-library\",encoding:\"binary\",evidence:A}):u?.includes(\"schematic capture\")?(A.push(\"schematic capture FileHeader stream\"),{confidence:1,container:\"cfb\",documentKind:\"schematic-document\",encoding:\"binary\",evidence:A}):{confidence:.8,container:\"cfb\",documentKind:\"compound-file\",encoding:\"binary\",evidence:A}}const o=SXe(t,e.encoding),i=o.text.replace(/^\\uFEFF/u,\"\"),r=i.trimStart(),s=[];if(/^\u003c\\?xml(?:\\s|\u003e)/iu.test(r)||/^\u003c[a-z][^\u003e]*\u003e/iu.test(r))return{confidence:.85,container:\"xml\",documentKind:\"xml-document\",encoding:o.encoding,evidence:[\"XML declaration or root element\"]};if(/^\\|RECORD=Board(?:\\||$)/imu.test(i))return s.push(\"Board root record\"),{confidence:.98,container:\"ascii\",documentKind:\"pcb-document\",encoding:o.encoding,evidence:s};if(/^\\|HEADER=[^\\r\\n]*Schematic Library/imu.test(i))return{confidence:.95,container:\"ascii\",documentKind:\"schematic-library\",encoding:o.encoding,evidence:[\"schematic library header\"]};if(/^\\|HEADER=[^\\r\\n]*(?:PCB|Printed Circuit Board) Library/imu.test(i)||/^\\|RECORD=(?:Pcb)?Library(?:\\||$)/imu.test(i))return{confidence:.9,container:\"ascii\",documentKind:\"pcb-library\",encoding:o.encoding,evidence:[\"PCB library header or root record\"]};if(/^\\|HEADER=[^\\r\\n]*Schematic Capture/imu.test(i)||/^\\|RECORD=31(?:\\||$)/imu.test(i))return s.push(\"schematic header or sheet record\"),{confidence:.95,container:\"ascii\",documentKind:\"schematic-document\",encoding:o.encoding,evidence:s};if(/^\\|(?:RECORD|HEADER)=/mu.test(i))return s.push(\"Altium property records\"),{confidence:.65,container:\"ascii\",documentKind:\"unknown\",encoding:o.encoding,evidence:s};if(/^\\s*\\[[^\\]\\r\\n]+\\]\\s*$/mu.test(i)){const a=i.toUpperCase();return/DOCUMENTPATH\\s*=/u.test(a)||/\\[(?:DESIGN|DOCUMENT\\d+|SOURCEPROJECT)\\]/u.test(a)?{confidence:.86,container:\"ini\",documentKind:\"project\",encoding:o.encoding,evidence:[\"INI sections and project document metadata\"]}:/OUTPUT(?:TYPE|GENERATOR|MEDIUM|CONTAINER)\\s*=/u.test(a)||/\\[OUTPUTJOB/u.test(a)?{confidence:.86,container:\"ini\",documentKind:\"output-job\",encoding:o.encoding,evidence:[\"INI sections and output-job metadata\"]}:/\\[(?:PROJECTGROUP|WORKSPACE)/u.test(a)?{confidence:.8,container:\"ini\",documentKind:\"workspace\",encoding:o.encoding,evidence:[\"INI sections and workspace metadata\"]}:{confidence:.65,container:\"ini\",documentKind:\"ini-document\",encoding:o.encoding,evidence:[\"INI section syntax\"]}}return{confidence:.1,container:\"ascii\",documentKind:\"unknown\",encoding:o.encoding,evidence:s}}function qqi(t){if(t.byteLength\u003c8)return;const n=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!0)\u002616777215;if(n===0||n\u003et.byteLength-4)return;const o=t.subarray(4,4+n);return new TextDecoder(\"windows-1252\").decode(o)}var P1n=class extends Ol{type=\"arc-record\";constructor(t={}){super(t)}get center(){return qh(this,[\"LOCATION.X\",\"X\"],[\"LOCATION.Y\",\"Y\"])}get radiusMils(){return tc(this,\"RADIUS\")}get widthMils(){return tc(this,\"WIDTH\")}get startAngle(){return xI(this.getNumber(\"STARTANGLE\")??0)}get endAngle(){return xI(this.getNumber(\"ENDANGLE\")??360)}get layer(){return pi(this,\"LAYER\")}get netIndex(){return this.getNumber(\"NET\")}get componentIndex(){return this.getNumber(\"COMPONENT\")}get polygonIndex(){return this.getNumber(\"POLYGON\")}get isFullCircle(){const t=this.getNumber(\"STARTANGLE\")??0,e=this.getNumber(\"ENDANGLE\")??360;return Math.abs(e-t)\u003e=360||e===t}},M1n=class extends Ol{type=\"fill-record\";constructor(t={}){super(t)}get start(){return qh(this,[\"X1\"],[\"Y1\"])}get end(){return qh(this,[\"X2\"],[\"Y2\"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get layer(){return pi(this,\"LAYER\")}get netIndex(){return this.getNumber(\"NET\")}get componentIndex(){return this.getNumber(\"COMPONENT\")}},D1n=class extends Ol{type=\"pad-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get componentIndex(){return this.getNumber(\"COMPONENT\")}get netIndex(){return this.getNumber(\"NET\")}get layer(){return pi(this,\"LAYER\")}get position(){return qh(this,[\"X\"],[\"Y\"])}get size(){return Yee(this,[\"XSIZE\"],[\"YSIZE\"])}get middleSize(){return Yee(this,[\"MIDXSIZE\",\"MIDLAYER1XSIZE\"],[\"MIDYSIZE\",\"MIDLAYER1YSIZE\"])}get bottomSize(){return Yee(this,[\"BOTTOMXSIZE\",\"BOTTOMLAYERXSIZE\"],[\"BOTTOMYSIZE\",\"BOTTOMLAYERYSIZE\"])}get holeSizeMils(){return tc(this,\"HOLESIZE\")}get holeWidthMils(){return tc(this,\"HOLEWIDTH\")}get shape(){return pi(this,\"SHAPE\")}get middleShape(){return pi(this,\"MIDSHAPE\")}get bottomShape(){return pi(this,\"BOTTOMSHAPE\")}get holeType(){return pi(this,\"HOLETYPE\",\"HOLESHAPE\")}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get holeRotation(){return xI(this.getNumber(\"HOLEROTATION\")??this.getNumber(\"SLOTROTATION\")??0)}get plated(){return this.getBoolean(\"PLATED\")}get padMode(){return this.getNumber(\"PADMODE\")}get behavior(){const t=this.layer?.toUpperCase();return(this.holeSizeMils??0)\u003e0||t===\"MULTILAYER\"?\"through-hole\":t===\"TOP\"||t===\"BOTTOM\"||t===\"TOP LAYER\"||t===\"BOTTOM LAYER\"?\"smd\":\"unknown\"}get pasteMaskExpansionMils(){return tc(this,\"PASTEMASKEXPANSION_MANUAL\")}get solderMaskExpansionMils(){return tc(this,\"SOLDERMASKEXPANSION_MANUAL\")}get tentedTop(){return this.getBoolean(\"TENTEDTOP\")??this.getBoolean(\"TENTINGTOP\")}get tentedBottom(){return this.getBoolean(\"TENTEDBOTTOM\")??this.getBoolean(\"TENTINGBOTTOM\")}};function N1n(t){if(!t)return\"\";if(!/^\\d+(?:,\\d+)*$/u.test(t))return t;try{return String.fromCodePoint(...t.split(\",\").map(e=\u003eNumber(e)))}catch{return t}}var R1n=class extends Ol{type=\"text-record\";constructor(t={}){super(t)}get text(){const t=this.getDecoded(\"WIDESTRING\");return t===void 0?pi(this,\"TEXT\"):N1n(t)}get position(){return qh(this,[\"X\"],[\"Y\"])}get layer(){return pi(this,\"LAYER\")}get heightMils(){return tc(this,\"HEIGHT\")}get strokeWidthMils(){return tc(this,\"WIDTH\")}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get mirrored(){return this.getBoolean(\"MIRROR\")}get inverted(){return this.getBoolean(\"INVERTED\")}get justification(){return pi(this,\"JUSTIFICATION\")}get fontName(){return pi(this,\"FONTNAME\")}get usesTrueTypeFont(){return this.getBoolean(\"USETTFONTS\")??this.getBoolean(\"FONTTYPE\")}get textBoxSize(){return Yee(this,[\"TEXTBOXWIDTH\"],[\"TEXTBOXHEIGHT\"])}get componentIndex(){return this.getNumber(\"COMPONENT\")}get isDesignator(){return this.getBoolean(\"DESIGNATOR\")===!0}get isComment(){return this.getBoolean(\"COMMENT\")===!0}},T1n=class extends Ol{type=\"track-record\";constructor(t={}){super(t)}get start(){return qh(this,[\"X1\"],[\"Y1\"])}get end(){return qh(this,[\"X2\"],[\"Y2\"])}get widthMils(){return tc(this,\"WIDTH\")}get layer(){return pi(this,\"LAYER\")}get netIndex(){return this.getNumber(\"NET\")}get componentIndex(){return this.getNumber(\"COMPONENT\")}get polygonIndex(){return this.getNumber(\"POLYGON\")}get unionIndex(){return this.getNumber(\"UNIONINDEX\")}get uniqueId(){return pi(this,\"UNIQUEID\")}get keepout(){return this.getBoolean(\"KEEPOUT\")}get polygonOutline(){return this.getBoolean(\"POLYGONOUTLINE\")}get userRouted(){return this.getBoolean(\"USERROUTED\")}get isZeroLength(){return this.start!==void 0\u0026\u0026this.end!==void 0?hXe(this.start,this.end):!1}},k1n=class extends Ol{type=\"via-record\";constructor(t={}){super(t)}get position(){return qh(this,[\"X\"],[\"Y\"])}get diameterMils(){return tc(this,\"DIAMETER\",\"TOPLAYERSIZE\")}get holeSizeMils(){return tc(this,\"HOLESIZE\")}get startLayer(){return pi(this,\"STARTLAYER\",\"FROMLAYER\")}get endLayer(){return pi(this,\"ENDLAYER\",\"TOLAYER\")}get netIndex(){return this.getNumber(\"NET\")}get kind(){const t=this.startLayer?.toUpperCase(),e=this.endLayer?.toUpperCase();return!t||!e?\"unknown\":t.includes(\"TOP\")\u0026\u0026e.includes(\"BOTTOM\")||t.includes(\"BOTTOM\")\u0026\u0026e.includes(\"TOP\")?\"through\":\"blind-buried\"}get tentedTop(){return this.getBoolean(\"TENTEDTOP\")??this.getBoolean(\"TENTINGTOP\")}get tentedBottom(){return this.getBoolean(\"TENTEDBOTTOM\")??this.getBoolean(\"TENTINGBOTTOM\")}},F1n=class extends o8{type=\"raw-field\";_raw;constructor(t){if(super(t),/[|\\r\\n]/u.test(t.raw))throw new Error(\"Raw Altium fields cannot contain record delimiters\");this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[|\\r\\n]/u.test(t))throw new Error(\"Raw Altium fields cannot contain record delimiters\");t!==this._raw\u0026\u0026(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,raw:this.raw}}},I1e=class extends Ol{type=\"unknown-record\";constructor(t={}){super(t)}},L1n=class extends Ol{type=\"component-body-record\";constructor(t={}){super(t)}get componentIndex(){return this.getNumber(\"COMPONENT\")}get bodyKind(){return pi(this,\"KIND\")}get identifier(){return pi(this,\"IDENTIFIER\",\"NAME\")}get modelId(){return pi(this,\"MODELID\")}get modelEmbedded(){return this.getBoolean(\"MODEL.EMBED\")}get modelPosition(){return qh(this,[\"MODEL.2D.X\"],[\"MODEL.2D.Y\"])}get modelRotation2d(){return xI(this.getNumber(\"MODEL.2D.ROTATION\")??0)}get modelRotation3d(){return{x:xI(this.getNumber(\"MODEL.3D.ROTX\")??0),y:xI(this.getNumber(\"MODEL.3D.ROTY\")??0),z:xI(this.getNumber(\"MODEL.3D.ROTZ\")??0)}}get standoffHeightMils(){return tc(this,\"STANDOFFHEIGHT\")}get overallHeightMils(){return tc(this,\"OVERALLHEIGHT\")}get opacity(){return this.getNumber(\"BODYOPACITY3D\")}},Xqi=class extends Ol{type=\"differential-pair-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get positiveNet(){return pi(this,\"POSITIVENET\",\"POSITIVE\")}get negativeNet(){return pi(this,\"NEGATIVENET\",\"NEGATIVE\")}},Zqi=class extends Ol{type=\"from-to-record\";get from(){return pi(this,\"FROM\")}get to(){return pi(this,\"TO\")}get netIndex(){return this.getNumber(\"NET\")}},eXi=class extends Ol{type=\"connection-record\";get netIndex(){return this.getNumber(\"NET\")}get from(){return pi(this,\"FROM\")}get to(){return pi(this,\"TO\")}},tXi=class extends Ol{type=\"embedded-board-record\";constructor(t={}){super(t)}get sourcePath(){return pi(this,\"SOURCEPATH\",\"FILENAME\")}get position(){return qh(this,[\"X\",\"ORIGINX\"],[\"Y\",\"ORIGINY\"])}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get mirrored(){return this.getBoolean(\"MIRROR\")}},nXi=class extends Ol{type=\"file-version-info-record\";constructor(t={}){super(t)}get versions(){const t=[];for(let e=0;e\u003c1e4;e++){const n=pi(this,`VER${e}`);if(n===void 0)break;t.push(n)}return t}},oXi=class extends Ol{type=\"unique-id-primitive-information-record\";get primitiveIndex(){return this.getNumber(\"PRIMITIVEINDEX\")}get primitiveObjectId(){return pi(this,\"PRIMITIVEOBJECTID\")}get uniqueId(){return pi(this,\"UNIQUEID\")}},iM=class extends Ol{type=\"option-record\";get optionFamily(){return this.recordKind}},iXi=class extends iM{type=\"advanced-placer-options-record\"},rXi=class extends iM{type=\"design-rule-checker-options-record\"},sXi=class extends iM{type=\"engineering-change-order-options-record\"},aXi=class extends iM{type=\"gerber-options-record\"},AXi=class extends iM{type=\"output-options-record\"},cXi=class extends iM{type=\"pin-swap-options-record\"},lXi=class extends iM{type=\"printer-options-record\"},uXi=class extends iM{type=\"testpoint-options-record\"},gXi=class extends Ol{type=\"model-record\";constructor(t={}){super(t)}get id(){return pi(this,\"ID\")}get name(){return pi(this,\"NAME\")}get checksum(){return pi(this,\"CHECKSUM\")}get embedded(){return this.getBoolean(\"EMBED\")}get rotation(){return{x:xI(this.getNumber(\"ROTX\")??0),y:xI(this.getNumber(\"ROTY\")??0),z:xI(this.getNumber(\"ROTZ\")??0)}}get standoffRaw(){return this.getNumber(\"DZ\")}},dXi=class extends Ol{type=\"parameter-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get value(){return pi(this,\"VALUE\")}get primitiveIndex(){return this.getNumber(\"PRIMITIVEINDEX\")}get imported(){return this.getBoolean(\"ISIMPORTED\")}},YXe=class extends Ol{type=\"region-record\";constructor(t={}){super(t)}get layer(){return pi(this,\"LAYER\")}get regionKind(){return s1e(this)}get componentIndex(){return this.getNumber(\"COMPONENT\")}get netIndex(){return this.getNumber(\"NET\")}get polygonIndex(){return this.getNumber(\"POLYGON\")}get holeCount(){return Math.max(this.getNumber(\"HOLECOUNT\")??0,0)}get isGeneratedPour(){return this.recordKind===\"RegionFill\"}get isBoardCutout(){return this.regionKind===\"BOARD_CUTOUT\"}get isLayerStackRegion(){return this.regionKind===\"LAYER_STACK_REGION\"}get isPolygonCutout(){return this.regionKind===\"POLYGON_CUTOUT\"}get layerStackId(){return pi(this,\"LAYERSTACKID\")}get geometry(){return r1e(this)}},hXi=class extends Ol{type=\"room-record\";constructor(t={}){super(t)}get name(){return pi(this,\"NAME\")}get start(){return qh(this,[\"X1\"],[\"Y1\"])}get end(){return qh(this,[\"X2\"],[\"Y2\"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get ruleIndex(){return this.getNumber(\"RULE\")}},pXi=class extends Ol{type=\"smart-union-record\";constructor(t={}){super(t)}get start(){return qh(this,[\"X1\"],[\"Y1\"])}get end(){return qh(this,[\"X2\"],[\"Y2\"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get unionType(){return pi(this,\"UNIONTYPE\")}get unionIndex(){return this.getNumber(\"UNIONINDEX\")}get rotation(){return xI(this.getNumber(\"ROTATION\")??0)}get mirrored(){return this.getBoolean(\"MIRROR\")}},H1n=new Map([[\"Arc\",P1n],[\"1\",i1n],[\"2\",MXe],[\"4\",DXe],[\"5\",Z$i],[\"6\",eqi],[\"7\",tqi],[\"8\",nqi],[\"10\",oqi],[\"11\",iqi],[\"12\",rqi],[\"13\",sqi],[\"14\",aqi],[\"15\",r1n],[\"16\",Aqi],[\"17\",NXe],[\"18\",RXe],[\"22\",uqi],[\"25\",TXe],[\"26\",cqi],[\"27\",s1n],[\"28\",gqi],[\"29\",dqi],[\"30\",a1n],[\"31\",hqi],[\"32\",A1n],[\"33\",c1n],[\"34\",pqi],[\"37\",lqi],[\"39\",mqi],[\"41\",_qi],[\"44\",fqi],[\"45\",Iqi],[\"46\",Cqi],[\"48\",yqi],[\"209\",xqi],[\"AdvancedPlacerOptions\",iXi],[\"Board\",qfn],[\"BoardRegion\",YXe],[\"Class\",vXe],[\"ComponentBody\",L1n],[\"ComponentBodyLegacy\",L1n],[\"Component\",e1e],[\"Connection\",eXi],[\"Coordinate\",f$i],[\"DesignRuleCheckerOptions\",rXi],[\"DifferentialPair\",Xqi],[\"Dimension\",Vfn],[\"DXPRule\",Zfn],[\"EmbeddedBoard\",tXi],[\"EngineeringChangeOrderOptions\",sXi],[\"FileVersionInfo\",nXi],[\"Fill\",M1n],[\"FromTo\",Zqi],[\"GerberOptions\",aXi],[\"Model\",gXi],[\"Net\",t1e],[\"OutputOptions\",AXi],[\"Pad\",D1n],[\"ParamItem\",dXi],[\"PinSwapOptions\",cXi],[\"Polygon\",Xfn],[\"PrinterOptions\",lXi],[\"Region\",YXe],[\"RegionFill\",YXe],[\"Room\",hXi],[\"Rule\",wXe],[\"SignalClass\",H$i],[\"SmartUnion\",pXi],[\"TestpointOptions\",uXi],[\"Text\",R1n],[\"Track\",T1n],[\"UniqueIDPrimitiveInformation\",oXi],[\"Via\",k1n]]);function UXe(t,e,n){const o=t.at(-1)===0?t.subarray(0,t.byteLength-1):t,i=_Xi(o,124);i[0]?.byteLength===0\u0026\u0026i.shift();const r=i.map(mXi);let s=fXi(r,\"RECORD\");s===void 0\u0026\u0026e!==void 0\u0026\u0026(r.unshift(new a9({key:\"RECORD\",value:e})),s=e);const a=(s===void 0?void 0:H1n.get(s))??I1e,A=new a({items:r,originalBinaryPayload:t,sourceLocation:n});for(const[c,l]of r.entries())l.setSourceLocation(n?{...n,fieldIndex:c}:void 0);return A}function mXi(t){const e=t.indexOf(61);if(e\u003c=0)return new F1n({raw:KXe(t)});const n=t.subarray(0,e),o=t.subarray(e+1),i=KXe(n),s=(i.toUpperCase().startsWith(\"%UTF8%\")?new TextDecoder().decode(o):KXe(o)).replaceAll(\"\\r\",\"\").replaceAll(`\n`,\"\");return new a9({key:i,value:s})}function _Xi(t,e){const n=[];let o=0;for(let i=0;i\u003ct.byteLength;i++)t[i]===e\u0026\u0026(n.push(t.subarray(o,i)),o=i+1);return n.push(t.subarray(o)),n}function fXi(t,e){const n=e.toUpperCase();return t.find(o=\u003eo instanceof a9\u0026\u0026o.key.toUpperCase()===n)?.value}function KXe(t){return new TextDecoder(\"windows-1252\").decode(t)}var C1e={Arcs6:1,BoardRegions:11,ComponentBodies6:12,Fills6:6,Pads6:2,Regions6:11,ShapeBasedRegions6:11,ShapeBasedComponentBodies6:12,Texts6:5,Tracks6:4,Vias6:3},IXi=512,CXi={BoardRegions:{extendedVertices:!1,recordKind:\"BoardRegion\"},ComponentBodies6:{extendedVertices:!1,recordKind:\"ComponentBodyLegacy\"},Regions6:{extendedVertices:!1,recordKind:\"RegionFill\"},ShapeBasedRegions6:{extendedVertices:!0,recordKind:\"Region\"},ShapeBasedComponentBodies6:{extendedVertices:!0,recordKind:\"ComponentBody\"}};function yXi(t,e,n={}){if(t===\"Pads6\")return y1e(EXi(e,n),t);if(t===\"Texts6\")return y1e(BXi(e,n),t);if(t===\"BoardRegions\"||t===\"ComponentBodies6\"||t===\"Regions6\"||t===\"ShapeBasedRegions6\"||t===\"ShapeBasedComponentBodies6\")return y1e(SXi(t,e,n),t);const o=n.maximumRecordLength??16*1024*1024,i=[],r=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=0;for(;s\u003ce.byteLength;){const a=s;if(s+5\u003ee.byteLength)throw new hh(`${t} primitive frame header is truncated`,s);const A=e[s],l=r.getUint32(s+1,!0)\u002616777215;if(s+=5,A!==C1e[t])throw new yI(`${t} frame at offset ${a} has unexpected primitive type ${A}`);if(l===0||l\u003eo)throw new hh(`Invalid ${t} primitive length ${l}`,a+1);if(s+l\u003ee.byteLength)throw new hh(`${t} primitive at offset ${a} exceeds its stream`,a);const u=e.subarray(s,s+l);i.push(xXi(t,u,a)),s+=l}if(n.expectedRecordCount!==void 0\u0026\u0026i.length!==n.expectedRecordCount)throw new yI(`${t} stream declares ${n.expectedRecordCount} records but contains ${i.length}`);return y1e(i,t)}function y1e(t,e){for(const[n,o]of t.entries()){const i={recordIndex:n,streamPath:`/${e}/Data`};o.setSourceLocation(i);for(const[r,s]of o.items.entries())s.setSourceLocation({...i,fieldIndex:r})}return t}function xXi(t,e,n){const o=t===\"Tracks6\"?33:t===\"Arcs6\"?45:t===\"Fills6\"?37:31;if(e.byteLength\u003co)throw new hh(`${t} primitive payload is shorter than ${o} bytes`,n);const i=new DataView(e.buffer,e.byteOffset,e.byteLength),r=LS(i.getUint8(0));if(t===\"Fills6\"){const A=i.getUint8(2)===2,c=[fi(\"RECORD\",\"Fill\"),fi(\"LAYER\",r),fi(\"LOCKED\",g_((i.getUint8(1)\u00264)===0)),fi(\"KEEPOUT\",g_(A)),fi(\"NET\",String(i.getUint16(3,!0))),fi(\"COMPONENT\",String(i.getUint16(7,!0))),na(\"X1\",i.getInt32(13,!0)),na(\"Y1\",i.getInt32(17,!0)),na(\"X2\",i.getInt32(21,!0)),na(\"Y2\",i.getInt32(25,!0)),fi(\"ROTATION\",i8(i.getFloat64(29,!0))),fi(\"KEEPOUTRESTRICTIONS\",String(e.byteLength\u003e=47?i.getUint8(46):A?31:0))];return e.byteLength\u003e=46\u0026\u0026c.push(fi(\"LAYER_V7_ID\",String(i.getUint32(42,!0)))),e.byteLength\u003e37\u0026\u0026e.byteLength\u003c46\u0026\u0026c.push(fi(\"UNPARSEDTRAILINGBYTES\",String(e.byteLength-37))),e.byteLength\u003e47\u0026\u0026c.push(fi(\"UNPARSEDTRAILINGBYTES\",String(e.byteLength-47))),new M1n({items:c,originalBinaryPayload:e})}const s=i.getUint16(1,!0),a=[fi(\"LAYER\",r),fi(\"LOCKED\",g_((i.getUint8(1)\u00264)===0)),...(s\u0026IXi)!==0?[fi(\"KEEPOUT\",\"TRUE\")]:[],fi(\"NET\",String(i.getUint16(3,!0))),fi(\"COMPONENT\",String(i.getUint16(7,!0))),fi(\"POLYGON\",String(i.getUint16(9,!0)))];return t===\"Tracks6\"?new T1n({originalBinaryPayload:e,items:[fi(\"RECORD\",\"Track\"),...a,na(\"X1\",i.getInt32(13,!0)),na(\"Y1\",i.getInt32(17,!0)),na(\"X2\",i.getInt32(21,!0)),na(\"Y2\",i.getInt32(25,!0)),na(\"WIDTH\",i.getInt32(29,!0))]}):t===\"Arcs6\"?new P1n({originalBinaryPayload:e,items:[fi(\"RECORD\",\"Arc\"),...a,na(\"LOCATION.X\",i.getInt32(13,!0)),na(\"LOCATION.Y\",i.getInt32(17,!0)),na(\"RADIUS\",i.getInt32(21,!0)),fi(\"STARTANGLE\",i8(i.getFloat64(25,!0))),fi(\"ENDANGLE\",i8(i.getFloat64(33,!0))),na(\"WIDTH\",i.getInt32(41,!0))]}):new k1n({originalBinaryPayload:e,items:[fi(\"RECORD\",\"Via\"),fi(\"LAYER\",\"MULTILAYER\"),fi(\"LOCKED\",g_((i.getUint8(1)\u00264)===0)),fi(\"TENTEDTOP\",g_((i.getUint8(1)\u002632)!==0)),fi(\"TENTEDBOTTOM\",g_((i.getUint8(1)\u002664)!==0)),fi(\"NET\",String(i.getUint16(3,!0))),na(\"X\",i.getInt32(13,!0)),na(\"Y\",i.getInt32(17,!0)),na(\"DIAMETER\",i.getInt32(21,!0)),na(\"HOLESIZE\",i.getInt32(25,!0)),fi(\"STARTLAYER\",LS(i.getUint8(29))),fi(\"ENDLAYER\",LS(i.getUint8(30)))]})}function EXi(t,e){const n=e.maximumRecordLength??16777216,o=[],i=new DataView(t.buffer,t.byteOffset,t.byteLength);let r=0;for(;r\u003ct.byteLength;){const s=r;if(t[r]!==C1e.Pads6)throw new yI(`Pads6 record at offset ${s} has unexpected primitive type ${t[r]}`);r+=1;const a=[];for(let l=0;l\u003c6;l++){const u=r;if(r+4\u003et.byteLength)throw new hh(`Pads6 subrecord ${l+1} length is truncated`,r);const g=i.getUint32(r,!0)\u002616777215;if(r+=4,g\u003en)throw new hh(`Invalid Pads6 subrecord length ${g}`,u);if(r+g\u003et.byteLength)throw new hh(`Pads6 subrecord ${l+1} at offset ${u} exceeds its stream`,u);a.push(t.subarray(r,r+g)),r+=g}const A=MXi(a[0]??new Uint8Array),c=a[4];if(!c||c.byteLength\u003c110)throw new hh(\"Pads6 geometry subrecord is shorter than 110 bytes\",s);o.push(vXi(A,c,a[5]))}if(e.expectedRecordCount!==void 0\u0026\u0026o.length!==e.expectedRecordCount)throw new yI(`Pads6 stream declares ${e.expectedRecordCount} records but contains ${o.length}`);return o}function BXi(t,e){const n=e.maximumRecordLength??16777216,o=[],i=new DataView(t.buffer,t.byteOffset,t.byteLength);let r=0;for(;r\u003ct.byteLength;){const s=r;if(t[r]!==C1e.Texts6)throw new yI(`Texts6 record at offset ${s} has unexpected primitive type ${t[r]}`);r+=1;const a=VXe(\"Texts6 properties\",t,i,r,n);r=a.nextOffset;const A=VXe(\"Texts6 legacy text\",t,i,r,n);r=A.nextOffset,o.push(bXi(a.payload,A.payload,e.wideStrings,s))}return O1n(\"Texts6\",o,e.expectedRecordCount),o}function bXi(t,e,n,o){if(t.byteLength\u003c40)throw new hh(\"Texts6 properties subrecord is shorter than 40 bytes\",o);const i=new DataView(t.buffer,t.byteOffset,t.byteLength),r=t.byteLength\u003e=119?i.getUint32(115,!0):4294967295,s=n?.get(r)??DXi(e),a=[fi(\"RECORD\",\"Text\"),fi(\"LAYER\",LS(i.getUint8(0))),fi(\"LOCKED\",g_((i.getUint8(1)\u00264)===0)),fi(\"COMPONENT\",String(i.getUint16(7,!0))),na(\"X\",i.getInt32(13,!0)),na(\"Y\",i.getInt32(17,!0)),na(\"HEIGHT\",i.getInt32(21,!0)),fi(\"STROKEFONT\",String(i.getUint16(25,!0))),fi(\"ROTATION\",i8(i.getFloat64(27,!0))),fi(\"MIRROR\",g_(i.getUint8(35)!==0)),na(\"WIDTH\",i.getInt32(36,!0)),fi(\"WIDESTRINGINDEX\",String(r)),fi(\"WIDESTRING\",RXi(s))];return t.byteLength\u003e=137\u0026\u0026a.push(fi(\"COMMENT\",g_(i.getUint8(40)!==0)),fi(\"DESIGNATOR\",g_(i.getUint8(41)!==0)),fi(\"FONTTYPE\",String(i.getUint8(43))),fi(\"BOLD\",g_(i.getUint8(44)!==0)),fi(\"ITALIC\",g_(i.getUint8(45)!==0)),fi(\"FONTNAME\",NXi(t.subarray(46,110))),fi(\"INVERTED\",g_(i.getUint8(110)!==0)),na(\"MARGINBORDERWIDTH\",i.getInt32(111,!0)),fi(\"INVERTEDRECT\",g_(i.getUint8(123)!==0)),na(\"TEXTBOXWIDTH\",i.getInt32(124,!0)),na(\"TEXTBOXHEIGHT\",i.getInt32(128,!0)),fi(\"JUSTIFICATION\",String(i.getUint8(132))),na(\"TEXTOFFSET\",i.getInt32(133,!0))),t.byteLength\u003e=230\u0026\u0026a.push(fi(\"LAYER_V7\",LS(i.getUint32(226,!0)))),new R1n({items:a,originalBinaryPayload:t})}function SXi(t,e,n){const o=CXi[t],i=n.maximumRecordLength??16*1024*1024,r=[],s=new DataView(e.buffer,e.byteOffset,e.byteLength);let a=0;for(;a\u003ce.byteLength;){const A=a;if(e[a]!==C1e[t])throw new yI(`${t} record at offset ${A} has unexpected primitive type ${e[a]}`);a+=1;const c=VXe(t,e,s,a,i);r.push(QXi(c.payload,A,t,o.recordKind,o.extendedVertices)),a=c.nextOffset}return O1n(t,r,n.expectedRecordCount),r}function QXi(t,e,n,o,i){if(t.byteLength\u003c26)throw new hh(`${n} payload is shorter than 26 bytes`,e);const r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=r.getUint32(18,!0)\u002616777215,a=22,A=a+s;if(A+4\u003et.byteLength)throw new hh(`${n} property block exceeds its record`,e+a);const c=new Uint8Array(s+1);c[0]=124,c.set(t.subarray(a,A),1);const l=UXe(c,o),u=r.getUint8(1),g=Number(l.getCaseInsensitive(\"KIND\")??0),h=l.getBoolean(\"ISBOARDCUTOUT\")===!0,d=[fi(\"SOURCESTREAM\",n),fi(\"LAYER\",LS(r.getUint8(0))),fi(\"LOCKED\",g_((u\u00264)===0)),fi(\"TEARDROP\",g_((u\u002616)!==0)),fi(\"KEEPOUT\",g_(r.getUint8(2)===2)),fi(\"NET\",String(r.getUint16(3,!0))),fi(\"POLYGON\",String(r.getUint16(5,!0))),fi(\"COMPONENT\",String(r.getUint16(7,!0))),fi(\"HOLECOUNT\",String(r.getUint16(14,!0)))];(n===\"BoardRegions\"||n===\"Regions6\"||n===\"ShapeBasedRegions6\")\u0026\u0026d.push(fi(\"REGIONKIND\",PXi(n,g,h)));let p=A;const _=r.getUint32(p,!0)+(i?1:0);p+=4,i?zXe(`${n} outline`,_,37,p,t.byteLength,e):zXe(`${n} outline`,_,16,p,t.byteLength,e);for(let y=0;y\u003c_;y++)if(i){const x=r.getUint8(p)!==0;d.push(fi(`KIND${y}`,x?\"1\":\"0\"),na(`VX${y}`,r.getInt32(p+1,!0)),na(`VY${y}`,r.getInt32(p+5,!0)),na(`CX${y}`,r.getInt32(p+9,!0)),na(`CY${y}`,r.getInt32(p+13,!0)),na(`R${y}`,r.getInt32(p+17,!0)),fi(`SA${y}`,i8(r.getFloat64(p+21,!0))),fi(`EA${y}`,i8(r.getFloat64(p+29,!0)))),p+=37}else d.push(fi(`KIND${y}`,\"0\"),na(`VX${y}`,r.getFloat64(p,!0)),na(`VY${y}`,r.getFloat64(p+8,!0))),p+=16;const f=r.getUint16(14,!0);for(let y=0;y\u003cf;y++){if(p+4\u003et.byteLength)throw new hh(`${n} hole ${y} count is truncated`,e+p);const x=r.getUint32(p,!0);p+=4,zXe(`${n} hole ${y}`,x,16,p,t.byteLength,e),d.push(fi(`HOLE${y}COUNT`,String(x)));for(let E=0;E\u003cx;E++)d.push(na(`HOLE${y}VX${E}`,r.getFloat64(p,!0)),na(`HOLE${y}VY${E}`,r.getFloat64(p+8,!0))),p+=16}p!==t.byteLength\u0026\u0026d.push(fi(\"UNPARSEDTRAILINGBYTES\",String(t.byteLength-p)));const I=l.items,C=[];I[0]\u0026\u0026C.push(I[0]);for(const y of d)C.push(y.setParent(l));for(let y=1;y\u003cI.length;y+=1){const x=I[y];x\u0026\u0026C.push(x)}return l.items=C,l.setOriginalBinaryPayload(t),l}function vXi(t,e,n){const o=new DataView(e.buffer,e.byteOffset,e.byteLength),i=o.getUint8(49),r=o.getUint8(1),s=o.getUint8(62),a=[fi(\"RECORD\",\"Pad\"),fi(\"NAME\",t),fi(\"LAYER\",LS(o.getUint8(0))),fi(\"LOCKED\",g_((r\u00264)===0)),fi(\"TENTEDTOP\",g_((r\u002632)!==0)),fi(\"TENTEDBOTTOM\",g_((r\u002664)!==0)),fi(\"NET\",String(o.getUint16(3,!0))),fi(\"COMPONENT\",String(o.getUint16(7,!0))),na(\"X\",o.getInt32(13,!0)),na(\"Y\",o.getInt32(17,!0)),na(\"XSIZE\",o.getInt32(21,!0)),na(\"YSIZE\",o.getInt32(25,!0)),na(\"MIDXSIZE\",o.getInt32(29,!0)),na(\"MIDYSIZE\",o.getInt32(33,!0)),na(\"BOTTOMXSIZE\",o.getInt32(37,!0)),na(\"BOTTOMYSIZE\",o.getInt32(41,!0)),na(\"HOLESIZE\",o.getInt32(45,!0)),fi(\"SHAPE\",x1e(i)),fi(\"MIDSHAPE\",x1e(o.getUint8(50))),fi(\"BOTTOMSHAPE\",x1e(o.getUint8(51))),fi(\"ROTATION\",i8(o.getFloat64(52,!0))),fi(\"PLATED\",o.getUint8(60)===0?\"FALSE\":\"TRUE\"),fi(\"PADMODE\",String(s)),fi(\"PADSTACKMODE\",FXi(s)),na(\"PASTEMASKEXPANSION_MANUAL\",o.getInt32(86,!0)),na(\"SOLDERMASKEXPANSION_MANUAL\",o.getInt32(90,!0)),fi(\"PASTEMASKEXPANSIONMODE\",G1n(o.getUint8(101))),fi(\"SOLDERMASKEXPANSIONMODE\",G1n(o.getUint8(102)))];return e.byteLength\u003e=114\u0026\u0026a.push(fi(\"HOLEROTATION\",i8(o.getFloat64(106,!0)))),e.byteLength\u003e=120\u0026\u0026a.push(fi(\"TOLAYER\",LS(o.getUint8(114))),fi(\"FROMLAYER\",LS(o.getUint8(117)))),n\u0026\u0026n.byteLength\u003e=596\u0026\u0026a.push(...wXi(n)),new D1n({items:a,originalBinaryPayload:e})}function wXi(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=[fi(\"STACKDATALENGTH\",String(t.byteLength)),fi(\"HOLETYPE\",String(e.getUint8(262))),fi(\"HOLESHAPE\",kXi(e.getUint8(262))),na(\"SLOTLENGTH\",e.getInt32(263,!0)),fi(\"SLOTROTATION\",i8(e.getFloat64(267,!0)))];t.byteLength\u003e596\u0026\u0026n.push(fi(\"UNPARSEDSTACKBYTES\",String(t.byteLength-596)));for(let o=0;o\u003c32;o++)n.push(na(`LAYER${o}HOLEXOFFSET`,e.getInt32(275+o*4,!0)),na(`LAYER${o}HOLEYOFFSET`,e.getInt32(403+o*4,!0)),fi(`LAYER${o}ALTSHAPE`,TXi(e.getUint8(532+o))),fi(`LAYER${o}CORNERRADIUS`,String(e.getUint8(564+o))));for(let o=0;o\u003c29;o++){const i=o+2;n.push(na(`LAYER${i}XSIZE`,e.getInt32(o*4,!0)),na(`LAYER${i}YSIZE`,e.getInt32(116+o*4,!0)),fi(`LAYER${i}SHAPE`,x1e(e.getUint8(232+o))))}return n}function VXe(t,e,n,o,i){if(o+4\u003ee.byteLength)throw new hh(`${t} subrecord length is truncated`,o);const r=o,s=n.getUint32(o,!0)\u002616777215;if(o+=4,s\u003ei)throw new hh(`Invalid ${t} subrecord length ${s}`,r);if(o+s\u003ee.byteLength)throw new hh(`${t} subrecord at offset ${r} exceeds its stream`,r);return{nextOffset:o+s,payload:e.subarray(o,o+s)}}function O1n(t,e,n){if(n!==void 0\u0026\u0026e.length!==n)throw new yI(`${t} stream declares ${n} records but contains ${e.length}`)}function zXe(t,e,n,o,i,r){const s=i-o;if(e\u003eMath.floor(s/n))throw new hh(`${t} declares ${e} vertices but exceeds its record`,r+o)}function PXi(t,e,n){return t===\"BoardRegions\"?\"LAYER_STACK_REGION\":e===0?n?\"BOARD_CUTOUT\":\"COPPER\":e===1?\"POLYGON_CUTOUT\":e===2?\"DASHED_OUTLINE\":e===3?\"UNKNOWN_3\":e===4?\"CAVITY_DEFINITION\":`UNKNOWN_${e}`}function MXi(t){if(t.byteLength===0)return\"\";const e=t[0]??0,n=Math.min(e+1,t.byteLength);return new TextDecoder(\"windows-1252\").decode(t.subarray(1,n))}function DXi(t){if(t.byteLength===0)return\"\";const e=t[0]??0,n=Math.min(e+1,t.byteLength);return new TextDecoder(\"windows-1252\").decode(t.subarray(1,n)).replaceAll(`\\r\n`,`\n`)}function NXi(t){return Y1n(t).replace(/\\0.*$/su,\"\")}function RXi(t){return Array.from(t,e=\u003eString(e.codePointAt(0)??0)).join(\",\")}function x1e(t){return t===1?\"ROUND\":t===2?\"RECTANGLE\":t===3?\"OCTAGONAL\":`SHAPE${t}`}function TXi(t){return t===0?\"DEFAULT\":t===1?\"ROUND\":t===2?\"RECTANGLE\":t===3?\"OCTAGONAL\":t===9?\"ROUNDRECT\":`ALTSHAPE${t}`}function kXi(t){return t===0?\"ROUND\":t===1?\"SQUARE\":t===2?\"SLOT\":`HOLESHAPE${t}`}function FXi(t){return t===0?\"SIMPLE\":t===1?\"TOP_MIDDLE_BOTTOM\":t===2?\"FULL_STACK\":`PADMODE${t}`}function G1n(t){return t===0?\"None\":t===1?\"Rule\":t===2?\"Manual\":`Mode${t}`}function fi(t,e){return new a9({key:t,value:e})}function g_(t){return t?\"TRUE\":\"FALSE\"}function na(t,e){return fi(t,`${i8(e/1e4,4)}mil`)}function i8(t,e=10){return Number.isFinite(t)?t.toFixed(e).replace(/\\.?0+$/u,\"\").replace(/^-0$/u,\"0\"):\"0\"}function LS(t){return t===1?\"TOP\":t\u003e=2\u0026\u0026t\u003c=31?`MID-LAYER${t-1}`:t===32?\"BOTTOM\":t===33?\"TOPOVERLAY\":t===34?\"BOTTOMOVERLAY\":t===35?\"TOPPASTE\":t===36?\"BOTTOMPASTE\":t===37?\"TOPSOLDER\":t===38?\"BOTTOMSOLDER\":t\u003e=39\u0026\u0026t\u003c=54?`INTERNALPLANE${t-38}`:t===55?\"DRILLGUIDE\":t===56?\"KEEPOUT\":t\u003e=57\u0026\u0026t\u003c=72?`MECHANICAL${t-56}`:t===73?\"DRILLDRAWING\":t===74?\"MULTILAYER\":t===75?\"CONNECTIONS\":t===76?\"BACKGROUND\":t===77?\"DRCERROR\":t===78?\"SELECTIONS\":t===79?\"VISIBLEGRID1\":t===80?\"VISIBLEGRID2\":t===81?\"PADHOLES\":t===82?\"VIAHOLES\":t\u003e=83\u0026\u0026t\u003c=98?`MECHANICAL${t-66}`:`LAYER${t}`}function LXi(t,e=16*1024*1024){const n=new Map,o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(;i\u003ct.byteLength;){if(i+8\u003et.byteLength)throw new hh(\"WideStrings6 entry header is truncated\",i);const r=o.getUint32(i,!0),s=o.getUint32(i+4,!0);if(i+=8,s\u003ee||i+s\u003et.byteLength)throw new hh(`WideStrings6 entry ${r} has invalid length ${s}`,i-4);const a=s\u003c=2?0:s,A=a===0?\"\":Y1n(t.subarray(i,i+a-2)).replaceAll(`\\r\n`,`\n`);n.set(r,A),i+=a}return n}function Y1n(t){let e=\"\";for(let n=0;n+1\u003ct.byteLength;n+=2)e+=String.fromCharCode((t[n]??0)|(t[n+1]??0)\u003c\u003c8);return e}var HXi={Board6:{recordKind:\"Board\"},Classes6:{recordKind:\"Class\"},Components6:{recordKind:\"Component\"},Connections6:{allowOpaqueRecords:!0,recordKind:\"Connection\"},Dimensions6:{headerSize:6,recordKind:\"Dimension\"},FileVersionInfo:{recordKind:\"FileVersionInfo\"},FromTos6:{recordKind:\"FromTo\"},Models:{recordKind:\"Model\"},Nets6:{recordKind:\"Net\"},Polygons6:{recordKind:\"Polygon\"},Rules6:{headerSize:6,recordKind:\"Rule\"},SignalClasses:{recordKind:\"SignalClass\"},SmartUnions:{recordKind:\"SmartUnion\"},UniqueIDPrimitiveInformation:{recordKind:\"UniqueIDPrimitiveInformation\"}},OXi=new Set([\"Arcs6\",\"BoardRegions\",\"ComponentBodies6\",\"Fills6\",\"Pads6\",\"Regions6\",\"ShapeBasedRegions6\",\"ShapeBasedComponentBodies6\",\"Texts6\",\"Tracks6\",\"Vias6\"]);function U1n(t,e={}){if(!f1e(t))throw new yI(\"Binary PcbDoc input does not begin with the OLE/CFB signature\");const n=Vee(t,e);if(!n.getStream(\"/Board6/Data\")||!n.getStream(\"/Board6/Header\"))throw new yI(\"Compound document does not contain the Board6 PCB streams\");const o=new Set(n.streams.filter(c=\u003ec.path.length\u003e=2).map(c=\u003ec.path[0]).filter(c=\u003ec!==void 0)),i=new Map,r=new Map,s=[],a=n.getStream(\"/WideStrings6/Data\"),A=a?LXi(a.content):new Map;for(const c of[...o].sort()){const l=n.getStream([c,\"Data\"]),u=n.getStream([c,\"Header\"]),g=u?YXi(u.content):void 0,h=HXi[c],d=l\u0026\u0026h?GXi({allowOpaqueRecords:h.allowOpaqueRecords,allowMissingLeadingDelimiter:c===\"Models\",bytes:l.content,expectedRecordCount:g,family:c,headerSize:h.headerSize,maximumRecordLength:e.maxPropertyRecordLength,recordKind:h.recordKind}):[],p=l\u0026\u0026OXi.has(c)?yXi(c,l.content,{expectedRecordCount:g,maximumRecordLength:e.maxPrimitiveRecordLength,wideStrings:A}):[];d.length\u003e0\u0026\u0026i.set(c,d),p.length\u003e0\u0026\u0026r.set(c,p),s.push({dataSize:l?.content.byteLength,declaredRecordCount:g,decodedPrimitiveRecordCount:p.length,decodedPropertyRecordCount:d.length,family:c,hasData:l!==void 0,hasHeader:u!==void 0})}return new P$i({compoundFile:n,primitiveRecords:r,propertyRecords:i,streamSummaries:s,wideStrings:A})}function GXi({allowOpaqueRecords:t=!1,allowMissingLeadingDelimiter:e=!1,bytes:n,expectedRecordCount:o,recordKind:i,family:r=i,headerSize:s=4,maximumRecordLength:a=16*1024*1024}){if(n.byteLength===0)return[];const A=[],c=new DataView(n.buffer,n.byteOffset,n.byteLength);let l=0,u=0;for(;l\u003cn.byteLength;){const g=l;if(l+s\u003en.byteLength)throw new hh(`${i} property record length is truncated`,l);const d=c.getUint32(s===6?l+2:l,!0)\u002616777215,p=s===6?c.getUint16(l,!0):void 0;if(l+=s,d===0||d\u003ea)throw new hh(`Invalid ${i} property record length ${d}`,g);if(l+d\u003en.byteLength)throw new hh(`${i} property record at offset ${g} exceeds its stream`,g);const m=n.subarray(l,l+d);if(m[0]!==124\u0026\u0026!e){if(t){u+=1,l+=d;continue}throw new yI(`${i} property record at offset ${g} does not begin with \"|\"`)}const f={byteOffset:g,recordIndex:u,streamPath:`/${r}/Data`},I=UXe(m,i,f);p!==void 0\u0026\u0026(I.insertField(\"BINARYRECORDTYPE\",String(p),{index:1}),I.clearDirty(!0)),A.push(I),u+=1,l+=d}if(o!==void 0\u0026\u0026u!==o)throw new yI(`${i} stream declares ${o} records but contains ${u}`);return A}function YXi(t){if(!(t.byteLength\u003c4))return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!0)}var K1n=class extends pXe{type=\"raw-line\";_raw;constructor(t){if(super(t),/[\\r\\n]/u.test(t.raw))throw new Error(\"Raw Altium lines cannot include their line terminator\");this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[\\r\\n]/u.test(t))throw new Error(\"Raw Altium lines cannot include their line terminator\");t!==this._raw\u0026\u0026(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}};function JXe(t,e={}){if(typeof t!=\"string\")throw new eM(\"parseAltiumAscii expects decoded text; use parseAltiumFile() for binary or byte input\");z1n(e.signal);const n=t.startsWith(\"\\uFEFF\"),o=n?t.slice(1):t,i=zXi(o,n?1:0),r=e.maxLineCount??1e6;if(i.length\u003er)throw new eM(`Altium text has ${i.length} lines, exceeding the configured limit of ${r}`);const s=i.map((A,c)=\u003e(z1n(e.signal),UXi(A.content,A.terminator,c+1,A.startOffset,e)));return n?[new K1n({raw:\"\\uFEFF\",terminator:\"\",nodeId:\"text:bom\",sourceLocation:{column:1,endColumn:2,endLine:1,endOffset:1,line:1,startOffset:0}}),...s]:s}function UXi(t,e,n,o,i){const r={column:1,endColumn:t.length+1,endLine:n,endOffset:o+t.length,line:n,startOffset:o},s=i.maxLineLength??16*1024*1024;if(t.length\u003es)throw new eM(`Altium line ${n} has ${t.length} characters, exceeding the configured limit of ${s}`,{excerpt:ik(i,t),location:r});if(!t.startsWith(\"|\")){if(V1n(i)\u0026\u0026t.length\u003e0)throw new eM(i.redactSourceText?`Expected an Altium record at line ${n}`:`Expected an Altium record at line ${n}, got ${JSON.stringify(t.slice(0,40))}`,{excerpt:ik(i,t),location:r});return t.length\u003e0\u0026\u0026WXe(i,{code:\"ALTIUM_RAW_TEXT_LINE\",excerpt:ik(i,t),location:r,message:`Preserved non-record text at line ${n}`,severity:\"warning\"}),new K1n({raw:t,terminator:e,nodeId:`text:${o}:raw-line`,sourceLocation:r})}const a=t.slice(1).split(\"|\"),A=i.maxFieldsPerRecord??1e5;if(a.length\u003eA)throw new eM(`Altium record at line ${n} has ${a.length} fields, exceeding the configured limit of ${A}`,{excerpt:ik(i,t),location:r});let c=o+1;const l=a.map((h,d)=\u003e{const p=KXi(h,{itemIndex:d,lineStartOffset:o,lineNumber:n,options:i,startOffset:c});return c+=h.length+1,p}),u=VXi(l);if(u===void 0){if(V1n(i))throw new eM(`Altium record at line ${n} has no RECORD field`,{excerpt:ik(i,t),location:r});return WXe(i,{code:\"ALTIUM_RECORD_KIND_MISSING\",excerpt:ik(i,t),location:r,message:`Preserved record without a RECORD field at line ${n}`,severity:\"warning\"}),new I1e({items:l,terminator:e,nodeId:`text:${o}:unknown-record`,sourceLocation:r})}const g=H1n.get(u)??I1e;return new g({items:l,terminator:e,nodeId:`text:${o}:record:${u}`,sourceLocation:r})}function KXi(t,e){const n={column:e.startOffset-e.lineStartOffset+1,endColumn:e.startOffset-e.lineStartOffset+t.length+1,endLine:e.lineNumber,endOffset:e.startOffset+t.length,line:e.lineNumber,startOffset:e.startOffset},o=`text:${e.startOffset}:item:${e.itemIndex}`,i=t.indexOf(\"=\");return i\u003c=0?(t.length\u003e0\u0026\u0026WXe(e.options,{code:\"ALTIUM_RAW_FIELD\",excerpt:ik(e.options,t),location:n,message:`Preserved malformed field segment at line ${e.lineNumber}`,severity:\"warning\"}),new F1n({raw:t,nodeId:o,sourceLocation:n})):new a9({key:t.slice(0,i),nodeId:o,sourceLocation:n,value:t.slice(i+1)})}function VXi(t){return new I1e({items:t}).recordKind}function zXi(t,e=0){const n=[];let o=0;for(let i=0;i\u003ct.length;i++){const r=t[i];if(r!==\"\\r\"\u0026\u0026r!==`\n`)continue;const s=r===\"\\r\"\u0026\u0026t[i+1]===`\n`,a=s?`\\r\n`:r;n.push({content:t.slice(o,i),startOffset:e+o,terminator:a}),s\u0026\u0026i++,o=i+1}return o\u003ct.length\u0026\u0026n.push({content:t.slice(o),startOffset:e+o,terminator:\"\"}),n}function V1n(t){return t.strict===!0||t.mode===\"strict\"}function WXe(t,e){t.onDiagnostic?.(e)}function JXi(t,e=120){return t.length\u003c=e?t:`${t.slice(0,e)}…`}function ik(t,e){return t.redactSourceText?void 0:JXi(e)}function z1n(t){t?.throwIfAborted()}function E1e(t,e={}){if(typeof t!=\"string\")throw new eM(\"parseAltiumPcbDoc expects decoded text; use parseAltiumFile() for binary or byte input\");const n=JXe(t,e),o=n.find(i=\u003ei instanceof Ol);if(o?.recordKind!==\"Board\")throw new eM(`Expected an Altium Board root record, got ${o?.recordKind??\"none\"}`,{location:o?.sourceLocation,recordKind:o?.recordKind});return new U$i({lines:n,originalSource:t})}function jXe(t,e={}){if(typeof t==\"string\"){const s=new d1e({lines:JXe(t,e),originalText:t,sourceFormat:\"ascii\"});return J1n(s),s}if(!f1e(t)){const s=SXe(t,e.encoding),a=new d1e({lines:JXe(s.text,e),originalBytes:t.slice(),originalText:s.text,sourceEncoding:s.encoding,sourceFormat:\"ascii\"});return J1n(a),a}const n=Vee(t,e),o=n.getStream(\"/FileHeader\");if(!o)throw new yI(\"Compound document does not contain a FileHeader stream\");const i=WXi(o.content,e.maxRecordLength);if(!i[0]?.getCaseInsensitive(\"HEADER\")?.toLowerCase().includes(\"schematic capture\"))throw new yI(\"FileHeader is not an Altium schematic record stream\");return new d1e({compoundFile:n,lines:i,originalBytes:t.slice(),sourceFormat:\"binary\"})}function J1n(t){if(!t.header?.getCaseInsensitive(\"HEADER\")?.toLowerCase().includes(\"schematic capture\")\u0026\u0026t.getRecordsByKind(\"31\").length===0)throw new yI(\"Expected an Altium schematic header or sheet record\")}function WXi(t,e=16*1024*1024){const n=[],o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(;i\u003ct.byteLength;){const r=i;if(i+4\u003et.byteLength)throw new hh(\"Schematic record length is truncated\",i);const a=o.getUint32(i,!0)\u002616777215;if(i+=4,a===0||a\u003ee)throw new hh(`Invalid schematic record length ${a}`,r);if(i+a\u003et.byteLength)throw new hh(`Schematic record at offset ${r} declares ${a} bytes with only ${t.byteLength-i} available`,r);const A=UXe(t.subarray(i,i+a),void 0,{byteOffset:r,recordIndex:n.length,streamPath:\"/FileHeader\"}),c=i+a\u003ct.byteLength?`\n`:\"\";A.terminator=c,n.push(A),i+=a}return n}function jXi(t,e={}){const n=e.maxFileSize??268435456;if(!Number.isSafeInteger(n)||n\u003c=0)throw new RangeError(\"maxFileSize must be a positive safe integer\");if(t.byteLength\u003en)throw new aA(`Altium file is ${t.byteLength} bytes, exceeding the ${n}-byte limit`);if(e.signal?.aborted)throw e.signal.reason??new DOMException(\"Parsing aborted\",\"AbortError\");const o=$qi(t,e);if(o.container===\"cfb\"){if(o.documentKind===\"pcb-document\")return{detection:o,document:U1n(t,e)};if(o.documentKind===\"schematic-document\")return{detection:o,document:jXe(t,e)};if(o.documentKind===\"pcb-library\"||o.documentKind===\"schematic-library\"||o.documentKind===\"integrated-library\"){if(e.allowUnknownCompoundFile)return{detection:o,document:Vee(t,e)};throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet fixture-verified`)}if(e.allowUnknownCompoundFile)return{detection:o,document:Vee(t,e)};throw new yI(\"Compound file is not a recognized Altium PCB or schematic document\")}if(o.container===\"zip\"||o.container===\"xml\")throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet implemented`);if(o.documentKind===\"pcb-library\"||o.documentKind===\"schematic-library\"||o.documentKind===\"integrated-library\")throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet fixture-verified`);const i=SXe(t,e.encoding);if(o.documentKind===\"project\"){const r=y1n(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind===\"output-job\"){const r=kqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind===\"workspace\"){const r=Uqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind===\"ini-document\"){if(!e.allowUnknownIni\u0026\u0026o.documentKind===\"ini-document\")throw new yI(\"INI input is not a recognized Altium project, workspace, or output job\");const r=Nqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind===\"pcb-document\"){const r=E1e(i.text,e).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind===\"schematic-document\")return{detection:o,document:jXe(t,e)};throw new yI(\"Text input is not a recognized Altium PCB or schematic document\")}var LE=class{constructor(t=256,e=64*1024*1024){if(this.maximumLength=e,!Number.isSafeInteger(t)||t\u003c0||!Number.isSafeInteger(e)||e\u003c=0||t\u003ee)throw new RangeError(\"Invalid binary writer capacity or limit\");this.bytes=new Uint8Array(t),this.view=new DataView(this.bytes.buffer)}maximumLength;bytes;view;_length=0;get length(){return this._length}uint8(t){return this.ensure(1),this.view.setUint8(this._length,t),this._length++,this}int8(t){return this.ensure(1),this.view.setInt8(this._length,t),this._length++,this}uint16(t){return this.ensure(2),this.view.setUint16(this._length,t,!0),this._length+=2,this}int16(t){return this.ensure(2),this.view.setInt16(this._length,t,!0),this._length+=2,this}uint32(t){return this.ensure(4),this.view.setUint32(this._length,t,!0),this._length+=4,this}int32(t){return this.ensure(4),this.view.setInt32(this._length,t,!0),this._length+=4,this}float64(t){return this.ensure(8),this.view.setFloat64(this._length,t,!0),this._length+=8,this}writeBytes(t){return this.ensure(t.byteLength),this.bytes.set(t,this._length),this._length+=t.byteLength,this}uint32LengthPrefixedBytes(t){return this.uint32(t.byteLength).writeBytes(t)}pascalString(t,e=\"windows-1252\"){const n=$Xi(t,e);if(n.byteLength\u003e255)throw new RangeError(\"Pascal string exceeds 255 bytes\");return this.uint8(n.byteLength).writeBytes(n)}guid(t){const e=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/iu.exec(t);if(!e)throw new TypeError(\"Invalid GUID\");return this.uint32(Number.parseInt(e[1]??\"\",16)),this.uint16(Number.parseInt(e[2]??\"\",16)),this.uint16(Number.parseInt(e[3]??\"\",16)),this.writeBytes(Uint8Array.from(`${e[4]}${e[5]}`.match(/.{2}/gu)?.map(n=\u003eNumber.parseInt(n,16))??[]))}toUint8Array(){return this.bytes.slice(0,this._length)}ensure(t){const e=this._length+t;if(!Number.isSafeInteger(e)||e\u003ethis.maximumLength)throw new RangeError(`Binary output exceeds the ${this.maximumLength}-byte limit`);if(e\u003c=this.bytes.byteLength)return;let n=Math.max(this.bytes.byteLength,1);for(;n\u003ce;)if(n=Math.min(n*2,this.maximumLength),n\u003ce\u0026\u0026n===this.maximumLength)throw new RangeError(`Binary output exceeds the ${this.maximumLength}-byte limit`);const o=new Uint8Array(n);o.set(this.bytes),this.bytes=o,this.view=new DataView(o.buffer)}};function $Xi(t,e){if(e===\"utf-8\")return new TextEncoder().encode(t);const n=[];for(const o of t){const i=o.codePointAt(0);if(i===void 0||i\u003e255)throw new RangeError(\"Windows-1252 writer currently accepts only single-byte code points\");n.push(i)}return Uint8Array.from(n)}var $Xe={exports:{}};const qXi=wit(xfn);var W1n;function XXi(){return W1n||(W1n=1,(function(t){var e={},n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";function o(Y){for(var W=\"\",te=0,j=0,J=0,oe=0,ie=0,ne=0,le=0,ge=0;ge\u003cY.length;)te=Y.charCodeAt(ge++),oe=te\u003e\u003e2,j=Y.charCodeAt(ge++),ie=(te\u00263)\u003c\u003c4|j\u003e\u003e4,J=Y.charCodeAt(ge++),ne=(j\u002615)\u003c\u003c2|J\u003e\u003e6,le=J\u002663,isNaN(j)?ne=le=64:isNaN(J)\u0026\u0026(le=64),W+=n.charAt(oe)+n.charAt(ie)+n.charAt(ne)+n.charAt(le);return W}function i(Y){var W=\"\",te=0,j=0,J=0,oe=0,ie=0,ne=0,le=0;Y=Y.replace(/[^\\w\\+\\/\\=]/g,\"\");for(var ge=0;ge\u003cY.length;)oe=n.indexOf(Y.charAt(ge++)),ie=n.indexOf(Y.charAt(ge++)),te=oe\u003c\u003c2|ie\u003e\u003e4,W+=String.fromCharCode(te),ne=n.indexOf(Y.charAt(ge++)),j=(ie\u002615)\u003c\u003c4|ne\u003e\u003e2,ne!==64\u0026\u0026(W+=String.fromCharCode(j)),le=n.indexOf(Y.charAt(ge++)),J=(ne\u00263)\u003c\u003c6|le,le!==64\u0026\u0026(W+=String.fromCharCode(J));return W}var r=(function(){return typeof Buffer\u003c\"u\"\u0026\u0026typeof e\u003c\"u\"\u0026\u0026typeof e.versions\u003c\"u\"\u0026\u0026!!e.versions.node})(),s=(function(){if(typeof Buffer\u003c\"u\"){var Y=!Buffer.from;if(!Y)try{Buffer.from(\"foo\",\"utf8\")}catch{Y=!0}return Y?function(W,te){return te?new Buffer(W,te):new Buffer(W)}:Buffer.from.bind(Buffer)}return function(){}})();function a(Y){if(r){if(Buffer.alloc)return Buffer.alloc(Y);var W=new Buffer(Y);return W.fill(0),W}return typeof Uint8Array\u003c\"u\"?new Uint8Array(Y):new Array(Y)}function A(Y){return r?Buffer.allocUnsafe?Buffer.allocUnsafe(Y):new Buffer(Y):typeof Uint8Array\u003c\"u\"?new Uint8Array(Y):new Array(Y)}var c=function(W){return r?s(W,\"binary\"):W.split(\"\").map(function(te){return te.charCodeAt(0)\u0026255})},l=/\\u0000/g,u=/[\\u0001-\\u0006]/g,g=function(Y){for(var W=[],te=0;te\u003cY[0].length;++te)W.push.apply(W,Y[0][te]);return W},h=g,d=function(Y,W,te){for(var j=[],J=W;J\u003cte;J+=2)j.push(String.fromCharCode(y(Y,J)));return j.join(\"\").replace(l,\"\")},p=d,m=function(Y,W,te){for(var j=[],J=W;J\u003cW+te;++J)j.push((\"0\"+Y[J].toString(16)).slice(-2));return j.join(\"\")},_=m,f=function(Y){if(Array.isArray(Y[0]))return[].concat.apply([],Y);var W=0,te=0;for(te=0;te\u003cY.length;++te)W+=Y[te].length;var j=new Uint8Array(W);for(te=0,W=0;te\u003cY.length;W+=Y[te].length,++te)j.set(Y[te],W);return j},I=f;r\u0026\u0026(d=function(Y,W,te){return Buffer.isBuffer(Y)?Y.toString(\"utf16le\",W,te).replace(l,\"\"):p(Y,W,te)},m=function(Y,W,te){return Buffer.isBuffer(Y)?Y.toString(\"hex\",W,W+te):_(Y,W,te)},g=function(Y){return Y[0].length\u003e0\u0026\u0026Buffer.isBuffer(Y[0][0])?Buffer.concat(Y[0]):h(Y)},c=function(Y){return s(Y,\"binary\")},I=function(Y){return Buffer.isBuffer(Y[0])?Buffer.concat(Y):f(Y)});var C=function(Y,W){return Y[W]},y=function(Y,W){return Y[W+1]*256+Y[W]},x=function(Y,W){var te=Y[W+1]*256+Y[W];return te\u003c32768?te:(65535-te+1)*-1},E=function(Y,W){return Y[W+3]*(1\u003c\u003c24)+(Y[W+2]\u003c\u003c16)+(Y[W+1]\u003c\u003c8)+Y[W]},B=function(Y,W){return(Y[W+3]\u003c\u003c24)+(Y[W+2]\u003c\u003c16)+(Y[W+1]\u003c\u003c8)+Y[W]};function S(Y,W){var te,j,J=0;switch(Y){case 1:te=C(this,this.l);break;case 2:te=(W!==\"i\"?y:x)(this,this.l);break;case 4:te=B(this,this.l);break;case 16:J=2,j=m(this,this.l,Y)}return this.l+=Y,J===0?te:j}var Q=function(Y,W,te){Y[te]=W\u0026255,Y[te+1]=W\u003e\u003e\u003e8\u0026255,Y[te+2]=W\u003e\u003e\u003e16\u0026255,Y[te+3]=W\u003e\u003e\u003e24\u0026255},w=function(Y,W,te){Y[te]=W\u0026255,Y[te+1]=W\u003e\u003e8\u0026255,Y[te+2]=W\u003e\u003e16\u0026255,Y[te+3]=W\u003e\u003e24\u0026255};function M(Y,W,te){var j=0,J=0;switch(te){case\"hex\":for(;J\u003cY;++J)this[this.l++]=parseInt(W.slice(2*J,2*J+2),16)||0;return this;case\"utf16le\":var oe=this.l+Y;for(J=0;J\u003cMath.min(W.length,Y);++J){var ie=W.charCodeAt(J);this[this.l++]=ie\u0026255,this[this.l++]=ie\u003e\u003e8}for(;this.l\u003coe;)this[this.l++]=0;return this}switch(Y){case 1:j=1,this[this.l]=W\u0026255;break;case 2:j=2,this[this.l]=W\u0026255,W\u003e\u003e\u003e=8,this[this.l+1]=W\u0026255;break;case 4:j=4,Q(this,W,this.l);break;case-4:j=4,w(this,W,this.l);break}return this.l+=j,this}function k(Y,W){var te=m(this,this.l,Y.length\u003e\u003e1);if(te!==Y)throw new Error(W+\"Expected \"+Y+\" saw \"+te);this.l+=Y.length\u003e\u003e1}function R(Y,W){Y.l=W,Y.read_shift=S,Y.chk=k,Y.write_shift=M}function F(Y){var W=a(Y);return R(W,0),W}var O=(function(){var Y={};Y.version=\"1.2.1\";function W(){for(var Ee=0,ke=new Array(256),Ce=0;Ce!=256;++Ce)Ee=Ce,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,Ee=Ee\u00261?-306674912^Ee\u003e\u003e\u003e1:Ee\u003e\u003e\u003e1,ke[Ce]=Ee;return typeof Int32Array\u003c\"u\"?new Int32Array(ke):ke}var te=W();function j(Ee){var ke=0,Ce=0,Le=0,Ye=typeof Int32Array\u003c\"u\"?new Int32Array(4096):new Array(4096);for(Le=0;Le!=256;++Le)Ye[Le]=Ee[Le];for(Le=0;Le!=256;++Le)for(Ce=Ee[Le],ke=256+Le;ke\u003c4096;ke+=256)Ce=Ye[ke]=Ce\u003e\u003e\u003e8^Ee[Ce\u0026255];var tt=[];for(Le=1;Le!=16;++Le)tt[Le-1]=typeof Int32Array\u003c\"u\"?Ye.subarray(Le*256,Le*256+256):Ye.slice(Le*256,Le*256+256);return tt}var J=j(te),oe=J[0],ie=J[1],ne=J[2],le=J[3],ge=J[4],_e=J[5],ue=J[6],fe=J[7],pe=J[8],ye=J[9],Me=J[10],ve=J[11],he=J[12],Qe=J[13],Pe=J[14];function we(Ee,ke){for(var Ce=ke^-1,Le=0,Ye=Ee.length;Le\u003cYe;)Ce=Ce\u003e\u003e\u003e8^te[(Ce^Ee.charCodeAt(Le++))\u0026255];return~Ce}function Te(Ee,ke){for(var Ce=ke^-1,Le=Ee.length-15,Ye=0;Ye\u003cLe;)Ce=Pe[Ee[Ye++]^Ce\u0026255]^Qe[Ee[Ye++]^Ce\u003e\u003e8\u0026255]^he[Ee[Ye++]^Ce\u003e\u003e16\u0026255]^ve[Ee[Ye++]^Ce\u003e\u003e\u003e24]^Me[Ee[Ye++]]^ye[Ee[Ye++]]^pe[Ee[Ye++]]^fe[Ee[Ye++]]^ue[Ee[Ye++]]^_e[Ee[Ye++]]^ge[Ee[Ye++]]^le[Ee[Ye++]]^ne[Ee[Ye++]]^ie[Ee[Ye++]]^oe[Ee[Ye++]]^te[Ee[Ye++]];for(Le+=15;Ye\u003cLe;)Ce=Ce\u003e\u003e\u003e8^te[(Ce^Ee[Ye++])\u0026255];return~Ce}function Re(Ee,ke){for(var Ce=ke^-1,Le=0,Ye=Ee.length,tt=0,At=0;Le\u003cYe;)tt=Ee.charCodeAt(Le++),tt\u003c128?Ce=Ce\u003e\u003e\u003e8^te[(Ce^tt)\u0026255]:tt\u003c2048?(Ce=Ce\u003e\u003e\u003e8^te[(Ce^(192|tt\u003e\u003e6\u002631))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|tt\u002663))\u0026255]):tt\u003e=55296\u0026\u0026tt\u003c57344?(tt=(tt\u00261023)+64,At=Ee.charCodeAt(Le++)\u00261023,Ce=Ce\u003e\u003e\u003e8^te[(Ce^(240|tt\u003e\u003e8\u00267))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|tt\u003e\u003e2\u002663))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|At\u003e\u003e6\u002615|(tt\u00263)\u003c\u003c4))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|At\u002663))\u0026255]):(Ce=Ce\u003e\u003e\u003e8^te[(Ce^(224|tt\u003e\u003e12\u002615))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|tt\u003e\u003e6\u002663))\u0026255],Ce=Ce\u003e\u003e\u003e8^te[(Ce^(128|tt\u002663))\u0026255]);return~Ce}return Y.table=te,Y.bstr=we,Y.buf=Te,Y.str=Re,Y})(),U=(function(){var W={};W.version=\"1.2.2\";function te(Et,Gt){for(var Rt=Et.split(\"/\"),Ht=Gt.split(\"/\"),Qt=0,Nt=0,_n=Math.min(Rt.length,Ht.length);Qt\u003c_n;++Qt){if(Nt=Rt[Qt].length-Ht[Qt].length)return Nt;if(Rt[Qt]!=Ht[Qt])return Rt[Qt]\u003cHt[Qt]?-1:1}return Rt.length-Ht.length}function j(Et){if(Et.charAt(Et.length-1)==\"/\")return Et.slice(0,-1).indexOf(\"/\")===-1?Et:j(Et.slice(0,-1));var Gt=Et.lastIndexOf(\"/\");return Gt===-1?Et:Et.slice(0,Gt+1)}function J(Et){if(Et.charAt(Et.length-1)==\"/\")return J(Et.slice(0,-1));var Gt=Et.lastIndexOf(\"/\");return Gt===-1?Et:Et.slice(Gt+1)}function oe(Et,Gt){typeof Gt==\"string\"\u0026\u0026(Gt=new Date(Gt));var Rt=Gt.getHours();Rt=Rt\u003c\u003c6|Gt.getMinutes(),Rt=Rt\u003c\u003c5|Gt.getSeconds()\u003e\u003e\u003e1,Et.write_shift(2,Rt);var Ht=Gt.getFullYear()-1980;Ht=Ht\u003c\u003c4|Gt.getMonth()+1,Ht=Ht\u003c\u003c5|Gt.getDate(),Et.write_shift(2,Ht)}function ie(Et){var Gt=Et.read_shift(2)\u002665535,Rt=Et.read_shift(2)\u002665535,Ht=new Date,Qt=Rt\u002631;Rt\u003e\u003e\u003e=5;var Nt=Rt\u002615;Rt\u003e\u003e\u003e=4,Ht.setMilliseconds(0),Ht.setFullYear(Rt+1980),Ht.setMonth(Nt-1),Ht.setDate(Qt);var _n=Gt\u002631;Gt\u003e\u003e\u003e=5;var qn=Gt\u002663;return Gt\u003e\u003e\u003e=6,Ht.setHours(Gt),Ht.setMinutes(qn),Ht.setSeconds(_n\u003c\u003c1),Ht}function ne(Et){R(Et,0);for(var Gt={},Rt=0;Et.l\u003c=Et.length-4;){var Ht=Et.read_shift(2),Qt=Et.read_shift(2),Nt=Et.l+Qt,_n={};Ht===21589\u0026\u0026(Rt=Et.read_shift(1),Rt\u00261\u0026\u0026(_n.mtime=Et.read_shift(4)),Qt\u003e5\u0026\u0026(Rt\u00262\u0026\u0026(_n.atime=Et.read_shift(4)),Rt\u00264\u0026\u0026(_n.ctime=Et.read_shift(4))),_n.mtime\u0026\u0026(_n.mt=new Date(_n.mtime*1e3))),Et.l=Nt,Gt[Ht]=_n}return Gt}var le;function ge(){return le||(le=qXi)}function _e(Et,Gt){if(Et[0]==80\u0026\u0026Et[1]==75)return Ro(Et,Gt);if((Et[0]|32)==109\u0026\u0026(Et[1]|32)==105)return Rs(Et,Gt);if(Et.length\u003c512)throw new Error(\"CFB file size \"+Et.length+\" \u003c 512\");var Rt=3,Ht=512,Qt=0,Nt=0,_n=0,qn=0,En=0,Rn=[],Hn=Et.slice(0,512);R(Hn,0);var Lo=ue(Hn);switch(Rt=Lo[0],Rt){case 3:Ht=512;break;case 4:Ht=4096;break;case 0:if(Lo[1]==0)return Ro(Et,Gt);default:throw new Error(\"Major Version: Expected 3 or 4 saw \"+Rt)}Ht!==512\u0026\u0026(Hn=Et.slice(0,Ht),R(Hn,28));var Io=Et.slice(0,Ht);fe(Hn,Rt);var gi=Hn.read_shift(4,\"i\");if(Rt===3\u0026\u0026gi!==0)throw new Error(\"# Directory Sectors: Expected 0 saw \"+gi);Hn.l+=4,_n=Hn.read_shift(4,\"i\"),Hn.l+=4,Hn.chk(\"00100000\",\"Mini Stream Cutoff Size: \"),qn=Hn.read_shift(4,\"i\"),Qt=Hn.read_shift(4,\"i\"),En=Hn.read_shift(4,\"i\"),Nt=Hn.read_shift(4,\"i\");for(var jo=-1,oi=0;oi\u003c109\u0026\u0026(jo=Hn.read_shift(4,\"i\"),!(jo\u003c0));++oi)Rn[oi]=jo;var Ji=pe(Et,Ht);ve(En,Nt,Ji,Ht,Rn);var wi=Qe(Ji,_n,Rn,Ht);wi[_n].name=\"!Directory\",Qt\u003e0\u0026\u0026qn!==At\u0026\u0026(wi[qn].name=\"!MiniFAT\"),wi[Rn[0]].name=\"!FAT\",wi.fat_addrs=Rn,wi.ssz=Ht;var Br={},gr=[],oa=[],hs=[];Pe(_n,wi,Ji,gr,Qt,Br,oa,qn),ye(oa,hs,gr),gr.shift();var Li={FileIndex:oa,FullPaths:hs};return Gt\u0026\u0026Gt.raw\u0026\u0026(Li.raw={header:Io,sectors:Ji}),Li}function ue(Et){if(Et[Et.l]==80\u0026\u0026Et[Et.l+1]==75)return[0,0];Et.chk(at,\"Header Signature: \"),Et.l+=16;var Gt=Et.read_shift(2,\"u\");return[Et.read_shift(2,\"u\"),Gt]}function fe(Et,Gt){var Rt=9;switch(Et.l+=2,Rt=Et.read_shift(2)){case 9:if(Gt!=3)throw new Error(\"Sector Shift: Expected 9 saw \"+Rt);break;case 12:if(Gt!=4)throw new Error(\"Sector Shift: Expected 12 saw \"+Rt);break;default:throw new Error(\"Sector Shift: Expected 9 or 12 saw \"+Rt)}Et.chk(\"0600\",\"Mini Sector Shift: \"),Et.chk(\"000000000000\",\"Reserved: \")}function pe(Et,Gt){for(var Rt=Math.ceil(Et.length/Gt)-1,Ht=[],Qt=1;Qt\u003cRt;++Qt)Ht[Qt-1]=Et.slice(Qt*Gt,(Qt+1)*Gt);return Ht[Rt-1]=Et.slice(Rt*Gt),Ht}function ye(Et,Gt,Rt){for(var Ht=0,Qt=0,Nt=0,_n=0,qn=0,En=Rt.length,Rn=[],Hn=[];Ht\u003cEn;++Ht)Rn[Ht]=Hn[Ht]=Ht,Gt[Ht]=Rt[Ht];for(;qn\u003cHn.length;++qn)Ht=Hn[qn],Qt=Et[Ht].L,Nt=Et[Ht].R,_n=Et[Ht].C,Rn[Ht]===Ht\u0026\u0026(Qt!==-1\u0026\u0026Rn[Qt]!==Qt\u0026\u0026(Rn[Ht]=Rn[Qt]),Nt!==-1\u0026\u0026Rn[Nt]!==Nt\u0026\u0026(Rn[Ht]=Rn[Nt])),_n!==-1\u0026\u0026(Rn[_n]=Ht),Qt!==-1\u0026\u0026Ht!=Rn[Ht]\u0026\u0026(Rn[Qt]=Rn[Ht],Hn.lastIndexOf(Qt)\u003cqn\u0026\u0026Hn.push(Qt)),Nt!==-1\u0026\u0026Ht!=Rn[Ht]\u0026\u0026(Rn[Nt]=Rn[Ht],Hn.lastIndexOf(Nt)\u003cqn\u0026\u0026Hn.push(Nt));for(Ht=1;Ht\u003cEn;++Ht)Rn[Ht]===Ht\u0026\u0026(Nt!==-1\u0026\u0026Rn[Nt]!==Nt?Rn[Ht]=Rn[Nt]:Qt!==-1\u0026\u0026Rn[Qt]!==Qt\u0026\u0026(Rn[Ht]=Rn[Qt]));for(Ht=1;Ht\u003cEn;++Ht)if(Et[Ht].type!==0){if(qn=Ht,qn!=Rn[qn])do qn=Rn[qn],Gt[Ht]=Gt[qn]+\"/\"+Gt[Ht];while(qn!==0\u0026\u0026Rn[qn]!==-1\u0026\u0026qn!=Rn[qn]);Rn[Ht]=-1}for(Gt[0]+=\"/\",Ht=1;Ht\u003cEn;++Ht)Et[Ht].type!==2\u0026\u0026(Gt[Ht]+=\"/\")}function Me(Et,Gt,Rt){for(var Ht=Et.start,Qt=Et.size,Nt=[],_n=Ht;Rt\u0026\u0026Qt\u003e0\u0026\u0026_n\u003e=0;)Nt.push(Gt.slice(_n*tt,_n*tt+tt)),Qt-=tt,_n=B(Rt,_n*4);return Nt.length===0?F(0):I(Nt).slice(0,Et.size)}function ve(Et,Gt,Rt,Ht,Qt){var Nt=At;if(Et===At){if(Gt!==0)throw new Error(\"DIFAT chain shorter than expected\")}else if(Et!==-1){var _n=Rt[Et],qn=(Ht\u003e\u003e\u003e2)-1;if(!_n)return;for(var En=0;En\u003cqn\u0026\u0026(Nt=B(_n,En*4))!==At;++En)Qt.push(Nt);Gt\u003e=1\u0026\u0026ve(B(_n,Ht-4),Gt-1,Rt,Ht,Qt)}}function he(Et,Gt,Rt,Ht,Qt){var Nt=[],_n=[];Qt||(Qt=[]);var qn=Ht-1,En=0,Rn=0;for(En=Gt;En\u003e=0;){Qt[En]=!0,Nt[Nt.length]=En,_n.push(Et[En]);var Hn=Rt[Math.floor(En*4/Ht)];if(Rn=En*4\u0026qn,Ht\u003c4+Rn)throw new Error(\"FAT boundary crossed: \"+En+\" 4 \"+Ht);if(!Et[Hn])break;En=B(Et[Hn],Rn)}return{nodes:Nt,data:g([_n])}}function Qe(Et,Gt,Rt,Ht){var Qt=Et.length,Nt=[],_n=[],qn=[],En=[],Rn=Ht-1,Hn=0,Lo=0,Io=0,gi=0;for(Hn=0;Hn\u003cQt;++Hn)if(qn=[],Io=Hn+Gt,Io\u003e=Qt\u0026\u0026(Io-=Qt),!_n[Io]){En=[];var jo=[];for(Lo=Io;Lo\u003e=0;){jo[Lo]=!0,_n[Lo]=!0,qn[qn.length]=Lo,En.push(Et[Lo]);var oi=Rt[Math.floor(Lo*4/Ht)];if(gi=Lo*4\u0026Rn,Ht\u003c4+gi)throw new Error(\"FAT boundary crossed: \"+Lo+\" 4 \"+Ht);if(!Et[oi]||(Lo=B(Et[oi],gi),jo[Lo]))break}Nt[Io]={nodes:qn,data:g([En])}}return Nt}function Pe(Et,Gt,Rt,Ht,Qt,Nt,_n,qn){for(var En=0,Rn=Ht.length?2:0,Hn=Gt[Et].data,Lo=0,Io=0,gi;Lo\u003cHn.length;Lo+=128){var jo=Hn.slice(Lo,Lo+128);R(jo,64),Io=jo.read_shift(2),gi=d(jo,0,Io-Rn),Ht.push(gi);var oi={name:gi,type:jo.read_shift(1),color:jo.read_shift(1),L:jo.read_shift(4,\"i\"),R:jo.read_shift(4,\"i\"),C:jo.read_shift(4,\"i\"),clsid:jo.read_shift(16),state:jo.read_shift(4,\"i\"),start:0,size:0},Ji=jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2);Ji!==0\u0026\u0026(oi.ct=we(jo,jo.l-8));var wi=jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2);wi!==0\u0026\u0026(oi.mt=we(jo,jo.l-8)),oi.start=jo.read_shift(4,\"i\"),oi.size=jo.read_shift(4,\"i\"),oi.size\u003c0\u0026\u0026oi.start\u003c0\u0026\u0026(oi.size=oi.type=0,oi.start=At,oi.name=\"\"),oi.type===5?(En=oi.start,Qt\u003e0\u0026\u0026En!==At\u0026\u0026(Gt[En].name=\"!StreamData\")):oi.size\u003e=4096?(oi.storage=\"fat\",Gt[oi.start]===void 0\u0026\u0026(Gt[oi.start]=he(Rt,oi.start,Gt.fat_addrs,Gt.ssz)),Gt[oi.start].name=oi.name,oi.content=Gt[oi.start].data.slice(0,oi.size)):(oi.storage=\"minifat\",oi.size\u003c0?oi.size=0:En!==At\u0026\u0026oi.start!==At\u0026\u0026Gt[En]\u0026\u0026(oi.content=Me(oi,Gt[En].data,(Gt[qn]||{}).data))),oi.content\u0026\u0026R(oi.content,0),Nt[gi]=oi,_n.push(oi)}}function we(Et,Gt){return new Date((E(Et,Gt+4)/1e7*Math.pow(2,32)+E(Et,Gt)/1e7-11644473600)*1e3)}function Te(Et,Gt){return ge(),_e(le.readFileSync(Et),Gt)}function Re(Et,Gt){var Rt=Gt\u0026\u0026Gt.type;switch(Rt||r\u0026\u0026Buffer.isBuffer(Et)\u0026\u0026(Rt=\"buffer\"),Rt||\"base64\"){case\"file\":return Te(Et,Gt);case\"base64\":return _e(c(i(Et)),Gt);case\"binary\":return _e(c(Et),Gt)}return _e(Et,Gt)}function Ee(Et,Gt){var Rt=Gt||{},Ht=Rt.root||\"Root Entry\";if(Et.FullPaths||(Et.FullPaths=[]),Et.FileIndex||(Et.FileIndex=[]),Et.FullPaths.length!==Et.FileIndex.length)throw new Error(\"inconsistent CFB structure\");Et.FullPaths.length===0\u0026\u0026(Et.FullPaths[0]=Ht+\"/\",Et.FileIndex[0]={name:Ht,type:5}),Rt.CLSID\u0026\u0026(Et.FileIndex[0].clsid=Rt.CLSID),ke(Et)}function ke(Et){var Gt=\"\u0001Sh33tJ5\";if(!U.find(Et,\"/\"+Gt)){var Rt=F(4);Rt[0]=55,Rt[1]=Rt[3]=50,Rt[2]=54,Et.FileIndex.push({name:Gt,type:2,content:Rt,size:4,L:69,R:69,C:69}),Et.FullPaths.push(Et.FullPaths[0]+Gt),Ce(Et)}}function Ce(Et,Gt){Ee(Et);for(var Rt=!1,Ht=!1,Qt=Et.FullPaths.length-1;Qt\u003e=0;--Qt){var Nt=Et.FileIndex[Qt];switch(Nt.type){case 0:Ht?Rt=!0:(Et.FileIndex.pop(),Et.FullPaths.pop());break;case 1:case 2:case 5:Ht=!0,isNaN(Nt.R*Nt.L*Nt.C)\u0026\u0026(Rt=!0),Nt.R\u003e-1\u0026\u0026Nt.L\u003e-1\u0026\u0026Nt.R==Nt.L\u0026\u0026(Rt=!0);break;default:Rt=!0;break}}if(!(!Rt\u0026\u0026!Gt)){var _n=new Date(1987,1,19),qn=0,En=Object.create?Object.create(null):{},Rn=[];for(Qt=0;Qt\u003cEt.FullPaths.length;++Qt)En[Et.FullPaths[Qt]]=!0,Et.FileIndex[Qt].type!==0\u0026\u0026Rn.push([Et.FullPaths[Qt],Et.FileIndex[Qt]]);for(Qt=0;Qt\u003cRn.length;++Qt){var Hn=j(Rn[Qt][0]);for(Ht=En[Hn];!Ht;){for(;j(Hn)\u0026\u0026!En[j(Hn)];)Hn=j(Hn);Rn.push([Hn,{name:J(Hn).replace(\"/\",\"\"),type:1,clsid:gt,ct:_n,mt:_n,content:null}]),En[Hn]=!0,Hn=j(Rn[Qt][0]),Ht=En[Hn]}}for(Rn.sort(function(gi,jo){return te(gi[0],jo[0])}),Et.FullPaths=[],Et.FileIndex=[],Qt=0;Qt\u003cRn.length;++Qt)Et.FullPaths[Qt]=Rn[Qt][0],Et.FileIndex[Qt]=Rn[Qt][1];for(Qt=0;Qt\u003cRn.length;++Qt){var Lo=Et.FileIndex[Qt],Io=Et.FullPaths[Qt];if(Lo.name=J(Io).replace(\"/\",\"\"),Lo.L=Lo.R=Lo.C=-(Lo.color=1),Lo.size=Lo.content?Lo.content.length:0,Lo.start=0,Lo.clsid=Lo.clsid||gt,Qt===0)Lo.C=Rn.length\u003e1?1:-1,Lo.size=0,Lo.type=5;else if(Io.slice(-1)==\"/\"){for(qn=Qt+1;qn\u003cRn.length\u0026\u0026j(Et.FullPaths[qn])!=Io;++qn);for(Lo.C=qn\u003e=Rn.length?-1:qn,qn=Qt+1;qn\u003cRn.length\u0026\u0026j(Et.FullPaths[qn])!=j(Io);++qn);Lo.R=qn\u003e=Rn.length?-1:qn,Lo.type=1}else j(Et.FullPaths[Qt+1]||\"\")==j(Io)\u0026\u0026(Lo.R=Qt+1),Lo.type=2}}}function Le(Et,Gt){var Rt=Gt||{};if(Rt.fileType==\"mad\")return ur(Et,Rt);if(Ce(Et),Rt.fileType===\"zip\")return uo(Et,Rt);var Ht=(function(gi){for(var jo=0,oi=0,Ji=0;Ji\u003cgi.FileIndex.length;++Ji){var wi=gi.FileIndex[Ji];if(wi.content){var Br=wi.content.length;Br\u003e0\u0026\u0026(Br\u003c4096?jo+=Br+63\u003e\u003e6:oi+=Br+511\u003e\u003e9)}}for(var gr=gi.FullPaths.length+3\u003e\u003e2,oa=jo+7\u003e\u003e3,hs=jo+127\u003e\u003e7,Li=oa+oi+gr+hs,ys=Li+127\u003e\u003e7,dr=ys\u003c=109?0:Math.ceil((ys-109)/127);Li+ys+dr+127\u003e\u003e7\u003eys;)dr=++ys\u003c=109?0:Math.ceil((ys-109)/127);var cA=[1,dr,ys,hs,gr,oi,jo,0];return gi.FileIndex[0].size=jo\u003c\u003c6,cA[7]=(gi.FileIndex[0].start=cA[0]+cA[1]+cA[2]+cA[3]+cA[4]+cA[5])+(cA[6]+7\u003e\u003e3),cA})(Et),Qt=F(Ht[7]\u003c\u003c9),Nt=0,_n=0;{for(Nt=0;Nt\u003c8;++Nt)Qt.write_shift(1,nt[Nt]);for(Nt=0;Nt\u003c8;++Nt)Qt.write_shift(2,0);for(Qt.write_shift(2,62),Qt.write_shift(2,3),Qt.write_shift(2,65534),Qt.write_shift(2,9),Qt.write_shift(2,6),Nt=0;Nt\u003c3;++Nt)Qt.write_shift(2,0);for(Qt.write_shift(4,0),Qt.write_shift(4,Ht[2]),Qt.write_shift(4,Ht[0]+Ht[1]+Ht[2]+Ht[3]-1),Qt.write_shift(4,0),Qt.write_shift(4,4096),Qt.write_shift(4,Ht[3]?Ht[0]+Ht[1]+Ht[2]-1:At),Qt.write_shift(4,Ht[3]),Qt.write_shift(-4,Ht[1]?Ht[0]-1:At),Qt.write_shift(4,Ht[1]),Nt=0;Nt\u003c109;++Nt)Qt.write_shift(-4,Nt\u003cHt[2]?Ht[1]+Nt:-1)}if(Ht[1])for(_n=0;_n\u003cHt[1];++_n){for(;Nt\u003c236+_n*127;++Nt)Qt.write_shift(-4,Nt\u003cHt[2]?Ht[1]+Nt:-1);Qt.write_shift(-4,_n===Ht[1]-1?At:_n+1)}var qn=function(gi){for(_n+=gi;Nt\u003c_n-1;++Nt)Qt.write_shift(-4,Nt+1);gi\u0026\u0026(++Nt,Qt.write_shift(-4,At))};for(_n=Nt=0,_n+=Ht[1];Nt\u003c_n;++Nt)Qt.write_shift(-4,bt.DIFSECT);for(_n+=Ht[2];Nt\u003c_n;++Nt)Qt.write_shift(-4,bt.FATSECT);qn(Ht[3]),qn(Ht[4]);for(var En=0,Rn=0,Hn=Et.FileIndex[0];En\u003cEt.FileIndex.length;++En)Hn=Et.FileIndex[En],Hn.content\u0026\u0026(Rn=Hn.content.length,!(Rn\u003c4096)\u0026\u0026(Hn.start=_n,qn(Rn+511\u003e\u003e9)));for(qn(Ht[6]+7\u003e\u003e3);Qt.l\u0026511;)Qt.write_shift(-4,bt.ENDOFCHAIN);for(_n=Nt=0,En=0;En\u003cEt.FileIndex.length;++En)Hn=Et.FileIndex[En],Hn.content\u0026\u0026(Rn=Hn.content.length,!(!Rn||Rn\u003e=4096)\u0026\u0026(Hn.start=_n,qn(Rn+63\u003e\u003e6)));for(;Qt.l\u0026511;)Qt.write_shift(-4,bt.ENDOFCHAIN);for(Nt=0;Nt\u003cHt[4]\u003c\u003c2;++Nt){var Lo=Et.FullPaths[Nt];if(!Lo||Lo.length===0){for(En=0;En\u003c17;++En)Qt.write_shift(4,0);for(En=0;En\u003c3;++En)Qt.write_shift(4,-1);for(En=0;En\u003c12;++En)Qt.write_shift(4,0);continue}Hn=Et.FileIndex[Nt],Nt===0\u0026\u0026(Hn.start=Hn.size?Hn.start-1:At);var Io=Nt===0\u0026\u0026Rt.root||Hn.name;if(Io.length\u003e32\u0026\u0026(console.error(\"Name \"+Io+\" will be truncated to \"+Io.slice(0,32)),Io=Io.slice(0,32)),Rn=2*(Io.length+1),Qt.write_shift(64,Io,\"utf16le\"),Qt.write_shift(2,Rn),Qt.write_shift(1,Hn.type),Qt.write_shift(1,Hn.color),Qt.write_shift(-4,Hn.L),Qt.write_shift(-4,Hn.R),Qt.write_shift(-4,Hn.C),Hn.clsid)Qt.write_shift(16,Hn.clsid,\"hex\");else for(En=0;En\u003c4;++En)Qt.write_shift(4,0);Qt.write_shift(4,Hn.state||0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,Hn.start),Qt.write_shift(4,Hn.size),Qt.write_shift(4,0)}for(Nt=1;Nt\u003cEt.FileIndex.length;++Nt)if(Hn=Et.FileIndex[Nt],Hn.size\u003e=4096)if(Qt.l=Hn.start+1\u003c\u003c9,r\u0026\u0026Buffer.isBuffer(Hn.content))Hn.content.copy(Qt,Qt.l,0,Hn.size),Qt.l+=Hn.size+511\u0026-512;else{for(En=0;En\u003cHn.size;++En)Qt.write_shift(1,Hn.content[En]);for(;En\u0026511;++En)Qt.write_shift(1,0)}for(Nt=1;Nt\u003cEt.FileIndex.length;++Nt)if(Hn=Et.FileIndex[Nt],Hn.size\u003e0\u0026\u0026Hn.size\u003c4096)if(r\u0026\u0026Buffer.isBuffer(Hn.content))Hn.content.copy(Qt,Qt.l,0,Hn.size),Qt.l+=Hn.size+63\u0026-64;else{for(En=0;En\u003cHn.size;++En)Qt.write_shift(1,Hn.content[En]);for(;En\u002663;++En)Qt.write_shift(1,0)}if(r)Qt.l=Qt.length;else for(;Qt.l\u003cQt.length;)Qt.write_shift(1,0);return Qt}function Ye(Et,Gt){var Rt=Et.FullPaths.map(function(En){return En.toUpperCase()}),Ht=Rt.map(function(En){var Rn=En.split(\"/\");return Rn[Rn.length-(En.slice(-1)==\"/\"?2:1)]}),Qt=!1;Gt.charCodeAt(0)===47?(Qt=!0,Gt=Rt[0].slice(0,-1)+Gt):Qt=Gt.indexOf(\"/\")!==-1;var Nt=Gt.toUpperCase(),_n=Qt===!0?Rt.indexOf(Nt):Ht.indexOf(Nt);if(_n!==-1)return Et.FileIndex[_n];var qn=!Nt.match(u);for(Nt=Nt.replace(l,\"\"),qn\u0026\u0026(Nt=Nt.replace(u,\"!\")),_n=0;_n\u003cRt.length;++_n)if((qn?Rt[_n].replace(u,\"!\"):Rt[_n]).replace(l,\"\")==Nt||(qn?Ht[_n].replace(u,\"!\"):Ht[_n]).replace(l,\"\")==Nt)return Et.FileIndex[_n];return null}var tt=64,At=-2,at=\"d0cf11e0a1b11ae1\",nt=[208,207,17,224,161,177,26,225],gt=\"00000000000000000000000000000000\",bt={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:At,FREESECT:-1,HEADER_SIGNATURE:at,HEADER_MINOR_VERSION:\"3e00\",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:gt,EntryTypes:[\"unknown\",\"storage\",\"stream\",\"lockbytes\",\"property\",\"root\"]};function Ct(Et,Gt,Rt){ge();var Ht=Le(Et,Rt);le.writeFileSync(Gt,Ht)}function Dt(Et){for(var Gt=new Array(Et.length),Rt=0;Rt\u003cEt.length;++Rt)Gt[Rt]=String.fromCharCode(Et[Rt]);return Gt.join(\"\")}function kt(Et,Gt){var Rt=Le(Et,Gt);switch(Gt\u0026\u0026Gt.type||\"buffer\"){case\"file\":return ge(),le.writeFileSync(Gt.filename,Rt),Rt;case\"binary\":return typeof Rt==\"string\"?Rt:Dt(Rt);case\"base64\":return o(typeof Rt==\"string\"?Rt:Dt(Rt));case\"buffer\":if(r)return Buffer.isBuffer(Rt)?Rt:s(Rt);case\"array\":return typeof Rt==\"string\"?c(Rt):Rt}return Rt}var it;function Yt(Et){try{var Gt=Et.InflateRaw,Rt=new Gt;if(Rt._processChunk(new Uint8Array([3,0]),Rt._finishFlushFlag),Rt.bytesRead)it=Et;else throw new Error(\"zlib does not expose bytesRead\")}catch(Ht){console.error(\"cannot use native zlib: \"+(Ht.message||Ht))}}function pn(Et,Gt){if(!it)return To(Et,Gt);var Rt=it.InflateRaw,Ht=new Rt,Qt=Ht._processChunk(Et.slice(Et.l),Ht._finishFlushFlag);return Et.l+=Ht.bytesRead,Qt}function be(Et){return it?it.deflateRawSync(Et):qt(Et)}var et=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],It=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Bt=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];function mt(Et){var Gt=(Et\u003c\u003c1|Et\u003c\u003c11)\u0026139536|(Et\u003c\u003c5|Et\u003c\u003c15)\u0026558144;return(Gt\u003e\u003e16|Gt\u003e\u003e8|Gt)\u0026255}for(var st=typeof Uint8Array\u003c\"u\",xt=st?new Uint8Array(256):[],Xe=0;Xe\u003c256;++Xe)xt[Xe]=mt(Xe);function Ze(Et,Gt){var Rt=xt[Et\u0026255];return Gt\u003c=8?Rt\u003e\u003e\u003e8-Gt:(Rt=Rt\u003c\u003c8|xt[Et\u003e\u003e8\u0026255],Gt\u003c=16?Rt\u003e\u003e\u003e16-Gt:(Rt=Rt\u003c\u003c8|xt[Et\u003e\u003e16\u0026255],Rt\u003e\u003e\u003e24-Gt))}function dt(Et,Gt){var Rt=Gt\u00267,Ht=Gt\u003e\u003e\u003e3;return(Et[Ht]|(Rt\u003c=6?0:Et[Ht+1]\u003c\u003c8))\u003e\u003e\u003eRt\u00263}function Ut(Et,Gt){var Rt=Gt\u00267,Ht=Gt\u003e\u003e\u003e3;return(Et[Ht]|(Rt\u003c=5?0:Et[Ht+1]\u003c\u003c8))\u003e\u003e\u003eRt\u00267}function Wt(Et,Gt){var Rt=Gt\u00267,Ht=Gt\u003e\u003e\u003e3;return(Et[Ht]|(Rt\u003c=4?0:Et[Ht+1]\u003c\u003c8))\u003e\u003e\u003eRt\u002615}function Xt(Et,Gt){var Rt=Gt\u00267,Ht=Gt\u003e\u003e\u003e3;return(Et[Ht]|(Rt\u003c=3?0:Et[Ht+1]\u003c\u003c8))\u003e\u003e\u003eRt\u002631}function Jt(Et,Gt){var Rt=Gt\u00267,Ht=Gt\u003e\u003e\u003e3;return(Et[Ht]|(Rt\u003c=1?0:Et[Ht+1]\u003c\u003c8))\u003e\u003e\u003eRt\u0026127}function yn(Et,Gt,Rt){var Ht=Gt\u00267,Qt=Gt\u003e\u003e\u003e3,Nt=(1\u003c\u003cRt)-1,_n=Et[Qt]\u003e\u003e\u003eHt;return Rt\u003c8-Ht||(_n|=Et[Qt+1]\u003c\u003c8-Ht,Rt\u003c16-Ht)||(_n|=Et[Qt+2]\u003c\u003c16-Ht,Rt\u003c24-Ht)||(_n|=Et[Qt+3]\u003c\u003c24-Ht),_n\u0026Nt}function An(Et,Gt,Rt){var Ht=Gt\u00267,Qt=Gt\u003e\u003e\u003e3;return Ht\u003c=5?Et[Qt]|=(Rt\u00267)\u003c\u003cHt:(Et[Qt]|=Rt\u003c\u003cHt\u0026255,Et[Qt+1]=(Rt\u00267)\u003e\u003e8-Ht),Gt+3}function kn(Et,Gt,Rt){var Ht=Gt\u00267,Qt=Gt\u003e\u003e\u003e3;return Rt=(Rt\u00261)\u003c\u003cHt,Et[Qt]|=Rt,Gt+1}function $n(Et,Gt,Rt){var Ht=Gt\u00267,Qt=Gt\u003e\u003e\u003e3;return Rt\u003c\u003c=Ht,Et[Qt]|=Rt\u0026255,Rt\u003e\u003e\u003e=8,Et[Qt+1]=Rt,Gt+8}function ht(Et,Gt,Rt){var Ht=Gt\u00267,Qt=Gt\u003e\u003e\u003e3;return Rt\u003c\u003c=Ht,Et[Qt]|=Rt\u0026255,Rt\u003e\u003e\u003e=8,Et[Qt+1]=Rt\u0026255,Et[Qt+2]=Rt\u003e\u003e\u003e8,Gt+16}function Kt(Et,Gt){var Rt=Et.length,Ht=2*Rt\u003eGt?2*Rt:Gt+5,Qt=0;if(Rt\u003e=Gt)return Et;if(r){var Nt=A(Ht);if(Et.copy)Et.copy(Nt);else for(;Qt\u003cEt.length;++Qt)Nt[Qt]=Et[Qt];return Nt}else if(st){var _n=new Uint8Array(Ht);if(_n.set)_n.set(Et);else for(;Qt\u003cRt;++Qt)_n[Qt]=Et[Qt];return _n}return Et.length=Ht,Et}function rn(Et){for(var Gt=new Array(Et),Rt=0;Rt\u003cEt;++Rt)Gt[Rt]=0;return Gt}function Lt(Et,Gt,Rt){var Ht=1,Qt=0,Nt=0,_n=0,qn=0,En=Et.length,Rn=st?new Uint16Array(32):rn(32);for(Nt=0;Nt\u003c32;++Nt)Rn[Nt]=0;for(Nt=En;Nt\u003cRt;++Nt)Et[Nt]=0;En=Et.length;var Hn=st?new Uint16Array(En):rn(En);for(Nt=0;Nt\u003cEn;++Nt)Rn[Qt=Et[Nt]]++,Ht\u003cQt\u0026\u0026(Ht=Qt),Hn[Nt]=0;for(Rn[0]=0,Nt=1;Nt\u003c=Ht;++Nt)Rn[Nt+16]=qn=qn+Rn[Nt-1]\u003c\u003c1;for(Nt=0;Nt\u003cEn;++Nt)qn=Et[Nt],qn!=0\u0026\u0026(Hn[Nt]=Rn[qn+16]++);var Lo=0;for(Nt=0;Nt\u003cEn;++Nt)if(Lo=Et[Nt],Lo!=0)for(qn=Ze(Hn[Nt],Ht)\u003e\u003eHt-Lo,_n=(1\u003c\u003cHt+4-Lo)-1;_n\u003e=0;--_n)Gt[qn|_n\u003c\u003cLo]=Lo\u002615|Nt\u003c\u003c4;return Ht}var Ho=st?new Uint16Array(512):rn(512),Ao=st?new Uint16Array(32):rn(32);if(!st){for(var qe=0;qe\u003c512;++qe)Ho[qe]=0;for(qe=0;qe\u003c32;++qe)Ao[qe]=0}(function(){for(var Et=[],Gt=0;Gt\u003c32;Gt++)Et.push(5);Lt(Et,Ao,32);var Rt=[];for(Gt=0;Gt\u003c=143;Gt++)Rt.push(8);for(;Gt\u003c=255;Gt++)Rt.push(9);for(;Gt\u003c=279;Gt++)Rt.push(7);for(;Gt\u003c=287;Gt++)Rt.push(8);Lt(Rt,Ho,288)})();var vt=(function(){for(var Gt=st?new Uint8Array(32768):[],Rt=0,Ht=0;Rt\u003cBt.length-1;++Rt)for(;Ht\u003cBt[Rt+1];++Ht)Gt[Ht]=Rt;for(;Ht\u003c32768;++Ht)Gt[Ht]=29;var Qt=st?new Uint8Array(259):[];for(Rt=0,Ht=0;Rt\u003cIt.length-1;++Rt)for(;Ht\u003cIt[Rt+1];++Ht)Qt[Ht]=Rt;function Nt(qn,En){for(var Rn=0;Rn\u003cqn.length;){var Hn=Math.min(65535,qn.length-Rn),Lo=Rn+Hn==qn.length;for(En.write_shift(1,+Lo),En.write_shift(2,Hn),En.write_shift(2,~Hn\u002665535);Hn-- \u003e0;)En[En.l++]=qn[Rn++]}return En.l}function _n(qn,En){for(var Rn=0,Hn=0,Lo=st?new Uint16Array(32768):[];Hn\u003cqn.length;){var Io=Math.min(65535,qn.length-Hn);if(Io\u003c10){for(Rn=An(En,Rn,+(Hn+Io==qn.length)),Rn\u00267\u0026\u0026(Rn+=8-(Rn\u00267)),En.l=Rn/8|0,En.write_shift(2,Io),En.write_shift(2,~Io\u002665535);Io-- \u003e0;)En[En.l++]=qn[Hn++];Rn=En.l*8;continue}Rn=An(En,Rn,+(Hn+Io==qn.length)+2);for(var gi=0;Io-- \u003e0;){var jo=qn[Hn];gi=(gi\u003c\u003c5^jo)\u002632767;var oi=-1,Ji=0;if((oi=Lo[gi])\u0026\u0026(oi|=Hn\u0026-32768,oi\u003eHn\u0026\u0026(oi-=32768),oi\u003cHn))for(;qn[oi+Ji]==qn[Hn+Ji]\u0026\u0026Ji\u003c250;)++Ji;if(Ji\u003e2){jo=Qt[Ji],jo\u003c=22?Rn=$n(En,Rn,xt[jo+1]\u003e\u003e1)-1:($n(En,Rn,3),Rn+=5,$n(En,Rn,xt[jo-23]\u003e\u003e5),Rn+=3);var wi=jo\u003c8?0:jo-4\u003e\u003e2;wi\u003e0\u0026\u0026(ht(En,Rn,Ji-It[jo]),Rn+=wi),jo=Gt[Hn-oi],Rn=$n(En,Rn,xt[jo]\u003e\u003e3),Rn-=3;var Br=jo\u003c4?0:jo-2\u003e\u003e1;Br\u003e0\u0026\u0026(ht(En,Rn,Hn-oi-Bt[jo]),Rn+=Br);for(var gr=0;gr\u003cJi;++gr)Lo[gi]=Hn\u002632767,gi=(gi\u003c\u003c5^qn[Hn])\u002632767,++Hn;Io-=Ji-1}else jo\u003c=143?jo=jo+48:Rn=kn(En,Rn,1),Rn=$n(En,Rn,xt[jo]),Lo[gi]=Hn\u002632767,++Hn}Rn=$n(En,Rn,0)-1}return En.l=(Rn+7)/8|0,En.l}return function(En,Rn){return En.length\u003c8?Nt(En,Rn):_n(En,Rn)}})();function qt(Et){var Gt=F(50+Math.floor(Et.length*1.1)),Rt=vt(Et,Gt);return Gt.slice(0,Rt)}var Zt=st?new Uint16Array(32768):rn(32768),nn=st?new Uint16Array(32768):rn(32768),zn=st?new Uint16Array(128):rn(128),Nn=1,Co=1;function ei(Et,Gt){var Rt=Xt(Et,Gt)+257;Gt+=5;var Ht=Xt(Et,Gt)+1;Gt+=5;var Qt=Wt(Et,Gt)+4;Gt+=4;for(var Nt=0,_n=st?new Uint8Array(19):rn(19),qn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],En=1,Rn=st?new Uint8Array(8):rn(8),Hn=st?new Uint8Array(8):rn(8),Lo=_n.length,Io=0;Io\u003cQt;++Io)_n[et[Io]]=Nt=Ut(Et,Gt),En\u003cNt\u0026\u0026(En=Nt),Rn[Nt]++,Gt+=3;var gi=0;for(Rn[0]=0,Io=1;Io\u003c=En;++Io)Hn[Io]=gi=gi+Rn[Io-1]\u003c\u003c1;for(Io=0;Io\u003cLo;++Io)(gi=_n[Io])!=0\u0026\u0026(qn[Io]=Hn[gi]++);var jo=0;for(Io=0;Io\u003cLo;++Io)if(jo=_n[Io],jo!=0){gi=xt[qn[Io]]\u003e\u003e8-jo;for(var oi=(1\u003c\u003c7-jo)-1;oi\u003e=0;--oi)zn[gi|oi\u003c\u003cjo]=jo\u00267|Io\u003c\u003c3}var Ji=[];for(En=1;Ji.length\u003cRt+Ht;)switch(gi=zn[Jt(Et,Gt)],Gt+=gi\u00267,gi\u003e\u003e\u003e=3){case 16:for(Nt=3+dt(Et,Gt),Gt+=2,gi=Ji[Ji.length-1];Nt-- \u003e0;)Ji.push(gi);break;case 17:for(Nt=3+Ut(Et,Gt),Gt+=3;Nt-- \u003e0;)Ji.push(0);break;case 18:for(Nt=11+Jt(Et,Gt),Gt+=7;Nt-- \u003e0;)Ji.push(0);break;default:Ji.push(gi),En\u003cgi\u0026\u0026(En=gi);break}var wi=Ji.slice(0,Rt),Br=Ji.slice(Rt);for(Io=Rt;Io\u003c286;++Io)wi[Io]=0;for(Io=Ht;Io\u003c30;++Io)Br[Io]=0;return Nn=Lt(wi,Zt,286),Co=Lt(Br,nn,30),Gt}function ro(Et,Gt){if(Et[0]==3\u0026\u0026!(Et[1]\u00263))return[a(Gt),2];for(var Rt=0,Ht=0,Qt=A(Gt||1\u003c\u003c18),Nt=0,_n=Qt.length\u003e\u003e\u003e0,qn=0,En=0;(Ht\u00261)==0;){if(Ht=Ut(Et,Rt),Rt+=3,Ht\u003e\u003e\u003e1)Ht\u003e\u003e1==1?(qn=9,En=5):(Rt=ei(Et,Rt),qn=Nn,En=Co);else{Rt\u00267\u0026\u0026(Rt+=8-(Rt\u00267));var Rn=Et[Rt\u003e\u003e\u003e3]|Et[(Rt\u003e\u003e\u003e3)+1]\u003c\u003c8;if(Rt+=32,Rn\u003e0)for(!Gt\u0026\u0026_n\u003cNt+Rn\u0026\u0026(Qt=Kt(Qt,Nt+Rn),_n=Qt.length);Rn-- \u003e0;)Qt[Nt++]=Et[Rt\u003e\u003e\u003e3],Rt+=8;continue}for(;;){!Gt\u0026\u0026_n\u003cNt+32767\u0026\u0026(Qt=Kt(Qt,Nt+32767),_n=Qt.length);var Hn=yn(Et,Rt,qn),Lo=Ht\u003e\u003e\u003e1==1?Ho[Hn]:Zt[Hn];if(Rt+=Lo\u002615,Lo\u003e\u003e\u003e=4,(Lo\u003e\u003e\u003e8\u0026255)===0)Qt[Nt++]=Lo;else{if(Lo==256)break;Lo-=257;var Io=Lo\u003c8?0:Lo-4\u003e\u003e2;Io\u003e5\u0026\u0026(Io=0);var gi=Nt+It[Lo];Io\u003e0\u0026\u0026(gi+=yn(Et,Rt,Io),Rt+=Io),Hn=yn(Et,Rt,En),Lo=Ht\u003e\u003e\u003e1==1?Ao[Hn]:nn[Hn],Rt+=Lo\u002615,Lo\u003e\u003e\u003e=4;var jo=Lo\u003c4?0:Lo-2\u003e\u003e1,oi=Bt[Lo];for(jo\u003e0\u0026\u0026(oi+=yn(Et,Rt,jo),Rt+=jo),!Gt\u0026\u0026_n\u003cgi\u0026\u0026(Qt=Kt(Qt,gi+100),_n=Qt.length);Nt\u003cgi;)Qt[Nt]=Qt[Nt-oi],++Nt}}}return Gt?[Qt,Rt+7\u003e\u003e\u003e3]:[Qt.slice(0,Nt),Rt+7\u003e\u003e\u003e3]}function To(Et,Gt){var Rt=Et.slice(Et.l||0),Ht=ro(Rt,Gt);return Et.l+=Ht[1],Ht[0]}function yo(Et,Gt){if(Et)typeof console\u003c\"u\"\u0026\u0026console.error(Gt);else throw new Error(Gt)}function Ro(Et,Gt){var Rt=Et;R(Rt,0);var Ht=[],Qt=[],Nt={FileIndex:Ht,FullPaths:Qt};Ee(Nt,{root:Gt.root});for(var _n=Rt.length-4;(Rt[_n]!=80||Rt[_n+1]!=75||Rt[_n+2]!=5||Rt[_n+3]!=6)\u0026\u0026_n\u003e=0;)--_n;Rt.l=_n+4,Rt.l+=4;var qn=Rt.read_shift(2);Rt.l+=6;var En=Rt.read_shift(4);for(Rt.l=En,_n=0;_n\u003cqn;++_n){Rt.l+=20;var Rn=Rt.read_shift(4),Hn=Rt.read_shift(4),Lo=Rt.read_shift(2),Io=Rt.read_shift(2),gi=Rt.read_shift(2);Rt.l+=8;var jo=Rt.read_shift(4),oi=ne(Rt.slice(Rt.l+Lo,Rt.l+Lo+Io));Rt.l+=Lo+Io+gi;var Ji=Rt.l;Rt.l=jo+4,On(Rt,Rn,Hn,Nt,oi),Rt.l=Ji}return Nt}function On(Et,Gt,Rt,Ht,Qt){Et.l+=2;var Nt=Et.read_shift(2),_n=Et.read_shift(2),qn=ie(Et);if(Nt\u00268257)throw new Error(\"Unsupported ZIP encryption\");for(var En=Et.read_shift(4),Rn=Et.read_shift(4),Hn=Et.read_shift(4),Lo=Et.read_shift(2),Io=Et.read_shift(2),gi=\"\",jo=0;jo\u003cLo;++jo)gi+=String.fromCharCode(Et[Et.l++]);if(Io){var oi=ne(Et.slice(Et.l,Et.l+Io));(oi[21589]||{}).mt\u0026\u0026(qn=oi[21589].mt),((Qt||{})[21589]||{}).mt\u0026\u0026(qn=Qt[21589].mt)}Et.l+=Io;var Ji=Et.slice(Et.l,Et.l+Rn);switch(_n){case 8:Ji=pn(Et,Hn);break;case 0:break;default:throw new Error(\"Unsupported ZIP Compression method \"+_n)}var wi=!1;Nt\u00268\u0026\u0026(En=Et.read_shift(4),En==134695760\u0026\u0026(En=Et.read_shift(4),wi=!0),Rn=Et.read_shift(4),Hn=Et.read_shift(4)),Rn!=Gt\u0026\u0026yo(wi,\"Bad compressed size: \"+Gt+\" != \"+Rn),Hn!=Rt\u0026\u0026yo(wi,\"Bad uncompressed size: \"+Rt+\" != \"+Hn);var Br=O.buf(Ji,0);En\u003e\u003e0!=Br\u003e\u003e0\u0026\u0026yo(wi,\"Bad CRC32 checksum: \"+En+\" != \"+Br),bi(Ht,gi,Ji,{unsafe:!0,mt:qn})}function uo(Et,Gt){var Rt=Gt||{},Ht=[],Qt=[],Nt=F(1),_n=Rt.compression?8:0,qn=0,En=0,Rn=0,Hn=0,Lo=0,Io=Et.FullPaths[0],gi=Io,jo=Et.FileIndex[0],oi=[],Ji=0;for(En=1;En\u003cEt.FullPaths.length;++En)if(gi=Et.FullPaths[En].slice(Io.length),jo=Et.FileIndex[En],!(!jo.size||!jo.content||gi==\"\u0001Sh33tJ5\")){var wi=Hn,Br=F(gi.length);for(Rn=0;Rn\u003cgi.length;++Rn)Br.write_shift(1,gi.charCodeAt(Rn)\u0026127);Br=Br.slice(0,Br.l),oi[Lo]=O.buf(jo.content,0);var gr=jo.content;_n==8\u0026\u0026(gr=be(gr)),Nt=F(30),Nt.write_shift(4,67324752),Nt.write_shift(2,20),Nt.write_shift(2,qn),Nt.write_shift(2,_n),jo.mt?oe(Nt,jo.mt):Nt.write_shift(4,0),Nt.write_shift(-4,oi[Lo]),Nt.write_shift(4,gr.length),Nt.write_shift(4,jo.content.length),Nt.write_shift(2,Br.length),Nt.write_shift(2,0),Hn+=Nt.length,Ht.push(Nt),Hn+=Br.length,Ht.push(Br),Hn+=gr.length,Ht.push(gr),Nt=F(46),Nt.write_shift(4,33639248),Nt.write_shift(2,0),Nt.write_shift(2,20),Nt.write_shift(2,qn),Nt.write_shift(2,_n),Nt.write_shift(4,0),Nt.write_shift(-4,oi[Lo]),Nt.write_shift(4,gr.length),Nt.write_shift(4,jo.content.length),Nt.write_shift(2,Br.length),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(4,0),Nt.write_shift(4,wi),Ji+=Nt.l,Qt.push(Nt),Ji+=Br.length,Qt.push(Br),++Lo}return Nt=F(22),Nt.write_shift(4,101010256),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,Lo),Nt.write_shift(2,Lo),Nt.write_shift(4,Ji),Nt.write_shift(4,Hn),Nt.write_shift(2,0),I([I(Ht),I(Qt),Nt])}var Oo={htm:\"text/html\",xml:\"text/xml\",gif:\"image/gif\",jpg:\"image/jpeg\",png:\"image/png\",mso:\"application/x-mso\",thmx:\"application/vnd.ms-officetheme\",sh33tj5:\"application/octet-stream\"};function ko(Et,Gt){if(Et.ctype)return Et.ctype;var Rt=Et.name||\"\",Ht=Rt.match(/\\.([^\\.]+)$/);return Ht\u0026\u0026Oo[Ht[1]]||Gt\u0026\u0026(Ht=(Rt=Gt).match(/[\\.\\\\]([^\\.\\\\])+$/),Ht\u0026\u0026Oo[Ht[1]])?Oo[Ht[1]]:\"application/octet-stream\"}function Ko(Et){for(var Gt=o(Et),Rt=[],Ht=0;Ht\u003cGt.length;Ht+=76)Rt.push(Gt.slice(Ht,Ht+76));return Rt.join(`\\r\n`)+`\\r\n`}function mi(Et){var Gt=Et.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7E-\\xFF=]/g,function(Rn){var Hn=Rn.charCodeAt(0).toString(16).toUpperCase();return\"=\"+(Hn.length==1?\"0\"+Hn:Hn)});Gt=Gt.replace(/ $/mg,\"=20\").replace(/\\t$/mg,\"=09\"),Gt.charAt(0)==`\n`\u0026\u0026(Gt=\"=0D\"+Gt.slice(1)),Gt=Gt.replace(/\\r(?!\\n)/mg,\"=0D\").replace(/\\n\\n/mg,`\n=0A`).replace(/([^\\r\\n])\\n/mg,\"$1=0A\");for(var Rt=[],Ht=Gt.split(`\\r\n`),Qt=0;Qt\u003cHt.length;++Qt){var Nt=Ht[Qt];if(Nt.length==0){Rt.push(\"\");continue}for(var _n=0;_n\u003cNt.length;){var qn=76,En=Nt.slice(_n,_n+qn);En.charAt(qn-1)==\"=\"?qn--:En.charAt(qn-2)==\"=\"?qn-=2:En.charAt(qn-3)==\"=\"\u0026\u0026(qn-=3),En=Nt.slice(_n,_n+qn),_n+=qn,_n\u003cNt.length\u0026\u0026(En+=\"=\"),Rt.push(En)}}return Rt.join(`\\r\n`)}function Fo(Et){for(var Gt=[],Rt=0;Rt\u003cEt.length;++Rt){for(var Ht=Et[Rt];Rt\u003c=Et.length\u0026\u0026Ht.charAt(Ht.length-1)==\"=\";)Ht=Ht.slice(0,Ht.length-1)+Et[++Rt];Gt.push(Ht)}for(var Qt=0;Qt\u003cGt.length;++Qt)Gt[Qt]=Gt[Qt].replace(/[=][0-9A-Fa-f]{2}/g,function(Nt){return String.fromCharCode(parseInt(Nt.slice(1),16))});return c(Gt.join(`\\r\n`))}function Nr(Et,Gt,Rt){for(var Ht=\"\",Qt=\"\",Nt=\"\",_n,qn=0;qn\u003c10;++qn){var En=Gt[qn];if(!En||En.match(/^\\s*$/))break;var Rn=En.match(/^(.*?):\\s*([^\\s].*)$/);if(Rn)switch(Rn[1].toLowerCase()){case\"content-location\":Ht=Rn[2].trim();break;case\"content-type\":Nt=Rn[2].trim();break;case\"content-transfer-encoding\":Qt=Rn[2].trim();break}}switch(++qn,Qt.toLowerCase()){case\"base64\":_n=c(i(Gt.slice(qn).join(\"\")));break;case\"quoted-printable\":_n=Fo(Gt.slice(qn));break;default:throw new Error(\"Unsupported Content-Transfer-Encoding \"+Qt)}var Hn=bi(Et,Ht.slice(Rt.length),_n,{unsafe:!0});Nt\u0026\u0026(Hn.ctype=Nt)}function Rs(Et,Gt){if(Dt(Et.slice(0,13)).toLowerCase()!=\"mime-version:\")throw new Error(\"Unsupported MAD header\");var Rt=Gt\u0026\u0026Gt.root||\"\",Ht=(r\u0026\u0026Buffer.isBuffer(Et)?Et.toString(\"binary\"):Dt(Et)).split(`\\r\n`),Qt=0,Nt=\"\";for(Qt=0;Qt\u003cHt.length;++Qt)if(Nt=Ht[Qt],!!/^Content-Location:/i.test(Nt)\u0026\u0026(Nt=Nt.slice(Nt.indexOf(\"file\")),Rt||(Rt=Nt.slice(0,Nt.lastIndexOf(\"/\")+1)),Nt.slice(0,Rt.length)!=Rt))for(;Rt.length\u003e0\u0026\u0026(Rt=Rt.slice(0,Rt.length-1),Rt=Rt.slice(0,Rt.lastIndexOf(\"/\")+1),Nt.slice(0,Rt.length)!=Rt););var _n=(Ht[1]||\"\").match(/boundary=\"(.*?)\"/);if(!_n)throw new Error(\"MAD cannot find boundary\");var qn=\"--\"+(_n[1]||\"\"),En=[],Rn=[],Hn={FileIndex:En,FullPaths:Rn};Ee(Hn);var Lo,Io=0;for(Qt=0;Qt\u003cHt.length;++Qt){var gi=Ht[Qt];gi!==qn\u0026\u0026gi!==qn+\"--\"||(Io++\u0026\u0026Nr(Hn,Ht.slice(Lo,Qt),Rt),Lo=Qt)}return Hn}function ur(Et,Gt){var Rt=Gt||{},Ht=Rt.boundary||\"SheetJS\";Ht=\"------=\"+Ht;for(var Qt=[\"MIME-Version: 1.0\",'Content-Type: multipart/related; boundary=\"'+Ht.slice(2)+'\"',\"\",\"\",\"\"],Nt=Et.FullPaths[0],_n=Nt,qn=Et.FileIndex[0],En=1;En\u003cEt.FullPaths.length;++En)if(_n=Et.FullPaths[En].slice(Nt.length),qn=Et.FileIndex[En],!(!qn.size||!qn.content||_n==\"\u0001Sh33tJ5\")){_n=_n.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7E-\\xFF]/g,function(Ji){return\"_x\"+Ji.charCodeAt(0).toString(16)+\"_\"}).replace(/[\\u0080-\\uFFFF]/g,function(Ji){return\"_u\"+Ji.charCodeAt(0).toString(16)+\"_\"});for(var Rn=qn.content,Hn=r\u0026\u0026Buffer.isBuffer(Rn)?Rn.toString(\"binary\"):Dt(Rn),Lo=0,Io=Math.min(1024,Hn.length),gi=0,jo=0;jo\u003c=Io;++jo)(gi=Hn.charCodeAt(jo))\u003e=32\u0026\u0026gi\u003c128\u0026\u0026++Lo;var oi=Lo\u003e=Io*4/5;Qt.push(Ht),Qt.push(\"Content-Location: \"+(Rt.root||\"file:///C:/SheetJS/\")+_n),Qt.push(\"Content-Transfer-Encoding: \"+(oi?\"quoted-printable\":\"base64\")),Qt.push(\"Content-Type: \"+ko(qn,_n)),Qt.push(\"\"),Qt.push(oi?mi(Hn):Ko(Hn))}return Qt.push(Ht+`--\\r\n`),Qt.join(`\\r\n`)}function zi(Et){var Gt={};return Ee(Gt,Et),Gt}function bi(Et,Gt,Rt,Ht){var Qt=Ht\u0026\u0026Ht.unsafe;Qt||Ee(Et);var Nt=!Qt\u0026\u0026U.find(Et,Gt);if(!Nt){var _n=Et.FullPaths[0];Gt.slice(0,_n.length)==_n?_n=Gt:(_n.slice(-1)!=\"/\"\u0026\u0026(_n+=\"/\"),_n=(_n+Gt).replace(\"//\",\"/\")),Nt={name:J(Gt),type:2},Et.FileIndex.push(Nt),Et.FullPaths.push(_n),Qt||U.utils.cfb_gc(Et)}return Nt.content=Rt,Nt.size=Rt?Rt.length:0,Ht\u0026\u0026(Ht.CLSID\u0026\u0026(Nt.clsid=Ht.CLSID),Ht.mt\u0026\u0026(Nt.mt=Ht.mt),Ht.ct\u0026\u0026(Nt.ct=Ht.ct)),Nt}function Ar(Et,Gt){Ee(Et);var Rt=U.find(Et,Gt);if(Rt){for(var Ht=0;Ht\u003cEt.FileIndex.length;++Ht)if(Et.FileIndex[Ht]==Rt)return Et.FileIndex.splice(Ht,1),Et.FullPaths.splice(Ht,1),!0}return!1}function ws(Et,Gt,Rt){Ee(Et);var Ht=U.find(Et,Gt);if(Ht){for(var Qt=0;Qt\u003cEt.FileIndex.length;++Qt)if(Et.FileIndex[Qt]==Ht)return Et.FileIndex[Qt].name=J(Rt),Et.FullPaths[Qt]=Rt,!0}return!1}function ds(Et){Ce(Et,!0)}return W.find=Ye,W.read=Re,W.parse=_e,W.write=kt,W.writeFile=Ct,W.utils={cfb_new:zi,cfb_add:bi,cfb_del:Ar,cfb_mov:ws,cfb_gc:ds,ReadShift:S,CheckField:k,prep_blob:R,bconcat:I,use_zlib:Yt,_deflateRaw:qt,_inflateRaw:To,consts:bt},W})();typeof U8\u003c\"u\"\u0026\u0026typeof DO_NOT_EXPORT_CFB\u003e\"u\"\u0026\u0026(t.exports=U)})($Xe)),$Xe.exports}var ZXi=XXi();const A9=_y(ZXi);function j1n(t){return[...t].map(e=\u003ee===\"|\"||new RegExp(\"\\\\p{Cc}\",\"u\").test(e)?\" \":e).join(\"\")}function $1n(){return A9.utils.cfb_new({root:\"Root Entry\"})}function rk({compoundFile:t,content:e,path:n}){A9.utils.cfb_add(t,n,e)}function aK(t){const e=new Uint8Array(t.reduce((o,i)=\u003eo+i.byteLength,0));let n=0;for(const o of t)e.set(o,n),n+=o.byteLength;return e}function B1e(t){return new LE(4,4).uint32(t).toUint8Array()}function o3({compoundFile:t,content:e,name:n,recordCount:o}){rk({compoundFile:t,content:B1e(o),path:`/${n}/Header`}),rk({compoundFile:t,content:e,path:`/${n}/Data`})}function q1n(t){const e=A9.write(t,{type:\"buffer\",fileType:\"cfb\"});return new Uint8Array(e)}var X1n=65535,eZi=1e4;function Z1n(t){if(typeof t==\"string\")return t;if(\"sourceFormat\"in t\u0026\u0026t.sourceFormat!==\"ascii\")throw new Yg(\"Binary Altium input is already a compound document\");return t.getString()}function c9(t){return new Map(qXe(t).map(({fieldName:e,fieldText:n})=\u003e[e,n]))}function tZi(t){return qXe(t).map(({fieldName:e})=\u003ee)}function nZi(t){return c9(t).get(\"RECORD\")??\"\"}function rM(t){const e=[];for(const{fieldName:n,fieldText:o}of qXe(t))/[^\\x20-\\x7e]/u.test(o)\u0026\u0026e.push(...new TextEncoder().encode(`|%UTF8%${n}=${o}||`)),e.push(...tIn(`|${n}=${o.replace(/[^\\x20-\\x7e]/gu,\"?\")}`));return e.push(0),Uint8Array.from(e)}function b1e(t){const e=new LE;for(const n of t)e.uint32LengthPrefixedBytes(rM(n));return e.toUint8Array()}function oZi(t){const e=new LE;for(const n of t){const o=c9(n),i=iZi(o.get(\"BINARYRECORDTYPE\")),r=n.split(\"|\").filter(a=\u003ea\u0026\u0026!/^BINARYRECORDTYPE=/iu.test(a)).map(a=\u003e`|${a}`).join(\"\"),s=rM(r);e.uint16(i).uint32(s.byteLength).writeBytes(s)}return e.toUint8Array()}function _c(t){if(t===void 0)return 0;const e=Gee(t);if(e===void 0||!Number.isFinite(e))throw new Yg(`Invalid Altium measurement: ${JSON.stringify(t)}`);return Math.round(e*eZi)}function S1e(t){if(t===void 0)return X1n;const e=Number(t);if(!Number.isInteger(e)||e\u003c0||e\u003eX1n)throw new Yg(`Invalid Altium record index: ${JSON.stringify(t)}`);return e}function iZi(t){if(t===void 0)return 0;const e=Number(t);if(!Number.isInteger(e)||e\u003c0||e\u003e65535)throw new Yg(`Invalid Altium binary record type: ${JSON.stringify(t)}`);return e}function E4(t){if(t===void 0)return 0;const e=Number(t);if(!Number.isFinite(e))throw new Yg(`Invalid finite Altium number: ${JSON.stringify(t)}`);return e}function i3(t){if(t===void 0||t.toUpperCase()===\"FALSE\")return!1;if(t.toUpperCase()===\"TRUE\")return!0;throw new Yg(`Invalid Altium boolean: ${JSON.stringify(t)}`)}function AK(t){const e=tIn(t.slice(0,255));return aK([Uint8Array.of(e.byteLength),e])}function eIn(t,e){const n=new Uint8Array(e??(t.length+1)*2),o=new DataView(n.buffer),i=Math.min(t.length,n.byteLength/2);for(let r=0;r\u003ci;r++)o.setUint16(r*2,t.charCodeAt(r),!0);return n}function rZi(t){return t.replace(/[^\\x20-\\x7e]/gu,\"?\")}function qXe(t){return t.split(\"|\").filter(Boolean).map(e=\u003e{const n=e.indexOf(\"=\");if(n\u003c1)throw new Yg(`Invalid Altium record field: ${JSON.stringify(e)}`);return{fieldName:e.slice(0,n).toUpperCase(),fieldText:e.slice(n+1)}})}function tIn(t){return Uint8Array.from(t,e=\u003ee.charCodeAt(0)\u0026127)}var sZi={BACKGROUND:76,BOTTOM:32,BOTTOMOVERLAY:34,BOTTOMPASTE:36,BOTTOMSOLDER:38,CONNECTIONS:75,DRCERROR:77,DRILLDRAWING:73,DRILLGUIDE:55,KEEPOUT:56,MULTILAYER:74,PADHOLES:81,SELECTIONS:78,TOP:1,TOPOVERLAY:33,TOPPASTE:35,TOPSOLDER:37,VIAHOLES:82,VISIBLEGRID1:79,VISIBLEGRID2:80};function B4(t,e=1){if(t===void 0)return e;const n=t.toUpperCase(),o=sZi[n];if(o!==void 0)return o;const i=aZi(n);if(i!==void 0)return i;throw new Yg(`Unsupported Altium PCB layer: ${JSON.stringify(t)}`)}function aZi(t){const e=/^(MID-LAYER|INTERNALPLANE|MECHANICAL)(\\d{1,2})$/u.exec(t),n=Number.parseInt(e?.[2]??\"\",10);if(!(!e||!Number.isInteger(n)||n\u003c1)){if(e[1]===\"MID-LAYER\"\u0026\u0026n\u003c=30)return n+1;if(e[1]===\"INTERNALPLANE\"\u0026\u0026n\u003c=16)return n+38;if(e[1]===\"MECHANICAL\"\u0026\u0026n\u003c=16)return n+56;if(e[1]===\"MECHANICAL\"\u0026\u0026n\u003c=32)return n+66}}var sk=[\"COMPONENT\",\"LAYER\",\"LOCKED\",\"NET\",\"POLYGON\",\"RECORD\"],AZi={ComponentBody:new Set([...sk,\"ARCRESOLUTION\",\"BODYCOLOR3D\",\"BODYOPACITY3D\",\"BODYPROJECTION\",\"CAVITYHEIGHT\",\"HOLECOUNT\",\"IDENTIFIER\",\"ISSHAPEBASED\",\"KEEPOUT\",\"KIND\",\"NAME\",\"OVERALLHEIGHT\",\"STANDOFFHEIGHT\",\"SUBPOLYINDEX\",\"TEARDROP\",\"TEXTURE\",\"TEXTURECENTERX\",\"TEXTURECENTERY\",\"TEXTUREROTATION\",\"TEXTURESIZEX\",\"TEXTURESIZEY\",\"UNIONINDEX\",\"V7_LAYER\"]),Fill:new Set([...sk,\"KEEPOUT\",\"ROTATION\",\"X1\",\"X2\",\"Y1\",\"Y2\"]),Pad:new Set([...sk,\"HOLESHAPE\",\"HOLESIZE\",\"HOLEROTATION\",\"HOLEWIDTH\",\"NAME\",\"PLATED\",\"ROTATION\",\"SHAPE\",\"TENTEDBOTTOM\",\"TENTEDTOP\",\"X\",\"XSIZE\",\"Y\",\"YSIZE\"]),Region:new Set([...sk,\"HOLECOUNT\",\"KEEPOUT\",\"REGIONKIND\",\"TEARDROP\"]),Text:new Set([...sk,\"BOLD\",\"COMMENT\",\"DESIGNATOR\",\"FONTNAME\",\"HEIGHT\",\"INVERTED\",\"INVERTEDRECT\",\"ITALIC\",\"ISSHAPEBASED\",\"JUSTIFICATION\",\"MARGINBORDERWIDTH\",\"MIRROR\",\"ROTATION\",\"STROKEFONT\",\"TEXT\",\"TEXTBOXHEIGHT\",\"TEXTBOXWIDTH\",\"TEXTOFFSET\",\"USETTFONTS\",\"WIDESTRING\",\"WIDTH\",\"X\",\"Y\"]),Track:new Set([...sk,\"KEEPOUT\",\"WIDTH\",\"X1\",\"X2\",\"Y1\",\"Y2\"]),Via:new Set([...sk,\"DIAMETER\",\"ENDLAYER\",\"HOLESIZE\",\"STARTLAYER\",\"STOPLAYER\",\"TENTEDBOTTOM\",\"TENTEDTOP\",\"X\",\"Y\"])};function cZi(t,e){const n=tZi(t),o=n.filter((r,s)=\u003en.indexOf(r)!==s);if(o.length\u003e0)throw new Yg(`${e} binary serialization does not support duplicate fields: ${[...new Set(o)].join(\", \")}`);const i=n.filter(r=\u003e!uZi(r,e));if(i.length\u003e0)throw new Yg(`${e} binary serialization does not support fields: ${i.join(\", \")}`);lZi(c9(t),e)}function nIn(t){if(t===void 0||t.toUpperCase()===\"RECTANGLE\")return 2;if(t.toUpperCase()===\"ROUND\")return 1;throw new Yg(`Unsupported Altium pad shape: ${JSON.stringify(t)}`)}function lZi(t,e){B4(t.get(\"LAYER\"),e===\"Via\"?74:1);for(const n of[\"BOLD\",\"COMMENT\",\"DESIGNATOR\",\"INVERTED\",\"INVERTEDRECT\",\"ITALIC\",\"KEEPOUT\",\"LOCKED\",\"MIRROR\",\"PLATED\",\"TENTEDBOTTOM\",\"TENTEDTOP\",\"TEARDROP\",\"USETTFONTS\"])t.has(n)\u0026\u0026i3(t.get(n));if(e===\"Pad\"){nIn(t.get(\"SHAPE\"));const n=t.get(\"HOLESHAPE\")?.toUpperCase();if(n!==void 0\u0026\u0026n!==\"ROUND\"\u0026\u0026n!==\"SLOT\"\u0026\u0026n!==\"SQUARE\")throw new Yg(`Unsupported Altium pad hole shape: ${JSON.stringify(n)}`)}if(e===\"Via\"){const n=t.get(\"LAYER\")?.toUpperCase();if(n!==void 0\u0026\u0026n!==\"MULTILAYER\")throw new Yg(`Via binary serialization requires MULTILAYER, got ${JSON.stringify(n)}`);B4(t.get(\"STARTLAYER\"),1),B4(t.get(\"ENDLAYER\")??t.get(\"STOPLAYER\"),32)}if(e===\"Region\"){const n=t.get(\"REGIONKIND\")?.toUpperCase()??\"COPPER\";if(n!==\"COPPER\"\u0026\u0026n!==\"POLYGON_CUTOUT\")throw new Yg(`Unsupported Altium region kind: ${JSON.stringify(n)}`)}}function uZi(t,e){return AZi[e].has(t)?!0:e!==\"Region\"\u0026\u0026e!==\"ComponentBody\"?!1:/^(?:KIND|VX|VY|CX|CY|R|SA|EA)\\d+$/u.test(t)||/^HOLE\\d+(?:COUNT|V[XY]\\d+)$/u.test(t)}var oIn=65535,gZi=4,dZi=8,hZi=32,pZi=64,mZi=512,_Zi=209,ak={componentBody:12,fill:6,pad:2,region:11,text:5,track:4,via:3};function fZi(t){const e=c9(t),n=B4(e.get(\"LAYER\")),o=nIn(e.get(\"SHAPE\")),i=_c(e.get(\"XSIZE\")),r=_c(e.get(\"YSIZE\")),s=new LE;cK({defaultLayerId:n,fields:e,writer:s}),s.int32(_c(e.get(\"X\"))).int32(_c(e.get(\"Y\")));for(let a=0;a\u003c3;a++)s.int32(i).int32(r);return s.int32(_c(e.get(\"HOLESIZE\"))).uint8(o).uint8(o).uint8(o).float64(E4(e.get(\"ROTATION\"))).uint8(i3(e.get(\"PLATED\"))?1:0).uint8(0).uint8(0).int32(0).writeBytes(new Uint8Array(38)).uint8(0).float64(E4(e.get(\"HOLEROTATION\"))),[AK(e.get(\"NAME\")??\"\"),AK(\"\"),AK(\"\"),AK(\"\"),s.toUint8Array(),bZi(e)]}function IZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4(e.get(\"LAYER\")),fields:e,writer:n}),n.int32(_c(e.get(\"X1\"))).int32(_c(e.get(\"Y1\"))).int32(_c(e.get(\"X2\"))).int32(_c(e.get(\"Y2\"))).int32(_c(e.get(\"WIDTH\"))).uint16(0),[n.toUint8Array()]}function CZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4(e.get(\"LAYER\")),fields:e,writer:n}),n.int32(_c(e.get(\"X1\"))).int32(_c(e.get(\"Y1\"))).int32(_c(e.get(\"X2\"))).int32(_c(e.get(\"Y2\"))).float64(E4(e.get(\"ROTATION\"))),[n.toUint8Array()]}function yZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4(\"MULTILAYER\"),fields:e,writer:n}),n.int32(_c(e.get(\"X\"))).int32(_c(e.get(\"Y\"))).int32(_c(e.get(\"DIAMETER\"))).int32(_c(e.get(\"HOLESIZE\"))).uint8(B4(e.get(\"STARTLAYER\"),1)).uint8(B4(e.get(\"ENDLAYER\")??e.get(\"STOPLAYER\"),32)).writeBytes(new Uint8Array(_Zi-n.length)),[n.toUint8Array()]}function xZi(t,e){const n=c9(t),o=iIn(n),i=new LE(137,137);return cK({defaultLayerId:B4(n.get(\"LAYER\")),fields:n,writer:i}),i.int32(_c(n.get(\"X\"))).int32(_c(n.get(\"Y\"))).int32(_c(n.get(\"HEIGHT\"))).uint16(E4(n.get(\"STROKEFONT\"))).float64(E4(n.get(\"ROTATION\"))).uint8(i3(n.get(\"MIRROR\"))?1:0).int32(_c(n.get(\"WIDTH\"))).uint8(i3(n.get(\"COMMENT\"))?1:0).uint8(i3(n.get(\"DESIGNATOR\"))?1:0).uint8(0).uint8(i3(n.get(\"USETTFONTS\"))?1:0).uint8(i3(n.get(\"BOLD\"))?1:0).uint8(i3(n.get(\"ITALIC\"))?1:0).writeBytes(eIn(n.get(\"FONTNAME\")??\"\",64)).uint8(i3(n.get(\"INVERTED\"))?1:0).int32(_c(n.get(\"MARGINBORDERWIDTH\"))).uint32(e).writeBytes(new Uint8Array(4)).uint8(i3(n.get(\"INVERTEDRECT\"))?1:0).int32(_c(n.get(\"TEXTBOXWIDTH\"))).int32(_c(n.get(\"TEXTBOXHEIGHT\"))).uint8(E4(n.get(\"JUSTIFICATION\"))).int32(_c(n.get(\"TEXTOFFSET\"))),[i.toUint8Array(),AK(rZi(o))]}function EZi(t){const e=new LE;for(const[n,o]of t.entries()){const i=eIn(iIn(c9(o)));e.uint32(n).uint32(i.byteLength),i.byteLength\u003e2\u0026\u0026e.writeBytes(i)}return e.toUint8Array()}function iIn(t){const e=t.get(\"WIDESTRING\");return e===void 0?t.get(\"TEXT\")??\"\":N1n(e)}function Ak(t,e){const n=new LE;for(const o of e){n.uint8(t);for(const i of o)n.uint32LengthPrefixedBytes(i)}return n.toUint8Array()}function cK({defaultLayerId:t,fields:e,writer:n}){n.uint8(B4(e.get(\"LAYER\"),t)).uint16(BZi(e)).uint16(S1e(e.get(\"NET\"))).uint16(S1e(e.get(\"POLYGON\"))).uint16(S1e(e.get(\"COMPONENT\"))).uint16(oIn).uint16(oIn)}function BZi(t){let e=dZi;return i3(t.get(\"LOCKED\"))||(e|=gZi),i3(t.get(\"TENTEDTOP\"))\u0026\u0026(e|=hZi),i3(t.get(\"TENTEDBOTTOM\"))\u0026\u0026(e|=pZi),i3(t.get(\"KEEPOUT\"))\u0026\u0026(e|=mZi),e}function bZi(t){const e=t.get(\"HOLESHAPE\")?.toUpperCase();if(e!==\"SLOT\"\u0026\u0026e!==\"SQUARE\")return new Uint8Array;const n=new Uint8Array(596),o=new DataView(n.buffer);return o.setUint8(262,e===\"SLOT\"?2:1),o.setInt32(263,_c(t.get(\"HOLEWIDTH\")),!0),o.setFloat64(267,E4(t.get(\"HOLEROTATION\")),!0),n}function rIn({fields:t,propertyBytes:e}){const n=SZi(t),o=QZi(t),i=new LE;cK({defaultLayerId:B4(t.get(\"LAYER\")),fields:t,writer:i}),i.uint8(0).uint16(o).uint16(0).uint32(e.byteLength).writeBytes(e).uint32(n-1);for(let r=0;r\u003cn;r++)vZi({fields:t,vertexIndex:r,writer:i});for(let r=0;r\u003co;r++)wZi({fields:t,holeIndex:r,writer:i});return[i.toUint8Array()]}function SZi(t){const e=[...t.keys()].flatMap(o=\u003e{const i=/^VX(\\d+)$/u.exec(o);return i?.[1]===void 0?[]:[Number(i[1])]}),n=Math.max(...e,-1)+1;if(n\u003c4)throw new Yg(\"Altium contours require an explicitly closed outline\");for(let o=0;o\u003cn;o++)if(!t.has(`VX${o}`)||!t.has(`VY${o}`))throw new Yg(`Altium contour outline is missing vertex ${o}`);if(_c(t.get(\"VX0\"))!==_c(t.get(`VX${n-1}`))||_c(t.get(\"VY0\"))!==_c(t.get(`VY${n-1}`)))throw new Yg(\"Altium contour outline must repeat its first vertex\");return n}function QZi(t){const e=E4(t.get(\"HOLECOUNT\"));if(!Number.isInteger(e)||e\u003c0||e\u003e65535)throw new Yg(`Invalid Altium contour hole count: ${e}`);return e}function vZi({fields:t,vertexIndex:e,writer:n}){const o=E4(t.get(`KIND${e}`));if(o!==0\u0026\u0026o!==1)throw new Yg(`Unsupported Altium contour vertex kind at index ${e}: ${o}`);n.uint8(o).int32(_c(t.get(`VX${e}`))).int32(_c(t.get(`VY${e}`))).int32(_c(t.get(`CX${e}`))).int32(_c(t.get(`CY${e}`))).int32(_c(t.get(`R${e}`))).float64(E4(t.get(`SA${e}`))).float64(E4(t.get(`EA${e}`)))}function wZi({fields:t,holeIndex:e,writer:n}){const o=E4(t.get(`HOLE${e}COUNT`));if(!Number.isInteger(o)||o\u003c3||o\u003e4294967295)throw new Yg(`Invalid Altium contour hole ${e} vertex count: ${o}`);n.uint32(o);for(let i=0;i\u003co;i++){const r=t.get(`HOLE${e}VX${i}`),s=t.get(`HOLE${e}VY${i}`);if(r===void 0||s===void 0)throw new Yg(`Altium contour hole ${e} is missing vertex ${i}`);n.float64(_c(r)).float64(_c(s))}}var PZi=/^(?:KIND|VX|VY|CX|CY|R|SA|EA)\\d+$|^HOLE\\d+(?:COUNT|V[XY]\\d+)$/u,MZi=new Set([\"COMPONENT\",\"HOLECOUNT\",\"KEEPOUT\",\"LAYER\",\"LOCKED\",\"NET\",\"POLYGON\",\"RECORD\",\"SOURCESTREAM\",\"TEARDROP\"]);function DZi(t){const e=c9(t),n=[...e.entries()].filter(([o])=\u003e!MZi.has(o)\u0026\u0026!PZi.test(o)).map(([o,i])=\u003e`|${o}=${i}`).join(\"\");return rIn({fields:e,propertyBytes:rM(n).subarray(1)})}var NZi=65535;function RZi(t){const e=c9(t);return rIn({fields:e,propertyBytes:TZi(e)})}function TZi(t){const e=t.get(\"LAYER\")??\"TOP\",n=S1e(t.get(\"POLYGON\")),o=kZi(t.get(\"REGIONKIND\")),i=[`V7_LAYER=${e}`,\"NAME= \",`KIND=${o}`,`SUBPOLYINDEX=${n===NZi?-1:n}`,\"UNIONINDEX=0\",\"ARCRESOLUTION=0.5mil\",\"ISSHAPEBASED=FALSE\",\"CAVITYHEIGHT=0mil\"].join(\"|\");return rM(`|${i}`).subarray(1)}function kZi(t){return t?.toUpperCase()===\"POLYGON_CUTOUT\"?1:0}var FZi=[\"Arcs6\",\"Regions6\",\"ComponentBodies6\",\"Classes6\",\"DifferentialPairs6\",\"Connections6\"];function LZi(t){const e=Z1n(t);if(E1e(e).boardGeometry.outline.vertices.length\u003c3)throw new Yg(\"Cannot create a binary PcbDoc without a board outline\");const o=HZi(e),i=$1n();YZi(i),o3({compoundFile:i,content:b1e(o.Board),name:\"Board6\",recordCount:o.Board.length}),o3({compoundFile:i,content:b1e(o.Net),name:\"Nets6\",recordCount:o.Net.length}),o3({compoundFile:i,content:b1e(o.Component),name:\"Components6\",recordCount:o.Component.length}),o3({compoundFile:i,content:b1e(o.Polygon),name:\"Polygons6\",recordCount:o.Polygon.length}),o3({compoundFile:i,content:oZi(o.Dimension),name:\"Dimensions6\",recordCount:o.Dimension.length}),o3({compoundFile:i,content:Ak(ak.pad,o.Pad.map(fZi)),name:\"Pads6\",recordCount:o.Pad.length}),o3({compoundFile:i,content:Ak(ak.via,o.Via.map(yZi)),name:\"Vias6\",recordCount:o.Via.length}),o3({compoundFile:i,content:Ak(ak.track,o.Track.map(IZi)),name:\"Tracks6\",recordCount:o.Track.length}),o3({compoundFile:i,content:Ak(ak.fill,o.Fill.map(CZi)),name:\"Fills6\",recordCount:o.Fill.length}),o3({compoundFile:i,content:Ak(ak.region,o.Region.map(RZi)),name:\"ShapeBasedRegions6\",recordCount:o.Region.length}),o3({compoundFile:i,content:Ak(ak.componentBody,o.ComponentBody.map(DZi)),name:\"ShapeBasedComponentBodies6\",recordCount:o.ComponentBody.length}),o3({compoundFile:i,content:Ak(ak.text,o.Text.map(xZi)),name:\"Texts6\",recordCount:o.Text.length}),o3({compoundFile:i,content:EZi(o.Text),name:\"WideStrings6\",recordCount:o.Text.length});for(const r of FZi)o3({compoundFile:i,content:new Uint8Array,name:r,recordCount:0});return q1n(i)}function HZi(t){const e={Board:[],Component:[],ComponentBody:[],Dimension:[],Fill:[],Net:[],Pad:[],Polygon:[],Region:[],Text:[],Track:[],Via:[]};for(const n of t.split(/\\r?\\n|\\r/u).filter(Boolean)){const o=nZi(n);if(!OZi(o))throw new Yg(`Unsupported PCB record kind for binary serialization: ${JSON.stringify(o||\"missing RECORD\")}`);GZi(o)\u0026\u0026cZi(n,o),e[o].push(n)}return e}function OZi(t){return[\"Board\",\"Component\",\"ComponentBody\",\"Dimension\",\"Fill\",\"Net\",\"Pad\",\"Polygon\",\"Region\",\"Text\",\"Track\",\"Via\"].includes(t)}function GZi(t){return[\"ComponentBody\",\"Fill\",\"Pad\",\"Region\",\"Text\",\"Track\",\"Via\"].includes(t)}function YZi(t){const e=new LE().uint32(19);for(const i of\"PCB 5.0 Bi\")e.uint16(i.charCodeAt(0));rk({compoundFile:t,content:e.toUint8Array(),path:\"/FileHeader\"});const n=\"PCB 6.0 Binary File\",o=new LE().uint32(n.length).writeBytes(AK(n)).float64(5.01);rk({compoundFile:t,content:o.toUint8Array(),path:\"/FileHeaderSix\"})}function UZi(t,e={}){const o=Z1n(t).split(/\\r?\\n|\\r/u).filter(Boolean).filter(a=\u003e!a.startsWith(\"|HEADER=\")),i=\"Protel for Windows - Schematic Capture Binary File Version 5.0\",r=[Q1e(rM(`|HEADER=${i}|WEIGHT=${o.length}|MINORVERSION=0|UNIQUEID=ALTIUMTS`)),...o.map(a=\u003eQ1e(rM(a)))],s=$1n();return rk({compoundFile:s,content:aK(r),path:\"/FileHeader\"}),rk({compoundFile:s,content:KZi(e.embeddedImages??[]),path:\"/Storage\"}),rk({compoundFile:s,content:Q1e(rM(`|HEADER=${i}`)),path:\"/Additional\"}),q1n(s)}function KZi(t){const e=Q1e(rM(\"|HEADER=Icon storage\")),n=t.map(({compressedBytes:o,name:i})=\u003e{const r=c1e(i,\"windows-1252\");if(r.byteLength===0||r.byteLength\u003e255)throw new RangeError(\"Embedded schematic image names must be 1 to 255 Windows-1252 bytes\");if(o.byteLength===0)throw new RangeError(\"Embedded schematic image compressed bytes must not be empty\");const s=aK([Uint8Array.of(208,r.byteLength),r,B1e(o.byteLength),o]);if(s.byteLength\u003e16777215)throw new RangeError(\"Embedded schematic image storage entries must fit in 24 bits\");return aK([B1e(s.byteLength),s])});return aK([e,...n])}function Q1e(t){return aK([B1e(t.byteLength),t])}[...Array.from({length:30},(t,e)=\u003e`MID${e+1}`),...Array.from({length:30},(t,e)=\u003e`MIDLAYER${e+1}`)],[...Array.from({length:16},(t,e)=\u003e`PLANE${e+1}`),...Array.from({length:16},(t,e)=\u003e`INTERNALPLANE${e+1}`)],[...Array.from({length:32},(t,e)=\u003e`MECHANICAL${e+1}`)];const sg=39.3700787402,VZi=100,zZi=80,fr=(t,e=0)=\u003etypeof t==\"number\"\u0026\u0026Number.isFinite(t)?t:e,Tu=(t,e)=\u003e{const n=fr(t,e);return n\u003e0?n:e},ti=(t,e=\"\")=\u003etypeof t==\"string\"?t:e,HE=t=\u003et!==null\u0026\u0026typeof t==\"object\"\u0026\u0026!Array.isArray(t),AA=t=\u003e{if(HE(t)\u0026\u0026!(typeof t.x!=\"number\"||!Number.isFinite(t.x)||typeof t.y!=\"number\"||!Number.isFinite(t.y)))return{x:t.x,y:t.y}},uu=t=\u003e{const e=typeof t==\"number\"\u0026\u0026Number.isFinite(t)?String(t):ti(t);return j1n(e).trim()},JZi=t=\u003e{const e=t.replace(/[^a-z0-9._-]+/giu,\"-\").replace(/^[.-]+|[.-]+$/gu,\"\").slice(0,80);return e?/^(?:aux|con|nul|prn|com[1-9]|lpt[1-9])$/iu.test(e)?`board-${e}`:e:\"board\"},Sp=t=\u003e{const e=Math.round(t*1e4)/1e4;return Number.isInteger(e)?String(e):e.toFixed(4)},Xi=t=\u003e`${Sp(t)}mil`,Dd=(t,e)=\u003et.filter(n=\u003en.type===e),r3=(t,e)=\u003eMath.abs(t.x-e.x)\u003c1e-9\u0026\u0026Math.abs(t.y-e.y)\u003c1e-9,v1e=t=\u003e{let e=0;for(const[n,o]of t.entries()){const i=t[(n+1)%t.length];i\u0026\u0026(e+=o.x*i.y-i.x*o.y)}return Math.abs(e/2)};class w1e{constructor(e,n){this.maxIterations=1e3,this.iteration=0,this.finished=!1,this.input=e,this.context=n}step(){if(this.iteration++,this.iteration\u003ethis.maxIterations)throw new Error(`${this.constructor.name} exceeded ${this.maxIterations} iterations`);this._step()}runUntilFinished(){for(;!this.finished;)this.step()}}function sM(t){const e=(t%360+360)%360;return e===0?0:e}function WZi(t){const e=Math.min(...t.map(i=\u003ei.x)),n=Math.min(...t.map(i=\u003ei.y)),o=Ad(pA(1e3,1e3),dC(sg,sg),pA(-e,-n));return i=\u003eBn(o,i)}function jZi({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=XZi(t),i=[];for(const r of Dd(t,\"cad_component\")){const s=n.get(ti(r.pcb_component_id));if(s===void 0)continue;const a=sIn(r.position),A=sIn(r.size);if(!a||!A)continue;$Zi(A,ti(r.cad_component_id));const c=ZZi(r),l=qZi({position:a,rotationDegrees:eer(r),size:A}).map(e),u=ter({boardThicknessMm:o,layer:c,positionZMm:a.z,sizeZMm:A.z});i.push([\"|RECORD=ComponentBody\",`LAYER=${c===\"bottom\"?\"MECHANICAL14\":\"MECHANICAL13\"}`,\"LOCKED=FALSE\",\"KEEPOUT=FALSE\",\"NET=65535\",\"POLYGON=65535\",`COMPONENT=${s}`,\"TEARDROP=FALSE\",\"HOLECOUNT=0\",\"ISSHAPEBASED=TRUE\",\"KIND=0\",`STANDOFFHEIGHT=${Xi(u*sg)}`,`OVERALLHEIGHT=${Xi(A.z*sg)}`,`BODYOPACITY3D=${r.show_as_translucent_model===!0?\"0.5\":\"1\"}`,`V7_LAYER=${c===\"bottom\"?\"14\":\"13\"}`,...l.flatMap((g,h)=\u003e[`KIND${h}=0`,`VX${h}=${Xi(g.x)}`,`VY${h}=${Xi(g.y)}`])].join(\"|\"))}return i}function sIn(t){if(!HE(t))return;const e=AA(t);if(!(!e||typeof t.z!=\"number\"||!Number.isFinite(t.z)))return{...e,z:t.z}}function $Zi(t,e){if(!(t.x\u003e0\u0026\u0026t.y\u003e0\u0026\u0026t.z\u003e=0))throw new Error(`CAD component ${JSON.stringify(e)} has an invalid body size`)}function qZi({position:t,rotationDegrees:e,size:n}){const o=Ad(pA(t.x,t.y),vQ(e*Math.PI/180)),i=n.x/2,r=n.y/2;return[{x:-i,y:-r},{x:i,y:-r},{x:i,y:r},{x:-i,y:r},{x:-i,y:-r}].map(a=\u003eBn(o,a))}function XZi(t){const e=Dd(t,\"pcb_board\")[0];return Math.max(fr(e?.thickness),0)}function ZZi(t){return ti(t.layer).toLowerCase()===\"bottom\"?\"bottom\":\"top\"}function eer(t){return HE(t.rotation)?fr(t.rotation.z):0}function ter({boardThicknessMm:t,layer:e,positionZMm:n,sizeZMm:o}){const i=e===\"bottom\"?-t/2:t/2;return(e===\"bottom\"?i-n:n-i)-o/2}const ner=Math.PI/24;function oer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n,netEntries:o}){const i=new Map(o.flatMap(l=\u003el.sourceNetIds.map(u=\u003e[u,l]))),r=t.flatMap(l=\u003el.type!==\"pcb_copper_pour\"?[]:[{copperPour:ixe.parse(l),polygonId:ier(l.altium_polygon_id),polygonRole:rer(l.altium_polygon_role),polygonCutoutCount:Math.max(0,Math.trunc(fr(l.altium_polygon_cutout_count))),pcbComponentId:ti(l.pcb_component_id)}]),s=[],a=new Set(r.flatMap(({polygonId:l})=\u003el===void 0?[]:[l]));let A=0;const c=()=\u003e{for(;a.has(A);)A++;const l=A;return a.add(l),A++,l};for(const l of r){const{copperPour:u,pcbComponentId:g,polygonCutoutCount:h,polygonRole:d}=l,p=l.polygonId??c(),m=ser(u),_={outerRing:m.outerRing.map(e),innerRings:m.innerRings.map(S=\u003eS.map(e))},f=cer(u.layer),I=Math.min(h,_.innerRings.length),C=_.innerRings.length-I,y=_.innerRings.slice(0,C),x=_.innerRings.slice(C),E=u.source_net_id?i.get(u.source_net_id):void 0,B=n.get(g);if(B!==void 0){s.push(Wee({altiumComponentIndex:B,innerRings:_.innerRings,layer:f,outerRing:_.outerRing})),!u.covered_with_solder_mask\u0026\u0026cIn(f)\u0026\u0026s.push(Wee({altiumComponentIndex:B,innerRings:_.innerRings,layer:f===\"TOP\"?\"TOPSOLDER\":\"BOTTOMSOLDER\",outerRing:_.outerRing}));continue}d!==\"region\"\u0026\u0026s.push(ler({layer:f,net:E,outerRing:_.outerRing,polygonIndex:p})),d!==\"outline\"\u0026\u0026s.push(Wee({innerRings:y,layer:f,net:E,outerRing:_.outerRing,polygonIndex:p})),s.push(...x.map(S=\u003eWee({innerRings:[],layer:f,net:E,outerRing:Jee(S),polygonIndex:p,regionKind:\"POLYGON_CUTOUT\"}))),d!==\"outline\"\u0026\u0026!u.covered_with_solder_mask\u0026\u0026cIn(f)\u0026\u0026s.push(Wee({innerRings:_.innerRings,layer:f===\"TOP\"?\"TOPSOLDER\":\"BOTTOMSOLDER\",outerRing:_.outerRing}))}return s}function ier(t){return typeof t==\"number\"\u0026\u0026Number.isInteger(t)\u0026\u0026t\u003e=0\u0026\u0026t\u003c65535?t:void 0}function rer(t){return t===\"outline\"||t===\"region\"?t:void 0}function ser(t){return t.shape===\"rect\"?{innerRings:[],outerRing:Jee(aer(t))}:t.shape===\"polygon\"?{innerRings:[],outerRing:Jee(t.points)}:{innerRings:t.brep_shape.inner_rings.map(e=\u003eAIn(aIn(e.vertices))),outerRing:Jee(aIn(t.brep_shape.outer_ring.vertices))}}function aer(t){const e=Ad(pA(t.center.x,t.center.y),vQ((t.rotation??0)*Math.PI/180)),n=t.width/2,o=t.height/2;return[{x:-n,y:-o},{x:n,y:-o},{x:n,y:o},{x:-n,y:o}].map(i=\u003eBn(e,i))}function aIn(t){const e=AIn(t);if(e.length\u003c3)throw new Error(\"A PCB copper pour ring requires at least three vertices\");const n=[];for(const[o,i]of e.entries()){const r=e[(o+1)%e.length];if(r){XXe(n,i);for(const s of Aer({bulge:i.bulge??0,end:r,start:i}))XXe(n,s)}}return Jee(n)}function Aer({bulge:t,end:e,start:n}){if(Math.abs(t)\u003c1e-12||r3(n,e))return[e];const o=e.x-n.x,i=e.y-n.y,r=(1-t*t)/(4*t),s={x:(n.x+e.x)/2-i*r,y:(n.y+e.y)/2+o*r},a=Math.hypot(n.x-s.x,n.y-s.y),A=Math.atan2(n.y-s.y,n.x-s.x),c=4*Math.atan(t),l=Math.max(2,Math.ceil(Math.abs(c)/ner));return Array.from({length:l},(u,g)=\u003e{const h=A+c*(g+1)/l;return{x:s.x+a*Math.cos(h),y:s.y+a*Math.sin(h)}})}function Jee(t){const e=[];for(const o of t)XXe(e,o);const n=e[0];if(n\u0026\u0026!r3(n,e.at(-1)??n)\u0026\u0026e.push(n),e.length\u003c4)throw new Error(\"A PCB copper pour ring requires at least three vertices\");return e}function AIn(t){const e=[...t],n=e[0],o=e.at(-1);return n\u0026\u0026o\u0026\u0026r3(n,o)\u0026\u0026e.pop(),e}function XXe(t,e){const n=t.at(-1);(!n||!r3(n,e))\u0026\u0026t.push(e)}function cer(t){if(t===\"top\")return\"TOP\";if(t===\"bottom\")return\"BOTTOM\";const e=/^inner(\\d+)$/u.exec(t);if(!e?.[1])throw new Error(`Unsupported PCB copper pour layer: ${t}`);return`MID-LAYER${Number(e[1])}`}function cIn(t){return t===\"TOP\"||t===\"BOTTOM\"}function ler({layer:t,net:e,outerRing:n,polygonIndex:o}){return[\"|RECORD=Polygon\",`NET=${e?.index??65535}`,`ID=${o}`,\"POLYGONTYPE=Polygon\",\"POUROVERSTYLE=1\",\"HATCHSTYLE=Solid\",\"SELECTION=FALSE\",`LAYER=${t}`,\"LOCKED=FALSE\",...lIn(n)].join(\"|\")}function Wee({altiumComponentIndex:t,innerRings:e,layer:n,net:o,outerRing:i,polygonIndex:r,regionKind:s=\"COPPER\"}){return[\"|RECORD=Region\",...t===void 0?[]:[`COMPONENT=${t}`],...o?[`NET=${o.index}`]:[],...r===void 0?[]:[`POLYGON=${r}`],`LAYER=${n}`,\"LOCKED=FALSE\",\"KEEPOUT=FALSE\",\"TEARDROP=FALSE\",`REGIONKIND=${s}`,`HOLECOUNT=${e.length}`,...lIn(i),...e.flatMap(uer)].join(\"|\")}function lIn(t){return t.flatMap((e,n)=\u003e[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function uer(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=\u003e[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function lK({altiumComponentIndex:t,circuitPoints:e,circuitToAltiumPcbPoint:n,closePath:o=!1,isKeepout:i=!1,layer:r,strokeWidthMm:s}){const a=o?tZe(e):[...e],A=[];for(let c=1;c\u003ca.length;c++){const l=a[c-1],u=a[c];if(!l||!u)continue;const g=n(l),h=n(u);r3(g,h)||A.push([\"|RECORD=Track\",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,...i?[\"KEEPOUT=TRUE\"]:[],\"LOCKED=FALSE\",`X1=${Xi(g.x)}`,`Y1=${Xi(g.y)}`,`X2=${Xi(h.x)}`,`Y2=${Xi(h.y)}`,`WIDTH=${Xi(s*sg)}`].join(\"|\"))}return A}function uIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,heightMm:o,isKeepout:i=!1,layer:r,rotationDegrees:s=0,widthMm:a}){const A=n({x:e.x-a/2,y:e.y-o/2}),c=n({x:e.x+a/2,y:e.y+o/2});return[\"|RECORD=Fill\",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,`KEEPOUT=${i?\"TRUE\":\"FALSE\"}`,\"LOCKED=FALSE\",`X1=${Xi(A.x)}`,`Y1=${Xi(A.y)}`,`X2=${Xi(c.x)}`,`Y2=${Xi(c.y)}`,`ROTATION=${Sp(sM(s))}`].join(\"|\")}function ZXe({altiumComponentIndex:t,circuitPoints:e,circuitToAltiumPcbPoint:n,innerRings:o=[],isKeepout:i=!1,layer:r}){const s=tZe(e).map(n),a=o.map(A=\u003etZe(A).map(n));if(s.length\u003c4)throw new Error(\"An Altium PCB region requires at least three vertices\");return[\"|RECORD=Region\",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,\"LOCKED=FALSE\",`KEEPOUT=${i?\"TRUE\":\"FALSE\"}`,\"TEARDROP=FALSE\",\"REGIONKIND=COPPER\",`HOLECOUNT=${a.length}`,...ger(s),...a.flatMap(der)].join(\"|\")}function ger(t){return t.flatMap((e,n)=\u003e[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function der(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=\u003e[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function eZe({center:t,radiusMm:e}){return Array.from({length:48},(o,i)=\u003e{const r=i*Math.PI*2/48;return{x:t.x+Math.cos(r)*e,y:t.y+Math.sin(r)*e}})}function jee({center:t,cornerRadiusMm:e,heightMm:n,rotationDegrees:o=0,widthMm:i}){const r=i/2,s=n/2,a=Math.min(Math.max(e,0),r,s),A=a===0?[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}]:her({halfHeightMm:s,halfWidthMm:r,radiusMm:a}),c=Ad(pA(t.x,t.y),vQ(o*Math.PI/180));return A.map(l=\u003eBn(c,l))}function her({halfHeightMm:t,halfWidthMm:e,radiusMm:n}){const o=[{x:e-n,y:t-n,start:0},{x:-e+n,y:t-n,start:90},{x:-e+n,y:-t+n,start:180},{x:e-n,y:-t+n,start:270}],i=8;return o.flatMap(r=\u003eArray.from({length:i},(s,a)=\u003e{const c=(r.start+a*90/i)*Math.PI/180;return{x:r.x+Math.cos(c)*n,y:r.y+Math.sin(c)*n}}))}function tZe(t){const e=[...t],n=e[0],o=e.at(-1);return n\u0026\u0026o\u0026\u0026!r3(n,o)\u0026\u0026e.push(n),e}const per=.05;function mer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){const r=_er(i);if(!r)continue;const s=n.get(r.pcbComponentId);if(s===void 0)throw new Error(`PCB courtyard references missing component ${r.pcbComponentId}`);o.push(...lK({altiumComponentIndex:s,circuitPoints:r.points,circuitToAltiumPcbPoint:e,closePath:!0,layer:fer(r.layer),strokeWidthMm:per}))}return o}function _er(t){if(t.type===\"pcb_courtyard_outline\"){const e=sxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:e.outline}}if(t.type===\"pcb_courtyard_polygon\"){const e=axe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:e.points}}if(t.type===\"pcb_courtyard_rect\"){const e=rxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:jee({center:e.center,cornerRadiusMm:0,heightMm:e.height,rotationDegrees:e.ccw_rotation,widthMm:e.width})}}if(t.type===\"pcb_courtyard_circle\"){const e=Axe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:eZe({center:e.center,radiusMm:e.radius})}}if(t.type===\"pcb_courtyard_pill\"){const e=cxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:jee({center:e.center,cornerRadiusMm:e.radius,heightMm:e.height,widthMm:e.width})}}}function fer(t){return t.toLowerCase()===\"bottom\"?\"MECHANICAL16\":\"MECHANICAL15\"}const OE=1e-9,Ier=4,gIn=8;function Cer({circuitJson:t,circuitToAltiumPcbPoint:e}){const n=[];for(const o of t){if(o.type!==\"pcb_cutout\")continue;const i=Z2e.parse(o);for(const r of yer(i))n.push(ber({circuitToAltiumPcbPoint:e,innerRings:r.innerRings??[],outerRing:r.outerRing}))}return n}function yer(t){return t.shape===\"rect\"?[{outerRing:jee({center:t.center,cornerRadiusMm:t.corner_radius??0,heightMm:t.height,rotationDegrees:t.rotation??0,widthMm:t.width})}]:t.shape===\"circle\"?[{outerRing:eZe({center:t.center,radiusMm:t.radius})}]:t.shape===\"polygon\"?[{outerRing:t.points}]:xer(t)}function xer(t){const e=nZe(t.route),n=e[0],o=e.at(-1),i=e.length\u003e=3\u0026\u0026n!==void 0\u0026\u0026o!==void 0\u0026\u0026r3(n,o);if(i\u0026\u0026e.pop(),e.length===0)return[];const r=t.slot_width/2,s=Math.min(Math.max(t.slot_corner_radius??r,0),r);if(e.length===1){const A=e[0];return A?[{outerRing:jee({center:A,cornerRadiusMm:s,heightMm:t.slot_width,widthMm:t.slot_width})}]:[]}if(t.slot_length!==void 0\u0026\u0026t.slot_length\u003eOE\u0026\u0026t.space_between_slots!==void 0\u0026\u0026t.space_between_slots\u003eOE){const A=i?[...e,e[0]]:e;return Ber({dashLength:t.slot_length,gapLength:t.space_between_slots,points:A}).flatMap(c=\u003edIn({cornerRadiusMm:s,halfWidthMm:r,points:c}))}return i?Eer({halfWidthMm:r,points:e}):dIn({cornerRadiusMm:s,halfWidthMm:r,points:e})}function dIn({cornerRadiusMm:t,halfWidthMm:e,points:n}){const o=nZe(n);if(o.length\u003c2||e\u003c=OE)return[];const i=o[0],r=o.at(-1),s=uK(i,o[1]),a=uK(o.at(-2),r);if(!i||!r||!s||!a)return[];const A=hIn(o,e),c=hIn(o,-e),l=s3(A[0],pm(s,-(e-t))),u=s3(A.at(-1),pm(a,e-t)),g=s3(c.at(-1),pm(a,e-t)),h=s3(c[0],pm(s,-(e-t)));A[0]=l,A[A.length-1]=u,c[0]=h,c[c.length-1]=g;const d=[...A];return _In({center:r,cornerRadiusMm:t,halfWidthMm:e,normal:gK(a),outward:a,points:d}),d.push(...c.slice(0,-1).reverse()),_In({center:i,cornerRadiusMm:t,halfWidthMm:e,normal:pm(gK(s),-1),outward:pm(s,-1),points:d}),[{outerRing:d}]}function Eer({halfWidthMm:t,points:e}){if(e.length\u003c3||t\u003c=OE)return[];const n=pIn(e,t),o=pIn(e,-t);if(n.length\u003c3||o.length\u003c3)return[];const[i,r]=v1e(n)\u003e=v1e(o)?[n,o]:[o,n];return[{innerRings:[r],outerRing:i}]}function hIn(t,e){const n=uK(t[0],t[1]),o=uK(t.at(-2),t.at(-1)),i=t[0],r=t.at(-1);if(!i||!r||!n||!o)return[];const s=[s3(i,pm(gK(n),e))];for(let a=1;a\u003ct.length-1;a++)mIn({boundary:s,index:a,offset:e,points:t});return s.push(s3(r,pm(gK(o),e))),s}function pIn(t,e){const n=[];for(const[o]of t.entries())mIn({boundary:n,index:o,offset:e,points:t,wrap:!0});return n}function mIn({boundary:t,index:e,offset:n,points:o,wrap:i=!1}){const r=o[e],s=o[i?(e-1+o.length)%o.length:e-1],a=o[i?(e+1)%o.length:e+1],A=uK(s,r),c=uK(r,a);if(!r||!A||!c)return;const l=s3(r,pm(gK(A),n)),u=s3(r,pm(gK(c),n)),g=ver({firstDirection:A,firstPoint:l,secondDirection:c,secondPoint:u});if(g\u0026\u0026Math.hypot(g.x-r.x,g.y-r.y)\u003c=Math.abs(n)*Ier){aM(t,g);return}aM(t,l),aM(t,u)}function _In({center:t,cornerRadiusMm:e,halfWidthMm:n,normal:o,outward:i,points:r}){if(e\u003c=OE){aM(r,s3(t,pm(i,n),pm(o,n))),aM(r,s3(t,pm(i,n),pm(o,-n)));return}const s=n-e,a=s3(t,pm(i,s),pm(o,s));fIn({center:a,endAngleRadians:0,normal:o,outward:i,points:r,radius:e,startAngleRadians:Math.PI/2});const A=s3(t,pm(i,s),pm(o,-s));fIn({center:A,endAngleRadians:-Math.PI/2,normal:o,outward:i,points:r,radius:e,startAngleRadians:0})}function fIn({center:t,endAngleRadians:e,normal:n,outward:o,points:i,radius:r,startAngleRadians:s}){for(let a=1;a\u003c=gIn;a++){const A=s+(e-s)*a/gIn;aM(i,s3(t,pm(o,Math.cos(A)*r),pm(n,Math.sin(A)*r)))}}function Ber({dashLength:t,gapLength:e,points:n}){const o=[0];for(let s=1;s\u003cn.length;s++){const a=n[s-1],A=n[s];!a||!A||o.push((o.at(-1)??0)+Math.hypot(A.x-a.x,A.y-a.y))}const i=o.at(-1)??0,r=[];for(let s=0;s\u003ci-OE;s+=t+e){const a=Math.min(s+t,i),A=[],c=IIn({cumulativeLengths:o,distance:s,points:n}),l=IIn({cumulativeLengths:o,distance:a,points:n});if(!(!c||!l)){A.push(c);for(let u=1;u\u003cn.length-1;u++){const g=o[u],h=n[u];h\u0026\u0026g!==void 0\u0026\u0026g\u003es+OE\u0026\u0026g\u003ca-OE\u0026\u0026A.push(h)}aM(A,l),A.length\u003e=2\u0026\u0026r.push(A)}}return r}function IIn({cumulativeLengths:t,distance:e,points:n}){for(let o=1;o\u003ct.length;o++){const i=t[o-1],r=t[o],s=n[o-1],a=n[o];if(i===void 0||r===void 0||!s||!a||e\u003er+OE)continue;const A=r-i;if(A\u003c=OE)continue;const c=Math.min(Math.max((e-i)/A,0),1);return{x:s.x+(a.x-s.x)*c,y:s.y+(a.y-s.y)*c}}return n.at(-1)}function ber({circuitToAltiumPcbPoint:t,innerRings:e,outerRing:n}){const o=CIn(n).map(t),i=e.map(r=\u003eCIn(r).map(t));return[\"|RECORD=Region\",\"LAYER=MULTILAYER\",\"LOCKED=FALSE\",\"KEEPOUT=FALSE\",\"TEARDROP=FALSE\",\"ISBOARDCUTOUT=TRUE\",\"REGIONKIND=COPPER\",`HOLECOUNT=${i.length}`,...Ser(o),...i.flatMap(Qer)].join(\"|\")}function CIn(t){const e=nZe(t),n=e[0],o=e.at(-1);if(n\u0026\u0026o\u0026\u0026!r3(n,o)\u0026\u0026e.push(n),e.length\u003c4||v1e(e)\u003c=OE)throw new Error(\"A PCB board cutout requires at least three vertices\");return e}function Ser(t){return t.flatMap((e,n)=\u003e[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function Qer(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=\u003e[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function nZe(t){const e=[];for(const n of t)aM(e,n);return e}function aM(t,e){const n=t.at(-1);(!n||!r3(n,e))\u0026\u0026t.push(e)}function uK(t,e){if(!t||!e)return;const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!(i\u003c=OE))return{x:n/i,y:o/i}}function gK(t){return{x:-t.y,y:t.x}}function pm(t,e){return{x:t.x*e,y:t.y*e}}function s3(...t){return t.reduce((e,n)=\u003e({x:e.x+n.x,y:e.y+n.y}),{x:0,y:0})}function yIn(t,e){return t.x*e.y-t.y*e.x}function ver({firstDirection:t,firstPoint:e,secondDirection:n,secondPoint:o}){const i=yIn(t,n);if(Math.abs(i)\u003c=OE)return;const r={x:o.x-e.x,y:o.y-e.y},s=yIn(r,n)/i;return s3(e,pm(t,s))}function xIn({altiumComponentIndex:t,circuitToAltiumPcbPoint:e,dimension:n,layer:o}){const i=n.to.x-n.from.x,r=n.to.y-n.from.y;if(Math.hypot(i,r)===0)throw new Error(\"A PCB dimension requires distinct from and to points\");const a=wer({deltaX:i,deltaY:r,offsetDirection:n.offset_direction}),A=\"offset\"in n?n.offset:void 0,c=n.offset_distance??A??0,l={x:n.from.x+a.x*c,y:n.from.y+a.y*c},u={x:n.to.x+a.x*c,y:n.to.y+a.y*c},g=e(n.from),h=e(n.to),d=e(l),p=e(u),m={x:(d.x+p.x)/2,y:(d.y+p.y)/2},_=n.font_size,f=n.arrow_size;return[\"|RECORD=Dimension\",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${o}`,\"DIMENSIONKIND=0\",`TEXTFORMAT=${n.text?uu(n.text):\"\u003c\u003e\"}`,`HEIGHT=${Xi(Math.abs(c)*sg)}`,`LINEWIDTH=${Xi(Math.max(.05,_*.1)*sg)}`,`TEXTHEIGHT=${Xi(_*sg)}`,`TEXTLINEWIDTH=${Xi(Math.max(.05,_*.1)*sg)}`,\"TEXTPRECISION=3\",\"TEXTBOLD=FALSE\",\"ITALIC=FALSE\",`TEXTGAP=${Xi(_*.2*sg)}`,`ARROWSIZE=${Xi(f*sg)}`,\"TEXTPOSITION=Manual\",`X1=${Xi(d.x)}`,`Y1=${Xi(d.y)}`,\"REFERENCES_COUNT=2\",`REFERENCE0POINTX=${Xi(g.x)}`,`REFERENCE0POINTY=${Xi(g.y)}`,`REFERENCE1POINTX=${Xi(h.x)}`,`REFERENCE1POINTY=${Xi(h.y)}`,`TEXT1X=${Xi(m.x)}`,`TEXT1Y=${Xi(m.y)}`,\"TEXTDIMENSIONUNIT=Millimeters\",\"TEXTSUFFIX=mm\",`ANGLE=${Sp(Per({end:p,start:d}))}`].join(\"|\")}function wer({deltaX:t,deltaY:e,offsetDirection:n}){const o=n??{x:-e,y:t},i=Math.hypot(o.x,o.y);if(i===0)throw new Error(\"A PCB dimension offset direction cannot be zero\");return{x:o.x/i,y:o.y/i}}function Per({end:t,start:e}){return(Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI%360+360)%360}function oZe({altiumComponentIndex:t,circuitText:e,circuitToAltiumPcbPoint:n,layer:o}){const i=AA(e.anchor_position)??AA(e.center)??{x:0,y:0},r=n(i),s=ti(e.layer).toLowerCase()===\"bottom\",a=typeof e.is_mirrored==\"boolean\"?e.is_mirrored:e.is_mirrored_from_top_view,A=typeof a==\"boolean\"?a:s,c=Tu(e.font_size,1);return[\"|RECORD=Text\",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${o}`,`X=${Xi(r.x)}`,`Y=${Xi(r.y)}`,`ROTATION=${Sp(sM(fr(e.ccw_rotation)))}`,`MIRROR=${A?\"TRUE\":\"FALSE\"}`,`HEIGHT=${Xi(c*sg)}`,`WIDTH=${Xi(Math.max(.05,c*.1)*sg)}`,\"USETTFONTS=TRUE\",\"FONTNAME=Arial\",`JUSTIFICATION=${Mer(e.anchor_alignment)}`,`WIDESTRING=${Der(ti(e.text))}`].join(\"|\")}function Mer(t){switch(t){case\"top_left\":return 1;case\"center_left\":return 2;case\"bottom_left\":return 3;case\"top_center\":return 4;case\"center\":return 5;case\"bottom_center\":return 6;case\"top_right\":return 7;case\"center_right\":return 8;case\"bottom_right\":return 9;default:return 5}}function Der(t){const e=[];for(const n of t){const o=n.codePointAt(0);o!==void 0\u0026\u0026e.push(o)}return e.join(\",\")}function Ner({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){if(!Rer(i))continue;const r=Ter({componentIndex:n,element:i});if(i.type===\"pcb_fabrication_note_path\"){const s=K2e.parse(i);o.push(...lK({altiumComponentIndex:r,circuitPoints:s.route,circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type===\"pcb_note_path\"){const s=j2e.parse(i);o.push(...lK({altiumComponentIndex:r,circuitPoints:s.route,circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type===\"pcb_note_line\"){const s=$2e.parse(i);if(s.is_dashed)throw new Error(\"Altium PCB note lines do not preserve dashed strokes\");o.push(...lK({altiumComponentIndex:r,circuitPoints:[{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}],circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type===\"pcb_fabrication_note_rect\"){const s=V2e.parse(i);o.push(...EIn({altiumComponentIndex:r,center:s.center,circuitToAltiumPcbPoint:e,cornerRadiusMm:s.corner_radius??0,hasStroke:s.has_stroke!==!1,heightMm:s.height,isFilled:s.is_filled===!0,isStrokeDashed:s.is_stroke_dashed===!0,layer:HS(s.layer),strokeWidthMm:s.stroke_width,widthMm:s.width}))}else if(i.type===\"pcb_note_rect\"){const s=W2e.parse(i);o.push(...EIn({altiumComponentIndex:r,center:s.center,circuitToAltiumPcbPoint:e,cornerRadiusMm:s.corner_radius??0,hasStroke:s.has_stroke!==!1,heightMm:s.height,isFilled:s.is_filled===!0,isStrokeDashed:s.is_stroke_dashed===!0,layer:HS(s.layer),strokeWidthMm:s.stroke_width,widthMm:s.width}))}else if(i.type===\"pcb_fabrication_note_text\"){const s=U2e.parse(i);o.push(oZe({altiumComponentIndex:r,circuitText:i,circuitToAltiumPcbPoint:e,layer:HS(s.layer)}))}else if(i.type===\"pcb_note_text\"){const s=J2e.parse(i);o.push(oZe({altiumComponentIndex:r,circuitText:i,circuitToAltiumPcbPoint:e,layer:HS(s.layer)}))}else if(i.type===\"pcb_fabrication_note_dimension\"){const s=z2e.parse(i);o.push(xIn({altiumComponentIndex:r,circuitToAltiumPcbPoint:e,dimension:s,layer:HS(s.layer)}))}else if(i.type===\"pcb_note_dimension\"){const s=q2e.parse(i);o.push(xIn({altiumComponentIndex:r,circuitToAltiumPcbPoint:e,dimension:s,layer:HS(s.layer)}))}}return o}function Rer(t){return[\"pcb_fabrication_note_dimension\",\"pcb_fabrication_note_path\",\"pcb_fabrication_note_rect\",\"pcb_fabrication_note_text\",\"pcb_note_dimension\",\"pcb_note_line\",\"pcb_note_path\",\"pcb_note_rect\",\"pcb_note_text\"].includes(t.type??\"\")}function EIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,cornerRadiusMm:o,hasStroke:i,heightMm:r,isFilled:s,isStrokeDashed:a,layer:A,strokeWidthMm:c,widthMm:l}){if(a)throw new Error(\"Altium PCB note rectangles do not preserve dashed strokes\");const u=jee({center:e,cornerRadiusMm:o,heightMm:r,widthMm:l}),g=[];return s\u0026\u0026g.push(o===0?uIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,heightMm:r,layer:A,widthMm:l}):ZXe({altiumComponentIndex:t,circuitPoints:u,circuitToAltiumPcbPoint:n,layer:A})),i\u0026\u0026g.push(...lK({altiumComponentIndex:t,circuitPoints:u,circuitToAltiumPcbPoint:n,closePath:!0,layer:A,strokeWidthMm:c})),g}function Ter({componentIndex:t,element:e}){if(typeof e.pcb_component_id!=\"string\")return;const n=t.get(e.pcb_component_id);if(n===void 0)throw new Error(`PCB annotation references missing component ${e.pcb_component_id}`);return n}function HS(t){return t.toLowerCase()===\"bottom\"?\"MECHANICAL2\":\"MECHANICAL1\"}class ker{constructor(e){this.parentByTraceIndex=Array.from({length:e},(n,o)=\u003eo)}getRoot(e){if(!Number.isInteger(e)||e\u003c0||e\u003e=this.parentByTraceIndex.length)throw new RangeError(`Unknown trace index: ${e}`);let n=e,o=this.parentByTraceIndex[n];for(;o!==n;){if(o===void 0)throw new RangeError(`Unknown trace index: ${n}`);n=o,o=this.parentByTraceIndex[n]}let i=e;for(;this.parentByTraceIndex[i]!==i;){const r=this.parentByTraceIndex[i];if(r===void 0)throw new RangeError(`Unknown trace index: ${i}`);this.parentByTraceIndex[i]=n,i=r}return n}connect(e,n){const o=this.getRoot(e),i=this.getRoot(n);if(o===i)return;const r=Math.min(o,i);this.parentByTraceIndex[o]=r,this.parentByTraceIndex[i]=r}}function BIn({basePcbNetName:t,useCountByPcbNetName:e}){const n=(e.get(t)??0)+1;return e.set(t,n),n===1?t:`${t}-${n}`}function bIn(t,e){return Math.min(...t.sourceNetIds.map(n=\u003ee.get(n)??Number.POSITIVE_INFINITY))}const SIn=t=\u003e{const e=new Map(Dd(t,\"source_net\").flatMap(g=\u003e{const h=ti(g.source_net_id);return h?[[h,uu(g.name)||h]]:[]})),n=new Map([...e.keys()].map((g,h)=\u003e[g,h])),o=Dd(t,\"source_trace\"),i=new ker(o.length),r=new Map,s=new Map;for(const[g,h]of o.entries()){const d=Array.isArray(h.connected_source_port_ids)?h.connected_source_port_ids.map(m=\u003eti(m)):[],p=Array.isArray(h.connected_source_net_ids)?h.connected_source_net_ids.map(m=\u003eti(m)):[];for(const[m,_]of[...d.map(f=\u003e[f,r]),...p.map(f=\u003e[f,s])]){if(!m)continue;const f=_.get(m);f===void 0?_.set(m,g):i.connect(f,g)}}const a=new Map;for(const g of o.keys()){const h=i.getRoot(g);a.set(h,[...a.get(h)??[],g])}const A=new Map,c=[];for(const g of a.values()){const h=g.flatMap(I=\u003e{const C=o[I];return C?[C]:[]}),d=[...new Set(h.flatMap(I=\u003eArray.isArray(I.connected_source_net_ids)?I.connected_source_net_ids.map(C=\u003eti(C)).filter(Boolean):[]))],p=[...new Set(h.flatMap(I=\u003eArray.isArray(I.connected_source_port_ids)?I.connected_source_port_ids.map(C=\u003eti(C)).filter(Boolean):[]))],m=h.map(I=\u003euu(I.name)||uu(I.display_name)).find(Boolean);if(d.length===0\u0026\u0026p.length===0\u0026\u0026!m)continue;const _=c.length,f=d.map(I=\u003ee.get(I)).find(Boolean)||m||`Net-${_+1}`;c.push({index:_,name:BIn({basePcbNetName:f,useCountByPcbNetName:A}),sourceNetIds:d,sourcePortIds:p,traceIds:h.map((I,C)=\u003eti(I.source_trace_id)||`source_trace_${g[C]??C}`)})}const l=new Set(c.flatMap(g=\u003eg.sourceNetIds)),u=new Set([...e.keys(),...Dd(t,\"pcb_copper_pour\").map(g=\u003eti(g.source_net_id)).filter(Boolean)]);for(const g of u){if(l.has(g))continue;const h=e.get(g)??g;c.push({index:c.length,name:BIn({basePcbNetName:h,useCountByPcbNetName:A}),sourceNetIds:[g],sourcePortIds:[],traceIds:[]}),l.add(g)}c.sort((g,h)=\u003e{const d=bIn(g,n),p=bIn(h,n);return d!==p?d-p:g.index-h.index});for(const[g,h]of c.entries())h.index=g;return c};function QIn(t){if(/[\\r\\n|*?]/u.test(t))throw new Error(`Cannot represent keepout exclusion query name: ${JSON.stringify(t)}`);return`'${t.replaceAll(\"'\",\"''\")}'`}function Fer({circuitJson:t,excludedComponentIds:e,unionIndex:n}){const o=Dd(t,\"pcb_component\"),i=Dd(t,\"source_component\"),r=o.map((u,g)=\u003e{const h=i.find(d=\u003ed.source_component_id===u.source_component_id);return uu(h?.name)||`Component-${g+1}`}),s=new Set,a=[...new Set(e)].map(u=\u003e{const g=o.findIndex(d=\u003ed.pcb_component_id===u);if(g===-1)throw new Error(`Keepout exclusion references missing PCB component ${u}`);const h=r[g];if(r.filter(d=\u003ed.toLowerCase()===h.toLowerCase()).length!==1)throw new Error(`Keepout exclusion has ambiguous Altium component name ${h}`);return s.add(ti(o[g].source_component_id)),QIn(h)}),A=new Set(Dd(t,\"source_port\").filter(u=\u003es.has(ti(u.source_component_id))).map(u=\u003eti(u.source_port_id))),c=SIn(t).filter(u=\u003eu.sourcePortIds.some(g=\u003eA.has(g))).map(u=\u003eQIn(u.name)),l=[`InComponent(${a.join(\", \")})`];return c.length\u0026\u0026l.push(`((IsTrack Or IsArc) And InNet(${c.join(\", \")}))`),[\"|RECORD=Rule\",\"BINARYRECORDTYPE=0\",\"RULEKIND=Clearance\",\"NETSCOPE=AnyNet\",\"LAYERKIND=SameLayer\",`SCOPE1EXPRESSION=IsKeepOut And InUnion(${n})`,`SCOPE2EXPRESSION=${l.join(\" Or \")}`,`NAME=TscircuitKeepoutExclusion${n}`,\"ENABLED=TRUE\",`PRIORITY=${n}`,\"GAP=0mil\",\"DEFINEDBYLOGICALDOCUMENT=FALSE\"].join(\"|\")}function Ler({circuitJson:t,circuitToAltiumPcbPoint:e}){const n=[];let o=0;for(const i of t){if(i.type!==\"pcb_keepout\")continue;const r=X2e.parse(i),s=r.excluded_pcb_component_ids?.length?++o:void 0;s!==void 0\u0026\u0026n.push(Fer({circuitJson:t,excludedComponentIds:r.excluded_pcb_component_ids,unionIndex:s}));const a=A=\u003es===void 0?A:`${A}|UNIONINDEX=${s}`;if(r.shape===\"outline\"\u0026\u0026r.stroke_width\u003c=0)throw new Error(`PCB keepout outline ${r.pcb_keepout_id} requires a stroke width`);for(const A of r.layers.map(Her)){if(r.shape===\"rect\"){n.push(a(uIn({center:r.center,circuitToAltiumPcbPoint:e,heightMm:r.height,isKeepout:!0,layer:A,widthMm:r.width})));continue}if(r.shape===\"circle\"){n.push(a(ZXe({circuitPoints:eZe({center:r.center,radiusMm:r.radius}),circuitToAltiumPcbPoint:e,isKeepout:!0,layer:A})));continue}n.push(...lK({circuitPoints:r.outline,circuitToAltiumPcbPoint:e,isKeepout:!0,layer:A,strokeWidthMm:r.stroke_width}).map(a))}}return n}function Her(t){const e=t.toLowerCase();if(e===\"top\")return\"TOP\";if(e===\"bottom\")return\"BOTTOM\";if(e===\"all\"||e===\"multilayer\")return\"KEEPOUT\";const n=/^inner(\\d+)$/u.exec(e);if(n?.[1])return`MID-LAYER${Number(n[1])}`;throw new Error(`Unsupported PCB keepout layer: ${t}`)}function Oer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){if(i.type!==\"pcb_silkscreen_graphic\")continue;const r=Ger(i);r\u0026\u0026o.push(ZXe({altiumComponentIndex:n.get(ti(i.pcb_component_id)),circuitPoints:r.outerRing,circuitToAltiumPcbPoint:e,innerRings:r.innerRings,layer:ti(i.layer).toLowerCase()===\"bottom\"?\"BOTTOMOVERLAY\":\"TOPOVERLAY\"}))}return o}function Ger(t){if(t.shape!==\"brep\"||!HE(t.brep_shape))return;const e=vIn(t.brep_shape.outer_ring);return e.length\u003c3?void 0:{innerRings:Array.isArray(t.brep_shape.inner_rings)?t.brep_shape.inner_rings.map(vIn).filter(o=\u003eo.length\u003e=3):[],outerRing:e}}function vIn(t){return!HE(t)||!Array.isArray(t.vertices)?[]:t.vertices.flatMap(e=\u003e{const n=AA(e);return n?[n]:[]})}function Yer({altiumComponentIndex:t,circuitToAltiumPcbPoint:e,silkscreenText:n}){const o=ti(n.layer).toLowerCase()===\"bottom\";return oZe({altiumComponentIndex:t,circuitText:n,circuitToAltiumPcbPoint:e,layer:o?\"BOTTOMOVERLAY\":\"TOPOVERLAY\"})}const Uer=t=\u003e{const e=Array.isArray(t?.outline)?t.outline.map(AA):[],n=e.filter(c=\u003e!!c),o=n.length===e.length,i=n[0],r=n.at(-1);if(n.length\u003e1\u0026\u0026i\u0026\u0026r\u0026\u0026r3(i,r)\u0026\u0026n.pop(),o\u0026\u0026n.length\u003e=3\u0026\u0026v1e(n)\u003e1e-9)return n;const s=AA(t?.center)??{x:0,y:0},a=Tu(t?.width,VZi),A=Tu(t?.height,zZi);return[{x:s.x-a/2,y:s.y-A/2},{x:s.x+a/2,y:s.y-A/2},{x:s.x+a/2,y:s.y+A/2},{x:s.x-a/2,y:s.y+A/2}]};function wIn(t,e){const n=e.pcbPorts.get(ti(t.pcb_port_id));return e.netBySourcePortId.get(ti(n?.source_port_id))}function PIn(t,e){const n=e.pcbPorts.get(ti(t.pcb_port_id)),o=e.sourcePorts.get(ti(n?.source_port_id));return uu(o?.pin_number?.toString())||uu(o?.name)||\"1\"}const Ker=t=\u003e{const e=Dd(t,\"pcb_board\")[0],n=Uer(e),o=WZi(n),i=n[0]??{x:0,y:0},a=[[\"|RECORD=Board\",\"KIND=Protel_Advanced_PCB\",\"VERSION=5.00\",...[...n,i].flatMap((f,I)=\u003e{const C=o(f);return[`KIND${I}=0`,`VX${I}=${Xi(C.x)}`,`VY${I}=${Xi(C.y)}`]})].join(\"|\")],A=new Map(Dd(t,\"source_component\").filter(f=\u003etypeof f.source_component_id==\"string\").map(f=\u003e[ti(f.source_component_id),f])),c=new Map(Dd(t,\"source_port\").map(f=\u003e[ti(f.source_port_id),f])),l=new Map(Dd(t,\"pcb_port\").map(f=\u003e[ti(f.pcb_port_id),f])),u=SIn(t),g=new Map(u.flatMap(f=\u003ef.traceIds.map(I=\u003e[I,f]))),h=new Map(u.flatMap(f=\u003ef.sourcePortIds.map(I=\u003e[I,f]))),d=Dd(t,\"pcb_component\"),p=new Map(d.map((f,I)=\u003e[ti(f.pcb_component_id)||`pcb_component_${I}`,I]));for(const f of u)a.push(`|RECORD=Net|ID=${f.index}|NAME=${uu(f.name)}|VISIBLE=FALSE|JUMPERSVISIBLE=FALSE`);a.push(...Cer({circuitJson:t,circuitToAltiumPcbPoint:o})),a.push(...oer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p,netEntries:u}));for(const[f,I]of d.entries()){const C=ti(I.pcb_component_id)||`pcb_component_${f}`,y=A.get(ti(I.source_component_id)),x=o(AA(I.center)??{x:0,y:0}),E=uu(y?.name)||`Component-${f+1}`,B=`TSCIRCUIT-${Sp(Tu(I.width,1))}x${Sp(Tu(I.height,1))}mm`,S=ti(I.layer).toLowerCase()===\"bottom\"?\"BOTTOM\":\"TOP\";a.push([\"|RECORD=Component\",`ID=${f}`,`LAYER=${S}`,`X=${Xi(x.x)}`,`Y=${Xi(x.y)}`,`ROTATION=${Sp(sM(fr(I.rotation)))}`,`PATTERN=${B}`,`SOURCEDESIGNATOR=${E}`,\"NAMEON=TRUE\",\"COMMENTON=TRUE\",`SOURCEUNIQUEID=${uu(C)}`].join(\"|\"))}a.push(...jZi({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p})),a.push(...Ler({circuitJson:t,circuitToAltiumPcbPoint:o}),...mer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}),...Ner({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}));const m={netBySourcePortId:h,pcbPorts:l,sourcePorts:c};for(const f of Dd(t,\"pcb_smtpad\")){const I=o({x:fr(f.x),y:fr(f.y)}),C=p.get(ti(f.pcb_component_id)),y=wIn(f,m),x=Tu(f.radius,.5)*2,E=Tu(f.width,x),B=Tu(f.height,E),S=f.shape===\"circle\"?\"ROUND\":\"RECTANGLE\",Q=ti(f.layer).toLowerCase()===\"bottom\"?\"BOTTOM\":\"TOP\";a.push([\"|RECORD=Pad\",...C===void 0?[]:[`COMPONENT=${C}`],...y?[`NET=${y.index}`]:[],`LAYER=${Q}`,`ROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,`NAME=${PIn(f,m)}`,\"HOLESIZE=0mil\",\"PLATED=TRUE\",\"LOCKED=FALSE\",`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`SHAPE=${S}`,`XSIZE=${Xi(E*sg)}`,`YSIZE=${Xi(B*sg)}`].join(\"|\"))}for(const f of Dd(t,\"pcb_plated_hole\")){const I=o({x:fr(f.x),y:fr(f.y)}),C=p.get(ti(f.pcb_component_id)),y=wIn(f,m),x=Tu(f.outer_width,Tu(f.outer_diameter,1.6)),E=Tu(f.outer_height,x),B=Tu(f.hole_width,Tu(f.hole_diameter,.8)),S=Tu(f.hole_height,B),Q=Math.abs(B-S)\u003e1e-9;a.push([\"|RECORD=Pad\",...C===void 0?[]:[`COMPONENT=${C}`],...y?[`NET=${y.index}`]:[],\"LAYER=MULTILAYER\",`ROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,`NAME=${PIn(f,m)}`,`HOLESIZE=${Xi(Math.min(B,S)*sg)}`,`HOLEWIDTH=${Xi(Math.max(B,S)*sg)}`,`HOLESHAPE=${Q?\"SLOT\":\"ROUND\"}`,`HOLEROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,\"PLATED=TRUE\",\"LOCKED=FALSE\",`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`SHAPE=${f.shape===\"circle\"||f.shape===\"oval\"||f.shape===\"pill\"?\"ROUND\":\"RECTANGLE\"}`,`XSIZE=${Xi(x*sg)}`,`YSIZE=${Xi(E*sg)}`].join(\"|\"))}for(const[f,I]of Dd(t,\"pcb_hole\").entries()){const C=o({x:fr(I.x),y:fr(I.y)}),y=p.get(ti(I.pcb_component_id)),x=Tu(I.hole_diameter,1),E=Tu(I.hole_width,x),B=Tu(I.hole_height,x),S=Math.abs(E-B)\u003e1e-9;a.push([\"|RECORD=Pad\",...y===void 0?[]:[`COMPONENT=${y}`],\"LAYER=MULTILAYER\",`ROTATION=${Sp(sM(fr(I.ccw_rotation)))}`,`NAME=NPTH-${f+1}`,`HOLESIZE=${Xi(Math.min(E,B)*sg)}`,`HOLEWIDTH=${Xi(Math.max(E,B)*sg)}`,`HOLESHAPE=${S?\"SLOT\":\"ROUND\"}`,`HOLEROTATION=${Sp(sM(fr(I.ccw_rotation)))}`,\"PLATED=FALSE\",\"LOCKED=FALSE\",`X=${Xi(C.x)}`,`Y=${Xi(C.y)}`,`SHAPE=${S?\"RECTANGLE\":\"ROUND\"}`,`XSIZE=${Xi(E*sg)}`,`YSIZE=${Xi(B*sg)}`].join(\"|\"))}for(const f of Dd(t,\"pcb_trace\")){const I=Array.isArray(f.route)?f.route.flatMap(y=\u003eHE(y)\u0026\u0026AA(y)?[y]:[]):[],C=g.get(ti(f.source_trace_id));for(let y=1;y\u003cI.length;y++){const x=I[y-1],E=I[y];if(!x||!E||x.route_type===\"via\"\u0026\u0026E.route_type===\"via\")continue;const B=o({x:fr(x.x),y:fr(x.y)}),S=o({x:fr(E.x),y:fr(E.y)});if(r3(B,S))continue;const Q=ti(E.layer,ti(x.layer)).toLowerCase()===\"bottom\"?\"BOTTOM\":\"TOP\";a.push([\"|RECORD=Track\",...C?[`NET=${C.index}`]:[],`LAYER=${Q}`,\"LOCKED=FALSE\",`X1=${Xi(B.x)}`,`Y1=${Xi(B.y)}`,`X2=${Xi(S.x)}`,`Y2=${Xi(S.y)}`,`WIDTH=${Xi(Tu(E.width,Tu(x.width,.2))*sg)}`].join(\"|\"))}}const _=new Map(Dd(t,\"pcb_trace\").map(f=\u003e[ti(f.pcb_trace_id),f]));for(const f of Dd(t,\"pcb_via\")){const I=o({x:fr(f.x),y:fr(f.y)}),C=_.get(ti(f.pcb_trace_id)),y=g.get(ti(f.source_trace_id,ti(C?.source_trace_id)));a.push([\"|RECORD=Via\",...y?[`NET=${y.index}`]:[],`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`DIAMETER=${Xi(Tu(f.outer_diameter,.6)*sg)}`,`HOLESIZE=${Xi(Tu(f.hole_diameter,.3)*sg)}`,\"STARTLAYER=TOP\",\"STOPLAYER=BOTTOM\",\"LOCKED=FALSE\"].join(\"|\"))}for(const f of Dd(t,\"pcb_silkscreen_path\")){const I=Array.isArray(f.route)?f.route.flatMap(x=\u003eHE(x)\u0026\u0026AA(x)?[x]:[]):[],C=p.get(ti(f.pcb_component_id)),y=ti(f.layer).toLowerCase()===\"bottom\"?\"BOTTOMOVERLAY\":\"TOPOVERLAY\";for(let x=1;x\u003cI.length;x++){const E=AA(I[x-1]),B=AA(I[x]);if(!E||!B)continue;const S=o(E),Q=o(B);r3(S,Q)||a.push([\"|RECORD=Track\",...C===void 0?[]:[`COMPONENT=${C}`],`LAYER=${y}`,\"LOCKED=FALSE\",`X1=${Xi(S.x)}`,`Y1=${Xi(S.y)}`,`X2=${Xi(Q.x)}`,`Y2=${Xi(Q.y)}`,`WIDTH=${Xi(Tu(f.stroke_width,.15)*sg)}`].join(\"|\"))}}a.push(...Oer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}));for(const f of Dd(t,\"pcb_silkscreen_text\"))a.push(Yer({altiumComponentIndex:p.get(ti(f.pcb_component_id)),circuitToAltiumPcbPoint:o,silkscreenText:f}));return`${a.join(`\\r\n`)}\\r\n`},Ver=/(?:^|\\|)RECORD=Region(?:\\||$)/iu,P1e=/\\|ISBOARDCUTOUT=TRUE(?=\\||$)/giu,MIn=\"/ShapeBasedRegions6/Data\",zer=11,DIn=18,NIn=22,M1e=new TextEncoder().encode(\"|ISBOARDCUTOUT=TRUE\");function RIn(t){const{cutoutRegionIndexes:e,source:n}=Jer(t),o=LZi(n);if(e.size===0)return o;const i=A9.read(o,{type:\"buffer\"}),r=A9.find(i,MIn);if(!r)throw new Error(`Altium PCB is missing ${MIn}`);const s=Wer(Uint8Array.from(r.content),e);if(s.count!==e.size)throw new Error(`Expected to mark ${e.size} Altium board-cutout regions, marked ${s.count}`);return r.content=s.stream,r.size=s.stream.byteLength,new Uint8Array(A9.write(i,{fileType:\"cfb\",type:\"buffer\"}))}function Jer(t){let e=0;const n=new Set,o=t.split(new RegExp(\"(?\u003c=\\\\n)\",\"u\")).map(i=\u003e{if(!Ver.test(i))return i;const r=e++;return P1e.test(i)?(P1e.lastIndex=0,n.add(r),i.replace(P1e,\"\")):i});return P1e.lastIndex=0,{cutoutRegionIndexes:n,source:o.join(\"\")}}function Wer(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=[];let i=0,r=0,s=0;for(;i\u003ct.byteLength;){if(t.byteLength-i\u003c5)throw new Error(\"Truncated Altium region record header\");const c=n.getUint8(i),l=n.getUint32(i+1,!0),u=i+5,g=u+l;if(g\u003et.byteLength)throw new Error(\"Truncated Altium region record payload\");if(c!==zer)throw new Error(`Unexpected Altium region object ID ${c}`);const h=t.subarray(u,g),d=e.has(r)?jer(h,r):h;d!==h\u0026\u0026s++,o.push($er(c,d)),r++,i=g}const a=new Uint8Array(o.reduce((c,l)=\u003ec+l.byteLength,0));let A=0;for(const c of o)a.set(c,A),A+=c.byteLength;return{count:s,stream:a}}function jer(t,e){if(t.byteLength\u003cNIn)throw new Error(`Altium region ${e} has no property block`);const o=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(DIn,!0),i=NIn+o;if(o\u003c1||i\u003et.byteLength)throw new Error(`Altium region ${e} has an invalid property block`);const r=i-1;if(t[r]!==0)throw new Error(`Altium region ${e} has an unterminated property block`);const s=new Uint8Array(t.byteLength+M1e.byteLength);return s.set(t.subarray(0,r),0),s.set(M1e,r),s.set(t.subarray(r),r+M1e.byteLength),new DataView(s.buffer).setUint32(DIn,o+M1e.byteLength,!0),s}function $er(t,e){const n=new Uint8Array(e.byteLength+5),o=new DataView(n.buffer);return o.setUint8(0,t),o.setUint32(1,e.byteLength,!0),n.set(e,5),n}const qer={Fill:\"Fills6\",Track:\"Tracks6\",Region:\"ShapeBasedRegions6\"};function Xer(t){const e=E1e(t,{mode:\"strict\"}),n=e.getRecordsByKind(\"Rule\");if(!n.length)return RIn(t);const o=t.split(/\\r?\\n/u).filter(a=\u003e!/^\\|RECORD=Rule\\|/u.test(a)).map(a=\u003ea.replace(/\\|UNIONINDEX=\\d+/gu,\"\")).join(`\\r\n`),i=A9.read(RIn(o),{type:\"buffer\"}),r=n.map(a=\u003e{if(a.get(\"RULEKIND\")!==\"Clearance\"||a.getNumber(\"BINARYRECORDTYPE\")!==0)throw new Error(\"Keepout rule serializer only supports native Clearance rules\");const A=a.getString().trim().replace(/\\|(?:RECORD|BINARYRECORDTYPE)=[^|]*/gu,\"\");if(/[^\\x20-\\x7e]/u.test(A))throw new Error(\"Keepout rule serialization requires ASCII query names\");const c=new TextEncoder().encode(`${A}\\0`),l=new Uint8Array(c.length+6);return new DataView(l.buffer).setUint32(2,c.length,!0),l.set(c,6),l}),s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,n.length,!0),A9.utils.cfb_add(i,\"Rules6/Header\",s),A9.utils.cfb_add(i,\"Rules6/Data\",iZe(r));for(const[a,A]of Object.entries(qer)){const c=e.getRecordsByKind(a);if(!c.some(p=\u003ep.getNumber(\"UNIONINDEX\")!==void 0))continue;const l=A9.find(i,`/${A}/Data`);if(!l)throw new Error(`Missing Altium ${A} stream`);const u=Uint8Array.from(l.content),g=new DataView(u.buffer),h=[];let d=0;for(const p of c){if(d+5\u003eu.length)throw new Error(`Truncated ${A} header`);const m=g.getUint32(d+1,!0),_=d+5+m;if(_\u003eu.length)throw new Error(`Truncated ${A} record`);const f=p.getNumber(\"UNIONINDEX\"),I=u.slice(d+5,_),C=f===void 0?I:Zer(I,a,f),y=new Uint8Array(5+C.length);y[0]=u[d],new DataView(y.buffer).setUint32(1,C.length,!0),y.set(C,5),h.push(y),d=_}if(d!==u.length)throw new Error(`Unexpected trailing ${A} records`);l.content=iZe(h),l.size=l.content.length}return new Uint8Array(A9.write(i,{fileType:\"cfb\",type:\"buffer\"}))}function Zer(t,e,n){if(!Number.isInteger(n)||n\u003c=0||n\u003e4294967295)throw new Error(\"Invalid keepout union index\");if(e===\"Region\"){if(t.length\u003c22)throw new Error(\"Truncated region properties\");const s=new DataView(t.buffer).getUint32(18,!0);if(22+s\u003et.length)throw new Error(\"Truncated region property block\");const a=new TextDecoder().decode(t.subarray(22,22+s));if(!a.includes(\"UNIONINDEX=0\"))throw new Error(\"Missing region union field\");const A=new TextEncoder().encode(a.replace(\"UNIONINDEX=0\",`UNIONINDEX=${n}`)),c=iZe([t.subarray(0,22),A,t.subarray(22+s)]);return new DataView(c.buffer).setUint32(18,A.length,!0),c}const o=e===\"Track\"?35:37,i=e===\"Track\"?36:37;if(t.length!==o)throw new Error(`Unexpected ${e} binary layout`);const r=new Uint8Array(i+9);return r.set(t),new DataView(r.buffer).setUint32(i,n,!0),r}function iZe(t){const e=new Uint8Array(t.reduce((o,i)=\u003eo+i.length,0));let n=0;for(const o of t)e.set(o,n),n+=o.length;return e}class etr extends w1e{_step(){const e=Ker(this.input);this.context.pcb={asciiContent:e,content:Xer(e),filename:`${this.context.safeProjectName}.PcbDoc`},this.finished=!0}getOutput(){if(!this.context.pcb)throw new Error(\"PCB document stage has not finished\");return this.context.pcb}}class ttr extends w1e{_step(){if(!this.context.pcb||!this.context.schematics)throw new Error(\"PCB and schematic stages must finish before the project\");const e=[\"[Design]\",`ProjectName=${this.context.safeProjectName}`,\"\",...[{path:this.context.pcb.filename,kind:\"pcb-document\"},...this.context.schematics.map(({filename:n})=\u003e({path:n,kind:\"schematic-document\"}))].flatMap((n,o)=\u003e[`[Document${o+1}]`,`DocumentPath=${n.path}`,`DocumentKind=${n.kind}`,\"\"])].join(`\\r\n`);this.context.project={content:e,filename:`${this.context.safeProjectName}.PrjPcb`},this.finished=!0}getOutput(){if(!this.context.project)throw new Error(\"Project document stage has not finished\");return this.context.project}}const rZe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const t in rZe)Object.freeze(rZe[t]);const $ee=Object.freeze(rZe),TIn=Object.create(null);for(const t in $ee)Object.hasOwn($ee,t)\u0026\u0026(TIn[$ee[t]]=t);const a3={to:{},get:{}};a3.get=function(t){const e=t.slice(0,3).toLowerCase();let n,o;switch(e){case\"hsl\":{n=a3.get.hsl(t),o=\"hsl\";break}case\"hwb\":{n=a3.get.hwb(t),o=\"hwb\";break}default:{n=a3.get.rgb(t),o=\"rgb\";break}}return n?{model:o,value:n}:null},a3.get.rgb=function(t){if(!t)return null;const e=/^#([a-f\\d]{3,4})$/i,n=/^#([a-f\\d]{6})([a-f\\d]{2})?$/i,o=/^rgba?\\(\\s*([+-]?(?:\\d*\\.)?\\d+(?:e\\d+)?)(?=[\\s,])\\s*(?:,\\s*)?([+-]?(?:\\d*\\.)?\\d+(?:e\\d+)?)(?=[\\s,])\\s*(?:,\\s*)?([+-]?(?:\\d*\\.)?\\d+(?:e\\d+)?)\\s*(?:[\\s,|/]\\s*([+-]?(?:\\d*\\.)?\\d+(?:e\\d+)?)(%?)\\s*)?\\)$/i,i=/^rgba?\\(\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,|/]\\s*([+-]?[\\d.]+)(%?)\\s*)?\\)$/i,r=/^(\\w+)$/;let s=[0,0,0,1],a,A,c;if(a=t.match(n)){for(c=a[2],a=a[1],A=0;A\u003c3;A++){const l=A*2;s[A]=Number.parseInt(a.slice(l,l+2),16)}c\u0026\u0026(s[3]=Number.parseInt(c,16)/255)}else if(a=t.match(e)){for(a=a[1],c=a[3],A=0;A\u003c3;A++)s[A]=Number.parseInt(a[A]+a[A],16);c\u0026\u0026(s[3]=Number.parseInt(c+c,16)/255)}else if(a=t.match(o)){for(A=0;A\u003c3;A++)s[A]=Number.parseFloat(a[A+1]);a[4]\u0026\u0026(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=t.match(i)){for(A=0;A\u003c3;A++)s[A]=Math.round(Number.parseFloat(a[A+1])*2.55);a[4]\u0026\u0026(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=t.toLowerCase().match(r))?a[1]===\"transparent\"?[0,0,0,0]:Object.hasOwn($ee,a[1])?(s=$ee[a[1]].slice(),s[3]=1,s):null:null;for(A=0;A\u003c3;A++)s[A]=AM(s[A],0,255);return s[3]=AM(s[3],0,1),s},a3.get.hsl=function(t){if(!t)return null;const e=/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[,|/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:e[+-]?\\d+)?)\\s*)?\\)$/i,n=t.match(e);if(n){const o=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,r=AM(Number.parseFloat(n[2]),0,100),s=AM(Number.parseFloat(n[3]),0,100),a=AM(Number.isNaN(o)?1:o,0,1);return[i,r,s,a]}return null},a3.get.hwb=function(t){if(!t)return null;const e=/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:e[+-]?\\d+)?)\\s*)?\\)$/i,n=t.match(e);if(n){const o=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,r=AM(Number.parseFloat(n[2]),0,100),s=AM(Number.parseFloat(n[3]),0,100),a=AM(Number.isNaN(o)?1:o,0,1);return[i,r,s,a]}return null},a3.to.hex=function(...t){return\"#\"+D1e(t[0])+D1e(t[1])+D1e(t[2])+(t[3]\u003c1?D1e(Math.round(t[3]*255)):\"\")},a3.to.rgb=function(...t){return t.length\u003c4||t[3]===1?\"rgb(\"+Math.round(t[0])+\", \"+Math.round(t[1])+\", \"+Math.round(t[2])+\")\":\"rgba(\"+Math.round(t[0])+\", \"+Math.round(t[1])+\", \"+Math.round(t[2])+\", \"+t[3]+\")\"},a3.to.rgb.percent=function(...t){const e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return t.length\u003c4||t[3]===1?\"rgb(\"+e+\"%, \"+n+\"%, \"+o+\"%)\":\"rgba(\"+e+\"%, \"+n+\"%, \"+o+\"%, \"+t[3]+\")\"},a3.to.hsl=function(...t){return t.length\u003c4||t[3]===1?\"hsl(\"+t[0]+\", \"+t[1]+\"%, \"+t[2]+\"%)\":\"hsla(\"+t[0]+\", \"+t[1]+\"%, \"+t[2]+\"%, \"+t[3]+\")\"},a3.to.hwb=function(...t){let e=\"\";return t.length\u003e=4\u0026\u0026t[3]!==1\u0026\u0026(e=\", \"+t[3]),\"hwb(\"+t[0]+\", \"+t[1]+\"%, \"+t[2]+\"%\"+e+\")\"},a3.to.keyword=function(...t){return TIn[t.slice(0,3)]};function AM(t,e,n){return Math.min(Math.max(e,t),n)}function D1e(t){const e=Math.round(t).toString(16).toUpperCase();return e.length\u003c2?\"0\"+e:e}function qee({cssColor:t,fallbackAltiumColor:e}){const n=a3.get.rgb(t.trim());if(!n||n.length\u003c3)return e;const[o=0,i=0,r=0]=n.map(Math.round);return o|i\u003c\u003c8|r\u003c\u003c16}const b4=132,kIn=16317695,Xee=16777215;function OS(t,e){const n=Math.round(e*1e5);if(!Number.isSafeInteger(n))throw new RangeError(`Invalid schematic coordinate ${t}: ${e}`);const o=Math.trunc(n/1e5),i=n-o*1e5;return[`${t}=${o}`,...i===0?[]:[`${t}_FRAC=${i\u003c0?\"-\":\"\"}${String(Math.abs(i)).padStart(5,\"0\")}`]]}const ntr=16777215,FIn=16711680,otr=16,itr=8,ck=3,rtr=\"Times New Roman\",sZe=11;function str({hasInputArrow:t,hasOutputArrow:e}){return t\u0026\u0026e?3:t?1:e?2:0}function atr({altiumPortPosition:t,facingDirection:e,hasInputArrow:n,hasOutputArrow:o,portName:i}){const r=Math.max([...i].length*itr,otr);return[\"RECORD=18\",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,`WIDTH=${r}`,`IOTYPE=${str({hasInputArrow:n,hasOutputArrow:o})}`,...e===\"up\"||e===\"down\"?[\"STYLE=4\"]:[],`NAME=${i}`,`FONTID=${ck}`,`COLOR=${FIn}`,`AREACOLOR=${ntr}`,`TEXTCOLOR=${FIn}`]}const N1e=20,Zee=4,LIn=\"Arial\",R1e=.18,HIn=.15,OIn=.2;function Atr({netLabelTextPresentations:t=[],schematicElements:e,templateFontFields:n=[]}){const o=new Map,i=new Map([[1,Zee],[2,Zee],[ck,sZe]]),r=sZe/N1e;o.set(r,ck);const s=e.some(d=\u003ed.type===\"schematic_net_label\"),a=[...new Set([...s?[R1e]:[],...e.flatMap(d=\u003e{const p=d.type===\"schematic_text\"?fr(d.font_size):0;return p\u003e0?[p]:[]})])].sort((d,p)=\u003ed-p),A=[];let c=ck+1;for(const d of a){if(o.has(d))continue;const p=c++;o.set(d,p),i.set(p,d*N1e),A.push(`SIZE${p}=${Sp(d*N1e)}`,`FONTNAME${p}=${LIn}`)}const l=new Map;for(const d of n){const p=c++;l.set(d.sourceFontId,p),A.push(...d.fields.map(m=\u003em.replace(/^(\\w+?)\\d+=/u,`$1${p}=`)))}const u=new Map(o),g=new Map([[Zee,1]]);for(const[d,p]of i)d\u003eck\u0026\u0026Number.isInteger(p)\u0026\u0026g.set(p,d);const h=[...e.flatMap(d=\u003ed.type===\"schematic_text\"\u0026\u0026(ti(d.schematic_component_id)||ti(d.source_trace_id))?[fr(d.font_size)]:[]),...s?[R1e]:[],...t.map(d=\u003efr(d.font_size)),...e.flatMap(d=\u003ed.type===\"schematic_port\"\u0026\u0026ti(d.schematic_component_id)?[OIn,Tu(d.display_pin_label_font_size,HIn)]:[])];for(const d of h){if(d\u003c=0)continue;const p=u.get(d);if(p!==void 0\u0026\u0026Number.isInteger(i.get(p)))continue;const m=Math.max(1,Math.ceil(Number(Sp(d*N1e))));let _=g.get(m);_===void 0\u0026\u0026(_=c++,g.set(m,_),i.set(_,m),A.push(`SIZE${_}=${m}`,`FONTNAME${_}=${LIn}`)),u.set(d,_)}return{nativeTextFontIdBySizeCircuitUnits:u,fontIdBySizeCircuitUnits:o,fontSizePointsById:i,sheetRecordFields:[`FONTIDCOUNT=${c-1}`,`SIZE1=${Zee}`,\"FONTNAME1=Arial\",`SIZE2=${Zee}`,\"FONTNAME2=Arial\",`SIZE${ck}=${sZe}`,`FONTNAME${ck}=${rtr}`,...A],templateFontIdBySourceFontId:l}}const ctr=[.278,.333,.408,.556,.556,.889,.778,.191,.333,.333,.5,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.722,.667,.722,.722,.667,.611,.778,.722,.333,.5,.722,.611,.889,.722,.778,.667,.778,.722,.667,.611,.722,.722,.944,.722,.722,.611,.333,.278,.333,.469,.556,.333,.556,.556,.5,.556,.556,.333,.556,.556,.278,.278,.5,.278,.833,.556,.556,.556,.556,.333,.5,.278,.556,.5,.722,.5,.5,.5,.48,.259,.48,.584];function ltr(t,e){return[...t].reduce((n,o)=\u003en+(ctr[o.codePointAt(0)-32]??1)*e,0)}const utr={bottom:1,bottom_left:0,bottom_center:1,bottom_right:2,left:3,center_left:3,center:4,center_right:5,right:5,top:7,top_left:6,top_center:7,top_right:8};function aZe(t){return utr[t]??0}function AZe(t){const e=(t%360+360)%360;return e===90||e===270?1:0}function cZe({circuitToAltiumSchematicPoint:t,fallbackAltiumColor:e,fallbackAltiumPosition:n,fallbackFontId:o,fallbackJustification:i,fontTable:r,schematicText:s}){const a=AA(s?.position),A=fr(s?.font_size);return{color:qee({cssColor:ti(s?.color),fallbackAltiumColor:e}),fontId:r.fontIdBySizeCircuitUnits.get(A)??o,justification:s?aZe(ti(s.anchor)):i,orientation:AZe(fr(s?.rotation)),position:a?t(a):n}}const GIn=2,gtr=132,dtr=10,YIn={bottom:{x:0,y:1},left:{x:1,y:0},right:{x:-1,y:0},top:{x:0,y:-1}},htr={bottom:{justification:3,orientation:1},left:{justification:3,orientation:0},right:{justification:5,orientation:0},top:{justification:5,orientation:1}},ptr={bottom:1,left:3,right:5,top:7},UIn={right:0,up:1,left:2,down:3},KIn={rail:2,ground:4};function mtr(t){return t in UIn}function _tr(t){return t in KIn}function ftr(t){return t in YIn}function lZe(t,e){const n=\"ABCDEFGHIJKLMNOPQRSTUVWXY\";let o=Math.max(Math.floor(t),0),i=\"\";for(let r=0;r\u003c4;r++)i=n[o%n.length]+i,o=Math.floor(o/n.length);return`CJN${e}${i}`}function Itr({altiumLabelCenter:t,altiumLabelPosition:e,anchorSide:n,fontSize:o,textFontSize:i,labelText:r}){if(!ftr(n))return;const s=YIn[n],a={x:t.x-e.x,y:t.y-e.y},A=a.x*s.x+a.y*s.y,c=o*.3,l=o*.5,u=o*.2,g=ltr(r,i),h=Math.max(A*2,l+g+u,dtr),d={x:-s.y,y:s.x},p=(f,I=0)=\u003e({x:e.x+s.x*f+d.x*I,y:e.y+s.y*f+d.y*I}),m=o*(.2/.18)/2,_=htr[n];return{orientation:_.orientation,outlinePoints:[p(0),p(c,m),p(h,m),p(h,-m),p(c,-m)],textJustification:_.justification,textPosition:p(l)}}function VIn(t){const e=t.lastIndexOf(\"_\");if(e\u003c1)return;const n=t.slice(0,e),o=t.slice(e+1);if(!(!_tr(n)||!mtr(o)))return{orientationIndex:UIn[o],styleIndex:KIn[n]}}function Ctr({anchorSide:t,altiumLabelCenter:e,altiumLabelPosition:n,decorationIndex:o,fontTable:i,labelText:r,symbolName:s,textPresentation:a}){const A=VIn(s),c=i.fontIdBySizeCircuitUnits.get(fr(a?.font_size))??(A?GIn:i.fontIdBySizeCircuitUnits.get(R1e)??GIn),l=A?c:i.nativeTextFontIdBySizeCircuitUnits.get(fr(a?.font_size))??i.nativeTextFontIdBySizeCircuitUnits.get(R1e)??c,u=qee({cssColor:ti(a?.color),fallbackAltiumColor:A?gtr:b4});if(A)return[[\"RECORD=17\",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`FONTID=${l}`,`ORIENTATION=${A.orientationIndex}`,`STYLE=${A.styleIndex}`,`COLOR=${u}`,\"SHOWNETNAME=T\",`TEXT=${r}`]];const g=[\"RECORD=25\",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`FONTID=${l}`,`ORIENTATION=${AZe(fr(a?.rotation))}`,`JUSTIFICATION=${a?aZe(ti(a.anchor)):ptr[t]??0}`,`COLOR=${u}`,`TEXT=${r}`];if(a\u0026\u0026r3(e,n))return[g];const h=Itr({altiumLabelCenter:e,altiumLabelPosition:n,anchorSide:t,fontSize:i.fontSizePointsById.get(c)??4,textFontSize:i.fontSizePointsById.get(l)??4,labelText:r});return h?[[\"RECORD=27\",\"LINEWIDTH=0\",\"LOCATIONCOUNT=2\",...OS(\"X1\",n.x),...OS(\"Y1\",n.y),...OS(\"X2\",h.textPosition.x),...OS(\"Y2\",h.textPosition.y),\"COLOR=34816\",`UNIQUEID=${lZe(o,\"W\")}`],[\"RECORD=7\",\"OWNERPARTID=-1\",\"LINEWIDTH=0\",`LOCATIONCOUNT=${h.outlinePoints.length}`,...h.outlinePoints.flatMap((d,p)=\u003e[...OS(`X${p+1}`,d.x),...OS(`Y${p+1}`,d.y)]),`COLOR=${u}`,`AREACOLOR=${kIn}`,\"ISSOLID=T\",`UNIQUEID=${lZe(o,\"P\")}`],[\"RECORD=25\",...OS(\"LOCATION.X\",h.textPosition.x),...OS(\"LOCATION.Y\",h.textPosition.y),`FONTID=${l}`,`ORIENTATION=${h.orientation}`,`JUSTIFICATION=${h.textJustification}`,`COLOR=${u}`,`TEXT=${r}`,`UNIQUEID=${lZe(o,\"T\")}`]]:[g]}const ytr=255;function zIn({altiumNoConnectPosition:t}){return[\"RECORD=22\",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,\"ISACTIVE=T\",\"SYMBOL=Thin Cross\",\"ORIENTATION=1\",\"OWNERPARTID=-1\",`COLOR=${ytr}`,\"SUPPRESSALL=T\"]}const xtr=new Set([\"schematic_line\",\"schematic_path\",\"schematic_rect\",\"schematic_text\"]);function T1e(t){return xtr.has(t.type??\"\")\u0026\u0026!ti(t.schematic_component_id)\u0026\u0026!ti(t.schematic_symbol_id)}const Etr=20,k1e=3615007,JIn=16777215;function uZe(t){return Sp(Math.max(fr(t.stroke_width),0)*Etr)}function dK({annotation:t,colorFieldName:e,fallbackAltiumColor:n}){return qee({cssColor:ti(t[e]),fallbackAltiumColor:n})}function Btr({annotation:t,circuitToAltiumSchematicPoint:e,fontTable:n}){const o=j1n(ti(t.text)),i=AA(t.position),r=fr(t.font_size),s=n.fontIdBySizeCircuitUnits.get(r);if(!o||!i||!s)return;const a=e(i);return[\"RECORD=4\",`LOCATION.X=${a.x}`,`LOCATION.Y=${a.y}`,`FONTID=${s}`,`TEXT=${o}`,`COLOR=${dK({annotation:t,colorFieldName:\"color\",fallbackAltiumColor:k1e})}`,`ORIENTATION=${AZe(fr(t.rotation))}`,`JUSTIFICATION=${aZe(ti(t.anchor))}`]}function btr({annotation:t,circuitToAltiumSchematicPoint:e}){const n=AA(t.center),o=fr(t.width),i=fr(t.height);if(!n||o\u003c=0||i\u003c=0)return;const r=e({x:n.x-o/2,y:n.y-i/2}),s=e({x:n.x+o/2,y:n.y+i/2}),a=dK({annotation:t,colorFieldName:\"color\",fallbackAltiumColor:k1e}),A=t.is_filled===!0;return[\"RECORD=14\",`LOCATION.X=${r.x}`,`LOCATION.Y=${r.y}`,`CORNER.X=${s.x}`,`CORNER.Y=${s.y}`,`LINEWIDTH=${uZe(t)}`,`COLOR=${a}`,`AREACOLOR=${dK({annotation:t,colorFieldName:\"fill_color\",fallbackAltiumColor:A?a:JIn})}`,`ISSOLID=${A?\"T\":\"F\"}`]}function Str({annotation:t,circuitToAltiumSchematicPoint:e}){const n=e({x:fr(t.x1),y:fr(t.y1)}),o=e({x:fr(t.x2),y:fr(t.y2)});return[\"RECORD=13\",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`CORNER.X=${o.x}`,`CORNER.Y=${o.y}`,`LINEWIDTH=${uZe(t)}`,`LINESTYLE=${t.is_dashed===!0?1:0}`,`COLOR=${dK({annotation:t,colorFieldName:\"color\",fallbackAltiumColor:k1e})}`]}function Qtr({annotation:t,circuitToAltiumSchematicPoint:e}){if(!Array.isArray(t.points))return;const n=t.points.flatMap(r=\u003e{const s=AA(r);return s?[s]:[]});if(n.length\u003c2)return;const o=n.map(e),i=t.is_filled===!0;return[`RECORD=${i?7:6}`,`LINEWIDTH=${uZe(t)}`,`LOCATIONCOUNT=${o.length}`,...o.flatMap((r,s)=\u003e[`X${s+1}=${r.x}`,`Y${s+1}=${r.y}`]),`COLOR=${dK({annotation:t,colorFieldName:\"stroke_color\",fallbackAltiumColor:k1e})}`,...i?[`AREACOLOR=${dK({annotation:t,colorFieldName:\"fill_color\",fallbackAltiumColor:JIn})}`,\"ISSOLID=T\"]:[]]}function WIn(t){if(T1e(t.annotation)){if(t.annotation.type===\"schematic_text\")return Btr(t);if(t.annotation.type===\"schematic_line\")return Str(t);if(t.annotation.type===\"schematic_rect\")return btr(t);if(t.annotation.type===\"schematic_path\")return Qtr(t)}}const vtr=10,wtr=10,Ptr=60,Mtr=160,gZe=132,jIn=12779519;function Dtr({childSheets:t,circuitJson:e}){const n=new Map(e.filter(o=\u003eo.type===\"source_port\").map(o=\u003e[ti(o.source_port_id),o]));return t.map(o=\u003e{const i=e.find(c=\u003ec.type===\"schematic_component\"\u0026\u0026c.is_schematic_group===!0\u0026\u0026!ti(c.schematic_sheet_id)\u0026\u0026o.subcircuitId!==void 0\u0026\u0026ti(c.subcircuit_id)===o.subcircuitId),r=e.filter(c=\u003ec.type===\"schematic_port\"\u0026\u0026ti(c.schematic_sheet_id)===o.schematicSheetId\u0026\u0026!ti(c.schematic_component_id)),s={0:0,1:0},a=r.flatMap(c=\u003e{const l=n.get(ti(c.source_port_id)),u=ti(c.display_pin_label)||ti(l?.name);if(!u)return[];const g=c.has_input_arrow===!0,h=c.has_output_arrow===!0,d=Ftr(c);return s[d]++,[{distanceFromTop:i?ktr({placementComponent:i,schematicPort:c}):s[d],doNotConnect:l?.do_not_connect===!0,ioType:g?h?3:1:h?2:0,name:u,side:d}]}),A=Math.max(o.name.length,o.filename.length,...a.map(c=\u003ec.name.length*2));return{childSheet:o,entries:a,height:Math.max(Ptr,Math.max(s[0],s[1])*vtr+20),placementComponent:i,width:Math.max(Mtr,A*6+20)}})}function Ntr({location:t,plan:e}){return e.entries.flatMap(n=\u003en.doNotConnect?[zIn({altiumNoConnectPosition:{x:t.x+(n.side===1?e.width:0),y:t.y-n.distanceFromTop*wtr}})]:[])}function Rtr({altiumSymbolRecordIndex:t,location:e,plan:n}){const{childSheet:o,entries:i}=n;return[[\"RECORD=32\",`OWNERINDEX=${t}`,\"OWNERPARTID=-1\",`LOCATION.X=${e.x}`,`LOCATION.Y=${e.y+10}`,\"COLOR=8388608\",\"FONTID=1\",`TEXT=${uu(o.name)}`],[\"RECORD=33\",`OWNERINDEX=${t}`,\"OWNERPARTID=-1\",`LOCATION.X=${e.x}`,`LOCATION.Y=${e.y}`,\"COLOR=8388608\",\"FONTID=1\",`TEXT=${uu(o.filename)}`],...i.map(r=\u003e[\"RECORD=16\",`OWNERINDEX=${t}`,\"OWNERPARTID=-1\",...r.side===1?[\"SIDE=1\"]:[],`DISTANCEFROMTOP=${r.distanceFromTop}`,`COLOR=${gZe}`,`AREACOLOR=${jIn}`,`TEXTCOLOR=${gZe}`,\"TEXTFONTID=1\",\"TEXTSTYLE=Full\",`NAME=${uu(r.name)}`,`IOTYPE=${r.ioType}`,\"ARROWKIND=Block \u0026 Triangle\"])]}function Ttr({location:t,plan:e}){return[\"RECORD=15\",\"OWNERPARTID=-1\",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,`XSIZE=${e.width}`,`YSIZE=${e.height}`,`COLOR=${gZe}`,`AREACOLOR=${jIn}`,\"ISSOLID=T\",`UNIQUEID=${uu(e.childSheet.schematicSheetId)}`,\"SYMBOLTYPE=Normal\"]}function ktr({placementComponent:t,schematicPort:e}){const n=AA(t.center),o=AA(e.center),i=HE(t.size)?t.size:void 0;if(!n||!o||!i)return 0;const r=n.y+fr(i.height)/2;return Math.max(Math.round((r-o.y)*2),0)}function Ftr(t){const e=ti(t.facing_direction);return e===\"right\"?1:e===\"left\"?0:t.has_output_arrow===!0\u0026\u0026t.has_input_arrow!==!0?1:0}function Ltr({graphicPrimitive:t,symbolMapping:e}){return t.type===\"path\"?Htr({pathPrimitive:t,symbolMapping:e}):t.type===\"circle\"?Otr({circlePrimitive:t,symbolMapping:e}):Gtr({boxPrimitive:t,symbolMapping:e})}function Htr({pathPrimitive:t,symbolMapping:e}){const n=t.points.map(r=\u003eUtr({symbolMapping:e,symbolPoint:r})),o=n[0],i=n.at(-1);return t.closed\u0026\u0026o\u0026\u0026i\u0026\u0026!r3(o,i)\u0026\u0026n.push(o),[`RECORD=${t.fill?7:6}`,...ete(e.altiumComponentRecordIndex),\"LINEWIDTH=1\",`LOCATIONCOUNT=${n.length}`,...n.flatMap((r,s)=\u003e[...qIn(`X${s+1}`,r.x),...qIn(`Y${s+1}`,r.y)]),`COLOR=${b4}`,...t.fill?[`AREACOLOR=${b4}`,\"ISSOLID=T\"]:[]]}const $In=5,dZe=10**$In;function qIn(t,e){const n=Math.round(e*dZe)/dZe,o=Math.trunc(n),i=Math.round(Math.abs(n-o)*dZe);return[`${t}=${o}`,...i\u003e0?[`${t}_FRAC=${String(i).padStart($In,\"0\")}`]:[]]}function Otr({circlePrimitive:t,symbolMapping:e}){const n=lk({symbolMapping:e,symbolPoint:{x:t.x,y:t.y}}),o=lk({symbolMapping:e,symbolPoint:{x:t.x+t.radius,y:t.y}}),i=Math.max(1,Math.abs(o.x-n.x));return[\"RECORD=8\",...ete(e.altiumComponentRecordIndex),`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`RADIUS=${i}`,`SECONDARYRADIUS=${i}`,\"LINEWIDTH=1\",`COLOR=${b4}`,`AREACOLOR=${t.fill?b4:Xee}`,`ISSOLID=${t.fill?\"T\":\"F\"}`]}function Gtr({boxPrimitive:t,symbolMapping:e}){const n=Ytr(t),o=lk({symbolMapping:e,symbolPoint:{x:n.x-t.width/2,y:n.y-t.height/2}}),i=lk({symbolMapping:e,symbolPoint:{x:n.x+t.width/2,y:n.y+t.height/2}});return[\"RECORD=14\",...ete(e.altiumComponentRecordIndex),`LOCATION.X=${o.x}`,`LOCATION.Y=${o.y}`,`CORNER.X=${i.x}`,`CORNER.Y=${i.y}`,\"LINEWIDTH=1\",`COLOR=${b4}`,`AREACOLOR=${Xee}`,\"ISSOLID=F\"]}function Ytr(t){const e=t.anchor.endsWith(\"_left\")?t.width/2:t.anchor.endsWith(\"_right\")?-t.width/2:0,n=t.anchor.startsWith(\"top_\")?-t.height/2:t.anchor.startsWith(\"bottom_\")?t.height/2:0;return{x:t.x+e,y:t.y+n}}function lk({symbolMapping:t,symbolPoint:e}){const n=Bn(t.symbolToCircuitMatrix,e);return t.circuitToAltiumSchematicPoint(n)}function Utr({symbolMapping:t,symbolPoint:e}){const n=Bn(t.symbolToCircuitMatrix,e);return t.circuitToAltiumSchematicPrecisePoint(n)}function ete(t){return[`OWNERINDEX=${t}`,\"OWNERPARTID=1\",\"OWNERPARTDISPLAYMODE=0\"]}const Ktr=3615007;function XIn({altiumComponentRecordIndex:t,circuitToAltiumSchematicPoint:e,fontTable:n,schematicText:o}){const i=uu(ti(o.text));if(!i)return;const r=cZe({circuitToAltiumSchematicPoint:e,fallbackAltiumColor:Ktr,fallbackAltiumPosition:{x:0,y:0},fallbackFontId:2,fallbackJustification:0,fontTable:n,schematicText:o});return[\"RECORD=4\",`OWNERINDEX=${t}`,\"OWNERPARTID=1\",`LOCATION.X=${r.position.x}`,`LOCATION.Y=${r.position.y}`,`FONTID=${r.fontId}`,`TEXT=${i}`,`COLOR=${r.color}`,`ORIENTATION=${r.orientation}`,`JUSTIFICATION=${r.justification}`]}const Vtr=new Set([\"schematic_arc\",\"schematic_circle\",\"schematic_line\",\"schematic_path\",\"schematic_rect\"]);function F1e(t){return Vtr.has(t.type??\"\")||t.type===\"schematic_text\"\u0026\u0026typeof t.schematic_symbol_id==\"string\"\u0026\u0026t.schematic_symbol_id.length\u003e0}function ztr({circuitToAltiumSchematicLength:t,graphic:e}){return Sp(Math.max(1,t(Math.max(fr(e.stroke_width),0))))}function cM({colorFieldName:t,fallbackAltiumColor:e,graphic:n}){return qee({cssColor:ti(n[t]),fallbackAltiumColor:e})}function tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:n}){return[...ete(t),`LINEWIDTH=${ztr({circuitToAltiumSchematicLength:e,graphic:n})}`,`LINESTYLE=${n.is_dashed===!0?1:0}`]}function L1e({circuitToAltiumSchematicLength:t,radius:e}){return Math.max(1,t(e))}function Jtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){if(!Array.isArray(o.points))return;const i=o.points.flatMap(a=\u003e{const A=AA(a);return A?[A]:[]});if(i.length\u003c2)return;const r=i.map(n),s=o.is_filled===!0;return[`RECORD=${s?7:6}`,...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATIONCOUNT=${r.length}`,...r.flatMap((a,A)=\u003e[`X${A+1}=${a.x}`,`Y${A+1}=${a.y}`]),`COLOR=${cM({graphic:o,colorFieldName:\"stroke_color\",fallbackAltiumColor:b4})}`,...s?[`AREACOLOR=${cM({graphic:o,colorFieldName:\"fill_color\",fallbackAltiumColor:Xee})}`,\"ISSOLID=T\"]:[]]}function Wtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.radius);if(!i||r\u003c=0)return;const s=n(i),a=o.is_filled===!0;return[\"RECORD=8\",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${s.x}`,`LOCATION.Y=${s.y}`,`RADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,`SECONDARYRADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,`COLOR=${cM({graphic:o,colorFieldName:\"color\",fallbackAltiumColor:b4})}`,`AREACOLOR=${cM({graphic:o,colorFieldName:\"fill_color\",fallbackAltiumColor:Xee})}`,`ISSOLID=${a?\"T\":\"F\"}`]}function jtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.radius);if(!i||r\u003c=0)return;const s=n(i),a=fr(o.start_angle_degrees),A=fr(o.end_angle_degrees),c=ti(o.direction)===\"clockwise\",l=fr(o.altium_secondary_radius),u=l\u003e0;return[`RECORD=${u?11:12}`,...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${s.x}`,`LOCATION.Y=${s.y}`,`RADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,...u?[`SECONDARYRADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:l}))}`]:[],`STARTANGLE=${Sp(c?A:a)}`,`ENDANGLE=${Sp(c?a:A)}`,`COLOR=${cM({graphic:o,colorFieldName:\"color\",fallbackAltiumColor:b4})}`]}function $tr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=n({x:fr(o.x1),y:fr(o.y1)}),r=n({x:fr(o.x2),y:fr(o.y2)});return[\"RECORD=13\",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${i.x}`,`LOCATION.Y=${i.y}`,`CORNER.X=${r.x}`,`CORNER.Y=${r.y}`,`COLOR=${cM({graphic:o,colorFieldName:\"color\",fallbackAltiumColor:b4})}`]}function qtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.width),s=fr(o.height),a=(fr(o.rotation)%360+360)%360;if(!i||r\u003c=0||s\u003c=0||a!==0)return;const A=n({x:i.x-r/2,y:i.y-s/2}),c=n({x:i.x+r/2,y:i.y+s/2}),l=o.is_filled===!0,u=cM({graphic:o,colorFieldName:\"color\",fallbackAltiumColor:b4});return[\"RECORD=14\",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${A.x}`,`LOCATION.Y=${A.y}`,`CORNER.X=${c.x}`,`CORNER.Y=${c.y}`,`COLOR=${u}`,`AREACOLOR=${cM({graphic:o,colorFieldName:\"fill_color\",fallbackAltiumColor:l?u:Xee})}`,`ISSOLID=${l?\"T\":\"F\"}`]}function Xtr(t){if(F1e(t.graphic)){if(t.graphic.type===\"schematic_text\")return XIn({altiumComponentRecordIndex:t.altiumComponentRecordIndex,circuitToAltiumSchematicPoint:t.circuitToAltiumSchematicPoint,fontTable:t.fontTable,schematicText:t.graphic});if(t.graphic.type===\"schematic_path\")return Jtr(t);if(t.graphic.type===\"schematic_circle\")return Wtr(t);if(t.graphic.type===\"schematic_arc\")return jtr(t);if(t.graphic.type===\"schematic_line\")return $tr(t);if(t.graphic.type===\"schematic_rect\")return qtr(t)}}function GE(t,e){return Array.isArray(e)?[t.a*e[0]+t.c*e[1]+t.e,t.b*e[0]+t.d*e[1]+t.f]:{x:t.a*e.x+t.c*e.y+t.e,y:t.b*e.x+t.d*e.y+t.f}}function ZIn(t){return typeof t\u003e\"u\"}function eCn(t,e=0){return{a:1,c:0,e:t,b:0,d:1,f:e}}function H1e(...t){t=Array.isArray(t[0])?t[0]:t;let e=(n,o)=\u003e({a:n.a*o.a+n.c*o.b,c:n.a*o.c+n.c*o.d,e:n.a*o.e+n.c*o.f+n.e,b:n.b*o.a+n.d*o.b,d:n.b*o.c+n.d*o.d,f:n.b*o.e+n.d*o.f+n.f});switch(t.length){case 0:throw new Error(\"no matrices provided\");case 1:return t[0];case 2:return e(t[0],t[1]);default:{let[n,o,...i]=t,r=e(n,o);return H1e(r,...i)}}}var{cos:Ztr,sin:enr}=Math;function tnr(t,e,n){let o=Ztr(t),i=enr(t),r={a:o,c:-i,e:0,b:i,d:o,f:0};return ZIn(e)||ZIn(n)?r:H1e([eCn(e,n),r,eCn(-e,-n)])}function nnr(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function O1e(t,e,n,o){var i=Error.call(this,t);return Object.setPrototypeOf\u0026\u0026Object.setPrototypeOf(i,O1e.prototype),i.expected=e,i.found=n,i.location=o,i.name=\"SyntaxError\",i}nnr(O1e,Error);function hZe(t,e,n){return n=n||\" \",t.length\u003ee?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}O1e.prototype.format=function(t){var e=\"Error: \"+this.message;if(this.location){var n=null,o;for(o=0;o\u003ct.length;o++)if(t[o].source===this.location.source){n=t[o].text.split(/\\r\\n|\\n|\\r/g);break}var i=this.location.start,r=this.location.source\u0026\u0026typeof this.location.source.offset==\"function\"?this.location.source.offset(i):i,s=this.location.source+\":\"+r.line+\":\"+r.column;if(n){var a=this.location.end,A=hZe(\"\",r.line.toString().length,\" \"),c=n[i.line-1],l=i.line===a.line?a.column:c.length+1,u=l-i.column||1;e+=`\n --\u003e `+s+`\n`+A+` |\n`+r.line+\" | \"+c+`\n`+A+\" | \"+hZe(\"\",i.column-1,\" \")+hZe(\"\",u,\"^\")}else e+=`\n at `+s}return e},O1e.buildMessage=function(t,e){var n={literal:function(c){return'\"'+i(c.text)+'\"'},class:function(c){var l=c.parts.map(function(u){return Array.isArray(u)?r(u[0])+\"-\"+r(u[1]):r(u)});return\"[\"+(c.inverted?\"^\":\"\")+l.join(\"\")+\"]\"},any:function(){return\"any character\"},end:function(){return\"end of input\"},other:function(c){return c.description}};function o(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"').replace(/\\0/g,\"\\\\0\").replace(/\\t/g,\"\\\\t\").replace(/\\n/g,\"\\\\n\").replace(/\\r/g,\"\\\\r\").replace(/[\\x00-\\x0F]/g,function(l){return\"\\\\x0\"+o(l)}).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,function(l){return\"\\\\x\"+o(l)})}function r(c){return c.replace(/\\\\/g,\"\\\\\\\\\").replace(/\\]/g,\"\\\\]\").replace(/\\^/g,\"\\\\^\").replace(/-/g,\"\\\\-\").replace(/\\0/g,\"\\\\0\").replace(/\\t/g,\"\\\\t\").replace(/\\n/g,\"\\\\n\").replace(/\\r/g,\"\\\\r\").replace(/[\\x00-\\x0F]/g,function(l){return\"\\\\x0\"+o(l)}).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,function(l){return\"\\\\x\"+o(l)})}function s(c){return n[c.type](c)}function a(c){var l=c.map(s),u,g;if(l.sort(),l.length\u003e0){for(u=1,g=1;u\u003cl.length;u++)l[u-1]!==l[u]\u0026\u0026(l[g]=l[u],g++);l.length=g}switch(l.length){case 1:return l[0];case 2:return l[0]+\" or \"+l[1];default:return l.slice(0,-1).join(\", \")+\", or \"+l[l.length-1]}}function A(c){return c?'\"'+i(c)+'\"':\"end of input\"}return\"Expected \"+a(t)+\" but \"+A(e)+\" found.\"};function GS(t){if(t.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let e=1/0,n=-1/0,o=1/0,i=-1/0,r=s=\u003e{e=Math.min(e,s.x),n=Math.max(n,s.x),o=Math.min(o,s.y),i=Math.max(i,s.y)};return t.forEach(s=\u003e{switch(s.type){case\"path\":s.points.forEach(r);break;case\"text\":r({x:s.x,y:s.y});break;case\"circle\":{let{x:a,y:A,radius:c}=s;r({x:a-c,y:A-c}),r({x:a+c,y:A+c});break}case\"box\":{let{x:a,y:A,width:c,height:l}=s,u=c/2,g=l/2;r({x:a-u,y:A-g}),r({x:a+u,y:A+g});break}}}),{minX:e,maxX:n,minY:o,maxY:i}}var onr=(t,e=\"right\")=\u003e{switch(e){case\"down\":switch(t){case\"middle_top\":return\"middle_right\";case\"middle_bottom\":return\"middle_left\";case\"middle_left\":return\"middle_bottom\";case\"middle_right\":return\"middle_top\"}break;case\"up\":switch(t){case\"middle_top\":return\"middle_left\";case\"middle_bottom\":return\"middle_right\";case\"middle_left\":return\"middle_top\";case\"middle_right\":return\"middle_bottom\"}break;case\"left\":switch(t){case\"middle_top\":return\"middle_bottom\";case\"middle_bottom\":return\"middle_top\";case\"middle_left\":return\"middle_right\";case\"middle_right\":return\"middle_left\"}break;case\"right\":return t}return t},hK=(t,e)=\u003e{let{primitives:n,center:o,ports:i,size:r}=t,s=H1e({a:1,b:0,c:0,d:-1,e:0,f:2*o.y}),a=n.map(c=\u003e{switch(c={...c},c.type){case\"path\":return{...c,points:c.points.map(h=\u003eGE(s,h))};case\"text\":let l=GE(s,{x:c.x,y:c.y}),u={top_left:\"bottom_left\",top_right:\"bottom_right\",bottom_left:\"top_left\",bottom_right:\"top_right\",center:\"center\",middle_top:\"middle_bottom\",middle_bottom:\"middle_top\",middle_left:\"middle_left\",middle_right:\"middle_right\"};return{...c,x:l.x,y:l.y,anchor:u[c.anchor]};case\"circle\":case\"box\":let g=GE(s,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),A=i.map(c=\u003e({...c,...GE(s,c)}));return{primitives:a,center:o,ports:A,size:r,...e}},pK=(t,e)=\u003e{let{primitives:n,center:o,ports:i,size:r}=t,s=H1e({a:-1,b:0,c:0,d:1,e:0,f:2*o.x}),a=n.map(c=\u003e{switch(c={...c},c.type){case\"path\":return{...c,points:c.points.map(h=\u003eGE(s,h))};case\"text\":let l=GE(s,{x:c.x,y:c.y}),u={top_left:\"top_right\",top_right:\"top_left\",bottom_left:\"bottom_right\",bottom_right:\"bottom_left\",center:\"center\",middle_top:\"middle_top\",middle_bottom:\"middle_bottom\",middle_left:\"middle_right\",middle_right:\"middle_left\"};return{...c,x:l.x,y:l.y,anchor:u[c.anchor]};case\"circle\":case\"box\":let g=GE(s,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),A=i.map(c=\u003e({...c,...GE(s,c)}));return{primitives:a,center:o,ports:A,size:r,...e}},nte=(t,e)=\u003e{let{newOrientation:n,overrides:o}=e,i={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},r=tnr(n?i[n]:Math.PI/2,t.center.x,t.center.y),{primitives:s,center:a,size:A,ports:c}=t,l=s.map(h=\u003e{switch(h={...h},h.type){case\"path\":return{...h,points:h.points.map(_=\u003eGE(r,_))};case\"text\":let d=GE(r,{x:h.x,y:h.y});return h.anchor=onr(h.anchor,n??\"right\"),{...h,x:d.x,y:d.y};case\"circle\":let p=GE(r,{x:h.x,y:h.y});return{...h,x:p.x,y:p.y};case\"box\":let m=GE(r,{x:h.x,y:h.y});return{...h,x:m.x,y:m.y,width:h.height,height:h.width}}}),u=c.map(h=\u003e({...h,...GE(r,h)})),g=GS(l);return{primitives:l,center:a,ports:u,size:{width:g.maxX-g.minX,height:g.maxY-g.minY},...o}},si=(t,e=\"down\",n={})=\u003ente(t,{newOrientation:e,overrides:n}),inr=class{symbol;constructor(t){this.symbol=JSON.parse(JSON.stringify(t)),this.symbol.size=this.computeSize()}changeTextAnchor(t,e,n){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(o=\u003eo.type===\"text\"\u0026\u0026o.text===t?{...o,anchor:e,...n?{x:o.x+n.x,y:o.y+n.y}:{}}:o)},this}labelPort(t,e){return this.symbol={...this.symbol,ports:this.symbol.ports.map(n=\u003en.labels.includes(t)?{...n,labels:e}:n)},this}rotateRightFacingSymbol(t){return this.symbol=nte(this.symbol,{newOrientation:t}),this}computeSize(){let t=GS(this.symbol.primitives);return{width:t.maxX-t.minX,height:t.maxY-t.minY}}build(){return{...this.symbol,size:this.computeSize()}}},Ln=t=\u003e{let e=t.primitives??[...Object.values(t.paths??{}),...Object.values(t.texts??{}),...Object.values(t.circles??{}),...Object.values(t.rects??{})],n=t.ports??Object.entries(t.refblocks).flatMap(([i,r])=\u003e[{...r,labels:[i]}]),o=t.center??{x:t.bounds.centerX,y:t.bounds.centerY};return n.length===2\u0026\u0026(o={x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2}),new inr({...t,primitives:e,ports:n,center:o})},mK={paths:{path11:{type:\"path\",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:\"primary\",fill:!1},path12:{type:\"path\",points:[{x:.29,y:.04},{x:.54,y:.04}],color:\"primary\",fill:!1},\"path11-5-5\":{type:\"path\",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:\"primary\",fill:!1},path17:{type:\"path\",points:[{x:0,y:-.13},{x:.07,y:-.11}],color:\"primary\",fill:!1},path18:{type:\"path\",points:[{x:.07,y:-.11},{x:.14,y:-.13}],color:\"primary\",fill:!1},path19:{type:\"path\",points:[{x:-.15,y:-.13},{x:-.07,y:-.11}],color:\"primary\",fill:!1},path20:{type:\"path\",points:[{x:-.07,y:-.11},{x:0,y:-.13}],color:\"primary\",fill:!1}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:\"circle\",x:0,y:.04,radius:.29,color:\"primary\",fill:!1}}},{paths:rnr,bounds:G1e,refblocks:tCn,circles:snr}=mK,anr=Ln({primitives:[...Object.values(rnr),...Object.values(snr),{type:\"text\",text:\"{REF}\",x:-.15,y:.3894553499999995},{type:\"text\",text:\"{VAL}\",x:.15,y:.3894553499999995}],ports:[{...tCn.left1,labels:[\"1\"]},{...tCn.right1,labels:[\"2\"]}],size:{width:G1e.width,height:G1e.height},center:{x:G1e.centerX,y:G1e.centerY}}).rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),{paths:Anr,bounds:Y1e,refblocks:nCn,circles:cnr}=mK,lnr=Ln({primitives:[...Object.values(Anr),...Object.values(cnr),{type:\"text\",text:\"{REF}\",x:-0,y:.4094553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:-.4094553499999995}],ports:[{...nCn.left1,labels:[\"1\"]},{...nCn.right1,labels:[\"2\"]}],size:{width:Y1e.width,height:Y1e.height},center:{x:Y1e.centerX,y:Y1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"right\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:unr,bounds:U1e,refblocks:oCn,circles:gnr}=mK,dnr=Ln({primitives:[...Object.values(unr),...Object.values(gnr),{type:\"text\",text:\"{REF}\",x:-0,y:-.3094553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:.4094553499999995}],ports:[{...oCn.left1,labels:[\"1\"]},{...oCn.right1,labels:[\"2\"]}],size:{width:U1e.width,height:U1e.height},center:{x:U1e.centerX,y:U1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"left\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:hnr,bounds:K1e,refblocks:iCn,circles:pnr}=mK,mnr=Ln({primitives:[...Object.values(hnr),...Object.values(pnr),{type:\"text\",text:\"{REF}\",x:-0,y:.4094553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:-.4094553499999995}],ports:[{...iCn.left1,labels:[\"1\"]},{...iCn.right1,labels:[\"2\"]}],size:{width:K1e.width,height:K1e.height},center:{x:K1e.centerX,y:K1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"right\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:_nr,bounds:V1e,refblocks:rCn,circles:fnr}=mK,Inr=Ln({primitives:[...Object.values(_nr),...Object.values(fnr),{type:\"text\",text:\"{REF}\",x:.15,y:-.2894553499999995},{type:\"text\",text:\"{VAL}\",x:-.15,y:-.2894553499999995}],ports:[{...rCn.left1,labels:[\"1\"]},{...rCn.right1,labels:[\"2\"]}],size:{width:V1e.width,height:V1e.height},center:{x:V1e.centerX,y:V1e.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),{paths:Cnr,bounds:z1e,refblocks:sCn,circles:ynr}=mK,xnr=Ln({primitives:[...Object.values(Cnr),...Object.values(ynr),{type:\"text\",text:\"{REF}\",x:.15,y:-.2894553499999995},{type:\"text\",text:\"{VAL}\",x:-.15,y:-.2894553499999995}],ports:[{...sCn.left1,labels:[\"1\"]},{...sCn.right1,labels:[\"2\"]}],size:{width:z1e.width,height:z1e.height},center:{x:z1e.centerX,y:z1e.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),_K={paths:{path40:{type:\"path\",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:\"primary\",fill:!1},path41:{type:\"path\",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:\"primary\",fill:!1},path42:{type:\"path\",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:\"primary\",fill:!1},path43:{type:\"path\",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:\"primary\",fill:!1},path44:{type:\"path\",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:\"primary\",fill:!1},\"path44-0\":{type:\"path\",points:[{x:.52,y:.04},{x:.15,y:.04}],color:\"primary\",fill:!1},\"path43-8\":{type:\"path\",points:[{x:.14,y:.18},{x:.08,y:.2}],color:\"primary\",fill:!1},\"path43-8-3\":{type:\"path\",points:[{x:.21,y:-.11},{x:.15,y:-.09}],color:\"primary\",fill:!1}},texts:{top1:{type:\"text\",text:\"{REF}\",x:-.01,y:.27},bottom1:{type:\"text\",text:\"{VAL}\",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Enr,texts:Vmr,bounds:J1e,refblocks:aCn,circles:Bnr}=_K,bnr=Ln({primitives:[...Object.values(Enr),...Object.values(Bnr),{type:\"text\",text:\"{REF}\",x:-.15,y:.3294553499999995},{type:\"text\",text:\"{VAL}\",x:.15,y:.3294553499999995}],ports:[{...aCn.left1,labels:[\"1\"]},{...aCn.right1,labels:[\"2\"]}],size:{width:J1e.width,height:J1e.height},center:{x:J1e.centerX,y:J1e.centerY}}).rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),Snr=Ln(_K).changeTextAnchor(\"{VAL}\",\"middle_top\").labelPort(\"left1\",[\"1\",\"neg\"]).labelPort(\"right1\",[\"2\",\"pos\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:Qnr,texts:zmr,bounds:W1e,refblocks:ACn,circles:vnr}=_K,wnr=Ln({primitives:[...Object.values(Qnr),...Object.values(vnr),{type:\"text\",text:\"{REF}\",x:-0,y:-.2294553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:.3294553499999995}],ports:[{...ACn.left1,labels:[\"1\"]},{...ACn.right1,labels:[\"2\"]}],size:{width:W1e.width,height:W1e.height},center:{x:W1e.centerX,y:W1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"left\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),Pnr=Ln(_K).changeTextAnchor(\"{VAL}\",\"middle_top\").labelPort(\"left1\",[\"1\",\"neg\"]).labelPort(\"right1\",[\"2\",\"pos\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:Mnr,texts:Jmr,bounds:j1e,refblocks:cCn,circles:Dnr}=_K,Nnr=Ln({primitives:[...Object.values(Mnr),...Object.values(Dnr),{type:\"text\",text:\"{REF}\",x:.15,y:-.2294553499999995},{type:\"text\",text:\"{VAL}\",x:-.15,y:-.2294553499999995}],ports:[{...cCn.left1,labels:[\"1\"]},{...cCn.right1,labels:[\"2\"]}],size:{width:j1e.width,height:j1e.height},center:{x:j1e.centerX,y:j1e.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),{paths:Rnr,texts:Wmr,bounds:$1e,refblocks:lCn,circles:Tnr}=_K,knr=Ln({primitives:[...Object.values(Rnr),...Object.values(Tnr),{type:\"text\",text:\"{REF}\",x:.15,y:-.2294553499999995},{type:\"text\",text:\"{VAL}\",x:-.15,y:-.2294553499999995}],ports:[{...lCn.left1,labels:[\"1\"]},{...lCn.right1,labels:[\"2\"]}],size:{width:$1e.width,height:$1e.height},center:{x:$1e.centerX,y:$1e.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),pZe={paths:{path40:{type:\"path\",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:\"primary\",fill:!1},path41:{type:\"path\",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:\"primary\",fill:!1},path42:{type:\"path\",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:\"primary\",fill:!1},path43:{type:\"path\",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:\"primary\",fill:!1},path44:{type:\"path\",points:[{x:.14,y:.04},{x:-.52,y:.04}],color:\"primary\",fill:!1},\"path44-0\":{type:\"path\",points:[{x:.52,y:.04},{x:.15,y:.04}],color:\"primary\",fill:!1},\"path43-8\":{type:\"path\",points:[{x:.18,y:.18},{x:.11,y:.18}],color:\"primary\",fill:!1},\"path43-8-8\":{type:\"path\",points:[{x:.18,y:-.09},{x:.11,y:-.09}],color:\"primary\",fill:!1}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Fnr,bounds:q1e,refblocks:uCn,circles:Lnr}=pZe,Hnr=Ln({primitives:[...Object.values(Fnr),...Object.values(Lnr),{type:\"text\",text:\"{REF}\",x:-.16,y:.2294553499999995},{type:\"text\",text:\"{VAL}\",x:.16,y:.2294553499999995}],ports:[{...uCn.left1,labels:[\"1\"]},{...uCn.right1,labels:[\"2\"]}],size:{width:q1e.width,height:q1e.height},center:{x:q1e.centerX,y:q1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").build(),{paths:Onr,bounds:X1e,refblocks:gCn,circles:Gnr}=pZe,dCn=Ln({primitives:[...Object.values(Onr),...Object.values(Gnr),{type:\"text\",text:\"{REF}\",x:-1118e-7,y:-.18},{type:\"text\",text:\"{VAL}\",x:1118e-7,y:.2738453}],ports:[{...gCn.left1,labels:[\"1\"]},{...gCn.right1,labels:[\"2\"]}],size:{width:X1e.width,height:X1e.height},center:{x:X1e.centerX,y:X1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"left\").labelPort(\"left1\",[\"2\"]).labelPort(\"right1\",[\"1\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),{paths:Ynr,bounds:Z1e,refblocks:hCn,circles:Unr}=pZe,Knr=Ln({primitives:[...Object.values(Ynr),...Object.values(Unr),{type:\"text\",text:\"{REF}\",x:-.0050250999999996715,y:.27384529999999985,anchor:\"middle_left\"},{type:\"text\",text:\"{VAL}\",x:-.00011179999999999524,y:-.27384530000000007,anchor:\"middle_left\"}],ports:[{...hCn.left1,labels:[\"1\"]},{...hCn.right1,labels:[\"2\"]}],size:{width:Z1e.width,height:Z1e.height},center:{x:Z1e.centerX,y:Z1e.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").labelPort(\"right1\",[\"2\"]).labelPort(\"left1\",[\"1\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),mZe=si(dCn,\"down\"),_Ze=mZe.primitives.find(t=\u003et.type===\"text\"\u0026\u0026t.text===\"{REF}\"),fZe=mZe.primitives.find(t=\u003et.type===\"text\"\u0026\u0026t.text===\"{VAL}\");_Ze.anchor=\"middle_left\",fZe.anchor=\"middle_left\",_Ze.x=.25,_Ze.y+=.21,fZe.y-=.21,fZe.x=.25;var Vnr=mZe,ote={paths:{path43:{type:\"path\",points:[{x:-.06,y:.19},{x:-.06,y:-.12}],color:\"primary\",fill:!1},\"path43-6\":{type:\"path\",points:[{x:.02,y:.13},{x:.02,y:-.06}],color:\"primary\",fill:!1},path44:{type:\"path\",points:[{x:-.06,y:.03},{x:-.5,y:.03}],color:\"primary\",fill:!1},\"path44-0\":{type:\"path\",points:[{x:.5,y:.03},{x:.03,y:.03}],color:\"primary\",fill:!1}},texts:{top1:{type:\"text\",text:\"{REF}\",x:-.03,y:.27},bottom1:{type:\"text\",text:\"{VAL}\",x:-.03,y:-.28}},refblocks:{left1:{x:-.5,y:.03},right1:{x:.5,y:.03}},bounds:{width:1,height:.29,centerX:0,centerY:.06},circles:{}},{paths:znr,bounds:pCn,refblocks:mCn,circles:Jnr}=ote,Wnr=Ln({primitives:[...Object.values(znr),...Object.values(Jnr),{type:\"text\",text:\"{REF}\",x:-.2,y:.31},{type:\"text\",text:\"{VAL}\",x:.2,y:.31}],ports:[{...mCn.left1,labels:[\"1\"]},{...mCn.right1,labels:[\"2\"]}],center:{x:pCn.centerX,y:pCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"down\").changeTextAnchor(\"{REF}\",\"middle_left\").build(),jnr={...Wnr,size:{width:1,height:.9}};function Gl(t){let e=t.size;if(!e){let n=GS(t.primitives);e={width:n.maxX-n.minX,height:n.maxY-n.minY}}return{...t,size:e}}var{paths:$nr,texts:_Cn,bounds:eIe,refblocks:fCn,circles:qnr}=ote,ICn=Gl({primitives:[...Object.values($nr),...Object.values(qnr),{..._Cn.top1,anchor:\"middle_bottom\"},{..._Cn.bottom1,anchor:\"middle_top\"}],ports:[{...fCn.left1,labels:[\"1\"]},{...fCn.right1,labels:[\"2\"]}],size:{width:eIe.width,height:eIe.height},center:{x:eIe.centerX,y:eIe.centerY}}),{paths:Xnr,bounds:CCn,refblocks:yCn,circles:Znr}=ote,eor=Ln({primitives:[...Object.values(Xnr),...Object.values(Znr),{type:\"text\",text:\"{REF}\",x:0,y:-.22},{type:\"text\",text:\"{VAL}\",x:0,y:.28}],ports:[{...yCn.left1,labels:[\"1\"]},{...yCn.right1,labels:[\"2\"]}],center:{x:CCn.centerX,y:CCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"left\").changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),tor={...eor,size:{width:1,height:.65}},{paths:nor,bounds:xCn,refblocks:ECn,circles:oor}=ote,ior=Ln({primitives:[...Object.values(nor),...Object.values(oor),{type:\"text\",text:\"{REF}\",x:0,y:.28},{type:\"text\",text:\"{VAL}\",x:0,y:-.22}],ports:[{...ECn.left1,labels:[\"1\"]},{...ECn.right1,labels:[\"2\"]}],center:{x:xCn.centerX,y:xCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"right\").changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),ror={...ior,size:{width:1,height:.65}},{paths:sor,bounds:BCn,refblocks:bCn,circles:aor}=ote,Aor=Ln({primitives:[...Object.values(sor),...Object.values(aor),{type:\"text\",text:\"{REF}\",x:.2,y:-.25},{type:\"text\",text:\"{VAL}\",x:-.2,y:-.25}],ports:[{...bCn.left1,labels:[\"1\"]},{...bCn.right1,labels:[\"2\"]}],center:{x:BCn.centerX,y:BCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"up\").changeTextAnchor(\"{REF}\",\"middle_left\").build(),cor={...Aor,size:{width:1,height:.9}},lor=nte(ICn,{newOrientation:\"up\"}),tIe={paths:{path1:{type:\"path\",points:[{x:-.3,y:0},{x:-.19998,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path2:{type:\"path\",points:[{x:.19998,y:0},{x:.3,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path3:{type:\"path\",points:[{x:-.19998,y:.07998},{x:.19998,y:.07998},{x:.19998,y:-.07998},{x:-.19998,y:-.07998},{x:-.19998,y:.07998}],color:\"primary\",fill:!1,strokeWidth:.012}},refblocks:{left1:{x:-.3,y:0},right1:{x:.3,y:0}},bounds:{centerX:0,centerY:0},circles:{}},{paths:uor,bounds:SCn,refblocks:QCn,circles:gor}=tIe,dor=Ln({primitives:[...Object.values(uor),...Object.values(gor),{type:\"text\",text:\"{REF}\",x:-.16,y:.16},{type:\"text\",text:\"{VAL}\",x:.16,y:.16}],ports:[{...QCn.left1,labels:[\"1\"]},{...QCn.right1,labels:[\"2\"]}],center:{x:SCn.centerX,y:SCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").build(),hor={...dor,size:{width:.9,height:.6}},{paths:por,bounds:vCn,refblocks:wCn,circles:mor}=tIe,_or=Ln({primitives:[...Object.values(por),...Object.values(mor),{type:\"text\",text:\"{REF}\",x:0,y:-.16},{type:\"text\",text:\"{VAL}\",x:0,y:.16}],ports:[{...wCn.left1,labels:[\"1\"]},{...wCn.right1,labels:[\"2\"]}],center:{x:vCn.centerX,y:vCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"left\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),Ior={..._or,size:{width:.6,height:.65}},{paths:Cor,bounds:PCn,refblocks:MCn,circles:yor}=tIe,xor=Ln({primitives:[...Object.values(Cor),...Object.values(yor),{type:\"text\",text:\"{REF}\",x:0,y:.16},{type:\"text\",text:\"{VAL}\",x:0,y:-.16}],ports:[{...MCn.left1,labels:[\"1\"]},{...MCn.right1,labels:[\"2\"]}],center:{x:PCn.centerX,y:PCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"right\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),Eor={...xor,size:{width:.6,height:.65}},nIe={paths:{path2:{type:\"path\",points:[{x:.15,y:-.01},{x:.55,y:-.01}],color:\"primary\",fill:!0},\"path2-5\":{type:\"path\",points:[{x:-.15,y:.06},{x:.14,y:.06}],color:\"primary\",fill:!0},\"path2-5-1\":{type:\"path\",points:[{x:.14,y:.06},{x:.14,y:-.08}],color:\"primary\",fill:!0},\"path2-5-1-6\":{type:\"path\",points:[{x:-.16,y:.06},{x:-.16,y:-.08}],color:\"primary\",fill:!0},\"path2-5-4\":{type:\"path\",points:[{x:-.15,y:-.08},{x:.14,y:-.08}],color:\"primary\",fill:!0},\"path2-9\":{type:\"path\",points:[{x:-.55,y:-.01},{x:-.17,y:-.01}],color:\"primary\",fill:!0}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{width:1.16,height:.35,centerX:0,centerY:0},circles:{}},{paths:Bor,bounds:oIe,refblocks:DCn,circles:bor}=nIe,Sor=Ln({primitives:[...Object.values(Bor),...Object.values(bor),{type:\"text\",text:\"{REF}\",x:-.2,y:.1404553499999995},{type:\"text\",text:\"{VAL}\",x:.2,y:.1494553499999995}],ports:[{...DCn.left1,labels:[\"1\"]},{...DCn.right1,labels:[\"2\"]}],size:{width:oIe.width,height:oIe.height},center:{x:oIe.centerX,y:oIe.centerY}}).rotateRightFacingSymbol(\"down\").labelPort(\"left\",[\"1\"]).labelPort(\"right\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),{paths:Qor,bounds:iIe,refblocks:NCn,circles:vor}=nIe,wor=Ln({primitives:[...Object.values(Qor),...Object.values(vor),{type:\"text\",text:\"{REF}\",x:0,y:-.2294553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:.1704553499999995}],ports:[{...NCn.left1,labels:[\"1\"]},{...NCn.right1,labels:[\"2\"]}],size:{width:iIe.width,height:iIe.height},center:{x:iIe.centerX,y:iIe.centerY}}).rotateRightFacingSymbol(\"left\").labelPort(\"left\",[\"1\"]).labelPort(\"right\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").changeTextAnchor(\"{VAL}\",\"middle_top\").build(),{paths:Por,bounds:rIe,refblocks:RCn,circles:Mor}=nIe,Dor=Ln({primitives:[...Object.values(Por),...Object.values(Mor),{type:\"text\",text:\"{REF}\",x:0,y:.2294553499999995},{type:\"text\",text:\"{VAL}\",x:0,y:-.1704553499999995}],ports:[{...RCn.left1,labels:[\"1\"]},{...RCn.right1,labels:[\"2\"]}],size:{width:rIe.width,height:rIe.height},center:{x:rIe.centerX,y:rIe.centerY}}).rotateRightFacingSymbol(\"right\").labelPort(\"left\",[\"1\"]).labelPort(\"right\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").changeTextAnchor(\"{VAL}\",\"middle_top\").build(),{paths:Nor,bounds:sIe,refblocks:TCn,circles:Ror}=nIe,Tor=Ln({primitives:[...Object.values(Nor),...Object.values(Ror),{type:\"text\",text:\"{REF}\",x:.2,y:-.1404553499999995},{type:\"text\",text:\"{VAL}\",x:-.2,y:-.1494553499999995}],ports:[{...TCn.left1,labels:[\"1\"]},{...TCn.right1,labels:[\"2\"]}],size:{width:sIe.width,height:sIe.height},center:{x:sIe.centerX,y:sIe.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left\",[\"1\"]).labelPort(\"right\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").changeTextAnchor(\"{VAL}\",\"middle_left\").build(),{paths:kor,bounds:kCn,refblocks:FCn,circles:For}=tIe,Lor=Ln({primitives:[...Object.values(kor),...Object.values(For),{type:\"text\",text:\"{REF}\",x:.16,y:-.16},{type:\"text\",text:\"{VAL}\",x:-.16,y:-.16}],ports:[{...FCn.left1,labels:[\"1\"]},{...FCn.right1,labels:[\"2\"]}],center:{x:kCn.centerX,y:kCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").build(),Hor={...Lor,size:{width:.9,height:.6}},IZe={paths:{\"horizontal-bar\":{type:\"path\",points:[{x:-.4,y:0},{x:.4,y:0}],color:\"primary\",fill:!1},\"middle-dash-1\":{type:\"path\",points:[{x:0,y:.2},{x:0,y:.07}],color:\"primary\",fill:!1},\"middle-dash-2\":{type:\"path\",points:[{x:0,y:.01},{x:0,y:-.12}],color:\"primary\",fill:!1},\"middle-dash-3\":{type:\"path\",points:[{x:0,y:-.18},{x:0,y:-.31}],color:\"primary\",fill:!1},\"left-vertical\":{type:\"path\",points:[{x:-.25,y:0},{x:-.25,y:-.2}],color:\"primary\",fill:!1},\"right-vertical\":{type:\"path\",points:[{x:.25,y:0},{x:.25,y:-.2}],color:\"primary\",fill:!1},\"left-ground\":{type:\"path\",points:[{x:-.3,y:-.2},{x:-.25,y:-.3},{x:-.2,y:-.2},{x:-.3,y:-.2}],color:\"primary\",fill:!1},\"right-ground\":{type:\"path\",points:[{x:.2,y:-.2},{x:.25,y:-.3},{x:.3,y:-.2},{x:.2,y:-.2}],color:\"primary\",fill:!1}},refblocks:{left1:{x:-.4,y:0},right1:{x:.4,y:0}},bounds:{centerX:0,centerY:-.02},circles:{}},{paths:Oor,bounds:LCn,refblocks:HCn,circles:Gor}=IZe,Yor=Ln({primitives:[...Object.values(Oor),...Object.values(Gor),{type:\"text\",text:\"{REF}\",x:0,y:.2594553499999995}],ports:[{...HCn.left1,labels:[\"1\"]},{...HCn.right1,labels:[\"2\"]}],center:{x:LCn.centerX,y:LCn.centerY}}).changeTextAnchor(\"{VAL}\",\"middle_bottom\").rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_left\").build(),{paths:Uor,bounds:OCn,refblocks:GCn,circles:Kor}=IZe,YCn=Ln({primitives:[...Object.values(Uor),...Object.values(Kor),{type:\"text\",text:\"{REF}\",x:0,y:.2594553499999995}],ports:[{...GCn.left1,labels:[\"1\"]},{...GCn.right1,labels:[\"2\"]}],center:{x:OCn.centerX,y:OCn.centerY}}).rotateRightFacingSymbol(\"right\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),Vor=pK(YCn),{paths:zor,bounds:UCn,refblocks:KCn,circles:Jor}=IZe,Wor=Ln({primitives:[...Object.values(zor),...Object.values(Jor),{type:\"text\",text:\"{REF}\",x:0,y:.2594553499999995}],ports:[{...KCn.left1,labels:[\"1\"]},{...KCn.right1,labels:[\"2\"]}],center:{x:UCn.centerX,y:UCn.centerY}}).rotateRightFacingSymbol(\"up\").labelPort(\"left1\",[\"1\"]).labelPort(\"right1\",[\"2\"]).changeTextAnchor(\"{REF}\",\"middle_right\").build(),aIe={paths:{path27:{type:\"path\",points:[{x:.3,y:0},{x:.06,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path28:{type:\"path\",points:[{x:-.06,y:0},{x:-.3,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path29:{type:\"path\",points:[{x:.06,y:.16002},{x:.06,y:-.16002}],color:\"primary\",fill:!1,strokeWidth:.012},path30:{type:\"path\",points:[{x:-.06,y:.16002},{x:-.06,y:-.16002}],color:\"primary\",fill:!1,strokeWidth:.012}},texts:{top1:{type:\"text\",text:\"{REF}\",x:0,y:.24,anchor:\"middle_bottom\"},bottom1:{type:\"text\",text:\"{VAL}\",x:0,y:-.24,anchor:\"middle_top\"}},refblocks:{left1:{x:-.3,y:0},right1:{x:.3,y:0}},bounds:{minX:-.3,maxX:.3,minY:-.24,maxY:.24,width:.6,height:.48,centerX:0,centerY:0},circles:{}},{paths:jor,texts:jmr,bounds:AIe,refblocks:VCn,circles:$or}=aIe,qor=Ln({primitives:[...Object.values(jor),...Object.values($or),{type:\"text\",text:\"{REF}\",x:-.2,y:.115},{type:\"text\",text:\"{VAL}\",x:.2,y:.115}],ports:[{...VCn.left1,labels:[\"1\"]},{...VCn.right1,labels:[\"2\"]}],size:{width:AIe.width,height:AIe.height},center:{x:AIe.centerX,y:AIe.centerY}}).changeTextAnchor(\"{VAL}\",\"top_left\").rotateRightFacingSymbol(\"down\").labelPort(\"left1\",[\"1\",\"pos\"]).labelPort(\"right1\",[\"2\",\"neg\"]).changeTextAnchor(\"{REF}\",\"bottom_left\").build(),Xor={...qor,size:{width:.9,height:.6}},Zor=Ln(aIe).changeTextAnchor(\"{VAL}\",\"middle_top\").rotateRightFacingSymbol(\"right\").labelPort(\"left1\",[\"2\",\"neg\"]).labelPort(\"right1\",[\"1\",\"pos\"]).changeTextAnchor(\"{REF}\",\"middle_bottom\").build(),eir={...Zor,size:{width:.6,height:.65}},cIe={paths:{path27:{type:\"path\",points:[{x:.3,y:0},{x:657e-6,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path28:{type:\"path\",points:[{x:-.038683,y:0},{x:-.3,y:0}],color:\"primary\",fill:!1,strokeWidth:.012},path30:{type:\"path\",points:[{x:-.074255,y:.16002},{x:-.074255,y:.16002},{x:-.069544,y:.149352},{x:-.065126,y:.138684},{x:-.061005,y:.128016},{x:-.057182,y:.117348},{x:-.053663,y:.10668},{x:-.05045,y:.096012},{x:-.047547,y:.085344},{x:-.044957,y:.074676},{x:-.042684,y:.064008},{x:-.040732,y:.05334},{x:-.039103,y:.042672},{x:-.037801,y:.032004},{x:-.03683,y:.021336},{x:-.036193,y:.010668},{x:-.035893,y:0},{x:-.036193,y:-.010668},{x:-.03683,y:-.021336},{x:-.037801,y:-.032004},{x:-.039103,y:-.042672},{x:-.040732,y:-.05334},{x:-.042684,y:-.064008},{x:-.044957,y:-.074676},{x:-.047547,y:-.085344},{x:-.05045,y:-.096012},{x:-.053663,y:-.10668},{x:-.057182,y:-.117348},{x:-.061005,y:-.128016},{x:-.065126,y:-.138684},{x:-.069544,y:-.149352},{x:-.074255,y:-.16002},{x:-.074255,y:-.16002}],color:\"primary\",fill:!1,strokeWidth:.012},\"path30-7\":{type:\"path\",points:[{x:-385e-6,y:.16002},{x:-385e-6,y:-.16002}],color:\"primary\",fill:!1,strokeWidth:.012},\"path30-9-2\":{type:\"path\",points:[{x:.156026,y:.2},{x:.085846,y:.2}],color:\"primary\",fill:!1,strokeWidth:.012},\"path30-9-2-9\":{type:\"path\",points:[{x:.120936,y:.16491},{x:.120936,y","content_mimetype":"text/plain","created_at":"2026-10-05T13:15:48.962Z"}; window.SSR_PACKAGE_RELEASES = [{"package_release_id":"a56db1f7-99bf-4f14-b32e-ab5431f039d0","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.19","github_commit_sha":null,"is_locked":false,"is_latest":true,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T13:15:23.548Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-6eb8ae0e3705282d2c5b6af9de5b0a5a","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a56db1f7-99bf-4f14-b32e-ab5431f039d0\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a56db1f7-99bf-4f14-b32e-ab5431f039d0\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a56db1f7-99bf-4f14-b32e-ab5431f039d0\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"8c707e6d-446a-4b11-8780-d980a2b6494b","user_code_job_started_at":"2026-10-05T13:30:31.188Z","user_code_job_completed_at":"2026-10-05T13:36:06.374Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=fc822d6e83ede29cb53d172f7155634cdc596139a58cdb1c014d59d17492c7e1","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"b0d81c84-a226-464b-84a4-a655185a3a25","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.18","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T12:40:09.172Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-5e6dee74e06130ba1abedd4457510217","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b0d81c84-a226-464b-84a4-a655185a3a25\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b0d81c84-a226-464b-84a4-a655185a3a25\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b0d81c84-a226-464b-84a4-a655185a3a25\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"2991f513-e5d8-4c7a-aaa0-2b7f2a68225d","user_code_job_started_at":"2026-10-05T12:42:32.098Z","user_code_job_completed_at":"2026-10-05T12:49:07.396Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=4f86521a8365124b06c76ccbd0aea9019032167491b5b467077c7a02ced49a41","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"4fa538fc-bfff-490e-9f59-243aaf206a0e","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.17","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T11:49:00.446Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-1c8ee8b89eec6e227c9616af021fb396","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=4fa538fc-bfff-490e-9f59-243aaf206a0e\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=4fa538fc-bfff-490e-9f59-243aaf206a0e\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=4fa538fc-bfff-490e-9f59-243aaf206a0e\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"5fc8d342-8923-4fa1-84aa-34984c9a77d2","user_code_job_started_at":"2026-10-05T11:50:18.413Z","user_code_job_completed_at":"2026-10-05T12:20:20.902Z","user_code_job_error":{"message":"Build timed out after 30 minutes","error_code":"user_code_job_timeout"},"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=213321f1092ec68a13466939f33e380ad9537c815ae2bf5594c11793768490c9","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"b67e103d-d359-4f47-b2a9-0f903c841431","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.16","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T11:17:26.970Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-bd0dfc621c57205fba9f8d8a2fe06917","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b67e103d-d359-4f47-b2a9-0f903c841431\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b67e103d-d359-4f47-b2a9-0f903c841431\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=b67e103d-d359-4f47-b2a9-0f903c841431\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"9c76ac3c-31ab-49c3-a2cf-c41ca2f64da1","user_code_job_started_at":"2026-10-05T11:19:43.035Z","user_code_job_completed_at":"2026-10-05T11:30:00.497Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=09c2571c8594cc5446af1ac461ebcbcf0adb0d8cbcae71522948e75d14fe4c8d","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"0bbc98b2-d526-41f0-b246-bed75ed24b86","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.15","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T10:46:55.472Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-715cefa259ee7f0247b1b614b14f8b7e","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=0bbc98b2-d526-41f0-b246-bed75ed24b86\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=0bbc98b2-d526-41f0-b246-bed75ed24b86\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=0bbc98b2-d526-41f0-b246-bed75ed24b86\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"18ce8d3d-ad7e-4cd0-811a-6afc0b8d5465","user_code_job_started_at":"2026-10-05T10:59:52.697Z","user_code_job_completed_at":"2026-10-05T11:07:38.031Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=7af4644656c74ce99e99241f2d5894cc1aa3ffa1341d798f79d619f1b39aeffa","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"e9f238ea-c9b4-46b5-8849-29781fd999f4","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.12","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T09:34:47.276Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-a0656aa2da3d10b804b917660ed827b2","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=e9f238ea-c9b4-46b5-8849-29781fd999f4\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=e9f238ea-c9b4-46b5-8849-29781fd999f4\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=e9f238ea-c9b4-46b5-8849-29781fd999f4\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"a96806df-4353-48e8-b890-c50f521cb7e3","user_code_job_started_at":"2026-10-05T09:51:54.289Z","user_code_job_completed_at":"2026-10-05T10:13:23.429Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=ca97a49f7a9ebf82d8b7f1f5f6cf5f4bead642d1fc3851e57dbcfe25c3ef045f","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"7367de0f-e2cf-43bb-94f0-2c5434bff2b2","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.11","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T09:14:49.936Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-61d9b2efba862b3954b4b2a65264fe42","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7367de0f-e2cf-43bb-94f0-2c5434bff2b2\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7367de0f-e2cf-43bb-94f0-2c5434bff2b2\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7367de0f-e2cf-43bb-94f0-2c5434bff2b2\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"8d3f4822-a570-4e98-9413-e2d5f629390c","user_code_job_started_at":"2026-10-05T09:15:54.152Z","user_code_job_completed_at":"2026-10-05T09:27:20.635Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=cfc8867bc4d639b40c0e74571f988aee8d776f2c8ce777e1897e84d476e1e7be","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"a9bd2d0b-8385-4ec9-9161-b4b045223edf","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.10","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T08:15:45.499Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-d404b30a0c8f20182d1ac6578217eada","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a9bd2d0b-8385-4ec9-9161-b4b045223edf\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a9bd2d0b-8385-4ec9-9161-b4b045223edf\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=a9bd2d0b-8385-4ec9-9161-b4b045223edf\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"3c1e0217-c73f-497c-a1d2-92490908d45c","user_code_job_started_at":"2026-10-05T08:20:44.239Z","user_code_job_completed_at":"2026-10-05T08:28:33.533Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=f0cda6b774cc88b59005d5b4fde56ae0dfceda649d56a89227d9eb5891788b45","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"634fb4eb-78e7-4dae-9a60-170630d10c39","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.9","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T07:49:23.366Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-b3ec16d1349b1d763cb802fb56c4eb5c","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=634fb4eb-78e7-4dae-9a60-170630d10c39\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=634fb4eb-78e7-4dae-9a60-170630d10c39\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=634fb4eb-78e7-4dae-9a60-170630d10c39\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"ba5f3a49-4474-4f6b-aaba-2bea883c2254","user_code_job_started_at":"2026-10-05T07:53:53.718Z","user_code_job_completed_at":"2026-10-05T08:04:14.215Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=a267d59279c15d74ab2f90a8c1647617b788e330ee29be5cef05c7dc72533493","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"53f45203-3e94-44cb-8e73-c8ed97d767d3","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.8","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T07:20:49.673Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-b2322aa668cde8ad296b75adca2b40e2","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=53f45203-3e94-44cb-8e73-c8ed97d767d3\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=53f45203-3e94-44cb-8e73-c8ed97d767d3\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=53f45203-3e94-44cb-8e73-c8ed97d767d3\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"4bd25e6a-980f-4d91-af03-8dcdabee4b24","user_code_job_started_at":"2026-10-05T07:22:15.388Z","user_code_job_completed_at":"2026-10-05T07:27:04.421Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=b512648421af19f71c7159c59da773f447b14befeabe06554abefa308b912d65","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"45d52ddf-a51d-46d4-9317-a78c01694cb1","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.7","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T05:38:14.445Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-d47c5b7e1407c9dcb4cbe5b9eac66a0f","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=45d52ddf-a51d-46d4-9317-a78c01694cb1\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=45d52ddf-a51d-46d4-9317-a78c01694cb1\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=45d52ddf-a51d-46d4-9317-a78c01694cb1\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"9145ecdb-39d1-4c86-8dcb-56dcb80ec739","user_code_job_started_at":"2026-10-05T05:42:40.257Z","user_code_job_completed_at":"2026-10-05T05:47:57.834Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=ce3d8d517d1ebc80458fafcf556332d5f49d7a1bceff2b1fe93c46de6452fc5a","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"d757a095-04de-48c8-b6e4-3d2ec8ce81cd","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.6","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T04:46:17.047Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-c97a22aae1657103e327908164f9c045","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=d757a095-04de-48c8-b6e4-3d2ec8ce81cd\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=d757a095-04de-48c8-b6e4-3d2ec8ce81cd\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=d757a095-04de-48c8-b6e4-3d2ec8ce81cd\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"513bdf82-a08d-49b9-a5b9-9034a97a809b","user_code_job_started_at":"2026-10-05T04:55:45.526Z","user_code_job_completed_at":"2026-10-05T05:03:03.781Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=e8de376a3c61eefc6f950e1bbd22fc81a72ed93da6f4b556d8fdc70dd7626038","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"29ddf4a0-6df5-4bf6-b7db-4ac4c7072c25","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.5","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T02:44:08.793Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-fcfb777c24f6df873e623a7d142514f0","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=29ddf4a0-6df5-4bf6-b7db-4ac4c7072c25\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=29ddf4a0-6df5-4bf6-b7db-4ac4c7072c25\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=29ddf4a0-6df5-4bf6-b7db-4ac4c7072c25\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"5948f3dd-37c3-4847-9494-13770e28b82c","user_code_job_started_at":"2026-10-05T02:52:43.128Z","user_code_job_completed_at":"2026-10-05T03:01:02.367Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=7fec255850c162f893ce5454cd1f55664114ec87478a9e657084e8e5e6ffc3a1","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"07c051a2-d349-46f2-9157-6c98cc3ae76d","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.4","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T01:35:01.188Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-fdefbc9b7a664cd926e8f2c3a463a4be","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=07c051a2-d349-46f2-9157-6c98cc3ae76d\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=07c051a2-d349-46f2-9157-6c98cc3ae76d\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=07c051a2-d349-46f2-9157-6c98cc3ae76d\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"6bbc2d0d-6fde-4113-9604-bb935d16d41d","user_code_job_started_at":"2026-10-05T01:39:51.775Z","user_code_job_completed_at":"2026-10-05T01:47:48.597Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=9e419461cdd6c04c78acd3264fdc71637b5a7e53e73d70d95fc8afd0f66aa118","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"97585b6d-8a91-4be0-bf4d-a168d61df90c","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.3","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-05T00:47:26.560Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-04010698d7538846241ce9b89224fd40","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=97585b6d-8a91-4be0-bf4d-a168d61df90c\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=97585b6d-8a91-4be0-bf4d-a168d61df90c\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=97585b6d-8a91-4be0-bf4d-a168d61df90c\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"bdbdb7ab-b4ca-40ce-bb80-7d791aaa4eed","user_code_job_started_at":"2026-10-05T00:50:25.910Z","user_code_job_completed_at":"2026-10-05T00:58:25.368Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=7a51abfa54e74e33e7a9d7fee115ddde0668908e770da41935d5fb91096d96bb","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"11a162c1-951f-47e3-8f83-660b7c8dec6b","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.2","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-04T20:42:25.857Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-b295b7fc212ec482ce2d90f1cc809bf9","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=11a162c1-951f-47e3-8f83-660b7c8dec6b\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=11a162c1-951f-47e3-8f83-660b7c8dec6b\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=11a162c1-951f-47e3-8f83-660b7c8dec6b\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"363c3448-fb09-4da6-b9bf-bc0e216b3531","user_code_job_started_at":"2026-10-04T22:04:21.772Z","user_code_job_completed_at":"2026-10-04T22:08:27.541Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=85b5b1bf068520a999c1e95c00bb11ca65b4c545a10dbb184d93a6d87476a69d","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"20c1facb-7cd6-4235-b2bc-6f24d9e89563","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.1","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-03T06:56:20.205Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-0aa20af2734ddbc93d819bac000d1aa4","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=20c1facb-7cd6-4235-b2bc-6f24d9e89563\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=20c1facb-7cd6-4235-b2bc-6f24d9e89563\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=20c1facb-7cd6-4235-b2bc-6f24d9e89563\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"0ea02129-f9cc-40f2-9cf2-8b08e970252a","user_code_job_started_at":"2026-10-03T07:53:29.792Z","user_code_job_completed_at":"2026-10-03T08:23:36.379Z","user_code_job_error":{"message":"Build timed out after 30 minutes","error_code":"user_code_job_timeout"},"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=87de178b6a93ad8f6ee24fae8e568d36c20bd3897f1a929bd42618fe4d3032a8","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null},{"package_release_id":"f050d04e-367c-49f8-869a-5a164b9c57c6","package_id":"2b60b995-332f-46c6-8360-e30a1b8dee13","version":"0.1.0","github_commit_sha":null,"is_locked":false,"is_latest":false,"ready_to_build":true,"is_pr_preview":false,"created_at":"2026-10-03T04:37:46.866Z","circuit_json_build_error":null,"circuit_json_build_error_last_updated_at":null,"has_transpiled":false,"transpilation_error":null,"transpilation_logs":null,"transpilation_in_progress":false,"transpilation_started_at":null,"transpilation_completed_at":null,"transpilation_is_stale":true,"transpilation_display_status":"pending","fs_sha":"md5-7749d273fff3d95957d72d46760a76d6","circuit_json_build_logs":null,"circuit_json_build_in_progress":false,"circuit_json_build_started_at":null,"circuit_json_build_completed_at":null,"circuit_json_build_is_stale":true,"circuit_json_build_display_status":"pending","image_generation_error":null,"image_generation_error_last_updated_at":null,"image_generation_logs":null,"image_generation_in_progress":false,"image_generation_started_at":null,"image_generation_completed_at":null,"image_generation_is_stale":true,"image_generation_display_status":"pending","pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=f050d04e-367c-49f8-869a-5a164b9c57c6\u0026file_path=dist%2Findex%2Fpcb.svg","sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=f050d04e-367c-49f8-869a-5a164b9c57c6\u0026file_path=dist%2Findex%2Fschematic.svg","cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=f050d04e-367c-49f8-869a-5a164b9c57c6\u0026file_path=dist%2Findex%2F3d.png","package_release_website_url":null,"display_status":"pending","latest_package_build_id":"284e991b-f173-46f7-beb2-c5d918bd6108","user_code_job_started_at":"2026-10-03T04:42:59.772Z","user_code_job_completed_at":"2026-10-03T04:46:38.270Z","user_code_job_error":null,"user_code_job_completed_logs":null,"user_code_job_log_stream_url":"https://usercode.tscircuit.com/user_code_jobs/view_log_stream?user_code_job_id=66e2eeea84f02308b7774bae328a63deac3599a68c496a213f856b3ae61e5c86","ai_review_requested":false,"github_pr_number":null,"github_pr_title":null,"github_branch_name":null}]; window.SSR_PACKAGE_BUILDS = []; window.SSR_RELATED_PACKAGES = [{"package_id":"d2ea0487-143c-447f-a62e-ab971c2524cd","creator_account_id":"9f398687-69d0-4ef4-a48c-bb6dc990e7df","latest_package_release_id":"bde55b83-e437-4d8f-b5c0-1e0b68a70ec3","last_built_release_id":"bde55b83-e437-4d8f-b5c0-1e0b68a70ec3","latest_package_release_fs_sha":"md5-4095a4495925ad2deb356dc9c3cccaaf","latest_pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=bde55b83-e437-4d8f-b5c0-1e0b68a70ec3\u0026file_path=dist%2Findex%2Fpcb.svg","latest_sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=bde55b83-e437-4d8f-b5c0-1e0b68a70ec3\u0026file_path=dist%2Findex%2Fschematic.svg","latest_cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=bde55b83-e437-4d8f-b5c0-1e0b68a70ec3\u0026file_path=dist%2Findex%2F3d.png","latest_version":"1.4.0","license":"unset","owner_org_id":"7ca3101d-0ece-4182-a775-d3aee7d7f0a0","org_owner_tscircuit_handle":"astra","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":null,"name":"astra/nema17-stepper-motor-controller-spring-clamp-rp2040","unscoped_name":"nema17-stepper-motor-controller-spring-clamp-rp2040","star_count":0,"created_at":"2026-09-26T19:14:57.511Z","updated_at":"2026-09-28T19:52:44.691Z","ai_description":"A 4-layer RP2040 controller board that negotiates USB‑C PD motor power and drives a NEMA17 stepper via a DRV8825, with current sensing, thermal shutdown, RGB status LED, buzzer alarm, optional AS5600 encoder, protection/filtering, and test points.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"same_author","thumbnail_url":"https://api.tscircuit.com/package_files/view?package_release_id=bde55b83-e437-4d8f-b5c0-1e0b68a70ec3\u0026file_path=dist%2Findex%2Fpcb.svg"},{"package_id":"7c4f7ef6-0c20-441e-b5a5-1952d955eccf","creator_account_id":"d16b4134-1b33-4d60-bdf2-151748766d5b","latest_package_release_id":"cbdd52b4-d52e-4095-8882-d107ff959339","last_built_release_id":"cbdd52b4-d52e-4095-8882-d107ff959339","latest_package_release_fs_sha":"md5-2ea962e9b2b863a7a4703b259838dc8e","latest_pcb_preview_image_url":"https://registry-api.tscircuit.com/package_files/view?package_release_id=cbdd52b4-d52e-4095-8882-d107ff959339\u0026file_path=dist%2Findex%2Fpcb.svg","latest_sch_preview_image_url":"https://registry-api.tscircuit.com/package_files/view?package_release_id=cbdd52b4-d52e-4095-8882-d107ff959339\u0026file_path=dist%2Findex%2Fschematic.svg","latest_cad_preview_image_url":"https://registry-api.tscircuit.com/package_files/download?package_release_id=cbdd52b4-d52e-4095-8882-d107ff959339\u0026file_path=dist%2Findex%2F3d.png","latest_version":"0.0.1","license":"unset","owner_org_id":"9e4219cf-4b9e-4932-9128-52cef42cad89","org_owner_tscircuit_handle":"0hmx3","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":"","name":"aura/diy-power-delivery-trigger","unscoped_name":"diy-power-delivery-trigger","star_count":0,"created_at":"2026-04-23T21:10:31.029Z","updated_at":"2026-04-25T11:57:14.077Z","ai_description":"This hardware design implements a USB Type-C port with supporting power management and signal conditioning components, including a USB-C connector, a FUSB302 USB-C port controller, ESD protection diodes, a buck converter for 3.3V power regulation, an STM32 microcontroller for control and processing, an RGB LED indicator, push button, terminal block connections, and associated filtering and support components.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"similar_ai_description","thumbnail_url":"https://registry-api.tscircuit.com/package_files/view?package_release_id=cbdd52b4-d52e-4095-8882-d107ff959339\u0026file_path=dist%2Findex%2Fpcb.svg"},{"package_id":"78c97ef5-3f00-466a-93ba-5ad748a0cb2d","creator_account_id":"9f398687-69d0-4ef4-a48c-bb6dc990e7df","latest_package_release_id":"43abb248-47c9-4cfd-9d4c-99af86d33572","last_built_release_id":"43abb248-47c9-4cfd-9d4c-99af86d33572","latest_package_release_fs_sha":"md5-f95e3b44ac11a208f017f25beb325180","latest_pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=43abb248-47c9-4cfd-9d4c-99af86d33572\u0026file_path=dist%2Findex%2Fpcb.svg","latest_sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=43abb248-47c9-4cfd-9d4c-99af86d33572\u0026file_path=dist%2Findex%2Fschematic.svg","latest_cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=43abb248-47c9-4cfd-9d4c-99af86d33572\u0026file_path=dist%2Findex%2F3d.png","latest_version":"1.3.4","license":"unset","owner_org_id":"2d29cfe5-d314-4a54-b56a-a6fa34c19af3","org_owner_tscircuit_handle":"muse1","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":null,"name":"muse/esp32-eink-display","unscoped_name":"esp32-eink-display","star_count":0,"created_at":"2026-10-03T00:27:01.165Z","updated_at":"2026-10-03T03:05:45.691Z","ai_description":"A 55×46 mm two-layer ESP32-S3 e-paper controller board with USB‑C power/programming, buck regulation, FPC display connector, UC8179-style boost/charge-pump circuitry, ESD protection, controls, and routed passive components.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"random","thumbnail_url":"https://api.tscircuit.com/package_files/view?package_release_id=43abb248-47c9-4cfd-9d4c-99af86d33572\u0026file_path=dist%2Findex%2Fpcb.svg"}]; window.SSR_PACKAGE_ROUTE = {"author":"astra","packageName":"am3352-sbc","packageNameWithScope":"astra/am3352-sbc","version":null,"isLegacyRoute":false,"kind":"file","filePath":"dist/viewer-part-09.txt"};

astra/am3352-sbc

A 4-layer AM3352 single-board computer with 128‑MiB DDR3, PMIC power regulation, USB‑C 5‑V PD input, dual USB host ports, HDMI output with ESD protection, microSD/UART/JTAG interfaces, addressable RGB indicators, and a PWM-driven buzzer.

Version
0.1.19
License
unset
Stars
0

dist/viewer-part-09.txt

4724111104014873},{x:.5791769346616289,y:.05163486686669809},{x:.5791768002287875,y:.05163606627643281},{x:.5791769023080691,y:.05163726887184294},{x:.5700269023080691,y:.7296112688718429},{x:.5690438463824576,y:.738377865441438},{x:.566369401453057,y:.746784229619043},{x:.5621063449386581,y:.7545073095436557},{x:.5564185037103594,y:.7612503115849266},{x:.5495244583167865,y:.7667541059559286},{x:.5416891430561892,y:.7708071849255477},{x:.5332136646999368,y:.773253790941974},{x:.5244237311281571,y:.773999902308069},{x:.515657134558562,y:.7730168463824576},{x:.507250770380957,y:.770342401453057},{x:.49952769045634426,y:.766079344938658},{x:.4927846884150734,y:.7603915037103594},{x:.4872808940440714,y:.7534974583167865},{x:.4832278150744524,y:.7456621430561892},{x:.480781209058026,y:.7371866646999369},{x:.48003509769193103,y:.7283967311281571},{x:.48718300813543913,y:.19876859615253395},{x:.10494770632221789,y:.754505330324044},{x:.1022980223560627,y:.75764690179997},{x:.09969080515339464,y:.7608238051533946},{x:.09945603456444842,y:.7610164763964532},{x:.09926022506190729,y:.7612486359882218},{x:.09604856383930557,y:.7638129153509474},{x:.0928716604858821,y:.7664201325536145},{x:.09260381265312083,y:.7665633002029657},{x:.09236647348574781,y:.7667527983743725},{x:.08871625734636118,y:.7686412418060533},{x:.08509175445642904,y:.7705785789630079},{x:.08480112262185491,y:.7706667411661766},{x:.08453137460075086,y:.770806295608766},{x:.08058287930375276,y:.7719463312873718},{x:.07665006449072577,y:.7731393376181454},{x:.07634781747275289,y:.773169106351106},{x:.07605602686309273,y:.7732533540659121},{x:.07196099086840901,y:.7736011710596524},{x:.067871,y:.774004},{x:.06756875298202693,y:.7739742312670393},{x:.06726613313330192,y:.7739999346616289},{x:.06318192637768459,y:.7735421665584931},{x:.05909193550927423,y:.7731393376181454},{x:.05880130367469977,y:.7730511754149765},{x:.05849948409798508,y:.77301734672231},{x:.054583060356599135,y:.7717715852937818},{x:.05065024554357096,y:.7705785789630079},{x:.0503823977108098,y:.7704354113136568},{x:.050092977163175983,y:.7703433505514221},{x:.04649484240404986,y:.768357469710569},{x:.042870339514117915,y:.7664201325536145},{x:.04263556892517204,y:.7662274613105563},{x:.04236966967595597,y:.7660807063222179},{x:.03922809820002561,y:.7634310223560591},{x:.036051194846605364,y:.7608238051533946},{x:.03585852360354703,y:.7605890345644487},{x:.035626364011778155,y:.7603932250619073},{x:.033062084649052234,y:.7571815638393052},{x:.03045486744638546,y:.7540046604858821},{x:.030311699797034096,y:.7537368126531205},{x:.03012220162562753,y:.7534994734857478},{x:.028233758193948882,y:.7498492573463653},{x:.026296421036992097,y:.746224754456429},{x:.026208258833823234,y:.7459341226218545},{x:.026068704391234022,y:.7456643746007509},{x:.02492866871262922,y:.741715879303756},{x:.023735662381854636,y:.7377830644907257},{x:.023705893648893955,y:.7374808174727527},{x:.023621645934087915,y:.7371890268630927},{x:.023273828940347806,y:.7330939908684111},{x:.022871000000000002,y:.729004},{x:.022871000000000002,y:.05103000000000002}]],O:[[{x:.012131736117046842,y:.4355587711738732},{x:.012426138979982786,y:.43287355609157196},{x:.012514983726773468,y:.43017371170811375},{x:.012905745911416293,y:.42849911573111366},{x:.01309315536666239,y:.42678977537085305},{x:.07316415536666239,y:.1412837753708531},{x:.07429915106219231,y:.13768552483470178},{x:.07533122192175289,y:.13405641311271962},{x:.07562440736087628,y:.1334840955199844},{x:.07581784742995093,y:.1328708369543332},{x:.07763301835724021,y:.12956315246900071},{x:.0793532628391043,y:.12620512014747703},{x:.07975246842568721,y:.12570099711853563},{x:.0800618324091279,y:.12513726042963025},{x:.08248742256740031,y:.1222472544549173},{x:.0848297326408542,y:.1192893488327618},{x:.1660597326408542,y:.03517334883276172},{x:.16792084009780786,y:.033590824390739155},{x:.16963596886504836,y:.031851158363102774},{x:.17127304088861567,y:.03074040344046043},{x:.172780173663761,y:.0294588683817891},{x:.1749142556657825,y:.0282698357562587},{x:.17693582072022015,y:.026898201947035502},{x:.17875813439943417,y:.026128166777013812},{x:.18048632312818114,y:.025165283073572443},{x:.1828113681007397,y:.02441543612151622},{x:.18506168183103927,y:.023464545648773483},{x:.2739246818310393,y:-.0041824543512264944},{x:.2748960678404206,y:-.004382857312604547},{x:.27582577451608603,y:-.004728396924478621},{x:.2792086173377598,y:-.005272563034129881},{x:.28256427991205235,y:-.0059648570457577},{x:.28355609768991147,y:-.005971901311054349},{x:.2845353517466465,y:-.006129424701440567},{x:.287959355733624,y:-.0060031749164705245},{x:.2913856000541485,y:-.006027509400590186},{x:.29235973459950004,y:-.005840924262640544},{x:.29335090385307644,y:-.005804377895986514},{x:.3811419038530764,y:.006122622104013507},{x:.38318930529213563,y:.00660893405691686},{x:.3852758334501729,y:.006882342567970358},{x:.387470347489584,y:.0076257947232155985},{x:.38972465411174423,y:.008161252125438313},{x:.3916378405507577,y:.009037647936572414},{x:.39363093730084414,y:.009712864429997858},{x:.3956382440479665,y:.010870159811164118},{x:.3977447722434711,y:.011835121954387393},{x:.39945022100051475,y:.01306792222421872},{x:.4012732927522862,y:.01411899850883961},{x:.4916652927522862,y:.07880999850883955},{x:.49276799959381884,y:.07977586317754862},{x:.49398769122063274,y:.08058901093294302},{x:.4960788615418114,y:.08267585840574071},{x:.4983012083703825,y:.08462241954283417},{x:.4991942961599152,y:.08578485282556958},{x:.5002319144966787,y:.08682032620708877},{x:.5018757798210403,y:.08927504258220473},{x:.5036756696393939,y:.09161775945128844},{x:.5043248175140242,y:.09293208968889465},{x:.5051404874699588,y:.09415009603518716},{x:.5560304874699588,y:.18912209603518723},{x:.5570965448702581,y:.19168827319789875},{x:.5583465570022521,y:.1941700494329812},{x:.5587848767756364,y:.19575236841213633},{x:.559414776433869,y:.19726864147332673},{x:.5599597135111237,y:.1999934877429328},{x:.5607015364856348,y:.20267144261291137},{x:.5892585364856349,y:.36700144261291134},{x:.5895780755292599,y:.371318367211785},{x:.589913428370686,y:.37563409214099147},{x:.5899036127276142,y:.3757163259822715},{x:.58990972616553,y:.3757989176124618},{x:.5893809351459178,y:.38009523269056544},{x:.5888678881103582,y:.38439345626922305},{x:.5314878881103581,y:.6446844562692231},{x:.5303800126922803,y:.6480826863142071},{x:.5293998170293023,y:.651519919480997},{x:.5290148883003433,y:.6522699863013032},{x:.5287535704445262,y:.6530715368858165},{x:.5270040207481954,y:.6561883351212919},{x:.5253720883446767,y:.6593682961290664},{x:.5248482251358019,y:.6600288547560561},{x:.5244355536676654,y:.6607640231862051},{x:.522111563906752,y:.6634796128039058},{x:.5198906090097624,y:.6662800975344761},{x:.4528876090097624,y:.7355630975344761},{x:.4513498405668143,y:.7368687638478525},{x:.44995999895015265,y:.7383308981052339},{x:.44799560298794544,y:.7397167316507253},{x:.4461630292013509,y:.741272707045399},{x:.44440008568631667,y:.7422532816059559},{x:.4427517012434998,y:.743416176715023},{x:.4405546878862334,y:.7443921472166956},{x:.43845377075029196,y:.7455607075703166},{x:.43653340109378364,y:.7461785074476045},{x:.43468982031452474,y:.7469974740014746},{x:.32025082031452473,y:.7849044740014746},{x:.3162756641960007,y:.785800462676764},{x:.3123143949565378,y:.7867559771378485},{x:.3119757732525013,y:.7867696456410259},{x:.3116451697261732,y:.786844162718285},{x:.30757159639863574,y:.7869474207351895},{x:.30350003021295163,y:.7871117699623142},{x:.30316524843732107,y:.7870591140117537},{x:.302826459804451,y:.7870677017158569},{x:.29881101440639224,y:.7863742609266953},{x:.29478561927964103,y:.7857411290712295},{x:.173234619279641,y:.7541621290712296},{x:.17180894449846637,y:.7536379076298808},{x:.17032768986057922,y:.753301394035824},{x:.16767817066393412,y:.7521190197025511},{x:.16495505208167519,y:.7511177274253745},{x:.16365904177145735,y:.7503254433998781},{x:.16227189957151614,y:.7497064173758784},{x:.15990395993272244,y:.7480298664806163},{x:.1574285077432372,y:.7465165596726792},{x:.15631196685338702,y:.745486660093817},{x:.15507224418821702,y:.7446089104628228},{x:.08487024418821705,y:.6837459104628228},{x:.08477922863788438,y:.6836498346778195},{x:.08467166808724909,y:.6835727301071804},{x:.08174665618590948,y:.6804486588585436},{x:.07880340242944883,y:.6773417676286113},{x:.07873287917322891,y:.6772297816598538},{x:.07864242772392874,y:.6771331746094597},{x:.07638309517198695,y:.6734984900001298},{x:.07410251962167697,y:.6698770964908778},{x:.07405519882875666,y:.6697535038963435},{x:.0739853324792622,y:.6696411069209627},{x:.07247850415964274,y:.6656354878421232},{x:.07094824805491862,y:.6616387601752097},{x:.07092594823683183,y:.6615083105489945},{x:.0708793519117729,y:.6613844430013583},{x:.013660351911772894,y:.4476944430013583},{x:.013380528959940628,y:.4459977798389246},{x:.012899536483696877,y:.44434683677239306},{x:.012664423003084308,y:.4416557821956227},{x:.012224847112815455,y:.43899048181468664},{x:.012281403443251489,y:.4372718288093888},{x:.012131736117046842,y:.4355587711738732}],[{x:.10337829031332789,y:.4348001396911351},{x:.15424861715004387,y:.6247803934833692},{x:.2060651876410252,y:.6697037849792326},{x:.3045603004668897,y:.6952928559694175},{x:.3958853477721772,y:.6650421672339206},{x:.4463402797077116,y:.6128703383711886},{x:.499069598507425,y:.373676069990286},{x:.47327322171072966,y:.22523195474705573},{x:.4307624349909165,y:.1458974207255564},{x:.35796896612556683,y:.09380119213930618},{x:.2911281310221294,y:.08472041346861442},{x:.22279798440939425,y:.10597924519162948},{x:.15856873728877424,y:.17249047688925445},{x:.10337829031332789,y:.4348001396911351}]],P:[[{x:.025556999999999996,y:.05103000000000002},{x:.02642166238185463,y:.04225093550927423},{x:.02898242103699209,y:.03380924554357098},{x:.033140867446385454,y:.026029339514117924},{x:.03873719484660536,y:.019210194846605383},{x:.04555633951411791,y:.013613867446385479},{x:.053336245543570956,y:.009455421036992116},{x:.061777935509274226,y:.006894662381854655},{x:.070557,y:.0060300000000000215},{x:.07933606449072576,y:.006894662381854655},{x:.08777775445642903,y:.009455421036992116},{x:.09555766048588209,y:.013613867446385486},{x:.10237680515339463,y:.019210194846605383},{x:.10797313255361454,y:.026029339514117924},{x:.1121315789630079,y:.03380924554357098},{x:.11469233761814536,y:.04225093550927425},{x:.11555699999999999,y:.05103000000000002},{x:.11555699999999999,y:.3249696679740436},{x:.22632413005583354,y:.32573306868659574},{x:.22797244585475993,y:.3259068917113995},{x:.2296296407459454,y:.32587748916779646},{x:.3399906407459454,y:.3347734891677965},{x:.3425199358315593,y:.3352301100895628},{x:.3450781711944775,y:.33547763407671893},{x:.4262801711944775,y:.3514846340767189},{x:.43023360415359113,y:.35267647626036297},{x:.4342017122431381,y:.35381850872164355},{x:.49034871224313803,y:.3761405087216436},{x:.49223471805815816,y:.37711419756221787},{x:.49421014578428074,y:.3778905822551455},{x:.4961445509948513,y:.379132728294546},{x:.49818726580808836,y:.3801873213410173},{x:.49984707528076383,y:.38151024250532195},{x:.5016330805772936,y:.3826570960152846},{x:.5368430805772937,y:.4104950960152846},{x:.538268982488492,y:.41186995272090265},{x:.539835277869678,y:.41308244849417974},{x:.5414366048100854,y:.41492417879038607},{x:.5431934850553138,y:.4166181652891421},{x:.5443237674236908,y:.41824478417169497},{x:.5456234206874699,y:.41973955124896434},{x:.546834674823181,y:.4218582966024136},{x:.5482273167355989,y:.4238624839583804},{x:.5490185434436073,y:.4256783549664296},{x:.5500016096439067,y:.4273979502871872},{x:.5725636096439066,y:.4777629502871872},{x:.5732747072201834,y:.47988746499756846},{x:.5741879174558705,y:.48193325814034926},{x:.5746713208988057,y:.4840600657825243},{x:.5753635933927087,y:.4861283376286891},{x:.5756465551694752,y:.4883507586397718},{x:.5761431038835471,y:.49053540091990977},{x:.5762022992770958,y:.49271564988294925},{x:.5764777701286589,y:.49487923612929946},{x:.5763217220435205,y:.4971141570479765},{x:.5763825271473633,y:.4993536938878067},{x:.5706825271473633,y:.5794656938878067},{x:.5700654182420953,y:.5830779192715516},{x:.5695689975224034,y:.5867086990904052},{x:.5693236589408173,y:.5874197813867033},{x:.5691969863455608,y:.5881612549906394},{x:.5678870248015591,y:.5915836805014664},{x:.5666918126627678,y:.5950478490261242},{x:.5415328126627678,y:.6498468490261241},{x:.5413708296623262,y:.6501242105110185},{x:.5412617638147841,y:.650426323944409},{x:.5391478795722351,y:.653930540410781},{x:.5370840246571379,y:.6574644536133865},{x:.536871043573226,y:.6577048843594048},{x:.5367051339883567,y:.6579799150765678},{x:.5339482287199508,y:.661004400648547},{x:.5312345979336611,y:.6640677725799057},{x:.5309788035098929,y:.664262032968313},{x:.5307624259999995,y:.6644994116930277},{x:.47414742599999943,y:.7155204116930277},{x:.47266946719886654,y:.7166100541651699},{x:.4713261182021025,y:.7178618913781634},{x:.46912758296129603,y:.7192213498885075},{x:.46704701478499566,y:.7207552731949938},{x:.4653848758470294,y:.7215356430341334},{x:.4638231175995642,y:.7225013521577397},{x:.4283261175995643,y:.7398953521577398},{x:.4243082080780145,y:.7413960258251278},{x:.4202985181688539,y:.7429185254841078},{x:.34090751816885384,y:.7644395254841077},{x:.3408415384597873,y:.7644506164558663},{x:.3407789202555512,y:.7644741810938074},{x:.33649241770984384,y:.7651816893280429},{x:.33220802793590354,y:.7659018811363755},{x:.33214115226719376,y:.7658998869955335},{x:.33207514002138977,y:.7659107826399355},{x:.2099811400213898,y:.7739077826399355},{x:.20641155146718015,y:.773790767187745},{x:.20284008504333162,y:.7738075792583221},{x:.0663570850433316,y:.7610135792583221},{x:.06408313636872824,y:.7605723800858132},{x:.061777935509274226,y:.7603453376181454},{x:.05976354040438703,y:.759734277543603},{x:.05769704052657306,y:.7593333282846051},{x:.05555285882676713,y:.7584569812513055},{x:.053336245543570956,y:.7577845789630079},{x:.05147976838249502,y:.7567922712467745},{x:.04953119704042999,y:.7559958719887517},{x:.04759918201567506,y:.7547180546196904},{x:.04555633951411791,y:.7536261325536145},{x:.043929123673028744,y:.7522907110247322},{x:.04217336337061703,y:.7511294669445447},{x:.04052776127482757,y:.7494992850446065},{x:.03873719484660536,y:.7480298051533947},{x:.037401773317722896,y:.7464025893123053},{x:.03590629693874444,y:.7449211263687215},{x:.034610347337597366,y:.7430012269141045},{x:.033140867446385454,y:.7412106604858821},{x:.032148559730151835,y:.7393541833248057},{x:.030970837593177758,y:.7376094333079335},{x:.030074343103068113,y:.7354735969579864},{x:.02898242103699209,y:.733430754456429},{x:.028371360962449563,y:.7314163593515414},{x:.027556652268729623,y:.729475372026062},{x:.027094064670152376,y:.7272056777739226},{x:.02642166238185463,y:.7249890644907258},{x:.02621533264498147,y:.722894163516222},{x:.025794946192721373,y:.7208315299365354},{x:.02578404246766777,y:.7185152008594541},{x:.025556999999999996,y:.71621},{x:.025556999999999996,y:.05103000000000002}],[{x:.11555699999999999,y:.414971805397996},{x:.11555699999999999,y:.6752310456989574},{x:.20767337575712835,y:.6838660911730216},{x:.3217031184787672,y:.6763972896549704},{x:.3925929523867085,y:.6571807523203506},{x:.4185706758911827,y:.6444513238436673},{x:.46361487793542,y:.6038578374443203},{x:.4814895996448674,y:.5649247767123354},{x:.48580725170954087,y:.5042413131675768},{x:.4723746184159119,y:.474255736718963},{x:.45098032059796866,y:.45734081304228297},{x:.40480552914494095,y:.4389833995595593},{x:.3301954695220376,y:.42427584033215343},{x:.22404845814303564,y:.41571952231013837},{x:.11555699999999999,y:.414971805397996}]],Q:[[{x:.012134510452571898,y:.39776120903599943},{x:.012467756958298536,y:.3937322544040442},{x:.012734737801221134,y:.38969836671479857},{x:.012831073490929856,y:.38933975275179394},{x:.012861682585025715,y:.38896968840207613},{x:.0716656825850257,y:.06709568840207614},{x:.07243605319674906,y:.06440524795975149},{x:.07301096718930201,y:.06166637692330789},{x:.07364750148994079,y:.06017438890024393},{x:.07409402290033937,y:.05861495861744442},{x:.07537446994903126,y:.05612650608452361},{x:.07647266436288541,y:.053552421842995857},{x:.07738804025928744,y:.05221328363312273},{x:.0781302116420243,y:.05077092937167972},{x:.07987152826568633,y:.04858009458346291},{x:.08145080010539194,y:.04626971775068952},{x:.16096480010539196,y:-.04855928224931053},{x:.16315500529851779,y:-.05070373085173594},{x:.16521251383898505,y:-.052975804178533654},{x:.1663001767861927,y:-.05378319510572523},{x:.1672680674520078,y:-.05473086511953138},{x:.1698345496348827,y:-.056406820906963286},{x:.172295783242646,y:-.058233836978172464},{x:.17352006120728586,y:-.058813521600477286},{x:.17465423537351554,y:-.059554156299027654},{x:.17749836607515132,y:-.06069721323044178},{x:.18026874092294012,y:-.06200896084304842},{x:.2672567409229401,y:-.09317596084304836},{x:.2695830047845554,y:-.09375972267138269},{x:.2718475349769373,y:-.09454977610873284},{x:.2738508793967248,y:-.09483071995927067},{x:.27581299058749986,y:-.09532309988014809},{x:.2782084422243766,y:-.09544181332278269},{x:.28058359188359605,y:-.09577489818042065},{x:.2826032520283714,y:-.0956596106656824},{x:.28462372036011635,y:-.09575974074040533},{x:.28699630390923414,y:-.09540884370631499},{x:.2893907973658866,y:-.09527215971995788},{x:.3753267973658866,y:-.08182715971995795},{x:.37840631600914065,y:-.08102976437129623},{x:.38152495221950905,y:-.08040256216817918},{x:.38266795913198753,y:-.07992627554804835},{x:.3838666954562622,y:-.07961588068444121},{x:.38673147789694834,y:-.07823302278004476},{x:.38966782930723504,y:-.07700945634885908},{x:.3906959547522998,y:-.07631933185595965},{x:.3918111026603398,y:-.07578103928710583},{x:.3943510569158511,y:-.07386586128072498},{x:.3969922811880835,y:-.07209295159323717},{x:.45217017177581864,y:-.026613783173476364},{x:.5097585536672307,y:-.09873256043298734},{x:.5159122791302333,y:-.10505326271144577},{x:.5231808703268614,y:-.11005198218579294},{x:.5312849993737013,y:-.11353662086994384},{x:.5399132291363312,y:-.11537326605347448},{x:.5487339815837399,y:-.1154913364919842},{x:.5574082801461085,y:-.11388629480473579},{x:.5656027763942881,y:-.11061982184365243},{x:.5730025604329874,y:-.10581744633276943},{x:.5793232627114457,y:-.0996637208697668},{x:.5843219821857929,y:-.09239512967313873},{x:.5878066208699438,y:-.08429100062629874},{x:.5896432660534744,y:-.07566277086366895},{x:.5897613364919841,y:-.06684201841626024},{x:.5881562948047357,y:-.058167719853891554},{x:.5848898218436525,y:-.04997322360571205},{x:.5800874463327694,y:-.042573439567012816},{x:.5106129498444961,y:.04443049374200151},{x:.5474711182959175,y:.12365010382899572},{x:.5481373073434039,y:.1255496832776173},{x:.5490025186311253,y:.12736726941208848},{x:.5495935209593992,y:.1297019482663393},{x:.5503905347901464,y:.13197456307270286},{x:.5506733336355601,y:.13396760967066554},{x:.5511673266667299,y:.13591906574595297},{x:.5791213266667299,y:.32118306574595296},{x:.5792865967797204,y:.3243841932678159},{x:.5796238248970751,y:.32757179562983435},{x:.579513579388425,y:.3287806341158348},{x:.5795761658223595,y:.3299928748079828},{x:.5791137513174164,y:.3331647361616822},{x:.5788226293197903,y:.33635687958013644},{x:.5226546293197903,y:.6297998795801365},{x:.5219105438778229,y:.6323181740447382},{x:.521369234544533,y:.6348876981954499},{x:.5206636104444891,y:.6365383151545928},{x:.5201549436340621,y:.6382598551025291},{x:.5189338607071872,y:.6405845973766512},{x:.5179016631869613,y:.6429991446291672},{x:.5168875780620563,y:.6444803850133782},{x:.5160528293589531,y:.6460696100820955},{x:.5144016744792594,y:.6481114616238732},{x:.5129182555439367,y:.6502782422813739},{x:.4473292555439367,y:.7283852422813738},{x:.4454767413796947,y:.7301964293264013},{x:.4437773055972873,y:.732151966404103},{x:.44233025961343425,y:.7332727172827731},{x:.4410215211764534,y:.7345522595114605},{x:.4388512574885805,y:.735967237520439},{x:.4368029695300015,y:.737553656027496},{x:.4351650804791521,y:.7383705673253327},{x:.43363186277883553,y:.7393702013057781},{x:.431227251583759,y:.7403345934673514},{x:.4289088260065632,y:.7414909282302113},{x:.3168848260065632,y:.7842309282302113},{x:.31544522398579106,y:.7846236280557255},{x:.31406876767085296,y:.7851998529634103},{x:.3111991137964475,y:.7857818972901452},{x:.30837424253549156,y:.7865524758495462},{x:.30688569012846406,y:.7866567776362199},{x:.305423266132861,y:.7869533972381565},{x:.30249520063786056,y:.7869644160479279},{x:.2995742760667897,y:.7871690831124285},{x:.29809397750772,y:.7869809786010931},{x:.2966017859654652,y:.7869865939723252},{x:.2937278327647654,y:.7864261638184524},{x:.2908231043767717,y:.786057054147543},{x:.2894079467091229,y:.7855837720890787},{x:.28794333170435554,y:.785298167434039},{x:.16895933170435556,y:.7496931674340391},{x:.16685145995859063,y:.7488293371508981},{x:.16467103610787698,y:.748169732810473},{x:.1627799564873854,y:.7471607878174731},{x:.16079664289106937,y:.7463480029082842},{x:.1588977982379503,y:.7450895455041626},{x:.15688795304330724,y:.7440172356850165},{x:.15523004539103946,y:.7426587459550258},{x:.15344340707901263,y:.7414746531917952},{x:.15182656105367498,y:.739869930478983},{x:.1500645317387979,y:.7384261234461069},{x:.08134353173879794,y:.6698101234461069},{x:.07898814712174665,y:.6669445493412297},{x:.07654417665723892,y:.6641541443502993},{x:.0761910053095167,y:.6635415309608049},{x:.07574199244846258,y:.6629952594015535},{x:.07399091166125166,y:.6597252337561722},{x:.07213828241215867,y:.6565116506297859},{x:.07191141209628055,y:.6558419081228384},{x:.07157759918584938,y:.6552185349547689},{x:.07049811528111428,y:.6516697230205841},{x:.06930802275051184,y:.6481564579560907},{x:.013298022750511833,y:.4072474579560906},{x:.013249789700227431,y:.40687927578320093},{x:.013136451320225305,y:.40652566731159423},{x:.012677284531251238,y:.4025091147450468},{x:.012152162963867598,y:.3985006516980174},{x:.01217668547678935,y:.39813013424102855},{x:.012134510452571898,y:.39776120903599943}],[{x:.1030741934540208,y:.3959601630333355},{x:.15405220468618464,y:.6152256818322884},{x:.20562817178182732,y:.6667228451191239},{x:.2990925609035841,y:.6946913078929434},{x:.38591644511804135,y:.6615657918309754},{x:.4364618489221904,y:.6013735361946543},{x:.4889800495366121,y:.3269984766785998},{x:.4631403994395801,y:.1557472448128009},{x:.4478929247459949,y:.12297570323093639},{x:.3763894463327694,y:.21252056043298723},{x:.3702357208697667,y:.2188412627114457},{x:.36296712967313866,y:.22383998218579282},{x:.35486300062629866,y:.22732462086994373},{x:.34623477086366883,y:.22916126605347437},{x:.3374140184162602,y:.2292793364919841},{x:.3287397198538915,y:.22767429480473567},{x:.32054522360571197,y:.22440782184365232},{x:.31314543956701274,y:.21960544633276935},{x:.3068247372885543,y:.2134517208697667},{x:.30182601781420715,y:.20618312967313862},{x:.2983413791300562,y:.19807900062629863},{x:.2965047339465256,y:.18945077086366885},{x:.29638666350801585,y:.18063001841626014},{x:.2979917051952643,y:.17195571985389144},{x:.30125817815634764,y:.16376122360571194},{x:.3060605536672306,y:.1563614395670127},{x:.3960043024488616,y:.04372356068896105},{x:.3492507773512258,y:.005187991106938553},{x:.28681342879982186,y:-.004580559340762309},{x:.22209853619564562,y:.018606191220169738},{x:.15806156000107346,y:.09497717514193305},{x:.1030741934540208,y:.3959601630333355}]],R:[[{x:-.010088,y:.05588800000000005},{x:-.009223337618145366,y:.04710893550927426},{x:-.006662578963007905,y:.03866724554357101},{x:-.0025041325536145423,y:.030887339514117953},{x:.0030921948466053617,y:.024068194846605412},{x:.009911339514117913,y:.018471867446385508},{x:.01769124554357096,y:.014313421036992145},{x:.02613293550927423,y:.011752662381854684},{x:.034912,y:.01088800000000005},{x:.043691064490725774,y:.011752662381854684},{x:.05213275445642904,y:.014313421036992145},{x:.059912660485882105,y:.018471867446385515},{x:.06673180515339464,y:.024068194846605412},{x:.07232813255361453,y:.030887339514117953},{x:.0764865789630079,y:.03866724554357101},{x:.07904733761814536,y:.04710893550927428},{x:.079912,y:.05588800000000005},{x:.079912,y:.36648688236049143},{x:.25933152798675563,y:.3728389247505383},{x:.2598033776805002,y:.3702688775066002},{x:.2630584474090824,y:.36206984491555727},{x:.26785052379396923,y:.35466338703825},{x:.5319365237939692,y:.022999387038250052},{x:.5380814500271169,y:.016670129897313986},{x:.5453430800394999,y:.011661303295187019},{x:.5534423534621115,y:.008165393629206541},{x:.5620680197594453,y:.00631674674730745},{x:.5708885994130244,y:.006186405112428031},{x:.5795651224933998,y:.00777937768050025},{x:.5877641550844427,y:.011034447409082423},{x:.59517061296175,y:.015826523793969254},{x:.601499870102686,y:.021971450027116944},{x:.606508696704813,y:.02923308003949996},{x:.6100046063707935,y:.03733235346211146},{x:.6118532532526926,y:.04595801975944533},{x:.6119835948875719,y:.05477859941302443},{x:.6103906223194997,y:.06345512249339977},{x:.6071355525909176,y:.07165415508444274},{x:.6023434762060308,y:.07906061296174999},{x:.36492288462028066,y:.3772356888373974},{x:.45122307475864126,y:.3907421966461853},{x:.4517263325772421,y:.3908725352482557},{x:.4522445282141884,y:.3909141268943158},{x:.4559919550269364,y:.3919772876167318},{x:.459762859565968,y:.3929539131315124},{x:.46023101962685037,y:.3931799280437793},{x:.4607311441523136,y:.39332181547170203},{x:.5072261441523136,y:.41160281547170213},{x:.5099186672764574,y:.4129799887569096},{x:.5126912264123276,y:.4141879634543456},{x:.5138373975854011,y:.41498434320238026},{x:.5150799754049854,y:.4156198976243936},{x:.5174520892726079,y:.41749589411441484},{x:.5199357102894067,y:.4192215573713852},{x:.5536387102894067,y:.4479225573713852},{x:.5544422891842978,y:.4487559165260936},{x:.5553578681885658,y:.44946439490120116},{x:.5574982196806069,y:.4519250983842071},{x:.5597619879819907,y:.4542727608851649},{x:.5603875460278954,y:.4552468777427617},{x:.5611473151639865,y:.4561203635073251},{x:.5627664809673836,y:.45895134712470415},{x:.5645287453623273,y:.46169553923588524},{x:.5649522427143585,y:.46277297903182424},{x:.5655270044804562,y:.4637779046177677},{x:.5843050044804562,y:.5056739046177676},{x:.5856980535944053,y:.5098331481877504},{x:.5870956418010017,y:.5139908687307394},{x:.5870987900445207,y:.5140153439302019},{x:.587106627133701,y:.514038743222053},{x:.5876614810321307,y:.5183898384933372},{x:.5882210839336397,y:.522740325535193},{x:.5899430839336397,y:.580600325535193},{x:.589777587866933,y:.5830153029012521},{x:.5898269599494498,y:.5854354407122341},{x:.5894767504310368,y:.5874052295805413},{x:.5893399666658296,y:.589401226848592},{x:.5887065118476329,y:.5917375144207835},{x:.5882827897945603,y:.5941207819778186},{x:.5699357897945603,y:.6593647819778187},{x:.5695566600666073,y:.6603356321127045},{x:.5693270257483343,y:.6613522723710545},{x:.5679549854437747,y:.6644370937206254},{x:.5667268644118839,y:.6675819841936177},{x:.5661656160899001,y:.668460215174679},{x:.5657420574552864,y:.6694125215424361},{x:.5637945617300048,y:.6721703971299327},{x:.5619765010042908,y:.6750152648867381},{x:.5612547025465381,y:.6757671267898905},{x:.5606534967163777,y:.6766185026674012},{x:.5398464967163776,y:.7006785026674012},{x:.5387925287989109,y:.70167944573824},{x:.5378793324857355,y:.7028102896247742},{x:.535601038014175,y:.7047103734673366},{x:.5334498940671065,y:.7067532939324781},{x:.5322209035416287,y:.707529385222465},{x:.5311046373415733,y:.7084603444980107},{x:.5029396373415734,y:.7276033444980106},{x:.49917038563569516,y:.7296565217962586},{x:.49541206095977475,y:.7317296332429761},{x:.4611910609597748,y:.7464366332429762},{x:.457170688924302,y:.7477143925092122},{x:.45316143447737084,y:.7490266191763204},{x:.37177643447737085,y:.7670666191763205},{x:.36787988134157384,y:.7675363076101905},{x:.36399443936523473,y:.7680904503837813},{x:.2290834393652347,y:.7739614503837813},{x:.2260604581328276,y:.7737959747883908},{x:.2230330269857825,y:.7738173839936113},{x:.030818026985782503,y:.7562573839936113},{x:.028490934977474184,y:.7558115802948838},{x:.02613293550927423,y:.7555793376181453},{x:.024169339379190496,y:.7549836872441402},{x:.022154034015341384,y:.7545976128723226},{x:.01995862841458906,y:.7537063820373993},{x:.01769124554357096,y:.7530185789630078},{x:.01588158498580211,y:.7520512952425895},{x:.013980322522940947,y:.7512794726091756},{x:.012000971535783972,y:.7499770641392344},{x:.009911339514117913,y:.7488601325536145},{x:.008325158769029223,y:.7475583876576994},{x:.006611003657363959,y:.7464304774736483},{x:.004923772632206568,y:.7447669421957904},{x:.0030921948466053617,y:.7432638051533946},{x:.0017904499506900475,y:.7416776244083056},{x:.0003292762098528329,y:.7402369716294513},{x:-.001000995511218774,y:.7382762382714833},{x:-.0025041325536145423,y:.7364446604858821},{x:-.0034714162740331275,y:.7346349999281129},{x:-.004623456556617868,y:.732936968032819},{x:-.005545647377387794,y:.7307543864780955},{x:-.006662578963007905,y:.728664754456429},{x:-.007258229337013042,y:.7267011583263452},{x:-.008056863899357211,y:.7248110017280808},{x:-.008535534543753812,y:.7224904473617442},{x:-.009223337618145366,y:.7202230644907257},{x:-.009424464135908606,y:.7181809926864091},{x:-.009839001899660749,y:.7161713490432334},{x:-.009855757323261527,y:.7138019994682},{x:-.010088,y:.711444},{x:-.010088,y:.05588800000000005}],[{x:.079912,y:.45654326739466394},{x:.079912,y:.6703676283824797},{x:.22820062174801237,y:.6839146886946046},{x:.3561457472749752,y:.6783468266821017},{x:.42954781695254723,y:.662076342723345},{x:.4559144639404158,y:.6507448714849071},{x:.47563211893454127,y:.6373433067928232},{x:.48601322722124407,y:.6253391992627579},{x:.4997779385388953,y:.5763903343143285},{x:.4985264355495565,y:.5343392524542002},{x:.48755361344964526,y:.5098575528750181},{x:.467303195590932,y:.4926125823096997},{x:.43241084881177044,y:.4788935374345549},{x:.3509044963348569,y:.4661372945522357},{x:.079912,y:.45654326739466394}]],S:[[{x:.021897597226735628,y:.20918252956592975},{x:.022856530106274857,y:.20041326151782815},{x:.025507836686771486,y:.19199957102060095},{x:.07532383668677148,y:.0752955710206009},{x:.07606476437254353,y:.07394451179196875},{x:.07662717764446286,y:.07250992955787258},{x:.07818101321859919,y:.07008559601860773},{x:.07956562874320691,y:.06756079148160443},{x:.08055589829123208,y:.06638024029801701},{x:.0813873780598424,y:.06508294454561242},{x:.08338432112997196,y:.06300833217803187},{x:.0852348965856767,y:.0608021661408081},{x:.08643645249257384,y:.05983749092219001},{x:.08750504545666679,y:.05872733599970995},{x:.08986835462050304,y:.05708217099364391},{x:.09211377343035676,y:.05527942517977789},{x:.09348044057646428,y:.05456769785378441},{x:.09474508130770348,y:.05368734639231786},{x:.18347008130770348,y:.00406434639231789},{x:.18531117162778632,y:.0032602675504258996},{x:.18705570252460849,y:.0022638899609980986},{x:.18934358471290644,y:.0014991491478438968},{x:.19155425509545604,y:.0005336596975895336},{x:.19351683738147718,y:.0001042099085839361},{x:.19542223123106015,y:-.0005326814704223887},{x:.1978153459361366,y:-.0008363843304376121},{x:.20017189655491793,y:-.0013520417748285815},{x:.2021805498702545,y:-.0013903589963945293},{x:.20417358345551592,y:-.0016432887864569548},{x:.36640558345551594,y:-.006196288786456984},{x:.3683537351453612,y:-.006059465175549666},{x:.37030515940756886,y:-.006136660097762148},{x:.3727431942064551,y:-.005751182385354602},{x:.3752054496398049,y:-.005578251970786187},{x:.37708947517888647,y:-.005063991846688501},{x:.37901846335331396,y:-.004758999502412188},{x:.3813344490261288,y:-.00390529164215812},{x:.3837156558614866,y:-.003255321831637216},{x:.38546315320491126,y:-.002383387922517842},{x:.38729557535780434,y:-.001707928996501587},{x:.5134735753578044,y:.059451071003498376},{x:.5144073364238021,y:.06002293670994077},{x:.5154151369003129,y:.060451046875811966},{x:.5181619939873726,y:.06232241135953579},{x:.5209964106485654,y:.06405830049148753},{x:.5218006642926897,y:.06480134570578519},{x:.5227055800155168,y:.06541784197435321},{x:.5250345719141375,y:.06778913394790613},{x:.5274758708842278,y:.07004463571609586},{x:.5281197100899656,y:.07093030562736781},{x:.5288869656553633,y:.07171149639276676},{x:.5307085905129939,y:.07449158843544039},{x:.5326629540416582,y:.07718002517181716},{x:.5331216364294024,y:.07817428398206286},{x:.5337217466362741,y:.07909014852127505},{x:.5349660004312154,y:.08217220325496363},{x:.5363583234240663,y:.08519025984344057},{x:.5366142220868877,y:.08625489874416871},{x:.5370241250365293,y:.08727024089657527},{x:.5783351250365293,y:.22800124089657534},{x:.5784689928995229,y:.22870739358153944},{x:.5787167010683089,y:.22938208824013706},{x:.5792894483007394,y:.23303529403132756},{x:.5799781923062021,y:.23666841715613338},{x:.579971724381043,y:.23738711763976203},{x:.5800830465086156,y:.23809717369609615},{x:.5799320834693805,y:.24179192160438975},{x:.5798988062915618,y:.2454896025769029},{x:.5797522511369868,y:.24619323160266243},{x:.5797229091764134,y:.2469113620006918},{x:.5788540372904492,y:.2505056649360105},{x:.5781000177526308,y:.2541258039501414},{x:.5778190074010411,y:.2547873214491718},{x:.5776501289474114,y:.2554859288404322},{x:.5462891289474114,y:.3454679288404322},{x:.5453940585085517,y:.34740151578805634},{x:.5446999978282894,y:.3494160105998292},{x:.5435456407901493,y:.3513945829466735},{x:.5425833616033817,y:.3534733584203385},{x:.5413282655917657,y:.35519517245680393},{x:.5402545326513293,y:.3570355547940282},{x:.5387363559437135,y:.3587509055417339},{x:.537387017705137,y:.36060200657115166},{x:.5358201287566253,y:.36204587934864135},{x:.5344079865107593,y:.36364142435019586},{x:.5325843328131388,y:.3650276335315076},{x:.5308997898345437,y:.36657992334222783},{x:.5290813226127058,y:.36769036763963614},{x:.5273850388959807,y:.368979759405903},{x:.44286903889598056,y:.42100375940590296},{x:.4391930936098881,y:.42279580082266366},{x:.4355432374645799,y:.42464039733796655},{x:.4352309585303121,y:.42472736117212373},{x:.4349395777453148,y:.4248694107387315},{x:.430984654780085,y:.42590987723258605},{x:.42704506666901776,y:.42700697873237736},{x:.18802361397643091,y:.46887992641475673},{x:.1445277950559712,y:.506325930968192},{x:.1345999941059918,y:.5433489412625321},{x:.1668438673565076,y:.6442112383308392},{x:.2418447705661005,y:.6964178007533797},{x:.3847076342900009,y:.6886954406015322},{x:.4475324208368403,y:.608018765726417},{x:.4536085342974724,y:.6016234190133417},{x:.4608155671913789,y:.5965363480257236},{x:.46887655728619765,y:.5929530460487544},{x:.47748172525324006,y:.5910112173678703},{x:.48630037931336645,y:.5907854853702875},{x:.49499362353660437,y:.5922845248100812},{x:.5032273814226823,y:.5954507284422511},{x:.5106852342735829,y:.6001624208368403},{x:.5170805809866582,y:.6062385342974724},{x:.5221676519742764,y:.6134455671913789},{x:.5257509539512455,y:.6215065572861976},{x:.5276927826321296,y:.63011172525324},{x:.5279185146297124,y:.6389303793133664},{x:.5264194751899187,y:.6476236235366044},{x:.5232532715577489,y:.6558573814226824},{x:.5185415791631597,y:.663315234273583},{x:.4431175791631597,y:.760171234273583},{x:.4420344490669973,y:.7613112710002186},{x:.44110391182703096,y:.7625789282836855},{x:.4390031114098716,y:.7645018722698176},{x:.4370414657025276,y:.7665665809866583},{x:.43575673751534005,y:.767473404028016},{x:.4345967726198766,y:.768535164822443},{x:.4321611907321885,y:.7700113141492059},{x:.4298344328086211,y:.7716536519742764},{x:.42839747791415833,y:.7722924126294288},{x:.42705266216361437,y:.7731074740629288},{x:.4243758968514515,y:.7740801011395291},{x:.42177344271380235,y:.7752369539512456},{x:.4202394824828045,y:.7755831050064366},{x:.4187614963922926,y:.7761201447252115},{x:.4159464142454535,y:.7765518720385514},{x:.41316827474676,y:.7771787826321297},{x:.4115962584106506,y:.7772190216964318},{x:.4100419001567639,y:.7774574015652649},{x:.23125890015676387,y:.7871214015652648},{x:.22961427991333744,y:.7870487065186679},{x:.22797320559841586,y:.7871788426312305},{x:.22521775007366066,y:.7868543723294609},{x:.22244596265035355,y:.7867318545526676},{x:.22084712542379714,y:.7863397068281228},{x:.21921219559556868,y:.7861471846952227},{x:.21657298639174055,y:.7852913862936938},{x:.21387836011908076,y:.7846304737606538},{x:.21238674832737245,y:.7839339433752962},{x:.2108207924222569,y:.7834261615145331},{x:.2083992528689725,y:.782071922865878},{x:.2058853407234555,y:.7808980140745921},{x:.20455827617124617,y:.7799238683005129},{x:.20312147299647784,y:.7791203404840283},{x:.10291447299647782,y:.7093683404840284},{x:.10181255131472464,y:.7084283417469311},{x:.10059641238964509,y:.7076416809983432},{x:.09846400643554813,y:.7055718520256913},{x:.09620311784593605,y:.7036431918911783},{x:.09530575393663021,y:.7025062807105057},{x:.09426645267874648,y:.7014974784931097},{x:.09257882390791694,y:.6990514089395268},{x:.09073764058529563,y:.6967187299857058},{x:.09007931964022471,y:.6954285972205445},{x:.08925679581402991,y:.6942364212378118},{x:.08807879885369768,y:.6915081121844703},{x:.08672807644060793,y:.6888610579553555},{x:.08633409736450004,y:.6874672826843552},{x:.08575996009935855,y:.6861375475907227},{x:.04484896009935855,y:.5581635475907226},{x:.04400698871411546,y:.5542371548008082},{x:.04309586967447821,y:.5503262293029391},{x:.04308290316808571,y:.5499278363503387},{x:.04299932697019912,y:.5495380927241992},{x:.04293953506277818,y:.5455228840020936},{x:.042808906634767226,y:.5415093553341928},{x:.04287391188557095,y:.5411160877505585},{x:.04286797679041901,y:.5407175280315513},{x:.04359266213029085,y:.5367678055966908},{x:.04424754429113727,y:.532805911414652},{x:.06119154429113727,y:.4696179114146519},{x:.06126294463056804,y:.4694283141856516},{x:.06129777501412092,y:.46922873472253734},{x:.06281676603792068,y:.46530228011432895},{x:.0643004966052513,y:.46136236601319713},{x:.0644075135916399,y:.46119034135699993},{x:.06448061074086608,y:.46100139182805006},{x:.06673642807197144,y:.45744672339211917},{x:.06896028828319853,y:.453871975109843},{x:.06909880931377366,y:.45372413383751425},{x:.06920736414622189,y:.4535530754671619},{x:.07211331798967527,y:.4505067971180214},{x:.07499184614403663,y:.4474345902263458},{x:.07515654793327702,y:.4473166137950705},{x:.07529638874761438,y:.44717002026055797},{x:.1386943887476144,y:.392590020260558},{x:.14135607757337018,y:.39071931904916735},{x:.1439175788350931,y:.3887136217356019},{x:.14495796828078528,y:.38818782053421796},{x:.14591168674437638,y:.38751752344016943},{x:.1488871876674173,y:.38620203695812855},{x:.15179076253542007,y:.38473460266203335},{x:.15291373991533655,y:.3844218744952798},{x:.15397990142199966,y:.3839505182141148},{x:.15715486761053352,y:.383240799869195},{x:.1602889333309822,y:.3823680212676226},{x:.4030282434963717,y:.3398437611206276},{x:.46657219784598525,y:.30072914754350266},{x:.487912612564808,y:.23949853636308405},{x:.45628203537627,y:.13174508671722343},{x:.35793695341674575,y:.08407681754539842},{x:.21775140382412592,y:.0880110894972649},{x:.15207256592030022,y:.12474460286217379},{x:.10828216331322851,y:.2273324289793991},{x:.10404037125679308,y:.23506720851839558},{x:.09837110341432329,y:.2418258338591919},{x:.09149222656964323,y:.24734857482022213},{x:.08366809210217534,y:.25142319556354265},{x:.07519937711167927,y:.2538931106990613},{x:.06641152956592972,y:.2546634027732644},{x:.05764226151782814,y:.2537044698937252},{x:.04922857102060091,y:.2510531633132285},{x:.04149379148160447,y:.24681137125679312},{x:.034735166140808106,y:.24114210341432332},{x:.029212425179777887,y:.23426322656964324},{x:.025137804436457384,y:.22643909210217536},{x:.022667889300938757,y:.21797037711167933},{x:.021897597226735628,y:.20918252956592975}]],T:[[{x:-.022050999999999998,y:.729004},{x:-.021186337618145364,y:.7202249355092742},{x:-.018625578963007903,y:.711783245543571},{x:-.01446713255361454,y:.7040033395141179},{x:-.008870805153394636,y:.6971841948466053},{x:-.002051660485882085,y:.6915878674463855},{x:.005728245543570962,y:.6874294210369921},{x:.014169935509274232,y:.6848686623818546},{x:.022949,y:.684004},{x:.264284,y:.684004},{x:.264284,y:.05103000000000002},{x:.26514866238185464,y:.04225093550927423},{x:.2677094210369921,y:.03380924554357098},{x:.27186786744638547,y:.026029339514117924},{x:.27746419484660534,y:.019210194846605383},{x:.28428333951411794,y:.013613867446385479},{x:.292063245543571,y:.009455421036992116},{x:.30050493550927426,y:.006894662381854655},{x:.309284,y:.0060300000000000215},{x:.3180630644907258,y:.006894662381854655},{x:.32650475445642907,y:.009455421036992116},{x:.3342846604858821,y:.013613867446385486},{x:.34110380515339467,y:.019210194846605383},{x:.34670013255361454,y:.026029339514117924},{x:.3508585789630079,y:.03380924554357098},{x:.35341933761814537,y:.04225093550927425},{x:.354284,y:.05103000000000002},{x:.354284,y:.684004},{x:.579103,y:.684004},{x:.5878820644907258,y:.6848686623818546},{x:.596323754456429,y:.6874294210369921},{x:.6041036604858822,y:.6915878674463855},{x:.6109228051533947,y:.6971841948466053},{x:.6165191325536146,y:.7040033395141179},{x:.6206775789630079,y:.711783245543571},{x:.6232383376181454,y:.7202249355092742},{x:.6241030000000001,y:.729004},{x:.6232383376181454,y:.7377830644907257},{x:.6206775789630079,y:.746224754456429},{x:.6165191325536146,y:.7540046604858821},{x:.6109228051533947,y:.7608238051533946},{x:.6041036604858822,y:.7664201325536145},{x:.596323754456429,y:.7705785789630079},{x:.5878820644907258,y:.7731393376181454},{x:.579103,y:.774004},{x:.022949,y:.774004},{x:.014169935509274211,y:.7731393376181454},{x:.005728245543570935,y:.7705785789630079},{x:-.0020516604858820953,y:.7664201325536145},{x:-.008870805153394643,y:.7608238051533946},{x:-.01446713255361454,y:.7540046604858821},{x:-.018625578963007903,y:.746224754456429},{x:-.021186337618145364,y:.7377830644907257},{x:-.022050999999999998,y:.729004}]],U:[[{x:.027022176378557076,y:.7288780077818786},{x:.02808017637855708,y:.35099900778187865},{x:.02823473618726791,y:.3494735334648019},{x:.028192796744230073,y:.34794082288884604},{x:.035484796744230065,y:.24514582288884607},{x:.03612518708694976,y:.24139252668431194},{x:.03666424897987138,y:.2376233431565944},{x:.055316248979871384,y:.16148034315659432},{x:.05618736340037885,y:.15900518320818077},{x:.05685851158014249,y:.15646848905542057},{x:.057648252259250334,y:.15485425480263812},{x:.058244846291224776,y:.15315910934454152},{x:.0595821022437829,y:.15090145489330362},{x:.06073523897858293,y:.14854443712190207},{x:.09649723897858292,y:.0906284371219021},{x:.09834293286415725,y:.08820732921922435},{x:.10003759110096133,y:.08567820232322114},{x:.10101147458130413,y:.08470684222595504},{x:.10184538199049184,y:.08361295562088691},{x:.10412794610596264,y:.08159844564215248},{x:.10628345014049506,y:.07944852663140606},{x:.15306845014049508,y:.041154526631406},{x:.15518086878702558,y:.03974701384514513},{x:.15716842451696925,y:.03816808161035298},{x:.15884280372557036,y:.03730705230772802},{x:.16040964618671547,y:.03626305906247794},{x:.1627560674239954,y:.03529470367371844},{x:.16501346722603244,y:.034133863066459845},{x:.23490646722603245,y:.006476863066459913},{x:.23625924682734178,y:.006089880823813601},{x:.23754823013535448,y:.005525708919597472},{x:.24049103862888763,y:.004879315347967098},{x:.24338780663402787,y:.004050652809021178},{x:.24479008944495417,y:.003935020529692536},{x:.24616436977860445,y:.0036331571990539033},{x:.3343553697786044,y:-.006825842800946093},{x:.3363658265006992,y:-.006865793301669296},{x:.3383604992721398,y:-.007120376900508131},{x:.34076517153289726,y:-.0069532142518240045},{x:.3431751712391958,y:-.00700110421331946},{x:.3451547915551648,y:-.0066480664270605625},{x:.3471608040448924,y:-.0065086169201366215},{x:.4090588040448924,y:.003962383079863387},{x:.4119620232343868,y:.004752615784895447},{x:.4149089852784979,y:.005359710588792872},{x:.4162090298953196,y:.005908616535408058},{x:.4175706649775032,y:.0062792425557079215},{x:.42026393287145114,y:.0076206811274584655},{x:.4230358315454356,y:.008791034549085273},{x:.4738028315454356,y:.03637303454908527},{x:.4760785863358737,y:.0379161826666043},{x:.4784624107710392,y:.03928649177082543},{x:.47972093897980134,y:.04038599604431689},{x:.48110410464379305,y:.04132389563682743},{x:.48303507818089647,y:.043281370330868374},{x:.4851057640535682,y:.045090410406577325},{x:.5154867640535682,y:.07740541040657731},{x:.5155903820373309,y:.07753992155387555},{x:.5157174079857786,y:.07765259073212467},{x:.5182811318880063,y:.08103290449336144},{x:.5208701788099869,y:.08439386230433626},{x:.5209455639802052,y:.08454600372347547},{x:.521048168494406,y:.08468128952824439},{x:.5340921684944061,y:.10592328952824437},{x:.5341054861393935,y:.10595068243490303},{x:.5341238592672674,y:.10597497562685786},{x:.5360339092314592,y:.10991723311331511},{x:.5379492688231333,y:.11385691363208547},{x:.5379569864823256,y:.11388637833537296},{x:.5379702672090579,y:.11391378915988949},{x:.557924267209058,y:.16807278915988946},{x:.5580810067186996,y:.16867450001810444},{x:.5583366124011981,y:.1692413235937006},{x:.5591915686944892,y:.17293786157308777},{x:.5601479818122073,y:.1766094575809222},{x:.5601843216510317,y:.17723018509512725},{x:.5603244341481242,y:.17783598350956487},{x:.5696394341481241,y:.2495799835095649},{x:.569721927352796,y:.25224539988339456},{x:.5700114646960025,y:.2548963275892337},{x:.5750284646960026,y:.7275053275892338},{x:.5742570402937379,y:.7362930758081182},{x:.5717860339652341,y:.7447614724740409},{x:.5677104050979391,y:.752585081852262},{x:.5621867778235843,y:.7594632470219072},{x:.5554274220406369,y:.7651316439528263},{x:.5476920960011455,y:.7693724393298378},{x:.5392780639467868,y:.7720226617648687},{x:.5305086724107663,y:.7729804646960026},{x:.5217209241918819,y:.7722090402937379},{x:.5132525275259592,y:.7697380339652341},{x:.505428918147738,y:.7656624050979391},{x:.4985507529780929,y:.7601387778235843},{x:.49288235604717384,y:.753379422040637},{x:.48864156067016223,y:.7456440960011456},{x:.48599133823513135,y:.7372300639467868},{x:.4850335353039975,y:.7284606724107663},{x:.48004487037154997,y:.258520878697574},{x:.4717248917269394,y:.19444051929027983},{x:.4550625667192203,y:.14921575933773623},{x:.4467624246683876,y:.135699076001046},{x:.42448554918380393,y:.11200409455592171},{x:.3866565267646711,y:.09145137140181527},{x:.33852910612300163,y:.08330987698295},{x:.2625775703514966,y:.09231733933890664},{x:.20464797458906397,y:.11524036210229632},{x:.16911733402594603,y:.14432255403825953},{x:.14104265103985364,y:.1897890642955865},{x:.12498883901236212,y:.25532548983758135},{x:.11807553704626646,y:.35278200048003916},{x:.11702182362144292,y:.7291299922181214},{x:.11613258476624799,y:.737906601393955},{x:.11354820087598706,y:.7463410885908555},{x:.10936798837422372,y:.7541093211959605},{x:.10375259048311052,y:.7609127703867312},{x:.09691780379445152,y:.7664899834261845},{x:.0891262853276994,y:.770626631144951},{x:.08067745876799748,y:.7731637444910576},{x:.07189600778187862,y:.7740038236214429},{x:.06311939860604492,y:.773114584766248},{x:.05468491140914452,y:.770530200875987},{x:.04691667880403945,y:.7663499883742237},{x:.04011322961326877,y:.7607345904831105},{x:.03453601657381558,y:.7538998037944515},{x:.030399368855048972,y:.7461082853276993},{x:.027862255508942363,y:.7376594587679974},{x:.027022176378557076,y:.7288780077818786}]],V:[[{x:-.017163400590915968,y:.72836062945125},{x:-.016173311217885875,y:.7195948244454146},{x:-.01349212241321528,y:.7111906087794154},{x:.27875887758678475,y:.033216608779415485},{x:.2789749302503264,y:.03282594254600198},{x:.27911899522766415,y:.032403397706182537},{x:.2811076886540147,y:.028969490703698003},{x:.2830281292409603,y:.025496951748158487},{x:.28331624571443165,y:.0251559418405784},{x:.28353997693249255,y:.024769621764193565},{x:.2861603801951793,y:.021789671162821947},{x:.2887213787977949,y:.018758515442121357},{x:.2890704869266977,y:.018480266679882864},{x:.2893652865202418,y:.018145017430816868},{x:.2925166989914198,y:.015733541060992128},{x:.2956198378696305,y:.013260254189586457},{x:.29601652162435305,y:.013055459516578674},{x:.296371060610326,y:.012784164535463174},{x:.29993237527606087,y:.011033834081706148},{x:.30345840254303674,y:.009213463087028258},{x:.303887417589348,y:.00908999264768462},{x:.3042880712333465,y:.00889307764850001},{x:.3081224287682413,y:.00787115732855266},{x:.3119358411735324,y:.006773658047051503},{x:.31238070070379703,y:.0067362567411129665},{x:.3128120721109714,y:.0066212890568466964},{x:.3167721203052928,y:.006367050695504971},{x:.32072637054875,y:.006034599409084053},{x:.3211699788607,y:.006084704547762943},{x:.3216154906697884,y:.006056102322046737},{x:.325549047092249,y:.006579316156958459},{x:.3294921755545854,y:.0070246887821141385},{x:.32991748502957097,y:.007160374853030322},{x:.330360016471596,y:.007219237253358143},{x:.3341159167548444,y:.008499796470269213},{x:.33789639122058457,y:.00970587758678474},{x:.33828705745399834,y:.009921930250326543},{x:.33870960229381747,y:.01006599522766418},{x:.3421435092963017,y:.012054688654014527},{x:.34561604825184156,y:.013975129240960359},{x:.3459570581594215,y:.014263245714431577},{x:.34634337823580646,y:.014486976932492547},{x:.34932332883717915,y:.01710738019518028},{x:.35235448455787866,y:.01966837879779494},{x:.3526327333201171,y:.020017486926697612},{x:.35296798256918316,y:.020312286520241793},{x:.3553794589390082,y:.023463698991420194},{x:.3578527458104136,y:.026566837869630475},{x:.3580575404834214,y:.026963521624353053},{x:.35832883546453687,y:.02731806061032596},{x:.3600791659182934,y:.03087937527605991},{x:.3618995369129718,y:.03440540254303673},{x:.3620230073523154,y:.034834417589348},{x:.3622199223515,y:.0352350712333465},{x:.6163569223515,y:.7132090712333464},{x:.6186287109431533,y:.7217330721109714},{x:.6191938976779532,y:.7305364906697883},{x:.6180307627466418,y:.7392810164715959},{x:.6151840047723358,y:.7476306022938175},{x:.6107630230675074,y:.7552643782358064},{x:.6049377134797582,y:.7618889825691831},{x:.597931939389674,y:.7672498354645368},{x:.5900149287666535,y:.7711409223515},{x:.5814909278890286,y:.7734127109431533},{x:.5726875093302116,y:.7739778976779532},{x:.5639429835284039,y:.7728147627466418},{x:.5555933977061824,y:.7699680047723358},{x:.5479596217641935,y:.7655470230675074},{x:.5413350174308168,y:.7597217134797583},{x:.5359741645354631,y:.7527159393896741},{x:.5320830776484999,y:.7447989287666535},{x:.3171703309688009,y:.17146543337864517},{x:.06915612241321528,y:.7468173912205845},{x:.06488687075903964,y:.7545370482518415},{x:.059193621202205074,y:.7612754845578786},{x:.05229516213036956,y:.7667737458104136},{x:.04445659745696326,y:.7708205369129717},{x:.0359791588264676,y:.7732603419529485},{x:.027188629451250054,y:.773999400590916},{x:.01842282444541461,y:.7730093112178859},{x:.010018608779415478,y:.7703281224132152},{x:.0022989517481584835,y:.7660588707590397},{x:-.004439484557878664,y:.7603656212022051},{x:-.009937745810413578,y:.7534671621303695},{x:-.013984536912971763,y:.7456285974569633},{x:-.016424341952948517,y:.7371511588264675},{x:-.017163400590915968,y:.72836062945125}]],W:[[{x:-.04486424190193638,y:.7324968210037928},{x:-.04468360364824366,y:.7236771280279449},{x:.03511539635175633,y:.05429612802794491},{x:.03538914303981033,y:.053053468981350556},{x:.035486899606724354,y:.05178477579191172},{x:.03633616861564037,y:.04875449496443272},{x:.037013200434797444,y:.04568114375463893},{x:.03752411791055629,y:.04451576738270255},{x:.03786750587531561,y:.043290523137271594},{x:.039291634880795206,y:.040484152470619886},{x:.040555238800576446,y:.03760193719815913},{x:.041283692791972554,y:.036558628261303676},{x:.041859515947665654,y:.035423918409107566},{x:.04380377647068911,y:.032949305154171604},{x:.045605392901094464,y:.030368987735599786},{x:.046523389329760155,y:.02948784001117424},{x:.047309519115439125,y:.028487270815480248},{x:.049699194314460494,y:.02643951297186818},{x:.05196958814642765,y:.024260253558522238},{x:.05304184892442764,y:.02357512905942291},{x:.054008074813295476,y:.022747151833295932},{x:.056751330810561565,y:.021204943586542027},{x:.059403252082379655,y:.019510489895534},{x:.060588570829346225,y:.019047717572039012},{x:.06169776130235942,y:.01842415101594414},{x:.06468917630833097,y:.01744675856409077},{x:.06762071317273859,y:.01630222750050557},{x:.06887353875396018,y:.016079591433481148},{x:.07008306824328207,y:.01568439886046892},{x:.07320768385688461,y:.015309382847312772},{x:.07630617899620724,y:.014758758098063603},{x:.07757836602719018,y:.014784814066709744},{x:.07884175299285809,y:.014633182505734484},{x:.08197949198836539,y:.014874954586349768},{x:.08512587197205507,y:.014939396351756326},{x:.08636853101864941,y:.015213143039810315},{x:.08763722420808827,y:.015310899606724347},{x:.09066750503556728,y:.016160168615640357},{x:.09374085624536103,y:.01683720043479743},{x:.09490623261729739,y:.017348117910556266},{x:.09613147686272838,y:.017691505875315594},{x:.09893784752938008,y:.01911563488079519},{x:.10182006280184085,y:.020379238800576432},{x:.10286337173869634,y:.02110769279197256},{x:.1039980815908924,y:.02168351594766564},{x:.10647269484582828,y:.023627776470689026},{x:.1090530122644002,y:.025429392901094458},{x:.10993415998882576,y:.026347389329760156},{x:.11093472918451973,y:.02713351911543911},{x:.11298248702813177,y:.02952319431446044},{x:.11516174644147774,y:.03179358814642764},{x:.11584687094057705,y:.032865848924427614},{x:.11667484816670405,y:.03383207481329547},{x:.118217056413458,y:.03657533081056164},{x:.11991151010446596,y:.039227252082379635},{x:.12037428242796094,y:.040412570829346184},{x:.12099784898405583,y:.041521761302359406},{x:.2862381791186236,y:.4176126753554925},{x:.4644074439049092,y:.03214939722735514},{x:.46457066699968924,y:.031871550040082325},{x:.46468087848244366,y:.03156873942729889},{x:.4668033610072479,y:.028070937443703255},{x:.4688757411162635,y:.024543219843286366},{x:.46909003322228215,y:.024302554657928657},{x:.4692572024422568,y:.02402706365982141},{x:.47202128937582516,y:.021010546759784428},{x:.47474207284479647,y:.017954914566682648},{x:.47499919883659564,y:.017760680011347015},{x:.4752169015744166,y:.01752309559247584},{x:.47851637060601154,y:.015103786828781735},{x:.4817809992520572,y:.012637666274559728},{x:.4820710779219699,y:.012497326674279732},{x:.48233094798351184,y:.012306779070622963},{x:.4860390023686124,y:.010577651122297159},{x:.4897220183436901,y:.008795813836836655},{x:.4900339021311097,y:.008714762363747632},{x:.4903259528556443,y:.008578574212853553},{x:.49430009414373083,y:.007606076497244536},{x:.4982599612093785,y:.006576997488159493},{x:.4985816645952609,y:.006558348904918078},{x:.4988946726372282,y:.006481753841050326},{x:.5029821768073245,y:.006303258899985619},{x:.5070667194929276,y:.00606648509648134},{x:.5073858795965667,y:.006110956057683261},{x:.5077078162324508,y:.006096897586191266},{x:.5117516027915979,y:.006719264880154805},{x:.5158038544123874,y:.0072838953667157535},{x:.5161082060899873,y:.007389776878261636},{x:.5164266994754154,y:.007438795258320738},{x:.5202713679739276,y:.008838107561233023},{x:.5241356027726449,y:.01018244390490916},{x:.524413449959918,y:.010345666999689355},{x:.5247162605727012,y:.010455878482443691},{x:.5282140625562944,y:.012578361007246536},{x:.5317417801567137,y:.014650741116263542},{x:.5319824453420714,y:.01486503322228222},{x:.5322579363401786,y:.01503220244225683},{x:.535274453240215,y:.01779628937582467},{x:.5383300854333174,y:.020517072844796484},{x:.5385243199886531,y:.020774198836595797},{x:.5387619044075241,y:.0209919015744166},{x:.5411812131712181,y:.024291370606011366},{x:.5436473337254403,y:.027555999252057217},{x:.5437876733257202,y:.027846077921969747},{x:.5439782209293771,y:.028105947983511865},{x:.5457073488777034,y:.03181400236861376},{x:.5474891861631633,y:.0354970183436901},{x:.5475702376362523,y:.03580890213110964},{x:.5477064257871465,y:.03610095285564429},{x:.548678923502756,y:.040075094143733274},{x:.5497080025118405,y:.04403496120937851},{x:.5497266510950819,y:.04435666459526063},{x:.5498032461589497,y:.04466967263722821},{x:.6466002461589497,y:.7226436726372282},{x:.6469851024138088,y:.7314568162324507},{x:.6456432047416794,y:.7401756994754154},{x:.6426261215175564,y:.7484652605727011},{x:.6380497975577433,y:.7560069363401786},{x:.6320900984255835,y:.7625109044075241},{x:.6249760520164882,y:.7677272209293771},{x:.6169810471443558,y:.7714554257871464},{x:.6084123273627718,y:.7735522461589497},{x:.5995991837675493,y:.7739371024138088},{x:.5908803005245846,y:.7725952047416793},{x:.5825907394272989,y:.7695781215175563},{x:.5750490636598214,y:.7650017975577432},{x:.5685450955924759,y:.7590420984255835},{x:.563328779070623,y:.7519280520164882},{x:.5596005742128536,y:.7439330471443557},{x:.5575037538410503,y:.7353643273627718},{x:.4822251865940539,y:.2081071670095049},{x:.3260455560950909,y:.5459966027726448},{x:.3245096626856286,y:.5486110836728201},{x:.32313748405233433,y:.5513150815908924},{x:.32228015650766817,y:.5524062697730983},{x:.32157725888373645,y:.5536027801567136},{x:.3195608173147473,y:.5558673865996665},{x:.3176874808845609,y:.5582517291845196},{x:.31663374639442166,y:.5591546941850146},{x:.31571092715520355,y:.5601910854333173},{x:.3132914281453504,y:.5620187898634509},{x:.3109889251867045,y:.563991848166704},{x:.30977927817660644,y:.5646718895469083},{x:.3086720007479428,y:.5655083337254402},{x:.3059424242873038,y:.566828898486493},{x:.3032992386976406,y:.5683148489840557},{x:.30198016522380455,y:.5687458331350992},{x:.3007309816563099,y:.5693501861631632},{x:.29779622383750376,y:.570112862691949},{x:.29491393175671793,y:.571054601139531},{x:.29353612307299787,y:.5712199655821879},{x:.29219303879062153,y:.5715690025118404},{x:.28916588071079274,y:.5717444815770724},{x:.2861552470071419,y:.5721058174942654},{x:.2847716515285703,y:.5719992073657418},{x:.2833862805070725,y:.5720795149035186},{x:.28038305415357795,y:.5716610529431293},{x:.27735977579191173,y:.5714281003932755},{x:.27602356431680025,y:.5710536126610233},{x:.27464914558761266,y:.5708621046332842},{x:.27178526326499086,y:.5698657829057354},{x:.26886552313727163,y:.5690474941246844},{x:.26762804552325165,y:.5684195201422382},{x:.26631739722735515,y:.5679635560950907},{x:.26370291632718046,y:.5664276626856288},{x:.2609989184091076,y:.5650554840523343},{x:.25990773022690183,y:.5641981565076682},{x:.2587112198432863,y:.5634952588837364},{x:.25644661340033337,y:.5614788173147471},{x:.2540622708154803,y:.5596054808845607},{x:.2531593058149851,y:.5585517463944213},{x:.2521229145666826,y:.5576289271552034},{x:.2502952101365493,y:.5552094281453507},{x:.24832215183329598,y:.5529069251867045},{x:.2476421104530918,y:.5516972781766065},{x:.24680566627455972,y:.5505900007479427},{x:.245485101513507,y:.5478604242873037},{x:.24399915101594416,y:.5452172386976405},{x:.10495542809967917,y:.22875042455884986},{x:.04468360364824366,y:.734330871972055},{x:.04278579956520255,y:.742945856245361},{x:.03924376119942353,y:.7510250628018409},{x:.034193607098905524,y:.7582580122644001},{x:.02782941185357234,y:.7643667464414777},{x:.020395747917620333,y:.7691165101044659},{x:.012178286827261426,y:.7723247724994944},{x:.003492821003792758,y:.7738682419019364},{x:-.00532687197205508,y:.7736876036482436},{x:-.013941856245361059,y:.7717897995652026},{x:-.022021062801840872,y:.7682477611994235},{x:-.029254012264400202,y:.7631976070989055},{x:-.035362746441477744,y:.7568334118535723},{x:-.04011251010446598,y:.7493997479176203},{x:-.04332077249949441,y:.7411822868272614},{x:-.04486424190193638,y:.7324968210037928}]],X:[[{x:-.03582341524240513,y:.7325834270170574},{x:-.035659804156077404,y:.7237634017461555},{x:-.03377863524060577,y:.7151447697271875},{x:-.030252200762440104,y:.7070587401552579},{x:-.02521601962092907,y:.6998160546121182},{x:.24190189785100796,y:.3863717955888736},{x:-.0190039697420246,y:.08021800391719859},{x:-.024040163260448045,y:.07297532698032597},{x:-.027566611556706647,y:.06488930343468059},{x:-.029447795200430175,y:.056270674630427356},{x:-.029611421359170286,y:.047450649639130975},{x:-.028051201971409197,y:.03876817707487998},{x:-.024827095393237467,y:.030556919489131844},{x:-.02006300223235442,y:.02313243090598055},{x:-.013942003917198569,y:.016780030257975413},{x:-.006699326980325947,y:.011743836739551976},{x:.0013866965653194212,y:.00821738844329338},{x:.010005325369572668,y:.006336204799569846},{x:.018825350360869044,y:.0061725786408297345},{x:.02750782292512003,y:.007732798028590823},{x:.03571908051086817,y:.010956904606762553},{x:.04314356909401947,y:.0157209977676456},{x:.049495969742024595,y:.021841996082801452},{x:.3010259353438819,y:.31699385831754345},{x:.5525549803790709,y:.021842054612118165},{x:.558907370566982,y:.01572104544144637},{x:.5663318510088331,y:.010956939592969957},{x:.5745431030849405,y:.007732818982704524},{x:.5832255729829426,y:.006172584757594898},{x:.5920455982538445,y:.006336195843922615},{x:.6006642302728125,y:.008217364759394247},{x:.6087502598447422,y:.011743799237559922},{x:.6159929453878819,y:.016779980379070948},{x:.6221139545585537,y:.023132370566981995},{x:.6268780604070301,y:.03055685100883309},{x:.6301021810172955,y:.0387681030849405},{x:.6316624152424052,y:.04745057298294264},{x:.6314988041560774,y:.05627059825384449},{x:.6296176352406058,y:.06488923027281246},{x:.6260912007624402,y:.07297525984474214},{x:.6210550196209291,y:.08021794538788188},{x:.36015009139561527,y:.3863716945525663},{x:.6272689697420246,y:.6998159960828014},{x:.632305163260448,y:.7070586730196741},{x:.6358316115567066,y:.7151446965653194},{x:.6377127952004301,y:.7237633253695727},{x:.6378764213591702,y:.7325833503608691},{x:.6363162019714091,y:.74126582292512},{x:.6330920953932374,y:.7494770805108681},{x:.6283280022323544,y:.7569015690940195},{x:.6222070039171985,y:.7632539697420246},{x:.6149643269803259,y:.7682901632604481},{x:.6068783034346805,y:.7718166115567067},{x:.5982596746304273,y:.7736977952004301},{x:.5894396496391309,y:.7738614213591702},{x:.58075717707488,y:.7723012019714092},{x:.5725459194891318,y:.7690770953932374},{x:.5651214309059804,y:.7643130022323544},{x:.5587690302579753,y:.7581920039171985},{x:.30102605390274134,y:.4557496318238965},{x:.04328401962092907,y:.7581919453878818},{x:.03693162943301802,y:.7643129545585536},{x:.029507148991166913,y:.76907706040703},{x:.021295896915059523,y:.7723011810172955},{x:.012613427017057378,y:.7738614152424051},{x:.003793401746155514,y:.7736978041560774},{x:-.004825230272812429,y:.7718166352406057},{x:-.012911259844742107,y:.7682902007624401},{x:-.02015394538788185,y:.7632540196209291},{x:-.02627495455855365,y:.756901629433018},{x:-.031039060407030063,y:.7494771489911669},{x:-.034263181017295495,y:.7412658969150595},{x:-.03582341524240513,y:.7325834270170574}]],Y:[[{x:-.02688005049839745,y:.731186349993587},{x:-.02644216088936969,y:.7223756821949907},{x:-.024293809188388457,y:.7138197369324374},{x:-.020517555346512936,y:.7058473143841377},{x:-.015258518681138845,y:.6987647902776368},{x:.25043465103960333,y:.4059541390643743},{x:.26029423204414154,y:.04978477430584237},{x:.26140149479875585,y:.04103299828270508},{x:.26419486861258723,y:.03266540142918031},{x:.26856700569651215,y:.025003545799746604},{x:.27434988727431814,y:.01834187220942495},{x:.28132128045004745,y:.012936385038381841},{x:.28921327849355916,y:.008994814127168342},{x:.2977225963459245,y:.006668631835443931},{x:.30652222569415766,y:.00604723204414153},{x:.3152740017172949,y:.007154494798755871},{x:.32364159857081976,y:.009947868612587236},{x:.3313034542002534,y:.014320005696512164},{x:.3379651277905751,y:.020102887274318144},{x:.3433706149616182,y:.027074280450047443},{x:.3473121858728317,y:.03496627849355913},{x:.3496383681645561,y:.04347559634592452},{x:.3502597679558585,y:.05227522569415767},{x:.34045421751128274,y:.4064927803087797},{x:.6166036868780955,y:.6970396048261934},{x:.6220250193382449,y:.7039986829780357},{x:.6259845336177533,y:.7118816938899454},{x:.6283300678033804,y:.7203856978734211},{x:.6289714843317633,y:.7291838908244783},{x:.6278841339254269,y:.7379381631220915},{x:.6251098028506934,y:.7463120929913156},{x:.620755107094902,y:.7539838750034306},{x:.6149873951738065,y:.7606586868780956},{x:.6080283170219642,y:.7660800193382449},{x:.6001453061100546,y:.7700395336177532},{x:.5916413021265788,y:.7723850678033803},{x:.5828431091755216,y:.7730264843317632},{x:.5740888368779085,y:.7719391339254268},{x:.5657149070086843,y:.7691648028506933},{x:.5580431249965694,y:.7648101070949019},{x:.5513683131219045,y:.7590423951738065},{x:.29567976193894085,y:.4900232412279098},{x:.051392518681138845,y:.7592432097223631},{x:.04485280102201476,y:.765163657957578},{x:.03728372005126494,y:.7696945108160528},{x:.028976151305805796,y:.7726616501633681},{x:.02024934999358704,y:.7739510504983974},{x:.011438682194990706,y:.7735131608893697},{x:.002882736932437466,y:.7713648091883885},{x:-.0050896856158622154,y:.7675885553465129},{x:-.012172209722363214,y:.7623295186811389},{x:-.01809265795757798,y:.7557898010220148},{x:-.022623510816052815,y:.7482207200512649},{x:-.025590650163368103,y:.7399131513058058},{x:-.02688005049839745,y:.731186349993587}]],Z:[[{x:.008711000000000003,y:.05103000000000002},{x:.00905278632815029,y:.04755978517413498},{x:.009251179439517476,y:.04407842782316871},{x:.009484424544736794,y:.043177288815328604},{x:.009575662381854637,y:.04225093550927423},{x:.01058788670939069,y:.038914079093048184},{x:.01146164687940622,y:.0355383196233794},{x:.011866213744552238,y:.0346999996115786},{x:.012136421036992098,y:.03380924554357098},{x:.013780184150668652,y:.030733981057728944},{x:.015295733266009179,y:.0275935480126292},{x:.015856074613338045,y:.026850263164785913},{x:.01629486744638546,y:.026029339514117927},{x:.01850700045157689,y:.023333847648222647},{x:.020606096809669634,y:.02054942610843994},{x:.02130067903544657,y:.01992974044441782},{x:.021891194846605365,y:.019210194846605383},{x:.024586686712500538,y:.016998061841414044},{x:.027188663217490867,y:.014676655565200585},{x:.02799079391630549,y:.014204383257544266},{x:.028710339514117916,y:.013613867446385479},{x:.03178560399995988,y:.01197010433270896},{x:.03479046815396611,y:.010200923661400137},{x:.035669321892902964,y:.00989421387003954},{x:.036490245543570964,y:.009455421036992116},{x:.03982710195979704,y:.008443196709456058},{x:.04311937851852794,y:.007294230264082269},{x:.04404118144126662,y:.007164869674294513},{x:.04493193550927423,y:.006894662381854655},{x:.048402150335139275,y:.006552876053704368},{x:.05185531895677298,y:.006068277970413476},{x:.052784646693945655,y:.006121237837117864},{x:.053711,y:.0060300000000000215},{x:.548341,y:.0060300000000000215},{x:.5571200644907257,y:.006894662381854655},{x:.565561754456429,y:.009455421036992116},{x:.5733416604858821,y:.013613867446385479},{x:.5801608051533946,y:.019210194846605383},{x:.5857571325536145,y:.026029339514117927},{x:.5899155789630078,y:.03380924554357098},{x:.5924763376181453,y:.04225093550927425},{x:.593341,y:.05103000000000002},{x:.5924763376181453,y:.05980906449072579},{x:.5899155789630078,y:.06825075445642906},{x:.5857571325536145,y:.07603066048588211},{x:.5801608051533946,y:.08284980515339466},{x:.5733416604858821,y:.08844613255361455},{x:.565561754456429,y:.09260457896300792},{x:.5571200644907257,y:.09516533761814538},{x:.548341,y:.09603000000000002},{x:.14224494935878249,y:.09603000000000002},{x:.5846943444347994,y:.7024816632174908},{x:.5851666167424556,y:.7032837939163054},{x:.5857571325536145,y:.7040033395141179},{x:.5874008956672913,y:.7070786039999603},{x:.5891700763385999,y:.7100834681539662},{x:.5894767861299605,y:.7109623218929031},{x:.5899155789630078,y:.711783245543571},{x:.5909278032905438,y:.7151201019597967},{x:.5920767697359177,y:.7184123785185279},{x:.5922061303257055,y:.7193341814412667},{x:.5924763376181453,y:.7202249355092742},{x:.5928181239462956,y:.7236951503351391},{x:.5933027220295866,y:.7271483189567729},{x:.5932497621628822,y:.7280776466939456},{x:.593341,y:.729004},{x:.5929992136718496,y:.7324742148258655},{x:.5928008205604824,y:.7359555721768313},{x:.5925675754552632,y:.7368567111846711},{x:.5924763376181453,y:.7377830644907257},{x:.5914641132906093,y:.7411199209069517},{x:.5905903531205937,y:.7444956803766206},{x:.5901857862554476,y:.7453340003884216},{x:.5899155789630078,y:.746224754456429},{x:.5882718158493319,y:.74930001894227},{x:.5867562667339908,y:.7524404519873709},{x:.5861959253866618,y:.7531837368352144},{x:.5857571325536145,y:.7540046604858821},{x:.5835449995484229,y:.7567001523517777},{x:.5814459031903303,y:.7594845738915601},{x:.5807513209645536,y:.760104259555582},{x:.5801608051533946,y:.7608238051533946},{x:.5774653132874991,y:.7630359381585863},{x:.5748633367825091,y:.7653573444347994},{x:.5740612060836946,y:.7658296167424556},{x:.5733416604858821,y:.7664201325536145},{x:.5702663960000408,y:.7680638956672906},{x:.5672615318460339,y:.7698330763385999},{x:.5663826781070966,y:.7701397861299606},{x:.565561754456429,y:.7705785789630079},{x:.5622248980402041,y:.7715908032905435},{x:.558932621481472,y:.7727397697359177},{x:.5580108185587332,y:.7728691303257055},{x:.5571200644907257,y:.7731393376181454},{x:.553649849664861,y:.7734811239462956},{x:.5501966810432269,y:.7739657220295866},{x:.5492673533060543,y:.7739127621628822},{x:.548341,y:.774004},{x:.053711,y:.774004},{x:.04493193550927421,y:.7731393376181454},{x:.036490245543570936,y:.7705785789630079},{x:.028710339514117906,y:.7664201325536145},{x:.021891194846605358,y:.7608238051533946},{x:.01629486744638546,y:.7540046604858821},{x:.012136421036992098,y:.746224754456429},{x:.009575662381854637,y:.7377830644907257},{x:.008711000000000003,y:.729004},{x:.009575662381854637,y:.7202249355092742},{x:.012136421036992098,y:.711783245543571},{x:.01629486744638546,y:.7040033395141179},{x:.021891194846605365,y:.6971841948466053},{x:.028710339514117916,y:.6915878674463855},{x:.036490245543570964,y:.6874294210369921},{x:.04493193550927423,y:.6848686623818546},{x:.053711,y:.684004},{x:.4598070506412174,y:.684004},{x:.017357655565200567,y:.07755233678250915},{x:.016885383257544267,y:.07675020608369457},{x:.01629486744638546,y:.07603066048588211},{x:.014651104332708876,y:.07295539600004002},{x:.012881923661400112,y:.06995053184603389},{x:.012575213870039523,y:.06907167810709706},{x:.012136421036992098,y:.06825075445642906},{x:.011124196709456038,y:.06491389804020298},{x:.00997523026408225,y:.06162162148147208},{x:.009845869674294495,y:.0606998185587334},{x:.009575662381854637,y:.05980906449072579},{x:.009233876053704348,y:.056338849664860746},{x:.008749277970413458,y:.05288568104322705},{x:.008802237837117845,y:.05195635330605437},{x:.008711000000000003,y:.05103000000000002}]],"[":[[{x:.152511,y:-.06942399999999993},{x:.15337566238185463,y:-.0782030644907257},{x:.1559364210369921,y:-.08664475445642897},{x:.16009486744638546,y:-.09442466048588202},{x:.16569119484660536,y:-.10124380515339457},{x:.1725103395141179,y:-.10684013255361446},{x:.18029024554357093,y:-.11099857896300783},{x:.1887319355092742,y:-.1135593376181453},{x:.197511,y:-.11442399999999993},{x:.404542,y:-.11442399999999993},{x:.4133210644907258,y:-.1135593376181453},{x:.4217627544564291,y:-.11099857896300783},{x:.42954266048588213,y:-.10684013255361446},{x:.4363618051533946,y:-.10124380515339457},{x:.44195813255361455,y:-.09442466048588202},{x:.44611657896300794,y:-.08664475445642897},{x:.4486773376181454,y:-.0782030644907257},{x:.449542,y:-.06942399999999993},{x:.4486773376181454,y:-.06064493550927416},{x:.44611657896300794,y:-.05220324554357089},{x:.44195813255361455,y:-.04442333951411784},{x:.4363618051533946,y:-.03760419484660529},{x:.42954266048588213,y:-.032007867446385396},{x:.4217627544564291,y:-.027849421036992027},{x:.4133210644907258,y:-.025288662381854565},{x:.404542,y:-.024423999999999932},{x:.24251099999999998,y:-.024423999999999932},{x:.24251099999999998,y:.7147659999999999},{x:.404542,y:.7147659999999999},{x:.4133210644907258,y:.7156306623818546},{x:.4217627544564291,y:.7181914210369921},{x:.42954266048588213,y:.7223498674463854},{x:.4363618051533946,y:.7279461948466053},{x:.44195813255361455,y:.7347653395141178},{x:.44611657896300794,y:.7425452455435709},{x:.4486773376181454,y:.7509869355092742},{x:.449542,y:.7597659999999999},{x:.4486773376181454,y:.7685450644907257},{x:.44611657896300794,y:.776986754456429},{x:.44195813255361455,y:.7847666604858821},{x:.4363618051533946,y:.7915858051533946},{x:.42954266048588213,y:.7971821325536145},{x:.4217627544564291,y:.8013405789630078},{x:.4133210644907258,y:.8039013376181453},{x:.404542,y:.804766},{x:.197511,y:.804766},{x:.1887319355092742,y:.8039013376181453},{x:.18029024554357093,y:.8013405789630078},{x:.1725103395141179,y:.7971821325536145},{x:.16569119484660536,y:.7915858051533946},{x:.16009486744638546,y:.7847666604858821},{x:.1559364210369921,y:.776986754456429},{x:.15337566238185463,y:.7685450644907257},{x:.152511,y:.7597659999999999},{x:.152511,y:-.06942399999999993}]],"\\\\":[[{x:.017522651058219416,y:.7303997530123288},{x:.018114599516431164,y:.7215980934307649},{x:.020412292453046287,y:.7130810386853763},{x:.024327430817071727,y:.7051758944136092},{x:.5013774308170718,y:-.059077105586390885},{x:.5067595580368128,y:-.06606654912342862},{x:.5134018419815468,y:-.0718716915303336},{x:.521049023404313,y:-.07626944443996993},{x:.5294072254116235,y:-.07909080467430848},{x:.5381552469876711,y:-.08022734894178067},{x:.5469569065692351,y:-.07963540048356893},{x:.5554739613146237,y:-.0773377075469538},{x:.5633791055863908,y:-.07342256918292836},{x:.5703685491234285,y:-.06804044196318723},{x:.5761736915303335,y:-.06139815801845332},{x:.5805714444399699,y:-.05375097659568702},{x:.5833928046743084,y:-.04539277458837649},{x:.5845293489417805,y:-.03664475301232898},{x:.5839374004835688,y:-.02784309343076498},{x:.5816397075469537,y:-.01932603868537643},{x:.5777245691829282,y:-.011420894413609283},{x:.10067456918292828,y:.7528321055863908},{x:.09529244196318712,y:.7598215491234285},{x:.0886501580184532,y:.7656266915303336},{x:.08100297659568693,y:.7700244444399699},{x:.07264477458837638,y:.7728458046743084},{x:.06389675301232887,y:.7739823489417805},{x:.055095093430764894,y:.7733904004835688},{x:.04657803868537634,y:.7710927075469537},{x:.03867289441360919,y:.7671775691829282},{x:.03168345087657147,y:.7617954419631872},{x:.025878308469666468,y:.7551531580184532},{x:.021480555560030153,y:.747505976595687},{x:.01865919532569161,y:.7391477745883763},{x:.017522651058219416,y:.7303997530123288}]],"]":[[{x:.15250999999999998,y:-.06942399999999993},{x:.15337466238185463,y:-.0782030644907257},{x:.1559354210369921,y:-.08664475445642897},{x:.16009386744638546,y:-.09442466048588202},{x:.16569019484660535,y:-.10124380515339457},{x:.1725093395141179,y:-.10684013255361446},{x:.18028924554357095,y:-.11099857896300783},{x:.18873093550927422,y:-.1135593376181453},{x:.19751,y:-.11442399999999993},{x:.404542,y:-.11442399999999993},{x:.4133210644907258,y:-.1135593376181453},{x:.4217627544564291,y:-.11099857896300783},{x:.42954266048588213,y:-.10684013255361446},{x:.4363618051533946,y:-.10124380515339457},{x:.44195813255361455,y:-.09442466048588202},{x:.44611657896300794,y:-.08664475445642897},{x:.4486773376181454,y:-.0782030644907257},{x:.449542,y:-.06942399999999993},{x:.449542,y:.7597659999999999},{x:.4486773376181454,y:.7685450644907257},{x:.44611657896300794,y:.776986754456429},{x:.44195813255361455,y:.7847666604858821},{x:.4363618051533946,y:.7915858051533946},{x:.42954266048588213,y:.7971821325536145},{x:.4217627544564291,y:.8013405789630078},{x:.4133210644907258,y:.8039013376181453},{x:.404542,y:.804766},{x:.19751,y:.804766},{x:.18873093550927422,y:.8039013376181453},{x:.18028924554357095,y:.8013405789630078},{x:.1725093395141179,y:.7971821325536145},{x:.16569019484660535,y:.7915858051533946},{x:.16009386744638546,y:.7847666604858821},{x:.1559354210369921,y:.776986754456429},{x:.15337466238185463,y:.7685450644907257},{x:.15250999999999998,y:.7597659999999999},{x:.15337466238185463,y:.7509869355092742},{x:.1559354210369921,y:.7425452455435709},{x:.16009386744638546,y:.7347653395141178},{x:.16569019484660535,y:.7279461948466053},{x:.1725093395141179,y:.7223498674463854},{x:.18028924554357095,y:.7181914210369921},{x:.18873093550927422,y:.7156306623818546},{x:.19751,y:.7147659999999999},{x:.35954200000000003,y:.7147659999999999},{x:.35954200000000003,y:-.024423999999999932},{x:.19751,y:-.024423999999999932},{x:.18873093550927422,y:-.025288662381854565},{x:.18028924554357095,y:-.027849421036992027},{x:.1725093395141179,y:-.03200786744638539},{x:.16569019484660535,y:-.03760419484660529},{x:.16009386744638546,y:-.04442333951411784},{x:.1559354210369921,y:-.052203245543570885},{x:.15337466238185463,y:-.06064493550927414},{x:.15250999999999998,y:-.06942399999999993}]],"^":[[{x:-.009830024293871129,y:.4771904357900641},{x:-.009184411720694952,y:.46839254975009553},{x:-.006834821991481832,y:.4598896653882279},{x:-.002871548521860348,y:.4520085437820153},{x:.002553102311361327,y:.44505205201500053},{x:.009230664218841726,y:.43928752416454453},{x:.016904522241296224,y:.4349364878031557},{x:.02527977431847106,y:.43216615081811305},{x:.034034564209935884,y:.43108297570612886},{x:.04283245024990444,y:.431728588279305},{x:.05133533461177206,y:.4340781780085181},{x:.05921645621798466,y:.4380414514781396},{x:.06617294798499941,y:.4434661023113613},{x:.30102423332324457,y:.6668931783680099},{x:.5358792969655858,y:.44346586927801307},{x:.5428358294884947,y:.4380412707099504},{x:.5507169808710617,y:.43407805645230807},{x:.5592198828854552,y:.4317285306064111},{x:.5680177737757447,y:.431082984132888},{x:.5767725555289304,y:.4321662250206897},{x:.5851477867919753,y:.43493662492998636},{x:.5928216121243246,y:.439287718945922},{x:.5994991307219868,y:.44505229696558585},{x:.6049237292900496,y:.45200882948849475},{x:.6088869435476919,y:.4598899808710617},{x:.6112364693935889,y:.4683928828854553},{x:.6118820158671119,y:.47719077377574476},{x:.6107987749793102,y:.4859455555289303},{x:.6080283750700135,y:.4943207867919753},{x:.6036772810540779,y:.5019946121243246},{x:.5979127030344141,y:.5086721307219868},{x:.33204070303441413,y:.7616071307219868},{x:.3294429315385385,y:.7636328335402047},{x:.3269493357811583,y:.7657854758354554},{x:.3259710287822201,y:.7663401706594313},{x:.32508417051150523,y:.7670317292900496},{x:.3221411194513825,y:.7685117087189752},{x:.3192754777587038,y:.7701365121968442},{x:.31820775306259985,y:.7704896904878621},{x:.3172030191289383,y:.7709949435476919},{x:.31402778830632944,y:.7718723248078522},{x:.310900225681529,y:.7729068491818869},{x:.30978411534954325,y:.7730449384962876},{x:.3087001171145447,y:.7733444693935889},{x:.30541472886927135,y:.7735855352151975},{x:.30214543579006414,y:.7739900242938711},{x:.3010238313163334,y:.7739077179367437},{x:.2999022262242552,y:.773990015867112},{x:.29663293618411596,y:.7735855022258356},{x:.2933475497500956,y:.7733444117206949},{x:.29226355376554153,y:.7730448726791859},{x:.29114744447106966,y:.7729067749793103},{x:.2880198896188706,y:.7718722271075298},{x:.28484466538822795,y:.7709948219914818},{x:.28383993525062523,y:.7704895613829726},{x:.2827722132080247,y:.7701363750700135},{x:.27990658372278143,y:.7685115500622604},{x:.2769635437820154,y:.7670315485218604},{x:.2760766907070934,y:.7663399832281829},{x:.2750983878756754,y:.765785281054078},{x:.27260480829144085,y:.7636326200241867},{x:.2700070520150006,y:.7616068976886387},{x:.004139052015000585,y:.5086718976886386},{x:-.001625475835455463,y:.5019943357811583},{x:-.0059765121968442594,y:.49432047775870375},{x:-.00874684918188691,y:.4859452256815289},{x:-.009830024293871129,y:.4771904357900641}]],_:[[{x:-.045,y:-.160601},{x:-.044135337618145365,y:-.16938006449072576},{x:-.041574578963007904,y:-.17782175445642903},{x:-.03741613255361454,y:-.1856016604858821},{x:-.03181980515339464,y:-.19242080515339463},{x:-.025000660485882086,y:-.19801713255361453},{x:-.017220754456429038,y:-.2021755789630079},{x:-.008779064490725769,y:-.20473633761814536},{x:0,y:-.20560099999999998},{x:.602052,y:-.20560099999999998},{x:.6108310644907258,y:-.20473633761814536},{x:.619272754456429,y:-.2021755789630079},{x:.6270526604858822,y:-.19801713255361453},{x:.6338718051533947,y:-.19242080515339463},{x:.6394681325536146,y:-.1856016604858821},{x:.6436265789630079,y:-.17782175445642903},{x:.6461873376181454,y:-.16938006449072576},{x:.6470520000000001,y:-.160601},{x:.6461873376181454,y:-.15182193550927423},{x:.6436265789630079,y:-.14338024554357096},{x:.6394681325536146,y:-.1356003395141179},{x:.6338718051533947,y:-.12878119484660536},{x:.6270526604858822,y:-.12318486744638546},{x:.619272754456429,y:-.1190264210369921},{x:.6108310644907258,y:-.11646566238185463},{x:.602052,y:-.115601},{x:0,y:-.115601},{x:-.00877906449072579,y:-.11646566238185463},{x:-.017220754456429066,y:-.1190264210369921},{x:-.025000660485882096,y:-.12318486744638546},{x:-.03181980515339464,y:-.12878119484660536},{x:-.03741613255361454,y:-.1356003395141179},{x:-.041574578963007904,y:-.14338024554357096},{x:-.044135337618145365,y:-.15182193550927423},{x:-.045,y:-.160601}]],a:[[{x:.029951000000000005,y:.25490100000000004},{x:.030216131121475042,y:.2522090785486062},{x:.03027571711850824,y:.2495047884160563},{x:.03064747136410999,y:.24782960757010103},{x:.03081566238185464,y:.24612193550927428},{x:.0316008669059687,y:.24353346308961055},{x:.0321868888075612,y:.2408927597850148},{x:.06949088880756119,y:.12701175978501478},{x:.07014919013856018,y:.12551652306247207},{x:.07061771774296957,y:.1239514111231075},{x:.07192248021942128,y:.12148874987750752},{x:.07304546130734973,y:.1189380599695235},{x:.0739828197765546,y:.11759998201998349},{x:.07474768294666384,y:.11615634846888903},{x:.07650781615341086,y:.11399555310027064},{x:.07810683439013419,y:.11171295672570881},{x:.07928722783725009,y:.11058345913436952},{x:.08031903331037206,y:.10931678199931477},{x:.15605303331037207,y:.033026781999314685},{x:.1581401110567553,y:.03130114899494214},{x:.16009013354595797,y:.02942202284781055},{x:.16153164054777758,y:.028496972085311937},{x:.16285166496406625,y:.027405552418137233},{x:.16523529439528092,y:.026120245637685162},{x:.16751444707429886,y:.024657656887915},{x:.24324744707429888,y:-.014037343112084925},{x:.24491821916217926,y:-.014693433733650136},{x:.24650124554357095,y:-.015539578963007873},{x:.24901423193062222,y:-.016301885049470277},{x:.2514585861893129,y:-.017261751399011975},{x:.25322525179064753,y:-.017579283958613606},{x:.2549429355092742,y:-.018100337618145335},{x:.2575563541074305,y:-.01835773688343746},{x:.2601410014196699,y:-.018822289810772906},{x:.26193566856615697,y:-.018789061710219754},{x:.263722,y:-.018964999999999968},{x:.376759,y:-.018964999999999968},{x:.3786816094876915,y:-.018775639493449434},{x:.3806133727303473,y:-.01879962736385296},{x:.3830607170270406,y:-.018344335046447002},{x:.3855380644907258,y:-.018100337618145335},{x:.3873867891740171,y:-.01753953311656589},{x:.3892861139289994,y:-.017186191753697247},{x:.3915976100664607,y:-.016262194563578608},{x:.3939797544564291,y:-.015539578963007873},{x:.3956835488825182,y:-.014628881868892333},{x:.3974774451646465,y:-.013911789983170525},{x:.4720844451646465,y:.0247832100168294},{x:.4742399118062311,y:.026185049737888398},{x:.4765030886255536,y:.02740538646642049},{x:.47792879308654873,y:.028584168427667152},{x:.47947957817165415,y:.02959274452399146},{x:.48132014276352414,y:.0313881589690925},{x:.48210100000000006,y:.032033776942416534},{x:.48210100000000006,y:.02603500000000003},{x:.4829656623818547,y:.01725593550927424},{x:.4855264210369921,y:.008814245543570985},{x:.4896848674463855,y:.0010343395141179344},{x:.4952811948466054,y:-.0057848051533946065},{x:.5021003395141179,y:-.01138113255361451},{x:.509880245543571,y:-.015539578963007873},{x:.5183219355092743,y:-.018100337618145335},{x:.527101,y:-.018964999999999968},{x:.5358800644907258,y:-.018100337618145335},{x:.544321754456429,y:-.015539578963007873},{x:.5521016604858822,y:-.011381132553614504},{x:.5589208051533947,y:-.0057848051533946065},{x:.5645171325536146,y:.0010343395141179344},{x:.5686755789630079,y:.008814245543570992},{x:.5712363376181454,y:.01725593550927426},{x:.5721010000000001,y:.02603500000000003},{x:.5721010000000001,y:.560059},{x:.5712363376181454,y:.5688380644907257},{x:.5686755789630079,y:.577279754456429},{x:.5645171325536146,y:.5850596604858821},{x:.5589208051533947,y:.5918788051533946},{x:.5521016604858822,y:.5974751325536145},{x:.544321754456429,y:.6016335789630078},{x:.5358800644907258,y:.6041943376181453},{x:.527101,y:.605059},{x:.5183219355092743,y:.6041943376181453},{x:.509880245543571,y:.6016335789630078},{x:.5021003395141179,y:.5974751325536145},{x:.4952811948466054,y:.5918788051533946},{x:.4896848674463855,y:.5850596604858821},{x:.4855264210369921,y:.577279754456429},{x:.4829656623818547,y:.5688380644907257},{x:.48210100000000006,y:.560059},{x:.48210100000000006,y:.5551612473179106},{x:.48111784979070266,y:.5559741116228759},{x:.47906658786156825,y:.5579287481398052},{x:.4777260461549398,y:.558778440075324},{x:.476502844006682,y:.5597897782764175},{x:.474008872962507,y:.5611345413953497},{x:.47161569478864906,y:.5626514387693977},{x:.3970086947886491,y:.6002454387693977},{x:.39545173243232984,y:.6008467903430146},{x:.3939797544564291,y:.6016335789630078},{x:.39134652561635536,y:.6024323601988234},{x:.3887796173011618,y:.6034237870938969},{x:.38713525366780027,y:.6037098355781862},{x:.3855380644907258,y:.6041943376181453},{x:.3827995979159321,y:.6044640530341434},{x:.3800885942320307,y:.6049356509696303},{x:.37842002129388747,y:.6048954036817589},{x:.376759,y:.605059},{x:.263722,y:.605059},{x:.26219504701733515,y:.604908608257877},{x:.26066140118579323,y:.6049547986330399},{x:.25781511370268967,y:.6044772224791067},{x:.2549429355092742,y:.6041943376181453},{x:.2534746624734083,y:.6037489418620853},{x:.2519614739213154,y:.6034950452430072},{x:.24926304753974865,y:.6024713624393285},{x:.24650124554357095,y:.6016335789630078},{x:.24514807736385555,y:.6009102955021357},{x:.24371349707866236,y:.6003660689935006},{x:.16798049707866233,y:.5627720689935006},{x:.1654642487594581,y:.5611982224645521},{x:.16285190958182658,y:.5597896123262998},{x:.16173267757498783,y:.5588642237445607},{x:.16050143578237863,y:.5580941146870384},{x:.15834057869520102,y:.5560596134829665},{x:.15605324108782545,y:.5541684273021619},{x:.08031924108782545,y:.47787942730216193},{x:.07924694249287094,y:.47656305714472025},{x:.07802357952480113,y:.4753857561141845},{x:.07646760484406812,y:.47315109973327435},{x:.07474784589903924,y:.4710398973462887},{x:.07395296229881854,y:.46953962579412084},{x:.07298278594430238,y:.4681462799973844},{x:.07189266871370663,y:.46565100631071576},{x:.07061782960809859,y:.46324486175923196},{x:.0701309079335922,y:.4616183434067253},{x:.06945120152585271,y:.46006249834135976},{x:.032147201525852716,y:.3450764983413597},{x:.031582343425880205,y:.34249647318004567},{x:.03081566238185464,y:.3399690644907258},{x:.030641204072877935,y:.33819775955415116},{x:.03026054307811779,y:.33645906634171463},{x:.03020987650767869,y:.3338184172918108},{x:.029951000000000005,y:.33119},{x:.029951000000000005,y:.25490100000000004}],[{x:.119951,y:.2620835578942187},{x:.119951,y:.3240730820964405},{x:.15174843963453788,y:.42208563822492473},{x:.21467365091165175,y:.4854719831046318},{x:.2742766075147511,y:.5150589999999999},{x:.3660620360389177,y:.5150589999999999},{x:.4245839309326211,y:.4855701837142105},{x:.48210100000000006,y:.4276323784447675},{x:.48210100000000006,y:.15956344905445352},{x:.4243936225653894,y:.10143318135145685},{x:.36578354074375496,y:.07103500000000003},{x:.2745522516182332,y:.07103500000000003},{x:.21486246778999646,y:.10153288315838035},{x:.15170083487400915,y:.1651582162341545},{x:.119951,y:.2620835578942187}]],b:[[{x:.03166000000000001,y:.04001500000000002},{x:.03252466238185464,y:.031235935509274233},{x:.0350854210369921,y:.022794245543570978},{x:.039243867446385465,y:.015014339514117927},{x:.04484019484660537,y:.008195194846605386},{x:.05165933951411792,y:.002598867446385482},{x:.05943924554357097,y:-.0015595789630078807},{x:.06788093550927424,y:-.004120337618145342},{x:.07666,y:-.0049849999999999756},{x:.08543906449072577,y:-.004120337618145342},{x:.09388075445642904,y:-.0015595789630078807},{x:.10166066048588211,y:.002598867446385489},{x:.10847980515339464,y:.008195194846605386},{x:.11407613255361454,y:.015014339514117927},{x:.1182345789630079,y:.022794245543570985},{x:.12079533761814537,y:.031235935509274254},{x:.12166,y:.04001500000000002},{x:.12166,y:.041388769861289504},{x:.12338630711141785,y:.04010106584896898},{x:.12512540667363178,y:.03853443023544684},{x:.12691331624345048,y:.03747016444054036},{x:.12858112311649333,y:.036226097502515},{x:.13069431360107225,y:.035219499067818724},{x:.13270563229917137,y:.034022247411931134},{x:.20674863229917137,y:-.0007227525880688923},{x:.20772794171481185,y:-.0010698043626217635},{x:.20864424554357097,y:-.0015595789630078669},{x:.21187816153300185,y:-.0025405766534664824},{x:.21506348921487128,y:-.003669406425619949},{x:.21609168791714548,y:-.0038187359083884913},{x:.21708593550927424,y:-.004120337618145342},{x:.22044909586509742,y:-.004451580001305548},{x:.22379344213248661,y:-.004937293022731791},{x:.22483101702188665,y:-.00488316156543817},{x:.225865,y:-.0049849999999999756},{x:.338045,y:-.0049849999999999756},{x:.33894984805462636,y:-.004895880245274822},{x:.33985755144997865,y:-.004948481373678995},{x:.343332465401001,y:-.004464230112452937},{x:.3468240644907258,y:-.004120337618145342},{x:.3476941397420575,y:-.003856403176165039},{x:.34859466384226984,y:-.0037309094409420443},{x:.351908335561611,y:-.0025780408502315546},{x:.35526575445642905,y:-.0015595789630078807},{x:.35606762040050133,y:-.0011309726863615623},{x:.35692635856942223,y:-.0008322067413783357},{x:.43209235856942224,y:.03391279325862169},{x:.4342218624454842,y:.03516383683568551},{x:.43645162164562873,y:.03622594356254809},{x:.4380158580934015,y:.037392738102356306},{x:.4396984532755396,y:.03838123120587913},{x:.4415429728374372,y:.04002368192832182},{x:.4435226810964235,y:.04150038501262054},{x:.5186856810964235,y:.11000138501262047},{x:.5200684051728882,y:.11153543836568303},{x:.5216038163727121,y:.1129166544997947},{x:.5230144082918019,y:.11480386048953693},{x:.5245918796416693,y:.11655397481445093},{x:.5256487561000858,y:.11832830784782436},{x:.5268852029038621,y:.11998252816661786},{x:.5279005150705119,y:.12210866485417524},{x:.5291062453835067,y:.12413290061668979},{x:.5297966590542814,y:.12607932670695898},{x:.530686625504748,y:.12794298045128052},{x:.567704625504748,y:.2301969804512806},{x:.5685418230641662,y:.23348712941632632},{x:.5695273376181453,y:.23673593550927427},{x:.5696276430094915,y:.2377543532384077},{x:.5698799976366801,y:.23874609563675617},{x:.5700592324586751,y:.24213635445346285},{x:.570392,y:.24551500000000004},{x:.570392,y:.314017},{x:.570065993218988,y:.3173270023951309},{x:.5699006262411136,y:.32064890697528625},{x:.569634437926433,y:.3217086568121163},{x:.5695273376181453,y:.3227960644907258},{x:.5685618455328773,y:.32597886535008125},{x:.5677515846008636,y:.32920467896823863},{x:.5307335846008636,y:.4324506789682387},{x:.5298196963817511,y:.43437967657309706},{x:.5291061063615623,y:.4363913954201699},{x:.5279358002551,y:.43835612690926706},{x:.5269566878799311,y:.4404227969757902},{x:.5256840310027916,y:.4421364386856148},{x:.5245916855370664,y:.44397028841230757},{x:.523060566435399,y:.4456689527415915},{x:.5216970801011935,y:.44750489697372575},{x:.5201145620561008,y:.4489373284986299},{x:.5186854393684929,y:.45052283528838016},{x:.44352243936849295,y:.5190228352883801},{x:.44134657552661755,y:.5206458300432604},{x:.43929971954126384,y:.5224287703137037},{x:.4378191137317927,y:.523276992839783},{x:.43645134158383936,y:.5242972253466508},{x:.43400065578620683,y:.5254645447348341},{x:.43164529517316985,y:.52681390451462},{x:.35647929517316984,y:.56056790451462},{x:.3558506134628383,y:.560778965311121},{x:.35526575445642905,y:.5610915789630079},{x:.351674330744245,y:.5621810254355277},{x:.34811645117964274,y:.5633754754766519},{x:.34745867349333664,y:.563459831081816},{x:.3468240644907258,y:.5636523376181454},{x:.3430891085149791,y:.5640201986736739},{x:.3393665669654169,y:.5644975898222324},{x:.3387049713307353,y:.5644519984974604},{x:.338045,y:.564517},{x:.225865,y:.564517},{x:.22507819619617456,y:.5644395065891945},{x:.22428916125732748,y:.5644893996719887},{x:.22069487882474298,y:.5640077875099223},{x:.21708593550927424,y:.5636523376181454},{x:.21632936813438544,y:.5634228354140474},{x:.21554576062305134,y:.5633178367349442},{x:.2121144991913443,y:.5621442688983362},{x:.20864424554357097,y:.5610915789630079},{x:.20794698905754733,y:.5607188876066144},{x:.20719892257093525,y:.5604630322059678},{x:.13315592257093525,y:.5267090322059678},{x:.13091775246116674,y:.5254099486077729},{x:.12858140317750869,y:.5242970714087468},{x:.1271119341080524,y:.5232009671819817},{x:.12552641140636125,y:.5222806946221156},{x:.12358468574515913,y:.5205699272235509},{x:.12166,y:.5191342684374534},{x:.12166,y:.7597659999999999},{x:.12079533761814537,y:.7685450644907257},{x:.1182345789630079,y:.776986754456429},{x:.11407613255361454,y:.7847666604858821},{x:.10847980515339464,y:.7915858051533946},{x:.10166066048588208,y:.7971821325536145},{x:.09388075445642904,y:.8013405789630078},{x:.08543906449072577,y:.8039013376181453},{x:.07666,y:.804766},{x:.06788093550927421,y:.8039013376181453},{x:.05943924554357094,y:.8013405789630078},{x:.05165933951411792,y:.7971821325536145},{x:.04484019484660537,y:.7915858051533946},{x:.039243867446385465,y:.7847666604858821},{x:.0350854210369921,y:.776986754456429},{x:.03252466238185464,y:.7685450644907257},{x:.03166000000000001,y:.7597659999999999},{x:.03166000000000001,y:.04001500000000002}],[{x:.12166,y:.16313400296117606},{x:.12166,y:.39738980161800674},{x:.17691400696537596,y:.447746357818324},{x:.23563826658076475,y:.474517},{x:.3284048540018634,y:.474517},{x:.3882155063572531,y:.44765846343288423},{x:.44979135555302596,y:.39154114946310603},{x:.480392,y:.30619363915535625},{x:.480392,y:.2534097446111891},{x:.44984564070758065,y:.16903221413717517},{x:.38802932067077023,y:.11269492399652684},{x:.3281476350434013,y:.08501500000000002},{x:.2358983461114888,y:.08501500000000002},{x:.1771018588393058,y:.11260550754658781},{x:.12166,y:.16313400296117606}]],c:[[{x:.0446,y:.25490100000000004},{x:.044822712444716174,y:.2526397626013558},{x:.04482893549381362,y:.2503675925637664},{x:.045254001037800355,y:.24826081602954003},{x:.045464662381854634,y:.24612193550927428},{x:.04612424100165128,y:.2439475961957434},{x:.04657362286091401,y:.24172029932495478},{x:.08145962286091402,y:.1278402993249547},{x:.08196610920465827,y:.1266269431042867},{x:.08230081253195312,y:.125355433994083},{x:.08366176737769918,y:.12256476567779218},{x:.08485778977199918,y:.11969953302126297},{x:.0855912581784792,y:.11860830168404396},{x:.08616758939694805,y:.11742652164475936},{x:.08804682625741464,y:.11495498435675963},{x:.08977884657839008,y:.1123781387363477},{x:.09071111026807865,y:.11145096769089737},{x:.09150692129220603,y:.11040433186669174},{x:.16233292129220603,y:.03411333186669174},{x:.16445877247754231,y:.03223237849112975},{x:.1664474797904295,y:.03020697184383589},{x:.16775479669311927,y:.029316055882572942},{x:.16893962068732413,y:.02826772347496185},{x:.17139158003796548,y:.02683764508339147},{x:.17373721213250964,y:.02523913360696181},{x:.24456521213250962,y:-.013455866393038113},{x:.2467886390083486,y:-.014400746043602006},{x:.24891924554357092,y:-.015539578963007873},{x:.25083834630720225,y:-.016121731815163746},{x:.25268405147305695,y:-.01690609278116076},{x:.2550490927002279,y:-.01739904776899966},{x:.2573609355092742,y:-.018100337618145335},{x:.259356733677244,y:-.018296906580526337},{x:.26131999536931183,y:-.018706117055345653},{x:.26373576373978486,y:-.0187282033967292},{x:.26614,y:-.018964999999999968},{x:.371854,y:-.018964999999999968},{x:.3744001776009888,y:-.018714223394882004},{x:.3769583677219744,y:-.018674567546095353},{x:.3787793796063011,y:-.01828290964379429},{x:.3806330644907258,y:-.018100337618145335},{x:.3830813939144215,y:-.01735764500708899},{x:.3855826926572475,y:-.01681967299983559},{x:.38729230564255435,y:-.01608027889939661},{x:.3890747544564291,y:-.015539578963007873},{x:.391331147776118,y:-.014333511606549179},{x:.393679431632842,y:-.013317897403369645},{x:.463449431632842,y:.02537710259663028},{x:.46566730315778443,y:.026909287408228903},{x:.46799586592077425,y:.028267352155161442},{x:.4692879686356918,y:.029410572352257962},{x:.47070743151062955,y:.03039118797094862},{x:.4725837728278355,y:.03232661755101331},{x:.4746026476214732,y:.03411286752390576},{x:.5454306476214732,y:.11040386752390575},{x:.5507700783887176,y:.11742598212342069},{x:.5546369668925095,y:.12535484002769406},{x:.5568827107762242,y:.13388573967401945},{x:.5574210073618384,y:.14269084337317217},{x:.5562311702134469,y:.15143177592795284},{x:.5533589241053942,y:.15977262820225266},{x:.5489146478448386,y:.16739286592077418},{x:.5430691324760942,y:.17399964762147313},{x:.5360470178765793,y:.17933907838871752},{x:.5281181599723059,y:.18320596689250943},{x:.5195872603259806,y:.1854517107762242},{x:.5107821566268278,y:.1859900073618383},{x:.5020412240720471,y:.18480017021344686},{x:.4937003717977473,y:.18192792410539416},{x:.4860801340792258,y:.17748364784483847},{x:.47947335237852684,y:.17163813247609414},{x:.41352572033101553,y:.10060392571412592},{x:.36021071976053953,y:.07103500000000003},{x:.27763077403847125,y:.07103500000000003},{x:.2233107097601157,y:.10071132697875086},{x:.16448866962379677,y:.16407213041308155},{x:.1346,y:.2616391113440561},{x:.1346,y:.3245158400933278},{x:.1645319520417492,y:.4231721923699009},{x:.2231207776861973,y:.4862793045993598},{x:.27734241586879393,y:.5150589999999999},{x:.3605019191882548,y:.5150589999999999},{x:.41371701660545657,y:.4863852380349392},{x:.47947395272027693,y:.4155592208902026},{x:.48608084903755494,y:.4097138350672089},{x:.4937011738972078,y:.40526970822380387},{x:.5020420824884065,y:.4023976256622846},{x:.5107830383716269,y:.4012079599048077},{x:.5195881315142611,y:.40174642913926084},{x:.5281189871247909,y:.40399234029494097},{x:.5360477692062626,y:.4078593842656568},{x:.5430697791097975,y:.41319895272027696},{x:.5489151649327911,y:.41980584903755497},{x:.5533592917761961,y:.42742617389720783},{x:.5562313743377155,y:.4357670824884066},{x:.5574210400951923,y:.4445080383716269},{x:.5568825708607392,y:.4533131315142611},{x:.5546366597050592,y:.4618439871247909},{x:.5507696157343432,y:.46977276920626265},{x:.5454300472797231,y:.4767947791097975},{x:.4746020472797231,y:.5530827791097974},{x:.47237947035514305,y:.5550491819442839},{x:.4702881116089302,y:.5571546051529963},{x:.469083054274185,y:.5579656532949738},{x:.4679951509624451,y:.5589281649327911},{x:.46543165406806053,y:.5604231806402761},{x:.46296973250196366,y:.5620801448811513},{x:.39319973250196366,y:.5996741448811513},{x:.39109075852725916,y:.6005560023370271},{x:.3890747544564291,y:.6016335789630078},{x:.38703122642603144,y:.6022534764138876},{x:.38506104886577136,y:.6030772968079529},{x:.3828205563795885,y:.6035307692082409},{x:.3806330644907258,y:.6041943376181453},{x:.3785078662851109,y:.6044036513718285},{x:.37641482574826585,y:.6048272797133635},{x:.3741289156203665,y:.604834940368031},{x:.371854,y:.605059},{x:.26614,y:.605059},{x:.26400488750824663,y:.6048487097743618},{x:.26185945318827825,y:.6048549475733314},{x:.2596259398913868,y:.6044174210783497},{x:.2573609355092742,y:.6041943376181453},{x:.2553078741931944,y:.60357154827667},{x:.25320244685788745,y:.6031591127457343},{x:.2510972070775077,y:.6022942563713519},{x:.24891924554357092,y:.6016335789630078},{x:.24702713339817148,y:.6006222239508241},{x:.24504262343928468,y:.5998069647561404},{x:.1742146234392847,y:.5622129647561404},{x:.17162525666515238,y:.5604936738034747},{x:.16894033563687538,y:.5589277936219744},{x:.16795812189104978,y:.5580587651214349},{x:.16686556037036515,y:.5573333247718834},{x:.16466136457832586,y:.5551419091149951},{x:.16233352162359432,y:.5530823147741101},{x:.09150752162359431,y:.47679431477411016},{x:.09067474586023959,y:.4756991081857825},{x:.08970182133886938,y:.4747262717047309},{x:.08801053269383365,y:.4721953272870651},{x:.08616805203977476,y:.4697722296898647},{x:.08556494203519081,y:.46853560069719197},{x:.08480050296804506,y:.467391648838166},{x:.08363547472152838,y:.4645793817614187},{x:.08230111970711389,y:.461843393160995},{x:.08195085264054901,y:.4605128647226562},{x:.08142427599227564,y:.4592417589140625},{x:.046538275992275634,y:.3442567589140625},{x:.04610669192420131,y:.34208755224892967},{x:.045464662381854634,y:.33997106449072584},{x:.04524807462900009,y:.3377720121321243},{x:.04481688692083,y:.3356047976316928},{x:.044816786846426454,y:.33339307378956023},{x:.0446,y:.33119200000000004},{x:.0446,y:.25490100000000004}]],d:[[{x:.03166100000000001,y:.24551500000000004},{x:.03199378652782141,y:.24213616168032864},{x:.032173060891358886,y:.2387457109778176},{x:.032425376075824915,y:.237754159461938},{x:.03252566238185464,y:.23673593550927427},{x:.03351123316568353,y:.23348694405135337},{x:.034348506941927405,y:.23019661460170962},{x:.0713675069419274,y:.12794261460170955},{x:.07225746993456125,y:.1260790095358921},{x:.0729478813145148,y:.12413263082247869},{x:.07415364826248581,y:.12210836405190925},{x:.07516899837159816,y:.11998219518580837},{x:.07640543228727825,y:.1183280219355851},{x:.07746229725612473,y:.11655373492181778},{x:.07903981058640837,y:.11480359733178996},{x:.08045044599662987,y:.11291636718401242},{x:.08198583537337678,y:.11153519469971836},{x:.08336853920306012,y:.1100011842405046},{x:.15853253920306012,y:.04150018424050468},{x:.16051177365736521,y:.04002385498013544},{x:.16235580937568672,y:.038381768082408986},{x:.16403890527939927,y:.03739293492543645},{x:.16560363358955885,y:.03622578962650935},{x:.16783285515961555,y:.03516395710594637},{x:.16996181351033893,y:.03391317596960988},{x:.24512381351033893,y:-.0008318240303901436},{x:.24598297689097734,y:-.0011307574341723537},{x:.24678524554357095,y:-.0015595789630078807},{x:.25014222995258023,y:-.0025779090504023904},{x:.2534554494825366,y:-.0037306956028641883},{x:.25435642329373365,y:-.003856270624521421},{x:.2552269355092742,y:-.004120337618145342},{x:.2587180827488419,y:-.0044641856090968535},{x:.2621925371943035,y:-.004948444626188875},{x:.2631006975177666,y:-.004895835488062085},{x:.264006,y:-.0049849999999999756},{x:.376189,y:-.0049849999999999756},{x:.37722298297811335,y:-.004883161565438171},{x:.3782605578675134,y:-.004937293022731791},{x:.3816049041349026,y:-.004451580001305548},{x:.3849680644907258,y:-.004120337618145342},{x:.3859623120828546,y:-.003818735908388489},{x:.38699051078512875,y:-.003669406425619949},{x:.39017583846699794,y:-.0025405766534665605},{x:.39340975445642906,y:-.0015595789630078807},{x:.39432605828518835,y:-.0010698043626217065},{x:.39530536770082864,y:-.0007227525880688923},{x:.46934836770082866,y:.034022247411931134},{x:.4713599418403825,y:.035219651121148166},{x:.4734733873673339,y:.03622640539423388},{x:.4751409393435705,y:.037470316580519136},{x:.4769285933263682,y:.03853443023544684},{x:.47866791375766776,y:.04010126481479184},{x:.480392,y:.041387347763641016},{x:.480392,y:.04001500000000002},{x:.4812566623818546,y:.031235935509274233},{x:.48381742103699205,y:.022794245543570978},{x:.48797586744638544,y:.015014339514117927},{x:.4935721948466053,y:.008195194846605386},{x:.5003913395141178,y:.002598867446385482},{x:.508171245543571,y:-.0015595789630078807},{x:.5166129355092742,y:-.004120337618145342},{x:.525392,y:-.0049849999999999756},{x:.5341710644907257,y:-.004120337618145342},{x:.542612754456429,y:-.0015595789630078807},{x:.5503926604858821,y:.002598867446385489},{x:.5572118051533946,y:.008195194846605386},{x:.5628081325536145,y:.015014339514117927},{x:.5669665789630078,y:.022794245543570985},{x:.5695273376181453,y:.031235935509274254},{x:.570392,y:.04001500000000002},{x:.570392,y:.7597659999999999},{x:.5695273376181453,y:.7685450644907257},{x:.5669665789630078,y:.776986754456429},{x:.5628081325536145,y:.7847666604858821},{x:.5572118051533946,y:.7915858051533946},{x:.5503926604858821,y:.7971821325536145},{x:.542612754456429,y:.8013405789630078},{x:.5341710644907257,y:.8039013376181453},{x:.525392,y:.804766},{x:.5166129355092742,y:.8039013376181453},{x:.508171245543571,y:.8013405789630078},{x:.5003913395141178,y:.7971821325536145},{x:.4935721948466053,y:.7915858051533946},{x:.48797586744638544,y:.7847666604858821},{x:.48381742103699205,y:.776986754456429},{x:.4812566623818546,y:.7685450644907257},{x:.480392,y:.7597659999999999},{x:.480392,y:.5191356905079497},{x:.47846953719699326,y:.5205697307992189},{x:.47652758859363875,y:.5222806946221157},{x:.47494232329576636,y:.5232008177790934},{x:.47347310730786674,y:.524296763521154},{x:.4711365045177018,y:.5254097994515352},{x:.46889807742906475,y:.5267090322059679},{x:.3948550774290648,y:.5604630322059679},{x:.3941070109424522,y:.5607188876066146},{x:.39340975445642906,y:.5610915789630079},{x:.389939500808656,y:.5621442688983361},{x:.38650823937694867,y:.5633178367349442},{x:.38572463186561456,y:.5634228354140474},{x:.3849680644907258,y:.5636523376181454},{x:.38135912117525683,y:.5640077875099224},{x:.3777648387426725,y:.5644893996719887},{x:.3769758038038255,y:.5644395065891945},{x:.376189,y:.564517},{x:.264006,y:.564517},{x:.26334558239453953,y:.5644519545432365},{x:.2626835384795895,y:.5644975635305632},{x:.2589614482177297,y:.5640201550156564},{x:.2552269355092742,y:.5636523376181454},{x:.25459189738202526,y:.5634597009082802},{x:.2539336765832372,y:.5633752751711479},{x:.2503762430229788,y:.5621808961392286},{x:.24678524554357095,y:.5610915789630079},{x:.24619999105363047,y:.5607787539207695},{x:.24557088842716707,y:.5605675378929096},{x:.17040888842716706,y:.5268135378929095},{x:.16805407047382528,y:.5254644267942322},{x:.16560391365212207,y:.5242973792806265},{x:.16423565717286473,y:.5232767996121171},{x:.1627545512703112,y:.5224282514648534},{x:.16070817900232118,y:.5206456609648356},{x:.15853278093215223,y:.5190230360586235},{x:.08336878093215222,y:.45052303605862365},{x:.08193967718325436,y:.44893757139643337},{x:.08035717944512263,y:.44750518296134467},{x:.07899365114577664,y:.44566921514174185},{x:.07746249136223225,y:.4439705283033309},{x:.07637015625263606,y:.44213672358948825},{x:.0750975108858587,y:.44042312810321155},{x:.07411836195358443,y:.43835642671545355},{x:.07294802033824888,y:.4363916652130956},{x:.07223443169362759,y:.4343799925343442},{x:.07132054574594202,y:.4324510425104215},{x:.034301545745942026,y:.32920504251042143},{x:.033491210284420626,y:.32597904935505284},{x:.03252566238185464,y:.3227960644907258},{x:.03241858101312289,y:.3217088491086539},{x:.03215243067755317,y:.32064928896150824},{x:.031987025628206905,y:.31732719375391183},{x:.03166100000000001,y:.314017},{x:.03166100000000001,y:.24551500000000004}],[{x:.121661,y:.25340994514221},{x:.121661,y:.3061934402169761},{x:.15226243948714763,y:.39154086238640384},{x:.21383969339611897,y:.4476587099299689},{x:.27364661400534074,y:.474517},{x:.3664157334192352,y:.474517},{x:.42513971513426946,y:.4477464845048247},{x:.480392,y:.3973901578243758},{x:.480392,y:.1631336467554691},{x:.4249518651426514,y:.1126053780239199},{x:.3661556538885112,y:.08501500000000002},{x:.2739038430667855,y:.08501500000000002},{x:.21402588591940364,y:.11269467351967463},{x:.15220815290195538,y:.1690325018607451},{x:.121661,y:.25340994514221}]],e:[[{x:.014571,y:.25490100000000004},{x:.014880046743786594,y:.2517631957525991},{x:.01501248842711947,y:.2486129918567585},{x:.015311525398480692,y:.24738231945287367},{x:.015435662381854634,y:.24612193550927428},{x:.016350926120166094,y:.24310471531940006},{x:.01709539726614681,y:.24004087979874045},{x:.05693639726614681,y:.12616087979874036},{x:.057746546207777846,y:.12441615547982068},{x:.05835851556287996,y:.12259245107255745},{x:.05959975008908581,y:.12042512406141898},{x:.06065161969764369,y:.11815983382640528},{x:.06178658068373706,y:.11660668611395116},{x:.06274257829935428,y:.11493741297405176},{x:.06438278737670251,y:.11305388338712186},{x:.06585638180708843,y:.11103732964943176},{x:.06727253892344205,y:.10973544513901749},{x:.06853582634733585,y:.1082847524971091},{x:.14942282634733584,y:.031993752497109104},{x:.15144602889400902,y:.03043003785468449},{x:.15333307828862142,y:.02870446646813117},{x:.1549277151407192,y:.027739074573098352},{x:.15640262843323158,y:.02659912765300345},{x:.15869202130341495,y:.025460166585296706},{x:.1608794538505091,y:.024135896643135493},{x:.2417664538505091,y:-.01455910335686443},{x:.24290092295632487,y:-.014970686687880902},{x:.2439652455435709,y:-.015539578963007873},{x:.24703931387581265,y:-.016472087396775758},{x:.2500591116803148,y:-.017567664555291233},{x:.2512520782049556,y:-.01775001548484057},{x:.2524069355092742,y:-.018100337618145335},{x:.25560385985111694,y:-.01841520718300011},{x:.2587793695882151,y:-.01890059980751419},{x:.2599849884971624,y:-.018846710691637396},{x:.261186,y:-.018964999999999968},{x:.381914,y:-.018964999999999968},{x:.3832466926412995,y:-.01883374123151461},{x:.3845848263549422,y:-.018885671038862982},{x:.3876272824249201,y:-.01840229079619376},{x:.39069306449072577,y:-.018100337618145335},{x:.3919745425012029,y:-.017711605513551366},{x:.39329709535359264,y:-.017501480567117658},{x:.39618678867610163,y:-.016433834605858122},{x:.39913475445642904,y:-.015539578963007873},{x:.4003157713548023,y:-.014908312279081314},{x:.40157191838151796,y:-.014444207562717595},{x:.48125191838151804,y:.02425079243728233},{x:.4833189661071789,y:.02551885102394819},{x:.4854901362659954,y:.026598980192539007},{x:.48706966813422276,y:.027819770278194},{x:.48877129863032925,y:.028863658687316496},{x:.4905512426555404,y:.030510612890229178},{x:.492469971641239,y:.03199356196515255},{x:.573357971641239,y:.10828456196515254},{x:.5791512607417543,y:.11493718669263933},{x:.5835353707163221,y:.12259219773755695},{x:.5863418226772573,y:.13095541731842886},{x:.5874627662495775,y:.13970545159690978},{x:.5868551242004307,y:.1485060416627534},{x:.584542247872996,y:.15701898577515713},{x:.5806130198074609,y:.16491713626599536},{x:.5752184380348474,y:.17189697164123896},{x:.5685658133073607,y:.17769026074175415},{x:.560910802262443,y:.1820743707163221},{x:.5525475826815711,y:.18488082267725728},{x:.5437975484030901,y:.18600176624957743},{x:.5349969583372466,y:.1853941242004306},{x:.5264840142248428,y:.183081247872996},{x:.5185858637340046,y:.17915201980746093},{x:.511606028358761,y:.17375743803484736},{x:.43573388395098006,y:.1021972341849065},{x:.3715652104827451,y:.07103500000000003},{x:.2713955768569904,y:.07103500000000003},{x:.2060606884620834,y:.10229012760321096},{x:.13826613078700495,y:.16623259795801962},{x:.104571,y:.2625454790108076},{x:.104571,y:.28619200000000006},{x:.542482,y:.28619200000000006},{x:.5512610644907258,y:.2870566623818547},{x:.559702754456429,y:.2896174210369921},{x:.5674826604858821,y:.2937758674463855},{x:.5743018051533947,y:.2993721948466054},{x:.5798981325536146,y:.3061913395141179},{x:.5840565789630079,y:.31397124554357103},{x:.5866173376181454,y:.32241293550927425},{x:.5874820000000001,y:.33119200000000004},{x:.5866173376181454,y:.33997106449072584},{x:.5840565789630079,y:.34841275445642905},{x:.5798981325536146,y:.35619266048588216},{x:.5743018051533947,y:.3630118051533947},{x:.5674826604858821,y:.3686081325536146},{x:.5660433240263831,y:.3693774739195968},{x:.5706944449992851,y:.3724210772554575},{x:.5769918122169339,y:.3785986803904119},{x:.5819629867044116,y:.38588613801169297},{x:.5854169290140312,y:.3940033972097681},{x:.5872209060798271,y:.40263851626586683},{x:.5873055920748429,y:.4114596523972937},{x:.5856677325637826,y:.4201278142894682},{x:.5823702695691338,y:.4283098893420352},{x:.5425292695691338,y:.5045998893420351},{x:.54083893518448,y:.5071829952333479},{x:.5393041274419548,y:.5098614335042745},{x:.5384286685906833,y:.5108662746451583},{x:.5376989227445426,y:.5119814449992851},{x:.5355371287009763,y:.5141851493557908},{x:.5335092744740836,y:.5165126960496618},{x:.49246227447408364,y:.5552086960496617},{x:.4903478252727746,y:.5568421196453192},{x:.48836639942178184,y:.5586345815458318},{x:.486865329057947,y:.5595323670561179},{x:.4854811710293013,y:.5606016367187369},{x:.48308868524123094,y:.5617911659624512},{x:.4807956399629947,y:.5631626292028359},{x:.40111563996299465,y:.6007566292028359},{x:.40009264564938235,y:.6011215754533451},{x:.39913475445642904,y:.6016335789630078},{x:.3959457374462889,y:.6026009566970012},{x:.3928069722488333,y:.6037206897930685},{x:.3917324370025758,y:.603879047413643},{x:.39069306449072577,y:.6041943376181453},{x:.38737659751458814,y:.6045209811048129},{x:.38407969371999856,y:.6050068561303112},{x:.38299491132800306,y:.6049525395264004},{x:.381914,y:.605059},{x:.261186,y:.605059},{x:.26023449599616577,y:.6049652850353624},{x:.2592798763752433,y:.6050186117946668},{x:.25585213857488087,y:.6045336605029273},{x:.2524069355092742,y:.6041943376181453},{x:.2514919972706982,y:.6039167941377678},{x:.2505453168634681,y:.6037828591890964},{x:.24727805138745723,y:.6026385076291858},{x:.2439652455435709,y:.6016335789630078},{x:.24312203363365809,y:.6011828728071931},{x:.24221967283726598,y:.6008668231955117},{x:.161332672837266,y:.5632728231955116},{x:.15891596978001063,y:.5618462817840929},{x:.15640337688314435,y:.5605963413854953},{x:.1551260781006526,y:.5596091689500753},{x:.15373589412748892,y:.5587885654418143},{x:.1516439317651508,y:.5569179592459522},{x:.1494234689111216,y:.555201853544281},{x:.06853646891112161,y:.47891385354428107},{x:.06722863655802509,y:.4774120673763562},{x:.06576662511800205,y:.47605991734502884},{x:.06433886916992998,y:.4740937424536807},{x:.06274309028364713,y:.4722613067803989},{x:.06175337150959475,y:.4705332315776763},{x:.06058324359446483,y:.4689218384474283},{x:.05956650326928079,y:.4667149016876259},{x:.05835887729241062,y:.4646063547351938},{x:.05772530643484857,y:.4627183994585984},{x:.05689202940417486,y:.4609096881637455},{x:.017051029404174856,y:.3459246881637455},{x:.016331419439147486,y:.342923979771159},{x:.015435662381854634,y:.33997106449072584},{x:.015304912520774374,y:.33864353887302173},{x:.014993833838408223,y:.33734636893611664},{x:.014873460143664087,y:.33426292937408214},{x:.014571,y:.33119200000000004},{x:.014571,y:.25490100000000004}],[{x:.12278767041868709,y:.376192},{x:.13831799224413532,y:.421014018902617},{x:.20587340146207272,y:.4847284236699839},{x:.27113246747276615,y:.5150589999999999},{x:.37183117966561724,y:.5150589999999999},{x:.4359272756482788,y:.48481767680255794},{x:.4662598881310508,y:.45622238914125884},{x:.5025937304308662,y:.3866481106579649},{x:.5074240772554575,y:.379266555000715},{x:.5104401600015575,y:.376192},{x:.12278767041868709,y:.376192}]],f:[[{x:.044112,y:.5239119999999999},{x:.04497666238185463,y:.5151329355092742},{x:.04753742103699209,y:.5066912455435709},{x:.051695867446385456,y:.4989113395141178},{x:.05729219484660536,y:.49209219484660527},{x:.0641113395141179,y:.4864958674463854},{x:.07189124554357096,y:.482337421036992},{x:.08033293550927423,y:.47977666238185457},{x:.089112,y:.47891199999999995},{x:.20304699999999998,y:.47891199999999995},{x:.20304699999999998,y:.05318299999999998},{x:.20391166238185462,y:.04440393550927419},{x:.2064724210369921,y:.03596224554357094},{x:.21063086744638546,y:.028182339514117884},{x:.21622719484660535,y:.021363194846605343},{x:.2230463395141179,y:.01576686744638544},{x:.23082624554357095,y:.011608421036992077},{x:.23926793550927422,y:.009047662381854615},{x:.248047,y:.008182999999999982},{x:.25682606449072576,y:.009047662381854615},{x:.26526775445642903,y:.011608421036992077},{x:.2730476604858821,y:.015766867446385446},{x:.2798668051533946,y:.021363194846605343},{x:.28546313255361455,y:.028182339514117884},{x:.2896215789630079,y:.03596224554357094},{x:.2921823376181454,y:.04440393550927421},{x:.293047,y:.05318299999999998},{x:.293047,y:.47891199999999995},{x:.459965,y:.47891199999999995},{x:.4687440644907258,y:.47977666238185457},{x:.4771857544564291,y:.482337421036992},{x:.48496566048588213,y:.4864958674463854},{x:.4917848051533946,y:.49209219484660527},{x:.49738113255361455,y:.4989113395141178},{x:.5015395789630079,y:.5066912455435709},{x:.5041003376181454,y:.5151329355092742},{x:.504965,y:.5239119999999999},{x:.5041003376181454,y:.5326910644907257},{x:.5015395789630079,y:.5411327544564289},{x:.49738113255361455,y:.548912660485882},{x:.4917848051533946,y:.5557318051533946},{x:.48496566048588213,y:.5613281325536145},{x:.4771857544564291,y:.5654865789630078},{x:.4687440644907258,y:.5680473376181453},{x:.459965,y:.568912},{x:.293047,y:.568912},{x:.293047,y:.6141229501499061},{x:.3322669208002554,y:.6884371453882767},{x:.4140490730325775,y:.7147659999999999},{x:.512941,y:.7147659999999999},{x:.5217200644907257,y:.7156306623818546},{x:.530161754456429,y:.7181914210369921},{x:.5379416604858821,y:.7223498674463854},{x:.5447608051533946,y:.7279461948466053},{x:.5503571325536145,y:.7347653395141178},{x:.5545155789630078,y:.7425452455435709},{x:.5570763376181453,y:.7509869355092742},{x:.557941,y:.7597659999999999},{x:.5570763376181453,y:.7685450644907257},{x:.5545155789630078,y:.776986754456429},{x:.5503571325536145,y:.7847666604858821},{x:.5447608051533946,y:.7915858051533946},{x:.5379416604858821,y:.7971821325536145},{x:.530161754456429,y:.8013405789630078},{x:.5217200644907257,y:.8039013376181453},{x:.512941,y:.804766},{x:.406984,y:.804766},{x:.40440576588043703,y:.8045120661033809},{x:.40181542834229744,y:.8044681908525655},{x:.400026512750784,y:.8040807473169851},{x:.3982049355092742,y:.8039013376181453},{x:.39572578148103565,y:.8031492944655273},{x:.39319377618916257,y:.8026009124809075},{x:.2872357761891626,y:.7684889124809076},{x:.28342960508890525,y:.7668362808879404},{x:.2796044085190959,y:.7652281761559891},{x:.27938594032962494,y:.7650805300410848},{x:.27914407460343155,y:.764975512444704},{x:.2757334504432472,y:.7626120885587936},{x:.27229547962292316,y:.7602886242777711},{x:.2721100135665551,y:.7601011941121303},{x:.27189328313916555,y:.7599510087370087},{x:.2690092742928275,y:.7569676176126634},{x:.26609064851257996,y:.7540180832118794},{x:.26594531194585036,y:.7537980718316557},{x:.26576204564604555,y:.7536084902175343},{x:.26351548295615396,y:.7501197819025626},{x:.26122836336792754,y:.7466575263349163},{x:.2082493633679275,y:.6462725263349164},{x:.20745880379789322,y:.6443351468057326},{x:.2064724210369921,y:.6424897544564291},{x:.20579637196662365,y:.6402611193438609},{x:.20491647908027386,y:.6381048157198157},{x:.20451907388691828,y:.636050431873947},{x:.20391166238185462,y:.6340480644907258},{x:.20368338854657433,y:.6317303613460921},{x:.20324107652369047,y:.6294438319050109},{x:.20325209776572678,y:.6273513925615422},{x:.20304699999999998,y:.6252690000000001},{x:.20304699999999998,y:.568912},{x:.089112,y:.568912},{x:.0803329355092742,y:.5680473376181453},{x:.07189124554357093,y:.5654865789630078},{x:.0641113395141179,y:.5613281325536145},{x:.05729219484660536,y:.5557318051533946},{x:.051695867446385456,y:.548912660485882},{x:.04753742103699209,y:.5411327544564289},{x:.04497666238185463,y:.5326910644907257},{x:.044112,y:.5239119999999999}]],g:[[{x:.03166100000000001,y:.285331},{x:.03199195389402992,y:.28197076872347165},{x:.03216742697517915,y:.27859884139484714},{x:.032423533978450624,y:.2775888625904497},{x:.03252566238185464,y:.2765519355092742},{x:.03350580569139788,y:.2733208360362635},{x:.034335737494852386,y:.2700479324456657},{x:.07135573749485238,y:.1675239324456658},{x:.07223945098422414,y:.16566943556296815},{x:.07292365731738822,y:.16373243532732273},{x:.07413231799188957,y:.16169720247238553},{x:.07515058411631778,y:.15956034321175439},{x:.07637911169281072,y:.15791388391586245},{x:.07742806119285411,y:.15614758463046624},{x:.07901055202445481,y:.15438725620434748},{x:.0804261330120869,y:.15249010996133996},{x:.08195226304990277,y:.15111496075964967},{x:.08332564517579637,y:.14958724031548856},{x:.1584886451757964,y:.08090524031548854},{x:.16047116284778873,y:.07942238349974136},{x:.16231838489394151,y:.07777404756068641},{x:.16399482319868336,y:.07678680357956279},{x:.16555276842115366,y:.07562151273533077},{x:.16778648358567103,y:.07455391860853194},{x:.1699197861673149,y:.07329763012616651},{x:.2450797861673149,y:.038459630126166475},{x:.2459605302529857,y:.0381521715215269},{x:.24678324554357095,y:.03771242103699209},{x:.2501181687545519,y:.03670078314085588},{x:.253408434365457,y:.03555218561964517},{x:.254332237398671,y:.03542245939316866},{x:.2552249355092742,y:.03515166238185463},{x:.2586931398688001,y:.03481007406735549},{x:.26214426420887293,y:.034325445502994434},{x:.2630756249571383,y:.03437843696081321},{x:.264004,y:.034287},{x:.376189,y:.034287},{x:.37724627227682206,y:.03439113223027483},{x:.37830727432005307,y:.03433688416138392},{x:.3816280756224084,y:.03482270219101675},{x:.3849680644907258,y:.03515166238185463},{x:.38598470638687477,y:.035460057329467706},{x:.38703590484658207,y:.03561384285228289},{x:.39019811948723343,y:.036738182220129235},{x:.39340975445642906,y:.03771242103699209},{x:.39434669699397534,y:.038213227257056566},{x:.39534769490287125,y:.03856913648017993},{x:.4693886949028713,y:.07340713648017996},{x:.47140406041677185,y:.07460963544760885},{x:.47352148667564636,y:.07562166704766733},{x:.4751827197672129,y:.0768642309221422},{x:.47696422705836306,y:.07792719476830276},{x:.47870627197824944,y:.0794997663623443},{x:.480392,y:.08076065187723735},{x:.480392,y:.018480463023952315},{x:.44982106300216956,y:-.06618482166306154},{x:.42509763890365326,y:-.0887666681923909},{x:.3663917896728536,y:-.115601},{x:.27366828971008494,y:-.115601},{x:.21388478385740822,y:-.08868092320279419},{x:.15228882603575622,y:-.032396134475538775},{x:.11903308523020223,y:.0605977685009861},{x:.11526275900748023,y:.06857299605517989},{x:.11000898883421664,y:.07565942769130271},{x:.1034736741518217,y:.08158473581569503},{x:.09590796343849313,y:.08612121416008753},{x:.08760260271404471,y:.08909452840579157},{x:.07887676233341709,y:.09039041575379858},{x:.07006577144893004,y:.08995907598006667},{x:.061508231499013855,y:.08781708523020218},{x:.05353300394482007,y:.08404675900748018},{x:.046446572308697254,y:.07879298883421659},{x:.04052126418430494,y:.07225767415182165},{x:.035984785839912437,y:.06469196343849308},{x:.03301147159420839,y:.05638660271404467},{x:.03171558424620138,y:.04766076233341703},{x:.0321469240199333,y:.038849771448930016},{x:.03428891476979778,y:.030292231499013812},{x:.07130891476979778,y:-.07322776850098624},{x:.07221644299685706,y:-.07514742841768875},{x:.07292365731738822,y:-.07714956467267746},{x:.07409706350042253,y:-.07912543338941479},{x:.07507924099251978,y:-.08120299605518004},{x:.07634383839048098,y:-.08290872027080634},{x:.07742806119285414,y:-.08473441536953392},{x:.07896439356931816,y:-.08644339813281518},{x:.08033301116578337,y:-.08828942769130284},{x:.0819060799658371,y:-.08971566618082738},{x:.08332564517579637,y:-.09129475968451163},{x:.1584886451757964,y:-.15997675968451153},{x:.16066766565506738,y:-.1616065940183929},{x:.16271768036753925,y:-.16339598773796155},{x:.16419165994754753,y:-.1642424237156923},{x:.16555276842115366,y:-.1652604872646693},{x:.16800788453794988,y:-.16643389898185532},{x:.17036760218951646,y:-.1677889719724602},{x:.24552760218951647,y:-.2016329719724602},{x:.24617798725770038,y:-.20185206166908357},{x:.24678324554357095,y:-.2021755789630079},{x:.2503526828238078,y:-.20325835592431216},{x:.25388756161766735,y:-.20444912053505218},{x:.25456819199860076,y:-.20453711665220192},{x:.2552249355092742,y:-.20473633761814536},{x:.25893702635910487,y:-.20510194665533446},{x:.2626362900994872,y:-.20558021041579141},{x:.263321009549333,y:-.20553373131203426},{x:.264004,y:-.20560099999999998},{x:.376189,y:-.20560099999999998},{x:.3769985938815523,y:-.20552126196245651},{x:.37781053527049396,y:-.2055717752142049},{x:.38138177137190815,y:-.20508955666026785},{x:.3849680644907258,y:-.20473633761814536},{x:.3857465461334356,y:-.20450018779358015},{x:.38655274094280934,y:-.2043913285403334},{x:.3899612805709507,y:-.2032216620796743},{x:.39340975445642906,y:-.2021755789630079},{x:.39412720724734457,y:-.20179209245674457},{x:.39489667386274535,y:-.20152804409855607},{x:.4689376738627454,y:-.16768404409855608},{x:.471176129388074,y:-.16638175223486265},{x:.4735129313995788,y:-.16526550692304898},{x:.47497970384913024,y:-.16416890323360386},{x:.4765626813675205,y:-.163247956304222},{x:.47850406105855325,y:-.16153398660426738},{x:.480578193417323,y:-.15998330217620907},{x:.5187211934173229,y:-.125144302176209},{x:.5200982241105119,y:-.12361318710120846},{x:.5216280341275545,y:-.12223470670068204},{x:.5230406381933351,y:-.12034152832018923},{x:.5246201913815024,y:-.1185852292702623},{x:.52567205708302,y:-.11681488878073784},{x:.5269035440443172,y:-.11516444436572898},{x:.5279196645391884,y:-.1130320574948894},{x:.5291262301085498,y:-.11100134969861394},{x:.5298125082093796,y:-.10905981698676002},{x:.5306983467616347,y:-.10720083421055714},{x:.5677173467616347,y:-.0046778342105572215},{x:.5685472301626403,y:-.001405045768812418},{x:.5695273376181453,y:.0018259355092742052},{x:.5696294781899907,y:.002862986138707272},{x:.5698856101392306,y:.003873086692614168},{x:.5700610582123972,y:.007244891642088324},{x:.570392,y:.010604999999999976},{x:.570392,y:.560059},{x:.5695273376181453,y:.5688380644907257},{x:.5669665789630078,y:.577279754456429},{x:.5628081325536145,y:.5850596604858821},{x:.5572118051533946,y:.5918788051533946},{x:.5503926604858821,y:.5974751325536145},{x:.542612754456429,y:.6016335789630078},{x:.5341710644907257,y:.6041943376181453},{x:.525392,y:.605059},{x:.5166129355092742,y:.6041943376181453},{x:.508171245543571,y:.6016335789630078},{x:.5003913395141178,y:.5974751325536145},{x:.4935721948466053,y:.5918788051533946},{x:.48797586744638544,y:.5850596604858821},{x:.48381742103699205,y:.577279754456429},{x:.4812566623818546,y:.5688380644907257},{x:.480392,y:.560059},{x:.480392,y:.5595783858718113},{x:.47850787544975776,y:.5609876460911735},{x:.47656308903374583,y:.5627046621197919},{x:.47498407852937236,y:.5636233247252487},{x:.47352120750708176,y:.5647175018259646},{x:.47118052218859596,y:.5658362200595997},{x:.46893813108831367,y:.5671408350985324},{x:.39489713108831365,y:.6009858350985324},{x:.39412742928685096,y:.6012499737741558},{x:.39340975445642906,y:.6016335789630078},{x:.38996152003118717,y:.6026795894402057},{x:.3865532301567984,y:.60384921275647},{x:.38574678706033977,y:.6039581147092028},{x:.3849680644907258,y:.6041943376181453},{x:.38138202040224084,y:.6045475321329209},{x:.37781103767268465,y:.6050297570960106},{x:.3769988444371686,y:.6049792372848822},{x:.376189,y:.605059},{x:.264004,y:.605059},{x:.2633207613423033,y:.6049917068657756},{x:.2626357925427961,y:.6050381952835313},{x:.25893677979996554,y:.6045599223713788},{x:.2552249355092742,y:.6041943376181453},{x:.25456795333002863,y:.6039950442528821},{x:.2538870765735461,y:.6039070086250592},{x:.2503524457397967,y:.6027162840056636},{x:.24678324554357095,y:.6016335789630078},{x:.24617776729948443,y:.6013099440989677},{x:.24552714829793862,y:.6010907675853725},{x:.17036714829793861,y:.5672457675853725},{x:.16800780172583518,y:.5658908729822889},{x:.16555304759050302,y:.5647176561362495},{x:.1641916021742222,y:.563699355958929},{x:.16271727507130354,y:.5628526987282604},{x:.16066758950642807,y:.5610635523625588},{x:.15848888603577402,y:.5594339797745099},{x:.08332588603577401,y:.49075297977450993},{x:.08190615458499984,y:.48917372437901785},{x:.08033291862515302,y:.48774732555289924},{x:.07896444452212992,y:.48590147772545017},{x:.07742825448734617,y:.4841926782200152},{x:.07634390022195357,y:.48236679190821125},{x:.07507917015624571,y:.48066087782555583},{x:.0740970979464375,y:.4785835213931001},{x:.07292379561819572,y:.47660786018244516},{x:.07221648966449083,y:.47460551074132296},{x:.0713088683600783,y:.4726856387236396},{x:.034288868360078294,y:.36916463872363964},{x:.03348577523186824,y:.3659561323879453},{x:.03252566238185464,y:.3627910644907258},{x:.0324167369020588,y:.3616851255348066},{x:.032146903820267865,y:.36060709221327164},{x:.03198519043554786,y:.35730356073015046},{x:.03166100000000001,y:.354012},{x:.03166100000000001,y:.285331}],[{x:.121661,y:.29320659086815803},{x:.121661,y:.34620780969623244},{x:.15228882172599023,y:.4318540207415116},{x:.21388481974037543,y:.48813802669691503},{x:.2736685500834057,y:.5150589999999999},{x:.3663915263934284,y:.5150589999999999},{x:.4250929420729598,y:.48822590193711934},{x:.480392,y:.4376951204586189},{x:.480392,y:.20264468470162808},{x:.4249051037436742,y:.15194152341431572},{x:.3661311050032371,y:.124287},{x:.2739261218560311,y:.124287},{x:.21407100266628776,y:.15203091487935444},{x:.15223458736534265,y:.208535427414771},{x:.121661,y:.29320659086815803}]],h:[[{x:.047041,y:.05318299999999998},{x:.04790566238185463,y:.04440393550927419},{x:.050466421036992094,y:.03596224554357094},{x:.05462486744638546,y:.028182339514117884},{x:.06022119484660536,y:.021363194846605343},{x:.06704033951411792,y:.01576686744638544},{x:.07482024554357096,y:.011608421036992077},{x:.08326193550927423,y:.009047662381854615},{x:.092041,y:.008182999999999982},{x:.10082006449072577,y:.009047662381854615},{x:.10926175445642904,y:.011608421036992077},{x:.1170416604858821,y:.015766867446385446},{x:.12386080515339463,y:.021363194846605343},{x:.12945713255361452,y:.028182339514117884},{x:.1336155789630079,y:.03596224554357094},{x:.13617633761814535,y:.04440393550927421},{x:.137041,y:.05318299999999998},{x:.137041,y:.3692271498339558},{x:.23047284680205596,y:.45237128863270537},{x:.2915669774325256,y:.478914},{x:.38669764440631527,y:.478914},{x:.43644054132690624,y:.4571557093088599},{x:.465011,y:.38123324165433015},{x:.465011,y:.05318299999999998},{x:.4658756623818546,y:.04440393550927419},{x:.46843642103699207,y:.03596224554357094},{x:.47259486744638546,y:.028182339514117884},{x:.4781911948466053,y:.021363194846605343},{x:.4850103395141179,y:.01576686744638544},{x:.492790245543571,y:.011608421036992077},{x:.5012319355092743,y:.009047662381854615},{x:.510011,y:.008182999999999982},{x:.5187900644907257,y:.009047662381854615},{x:.527231754456429,y:.011608421036992077},{x:.5350116604858821,y:.015766867446385446},{x:.5418308051533947,y:.021363194846605343},{x:.5474271325536145,y:.028182339514117884},{x:.5515855789630079,y:.03596224554357094},{x:.5541463376181454,y:.04440393550927421},{x:.555011,y:.05318299999999998},{x:.555011,y:.38942},{x:.5546506186962206,y:.39307901278178137},{x:.554410350301749,y:.3967478709583736},{x:.5542188683658584,y:.3974626474508545},{x:.5541463376181454,y:.3981990644907258},{x:.5530790429582076,y:.40171746346329923},{x:.5521276325304605,y:.40526895152034226},{x:.5139866325304605,y:.5066239515203422},{x:.5138553396770835,y:.5068902237569821},{x:.5137747554395128,y:.50717595947055},{x:.511905898744729,y:.5108438433478746},{x:.5100853961903059,y:.5145359657635786},{x:.5099046789559015,y:.5147715076888114},{x:.5097698988494882,y:.5150360318659072},{x:.5072213830653152,y:.5182688425286295},{x:.504715563605999,y:.5215348594178236},{x:.5044923668525381,y:.521730619287556},{x:.5043085704011859,y:.5219637664124008},{x:.5011783335599848,y:.5246372687597332},{x:.4980834944323178,y:.5273516689249697},{x:.497826395485866,y:.5275001237971909},{x:.49760064588412606,y:.5276929341565276},{x:.49400898123224624,y:.5297043869925788},{x:.49044405536829966,y:.5317628575577613},{x:.490162934397186,y:.5318583023949868},{x:.48990390707565157,y:.532003366394835},{x:.41414290707565155,y:.5651423663948351},{x:.41372099607879415,y:.5652794559590063},{x:.41332975445642905,y:.5654885789630079},{x:.40952975949805703,y:.5666412948313546},{x:.4057531353317914,y:.5678684156337233},{x:.40531258638921414,y:.5679205603081202},{x:.4048880644907258,y:.5680493376181454},{x:.4009362016599996,y:.5684385621342186},{x:.39699274487562397,y:.5689053213297277},{x:.39655048803612764,y:.5688705172237564},{x:.396109,y:.568914},{x:.282214,y:.568914},{x:.28182836168040026,y:.5688760179407144},{x:.2814421286004882,y:.5689073796745989},{x:.27744221175957573,y:.5684440198796774},{x:.2734349355092742,y:.5680493376181454},{x:.2730641170540284,y:.5679368510695262},{x:.2726791869636831,y:.5678922598605547},{x:.26884652441488044,y:.5666574583296339},{x:.26499324554357095,y:.5654885789630079},{x:.2646514972979566,y:.5653059107200353},{x:.264282662844679,y:.5651870801833616},{x:.18800566284467896,y:.5320480801833616},{x:.1856267698486466,y:.5307235797343987},{x:.1831549202301779,y:.529581917442145},{x:.18178185218619736,y:.5285828381463435},{x:.18029822995654404,y:.527756799180932},{x:.17822344394147954,y:.5259936496360635},{x:.17602181748454487,y:.5243916901265875},{x:.137041,y:.4897030201456747},{x:.137041,y:.7597659999999999},{x:.13617633761814535,y:.7685450644907257},{x:.1336155789630079,y:.776986754456429},{x:.12945713255361452,y:.7847666604858821},{x:.12386080515339463,y:.7915858051533946},{x:.11704166048588208,y:.7971821325536145},{x:.10926175445642904,y:.8013405789630078},{x:.10082006449072577,y:.8039013376181453},{x:.092041,y:.804766},{x:.08326193550927423,y:.8039013376181453},{x:.07482024554357093,y:.8013405789630078},{x:.06704033951411792,y:.7971821325536145},{x:.06022119484660536,y:.7915858051533946},{x:.05462486744638546,y:.7847666604858821},{x:.050466421036992094,y:.776986754456429},{x:.04790566238185463,y:.7685450644907257},{x:.047041,y:.7597659999999999},{x:.047041,y:.05318299999999998}]],i:[[{x:.216026,y:.7597659999999999},{x:.21689066238185462,y:.7509869355092742},{x:.21945142103699208,y:.7425452455435709},{x:.22360986744638545,y:.7347653395141178},{x:.22920619484660534,y:.7279461948466053},{x:.2360253395141179,y:.7223498674463854},{x:.24380524554357094,y:.7181914210369921},{x:.25224693550927424,y:.7156306623818546},{x:.261026,y:.7147659999999999},{x:.341026,y:.7147659999999999},{x:.3498050644907258,y:.7156306623818546},{x:.35824675445642906,y:.7181914210369921},{x:.3660266604858821,y:.7223498674463854},{x:.3728458051533946,y:.7279461948466053},{x:.37844213255361453,y:.7347653395141178},{x:.3826005789630079,y:.7425452455435709},{x:.38516133761814536,y:.7509869355092742},{x:.386026,y:.7597659999999999},{x:.38516133761814536,y:.7685450644907257},{x:.3826005789630079,y:.776986754456429},{x:.37844213255361453,y:.7847666604858821},{x:.3728458051533946,y:.7915858051533946},{x:.3660266604858821,y:.7971821325536145},{x:.35824675445642906,y:.8013405789630078},{x:.3498050644907258,y:.8039013376181453},{x:.341026,y:.804766},{x:.261026,y:.804766},{x:.25224693550927424,y:.8039013376181453},{x:.24380524554357094,y:.8013405789630078},{x:.2360253395141179,y:.7971821325536145},{x:.22920619484660534,y:.7915858051533946},{x:.22360986744638545,y:.7847666604858821},{x:.21945142103699208,y:.776986754456429},{x:.21689066238185462,y:.7685450644907257},{x:.216026,y:.7597659999999999}],[{x:.25597800000000004,y:.05318299999999998},{x:.25684266238185466,y:.04440393550927419},{x:.2594034210369921,y:.03596224554357094},{x:.2635618674463855,y:.028182339514117884},{x:.2691581948466054,y:.021363194846605343},{x:.27597733951411796,y:.01576686744638544},{x:.28375724554357096,y:.011608421036992077},{x:.2921989355092742,y:.009047662381854615},{x:.300978,y:.008182999999999982},{x:.3097570644907258,y:.009047662381854615},{x:.3181987544564291,y:.011608421036992077},{x:.32597866048588214,y:.015766867446385446},{x:.33279780515339463,y:.021363194846605343},{x:.33839413255361456,y:.028182339514117884},{x:.34255257896300795,y:.03596224554357094},{x:.3451133376181454,y:.04440393550927421},{x:.345978,y:.05318299999999998},{x:.345978,y:.523911},{x:.3451133376181454,y:.5326900644907258},{x:.34255257896300795,y:.541131754456429},{x:.33839413255361456,y:.5489116604858821},{x:.33279780515339463,y:.5557308051533947},{x:.32597866048588214,y:.5613271325536145},{x:.3181987544564291,y:.5654855789630079},{x:.3097570644907258,y:.5680463376181454},{x:.300978,y:.5689110000000001},{x:.2921989355092742,y:.5680463376181454},{x:.28375724554357096,y:.5654855789630079},{x:.27597733951411796,y:.5613271325536145},{x:.2691581948466054,y:.5557308051533947},{x:.2635618674463855,y:.5489116604858821},{x:.2594034210369921,y:.541131754456429},{x:.25684266238185466,y:.5326900644907258},{x:.25597800000000004,y:.523911},{x:.25597800000000004,y:.05318299999999998}]],j:[[{x:.11017199870220953,y:-.1121580749666587},{x:.11173080987432929,y:-.12084080046598154},{x:.114953584640513,y:-.12905258085596802},{x:.11971647357384912,y:-.1364778420214504},{x:.12583644152368842,y:-.14283123533997366},{x:.1330783015538362,y:-.147868603469331},{x:.14116375304461573,y:-.15139636317729976},{x:.23896575304461573,y:-.18307436317729964},{x:.2424293887998465,y:-.18383095770413346},{x:.24586120600074532,y:-.1847208108507566},{x:.24673197042105502,y:-.1847708110651418},{x:.2475840766296098,y:-.18495694463669302},{x:.2511287638648936,y:-.18502327959701073},{x:.25466824139749206,y:-.18522652014211538},{x:.25553202888155596,y:-.18510568190524296},{x:.2564040749666586,y:-.1851220012977904},{x:.25989359333942796,y:-.1844955274762681},{x:.2634047110671092,y:-.18400434499968443},{x:.3944597110671092,y:-.15232634499968456},{x:.39510744613291976,y:-.15210060706564532},{x:.39578357398914765,y:-.1519849807175323},{x:.3992672661785621,y:-.15065089524264363},{x:.4027898773796621,y:-.14942325292878383},{x:.40338112711156726,y:-.1490754856432793},{x:.40402170577913904,y:-.1488301750218278},{x:.4071781926350792,y:-.14684208899421944},{x:.4103936167153703,y:-.14495080812962524},{x:.41090565971774945,y:-.14449437599440731},{x:.41148607211771127,y:-.14412880824922783},{x:.41419405162048195,y:-.14156312270000898},{x:.41697872163578864,y:-.1390808841476645},{x:.4173918803832174,y:-.13853332759371953},{x:.41788982159253774,y:-.13806155128824654},{x:.42004522760849955,y:-.13501686407422092},{x:.422292130251795,y:-.13203905886963707},{x:.4225905272853119,y:-.13142142018825975},{x:.42298686170256505,y:-.13086156542133753},{x:.4245068631872901,y:-.12745488216466036},{x:.4261296512500701,y:-.1240959456918764},{x:.4263018193390199,y:-.1234319603912164},{x:.42658131605481786,y:-.12280554206756752},{x:.4588533160548179,y:-.025908542067567514},{x:.4594769463166796,y:-.023162642495487502},{x:.46029433761814537,y:-.02046806449072583},{x:.46045163429328767,y:-.01887100454660151},{x:.46080705178433234,y:-.017306069686551954},{x:.4608830007338393,y:-.01449126757618431},{x:.461159,y:-.01168900000000006},{x:.461159,y:.534292},{x:.46029433761814537,y:.5430710644907257},{x:.4577335789630079,y:.551512754456429},{x:.45357513255361454,y:.5592926604858821},{x:.4479788051533946,y:.5661118051533947},{x:.4411596604858821,y:.5717081325536145},{x:.43337975445642907,y:.5758665789630079},{x:.4249380644907258,y:.5784273376181454},{x:.416159,y:.579292},{x:.4073799355092742,y:.5784273376181454},{x:.39893824554357094,y:.5758665789630079},{x:.39115833951411794,y:.5717081325536145},{x:.3843391948466054,y:.5661118051533947},{x:.37874286744638547,y:.5592926604858821},{x:.3745844210369921,y:.551512754456429},{x:.37202366238185464,y:.5430710644907257},{x:.371159,y:.534292},{x:.371159,y:-.004392296840350002},{x:.3490732119536395,y:-.07070509444595838},{x:.254610065464387,y:-.09353828321774525},{x:.16889624695538427,y:-.06577563682270039},{x:.16027792337039018,y:-.063893055363307},{x:.15145792503334138,y:-.0637279987022096},{x:.14277519953401854,y:-.06528680987432936},{x:.13456341914403205,y:-.06850958464051307},{x:.12713815797854966,y:-.0732724735738492},{x:.12078476466002638,y:-.07939244152368852},{x:.11574739653066908,y:-.08663430155383627},{x:.11221963682270032,y:-.0947197530446158},{x:.11033705536330693,y:-.10333807662960988},{x:.11017199870220953,y:-.1121580749666587}],[{x:.3403,y:.7597659999999999},{x:.3411646623818546,y:.7509869355092742},{x:.34372542103699205,y:.7425452455435709},{x:.34788386744638544,y:.7347653395141178},{x:.3534801948466053,y:.7279461948466053},{x:.3602993395141179,y:.7223498674463854},{x:.36807924554357097,y:.7181914210369921},{x:.37652093550927423,y:.7156306623818546},{x:.3853,y:.7147659999999999},{x:.447023,y:.7147659999999999},{x:.4558020644907258,y:.7156306623818546},{x:.46424375445642907,y:.7181914210369921},{x:.4720236604858821,y:.7223498674463854},{x:.4788428051533946,y:.7279461948466053},{x:.48443913255361454,y:.7347653395141178},{x:.48859757896300793,y:.7425452455435709},{x:.49115833761814537,y:.7509869355092742},{x:.492023,y:.7597659999999999},{x:.49115833761814537,y:.7685450644907257},{x:.48859757896300793,y:.776986754456429},{x:.48443913255361454,y:.7847666604858821},{x:.4788428051533946,y:.7915858051533946},{x:.4720236604858821,y:.7971821325536145},{x:.46424375445642907,y:.8013405789630078},{x:.4558020644907258,y:.8039013376181453},{x:.447023,y:.804766},{x:.3853,y:.804766},{x:.37652093550927423,y:.8039013376181453},{x:.36807924554357097,y:.8013405789630078},{x:.3602993395141179,y:.7971821325536145},{x:.3534801948466053,y:.7915858051533946},{x:.34788386744638544,y:.7847666604858821},{x:.34372542103699205,y:.776986754456429},{x:.3411646623818546,y:.7685450644907257},{x:.3403,y:.7597659999999999}]],k:[[{x:.020185999999999996,y:.05318299999999998},{x:.02105066238185463,y:.04440393550927419},{x:.02361142103699209,y:.03596224554357094},{x:.027769867446385453,y:.028182339514117884},{x:.03336619484660536,y:.021363194846605343},{x:.04018533951411791,y:.01576686744638544},{x:.047965245543570956,y:.011608421036992077},{x:.056406935509274225,y:.009047662381854615},{x:.065186,y:.008182999999999982},{x:.07396506449072576,y:.009047662381854615},{x:.08240675445642903,y:.011608421036992077},{x:.0901866604858821,y:.015766867446385446},{x:.09700580515339463,y:.021363194846605343},{x:.10260213255361453,y:.028182339514117884},{x:.10676057896300789,y:.03596224554357094},{x:.10932133761814536,y:.04440393550927421},{x:.11018599999999999,y:.05318299999999998},{x:.11018599999999999,y:.16578332733911408},{x:.23477705990096162,y:.26351643594805596},{x:.5068321321577423,y:.019673199736523116},{x:.5139466814455551,y:.014457569113271652},{x:.5219420457215526,y:.010730135081525344},{x:.5305109676204599,y:.008634140840755075},{x:.539324148279209,y:.008250134274186548},{x:.5480429021075728,y:.009592872538819623},{x:.5563321722854605,y:.012610754956160736},{x:.5638734068086124,y:.017187805997359452},{x:.5703768002634768,y:.02314813215774228},{x:.5755924308867283,y:.030262681445555134},{x:.5793198649184746,y:.03825804572155257},{x:.5814158591592449,y:.04682696762045996},{x:.5817998657258134,y:.05564014827920904},{x:.5804571274611804,y:.06435890210757275},{x:.5774392450438393,y:.07264817228546054},{x:.5728621940026405,y:.08018940680861247},{x:.5669018678422577,y:.08669280026347684},{x:.3066862956724008,y:.3199242805817128},{x:.5215978711622948,y:.4885076152557163},{x:.5279716470169837,y:.49460635247919954},{x:.533033147947031,y:.5018313661609891},{x:.5365878633102175,y:.5099050030771282},{x:.5384991873886431,y:.5185169978886772},{x:.5386936690698568,y:.5273363964646907},{x:.5371638345319164,y:.5360242742638681},{x:.5339684744581735,y:.5442467610146052},{x:.5292303847442837,y:.5516878711622948},{x:.5231316475208004,y:.5580616470169838},{x:.5159066338390108,y:.5631231479470311},{x:.5078329969228718,y:.5666778633102175},{x:.4992210021113228,y:.5685891873886431},{x:.49040160353530926,y:.5687836690698569},{x:.4817137257361318,y:.5672538345319164},{x:.47349123898539475,y:.5640584744581736},{x:.46605012883770514,y:.5593203847442837},{x:.11018599999999999,y:.28016947631338524},{x:.11018599999999999,y:.7597659999999999},{x:.10932133761814536,y:.7685450644907257},{x:.10676057896300789,y:.776986754456429},{x:.10260213255361453,y:.7847666604858821},{x:.09700580515339463,y:.7915858051533946},{x:.09018666048588207,y:.7971821325536145},{x:.08240675445642903,y:.8013405789630078},{x:.07396506449072576,y:.8039013376181453},{x:.065186,y:.804766},{x:.056406935509274204,y:.8039013376181453},{x:.04796524554357093,y:.8013405789630078},{x:.04018533951411791,y:.7971821325536145},{x:.03336619484660536,y:.7915858051533946},{x:.027769867446385453,y:.7847666604858821},{x:.02361142103699209,y:.776986754456429},{x:.02105066238185463,y:.7685450644907257},{x:.020185999999999996,y:.7597659999999999},{x:.020185999999999996,y:.05318299999999998}]],l:[[{x:.25602600000000003,y:.05355900000000002},{x:.25689066238185465,y:.044779935509274234},{x:.2594514210369921,y:.036338245543570985},{x:.2636098674463855,y:.028558339514117927},{x:.26920619484660535,y:.021739194846605386},{x:.27602533951411795,y:.016142867446385482},{x:.283805245543571,y:.01198442103699212},{x:.2922469355092743,y:.009423662381854658},{x:.301026,y:.008559000000000025},{x:.3098050644907258,y:.009423662381854658},{x:.3182467544564291,y:.01198442103699212},{x:.32602666048588214,y:.01614286744638549},{x:.3328458051533947,y:.021739194846605386},{x:.33844213255361455,y:.028558339514117927},{x:.34260057896300794,y:.036338245543570985},{x:.3451613376181454,y:.044779935509274255},{x:.346026,y:.05355900000000002},{x:.346026,y:.765137},{x:.3451613376181454,y:.7739160644907257},{x:.34260057896300794,y:.782357754456429},{x:.33844213255361455,y:.7901376604858821},{x:.3328458051533947,y:.7969568051533946},{x:.32602666048588214,y:.8025531325536145},{x:.3182467544564291,y:.8067115789630078},{x:.3098050644907258,y:.8092723376181453},{x:.301026,y:.810137},{x:.2922469355092743,y:.8092723376181453},{x:.283805245543571,y:.8067115789630078},{x:.27602533951411795,y:.8025531325536145},{x:.26920619484660535,y:.7969568051533946},{x:.2636098674463855,y:.7901376604858821},{x:.2594514210369921,y:.782357754456429},{x:.25689066238185465,y:.7739160644907257},{x:.25602600000000003,y:.765137},{x:.25602600000000003,y:.05355900000000002}]],m:[[{x:.005538000000000001,y:.03920400000000002},{x:.006402662381854635,y:.030424935509274227},{x:.008963421036992096,y:.02198324554357097},{x:.013121867446385459,y:.01420333951411792},{x:.018718194846605363,y:.00738419484660538},{x:.025537339514117914,y:.0017878674463854757},{x:.03331724554357096,y:-.002370578963007887},{x:.04175893550927423,y:-.004931337618145348},{x:.050538,y:-.005795999999999982},{x:.059317064490725775,y:-.004931337618145348},{x:.06775875445642904,y:-.002370578963007887},{x:.0755386604858821,y:.0017878674463854827},{x:.08235780515339464,y:.00738419484660538},{x:.08795413255361453,y:.01420333951411792},{x:.0921125789630079,y:.02198324554357098},{x:.09467333761814536,y:.030424935509274248},{x:.095538,y:.03920400000000002},{x:.095538,y:.3993271266071161},{x:.14963521853994496,y:.4943223065353007},{x:.1738257653562211,y:.5150589999999999},{x:.22021623464377893,y:.5150589999999999},{x:.2416666625786254,y:.49667119950297894},{x:.27741,y:.4029520066676719},{x:.27741,y:.03920400000000002},{x:.2782746623818546,y:.030424935509274227},{x:.28083542103699205,y:.02198324554357097},{x:.28499386744638544,y:.01420333951411792},{x:.2905901948466053,y:.00738419484660538},{x:.2974093395141179,y:.0017878674463854757},{x:.30518924554357096,y:-.002370578963007887},{x:.31363093550927423,y:-.004931337618145348},{x:.32241,y:-.005795999999999982},{x:.33118906449072577,y:-.004931337618145348},{x:.33963075445642904,y:-.002370578963007887},{x:.3474106604858821,y:.0017878674463854827},{x:.35422980515339464,y:.00738419484660538},{x:.3598261325536145,y:.01420333951411792},{x:.3639845789630079,y:.02198324554357098},{x:.36654533761814534,y:.030424935509274248},{x:.36740999999999996,y:.03920400000000002},{x:.36740999999999996,y:.3993264781598986},{x:.4215891088917321,y:.494459500052724},{x:.445289826307752,y:.5150589999999999},{x:.4920928256254945,y:.5150589999999999},{x:.5065149999999999,y:.5026965582556255},{x:.5065149999999999,y:.03920400000000002},{x:.5073796623818546,y:.030424935509274227},{x:.5099404210369921,y:.02198324554357097},{x:.5140988674463854,y:.01420333951411792},{x:.5196951948466053,y:.00738419484660538},{x:.5265143395141179,y:.0017878674463854757},{x:.534294245543571,y:-.002370578963007887},{x:.5427359355092742,y:-.004931337618145348},{x:.551515,y:-.005795999999999982},{x:.5602940644907257,y:-.004931337618145348},{x:.568735754456429,y:-.002370578963007887},{x:.5765156604858821,y:.0017878674463854827},{x:.5833348051533946,y:.00738419484660538},{x:.5889311325536145,y:.01420333951411792},{x:.5930895789630078,y:.02198324554357098},{x:.5956503376181453,y:.030424935509274248},{x:.596515,y:.03920400000000002},{x:.596515,y:.523393},{x:.5963454778388272,y:.5251141873868636},{x:.5963825315707437,y:.5268433058919912},{x:.5959141404350922,y:.5294936295415332},{x:.5956503376181453,y:.5321720644907257},{x:.5951482857762117,y:.5338271076115645},{x:.59484729324509,y:.5355302304139588},{x:.5938708496195351,y:.5380382502602514},{x:.5930895789630078,y:.540613754456429},{x:.592274291011045,y:.5421390509322689},{x:.5916468191910574,y:.543750727977755},{x:.5901998472565338,y:.5460200622246176},{x:.5889311325536145,y:.5483936604858821},{x:.5878339395503975,y:.5497305940285525},{x:.5869041018316961,y:.5511888894721116},{x:.5850422079081763,y:.5531323288770946},{x:.5833348051533946,y:.5552128051533947},{x:.581997871610724,y:.5563099981566119},{x:.5808014011353795,y:.5575588705221693},{x:.5380264011353795,y:.5942248705221693},{x:.5358211367621821,y:.5957677297988329},{x:.5337406604858821,y:.5974751325536145},{x:.5322153640100423,y:.5982904205055773},{x:.5307982404674333,y:.599281876328501},{x:.5283343527176928,y:.600364864260089},{x:.525960754456429,y:.6016335789630078},{x:.5243057113355902,y:.6021356308049415},{x:.5227223939887274,y:.6028315689939708},{x:.5200945686869033,y:.6034130669616181},{x:.5175190644907257,y:.6041943376181453},{x:.5157978771038628,y:.6043638597793182},{x:.5141092119504517,y:.6047375358201355},{x:.5114184349491921,y:.6047951971830532},{x:.50874,y:.605059},{x:.428467,y:.605059},{x:.42563553135621585,y:.6047801246797119},{x:.42279150043448566,y:.6046996620098968},{x:.4212557149999115,y:.6043487504203328},{x:.4196879355092742,y:.6041943376181453},{x:.41696527861756566,y:.6033684286794448},{x:.4141915924406847,y:.6027346691689239},{x:.4127537761476033,y:.6020908833721776},{x:.4112462455435709,y:.6016335789630078},{x:.40873703058140176,y:.6002923756232341},{x:.4061402803536474,y:.5991296742945802},{x:.40485568767586616,y:.5982177546177817},{x:.4034663395141179,y:.5974751325536145},{x:.4012669942053008,y:.5956701765049598},{x:.3989469715816508,y:.5940232153181825},{x:.3567609715816508,y:.5573572153181825},{x:.3545792701559384,y:.5550484712393128},{x:.3522737143614353,y:.552863400803129},{x:.35155574109793963,y:.5518488790642903},{x:.35070210094674875,y:.5509455305944583},{x:.3490127339279754,y:.5482555195520005},{x:.34717776483660073,y:.5456626430091704},{x:.33048446785976626,y:.5163509060824124},{x:.3216828574856715,y:.5394287684036221},{x:.32062739498214626,y:.5415455848316745},{x:.31976928952310246,y:.5437498007710907},{x:.3186639603788477,y:.5454834136126945},{x:.31774653490223986,y:.5473233854865517},{x:.3162983824161672,y:.5491936173608123},{x:.31502674401548947,y:.5511880718386934},{x:.3136044423732838,y:.5526727347769701},{x:.3123456842645886,y:.5542983712755478},{x:.3105604934838748,y:.5558501466339272},{x:.30892419049215825,y:.5575581938831911},{x:.2661511904921582,y:.594224193883191},{x:.26394553725639397,y:.5957674011217274},{x:.2618646604858821,y:.5974751325536145},{x:.26033982189406285,y:.5982901757614695},{x:.258923146662659,y:.5992813666868191},{x:.25645880963824363,y:.6003646200309664},{x:.25408475445642903,y:.6016335789630078},{x:.25243020816870526,y:.6021354800922637},{x:.25084738219782576,y:.6028312459348294},{x:.24821906447459133,y:.6034129165660671},{x:.24564306449072576,y:.6041943376181453},{x:.24392239379305308,y:.6043638088898747},{x:.2422342441971012,y:.6047374117585159},{x:.2395429505511757,y:.6047951464006902},{x:.236864,y:.605059},{x:.157178,y:.605059},{x:.1544990494488241,y:.6047951464006902},{x:.1518077558028988,y:.6047374117585159},{x:.15011960620694695,y:.6043638088898747},{x:.14839893550927424,y:.6041943376181453},{x:.14582293552540848,y:.6034129165660671},{x:.1431946178021742,y:.6028312459348294},{x:.1416117918312948,y:.6021354800922637},{x:.13995724554357097,y:.6016335789630078},{x:.13758319036175665,y:.6003646200309664},{x:.135118853337341,y:.5992813666868191},{x:.13370217810593676,y:.5982901757614691},{x:.13217733951411792,y:.5974751325536145},{x:.13009646274360603,y:.5957674011217274},{x:.1278908095078418,y:.594224193883191},{x:.09495385911112918,y:.5659898819750746},{x:.09467333761814536,y:.5688380644907257},{x:.0921125789630079,y:.577279754456429},{x:.08795413255361453,y:.5850596604858821},{x:.08235780515339464,y:.5918788051533946},{x:.07553866048588208,y:.5974751325536145},{x:.06775875445642904,y:.6016335789630078},{x:.059317064490725775,y:.6041943376181453},{x:.050538,y:.605059},{x:.04175893550927421,y:.6041943376181453},{x:.033317245543570934,y:.6016335789630078},{x:.025537339514117904,y:.5974751325536145},{x:.018718194846605356,y:.5918788051533946},{x:.013121867446385459,y:.5850596604858821},{x:.008963421036992096,y:.577279754456429},{x:.006402662381854635,y:.5688380644907257},{x:.005538000000000001,y:.560059},{x:.005538000000000001,y:.03920400000000002}]],n:[[{x:.047041,y:.03920400000000002},{x:.04790566238185463,y:.030424935509274227},{x:.050466421036992094,y:.02198324554357097},{x:.05462486744638546,y:.01420333951411792},{x:.06022119484660536,y:.00738419484660538},{x:.06704033951411792,y:.0017878674463854757},{x:.07482024554357096,y:-.002370578963007887},{x:.08326193550927423,y:-.004931337618145348},{x:.092041,y:-.005795999999999982},{x:.10082006449072577,y:-.004931337618145348},{x:.10926175445642904,y:-.002370578963007887},{x:.1170416604858821,y:.0017878674463854827},{x:.12386080515339463,y:.00738419484660538},{x:.12945713255361452,y:.01420333951411792},{x:.1336155789630079,y:.02198324554357098},{x:.13617633761814535,y:.030424935509274248},{x:.137041,y:.03920400000000002},{x:.137041,y:.3923986904044417},{x:.23217657812189968,y:.4860775193429304},{x:.29246969284729285,y:.5150589999999999},{x:.3857956927587408,y:.5150589999999999},{x:.4353266752666751,y:.4910865745843881},{x:.465011,y:.4037995608673687},{x:.465011,y:.03920400000000002},{x:.4658756623818546,y:.030424935509274227},{x:.46843642103699207,y:.02198324554357097},{x:.47259486744638546,y:.01420333951411792},{x:.4781911948466053,y:.00738419484660538},{x:.4850103395141179,y:.0017878674463854757},{x:.492790245543571,y:-.002370578963007887},{x:.5012319355092743,y:-.004931337618145348},{x:.510011,y:-.005795999999999982},{x:.5187900644907257,y:-.004931337618145348},{x:.527231754456429,y:-.002370578963007887},{x:.5350116604858821,y:.0017878674463854827},{x:.5418308051533947,y:.00738419484660538},{x:.5474271325536145,y:.01420333951411792},{x:.5515855789630079,y:.02198324554357098},{x:.5541463376181454,y:.030424935509274248},{x:.555011,y:.03920400000000002},{x:.555011,y:.411242},{x:.5547211401667089,y:.41418499627592825},{x:.5546227314347089,y:.4171405946120584},{x:.5542897326303223,y:.4185651504993601},{x:.5541463376181454,y:.4200210644907258},{x:.5532878972691104,y:.42285096307022063},{x:.5526147708021555,y:.4257305718218671},{x:.5144747708021555,y:.537881571821867},{x:.5144109474804813,y:.5380222238814931},{x:.5143747633675698,y:.5381723808934484},{x:.5125889395552703,y:.5420375142269895},{x:.5108295711501452,y:.5459147613418461},{x:.5107395343200961,y:.546040259499208},{x:.5106747512949527,y:.5461804721160435},{x:.5081691914797779,y:.5496229410537735},{x:.5056872154570532,y:.5530824522038071},{x:.5055744251835149,y:.5531879736350976},{x:.505483532821465,y:.5533128535645805},{x:.5023545242619802,y:.5562003659557777},{x:.4992453215682988,y:.5591091940676126},{x:.49911411231822944,y:.5591906836434047},{x:.49900060356177384,y:.559295431819878},{x:.49536839230215873,y:.5615170221826804},{x:.49175144785337105,y:.5637633826232722},{x:.4916068619246677,y:.563817708744868},{x:.49147509885166074,y:.5638982997546532},{x:.41571709885166075,y:.6005642997546532},{x:.4144883994140345,y:.6010164083750983},{x:.41333375445642906,y:.6016335789630078},{x:.41035728417594536,y:.6025364813514484},{x:.4074382196167836,y:.6036105717354909},{x:.4061449272779714,y:.6038142858466193},{x:.4048920644907258,y:.6041943376181453},{x:.4017966387343604,y:.6044992104448776},{x:.3987241185432898,y:.6049831812385367},{x:.3974159338025849,y:.6049306722213019},{x:.396113,y:.605059},{x:.282216,y:.605059},{x:.28097323419788345,y:.6049365982521052},{x:.2797255990169867,y:.6049900349640848},{x:.2765922846246742,y:.6045051123806029},{x:.2734369355092743,y:.6041943376181453},{x:.2722419284999821,y:.603831836204989},{x:.27100784129389754,y:.6036408445963318},{x:.26802933636200627,y:.6025539603505436},{x:.264995245543571,y:.6016335789630078},{x:.2638939207763026,y:.6010449086106044},{x:.2627208068242762,y:.6006168283817219},{x:.18644080682427616,y:.563950828381722},{x:.18387931815291048,y:.5623935720684188},{x:.18122474955630472,y:.5610008994562176},{x:.18011833133270075,y:.5601070811947741},{x:.17890296169536754,y:.5593681975674947},{x:.17669449694619624,y:.5573411418478543},{x:.17436263208920222,y:.5554573484070612},{x:.137041,y:.5187071981771466},{x:.137041,y:.560059},{x:.13617633761814535,y:.5688380644907257},{x:.1336155789630079,y:.577279754456429},{x:.12945713255361452,y:.5850596604858821},{x:.12386080515339463,y:.5918788051533946},{x:.11704166048588208,y:.5974751325536145},{x:.10926175445642904,y:.6016335789630078},{x:.10082006449072577,y:.6041943376181453},{x:.092041,y:.605059},{x:.08326193550927423,y:.6041943376181453},{x:.07482024554357093,y:.6016335789630078},{x:.06704033951411792,y:.5974751325536145},{x:.06022119484660536,y:.5918788051533946},{x:.05462486744638546,y:.5850596604858821},{x:.050466421036992094,y:.577279754456429},{x:.04790566238185463,y:.5688380644907257},{x:.047041,y:.560059},{x:.047041,y:.03920400000000002}]],o:[[{x:.021894999999999998,y:.25490100000000004},{x:.022142430975592695,y:.2523887911456351},{x:.02217771682540861,y:.24986467341374632},{x:.02257373987793045,y:.24800963837050735},{x:.02275966238185463,y:.24612193550927428},{x:.023492446675001572,y:.24370626943231966},{x:.02401948545822835,y:.2412375358426815},{x:.060310485458228355,y:.12735753584268142},{x:.06080304558444478,y:.12621387418764726},{x:.061129830312657105,y:.12501229639135567},{x:.06254436541764224,y:.12217075210694647},{x:.06379993607002282,y:.11925547753662338},{x:.06450614911208748,y:.11822988473324028},{x:.0650610709625847,y:.11711514745523491},{x:.06700278396163635,y:.114604164756607},{x:.06880297103068717,y:.11198985605258731},{x:.06969569761744246,y:.11112174505713},{x:.07045743125471368,y:.1101366870258529},{x:.14244943125471368,y:.0338456870258529},{x:.144568728324263,y:.03200109409682955},{x:.1465508815997487,y:.0300098604251366},{x:.14788834203377002,y:.029111770054614114},{x:.1491035320893312,y:.02805409342394511},{x:.1515419696884587,y:.026658398178569347},{x:.15387450686277807,y:.025092124424329433},{x:.22587150686277807,y:-.01360287557567049},{x:.22795933917571506,y:-.014473279294209745},{x:.22995424554357097,y:-.015539578963007873},{x:.23202067225559728,y:-.016166422653018674},{x:.2340138134199343,y:-.01699735024728135},{x:.23623133596214702,y:-.01744371352418634},{x:.23839593550927424,y:-.018100337618145335},{x:.2405449475487996,y:-.01831199682974963},{x:.24266189699648397,y:-.01873811583170923},{x:.2449238916202761,y:-.018743285176571887},{x:.247175,y:-.018964999999999968},{x:.354874,y:-.018964999999999968},{x:.35712497901801044,y:-.018743297917588594},{x:.3593868436844028,y:-.018738141970160445},{x:.36150392306047363,y:-.018312009573623896},{x:.3636530644907258,y:-.018100337618145335},{x:.36581753964743763,y:-.017443751257606326},{x:.36803493734305537,y:-.016997426474138877},{x:.370028203326089,y:-.016166460394901543},{x:.3720947544564291,y:-.015539578963007873},{x:.3740895461854217,y:-.014473340569958804},{x:.376177263560353,y:-.01360299896157894},{x:.448175263560353,y:.025092001038420984},{x:.4505076595021602,y:.026658160356610353},{x:.4529459593263057,y:.028053731854915283},{x:.45416130097157975,y:.029111510806286087},{x:.45549891730603415,y:.030009694621828502},{x:.4574809543881169,y:.03200078850323144},{x:.4596001404718476,y:.03384523318438343},{x:.5315941404718476,y:.11013623318438343},{x:.5323560786638525,y:.11112152750713142},{x:.5332490289693128,y:.11198985605258731},{x:.5350490398057314,y:.11460390882403626},{x:.5369905975332091,y:.11711461878219896},{x:.5375456739097991,y:.11822962771804991},{x:.5382520639299772,y:.11925547753662338},{x:.5395075116659538,y:.12217046671076734},{x:.5409219476918898,y:.12501171320336152},{x:.5412488309792026,y:.126213587584214},{x:.5417415145417717,y:.12735753584268142},{x:.5780325145417716,y:.2412375358426815},{x:.5785595533249983,y:.2437062694323195},{x:.5792923376181454,y:.24612193550927428},{x:.5794782601220696,y:.2480096383705079},{x:.5798742831745913,y:.24986467341374632},{x:.5799095690244073,y:.25238879114563434},{x:.580157,y:.25490100000000004},{x:.580157,y:.33119200000000004},{x:.5799156873690254,y:.3336420882589673},{x:.5798881240960263,y:.3361038771468651},{x:.5794843860383102,y:.3380211641581212},{x:.5792923376181454,y:.33997106449072584},{x:.5785776732343003,y:.3423269972319261},{x:.5780703683949873,y:.3447361062088315},{x:.5417793683949873,y:.4597211062088315},{x:.5412650895934552,y:.4609244011905288},{x:.540921633437906,y:.46218711230867804},{x:.5395351283421765,y:.46497211555478546},{x:.5383124760126231,y:.46783284286481475},{x:.5375733277285976,y:.46891268605384906},{x:.5369901282681178,y:.47008412955994733},{x:.5350869372989228,y:.47254512602400234},{x:.5333296776789325,y:.47511235762423976},{x:.5323940649664491,y:.4760272512524403},{x:.5315935342292432,y:.47706240922950055},{x:.45959953422924316,y:.5533504092295005},{x:.4572787448447235,y:.5553702403350376},{x:.45508230823461715,y:.5575246421731296},{x:.45395838697349994,y:.5582600166131206},{x:.4529452394037514,y:.5591417799431011},{x:.45027499383570063,y:.5606700370119551},{x:.44770045819082444,y:.5623545390972755},{x:.3757024581908245,y:.5999485390972755},{x:.37385313535723513,y:.6006937047902838},{x:.3720947544564291,y:.6016335789630078},{x:.36977177563531344,y:.6023382468844833},{x:.3675201821794923,y:.6032455034042244},{x:.36556101895058973,y:.6036155659602718},{x:.3636530644907258,y:.6041943376181453},{x:.36123724716457173,y:.6044322748568528},{x:.35885192047906295,y:.6048828346046191},{x:.35685820639902277,y:.60486357272721},{x:.354874,y:.605059},{x:.247175,y:.605059},{x:.24519066624232813,y:.6048635601834779},{x:.24319682408363533,y:.6048828119349353},{x:.24081162559758007,y:.6044322623250186},{x:.23839593550927424,y:.6041943376181453},{x:.23648785858508298,y:.6036155288111242},{x:.234528571713998,y:.6032454313367869},{x:.23227710201651716,y:.602338209770572},{x:.22995424554357097,y:.6016335789630078},{x:.2281957517789948,y:.6006936444633418},{x:.22634631449119302,y:.5999484204015954},{x:.15434931449119302,y:.5623544204015953},{x:.15177463525955168,y:.5606698034147719},{x:.14910425200363037,y:.5591414183832311},{x:.14809125527340347,y:.55825976164439},{x:.1469674919716301,y:.5575244814106152},{x:.14477093694990967,y:.5553699388664325},{x:.14245003748743465,y:.5533499553954043},{x:.07045803748743465,y:.4770619553954044},{x:.06965771196430402,y:.47602703312304784},{x:.06872232232106745,y:.47511235762423976},{x:.06696488716695402,y:.4725448695811053},{x:.06506154021654398,y:.4700836008922148},{x:.0644784960433022,y:.46891242859710086},{x:.06373952398737684,y:.46783284286481475},{x:.06251674952606694,y:.46497182979435886},{x:.06113014455468816,y:.46218652912371366},{x:.06078678779193787,y:.46092411430034236},{x:.06027263160501272,y:.4597211062088315},{x:.023981631605012717,y:.3447361062088315},{x:.0234743267656997,y:.3423269972319261},{x:.02275966238185463,y:.33997106449072584},{x:.0225676139616898,y:.3380211641581212},{x:.022163875903973694,y:.3361038771468651},{x:.022136312630974576,y:.33364208825896713},{x:.021894999999999998,y:.33119200000000004},{x:.021894999999999998,y:.25490100000000004}],[{x:.111895,y:.2618978965790472},{x:.111895,y:.324259211613835},{x:.14299436878278687,y:.42279496206129447},{x:.20271328316555492,y:.48607750096051383},{x:.25821631520114247,y:.5150589999999999},{x:.3438328207386419,y:.5150589999999999},{x:.3993370917152178,y:.4860772565752743},{x:.4590577300605173,y:.42279464888454726},{x:.490157,y:.324259211613835},{x:.490157,y:.2618978965790472},{x:.4591028039244665,y:.16445082019422033},{x:.39914727445977055,y:.10091681321598435},{x:.3435475642149213,y:.07103500000000003},{x:.2585015743575747,y:.07103500000000003},{x:.20290309936793577,y:.10091656436690524},{x:.14294929572583875,y:.164450507494742},{x:.111895,y:.2618978965790472}]],p:[[{x:.031904,y:-.15424400000000005},{x:.032768662381854635,y:-.16302306449072582},{x:.0353294210369921,y:-.17146475445642909},{x:.03948786744638546,y:-.17924466048588214},{x:.04508419484660536,y:-.18606380515339468},{x:.051903339514117915,y:-.19166013255361458},{x:.05968324554357096,y:-.19581857896300794},{x:.06812493550927423,y:-.1983793376181454},{x:.076904,y:-.19924400000000003},{x:.08568306449072577,y:-.1983793376181454},{x:.09412475445642904,y:-.19581857896300794},{x:.1019046604858821,y:-.19166013255361458},{x:.10872380515339464,y:-.18606380515339468},{x:.11432013255361453,y:-.17924466048588214},{x:.1184785789630079,y:-.17146475445642909},{x:.12103933761814537,y:-.16302306449072582},{x:.121904,y:-.15424400000000005},{x:.121904,y:.08461372659928788},{x:.12362832174470662,y:.08333438131496537},{x:.12536021772829115,y:.08178035235824195},{x:.1271620685101291,y:.08071254912256186},{x:.12884414120453105,y:.07946455014784792},{x:.13094744853162613,y:.07846927732892851},{x:.13294924262910485,y:.07728298474798974},{x:.20690724262910487,y:.04275398474798971},{x:.20784573679964677,y:.04242345923251374},{x:.20872324554357097,y:.041954421036992075},{x:.21199903754957586,y:.040960720395783044},{x:.21522783943974558,y:.03982357810698025},{x:.21621278303720604,y:.03968249467654502},{x:.21716493550927424,y:.0393936623818546},{x:.22057164546850772,y:.03905813073713887},{x:.2239602522910248,y:.038572746319036566},{x:.22495379448531613,y:.03862652673075318},{x:.225944,y:.038528999999999966},{x:.338005,y:.038528999999999966},{x:.33886621477794643,y:.03861382225207184},{x:.3397300481447032,y:.038562076501738984},{x:.34324908380057223,y:.0390454971728409},{x:.3467840644907258,y:.0393936623818546},{x:.3476121832677305,y:.039644869466491955},{x:.3484695134136621,y:.03976264352593092},{x:.35182662109175783,y:.04092330520367998},{x:.35522575445642907,y:.04195442103699206},{x:.3559889530923063,y:.042362359206810904},{x:.35680683330070073,y:.04264512708496585},{x:.4318888333007007,y:.07717412708496588},{x:.43400924312431544,y:.07841428389434572},{x:.43622962614931016,y:.07946501028796468},{x:.4378075563324746,y:.08063579029221077},{x:.43950360927818305,y:.0816277549521855},{x:.44134133343031445,y:.08325775393151234},{x:.4433140658676044,y:.08472146615145025},{x:.5183930658676044,y:.1527974661514503},{x:.519792625068414,y:.15434228537837358},{x:.5213447099268285,y:.1557337827706549},{x:.522746916505161,y:.1576032022519019},{x:.5243158963961404,y:.15933502631539204},{x:.52538718417891,y:.1611232027292085},{x:.5266379784876352,y:.1627907596241023},{x:.5276485364111687,y:.16489781566710873},{x:.5288495066792682,y:.16690245600899573},{x:.5295513540552914,y:.16886527099294393},{x:.530452790490496,y:.17074480411415546},{x:.5674347904904959,y:.2723648041141554},{x:.5682868803844835,y:.2756900562357905},{x:.5692833376181453,y:.27897493550927416},{x:.5693799285821196,y:.2799556400244087},{x:.5696245448495124,y:.2809102467717411},{x:.5698115375679212,y:.2843378395980749},{x:.570148,y:.28775399999999995},{x:.570148,y:.355831},{x:.5698183264321395,y:.3591782319067787},{x:.5696454905753794,y:.362537215959393},{x:.5693867528695432,y:.3635600718226051},{x:.5692833376181453,y:.3646100644907258},{x:.5683069860848939,y:.3678286641524751},{x:.567482165940186,y:.37108938766543825},{x:.530500165940186,y:.47369538766543823},{x:.5295747233109523,y:.4756403735939819},{x:.5288495066792682,y:.4776685439910043},{x:.5276841925618525,y:.47961366765708685},{x:.5267099630491849,y:.4816611880905031},{x:.5254228546094585,y:.48338825675926556},{x:.5243158963961404,y:.48523597368460797},{x:.5227934986603558,y:.48691638083844907},{x:.5214385372739072,y:.48873449599152474},{x:.5198392258792078,y:.49017727712011666},{x:.5183930658676044,y:.4917735338485497},{x:.4433140658676044,y:.5598495338485497},{x:.44114571117720175,y:.5614583923016819},{x:.43910641435493325,y:.5632279843609703},{x:.43761161896162687,y:.5640805897495177},{x:.43622962614931016,y:.5651059897120353},{x:.43378906307257026,y:.5662609093863238},{x:.43144372048223223,y:.5675986521566495},{x:.35636172048223225,y:.6011446521566495},{x:.355773047491519,y:.6013410447411239},{x:.35522575445642907,y:.6016335789630078},{x:.3515938477815883,y:.6027353058079922},{x:.3479935881359665,y:.6039364213810477},{x:.34737791203915763,y:.6040141959337602},{x:.3467840644907258,y:.6041943376181453},{x:.34300700763927916,y:.6045663452480041},{x:.3392415999493003,y:.6050420059085138},{x:.33862258083352115,y:.60499817359702},{x:.338005,y:.605059},{x:.225944,y:.605059},{x:.2251997336627212,y:.6049856961639699},{x:.22445344765540867,y:.6050343071552383},{x:.22081614914993766,y:.6045539507735711},{x:.21716493550927424,y:.6041943376181453},{x:.21644927090994795,y:.6039772431353645},{x:.21570784104506457,y:.6038793269025836},{x:.2122341450916469,y:.6026985986973952},{x:.20872324554357097,y:.6016335789630078},{x:.20806368527139987,y:.6012810366527016},{x:.20735560428285457,y:.6010403560617851},{x:.13339760428285458,y:.5674943560617851},{x:.13116986982932302,y:.566206971138138},{x:.12884414120453105,y:.5651064498521521},{x:.1273598902040749,y:.5640052229355318},{x:.12575970914356202,y:.5630804946901414},{x:.12382593632220404,y:.5613832370749092},{x:.121904,y:.5599572734007121},{x:.121904,y:.560059},{x:.12103933761814537,y:.5688380644907257},{x:.1184785789630079,y:.577279754456429},{x:.11432013255361453,y:.5850596604858821},{x:.10872380515339464,y:.5918788051533946},{x:.10190466048588208,y:.5974751325536145},{x:.09412475445642904,y:.6016335789630078},{x:.08568306449072577,y:.6041943376181453},{x:.076904,y:.605059},{x:.0681249355092742,y:.6041943376181453},{x:.059683245543570934,y:.6016335789630078},{x:.051903339514117915,y:.5974751325536145},{x:.04508419484660536,y:.5918788051533946},{x:.03948786744638546,y:.5850596604858821},{x:.0353294210369921,y:.577279754456429},{x:.032768662381854635,y:.5688380644907257},{x:.031904,y:.560059},{x:.031904,y:-.15424400000000005}],[{x:.121904,y:.20607608160839302},{x:.121904,y:.438494918391607},{x:.17699192809119763,y:.48844251958412144},{x:.23567259519301437,y:.5150589999999999},{x:.3284092961747297,y:.5150589999999999},{x:.38817711429028284,y:.4883552464171925},{x:.4496333594179428,y:.43263133769024387},{x:.48014799999999996,y:.3479689286382035},{x:.48014799999999996,y:.29568777567179994},{x:.44968806913177495,y:.21198926897045803},{x:.3879916447872207,y:.1560475837631447},{x:.32815352882369925,y:.12852899999999995},{x:.2359312215606538,y:.12852899999999995},{x:.17717907548697515,y:.15595879598931894},{x:.121904,y:.20607608160839302}]],q:[[{x:.031905,y:.285813},{x:.03224141038262204,y:.2823973680650777},{x:.0324282929389951,y:.2789703010434802},{x:.03267301908894614,y:.2780151713289937},{x:.032769662381854636,y:.2770339355092742},{x:.03376596546737772,y:.2737495643941025},{x:.03461784473664685,y:.27042480648246636},{x:.07159784473664685,y:.1688028064824664},{x:.0724995244823713,y:.166922651750872},{x:.0732016076706368,y:.1649592141085361},{x:.07440224792307432,y:.1629551516523985},{x:.07541246819615938,y:.16084867156853302},{x:.07666362241043057,y:.15918055247485355},{x:.0777352629490018,y:.15739181137154173},{x:.07930380642556048,y:.15566048970702676},{x:.08070556947724908,y:.15379156924569237},{x:.08225811700526783,y:.15239959067120604},{x:.08365813234923056,y:.15085428642438087},{x:.15873913234923054,y:.08277728642438094},{x:.16071062555900373,y:.0813145118522212},{x:.16254708404197357,y:.07968542770293169},{x:.16424441690754124,y:.07869257021816739},{x:.16582360332185575,y:.07752087268448676},{x:.16804258800473576,y:.07647082416071167},{x:.17016157800418052,y:.07523131768336211},{x:.24523757800418056,y:.0406993176833621},{x:.24605678866737324,y:.04041603175027397},{x:.24682124554357093,y:.04000742103699214},{x:.2502190216384501,y:.03897671692697023},{x:.2535747153580455,y:.03781630621794852},{x:.25443345146196317,y:.037698283616711674},{x:.2552629355092742,y:.03744666238185468},{x:.25879650468596477,y:.037098636194782805},{x:.2623141045905799,y:.03661518582049534},{x:.2631793653883337,y:.03666696209348752},{x:.264042,y:.036582000000000045},{x:.376106,y:.036582000000000045},{x:.3770966034546813,y:.036679565924422064},{x:.37809054588497415,y:.03662578154659327},{x:.38147875036256007,y:.037111169723096304},{x:.3848850644907258,y:.03744666238185468},{x:.3858375996101805,y:.03773561075136079},{x:.38682293652697,y:.03787676837406198},{x:.39005134306992567,y:.03901383585544661},{x:.39332675445642906,y:.04000742103699214},{x:.39420461585020444,y:.04047664772778637},{x:.3951434813083616,y:.04080732274273922},{x:.4691044813083616,y:.07533932274273922},{x:.47110618065167786,y:.07652560719175487},{x:.47320939667814427,y:.07752087268448679},{x:.4748915208069018,y:.0787689461703934},{x:.4766934263594154,y:.07983682509171056},{x:.47842523099597173,y:.08139082758714347},{x:.48014799999999996,y:.08266905805748193},{x:.48014799999999996,y:-.15619500000000008},{x:.4810126623818546,y:-.16497406449072585},{x:.483573421036992,y:-.17341575445642912},{x:.4877318674463854,y:-.18119566048588218},{x:.4933281948466053,y:-.18801480515339472},{x:.5001473395141178,y:-.19361113255361462},{x:.5079272455435709,y:-.19776957896300798},{x:.5163689355092742,y:-.20033033761814545},{x:.525148,y:-.20119500000000007},{x:.5339270644907257,y:-.20033033761814545},{x:.542368754456429,y:-.19776957896300798},{x:.5501486604858821,y:-.19361113255361462},{x:.5569678051533946,y:-.18801480515339472},{x:.5625641325536145,y:-.18119566048588218},{x:.5667225789630078,y:-.17341575445642912},{x:.5692833376181453,y:-.16497406449072585},{x:.570148,y:-.15619500000000008},{x:.570148,y:.5581050000000001},{x:.5692833376181453,y:.5668840644907258},{x:.5667225789630078,y:.5753257544564291},{x:.5625641325536145,y:.5831056604858822},{x:.5569678051533946,y:.5899248051533947},{x:.5501486604858821,y:.5955211325536146},{x:.542368754456429,y:.5996795789630079},{x:.5339270644907257,y:.6022403376181454},{x:.525148,y:.6031050000000001},{x:.5163689355092742,y:.6022403376181454},{x:.5079272455435709,y:.5996795789630079},{x:.5001473395141178,y:.5955211325536146},{x:.4933281948466053,y:.5899248051533947},{x:.4877318674463854,y:.5831056604858822},{x:.483573421036992,y:.5753257544564291},{x:.4810126623818546,y:.5668840644907258},{x:.48014799999999996,y:.5581050000000001},{x:.48014799999999996,y:.558005596763998},{x:.4782247267606458,y:.559432223348863},{x:.47629232280480055,y:.5611281889595863},{x:.4746904859851039,y:.5620538174856352},{x:.4732046002880372,y:.5631560030691136},{x:.4708804506539088,y:.5642554633364756},{x:.4686543108210992,y:.5655418481335316},{x:.3946933108210992,y:.5990868481335316},{x:.3939857884552202,y:.5993273179516839},{x:.39332675445642906,y:.5996795789630079},{x:.3898152875083263,y:.6007447708163117},{x:.38634099890642704,y:.6019255978665906},{x:.3856001580501581,y:.6020234163584227},{x:.3848850644907258,y:.6022403376181454},{x:.38123326077373504,y:.6026000088910167},{x:.3775953617236344,y:.6030803465985108},{x:.3768496724756141,y:.6030317546542387},{x:.376106,y:.6031050000000001},{x:.264042,y:.6031050000000001},{x:.26342400033164626,y:.6030441323453897},{x:.26280456058717394,y:.6030879828235033},{x:.25903957642572706,y:.602612304281983},{x:.2552629355092742,y:.6022403376181454},{x:.254668685221597,y:.6020600737641458},{x:.25405259303422617,y:.6019822349683996},{x:.25045275226756825,y:.6007811844842303},{x:.24682124554357093,y:.5996795789630079},{x:.24627358134186672,y:.5993868463484354},{x:.24568451278884912,y:.5991903095800973},{x:.17060851278884911,y:.5656453095800973},{x:.16826609518471405,y:.5643091772352096},{x:.16582839971196278,y:.5631560030691136},{x:.1644435861855132,y:.5621287897998347},{x:.16294590048199914,y:.5612744987855388},{x:.1609091582647261,y:.559507056844315},{x:.15874327554635076,y:.5579004698017108},{x:.08366227554635075,y:.4898404698017108},{x:.0822135909199537,y:.48824184486316324},{x:.08061175169940471,y:.4867967151276658},{x:.07925889408089541,y:.48498133393711457},{x:.07773859373239328,y:.48330368097737925},{x:.0766296214289207,y:.4814531488185024},{x:.0753404919252871,y:.4797232835162987},{x:.07436779238761855,y:.4776788549378484},{x:.07320399804016177,y:.47573684172476444},{x:.07247735524331753,y:.47370551725863386},{x:.07155047598047157,y:.4717573941431678},{x:.034570475980471575,y:.3691493941431678},{x:.03374586128764337,y:.36588916100716024},{x:.032769662381854636,y:.3626710644907258},{x:.032666195333495754,y:.36162054591923504},{x:.032407352052251925,y:.36059717166956007},{x:.03223462203187315,y:.35723870865311785},{x:.031905,y:.353892},{x:.031905,y:.285813}],[{x:.121905,y:.2937462257558374},{x:.121905,y:.3460304727958324},{x:.1524170009298456,y:.4306917867874386},{x:.21387346155335435,y:.48640130996954867},{x:.2736381428091649,y:.513105},{x:.36637802828147564,y:.513105},{x:.4250638403772601,y:.4864880590885319},{x:.48014799999999996,y:.4365549481293854},{x:.48014799999999996,y:.20413270643748072},{x:.4248733312055972,y:.15401438585682045},{x:.36611835928516706,y:.12658200000000003},{x:.27389496414813935,y:.12658200000000003},{x:.2140623112166411,y:.15410266134357853},{x:.15236330162501277,y:.21004602219345103},{x:.121905,y:.2937462257558374}]],r:[[{x:.062422000000000005,y:.03920400000000002},{x:.06328666238185464,y:.030424935509274227},{x:.0658474210369921,y:.02198324554357097},{x:.07000586744638546,y:.01420333951411792},{x:.07560219484660537,y:.00738419484660538},{x:.08242133951411793,y:.0017878674463854757},{x:.09020124554357097,y:-.002370578963007887},{x:.09864293550927423,y:-.004931337618145348},{x:.107422,y:-.005795999999999982},{x:.11620106449072577,y:-.004931337618145348},{x:.12464275445642904,y:-.002370578963007887},{x:.1324226604858821,y:.0017878674463854827},{x:.13924180515339463,y:.00738419484660538},{x:.14483813255361455,y:.01420333951411792},{x:.14899657896300791,y:.02198324554357098},{x:.15155733761814538,y:.030424935509274248},{x:.152422,y:.03920400000000002},{x:.152422,y:.3275398012121413},{x:.1925108808296549,y:.4204278633799401},{x:.27478075869941443,y:.4836647262821032},{x:.3576648607132649,y:.5150589999999999},{x:.49463,y:.5150589999999999},{x:.5034090644907258,y:.5159236623818546},{x:.511850754456429,y:.5184844210369921},{x:.5196306604858821,y:.5226428674463854},{x:.5264498051533947,y:.5282391948466053},{x:.5320461325536145,y:.5350583395141179},{x:.5362045789630079,y:.542838245543571},{x:.5387653376181454,y:.5512799355092742},{x:.53963,y:.560059},{x:.5387653376181454,y:.5688380644907257},{x:.5362045789630079,y:.577279754456429},{x:.5320461325536145,y:.5850596604858821},{x:.5264498051533947,y:.5918788051533946},{x:.5196306604858821,y:.5974751325536145},{x:.511850754456429,y:.6016335789630078},{x:.5034090644907258,y:.6041943376181453},{x:.49463,y:.605059},{x:.349428,y:.605059},{x:.34572095329292224,y:.6046938877675093},{x:.3420044651532413,y:.6044424555930356},{x:.34133700376168824,y:.6042621064259311},{x:.3406489355092742,y:.6041943376181453},{x:.33708434852821606,y:.6031130319790114},{x:.33348832364990477,y:.6021413801353276},{x:.23668632364990477,y:.5654753801353276},{x:.2347311434313091,y:.5645060813254815},{x:.23268939209293205,y:.5637356779621759},{x:.23078888495220712,y:.562551669954317},{x:.22878273496962892,y:.5615571024090896},{x:.2270542238076375,y:.5602249916656349},{x:.22520200238894322,y:.5590710654608507},{x:.152422,y:.5031286093364514},{x:.152422,y:.560059},{x:.15155733761814538,y:.5688380644907257},{x:.14899657896300791,y:.577279754456429},{x:.14483813255361455,y:.5850596604858821},{x:.13924180515339463,y:.5918788051533946},{x:.1324226604858821,y:.5974751325536145},{x:.12464275445642904,y:.6016335789630078},{x:.11620106449072577,y:.6041943376181453},{x:.107422,y:.605059},{x:.09864293550927423,y:.6041943376181453},{x:.09020124554357094,y:.6016335789630078},{x:.08242133951411793,y:.5974751325536145},{x:.07560219484660537,y:.5918788051533946},{x:.07000586744638546,y:.5850596604858821},{x:.0658474210369921,y:.577279754456429},{x:.06328666238185464,y:.5688380644907257},{x:.062422000000000005,y:.560059},{x:.062422000000000005,y:.03920400000000002}]],s:[[{x:.056563,y:.369888},{x:.056809270227573656,y:.3673875764180495},{x:.05684306423764694,y:.36487528163458033},{x:.05724057756471223,y:.36300843953465567},{x:.057427662381854636,y:.3611089355092742},{x:.05815700903783985,y:.3587046018033244},{x:.05868027810379197,y:.35624717294397146},{x:.05943435615016931,y:.3544937526945111},{x:.0599884210369921,y:.352667245543571},{x:.06117281573842168,y:.3504513989095756},{x:.06216545092350078,y:.34814327358726177},{x:.06324711489275962,y:.3465706581451233},{x:.06414686744638545,y:.3448873395141179},{x:.06574079456909979,y:.3429451336955602},{x:.0671646494598194,y:.3408750118720105},{x:.06853233161222538,y:.3395436359667022},{x:.06974319484660536,y:.33806819484660533},{x:.07168540066516299,y:.33647426772389105},{x:.07348575731657993,y:.3347217030198468},{x:.07508689839402109,y:.33368273068076537},{x:.07656233951411792,y:.33247186744638546},{x:.07877818614811302,y:.331287472744956},{x:.08088585786376518,y:.3299198152391437},{x:.15568385786376518,y:.29122381523914376},{x:.1574569269125657,y:.29051717359061785},{x:.15914024554357095,y:.2896174210369921},{x:.16154457924952065,y:.28888807438100694},{x:.16387856938737105,y:.2879578823843842},{x:.16575542835833412,y:.2876107272686775},{x:.16758193550927422,y:.2870566623818547},{x:.17008235909122482,y:.286810392154281},{x:.17255297371919248,y:.2863534124236203},{x:.17446149597461844,y:.28637908481714247},{x:.176361,y:.28619200000000006},{x:.288347309340128,y:.28619200000000006},{x:.3974525128623667,y:.21942256309828728},{x:.45549,y:.1602321160680505},{x:.45549,y:.13007078589845048},{x:.407404042616179,y:.10590438131127383},{x:.31753214348357883,y:.07103500000000003},{x:.21224543978224936,y:.07103500000000003},{x:.16354378174687056,y:.09622932957230687},{x:.14433666195924297,y:.15500005013212306},{x:.1407876006468136,y:.16307617408904287},{x:.13573115992893667,y:.17030473007440486},{x:.12936165598671553,y:.1764079287355125},{x:.12192386528459082,y:.18115122757053267},{x:.11370361794808405,y:.18435234426530817},{x:.10501681347236942,y:.18588826170046568},{x:.09619728088183255,y:.18569995543032455},{x:.08758394986787689,y:.1837946619592429},{x:.07950782591095708,y:.18024560064681355},{x:.07227926992559508,y:.1751891599289366},{x:.06617607126448745,y:.1688196559867155},{x:.06143277242946728,y:.16138186528459075},{x:.05823165573469179,y:.153161617948084},{x:.05669573829953427,y:.14447481347236937},{x:.0568840445696754,y:.1356552808818325},{x:.05878933804075704,y:.12704194986787684},{x:.08372233804075704,y:.050750949867876836},{x:.08542587043333498,y:.04687444913825993},{x:.08709879890390285,y:.042984643121031924},{x:.08719974017890864,y:.04283789110571456},{x:.0872713993531864,y:.04267482591095703},{x:.0896984666241539,y:.03920515373890898},{x:.0920981137517354,y:.03571646140762123},{x:.09222574536637099,y:.03559222185697407},{x:.09232784007106334,y:.035446269925595034},{x:.09538517138631239,y:.032516763866873036},{x:.0984193200775319,y:.02956325371133576},{x:.09856873722042347,y:.029466301081615798},{x:.09869734401328446,y:.029343071264487396},{x:.10226744784494098,y:.027066310594042624},{x:.10581949746716537,y:.024761484353185106},{x:.18061849746716538,y:-.013933515646814817},{x:.1823912439162618,y:-.014639995851387814},{x:.18407424554357094,y:-.01553957896300786},{x:.18647892276401756,y:-.016269029822976466},{x:.18881326125361947,y:-.017199317363260178},{x:.19068977232738848,y:-.017546377073194466},{x:.1925159355092742,y:-.018100337618145335},{x:.19501671633437545,y:-.018346643031098245},{x:.19748769126025723,y:-.018803648509519946},{x:.19939585369049342,y:-.018777950414796084},{x:.201295,y:-.018964999999999968},{x:.325956,y:-.018964999999999968},{x:.3298421413721484,y:-.018582248482612737},{x:.33373593654739714,y:-.01828737118339306},{x:.334227355251249,y:-.018150342613638803},{x:.3347350644907258,y:-.018100337618145335},{x:.33847186362931597,y:-.016966791992147238},{x:.34223331291484477,y:-.015917938922943478},{x:.44196531291484475,y:.022777061077056446},{x:.44388622686678575,y:.02374867869889352},{x:.4458951331158935,y:.02452214291663178},{x:.5206971331158935,y:.06211514291663188},{x:.5230429253028388,y:.06359852573319036},{x:.5254906604858821,y:.06490686744638552},{x:.526762463529903,y:.06595060923072474},{x:.5281530225051898,y:.06682994172267823},{x:.5301643473216751,y:.06874246310749585},{x:.5323098051533947,y:.07050319484660542},{x:.5333535469377338,y:.07177499789062616},{x:.5345458374532134,y:.07290871885358566},{x:.536145400814505,y:.07517688168239829},{x:.5379061325536145,y:.07732233951411796},{x:.538681702666837,y:.0787733291400739},{x:.5396299056666436,y:.08011787031323085},{x:.5407562372498129,y:.08265451036052812},{x:.5420645789630079,y:.08510224554357101},{x:.5425421726806072,y:.08667666103386074},{x:.5432098492552168,y:.08818035245395842},{x:.5438196647691762,y:.09088798806528645},{x:.5446253376181454,y:.09354393550927428},{x:.5447866012813922,y:.09518127295954937},{x:.5451480929944793,y:.09678632860859225},{x:.545217957571016,y:.09956090686586556},{x:.54549,y:.10232300000000005},{x:.54549,y:.17861300000000002},{x:.5450792542455133,y:.1827833716312913},{x:.5447095428008049,y:.18695758114513777},{x:.5446471218945653,y:.18717088502046353},{x:.5446253376181454,y:.1873920644907258},{x:.5434088850836819,y:.19140217107899518},{x:.5422319296624953,y:.19542404720269643},{x:.5421290946347417,y:.1956210747891699},{x:.5420645789630079,y:.19583375445642906},{x:.5400891672372728,y:.199529489854385},{x:.5381501975764,y:.20324447414399938},{x:.5380109003195782,y:.20341765378196683},{x:.5379061325536145,y:.20361366048588211},{x:.5352476756014034,y:.20685299965477524},{x:.5326212052175259,y:.21011832734743824},{x:.45781920521752584,y:.28640632734743826},{x:.45695946559173245,y:.28712616331644525},{x:.45621413415776596,y:.2879638966272176},{x:.45358375241990234,y:.28995255364350675},{x:.45105542866152953,y:.29206944848930627},{x:.4500717756605794,y:.29260772613156716},{x:.4491773318997613,y:.2932839556822147},{x:.3245133318997613,y:.3695749556822147},{x:.3213472249094816,y:.3711082739568931},{x:.3182447544564291,y:.37276657896300797},{x:.31738368821196916,y:.37302778055263114},{x:.3165738477898179,y:.3734199792757539},{x:.31316944110160955,y:.3743061584374605},{x:.3098030644907258,y:.3753273376181454},{x:.3089075854904768,y:.3754155346015568},{x:.3080367917497669,y:.3756422053074494},{x:.30452491480344407,y:.37584718998797495},{x:.301024,y:.376192},{x:.18731182116617404,y:.376192},{x:.146563,y:.397272996602132},{x:.146563,y:.42779681790574337},{x:.20153437253410483,y:.48386323770148376},{x:.2842918489876165,y:.5150589999999999},{x:.39008456648169626,y:.5150589999999999},{x:.4553477907191711,y:.4822576837794137},{x:.4635801440629335,y:.47908783003036465},{x:.47227272283422006,y:.4775849365970516},{x:.4810914761057044,y:.47780675883128426},{x:.48969750413477736,y:.47974477222900047},{x:.4977600820905977,y:.48332450002217653},{x:.5049693696238691,y:.488408375279255},{x:.5110483178577028,y:.4948010275251766},{x:.5157633162205862,y:.5022567907191711},{x:.5189331699696352,y:.5104891440629334},{x:.5204360634029483,y:.51918172283422},{x:.5202142411687157,y:.5280004761057044},{x:.5182762277709995,y:.5366065041347774},{x:.5146964999778234,y:.5446690820905977},{x:.509612624720745,y:.551878369623869},{x:.5032199724748234,y:.5579573178577029},{x:.49576420928082887,y:.5626723162205862},{x:.42096520928082887,y:.6002663162205862},{x:.41942927464851043,y:.6008577252562829},{x:.41797775445642904,y:.6016335789630078},{x:.4153223812886681,y:.6024390776071881},{x:.41273285593706643,y:.6034361699696352},{x:.41111105567880996,y:.6037165692645292},{x:.40953606449072577,y:.6041943376181453},{x:.40677456858393113,y:.6044663212253706},{x:.4040402771657799,y:.6049390634029483},{x:.4023949361559939,y:.6048976773693867},{x:.400757,y:.605059},{x:.276092,y:.605059},{x:.2724204350331364,y:.6046973824138966},{x:.26873912724910987,y:.6044542166602351},{x:.2680367190736708,y:.6042656240771296},{x:.2673129355092742,y:.6041943376181453},{x:.2637824667250502,y:.6031233816208718},{x:.26021933352302795,y:.6021667007079561},{x:.1604883335230279,y:.5645727007079561},{x:.15963695838633216,y:.5641523105976027},{x:.15873109713512196,y:.563867735718488},{x:.15568848233041307,y:.5622026409240001},{x:.1525785174681621,y:.5606670094317409},{x:.15182551530799093,y:.5600886019499048},{x:.15099257773152036,y:.559632770334096},{x:.14833326979676884,y:.5574060851671644},{x:.1455826488796249,y:.5552932363569977},{x:.14495695714670492,y:.554579039378831},{x:.14422895256892138,y:.5539694683796904},{x:.06943095256892137,y:.47768146837969044},{x:.06680494464711424,y:.4744165369262552},{x:.06414686744638545,y:.4711776604858821},{x:.0640418150384659,y:.470981121254323},{x:.0639021439692389,y:.47080746737336276},{x:.06196355058191934,y:.4670929619312254},{x:.0599884210369921,y:.46339775445642906},{x:.05992373008360734,y:.46318449696300446},{x:.05982062094636722,y:.462986931318802},{x:.05864394115023422,y:.4589655982489849},{x:.057427662381854636,y:.45495606449072584},{x:.05740581892006417,y:.454734284101312},{x:.05734323414113077,y:.4545203990307778},{x:.05697368708086039,y:.4503467759079653},{x:.056563,y:.44617700000000005},{x:.056563,y:.369888}]],t:[[{x:.036055000000000004,y:.484201},{x:.03691966238185464,y:.4754219355092742},{x:.0394804210369921,y:.466980245543571},{x:.04363886744638546,y:.4592003395141179},{x:.049235194846605365,y:.45238119484660533},{x:.05605433951411792,y:.44678486744638546},{x:.06383424554357096,y:.44262642103699207},{x:.07227593550927423,y:.4400656623818546},{x:.081055,y:.439201},{x:.201032,y:.439201},{x:.201032,y:.17345100000000002},{x:.2013458215844704,y:.17026471598156256},{x:.20148726326025637,y:.1670661406603643},{x:.20177732050748418,y:.165883633894134},{x:.20189666238185464,y:.16467193550927425},{x:.20282606714776777,y:.16160809859877695},{x:.20358880215081968,y:.15849857690755997},{x:.20410398165518515,y:.15739537903902878},{x:.2044574210369921,y:.15623024554357098},{x:.20596669248041014,y:.15340659727526443},{x:.20732140933230742,y:.15050562638878262},{x:.2623124093323074,y:.05773162638878261},{x:.2645408071528226,y:.05469603003381387},{x:.2666808493837164,y:.051597510818645845},{x:.2671477670132535,y:.051144744093296994},{x:.26753264280400524,y:.05062045370997057},{x:.2703104380556505,y:.04807792433615628},{x:.27301385108661325,y:.04545644382682572},{x:.2735601274310704,y:.04510346799784869},{x:.2740398919211364,y:.04466433724917905},{x:.27726033549019774,y:.04271258283448707},{x:.28042322867453984,y:.040668883056825214},{x:.28102787064035484,y:.04042926278737637},{x:.28158408674943697,y:.04009216722176761},{x:.28512341879560005,y:.038806192593798694},{x:.288624243922019,y:.03741881178414046},{x:.39861224392201905,y:.005893811784140432},{x:.4004470188387682,y:.005558110934368086},{x:.4022319355092743,y:.0050166623818546086},{x:.4047755505163489,y:.004766138170207483},{x:.4072897364122725,y:.0043061284251197166},{x:.4091547486303562,y:.0043348248023798485},{x:.411011,y:.004151999999999975},{x:.520997,y:.004151999999999975},{x:.5297760644907258,y:.0050166623818546086},{x:.538217754456429,y:.00757742103699207},{x:.5459976604858822,y:.011735867446385433},{x:.5528168051533947,y:.017332194846605337},{x:.5584131325536146,y:.02415133951411788},{x:.5625715789630079,y:.031931245543570935},{x:.5651323376181454,y:.040372935509274205},{x:.5659970000000001,y:.049151999999999973},{x:.5651323376181454,y:.05793106449072574},{x:.5625715789630079,y:.06637275445642901},{x:.5584131325536146,y:.07415266048588207},{x:.5528168051533947,y:.08097180515339461},{x:.5459976604858822,y:.08656813255361451},{x:.538217754456429,y:.09072657896300787},{x:.5297760644907258,y:.09328733761814534},{x:.520997,y:.09415199999999997},{x:.41733272532416527,y:.09415199999999997},{x:.33061421916568134,y:.11900744701827656},{x:.291032,y:.1857856616511605},{x:.291032,y:.439201},{x:.466004,y:.439201},{x:.47478306449072577,y:.4400656623818546},{x:.48322475445642904,y:.44262642103699207},{x:.4910046604858821,y:.44678486744638546},{x:.49782380515339464,y:.45238119484660533},{x:.5034201325536145,y:.4592003395141179},{x:.5075785789630078,y:.466980245543571},{x:.5101393376181453,y:.4754219355092742},{x:.511004,y:.484201},{x:.5101393376181453,y:.4929800644907258},{x:.5075785789630078,y:.501421754456429},{x:.5034201325536145,y:.5092016604858821},{x:.49782380515339464,y:.5160208051533947},{x:.4910046604858821,y:.5216171325536145},{x:.48322475445642904,y:.5257755789630079},{x:.47478306449072577,y:.5283363376181454},{x:.466004,y:.529201},{x:.291032,y:.529201},{x:.291032,y:.702148},{x:.2901673376181454,y:.7109270644907257},{x:.2876065789630079,y:.719368754456429},{x:.28344813255361456,y:.7271486604858821},{x:.27785180515339464,y:.7339678051533947},{x:.2710326604858821,y:.7395641325536145},{x:.26325275445642904,y:.7437225789630079},{x:.25481106449072577,y:.7462833376181454},{x:.246032,y:.747148},{x:.23725293550927423,y:.7462833376181454},{x:.22881124554357096,y:.7437225789630079},{x:.2210313395141179,y:.7395641325536145},{x:.21421219484660536,y:.7339678051533947},{x:.20861586744638547,y:.7271486604858821},{x:.2044574210369921,y:.719368754456429},{x:.20189666238185464,y:.7109270644907257},{x:.201032,y:.702148},{x:.201032,y:.529201},{x:.081055,y:.529201},{x:.07227593550927423,y:.5283363376181454},{x:.06383424554357094,y:.5257755789630079},{x:.05605433951411792,y:.5216171325536145},{x:.049235194846605365,y:.5160208051533947},{x:.04363886744638546,y:.5092016604858821},{x:.0394804210369921,y:.501421754456429},{x:.03691966238185464,y:.4929800644907258},{x:.036055000000000004,y:.484201}]],u:[[{x:.047041,y:.17386599999999997},{x:.04733731084809023,y:.17085750547164297},{x:.04744678100255899,y:.1678364368310572},{x:.0477687404511641,y:.16647712720137547},{x:.04790566238185463,y:.1650869355092742},{x:.048783207866406234,y:.16219405573845885},{x:.04947995583647738,y:.15925239265237093},{x:.08761895583647737,y:.04817539265237096},{x:.08938287590080696,y:.04431825367483454},{x:.09111755940033861,y:.04044787795123246},{x:.0912166047918106,y:.04030846472648272},{x:.0912877277290914,y:.04015294120864865},{x:.09377024504918263,y:.03671403980837168},{x:.09622666993792225,y:.03325645223155292},{x:.09635101037087945,y:.03313904059014135},{x:.09645110783403886,y:.03300038080982997},{x:.09955682066149267,y:.030111872039067004},{x:.10264058790854466,y:.027199945760571206},{x:.10278544504987946,y:.027109047766032002},{x:.10291067034954356,y:.026992580340839414},{x:.10652022788210418,y:.024765467971757132},{x:.11011283004156149,y:.02251110668543916},{x:.1858688300415615,y:-.015231893314560811},{x:.1873332068933575,y:-.0157898639141544},{x:.18871524554357097,y:-.01652857896300789},{x:.19144581156206075,y:-.017356887109087667},{x:.19411224226228255,y:-.018372875537717062},{x:.1956573361874375,y:-.018634439137126358},{x:.19715693550927424,y:-.019089337618145352},{x:.1999966293703256,y:-.019369023051625026},{x:.20281003486202434,y:-.01984529472354478},{x:.2043764687674932,y:-.01980039958033106},{x:.205936,y:-.019953999999999986},{x:.319832,y:-.019953999999999986},{x:.32132997950952447,y:-.01980646189590665},{x:.3228344649392302,y:-.019853723877644197},{x:.3257100002545037,y:-.019375067506000147},{x:.3286110644907258,y:-.019089337618145352},{x:.3300514774877758,y:-.018652393112465325},{x:.33153627500704863,y:-.018405236421526333},{x:.3342631764918695,y:-.017374788187221168},{x:.33705275445642907,y:-.01652857896300789},{x:.3383802466773209,y:-.015819019588053155},{x:.3397882963501792,y:-.015286942317463331},{x:.4160692963501792,y:.02245605768253664},{x:.4183042276197719,y:.02384992521458428},{x:.42064256487504254,y:.025062345668598177},{x:.4220380841989542,y:.02617863282445781},{x:.4235544084161923,y:.027124324140885128},{x:.42547446604244665,y:.028927422360218155},{x:.42753134130624215,y:.03057273346328787},{x:.465011,y:.06712410441560081},{x:.465011,y:.025046000000000013},{x:.4658756623818546,y:.016266935509274223},{x:.46843642103699207,y:.007825245543570968},{x:.47259486744638546,y:45339514117916785e-21},{x:.4781911948466053,y:-.006773805153394624},{x:.4850103395141179,y:-.012370132553614528},{x:.492790245543571,y:-.01652857896300789},{x:.5012319355092743,y:-.019089337618145352},{x:.510011,y:-.019953999999999986},{x:.5187900644907257,y:-.019089337618145352},{x:.527231754456429,y:-.01652857896300789},{x:.5350116604858821,y:-.012370132553614521},{x:.5418308051533947,y:-.006773805153394624},{x:.5474271325536145,y:45339514117916785e-21},{x:.5515855789630079,y:.007825245543570974},{x:.5541463376181454,y:.016266935509274244},{x:.555011,y:.025046000000000013},{x:.555011,y:.545898},{x:.5541463376181454,y:.5546770644907257},{x:.5515855789630079,y:.563118754456429},{x:.5474271325536145,y:.5708986604858821},{x:.5418308051533947,y:.5777178051533947},{x:.5350116604858821,y:.5833141325536145},{x:.527231754456429,y:.5874725789630079},{x:.5187900644907257,y:.5900333376181454},{x:.510011,y:.590898},{x:.5012319355092743,y:.5900333376181454},{x:.492790245543571,y:.5874725789630079},{x:.4850103395141179,y:.5833141325536145},{x:.4781911948466053,y:.5777178051533947},{x:.47259486744638546,y:.5708986604858821},{x:.46843642103699207,y:.563118754456429},{x:.4658756623818546,y:.5546770644907257},{x:.465011,y:.545898},{x:.465011,y:.19283699530520199},{x:.36978450462305706,y:.099969048308901},{x:.30930812362389754,y:.07004600000000001},{x:.2165251763155874,y:.07004600000000001},{x:.16675256431883717,y:.09484360935890679},{x:.137041,y:.18137632992954258},{x:.137041,y:.545898},{x:.13617633761814535,y:.5546770644907257},{x:.1336155789630079,y:.563118754456429},{x:.12945713255361452,y:.5708986604858821},{x:.12386080515339463,y:.5777178051533947},{x:.11704166048588208,y:.5833141325536145},{x:.10926175445642904,y:.5874725789630079},{x:.10082006449072577,y:.5900333376181454},{x:.092041,y:.590898},{x:.08326193550927423,y:.5900333376181454},{x:.07482024554357093,y:.5874725789630079},{x:.06704033951411792,y:.5833141325536145},{x:.06022119484660536,y:.5777178051533947},{x:.05462486744638546,y:.5708986604858821},{x:.050466421036992094,y:.563118754456429},{x:.04790566238185463,y:.5546770644907257},{x:.047041,y:.545898},{x:.047041,y:.17386599999999997}]],v:[[{x:.003930906419490336,y:.5438334563092145},{x:.005386967221411215,y:.5351329102741644},{x:.00851244255100142,y:.5268836061622384},{x:.26071044255100145,y:.018289606162238365},{x:.26144011887972296,y:.017121905714788027},{x:.2620056398700735,y:.01586646241095203},{x:.26377267234206975,y:.013389122267562115},{x:.26538522214413157,y:.010808560104194675},{x:.26632868500311185,y:.009805649483352854},{x:.267128264504625,y:.008684656842684199},{x:.2693446490294707,y:.006599649029470163},{x:.2714296568426842,y:.00438326450462502},{x:.27255064948335267,y:.0035836850031119977},{x:.2735535601041947,y:.0026402221441315446},{x:.27613412226756273,y:.0010276723420693272},{x:.278611462410952,y:-.0007393601299264599},{x:.2798669057147878,y:-.0013048811202769175},{x:.28103460616223835,y:-.0020345574489985807},{x:.28388017640738666,y:-.0031126798553442526},{x:.2866546460885495,y:-.00436245420755494},{x:.28799629407344673,y:-.00467218403223142},{x:.2892839102741644,y:-.005160032778588779},{x:.2922851349323858,y:-.00566229614975999},{x:.29525011283741587,y:-.006346784254711718},{x:.2966264067237199,y:-.006388820170250395},{x:.2979844563092145,y:-.006616093580509658},{x:.301026,y:-.00652319621682493},{x:.30406754369078554,y:-.006616093580509658},{x:.3054255932762801,y:-.006388820170250395},{x:.30680188716258416,y:-.006346784254711718},{x:.30976686506761425,y:-.005662296149759988},{x:.31276808972583564,y:-.005160032778588779},{x:.3140557059265533,y:-.00467218403223142},{x:.3153973539114505,y:-.00436245420755494},{x:.3181718235926135,y:-.0031126798553442175},{x:.3210173938377617,y:-.0020345574489985807},{x:.32218509428521225,y:-.0013048811202769192},{x:.323440537589048,y:-.0007393601299264599},{x:.32591787773243747,y:.0010276723420694187},{x:.32849843989580535,y:.0026402221441315446},{x:.32950135051664736,y:.0035836850031119635},{x:.3306223431573158,y:.00438326450462502},{x:.3327073509705293,y:.006599649029470129},{x:.334923735495375,y:.008684656842684203},{x:.33572331499688823,y:.009805649483352899},{x:.33666677785586846,y:.01080856010419469},{x:.3382793276579303,y:.013389122267562135},{x:.3400463601299265,y:.01586646241095204},{x:.34061188112027707,y:.017121905714788034},{x:.3413415574489986,y:.018289606162238365},{x:.5935395574489987,y:.5268836061622384},{x:.5966650327785888,y:.5351329102741644},{x:.5981210935805097,y:.5438334563092145},{x:.5978517842547117,y:.5526508871625841},{x:.595867454207555,y:.5612463539114505},{x:.5922443601299265,y:.569289537589048},{x:.587121735495375,y:.5764713431573159},{x:.5806964398958053,y:.5825157778558685},{x:.5732153938377617,y:.5871905574489986},{x:.5649660897258356,y:.5903160327785888},{x:.5562655436907855,y:.5917720935805096},{x:.5474481128374159,y:.5915027842547117},{x:.5388526460885495,y:.589518454207555},{x:.5308094624109521,y:.5858953601299265},{x:.5236276568426842,y:.580772735495375},{x:.5175832221441315,y:.5743474398958054},{x:.5129084425510014,y:.5668663938377616},{x:.301026,y:.13957458745236595},{x:.08914355744899859,y:.5668663938377616},{x:.08446877785586845,y:.5743474398958054},{x:.07842434315731579,y:.580772735495375},{x:.07124253758904797,y:.5858953601299265},{x:.06319935391145051,y:.589518454207555},{x:.054603887162584124,y:.5915027842547117},{x:.04578645630921451,y:.5917720935805096},{x:.037085910274164385,y:.5903160327785888},{x:.028836606162238352,y:.5871905574489986},{x:.02135556010419467,y:.5825157778558685},{x:.014930264504625007,y:.5764713431573159},{x:.009807639870073534,y:.569289537589048},{x:.006184545792445054,y:.5612463539114505},{x:.004200215745288276,y:.5526508871625841},{x:.003930906419490336,y:.5438334563092145}]],w:[[{x:-.04481226541001698,y:.5427688011711321},{x:-.0431501306438814,y:.534105261341125},{x:.1073618693561186,y:.025511261341124997},{x:.10747750697825527,y:.02522662926113043},{x:.10753949092041715,y:.02492572151525217},{x:.1091366577408943,y:.021142772088450095},{x:.11068223944402648,y:.01733845540642648},{x:.11085118408582124,y:.017081852232977028},{x:.1109706812129555,y:.01679881881229654},{x:.11327517574267339,y:.0134001494872997},{x:.11553324489331337,y:.009970459715744673},{x:.11574900410692728,y:.009751746564891355},{x:.11592142221145292,y:.009497464285038355},{x:.11884468401801046,y:.006613684018010047},{x:.12172846428503836,y:.0036904222114529234},{x:.12198274656489135,y:.0035180041069272803},{x:.12220145971574467,y:.0033022448933133844},{x:.1256311494872997,y:.001044175742673395},{x:.12902981881229655,y:-.0012603187870445023},{x:.12931285223297703,y:-.0013798159141787526},{x:.12956945540642648,y:-.0015487605559735135},{x:.1333737720884501,y:-.0030943422591057004},{x:.13715672151525218,y:-.004691509079582858},{x:.13745762926113045,y:-.004753493021744735},{x:.137742261341125,y:-.004869130643881392},{x:.14177500717701197,y:-.005642829061426576},{x:.14579686008065018,y:-.006471289947453558},{x:.1461040784358031,y:-.006473378696506754},{x:.14640580117113214,y:-.006531265410016966},{x:.150512,y:-.006503347745684165},{x:.15461819882886788,y:-.006531265410016966},{x:.15491992156419693,y:-.006473378696506754},{x:.15522713991934983,y:-.006471289947453558},{x:.159248992822988,y:-.005642829061426585},{x:.16328173865887502,y:-.004869130643881392},{x:.16356637073886957,y:-.004753493021744732},{x:.16386727848474786,y:-.004691509079582851},{x:.1676502279115502,y:-.0030943422591055763},{x:.17145454459357354,y:-.0015487605559735135},{x:.17171114776702298,y:-.0013798159141787517},{x:.17199418118770346,y:-.0012603187870445023},{x:.17539285051270065,y:.001044175742673613},{x:.17882254028425534,y:.0033022448933133844},{x:.17904125343510863,y:.0035180041069272374},{x:.17929553571496165,y:.0036904222114529095},{x:.18217931598198978,y:.006613684018010279},{x:.1851025777885471,y:.009497464285038375},{x:.18527499589307275,y:.009751746564891386},{x:.18549075510668664,y:.009970459715744683},{x:.1877488242573266,y:.013400149487299715},{x:.1900533187870445,y:.016798818812296553},{x:.19017281591417878,y:.01708185223297707},{x:.19034176055597352,y:.01733845540642648},{x:.19188734225910553,y:.02114277208844964},{x:.19348450907958287,y:.02492572151525217},{x:.19354649302174473,y:.02522662926113043},{x:.1936621306438814,y:.025511261341124997},{x:.30102443002882817,y:.38829842311817664},{x:.4083889386148475,y:.025511027311792445},{x:.40850451632069196,y:.025226547135196155},{x:.40856646677585007,y:.0249257992040805},{x:.410163689741502,y:.021142697708463984},{x:.41170935302882616,y:.01733823938560964},{x:.41187820927072055,y:.017081773507688556},{x:.41199764237598097,y:.016798890297984457},{x:.41430222163921304,y:.013400082779514221},{x:.4165603984391837,y:.009970270005002412},{x:.41677604416644776,y:.009751674265617277},{x:.4169483701745541,y:.009497526820430955},{x:.41987174204670485,y:.006613627545966159},{x:.42275565189129766,y:.0036902661012626486},{x:.42300979995956794,y:.0035179410120882958},{x:.4232283964786704,y:.003302296075210584},{x:.4266582174181369,y:.0010441316765615349},{x:.4300570332693414,y:-.001260435297455717},{x:.43033991691088264,y:-.001379867379883588},{x:.4305963833993421,y:-.0015487226944633017},{x:.43440084731088763,y:-.0030943722258508074},{x:.43818395458161874,y:-.004691581512785238},{x:.43848470273672896,y:-.004753530880516994},{x:.4387691833312223,y:-.0048691075577547704},{x:.44280208680029426,y:-.005642843777199688},{x:.4468241027997286,y:-.0064713155198797695},{x:.44713115788546864,y:-.006473401493455157},{x:.44743272015628793,y:-.006531257986460835},{x:.45153908096424766,y:-.006503346644966049},{x:.45564544187310013,y:-.00653124313893301},{x:.4559470039347234,y:-.006473385555557348},{x:.4562540590129192,y:-.0064712984717510205},{x:.4602760720167908,y:-.005642812186517322},{x:.4643089726882076,y:-.004869061385152536},{x:.46459345286480397,y:-.004753483679308031},{x:.46489420079591953,y:-.0046915332241499325},{x:.46867730229153426,y:-.003094310258498727},{x:.4724817606143904,y:-.0015486469711738574},{x:.4727382264923116,y:-.0013797907292793573},{x:.47302110970201555,y:-.0012603576240190345},{x:.4764199172204845,y:.0010442216392121837},{x:.47984972999499764,y:.0033023984391836667},{x:.4800683257343829,y:.003518044166447842},{x:.48032247317956905,y:.003690370174554085},{x:.483206372454032,y:.0066137420467029156},{x:.48612973389873737,y:.009497651891297622},{x:.4863020589879118,y:.009751799959568049},{x:.48651770392478944,y:.009970396478670394},{x:.4887758683234383,y:.01340021741813658},{x:.49108043529745576,y:.016799033269341422},{x:.49119986737988364,y:.017081916910882677},{x:.4913687226944633,y:.017338383399342037},{x:.4929143722258502,y:.021142847310886045},{x:.4945115815127853,y:.024925954581618698},{x:.4945735308805171,y:.025226702736729056},{x:.4946891075577548,y:.025511183331222268},{x:.6452021075577549,y:.5341051833312223},{x:.6468642579864609,y:.542768720156288},{x:.646804298471751,y:.5515900590129192},{x:.64502453322415,y:.5602302007959196},{x:.641593357624019,y:.5683571097020156},{x:.636642629825446,y:.5756584731795691},{x:.6303626035213297,y:.5818537039247894},{x:.622994616600658,y:.5867047226944633},{x:.6148218166687778,y:.5900251075577548},{x:.6061582798437121,y:.5916872579864608},{x:.5973369409870808,y:.591627298471751},{x:.5886967992040805,y:.58984753322415},{x:.5805698902979844,y:.5864163576240191},{x:.573268526820431,y:.5814656298254459},{x:.5670732960752106,y:.5751856035213296},{x:.5622222773055368,y:.567817616600658},{x:.5589018924422452,y:.5596448166687777},{x:.4515387133151436,y:.1968570925189096},{x:.34417406138515255,y:.5596449726882076},{x:.3440584683142858,y:.559929490683899},{x:.34399650907958285,y:.5602302784847478},{x:.3423992950207163,y:.5640133397974443},{x:.3408536469711739,y:.5678177606143904},{x:.3406847682813525,y:.5680742605871558},{x:.34056531878704455,y:.5683571811877035},{x:.33826075609875456,y:.5717559510329858},{x:.33600260156081635,y:.5751857299949976},{x:.33578692716538155,y:.5754043547947312},{x:.3356145777885471,y:.5756585357149616},{x:.33269122952253233,y:.5785424012737268},{x:.32980734810870244,y:.5814657338987373},{x:.3295531662537196,y:.581638081896991},{x:.3293345402842553,y:.5818537551066867},{x:.3259047490749403,y:.5841118910428063},{x:.32250596673065857,y:.5864164352974557},{x:.322223045482268,y:.5865358832573104},{x:.32196654459357354,y:.5867047605559735},{x:.318162115393689,y:.5882503879717952},{x:.31437904541838135,y:.5898475815127853},{x:.31407825728149374,y:.5899095391161314},{x:.313793738658875,y:.5900251306438814},{x:.30976087354902626,y:.5907988519446131},{x:.3057388972002714,y:.5916273155198798},{x:.3054318012943039,y:.5916294017707667},{x:.3051301988288679,y:.5916872654100169},{x:.30102387855356455,y:.5916593469199811},{x:.29691755812689985,y:.5916872431389331},{x:.2966159559752979,y:.5916293778639092},{x:.2963088600806502,y:.5916272899474536},{x:.29228688822522214,y:.5907988045585649},{x:.28825402731179245,y:.5900250613851525},{x:.2879695093161011,y:.5899094683142858},{x:.2876687215152522,y:.5898475090795828},{x:.2838856602025565,y:.5882502950207166},{x:.28008123938560964,y:.5867046469711739},{x:.27982473941284386,y:.5865357682813523},{x:.27954181881229656,y:.5864163187870445},{x:.276143048967013,y:.5841117560987538},{x:.2727132700050024,y:.5818536015608163},{x:.2724946452052691,y:.5816379271653819},{x:.27224046428503834,y:.5814655777885471},{x:.2693565987262721,y:.5785422295225312},{x:.2664332661012626,y:.5756583481087024},{x:.2662609181030087,y:.5754041662537193},{x:.2660452448933134,y:.5751855402842553},{x:.26378710895719626,y:.5717557490749442},{x:.2614825647025443,y:.5683569667306586},{x:.2613631167426894,y:.5680740454822678},{x:.2611942394440265,y:.5678175445935736},{x:.2596486120282045,y:.5640131153936881},{x:.2580514184872148,y:.5602300454183813},{x:.25798946088386876,y:.5599292572814941},{x:.2578738693561186,y:.559644738658875},{x:.150512,y:.196859029989096},{x:.0431501306438814,y:.559644738658875},{x:.039829760555973516,y:.5678175445935736},{x:.034978755106686646,y:.5751855402842553},{x:.028783535714961644,y:.5814655777885471},{x:.021482181187703456,y:.5864163187870445},{x:.01335527848474783,y:.5898475090795828},{x:.0047151399193498065,y:.5916272899474536},{x:-.004106198828867862,y:.5916872654100169},{x:-.01276973865887501,y:.5900251306438814},{x:-.020942544593573535,y:.5867047605559735},{x:-.028310540284255312,y:.5818537551066867},{x:-.034590577788547086,y:.5756585357149616},{x:-.03954131878704451,y:.5683571811877035},{x:-.04297250907958286,y:.5602302784847478},{x:-.04475228994745356,y:.5515901399193498},{x:-.04481226541001698,y:.5427688011711321}]],x:[[{x:-.007882248997940308,y:.03911618267902263},{x:-.007180671607209664,y:.030322582532795114},{x:-.0047770285451087455,y:.021834819906700376},{x:-.0007636904665355299,y:.013979074758467071},{x:.004705112296856322,y:.007057238968589209},{x:.011419216721809594,y:.001335314804661543},{x:.019120603540586492,y:-.0029668073965882433},{x:.02751331277672888,y:-.0056837994916240225},{x:.036274817320977384,y:-.006711248997940296},{x:.04506841746720488,y:-.006009671607209652},{x:.05355618009329963,y:-.003606028545108733},{x:.061411925241532925,y:.0004073095334644686},{x:.0683337610314108,y:.005876112296856327},{x:.3010265,y:.23008742701759316},{x:.5337192389685892,y:.005876112296856327},{x:.540641074758467,y:.0004073095334644686},{x:.5484968199067003,y:-.003606028545108733},{x:.556984582532795,y:-.006009671607209652},{x:.5657781826790226,y:-.006711248997940296},{x:.5745396872232711,y:-.0056837994916240225},{x:.5829323964594135,y:-.0029668073965882433},{x:.5906337832781904,y:.001335314804661536},{x:.5973478877031436,y:.007057238968589213},{x:.6028166904665355,y:.013979074758467089},{x:.6068300285451087,y:.021834819906700383},{x:.6092336716072096,y:.030322582532795128},{x:.6099352489979403,y:.03911618267902263},{x:.608907799491624,y:.047877687223271126},{x:.6061908073965883,y:.05627039645941352},{x:.6018886851953384,y:.0639717832781904},{x:.5961667610314108,y:.07068588770314368},{x:.36588095484811606,y:.292578},{x:.5961667610314108,y:.5144701122968564},{x:.6018886851953384,y:.5211842167218096},{x:.6061908073965883,y:.5288856035405864},{x:.608907799491624,y:.5372783127767289},{x:.6099352489979403,y:.5460398173209774},{x:.6092336716072096,y:.5548334174672048},{x:.6068300285451087,y:.5633211800932996},{x:.6028166904665355,y:.571176925241533},{x:.5973478877031436,y:.5780987610314108},{x:.5906337832781904,y:.5838206851953385},{x:.5829323964594135,y:.5881228073965883},{x:.5745396872232711,y:.590839799491624},{x:.5657781826790226,y:.5918672489979403},{x:.556984582532795,y:.5911656716072097},{x:.5484968199067003,y:.5887620285451087},{x:.540641074758467,y:.5847486904665355},{x:.5337192389685892,y:.5792798877031436},{x:.3010265,y:.35506857298240685},{x:.0683337610314108,y:.5792798877031436},{x:.06141192524153289,y:.5847486904665355},{x:.05355618009329961,y:.5887620285451087},{x:.0450684174672049,y:.5911656716072097},{x:.03627481732097735,y:.5918672489979403},{x:.02751331277672888,y:.590839799491624},{x:.01912060354058648,y:.5881228073965883},{x:.011419216721809584,y:.5838206851953385},{x:.004705112296856315,y:.5780987610314108},{x:-.0007636904665355368,y:.571176925241533},{x:-.004777028545108752,y:.5633211800932996},{x:-.007180671607209664,y:.5548334174672048},{x:-.007882248997940308,y:.5460398173209774},{x:-.006854799491624035,y:.5372783127767289},{x:-.004137807396588256,y:.5288856035405864},{x:.0001643148046615306,y:.5211842167218096},{x:.005886238968589197,y:.5144701122968564},{x:.23617204515188386,y:.292578},{x:.005886238968589197,y:.07068588770314368},{x:.00016431480466150977,y:.0639717832781904},{x:-.004137807396588256,y:.05627039645941351},{x:-.006854799491624035,y:.047877687223271126},{x:-.007882248997940308,y:.03911618267902263}]],y:[[{x:-7800000000000168e-20,y:-.15516599999999992},{x:.0007866623818546317,y:-.16394506449072568},{x:.003347421036992093,y:-.17238675445642895},{x:.007505867446385456,y:-.180166660485882},{x:.013102194846605353,y:-.18698580515339455},{x:.0199213395141179,y:-.19258213255361445},{x:.02770124554357093,y:-.1967405789630078},{x:.03614293550927421,y:-.19930133761814528},{x:.044922,y:-.2001659999999999},{x:.084618,y:-.2001659999999999},{x:.08470326921416556,y:-.20015760171543356},{x:.08478856964894584,y:-.200165676732115},{x:.08909199801123496,y:-.19972534965725622},{x:.09339706449072577,y:-.19930133761814528},{x:.0934790568568106,y:-.19927646550581232},{x:.09356429362525961,y:-.1992677440740231},{x:.09769912926743524,y:-.1979963205354665},{x:.10183875445642904,y:-.1967405789630078},{x:.1019143190537861,y:-.19670018884423682},{x:.10199621655469396,y:-.19667500612370953},{x:.18074721655469395,y:-.16370500612370958},{x:.18295470197399702,y:-.16251430076809983},{x:.18525522528778574,y:-.16151511930158513},{x:.18682754729843723,y:-.16042530954354395},{x:.18851130436774752,y:-.15951710034658062},{x:.19044407848245243,y:-.15791861501920362},{x:.19250546725178602,y:-.1564898227103016},{x:.27125546725178606,y:-.08958282271030155},{x:.27347158712358693,y:-.0872898341236823},{x:.27580944257935097,y:-.08512109812948883},{x:.27653091968085064,y:-.08412438503144627},{x:.2773860111192193,y:-.08323963374445845},{x:.2791122089873479,y:-.0805583607511536},{x:.2809820438025964,y:-.07797520343727593},{x:.35909504380259644,y:.055837796562724036},{x:.35921507445013207,y:.05609937330868571},{x:.35938084670619436,y:.05633463764830328},{x:.359814044874128,y:.05731131476590327},{x:.3603874218559792,y:.0582128676935936},{x:.5972854218559792,y:.5265638676935935},{x:.6004763520268956,y:.5347880745861305},{x:.6020015061983327,y:.5434767752438966},{x:.6018022735507984,y:.5522960677732933},{x:.5998863104832066,y:.5609070317083322},{x:.5963272463817603,y:.568978752534074},{x:.591261854083932,y:.5762010385458585},{x:.5848847937750224,y:.5822963413425576},{x:.5774411323064065,y:.5870304218559792},{x:.5692169254138695,y:.5902213520268956},{x:.5605282247561034,y:.5917465061983327},{x:.5517089322267067,y:.5915472735507984},{x:.5430979682916678,y:.5896313104832066},{x:.5350262474659261,y:.5860722463817603},{x:.5278039614541415,y:.5810068540839319},{x:.5217086586574424,y:.5746297937750224},{x:.5169745781440208,y:.5671861323064065},{x:.3203411783046204,y:.17843886787959407},{x:.12481771439881506,y:.5670983271806026},{x:.12009991274687032,y:.5745523168465348},{x:.11401856108654926,y:.5809426827476728},{x:.10680736235169674,y:.5860238467061943},{x:.09874343886560628,y:.5896005424407229},{x:.09013668268554793,y:.5915353195400148},{x:.08131784662479694,y:.5917538256051798},{x:.0726258336075076,y:.5902476635706729},{x:.06439467281939737,y:.5870747143988151},{x:.05694068315346515,y:.5823569127468703},{x:.05055031725232718,y:.5762755610865493},{x:.04546915329380567,y:.5690643623516968},{x:.041892457559277035,y:.5610004388656062},{x:.039957680459985136,y:.5523936826855479},{x:.039739174394820276,y:.5435748466247969},{x:.0412453364293271,y:.5348828336075077},{x:.04441828560118493,y:.5266516728193974},{x:.26905653043412125,y:.0801181620528446},{x:.20712852539925722,y:-.025968816269973185},{x:.1395520619925953,y:-.08338263769409424},{x:.07557825049874085,y:-.11016599999999992},{x:.044922,y:-.11016599999999992},{x:.03614293550927422,y:-.11103066238185455},{x:.02770124554357096,y:-.11359142103699202},{x:.01992133951411791,y:-.11774986744638538},{x:.01310219484660536,y:-.12334619484660528},{x:.007505867446385456,y:-.13016533951411782},{x:.003347421036992093,y:-.13794524554357088},{x:.0007866623818546317,y:-.14638693550927412},{x:-7800000000000168e-20,y:-.15516599999999992}]],z:[[{x:.051680000000000004,y:.038348999999999966},{x:.05192127447228559,y:.035899299172703986},{x:.05194879067317478,y:.033437899088824954},{x:.05235257576103353,y:.03152022369965088},{x:.05254466238185464,y:.029569935509274177},{x:.053259213756049764,y:.02721437531096308},{x:.05376639657582897,y:.024805638484003446},{x:.054536542955643516,y:.023003585252525667},{x:.0551054210369921,y:.02112824554357092},{x:.05626578950451143,y:.018957348831652537},{x:.05723314819184797,y:.01669384166703705},{x:.05834005957014514,y:.015076662488338128},{x:.05926386744638546,y:.01334833951411787},{x:.060825460697764414,y:.011445532631778232},{x:.062215820200804926,y:.009414240440453706},{x:.0636169585940798,y:.00804408260344652},{x:.06486019484660537,y:.0065291948466053296},{x:.06676300172894496,y:.004967601595226417},{x:.06852293131171022,y:.0032465857969436324},{x:.07016445175727676,y:.0021761036989109733},{x:.07167933951411792,y:.0009328674463854256},{x:.07385023622603624,y:-.00022750102113387976},{x:.07591210278164046,y:-.0015721027544036703},{x:.07773092256935071,y:-.0023017710867676167},{x:.07945924554357096,y:-.003225578963007937},{x:.08181480574188199,y:-.003940130337203038},{x:.08409937289490133,y:-.004856645714911602},{x:.08602559580031956,y:-.00521745953679684},{x:.08790093550927423,y:-.0057863376181453985},{x:.09035063633657014,y:-.00602761209043098},{x:.09277010945251417,y:-.006480819940600742},{x:.09472971180962335,y:-.006458913379178931},{x:.09668,y:-.006651000000000032},{x:.505373,y:-.006651000000000032},{x:.5141520644907257,y:-.0057863376181453985},{x:.522593754456429,y:-.003225578963007937},{x:.5303736604858821,y:.0009328674463854256},{x:.5371928051533946,y:.0065291948466053296},{x:.5427891325536145,y:.013348339514117874},{x:.5469475789630078,y:.021128245543570928},{x:.5495083376181453,y:.029569935509274198},{x:.550373,y:.038348999999999966},{x:.5495083376181453,y:.047128064490725735},{x:.5469475789630078,y:.055569754456429005},{x:.5427891325536145,y:.06334966048588206},{x:.5371928051533946,y:.0701688051533946},{x:.5303736604858821,y:.0757651325536145},{x:.522593754456429,y:.07992357896300786},{x:.5141520644907257,y:.08248433761814533},{x:.505373,y:.08334899999999996},{x:.190464663126857,y:.08334899999999996},{x:.5404754142030563,y:.5196949313117102},{x:.5415458963010891,y:.5213364517572769},{x:.5427891325536145,y:.5228513395141179},{x:.5439495010211337,y:.525022236226036},{x:.5452941027544036,y:.5270841027816404},{x:.5460237710867677,y:.5289029225693511},{x:.5469475789630078,y:.530631245543571},{x:.5476621303372028,y:.5329868057418816},{x:.5485786457149116,y:.5352713728949013},{x:.5489394595367969,y:.53719759580032},{x:.5495083376181453,y:.5390729355092743},{x:.5497496120904308,y:.5415226363365697},{x:.5502028199406007,y:.5439421094525142},{x:.5501809133791788,y:.5459017118096235},{x:.550373,y:.547852},{x:.5501317255277144,y:.5503017008272966},{x:.5501042093268251,y:.552763100911175},{x:.5497004242389665,y:.5546807763003486},{x:.5495083376181453,y:.5566310644907257},{x:.5487937862439503,y:.5589866246890365},{x:.548286603424171,y:.5613953615159966},{x:.5475164570443563,y:.5631974147474748},{x:.5469475789630078,y:.565072754456429},{x:.5457872104954887,y:.567243651168347},{x:.544819851808152,y:.569507158332963},{x:.5437129404298549,y:.5711243375116617},{x:.5427891325536145,y:.5728526604858821},{x:.5412275393022352,y:.5747554673682221},{x:.539837179799195,y:.5767867595595463},{x:.5384360414059206,y:.578156917396553},{x:.5371928051533946,y:.5796718051533947},{x:.5352899982710546,y:.5812333984047738},{x:.5335300686882897,y:.5829544142030564},{x:.5318885482427235,y:.5840248963010888},{x:.5303736604858821,y:.5852681325536145},{x:.5282027637739638,y:.5864285010211338},{x:.5261408972183595,y:.5877731027544036},{x:.5243220774306487,y:.5885027710867679},{x:.522593754456429,y:.5894265789630079},{x:.5202381942581186,y:.5901411303372028},{x:.5179536271050986,y:.5910576457149116},{x:.5160274041996802,y:.5914184595367968},{x:.5141520644907257,y:.5919873376181454},{x:.5117023636634302,y:.5922286120904309},{x:.5092828905474858,y:.5926818199406008},{x:.5073232881903766,y:.5926599133791789},{x:.505373,y:.592852},{x:.09668,y:.592852},{x:.08790093550927423,y:.5919873376181454},{x:.07945924554357094,y:.5894265789630079},{x:.07167933951411792,y:.5852681325536145},{x:.06486019484660537,y:.5796718051533947},{x:.05926386744638546,y:.5728526604858821},{x:.0551054210369921,y:.565072754456429},{x:.05254466238185464,y:.5566310644907257},{x:.051680000000000004,y:.547852},{x:.05254466238185464,y:.5390729355092743},{x:.0551054210369921,y:.530631245543571},{x:.05926386744638546,y:.5228513395141179},{x:.06486019484660537,y:.5160321948466053},{x:.07167933951411792,y:.5104358674463855},{x:.07945924554357096,y:.5062774210369921},{x:.08790093550927423,y:.5037166623818546},{x:.09668,y:.502852},{x:.41158833687314295,y:.502852},{x:.06157758579694366,y:.06650606868828973},{x:.06050710369891106,y:.06486454824272328},{x:.05926386744638546,y:.06334966048588206},{x:.05810349897886612,y:.06117876377396365},{x:.05675889724559635,y:.059116897218359485},{x:.05602922891323242,y:.05729807743064926},{x:.0551054210369921,y:.055569754456429005},{x:.054390869662797,y:.05321419425811798},{x:.053474354285088434,y:.050929627105098636},{x:.0531135404632032,y:.04900340419968042},{x:.05254466238185464,y:.047128064490725735},{x:.05230338790956906,y:.04467836366342984},{x:.051850180059399294,y:.04225889054748581},{x:.05187208662082111,y:.04029928819037662},{x:.051680000000000004,y:.038348999999999966}]]},c0=D0;function z(y){return!y||typeof y!="object"?!1:"route_type"in y&&y.route_type==="wire"&&("start_width"in y||"end_width"in y||"width_interpolation_mode"in y)}function X0(y){let x=[];for(let e=0;e<y.length-1;e++){let t=y[e];if(!z(t))continue;let r=y[e+1];if(!r)continue;let n=r.route_type==="through_pad"?r.start:{x:r.x,y:r.y},o=r.route_type==="via"?r.from_layer:r.route_type==="through_pad"?r.start_layer:r.layer;if(!n||o!==t.layer||t.width!==t.start_width)continue;let i={start:{x:t.x,y:t.y},end:n,start_width:t.start_width,end_width:t.end_width,width_interpolation_mode:t.width_interpolation_mode,layer:t.layer,is_inside_copper_pour:!!(t.is_inside_copper_pour&&r.is_inside_copper_pour)};f0(i)&&x.push(i)}return x}function $0(y){let{start:x,end:e,start_width:t,end_width:r}=y,n=e.x-x.x,o=e.y-x.y,i=Math.hypot(n,o);if(!f0(y))return[];let a=Math.abs(r-t),c=y.width_interpolation_mode==="linear"?1:Math.max(1,Math.ceil(Math.sqrt(a/(.001+a*1e-6)*(3/8)))),d=-o/i,f=n/i,l=[],p=[];for(let s=0;s<=c;s++){let L=s/c,m=t<=r?L:1-L,_=(y.width_interpolation_mode==="quadratic"?Math.min(t,r)+a*m*m:t+(r-t)*L)/2,h=x.x+n*L,g=x.y+o*L;l.push({x:h+d*_,y:g+f*_}),p.push({x:h-d*_,y:g-f*_})}return[...l,...p.reverse()]}function f0(y){let{start:x,end:e,start_width:t,end_width:r}=y,n=Math.hypot(e.x-x.x,e.y-x.y);return!(![x.x,x.y,e.x,e.y,n,t,r].every(Number.isFinite)||n<=0||t<=0||r<=0||y.width_interpolation_mode!=="linear"&&y.width_interpolation_mode!=="quadratic")}var H=class{constructor(y=[1,1,1,1],x=0,e=0){M(this,"color");M(this,"element");M(this,"category");M(this,"vertices",[]);M(this,"indices",[]);this.color=y,this.element=x,this.category=e}polygon(y){if(!y[0]||y[0].length<3)return;let x=[],e=[];for(let[n,o]of y.entries()){n&&e.push(x.length/2);for(let i of o){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))throw new Error("Non-finite polygon vertex");x.push(i.x,i.y)}}let t=V(x,e,2),r=this.vertices.length/8;for(let n=0;n<x.length;n+=2)this.vertices.push(x[n],x[n+1],...this.color,this.element,this.category);for(let n of t)this.indices.push(r+n)}line(y,x,e){if(!(e>0))return;let t=Math.atan2(x.y-y.y,x.x-y.x),r=e/2,n=[];for(let o=0;o<=12;o++){let i=t+Math.PI/2+o*Math.PI/12;n.push({x:y.x+r*Math.cos(i),y:y.y+r*Math.sin(i)})}for(let o=0;o<=12;o++){let i=t-Math.PI/2+o*Math.PI/12;n.push({x:x.x+r*Math.cos(i),y:x.y+r*Math.sin(i)})}this.polygon([n])}path(y,x,e=!1){for(let t=1;t<y.length;t++)this.line(y[t-1],y[t],x);e&&y.length>2&&this.line(y.at(-1),y[0],x)}build(){return{vertices:new Float32Array(this.vertices),indices:new Uint32Array(this.indices)}}};function Y(y,x,e=0){let t=e*Math.PI/180,r=y.x-x.x,n=y.y-x.y;return{x:x.x+r*Math.cos(t)-n*Math.sin(t),y:x.y+r*Math.sin(t)+n*Math.cos(t)}}function q(y,x,e=x,t=0){return x>0&&e>0?Array.from({length:96},(r,n)=>{let o=n*2*Math.PI/96;return Y({x:y.x+Math.cos(o)*x/2,y:y.y+Math.sin(o)*e/2},y,t)}):[]}function p0(y,x,e,t=0,r=0){if(!(x>0&&e>0))return[];t=Math.max(0,Math.min(t,x/2,e/2));let n=[];for(let o=0;o<4;o++){let i=o===0||o===3?1:-1,a=o<2?1:-1,c=t?24:1;for(let d=0;d<c;d++){let f=(o+d/(c-1||1))*Math.PI/2;n.push(Y({x:y.x+i*(x/2-t)+t*Math.cos(f),y:y.y+a*(e/2-t)+t*Math.sin(f)},y,r))}}return n}function V0(y){let x=[];for(let e=0;e<y.length;e++){let t=y[e],r=y[(e+1)%y.length];x.push({x:t.x,y:t.y});let n=t.bulge??0,o=r.x-t.x,i=r.y-t.y;if(!n||!o&&!i)continue;let a=4*Math.atan(n),c={x:(t.x+r.x)/2-i*(1-n*n)/(4*n),y:(t.y+r.y)/2+o*(1-n*n)/(4*n)},d=Math.atan2(t.y-c.y,t.x-c.x),f=Math.hypot(t.x-c.x,t.y-c.y),l=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI/48)));for(let p=1;p<l;p++)x.push({x:c.x+f*Math.cos(d+a*p/l),y:c.y+f*Math.sin(d+a*p/l)})}return x}function l0(y,x,e){let t=[];for(let r=0;r<y.length;r++){let n=y[r],o=y[(r+1)%y.length],i=n.x+n.y-x,a=o.x+o.y-x,c=e?i>=0:i<=0,d=e?a>=0:a<=0;if(c&&t.push(n),c!==d){let f=i/(i-a);t.push({x:n.x+f*(o.x-n.x),y:n.y+f*(o.y-n.y)})}}return t}function z0(y,x){let e=y.color,t=[e[0]+(1-e[0])*.4,e[1]+(1-e[1])*.4,e[2]+(1-e[2])*.4,e[3]];y.color=[t[0],t[1],t[2],t[3]*.2],y.polygon(x),y.color=t;let r=new H;r.polygon(x);let n=.15*Math.SQRT2/2;for(let o=0;o<r.indices.length;o+=3){let i=r.indices.slice(o,o+3).map(f=>({x:r.vertices[f*8],y:r.vertices[f*8+1]})),a=i.map(f=>f.x+f.y),c=Math.ceil(Math.min(...a)-n),d=Math.floor(Math.max(...a)+n);for(let f=c;f<=d;f++)y.polygon([l0(l0(i,f-n,!0),f+n,!1)])}y.color=e}function H0(y,x){let e=!1;for(let t=0,r=y.length-1;t<y.length;r=t++){let n=y[t],o=y[r];n.y>x.y!=o.y>x.y&&x.x<(o.x-n.x)*(x.y-n.y)/(o.y-n.y)+n.x&&(e=!e)}return e}function u0(y,x){let e=x.filter(t=>t.length>=3).map(t=>({ring:t,parents:[]}));for(let[t,r]of e.entries())r.parents=e.flatMap((n,o)=>t!==o&&H0(n.ring,r.ring[0])?[o]:[]);for(let[t,r]of e.entries())if(r.parents.length%2===0){let n=e.filter(o=>o.parents.length===r.parents.length+1&&o.parents.includes(t));y.polygon([r.ring,...n.map(o=>o.ring)])}}var q0=y=>s0[y]??(y===" "?R.spaceWidthRatio:R.glyphWidthRatio);function d0(y,x,e){let t=q0(y),r=x?R.letterSpacingRatio:0,n=x?a0[y]?.[x]??0:0;return e*(t+r+n)}function j0(y,x){let e=x*R.glyphWidthRatio,t=x*R.letterSpacingRatio,r=x*R.spaceWidthRatio,n=x*R.strokeWidthRatio,o=x*R.lineHeightRatio,i=y.replace(/\\\\n/g,`\n`).split(`\n`),a=i.map(f=>{let l=Array.from(f);return l.reduce((p,s,L)=>p+d0(s,l[L+1],x),0)}),c=a.reduce((f,l)=>Math.max(f,l),0),d=i.length>1?x+(i.length-1)*o:x;return{width:c,height:d,glyphWidth:e,letterSpacing:t,spaceWidth:r,strokeWidth:n,lineHeight:o,lines:i,lineWidths:a}}function K0(y){let{line:x,fontSize:e,startX:t,startY:r}=y,n=e,o=e,i=Array.from(x),a=[],c=t+y.layout.strokeWidth/2;return i.forEach((d,f)=>{let l=c0[d];if(l?.length){let p=[];for(let s of l){let L=s.map(m=>({x:c+m.x*o,y:r+(1-m.y)*n}));L.length>=3&&p.push(L)}p.length>0&&a.push(p)}c+=d0(d,i[f+1],e)}),a}function J0(y){let x=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let n of y)for(let o of n)x=Math.min(x,o.x),e=Math.min(e,o.y),t=Math.max(t,o.x),r=Math.max(r,o.y);return x===Number.POSITIVE_INFINITY||e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY||r===Number.NEGATIVE_INFINITY?null:{minX:x,minY:e,maxX:t,maxY:r}}function Q0(y,x,e){let t=x5(y,x),r=e5(t,x,e),n=J0(r.flat()),o=t5(y,x,n);return{bounds:n?i5(n,o):null,glyphGroups:o5(r,o),linePlacements:t.map(({line:i,startX:a,startY:c})=>({line:i,startX:a+o.x,startY:c+o.y})),startOffset:o}}function y5(y,x){let e=x.width+x.strokeWidth,t=x.height+x.strokeWidth,r=0,n=0;return y==="center"||y==="top_center"||y==="bottom_center"?r=-e/2:y==="top_left"||y==="bottom_left"||y==="center_left"?r=0:y==="top_right"||y==="bottom_right"||y==="center_right"?r=-e:(y==="top_center"||y==="bottom_center")&&(r=-e/2),y==="center"||y==="center_left"||y==="center_right"?n=-t/2:y==="top_left"||y==="top_right"||y==="top_center"?n=0:(y==="bottom_left"||y==="bottom_right"||y==="bottom_center")&&(n=-t),{x:r,y:n}}function x5(y,x){return x.lines.map((e,t)=>({line:e,startX:s5({alignment:y,lineWidth:x.lineWidths[t],maxWidth:x.width,strokeWidth:x.strokeWidth}),startY:t*x.lineHeight}))}function e5(y,x,e){return y.flatMap(({line:t,startX:r,startY:n})=>K0({line:t,fontSize:e,startX:r,startY:n,layout:x}))}function t5(y,x,e){return e?{x:-r5(y,e),y:-n5(y,e)}:y5(y,x)}function r5(y,x){return y==="top_left"||y==="bottom_left"||y==="center_left"?x.minX:y==="top_right"||y==="bottom_right"||y==="center_right"?x.maxX:(x.minX+x.maxX)/2}function n5(y,x){return y==="top_left"||y==="top_right"||y==="top_center"?x.minY:y==="bottom_left"||y==="bottom_right"||y==="bottom_center"?x.maxY:(x.minY+x.maxY)/2}function o5(y,x){return x.x===0&&x.y===0?y:y.map(e=>e.map(t=>t.map(r=>({x:r.x+x.x,y:r.y+x.y}))))}function i5(y,x){return{minX:y.minX+x.x,minY:y.minY+x.y,maxX:y.maxX+x.x,maxY:y.maxY+x.y}}function s5(y){let{alignment:x,lineWidth:e,maxWidth:t,strokeWidth:r}=y,n=e+r,o=t+r;return x==="top_left"||x==="bottom_left"||x==="center_left"?0:x==="top_right"||x==="bottom_right"||x==="center_right"?o-n:(o-n)/2}function L0(y,x,e="up"){let t=String(x.text??"");if(!t)return;let r=x.anchor_position??x.center??{x:x.x??0,y:x.y??0},n=x.font_size??1,o=j0(t,n),i=Q0(x.anchor_alignment??"center",o,n),a=x.type==="pcb_note_text",c=x.type==="pcb_fabrication_note_text",d=c?!1:a?x.is_mirrored_from_top_view??x.layer==="bottom":x.type==="pcb_silkscreen_text"?x.layer==="bottom":x.is_mirrored??x.layer==="bottom",f=a||c?0:x.ccw_rotation??0,l=e==="up"?-1:1,p=s=>Y({x:r.x+(d?-s.x:s.x),y:r.y+l*s.y},r,-l*f);if(x.is_knockout&&!a&&!c){let s=i.bounds;if(!s)return;let L={left:.2,right:.2,top:.2,bottom:.2,...x.knockout_padding},m=[{x:s.minX-L.left,y:s.minY-L.top},{x:s.maxX+L.right,y:s.minY-L.top},{x:s.maxX+L.right,y:s.maxY+L.bottom},{x:s.minX-L.left,y:s.maxY+L.bottom}];u0(y,[m.map(p),...i.glyphGroups.flatMap(u=>u.map(_=>_.map(p)))]);return}for(let s of i.glyphGroups)u0(y,s.map(L=>L.map(p)))}var b=(y,x,e)=>[y/255,x/255,e/255,1],a5={board:b(70,72,72),top:b(200,52,52),bottom:b(77,127,196),inner1:b(127,200,127),inner2:b(206,125,44),inner3:b(79,203,203),inner4:b(219,98,139),inner5:b(167,165,198),inner6:b(40,204,217),inner7:b(232,178,167),inner8:b(242,237,161),drill:b(255,38,226),top_silkscreen:b(242,237,161),bottom_silkscreen:b(242,237,161),soldermask_top:b(12,55,33),soldermask_bottom:b(12,55,33),top_fabrication:[1,1,1,.5],bottom_fabrication:[1,1,1,.5],top_notes:b(89,148,220),bottom_notes:b(89,148,220),top_courtyard:b(255,0,245),bottom_courtyard:b(38,233,255),edge_cuts:b(208,210,205)},j=y=>y.replace(/_copper$/,"");function c5(y){let x=y.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(x){let t=x.length<=4?[...x].map(r=>r+r).join(""):x;if(t.length!==6&&t.length!==8)throw new Error(`Unsupported color: ${y}`);return[parseInt(t.slice(0,2),16)/255,parseInt(t.slice(2,4),16)/255,parseInt(t.slice(4,6),16)/255,t.length===8?parseInt(t.slice(6),16)/255:1]}let e=y.match(/^rgba?\\(([^)]+)\\)$/);if(e){let t=e[1].split(",").map(r=>Number(r.trim()));if((t.length===3||t.length===4)&&t.every(Number.isFinite))return[t[0]/255,t[1]/255,t[2]/255,t[3]??1]}throw new Error(`Unsupported color: ${y}`)}function l5(y,x=0){return y[`${y.type}_id`]??`${y.type}:${x}`}function K(y){return y.center??y.anchor_position??{x:y.x??0,y:y.y??0}}function P(y,x=!1){if(y.brep_shape)return[y.brep_shape.outer_ring,...y.brep_shape.inner_rings??[]].map(a=>V0(a.vertices));if(y.outline?.length)return[y.outline];let e=x?y.hole_shape??y.shape:y.shape;if(e==="polygon")return[y.points??y.vertices??[]];let t=K(y),r=y.rect_ccw_rotation??y.ccw_rotation??y.rotation??0,n=x?Y({x:t.x+(y.hole_offset_x??0),y:t.y+(y.hole_offset_y??0)},t,r):t;if(e==="circle"||e==="circular_hole_with_rect_pad"&&x||y.type==="pcb_via"){let a=x?y.hole_diameter:y.outer_diameter??(y.radius!=null?y.radius*2:y.diameter);return[q(n,a||y.diameter||y.hole_diameter||y.radius*2)]}let o=x?y.hole_width??y.hole_diameter:y.rect_pad_width??y.outer_width??y.width??y.hole_diameter,i=x?y.hole_height??y.hole_diameter:y.rect_pad_height??y.outer_height??y.height??y.hole_diameter;if(e==="oval")return[q(n,o,i,r)];if(["rect","square","rotated_rect","roundrect","rounded_rect","pill","rotated_pill","circular_hole_with_rect_pad","pill_hole_with_rect_pad",void 0].includes(e)){let c=e?.includes("pill")&&!(e==="pill_hole_with_rect_pad"&&!x)?Math.min(o,i)/2:y.corner_radius??y.rect_border_radius??0;return[p0(n,o,i,c,r)]}throw new Error(`Unsupported shape: ${e}`)}function u5(y,x={}){let e=new Map,t=[],r=y.map(l5),n=y.find(l=>l.type==="pcb_board"),o=["top",...Array.from({length:Math.max(0,Math.min(8,(n?.num_layers??2)-2))},(l,p)=>`inner${p+1}`),"bottom"],i=(l,p,s=!1,L=0)=>{l=j(l),e.has(l)||e.set(l,{paint:new H,erase:new H});let m=e.get(l)[s?"erase":"paint"];return m.color=x.layerColors?.[l]??a5[l]??[.75,.75,.75,1],m.element=p,m.category=L,m},a=[],c=[],d=[];for(let[l,p]of y.entries()){let s=p,L=s.type;try{if(L==="pcb_board"||L==="pcb_panel"){let m=P(s);i("board",l).polygon(m);for(let u of m)i("edge_cuts",l).path(u,.1,!0);for(let u of["top","bottom"])i(`soldermask_${u}`,l).polygon(m)}else if(L==="pcb_cutout")d.push({rings:P(s),index:l}),i("edge_cuts",l).path(P(s)[0],.05,!0);else if(L==="pcb_smtpad")i(s.layer,l).polygon(P(s)),s.is_covered_with_solder_mask||i(`soldermask_${s.layer}`,l,!0).polygon(P(s));else if(L==="pcb_via"||L==="pcb_plated_hole"){let m=s.layers??o;if(L==="pcb_via"&&!s.layers&&s.from_layer&&s.to_layer){let u=o.indexOf(s.from_layer),_=o.indexOf(s.to_layer);m=o.slice(Math.min(u,_),Math.max(u,_)+1)}for(let u of m)i(u,l).polygon(P(s));a.push({element:s,index:l,layers:m});for(let u of["top","bottom"])m.includes(u)&&!s.is_covered_with_solder_mask&&i(`soldermask_${u}`,l,!0).polygon(P(s))}else if(L==="pcb_hole")a.push({element:{...s,shape:s.hole_shape},index:l,layers:o});else if(L==="pcb_trace"){let m=s.route??[];if(s.route_thickness_mode==="interpolated"&&m.some((u,_)=>u.route_type==="wire"&&!z(u)&&m[_+1]?.route_type==="wire")||m.some(u=>u.route_type==="through_pad"))throw new Error("Interpolated/through-pad traces are not supported yet");for(let u of X0(m)){let _=$0(u);if(!_.length)throw new Error("Invalid teardrop geometry or interpolation mode");i(u.layer,l).polygon([_])}for(let u=1;u<m.length;u++){let _=m[u-1],h=m[u];if(z(_))continue;let g=_.route_type==="wire"&&h.route_type==="wire"&&_.layer===h.layer||_.route_type==="wire"&&h.route_type==="via"&&[h.from_layer,h.to_layer].includes(_.layer)?_.layer:_.route_type==="via"&&h.route_type==="wire"&&[_.from_layer,_.to_layer].includes(h.layer)?h.layer:void 0;g&&i(g,l).line(_,h,_.width??h.width??.15)}}else if(L==="pcb_copper_pour")i(s.layer,l,!1,1).polygon(P(s));else if(L==="pcb_copper_text")L0(i(s.layer,l),s,x.textYAxis);else if(/^pcb_(silkscreen|fabrication_note|courtyard|note|user_note)_/.test(L)){let m=L.match(/^pcb_(silkscreen|fabrication_note|courtyard|note|user_note)_/)[1],u={silkscreen:"silkscreen",fabrication_note:"fabrication",courtyard:"courtyard",note:"notes",user_note:"notes"}[m],_=`${s.layer??"top"}_${u}`,h=i(_,l);if(L.endsWith("_text"))s.color&&(m==="note"||m==="fabrication_note")&&(h.color=c5(s.color)),L0(h,s,x.textYAxis);else if(L.endsWith("_path")||L.endsWith("_line")||L.endsWith("_outline")){let g=s.route??s.points??s.outline??[s.start,s.end].filter(Boolean);h.path(g,s.stroke_width??s.width??.05,L.endsWith("_outline"))}else if(L==="pcb_silkscreen_graphic"&&s.shape==="brep")h.polygon(P(s));else if(L.endsWith("_rect")){let g=p0(K(s),s.width,s.height,s.corner_radius??0,s.ccw_rotation??0);s.is_filled?h.polygon([g]):h.path(g,s.stroke_width??.05,!0)}else if(L.endsWith("_circle")){let g=q(K(s),(s.radius??0)*2);s.is_filled?h.polygon([g]):h.path(g,s.stroke_width??.05,!0)}else throw new Error("Unsupported annotation geometry")}else if(L==="pcb_keepout")c.push({rings:P(s),index:l,layers:s.layers??[s.layer??"top"]});else if(L.startsWith("pcb_")&&!["pcb_component","pcb_port","pcb_group","pcb_solder_paste","pcb_debug_object","pcb_trace_hint","pcb_anchor","pcb_breakout_point"].includes(L)&&!/_(error|warning)$/.test(L))throw new Error("Unsupported PCB element")}catch(m){t.push({elementId:r[l],type:L,message:String(m)})}}for(let{rings:l,index:p,layers:s}of c)try{for(let L of s)z0(i(L,p),l)}catch(L){t.push({elementId:r[p],type:"pcb_keepout",message:String(L)})}for(let{element:l,index:p,layers:s}of a){let L=P(l,!0);for(let u of s)i(u,p,!0).polygon(L);s.includes("top")&&s.includes("bottom")&&(i("board",p,!0).polygon(L),i("drill",p).polygon(L));for(let u of["top","bottom"])s.includes(u)&&i(`soldermask_${u}`,p,!0).polygon(L)}for(let{rings:l,index:p}of d)for(let s of e.keys())s!=="edge_cuts"&&i(s,p,!0).polygon(l);let f=[...e].map(([l,p])=>({name:l,paint:p.paint.build(),erase:p.erase.build()}));return{layers:f,elementIds:r,diagnostics:t,triangleCount:f.reduce((l,p)=>l+(p.paint.indices.length+p.erase.indices.length)/3,0)}}var L5=`\nstruct Camera { rowX: vec4f, rowY: vec4f, viewport: vec4f }\n@group(0) @binding(0) var<uniform> camera: Camera;\n@group(0) @binding(1) var<storage, read> highlights: array<u32>;\nstruct VertexOut {\n  @builtin(position) position: vec4f,\n  @location(0) color: vec4f,\n  @location(1) @interpolate(flat) category: u32,\n  @location(2) @interpolate(flat) selected: u32,\n}\n@vertex fn vertexMain(@location(0) p: vec2f, @location(1) color: vec4f,\n  @location(2) element: f32, @location(3) category: f32) -> VertexOut {\n  let pixel = vec2f(dot(camera.rowX.xyz, vec3f(p, 1)), dot(camera.rowY.xyz, vec3f(p, 1)));\n  var out: VertexOut;\n  out.position = vec4f(pixel.x / camera.viewport.x * 2 - 1, 1 - pixel.y / camera.viewport.y * 2, 0, 1);\n  let highlight = select(0.0, 1.0, (highlights[u32(element)] & 1u) != 0u);\n  out.color = vec4f(mix(color.rgb, min(vec3f(1), color.rgb * 1.5), highlight), color.a);\n  out.category = u32(category);\n  out.selected = highlights[u32(element)] & 2u;\n  return out;\n}\n@fragment fn fragmentMain(in: VertexOut) -> @location(0) vec4f {\n  if (in.category == 1u && camera.viewport.z == 0) { discard; }\n  if (camera.viewport.w == 1) {\n    if (in.selected == 0u) { discard; }\n    return vec4f(in.color.rgb, 1);\n  }\n  return vec4f(in.color.rgb * in.color.a, in.color.a);\n}\n`,h5=`\n@group(0) @binding(0) var image: texture_2d<f32>;\n@group(0) @binding(1) var imageSampler: sampler;\n@group(0) @binding(2) var<uniform> fade: vec4f;\nstruct Out { @builtin(position) position: vec4f, @location(0) uv: vec2f }\n@vertex fn vertexMain(@builtin(vertex_index) index: u32) -> Out {\n  let points = array<vec2f, 6>(vec2f(0,0),vec2f(1,0),vec2f(0,1),vec2f(0,1),vec2f(1,0),vec2f(1,1));\n  var out: Out;\n  out.uv = points[index];\n  out.position = vec4f(out.uv.x * 2 - 1, 1 - out.uv.y * 2, 0, 1);\n  return out;\n}\n@fragment fn fragmentMain(in: Out) -> @location(0) vec4f {\n  return textureSample(image, imageSampler, in.uv) * fade.x;\n}\n`,h0={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha"}},G,Z=(G=class{constructor(x,e,t,r,n){M(this,"canvas");M(this,"device");M(this,"context");M(this,"config");M(this,"realToCanvasMat",{a:1,b:0,c:0,d:-1,e:0,f:0});M(this,"stats",{geometryUploads:0,frames:0,triangleCount:0,compileMs:0,vertexBytes:0});M(this,"circuit");M(this,"scene");M(this,"layers",[]);M(this,"xRayLayers",[]);M(this,"xRayUniform");M(this,"xRayCameraGroup");M(this,"uniform");M(this,"highlights");M(this,"cameraGroup");M(this,"highlightKey","");M(this,"highlightIndices",new Map);M(this,"sample");M(this,"size","");M(this,"disposed",!1);M(this,"adapterInfo");M(this,"lost",!1);M(this,"paintPipeline");M(this,"erasePipeline");M(this,"compositePipeline");M(this,"sampler");M(this,"options",{});this.canvas=x,this.device=e,this.context=t,this.config=n,this.uniform=e.createBuffer({size:48,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.xRayUniform=e.createBuffer({size:48,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.highlights=e.createBuffer({size:4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});let o=e.createShaderModule({code:L5}),i=e.createPipelineLayout({bindGroupLayouts:[e.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.VERTEX,buffer:{type:"read-only-storage"}}]})]}),a=d=>({layout:i,vertex:{module:o,entryPoint:"vertexMain",buffers:[{arrayStride:32,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x4"},{shaderLocation:2,offset:24,format:"float32"},{shaderLocation:3,offset:28,format:"float32"}]}]},fragment:{module:o,entryPoint:"fragmentMain",targets:[{format:"rgba8unorm",blend:d}]},primitive:{topology:"triangle-list"},multisample:{count:n.sampleCount??4}});this.paintPipeline=e.createRenderPipeline(a(h0)),this.erasePipeline=e.createRenderPipeline(a({color:{srcFactor:"zero",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha"}}));let c=e.createShaderModule({code:h5});this.compositePipeline=e.createRenderPipeline({layout:"auto",vertex:{module:c,entryPoint:"vertexMain"},fragment:{module:c,entryPoint:"fragmentMain",targets:[{format:r,blend:h0}]},primitive:{topology:"triangle-list"}}),this.sampler=e.createSampler({minFilter:"linear",magFilter:"linear"}),e.lost.then(d=>{this.lost=!0,this.disposed||n.onDeviceLost?.(d.message||d.reason)})}static async create(x,e={}){if(!globalThis.navigator?.gpu)throw new Error("WebGPU is unavailable");let t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("No WebGPU adapter available");let r=await t.requestDevice(),n=x.getContext("webgpu");if(!n)throw r.destroy(),new Error("WebGPU canvas context is unavailable");let o=navigator.gpu.getPreferredCanvasFormat();n.configure({device:r,format:o,alphaMode:"premultiplied"}),r.pushErrorScope("validation");try{let i=new G(x,r,n,o,e),a=await r.popErrorScope();if(a)throw i.dispose(),new Error(a.message);return r.addEventListener("uncapturederror",c=>e.onDeviceLost?.(c.error.message)),i.adapterInfo=t.info,i}catch(i){throw n.unconfigure(),r.destroy(),i}}get diagnostics(){return this.scene?.diagnostics??[]}setCircuitJson(x){if(this.assertLive(),this.circuit===x)return;let e=performance.now(),t=u5(x,this.config);this.releaseLayers(),this.highlights.destroy(),this.highlights=this.device.createBuffer({size:Math.max(4,t.elementIds.length*4),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.highlightIndices=new Map(t.elementIds.map((n,o)=>[n,o])),this.highlightKey="!",this.cameraGroup=this.device.createBindGroup({layout:this.paintPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.uniform}},{binding:1,resource:{buffer:this.highlights}}]}),this.xRayCameraGroup=this.device.createBindGroup({layout:this.paintPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.xRayUniform}},{binding:1,resource:{buffer:this.highlights}}]}),this.stats.vertexBytes=0;let r=n=>{let o=(i,a)=>{let c=this.device.createBuffer({size:Math.max(4,i.byteLength),usage:a|GPUBufferUsage.COPY_DST});return i.byteLength&&this.device.queue.writeBuffer(c,0,i.buffer,i.byteOffset,i.byteLength),this.stats.vertexBytes+=i.byteLength,c};return{vertices:o(n.vertices,GPUBufferUsage.VERTEX),indices:o(n.indices,GPUBufferUsage.INDEX),count:n.indices.length}};this.layers=t.layers.map(n=>({name:n.name,paint:r(n.paint),erase:r(n.erase),opacity:this.device.createBuffer({size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})})),this.xRayLayers=this.layers.filter(n=>this.isCopper(n.name)||n.name==="drill").map(n=>({...n,opacity:this.device.createBuffer({size:16,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})})),this.scene=t,this.circuit=x,this.size="",this.stats.geometryUploads++,this.stats.triangleCount=t.triangleCount,this.stats.compileMs=performance.now()-e}drawElements(x,e={}){this.setCircuitJson(x),this.options={},this.render(e)}render(x={}){this.assertLive(),this.options={...this.options,...x};let e=this.options;e.transform&&(this.realToCanvasMat=e.transform);let t=this.realToCanvasMat,r=this.canvas.width,n=this.canvas.height;if(!r||!n)return;if(![...Object.values(t),r,n].every(Number.isFinite))throw new Error("Invalid camera or canvas dimensions");if(r>this.device.limits.maxTextureDimension2D||n>this.device.limits.maxTextureDimension2D)throw new Error("Canvas exceeds GPU texture limits");this.resize(r,n),this.device.queue.writeBuffer(this.uniform,0,new Float32Array([t.a,t.c,t.e,0,t.b,t.d,t.f,0,r,n,e.showCopperPours===!1?0:1,0]));let o=e.xRayElementIds??[],i=o.length>0;i&&this.device.queue.writeBuffer(this.xRayUniform,0,new Float32Array([t.a,t.c,t.e,0,t.b,t.d,t.f,0,r,n,e.showCopperPours===!1?0:1,1]));let a=i?[]:e.highlightedElementIds??[],c=JSON.stringify([a,o]);if(c!==this.highlightKey){let u=new Uint32Array(Math.max(1,this.scene?.elementIds.length??0));for(let _ of a){let h=this.highlightIndices.get(_);h!==void 0&&(u[h]=1)}for(let _ of o){let h=this.highlightIndices.get(_);h!==void 0&&(u[h]|=2)}this.device.queue.writeBuffer(this.highlights,0,u),this.highlightKey=c}let d=j(e.selectedLayer??"top"),f=e.layers?new Set(e.layers.map(j)):void 0,l=this.layers.filter(u=>f&&!f.has(u.name)||i&&!this.isCopper(u.name)||u.name==="board"&&!e.showBoardMaterial||u.name.startsWith("soldermask_")&&(!e.showSolderMask||u.name!==`soldermask_${d}`)||u.name.includes("silkscreen")&&e.showSilkscreen===!1||u.name.includes("fabrication")&&!e.showFabricationNotes||u.name.includes("notes")&&e.showPcbNotes===!1||u.name.includes("courtyard")&&!e.showCourtyards?!1:i&&this.isCopper(u.name)||this.opacity(u.name,d,e.hiddenLayerOpacity??.4)>0).sort((u,_)=>this.order(u.name,d)-this.order(_.name,d)),p=i?this.xRayLayers.filter(u=>!f||f.has(u.name)).sort((u,_)=>this.xRayOrder(u.name,d)-this.xRayOrder(_.name,d)):[],s=[...l.map(u=>({layer:u,xRay:!1})),...p.map(u=>({layer:u,xRay:!0}))],L=this.device.createCommandEncoder();for(let{layer:u,xRay:_}of s){this.ensureTexture(u,r,n);let h=u.texture.createView(),g=(this.config.sampleCount??4)>1,T=L.beginRenderPass({colorAttachments:[{view:g?this.sample.createView():h,...g?{resolveTarget:h}:{},clearValue:[0,0,0,0],loadOp:"clear",storeOp:g?"discard":"store"}]});for(let[C,y0]of[[u.paint,this.paintPipeline],[u.erase,this.erasePipeline]])C.count&&(T.setBindGroup(0,_&&y0===this.paintPipeline?this.xRayCameraGroup:this.cameraGroup),T.setPipeline(y0),T.setVertexBuffer(0,C.vertices),T.setIndexBuffer(C.indices,"uint32"),T.drawIndexed(C.count));T.end(),this.device.queue.writeBuffer(u.opacity,0,new Float32Array([_?1:i&&this.isCopper(u.name)?Math.max(0,Math.min(1,e.hiddenLayerOpacity??.4)):this.opacity(u.name,d,e.hiddenLayerOpacity??.4),0,0,0]))}let m=L.beginRenderPass({colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:e.background??[0,0,0,0],loadOp:"clear",storeOp:"store"}]});m.setPipeline(this.compositePipeline);for(let{layer:u}of s)m.setBindGroup(0,u.composite),m.draw(6);m.end(),this.device.queue.submit([L.finish()]),this.stats.frames++}async flush(){this.assertLive(),await this.device.queue.onSubmittedWorkDone()}isCopper(x){return/^(top|bottom|inner\\d+)$/.test(x)}opacity(x,e,t){return["board","drill","edge_cuts"].includes(x)||x===e||x.startsWith(`${e}_`)||x.endsWith(`_${e}`)?1:Math.max(0,Math.min(1,t))}xRayOrder(x,e){return x==="drill"?200:x===e?100:x==="bottom"?0:x.startsWith("inner")?20-Number(x.slice(5)):40}order(x,e){if(x==="board")return-100;if(x==="drill")return 200;if(x==="edge_cuts")return 150;let t=x===e?100:x.startsWith("inner")?20-Number(x.slice(5)):x==="bottom"?30:40;return x.includes("soldermask")?110:x.startsWith(`${e}_`)?120:t}resize(x,e){let t=`${x}:${e}`;if(t!==this.size){this.sample?.destroy(),this.sample=(this.config.sampleCount??4)>1?this.device.createTexture({size:[x,e],format:"rgba8unorm",sampleCount:this.config.sampleCount??4,usage:GPUTextureUsage.RENDER_ATTACHMENT}):void 0;for(let r of[...this.layers,...this.xRayLayers])r.texture?.destroy(),r.texture=void 0,r.composite=void 0;this.size=t}}ensureTexture(x,e,t){x.texture||(x.texture=this.device.createTexture({size:[e,t],format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),x.composite=this.device.createBindGroup({layout:this.compositePipeline.getBindGroupLayout(0),entries:[{binding:0,resource:x.texture.createView()},{binding:1,resource:this.sampler},{binding:2,resource:{buffer:x.opacity}}]}))}assertLive(){if(this.disposed||this.lost)throw new Error(this.lost?"WebGPU device lost":"Renderer disposed")}releaseLayers(){for(let x of this.xRayLayers)x.opacity.destroy(),x.texture?.destroy();this.xRayLayers=[];for(let x of this.layers){for(let e of[x.paint,x.erase])e.vertices.destroy(),e.indices.destroy();x.opacity.destroy(),x.texture?.destroy()}this.layers=[]}dispose(){if(this.disposed)return;this.disposed=!0,this.releaseLayers(),this.sample?.destroy(),this.uniform.destroy(),this.xRayUniform.destroy(),this.highlights.destroy(),this.context.unconfigure();let x=()=>this.device.destroy();this.device.queue.onSubmittedWorkDone().then(x,x),this.circuit=void 0,this.scene=void 0}},M(G,"supportsXRayNet",!0),G);var k=self,m0="supportsXRayNet"in Z&&Z.supportsXRayNet===!0,w,E,D,J=!1,W=!1,Q=y=>{W||(W=!0,w?.dispose(),k.postMessage({type:"error",message:y instanceof Error?y.message:String(y)}))};function g0(){if(J||W||!w||!D)return;J=!0;let y=()=>{if(J=!1,!(W||!w||!D))try{let x=D;E.width!==x.width&&(E.width=x.width),E.height!==x.height&&(E.height=x.height),w.render({...x.options,transform:x.transform}),k.postMessage({type:"rendered",xRayActive:m0&&!!x.options.xRayElementIds?.length,geometryUploads:w.stats.geometryUploads,frames:w.stats.frames,compileMs:w.stats.compileMs})}catch(x){Q(x)}};k.requestAnimationFrame?k.requestAnimationFrame(y):setTimeout(y,16)}k.onmessage=async({data:y})=>{try{if(y.type==="init"){if(E=y.canvas,w=await Z.create(E,{onDeviceLost:Q}),W){w.dispose();return}k.postMessage({type:"ready",supportsXRayNet:m0})}else if(y.type==="scene"){if(w.setCircuitJson(y.elements),w.diagnostics.length)throw new Error(`Unsupported WebGPU geometry: ${w.diagnostics.map(x=>`${x.type}: ${x.message}`).join("; ")}`);g0()}else y.type==="view"?(D=y,g0()):(W=!0,w?.dispose())}catch(x){Q(x)}};})();\n'],{type:"text/javascript"}));try{return new Worker(t)}finally{URL.revokeObjectURL(t)}}var XRi=zRi({"inline-worker:/home/runner/work/pcb-viewer/pcb-viewer/src/lib/webgpu/pcb-webgpu.worker.ts"(){}}),ZRi=Vje({"node_modules/svgson/dist/svgson.umd.js"(t,e){(function(n,o){typeof t=="object"&&typeof e<"u"?e.exports=o():typeof define=="function"&&define.amd?define(o):(n=typeof globalThis<"u"?globalThis:n||self,n.svgson=o())})(t,function(){var n=function(j){return j!=null&&(o(j)||i(j)||!!j._isBuffer)};function o(j){return!!j.constructor&&typeof j.constructor.isBuffer=="function"&&j.constructor.isBuffer(j)}function i(j){return typeof j.readFloatLE=="function"&&typeof j.slice=="function"&&o(j.slice(0,0))}var r=Object.prototype.toString,s=function(J){if(typeof J>"u")return"undefined";if(J===null)return"null";if(J===!0||J===!1||J instanceof Boolean)return"boolean";if(typeof J=="string"||J instanceof String)return"string";if(typeof J=="number"||J instanceof Number)return"number";if(typeof J=="function"||J instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(J))return"array";if(J instanceof RegExp)return"regexp";if(J instanceof Date)return"date";var oe=r.call(J);return oe==="[object RegExp]"?"regexp":oe==="[object Date]"?"date":oe==="[object Arguments]"?"arguments":oe==="[object Error]"?"error":n(J)?"buffer":oe==="[object Set]"?"set":oe==="[object WeakSet]"?"weakset":oe==="[object Map]"?"map":oe==="[object WeakMap]"?"weakmap":oe==="[object Symbol]"?"symbol":oe==="[object Int8Array]"?"int8array":oe==="[object Uint8Array]"?"uint8array":oe==="[object Uint8ClampedArray]"?"uint8clampedarray":oe==="[object Int16Array]"?"int16array":oe==="[object Uint16Array]"?"uint16array":oe==="[object Int32Array]"?"int32array":oe==="[object Uint32Array]"?"uint32array":oe==="[object Float32Array]"?"float32array":oe==="[object Float64Array]"?"float64array":"object"};function a(j,J){return J={exports:{}},j(J,J.exports),J.exports}var A=a(function(j){(function(){function J(oe,ie){if(typeof ie!="function")return oe;var ne={};for(var le in oe)Object.prototype.hasOwnProperty.call(oe,le)&&(ne[ie(le,oe[le])||le]=oe[le]);return ne}j.exports?j.exports=J:window.rename=J})()}),c=function j(J,oe){var ie=s(J);if(ie!=="object"&&ie!=="array")throw new Error("expected an object");var ne=[];ie==="object"&&(J=A(J,oe),ne={});for(var le in J)if(J.hasOwnProperty(le)){var ge=J[le];s(ge)==="object"||s(ge)==="array"?ne[le]=j(ge,oe):ne[le]=ge}return ne},l=a(function(j){var J=Object.prototype.hasOwnProperty,oe="~";function ie(){}Object.create&&(ie.prototype=Object.create(null),new ie().__proto__||(oe=!1));function ne(ge,_e,ue){this.fn=ge,this.context=_e,this.once=ue||!1}function le(){this._events=new ie,this._eventsCount=0}le.prototype.eventNames=function(){var _e=[],ue,fe;if(this._eventsCount===0)return _e;for(fe in ue=this._events)J.call(ue,fe)&&_e.push(oe?fe.slice(1):fe);return Object.getOwnPropertySymbols?_e.concat(Object.getOwnPropertySymbols(ue)):_e},le.prototype.listeners=function(_e,ue){var fe=oe?oe+_e:_e,pe=this._events[fe];if(ue)return!!pe;if(!pe)return[];if(pe.fn)return[pe.fn];for(var ye=0,Me=pe.length,ve=new Array(Me);ye<Me;ye++)ve[ye]=pe[ye].fn;return ve},le.prototype.emit=function(_e,ue,fe,pe,ye,Me){var ve=oe?oe+_e:_e;if(!this._events[ve])return!1;var he=this._events[ve],Qe=arguments.length,Pe,we;if(he.fn){switch(he.once&&this.removeListener(_e,he.fn,void 0,!0),Qe){case 1:return he.fn.call(he.context),!0;case 2:return he.fn.call(he.context,ue),!0;case 3:return he.fn.call(he.context,ue,fe),!0;case 4:return he.fn.call(he.context,ue,fe,pe),!0;case 5:return he.fn.call(he.context,ue,fe,pe,ye),!0;case 6:return he.fn.call(he.context,ue,fe,pe,ye,Me),!0}for(we=1,Pe=new Array(Qe-1);we<Qe;we++)Pe[we-1]=arguments[we];he.fn.apply(he.context,Pe)}else{var Te=he.length,Re;for(we=0;we<Te;we++)switch(he[we].once&&this.removeListener(_e,he[we].fn,void 0,!0),Qe){case 1:he[we].fn.call(he[we].context);break;case 2:he[we].fn.call(he[we].context,ue);break;case 3:he[we].fn.call(he[we].context,ue,fe);break;case 4:he[we].fn.call(he[we].context,ue,fe,pe);break;default:if(!Pe)for(Re=1,Pe=new Array(Qe-1);Re<Qe;Re++)Pe[Re-1]=arguments[Re];he[we].fn.apply(he[we].context,Pe)}}return!0},le.prototype.on=function(_e,ue,fe){var pe=new ne(ue,fe||this),ye=oe?oe+_e:_e;return this._events[ye]?this._events[ye].fn?this._events[ye]=[this._events[ye],pe]:this._events[ye].push(pe):(this._events[ye]=pe,this._eventsCount++),this},le.prototype.once=function(_e,ue,fe){var pe=new ne(ue,fe||this,!0),ye=oe?oe+_e:_e;return this._events[ye]?this._events[ye].fn?this._events[ye]=[this._events[ye],pe]:this._events[ye].push(pe):(this._events[ye]=pe,this._eventsCount++),this},le.prototype.removeListener=function(_e,ue,fe,pe){var ye=oe?oe+_e:_e;if(!this._events[ye])return this;if(!ue)return--this._eventsCount===0?this._events=new ie:delete this._events[ye],this;var Me=this._events[ye];if(Me.fn)Me.fn===ue&&(!pe||Me.once)&&(!fe||Me.context===fe)&&(--this._eventsCount===0?this._events=new ie:delete this._events[ye]);else{for(var ve=0,he=[],Qe=Me.length;ve<Qe;ve++)(Me[ve].fn!==ue||pe&&!Me[ve].once||fe&&Me[ve].context!==fe)&&he.push(Me[ve]);he.length?this._events[ye]=he.length===1?he[0]:he:--this._eventsCount===0?this._events=new ie:delete this._events[ye]}return this},le.prototype.removeAllListeners=function(_e){var ue;return _e?(ue=oe?oe+_e:_e,this._events[ue]&&(--this._eventsCount===0?this._events=new ie:delete this._events[ue])):(this._events=new ie,this._eventsCount=0),this},le.prototype.off=le.prototype.removeListener,le.prototype.addListener=le.prototype.on,le.prototype.setMaxListeners=function(){return this},le.prefixed=oe,le.EventEmitter=le,j.exports=le});function u(j,J,oe){return J in j?Object.defineProperty(j,J,{value:oe,enumerable:!0,configurable:!0,writable:!0}):j[J]=oe,j}var g=function(){},h={data:"state-data",cdata:"state-cdata",tagBegin:"state-tag-begin",tagName:"state-tag-name",tagEnd:"state-tag-end",attributeNameStart:"state-attribute-name-start",attributeName:"state-attribute-name",attributeNameEnd:"state-attribute-name-end",attributeValueBegin:"state-attribute-value-begin",attributeValue:"state-attribute-value"},d={lt:"action-lt",gt:"action-gt",space:"action-space",equal:"action-equal",quote:"action-quote",slash:"action-slash",char:"action-char",error:"action-error"},p={text:"text",openTag:"open-tag",closeTag:"close-tag",attributeName:"attribute-name",attributeValue:"attribute-value"},m={" ":d.space,"	":d.space,"\n":d.space,"\r":d.space,"<":d.lt,">":d.gt,'"':d.quote,"'":d.quote,"=":d.equal,"/":d.slash},_=function(J){return m[J]||d.char},f=function(J){var oe,ie,ne,le,ge,_e,ue,fe,pe,ye;J=Object.assign({debug:!1},J);var Me=new l,ve=h.data,he="",Qe="",Pe="",we="",Te="",Re="",Ee=function(Le,Ye){if(!(Qe[0]==="?"||Qe[0]==="!")){var tt={type:Le,value:Ye};J.debug&&console.log("emit:",tt),Me.emit("data",tt)}};Me.stateMachine=(ye={},u(ye,h.data,(oe={},u(oe,d.lt,function(){he.trim()&&Ee(p.text,he),Qe="",Te=!1,ve=h.tagBegin}),u(oe,d.char,function(Ce){he+=Ce}),oe)),u(ye,h.cdata,u({},d.char,function(Ce){he+=Ce,he.substr(-3)==="]]>"&&(Ee(p.text,he.slice(0,-3)),he="",ve=h.data)})),u(ye,h.tagBegin,(ie={},u(ie,d.space,g),u(ie,d.char,function(Ce){Qe=Ce,ve=h.tagName}),u(ie,d.slash,function(){Qe="",Te=!0}),ie)),u(ye,h.tagName,(ne={},u(ne,d.space,function(){Te?ve=h.tagEnd:(ve=h.attributeNameStart,Ee(p.openTag,Qe))}),u(ne,d.gt,function(){Ee(Te?p.closeTag:p.openTag,Qe),he="",ve=h.data}),u(ne,d.slash,function(){ve=h.tagEnd,Ee(p.openTag,Qe)}),u(ne,d.char,function(Ce){Qe+=Ce,Qe==="![CDATA["&&(ve=h.cdata,he="",Qe="")}),ne)),u(ye,h.tagEnd,(le={},u(le,d.gt,function(){Ee(p.closeTag,Qe),he="",ve=h.data}),u(le,d.char,g),le)),u(ye,h.attributeNameStart,(ge={},u(ge,d.char,function(Ce){Pe=Ce,ve=h.attributeName}),u(ge,d.gt,function(){he="",ve=h.data}),u(ge,d.space,g),u(ge,d.slash,function(){Te=!0,ve=h.tagEnd}),ge)),u(ye,h.attributeName,(_e={},u(_e,d.space,function(){ve=h.attributeNameEnd}),u(_e,d.equal,function(){Ee(p.attributeName,Pe),ve=h.attributeValueBegin}),u(_e,d.gt,function(){we="",Ee(p.attributeName,Pe),Ee(p.attributeValue,we),he="",ve=h.data}),u(_e,d.slash,function(){Te=!0,we="",Ee(p.attributeName,Pe),Ee(p.attributeValue,we),ve=h.tagEnd}),u(_e,d.char,function(Ce){Pe+=Ce}),_e)),u(ye,h.attributeNameEnd,(ue={},u(ue,d.space,g),u(ue,d.equal,function(){Ee(p.attributeName,Pe),ve=h.attributeValueBegin}),u(ue,d.gt,function(){we="",Ee(p.attributeName,Pe),Ee(p.attributeValue,we),he="",ve=h.data}),u(ue,d.char,function(Ce){we="",Ee(p.attributeName,Pe),Ee(p.attributeValue,we),Pe=Ce,ve=h.attributeName}),ue)),u(ye,h.attributeValueBegin,(fe={},u(fe,d.space,g),u(fe,d.quote,function(Ce){Re=Ce,we="",ve=h.attributeValue}),u(fe,d.gt,function(){we="",Ee(p.attributeValue,we),he="",ve=h.data}),u(fe,d.char,function(Ce){Re="",we=Ce,ve=h.attributeValue}),fe)),u(ye,h.attributeValue,(pe={},u(pe,d.space,function(Ce){Re?we+=Ce:(Ee(p.attributeValue,we),ve=h.attributeNameStart)}),u(pe,d.quote,function(Ce){Re===Ce?(Ee(p.attributeValue,we),ve=h.attributeNameStart):we+=Ce}),u(pe,d.gt,function(Ce){Re?we+=Ce:(Ee(p.attributeValue,we),he="",ve=h.data)}),u(pe,d.slash,function(Ce){Re?we+=Ce:(Ee(p.attributeValue,we),Te=!0,ve=h.tagEnd)}),u(pe,d.char,function(Ce){we+=Ce}),pe)),ye);var ke=function(Le){J.debug&&console.log(ve,Le);var Ye=Me.stateMachine[ve],tt=Ye[_(Le)]||Ye[d.error]||Ye[d.char];tt(Le)};return Me.write=function(Ce){for(var Le=Ce.length,Ye=0;Ye<Le;Ye++)ke(Ce[Ye])},Me},I={State:h,Action:d,Type:p,create:f},C=I.Type,y={element:"element",text:"text"},x=function(J){return Object.assign({name:"",type:y.element,value:"",parent:null,attributes:{},children:[]},J)},E=function(J){J=Object.assign({stream:!1,parentNodes:!0,doneEvent:"done",tagPrefix:"tag:",emitTopLevelOnly:!1,debug:!1},J);var oe=void 0,ie=void 0,ne=void 0,le=void 0,ge=new l,_e=function(fe){switch(fe.type){case C.openTag:if(ne===null)ne=ie,ne.name=fe.value;else{var pe=x({name:fe.value,parent:ne});ne.children.push(pe),ne=pe}break;case C.closeTag:var ye=ne.parent;if(J.parentNodes||(ne.parent=null),ne.name!==fe.value)break;J.stream&&ye===ie&&(ie.children=[],ne.parent=null),(!J.emitTopLevelOnly||ye===ie)&&(ge.emit(J.tagPrefix+ne.name,ne),ge.emit("tag",ne.name,ne)),ne===ie&&(oe.removeAllListeners("data"),ge.emit(J.doneEvent,ne),ie=null),ne=ye;break;case C.text:ne&&ne.children.push(x({type:y.text,value:fe.value,parent:J.parentNodes?ne:null}));break;case C.attributeName:le=fe.value,ne.attributes[le]="";break;case C.attributeValue:ne.attributes[le]=fe.value;break}};return ge.reset=function(){oe=I.create({debug:J.debug}),oe.on("data",_e),ie=x(),ne=null,le="",ge.parse=oe.write},ge.reset(),ge},B=function(J,oe){oe=Object.assign({},oe,{stream:!1,tagPrefix:":"});var ie=E(oe),ne=void 0;return ie.on("done",function(le){ne=le}),ie.parse(J),ne},S={parseSync:B},Q=S.parseSync,w=function(J){var oe=Q("<root>".concat(J,"</root>"),{parentNodes:!1}),ie=oe.children&&oe.children.length>0&&oe.children.every(function(ne){return ne.name==="svg"});if(ie)return oe.children.length===1?oe.children[0]:oe.children;throw Error("nothing to parse")},M=function(J){return c(J,function(oe){return R(oe)?oe:k(oe)})},k=function(J){return J.replace(/[-|:]([a-z])/gi,function(oe,ie){return ie.toUpperCase()})},R=function(J){return/^(data|aria)(-\w+)/.test(J)},F=function(J){if(J){var oe=String(J);return/[&<>]/.test(oe)?"<![CDATA[".concat(oe.replace(/]]>/,"]]]]><![CDATA[>"),"]]>"):oe}return""},O=function(J){return String(J).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},U=function(J){var oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=oe.transformNode,ne=ie===void 0?function(ue){return ue}:ie,le=oe.camelcase,ge=le===void 0?!1:le,_e=function(fe){var pe;return pe=ne(fe),ge&&(pe=M(pe)),pe};return _e(w(J))};function Y(){for(var j=arguments.length,J=new Array(j),oe=0;oe<j;oe++)J[oe]=arguments[oe];return new Promise(function(ie,ne){try{var le=U.apply(void 0,J);ie(le)}catch(ge){ne(ge)}})}var W=function j(J){var oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=oe.transformAttr,ne=ie===void 0?function(ve,he,Qe){return"".concat(ve,'="').concat(Qe(he),'"')}:ie,le=oe.transformNode,ge=le===void 0?function(ve){return ve}:le,_e=oe.selfClose,ue=_e===void 0?!0:_e;if(Array.isArray(J))return J.map(function(ve){return j(ve,{transformAttr:ne,selfClose:ue,transformNode:ge})}).join("");var fe=ge(J);if(fe.type==="text")return F(fe.value);var pe="";for(var ye in fe.attributes){var Me=ne(ye,fe.attributes[ye],O,fe.name);pe+=Me?" ".concat(Me):""}return fe.children&&fe.children.length>0||!ue?"<".concat(fe.name).concat(pe,">").concat(j(fe.children,{transformAttr:ne,transformNode:ge,selfClose:ue}),"</").concat(fe.name,">"):"<".concat(fe.name).concat(pe,"/>")},te=Object.assign({},{parse:Y,parseSync:U,stringify:W});return te})}}),Zgn=ee.createContext(null),eTi=()=>ee.useContext(Zgn),edn=!0,tTi=!1,eee={CCW:-1,CW:1,NOT_ORIENTABLE:0},nTi=2*Math.PI,q_e=1,tdn=0,W6=2,oTi=3,iTi=4,rTi=1,sTi=2,zje=0,tee=1,FU=2,X_e=Object.freeze({__proto__:null,BOUNDARY:W6,CCW:edn,CONTAINS:oTi,CW:tTi,END_VERTEX:FU,INSIDE:q_e,INTERLACE:iTi,NOT_VERTEX:zje,ORIENTATION:eee,OUTSIDE:tdn,OVERLAP_OPPOSITE:sTi,OVERLAP_SAME:rTi,PIx2:nTi,START_VERTEX:tee}),j6=1e-6;function ndn(t){j6=t}function odn(){return j6}var aTi=3;function Jje(t){return t<j6&&t>-j6}function LT(t,e){return t-e<j6&&t-e>-j6}function idn(t,e){return t-e>j6}function ATi(t,e){return t-e>-j6}function rdn(t,e){return t-e<-j6}function cTi(t,e){return t-e<j6}var lTi=Object.freeze({__proto__:null,DECIMALS:aTi,EQ:LT,EQ_0:Jje,GE:ATi,GT:idn,LE:cTi,LT:rdn,getTolerance:odn,setTolerance:ndn}),Ue={Utils:lTi,Errors:void 0,Matrix:void 0,Planar_set:void 0,Point:void 0,Vector:void 0,Line:void 0,Circle:void 0,Segment:void 0,Arc:void 0,Box:void 0,Edge:void 0,Face:void 0,Ray:void 0,Ray_shooting:void 0,Multiline:void 0,Polygon:void 0,Distance:void 0,Inversion:void 0};for(let t in X_e)Ue[t]=X_e[t];Object.defineProperty(Ue,"DP_TOL",{get:function(){return odn()},set:function(t){ndn(t)}});var wd=class{static get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")}static get ZERO_DIVISION(){return new Error("Zero division")}static get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")}static get INFINITE_LOOP(){return new Error("Infinite loop")}static get CANNOT_COMPLETE_BOOLEAN_OPERATION(){return new Error("Cannot complete boolean operation")}static get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")}static get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")}static get UNSUPPORTED_SHAPE_TYPE(){return new Error("Unsupported shape type")}};Ue.Errors=wd;var Wje=class{constructor(t,e){this.first=t,this.last=e||this.first}[Symbol.iterator](){let t;return{next:()=>(t=t?t.next:this.first,{value:t,done:t===void 0})}}get size(){let t=0;for(let e of this)t++;return t}toArray(t=void 0,e=void 0){let n=[],o=t||this.first,i=e||this.last,r=o;if(r===void 0)return n;do n.push(r),r=r.next;while(r!==i.next);return n}append(t){return this.isEmpty()?this.first=t:(t.prev=this.last,this.last.next=t),this.last=t,this.last.next=void 0,this.first.prev=void 0,this}insert(t,e){if(this.isEmpty())this.first=t,this.last=t;else if(e==null)t.next=this.first,this.first.prev=t,this.first=t;else{let n=e.next;e.next=t,n&&(n.prev=t),t.prev=e,t.next=n,this.last===e&&(this.last=t)}return this.last.next=void 0,this.first.prev=void 0,this}remove(t){return t===this.first&&t===this.last?(this.first=void 0,this.last=void 0):(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this.first&&(this.first=t.next),t===this.last&&(this.last=t.prev)),this}isEmpty(){return this.first===void 0}static testInfiniteLoop(t){let e=t,n=t;do{if(e!=t&&e===n)throw wd.INFINITE_LOOP;e=e.next,n=n.next.next}while(e!=t)}},sdn={stroke:"black"},uTi=class{constructor(t=sdn){for(const e in t)this[e]=t[e];this.stroke=t.stroke??sdn.stroke}toAttributesString(){return Object.keys(this).reduce((t,e)=>t+(this[e]!==void 0?this.toAttrString(e,this[e]):""),"")}toAttrString(t,e){const n=t==="className"?"class":this.convertCamelToKebabCase(t);return e===null?`${n} `:`${n}="${e.toString()}" `}convertCamelToKebabCase(t){return t.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).join("-").toLowerCase()}};function HT(t){return new uTi(t).toAttributesString()}function LU(t,e){let n=[],[o,i,r]=t.standard,[s,a,A]=e.standard,c=o*a-i*s,l=r*a-i*A,u=o*A-r*s;if(!Ue.Utils.EQ_0(c)){let g,h;i===0?(g=r/o,h=u/c):a===0?(g=A/s,h=u/c):o===0?(g=l/c,h=r/i):s===0?(g=l/c,h=A/a):(g=l/c,h=u/c),n.push(new Ue.Point(g,h))}return n}function OT(t,e){let n=[],o=e.pc.projectionOn(t),i=e.pc.distanceTo(o)[0];if(Ue.Utils.EQ(i,e.r))n.push(o);else if(Ue.Utils.LT(i,e.r)){let r=Math.sqrt(e.r*e.r-i*i),s,a;s=t.norm.rotate90CCW().multiply(r),a=o.translate(s),n.push(a),s=t.norm.rotate90CW().multiply(r),a=o.translate(s),n.push(a)}return n}function HU(t,e){let n=[];for(let o of e.toSegments()){let i=nee(o,t);for(let r of i)_dn(r,n)||n.push(r)}return n}function Z_e(t,e){let n=[];if(HU(t,e.box).length===0)return n;let o=new Ue.Circle(e.pc,e.r),i=OT(t,o);for(let r of i)r.on(e)&&n.push(r);return n}function nee(t,e){let n=[];if(t.ps.on(e)&&n.push(t.ps),t.pe.on(e)&&!t.isZeroLength()&&n.push(t.pe),n.length>0||t.isZeroLength()||t.ps.leftTo(e)&&t.pe.leftTo(e)||!t.ps.leftTo(e)&&!t.pe.leftTo(e))return n;let o=new Ue.Line(t.ps,t.pe);return LU(o,e)}function efe(t,e){let n=[];if(t.isZeroLength())return t.ps.on(e)&&n.push(t.ps),n;if(e.isZeroLength())return e.ps.on(t)&&n.push(e.ps),n;let o=new Ue.Line(t.ps,t.pe),i=new Ue.Line(e.ps,e.pe);if(o.incidentTo(i))t.ps.on(e)&&n.push(t.ps),t.pe.on(e)&&n.push(t.pe),e.ps.on(t)&&!e.ps.equalTo(t.ps)&&!e.ps.equalTo(t.pe)&&n.push(e.ps),e.pe.on(t)&&!e.pe.equalTo(t.ps)&&!e.pe.equalTo(t.pe)&&n.push(e.pe);else if(o.parallelTo(i)){const r=new Ue.Vector(t.ps,t.pe),s=new Ue.Vector(e.ps,e.pe),a=new Ue.Vector(t.ps,e.ps),A=r.cross(s);if(!Ue.Utils.EQ_0(A)){const c=a.cross(s)/A,l=a.cross(r)/A;Ue.Utils.GE(c,0)&&Ue.Utils.LE(c,1)&&Ue.Utils.GE(l,0)&&Ue.Utils.LE(l,1)&&n.push(adn(t.ps.translate(r.multiply(c)),t,e))}}else{let r=LU(o,i);r.length>0&&Adn(r[0],t)&&Adn(r[0],e)&&n.push(adn(r[0],t,e))}return n}function adn(t,e,n){for(const o of[e.ps,e.pe,n.ps,n.pe])if(t.equalTo(o))return o;return t}function Adn(t,e){const n=e.box;return Ue.Utils.LE(t.x,n.xmax)&&Ue.Utils.GE(t.x,n.xmin)&&Ue.Utils.LE(t.y,n.ymax)&&Ue.Utils.GE(t.y,n.ymin)}function tfe(t,e){let n=[];if(t.isZeroLength()){let[r,s]=t.ps.distanceTo(e.pc);return Ue.Utils.EQ(r,e.r)&&n.push(t.ps),n}let o=new Ue.Line(t.ps,t.pe),i=OT(o,e);for(let r of i)r.on(t)&&n.push(r);return n}function OU(t,e){let n=[];if(t.isZeroLength())return t.ps.on(e)&&n.push(t.ps),n;let o=new Ue.Line(t.ps,t.pe),i=new Ue.Circle(e.pc,e.r),r=OT(o,i);for(let s of r)s.on(t)&&s.on(e)&&n.push(s);return n}function gTi(t,e){let n=[];for(let o of e.toSegments()){let i=efe(o,t);for(let r of i)n.push(r)}return n}function cdn(t,e){let n=[],o=new Ue.Vector(t.pc,e.pc),i=t.r,r=e.r;if(Ue.Utils.EQ_0(i)||Ue.Utils.EQ_0(r))return n;if(Ue.Utils.EQ_0(o.x)&&Ue.Utils.EQ_0(o.y)&&Ue.Utils.EQ(i,r))return n.push(t.pc.translate(-i,0)),n;let s=t.pc.distanceTo(e.pc)[0];if(Ue.Utils.GT(s,i+r)||Ue.Utils.LT(s,Math.abs(i-r)))return n;o.x/=s,o.y/=s;let a;if(Ue.Utils.EQ(s,i+r)||Ue.Utils.EQ(s,Math.abs(i-r)))return a=t.pc.translate(i*o.x,i*o.y),n.push(a),n;let A=i*i/(2*s)-r*r/(2*s)+s/2,c=t.pc.translate(A*o.x,A*o.y),l=Math.sqrt(i*i-A*A);return a=c.translate(o.rotate90CCW().multiply(l)),n.push(a),a=c.translate(o.rotate90CW().multiply(l)),n.push(a),n}function dTi(t,e){let n=[];for(let o of e.toSegments()){let i=tfe(o,t);for(let r of i)n.push(r)}return n}function ldn(t,e){let n=[];if(t.pc.equalTo(e.pc)&&Ue.Utils.EQ(t.r,e.r)){let s;return s=t.start,s.on(e)&&n.push(s),s=t.end,s.on(e)&&n.push(s),s=e.start,s.on(t)&&n.push(s),s=e.end,s.on(t)&&n.push(s),n}let o=new Ue.Circle(t.pc,t.r),i=new Ue.Circle(e.pc,e.r),r=o.intersect(i);for(let s of r)s.on(t)&&s.on(e)&&n.push(s);return n}function jje(t,e){let n=[];if(e.pc.equalTo(t.pc)&&Ue.Utils.EQ(e.r,t.r))return n.push(t.start),n.push(t.end),n;let o=e,i=new Ue.Circle(t.pc,t.r),r=cdn(o,i);for(let s of r)s.on(t)&&n.push(s);return n}function hTi(t,e){let n=[];for(let o of e.toSegments()){let i=OU(o,t);for(let r of i)n.push(r)}return n}function udn(t,e){return t.isSegment?efe(t.shape,e):OU(e,t.shape)}function gdn(t,e){return t.isSegment?OU(t.shape,e):ldn(t.shape,e)}function ddn(t,e){return t.isSegment?nee(t.shape,e):Z_e(e,t.shape)}function pTi(t,e){return t.isSegment?Xje(e,t.shape):Zje(e,t.shape)}function mTi(t,e){return t.isSegment?tfe(t.shape,e):jje(t.shape,e)}function $je(t,e){let n=[];for(let o of e.edges)for(let i of udn(o,t))n.push(i);return n}function qje(t,e){let n=[];for(let o of e.edges)for(let i of gdn(o,t))n.push(i);return n}function oee(t,e){let n=[];if(e.isEmpty())return n;for(let o of e.edges)for(let i of ddn(o,t))_dn(i,n)||n.push(i);return t.sortPoints(n)}function hdn(t,e){let n=[];if(e.isEmpty())return n;for(let o of e.edges)for(let i of mTi(o,t))n.push(i);return n}function pdn(t,e){return t.isSegment?udn(e,t.shape):t.isArc?gdn(e,t.shape):t.isLine?ddn(e,t.shape):t.isRay?pTi(e,t.shape):[]}function mdn(t,e){let n=[];if(e.isEmpty()||t.shape.box.not_intersect(e.box))return n;let o=e.edges.search(t.shape.box);for(let i of o)n=[...n,...pdn(t,i)];return n}function _Ti(t,e){let n=[];if(e.isEmpty()||t.size===0)return n;for(let o of t)n=[...n,...mdn(o,e)];return n}function fTi(t,e){let n=[];if(t.isEmpty()||e.isEmpty()||t.box.not_intersect(e.box))return n;for(let o of t.edges)n=[...n,...mdn(o,e)];return n}function ITi(t,e){return t instanceof Ue.Line?oee(t,e):t instanceof Ue.Segment?$je(t,e):t instanceof Ue.Arc?qje(t,e):[]}function _dn(t,e){return e.some(n=>n.equalTo(t))}function kP(t){return new Ue.Line(t.start,t.norm)}function Xje(t,e){return nee(e,kP(t)).filter(n=>t.contains(n))}function Zje(t,e){return Z_e(kP(t),e).filter(n=>t.contains(n))}function fdn(t,e){return OT(kP(t),e).filter(n=>t.contains(n))}function CTi(t,e){return HU(kP(t),e).filter(n=>t.contains(n))}function Idn(t,e){return LU(kP(t),e).filter(n=>t.contains(n))}function yTi(t,e){return LU(kP(t),kP(e)).filter(n=>t.contains(n)).filter(n=>e.contains(n))}function Cdn(t,e){return oee(kP(t),e).filter(n=>t.contains(n))}function ydn(t,e){if(t.intersect&&t.intersect instanceof Function)return t.intersect(e);throw wd.UNSUPPORTED_SHAPE_TYPE}function GU(t,e){let n=[];for(let o of e)n=[...n,...ydn(t,o.shape)];return n}function xTi(t,e){let n=[];for(let o of t)for(let i of e)n=[...n,...ydn(o.shape,i.shape)];return n}var GT=class ene extends Wje{constructor(...e){if(super(),this.isInfinite=!1,e.length===1&&e[0]instanceof Array&&e[0].length>0){const n=e[0],o=n.length,i=A=>A instanceof Ue.Segment||A instanceof Ue.Arc||A instanceof Ue.Ray||A instanceof Ue.Line,r=A=>A instanceof Ue.Segment||A instanceof Ue.Arc||A instanceof Ue.Ray,s=A=>A instanceof Ue.Segment||A instanceof Ue.Arc;if(o===1&&i(n[0])||o>1&&r(n[0])&&r(n[o-1])&&n.slice(1,o-1).every(s)){this.isInfinite=n.some(A=>A instanceof Ue.Ray||A instanceof Ue.Line);for(let A of n){let c=new Ue.Edge(A);this.append(c)}this.setArcLength()}else throw Ue.Errors.ILLEGAL_PARAMETERS}}get edges(){return[...this]}get box(){return this.edges.reduce((e,n)=>e.merge(n.box),new Ue.Box)}get vertices(){let e=this.edges.map(n=>n.start);return e.push(this.last.end),e}get length(){if(this.isEmpty())return 0;if(this.isInfinite)return Number.POSITIVE_INFINITY;let e=0;for(let n of this)e+=n.length;return e}clone(){return new ene(this.toShapes())}setArcLength(){for(let e of this)this.setOneEdgeArcLength(e)}setOneEdgeArcLength(e){e===this.first?e.arc_length=0:e.arc_length=e.prev.arc_length+e.prev.length}pointAtLength(e){if(e>this.length||e<0||this.isInfinite)return null;let n=null;for(let o of this)if(e>=o.arc_length&&(o===this.last||e<o.next.arc_length)){n=o.pointAtLength(e-o.arc_length);break}return n}addVertex(e,n){let o=n.shape.split(e);if(o[0]===null)return n.prev;if(o[1]===null)return n;let i=new Ue.Edge(o[0]),r=n.prev;return this.insert(i,r),n.shape=o[1],i}getChain(e,n){let o=[];for(let i=e;i!==n.next;i=i.next)o.push(i);return o}split(e){for(let n of e){let o=this.findEdgeByPoint(n);this.addVertex(n,o)}return this}findEdgeByPoint(e){let n;for(let o of this)if(o.shape.contains(e)){n=o;break}return n}distanceTo(e){if(e instanceof Ue.Point){const[n,o]=Ue.Distance.shape2multiline(e,this);return[n,o.reverse()]}if(e instanceof Ue.Line){const[n,o]=Ue.Distance.shape2multiline(e,this);return[n,o.reverse()]}if(e instanceof Ue.Circle){const[n,o]=Ue.Distance.shape2multiline(e,this);return[n,o.reverse()]}if(e instanceof Ue.Segment){const[n,o]=Ue.Distance.shape2multiline(e,this);return[n,o.reverse()]}if(e instanceof Ue.Arc){const[n,o]=Ue.Distance.shape2multiline(e,this);return[n,o.reverse()]}if(e instanceof Ue.Box){const[n,o]=Ue.Distance.shape2multiline(new Ue.Polygon(e),this);return[n,o.reverse()]}if(e instanceof Ue.Multiline)return Ue.Distance.multiline2multiline(this,e);throw Ue.Errors.UNSUPPORTED_SHAPE_TYPE}intersect(e){return e instanceof Ue.Multiline?xTi(this,e):GU(e,this)}contains(e){if(e instanceof Ue.Point)return this.edges.some(n=>n.shape.contains(e));throw Ue.Errors.UNSUPPORTED_SHAPE_TYPE}translate(e){return new ene(this.edges.map(n=>n.shape.translate(e)))}rotate(e=0,n=new Ue.Point){return new ene(this.edges.map(o=>o.shape.rotate(e,n)))}transform(e=new Ue.Matrix){return new ene(this.edges.map(n=>n.shape.transform(e)))}toShapes(){return this.edges.map(e=>e.shape.clone())}toJSON(){return this.edges.map(e=>e.toJSON())}svgPoints(){return this.vertices.map(e=>`${e.x},${e.y}`).join(" ")}dpath(){let e=`M${this.first.start.x},${this.first.start.y}`;for(let n of this)e+=n.svg();return e}svg(e={}){let n=`
<path ${HT({fill:"none",...e})} d="`;n+=`
M${this.first.start.x},${this.first.start.y}`;for(let o of this)n+=o.svg();return n+=`" >
</path>`,n}};Ue.Multiline=GT;var ETi=(...t)=>new Ue.Multiline(...t);Ue.multiline=ETi;function YU(t,e,n){let o=n.length,i=t.shape.split(e);if(i.length===0)return;let r=0;i[0]===null?r=0:i[1]===null?r=t.shape.length:r=i[0].length;let s=zje;LT(r,0)&&(s|=tee),LT(r,t.shape.length)&&(s|=FU);let a;r===1/0?a=i[0].coord(e):a=s&FU&&t.next&&t.next.arc_length===0?0:t.arc_length+r,n.push({id:o,pt:e,arc_length:a,edge_before:t,edge_after:void 0,face:t.face,is_vertex:s})}function iee(t){t.int_points1_sorted=FP(t.int_points1),t.int_points2_sorted=FP(t.int_points2)}function FP(t){let e=new Map,n=0;for(let i of t)e.has(i.face)||(e.set(i.face,n),n++);for(let i of t)i.faceId=e.get(i.face);return t.slice().sort(BTi)}function BTi(t,e){return t.faceId<e.faceId?-1:t.faceId>e.faceId?1:t.arc_length<e.arc_length?-1:t.arc_length>e.arc_length?1:0}function e$e(t){if(t.int_points1.length<2)return;let e=!1,n,o,i,r;for(let s=0;s<t.int_points1_sorted.length;s++)if(t.int_points1_sorted[s].id!==-1){n=t.int_points1_sorted[s],o=t.int_points2[n.id];for(let a=s+1;a<t.int_points1_sorted.length&&(i=t.int_points1_sorted[a],!!LT(i.arc_length,n.arc_length));a++)i.id!==-1&&(r=t.int_points2[i.id],r.id!==-1&&i.edge_before===n.edge_before&&i.edge_after===n.edge_after&&r.edge_before===o.edge_before&&r.edge_after===o.edge_after&&(i.id=-1,r.id=-1,e=!0))}o=t.int_points2_sorted[0],n=t.int_points1[o.id];for(let s=1;s<t.int_points2_sorted.length;s++){let a=t.int_points2_sorted[s];if(a.id===-1)continue;if(o.id===-1||!LT(a.arc_length,o.arc_length)){o=a,n=t.int_points1[o.id];continue}let A=t.int_points1[a.id];A.edge_before===n.edge_before&&A.edge_after===n.edge_after&&a.edge_before===o.edge_before&&a.edge_after===o.edge_after&&(A.id=-1,a.id=-1,e=!0)}e&&(t.int_points1=t.int_points1.filter(s=>s.id>=0),t.int_points2=t.int_points2.filter(s=>s.id>=0),t.int_points1.forEach((s,a)=>s.id=a),t.int_points2.forEach((s,a)=>s.id=a))}function t$e(t){for(let e of t)e.edge_before&&(e.edge_before.bvStart=void 0,e.edge_before.bvEnd=void 0,e.edge_before.bv=void 0,e.edge_before.overlap=void 0),e.edge_after&&(e.edge_after.bvStart=void 0,e.edge_after.bvEnd=void 0,e.edge_after.bv=void 0,e.edge_after.overlap=void 0);for(let e of t)e.edge_before&&(e.edge_before.bvEnd=W6),e.edge_after&&(e.edge_after.bvStart=W6)}function n$e(t,e){for(let n of t)n.edge_before&&n.edge_before.setInclusion(e),n.edge_after&&n.edge_after.setInclusion(e)}function bTi(t){let e,n,o,i=t.int_points1.length;for(let r=0;r<i;r++){let s=t.int_points1_sorted[r];s.face!==e&&(n=r,e=s.face);let a=r,A=UU(t.int_points1_sorted,r,e),c;a+A<i&&t.int_points1_sorted[a+A].face===e?c=a+A:c=n;let l=UU(t.int_points1_sorted,c,e);o=null;for(let _=c;_<c+l;_++){let f=t.int_points1_sorted[_];if(f.face===e&&t.int_points2[f.id].face===t.int_points2[s.id].face){o=f;break}}if(o===null)continue;let u=s.edge_after,g=o.edge_before;if(!(u.bv===W6&&g.bv===W6)||u!==g)continue;let h=t.int_points2[s.id],d=t.int_points2[o.id],p=h.edge_after,m=d.edge_before;p.bv===W6&&m.bv===W6&&p===m||(h=t.int_points2[o.id],d=t.int_points2[s.id],p=h.edge_after,m=d.edge_before),p.bv===W6&&m.bv===W6&&p===m&&u.setOverlap(p)}}function UU(t,e,n){let o,i,r=1;if(t.length===1)return 1;o=t[e];for(let s=e+1;s<t.length&&!(o.face!==n||(i=t[s],!(i.pt.equalTo(o.pt)&&i.edge_before===o.edge_before&&i.edge_after===o.edge_after)));s++)r++;return r}function KU(t,e){if(e){for(let n of e){let o=n.edge_before;if(n.is_vertex=zje,o.shape.start&&o.shape.start.equalTo(n.pt)&&(n.is_vertex|=tee),o.shape.end&&o.shape.end.equalTo(n.pt)&&(n.is_vertex|=FU),n.is_vertex&tee){n.edge_before=o.prev,o.prev&&(n.is_vertex=FU);continue}if(n.is_vertex&FU)continue;let i=t.addVertex(n.pt,o);n.edge_before=i}for(let n of e)n.edge_before?n.edge_after=n.edge_before.next:t instanceof GT&&n.is_vertex&tee&&(n.edge_after=t.first)}}function xdn(t,e,n){const o=t.edge_before,i=e.edge_after,r=n.length;o.next=n[0],n[0].prev=o,n[r-1].next=i,i.prev=n[r-1]}var{INSIDE:$6,OUTSIDE:q6,BOUNDARY:p1,OVERLAP_SAME:STi,OVERLAP_OPPOSITE:QTi}=X_e,{NOT_VERTEX:wmr,START_VERTEX:Edn,END_VERTEX:Bdn}=X_e,nfe=1,ree=2,YT=3;function vTi(t,e){let[n]=see(t,e,nfe,!0);return n}function o$e(t,e){let o=e.clone().reverse(),[i]=see(t,o,YT,!0);return i}function bdn(t,e){let[n]=see(t,e,ree,!0);return n}function Sdn(t,e){let[n,o]=see(t,e,ree,!1),i=[];for(let s of n.faces)i=[...i,...[...s.edges].map(a=>a.shape)];let r=[];for(let s of o.faces)r=[...r,...[...s.edges].map(a=>a.shape)];return[i,r]}function i$e(t,e){let[n]=see(t,e,YT,!1),o=[];for(let i of n.faces)o=[...o,...[...i.edges].map(r=>r.shape)];return o}function Qdn(t,e){let n=t.clone(),o=e.clone(),i=vdn(n,o);iee(i),KU(n,i.int_points1_sorted),KU(o,i.int_points2_sorted),e$e(i),iee(i);let r=i.int_points1_sorted.map(a=>a.pt),s=i.int_points2_sorted.map(a=>a.pt);return[r,s]}function wTi(t,e,n,o){let i=wdn(t,n.int_points1),r=wdn(e,n.int_points2);for(Pdn(i,e),Pdn(r,t),t$e(n.int_points1),t$e(n.int_points2),n$e(n.int_points1,e),n$e(n.int_points2,t);MTi(t,e,n.int_points1,n.int_points1_sorted,n.int_points2,n););bTi(n),r$e(t,o,n.int_points1_sorted,!0),r$e(e,o,n.int_points2_sorted,!1),Mdn(t,i,o,!0),Mdn(e,r,o,!1)}function PTi(t,e,n,o){DTi(t,e,o,n.int_points2),NTi(t,e,n),s$e(t,n.int_points1),s$e(e,n.int_points2),a$e(t,n.int_points1,n.int_points2),a$e(t,n.int_points2,n.int_points1),Ddn(t),Ddn(e)}function see(t,e,n,o){let i=t.clone(),r=e.clone(),s=vdn(i,r);return iee(s),KU(i,s.int_points1_sorted),KU(r,s.int_points2_sorted),e$e(s),iee(s),wTi(i,r,s,n),o&&PTi(i,r,s,n),[i,r]}function vdn(t,e){let n={int_points1:[],int_points2:[]};for(let o of t.edges){let i=e.edges.search(o.box);for(let r of i){let s=o.shape.intersect(r.shape);for(let a of s)YU(o,a,n.int_points1),YU(r,a,n.int_points2)}}return n}function wdn(t,e){let n=[];for(let o of t.faces)e.find(i=>i.face===o)||n.push(o);return n}function Pdn(t,e){for(let n of t)n.first.bv=n.first.bvStart=n.first.bvEnd=void 0,n.first.setInclusion(e)}function MTi(t,e,n,o,i,r){let s,a,A,c=o.length,l=!1;for(let u=0;u<c;u++){let g=o[u];g.face!==s&&(a=u,s=g.face);let h=u,d=UU(o,u,s),p;h+d<c&&o[h+d].face===s?p=h+d:p=a;let m=UU(o,p,s);A=null;for(let I=p;I<p+m;I++){let C=o[I];if(C.face===s&&i[C.id].face===i[g.id].face){A=C;break}}if(A===null)continue;let _=g.edge_after,f=A.edge_before;if(_.bv===p1&&f.bv!=p1){_.bv=f.bv;continue}if(_.bv!=p1&&f.bv===p1){f.bv=_.bv;continue}if(_.bv===p1&&f.bv===p1&&_!=f||_.bv===$6&&f.bv===q6||_.bv===q6&&f.bv===$6){let I=_.next;for(;I!=f;)I.bvStart=void 0,I.bvEnd=void 0,I.bv=void 0,I.setInclusion(e),I=I.next}if(_.bv===p1&&f.bv===p1&&_!=f){let I=_.next,C;for(;I!=f;){if(I.bv!=p1){if(C===void 0)C=I.bv;else if(I.bv!=C)throw wd.UNRESOLVED_BOUNDARY_CONFLICT}I=I.next}C!=null&&(_.bv=C,f.bv=C);continue}if(_.bv===$6&&f.bv===q6||_.bv===q6&&f.bv===$6){let I=_;for(;I!=f;){if(I.bvStart===_.bv&&I.bvEnd===f.bv){let[C,y]=I.shape.distanceTo(e);if(C<10*Ue.DP_TOL){YU(I,y.ps,n);let x=n[n.length-1];if(x.is_vertex&Edn)x.edge_after=I,x.edge_before=I.prev,I.bvStart=p1,I.bv=void 0,I.setInclusion(e);else if(x.is_vertex&Bdn)x.edge_after=I.next,I.bvEnd=p1,I.bv=void 0,I.setInclusion(e);else{let S=e.addVertex(x.pt,I);x.edge_before=S,x.edge_after=S.next,S.setInclusion(e),S.next.bvStart=p1,S.next.bvEnd=void 0,S.next.bv=void 0,S.next.setInclusion(e)}let E=e.findEdgeByPoint(y.pe);YU(E,y.pe,i);let B=i[i.length-1];if(B.is_vertex&Edn)B.edge_after=E,B.edge_before=E.prev;else if(B.is_vertex&Bdn)B.edge_after=E.next;else{let S=i.find(w=>w.edge_after===E),Q=e.addVertex(B.pt,E);B.edge_before=Q,B.edge_after=Q.next,S&&(S.edge_after=Q),Q.bvStart=void 0,Q.bvEnd=p1,Q.bv=void 0,Q.setInclusion(t),Q.next.bvStart=p1,Q.next.bvEnd=void 0,Q.next.bv=void 0,Q.next.setInclusion(t)}iee(r),l=!0;break}}I=I.next}if(l)break;throw wd.UNRESOLVED_BOUNDARY_CONFLICT}}return l}function r$e(t,e,n,o){if(!n)return;let i,r,s,a;for(let A=0;A<n.length;A++){if(s=n[A],s.face!==i&&(r=A,i=s.face),i.isEmpty())continue;let c=A,l=UU(n,A,i),u;c+l<n.length&&n[c+l].face===s.face?u=c+l:u=r,a=n[u];let g=u,h=UU(n,g,i),d=s.edge_after,p=a.edge_before;if(d.bv===$6&&p.bv===$6&&e===nfe||d.bv===q6&&p.bv===q6&&e===ree||(d.bv===q6||p.bv===q6)&&e===YT&&!o||(d.bv===$6||p.bv===$6)&&e===YT&&o||d.bv===p1&&p.bv===p1&&d.overlap&STi&&o||d.bv===p1&&p.bv===p1&&d.overlap&QTi){t.removeChain(i,d,p);for(let m=c;m<c+l;m++)n[m].edge_after=void 0;for(let m=g;m<g+h;m++)n[m].edge_before=void 0}A+=l-1}}function DTi(t,e,n,o){for(let i of e.faces){for(let r of i)t.edges.add(r);o.find(r=>r.face===i)===void 0&&t.addFace(i.first,i.last)}}function NTi(t,e,n){if(n.int_points1.length!==0)for(let o=0;o<n.int_points1.length;o++){let i=n.int_points1[o],r=n.int_points2[o];if(i.edge_before!==void 0&&i.edge_after===void 0&&r.edge_before===void 0&&r.edge_after!==void 0&&(i.edge_before.next=r.edge_after,r.edge_after.prev=i.edge_before,i.edge_after=r.edge_after,r.edge_before=i.edge_before),r.edge_before!==void 0&&r.edge_after===void 0&&i.edge_before===void 0&&i.edge_after!==void 0&&(r.edge_before.next=i.edge_after,i.edge_after.prev=r.edge_before,r.edge_after=i.edge_after,i.edge_before=r.edge_before),i.edge_before!==void 0&&i.edge_after===void 0)for(let s of n.int_points1_sorted)s!==i&&s.edge_before===void 0&&s.edge_after!==void 0&&s.pt.equalTo(i.pt)&&(i.edge_before.next=s.edge_after,s.edge_after.prev=i.edge_before,i.edge_after=s.edge_after,s.edge_before=i.edge_before);if(r.edge_before!==void 0&&r.edge_after===void 0)for(let s of n.int_points2_sorted)s!==r&&s.edge_before===void 0&&s.edge_after!==void 0&&s.pt.equalTo(r.pt)&&(r.edge_before.next=s.edge_after,s.edge_after.prev=r.edge_before,r.edge_after=s.edge_after,s.edge_before=r.edge_before)}}function s$e(t,e){for(let n of e)t.faces.delete(n.face),n.face=void 0,n.edge_before&&(n.edge_before.face=void 0),n.edge_after&&(n.edge_after.face=void 0)}function a$e(t,e,n){for(let o of e){if(o.edge_before===void 0||o.edge_after===void 0||o.face||o.edge_after.face||o.edge_before.face)continue;let i=o.edge_after,r=o.edge_before;try{Wje.testInfiniteLoop(i)}catch{throw wd.CANNOT_COMPLETE_BOOLEAN_OPERATION}let s=t.addFace(i,r);for(let a of e)a.edge_before&&a.edge_after&&a.edge_before.face===s&&a.edge_after.face===s&&(a.face=s);for(let a of n)a.edge_before&&a.edge_after&&a.edge_before.face===s&&a.edge_after.face===s&&(a.face=s)}}function Mdn(t,e,n,o){for(let i of e){let r=i.first.bv;(n===nfe&&r===$6||n===YT&&r===$6&&o||n===YT&&r===q6&&!o||n===ree&&r===q6)&&t.deleteFace(i)}}function Ddn(t){const e=[];for(const n of t.edges)(!n.face||!t.faces.has(n.face))&&e.push(n);for(const n of e)t.edges.delete(n)}var RTi=Object.freeze({__proto__:null,BOOLEAN_INTERSECT:ree,BOOLEAN_SUBTRACT:YT,BOOLEAN_UNION:nfe,calculateIntersections:Qdn,innerClip:Sdn,intersect:bdn,outerClip:i$e,removeNotRelevantChains:r$e,removeOldFaces:s$e,restoreFaces:a$e,subtract:o$e,unify:vTi}),TTi=RegExp("T.F..FFF.|T.F...F.."),kTi=RegExp("T........|.T.......|...T.....|....T...."),FTi=RegExp("FT.......|F..T.....|F...T...."),LTi=RegExp("T.F..F..."),HTi=RegExp("T.F..F...|.TF..F...|..FT.F...|..F.TF..."),VU=class{constructor(){this.m=new Array(9).fill(void 0)}get I2I(){return this.m[0]}set I2I(t){this.m[0]=t}get I2B(){return this.m[1]}set I2B(t){this.m[1]=t}get I2E(){return this.m[2]}set I2E(t){this.m[2]=t}get B2I(){return this.m[3]}set B2I(t){this.m[3]=t}get B2B(){return this.m[4]}set B2B(t){this.m[4]=t}get B2E(){return this.m[5]}set B2E(t){this.m[5]=t}get E2I(){return this.m[6]}set E2I(t){this.m[6]=t}get E2B(){return this.m[7]}set E2B(t){this.m[7]=t}get E2E(){return this.m[8]}set E2E(t){this.m[8]=t}toString(){return this.m.map(t=>t instanceof Array&&t.length>0?"T":t instanceof Array&&t.length===0?"F":"*").join("")}equal(){return TTi.test(this.toString())}intersect(){return kTi.test(this.toString())}touch(){return FTi.test(this.toString())}inside(){return LTi.test(this.toString())}covered(){return HTi.test(this.toString())}};function aee(t,e){let n,o=new Ue.Ray(e),i=new Ue.Line(o.pt,o.norm);const r=new Ue.Box(o.box.xmin-Ue.DP_TOL,o.box.ymin-Ue.DP_TOL,o.box.xmax+Ue.DP_TOL,o.box.ymax+Ue.DP_TOL);if(t.box.not_intersect(r))return Ue.OUTSIDE;let s=t.edges.search(r);if(s.length===0)return Ue.OUTSIDE;for(let l of s)if(l.shape.contains(e))return Ue.BOUNDARY;let a=[...t.faces],A=[];for(let l of s)for(let u of o.intersect(l.shape)){if(u.equalTo(e))return Ue.BOUNDARY;A.push({pt:u,edge:l,face_index:a.indexOf(l.face)})}A.sort((l,u)=>rdn(l.pt.x,u.pt.x)?-1:idn(l.pt.x,u.pt.x)?1:l.face_index<u.face_index?-1:l.face_index>u.face_index?1:l.edge.arc_length<u.edge.arc_length?-1:l.edge.arc_length>u.edge.arc_length?1:0);let c=0;for(let l=0;l<A.length;l++){let u=A[l];if(u.pt.equalTo(u.edge.shape.start)){if(l>0&&u.pt.equalTo(A[l-1].pt)&&u.face_index===A[l-1].face_index&&u.edge.prev===A[l-1].edge)continue;let g=u.edge.prev;for(;Jje(g.length);)g=g.prev;let h=g.shape.tangentInEnd(),d=u.pt.translate(h),p=u.edge.shape.tangentInStart(),m=u.pt.translate(p),_=d.leftTo(i),f=m.leftTo(i);(_&&!f||!_&&f)&&c++}else if(u.pt.equalTo(u.edge.shape.end)){if(l>0&&u.pt.equalTo(A[l-1].pt)&&u.face_index===A[l-1].face_index&&u.edge.next===A[l-1].edge)continue;let g=u.edge.next;for(;Jje(g.length);)g=g.next;let h=g.shape.tangentInStart(),d=u.pt.translate(h),p=u.edge.shape.tangentInEnd(),m=u.pt.translate(p),_=d.leftTo(i),f=m.leftTo(i);(_&&!f||!_&&f)&&c++}else if(u.edge.shape instanceof Ue.Segment)c++;else{let g=u.edge.shape.box;LT(u.pt.y,g.ymin)||LT(u.pt.y,g.ymax)||c++}}return n=c%2===1?q_e:tdn,n}function OTi(t,e){return zU(t,e).equal()}function Ndn(t,e){return zU(t,e).intersect()}function GTi(t,e){return zU(t,e).touch()}function YTi(t,e){return!Ndn(t,e)}function Rdn(t,e){return zU(t,e).inside()}function Tdn(t,e){return zU(t,e).covered()}function UTi(t,e){return Rdn(e,t)}function kdn(t,e){return Tdn(e,t)}function zU(t,e){if(t instanceof Ue.Line&&e instanceof Ue.Line)return KTi(t,e);if(t instanceof Ue.Line&&e instanceof Ue.Circle)return VTi(t,e);if(t instanceof Ue.Line&&e instanceof Ue.Box)return zTi(t,e);if(t instanceof Ue.Line&&e instanceof Ue.Polygon)return JTi(t,e);if((t instanceof Ue.Segment||t instanceof Ue.Arc)&&e instanceof Ue.Polygon)return Fdn(t,e);if((t instanceof Ue.Segment||t instanceof Ue.Arc)&&(e instanceof Ue.Circle||e instanceof Ue.Box))return Fdn(t,new Ue.Polygon(e));if(t instanceof Ue.Polygon&&e instanceof Ue.Polygon)return ofe(t,e);if((t instanceof Ue.Circle||t instanceof Ue.Box)&&(e instanceof Ue.Circle||e instanceof Ue.Box))return ofe(new Ue.Polygon(t),new Ue.Polygon(e));if((t instanceof Ue.Circle||t instanceof Ue.Box)&&e instanceof Ue.Polygon)return ofe(new Ue.Polygon(t),e);if(t instanceof Ue.Polygon&&(e instanceof Ue.Circle||e instanceof Ue.Box))return ofe(t,new Ue.Polygon(e))}function KTi(t,e){let n=new VU,o=LU(t,e);return o.length===0?t.contains(e.pt)&&e.contains(t.pt)?(n.I2I=[t],n.I2E=[],n.E2I=[]):(n.I2I=[],n.I2E=[t],n.E2I=[e]):(n.I2I=o,n.I2E=t.split(o),n.E2I=e.split(o)),n}function VTi(t,e){let n=new VU,o=OT(t,e);if(o.length===0)n.I2I=[],n.I2B=[],n.I2E=[t],n.E2I=[e];else if(o.length===1)n.I2I=[],n.I2B=o,n.I2E=t.split(o),n.E2I=[e];else{let i=new GT([t]),r=t.sortPoints(o);i.split(r);let s=i.toShapes();n.I2I=[s[1]],n.I2B=r,n.I2E=[s[0],s[2]],n.E2I=new Ue.Polygon([e.toArc()]).cutWithLine(t)}return n}function zTi(t,e){let n=new VU,o=HU(t,e);if(o.length===0)n.I2I=[],n.I2B=[],n.I2E=[t],n.E2I=[e];else if(o.length===1)n.I2I=[],n.I2B=o,n.I2E=t.split(o),n.E2I=[e];else{let i=new GT([t]),r=t.sortPoints(o);i.split(r);let s=i.toShapes();e.toSegments().some(a=>a.contains(o[0])&&a.contains(o[1]))?(n.I2I=[],n.I2B=[s[1]],n.I2E=[s[0],s[2]],n.E2I=[e]):(n.I2I=[s[1]],n.I2B=r,n.I2E=[s[0],s[2]],n.E2I=new Ue.Polygon(e.toSegments()).cutWithLine(t))}return n}function JTi(t,e){let n=new VU,o=oee(t,e),i=new GT([t]),r=o.length>0?o.slice():t.sortPoints(o);return i.split(r),[...i].forEach(s=>s.setInclusion(e)),n.I2I=[...i].filter(s=>s.bv===Ue.INSIDE).map(s=>s.shape),n.I2B=[...i].slice(1).map(s=>s.bv===Ue.BOUNDARY?s.shape:s.shape.start),n.I2E=[...i].filter(s=>s.bv===Ue.OUTSIDE).map(s=>s.shape),n.E2I=e.cutWithLine(t),n}function Fdn(t,e){let n=new VU,o=ITi(t,e),i=o.length>0?o.slice():t.sortPoints(o),r=new GT([t]);r.split(i),[...r].forEach(s=>s.setInclusion(e)),n.I2I=[...r].filter(s=>s.bv===Ue.INSIDE).map(s=>s.shape),n.I2B=[...r].slice(1).map(s=>s.bv===Ue.BOUNDARY?s.shape:s.shape.start),n.I2E=[...r].filter(s=>s.bv===Ue.OUTSIDE).map(s=>s.shape),n.B2I=[],n.B2B=[],n.B2E=[];for(let s of[t.start,t.end])switch(aee(e,s)){case Ue.INSIDE:n.B2I.push(s);break;case Ue.BOUNDARY:n.B2B.push(s);break;case Ue.OUTSIDE:n.B2E.push(s);break}return n}function ofe(t,e){let n=new VU,[o,i]=Qdn(t,e),r=bdn(t,e),s=o$e(t,e),a=o$e(e,t),[A,c]=Sdn(t,e),l=i$e(t,e),u=i$e(e,t);return n.I2I=r.isEmpty()?[]:[r],n.I2B=c,n.I2E=s.isEmpty()?[]:[s],n.B2I=A,n.B2B=o,n.B2E=l,n.E2I=a.isEmpty()?[]:[a],n.E2B=u,n}var WTi=Object.freeze({__proto__:null,contain:UTi,cover:kdn,covered:Tdn,disjoint:YTi,equal:OTi,inside:Rdn,intersect:Ndn,relate:zU,touch:GTi}),Aee=class Fk{constructor(e=1,n=0,o=0,i=1,r=0,s=0){this.a=e,this.b=n,this.c=o,this.d=i,this.tx=r,this.ty=s}fromMatrix3x3(e){const[n,o,i]=e[0],[r,s,a]=e[1];return new Fk(n,r,o,s,i,a)}toMatrix3x3(){return[[this.a,this.c,this.tx],[this.b,this.d,this.ty],[0,0,1]]}clone(){return new Fk(this.a,this.b,this.c,this.d,this.tx,this.ty)}transform(e){return[e[0]*this.a+e[1]*this.c+this.tx,e[0]*this.b+e[1]*this.d+this.ty]}multiply(e){return new Fk(this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.tx+this.c*e.ty+this.tx,this.b*e.tx+this.d*e.ty+this.ty)}translate(...e){let n,o;if(e.length==1&&!isNaN(e[0].x)&&!isNaN(e[0].y))n=e[0].x,o=e[0].y;else if(e.length===2&&typeof e[0]=="number"&&typeof e[1]=="number")n=e[0],o=e[1];else throw wd.ILLEGAL_PARAMETERS;return this.multiply(new Fk(1,0,0,1,n,o))}rotate(e,n=0,o=0){let i=Math.cos(e),r=Math.sin(e);return this.translate(n,o).multiply(new Fk(i,r,-r,i,0,0)).translate(-n,-o)}scale(e,n){return this.multiply(new Fk(e,0,0,n,0,0))}equalTo(e){return!(!Ue.Utils.EQ(this.tx,e.tx)||!Ue.Utils.EQ(this.ty,e.ty)||!Ue.Utils.EQ(this.a,e.a)||!Ue.Utils.EQ(this.b,e.b)||!Ue.Utils.EQ(this.c,e.c)||!Ue.Utils.EQ(this.d,e.d))}};Ue.Matrix=Aee;var jTi=(...t)=>new Ue.Matrix(...t);Ue.matrix=jTi;var $Ti=class{constructor(t,e){this.low=t,this.high=e}get max(){return this.clone()}less_than(t){return this.low<t.low||this.low===t.low&&this.high<t.high}equal_to(t){return this.low===t.low&&this.high===t.high}intersect(t){return!this.not_intersect(t)}not_intersect(t){return this.high<t.low||t.high<this.low}merge(t){const e=this.low===void 0?t.low:this.low<t.low?this.low:t.low,n=this.high===void 0?t.high:this.high>t.high?this.high:t.high,o=this.clone();return o.low=e,o.high=n,o}output(){return[this.low,this.high]}comparable_less_than(t,e){return t<e}},qTi=class y4n extends $Ti{clone(){return new y4n(this.low,this.high)}},fI=1,cu=0,LP=class{constructor(e,n,o=null,i=null,r=null,s=cu){if(this.left=o,this.right=i,this.parent=r,this.color=s,this.item={key:void 0,values:[]},n!==void 0&&this.item.values.push(n),e!==void 0)if(Array.isArray(e)){const[a,A]=e;if(!Number.isNaN(a)&&!Number.isNaN(A)){let c=a,l=A;c>l&&([c,l]=[l,c]),this.item.key=new qTi(c,l)}}else this.item.key=e;this.max=this.item.key?this.item.key.max:void 0}isNil(){return this.item.key===void 0&&this.item.values.length===0&&this.left===null&&this.right===null&&this.color===cu}requireKey(){if(!this.item.key)throw new Error("Node key is undefined (nil/sentinel). Operation is not applicable.");return this.item.key}less_than(e){const n=this.requireKey(),o=e.requireKey();return n.less_than(o)}_value_equal(e){const n=this.item.values[0],o=e.item.values[0];return n&&o&&n.equal_to?n.equal_to(o):n===o}equal_to(e){const n=this.requireKey(),o=e.requireKey();return n.equal_to(o)}intersect(e){const n=this.requireKey(),o=e.requireKey();return n.intersect(o)}copy_data(e){this.item.key=e.item.key,this.item.values=e.item.values.slice()}update_max(){this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max&&(this.max=this.max?this.max.merge(this.right.max):this.right.max),this.left&&this.left.max&&(this.max=this.max?this.max.merge(this.left.max):this.left.max)}not_intersect_left_subtree(e){if(!this.left)return!0;const n=this.left.max?this.left.max.high:this.left.item.key.high,o=this.requireKey(),i=e.requireKey();return o.comparable_less_than(n,i.low)}not_intersect_right_subtree(e){if(!this.right)return!0;const n=this.right.max?this.right.max.low:this.right.item.key.low,o=this.requireKey(),i=e.requireKey();return o.comparable_less_than(i.high,n)}},A$e=class x4n{constructor(){this.root=null,this.nil_node=new LP}get size(){let e=0;return this.tree_walk(this.root,n=>e+=n.item.values.length),e}get keys(){const e=[];return this.tree_walk(this.root,n=>e.push(n.item.key.output())),e}get values(){const e=[];return this.tree_walk(this.root,n=>{for(const o of n.item.values)e.push(o)}),e}get items(){const e=[];return this.tree_walk(this.root,n=>{const o=n.item.key.output();for(const i of n.item.values)e.push({key:o,value:i})}),e}isEmpty(){return this.root==null||this.root===this.nil_node}clear(){this.root=null}insert(e,n=e){if(e===void 0)return;const o=this.tree_search(this.root,new LP(e));if(o)return o.item.values.push(n),o;const i=new LP(e,n,this.nil_node,this.nil_node,null,fI);return this.tree_insert(i),this.recalc_max(i),i}exist(e,n=e){const o=this.tree_search(this.root,new LP(e));return o?arguments.length<2||n===e?!0:o.item.values.some(i=>i&&i.equal_to?i.equal_to(n):i===n):!1}remove(e,n=e){const o=this.tree_search(this.root,new LP(e));if(!o)return;if(arguments.length<2)return this.tree_delete(o),o;const i=o.item.values.findIndex(r=>r&&r.equal_to?r.equal_to(n):r===n);if(i>=0)return o.item.values.splice(i,1),o.item.values.length===0&&this.tree_delete(o),o}search(e,n=(o,i)=>o===i?i.output():o){const o=new LP(e),i=[];this.tree_search_interval(this.root,o,i);const r=[];for(const s of i)for(const a of s.item.values)r.push(n(a,s.item.key));return r}intersect_any(e){const n=new LP(e);return this.tree_find_any_interval(this.root,n)}forEach(e){this.tree_walk(this.root,n=>{for(const o of n.item.values)e(n.item.key,o)})}map(e){const n=new x4n;return this.tree_walk(this.root,o=>{for(const i of o.item.values)n.insert(o.item.key,e(i,o.item.key))}),n}*iterate(e,n=(o,i)=>o===i?i.output():o){let o=null;for(e?o=this.tree_search_nearest_forward(this.root,new LP(e)):this.root&&(o=this.local_minimum(this.root));o;){for(const i of o.item.values)yield n(i,o.item.key);o=this.tree_successor(o)}}recalc_max(e){let n=e;for(;n.parent!=null;)n.parent.update_max(),n=n.parent}tree_insert(e){let n=this.root,o=null;if(this.root==null||this.root===this.nil_node)this.root=e;else{for(;n!==this.nil_node;)o=n,e.less_than(n)?n=n.left:n=n.right;e.parent=o,e.less_than(o)?o.left=e:o.right=e}this.insert_fixup(e)}insert_fixup(e){let n,o;for(n=e;n!==this.root&&n.parent.color===fI;)n.parent===n.parent.parent.left?(o=n.parent.parent.right,o.color===fI?(n.parent.color=cu,o.color=cu,n.parent.parent.color=fI,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,this.rotate_left(n)),n.parent.color=cu,n.parent.parent.color=fI,this.rotate_right(n.parent.parent))):(o=n.parent.parent.left,o.color===fI?(n.parent.color=cu,o.color=cu,n.parent.parent.color=fI,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,this.rotate_right(n)),n.parent.color=cu,n.parent.parent.color=fI,this.rotate_left(n.parent.parent)));this.root.color=cu}tree_delete(e){let n,o;e.left===this.nil_node||e.right===this.nil_node?n=e:n=this.tree_successor(e),n.left!==this.nil_node?o=n.left:o=n.right,o.parent=n.parent,n===this.root?this.root=o:(n===n.parent.left?n.parent.left=o:n.parent.right=o,n.parent.update_max()),this.recalc_max(o),n!==e&&(e.copy_data(n),e.update_max(),this.recalc_max(e)),n.color===cu&&this.delete_fixup(o)}delete_fixup(e){let n=e,o;for(;n!==this.root&&n.parent!=null&&n.color===cu;)n===n.parent.left?(o=n.parent.right,o.color===fI&&(o.color=cu,n.parent.color=fI,this.rotate_left(n.parent),o=n.parent.right),o.left.color===cu&&o.right.color===cu?(o.color=fI,n=n.parent):(o.right.color===cu&&(o.color=fI,o.left.color=cu,this.rotate_right(o),o=n.parent.right),o.color=n.parent.color,n.parent.color=cu,o.right.color=cu,this.rotate_left(n.parent),n=this.root)):(o=n.parent.left,o.color===fI&&(o.color=cu,n.parent.color=fI,this.rotate_right(n.parent),o=n.parent.left),o.left.color===cu&&o.right.color===cu?(o.color=fI,n=n.parent):(o.left.color===cu&&(o.color=fI,o.right.color=cu,this.rotate_left(o),o=n.parent.left),o.color=n.parent.color,n.parent.color=cu,o.left.color=cu,this.rotate_right(n.parent),n=this.root));n.color=cu}tree_search(e,n){if(!(e==null||e===this.nil_node))return n.equal_to(e)?e:n.less_than(e)?this.tree_search(e.left,n):this.tree_search(e.right,n)}tree_search_nearest_forward(e,n){let o=null,i=e;for(;i&&i!==this.nil_node;)i.less_than(n)?i.intersect(n)?(o=i,i=i.left):i=i.right:((!o||i.less_than(o))&&(o=i),i=i.left);return o||null}tree_search_interval(e,n,o){e!=null&&e!==this.nil_node&&(e.left!==this.nil_node&&!e.not_intersect_left_subtree(n)&&this.tree_search_interval(e.left,n,o),e.intersect(n)&&o.push(e),e.right!==this.nil_node&&!e.not_intersect_right_subtree(n)&&this.tree_search_interval(e.right,n,o))}tree_find_any_interval(e,n){let o=!1;return e!=null&&e!==this.nil_node&&(e.left!==this.nil_node&&!e.not_intersect_left_subtree(n)&&(o=this.tree_find_any_interval(e.left,n)),o||(o=e.intersect(n)),!o&&e.right!==this.nil_node&&!e.not_intersect_right_subtree(n)&&(o=this.tree_find_any_interval(e.right,n))),o}local_minimum(e){let n=e;for(;n.left!=null&&n.left!==this.nil_node;)n=n.left;return n}local_maximum(e){let n=e;for(;n.right!=null&&n.right!==this.nil_node;)n=n.right;return n}tree_successor(e){let n,o,i;if(e.right!==this.nil_node)n=this.local_minimum(e.right);else{for(o=e,i=e.parent;i!=null&&i.right===o;)o=i,i=i.parent;n=i}return n}rotate_left(e){const n=e.right;e.right=n.left,n.left!==this.nil_node&&(n.left.parent=e),n.parent=e.parent,e===this.root?this.root=n:e===e.parent.left?e.parent.left=n:e.parent.right=n,n.left=e,e.parent=n,e!==null&&e!==this.nil_node&&e.update_max(),n!=null&&n!==this.nil_node&&n.update_max()}rotate_right(e){const n=e.left;e.left=n.right,n.right!==this.nil_node&&(n.right.parent=e),n.parent=e.parent,e===this.root?this.root=n:e===e.parent.left?e.parent.left=n:e.parent.right=n,n.right=e,e.parent=n,e!==null&&e!==this.nil_node&&e.update_max(),n!=null&&n!==this.nil_node&&n.update_max()}tree_walk(e,n){e!=null&&e!==this.nil_node&&(this.tree_walk(e.left,n),n(e),this.tree_walk(e.right,n))}testRedBlackProperty(){let e=!0;return this.tree_walk(this.root,function(n){n.color===fI&&(n.left.color===cu&&n.right.color===cu||(e=!1))}),e}testBlackHeightProperty(e){let n=0,o=0,i=0;if(e.color===cu&&n++,e.left!==this.nil_node?o=this.testBlackHeightProperty(e.left):o=1,e.right!==this.nil_node?i=this.testBlackHeightProperty(e.right):i=1,o!==i)throw new Error("Red-black height property violated");return n+=o,n}},XTi=class extends Set{constructor(t){super(t),this.index=new A$e,this.forEach(e=>this.index.insert(e))}add(t){let e=this.size;const{key:n,value:o}=t,i=n||t.box,r=o||t;return super.add(r),this.size>e&&this.index.insert(i,r),this}delete(t){const{key:e,value:n}=t,o=e||t.box,i=n||t;let r=super.delete(i);return r&&this.index.remove(o,i),r}clear(){super.clear(),this.index=new A$e}search(t){return this.index.search(t)}hit(t){let e=new Ue.Box(t.x-1,t.y-1,t.x+1,t.y+1);return this.index.search(e).filter(o=>t.on(o))}svg(){return[...this].reduce((e,n)=>e+n.svg(),"")}};Ue.PlanarSet=XTi;var HP=class{get name(){throw wd.CANNOT_INVOKE_ABSTRACT_METHOD}get box(){throw wd.CANNOT_INVOKE_ABSTRACT_METHOD}clone(){throw wd.CANNOT_INVOKE_ABSTRACT_METHOD}translate(...t){return this.transform(new Aee().translate(...t))}rotate(t,e=new Ue.Point){return this.transform(new Aee().rotate(t,e.x,e.y))}scale(t,e){return this.transform(new Aee().scale(t,e))}transform(...t){throw wd.CANNOT_INVOKE_ABSTRACT_METHOD}toJSON(){return Object.assign({},this,{name:this.name})}svg(t={}){throw wd.CANNOT_INVOKE_ABSTRACT_METHOD}},ZTi=class E4n extends HP{constructor(...e){if(super(),this.x=0,this.y=0,e.length!==0){if(e.length===1&&e[0]instanceof Array&&e[0].length===2){let n=e[0];if(typeof n[0]=="number"&&typeof n[1]=="number"){this.x=n[0],this.y=n[1];return}}if(e.length===1&&e[0]instanceof Object&&e[0].name==="point"){let{x:n,y:o}=e[0];this.x=n,this.y=o;return}if(e.length===2&&typeof e[0]=="number"&&typeof e[1]=="number"){this.x=e[0],this.y=e[1];return}throw wd.ILLEGAL_PARAMETERS}}get box(){return new Ue.Box(this.x,this.y,this.x,this.y)}clone(){return new Ue.Point(this.x,this.y)}get vertices(){return[this.clone()]}equalTo(e){return Ue.Utils.EQ(this.x,e.x)&&Ue.Utils.EQ(this.y,e.y)}lessThan(e){return!!(Ue.Utils.LT(this.y,e.y)||Ue.Utils.EQ(this.y,e.y)&&Ue.Utils.LT(this.x,e.x))}transform(e){return new Ue.Point(e.transform([this.x,this.y]))}projectionOn(e){if(this.equalTo(e.pt))return this.clone();let n=new Ue.Vector(this,e.pt);if(Ue.Utils.EQ_0(n.cross(e.norm)))return e.pt.clone();let o=n.dot(e.norm),i=e.norm.multiply(o);return this.translate(i)}leftTo(e){let n=new Ue.Vector(e.pt,this);return Ue.Utils.GT(n.dot(e.norm),0)}distanceTo(e){if(e instanceof E4n){let n=e.x-this.x,o=e.y-this.y;return[Math.sqrt(n*n+o*o),new Ue.Segment(this,e)]}if(e instanceof Ue.Line)return Ue.Distance.point2line(this,e);if(e instanceof Ue.Circle)return Ue.Distance.point2circle(this,e);if(e instanceof Ue.Segment)return Ue.Distance.point2segment(this,e);if(e instanceof Ue.Arc)return Ue.Distance.point2arc(this,e);if(e instanceof Ue.Box)return Ue.Distance.point2polygon(this,new Ue.Polygon(e));if(e instanceof Ue.Polygon)return Ue.Distance.point2polygon(this,e);if(e instanceof Ue.PlanarSet)return Ue.Distance.shape2planarSet(this,e);if(e instanceof Ue.Multiline)return Ue.Distance.shape2multiline(this,e)}on(e){if(e instanceof Ue.Point)return this.equalTo(e);if(e.contains&&e.contains instanceof Function)return e.contains(this);throw Ue.Errors.UNSUPPORTED_SHAPE_TYPE}get name(){return"point"}svg(e={}){const n=e.r??3;return`
<circle cx="${this.x}" cy="${this.y}" r="${n}"
            ${HT({fill:"red",...e})} />`}};Ue.Point=ZTi;var eki=(...t)=>new Ue.Point(...t);Ue.point=eki;var tki=class extends HP{constructor(...e){if(super(),this.x=0,this.y=0,e.length!==0){if(e.length===1&&e[0]instanceof Array&&e[0].length===2){let n=e[0];if(typeof n[0]=="number"&&typeof n[1]=="number"){this.x=n[0],this.y=n[1];return}}if(e.length===1&&e[0]instanceof Object&&e[0].name==="vector"){let{x:n,y:o}=e[0];this.x=n,this.y=o;return}if(e.length===1&&e[0]instanceof Object&&e[0].name==="segment"){let{start:n,end:o}=e[0];this.x=o.x-n.x,this.y=o.y-n.y;return}if(e.length===2){let n=e[0],o=e[1];if(typeof n=="number"&&typeof o=="number"){this.x=n,this.y=o;return}if(n instanceof Ue.Point&&o instanceof Ue.Point){this.x=o.x-n.x,this.y=o.y-n.y;return}}throw wd.ILLEGAL_PARAMETERS}}clone(){return new Ue.Vector(this.x,this.y)}get slope(){let e=Math.atan2(this.y,this.x);return e<0&&(e=2*Math.PI+e),e}get length(){return Math.sqrt(this.dot(this))}isZeroLength(){return Ue.Utils.EQ_0(this.length)}equalTo(e){return Ue.Utils.EQ(this.x,e.x)&&Ue.Utils.EQ(this.y,e.y)}multiply(e){return new Ue.Vector(e*this.x,e*this.y)}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}normalize(){if(this.isZeroLength())throw wd.ZERO_DIVISION;return new Ue.Vector(this.x/this.length,this.y/this.length)}rotate(e,n=new Ue.Point){if(n.x===0&&n.y===0)return this.transform(new Aee().rotate(e));throw wd.OPERATION_IS_NOT_SUPPORTED}transform(e){return new Ue.Vector(e.transform([this.x,this.y]))}rotate90CCW(){return new Ue.Vector(-this.y,this.x)}rotate90CW(){return new Ue.Vector(this.y,-this.x)}invert(){return new Ue.Vector(-this.x,-this.y)}add(e){return new Ue.Vector(this.x+e.x,this.y+e.y)}subtract(e){return new Ue.Vector(this.x-e.x,this.y-e.y)}angleTo(e){let n=this.normalize(),o=e.normalize(),i=Math.atan2(n.cross(o),n.dot(o));return i<0&&(i+=2*Math.PI),i}projectionOn(e){let n=e.normalize(),o=this.dot(n);return n.multiply(o)}get name(){return"vector"}};Ue.Vector=tki;var Ldn=(...t)=>new Ue.Vector(...t);Ue.vector=Ldn;var nki=class Sit extends HP{constructor(...e){if(super(),this.ps=new Ue.Point,this.pe=new Ue.Point,e.length!==0){if(e.length===1&&e[0]instanceof Array&&e[0].length===4){let n=e[0];this.ps=new Ue.Point(n[0],n[1]),this.pe=new Ue.Point(n[2],n[3]);return}if(e.length===1&&e[0]instanceof Object&&e[0].name==="segment"){let{ps:n,pe:o}=e[0];this.ps=new Ue.Point(n.x,n.y),this.pe=new Ue.Point(o.x,o.y);return}if(e.length===1&&e[0]instanceof Ue.Point){this.ps=e[0].clone();return}if(e.length===2&&e[0]instanceof Ue.Point&&e[1]instanceof Ue.Point){this.ps=e[0].clone(),this.pe=e[1].clone();return}if(e.length===4){this.ps=new Ue.Point(e[0],e[1]),this.pe=new Ue.Point(e[2],e[3]);return}throw wd.ILLEGAL_PARAMETERS}}clone(){return new Ue.Segment(this.start,this.end)}get start(){return this.ps}get end(){return this.pe}get vertices(){return[this.ps.clone(),this.pe.clone()]}get length(){return this.start.distanceTo(this.end)[0]}get slope(){return new Ue.Vector(this.start,this.end).slope}get box(){return new Ue.Box(Math.min(this.start.x,this.end.x),Math.min(this.start.y,this.end.y),Math.max(this.start.x,this.end.x),Math.max(this.start.y,this.end.y))}equalTo(e){return this.ps.equalTo(e.ps)&&this.pe.equalTo(e.pe)}contains(e){return Ue.Utils.EQ_0(this.distanceToPoint(e))}intersect(e){if(e instanceof Ue.Point)return this.contains(e)?[e]:[];if(e instanceof Ue.Line)return nee(this,e);if(e instanceof Ue.Ray)return Xje(e,this);if(e instanceof Ue.Segment)return efe(this,e);if(e instanceof Ue.Circle)return tfe(this,e);if(e instanceof Ue.Box)return gTi(this,e);if(e instanceof Ue.Arc)return OU(this,e);if(e instanceof Ue.Polygon)return $je(this,e);if(e instanceof Ue.Multiline)return GU(this,e)}distanceTo(e){if(e instanceof Ue.Point){let[n,o]=Ue.Distance.point2segment(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Circle){let[n,o]=Ue.Distance.segment2circle(this,e);return[n,o]}if(e instanceof Ue.Line){let[n,o]=Ue.Distance.segment2line(this,e);return[n,o]}if(e instanceof Ue.Segment){let[n,o]=Ue.Distance.segment2segment(this,e);return[n,o]}if(e instanceof Ue.Arc){let[n,o]=Ue.Distance.segment2arc(this,e);return[n,o]}if(e instanceof Ue.Box){let[n,o]=Ue.Distance.shape2polygon(this,new Ue.Polygon(e));return[n,o]}if(e instanceof Ue.Polygon){let[n,o]=Ue.Distance.shape2polygon(this,e);return[n,o]}if(e instanceof Ue.PlanarSet){let[n,o]=Ue.Distance.shape2planarSet(this,e);return[n,o]}if(e instanceof Ue.Multiline)return Ue.Distance.shape2multiline(this,e)}tangentInStart(){return new Ue.Vector(this.start,this.end).normalize()}tangentInEnd(){return new Ue.Vector(this.end,this.start).normalize()}reverse(){return new Sit(this.end,this.start)}split(e){return this.start.equalTo(e)?[null,this.clone()]:this.end.equalTo(e)?[this.clone(),null]:[new Ue.Segment(this.start,e),new Ue.Segment(e,this.end)]}middle(){return new Ue.Point((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)}pointAtLength(e){if(e>this.length||e<0)return null;if(e==0)return this.start;if(e==this.length)return this.end;let n=e/this.length;return new Ue.Point((this.end.x-this.start.x)*n+this.start.x,(this.end.y-this.start.y)*n+this.start.y)}distanceToPoint(e){let[n,...o]=Ue.Distance.point2segment(e,this);return n}definiteIntegral(e=0){let n=this.end.x-this.start.x,o=this.start.y-e,i=this.end.y-e;return n*(o+i)/2}transform(e=new Ue.Matrix){return new Sit(this.ps.transform(e),this.pe.transform(e))}isZeroLength(){return this.ps.equalTo(this.pe)}sortPoints(e){return new Ue.Line(this.start,this.end).sortPoints(e)}get name(){return"segment"}svg(e={}){return`
<line x1="${this.start.x}" y1="${this.start.y}" x2="${this.end.x}" y2="${this.end.y}" ${HT(e)} />`}};Ue.Segment=nki;var oki=(...t)=>new Ue.Segment(...t);Ue.segment=oki;var{vector:cee}=Ue,iki=class B4n extends HP{constructor(...e){if(super(),this.pt=new Ue.Point,this.norm=new Ue.Vector(0,1),e.length!==0){if(e.length===1&&e[0]instanceof Object&&e[0].name==="line"){let{pt:n,norm:o}=e[0];this.pt=new Ue.Point(n),this.norm=new Ue.Vector(o);return}if(e.length===2){let n=e[0],o=e[1];if(n instanceof Ue.Point&&o instanceof Ue.Point){this.pt=n,this.norm=B4n.points2norm(n,o),this.norm.dot(cee(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}if(n instanceof Ue.Point&&o instanceof Ue.Vector){if(Ue.Utils.EQ_0(o.x)&&Ue.Utils.EQ_0(o.y))throw wd.ILLEGAL_PARAMETERS;this.pt=n.clone(),this.norm=o.clone(),this.norm=this.norm.normalize(),this.norm.dot(cee(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}if(n instanceof Ue.Vector&&o instanceof Ue.Point){if(Ue.Utils.EQ_0(n.x)&&Ue.Utils.EQ_0(n.y))throw wd.ILLEGAL_PARAMETERS;this.pt=o.clone(),this.norm=n.clone(),this.norm=this.norm.normalize(),this.norm.dot(cee(this.pt.x,this.pt.y))>=0&&this.norm.invert();return}}throw wd.ILLEGAL_PARAMETERS}}clone(){return new Ue.Line(this.pt,this.norm)}get start(){}get end(){}get length(){return Number.POSITIVE_INFINITY}get box(){return new Ue.Box(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}get middle(){}get slope(){return new Ue.Vector(this.norm.y,-this.norm.x).slope}get standard(){let e=this.norm.x,n=this.norm.y,o=this.norm.dot(cee(this.pt.x,this.pt.y));return[e,n,o]}parallelTo(e){return Ue.Utils.EQ_0(this.norm.cross(e.norm))}incidentTo(e){return this.parallelTo(e)&&this.pt.on(e)}contains(e){if(this.pt.equalTo(e))return!0;let n=new Ue.Vector(this.pt,e);return Ue.Utils.EQ_0(this.norm.dot(n))}coord(e){return cee(e.x,e.y).cross(this.norm)}intersect(e){if(e instanceof Ue.Point)return this.contains(e)?[e]:[];if(e instanceof Ue.Line)return LU(this,e);if(e instanceof Ue.Ray)return Idn(e,this);if(e instanceof Ue.Circle)return OT(this,e);if(e instanceof Ue.Box)return HU(this,e);if(e instanceof Ue.Segment)return nee(e,this);if(e instanceof Ue.Arc)return Z_e(this,e);if(e instanceof Ue.Polygon)return oee(this,e);if(e instanceof Ue.Multiline)return GU(this,e)}distanceTo(e){if(e instanceof Ue.Point){let[n,o]=Ue.Distance.point2line(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Circle){let[n,o]=Ue.Distance.circle2line(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Segment){let[n,o]=Ue.Distance.segment2line(e,this);return[n,o.reverse()]}if(e instanceof Ue.Arc){let[n,o]=Ue.Distance.arc2line(e,this);return[n,o.reverse()]}if(e instanceof Ue.Box){let[n,o]=Ue.Distance.shape2polygon(this,new Ue.Polygon(e));return[n,o]}if(e instanceof Ue.Polygon){let[n,o]=Ue.Distance.shape2polygon(this,e);return[n,o]}}split(e){if(e instanceof Ue.Point)return[new Ue.Ray(e,this.norm),new Ue.Ray(e,this.norm)];{let n=new Ue.Multiline([this]),o=this.sortPoints(e);return n.split(o),n.toShapes()}}rotate(e,n=new Ue.Point){return new Ue.Line(this.pt.rotate(e,n),this.norm.rotate(e))}transform(e){return new Ue.Line(this.pt.transform(e),this.norm.clone())}sortPoints(e){return e.slice().sort((n,o)=>this.coord(n)<this.coord(o)?-1:this.coord(n)>this.coord(o)?1:0)}get name(){return"line"}svg(e,n={}){let o=HU(this,e);if(o.length===0)return"";let i=o[0],r=o.length===2?o[1]:o.find(a=>!a.equalTo(i));return r===void 0&&(r=i),new Ue.Segment(i,r).svg(n)}static points2norm(e,n){if(e.equalTo(n))throw wd.ILLEGAL_PARAMETERS;return new Ue.Vector(e,n).normalize().rotate90CCW()}};Ue.Line=iki;var rki=(...t)=>new Ue.Line(...t);Ue.line=rki;var ski=class extends HP{constructor(...e){if(super(),this.pc=new Ue.Point,this.r=1,e.length===1&&e[0]instanceof Object&&e[0].name==="circle"){let{pc:n,r:o}=e[0];this.pc=new Ue.Point(n),this.r=o}else{let[n,o]=[...e];n&&n instanceof Ue.Point&&(this.pc=n.clone()),o!==void 0&&(this.r=o)}}clone(){return new Ue.Circle(this.pc.clone(),this.r)}get center(){return this.pc}get box(){return new Ue.Box(this.pc.x-this.r,this.pc.y-this.r,this.pc.x+this.r,this.pc.y+this.r)}contains(e){if(e instanceof Ue.Point)return Ue.Utils.LE(e.distanceTo(this.center)[0],this.r);if(e instanceof Ue.Segment)return Ue.Utils.LE(e.start.distanceTo(this.center)[0],this.r)&&Ue.Utils.LE(e.end.distanceTo(this.center)[0],this.r);if(e instanceof Ue.Arc)return this.intersect(e).length===0&&Ue.Utils.LE(e.start.distanceTo(this.center)[0],this.r)&&Ue.Utils.LE(e.end.distanceTo(this.center)[0],this.r);if(e instanceof Ue.Circle)return this.intersect(e).length===0&&Ue.Utils.LE(e.r,this.r)&&Ue.Utils.LE(e.center.distanceTo(this.center)[0],this.r)}toArc(e=!0){return new Ue.Arc(this.center,this.r,Math.PI,-Math.PI,e)}scale(e,n){if(e!==n||!(this.pc.x===0&&this.pc.y===0))throw wd.OPERATION_IS_NOT_SUPPORTED;return new Ue.Circle(this.pc,this.r*e)}transform(e=new Ue.Matrix){return new Ue.Circle(this.pc.transform(e),this.r)}intersect(e){if(e instanceof Ue.Point)return this.contains(e)?[e]:[];if(e instanceof Ue.Line)return OT(e,this);if(e instanceof Ue.Ray)return fdn(e,this);if(e instanceof Ue.Segment)return tfe(e,this);if(e instanceof Ue.Circle)return cdn(e,this);if(e instanceof Ue.Box)return dTi(this,e);if(e instanceof Ue.Arc)return jje(e,this);if(e instanceof Ue.Polygon)return hdn(this,e);if(e instanceof Ue.Multiline)return GU(this,e)}distanceTo(e){if(e instanceof Ue.Point){let[n,o]=Ue.Distance.point2circle(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Circle){let[n,o]=Ue.Distance.circle2circle(this,e);return[n,o]}if(e instanceof Ue.Line){let[n,o]=Ue.Distance.circle2line(this,e);return[n,o]}if(e instanceof Ue.Segment){let[n,o]=Ue.Distance.segment2circle(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Arc){let[n,o]=Ue.Distance.arc2circle(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Box){let[n,o]=Ue.Distance.shape2polygon(this,new Ue.Polygon(e));return[n,o]}if(e instanceof Ue.Polygon){let[n,o]=Ue.Distance.shape2polygon(this,e);return[n,o]}if(e instanceof Ue.PlanarSet){let[n,o]=Ue.Distance.shape2planarSet(this,e);return[n,o]}if(e instanceof Ue.Multiline){let[n,o]=Ue.Distance.shape2multiline(this,e);return[n,o]}}get name(){return"circle"}svg(e={}){return`
<circle cx="${this.pc.x}" cy="${this.pc.y}" r="${this.r}"
                ${HT({fill:"none",...e})} />`}};Ue.Circle=ski;var aki=(...t)=>new Ue.Circle(...t);Ue.circle=aki;var Aki=class extends HP{constructor(...t){if(super(),this.pc=new Ue.Point,this.r=1,this.startAngle=0,this.endAngle=2*Math.PI,this.counterClockwise=!0,t.length!==0)if(t.length===1&&t[0]instanceof Object&&t[0].name==="arc"){let{pc:e,r:n,startAngle:o,endAngle:i,counterClockwise:r}=t[0];this.pc=new Ue.Point(e.x,e.y),this.r=n,this.startAngle=o,this.endAngle=i,this.counterClockwise=r}else{let[e,n,o,i,r]=[...t];e&&e instanceof Ue.Point&&(this.pc=e.clone()),n!==void 0&&(this.r=n),o!==void 0&&(this.startAngle=o),i!==void 0&&(this.endAngle=i),r!==void 0&&(this.counterClockwise=r)}}clone(){return new Ue.Arc(this.pc.clone(),this.r,this.startAngle,this.endAngle,this.counterClockwise)}get sweep(){let t=this.startAngle,e=this.endAngle;if(Ue.Utils.EQ(Math.abs(t-e),Ue.PIx2))return Ue.PIx2;Math.abs(t)>Ue.PIx2&&(t-=Math.trunc(t/Ue.PIx2)*Ue.PIx2),t<0&&(t+=Ue.PIx2),Math.abs(e)>Ue.PIx2&&(e-=Math.trunc(e/Ue.PIx2)*Ue.PIx2),e<0&&(e+=Ue.PIx2);let n=this.counterClockwise?e-t:t-e;return n<0&&(n+=Ue.PIx2),n}get start(){return new Ue.Point(this.pc.x+this.r,this.pc.y).rotate(this.startAngle,this.pc)}get end(){return new Ue.Point(this.pc.x+this.r,this.pc.y).rotate(this.endAngle,this.pc)}get center(){return this.pc.clone()}get vertices(){return[this.start.clone(),this.end.clone()]}get length(){return Math.abs(this.sweep*this.r)}get box(){let e=this.breakToFunctional().reduce((n,o)=>n.merge(o.start.box),new Ue.Box);return e=e.merge(this.end.box),e}contains(t){if(!Ue.Utils.EQ(this.pc.distanceTo(t)[0],this.r))return!1;if(t.equalTo(this.start))return!0;let e=new Ue.Vector(this.pc,t).slope,n=new Ue.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise);return Ue.Utils.LE(n.length,this.length)}split(t){if(this.start.equalTo(t))return[null,this.clone()];if(this.end.equalTo(t))return[this.clone(),null];let e=new Ue.Vector(this.pc,t).slope;return[new Ue.Arc(this.pc,this.r,this.startAngle,e,this.counterClockwise),new Ue.Arc(this.pc,this.r,e,this.endAngle,this.counterClockwise)]}middle(){let t=this.counterClockwise?this.startAngle+this.sweep/2:this.startAngle-this.sweep/2;return new Ue.Arc(this.pc,this.r,this.startAngle,t,this.counterClockwise).end}pointAtLength(t){if(t>this.length||t<0)return null;if(t===0)return this.start;if(t===this.length)return this.end;let e=t/this.length,n=this.counterClockwise?this.startAngle+this.sweep*e:this.startAngle-this.sweep*e;return new Ue.Arc(this.pc,this.r,this.startAngle,n,this.counterClockwise).end}chordHeight(){return(1-Math.cos(Math.abs(this.sweep/2)))*this.r}intersect(t){if(t instanceof Ue.Point)return this.contains(t)?[t]:[];if(t instanceof Ue.Line)return Z_e(t,this);if(t instanceof Ue.Ray)return Zje(t,this);if(t instanceof Ue.Circle)return jje(this,t);if(t instanceof Ue.Segment)return OU(t,this);if(t instanceof Ue.Box)return hTi(this,t);if(t instanceof Ue.Arc)return ldn(this,t);if(t instanceof Ue.Polygon)return qje(this,t);if(t instanceof Ue.Multiline)return GU(this,t)}distanceTo(t){if(t instanceof Ue.Point){let[e,n]=Ue.Distance.point2arc(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ue.Circle){let[e,n]=Ue.Distance.arc2circle(this,t);return[e,n]}if(t instanceof Ue.Line){let[e,n]=Ue.Distance.arc2line(this,t);return[e,n]}if(t instanceof Ue.Segment){let[e,n]=Ue.Distance.segment2arc(t,this);return n=n.reverse(),[e,n]}if(t instanceof Ue.Arc){let[e,n]=Ue.Distance.arc2arc(this,t);return[e,n]}if(t instanceof Ue.Box){let[e,n]=Ue.Distance.shape2polygon(this,new Ue.Polygon(t));return[e,n]}if(t instanceof Ue.Polygon){let[e,n]=Ue.Distance.shape2polygon(this,t);return[e,n]}if(t instanceof Ue.PlanarSet){let[e,n]=Ue.Distance.shape2planarSet(this,t);return[e,n]}if(t instanceof Ue.Multiline)return Ue.Distance.shape2multiline(this,t)}breakToFunctional(){let t=[],e=[0,Math.PI/2,Math.PI,3*Math.PI/2],n=this.startAngle,o=this.endAngle;Ue.Utils.EQ(Math.abs(n-o),Ue.PIx2)&&(o=n),Math.abs(n)>Ue.PIx2&&(n-=Math.trunc(n/Ue.PIx2)*Ue.PIx2),n<0&&(n+=Ue.PIx2),Math.abs(o)>Ue.PIx2&&(o-=Math.trunc(o/Ue.PIx2)*Ue.PIx2),o<0&&(o+=Ue.PIx2);let i=n,r,s,a;this.counterClockwise?(s=Math.ceil(n/(Math.PI/2))%4,a=1):(s=Math.floor(n/(Math.PI/2))%4,a=-1);for(let A=0,c=s;A<4;A++,c=(c+a+4)%4){if(r=e[c],r===i)continue;let l=this.counterClockwise?r-n:n-r;if(l<0&&(l+=Ue.PIx2),l>this.sweep)break;t.push(new Ue.Arc(this.pc,this.r,i,r,this.counterClockwise)),i=r}return t.length===0?(t.push(this),t):(r=o,i!==r&&t.push(new Ue.Arc(this.pc,this.r,i,r,this.counterClockwise)),t)}tangentInStart(){let t=new Ue.Vector(this.pc,this.start),e=this.counterClockwise?Math.PI/2:-Math.PI/2;return t.rotate(e).normalize()}tangentInEnd(){let t=new Ue.Vector(this.pc,this.end),e=this.counterClockwise?-Math.PI/2:Math.PI/2;return t.rotate(e).normalize()}reverse(){return new Ue.Arc(this.pc,this.r,this.endAngle,this.startAngle,!this.counterClockwise)}transform(t=new Ue.Matrix){let e=this.start.transform(t),n=this.end.transform(t),o=this.pc.transform(t),i=this.counterClockwise;return t.a*t.d<0&&(i=!i),Ue.Arc.arcSE(o,e,n,i)}static arcSE(t,e,n,o){let{vector:i}=Ue,r=i(t,e).slope,s=i(t,n).slope;Ue.Utils.EQ(r,s)&&(s+=2*Math.PI,o=!0);let a=i(t,e).length;return new Ue.Arc(t,a,r,s,o)}definiteIntegral(t=0){return this.breakToFunctional().reduce((o,i)=>o+i.circularSegmentDefiniteIntegral(t),0)}circularSegmentDefiniteIntegral(t){let n=new Ue.Segment(this.start,this.end).definiteIntegral(t),o=Ue.Utils.EQ(this.sweep,Ue.PIx2)?0:this.circularSegmentArea();return this.counterClockwise?n-o:n+o}circularSegmentArea(){return .5*this.r*this.r*(this.sweep-Math.sin(this.sweep))}sortPoints(t){let{vector:e}=Ue;return t.slice().sort((n,o)=>{let i=e(this.pc,n).slope,r=e(this.pc,o).slope;return i<r?-1:i>r?1:0})}get name(){return"arc"}svg(t={}){let e=this.sweep<=Math.PI?"0":"1",n=this.counterClockwise?"1":"0";return Ue.Utils.EQ(this.sweep,2*Math.PI)?new Ue.Circle(this.pc,this.r).svg(t):`
<path d="M${this.start.x},${this.start.y}
                             A${this.r},${this.r} 0 ${e},${n} ${this.end.x},${this.end.y}"
                    ${HT({fill:"none",...t})} />`}};Ue.Arc=Aki;var cki=(...t)=>new Ue.Arc(...t);Ue.arc=cki;var lki=class tne extends HP{constructor(e=void 0,n=void 0,o=void 0,i=void 0){super(),this.xmin=e,this.ymin=n,this.xmax=o,this.ymax=i}clone(){return new tne(this.xmin,this.ymin,this.xmax,this.ymax)}get low(){return new Ue.Point(this.xmin,this.ymin)}get high(){return new Ue.Point(this.xmax,this.ymax)}get max(){return this.clone()}get center(){return new Ue.Point((this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)}get width(){return Math.abs(this.xmax-this.xmin)}get height(){return Math.abs(this.ymax-this.ymin)}get box(){return this.clone()}not_intersect(e){return this.xmax<e.xmin||this.xmin>e.xmax||this.ymax<e.ymin||this.ymin>e.ymax}intersect(e){return!this.not_intersect(e)}merge(e){return new tne(this.xmin===void 0?e.xmin:Math.min(this.xmin,e.xmin),this.ymin===void 0?e.ymin:Math.min(this.ymin,e.ymin),this.xmax===void 0?e.xmax:Math.max(this.xmax,e.xmax),this.ymax===void 0?e.ymax:Math.max(this.ymax,e.ymax))}less_than(e){return!!(this.low.lessThan(e.low)||this.low.equalTo(e.low)&&this.high.lessThan(e.high))}equal_to(e){return this.low.equalTo(e.low)&&this.high.equalTo(e.high)}output(){return this.clone()}comparable_less_than(e,n){return e.lessThan(n)}set(e,n,o,i){this.xmin=e,this.ymin=n,this.xmax=o,this.ymax=i}extend(e){return e<=0?this.clone():new tne(this.xmin-e,this.ymin-e,this.xmax+e,this.ymax+e)}toPoints(){return[new Ue.Point(this.xmin,this.ymin),new Ue.Point(this.xmax,this.ymin),new Ue.Point(this.xmax,this.ymax),new Ue.Point(this.xmin,this.ymax)]}toSegments(){let e=this.toPoints();return[new Ue.Segment(e[0],e[1]),new Ue.Segment(e[1],e[2]),new Ue.Segment(e[2],e[3]),new Ue.Segment(e[3],e[0])]}rotate(e,n=new Ue.Point){throw wd.OPERATION_IS_NOT_SUPPORTED}transform(e=new Ue.Matrix){return this.toPoints().map(o=>o.transform(e)).reduce((o,i)=>o.merge(i.box),new tne)}contains(e){if(e instanceof Ue.Point)return e.x>=this.xmin&&e.x<=this.xmax&&e.y>=this.ymin&&e.y<=this.ymax;if(e instanceof Ue.Segment)return e.vertices.every(n=>this.contains(n));if(e instanceof Ue.Box)return e.toSegments().every(n=>this.contains(n));if(e instanceof Ue.Circle)return this.contains(e.box);if(e instanceof Ue.Arc)return e.vertices.every(n=>this.contains(n))&&this.toSegments().every(n=>OU(n,e).length===0);if(e instanceof Ue.Line||e instanceof Ue.Ray)return!1;if(e instanceof Ue.Multiline)return e.toShapes().every(n=>this.contains(n));if(e instanceof Ue.Polygon)return this.contains(e.box)}distanceTo(e){const n=this.toSegments().map(i=>i.distanceTo(e));let o=[Number.MAX_SAFE_INTEGER,null];return n.forEach(i=>{i[0]<o[0]&&(o=i)}),o}get name(){return"box"}svg(e={}){const n=this.xmax-this.xmin,o=this.ymax-this.ymin;return`
<rect x="${this.xmin}" y="${this.ymin}" width="${n}" height="${o}"
                ${HT({fill:"none",...e})} />`}};Ue.Box=lki;var uki=(...t)=>new Ue.Box(...t);Ue.box=uki;var gki=class{constructor(t){this.shape=t,this.next=void 0,this.prev=void 0,this.face=void 0,this.arc_length=0,this.bvStart=void 0,this.bvEnd=void 0,this.bv=void 0,this.overlap=void 0}get start(){return this.shape.start}get end(){return this.shape.end}get length(){return this.shape.length}get box(){return this.shape.box}get isSegment(){return this.shape instanceof Ue.Segment}get isArc(){return this.shape instanceof Ue.Arc}get isLine(){return this.shape instanceof Ue.Line}get isRay(){return this.shape instanceof Ue.Ray}middle(){return this.shape.middle()}pointAtLength(t){return this.shape.pointAtLength(t)}contains(t){return this.shape.contains(t)}setInclusion(t){if(this.bv!==void 0)return this.bv;if(this.shape instanceof Ue.Line||this.shape instanceof Ue.Ray)return this.bv=Ue.OUTSIDE,this.bv;if(this.bvStart===void 0&&(this.bvStart=aee(t,this.start)),this.bvEnd===void 0&&(this.bvEnd=aee(t,this.end)),this.bvStart===Ue.OUTSIDE||this.bvEnd==Ue.OUTSIDE)this.bv=Ue.OUTSIDE;else if(this.bvStart===Ue.INSIDE||this.bvEnd==Ue.INSIDE)this.bv=Ue.INSIDE;else{let e=aee(t,this.middle());this.bv=e}return this.bv}setOverlap(t){let e,n=this.shape,o=t.shape;n instanceof Ue.Segment&&o instanceof Ue.Segment?n.start.equalTo(o.start)&&n.end.equalTo(o.end)?e=Ue.OVERLAP_SAME:n.start.equalTo(o.end)&&n.end.equalTo(o.start)&&(e=Ue.OVERLAP_OPPOSITE):(n instanceof Ue.Arc&&o instanceof Ue.Arc||n instanceof Ue.Segment&&o instanceof Ue.Arc||n instanceof Ue.Arc&&o instanceof Ue.Segment)&&(n.start.equalTo(o.start)&&n.end.equalTo(o.end)&&n.middle().equalTo(o.middle())?e=Ue.OVERLAP_SAME:n.start.equalTo(o.end)&&n.end.equalTo(o.start)&&n.middle().equalTo(o.middle())&&(e=Ue.OVERLAP_OPPOSITE)),this.overlap===void 0&&(this.overlap=e),t.overlap===void 0&&(t.overlap=e)}svg(){if(this.shape instanceof Ue.Segment)return` L${this.shape.end.x},${this.shape.end.y}`;if(this.shape instanceof Ue.Arc){let t=this.shape,e,n=t.counterClockwise?"1":"0";if(Ue.Utils.EQ(t.sweep,2*Math.PI)){let o=t.counterClockwise?1:-1,i=new Ue.Arc(t.pc,t.r,t.startAngle,t.startAngle+o*Math.PI,t.counterClockwise),r=new Ue.Arc(t.pc,t.r,t.startAngle+o*Math.PI,t.endAngle,t.counterClockwise);return e="0",` A${i.r},${i.r} 0 ${e},${n} ${i.end.x},${i.end.y}
                    A${r.r},${r.r} 0 ${e},${n} ${r.end.x},${r.end.y}`}else return e=t.sweep<=Math.PI?"0":"1",` A${t.r},${t.r} 0 ${e},${n} ${t.end.x},${t.end.y}`}}toJSON(){return this.shape.toJSON()}};Ue.Edge=gki;var dki=class extends Wje{constructor(t,e){super(t,e),this.setCircularLinks()}setCircularLinks(){this.isEmpty()||(this.last.next=this.first,this.first.prev=this.last)}[Symbol.iterator](){let t;return{next:()=>{let e=t||this.first,n=this.first?t?t===this.first:!1:!0;return t=e?e.next:void 0,{value:e,done:n}}}}append(t){return super.append(t),this.setCircularLinks(),this}insert(t,e){return super.insert(t,e),this.setCircularLinks(),this}remove(t){return super.remove(t),this}},hki=class nne extends dki{constructor(e,...n){if(super(),this._box=void 0,this._orientation=void 0,n.length!==0){if(n.length===1){if(n[0]instanceof Array){let o=n[0];if(o.length===0)return;if(o.every(i=>i instanceof Ue.Point)){let i=nne.points2segments(o);this.shapes2face(e.edges,i)}else if(o.every(i=>i instanceof Array&&i.length===2)){let i=o.map(s=>new Ue.Point(s[0],s[1])),r=nne.points2segments(i);this.shapes2face(e.edges,r)}else if(o.every(i=>i instanceof Ue.Segment||i instanceof Ue.Arc))this.shapes2face(e.edges,o);else if(o.every(i=>i.name==="segment"||i.name==="arc")){let i=[];for(let r of o){let s;r.name==="segment"?s=new Ue.Segment(r):s=new Ue.Arc(r),i.push(s)}this.shapes2face(e.edges,i)}}else if(n[0]instanceof nne){let o=n[0];this.first=o.first,this.last=o.last;for(let i of o)e.edges.add(i)}else if(n[0]instanceof Ue.Circle)this.shapes2face(e.edges,[n[0].toArc(edn)]);else if(n[0]instanceof Ue.Box){let o=n[0];this.shapes2face(e.edges,[new Ue.Segment(new Ue.Point(o.xmin,o.ymin),new Ue.Point(o.xmax,o.ymin)),new Ue.Segment(new Ue.Point(o.xmax,o.ymin),new Ue.Point(o.xmax,o.ymax)),new Ue.Segment(new Ue.Point(o.xmax,o.ymax),new Ue.Point(o.xmin,o.ymax)),new Ue.Segment(new Ue.Point(o.xmin,o.ymax),new Ue.Point(o.xmin,o.ymin))])}}n.length===2&&n[0]instanceof Ue.Edge&&n[1]instanceof Ue.Edge&&(this.first=n[0],this.last=n[1],this.last.next=this.first,this.first.prev=this.last,this.setArcLength())}}get edges(){return this.toArray()}get vertices(){return this.edges.map(e=>e.shape.start.clone())}get shapes(){return this.edges.map(e=>e.shape.clone())}get box(){if(this._box===void 0){let e=new Ue.Box;for(let n of this)e=e.merge(n.box);this._box=e}return this._box}get perimeter(){return this.last.arc_length+this.last.length}pointAtLength(e){if(e>this.perimeter||e<0)return null;let n=null;for(let o of this)if(e>=o.arc_length&&(o===this.last||e<o.next.arc_length)){n=o.pointAtLength(e-o.arc_length);break}return n}static points2segments(e){let n=[];for(let o=0;o<e.length;o++)e[o].equalTo(e[(o+1)%e.length])||n.push(new Ue.Segment(e[o],e[(o+1)%e.length]));return n}shapes2face(e,n){for(let o of n){let i=new Ue.Edge(o);this.append(i),e.add(i)}}append(e){return super.append(e),this.setOneEdgeArcLength(e),e.face=this,this}insert(e,n){return super.insert(e,n),this.setOneEdgeArcLength(e),e.face=this,this}remove(e){return super.remove(e),this.setArcLength(),this}merge_with_next_edge(e){return e.shape.end.x=e.next.shape.end.x,e.shape.end.y=e.next.shape.end.y,this.remove(e.next),this}reverse(){let e=[],n=this.last;do n.shape=n.shape.reverse(),e.push(n),n=n.prev;while(n!==this.last);this.first=void 0,this.last=void 0;for(let o of e)this.first===void 0?(o.prev=o,o.next=o,this.first=o,this.last=o):(o.prev=this.last,this.last.next=o,this.last=o,this.last.next=this.first,this.first.prev=this.last),this.setOneEdgeArcLength(o);this._orientation!==void 0&&(this._orientation=void 0,this._orientation=this.orientation())}setArcLength(){for(let e of this)this.setOneEdgeArcLength(e),e.face=this}setOneEdgeArcLength(e){e===this.first?e.arc_length=0:e.arc_length=e.prev.arc_length+e.prev.length}area(){return Math.abs(this.signedArea())}signedArea(){let e=0,n=this.box.ymin;for(let o of this)e+=o.shape.definiteIntegral(n);return e}orientation(){if(this._orientation===void 0){let e=this.signedArea();Ue.Utils.EQ_0(e)?this._orientation=eee.NOT_ORIENTABLE:Ue.Utils.LT(e,0)?this._orientation=eee.CCW:this._orientation=eee.CW}return this._orientation}isSimple(e){return nne.getSelfIntersections(this,e,!0).length===0}static getSelfIntersections(e,n,o=!1){let i=[];for(let r of e){let s=n.search(r.box);for(let a of s){if(r===a||a.face!==e||r.shape instanceof Ue.Segment&&a.shape instanceof Ue.Segment&&(r.next===a||r.prev===a))continue;let A=r.shape.intersect(a.shape);for(let c of A)if(!(c.equalTo(r.start)&&c.equalTo(a.end)&&a===r.prev)&&!(c.equalTo(r.end)&&c.equalTo(a.start)&&a===r.next)&&(i.push(c),o))break;if(i.length>0&&o)break}if(i.length>0&&o)break}return i}findEdgeByPoint(e){let n;for(let o of this)if(!e.equalTo(o.shape.start)&&(e.equalTo(o.shape.end)||o.shape.contains(e))){n=o;break}return n}toPolygon(){return new Ue.Polygon(this.shapes)}toJSON(){return this.edges.map(e=>e.toJSON())}svg(){let e=`M${this.first.start.x},${this.first.start.y}`;for(let n of this)e+=n.svg();return e+=" z",e}};Ue.Face=hki;var pki=class b4n extends HP{constructor(...e){if(super(),this.pt=new Ue.Point,this.norm=new Ue.Vector(0,1),e.length!==0&&(e.length>=1&&e[0]instanceof Ue.Point&&(this.pt=e[0].clone()),e.length!==1)){if(e.length===2&&e[1]instanceof Ue.Vector){this.norm=e[1].clone();return}throw wd.ILLEGAL_PARAMETERS}}clone(){return new b4n(this.pt,this.norm)}get slope(){return new Ue.Vector(this.norm.y,-this.norm.x).slope}get box(){let e=this.slope;return new Ue.Box(e>Math.PI/2&&e<3*Math.PI/2?Number.NEGATIVE_INFINITY:this.pt.x,e>=0&&e<=Math.PI?this.pt.y:Number.NEGATIVE_INFINITY,e>=Math.PI/2&&e<=3*Math.PI/2?this.pt.x:Number.POSITIVE_INFINITY,e>=Math.PI&&e<=2*Math.PI||e===0?this.pt.y:Number.POSITIVE_INFINITY)}get start(){return this.pt}get end(){}get length(){return Number.POSITIVE_INFINITY}contains(e){if(this.pt.equalTo(e))return!0;let n=new Ue.Vector(this.pt,e);return Ue.Utils.EQ_0(this.norm.dot(n))&&Ue.Utils.GE(n.cross(this.norm),0)}coord(e){return Ldn(e.x,e.y).cross(this.norm)}split(e){return this.contains(e)?this.pt.equalTo(e)?[this]:[new Ue.Segment(this.pt,e),new Ue.Ray(e,this.norm)]:[]}intersect(e){if(e instanceof Ue.Point)return this.contains(e)?[e]:[];if(e instanceof Ue.Segment)return Xje(this,e);if(e instanceof Ue.Arc)return Zje(this,e);if(e instanceof Ue.Line)return Idn(this,e);if(e instanceof Ue.Ray)return yTi(this,e);if(e instanceof Ue.Circle)return fdn(this,e);if(e instanceof Ue.Box)return CTi(this,e);if(e instanceof Ue.Polygon)return Cdn(this,e);if(e instanceof Ue.Multiline)return GU(this,e)}rotate(e,n=new Ue.Point){return new Ue.Ray(this.pt.rotate(e,n),this.norm.rotate(e))}transform(e){return new Ue.Ray(this.pt.transform(e),this.norm.clone())}get name(){return"ray"}svg(e,n={}){let o=new Ue.Line(this.pt,this.norm),i=HU(o,e);return i=i.filter(s=>this.contains(s)),i.length===0||i.length===2?"":new Ue.Segment(this.pt,i[0]).svg(n)}};Ue.Ray=pki;var mki=(...t)=>new Ue.Ray(...t);Ue.ray=mki;var _ki=class VM{constructor(){this.faces=new Ue.PlanarSet,this.edges=new Ue.PlanarSet;let e=[...arguments];if(e.length===1&&(e[0]instanceof Array&&e[0].length>0||e[0]instanceof Ue.Circle||e[0]instanceof Ue.Box)){let n=e[0];if(e[0]instanceof Array&&e[0].every(o=>o instanceof Array))if(n.every(o=>o instanceof Array&&o.length===2&&typeof o[0]=="number"&&typeof o[1]=="number"))this.faces.add(new Ue.Face(this,n));else for(let o of n)if(o instanceof Array&&o[0]instanceof Array&&o[0].every(i=>i instanceof Array&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number"))for(let i of o)this.faces.add(new Ue.Face(this,i));else this.faces.add(new Ue.Face(this,o));else this.faces.add(new Ue.Face(this,n))}}get box(){return[...this.faces].reduce((e,n)=>e.merge(n.box),new Ue.Box)}get vertices(){return[...this.faces].flatMap(e=>e.vertices)}clone(){let e=new VM;for(let n of this.faces)e.addFace(n.shapes);return e}createFromArray(e){const n=new VM;return e.forEach(o=>[...o.faces].forEach(i=>n.addFace(i.shapes))),n}isEmpty(){return this.edges.size===0||this.faces.size===0}isValid(){let e=!0;for(let n of this.faces)if(!n.isSimple(this.edges)){e=!1;break}return e}area(){let e=[...this.faces].reduce((n,o)=>n+o.signedArea(),0);return Math.abs(e)}addFace(...e){let n=new Ue.Face(this,...e);return this.faces.add(n),n}deleteFace(e){for(let n of e)this.edges.delete(n);return this.faces.delete(e)}recreateFaces(){this.faces.clear();for(let o of this.edges)o.face=null;let e,n=!0;for(;n;){n=!1;for(let o of this.edges)if(o.face===null){e=o,n=!0;break}if(n){let o=e;do o=o.next;while(o.next!==e);this.addFace(e,o)}}}removeChain(e,n,o){if(o.next===n){this.deleteFace(e);return}for(let i=n;i!==o.next;i=i.next)if(e.remove(i),this.edges.delete(i),e.isEmpty()){this.deleteFace(e);break}}addVertex(e,n){let o=n.shape.split(e);if(o[0]===null)return n.prev;if(o[1]===null)return n;let i=new Ue.Edge(o[0]),r=n.prev;return n.face.insert(i,r),this.edges.delete(n),this.edges.add(i),n.shape=o[1],this.edges.add(n),i}removeEndVertex(e){const n=e.next;n!==e&&(e.face.merge_with_next_edge(e),this.edges.delete(n))}cut(e){const o=this.splitToIslands().flatMap(i=>i._cutSingleIsland(e)).filter(i=>i.isValid()&&i.isEmpty()===!1);return this.createFromArray(o)}_cutSingleIsland(e){let n=this.clone();const o=e.clone();let i={int_points1:[],int_points2:[],int_points1_sorted:[],int_points2_sorted:[]};for(let a of o.edges)for(let A of n.edges){let c=pdn(a,A);for(let l of c)YU(a,l,i.int_points1),YU(A,l,i.int_points2)}if(i.int_points1.length===0)return n;i.int_points1_sorted=FP(i.int_points1),i.int_points2_sorted=FP(i.int_points2),KU(o,i.int_points1_sorted),KU(n,i.int_points2_sorted),e$e(i),i.int_points1_sorted=FP(i.int_points1),i.int_points2_sorted=FP(i.int_points2),t$e(i.int_points1),n$e(i.int_points1,n);for(let a of i.int_points1_sorted)a.edge_before&&a.edge_after&&a.edge_before.bv===a.edge_after.bv&&(i.int_points2[a.id]=-1,a.id=-1);if(i.int_points1=i.int_points1.filter(a=>a.id>=0),i.int_points2=i.int_points2.filter(a=>a.id>=0),i.int_points1.forEach((a,A)=>{a.id=A}),i.int_points2.forEach((a,A)=>{a.id=A}),i.int_points1.length===0)return n;i.int_points1_sorted=FP(i.int_points1),i.int_points2_sorted=FP(i.int_points2);let r,s;for(let a=1;a<i.int_points1_sorted.length;a++)if(s=i.int_points1_sorted[a],r=i.int_points1_sorted[a-1],s.edge_before&&s.edge_before.bv===q_e){let A=r.edge_after,c=s.edge_before,l=o.getChain(A,c);xdn(i.int_points2[r.id],i.int_points2[s.id],l),l.forEach(u=>n.edges.add(u)),l=l.reverse().map(u=>new Ue.Edge(u.shape.reverse()));for(let u=0;u<l.length-1;u++)l[u].next=l[u+1],l[u+1].prev=l[u];xdn(i.int_points2[s.id],i.int_points2[r.id],l),l.forEach(u=>n.edges.add(u))}return n.recreateFaces(),n}cutWithLine(e){let n=new GT([e]);return this.cut(n)}findEdgeByPoint(e){let n;for(let o of this.faces)if(n=o.findEdgeByPoint(e),n!==void 0)break;return n}splitToIslands(){if(this.isEmpty())return[];let e=this.toArray();e.sort((i,r)=>r.area()-i.area());let n=[...e[0].faces][0].orientation(),o=e.filter(i=>[...i.faces][0].orientation()===n);for(let i of e){let r=[...i.faces][0];if(r.orientation()!==n){for(let s of o)if(r.shapes.every(a=>s.contains(a))){s.addFace(r.shapes);break}}}return o}rearrange(){if(this.faces.size<=1)return this.clone();const e=this.splitToIslands(),n=new VM;return e.forEach(o=>{o.faces.forEach(i=>n.addFace(i.shapes))}),n}orientation(){return this.isEmpty()?eee.NOT_ORIENTABLE:[...this.faces][0].orientation()}isOuter(e){return e.orientation()===this.orientation()}isMultiPolygon(){let e=0;return this.faces.forEach(n=>{this.isOuter(n)&&e++}),e>1}reverse(){for(let e of this.faces)e.reverse();return this}contains(e){if(e instanceof Ue.Point){let n=aee(this,e);return n===q_e||n===W6}else return kdn(this,e)}distanceTo(e){if(e instanceof Ue.Point){let[n,o]=Ue.Distance.point2polygon(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Circle||e instanceof Ue.Line||e instanceof Ue.Segment||e instanceof Ue.Arc){let[n,o]=Ue.Distance.shape2polygon(e,this);return o=o.reverse(),[n,o]}if(e instanceof Ue.Box)return this.distanceTo(new Ue.Polygon(e));if(e instanceof Ue.Polygon){let n=[Number.POSITIVE_INFINITY,new Ue.Segment],o,i;for(let r of this.edges){let s=n[0];[o,i]=Ue.Distance.shape2planarSet(r.shape,e.edges,s),Ue.Utils.LT(o,s)&&(n=[o,i])}return n}}intersect(e){if(e instanceof Ue.Point)return this.contains(e)?[e]:[];if(e instanceof Ue.Line)return oee(e,this);if(e instanceof Ue.Ray)return Cdn(e,this);if(e instanceof Ue.Circle)return hdn(e,this);if(e instanceof Ue.Segment)return $je(e,this);if(e instanceof Ue.Arc)return qje(e,this);if(e instanceof Ue.Polygon)return fTi(e,this);if(e instanceof Ue.Multiline)return _Ti(e,this)}translate(e){let n=new VM;for(let o of this.faces)n.addFace(o.shapes.map(i=>i.translate(e)));return n}rotate(e=0,n=new Ue.Point){let o=new VM;for(let i of this.faces)o.addFace(i.shapes.map(r=>r.rotate(e,n)));return o}scale(e,n){let o=new VM;for(let i of this.faces)o.addFace(i.shapes.map(r=>r.scale(e,n)));return o}transform(e=new Ue.Matrix){let n=new VM;for(let o of this.faces)n.addFace(o.shapes.map(i=>i.transform(e)));return n}toJSON(){return[...this.faces].map(e=>e.toJSON())}toArray(){return[...this.faces].map(e=>e.toPolygon())}dpath(){return[...this.faces].reduce((e,n)=>e+n.svg(),"")}svg(e={}){let n=`
<path ${HT({fillRule:"evenodd",fill:"lightcyan",...e})} d="`;for(let o of this.faces)n+=`
${o.svg()}`;return n+=`" >
</path>`,n}};Ue.Polygon=_ki;var fki=(...t)=>new Ue.Polygon(...t);Ue.polygon=fki;var{Circle:c$e,Line:Hdn,Point:Odn,Vector:ife,Utils:l$e}=Ue,Iki=class jye{constructor(e){this.circle=e}get inversion_circle(){return this.circle}static inversePoint(e,n){const o=new ife(e.pc,n),i=e.r*e.r,r=o.dot(o);return l$e.EQ_0(r)?new Odn(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):e.pc.translate(o.multiply(i/r))}static inverseCircle(e,n){const o=e.pc.distanceTo(n.pc)[0];if(l$e.EQ(o,n.r)){let i=e.r*e.r/(2*n.r),r=new ife(e.pc,n.pc);r=r.normalize();let s=e.pc.translate(r.multiply(i));return new Hdn(s,r)}else{let i=new ife(e.pc,n.pc),r=e.r*e.r/(i.dot(i)-n.r*n.r),s=e.pc.translate(i.multiply(r)),a=Math.abs(r)*n.r;return new c$e(s,a)}}static inverseLine(e,n){const[o,i]=e.pc.distanceTo(n);if(l$e.EQ_0(o))return n.clone();{let r=e.r*e.r/(2*o),s=new ife(e.pc,i.end);return s=s.multiply(r/o),new c$e(e.pc.translate(s),r)}}inverse(e){if(e instanceof Odn)return jye.inversePoint(this.circle,e);if(e instanceof c$e)return jye.inverseCircle(this.circle,e);if(e instanceof Hdn)return jye.inverseLine(this.circle,e)}};Ue.Inversion=Iki;var Cki=t=>new Ue.Inversion(t);Ue.inversion=Cki;var yki=class Fr{static point2point(e,n){return e.distanceTo(n)}static point2line(e,n){let o=e.projectionOn(n);return[new Ue.Vector(e,o).length,new Ue.Segment(e,o)]}static point2circle(e,n){let[o,i]=e.distanceTo(n.center);if(Ue.Utils.EQ_0(o))return[n.r,new Ue.Segment(e,n.toArc().start)];{let r=Math.abs(o-n.r),s=new Ue.Vector(n.pc,e).normalize().multiply(n.r),a=n.pc.translate(s);return[r,new Ue.Segment(e,a)]}}static point2segment(e,n){if(n.start.equalTo(n.end))return Fr.point2point(e,n.start);let o=new Ue.Vector(n.start,n.end),i=new Ue.Vector(n.start,e),r=new Ue.Vector(n.end,e),s=o.dot(i),a=-o.dot(r),A,c;if(Ue.Utils.GE(s,0)&&Ue.Utils.GE(a,0)){let l=n.tangentInStart();return A=Math.abs(l.cross(i)),c=n.start.translate(l.multiply(l.dot(i))),[A,new Ue.Segment(e,c)]}else return s<0?e.distanceTo(n.start):e.distanceTo(n.end)}static point2arc(e,n){let o=new Ue.Circle(n.pc,n.r),i=[],r,s;return[r,s]=Fr.point2circle(e,o),s.end.on(n)&&i.push(Fr.point2circle(e,o)),i.push(Fr.point2point(e,n.start)),i.push(Fr.point2point(e,n.end)),Fr.sort(i),i[0]}static point2edge(e,n){return n.shape instanceof Ue.Segment?Fr.point2segment(e,n.shape):Fr.point2arc(e,n.shape)}static segment2line(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=[];return i.push(Fr.point2line(e.start,n)),i.push(Fr.point2line(e.end,n)),Fr.sort(i),i[0]}static segment2segment(e,n){let o=efe(e,n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=[],r,s;return[r,s]=Fr.point2segment(n.start,e),i.push([r,s.reverse()]),[r,s]=Fr.point2segment(n.end,e),i.push([r,s.reverse()]),i.push(Fr.point2segment(e.start,n)),i.push(Fr.point2segment(e.end,n)),Fr.sort(i),i[0]}static segment2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=new Ue.Line(e.ps,e.pe),[r,s]=Fr.point2line(n.center,i);if(Ue.Utils.GE(r,n.r)&&s.end.on(e))return Fr.point2circle(s.end,n);{let[a,A]=Fr.point2circle(e.start,n),[c,l]=Fr.point2circle(e.end,n);return Ue.Utils.LT(a,c)?[a,A]:[c,l]}}static segment2arc(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=new Ue.Line(e.ps,e.pe),r=new Ue.Circle(n.pc,n.r),[s,a]=Fr.point2line(r.center,i);if(Ue.Utils.GE(s,r.r)&&a.end.on(e)){let[u,g]=Fr.point2circle(a.end,r);if(g.end.on(n))return[u,g]}let A=[];A.push(Fr.point2arc(e.start,n)),A.push(Fr.point2arc(e.end,n));let c,l;return[c,l]=Fr.point2segment(n.start,e),A.push([c,l.reverse()]),[c,l]=Fr.point2segment(n.end,e),A.push([c,l.reverse()]),Fr.sort(A),A[0]}static circle2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];if(e.center.equalTo(n.center)){let i=e.toArc(),r=n.toArc();return Fr.point2point(i.start,r.start)}else{let i=new Ue.Line(e.center,n.center),r=i.intersect(e),s=i.intersect(n),a=[];return a.push(Fr.point2point(r[0],s[0])),a.push(Fr.point2point(r[0],s[1])),a.push(Fr.point2point(r[1],s[0])),a.push(Fr.point2point(r[1],s[1])),Fr.sort(a),a[0]}}static circle2line(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let[i,r]=Fr.point2line(e.center,n),[s,a]=Fr.point2circle(r.end,e);return a=a.reverse(),[s,a]}static arc2line(e,n){let o=n.intersect(e);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=new Ue.Circle(e.center,e.r),[r,s]=Fr.point2line(i.center,n);if(Ue.Utils.GE(r,i.r)){let[a,A]=Fr.point2circle(s.end,i);if(A.end.on(e))return[a,A]}else{let a=[];return a.push(Fr.point2line(e.start,n)),a.push(Fr.point2line(e.end,n)),Fr.sort(a),a[0]}}static arc2circle(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=new Ue.Circle(e.center,e.r),[r,s]=Fr.circle2circle(i,n);if(s.start.on(e))return[r,s];{let a=[];return a.push(Fr.point2circle(e.start,n)),a.push(Fr.point2circle(e.end,n)),Fr.sort(a),a[0]}}static arc2arc(e,n){let o=e.intersect(n);if(o.length>0)return[0,new Ue.Segment(o[0],o[0])];let i=new Ue.Circle(e.center,e.r),r=new Ue.Circle(n.center,n.r),[s,a]=Fr.circle2circle(i,r);if(a.start.on(e)&&a.end.on(n))return[s,a];{let A=[],c,l;return[c,l]=Fr.point2arc(e.start,n),l.end.on(n)&&A.push([c,l]),[c,l]=Fr.point2arc(e.end,n),l.end.on(n)&&A.push([c,l]),[c,l]=Fr.point2arc(n.start,e),l.end.on(e)&&A.push([c,l.reverse()]),[c,l]=Fr.point2arc(n.end,e),l.end.on(e)&&A.push([c,l.reverse()]),[c,l]=Fr.point2point(e.start,n.start),A.push([c,l]),[c,l]=Fr.point2point(e.start,n.end),A.push([c,l]),[c,l]=Fr.point2point(e.end,n.start),A.push([c,l]),[c,l]=Fr.point2point(e.end,n.end),A.push([c,l]),Fr.sort(A),A[0]}}static point2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of n.edges){let[r,s]=Fr.point2edge(e,i);Ue.Utils.LT(r,o[0])&&(o=[r,s])}return o}static shape2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of n.edges){let[r,s]=e.distanceTo(i.shape);Ue.Utils.LT(r,o[0])&&(o=[r,s])}return o}static polygon2polygon(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of e.edges)for(let r of n.edges){let[s,a]=i.shape.distanceTo(r.shape);Ue.Utils.LT(s,o[0])&&(o=[s,a])}return o}static box2box_minmax(e,n){let o=Math.max(Math.max(e.xmin-n.xmax,0),Math.max(n.xmin-e.xmax,0)),i=Math.max(Math.max(e.ymin-n.ymax,0),Math.max(n.ymin-e.ymax,0)),r=o*o+i*i,s=e.merge(n),a=s.xmax-s.xmin,A=s.ymax-s.ymin,c=a*a+A*A;return[r,c]}static minmax_tree_process_level(e,n,o,i){let r,s;for(let l of n){[r,s]=Fr.box2box_minmax(e.box,l.item.key);for(let u of l.item.values)u instanceof Ue.Edge?i.insert([r,s],u.shape):i.insert([r,s],u);Ue.Utils.LT(s,o)&&(o=s)}if(n.length===0)return o;let a=n.map(l=>l.left.isNil()?void 0:l.left).filter(l=>l!==void 0),A=n.map(l=>l.right.isNil()?void 0:l.right).filter(l=>l!==void 0),c=[...a,...A].filter(l=>{let[u,g]=Fr.box2box_minmax(e.box,l.max);return Ue.Utils.LE(u,o)});return o=Fr.minmax_tree_process_level(e,c,o,i),o}static minmax_tree(e,n,o){let i=new A$e,r=[n.index.root],s=o<Number.POSITIVE_INFINITY?o*o:Number.POSITIVE_INFINITY;return s=Fr.minmax_tree_process_level(e,r,s,i),i}static minmax_tree_calc_distance(e,n,o){let i,r;if(n!=null&&!n.isNil()){if([i,r]=Fr.minmax_tree_calc_distance(e,n.left,o),r)return[i,r];if(Ue.Utils.LT(i[0],Math.sqrt(n.item.key.low)))return[i,!0];let[s,a]=Fr.distanceToArray(e,n.item.values);return Ue.Utils.LT(s,i[0])&&(i=[s,a]),[i,r]=Fr.minmax_tree_calc_distance(e,n.right,i),[i,r]}return[o,!1]}static shape2planarSet(e,n,o=Number.POSITIVE_INFINITY){let i=[o,new Ue.Segment],r=!1;if(n instanceof Ue.PlanarSet){let s=Fr.minmax_tree(e,n,o);[i,r]=Fr.minmax_tree_calc_distance(e,s.root,i)}return i}static sort(e){e.sort((n,o)=>Ue.Utils.LT(n[0],o[0])?-1:Ue.Utils.GT(n[0],o[0])?1:0)}static distance(e,n){return e.distanceTo(n)}static distanceToArray(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of n){let[r,s]=e.distanceTo(i);Ue.Utils.LT(r,o[0])&&(o=[r,s])}return o}static shape2multiline(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of n){let[r,s]=Fr.distance(e,i.shape);Ue.Utils.LT(r,o[0])&&(o=[r,s])}return o}static multiline2multiline(e,n){let o=[Number.POSITIVE_INFINITY,new Ue.Segment];for(let i of e)for(let r of n){let[s,a]=Fr.distance(i.shape,r.shape);Ue.Utils.LT(s,o[0])&&(o=[s,a])}return o}};Ue.Distance=yki;var{Multiline:xki,Point:Gdn,Segment:Eki,Polygon:Ydn}=Ue;function u$e(t){return new Gdn(t.split(" ").map(Number))}function Udn(t){return t.split(", ").map(u$e)}function g$e(t){const e=Udn(t);let n=[];for(let o=0;o<e.length-1;o++)n.push(new Eki(e[o],e[o+1]));return new xki(n)}function Bki(t){return t.replace(/\(\(/,"").replace(/\)\)$/,"").split("), (").map(g$e)}function Kdn(t){const e=t.replace(/\(\(/,"").replace(/\)\)$/,"").split("), ("),n=new Ydn;let o;return e.forEach((i,r)=>{let s=i.split(", ").map(A=>new Gdn(A.split(" ").map(Number)));const a=n.addFace(s);r===0?o=a.orientation():a.orientation()===o&&a.reverse()}),n}function bki(t){const n=t.split(/\)\), \(\(/).map(r=>"(("+r+"))").map(Kdn),o=new Ydn;return n.reduce((r,s)=>[...r,...s?.faces],[]).forEach(r=>o.addFace([...r?.shapes])),o}function Ski(t){if(t.startsWith("POLYGON")){const e=t.replace(/^POLYGON /,"");return Kdn(e)}else{const e=t.replace(/^MULTIPOLYGON \(\(\((.*)\)\)\)$/,"$1");return bki(e)}}function Qki(t){return t.split(`
`).map(n=>n.match(/\(([^)]+)\)/)[1]).map(u$e)}function vki(t){return t.split(`
`).map(n=>n.match(/\(([^)]+)\)/)[1]).map(g$e).reduce((n,o)=>[...n,...o],[])}function Vdn(t){if(t.startsWith("POINT")){const e=t.replace(/^POINT \(/,"").replace(/\)$/,"");return u$e(e)}else if(t.startsWith("MULTIPOINT")){const e=t.replace(/^MULTIPOINT \(/,"").replace(/\)$/,"");return Udn(e)}else if(t.startsWith("LINESTRING")){const e=t.replace(/^LINESTRING \(/,"").replace(/\)$/,"");return g$e(e)}else if(t.startsWith("MULTILINESTRING")){const e=t.replace(/^MULTILINESTRING /,"");return Bki(e)}else{if(t.startsWith("POLYGON")||t.startsWith("MULTIPOLYGON"))return Ski(t);if(t.startsWith("GEOMETRYCOLLECTION")){const e=/(?<type>POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON) \((?:[^\(\)]|\([^\)]*\))*\)/g,n=t.match(e);return n[0].startsWith("GEOMETRYCOLLECTION")&&(n[0]=n[0].replace("GEOMETRYCOLLECTION (","")),n.map(Vdn).map(i=>i instanceof Array?i:[i]).reduce((i,r)=>[...i,...r],[])}else{if(zdn(t))return Qki(t);if(Jdn(t))return vki(t)}}return[]}function zdn(t){return t.split(`
`)?.every(e=>e.includes("POINT"))}function Jdn(t){return t.split(`
`)?.every(e=>e.includes("LINESTRING"))}function wki(t){return t.startsWith("POINT")||zdn(t)||t.startsWith("LINESTRING")||Jdn(t)||t.startsWith("MULTILINESTRING")||t.startsWith("POLYGON")||t.startsWith("MULTIPOINT")||t.startsWith("MULTIPOLYGON")||t.startsWith("GEOMETRYCOLLECTION")}Ue.isWktString=wki,Ue.parseWKT=Vdn,Ue.BooleanOperations=RTi,Ue.Relations=WTi;function Wdn(t,e,n){if(!e||!n)return;let o=t.get(e);o||(o=new Set,t.set(e,o)),o.add(n);let i=t.get(n);i||(i=new Set,t.set(n,i)),i.add(e)}function jdn(t,e){if(!e.subcircuit_id&&!e.source_group_id)return[...t];let n=e;if(e.subcircuit_id){const a=new Set([e.subcircuit_id]),A=new Map,c=new Map;for(const u of t)if(u.type==="source_group"){const g=u.source_group_id,h=u.subcircuit_id;h&&c.set(g,h);const d=u.parent_source_group_id;d&&(A.has(d)||A.set(d,[]),A.get(d).push(g))}let l;for(const[u,g]of c)if(g===e.subcircuit_id){l=u;break}if(l){const u=g=>{const h=A.get(g)||[];for(const d of h){const p=c.get(d);p&&a.add(p),u(d)}};u(l),n={...e,subcircuit_ids:Array.from(a)}}}const o=new Map;for(const a of t){const A=`${a.type}_id`,c=a[A];typeof c=="string"&&o.set(c,a)}const i=new Map;for(const a of t){const A=Object.entries(a);for(const[c,l]of A)if(c!=="parent_source_group_id"){if(c.endsWith("_id")&&typeof l=="string"){const u=o.get(l);Wdn(i,a,u)}else if(c.endsWith("_ids")&&Array.isArray(l)){for(const u of l)if(typeof u=="string"){const g=o.get(u);Wdn(i,a,g)}}}}const r=[],s=new Set;for(const a of t){let A=!1;(n.subcircuit_id&&"subcircuit_id"in a&&a.subcircuit_id===n.subcircuit_id||n.subcircuit_ids&&"subcircuit_id"in a&&a.subcircuit_id&&n.subcircuit_ids.includes(a.subcircuit_id)||n.source_group_id&&"source_group_id"in a&&a.source_group_id===n.source_group_id||n.source_group_id&&"member_source_group_ids"in a&&Array.isArray(a.member_source_group_ids)&&a.member_source_group_ids.includes(n.source_group_id))&&(A=!0),A&&(r.push(a),s.add(a))}for(;r.length>0;){const a=r.shift(),A=i.get(a);if(A)for(const c of A)s.has(c)||(s.add(c),r.push(c))}return t.filter(a=>s.has(a))}var rfe=(t,e={})=>{const n=t;let o=n._internal_store;if(!o){o={counts:{},editCount:0},n._internal_store=o;for(const r of n){const s=r.type,a=r[`${s}_id`];if(!a)continue;const A=Number.parseInt(a.split("_").pop());Number.isNaN(A)||(o.counts[s]=Math.max(o.counts[s]??0,A))}}const i=new Proxy({},{get:(r,s)=>{if(s==="toArray")return()=>(n.editCount=o.editCount,n);if(s==="editCount")return o.editCount;if(s==="subtree")return A=>rfe(jdn(n,A),e);if(s==="insert")return A=>{const c=A.type;if(!c)throw new Error("insert requires an element with a type");o.counts[c]??=-1,o.counts[c]++;const l=o.counts[c],u={...A,type:c,[`${c}_id`]:`${c}_${l}`};return e.validateInserts&&(R9[c]??U4).parse(u),n.push(u),o.editCount++,u};if(s==="insertAll")return A=>A.map(c=>i.insert(c));const a=s;return{get:A=>n.find(c=>c.type===a&&c[`${a}_id`]===A),getUsing:A=>{const c=Object.keys(A);if(c.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=c[0],u=l.replace("_id",""),g=n.find(h=>h.type===u&&h[l]===A[l]);return g?n.find(h=>h.type===a&&h[`${a}_id`]===g[`${a}_id`]):null},getWhere:A=>{const c=Object.keys(A);return n.find(l=>l.type===a&&c.every(u=>l[u]===A[u]))},list:A=>{const c=A?Object.keys(A):[];return n.filter(l=>l.type===a&&c.every(u=>l[u]===A[u]))},insert:A=>{o.counts[a]??=-1,o.counts[a]++;const c=o.counts[a],l={type:a,[`${a}_id`]:`${a}_${c}`,...A};return e.validateInserts&&(R9[a]??U4).parse(l),n.push(l),o.editCount++,l},delete:A=>{const c=n.find(l=>l[`${a}_id`]===A);c&&(n.splice(n.indexOf(c),1),o.editCount++)},update:(A,c)=>{const l=n.find(u=>u.type===a&&u[`${a}_id`]===A);return l?(Object.assign(l,c),o.editCount++,l):null},select:A=>{if(a==="source_component")return n.find(c=>c.type==="source_component"&&c.name===A.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="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 g=n.find(h=>h.type==="source_port"&&h.source_component_id===u.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!g)return null;if(a==="source_port")return g;if(a==="pcb_port")return n.find(h=>h.type==="pcb_port"&&h.source_port_id===g.source_port_id);if(a==="schematic_port")return n.find(h=>h.type==="schematic_port"&&h.source_port_id===g.source_port_id)}}}}});return i};rfe.unparsed=rfe;var wS=rfe;function d$e(t){const e=t.type;return`${e}:${t[`${e}_id`]}`}var h$e=(t,e={})=>{let n=t._internal_store_indexed;if(!n){n={counts:{},editCount:0,indexes:{}};for(const s of t){const a=s.type,A=s[`${a}_id`];if(!A)continue;const c=Number.parseInt(A.split("_").pop()||"");Number.isNaN(c)||(n.counts[a]=Math.max(n.counts[a]??0,c))}const i=e.indexConfig||{},r=n.indexes;if(i.byId&&(r.byId=new Map),i.byType&&(r.byType=new Map),i.byRelation&&(r.byRelation=new Map),i.bySubcircuit&&(r.bySubcircuit=new Map),i.byCustomField&&i.byCustomField.length>0){r.byCustomField=new Map;for(const s of i.byCustomField)r.byCustomField.set(s,new Map)}for(const s of t){if(i.byId){const a=d$e(s);r.byId.set(a,s)}if(i.byType){const a=r.byType.get(s.type)||[];a.push(s),r.byType.set(s.type,a)}if(i.byRelation){const a=Object.entries(s);for(const[A,c]of a)if(A.endsWith("_id")&&A!==`${s.type}_id`&&typeof c=="string"){const l=r.byRelation.get(A)||new Map,u=l.get(c)||[];u.push(s),l.set(c,u),r.byRelation.set(A,l)}}if(i.bySubcircuit&&"subcircuit_id"in s){const a=s.subcircuit_id;if(a&&typeof a=="string"){const A=r.bySubcircuit.get(a)||[];A.push(s),r.bySubcircuit.set(a,A)}}if(i.byCustomField&&r.byCustomField){for(const a of i.byCustomField)if(a in s){const A=s[a];if(A!==void 0&&(typeof A=="string"||typeof A=="number")){const c=String(A),l=r.byCustomField.get(a),u=l.get(c)||[];u.push(s),l.set(c,u)}}}}t._internal_store_indexed=n}const o=new Proxy({},{get:(i,r)=>{if(r==="toArray")return()=>(t.editCount=n.editCount,t);if(r==="editCount")return n.editCount;if(r==="insert")return a=>{const{type:A,...c}=a;if(!A)throw new Error("insert requires an element with a type");return delete c[`${A}_id`],o[A].insert(c)};if(r==="insertAll")return a=>a.map(A=>o.insert(A));if(r==="subtree")return a=>h$e(jdn(t,a),e);const s=r;return{get:a=>{const A=e.indexConfig||{};return A.byId&&n.indexes.byId?n.indexes.byId.get(`${s}:${a}`)||null:A.byType&&n.indexes.byType?(n.indexes.byType.get(s)||[]).find(l=>l[`${s}_id`]===a)||null:t.find(c=>c.type===s&&c[`${s}_id`]===a)||null},getUsing:a=>{const A=e.indexConfig||{},c=Object.keys(a);if(c.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=c[0],u=l.replace("_id","");if(A.byRelation&&n.indexes.byRelation){const h=n.indexes.byRelation.get(l);if(h){const p=(h.get(a[l])||[]).find(_=>_.type===u);if(!p)return null;const m=p[`${s}_id`];return A.byId&&n.indexes.byId?n.indexes.byId.get(`${s}:${m}`)||null:A.byType&&n.indexes.byType?(n.indexes.byType.get(s)||[]).find(f=>f[`${s}_id`]===m)||null:t.find(_=>_.type===s&&_[`${s}_id`]===m)||null}}const g=t.find(h=>h.type===u&&h[l]===a[l]);return g&&t.find(h=>h.type===s&&h[`${s}_id`]===g[`${s}_id`])||null},getWhere:a=>{const A=e.indexConfig||{},c=Object.keys(a);if(c.length===1&&A.byCustomField&&n.indexes.byCustomField){const l=c[0],u=n.indexes.byCustomField.get(l);if(u){const g=String(a[l]);return(u.get(g)||[]).find(d=>d.type===s)||null}}if("subcircuit_id"in a&&A.bySubcircuit&&n.indexes.bySubcircuit){const l=a.subcircuit_id;return(n.indexes.bySubcircuit.get(l)||[]).find(g=>g.type===s&&c.every(h=>g[h]===a[h]))||null}return A.byType&&n.indexes.byType?(n.indexes.byType.get(s)||[]).find(u=>c.every(g=>u[g]===a[g]))||null:t.find(l=>l.type===s&&c.every(u=>l[u]===a[u]))||null},list:a=>{const A=e.indexConfig||{},c=a?Object.keys(a):[];if(c.length===0&&A.byType&&n.indexes.byType)return(n.indexes.byType.get(s)||[]).slice();if(c.length===1&&c[0]==="subcircuit_id"&&A.bySubcircuit&&n.indexes.bySubcircuit){const u=a.subcircuit_id;return(n.indexes.bySubcircuit.get(u)||[]).filter(h=>h.type===s)}let l;return A.byType&&n.indexes.byType?l=n.indexes.byType.get(s)||[]:l=t.filter(u=>u.type===s),c.length>0?l.filter(u=>c.every(g=>u[g]===a[g])):l.slice()},insert:a=>{n.counts[s]??=-1,n.counts[s]++;const A=n.counts[s],c={type:s,[`${s}_id`]:`${s}_${A}`,...a};e.validateInserts&&(R9[s]??U4).parse(c),t.push(c),n.editCount++;const l=e.indexConfig||{};if(l.byId&&n.indexes.byId){const u=d$e(c);n.indexes.byId.set(u,c)}if(l.byType&&n.indexes.byType){const u=n.indexes.byType.get(s)||[];u.push(c),n.indexes.byType.set(s,u)}if(l.byRelation&&n.indexes.byRelation){const u=Object.entries(c);for(const[g,h]of u)if(g.endsWith("_id")&&g!==`${c.type}_id`&&typeof h=="string"){const d=n.indexes.byRelation.get(g)||new Map,p=d.get(h)||[];p.push(c),d.set(h,p),n.indexes.byRelation.set(g,d)}}if(l.bySubcircuit&&n.indexes.bySubcircuit&&"subcircuit_id"in c){const u=c.subcircuit_id;if(u&&typeof u=="string"){const g=n.indexes.bySubcircuit.get(u)||[];g.push(c),n.indexes.bySubcircuit.set(u,g)}}if(l.byCustomField&&n.indexes.byCustomField){for(const u of l.byCustomField)if(u in c){const g=c[u];if(g!==void 0&&(typeof g=="string"||typeof g=="number")){const h=String(g),d=n.indexes.byCustomField.get(u),p=d.get(h)||[];p.push(c),d.set(h,p)}}}return c},delete:a=>{const A=e.indexConfig||{};let c;if(A.byId&&n.indexes.byId?c=n.indexes.byId.get(`${s}:${a}`):A.byType&&n.indexes.byType?c=(n.indexes.byType.get(s)||[]).find(g=>g[`${s}_id`]===a):c=t.find(u=>u[`${s}_id`]===a),!c)return;const l=t.indexOf(c);if(l>=0&&(t.splice(l,1),n.editCount++),A.byId&&n.indexes.byId){const u=d$e(c);n.indexes.byId.delete(u)}if(A.byType&&n.indexes.byType){const g=(n.indexes.byType.get(s)||[]).filter(h=>h[`${s}_id`]!==a);n.indexes.byType.set(s,g)}if(A.byRelation&&n.indexes.byRelation)for(const[u,g]of n.indexes.byRelation.entries())for(const[h,d]of g.entries()){const p=d.filter(m=>m!==c);p.length===0?g.delete(h):g.set(h,p)}if(A.bySubcircuit&&n.indexes.bySubcircuit&&"subcircuit_id"in c){const u=c.subcircuit_id;if(u){const h=(n.indexes.bySubcircuit.get(u)||[]).filter(d=>d!==c);h.length===0?n.indexes.bySubcircuit.delete(u):n.indexes.bySubcircuit.set(u,h)}}if(A.byCustomField&&n.indexes.byCustomField)for(const u of n.indexes.byCustomField.values())for(const[g,h]of u.entries()){const d=h.filter(p=>p!==c);d.length===0?u.delete(g):u.set(g,d)}},update:(a,A)=>{const c=e.indexConfig||{};let l;if(c.byId&&n.indexes.byId?l=n.indexes.byId.get(`${s}:${a}`):c.byType&&n.indexes.byType?l=(n.indexes.byType.get(s)||[]).find(g=>g[`${s}_id`]===a):l=t.find(u=>u.type===s&&u[`${s}_id`]===a),!l)return null;if(c.byRelation&&n.indexes.byRelation){const u=Object.entries(l);for(const[g,h]of u)if(g.endsWith("_id")&&g!==`${l.type}_id`&&typeof h=="string"&&g in A&&A[g]!==h){const d=n.indexes.byRelation.get(g);if(d){const m=(d.get(h)||[]).filter(_=>_!==l);m.length===0?d.delete(h):d.set(h,m)}}}if(c.bySubcircuit&&n.indexes.bySubcircuit&&"subcircuit_id"in l&&"subcircuit_id"in A){const u=l.subcircuit_id,g=A.subcircuit_id;if(u!==g){const d=(n.indexes.bySubcircuit.get(u)||[]).filter(p=>p!==l);d.length===0?n.indexes.bySubcircuit.delete(u):n.indexes.bySubcircuit.set(u,d)}}if(c.byCustomField&&n.indexes.byCustomField){for(const u of c.byCustomField)if(u in l&&u in A&&l[u]!==A[u]){const g=n.indexes.byCustomField.get(u);if(g){const h=String(l[u]),p=(g.get(h)||[]).filter(m=>m!==l);p.length===0?g.delete(h):g.set(h,p)}}}if(Object.assign(l,A),n.editCount++,c.byRelation&&n.indexes.byRelation){const u=Object.entries(l);for(const[g,h]of u)if(g.endsWith("_id")&&g!==`${l.type}_id`&&typeof h=="string"&&g in A){const d=n.indexes.byRelation.get(g)||new Map,p=d.get(h)||[];p.includes(l)||(p.push(l),d.set(h,p),n.indexes.byRelation.set(g,d))}}if(c.bySubcircuit&&n.indexes.bySubcircuit&&"subcircuit_id"in l&&"subcircuit_id"in A){const u=l.subcircuit_id;if(u&&typeof u=="string"){const g=n.indexes.bySubcircuit.get(u)||[];g.includes(l)||(g.push(l),n.indexes.bySubcircuit.set(u,g))}}if(c.byCustomField&&n.indexes.byCustomField){for(const u of c.byCustomField)if(u in l&&u in A){const g=l[u];if(g!==void 0&&(typeof g=="string"||typeof g=="number")){const h=String(g),d=n.indexes.byCustomField.get(u),p=d.get(h)||[];p.includes(l)||(p.push(l),d.set(h,p))}}}return l},select:a=>{if(s==="source_component")return t.find(A=>A.type==="source_component"&&A.name===a.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[A,c]=a.replace(/\./g,"").split(/[\s\>]+/),l=t.find(g=>g.type==="source_component"&&g.name===A);if(!l)return null;const u=t.find(g=>g.type==="source_port"&&g.source_component_id===l.source_component_id&&(g.name===c||(g.port_hints??[]).includes(c)));if(!u)return null;if(s==="source_port")return u;if(s==="pcb_port")return t.find(g=>g.type==="pcb_port"&&g.source_port_id===u.source_port_id)||null;if(s==="schematic_port")return t.find(g=>g.type==="schematic_port"&&g.source_port_id===u.source_port_id)||null}return null}}}});return o};h$e.unparsed=h$e;var Pki=t=>Math.round(t/(Math.PI/2)),Mki=t=>{switch(t){case"from_left":return{x:-1,y:0};case"from_right":return{x:1,y:0};case"from_top":return{x:0,y:1};case"from_bottom":return{x:0,y:-1}}},Dki=({x:t,y:e})=>t>0?"from_right":t<0?"from_left":e>0?"from_top":"from_bottom",Nki=(t,e)=>{if(!t)return t;if(t==="from_above"||t==="from_below")return e.isFlipped?t==="from_above"?"from_below":"from_above":t;let{x:n,y:o}=Mki(t),i=Math.round(e.rotationDegrees/90);for(;i>0;)[n,o]=[-o,n],i--;for(;i<0;)[n,o]=[o,-n],i++;return e.isFlipped&&(o=-o),Dki({x:n,y:o})},Rki=(t,e)=>{const n=MNi(e),o=Math.abs(Pki(n.rotation.angle))%2===1,i=n.rotation.angle/Math.PI*180,r=n.scale.sy<0;if(t.type==="pcb_plated_hole"||t.type==="pcb_hole"||t.type==="pcb_via"||t.type==="pcb_smtpad"||t.type==="pcb_solder_paste"||t.type==="pcb_port"){const{x:s,y:a}=_i(e,{x:Number(t.x),y:Number(t.y)});t.x=s,t.y=a,t.type==="pcb_smtpad"&&t.shape==="polygon"&&Array.isArray(t.points)&&(t.points=t.points.map(A=>{const c=_i(e,{x:A.x,y:A.y});return{x:c.x,y:c.y}}))}else if(t.type==="pcb_keepout"||t.type==="pcb_board")t.center=_i(e,t.center);else if(t.type==="pcb_silkscreen_text"||t.type==="pcb_fabrication_note_text"||t.type==="pcb_note_text")t.anchor_position=_i(e,t.anchor_position);else if(t.type==="pcb_copper_text")t.anchor_position&&(t.anchor_position=_i(e,t.anchor_position));else if(t.type==="pcb_courtyard_rect")t.center=_i(e,t.center),t.ccw_rotation=((t.ccw_rotation??0)+i)%360;else if(t.type==="pcb_silkscreen_circle"||t.type==="pcb_silkscreen_rect"||t.type==="pcb_silkscreen_pill"||t.type==="pcb_silkscreen_oval"||t.type==="pcb_note_rect"||t.type==="pcb_courtyard_circle")t.center=_i(e,t.center);else if(t.type==="pcb_component")t.center=_i(e,t.center),t.rotation=t.rotation+i,t.rotation=t.rotation%360,t.cable_insertion_center&&(t.cable_insertion_center=_i(e,t.cable_insertion_center)),t.insertion_direction=Nki(t.insertion_direction,{rotationDegrees:i,isFlipped:r}),o&&([t.width,t.height]=[t.height,t.width]);else if(t.type==="pcb_courtyard_outline")t.outline=t.outline.map(s=>{const a=_i(e,s);return s.x=a.x,s.y=a.y,s});else if(t.type==="pcb_courtyard_polygon")t.points=t.points.map(s=>{const a=_i(e,s);return s.x=a.x,s.y=a.y,s});else if(t.type==="pcb_trace")t.route=t.route.map(s=>{if(!("x"in s))return s.start=_i(e,s.start),s.end=_i(e,s.end),s;const a=_i(e,s);return s.x=a.x,s.y=a.y,s});else if(t.type==="pcb_silkscreen_path"||t.type==="pcb_trace_hint"||t.type==="pcb_fabrication_note_path"||t.type==="pcb_note_path")t.route=t.route.map(s=>{const a=_i(e,s);return s.x=a.x,s.y=a.y,s});else if(t.type==="pcb_silkscreen_line"||t.type==="pcb_note_line"){const s={x:t.x1,y:t.y1},a={x:t.x2,y:t.y2},A=_i(e,s),c=_i(e,a);t.x1=A.x,t.y1=A.y,t.x2=c.x,t.y2=c.y}else if(t.type==="cad_component"){const s=_i(e,{x:t.position.x,y:t.position.y});t.position.x=s.x,t.position.y=s.y}return t},Tki=t=>{const e=t.type;return t[`${e}_id`]},p$e=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),lee=(t,e,n)=>{const o=n/2;return{minX:t-o,minY:e-o,maxX:t+o,maxY:e+o}},$dn=(t,e,n,o,i)=>{const r=n/2,s=o/2,a=i*Math.PI/180,A=Math.cos(a),c=Math.sin(a),l=[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}].map(u=>({x:t+u.x*A-u.y*c,y:e+u.x*c+u.y*A}));return{minX:Math.min(...l.map(u=>u.x)),minY:Math.min(...l.map(u=>u.y)),maxX:Math.max(...l.map(u=>u.x)),maxY:Math.max(...l.map(u=>u.y))}},kki=(t,e,n,o,i)=>{const r=n/2,s=o/2,a=i*Math.PI/180,A=Math.cos(a),c=Math.sin(a),l=Math.hypot(r*A,s*c),u=Math.hypot(r*c,s*A);return{minX:t-l,minY:e-u,maxX:t+l,maxY:e+u}},Fki=(t,e,n,o,i)=>{const r=Math.min(n,o)/2,s=Math.max(n,o)/2-r,a=i*Math.PI/180,A=n>=o?{x:s,y:0}:{x:0,y:s},c={x:A.x*Math.cos(a)-A.y*Math.sin(a),y:A.x*Math.sin(a)+A.y*Math.cos(a)},l=Math.abs(c.x)+r,u=Math.abs(c.y)+r;return{minX:t-l,minY:e-u,maxX:t+l,maxY:e+u}},sfe=t=>t.length===0?null:{minX:Math.min(...t.map(e=>e.x)),minY:Math.min(...t.map(e=>e.y)),maxX:Math.max(...t.map(e=>e.x)),maxY:Math.max(...t.map(e=>e.y))},m$e=t=>Array.isArray(t)?t.flatMap(e=>!e||typeof e!="object"?[]:"x"in e&&"y"in e&&typeof e.x=="number"&&typeof e.y=="number"?[{x:e.x,y:e.y}]:"start"in e&&"end"in e?[e.start,e.end].filter(o=>!!(o&&typeof o=="object"&&"x"in o&&"y"in o&&typeof o.x=="number"&&typeof o.y=="number")):[]):[],Lki=t=>{if(!t.type.startsWith("pcb_"))return null;if(t.type==="pcb_smtpad"&&t.shape==="polygon"&&Array.isArray(t.points))return sfe(t.points);if(t.type==="pcb_hole"&&t.hole_shape==="circle")return lee(t.x,t.y,t.hole_diameter);if(t.type==="pcb_plated_hole"){let u;if("outer_diameter"in t&&typeof t.outer_diameter=="number"?u=lee(t.x,t.y,t.outer_diameter):"hole_diameter"in t&&typeof t.hole_diameter=="number"&&(u=lee(t.x,t.y,t.hole_diameter)),(t.shape==="oval"||t.shape==="pill")&&typeof t.outer_width=="number"&&typeof t.outer_height=="number"&&(u=(t.shape==="pill"?Fki:kki)(t.x,t.y,t.outer_width,t.outer_height,t.ccw_rotation??0)),"rect_pad_width"in t&&typeof t.rect_pad_width=="number"&&"rect_pad_height"in t&&typeof t.rect_pad_height=="number"){const g=$dn(t.x,t.y,t.rect_pad_width,t.rect_pad_height,"rect_ccw_rotation"in t?t.rect_ccw_rotation??0:0);u=u?p$e(u,g):g}if("hole_diameter"in t&&typeof t.hole_diameter=="number"){const g=lee(t.x+("hole_offset_x"in t?t.hole_offset_x??0:0),t.y+("hole_offset_y"in t?t.hole_offset_y??0:0),t.hole_diameter);u=u?p$e(u,g):g}if(u)return u}const e=t,n=sfe(m$e(e.route));if(n)return n;const o=sfe(m$e(e.outline));if(o)return o;const i=sfe(m$e(e.points));if(i)return i;let r,s,a,A;"x"in t&&"y"in t&&(r=Number(t.x),s=Number(t.y)),"outer_diameter"in t&&(a=Number(t.outer_diameter),A=Number(t.outer_diameter)),"width"in t&&(a=Number(t.width)),"height"in t&&(A=Number(t.height)),"center"in t&&t.center&&typeof t.center=="object"&&"x"in t.center&&"y"in t.center&&(r=Number(t.center.x),s=Number(t.center.y));let c=0;if("rotation"in t&&typeof t.rotation=="number"&&(c=t.rotation),"ccw_rotation"in t&&typeof t.ccw_rotation=="number"&&(c=t.ccw_rotation),r!==void 0&&s!==void 0)return a!==void 0&&A!==void 0?c?$dn(r,s,a,A,c):{minX:r-a/2,minY:s-A/2,maxX:r+a/2,maxY:s+A/2}:"radius"in t&&typeof t.radius=="number"?lee(r,s,t.radius*2):{minX:r,minY:s,maxX:r,maxY:s};const l=[e.anchor_position,e.position].filter(u=>!!(u&&typeof u=="object"&&"x"in u&&"y"in u&&typeof u.x=="number"&&typeof u.y=="number")).at(0);return l?{minX:l.x,minY:l.y,maxX:l.x,maxY:l.y}:null},_$e=t=>{let e={minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY};for(const n of t){const o=Lki(n);o&&(e=p$e(e,o))}return e};function Hki(t){let e=0;if(t.length==0)return e;for(var n=0;n<t.length;n++){var o=t.charCodeAt(n);e=(e<<5)-e+o,e=e&e}return Math.abs(e)}var qdn=[["#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"]],Oki=t=>{let{x:e,y:n,width:o,height:i}={...t,...t.size,...t.center,...t.position};if(t.x1!==void 0&&t.x2!==void 0&&t.y1!==void 0&&t.y2!==void 0&&(e=(t.x1+t.x2)/2,n=(t.y1+t.y2)/2,o=Math.abs(t.x1-t.x2),i=Math.abs(t.y1-t.y2)),t.points&&Array.isArray(t.points)&&t.points.length>0){const a=t.points.map(h=>h.x),A=t.points.map(h=>h.y),c=Math.min(...a),l=Math.max(...a),u=Math.min(...A),g=Math.max(...A);e=(c+l)/2,n=(u+g)/2,o=l-c,i=g-u}const r=t.text||t.name||t.source?.text||t.source?.name||"?",s=t;return e===void 0||n===void 0?null:(o===void 0&&("radius"in t?(o=t.radius*2,i=t.radius*2):"outer_diameter"in t?(o=t.outer_diameter,i=t.outer_diameter):"rect_pad_width"in t&&"rect_pad_height"in t?(o=t.rect_pad_width,i=t.rect_pad_height,"hole_diameter"in t&&(o=Math.max(o,t.hole_diameter),i=Math.max(i,t.hole_diameter))):"hole_diameter"in t&&(o=t.hole_diameter,i=t.hole_diameter)),(o===void 0||i===void 0)&&(o=.1,i=.1),{x:e,y:n,width:o,height:i,title:r,content:s,bg_color:qdn[Hki(t.type||r)%qdn.length]?.[4]??"#f00"})},Gki=t=>!!t,Yki=t=>{const e=t.filter(c=>c.type.startsWith("pcb_")||c.type.startsWith("schematic_")).concat(t.filter(c=>c.type==="pcb_trace"||c.type==="schematic_trace").flatMap(c=>c.route)).map(c=>Oki(c)).filter(Gki);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let n=e[0].x-e[0].width/2,o=e[0].x+e[0].width/2,i=e[0].y-e[0].height/2,r=e[0].y+e[0].height/2;for(const c of e.slice(1))n=Math.min(n,c.x-c.width/2),o=Math.max(o,c.x+c.width/2),i=Math.min(i,c.y-c.height/2),r=Math.max(r,c.y+c.height/2);const s=o-n,a=r-i;return{center:{x:n+s/2,y:i+a/2},width:s,height:a}},u_={HIDDEN_LAYER_OPACITY:"pcb_viewer_hidden_layer_opacity",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",IS_SHOWING_COURTYARDS:"pcb_viewer_is_showing_courtyards",IS_SHOWING_GROUP_ANCHOR_OFFSETS:"pcb_viewer_is_showing_group_anchor_offsets",IS_SHOWING_SOLDER_MASK:"pcb_viewer_is_showing_solder_mask",IS_SHOWING_FABRICATION_NOTES:"pcb_viewer_is_showing_fabrication_notes",IS_SHOWING_PCB_NOTES:"pcb_viewer_is_showing_pcb_notes",IS_SHOWING_SILKSCREEN:"pcb_viewer_is_showing_silkscreen"},OP=(t,e)=>{if(typeof window>"u")return e;try{const n=localStorage.getItem(t);return n!==null?JSON.parse(n):e}catch{return e}},GP=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(e))}catch{}},Uki=(t,e)=>{if(typeof window>"u")return e;try{const n=localStorage.getItem(t);return n!==null?JSON.parse(n):e}catch{return e}},Kki=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(e))}catch{}},Vki=(t,e)=>{if(typeof window>"u")return e;try{const n=localStorage.getItem(t),o=n!==null?JSON.parse(n):null;return typeof o=="number"&&Number.isFinite(o)?o:e}catch{return e}},zki=(t,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(e))}catch{}},Jki="named_only",Wki=(t={},e=!1)=>iFt(n=>({hidden_layer_opacity:Math.max(0,Math.min(1,Vki(u_.HIDDEN_LAYER_OPACITY,.2))),setHiddenLayerOpacity:o=>{if(!Number.isFinite(o))return;const i=Math.max(0,Math.min(1,o));zki(u_.HIDDEN_LAYER_OPACITY,i),n({hidden_layer_opacity:i})},selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,is_moving_component:!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_drc_warnings:!0,is_showing_copper_pours:OP(u_.IS_SHOWING_COPPER_POURS,!0),is_showing_courtyards:OP(u_.IS_SHOWING_COURTYARDS,!0),is_showing_pcb_groups:e?!1:OP(u_.IS_SHOWING_PCB_GROUPS,!0),is_showing_group_anchor_offsets:OP(u_.IS_SHOWING_GROUP_ANCHOR_OFFSETS,!1),is_showing_solder_mask:OP(u_.IS_SHOWING_SOLDER_MASK,!1),is_showing_silkscreen:OP(u_.IS_SHOWING_SILKSCREEN,!0),is_showing_fabrication_notes:OP(u_.IS_SHOWING_FABRICATION_NOTES,!1),is_showing_pcb_notes:OP(u_.IS_SHOWING_PCB_NOTES,!0),pcb_group_view_mode:e?"all":Uki(u_.PCB_GROUP_VIEW_MODE,Jki),hovered_error_id:null,focused_error_id:null,...t,selectLayer:o=>n({selected_layer:o}),setEditMode:o=>n({in_edit_mode:o!=="off",in_move_footprint_mode:o==="move_footprint",is_moving_component:!1}),setIsShowingRatsNest:o=>n({is_showing_rats_nest:o}),setIsMovingComponent:o=>n({is_moving_component:o}),setIsMouseOverContainer:o=>n({is_mouse_over_container:o}),setIsShowingMultipleTracesLength:o=>n({is_showing_multiple_traces_length:o}),setIsShowingAutorouting:o=>n({is_showing_autorouting:o}),setIsShowingDrcErrors:o=>n({is_showing_drc_errors:o}),setIsShowingDrcWarnings:o=>n({is_showing_drc_warnings:o}),setIsShowingCopperPours:o=>{GP(u_.IS_SHOWING_COPPER_POURS,o),n({is_showing_copper_pours:o})},setIsShowingCourtyards:o=>{GP(u_.IS_SHOWING_COURTYARDS,o),n({is_showing_courtyards:o})},setIsShowingPcbGroups:o=>{e||(GP(u_.IS_SHOWING_PCB_GROUPS,o),n({is_showing_pcb_groups:o}))},setIsShowingGroupAnchorOffsets:o=>{GP(u_.IS_SHOWING_GROUP_ANCHOR_OFFSETS,o),n({is_showing_group_anchor_offsets:o})},setIsShowingSolderMask:o=>{GP(u_.IS_SHOWING_SOLDER_MASK,o),n({is_showing_solder_mask:o})},setIsShowingSilkscreen:o=>{GP(u_.IS_SHOWING_SILKSCREEN,o),n({is_showing_silkscreen:o})},setIsShowingFabricationNotes:o=>{GP(u_.IS_SHOWING_FABRICATION_NOTES,o),n({is_showing_fabrication_notes:o})},setIsShowingPcbNotes:o=>{GP(u_.IS_SHOWING_PCB_NOTES,o),n({is_showing_pcb_notes:o})},setPcbGroupViewMode:o=>{e||(Kki(u_.PCB_GROUP_VIEW_MODE,o),n({pcb_group_view_mode:o}))},setHoveredErrorId:o=>n({hovered_error_id:o}),setFocusedErrorId:o=>n({focused_error_id:o})})),Kc=t=>{const e=ee.useContext(Xdn);return hFt(e,t)},Xdn=ee.createContext(null),jki=({children:t,initialState:e,disablePcbGroups:n})=>{const o=ee.useMemo(()=>Wki(e,n),[n]);return K.jsx(Xdn.Provider,{value:o,children:t})},$ki=()=>{ee.useEffect(()=>{KNi()},[]);const t=Kc(e=>e.pcb_viewer_id);return K.jsx(UNi,{position:"top-center",containerId:t})};function qki(){var t=ee.useRef(!1),e=ee.useCallback(function(){return t.current},[]);return ee.useEffect(function(){return t.current=!0,function(){t.current=!1}},[]),e}var Xki=function(t){t===void 0&&(t={});var e=ee.useState(t),n=e[0],o=e[1],i=ee.useCallback(function(r){o(function(s){return Object.assign({},s,r instanceof Function?r(s):r)})},[]);return[n,i]},Zki=Xki,eFi=function(){},Zdn=typeof window<"u",tFi=qgn($Ri()),nFi=function(){var t=qki(),e=Zki({value:void 0,error:void 0,noUserInteraction:!0}),n=e[0],o=e[1],i=ee.useCallback(function(r){if(t()){var s,a;try{if(typeof r!="string"&&typeof r!="number"){var A=new Error("Cannot copy typeof "+typeof r+" to clipboard, must be a string");console.error(A),o({value:r,error:A,noUserInteraction:!0});return}else if(r===""){var A=new Error("Cannot copy empty string to clipboard.");console.error(A),o({value:r,error:A,noUserInteraction:!0});return}a=r.toString(),s=(0,tFi.default)(a),o({value:a,error:void 0,noUserInteraction:s})}catch(c){o({value:a,error:c,noUserInteraction:s})}}},[]);return[n,i]},oFi=nFi,iFi=Zdn?ee.useLayoutEffect:ee.useEffect,rFi=iFi,ehn={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function sFi(){var t=ee.useState(null),e=t[0],n=t[1],o=ee.useState(ehn),i=o[0],r=o[1],s=ee.useMemo(function(){return new window.ResizeObserver(function(a){if(a[0]){var A=a[0].contentRect,c=A.x,l=A.y,u=A.width,g=A.height,h=A.top,d=A.left,p=A.bottom,m=A.right;r({x:c,y:l,width:u,height:g,top:h,left:d,bottom:p,right:m})}})},[]);return rFi(function(){if(e)return s.observe(e),function(){s.disconnect()}},[e]),[n,i]}var uee=Zdn&&typeof window.ResizeObserver<"u"?sFi:function(){return[eFi,ehn]},thn=({initialTransform:t,initialTouch1:e,initialTouch2:n,finalTouch1:o,finalTouch2:i})=>{if(!o||!i)return t;const r={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(o.x+i.x)/2,y:(o.y+i.y)/2},a=Math.hypot(n.x-e.x,n.y-e.y),A=Math.hypot(i.x-o.x,i.y-o.y),c=a===0?1:A/a,l=s.x-r.x,u=s.y-r.y;return NC(Qd(l,u),Qd(r.x,r.y),vS(c,c),Qd(-r.x,-r.y),t)},aFi=(t={})=>{const e=ee.useRef(null),[n,o]=ee.useState(0),i=t.canvasElm??e.current,[r,s]=ee.useState(t.initialTransform??RP()),[a,A]=ee.useState(0),[c,l]=ee.useReducer(I=>I+1,0),u=ee.useCallback(I=>{t.onSetTransform&&t.onSetTransform(I),t.transform||s(I)},[t.onSetTransform,s]),g=ee.useCallback(I=>{u(I),l()},[u]),h=t.transform??r,d=ee.useCallback(()=>{o(Date.now())},[]),p=ee.useRef("none"),m=ee.useRef(null),_=ee.useRef(null);ee.useEffect(()=>{const I=t.canvasElm??e.current;if(I&&!i){A(a+1);return}if(!I){const U=setTimeout(()=>{A(a+1)},100);return()=>clearTimeout(U)}let C=t.transform??r,y={x:0,y:0},x={x:0,y:0},E=!1;const B=U=>({x:U.pageX-I.getBoundingClientRect().left-window.scrollX,y:U.pageY-I.getBoundingClientRect().top-window.scrollY});function S(U){t.enabled!==!1&&(t.shouldDrag&&!t.shouldDrag(U)||(y=B(U),!(Date.now()-n<100)&&(E=!0,U.preventDefault())))}function Q(U){if(!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=NC(Qd(x.x-y.x,x.y-y.y),C);u(Y),C=Y,E=!1}function w(U){if(B(U),!E||t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;x=B(U);const Y=NC(Qd(x.x-y.x,x.y-y.y),C);u(Y)}function M(U){if(t.enabled===!1||t.shouldDrag&&!t.shouldDrag(U))return;const Y=B(U),W=NC(Qd(Y.x,Y.y),vS(1-U.deltaY/1e3,1-U.deltaY/1e3),Qd(-Y.x,-Y.y),C);u(W),C=W,U.preventDefault()}function k(U){if(!E||t.shouldDrag&&!t.shouldDrag(U))return;if(I){const W=I.getBoundingClientRect();if(U.clientX>=W.left+10&&U.clientX<=W.right-10&&U.clientY>=W.top+10&&U.clientY<=W.bottom-10)return}E=!1,x=B(U);const Y=NC(Qd(x.x-y.x,x.y-y.y),C);u(Y),C=Y}function R(U){if(U.preventDefault(),t.enabled!==!1){if(U.touches.length===1){p.current="drag";const Y=U.touches[0];m.current={initialTransform:C,initialTouch:{x:Y.clientX,y:Y.clientY}}}else if(U.touches.length===2){p.current="pinch";const Y=U.touches[0],W=U.touches[1];_.current={initialTransform:C,initialTouch1:{x:Y.clientX,y:Y.clientY},initialTouch2:{x:W.clientX,y:W.clientY},finalTouch1:null,finalTouch2:null}}}}function F(U){if(U.preventDefault(),t.enabled!==!1){if(p.current==="drag"&&U.touches.length===1&&m.current){const Y=U.touches[0],W={x:Y.clientX,y:Y.clientY},te=W.x-m.current.initialTouch.x,j=W.y-m.current.initialTouch.y,J=NC(Qd(te,j),m.current.initialTransform);u(J)}else if(p.current==="pinch"&&U.touches.length===2&&_.current){const Y=U.touches[0],W=U.touches[1];_.current.finalTouch1={x:Y.clientX,y:Y.clientY},_.current.finalTouch2={x:W.clientX,y:W.clientY};const te=thn(_.current);u(te)}}}function O(U){U.preventDefault();const Y=U.changedTouches[0];if(p.current==="drag"&&m.current&&Y){const W={x:Y.clientX,y:Y.clientY},te=W.x-m.current.initialTouch.x,j=W.y-m.current.initialTouch.y,J=NC(Qd(te,j),m.current.initialTransform);u(J),C=J}else if(p.current==="pinch"&&_.current){const W=thn(_.current);u(W),C=W}p.current="none",m.current=null,_.current=null}return I.addEventListener("mousedown",S),I.addEventListener("mouseup",Q),window.addEventListener("mousemove",w),I.addEventListener("mouseout",k),I.addEventListener("wheel",M),I.addEventListener("touchstart",R,{passive:!1}),I.addEventListener("touchmove",F,{passive:!1}),I.addEventListener("touchend",O,{passive:!1}),I.addEventListener("touchcancel",O,{passive:!1}),()=>{I.removeEventListener("mousedown",S),I.removeEventListener("mouseup",Q),window.removeEventListener("mousemove",w),I.removeEventListener("mouseout",k),I.removeEventListener("wheel",M),I.removeEventListener("touchstart",R),I.removeEventListener("touchmove",F),I.removeEventListener("touchend",O),I.removeEventListener("touchcancel",O)}},[i,a,c,n,t.enabled,t.shouldDrag]);const f=ee.useCallback(I=>_i(h,I),[h]);return{ref:e,transform:h,applyTransformToPoint:f,setTransform:g,cancelDrag:d}},AFi=aFi,cFi=(t,e)=>{if(t?.type!=="pcb_smtpad"&&t?.type!=="pcb_plated_hole")return;const n=e.find(i=>i.type==="pcb_component"&&i.pcb_component_id===t.pcb_component_id);if(n?.type!=="pcb_component")return;const o=e.find(i=>i.type==="source_component"&&i.source_component_id===n.source_component_id);if(o?.type==="source_component")return{source_component_id:o.source_component_id,pcb_component_id:n.pcb_component_id,refdes:o.name,manufacturer_part_number:o.manufacturer_part_number}};function lFi(t){const e=new Map;let n=0;function o(i){for(const[,s]of e)if(s.has(i))return s;const r=new Set;return e.set(`connectivity_net${n++}`,r),r}for(const i of t){let r=null;for(const s of i){if(!r)r=o(s);else if(!r.has(s)){const a=o(s);if(a!==r){for(const A of a)r.add(A);e.delete(Array.from(e.entries()).find(([,A])=>A===a)[0])}}r.add(s)}}return Object.fromEntries(Array.from(e.entries()).map(([i,r])=>[i,Array.from(r)]))}var uFi=class{netMap;idToNetMap;constructor(t){this.netMap=t,this.idToNetMap={};for(const[e,n]of Object.entries(t))for(const o of n)this.idToNetMap[o]=e}addConnections(t){for(const e of t){const n=new Set;for(const i of e){const r=this.idToNetMap[i];r&&n.add(r)}let o;if(n.size===0)o=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[o]=[];else if(n.size===1)o=n.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{o=n.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const i of n)if(i!==o){this.netMap[o].push(...this.netMap[i]),this.netMap[i]=this.netMap[o];for(const r of this.netMap[o])this.idToNetMap[r]=o}}for(const i of e)this.netMap[o].includes(i)||this.netMap[o].push(i),this.idToNetMap[i]=o}}getIdsConnectedToNet(t){return this.netMap[t]||[]}getNetConnectedToId(t){return this.idToNetMap[t]}areIdsConnected(t,e){if(t===e)return!0;const n=this.getNetConnectedToId(t);if(!n)return!1;const o=this.getNetConnectedToId(e);return o?n===o||o===t||o===t:!1}areAllIdsConnected(t){const e=this.getNetConnectedToId(t[0]);for(const n of t){const o=this.getNetConnectedToId(n);if(o===void 0||o!==e)return!1}return!0}},nhn=t=>{const e=[];for(const o of t)if(o.type==="source_trace")e.push([o.source_trace_id,...o.connected_source_port_ids??[],...o.connected_source_net_ids??[]].filter(Boolean));else if(o.type==="pcb_port"){const{pcb_port_id:i,source_port_id:r}=o;r&&i&&e.push([r,i])}else if(o.type==="pcb_smtpad"){const{pcb_smtpad_id:i,pcb_port_id:r}=o;r&&i&&e.push([i,r])}else if(o.type==="pcb_plated_hole"){const{pcb_plated_hole_id:i,pcb_port_id:r}=o;r&&i&&e.push([i,r])}else if(o.type==="pcb_trace"){const{pcb_trace_id:i,source_trace_id:r}=o,s=Array.isArray(o.route)?o.route.filter(a=>a&&a.route_type==="wire"):[];if(r&&i&&e.push([i,r]),Array.isArray(s)){const a=s.find(c=>c?.start_pcb_port_id)?.start_pcb_port_id,A=s.find(c=>c?.end_pcb_port_id)?.end_pcb_port_id;a&&i&&A&&e.push([a,i,A])}}else if(o.type==="pcb_via"){const{pcb_via_id:i,pcb_trace_id:r,source_trace_id:s,source_net_id:a}=o,A=[r,s,a].filter(c=>!!c);i&&A.length>0&&e.push([i,...A])}else if(o.type==="source_component"&&o.internally_connected_source_port_ids)for(const i of o.internally_connected_source_port_ids)e.push(i);const n=lFi(e);return new uFi(n)};function gFi(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=t.map(u=>Array.isArray(u)?{x:u[0],y:u[1]}:u),o=[],i=[];function r(u,g){const h=g.x-u.x,d=g.y-u.y,p=Math.sqrt(h*h+d*d);return{x:-d/p,y:h/p}}function s(u,g,h,d){const p=d/2,m={x:u.x+g.x*p*h,y:u.y+g.y*p*h};h>0?o.push(m):i.unshift(m)}const a=r(n[0],n[1]),A=n[0].trace_width??e;s(n[0],a,1,A),s(n[0],a,-1,A);for(let u=1;u<n.length-1;u++){const g=n[u-1],h=n[u],d=n[u+1],p=r(g,h),m=r(h,d),_=p.x+m.x,f=p.y+m.y,I=Math.sqrt(_*_+f*f),C=h.trace_width??e;if(I/2>2*(C/2))s(h,p,1,C),s(h,m,1,C),s(h,p,-1,C),s(h,m,-1,C);else{const x=1/I;s(h,{x:_*x,y:f*x},1,C),s(h,{x:_*x,y:f*x},-1,C)}}const c=r(n[n.length-2],n[n.length-1]),l=n[n.length-1].trace_width??e;return s(n[n.length-1],c,1,l),s(n[n.length-1],c,-1,l),[...o,...i]}var dFi=(t,e)=>{const{x:n,y:o,width:i,height:r,layer:s,rect_border_radius:a}=t,A=t.corner_radius??a??0,c=[{_pcb_drawing_object_id:i9("rect"),pcb_drawing_type:"rect",x:n,y:o,w:i,h:r,layer:s||"top",_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,roundness:A,...t.shape==="rotated_rect"&&t.ccw_rotation!==void 0?{ccw_rotation:t.ccw_rotation}:{}}];if(t.is_covered_with_solder_mask){const l=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",g={...{_pcb_drawing_object_id:i9("rect"),pcb_drawing_type:"rect",x:n,y:o,w:i,h:r,layer:l,_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,roundness:A,...t.shape==="rotated_rect"&&t.ccw_rotation!==void 0?{ccw_rotation:t.ccw_rotation}:{}},..."solder_mask_color"in t&&t.solder_mask_color?{color:t.solder_mask_color}:{}};c.push(g)}return c},hFi=(t,e)=>{const{x:n,y:o,radius:i,layer:r}=t,s=[{_pcb_drawing_object_id:i9("circle"),pcb_drawing_type:"circle",x:n,y:o,r:i,layer:r||"top",_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port}];if(t.is_covered_with_solder_mask){const a=r==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",A={_pcb_drawing_object_id:i9("circle"),pcb_drawing_type:"circle",x:n,y:o,r:i,layer:a,_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,..."solder_mask_color"in t&&t.solder_mask_color?{color:t.solder_mask_color}:{}};s.push(A)}return s},pFi=(t,e)=>{const{layer:n,points:o}=t,i=[{_pcb_drawing_object_id:i9("polygon"),pcb_drawing_type:"polygon",points:f$e(o),layer:n||"top",_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port}];if(t.is_covered_with_solder_mask){const r=n==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",s={_pcb_drawing_object_id:i9("polygon"),pcb_drawing_type:"polygon",points:f$e(o),layer:r,_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,..."solder_mask_color"in t&&t.solder_mask_color?{color:t.solder_mask_color}:{}};i.push(s)}return i},mFi=(t,e)=>{const{x:n,y:o,width:i,height:r,layer:s}=t,a=[{_pcb_drawing_object_id:i9("pill"),pcb_drawing_type:"pill",x:n,y:o,w:i,h:r,layer:s||"top",_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port}];if(t.is_covered_with_solder_mask){const A=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",c={_pcb_drawing_object_id:i9("pill"),pcb_drawing_type:"pill",x:n,y:o,w:i,h:r,layer:A,_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,..."solder_mask_color"in t&&t.solder_mask_color?{color:t.solder_mask_color}:{}};a.push(c)}return a},_Fi=(t,e)=>{const{x:n,y:o,width:i,height:r,layer:s,ccw_rotation:a}=t,A=[{_pcb_drawing_object_id:i9("pill"),pcb_drawing_type:"pill",x:n,y:o,w:i,h:r,layer:s||"top",_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,ccw_rotation:a}];if(t.is_covered_with_solder_mask){const c=s==="bottom"?"soldermask_with_copper_bottom":"soldermask_with_copper_top",l={_pcb_drawing_object_id:i9("pill"),pcb_drawing_type:"pill",x:n,y:o,w:i,h:r,layer:c,_element:t,_parent_pcb_component:e._parent_pcb_component,_parent_source_component:e._parent_source_component,_source_port:e._source_port,ccw_rotation:a,..."solder_mask_color"in t&&t.solder_mask_color?{color:t.solder_mask_color}:{}};A.push(l)}return A},Pd=0,i9=t=>`${t}_${Pd++}`,f$e=t=>(t??[]).map(e=>({x:lt.parse(e.x),y:lt.parse(e.y)}));function fFi(t){const e=new Map;for(const n of t){const o=n[`${n.type}_id`];o!==void 0&&!e.has(`${n.type}:${o}`)&&e.set(`${n.type}:${o}`,n)}return e}var IFi=(t,e,n)=>{const o=(A,c)=>{if(c!==void 0)return n?n.get(`${A}:${c}`):e.find(l=>l.type===A&&l[`${A}_id`]===c)},i=o("pcb_component","pcb_component_id"in t?t.pcb_component_id:void 0),r=o("source_component",i?.source_component_id),s="source_port_id"in t?t.source_port_id:"pcb_port_id"in t?o("pcb_port",t.pcb_port_id)?.source_port_id:void 0,a=o("source_port",s);switch(t.type){case"pcb_smtpad":{const A={_parent_pcb_component:i,_parent_source_component:r,_source_port:a};return t.shape==="rect"||t.shape==="rotated_rect"?dFi(t,A):t.shape==="circle"?hFi(t,A):t.shape==="polygon"?pFi(t,A):t.shape==="pill"?mFi(t,A):t.shape==="rotated_pill"?_Fi(t,A):[]}case"pcb_trace":{const A=[];if(t.route_thickness_mode==="interpolated"){const u=t.route.flatMap(d=>d.route_type==="through_pad"?[{...d.start,trace_width:d.width},{...d.end,trace_width:d.width}]:[{x:d.x,y:d.y,trace_width:d.route_type==="wire"?d.width:.5}]),g=gFi(u,.5),h=t.route[0].layer;return A.push({_pcb_drawing_object_id:`polygon_${Pd++}`,_element:t,pcb_drawing_type:"polygon",points:g,layer:h}),t.route.forEach(d=>{d.route_type==="via"&&A.push({_pcb_drawing_object_id:`circle_${Pd++}`,_element:t,pcb_drawing_type:"circle",x:d.x,y:d.y,r:d.outer_diameter/2,layer:d.from_layer})}),A}let c=null,l=null;for(const u of t.route)u.route_type==="wire"&&(c!==null&&l!==null&&A.push({_pcb_drawing_object_id:`line_${Pd++}`,_element:t,pcb_drawing_type:"line",x1:c,y1:l,x2:u.x,y2:u.y,width:u.width,squareCap:!1,layer:u.layer}),c=u.x,l=u.y);return A}case"pcb_via":{const{x:A,y:c,outer_diameter:l,hole_diameter:u}=t,g=t.from_layer,h=t.to_layer,d=t.layers,p=[];g&&h?p.push(g,h):d&&Array.isArray(d)?p.push(...d):p.push("top","bottom");const m=[];for(const _ of p)m.push({_pcb_drawing_object_id:`circle_${Pd++}`,pcb_drawing_type:"circle",x:A,y:c,r:l/2,layer:_,_element:t,_parent_pcb_component:i,_parent_source_component:r});return m.push({_pcb_drawing_object_id:`circle_${Pd++}`,pcb_drawing_type:"circle",x:A,y:c,r:u/2,layer:"drill",_element:t}),m}case"pcb_plated_hole":if(t.shape==="circle"){const{x:A,y:c,hole_diameter:l,outer_diameter:u}=t;return[{_pcb_drawing_object_id:`circle_${Pd++}`,pcb_drawing_type:"circle",x:A,y:c,r:u/2,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a},{_pcb_drawing_object_id:`circle_${Pd++}`,pcb_drawing_type:"circle",x:A,y:c,r:l/2,layer:"drill",_element:t}]}else if(t.shape==="oval"){const{x:A,y:c,outer_height:l,outer_width:u,hole_height:g,hole_width:h}=t;return[{_pcb_drawing_object_id:`oval_${Pd++}`,pcb_drawing_type:"oval",x:A,y:c,rX:u/2,rY:l/2,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a},{_pcb_drawing_object_id:`oval_${Pd++}`,_element:t,pcb_drawing_type:"oval",x:A,y:c,rX:h/2,rY:g/2,layer:"drill"}]}else if(t.shape==="pill"){const{x:A,y:c,outer_height:l,outer_width:u,hole_height:g,hole_width:h}=t;return[{_pcb_drawing_object_id:`pill_${Pd++}`,pcb_drawing_type:"pill",x:A,y:c,w:u,h:l,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,ccw_rotation:t.ccw_rotation},{_pcb_drawing_object_id:`pill_${Pd++}`,_element:t,pcb_drawing_type:"pill",x:A,y:c,w:h,h:g,layer:"drill",ccw_rotation:t.ccw_rotation}]}else if(t.shape==="circular_hole_with_rect_pad"){const{x:A,y:c,hole_diameter:l,rect_pad_width:u,rect_pad_height:g,rect_border_radius:h,hole_offset_x:d,hole_offset_y:p}=t,m=lt.parse(d??0),_=lt.parse(p??0);return[{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:u,h:g,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,roundness:h},{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:u,h:g,layer:"bottom",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,roundness:h,is_hoverable:!1},{_pcb_drawing_object_id:`circle_${Pd++}`,_element:t,pcb_drawing_type:"circle",x:A+m,y:c+_,r:l/2,layer:"drill",is_hoverable:!1}]}else if(t.shape==="pill_hole_with_rect_pad"){const{x:A,y:c,hole_width:l,hole_height:u,rect_pad_width:g,rect_pad_height:h,rect_border_radius:d}=t;return[{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:g,h,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,roundness:d},{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:g,h,layer:"bottom",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,roundness:d,is_hoverable:!1},{_pcb_drawing_object_id:`pill_${Pd++}`,_element:t,pcb_drawing_type:"pill",x:A,y:c,w:l,h:u,layer:"drill",is_hoverable:!1}]}else if(t.shape==="rotated_pill_hole_with_rect_pad"){const{x:A,y:c,hole_width:l,hole_height:u,hole_ccw_rotation:g,rect_pad_width:h,rect_pad_height:d,rect_ccw_rotation:p,rect_border_radius:m}=t;return[{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:h,h:d,layer:"top",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,ccw_rotation:p,roundness:m},{_pcb_drawing_object_id:`rect_${Pd++}`,pcb_drawing_type:"rect",x:A,y:c,w:h,h:d,layer:"bottom",_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a,ccw_rotation:p,roundness:m,is_hoverable:!1},{_pcb_drawing_object_id:`pill_${Pd++}`,_element:t,pcb_drawing_type:"pill",x:A,y:c,w:l,h:u,layer:"drill",ccw_rotation:g,is_hoverable:!1}]}else if(t.shape==="hole_with_polygon_pad"){const{x:A,y:c,pad_outline:l,hole_shape:u,hole_diameter:g,hole_width:h,hole_height:d,layers:p,hole_offset_x:m,hole_offset_y:_}=t,f=lt.parse(m??0),I=lt.parse(_??0),C=l,y=[];if(C&&Array.isArray(C)){const B=f$e(C).map(S=>({x:S.x+A,y:S.y+c}));for(const S of p||["top","bottom"])y.push({_pcb_drawing_object_id:`polygon_${Pd++}`,pcb_drawing_type:"polygon",points:B,layer:S,_element:t,_parent_pcb_component:i,_parent_source_component:r,_source_port:a})}const x={x:A+f,y:c+I},E=[];return u==="circle"?E.push({_pcb_drawing_object_id:`circle_${Pd++}`,pcb_drawing_type:"circle",x:x.x,y:x.y,r:(g??0)/2,layer:"drill",_element:t,_parent_pcb_component:i,_parent_source_component:r}):u==="oval"?E.push({_pcb_drawing_object_id:`oval_${Pd++}`,pcb_drawing_type:"oval",x:x.x,y:x.y,rX:(h??0)/2,rY:(d??0)/2,layer:"drill",_element:t,_parent_pcb_component:i,_parent_source_component:r}):(u==="pill"||u==="rotated_pill")&&E.push({_pcb_drawing_object_id:`pill_${Pd++}`,pcb_drawing_type:"pill",x:x.x,y:x.y,w:h??0,h:d??0,layer:"drill",_element:t,_parent_pcb_component:i,_parent_source_component:r,ccw_rotation:t.ccw_rotation}),[...y,...E]}else return[]}return[]};function CFi({primitivesWithoutInteractionMetadata:t,drawingObjectIdsWithMouseOver:e,primitiveIdsInMousedOverNet:n}){const o=[];for(const i of t){const r={...i},s=i._element,a=i._parent_pcb_component;i?.layer==="drill"?(r.is_in_highlighted_net=!1,r.is_mouse_over=!1):e.has(i._pcb_drawing_object_id)?r.is_mouse_over=!0:s&&("pcb_trace_id"in s&&n.includes(s.pcb_trace_id)||"pcb_port_id"in s&&n.includes(s.pcb_port_id)||"pcb_via_id"in s&&n.includes(s.pcb_via_id)||"pcb_component_id"in s&&n.includes(s.pcb_component_id)||a&&"pcb_component_id"in a&&n.includes(a.pcb_component_id))?r.is_in_highlighted_net=!0:(r.is_in_highlighted_net=!1,r.is_mouse_over=!1),o.push(r)}return o}var ohn=t=>{const e=new Map,n=new Map,o=new Map,i=new Map,r=new Map;for(const s of t)s.type==="pcb_trace"&&s.pcb_trace_id?e.set(s.pcb_trace_id,s):s.type==="pcb_port"&&s.pcb_port_id?n.set(s.pcb_port_id,s):s.type==="pcb_via"&&s.pcb_via_id?o.set(s.pcb_via_id,s):s.type==="pcb_component"&&s.pcb_component_id?i.set(s.pcb_component_id,s):s.type==="pcb_board"&&s.pcb_board_id&&r.set(s.pcb_board_id,s);return{tracesById:e,portsById:n,viasById:o,componentsById:i,boardsById:r}},I4=(t,e)=>e?t?{minX:Math.min(t.minX,e.minX),maxX:Math.max(t.maxX,e.maxX),minY:Math.min(t.minY,e.minY),maxY:Math.max(t.maxY,e.maxY)}:e:t,UT=(t,e=.45)=>({minX:t.x-e,maxX:t.x+e,minY:t.y-e,maxY:t.y+e}),yFi=t=>{if(t.length===0)return null;let e=null;for(const n of t){const o=Math.max((n.width??.2)/2,.3);e=I4(e,UT(n,o))}return e},ihn=t=>{if(!t?.center)return null;const e=Math.max(t.width??0,1.2),n=Math.max(t.height??0,1.2);return{minX:t.center.x-e/2,maxX:t.center.x+e/2,minY:t.center.y-n/2,maxY:t.center.y+n/2}},xFi=t=>!t?.center||typeof t.width!="number"||typeof t.height!="number"?null:{minX:t.center.x-t.width/2,maxX:t.center.x+t.width/2,minY:t.center.y-t.height/2,maxY:t.center.y+t.height/2},EFi=(t,e)=>({minX:t.minX-e,maxX:t.maxX+e,minY:t.minY-e,maxY:t.maxY+e}),BFi=(t,e=.35)=>{const n=Oh(t);return n?EFi(n,e):null},rhn=({error:t,tracesById:e,portsById:n,viasById:o,componentsById:i})=>{if(t.center)return t.center;if(t.pcb_center)return t.pcb_center;if(t.component_center)return t.component_center;if(t.pcb_via_ids?.length){const r=t.pcb_via_ids.map(s=>o.get(s)).filter(Boolean);if(r.length>0)return{x:r.reduce((s,a)=>s+a.x,0)/r.length,y:r.reduce((s,a)=>s+a.y,0)/r.length}}if(t.pcb_port_ids?.length){const r=t.pcb_port_ids.map(s=>n.get(s)).filter(Boolean);if(r.length>0)return{x:r.reduce((s,a)=>s+a.x,0)/r.length,y:r.reduce((s,a)=>s+a.y,0)/r.length}}if(t.pcb_trace_id){const r=e.get(t.pcb_trace_id);if(r?.route?.length){const s=Math.floor(r.route.length/2);return{x:r.route[s].x,y:r.route[s].y}}}return t.pcb_component_id?i.get(t.pcb_component_id)?.center??null:null},bFi=({error:t,indexes:e})=>rhn({error:t,...e}),SFi=({error:t,boardsById:e})=>{if(!t.component_bounds||!t.pcb_board_id)return null;const n=xFi(e.get(t.pcb_board_id));if(!n)return null;const o=t.component_bounds,i=[];return o.min_x<n.minX&&(i.push({x:n.minX,y:Math.max(o.min_y,n.minY)}),i.push({x:n.minX,y:Math.min(o.max_y,n.maxY)})),o.max_x>n.maxX&&(i.push({x:n.maxX,y:Math.max(o.min_y,n.minY)}),i.push({x:n.maxX,y:Math.min(o.max_y,n.maxY)})),o.min_y<n.minY&&(i.push({x:Math.max(o.min_x,n.minX),y:n.minY}),i.push({x:Math.min(o.max_x,n.maxX),y:n.minY})),o.max_y>n.maxY&&(i.push({x:Math.max(o.min_x,n.minX),y:n.maxY}),i.push({x:Math.min(o.max_x,n.maxX),y:n.maxY})),BFi(i,.3)},shn=new Set(["source_failed_to_create_component_error"]),QFi=({error:t,indexes:e})=>{if(shn.has(t.error_type)||shn.has(t.type))return null;let n=null;const o=rhn({error:t,...e});if(o&&(n=I4(n,UT(o,.35))),t.error_type==="pcb_component_outside_board_error"?n=I4(n,SFi({error:t,boardsById:e.boardsById})):t.component_bounds&&!o&&(n=I4(n,{minX:t.component_bounds.min_x,maxX:t.component_bounds.max_x,minY:t.component_bounds.min_y,maxY:t.component_bounds.max_y})),t.center&&!o&&(n=I4(n,UT(t.center))),t.pcb_center&&!o&&(n=I4(n,UT(t.pcb_center))),t.component_center&&!o&&(n=I4(n,UT(t.component_center))),t.pcb_port_ids&&!o)for(const i of t.pcb_port_ids){const r=e.portsById.get(i);r&&(n=I4(n,UT({x:r.x,y:r.y},.4)))}if(t.pcb_trace_id&&!o){const i=e.tracesById.get(t.pcb_trace_id);i?.route&&(n=I4(n,yFi(i.route)))}if(t.pcb_via_ids)for(const i of t.pcb_via_ids){const r=e.viasById.get(i);r&&(n=I4(n,UT({x:r.x,y:r.y},Math.max((r.outer_diameter??.5)/2,.28))))}if(t.pcb_component_id&&!o&&(n=I4(n,ihn(e.componentsById.get(t.pcb_component_id)))),t.pcb_component_ids&&!o)for(const i of t.pcb_component_ids)n=I4(n,ihn(e.componentsById.get(i)));return n},vFi=({bounds:t,width:e,height:n})=>{const o={x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2},i=Math.max(t.maxX-t.minX,.8)+1.4,r=Math.max(t.maxY-t.minY,.8)+1.4,s=Math.min(e/i,n/r,240)*.92;return NC(Qd(e/2,n/2),vS(s,-s,0,0),Qd(-o.x,-o.y))},wFi=t=>{const e=new Set;t.pcb_trace_id&&e.add(t.pcb_trace_id);for(const n of t.pcb_port_ids??[])e.add(n);for(const n of t.pcb_via_ids??[])e.add(n);t.pcb_component_id&&e.add(t.pcb_component_id);for(const n of t.pcb_component_ids??[])e.add(n);return[...e]},JU=(t,e)=>{const n=["pcb_trace_error_id","pcb_via_clearance_error_id","pcb_component_outside_board_error_id","source_failed_to_create_component_error_id","pcb_error_id"];for(const o of n)if(typeof t?.[o]=="string"&&t[o].length>0)return t[o];for(const[o,i]of Object.entries(t??{}))if(o.endsWith("_error_id")&&typeof i=="string"&&i.length>0)return i;return`error_${e}_${t?.error_type}_${t?.message?.slice(0,20)}`},ahn=(t,e)=>e?t.find((n,o)=>n.type?.includes("error")?JU(n,o)===e:!1)??null:null,PFi=t=>1-(1-t)**3,MFi=(t,e,n)=>({a:t.a+(e.a-t.a)*n,b:t.b+(e.b-t.b)*n,c:t.c+(e.c-t.c)*n,d:t.d+(e.d-t.d)*n,e:t.e+(e.e-t.e)*n,f:t.f+(e.f-t.f)*n}),Ahn=t=>{t!==null&&window.cancelAnimationFrame(t)},DFi=({startTransform:t,endTransform:e,durationMs:n,onUpdate:o,setAnimationFrameId:i,onComplete:r})=>{const s=performance.now(),a=c=>{const l=c-s,u=Math.min(1,l/n),g=PFi(u);if(o(MFi(t,e,g)),u<1){i(window.requestAnimationFrame(a));return}i(null),r?.()},A=window.requestAnimationFrame(a);return i(A),A},afe=t=>t?.trim()||null;function I$e({primitiveElement:t,elements:e}){const n=t.source_trace_id;if(!n)return null;const o=wS(e),i=o.source_trace.get(n),r=afe(i?.name);if(r)return r;const s=o.source_net.get(n),a=afe(s?.name);if(a)return a;for(const A of i?.connected_source_net_ids??[]){const c=afe(o.source_net.get(A)?.name);if(c)return c}return null}function chn({primitiveElement:t,elements:e}){const n=wS(e).source_trace.get(t?.source_trace_id),o=t.trace_length,i=typeof o=="number",r=n?.max_length,s=i?`${o.toFixed(3)}${typeof r=="number"?` / ${r}`:""} mm`:"",a=I$e({primitiveElement:t,elements:e})??afe(n?.display_name);if(!s&&!a)return null;const A=!!(i&&typeof r=="number"&&o>r);return{text:s,name:a,isOverLength:A}}function gee(t,e){if(!t)return;const n=[];for(const o of[`${t.type}_id`,"pcb_port_id","pcb_trace_id","source_trace_id","source_net_id"]){const i=t[o];typeof i=="string"&&n.push(i)}for(const o of n){const i=e.getNetConnectedToId(o);if(i)return i}}function lhn(t){return t&&["pcb_trace","pcb_smtpad","pcb_plated_hole","pcb_via"].includes(t.type)}function NFi(t,e,n){const o=t.type==="pcb_trace"?I$e({primitiveElement:t,elements:e}):null;if(o)return o;const i=gee(t,n),r=i?e.filter(s=>gee(s,n)===i):[];for(const s of["source_net","source_trace"])for(const a of r)if(a.type===s&&"name"in a&&typeof a.name=="string"&&a.name.trim())return a.name.trim();if(t.type==="pcb_trace"){const s=chn({primitiveElement:t,elements:e})?.name;if(s)return s}for(const s of r)if(s.type==="source_trace"&&s.display_name?.trim())return s.display_name.trim();return"Net"}function RFi(t,e,n){return e.flatMap(o=>{if(o.type!=="source_bus")return[];const i=[...new Set(o.source_trace_ids.flatMap(r=>{const s=n.getNetConnectedToId(r);return s?[s]:[]}))];return i.includes(t)?[{id:o.source_bus_id,name:o.name?.trim()||"Bus",netIds:i}]:[]})}var TFi=async()=>{const{default:t}=await Promise.resolve().then(()=>(XRi(),Xgn));return new t};function kFi(t){const{elements:e,primitives:n,transform:o,width:i=500,height:r=500}=t,s=ee.useRef(null),a=ee.useRef(void 0),A=ee.useRef(!1),[c,l]=ee.useState(null),[u,g]=ee.useState(),h=Kc(w=>w.selected_layer),d=Kc(w=>w.hidden_layer_opacity),p=Kc(w=>w.is_showing_copper_pours),m=Kc(w=>w.is_showing_solder_mask),_=Kc(w=>w.is_showing_silkscreen),f=Kc(w=>w.is_showing_fabrication_notes),I=Kc(w=>w.is_showing_pcb_notes),C=Kc(w=>w.is_showing_courtyards),y=ee.useMemo(()=>[...new Set(n.flatMap(w=>{if(!w.is_mouse_over&&!w.is_in_highlighted_net)return[];const M=w._element,k=M?.[`${M.type}_id`];return k?[k]:[]}))],[n]),x=ee.useMemo(()=>(t.xRayElements??[]).map(w=>w[`${w.type}_id`]),[t.xRayElements]),E=ee.useMemo(()=>({selectedLayer:h,hiddenLayerOpacity:d,showCopperPours:p,showSolderMask:m,showSilkscreen:_,showFabricationNotes:f,showPcbNotes:I,showCourtyards:C,highlightedElementIds:y,xRayElementIds:x}),[h,d,p,m,_,f,I,C,y,x]),B=ee.useRef(e),S=ee.useRef(void 0);if(B.current=e,o){const w=typeof window>"u"?1:window.devicePixelRatio||1;S.current={type:"view",width:Math.max(1,Math.round(i*w)),height:Math.max(1,Math.round(r*w)),transform:{a:o.a*w,b:o.b*w,c:o.c*w,d:o.d*w,e:o.e*w,f:o.f*w},options:E}}ee.useEffect(()=>{let w=!1,M=!1,k;const R=document.createElement("canvas");R.className="pcb-webgpu-canvas",R.style.cssText="position:absolute;inset:0;width:100%;height:100%;pointer-events:none",s.current?.append(R);const F=U=>{w||M||(M=!0,clearTimeout(O),R.remove(),A.current=!1,k?.terminate(),k=void 0,a.current=void 0,s.current&&(s.current.dataset.xRayNetActive="false"),g(U))},O=setTimeout(()=>F("WebGPU worker startup timed out"),15e3);return(async()=>{try{if(!navigator.gpu||typeof Worker>"u"||!R.transferControlToOffscreen)throw new Error("WebGPU workers are unavailable");if(k=await TFi(),w||M){k.terminate();return}a.current=k,k.onmessage=({data:Y})=>{w||M||(Y.type==="rendered"?s.current&&(s.current.dataset.xRayNetActive=String(Y.xRayActive)):Y.type==="error"?F(Y.message):Y.type==="ready"&&(clearTimeout(O),l(Y.supportsXRayNet),A.current=!0,k.postMessage({type:"scene",elements:B.current}),S.current&&k.postMessage(S.current)))},k.onerror=Y=>{Y.preventDefault(),F(Y.message||"WebGPU worker failed")},k.addEventListener("messageerror",()=>{F("WebGPU worker communication failed")});const U=R.transferControlToOffscreen();k.postMessage({type:"init",canvas:U},[U])}catch(U){F(String(U))}})(),()=>{w=!0,clearTimeout(O),A.current=!1,a.current=void 0,k?.terminate(),R.remove()}},[]),ee.useEffect(()=>{A.current&&a.current?.postMessage({type:"scene",elements:e})},[e]),ee.useEffect(()=>{A.current&&S.current&&a.current?.postMessage(S.current)},[o,i,r,E]);const Q=!!(t.xRayElements&&c===!1);return K.jsx("div",{ref:s,"data-pcb-renderer":"webgpu","data-webgpu-error":u,style:{width:i,height:r,background:"black",position:"relative",overflow:"hidden"},children:u?K.jsxs("div",{role:"alert",style:{padding:16,color:"white",position:"relative"},children:[K.jsx("strong",{children:"WebGPU rendering failed"}),K.jsx("div",{children:u})]}):K.jsxs(K.Fragment,{children:[K.jsx(FT.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:o,stringifyCoord:(w,M,k)=>`${FT.toMMSI(w,k)}, ${FT.toMMSI(M,k)}`}),Q&&K.jsx("div",{role:"status",style:{padding:16,color:"white",position:"relative"},children:"X-Ray is unavailable in this WebGPU renderer."})]})})}var qi={board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(38, 233, 255)",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)",soldermaskWithCopper:{top:"rgb(18, 82, 50)",bottom:"rgb(77, 127, 196)"},soldermask:{top:"rgb(12, 55, 33)",bottom:"rgb(12, 55, 33)"},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)"}},Zx=(t,e=1)=>{if(Math.abs(t.a)!==Math.abs(t.d))throw new Error("Cannot scale non-uniformly");return e*Math.abs(t.a)},Ru={elementOverlay:40,dimensionOverlay:40,errorOverlay:40,pcbGroupOverlay:35,ratsNestOverlay:30,toolbarOverlay:70,warnings:30,topLayer:30,clickToInteractOverlay:100},dee={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:qi.board.copper.f,inner1:qi.board.copper.in1,inner2:qi.board.copper.in2,inner3:qi.board.copper.in3,inner4:qi.board.copper.in4,inner5:qi.board.copper.in5,inner6:qi.board.copper.in6,inner7:qi.board.copper.in7,inner8:qi.board.copper.in8,bottom:qi.board.copper.b,drill:qi.board.anchor,keepout:qi.board.background,tkeepout:qi.board.b_crtyd,tplace:qi.board.b_silks,top_courtyard:qi.board.f_crtyd,bottom_courtyard:qi.board.b_crtyd,top_silkscreen:qi.board.f_silks,bottom_silkscreen:qi.board.b_silks,top_fabrication:qi.board.f_fab,bottom_fabrication:qi.board.b_fab,soldermask_top:qi.board.soldermask.top,soldermask_bottom:qi.board.soldermask.bottom,soldermask_with_copper_top:qi.board.soldermaskWithCopper.top,soldermask_with_copper_bottom:qi.board.soldermaskWithCopper.bottom,bottom_notes:qi.board.user_2,top_notes:qi.board.user_2,...qi.board},FFi=["board","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","bottom_courtyard","bottom_fabrication","top_courtyard","top_fabrication","edge_cuts","top_silkscreen"],LFi=class{canvasLayerMap;ctxLayerMap;aperture;transform;foregroundLayer="top";hiddenLayerOpacity=.2;xRayNetActive=!1;lastPoint;constructor(t){this.canvasLayerMap=t,this.ctxLayerMap=Object.fromEntries(Object.entries(t).map(([e,n])=>[e,n.getContext("2d")])),this.transform=RP(),this.transform.d*=-1,this.transform=NC(this.transform,Qd(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const t of Object.values(this.ctxLayerMap))t.clearRect(0,0,t.canvas.width,t.canvas.height)}equip(t){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===t.color?1:.5,...t}}drawMeshPattern(t,e,n,o,i,r=45){const s=this.getLayerCtx(),[a,A]=_i(this.transform,[t,e]),[c,l]=_i(this.transform,[t+n,e+o]),u=Zx(this.transform,i);s.lineWidth=1,s.strokeStyle=this.aperture.color;const g=h=>{const d=Math.sin(h),p=Math.cos(h),m=Math.sqrt((c-a)**2+(l-A)**2);for(let _=-m;_<=m;_+=u)s.beginPath(),s.moveTo(a+_*p-m*d,A+_*d+m*p),s.lineTo(a+_*p+m*d,A+_*d-m*p),s.stroke()};g(r*Math.PI/180),g((r+90)*Math.PI/180)}rect({x:t,y:e,w:n,h:o,mesh_fill:i,is_filled:r=!0,has_stroke:s,is_stroke_dashed:a,stroke_width:A,roundness:c}){const[l,u]=_i(this.transform,[t-n/2,e-o/2]),[g,h]=_i(this.transform,[t+n/2,e+o/2]);this.applyAperture();const d=this.getLayerCtx(),p=c?Zx(this.transform,c):0,m=s===void 0?r===!1:s;if(i)d.save(),d.beginPath(),p>0&&d.roundRect?d.roundRect(l,u,g-l,h-u,p):d.rect(l,u,g-l,h-u),d.clip(),this.drawMeshPattern(t-n/2,e-o/2,n,o,.15),d.restore(),p>0&&d.roundRect?(d.beginPath(),d.roundRect(l,u,g-l,h-u,p),d.stroke()):d.strokeRect(l,u,g-l,h-u);else if(r!==!1&&(p>0&&d.roundRect?(d.beginPath(),d.roundRect(l,u,g-l,h-u,p),d.fill()):d.fillRect(l,u,g-l,h-u)),m){const _=d.lineWidth;if(A!==void 0&&(d.lineWidth=Zx(this.transform,A)),a){let f=[];const I=Math.abs(this.transform.a);if(I>0){const y=.1*I,x=y*1.3;y>.5&&(f=[y,x])}d.setLineDash(f)}p>0&&d.roundRect?(d.beginPath(),d.roundRect(l,u,g-l,h-u,p),d.stroke()):d.strokeRect(l,u,g-l,h-u),a&&d.setLineDash([]),A!==void 0&&(d.lineWidth=_)}}rotatedRect(t,e,n,o,i,r,s){const a=this.getLayerCtx();this.applyAperture();const[A,c]=_i(this.transform,[t-n/2,e-o/2]),[l,u]=_i(this.transform,[t+n/2,e+o/2]),g=r?Zx(this.transform,r):0;a.save();const[h,d]=_i(this.transform,[t,e]);a.translate(h,d);const p=360-i;i&&a.rotate(p*Math.PI/180),a.translate(-h,-d),s?(a.beginPath(),g>0&&a.roundRect?a.roundRect(A,c,l-A,u-c,g):a.rect(A,c,l-A,u-c),a.clip(),this.drawMeshPattern(t-n/2,e-o/2,n,o,.15),g>0&&a.roundRect?(a.beginPath(),a.roundRect(A,c,l-A,u-c,g),a.stroke()):a.strokeRect(A,c,l-A,u-c)):g>0&&a.roundRect?(a.beginPath(),a.roundRect(A,c,l-A,u-c,g),a.fill()):a.fillRect(A,c,l-A,u-c),a.restore()}rotatedPill(t,e,n,o,i){const r=this.getLayerCtx();this.applyAperture(),r.save();const[s,a]=_i(this.transform,[t,e]);r.translate(s,a);const A=360-i;i&&r.rotate(A*Math.PI/180),r.translate(-s,-a),this.pill(t,e,n,o),r.restore()}circle(t,e,n,o,i=!0){const r=Zx(this.transform,n),[s,a]=_i(this.transform,[t,e]);this.applyAperture();const A=this.getLayerCtx();o?(A.save(),A.beginPath(),A.arc(s,a,r,0,2*Math.PI),A.clip(),this.drawMeshPattern(t-n,e-n,n*2,n*2,.15),A.restore(),A.beginPath(),A.arc(s,a,r,0,2*Math.PI),A.stroke()):(A.beginPath(),A.arc(s,a,r,0,2*Math.PI),A.fill())}oval(t,e,n,o){const i=Zx(this.transform,n),r=Zx(this.transform,o),[s,a]=_i(this.transform,[t,e]);this.applyAperture();const A=this.getLayerCtx();A.beginPath(),A.ellipse(s,a,i,r,0,0,2*Math.PI),A.fill(),A.closePath()}pill(t,e,n,o){const[i,r]=_i(this.transform,[t-n/2,e+o/2]),s=Zx(this.transform,n),a=Zx(this.transform,o),A=Math.min(s,a)/2;this.applyAperture();const c=this.getLayerCtx();c.beginPath(),c.arc(i+A,r+A,A,Math.PI,Math.PI*1.5),c.arc(i+s-A,r+A,A,Math.PI*1.5,0),c.arc(i+s-A,r+a-A,A,0,Math.PI*.5),c.arc(i+A,r+a-A,A,Math.PI*.5,Math.PI),c.fill(),c.closePath()}polygon(t){if(t.length<3)return;this.applyAperture();const e=this.getLayerCtx(),n=t.map(i=>_i(this.transform,[i.x,i.y]));e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let i=1;i<n.length;i++)e.lineTo(n[i][0],n[i][1]);e.closePath(),e.fill("evenodd");const o=Zx(this.transform,this.aperture.size);o>0&&(e.lineWidth=o,e.stroke())}debugText(t,e,n){const[o,i]=_i(this.transform,[e,n]);this.applyAperture();const r=this.getLayerCtx();r.font="10px sans-serif",r.fillText(t,o,i)}getLayerCtx(){const t=this.ctxLayerMap[this.aperture.layer];if(!t)throw new Error(`No context for layer "${this.aperture.layer}"`);return t}getLayerOpacity(t){if(this.xRayNetActive)return/^(top|bottom|inner\d+)$/.test(t)?this.hiddenLayerOpacity:0;const e=this.foregroundLayer,n=(e==="top"||e==="bottom")&&(t.startsWith(`${e}_`)||t.endsWith(`_${e}`)),o=["board","drill","edge_cuts","other"].includes(t);return t===e||n||o?1:this.hiddenLayerOpacity}orderAndFadeLayers(){const{canvasLayerMap:t,foregroundLayer:e}=this,o=["board",...Object.keys(t).filter(u=>/^inner\d+$/.test(u)).sort((u,g)=>Number(g.slice(5))-Number(u.slice(5))),...FFi.filter(u=>u!=="board")],i=e==="top"?"soldermask_top":e==="bottom"?"soldermask_bottom":void 0,r=e==="top"?"top_silkscreen":e==="bottom"?"bottom_silkscreen":void 0,s=e==="top"?"top_notes":e==="bottom"?"bottom_notes":void 0,a=e==="top"?"top_fabrication":e==="bottom"?"bottom_fabrication":void 0,A=e==="top"?"top_courtyard":e==="bottom"?"bottom_courtyard":void 0,c=[e,"edge_cuts",...i?[i]:[],...r?[r]:[],...s?[s]:[],...a?[a]:[],...A?[A]:[]],l=[...o.filter(u=>!c.includes(u)),...e==="drill"?[]:[e],...i?[i]:[],"edge_cuts",...r?[r]:[],...s?[s]:[],...a?[a]:[],...A?[A]:[],"drill"];l.forEach((u,g)=>{const h=t[u];h&&(h.style.zIndex=`${Ru.topLayer-(l.length-g)}`)});for(const[u,g]of Object.entries(t)){const h=this.getLayerOpacity(u);g.style.opacity=String(h),g.style.display=h===0?"none":""}}applyAperture(){const{transform:t,aperture:e}=this;let{size:n,mode:o,color:i,fontSize:r,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(i||(i="undefined"),a.lineWidth=Zx(t,n),a.lineCap="round",o==="add"){a.globalCompositeOperation="source-over";let A=dee[i.toLowerCase()];if(!A)try{A=Ka(i).rgb().toString()}catch{console.warn(`Invalid color format: '${i}'`),A="white"}a.fillStyle=A,a.strokeStyle=A}else a.globalCompositeOperation="destination-out",a.fillStyle="rgba(0,0,0,1)",a.strokeStyle="rgba(0,0,0,1)";a.font=`${Zx(V6(t),r)}px sans-serif`}moveTo(t,e){this.lastPoint={x:t,y:e}}lineTo(t,e){const[n,o]=_i(this.transform,[t,e]),{size:i,shape:r,mode:s}=this.aperture,a=Zx(this.transform,i),{lastPoint:A}=this,c=_i(this.transform,A);this.applyAperture();const l=this.getLayerCtx();r==="square"&&l.fillRect(c.x-a/2,c.y-a/2,a,a),l.beginPath(),l.moveTo(c.x,c.y),l.lineTo(n,o),l.stroke(),l.closePath(),r==="square"&&l.fillRect(n-a/2,o-a/2,a,a),this.lastPoint={x:t,y:e}}polygonWithArcs(t){const e=this.getLayerCtx(),n=o=>{if(o.vertices.length===0)return;const i=o.vertices[0],r=_i(this.transform,[i.x,i.y]);e.moveTo(r[0],r[1]);for(let s=0;s<o.vertices.length;s++){const a=o.vertices[s],A=o.vertices[(s+1)%o.vertices.length];if(a.bulge&&a.bulge!==0){const c=a.bulge,l=A.x-a.x,u=A.y-a.y,g=Math.sqrt(l*l+u*u);if(g<1e-9){const M=_i(this.transform,[A.x,A.y]);e.lineTo(M[0],M[1]);continue}const h=4*Math.atan(c),d=Math.abs(g/(2*Math.sin(h/2))),p=(a.x+A.x)/2,m=(a.y+A.y)/2,_=l/g,I=-(u/g),C=_,y=Math.sqrt(Math.max(0,d*d-(g/2)**2)),x=p+y*I*Math.sign(c),E=m+y*C*Math.sign(c),B=Math.atan2(a.y-E,a.x-x);let S=Math.atan2(A.y-E,A.x-x);c>0&&S<B?S+=2*Math.PI:c<0&&S>B&&(S-=2*Math.PI);const Q=_i(this.transform,[x,E]),w=Zx(this.transform,d);e.arc(Q[0],Q[1],w,-B,-S,c>0)}else{const c=_i(this.transform,[A.x,A.y]);e.lineTo(c[0],c[1])}}e.closePath()};if(e.beginPath(),n(t.outer_ring),t.inner_rings)for(const o of t.inner_rings)n(o);e.fill("evenodd")}},HFi=(t=2)=>{const e=Math.max(2,Math.min(10,Math.floor(t)));return["top",...Array.from({length:e-2},(n,o)=>`inner${o+1}`),"bottom"]},Afe=t=>{const e=t.find(n=>n.type==="pcb_board");return HFi(e?.num_layers??2)},C$e=t=>`${t}_copper`,uhn=t=>t.map(e=>e.endsWith("_copper")?e.slice(0,-7):e),OFi=t=>["board","bottom","soldermask_bottom","bottom_silkscreen","top","soldermask_top","soldermask_with_copper_bottom","soldermask_with_copper_top","top_fabrication","bottom_fabrication",...Afe(t).filter(n=>n.startsWith("inner")),"drill","edge_cuts","bottom_notes","top_notes","top_silkscreen","top_courtyard","bottom_courtyard","other"],GFi=(t,e)=>{const n=Afe(t).reverse();return[...n.filter(o=>o!==e),...n.filter(o=>o===e)]};function YFi(t){return t.type==="pcb_copper_pour"}function UFi({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=e.filter(YFi);if(i.length===0)return;const r=new xl(t);r.realToCanvasMat=o,r.drawElements(i,{layers:n})}var KFi={...i2,courtyard:{top:qi.board.f_crtyd,bottom:qi.board.b_crtyd}};function VFi(t){return t.type==="pcb_courtyard_circle"||t.type==="pcb_courtyard_rect"||t.type==="pcb_courtyard_outline"}function ghn({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=new xl(t);i.configure({colorOverrides:KFi}),i.realToCanvasMat=o;const r=e.filter(VFi);i.drawElements(r,{layers:n})}var zFi={...i2,silkscreen:{top:qi.board.f_fab,bottom:qi.board.b_fab}};function JFi(t){return t.type.includes("pcb_fabrication_note")}function dhn({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=new xl(t);i.configure({colorOverrides:zFi}),i.realToCanvasMat=o;const r=e.filter(JFi);i.drawElements(r,{layers:n})}function WFi(t){return t.type==="pcb_hole"}function jFi({canvas:t,elements:e,layers:n,realToCanvasMat:o,drawSoldermask:i}){const r=new xl(t);r.realToCanvasMat=o;const s=e.filter(WFi);r.drawElements(s,{layers:n,drawSoldermask:i})}function $Fi(t){return t.type==="pcb_board"}function hhn({canvas:t,elements:e,layers:n,realToCanvasMat:o,drawSoldermask:i}){const r=new xl(t);r.realToCanvasMat=o;const s=e.filter($Fi);for(const a of s)r.drawElements([a],{layers:n,drawSoldermask:!1,drawBoardMaterial:i??!1,minBoardOutlineStrokePx:2})}function qFi(t){return t.type==="pcb_copper_text"}function XFi({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=e.filter(qFi);if(i.length===0)return;const r=new xl(t);r.realToCanvasMat=o,r.drawElements(i,{layers:n})}function ZFi(t){return t.type==="pcb_cutout"}function eLi({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=new xl(t);i.realToCanvasMat=o;const r=e.filter(ZFi);i.drawElements(r,{layers:n})}function tLi(t){return t.type==="pcb_keepout"}function nLi({elements:t,layer:e}){return t.filter(tLi).filter(n=>n.layers.includes(e))}function oLi(t){return Ka(dee[t]).lighten(.4).hex()}function iLi({canvas:t,elements:e,layer:n,realToCanvasMat:o}){const i=nLi({elements:e,layer:n});if(i.length===0)return;const r=new xl(t),s=oLi(n);r.configure({colorOverrides:{keepout:{top:s,bottom:s}}}),r.realToCanvasMat=o,r.drawElements(i,{layers:[C$e(n)]})}function rLi(t){return t.type.startsWith("pcb_note_")}function phn({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=new xl(t);i.realToCanvasMat=o;const r=e.filter(rLi);i.drawElements(r,{layers:n})}function sLi(t){return t.type==="pcb_panel"}function aLi({canvas:t,elements:e,layers:n,realToCanvasMat:o,drawSoldermask:i}){const r=new xl(t);r.realToCanvasMat=o;const s=e.filter(sLi);for(const a of s)r.drawElements([a],{layers:n})}var ALi={...i2,copper:{...i2.copper,top:Ka(qi.board.pad_front).lighten(.5).toString(),bottom:Ka(qi.board.pad_back).lighten(.5).toString(),inner1:Ka(qi.board.copper.in1).lighten(.5).toString(),inner2:Ka(qi.board.copper.in2).lighten(.5).toString(),inner3:Ka(qi.board.copper.in3).lighten(.5).toString(),inner4:Ka(qi.board.copper.in4).lighten(.5).toString(),inner5:Ka(qi.board.copper.in5).lighten(.5).toString(),inner6:Ka(qi.board.copper.in6).lighten(.5).toString(),inner7:Ka(qi.board.copper.in7).lighten(.5).toString(),inner8:Ka(qi.board.copper.in8).lighten(.5).toString()}};function cLi(t){return t.type==="pcb_smtpad"}function mhn({canvas:t,elements:e,layers:n,realToCanvasMat:o,primitives:i,drawSoldermask:r}){const s=new Set(uhn(n)),a=e.filter(cLi).filter(u=>s.has(u.layer));if(a.length===0)return;const A=new Set;if(i)for(const u of i)(u.is_mouse_over||u.is_in_highlighted_net)&&u._element?.type==="pcb_smtpad"&&A.add(u._element.pcb_smtpad_id);const c=a.filter(u=>A.has(u.pcb_smtpad_id)),l=a.filter(u=>!A.has(u.pcb_smtpad_id));if(l.length>0){const u=new xl(t);u.realToCanvasMat=o,u.drawElements(l,{layers:n,drawSoldermask:r})}if(c.length>0){const u=new xl(t);u.configure({colorOverrides:ALi}),u.realToCanvasMat=o,u.drawElements(c,{layers:n,drawSoldermask:r})}}var lLi={...i2,copper:Object.fromEntries(Object.entries(i2.copper).map(([t,e])=>[t,Ka(e).lighten(.5).toString()]))};function uLi(t){return t.type==="pcb_trace"}var gLi=(t,e)=>{const n=t.route.filter(r=>r.route_type==="wire"&&"layer"in r&&e.has(r.layer)?!0:r.route_type==="via"?e.has(r.from_layer)||e.has(r.to_layer):!1),o=n.filter(r=>r.route_type==="wire").length,i=n.some(r=>r.route_type==="via");return o<2&&!i?null:{...t,route:n}},dLi=t=>({...t,route:t.route.map(e=>!("is_inside_copper_pour"in e)||e.is_inside_copper_pour!==!0?e:{...e,is_inside_copper_pour:!1})}),hLi=(t,e)=>e?t:t.filter(n=>n.type!=="pcb_copper_pour"),pLi=({primitives:t})=>{const e=new Set;for(const n of t)(n.is_mouse_over||n.is_in_highlighted_net)&&n._element?.type==="pcb_trace"&&e.add(n._element.pcb_trace_id);return e};function _hn({canvas:t,elements:e,layers:n,realToCanvasMat:o,primitives:i,showCopperPours:r}){const s=new Set(uhn(n)),a=e.filter(uLi).map(g=>gLi(g,s)).filter(g=>g!==null).map(g=>r?g:dLi(g));if(a.length===0)return;const A=pLi({primitives:i??[]}),c=[],l=[];for(const g of a)A.has(g.pcb_trace_id)?c.push(g):l.push(g);const u=hLi(e,r);if(l.length>0){const g=new xl(t);g.realToCanvasMat=o,g.drawElements(l,{layers:n,clipContextElements:u})}if(c.length>0){const g=new xl(t);g.configure({colorOverrides:lLi}),g.realToCanvasMat=o,g.drawElements(c,{layers:n,clipContextElements:u})}}var mLi={...i2,copper:{...i2.copper,top:Ka(qi.board.pad_front).lighten(.5).toString(),bottom:Ka(qi.board.pad_back).lighten(.5).toString(),inner1:Ka(qi.board.copper.in1).lighten(.5).toString(),inner2:Ka(qi.board.copper.in2).lighten(.5).toString(),inner3:Ka(qi.board.copper.in3).lighten(.5).toString(),inner4:Ka(qi.board.copper.in4).lighten(.5).toString(),inner5:Ka(qi.board.copper.in5).lighten(.5).toString(),inner6:Ka(qi.board.copper.in6).lighten(.5).toString(),inner7:Ka(qi.board.copper.in7).lighten(.5).toString(),inner8:Ka(qi.board.copper.in8).lighten(.5).toString()}};function _Li(t){return t.type==="pcb_plated_hole"}function fhn({canvas:t,elements:e,layers:n,realToCanvasMat:o,primitives:i,drawSoldermask:r}){const s=e.filter(_Li);if(s.length===0)return;const a=new Set;if(i)for(const l of i)(l.is_mouse_over||l.is_in_highlighted_net)&&l._element?.type==="pcb_plated_hole"&&a.add(l._element.pcb_plated_hole_id);const A=s.filter(l=>a.has(l.pcb_plated_hole_id)),c=s.filter(l=>!a.has(l.pcb_plated_hole_id));if(c.length>0){const l=new xl(t);l.realToCanvasMat=o,l.drawElements(c,{layers:n,drawSoldermask:r})}if(A.length>0){const l=new xl(t);l.configure({colorOverrides:mLi}),l.realToCanvasMat=o,l.drawElements(A,{layers:n,drawSoldermask:r})}}function Ihn(t){const{lines:e,anchorPoint:n,ccwRotation:o}=t;if(!o)return e;const i=o*Math.PI/180,r=wNi(i),s=NC(Qd(n.x,n.y),r,Qd(-n.x,-n.y));return _i(s,n),e.map(a=>({...a,x1:_i(s,{x:a.x1,y:a.y1}).x,y1:_i(s,{x:a.x1,y:a.y1}).y,x2:_i(s,{x:a.x2,y:a.y2}).x,y2:_i(s,{x:a.x2,y:a.y2}).y}))}var fLi=.6,Chn=.2,yhn=t=>{const e=t.size*.7,n=e*fLi,o=e*Chn,i=e*Chn,r=t.text.split(/\r?\n/),s=t.text.length>0&&e>0,a=s?r.length:0,A=s?r.map(u=>u.length===0?0:u.length*n+(u.length-1)*o):[],c=A.length>0?Math.max(...A):0,l=a>0?a*e+(a-1)*i:0;return{text_lines:r,line_count:a,line_widths:A,target_height:e,target_width_char:n,space_between_chars:o,space_between_lines:i,width:c,height:l}},xhn=t=>{const e=yhn(t);return{width:e.width,height:e.height,lineHeight:e.target_height,lineSpacing:e.space_between_lines,lineCount:e.line_count}},Ehn=t=>{const{text_lines:e,line_count:n,line_widths:o,target_height:i,target_width_char:r,space_between_chars:s,space_between_lines:a,width:A}=yhn(t);if(i<=0||n===0)return[];const c=i/12,l=[];for(let u=0;u<n;u++){const g=-u*(i+a),h=o[u],d=(A-h)/2;let p=t.x+d;for(let m=0;m<e[u].length;m++){const _=e[u][m],f=Ov[_]??Ov[_.toUpperCase()];if(!f){p+=r+s;continue}for(const{x1:I,y1:C,x2:y,y2:x}of f)l.push({_pcb_drawing_object_id:i9("line"),pcb_drawing_type:"line",x1:p+r*I,y1:t.y+g+i*C,x2:p+r*y,y2:t.y+g+i*x,width:c,layer:t.layer,unit:t.unit,color:t.color});p+=r+s}}return l};function X6(t){const n=t.color??dee[t.layer];let o=Ka(n);return t._element?.type==="pcb_copper_pour"&&(o=o.alpha(.7)),t.is_mouse_over||t.is_in_highlighted_net?o.lighten(.5).rgb().toString():o.rgb().toString()}var Bhn=(t,e)=>{t.equip({size:e.zoomIndependent?e.width/t.transform.a:e.width,shape:e.squareCap?"square":"circle",color:X6(e),layer:e.layer}),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2)},ILi=(t,e,n)=>{switch(n){case"top_left":return{x:0,y:-e};case"top_center":return{x:-t/2,y:-e};case"top_right":return{x:-t,y:-e};case"center_left":return{x:0,y:-e/2};case"center":return{x:-t/2,y:-e/2};case"center_right":return{x:-t,y:-e/2};case"bottom_left":return{x:0,y:0};case"bottom_center":return{x:-t/2,y:0};case"bottom_right":return{x:-t,y:0};default:return{x:0,y:0}}},bhn=t=>t.layer==="bottom_silkscreen"||t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0,CLi=(t,e)=>{t.equip({fontSize:e.size,color:X6(e),layer:e.layer});const{width:n,height:o}=xhn(e),i=ILi(n,o,e.align);e.x??=0,e.y??=0;const r={x:e.x,y:e.y};let s=Ehn({...e,x:e.x+i.x,y:e.y+i.y});if(bhn(e)&&(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:r,ccwRotation:e.ccw_rotation};s=Ihn(a)}for(const a of s)Bhn(t,a)},yLi=(t,e)=>{const{width:n,height:o,lineHeight:i}=xhn(e);e.x??=0,e.y??=0;const r=e.knockout_padding??{left:e.size*.5,right:e.size*.5,top:e.size*.3,bottom:e.size*.3},s=n+r.left+r.right,a=o+r.top+r.bottom,A=n/2,c=i-o/2,l=e.x-A,u=e.y-c,g={x:e.x,y:e.y},h={_pcb_drawing_object_id:`knockout_rect_${e._pcb_drawing_object_id}`,x:e.x,y:e.y,w:s,h:a,layer:e.layer,ccw_rotation:e.ccw_rotation};e.ccw_rotation?Qhn(t,h):Shn(t,h);let d=Ehn({...e,x:l,y:u});if(bhn(e)&&(d=d.map(p=>({...p,x1:2*e.x-p.x1,x2:2*e.x-p.x2}))),e.ccw_rotation){const p={lines:d,anchorPoint:g,ccwRotation:e.ccw_rotation};d=Ihn(p)}for(const p of d)t.equip({size:p.width,shape:"circle",color:"black",layer:e.layer,mode:"subtract"}),t.moveTo(p.x1,p.y1),t.lineTo(p.x2,p.y2);t.equip({mode:"add"})},Shn=(t,e)=>{t.equip({color:X6(e),layer:e.layer,size:e.stroke_width}),t.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})},Qhn=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.rotatedRect(e.x,e.y,e.w,e.h,e.ccw_rotation,e.roundness,e.mesh_fill)},xLi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.rotatedPill(e.x,e.y,e.w,e.h,e.ccw_rotation)},ELi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.circle(e.x,e.y,e.r,e.mesh_fill)},BLi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.oval(e.x,e.y,e.rX,e.rY)},bLi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.pill(e.x,e.y,e.w,e.h)},SLi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.polygon(e.points)},QLi=(t,e)=>{t.equip({color:X6(e),layer:e.layer}),t.polygonWithArcs(e.brep_shape)},vLi=(t,e)=>{switch(e.pcb_drawing_type){case"line":return Bhn(t,e);case"text":return e.is_knockout?yLi(t,e):CLi(t,e);case"rect":return e.ccw_rotation?Qhn(t,e):Shn(t,e);case"circle":return ELi(t,e);case"oval":return BLi(t,e);case"pill":return e.ccw_rotation?xLi(t,e):bLi(t,e);case"polygon":return SLi(t,e);case"polygon_with_arcs":return QLi(t,e)}},wLi=(t,e)=>{for(const n of e)vLi(t,n)},PLi={...i2,silkscreen:{top:qi.board.f_silks,bottom:qi.board.b_silks}};function MLi(t){return t.type.includes("pcb_silkscreen")}function vhn({canvas:t,elements:e,layers:n,realToCanvasMat:o}){const i=new xl(t);i.configure({colorOverrides:PLi}),i.realToCanvasMat=o;const r=e.filter(MLi);i.drawElements(r,{layers:n})}var DLi={...i2,copper:{...i2.copper,top:Ka(qi.board.pad_front).lighten(.5).toString(),bottom:Ka(qi.board.pad_back).lighten(.5).toString(),inner1:Ka(qi.board.copper.in1).lighten(.5).toString(),inner2:Ka(qi.board.copper.in2).lighten(.5).toString(),inner3:Ka(qi.board.copper.in3).lighten(.5).toString(),inner4:Ka(qi.board.copper.in4).lighten(.5).toString(),inner5:Ka(qi.board.copper.in5).lighten(.5).toString(),inner6:Ka(qi.board.copper.in6).lighten(.5).toString(),inner7:Ka(qi.board.copper.in7).lighten(.5).toString(),inner8:Ka(qi.board.copper.in8).lighten(.5).toString()},soldermask:{...i2.soldermask,top:Ka(qi.board.soldermask.top).lighten(.35).toString(),bottom:Ka(qi.board.soldermask.bottom).lighten(.35).toString()}};function whn({canvas:t,elements:e,layers:n,realToCanvasMat:o,drawSoldermaskTop:i,drawSoldermaskBottom:r,primitives:s}){const a=new xl(t);a.realToCanvasMat=o;const A=e.filter(g=>g.type==="pcb_board");if(a.drawElements(e,{layers:n,drawSoldermask:!0,drawSoldermaskTop:i,drawSoldermaskBottom:r,drawBoardMaterial:!1}),A.length>1&&hhn({canvas:t,elements:A,layers:[],realToCanvasMat:o,drawSoldermask:!1}),!s)return;const c=new Set;for(const g of s){if(!(g.is_mouse_over||g.is_in_highlighted_net))continue;const h=g._element;h?.type==="pcb_smtpad"?c.add(h.pcb_smtpad_id):h?.type==="pcb_plated_hole"?c.add(h.pcb_plated_hole_id):h?.type==="pcb_via"&&c.add(h.pcb_via_id)}if(c.size===0)return;const l=e.filter(g=>g.type==="pcb_smtpad"?c.has(g.pcb_smtpad_id):g.type==="pcb_plated_hole"?c.has(g.pcb_plated_hole_id):g.type==="pcb_via"?c.has(g.pcb_via_id):!1);if(l.length===0)return;const u=new xl(t);u.configure({colorOverrides:DLi}),u.realToCanvasMat=o,u.drawElements(l,{layers:n,clipContextElements:e,drawSoldermask:!0,drawSoldermaskTop:i,drawSoldermaskBottom:r,drawBoardMaterial:!1})}var NLi={...i2,copper:{...i2.copper,top:Ka(qi.board.pad_front).lighten(.5).toString(),bottom:Ka(qi.board.pad_back).lighten(.5).toString(),inner1:Ka(qi.board.copper.in1).lighten(.5).toString(),inner2:Ka(qi.board.copper.in2).lighten(.5).toString(),inner3:Ka(qi.board.copper.in3).lighten(.5).toString(),inner4:Ka(qi.board.copper.in4).lighten(.5).toString(),inner5:Ka(qi.board.copper.in5).lighten(.5).toString(),inner6:Ka(qi.board.copper.in6).lighten(.5).toString(),inner7:Ka(qi.board.copper.in7).lighten(.5).toString(),inner8:Ka(qi.board.copper.in8).lighten(.5).toString()}};function RLi(t){return t.type==="pcb_via"}function Phn({canvas:t,elements:e,layers:n,realToCanvasMat:o,primitives:i,drawSoldermask:r}){const s=e.filter(RLi).filter(l=>n.some(u=>u.includes("copper")));if(s.length===0)return;const a=new Set;if(i)for(const l of i)(l.is_mouse_over||l.is_in_highlighted_net)&&l._element?.type==="pcb_via"&&a.add(l._element.pcb_via_id);const A=s.filter(l=>a.has(l.pcb_via_id)),c=s.filter(l=>!a.has(l.pcb_via_id));if(c.length>0){const l=new xl(t);l.realToCanvasMat=o,l.drawElements(c,{layers:n,drawSoldermask:r,drawSoldermaskTop:n.includes("top_copper"),drawSoldermaskBottom:n.includes("bottom_copper"),clipContextElements:e})}if(A.length>0){const l=new xl(t);l.configure({colorOverrides:NLi}),l.realToCanvasMat=o,l.drawElements(A,{layers:n,drawSoldermask:r,drawSoldermaskTop:n.includes("top_copper"),drawSoldermaskBottom:n.includes("bottom_copper"),clipContextElements:e})}}var TLi=({primitives:t,isShowingSolderMask:e,isShowingSilkscreen:n,isShowingFabricationNotes:o})=>t.filter(i=>e||!i.layer?.includes("soldermask")).filter(i=>n||!i.layer?.includes("silkscreen")).filter(i=>o||!i.layer?.includes("fabrication")).filter(i=>i.layer!=="board").filter(i=>i._element?.type!=="pcb_smtpad").filter(i=>i._element?.type!=="pcb_plated_hole"||i.layer==="drill").filter(i=>i._element?.type!=="pcb_via").filter(i=>i._element?.type!=="pcb_trace").filter(i=>i._element?.type!=="pcb_copper_text"),kLi=({primitives:t,elements:e,xRayElements:n,transform:o,grid:i,width:r=500,height:s=500})=>{const a=ee.useRef(null),A=ee.useRef({}),c=Kc(_=>_.hidden_layer_opacity),l=Kc(_=>_.selected_layer),u=Kc(_=>_.is_showing_copper_pours),g=Kc(_=>_.is_showing_solder_mask),h=Kc(_=>_.is_showing_fabrication_notes),d=Kc(_=>_.is_showing_pcb_notes),p=Kc(_=>_.is_showing_courtyards),m=Kc(_=>_.is_showing_silkscreen);return ee.useEffect(()=>{if(!A.current||Object.keys(A.current).length===0)return;const _=Object.fromEntries(Object.entries(A.current).filter(([x,E])=>!!E));if(Object.keys(_).length===0)return;const f=new LFi(_);o&&(f.transform=o),f.clear(),f.foregroundLayer=l,f.hiddenLayerOpacity=c,f.xRayNetActive=!!n;const I=Object.fromEntries(Object.entries(_).filter(([x])=>f.getLayerOpacity(x)>0)),C=TLi({primitives:t,isShowingSolderMask:g,isShowingSilkscreen:m,isShowingFabricationNotes:h});if(wLi(f,C.filter(x=>f.getLayerOpacity(x.layer??"other")>0)),o){const x=Afe(e).map(Q=>({canvas:I[Q],layer:Q,copperLayer:C$e(Q)}));for(const{canvas:Q,copperLayer:w}of x)Q&&_hn({canvas:Q,elements:e,layers:[w],realToCanvasMat:o,primitives:t,showCopperPours:u});for(const{canvas:Q,copperLayer:w}of x)Q&&XFi({canvas:Q,elements:e,layers:[w],realToCanvasMat:o});for(const{canvas:Q,copperLayer:w,layer:M}of x)Q&&fhn({canvas:Q,elements:e,layers:[w],realToCanvasMat:o,primitives:t,drawSoldermask:g&&(M==="top"||M==="bottom")});for(const{canvas:Q,copperLayer:w}of x)Q&&UFi({canvas:Q,elements:e,layers:[w],realToCanvasMat:o});for(const{canvas:Q,copperLayer:w}of x)Q&&mhn({canvas:Q,elements:e,layers:[w],realToCanvasMat:o,primitives:t,drawSoldermask:g});for(const{canvas:Q,copperLayer:w,layer:M}of x)Q&&Phn({canvas:Q,elements:e,layers:[w],realToCanvasMat:o,primitives:t,drawSoldermask:g&&(M==="top"||M==="bottom")});if(g){const Q=l==="bottom"?"bottom":"top",w=Q==="top",M=Q==="bottom",k=I.soldermask_top;k&&Q==="top"&&whn({canvas:k,elements:e,layers:["top_soldermask"],realToCanvasMat:o,drawSoldermaskTop:w,drawSoldermaskBottom:M,primitives:t});const R=I.soldermask_bottom;R&&Q==="bottom"&&whn({canvas:R,elements:e,layers:["bottom_soldermask"],realToCanvasMat:o,drawSoldermaskTop:w,drawSoldermaskBottom:M,primitives:t})}const E=I.drill;if(E&&jFi({canvas:E,elements:e,layers:["drill"],realToCanvasMat:o}),m){const Q=I.top_silkscreen;Q&&vhn({canvas:Q,elements:e,layers:["top_silkscreen"],realToCanvasMat:o});const w=I.bottom_silkscreen;w&&vhn({canvas:w,elements:e,layers:["bottom_silkscreen"],realToCanvasMat:o})}if(h){const Q=I.top_fabrication;Q&&dhn({canvas:Q,elements:e,layers:["top_fabrication_note"],realToCanvasMat:o});const w=I.bottom_fabrication;w&&dhn({canvas:w,elements:e,layers:["bottom_fabrication_note"],realToCanvasMat:o})}if(d){const Q=I.bottom_notes;Q&&phn({canvas:Q,elements:e,layers:["bottom_user_note"],realToCanvasMat:o});const w=I.top_notes;w&&phn({canvas:w,elements:e,layers:["top_user_note"],realToCanvasMat:o})}if(p){const Q=I.top_courtyard;Q&&ghn({canvas:Q,elements:e,layers:["top_courtyard"],realToCanvasMat:o});const w=I.bottom_courtyard;w&&ghn({canvas:w,elements:e,layers:["bottom_courtyard"],realToCanvasMat:o})}const B=I.board;B&&(aLi({canvas:B,elements:e,layers:[],realToCanvasMat:o,drawSoldermask:g}),hhn({canvas:B,elements:e,layers:[],realToCanvasMat:o,drawSoldermask:g}));const S=I.edge_cuts;S&&eLi({canvas:S,elements:e,layers:["edge_cuts"],realToCanvasMat:o});for(const{canvas:Q,layer:w}of x)Q&&iLi({canvas:Q,elements:e,layer:w,realToCanvasMat:o})}f.orderAndFadeLayers();const y=a.current;if(y&&o&&n){y.getContext("2d").clearRect(0,0,r,s);for(const E of GFi(e,l)){const B={canvas:y,elements:n,layers:[C$e(E)],realToCanvasMat:o,drawSoldermask:!1};_hn({...B,showCopperPours:!1}),mhn(B),fhn(B),Phn(B)}const x=new xl(y);x.realToCanvasMat=o,x.drawElements(n.filter(E=>E.type==="pcb_via"||E.type==="pcb_plated_hole"),{layers:["drill"],drawSoldermask:!1})}},[t,e,n,r,s,o,l,c,u,g,h,d,p,m]),K.jsxs("div",{style:{backgroundColor:"black",width:r,height:s,position:"relative"},children:[K.jsx(FT.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:r,height:s,transform:o,stringifyCoord:(_,f,I)=>`${FT.toMMSI(_,I)}, ${FT.toMMSI(f,I)}`}),n&&K.jsx("canvas",{ref:a,className:"pcb-x-ray-net",width:r,height:s,style:{position:"absolute",left:0,top:0,zIndex:Ru.topLayer,pointerEvents:"none"}}),OFi(e).filter(_=>!(!g&&_.includes("soldermask")||!m&&_.includes("silkscreen"))).map(_=>_.replace(/-/g,"")).map((_,f)=>K.jsx("canvas",{className:`pcb-layer-${_}`,ref:I=>{A.current??={},I?A.current[_]=I:delete A.current[_]},style:{position:"absolute",zIndex:f,left:0,top:0,pointerEvents:"none"},width:r,height:s},_))]})};new TextEncoder,(()=>{const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])})();var FLi=new Uint16Array([255]),LLi=new Uint8Array(FLi.buffer);LLi[0];var HLi=new Uint16Array([255]),OLi=new Uint8Array(HLi.buffer);OLi[0],new TextDecoder("latin1");var YP=1e-9,cfe=(t,e,n)=>t>=e-YP&&t<=n+YP,GLi=t=>{const e=[];for(const n of t)e.some(o=>Math.abs(o.x-n.x)<YP&&Math.abs(o.y-n.y)<YP)||e.push(n);return e};function YLi(t,e){const{origin:n,directionVector:o}=t;if(Math.abs(o.x)<YP&&Math.abs(o.y)<YP)return null;const i=[];if(Math.abs(o.x)>=YP){const c=(e.minX-n.x)/o.x,l=n.y+c*o.y;cfe(l,e.minY,e.maxY)&&i.push({x:e.minX,y:l});const u=(e.maxX-n.x)/o.x,g=n.y+u*o.y;cfe(g,e.minY,e.maxY)&&i.push({x:e.maxX,y:g})}if(Math.abs(o.y)>=YP){const c=(e.minY-n.y)/o.y,l=n.x+c*o.x;cfe(l,e.minX,e.maxX)&&i.push({x:l,y:e.minY});const u=(e.maxY-n.y)/o.y,g=n.x+u*o.x;cfe(g,e.minX,e.maxX)&&i.push({x:g,y:e.maxY})}const r=GLi(i);if(r.length<2)return null;let s=r[0],a=r[1],A=(s.x-a.x)**2+(s.y-a.y)**2;for(let c=0;c<r.length;c++)for(let l=c+1;l<r.length;l++){const u=r[c],g=r[l],h=(u.x-g.x)**2+(u.y-g.y)**2;h>A&&(s=u,a=g,A=h)}return[s,a]}function ULi(t,e,n){const o=V6(t),i=[_i(o,{x:0,y:0}),_i(o,{x:e,y:0}),_i(o,{x:0,y:n}),_i(o,{x:e,y:n})];return{minX:Math.min(...i.map(r=>r.x)),maxX:Math.max(...i.map(r=>r.x)),minY:Math.min(...i.map(r=>r.y)),maxY:Math.max(...i.map(r=>r.y))}}var KLi=.6,VLi=1,Mhn=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Dhn=t=>(t.ccwRotationDegrees??0)*Math.PI/180,zLi=t=>t.a*t.d-t.b*t.c<0?1:-1,JLi=(t,e)=>Dhn(t)*zLi(e),WLi=(t,e)=>{const n=Math.cos(e),o=Math.sin(e);return{x:t.x*n-t.y*o,y:t.x*o+t.y*n}},jLi=t=>Nhn(t,Dhn(t)),$Li=(t,e)=>Nhn(t,JLi(t,e)),Nhn=(t,e)=>{const n=t.width/2,o=t.height/2;return[{x:-n,y:-o},{x:n,y:-o},{x:n,y:o},{x:-n,y:o}].map(i=>{const r=WLi(i,e);return{x:t.center.x+r.x,y:t.center.y+r.y}})},qLi=(t,e)=>{const n=$Li(t,e).map(c=>_i(e,c)),o=_i(e,t.center),i=Mhn(n[0],n[1]),r=Mhn(n[1],n[2]),s=n.length>=2?Math.atan2(n[1].y-n[0].y,n[1].x-n[0].x):0,a=s*180/Math.PI,A=n.reduce((c,l)=>({minX:Math.min(c.minX,l.x),maxX:Math.max(c.maxX,l.x),minY:Math.min(c.minY,l.y),maxY:Math.max(c.maxY,l.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0});return{center:o,corners:n,width:i,height:r,angleRadians:s,angleDegrees:a,bounds:A}},XLi=2,ZLi=12,eHi=12,lfe=t=>({tip:{...t},base:{...t},leftWing:{...t},rightWing:{...t}}),Rhn=(t,e,n)=>{const o=t.x-e.x,i=t.y-e.y,r=Math.hypot(o,i);if(r===0)return lfe(t);const s=o/r,A=-(i/r)*(n/2),c=s*(n/2);return{tip:{...t},base:{...e},leftWing:{x:e.x+A,y:e.y+c},rightWing:{x:e.x-A,y:e.y-c}}};function Thn(t){const{start:e,end:n}=t,o=n.x-e.x,i=n.y-e.y,r=Math.hypot(o,i),s=XLi,a=ZLi;if(r===0){const f=t.doubleSided?[lfe(e),lfe(e)]:[lfe(e)];return{shaftStart:{...e},shaftEnd:{...e},heads:f,shaftWidth:s,headLength:0,headWidth:a,length:r}}const A=o/r,c=i/r,l=Math.min(eHi,r*.5),u=Math.max(l,s*2),g=t.doubleSided?r/2:r,h=Math.min(u,g),d={x:n.x-A*h,y:n.y-c*h},p=[Rhn(n,d,a)];let m={...e};const _={...d};if(t.doubleSided){const f={x:e.x+A*h,y:e.y+c*h};p.unshift(Rhn(e,f,a)),m=f}return{shaftStart:m,shaftEnd:_,heads:p,shaftWidth:s,headLength:h,headWidth:a,length:r}}function tHi(t){const e=Thn(t);return[e.shaftStart,e.shaftEnd,...e.heads.flatMap(o=>[o.tip,o.base,o.leftWing,o.rightWing])].reduce((o,i)=>({minX:Math.min(o.minX,i.x),maxX:Math.max(o.maxX,i.x),minY:Math.min(o.minY,i.y),maxY:Math.max(o.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function khn(t,e,{fontSize:n=12,strokeWidth:o=2,normalPadding:i=6,alongOffset:r=0}={}){const s={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a=e.x-t.x,A=e.y-t.y,c=Math.hypot(a,A);if(c===0)return{x:s.x+r,y:s.y-(o/2+n*.65+i),angleRadians:0,angleDegrees:0,direction:{x:1,y:0},normal:{x:0,y:-1}};let l=a/c,u=A/c,g=-u,h=l;(l<0||l===0&&u<0)&&(l=-l,u=-u,g=-g,h=-h);const p=Math.atan2(u,l),m=o/2+n*.65+i;return{x:s.x+g*m+l*r,y:s.y+h*m+u*r,angleRadians:p,angleDegrees:p*180/Math.PI,direction:{x:l,y:u},normal:{x:g,y:h}}}var UP=["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 Fhn(t,e,n,o={}){const i=o.padding??40,r=o.yFlip??!1;let s;if("center"in t){const l=t.width/2,u=t.height/2;s={minX:t.center.x-l,maxX:t.center.x+l,minY:t.center.y-u,maxY:t.center.y+u}}else s=t;const a=s.maxX-s.minX||1,A=s.maxY-s.minY||1,c=Math.min((e-2*i)/a,(n-2*i)/A);return NC(Qd(e/2,n/2),vS(c,r?-c:c),Qd(-(s.minX+a/2),-(s.minY+A/2)))}function nHi(t){const e=[...t.points||[],...(t.lines||[]).flatMap(n=>n.points),...(t.polygons||[]).flatMap(n=>n.points),...(t.rects||[]).flatMap(n=>jLi(n)),...(t.circles||[]).flatMap(n=>[{x:n.center.x-n.radius,y:n.center.y},{x:n.center.x+n.radius,y:n.center.y},{x:n.center.x,y:n.center.y-n.radius},{x:n.center.x,y:n.center.y+n.radius}]),...(t.arrows||[]).flatMap(n=>{const o=tHi(n);return[{x:o.minX,y:o.minY},{x:o.maxX,y:o.maxY}]}),...(t.texts||[]).flatMap(n=>{const o=n.fontSize??12,i=n.text.length*o*KLi,r=o*VLi,s=n.anchorSide??"center",a={top_left:{dx:0,dy:0},top_center:{dx:-i/2,dy:0},top_right:{dx:-i,dy:0},center_left:{dx:0,dy:-r/2},center:{dx:-i/2,dy:-r/2},center_right:{dx:-i,dy:-r/2},bottom_left:{dx:0,dy:-r},bottom_center:{dx:-i/2,dy:-r},bottom_right:{dx:-i,dy:-r}},{dx:A,dy:c}=a[s],l=n.x+A,u=n.y+c;return[{x:l,y:u},{x:l+i,y:u+r}]})];return e.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:e.reduce((n,o)=>({minX:Math.min(n.minX,o.x),maxX:Math.max(n.maxX,o.x),minY:Math.min(n.minY,o.y),maxY:Math.max(n.maxY,o.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function oHi(t,e,n={}){const o=n.disableLabels!==!1,i=n.hideInlineLabels??o,r=e instanceof HTMLCanvasElement?e.getContext("2d"):e;if(!r)throw new Error("Could not get 2D context from canvas");const s=e instanceof HTMLCanvasElement?e.width:e.canvas.width,a=e instanceof HTMLCanvasElement?e.height:e.canvas.height;let A;if(n.transform)A=n.transform;else if(n.viewbox)A=Fhn(n.viewbox,s,a,{padding:n.padding,yFlip:n.yFlip});else{const c=nHi(t),l=t.coordinateSystem==="cartesian";A=Fhn(c,s,a,{padding:n.padding??40,yFlip:l})}if(r.clearRect(0,0,s,a),r.save(),t.rects&&t.rects.length>0&&t.rects.forEach(c=>{const l=qLi(c,A);r.save(),r.translate(l.center.x,l.center.y),Math.abs(l.angleRadians)>1e-6&&r.rotate(l.angleRadians),r.beginPath(),r.rect(-l.width/2,-l.height/2,l.width,l.height),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke,r.stroke()),r.restore()}),t.circles&&t.circles.length>0&&t.circles.forEach(c=>{const l=_i(A,c.center),u=c.radius*Math.abs(A.a);r.beginPath(),r.arc(l.x,l.y,u,0,2*Math.PI),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke??"transparent",r.stroke())}),t.polygons&&t.polygons.length>0&&t.polygons.forEach(c=>{if(c.points.length===0)return;const l=c.points.map(u=>_i(A,u));r.beginPath(),r.moveTo(l[0].x,l[0].y);for(let u=1;u<l.length;u++)r.lineTo(l[u].x,l[u].y);r.closePath(),c.fill&&(r.fillStyle=c.fill,r.fill()),c.stroke&&(r.strokeStyle=c.stroke,c.strokeWidth!==void 0&&(r.lineWidth=c.strokeWidth*Math.abs(A.a)),r.stroke())}),t.arrows&&t.arrows.length>0&&t.arrows.forEach((c,l)=>{const u=Thn(c),g=_i(A,u.shaftStart),h=_i(A,u.shaftEnd),d=c.color||UP[l%UP.length],p=Math.hypot(A.a,A.b);r.strokeStyle=d,r.fillStyle=d,r.lineWidth=u.shaftWidth*(p||1),r.lineCap="round",r.setLineDash([]),r.beginPath(),r.moveTo(g.x,g.y),r.lineTo(h.x,h.y),r.stroke(),u.heads.forEach(y=>{const x=_i(A,y.tip),E=_i(A,y.leftWing),B=_i(A,y.rightWing);r.beginPath(),r.moveTo(x.x,x.y),r.lineTo(E.x,E.y),r.lineTo(B.x,B.y),r.closePath(),r.fill()});const m=12,_=u.shaftWidth*(p||1),f=m*.6,I=khn(g,h,{fontSize:m,strokeWidth:_,normalPadding:6,alongOffset:c.label?f:0}),C=khn(g,h,{fontSize:m,strokeWidth:_,normalPadding:12,alongOffset:c.inlineLabel?-f:0});if(r.fillStyle=d,r.font=`${m}px sans-serif`,!o&&c.label){const y=C.x,x=C.y;r.save(),r.textAlign="center",r.textBaseline="middle",r.fillText(c.label,y,x),r.restore()}!i&&c.inlineLabel&&(r.save(),r.translate(I.x,I.y),r.rotate(I.angleRadians),r.textAlign="center",r.textBaseline="middle",r.fillText(c.inlineLabel,0,0),r.restore())}),t.lines&&t.lines.length>0&&t.lines.map((c,l)=>({line:c,originalIndex:l})).sort((c,l)=>(c.line.zIndex??0)-(l.line.zIndex??0)||c.originalIndex-l.originalIndex).forEach(({line:c,originalIndex:l})=>{if(c.points.length===0)return;r.beginPath();const u=_i(A,c.points[0]);r.moveTo(u.x,u.y);for(let g=1;g<c.points.length;g++){const h=_i(A,c.points[g]);r.lineTo(h.x,h.y)}if(r.strokeStyle=c.strokeColor||UP[l%UP.length],c.strokeWidth?r.lineWidth=c.strokeWidth*A.a:r.lineWidth=2,r.lineCap="round",c.strokeDash)if(typeof c.strokeDash=="string"){let g;if(c.strokeDash.includes(","))g=c.strokeDash.split(",").map(h=>parseFloat(h.trim())).filter(h=>!Number.isNaN(h));else{const h=parseFloat(c.strokeDash.trim());g=Number.isNaN(h)?[]:[h]}r.setLineDash(g)}else r.setLineDash(c.strokeDash.map(g=>g*Math.abs(A.a)));else r.setLineDash([]);r.stroke()}),t.infiniteLines&&t.infiniteLines.length>0){const c=ULi(A,s,a);t.infiniteLines.forEach((l,u)=>{const g=YLi(l,c);if(!g)return;const[h,d]=g,p=_i(A,h),m=_i(A,d);if(r.beginPath(),r.moveTo(p.x,p.y),r.lineTo(m.x,m.y),r.strokeStyle=l.strokeColor||UP[u%UP.length],r.lineWidth=l.strokeWidth?l.strokeWidth*Math.abs(A.a):2,r.lineCap="round",l.strokeDash)if(typeof l.strokeDash=="string"){let _;if(l.strokeDash.includes(","))_=l.strokeDash.split(",").map(f=>parseFloat(f.trim())).filter(f=>!Number.isNaN(f));else{const f=parseFloat(l.strokeDash.trim());_=Number.isNaN(f)?[]:[f]}r.setLineDash(_)}else r.setLineDash(l.strokeDash.map(_=>_*Math.abs(A.a)));else r.setLineDash([]);r.stroke()})}t.texts&&t.texts.length>0&&t.texts.forEach(c=>{const l=_i(A,{x:c.x,y:c.y});r.fillStyle=c.color||"black",r.font=`${(c.fontSize??12)*Math.abs(A.a)}px sans-serif`;const u=c.anchorSide??"center",g={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"},h={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"};r.textAlign=g[u],r.textBaseline=h[u],r.fillText(c.text,l.x,l.y)}),t.points&&t.points.length>0&&t.points.forEach((c,l)=>{const u=_i(A,c);r.beginPath(),r.arc(u.x,u.y,3,0,2*Math.PI),r.fillStyle=c.color||UP[l%UP.length],r.fill(),c.label&&!o&&(r.fillStyle=c.color||"black",r.font="12px sans-serif",r.fillText(c.label,u.x+5,u.y-5))}),r.restore()}qgn(ZRi(),1);var iHi=({children:t,transform:e,debugGraphics:n})=>{const o=ee.useRef(null),[i,{width:r,height:s}]=uee(),a=Kc(A=>A.is_showing_autorouting);return ee.useEffect(()=>{a&&o.current&&n&&r&&s&&(o.current.width=r,o.current.height=s,oHi(n,o.current,{transform:e,disableLabels:!0}))},[n,e,r,s,a]),a?K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:o,style:{position:"absolute",top:0,left:0,opacity:.5,zIndex:100,width:"100%",height:"100%",pointerEvents:"none"}})]}):t},ufe=(t,e,n)=>n(t,e),Lhn=(t,e,n,o,i)=>{const r=i*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=t-n,c=e-o,l=A*s-c*a,u=A*a+c*s;return{x:l+n,y:u+o}},hee=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].x,o=t[0].y,i=t[0].y;for(const r of t)e=ufe(e,r.x,Math.min),n=ufe(n,r.x,Math.max),o=ufe(o,r.y,Math.min),i=ufe(i,r.y,Math.max);return{minX:e,maxX:n,minY:o,maxY:i}},rHi=(t,e)=>({minX:Math.min(t.minX,e.minX),maxX:Math.max(t.maxX,e.maxX),minY:Math.min(t.minY,e.minY),maxY:Math.max(t.maxY,e.maxY)}),sHi=(t,e)=>t?rHi(t,e):e,aHi=t=>{switch(t.pcb_drawing_type){case"line":{const e=(t.width??0)/2,n=[{x:t.x1,y:t.y1},{x:t.x2,y:t.y2}],o=hee(n);return o?{minX:o.minX-e,maxX:o.maxX+e,minY:o.minY-e,maxY:o.maxY+e}:null}case"rect":{const e=t.w/2,n=t.h/2,o=[{x:t.x-e,y:t.y-n},{x:t.x+e,y:t.y-n},{x:t.x+e,y:t.y+n},{x:t.x-e,y:t.y+n}],i=t.ccw_rotation??0,r=i===0?o:o.map(s=>Lhn(s.x,s.y,t.x,t.y,i));return hee(r)}case"circle":return{minX:t.x-t.r,maxX:t.x+t.r,minY:t.y-t.r,maxY:t.y+t.r};case"oval":return{minX:t.x-t.rX,maxX:t.x+t.rX,minY:t.y-t.rY,maxY:t.y+t.rY};case"pill":{const e=t.w/2,n=t.h/2,o=[{x:t.x-e,y:t.y-n},{x:t.x+e,y:t.y-n},{x:t.x+e,y:t.y+n},{x:t.x-e,y:t.y+n}],i=t.ccw_rotation??0,r=i===0?o:o.map(s=>Lhn(s.x,s.y,t.x,t.y,i));return hee(r)}case"polygon":return hee(t.points);case"polygon_with_arcs":{const e=t.brep_shape.outer_ring.vertices.map(n=>({x:n.x,y:n.y}));return hee(e)}case"text":{const e=t.size??0,n=t.text?t.text.length*e*.6:0,o=e;if(n===0&&o===0)return{minX:t.x,maxX:t.x,minY:t.y,maxY:t.y};const i=n/2,r=o/2;return{minX:t.x-i,maxX:t.x+i,minY:t.y-r,maxY:t.y+r}}default:return null}};function AHi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t,a=n.x-e.x,A=n.y-e.y,c=Math.sqrt(a*a+A*A),l=i.x-o.x,u=i.y-o.y,g=Math.sqrt(l*l+u*u),h=Math.atan2(u,l)*(180/Math.PI),d=Math.abs(h)%90,m=Math.min(d,90-d)>15,_=(o.x+i.x)/2,f=(o.y+i.y)/2,I=15,C=h+90;let y=Math.cos(C*Math.PI/180)*I,x=Math.sin(C*Math.PI/180)*I;const E=l>0&&u<0,B=l>0&&u>0,S=l<0&&u>0;r!==s&&!E&&(y=-y,x=-x),E&&(y+=Math.cos(C*Math.PI/180)*-45,x+=Math.sin(C*Math.PI/180)*-45),B&&(y+=Math.cos(C*Math.PI/180)+-20,x+=Math.sin(C*Math.PI/180)+-10),S&&(y+=Math.cos(C*Math.PI/180)*10,x+=Math.sin(C*Math.PI/180)*10);const Q=_+y,w=f+x;return{distance:c,screenDistance:g,x:Q,y:w,show:c>.01&&g>30&&m}}function cHi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t;return ee.useMemo(()=>AHi({dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}),[e,n,o,i,r,s])}var lHi=(t,e,n)=>{const o=n*Math.PI/180,i=Math.cos(o),r=Math.sin(o),s=t.x-e.x,a=t.y-e.y,A=s*i-a*r,c=s*r+a*i;return{x:A+e.x,y:c+e.y}},Hhn=(t,e,n,o)=>{const i={top_left:{x:t.x-e,y:t.y-n},top_center:{x:t.x,y:t.y-n},top_right:{x:t.x+e,y:t.y-n},center_left:{x:t.x-e,y:t.y},center:{x:t.x,y:t.y},center_right:{x:t.x+e,y:t.y},bottom_left:{x:t.x-e,y:t.y+n},bottom_center:{x:t.x,y:t.y+n},bottom_right:{x:t.x+e,y:t.y+n}};return o===0?Object.entries(i).map(([r,s])=>({anchor:r,point:s})):Object.entries(i).map(([r,s])=>({anchor:r,point:lHi(s,t,o)}))},uHi=t=>{switch(t.pcb_drawing_type){case"rect":{const e=t.ccw_rotation??0;return Hhn({x:t.x,y:t.y},t.w/2,t.h/2,e)}case"pill":{const e=t.ccw_rotation??0;return Hhn({x:t.x,y:t.y},t.w/2,t.h/2,e)}case"circle":return[{anchor:"circle_center",point:{x:t.x,y:t.y}},{anchor:"circle_right",point:{x:t.x+t.r,y:t.y}},{anchor:"circle_left",point:{x:t.x-t.r,y:t.y}},{anchor:"circle_top",point:{x:t.x,y:t.y-t.r}},{anchor:"circle_bottom",point:{x:t.x,y:t.y+t.r}}];case"oval":return[{anchor:"oval_center",point:{x:t.x,y:t.y}},{anchor:"oval_right",point:{x:t.x+t.rX,y:t.y}},{anchor:"oval_left",point:{x:t.x-t.rX,y:t.y}},{anchor:"oval_top",point:{x:t.x,y:t.y-t.rY}},{anchor:"oval_bottom",point:{x:t.x,y:t.y+t.rY}}];case"line":{const e={x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2};return[{anchor:"line_start",point:{x:t.x1,y:t.y1}},{anchor:"line_mid",point:e},{anchor:"line_end",point:{x:t.x2,y:t.y2}}]}case"polygon":return t.points.map((e,n)=>({anchor:`polygon_vertex_${n}`,point:e}));case"polygon_with_arcs":return t.brep_shape.outer_ring.vertices.map((e,n)=>({anchor:`polygon_with_arcs_vertex_${n}`,point:{x:e.x,y:e.y}}));default:return[]}},Ohn=({screenPoint:{x:t,y:e}})=>`M${t-2.5},${e-2.5}l5,5m0,-5l-5,5`,gHi=ee.memo(function({points:e,startId:n,endId:o}){const{path:i,pointsById:r}=ee.useMemo(()=>({path:e.map(Ohn).join(""),pointsById:new Map(e.map(a=>[a.id,a]))}),[e]),s=[...new Set([n,o])].flatMap(a=>{const A=a===null?void 0:r.get(a);return A?[Ohn(A)]:[]}).join("");return K.jsxs("svg",{"aria-hidden":"true",width:"100%",height:"100%",style:{position:"absolute",left:0,top:0,overflow:"visible",pointerEvents:"none",zIndex:Ru.dimensionOverlay},fill:"none",strokeWidth:1,children:[K.jsx("path",{d:i,stroke:"white"}),K.jsx("path",{d:s,stroke:"#66ccff"})]})}),dHi=16,hHi=[],pHi=RP(),Ghn=t=>{if(t.pcb_drawing_type==="text")return!0;const e=t._element;if(!e||typeof e!="object")return!1;const n=typeof e.type=="string"?e.type:void 0;return n?!!(n.startsWith("pcb_silkscreen_")||n.startsWith("pcb_note_")||n==="pcb_text"||n.startsWith("pcb_fabrication_note_")&&n!=="pcb_fabrication_note_rect"):!1},mHi=({children:t,transform:e,focusOnHover:n=!1,primitives:o=hHi,onBoundsSelected:i,cancelPanDrag:r})=>{e||(e=pHi);const[s,a]=ee.useState(!1),[A,c]=ee.useState(!1),[l,u]=ee.useState(!1),[g,h]=ee.useState(!1),[d,p]=ee.useState(!1),[m,_]=ee.useState(!1),[f,I]=ee.useState({start:null,end:null}),C=Kc(ve=>ve.is_mouse_over_container),y=ee.useCallback(()=>{l&&(u(!1),window.dispatchEvent(new Event("disarm-dimension-tool")))},[l]),x=ee.useCallback(()=>{g&&(h(!1),window.dispatchEvent(new Event("disarm-bounds-tool")))},[g]),[E,B]=ee.useState({x:0,y:0}),[S,Q]=ee.useState({x:0,y:0}),[w,M]=ee.useState({x:0,y:0}),[k,R]=ee.useState({x:0,y:0}),F=ee.useRef({x:0,y:0}),O=ee.useRef(!1),U=ee.useRef(null),W=U.current?.getBoundingClientRect(),te=ee.useMemo(()=>{const ve=new Map;for(const he of o){if(!he._element||Ghn(he)||he.pcb_drawing_type==="pill"||he.pcb_drawing_type==="rect"&&he.ccw_rotation&&he.ccw_rotation!==0)continue;const Qe=aHi(he);if(!Qe)continue;const Pe=ve.get(he._element);ve.set(he._element,sHi(Pe??void 0,Qe))}return ve},[o]),j=ee.useMemo(()=>{const ve=[];for(const he of o){if(!he._element||Ghn(he))continue;const Qe=uHi(he);if(Qe.length!==0)for(const Pe of Qe)ve.push({anchor:Pe.anchor,point:Pe.point,element:he._element})}return ve},[o]),J=ee.useMemo(()=>{const ve=[];te.forEach((he,Qe)=>{if(!he)return;const Pe=(he.minX+he.maxX)/2,we=(he.minY+he.maxY)/2,Te={top_left:{x:he.minX,y:he.minY},top_center:{x:Pe,y:he.minY},top_right:{x:he.maxX,y:he.minY},center_left:{x:he.minX,y:we},center:{x:Pe,y:we},center_right:{x:he.maxX,y:we},bottom_left:{x:he.minX,y:he.maxY},bottom_center:{x:Pe,y:he.maxY},bottom_right:{x:he.maxX,y:he.maxY}};for(const[Re,Ee]of Object.entries(Te))ve.push({anchor:Re,point:Ee,element:Qe})});for(const he of j)ve.push(he);return ve.push({anchor:"origin",point:{x:0,y:0},element:null}),ve},[te,j]),oe=ee.useMemo(()=>J.map((ve,he)=>({...ve,id:`${he}-${ve.anchor}`,screenPoint:_i(e,ve.point)})),[J,e]),ie=ee.useCallback(ve=>{if(oe.length===0)return{point:ve,id:null};const he=_i(e,ve);let Qe=null;for(const Pe of oe){const we=Pe.screenPoint.x-he.x,Te=Pe.screenPoint.y-he.y,Re=Math.hypot(we,Te);Re>dHi||(!Qe||Re<Qe.distance)&&(Qe={distance:Re,id:Pe.id,point:Pe.point})}return Qe?{point:Qe.point,id:Qe.id}:{point:ve,id:null}},[oe,e]);ee.useEffect(()=>{const ve=Pe=>{const we=Pe.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;const Te=U.current?.contains(document.activeElement)||document.activeElement===U.current;if(!(!C&&!Te)){if(Pe.key==="d"){const Re=ie({x:F.current.x,y:F.current.y});B({x:Re.point.x,y:Re.point.y}),Q({x:Re.point.x,y:Re.point.y}),I({start:Re.id,end:Re.id}),s?(a(!1),c(!1),I({start:null,end:null})):(a(!0),c(!0)),y()}Pe.key==="Escape"&&(a(!1),c(!1),I({start:null,end:null}),p(!1),_(!1),y(),x())}},he=()=>{u(!0),h(!1),window.dispatchEvent(new Event("disarm-bounds-tool"))},Qe=()=>{h(!0),u(!1),a(!1),c(!1),window.dispatchEvent(new Event("disarm-dimension-tool"))};return window.addEventListener("keydown",ve),window.addEventListener("arm-dimension-tool",he),window.addEventListener("arm-bounds-tool",Qe),()=>{window.removeEventListener("keydown",ve),window.removeEventListener("arm-dimension-tool",he),window.removeEventListener("arm-bounds-tool",Qe),y(),x()}},[C,s,y,x,ie]);const ne=_i(e,E),le=_i(e,S),ge=_i(e,w),_e=_i(e,k),ue={minX:Math.min(w.x,k.x),minY:Math.min(w.y,k.y),maxX:Math.max(w.x,k.x),maxY:Math.max(w.y,k.y)},fe={left:Math.min(ge.x,_e.x),top:Math.min(ge.y,_e.y),width:Math.abs(ge.x-_e.x),height:Math.abs(ge.y-_e.y)},pe=ee.useCallback((ve,he)=>{const Qe={minX:Math.min(ve.x,he.x),minY:Math.min(ve.y,he.y),maxX:Math.max(ve.x,he.x),maxY:Math.max(ve.y,he.y)};i?.(Qe),window.dispatchEvent(new CustomEvent("pcb-viewer:bounds-selected",{detail:Qe}))},[i]),ye={left:Math.min(ne.x,le.x),right:Math.max(ne.x,le.x),top:Math.min(ne.y,le.y),bottom:Math.max(ne.y,le.y),flipX:ne.x>le.x,flipY:ne.y>le.y,width:0,height:0};ye.width=ye.right-ye.left,ye.height=ye.bottom-ye.top;const Me=cHi({dimensionStart:E,dimensionEnd:S,screenDimensionStart:ne,screenDimensionEnd:le,flipX:ye.flipX,flipY:ye.flipY});return K.jsxs("div",{ref:U,"data-pcb-viewer":!0,tabIndex:0,style:{position:"relative",outline:"none"},onMouseDownCapture:()=>{O.current=!1},onClickCapture:ve=>{O.current&&(O.current=!1,ve.stopPropagation(),U.current?.focus())},onContextMenuCapture:ve=>{!l&&!s&&!O.current||(ve.preventDefault(),ve.stopPropagation())},onMouseEnter:()=>{n&&U.current&&U.current.focus()},onMouseLeave:()=>{U.current&&U.current.blur()},onClick:()=>{U.current&&U.current.focus()},onMouseMove:ve=>{const he=ve.currentTarget.getBoundingClientRect(),Qe=ve.clientX-he.left,Pe=ve.clientY-he.top,we=_i(V6(e),{x:Qe,y:Pe});if(F.current.x=we.x,F.current.y=we.y,A){const Te=ie(we);Q({x:Te.point.x,y:Te.point.y}),I(Re=>({...Re,end:Te.id}))}m&&(r?.(),R({x:we.x,y:we.y}))},onMouseDown:ve=>{O.current=l||s;const he=ve.currentTarget.getBoundingClientRect(),Qe=ve.clientX-he.left,Pe=ve.clientY-he.top,we=_i(V6(e),{x:Qe,y:Pe});if(g)ve.preventDefault(),ve.stopPropagation(),r?.(),M({x:we.x,y:we.y}),R({x:we.x,y:we.y}),p(!0),_(!0),x();else if(l&&!s){const Te=ie(we);B({x:Te.point.x,y:Te.point.y}),Q({x:Te.point.x,y:Te.point.y}),I({start:Te.id,end:Te.id}),a(!0),c(!0),y()}else A?(c(!1),I(Te=>({...Te,end:null}))):s&&(a(!1),I({start:null,end:null}))},onMouseUp:ve=>{if(!m)return;const he=ve.currentTarget.getBoundingClientRect(),Qe=ve.clientX-he.left,Pe=ve.clientY-he.top,we=_i(V6(e),{x:Qe,y:Pe}),Te={x:we.x,y:we.y};ve.preventDefault(),ve.stopPropagation(),r?.(),R(Te),_(!1),pe(w,Te)},children:[t,d&&K.jsxs(K.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.dimensionOverlay},width:W.width,height:W.height,children:K.jsx("rect",{x:fe.left,y:fe.top,width:fe.width,height:fe.height,stroke:"red",strokeWidth:1.5,strokeDasharray:"4,3",fill:"rgba(255, 0, 0, 0.12)"})}),K.jsxs("div",{style:{left:0,bottom:s?58:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.dimensionOverlay},children:["minX: ",ue.minX.toFixed(2),", minY:"," ",ue.minY.toFixed(2),K.jsx("br",{}),"maxX: ",ue.maxX.toFixed(2),", maxY:"," ",ue.maxY.toFixed(2)]})]}),s&&K.jsxs(K.Fragment,{children:[Me.show&&K.jsx("div",{style:{position:"absolute",left:Me.x,top:Me.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:Ru.dimensionOverlay},children:Me.distance.toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:ye.left,width:ye.width,textAlign:"center",top:ne.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:ye.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:Ru.dimensionOverlay},children:Math.abs(E.x-S.x).toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:le.x,height:ye.height,display:"flex",flexDirection:"column",justifyContent:"center",top:ye.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:Ru.dimensionOverlay},children:K.jsx("div",{style:{marginLeft:ye.flipX?"-100%":4,paddingRight:4},children:Math.abs(E.y-S.y).toFixed(2)})}),K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.dimensionOverlay},width:W.width,height:W.height,children:[K.jsx("defs",{children:K.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:K.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),K.jsx("line",{x1:ne.x,y1:ne.y,x2:le.x,y2:le.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),K.jsx("line",{x1:ne.x,y1:ne.y,x2:le.x,y2:ne.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),K.jsx("line",{x1:le.x,y1:ne.y,x2:le.x,y2:le.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),A&&K.jsx(gHi,{points:oe,startId:f.start,endId:f.end}),K.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",E.x.toFixed(2),",",E.y.toFixed(2),")",K.jsx("br",{}),"(",S.x.toFixed(2),",",S.y.toFixed(2),")",K.jsx("br",{}),"dist:"," ",Math.sqrt((S.x-E.x)**2+(S.y-E.y)**2).toFixed(2)]})]})]})},_Hi=(t,e,n=0)=>{const o=t.width/2,i=t.height/2,r=t.center.x-o-n,s=t.center.x+o+n,a=t.center.y-i-n,A=t.center.y+i+n;return e.x>r&&e.x<s&&e.y>a&&e.y<A},fHi=({children:t,disabled:e,transform:n,soup:o,cancelPanDrag:i,onCreateEditEvent:r,onModifyEditEvent:s})=>{n||(n=RP());const a=ee.useRef(null),[A,c]=ee.useState(null),[l,u]=ee.useState(null),g=A!==null;Kc(m=>m.in_edit_mode);const h=Kc(m=>m.in_move_footprint_mode),d=Kc(m=>m.setIsMovingComponent),p=e||!h;return K.jsxs("div",{ref:a,style:{position:"relative",overflow:"hidden"},onMouseDown:m=>{if(p)return;const _=m.currentTarget.getBoundingClientRect(),f=m.clientX-_.left,I=m.clientY-_.top;if(Number.isNaN(f)||Number.isNaN(I))return;const C=_i(V6(n),{x:f,y:I});let y=!1;for(const x of o)if(x.type==="pcb_component"&&_Hi(x,C,10/n.a)){i(),c(x.pcb_component_id),y=!0;const E=Math.random().toString();u({dragStart:C,originalCenter:x.center,dragEnd:C,edit_event_id:E}),r({edit_event_id:E,edit_event_type:"edit_pcb_component_location",pcb_edit_event_type:"edit_component_location",pcb_component_id:x.pcb_component_id,original_center:x.center,new_center:x.center,in_progress:!0,created_at:Date.now()}),d(!0);break}if(y||c(null),y)return m.preventDefault(),!1},onMouseMove:m=>{if(!A||!l)return;const _=m.currentTarget.getBoundingClientRect(),f=m.clientX-_.left,I=m.clientY-_.top;if(Number.isNaN(f)||Number.isNaN(I))return;const C=_i(V6(n),{x:f,y:I});u({...l,dragEnd:C}),s({edit_event_id:l.edit_event_id,new_center:{x:l.originalCenter.x+C.x-l.dragStart.x,y:l.originalCenter.y+C.y-l.dragStart.y}})},onMouseUp:m=>{A&&(c(null),d(!1),l&&(s({edit_event_id:l.edit_event_id,in_progress:!1}),u(null)))},children:[t,!p&&o.filter(m=>m.type==="pcb_component").map(m=>{if(!m?.center)return null;const _=_i(n,m.center);return K.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:_.x,top:_.y,width:m.width*n.a+20,height:m.height*n.a+20,transform:"translate(-50%, -50%)",background:g&&A===m.pcb_component_id?"rgba(255, 0, 0, 0.2)":""}},m.pcb_component_id)})]})},y$e=(t,e)=>{const n=e.current;if(!n)return{transform:"translate(-50%, -100%)",left:t.x,top:t.y};const o=n.getBoundingClientRect(),i=200,r=10,s=60;let a="-50%",A="-100%",c=t.x,l=t.y;return t.x+s+i<o.width-r?(c=t.x+s,a="0%"):t.x-s-i>r?(c=t.x-s,a="-100%"):(c=t.x,a="-50%"),{transform:`translate(${a}, ${A})`,left:c,top:l}},IHi=({center:t})=>K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.errorOverlay+30},width:"100%",height:"100%",children:[K.jsx("circle",{cx:t.x,cy:t.y,r:11,fill:"none",stroke:"#ff6b6b",strokeWidth:2.5,opacity:.95}),K.jsx("circle",{cx:t.x,cy:t.y,r:4.5,fill:"#ff6b6b",opacity:.95}),K.jsx("line",{x1:t.x-18,y1:t.y,x2:t.x-8,y2:t.y,stroke:"#ff6b6b",strokeWidth:2}),K.jsx("line",{x1:t.x+8,y1:t.y,x2:t.x+18,y2:t.y,stroke:"#ff6b6b",strokeWidth:2}),K.jsx("line",{x1:t.x,y1:t.y-18,x2:t.x,y2:t.y-8,stroke:"#ff6b6b",strokeWidth:2}),K.jsx("line",{x1:t.x,y1:t.y+8,x2:t.x,y2:t.y+18,stroke:"#ff6b6b",strokeWidth:2})]}),Yhn=({errorCenter:t,isHighlighted:e=!1})=>K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.errorOverlay},width:"100%",height:"100%",children:K.jsx("rect",{x:t.x-7,y:t.y-7,width:14,height:14,transform:`rotate(45 ${t.x} ${t.y})`,fill:e?"#ff4444":"transparent",stroke:e?"#ff4444":"red",strokeWidth:e?2.5:1.5})}),x$e=kU`
  opacity: 0;
  pointer-events: none;
  background-color: rgba(0, 0, 0, 0.8);
  padding: 8px 12px;
  border-radius: 4px;
  width: 200px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  word-wrap: break-word;
  line-height: 1.4;
  transition: opacity 0.2s;
  margin-bottom: 10px;
  color: red;
`,CHi=({children:t,transform:e=RP(),elements:n})=>{const o=ee.useRef(null),{isShowingDRCErrors:i,hoveredErrorId:r,focusedErrorId:s}=Kc(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??r;if(!n)return K.jsx("div",{style:{position:"relative"},ref:o,children:t});const A=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),c=n.filter(p=>p.type==="pcb_via_clearance_error"),l=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),u=ohn(n),g=ahn(n,a),h=p=>{const m=bFi({error:p,indexes:u});if(!m||typeof m.x!="number"||typeof m.y!="number")return null;const _=_i(e,m);return Number.isNaN(_.x)||Number.isNaN(_.y)?null:_};let d=null;return g&&(d=h(g)),K.jsxs("div",{style:{position:"relative"},ref:o,children:[t,A.map((p,m)=>{const _=JU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=y$e(I,o);return K.jsxs(ee.Fragment,{children:[K.jsx(Yhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Ru.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?200:100,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||f?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${x$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),c.map((p,m)=>{const _=JU(p,m),f=a===_;if(!f&&!i)return null;const I=h(p);if(!I)return null;const C=y$e({x:I.x,y:I.y},o);return K.jsxs(ee.Fragment,{children:[K.jsx(Yhn,{errorCenter:I,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:I.x-15,top:I.y-15,width:30,height:30,zIndex:Ru.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:y=>{const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="1")}},onMouseLeave:y=>{if(!f){const x=y.currentTarget.nextElementSibling;if(x){const E=x.querySelector(".error-message");E&&(E.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?Ru.errorOverlay+10:Ru.errorOverlay+1,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${x$e}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:p.message})})]},_)}),l.map((p,m)=>{const _=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!_)return null;const f=n?.filter(y=>y.type==="source_component"&&y.name===_||y.type==="pcb_component"&&n?.find(x=>x.type==="source_component"&&x.source_component_id===y.source_component_id&&x.name===_))||[],I=JU(p,m),C=a===I;return!C&&!i?null:f.map((y,x)=>{let E={x:0,y:0};if(y.type==="pcb_component")E=y.center||{x:0,y:0};else if(y.type==="source_component"){const F=n?.find(O=>O.type==="pcb_component"&&O.source_component_id===y.source_component_id);F&&F.type==="pcb_component"&&(E=F.center||{x:0,y:0})}const B=_i(e,E);if(Number.isNaN(B.x)||Number.isNaN(B.y))return null;const S=Math.abs(e.a),k=Math.max(8,Math.min(30,.5*S)),R=y$e(B,o);return K.jsxs(ee.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:Ru.errorOverlay},width:"100%",height:"100%",children:C?K.jsx("polygon",{points:`${B.x},${B.y-k*1.25} ${B.x+k},${B.y} ${B.x},${B.y+k*1.25} ${B.x-k},${B.y}`,fill:"#ff4444"}):K.jsx("circle",{cx:B.x,cy:B.y,r:k,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,k*.15):Math.max(1,k*.1),opacity:1})}),K.jsx("div",{style:{position:"absolute",left:B.x-(k+10),top:B.y-(k+10),width:(k+10)*2,height:(k+10)*2,zIndex:Ru.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:F=>{const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:F=>{if(!C){const O=F.currentTarget.nextElementSibling;if(O){const U=O.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:C?Ru.errorOverlay+20:Ru.errorOverlay+10,left:R.left,top:R.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:R.transform},children:K.jsx("div",{className:`error-message ${x$e}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:p.message})})]},`${I}_${x}`)})}),d&&K.jsx(IHi,{center:d})]})};function yHi(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}var KP=t=>t?.type==="pcb_component",Uhn=t=>t?.type==="pcb_group",xHi=t=>t?.type==="pcb_panel",E$e=t=>t?.type==="pcb_board",Gg={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},TE={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},B$e=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const i={color:TE.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Gg.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},r=new Map;return t.forEach(s=>{if(!r.has(s.anchor_id)){const a=_i(e,s.anchor);r.set(s.anchor_id,a)}}),K.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:Ru.dimensionOverlay},children:K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,A=s.anchor_id,c=s.target,l=r.get(A),u=_i(e,c),g=c.x-a.x,h=c.y-a.y,d=Math.abs(u.x-l.x),p=Math.abs(u.y-l.y),m=u.y<l.y,_=u.x>l.x,f=m?Gg.LABEL_OFFSET_ABOVE:Gg.LABEL_OFFSET_BELOW,I=_?Gg.LABEL_OFFSET_RIGHT:Gg.LABEL_OFFSET_LEFT,C=d>Gg.MIN_LINE_LENGTH_FOR_LABEL,y=p>Gg.MIN_LINE_LENGTH_FOR_LABEL,x=`${s.display_offset_x??g.toFixed(2)}mm`,E=`${s.display_offset_y??h.toFixed(2)}mm`;return K.jsxs("g",{children:[K.jsx("line",{x1:l.x,y1:l.y,x2:u.x,y2:l.y,stroke:TE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),K.jsx("line",{x1:u.x,y1:l.y,x2:u.x,y2:u.y,stroke:TE.OFFSET_LINE,strokeWidth:Gg.LINE_STROKE_WIDTH,strokeDasharray:Gg.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?K.jsx("circle",{cx:u.x,cy:u.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:TE.COMPONENT_MARKER_FILL,stroke:TE.COMPONENT_MARKER_STROKE,strokeWidth:1}):K.jsxs(K.Fragment,{children:[K.jsx("line",{x1:u.x-Gg.ANCHOR_MARKER_SIZE,y1:u.y,x2:u.x+Gg.ANCHOR_MARKER_SIZE,y2:u.y,stroke:TE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:u.x,y1:u.y-Gg.ANCHOR_MARKER_SIZE,x2:u.x,y2:u.y+Gg.ANCHOR_MARKER_SIZE,stroke:TE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]}),C&&K.jsx("foreignObject",{x:Math.min(l.x,u.x),y:l.y+f,width:Math.abs(u.x-l.x),height:20,style:{overflow:"visible"},children:K.jsx("div",{style:{...i,textAlign:"center"},children:x})}),y&&K.jsx("foreignObject",{x:u.x+I,y:Math.min(l.y,u.y),width:Gg.Y_LABEL_MIN_WIDTH,height:Math.abs(u.y-l.y),style:{overflow:"visible"},children:K.jsx("div",{style:{...i,display:"flex",alignItems:"center",justifyContent:_?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:E})})]},s.id)}),Array.from(r.entries()).map(([s,a])=>K.jsxs("g",{children:[K.jsx("line",{x1:a.x-Gg.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Gg.ANCHOR_MARKER_SIZE,y2:a.y,stroke:TE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:a.x,y1:a.y-Gg.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Gg.ANCHOR_MARKER_SIZE,stroke:TE.OFFSET_LINE,strokeWidth:Gg.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},EHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>E$e(_)),s=t.filter(_=>KP(_)),a=t.filter(_=>Uhn(_)),A=e.map(_=>KP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:KP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),c=new Set;if(A.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f?.pcb_group_id&&c.add(f.pcb_group_id)}),!Kc(_=>_.is_showing_group_anchor_offsets)&&A.length===0)return null;const u=s.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{component:_,board:I,type:"component"}:null}).filter(_=>!!_),g=a.map(_=>{const f=_.positioned_relative_to_pcb_board_id;if(!f||!_.center)return null;const I=r.find(C=>C.pcb_board_id===f);return I?{group:_,board:I,type:"group"}:null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=A.length===0,p=h.filter(_=>_.type==="component"?d||A.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>_.type==="component"?{id:`${_.board.pcb_board_id}-${_.component.pcb_component_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:{id:`${_.board.pcb_board_id}-${_.group.pcb_group_id}-${_.type}`,anchor:_.board.center,anchor_id:_.board.pcb_board_id,target:{x:_.group.anchor_position?.x??_.group.center.x,y:_.group.anchor_position?.y??_.group.center.y},type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}).filter(_=>!!_);return K.jsx(B$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},BHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>Uhn(_)),s=t.filter(_=>KP(_)),a=e.map(_=>KP(_._parent_pcb_component)?_._parent_pcb_component.pcb_component_id:KP(_._element)?_._element.pcb_component_id:null).filter(_=>!!_),A=(_,f)=>{if(f.has(_))return;f.add(_);const I=r.find(C=>C.pcb_group_id===_);I?.position_mode==="relative_to_group_anchor"&&I.positioned_relative_to_pcb_group_id&&A(I.positioned_relative_to_pcb_group_id,f)},c=new Set;if(a.forEach(_=>{const f=s.find(I=>I.pcb_component_id===_);f&&(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&A(f.positioned_relative_to_pcb_group_id,c),f.pcb_group_id&&A(f.pcb_group_id,c))}),!Kc(_=>_.is_showing_group_anchor_offsets)&&a.length===0)return null;const u=s.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}if(_.pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.pcb_group_id);return f&&f.anchor_position?{component:_,parentGroup:f,type:"component"}:null}return null}).filter(_=>!!_),g=r.map(_=>{if(_.position_mode==="relative_to_group_anchor"&&_.positioned_relative_to_pcb_group_id){const f=r.find(I=>I.pcb_group_id===_.positioned_relative_to_pcb_group_id);if(f&&f.anchor_position&&_.anchor_position)return{group:_,parentGroup:f,type:"group"}}return null}).filter(_=>!!_),h=[...u,...g];if(h.length===0)return null;const d=a.length===0,p=h.filter(_=>_.type==="component"?d||a.includes(_.component.pcb_component_id):d||c.has(_.group.pcb_group_id)||c.has(_.parentGroup.pcb_group_id));if(p.length===0)return null;const m=p.map(_=>{const f=_.parentGroup.anchor_position;return f?_.type==="component"?_.component.center?{id:`${_.parentGroup.pcb_group_id}-${_.component.pcb_component_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.component.center,type:"component",display_offset_x:_.component.display_offset_x,display_offset_y:_.component.display_offset_y}:null:_.group.anchor_position?{id:`${_.parentGroup.pcb_group_id}-${_.group.pcb_group_id}-${_.type}`,anchor:f,anchor_id:_.parentGroup.pcb_group_id,target:_.group.anchor_position,type:"group",display_offset_x:_.group.display_offset_x,display_offset_y:_.group.display_offset_y}:null:null}).filter(_=>!!_);return K.jsx(B$e,{targets:m,transform:n,containerWidth:o,containerHeight:i})},bHi=(t,e)=>{const n=t.pcb_component_id,o=e.filter(i=>(i.type==="pcb_smtpad"||i.type==="pcb_plated_hole")&&i.pcb_component_id===n||i.type==="pcb_hole"&&i.pcb_component_id===n);return o.length===0?_$e([t]):_$e(o)},SHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=new Map;for(const a of e)KP(a._parent_pcb_component)&&r.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),KP(a._element)&&r.set(a._element.pcb_component_id,a._element);if(r.size===0)return null;const s=[];for(const a of r.values()){const A=bHi(a,t);if(!A)continue;const c=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,l=c?wS(t).pcb_group.get(c):null;s.push({component:a,bbox:A,group:l})}return s.length===0?null:K.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:i,overflow:"hidden",pointerEvents:"none",zIndex:Ru.dimensionOverlay},children:K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:i,children:s.map(({component:a,bbox:A,group:c})=>{const l=_i(n,{x:A.minX,y:A.maxY}),u=_i(n,{x:A.maxX,y:A.minY}),g={x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),width:Math.abs(u.x-l.x),height:Math.abs(u.y-l.y)},h=a.center??{x:(A.minX+A.maxX)/2,y:(A.minY+A.maxY)/2},d=_i(n,h);return K.jsxs("g",{children:[K.jsx("rect",{x:g.x,y:g.y,width:g.width,height:g.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),K.jsx("line",{x1:d.x-6,y1:d.y,x2:d.x+6,y2:d.y,stroke:TE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("line",{x1:d.x,y1:d.y-6,x2:d.x,y2:d.y+6,stroke:TE.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("circle",{cx:d.x,cy:d.y,r:Gg.COMPONENT_MARKER_RADIUS,fill:TE.COMPONENT_MARKER_FILL,stroke:TE.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},QHi=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(h=>xHi(h)),s=t.filter(h=>E$e(h)),a=e.map(h=>E$e(h._element)?h._element.pcb_board_id:null).filter(h=>!!h);if(!Kc(h=>h.is_showing_group_anchor_offsets)&&a.length===0)return null;const c=s.map(h=>{const d=h.pcb_panel_id,p=h.position_mode;if(!d||p!=="relative_to_panel_anchor")return null;const m=r.find(_=>_.pcb_panel_id===d);return m?{board:h,panel:m,type:"board"}:null}).filter(h=>!!h);if(c.length===0)return null;const l=a.length===0,u=c.filter(h=>l||a.includes(h.board.pcb_board_id));if(u.length===0)return null;const g=u.map(h=>h.board.center?{id:`${h.panel.pcb_panel_id}-${h.board.pcb_board_id}-${h.type}`,anchor:h.panel.center,anchor_id:h.panel.pcb_panel_id,target:h.board.center,type:"board",display_offset_x:h.board.display_offset_x,display_offset_y:h.board.display_offset_y}:null).filter(h=>!!h);return K.jsx(B$e,{targets:g,transform:n,containerWidth:o,containerHeight:i})};function vHi(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,i=e.filter(A=>A._element.type==="pcb_trace"),r=o.filter(A=>A.type==="source_trace"),s=e.filter(A=>A._element.type!=="pcb_trace"),a=i.filter(A=>r.some(l=>A._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0)||I$e({primitiveElement:A._element,elements:o})!==null);if(!n)return[...s,...a];if(i.length>1){const A=i.reduce((c,l)=>{const u=c._element.trace_length;return l._element.trace_length<u?l:c},i[0]);return[...s,A]}return e}var wHi={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},PHi=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:i}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const r=[],s=Array.from(new Set((e.port_hints??[]).concat(i?.port_hints??[]))).filter(A=>!/^[0-9]+$/.test(A)).filter(A=>!A.includes("unnamed_")).sort((A,c)=>c.localeCompare(A)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?r.push(...s.map(A=>`${a}.${A}`)):r.push(...s):a&&r.push(a),r.join(", ")}default:return""}},MHi={top:"red",bottom:"aqua"},DHi=({primitive:t,mousePos:e,elements:n})=>{const[o,i]=ee.useState(!1),r=t._element;ee.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);const[s,a,A,c]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],l=t.same_space_index??0,u=26,g=MHi[t?._element?.layer]??"red";let h=0;if(r.type==="pcb_smtpad"&&r?.shape==="rotated_rect"?h=r?.ccw_rotation??0:(r.type==="pcb_smtpad"&&(r?.shape==="pill"||r?.shape==="rotated_pill")&&"ccw_rotation"in t||r.type==="pcb_plated_hole"&&(r?.shape==="pill"||r?.shape==="oval")&&"ccw_rotation"in t)&&(h=r.ccw_rotation??0),r.type==="pcb_trace"){const m=chn({primitiveElement:r,elements:n});return m?K.jsx("div",{style:{zIndex:Ru.elementOverlay,position:"absolute",left:e.x+12,top:e.y+12,color:g,pointerEvents:"none"},children:K.jsxs("div",{style:{backgroundColor:"#f2efcc",color:m.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"4px 6px",borderRadius:"4px",fontSize:"11px",lineHeight:1.2,textAlign:"left",whiteSpace:"nowrap"},children:[m.text&&K.jsx("div",{children:m.text}),m.name&&K.jsx("div",{style:{marginTop:m.text?"2px":0},children:m.name})]})}):null}const d=PHi(t);return d.trim().length===0?null:K.jsx("div",{style:{zIndex:Ru.elementOverlay,position:"absolute",left:s-A/2-8,top:a-c/2-8,width:A+16,height:c+16,color:g,transform:`rotate(${-h}deg)`,transformOrigin:"center center"},children:K.jsx("div",{style:{width:o?`calc(100% + ${u*2*l}px)`:"100%",height:o?`calc(100% + ${u*2*l}px)`:"100%",marginLeft:o?`${-u*l}px`:0,marginTop:o?`${-u*l}px`:0,border:`1px solid ${g}`,opacity:o||l===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:K.jsx("div",{style:{position:"absolute",bottom:c+20+u*l,marginRight:o?`${-u*l}px`:0,marginBottom:o?0:-u*l,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(${h}deg)`,minWidth:"45px",textAlign:"center"},children:d})})})},NHi=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,i]=Kc(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),r=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return r&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=vHi({primitives:s,is_showing_multiple_traces_length:i,elements:n}),K.jsx("div",{style:wHi,children:!o&&s.map(a=>K.jsx(DHi,{primitive:a,mousePos:e,elements:n},a._pcb_drawing_object_id))})},gfe=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,i=t[0].y;for(const r of t)r.x<e&&(e=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y);return{center:{x:(e+o)/2,y:(n+i)/2},width:o-e,height:i-n}},Khn=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o].x,s=e[o].y,a=e[i].x,A=e[i].y;s>t.y!=A>t.y&&t.x<(a-r)*(t.y-s)/(A-s||Number.EPSILON)+r&&(n=!n)}return n},b$e=(t,e,n,o,i=!1)=>{const r=[];for(const s of t){if(!s._element||!i&&s._element.type==="pcb_trace"&&s.layer!==o)continue;if("x1"in s&&s._element?.type==="pcb_trace"){const c=Zd({x:e.x,y:e.y},{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}),l=s.width||.5,u=Math.max(l*25,2)/n.a;c<u&&r.push(s);continue}if(s.pcb_drawing_type==="polygon"){const c=s.points.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=gfe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;Khn(e,c)&&r.push(s);continue}if(s.pcb_drawing_type==="polygon_with_arcs"){const c=s.brep_shape.outer_ring.vertices.map(u=>({x:lt.parse(u.x),y:lt.parse(u.y)})),l=gfe(c);if(!l||e.x<l.center.x-l.width/2||e.x>l.center.x+l.width/2||e.y<l.center.y-l.height/2||e.y>l.center.y+l.height/2)continue;Khn(e,c)&&r.push(s);continue}if(!("x"in s&&"y"in s))continue;let a=0,A=0;if("w"in s&&"h"in s)a=s.w,A=s.h;else if("r"in s)a=s.r*2,A=s.r*2;else if("rX"in s&&"rY"in s)a=s.rX*2,A=s.rY*2;else continue;Math.abs(s.x-e.x)<a/2&&Math.abs(s.y-e.y)<A/2&&r.push(s)}return r},RHi=({elements:t,children:e,transform:n,primitives:o,selectedLayer:i,onMouseHoverOverPrimitives:r})=>{const[s,a]=ee.useState([]),[A,c]=ee.useState({x:0,y:0}),[l,{width:u,height:g}]=uee();ee.useEffect(()=>{a([]),r([])},[i,o,r]);const h=ee.useMemo(()=>{const p=[];for(const m of s){if(m._element?.type==="pcb_via"||m._element?.type==="pcb_component"||m?.layer==="drill"||m?.is_hoverable===!1)continue;let _=null,f=0,I=0;if(m.pcb_drawing_type==="polygon"){const E=gfe(m.points);if(!E)continue;_=E.center,f=E.width,I=E.height}else if(m.pcb_drawing_type==="polygon_with_arcs"){const E=m.brep_shape.outer_ring.vertices.map(S=>({x:S.x,y:S.y})),B=gfe(E);if(!B)continue;_=B.center,f=B.width,I=B.height}else m.pcb_drawing_type==="line"?(_={x:(m.x1+m.x2)/2,y:(m.y1+m.y2)/2},f=Math.abs(m.x2-m.x1),I=Math.abs(m.y2-m.y1)):"x"in m&&"y"in m&&(_={x:m.x,y:m.y},f="w"in m?m.w:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rX*2:0,I="h"in m?m.h:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rY*2:0);if(!_)continue;const C=_i(n,_),y={w:f*n.a,h:I*n.a},x=p.filter(E=>C.x===E.screen_x&&C.y===E.screen_y&&y.w===E.screen_w&&y.h===E.screen_h).length;p.push({...m,x:_.x,y:_.y,w:f,h:I,screen_x:C.x,screen_y:C.y,screen_w:y.w,screen_h:y.h,same_space_index:x})}return p},[s,n]),d=(p,m,_,f)=>{c({x:p,y:m});const I=_i(V6(_),{x:p,y:m}),C=b$e(f,I,_,i);yHi(new Set(C.map(y=>y._pcb_drawing_object_id)),new Set(s.map(y=>y._pcb_drawing_object_id)))||(a(C),r(C))};return K.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:p=>{if(n){const m=p.currentTarget.getBoundingClientRect(),_=p.clientX-m.left,f=p.clientY-m.top;d(_,f,n,o)}},onTouchStart:p=>{if(n){const m=p.touches[0],_=p.currentTarget.getBoundingClientRect(),f=m.clientX-_.left,I=m.clientY-_.top;d(f,I,n,o)}},children:[e,K.jsx(NHi,{elements:t,mousePos:A,highlightedPrimitives:h}),n&&K.jsxs(K.Fragment,{children:[K.jsx(EHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(BHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(SHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g}),K.jsx(QHi,{elements:t,highlightedPrimitives:h,transform:n,containerWidth:u,containerHeight:g})]})]})},Vhn=["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)"],THi=({children:t,transform:e=RP(),elements:n=[],hoveredComponentIds:o=[]})=>{const[i,{width:r,height:s}]=uee(),a=ee.useRef(null),{is_showing_pcb_groups:A,pcb_group_view_mode:c,is_showing_group_anchor_offsets:l}=Kc(u=>({is_showing_pcb_groups:u.is_showing_pcb_groups,pcb_group_view_mode:u.pcb_group_view_mode,is_showing_group_anchor_offsets:u.is_showing_group_anchor_offsets}));return ee.useEffect(()=>{const u=a.current;if(!u||!r||!s)return;u.width=r,u.height=s;const g=u.getContext("2d");if(!g||(g.clearRect(0,0,r,s),!A))return;const h=n.filter(x=>x.type==="pcb_group"),d=n.filter(x=>x.type==="pcb_component"),p=n.filter(x=>x.type==="source_group"),m=new Map(p.map(x=>[x.source_group_id,x])),_=h.filter(x=>{if(x.name?.toLowerCase().includes("subpanel"))return!1;if(c==="all")return!0;if(!x.source_group_id)return!1;const E=m.get(x.source_group_id);return E?E.was_automatically_named!==!0:!1}),f=new Map;p.forEach(x=>{const E=x;if(E.parent_source_group_id){const B=f.get(E.parent_source_group_id)||[];B.push(x.source_group_id),f.set(E.parent_source_group_id,B)}});const I=x=>{const E=[],B=f.get(x)||[];for(const S of B)E.push(S),E.push(...I(S));return E},C=x=>{const E=p.find(B=>B.source_group_id===x);return E?.parent_source_group_id?1+C(E.parent_source_group_id):0},y=new Set;if(o.length>0)for(const x of d){if(!o.includes(x.pcb_component_id))continue;const E=x.positioned_relative_to_pcb_group_id??x.pcb_group_id;E&&y.add(E)}_.forEach((x,E)=>{let B=d.filter(we=>we.pcb_group_id===x.pcb_group_id);if(x.source_group_id){const we=I(x.source_group_id),Te=h.filter(Re=>Re.source_group_id&&we.includes(Re.source_group_id));for(const Re of Te){const Ee=d.filter(ke=>ke.pcb_group_id===Re.pcb_group_id);B=[...B,...Ee]}}let S,Q,w,M,k=!1;if(x.center&&x.width&&x.height){k=!0;const we=x.width/2,Te=x.height/2;S=x.center.x-we,w=x.center.x+we,Q=x.center.y-Te,M=x.center.y+Te}else if(B.length===0||(S=1/0,Q=1/0,w=-1/0,M=-1/0,B.forEach(we=>{if(we.center&&typeof we.width=="number"&&typeof we.height=="number"){const Te=we.center.x-we.width/2,Re=we.center.x+we.width/2,Ee=we.center.y+we.height/2,ke=we.center.y-we.height/2;S=Math.min(S,Te),w=Math.max(w,Re),Q=Math.min(Q,ke),M=Math.max(M,Ee)}}),S===1/0||w===-1/0))return;const R=x.source_group_id?C(x.source_group_id):0,F=x.source_group_id?I(x.source_group_id).length>0:!1;if(!k){const Re=1+(F?.5:0);S-=Re,w+=Re,Q-=Re,M+=Re}const O=_i(e,{x:S,y:M}),U=_i(e,{x:w,y:M}),Y=_i(e,{x:S,y:Q}),W=_i(e,{x:w,y:Q}),te=Vhn[E%Vhn.length];g.strokeStyle=te,g.lineWidth=2;const j=Math.max(4,Math.min(12,8*Math.abs(e.a))),J=Math.max(2,Math.min(6,4*Math.abs(e.a))),ie=j*(F?1.3:1),ne=J;g.setLineDash([ie,ne]),g.beginPath(),g.moveTo(O.x,O.y),g.lineTo(U.x,U.y),g.lineTo(W.x,W.y),g.lineTo(Y.x,Y.y),g.closePath(),g.stroke();const le=Math.max(8,Math.min(12,10*Math.abs(e.a))),ge=R==0||R==1?0:R*.11,_e=le*(1-ge),ue=4,fe=x.name||`Group ${E+1}`;g.font=`${_e}px sans-serif`,g.setLineDash([]);const ye=g.measureText(fe).width+ue*2,Me=_e+ue*2,ve=O.x-5,he=O.y-5,Qe=3;if(g.fillStyle="rgba(0, 0, 0, 0.8)",g.beginPath(),g.roundRect(ve,he-Me,ye,Me,Qe),g.fill(),g.fillStyle=te,g.textAlign="left",g.textBaseline="middle",g.fillText(fe,ve+ue,he-Me/2),l&&y.has(x.pcb_group_id)&&!!x.anchor_position&&x.anchor_position){const we=Array.isArray(x.anchor_position)?{x:x.anchor_position[0]??0,y:x.anchor_position[1]??0}:{x:x.anchor_position.x,y:x.anchor_position.y},Te=_i(e,we);g.strokeStyle="white",g.lineWidth=1.5,g.setLineDash([]);const Re=Math.max(4,Math.min(8,6*Math.abs(e.a)));g.beginPath(),g.moveTo(Te.x-Re,Te.y),g.lineTo(Te.x+Re,Te.y),g.stroke(),g.beginPath(),g.moveTo(Te.x,Te.y-Re),g.lineTo(Te.x,Te.y+Re),g.stroke()}})},[n,e,r,s,A,c,l,o]),K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Ru.pcbGroupOverlay,display:A?"block":"none"}})]})},kHi=({transform:t,soup:e,children:n})=>{const o=Kc(a=>a.is_showing_rats_nest),{netMap:i,idToNetMap:r}=ee.useMemo(()=>nhn(e||[]),[e]),s=ee.useMemo(()=>{if(!e||!o)return[];const a=g=>{const h=wS(e)[g.replace(/_\d+$/,"")].get(g);return h&&"x"in h&&"y"in h?{x:h.x,y:h.y}:null},A=(g,h)=>{const d=i[h]||[];let p=null,m=1/0;return d.forEach(_=>{const f=a(_);if(f){const I=Math.sqrt((g.x-f.x)**2+(g.y-f.y)**2);I<m&&I>0&&(m=I,p=f)}}),p},c=wS(e).pcb_port.list(),l=wS(e).source_trace.list(),u=[];return c.forEach((g,h)=>{const d=r[g.pcb_port_id];let p=!1;for(const f of l)f.connected_source_port_ids.includes(g.source_port_id)&&f.connected_source_net_ids.length>0&&(p=!0);if(!d)return;const m={x:g.x,y:g.y},_=A(m,d);_&&u.push({key:`${g.pcb_port_id}-${h}`,startPoint:m,endPoint:_,isInNet:p})}),u},[e,i,r,o]);return!e||!o?n:(t||(t=RP()),K.jsxs("div",{style:{position:"relative"},children:[n,K.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:Ru.ratsNestOverlay},children:s.map(({key:a,startPoint:A,endPoint:c,isInNet:l})=>{const u=_i(t,A),g=_i(t,c);return K.jsx("line",{x1:u.x,y1:u.y,x2:g.x,y2:g.y,stroke:"white",strokeWidth:"1",strokeDasharray:l?"6,6":void 0},a)})})]}))},FHi={version:"1.11.414"},Z6=(t,e,n)=>{const o=Kc(s=>s.is_mouse_over_container),i=ee.useRef(o),r=ee.useRef(e);ee.useEffect(()=>{i.current=o},[o]),ee.useEffect(()=>{r.current=e},[e]),ee.useEffect(()=>{if(!t)return;const s=a=>{const A=a.target;if(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.isContentEditable)return;const c=t.split("+"),l=c.includes("ctrl"),u=c.includes("shift"),g=c.includes("alt"),h=c.includes("meta"),d=c[c.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(i.current||p)&&(!l||a.ctrlKey)&&(!u||a.shiftKey)&&(!g||a.altKey)&&(!h||a.metaKey)&&a.key.toLowerCase()===d.toLowerCase()&&(a.preventDefault(),r.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},LHi=()=>{const[t,e]=ee.useState(!1);return ee.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},pee=(t,e={stopPropagation:!0})=>{const n=ee.useRef(0),o=ee.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),i=ee.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:i,style:{touchAction:"manipulation"}}},dfe=kU`
  background: #222;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px;
  font: 12px sans-serif;
  box-shadow: 0 4px 16px #0008;
`,e8=kU`
  display: block;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  &:hover, &:focus-visible { background: #444; }
`,HHi=({component:t,onViewSchematicComponent:e,position:n,onClose:o,onXRayNet:i,xRayGroups:r=[],onXRayGroup:s,xRayDisplayName:a="Net",onExitXRayNet:A})=>{const c=eTi(),[l,u]=ee.useState(!1),g=Kc(x=>x.hidden_layer_opacity),h=Kc(x=>x.setHiddenLayerOpacity),[d,p]=ee.useState(!1),[m,_]=ee.useState(!1),f=ee.useRef(null),I=window.innerWidth<480,C=!I&&n.x+460>window.innerWidth,y=I?{position:"relative"}:{position:"absolute",top:0,...C?{right:"100%"}:{left:"100%"}};return ee.useEffect(()=>{const x=B=>{f.current?.contains(B.target)||(B.preventDefault(),o())},E=B=>{B.key==="Escape"&&(B.preventDefault(),o())};return f.current?.querySelector("button")?.focus(),window.addEventListener("pointerdown",x,!0),window.addEventListener("keydown",E),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("pointerdown",x,!0),window.removeEventListener("keydown",E),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)}},[o]),c6.createPortal(K.jsxs("div",{ref:f,role:"menu","aria-label":"PCB context menu",className:dfe,onContextMenu:x=>{x.preventDefault(),x.stopPropagation()},onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>x.stopPropagation(),onKeyDown:x=>{x.stopPropagation();const E=x.target.closest("button");if(!E)return;const B=E.closest('[role="menu"]'),S=Array.from(B.querySelectorAll("button:not(:disabled)")).filter(Q=>Q.closest('[role="menu"]')===B);if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const Q=x.key==="ArrowDown"?1:-1;S[(S.indexOf(E)+Q+S.length)%S.length]?.focus()}else x.key==="ArrowRight"&&E.hasAttribute("aria-haspopup")?(x.preventDefault(),E.click(),requestAnimationFrame(()=>E.parentElement?.querySelector('[role="menu"] button')?.focus())):x.key==="ArrowLeft"?(x.preventDefault(),B.parentElement?.querySelector(":scope > button")?.focus(),B.getAttribute("aria-label")==="Hidden Layer Visibility"?_(!1):B.getAttribute("aria-label")==="Visibility"?p(!1):B.getAttribute("aria-label")==="Rendering Engine"&&u(!1)):x.key==="Escape"&&(x.preventDefault(),o())},style:{position:"fixed",zIndex:1e4,left:Math.max(C?310:4,Math.min(n.x,window.innerWidth-(I?248:168))),top:Math.max(4,Math.min(n.y,window.innerHeight-(I?340:260))),width:I?230:150,maxHeight:window.innerHeight-8,...I?{overflowY:"auto"}:{}},children:[i&&K.jsxs("button",{type:"button",role:"menuitem",className:e8,style:{whiteSpace:"normal",overflowWrap:"anywhere"},onClick:()=>{i(),o()},children:["X-Ray ",a]}),s&&r.map(x=>K.jsxs("button",{type:"button",role:"menuitem",className:e8,style:{whiteSpace:"normal",overflowWrap:"anywhere"},onClick:()=>{s(x),o()},children:["X-Ray ",x.name]},x.id)),A&&K.jsx("button",{type:"button",role:"menuitem",className:e8,onClick:()=>{A(),o()},children:"Exit X-Ray Net"}),K.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{p(!0),u(!1)},children:[K.jsx("button",{type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":d,className:e8,onClick:()=>{p(!0),u(!1)},children:"Visibility ▸"}),d&&K.jsx("div",{role:"menu","aria-label":"Visibility",className:dfe,style:y,children:K.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>_(!0),children:[K.jsx("button",{type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":m,className:e8,onClick:()=>_(!0),children:"Hidden Layer Visibility ▸"}),m&&K.jsx("div",{role:"menu","aria-label":"Hidden Layer Visibility",className:dfe,style:{minWidth:80,...y},children:[0,.05,.1,.2,.4,.6,.8,1].map(x=>K.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":g===x,className:e8,onClick:()=>{h(x),o()},children:[K.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:16},children:g===x?"✓":""}),x===0?"Hide":`${x*100}%`]},x))})]})})]}),c&&K.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{u(!0),p(!1)},children:[K.jsx("button",{type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":l,className:e8,onClick:()=>{u(!0),p(!1)},children:"Rendering Engine ▸"}),l&&K.jsx("div",{role:"menu","aria-label":"Rendering Engine",className:dfe,style:y,children:["canvas","webgpu"].map(x=>K.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":c.renderer===x,className:e8,onClick:()=>{c.setRenderer(x),o()},children:[K.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:16},children:c.renderer===x?"✓":""}),x==="canvas"?"Canvas":"WebGPU (experimental)"]},x))})]}),t&&e&&K.jsxs("button",{type:"button",role:"menuitem",className:e8,style:{whiteSpace:"normal",overflowWrap:"anywhere"},onClick:()=>{o(),e({source_component_id:t.source_component_id,pcb_component_id:t.pcb_component_id,refdes:t.refdes})},children:[K.jsx("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{verticalAlign:"-1px",marginRight:5},children:K.jsx("path",{d:"M5 11 11 5M5 5h6v6"})}),t.refdes," on Schematic"]}),t?.manufacturer_part_number&&K.jsxs("button",{type:"button",role:"menuitem",disabled:!0,"aria-label":`Manufacturer part number: ${t.manufacturer_part_number}`,className:e8,style:{marginTop:4,background:"#292929",color:"#aaa",cursor:"default",whiteSpace:"normal",overflowWrap:"anywhere"},children:["MPN: ",t.manufacturer_part_number]})]}),document.body)},WU=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:i,...r}=pee(n);return K.jsx("div",{...o,...r,style:{backgroundColor:"#1F1F1F",border:"1px solid #666",margin:0,padding:4,paddingLeft:e?8:6,paddingRight:e?8:6,borderRadius:2,color:"#eee",cursor:"pointer",fontSize:12,height:"fit-content",userSelect:"none",whiteSpace:"nowrap",...i,...o.style},children:t})},OHi=t=>{const e=new Map;return t.forEach((n,o)=>{const i=n.error_type||"unknown_error",r=e.get(i)||[];r.push({error:n,index:o,errorId:JU(n,o)}),e.set(i,r)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},GHi=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const i=ee.useRef(null),r=ee.useRef(null),s=ee.useRef(null),a=ee.useCallback(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),r.current!==null&&(window.cancelAnimationFrame(r.current),r.current=null)},[]);ee.useEffect(()=>a,[a]);const A=ee.useCallback(l=>{a(),s.current=l,e(l),n(null),r.current=window.requestAnimationFrame(()=>{n(l),r.current=null}),t(),i.current=window.setTimeout(()=>{s.current=null,e(null),n(null),i.current=null},o)},[a,o,t,n,e]),c=ee.useCallback(l=>s.current===l,[]);return{handleErrorSelect:A,isSelectedError:c}},YHi=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:i,...r}=pee(()=>o(e,t));return K.jsx("button",{type:"button","aria-label":n===t?"Error message copied":"Copy error message",style:{position:"absolute",top:12,right:16,cursor:"pointer",color:"#888",fontSize:16,background:"none",border:"none",padding:0,display:"flex",alignItems:"center",...i},...r,children:n===t?K.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):K.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:K.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})})},UHi=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:i,setHoveredErrorId:r,setFocusedErrorId:s})=>{const[a,A]=ee.useState(null),[c,l]=ee.useState(new Set),[u,g]=ee.useState(new Set),[,h]=oFi(),{handleErrorSelect:d,isSelectedError:p}=GHi({onClose:i,setHoveredErrorId:r,setFocusedErrorId:s}),m=ee.useMemo(()=>t?.filter(y=>y.type.includes("error"))??[],[t]),_=m.length,f=ee.useMemo(()=>OHi(m),[m]),I=ee.useCallback(y=>{l(x=>{const E=new Set(x);return E.has(y)?E.delete(y):E.add(y),E})},[]),C=ee.useCallback(y=>{g(x=>{const E=new Set(x);return E.has(y)?E.delete(y):E.add(y),E})},[]);return K.jsxs("div",{style:{position:"relative"},children:[K.jsx(WU,{isSmallScreen:n,style:_>0?{color:"red"}:void 0,onClick:o,children:K.jsxs("div",{children:[_," errors"]})}),e&&_>0&&K.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"#2a2a2a",border:"1px solid #666",borderRadius:4,marginTop:4,zIndex:1e3,minWidth:n?"280px":"400px",maxWidth:n?"90vw":"600px",maxHeight:"400px",overflow:"auto",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)"},children:f.map(({errorType:y,errors:x},E)=>{const B=c.has(y);return K.jsxs("div",{style:{borderBottom:E<f.length-1?"1px solid #444":"none"},children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",cursor:"pointer",backgroundColor:"#232323",transition:"background-color 0.2s ease",touchAction:"manipulation",position:"sticky",top:0,zIndex:1},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#303030"},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#232323"},onTouchStart:S=>{S.stopPropagation(),S.currentTarget.style.backgroundColor="#303030"},onTouchEnd:S=>{S.stopPropagation(),S.preventDefault(),S.currentTarget.style.backgroundColor="#232323",I(y)},onClick:S=>{S.stopPropagation(),I(y)},children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[K.jsx("div",{style:{color:"#888",fontSize:"16px",transform:B?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),K.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:y})]}),K.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:x.length})]}),!B&&x.map(({error:S,index:Q,errorId:w})=>{const M=u.has(w),k=S.message??"No error message";return K.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 24px",cursor:"pointer",backgroundColor:"#2a2a2a",transition:"background-color 0.2s ease",touchAction:"manipulation"},onMouseEnter:R=>{R.currentTarget.style.backgroundColor="#333",r(w)},onMouseLeave:R=>{R.currentTarget.style.backgroundColor="#2a2a2a",p(w)||r(null)},onTouchStart:R=>{R.stopPropagation(),R.currentTarget.style.backgroundColor="#333",r(w)},onTouchEnd:R=>{R.stopPropagation(),R.preventDefault(),R.currentTarget.style.backgroundColor="#2a2a2a",d(w)},onClick:R=>{R.stopPropagation(),d(w)},children:[K.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:k}),K.jsx("button",{type:"button","aria-label":M?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:M?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),C(w)},onTouchEnd:R=>{R.stopPropagation(),R.preventDefault(),C(w)},children:"›"})]}),M&&K.jsxs("div",{"data-error-id":Q,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[K.jsx("div",{style:{fontSize:n?"11px":"12px",color:"#ccc",lineHeight:1.5,wordWrap:"break-word",overflowWrap:"break-word",hyphens:"auto",userSelect:"text",paddingRight:30},onMouseDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:k}),K.jsx(YHi,{errorId:w,errorMessage:k,copiedErrorId:a,onCopy:(R,F)=>{h(R),A(F),setTimeout(()=>A(null),2e3)}})]})]},w)})]},y)})})]})},KHi=({name:t,selected:e,onClick:n})=>{const{style:o,...i}=pee(n);return K.jsxs("div",{className:kU`
        margin-top: 2px;
        padding: 4px;
        padding-left: 8px;
        padding-right: 18px;
        cursor: pointer;

        &:hover {
          background-color: rgba(255, 255, 255, 0.1);
        }
      `,...i,style:o,children:[K.jsx("span",{style:{marginRight:2,opacity:e?1:0},children:"•"}),K.jsx("span",{style:{marginLeft:2,fontWeight:500,color:dee[t.replace(/-/,"")]},children:t})]})},C4=({label:t,checked:e,onClick:n})=>{const{style:o,...i}=pee(n);return K.jsxs("div",{className:kU`
        margin-top: 2px;
        padding: 4px;
        padding-left: 8px;
        padding-right: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;

        &:hover {
          background-color: rgba(255, 255, 255, 0.1);
        }
      `,...i,style:o,children:[K.jsx("input",{type:"checkbox",checked:e,onChange:()=>{},readOnly:!0}),K.jsx("span",{style:{color:"#eee"},children:t})]})},zhn=({label:t,checked:e,onClick:n})=>{const{style:o,...i}=pee(n);return K.jsxs("div",{className:kU`
        margin-top: 2px;
        padding: 4px;
        padding-left: 8px;
        padding-right: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;

        &:hover {
          background-color: rgba(255, 255, 255, 0.1);
        }
      `,...i,style:o,children:[K.jsx("input",{type:"radio",checked:e,onChange:()=>{},readOnly:!0}),K.jsx("span",{style:{color:"#eee"},children:t})]})},VHi=({children:t,elements:e,onContextMenuOpenChange:n,getNetAtPoint:o,getComponentAtPoint:i,onViewSchematicComponent:r,xRayNetIds:s=[],onXRayNetsChange:a})=>{const A=LHi(),{isMouseOverContainer:c,setIsMouseOverContainer:l,selectedLayer:u,selectLayer:g,viewSettings:h,setIsShowingRatsNest:d,setIsShowingMultipleTracesLength:p,setIsShowingAutorouting:m,setIsShowingDrcErrors:_,setIsShowingDrcWarnings:f,setIsShowingCopperPours:I,setIsShowingCourtyards:C,setIsShowingPcbGroups:y,setIsShowingGroupAnchorOffsets:x,setIsShowingSolderMask:E,setIsShowingSilkscreen:B,setIsShowingFabricationNotes:S,setIsShowingPcbNotes:Q,setPcbGroupViewMode:w,setHoveredErrorId:M,setFocusedErrorId:k}=Kc(it=>({isMouseOverContainer:it.is_mouse_over_container,setIsMouseOverContainer:it.setIsMouseOverContainer,selectedLayer:it.selected_layer,selectLayer:it.selectLayer,viewSettings:{is_showing_rats_nest:it.is_showing_rats_nest,is_showing_multiple_traces_length:it.is_showing_multiple_traces_length,is_showing_autorouting:it.is_showing_autorouting,is_showing_drc_errors:it.is_showing_drc_errors,is_showing_drc_warnings:it.is_showing_drc_warnings,is_showing_copper_pours:it.is_showing_copper_pours,is_showing_courtyards:it.is_showing_courtyards,is_showing_pcb_groups:it.is_showing_pcb_groups,is_showing_group_anchor_offsets:it.is_showing_group_anchor_offsets,is_showing_solder_mask:it.is_showing_solder_mask,is_showing_silkscreen:it.is_showing_silkscreen,is_showing_fabrication_notes:it.is_showing_fabrication_notes,is_showing_pcb_notes:it.is_showing_pcb_notes,pcb_group_view_mode:it.pcb_group_view_mode},setIsShowingRatsNest:it.setIsShowingRatsNest,setIsShowingMultipleTracesLength:it.setIsShowingMultipleTracesLength,setIsShowingAutorouting:it.setIsShowingAutorouting,setIsShowingDrcErrors:it.setIsShowingDrcErrors,setIsShowingDrcWarnings:it.setIsShowingDrcWarnings,setIsShowingCopperPours:it.setIsShowingCopperPours,setIsShowingCourtyards:it.setIsShowingCourtyards,setIsShowingPcbGroups:it.setIsShowingPcbGroups,setIsShowingGroupAnchorOffsets:it.setIsShowingGroupAnchorOffsets,setIsShowingSolderMask:it.setIsShowingSolderMask,setIsShowingSilkscreen:it.setIsShowingSilkscreen,setIsShowingFabricationNotes:it.setIsShowingFabricationNotes,setIsShowingPcbNotes:it.setIsShowingPcbNotes,setPcbGroupViewMode:it.setPcbGroupViewMode,setHoveredErrorId:it.setHoveredErrorId,setFocusedErrorId:it.setFocusedErrorId})),[R,F]=ee.useState(null),[O,U]=ee.useState([]),[Y,W]=ee.useState(),[te,j]=ee.useState("Net"),[J,oe]=ee.useState(),ie=it=>{const Yt=it.currentTarget.getBoundingClientRect();return i?.({x:it.clientX-Yt.left,y:it.clientY-Yt.top})},ne=ee.useRef(null),le=Kc(it=>it.in_edit_mode),ge=it=>{const Yt=it.currentTarget.getBoundingClientRect();return o?.({x:it.clientX-Yt.left,y:it.clientY-Yt.top})},_e=ee.useCallback(()=>{F(null),n?.(!1)},[n]),[ue,fe]=ee.useState(!1),[pe,ye]=ee.useState(!1),[Me,ve]=ee.useState(!1),[he,Qe]=ee.useState(!1),[Pe,we]=ee.useState(!1);ee.useEffect(()=>{const it=()=>Qe(!0),Yt=()=>Qe(!1),pn=()=>we(!0),be=()=>we(!1);return window.addEventListener("arm-dimension-tool",it),window.addEventListener("disarm-dimension-tool",Yt),window.addEventListener("arm-bounds-tool",pn),window.addEventListener("disarm-bounds-tool",be),()=>{window.removeEventListener("arm-dimension-tool",it),window.removeEventListener("disarm-dimension-tool",Yt),window.removeEventListener("arm-bounds-tool",pn),window.removeEventListener("disarm-bounds-tool",be)}},[]);const Te=Afe(e??[]),Re=Te,Ee=ee.useRef(!1),ke=ee.useRef(null),Ce={1:Te[0]?()=>g(Te[0]):()=>{},2:Te[1]?()=>g(Te[1]):()=>{},3:Te[2]?()=>g(Te[2]):()=>{},4:Te[3]?()=>g(Te[3]):()=>{},5:Te[4]?()=>g(Te[4]):()=>{},6:Te[5]?()=>g(Te[5]):()=>{},7:Te[6]?()=>g(Te[6]):()=>{},8:Te[7]?()=>g(Te[7]):()=>{},9:Te[8]?()=>g(Te[8]):()=>{},0:Te[9]?()=>g(Te[9]):()=>{}};Z6("1",Ce[1],ke),Z6("2",Ce[2],ke),Z6("3",Ce[3],ke),Z6("4",Ce[4],ke),Z6("5",Ce[5],ke),Z6("6",Ce[6],ke),Z6("7",Ce[7],ke),Z6("8",Ce[8],ke),Z6("9",Ce[9],ke),Z6("0",Ce[0],ke),ee.useLayoutEffect(()=>{if(Ee.current)return;Ee.current=!0;const it=Yt=>{if(ke.current){const pn=ke.current.getBoundingClientRect();Yt.clientX>=pn.left&&Yt.clientX<=pn.right&&Yt.clientY>=pn.top&&Yt.clientY<=pn.bottom&&l(!0)}document.removeEventListener("mousemove",it)};return document.addEventListener("mousemove",it),()=>{document.removeEventListener("mousemove",it)}},[l]);const Le=ee.useCallback(()=>{l(!0)},[l]),Ye=ee.useCallback(()=>{c||l(!0)},[c,l]),tt=ee.useCallback(()=>{l(!1),ye(!1),fe(!1),ve(!1)},[l]),At=ee.useCallback(()=>{ye(!pe)},[pe]),at=ee.useCallback(()=>{const it=!Me;ve(it),it&&fe(!1),it||M(null)},[Me,M]),nt=ee.useCallback(()=>{ve(!1)},[]),gt=ee.useCallback(()=>{d(!h.is_showing_rats_nest)},[h.is_showing_rats_nest,d]),bt=ee.useCallback(()=>{Qe(!0),we(!1),window.dispatchEvent(new Event("arm-dimension-tool"))},[]),Ct=ee.useCallback(()=>{we(!0),Qe(!1),window.dispatchEvent(new Event("arm-bounds-tool"))},[]),Dt=ee.useCallback(()=>{const it=!ue;fe(it),it&&ve(!1)},[ue]),kt=ee.useCallback(it=>{it.stopPropagation()},[]);return K.jsxs("div",{ref:ke,onPointerDown:it=>{ne.current={x:it.clientX,y:it.clientY}},onClick:it=>{if(it.detail>1||le||he||Pe||it.target.closest("button, input, select, [role=menu]"))return;const Yt=ne.current;if(!Yt||Math.hypot(it.clientX-Yt.x,it.clientY-Yt.y)>4)return;const pn=ge(it),be=ie(it);if(!pn&&!be)return;const et=pn?.netId;et&&s.includes(et)?(a?.(s.filter(It=>It!==et)),_e()):(W(et),j(pn?.displayName??"Net"),U(pn?.groups??[]),oe(be),n?.(!0),F({x:it.clientX,y:it.clientY}))},onDoubleClick:()=>{a?.([]),_e()},onContextMenu:it=>{it.preventDefault(),it.stopPropagation();const Yt=ge(it);oe(ie(it)),W(Yt?.netId),j(Yt?.displayName??"Net"),U(Yt?.groups??[]),n?.(!0),F({x:it.clientX,y:it.clientY})},style:{position:"relative",zIndex:"999 !important"},onMouseEnter:Le,onMouseLeave:tt,onMouseMove:Ye,children:[t,R&&K.jsx(HHi,{position:R,component:J,onViewSchematicComponent:r,onClose:_e,xRayDisplayName:te,xRayGroups:O.filter(it=>it.netIds.some(Yt=>!s.includes(Yt))),onXRayGroup:it=>a?.([...new Set([...s,...it.netIds])]),onXRayNet:Y&&!s.includes(Y)?()=>a?.([...s,Y]):void 0,onExitXRayNet:s.length>0?()=>a?.([]):void 0}),K.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:c?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",FHi.version]}),K.jsxs("div",{"data-toolbar-overlay":!0,onTouchStart:it=>it.stopPropagation(),onTouchEnd:it=>it.stopPropagation(),onTouchMove:it=>it.stopPropagation(),onMouseDown:kt,onMouseMove:kt,onMouseUp:kt,onPointerDown:kt,onPointerMove:kt,onPointerUp:kt,onWheel:kt,style:{position:"absolute",opacity:A||c?1:0,top:16,left:16,right:A?16:"auto",transition:c?"opacity 100ms linear":"opacity 300ms linear",zIndex:Ru.toolbarOverlay,color:"red",display:"flex",flexWrap:"wrap",maxWidth:"550px",gap:4,fontSize:12,fontFamily:"sans-serif"},children:[K.jsxs(WU,{isSmallScreen:A,onClick:At,onMouseLeave:()=>{pe&&ye(!1)},children:[K.jsxs("div",{children:["layer:"," ",K.jsx("span",{style:{marginLeft:2,fontWeight:500,color:dee[u]},children:u})]}),pe&&K.jsx("div",{style:{marginTop:4,minWidth:120},children:Re.map(it=>K.jsx(KHi,{name:it,selected:it===u,onClick:()=>{g(it)}},it))})]}),K.jsx(UHi,{elements:e,isOpen:Me,isSmallScreen:A,onToggle:at,onClose:nt,setHoveredErrorId:M,setFocusedErrorId:k}),K.jsx(WU,{isSmallScreen:A,style:{},onClick:gt,children:K.jsxs("div",{children:[h.is_showing_rats_nest?"✖ ":"","Rats Nest"]})}),K.jsx(WU,{isSmallScreen:A,style:he?{backgroundColor:"#444"}:{},onClick:bt,children:K.jsx("div",{children:"📏"})}),K.jsx(WU,{isSmallScreen:A,style:Pe?{backgroundColor:"#444"}:{},onClick:Ct,children:K.jsx("div",{children:"Bounds"})}),K.jsx(WU,{isSmallScreen:A,onClick:Dt,children:K.jsxs("div",{children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View",K.jsx("span",{style:{fontSize:"8px",transform:ue?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),ue&&K.jsxs("div",{style:{marginTop:4,minWidth:120},children:[K.jsx(C4,{label:"Show All Trace Lengths",checked:h.is_showing_multiple_traces_length,onClick:()=>{p(!h.is_showing_multiple_traces_length)}}),K.jsx(C4,{label:"Show Autorouting Animation",checked:h.is_showing_autorouting,onClick:()=>{m(!h.is_showing_autorouting)}}),K.jsx(C4,{label:"Show DRC Errors",checked:h.is_showing_drc_errors,onClick:()=>{_(!h.is_showing_drc_errors)}}),K.jsx(C4,{label:"Show DRC Warnings",checked:h.is_showing_drc_warnings,onClick:()=>{f(!h.is_showing_drc_warnings)}}),K.jsx(C4,{label:"Show Copper Pours",checked:h.is_showing_copper_pours,onClick:()=>{I(!h.is_showing_copper_pours)}}),K.jsx(C4,{label:"Show Courtyards",checked:h.is_showing_courtyards,onClick:()=>{C(!h.is_showing_courtyards)}}),K.jsx(C4,{label:"Show Solder Mask",checked:h.is_showing_solder_mask,onClick:()=>{E(!h.is_showing_solder_mask)}}),K.jsx(C4,{label:"Show Silkscreen",checked:h.is_showing_silkscreen,onClick:()=>{B(!h.is_showing_silkscreen)}}),K.jsx(C4,{label:"Show Fabrication Notes",checked:h.is_showing_fabrication_notes,onClick:()=>{S(!h.is_showing_fabrication_notes)}}),K.jsx(C4,{label:"Show PCB Notes",checked:h.is_showing_pcb_notes,onClick:()=>{Q(!h.is_showing_pcb_notes)}}),K.jsx(C4,{label:"Show Group Anchor Offsets",checked:h.is_showing_group_anchor_offsets,onClick:()=>{x(!h.is_showing_group_anchor_offsets)}}),K.jsx(C4,{label:"Show PCB Groups",checked:h.is_showing_pcb_groups,onClick:()=>{y(!h.is_showing_pcb_groups)}}),h.is_showing_pcb_groups&&K.jsxs("div",{style:{marginLeft:16},children:[K.jsx(zhn,{label:"Show All Groups",checked:h.pcb_group_view_mode==="all",onClick:()=>{w("all")}}),K.jsx(zhn,{label:"Show Named Groups",checked:h.pcb_group_view_mode==="named_only",onClick:()=>{w("named_only")}})]})]})]})})]})]})},zHi=t=>t.type==="pcb_manual_edit_conflict_warning"||t.type==="pcb_connector_not_in_accessible_orientation_warning",JHi=t=>t.type==="pcb_connector_not_in_accessible_orientation_warning"?`Connector faces ${t.facing_direction}; expected ${t.recommended_facing_direction}`:"Manual Edit Conflict",WHi=({children:t,transform:e=RP(),elements:n=[]})=>{const[o,{width:i,height:r}]=uee(),s=ee.useRef(null),a=Kc(A=>A.is_showing_drc_warnings);return ee.useEffect(()=>{const A=s.current;if(!A||!i||!r)return;A.width=i,A.height=r;const c=A.getContext("2d");if(!c)return;c.clearRect(0,0,i,r);const l=n.filter(g=>g.type==="pcb_component"),u=n.filter(zHi);c.strokeStyle=qi.board.drc_warning,c.lineWidth=2,u.forEach(g=>{const h=l.find(U=>U.pcb_component_id===g.pcb_component_id);if(!h)return;const{width:d,height:p,center:m}=h,_=_i(e,m),f=d*Math.abs(e.a),I=p*Math.abs(e.d),C=.1*Math.abs(e.a),y=f+C*2,x=I+C*2,E=_.x-y/2,B=_.y-x/2;c.beginPath(),c.rect(E,B,y,x),c.stroke();const S=JHi(g),Q=4,w=Math.max(8,Math.min(12,10*Math.abs(e.a)));c.font=`${w}px sans-serif`;const k=c.measureText(S).width+Q*2,R=w+Q*2,F=E+(y-k)/2,O=B+x+5;c.fillStyle="rgba(0, 0, 0, 0.7)",c.beginPath(),c.roundRect(F,O,k,R,3),c.fill(),c.fillStyle=qi.board.drc_warning,c.textAlign="center",c.textBaseline="middle",c.fillText(S,F+k/2,O+R/2)})},[n,e,i,r,a]),a?K.jsxs("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:Ru.warnings}})]}):K.jsx("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:t})},jHi=t=>{const{transform:e,elements:n}=t,{hoveredErrorId:o,focusedErrorId:i,isShowingCopperPours:r,selectedLayer:s}=Kc(w=>({hoveredErrorId:w.hovered_error_id,focusedErrorId:w.focused_error_id,isShowingCopperPours:w.is_showing_copper_pours,selectedLayer:w.selected_layer})),a=i??o,A=ee.useMemo(()=>r?n:n.filter(w=>w.type!=="pcb_copper_pour"),[n,r]),c=ee.useMemo(()=>{const w=fFi(n);return A.flatMap(M=>IFi(M,n,w))},[A,n]),l=ee.useMemo(()=>nhn(n),[n]),[u,g]=ee.useState([]);ee.useEffect(()=>g([]),[l]),ee.useEffect(()=>{if(u.length===0)return;const w=M=>{M.key==="Escape"&&g([])};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[u.length]);const h=ee.useMemo(()=>u.length>0?A.filter(w=>lhn(w)&&u.includes(gee(w,l)??"")):void 0,[A,l,u]),d=ee.useMemo(()=>{if(!h)return c;const w=new Set(h);return c.filter(M=>(M._element?.type==="pcb_smtpad"||M._element?.type==="pcb_plated_hole")&&w.has(M._element))},[c,h]),p=w=>{if(!e)return;const M=b$e(c,_i(V6(e),w),e,s).filter(k=>k._element?.type==="pcb_smtpad"||k._element?.type==="pcb_plated_hole");return M.sort((k,R)=>+(R.layer===s)-+(k.layer===s)),cFi(M[0]?._element,n)},m=w=>{if(!e)return;const M=(F,O)=>({netId:F,displayName:NFi(O,n,l),groups:RFi(F,n,l)}),R=b$e(c,_i(V6(e),w),e,s,u.length>0).filter(F=>lhn(F._element)&&F.layer!=="drill");R.sort((F,O)=>+(O.layer===s)-+(F.layer===s));for(const F of R){const O=gee(F._element,l);if(O&&u.includes(O))return M(O,F._element)}for(const F of R){const O=gee(F._element,l);if(O)return M(O,F._element)}},[_,f]=ee.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),[I,C]=ee.useState([]),y=ee.useRef(e??null),x=ee.useRef(null),E=ee.useMemo(()=>ohn(n),[n]),B=ee.useMemo(()=>{if(!a)return[];const M=n.filter(k=>k.type.includes("error")).find((k,R)=>JU(k,R)===a);return M?wFi(M):[]},[a,n]);ee.useEffect(()=>{e&&(y.current=e)},[e]),ee.useEffect(()=>()=>{Ahn(x.current)},[]),ee.useEffect(()=>{if(!t.width||!t.height||!t.setTransform||!i)return;const w=ahn(n,i);if(!w)return;const M=QFi({error:w,indexes:E});if(!M)return;const k=y.current??e;if(!k)return;const R=vFi({bounds:M,width:t.width,height:t.height});Ahn(x.current),DFi({startTransform:k,endTransform:R,durationMs:420,setAnimationFrameId:F=>{x.current=F},onUpdate:F=>{y.current=F,t.setTransform?.(F)}})},[i,n,E,t.height,t.setTransform,t.width]);const S=ee.useMemo(()=>{if(u.length>0)return c;const w=[..._.primitiveIdsInMousedOverNet,...B];return CFi({primitivesWithoutInteractionMetadata:c,drawingObjectIdsWithMouseOver:_.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:w})},[c,_,B,u]),Q=ee.useCallback(w=>{const M=[];for(const F of w)if(F._element){const O=l.getNetConnectedToId("pcb_port_id"in F._element?F._element?.pcb_port_id:"pcb_trace_id"in F._element?F._element?.pcb_trace_id:"");M.push(...l.getIdsConnectedToNet(O))}const k=new Set(w.map(F=>F._pcb_drawing_object_id));f({drawingObjectIdsWithMouseOver:k,primitiveIdsInMousedOverNet:M});const R=w.map(F=>F._parent_pcb_component?.type==="pcb_component"&&F._parent_pcb_component.pcb_component_id?F._parent_pcb_component.pcb_component_id:F._element?.type==="pcb_component"&&F._element.pcb_component_id?F._element.pcb_component_id:null).filter(F=>!!F);C(Array.from(new Set(R)))},[l]);return K.jsx(RHi,{elements:A,transform:e,primitives:d,selectedLayer:s,onMouseHoverOverPrimitives:Q,children:K.jsx(fHi,{disabled:!t.allowEditing,transform:e,soup:n,cancelPanDrag:t.cancelPanDrag,onCreateEditEvent:t.onCreateEditEvent,onModifyEditEvent:t.onModifyEditEvent,children:K.jsx(mHi,{transform:e,focusOnHover:t.focusOnHover,primitives:c,onBoundsSelected:t.onBoundsSelected,cancelPanDrag:t.cancelPanDrag,children:K.jsx(VHi,{elements:n,getNetAtPoint:m,xRayNetIds:u,onXRayNetsChange:g,onContextMenuOpenChange:t.onContextMenuOpenChange,getComponentAtPoint:p,onViewSchematicComponent:t.onViewSchematicComponent,children:K.jsx(CHi,{transform:e,elements:n,children:K.jsx(kHi,{transform:e,soup:n,children:K.jsx(THi,{transform:e,elements:n,hoveredComponentIds:I,children:K.jsx(iHi,{transform:e,debugGraphics:t.debugGraphics,children:K.jsx(WHi,{transform:e,elements:n,children:t.renderer==="canvas"?K.jsx(kLi,{transform:e,primitives:S,elements:A,xRayElements:h,width:t.width,height:t.height,grid:t.grid}):K.jsx(kFi,{transform:e,primitives:S,elements:n,xRayElements:h,width:t.width,height:t.height,grid:t.grid})})})})})})})})})})},hfe=t=>Number.isFinite(t)?t.toFixed(4):"NaN",$Hi=t=>{let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n);return Math.abs(e)},qHi=t=>{if(!t?.length)return"0";const e=[];for(const i of t){if(!i?.type?.startsWith("pcb_"))continue;const r=Tki(i),s=_$e([i]),a=[hfe(s.minX),hfe(s.minY),hfe(s.maxX),hfe(s.maxY)].join(",");let A=`${r}:${a}`;if(i.type==="pcb_trace"){const c=(i.route??[]).length;A+=`:${c}`;for(const l of i.route??[])l.route_type==="via"&&(A+=`:${l.tented_on_top}:${l.tented_on_bottom}`)}i.type==="pcb_board"&&(A+=`:${i.default_via_tented_on_top}:${i.default_via_tented_on_bottom}`),i.type==="pcb_via"&&(A+=`:${i.tented_on_top}:${i.tented_on_bottom}`),e.push(A)}if(e.length===0)return"0";e.sort();const n=e.join(","),o=$Hi(n);return`${e.length}_${o.toString(36)}`},XHi=t=>{if(!t)return"empty";const e=t.find(o=>o.type==="pcb_board");if(!e)return"no-board";const n=o=>Math.round(o*1e3)/1e3;return e.outline?e.outline.map(o=>`${n(o.x)}_${n(o.y)}`).join(","):`${n(e.width)}_${n(e.height)}`};function ZHi({circuitJson:t,editEvents:e}){let n=structuredClone(t);for(const o of e){if(o.edit_event_type==="edit_pcb_component_location"){const a=wS(n).pcb_component.get(o.pcb_component_id);if(a?.center.x===o.new_center.x&&a.center.y===o.new_center.y)continue;const c=Qd(o.new_center.x-o.original_center.x,o.new_center.y-o.original_center.y);n=n.map(l=>"pcb_component_id"in l&&l.pcb_component_id===o.pcb_component_id?Rki(l,c):l);continue}if(o.edit_event_type==="edit_schematic_component_location"){n=n.map(a=>a.type==="schematic_component"&&a.schematic_component_id===o.schematic_component_id?{...a,center:o.new_center}:a);continue}if(o.edit_event_type!=="edit_pcb_trace_hint"||!o.pcb_trace_hint_id)continue;if(wS(n).pcb_trace_hint.get(o.pcb_trace_hint_id)){n=n.map(a=>a.type==="pcb_trace_hint"&&a.pcb_trace_hint_id===o.pcb_trace_hint_id?{...a,route:o.route}:a);continue}const r=wS(n).pcb_port.get(o.pcb_port_id);if(!r?.pcb_component_id)continue;const s={type:"pcb_trace_hint",pcb_trace_hint_id:o.pcb_trace_hint_id,route:o.route,pcb_port_id:o.pcb_port_id,pcb_component_id:r.pcb_component_id};n=n.filter(a=>a.type!=="pcb_trace_hint"||a.pcb_port_id!==o.pcb_port_id).concat(s)}return n}var eOi=NC(Qd(400,300),vS(40,-40)),S$e=({circuitJson:t,debugGraphics:e,height:n=600,renderer:o="canvas",initialState:i,allowEditing:r=!0,editEvents:s,onEditEventsChanged:a,onBoundsSelected:A,onViewSchematicComponent:c,focusOnHover:l=!1,clickToInteractEnabled:u=!1,disablePcbGroups:g=!1})=>{const[h,d]=ee.useState(o);ee.useEffect(()=>d(o),[o]);const p=ee.useMemo(()=>({renderer:h,setRenderer:d}),[h]),[m,_]=ee.useState(!u),[f,I]=ee.useState(!1),C=ee.useRef(!1),[y,x]=uee(),[E,B]=ee.useState(eOi),S=ee.useCallback(le=>{if(C.current||le instanceof MouseEvent&&(le.button===2||(le.buttons&2)!==0))return!1;const ge=le.target;return ge instanceof Element?!ge.closest("[data-toolbar-overlay]"):!0},[]),{ref:Q,setTransform:w,cancelDrag:M}=AFi({transform:E,onSetTransform:B,enabled:m&&!f,shouldDrag:S}),k=ee.useCallback(le=>{C.current=le,le&&M(),I(le)},[M]);let[R,F]=ee.useState([]);R=s??R;const O=ee.useRef(!1),U=ee.useRef(null),Y=ee.useMemo(()=>qHi(t),[t]),W=XHi(t),te=()=>{const le=x?.width>0?x:{width:500,height:500},{center:ge,width:_e,height:ue}=J.some(ye=>ye.type.startsWith("pcb_"))?Yki(J.filter(ye=>ye.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},fe=Math.min((le.width??0)/_e,(le.height??0)/ue,100)*.75,pe=NC(Qd((le.width??0)/2,(le.height??0)/2),vS(fe,-fe,0,0),Qd(-ge.x,-ge.y));w(pe)};ee.useEffect(()=>{x?.width&&t&&t.length!==0&&(O.current||(te(),O.current=!0))},[t,x]),ee.useEffect(()=>{O.current===!0&&te()},[W]);const j=ee.useMemo(()=>t?.filter(le=>le.type.startsWith("pcb_")||le.type.startsWith("source_"))??[],[Y]),J=ee.useMemo(()=>ZHi({circuitJson:j,editEvents:R}),[j,R]),oe=le=>{F([...R,le]),a?.([...R,le])},ie=le=>{const ge=R.map(_e=>_e.edit_event_id===le.edit_event_id?{..._e,...le}:_e);F(ge),a?.(ge)},ne=ee.useMemo(()=>({...i,...g&&{is_showing_pcb_groups:!1}}),[i,g]);return K.jsx(Zgn.Provider,{value:p,children:K.jsxs("div",{ref:Q,style:{position:"relative"},onContextMenu:le=>le.preventDefault(),children:[K.jsx("div",{ref:y,children:K.jsxs(jki,{initialState:ne,disablePcbGroups:g,children:[K.jsx(jHi,{renderer:h,transform:E,setTransform:w,height:n,width:x.width,allowEditing:r,focusOnHover:l,onBoundsSelected:A,onViewSchematicComponent:c,cancelPanDrag:M,onContextMenuOpenChange:k,onCreateEditEvent:oe,onModifyEditEvent:ie,grid:{spacing:1,view_window:{left:0,right:x.width||500,top:n,bottom:0}},elements:J,debugGraphics:e}),K.jsx($ki,{})]})}),u&&!m&&K.jsx("div",{onClick:()=>{_(!0),te()},onTouchStart:le=>{const ge=le.touches[0];U.current={x:ge.clientX,y:ge.clientY}},onTouchEnd:le=>{const ge=le.changedTouches[0],_e=U.current;if(!_e)return;const ue=Math.abs(ge.clientX-_e.x),fe=Math.abs(ge.clientY-_e.y);ue<10&&fe<10&&(le.preventDefault(),_(!0),te()),U.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:Ru.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:K.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})})};const tOi=({circuitJson:t,containerClassName:e,...n})=>{const o=ee.useRef(null),[i,r]=ee.useState(620);return ee.useLayoutEffect(()=>{const s=()=>{if(o.current){const A=o.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(A,620),c))}};s();const a=new ResizeObserver(s);return o.current&&a.observe(o.current),window.addEventListener("resize",s),()=>{a.disconnect(),window.removeEventListener("resize",s)}},[]),K.jsx("div",{ref:o,className:e||"rf-w-full rf-h-full",children:K.jsx(S$e,{...n,circuitJson:t,height:i})})},nOi='*,: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.19 | 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-z-\\[102\\]{z-index:102}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-0{margin:0}.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-0{margin-bottom:0}.rf-mb-0\\.5{margin-bottom:.125rem}.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-7{margin-bottom:1.75rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.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-mr-auto{margin-right:auto}.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-\\[4\\/3\\]{aspect-ratio:4/3}.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-2{height:.5rem;width:.5rem}.rf-size-3{height:.75rem;width:.75rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.rf-h-0{height:0}.rf-h-0\\.5{height:.125rem}.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-\\[calc\\(100vh-60px\\)\\]{height:calc(100vh - 60px)}.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-\\[80vh\\]{max-height:80vh!important}.rf-max-h-16{max-height:4rem}.rf-max-h-20{max-height:5rem}.rf-max-h-24{max-height:6rem}.rf-max-h-28{max-height:7rem}.rf-max-h-32{max-height:8rem}.rf-max-h-64{max-height:16rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[120px\\]{max-height:120px}.rf-max-h-\\[150px\\]{max-height:150px}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-max-h-none{max-height:none}.rf-min-h-0{min-height:0}.rf-min-h-56{min-height:14rem}.rf-min-h-72{min-height:18rem}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[360px\\]{min-height:360px}.rf-min-h-\\[400px\\]{min-height:400px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.rf-min-h-full{min-height:100%}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.\\!rf-w-\\[95vw\\]{width:95vw!important}.rf-w-1{width:.25rem}.rf-w-10{width:2.5rem}.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-7{width:1.75rem}.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-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-\\[12px\\]{min-width:12px}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[192px\\]{min-width:192px}.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-\\[95vw\\]{max-width:95vw!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-7xl{max-width:80rem}.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-\\[320px\\]{max-width:320px}.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-0{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-0{--tw-translate-y:-0px}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf--translate-y-1,.rf-translate-x-\\[-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-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.-rf-rotate-90,.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-rotate-90{--tw-rotate:-90deg}.rf-rotate-90{--tw-rotate:90deg}.rf-rotate-90,.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-content-center{place-content:center}.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-baseline{align-items:baseline}.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-1\\.5{gap:.375rem}.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-gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.rf-gap-y-1{row-gap:.25rem}.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-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-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}.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-text-nowrap{text-wrap:nowrap}.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-none{border-radius:0}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-0{border-width:0}.rf-border-2{border-width:2px}.rf-border-y{border-top-width:1px}.rf-border-b,.rf-border-y{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-r{border-right-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-100{--tw-border-opacity:1;border-color:rgb(219 234 254/var(--tw-border-opacity,1))}.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-border{border-color:hsl(var(--border))}.rf-border-emerald-500{--tw-border-opacity:1;border-color:rgb(16 185 129/var(--tw-border-opacity,1))}.rf-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/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-100{--tw-border-opacity:1;border-color:rgb(255 237 213/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-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/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-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-red-700{--tw-border-opacity:1;border-color:rgb(185 28 28/var(--tw-border-opacity,1))}.rf-border-red-800{--tw-border-opacity:1;border-color:rgb(153 27 27/var(--tw-border-opacity,1))}.rf-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.rf-border-slate-700{--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.rf-border-slate-800{--tw-border-opacity:1;border-color:rgb(30 41 59/var(--tw-border-opacity,1))}.rf-border-slate-800\\/60{border-color:rgba(30,41,59,.6)}.rf-border-transparent{border-color:transparent}.rf-border-yellow-200{--tw-border-opacity:1;border-color:rgb(254 240 138/var(--tw-border-opacity,1))}.rf-border-zinc-100{--tw-border-opacity:1;border-color:rgb(244 244 245/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-border-l-blue-500{--tw-border-opacity:1;border-left-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-t-blue-600{--tw-border-opacity:1;border-top-color:rgb(37 99 235/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-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-emerald-500{--tw-bg-opacity:1;background-color:rgb(16 185 129/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-300{--tw-bg-opacity:1;background-color:rgb(134 239 172/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-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/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-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/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-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-purple-500{--tw-bg-opacity:1;background-color:rgb(168 85 247/var(--tw-bg-opacity,1))}.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-50\\/50{background-color:rgba(254,242,242,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/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-red-950{--tw-bg-opacity:1;background-color:rgb(69 10 10/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-slate-800{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.rf-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/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-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/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-zinc-950{--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.rf-from-blue-500{--tw-gradient-from:#3b82f6 var(--tw-gradient-from-position);--tw-gradient-to:rgba(59,130,246,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-emerald-500{--tw-gradient-from:#10b981 var(--tw-gradient-from-position);--tw-gradient-to:rgba(16,185,129,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-green-500{--tw-gradient-from:#22c55e var(--tw-gradient-from-position);--tw-gradient-to:rgba(34,197,94,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-red-500{--tw-gradient-from:#ef4444 var(--tw-gradient-from-position);--tw-gradient-to:rgba(239,68,68,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-to-blue-600{--tw-gradient-to:#2563eb var(--tw-gradient-to-position)}.rf-to-emerald-600{--tw-gradient-to:#059669 var(--tw-gradient-to-position)}.rf-to-green-600{--tw-gradient-to:#16a34a var(--tw-gradient-to-position)}.rf-to-red-600{--tw-gradient-to:#dc2626 var(--tw-gradient-to-position)}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-stroke-1{stroke-width:1}.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-1\\.5{padding-left:.375rem;padding-right:.375rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-5{padding-left:1.25rem;padding-right:1.25rem}.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-1\\.5{padding-bottom:.375rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.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-1{padding-top:.25rem}.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-align-bottom{vertical-align:bottom}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[10px\\]{font-size:10px}.rf-text-\\[11px\\]{font-size:11px}.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-normal{font-weight:400}.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-4{line-height:1rem}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-tight{letter-spacing:-.025em}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-wider{letter-spacing:.05em}.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-emerald-600{--tw-text-opacity:1;color:rgb(5 150 105/var(--tw-text-opacity,1))}.rf-text-foreground{color:hsl(var(--foreground))}.rf-text-gray-200{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.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{color:hsl(var(--muted))}.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-400{--tw-text-opacity:1;color:rgb(251 146 60/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-700{--tw-text-opacity:1;color:rgb(194 65 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-200{--tw-text-opacity:1;color:rgb(226 232 240/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-50{--tw-text-opacity:1;color:rgb(248 250 252/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-700{--tw-text-opacity:1;color:rgb(161 98 7/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-600{--tw-text-opacity:1;color:rgb(82 82 91/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-accent-blue-600{accent-color:#2563eb}.rf-opacity-0{opacity:0}.rf-opacity-10{opacity:.1}.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-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.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-shadow-sm,.rf-shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px 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-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-150{transition-duration:.15s}.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-animate-in{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}.rf-fade-in-0{--tw-enter-opacity:0}.rf-zoom-in-95{--tw-enter-scale:.95}.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-150{animation-duration:.15s}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.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--translate-y-0\\.5:hover{--tw-translate-y:-0.125rem;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))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-zinc-300:hover{--tw-border-opacity:1;border-color:rgb(212 212 216/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-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-50:hover{--tw-bg-opacity:1;background-color:rgb(248 250 252/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-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/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}.hover\\:rf-shadow-md:hover{--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);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.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-900:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(24 24 27/var(--tw-ring-opacity,1))}.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-text-gray-500:disabled{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.disabled\\:rf-opacity-40:disabled{opacity:.4}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-scale-\\[1\\.03\\]{--tw-scale-x:1.03;--tw-scale-y:1.03;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-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.rf-peer:disabled~.peer-disabled\\:rf-cursor-not-allowed{cursor:not-allowed}.rf-peer:disabled~.peer-disabled\\:rf-opacity-70{opacity:.7}.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-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(24 24 27/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-300:is(.rf-dark *){--tw-text-opacity:1;color:rgb(212 212 216/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-mt-4{margin-top:1rem}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-h-5{height:1.25rem}.sm\\:rf-w-1\\/2{width:50%}.sm\\:rf-w-5{width:1.25rem}.sm\\:rf-w-\\[90vw\\]{width:90vw}.sm\\:rf-w-auto{width:auto}.sm\\:rf-max-w-\\[500px\\]{max-width:500px}.sm\\:rf-max-w-md{max-width:28rem}.sm\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.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-grid-cols-\\[minmax\\(0\\2c 1fr\\)_auto\\]{grid-template-columns:minmax(0,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-gap-4{gap:1rem}.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-rounded-lg{border-radius:var(--radius)}.sm\\:rf-p-3{padding:.75rem}.sm\\:rf-p-6{padding:1.5rem}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\\:rf-px-8{padding-left:2rem;padding-right:2rem}.sm\\:rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\\:rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-2xl{font-size:1.5rem;line-height:2rem}.sm\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\\:rf-text-base{font-size:1rem;line-height:1.5rem}.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-w-52{width:13rem}.md\\:rf-w-auto{width:auto}.md\\:rf-min-w-0{min-width:0}.md\\:rf-max-w-\\[660px\\]{max-width:660px}.md\\:rf-max-w-lg{max-width:32rem}.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:rf-grid-cols-\\[220px_1fr\\]{grid-template-columns:220px 1fr}.md\\:rf-flex-row{flex-direction:row}.md\\:rf-flex-col{flex-direction:column}.md\\:rf-overflow-y-auto{overflow-y:auto}.md\\:rf-overflow-x-hidden{overflow-x:hidden}.md\\:rf-border-b-0{border-bottom-width:0}.md\\:rf-border-r{border-right-width:1px}.md\\:rf-p-8{padding:2rem}.md\\:rf-py-8{padding-bottom:2rem;padding-top:2rem}.md\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width:1024px){.lg\\:rf-max-w-\\[720px\\]{max-width:720px}.lg\\:rf-max-w-xl{max-width:36rem}.lg\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1280px){.xl\\:rf-max-w-\\[800px\\]{max-width:800px}}.\\[\\&\\>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}',mee=()=>{ee.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=nOi,document.head.appendChild(e)},[])},oOi=t=>{ee.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t])},Jhn=t=>`hsl(${rE.indexOf(t)*137.5%360}, 70%, 50%)`,iOi=({phaseTimings:t})=>{if(!t)return null;const e=Object.values(t).reduce((n,o)=>n+o,0);return K.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[K.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:rE.map(n=>{const o=t[n]||0,i=o/e*100;return K.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:Jhn(n)},children:K.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:[n,": ",o.toFixed(1),"ms"]})},n)})}),K.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},rOi=t=>{if(t instanceof Blob)return t;if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t,null,2)}catch{return String(t)}return String(t)},sOi=({renderLog:t,onRerunWithDebug:e})=>{const[n,o]=ee.useState("chronological"),[i,r]=ee.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(!t)return K.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[K.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(t?.phaseTimings??{});n==="chronological"?a.sort((c,l)=>rE.indexOf(c[0])-rE.indexOf(l[0])):a.sort((c,l)=>l[1]-c[1]);const A=a.reduce((c,[l,u])=>c+u,0);return K.jsxs("div",{className:"rf-bg-white",children:[K.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[K.jsx("div",{children:"Render Logs"}),K.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&K.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[K.jsx("select",{value:i,onChange:c=>r(c.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(c=>K.jsx("option",{value:c.value,children:c.label},c.value))}),K.jsx(fA,{onClick:()=>e(i),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),K.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:K.jsxs("select",{onChange:c=>{if(c.target.value){const l=t?.debugOutputs?.find(u=>u.name===c.target.value);if(l){const u=rOi(l.content),g=u instanceof Blob?u:new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(g),d=document.createElement("a");d.href=h,d.download=`debug-${l.name}.txt`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(h)}c.target.value=""}},disabled:!t?.debugOutputs||t.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:[K.jsx("option",{value:"",children:"Download Debug Output"}),t?.debugOutputs?.map(c=>K.jsx("option",{value:c.name,children:c.name},c.name))]})}),K.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[K.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),K.jsxs("select",{value:n,onChange:c=>o(c.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[K.jsx("option",{value:"chronological",children:"Phase Order"}),K.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),K.jsx(iOi,{phaseTimings:t.phaseTimings}),K.jsxs("table",{className:"rf-w-full rf-text-xs",children:[K.jsx("thead",{children:K.jsxs("tr",{children:[K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),K.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),K.jsx("tbody",{children:a.map(([c,l])=>K.jsxs("tr",{children:[K.jsx("td",{className:"rf-p-2",children:rE.indexOf(c)}),K.jsx("td",{className:"rf-p-2",children:c}),K.jsx("td",{className:"rf-p-2",children:K.jsx("div",{className:"rf-w-8",children:K.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Jhn(c),width:`${l/A*100}%`}})})}),K.jsx("td",{className:"rf-p-2",children:K.jsxs("div",{className:"rf-flex w-full",children:[K.jsxs("span",{className:"rf-flex-grow",children:[l,"ms"]}),K.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(l/A*100).toFixed(1),"%"]})]})})]},c))})]})]})};var aOi=8,Q$e=t=>Math.hypot(t.a,t.b)||1,AOi=t=>[t.label,t.inlineLabel].filter(Boolean).join(`
`),_ee=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Whn=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=o*o+i*i;if(r===0)return _ee(t,e);const s=((t.x-e.x)*o+(t.y-e.y)*i)/r,a=Math.max(0,Math.min(1,s));return _ee(t,{x:e.x+o*a,y:e.y+i*a})},cOi=(t,e,n)=>{const o=n.x-e.x,i=n.y-e.y,r=Math.hypot(o,i);return r===0?_ee(t,e):Math.abs(i*t.x-o*t.y+n.x*e.y-n.y*e.x)/r},v$e=(t,e)=>{let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o],s=e[i];r.y>t.y!=s.y>t.y&&t.x<(s.x-r.x)*(t.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},w$e=(t,e,n,o=!1)=>{if(e.length===0)return!1;const i=o?e.length:e.length-1;for(let r=0;r<i;r+=1){const s=e[r],a=e[(r+1)%e.length];if(Whn(t,s,a)<=n)return!0}return!1},jhn=(t,e,n)=>Math.max(n,(t??2)*Q$e(e)/2+4),PS=(t,e)=>Bn(t,e),P$e=(t,e,n,o)=>_ee(t,PS(n,e))<=o,lOi=(t,e,n,o)=>{if(e.points.length===0)return!1;if(e.points.length===1)return P$e(t,e.points[0],n,o);const i=e.points.map(r=>PS(n,r));return w$e(t,i,jhn(e.strokeWidth,n,o))},uOi=(t,e,n,o)=>{const{origin:i,directionVector:r}=e;if(r.x===0&&r.y===0)return!1;const s=PS(n,i),a=PS(n,{x:i.x+r.x,y:i.y+r.y});return cOi(t,s,a)<=jhn(e.strokeWidth,n,o)},gOi=(t,e,n,o)=>{const i=VQe(e,n).corners;return v$e(t,i)||w$e(t,i,o,!0)},dOi=(t,e,n,o)=>{const i=PS(n,e.center),r=e.radius*Q$e(n);return _ee(t,i)<=r+o},hOi=(t,e,n,o)=>{if(e.points.length===0)return!1;if(e.points.length===1)return P$e(t,e.points[0],n,o);const i=e.points.map(r=>PS(n,r));return v$e(t,i)||w$e(t,i,o,!0)},pOi=(t,e,n,o)=>{const i=jW(e),r=PS(n,i.shaftStart),s=PS(n,i.shaftEnd),a=Math.max(o,i.shaftWidth*Q$e(n)/2+4);return Whn(t,r,s)<=a?!0:i.heads.some(A=>{const c=[A.tip,A.leftWing,A.rightWing].map(l=>PS(n,l));return v$e(t,c)})};function mOi(t,e,n,o={}){const i=o.hitSlop??aOi;for(let s=(t.points?.length??0)-1;s>=0;s-=1){const a=t.points?.[s];if(a?.label&&P$e(n,a,e,i))return a.label}for(let s=(t.infiniteLines?.length??0)-1;s>=0;s-=1){const a=t.infiniteLines?.[s];if(a?.label&&uOi(n,a,e,i))return a.label}const r=t.lines?.map((s,a)=>({line:s,originalIndex:a})).sort((s,a)=>(s.line.zIndex??0)-(a.line.zIndex??0)||s.originalIndex-a.originalIndex)??[];for(let s=r.length-1;s>=0;s-=1){const a=r[s]?.line;if(a?.label&&lOi(n,a,e,i))return a.label}for(let s=(t.arrows?.length??0)-1;s>=0;s-=1){const a=t.arrows?.[s],A=a?AOi(a):"";if(!(!a||!A)&&pOi(n,a,e,i))return A}for(let s=(t.polygons?.length??0)-1;s>=0;s-=1){const a=t.polygons?.[s];if(a?.label&&hOi(n,a,e,i))return a.label}for(let s=(t.circles?.length??0)-1;s>=0;s-=1){const a=t.circles?.[s];if(a?.label&&dOi(n,a,e,i))return a.label}for(let s=(t.rects?.length??0)-1;s>=0;s-=1){const a=t.rects?.[s];if(a?.label&&gOi(n,a,e,i))return a.label}return null}const _Oi=Fs[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],fOi=t=>{const e=ee.useRef(t);return ee.useEffect(()=>{e.current=t}),e};function IOi(){}function $hn(t,e,n={}){const o=yOi(n.polyfill),i=fOi(e);return _Oi(()=>{let r=!1;const s=t&&"current"in t?t.current:t;if(!s)return IOi;function a(A,c){r||i.current(A,c)}return o.subscribe(s,a),()=>{r=!0,o.unsubscribe(s,a)}},[t,o,i]),o.observer}function COi(t){let e=!1,n=[];const o=new Map,i=new(t||window.ResizeObserver)((r,s)=>{n=n.concat(r);function a(){const A=new Set;for(let c=0;c<n.length;c++){if(A.has(n[c].target))continue;A.add(n[c].target);const l=o.get(n[c].target);l?.forEach(u=>u(n[c],s))}n=[],e=!1}e||window.requestAnimationFrame(a),e=!0});return{observer:i,subscribe(r,s){var a;i.observe(r);const A=(a=o.get(r))!==null&&a!==void 0?a:[];A.push(s),o.set(r,A)},unsubscribe(r,s){var a;const A=(a=o.get(r))!==null&&a!==void 0?a:[];if(A.length===1){i.unobserve(r),o.delete(r);return}const c=A.indexOf(s);c!==-1&&A.splice(c,1),o.set(r,A)}}}let M$e;const yOi=t=>M$e||(M$e=COi(t));var xOi=t=>{const e={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const n of t.lines??[])for(const o of n.points??[])e.minX=Math.min(e.minX,o.x),e.minY=Math.min(e.minY,o.y),e.maxX=Math.max(e.maxX,o.x),e.maxY=Math.max(e.maxY,o.y);for(const n of t.rects??[]){const o=hmo(n);e.minX=Math.min(e.minX,o.minX),e.minY=Math.min(e.minY,o.minY),e.maxX=Math.max(e.maxX,o.maxX),e.maxY=Math.max(e.maxY,o.maxY)}for(const n of t.polygons??[])for(const o of n.points??[])e.minX=Math.min(e.minX,o.x),e.minY=Math.min(e.minY,o.y),e.maxX=Math.max(e.maxX,o.x),e.maxY=Math.max(e.maxY,o.y);for(const n of t.points??[])e.minX=Math.min(e.minX,n.x),e.minY=Math.min(e.minY,n.y),e.maxX=Math.max(e.maxX,n.x),e.maxY=Math.max(e.maxY,n.y);for(const n of t.circles??[])e.minX=Math.min(e.minX,n.center.x-n.radius),e.minY=Math.min(e.minY,n.center.y-n.radius),e.maxX=Math.max(e.maxX,n.center.x+n.radius),e.maxY=Math.max(e.maxY,n.center.y+n.radius);for(const n of t.arrows??[]){const o=lbt(n);e.minX=Math.min(e.minX,o.minX),e.minY=Math.min(e.minY,o.minY),e.maxX=Math.max(e.maxX,o.maxX),e.maxY=Math.max(e.maxY,o.maxY)}for(const n of t.texts??[])e.minX=Math.min(e.minX,n.x),e.minY=Math.min(e.minY,n.y),e.maxX=Math.max(e.maxX,n.x),e.maxY=Math.max(e.maxY,n.y);return e};function qhn(t){const e=l=>!l||l.length===0?0:l.reduce((u,g)=>{const h=Number.isNaN(g.step)?0:g.step||0;return Math.max(u,h)},0),n=e(t.points),o=e(t.lines),i=e(t.infiniteLines),r=e(t.rects),s=e(t.polygons),a=e(t.circles),A=e(t.texts),c=e(t.arrows);return Math.max(n,o,i,r,s,a,A,c)}var EOi=t=>t.slice().sort((e,n)=>n.width*n.height-e.width*e.height);function BOi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t,a=n.x-e.x,A=n.y-e.y,c=Math.sqrt(a*a+A*A),l=i.x-o.x,u=i.y-o.y,g=Math.sqrt(l*l+u*u),h=Math.atan2(u,l)*(180/Math.PI),d=Math.abs(h)%90,m=Math.min(d,90-d)>15,_=(o.x+i.x)/2,f=(o.y+i.y)/2,I=15,C=h+90;let y=Math.cos(C*Math.PI/180)*I,x=Math.sin(C*Math.PI/180)*I;const E=l>0&&u<0,B=l>0&&u>0,S=l<0&&u>0;r!==s&&!E&&(y=-y,x=-x),E&&(y+=Math.cos(C*Math.PI/180)*-45,x+=Math.sin(C*Math.PI/180)*-45),B&&(y+=Math.cos(C*Math.PI/180)+-20,x+=Math.sin(C*Math.PI/180)+-10),S&&(y+=Math.cos(C*Math.PI/180)*10,x+=Math.sin(C*Math.PI/180)*10);const Q=_+y,w=f+x;return{distance:c,screenDistance:g,x:Q,y:w,show:c>.01&&g>30&&m}}function bOi(t){const{dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}=t;return ee.useMemo(()=>BOi({dimensionStart:e,dimensionEnd:n,screenDimensionStart:o,screenDimensionEnd:i,flipX:r,flipY:s}),[e,n,o,i,r,s])}var SOi=({children:t,transform:e})=>{e||(e=QQ());const[n,o]=ee.useState(!1),[i,r]=ee.useState(!1),[s,a]=ee.useState({x:0,y:0}),[A,c]=ee.useState({x:0,y:0}),l=ee.useRef({x:0,y:0}),u=ee.useRef(null),g=ee.useRef(!1),d=u.current?.getBoundingClientRect(),p=ee.useCallback(()=>{g.current=!0,u.current?.focus()},[]),m=ee.useCallback(()=>{g.current=!1},[]);ee.useEffect(()=>{const y=x=>{const E=u.current?.contains(document.activeElement)||document.activeElement===u.current;!g.current&&!E||(x.key==="d"&&(a({x:l.current.x,y:l.current.y}),c({x:l.current.x,y:l.current.y}),o(B=>!B),r(!0)),x.key==="Escape"&&(o(!1),r(!1)))};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[]);const _=Bn(e,s),f=Bn(e,A),I={left:Math.min(_.x,f.x),right:Math.max(_.x,f.x),top:Math.min(_.y,f.y),bottom:Math.max(_.y,f.y),flipX:_.x>f.x,flipY:_.y>f.y,width:0,height:0};I.width=I.right-I.left,I.height=I.bottom-I.top;const C=bOi({dimensionStart:s,dimensionEnd:A,screenDimensionStart:_,screenDimensionEnd:f,flipX:I.flipX,flipY:I.flipY});return K.jsxs("div",{ref:u,tabIndex:0,style:{position:"relative"},onMouseMove:y=>{const x=y.currentTarget.getBoundingClientRect(),E=y.clientX-x.left,B=y.clientY-x.top,S=Bn(bV(e),{x:E,y:B});l.current.x=S.x,l.current.y=S.y,i&&c({x:S.x,y:S.y})},onMouseDown:()=>{i?r(!1):n&&o(!1)},onMouseEnter:p,onMouseLeave:m,children:[t,n&&K.jsxs(K.Fragment,{children:[C.show&&K.jsx("div",{style:{position:"absolute",left:C.x,top:C.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:30},children:C.distance.toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:I.left,width:I.width,textAlign:"center",top:_.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:I.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:30},children:Math.abs(s.x-A.x).toFixed(2)}),K.jsx("div",{style:{position:"absolute",left:f.x,height:I.height,display:"flex",flexDirection:"column",justifyContent:"center",top:I.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:30},children:K.jsx("div",{style:{marginLeft:I.flipX?"-100%":4,paddingRight:4},children:Math.abs(s.y-A.y).toFixed(2)})}),K.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:30},width:d?.width||"100%",height:d?.height||"100%",children:[K.jsx("defs",{children:K.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:K.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),K.jsx("line",{x1:_.x,y1:_.y,x2:f.x,y2:f.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),K.jsx("line",{x1:_.x,y1:_.y,x2:f.x,y2:_.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),K.jsx("line",{x1:f.x,y1:_.y,x2:f.x,y2:f.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),K.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",s.x.toFixed(2),",",s.y.toFixed(2),")",K.jsx("br",{}),"(",A.x.toFixed(2),",",A.y.toFixed(2),")",K.jsx("br",{}),"dist:"," ",Math.sqrt((A.x-s.x)**2+(A.y-s.y)**2).toFixed(2)]})]})]})},Xhn=({label:t,onClose:e})=>K.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Object label",onClick:e,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0, 0, 0, 0.28)"},children:K.jsxs("div",{onClick:n=>{n.stopPropagation()},style:{width:"min(420px, 100%)",background:"#fff",borderRadius:10,boxShadow:"0 12px 32px rgba(0, 0, 0, 0.2)",padding:16},children:[K.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"Object label"}),K.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",marginBottom:16},children:t}),K.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:K.jsx("button",{type:"button",onClick:e,children:"Close"})})]})}),Zhn=(t,e,n,o,i,r)=>{const s=t-n,a=e-o,A=i-n,c=r-o,l=s*A+a*c,u=A*A+c*c;let g=-1;u!==0&&(g=l/u);let h=0,d=0;g<0?(h=n,d=o):g>1?(h=i,d=r):(h=n+g*A,d=o+g*c);const p=t-h,m=e-d;return Math.sqrt(p*p+m*m)},r9=(t,e)=>{try{return qpo(t,e)}catch{return e}},QOi=({arrow:t,index:e,interactiveState:n})=>{const{realToScreen:o,onObjectClicked:i,setHoverTooltip:r}=n,[s,a]=ee.useState(!1),A=ee.useMemo(()=>jW(t),[t]),c=ee.useMemo(()=>({shaftStart:Bn(o,A.shaftStart),shaftEnd:Bn(o,A.shaftEnd),heads:A.heads.map(y=>({tip:Bn(o,y.tip),base:Bn(o,y.base),leftWing:Bn(o,y.leftWing),rightWing:Bn(o,y.rightWing)}))}),[A,o]),l=Math.abs(o.a),u=12,g=A.shaftWidth*(l||1),h=u*.6,d=ee.useMemo(()=>Vce(c.shaftStart,c.shaftEnd,{fontSize:u,strokeWidth:g,normalPadding:6,alongOffset:t.label?h:0}),[c,u,g,t.label,h]),p=ee.useMemo(()=>Vce(c.shaftStart,c.shaftEnd,{fontSize:u,strokeWidth:g,normalPadding:12,alongOffset:t.inlineLabel?-h:0}),[c,u,g,t.inlineLabel,h]),m=t.color||rh[e%rh.length]||"black",_=s?r9(.2,m):m,f=[t.label,t.inlineLabel].filter(Boolean).join(`
`),I=t.label?p:d;ee.useEffect(()=>{if(!(!s||!f))return r?.({text:f,x:I.x,y:I.y}),()=>{r?.(null)}},[s,r,I.x,I.y,f]);const C=y=>{const x=y.currentTarget.getBoundingClientRect(),E=y.clientX-x.left,B=y.clientY-x.top,S=10,w=[{from:c.shaftStart,to:c.shaftEnd},...c.heads.flatMap(M=>[{from:M.base,to:M.leftWing},{from:M.leftWing,to:M.tip},{from:M.tip,to:M.rightWing},{from:M.rightWing,to:M.base}])].some(({from:M,to:k})=>Zhn(E,B,M.x,M.y,k.x,k.y)<S);a(w)};return K.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:K.jsxs("svg",{style:{width:"100%",height:"100%",pointerEvents:"auto"},onMouseMove:C,onMouseLeave:()=>{a(!1),r?.(null)},onClick:s?y=>{y.stopPropagation(),i?.({type:"arrow",index:e,object:t})}:void 0,children:[K.jsx("line",{x1:c.shaftStart.x,y1:c.shaftStart.y,x2:c.shaftEnd.x,y2:c.shaftEnd.y,stroke:_,strokeWidth:g,strokeLinecap:"round",pointerEvents:"stroke"}),c.heads.map((y,x)=>K.jsx("polygon",{points:`${y.tip.x},${y.tip.y} ${y.leftWing.x},${y.leftWing.y} ${y.rightWing.x},${y.rightWing.y}`,fill:_},x))]})})},vOi=({circle:t,interactiveState:e,index:n})=>{const o=rh[n%rh.length];let{center:i,radius:r,fill:s,stroke:a,layer:A,step:c,label:l}=t;const{activeLayers:u,activeStep:g,realToScreen:h,onObjectClicked:d,setHoverTooltip:p}=e,[m,_]=ee.useState(!1),f=Bn(h,i),I=r*h.a;let C=s||o;return m&&(C=r9(.2,C),a=a&&r9(.2,a)),ee.useEffect(()=>{if(!(!m||!l))return p?.({text:l,x:f.x,y:f.y-I}),()=>{p?.(null)}},[m,l,f.x,f.y,I,p]),K.jsx("div",{style:{position:"absolute",left:f.x-I,top:f.y-I,width:I*2,height:I*2,borderRadius:"50%",backgroundColor:C,border:a?`2px solid ${a}`:"none",cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>_(!0),onMouseLeave:()=>{_(!1),p?.(null)},onClick:()=>d?.({type:"circle",index:n,object:t})})},wOi=({x:t,y:e,onSaveCamera:n,onLoadCamera:o,onClearCamera:i,onAddMark:r,onClearMarks:s,onClose:a})=>{const A=ee.useRef(null);ee.useEffect(()=>{const h=d=>{A.current&&!A.current.contains(d.target)&&a()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[a]);const c={position:"absolute",left:t,top:e,backgroundColor:"white",border:"1px solid #ccc",borderRadius:3,boxShadow:"0 2px 6px rgba(0,0,0,0.1)",padding:0,zIndex:1e3,minWidth:160,fontSize:"12px"},l={padding:"4px 8px",cursor:"pointer",userSelect:"none",lineHeight:"1.5"},u=h=>{h.currentTarget.style.backgroundColor="#f5f5f5"},g=h=>{h.currentTarget.style.backgroundColor=""};return K.jsxs("div",{ref:A,style:c,children:[K.jsx("div",{style:l,onClick:()=>{n(),a()},onMouseEnter:u,onMouseLeave:g,children:"Save Camera Position"}),K.jsx("div",{style:l,onClick:()=>{o(),a()},onMouseEnter:u,onMouseLeave:g,children:"Load Camera Position"}),K.jsx("div",{style:l,onClick:()=>{i(),a()},onMouseEnter:u,onMouseLeave:g,children:"Clear Saved Camera Position"}),K.jsx("div",{style:l,onClick:()=>{r(),a()},onMouseEnter:u,onMouseLeave:g,children:"Add Mark"}),K.jsx("div",{style:l,onClick:()=>{s(),a()},onMouseEnter:u,onMouseLeave:g,children:"Clear Marks"})]})},POi=({infiniteLine:t,index:e,interactiveState:n,size:o})=>{const{realToScreen:i,onObjectClicked:r,setHoverTooltip:s}=n,[a,A]=ee.useState(!1),c=obt(i,o.width,o.height),l=nbt(t,c);if(!l)return null;const[u,g]=l,h=Bn(i,u),d=Bn(i,g),p=t.strokeColor??rh[e%rh.length],m=(t.strokeWidth??1/Math.abs(i.a))*Math.abs(i.a),_=(h.x+d.x)/2,f=(h.y+d.y)/2;return K.jsx("div",{style:{position:"absolute",top:0,left:0,width:o.width,height:o.height,pointerEvents:"none"},children:K.jsxs("svg",{style:{width:o.width,height:o.height,pointerEvents:"none"},children:[K.jsx("line",{x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:"transparent",strokeWidth:m+10,pointerEvents:"stroke",onMouseEnter:()=>{A(!0),t.label&&s?.({text:t.label,x:_,y:f})},onMouseLeave:()=>{A(!1),s?.(null)},onClick:()=>r?.({type:"infinite-line",index:e,object:t})}),K.jsx("line",{x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:a?r9(.2,p):p,strokeWidth:m,strokeDasharray:t.strokeDash?typeof t.strokeDash=="string"?t.strokeDash:t.strokeDash.map(I=>I*Math.abs(i.a)).join(","):void 0,pointerEvents:"none"})]})})},MOi=({line:t,index:e,interactiveState:n,size:o,mousePosition:i})=>{const{activeLayers:r,activeStep:s,realToScreen:a,onObjectClicked:A,setHoverTooltip:c}=n,{points:l,layer:u,step:g,strokeColor:h,strokeWidth:d=1/a.a,strokeDash:p}=t,m=l.map(B=>Bn(a,B)),_=d*Math.abs(a.a),C=Math.max(_/2+3,6),y=C*2,x=ee.useMemo(()=>{if(!i)return!1;for(let B=0;B<m.length-1;B++)if(Zhn(i.x,i.y,m[B].x,m[B].y,m[B+1].x,m[B+1].y)<=C)return!0;return!1},[C,i,m]),E=h??rh[e%rh.length];return ee.useEffect(()=>{if(!(!x||!t.label||!i))return c?.({text:t.label,x:i.x,y:i.y}),()=>{c?.(null)}},[x,t.label,i?.x,i?.y,c]),K.jsx("div",{style:{position:"absolute",top:0,left:0,width:o.width,height:o.height,pointerEvents:"none"},children:K.jsxs("svg",{style:{width:o.width,height:o.height,overflow:"visible",pointerEvents:"none"},children:[K.jsx("polyline",{points:m.map(B=>`${B.x},${B.y}`).join(" "),stroke:"transparent",fill:"none",strokeWidth:y,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"stroke",onClick:x?()=>A?.({type:"line",index:e,object:t}):void 0}),K.jsx("polyline",{points:m.map(B=>`${B.x},${B.y}`).join(" "),stroke:x?r9(.2,E):E,fill:"none",strokeWidth:_,strokeDasharray:p?typeof p=="string"?p:`${p[0]*Math.abs(a.a)}, ${p[1]*Math.abs(a.a)}`:void 0,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"})]})})},DOi=({marker:t,transform:e})=>{const[n,o]=Bn(e,[t.x,t.y]);return K.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:900},children:K.jsxs("g",{transform:`translate(${n}, ${o})`,children:[K.jsx("circle",{r:7,fill:"rgba(255, 0, 0, 0.5)",stroke:"rgba(255, 0, 0, 0.8)",strokeWidth:2}),K.jsx("circle",{r:2,fill:"rgba(255, 0, 0, 0.9)"})]})})},NOi=({point:t,interactiveState:e,index:n})=>{const{color:o,label:i,layer:r,step:s}=t,{activeLayers:a,activeStep:A,realToScreen:c,onObjectClicked:l,setHoverTooltip:u}=e,[g,h]=ee.useState(!1),d=Bn(c,t),p=10,m=`${i?`${i}
`:""}x: ${t.x.toFixed(2)}, y: ${t.y.toFixed(2)}`;return ee.useEffect(()=>{if(g)return u?.({text:m,x:d.x,y:d.y-p/2}),()=>{u?.(null)}},[g,d.x,d.y,u,m]),K.jsx("div",{style:{position:"absolute",left:d.x-p/2,top:d.y-p/2,width:p,height:p,borderRadius:"50%",border:`2px solid ${g?r9(.2,o??rh[n%rh.length]):o??rh[n%rh.length]}`,cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),u?.(null)},onClick:()=>l?.({type:"point",index:n,object:t})})},ROi=({polygon:t,interactiveState:e,index:n})=>{const{points:o,fill:i,stroke:r,strokeWidth:s}=t,{realToScreen:a,onObjectClicked:A,setHoverTooltip:c}=e,[l,u]=ee.useState(!1),g=!!(o&&o.length>0),h=g?o.map(U=>Bn(a,U)):[],d=h.map(U=>U.x),p=h.map(U=>U.y),m=g?Math.min(...d):0,_=g?Math.max(...d):0,f=g?Math.min(...p):0,I=g?Math.max(...p):0,C=4,y=m-C,x=f-C,E=Math.max(_-m,0)+C*2,B=Math.max(I-f,0)+C*2,S=h.map(U=>({x:U.x-y,y:U.y-x})),Q=rh[n%rh.length],M=i!==void 0||r!==void 0?i||"transparent":Q,k=r,R=l?r9(.2,M):M,F=k?l?r9(.2,k):k:void 0,O=s===void 0?void 0:s*a.a;return ee.useEffect(()=>{if(!(!g||!l||!t.label))return c?.({text:t.label,x:(m+_)/2,y:x}),()=>{c?.(null)}},[g,l,_,m,t.label,c,x]),g?K.jsx("div",{style:{position:"absolute",top:x,left:y,width:E,height:B,pointerEvents:"none"},children:K.jsx("svg",{width:E,height:B,style:{display:"block"},children:K.jsx("polygon",{points:S.map(U=>`${U.x},${U.y}`).join(" "),fill:R,stroke:F??"none",strokeWidth:O,pointerEvents:"all",onMouseEnter:()=>u(!0),onMouseLeave:()=>{u(!1),c?.(null)},onClick:()=>A?.({type:"polygon",index:n,object:t})})})}):null},TOi=({rect:t,interactiveState:e,index:n})=>{const o=rh[n%rh.length];let{fill:i,stroke:r}=t;const{activeLayers:s,activeStep:a,realToScreen:A,onObjectClicked:c,setHoverTooltip:l}=e,[u,g]=ee.useState(!1),h=VQe(t,A);let p=i!==void 0||r!==void 0?i||"transparent":o;return u&&(p=r9(.2,p),r=r9(.2,r)),ee.useEffect(()=>{if(!(!u||!t.label))return l?.({text:t.label,x:h.center.x,y:h.center.y-h.height/2}),()=>{l?.(null)}},[u,h.center.x,h.center.y,h.height,t.label,l]),K.jsx("div",{style:{position:"absolute",left:h.center.x,top:h.center.y,width:h.width,height:h.height,transform:"translate(-50%, -50%)",pointerEvents:"none"},children:K.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:p,border:r?`2px solid ${u?r9(.2,r):r}`:"none",boxSizing:"border-box",cursor:"pointer",transition:"border-color 0.2s",transformOrigin:"center",transform:`rotate(${h.angleDegrees}deg)`,pointerEvents:"auto"},onMouseEnter:()=>g(!0),onMouseLeave:()=>{g(!1),l?.(null)},onClick:()=>c?.({type:"rect",index:n,object:t})})})},kOi=({textObj:t,interactiveState:e,index:n})=>{const{realToScreen:o,onObjectClicked:i}=e,{x:r,y:s,text:a,color:A,fontSize:c,anchorSide:l}=t,u=Bn(o,{x:r,y:s}),h={top_left:"translate(0%, 0%)",top_center:"translate(-50%, 0%)",top_right:"translate(-100%, 0%)",center_left:"translate(0%, -50%)",center:"translate(-50%, -50%)",center_right:"translate(-100%, -50%)",bottom_left:"translate(0%, -100%)",bottom_center:"translate(-50%, -100%)",bottom_right:"translate(-100%, -100%)"}[l??"center"];return K.jsx("div",{style:{position:"absolute",left:u.x,top:u.y,transform:h,color:A||"black",fontSize:c??12,whiteSpace:"pre",cursor:"default"},onClick:()=>i?.({type:"text",index:n,object:t}),children:a})},epn=({text:t})=>K.jsx("div",{style:{background:"white",border:"1px solid #ccc",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",borderRadius:"4px",padding:"4px 8px",fontSize:"12px",minWidth:"120px",maxWidth:"300px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",zIndex:100},children:t}),y4=5,FOi=(t,e)=>ee.useMemo(()=>(n,o)=>{const i=Bn(t,n),r=Bn(t,o),s=-y4,a=e.width+y4,A=-y4,c=e.height+y4;if(i.x>=s&&i.x<=a&&i.y>=A&&i.y<=c||r.x>=s&&r.x<=a&&r.y>=A&&r.y<=c)return!0;const l=(u,g,h,d)=>{const p=(g.x-u.x)*(d.y-h.y)-(g.y-u.y)*(d.x-h.x);if(p===0)return!1;const m=((d.y-h.y)*(d.x-u.x)+(h.x-d.x)*(d.y-u.y))/p,_=((u.y-g.y)*(d.x-u.x)+(g.x-u.x)*(d.y-u.y))/p;return m>=0&&m<=1&&_>=0&&_<=1};return l(i,r,{x:s,y:A},{x:a,y:A})||l(i,r,{x:a,y:A},{x:a,y:c})||l(i,r,{x:s,y:c},{x:a,y:c})||l(i,r,{x:s,y:A},{x:s,y:c})},[t,e]),LOi=(t,e)=>ee.useMemo(()=>n=>{const o=Bn(t,n);return o.x>=-y4&&o.x<=e.width+y4&&o.y>=-y4&&o.y<=e.height+y4},[t,e]),HOi=({isPointOnScreen:t,doesLineIntersectViewport:e,filterLayerAndStep:n})=>ee.useMemo(()=>o=>{if(!n(o))return!1;if(o.points.some(i=>t(i)))return!0;for(let i=0;i<o.points.length-1;i++)if(e(o.points[i],o.points[i+1]))return!0;return!!(o.points.length>2&&o.closed&&e(o.points[o.points.length-1],o.points[0]))},[t,e,n]),OOi=({isPointOnScreen:t,filterLayerAndStep:e})=>ee.useMemo(()=>n=>e(n)?t(n):!1,[t,e]),GOi=({realToScreen:t,isPointOnScreen:e,doesLineIntersectViewport:n,filterLayerAndStep:o})=>ee.useMemo(()=>i=>{if(!o(i))return!1;const{center:r}=i,[s,a,A,c]=abt(i,t);return e(r)||e(s)||e(a)||e(A)||e(c)?!0:n(s,a)||n(a,A)||n(A,c)||n(c,s)},[t,e,n,o]),YOi=({isPointOnScreen:t,filterLayerAndStep:e,realToScreen:n,size:o})=>ee.useMemo(()=>i=>{if(!e(i))return!1;const{center:r,radius:s}=i;if(t(r)||t({x:r.x+s,y:r.y})||t({x:r.x-s,y:r.y})||t({x:r.x,y:r.y+s})||t({x:r.x,y:r.y-s}))return!0;const a=Bn(n,r),A=Math.abs(n.a),c=s*A,l=-y4,u=o.width+y4,g=-y4,h=o.height+y4;if(a.x>=l&&a.x<=u&&(Math.abs(a.y-g)<=c||Math.abs(a.y-h)<=c)||a.y>=g&&a.y<=h&&(Math.abs(a.x-l)<=c||Math.abs(a.x-u)<=c))return!0;const d=(m,_)=>{const f=a.x-m,I=a.y-_;return f*f+I*I},p=c*c;return d(l,g)<=p||d(u,g)<=p||d(l,h)<=p||d(u,h)<=p},[t,e,n,o]),UOi=({isPointOnScreen:t,filterLayerAndStep:e})=>ee.useMemo(()=>n=>e(n)?t({x:n.x,y:n.y}):!1,[t,e]),KOi=({isPointOnScreen:t,doesLineIntersectViewport:e})=>ee.useMemo(()=>n=>{const o=jW(n),{shaftStart:i,shaftEnd:r,heads:s}=o;return t(i)||t(r)||s.some(A=>t(A.tip)||t(A.leftWing)||t(A.rightWing)||t(A.base))?!0:[[i,r],...s.flatMap(A=>[[A.base,A.leftWing],[A.leftWing,A.tip],[A.tip,A.rightWing],[A.rightWing,A.base]])].some(([A,c])=>e(A,c))},[t,e]),VOi=({isPointOnScreen:t,doesLineIntersectViewport:e,filterLayerAndStep:n})=>ee.useMemo(()=>o=>{if(!n(o)||!o.points||o.points.length===0)return!1;if(o.points.some(i=>t(i)))return!0;for(let i=0;i<o.points.length;i++){const r=o.points[i],s=o.points[(i+1)%o.points.length];if(e(r,s))return!0}return!1},[t,e,n]),zOi=1e3,JOi=({graphics:t,onObjectClicked:e,objectLimit:n,height:o=600,stepMetadata:i,alwaysShowToolbar:r=!1})=>{const[s,a]=ee.useState(null),[A,c]=ee.useState(null),[l,u]=ee.useState(!0),[g,h]=ee.useState({width:600,height:o}),[d,p]=ee.useState(null),[m,_]=ee.useState(!1),[f,I]=ee.useState(null),[C,y]=ee.useState([]),[x,E]=ee.useState(null),[B,S]=ee.useState(null),Q=Array.from(new Set([...t.lines?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.infiniteLines?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.rects?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.polygons?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.points?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.texts?.map(Ct=>Ct.layer).filter(Boolean)??[],...t.circles?.map(Ct=>Ct.layer).filter(Boolean)??[]])),w=qhn(t),M=ee.useMemo(()=>{const Ct=xOi(t),Dt=Ct.maxX-Ct.minX,kt=Ct.maxY-Ct.minY;return{minX:Ct.minX-Dt/10,minY:Ct.minY-kt/10,maxX:Ct.maxX+Dt/10,maxY:Ct.maxY+kt/10}},[t]),k=ee.useCallback(()=>{const Ct=window.location.pathname,Dt=window.location.search;return`saved-camera-position-${Ct}${Dt}`},[]),R=ee.useCallback(()=>{const Ct=Math.max(M.maxX-M.minX,1),Dt=Math.max(M.maxY-M.minY,1),kt=Math.min(g.width/Ct,g.height/Dt);return Ad(pA(g.width/2,g.height/2),dC(kt,-kt),pA(-(M.maxX+M.minX)/2,-(M.maxY+M.minY)/2))},[g,M]),F=ee.useCallback(()=>{try{const Ct=localStorage.getItem(k());if(Ct)return JSON.parse(Ct)}catch(Ct){console.error("Error loading saved data:",Ct)}return null},[k]),O=ee.useCallback(()=>F()?.transform||null,[F]),{transform:U,ref:Y,setTransform:W}=Xun({initialTransform:R()});$hn(Y,Ct=>{h({width:Ct.contentRect.width,height:Ct.contentRect.height})}),ee.useEffect(()=>{const Ct=F();Ct?.markers&&y(Ct.markers)},[F]);const te=ee.useCallback(Ct=>{Ct.preventDefault();const Dt=Ct.clientX,kt=Ct.clientY,it=Ct.currentTarget.getBoundingClientRect(),Yt=it.left,pn=it.top,be=window.innerWidth,et=window.innerHeight,It=160,Bt=100;let mt=Dt-Yt,st=kt-pn;Dt>be/2&&(mt=mt-It),kt>et/2&&(st=st-Bt),p({x:mt,y:st,clientX:Dt,clientY:kt})},[]),j=ee.useCallback((Ct,Dt)=>{try{const kt={transform:Ct,markers:Dt};localStorage.setItem(k(),JSON.stringify(kt))}catch(kt){console.error("Error saving data:",kt)}},[k]),J=ee.useCallback(()=>{j(U,C)},[j,U,C]),oe=ee.useCallback(()=>{try{const Ct=O();Ct&&W(Ct)}catch(Ct){console.error("Error loading camera position:",Ct)}},[O,W]),ie=ee.useCallback(()=>{try{const Ct=R();j(Ct,C),W(Ct)}catch(Ct){console.error("Error clearing camera position:",Ct)}},[j,R,W,C]),ne=ee.useCallback(()=>{if(d)try{const Ct={x:d.clientX,y:d.clientY},Dt=Y.current?.getBoundingClientRect();if(Dt){const kt=Ct.x-Dt.left,it=Ct.y-Dt.top,Yt=bV(U),[pn,be]=Bn(Yt,[kt,it]),et={x:pn,y:be},It=[...C,et];y(It);const Bt=F();Bt?.transform&&j(Bt.transform,It)}}catch(Ct){console.error("Error adding marker:",Ct)}},[d,Y,U,C,j]),le=ee.useCallback(()=>{y([]);const Ct=F();Ct?.transform&&j(Ct.transform,[])},[F,j]),ge=ee.useCallback(Ct=>{switch(Ct.type){case"arrow":return[Ct.object.label,Ct.object.inlineLabel].filter(Boolean).join(`
`);case"text":return Ct.object.text??"";default:return Ct.object.label??""}},[]),_e=ee.useCallback(Ct=>{if(e?.(Ct),!m)return;const Dt=ge(Ct);I(Dt||null)},[m,ge,e]);ee.useEffect(()=>{if(!f)return;const Ct=Dt=>{Dt.key==="Escape"&&I(null)};return window.addEventListener("keydown",Ct),()=>{window.removeEventListener("keydown",Ct)}},[f]);const ue={activeLayers:s,activeStep:l?w:A,realToScreen:U,onObjectClicked:_e,setHoverTooltip:S},fe=w>0?i?.[l?w:A??-1]?.title:void 0,pe=LOi(U,g),ye=FOi(U,g),Me=Ct=>{if(s&&Ct.layer&&!s.includes(Ct.layer))return!1;const Dt=l?w:A;return!(Dt!==null&&Ct.step!==void 0&&Ct.step!==Dt)},ve=HOi({isPointOnScreen:pe,doesLineIntersectViewport:ye,filterLayerAndStep:Me}),he=OOi({isPointOnScreen:pe,filterLayerAndStep:Me}),Qe=GOi({realToScreen:U,isPointOnScreen:pe,doesLineIntersectViewport:ye,filterLayerAndStep:Me}),Pe=YOi({isPointOnScreen:pe,filterLayerAndStep:Me,realToScreen:U,size:g}),we=UOi({isPointOnScreen:pe,filterLayerAndStep:Me}),Te=KOi({isPointOnScreen:pe,doesLineIntersectViewport:ye}),Re=VOi({isPointOnScreen:pe,doesLineIntersectViewport:ye,filterLayerAndStep:Me}),Ee=(Ct,Dt)=>{if(!Ct)return[];const kt=Ct.map((it,Yt)=>({...it,originalIndex:Yt})).filter(Dt);return n?kt.slice(-n):kt},ke=ee.useMemo(()=>Ee(t.lines,ve).sort((Ct,Dt)=>(Ct.zIndex??0)-(Dt.zIndex??0)||Ct.originalIndex-Dt.originalIndex),[t.lines,ve,n]),Ce=ee.useMemo(()=>Ee(t.infiniteLines,Me),[t.infiniteLines,Me,n]),Le=ee.useMemo(()=>EOi(Ee(t.rects,Qe)),[t.rects,Qe,n]),Ye=ee.useMemo(()=>Ee(t.polygons,Re),[t.polygons,Re,n]),tt=ee.useMemo(()=>Ee(t.points,he),[t.points,he,n]),At=ee.useMemo(()=>Ee(t.circles,Pe),[t.circles,Pe,n]),at=ee.useMemo(()=>Ee(t.texts,we),[t.texts,we,n]),nt=ee.useMemo(()=>Ee(t.arrows,Te),[t.arrows,Te,n]),gt=Ce.length+ke.length+Le.length+Ye.length+tt.length+At.length+at.length+nt.length,bt=n&&gt>n;return K.jsxs("div",{children:[K.jsxs("div",{style:{margin:8,display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[Q.length>1&&K.jsxs("select",{value:s?s[0]:"",onChange:Ct=>{const Dt=Ct.target.value;a(Dt===""?null:[Dt])},style:{marginRight:8},children:[K.jsx("option",{value:"",children:"All Layers"}),Q.map(Ct=>K.jsx("option",{value:Ct,children:Ct},Ct))]}),w>0&&K.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8},children:["Step:",K.jsx("input",{type:"number",min:0,max:w,value:A??0,onChange:Ct=>{const Dt=parseInt(Ct.target.value);u(!1),c(Number.isNaN(Dt)?null:Dt)},disabled:A===null}),K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:A!==null,onChange:Ct=>{u(!1),c(Ct.target.checked?0:null)}}),"Filter by step"]}),K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:l,onChange:Ct=>{u(Ct.target.checked),c(null)}}),"Show last step"]}),bt&&K.jsxs("span",{style:{color:"red",fontSize:"12px"},children:["Display limited to ",n," objects. Received:"," ",gt,"."]})]}),K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:m,onChange:Ct=>{const Dt=Ct.target.checked;_(Dt),Dt||I(null)}}),"Enable Object Interation"]}),w>0&&fe&&K.jsx("div",{style:{marginLeft:"auto",textAlign:"right"},children:fe})]}),K.jsxs("div",{ref:Y,style:{position:"relative",height:o,overflow:"hidden"},onMouseMove:Ct=>{const Dt=Y.current?.getBoundingClientRect();Dt&&E({x:Ct.clientX-Dt.left,y:Ct.clientY-Dt.top})},onMouseLeave:()=>E(null),onContextMenu:te,children:[K.jsxs(SOi,{transform:U,children:[nt.map(Ct=>K.jsx(QOi,{arrow:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),Ce.map(Ct=>K.jsx(POi,{infiniteLine:Ct,index:Ct.originalIndex,interactiveState:ue,size:g},Ct.originalIndex)),ke.map(Ct=>K.jsx(MOi,{line:Ct,index:Ct.originalIndex,interactiveState:ue,size:g,mousePosition:x},Ct.originalIndex)),Le.map(Ct=>K.jsx(TOi,{rect:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),Ye.map(Ct=>K.jsx(ROi,{polygon:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),At.map(Ct=>K.jsx(vOi,{circle:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),at.map(Ct=>K.jsx(kOi,{textObj:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),tt.map(Ct=>K.jsx(NOi,{point:Ct,index:Ct.originalIndex,interactiveState:ue},Ct.originalIndex)),K.jsx(FT.SuperGrid,{stringifyCoord:(Ct,Dt)=>`${Ct.toFixed(2)}, ${Dt.toFixed(2)}`,width:g.width,height:g.height,transform:U})]}),C.map((Ct,Dt)=>K.jsx(DOi,{marker:Ct,index:Dt,transform:U},Dt)),B&&K.jsx("div",{style:{position:"absolute",left:B.x,top:B.y-8,transform:"translate(-50%, -100%)",pointerEvents:"none",zIndex:zOi},children:K.jsx(epn,{text:B.text})}),d&&K.jsx(wOi,{x:d.x,y:d.y,onSaveCamera:J,onLoadCamera:oe,onClearCamera:ie,onAddMark:ne,onClearMarks:le,onClose:()=>p(null)}),f&&K.jsx(Xhn,{label:f,onClose:()=>{I(null)}})]})]})};function WOi(t,{showLastStep:e,activeStep:n,maxStep:o}){const i=e?o:n;return i===null?t:{...t,points:t.points?.filter(s=>s.step===void 0||s.step===i),lines:t.lines?.filter(s=>s.step===void 0||s.step===i),infiniteLines:t.infiniteLines?.filter(s=>s.step===void 0||s.step===i),rects:t.rects?.filter(s=>s.step===void 0||s.step===i),polygons:t.polygons?.filter(s=>s.step===void 0||s.step===i),circles:t.circles?.filter(s=>s.step===void 0||s.step===i),texts:t.texts?.filter(s=>s.step===void 0||s.step===i)}}function jOi(t){const e=V5(t),n=e.maxX-e.minX,o=e.maxY-e.minY;return{minX:e.minX-n/10,minY:e.minY-o/10,maxX:e.maxX+n/10,maxY:e.maxY+o/10}}function $Oi({graphics:t,showLabelsByDefault:e=!0,showGrid:n=!0,height:o=500,width:i="100%",stepMetadata:r,alwaysShowToolbar:s=!1}){const a=ee.useRef(null),A=ee.useRef(null),[c,l]=ee.useState({width:600,height:600}),[u,g]=ee.useState(null),[h,d]=ee.useState(!0),[p,m]=ee.useState(!1),[_,f]=ee.useState(null),[I,C]=ee.useState(null),[y,x]=ee.useState(null),E=qhn(t),B=s||E>0||e,S=E>0?r?.[h?E:u??-1]?.title:void 0,Q=WOi(t,{activeStep:u,showLastStep:h,maxStep:E}),w=jOi(t),{transform:M,ref:k}=Xun({initialTransform:Ad(pA(c.width/2,c.height/2),dC(Math.min(c.width/(w.maxX-w.minX),c.height/(w.maxY-w.minY)),-Math.min(c.width/(w.maxX-w.minX),c.height/(w.maxY-w.minY))),pA(-(w.maxX+w.minX)/2,-(w.maxY+w.minY)/2))});$hn(A,j=>{l({width:j.contentRect.width,height:j.contentRect.height})});const R=()=>{a.current&&(a.current.width=c.width,a.current.height=c.height,fmo(Q,a.current,{transform:M,disableLabels:!0,hideInlineLabels:!0}),n&&F(a.current,M))},F=(j,J)=>{const oe=j.getContext("2d");if(!oe)return;oe.save(),oe.beginPath();const ie={x:-1e3,y:0},ne={x:1e3,y:0},le=O(ie,J),ge=O(ne,J);oe.moveTo(le.x,le.y),oe.lineTo(ge.x,ge.y);const _e={x:0,y:-1e3},ue={x:0,y:1e3},fe=O(_e,J),pe=O(ue,J);oe.moveTo(fe.x,fe.y),oe.lineTo(pe.x,pe.y),oe.strokeStyle="#aaa",oe.lineWidth=1,oe.stroke(),oe.beginPath(),oe.setLineDash([2,2]);const ye=10;for(let Me=-100;Me<=100;Me+=ye){if(Me===0)continue;const ve=O({x:Me,y:-100},J),he=O({x:Me,y:100},J);oe.moveTo(ve.x,ve.y),oe.lineTo(he.x,he.y)}for(let Me=-100;Me<=100;Me+=ye){if(Me===0)continue;const ve=O({x:-100,y:Me},J),he=O({x:100,y:Me},J);oe.moveTo(ve.x,ve.y),oe.lineTo(he.x,he.y)}oe.strokeStyle="#ddd",oe.stroke(),oe.restore()},O=(j,J)=>({x:J.a*j.x+J.c*j.y+J.e,y:J.b*j.x+J.d*j.y+J.f}),U=j=>{if(!a.current)return{label:null,overlayPoint:null};const J=a.current,oe=J.getBoundingClientRect(),ie=oe.width===0?1:J.width/oe.width,ne=oe.height===0?1:J.height/oe.height,le={x:j.clientX-oe.left,y:j.clientY-oe.top};return{label:mOi(Q,M,{x:le.x*ie,y:le.y*ne},{hitSlop:8}),overlayPoint:le}},Y=j=>{const{label:J,overlayPoint:oe}=U(j);f(J),C(J?oe:null)},W=()=>{f(null),C(null)},te=j=>{if(!p)return;const{label:J}=U(j);x(J)};return ee.useEffect(()=>{R()},[M,c,Q,n]),ee.useEffect(()=>{if(!y)return;const j=J=>{J.key==="Escape"&&x(null)};return window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}},[y]),K.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[B&&K.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[K.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:E>0&&K.jsxs(K.Fragment,{children:[K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:u!==null,onChange:j=>{g(j.target.checked?0:null)}}),"Filter by step"]}),K.jsx("input",{type:"number",min:0,max:E,value:u??0,onChange:j=>{const J=parseInt(j.target.value);d(!1),g(Number.isNaN(J)?0:Math.min(J,E))},disabled:u===null,style:{width:"60px"}}),K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:h,onChange:j=>{d(j.target.checked),g(null)}}),"Show last step"]})]})}),K.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:K.jsxs("label",{children:[K.jsx("input",{type:"checkbox",style:{marginRight:4},checked:p,onChange:j=>{const J=j.target.checked;m(J),J||x(null)}}),"Enable Object Interation"]})}),E>0&&S&&K.jsx("div",{style:{marginLeft:"auto",textAlign:"right"},children:S})]}),K.jsxs("div",{ref:j=>{A.current=j,k&&j&&(k.current=j)},style:{position:"relative",width:i,height:o,border:"1px solid #ccc",overflow:"hidden"},children:[K.jsx("canvas",{ref:a,onMouseMove:Y,onMouseLeave:W,onClick:te,style:{position:"absolute",top:0,left:0,width:i,height:o}}),_&&I&&K.jsx("div",{style:{position:"absolute",left:I.x,top:I.y-12,transform:"translate(-50%, -100%)",pointerEvents:"none"},children:K.jsx(epn,{text:_})}),y&&K.jsx(Xhn,{label:y,onClose:()=>{x(null)}})]})]})}var fee=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fee);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=fee(o));return e},qOi=({solver:t,className:e=""})=>{const[n,o]=ee.useState(!1),i=ee.useRef(null);ee.useEffect(()=>{const A=c=>{i.current&&!i.current.contains(c.target)&&o(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[]);const r=()=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${t.getSolverName()}`);return}const A=fee(t.getConstructorParams()),c=new Blob([JSON.stringify(A,null,2)],{type:"application/json"}),l=URL.createObjectURL(c),u=document.createElement("a");u.href=l,u.download=`${t.getSolverName()}_params.json`,u.click(),URL.revokeObjectURL(l)}catch(A){alert(`Error downloading params for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)},s=()=>{try{const A=fee(t.getConstructorParams()),c=t.getSolverName(),l=c==="SchematicTracePipelineSolver";let u;l?u=`import { PipelineDebugger } from "site/components/PipelineDebugger"
import type { InputProblem } from "lib/types/InputProblem"

const inputProblem: InputProblem = ${JSON.stringify(A,null,2)}

export default () => <PipelineDebugger inputProblem={inputProblem} />
`:u=`import { useMemo } from "react"
import { GenericSolverDebugger } from "../components/GenericSolverDebugger"
import { ${c} } from "lib/solvers/${c}/${c}"

export const inputProblem = ${JSON.stringify(A,null,2)}

export default () => {
  const solver = useMemo(() => {
    return new ${c}(inputProblem as any)
  }, [])
  return <GenericSolverDebugger solver={solver} />
}
`;const g=new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(g),d=document.createElement("a");d.href=h,d.download=`${c}.page.tsx`,d.click(),URL.revokeObjectURL(h)}catch(A){alert(`Error generating page.tsx for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)},a=()=>{try{const A=fee(t.getConstructorParams()),c=t.getSolverName(),l=`import { ${c} } from "lib/solvers/${c}/${c}"
import { test, expect } from "bun:test"

test("${c} should solve problem correctly", () => {
  const input = ${JSON.stringify(A,null,2)}
  
  const solver = new ${c}(input as any)
  solver.solve()

  expect(solver).toMatchSolverSnapshot(import.meta.path)
  
  // Add more specific assertions based on expected output
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
})
`,u=new Blob([l],{type:"text/plain"}),g=URL.createObjectURL(u),h=document.createElement("a");h.href=g,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(g)}catch(A){alert(`Error generating test.ts for ${t.getSolverName()}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.getSolverName()}`,children:t.getSolverName()}),n&&K.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},tpn=t=>t.activeSubSolver?[t,...tpn(t.activeSubSolver)]:[t],XOi=({solver:t})=>{const e=tpn(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(qOi,{solver:n})]},n.getSolverName()))})},ZOi=({solver:t,triggerRender:e,animationSpeed:n=25,renderer:o,onRendererChange:i,onAnimationSpeedChange:r,onDownloadVisualization:s,onSolverStarted:a,onSolverCompleted:A})=>{const[c,l]=ee.useReducer(B=>!B,!1),u=ee.useRef(void 0),g=ee.useRef(null),h="solver-debugger-last-iteration",[d,p]=ee.useState(null),m=ee.useRef(null),_=ee.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),f=()=>{const B=Math.max(1,n),S=n<1?Math.round(1/n):1;u.current=setInterval(()=>{if(t.solved||t.failed){u.current&&(clearInterval(u.current),u.current=void 0),l(),e(),A&&t.solved&&A(t);return}for(let Q=0;Q<S&&!(t.solved||t.failed);Q++)t.step();e()},B)},I=()=>{u.current&&(clearInterval(u.current),u.current=void 0)},C=()=>{!t.solved&&!t.failed&&(t.step(),e())},y=()=>{!t.solved&&!t.failed&&(a&&a(t),t.solve(),e(),A&&A(t))},x=()=>{c?(I(),l()):(l(),f())},E=()=>{if(t.solved||t.failed||c)return;g.current===null&&typeof window<"u"&&(g.current=window.localStorage.getItem(h));const B=window.prompt("Step until which iteration?",g.current??`${t.iterations}`);if(B===null)return;g.current=B,typeof window<"u"&&window.localStorage.setItem(h,B);const S=Number(B);if(!Number.isFinite(S)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<S&&!t.solved&&!t.failed;)t.step();e(),t.solved&&A&&A(t)};return ee.useEffect(()=>()=>{I()},[]),ee.useEffect(()=>{(t.solved||t.failed)&&c&&(I(),l())},[t.solved,t.failed,c]),ee.useEffect(()=>{c&&(I(),f())},[n,c]),ee.useEffect(()=>{if(typeof document>"u")return;const B=S=>{m.current&&!m.current.contains(S.target)&&p(null)};return document.addEventListener("mousedown",B),()=>{document.removeEventListener("mousedown",B)}},[]),K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsxs("div",{className:"flex items-center gap-2",ref:m,children:[K.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="renderer"?"open":"closed",children:"Renderer"}),d==="renderer"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(B=>K.jsxs("button",{type:"button",onClick:()=>{i(B),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B==="vector"?"Vector":"Canvas",o===B&&K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},B))})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="debug"?"open":"closed",children:"Debug"}),d==="debug"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:K.jsx("button",{type:"button",onClick:()=>{s(),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),K.jsxs("div",{className:"relative",children:[K.jsx("button",{type:"button",onClick:()=>p(d==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":d==="animation"?"open":"closed",children:"Animation"}),d==="animation"&&K.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:_.map(B=>K.jsxs("button",{type:"button",onClick:()=>{r(B.value),p(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[B.label,K.jsx("span",{className:"ml-auto text-xs text-slate-500",children:B.description}),n===B.value&&K.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},B.value))})]})]}),K.jsx(XOi,{solver:t})]})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.jsx("button",{onClick:C,disabled:t.solved||t.failed||c,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),K.jsx("button",{onClick:y,disabled:t.solved||t.failed||c,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),K.jsx("button",{onClick:x,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${c?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:c?"Stop":"Animate"}),K.jsx("button",{onClick:E,disabled:t.solved||t.failed||c,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},eGi=t=>t!==null&&"pipelineDef"in t&&Array.isArray(t.pipelineDef),tGi=(t,e,n)=>{const o=t.currentPipelineStageIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},nGi=(t,e)=>{const o=t.pipelineDef[e].solverName,i=tGi(t,e),r=t[o],s=t.firstIterationOfStage?.[o]??(e===t.currentPipelineStageIndex?t.iterations:null),a=t.iterations;let A=0;if(i==="Completed"){const g=t.pipelineDef[e+1],h=g?t.firstIterationOfStage?.[g.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnStage?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},oGi=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},iGi=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},npn=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"||t==null)return String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},rGi=t=>Object.entries(t).map(([e,n])=>`${e}: ${npn(n)}`).join(", "),sGi=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=rGi(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",npn(i)]},o))})]})},D$e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(D$e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=D$e(o));return e},aGi=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=D$e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},AGi=({expanded:t})=>K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${t?"rotate-90":""}`,children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),opn=t=>{let e=t;for(;e.activeSubSolver;)e=e.activeSubSolver;return e},ipn=({solver:t,onStepUntilPhase:e,onDownloadInput:n,isNested:o=!1,indentLevel:i=0,triggerRender:r})=>{const[s,a]=ee.useState(new Set),A=t.pipelineDef.map((m,_)=>nGi(t,_)),c=m=>{a(_=>{const f=new Set(_);return f.has(m)?f.delete(m):f.add(m),f})},l=m=>{e?.(m)},u=m=>{m.solverInstance&&(n?n(m.solverInstance,m.name):aGi(m.solverInstance,m.name))},g=m=>`${(m/1e3).toFixed(2)}s`,h=()=>{if(!t.solved&&!t.failed){const m=t.activeSubSolver;for(;!t.solved&&!t.failed&&(t.step(),!(t.activeSubSolver&&t.activeSubSolver!==m)););r?.()}},d=()=>{if(!t.solved&&!t.failed){const m=opn(t);for(;!t.solved&&!t.failed&&(t.step(),opn(t)===m););r?.()}},p=i*24;return K.jsxs("div",{className:o?"":"border-t border-gray-200",children:[!o&&K.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),K.jsxs("div",{className:"flex gap-2",children:[K.jsx("button",{onClick:d,disabled:t.solved||t.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),K.jsx("button",{onClick:h,disabled:t.solved||t.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[!o&&K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:A.map(m=>{const _=eGi(m.solverInstance),f=s.has(m.name);return K.jsxs(Fs.Fragment,{children:[K.jsxs("tr",{className:`border-b border-gray-100 ${m.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:p},children:[_?K.jsx("button",{onClick:()=>c(m.name),className:"text-gray-500 hover:text-gray-700",title:f?"Collapse":"Expand",children:K.jsx(AGi,{expanded:f})}):K.jsx("span",{className:"w-4"}),K.jsx("span",{className:"text-gray-400 w-6",children:String(m.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>l(m.name),disabled:m.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${m.name} completes`,children:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:m.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(oGi,{status:m.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:m.firstIteration!==null?m.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:m.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(iGi,{progress:m.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:g(m.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(sGi,{stats:m.stats})}),K.jsx("td",{className:"px-4 py-2",children:m.solverInstance?K.jsxs("button",{onClick:()=>u(m),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${m.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),K.jsx("span",{children:"Input"})]}):null})]}),_&&f&&K.jsx("tr",{children:K.jsx("td",{colSpan:8,className:"p-0",children:K.jsx(ipn,{solver:m.solverInstance,onStepUntilPhase:e,onDownloadInput:n,isNested:!0,indentLevel:i+1,triggerRender:r})})})]},m.name)})})]})})]})};function cGi({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,_)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof _=="number"&&(_<a&&(a=_),_>c&&(c=_))};for(const m of e)l(m.x,m.y);for(const m of n){const _=m.points??[];for(const f of _)l(f.x,f.y)}for(const m of o){const _=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(_,f),l(_+I,f+C)}for(const m of i){const _=m.x??0,f=m.y??0,I=m.radius??1;l(_-I,f-I),l(_+I,f+I)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const u=10,g=s-u,h=a-u,d=Math.max(1,A-s+2*u),p=Math.max(1,c-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${g} ${h} ${d} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,_)=>K.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${_}`)),n.map((m,_)=>K.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${_}`)),i.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${_}`)),e.map((m,_)=>K.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${_}`)),r.map((m,_)=>K.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${_}`))]})}var lGi=class extends Fs.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},uGi=({solver:t,createSolver:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ee.useReducer(f=>f+1,0),[a]=ee.useState(()=>{if(e)return e();if(!t)throw new Error("GenericSolverDebugger requires solver or createSolver");return t}),[A,c]=ee.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[l,u]=ee.useState(n),g=ee.useMemo(()=>{try{return a.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(f){return console.error("Visualization error:",f),{points:[],lines:[],rects:[],circles:[]}}},[a,r]),h=ee.useMemo(()=>(g.rects?.length||0)===0&&(g.lines?.length||0)===0&&(g.points?.length||0)===0&&(g.circles?.length||0)===0,[g]);ee.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const f=document.createElement("script");f.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(f)}},[]),ee.useEffect(()=>{u(n)},[n]);const d=a.pipelineDef!==void 0,p=f=>{const I=a;if(!a.solved&&!a.failed){for(;!a.solved&&!a.failed&&I.currentPipelineStageIndex<=I.pipelineDef.findIndex(C=>C.solverName===f);)a.step();s()}},m=()=>{const f=JSON.stringify(g,null,2),I=new Blob([f],{type:"application/json"}),C=URL.createObjectURL(I),y=document.createElement("a");y.download="visualization.json",y.href=C,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(C)},_=f=>{c(f),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",f)};return K.jsxs("div",{children:[K.jsx(ZOi,{solver:a,triggerRender:s,animationSpeed:l,renderer:A,onRendererChange:_,onAnimationSpeedChange:u,onDownloadVisualization:m,onSolverStarted:o,onSolverCompleted:i}),h?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(lGi,{fallback:K.jsx(cGi,{graphics:g}),children:A==="canvas"?K.jsx($Oi,{graphics:g}):K.jsx(JOi,{graphics:g})}),d&&K.jsx(ipn,{solver:a,onStepUntilPhase:p,triggerRender:s})]})};const gGi=()=>{ee.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},dGi=1e3,kE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},dGi)},N$e=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},hGi=t=>{const e=t.solverConstructorArgs??[t.solverParams];if(t.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||e.length!==1)return e;const[{input:n,options:o}]=e;return[n,o]},t8="https://github.com/tscircuit/tscircuit-autorouter/issues/new",rpn="https://github.com/tscircuit/copper-pour-solver/issues/new",spn="https://github.com/tscircuit/calculate-packing/issues/new",pGi="https://github.com/tscircuit/matchpack/issues/new",apn="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",mGi={PackSolver2:spn,LayoutPipelineSolver:pGi,AutoroutingPipelineSolver:t8,AssignableAutoroutingPipeline2:t8,AssignableAutoroutingPipeline3:t8,AutoroutingPipeline1_OriginalUnravel:t8,AutoroutingPipelineSolver3_HgPortPointPathing:t8,AutoroutingPipelineSolver4:t8,AutoroutingPipelineSolver5:t8,AutoroutingPipelineSolver7_MultiGraph:t8,AutoroutingPipelineSolver8:t8,CopperPourPipelineSolver:rpn,SchematicTracePipelineSolver:apn},_Gi=t=>t.toLowerCase().includes("pack")?mln:t.toLowerCase().includes("rout")?fln:rbi,Apn=t=>{const e=mGi[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?t8:n.includes("schematic")&&n.includes("trace")?apn:n.includes("copperpour")?rpn:n.includes("pack")?spn:null},fGi=t=>`${N$e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,cpn=t=>{kE(JSON.stringify(t.solverParams,null,2),{fileName:fGi(t),mimeType:"application/json"})},IGi=({solverEvent:t})=>{const e=Apn(t.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[K.jsxs(fA,{type:"button",variant:"outline",size:"sm",onClick:()=>cpn(t),children:[K.jsx(mZ,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?K.jsx(fA,{asChild:!0,variant:"outline",size:"sm",children:K.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[K.jsx(Bme,{className:"rf-w-4 rf-h-4"}),"Report"]})}):K.jsxs(fA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[K.jsx(Bme,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},CGi=({solverEvent:t})=>{const e=Apn(t.solverName);return e?K.jsx(fA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:K.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:K.jsx(Bme,{className:"rf-w-4 rf-h-4"})})}):K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:K.jsx(Bme,{className:"rf-w-4 rf-h-4"})})},yGi=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);gGi();const o=ee.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=mMe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(mMe).join(", ")}`,classFound:!1};try{return{instance:new a(...hGi(r)),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return K.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=_Gi(A.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[K.jsx(IGi,{solverEvent:r}),K.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:K.jsx(bE,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(uGi,{solver:s.instance})})})]}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(CGi,{solverEvent:r}),K.jsx(fA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>cpn(r),children:K.jsx(mZ,{className:"rf-w-4 rf-h-4"})})]})]}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},xGi=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],EGi=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function BGi(t,e){let n=-1,o=-1;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.status!=="running"||r.subcircuit_id!==e.subcircuit_id||r.componentDisplayName!==e.componentDisplayName)continue;let s=0,a=!1;for(const A of EGi)if(!(r[A]===void 0||e[A]===void 0)){if(r[A]!==e[A]){a=!0;break}s++}!a&&s>o&&(n=i,o=s)}return n}function bGi(t,e){const n=Object.fromEntries(xGi.filter(s=>e[s]!==void 0).map(s=>[s,e[s]])),o=e.simpleRouteJson?structuredClone(e.simpleRouteJson):void 0,i=e.type==="autorouting:start"?-1:BGi(t,e),r={...i===-1?{id:`autorouting_phase_${t.length+1}`}:t[i],...n,status:e.type==="autorouting:start"?"running":e.type==="autorouting:end"?"complete":"error",...e.type==="autorouting:start"?{startSimpleRouteJson:o}:e.type==="autorouting:end"?{endSimpleRouteJson:o}:{errorSimpleRouteJson:o,error:e.error?{...e.error}:void 0}};return i===-1?[...t,r]:t.map((s,a)=>a===i?r:s)}const SGi=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),QGi=new Set(["tscircuit","default","auto","auto_local"]);function vGi(t){if(t==="FanoutSolver")return"Fanout";if(t==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const e=t.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(e)return`Pipeline${e[1]}`;const n=t.match(/^AssignableAutoroutingPipeline(\d+)$/);return n?`Assignable${n[1]}`:t}function wGi(t){const e=t.autorouterName?.trim(),n=e?.replace(/-/g,"_"),o=n&&SGi.get(n);if(o)return o;if(n&&!QGi.has(n))return e;const i=t.solverName?.trim();if(i)return vGi(i);const r=t.autorouterVersion?.trim();if(r){const s=r.match(/^beta[_-]pipeline(\d+)$/);return s?`Pipeline${s[1]}`:r==="latest"?"default":r}return e?"default":"Unknown"}const R$e="#fbbf24";function PGi(t){const e=t.endSimpleRouteJson?.traces??[],n=new Set(e.flatMap(i=>[i.pcb_trace_id,i.__replaces_pcb_trace_id].filter(r=>r!==void 0)));return[...(t.startSimpleRouteJson?.traces??[]).filter(i=>!n.has(i.pcb_trace_id)),...e]}function lpn(t){const e=new Map((t.startSimpleRouteJson?.traces??[]).map(n=>[n.pcb_trace_id,n]));return(t.endSimpleRouteJson?.traces??[]).filter(n=>{const o=e.get(n.pcb_trace_id);return!o||!!n.__replaces_pcb_trace_id&&n.__replaces_pcb_trace_id!==o.__replaces_pcb_trace_id||JSON.stringify(o.route)!==JSON.stringify(n.route)}).map(n=>n.pcb_trace_id)}function MGi(t,e){return{outer_diameter:t.via_diameter??e.minViaPadDiameter??e.min_via_pad_diameter??e.minViaDiameter??.6,hole_diameter:t.via_hole_diameter??e.minViaHoleDiameter??e.min_via_hole_diameter??.3}}function upn(t,e){const n=[];for(const a of t.route)a.route_type==="wire"?n.push({...a,layer:a.layer}):a.route_type==="via"?n.push({route_type:"via",x:a.x,y:a.y,from_layer:a.from_layer,to_layer:a.to_layer,...MGi(a,e)}):a.route_type==="through_obstacle"&&n.push({route_type:"through_pad",start:{...a.start},end:{...a.end},width:a.width,start_layer:a.from_layer,end_layer:a.to_layer,pcb_smtpad_id:a.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:a.circuitJsonMetadata?.pcb_plated_hole_id});const o=a=>{let A=-1,c=Number.POSITIVE_INFINITY;return n.forEach((l,u)=>{if(l.route_type!=="wire")return;const g=Math.hypot(l.x-a.x,l.y-a.y);g<c&&(c=g,A=u)}),A},i=t.route.filter(a=>a.route_type==="jumper").map(a=>[o(a.start),o(a.end)].sort((A,c)=>A-c)).filter(([a,A])=>a>=0&&A>a).sort(([a],[A])=>a-A),r=[];let s=0;for(const[a,A]of i)a>=s&&r.push(n.slice(s,a+1)),s=Math.max(s,A);return s<n.length&&r.push(n.slice(s)),r}function DGi(t){const e=[],n=[],o=t.endSimpleRouteJson;if(!o)return{lines:e,circles:n};const i=new Set(lpn(t));for(const r of o.traces??[])if(i.has(r.pcb_trace_id))for(const s of upn(r,o)){let a;for(const A of s){if(A.route_type==="through_pad"){a={...A.end,layer:A.end_layer,width:A.width};continue}const c=A.route_type==="wire"?A.layer:A.from_layer;a&&a.layer===c&&(a.x!==A.x||a.y!==A.y)&&e.push({points:[{x:a.x,y:a.y},{x:A.x,y:A.y}],strokeWidth:A.route_type==="wire"?A.width:a.width,strokeColor:R$e,layer:c}),A.route_type==="via"&&n.push({center:{x:A.x,y:A.y},radius:A.outer_diameter/2,stroke:R$e,fill:"transparent"}),a={x:A.x,y:A.y,layer:A.route_type==="wire"?A.layer:A.to_layer,width:A.route_type==="wire"?A.width:a?.width??o.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:e,circles:n}}function NGi(t){const e=JSON.stringify(t);let n=2166136261;for(let o=0;o<e.length;o++)n=Math.imul(n^e.charCodeAt(o),16777619);return(n>>>0).toString(36)}const RGi=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function TGi(t,e,n){const o=n==="input"?e.startSimpleRouteJson??e.errorSimpleRouteJson:e.endSimpleRouteJson,i=t.filter(c=>!RGi.has(c.type)&&!c.type.endsWith("_error")&&!c.type.endsWith("_warning"));if(!o)return i;const r=n==="input"?o.traces??[]:PGi(e),s=new Set(t.filter(c=>c.type==="source_trace").map(c=>c.source_trace_id)),a=["top",...Array.from({length:Math.max(0,o.layerCount-2)},(c,l)=>`inner${l+1}`),...o.layerCount>1?["bottom"]:[]],A=[];for(const c of r){const u=o.connections.find(h=>h.name===c.connection_name||h.source_trace_id===c.connection_name)?.source_trace_id??c.connection_name??"",g=upn(c,o);for(const[h,d]of g.entries()){const p={type:"pcb_trace",pcb_trace_id:`${e.id}_${n}_${c.pcb_trace_id}_${h}_${NGi(d)}`,subcircuit_id:e.subcircuit_id??void 0,source_trace_id:s.has(u)?u:void 0,route:d};A.push(p);for(const[m,_]of d.entries()){if(_.route_type!=="via")continue;const f=a.indexOf(_.from_layer),I=a.indexOf(_.to_layer),C={type:"pcb_via",pcb_via_id:`${p.pcb_trace_id}_via_${m}`,pcb_trace_id:p.pcb_trace_id,subcircuit_id:e.subcircuit_id??void 0,x:_.x,y:_.y,outer_diameter:_.outer_diameter,hole_diameter:_.hole_diameter,layers:f>=0&&I>=0?a.slice(Math.min(f,I),Math.max(f,I)+1):[_.from_layer,_.to_layer]};A.push(C)}}}return[...i,...A]}const T$e=(t,e)=>t.phaseName||`Phase ${t.phaseOrdinal??e+1}`,gpn=t=>t.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||t.componentDisplayName||t.subcircuit_id||"Board",dpn=t=>t.startSimpleRouteJson??t.endSimpleRouteJson??t.errorSimpleRouteJson,kGi={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},FGi=({circuitJson:t,phases:e=[],isRunning:n=!1})=>{const[o,i]=ee.useState(null),[r,s]=ee.useState("output"),[a,A]=ee.useState(!0),[c,l]=ee.useState(!1),u=ee.useRef(null),[g,h]=ee.useState(480),d=o?e.findIndex(R=>R.id===o.id&&dpn(R)===dpn(o)):-1,p=d<0?e.length-1:d,m=e[p],_=d<0,f=!!m?.endSimpleRouteJson,I=m?.startSimpleRouteJson??m?.errorSimpleRouteJson,C=!!I,y=r==="output"&&!f?"input":r==="input"&&!C?"output":r,x=y==="input"?I:m?.endSimpleRouteJson,E=ee.useMemo(()=>!m||!x?null:TGi(t??[],m,y),[t,m,x,y]),B=ee.useMemo(()=>m&&y==="output"&&a?DGi(m):{lines:[],circles:[]},[m,y,a]);if(ee.useLayoutEffect(()=>{const R=u.current;if(!R)return;const F=()=>h(Math.max(360,R.clientHeight));F();const O=new ResizeObserver(F);return O.observe(R),()=>O.disconnect()},[!!m]),!m)return K.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[K.jsx(fln,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),K.jsx("h3",{className:"rf-text-base rf-font-medium",children:n?"Waiting for autorouting":"No autorouting captures"}),K.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:n?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const S=T$e(m,p),Q=m.status==="running"&&n,w=!f,M=I?.connections.length,k=E?.filter(R=>R.type==="pcb_trace").length??0;return K.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[K.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[K.jsx("span",{children:"Routing phases"}),K.jsx("span",{children:e.length})]}),K.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:e.map((R,F)=>{const O=lpn(R).length,U=R.endSimpleRouteJson?`${O} ${O===1?"trace":"traces"} routed`:R.status==="error"?"Failed":R.status==="running"&&n?"Routing…":"No output";return K.jsxs("button",{type:"button","aria-pressed":F===p,title:`${gpn(R)} · ${U}`,onClick:()=>i(R),className:Oi("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",F===p?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[K.jsx("span",{className:Oi("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",F===p?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:F+1}),K.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[K.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:T$e(R,F),children:T$e(R,F)}),R.status==="complete"?K.jsx(CS,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):R.status==="error"?K.jsx(oWe,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):n?K.jsx(SE,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),K.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[wGi(R)," · ",U]})]})]},R.id)})})]}),K.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[K.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[S,K.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[p+1," of ",e.length]})]}),n&&K.jsx("button",{type:"button",onClick:()=>i(null),disabled:_,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:_?"Following latest":"Follow latest"}),K.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(R=>K.jsx("button",{type:"button","aria-pressed":y===R,disabled:R==="input"?!C:!f,onClick:()=>s(R),className:Oi("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",y===R?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:R==="input"?"Input":"Output"},R))})]}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[K.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx("input",{type:"checkbox",checked:a,disabled:y!=="output",onChange:R=>A(R.target.checked),className:"rf-accent-blue-600"}),K.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:R$e}}),"Highlight changes (all layers)"]}),K.jsxs("span",{children:[y==="input"?"Before this phase":"After this phase"," ","· ",k," traces"]})]}),w&&K.jsx("div",{className:Oi("rf-border-y rf-px-4 rf-py-2 rf-text-xs",m.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:m.status==="error"?`Routing failed: ${m.error?.message||"No output was captured."}`:Q?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),K.jsx("div",{ref:u,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:E?K.jsx(S$e,{circuitJson:E,height:g,allowEditing:!1,clickToInteractEnabled:!1,initialState:kGi,debugGraphics:B}):K.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[K.jsxs("span",{children:[M===void 0?"Input unavailable":`${M} input connections`,` · ${gpn(m)}`]}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[K.jsxs("button",{type:"button",disabled:!x,onClick:()=>kE(JSON.stringify(x,null,2),{fileName:`${m.id}-${y}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[K.jsx(mZ,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),K.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"rf-flex rf-items-center rf-gap-1",children:[K.jsx(bT,{className:Oi("rf-h-3 rf-w-3",c&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),c&&K.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${S} ${y} SRJ`,children:x?JSON.stringify(x,null,2):"No snapshot captured."})]})]})},hpn=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{dG.captureException(o)}catch{}}},[t,e]),ee.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{dG.captureException(i,{error_type:o.type})}catch{}}},[n])},ppn=t=>{ee.useEffect(()=>{try{bUo(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},mpn="0.0.2886",LGi={version:mpn},pfe=pFt()(mFt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),HGi=t=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(null),[r,s]=ee.useState(""),[a,A]=OO("eval-version-selection",null),c=pfe(h=>h.setLastRunEvalVersion),l=pfe(h=>h.lastRunEvalVersion);return ee.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(p=>p!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),ee.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:ee.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},OGi=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=ee.useState(""),[s,a]=ee.useState("");if(!o)return null;const A=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=u=>{u.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return K.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:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.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:u=>a(u.target.value),onKeyDown:l}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),c&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.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:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},GGi=t=>{const e=ee.useRef(null),n=md(o=>o.recentEvents);ee.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var YGi=Object.defineProperty,MS=(t,e)=>YGi(t,"name",{value:e,configurable:!0}),UGi="AlertDialog",[KGi,Pmr]=Nx(UGi,[Y0n]),DS=Y0n(),VGi=MS(t=>{const{__scopeAlertDialog:e,...n}=t,o=DS(e);return K.jsx(r_e,{...o,...n,modal:!0})},"AlertDialog");ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=DS(o);return K.jsx(iwi,{...r,...i,ref:n})},"AlertDialogTrigger"));var zGi=MS(t=>{const{__scopeAlertDialog:e,...n}=t,o=DS(e);return K.jsx(s_e,{...o,...n})},"AlertDialogPortal"),JGi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=DS(o);return K.jsx(wZ,{...r,...i,ref:n})},"AlertDialogOverlay")),WGi="AlertDialogContent",[jGi,$Gi]=KGi(WGi),qGi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=DS(o),a=ee.useRef(null),A=$A(n,a),c=ee.useRef(null);return K.jsx(jGi,{scope:o,cancelRef:c,children:K.jsx(MZ,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:ar(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),XGi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=DS(o);return K.jsx(a_e,{...r,...i,ref:n})},"AlertDialogTitle")),ZGi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=DS(o);return K.jsx(A_e,{...r,...i,ref:n})},"AlertDialogDescription")),eYi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=DS(o);return K.jsx(VWe,{...r,...i,ref:n})},"AlertDialogAction")),tYi="AlertDialogCancel",nYi=ee.forwardRef(MS(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=$Gi(tYi,o),s=DS(o),a=$A(n,r);return K.jsx(VWe,{...s,...i,ref:a})},"AlertDialogCancel")),oYi=VGi,iYi=zGi,_pn=JGi,fpn=qGi,Ipn=eYi,Cpn=nYi,ypn=XGi,xpn=ZGi;const Epn=oYi,rYi=iYi,Bpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(_pn,{className:Oi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));Bpn.displayName=_pn.displayName;const k$e=ee.forwardRef(({className:t,...e},n)=>K.jsxs(rYi,{children:[K.jsx(Bpn,{}),K.jsx(fpn,{ref:n,className:Oi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));k$e.displayName=fpn.displayName;const F$e=({className:t,...e})=>K.jsx("div",{className:Oi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});F$e.displayName="AlertDialogHeader";const L$e=({className:t,...e})=>K.jsx("div",{className:Oi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});L$e.displayName="AlertDialogFooter";const H$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(ypn,{ref:n,className:Oi("rf-text-lg rf-font-semibold",t),...e}));H$e.displayName=ypn.displayName;const O$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(xpn,{ref:n,className:Oi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));O$e.displayName=xpn.displayName;const sYi=ee.forwardRef(({className:t,...e},n)=>K.jsx(Ipn,{ref:n,className:Oi(gU(),t),...e}));sYi.displayName=Ipn.displayName;const G$e=ee.forwardRef(({className:t,...e},n)=>K.jsx(Cpn,{ref:n,className:Oi(gU({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));G$e.displayName=Cpn.displayName;var aYi=Object.defineProperty,NS=(t,e)=>aYi(t,"name",{value:e,configurable:!0}),Y$e="Checkbox",[AYi,Mmr]=Nx(Y$e),[cYi,U$e]=AYi(Y$e);function bpn(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:u}=t,[g,h]=DB({prop:n,defaultProp:i??!1,onChange:A,caller:Y$e}),[d,p]=ee.useState(null),[m,_]=ee.useState(null),f=ee.useRef(!1),[I,C]=ee.useReducer(E=>E+1,0),y=d?!!s||!!d.closest("form"):!0,x={checked:g,disabled:r,setChecked:h,control:d,setControl:p,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:f,userInteractionCount:I,onUserInteraction:C,required:c,defaultChecked:RS(i)?!1:i,isFormControl:y,bubbleInput:m,setBubbleInput:_};return K.jsx(cYi,{scope:e,...x,children:Qpn(u)?u(x):o})}NS(bpn,"CheckboxProvider");var lYi="CheckboxTrigger",uYi=ee.forwardRef(NS(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:u,setChecked:g,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:p,bubbleInput:m}=U$e(lYi,e),_=$A(r,u),f=ee.useRef(c);return ee.useEffect(()=>{const I=s?.form;if(I){const C=NS(()=>g(f.current),"reset");return I.addEventListener("reset",C),()=>I.removeEventListener("reset",C)}},[s,g]),K.jsx(Na.button,{type:"button",role:"checkbox","aria-checked":RS(c)?"mixed":c,"aria-required":l,"data-state":K$e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:_,onKeyDown:ar(n,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:ar(o,I=>{d(),g(C=>RS(C)?!0:!C),m&&p&&(h.current=I.isPropagationStopped(),h.current||I.stopPropagation())})})},"CheckboxTrigger")),Spn=ee.forwardRef(NS(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:u,...g}=e;return K.jsx(bpn,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:u,value:c,internal_do_not_use_render:({isFormControl:h})=>K.jsxs(K.Fragment,{children:[K.jsx(uYi,{...g,ref:n,__scopeCheckbox:o}),h&&K.jsx(pYi,{__scopeCheckbox:o})]})})},"Checkbox")),gYi="CheckboxIndicator",dYi=ee.forwardRef(NS(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=U$e(gYi,o);return K.jsx(uE,{present:i||RS(s.checked)||s.checked===!0,children:K.jsx(Na.span,{"data-state":K$e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),hYi="CheckboxBubbleInput",pYi=ee.forwardRef(NS(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:u,name:g,value:h,form:d,bubbleInput:p,setBubbleInput:m}=U$e(hYi,e),_=$A(i,m),f=SWe(r),I=ee.useRef(!1),C=ee.useRef(A),y=ee.useRef(a);ee.useEffect(()=>{const E=p;if(!E)return;const B=window.HTMLInputElement.prototype,Q=Object.getOwnPropertyDescriptor(B,"checked").set,w=a!==y.current;y.current=a;const M=C.current!==A;C.current=A;const k=!(w&&s.current);if(M&&Q){I.current=!w;const R=new Event("click",{bubbles:k});E.indeterminate=RS(A),Q.call(E,RS(A)?!1:A),E.dispatchEvent(R),I.current=!1}},[p,A,s,a]);const x=ee.useRef(RS(A)?!1:A);return K.jsx(Na.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:g,value:h,form:d,...o,tabIndex:-1,ref:_,onClick:ar(n,E=>{I.current&&E.stopPropagation()}),style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function Qpn(t){return typeof t=="function"}NS(Qpn,"isFunction");function RS(t){return t==="indeterminate"}NS(RS,"isIndeterminate");function K$e(t){return RS(t)?"indeterminate":t?"checked":"unchecked"}NS(K$e,"getState");const Iee=ee.forwardRef(({className:t,...e},n)=>K.jsx(Spn,{ref:n,className:Oi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:K.jsx(dYi,{className:Oi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:K.jsx(CS,{className:"rf-h-4 rf-w-4"})})}));Iee.displayName=Spn.displayName;const KT=r_e,mYi=s_e,vpn=ee.forwardRef(({className:t,...e},n)=>K.jsx(wZ,{className:Oi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));vpn.displayName=wZ.displayName;const VP=ee.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>K.jsxs(mYi,{children:[K.jsx(vpn,{className:Oi(n?"":"rf-hidden")}),K.jsx(MZ,{ref:i,className:Oi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));VP.displayName=MZ.displayName;const zP=({className:t,...e})=>K.jsx("div",{className:Oi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});zP.displayName="DialogHeader";const jU=({className:t,...e})=>K.jsx("div",{className:Oi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});jU.displayName="DialogFooter";const JP=ee.forwardRef(({className:t,...e},n)=>K.jsx(a_e,{ref:n,className:Oi("rf-text-lg rf-font-semibold",t),...e}));JP.displayName=a_e.displayName;const VT=ee.forwardRef(({className:t,...e},n)=>K.jsx(A_e,{ref:n,className:Oi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));VT.displayName=A_e.displayName;const mfe={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},_Yi="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let V$e=null;const z$e=async()=>(V$e||(V$e=import(_Yi)),V$e),fYi=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??QC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},IYi=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},CYi=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),wpn=async(t,e)=>{const{fetchEasyEDAComponent:n}=await z$e();return n(t,{fetch:fYi(e),includeModelMetadata:e?.includeModelMetadata})},yYi=async(t,e)=>{const{convertRawEasyToTsx:n}=await z$e(),o=await wpn(t,e);return n({rawEasy:o})},xYi=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await z$e(),i=await wpn(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function WP(t){return Array.isArray?Array.isArray(t):Mpn(t)==="[object Array]"}function EYi(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function J$e(t){return t==null?"":EYi(t)}function TC(t){return typeof t=="string"}function _fe(t){return typeof t=="number"}function BYi(t){return t===!0||t===!1||bYi(t)&&Mpn(t)=="[object Boolean]"}function Ppn(t){return typeof t=="object"}function bYi(t){return Ppn(t)&&t!==null}function FE(t){return t!=null}function ffe(t){return!t.trim().length}function Mpn(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const SYi="Incorrect 'index' type",W$e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",QYi=t=>`Invalid value for key ${t}`,vYi=t=>`Pattern length exceeds max of ${t}.`,wYi=t=>`Missing ${t} property in key`,PYi=t=>`Property 'weight' in key '${t}' must be a positive integer`,MYi="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",Dpn=Object.prototype.hasOwnProperty;var DYi=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=Npn(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Npn(t){let e=null,n=null,o=null,i=1,r=null;if(TC(t)||WP(t))o=t,e=Rpn(t),n=Ife(t);else{if(!Dpn.call(t,"name"))throw new Error(wYi("name"));const s=t.name;if(o=s,Dpn.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(PYi(Ife(s)));e=Rpn(s),n=Ife(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Rpn(t){return WP(t)?t:t.split(".")}function Ife(t){return WP(t)?t.join("."):t}function NYi(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(FE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!FE(c))return;if(a===s.length-1&&(TC(c)||_fe(c)||BYi(c)||typeof c=="bigint"))n.push(A!==void 0?{v:J$e(c),i:A}:J$e(c));else if(WP(c)){o=!0;for(let l=0,u=c.length;l<u;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,TC(e)?e.split("."):e,0),o?n:n[0]}const wa=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:NYi,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function RYi(t){return t>=9&&t<=13||t===32||t===160}function TYi(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)RYi(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var j$e=class{constructor({getFn:t=wa.getFn,fieldNormWeight:e=wa.fieldNormWeight}={}){this.norm=TYi(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(TC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(W$e);if(TC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(W$e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!FE(t)||ffe(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(FE(s)){if(WP(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(FE(l)){if(TC(l)){if(!ffe(l)){const u={v:l,i:A,n:this.norm.get(l)};a.push(u)}}else if(FE(l.v)){const u=TC(l.v)?l.v:J$e(l.v);if(!ffe(u)){const g={v:u,i:l.i,n:this.norm.get(u)};a.push(g)}}}}n.$[o]=a}else if(TC(s)&&!ffe(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function Tpn(t,e,{getFn:n=wa.getFn,fieldNormWeight:o=wa.fieldNormWeight}={}){const i=new j$e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(Npn)),i.setSources(e),i.create(),i}function kYi(t,{getFn:e=wa.getFn,fieldNormWeight:n=wa.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new j$e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function FYi(t=[],e=wa.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function LYi(t,e,n,{location:o=wa.location,distance:i=wa.distance,threshold:r=wa.threshold,findAllMatches:s=wa.findAllMatches,minMatchCharLength:a=wa.minMatchCharLength,includeMatches:A=wa.includeMatches,ignoreLocation:c=wa.ignoreLocation}={}){if(e.length>32)throw new Error(vYi(32));const l=e.length,u=t.length,g=Math.max(0,Math.min(o,u));let h=r,d=g;const p=(S,Q)=>{const w=S/l;if(c)return w;const M=Math.abs(g-Q);return i?w+M/i:M?1:w},m=a>1||A,_=m?Array(u):[];let f;for(;(f=t.indexOf(e,d))>-1;){const S=p(0,f);if(h=Math.min(S,h),d=f+l,m){let Q=0;for(;Q<l;)_[f+Q]=1,Q+=1}}d=-1;let I=[],C=1,y=0,x=l+u;const E=1<<l-1;for(let S=0;S<l;S+=1){let Q=0,w=x;for(;Q<w;)p(S,g+w)<=h?Q=w:x=w,w=Math.floor((x-Q)/2+Q);x=w;let M=Math.max(1,g-w+1);const k=s?u:Math.min(g+w,u)+l,R=Array(k+2);R[k+1]=(1<<S)-1;for(let F=k;F>=M;F-=1){const O=F-1,U=n[t[O]];if(R[F]=(R[F+1]<<1|1)&U,S&&(R[F]|=(I[F+1]|I[F])<<1|1|I[F+1]),R[F]&E&&(C=p(S,O),C<=h)){if(h=C,d=O,y=S,d<=g)break;M=Math.max(1,2*g-d)}}if(p(S+1,g)>h)break;I=R}if(m&&d>=0){const S=Math.min(u-1,d+l-1+y);for(let Q=d;Q<=S;Q+=1)n[t[Q]]&&(_[Q]=1)}const B={isMatch:d>=0,score:Math.max(.001,C)};if(m){const S=FYi(_,a);S.length?A&&(B.indices=S):B.isMatch=!1}return B}function HYi(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function $$e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const kpn={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},OYi=new RegExp("["+Object.keys(kpn).join("")+"]","g"),Cee=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(OYi,e=>kpn[e]):t=>t;var q$e=class{constructor(t,{location:e=wa.location,threshold:n=wa.threshold,distance:o=wa.distance,includeMatches:i=wa.includeMatches,findAllMatches:r=wa.findAllMatches,minMatchCharLength:s=wa.minMatchCharLength,isCaseSensitive:a=wa.isCaseSensitive,ignoreDiacritics:A=wa.ignoreDiacritics,ignoreLocation:c=wa.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?Cee(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(g,h)=>{this.chunks.push({pattern:g,alphabet:HYi(g),startIndex:h})},u=this.pattern.length;if(u>32){let g=0;const h=u%32,d=u-h;for(;g<d;)l(this.pattern.substr(g,32),g),g+=32;if(h){const p=u-32;l(this.pattern.substr(p),p)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?Cee(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let u=0,g=!1;this.chunks.forEach(({pattern:d,alphabet:p,startIndex:m})=>{const{isMatch:_,score:f,indices:I}=LYi(t,d,p,{location:i+m,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});_&&(g=!0),u+=f,_&&I&&l.push(...I)});const h={isMatch:g,score:g?u/this.chunks.length:1};return g&&o&&(h.indices=$$e(l)),h}};const GYi=new Set(["fuzzy","include"]);function YYi(t){return t.startsWith("inverse")}const X$e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new q$e(t,{location:e.location??wa.location,threshold:e.threshold??wa.threshold,distance:e.distance??wa.distance,includeMatches:e.includeMatches??wa.includeMatches,findAllMatches:e.findAllMatches??wa.findAllMatches,minMatchCharLength:e.minMatchCharLength??wa.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??wa.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??wa.ignoreDiacritics,ignoreLocation:e.ignoreLocation??wa.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],Fpn=X$e.length,UYi="\0",KYi="|";function VYi(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function Lpn(t,e){const n=t.match(e);return n?n[1]:null}function zYi(t,e={}){return t.replace(/\\\|/g,UYi).split(KYi).map(n=>{const o=VYi(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<Fpn;){const l=X$e[c],u=Lpn(a,l.multiRegex);u&&(i.push(l.create(u,e)),A=!0)}if(!A)for(c=-1;++c<Fpn;){const l=X$e[c],u=Lpn(a,l.singleRegex);if(u){i.push(l.create(u,e));break}}}return i})}var JYi=class{constructor(t,{isCaseSensitive:e=wa.isCaseSensitive,ignoreDiacritics:n=wa.ignoreDiacritics,includeMatches:o=wa.includeMatches,minMatchCharLength:i=wa.minMatchCharLength,ignoreLocation:r=wa.ignoreLocation,findAllMatches:s=wa.findAllMatches,location:a=wa.location,threshold:A=wa.threshold,distance:c=wa.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?Cee(t):t,this.pattern=t,this.query=zYi(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?Cee(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const u=e[c];s.length=0,r=0,A=!1;for(let g=0,h=u.length;g<h;g+=1){const d=u[g],{isMatch:p,indices:m,score:_}=d.search(t);if(p)r+=1,a+=_,YYi(d.type)&&(A=!0),n&&(GYi.has(d.type)?s.push(...m):s.push(m));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const g={isMatch:!0,score:a/r};return A&&(g.hasInverse=!0),n&&(g.indices=$$e(s)),g}}return{isMatch:!1,score:1}}};const Z$e=[];function eqe(...t){Z$e.push(...t)}function Cfe(t,e){for(let n=0,o=Z$e.length;n<o;n+=1){const i=Z$e[n];if(i.condition(t,e))return new i(t,e)}return new q$e(t,e)}const yfe={AND:"$and",OR:"$or"},tqe={PATH:"$path",PATTERN:"$val"},nqe=t=>!!(t[yfe.AND]||t[yfe.OR]),WYi=t=>!!t[tqe.PATH],jYi=t=>!WP(t)&&Ppn(t)&&!nqe(t),Hpn=t=>({[yfe.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Opn(t,e,{auto:n=!0}={}){const o=i=>{if(TC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=Cfe(i,e)),A}const r=Object.keys(i),s=WYi(i);if(!s&&r.length>1&&!nqe(i))return o(Hpn(i));if(jYi(i)){const A=s?i[tqe.PATH]:r[0],c=s?i[tqe.PATTERN]:i[A];if(!TC(c))throw new Error(QYi(A));const l={keyId:Ife(A),pattern:c};return n&&(l.searcher=Cfe(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];WP(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return nqe(t)||(t=Hpn(t)),o(t)}function oqe(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function $Yi(t,{ignoreFieldNorm:e=wa.ignoreFieldNorm}){t.forEach(n=>{n.score=oqe(n.matches,{ignoreFieldNorm:e})})}var qYi=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function XYi(t){const e=[];return t.matches.forEach(n=>{if(!FE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function ZYi(t,e,{includeMatches:n=wa.includeMatches,includeScore:o=wa.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=XYi(i)),o&&(s.score=i.score),s})}const eUi=/[\p{L}\p{M}\p{N}_]+/gu,Gpn=new WeakSet;function tUi(t){Gpn.has(t)||(Gpn.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function nUi(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||tUi(t),e=>e.match(t)||[]):e=>e.match(eUi)||[]}function iqe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=nUi(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=Cee(i)),o(i)}}}var oUi=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=iqe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new q$e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),u=this.idfWeights[c];o+=u,l.isMatch&&(i++,n+=u*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=$$e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function rqe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function Ypn(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){rqe(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)rqe(t,c.v,i,o);else rqe(t,A.v,i,o)}}function iUi(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Ypn(o,i,e,n);return o}function rUi(t,e,n,o){Ypn(t,e,n,o)}function sUi(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function Upn(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)sUi(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var jP=class{constructor(t,e,n){this.options={...wa,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new DYi(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Cfe(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof j$e))throw new Error(SYi);if(this._myIndex=e||Tpn(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=iqe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=iUi(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!FE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=iqe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});rUi(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&Upn(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(W$e);this._invertedIndex&&Upn(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(TC(t)&&!t.trim()){let g=this._docs.map((h,d)=>({item:h,refIndex:d}));return _fe(n)&&n>-1&&(g=g.slice(0,n)),g}const A=r&&_fe(n)&&n>0&&TC(t),c=s,l=(g,h)=>c(g,h)||g.idx-h.idx;let u;if(A){const g=new qYi(n,l);TC(this._docs[0])?this._searchStringList(t,{heap:g,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:g,ignoreFieldNorm:a}),u=g.extractSorted()}else u=TC(t)?TC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),$Yi(u,{ignoreFieldNorm:a}),r&&u.sort(TC(t)?l:c),_fe(n)&&n>-1&&(u=u.slice(0,n));return ZYi(u,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!FE(a))return;const l=o.searchIn(a);if(l.isMatch){const u={score:l.score,value:a,norm:c,indices:l.indices};i&&(u.matchedMask=l.matchedMask,u.matchedTerms=l.matchedTerms,u.termCount=l.termCount);const g=[u];if(!i||this._coversAllTokens(g)){const h={item:a,idx:A,matches:g};e?(h.score=oqe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=Opn(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let p;return h===null?(p=[],n.forEach((m,_)=>{p.push(...this._findMatches({key:m,value:A[_],searcher:d}))})):p=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),p&&p.length?[{idx:c,item:A,matches:p}]:[]}const{children:l,operator:u}=a,g=[];for(let h=0,d=l.length;h<d;h+=1){const p=l[h],m=o(p,A,c);if(m.length)g.push(...m);else if(u===yfe.AND)return[]}return g},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(FE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!FE(A))return;const l=[];let u=!1,g=!1;if(s.forEach((h,d)=>{const p=this._findMatches({key:h,value:A[d],searcher:o});p.length?(l.push(...p),p[0].hasInverse&&(g=!0)):u=!0}),!(g&&u)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=oqe(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!FE(e))return[];const o=[];if(WP(e))e.forEach(({v:i,i:r,n:s})=>{if(!FE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};jP.version="7.5.0",jP.createIndex=Tpn,jP.parseIndex=kYi,jP.config=wa,jP.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(MYi);return Cfe(t,{...wa,...n}).searchIn(e)},jP.parseQuery=Opn,eqe(JYi),eqe(oUi),jP.use=function(...t){t.forEach(e=>eqe(e))};var aUi=jP;const AUi="https://kicad-mod-cache.tscircuit.com";let sqe=null,yee=null,aqe=null;const cUi=async()=>sqe||yee||(yee=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(sqe=t,yee=null,t)),yee),lUi=async(t,e=20)=>{const n=await cUi();return aqe||(aqe=new aUi(n)),aqe.search(t).slice(0,e).map(o=>o.item)},uUi=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},gUi=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),dUi=async t=>{const e=await fetch(`${AUi}/${gUi(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await DE("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Kpn=t=>t?.source==="jlcpcb"||t?.source==="kicad",hUi=async(t,e)=>{if(t.source==="jlcpcb")return xYi(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return dUi(t.footprint.path);throw new Error("Footprint preview is not available for this source")},pUi=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=ee.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[K.jsxs("div",{className:"rf-relative rf-flex-grow",children:[K.jsx(iWe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),K.jsx(yje,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),K.jsx(fA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):K.jsxs(K.Fragment,{children:[K.jsx(iWe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),K.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},mUi=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),_Ui=t=>mUi.format(t),Vpn=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},fUi=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},IUi=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},CUi=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},yUi=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Vpn(e):null;return K.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=Vpn(r),a=i===s,A=fUi(r),c=IUi(r),l=CUi(r),u=r.source==="jlcpcb"?r.component.stock:null,g=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return K.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[K.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[K.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&K.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&K.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&K.jsx(ybi,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),K.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?K.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),K.jsxs("div",{children:[r.source==="tscircuit.com"&&o?K.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:K.jsx(fA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:p=>{p.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?K.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,g!=null&&K.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:_Ui(g)})]})]},s)})})},xUi=({circuitJson:t,error:e,isLoading:n,height:o})=>K.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?K.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:K.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[K.jsx(oWe,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),K.jsx("span",{children:e})]})}):t?K.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:K.jsx(S$e,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):K.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),zpn={importComponentDialog:101,importComponentDetailsDialog:102},EUi=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,u=c?.latest_sch_preview_image_url,g=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,p=d?`https://tscircuit.com/${d}`:void 0,m=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return K.jsx(KT,{open:e,onOpenChange:n,children:K.jsxs(VP,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:zpn.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[K.jsx(zP,{className:"rf-pb-4 rf-border-b",children:K.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx(JP,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),K.jsx(VT,{children:c?.description})]})})}),K.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?K.jsxs("div",{children:[K.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),K.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:p?K.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(g||l||u)&&K.jsx(K.Fragment,{children:K.jsxs("div",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),K.jsxs(dRe,{value:r,onValueChange:_=>s(_),children:[K.jsxs(Jge,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&K.jsx(p6,{value:"pcb",children:"PCB"}),u&&K.jsx(p6,{value:"schematic",children:"Schematic"}),g&&K.jsx(p6,{value:"3d",children:"3D"})]}),K.jsxs("div",{className:"rf-mt-4",children:[K.jsx(cI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?K.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?K.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),K.jsx(cI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?K.jsx("img",{src:g,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?K.jsxs("section",{children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),K.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?K.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),K.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),K.jsxs(jU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex-1",children:m?K.jsxs(fA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(m,"_blank"),children:[K.jsx(hbi,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),K.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),K.jsx(fA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},BUi=()=>{const[t,e]=ee.useState(null),[n,o]=ee.useState(!1),i=ee.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=ee.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},bUi=(t,e)=>{const[n,o]=ee.useState({circuitJson:null,error:null,isLoading:!1});return ee.useEffect(()=>{if(!t||!Kpn(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),hUi(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},SUi=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},QUi=({sessionToken:t})=>{const[e,n]=ee.useState([]),[o,i]=ee.useState(!1),[r,s]=ee.useState(null),[a,A]=ee.useState(!1),c=ee.useCallback(async u=>{const g=u.trim();if(!g)return[];i(!0),s(null);try{const d=(await SUi(g,t)).map(p=>({source:"tscircuit.com",package:p}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=ee.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},vUi=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},Jpn=(t,e)=>{const n=vUi(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},wUi=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},PUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=wUi(l);if(!u)return[];o(!0),r(null);try{const g=await IYi(u,10),h=Jpn(l,g.map(d=>({source:"jlcpcb",component:CYi(d)})));return e(h),h}catch(g){console.error("Error searching JLCPCB components",g);const h=Jpn(l,[]);return e(h),r(h.length>0?null:g instanceof Error?g.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},MUi=()=>{const[t,e]=ee.useState([]),[n,o]=ee.useState(!1),[i,r]=ee.useState(null),[s,a]=ee.useState(!1),A=ee.useCallback(async l=>{const u=l.trim();if(!u)return[];o(!0),r(null);try{const h=(await lUi(u,20)).map(d=>({source:"kicad",footprint:uUi(d)}));return e(h),h}catch(g){return console.error("Error searching KiCad footprints",g),e([]),r(g instanceof Error?g.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=ee.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},DUi=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},NUi=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{mee();const A=ee.useMemo(()=>DUi({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[u,g]=ee.useState(A[0]??"tscircuit.com"),[h,d]=ee.useState(""),[p,m]=ee.useState(null),{results:_,isSearching:f,error:I,hasSearched:C,search:y,reset:x}=QUi({sessionToken:a}),{results:E,isSearching:B,error:S,hasSearched:Q,search:w,reset:M}=PUi(),{results:k,isSearching:R,error:F,hasSearched:O,search:U,reset:Y}=MUi(),{details:W,isLoading:te,fetchDetails:j,reset:J}=BUi(),[oe,ie]=ee.useState(null),[ne,le]=ee.useState(!1),[ge,_e]=ee.useState("pcb"),[ue,fe]=ee.useState(null),[pe,ye]=ee.useState(!1),Me=ee.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:ve,error:he,isLoading:Qe}=bUi(p,Me),Pe=Kpn(p);ee.useEffect(()=>{fe(null)},[p]);const we=ee.useCallback(()=>{x(),M(),Y(),m(null)},[M,Y,x]);ee.useEffect(()=>{t||(we(),d(""),le(!1),ie(null),fe(null))},[t,we]),ee.useEffect(()=>{d(""),m(null),u==="tscircuit.com"?x():u==="jlcpcb"?M():u==="kicad"&&Y()},[u,M,Y,x]);const Te=nt=>{m(nt),ie(nt),_e("pcb"),le(!0),J();const gt=nt.package.org_owner_tscircuit_handle,bt=nt.package.unscoped_name;if(gt&&bt){const Ct=bt.split("/").pop()??bt;j(gt,Ct)}},Re=async()=>{h.trim()&&(m(null),u==="tscircuit.com"?await y(h):u==="jlcpcb"?await w(h):u==="kicad"&&await U(h))},Ee=async nt=>{try{if(fe(null),ye(!0),nt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:nt,footprint:nt.footprint.qualifiedName})}else if(nt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const gt=await yYi(nt.component.partNumber,{headers:n,apiBase:s});await r({result:nt,tsx:gt})}else if(nt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const gt=nt.package.org_owner_tscircuit_handle,bt=nt.package.unscoped_name;if(!gt||!bt)throw new Error("Missing package metadata");const Ct=bt.split("/").pop()??bt,Dt=`@tsci/${gt}.${Ct}`;await i({result:nt,fullPackageName:Dt})}return!0}catch(gt){return console.error("Failed to import component",gt),fe(gt instanceof Error?gt.message:"Failed to import component"),!1}finally{ye(!1)}};let ke=[],Ce=!1,Le=null,Ye=!1;u==="tscircuit.com"?(ke=_,Ce=f,Le=I,Ye=C):u==="jlcpcb"?(ke=E,Ce=B,Le=S,Ye=Q):u==="kicad"&&(ke=k,Ce=R,Le=F,Ye=O);const tt=async()=>{if(!p)return;await Ee(p)&&(e(),we(),d(""))},At=nt=>{nt||e()},at=nt=>{le(nt),nt||ie(null)};return K.jsxs(KT,{open:t,onOpenChange:At,children:[K.jsxs(VP,{style:{width:"calc(100vw - 2rem)",maxWidth:Pe?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:zpn.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[K.jsxs(zP,{children:[K.jsxs(JP,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?mfe[u].label:""," ","Component"]}),K.jsx(VT,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?K.jsxs(dRe,{value:u,onValueChange:nt=>g(nt),className:"rf-min-w-0 rf-w-full",children:[!l&&K.jsx(Jge,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(nt=>K.jsx(p6,{value:nt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:mfe[nt].label},nt))}),K.jsxs("div",{className:"rf-min-w-0",style:Pe?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[K.jsxs("div",{className:"rf-min-w-0",children:[K.jsx(pUi,{query:h,placeholder:mfe[u].placeholder,isSearching:Ce,onQueryChange:d,onSubmit:Re}),K.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Ce?K.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(SE,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),K.jsx("p",{children:"Searching..."})]}):ke.length>0?K.jsx(yUi,{results:ke,selected:p,onSelect:m,onShowDetails:u==="tscircuit.com"?Te:void 0}):K.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Le?`Error: ${Le}`:Ye?mfe[u].emptyMessage:"Enter a search term to find components"})})]}),Pe?K.jsx("div",{className:"rf-mt-4",children:K.jsx(xUi,{circuitJson:ve,error:he,isLoading:Qe,height:325})}):null]})]}):null,ue?K.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ue}):null,K.jsxs(jU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[K.jsx(fA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),K.jsx(fA,{onClick:tt,disabled:!p||pe,className:"rf-order-1 sm:rf-order-2",children:pe?K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),K.jsx(EUi,{packageResult:oe,isOpen:ne,onOpenChange:at,isLoading:te,details:W,previewTab:ge,onPreviewTabChange:nt=>_e(nt),isSubmitting:pe,onImport:()=>{oe&&Ee(oe).then(nt=>{nt&&(le(!1),e(),we(),d(""))})}})]})},RUi=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Wpn=t=>{const e=md(s=>s.pushEvent),n=md(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await ua.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await ua.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${RUi(a)}.tsx`;await ua.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return K.jsx(NUi,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Wpn.displayName="ImportComponentDialogForCli";const TUi=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToAltiumZip:n}=await Promise.resolve().then(()=>Adr),o=await n(t,e);return new Blob([new Uint8Array(o)],{type:"application/zip"})},kUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await TUi({circuitJson:t,projectName:e});kE(n,{fileName:`${e}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:n=>`Failed to generate Altium project: ${n instanceof Error?n.message:String(n)}`})};var Aqe={exports:{}},jpn;function FUi(){return jpn||(jpn=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,u){if(!r[l]){if(!i[l]){var g=typeof U8=="function"&&U8;if(!u&&g)return g(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(p){var m=i[l][1][p];return a(m||p)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof U8=="function"&&U8,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,u,g,h,d,p,m,_=[],f=0,I=c.length,C=I,y=s.getTypeOf(c)!=="string";f<c.length;)C=I-f,g=y?(l=c[f++],u=f<I?c[f++]:0,f<I?c[f++]:0):(l=c.charCodeAt(f++),u=f<I?c.charCodeAt(f++):0,f<I?c.charCodeAt(f++):0),h=l>>2,d=(3&l)<<4|u>>4,p=1<C?(15&u)<<2|g>>6:64,m=2<C?63&g:64,_.push(A.charAt(h)+A.charAt(d)+A.charAt(p)+A.charAt(m));return _.join("")},r.decode=function(c){var l,u,g,h,d,p,m=0,_=0,f="data:";if(c.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var I,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=a.uint8array?new Uint8Array(0|C):new Array(0|C);m<c.length;)l=A.indexOf(c.charAt(m++))<<2|(h=A.indexOf(c.charAt(m++)))>>4,u=(15&h)<<4|(d=A.indexOf(c.charAt(m++)))>>2,g=(3&d)<<6|(p=A.indexOf(c.charAt(m++))),I[_++]=l,d!==64&&(I[_++]=u),p!==64&&(I[_++]=g);return I}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(u,g,h,d,p){this.compressedSize=u,this.uncompressedSize=g,this.crc32=h,this.compression=d,this.compressedContent=p}l.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),g=this;return u.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(u,g,h){return u.pipe(new A).pipe(new c("uncompressedSize")).pipe(g.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",g)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var u=0;u<8;u++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u[m])];return-1^l})(0|c,A,A.length,0):(function(l,u,g,h){var d=a,p=h+g;l^=-1;for(var m=h;m<p;m++)l=l>>>8^d[255&(l^u.charCodeAt(m))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function u(g,h){c.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(u,c),u.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,g.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(h){g.push({data:h,meta:g.meta})}},r.compressWorker=function(g){return new u("Deflate",g)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,p){var m,_="";for(m=0;m<p;m++)_+=String.fromCharCode(255&d),d>>>=8;return _}function a(d,p,m,_,f,I){var C,y,x=d.file,E=d.compression,B=I!==l.utf8encode,S=A.transformTo("string",I(x.name)),Q=A.transformTo("string",l.utf8encode(x.name)),w=x.comment,M=A.transformTo("string",I(w)),k=A.transformTo("string",l.utf8encode(w)),R=Q.length!==x.name.length,F=k.length!==w.length,O="",U="",Y="",W=x.dir,te=x.date,j={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(j.crc32=d.crc32,j.compressedSize=d.compressedSize,j.uncompressedSize=d.uncompressedSize);var J=0;p&&(J|=8),B||!R&&!F||(J|=2048);var oe=0,ie=0;W&&(oe|=16),f==="UNIX"?(ie=798,oe|=(function(le,ge){var _e=le;return le||(_e=ge?16893:33204),(65535&_e)<<16})(x.unixPermissions,W)):(ie=20,oe|=(function(le){return 63&(le||0)})(x.dosPermissions)),C=te.getUTCHours(),C<<=6,C|=te.getUTCMinutes(),C<<=5,C|=te.getUTCSeconds()/2,y=te.getUTCFullYear()-1980,y<<=4,y|=te.getUTCMonth()+1,y<<=5,y|=te.getUTCDate(),R&&(U=s(1,1)+s(u(S),4)+Q,O+="up"+s(U.length,2)+U),F&&(Y=s(1,1)+s(u(M),4)+k,O+="uc"+s(Y.length,2)+Y);var ne="";return ne+=`
\0`,ne+=s(J,2),ne+=E.magic,ne+=s(C,2),ne+=s(y,2),ne+=s(j.crc32,4),ne+=s(j.compressedSize,4),ne+=s(j.uncompressedSize,4),ne+=s(S.length,2),ne+=s(O.length,2),{fileRecord:g.LOCAL_FILE_HEADER+ne+S+O,dirRecord:g.CENTRAL_FILE_HEADER+s(ie,2)+ne+s(M.length,2)+"\0\0\0\0"+s(oe,4)+s(_,4)+S+O+M}}var A=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),u=o("../crc32"),g=o("../signature");function h(d,p,m,_){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=_,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}A.inherits(h,c),h.prototype.push=function(d){var p=d.meta.percent||0,m=this.entriesCount,_=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-_-1))/m:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var p=this.streamFiles&&!d.file.dir;if(p){var m=a(d,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var p=this.streamFiles&&!d.file.dir,m=a(d,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(_){return g.DATA_DESCRIPTOR+s(_.crc32,4)+s(_.compressedSize,4)+s(_.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-d,_=(function(f,I,C,y,x){var E=A.transformTo("string",x(y));return g.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(I,4)+s(C,4)+s(E.length,2)+E})(this.dirRecords.length,m,d,this.zipComment,this.encodeFileName);this.push({data:_,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var p=this;return d.on("data",function(m){p.processChunk(m)}),d.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),d.on("error",function(m){p.error(m)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var p=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var m=0;m<p.length;m++)try{p[m].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,p=0;p<d.length;p++)d[p].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(A,c,l){var u=new a(c.streamFiles,l,c.platform,c.encodeFileName),g=0;try{A.forEach(function(h,d){g++;var p=(function(I,C){var y=I||C,x=s[y];if(!x)throw new Error(y+" is not a valid compression method !");return x})(d.options.compression,c.compression),m=d.options.compressionOptions||c.compressionOptions||{},_=d.dir,f=d.date;d._compressWorker(p,m).withStreamInfo("file",{name:h,dir:_,date:f,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(u)}),u.entriesCount=g}catch(h){u.error(h)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var A in this)typeof this[A]!="function"&&(a[A]=this[A]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.2",s.loadAsync=function(a,A){return new s().loadAsync(a,A)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),A=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),u=o("./nodejsUtils");function g(h){return new a.Promise(function(d,p){var m=h.decompressed.getContentWorker().pipe(new l);m.on("error",function(_){p(_)}).on("end",function(){m.streamInfo.crc32!==h.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var p=this;return d=s.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:A.utf8decode}),u.isNode&&u.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(m){var _=new c(d);return _.load(m),_}).then(function(m){var _=[a.Promise.resolve(m)],f=m.files;if(d.checkCRC32)for(var I=0;I<f.length;I++)_.push(g(f[I]));return a.Promise.all(_)}).then(function(m){for(var _=m.shift(),f=_.files,I=0;I<f.length;I++){var C=f[I],y=C.fileNameStr,x=s.resolve(C.fileNameStr);p.file(x,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(p.file(x).unsafeOriginalName=y)}return _.zipComment.length&&(p.comment=_.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function A(c,l){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}s.inherits(A,a),A.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(u){l.push({data:u,meta:{percent:0}})}).on("error",function(u){l.isPaused?this.generatedError=u:l.error(u)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},A.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=A},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(A,c,l){s.call(this,c),this._helper=A;var u=this;A.on("data",function(g,h){u.push(g)||u._helper.pause(),l&&l(h)}).on("error",function(g){u.emit("error",g)}).on("end",function(){u.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(x,E,B){var S,Q=A.getTypeOf(E),w=A.extend(B||{},u);w.date=w.date||new Date,w.compression!==null&&(w.compression=w.compression.toUpperCase()),typeof w.unixPermissions=="string"&&(w.unixPermissions=parseInt(w.unixPermissions,8)),w.unixPermissions&&16384&w.unixPermissions&&(w.dir=!0),w.dosPermissions&&16&w.dosPermissions&&(w.dir=!0),w.dir&&(x=f(x)),w.createFolders&&(S=_(x))&&I.call(this,S,!0);var M=Q==="string"&&w.binary===!1&&w.base64===!1;B&&B.binary!==void 0||(w.binary=!M),(E instanceof g&&E.uncompressedSize===0||w.dir||!E||E.length===0)&&(w.base64=!1,w.binary=!0,E="",w.compression="STORE",Q="string");var k=null;k=E instanceof g||E instanceof c?E:p.isNode&&p.isStream(E)?new m(x,E):A.prepareContent(x,E,w.binary,w.optimizedBinaryString,w.base64);var R=new h(x,k,w);this.files[x]=R}var a=o("./utf8"),A=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),u=o("./defaults"),g=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),p=o("./nodejsUtils"),m=o("./nodejs/NodejsStreamInputAdapter"),_=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var E=x.lastIndexOf("/");return 0<E?x.substring(0,E):""},f=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},I=function(x,E){return E=E!==void 0?E:u.createFolders,x=f(x),this.files[x]||s.call(this,x,null,{dir:!0,createFolders:E}),this.files[x]};function C(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var E,B,S;for(E in this.files)S=this.files[E],(B=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&x(B,S)},filter:function(x){var E=[];return this.forEach(function(B,S){x(B,S)&&E.push(S)}),E},file:function(x,E,B){if(arguments.length!==1)return x=this.root+x,s.call(this,x,E,B),this;if(C(x)){var S=x;return this.filter(function(w,M){return!M.dir&&S.test(w)})}var Q=this.files[this.root+x];return Q&&!Q.dir?Q:null},folder:function(x){if(!x)return this;if(C(x))return this.filter(function(Q,w){return w.dir&&x.test(Q)});var E=this.root+x,B=I.call(this,E),S=this.clone();return S.root=B.name,S},remove:function(x){x=this.root+x;var E=this.files[x];if(E||(x.slice(-1)!=="/"&&(x+="/"),E=this.files[x]),E&&!E.dir)delete this.files[x];else for(var B=this.filter(function(Q,w){return w.name.slice(0,x.length)===x}),S=0;S<B.length;S++)delete this.files[B[S].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var E,B={};try{if((B=A.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=B.type.toLowerCase(),B.compression=B.compression.toUpperCase(),B.type==="binarystring"&&(B.type="string"),!B.type)throw new Error("No output type specified.");A.checkSupport(B.type),B.platform!=="darwin"&&B.platform!=="freebsd"&&B.platform!=="linux"&&B.platform!=="sunos"||(B.platform="UNIX"),B.platform==="win32"&&(B.platform="DOS");var S=B.comment||this.comment||"";E=d.generateWorker(this,B,S)}catch(Q){(E=new c("error")).error(Q)}return new l(E,B.type||"string",B.mimeType)},generateAsync:function(x,E){return this.generateInternalStream(x).accumulate(E)},generateNodeStream:function(x,E){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(E)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A);for(var c=0;c<this.data.length;c++)A[c]=255&A[c]}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data[this.zero+A]},a.prototype.lastIndexOfSignature=function(A){for(var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===u&&this.data[h+3]===g)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(A){var c=A.charCodeAt(0),l=A.charCodeAt(1),u=A.charCodeAt(2),g=A.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&u===h[2]&&g===h[3]},a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(A){this.data=A,this.length=A.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(A){this.checkIndex(this.index+A)},checkIndex:function(A){if(this.length<this.zero+A||A<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+A+"). Corrupted zip ?")},setIndex:function(A){this.checkIndex(A),this.index=A},skip:function(A){this.setIndex(this.index+A)},byteAt:function(){},readInt:function(A){var c,l=0;for(this.checkOffset(A),c=this.index+A-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=A,l},readString:function(A){return s.transformTo("string",this.readData(A))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var A=this.readInt(4);return new Date(Date.UTC(1980+(A>>25&127),(A>>21&15)-1,A>>16&31,A>>11&31,A>>5&63,(31&A)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data.charCodeAt(this.zero+A)},a.prototype.lastIndexOfSignature=function(A){return this.data.lastIndexOf(A)-this.zero},a.prototype.readAndCheckSignature=function(A){return A===this.readData(4)},a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),A=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),u=o("./Uint8ArrayReader");i.exports=function(g){var h=s.getTypeOf(g);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new l(g):a.uint8array?new u(s.transformTo("uint8array",g)):new A(s.transformTo("array",g)):new c(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function A(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(A,s),A.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},i.exports=A},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function A(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(A,s),A.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=A},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(A,a),A.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}a.prototype.processChunk.call(this,c)},i.exports=A},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(u){l.dataIsReady=!0,l.data=u,l.max=u&&u.length||0,l.type=s.getTypeOf(u),l.isPaused||l._tickAndRepeat()},function(u){l.error(u)})}s.inherits(A,a),A.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},A.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},A.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=A},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,A){return this._listeners[a].push(A),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,A){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,A)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var A=this;return a.on("data",function(c){A.processChunk(c)}),a.on("end",function(){A.end()}),a.on("error",function(c){A.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,A){return this.extraStreamInfo[a]=A,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),A=o("./GenericWorker"),c=o("../base64"),l=o("../support"),u=o("../external"),g=null;if(l.nodestream)try{g=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(p,m){return new u.Promise(function(_,f){var I=[],C=p._internalType,y=p._outputType,x=p._mimeType;p.on("data",function(E,B){I.push(E),m&&m(B)}).on("error",function(E){I=[],f(E)}).on("end",function(){try{var E=(function(B,S,Q){switch(B){case"blob":return s.newBlob(s.transformTo("arraybuffer",S),Q);case"base64":return c.encode(S);default:return s.transformTo(B,S)}})(y,(function(B,S){var Q,w=0,M=null,k=0;for(Q=0;Q<S.length;Q++)k+=S[Q].length;switch(B){case"string":return S.join("");case"array":return Array.prototype.concat.apply([],S);case"uint8array":for(M=new Uint8Array(k),Q=0;Q<S.length;Q++)M.set(S[Q],w),w+=S[Q].length;return M;case"nodebuffer":return Buffer.concat(S);default:throw new Error("concat : unsupported type '"+B+"'")}})(C,I),x);_(E)}catch(B){f(B)}I=[]}).resume()})}function d(p,m,_){var f=m;switch(m){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=m,this._mimeType=_,s.checkSupport(f),this._worker=p.pipe(new a(f)),p.lock()}catch(I){this._worker=new A("error"),this._worker.error(I)}}d.prototype={accumulate:function(p){return h(this,p)},on:function(p,m){var _=this;return p==="data"?this._worker.on(p,function(f){m.call(_,f.data,f.meta)}):this._worker.on(p,function(){s.delay(m,arguments,_)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new g(this,{objectMode:this._outputType!=="nodebuffer"},p)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),A=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;l[254]=l[254]=1;function g(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return a.nodebuffer?A.newBufferFrom(d,"utf-8"):(function(p){var m,_,f,I,C,y=p.length,x=0;for(I=0;I<y;I++)(64512&(_=p.charCodeAt(I)))==55296&&I+1<y&&(64512&(f=p.charCodeAt(I+1)))==56320&&(_=65536+(_-55296<<10)+(f-56320),I++),x+=_<128?1:_<2048?2:_<65536?3:4;for(m=a.uint8array?new Uint8Array(x):new Array(x),I=C=0;C<x;I++)(64512&(_=p.charCodeAt(I)))==55296&&I+1<y&&(64512&(f=p.charCodeAt(I+1)))==56320&&(_=65536+(_-55296<<10)+(f-56320),I++),_<128?m[C++]=_:(_<2048?m[C++]=192|_>>>6:(_<65536?m[C++]=224|_>>>12:(m[C++]=240|_>>>18,m[C++]=128|_>>>12&63),m[C++]=128|_>>>6&63),m[C++]=128|63&_);return m})(d)},r.utf8decode=function(d){return a.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):(function(p){var m,_,f,I,C=p.length,y=new Array(2*C);for(m=_=0;m<C;)if((f=p[m++])<128)y[_++]=f;else if(4<(I=l[f]))y[_++]=65533,m+=I-1;else{for(f&=I===2?31:I===3?15:7;1<I&&m<C;)f=f<<6|63&p[m++],I--;1<I?y[_++]=65533:f<65536?y[_++]=f:(f-=65536,y[_++]=55296|f>>10&1023,y[_++]=56320|1023&f)}return y.length!==_&&(y.subarray?y=y.subarray(0,_):y.length=_),s.applyFromCharCode(y)})(d=s.transformTo(a.uint8array?"uint8array":"array",d))},s.inherits(g,c),g.prototype.processChunk=function(d){var p=s.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var _=(function(I,C){var y;for((C=C||I.length)>I.length&&(C=I.length),y=C-1;0<=y&&(192&I[y])==128;)y--;return y<0||y===0?C:y+l[I[y]]>C?y:C})(p),f=p;_!==p.length&&(a.uint8array?(f=p.subarray(0,_),this.leftOver=p.subarray(_,p.length)):(f=p.slice(0,_),this.leftOver=p.slice(_,p.length))),this.push({data:r.utf8decode(f),meta:d.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=g,s.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),A=o("./nodejsUtils"),c=o("./external");function l(m){return m}function u(m,_){for(var f=0;f<m.length;++f)_[f]=255&m.charCodeAt(f);return _}o("setimmediate"),r.newBlob=function(m,_){r.checkSupport("blob");try{return new Blob([m],{type:_})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(m),f.getBlob(_)}catch{throw new Error("Bug : can't construct the Blob.")}}};var g={stringifyByChunk:function(m,_,f){var I=[],C=0,y=m.length;if(y<=f)return String.fromCharCode.apply(null,m);for(;C<y;)_==="array"||_==="nodebuffer"?I.push(String.fromCharCode.apply(null,m.slice(C,Math.min(C+f,y)))):I.push(String.fromCharCode.apply(null,m.subarray(C,Math.min(C+f,y)))),C+=f;return I.join("")},stringifyByChar:function(m){for(var _="",f=0;f<m.length;f++)_+=String.fromCharCode(m[f]);return _},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,A.allocBuffer(1)).length===1}catch{return!1}})()}};function h(m){var _=65536,f=r.getTypeOf(m),I=!0;if(f==="uint8array"?I=g.applyCanBeUsed.uint8array:f==="nodebuffer"&&(I=g.applyCanBeUsed.nodebuffer),I)for(;1<_;)try{return g.stringifyByChunk(m,f,_)}catch{_=Math.floor(_/2)}return g.stringifyByChar(m)}function d(m,_){for(var f=0;f<m.length;f++)_[f]=m[f];return _}r.applyFromCharCode=h;var p={};p.string={string:l,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,A.allocBuffer(m.length))}},p.array={string:h,array:l,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(m)}},p.arraybuffer={string:function(m){return h(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:l,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return A.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:l,nodebuffer:function(m){return A.newBufferFrom(m)}},p.nodebuffer={string:h,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:l},r.transformTo=function(m,_){if(_=_||"",!m)return _;r.checkSupport(m);var f=r.getTypeOf(_);return p[f][m](_)},r.resolve=function(m){for(var _=m.split("/"),f=[],I=0;I<_.length;I++){var C=_[I];C==="."||C===""&&I!==0&&I!==_.length-1||(C===".."?f.pop():f.push(C))}return f.join("/")},r.getTypeOf=function(m){if(typeof m=="string")return"string";var _=Object.prototype.toString.call(m);return _==="[object Array]"?"array":s.nodebuffer&&A.isBuffer(m)?"nodebuffer":s.uint8array&&_==="[object Uint8Array]"?"uint8array":s.arraybuffer&&_==="[object ArrayBuffer]"?"arraybuffer":void 0},r.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(m){var _,f,I="";for(f=0;f<(m||"").length;f++)I+="\\x"+((_=m.charCodeAt(f))<16?"0":"")+_.toString(16).toUpperCase();return I},r.delay=function(m,_,f){setImmediate(function(){m.apply(f||null,_||[])})},r.inherits=function(m,_){function f(){}f.prototype=_.prototype,m.prototype=new f},r.extend=function(){var m,_,f={};for(m=0;m<arguments.length;m++)for(_ in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],_)&&f[_]===void 0&&(f[_]=arguments[m][_]);return f},r.prepareContent=function(m,_,f,I,C){return c.Promise.resolve(_).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)?Blob.prototype.arrayBuffer!==void 0?y.arrayBuffer():typeof FileReader<"u"?new c.Promise(function(x,E){var B=new FileReader;B.onload=function(S){x(S.target.result)},B.onerror=function(S){E(S.target.error)},B.readAsArrayBuffer(y)}):c.Promise.reject(new Error(m+" is a Blob, but we have no way of reading it.")):y}).then(function(y){var x=r.getTypeOf(y);return x?(x==="arraybuffer"?y=r.transformTo("uint8array",y):x==="string"&&(C?y=a.decode(y):f&&I!==!0&&(y=(function(E){return u(E,s.uint8array?new Uint8Array(E.length):new Array(E.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./signature"),c=o("./zipEntry"),l=o("./support");function u(g){this.files=[],this.loadOptions=g}u.prototype={checkSignature:function(g){if(!this.reader.readAndCheckSignature(g)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(g)+")")}},isSignature:function(g,h){var d=this.reader.index;this.reader.setIndex(g);var p=this.reader.readString(4)===h;return this.reader.setIndex(d),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var g=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=a.transformTo(h,g);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var g,h,d,p=this.zip64EndOfCentralSize-44;0<p;)g=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[g]={id:g,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var g,h;for(g=0;g<this.files.length;g++)h=this.files[g],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(A.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var g;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(A.CENTRAL_FILE_HEADER);)(g=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(g);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var g=this.reader.lastIndexOfSignature(A.CENTRAL_DIRECTORY_END);if(g<0)throw this.isSignature(0,A.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(g);var h=g;if(this.checkSignature(A.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(g=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(g),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,A.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var p=h-d;if(0<p)this.isSignature(h,A.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(g){this.reader=s(g)},load:function(g){this.prepareReader(g),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),u=o("./compressions"),g=o("./support");function h(d,p){this.options=d,this.loadOptions=p}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var p,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(_){for(var f in u)if(Object.prototype.hasOwnProperty.call(u,f)&&u[f].magic===_)return u[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new A(this.compressedSize,this.uncompressedSize,this.crc32,p,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var p=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(p),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var p,m,_,f=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<f;)p=d.readInt(2),m=d.readInt(2),_=d.readData(m),this.extraFields[p]={id:p,length:m,value:_};d.setIndex(f)},handleUTF8:function(){var d=g.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var _=this.findExtraFieldUnicodeComment();if(_!==null)this.fileCommentStr=_;else{var f=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var p=s(d.value);return p.readInt(1)!==1||c(this.fileName)!==p.readInt(4)?null:l.utf8decode(p.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var p=s(d.value);return p.readInt(1)!==1||c(this.fileComment)!==p.readInt(4)?null:l.utf8decode(p.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(p,m,_){this.name=p,this.dir=_.dir,this.date=_.date,this.comment=_.comment,this.unixPermissions=_.unixPermissions,this.dosPermissions=_.dosPermissions,this._data=m,this._dataBinary=_.binary,this.options={compression:_.compression,compressionOptions:_.compressionOptions}}var a=o("./stream/StreamHelper"),A=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),u=o("./stream/GenericWorker");s.prototype={internalStream:function(p){var m=null,_="string";try{if(!p)throw new Error("No output type specified.");var f=(_=p.toLowerCase())==="string"||_==="text";_!=="binarystring"&&_!=="text"||(_="string"),m=this._decompressWorker();var I=!this._dataBinary;I&&!f&&(m=m.pipe(new c.Utf8EncodeWorker)),!I&&f&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(C){(m=new u("error")).error(C)}return new a(m,_,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof l&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var _=this._decompressWorker();return this._dataBinary||(_=_.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(_,p,m)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof u?this._data:new A(this._data)}};for(var g=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<g.length;d++)s.prototype[g[d]]=h;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,A,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var l=0,u=new c(p),g=s.document.createTextNode("");u.observe(g,{characterData:!0}),a=function(){g.data=l=++l%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var h=new s.MessageChannel;h.port1.onmessage=p,a=function(){h.port2.postMessage(0)}}var d=[];function p(){var m,_;A=!0;for(var f=d.length;f;){for(_=d,d=[],m=-1;++m<f;)_[m]();f=d.length}A=!1}i.exports=function(m){d.push(m)!==1||A||a()}}).call(this,typeof my<"u"?my:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var A={},c=["REJECTED"],l=["FULFILLED"],u=["PENDING"];function g(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,f!==a&&m(this,f)}function h(f,I,C){this.promise=f,typeof I=="function"&&(this.onFulfilled=I,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(f,I,C){s(function(){var y;try{y=I(C)}catch(x){return A.reject(f,x)}y===f?A.reject(f,new TypeError("Cannot resolve promise with itself")):A.resolve(f,y)})}function p(f){var I=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof I=="function")return function(){I.apply(f,arguments)}}function m(f,I){var C=!1;function y(B){C||(C=!0,A.reject(f,B))}function x(B){C||(C=!0,A.resolve(f,B))}var E=_(function(){I(x,y)});E.status==="error"&&y(E.value)}function _(f,I){var C={};try{C.value=f(I),C.status="success"}catch(y){C.status="error",C.value=y}return C}(i.exports=g).prototype.finally=function(f){if(typeof f!="function")return this;var I=this.constructor;return this.then(function(C){return I.resolve(f()).then(function(){return C})},function(C){return I.resolve(f()).then(function(){throw C})})},g.prototype.catch=function(f){return this.then(null,f)},g.prototype.then=function(f,I){if(typeof f!="function"&&this.state===l||typeof I!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==u?d(C,this.state===l?f:I,this.outcome):this.queue.push(new h(C,f,I)),C},h.prototype.callFulfilled=function(f){A.resolve(this.promise,f)},h.prototype.otherCallFulfilled=function(f){d(this.promise,this.onFulfilled,f)},h.prototype.callRejected=function(f){A.reject(this.promise,f)},h.prototype.otherCallRejected=function(f){d(this.promise,this.onRejected,f)},A.resolve=function(f,I){var C=_(p,I);if(C.status==="error")return A.reject(f,C.value);var y=C.value;if(y)m(f,y);else{f.state=l,f.outcome=I;for(var x=-1,E=f.queue.length;++x<E;)f.queue[x].callFulfilled(I)}return f},A.reject=function(f,I){f.state=c,f.outcome=I;for(var C=-1,y=f.queue.length;++C<y;)f.queue[C].callRejected(I);return f},g.resolve=function(f){return f instanceof this?f:A.resolve(new this(a),f)},g.reject=function(f){var I=new this(a);return A.reject(I,f)},g.all=function(f){var I=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,y=!1;if(!C)return this.resolve([]);for(var x=new Array(C),E=0,B=-1,S=new this(a);++B<C;)Q(f[B],B);return S;function Q(w,M){I.resolve(w).then(function(k){x[M]=k,++E!==C||y||(y=!0,A.resolve(S,x))},function(k){y||(y=!0,A.reject(S,k))})}},g.race=function(f){var I=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,y=!1;if(!C)return this.resolve([]);for(var x=-1,E=new this(a);++x<C;)B=f[x],I.resolve(B).then(function(S){y||(y=!0,A.resolve(E,S))},function(S){y||(y=!0,A.reject(E,S))});var B;return E}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),u=Object.prototype.toString,g=0,h=-1,d=0,p=8;function m(f){if(!(this instanceof m))return new m(f);this.options=a.assign({level:h,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},f||{});var I=this.options;I.raw&&0<I.windowBits?I.windowBits=-I.windowBits:I.gzip&&0<I.windowBits&&I.windowBits<16&&(I.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,I.level,I.method,I.windowBits,I.memLevel,I.strategy);if(C!==g)throw new Error(c[C]);if(I.header&&s.deflateSetHeader(this.strm,I.header),I.dictionary){var y;if(y=typeof I.dictionary=="string"?A.string2buf(I.dictionary):u.call(I.dictionary)==="[object ArrayBuffer]"?new Uint8Array(I.dictionary):I.dictionary,(C=s.deflateSetDictionary(this.strm,y))!==g)throw new Error(c[C]);this._dict_set=!0}}function _(f,I){var C=new m(I);if(C.push(f,!0),C.err)throw C.msg||c[C.err];return C.result}m.prototype.push=function(f,I){var C,y,x=this.strm,E=this.options.chunkSize;if(this.ended)return!1;y=I===~~I?I:I===!0?4:0,typeof f=="string"?x.input=A.string2buf(f):u.call(f)==="[object ArrayBuffer]"?x.input=new Uint8Array(f):x.input=f,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new a.Buf8(E),x.next_out=0,x.avail_out=E),(C=s.deflate(x,y))!==1&&C!==g)return this.onEnd(C),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(A.buf2binstring(a.shrinkBuf(x.output,x.next_out))):this.onData(a.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&C!==1);return y===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===g):y!==2||(this.onEnd(g),!(x.avail_out=0))},m.prototype.onData=function(f){this.chunks.push(f)},m.prototype.onEnd=function(f){f===g&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},r.Deflate=m,r.deflate=_,r.deflateRaw=function(f,I){return(I=I||{}).raw=!0,_(f,I)},r.gzip=function(f,I){return(I=I||{}).gzip=!0,_(f,I)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),u=o("./zlib/zstream"),g=o("./zlib/gzheader"),h=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},m||{});var _=this.options;_.raw&&0<=_.windowBits&&_.windowBits<16&&(_.windowBits=-_.windowBits,_.windowBits===0&&(_.windowBits=-15)),!(0<=_.windowBits&&_.windowBits<16)||m&&m.windowBits||(_.windowBits+=32),15<_.windowBits&&_.windowBits<48&&(15&_.windowBits)==0&&(_.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var f=s.inflateInit2(this.strm,_.windowBits);if(f!==c.Z_OK)throw new Error(l[f]);this.header=new g,s.inflateGetHeader(this.strm,this.header)}function p(m,_){var f=new d(_);if(f.push(m,!0),f.err)throw f.msg||l[f.err];return f.result}d.prototype.push=function(m,_){var f,I,C,y,x,E,B=this.strm,S=this.options.chunkSize,Q=this.options.dictionary,w=!1;if(this.ended)return!1;I=_===~~_?_:_===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?B.input=A.binstring2buf(m):h.call(m)==="[object ArrayBuffer]"?B.input=new Uint8Array(m):B.input=m,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new a.Buf8(S),B.next_out=0,B.avail_out=S),(f=s.inflate(B,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&Q&&(E=typeof Q=="string"?A.string2buf(Q):h.call(Q)==="[object ArrayBuffer]"?new Uint8Array(Q):Q,f=s.inflateSetDictionary(this.strm,E)),f===c.Z_BUF_ERROR&&w===!0&&(f=c.Z_OK,w=!1),f!==c.Z_STREAM_END&&f!==c.Z_OK)return this.onEnd(f),!(this.ended=!0);B.next_out&&(B.avail_out!==0&&f!==c.Z_STREAM_END&&(B.avail_in!==0||I!==c.Z_FINISH&&I!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=A.utf8border(B.output,B.next_out),y=B.next_out-C,x=A.buf2string(B.output,C),B.next_out=y,B.avail_out=S-y,y&&a.arraySet(B.output,B.output,C,y,0),this.onData(x)):this.onData(a.shrinkBuf(B.output,B.next_out)))),B.avail_in===0&&B.avail_out===0&&(w=!0)}while((0<B.avail_in||B.avail_out===0)&&f!==c.Z_STREAM_END);return f===c.Z_STREAM_END&&(I=c.Z_FINISH),I===c.Z_FINISH?(f=s.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===c.Z_OK):I!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(B.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},r.Inflate=d,r.inflate=p,r.inflateRaw=function(m,_){return(_=_||{}).raw=!0,p(m,_)},r.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var u=l.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var g in u)u.hasOwnProperty(g)&&(c[g]=u[g])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var a={arraySet:function(c,l,u,g,h){if(l.subarray&&c.subarray)c.set(l.subarray(u,u+g),h);else for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){var l,u,g,h,d,p;for(l=g=0,u=c.length;l<u;l++)g+=c[l].length;for(p=new Uint8Array(g),l=h=0,u=c.length;l<u;l++)d=c[l],p.set(d,h),h+=d.length;return p}},A={arraySet:function(c,l,u,g,h){for(var d=0;d<g;d++)c[h+d]=l[u+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,A))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,A=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{A=!1}for(var c=new s.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function u(g,h){if(h<65537&&(g.subarray&&A||!g.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(g,h));for(var d="",p=0;p<h;p++)d+=String.fromCharCode(g[p]);return d}c[254]=c[254]=1,r.string2buf=function(g){var h,d,p,m,_,f=g.length,I=0;for(m=0;m<f;m++)(64512&(d=g.charCodeAt(m)))==55296&&m+1<f&&(64512&(p=g.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),m++),I+=d<128?1:d<2048?2:d<65536?3:4;for(h=new s.Buf8(I),m=_=0;_<I;m++)(64512&(d=g.charCodeAt(m)))==55296&&m+1<f&&(64512&(p=g.charCodeAt(m+1)))==56320&&(d=65536+(d-55296<<10)+(p-56320),m++),d<128?h[_++]=d:(d<2048?h[_++]=192|d>>>6:(d<65536?h[_++]=224|d>>>12:(h[_++]=240|d>>>18,h[_++]=128|d>>>12&63),h[_++]=128|d>>>6&63),h[_++]=128|63&d);return h},r.buf2binstring=function(g){return u(g,g.length)},r.binstring2buf=function(g){for(var h=new s.Buf8(g.length),d=0,p=h.length;d<p;d++)h[d]=g.charCodeAt(d);return h},r.buf2string=function(g,h){var d,p,m,_,f=h||g.length,I=new Array(2*f);for(d=p=0;d<f;)if((m=g[d++])<128)I[p++]=m;else if(4<(_=c[m]))I[p++]=65533,d+=_-1;else{for(m&=_===2?31:_===3?15:7;1<_&&d<f;)m=m<<6|63&g[d++],_--;1<_?I[p++]=65533:m<65536?I[p++]=m:(m-=65536,I[p++]=55296|m>>10&1023,I[p++]=56320|1023&m)}return u(I,p)},r.utf8border=function(g,h){var d;for((h=h||g.length)>g.length&&(h=g.length),d=h-1;0<=d&&(192&g[d])==128;)d--;return d<0||d===0?h:d+c[g[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,A,c){for(var l=65535&s|0,u=s>>>16&65535|0,g=0;A!==0;){for(A-=g=2e3<A?2e3:A;u=u+(l=l+a[c++]|0)|0,--g;);l%=65521,u%=65521}return l|u<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,A=[],c=0;c<256;c++){a=c;for(var l=0;l<8;l++)a=1&a?3988292384^a>>>1:a>>>1;A[c]=a}return A})();i.exports=function(a,A,c,l){var u=s,g=l+c;a^=-1;for(var h=l;h<g;h++)a=a>>>8^u[255&(a^A[h])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),A=o("./trees"),c=o("./adler32"),l=o("./crc32"),u=o("./messages"),g=0,h=4,d=0,p=-2,m=-1,_=4,f=2,I=8,C=9,y=286,x=30,E=19,B=2*y+1,S=15,Q=3,w=258,M=w+Q+1,k=42,R=113,F=1,O=2,U=3,Y=4;function W(he,Qe){return he.msg=u[Qe],Qe}function te(he){return(he<<1)-(4<he?9:0)}function j(he){for(var Qe=he.length;0<=--Qe;)he[Qe]=0}function J(he){var Qe=he.state,Pe=Qe.pending;Pe>he.avail_out&&(Pe=he.avail_out),Pe!==0&&(a.arraySet(he.output,Qe.pending_buf,Qe.pending_out,Pe,he.next_out),he.next_out+=Pe,Qe.pending_out+=Pe,he.total_out+=Pe,he.avail_out-=Pe,Qe.pending-=Pe,Qe.pending===0&&(Qe.pending_out=0))}function oe(he,Qe){A._tr_flush_block(he,0<=he.block_start?he.block_start:-1,he.strstart-he.block_start,Qe),he.block_start=he.strstart,J(he.strm)}function ie(he,Qe){he.pending_buf[he.pending++]=Qe}function ne(he,Qe){he.pending_buf[he.pending++]=Qe>>>8&255,he.pending_buf[he.pending++]=255&Qe}function le(he,Qe){var Pe,we,Te=he.max_chain_length,Re=he.strstart,Ee=he.prev_length,ke=he.nice_match,Ce=he.strstart>he.w_size-M?he.strstart-(he.w_size-M):0,Le=he.window,Ye=he.w_mask,tt=he.prev,At=he.strstart+w,at=Le[Re+Ee-1],nt=Le[Re+Ee];he.prev_length>=he.good_match&&(Te>>=2),ke>he.lookahead&&(ke=he.lookahead);do if(Le[(Pe=Qe)+Ee]===nt&&Le[Pe+Ee-1]===at&&Le[Pe]===Le[Re]&&Le[++Pe]===Le[Re+1]){Re+=2,Pe++;do;while(Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Le[++Re]===Le[++Pe]&&Re<At);if(we=w-(At-Re),Re=At-w,Ee<we){if(he.match_start=Qe,ke<=(Ee=we))break;at=Le[Re+Ee-1],nt=Le[Re+Ee]}}while((Qe=tt[Qe&Ye])>Ce&&--Te!=0);return Ee<=he.lookahead?Ee:he.lookahead}function ge(he){var Qe,Pe,we,Te,Re,Ee,ke,Ce,Le,Ye,tt=he.w_size;do{if(Te=he.window_size-he.lookahead-he.strstart,he.strstart>=tt+(tt-M)){for(a.arraySet(he.window,he.window,tt,tt,0),he.match_start-=tt,he.strstart-=tt,he.block_start-=tt,Qe=Pe=he.hash_size;we=he.head[--Qe],he.head[Qe]=tt<=we?we-tt:0,--Pe;);for(Qe=Pe=tt;we=he.prev[--Qe],he.prev[Qe]=tt<=we?we-tt:0,--Pe;);Te+=tt}if(he.strm.avail_in===0)break;if(Ee=he.strm,ke=he.window,Ce=he.strstart+he.lookahead,Le=Te,Ye=void 0,Ye=Ee.avail_in,Le<Ye&&(Ye=Le),Pe=Ye===0?0:(Ee.avail_in-=Ye,a.arraySet(ke,Ee.input,Ee.next_in,Ye,Ce),Ee.state.wrap===1?Ee.adler=c(Ee.adler,ke,Ye,Ce):Ee.state.wrap===2&&(Ee.adler=l(Ee.adler,ke,Ye,Ce)),Ee.next_in+=Ye,Ee.total_in+=Ye,Ye),he.lookahead+=Pe,he.lookahead+he.insert>=Q)for(Re=he.strstart-he.insert,he.ins_h=he.window[Re],he.ins_h=(he.ins_h<<he.hash_shift^he.window[Re+1])&he.hash_mask;he.insert&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[Re+Q-1])&he.hash_mask,he.prev[Re&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=Re,Re++,he.insert--,!(he.lookahead+he.insert<Q)););}while(he.lookahead<M&&he.strm.avail_in!==0)}function _e(he,Qe){for(var Pe,we;;){if(he.lookahead<M){if(ge(he),he.lookahead<M&&Qe===g)return F;if(he.lookahead===0)break}if(Pe=0,he.lookahead>=Q&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,Pe=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),Pe!==0&&he.strstart-Pe<=he.w_size-M&&(he.match_length=le(he,Pe)),he.match_length>=Q)if(we=A._tr_tally(he,he.strstart-he.match_start,he.match_length-Q),he.lookahead-=he.match_length,he.match_length<=he.max_lazy_match&&he.lookahead>=Q){for(he.match_length--;he.strstart++,he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,Pe=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart,--he.match_length!=0;);he.strstart++}else he.strstart+=he.match_length,he.match_length=0,he.ins_h=he.window[he.strstart],he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+1])&he.hash_mask;else we=A._tr_tally(he,0,he.window[he.strstart]),he.lookahead--,he.strstart++;if(we&&(oe(he,!1),he.strm.avail_out===0))return F}return he.insert=he.strstart<Q-1?he.strstart:Q-1,Qe===h?(oe(he,!0),he.strm.avail_out===0?U:Y):he.last_lit&&(oe(he,!1),he.strm.avail_out===0)?F:O}function ue(he,Qe){for(var Pe,we,Te;;){if(he.lookahead<M){if(ge(he),he.lookahead<M&&Qe===g)return F;if(he.lookahead===0)break}if(Pe=0,he.lookahead>=Q&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,Pe=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),he.prev_length=he.match_length,he.prev_match=he.match_start,he.match_length=Q-1,Pe!==0&&he.prev_length<he.max_lazy_match&&he.strstart-Pe<=he.w_size-M&&(he.match_length=le(he,Pe),he.match_length<=5&&(he.strategy===1||he.match_length===Q&&4096<he.strstart-he.match_start)&&(he.match_length=Q-1)),he.prev_length>=Q&&he.match_length<=he.prev_length){for(Te=he.strstart+he.lookahead-Q,we=A._tr_tally(he,he.strstart-1-he.prev_match,he.prev_length-Q),he.lookahead-=he.prev_length-1,he.prev_length-=2;++he.strstart<=Te&&(he.ins_h=(he.ins_h<<he.hash_shift^he.window[he.strstart+Q-1])&he.hash_mask,Pe=he.prev[he.strstart&he.w_mask]=he.head[he.ins_h],he.head[he.ins_h]=he.strstart),--he.prev_length!=0;);if(he.match_available=0,he.match_length=Q-1,he.strstart++,we&&(oe(he,!1),he.strm.avail_out===0))return F}else if(he.match_available){if((we=A._tr_tally(he,0,he.window[he.strstart-1]))&&oe(he,!1),he.strstart++,he.lookahead--,he.strm.avail_out===0)return F}else he.match_available=1,he.strstart++,he.lookahead--}return he.match_available&&(we=A._tr_tally(he,0,he.window[he.strstart-1]),he.match_available=0),he.insert=he.strstart<Q-1?he.strstart:Q-1,Qe===h?(oe(he,!0),he.strm.avail_out===0?U:Y):he.last_lit&&(oe(he,!1),he.strm.avail_out===0)?F:O}function fe(he,Qe,Pe,we,Te){this.good_length=he,this.max_lazy=Qe,this.nice_length=Pe,this.max_chain=we,this.func=Te}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=I,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*B),this.dyn_dtree=new a.Buf16(2*(2*x+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),j(this.dyn_ltree),j(this.dyn_dtree),j(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(S+1),this.heap=new a.Buf16(2*y+1),j(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),j(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ye(he){var Qe;return he&&he.state?(he.total_in=he.total_out=0,he.data_type=f,(Qe=he.state).pending=0,Qe.pending_out=0,Qe.wrap<0&&(Qe.wrap=-Qe.wrap),Qe.status=Qe.wrap?k:R,he.adler=Qe.wrap===2?0:1,Qe.last_flush=g,A._tr_init(Qe),d):W(he,p)}function Me(he){var Qe=ye(he);return Qe===d&&(function(Pe){Pe.window_size=2*Pe.w_size,j(Pe.head),Pe.max_lazy_match=s[Pe.level].max_lazy,Pe.good_match=s[Pe.level].good_length,Pe.nice_match=s[Pe.level].nice_length,Pe.max_chain_length=s[Pe.level].max_chain,Pe.strstart=0,Pe.block_start=0,Pe.lookahead=0,Pe.insert=0,Pe.match_length=Pe.prev_length=Q-1,Pe.match_available=0,Pe.ins_h=0})(he.state),Qe}function ve(he,Qe,Pe,we,Te,Re){if(!he)return p;var Ee=1;if(Qe===m&&(Qe=6),we<0?(Ee=0,we=-we):15<we&&(Ee=2,we-=16),Te<1||C<Te||Pe!==I||we<8||15<we||Qe<0||9<Qe||Re<0||_<Re)return W(he,p);we===8&&(we=9);var ke=new pe;return(he.state=ke).strm=he,ke.wrap=Ee,ke.gzhead=null,ke.w_bits=we,ke.w_size=1<<ke.w_bits,ke.w_mask=ke.w_size-1,ke.hash_bits=Te+7,ke.hash_size=1<<ke.hash_bits,ke.hash_mask=ke.hash_size-1,ke.hash_shift=~~((ke.hash_bits+Q-1)/Q),ke.window=new a.Buf8(2*ke.w_size),ke.head=new a.Buf16(ke.hash_size),ke.prev=new a.Buf16(ke.w_size),ke.lit_bufsize=1<<Te+6,ke.pending_buf_size=4*ke.lit_bufsize,ke.pending_buf=new a.Buf8(ke.pending_buf_size),ke.d_buf=1*ke.lit_bufsize,ke.l_buf=3*ke.lit_bufsize,ke.level=Qe,ke.strategy=Re,ke.method=Pe,Me(he)}s=[new fe(0,0,0,0,function(he,Qe){var Pe=65535;for(Pe>he.pending_buf_size-5&&(Pe=he.pending_buf_size-5);;){if(he.lookahead<=1){if(ge(he),he.lookahead===0&&Qe===g)return F;if(he.lookahead===0)break}he.strstart+=he.lookahead,he.lookahead=0;var we=he.block_start+Pe;if((he.strstart===0||he.strstart>=we)&&(he.lookahead=he.strstart-we,he.strstart=we,oe(he,!1),he.strm.avail_out===0)||he.strstart-he.block_start>=he.w_size-M&&(oe(he,!1),he.strm.avail_out===0))return F}return he.insert=0,Qe===h?(oe(he,!0),he.strm.avail_out===0?U:Y):(he.strstart>he.block_start&&(oe(he,!1),he.strm.avail_out),F)}),new fe(4,4,8,4,_e),new fe(4,5,16,8,_e),new fe(4,6,32,32,_e),new fe(4,4,16,16,ue),new fe(8,16,32,32,ue),new fe(8,16,128,128,ue),new fe(8,32,128,256,ue),new fe(32,128,258,1024,ue),new fe(32,258,258,4096,ue)],r.deflateInit=function(he,Qe){return ve(he,Qe,I,15,8,0)},r.deflateInit2=ve,r.deflateReset=Me,r.deflateResetKeep=ye,r.deflateSetHeader=function(he,Qe){return he&&he.state?he.state.wrap!==2?p:(he.state.gzhead=Qe,d):p},r.deflate=function(he,Qe){var Pe,we,Te,Re;if(!he||!he.state||5<Qe||Qe<0)return he?W(he,p):p;if(we=he.state,!he.output||!he.input&&he.avail_in!==0||we.status===666&&Qe!==h)return W(he,he.avail_out===0?-5:p);if(we.strm=he,Pe=we.last_flush,we.last_flush=Qe,we.status===k)if(we.wrap===2)he.adler=0,ie(we,31),ie(we,139),ie(we,8),we.gzhead?(ie(we,(we.gzhead.text?1:0)+(we.gzhead.hcrc?2:0)+(we.gzhead.extra?4:0)+(we.gzhead.name?8:0)+(we.gzhead.comment?16:0)),ie(we,255&we.gzhead.time),ie(we,we.gzhead.time>>8&255),ie(we,we.gzhead.time>>16&255),ie(we,we.gzhead.time>>24&255),ie(we,we.level===9?2:2<=we.strategy||we.level<2?4:0),ie(we,255&we.gzhead.os),we.gzhead.extra&&we.gzhead.extra.length&&(ie(we,255&we.gzhead.extra.length),ie(we,we.gzhead.extra.length>>8&255)),we.gzhead.hcrc&&(he.adler=l(he.adler,we.pending_buf,we.pending,0)),we.gzindex=0,we.status=69):(ie(we,0),ie(we,0),ie(we,0),ie(we,0),ie(we,0),ie(we,we.level===9?2:2<=we.strategy||we.level<2?4:0),ie(we,3),we.status=R);else{var Ee=I+(we.w_bits-8<<4)<<8;Ee|=(2<=we.strategy||we.level<2?0:we.level<6?1:we.level===6?2:3)<<6,we.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,we.status=R,ne(we,Ee),we.strstart!==0&&(ne(we,he.adler>>>16),ne(we,65535&he.adler)),he.adler=1}if(we.status===69)if(we.gzhead.extra){for(Te=we.pending;we.gzindex<(65535&we.gzhead.extra.length)&&(we.pending!==we.pending_buf_size||(we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),J(he),Te=we.pending,we.pending!==we.pending_buf_size));)ie(we,255&we.gzhead.extra[we.gzindex]),we.gzindex++;we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),we.gzindex===we.gzhead.extra.length&&(we.gzindex=0,we.status=73)}else we.status=73;if(we.status===73)if(we.gzhead.name){Te=we.pending;do{if(we.pending===we.pending_buf_size&&(we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),J(he),Te=we.pending,we.pending===we.pending_buf_size)){Re=1;break}Re=we.gzindex<we.gzhead.name.length?255&we.gzhead.name.charCodeAt(we.gzindex++):0,ie(we,Re)}while(Re!==0);we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),Re===0&&(we.gzindex=0,we.status=91)}else we.status=91;if(we.status===91)if(we.gzhead.comment){Te=we.pending;do{if(we.pending===we.pending_buf_size&&(we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),J(he),Te=we.pending,we.pending===we.pending_buf_size)){Re=1;break}Re=we.gzindex<we.gzhead.comment.length?255&we.gzhead.comment.charCodeAt(we.gzindex++):0,ie(we,Re)}while(Re!==0);we.gzhead.hcrc&&we.pending>Te&&(he.adler=l(he.adler,we.pending_buf,we.pending-Te,Te)),Re===0&&(we.status=103)}else we.status=103;if(we.status===103&&(we.gzhead.hcrc?(we.pending+2>we.pending_buf_size&&J(he),we.pending+2<=we.pending_buf_size&&(ie(we,255&he.adler),ie(we,he.adler>>8&255),he.adler=0,we.status=R)):we.status=R),we.pending!==0){if(J(he),he.avail_out===0)return we.last_flush=-1,d}else if(he.avail_in===0&&te(Qe)<=te(Pe)&&Qe!==h)return W(he,-5);if(we.status===666&&he.avail_in!==0)return W(he,-5);if(he.avail_in!==0||we.lookahead!==0||Qe!==g&&we.status!==666){var ke=we.strategy===2?(function(Ce,Le){for(var Ye;;){if(Ce.lookahead===0&&(ge(Ce),Ce.lookahead===0)){if(Le===g)return F;break}if(Ce.match_length=0,Ye=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++,Ye&&(oe(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Le===h?(oe(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(oe(Ce,!1),Ce.strm.avail_out===0)?F:O})(we,Qe):we.strategy===3?(function(Ce,Le){for(var Ye,tt,At,at,nt=Ce.window;;){if(Ce.lookahead<=w){if(ge(Ce),Ce.lookahead<=w&&Le===g)return F;if(Ce.lookahead===0)break}if(Ce.match_length=0,Ce.lookahead>=Q&&0<Ce.strstart&&(tt=nt[At=Ce.strstart-1])===nt[++At]&&tt===nt[++At]&&tt===nt[++At]){at=Ce.strstart+w;do;while(tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&tt===nt[++At]&&At<at);Ce.match_length=w-(at-At),Ce.match_length>Ce.lookahead&&(Ce.match_length=Ce.lookahead)}if(Ce.match_length>=Q?(Ye=A._tr_tally(Ce,1,Ce.match_length-Q),Ce.lookahead-=Ce.match_length,Ce.strstart+=Ce.match_length,Ce.match_length=0):(Ye=A._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++),Ye&&(oe(Ce,!1),Ce.strm.avail_out===0))return F}return Ce.insert=0,Le===h?(oe(Ce,!0),Ce.strm.avail_out===0?U:Y):Ce.last_lit&&(oe(Ce,!1),Ce.strm.avail_out===0)?F:O})(we,Qe):s[we.level].func(we,Qe);if(ke!==U&&ke!==Y||(we.status=666),ke===F||ke===U)return he.avail_out===0&&(we.last_flush=-1),d;if(ke===O&&(Qe===1?A._tr_align(we):Qe!==5&&(A._tr_stored_block(we,0,0,!1),Qe===3&&(j(we.head),we.lookahead===0&&(we.strstart=0,we.block_start=0,we.insert=0))),J(he),he.avail_out===0))return we.last_flush=-1,d}return Qe!==h?d:we.wrap<=0?1:(we.wrap===2?(ie(we,255&he.adler),ie(we,he.adler>>8&255),ie(we,he.adler>>16&255),ie(we,he.adler>>24&255),ie(we,255&he.total_in),ie(we,he.total_in>>8&255),ie(we,he.total_in>>16&255),ie(we,he.total_in>>24&255)):(ne(we,he.adler>>>16),ne(we,65535&he.adler)),J(he),0<we.wrap&&(we.wrap=-we.wrap),we.pending!==0?d:1)},r.deflateEnd=function(he){var Qe;return he&&he.state?(Qe=he.state.status)!==k&&Qe!==69&&Qe!==73&&Qe!==91&&Qe!==103&&Qe!==R&&Qe!==666?W(he,p):(he.state=null,Qe===R?W(he,-3):d):p},r.deflateSetDictionary=function(he,Qe){var Pe,we,Te,Re,Ee,ke,Ce,Le,Ye=Qe.length;if(!he||!he.state||(Re=(Pe=he.state).wrap)===2||Re===1&&Pe.status!==k||Pe.lookahead)return p;for(Re===1&&(he.adler=c(he.adler,Qe,Ye,0)),Pe.wrap=0,Ye>=Pe.w_size&&(Re===0&&(j(Pe.head),Pe.strstart=0,Pe.block_start=0,Pe.insert=0),Le=new a.Buf8(Pe.w_size),a.arraySet(Le,Qe,Ye-Pe.w_size,Pe.w_size,0),Qe=Le,Ye=Pe.w_size),Ee=he.avail_in,ke=he.next_in,Ce=he.input,he.avail_in=Ye,he.next_in=0,he.input=Qe,ge(Pe);Pe.lookahead>=Q;){for(we=Pe.strstart,Te=Pe.lookahead-(Q-1);Pe.ins_h=(Pe.ins_h<<Pe.hash_shift^Pe.window[we+Q-1])&Pe.hash_mask,Pe.prev[we&Pe.w_mask]=Pe.head[Pe.ins_h],Pe.head[Pe.ins_h]=we,we++,--Te;);Pe.strstart=we,Pe.lookahead=Q-1,ge(Pe)}return Pe.strstart+=Pe.lookahead,Pe.block_start=Pe.strstart,Pe.insert=Pe.lookahead,Pe.lookahead=0,Pe.match_length=Pe.prev_length=Q-1,Pe.match_available=0,he.next_in=ke,he.input=Ce,he.avail_in=Ee,Pe.wrap=Re,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var A,c,l,u,g,h,d,p,m,_,f,I,C,y,x,E,B,S,Q,w,M,k,R,F,O;A=s.state,c=s.next_in,F=s.input,l=c+(s.avail_in-5),u=s.next_out,O=s.output,g=u-(a-s.avail_out),h=u+(s.avail_out-257),d=A.dmax,p=A.wsize,m=A.whave,_=A.wnext,f=A.window,I=A.hold,C=A.bits,y=A.lencode,x=A.distcode,E=(1<<A.lenbits)-1,B=(1<<A.distbits)-1;e:do{C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=y[I&E];t:for(;;){if(I>>>=Q=S>>>24,C-=Q,(Q=S>>>16&255)===0)O[u++]=65535&S;else{if(!(16&Q)){if((64&Q)==0){S=y[(65535&S)+(I&(1<<Q)-1)];continue t}if(32&Q){A.mode=12;break e}s.msg="invalid literal/length code",A.mode=30;break e}w=65535&S,(Q&=15)&&(C<Q&&(I+=F[c++]<<C,C+=8),w+=I&(1<<Q)-1,I>>>=Q,C-=Q),C<15&&(I+=F[c++]<<C,C+=8,I+=F[c++]<<C,C+=8),S=x[I&B];n:for(;;){if(I>>>=Q=S>>>24,C-=Q,!(16&(Q=S>>>16&255))){if((64&Q)==0){S=x[(65535&S)+(I&(1<<Q)-1)];continue n}s.msg="invalid distance code",A.mode=30;break e}if(M=65535&S,C<(Q&=15)&&(I+=F[c++]<<C,(C+=8)<Q&&(I+=F[c++]<<C,C+=8)),d<(M+=I&(1<<Q)-1)){s.msg="invalid distance too far back",A.mode=30;break e}if(I>>>=Q,C-=Q,(Q=u-g)<M){if(m<(Q=M-Q)&&A.sane){s.msg="invalid distance too far back",A.mode=30;break e}if(R=f,(k=0)===_){if(k+=p-Q,Q<w){for(w-=Q;O[u++]=f[k++],--Q;);k=u-M,R=O}}else if(_<Q){if(k+=p+_-Q,(Q-=_)<w){for(w-=Q;O[u++]=f[k++],--Q;);if(k=0,_<w){for(w-=Q=_;O[u++]=f[k++],--Q;);k=u-M,R=O}}}else if(k+=_-Q,Q<w){for(w-=Q;O[u++]=f[k++],--Q;);k=u-M,R=O}for(;2<w;)O[u++]=R[k++],O[u++]=R[k++],O[u++]=R[k++],w-=3;w&&(O[u++]=R[k++],1<w&&(O[u++]=R[k++]))}else{for(k=u-M;O[u++]=O[k++],O[u++]=O[k++],O[u++]=O[k++],2<(w-=3););w&&(O[u++]=O[k++],1<w&&(O[u++]=O[k++]))}break}}break}}while(c<l&&u<h);c-=w=C>>3,I&=(1<<(C-=w<<3))-1,s.next_in=c,s.next_out=u,s.avail_in=c<l?l-c+5:5-(c-l),s.avail_out=u<h?h-u+257:257-(u-h),A.hold=I,A.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),A=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),u=1,g=2,h=0,d=-2,p=1,m=852,_=592;function f(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function I(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(k){var R;return k&&k.state?(R=k.state,k.total_in=k.total_out=R.total=0,k.msg="",R.wrap&&(k.adler=1&R.wrap),R.mode=p,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new s.Buf32(m),R.distcode=R.distdyn=new s.Buf32(_),R.sane=1,R.back=-1,h):d}function y(k){var R;return k&&k.state?((R=k.state).wsize=0,R.whave=0,R.wnext=0,C(k)):d}function x(k,R){var F,O;return k&&k.state?(O=k.state,R<0?(F=0,R=-R):(F=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15<R)?d:(O.window!==null&&O.wbits!==R&&(O.window=null),O.wrap=F,O.wbits=R,y(k))):d}function E(k,R){var F,O;return k?(O=new I,(k.state=O).window=null,(F=x(k,R))!==h&&(k.state=null),F):d}var B,S,Q=!0;function w(k){if(Q){var R;for(B=new s.Buf32(512),S=new s.Buf32(32),R=0;R<144;)k.lens[R++]=8;for(;R<256;)k.lens[R++]=9;for(;R<280;)k.lens[R++]=7;for(;R<288;)k.lens[R++]=8;for(l(u,k.lens,0,288,B,0,k.work,{bits:9}),R=0;R<32;)k.lens[R++]=5;l(g,k.lens,0,32,S,0,k.work,{bits:5}),Q=!1}k.lencode=B,k.lenbits=9,k.distcode=S,k.distbits=5}function M(k,R,F,O){var U,Y=k.state;return Y.window===null&&(Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new s.Buf8(Y.wsize)),O>=Y.wsize?(s.arraySet(Y.window,R,F-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize):(O<(U=Y.wsize-Y.wnext)&&(U=O),s.arraySet(Y.window,R,F-O,U,Y.wnext),(O-=U)?(s.arraySet(Y.window,R,F-O,O,0),Y.wnext=O,Y.whave=Y.wsize):(Y.wnext+=U,Y.wnext===Y.wsize&&(Y.wnext=0),Y.whave<Y.wsize&&(Y.whave+=U))),0}r.inflateReset=y,r.inflateReset2=x,r.inflateResetKeep=C,r.inflateInit=function(k){return E(k,15)},r.inflateInit2=E,r.inflate=function(k,R){var F,O,U,Y,W,te,j,J,oe,ie,ne,le,ge,_e,ue,fe,pe,ye,Me,ve,he,Qe,Pe,we,Te=0,Re=new s.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return d;(F=k.state).mode===12&&(F.mode=13),W=k.next_out,U=k.output,j=k.avail_out,Y=k.next_in,O=k.input,te=k.avail_in,J=F.hold,oe=F.bits,ie=te,ne=j,Qe=h;e:for(;;)switch(F.mode){case p:if(F.wrap===0){F.mode=13;break}for(;oe<16;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(2&F.wrap&&J===35615){Re[F.check=0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0),oe=J=0,F.mode=2;break}if(F.flags=0,F.head&&(F.head.done=!1),!(1&F.wrap)||(((255&J)<<8)+(J>>8))%31){k.msg="incorrect header check",F.mode=30;break}if((15&J)!=8){k.msg="unknown compression method",F.mode=30;break}if(oe-=4,he=8+(15&(J>>>=4)),F.wbits===0)F.wbits=he;else if(he>F.wbits){k.msg="invalid window size",F.mode=30;break}F.dmax=1<<he,k.adler=F.check=1,F.mode=512&J?10:12,oe=J=0;break;case 2:for(;oe<16;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(F.flags=J,(255&F.flags)!=8){k.msg="unknown compression method",F.mode=30;break}if(57344&F.flags){k.msg="unknown header flags set",F.mode=30;break}F.head&&(F.head.text=J>>8&1),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),oe=J=0,F.mode=3;case 3:for(;oe<32;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.head&&(F.head.time=J),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,Re[2]=J>>>16&255,Re[3]=J>>>24&255,F.check=A(F.check,Re,4,0)),oe=J=0,F.mode=4;case 4:for(;oe<16;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.head&&(F.head.xflags=255&J,F.head.os=J>>8),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),oe=J=0,F.mode=5;case 5:if(1024&F.flags){for(;oe<16;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.length=J,F.head&&(F.head.extra_len=J),512&F.flags&&(Re[0]=255&J,Re[1]=J>>>8&255,F.check=A(F.check,Re,2,0)),oe=J=0}else F.head&&(F.head.extra=null);F.mode=6;case 6:if(1024&F.flags&&(te<(le=F.length)&&(le=te),le&&(F.head&&(he=F.head.extra_len-F.length,F.head.extra||(F.head.extra=new Array(F.head.extra_len)),s.arraySet(F.head.extra,O,Y,le,he)),512&F.flags&&(F.check=A(F.check,O,le,Y)),te-=le,Y+=le,F.length-=le),F.length))break e;F.length=0,F.mode=7;case 7:if(2048&F.flags){if(te===0)break e;for(le=0;he=O[Y+le++],F.head&&he&&F.length<65536&&(F.head.name+=String.fromCharCode(he)),he&&le<te;);if(512&F.flags&&(F.check=A(F.check,O,le,Y)),te-=le,Y+=le,he)break e}else F.head&&(F.head.name=null);F.length=0,F.mode=8;case 8:if(4096&F.flags){if(te===0)break e;for(le=0;he=O[Y+le++],F.head&&he&&F.length<65536&&(F.head.comment+=String.fromCharCode(he)),he&&le<te;);if(512&F.flags&&(F.check=A(F.check,O,le,Y)),te-=le,Y+=le,he)break e}else F.head&&(F.head.comment=null);F.mode=9;case 9:if(512&F.flags){for(;oe<16;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(J!==(65535&F.check)){k.msg="header crc mismatch",F.mode=30;break}oe=J=0}F.head&&(F.head.hcrc=F.flags>>9&1,F.head.done=!0),k.adler=F.check=0,F.mode=12;break;case 10:for(;oe<32;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}k.adler=F.check=f(J),oe=J=0,F.mode=11;case 11:if(F.havedict===0)return k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=oe,2;k.adler=F.check=1,F.mode=12;case 12:if(R===5||R===6)break e;case 13:if(F.last){J>>>=7&oe,oe-=7&oe,F.mode=27;break}for(;oe<3;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}switch(F.last=1&J,oe-=1,3&(J>>>=1)){case 0:F.mode=14;break;case 1:if(w(F),F.mode=20,R!==6)break;J>>>=2,oe-=2;break e;case 2:F.mode=17;break;case 3:k.msg="invalid block type",F.mode=30}J>>>=2,oe-=2;break;case 14:for(J>>>=7&oe,oe-=7&oe;oe<32;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if((65535&J)!=(J>>>16^65535)){k.msg="invalid stored block lengths",F.mode=30;break}if(F.length=65535&J,oe=J=0,F.mode=15,R===6)break e;case 15:F.mode=16;case 16:if(le=F.length){if(te<le&&(le=te),j<le&&(le=j),le===0)break e;s.arraySet(U,O,Y,le,W),te-=le,Y+=le,j-=le,W+=le,F.length-=le;break}F.mode=12;break;case 17:for(;oe<14;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(F.nlen=257+(31&J),J>>>=5,oe-=5,F.ndist=1+(31&J),J>>>=5,oe-=5,F.ncode=4+(15&J),J>>>=4,oe-=4,286<F.nlen||30<F.ndist){k.msg="too many length or distance symbols",F.mode=30;break}F.have=0,F.mode=18;case 18:for(;F.have<F.ncode;){for(;oe<3;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.lens[Ee[F.have++]]=7&J,J>>>=3,oe-=3}for(;F.have<19;)F.lens[Ee[F.have++]]=0;if(F.lencode=F.lendyn,F.lenbits=7,Pe={bits:F.lenbits},Qe=l(0,F.lens,0,19,F.lencode,0,F.work,Pe),F.lenbits=Pe.bits,Qe){k.msg="invalid code lengths set",F.mode=30;break}F.have=0,F.mode=19;case 19:for(;F.have<F.nlen+F.ndist;){for(;fe=(Te=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,pe=65535&Te,!((ue=Te>>>24)<=oe);){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(pe<16)J>>>=ue,oe-=ue,F.lens[F.have++]=pe;else{if(pe===16){for(we=ue+2;oe<we;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(J>>>=ue,oe-=ue,F.have===0){k.msg="invalid bit length repeat",F.mode=30;break}he=F.lens[F.have-1],le=3+(3&J),J>>>=2,oe-=2}else if(pe===17){for(we=ue+3;oe<we;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}oe-=ue,he=0,le=3+(7&(J>>>=ue)),J>>>=3,oe-=3}else{for(we=ue+7;oe<we;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}oe-=ue,he=0,le=11+(127&(J>>>=ue)),J>>>=7,oe-=7}if(F.have+le>F.nlen+F.ndist){k.msg="invalid bit length repeat",F.mode=30;break}for(;le--;)F.lens[F.have++]=he}}if(F.mode===30)break;if(F.lens[256]===0){k.msg="invalid code -- missing end-of-block",F.mode=30;break}if(F.lenbits=9,Pe={bits:F.lenbits},Qe=l(u,F.lens,0,F.nlen,F.lencode,0,F.work,Pe),F.lenbits=Pe.bits,Qe){k.msg="invalid literal/lengths set",F.mode=30;break}if(F.distbits=6,F.distcode=F.distdyn,Pe={bits:F.distbits},Qe=l(g,F.lens,F.nlen,F.ndist,F.distcode,0,F.work,Pe),F.distbits=Pe.bits,Qe){k.msg="invalid distances set",F.mode=30;break}if(F.mode=20,R===6)break e;case 20:F.mode=21;case 21:if(6<=te&&258<=j){k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=oe,c(k,ne),W=k.next_out,U=k.output,j=k.avail_out,Y=k.next_in,O=k.input,te=k.avail_in,J=F.hold,oe=F.bits,F.mode===12&&(F.back=-1);break}for(F.back=0;fe=(Te=F.lencode[J&(1<<F.lenbits)-1])>>>16&255,pe=65535&Te,!((ue=Te>>>24)<=oe);){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(fe&&(240&fe)==0){for(ye=ue,Me=fe,ve=pe;fe=(Te=F.lencode[ve+((J&(1<<ye+Me)-1)>>ye)])>>>16&255,pe=65535&Te,!(ye+(ue=Te>>>24)<=oe);){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}J>>>=ye,oe-=ye,F.back+=ye}if(J>>>=ue,oe-=ue,F.back+=ue,F.length=pe,fe===0){F.mode=26;break}if(32&fe){F.back=-1,F.mode=12;break}if(64&fe){k.msg="invalid literal/length code",F.mode=30;break}F.extra=15&fe,F.mode=22;case 22:if(F.extra){for(we=F.extra;oe<we;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.length+=J&(1<<F.extra)-1,J>>>=F.extra,oe-=F.extra,F.back+=F.extra}F.was=F.length,F.mode=23;case 23:for(;fe=(Te=F.distcode[J&(1<<F.distbits)-1])>>>16&255,pe=65535&Te,!((ue=Te>>>24)<=oe);){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if((240&fe)==0){for(ye=ue,Me=fe,ve=pe;fe=(Te=F.distcode[ve+((J&(1<<ye+Me)-1)>>ye)])>>>16&255,pe=65535&Te,!(ye+(ue=Te>>>24)<=oe);){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}J>>>=ye,oe-=ye,F.back+=ye}if(J>>>=ue,oe-=ue,F.back+=ue,64&fe){k.msg="invalid distance code",F.mode=30;break}F.offset=pe,F.extra=15&fe,F.mode=24;case 24:if(F.extra){for(we=F.extra;oe<we;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}F.offset+=J&(1<<F.extra)-1,J>>>=F.extra,oe-=F.extra,F.back+=F.extra}if(F.offset>F.dmax){k.msg="invalid distance too far back",F.mode=30;break}F.mode=25;case 25:if(j===0)break e;if(le=ne-j,F.offset>le){if((le=F.offset-le)>F.whave&&F.sane){k.msg="invalid distance too far back",F.mode=30;break}ge=le>F.wnext?(le-=F.wnext,F.wsize-le):F.wnext-le,le>F.length&&(le=F.length),_e=F.window}else _e=U,ge=W-F.offset,le=F.length;for(j<le&&(le=j),j-=le,F.length-=le;U[W++]=_e[ge++],--le;);F.length===0&&(F.mode=21);break;case 26:if(j===0)break e;U[W++]=F.length,j--,F.mode=21;break;case 27:if(F.wrap){for(;oe<32;){if(te===0)break e;te--,J|=O[Y++]<<oe,oe+=8}if(ne-=j,k.total_out+=ne,F.total+=ne,ne&&(k.adler=F.check=F.flags?A(F.check,U,ne,W-ne):a(F.check,U,ne,W-ne)),ne=j,(F.flags?J:f(J))!==F.check){k.msg="incorrect data check",F.mode=30;break}oe=J=0}F.mode=28;case 28:if(F.wrap&&F.flags){for(;oe<32;){if(te===0)break e;te--,J+=O[Y++]<<oe,oe+=8}if(J!==(4294967295&F.total)){k.msg="incorrect length check",F.mode=30;break}oe=J=0}F.mode=29;case 29:Qe=1;break e;case 30:Qe=-3;break e;case 31:return-4;default:return d}return k.next_out=W,k.avail_out=j,k.next_in=Y,k.avail_in=te,F.hold=J,F.bits=oe,(F.wsize||ne!==k.avail_out&&F.mode<30&&(F.mode<27||R!==4))&&M(k,k.output,k.next_out,ne-k.avail_out)?(F.mode=31,-4):(ie-=k.avail_in,ne-=k.avail_out,k.total_in+=ie,k.total_out+=ne,F.total+=ne,F.wrap&&ne&&(k.adler=F.check=F.flags?A(F.check,U,ne,k.next_out-ne):a(F.check,U,ne,k.next_out-ne)),k.data_type=F.bits+(F.last?64:0)+(F.mode===12?128:0)+(F.mode===20||F.mode===15?256:0),(ie==0&&ne===0||R===4)&&Qe===h&&(Qe=-5),Qe)},r.inflateEnd=function(k){if(!k||!k.state)return d;var R=k.state;return R.window&&(R.window=null),k.state=null,h},r.inflateGetHeader=function(k,R){var F;return k&&k.state?(2&(F=k.state).wrap)==0?d:((F.head=R).done=!1,h):d},r.inflateSetDictionary=function(k,R){var F,O=R.length;return k&&k.state?(F=k.state).wrap!==0&&F.mode!==11?d:F.mode===11&&a(1,R,O,0)!==F.check?-3:M(k,R,O,O)?(F.mode=31,-4):(F.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],A=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,g,h,d,p,m,_,f){var I,C,y,x,E,B,S,Q,w,M=f.bits,k=0,R=0,F=0,O=0,U=0,Y=0,W=0,te=0,j=0,J=0,oe=null,ie=0,ne=new s.Buf16(16),le=new s.Buf16(16),ge=null,_e=0;for(k=0;k<=15;k++)ne[k]=0;for(R=0;R<d;R++)ne[g[h+R]]++;for(U=M,O=15;1<=O&&ne[O]===0;O--);if(O<U&&(U=O),O===0)return p[m++]=20971520,p[m++]=20971520,f.bits=1,0;for(F=1;F<O&&ne[F]===0;F++);for(U<F&&(U=F),k=te=1;k<=15;k++)if(te<<=1,(te-=ne[k])<0)return-1;if(0<te&&(u===0||O!==1))return-1;for(le[1]=0,k=1;k<15;k++)le[k+1]=le[k]+ne[k];for(R=0;R<d;R++)g[h+R]!==0&&(_[le[g[h+R]]++]=R);if(B=u===0?(oe=ge=_,19):u===1?(oe=a,ie-=257,ge=A,_e-=257,256):(oe=c,ge=l,-1),k=F,E=m,W=R=J=0,y=-1,x=(j=1<<(Y=U))-1,u===1&&852<j||u===2&&592<j)return 1;for(;;){for(S=k-W,w=_[R]<B?(Q=0,_[R]):_[R]>B?(Q=ge[_e+_[R]],oe[ie+_[R]]):(Q=96,0),I=1<<k-W,F=C=1<<Y;p[E+(J>>W)+(C-=I)]=S<<24|Q<<16|w|0,C!==0;);for(I=1<<k-1;J&I;)I>>=1;if(I!==0?(J&=I-1,J+=I):J=0,R++,--ne[k]==0){if(k===O)break;k=g[h+_[R]]}if(U<k&&(J&x)!==y){for(W===0&&(W=U),E+=F,te=1<<(Y=k-W);Y+W<O&&!((te-=ne[Y+W])<=0);)Y++,te<<=1;if(j+=1<<Y,u===1&&852<j||u===2&&592<j)return 1;p[y=J&x]=U<<24|Y<<16|E-m|0}}return J!==0&&(p[E+J]=k-W<<24|64<<16|0),f.bits=U,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,A=1;function c(Te){for(var Re=Te.length;0<=--Re;)Te[Re]=0}var l=0,u=29,g=256,h=g+1+u,d=30,p=19,m=2*h+1,_=15,f=16,I=7,C=256,y=16,x=17,E=18,B=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],S=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=new Array(2*(h+2));c(M);var k=new Array(2*d);c(k);var R=new Array(512);c(R);var F=new Array(256);c(F);var O=new Array(u);c(O);var U,Y,W,te=new Array(d);function j(Te,Re,Ee,ke,Ce){this.static_tree=Te,this.extra_bits=Re,this.extra_base=Ee,this.elems=ke,this.max_length=Ce,this.has_stree=Te&&Te.length}function J(Te,Re){this.dyn_tree=Te,this.max_code=0,this.stat_desc=Re}function oe(Te){return Te<256?R[Te]:R[256+(Te>>>7)]}function ie(Te,Re){Te.pending_buf[Te.pending++]=255&Re,Te.pending_buf[Te.pending++]=Re>>>8&255}function ne(Te,Re,Ee){Te.bi_valid>f-Ee?(Te.bi_buf|=Re<<Te.bi_valid&65535,ie(Te,Te.bi_buf),Te.bi_buf=Re>>f-Te.bi_valid,Te.bi_valid+=Ee-f):(Te.bi_buf|=Re<<Te.bi_valid&65535,Te.bi_valid+=Ee)}function le(Te,Re,Ee){ne(Te,Ee[2*Re],Ee[2*Re+1])}function ge(Te,Re){for(var Ee=0;Ee|=1&Te,Te>>>=1,Ee<<=1,0<--Re;);return Ee>>>1}function _e(Te,Re,Ee){var ke,Ce,Le=new Array(_+1),Ye=0;for(ke=1;ke<=_;ke++)Le[ke]=Ye=Ye+Ee[ke-1]<<1;for(Ce=0;Ce<=Re;Ce++){var tt=Te[2*Ce+1];tt!==0&&(Te[2*Ce]=ge(Le[tt]++,tt))}}function ue(Te){var Re;for(Re=0;Re<h;Re++)Te.dyn_ltree[2*Re]=0;for(Re=0;Re<d;Re++)Te.dyn_dtree[2*Re]=0;for(Re=0;Re<p;Re++)Te.bl_tree[2*Re]=0;Te.dyn_ltree[2*C]=1,Te.opt_len=Te.static_len=0,Te.last_lit=Te.matches=0}function fe(Te){8<Te.bi_valid?ie(Te,Te.bi_buf):0<Te.bi_valid&&(Te.pending_buf[Te.pending++]=Te.bi_buf),Te.bi_buf=0,Te.bi_valid=0}function pe(Te,Re,Ee,ke){var Ce=2*Re,Le=2*Ee;return Te[Ce]<Te[Le]||Te[Ce]===Te[Le]&&ke[Re]<=ke[Ee]}function ye(Te,Re,Ee){for(var ke=Te.heap[Ee],Ce=Ee<<1;Ce<=Te.heap_len&&(Ce<Te.heap_len&&pe(Re,Te.heap[Ce+1],Te.heap[Ce],Te.depth)&&Ce++,!pe(Re,ke,Te.heap[Ce],Te.depth));)Te.heap[Ee]=Te.heap[Ce],Ee=Ce,Ce<<=1;Te.heap[Ee]=ke}function Me(Te,Re,Ee){var ke,Ce,Le,Ye,tt=0;if(Te.last_lit!==0)for(;ke=Te.pending_buf[Te.d_buf+2*tt]<<8|Te.pending_buf[Te.d_buf+2*tt+1],Ce=Te.pending_buf[Te.l_buf+tt],tt++,ke===0?le(Te,Ce,Re):(le(Te,(Le=F[Ce])+g+1,Re),(Ye=B[Le])!==0&&ne(Te,Ce-=O[Le],Ye),le(Te,Le=oe(--ke),Ee),(Ye=S[Le])!==0&&ne(Te,ke-=te[Le],Ye)),tt<Te.last_lit;);le(Te,C,Re)}function ve(Te,Re){var Ee,ke,Ce,Le=Re.dyn_tree,Ye=Re.stat_desc.static_tree,tt=Re.stat_desc.has_stree,At=Re.stat_desc.elems,at=-1;for(Te.heap_len=0,Te.heap_max=m,Ee=0;Ee<At;Ee++)Le[2*Ee]!==0?(Te.heap[++Te.heap_len]=at=Ee,Te.depth[Ee]=0):Le[2*Ee+1]=0;for(;Te.heap_len<2;)Le[2*(Ce=Te.heap[++Te.heap_len]=at<2?++at:0)]=1,Te.depth[Ce]=0,Te.opt_len--,tt&&(Te.static_len-=Ye[2*Ce+1]);for(Re.max_code=at,Ee=Te.heap_len>>1;1<=Ee;Ee--)ye(Te,Le,Ee);for(Ce=At;Ee=Te.heap[1],Te.heap[1]=Te.heap[Te.heap_len--],ye(Te,Le,1),ke=Te.heap[1],Te.heap[--Te.heap_max]=Ee,Te.heap[--Te.heap_max]=ke,Le[2*Ce]=Le[2*Ee]+Le[2*ke],Te.depth[Ce]=(Te.depth[Ee]>=Te.depth[ke]?Te.depth[Ee]:Te.depth[ke])+1,Le[2*Ee+1]=Le[2*ke+1]=Ce,Te.heap[1]=Ce++,ye(Te,Le,1),2<=Te.heap_len;);Te.heap[--Te.heap_max]=Te.heap[1],(function(nt,gt){var bt,Ct,Dt,kt,it,Yt,pn=gt.dyn_tree,be=gt.max_code,et=gt.stat_desc.static_tree,It=gt.stat_desc.has_stree,Bt=gt.stat_desc.extra_bits,mt=gt.stat_desc.extra_base,st=gt.stat_desc.max_length,xt=0;for(kt=0;kt<=_;kt++)nt.bl_count[kt]=0;for(pn[2*nt.heap[nt.heap_max]+1]=0,bt=nt.heap_max+1;bt<m;bt++)st<(kt=pn[2*pn[2*(Ct=nt.heap[bt])+1]+1]+1)&&(kt=st,xt++),pn[2*Ct+1]=kt,be<Ct||(nt.bl_count[kt]++,it=0,mt<=Ct&&(it=Bt[Ct-mt]),Yt=pn[2*Ct],nt.opt_len+=Yt*(kt+it),It&&(nt.static_len+=Yt*(et[2*Ct+1]+it)));if(xt!==0){do{for(kt=st-1;nt.bl_count[kt]===0;)kt--;nt.bl_count[kt]--,nt.bl_count[kt+1]+=2,nt.bl_count[st]--,xt-=2}while(0<xt);for(kt=st;kt!==0;kt--)for(Ct=nt.bl_count[kt];Ct!==0;)be<(Dt=nt.heap[--bt])||(pn[2*Dt+1]!==kt&&(nt.opt_len+=(kt-pn[2*Dt+1])*pn[2*Dt],pn[2*Dt+1]=kt),Ct--)}})(Te,Re),_e(Le,at,Te.bl_count)}function he(Te,Re,Ee){var ke,Ce,Le=-1,Ye=Re[1],tt=0,At=7,at=4;for(Ye===0&&(At=138,at=3),Re[2*(Ee+1)+1]=65535,ke=0;ke<=Ee;ke++)Ce=Ye,Ye=Re[2*(ke+1)+1],++tt<At&&Ce===Ye||(tt<at?Te.bl_tree[2*Ce]+=tt:Ce!==0?(Ce!==Le&&Te.bl_tree[2*Ce]++,Te.bl_tree[2*y]++):tt<=10?Te.bl_tree[2*x]++:Te.bl_tree[2*E]++,Le=Ce,at=(tt=0)===Ye?(At=138,3):Ce===Ye?(At=6,3):(At=7,4))}function Qe(Te,Re,Ee){var ke,Ce,Le=-1,Ye=Re[1],tt=0,At=7,at=4;for(Ye===0&&(At=138,at=3),ke=0;ke<=Ee;ke++)if(Ce=Ye,Ye=Re[2*(ke+1)+1],!(++tt<At&&Ce===Ye)){if(tt<at)for(;le(Te,Ce,Te.bl_tree),--tt!=0;);else Ce!==0?(Ce!==Le&&(le(Te,Ce,Te.bl_tree),tt--),le(Te,y,Te.bl_tree),ne(Te,tt-3,2)):tt<=10?(le(Te,x,Te.bl_tree),ne(Te,tt-3,3)):(le(Te,E,Te.bl_tree),ne(Te,tt-11,7));Le=Ce,at=(tt=0)===Ye?(At=138,3):Ce===Ye?(At=6,3):(At=7,4)}}c(te);var Pe=!1;function we(Te,Re,Ee,ke){ne(Te,(l<<1)+(ke?1:0),3),(function(Ce,Le,Ye,tt){fe(Ce),ie(Ce,Ye),ie(Ce,~Ye),s.arraySet(Ce.pending_buf,Ce.window,Le,Ye,Ce.pending),Ce.pending+=Ye})(Te,Re,Ee)}r._tr_init=function(Te){Pe||((function(){var Re,Ee,ke,Ce,Le,Ye=new Array(_+1);for(Ce=ke=0;Ce<u-1;Ce++)for(O[Ce]=ke,Re=0;Re<1<<B[Ce];Re++)F[ke++]=Ce;for(F[ke-1]=Ce,Ce=Le=0;Ce<16;Ce++)for(te[Ce]=Le,Re=0;Re<1<<S[Ce];Re++)R[Le++]=Ce;for(Le>>=7;Ce<d;Ce++)for(te[Ce]=Le<<7,Re=0;Re<1<<S[Ce]-7;Re++)R[256+Le++]=Ce;for(Ee=0;Ee<=_;Ee++)Ye[Ee]=0;for(Re=0;Re<=143;)M[2*Re+1]=8,Re++,Ye[8]++;for(;Re<=255;)M[2*Re+1]=9,Re++,Ye[9]++;for(;Re<=279;)M[2*Re+1]=7,Re++,Ye[7]++;for(;Re<=287;)M[2*Re+1]=8,Re++,Ye[8]++;for(_e(M,h+1,Ye),Re=0;Re<d;Re++)k[2*Re+1]=5,k[2*Re]=ge(Re,5);U=new j(M,B,g+1,h,_),Y=new j(k,S,0,d,_),W=new j(new Array(0),Q,0,p,I)})(),Pe=!0),Te.l_desc=new J(Te.dyn_ltree,U),Te.d_desc=new J(Te.dyn_dtree,Y),Te.bl_desc=new J(Te.bl_tree,W),Te.bi_buf=0,Te.bi_valid=0,ue(Te)},r._tr_stored_block=we,r._tr_flush_block=function(Te,Re,Ee,ke){var Ce,Le,Ye=0;0<Te.level?(Te.strm.data_type===2&&(Te.strm.data_type=(function(tt){var At,at=4093624447;for(At=0;At<=31;At++,at>>>=1)if(1&at&&tt.dyn_ltree[2*At]!==0)return a;if(tt.dyn_ltree[18]!==0||tt.dyn_ltree[20]!==0||tt.dyn_ltree[26]!==0)return A;for(At=32;At<g;At++)if(tt.dyn_ltree[2*At]!==0)return A;return a})(Te)),ve(Te,Te.l_desc),ve(Te,Te.d_desc),Ye=(function(tt){var At;for(he(tt,tt.dyn_ltree,tt.l_desc.max_code),he(tt,tt.dyn_dtree,tt.d_desc.max_code),ve(tt,tt.bl_desc),At=p-1;3<=At&&tt.bl_tree[2*w[At]+1]===0;At--);return tt.opt_len+=3*(At+1)+5+5+4,At})(Te),Ce=Te.opt_len+3+7>>>3,(Le=Te.static_len+3+7>>>3)<=Ce&&(Ce=Le)):Ce=Le=Ee+5,Ee+4<=Ce&&Re!==-1?we(Te,Re,Ee,ke):Te.strategy===4||Le===Ce?(ne(Te,2+(ke?1:0),3),Me(Te,M,k)):(ne(Te,4+(ke?1:0),3),(function(tt,At,at,nt){var gt;for(ne(tt,At-257,5),ne(tt,at-1,5),ne(tt,nt-4,4),gt=0;gt<nt;gt++)ne(tt,tt.bl_tree[2*w[gt]+1],3);Qe(tt,tt.dyn_ltree,At-1),Qe(tt,tt.dyn_dtree,at-1)})(Te,Te.l_desc.max_code+1,Te.d_desc.max_code+1,Ye+1),Me(Te,Te.dyn_ltree,Te.dyn_dtree)),ue(Te),ke&&fe(Te)},r._tr_tally=function(Te,Re,Ee){return Te.pending_buf[Te.d_buf+2*Te.last_lit]=Re>>>8&255,Te.pending_buf[Te.d_buf+2*Te.last_lit+1]=255&Re,Te.pending_buf[Te.l_buf+Te.last_lit]=255&Ee,Te.last_lit++,Re===0?Te.dyn_ltree[2*Ee]++:(Te.matches++,Re--,Te.dyn_ltree[2*(F[Ee]+g+1)]++,Te.dyn_dtree[2*oe(Re)]++),Te.last_lit===Te.lit_bufsize-1},r._tr_align=function(Te){ne(Te,2,3),le(Te,C,M),(function(Re){Re.bi_valid===16?(ie(Re,Re.bi_buf),Re.bi_buf=0,Re.bi_valid=0):8<=Re.bi_valid&&(Re.pending_buf[Re.pending++]=255&Re.bi_buf,Re.bi_buf>>=8,Re.bi_valid-=8)})(Te)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,A){if(!a.setImmediate){var c,l,u,g,h=1,d={},p=!1,m=a.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(a);_=_&&_.setTimeout?_:a,c={}.toString.call(a.process)==="[object process]"?function(y){n.nextTick(function(){I(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,x=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=x,y}})()?(g="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(y){a.postMessage(g+y,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(y){I(y.data)},function(y){u.port2.postMessage(y)}):m&&"onreadystatechange"in m.createElement("script")?(l=m.documentElement,function(y){var x=m.createElement("script");x.onreadystatechange=function(){I(y),x.onreadystatechange=null,l.removeChild(x),x=null},l.appendChild(x)}):function(y){setTimeout(I,0,y)},_.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),E=0;E<x.length;E++)x[E]=arguments[E+1];var B={callback:y,args:x};return d[h]=B,c(h),h++},_.clearImmediate=f}function f(y){delete d[y]}function I(y){if(p)setTimeout(I,0,y);else{var x=d[y];if(x){p=!0;try{(function(E){var B=E.callback,S=E.args;switch(S.length){case 0:B();break;case 1:B(S[0]);break;case 2:B(S[0],S[1]);break;case 3:B(S[0],S[1],S[2]);break;default:B.apply(A,S)}})(x)}finally{f(y),p=!1}}}}function C(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(g)===0&&I(+y.data.slice(g.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof my<"u"?my:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Aqe)),Aqe.exports}var LUi=FUi();const xfe=_y(LUi),HUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=new xfe,[o,{convertCircuitJsonToBomRows:i,convertBomRowsToCsv:r},{convertCircuitJsonToPickAndPlaceCsv:s}]=await Promise.all([DE("circuit-json-to-gerber"),DE("circuit-json-to-bom-csv"),DE("circuit-json-to-pnp-csv")]),a=t.filter(h=>!("error_type"in h)&&!("warning_type"in h)),A=o.convertCircuitJsonToGerberFiles(a,{flip_y_axis:!1});for(const[h,d]of Object.entries(A))n.file(`gerber/${h}`,d);const c=await i({circuitJson:t}),l=await r(c);n.file("bom.csv",l);const u=await s(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",u);const g=await n.generateAsync({type:"blob"});kE(g,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},OUi=async t=>{const{createFdmComponentBox:e,renderFdmComponentBoxPng:n}=await DE("circuit-json-to-fdm-component-box"),[o,i]=await Promise.all([e(t),n(t,{},{width:960,height:640})]);return{...o,previewPng:i}},GUi=async t=>{const{createFdmComponentBox:e}=await DE("circuit-json-to-fdm-component-box");return e(t)},$pn=({generatedBox:t,projectName:e})=>{const n=Uint8Array.from(t.threeMf);kE(new Blob([n.buffer],{type:"model/3mf"}),{fileName:`${N$e(e)}-component-box.3mf`})},YUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const n=await GUi(t);$pn({generatedBox:n,projectName:e})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:n=>`Failed to generate component box: ${n instanceof Error?n.message:String(n)}`})},UUi=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await DE("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}kE(n,{fileName:`${e}.glb`})},KUi=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await DE("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new xfe;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
`)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const A=a.split("/").pop()||a,c=await fetch(a);if(c.ok){const l=await c.arrayBuffer();s.file(A,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},VUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await KUi({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});kE(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},zUi=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await DE("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),A=new n(t,{includeBuiltin3dModels:!0,projectName:e});A.runUntilFinished();const c=A.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),g=new xfe;return g.file(`${e}.kicad_sch`,a),g.file(`${e}.kicad_pcb`,c),g.file(`${e}.kicad_pro`,u),await r({projectName:e,model3dSourcePaths:A.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{g.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),g},JUi=async({circuitJson:t,projectName:e})=>{await ua.promise((async()=>{const o=await(await zUi({circuitJson:t,projectName:e})).generateAsync({type:"blob"});kE(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},qpn=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await DE("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});kE(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";ua.error(`Failed to export to LBRN format: ${i}`)}},WUi=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await DE("circuit-to-svg"),o=n(t);kE(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},jUi=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await DE("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){ua.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to convert circuit to STEP format: ${l}`);return}const A=new Blob([a],{type:"application/step"});try{kE(A,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";ua.error(`Failed to download STEP file: ${l}`)}},$Ui=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"Altium Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],qUi=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=N$e(o);if(t==="Fabrication Files"){await HUi({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await JUi({circuitJson:e,projectName:i});return}if(t==="Altium Project"){await kUi({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await VUi({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){kE(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");kE(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await UUi({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){WUi({circuitJson:e,projectName:i});return}if(t==="STEP"){await jUi({circuitJson:e,projectName:i});return}if(t==="Component Box (3MF)"){await YUi({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await qpn({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},XUi=({packageName:t,onSelectReview:e})=>{const n=md(u=>u.fsMap),o=md(u=>u.circuitJson),[i,r]=ee.useState([]),[s,a]=ee.useState(!1),[A,c]=ee.useState(!1);ee.useEffect(()=>{!t||!zge()||(a(!0),gq.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(u=>r(u.ai_reviews)).catch(u=>{console.error("Failed to load AI reviews",u),ua.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const l=async()=>{if(!o){ua.error("Need Circuit JSON to Request AI Review");return}if(!zge()){ua.error("Missing registry token");return}c(!0);try{const{ai_review:u}=await gq.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(g=>[u,...g]),e(u),ua.success("AI review requested")}catch(u){console.error("Failed to create AI review",u),ua.error("Failed to request AI review")}finally{c(!1)}};return K.jsxs(K.Fragment,{children:[K.jsxs(zP,{children:[K.jsx(JP,{children:"AI Review"}),K.jsx(VT,{children:"Select an AI review or request a new one."})]}),K.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:K.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?K.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(u=>K.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(u),children:new Date(u.created_at||"").toLocaleString()},u.ai_review_id)):K.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),K.jsx(jU,{className:"rf-mt-4",children:K.jsx(fA,{onClick:l,disabled:A,children:A?"Requesting...":"Review my Board"})})]})};function cqe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var zT=cqe();function Xpn(t){zT=t}var xee={exec:()=>null};function L0(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(g2.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var g2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[	 ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},ZUi=/^(?:[ \t]*(?:\n|$))+/,eKi=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tKi=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Eee=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nKi=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,lqe=/(?:[*+-]|\d{1,9}[.)])/,Zpn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,emn=L0(Zpn).replace(/bull/g,lqe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),oKi=L0(Zpn).replace(/bull/g,lqe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),uqe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,iKi=/^[^\n]+/,gqe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,rKi=L0(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gqe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),sKi=L0(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lqe).getRegex(),Efe="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",dqe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,aKi=L0("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ 	]*)+\\n|$))","i").replace("comment",dqe).replace("tag",Efe).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),tmn=L0(uqe).replace("hr",Eee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Efe).getRegex(),AKi=L0(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tmn).getRegex(),hqe={blockquote:AKi,code:eKi,def:rKi,fences:tKi,heading:nKi,hr:Eee,html:aKi,lheading:emn,list:sKi,newline:ZUi,paragraph:tmn,table:xee,text:iKi},nmn=L0("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Eee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}	)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Efe).getRegex(),cKi={...hqe,lheading:oKi,table:nmn,paragraph:L0(uqe).replace("hr",Eee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",nmn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Efe).getRegex()},lKi={...hqe,html:L0(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",dqe).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xee,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:L0(uqe).replace("hr",Eee).replace("heading",` *#{1,6} *[^
]`).replace("lheading",emn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},uKi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,gKi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,omn=/^( {2,}|\\)\n(?!\s*$)/,dKi=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Bfe=/[\p{P}\p{S}]/u,pqe=/[\s\p{P}\p{S}]/u,imn=/[^\s\p{P}\p{S}]/u,hKi=L0(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,pqe).getRegex(),rmn=/(?!~)[\p{P}\p{S}]/u,pKi=/(?!~)[\s\p{P}\p{S}]/u,mKi=/(?:[^\s\p{P}\p{S}]|~)/u,_Ki=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,smn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fKi=L0(smn,"u").replace(/punct/g,Bfe).getRegex(),IKi=L0(smn,"u").replace(/punct/g,rmn).getRegex(),amn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",CKi=L0(amn,"gu").replace(/notPunctSpace/g,imn).replace(/punctSpace/g,pqe).replace(/punct/g,Bfe).getRegex(),yKi=L0(amn,"gu").replace(/notPunctSpace/g,mKi).replace(/punctSpace/g,pKi).replace(/punct/g,rmn).getRegex(),xKi=L0("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,imn).replace(/punctSpace/g,pqe).replace(/punct/g,Bfe).getRegex(),EKi=L0(/\\(punct)/,"gu").replace(/punct/g,Bfe).getRegex(),BKi=L0(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),bKi=L0(dqe).replace("(?:-->|$)","-->").getRegex(),SKi=L0("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",bKi).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bfe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,QKi=L0(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",bfe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Amn=L0(/^!?\[(label)\]\[(ref)\]/).replace("label",bfe).replace("ref",gqe).getRegex(),cmn=L0(/^!?\[(ref)\](?:\[\])?/).replace("ref",gqe).getRegex(),vKi=L0("reflink|nolink(?!\\()","g").replace("reflink",Amn).replace("nolink",cmn).getRegex(),mqe={_backpedal:xee,anyPunctuation:EKi,autolink:BKi,blockSkip:_Ki,br:omn,code:gKi,del:xee,emStrongLDelim:fKi,emStrongRDelimAst:CKi,emStrongRDelimUnd:xKi,escape:uKi,link:QKi,nolink:cmn,punctuation:hKi,reflink:Amn,reflinkSearch:vKi,tag:SKi,text:dKi,url:xee},wKi={...mqe,link:L0(/^!?\[(label)\]\((.*?)\)/).replace("label",bfe).getRegex(),reflink:L0(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bfe).getRegex()},_qe={...mqe,emStrongRDelimAst:yKi,emStrongLDelim:IKi,url:L0(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},PKi={..._qe,br:L0(omn).replace("{2,}","*").getRegex(),text:L0(_qe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Sfe={normal:hqe,gfm:cKi,pedantic:lKi},Bee={normal:mqe,gfm:_qe,breaks:PKi,pedantic:wKi},MKi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},lmn=t=>MKi[t];function n8(t,e){if(e){if(g2.escapeTest.test(t))return t.replace(g2.escapeReplace,lmn)}else if(g2.escapeTestNoEncode.test(t))return t.replace(g2.escapeReplaceNoEncode,lmn);return t}function umn(t){try{t=encodeURI(t).replace(g2.percentDecode,"%")}catch{return null}return t}function gmn(t,e){const n=t.replace(g2.findPipe,(r,s,a)=>{let A=!1,c=s;for(;--c>=0&&a[c]==="\\";)A=!A;return A?"|":" |"}),o=n.split(g2.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(g2.slashPipe,"|");return o}function bee(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function DKi(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function dmn(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const A={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,A}function NKi(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
`).map(r=>{const s=r.match(n.other.beginningSpace);if(s===null)return r;const[a]=s;return a.length>=i.length?r.slice(i.length):r}).join(`
`)}var Qfe=class{options;rules;lexer;constructor(t){this.options=t||zT}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:bee(n,`
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],o=NKi(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){const o=bee(n,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(n=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:bee(e[0],`
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=bee(e[0],`
`).split(`
`),o="",i="";const r=[];for(;n.length>0;){let s=!1;const a=[];let A;for(A=0;A<n.length;A++)if(this.rules.other.blockquoteStart.test(n[A]))a.push(n[A]),s=!0;else if(!s)a.push(n[A]);else break;n=n.slice(A);const c=a.join(`
`),l=c.replace(this.rules.other.blockquoteSetextReplace,`
    $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
${c}`:c,i=i?`${i}
${l}`:l;const u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,r,!0),this.lexer.state.top=u,n.length===0)break;const g=r.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){const h=g,d=h.raw+`
`+n.join(`
`),p=this.blockquote(d);r[r.length-1]=p,o=o.substring(0,o.length-h.raw.length)+p.raw,i=i.substring(0,i.length-h.text.length)+p.text;break}else if(g?.type==="list"){const h=g,d=h.raw+`
`+n.join(`
`),p=this.list(d);r[r.length-1]=p,o=o.substring(0,o.length-g.raw.length)+p.raw,i=i.substring(0,i.length-h.raw.length)+p.raw,n=d.substring(r.at(-1).raw.length).split(`
`);continue}}return{type:"blockquote",raw:o,tokens:r,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim();const o=n.length>1,i={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");const r=this.rules.other.listItemRegex(n);let s=!1;for(;t;){let A=!1,c="",l="";if(!(e=r.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let u=e[2].split(`
`,1)[0].replace(this.rules.other.listReplaceTabs,_=>" ".repeat(3*_.length)),g=t.split(`
`,1)[0],h=!u.trim(),d=0;if(this.options.pedantic?(d=2,l=u.trimStart()):h?d=e[1].length+1:(d=e[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,l=u.slice(d),d+=e[1].length),h&&this.rules.other.blankLine.test(g)&&(c+=g+`
`,t=t.substring(g.length+1),A=!0),!A){const _=this.rules.other.nextBulletRegex(d),f=this.rules.other.hrRegex(d),I=this.rules.other.fencesBeginRegex(d),C=this.rules.other.headingBeginRegex(d),y=this.rules.other.htmlBeginRegex(d);for(;t;){const x=t.split(`
`,1)[0];let E;if(g=x,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting,"  "),E=g):E=g.replace(this.rules.other.tabCharGlobal,"    "),I.test(g)||C.test(g)||y.test(g)||_.test(g)||f.test(g))break;if(E.search(this.rules.other.nonSpaceChar)>=d||!g.trim())l+=`
`+E.slice(d);else{if(h||u.replace(this.rules.other.tabCharGlobal,"    ").search(this.rules.other.nonSpaceChar)>=4||I.test(u)||C.test(u)||f.test(u))break;l+=`
`+g}!h&&!g.trim()&&(h=!0),c+=x+`
`,t=t.substring(x.length+1),u=E.slice(d)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0));let p=null,m;this.options.gfm&&(p=this.rules.other.listIsTask.exec(l),p&&(m=p[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!p,checked:m,loose:!1,text:l,tokens:[]}),i.raw+=c}const a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let A=0;A<i.items.length;A++)if(this.lexer.state.top=!1,i.items[A].tokens=this.lexer.blockTokens(i.items[A].text,[]),!i.loose){const c=i.items[A].tokens.filter(u=>u.type==="space"),l=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw));i.loose=l}if(i.loose)for(let A=0;A<i.items.length;A++)i.items[A].loose=!0;return i}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:o,title:i}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const n=gmn(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
`):[],r={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===o.length){for(const s of o)this.rules.other.tableAlignRight.test(s)?r.align.push("right"):this.rules.other.tableAlignCenter.test(s)?r.align.push("center"):this.rules.other.tableAlignLeft.test(s)?r.align.push("left"):r.align.push(null);for(let s=0;s<n.length;s++)r.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:r.align[s]});for(const s of i)r.rows.push(gmn(s,r.header.length).map((a,A)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[A]})));return r}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const r=bee(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{const r=DKi(e[2],"()");if(r===-2)return;if(r>-1){const a=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],i="";if(this.options.pedantic){const r=this.rules.other.pedanticHrefTitle.exec(o);r&&(o=r[1],i=r[3])}else i=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?o=o.slice(1):o=o.slice(1,-1)),dmn(e,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const o=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[o.toLowerCase()];if(!i){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return dmn(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||o[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const r=[...o[0]].length-1;let s,a,A=r,c=0;const l=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,e=e.slice(-1*t.length+r);(o=l.exec(e))!=null;){if(s=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!s)continue;if(a=[...s].length,o[3]||o[4]){A+=a;continue}else if((o[5]||o[6])&&r%3&&!((r+a)%3)){c+=a;continue}if(A-=a,A>0)continue;a=Math.min(a,a+A+c);const u=[...o[0]][0].length,g=t.slice(0,r+o.index+u+a);if(Math.min(r,a)%2){const d=g.slice(1,-1);return{type:"em",raw:g,text:d,tokens:this.lexer.inlineTokens(d)}}const h=g.slice(2,-2);return{type:"strong",raw:g,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," ");const o=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return o&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,o;return e[2]==="@"?(n=e[1],o="mailto:"+n):(n=e[1],o=n),{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,o;if(e[2]==="@")n=e[0],o="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){const n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},TS=class Qit{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zT,this.options.tokenizer=this.options.tokenizer||new Qfe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:g2,block:Sfe.normal,inline:Bee.normal};this.options.pedantic?(n.block=Sfe.pedantic,n.inline=Bee.pedantic):this.options.gfm&&(n.block=Sfe.gfm,this.options.breaks?n.inline=Bee.breaks:n.inline=Bee.gfm),this.tokenizer.rules=n}static get rules(){return{block:Sfe,inline:Bee}}static lex(e,n){return new Qit(n).lex(e)}static lexInline(e,n){return new Qit(n).inlineTokens(e)}lex(e){e=e.replace(g2.carriageReturn,`
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],o=!1){for(this.options.pedantic&&(e=e.replace(g2.tabCharGlobal,"    ").replace(g2.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(s=>(i=s.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);const s=n.at(-1);i.raw.length===1&&s!==void 0?s.raw+=`
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);const s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=`
`+i.raw,s.text+=`
`+i.text,this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);const s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=`
`+i.raw,s.text+=`
`+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let r=e;if(this.options.extensions?.startBlock){let s=1/0;const a=e.slice(1);let A;this.options.extensions.startBlock.forEach(c=>{A=c.call({lexer:this},a),typeof A=="number"&&A>=0&&(s=Math.min(s,A))}),s<1/0&&s>=0&&(r=e.substring(0,s+1))}if(this.state.top&&(i=this.tokenizer.paragraph(r))){const s=n.at(-1);o&&s?.type==="paragraph"?(s.raw+=`
`+i.raw,s.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i),o=r.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);const s=n.at(-1);s?.type==="text"?(s.raw+=`
`+i.raw,s.text+=`
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(e){const s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let o=e,i=null;if(this.tokens.links){const a=Object.keys(this.tokens.links);if(a.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)a.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,i.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(i=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let r=!1,s="";for(;e;){r||(s=""),r=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);const c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,o,s)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let A=e;if(this.options.extensions?.startInline){let c=1/0;const l=e.slice(1);let u;this.options.extensions.startInline.forEach(g=>{u=g.call({lexer:this},l),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(A=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(A)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(s=a.raw.slice(-1)),r=!0;const c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}},vfe=class{options;parser;constructor(t){this.options=t||zT}space(t){return""}code({text:t,lang:e,escaped:n}){const o=(e||"").match(g2.notSpaceStart)?.[0],i=t.replace(g2.endingNewline,"")+`
`;return o?'<pre><code class="language-'+n8(o)+'">'+(n?i:n8(i,!0))+`</code></pre>
`:"<pre><code>"+(n?i:n8(i,!0))+`</code></pre>
`}blockquote({tokens:t}){return`<blockquote>
${this.parser.parse(t)}</blockquote>
`}html({text:t}){return t}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
`}hr(t){return`<hr>
`}list(t){const e=t.ordered,n=t.start;let o="";for(let s=0;s<t.items.length;s++){const a=t.items[s];o+=this.listitem(a)}const i=e?"ol":"ul",r=e&&n!==1?' start="'+n+'"':"";return"<"+i+r+`>
`+o+"</"+i+`>
`}listitem(t){let e="";if(t.task){const n=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+n8(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):e+=n+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let o="";for(let i=0;i<t.rows.length;i++){const r=t.rows[i];n="";for(let s=0;s<r.length;s++)n+=this.tablecell(r[s]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
<thead>
`+e+`</thead>
`+o+`</table>
`}tablerow({text:t}){return`<tr>
${t}</tr>
`}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${n8(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const o=this.parser.parseInline(n),i=umn(t);if(i===null)return o;t=i;let r='<a href="'+t+'"';return e&&(r+=' title="'+n8(e)+'"'),r+=">"+o+"</a>",r}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const i=umn(t);if(i===null)return n8(n);t=i;let r=`<img src="${t}" alt="${n}"`;return e&&(r+=` title="${n8(e)}"`),r+=">",r}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:n8(t.text)}},fqe=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},kS=class vit{options;renderer;textRenderer;constructor(e){this.options=e||zT,this.options.renderer=this.options.renderer||new vfe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fqe}static parse(e,n){return new vit(n).parse(e)}static parseInline(e,n){return new vit(n).parseInline(e)}parse(e,n=!0){let o="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions?.renderers?.[r.type]){const a=r,A=this.options.extensions.renderers[a.type].call({parser:this},a);if(A!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(a.type)){o+=A||"";continue}}const s=r;switch(s.type){case"space":{o+=this.renderer.space(s);continue}case"hr":{o+=this.renderer.hr(s);continue}case"heading":{o+=this.renderer.heading(s);continue}case"code":{o+=this.renderer.code(s);continue}case"table":{o+=this.renderer.table(s);continue}case"blockquote":{o+=this.renderer.blockquote(s);continue}case"list":{o+=this.renderer.list(s);continue}case"html":{o+=this.renderer.html(s);continue}case"paragraph":{o+=this.renderer.paragraph(s);continue}case"text":{let a=s,A=this.renderer.text(a);for(;i+1<e.length&&e[i+1].type==="text";)a=e[++i],A+=`
`+this.renderer.text(a);n?o+=this.renderer.paragraph({type:"paragraph",raw:A,text:A,tokens:[{type:"text",raw:A,text:A,escaped:!0}]}):o+=A;continue}default:{const a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return o}parseInline(e,n=this.renderer){let o="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions?.renderers?.[r.type]){const a=this.options.extensions.renderers[r.type].call({parser:this},r);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){o+=a||"";continue}}const s=r;switch(s.type){case"escape":{o+=n.text(s);break}case"html":{o+=n.html(s);break}case"link":{o+=n.link(s);break}case"image":{o+=n.image(s);break}case"strong":{o+=n.strong(s);break}case"em":{o+=n.em(s);break}case"codespan":{o+=n.codespan(s);break}case"br":{o+=n.br(s);break}case"del":{o+=n.del(s);break}case"text":{o+=n.text(s);break}default:{const a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return o}},wfe=class{options;block;constructor(t){this.options=t||zT}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?TS.lex:TS.lexInline}provideParser(){return this.block?kS.parse:kS.parseInline}},RKi=class{defaults=cqe();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=kS;Renderer=vfe;TextRenderer=fqe;Lexer=TS;Tokenizer=Qfe;Hooks=wfe;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(const o of t)switch(n=n.concat(e.call(this,o)),o.type){case"table":{const i=o;for(const r of i.header)n=n.concat(this.walkTokens(r.tokens,e));for(const r of i.rows)for(const s of r)n=n.concat(this.walkTokens(s.tokens,e));break}case"list":{const i=o;n=n.concat(this.walkTokens(i.items,e));break}default:{const i=o;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(r=>{const s=i[r].flat(1/0);n=n.concat(this.walkTokens(s,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const r=e.renderers[i.name];r?e.renderers[i.name]=function(...s){let a=i.renderer.apply(this,s);return a===!1&&(a=r.apply(this,s)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const r=e[i.level];r?r.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),o.extensions=e),n.renderer){const i=this.defaults.renderer||new vfe(this.defaults);for(const r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const s=r,a=n.renderer[s],A=i[s];i[s]=(...c)=>{let l=a.apply(i,c);return l===!1&&(l=A.apply(i,c)),l||""}}o.renderer=i}if(n.tokenizer){const i=this.defaults.tokenizer||new Qfe(this.defaults);for(const r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const s=r,a=n.tokenizer[s],A=i[s];i[s]=(...c)=>{let l=a.apply(i,c);return l===!1&&(l=A.apply(i,c)),l}}o.tokenizer=i}if(n.hooks){const i=this.defaults.hooks||new wfe;for(const r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const s=r,a=n.hooks[s],A=i[s];wfe.passThroughHooks.has(r)?i[s]=c=>{if(this.defaults.async)return Promise.resolve(a.call(i,c)).then(u=>A.call(i,u));const l=a.call(i,c);return A.call(i,l)}:i[s]=(...c)=>{let l=a.apply(i,c);return l===!1&&(l=A.apply(i,c)),l}}o.hooks=i}if(n.walkTokens){const i=this.defaults.walkTokens,r=n.walkTokens;o.walkTokens=function(s){let a=[];return a.push(r.call(this,s)),i&&(a=a.concat(i.call(this,s))),a}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return TS.lex(t,e??this.defaults)}parser(t,e){return kS.parse(t,e??this.defaults)}parseMarkdown(t){return(n,o)=>{const i={...o},r={...this.defaults,...i},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=t);const a=r.hooks?r.hooks.provideLexer():t?TS.lex:TS.lexInline,A=r.hooks?r.hooks.provideParser():t?kS.parse:kS.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(c=>a(c,r)).then(c=>r.hooks?r.hooks.processAllTokens(c):c).then(c=>r.walkTokens?Promise.all(this.walkTokens(c,r.walkTokens)).then(()=>c):c).then(c=>A(c,r)).then(c=>r.hooks?r.hooks.postprocess(c):c).catch(s);try{r.hooks&&(n=r.hooks.preprocess(n));let c=a(n,r);r.hooks&&(c=r.hooks.processAllTokens(c)),r.walkTokens&&this.walkTokens(c,r.walkTokens);let l=A(c,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(c){return s(c)}}}onError(t,e){return n=>{if(n.message+=`
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+n8(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},JT=new RKi;function lu(t,e){return JT.parse(t,e)}lu.options=lu.setOptions=function(t){return JT.setOptions(t),lu.defaults=JT.defaults,Xpn(lu.defaults),lu},lu.getDefaults=cqe,lu.defaults=zT,lu.use=function(...t){return JT.use(...t),lu.defaults=JT.defaults,Xpn(lu.defaults),lu},lu.walkTokens=function(t,e){return JT.walkTokens(t,e)},lu.parseInline=JT.parseInline,lu.Parser=kS,lu.parser=kS.parse,lu.Renderer=vfe,lu.TextRenderer=fqe,lu.Lexer=TS,lu.lexer=TS.lex,lu.Tokenizer=Qfe,lu.Hooks=wfe,lu.parse=lu,lu.options,lu.setOptions,lu.use,lu.walkTokens,lu.parseInline,kS.parse,TS.lex;const TKi=({review:t,onBack:e})=>{const[n,o]=ee.useState(t.ai_review_text??null),i=Hw(),r=t.ai_review_id;ee.useEffect(()=>{if(!r)return;let a;async function A(){try{const c=await i.get("ai_reviews/get",{searchParams:{ai_review_id:r}}),{ai_review:l}=await c.json();if(l.ai_review_text){o(l.ai_review_text);return}}catch(c){console.error("Failed to load AI review text",c)}a=setTimeout(A,1e3)}return a=setTimeout(A,1e3),()=>clearTimeout(a)},[r]);const s=ee.useMemo(()=>lu.parse(t.ai_review_text||""),[t.ai_review_text]);return K.jsxs(K.Fragment,{children:[K.jsxs(zP,{className:"rf-flex rf-flex-row rf-items-center rf-justify-between",children:[K.jsx(fA,{variant:"ghost",size:"sm",onClick:e,children:"Back"}),K.jsx(JP,{children:"AI Review"})]}),n?K.jsx("div",{className:"rf-h-64 rf-overflow-y-auto rf-prose rf-max-w-none rf-mt-2",dangerouslySetInnerHTML:{__html:s}}):K.jsx("div",{className:"rf-h-64 rf-overflow-y-auto rf-prose rf-max-w-none rf-mt-2",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:[K.jsxs("svg",{className:"rf-animate-spin rf-h-6 rf-w-6 rf-text-zinc-400 rf-mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[K.jsx("circle",{className:"rf-opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),K.jsx("path",{className:"rf-opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),K.jsx("span",{children:"Loading..."})]})})]})},kKi=({isOpen:t,onClose:e,packageName:n})=>{const[o,i]=ee.useState("list_reviews"),[r,s]=ee.useState(null),a=A=>{s(A),i("view_review")};return K.jsx(KT,{open:t,onOpenChange:A=>{A||(i("list_reviews"),s(null),e())},children:K.jsxs(VP,{className:"rf-max-w-2xl",children:[o==="list_reviews"&&K.jsx(XUi,{packageName:n,onSelectReview:a}),o==="view_review"&&r&&K.jsx(TKi,{review:r,onBack:()=>i("list_reviews")})]})})};var $U=(function(){function t(){this.listeners=[]}var e=t.prototype;return e.subscribe=function(o){var i=this,r=o||function(){};return this.listeners.push(r),this.onSubscribe(),function(){i.listeners=i.listeners.filter(function(s){return s!==r}),i.onUnsubscribe()}},e.hasListeners=function(){return this.listeners.length>0},e.onSubscribe=function(){},e.onUnsubscribe=function(){},t})(),Pfe=typeof window>"u";function II(){}function FKi(t,e){return typeof t=="function"?t(e):t}function Iqe(t){return typeof t=="number"&&t>=0&&t!==1/0}function Mfe(t){return Array.isArray(t)?t:[t]}function hmn(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Dfe(t,e,n){return See(t)?typeof e=="function"?ca({},n,{queryKey:t,queryFn:e}):ca({},e,{queryKey:t}):t}function LKi(t,e,n){return See(t)?ca({},e,{mutationKey:t}):typeof t=="function"?ca({},e,{mutationFn:t}):ca({},t)}function $P(t,e,n){return See(t)?[ca({},e,{queryKey:t}),n]:[t||{},e]}function HKi(t,e){if(t===!0&&e===!0||t==null&&e==null)return"all";if(t===!1&&e===!1)return"none";var n=t??!e;return n?"active":"inactive"}function pmn(t,e){var n=t.active,o=t.exact,i=t.fetching,r=t.inactive,s=t.predicate,a=t.queryKey,A=t.stale;if(See(a)){if(o){if(e.queryHash!==Cqe(a,e.options))return!1}else if(!Nfe(e.queryKey,a))return!1}var c=HKi(n,r);if(c==="none")return!1;if(c!=="all"){var l=e.isActive();if(c==="active"&&!l||c==="inactive"&&l)return!1}return!(typeof A=="boolean"&&e.isStale()!==A||typeof i=="boolean"&&e.isFetching()!==i||s&&!s(e))}function mmn(t,e){var n=t.exact,o=t.fetching,i=t.predicate,r=t.mutationKey;if(See(r)){if(!e.options.mutationKey)return!1;if(n){if(WT(e.options.mutationKey)!==WT(r))return!1}else if(!Nfe(e.options.mutationKey,r))return!1}return!(typeof o=="boolean"&&e.state.status==="loading"!==o||i&&!i(e))}function Cqe(t,e){var n=e?.queryKeyHashFn||WT;return n(t)}function WT(t){var e=Mfe(t);return OKi(e)}function OKi(t){return JSON.stringify(t,function(e,n){return yqe(n)?Object.keys(n).sort().reduce(function(o,i){return o[i]=n[i],o},{}):n})}function Nfe(t,e){return _mn(Mfe(t),Mfe(e))}function _mn(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(function(n){return!_mn(t[n],e[n])}):!1}function Rfe(t,e){if(t===e)return t;var n=Array.isArray(t)&&Array.isArray(e);if(n||yqe(t)&&yqe(e)){for(var o=n?t.length:Object.keys(t).length,i=n?e:Object.keys(e),r=i.length,s=n?[]:{},a=0,A=0;A<r;A++){var c=n?A:i[A];s[c]=Rfe(t[c],e[c]),s[c]===t[c]&&a++}return o===r&&a===o?t:s}return e}function GKi(t,e){if(t&&!e||e&&!t)return!1;for(var n in t)if(t[n]!==e[n])return!1;return!0}function yqe(t){if(!fmn(t))return!1;var e=t.constructor;if(typeof e>"u")return!0;var n=e.prototype;return!(!fmn(n)||!n.hasOwnProperty("isPrototypeOf"))}function fmn(t){return Object.prototype.toString.call(t)==="[object Object]"}function See(t){return typeof t=="string"||Array.isArray(t)}function YKi(t){return new Promise(function(e){setTimeout(e,t)})}function Imn(t){Promise.resolve().then(t).catch(function(e){return setTimeout(function(){throw e})})}function Cmn(){if(typeof AbortController=="function")return new AbortController}var UKi=(function(t){NN(e,t);function e(){var o;return o=t.call(this)||this,o.setup=function(i){var r;if(!Pfe&&((r=window)!=null&&r.addEventListener)){var s=function(){return i()};return window.addEventListener("visibilitychange",s,!1),window.addEventListener("focus",s,!1),function(){window.removeEventListener("visibilitychange",s),window.removeEventListener("focus",s)}}},o}var n=e.prototype;return n.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},n.onUnsubscribe=function(){if(!this.hasListeners()){var i;(i=this.cleanup)==null||i.call(this),this.cleanup=void 0}},n.setEventListener=function(i){var r,s=this;this.setup=i,(r=this.cleanup)==null||r.call(this),this.cleanup=i(function(a){typeof a=="boolean"?s.setFocused(a):s.onFocus()})},n.setFocused=function(i){this.focused=i,i&&this.onFocus()},n.onFocus=function(){this.listeners.forEach(function(i){i()})},n.isFocused=function(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)},e})($U),Qee=new UKi,KKi=(function(t){NN(e,t);function e(){var o;return o=t.call(this)||this,o.setup=function(i){var r;if(!Pfe&&((r=window)!=null&&r.addEventListener)){var s=function(){return i()};return window.addEventListener("online",s,!1),window.addEventListener("offline",s,!1),function(){window.removeEventListener("online",s),window.removeEventListener("offline",s)}}},o}var n=e.prototype;return n.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},n.onUnsubscribe=function(){if(!this.hasListeners()){var i;(i=this.cleanup)==null||i.call(this),this.cleanup=void 0}},n.setEventListener=function(i){var r,s=this;this.setup=i,(r=this.cleanup)==null||r.call(this),this.cleanup=i(function(a){typeof a=="boolean"?s.setOnline(a):s.onOnline()})},n.setOnline=function(i){this.online=i,i&&this.onOnline()},n.onOnline=function(){this.listeners.forEach(function(i){i()})},n.isOnline=function(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine},e})($U),Tfe=new KKi;function VKi(t){return Math.min(1e3*Math.pow(2,t),3e4)}function kfe(t){return typeof t?.cancel=="function"}var ymn=function(e){this.revert=e?.revert,this.silent=e?.silent};function Ffe(t){return t instanceof ymn}var xmn=function(e){var n=this,o=!1,i,r,s,a;this.abort=e.abort,this.cancel=function(g){return i?.(g)},this.cancelRetry=function(){o=!0},this.continueRetry=function(){o=!1},this.continue=function(){return r?.()},this.failureCount=0,this.isPaused=!1,this.isResolved=!1,this.isTransportCancelable=!1,this.promise=new Promise(function(g,h){s=g,a=h});var A=function(h){n.isResolved||(n.isResolved=!0,e.onSuccess==null||e.onSuccess(h),r?.(),s(h))},c=function(h){n.isResolved||(n.isResolved=!0,e.onError==null||e.onError(h),r?.(),a(h))},l=function(){return new Promise(function(h){r=h,n.isPaused=!0,e.onPause==null||e.onPause()}).then(function(){r=void 0,n.isPaused=!1,e.onContinue==null||e.onContinue()})},u=function g(){if(!n.isResolved){var h;try{h=e.fn()}catch(d){h=Promise.reject(d)}i=function(p){if(!n.isResolved&&(c(new ymn(p)),n.abort==null||n.abort(),kfe(h)))try{h.cancel()}catch{}},n.isTransportCancelable=kfe(h),Promise.resolve(h).then(A).catch(function(d){var p,m;if(!n.isResolved){var _=(p=e.retry)!=null?p:3,f=(m=e.retryDelay)!=null?m:VKi,I=typeof f=="function"?f(n.failureCount,d):f,C=_===!0||typeof _=="number"&&n.failureCount<_||typeof _=="function"&&_(n.failureCount,d);if(o||!C){c(d);return}n.failureCount++,e.onFail==null||e.onFail(n.failureCount,d),YKi(I).then(function(){if(!Qee.isFocused()||!Tfe.isOnline())return l()}).then(function(){o?c(d):g()})}})}};u()},zKi=(function(){function t(){this.queue=[],this.transactions=0,this.notifyFn=function(n){n()},this.batchNotifyFn=function(n){n()}}var e=t.prototype;return e.batch=function(o){var i;this.transactions++;try{i=o()}finally{this.transactions--,this.transactions||this.flush()}return i},e.schedule=function(o){var i=this;this.transactions?this.queue.push(o):Imn(function(){i.notifyFn(o)})},e.batchCalls=function(o){var i=this;return function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];i.schedule(function(){o.apply(void 0,s)})}},e.flush=function(){var o=this,i=this.queue;this.queue=[],i.length&&Imn(function(){o.batchNotifyFn(function(){i.forEach(function(r){o.notifyFn(r)})})})},e.setNotifyFunction=function(o){this.notifyFn=o},e.setBatchNotifyFunction=function(o){this.batchNotifyFn=o},t})(),dh=new zKi,Emn=console;function Lfe(){return Emn}function JKi(t){Emn=t}var WKi=(function(){function t(n){this.abortSignalConsumed=!1,this.hadObservers=!1,this.defaultOptions=n.defaultOptions,this.setOptions(n.options),this.observers=[],this.cache=n.cache,this.queryKey=n.queryKey,this.queryHash=n.queryHash,this.initialState=n.state||this.getDefaultState(this.options),this.state=this.initialState,this.meta=n.meta,this.scheduleGc()}var e=t.prototype;return e.setOptions=function(o){var i;this.options=ca({},this.defaultOptions,o),this.meta=o?.meta,this.cacheTime=Math.max(this.cacheTime||0,(i=this.options.cacheTime)!=null?i:300*1e3)},e.setDefaultOptions=function(o){this.defaultOptions=o},e.scheduleGc=function(){var o=this;this.clearGcTimeout(),Iqe(this.cacheTime)&&(this.gcTimeout=setTimeout(function(){o.optionalRemove()},this.cacheTime))},e.clearGcTimeout=function(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)},e.optionalRemove=function(){this.observers.length||(this.state.isFetching?this.hadObservers&&this.scheduleGc():this.cache.remove(this))},e.setData=function(o,i){var r,s,a=this.state.data,A=FKi(o,a);return(r=(s=this.options).isDataEqual)!=null&&r.call(s,a,A)?A=a:this.options.structuralSharing!==!1&&(A=Rfe(a,A)),this.dispatch({data:A,type:"success",dataUpdatedAt:i?.updatedAt}),A},e.setState=function(o,i){this.dispatch({type:"setState",state:o,setStateOptions:i})},e.cancel=function(o){var i,r=this.promise;return(i=this.retryer)==null||i.cancel(o),r?r.then(II).catch(II):Promise.resolve()},e.destroy=function(){this.clearGcTimeout(),this.cancel({silent:!0})},e.reset=function(){this.destroy(),this.setState(this.initialState)},e.isActive=function(){return this.observers.some(function(o){return o.options.enabled!==!1})},e.isFetching=function(){return this.state.isFetching},e.isStale=function(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(function(o){return o.getCurrentResult().isStale})},e.isStaleByTime=function(o){return o===void 0&&(o=0),this.state.isInvalidated||!this.state.dataUpdatedAt||!hmn(this.state.dataUpdatedAt,o)},e.onFocus=function(){var o,i=this.observers.find(function(r){return r.shouldFetchOnWindowFocus()});i&&i.refetch(),(o=this.retryer)==null||o.continue()},e.onOnline=function(){var o,i=this.observers.find(function(r){return r.shouldFetchOnReconnect()});i&&i.refetch(),(o=this.retryer)==null||o.continue()},e.addObserver=function(o){this.observers.indexOf(o)===-1&&(this.observers.push(o),this.hadObservers=!0,this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:o}))},e.removeObserver=function(o){this.observers.indexOf(o)!==-1&&(this.observers=this.observers.filter(function(i){return i!==o}),this.observers.length||(this.retryer&&(this.retryer.isTransportCancelable||this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.cacheTime?this.scheduleGc():this.cache.remove(this)),this.cache.notify({type:"observerRemoved",query:this,observer:o}))},e.getObserversCount=function(){return this.observers.length},e.invalidate=function(){this.state.isInvalidated||this.dispatch({type:"invalidate"})},e.fetch=function(o,i){var r=this,s,a,A;if(this.state.isFetching){if(this.state.dataUpdatedAt&&i?.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var c;return(c=this.retryer)==null||c.continueRetry(),this.promise}}if(o&&this.setOptions(o),!this.options.queryFn){var l=this.observers.find(function(f){return f.options.queryFn});l&&this.setOptions(l.options)}var u=Mfe(this.queryKey),g=Cmn(),h={queryKey:u,pageParam:void 0,meta:this.meta};Object.defineProperty(h,"signal",{enumerable:!0,get:function(){if(g)return r.abortSignalConsumed=!0,g.signal}});var d=function(){return r.options.queryFn?(r.abortSignalConsumed=!1,r.options.queryFn(h)):Promise.reject("Missing queryFn")},p={fetchOptions:i,options:this.options,queryKey:u,state:this.state,fetchFn:d,meta:this.meta};if((s=this.options.behavior)!=null&&s.onFetch){var m;(m=this.options.behavior)==null||m.onFetch(p)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((a=p.fetchOptions)==null?void 0:a.meta)){var _;this.dispatch({type:"fetch",meta:(_=p.fetchOptions)==null?void 0:_.meta})}return this.retryer=new xmn({fn:p.fetchFn,abort:g==null||(A=g.abort)==null?void 0:A.bind(g),onSuccess:function(I){r.setData(I),r.cache.config.onSuccess==null||r.cache.config.onSuccess(I,r),r.cacheTime===0&&r.optionalRemove()},onError:function(I){Ffe(I)&&I.silent||r.dispatch({type:"error",error:I}),Ffe(I)||(r.cache.config.onError==null||r.cache.config.onError(I,r),Lfe().error(I)),r.cacheTime===0&&r.optionalRemove()},onFail:function(){r.dispatch({type:"failed"})},onPause:function(){r.dispatch({type:"pause"})},onContinue:function(){r.dispatch({type:"continue"})},retry:p.options.retry,retryDelay:p.options.retryDelay}),this.promise=this.retryer.promise,this.promise},e.dispatch=function(o){var i=this;this.state=this.reducer(this.state,o),dh.batch(function(){i.observers.forEach(function(r){r.onQueryUpdate(o)}),i.cache.notify({query:i,type:"queryUpdated",action:o})})},e.getDefaultState=function(o){var i=typeof o.initialData=="function"?o.initialData():o.initialData,r=typeof o.initialData<"u",s=r?typeof o.initialDataUpdatedAt=="function"?o.initialDataUpdatedAt():o.initialDataUpdatedAt:0,a=typeof i<"u";return{data:i,dataUpdateCount:0,dataUpdatedAt:a?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isFetching:!1,isInvalidated:!1,isPaused:!1,status:a?"success":"idle"}},e.reducer=function(o,i){var r,s;switch(i.type){case"failed":return ca({},o,{fetchFailureCount:o.fetchFailureCount+1});case"pause":return ca({},o,{isPaused:!0});case"continue":return ca({},o,{isPaused:!1});case"fetch":return ca({},o,{fetchFailureCount:0,fetchMeta:(r=i.meta)!=null?r:null,isFetching:!0,isPaused:!1},!o.dataUpdatedAt&&{error:null,status:"loading"});case"success":return ca({},o,{data:i.data,dataUpdateCount:o.dataUpdateCount+1,dataUpdatedAt:(s=i.dataUpdatedAt)!=null?s:Date.now(),error:null,fetchFailureCount:0,isFetching:!1,isInvalidated:!1,isPaused:!1,status:"success"});case"error":var a=i.error;return Ffe(a)&&a.revert&&this.revertState?ca({},this.revertState):ca({},o,{error:a,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return ca({},o,{isInvalidated:!0});case"setState":return ca({},o,i.state);default:return o}},t})(),jKi=(function(t){NN(e,t);function e(o){var i;return i=t.call(this)||this,i.config=o||{},i.queries=[],i.queriesMap={},i}var n=e.prototype;return n.build=function(i,r,s){var a,A=r.queryKey,c=(a=r.queryHash)!=null?a:Cqe(A,r),l=this.get(c);return l||(l=new WKi({cache:this,queryKey:A,queryHash:c,options:i.defaultQueryOptions(r),state:s,defaultOptions:i.getQueryDefaults(A),meta:r.meta}),this.add(l)),l},n.add=function(i){this.queriesMap[i.queryHash]||(this.queriesMap[i.queryHash]=i,this.queries.push(i),this.notify({type:"queryAdded",query:i}))},n.remove=function(i){var r=this.queriesMap[i.queryHash];r&&(i.destroy(),this.queries=this.queries.filter(function(s){return s!==i}),r===i&&delete this.queriesMap[i.queryHash],this.notify({type:"queryRemoved",query:i}))},n.clear=function(){var i=this;dh.batch(function(){i.queries.forEach(function(r){i.remove(r)})})},n.get=function(i){return this.queriesMap[i]},n.getAll=function(){return this.queries},n.find=function(i,r){var s=$P(i,r),a=s[0];return typeof a.exact>"u"&&(a.exact=!0),this.queries.find(function(A){return pmn(a,A)})},n.findAll=function(i,r){var s=$P(i,r),a=s[0];return Object.keys(a).length>0?this.queries.filter(function(A){return pmn(a,A)}):this.queries},n.notify=function(i){var r=this;dh.batch(function(){r.listeners.forEach(function(s){s(i)})})},n.onFocus=function(){var i=this;dh.batch(function(){i.queries.forEach(function(r){r.onFocus()})})},n.onOnline=function(){var i=this;dh.batch(function(){i.queries.forEach(function(r){r.onOnline()})})},e})($U),$Ki=(function(){function t(n){this.options=ca({},n.defaultOptions,n.options),this.mutationId=n.mutationId,this.mutationCache=n.mutationCache,this.observers=[],this.state=n.state||Bmn(),this.meta=n.meta}var e=t.prototype;return e.setState=function(o){this.dispatch({type:"setState",state:o})},e.addObserver=function(o){this.observers.indexOf(o)===-1&&this.observers.push(o)},e.removeObserver=function(o){this.observers=this.observers.filter(function(i){return i!==o})},e.cancel=function(){return this.retryer?(this.retryer.cancel(),this.retryer.promise.then(II).catch(II)):Promise.resolve()},e.continue=function(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()},e.execute=function(){var o=this,i,r=this.state.status==="loading",s=Promise.resolve();return r||(this.dispatch({type:"loading",variables:this.options.variables}),s=s.then(function(){o.mutationCache.config.onMutate==null||o.mutationCache.config.onMutate(o.state.variables,o)}).then(function(){return o.options.onMutate==null?void 0:o.options.onMutate(o.state.variables)}).then(function(a){a!==o.state.context&&o.dispatch({type:"loading",context:a,variables:o.state.variables})})),s.then(function(){return o.executeMutation()}).then(function(a){i=a,o.mutationCache.config.onSuccess==null||o.mutationCache.config.onSuccess(i,o.state.variables,o.state.context,o)}).then(function(){return o.options.onSuccess==null?void 0:o.options.onSuccess(i,o.state.variables,o.state.context)}).then(function(){return o.options.onSettled==null?void 0:o.options.onSettled(i,null,o.state.variables,o.state.context)}).then(function(){return o.dispatch({type:"success",data:i}),i}).catch(function(a){return o.mutationCache.config.onError==null||o.mutationCache.config.onError(a,o.state.variables,o.state.context,o),Lfe().error(a),Promise.resolve().then(function(){return o.options.onError==null?void 0:o.options.onError(a,o.state.variables,o.state.context)}).then(function(){return o.options.onSettled==null?void 0:o.options.onSettled(void 0,a,o.state.variables,o.state.context)}).then(function(){throw o.dispatch({type:"error",error:a}),a})})},e.executeMutation=function(){var o=this,i;return this.retryer=new xmn({fn:function(){return o.options.mutationFn?o.options.mutationFn(o.state.variables):Promise.reject("No mutationFn found")},onFail:function(){o.dispatch({type:"failed"})},onPause:function(){o.dispatch({type:"pause"})},onContinue:function(){o.dispatch({type:"continue"})},retry:(i=this.options.retry)!=null?i:0,retryDelay:this.options.retryDelay}),this.retryer.promise},e.dispatch=function(o){var i=this;this.state=qKi(this.state,o),dh.batch(function(){i.observers.forEach(function(r){r.onMutationUpdate(o)}),i.mutationCache.notify(i)})},t})();function Bmn(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function qKi(t,e){switch(e.type){case"failed":return ca({},t,{failureCount:t.failureCount+1});case"pause":return ca({},t,{isPaused:!0});case"continue":return ca({},t,{isPaused:!1});case"loading":return ca({},t,{context:e.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:e.variables});case"success":return ca({},t,{data:e.data,error:null,status:"success",isPaused:!1});case"error":return ca({},t,{data:void 0,error:e.error,failureCount:t.failureCount+1,isPaused:!1,status:"error"});case"setState":return ca({},t,e.state);default:return t}}var XKi=(function(t){NN(e,t);function e(o){var i;return i=t.call(this)||this,i.config=o||{},i.mutations=[],i.mutationId=0,i}var n=e.prototype;return n.build=function(i,r,s){var a=new $Ki({mutationCache:this,mutationId:++this.mutationId,options:i.defaultMutationOptions(r),state:s,defaultOptions:r.mutationKey?i.getMutationDefaults(r.mutationKey):void 0,meta:r.meta});return this.add(a),a},n.add=function(i){this.mutations.push(i),this.notify(i)},n.remove=function(i){this.mutations=this.mutations.filter(function(r){return r!==i}),i.cancel(),this.notify(i)},n.clear=function(){var i=this;dh.batch(function(){i.mutations.forEach(function(r){i.remove(r)})})},n.getAll=function(){return this.mutations},n.find=function(i){return typeof i.exact>"u"&&(i.exact=!0),this.mutations.find(function(r){return mmn(i,r)})},n.findAll=function(i){return this.mutations.filter(function(r){return mmn(i,r)})},n.notify=function(i){var r=this;dh.batch(function(){r.listeners.forEach(function(s){s(i)})})},n.onFocus=function(){this.resumePausedMutations()},n.onOnline=function(){this.resumePausedMutations()},n.resumePausedMutations=function(){var i=this.mutations.filter(function(r){return r.state.isPaused});return dh.batch(function(){return i.reduce(function(r,s){return r.then(function(){return s.continue().catch(II)})},Promise.resolve())})},e})($U);function ZKi(){return{onFetch:function(e){e.fetchFn=function(){var n,o,i,r,s,a,A=(n=e.fetchOptions)==null||(o=n.meta)==null?void 0:o.refetchPage,c=(i=e.fetchOptions)==null||(r=i.meta)==null?void 0:r.fetchMore,l=c?.pageParam,u=c?.direction==="forward",g=c?.direction==="backward",h=((s=e.state.data)==null?void 0:s.pages)||[],d=((a=e.state.data)==null?void 0:a.pageParams)||[],p=Cmn(),m=p?.signal,_=d,f=!1,I=e.options.queryFn||function(){return Promise.reject("Missing queryFn")},C=function(R,F,O,U){return _=U?[F].concat(_):[].concat(_,[F]),U?[O].concat(R):[].concat(R,[O])},y=function(R,F,O,U){if(f)return Promise.reject("Cancelled");if(typeof O>"u"&&!F&&R.length)return Promise.resolve(R);var Y={queryKey:e.queryKey,signal:m,pageParam:O,meta:e.meta},W=I(Y),te=Promise.resolve(W).then(function(J){return C(R,O,J,U)});if(kfe(W)){var j=te;j.cancel=W.cancel}return te},x;if(!h.length)x=y([]);else if(u){var E=typeof l<"u",B=E?l:bmn(e.options,h);x=y(h,E,B)}else if(g){var S=typeof l<"u",Q=S?l:eVi(e.options,h);x=y(h,S,Q,!0)}else(function(){_=[];var k=typeof e.options.getNextPageParam>"u",R=A&&h[0]?A(h[0],0,h):!0;x=R?y([],k,d[0]):Promise.resolve(C([],d[0],h[0]));for(var F=function(Y){x=x.then(function(W){var te=A&&h[Y]?A(h[Y],Y,h):!0;if(te){var j=k?d[Y]:bmn(e.options,W);return y(W,k,j)}return Promise.resolve(C(W,d[Y],h[Y]))})},O=1;O<h.length;O++)F(O)})();var w=x.then(function(k){return{pages:k,pageParams:_}}),M=w;return M.cancel=function(){f=!0,p?.abort(),kfe(x)&&x.cancel()},w}}}}function bmn(t,e){return t.getNextPageParam==null?void 0:t.getNextPageParam(e[e.length-1],e)}function eVi(t,e){return t.getPreviousPageParam==null?void 0:t.getPreviousPageParam(e[0],e)}var tVi=(function(){function t(n){n===void 0&&(n={}),this.queryCache=n.queryCache||new jKi,this.mutationCache=n.mutationCache||new XKi,this.defaultOptions=n.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var e=t.prototype;return e.mount=function(){var o=this;this.unsubscribeFocus=Qee.subscribe(function(){Qee.isFocused()&&Tfe.isOnline()&&(o.mutationCache.onFocus(),o.queryCache.onFocus())}),this.unsubscribeOnline=Tfe.subscribe(function(){Qee.isFocused()&&Tfe.isOnline()&&(o.mutationCache.onOnline(),o.queryCache.onOnline())})},e.unmount=function(){var o,i;(o=this.unsubscribeFocus)==null||o.call(this),(i=this.unsubscribeOnline)==null||i.call(this)},e.isFetching=function(o,i){var r=$P(o,i),s=r[0];return s.fetching=!0,this.queryCache.findAll(s).length},e.isMutating=function(o){return this.mutationCache.findAll(ca({},o,{fetching:!0})).length},e.getQueryData=function(o,i){var r;return(r=this.queryCache.find(o,i))==null?void 0:r.state.data},e.getQueriesData=function(o){return this.getQueryCache().findAll(o).map(function(i){var r=i.queryKey,s=i.state,a=s.data;return[r,a]})},e.setQueryData=function(o,i,r){var s=Dfe(o),a=this.defaultQueryOptions(s);return this.queryCache.build(this,a).setData(i,r)},e.setQueriesData=function(o,i,r){var s=this;return dh.batch(function(){return s.getQueryCache().findAll(o).map(function(a){var A=a.queryKey;return[A,s.setQueryData(A,i,r)]})})},e.getQueryState=function(o,i){var r;return(r=this.queryCache.find(o,i))==null?void 0:r.state},e.removeQueries=function(o,i){var r=$P(o,i),s=r[0],a=this.queryCache;dh.batch(function(){a.findAll(s).forEach(function(A){a.remove(A)})})},e.resetQueries=function(o,i,r){var s=this,a=$P(o,i,r),A=a[0],c=a[1],l=this.queryCache,u=ca({},A,{active:!0});return dh.batch(function(){return l.findAll(A).forEach(function(g){g.reset()}),s.refetchQueries(u,c)})},e.cancelQueries=function(o,i,r){var s=this,a=$P(o,i,r),A=a[0],c=a[1],l=c===void 0?{}:c;typeof l.revert>"u"&&(l.revert=!0);var u=dh.batch(function(){return s.queryCache.findAll(A).map(function(g){return g.cancel(l)})});return Promise.all(u).then(II).catch(II)},e.invalidateQueries=function(o,i,r){var s,a,A,c=this,l=$P(o,i,r),u=l[0],g=l[1],h=ca({},u,{active:(s=(a=u.refetchActive)!=null?a:u.active)!=null?s:!0,inactive:(A=u.refetchInactive)!=null?A:!1});return dh.batch(function(){return c.queryCache.findAll(u).forEach(function(d){d.invalidate()}),c.refetchQueries(h,g)})},e.refetchQueries=function(o,i,r){var s=this,a=$P(o,i,r),A=a[0],c=a[1],l=dh.batch(function(){return s.queryCache.findAll(A).map(function(g){return g.fetch(void 0,ca({},c,{meta:{refetchPage:A?.refetchPage}}))})}),u=Promise.all(l).then(II);return c?.throwOnError||(u=u.catch(II)),u},e.fetchQuery=function(o,i,r){var s=Dfe(o,i,r),a=this.defaultQueryOptions(s);typeof a.retry>"u"&&(a.retry=!1);var A=this.queryCache.build(this,a);return A.isStaleByTime(a.staleTime)?A.fetch(a):Promise.resolve(A.state.data)},e.prefetchQuery=function(o,i,r){return this.fetchQuery(o,i,r).then(II).catch(II)},e.fetchInfiniteQuery=function(o,i,r){var s=Dfe(o,i,r);return s.behavior=ZKi(),this.fetchQuery(s)},e.prefetchInfiniteQuery=function(o,i,r){return this.fetchInfiniteQuery(o,i,r).then(II).catch(II)},e.cancelMutations=function(){var o=this,i=dh.batch(function(){return o.mutationCache.getAll().map(function(r){return r.cancel()})});return Promise.all(i).then(II).catch(II)},e.resumePausedMutations=function(){return this.getMutationCache().resumePausedMutations()},e.executeMutation=function(o){return this.mutationCache.build(this,o).execute()},e.getQueryCache=function(){return this.queryCache},e.getMutationCache=function(){return this.mutationCache},e.getDefaultOptions=function(){return this.defaultOptions},e.setDefaultOptions=function(o){this.defaultOptions=o},e.setQueryDefaults=function(o,i){var r=this.queryDefaults.find(function(s){return WT(o)===WT(s.queryKey)});r?r.defaultOptions=i:this.queryDefaults.push({queryKey:o,defaultOptions:i})},e.getQueryDefaults=function(o){var i;return o?(i=this.queryDefaults.find(function(r){return Nfe(o,r.queryKey)}))==null?void 0:i.defaultOptions:void 0},e.setMutationDefaults=function(o,i){var r=this.mutationDefaults.find(function(s){return WT(o)===WT(s.mutationKey)});r?r.defaultOptions=i:this.mutationDefaults.push({mutationKey:o,defaultOptions:i})},e.getMutationDefaults=function(o){var i;return o?(i=this.mutationDefaults.find(function(r){return Nfe(o,r.mutationKey)}))==null?void 0:i.defaultOptions:void 0},e.defaultQueryOptions=function(o){if(o?._defaulted)return o;var i=ca({},this.defaultOptions.queries,this.getQueryDefaults(o?.queryKey),o,{_defaulted:!0});return!i.queryHash&&i.queryKey&&(i.queryHash=Cqe(i.queryKey,i)),i},e.defaultQueryObserverOptions=function(o){return this.defaultQueryOptions(o)},e.defaultMutationOptions=function(o){return o?._defaulted?o:ca({},this.defaultOptions.mutations,this.getMutationDefaults(o?.mutationKey),o,{_defaulted:!0})},e.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},t})(),nVi=(function(t){NN(e,t);function e(o,i){var r;return r=t.call(this)||this,r.client=o,r.options=i,r.trackedProps=[],r.selectError=null,r.bindMethods(),r.setOptions(i),r}var n=e.prototype;return n.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},n.onSubscribe=function(){this.listeners.length===1&&(this.currentQuery.addObserver(this),Smn(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},n.onUnsubscribe=function(){this.listeners.length||this.destroy()},n.shouldFetchOnReconnect=function(){return xqe(this.currentQuery,this.options,this.options.refetchOnReconnect)},n.shouldFetchOnWindowFocus=function(){return xqe(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},n.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},n.setOptions=function(i,r){var s=this.options,a=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(i),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();var A=this.hasListeners();A&&Qmn(this.currentQuery,a,this.options,s)&&this.executeFetch(),this.updateResult(r),A&&(this.currentQuery!==a||this.options.enabled!==s.enabled||this.options.staleTime!==s.staleTime)&&this.updateStaleTimeout();var c=this.computeRefetchInterval();A&&(this.currentQuery!==a||this.options.enabled!==s.enabled||c!==this.currentRefetchInterval)&&this.updateRefetchInterval(c)},n.getOptimisticResult=function(i){var r=this.client.defaultQueryObserverOptions(i),s=this.client.getQueryCache().build(this.client,r);return this.createResult(s,r)},n.getCurrentResult=function(){return this.currentResult},n.trackResult=function(i,r){var s=this,a={},A=function(l){s.trackedProps.includes(l)||s.trackedProps.push(l)};return Object.keys(i).forEach(function(c){Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:function(){return A(c),i[c]}})}),(r.useErrorBoundary||r.suspense)&&A("error"),a},n.getNextResult=function(i){var r=this;return new Promise(function(s,a){var A=r.subscribe(function(c){c.isFetching||(A(),c.isError&&i?.throwOnError?a(c.error):s(c))})})},n.getCurrentQuery=function(){return this.currentQuery},n.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},n.refetch=function(i){return this.fetch(ca({},i,{meta:{refetchPage:i?.refetchPage}}))},n.fetchOptimistic=function(i){var r=this,s=this.client.defaultQueryObserverOptions(i),a=this.client.getQueryCache().build(this.client,s);return a.fetch().then(function(){return r.createResult(a,s)})},n.fetch=function(i){var r=this;return this.executeFetch(i).then(function(){return r.updateResult(),r.currentResult})},n.executeFetch=function(i){this.updateQuery();var r=this.currentQuery.fetch(this.options,i);return i?.throwOnError||(r=r.catch(II)),r},n.updateStaleTimeout=function(){var i=this;if(this.clearStaleTimeout(),!(Pfe||this.currentResult.isStale||!Iqe(this.options.staleTime))){var r=hmn(this.currentResult.dataUpdatedAt,this.options.staleTime),s=r+1;this.staleTimeoutId=setTimeout(function(){i.currentResult.isStale||i.updateResult()},s)}},n.computeRefetchInterval=function(){var i;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(i=this.options.refetchInterval)!=null?i:!1},n.updateRefetchInterval=function(i){var r=this;this.clearRefetchInterval(),this.currentRefetchInterval=i,!(Pfe||this.options.enabled===!1||!Iqe(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(r.options.refetchIntervalInBackground||Qee.isFocused())&&r.executeFetch()},this.currentRefetchInterval))},n.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},n.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},n.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},n.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},n.createResult=function(i,r){var s=this.currentQuery,a=this.options,A=this.currentResult,c=this.currentResultState,l=this.currentResultOptions,u=i!==s,g=u?i.state:this.currentQueryInitialState,h=u?this.currentResult:this.previousQueryResult,d=i.state,p=d.dataUpdatedAt,m=d.error,_=d.errorUpdatedAt,f=d.isFetching,I=d.status,C=!1,y=!1,x;if(r.optimisticResults){var E=this.hasListeners(),B=!E&&Smn(i,r),S=E&&Qmn(i,s,r,a);(B||S)&&(f=!0,p||(I="loading"))}if(r.keepPreviousData&&!d.dataUpdateCount&&h?.isSuccess&&I!=="error")x=h.data,p=h.dataUpdatedAt,I=h.status,C=!0;else if(r.select&&typeof d.data<"u")if(A&&d.data===c?.data&&r.select===this.selectFn)x=this.selectResult;else try{this.selectFn=r.select,x=r.select(d.data),r.structuralSharing!==!1&&(x=Rfe(A?.data,x)),this.selectResult=x,this.selectError=null}catch(M){Lfe().error(M),this.selectError=M}else x=d.data;if(typeof r.placeholderData<"u"&&typeof x>"u"&&(I==="loading"||I==="idle")){var Q;if(A?.isPlaceholderData&&r.placeholderData===l?.placeholderData)Q=A.data;else if(Q=typeof r.placeholderData=="function"?r.placeholderData():r.placeholderData,r.select&&typeof Q<"u")try{Q=r.select(Q),r.structuralSharing!==!1&&(Q=Rfe(A?.data,Q)),this.selectError=null}catch(M){Lfe().error(M),this.selectError=M}typeof Q<"u"&&(I="success",x=Q,y=!0)}this.selectError&&(m=this.selectError,x=this.selectResult,_=Date.now(),I="error");var w={status:I,isLoading:I==="loading",isSuccess:I==="success",isError:I==="error",isIdle:I==="idle",data:x,dataUpdatedAt:p,error:m,errorUpdatedAt:_,failureCount:d.fetchFailureCount,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>g.dataUpdateCount||d.errorUpdateCount>g.errorUpdateCount,isFetching:f,isRefetching:f&&I!=="loading",isLoadingError:I==="error"&&d.dataUpdatedAt===0,isPlaceholderData:y,isPreviousData:C,isRefetchError:I==="error"&&d.dataUpdatedAt!==0,isStale:Eqe(i,r),refetch:this.refetch,remove:this.remove};return w},n.shouldNotifyListeners=function(i,r){if(!r)return!0;var s=this.options,a=s.notifyOnChangeProps,A=s.notifyOnChangePropsExclusions;if(!a&&!A||a==="tracked"&&!this.trackedProps.length)return!0;var c=a==="tracked"?this.trackedProps:a;return Object.keys(i).some(function(l){var u=l,g=i[u]!==r[u],h=c?.some(function(p){return p===l}),d=A?.some(function(p){return p===l});return g&&!d&&(!c||h)})},n.updateResult=function(i){var r=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!GKi(this.currentResult,r)){var s={cache:!0};i?.listeners!==!1&&this.shouldNotifyListeners(this.currentResult,r)&&(s.listeners=!0),this.notify(ca({},s,i))}},n.updateQuery=function(){var i=this.client.getQueryCache().build(this.client,this.options);if(i!==this.currentQuery){var r=this.currentQuery;this.currentQuery=i,this.currentQueryInitialState=i.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(r?.removeObserver(this),i.addObserver(this))}},n.onQueryUpdate=function(i){var r={};i.type==="success"?r.onSuccess=!0:i.type==="error"&&!Ffe(i.error)&&(r.onError=!0),this.updateResult(r),this.hasListeners()&&this.updateTimers()},n.notify=function(i){var r=this;dh.batch(function(){i.onSuccess?(r.options.onSuccess==null||r.options.onSuccess(r.currentResult.data),r.options.onSettled==null||r.options.onSettled(r.currentResult.data,null)):i.onError&&(r.options.onError==null||r.options.onError(r.currentResult.error),r.options.onSettled==null||r.options.onSettled(void 0,r.currentResult.error)),i.listeners&&r.listeners.forEach(function(s){s(r.currentResult)}),i.cache&&r.client.getQueryCache().notify({query:r.currentQuery,type:"observerResultsUpdated"})})},e})($U);function oVi(t,e){return e.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Smn(t,e){return oVi(t,e)||t.state.dataUpdatedAt>0&&xqe(t,e,e.refetchOnMount)}function xqe(t,e,n){if(e.enabled!==!1){var o=typeof n=="function"?n(t):n;return o==="always"||o!==!1&&Eqe(t,e)}return!1}function Qmn(t,e,n,o){return n.enabled!==!1&&(t!==e||o.enabled===!1)&&(!n.suspense||t.state.status!=="error")&&Eqe(t,n)}function Eqe(t,e){return t.isStaleByTime(e.staleTime)}var iVi=(function(t){NN(e,t);function e(o,i){var r;return r=t.call(this)||this,r.client=o,r.setOptions(i),r.bindMethods(),r.updateResult(),r}var n=e.prototype;return n.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},n.setOptions=function(i){this.options=this.client.defaultMutationOptions(i)},n.onUnsubscribe=function(){if(!this.listeners.length){var i;(i=this.currentMutation)==null||i.removeObserver(this)}},n.onMutationUpdate=function(i){this.updateResult();var r={listeners:!0};i.type==="success"?r.onSuccess=!0:i.type==="error"&&(r.onError=!0),this.notify(r)},n.getCurrentResult=function(){return this.currentResult},n.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},n.mutate=function(i,r){return this.mutateOptions=r,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,ca({},this.options,{variables:typeof i<"u"?i:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},n.updateResult=function(){var i=this.currentMutation?this.currentMutation.state:Bmn(),r=ca({},i,{isLoading:i.status==="loading",isSuccess:i.status==="success",isError:i.status==="error",isIdle:i.status==="idle",mutate:this.mutate,reset:this.reset});this.currentResult=r},n.notify=function(i){var r=this;dh.batch(function(){r.mutateOptions&&(i.onSuccess?(r.mutateOptions.onSuccess==null||r.mutateOptions.onSuccess(r.currentResult.data,r.currentResult.variables,r.currentResult.context),r.mutateOptions.onSettled==null||r.mutateOptions.onSettled(r.currentResult.data,null,r.currentResult.variables,r.currentResult.context)):i.onError&&(r.mutateOptions.onError==null||r.mutateOptions.onError(r.currentResult.error,r.currentResult.variables,r.currentResult.context),r.mutateOptions.onSettled==null||r.mutateOptions.onSettled(void 0,r.currentResult.error,r.currentResult.variables,r.currentResult.context))),i.listeners&&r.listeners.forEach(function(s){s(r.currentResult)})})},e})($U),rVi=NFt.unstable_batchedUpdates;dh.setBatchNotifyFunction(rVi);var sVi=console;JKi(sVi);var vmn=Fs.createContext(void 0),wmn=Fs.createContext(!1);function Pmn(t){return t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=vmn),window.ReactQueryClientContext):vmn}var Bqe=function(){var e=Fs.useContext(Pmn(Fs.useContext(wmn)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},aVi=function(e){var n=e.client,o=e.contextSharing,i=o===void 0?!1:o,r=e.children;Fs.useEffect(function(){return n.mount(),function(){n.unmount()}},[n]);var s=Pmn(i);return Fs.createElement(wmn.Provider,{value:i},Fs.createElement(s.Provider,{value:n},r))};function AVi(){var t=!1;return{clearReset:function(){t=!1},reset:function(){t=!0},isReset:function(){return t}}}var cVi=Fs.createContext(AVi()),lVi=function(){return Fs.useContext(cVi)};function Mmn(t,e,n){return typeof e=="function"?e.apply(void 0,n):typeof e=="boolean"?e:!!t}function uVi(t,e,n){var o=Fs.useRef(!1),i=Fs.useState(0),r=i[1],s=LKi(t,e),a=Bqe(),A=Fs.useRef();A.current?A.current.setOptions(s):A.current=new iVi(a,s);var c=A.current.getCurrentResult();Fs.useEffect(function(){o.current=!0;var u=A.current.subscribe(dh.batchCalls(function(){o.current&&r(function(g){return g+1})}));return function(){o.current=!1,u()}},[]);var l=Fs.useCallback(function(u,g){A.current.mutate(u,g).catch(II)},[]);if(c.error&&Mmn(void 0,A.current.options.useErrorBoundary,[c.error]))throw c.error;return ca({},c,{mutate:l,mutateAsync:c.mutate})}function gVi(t,e){var n=Fs.useRef(!1),o=Fs.useState(0),i=o[1],r=Bqe(),s=lVi(),a=r.defaultQueryObserverOptions(t);a.optimisticResults=!0,a.onError&&(a.onError=dh.batchCalls(a.onError)),a.onSuccess&&(a.onSuccess=dh.batchCalls(a.onSuccess)),a.onSettled&&(a.onSettled=dh.batchCalls(a.onSettled)),a.suspense&&(typeof a.staleTime!="number"&&(a.staleTime=1e3),a.cacheTime===0&&(a.cacheTime=1)),(a.suspense||a.useErrorBoundary)&&(s.isReset()||(a.retryOnMount=!1));var A=Fs.useState(function(){return new e(r,a)}),c=A[0],l=c.getOptimisticResult(a);if(Fs.useEffect(function(){n.current=!0,s.clearReset();var u=c.subscribe(dh.batchCalls(function(){n.current&&i(function(g){return g+1})}));return c.updateResult(),function(){n.current=!1,u()}},[s,c]),Fs.useEffect(function(){c.setOptions(a,{listeners:!1})},[a,c]),a.suspense&&l.isLoading)throw c.fetchOptimistic(a).then(function(u){var g=u.data;a.onSuccess==null||a.onSuccess(g),a.onSettled==null||a.onSettled(g,null)}).catch(function(u){s.clearReset(),a.onError==null||a.onError(u),a.onSettled==null||a.onSettled(void 0,u)});if(l.isError&&!s.isReset()&&!l.isFetching&&Mmn(a.suspense,a.useErrorBoundary,[l.error,c.getCurrentQuery()]))throw l.error;return a.notifyOnChangeProps==="tracked"&&(l=c.trackResult(l,a)),l}function dVi(t,e,n){var o=Dfe(t,e,n);return gVi(o,nVi)}function hVi({orderQuote:t,selectedShippingCarrier:e,onSelectShippingCarrier:n,lowestShippingCarrierCost:o}){const i=e?t.shipping_options.find(r=>r.carrier===e):null;return K.jsxs("div",{className:"rf-rounded-xl rf-bg-white rf-shadow-lg rf-border rf-border-gray-200",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-6 rf-pt-4 rf-pb-2",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(bbi,{className:"rf-w-6 rf-h-6 rf-text-blue-500"}),K.jsx("span",{className:"rf-font-semibold rf-text-lg",children:t.vendor_name.toUpperCase()})]}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-end",children:[K.jsx("span",{className:"rf-text-gray-500 rf-text-sm",children:"Fully Assembled PCB"}),K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsxs("span",{className:"rf-text-gray-400 rf-line-through rf-text-base",children:["$",o.toFixed(2)]}),K.jsx("span",{className:"rf-font-bold rf-text-xl rf-text-blue-600",children:"$50.00"})]})]})]}),K.jsx("hr",{className:"rf-border-gray-200"}),K.jsxs("div",{className:"rf-px-6 rf-pt-4 rf-pb-2",children:[K.jsx("div",{className:"rf-mb-2 rf-text-sm rf-font-bold rf-text-gray-700",children:"Shipping Options:"}),K.jsx("div",{className:"rf-flex rf-flex-col rf-gap-2 rf-mb-2",children:t.shipping_options.map((r,s)=>K.jsxs("button",{type:"button",className:Oi("rf-flex rf-items-center rf-gap-3 rf-px-4 rf-py-3 rf-rounded-lg rf-border rf-min-w-[148px] rf-transition-colors rf-bg-white",e===r.carrier?"rf-border-blue-600 rf-bg-blue-50 rf-ring-2 rf-ring-blue-500":"rf-border-gray-300 rf-bg-gray-50 hover:rf-border-blue-300"),onClick:()=>n(r.carrier),children:[K.jsx(wbi,{className:"rf-w-5 rf-h-5 rf-text-yellow-500"}),K.jsxs("div",{className:"rf-text-left rf-flex-1",children:[K.jsx("div",{className:"rf-leading-tight rf-font-medium",children:r.carrier}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:"Express, 5-12 days"})]}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-end rf-ml-2",children:[K.jsxs("span",{className:"rf-text-gray-400 rf-line-through rf-text-sm",children:["$",r.cost.toFixed(2)]}),K.jsx("span",{className:"rf-text-xs rf-text-blue-600 rf-font-medium",children:"waived"})]})]},r.carrier+s))})]}),e!==null&&i&&K.jsx("div",{className:"rf-px-6 rf-pb-4 rf-pt-2",children:K.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mt-3 rf-mb-2",children:[K.jsx("span",{className:"rf-text-gray-700 rf-font-bold",children:"Total (incl. shipping):"}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-end",children:[K.jsxs("div",{className:"rf-text-gray-400 rf-line-through rf-text-base",children:["$",(t.total_cost_without_shipping+i.cost).toFixed(2)]}),K.jsx("div",{className:"rf-flex rf-items-center",children:K.jsx("span",{className:"rf-font-bold rf-text-xl rf-text-blue-600",children:"$50.00"})})]})]})})]})}const pVi=async t=>{try{const{order_quote_id:e}=await gq.post("order_quotes/create",{json:{package_release_id:t,vendor_name:"jlcpcb"}}).json();return{order_quote_id:e}}catch(e){if(e instanceof Wb){const n=await e.response.json();throw{error:{message:n.message,error_code:n.error_code}}}throw e}},mVi=async t=>{const{order_quote:e}=await gq.get("order_quotes/get",{searchParams:{order_quote_id:t}}).json();return e},_Vi=()=>{const t=Bqe();return uVi({mutationKey:["createOrderQuote"],mutationFn:e=>pVi(e),onSuccess:e=>{t.invalidateQueries(["getOrderQuote",e.order_quote_id])}})},fVi=t=>{const{data:e,error:n,status:o}=dVi(["getOrderQuote",t],()=>mVi(t||""),{enabled:!!t,refetchInterval:i=>i?.is_completed||i?.has_error?!1:4e3,refetchIntervalInBackground:!0,retry:!1});return{status:o==="loading"?"loading":o==="error"?"error":"success",data:e??null,error:n instanceof Error?n:null}},IVi=({onCancel:t,packageReleaseId:e,signIn:n,isLoggedIn:o})=>{const[i,r]=ee.useState(null),[s,a]=ee.useState(null),{mutate:A,error:c}=_Vi();ee.useEffect(()=>{e&&A(e,{onSuccess:p=>{a(p.order_quote_id)}})},[e]);const{data:l}=fVi(s||void 0),u=c&&c.error?.message||l?.error?.message;hpn({errorMessage:u});const g=async p=>{const m=uq("TSCIRCUIT_STRIPE_CHECKOUT_BASE_URL");window.location.href=`${m}?client_reference_id=${p}&shipping_option=${i}`};ee.useEffect(()=>{if(i===null&&l&&Array.isArray(l.shipping_options)&&l.shipping_options.length>0){const p=l.shipping_options.reduce((m,_)=>_.cost<m.cost?_:m,l.shipping_options[0]);r(p?.carrier||null)}},[l]);const h=ee.useMemo(()=>l&&Array.isArray(l.shipping_options)&&l.shipping_options.length>0?l.shipping_options.reduce((p,m)=>m.cost<p.cost?m:p,l.shipping_options[0]).cost:0,[l]),d=c&&c.error?.error_code?.includes("no_token")||l?.error?.error_code?.includes("no_token")&&n;return!o||d?K.jsx(xVi,{signIn:n}):K.jsxs("div",{className:`
      rf-w-full rf-mx-auto rf-bg-white rf-rounded-2xl 
      rf-p-4 sm:rf-p-6 md:rf-p-8 
      rf-flex rf-flex-col rf-gap-3
      rf-max-w-full sm:rf-max-w-md md:rf-max-w-lg lg:rf-max-w-xl
    `,children:[K.jsx("h2",{className:"rf-text-xl sm:rf-text-2xl md:rf-text-3xl rf-font-bold rf-text-center",children:"Order PCB"}),!(c||l?.error)&&(!s||!l||l?.is_processing)&&K.jsx(CVi,{message:"Fetching quotes..."}),(c||l?.error)&&K.jsx(yVi,{message:c&&c.error?.message||l?.error?.message||"Failed to fetch quotes"}),l?.is_completed&&!c&&!l?.error&&Array.isArray(l?.shipping_options)&&l.shipping_options.length>0&&K.jsxs(K.Fragment,{children:[K.jsx("div",{className:"rf-bg-blue-100 rf-text-blue-800 rf-p-2 sm:rf-p-3 rf-rounded-md rf-text-center rf-text-xs sm:rf-text-sm",children:"This board is eligible for the tscircuit Flat Fee"}),K.jsx(hVi,{orderQuote:l,selectedShippingCarrier:i,onSelectShippingCarrier:r,lowestShippingCarrierCost:h+(l.total_cost_without_shipping||0)},l?.order_quote_id)]}),K.jsxs("div",{className:"rf-flex rf-flex-col-reverse sm:rf-flex-row rf-justify-between rf-mt-5 rf-gap-3 sm:rf-gap-4",children:[K.jsx(fA,{variant:"outline",type:"button",className:"rf-w-full sm:rf-w-1/2 rf-border-red-500 rf-text-red-500 rf-hover:bg-red-50 rf-hover:text-red-600 rf-text-sm sm:rf-text-base",onClick:t,children:"Cancel"}),K.jsx(fA,{type:"button",className:"rf-w-full sm:rf-w-1/2 rf-bg-blue-600 rf-hover:bg-blue-700 rf-text-sm sm:rf-text-base",disabled:i===null,onClick:()=>{if(i===null){ua.error("Please select a shipping option.");return}l&&g(l.order_quote_id)},children:"Continue"})]}),K.jsx("div",{className:"rf-text-xs rf-text-center rf-text-gray-400 rf-mt-3 sm:rf-mt-4 rf-px-2",children:"Pricing may vary based on specifications."})]})},CVi=({message:t})=>K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-2 rf-my-12",children:[K.jsx(SE,{className:"rf-animate-spin rf-w-8 rf-h-8 rf-text-gray-400"}),K.jsx("p",{className:"rf-text-gray-600",children:t})]}),yVi=({message:t})=>K.jsx("div",{className:"rf-text-red-600 rf-text-center rf-py-12",children:t}),xVi=({signIn:t})=>K.jsxs("div",{className:`
    rf-w-full rf-mx-auto rf-bg-white rf-rounded-2xl 
    rf-p-4 sm:rf-p-6 md:rf-p-8 
    rf-flex rf-flex-col rf-gap-3
    rf-max-w-full sm:rf-max-w-md md:rf-max-w-lg lg:rf-max-w-xl
  `,children:[K.jsx("h2",{className:"rf-text-xl sm:rf-text-2xl md:rf-text-3xl rf-font-bold rf-text-center",children:"Order PCB"}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4 rf-py-4 sm:rf-py-6 md:rf-py-8",children:[K.jsx("p",{className:"rf-text-gray-600 rf-text-sm sm:rf-text-base rf-text-center rf-px-2",children:"Please sign in to continue"}),K.jsxs(fA,{onClick:t,className:"rf-flex rf-items-center rf-gap-2 rf-text-sm sm:rf-text-base rf-px-4 sm:rf-px-6",children:[K.jsx(nWe,{className:"rf-w-4 rf-h-4 sm:rf-w-5 sm:rf-h-5"}),"Sign in with GitHub"]})]})]}),EVi=new tVi,BVi=({isOpen:t,onClose:e,stage:n,setStage:o,circuitJson:i,packageReleaseId:r,signIn:s,isLoggedIn:a})=>K.jsx(aVi,{client:EVi,children:K.jsx(KT,{open:t,onOpenChange:A=>{A||e()},children:K.jsx(VP,{className:`
          !rf-p-0 !rf-z-[101] rf-rounded-md
          !rf-w-[95vw] !rf-max-w-[95vw]
          sm:rf-w-[90vw] sm:rf-max-w-[500px]
          md:rf-w-auto md:rf-max-w-[660px]
          lg:rf-max-w-[720px]
          xl:rf-max-w-[800px]
          rf-max-h-[90vh] rf-overflow-y-auto
        `,children:K.jsx("div",{className:"rf-relative rf-w-full",children:n==="initial"&&K.jsx(IVi,{onCancel:e,packageReleaseId:r??"",signIn:s??(()=>{}),isLoggedIn:a})})})})}),bVi=({isOpen:t,onClose:e,stage:n,setStage:o,signIn:i,isLoggedIn:r})=>{const s=md(a=>a.circuitJson);return K.jsx(BVi,{signIn:i,isOpen:t,onClose:e,stage:n,setStage:o,circuitJson:s,isLoggedIn:r??!1})},SVi=()=>{const[t,e]=ee.useState(!1),[n,o]=ee.useState("initial");return{isOpen:t,stage:n,open:()=>e(!0),close:()=>{e(!1),o("initial")},setStage:o,OrderDialog:bVi}};async function Dmn(){const t=await fetch(`${QC}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){const r=await(await fetch(`${QC}/files/get?file_path=${encodeURIComponent(o.file_path)}`)).json();(r.file?.text_content||r.file?.binary_content_b64)&&n.set(o.file_path,{text_content:r.file.text_content,binary_content_b64:r.file.binary_content_b64})}return n}const QVi="https://api.tscircuit.com/bug_reports/view?bug_report_id=",vVi=t=>`${QVi}${t}`,wVi=t=>{const[e,n]=ee.useState(!1),[o,i]=ee.useState(!1),[r,s]=ee.useState(null),[a,A]=ee.useState(null),[c,l]=ee.useState([]),u=ee.useRef(null),[g,h]=ee.useState(null),[d,p]=ee.useState(0),m=t?.onLoginRequired,_=ee.useMemo(()=>zge()?!0:typeof document>"u"?!1:document.cookie.split(";").some(x=>x.trim().startsWith("session=")),[e]);ee.useEffect(()=>{if(e&&!g&&u.current){const x=typeof window<"u"?window.__TSCIRCUIT_LAST_EXECUTION_ERROR:void 0;x&&(u.current.value=`I'm getting this execution error:

${x}`)}},[e,g]),ee.useEffect(()=>{e&&!g&&Dmn().then(x=>{p(x.size)}).catch(x=>{console.error("Failed to fetch file count",x),p(0)})},[e,g]);const f=ee.useCallback(()=>{s(null),h(null),A(null),l([]),u.current&&(u.current.value=""),n(!0)},[]),I=ee.useCallback(()=>{n(!1)},[]),C=ee.useCallback(async()=>{i(!0),s(null),A(null),l([]);const x=Hw(),E=u.current?.value||"";try{const B=await Dmn();if(B.size===0){ua.error("No project files available to include in the bug report"),i(!1);return}const S=new Date(Date.now()+1440*60*1e3).toISOString(),w=(await x.post("bug_reports/create",{json:{text:E.trim()||void 0,is_auto_deleted:!0,delete_at:S}}).json()).bug_report.bug_report_id,M=Array.from(B.entries()),k=[];for(let F=0;F<M.length;F++){const[O,U]=M[F];A({current:F+1,total:M.length,currentFile:O});try{const Y={bug_report_id:w,file_path:O};U.text_content&&(Y.content_text=U.text_content),U.binary_content_b64&&(Y.content_base64=U.binary_content_b64),await x.post("bug_reports/upload_file",{json:Y})}catch(Y){const W=Y instanceof Wb?`HTTP ${Y.response.status}`:Y instanceof Error?Y.message:"Upload failed";k.push({filePath:O,message:W}),l([...k])}}A(null);const R=vVi(w);h({bugReportUrl:R})}catch(B){if(console.error("Failed to submit bug report",B),B instanceof Wb)if(B.response.status===401)if(_){const S="Your session has expired. Please sign in again to continue.";s(S),ua.error(S),m&&(I(),m())}else{const S="You must be logged in to report a bug. Please sign in via cli and try again.";s(S),ua.error(S),setTimeout(()=>{m&&(I(),m())},1e3)}else{const S=`Failed to submit bug report (${B.response.status})`;s(S),ua.error(S)}else if(B instanceof Error)s(B.message),ua.error(B.message);else{const S="Failed to submit bug report";s(S),ua.error(S)}}finally{i(!1)}},[_,m]);return{BugReportDialog:ee.useMemo(()=>{const x=a?Math.round(a.current/a.total*100):0;return K.jsx(Epn,{open:e,onOpenChange:E=>{E?(s(null),h(null),A(null),l([]),n(!0)):o||I()},children:K.jsxs(k$e,{children:[K.jsxs(F$e,{children:[K.jsx(H$e,{children:g?"Bug Report Created":"Report Bug"}),K.jsx(O$e,{asChild:!0,children:g?K.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[K.jsx("p",{children:"Bug report created successfully."}),c.length>0&&K.jsxs("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-28 rf-overflow-y-auto rf-overflow-x-hidden",children:[K.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[c.length," file(s) failed:"]}),c.map((E,B)=>K.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${E.filePath}: ${E.message}`,children:[K.jsx("span",{className:"rf-font-medium rf-break-all",children:E.filePath.split("/").pop()}),K.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:E.message})]},B))]}),K.jsx("div",{children:K.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:g.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),K.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",K.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"tscircuit Discord"}),"."]})]}):K.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:a?K.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[K.jsx("span",{children:"Uploading files..."}),K.jsxs("span",{children:[a.current,"/",a.total]})]}),K.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:K.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${x}%`}})}),K.jsx("p",{className:"rf-text-xs rf-text-gray-500 rf-break-all rf-truncate rf-w-full rf-max-w-full",children:`${a.currentFile.slice(0,60)}${a.currentFile.length>60?"...":""}`}),c.length>0&&K.jsx("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-20 rf-overflow-y-auto rf-overflow-x-hidden",children:c.map((E,B)=>K.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${E.filePath}: ${E.message}`,children:[K.jsx("span",{className:"rf-font-medium rf-break-all",children:E.filePath.split("/").pop()}),K.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:E.message})]},B))})]}):K.jsxs(K.Fragment,{children:[K.jsxs("p",{children:["Reporting a bug will upload your entire project",d>0?` (${d} file${d===1?"":"s"})`:""," ","to tscircuit support."]}),K.jsxs("div",{className:"rf-space-y-2",children:[K.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),K.jsx("textarea",{ref:u,id:"bug-description",className:"rf-w-full rf-min-h-[100px] rf-px-3 rf-py-2 rf-text-sm rf-border rf-border-gray-300 rf-rounded-md focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-blue-500",placeholder:"Describe the issue you're experiencing...",disabled:o})]}),K.jsxs("p",{children:["Share the generated bug report link privately with tscircuit staff so we can help debug your issue. You can also reach out on our",K.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"Discord community"}),"."]}),!_&&K.jsx("p",{className:"rf-text-red-600",children:"You appear to be logged out. Please log in before reporting a bug or the upload will fail."}),r&&K.jsx("p",{className:"rf-text-red-600",children:r})]})})})]}),K.jsx(L$e,{children:g?K.jsx("button",{type:"button",className:gU(),onClick:()=>{I()},children:"Close"}):K.jsxs(K.Fragment,{children:[K.jsx(G$e,{disabled:o,onClick:()=>{o||I()},children:"Cancel"}),!_&&m?K.jsx("button",{type:"button",className:gU(),onClick:E=>{E.preventDefault(),I(),m()},children:"Sign In"}):K.jsx("button",{type:"button",className:NB(gU(),o&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:o,onClick:E=>{E.preventDefault(),C()},children:o?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[e,o,I,r,g,d,_,C,m,a,c]),openBugReportDialog:f}};function PVi({open:t,onOpenChange:e,onExport:n}){const[o,i]=ee.useState(!1),r=()=>{n({includeSilkscreen:o}),e(!1)},s=()=>{e(!1)};return K.jsx(KT,{open:t,onOpenChange:e,children:K.jsxs(VP,{children:[K.jsxs(zP,{children:[K.jsx(JP,{children:"LightBurn Export Options"}),K.jsx(VT,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),K.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[K.jsx(Iee,{id:"includeSilkscreen",checked:o,onCheckedChange:a=>i(a===!0)}),K.jsx("label",{htmlFor:"includeSilkscreen",className:"rf-text-xs rf-font-medium rf-leading-none peer-disabled:rf-cursor-not-allowed peer-disabled:rf-opacity-70",children:"Include silkscreen layer"})]})}),K.jsxs(jU,{children:[K.jsx(fA,{variant:"outline",onClick:s,children:"Cancel"}),K.jsx(fA,{onClick:r,children:"Export"})]})]})})}const MVi=/#(\d+)/,DVi=t=>{const e=t.match(MVi);if(!e)return null;const n=Number.parseInt(e[1],10);return Number.isFinite(n)?n:null},NVi=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const e=new Date(t).getTime();return Number.isFinite(e)?e:null}return null},RVi=t=>{if(!t)return null;let e=null,n=-1,o=-1;for(const[i,r]of Object.entries(t)){const s=DVi(i),a=NVi(r.createdAt);if(s!==null){s>n&&(n=s,e={key:i,value:r});continue}if(n===-1){if(a!==null&&a>o){o=a,e={key:i,value:r};continue}e||(e={key:i,value:r})}}return e};var TVi=Object.defineProperty,kVi=(t,e)=>TVi(t,"name",{value:e,configurable:!0});function bqe(t,[e,n]){return Math.min(n,Math.max(e,t))}kVi(bqe,"clamp");var FVi=Object.defineProperty,LVi=(t,e)=>FVi(t,"name",{value:e,configurable:!0});function Nmn(t){const e=ee.useRef({value:t,previous:t});return ee.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}LVi(Nmn,"usePrevious");var HVi=Object.defineProperty,OVi=(t,e)=>HVi(t,"name",{value:e,configurable:!0}),Rmn=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),GVi=ee.forwardRef(OVi(function(e,n){return K.jsx(Na.span,{...e,ref:n,style:{...Rmn,...e.style}})},"VisuallyHidden")),YVi=GVi,UVi=Object.defineProperty,nl=(t,e)=>UVi(t,"name",{value:e,configurable:!0}),KVi=[" ","Enter","ArrowUp","ArrowDown"],VVi=[" ","Enter"],qU="Select",[Hfe,Ofe,zVi]=tge(qU),[jT,kmr]=Nx(qU,[zVi,PP]),Sqe=PP(),[JVi,qP]=jT(qU),[WVi,jVi]=jT(qU);function Tmn(t){const{__scopeSelect:e,children:n,open:o,defaultOpen:i,onOpenChange:r,value:s,defaultValue:a,onValueChange:A,dir:c,name:l,autoComplete:u,disabled:g,required:h,form:d,internal_do_not_use_render:p}=t,m=Sqe(e),[_,f]=ee.useState(null),[I,C]=ee.useState(null),[y,x]=ee.useState(!1),E=Q$(c),[B,S]=DB({prop:o,defaultProp:i??!1,onChange:r,caller:qU}),[Q,w]=DB({prop:s,defaultProp:a,onChange:A,caller:qU}),M=ee.useRef(null),k=ee.useRef(Q);ee.useEffect(()=>{const J=d?_?.ownerDocument.getElementById(d):_?.form;if(J instanceof HTMLFormElement){const oe=nl(()=>w(k.current),"reset");return J.addEventListener("reset",oe),()=>J.removeEventListener("reset",oe)}},[d,_,w]);const R=_?!!d||!!_.closest("form"):!0,[F,O]=ee.useState(new Set),U=t_(),Y=Array.from(F).map(J=>J.props.value).join(";"),W=ee.useCallback(J=>{O(oe=>new Set(oe).add(J))},[]),te=ee.useCallback(J=>{O(oe=>{const ie=new Set(oe);return ie.delete(J),ie})},[]),j={required:h,trigger:_,onTriggerChange:f,valueNode:I,onValueNodeChange:C,valueNodeHasChildren:y,onValueNodeHasChildrenChange:x,contentId:U,value:Q,onValueChange:w,open:B,onOpenChange:S,dir:E,triggerPointerDownPosRef:M,disabled:g,name:l,autoComplete:u,form:d,nativeOptions:F,nativeSelectKey:Y,isFormControl:R};return K.jsx(CZ,{...m,children:K.jsx(JVi,{scope:e,...j,children:K.jsx(Hfe.Provider,{scope:e,children:K.jsx(WVi,{scope:e,onNativeOptionAdd:W,onNativeOptionRemove:te,children:$mn(p)?p(j):n})})})})}nl(Tmn,"SelectProvider");var $Vi=nl(t=>{const{__scopeSelect:e,children:n,...o}=t;return K.jsx(Tmn,{__scopeSelect:e,...o,internal_do_not_use_render:({isFormControl:i})=>K.jsxs(K.Fragment,{children:[n,i?K.jsx(Izi,{__scopeSelect:e}):null]})})},"Select"),qVi="SelectTrigger",kmn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,disabled:i=!1,...r}=e,s=Sqe(o),a=qP(qVi,o),A=a.disabled||i,c=$A(n,a.onTriggerChange),l=Ofe(o),u=ee.useRef("touch"),[g,h,d]=wqe(m=>{const _=l().filter(C=>!C.disabled),f=_.find(C=>C.value===a.value),I=Pqe(_,m,f);I!==void 0&&a.onValueChange(I.value)}),p=nl(m=>{A||(a.onOpenChange(!0),d()),m&&(a.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})},"handleOpen");return K.jsx(Hme,{asChild:!0,...s,children:K.jsx(Na.button,{type:"button",role:"combobox","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:A,"data-disabled":A?"":void 0,"data-placeholder":vee(a.value)?"":void 0,...r,ref:c,onClick:ar(r.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&p(m)}),onPointerDown:ar(r.onPointerDown,m=>{u.current=m.pointerType;const _=m.target;_.hasPointerCapture(m.pointerId)&&_.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(p(m),m.preventDefault())}),onKeyDown:ar(r.onKeyDown,m=>{const _=g.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(_&&m.key===" ")&&KVi.includes(m.key)&&(p(),m.preventDefault())})})})},"SelectTrigger")),XVi="SelectValue",ZVi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,className:i,style:r,children:s,placeholder:a="",...A}=e,c=qP(XVi,o),{onValueNodeHasChildrenChange:l}=c,u=s!==void 0,g=$A(n,c.onValueNodeChange);Ep(()=>{l(u)},[l,u]);const h=vee(c.value);return K.jsx(Na.span,{...A,asChild:h?!1:A.asChild,ref:g,style:{pointerEvents:"none"},children:K.jsx(ee.Fragment,{children:h?a:s},h?"placeholder":"value")})},"SelectValue")),ezi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,children:i,...r}=e;return K.jsx(Na.span,{"aria-hidden":!0,...r,ref:n,children:i||"▼"})},"SelectIcon")),tzi="SelectPortal",[nzi,ozi]=jT(tzi,{forceMount:void 0}),izi=nl(t=>{const{__scopeSelect:e,forceMount:n,...o}=t;return K.jsx(nzi,{scope:t.__scopeSelect,forceMount:n,children:K.jsx(Gme,{asChild:!0,...o})})},"SelectPortal"),$T="SelectContent",Fmn=ee.forwardRef(nl(function(e,n){const o=ozi($T,e.__scopeSelect),{forceMount:i=o.forceMount,...r}=e,s=qP($T,e.__scopeSelect),[a,A]=ee.useState();return Ep(()=>{A(new DocumentFragment)},[]),K.jsx(uE,{present:i||s.open,children:({present:c})=>c?K.jsx(azi,{...r,ref:n}):K.jsx(rzi,{...r,fragment:a})})},"SelectContent")),rzi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,children:i,fragment:r}=e;return r?c6.createPortal(K.jsx(Lmn,{scope:o,children:K.jsx(Hfe.Slot,{scope:o,children:K.jsx("div",{ref:n,children:i})})}),r):null},"SelectContentFragment")),s9=10,[Lmn,qT]=jT($T),szi=MB("SelectContent.RemoveScroll"),azi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o}=e,{position:i="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:s,onPointerDownOutside:a,side:A,sideOffset:c,align:l,alignOffset:u,arrowPadding:g,collisionBoundary:h,collisionPadding:d,sticky:p,hideWhenDetached:m,avoidCollisions:_,...f}=e,I=qP($T,o),[C,y]=ee.useState(null),[x,E]=ee.useState(null),B=$A(n,y),[S,Q]=ee.useState(null),[w,M]=ee.useState(null),k=Ofe(o),[R,F]=ee.useState(!1),O=ee.useRef(!1);ee.useEffect(()=>{if(C)return Kme(C)},[C]),hU();const U=ee.useCallback(_e=>{const[ue,...fe]=k().map(Me=>Me.ref.current),[pe]=fe.slice(-1),ye=document.activeElement;for(const Me of _e)if(Me===ye||(Me?.scrollIntoView({block:"nearest"}),Me===ue&&x&&(x.scrollTop=0),Me===pe&&x&&(x.scrollTop=x.scrollHeight),Me?.focus(),document.activeElement!==ye))return},[k,x]),Y=ee.useCallback(()=>U([S,C]),[U,S,C]);ee.useEffect(()=>{R&&Y()},[R,Y]);const{onOpenChange:W,triggerPointerDownPosRef:te}=I;ee.useEffect(()=>{if(C){let _e={x:0,y:0};const ue=nl(pe=>{_e={x:Math.abs(Math.round(pe.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(pe.pageY)-(te.current?.y??0))}},"handlePointerMove"),fe=nl(pe=>{_e.x<=10&&_e.y<=10?pe.preventDefault():pe.composedPath().includes(C)||W(!1),document.removeEventListener("pointermove",ue),te.current=null},"handlePointerUp");return te.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",fe,{capture:!0})}}},[C,W,te]),ee.useEffect(()=>{const _e=nl(()=>W(!1),"close");return window.addEventListener("blur",_e),window.addEventListener("resize",_e),()=>{window.removeEventListener("blur",_e),window.removeEventListener("resize",_e)}},[W]);const[j,J]=wqe(_e=>{const ue=k().filter(ye=>!ye.disabled),fe=ue.find(ye=>ye.ref.current===document.activeElement),pe=Pqe(ue,_e,fe);pe&&setTimeout(()=>pe.ref.current?.focus())}),oe=ee.useCallback((_e,ue,fe)=>{const pe=!O.current&&!fe;(I.value!==void 0&&I.value===ue||pe)&&(Q(_e),pe&&(O.current=!0))},[I.value]),ie=ee.useCallback(()=>C?.focus(),[C]),ne=ee.useCallback((_e,ue,fe)=>{const pe=!O.current&&!fe;(I.value!==void 0&&I.value===ue||pe)&&M(_e)},[I.value]),le=i==="popper"?Hmn:Azi,ge=le===Hmn?{side:A,sideOffset:c,align:l,alignOffset:u,arrowPadding:g,collisionBoundary:h,collisionPadding:d,sticky:p,hideWhenDetached:m,avoidCollisions:_}:{};return K.jsx(Lmn,{scope:o,content:C,viewport:x,onViewportChange:E,itemRefCallback:oe,selectedItem:S,onItemLeave:ie,itemTextRefCallback:ne,focusSelectedItem:Y,selectedItemText:w,position:i,isPositioned:R,searchRef:j,children:K.jsx(yZ,{as:szi,allowPinchZoom:!0,children:K.jsx(Sme,{asChild:!0,trapped:I.open,onMountAutoFocus:_e=>{_e.preventDefault()},onUnmountAutoFocus:ar(r,_e=>{I.trigger?.focus({preventScroll:!0}),_e.preventDefault()}),children:K.jsx(_Z,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:_e=>_e.preventDefault(),onDismiss:()=>I.onOpenChange(!1),children:K.jsx(le,{role:"listbox",id:I.contentId,"data-state":I.open?"open":"closed",dir:I.dir,onContextMenu:_e=>_e.preventDefault(),...f,...ge,onPlaced:()=>F(!0),ref:B,style:{display:"flex",flexDirection:"column",outline:"none",...f.style},onKeyDown:ar(f.onKeyDown,_e=>{const ue=_e.ctrlKey||_e.altKey||_e.metaKey;if(_e.key==="Tab"&&_e.preventDefault(),!ue&&_e.key.length===1&&J(_e.key),["ArrowUp","ArrowDown","Home","End"].includes(_e.key)){let pe=k().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(_e.key)&&(pe=pe.slice().reverse()),["ArrowUp","ArrowDown"].includes(_e.key)){const ye=_e.target,Me=pe.indexOf(ye);pe=pe.slice(Me+1)}setTimeout(()=>U(pe)),_e.preventDefault()}})})})})})})},"SelectContentImpl")),Azi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,onPlaced:i,...r}=e,s=qP($T,o),a=qT($T,o),[A,c]=ee.useState(null),[l,u]=ee.useState(null),g=$A(n,u),h=Ofe(o),d=ee.useRef(!1),p=ee.useRef(!0),{viewport:m,selectedItem:_,selectedItemText:f,focusSelectedItem:I}=a,C=ee.useCallback(()=>{if(s.trigger&&s.valueNode&&A&&l&&m&&_&&f){const B=s.trigger.getBoundingClientRect(),S=l.getBoundingClientRect(),Q=s.valueNode.getBoundingClientRect(),w=f.getBoundingClientRect();if(s.dir!=="rtl"){const ye=w.left-S.left,Me=Q.left-ye,ve=B.left-Me,he=B.width+ve,Qe=Math.max(he,S.width),Pe=window.innerWidth-s9,we=bqe(Me,[s9,Math.max(s9,Pe-Qe)]);A.style.minWidth=he+"px",A.style.left=we+"px"}else{const ye=S.right-w.right,Me=window.innerWidth-Q.right-ye,ve=window.innerWidth-B.right-Me,he=B.width+ve,Qe=Math.max(he,S.width),Pe=window.innerWidth-s9,we=bqe(Me,[s9,Math.max(s9,Pe-Qe)]);A.style.minWidth=he+"px",A.style.right=we+"px"}const M=h(),k=window.innerHeight-s9*2,R=m.scrollHeight,F=window.getComputedStyle(l),O=parseInt(F.borderTopWidth,10),U=parseInt(F.paddingTop,10),Y=parseInt(F.borderBottomWidth,10),W=parseInt(F.paddingBottom,10),te=O+U+R+W+Y,j=Math.min(_.offsetHeight*5,te),J=window.getComputedStyle(m),oe=parseInt(J.paddingTop,10),ie=parseInt(J.paddingBottom,10),ne=B.top+B.height/2-s9,le=k-ne,ge=_.offsetHeight/2,_e=_.offsetTop+ge,ue=O+U+_e,fe=te-ue;if(ue<=ne){const ye=M.length>0&&_===M[M.length-1].ref.current;A.style.bottom="0px";const Me=l.clientHeight-m.offsetTop-m.offsetHeight,ve=Math.max(le,ge+(ye?ie:0)+Me+Y),he=ue+ve;A.style.height=he+"px"}else{const ye=M.length>0&&_===M[0].ref.current;A.style.top="0px";const ve=Math.max(ne,O+m.offsetTop+(ye?oe:0)+ge)+fe;A.style.height=ve+"px",m.scrollTop=ue-ne+m.offsetTop}A.style.margin=`${s9}px 0`,A.style.minHeight=j+"px",A.style.maxHeight=k+"px",i?.(),requestAnimationFrame(()=>d.current=!0)}},[h,s.trigger,s.valueNode,A,l,m,_,f,s.dir,i]);Ep(()=>C(),[C]);const[y,x]=ee.useState();Ep(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);const E=ee.useCallback(B=>{B&&p.current===!0&&(C(),I?.(),p.current=!1)},[C,I]);return K.jsx(czi,{scope:o,contentWrapper:A,shouldExpandOnScrollRef:d,onScrollButtonChange:E,children:K.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:y},children:K.jsx(Na.div,{...r,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})},"SelectItemAlignedPosition")),Hmn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,align:i="start",collisionPadding:r=s9,...s}=e,a=Sqe(o);return K.jsx(Ome,{...a,...s,ref:n,align:i,collisionPadding:r,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[czi,Qqe]=jT($T,{}),Omn="SelectViewport",lzi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,nonce:i,...r}=e,s=qT(Omn,o),a=Qqe(Omn,o),A=$A(n,s.onViewportChange),c=ee.useRef(0);return K.jsxs(K.Fragment,{children:[K.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),K.jsx(Hfe.Slot,{scope:o,children:K.jsx(Na.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:A,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:ar(r.onScroll,l=>{const u=l.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:h}=a;if(h?.current&&g){const d=Math.abs(c.current-u.scrollTop);if(d>0){const p=window.innerHeight-s9*2,m=parseFloat(g.style.minHeight),_=parseFloat(g.style.height),f=Math.max(m,_);if(f<p){const I=f+d,C=Math.min(p,I),y=I-C;g.style.height=C+"px",g.style.bottom==="0px"&&(u.scrollTop=y>0?y:0,g.style.justifyContent="flex-end")}}}c.current=u.scrollTop})})})]})},"SelectViewport")),uzi="SelectGroup",[Fmr,gzi]=jT(uzi),dzi="SelectLabel",Gmn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,...i}=e,r=gzi(dzi,o);return K.jsx(Na.div,{id:r.id,...i,ref:n})},"SelectLabel")),vqe="SelectItem",[hzi,Ymn]=jT(vqe),Umn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,value:i,disabled:r=!1,textValue:s,...a}=e,A=qP(vqe,o),c=qT(vqe,o),l=A.value===i,[u,g]=ee.useState(s??""),[h,d]=ee.useState(!1),p=lE(C=>c.itemRefCallback?.(C,i,r)),m=$A(n,p),_=t_(),f=ee.useRef("touch"),I=nl(()=>{r||(A.onValueChange(i),A.onOpenChange(!1))},"handleSelect");return K.jsx(hzi,{scope:o,value:i,disabled:r,textId:_,isSelected:l,onItemTextChange:ee.useCallback(C=>{g(y=>y||(C?.textContent??"").trim())},[]),children:K.jsx(Hfe.ItemSlot,{scope:o,value:i,disabled:r,textValue:u,children:K.jsx(Na.div,{role:"option","aria-labelledby":_,"data-highlighted":h?"":void 0,"aria-selected":l&&h,"data-state":l?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...a,ref:m,onFocus:ar(a.onFocus,()=>d(!0)),onBlur:ar(a.onBlur,()=>d(!1)),onClick:ar(a.onClick,()=>{f.current!=="mouse"&&I()}),onPointerUp:ar(a.onPointerUp,()=>{f.current==="mouse"&&I()}),onPointerDown:ar(a.onPointerDown,C=>{f.current=C.pointerType}),onPointerMove:ar(a.onPointerMove,C=>{f.current=C.pointerType,r?c.onItemLeave?.():f.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ar(a.onPointerLeave,C=>{C.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:ar(a.onKeyDown,C=>{r||C.target!==C.currentTarget||c.searchRef?.current!==""&&C.key===" "||(VVi.includes(C.key)&&I(),C.key===" "&&C.preventDefault())})})})})},"SelectItem")),Gfe="SelectItemText",pzi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,className:i,style:r,...s}=e,a=qP(Gfe,o),A=qT(Gfe,o),c=Ymn(Gfe,o),l=jVi(Gfe,o),[u,g]=ee.useState(null),h=lE(I=>A.itemTextRefCallback?.(I,c.value,c.disabled)),d=$A(n,g,c.onItemTextChange,h),p=u?.textContent,m=ee.useMemo(()=>K.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:_,onNativeOptionRemove:f}=l;return Ep(()=>(_(m),()=>f(m)),[_,f,m]),K.jsxs(K.Fragment,{children:[K.jsx(Na.span,{id:c.textId,...s,ref:d}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren&&!vee(a.value)?c6.createPortal(s.children,a.valueNode):null]})},"SelectItemText")),mzi="SelectItemIndicator",_zi=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,...i}=e;return Ymn(mzi,o).isSelected?K.jsx(Na.span,{"aria-hidden":!0,...i,ref:n}):null},"SelectItemIndicator")),Kmn="SelectScrollUpButton",Vmn=ee.forwardRef(nl(function(e,n){const o=qT(Kmn,e.__scopeSelect),i=Qqe(Kmn,e.__scopeSelect),[r,s]=ee.useState(!1),a=$A(n,i.onScrollButtonChange);return Ep(()=>{if(o.viewport&&o.isPositioned){let A=function(){const l=c.scrollTop>0;s(l)};nl(A,"handleScroll");const c=o.viewport;return A(),c.addEventListener("scroll",A),()=>c.removeEventListener("scroll",A)}},[o.viewport,o.isPositioned]),r?K.jsx(Wmn,{...e,ref:a,onAutoScroll:()=>{const{viewport:A,selectedItem:c}=o;A&&c&&(A.scrollTop=A.scrollTop-c.offsetHeight)}}):null},"SelectScrollUpButton")),zmn="SelectScrollDownButton",Jmn=ee.forwardRef(nl(function(e,n){const o=qT(zmn,e.__scopeSelect),i=Qqe(zmn,e.__scopeSelect),[r,s]=ee.useState(!1),a=$A(n,i.onScrollButtonChange);return Ep(()=>{if(o.viewport&&o.isPositioned){let A=function(){const l=c.scrollHeight-c.clientHeight,u=Math.ceil(c.scrollTop)<l;s(u)};nl(A,"handleScroll");const c=o.viewport;return A(),c.addEventListener("scroll",A),()=>c.removeEventListener("scroll",A)}},[o.viewport,o.isPositioned]),r?K.jsx(Wmn,{...e,ref:a,onAutoScroll:()=>{const{viewport:A,selectedItem:c}=o;A&&c&&(A.scrollTop=A.scrollTop+c.offsetHeight)}}):null},"SelectScrollDownButton")),Wmn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,onAutoScroll:i,...r}=e,s=qT("SelectScrollButton",o),a=ee.useRef(null),A=Ofe(o),c=ee.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return ee.useEffect(()=>()=>c(),[c]),Ep(()=>{A().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[A]),K.jsx(Na.div,{"aria-hidden":!0,...r,ref:n,style:{flexShrink:0,...r.style},onPointerDown:ar(r.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(i,50))}),onPointerMove:ar(r.onPointerMove,()=>{s.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(i,50))}),onPointerLeave:ar(r.onPointerLeave,()=>{c()})})},"SelectScrollButtonImpl")),jmn=ee.forwardRef(nl(function(e,n){const{__scopeSelect:o,...i}=e;return K.jsx(Na.div,{"aria-hidden":!0,...i,ref:n})},"SelectSeparator")),fzi="SelectBubbleInput",Izi=ee.forwardRef(nl(function({__scopeSelect:e,...n},o){const i=qP(fzi,e),{value:r,onValueChange:s,required:a,disabled:A,name:c,autoComplete:l,form:u}=i,{nativeOptions:g,nativeSelectKey:h}=i,d=ee.useRef(null),p=$A(o,d),m=r??"",_=Nmn(m),f=Array.from(g).some(I=>(I.props.value??"")==="");return ee.useEffect(()=>{const I=d.current;if(!I)return;const C=window.HTMLSelectElement.prototype,x=Object.getOwnPropertyDescriptor(C,"value").set;if(_!==m&&x){const E=new Event("change",{bubbles:!0});x.call(I,m),I.dispatchEvent(E)}},[_,m]),K.jsxs(Na.select,{"aria-hidden":!0,required:a,tabIndex:-1,name:c,autoComplete:l,disabled:A,form:u,onChange:I=>s(I.target.value),...n,style:{...Rmn,...n.style},ref:p,defaultValue:m,children:[vee(r)&&!f?K.jsx("option",{value:""}):null,Array.from(g)]},h)},"SelectBubbleInput"));function $mn(t){return typeof t=="function"}nl($mn,"isFunction");function vee(t){return t===""||t===void 0}nl(vee,"shouldShowPlaceholder");function wqe(t){const e=lE(t),n=ee.useRef(""),o=ee.useRef(0),i=ee.useCallback(s=>{const a=n.current+s;e(a),nl((function A(c){n.current=c,window.clearTimeout(o.current),c!==""&&(o.current=window.setTimeout(()=>A(""),1e3))}),"updateSearch")(a)},[e]),r=ee.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return ee.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,i,r]}nl(wqe,"useTypeaheadSearch");function Pqe(t,e,n){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,r=n?t.indexOf(n):-1;let s=qmn(t,Math.max(r,0));i.length===1&&(s=s.filter(c=>c!==n));const A=s.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return A!==n?A:void 0}nl(Pqe,"findNextItem");function qmn(t,e){return t.map((n,o)=>t[(e+o)%t.length])}nl(qmn,"wrapArray");const Czi=$Vi,yzi=ZVi,Xmn=ee.forwardRef(({className:t,children:e,...n},o)=>K.jsxs(kmn,{ref:o,className:Oi("rf-flex rf-h-10 rf-w-full rf-items-center rf-justify-between rf-rounded-md rf-border rf-border-input rf-bg-background rf-px-3 rf-py-2 rf-text-sm rf-ring-offset-background rf-placeholder:text-muted-foreground focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-ring focus:rf-ring-offset-2 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 [&>span]:rf-line-clamp-1",t),...n,children:[e,K.jsx(ezi,{asChild:!0,children:K.jsx(pZ,{className:"rf-h-4 rf-w-4 rf-opacity-50"})})]}));Xmn.displayName=kmn.displayName;const Zmn=ee.forwardRef(({className:t,...e},n)=>K.jsx(Vmn,{ref:n,className:Oi("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",t),...e,children:K.jsx(sbi,{className:"rf-h-4 rf-w-4"})}));Zmn.displayName=Vmn.displayName;const e_n=ee.forwardRef(({className:t,...e},n)=>K.jsx(Jmn,{ref:n,className:Oi("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",t),...e,children:K.jsx(pZ,{className:"rf-h-4 rf-w-4"})}));e_n.displayName=Jmn.displayName;const t_n=ee.forwardRef(({className:t,children:e,position:n="popper",...o},i)=>K.jsx(izi,{children:K.jsxs(Fmn,{ref:i,className:Oi("rf-relative rf-z-[100] rf-max-h-96 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-bg-white rf-text-black rf-shadow-md data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:rf-translate-y-1 data-[side=left]:-rf-translate-x-1 data-[side=right]:rf-translate-x-1 data-[side=top]:-rf-translate-y-1",t),position:n,...o,children:[K.jsx(Zmn,{}),K.jsx(lzi,{className:Oi("rf-p-1",n==="popper"&&"rf-h-[var(--radix-select-trigger-height)] rf-w-full rf-min-w-[var(--radix-select-trigger-width)]"),children:e}),K.jsx(e_n,{})]})}));t_n.displayName=Fmn.displayName;const xzi=ee.forwardRef(({className:t,...e},n)=>K.jsx(Gmn,{ref:n,className:Oi("rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",t),...e}));xzi.displayName=Gmn.displayName;const n_n=ee.forwardRef(({className:t,children:e,...n},o)=>K.jsxs(Umn,{ref:o,className:Oi("rf-relative rf-flex rf-w-full rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-text-gray-800 rf-outline-none focus:rf-bg-gray-100 focus:rf-text-gray-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50",t),...n,children:[K.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:K.jsx(_zi,{children:K.jsx(CS,{className:"rf-h-4 rf-w-4"})})}),K.jsx(pzi,{children:e})]}));n_n.displayName=Umn.displayName;const Ezi=ee.forwardRef(({className:t,...e},n)=>K.jsx(jmn,{ref:n,className:Oi("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted",t),...e}));Ezi.displayName=jmn.displayName;const o_n="Component Box (3MF)",Mqe=t=>`${t.toFixed(1)} mm`;function Bzi({open:t,onOpenChange:e,circuitJson:n,projectName:o}){mee();const[i,r]=ee.useState(""),[s,a]=ee.useState(null),[A,c]=ee.useState(null),[l,u]=ee.useState(!1),[g,h]=ee.useState(null);ee.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]),ee.useEffect(()=>{if(!t||i!==o_n)return;let p=!1;return u(!0),a(null),h(null),OUi(n).then(m=>{if(p)return;const _=Uint8Array.from(m.previewPng);a(m),c(URL.createObjectURL(new Blob([_.buffer],{type:"image/png"})))}).catch(m=>{p||h(m instanceof Error?m.message:String(m))}).finally(()=>{p||u(!1)}),()=>{p=!0}},[n,t,i]);const d=p=>{p||(r(""),a(null),c(null),h(null),u(!1)),e(p)};return K.jsx(KT,{open:t,onOpenChange:d,children:K.jsxs(VP,{className:"rf-max-h-[90vh] rf-max-w-3xl rf-overflow-y-auto",children:[K.jsxs(zP,{children:[K.jsx(JP,{children:"Export Accessory"}),K.jsx(VT,{children:"Generate a printable accessory from the components in this circuit."})]}),K.jsxs("div",{className:"rf-grid rf-gap-5 md:rf-grid-cols-[220px_1fr]",children:[K.jsxs("div",{className:"rf-space-y-2",children:[K.jsx("label",{htmlFor:"accessory-select",className:"rf-text-sm rf-font-medium",children:"Accessory"}),K.jsxs(Czi,{value:i,onValueChange:p=>r(p),children:[K.jsx(Xmn,{id:"accessory-select",children:K.jsx(yzi,{placeholder:"Choose an accessory"})}),K.jsx(t_n,{children:K.jsx(n_n,{value:o_n,children:"Component Box"})})]}),K.jsx("p",{className:"rf-text-xs rf-leading-relaxed rf-text-zinc-500",children:"Creates grouped compartments with raised refdes labels as a multi-material 3MF."})]}),K.jsxs("div",{className:"rf-overflow-hidden rf-rounded-lg rf-border rf-border-zinc-200 rf-bg-zinc-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-900",children:[K.jsxs("div",{className:"rf-flex rf-min-h-56 rf-items-center rf-justify-center",children:[!i&&K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-center rf-text-zinc-500",children:[K.jsx(Bbi,{className:"rf-h-10 rf-w-10 rf-stroke-1"}),K.jsx("p",{className:"rf-text-sm",children:"Choose an accessory to generate its preview."})]}),l&&K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-zinc-600 dark:rf-text-zinc-300",children:[K.jsx(SE,{className:"rf-h-8 rf-w-8 rf-animate-spin"}),K.jsx("p",{className:"rf-text-sm",children:"Generating component box…"})]}),g&&!l&&K.jsxs("div",{className:"rf-p-8 rf-text-center",children:[K.jsx("p",{className:"rf-text-sm rf-font-medium rf-text-red-600",children:"Could not generate the preview"}),K.jsx("p",{className:"rf-mt-1 rf-text-xs rf-text-red-500",children:g})]}),A&&s&&!l&&K.jsx("img",{src:A,alt:"Generated component box preview",className:"rf-block rf-h-auto rf-max-h-[300px] rf-w-full rf-object-contain"})]}),s&&!l&&K.jsxs("div",{className:"rf-flex rf-flex-wrap rf-gap-x-5 rf-gap-y-1 rf-border-t rf-border-zinc-200 rf-bg-white rf-px-4 rf-py-3 rf-text-xs rf-text-zinc-600 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-300",children:[K.jsxs("span",{children:[s.compartments.length," compartments"]}),K.jsxs("span",{children:[Mqe(s.dimensions.width)," ×"," ",Mqe(s.dimensions.depth)," ×"," ",Mqe(s.dimensions.height)]})]})]})]}),K.jsxs(jU,{children:[K.jsx(fA,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),K.jsxs(fA,{disabled:!s||l,onClick:()=>{s&&$pn({generatedBox:s,projectName:o})},children:[K.jsx(mZ,{}),"Download 3MF"]})]})]})})}const Yfe=t=>{const e=pfe(ye=>ye.lastRunEvalVersion),n=md(ye=>ye.currentMainComponentPath),[o,i]=ee.useState(null),[r,s]=ee.useState(!1),[a,A]=ee.useState(!0),[c,l]=ee.useState(!1),[u,g]=ee.useState(null),[h,d]=ee.useState(null),[p,m]=ee.useState(!1),[_,f]=ee.useState(null),[I,C]=ee.useState(null),[y,x]=ee.useState(!1),[E,B]=ee.useState(!1),[S,Q]=ee.useState(!1),[w,M]=ee.useState(!1),[k,R]=ee.useState(null),F=SVi(),O=md(ye=>ye.pushEvent),U=md(ye=>ye.recentEvents),Y=ee.useMemo(()=>Date.now(),[]);GGi(ye=>{if(!(new Date(ye.created_at).valueOf()<Y+500)){if(ye.event_type==="FILE_UPDATED"){s(!0);return}if(ye.event_type==="SNIPPET_SAVED"){s(!1),A(!1),f("Snippet saved successfully."),x(!1);return}ye.event_type==="REQUEST_EXPORT"&&(B(!0),f("Export processing..."),x(!1)),ye.event_type==="EXPORT_CREATED"&&(f(`Export created: ${ye.exportFilePath}`),x(!1),B(!1))}}),ee.useEffect(()=>{if(!c||u===null)return;const ye=U.filter(he=>new Date(he.created_at).valueOf()>u),Me=ye.find(he=>he.event_type==="FAILED_TO_SAVE_SNIPPET"),ve=ye.find(he=>he.event_type==="SNIPPET_SAVED");Me&&(l(!1),g(null),C(Me.message??"Failed to save snippet. See console for error."),console.error(Me.message),x(!0),Me.error_code==="SNIPPET_UNSET"&&Me.available_snippet_names&&(d(Me.available_snippet_names),m(!0))),ve&&(l(!1),g(null),f("Snippet saved successfully."),x(!1))},[U,c]);const W=async()=>{l(!0),g(Date.now()),f(null),x(!1),await O({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:o})},j=md(ye=>ye.circuitJson)??t.circuitJson,J=ee.useMemo(()=>{let ye="Untitled";if(n){const Me=n.split("/").pop();Me&&(ye=Me.replace(/\.[^.]+$/,""))}return(t.projectName??o??ye).replace(/\.(board|circuit)$/,"")},[n,t.projectName,o]),[oe,ie]=ee.useState(!1),[ne,le]=ee.useState(!1),{BugReportDialog:ge,openBugReportDialog:_e}=wVi({onLoginRequired:t.onLoginRequired}),ue=async ye=>{k&&(await qpn({circuitJson:k.circuitJson,projectName:k.projectName,options:ye}),R(null))},fe=ee.useMemo(()=>RVi(t.autoroutingLog),[t.autoroutingLog]),pe=ye=>{if(!j){ua.error("No Circuit JSON to export");return}const Me=fe?.value.simpleRouteJson;if(ye==="LightBurn"){R({circuitJson:j,projectName:J}),Q(!0);return}qUi({exportName:ye,circuitJson:j,simpleRouteJson:Me,projectName:J})};return K.jsxs(K.Fragment,{children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[K.jsxs(o_e,{children:[K.jsx(i_e,{asChild:!0,children:K.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),K.jsxs(vZ,{className:"rf-z-[101]",children:[!t.isWebEmbedded&&K.jsxs(K.Fragment,{children:[K.jsx(bp,{className:"rf-text-xs",onSelect:W,disabled:c,children:c?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&K.jsx(bp,{className:"rf-text-xs",onSelect:()=>{F.open()},children:"Order"}),K.jsx(bp,{className:"rf-text-xs",onSelect:()=>ie(!0),disabled:c,children:"Import"}),K.jsx(bp,{className:"rf-text-xs",onSelect:()=>{if(!zge()){ua.error("Requires tscircuit token");return}le(!0)},children:"AI Review"})]}),!t.isWebEmbedded&&t.onLoginRequired&&K.jsx(bp,{className:"rf-text-xs",onSelect:()=>{t.onLoginRequired?.()},children:"Sign In"}),!t.isWebEmbedded&&K.jsxs(QZ,{children:[K.jsx(BU,{className:"rf-text-xs",children:"Report Bug"}),K.jsx(SZ,{children:K.jsxs(bU,{children:[K.jsx(bp,{className:"rf-text-xs",onSelect:()=>{_e()},children:"Report Entire Circuit"}),K.jsx(bp,{className:"rf-text-xs",disabled:!fe||!t.onReportAutoroutingLog,onSelect:()=>{!fe||!t.onReportAutoroutingLog||t.onReportAutoroutingLog(fe.key,{simpleRouteJson:fe.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),K.jsxs(QZ,{children:[K.jsx(BU,{className:"rf-text-xs",disabled:E,children:E?"Exporting...":"Export"}),K.jsx(SZ,{children:K.jsx(bU,{children:$Ui.map((ye,Me)=>K.jsx(bp,{onSelect:()=>pe(ye.name),disabled:E||ye.name==="Simple Route JSON"&&!fe,children:K.jsx("span",{className:"rf-text-xs",children:ye.name})},Me))})})]}),K.jsx(bp,{className:"rf-text-xs",disabled:E,onSelect:()=>{if(!j){ua.error("No Circuit JSON to export");return}M(!0)},children:"Export Accessory…"}),!t.isWebEmbedded&&K.jsxs(QZ,{children:[K.jsx(BU,{className:"rf-text-xs",children:"Advanced"}),K.jsx(SZ,{children:K.jsxs(bU,{children:[K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(Iee,{id:"load-latest-eval",checked:t.shouldLoadLatestEval,onCheckedChange:ye=>{t.onChangeShouldLoadLatestEval?.(ye===!0)}}),K.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),e&&K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",children:K.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:K.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",e]})})}),K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",children:K.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:K.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",LGi.version]})})}),K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:K.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:K.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),K.jsx(Epn,{open:y,onOpenChange:x,children:K.jsxs(k$e,{children:[K.jsxs(F$e,{children:[K.jsx(H$e,{children:"Error Saving Snippet"}),K.jsx(O$e,{children:I})]}),K.jsx(L$e,{children:K.jsx(G$e,{onClick:()=>x(!1),children:"Dismiss"})})]})}),K.jsx(OGi,{snippetNames:h??[],onSelect:async ye=>{l(!0),g(Date.now()),i(ye),await O({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:ye}),m(!1)},onCancel:()=>m(!1),isOpen:p})]}),K.jsxs(o_e,{children:[K.jsx(i_e,{asChild:!0,children:K.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),K.jsx(vZ,{className:"rf-z-[101]",children:K.jsxs(QZ,{children:[K.jsx(BU,{className:"rf-text-xs",children:"Schematic"}),K.jsx(SZ,{children:K.jsxs(bU,{children:[K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",onSelect:ye=>ye.preventDefault(),children:K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(Iee,{id:"show-schematic-ports",checked:t.showSchematicPorts,onCheckedChange:ye=>{t.onChangeShowSchematicPorts?.(ye===!0)}}),K.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),K.jsx(bp,{className:"rf-flex rf-items-center rf-gap-2",onSelect:ye=>ye.preventDefault(),children:K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(Iee,{id:"show-schematic-grid",checked:t.showSchematicDebugGrid,onCheckedChange:ye=>{t.onChangeShowSchematicDebugGrid?.(ye===!0)}}),K.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),ge,K.jsx(PVi,{open:S,onOpenChange:Q,onExport:ue}),j&&K.jsx(Bzi,{open:w,onOpenChange:M,circuitJson:j,projectName:J}),K.jsx(Wpn,{isOpen:oe,onClose:()=>ie(!1)}),K.jsx(kKi,{isOpen:ne,onClose:()=>le(!1),packageName:o}),K.jsx(ein,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),K.jsx(F.OrderDialog,{isOpen:F.isOpen,onClose:F.close,stage:F.stage,setStage:F.setStage})]})};var bzi=Object.defineProperty,CI=(t,e)=>bzi(t,"name",{value:e,configurable:!0}),[Dqe,Lmr]=Nx("Tooltip",[PP]),Nqe=PP(),Szi="TooltipProvider",Qzi=700,Rqe="tooltip.open",[vzi,Tqe]=Dqe(Szi),wzi=CI(t=>{const{__scopeTooltip:e,delayDuration:n=Qzi,skipDelayDuration:o=300,disableHoverableContent:i=!1,children:r}=t,s=ee.useRef(!0),a=ee.useRef(!1),A=ee.useRef(0);return ee.useEffect(()=>{const c=A.current;return()=>window.clearTimeout(c)},[]),K.jsx(vzi,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:ee.useCallback(()=>{o<=0||(window.clearTimeout(A.current),s.current=!1)},[o]),onClose:ee.useCallback(()=>{o<=0||(window.clearTimeout(A.current),A.current=window.setTimeout(()=>s.current=!0,o))},[o]),isPointerInTransitRef:a,onPointerInTransitChange:ee.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:r})},"TooltipProvider"),kqe="Tooltip",[Pzi,Ufe]=Dqe(kqe),Mzi=CI(t=>{const{__scopeTooltip:e,children:n,open:o,defaultOpen:i,onOpenChange:r,disableHoverableContent:s,delayDuration:a}=t,A=Tqe(kqe,t.__scopeTooltip),c=Nqe(e),[l,u]=ee.useState(null),[g,h]=ee.useState(void 0),d=t_(),p=ee.useRef(0),m=s??A.disableHoverableContent,_=a??A.delayDuration,f=ee.useRef(!1),[I,C]=DB({prop:o,defaultProp:i??!1,onChange:CI(Q=>{Q?(A.onOpen(),document.dispatchEvent(new CustomEvent(Rqe))):A.onClose(),r?.(Q)},"onChange"),caller:kqe}),y=ee.useMemo(()=>I?f.current?"delayed-open":"instant-open":"closed",[I]),x=ee.useCallback(()=>{window.clearTimeout(p.current),p.current=0,f.current=!1,C(!0)},[C]),E=ee.useCallback(()=>{window.clearTimeout(p.current),p.current=0,C(!1)},[C]),B=ee.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{f.current=!0,C(!0),p.current=0},_)},[_,C]);ee.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]);const S=g??d;return K.jsx(CZ,{...c,children:K.jsx(Pzi,{scope:e,contentId:S,setContentId:h,open:I,stateAttribute:y,trigger:l,onTriggerChange:u,onTriggerEnter:ee.useCallback(()=>{A.isOpenDelayedRef.current?B():x()},[A.isOpenDelayedRef,B,x]),onTriggerLeave:ee.useCallback(()=>{m?E():(window.clearTimeout(p.current),p.current=0)},[E,m]),onOpen:x,onClose:E,disableHoverableContent:m,children:n})})},"Tooltip"),i_n="TooltipTrigger",Dzi=ee.forwardRef(CI(function(e,n){const{__scopeTooltip:o,...i}=e,r=Ufe(i_n,o),s=Tqe(i_n,o),a=Nqe(o),A=ee.useRef(null),c=$A(n,A,r.onTriggerChange),l=ee.useRef(!1),u=ee.useRef(!1),g=ee.useCallback(()=>l.current=!1,[]);return ee.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),K.jsx(Hme,{asChild:!0,...a,children:K.jsx(Na.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...i,ref:c,onPointerMove:ar(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:ar(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:ar(e.onPointerDown,()=>{r.open&&r.onClose(),l.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:ar(e.onFocus,()=>{l.current||r.onOpen()}),onBlur:ar(e.onBlur,r.onClose),onClick:ar(e.onClick,r.onClose)})})},"TooltipTrigger")),Nzi="TooltipPortal",[Hmr,Rzi]=Dqe(Nzi,{forceMount:void 0}),wee="TooltipContent",Tzi=ee.forwardRef(CI(function(e,n){const o=Rzi(wee,e.__scopeTooltip),{forceMount:i=o.forceMount,side:r="top",...s}=e,a=Ufe(wee,e.__scopeTooltip);return K.jsx(uE,{present:i||a.open,children:a.disableHoverableContent?K.jsx(r_n,{side:r,...s,ref:n}):K.jsx(kzi,{side:r,...s,ref:n})})},"TooltipContent")),kzi=ee.forwardRef(CI(function(e,n){const o=Ufe(wee,e.__scopeTooltip),i=Tqe(wee,e.__scopeTooltip),r=ee.useRef(null),s=$A(n,r),[a,A]=ee.useState(null),{trigger:c,onClose:l}=o,u=r.current,{onPointerInTransitChange:g}=i,h=ee.useCallback(()=>{A(null),g(!1)},[g]),d=ee.useCallback((p,m)=>{const _=p.currentTarget,f={x:p.clientX,y:p.clientY},I=s_n(f,_.getBoundingClientRect()),C=a_n(f,I),y=A_n(m.getBoundingClientRect()),x=l_n([...C,...y]);A(x),g(!0)},[g]);return ee.useEffect(()=>()=>h(),[h]),ee.useEffect(()=>{if(c&&u){const p=CI(_=>d(_,u),"handleTriggerLeave"),m=CI(_=>d(_,c),"handleContentLeave");return c.addEventListener("pointerleave",p),u.addEventListener("pointerleave",m),()=>{c.removeEventListener("pointerleave",p),u.removeEventListener("pointerleave",m)}}},[c,u,d,h]),ee.useEffect(()=>{if(a){const p=CI(m=>{const _=m.target,f={x:m.clientX,y:m.clientY},I=c?.contains(_)||u?.contains(_),C=!c_n(f,a);I?h():C&&(h(),l())},"handleTrackPointerGrace");return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[c,u,a,l,h]),K.jsx(r_n,{...e,ref:s})},"TooltipContentHoverable")),Fzi=EFt("TooltipContent"),r_n=ee.forwardRef(CI(function(e,n){const{__scopeTooltip:o,children:i,"aria-label":r,id:s,onEscapeKeyDown:a,onPointerDownOutside:A,...c}=e,l=Ufe(wee,o),u=Nqe(o),{onClose:g}=l;ee.useEffect(()=>(document.addEventListener(Rqe,g),()=>document.removeEventListener(Rqe,g)),[g]),ee.useEffect(()=>{if(l.trigger){const d=CI(p=>{p.target instanceof Node&&p.target.contains(l.trigger)&&g()},"handleScroll");return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,g]);const{setContentId:h}=l;return Ep(()=>(h(s),()=>{h(void 0)}),[s,h]),K.jsx(_Z,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:A,onFocusOutside:d=>d.preventDefault(),onDismiss:g,children:K.jsxs(Ome,{"data-state":l.stateAttribute,role:r?void 0:"tooltip",id:r?void 0:l.contentId,...u,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[K.jsx(Fzi,{children:i}),r?K.jsx(YVi,{id:l.contentId,role:"tooltip",children:r}):null]})})},"TooltipContentImpl"));function s_n(t,e){const n=Math.abs(e.top-t.y),o=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),r=Math.abs(e.left-t.x);switch(Math.min(n,o,i,r)){case r:return"left";case i:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}CI(s_n,"getExitSideFromRect");function a_n(t,e,n=5){const o=[];switch(e){case"top":o.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":o.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":o.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":o.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return o}CI(a_n,"getPaddedExitPoints");function A_n(t){const{top:e,right:n,bottom:o,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:o},{x:i,y:o}]}CI(A_n,"getPointsFromRect");function c_n(t,e){const{x:n,y:o}=t;let i=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){const a=e[r],A=e[s],c=a.x,l=a.y,u=A.x,g=A.y;l>o!=g>o&&n<(u-c)*(o-l)/(g-l)+c&&(i=!i)}return i}CI(c_n,"isPointInPolygon");function l_n(t){const e=t.slice();return e.sort((n,o)=>n.x<o.x?-1:n.x>o.x?1:n.y<o.y?-1:n.y>o.y?1:0),u_n(e)}CI(l_n,"getHull");function u_n(t){if(t.length<=1)return t.slice();const e=[];for(let o=0;o<t.length;o++){const i=t[o];for(;e.length>=2;){const r=e[e.length-1],s=e[e.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let o=t.length-1;o>=0;o--){const i=t[o];for(;n.length>=2;){const r=n[n.length-1],s=n[n.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}CI(u_n,"getHullPresorted");var Lzi=wzi,Hzi=Mzi,Ozi=Dzi,g_n=Tzi;const Fqe=Lzi,Lqe=Hzi,Hqe=Ozi,Kfe=ee.forwardRef(({className:t,sideOffset:e=4,...n},o)=>K.jsx(g_n,{ref:o,sideOffset:e,className:Oi("z-50 overflow-hidden rounded-md bg-slate-900 px-3 py-1.5 text-xs text-slate-50 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-slate-50 dark:text-slate-900",t),...n}));Kfe.displayName=g_n.displayName;const Gzi="24b58135-86c7-4e4b-bf6e-cca862bc4b26",d_n="runframe-crisp-chat-script",Yzi="tscircuit.com",Pee=t=>{window.$crisp=window.$crisp||[],window.$crisp.push(t)},Uzi=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=Gzi,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,Pee(["do","chat:hide"]),Pee(["on","chat:closed",()=>Pee(["do","chat:hide"])])),!document.getElementById(d_n)){const t=document.createElement("script");t.id=d_n,t.src="https://client.crisp.chat/l.js",t.async=!0,document.head.appendChild(t)}},Kzi=()=>{Uzi(),Pee(["do","chat:show"]),Pee(["do","chat:open"])},Vzi=({isCli:t,hostname:e=typeof window<"u"?window.location.hostname:void 0}={})=>e?.toLowerCase()===Yzi?!1:!!t,zzi=()=>K.jsx(Fqe,{children:K.jsxs(Lqe,{children:[K.jsx(Hqe,{asChild:!0,children:K.jsx(fA,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:Kzi,className:"rf-h-8 rf-w-8",children:K.jsx(xbi,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),K.jsx(Kfe,{side:"bottom",children:"Get Support or Give Feedback"})]})}),Jzi=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","autorouting","solvers"],Oqe=t=>t instanceof Error?t.message:"An unknown error occurred",h_n=({code:t,fsMap:e,onRunClicked:n=void 0,errorMessage:o,errorStack:i,circuitJson:r,autoroutingGraphics:s,showRightHeaderContent:a=!0,showCodeTab:A=!1,codeTabContent:c,showJsonTab:l=!0,showRenderLogTab:u=!0,onActiveTabChange:g,renderLog:h,showImportAndFormatButtons:d=!0,className:p,headerClassName:m,leftHeaderContent:_,readOnly:f,isStreaming:I,autoroutingLog:C,onReportAutoroutingLog:y,isRunningCode:x,hasCodeChangedSinceLastRun:E,onEditEvent:B,editEvents:S,defaultActiveTab:Q,defaultTab:w,availableTabs:M,autoRotate3dViewerDisabled:k,showSchematicDebugGrid:R=!1,showSchematicPorts:F=!1,onChangeShowSchematicDebugGrid:O,onChangeShowSchematicPorts:U,showToggleFullScreen:Y=!0,defaultToFullScreen:W=!1,activeEffectName:te,allowSelectingVersion:j=!0,showFileMenu:J=!1,isWebEmbedded:oe=!1,isCli:ie=!1,projectName:ne,schematicSvgOptions:le,hideSchematicInAnalogSimulation:ge=!1,onRerunWithDebug:_e,solverEvents:ue,autoroutingPhases:fe,onPcbBoundsSelected:pe})=>{mee();const{versions:ye,latestVersion:Me,lastRunEvalVersion:ve,search:he,setSearch:Qe,selectVersion:Pe}=HGi(j),we=ee.useMemo(()=>r?r.filter(Ze=>Ze&&"error_type"in Ze||Ze.type.includes("error")):null,[r]),Te=ee.useMemo(()=>r?r.filter(Ze=>Ze&&"warning_type"in Ze||Ze.type.includes("warning")):null,[r]),Re=ee.useMemo(()=>r?r.some(Ze=>Ze.type==="schematic_group"):!0,[r]),Ee=ee.useMemo(()=>r?.some(Ze=>Ze.type==="pcb_panel"),[r]),ke=(!M||M.includes("schematic"))&&Re&&!Ee,{controller:Ce,focusSchematicComponent:Le}=ANi(),Ye=ke?({source_component_id:Ze})=>{const dt=r?.find(Ut=>Ut.type==="schematic_component"&&Ut.source_component_id===Ze);dt?.type==="schematic_component"&&(Le(dt.schematic_component_id),st("schematic"))}:void 0,tt=ee.useMemo(()=>!r||!x||we?.length?!1:r.some(dt=>dt.type==="simulation_experiment")&&!ojo(r),[r,we,x]),At=ee.useMemo(()=>we?.find(Ze=>Ze.type.startsWith("simulation_")),[we]);hpn({errorMessage:o,errorStack:i,circuitJsonErrors:we});const at=w??M?.[0]??"pcb",[nt,gt]=OO("runframe-active-tab",Q??at,Q);ppn({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:oe,activeTab:nt});const[bt,Ct]=ee.useState(null),[Dt,kt]=ee.useState(W),[it,Yt]=ee.useState(R),[pn,be]=ee.useState(F),et=O?R:it,It=U?F:pn,Bt=O??Yt,mt=U??be;oOi(Dt);const st=ee.useCallback(Ze=>{gt(Ze),g?.(Ze)},[g,gt]),xt=()=>{kt(!Dt)};ee.useEffect(()=>{o&&(nt!=="errors"&&Ct(nt),st("errors"))},[o]),ee.useEffect(()=>{(nt==="code"||nt==="errors")&&r&&!o&&st(bt??Q??w??M?.[0]??"pcb")},[r]);const Xe=ee.useCallback(Ze=>{window.TSCIRCUIT_3D_OBJECT_REF=Ze===null?void 0:Ze},[]);return K.jsx("div",{className:Oi("flex flex-col relative rf-overflow-x-hidden rf-h-full",p),children:K.jsx("div",{className:Oi("rf-md:sticky rf-md:top-2 rf-h-full",Dt&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:K.jsxs(dRe,{value:nt,onValueChange:st,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[K.jsxs("div",{className:Oi("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",m),children:[_,J&&!_&&K.jsx(Yfe,{isWebEmbedded:oe,circuitJson:r,projectName:ne,autoroutingLog:C,onReportAutoroutingLog:y,showSchematicDebugGrid:et,onChangeShowSchematicDebugGrid:Bt,showSchematicPorts:It,onChangeShowSchematicPorts:mt}),(_||J)&&K.jsx("div",{className:"rf-flex-grow"}),!_&&!J&&x&&K.jsx(SE,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!_&&!J&&K.jsx("div",{className:"rf-flex-grow"}),h&&h.progress!==1&&!o&&K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-max-w-xs",children:[te?K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:te,children:te}):h.lastRenderEvent&&K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:h.lastRenderEvent?.phase??"",children:h.lastRenderEvent?.phase??""}),K.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white rf-flex-shrink-0",children:K.jsx(SE,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),K.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0",children:[((h.progress??0)*100).toFixed(1),"%"]})]}),a&&Vzi({isCli:ie})&&K.jsx(zzi,{}),a&&K.jsxs(Jge,{children:[A&&K.jsx(p6,{value:"code",children:"Code"}),!M||M.includes("pcb")?K.jsxs(p6,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&K.jsx("span",{className:Oi("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",E?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!M||M.includes("schematic")?K.jsxs(p6,{value:"schematic",className:Oi("rf-whitespace-nowrap",r&&!Re&&"rf-opacity-50"),disabled:r?!Re||Ee:!1,children:[r&&K.jsx("span",{className:Oi("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",E?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!M||M.includes("cad")?K.jsxs(p6,{value:"cad",children:[r&&K.jsx("span",{className:Oi("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",E?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(nt)&&K.jsx(p6,{value:nt,children:xYt(nt)}),K.jsxs(o_e,{children:[K.jsx(i_e,{asChild:!0,children:K.jsxs("button",{type:"button","aria-label":"More views",className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[K.jsx(dbi,{className:"rf-w-4 rf-h-4"}),(we&&we.length>0||o)&&K.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),K.jsxs(vZ,{className:"rf-*:text-xs rf-z-[101]",children:[Jzi.filter(Ze=>!M||M.includes(Ze)).map(Ze=>K.jsxs(bp,{onSelect:()=>st(Ze),children:[nt!==Ze&&K.jsx(pln,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),nt===Ze&&K.jsx(CS,{className:"rf-w-3 rf-h-3"}),K.jsx("div",{className:"rf-pr-2",children:xYt(Ze)}),Ze==="errors"&&(we&&we.length>0||o)&&K.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:o?1:we?.length}),Ze==="solvers"&&ue&&ue.length>0&&K.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-min-w-[12px] rf-h-3 rf-px-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-blue-500 rf-rounded-full",children:ue.length})]},Ze)),K.jsx(bp,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:K.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",mpn.split(".").map((Ze,dt)=>dt===2?parseInt(Ze)+1:Ze).join(".")]})}),j?K.jsxs(QZ,{onOpenChange:Ze=>!Ze&&Qe(""),children:[K.jsx(BU,{className:"rf-text-xs rf-opacity-60",children:K.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",ve??Me??"latest"]})}),K.jsx(SZ,{children:K.jsxs(bU,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[K.jsx("div",{className:"rf-p-1",children:K.jsx(yje,{value:he,onChange:Ze=>Qe(Ze.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),K.jsx(H0n,{}),K.jsx(bp,{onSelect:()=>Pe(null),children:Me?`${Me} (latest)`:"latest"}),ye.map(Ze=>K.jsx(bp,{onSelect:()=>Pe(Ze),children:Ze},Ze))]})})]}):ve&&K.jsx(bp,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:K.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",ve]})})]})]})]}),Y&&K.jsx(fA,{onClick:xt,variant:"ghost",children:Dt?K.jsx(Ebi,{size:16}):K.jsx(fbi,{size:16})})]}),A&&K.jsx(cI,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:K.jsx("div",{className:"rf-h-full",children:c})}),(!M||M.includes("pcb"))&&K.jsx(cI,{value:"pcb",children:K.jsx("div",{className:Oi("rf-overflow-hidden",Dt?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:K.jsx(bE,{fallbackRender:({error:Ze})=>K.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),K.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:Oqe(Ze)})]})}),children:r?K.jsx(tOi,{focusOnHover:!1,circuitJson:r,debugGraphics:s,onBoundsSelected:pe,onViewSchematicComponent:Ye,containerClassName:Oi("rf-h-full rf-w-full",Dt?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:Ze=>{if(B)for(const dt of Ze)B(dt)}}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("assembly"))&&K.jsx(cI,{value:"assembly",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{children:"Error loading Assembly"}),children:r?K.jsx(cNi,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("pinout"))&&K.jsx(cI,{value:"pinout",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{children:"Error loading Pinout Viewer"}),children:r?K.jsx(lNi,{circuitJson:r,containerStyle:{height:"100%"}}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("schematic"))&&K.jsx(cI,{value:"schematic",children:K.jsx("div",{className:Oi("rf-overflow-auto rf-bg-white",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallbackRender:({error:Ze})=>K.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),K.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:Oqe(Ze)})]})}),children:r?K.jsx(zDi,{controller:Ce,circuitJson:r,containerStyle:{height:"100%"},debugGrid:et,showSchematicPorts:It,css:le?.css,className:le?.className}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("cad"))&&K.jsx(cI,{value:"cad",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallbackRender:({error:Ze,resetErrorBoundary:dt})=>K.jsx(J8i,{error:Ze,resetErrorBoundary:dt}),children:r?K.jsx(V8i,{ref:Xe,circuitJson:r,autoRotateDisabled:k,onViewSchematicComponent:Ye},`cad-${Dt}`):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("analog_simulation"))&&K.jsx(cI,{value:"analog_simulation",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{children:"Error loading Analog Simulation"}),children:r?At?K.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),K.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:At.message})]})}):tt?K.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[K.jsx(SE,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):K.jsx(aNi,{circuitJson:r,hideSchematic:ge,containerStyle:{height:"100%"}}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("bom"))&&K.jsx(cI,{value:"bom",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallbackRender:({error:Ze})=>K.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),K.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:Oqe(Ze)})]})}),children:r?K.jsx(SNi,{circuitJson:r}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("circuit_json"))&&K.jsx(cI,{value:"circuit_json",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full  rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{children:"Error loading JSON viewer"}),children:r?K.jsx(dNi,{elements:r}):K.jsx(QS,{onRunClicked:n})})})}),(!M||M.includes("errors"))&&K.jsx(cI,{value:"errors",className:"rf-h-full",children:K.jsx("div",{className:Oi("rf-overflow-hidden",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:o||we&&we.length>0||r?K.jsx(ewi,{code:t,fsMap:e,circuitJsonErrors:we,circuitJsonWarnings:Te,errorMessage:o,errorStack:i,circuitJson:r,evalVersion:ve,autoroutingLog:C,onReportAutoroutingLog:y}):K.jsx(QS,{onRunClicked:n})})}),u&&(!M||M.includes("render_log"))&&K.jsx(cI,{value:"render_log",children:K.jsx(sOi,{renderLog:h,onRerunWithDebug:_e})}),(!M||M.includes("autorouting"))&&K.jsx(cI,{value:"autorouting",children:K.jsx("div",{className:Oi("rf-overflow-auto",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{className:"rf-p-4",children:"Error loading autorouting captures"}),children:K.jsx(FGi,{circuitJson:r,phases:fe,isRunning:x})})})}),(!M||M.includes("solvers"))&&K.jsx(cI,{value:"solvers",children:K.jsx("div",{className:Oi("rf-overflow-hidden",Dt?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:K.jsx(bE,{fallback:K.jsx("div",{children:"Error loading Solvers view"}),children:K.jsx(yGi,{solverEvents:ue})})})})]})})})};const p_n=Symbol("Comlink.proxy"),Wzi=Symbol("Comlink.endpoint"),m_n=Symbol("Comlink.releaseProxy"),Gqe=Symbol("Comlink.finalizer"),Vfe=Symbol("Comlink.thrown"),__n=t=>typeof t=="object"&&t!==null||typeof t=="function",jzi={canHandle:t=>__n(t)&&t[p_n],serialize(t){const{port1:e,port2:n}=new MessageChannel;return I_n(t,e),[n,[n]]},deserialize(t){return t.start(),y_n(t)}},$zi={canHandle:t=>__n(t)&&Vfe in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},f_n=new Map([["proxy",jzi],["throw",$zi]]);function qzi(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function I_n(t,e=globalThis,n=["*"]){e.addEventListener("message",function o(i){if(!i||!i.data)return;if(!qzi(n,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}const{id:r,type:s,path:a}=Object.assign({path:[]},i.data),A=(i.data.argumentList||[]).map(XT);let c;try{const l=a.slice(0,-1).reduce((g,h)=>g[h],t),u=a.reduce((g,h)=>g[h],t);switch(s){case"GET":c=u;break;case"SET":l[a.slice(-1)[0]]=XT(i.data.value),c=!0;break;case"APPLY":c=u.apply(l,A);break;case"CONSTRUCT":{const g=new u(...A);c=Uqe(g)}break;case"ENDPOINT":{const{port1:g,port2:h}=new MessageChannel;I_n(t,h),c=nJi(g,[g])}break;case"RELEASE":c=void 0;break;default:return}}catch(l){c={value:l,[Vfe]:0}}Promise.resolve(c).catch(l=>({value:l,[Vfe]:0})).then(l=>{const[u,g]=jfe(l);e.postMessage(Object.assign(Object.assign({},u),{id:r}),g),s==="RELEASE"&&(e.removeEventListener("message",o),C_n(e),Gqe in t&&typeof t[Gqe]=="function"&&t[Gqe]())}).catch(l=>{const[u,g]=jfe({value:new TypeError("Unserializable return value"),[Vfe]:0});e.postMessage(Object.assign(Object.assign({},u),{id:r}),g)})}),e.start&&e.start()}function Xzi(t){return t.constructor.name==="MessagePort"}function C_n(t){Xzi(t)&&t.close()}function y_n(t,e){const n=new Map;return t.addEventListener("message",function(i){const{data:r}=i;if(!r||!r.id)return;const s=n.get(r.id);if(s)try{s(r)}finally{n.delete(r.id)}}),Yqe(t,n,[],e)}function zfe(t){if(t)throw new Error("Proxy has been released and is not useable")}function x_n(t){return XU(t,new Map,{type:"RELEASE"}).then(()=>{C_n(t)})}const Jfe=new WeakMap,Wfe="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(Jfe.get(t)||0)-1;Jfe.set(t,e),e===0&&x_n(t)});function Zzi(t,e){const n=(Jfe.get(e)||0)+1;Jfe.set(e,n),Wfe&&Wfe.register(t,e,t)}function eJi(t){Wfe&&Wfe.unregister(t)}function Yqe(t,e,n=[],o=function(){}){let i=!1;const r=new Proxy(o,{get(s,a){if(zfe(i),a===m_n)return()=>{eJi(r),x_n(t),e.clear(),i=!0};if(a==="then"){if(n.length===0)return{then:()=>r};const A=XU(t,e,{type:"GET",path:n.map(c=>c.toString())}).then(XT);return A.then.bind(A)}return Yqe(t,e,[...n,a])},set(s,a,A){zfe(i);const[c,l]=jfe(A);return XU(t,e,{type:"SET",path:[...n,a].map(u=>u.toString()),value:c},l).then(XT)},apply(s,a,A){zfe(i);const c=n[n.length-1];if(c===Wzi)return XU(t,e,{type:"ENDPOINT"}).then(XT);if(c==="bind")return Yqe(t,e,n.slice(0,-1));const[l,u]=E_n(A);return XU(t,e,{type:"APPLY",path:n.map(g=>g.toString()),argumentList:l},u).then(XT)},construct(s,a){zfe(i);const[A,c]=E_n(a);return XU(t,e,{type:"CONSTRUCT",path:n.map(l=>l.toString()),argumentList:A},c).then(XT)}});return Zzi(r,t),r}function tJi(t){return Array.prototype.concat.apply([],t)}function E_n(t){const e=t.map(jfe);return[e.map(n=>n[0]),tJi(e.map(n=>n[1]))]}const B_n=new WeakMap;function nJi(t,e){return B_n.set(t,e),t}function Uqe(t){return Object.assign(t,{[p_n]:!0})}function jfe(t){for(const[e,n]of f_n)if(n.canHandle(t)){const[o,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:o},i]}return[{type:"RAW",value:t},B_n.get(t)||[]]}function XT(t){switch(t.type){case"HANDLER":return f_n.get(t.name).deserialize(t.value);case"RAW":return t.value}}function XU(t,e,n,o){return new Promise(i=>{const r=oJi();e.set(r,i),t.start&&t.start(),t.postMessage(Object.assign({id:r},n),o)})}function oJi(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function Kqe(t,e=""){const n=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const i=t[o],r=e?`${e}.${o}`:o;if(i!==null&&typeof i=="object"&&!Array.isArray(i)){const s=Kqe(i,r);n.push(...s)}else n.push(r)}return n}function b_n(t,e){const n=e.split(".");let o=t;for(const i of n)o=o[i];return o}var iJi=(t="latest")=>[`https://jscdn.tscircuit.com/@tscircuit/eval/${t}/dist/webworker/entrypoint.js`,`https://cdn.jsdelivr.net/npm/@tscircuit/eval@${t}/dist/webworker/entrypoint.js`,`https://unpkg.com/@tscircuit/eval@${t}/dist/webworker/entrypoint.js`],rJi=async(t="latest",e=!1)=>{let n;for(const o of iJi(t))try{const i=await globalThis.fetch(o);if(!i.ok)throw new Error(`Failed to fetch webworker entrypoint from ${o}: ${i.status} ${i.statusText}`);return await i.blob()}catch(i){n=i,e&&console.warn(`[Worker] Failed to fetch webworker entrypoint from ${o}, trying next CDN fallback if available`,i)}throw n instanceof Error?n:new Error("Failed to fetch webworker entrypoint from CDN fallbacks")},S_n=async t=>{const e=globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER;if(e&&typeof e.kill=="function"){t.verbose&&console.log("[Worker] Killing previous global worker instance...");try{await e.kill()}catch(g){t.verbose&&console.warn("[Worker] Error killing previous global worker instance:",g),globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===e&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}}t.verbose&&console.log("[Worker] Creating circuit web worker with config:",t);let n=t.webWorkerBlobUrl??t.webWorkerUrl;if(!n){const g=await rJi(t.evalVersion??"latest",t.verbose);n=URL.createObjectURL(g)}const o=new Worker(n,{type:"module"});let i;o.addEventListener("error",g=>{console.error("[Worker] Error in worker",g),i=g}),o.addEventListener("unhandledrejection",g=>{console.error("[Worker] Unhandled rejection in worker",g)}),o.addEventListener("messageerror",g=>{console.error("[Worker] Message error in worker",g)});const r=g=>{console.log("[Worker] Message in worker",g)};if(o.addEventListener("message",r),o.addEventListener("message",async g=>{const h=g.data;if(h?.type==="worker_fetch")try{const d=await globalThis.fetch(h.input,h.init),p=await d.text();o.postMessage({type:"worker_fetch_result",requestId:h.requestId,success:!0,response:{body:p,status:d.status,statusText:d.statusText,headers:(()=>{const m={};return d.headers.forEach((_,f)=>{m[f]=_}),m})()}})}catch(d){o.postMessage({type:"worker_fetch_result",requestId:h.requestId,success:!1,error:{name:d.name,message:d.message,stack:d.stack}})}}),i)throw i;const s=y_n(o);o.removeEventListener("message",r);function a(g){return!g||typeof g!="object"?g:g.type&&g.props!==void 0?{__isSerializedReactElement:!0,type:g.type,props:A(g.props),key:g.key}:g}function A(g){if(!g||typeof g!="object")return g;const h={};for(const[d,p]of Object.entries(g))d==="children"?Array.isArray(p)?h.children=p.map(a):h.children=a(p):h[d]=p;return h}t.enableFetchProxy&&o.postMessage({type:"override_global_fetch"}),t.disableCdnLoading&&await s.setDisableCdnLoading(!0),t.snippetsApiBaseUrl&&await s.setSnippetsApiBaseUrl(t.snippetsApiBaseUrl),t.tscircuitSessionToken&&await s.setTscircuitSessionToken(t.tscircuitSessionToken),t.easyEdaProxyConfig&&await s.setEasyEdaProxyConfig(t.easyEdaProxyConfig);const c=g=>typeof g=="function"?Uqe(g):g;if(t.platform)for(const g of Kqe(t.platform))await s.setPlatformConfigProperty(g,c(b_n(t.platform,g))).catch(h=>{throw new Error(`Error setting platform config property ${g}: ${h instanceof Error?h.message:String(h)}`)});if(t.projectConfig)for(const g of Kqe(t.projectConfig))await s.setProjectConfigProperty(g,c(b_n(t.projectConfig,g))).catch(h=>{throw new Error(`Error setting project config property ${g}: ${h instanceof Error?h.message:String(h)}`)});let l=!1;const u={clearEventListeners:s.clearEventListeners.bind(s),enableDebug:async(...g)=>{if(l)throw new Error("CircuitWebWorker was terminated, can't enableDebug");return s.enableDebug.bind(s)(...g)},version:s.version.bind(s),execute:async(...g)=>{if(l)throw new Error("CircuitWebWorker was terminated, can't execute");return s.execute.bind(s)(...g)},executeComponent:async g=>{if(l)throw new Error("CircuitWebWorker was terminated, can't executeComponent");if(typeof g=="function")return s.executeComponent.bind(s)(g);if(g&&typeof g=="object"&&g.type){const h=a(g);return s.executeComponent.bind(s)(h)}return s.executeComponent.bind(s)(g)},executeWithFsMap:async(...g)=>{if(l)throw new Error("CircuitWebWorker was terminated, can't executeWithFsMap");return s.executeWithFsMap.bind(s)(...g)},renderUntilSettled:s.renderUntilSettled.bind(s),getCircuitJson:s.getCircuitJson.bind(s),on:(g,h)=>{const d=Uqe(h);s.on(g,d)},kill:async()=>{s[m_n](),o.terminate(),l=!0,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===u&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}};return u.__rawWorker=o,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=u,u};const sJi=({error:t,resetErrorBoundary:e,componentStack:n})=>{const o=t instanceof Error?t:new Error(String(t));return K.jsx("section",{className:"rf-h-full rf-w-full rf-grid rf-place-items-center",children:K.jsx("div",{className:"rf-min-h-full rf-flex rf-items-center rf-justify-center rf-px-4",children:K.jsxs("div",{className:"rf-max-w-lg rf-w-full rf-text-center",children:[K.jsxs("div",{className:"rf-mb-8",children:[K.jsx("div",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-20 rf-h-20 rf-bg-red-100 rf-rounded-full rf-mb-6",children:K.jsx(vbi,{className:"rf-w-10 rf-h-10 rf-text-red-600"})}),K.jsx("h1",{className:"rf-text-2xl rf-font-bold rf-text-gray-900 rf-mb-3",children:"Oops! Something went wrong"}),K.jsx("p",{className:"rf-text-gray-600 rf-mb-4",children:"RunFrame encountered an unexpected error."}),K.jsx("pre",{className:"rf-text-xs no-scrollbar rf-font-mono rf-text-left rf-whitespace-pre-wrap rf-text-red-600 rf-bg-red-50 rf-border rf-border-red-200 rf-p-3 rf-rounded-lg rf-mb-4 rf-overflow-auto rf-max-h-[120px]",children:o.message}),o.stack&&K.jsxs("details",{className:"rf-text-center rf-mb-6",children:[K.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View stack trace"}),K.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:o.stack})]}),n&&K.jsxs("details",{className:"rf-text-center rf-mb-6",children:[K.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View component stack"}),K.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:n})]})]}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-gap-2 rf-justify-center",children:[K.jsx(fA,{variant:"destructive",size:"lg",onClick:()=>window.location.reload(),children:"Refresh Dev Server"}),K.jsx(fA,{variant:"outline",size:"lg",onClick:e,children:"Try Again"})]})]})})})},Q_n=t=>{const e={};if(!t)return e;for(const o of rE)e[o]=0;const n=new Map;for(const o of t){const[,,i,r]=o.type.split(":");if(r==="start"){n.set(`${i}:${o.renderId}`,o);continue}if(r==="end"){const s=n.get(`${i}:${o.renderId}`);if(s){const a=o.createdAt-s.createdAt;e[i]=(e[i]||0)+a}}}return e},$fe=t=>{const e=t.toLowerCase(),n=e.split("/").pop();return e.endsWith(".circuit.json")||n==="circuit.json"},aJi=t=>t.endsWith(".tsx")||$fe(t)||t.endsWith(".jsx"),AJi=({mainComponentPath:t,fsMap:e})=>ee.useMemo(()=>{if(!(t!=null&&$fe(t)))return{isStaticCircuitJson:!1,circuitJson:null,error:null};const o=e.get(t);if(!o)return{isStaticCircuitJson:!0,circuitJson:null,error:`Circuit JSON file not found: ${t}`};try{return{isStaticCircuitJson:!0,circuitJson:JSON.parse(o),error:null}}catch(i){return{isStaticCircuitJson:!0,circuitJson:null,error:`Failed to parse circuit.json: ${i instanceof Error?i.message:String(i)}`}}},[t,e]),cJi=(t,e)=>{const n={};for(const[o,i]of t.entries()){const r=e.get(o);r!==i&&(n[o]={old:i,new:r})}for(const[o,i]of e.entries())t.has(o)||(n[o]={old:void 0,new:i});return n},lJi=({message:t="Loading files..."})=>K.jsxs("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4 rf-p-2 rf-border-b",children:[K.jsx("div",{className:"rf-w-20 rf-h-9 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded-md rf-animate-pulse"}),K.jsx("div",{className:"rf-flex rf-gap-6 rf-ml-auto",children:["PCB","Schematic","3D"].map((e,n)=>K.jsx("div",{className:"rf-h-6 rf-w-20 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded rf-animate-pulse"},n))})]}),K.jsx("div",{className:"rf-flex-1 rf-p-4",children:K.jsx("div",{className:"rf-w-full rf-h-full rf-rounded-lg rf-bg-gray-100 dark:rf-bg-gray-800 rf-animate-pulse rf-flex rf-items-center rf-justify-center",children:K.jsx("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4",children:K.jsx("div",{className:"rf-text-sm rf-text-gray-400 dark:rf-text-gray-500",children:t})})})})]}),v_n=({projectBaseUrl:t})=>({projectBaseUrl:t,enablePartOrientationAnalysis:!0}),uJi=t=>!t||typeof t!="object"?!1:!!("error_type"in t||typeof t.type=="string"&&t.type.includes("error")),gJi=t=>t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:typeof t=="string"?{message:t}:t&&typeof t=="object"?t:{message:String(t)},dJi=t=>Array.isArray(t)?t.filter(uJi):[],Vqe=({circuitJson:t,executionError:e})=>{const n=[];e&&n.push(gJi(e));const o=dJi(t);return n.push(...o),{hasExecutionError:!!e,...n.length>0?{errors:n}:{}}};function hJi(){const t=ee.useRef(Promise.resolve()),e=ee.useRef(!1),n=ee.useRef(null),o=ee.useCallback(async s=>{await t.current;const a={cancelled:!1};n.current=a;let A;const c=new Promise(l=>{A=l});try{return t.current=c,e.current=!0,await s()}catch(l){if(!a.cancelled)throw l}finally{e.current=!1,n.current=null,A()}},[]),i=ee.useCallback(()=>{n.current&&(n.current.cancelled=!0),t.current=Promise.resolve(),e.current=!1},[]),r=ee.useCallback(()=>e.current,[]);return{runWithMutex:o,isLocked:r,cancel:i}}const pJi=26,e3=vc("run-frame:RunFrame"),mJi=async()=>{try{const t=await fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval");if(t.ok)return(await t.json()).tags?.latest}catch(t){console.error("Failed to fetch latest eval version",t)}},w_n=async(t,e)=>{if(t)return t;if(e||!window.TSCIRCUIT_LATEST_EVAL_VERSION){const n=await mJi();if(n)return window.TSCIRCUIT_LATEST_EVAL_VERSION=n,n}return window.TSCIRCUIT_LATEST_EVAL_VERSION?window.TSCIRCUIT_LATEST_EVAL_VERSION:"latest"},P_n=t=>{mee();const e=md(ve=>ve.circuitJson),n=md(ve=>ve.setCircuitJson),[o,i]=ee.useState(null),[r,s]=ee.useState(null),a=ee.useRef(null),[A,c]=ee.useState(null),[l,u]=ee.useReducer((ve,he)=>ve+1,0),g=pfe(ve=>ve.setLastRunEvalVersion),h=ee.useRef(0),d=hJi(),[p,m]=ee.useState(!1),[_,f]=ee.useState(!1),[I,C]=ee.useState({}),[y,x]=ee.useState(""),[E,B]=ee.useState(!1),[S,Q]=ee.useState(!1),w=Object.values(I).sort((ve,he)=>ve.startTime-he.startTime)[0]?.effectName,M=ve=>{t.onRunCompleted?.(ve)};ee.useEffect(()=>{const ve=he=>{(he.ctrlKey||he.metaKey)&&he.key==="Enter"&&!p&&(he.preventDefault(),he.stopPropagation(),u(1))};return window.addEventListener("keydown",ve,{capture:!0}),()=>window.removeEventListener("keydown",ve,{capture:!0})},[p]),ee.useEffect(()=>{let ve=!1;return(async()=>{try{if(!globalThis.runFrameWorker){const Qe=await w_n(t.evalVersion,t.forceLatestEvalVersion),Pe=await S_n({evalVersion:Qe,webWorkerBlobUrl:t.evalWebWorkerBlobUrl,projectConfig:v_n({projectBaseUrl:t.projectBaseUrl||`${QC}/files/static`}),...t.platformConfig&&{platform:t.platformConfig},verbose:!0,...t.enableFetchProxy&&{enableFetchProxy:t.enableFetchProxy},...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI&&{disableCdnLoading:!0},...t.tscircuitSessionToken&&{tscircuitSessionToken:t.tscircuitSessionToken},...t.easyEdaProxyConfig&&{easyEdaProxyConfig:t.easyEdaProxyConfig}});if(ve)return;globalThis.runFrameWorker=Pe,g(Qe)}ve||f(!0)}catch(Qe){console.error("Failed to preload eval worker",Qe)}})(),()=>{ve=!0}},[t.evalVersion,t.evalWebWorkerBlobUrl,t.forceLatestEvalVersion,t.tscircuitSessionToken]);const[k,R]=ee.useState(null),[F,O]=ee.useState({}),[U,Y]=ee.useState([]),[W,te]=ee.useState([]),j=ee.useRef(0),[J,oe]=ee.useState(t.defaultActiveTab??t.defaultTab??"pcb");ppn({source:"runframe",component:"RunFrame",isWebEmbedded:t.isWebEmbedded,activeTab:J}),ee.useEffect(()=>{t.debug&&vc.enable("run-frame*")},[t.debug]);const ie=t.fsMap instanceof Map?t.fsMap:Object.entries(t.fsMap??{}).reduce((ve,[he,Qe])=>ve.set(he,Qe),new Map),ne=ee.useRef(null),le=ee.useRef(null),{isStaticCircuitJson:ge,circuitJson:_e,error:ue}=AJi({mainComponentPath:t.mainComponentPath,fsMap:ie});ee.useEffect(()=>{ge&&(_e?(n(_e),i(null)):ue&&i({error:ue,stack:""}))},[ge,_e,ue]),ee.useEffect(()=>{if(t.isLoadingFiles||ge)return;const ve=ie instanceof Map?Object.fromEntries(ie.entries()):ie;if(!ve||Object.keys(ve).length===0){i({error:"No files provided. Please provide at least one file with code to execute.",stack:""}),m(!1);return}const he=l!==h.current;if(ne.current&&e){const Pe=cJi(ne.current,ie);if(Object.keys(Pe).length>0)e3("code changes detected");else if(le.current!==t.entrypoint)e3("render triggered by entrypoint change");else if(!he){e3("render triggered without changes to fsMap, skipping");return}}if(t.showRunButton&&l===h.current)return;ne.current=ie,le.current=t.entrypoint??null,h.current=l,m(!0);const Qe=async()=>{e3("running render worker"),i(null),R(null),C({}),Y([]),te([]);const Pe=++j.current,we={progress:0,debugOutputs:[]};let Te=!1;a.current=()=>{Te=!0};const Re=await w_n(t.evalVersion,!globalThis.runFrameWorker&&t.forceLatestEvalVersion);e3("resolvedEvalVersion",Re);const Ee=globalThis.runFrameWorker??await S_n({evalVersion:Re,webWorkerBlobUrl:t.evalWebWorkerBlobUrl,verbose:!0,projectConfig:v_n({projectBaseUrl:t.projectBaseUrl||`${QC}/files/static`}),...t.platformConfig&&{platform:t.platformConfig},...t.enableFetchProxy&&{enableFetchProxy:t.enableFetchProxy},...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI&&{disableCdnLoading:!0},...t.tscircuitSessionToken&&{tscircuitSessionToken:t.tscircuitSessionToken},...t.easyEdaProxyConfig&&{easyEdaProxyConfig:t.easyEdaProxyConfig}});globalThis.runFrameWorker=Ee,g(Re),await Ee.clearEventListeners(),y?.trim()&&Ee.enableDebug(y.replace("DEBUG=","")),e3("Starting render..."),t.onRenderStarted?.();const ke=ie instanceof Map?Object.fromEntries(ie.entries()):ie;let Ce=Date.now();Ee.on("asyncEffect:start",nt=>{const gt=`${nt.phase}|${nt.componentDisplayName??""}|${nt.effectName}`;C(bt=>({...bt,[gt]:{...nt,startTime:Date.now()}}))}),Ee.on("asyncEffect:end",nt=>{const gt=`${nt.phase}|${nt.componentDisplayName??""}|${nt.effectName}`;C(bt=>{const{[gt]:Ct,...Dt}=bt;return Dt})});let Le=[];const Ye=nt=>{Te||Pe!==j.current||(Le=bGi(Le,nt),te(Le))};Ee.on("autorouting:end",nt=>Ye({...nt,type:"autorouting:end"})),Ee.on("autorouting:error",nt=>Ye({...nt,type:"autorouting:error"})),Ee.on("autorouting:start",nt=>{Ye({...nt,type:"autorouting:start"}),O({...F,[nt.componentDisplayName]:{simpleRouteJson:nt.simpleRouteJson,createdAt:Date.now()}})}),Ee.on("solver:started",nt=>{e3("solver:started",nt),Y(gt=>{const bt=`${nt.componentName}-${nt.solverName}`;return gt.some(Dt=>`${Dt.componentName}-${Dt.solverName}`===bt)?gt:[...gt,nt]})}),Ee.on("board:renderPhaseStarted",nt=>{we.lastRenderEvent=nt,we.eventsProcessed=(we.eventsProcessed??0)+1;const gt=rE.indexOf(nt.phase)/pJi*.75+we.eventsProcessed/1e3*.25,bt=1-Math.exp(-gt*3);we.progress=bt,Te||R({...we})}),J==="render_log"&&Ee.on("renderable:renderLifecycle:anyEvent",nt=>{we.renderEvents=we.renderEvents??[],nt.createdAt=Date.now(),we.renderEvents.push(nt),Date.now()-Ce>500&&(we.phaseTimings=Q_n(we.renderEvents??[]),Ce=Date.now()),Te||R({...we})}),Ee.on("autorouting:progress",nt=>{c(nt.debugGraphics)}),Ee.on("debug:logOutput",nt=>{we.debugOutputs=we.debugOutputs??[],we.debugOutputs.push({type:"debug",name:nt.name,content:nt.content}),Te||R({...we})}),e3("Executing fsMap...");const tt=await Ee.executeWithFsMap({entrypoint:t.entrypoint,fsMap:ke,...t.mainComponentPath?{mainComponentPath:t.mainComponentPath}:{}}).then(()=>({success:!0})).catch(nt=>{const gt=nt.message.replace("Error: ","");return e3(`eval error: ${gt}`),t.onError?.(nt),M(Vqe({executionError:nt})),i({error:gt,stack:nt.stack}),R(null),console.error(nt),{success:!1}});if(e3("worker call started"),!tt.success){m(!1),C({});return}const At=Ee.renderUntilSettled();e3("waiting for initial circuit json...");let at=await Ee.getCircuitJson().catch(nt=>(e3("error getting initial circuit json",nt),t.onError?.(nt),M(Vqe({executionError:nt})),i({error:nt.message,stack:nt.stack}),R(null),m(!1),C({}),null));at&&(e3("got initial circuit json"),n(at),t.onCircuitJsonChange?.(at),t.onInitialRender?.({circuitJson:at}),await At,e3("getting final circuit json"),at=await Ee.getCircuitJson(),t.onCircuitJsonChange?.(at),n(at),M(Vqe({circuitJson:at})),t.onRenderFinished?.({circuitJson:at}),c({}),J==="render_log"&&(we.phaseTimings=Q_n(we.renderEvents??[])),we.progress=1,Te||R({...we}),m(!1),C({}),x(""),a.current=null)};d.runWithMutex(Qe)},[t.fsMap,t.entrypoint,l,t.evalVersion,t.mainComponentPath,t.isLoadingFiles,y,ge]);const fe=ee.useRef(null),pe=ee.useRef(null),ye=ve=>{if(!ve||ve===null){console.warn("[RunFrame] handleEditEvent received null or undefined event.");return}ve.in_progress?(fe.current=ve,pe.current&&(clearTimeout(pe.current),pe.current=null)):(pe.current&&clearTimeout(pe.current),pe.current=setTimeout(()=>{const he=ve||fe.current;t.onEditEvent?.(he),fe.current=null,pe.current=null},100))},Me=async(ve,he)=>{let Qe="";const Pe=Array.isArray(e)&&e.find(Re=>Re.type==="software_project_metadata"),we=t.projectUrl??Pe?.project_url;if(we)try{Qe=new URL(we).pathname}catch{Qe=we}const Te=Qe?`${Qe} - ${ve}`:ve;await gq.post("autorouting/bug_reports/create",{json:{title:Te,simple_route_json:he.simpleRouteJson}}).json().then(({autorouting_bug_report:Re})=>{window.open(`https://api.tscircuit.com/autorouting/bug_reports/view?autorouting_bug_report_id=${Re.autorouting_bug_report_id}`,"_blank")}).catch(Re=>{console.error("Failed to report autorouting bug",Re);const Ee=Re instanceof Wb&&Re.response?.status===401,ke=Re instanceof Wb&&Re.response?.status===413;if(Ee){t.onLoginRequired?t.onLoginRequired():alert("You must be logged in to report autorouting bugs");return}if(ke){alert("This autorouting log is too large to report online. Download the log and attach it to a GitHub issue.");return}const Ce=Re instanceof Error?Re.message:"Failed to report autorouting bug";alert(`Failed to report autorouting bug: ${Ce}`)})};return t.isLoadingFiles?K.jsx(lJi,{}):K.jsx(bE,{onError:(ve,he)=>{s(he.componentStack??null)},onReset:()=>s(null),fallbackRender:ve=>K.jsx(sJi,{...ve,componentStack:r}),children:K.jsx(h_n,{code:ie.get(t.entrypoint??t.mainComponentPath),fsMap:ie,defaultActiveTab:t.defaultActiveTab??t.defaultTab,defaultTab:t.defaultTab,availableTabs:t.availableTabs,schematicSvgOptions:t.schematicSvgOptions,showToggleFullScreen:t.showToggleFullScreen,autoroutingGraphics:A,autoroutingLog:F,onReportAutoroutingLog:t.onReportAutoroutingLog||Me,leftHeaderContent:K.jsxs(K.Fragment,{children:[t.showRunButton&&K.jsx(Fqe,{children:K.jsxs(Lqe,{children:[K.jsx(Hqe,{asChild:!0,children:K.jsxs("div",{className:"rf-relative rf-inline-flex",children:[K.jsxs("button",{type:"button",onClick:()=>{u(1)},className:"rf-flex rf-items-center rf-gap-2 rf-px-4 rf-py-2 rf-bg-blue-600 hover:rf-bg-blue-700 rf-text-white rf-rounded-md disabled:rf-opacity-50 transition-colors duration-200",disabled:p||!_,children:["Run"," ",p||!_?K.jsx(SE,{className:"rf-w-3 rf-h-3 rf-animate-spin"}):K.jsx(_ln,{className:"rf-w-3 rf-h-3"})]}),p&&K.jsx("div",{className:"rf-flex rf-items-center rf-ml-1",children:K.jsx(fA,{onClick:ve=>{ve.stopPropagation(),m(!1),R(null),i(null),a.current&&(a.current(),a.current=null),d.cancel(),C({}),globalThis.runFrameWorker&&(globalThis.runFrameWorker.kill(),globalThis.runFrameWorker=null)},variant:"ghost",size:"icon",className:"rf-text-red-300 hover:rf-text-red-400 hover:!rf-bg-transparent [&>svg]:rf-text-red-300 [&>svg]:hover:rf-text-red-400 rf-flex rf-items-center rf-justify-center",children:K.jsx(Qbi,{className:"!rf-h-2.5 !rf-w-2.5",fill:"currentColor",stroke:"currentColor"})})})]})}),K.jsx(Kfe,{sideOffset:8,className:"rf-p-0 rf-bg-transparent rf-border-none rf-shadow-none rf-pointer-events-none",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-px-2.5 rf-py-1.5 rf-bg-slate-900 rf-rounded-md rf-shadow-xl rf-border rf-border-slate-800/60",children:[K.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Ctrl"}),K.jsx("span",{className:"rf-text-slate-500 rf-text-[11px] rf-font-medium rf-leading-none",children:"+"}),K.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Enter"})]})})]})}),t.showFileMenu!==!1&&K.jsx(Yfe,{isWebEmbedded:t.isWebEmbedded,onLoginRequired:t.onLoginRequired,showSchematicDebugGrid:E,onChangeShowSchematicDebugGrid:B,showSchematicPorts:S,onChangeShowSchematicPorts:Q,autoroutingLog:F,onReportAutoroutingLog:t.onReportAutoroutingLog||Me,shouldLoadLatestEval:t.shouldLoadLatestEval,onChangeShouldLoadLatestEval:t.onChangeShouldLoadLatestEval}),t.leftHeaderContent]}),onActiveTabChange:oe,circuitJson:e,renderLog:k,activeEffectName:w,isRunningCode:p,errorMessage:o?.error,errorStack:o?.stack,onEditEvent:ye,editEvents:t.editEvents,onPcbBoundsSelected:t.onPcbBoundsSelected,defaultToFullScreen:t.defaultToFullScreen,onRerunWithDebug:ve=>{x(ve||""),u(1)},solverEvents:U,autoroutingPhases:ge?[]:W,isCli:t.isCli,showSchematicDebugGrid:E,showSchematicPorts:S,onChangeShowSchematicDebugGrid:B,onChangeShowSchematicPorts:Q})})},_Ji=t=>new Promise(e=>setTimeout(e,t)),fJi=({isOpen:t,onClose:e,onLoginSuccess:n})=>{const[o,i]=ee.useState("idle"),[r,s]=ee.useState(null),[a,A]=ee.useState(null),c=md(p=>p.pushEvent),l=ee.useRef(null);ee.useEffect(()=>()=>{l.current&&l.current.abort()},[]);const u=ee.useCallback(async()=>{i("creating"),A(null),l.current=new AbortController;try{const p=Hw(),{login_page:m}=await p.post("sessions/login_page/create",{json:{},signal:l.current?.signal}).json();s(m.url),i("waiting");const _=new URL(m.url);for(_.searchParams.set("autoclose","true"),window.open(_.toString(),"_blank");!l.current?.signal.aborted;){const{login_page:I}=await p.post("sessions/login_page/get",{json:{login_page_id:m.login_page_id},headers:{Authorization:`Bearer ${m.login_page_auth_token}`},signal:l.current?.signal}).json();if(I.was_login_successful){i("exchanging");break}if(I.is_expired)throw new Error("Login page expired. Please try again.");await _Ji(1e3)}if(l.current?.signal.aborted){i("idle");return}const{session:f}=await p.post("sessions/login_page/exchange_for_cli_session",{json:{login_page_id:m.login_page_id},headers:{Authorization:`Bearer ${m.login_page_auth_token}`},signal:l.current?.signal}).json();typeof window<"u"&&(window.TSCIRCUIT_REGISTRY_TOKEN=f.token),await c({event_type:"TOKEN_UPDATED",registry_token:f.token}),i("success"),ua.success("Successfully logged in!"),n?.(),setTimeout(()=>{e(),i("idle"),s(null)},1e3)}catch(p){if(p instanceof DOMException&&p.name==="AbortError"){i("idle");return}console.error("Login error:",p);const m=p instanceof Error?p.message:"Failed to complete login";A(m),i("error"),ua.error(m)}},[c,n,e]),g=ee.useCallback(()=>{l.current&&l.current.abort(),i("idle"),s(null),A(null),e()},[e]),h=o==="creating"||o==="waiting"||o==="exchanging",d=()=>{switch(o){case"creating":return"Creating login page...";case"waiting":return"Waiting for you to complete login in the browser...";case"exchanging":return"Generating token...";case"success":return"Successfully logged in!";case"error":return a||"An error occurred";default:return null}};return K.jsx(KT,{open:t,onOpenChange:p=>!p&&!h&&g(),children:K.jsxs(VP,{className:"rf-max-w-md",children:[K.jsxs(zP,{children:[K.jsx(JP,{children:"Sign In Required"}),K.jsx(VT,{children:o==="idle"||o==="error"?"Sign in to continue. A new browser window will open for authentication.":"Complete the login process in the opened browser window."})]}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4 rf-py-4",children:[o==="idle"||o==="error"?K.jsx(fA,{onClick:u,className:"rf-w-full",children:"Sign In"}):K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-w-full",children:[o!=="success"&&K.jsx("div",{className:"rf-animate-spin rf-w-6 rf-h-6 rf-border-2 rf-border-gray-300 rf-border-t-blue-600 rf-rounded-full"}),K.jsx("p",{className:"rf-text-sm rf-text-gray-600 rf-text-center",children:d()}),r&&o==="waiting"&&K.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"rf-text-xs rf-text-blue-600 hover:rf-underline",children:"Click here if the window didn't open"})]}),a&&o==="error"&&K.jsx("p",{className:"rf-text-sm rf-text-red-600 rf-text-center",children:a}),h&&K.jsx(fA,{variant:"outline",onClick:g,className:"rf-w-full",children:"Cancel"})]})]})})},IJi=()=>{const[t,e]=ee.useState(!1),n=ee.useCallback(()=>{e(!0)},[]),o=ee.useCallback(()=>{e(!1)},[]),i=ee.useCallback(()=>{e(!1)},[]);return{LoginDialog:K.jsx(fJi,{isOpen:t,onClose:o,onLoginSuccess:i}),openLoginDialog:n}},CJi=({apiBaseUrl:t,fetchImpl:e=globalThis.fetch.bind(globalThis)})=>{const n=`${t.replace(/\/$/,"")}/cache`;return{getItem:async o=>{try{const i=await e(`${n}?key=${encodeURIComponent(o)}`);return i.ok?await i.text():null}catch{return null}},setItem:async(o,i)=>{try{await e(`${n}?key=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8"},body:i})}catch{}}}},yJi=t=>{const[e,n]=OO("load-latest-eval",!0),o=t.evalWebWorkerBlobUrl??t.workerBlobUrl,i=t.apiBaseUrl??QC,r=ee.useMemo(()=>({...t.platformConfig,localCacheEngine:t.platformConfig?.localCacheEngine??CJi({apiBaseUrl:i})}),[i,t.platformConfig]),[s]=ee.useState(()=>typeof window>"u"?void 0:new URLSearchParams(window.location.hash.slice(1)).get("main_component")??void 0),a=ee.useCallback(l=>{if(typeof window>"u")return;const u=new URLSearchParams(window.location.hash.slice(1));if(u.get("main_component")===l)return;u.set("main_component",l);const g=u.toString(),h=`${window.location.pathname}${window.location.search}${g.length>0?`#${g}`:""}`;window.history.replaceState(null,"",h)},[]),{LoginDialog:A,openLoginDialog:c}=IJi();return K.jsxs(K.Fragment,{children:[A,K.jsx(Cfn,{debug:t.debug,forceLatestEvalVersion:!o&&e,defaultToFullScreen:!0,showToggleFullScreen:!1,evalWebWorkerBlobUrl:o,apiBaseUrl:t.apiBaseUrl,platformConfig:r,isCli:!0,showFilesSwitch:!0,enableFetchProxy:t.enableFetchProxy,initialMainComponentPath:s,onLoginRequired:c,onMainComponentPathChange:a,shouldLoadLatestEval:!o&&e,onChangeShouldLoadLatestEval:l=>{n(l),globalThis.runFrameWorker=null},leftHeaderContent:K.jsx("div",{className:"rf-flex rf-items-center rf-justify-between",children:t.scenarioSelectorContent})})]})};vc("run-frame:ImportComponentDialog");var M_n=1,xJi=.9,EJi=.8,BJi=.17,zqe=.1,Jqe=.999,bJi=.9999,SJi=.99,QJi=/[\\\/_+.#"@\[\(\{&]/,vJi=/[\\\/_+.#"@\[\(\{&]/g,wJi=/[\s-]/,D_n=/[\s-]/g;function Wqe(t,e,n,o,i,r,s){if(r===e.length)return i===t.length?M_n:SJi;var a=`${i},${r}`;if(s[a]!==void 0)return s[a];for(var A=o.charAt(r),c=n.indexOf(A,i),l=0,u,g,h,d;c>=0;)u=Wqe(t,e,n,o,c+1,r+1,s),u>l&&(c===i?u*=M_n:QJi.test(t.charAt(c-1))?(u*=EJi,h=t.slice(i,c-1).match(vJi),h&&i>0&&(u*=Math.pow(Jqe,h.length))):wJi.test(t.charAt(c-1))?(u*=xJi,d=t.slice(i,c-1).match(D_n),d&&i>0&&(u*=Math.pow(Jqe,d.length))):(u*=BJi,i>0&&(u*=Math.pow(Jqe,c-i))),t.charAt(c)!==e.charAt(r)&&(u*=bJi)),(u<zqe&&n.charAt(c-1)===o.charAt(r+1)||o.charAt(r+1)===o.charAt(r)&&n.charAt(c-1)!==o.charAt(r))&&(g=Wqe(t,e,n,o,c+1,r+2,s),g*zqe>u&&(u=g*zqe)),u>l&&(l=u),c=n.indexOf(A,c+1);return s[a]=l,l}function N_n(t){return t.toLowerCase().replace(D_n," ")}function PJi(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Wqe(t,e,N_n(t),N_n(e),0,0,{})}var Mee='[cmdk-group=""]',jqe='[cmdk-group-items=""]',MJi='[cmdk-group-heading=""]',R_n='[cmdk-item=""]',T_n=`${R_n}:not([aria-disabled="true"])`,$qe="cmdk-item-select",ZU="data-value",DJi=(t,e,n)=>PJi(t,e,n),k_n=ee.createContext(void 0),Dee=()=>ee.useContext(k_n),F_n=ee.createContext(void 0),qqe=()=>ee.useContext(F_n),L_n=ee.createContext(void 0),H_n=ee.forwardRef((t,e)=>{let n=eK(()=>{var J,oe;return{search:"",value:(oe=(J=t.value)!=null?J:t.defaultValue)!=null?oe:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=eK(()=>new Set),i=eK(()=>new Map),r=eK(()=>new Map),s=eK(()=>new Set),a=O_n(t),{label:A,children:c,value:l,onValueChange:u,filter:g,shouldFilter:h,loop:d,disablePointerSelection:p=!1,vimBindings:m=!0,..._}=t,f=t_(),I=t_(),C=t_(),y=ee.useRef(null),x=UJi();ZT(()=>{if(l!==void 0){let J=l.trim();n.current.value=J,E.emit()}},[l]),ZT(()=>{x(6,k)},[]);let E=ee.useMemo(()=>({subscribe:J=>(s.current.add(J),()=>s.current.delete(J)),snapshot:()=>n.current,setState:(J,oe,ie)=>{var ne,le,ge,_e;if(!Object.is(n.current[J],oe)){if(n.current[J]=oe,J==="search")M(),Q(),x(1,w);else if(J==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ue=document.getElementById(C);ue?ue.focus():(ne=document.getElementById(f))==null||ne.focus()}if(x(7,()=>{var ue;n.current.selectedItemId=(ue=R())==null?void 0:ue.id,E.emit()}),ie||x(5,k),((le=a.current)==null?void 0:le.value)!==void 0){let ue=oe??"";(_e=(ge=a.current).onValueChange)==null||_e.call(ge,ue);return}}E.emit()}},emit:()=>{s.current.forEach(J=>J())}}),[]),B=ee.useMemo(()=>({value:(J,oe,ie)=>{var ne;oe!==((ne=r.current.get(J))==null?void 0:ne.value)&&(r.current.set(J,{value:oe,keywords:ie}),n.current.filtered.items.set(J,S(oe,ie)),x(2,()=>{Q(),E.emit()}))},item:(J,oe)=>(o.current.add(J),oe&&(i.current.has(oe)?i.current.get(oe).add(J):i.current.set(oe,new Set([J]))),x(3,()=>{M(),Q(),n.current.value||w(),E.emit()}),()=>{r.current.delete(J),o.current.delete(J),n.current.filtered.items.delete(J);let ie=R();x(4,()=>{M(),ie?.getAttribute("id")===J&&w(),E.emit()})}),group:J=>(i.current.has(J)||i.current.set(J,new Set),()=>{r.current.delete(J),i.current.delete(J)}),filter:()=>a.current.shouldFilter,label:A||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:f,inputId:C,labelId:I,listInnerRef:y}),[]);function S(J,oe){var ie,ne;let le=(ne=(ie=a.current)==null?void 0:ie.filter)!=null?ne:DJi;return J?le(J,n.current.search,oe):0}function Q(){if(!n.current.search||a.current.shouldFilter===!1)return;let J=n.current.filtered.items,oe=[];n.current.filtered.groups.forEach(ne=>{let le=i.current.get(ne),ge=0;le.forEach(_e=>{let ue=J.get(_e);ge=Math.max(ue,ge)}),oe.push([ne,ge])});let ie=y.current;F().sort((ne,le)=>{var ge,_e;let ue=ne.getAttribute("id"),fe=le.getAttribute("id");return((ge=J.get(fe))!=null?ge:0)-((_e=J.get(ue))!=null?_e:0)}).forEach(ne=>{let le=ne.closest(jqe);le?le.appendChild(ne.parentElement===le?ne:ne.closest(`${jqe} > *`)):ie.appendChild(ne.parentElement===ie?ne:ne.closest(`${jqe} > *`))}),oe.sort((ne,le)=>le[1]-ne[1]).forEach(ne=>{var le;let ge=(le=y.current)==null?void 0:le.querySelector(`${Mee}[${ZU}="${encodeURIComponent(ne[0])}"]`);ge?.parentElement.appendChild(ge)})}function w(){let J=F().find(ie=>ie.getAttribute("aria-disabled")!=="true"),oe=J?.getAttribute(ZU);E.setState("value",oe||void 0)}function M(){var J,oe,ie,ne;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=o.current.size;return}n.current.filtered.groups=new Set;let le=0;for(let ge of o.current){let _e=(oe=(J=r.current.get(ge))==null?void 0:J.value)!=null?oe:"",ue=(ne=(ie=r.current.get(ge))==null?void 0:ie.keywords)!=null?ne:[],fe=S(_e,ue);n.current.filtered.items.set(ge,fe),fe>0&&le++}for(let[ge,_e]of i.current)for(let ue of _e)if(n.current.filtered.items.get(ue)>0){n.current.filtered.groups.add(ge);break}n.current.filtered.count=le}function k(){var J,oe,ie;let ne=R();ne&&(((J=ne.parentElement)==null?void 0:J.firstChild)===ne&&((ie=(oe=ne.closest(Mee))==null?void 0:oe.querySelector(MJi))==null||ie.scrollIntoView({block:"nearest"})),ne.scrollIntoView({block:"nearest"}))}function R(){var J;return(J=y.current)==null?void 0:J.querySelector(`${R_n}[aria-selected="true"]`)}function F(){var J;return Array.from(((J=y.current)==null?void 0:J.querySelectorAll(T_n))||[])}function O(J){let oe=F()[J];oe&&E.setState("value",oe.getAttribute(ZU))}function U(J){var oe;let ie=R(),ne=F(),le=ne.findIndex(_e=>_e===ie),ge=ne[le+J];(oe=a.current)!=null&&oe.loop&&(ge=le+J<0?ne[ne.length-1]:le+J===ne.length?ne[0]:ne[le+J]),ge&&E.setState("value",ge.getAttribute(ZU))}function Y(J){let oe=R(),ie=oe?.closest(Mee),ne;for(;ie&&!ne;)ie=J>0?GJi(ie,Mee):YJi(ie,Mee),ne=ie?.querySelector(T_n);ne?E.setState("value",ne.getAttribute(ZU)):U(J)}let W=()=>O(F().length-1),te=J=>{J.preventDefault(),J.metaKey?W():J.altKey?Y(1):U(1)},j=J=>{J.preventDefault(),J.metaKey?O(0):J.altKey?Y(-1):U(-1)};return ee.createElement(Na.div,{ref:e,tabIndex:-1,..._,"cmdk-root":"",onKeyDown:J=>{var oe;(oe=_.onKeyDown)==null||oe.call(_,J);let ie=J.nativeEvent.isComposing||J.keyCode===229;if(!(J.defaultPrevented||ie))switch(J.key){case"n":case"j":{m&&J.ctrlKey&&te(J);break}case"ArrowDown":{te(J);break}case"p":case"k":{m&&J.ctrlKey&&j(J);break}case"ArrowUp":{j(J);break}case"Home":{J.preventDefault(),O(0);break}case"End":{J.preventDefault(),W();break}case"Enter":{J.preventDefault();let ne=R();if(ne){let le=new Event($qe);ne.dispatchEvent(le)}}}}},ee.createElement("label",{"cmdk-label":"",htmlFor:B.inputId,id:B.labelId,style:VJi},A),qfe(t,J=>ee.createElement(F_n.Provider,{value:E},ee.createElement(k_n.Provider,{value:B},J))))}),NJi=ee.forwardRef((t,e)=>{var n,o;let i=t_(),r=ee.useRef(null),s=ee.useContext(L_n),a=Dee(),A=O_n(t),c=(o=(n=A.current)==null?void 0:n.forceMount)!=null?o:s?.forceMount;ZT(()=>{if(!c)return a.item(i,s?.id)},[c]);let l=G_n(i,r,[t.value,t.children,r],t.keywords),u=qqe(),g=XP(x=>x.value&&x.value===l.current),h=XP(x=>c||a.filter()===!1?!0:x.search?x.filtered.items.get(i)>0:!0);ee.useEffect(()=>{let x=r.current;if(!(!x||t.disabled))return x.addEventListener($qe,d),()=>x.removeEventListener($qe,d)},[h,t.onSelect,t.disabled]);function d(){var x,E;p(),(E=(x=A.current).onSelect)==null||E.call(x,l.current)}function p(){u.setState("value",l.current,!0)}if(!h)return null;let{disabled:m,value:_,onSelect:f,forceMount:I,keywords:C,...y}=t;return ee.createElement(Na.div,{ref:_R(r,e),...y,id:i,"cmdk-item":"",role:"option","aria-disabled":!!m,"aria-selected":!!g,"data-disabled":!!m,"data-selected":!!g,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:d},t.children)}),RJi=ee.forwardRef((t,e)=>{let{heading:n,children:o,forceMount:i,...r}=t,s=t_(),a=ee.useRef(null),A=ee.useRef(null),c=t_(),l=Dee(),u=XP(h=>i||l.filter()===!1?!0:h.search?h.filtered.groups.has(s):!0);ZT(()=>l.group(s),[]),G_n(s,a,[t.value,t.heading,A]);let g=ee.useMemo(()=>({id:s,forceMount:i}),[i]);return ee.createElement(Na.div,{ref:_R(a,e),...r,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},n&&ee.createElement("div",{ref:A,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),qfe(t,h=>ee.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},ee.createElement(L_n.Provider,{value:g},h))))}),TJi=ee.forwardRef((t,e)=>{let{alwaysRender:n,...o}=t,i=ee.useRef(null),r=XP(s=>!s.search);return!n&&!r?null:ee.createElement(Na.div,{ref:_R(i,e),...o,"cmdk-separator":"",role:"separator"})}),kJi=ee.forwardRef((t,e)=>{let{onValueChange:n,...o}=t,i=t.value!=null,r=qqe(),s=XP(c=>c.search),a=XP(c=>c.selectedItemId),A=Dee();return ee.useEffect(()=>{t.value!=null&&r.setState("search",t.value)},[t.value]),ee.createElement(Na.input,{ref:e,...o,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":A.listId,"aria-labelledby":A.labelId,"aria-activedescendant":a,id:A.inputId,type:"text",value:i?t.value:s,onChange:c=>{i||r.setState("search",c.target.value),n?.(c.target.value)}})}),FJi=ee.forwardRef((t,e)=>{let{children:n,label:o="Suggestions",...i}=t,r=ee.useRef(null),s=ee.useRef(null),a=XP(c=>c.selectedItemId),A=Dee();return ee.useEffect(()=>{if(s.current&&r.current){let c=s.current,l=r.current,u,g=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let h=c.offsetHeight;l.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return g.observe(c),()=>{cancelAnimationFrame(u),g.unobserve(c)}}},[]),ee.createElement(Na.div,{ref:_R(r,e),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":o,id:A.listId},qfe(t,c=>ee.createElement("div",{ref:_R(s,A.listInnerRef),"cmdk-list-sizer":""},c)))}),LJi=ee.forwardRef((t,e)=>{let{open:n,onOpenChange:o,overlayClassName:i,contentClassName:r,container:s,...a}=t;return ee.createElement(r_e,{open:n,onOpenChange:o},ee.createElement(s_e,{container:s},ee.createElement(wZ,{"cmdk-overlay":"",className:i}),ee.createElement(MZ,{"aria-label":t.label,"cmdk-dialog":"",className:r},ee.createElement(H_n,{ref:e,...a}))))}),HJi=ee.forwardRef((t,e)=>XP(n=>n.filtered.count===0)?ee.createElement(Na.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),OJi=ee.forwardRef((t,e)=>{let{progress:n,children:o,label:i="Loading...",...r}=t;return ee.createElement(Na.div,{ref:e,...r,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},qfe(t,s=>ee.createElement("div",{"aria-hidden":!0},s)))}),t3=Object.assign(H_n,{List:FJi,Item:NJi,Input:kJi,Group:RJi,Separator:TJi,Dialog:LJi,Empty:HJi,Loading:OJi});function GJi(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function YJi(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function O_n(t){let e=ee.useRef(t);return ZT(()=>{e.current=t}),e}var ZT=typeof window>"u"?ee.useEffect:ee.useLayoutEffect;function eK(t){let e=ee.useRef();return e.current===void 0&&(e.current=t()),e}function XP(t){let e=qqe(),n=()=>t(e.snapshot());return ee.useSyncExternalStore(e.subscribe,n,n)}function G_n(t,e,n,o=[]){let i=ee.useRef(),r=Dee();return ZT(()=>{var s;let a=(()=>{var c;for(let l of n){if(typeof l=="string")return l.trim();if(typeof l=="object"&&"current"in l)return l.current?(c=l.current.textContent)==null?void 0:c.trim():i.current}})(),A=o.map(c=>c.trim());r.value(t,a,A),(s=e.current)==null||s.setAttribute(ZU,a),i.current=a}),i}var UJi=()=>{let[t,e]=ee.useState(),n=eK(()=>new Map);return ZT(()=>{n.current.forEach(o=>o()),n.current=new Map},[t]),(o,i)=>{n.current.set(o,i),e({})}};function KJi(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function qfe({asChild:t,children:e},n){return t&&ee.isValidElement(e)?ee.cloneElement(KJi(e),{ref:e.ref},n(e.props.children)):n(e)}var VJi={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Y_n=ee.forwardRef(({className:t,...e},n)=>K.jsx(t3,{ref:n,className:Oi("rf-flex rf-h-full rf-w-full rf-flex-col rf-overflow-hidden rf-rounded-md rf-bg-white rf-text-zinc-950 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",t),...e}));Y_n.displayName=t3.displayName;const U_n=ee.forwardRef(({className:t,...e},n)=>K.jsxs("div",{className:"rf-flex rf-items-center rf-border-b rf-px-3","cmdk-input-wrapper":"",children:[K.jsx(iWe,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-shrink-0 rf-opacity-50"}),K.jsx(t3.Input,{ref:n,className:Oi("rf-flex rf-h-10 rf-w-full rf-rounded-md rf-bg-transparent rf-py-3 rf-text-sm rf-outline-none placeholder:rf-text-zinc-500 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:placeholder:rf-text-zinc-400",t),...e})]}));U_n.displayName=t3.Input.displayName;const K_n=ee.forwardRef(({className:t,...e},n)=>K.jsx(t3.List,{ref:n,className:Oi("rf-max-h-[300px] rf-overflow-y-auto rf-overflow-x-hidden rf-py-1",t),...e}));K_n.displayName=t3.List.displayName;const Xqe=ee.forwardRef((t,e)=>K.jsx(t3.Empty,{ref:e,className:"rf-py-6 rf-text-center rf-text-sm",...t}));Xqe.displayName=t3.Empty.displayName;const Nee=ee.forwardRef(({className:t,...e},n)=>K.jsx(t3.Group,{ref:n,className:Oi("rf-overflow-hidden rf-px-1 rf-py-0 rf-text-zinc-950 [&_[cmdk-group-heading]]:rf-px-2 [&_[cmdk-group-heading]]:rf-py-1.5 [&_[cmdk-group-heading]]:rf-text-xs [&_[cmdk-group-heading]]:rf-font-medium [&_[cmdk-group-heading]]:rf-text-zinc-500 dark:rf-text-zinc-50 dark:[&_[cmdk-group-heading]]:rf-text-zinc-400",t),...e}));Nee.displayName=t3.Group.displayName;const zJi=ee.forwardRef(({className:t,...e},n)=>K.jsx(t3.Separator,{ref:n,className:Oi("rf--mx-1 rf-h-px rf-bg-zinc-200 dark:rf-bg-zinc-800",t),...e}));zJi.displayName=t3.Separator.displayName;const Ree=ee.forwardRef(({className:t,...e},n)=>K.jsx(t3.Item,{ref:n,className:Oi("rf-relative rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none data-[disabled=true]:rf-pointer-events-none data-[selected=true]:rf-bg-zinc-100 data-[selected=true]:rf-text-zinc-900 data-[disabled=true]:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:data-[selected=true]:rf-bg-zinc-800 dark:data-[selected=true]:rf-text-zinc-50",t),...e}));Ree.displayName=t3.Item.displayName;var JJi=Object.defineProperty,ZP=(t,e)=>JJi(t,"name",{value:e,configurable:!0}),Zqe="Popover",[V_n,Gmr]=Nx(Zqe,[PP]),eXe=PP(),[WJi,tK]=V_n(Zqe),jJi=ZP(t=>{const{__scopePopover:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!1}=t,a=eXe(e),A=ee.useRef(null),[c,l]=ee.useState(!1),[u,g]=DB({prop:o,defaultProp:i??!1,onChange:r,caller:Zqe});return K.jsx(CZ,{...a,children:K.jsx(WJi,{scope:e,contentId:t_(),triggerRef:A,open:u,onOpenChange:g,onOpenToggle:ee.useCallback(()=>g(h=>!h),[g]),hasCustomAnchor:c,onCustomAnchorAdd:ee.useCallback(()=>l(!0),[]),onCustomAnchorRemove:ee.useCallback(()=>l(!1),[]),modal:s,children:n})})},"Popover"),$Ji="PopoverTrigger",qJi=ee.forwardRef(ZP(function(e,n){const{__scopePopover:o,...i}=e,r=tK($Ji,o),s=eXe(o),a=$A(n,r.triggerRef),A=K.jsx(Na.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":tXe(r.open),...i,ref:a,onClick:ar(e.onClick,r.onOpenToggle)});return r.hasCustomAnchor?A:K.jsx(Hme,{asChild:!0,...s,children:A})},"PopoverTrigger")),z_n="PopoverPortal",[XJi,ZJi]=V_n(z_n,{forceMount:void 0}),eWi=ZP(t=>{const{__scopePopover:e,forceMount:n,children:o,container:i}=t,r=tK(z_n,e);return K.jsx(XJi,{scope:e,forceMount:n,children:K.jsx(uE,{present:n||r.open,children:K.jsx(Gme,{asChild:!0,container:i,children:o})})})},"PopoverPortal"),Tee="PopoverContent",tWi=ee.forwardRef(ZP(function(e,n){const o=ZJi(Tee,e.__scopePopover),{forceMount:i=o.forceMount,...r}=e,s=tK(Tee,e.__scopePopover);return K.jsx(uE,{present:i||s.open,children:s.modal?K.jsx(oWi,{...r,ref:n}):K.jsx(iWi,{...r,ref:n})})},"PopoverContent")),nWi=MB("PopoverContent.RemoveScroll"),oWi=ee.forwardRef(ZP(function(e,n){const o=tK(Tee,e.__scopePopover),i=ee.useRef(null),r=$A(n,i),s=ee.useRef(!1);return ee.useEffect(()=>{const a=i.current;if(a)return Kme(a)},[]),K.jsx(yZ,{as:nWi,allowPinchZoom:!0,children:K.jsx(J_n,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ar(e.onCloseAutoFocus,a=>{a.preventDefault(),s.current||o.triggerRef.current?.focus()}),onPointerDownOutside:ar(e.onPointerDownOutside,a=>{const A=a.detail.originalEvent,c=A.button===0&&A.ctrlKey===!0,l=A.button===2||c;s.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:ar(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),iWi=ee.forwardRef(ZP(function(e,n){const o=tK(Tee,e.__scopePopover),i=ee.useRef(!1),r=ee.useRef(!1);return K.jsx(J_n,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||o.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=s.target;o.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})},"PopoverContentNonModal")),J_n=ee.forwardRef(ZP(function(e,n){const{__scopePopover:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:A,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...g}=e,h=tK(Tee,o),d=eXe(o);return hU(),K.jsx(Sme,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:K.jsx(_Z,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:A,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:K.jsx(Ome,{"data-state":tXe(h.open),role:"dialog",id:h.contentId,...d,...g,ref:n,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function tXe(t){return t?"open":"closed"}ZP(tXe,"getState");var rWi=jJi,sWi=qJi,aWi=eWi,W_n=tWi;const AWi=rWi,cWi=sWi,j_n=ee.forwardRef(({className:t,align:e="center",sideOffset:n=4,...o},i)=>K.jsx(aWi,{children:K.jsx(W_n,{ref:i,align:e,sideOffset:n,className:Oi("rf-z-50 rf-w-72 rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-4 rf-text-zinc-950 rf-shadow-md rf-outline-none data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 rf-origin-[--radix-popover-content-transform-origin] dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",t),...o})}));j_n.displayName=W_n.displayName;function $_n(t,e){const n=t.lastIndexOf("."),o=e.lastIndexOf("."),i=n>0?t.substring(0,n):t,r=o>0?e.substring(0,o):e;if(i!==r&&t.substring(n)===e.substring(o)){if(i.startsWith(r))return 1;if(r.startsWith(i))return-1}return t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})}function lWi(t){const e=[],n=new Map;n.set("",{name:"",path:"",type:"folder",children:e});for(const o of t){const i=o.split("/");let r="";for(let s=0;s<i.length;s++){const a=i[s],A=r;if(r=r?`${r}/${a}`:a,!n.has(r)){const c=s===i.length-1,l={name:a,path:r,type:c?"file":"folder",children:c?void 0:[]};n.set(r,l);const u=n.get(A);u&&u.children&&u.children.push(l)}}}return e}function q_n(t,e){for(const n of t){if(n.path===e)return n;if(n.children){const o=q_n(n.children,e);if(o)return o}}return null}function uWi(t,e){let n;if(e?n=q_n(t,e):n={name:"",path:"",type:"folder",children:t},!n||!n.children)return{files:[],folders:[]};const o=n.children.filter(r=>r.type==="file"),i=n.children.filter(r=>r.type==="folder");return o.sort((r,s)=>$_n(r.name,s.name)),i.sort((r,s)=>$_n(r.name,s.name)),{files:o,folders:i}}const gWi=t=>{const e=t.split("/").pop()||"";return e.endsWith(".py.tsx")?e.slice(0,-4):e};function nXe(t){const e=t.lastIndexOf("/");return e===-1?"/":t.substring(0,e)}function dWi({currentFile:t,files:e}){const[n,o]=ee.useState(!1),[i,r]=ee.useState(()=>{if(typeof window<"u"){const A=new URLSearchParams(window.location.search),c=new URLSearchParams(window.location.hash.slice(1)),l=A.get("file")??c.get("file");if(l&&e.includes(l)){const u=nXe(l);return u==="/"?null:u}}if(t&&e.includes(t)){const A=nXe(t);return A==="/"?null:A}return null});return ee.useEffect(()=>{if(t&&!n&&e.includes(t)){const A=nXe(t);r(A==="/"?null:A)}},[t,n,e]),{currentFolder:i,navigateToFolder:A=>{r(A),o(!0)},resetManualNavigation:()=>{o(!1)}}}const oXe=t=>t.endsWith(".tsx")||t.endsWith(".jsx")?K.jsx(gbi,{className:"rf-h-4 rf-w-4 rf-text-blue-500"}):t.endsWith(".md")||t.endsWith(".txt")?K.jsx(pbi,{className:"rf-h-4 rf-w-4 rf-text-gray-600"}):K.jsx(mbi,{className:"rf-h-4 rf-w-4 rf-text-gray-500"}),hWi=t=>t.endsWith(".tsx")||$fe(t)||t.endsWith(".jsx"),pWi=t=>gWi(t),X_n=t=>t.substring(0,t.lastIndexOf("/"))||"/",Z_n=({files:t,onFileChange:e,currentFile:n,fileFilter:o=hWi,getDisplayName:i=pWi,placeholder:r="Select file",searchPlaceholder:s="Search for file",emptyMessage:a="No files found in this directory.",pinnedFiles:A=[],onToggleFavorite:c,recentlySavedFiles:l=[]})=>{const[u,g]=ee.useState(!1),[h,d]=ee.useState(n),{currentFolder:p,navigateToFolder:m,resetManualNavigation:_}=dWi({currentFile:h,files:t}),[f,I]=ee.useState(0),[C,y]=ee.useState(""),[x,E]=OO("runframe:recentlyViewed",[]),[B,S]=OO("runframe:showRecents",!1);ee.useEffect(()=>{const ie=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="k"&&(ne.preventDefault(),g(le=>!le))};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[]);const Q=t.filter(o),w=ee.useRef(null);ee.useEffect(()=>{const ie=()=>{w.current&&(clearTimeout(w.current),w.current=null)};return d(n),n&&Q.includes(n)&&(ie(),w.current=setTimeout(()=>{E(ne=>{if(ne[0]===n)return ne;const le=ne.filter(ge=>ge!==n);return[n,...le].slice(0,10)})},500)),ie},[n,Q,E]);const M=lWi(Q),{files:k,folders:R}=uWi(M,p||""),O=(()=>{if(!C.trim())return{currentDirResults:[],globalResults:[]};const ie=C.toLowerCase(),le=Q.map(ue=>{const fe=ue.split("/").pop()||"";return{path:ue,fileName:fe}}).filter(ue=>ue.fileName.toLowerCase().includes(ie)||ue.path.toLowerCase().includes(ie)),ge=le.filter(ue=>p?ue.path.substring(0,ue.path.lastIndexOf("/"))===p:!ue.path.includes("/")),_e=le.filter(ue=>p?ue.path.substring(0,ue.path.lastIndexOf("/"))!==p:ue.path.includes("/"));return{currentDirResults:ge,globalResults:_e}})(),U=C.trim().length>0,Y=ie=>{m(ie),I(0)},W=ee.useCallback(()=>{if(!p)return;const ie=p.lastIndexOf("/"),ne=ie===-1?null:p.substring(0,ie);Y(ne)},[p,Y]);ee.useEffect(()=>{if(!u)return;const ie=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="ArrowUp"&&(ne.preventDefault(),W())};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[u,W]);const te=ee.useCallback((ie,ne,le=!1)=>{if(d(ie),I(ne),g(!1),e(ie),le){const ge=ie.lastIndexOf("/"),_e=ge===-1?null:ie.substring(0,ge);Y(_e)}},[e,Y]);ee.useEffect(()=>{const ie=ne=>{if((ne.metaKey||ne.ctrlKey)&&(ne.key==="ArrowLeft"||ne.key==="ArrowRight")){if(ne.preventDefault(),!n||k.length===0)return;const le=k.findIndex(ue=>ue.path===n);if(le===-1)return;let ge;ne.key==="ArrowLeft"?ge=le===0?k.length-1:le-1:ge=le===k.length-1?0:le+1;const _e=k[ge];_e&&te(_e.path,ge)}};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[n,k,te]),ee.useEffect(()=>{if(k.length>0){const ie=k.findIndex(ne=>ne.path===n);ie>=0&&I(ie)}},[k,n]);const j=ee.useMemo(()=>{const ie=l.filter(ge=>Q.includes(ge)),ne=x.filter(ge=>Q.includes(ge)),le=[];ie.length>0&&le.push({path:ie[0],type:"saved"});for(const ge of ne){if(le.length>=3)break;le.some(_e=>_e.path===ge)||le.push({path:ge,type:"viewed"})}return le},[l,x,Q]),J=p??"/";J.length>25&&""+J.slice(-22);const oe=()=>`rf-w-full rf-min-w-[600px] ${U?"rf-max-w-[600px]":"rf-max-w-[1000px]"}`;return K.jsx("div",{className:"rf-flex rf-items-center rf-gap-1",children:K.jsxs(AWi,{open:u,onOpenChange:ie=>{g(ie),ie||(y(""),_())},children:[K.jsx(cWi,{asChild:!0,children:K.jsxs(fA,{variant:"outline",role:"combobox","aria-expanded":u,className:"rf-w-fit rf-min-w-32 rf-max-w-100 rf-justify-center rf-items-center rf-gap-1 !rf-font-normal",children:[K.jsx("span",{className:"rf-truncate rf-text-left",children:h?i(h):r}),K.jsx(abi,{className:"rf-opacity-50 rf-flex-shrink-0"})]})}),K.jsx(j_n,{className:Oi("!rf-p-0 !rf-overflow-y-auto !rf-max-h-[80vh] !rf-z-[200]",oe()),children:K.jsxs(Y_n,{shouldFilter:!1,children:[K.jsx(U_n,{placeholder:s,className:"rf-h-9 rf-w-full",value:C,onValueChange:y}),j.length>0&&K.jsxs("div",{className:"rf-border-b rf-border-gray-200",children:[K.jsxs("button",{onClick:()=>S(!B),className:"rf-w-full rf-px-3 rf-py-2 rf-flex rf-items-center rf-justify-between rf-text-xs rf-text-slate-600 hover:rf-bg-slate-50 rf-bg-transparent rf-border-none rf-cursor-pointer",children:[K.jsx("span",{className:"rf-font-medium",children:"Recent Files"}),K.jsx(pZ,{className:Oi("rf-h-4 rf-w-4 rf-transition-transform",!B&&"-rf-rotate-90")})]}),B&&K.jsx("div",{className:"rf-pb-1",children:j.map((ie,ne)=>K.jsxs("div",{onClick:()=>te(ie.path,ne,!0),className:Oi("rf-flex rf-items-center rf-px-3 rf-py-1.5 rf-cursor-pointer hover:rf-bg-slate-100",ie.path===n&&"rf-font-medium"),children:[ie.type==="saved"?K.jsx("span",{title:"Recently saved",children:K.jsx(Sbi,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-green-500"})}):K.jsx("span",{title:"Recently viewed",children:K.jsx(ubi,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-blue-500"})}),K.jsx("span",{className:"rf-text-sm",children:i(ie.path.split("/").pop()||"")}),K.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:X_n(ie.path)}),K.jsx(CS,{className:Oi("rf-ml-auto rf-h-4 rf-w-4",ie.path===n?"rf-opacity-100":"rf-opacity-0")})]},ie.path))})]}),K.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-slate-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[K.jsx("div",{className:"rf-flex rf-items-center rf-text-xs rf-text-slate-600 rf-min-w-0 rf-flex-1",children:K.jsxs("div",{className:"rf-flex rf-items-center rf-min-w-0",children:[K.jsx("button",{onClick:()=>Y(null),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-flex-shrink-0",children:"root"}),p?.split("/").filter(Boolean).map((ie,ne,le)=>{const ge=le.slice(0,ne+1).join("/");return K.jsxs("span",{className:"rf-flex rf-items-center rf-min-w-0",children:[K.jsx("span",{className:"rf-mx-1 rf-flex-shrink-0",children:"/"}),ne===le.length-1?K.jsx("span",{className:"rf-text-slate-800 rf-truncate rf-max-w-[200px]",title:ie,children:ie}):K.jsx("button",{onClick:()=>Y(ge),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-truncate rf-max-w-[150px]",title:ie,children:ie})]},ge)})]})}),K.jsx("div",{className:"rf-flex rf-items-center rf-gap-2 rf-flex-shrink-0",children:p&&K.jsxs("button",{onClick:W,className:"rf-flex rf-items-center rf-gap-1 rf-text-slate-600 hover:rf-text-slate-800 rf-bg-transparent rf-border-none rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-colors",title:"Go up one level",children:[K.jsx(ibi,{className:"rf-h-3 rf-w-3"}),K.jsx("span",{className:"rf-text-xs rf-font-medium",children:"Up"})]})})]}),K.jsx(K_n,{className:"rf-overflow-visible rf-max-h-none",children:U?K.jsx(K.Fragment,{children:O.currentDirResults.length===0&&O.globalResults.length===0?K.jsxs(Xqe,{children:['No files found matching "',C,'".']}):K.jsxs(K.Fragment,{children:[O.currentDirResults.length>0&&K.jsx(Nee,{children:O.currentDirResults.map((ie,ne)=>K.jsxs(Ree,{value:`search-current:${ie.path}`,onSelect:()=>{d(ie.path),g(!1),e(ie.path)},className:Oi(ie.path===n&&"rf-font-medium","rf-group"),children:[K.jsx("span",{className:"rf-mr-2",children:oXe(ie.fileName)}),K.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[K.jsx("span",{className:"rf-truncate rf-flex-1",children:i(ie.fileName)}),K.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:p||"/"}),ie.path===n&&K.jsx(CS,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},ie.path))}),O.globalResults.length>0&&K.jsx(Nee,{children:O.globalResults.map(ie=>K.jsxs(Ree,{value:`search-global:${ie.path}`,onSelect:()=>{d(ie.path),g(!1),e(ie.path)},className:Oi(ie.path===n&&"rf-font-medium","rf-group"),children:[K.jsx("span",{className:"rf-mr-2",children:oXe(ie.fileName)}),K.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[K.jsx("span",{className:"rf-truncate rf-flex-1",children:i(ie.fileName)}),K.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:X_n(ie.path)}),ie.path===n&&K.jsx(CS,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},ie.path))})]})}):K.jsxs(K.Fragment,{children:[K.jsx(Xqe,{children:a}),k.length>0&&K.jsx(Nee,{children:k.map((ie,ne)=>K.jsxs(Ree,{value:`current:${ie.path}`,onSelect:()=>te(ie.path,ne),className:Oi(ie.path===n&&"rf-font-medium","rf-group"),children:[K.jsx("span",{className:"rf-mr-2",children:oXe(ie.name)}),i(ie.name),K.jsx("div",{className:"rf-ml-auto rf-flex rf-items-center rf-gap-1",children:K.jsx(CS,{className:Oi("rf-h-4 rf-w-4",ie.path===n?"rf-opacity-100":"rf-opacity-0")})})]},ie.path))}),R.length>0&&K.jsx(Nee,{children:R.map(ie=>K.jsxs(Ree,{value:`folder-${ie.path}`,onSelect:()=>Y(ie.path),className:"rf-text-slate-600 hover:rf-text-slate-900",children:[K.jsx(_bi,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-blue-600"}),ie.name,K.jsx(bT,{className:"rf-ml-auto rf-h-4 rf-w-4"})]},ie.path))}),k.length===0&&R.length===0&&K.jsx("div",{className:"rf-p-4 rf-text-center rf-text-slate-500 rf-text-sm",children:"No files or folders in this directory"})]})})]})})]})})},mWi=({files:t,onFileChange:e,currentFile:n})=>K.jsx(Z_n,{files:t,onFileChange:e,currentFile:n,fileFilter:()=>!0,placeholder:"Select circuit",searchPlaceholder:"Search for circuit file",emptyMessage:"No circuit files found in this directory."}),efn=t=>t!==null&&!["0","false","off","no"].includes(t.toLowerCase()),_Wi=({hash:t,search:e=""})=>{const n=new URLSearchParams(t.startsWith("#")?t.slice(1):t),o=new URLSearchParams(e.startsWith("?")?e.slice(1):e);return efn(n.get("gallery"))||efn(o.get("gallery"))},fWi=({hash:t,initialCircuitPath:e})=>{const n=new URLSearchParams(t.startsWith("#")?t.slice(1):t);return n.get("file")??n.get("main_component")??e??""},IWi=({hash:t,filePath:e})=>{const n=new URLSearchParams(t.startsWith("#")?t.slice(1):t);if(n.get("file")===e&&!n.has("gallery")&&(!n.has("main_component")||n.get("main_component")===e))return t.startsWith("#")?t:t?`#${t}`:"";n.delete("gallery"),n.set("file",e),n.has("main_component")&&n.set("main_component",e);const o=n.toString();return o?`#${o}`:""},CWi=(t,e=!1)=>{const[n,o]=ee.useState(()=>typeof window>"u"?t??"":fWi({hash:window.location.hash,initialCircuitPath:t})),[i,r]=ee.useState(()=>typeof window>"u"?e:e||_Wi({hash:window.location.hash,search:window.location.search})),s=ee.useCallback(l=>{if(typeof window>"u")return;const u=new URLSearchParams(window.location.hash.slice(1)),g=new URLSearchParams(window.location.search.slice(1));l?u.set("gallery","true"):(u.delete("gallery"),g.delete("gallery"));const h=g.toString(),d=u.toString();window.history.replaceState(null,"",`${window.location.pathname}${h?`?${h}`:""}${d?`#${d}`:""}`)},[]),a=ee.useCallback(()=>{r(!0),s(!0)},[s]),A=ee.useCallback(()=>{r(!1),s(!1)},[s]),c=ee.useCallback(l=>{if(typeof window>"u")return;const u=IWi({hash:window.location.hash,filePath:l}),g=new URLSearchParams(window.location.search.slice(1));g.delete("gallery");const h=g.toString(),d=`${window.location.pathname}${h?`?${h}`:""}${u}`;u===window.location.hash&&`${h?`?${h}`:""}`===window.location.search||window.history.replaceState(null,"",d)},[]);return{currentCircuitJsonPath:n,setCurrentCircuitJsonPath:o,updateFileHash:c,isGalleryVisible:i,showGallery:a,hideGallery:A}},yWi=t=>{const e=t.fileStaticAssetUrl,n=e.search(/[?#]/),o=n===-1?e:e.slice(0,n),i=n===-1?"":e.slice(n),r=o.includes("/")?o.slice(0,o.lastIndexOf("/")+1):"";return["3d.png","pcb.png","pcb.svg","schematic.png","schematic.svg"].map(s=>`${r}${s}${i}`)},tfn=t=>(t.split("/").pop()??t).replace(/(\.board|\.circuit)?\.(tsx|jsx|json)$/i,""),xWi=({fileRef:t})=>{const e=yWi(t),[n,o]=ee.useState(0);return n>=e.length?K.jsx("div",{className:"rf-flex rf-h-full rf-w-full rf-items-center rf-justify-center rf-bg-zinc-100 rf-text-zinc-400",children:K.jsx(Ibi,{className:"rf-h-8 rf-w-8","aria-hidden":"true"})}):K.jsx("img",{src:e[n],alt:`Preview of ${tfn(t.filePath)}`,className:"rf-h-full rf-w-full rf-object-contain rf-transition-transform rf-duration-200 group-hover:rf-scale-[1.03]",loading:"lazy",onError:()=>o(i=>i+1)})},EWi=({files:t,projectName:e,onSelectFile:n,onClose:o})=>(ee.useEffect(()=>{const i=r=>{r.key==="Escape"&&o()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[o]),K.jsx("main",{className:"rf-h-full rf-w-full rf-overflow-y-auto rf-bg-zinc-50",children:K.jsxs("div",{className:"rf-mx-auto rf-w-full rf-max-w-7xl rf-px-5 rf-py-8 sm:rf-px-8 sm:rf-py-10",children:[K.jsxs("div",{className:"rf-mb-7 rf-flex rf-items-start rf-justify-between rf-gap-4",children:[K.jsxs("div",{children:[K.jsx("p",{className:"rf-mb-1 rf-text-xs rf-font-medium rf-uppercase rf-tracking-wider rf-text-zinc-500",children:e??"tscircuit project"}),K.jsx("h1",{className:"rf-text-2xl rf-font-semibold rf-tracking-tight rf-text-zinc-950 sm:rf-text-3xl",children:"Circuit gallery"}),K.jsxs("p",{className:"rf-mt-2 rf-text-sm rf-text-zinc-600",children:["Explore ",t.length," ",t.length===1?"board":"boards",". Select one to open its interactive preview."]})]}),K.jsxs(fA,{type:"button",variant:"outline",onClick:o,children:[K.jsx(obi,{className:"rf-h-4 rf-w-4"}),"Back to circuit"]})]}),K.jsx("div",{className:"rf-grid rf-grid-cols-1 rf-gap-5 sm:rf-grid-cols-2 lg:rf-grid-cols-3",children:t.map(i=>K.jsxs("button",{type:"button",onClick:()=>n(i.filePath),className:"group rf-overflow-hidden rf-rounded-xl rf-border rf-border-zinc-200 rf-bg-white rf-text-left rf-shadow-sm rf-transition-all hover:rf--translate-y-0.5 hover:rf-border-zinc-300 hover:rf-shadow-md focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-900 focus-visible:rf-ring-offset-2",children:[K.jsx("div",{className:"rf-aspect-[4/3] rf-w-full rf-overflow-hidden rf-bg-white rf-p-3",children:K.jsx(xWi,{fileRef:i})}),K.jsxs("div",{className:"rf-border-t rf-border-zinc-100 rf-px-4 rf-py-3",children:[K.jsx("div",{className:"rf-truncate rf-text-sm rf-font-medium rf-text-zinc-900",children:tfn(i.filePath)}),K.jsx("div",{className:"rf-mt-0.5 rf-truncate rf-text-xs rf-text-zinc-500",children:i.filePath})]})]},i.filePath))})]})})),BWi=t=>t instanceof Error?t.message:"An unknown error occurred",bWi=t=>{mee();const{currentCircuitJsonPath:e,setCurrentCircuitJsonPath:n,updateFileHash:o,isGalleryVisible:i,showGallery:r,hideGallery:s}=CWi(t.initialCircuitPath,t.defaultToGallery),[a,A]=ee.useState(null),[c,l]=ee.useState(!1),[u,g]=ee.useState({}),[h,d]=ee.useState(new Set),[p,m]=ee.useState(new Set),_=t.files,f=_.map(S=>S.filePath),I=ee.useCallback(async S=>{if(!S.fileStaticAssetUrl)throw new Error(`No fileStaticAssetUrl provided for ${S.filePath}`);const Q=await fetch(S.fileStaticAssetUrl);if(!Q.ok)throw new Error(`Failed to fetch ${S.filePath}: ${Q.statusText}`);return await Q.json()},[]),C=ee.useCallback(async S=>{if(u[S]){A(u[S]),o(S),t.onCircuitJsonPathChange?.(S);return}if(p.has(S)){console.warn(`Skipping failed file: ${S}`),A(null);return}if(!h.has(S)){d(Q=>new Set(Q).add(S)),l(!0),A(null);try{const Q=_.find(k=>k.filePath===S);if(!Q)throw new Error(`File reference not found for ${S}`);const M=await(t.onFetchFile||I)(Q);g(k=>({...k,[S]:M})),A(M),o(S),t.onCircuitJsonPathChange?.(S),m(k=>{const R=new Set(k);return R.delete(S),R})}catch(Q){console.error(`Failed to load circuit JSON file ${S}:`,Q),m(w=>new Set(w).add(S)),A(null)}finally{d(Q=>{const w=new Set(Q);return w.delete(S),w}),l(!1)}}},[_,u,h,p,t.onFetchFile,t.onCircuitJsonPathChange,I,o]);ee.useEffect(()=>{if(f.length===0||i)return;let S=e;(!S||!f.includes(S))&&(S=Ifn(f)??f[0],n(S)),S&&f.includes(S)&&C(S)},[e,i]);const y=ee.useCallback(S=>{s(),n(S)},[s]),x=ee.useCallback(S=>{m(Q=>{const w=new Set(Q);return w.delete(S),w}),C(S)},[C]);if(f.length===0)return K.jsx("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full rf-items-center rf-justify-center",children:K.jsxs("div",{className:"rf-text-center rf-p-8",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-2",children:"No Circuit JSON Files Found"}),K.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Please provide circuit JSON files to view."})]})});if(i)return K.jsx(EWi,{files:_,projectName:t.projectName,onSelectFile:y,onClose:s});const E=f.length>1?K.jsxs(K.Fragment,{children:[K.jsx(mWi,{currentFile:e,files:f,onFileChange:y}),K.jsx(fA,{type:"button",variant:"outline",size:"icon",onClick:r,"aria-label":`Browse all ${f.length} circuits as a gallery`,title:"Open circuit gallery",children:K.jsx(mln,{className:"rf-h-4 rf-w-4"})})]}):null,B=p.has(e);return K.jsx(bE,{fallbackRender:({error:S})=>K.jsx("div",{className:"rf-mt-4 rf-mx-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Circuit JSON Preview"}),K.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:BWi(S)})]})}),children:B?K.jsxs("div",{className:"rf-w-full rf-h-full rf-flex rf-flex-col",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-w-full rf-p-4 rf-border-b rf-border-gray-200",children:[(t.showFileMenu??!0)&&K.jsx(Yfe,{isWebEmbedded:!0,circuitJson:null,projectName:t.projectName}),f.length>1&&K.jsx("div",{className:"rf-absolute rf-left-1/2 rf-transform rf--translate-x-1/2 rf-flex rf-items-center rf-gap-2",children:E})]}),K.jsx("div",{className:"rf-flex-1 rf-flex rf-items-center rf-justify-center",children:K.jsxs("div",{className:"rf-text-center rf-p-8",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-600 rf-mb-2",children:"Failed to Load Circuit File"}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-600 rf-mb-4",children:["Could not load: ",e]}),K.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-2",children:[K.jsx("button",{onClick:()=>x(e),className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600",children:"Retry"}),f.length>1&&K.jsx("p",{className:"rf-text-xs rf-text-gray-500",children:"Or select a different file from the dropdown above"})]})]})})]}):K.jsx(h_n,{circuitJson:a,defaultToFullScreen:t.defaultToFullScreen,showToggleFullScreen:t.showToggleFullScreen,showFileMenu:!1,isWebEmbedded:!1,projectName:t.projectName,defaultActiveTab:t.tabSelected,leftHeaderContent:K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-w-full",children:[(t.showFileMenu??!0)&&K.jsx(Yfe,{isWebEmbedded:!0,circuitJson:a,projectName:t.projectName}),f.length>1&&K.jsx("div",{className:`rf-absolute rf-left-1/2 rf-transform rf--translate-x-1/2 rf-flex rf-items-center rf-gap-2 ${c?"rf-opacity-50":""}`,children:E})]})})})},SWi=()=>{const t=md(e=>e.fsMap);ee.useEffect(()=>{if(!document||!t)return;const e=Array.from(t.keys()),n=Ifn(e),o=t.get("package.json");try{if(o){const i=JSON.parse(o);if(i?.name){document.title=i.name;return}}}catch{}n&&(document.title=n)},[t])},nfn=(t,e,n)=>{const o=t instanceof RegExp?ofn(t,n):t,i=e instanceof RegExp?ofn(e,n):e,r=o!==null&&i!=null&&QWi(o,i,n);return r&&{start:r[0],end:r[1],pre:n.slice(0,r[0]),body:n.slice(r[0]+o.length,r[1]),post:n.slice(r[1]+i.length)}},ofn=(t,e)=>{const n=e.match(t);return n?n[0]:null},QWi=(t,e,n)=>{let o,i,r,s,a,A=n.indexOf(t),c=n.indexOf(e,A+1),l=A;if(A>=0&&c>0){if(t===e)return[A,c];for(o=[],r=n.length;l>=0&&!a;){if(l===A)o.push(l),A=n.indexOf(t,l+1);else if(o.length===1){const u=o.pop();u!==void 0&&(a=[u,c])}else i=o.pop(),i!==void 0&&i<r&&(r=i,s=c),c=n.indexOf(e,l+1);l=A<c&&A>=0?A:c}o.length&&s!==void 0&&(a=[r,s])}return a},ifn="\0SLASH"+Math.random()+"\0",rfn="\0OPEN"+Math.random()+"\0",iXe="\0CLOSE"+Math.random()+"\0",sfn="\0COMMA"+Math.random()+"\0",afn="\0PERIOD"+Math.random()+"\0",vWi=new RegExp(ifn,"g"),wWi=new RegExp(rfn,"g"),PWi=new RegExp(iXe,"g"),MWi=new RegExp(sfn,"g"),DWi=new RegExp(afn,"g"),NWi=/\\\\/g,RWi=/\\{/g,TWi=/\\}/g,kWi=/\\,/g,FWi=/\\\./g,LWi=1e5,HWi=4e6,OWi=1e3,GWi=1e3;function rXe(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function YWi(t){return t.replace(NWi,ifn).replace(RWi,rfn).replace(TWi,iXe).replace(kWi,sfn).replace(FWi,afn)}function UWi(t){return t.replace(vWi,"\\").replace(wWi,"{").replace(PWi,"}").replace(MWi,",").replace(DWi,".")}function sXe(t,e){for(let n=0;n<e.length;n++)t.push(e[n])}function KWi(t){const e=[];let n="";for(;;){const o=nfn("{","}",t);if(!o){const A=t.split(",");return A[0]=n+A[0],sXe(e,A),e}const{pre:i,body:r,post:s}=o,a=i.split(",");if(a[0]=n+a[0],a[a.length-1]+="{"+r+"}",!s.length)return sXe(e,a),e;n=a.pop(),sXe(e,a),t=s}}function VWi(t,e={}){if(!t)return[];const{max:n=LWi,maxLength:o=HWi,maxDepth:i=OWi,maxRewrites:r=GWi}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),aXe(YWi(t),n,o,i,0,r,!0).map(UWi)}function zWi(t){return"{"+t+"}"}function JWi(t){return/^-?0\d/.test(t)}function WWi(t,e){return t<=e}function jWi(t,e){return t>=e}function kee(t,e,n,o,i,r){const s=[];let a=0;for(let A=0;A<t.length;A++)for(let c=0;c<n.length;c++){if(s.length>=o)return s;const l=t[A]+e+n[c];if(!(r&&!l)){if(a+l.length>i)return s;s.push(l),a+=l.length}}return s}function $Wi(t,e,n,o){const i=t.split(/\.\./),r=[];if(i[0]===void 0||i[1]===void 0)return r;const s=rXe(i[0]),a=rXe(i[1]),A=Math.max(i[0].length,i[1].length);let c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(rXe(i[2])),1):1,l=WWi;a<s&&(c*=-1,l=jWi);const g=i.some(JWi);let h=0;for(let d=s;l(d,a)&&r.length<n;d+=c){let p;if(e)p=String.fromCharCode(d),p==="\\"&&(p="");else if(p=String(d),g){const m=A-p.length;if(m>0){const _=new Array(m+1).join("0");d<0?p="-"+_+p.slice(1):p=_+p}}if(h+p.length>o)break;r.push(p),h+=p.length}return r}function aXe(t,e,n,o,i,r,s){if(i>o)return[t];let a=[""],A=0,c=!1,l=!0;for(;;){const u=nfn("{","}",t);if(!u)return kee(a,t,[""],e,n,c);const g=u.pre;if(/\$$/.test(g)){if(a=kee(a,g+"{"+u.body+"}",[""],e,n,c&&!u.post.length),l=!1,!u.post.length)break;t=u.post;continue}const h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(u.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(u.body),p=h||d,m=u.body.indexOf(",")>=0;if(!p&&!m){if(A<r&&u.post.match(/,(?!,).*\}/)){A++,t=u.pre+"{"+u.body+iXe+u.post,s=!0;continue}return kee(a,g+"{"+u.body+"}"+u.post,[""],e,n,c)}l&&(c=s&&!p,l=!1);let _;if(p)_=$Wi(u.body,d,e,n);else{let f=KWi(u.body);if(f.length===1&&f[0]!==void 0&&(f=aXe(f[0],e,n,o,i+1,r,!1).map(zWi),f.length===1)){if(a=kee(a,g+f[0],[""],e,n,c&&!u.post.length),!u.post.length)break;t=u.post;continue}let I=c&&!u.post.length&&!g;for(let y=0;I&&y<a.length;y++)a[y]&&(I=!1);_=[];let C=0;e:for(let y=0;y<f.length;y++){const x=aXe(f[y],e,n,o,i+1,r,!1);for(let E=0;E<x.length;E++){const B=x[E];if(!(I&&!B)){if(_.length>=e||C+B.length>n)break e;_.push(B),C+=B.length}}}}if(a=kee(a,g,_,e,n,c&&!u.post.length),!u.post.length)break;t=u.post}return a}const qWi=1024*64,Xfe=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>qWi)throw new TypeError("pattern is too long")},XWi={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Fee=t=>t.replace(/[[\]\\-]/g,"\\$&"),ZWi=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Afn=t=>t.join(""),eji=(t,e)=>{const n=e;if(t.charAt(n)!=="[")throw new Error("not in a brace expression");const o=[],i=[];let r=n+1,s=!1,a=!1,A=!1,c=!1,l=n,u="";e:for(;r<t.length;){const p=t.charAt(r);if((p==="!"||p==="^")&&r===n+1){c=!0,r++;continue}if(p==="]"&&s&&!A){l=r+1;break}if(s=!0,p==="\\"&&!A){A=!0,r++;continue}if(p==="["&&!A){for(const[m,[_,f,I]]of Object.entries(XWi))if(t.startsWith(m,r)){if(u)return["$.",!1,t.length-n,!0];r+=m.length,I?i.push(_):o.push(_),a=a||f;continue e}}if(A=!1,u){p>u?o.push(Fee(u)+"-"+Fee(p)):p===u&&o.push(Fee(p)),u="",r++;continue}if(t.startsWith("-]",r+1)){o.push(Fee(p+"-")),r+=2;continue}if(t.startsWith("-",r+1)){u=p,r+=2;continue}o.push(Fee(p)),r++}if(l<r)return["",!1,0,!1];if(!o.length&&!i.length)return["$.",!1,t.length-n,!0];if(i.length===0&&o.length===1&&/^\\?.$/.test(o[0])&&!c){const p=o[0].length===2?o[0].slice(-1):o[0];return[ZWi(p),!1,l-n,!1]}const g="["+(c?"^":"")+Afn(o)+"]",h="["+(c?"":"^")+Afn(i)+"]";return[o.length&&i.length?"("+g+"|"+h+")":o.length?g:h,a,l-n,!0]},Lee=(t,{windowsPathsNoEscape:e=!1,magicalBraces:n=!0}={})=>n?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var n3;const tji=new Set(["!","?","+","*","@"]),AXe=t=>tji.has(t),cfn=t=>AXe(t.type),nji=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),oji=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iji=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),lfn=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),rji="(?!(?:^|/)\\.\\.?(?:$|/))",Zfe="(?!\\.)",sji=new Set(["[","."]),aji=new Set(["..","."]),Aji=new Set("().*{}+?[]^$\\!"),cji=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),cXe="[^/]",ufn=cXe+"*?",gfn=cXe+"+?";let lji=0;class lXe{type;#o;#n;#i=!1;#t=[];#e;#s;#r;#c=!1;#a;#l;#g=!1;id=++lji;get depth(){return(this.#e?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#o.id,parent:this.#e?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(e,n,o={}){this.type=e,e&&(this.#n=!0),this.#e=n,this.#o=this.#e?this.#e.#o:this,this.#a=this.#o===this?o:this.#o.#a,this.#r=this.#o===this?[]:this.#o.#r,e==="!"&&!this.#o.#c&&this.#r.push(this),this.#s=this.#e?this.#e.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(const e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#l=this.#t.map(e=>String(e)).join("")}#d(){if(this!==this.#o)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let e;for(;e=this.#r.pop();){if(e.type!=="!")continue;let n=e,o=n.#e;for(;o;){for(let i=n.#s+1;!o.type&&i<o.#t.length;i++)for(const r of e.#t){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(o.#t[i])}n=o,o=n.#e}}return this}push(...e){for(const n of e)if(n!==""){if(typeof n!="string"&&!(n instanceof n3&&n.#e===this))throw new Error("invalid part: "+n);this.#t.push(n)}}toJSON(){const e=this.type===null?this.#t.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#t.map(n=>n.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#o||this.#o.#c&&this.#e?.type==="!")&&e.push({}),e}isStart(){if(this.#o===this)return!0;if(!this.#e?.isStart())return!1;if(this.#s===0)return!0;const e=this.#e;for(let n=0;n<this.#s;n++){const o=e.#t[n];if(!(o instanceof n3&&o.type==="!"))return!1}return!0}isEnd(){if(this.#o===this||this.#e?.type==="!")return!0;if(!this.#e?.isEnd())return!1;if(!this.type)return this.#e?.isEnd();const e=this.#e?this.#e.#t.length:0;return this.#s===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){const n=new n3(this.type,e);for(const o of this.#t)n.copyIn(o);return n}static#A(e,n,o,i,r){const s=i.maxExtglobRecursion??2;let a=!1,A=!1,c=-1,l=!1;if(n.type===null){let p=o,m="";for(;p<e.length;){const _=e.charAt(p++);if(a||_==="\\"){a=!a,m+=_;continue}if(A){p===c+1?(_==="^"||_==="!")&&(l=!0):_==="]"&&!(p===c+2&&l)&&(A=!1),m+=_;continue}else if(_==="["){A=!0,c=p,l=!1,m+=_;continue}if(!i.noext&&AXe(_)&&e.charAt(p)==="("&&r<=s){n.push(m),m="";const I=new n3(_,n);p=n3.#A(e,I,p,i,r+1),n.push(I);continue}m+=_}return n.push(m),p}let u=o+1,g=new n3(null,n);const h=[];let d="";for(;u<e.length;){const p=e.charAt(u++);if(a||p==="\\"){a=!a,d+=p;continue}if(A){u===c+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(u===c+2&&l)&&(A=!1),d+=p;continue}else if(p==="["){A=!0,c=u,l=!1,d+=p;continue}if(!i.noext&&AXe(p)&&e.charAt(u)==="("&&(r<=s||n&&n.#u(p))){const _=n&&n.#u(p)?0:1;g.push(d),d="";const f=new n3(p,g);g.push(f),u=n3.#A(e,f,u,i,r+_);continue}if(p==="|"){g.push(d),d="",h.push(g),g=new n3(null,n);continue}if(p===")")return d===""&&n.#t.length===0&&(n.#g=!0),g.push(d),d="",n.push(...h,g),u;d+=p}return n.type=null,n.#n=void 0,n.#t=[e.substring(o-1)],u}#m(e){return this.#_(e,oji)}#_(e,n=nji){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;const o=e.#t[0];return!o||typeof o!="object"||o.type===null?!1:this.#u(o.type,n)}#u(e,n=iji){return!!n.get(this.type)?.includes(e)}#h(e,n){const o=e.#t[0],i=new n3(null,o,this.options);i.#t.push(""),o.push(i),this.#p(e,n)}#p(e,n){const o=e.#t[0];this.#t.splice(n,1,...o.#t);for(const i of o.#t)typeof i=="object"&&(i.#e=this);this.#l=void 0}#C(e){return!!lfn.get(this.type)?.has(e)}#y(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;const n=e.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#C(n.type)}#x(e){const n=lfn.get(this.type),o=e.#t[0],i=n?.get(o.type);if(!i)return!1;this.#t=o.#t;for(const r of this.#t)typeof r=="object"&&(r.#e=this);this.type=i,this.#l=void 0,this.#g=!1}static fromGlob(e,n={}){const o=new n3(null,void 0,n);return n3.#A(e,o,0,n,0),o}toMMPattern(){if(this!==this.#o)return this.#o.toMMPattern();const e=this.toString(),[n,o,i,r]=this.toRegExpSource();if(!(i||this.#n||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return o;const a=(this.#a.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${n}$`,a),{_src:n,_glob:e})}get options(){return this.#a}toRegExpSource(e){const n=e??!!this.#a.dot;if(this.#o===this&&(this.#f(),this.#d()),!cfn(this)){const A=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),c=this.#t.map(h=>{const[d,p,m,_]=typeof h=="string"?n3.#E(h,this.#n,A):h.toRegExpSource(e);return this.#n=this.#n||m,this.#i=this.#i||_,d}).join("");let l="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&aji.has(this.#t[0]))){const d=sji,p=n&&d.has(c.charAt(0))||c.startsWith("\\.")&&d.has(c.charAt(2))||c.startsWith("\\.\\.")&&d.has(c.charAt(4)),m=!n&&!e&&d.has(c.charAt(0));l=p?rji:m?Zfe:""}let u="";return this.isEnd()&&this.#o.#c&&this.#e?.type==="!"&&(u="(?:$|\\/)"),[l+c+u,Lee(c),this.#n=!!this.#n,this.#i]}const o=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:";let r=this.#I(n);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){const A=this.toString(),c=this;return c.#t=[A],c.type=null,c.#n=void 0,[A,Lee(this.toString()),!1,!1]}let s=!o||e||n||!Zfe?"":this.#I(!0);s===r&&(s=""),s&&(r=`(?:${r})(?:${s})*?`);let a="";if(this.type==="!"&&this.#g)a=(this.isStart()&&!n?Zfe:"")+gfn;else{const A=this.type==="!"?"))"+(this.isStart()&&!n&&!e?Zfe:"")+ufn+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+r+A}return[a,Lee(r),this.#n=!!this.#n,this.#i]}#f(){if(cfn(this)){let e=0,n=!1;do{n=!0;for(let o=0;o<this.#t.length;o++){const i=this.#t[o];typeof i=="object"&&(i.#f(),this.#_(i)?(n=!1,this.#p(i,o)):this.#m(i)?(n=!1,this.#h(i,o)):this.#y(i)&&(n=!1,this.#x(i)))}}while(!n&&++e<10)}else for(const e of this.#t)typeof e=="object"&&e.#f();this.#l=void 0}#I(e){return this.#t.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");const[o,i,r,s]=n.toRegExpSource(e);return this.#i=this.#i||s,o}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#E(e,n,o=!1){let i=!1,r="",s=!1,a=!1;for(let A=0;A<e.length;A++){const c=e.charAt(A);if(i){i=!1,r+=(Aji.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,r+=o&&/^[*]+$/.test(e)?gfn:ufn,n=!0;continue}else a=!1;if(c==="\\"){A===e.length-1?r+="\\\\":i=!0;continue}if(c==="["){const[l,u,g,h]=eji(e,A);if(g){r+=l,s=s||u,A+=g-1,n=n||h;continue}}if(c==="?"){r+=cXe,n=!0;continue}r+=cji(c)}return[r,Lee(e),!!n,s]}}n3=lXe;const uji=(t,{windowsPathsNoEscape:e=!1,magicalBraces:n=!1}={})=>n?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var nK={env:{}};const d2=(t,e,n={})=>(Xfe(e),!n.nocomment&&e.charAt(0)==="#"?!1:new Hee(e,n).match(t)),gji=/^\*+([^+@!?*[(]*)$/,dji=t=>e=>!e.startsWith(".")&&e.endsWith(t),hji=t=>e=>e.endsWith(t),pji=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),mji=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),_ji=/^\*+\.\*+$/,fji=t=>!t.startsWith(".")&&t.includes("."),Iji=t=>t!=="."&&t!==".."&&t.includes("."),Cji=/^\.\*+$/,yji=t=>t!=="."&&t!==".."&&t.startsWith("."),xji=/^\*+$/,Eji=t=>t.length!==0&&!t.startsWith("."),Bji=t=>t.length!==0&&t!=="."&&t!=="..",bji=/^\?+([^+@!?*[(]*)?$/,Sji=([t,e=""])=>{const n=dfn([t]);return e?(e=e.toLowerCase(),o=>n(o)&&o.toLowerCase().endsWith(e)):n},Qji=([t,e=""])=>{const n=hfn([t]);return e?(e=e.toLowerCase(),o=>n(o)&&o.toLowerCase().endsWith(e)):n},vji=([t,e=""])=>{const n=hfn([t]);return e?o=>n(o)&&o.endsWith(e):n},wji=([t,e=""])=>{const n=dfn([t]);return e?o=>n(o)&&o.endsWith(e):n},dfn=([t])=>{const e=t.length;return n=>n.length===e&&!n.startsWith(".")},hfn=([t])=>{const e=t.length;return n=>n.length===e&&n!=="."&&n!==".."},pfn=typeof nK=="object"&&nK?typeof nK.env=="object"&&nK.env&&nK.env.__MINIMATCH_TESTING_PLATFORM__||nK.platform:"posix",mfn={win32:{sep:"\\"},posix:{sep:"/"}},Pji=pfn==="win32"?mfn.win32.sep:mfn.posix.sep;d2.sep=Pji;const kC=Symbol("globstar **");d2.GLOBSTAR=kC;const Mji="[^/]"+"*?",Dji="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Nji="(?:(?!(?:\\/|^)\\.).)*?",Rji=(t,e={})=>n=>d2(n,t,e);d2.filter=Rji;const x4=(t,e={})=>Object.assign({},t,e),Tji=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return d2;const e=d2;return Object.assign((o,i,r={})=>e(o,i,x4(t,r)),{Minimatch:class extends e.Minimatch{constructor(i,r={}){super(i,x4(t,r))}static defaults(i){return e.defaults(x4(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,r,s={}){super(i,r,x4(t,s))}static fromGlob(i,r={}){return e.AST.fromGlob(i,x4(t,r))}},unescape:(o,i={})=>e.unescape(o,x4(t,i)),escape:(o,i={})=>e.escape(o,x4(t,i)),filter:(o,i={})=>e.filter(o,x4(t,i)),defaults:o=>e.defaults(x4(t,o)),makeRe:(o,i={})=>e.makeRe(o,x4(t,i)),braceExpand:(o,i={})=>e.braceExpand(o,x4(t,i)),match:(o,i,r={})=>e.match(o,i,x4(t,r)),sep:e.sep,GLOBSTAR:kC})};d2.defaults=Tji;const _fn=(t,e={})=>(Xfe(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:VWi(t,{max:e.braceExpandMax}));d2.braceExpand=_fn;const kji=(t,e={})=>new Hee(t,e).makeRe();d2.makeRe=kji;const Fji=(t,e,n={})=>{const o=new Hee(e,n);return t=t.filter(i=>o.match(i)),o.options.nonull&&!t.length&&t.push(e),t};d2.match=Fji;const ffn=/[?*]|[+@!]\(.*?\)|\[|\]/,Lji=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class Hee{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,n={}){Xfe(e),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=e,this.platform=n.platform||pfn,this.isWindows=this.platform==="win32";const o="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[o]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const e of this.set)for(const n of e)if(typeof n!="string")return!0;return!1}debug(...e){}make(){const e=this.pattern,n=this.options;if(!n.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);const o=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(o),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){const A=r[0]===""&&r[1]===""&&(r[2]==="?"||!ffn.test(r[2]))&&!ffn.test(r[3]),c=/^[a-z]:/i.test(r[0]);if(A)return[...r.slice(0,4),...r.slice(4).map(l=>this.parse(l))];if(c)return[r[0],...r.slice(1).map(l=>this.parse(l))]}return r.map(A=>this.parse(A))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){const s=this.set[r];s[0]===""&&s[1]===""&&this.globParts[r][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(const o of e)for(let i=0;i<o.length;i++)o[i]==="**"&&(o[i]="*");const{optimizationLevel:n=1}=this.options;return n>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):n>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(n=>{let o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let i=o;for(;n[i+1]==="**";)i++;i!==o&&n.splice(o,i-o)}return n})}levelOneOptimize(e){return e.map(n=>(n=n.reduce((o,i)=>{const r=o[o.length-1];return i==="**"&&r==="**"?o:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(o.pop(),o):(o.push(i),o)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){const r=e[i];i===1&&r===""&&e[0]===""||(r==="."||r==="")&&(n=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(n=!0,e.pop())}let o=0;for(;(o=e.indexOf("..",o+1))!==-1;){const i=e[o-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(n=!0,e.splice(o-1,2),o-=2)}}while(n);return e.length===0?[""]:e}firstPhasePreProcess(e){let n=!1;do{n=!1;for(let o of e){let i=-1;for(;(i=o.indexOf("**",i+1))!==-1;){let s=i;for(;o[s+1]==="**";)s++;s>i&&o.splice(i+1,s-i);let a=o[i+1];const A=o[i+2],c=o[i+3];if(a!==".."||!A||A==="."||A===".."||!c||c==="."||c==="..")continue;n=!0,o.splice(i,1);const l=o.slice(0);l[i]="**",e.push(l),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<o.length-1;s++){const a=o[s];s===1&&a===""&&o[0]===""||(a==="."||a==="")&&(n=!0,o.splice(s,1),s--)}o[0]==="."&&o.length===2&&(o[1]==="."||o[1]==="")&&(n=!0,o.pop())}let r=0;for(;(r=o.indexOf("..",r+1))!==-1;){const s=o[r-1];if(s&&s!=="."&&s!==".."&&s!=="**"){n=!0;const A=r===1&&o[r+1]==="**"?["."]:[];o.splice(r-1,2,...A),o.length===0&&o.push(""),r-=2}}}}while(n);return e}secondPhasePreProcess(e){for(let n=0;n<e.length-1;n++)for(let o=n+1;o<e.length;o++){const i=this.partsMatch(e[n],e[o],!this.preserveMultipleSlashes);if(i){e[n]=[],e[o]=i;break}}return e.filter(n=>n.length)}partsMatch(e,n,o=!1){let i=0,r=0,s=[],a="";for(;i<e.length&&r<n.length;)if(e[i]===n[r])s.push(a==="b"?n[r]:e[i]),i++,r++;else if(o&&e[i]==="**"&&n[r]===e[i+1])s.push(e[i]),i++;else if(o&&n[r]==="**"&&e[i]===n[r+1])s.push(n[r]),r++;else if(e[i]==="*"&&n[r]&&(this.options.dot||!n[r].startsWith("."))&&n[r]!=="**"){if(a==="b")return!1;a="a",s.push(e[i]),i++,r++}else if(n[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",s.push(n[r]),i++,r++}else return!1;return e.length===n.length&&s}parseNegate(){if(this.nonegate)return;const e=this.pattern;let n=!1,o=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)n=!n,o++;o&&(this.pattern=e.slice(o)),this.negate=n}matchOne(e,n,o=!1){let i=0,r=0;if(this.isWindows){const a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),A=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),c=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),l=!c&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),u=A?3:a?0:void 0,g=l?3:c?0:void 0;if(typeof u=="number"&&typeof g=="number"){const[h,d]=[e[u],n[g]];h.toLowerCase()===d.toLowerCase()&&(n[g]=h,r=g,i=u)}}const{optimizationLevel:s=1}=this.options;return s>=2&&(e=this.levelTwoFileOptimize(e)),n.includes(kC)?this.#o(e,n,o,i,r):this.#i(e,n,o,i,r)}#o(e,n,o,i,r){const s=n.indexOf(kC,r),a=n.lastIndexOf(kC),[A,c,l]=o?[n.slice(r,s),n.slice(s+1),[]]:[n.slice(r,s),n.slice(s+1,a),n.slice(a+1)];if(A.length){const f=e.slice(i,i+A.length);if(!this.#i(f,A,o,0,0))return!1;i+=A.length,r+=A.length}let u=0;if(l.length){if(l.length+i>e.length)return!1;let f=e.length-l.length;if(this.#i(e,l,o,f,0))u=l.length;else{if(e[e.length-1]!==""||i+l.length===e.length||(f--,!this.#i(e,l,o,f,0)))return!1;u=l.length+1}}if(!c.length){let f=!!u;for(let I=i;I<e.length-u;I++){const C=String(e[I]);if(f=!0,C==="."||C===".."||!this.options.dot&&C.startsWith("."))return!1}return o||f}const g=[[[],0]];let h=g[0],d=0;const p=[0];for(const f of c)f===kC?(p.push(d),h=[[],0],g.push(h)):(h[0].push(f),d++);let m=g.length-1;const _=e.length-u;for(const f of g)f[1]=_-(p[m--]+f[0].length);return!!this.#n(e,g,i,0,o,0,!!u)}#n(e,n,o,i,r,s,a){const A=n[i];if(!A){for(let u=o;u<e.length;u++){a=!0;const g=e[u];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}const[c,l]=A;for(;o<=l;){if(this.#i(e.slice(0,o+c.length),c,r,o,0)&&s<this.maxGlobstarRecursion){const h=this.#n(e,n,o+c.length,i+1,r,s+1,a);if(h!==!1)return h}const g=e[o];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;o++}return r||null}#i(e,n,o,i,r){let s,a,A,c;for(s=i,a=r,c=e.length,A=n.length;s<c&&a<A;s++,a++){this.debug("matchOne loop");let l=n[a],u=e[s];if(this.debug(n,l,u),l===!1||l===kC)return!1;let g;if(typeof l=="string"?(g=u===l,this.debug("string match",l,u,g)):(g=l.test(u),this.debug("pattern match",l,u,g)),!g)return!1}if(s===c&&a===A)return!0;if(s===c)return o;if(a===A)return s===c-1&&e[s]==="";throw new Error("wtf?")}braceExpand(){return _fn(this.pattern,this.options)}parse(e){Xfe(e);const n=this.options;if(e==="**")return kC;if(e==="")return"";let o,i=null;(o=e.match(xji))?i=n.dot?Bji:Eji:(o=e.match(gji))?i=(n.nocase?n.dot?mji:pji:n.dot?hji:dji)(o[1]):(o=e.match(bji))?i=(n.nocase?n.dot?Qji:Sji:n.dot?vji:wji)(o):(o=e.match(_ji))?i=n.dot?Iji:fji:(o=e.match(Cji))&&(i=yji);const r=lXe.fromGlob(e,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const e=this.set;if(!e.length)return this.regexp=!1,this.regexp;const n=this.options,o=n.noglobstar?Mji:n.dot?Dji:Nji,i=new Set(n.nocase?["i"]:[]);let r=e.map(A=>{const c=A.map(u=>{if(u instanceof RegExp)for(const g of u.flags.split(""))i.add(g);return typeof u=="string"?Lji(u):u===kC?kC:u._src});c.forEach((u,g)=>{const h=c[g+1],d=c[g-1];u!==kC||d===kC||(d===void 0?h!==void 0&&h!==kC?c[g+1]="(?:\\/|"+o+"\\/)?"+h:c[g]=o:h===void 0?c[g-1]=d+"(?:\\/|\\/"+o+")?":h!==kC&&(c[g-1]=d+"(?:\\/|\\/"+o+"\\/)"+h,c[g+1]=kC))});const l=c.filter(u=>u!==kC);if(this.partial&&l.length>=1){const u=[];for(let g=1;g<=l.length;g++)u.push(l.slice(0,g).join("/"));return"(?:"+u.join("|")+")"}return l.join("/")}).join("|");const[s,a]=e.length>1?["(?:",")"]:["",""];r="^"+s+r+a+"$",this.partial&&(r="^(?:\\/|"+s+r.slice(1,-1)+a+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,n=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&n)return!0;const o=this.options;this.isWindows&&(e=e.split("\\").join("/"));const i=this.slashSplit(e);this.debug(this.pattern,"split",i);const r=this.set;this.debug(this.pattern,"set",r);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(const a of r){let A=i;if(o.matchBase&&a.length===1&&(A=[s]),this.matchOne(A,a,n))return o.flipNegate?!0:!this.negate}return o.flipNegate?!1:this.negate}static defaults(e){return d2.defaults(e).Minimatch}}d2.AST=lXe,d2.Minimatch=Hee,d2.escape=uji,d2.unescape=Lee;const Hji=t=>(t.endsWith(".tsx")||t.endsWith(".ts")||t.endsWith(".jsx")||t.endsWith(".js")||$fe(t))&&!t.endsWith(".d.ts"),Oji=t=>{if(!t)return null;try{const e=JSON.parse(t);return LDn.parse(e)}catch(e){return console.warn("Failed to parse tscircuit.config.json",e),null}},Gji=(t,e)=>{const o=Oji(e)?.includeBoardFiles?.filter(Boolean);if(o&&o.length>0){const i=o.map(r=>new Hee(r,{dot:!0}));return t.filter(r=>i.some(s=>s.match(r)))}return t.filter(Hji)},uXe=vc("run-frame:RunFrameWithApi"),Yji=()=>{const e=!!md(o=>o.error),n=e?"Dev server disconnected":"Dev server connected";return K.jsx(Fqe,{children:K.jsxs(Lqe,{children:[K.jsx(Hqe,{asChild:!0,children:K.jsx("button",{type:"button","aria-label":n,className:"rf-inline-flex rf-items-center rf-justify-center rf-p-2 rf-rounded-full rf-outline-none",children:K.jsx("span",{className:Oi("rf-inline-flex rf-size-2 rf-rounded-full rf-flex-shrink-0",e?"rf-bg-red-600":"rf-bg-green-600 rf-opacity-50"),"aria-hidden":"true"})})}),K.jsx(Kfe,{side:"right",children:n})]})})},Ifn=t=>t.find(e=>e.includes("entrypoint."))??t.find(e=>e.includes("index."))??t.find(e=>e.includes("main."))??t.find(e=>e.endsWith(".tsx")),Uji=t=>t.find(e=>e.includes("manual-edits."))??t.find(e=>e.includes("manual-edit."))??t.find(e=>e.endsWith(".json")),Cfn=t=>{const{apiBaseUrl:e,leftHeaderContent:n}=t;ee.useEffect(()=>{t.debug&&vc.enable("run-frame*")},[t.debug]);const o=md(k=>k.startPolling),i=md(k=>k.stopPolling),r=md(k=>k.setCurrentMainComponentPath),s=md(k=>k.pushEvent),a=zFo(),A=md(k=>k.fsMap),c=md(k=>k.recentlySavedFiles),l=ee.useMemo(()=>Array.from(A.keys()),[A]),u=ee.useMemo(()=>{const k=A.get("tscircuit.config.json");return typeof k=="string"?k:void 0},[A]),g=ee.useMemo(()=>Gji(l,u),[l,u]),h=md(k=>k.circuitJson),[d,p]=ee.useState(()=>typeof window>"u"?t.initialMainComponentPath??"":new URLSearchParams(window.location.hash.slice(1)).get("file")??t.initialMainComponentPath??""),[m,_]=OO("runframe:favorites",[]),f=!a,I=ee.useCallback(k=>{_(R=>R.includes(k)?R.filter(F=>F!==k):[...R,k])},[_]),C=t.fileFilter??aJi,y=ee.useMemo(()=>g.filter(C),[g,C]);ee.useEffect(()=>{if(d&&(y.includes(d)||g.includes(d)))return;if(d){const U=d.includes("/")?d.substring(0,d.lastIndexOf("/")):"",Y=y.find(W=>(W.includes("/")?W.substring(0,W.lastIndexOf("/")):"")===U);if(Y){p(Y);return}}const k=window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,R=[t.initialMainComponentPath,k].filter(U=>!!U);for(const U of R)if(y.includes(U)){p(U);return}const O=(y.length>0?y:g)[0];O&&p(O)},[y,g,t.initialMainComponentPath,d]);const x=ee.useCallback(k=>{if(typeof window>"u")return;const R=new URLSearchParams(window.location.hash.slice(1));if(R.get("file")===k)return;R.set("file",k);const F=R.toString(),O=`${window.location.pathname}${window.location.search}${F.length>0?`#${F}`:""}`;window.history.replaceState(null,"",O)},[]);ee.useEffect(()=>{d&&(x(d),t.onMainComponentPathChange?.(d),r(d))},[d,t.onMainComponentPathChange,x,r]),SWi();const{editEventsForRender:E,pushEditEvent:B,markRenderStarted:S,markRenderComplete:Q}=VFo();ee.useEffect(()=>{e&&(window.TSCIRCUIT_FILESERVER_API_BASE_URL=e)},[e]),ee.useEffect(()=>(o(),()=>i()),[o,i]);const w=ee.useMemo(()=>String(d).length>0?{mainComponentPath:d}:{},[d]),M=ee.useCallback(async k=>{try{await s({event_type:"RUN_COMPLETED",initiator:"runframe",...k})}catch(R){uXe("Failed to push RUN_COMPLETED event",R)}},[s]);return K.jsx(P_n,{fsMap:A,showFileMenu:t.showFileMenu,shouldLoadLatestEval:t.shouldLoadLatestEval,onChangeShouldLoadLatestEval:t.onChangeShouldLoadLatestEval,isCli:t.isCli,schematicSvgOptions:t.schematicSvgOptions,isLoadingFiles:f,evalVersion:t.evalVersion,forceLatestEvalVersion:t.forceLatestEvalVersion,evalWebWorkerBlobUrl:t.evalWebWorkerBlobUrl??t.workerBlobUrl,platformConfig:t.platformConfig,enableFetchProxy:t.enableFetchProxy,leftHeaderContent:K.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-w-full",children:[K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[t.leftHeaderContent,K.jsx(Yji,{})]}),t.showFilesSwitch&&K.jsx("div",{className:"rf-absolute rf-left-1/2 rf-transform rf--translate-x-1/2",children:K.jsx(Z_n,{currentFile:d,files:y,onFileChange:k=>{typeof A.get(k)=="string"&&p(k)},pinnedFiles:m,onToggleFavorite:I,fileFilter:C,recentlySavedFiles:c})})]}),defaultToFullScreen:t.defaultToFullScreen,showToggleFullScreen:t.showToggleFullScreen,onInitialRender:()=>{uXe("onInitialRender / markRenderStarted"),S()},onRenderFinished:()=>{uXe("onRenderFinished / markRenderComplete"),Q()},onRunCompleted:M,editEvents:E,onEditEvent:k=>{B(k),fetch(`${QC}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_type:"USER_CREATED_MANUAL_EDIT",...k})});const R=Uji(Array.from(A.keys()))??"manual-edits.json",F=A.get(R),O=JSON.parse(F??"{}");VRt({circuitJson:h,editEvents:[k],manualEditsFile:O}),fetch(`${QC}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:R,text_content:JSON.stringify(O),initiator:"runframe"})})},onLoginRequired:t.onLoginRequired,easyEdaProxyConfig:{proxyEndpointUrl:`${QC}/proxy`},...w})},Kji=()=>new Promise(t=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t()}),Vji=()=>{const t=window.location.hash.slice(1),n=new URLSearchParams(t).get("tab")?.toLowerCase()?.trim();return n&&["pcb","schematic","cad"].includes(n)?n:"pcb"},zji=()=>{const t=document.getElementById("root");if(t)return t;const e=document.createElement("div");return e.id="root",e.style.height="100vh",document.body.appendChild(e),e},Jji=async()=>{const t=Array.from(document.querySelectorAll("script[type='tscircuit-tsx']")),e=new Map;return await Promise.all(t.map(async(n,o)=>{const i=n.dataset.path||n.getAttribute("data-file-path")||`script${o?o+1:""}.tsx`;if(n.src){const s=await(await fetch(n.src)).text();e.set(i,s)}else e.set(i,n.textContent||"")})),{fsMap:e}},yfn="<--INJECT_TSCIRCUIT_EVAL_WEB_WORKER_BLOB_URL-->",gXe={evalWebWorkerBlobUrl:yfn.includes("<--")?void 0:yfn,enableFetchProxy:"<--INJECT_ENABLE_FETCH_PROXY-->".includes("<--")?void 0:!0};(async()=>{await Kji();const t=H4n.createRoot(zji()),e=window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST,n=window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,o=window.TSCIRCUIT_PACKAGE_NAME;if(Array.isArray(e)){const i=Vji();t.render(K.jsx(bWi,{files:e,initialCircuitPath:n,tabSelected:i,projectName:o}))}else if(window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI)t.render(K.jsx(yJi,{...gXe}));else{const{fsMap:i}=await Jji();i.size>0?t.render(K.jsx(P_n,{...gXe,fsMap:i})):t.render(K.jsx(Cfn,{...gXe}))}})();const xfn=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));var Wji=0,o8=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(t={}){this.hasExplicitNodeId=t.nodeId!==void 0,this._nodeId=t.nodeId??Efn(t.sourceLocation,this.constructor.name)??`altium-node-${(++Wji).toString(36)}`,this._sourceLocation=t.sourceLocation}get document(){let t=this;for(;t.parent;)t=t.parent;return t}get nodeId(){return this._nodeId}get isDirty(){return this._dirty}get parent(){return this._parent}get revision(){return this._revision}get sourceLocation(){return this._sourceLocation}setParent(t){return this._parent=t,this}setSourceLocation(t){return this._sourceLocation=t,this.hasExplicitNodeId||(this._nodeId=Efn(t,this.constructor.name)??this._nodeId),this}adoptChildren(t){for(const e of t)e.setParent(this)}markDirty(){this._dirty=!0,this._revision++,this.parent?.markDirty()}clearDirty(t=!1){if(this._dirty=!1,t)for(const e of this.getChildren())e.clearDirty(!0)}*walk(t=!0){t&&(yield this);for(const e of this.getChildren())yield*e.walk(!0)}visit(t){const e=(n,o,i)=>{if(t(n,{depth:i,parent:o})!==!1)for(const s of n.getChildren())e(s,n,i+1)};e(this,this.parent,0)}findAll(t,e=!0){return[...this.walk(e)].filter(t)}deepEquals(t){if(this.type!==t.type||this.getString()!==t.getString())return!1;const e=this.getChildren(),n=t.getChildren();return e.length===n.length&&e.every((o,i)=>{const r=n[i];return r!==void 0&&o.deepEquals(r)})}getStructuralHash(){let t=2166136261;const e=`${this.type}\0${this.getString()}`;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,text:this.getString(),children:this.getChildren().map(t=>t.toJSON())}}};function Efn(t,e){if(!t)return;const n=t.streamPath!==void 0?[t.streamPath,t.recordIndex??"",t.fieldIndex??"",t.byteOffset??""].join(":"):t.startOffset!==void 0?`text:${t.startOffset}`:t.byteOffset!==void 0?`byte:${t.byteOffset}`:void 0;return n===void 0?void 0:`${n}:${e}`}var ek=class extends Error{code;constructor(t,e="ALTIUM_ERROR",n){super(t,n),this.name=new.target.name,this.code=e}},eM=class extends ek{excerpt;fieldName;location;recordKind;constructor(t,e={}){super(t,"ALTIUM_SYNTAX",{cause:e.cause}),this.excerpt=e.excerpt,this.fieldName=e.fieldName,this.location=e.location,this.recordKind=e.recordKind}},yI=class extends ek{constructor(t,e){super(t,"ALTIUM_FORMAT_DETECTION",e)}},aA=class extends ek{byteOffset;constructor(t,e={}){super(t,"ALTIUM_CORRUPT_CONTAINER",{cause:e.cause}),this.byteOffset=e.byteOffset}},jji=class extends ek{constructor(t,e){super(t,"ALTIUM_UNSUPPORTED_VERSION",e)}},dXe=class extends ek{constructor(t,e){super(t,"ALTIUM_UNSUPPORTED_FEATURE",e)}},Yg=class extends ek{constructor(t,e){super(t,"ALTIUM_SERIALIZATION",e)}},hh=class extends ek{byteOffset;constructor(t,e,n){super(t,"ALTIUM_TRUNCATED_RECORD",n),this.byteOffset=e}},$ji=class extends o8{type="embedded-model";index;record;stream;constructor(t){super({sourceLocation:t.stream.sourceLocation}),this.index=t.index,this.record=t.record,this.stream=t.stream}get compressedSize(){return this.stream.metadata.size}get isCompressedDataLoaded(){return this.stream.isContentLoaded}getCompressedBytes(){return this.stream.content.slice()}async getDecompressedBytes(t={}){return qji(this.stream.content,t)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function qji(t,e={}){const n=e.maximumOutputSize??67108864;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maximumOutputSize must be a positive safe integer number of bytes");const o=[];let i=0;try{const a=new Lce(c=>{if(i+=c.byteLength,i>n)throw new aA(`Embedded model expands beyond the ${n}-byte limit`);o.push(c)}),A=64*1024;for(let c=0;c<t.byteLength;){const l=Math.min(c+A,t.byteLength);a.push(t.subarray(c,l),l===t.byteLength),c=l}}catch(a){throw a instanceof aA?a:new aA(`Embedded model zlib decompression failed: ${a instanceof Error?a.message:String(a)}`)}const r=new Uint8Array(i);let s=0;for(const a of o)r.set(a,s),s+=a.byteLength;return r}function xI(t){if(!Number.isFinite(t))return t;const e=(t%360+360)%360;return Object.is(e,-0)?0:e}function hXe(t,e,n=1e-9){return Math.abs(t.x-e.x)<=n&&Math.abs(t.y-e.y)<=n}function Xji(t){if(t.length===0)return;let e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of t)!Number.isFinite(r.x)||!Number.isFinite(r.y)||(e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x),i=Math.max(i,r.y));return Number.isFinite(e)?{minX:e,minY:n,maxX:o,maxY:i}:void 0}function Zji(t){if(t.length<3)return 0;let e=0;for(let n=0;n<t.length;n++){const o=t[n],i=t[(n+1)%t.length];!o||!i||(e+=o.x*i.y-i.x*o.y)}return e/2}function e$i(t){const e=Zji(t);return Math.abs(e)<=Number.EPSILON?"degenerate":e<0?"clockwise":"counterclockwise"}var pXe=class extends o8{terminator;constructor(t={}){super(t),this.terminator=t.terminator??""}},a9=class extends o8{type="field";_key;_value;constructor(t){super(t),Bfn(t.key),bfn(t.value??""),this._key=t.key,this._value=t.value??""}get key(){return this._key}set key(t){Bfn(t),t!==this._key&&(this._key=t,this.markDirty())}get value(){return this._value}set value(t){bfn(t),t!==this._value&&(this._value=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.key}=${this.value}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,key:this.key,value:this.value}}};function Bfn(t){if(t.length===0||/[=|\r\n]/u.test(t))throw new Error(`Invalid Altium field key: ${JSON.stringify(t)}`)}function bfn(t){if(/[|\r\n]/u.test(t))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(t)}`)}var t$i={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},n$i=/^([+-]?(?:\d+\.\d*|\d+|\.\d+)(?:e[+-]?\d+)?)([a-z]+)?$/iu,Oee=class S4n{unit;value;#o;constructor(e){if(!Number.isFinite(e.value))throw new RangeError("Altium measurement value must be finite");this.value=e.value,this.unit=e.unit,this.#o=e.raw??`${r$i(e.value)}${e.unit===void 0?"":e.unit}`}static parse(e){const n=n$i.exec(e.trim());if(!n?.[1])return;const o=Number(n[1]);if(Number.isFinite(o))return new S4n({raw:e,unit:n[2],value:o})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#o}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(t$i[this.normalizedUnit]??1)}toMillimeters(){return this.toMils()*.0254}to(e){const n=this.toMils();return e==="mil"?n:e==="mm"?n*.0254:e==="cm"?n*.00254:n/1e3}equals(e,n=0){return Math.abs(this.toMils()-e.toMils())<=n}toString(){return this.raw}toJSON(){return{raw:this.raw,unit:this.unit,value:this.value}}};function oK(t){return t===void 0?void 0:Oee.parse(t)}function Gee(t){return oK(t)?.toMils()}function o$i(t,e="mil"){if(t instanceof Oee)return t;if(typeof t=="string"){const n=Oee.parse(t);if(!n)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(t)}`);return n}return typeof t=="number"?new Oee({unit:e,value:t}):new Oee(t)}function i$i(t,e="mil"){return o$i(t,e).toString()}function r$i(t){return Object.is(t,-0)?"-0":String(t)}var Ol=class extends pXe{type="record";items;_originalBinaryPayload;constructor(t={}){super(t),this.items=t.items??[],this._originalBinaryPayload=t.originalBinaryPayload?.slice(),this.adoptChildren(this.items)}get originalBinaryPayload(){return this._originalBinaryPayload?.slice()}setOriginalBinaryPayload(t){return this._originalBinaryPayload=t?.slice(),this}getAltiumMeasurement(t){return oK(this.getCaseInsensitive(t))}get recordKind(){return this.get("RECORD")}get fields(){return this.items.filter(t=>t instanceof a9)}get(t){return this.fields.find(e=>e.key===t)?.value}getCaseInsensitive(t){const e=t.toUpperCase();return this.fields.find(n=>n.key.toUpperCase()===e)?.value}getDecoded(t){const e=this.getCaseInsensitive(`%UTF8%${t}`);return e===void 0?this.getCaseInsensitive(t):A$i(e)}getAll(t){return this.fields.filter(e=>e.key===t).map(e=>e.value)}getFirstField(t){return this.fields.find(e=>e.key===t)}getLastField(t){return this.fields.findLast(e=>e.key===t)}getAllFields(t){return this.fields.filter(e=>e.key===t)}getBoolean(t){const e=this.getCaseInsensitive(t)?.toUpperCase();if(e==="TRUE"||e==="T")return!0;if(e==="FALSE"||e==="F")return!1}getNumber(t){const e=this.getCaseInsensitive(t);if(!(e===void 0||!s$i(e)))return Number(e)}getMeasurement(t){const e=this.getCaseInsensitive(t);if(e===void 0)return;const n=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*([a-z]+)?\s*$/iu.exec(e);if(!n?.[1])return;const o=n[2];return o===void 0?{value:Number(n[1])}:{value:Number(n[1]),unit:o}}set(t,e){const n=this.fields.find(o=>o.key===t);if(n)n.value=e;else{const o=new a9({key:t,value:e}).setParent(this);this.items.push(o),this.markDirty()}return this}setMeasurement(t,e,n="mil"){return this.set(t,i$i(e,n))}setPoint(t,e,n="mil"){return this.setMeasurement(t.x,e.x,n),this.setMeasurement(t.y,e.y,n),this}setSize(t,e,n="mil"){return this.setMeasurement(t.width,e.width,n),this.setMeasurement(t.height,e.height,n),this}setAngle(t,e){if(!Number.isFinite(e))throw new RangeError("Altium angles must be finite");return this.set(t,String(xI(e)))}insertField(t,e,n={}){const o=new a9({key:t,value:e}).setParent(this);let i=n.index;if(i===void 0&&n.beforeKey!==void 0&&(i=this.items.findIndex(s=>s instanceof a9&&s.key===n.beforeKey)),i===void 0&&n.afterKey!==void 0){const s=this.items.findLastIndex(a=>a instanceof a9&&a.key===n.afterKey);i=s<0?this.items.length:s+1}const r=i===void 0?this.items.length:Math.min(Math.max(i,0),this.items.length);return this.items.splice(r,0,o),this.markDirty(),o}replaceFieldOccurrence(t,e,n){if(!Number.isInteger(e)||e<0)return!1;const o=this.getAllFields(t)[e];return o?(o.value=n,!0):!1}delete(t){const e=this.items.length;this.items=this.items.filter(o=>!(o instanceof a9&&o.key===t));const n=e-this.items.length;return n>0&&this.markDirty(),n}getChildren(){return[...this.items]}getString(){return`|${this.items.map(t=>t.getString()).join("|")}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,recordKind:this.recordKind,originalBinaryPayloadLength:this._originalBinaryPayload?.byteLength,fields:this.fields.map(t=>({key:t.key,value:t.value})),items:this.items.map(t=>t.toJSON())}}};function s$i(t){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu.test(t.trim())}var a$i=new Map([["€",128],["‚",130],["ƒ",131],["„",132],["…",133],["†",134],["‡",135],["ˆ",136],["‰",137],["Š",138],["‹",139],["Œ",140],["Ž",142],["‘",145],["’",146],["“",147],["”",148],["•",149],["–",150],["—",151],["˜",152],["™",153],["š",154],["›",155],["œ",156],["ž",158],["Ÿ",159]]);function A$i(t){const e=[];for(const n of t){const o=a$i.get(n);if(o!==void 0){e.push(o);continue}const i=n.codePointAt(0);if(i===void 0||i>255)return t;e.push(i)}try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(e))}catch{return t}}function tc(t,...e){for(const n of e){const o=Gee(t.getCaseInsensitive(n));if(o!==void 0)return o}}function qh(t,e,n){const o=tc(t,...e),i=tc(t,...n);return o===void 0||i===void 0?void 0:{x:o,y:i}}function Yee(t,e,n){const o=tc(t,...e),i=tc(t,...n);return o===void 0||i===void 0?void 0:{width:o,height:i}}function pi(t,...e){for(const n of e){const o=t.getDecoded(n);if(o!==void 0)return o}}function c$i(t,...e){for(const n of e){const o=t.getNumber(n);if(o!==void 0)return o}}var e1e=class extends Ol{type="component-record";constructor(t={}){super(t)}get id(){return this.getNumber("ID")}get designator(){return pi(this,"SOURCEDESIGNATOR","DESIGNATOR")}get comment(){return pi(this,"SOURCECOMMENT","COMMENT")}get footprint(){return pi(this,"PATTERN","FOOTPRINT")}get footprintLibrary(){return pi(this,"SOURCEFOOTPRINTLIBRARY")}get sourceLibrary(){return pi(this,"SOURCECOMPONENTLIBRARY")}get sourceLibraryReference(){return pi(this,"SOURCELIBREFERENCE")}get sourceUniqueId(){return pi(this,"SOURCEUNIQUEID")}get sourceHierarchicalPath(){return pi(this,"SOURCEHIERARCHICALPATH")}get position(){return qh(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}get rotation(){return xI(this.getNumber("ROTATION")??0)}get side(){const t=this.getCaseInsensitive("LAYER")?.toUpperCase();return t==="TOP"||t==="TOP LAYER"?"top":t==="BOTTOM"||t==="BOTTOM LAYER"?"bottom":"unknown"}get mirrored(){return this.side==="bottom"}get locked(){return this.getBoolean("LOCKED")}get selected(){return this.getBoolean("SELECTION")}get unionIndex(){return this.getNumber("UNIONINDEX")}get channelOffset(){return this.getNumber("CHANNELOFFSET")}get heightMils(){return tc(this,"HEIGHT")}getOwnedPrimitives(t){return t.getRecordsOwnedByComponent(this)}getBounds(t,e){return t.getComponentBounds(this,e)}},t1e=class extends Ol{type="net-record";constructor(t={}){super(t)}get id(){return this.getNumber("ID")}get name(){return pi(this,"NAME")}get visible(){return this.getBoolean("VISIBLE")}get color(){return this.getNumber("COLOR")}},l$i=65535,Sfn=new WeakMap,u$i=class{constructor(t){this.document=t,this.components=t.getRecordsByKind("Component").filter(e=>e instanceof e1e),this.nets=t.getRecordsByKind("Net").filter(e=>e instanceof t1e),this.polygons=t.getRecordsByKind("Polygon"),this.rules=[...t.getRecordsByKind("Rule"),...t.getRecordsByKind("DXPRule")],this.componentTargets=o1e(this.components),this.netTargets=o1e(this.nets),this.polygonTargets=o1e(this.polygons),this.ruleTargets=o1e(this.rules);for(const e of t.records){fXe(this.byKind,e.recordKind??"Unknown",e);const n=e.getDecoded("LAYER");n!==void 0&&fXe(this.byLayer,n.toUpperCase(),e),i1e(this.byComponent,e,"COMPONENT"),i1e(this.byNet,e,"NET"),i1e(this.byPolygon,e,"POLYGON"),i1e(this.byRule,e,"RULE");const o=e.getDecoded("UNIQUEID");if(!o)continue;const i=o.toUpperCase(),r=this.uniqueIds.get(i);if(!r){this.uniqueIds.set(i,e);continue}const s=this.duplicateUniqueIds.get(i)??[r];s.push(e),this.duplicateUniqueIds.set(i,s)}}document;byComponent=new Map;byKind=new Map;byLayer=new Map;byNet=new Map;byPolygon=new Map;byRule=new Map;components;duplicateUniqueIds=new Map;nets;polygons;rules;uniqueIds=new Map;componentTargets;netTargets;polygonTargets;ruleTargets;getComponent(t){return nk(t)?this.componentTargets.get(t):void 0}getNet(t){return nk(t)?this.netTargets.get(t):void 0}getPolygon(t){return nk(t)?this.polygonTargets.get(t):void 0}getRule(t){return nk(t)?this.ruleTargets.get(t):void 0}getRecordByUniqueId(t){return this.uniqueIds.get(t.toUpperCase())}getDanglingReferences(){const t=[],e=[["COMPONENT",this.componentTargets],["NET",this.netTargets],["POLYGON",this.polygonTargets],["RULE",this.ruleTargets]];for(const n of this.document.records)for(const[o,i]of e){const r=tk(n,o);r!==void 0&&!i.has(r)&&t.push({field:o,index:r,record:n})}return t}};function rg(t){const e=Sfn.get(t);if(e?.revision===t.revision)return e.index;const n=new u$i(t);return Sfn.set(t,{index:n,revision:t.revision}),n}function Qfn(t,e){return rg(t).getComponent(e)}function vfn(t,e){return rg(t).getNet(e)}function wfn(t,e){return rg(t).getPolygon(e)}function Pfn(t,e){return rg(t).getRule(e)}function mXe(t,e){return e instanceof e1e?tM(rg(t).components,e):tk(e,"COMPONENT")}function _Xe(t,e){return e instanceof t1e?tM(rg(t).nets,e):tk(e,"NET")}function g$i(t,e){return e.recordKind==="Polygon"?tM(rg(t).polygons,e):tk(e,"POLYGON")}function d$i(t,e){return e.recordKind==="Rule"||e.recordKind==="DXPRule"?tM(rg(t).rules,e):tk(e,"RULE")??tk(e,"RULEINDEX")}function Mfn(t,e){const n=mXe(t,e);return n===void 0?void 0:rg(t).getComponent(n)}function Dfn(t,e){const n=_Xe(t,e);return n===void 0?void 0:rg(t).getNet(n)}function Nfn(t,e){const n=g$i(t,e);return n===void 0?void 0:rg(t).getPolygon(n)}function Rfn(t,e){const n=d$i(t,e);return n===void 0?void 0:rg(t).getRule(n)}function n1e(t,e){const n=typeof e=="number"?e:tM(rg(t).components,e);return n===void 0?[]:[...rg(t).byComponent.get(n)??[]]}function Tfn(t,e){const n=typeof e=="number"?e:tM(rg(t).nets,e);return n===void 0?[]:[...rg(t).byNet.get(n)??[]]}function kfn(t,e){const n=typeof e=="number"?e:tM(rg(t).polygons,e);return n===void 0?[]:[...rg(t).byPolygon.get(n)??[]]}function Ffn(t,e){const n=typeof e=="number"?e:tM(rg(t).rules,e);return n===void 0?[]:[...rg(t).byRule.get(n)??[]]}function o1e(t){const e=new Map,n=t.some(o=>o.getNumber("ID")!==void 0);return t.forEach((o,i)=>{const r=n?o.getNumber("ID"):i;r!==void 0&&nk(r)&&e.set(r,o)}),e}function tM(t,e){if(t.some(i=>i.getNumber("ID")!==void 0)){const i=e.getNumber("ID");return i!==void 0&&nk(i)?i:void 0}const o=t.indexOf(e);return o>=0?o:void 0}function i1e(t,e,n){const o=tk(e,n);o!==void 0&&fXe(t,o,e)}function fXe(t,e,n){const o=t.get(e);o?o.push(n):t.set(e,[n])}function tk(t,e){const n=t.getNumber(e);return n!==void 0&&nk(n)?n:void 0}function nk(t){return Number.isInteger(t)&&t>=0&&t<l$i}var Lfn=1e5,h$i=1e4;function IXe(t){return a1e(p$i(t))}function p$i(t){return Hfn(Ufn(t))}function Hfn(t){const e=[];for(let n=0;n<Lfn;n++){const o=ok(t,`VX${n}`),i=ok(t,`VY${n}`);if(o===void 0||i===void 0)break;const r=yXe(t,`KIND${n}`),s={x:o,y:i};if(r!==1){e.push({index:n,kind:r===void 0||r===0?"line":"unknown",position:s,rawKind:r});continue}const a=ok(t,`CX${n}`),A=ok(t,`CY${n}`),c=ok(t,`R${n}`),l=yXe(t,`SA${n}`),u=yXe(t,`EA${n}`),g=a!==void 0&&A!==void 0&&c!==void 0&&c>0&&l!==void 0&&u!==void 0?{center:{x:a,y:A},endAngleDegrees:u,radiusMils:c,startAngleDegrees:l}:void 0;e.push({arc:g,index:n,kind:g?"arc":"unknown",position:s,rawKind:r})}return e}function r1e(t){const e=Ufn(t),n=[],o=Kfn(e.get("HOLECOUNT"),h$i);for(let i=0;i<o;i++){const r=Kfn(e.get(`HOLE${i}COUNT`),Lfn),s=[];for(let a=0;a<r;a++){const A=ok(e,`HOLE${i}VX${a}`),c=ok(e,`HOLE${i}VY${a}`);if(A===void 0||c===void 0)break;s.push({index:a,kind:"line",position:{x:A,y:c},rawKind:0})}s.length>=3&&n.push(a1e(s))}return{holes:n,outline:a1e(Hfn(e)),record:t}}function Ofn(t){const e=t.board?IXe(t.board):a1e([]),n=t.records.filter(o=>o.recordKind==="BoardRegion"||o.recordKind==="Region");return{cutouts:n.filter(o=>s1e(o)==="BOARD_CUTOUT").map(r1e),layerStackRegions:n.filter(o=>s1e(o)==="LAYER_STACK_REGION").map(r1e),outline:e,polygonCutouts:n.filter(o=>s1e(o)==="POLYGON_CUTOUT").map(r1e)}}function s1e(t){if(t.recordKind==="BoardRegion"||t.getDecoded("OBJECTKIND")?.toUpperCase()==="BOARDREGION"||t.getDecoded("LAYERSTACKID")!==void 0)return"LAYER_STACK_REGION";const n=(t.getDecoded("REGIONKIND")??t.getDecoded("KIND")??void 0)?.replace(/[\s-]+/gu,"_").toUpperCase();return n==="0"?t.getBoolean("ISBOARDCUTOUT")===!0?"BOARD_CUTOUT":"COPPER":n==="1"?"POLYGON_CUTOUT":n==="2"?"DASHED_OUTLINE":n==="3"?"UNKNOWN_3":n==="4"?"CAVITY_DEFINITION":n}function a1e(t){const e=[];for(const i of t){if(!i.arc){Yfn(e,i.position);continue}for(const r of m$i(i.position,i.arc))Yfn(e,r)}const n=e[0],o=e.at(-1);return{bounds:Xji(e),isExplicitlyClosed:n!==void 0&&o!==void 0&&hXe(n,o,1e-4),points:e,vertices:t,winding:e$i(e)}}function m$i(t,e){const n=CXe(e.center,e.radiusMils,e.startAngleDegrees),o=CXe(e.center,e.radiusMils,e.endAngleDegrees),i=_$i(e.endAngleDegrees-e.startAngleDegrees)||360,r=Gfn(t,n)<=Gfn(t,o),s=r?e.startAngleDegrees:e.endAngleDegrees,a=r?i:-i,A=Math.max(2,Math.ceil(Math.abs(a)/7.5)),c=[];for(let l=0;l<=A;l++)c.push(CXe(e.center,e.radiusMils,s+a*l/A));return c}function CXe(t,e,n){const o=n*Math.PI/180;return{x:t.x+Math.cos(o)*e,y:t.y+Math.sin(o)*e}}function _$i(t){return(t%360+360)%360}function Gfn(t,e){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o}function Yfn(t,e){const n=t.at(-1);n&&hXe(n,e,1e-4)||t.push(e)}function Ufn(t){const e=new Map;for(const n of t.fields){const o=n.key.toUpperCase();e.has(o)||e.set(o,n.value)}return e}function ok(t,e){return Gee(t.get(e.toUpperCase()))}function yXe(t,e){const n=Number(t.get(e.toUpperCase()));return Number.isFinite(n)?n:void 0}function Kfn(t,e){const n=Number(t??0);return Number.isInteger(n)?Math.min(Math.max(n,0),e):0}var Vfn=class extends Ol{type="dimension-record";constructor(t={}){super(t)}get dimensionKind(){return pi(this,"DIMENSIONKIND","KIND")}get start(){return this.referencePoints[0]??qh(this,["X1"],["Y1"])}get end(){return this.referencePoints[1]??qh(this,["X2"],["Y2"])}get dimensionLineAnchor(){return qh(this,["X1"],["Y1"])}get referencePoints(){return zfn({pointInfix:"POINT",prefix:"REFERENCE",record:this})}get textPoints(){const t=qh(this,["TEXTX"],["TEXTY"]);return t?[t]:zfn({pointInfix:"",prefix:"TEXT",record:this})}get unit(){return pi(this,"TEXTDIMENSIONUNIT","DIMENSIONUNIT","UNIT")}get precision(){return c$i(this,"TEXTPRECISION","PRECISION")??tc(this,"TEXTPRECISION","PRECISION")}get prefix(){return pi(this,"TEXTPREFIX","PREFIX")}get suffix(){return pi(this,"TEXTSUFFIX","SUFFIX")}get lineWidthMils(){return tc(this,"LINEWIDTH","ARROWLINEWIDTH","WIDTH")}get textHeightMils(){return tc(this,"TEXTHEIGHT","HEIGHT")}};function zfn({pointInfix:t,prefix:e,record:n}){const o=[],i=e==="REFERENCE"?n.getNumber("REFERENCES_COUNT"):void 0,r=Math.min(Math.max(i??100,0),1e4),s=e==="REFERENCE"?0:1;for(let a=s;a<s+r;a++){const A=qh(n,[`${e}${a}${t}X`],[`${e}${a}${t}Y`]);if(!A)break;o.push(A)}return o}var f$i=class extends Ol{type="coordinate-record";get position(){return qh(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}};function I$i(t){return t.replace(/[\s_-]/gu,"").toUpperCase()}function iK(t){return Gee(t)}function Md(t,e,n=0){return iK(t.getCaseInsensitive(e))??n}function C$i(t){return IXe(t).points}function y$i(t){if(!(t instanceof Vfn))return;const e=t,n=e.start,o=e.end;if(!n||!o)return;const i=o.x-n.x,r=o.y-n.y,s=Math.hypot(i,r);if(s===0)return;const a=-r/s,A=i/s,c=e.dimensionLineAnchor??n,l=(c.x-n.x)*a+(c.y-n.y)*A,u={x:n.x+a*l,y:n.y+A*l},g={x:o.x+a*l,y:o.y+A*l},h=e.textPoints[0]??{x:(u.x+g.x)/2,y:(u.y+g.y)/2},d=x$i({dimension:e,measuredDistanceMils:s}),p=e.textHeightMils??50,m=Jfn({fallbackMils:10,fieldName:"TEXTGAP",record:t});return{arrowSize:Jfn({fallbackMils:40,fieldName:"ARROWSIZE",record:t}),dimensionEnd:g,dimensionStart:u,estimatedTextHalfWidth:d.length*p*.3+m,label:d,lineWidth:e.lineWidthMils??8,referenceEnd:o,referenceStart:n,textHeight:p,textPosition:h}}function x$i({dimension:t,measuredDistanceMils:e}){const n=t.getDecoded("TEXTFORMAT")?.trim();if(n&&n!=="<>")return n;const o=Math.min(Math.max(t.precision??2,0),6),i=t.unit?.toUpperCase()??"MILS",{amount:r,unitLabel:s}=E$i({measuredDistanceMils:e,normalizedUnit:i}),a=t.prefix??"",A=t.suffix??` ${s}`;return`${a}${r.toFixed(o)}${A}`}function E$i({measuredDistanceMils:t,normalizedUnit:e}){return e.includes("MILLIMETER")?{amount:t*.0254,unitLabel:"mm"}:e.includes("CENTIMETER")?{amount:t*.00254,unitLabel:"cm"}:e.includes("INCH")?{amount:t/1e3,unitLabel:"in"}:{amount:t,unitLabel:"mil"}}function Jfn({fallbackMils:t,fieldName:e,record:n}){return n.getAltiumMeasurement(e)?.toMils()??t}var xXe=I$i;function B$i(t,e){const n=S$i(t,e),o=t.getNumber("PADMODE")??0,i=b$i(t,n,o),r=t.getCaseInsensitive(`LAYER${n}ALTSHAPE`)?.toUpperCase(),s=Number(t.getCaseInsensitive(`LAYER${n}CORNERRADIUS`)??0),a=r==="ROUNDRECT"&&Number.isFinite(s)?Math.min(i.width,i.height)*s/200:0,A=t.getNumber("HOLETYPE"),c=t.getCaseInsensitive("HOLESHAPE")?.toUpperCase()??(A===1?"SQUARE":A===2?"SLOT":"ROUND"),l=Md(t,"HOLESIZE"),u=iK(t.getCaseInsensitive("SLOTLENGTH"))??(c==="SLOT"?iK(t.getCaseInsensitive("HOLEWIDTH")):void 0)??l;return{cornerRadius:a,height:i.height,holeOffsetX:Md(t,`LAYER${n}HOLEXOFFSET`,Md(t,`PADXOFFSET${n}`)),holeOffsetY:Md(t,`LAYER${n}HOLEYOFFSET`,Md(t,`PADYOFFSET${n}`)),holeRotation:Number(t.getCaseInsensitive("SLOTROTATION")??t.getCaseInsensitive("HOLEROTATION")??0),holeShape:c,holeSize:l,layerOrdinal:n,plated:t.getBoolean("PLATED")!==!1,rotation:Number(t.getCaseInsensitive("ROTATION")??0),shape:r==="ROUNDRECT"?r:i.shape,slotLength:u,width:i.width,x:Md(t,"X"),y:Md(t,"Y")}}function b$i(t,e,n){if(!(xXe(t.getCaseInsensitive("LAYER")??"")==="MULTILAYER")||n===0||e===0)return{height:FS(t,["YSIZE","TOPYSIZE"])??FS(t,["XSIZE","TOPXSIZE"])??20,shape:A1e(t,["SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:FS(t,["XSIZE","TOPXSIZE"])??20};if(e===31){const s=FS(t,["BOTTOMXSIZE","BOTXSIZE","XSIZE","TOPXSIZE"])??20;return{height:FS(t,["BOTTOMYSIZE","BOTYSIZE","YSIZE","TOPYSIZE"])??s,shape:A1e(t,["BOTTOMSHAPE","BOTSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:s}}if(n===2&&e>=2){const s=FS(t,[`LAYER${e}XSIZE`,"MIDXSIZE","XSIZE"])??20;return{height:FS(t,[`LAYER${e}YSIZE`,"MIDYSIZE","YSIZE"])??s,shape:A1e(t,[`LAYER${e}SHAPE`,"MIDSHAPE","SHAPE"])?.toUpperCase()??"ROUND",width:s}}const r=FS(t,["MIDXSIZE","XSIZE","TOPXSIZE"])??20;return{height:FS(t,["MIDYSIZE","YSIZE","TOPYSIZE"])??r,shape:A1e(t,["MIDSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:r}}function S$i(t,e){const n=e?.length===1?xXe(e[0]??""):xXe(t.getCaseInsensitive("LAYER")??"");if(n==="BOTTOM")return 31;if(n==="TOP")return 0;const o=/^(?:MIDLAYER|MID|INTERNALPLANE)(\d+)$/u.exec(n);return o?.[1]?Math.min(Math.max(Number(o[1]),1),30):0}function FS(t,e){for(const n of e){const o=iK(t.getCaseInsensitive(n));if(o!==void 0)return o}}function A1e(t,e){for(const n of e){const o=t.getCaseInsensitive(n);if(o!==void 0)return o}}function EXe(t){if(t.length!==0)return{minX:Math.min(...t.map(e=>e.x)),minY:Math.min(...t.map(e=>e.y)),maxX:Math.max(...t.map(e=>e.x)),maxY:Math.max(...t.map(e=>e.y))}}function Q$i(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e}function BXe(t,e){return{minX:t.minX-e,minY:t.minY-e,maxX:t.maxX+e,maxY:t.maxY+e}}function v$i(t,e){const n=t.recordKind;if(n==="Dimension"){const o=y$i(t);if(!o)return;const i=o.dimensionEnd.x-o.dimensionStart.x,r=o.dimensionEnd.y-o.dimensionStart.y,s=Math.hypot(i,r),a={x:i/s,y:r/s},A=EXe([o.referenceStart,o.referenceEnd,o.dimensionStart,o.dimensionEnd,o.textPosition,{x:o.textPosition.x-a.x*o.estimatedTextHalfWidth,y:o.textPosition.y-a.y*o.estimatedTextHalfWidth},{x:o.textPosition.x+a.x*o.estimatedTextHalfWidth,y:o.textPosition.y+a.y*o.estimatedTextHalfWidth}]);return A?BXe(A,Math.max(o.arrowSize,o.textHeight)):void 0}if(n==="Track"){const o=EXe([{x:Md(t,"X1"),y:Md(t,"Y1")},{x:Md(t,"X2"),y:Md(t,"Y2")}]),i=Md(t,"WIDTH");return o&&i>0?BXe(o,i/2):o}if(n==="Pad"){const o=B$i(t,e),i=o.rotation*Math.PI/180,r=o.width/2,s=o.height/2,a=Math.abs(Math.cos(i))*r+Math.abs(Math.sin(i))*s,A=Math.abs(Math.sin(i))*r+Math.abs(Math.cos(i))*s;return{minX:o.x-a,minY:o.y-A,maxX:o.x+a,maxY:o.y+A}}if(n==="Via"){const o=Md(t,"X"),i=Md(t,"Y"),r=iK(t.getCaseInsensitive("DIAMETER"))??iK(t.getCaseInsensitive("TOPLAYERSIZE"))??20;return{minX:o-r/2,minY:i-r/2,maxX:o+r/2,maxY:i+r/2}}if(n==="Arc"){const o=Md(t,"LOCATION.X"),i=Md(t,"LOCATION.Y"),r=Md(t,"RADIUS"),s=Md(t,"WIDTH"),a=r+Math.max(s/2,0);return{minX:o-a,minY:i-a,maxX:o+a,maxY:i+a}}if(n==="ComponentBody"||n==="Region"||n==="Polygon"||n==="Board")return EXe(C$i(t));if(n==="Text"){const o=Md(t,"X"),i=Md(t,"Y"),r=Md(t,"HEIGHT",30);return BXe({minX:o,minY:i,maxX:o,maxY:i},r)}if(n==="Fill"){const o=Md(t,"X1"),i=Md(t,"Y1"),r=Md(t,"X2"),s=Md(t,"Y2"),a=(o+r)/2,A=(i+s)/2,c=Math.abs(r-o)/2,l=Math.abs(s-i)/2,u=Number(t.getCaseInsensitive("ROTATION")??0)*Math.PI/180,g=Math.abs(Math.cos(u))*c+Math.abs(Math.sin(u))*l,h=Math.abs(Math.sin(u))*c+Math.abs(Math.cos(u))*l;return{minX:a-g,minY:A-h,maxX:a+g,maxY:A+h}}}var Wfn=new WeakMap,w$i=class{constructor(t){this.document=t;const e=rg(t);this.edges=e.nets.flatMap((n,o)=>{const i=n.getNumber("ID")??o,r=e.byNet.get(i)??[],s=new Map;for(const a of r){const A=mXe(t,a),c=s.get(A);c?c.push(a):s.set(A,[a])}return[...s].map(([a,A])=>({component:a===void 0?void 0:e.getComponent(a),net:n,primitives:A}))})}document;edges;getConnectedRecords(t){const e=_Xe(this.document,t);return e===void 0?[]:[...rg(this.document).byNet.get(e)??[]].filter(n=>n!==t)}getNetsForComponent(t){const e=rg(this.document),n=new Set;for(const o of n1e(this.document,t)){const i=_Xe(this.document,o),r=i===void 0?void 0:e.getNet(i);r&&n.add(r)}return[...n]}getComponentsForNet(t){const e=rg(this.document),n=typeof t=="number"?t:t.getNumber("ID")??e.nets.indexOf(t);if(n<0)return[];const o=new Set;for(const i of e.byNet.get(n)??[]){const r=mXe(this.document,i),s=r===void 0?void 0:e.getComponent(r);s&&o.add(s)}return[...o]}getConnectedComponents(t){const e=new Set,n=typeof t=="number"?rg(this.document).getComponent(t):t;for(const o of this.getNetsForComponent(t))for(const i of this.getComponentsForNet(o))i!==n&&e.add(i);return[...e]}};function jfn(t){const e=Wfn.get(t);if(e?.revision===t.revision)return e.graph;const n=new w$i(t);return Wfn.set(t,{graph:n,revision:t.revision}),n}function $fn(t,e,n){let o;for(const i of n1e(t,e))o=Q$i(o,v$i(i,n));return o}var P$i=class extends o8{type="binary-pcb-document";compoundFile;embeddedModels;primitiveRecords;propertyRecords;streamSummaries;wideStrings;constructor(t){super({sourceLocation:{byteOffset:0,streamPath:"/"}}),this.compoundFile=t.compoundFile,this.primitiveRecords=t.primitiveRecords,this.propertyRecords=t.propertyRecords,this.streamSummaries=t.streamSummaries,this.wideStrings=t.wideStrings??new Map,this.embeddedModels=this.models.flatMap((e,n)=>{const o=this.compoundFile.getStream(["Models",String(n)]);return o?[new $ji({index:n,record:e,stream:o})]:[]}),this.adoptChildren([this.compoundFile,...this.records]),this.clearDirty(!0)}get records(){return[...this.propertyRecords.values(),...this.primitiveRecords.values()].flat()}get board(){return this.propertyRecords.get("Board6")?.[0]}get components(){return this.propertyRecords.get("Components6")??[]}get componentBodies(){return this.primitiveRecords.get("ShapeBasedComponentBodies6")??this.primitiveRecords.get("ComponentBodies6")??[]}get legacyComponentBodies(){return this.primitiveRecords.get("ComponentBodies6")??[]}get nets(){return this.propertyRecords.get("Nets6")??[]}get index(){return rg(this)}get connectivity(){return jfn(this)}get boardGeometry(){return Ofn(this)}get polygons(){return this.propertyRecords.get("Polygons6")??[]}get rules(){return this.propertyRecords.get("Rules6")??[]}getComponentByIndex(t){return Qfn(this,t)}getNetByIndex(t){return vfn(this,t)}getPolygonByIndex(t){return wfn(this,t)}getRuleByIndex(t){return Pfn(this,t)}getComponentForRecord(t){return Mfn(this,t)}getNetForRecord(t){return Dfn(this,t)}getPolygonForRecord(t){return Nfn(this,t)}getRuleForRecord(t){return Rfn(this,t)}getRecordsOwnedByComponent(t){return n1e(this,t)}getRecordsOnNet(t){return Tfn(this,t)}getRecordsForPolygon(t){return kfn(this,t)}getRecordsForRule(t){return Ffn(this,t)}getRecordsByLayer(t){return[...this.index.byLayer.get(t.toUpperCase())??[]]}getComponentBounds(t,e){return $fn(this,t,e)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}get models(){return this.propertyRecords.get("Models")??[]}getModelsById(t){const e=t.toUpperCase();return this.models.filter(n=>n.getDecoded("ID")?.toUpperCase()===e)}getModelForComponentBody(t){const e=t.getDecoded("MODELID");if(!e)return;const n=this.getModelsById(e);return n.length<=1?n[0]:n.find(o=>bXe(o.getNumber("ROTX"),t.getNumber("MODEL.3D.ROTX"))&&bXe(o.getNumber("ROTY"),t.getNumber("MODEL.3D.ROTY"))&&bXe(o.getNumber("ROTZ"),t.getNumber("MODEL.3D.ROTZ")))??n[0]}getEmbeddedModelForComponentBody(t){const e=this.getModelForComponentBody(t);return this.embeddedModels.find(n=>n.record===e)}get tracks(){return this.primitiveRecords.get("Tracks6")??[]}get arcs(){return this.primitiveRecords.get("Arcs6")??[]}get vias(){return this.primitiveRecords.get("Vias6")??[]}get pads(){return this.primitiveRecords.get("Pads6")??[]}get fills(){return this.primitiveRecords.get("Fills6")??[]}get regions(){return this.primitiveRecords.get("ShapeBasedRegions6")??this.primitiveRecords.get("Regions6")??[]}get regionFills(){return this.primitiveRecords.get("Regions6")??[]}get boardRegions(){return this.primitiveRecords.get("BoardRegions")??[]}get texts(){return this.primitiveRecords.get("Texts6")??[]}getRecordsByKind(t){return this.records.filter(e=>e.recordKind===t)}getStreamSummary(t){return this.streamSummaries.find(e=>e.family.toLowerCase()===t.toLowerCase())}getBytes(){if(this.isDirty)throw new Yg("Modified binary PCB documents cannot yet be serialized safely");return this.compoundFile.getBytes()}getChildren(){return[this.compoundFile,...this.records]}getString(){return this.records.map(t=>t.getString()).join(`
`)}};function bXe(t,e){return t!==void 0&&e!==void 0&&Math.abs(t-e)<Number.EPSILON}function SXe(t,e){if(e!==void 0)return{encoding:e,text:e==="utf-16le"?l1e(t,!0):e==="utf-16be"?l1e(t,!1):new TextDecoder(e,{fatal:e==="utf-8"}).decode(t)};if(t[0]===239&&t[1]===187&&t[2]===191)return{encoding:"utf-8-bom",text:`\uFEFF${new TextDecoder().decode(t.subarray(3))}`};if(t[0]===255&&t[1]===254)return{encoding:"utf-16le-bom",text:`\uFEFF${l1e(t.subarray(2),!0)}`};if(t[0]===254&&t[1]===255)return{encoding:"utf-16be-bom",text:`\uFEFF${l1e(t.subarray(2),!1)}`};try{return{encoding:"utf-8",text:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{return{encoding:"windows-1252",text:new TextDecoder("windows-1252").decode(t)}}}function c1e(t,e="utf-8"){const n=e.endsWith("-bom"),o=n&&t.startsWith("\uFEFF")?t.slice(1):t;if(e==="utf-8"||e==="utf-8-bom"){const c=new TextEncoder().encode(o);return n?Uint8Array.from([239,187,191,...c]):c}if(e==="windows-1252")return D$i(o);const i=e==="utf-16le"||e==="utf-16le-bom",r=o.length*2+(n?2:0),s=new Uint8Array(r),a=new DataView(s.buffer);let A=0;n&&(s[0]=i?255:254,s[1]=i?254:255,A=2);for(let c=0;c<o.length;c++)a.setUint16(A,o.charCodeAt(c),i),A+=2;return s}function l1e(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=[],i=8192;for(let r=0;r+2<=t.byteLength;r+=i*2){const s=Math.min(r+i*2,t.byteLength),a=[];for(let A=r;A+2<=s;A+=2)a.push(n.getUint16(A,e));o.push(String.fromCharCode(...a))}return o.join("")}var M$i=new Map([["€",128],["‚",130],["ƒ",131],["„",132],["…",133],["†",134],["‡",135],["ˆ",136],["‰",137],["Š",138],["‹",139],["Œ",140],["Ž",142],["‘",145],["’",146],["“",147],["”",148],["•",149],["–",150],["—",151],["˜",152],["™",153],["š",154],["›",155],["œ",156],["ž",158],["Ÿ",159]]);function D$i(t){const e=[];for(const n of t){const o=M$i.get(n);if(o!==void 0){e.push(o);continue}const i=n.codePointAt(0);if(i===void 0||i>255)throw new RangeError(`Character ${JSON.stringify(n)} cannot be encoded as Windows-1252`);e.push(i)}return Uint8Array.from(e)}function N$i(t){const e=new Map(t.fields.map(r=>[r.key.toUpperCase(),r.value])),n=[...QXe(e,"LAYER_V8_","v8"),...QXe(e,"LAYERV7_","v7")];n.length===0&&n.push(...QXe(e,"LAYER","legacy"));const o=e.has("V9_MASTERSTACK_ID")?"V9_MASTERSTACK_":"LAYERMASTERSTACK_V8",i=T$i(e);return{entries:n.sort((r,s)=>r.index-s.index),id:EI(e,`${o}ID`),impedanceProfiles:R$i(e,i),isFlex:h2(EI(e,`${o}ISFLEX`)),layerPairs:F$i(e),name:EI(e,`${o}NAME`),style:EI(e,`${o}STYLE`)??EI(e,"LAYERSTACKSTYLE"),subStacks:k$i(e),traceImpedanceConfigurations:i}}function R$i(t,e){return[...Uee(t,/^V9_IMPEDANCEPROFILE(\d+)_ID$/u)].sort((n,o)=>n-o).map(n=>{const o=`V9_IMPEDANCEPROFILE${n}_`,i=EI(t,`${o}ID`);return{displayName:EI(t,`${o}DISPLAY_NAME`),id:i,index:n,isDifferentialPair:h2(EI(t,`${o}ISDIFFPAIR`)),name:EI(t,`${o}NAME`),targetImpedanceOhms:nM(EI(t,`${o}IMPEDANCE`)),traceConfigurations:e.filter(({profileId:r})=>i!==void 0&&r?.toUpperCase()===i.toUpperCase())}})}function T$i(t){return[...Uee(t,/^V9_TRACEIMPEDANCE(\d+)_PROFILE_ID$/u)].sort((e,n)=>e-n).map(e=>{const n=`V9_TRACEIMPEDANCE${e}_`,o=r=>EI(t,`${n}${r}`),i=r=>Gee(o(r));return{calculatedImpedanceOhms:nM(o("CALC_IMPEDANCE")),differentialPairGapMils:i("DIFF_PAIR_GAP"),differentialPairMaximumGapMils:i("DIFF_PAIR_MAXGAP"),differentialPairMinimumGapMils:i("DIFF_PAIR_MINGAP"),enabled:h2(o("ENABLED")),etchFactor:nM(o("ETCH_FACTOR")),impedanceErrorPercent:nM(o("IMPEDANCE_ERR")),index:e,layerId:o("LAYER_V7ID"),profileId:o("PROFILE_ID"),propagationSpeed:nM(o("PROPAGATION_SPEED")),referenceBottomLayerId:o("REF_BOT_V7ID"),referenceTopLayerId:o("REF_TOP_V7ID"),subStackId:o("SUBSTACK_ID"),traceGapLocked:h2(o("TRACEGAP_LOCKED")),traceMaximumWidthMils:i("TRACE_MAXWIDTH"),traceMinimumWidthMils:i("TRACE_MINWIDTH"),traceWidthLocked:h2(o("TRACEWIDTH_LOCKED")),traceWidthMils:i("TRACE_WIDTH")}})}function k$i(t){const e=Uee(t,/^V9_SUBSTACK(\d+)_ID$/u),n=e.size>0?"v9":"v8";return[...n==="v9"?e:Uee(t,/^LAYERSUBSTACK_V8_(\d+)ID$/u)].sort((i,r)=>i-r).map(i=>{const r=n==="v9"?`V9_SUBSTACK${i}_`:`LAYERSUBSTACK_V8_${i}`,s=a=>EI(t,`${r}${a}`);return{id:s("ID"),index:i,isFlex:h2(s("ISFLEX")),name:s("NAME"),service:h2(s("SERVICE")),showBottomDielectric:h2(s("SHOWBOTTOMDIELECTRIC")),showTopDielectric:h2(s("SHOWTOPDIELECTRIC")),source:n,type:nM(s("TYPE")),usedByPrimitives:h2(s("USEDBYPRIMS"))}})}function F$i(t){return[...Uee(t,/^LAYERPAIR(\d+)LOW$/u)].sort((n,o)=>n-o).map(n=>{const o=`LAYERPAIR${n}`,i=`${o}SUBSTACK_`,r=[...t].flatMap(([s,a])=>{if(!s.startsWith(i))return[];const A=s.slice(i.length);return/^\d+$/u.test(A)?[{index:Number(A),value:a}]:[]}).sort((s,a)=>s.index-a.index).map(({value:s})=>s);return{drillDrawing:h2(EI(t,`${o}DRILLDRAWING`)),drillGuide:h2(EI(t,`${o}DRILLGUIDE`)),highLayer:EI(t,`${o}HIGH`),index:n,lowLayer:EI(t,`${o}LOW`),subStackIds:r}})}function Uee(t,e){const n=new Set;for(const o of t.keys()){const i=e.exec(o)?.[1];i!==void 0&&n.add(Number(i))}return n}function QXe(t,e,n){const o=new Set,i=n==="legacy"?/^LAYER(\d+)NAME$/u:new RegExp(`^${L$i(e)}(\\d+)(?:_|)(?:ID|NAME|LAYERID)$`,"u");for(const r of t.keys()){const s=i.exec(r);s?.[1]&&o.add(Number(s[1]))}return[...o].map(r=>{const s=`${e}${r}`,a=c=>EI(t,`${s}${c}`),A={index:r,source:n};return n==="v8"?(A.id=a("ID"),A.name=a("NAME"),A.layerId=a("LAYERID"),A.usedByPrimitives=h2(a("USEDBYPRIMS")),A.mechanicalEnabled=h2(a("MECHENABLED")),A.copperThickness=oK(a("COPTHICK")??""),A.dielectricType=a("DIELTYPE"),A.dielectricConstant=nM(a("DIELCONST")),A.dielectricHeight=oK(a("DIELHEIGHT")??""),A.dielectricMaterial=a("DIELMATERIAL"),A):(A.layerId=a("LAYERID"),A.name=a("NAME"),A.previous=a("PREV"),A.next=a("NEXT"),A.mechanicalEnabled=h2(a("MECHENABLED")),A.copperThickness=oK(a("COPTHICK")??""),A.dielectricType=a("DIELTYPE"),A.dielectricConstant=nM(a("DIELCONST")),A.dielectricHeight=oK(a("DIELHEIGHT")??""),A.dielectricMaterial=a("DIELMATERIAL"),A)})}function EI(t,e){return t.get(e.toUpperCase())}function h2(t){if(t!==void 0){if(/^(?:T|TRUE|1)$/iu.test(t))return!0;if(/^(?:F|FALSE|0)$/iu.test(t))return!1}}function nM(t){if(t===void 0)return;const e=Number(t);return Number.isFinite(e)?e:void 0}function L$i(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}var qfn=class extends Ol{type="board-record";constructor(t={}){super(t)}get fileName(){return pi(this,"FILENAME")}get version(){return pi(this,"VERSION")}get date(){return pi(this,"DATE")}get time(){return pi(this,"TIME")}get displayUnit(){return pi(this,"DISPLAYUNIT")}get origin(){return qh(this,["ORIGINX","ORIGIN.X"],["ORIGINY","ORIGIN.Y"])}get sheetOrigin(){return qh(this,["SHEETX"],["SHEETY"])}get sheetSize(){return Yee(this,["SHEETWIDTH"],["SHEETHEIGHT"])}get uniqueId(){return pi(this,"UNIQUEID")}get grid(){return{dotGrid:this.getBoolean("DOTGRID"),electricalGridEnabled:this.getBoolean("ELECTRICALGRIDENABLED"),electricalGridRangeMils:tc(this,"ELECTRICALGRIDRANGE"),largeVisibleGridMultiplier:this.getNumber("BIGVISIBLEGRIDMULTFACTOR"),largeVisibleGridSize:this.getNumber("BIGVISIBLEGRIDSIZE"),snapEnabled:this.getBoolean("GRIDSNAPENABLED"),snapSizeMils:tc(this,"GRIDSIZE"),visibleGridMultiplier:this.getNumber("VISIBLEGRIDMULTFACTOR"),visibleGridSize:this.getNumber("VISIBLEGRIDSIZE")}}get outline(){return IXe(this)}get layerStack(){return N$i(this)}},vXe=class extends Ol{type="class-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get classKind(){return pi(this,"KIND")}get superClass(){return this.getBoolean("SUPERCLASS")}get uniqueId(){return pi(this,"UNIQUEID")}get members(){const t=[];for(let e=0;e<1e5;e++){const n=pi(this,`M${e}`);if(n===void 0)break;t.push(n)}return t}},H$i=class extends vXe{type="signal-class-record"},Xfn=class extends Ol{type="polygon-record";constructor(t={}){super(t)}get id(){return this.getNumber("ID")}get name(){return pi(this,"NAME")}get layer(){return pi(this,"LAYER")}get netIndex(){return this.getNumber("NET")}get polygonType(){return pi(this,"POLYGONTYPE")}get pourOverStyle(){return pi(this,"POUROVERSTYLE","POUROVER")}get hatchStyle(){return pi(this,"HATCHSTYLE")}get pourIndex(){return this.getNumber("POURINDEX")}get priority(){return this.getNumber("POURORDER")??this.getNumber("PRIORITY")}get shelved(){return this.getBoolean("SHELVED")}get removeDeadCopper(){return this.getBoolean("REMOVEDEAD")}get trackWidthMils(){return tc(this,"TRACKWIDTH")}get gridSizeMils(){return tc(this,"GRIDSIZE")}},wXe=class extends Ol{type="rule-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get ruleKind(){return pi(this,"RULEKIND")}get priority(){return this.getNumber("PRIORITY")??this.getNumber("INDEXFORSAVE")}get enabled(){return this.getBoolean("ENABLED")}get scope1Expression(){return pi(this,"SCOPE1EXPRESSION")}get scope2Expression(){return pi(this,"SCOPE2EXPRESSION")}get comment(){return pi(this,"COMMENT")}get uniqueId(){return pi(this,"UNIQUEID")}get category(){const t=this.ruleKind?.toUpperCase();return t?["BOARDOUTLINECLEARANCE","CLEARANCE","COMPONENTCLEARANCE","HOLETOHOLECLEARANCE","PLANECLEARANCE"].includes(t)?"clearance":t==="WIDTH"?"routing-width":t==="ROUTINGVIAS"?"via-style":t==="ROUTINGLAYERS"?"routing-layer":t==="DIFFPAIRSROUTING"?"differential-pair":t==="LENGTH"||t==="MATCHEDLENGTHS"?"length":t==="PLANECONNECT"?"plane-connect":t==="POLYGONCONNECT"?"polygon-connect":t==="SOLDERMASKEXPANSION"||t==="PASTEMASKEXPANSION"?"mask":/(?:ASSEMBLY|FABRICATION|HEIGHT|HOLE|SILK|SLIVER|TESTPOINT)/u.test(t)?"manufacturing":"unknown":"unknown"}get clearanceMils(){if(this.category==="clearance")return tc(this,"GAP","GENERICCLEARANCE","CLEARANCE")}get verticalClearanceMils(){if(this.category==="clearance")return tc(this,"VERTICALGAP")}get widthConstraint(){if(this.normalizedRuleKind==="WIDTH")return oM(this,["MINLIMIT"],["PREFEREDWIDTH","PREFERREDWIDTH"],["MAXLIMIT"])}get layerConstraints(){if(!["DIFFPAIRSROUTING","WIDTH"].includes(this.normalizedRuleKind??""))return[];const t=new Map;for(const e of this.fields){const n=/^(TOPLAYER|BOTTOMLAYER|MIDLAYER(\d+))_(MINWIDTH|PREFWIDTH|MAXWIDTH|MINGAP|PREFGAP|MAXGAP)$/u.exec(e.key.toUpperCase());if(!n?.[1]||!n[3])continue;const o=O$i(n[1],n[2]),i=t.get(o)??{layer:o},r=tc(this,e.key);r!==void 0&&(n[3].endsWith("GAP")?(i.gap??={},e1n(i.gap,n[3],r)):e1n(i,n[3],r),t.set(o,i))}return[...t.values()]}get viaDiameterConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return oM(this,["MINWIDTH"],["WIDTH","PREFEREDWIDTH"],["MAXWIDTH"])}get viaHoleConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return oM(this,["MINHOLEWIDTH"],["HOLEWIDTH","PREFEREDHOLEWIDTH"],["MAXHOLEWIDTH"])}get viaStyle(){if(this.normalizedRuleKind==="ROUTINGVIAS")return pi(this,"VIASTYLE")}get routingLayers(){if(this.normalizedRuleKind!=="ROUTINGLAYERS")return[];const t=new Map;for(const e of this.fields){const n=/^(TOP LAYER|BOTTOM LAYER|MID LAYER (\d+))(_V5)?$/u.exec(e.key.toUpperCase());if(!n?.[1])continue;const o=G$i(n[1],n[2]),i=t.get(o)??{layer:o};n[3]?i.enabled=Y$i(e.value):i.mode=e.value,t.set(o,i)}return[...t.values()]}get differentialPairGap(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return oM(this,["MINLIMIT"],["MOSTFREQGAP","PREFEREDGAP","PREFERREDGAP"],["MAXLIMIT"])}get maximumUncoupledLengthMils(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return tc(this,"MAXUNCOUPLEDLENGTH")}get matchedLengthToleranceMils(){if(["LENGTH","MATCHEDLENGTHS"].includes(this.normalizedRuleKind??""))return tc(this,"TOLERANCE")}get impedanceConstraint(){if(this.normalizedRuleKind!=="WIDTH")return;const t={maximum:this.getNumber("MAXIMP"),minimum:this.getNumber("MINIMP"),preferred:this.getNumber("FAVIMP")};return u1e(t)?t:void 0}get thermalRelief(){if(!["PLANECONNECT","POLYGONCONNECT"].includes(this.normalizedRuleKind??""))return;const t={airGapMils:tc(this,"AIRGAPWIDTH","RELIEFAIRGAP"),angle:pi(this,"POLYGONRELIEFANGLE"),conductorWidthMils:tc(this,"RELIEFCONDUCTORWIDTH"),connectionStyle:pi(this,"CONNECTSTYLE","PLANECONNECTSTYLE"),expansionMils:tc(this,"RELIEFEXPANSION"),spokeCount:this.getNumber("RELIEFENTRIES")};return u1e(t)?t:void 0}get maskExpansionMils(){if(["PASTEMASKEXPANSION","SOLDERMASKEXPANSION"].includes(this.normalizedRuleKind??""))return tc(this,"EXPANSION")}get heightConstraint(){if(this.normalizedRuleKind==="HEIGHT")return oM(this,["MINHEIGHT"],["PREFHEIGHT","PREFEREDHEIGHT"],["MAXHEIGHT"])}get holeSizeConstraint(){if(this.normalizedRuleKind==="HOLESIZE")return oM(this,["MINLIMIT"],[],["MAXLIMIT"])}get minimumSolderMaskSliverMils(){if(this.normalizedRuleKind==="MINIMUMSOLDERMASKSLIVER")return tc(this,"MINSOLDERMASKWIDTH")}get minimumSilkClearanceMils(){if(["SILKTOBOARDREGIONCLEARANCE","SILKTOSILKCLEARANCE","SILKTOSOLDERMASKCLEARANCE"].includes(this.normalizedRuleKind??""))return tc(this,"MINSILKSCREENTOMASKGAP","SILKTOSILKCLEARANCE")}get testPointSettings(){if(!this.normalizedRuleKind?.includes("TESTPOINT"))return;const t={allowBottom:this.getBoolean("ALLOWSIDEBOTTOM"),allowTop:this.getBoolean("ALLOWSIDETOP"),gridMils:tc(this,"TESTPOINTGRID"),holeSize:oM(this,["MINHOLESIZE"],["PREFEREDHOLESIZE","PREFERREDHOLESIZE"],["MAXHOLESIZE"]),padSize:oM(this,["MINSIZE"],["PREFEREDSIZE","PREFERREDSIZE"],["MAXSIZE"]),underComponent:this.getBoolean("TESTPOINTUNDERCOMPONENT"),useGrid:this.getBoolean("USEGRID")};return u1e(t)?t:void 0}get normalizedRuleKind(){return this.ruleKind?.toUpperCase()}},Zfn=class extends wXe{type="dxp-rule-record"};function oM(t,e,n,o){const i={maximumMils:tc(t,...o),minimumMils:tc(t,...e),preferredMils:tc(t,...n)};return u1e(i)?i:void 0}function e1n(t,e,n){e.startsWith("MIN")?t.minimumMils=n:e.startsWith("MAX")?t.maximumMils=n:t.preferredMils=n}function O$i(t,e){return t==="TOPLAYER"?"TOP":t==="BOTTOMLAYER"?"BOTTOM":`MID-LAYER${e??""}`}function G$i(t,e){return t==="TOP LAYER"?"TOP":t==="BOTTOM LAYER"?"BOTTOM":`MID-LAYER${e??""}`}function Y$i(t){if(/^(?:TRUE|T|1)$/iu.test(t))return!0;if(/^(?:FALSE|F|0)$/iu.test(t))return!1}function u1e(t){return Object.values(t).some(e=>e!==void 0)}var U$i=class extends o8{type="pcb-document";_lines;originalBytes;originalSource;sourceEncoding;constructor(t={}){super({sourceLocation:{column:1,endOffset:t.originalSource?.length,line:1,startOffset:0}}),this._lines=t.lines??[],this.originalBytes=t.originalBytes?.slice(),this.originalSource=t.originalSource,this.sourceEncoding=t.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(t,e){return this.originalBytes=t.slice(),this.sourceEncoding=e,this}getBytes(){return!this.isDirty&&this.originalBytes?this.originalBytes.slice():c1e(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(t){t!==this._lines&&(this._lines=t,this.adoptChildren(t),this.markDirty())}get records(){return this.lines.filter(t=>t instanceof Ol)}get board(){return this.records.find(t=>t instanceof qfn)}get components(){return this.records.filter(t=>t instanceof e1e)}get nets(){return this.records.filter(t=>t instanceof t1e)}get classes(){return this.records.filter(t=>t instanceof vXe)}get index(){return rg(this)}get connectivity(){return jfn(this)}get boardGeometry(){return Ofn(this)}get polygons(){return this.records.filter(t=>t instanceof Xfn)}get rules(){return this.records.filter(t=>t instanceof wXe||t instanceof Zfn)}getComponentByIndex(t){return Qfn(this,t)}getNetByIndex(t){return vfn(this,t)}getPolygonByIndex(t){return wfn(this,t)}getRuleByIndex(t){return Pfn(this,t)}getComponentForRecord(t){return Mfn(this,t)}getNetForRecord(t){return Dfn(this,t)}getPolygonForRecord(t){return Nfn(this,t)}getRuleForRecord(t){return Rfn(this,t)}getRecordsOwnedByComponent(t){return n1e(this,t)}getRecordsOnNet(t){return Tfn(this,t)}getRecordsForPolygon(t){return kfn(this,t)}getRecordsForRule(t){return Ffn(this,t)}getRecordsByLayer(t){return[...this.index.byLayer.get(t.toUpperCase())??[]]}getComponentBounds(t,e){return $fn(this,t,e)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}getRecordsByKind(t){return this.records.filter(e=>e.recordKind===t)}insertRecord(t,e=this.lines.length){const n=Math.min(Math.max(e,0),this.lines.length);return t.setParent(this),this.lines.splice(n,0,t),this.markDirty(),this}removeRecord(t){const e=this.lines.indexOf(t);return e<0?!1:(this.lines.splice(e,1),t.setParent(void 0),this.markDirty(),!0)}allocateRecordId(t,e="ID"){const n=new Set(this.getRecordsByKind(t).map(i=>i.getNumber(e)).filter(i=>i!==void 0));let o=0;for(;n.has(o);)o++;return o}getChildren(){return[...this.lines]}getString(){return!this.isDirty&&this.originalSource!==void 0?this.originalSource:this.lines.map(t=>`${t.getString()}${t.terminator}`).join("")}},K$i=class{index;name;record;storage;compressedBytes;decodedPayload;constructor(t){this.compressedBytes=t.compressedBytes,this.index=t.index,this.name=t.name,this.record=t.record,this.storage=t.storage}get compressedSize(){return this.compressedBytes.byteLength}getCompressedBytes(){return this.compressedBytes.slice()}getBitmapBytes(t={}){return this.getPayload(t).bitmapBytes.slice()}getEnhancedMetafileBytes(t={}){return this.getPayload(t).enhancedMetafileBytes?.slice()}getNativePngBytes(t={}){return this.getPayload(t).nativePngBytes?.slice()}getDataUrl(t={}){return`data:image/png;base64,${X$i(this.getPngBytes(t))}`}getPngBytes(t={}){const e=this.getPayload(t);return e.nativePngBytes?.slice()??$$i(e.bitmapBytes)}getPayload(t){return Object.keys(t).length>0?t1n(this.compressedBytes,t):(this.decodedPayload??=t1n(this.compressedBytes),this.decodedPayload)}};function V$i(t,e){if(!t||e.length===0)return[];const n=z$i(t.content),o=new Set(n);return e.flatMap((i,r)=>{const s=o1n(i.fileName),a=n.find(A=>o.has(A)&&o1n(A.name)===s)??n.find(A=>o.has(A));return a?(o.delete(a),[new K$i({compressedBytes:a.compressedBytes,index:r,name:a.name,record:i,storage:t})]):[]})}function z$i(t){if(t.byteLength<4)throw new aA("Schematic image storage header is truncated");const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=4+e.getUint32(0,!0);if(o>t.byteLength)throw new aA("Schematic image storage header exceeds the stream");const i=[];for(;o<t.byteLength;){if(o+4>t.byteLength)throw new aA("Schematic image storage frame length is truncated");const r=e.getUint32(o,!0)&16777215,s=o+4,a=s+r;if(r===0||a>t.byteLength)throw new aA(`Invalid schematic image storage frame length ${r}`);if(s+2>a||t[s]!==208)throw new aA("Schematic image storage entry header is invalid");const A=t[s+1]??0,c=s+2,l=c+A;if(l+4>a)throw new aA("Schematic image storage entry name is truncated");const u=e.getUint32(l,!0),g=l+4,h=g+u;if(h>a)throw new aA("Schematic image storage compressed payload is truncated");i.push({compressedBytes:t.subarray(g,h),name:new TextDecoder("windows-1252").decode(t.subarray(c,l))}),o=a}return i}function t1n(t,e={}){const n=e.maximumBitmapSize??33554432,o=e.maximumMetafileSize??32*1024*1024,i=e.maximumNativeImageSize??32*1024*1024,r=e.maximumOutputSize??64*1024*1024;for(const[g,h]of[["maximumBitmapSize",n],["maximumMetafileSize",o],["maximumNativeImageSize",i],["maximumOutputSize",r]])if(!Number.isSafeInteger(h)||h<=0)throw new RangeError(`${g} must be a positive safe integer`);let s=0;const a=[];try{const g=new Lce(d=>{if(s+=d.byteLength,s>r)throw new aA(`Schematic image expands beyond the ${r}-byte limit`);a.push(d.slice())}),h=64*1024;for(let d=0;d<t.byteLength;){const p=Math.min(d+h,t.byteLength);g.push(t.subarray(d,p),p===t.byteLength),d=p}}catch(g){throw g instanceof aA?g:new aA(`Schematic image zlib decompression failed: ${g instanceof Error?g.message:String(g)}`)}const A=n1n(a);if(A.byteLength<6||A[0]!==66||A[1]!==77)throw new aA("Embedded schematic image is not a Windows bitmap");const l=new DataView(A.buffer,A.byteOffset,A.byteLength).getUint32(2,!0);if(l<14||l>n)throw new aA(`Embedded schematic bitmap declares invalid size ${l}`);if(l>A.byteLength)throw new aA("Embedded schematic bitmap payload is truncated");const u=J$i(A,l,o,i);return{bitmapBytes:A.slice(0,l),...u}}function J$i(t,e,n,o){if(e>=t.byteLength)return{};const i=t[e]??0,r=e+1,s=r+i;if(s>t.byteLength)return{};const a=new TextDecoder("windows-1252").decode(t.subarray(r,s));if(a==="TdxPNGImage"){const d=j$i(t.subarray(s),o);return d?{nativePngBytes:d}:{}}if(a!=="TMetafile"||s+88>t.byteLength)return{};const A=new DataView(t.buffer,t.byteOffset+s,t.byteLength-s),c=A.getUint32(0,!0),l=A.getUint32(4,!0),u=A.getUint32(40,!0),g=A.getUint32(48,!0);if(c!==1||![88,100,108].includes(l)||u!==1179469088||g<l||g%4!==0||g>n||s+g>t.byteLength)return{};const h=t.slice(s,s+g);return W$i(h,l)?{enhancedMetafileBytes:h}:{}}function W$i(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=e;for(;o+8<=t.byteLength;){const i=n.getUint32(o,!0),r=n.getUint32(o+4,!0),s=o+r;if(r<8||r%4!==0||s<=o||s>t.byteLength)return!1;if(i===14)return r>=20&&s===t.byteLength;o=s}return!1}function j$i(t,e){const n=[137,80,78,71,13,10,26,10];if(t.byteLength<20||t.byteLength>e||!n.every((s,a)=>t[a]===s))return;const o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=n.length,r=!1;for(;i+12<=t.byteLength;){const s=o.getUint32(i),a=i+12+s;if(s>e||a>t.byteLength||a>e)return;const A=new TextDecoder().decode(t.subarray(i+4,i+8));if(!r){if(A!=="IHDR"||s!==13)return;r=!0}if(A==="IEND")return s!==0?void 0:t.slice(0,a);i=a}}function $$i(t){if(t.byteLength<54||t[0]!==66||t[1]!==77)throw new aA("Embedded schematic image is not a supported Windows bitmap");const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(10,!0),o=e.getUint32(14,!0),i=e.getInt32(18,!0),r=e.getInt32(22,!0),s=e.getUint16(26,!0),a=e.getUint16(28,!0),A=e.getUint32(30,!0),c=Math.abs(r);if(o<40||i<=0||c<=0||i>16384||c>16384||s!==1||a!==24&&a!==32||A!==0)throw new aA(`Unsupported schematic bitmap (${i}x${r}, ${a}-bit, compression ${A})`);const l=a/8,u=Math.ceil(i*l/4)*4,g=u*c;if(!Number.isSafeInteger(g)||n<14+o||n+g>t.byteLength)throw new aA("Embedded schematic bitmap pixel payload is truncated");const h=1+i*4,d=new Uint8Array(h*c),p=r<0;for(let f=0;f<c;f++){const I=p?f:c-f-1,C=n+I*u,y=f*h;d[y]=0;for(let x=0;x<i;x++){const E=C+x*l,B=y+1+x*4;d[B]=t[E+2]??0,d[B+1]=t[E+1]??0,d[B+2]=t[E]??0,d[B+3]=a===32?t[E+3]??255:255}}const m=new Uint8Array(13),_=new DataView(m.buffer);return _.setUint32(0,i),_.setUint32(4,c),m[8]=8,m[9]=6,n1n([new Uint8Array([137,80,78,71,13,10,26,10]),PXe("IHDR",m),PXe("IDAT",w8t(d,{level:6})),PXe("IEND",new Uint8Array)])}function PXe(t,e){const n=new TextEncoder().encode(t),o=new Uint8Array(12+e.byteLength),i=new DataView(o.buffer);return i.setUint32(0,e.byteLength),o.set(n,4),o.set(e,8),i.setUint32(8+e.byteLength,q$i(o.subarray(4,8+e.byteLength))),o}function q$i(t){let e=4294967295;for(const n of t){e^=n;for(let o=0;o<8;o++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}function n1n(t){const e=new Uint8Array(t.reduce((o,i)=>o+i.byteLength,0));let n=0;for(const o of t)e.set(o,n),n+=o.byteLength;return e}function o1n(t){return t?.replace(/\\/gu,"/").split("/").at(-1)?.toLowerCase()}function X$i(t){const e=[];for(let o=0;o<t.byteLength;o+=32768)e.push(String.fromCharCode(...t.subarray(o,o+32768)));return btoa(e.join(""))}var ol=class extends Ol{type="schematic-record";constructor(t={}){super(t)}get ownerIndex(){return this.getNumber("OWNERINDEX")}get ownerPartId(){return this.getNumber("OWNERPARTID")}get indexInSheet(){return this.getNumber("INDEXINSHEET")}get uniqueId(){return pi(this,"UNIQUEID")}get position(){const t=l1n(this,"LOCATION.X"),e=l1n(this,"LOCATION.Y");return t===void 0||e===void 0?void 0:{x:t,y:e}}},i1n=class extends ol{type="schematic-component-record";get libraryReference(){return pi(this,"LIBREFERENCE")}},MXe=class extends ol{type="schematic-pin-record";get name(){return pi(this,"NAME")}get designator(){return pi(this,"DESIGNATOR")}get electricalType(){return this.getNumber("ELECTRICAL")}get hidden(){return this.getBoolean("ISHIDDEN")}},DXe=class extends ol{type="schematic-label-record";get text(){return pi(this,"TEXT")}},Z$i=class extends ol{type="schematic-bezier-record"},eqi=class extends ol{type="schematic-polyline-record"},tqi=class extends ol{type="schematic-polygon-record"},nqi=class extends ol{type="schematic-ellipse-record"},oqi=class extends ol{type="schematic-rounded-rectangle-record"},iqi=class extends ol{type="schematic-elliptical-arc-record"},rqi=class extends ol{type="schematic-arc-record"},sqi=class extends ol{type="schematic-line-record"},aqi=class extends ol{type="schematic-rectangle-record"},r1n=class extends ol{type="schematic-sheet-symbol-record";get fileName(){return pi(this,"FILENAME")}},Aqi=class extends ol{type="schematic-sheet-entry-record";get name(){return pi(this,"NAME")}},NXe=class extends ol{type="schematic-power-port-record";get text(){return pi(this,"TEXT")}},RXe=class extends ol{type="schematic-port-record";get name(){return pi(this,"NAME")}},TXe=class extends ol{type="schematic-net-label-record";get text(){return pi(this,"TEXT")}},cqi=class extends ol{type="schematic-bus-record"},lqi=class extends ol{type="schematic-bus-entry-record"},s1n=class extends ol{type="schematic-wire-record"},uqi=class extends ol{type="schematic-no-erc-record"},gqi=class extends ol{type="schematic-text-frame-record";get text(){return pi(this,"TEXT")}},dqi=class extends ol{type="schematic-junction-record"},a1n=class extends ol{type="schematic-image-record";get fileName(){return pi(this,"FILENAME")}},hqi=class extends ol{type="schematic-sheet-record"},A1n=class extends ol{type="schematic-sheet-name-record"},c1n=class extends ol{type="schematic-sheet-file-name-record"},pqi=class extends ol{type="schematic-designator-record";get text(){return pi(this,"TEXT")}},mqi=class extends ol{type="schematic-template-record";get fileName(){return pi(this,"FILENAME")}},_qi=class extends ol{type="schematic-parameter-record";get name(){return pi(this,"NAME")}get text(){return pi(this,"TEXT")}},fqi=class extends ol{type="schematic-implementation-list-record"},Iqi=class extends ol{type="schematic-implementation-record";get modelName(){return pi(this,"MODELNAME")}get modelType(){return pi(this,"MODELTYPE")}},Cqi=class extends ol{type="schematic-implementation-map-record"},yqi=class extends ol{type="schematic-implementation-parameter-record"},xqi=class extends ol{type="schematic-note-record";get text(){return pi(this,"TEXT")}};function l1n(t,e){const n=t.getCaseInsensitive(e);if(n===void 0)return;const o=Number(n);if(!Number.isFinite(o))return;const i=t.getCaseInsensitive(`${e}_FRAC`);if(i===void 0)return o;const r=+`0.${i.replace(/^[+-]/u,"")}`;return Number.isFinite(r)?o<0?o-r:o+r:o}var u1n=new WeakMap,g1n=new WeakMap,Eqi=class{constructor(t){this.document=t,this.records=t.records;for(const e of this.records){const n=e.getNumber("OWNERINDEX");if(n!==void 0&&n>=0){const a=this.byOwner.get(n);a?a.push(e):this.byOwner.set(n,[e])}const o=e.getDecoded("UNIQUEID");if(!o)continue;const i=o.toUpperCase(),r=this.uniqueIds.get(i);if(!r){this.uniqueIds.set(i,e);continue}const s=this.duplicateUniqueIds.get(i)??[r];s.push(e),this.duplicateUniqueIds.set(i,s)}}document;byOwner=new Map;duplicateUniqueIds=new Map;records;uniqueIds=new Map;getParent(t){const e=t.getNumber("OWNERINDEX");return e===void 0||e<0?void 0:this.records[e]}getOwnedRecords(t){const e=typeof t=="number"?t:this.records.indexOf(t);return e<0?[]:[...this.byOwner.get(e)??[]]}getRecordByUniqueId(t){return this.uniqueIds.get(t.toUpperCase())}getOwnershipCycles(){const t=[],e=new Set;for(const n of this.records){if(e.has(n))continue;const o=[],i=new Map;let r=n;for(;r;){const s=i.get(r);if(s!==void 0){t.push(o.slice(s));break}if(e.has(r))break;i.set(r,o.length),o.push(r),r=this.getParent(r)}for(const s of o)e.add(s)}return t}},Bqi=class{constructor(t){this.document=t;const e=new wqi,n=new Map,o=new Map;for(const a of t.wires){const A=Qqi(a);for(const c of A){const l=g1e(c);e.add(l),o.set(l,c),p1n(n,l,a)}for(let c=1;c<A.length;c++){const l=A[c-1],u=A[c];l&&u&&e.union(g1e(l),g1e(u))}}const i=[...t.pins,...t.labels,...t.netLabels,...t.ports,...t.powerPorts];for(const a of i){const A=a.position;if(!A)continue;const c=g1e(A);e.add(c),o.set(c,A),p1n(n,c,a)}const r=new Map;for(const[a,A]of n){const c=e.find(a),l=r.get(c)??{names:new Set,points:new Map,records:new Set},u=o.get(a);u&&l.points.set(a,u);for(const g of A){l.records.add(g);const h=vqi(g);h&&l.names.add(h)}r.set(c,l)}const s=[];for(const[a,A]of r){const c=new Set([...A.names].map(g=>g.toUpperCase())),l=s.filter(g=>[...g.names].some(h=>c.has(h.toUpperCase())));if(l.length===0||c.size===0){s.push({id:a,...A});continue}const u=l[0];if(u){m1n(u,A);for(const g of l.slice(1)){m1n(u,g);const h=s.indexOf(g);h>=0&&s.splice(h,1)}}}this.nets=s.map(a=>({id:a.id,names:[...a.names],points:[...a.points.values()],records:[...a.records]}));for(const a of this.nets)for(const A of a.records)this.recordNets.set(A,a)}document;nets;recordNets=new Map;getNetForRecord(t){return this.recordNets.get(t)}getNetsByName(t){const e=t.toUpperCase();return this.nets.filter(n=>n.names.some(o=>o.toUpperCase()===e))}getPinsForComponent(t){return kXe(this.document).getOwnedRecords(t).filter(e=>e instanceof MXe)}};function kXe(t){const e=u1n.get(t);if(e?.revision===t.revision)return e.index;const n=new Eqi(t);return u1n.set(t,{index:n,revision:t.revision}),n}function bqi(t){const e=g1n.get(t);if(e?.revision===t.revision)return e.graph;const n=new Bqi(t);return g1n.set(t,{graph:n,revision:t.revision}),n}function Sqi(t){const e=kXe(t);return t.sheetSymbols.map(n=>{const o=e.getOwnedRecords(n),i=o.find(s=>s instanceof A1n),r=o.find(s=>s instanceof c1n);return{fileName:r?.getDecoded("TEXT"),fileNameRecord:r,name:i?.getDecoded("TEXT"),nameRecord:i,symbol:n}})}function Qqi(t){const e=t.getNumber("LOCATIONCOUNT"),n=e===void 0?1e5:Math.min(Math.max(e,0),1e5),o=[];for(let i=1;i<=n;i++){const r=d1n(t,`X${i}`),s=d1n(t,`Y${i}`);if(r===void 0||s===void 0)break;o.push({x:r,y:s})}return o}function vqi(t){if(t instanceof TXe||t instanceof DXe||t instanceof NXe)return t.getDecoded("TEXT");if(t instanceof RXe)return t.getDecoded("NAME")}function d1n(t,e){const n=t.getCaseInsensitive(e);if(n===void 0)return;const o=Number(n);if(!Number.isFinite(o))return;const i=t.getCaseInsensitive(`${e}_FRAC`);if(i===void 0)return o;const r=+`0.${i.replace(/^[+-]/u,"")}`;return Number.isFinite(r)?o<0?o-r:o+r:o}function g1e(t){return`${h1n(t.x)},${h1n(t.y)}`}function h1n(t){return t.toFixed(6).replace(/\.?0+$/u,"")}function p1n(t,e,n){const o=t.get(e);o?o.push(n):t.set(e,[n])}function m1n(t,e){for(const n of e.names)t.names.add(n);for(const[n,o]of e.points)t.points.set(n,o);for(const n of e.records)t.records.add(n)}var wqi=class{parents=new Map;add(t){this.parents.has(t)||this.parents.set(t,t)}find(t){this.add(t);const e=this.parents.get(t);if(e===void 0||e===t)return t;const n=this.find(e);return this.parents.set(t,n),n}union(t,e){const n=this.find(t),o=this.find(e);n!==o&&this.parents.set(o,n)}},d1e=class extends o8{type="schematic-document";compoundFile;embeddedImages;originalBytes;originalText;sourceEncoding;sourceFormat;_lines;constructor(t){super({sourceLocation:t.sourceFormat==="binary"?{byteOffset:0,streamPath:"/"}:{column:1,endOffset:t.originalText?.length,line:1,startOffset:0}}),this.compoundFile=t.compoundFile,this._lines=t.lines??[],this.originalBytes=t.originalBytes,this.originalText=t.originalText,this.sourceEncoding=t.sourceEncoding,this.sourceFormat=t.sourceFormat,this.embeddedImages=V$i(this.compoundFile?.getStream("/Storage"),this.records.filter(e=>e instanceof a1n)),this.adoptChildren([...this.compoundFile?[this.compoundFile]:[],...this._lines]),this.clearDirty(!0)}get lines(){return this._lines}set lines(t){t!==this._lines&&(this._lines=t,this.adoptChildren(t),this.markDirty())}get header(){return this.lines.find(t=>t instanceof Ol&&t.getCaseInsensitive("HEADER")!==void 0)}get records(){return this.lines.filter(t=>t instanceof Ol&&t.recordKind!==void 0)}get index(){return kXe(this)}get netGraph(){return bqi(this)}get components(){return this.records.filter(t=>t instanceof i1n)}get pins(){return this.records.filter(t=>t instanceof MXe)}get wires(){return this.records.filter(t=>t instanceof s1n)}get labels(){return this.records.filter(t=>t instanceof DXe)}get netLabels(){return this.records.filter(t=>t instanceof TXe)}get ports(){return this.records.filter(t=>t instanceof RXe)}get powerPorts(){return this.records.filter(t=>t instanceof NXe)}get sheetSymbols(){return this.records.filter(t=>t instanceof r1n)}get sheetLinks(){return Sqi(this)}getEmbeddedImageForRecord(t){return this.embeddedImages.find(e=>e.record===t)}getRecordsByKind(t){return this.records.filter(e=>e.recordKind===t)}getParent(t){return this.index.getParent(t)}getOwnedRecords(t){return this.index.getOwnedRecords(t)}getRecordByUniqueId(t){return this.index.getRecordByUniqueId(t)}getBytes(){if(!this.isDirty&&this.originalBytes)return this.originalBytes.slice();if(this.sourceFormat==="binary")throw new Yg("Modified binary schematic documents cannot yet be serialized safely");return c1e(this.getString(),this.sourceEncoding)}getChildren(){return[...this.compoundFile?[this.compoundFile]:[],...this.lines]}getString(){return!this.isDirty&&this.originalText!==void 0?this.originalText:this.lines.map(t=>`${t.getString()}${t.terminator}`).join("")}},_1n=class extends o8{metadata;path;constructor(t,e){super(),this.metadata=t,this.path=e,this.setSourceLocation({recordIndex:t.id,streamPath:`/${e.join("/")}`})}get name(){return this.metadata.name}get pathString(){return`/${this.path.join("/")}`}getString(){return this.pathString}},FXe=class extends _1n{type="compound-stream";contentSource;loadedContent;constructor(t,e,n){super(t,e),this.contentSource=n,n instanceof Uint8Array&&(this.loadedContent=n)}get content(){return this.loadedContent??=typeof this.contentSource=="function"?this.contentSource():this.contentSource,this.loadedContent}get isContentLoaded(){return this.loadedContent!==void 0}replaceContent(t){this.loadedContent=t.slice(),this.markDirty()}getChildren(){return[]}},f1n=class Q4n extends _1n{type="compound-storage";entries;constructor(e,n,o){super(e,n),this.entries=o,this.adoptChildren(o)}get storages(){return this.entries.filter(e=>e instanceof Q4n)}get streams(){return this.entries.filter(e=>e instanceof FXe)}getChildren(){return[...this.entries]}},Pqi=class extends o8{type="compound-file";header;originalBytes;root;constructor(t){super({sourceLocation:{byteOffset:0,streamPath:"/"}}),this.header=t.header,this.originalBytes=t.originalBytes,this.root=t.root,this.adoptChildren([this.root]),this.clearDirty(!0)}get entries(){const t=[],e=n=>{for(const o of n.entries)t.push(o),o instanceof f1n&&e(o)};return e(this.root),t}get streams(){return this.entries.filter(t=>t instanceof FXe)}getStream(t){const e=Mqi(t);return this.streams.find(n=>n.path.length===e.length&&n.path.every((o,i)=>o.toLowerCase()===e[i]?.toLowerCase()))}getBytes(){if(this.isDirty)throw new Yg("Modified compound files cannot yet be serialized safely");return this.originalBytes.slice()}getChildren(){return[this.root]}getString(){return this.entries.map(t=>t.pathString).join(`
`)}};function Mqi(t){return(Array.isArray(t)?t:t.split(/[\\/]/u)).filter(Boolean)}var LXe=class extends pXe{},Kee=class extends LXe{type="ini-section-line";_name;leading;trailing;constructor(t){super(t),this._name=t.name,this.leading=t.leading??"",this.trailing=t.trailing??""}get name(){return this._name}set name(t){if(/[\]\r\n]/u.test(t))throw new Error("INI section names cannot contain closing brackets");t!==this._name&&(this._name=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}[${this.name}]${this.trailing}`}},HXe=class extends LXe{type="ini-key-value-line";_key;_value;afterEquals;beforeEquals;leading;constructor(t){super(t),this._key=t.key,this._value=t.value??"",this.leading=t.leading??"",this.beforeEquals=t.beforeEquals??"",this.afterEquals=t.afterEquals??""}get key(){return this._key}set key(t){if(t.length===0||/[=\r\n]/u.test(t))throw new Error("INI keys must be non-empty and cannot contain '='");t!==this._key&&(this._key=t,this.markDirty())}get value(){return this._value}set value(t){if(/[\r\n]/u.test(t))throw new Error("INI values cannot contain line terminators");t!==this._value&&(this._value=t,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}${this.key}${this.beforeEquals}=${this.afterEquals}${this.value}`}},I1n=class extends LXe{type="ini-comment-line";_raw;constructor(t){super(t),this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[\r\n]/u.test(t))throw new Error("INI comments cannot contain line terminators");t!==this._raw&&(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}},Dqi=class extends I1n{type="ini-raw-line"},h1e=class extends o8{type="ini-document";_lines;originalBytes;originalSource;sourceEncoding;constructor(t={}){super({sourceLocation:{column:1,endOffset:t.originalSource?.length,line:1,startOffset:0}}),this._lines=t.lines??[],this.originalBytes=t.originalBytes?.slice(),this.originalSource=t.originalSource,this.sourceEncoding=t.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(t,e){return this.originalBytes=t.slice(),this.sourceEncoding=e,this}getBytes(){return!this.isDirty&&this.originalBytes?this.originalBytes.slice():c1e(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(t){t!==this._lines&&(this._lines=t,this.adoptChildren(t),this.markDirty())}get sections(){const t=[{entries:[],name:""}];for(const e of this.lines)e instanceof Kee?t.push({entries:[],header:e,name:e.name}):e instanceof HXe&&t.at(-1)?.entries.push(e);return t}getSection(t){const e=t.toUpperCase();return this.sections.find(n=>n.name.toUpperCase()===e)}getAll(t,e){const n=e.toUpperCase();return this.getSection(t)?.entries.filter(o=>o.key.toUpperCase()===n).map(o=>o.value)??[]}get(t,e){return this.getAll(t,e)[0]}set(t,e,n){const o=this.getSection(t),i=e.toUpperCase(),r=o?.entries.find(A=>A.key.toUpperCase()===i);if(r)return r.value=n,this;let s=this.lines.length;if(o){const A=o.header?this.lines.indexOf(o.header):-1,c=this.lines.findIndex((l,u)=>u>A&&l instanceof Kee);s=c<0?this.lines.length:c}else{const A=C1n(this),c=this.lines.at(-1);c&&c.terminator===""&&(c.terminator=A,c.markDirty());const l=new Kee({name:t,terminator:A}).setParent(this);this.lines.push(l),s=this.lines.length}const a=new HXe({key:e,terminator:C1n(this),value:n}).setParent(this);return this.lines.splice(s,0,a),this.markDirty(),this}removeSection(t){const e=this.getSection(t);if(!e)return!1;const n=e.header?this.lines.indexOf(e.header):0,o=this.lines.findIndex((s,a)=>a>n&&s instanceof Kee),i=(o<0?this.lines.length:o)-n,r=this.lines.splice(n,i);for(const s of r)s.setParent(void 0);return this.markDirty(),!0}getChildren(){return[...this.lines]}getString(){return!this.isDirty&&this.originalSource!==void 0?this.originalSource:this.lines.map(t=>`${t.getString()}${t.terminator}`).join("")}};function Nqi(t){return new h1e({lines:p1e(t),originalSource:t})}function p1e(t){return Rqi(t).map(({content:e,lineNumber:n,startOffset:o,terminator:i})=>{const r={column:1,endColumn:e.length+1,endLine:n,endOffset:o+e.length,line:n,startOffset:o},s={nodeId:`ini:${o}`,sourceLocation:r,terminator:i},a=/^(\s*)\[([^\]]*)\](\s*)$/u.exec(e);if(a?.[2]!==void 0)return new Kee({...s,leading:a[1],name:a[2],trailing:a[3]});if(/^\s*[;#]/u.test(e))return new I1n({...s,raw:e});const A=e.indexOf("=");if(A>0){const c=e.slice(0,A),l=/^\s*/u.exec(c)?.[0]??"",u=c.slice(l.length),g=u.trimEnd(),h=u.slice(g.length),d=e.slice(A+1),p=/^\s*/u.exec(d)?.[0]??"";return new HXe({...s,afterEquals:p,beforeEquals:h,key:g,leading:l,value:d.slice(p.length)})}return new Dqi({...s,raw:e})})}function Rqi(t){const e=[];let n=0,o=1;for(let i=0;i<t.length;i++){const r=t[i];if(r!=="\r"&&r!==`
`)continue;const s=r==="\r"&&t[i+1]===`
`;e.push({content:t.slice(n,i),lineNumber:o,startOffset:n,terminator:s?`\r
`:r}),s&&i++,n=i+1,o++}return n<t.length&&e.push({content:t.slice(n),lineNumber:o,startOffset:n,terminator:""}),e}function C1n(t){return t.lines.find(e=>e.terminator!=="")?.terminator??`
`}var Tqi=class extends h1e{type="output-job-document";constructor(t={}){super(t)}get outputs(){return this.sections.flatMap(t=>{const e=rK(t,"OUTPUTTYPE")??rK(t,"OUTPUTGENERATOR")??rK(t,"OUTPUTNAME");return e===void 0?[]:[{category:Lqi(e),dataSource:rK(t,"DATASOURCE")??rK(t,"SOURCE"),outputType:e,section:t,settings:Fqi(t),variant:rK(t,"VARIANT")}]})}get containers(){return this.sections.filter(t=>t.entries.some(e=>/^(?:CONTAINERTYPE|OUTPUTMEDIUM|OUTPUTCONTAINER)$/iu.test(e.key)))}get fabricationOutputs(){return this.outputs.filter(t=>t.category==="fabrication")}get drillOutputs(){return this.outputs.filter(t=>t.category==="drill")}get pickAndPlaceOutputs(){return this.outputs.filter(t=>t.category==="pick-and-place")}get bomOutputs(){return this.outputs.filter(t=>t.category==="bom")}get drawingOutputs(){return this.outputs.filter(t=>t.category==="drawing")}get reportOutputs(){return this.outputs.filter(t=>t.category==="report")}};function kqi(t){return new Tqi({lines:p1e(t),originalSource:t})}function rK(t,e){const n=e.toUpperCase();return t.entries.find(o=>o.key.toUpperCase()===n)?.value}function Fqi(t){const e={};for(const n of t.entries){const o=n.key.toUpperCase(),i=e[o];i?i.push(n.value):e[o]=[n.value]}return e}function Lqi(t){return/GERBER|ODB|IPC.?2581/iu.test(t)?"fabrication":/DRILL|NC\b/iu.test(t)?"drill":/PICK.?AND.?PLACE|PICK.?PLACE|PICKPLACE|CENTROID/iu.test(t)?"pick-and-place":/\bBOM\b|BILL OF MATERIAL/iu.test(t)?"bom":/DRAWING|PDF|DRAFTSMAN|PRINT/iu.test(t)?"drawing":/ASSEMBLY/iu.test(t)?"assembly":/REPORT|VALIDATION|DESIGN RULE|ERC|DRC/iu.test(t)?"report":"unknown"}var Hqi=class{constructor(t,e){this.project=t,this.baseDirectory=e,this.nodes=t.documents.map(n=>({kind:n.kind,path:n.path,reference:n,resolvedPath:OXe(e,n.path),uniqueId:n.uniqueId}));for(const n of this.nodes)this.byPath.set(m1e(n.resolvedPath).toUpperCase(),n),n.uniqueId&&this.byUniqueId.set(n.uniqueId.toUpperCase(),n)}project;baseDirectory;byPath=new Map;byUniqueId=new Map;nodes;getByKind(t){const e=t.toUpperCase();return this.nodes.filter(n=>n.kind?.toUpperCase()===e)}getByPath(t){return this.byPath.get(m1e(t).toUpperCase())}getByUniqueId(t){return this.byUniqueId.get(t.toUpperCase())}},Oqi=class extends h1e{type="project-document";constructor(t={}){super(t)}get documents(){return this.sections.flatMap(t=>{const e=sK(t,"DOCUMENTPATH");return e?[{kind:sK(t,"DOCUMENTKIND")??E1n(e),path:e,section:t,uniqueId:sK(t,"DOCUMENTUNIQUEID")}]:[]})}get variants(){return this.sections.flatMap(t=>{if(!t.name.toUpperCase().includes("VARIANT"))return[];const e=sK(t,"VARIANTNAME")??sK(t,"NAME")??t.name;return[{alternateParts:GXe(t,/ALTERNATE|PARTCHOICE/iu),description:sK(t,"DESCRIPTION"),name:e,parameters:GXe(t,/PARAMETER/iu),section:t}]})}get projectOptions(){return this.sections.filter(t=>/^(?:DESIGN|PROJECTOPTIONS?|OPTIONS?|PREFERENCES)$/iu.test(t.name))}get projectParameters(){return this.sections.flatMap(t=>GXe(t,/PARAMETER/iu,/PARAMETER|PARAMETERS/iu.test(t.name)))}get compilerSettings(){return this.sections.filter(t=>/COMPILER|COMPILATION/iu.test(t.name))}get ecoSettings(){return this.sections.filter(t=>/\bECO\b/iu.test(t.name))}resolveDocumentPaths(t){return this.documents.map(e=>OXe(t,e.path))}getDocumentGraph(t){return new Hqi(this,t)}addDocument(t,e={}){if(t.trim().length===0||t.includes("\0")||/[\r\n]/u.test(t))throw new TypeError("Project document paths must be non-empty single-line values");const n=B1n(this,"Document");this.set(n,"DocumentPath",t);const o=e.kind??E1n(t);o&&this.set(n,"DocumentKind",o),e.uniqueId&&this.set(n,"DocumentUniqueId",e.uniqueId);const i=this.documents.find(r=>r.section.name===n);if(!i)throw new Error("Failed to create project document reference");return i}removeDocument(t){const e=typeof t=="string"?this.documents.find(n=>n.path===t||n.uniqueId===t):t;return e?this.removeSection(e.section.name):!1}addVariant(t,e={}){if(t.trim().length===0||t.includes("\0")||/[\r\n]/u.test(t))throw new TypeError("Project variant names must be non-empty single-line values");const n=B1n(this,"Variant");this.set(n,"VariantName",t),e.description&&this.set(n,"Description",e.description);const o=this.variants.find(i=>i.section.name===n);if(!o)throw new Error("Failed to create project variant");return o}removeVariant(t){const e=typeof t=="string"?this.variants.find(n=>n.name===t):t;return e?this.removeSection(e.section.name):!1}};function y1n(t){return new Oqi({lines:p1e(t),originalSource:t})}function OXe(t,e){if(Gqi(e))return m1e(e);const n=/\\/u.test(t)?"\\":"/",o=`${x1n(t)}${n}${e}`;return m1e(o,n)}function Gqi(t){return/^(?:[a-z]:[\\/]|\\\\|\/)/iu.test(t)}function m1e(t,e){const n=e??(/\\/u.test(t)&&!/\//u.test(t)?"\\":"/"),o=/^([a-z]:|\\\\[^\\/]+[\\/][^\\/]+|\/)/iu.exec(t)?.[0]??"",i=t.slice(o.length).split(/[\\/]+/u).filter(Boolean),r=[];for(const A of i)A!=="."&&(A===".."&&r.length>0?r.pop():A!==".."&&r.push(A));const s=x1n(o),a=r.join(n);return o==="/"?`/${a}`:s?a?`${s}${n}${a}`:s:a}function x1n(t){let e=t.length;for(;e>0;){const n=t[e-1];if(n!=="/"&&n!=="\\")break;e--}return t.slice(0,e)}function E1n(t){const e=/\.([^.\\/]+)$/u.exec(t)?.[1]?.toLowerCase();return e===void 0?void 0:{outjob:"output-job",pcbdoc:"pcb-document",pcblib:"pcb-library",schdoc:"schematic-document",schlib:"schematic-library"}[e]}function sK(t,e){const n=e.toUpperCase();return t.entries.find(o=>o.key.toUpperCase()===n)?.value}function GXe(t,e,n=!1){return t.entries.filter(o=>n||e.test(o.key)).map(o=>({key:o.key,section:t,value:o.value}))}function B1n(t,e){const n=new Set(t.sections.map(i=>i.name.toUpperCase()));let o=1;for(;n.has(`${e}${o}`.toUpperCase());)o++;return`${e}${o}`}var Yqi=class extends h1e{type="workspace-document";constructor(t={}){super(t)}get projects(){return this.sections.flatMap(t=>/SESSION|WINDOW|VIEW|RECENT|UI/iu.test(t.name)?[]:t.entries.filter(e=>/PROJECT/iu.test(e.key)&&/\.PRJPCB(?:$|[?#])/iu.test(e.value.trim())).map(e=>({key:e.key,path:e.value,section:t})))}get sessionSections(){return this.sections.filter(t=>/SESSION|WINDOW|VIEW|RECENT|UI/iu.test(t.name))}resolveProjectPaths(t){return this.projects.map(e=>OXe(t,e.path))}};function Uqi(t){return new Yqi({lines:p1e(t),originalSource:t})}var b1n=new Uint8Array([208,207,17,224,161,177,26,225]),S1n=4294967290,Q1n=4294967294,_1e=4294967295,v1n=4294967295;function f1e(t){return t.byteLength>=b1n.byteLength&&b1n.every((e,n)=>t[n]===e)}function Vee(t,e={}){const n=e.maxFileSize??268435456,o=e.maxChainLength??1e6,i=e.maxDirectoryEntries??1e5;if(t.byteLength>n)throw new aA(`Compound file is ${t.byteLength} bytes, exceeding the ${n}-byte limit`);if(t.byteLength<512)throw new aA("Compound file header is truncated",{byteOffset:t.byteLength});if(!f1e(t))throw new aA("Input does not begin with the OLE/CFB signature",{byteOffset:0});const r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=r.getUint16(24,!0),a=r.getUint16(26,!0),A=r.getUint16(28,!0),c=r.getUint16(30,!0),l=r.getUint16(32,!0);if(a!==3&&a!==4)throw new jji(`Unsupported CFB major version ${a}`);const u=a===3?9:12;if(c!==u)throw new aA(`CFB version ${a} must use sector shift ${u}, got ${c}`,{byteOffset:30});if(A!==65534)throw new aA(`Unsupported CFB byte order 0x${A.toString(16)}`,{byteOffset:28});const g=2**c,h=2**l,d=Math.floor(t.byteLength/g)-1;if(d<0)throw new aA("Compound file has no sectors");const p=r.getUint32(40,!0),m=r.getUint32(44,!0),_=r.getUint32(48,!0),f=r.getUint32(56,!0),I=r.getUint32(60,!0),C=r.getUint32(64,!0),y=r.getUint32(68,!0),x=r.getUint32(72,!0),E={byteOrder:A,directorySectorCount:p,fatSectorCount:m,majorVersion:a,miniFatSectorCount:C,miniSectorSize:h,miniStreamCutoffSize:f,minorVersion:s,sectorSize:g},B=ne=>{zqi(ne,d);const le=(ne+1)*g,ge=le+g;if(ge>t.byteLength)throw new aA(`Sector ${ne} extends beyond the file`,{byteOffset:le});return t.subarray(le,ge)},S=[];for(let ne=0;ne<109;ne++){const le=r.getUint32(76+ne*4,!0);le!==_1e&&S.push(le)}let Q=y;const w=new Set;for(let ne=0;ne<x;ne++){if(Q===Q1n||Q===_1e)throw new aA(`DIFAT chain ended after ${ne} of ${x} sectors`);if(w.has(Q))throw new aA(`DIFAT chain contains a loop at sector ${Q}`);w.add(Q);const le=B(Q),ge=zee(le),_e=g/4-1;for(let ue=0;ue<_e;ue++){const fe=ge.getUint32(ue*4,!0);fe!==_1e&&S.push(fe)}Q=ge.getUint32(g-4,!0)}if(S.length<m)throw new aA(`Header declares ${m} FAT sectors, but DIFAT contains ${S.length}`);S.length=m;const M=[];for(const ne of S){const le=B(ne),ge=zee(le);for(let _e=0;_e<le.byteLength;_e+=4)M.push(ge.getUint32(_e,!0))}const k=(ne,le)=>w1n({allocationTable:M,expectedSize:le,maxChainLength:o,readUnit:B,startSector:ne,unitSize:g}),R=k(_),F=Kqi(R,a,i),O=F[0];if(O?.rawType!==5)throw new aA("Directory entry 0 is not a root storage");const U=k(O.metadata.startSector,O.metadata.size),Y=C===0?new Uint8Array:k(I,C*g),W=zee(Y),te=[];for(let ne=0;ne+4<=Y.byteLength;ne+=4)te.push(W.getUint32(ne,!0));const j=ne=>{const le=ne*h,ge=le+h;if(ne<0||ge>U.byteLength)throw new aA(`Mini sector ${ne} extends beyond the root mini stream`);return U.subarray(le,ge)},J=ne=>{if(ne.size===0)return new Uint8Array;if(ne.size<f){if(te.length===0)throw new aA(`Stream ${JSON.stringify(ne.name)} requires a MiniFAT`);return w1n({allocationTable:te,expectedSize:ne.size,maxChainLength:o,readUnit:j,startSector:ne.startSector,unitSize:h})}return k(ne.startSector,ne.size)},oe=new Set([0]),ie=(ne,le)=>{const ge=ne.rawType===5?le:[...le,ne.metadata.name],_e=[],ue=Vqi(ne.metadata.childId,F);for(const fe of ue){if(oe.has(fe))throw new aA(`Directory entry ${fe} is referenced more than once`);oe.add(fe);const pe=F[fe];!pe||pe.rawType===0||(pe.rawType===1?_e.push(ie(pe,ge)):pe.rawType===2&&_e.push(new FXe(pe.metadata,[...ge,pe.metadata.name],()=>J(pe.metadata))))}return new f1n(ne.metadata,ge,_e)};return new Pqi({header:E,originalBytes:t.slice(),root:ie(O,[])})}function Kqi(t,e,n){const o=Math.floor(t.byteLength/128);if(o>n)throw new aA(`Directory contains ${o} entries, exceeding the ${n}-entry limit`);const i=[],r=zee(t);for(let s=0;s<o;s++){const a=s*128,A=r.getUint16(a+64,!0),c=r.getUint8(a+66);if(A>64||A%2!==0)throw new aA(`Directory entry ${s} has invalid UTF-16 name length ${A}`,{byteOffset:a+64});const l=t.subarray(a,a+Math.max(A-2,0)),u=r.getBigUint64(a+120,!0),g=Number(e===3?u&0xffffffffn:u);if(!Number.isSafeInteger(g))throw new aA(`Directory entry ${s} stream size exceeds JavaScript's safe integer range`);i.push({metadata:{childId:r.getUint32(a+76,!0),clsid:Wqi(t.subarray(a+80,a+96)),color:r.getUint8(a+67),creationTime:r.getBigUint64(a+100,!0),id:s,leftSiblingId:r.getUint32(a+68,!0),modifiedTime:r.getBigUint64(a+108,!0),name:l.byteLength===0?"":jqi(l),rightSiblingId:r.getUint32(a+72,!0),size:g,startSector:r.getUint32(a+116,!0),stateBits:r.getUint32(a+96,!0),type:Jqi(c)},rawType:c})}return i}function Vqi(t,e){if(t===v1n)return[];const n=[],o=new Set,i=r=>{if(r===v1n)return;if(r>=e.length)throw new aA(`Directory sibling tree references missing entry ${r}`);if(o.has(r))throw new aA(`Directory sibling tree contains a loop at entry ${r}`);o.add(r);const s=e[r];s&&(i(s.metadata.leftSiblingId),n.push(r),i(s.metadata.rightSiblingId))};return i(t),n}function w1n(t){if(t.expectedSize===0)return new Uint8Array;const e=[],n=new Set;let o=t.startSector;for(;o!==Q1n;){if(o>=S1n||o>=t.allocationTable.length)throw new aA(`Sector chain references invalid sector ${o}`);if(n.has(o))throw new aA(`Sector chain contains a loop at sector ${o}`);if(e.length>=t.maxChainLength)throw new aA(`Sector chain exceeds the ${t.maxChainLength}-sector limit`);n.add(o),e.push(o),o=t.allocationTable[o]??_1e}const i=e.length*t.unitSize;if(t.expectedSize!==void 0&&i<t.expectedSize)throw new aA(`Sector chain contains ${i} bytes, expected ${t.expectedSize}`);const r=t.expectedSize??i,s=new Uint8Array(r);let a=0;for(const A of e){if(a>=r)break;const c=t.readUnit(A),l=r-a;s.set(c.subarray(0,Math.min(c.byteLength,l)),a),a+=Math.min(c.byteLength,l)}return s}function zqi(t,e){if(t>=S1n||t>=e)throw new aA(`Invalid regular sector ${t}; file contains ${e} sectors`)}function zee(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Jqi(t){return t===1?"storage":t===2?"stream":t===5?"root":"stream"}function Wqi(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function jqi(t){const e=zee(t),n=[];for(let o=0;o+2<=t.byteLength;o+=2)n.push(e.getUint16(o,!0));return String.fromCharCode(...n)}function $qi(t,e={}){const n=e.maxFileSize??268435456;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxFileSize must be a positive safe integer");if(t.byteLength>n)throw new RangeError(`Altium file is ${t.byteLength} bytes, exceeding the ${n}-byte detection limit`);if(t.byteLength>=4&&t[0]===80&&t[1]===75&&(t[2]===3||t[2]===5||t[2]===7)&&(t[3]===4||t[3]===6||t[3]===8))return{confidence:1,container:"zip",documentKind:"zip-container",encoding:"binary",evidence:["ZIP local-file or directory signature"]};if(f1e(t)){const a=Vee(t,e),A=["OLE/CFB signature"];if(a.getStream("/Board6/Data")&&a.getStream("/Board6/Header"))return A.push("Board6/Data and Board6/Header streams"),{confidence:1,container:"cfb",documentKind:"pcb-document",encoding:"binary",evidence:A};const c=a.getStream("/FileHeader"),u=(c?qqi(c.content):void 0)?.toLowerCase();return u?.includes("schematic library")?(A.push("schematic library FileHeader stream"),{confidence:.95,container:"cfb",documentKind:"schematic-library",encoding:"binary",evidence:A}):u?.includes("pcb library")?(A.push("PCB library FileHeader stream"),{confidence:.95,container:"cfb",documentKind:"pcb-library",encoding:"binary",evidence:A}):u?.includes("integrated library")?(A.push("integrated library FileHeader stream"),{confidence:.9,container:"cfb",documentKind:"integrated-library",encoding:"binary",evidence:A}):u?.includes("schematic capture")?(A.push("schematic capture FileHeader stream"),{confidence:1,container:"cfb",documentKind:"schematic-document",encoding:"binary",evidence:A}):{confidence:.8,container:"cfb",documentKind:"compound-file",encoding:"binary",evidence:A}}const o=SXe(t,e.encoding),i=o.text.replace(/^\uFEFF/u,""),r=i.trimStart(),s=[];if(/^<\?xml(?:\s|>)/iu.test(r)||/^<[a-z][^>]*>/iu.test(r))return{confidence:.85,container:"xml",documentKind:"xml-document",encoding:o.encoding,evidence:["XML declaration or root element"]};if(/^\|RECORD=Board(?:\||$)/imu.test(i))return s.push("Board root record"),{confidence:.98,container:"ascii",documentKind:"pcb-document",encoding:o.encoding,evidence:s};if(/^\|HEADER=[^\r\n]*Schematic Library/imu.test(i))return{confidence:.95,container:"ascii",documentKind:"schematic-library",encoding:o.encoding,evidence:["schematic library header"]};if(/^\|HEADER=[^\r\n]*(?:PCB|Printed Circuit Board) Library/imu.test(i)||/^\|RECORD=(?:Pcb)?Library(?:\||$)/imu.test(i))return{confidence:.9,container:"ascii",documentKind:"pcb-library",encoding:o.encoding,evidence:["PCB library header or root record"]};if(/^\|HEADER=[^\r\n]*Schematic Capture/imu.test(i)||/^\|RECORD=31(?:\||$)/imu.test(i))return s.push("schematic header or sheet record"),{confidence:.95,container:"ascii",documentKind:"schematic-document",encoding:o.encoding,evidence:s};if(/^\|(?:RECORD|HEADER)=/mu.test(i))return s.push("Altium property records"),{confidence:.65,container:"ascii",documentKind:"unknown",encoding:o.encoding,evidence:s};if(/^\s*\[[^\]\r\n]+\]\s*$/mu.test(i)){const a=i.toUpperCase();return/DOCUMENTPATH\s*=/u.test(a)||/\[(?:DESIGN|DOCUMENT\d+|SOURCEPROJECT)\]/u.test(a)?{confidence:.86,container:"ini",documentKind:"project",encoding:o.encoding,evidence:["INI sections and project document metadata"]}:/OUTPUT(?:TYPE|GENERATOR|MEDIUM|CONTAINER)\s*=/u.test(a)||/\[OUTPUTJOB/u.test(a)?{confidence:.86,container:"ini",documentKind:"output-job",encoding:o.encoding,evidence:["INI sections and output-job metadata"]}:/\[(?:PROJECTGROUP|WORKSPACE)/u.test(a)?{confidence:.8,container:"ini",documentKind:"workspace",encoding:o.encoding,evidence:["INI sections and workspace metadata"]}:{confidence:.65,container:"ini",documentKind:"ini-document",encoding:o.encoding,evidence:["INI section syntax"]}}return{confidence:.1,container:"ascii",documentKind:"unknown",encoding:o.encoding,evidence:s}}function qqi(t){if(t.byteLength<8)return;const n=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!0)&16777215;if(n===0||n>t.byteLength-4)return;const o=t.subarray(4,4+n);return new TextDecoder("windows-1252").decode(o)}var P1n=class extends Ol{type="arc-record";constructor(t={}){super(t)}get center(){return qh(this,["LOCATION.X","X"],["LOCATION.Y","Y"])}get radiusMils(){return tc(this,"RADIUS")}get widthMils(){return tc(this,"WIDTH")}get startAngle(){return xI(this.getNumber("STARTANGLE")??0)}get endAngle(){return xI(this.getNumber("ENDANGLE")??360)}get layer(){return pi(this,"LAYER")}get netIndex(){return this.getNumber("NET")}get componentIndex(){return this.getNumber("COMPONENT")}get polygonIndex(){return this.getNumber("POLYGON")}get isFullCircle(){const t=this.getNumber("STARTANGLE")??0,e=this.getNumber("ENDANGLE")??360;return Math.abs(e-t)>=360||e===t}},M1n=class extends Ol{type="fill-record";constructor(t={}){super(t)}get start(){return qh(this,["X1"],["Y1"])}get end(){return qh(this,["X2"],["Y2"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get rotation(){return xI(this.getNumber("ROTATION")??0)}get layer(){return pi(this,"LAYER")}get netIndex(){return this.getNumber("NET")}get componentIndex(){return this.getNumber("COMPONENT")}},D1n=class extends Ol{type="pad-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get componentIndex(){return this.getNumber("COMPONENT")}get netIndex(){return this.getNumber("NET")}get layer(){return pi(this,"LAYER")}get position(){return qh(this,["X"],["Y"])}get size(){return Yee(this,["XSIZE"],["YSIZE"])}get middleSize(){return Yee(this,["MIDXSIZE","MIDLAYER1XSIZE"],["MIDYSIZE","MIDLAYER1YSIZE"])}get bottomSize(){return Yee(this,["BOTTOMXSIZE","BOTTOMLAYERXSIZE"],["BOTTOMYSIZE","BOTTOMLAYERYSIZE"])}get holeSizeMils(){return tc(this,"HOLESIZE")}get holeWidthMils(){return tc(this,"HOLEWIDTH")}get shape(){return pi(this,"SHAPE")}get middleShape(){return pi(this,"MIDSHAPE")}get bottomShape(){return pi(this,"BOTTOMSHAPE")}get holeType(){return pi(this,"HOLETYPE","HOLESHAPE")}get rotation(){return xI(this.getNumber("ROTATION")??0)}get holeRotation(){return xI(this.getNumber("HOLEROTATION")??this.getNumber("SLOTROTATION")??0)}get plated(){return this.getBoolean("PLATED")}get padMode(){return this.getNumber("PADMODE")}get behavior(){const t=this.layer?.toUpperCase();return(this.holeSizeMils??0)>0||t==="MULTILAYER"?"through-hole":t==="TOP"||t==="BOTTOM"||t==="TOP LAYER"||t==="BOTTOM LAYER"?"smd":"unknown"}get pasteMaskExpansionMils(){return tc(this,"PASTEMASKEXPANSION_MANUAL")}get solderMaskExpansionMils(){return tc(this,"SOLDERMASKEXPANSION_MANUAL")}get tentedTop(){return this.getBoolean("TENTEDTOP")??this.getBoolean("TENTINGTOP")}get tentedBottom(){return this.getBoolean("TENTEDBOTTOM")??this.getBoolean("TENTINGBOTTOM")}};function N1n(t){if(!t)return"";if(!/^\d+(?:,\d+)*$/u.test(t))return t;try{return String.fromCodePoint(...t.split(",").map(e=>Number(e)))}catch{return t}}var R1n=class extends Ol{type="text-record";constructor(t={}){super(t)}get text(){const t=this.getDecoded("WIDESTRING");return t===void 0?pi(this,"TEXT"):N1n(t)}get position(){return qh(this,["X"],["Y"])}get layer(){return pi(this,"LAYER")}get heightMils(){return tc(this,"HEIGHT")}get strokeWidthMils(){return tc(this,"WIDTH")}get rotation(){return xI(this.getNumber("ROTATION")??0)}get mirrored(){return this.getBoolean("MIRROR")}get inverted(){return this.getBoolean("INVERTED")}get justification(){return pi(this,"JUSTIFICATION")}get fontName(){return pi(this,"FONTNAME")}get usesTrueTypeFont(){return this.getBoolean("USETTFONTS")??this.getBoolean("FONTTYPE")}get textBoxSize(){return Yee(this,["TEXTBOXWIDTH"],["TEXTBOXHEIGHT"])}get componentIndex(){return this.getNumber("COMPONENT")}get isDesignator(){return this.getBoolean("DESIGNATOR")===!0}get isComment(){return this.getBoolean("COMMENT")===!0}},T1n=class extends Ol{type="track-record";constructor(t={}){super(t)}get start(){return qh(this,["X1"],["Y1"])}get end(){return qh(this,["X2"],["Y2"])}get widthMils(){return tc(this,"WIDTH")}get layer(){return pi(this,"LAYER")}get netIndex(){return this.getNumber("NET")}get componentIndex(){return this.getNumber("COMPONENT")}get polygonIndex(){return this.getNumber("POLYGON")}get unionIndex(){return this.getNumber("UNIONINDEX")}get uniqueId(){return pi(this,"UNIQUEID")}get keepout(){return this.getBoolean("KEEPOUT")}get polygonOutline(){return this.getBoolean("POLYGONOUTLINE")}get userRouted(){return this.getBoolean("USERROUTED")}get isZeroLength(){return this.start!==void 0&&this.end!==void 0?hXe(this.start,this.end):!1}},k1n=class extends Ol{type="via-record";constructor(t={}){super(t)}get position(){return qh(this,["X"],["Y"])}get diameterMils(){return tc(this,"DIAMETER","TOPLAYERSIZE")}get holeSizeMils(){return tc(this,"HOLESIZE")}get startLayer(){return pi(this,"STARTLAYER","FROMLAYER")}get endLayer(){return pi(this,"ENDLAYER","TOLAYER")}get netIndex(){return this.getNumber("NET")}get kind(){const t=this.startLayer?.toUpperCase(),e=this.endLayer?.toUpperCase();return!t||!e?"unknown":t.includes("TOP")&&e.includes("BOTTOM")||t.includes("BOTTOM")&&e.includes("TOP")?"through":"blind-buried"}get tentedTop(){return this.getBoolean("TENTEDTOP")??this.getBoolean("TENTINGTOP")}get tentedBottom(){return this.getBoolean("TENTEDBOTTOM")??this.getBoolean("TENTINGBOTTOM")}},F1n=class extends o8{type="raw-field";_raw;constructor(t){if(super(t),/[|\r\n]/u.test(t.raw))throw new Error("Raw Altium fields cannot contain record delimiters");this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[|\r\n]/u.test(t))throw new Error("Raw Altium fields cannot contain record delimiters");t!==this._raw&&(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,raw:this.raw}}},I1e=class extends Ol{type="unknown-record";constructor(t={}){super(t)}},L1n=class extends Ol{type="component-body-record";constructor(t={}){super(t)}get componentIndex(){return this.getNumber("COMPONENT")}get bodyKind(){return pi(this,"KIND")}get identifier(){return pi(this,"IDENTIFIER","NAME")}get modelId(){return pi(this,"MODELID")}get modelEmbedded(){return this.getBoolean("MODEL.EMBED")}get modelPosition(){return qh(this,["MODEL.2D.X"],["MODEL.2D.Y"])}get modelRotation2d(){return xI(this.getNumber("MODEL.2D.ROTATION")??0)}get modelRotation3d(){return{x:xI(this.getNumber("MODEL.3D.ROTX")??0),y:xI(this.getNumber("MODEL.3D.ROTY")??0),z:xI(this.getNumber("MODEL.3D.ROTZ")??0)}}get standoffHeightMils(){return tc(this,"STANDOFFHEIGHT")}get overallHeightMils(){return tc(this,"OVERALLHEIGHT")}get opacity(){return this.getNumber("BODYOPACITY3D")}},Xqi=class extends Ol{type="differential-pair-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get positiveNet(){return pi(this,"POSITIVENET","POSITIVE")}get negativeNet(){return pi(this,"NEGATIVENET","NEGATIVE")}},Zqi=class extends Ol{type="from-to-record";get from(){return pi(this,"FROM")}get to(){return pi(this,"TO")}get netIndex(){return this.getNumber("NET")}},eXi=class extends Ol{type="connection-record";get netIndex(){return this.getNumber("NET")}get from(){return pi(this,"FROM")}get to(){return pi(this,"TO")}},tXi=class extends Ol{type="embedded-board-record";constructor(t={}){super(t)}get sourcePath(){return pi(this,"SOURCEPATH","FILENAME")}get position(){return qh(this,["X","ORIGINX"],["Y","ORIGINY"])}get rotation(){return xI(this.getNumber("ROTATION")??0)}get mirrored(){return this.getBoolean("MIRROR")}},nXi=class extends Ol{type="file-version-info-record";constructor(t={}){super(t)}get versions(){const t=[];for(let e=0;e<1e4;e++){const n=pi(this,`VER${e}`);if(n===void 0)break;t.push(n)}return t}},oXi=class extends Ol{type="unique-id-primitive-information-record";get primitiveIndex(){return this.getNumber("PRIMITIVEINDEX")}get primitiveObjectId(){return pi(this,"PRIMITIVEOBJECTID")}get uniqueId(){return pi(this,"UNIQUEID")}},iM=class extends Ol{type="option-record";get optionFamily(){return this.recordKind}},iXi=class extends iM{type="advanced-placer-options-record"},rXi=class extends iM{type="design-rule-checker-options-record"},sXi=class extends iM{type="engineering-change-order-options-record"},aXi=class extends iM{type="gerber-options-record"},AXi=class extends iM{type="output-options-record"},cXi=class extends iM{type="pin-swap-options-record"},lXi=class extends iM{type="printer-options-record"},uXi=class extends iM{type="testpoint-options-record"},gXi=class extends Ol{type="model-record";constructor(t={}){super(t)}get id(){return pi(this,"ID")}get name(){return pi(this,"NAME")}get checksum(){return pi(this,"CHECKSUM")}get embedded(){return this.getBoolean("EMBED")}get rotation(){return{x:xI(this.getNumber("ROTX")??0),y:xI(this.getNumber("ROTY")??0),z:xI(this.getNumber("ROTZ")??0)}}get standoffRaw(){return this.getNumber("DZ")}},dXi=class extends Ol{type="parameter-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get value(){return pi(this,"VALUE")}get primitiveIndex(){return this.getNumber("PRIMITIVEINDEX")}get imported(){return this.getBoolean("ISIMPORTED")}},YXe=class extends Ol{type="region-record";constructor(t={}){super(t)}get layer(){return pi(this,"LAYER")}get regionKind(){return s1e(this)}get componentIndex(){return this.getNumber("COMPONENT")}get netIndex(){return this.getNumber("NET")}get polygonIndex(){return this.getNumber("POLYGON")}get holeCount(){return Math.max(this.getNumber("HOLECOUNT")??0,0)}get isGeneratedPour(){return this.recordKind==="RegionFill"}get isBoardCutout(){return this.regionKind==="BOARD_CUTOUT"}get isLayerStackRegion(){return this.regionKind==="LAYER_STACK_REGION"}get isPolygonCutout(){return this.regionKind==="POLYGON_CUTOUT"}get layerStackId(){return pi(this,"LAYERSTACKID")}get geometry(){return r1e(this)}},hXi=class extends Ol{type="room-record";constructor(t={}){super(t)}get name(){return pi(this,"NAME")}get start(){return qh(this,["X1"],["Y1"])}get end(){return qh(this,["X2"],["Y2"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get ruleIndex(){return this.getNumber("RULE")}},pXi=class extends Ol{type="smart-union-record";constructor(t={}){super(t)}get start(){return qh(this,["X1"],["Y1"])}get end(){return qh(this,["X2"],["Y2"])}get bounds(){if(!(!this.start||!this.end))return{minX:Math.min(this.start.x,this.end.x),minY:Math.min(this.start.y,this.end.y),maxX:Math.max(this.start.x,this.end.x),maxY:Math.max(this.start.y,this.end.y)}}get unionType(){return pi(this,"UNIONTYPE")}get unionIndex(){return this.getNumber("UNIONINDEX")}get rotation(){return xI(this.getNumber("ROTATION")??0)}get mirrored(){return this.getBoolean("MIRROR")}},H1n=new Map([["Arc",P1n],["1",i1n],["2",MXe],["4",DXe],["5",Z$i],["6",eqi],["7",tqi],["8",nqi],["10",oqi],["11",iqi],["12",rqi],["13",sqi],["14",aqi],["15",r1n],["16",Aqi],["17",NXe],["18",RXe],["22",uqi],["25",TXe],["26",cqi],["27",s1n],["28",gqi],["29",dqi],["30",a1n],["31",hqi],["32",A1n],["33",c1n],["34",pqi],["37",lqi],["39",mqi],["41",_qi],["44",fqi],["45",Iqi],["46",Cqi],["48",yqi],["209",xqi],["AdvancedPlacerOptions",iXi],["Board",qfn],["BoardRegion",YXe],["Class",vXe],["ComponentBody",L1n],["ComponentBodyLegacy",L1n],["Component",e1e],["Connection",eXi],["Coordinate",f$i],["DesignRuleCheckerOptions",rXi],["DifferentialPair",Xqi],["Dimension",Vfn],["DXPRule",Zfn],["EmbeddedBoard",tXi],["EngineeringChangeOrderOptions",sXi],["FileVersionInfo",nXi],["Fill",M1n],["FromTo",Zqi],["GerberOptions",aXi],["Model",gXi],["Net",t1e],["OutputOptions",AXi],["Pad",D1n],["ParamItem",dXi],["PinSwapOptions",cXi],["Polygon",Xfn],["PrinterOptions",lXi],["Region",YXe],["RegionFill",YXe],["Room",hXi],["Rule",wXe],["SignalClass",H$i],["SmartUnion",pXi],["TestpointOptions",uXi],["Text",R1n],["Track",T1n],["UniqueIDPrimitiveInformation",oXi],["Via",k1n]]);function UXe(t,e,n){const o=t.at(-1)===0?t.subarray(0,t.byteLength-1):t,i=_Xi(o,124);i[0]?.byteLength===0&&i.shift();const r=i.map(mXi);let s=fXi(r,"RECORD");s===void 0&&e!==void 0&&(r.unshift(new a9({key:"RECORD",value:e})),s=e);const a=(s===void 0?void 0:H1n.get(s))??I1e,A=new a({items:r,originalBinaryPayload:t,sourceLocation:n});for(const[c,l]of r.entries())l.setSourceLocation(n?{...n,fieldIndex:c}:void 0);return A}function mXi(t){const e=t.indexOf(61);if(e<=0)return new F1n({raw:KXe(t)});const n=t.subarray(0,e),o=t.subarray(e+1),i=KXe(n),s=(i.toUpperCase().startsWith("%UTF8%")?new TextDecoder().decode(o):KXe(o)).replaceAll("\r","").replaceAll(`
`,"");return new a9({key:i,value:s})}function _Xi(t,e){const n=[];let o=0;for(let i=0;i<t.byteLength;i++)t[i]===e&&(n.push(t.subarray(o,i)),o=i+1);return n.push(t.subarray(o)),n}function fXi(t,e){const n=e.toUpperCase();return t.find(o=>o instanceof a9&&o.key.toUpperCase()===n)?.value}function KXe(t){return new TextDecoder("windows-1252").decode(t)}var C1e={Arcs6:1,BoardRegions:11,ComponentBodies6:12,Fills6:6,Pads6:2,Regions6:11,ShapeBasedRegions6:11,ShapeBasedComponentBodies6:12,Texts6:5,Tracks6:4,Vias6:3},IXi=512,CXi={BoardRegions:{extendedVertices:!1,recordKind:"BoardRegion"},ComponentBodies6:{extendedVertices:!1,recordKind:"ComponentBodyLegacy"},Regions6:{extendedVertices:!1,recordKind:"RegionFill"},ShapeBasedRegions6:{extendedVertices:!0,recordKind:"Region"},ShapeBasedComponentBodies6:{extendedVertices:!0,recordKind:"ComponentBody"}};function yXi(t,e,n={}){if(t==="Pads6")return y1e(EXi(e,n),t);if(t==="Texts6")return y1e(BXi(e,n),t);if(t==="BoardRegions"||t==="ComponentBodies6"||t==="Regions6"||t==="ShapeBasedRegions6"||t==="ShapeBasedComponentBodies6")return y1e(SXi(t,e,n),t);const o=n.maximumRecordLength??16*1024*1024,i=[],r=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=0;for(;s<e.byteLength;){const a=s;if(s+5>e.byteLength)throw new hh(`${t} primitive frame header is truncated`,s);const A=e[s],l=r.getUint32(s+1,!0)&16777215;if(s+=5,A!==C1e[t])throw new yI(`${t} frame at offset ${a} has unexpected primitive type ${A}`);if(l===0||l>o)throw new hh(`Invalid ${t} primitive length ${l}`,a+1);if(s+l>e.byteLength)throw new hh(`${t} primitive at offset ${a} exceeds its stream`,a);const u=e.subarray(s,s+l);i.push(xXi(t,u,a)),s+=l}if(n.expectedRecordCount!==void 0&&i.length!==n.expectedRecordCount)throw new yI(`${t} stream declares ${n.expectedRecordCount} records but contains ${i.length}`);return y1e(i,t)}function y1e(t,e){for(const[n,o]of t.entries()){const i={recordIndex:n,streamPath:`/${e}/Data`};o.setSourceLocation(i);for(const[r,s]of o.items.entries())s.setSourceLocation({...i,fieldIndex:r})}return t}function xXi(t,e,n){const o=t==="Tracks6"?33:t==="Arcs6"?45:t==="Fills6"?37:31;if(e.byteLength<o)throw new hh(`${t} primitive payload is shorter than ${o} bytes`,n);const i=new DataView(e.buffer,e.byteOffset,e.byteLength),r=LS(i.getUint8(0));if(t==="Fills6"){const A=i.getUint8(2)===2,c=[fi("RECORD","Fill"),fi("LAYER",r),fi("LOCKED",g_((i.getUint8(1)&4)===0)),fi("KEEPOUT",g_(A)),fi("NET",String(i.getUint16(3,!0))),fi("COMPONENT",String(i.getUint16(7,!0))),na("X1",i.getInt32(13,!0)),na("Y1",i.getInt32(17,!0)),na("X2",i.getInt32(21,!0)),na("Y2",i.getInt32(25,!0)),fi("ROTATION",i8(i.getFloat64(29,!0))),fi("KEEPOUTRESTRICTIONS",String(e.byteLength>=47?i.getUint8(46):A?31:0))];return e.byteLength>=46&&c.push(fi("LAYER_V7_ID",String(i.getUint32(42,!0)))),e.byteLength>37&&e.byteLength<46&&c.push(fi("UNPARSEDTRAILINGBYTES",String(e.byteLength-37))),e.byteLength>47&&c.push(fi("UNPARSEDTRAILINGBYTES",String(e.byteLength-47))),new M1n({items:c,originalBinaryPayload:e})}const s=i.getUint16(1,!0),a=[fi("LAYER",r),fi("LOCKED",g_((i.getUint8(1)&4)===0)),...(s&IXi)!==0?[fi("KEEPOUT","TRUE")]:[],fi("NET",String(i.getUint16(3,!0))),fi("COMPONENT",String(i.getUint16(7,!0))),fi("POLYGON",String(i.getUint16(9,!0)))];return t==="Tracks6"?new T1n({originalBinaryPayload:e,items:[fi("RECORD","Track"),...a,na("X1",i.getInt32(13,!0)),na("Y1",i.getInt32(17,!0)),na("X2",i.getInt32(21,!0)),na("Y2",i.getInt32(25,!0)),na("WIDTH",i.getInt32(29,!0))]}):t==="Arcs6"?new P1n({originalBinaryPayload:e,items:[fi("RECORD","Arc"),...a,na("LOCATION.X",i.getInt32(13,!0)),na("LOCATION.Y",i.getInt32(17,!0)),na("RADIUS",i.getInt32(21,!0)),fi("STARTANGLE",i8(i.getFloat64(25,!0))),fi("ENDANGLE",i8(i.getFloat64(33,!0))),na("WIDTH",i.getInt32(41,!0))]}):new k1n({originalBinaryPayload:e,items:[fi("RECORD","Via"),fi("LAYER","MULTILAYER"),fi("LOCKED",g_((i.getUint8(1)&4)===0)),fi("TENTEDTOP",g_((i.getUint8(1)&32)!==0)),fi("TENTEDBOTTOM",g_((i.getUint8(1)&64)!==0)),fi("NET",String(i.getUint16(3,!0))),na("X",i.getInt32(13,!0)),na("Y",i.getInt32(17,!0)),na("DIAMETER",i.getInt32(21,!0)),na("HOLESIZE",i.getInt32(25,!0)),fi("STARTLAYER",LS(i.getUint8(29))),fi("ENDLAYER",LS(i.getUint8(30)))]})}function EXi(t,e){const n=e.maximumRecordLength??16777216,o=[],i=new DataView(t.buffer,t.byteOffset,t.byteLength);let r=0;for(;r<t.byteLength;){const s=r;if(t[r]!==C1e.Pads6)throw new yI(`Pads6 record at offset ${s} has unexpected primitive type ${t[r]}`);r+=1;const a=[];for(let l=0;l<6;l++){const u=r;if(r+4>t.byteLength)throw new hh(`Pads6 subrecord ${l+1} length is truncated`,r);const g=i.getUint32(r,!0)&16777215;if(r+=4,g>n)throw new hh(`Invalid Pads6 subrecord length ${g}`,u);if(r+g>t.byteLength)throw new hh(`Pads6 subrecord ${l+1} at offset ${u} exceeds its stream`,u);a.push(t.subarray(r,r+g)),r+=g}const A=MXi(a[0]??new Uint8Array),c=a[4];if(!c||c.byteLength<110)throw new hh("Pads6 geometry subrecord is shorter than 110 bytes",s);o.push(vXi(A,c,a[5]))}if(e.expectedRecordCount!==void 0&&o.length!==e.expectedRecordCount)throw new yI(`Pads6 stream declares ${e.expectedRecordCount} records but contains ${o.length}`);return o}function BXi(t,e){const n=e.maximumRecordLength??16777216,o=[],i=new DataView(t.buffer,t.byteOffset,t.byteLength);let r=0;for(;r<t.byteLength;){const s=r;if(t[r]!==C1e.Texts6)throw new yI(`Texts6 record at offset ${s} has unexpected primitive type ${t[r]}`);r+=1;const a=VXe("Texts6 properties",t,i,r,n);r=a.nextOffset;const A=VXe("Texts6 legacy text",t,i,r,n);r=A.nextOffset,o.push(bXi(a.payload,A.payload,e.wideStrings,s))}return O1n("Texts6",o,e.expectedRecordCount),o}function bXi(t,e,n,o){if(t.byteLength<40)throw new hh("Texts6 properties subrecord is shorter than 40 bytes",o);const i=new DataView(t.buffer,t.byteOffset,t.byteLength),r=t.byteLength>=119?i.getUint32(115,!0):4294967295,s=n?.get(r)??DXi(e),a=[fi("RECORD","Text"),fi("LAYER",LS(i.getUint8(0))),fi("LOCKED",g_((i.getUint8(1)&4)===0)),fi("COMPONENT",String(i.getUint16(7,!0))),na("X",i.getInt32(13,!0)),na("Y",i.getInt32(17,!0)),na("HEIGHT",i.getInt32(21,!0)),fi("STROKEFONT",String(i.getUint16(25,!0))),fi("ROTATION",i8(i.getFloat64(27,!0))),fi("MIRROR",g_(i.getUint8(35)!==0)),na("WIDTH",i.getInt32(36,!0)),fi("WIDESTRINGINDEX",String(r)),fi("WIDESTRING",RXi(s))];return t.byteLength>=137&&a.push(fi("COMMENT",g_(i.getUint8(40)!==0)),fi("DESIGNATOR",g_(i.getUint8(41)!==0)),fi("FONTTYPE",String(i.getUint8(43))),fi("BOLD",g_(i.getUint8(44)!==0)),fi("ITALIC",g_(i.getUint8(45)!==0)),fi("FONTNAME",NXi(t.subarray(46,110))),fi("INVERTED",g_(i.getUint8(110)!==0)),na("MARGINBORDERWIDTH",i.getInt32(111,!0)),fi("INVERTEDRECT",g_(i.getUint8(123)!==0)),na("TEXTBOXWIDTH",i.getInt32(124,!0)),na("TEXTBOXHEIGHT",i.getInt32(128,!0)),fi("JUSTIFICATION",String(i.getUint8(132))),na("TEXTOFFSET",i.getInt32(133,!0))),t.byteLength>=230&&a.push(fi("LAYER_V7",LS(i.getUint32(226,!0)))),new R1n({items:a,originalBinaryPayload:t})}function SXi(t,e,n){const o=CXi[t],i=n.maximumRecordLength??16*1024*1024,r=[],s=new DataView(e.buffer,e.byteOffset,e.byteLength);let a=0;for(;a<e.byteLength;){const A=a;if(e[a]!==C1e[t])throw new yI(`${t} record at offset ${A} has unexpected primitive type ${e[a]}`);a+=1;const c=VXe(t,e,s,a,i);r.push(QXi(c.payload,A,t,o.recordKind,o.extendedVertices)),a=c.nextOffset}return O1n(t,r,n.expectedRecordCount),r}function QXi(t,e,n,o,i){if(t.byteLength<26)throw new hh(`${n} payload is shorter than 26 bytes`,e);const r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=r.getUint32(18,!0)&16777215,a=22,A=a+s;if(A+4>t.byteLength)throw new hh(`${n} property block exceeds its record`,e+a);const c=new Uint8Array(s+1);c[0]=124,c.set(t.subarray(a,A),1);const l=UXe(c,o),u=r.getUint8(1),g=Number(l.getCaseInsensitive("KIND")??0),h=l.getBoolean("ISBOARDCUTOUT")===!0,d=[fi("SOURCESTREAM",n),fi("LAYER",LS(r.getUint8(0))),fi("LOCKED",g_((u&4)===0)),fi("TEARDROP",g_((u&16)!==0)),fi("KEEPOUT",g_(r.getUint8(2)===2)),fi("NET",String(r.getUint16(3,!0))),fi("POLYGON",String(r.getUint16(5,!0))),fi("COMPONENT",String(r.getUint16(7,!0))),fi("HOLECOUNT",String(r.getUint16(14,!0)))];(n==="BoardRegions"||n==="Regions6"||n==="ShapeBasedRegions6")&&d.push(fi("REGIONKIND",PXi(n,g,h)));let p=A;const _=r.getUint32(p,!0)+(i?1:0);p+=4,i?zXe(`${n} outline`,_,37,p,t.byteLength,e):zXe(`${n} outline`,_,16,p,t.byteLength,e);for(let y=0;y<_;y++)if(i){const x=r.getUint8(p)!==0;d.push(fi(`KIND${y}`,x?"1":"0"),na(`VX${y}`,r.getInt32(p+1,!0)),na(`VY${y}`,r.getInt32(p+5,!0)),na(`CX${y}`,r.getInt32(p+9,!0)),na(`CY${y}`,r.getInt32(p+13,!0)),na(`R${y}`,r.getInt32(p+17,!0)),fi(`SA${y}`,i8(r.getFloat64(p+21,!0))),fi(`EA${y}`,i8(r.getFloat64(p+29,!0)))),p+=37}else d.push(fi(`KIND${y}`,"0"),na(`VX${y}`,r.getFloat64(p,!0)),na(`VY${y}`,r.getFloat64(p+8,!0))),p+=16;const f=r.getUint16(14,!0);for(let y=0;y<f;y++){if(p+4>t.byteLength)throw new hh(`${n} hole ${y} count is truncated`,e+p);const x=r.getUint32(p,!0);p+=4,zXe(`${n} hole ${y}`,x,16,p,t.byteLength,e),d.push(fi(`HOLE${y}COUNT`,String(x)));for(let E=0;E<x;E++)d.push(na(`HOLE${y}VX${E}`,r.getFloat64(p,!0)),na(`HOLE${y}VY${E}`,r.getFloat64(p+8,!0))),p+=16}p!==t.byteLength&&d.push(fi("UNPARSEDTRAILINGBYTES",String(t.byteLength-p)));const I=l.items,C=[];I[0]&&C.push(I[0]);for(const y of d)C.push(y.setParent(l));for(let y=1;y<I.length;y+=1){const x=I[y];x&&C.push(x)}return l.items=C,l.setOriginalBinaryPayload(t),l}function vXi(t,e,n){const o=new DataView(e.buffer,e.byteOffset,e.byteLength),i=o.getUint8(49),r=o.getUint8(1),s=o.getUint8(62),a=[fi("RECORD","Pad"),fi("NAME",t),fi("LAYER",LS(o.getUint8(0))),fi("LOCKED",g_((r&4)===0)),fi("TENTEDTOP",g_((r&32)!==0)),fi("TENTEDBOTTOM",g_((r&64)!==0)),fi("NET",String(o.getUint16(3,!0))),fi("COMPONENT",String(o.getUint16(7,!0))),na("X",o.getInt32(13,!0)),na("Y",o.getInt32(17,!0)),na("XSIZE",o.getInt32(21,!0)),na("YSIZE",o.getInt32(25,!0)),na("MIDXSIZE",o.getInt32(29,!0)),na("MIDYSIZE",o.getInt32(33,!0)),na("BOTTOMXSIZE",o.getInt32(37,!0)),na("BOTTOMYSIZE",o.getInt32(41,!0)),na("HOLESIZE",o.getInt32(45,!0)),fi("SHAPE",x1e(i)),fi("MIDSHAPE",x1e(o.getUint8(50))),fi("BOTTOMSHAPE",x1e(o.getUint8(51))),fi("ROTATION",i8(o.getFloat64(52,!0))),fi("PLATED",o.getUint8(60)===0?"FALSE":"TRUE"),fi("PADMODE",String(s)),fi("PADSTACKMODE",FXi(s)),na("PASTEMASKEXPANSION_MANUAL",o.getInt32(86,!0)),na("SOLDERMASKEXPANSION_MANUAL",o.getInt32(90,!0)),fi("PASTEMASKEXPANSIONMODE",G1n(o.getUint8(101))),fi("SOLDERMASKEXPANSIONMODE",G1n(o.getUint8(102)))];return e.byteLength>=114&&a.push(fi("HOLEROTATION",i8(o.getFloat64(106,!0)))),e.byteLength>=120&&a.push(fi("TOLAYER",LS(o.getUint8(114))),fi("FROMLAYER",LS(o.getUint8(117)))),n&&n.byteLength>=596&&a.push(...wXi(n)),new D1n({items:a,originalBinaryPayload:e})}function wXi(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=[fi("STACKDATALENGTH",String(t.byteLength)),fi("HOLETYPE",String(e.getUint8(262))),fi("HOLESHAPE",kXi(e.getUint8(262))),na("SLOTLENGTH",e.getInt32(263,!0)),fi("SLOTROTATION",i8(e.getFloat64(267,!0)))];t.byteLength>596&&n.push(fi("UNPARSEDSTACKBYTES",String(t.byteLength-596)));for(let o=0;o<32;o++)n.push(na(`LAYER${o}HOLEXOFFSET`,e.getInt32(275+o*4,!0)),na(`LAYER${o}HOLEYOFFSET`,e.getInt32(403+o*4,!0)),fi(`LAYER${o}ALTSHAPE`,TXi(e.getUint8(532+o))),fi(`LAYER${o}CORNERRADIUS`,String(e.getUint8(564+o))));for(let o=0;o<29;o++){const i=o+2;n.push(na(`LAYER${i}XSIZE`,e.getInt32(o*4,!0)),na(`LAYER${i}YSIZE`,e.getInt32(116+o*4,!0)),fi(`LAYER${i}SHAPE`,x1e(e.getUint8(232+o))))}return n}function VXe(t,e,n,o,i){if(o+4>e.byteLength)throw new hh(`${t} subrecord length is truncated`,o);const r=o,s=n.getUint32(o,!0)&16777215;if(o+=4,s>i)throw new hh(`Invalid ${t} subrecord length ${s}`,r);if(o+s>e.byteLength)throw new hh(`${t} subrecord at offset ${r} exceeds its stream`,r);return{nextOffset:o+s,payload:e.subarray(o,o+s)}}function O1n(t,e,n){if(n!==void 0&&e.length!==n)throw new yI(`${t} stream declares ${n} records but contains ${e.length}`)}function zXe(t,e,n,o,i,r){const s=i-o;if(e>Math.floor(s/n))throw new hh(`${t} declares ${e} vertices but exceeds its record`,r+o)}function PXi(t,e,n){return t==="BoardRegions"?"LAYER_STACK_REGION":e===0?n?"BOARD_CUTOUT":"COPPER":e===1?"POLYGON_CUTOUT":e===2?"DASHED_OUTLINE":e===3?"UNKNOWN_3":e===4?"CAVITY_DEFINITION":`UNKNOWN_${e}`}function MXi(t){if(t.byteLength===0)return"";const e=t[0]??0,n=Math.min(e+1,t.byteLength);return new TextDecoder("windows-1252").decode(t.subarray(1,n))}function DXi(t){if(t.byteLength===0)return"";const e=t[0]??0,n=Math.min(e+1,t.byteLength);return new TextDecoder("windows-1252").decode(t.subarray(1,n)).replaceAll(`\r
`,`
`)}function NXi(t){return Y1n(t).replace(/\0.*$/su,"")}function RXi(t){return Array.from(t,e=>String(e.codePointAt(0)??0)).join(",")}function x1e(t){return t===1?"ROUND":t===2?"RECTANGLE":t===3?"OCTAGONAL":`SHAPE${t}`}function TXi(t){return t===0?"DEFAULT":t===1?"ROUND":t===2?"RECTANGLE":t===3?"OCTAGONAL":t===9?"ROUNDRECT":`ALTSHAPE${t}`}function kXi(t){return t===0?"ROUND":t===1?"SQUARE":t===2?"SLOT":`HOLESHAPE${t}`}function FXi(t){return t===0?"SIMPLE":t===1?"TOP_MIDDLE_BOTTOM":t===2?"FULL_STACK":`PADMODE${t}`}function G1n(t){return t===0?"None":t===1?"Rule":t===2?"Manual":`Mode${t}`}function fi(t,e){return new a9({key:t,value:e})}function g_(t){return t?"TRUE":"FALSE"}function na(t,e){return fi(t,`${i8(e/1e4,4)}mil`)}function i8(t,e=10){return Number.isFinite(t)?t.toFixed(e).replace(/\.?0+$/u,"").replace(/^-0$/u,"0"):"0"}function LS(t){return t===1?"TOP":t>=2&&t<=31?`MID-LAYER${t-1}`:t===32?"BOTTOM":t===33?"TOPOVERLAY":t===34?"BOTTOMOVERLAY":t===35?"TOPPASTE":t===36?"BOTTOMPASTE":t===37?"TOPSOLDER":t===38?"BOTTOMSOLDER":t>=39&&t<=54?`INTERNALPLANE${t-38}`:t===55?"DRILLGUIDE":t===56?"KEEPOUT":t>=57&&t<=72?`MECHANICAL${t-56}`:t===73?"DRILLDRAWING":t===74?"MULTILAYER":t===75?"CONNECTIONS":t===76?"BACKGROUND":t===77?"DRCERROR":t===78?"SELECTIONS":t===79?"VISIBLEGRID1":t===80?"VISIBLEGRID2":t===81?"PADHOLES":t===82?"VIAHOLES":t>=83&&t<=98?`MECHANICAL${t-66}`:`LAYER${t}`}function LXi(t,e=16*1024*1024){const n=new Map,o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(;i<t.byteLength;){if(i+8>t.byteLength)throw new hh("WideStrings6 entry header is truncated",i);const r=o.getUint32(i,!0),s=o.getUint32(i+4,!0);if(i+=8,s>e||i+s>t.byteLength)throw new hh(`WideStrings6 entry ${r} has invalid length ${s}`,i-4);const a=s<=2?0:s,A=a===0?"":Y1n(t.subarray(i,i+a-2)).replaceAll(`\r
`,`
`);n.set(r,A),i+=a}return n}function Y1n(t){let e="";for(let n=0;n+1<t.byteLength;n+=2)e+=String.fromCharCode((t[n]??0)|(t[n+1]??0)<<8);return e}var HXi={Board6:{recordKind:"Board"},Classes6:{recordKind:"Class"},Components6:{recordKind:"Component"},Connections6:{allowOpaqueRecords:!0,recordKind:"Connection"},Dimensions6:{headerSize:6,recordKind:"Dimension"},FileVersionInfo:{recordKind:"FileVersionInfo"},FromTos6:{recordKind:"FromTo"},Models:{recordKind:"Model"},Nets6:{recordKind:"Net"},Polygons6:{recordKind:"Polygon"},Rules6:{headerSize:6,recordKind:"Rule"},SignalClasses:{recordKind:"SignalClass"},SmartUnions:{recordKind:"SmartUnion"},UniqueIDPrimitiveInformation:{recordKind:"UniqueIDPrimitiveInformation"}},OXi=new Set(["Arcs6","BoardRegions","ComponentBodies6","Fills6","Pads6","Regions6","ShapeBasedRegions6","ShapeBasedComponentBodies6","Texts6","Tracks6","Vias6"]);function U1n(t,e={}){if(!f1e(t))throw new yI("Binary PcbDoc input does not begin with the OLE/CFB signature");const n=Vee(t,e);if(!n.getStream("/Board6/Data")||!n.getStream("/Board6/Header"))throw new yI("Compound document does not contain the Board6 PCB streams");const o=new Set(n.streams.filter(c=>c.path.length>=2).map(c=>c.path[0]).filter(c=>c!==void 0)),i=new Map,r=new Map,s=[],a=n.getStream("/WideStrings6/Data"),A=a?LXi(a.content):new Map;for(const c of[...o].sort()){const l=n.getStream([c,"Data"]),u=n.getStream([c,"Header"]),g=u?YXi(u.content):void 0,h=HXi[c],d=l&&h?GXi({allowOpaqueRecords:h.allowOpaqueRecords,allowMissingLeadingDelimiter:c==="Models",bytes:l.content,expectedRecordCount:g,family:c,headerSize:h.headerSize,maximumRecordLength:e.maxPropertyRecordLength,recordKind:h.recordKind}):[],p=l&&OXi.has(c)?yXi(c,l.content,{expectedRecordCount:g,maximumRecordLength:e.maxPrimitiveRecordLength,wideStrings:A}):[];d.length>0&&i.set(c,d),p.length>0&&r.set(c,p),s.push({dataSize:l?.content.byteLength,declaredRecordCount:g,decodedPrimitiveRecordCount:p.length,decodedPropertyRecordCount:d.length,family:c,hasData:l!==void 0,hasHeader:u!==void 0})}return new P$i({compoundFile:n,primitiveRecords:r,propertyRecords:i,streamSummaries:s,wideStrings:A})}function GXi({allowOpaqueRecords:t=!1,allowMissingLeadingDelimiter:e=!1,bytes:n,expectedRecordCount:o,recordKind:i,family:r=i,headerSize:s=4,maximumRecordLength:a=16*1024*1024}){if(n.byteLength===0)return[];const A=[],c=new DataView(n.buffer,n.byteOffset,n.byteLength);let l=0,u=0;for(;l<n.byteLength;){const g=l;if(l+s>n.byteLength)throw new hh(`${i} property record length is truncated`,l);const d=c.getUint32(s===6?l+2:l,!0)&16777215,p=s===6?c.getUint16(l,!0):void 0;if(l+=s,d===0||d>a)throw new hh(`Invalid ${i} property record length ${d}`,g);if(l+d>n.byteLength)throw new hh(`${i} property record at offset ${g} exceeds its stream`,g);const m=n.subarray(l,l+d);if(m[0]!==124&&!e){if(t){u+=1,l+=d;continue}throw new yI(`${i} property record at offset ${g} does not begin with "|"`)}const f={byteOffset:g,recordIndex:u,streamPath:`/${r}/Data`},I=UXe(m,i,f);p!==void 0&&(I.insertField("BINARYRECORDTYPE",String(p),{index:1}),I.clearDirty(!0)),A.push(I),u+=1,l+=d}if(o!==void 0&&u!==o)throw new yI(`${i} stream declares ${o} records but contains ${u}`);return A}function YXi(t){if(!(t.byteLength<4))return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!0)}var K1n=class extends pXe{type="raw-line";_raw;constructor(t){if(super(t),/[\r\n]/u.test(t.raw))throw new Error("Raw Altium lines cannot include their line terminator");this._raw=t.raw}get raw(){return this._raw}set raw(t){if(/[\r\n]/u.test(t))throw new Error("Raw Altium lines cannot include their line terminator");t!==this._raw&&(this._raw=t,this.markDirty())}getChildren(){return[]}getString(){return this.raw}};function JXe(t,e={}){if(typeof t!="string")throw new eM("parseAltiumAscii expects decoded text; use parseAltiumFile() for binary or byte input");z1n(e.signal);const n=t.startsWith("\uFEFF"),o=n?t.slice(1):t,i=zXi(o,n?1:0),r=e.maxLineCount??1e6;if(i.length>r)throw new eM(`Altium text has ${i.length} lines, exceeding the configured limit of ${r}`);const s=i.map((A,c)=>(z1n(e.signal),UXi(A.content,A.terminator,c+1,A.startOffset,e)));return n?[new K1n({raw:"\uFEFF",terminator:"",nodeId:"text:bom",sourceLocation:{column:1,endColumn:2,endLine:1,endOffset:1,line:1,startOffset:0}}),...s]:s}function UXi(t,e,n,o,i){const r={column:1,endColumn:t.length+1,endLine:n,endOffset:o+t.length,line:n,startOffset:o},s=i.maxLineLength??16*1024*1024;if(t.length>s)throw new eM(`Altium line ${n} has ${t.length} characters, exceeding the configured limit of ${s}`,{excerpt:ik(i,t),location:r});if(!t.startsWith("|")){if(V1n(i)&&t.length>0)throw new eM(i.redactSourceText?`Expected an Altium record at line ${n}`:`Expected an Altium record at line ${n}, got ${JSON.stringify(t.slice(0,40))}`,{excerpt:ik(i,t),location:r});return t.length>0&&WXe(i,{code:"ALTIUM_RAW_TEXT_LINE",excerpt:ik(i,t),location:r,message:`Preserved non-record text at line ${n}`,severity:"warning"}),new K1n({raw:t,terminator:e,nodeId:`text:${o}:raw-line`,sourceLocation:r})}const a=t.slice(1).split("|"),A=i.maxFieldsPerRecord??1e5;if(a.length>A)throw new eM(`Altium record at line ${n} has ${a.length} fields, exceeding the configured limit of ${A}`,{excerpt:ik(i,t),location:r});let c=o+1;const l=a.map((h,d)=>{const p=KXi(h,{itemIndex:d,lineStartOffset:o,lineNumber:n,options:i,startOffset:c});return c+=h.length+1,p}),u=VXi(l);if(u===void 0){if(V1n(i))throw new eM(`Altium record at line ${n} has no RECORD field`,{excerpt:ik(i,t),location:r});return WXe(i,{code:"ALTIUM_RECORD_KIND_MISSING",excerpt:ik(i,t),location:r,message:`Preserved record without a RECORD field at line ${n}`,severity:"warning"}),new I1e({items:l,terminator:e,nodeId:`text:${o}:unknown-record`,sourceLocation:r})}const g=H1n.get(u)??I1e;return new g({items:l,terminator:e,nodeId:`text:${o}:record:${u}`,sourceLocation:r})}function KXi(t,e){const n={column:e.startOffset-e.lineStartOffset+1,endColumn:e.startOffset-e.lineStartOffset+t.length+1,endLine:e.lineNumber,endOffset:e.startOffset+t.length,line:e.lineNumber,startOffset:e.startOffset},o=`text:${e.startOffset}:item:${e.itemIndex}`,i=t.indexOf("=");return i<=0?(t.length>0&&WXe(e.options,{code:"ALTIUM_RAW_FIELD",excerpt:ik(e.options,t),location:n,message:`Preserved malformed field segment at line ${e.lineNumber}`,severity:"warning"}),new F1n({raw:t,nodeId:o,sourceLocation:n})):new a9({key:t.slice(0,i),nodeId:o,sourceLocation:n,value:t.slice(i+1)})}function VXi(t){return new I1e({items:t}).recordKind}function zXi(t,e=0){const n=[];let o=0;for(let i=0;i<t.length;i++){const r=t[i];if(r!=="\r"&&r!==`
`)continue;const s=r==="\r"&&t[i+1]===`
`,a=s?`\r
`:r;n.push({content:t.slice(o,i),startOffset:e+o,terminator:a}),s&&i++,o=i+1}return o<t.length&&n.push({content:t.slice(o),startOffset:e+o,terminator:""}),n}function V1n(t){return t.strict===!0||t.mode==="strict"}function WXe(t,e){t.onDiagnostic?.(e)}function JXi(t,e=120){return t.length<=e?t:`${t.slice(0,e)}…`}function ik(t,e){return t.redactSourceText?void 0:JXi(e)}function z1n(t){t?.throwIfAborted()}function E1e(t,e={}){if(typeof t!="string")throw new eM("parseAltiumPcbDoc expects decoded text; use parseAltiumFile() for binary or byte input");const n=JXe(t,e),o=n.find(i=>i instanceof Ol);if(o?.recordKind!=="Board")throw new eM(`Expected an Altium Board root record, got ${o?.recordKind??"none"}`,{location:o?.sourceLocation,recordKind:o?.recordKind});return new U$i({lines:n,originalSource:t})}function jXe(t,e={}){if(typeof t=="string"){const s=new d1e({lines:JXe(t,e),originalText:t,sourceFormat:"ascii"});return J1n(s),s}if(!f1e(t)){const s=SXe(t,e.encoding),a=new d1e({lines:JXe(s.text,e),originalBytes:t.slice(),originalText:s.text,sourceEncoding:s.encoding,sourceFormat:"ascii"});return J1n(a),a}const n=Vee(t,e),o=n.getStream("/FileHeader");if(!o)throw new yI("Compound document does not contain a FileHeader stream");const i=WXi(o.content,e.maxRecordLength);if(!i[0]?.getCaseInsensitive("HEADER")?.toLowerCase().includes("schematic capture"))throw new yI("FileHeader is not an Altium schematic record stream");return new d1e({compoundFile:n,lines:i,originalBytes:t.slice(),sourceFormat:"binary"})}function J1n(t){if(!t.header?.getCaseInsensitive("HEADER")?.toLowerCase().includes("schematic capture")&&t.getRecordsByKind("31").length===0)throw new yI("Expected an Altium schematic header or sheet record")}function WXi(t,e=16*1024*1024){const n=[],o=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(;i<t.byteLength;){const r=i;if(i+4>t.byteLength)throw new hh("Schematic record length is truncated",i);const a=o.getUint32(i,!0)&16777215;if(i+=4,a===0||a>e)throw new hh(`Invalid schematic record length ${a}`,r);if(i+a>t.byteLength)throw new hh(`Schematic record at offset ${r} declares ${a} bytes with only ${t.byteLength-i} available`,r);const A=UXe(t.subarray(i,i+a),void 0,{byteOffset:r,recordIndex:n.length,streamPath:"/FileHeader"}),c=i+a<t.byteLength?`
`:"";A.terminator=c,n.push(A),i+=a}return n}function jXi(t,e={}){const n=e.maxFileSize??268435456;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("maxFileSize must be a positive safe integer");if(t.byteLength>n)throw new aA(`Altium file is ${t.byteLength} bytes, exceeding the ${n}-byte limit`);if(e.signal?.aborted)throw e.signal.reason??new DOMException("Parsing aborted","AbortError");const o=$qi(t,e);if(o.container==="cfb"){if(o.documentKind==="pcb-document")return{detection:o,document:U1n(t,e)};if(o.documentKind==="schematic-document")return{detection:o,document:jXe(t,e)};if(o.documentKind==="pcb-library"||o.documentKind==="schematic-library"||o.documentKind==="integrated-library"){if(e.allowUnknownCompoundFile)return{detection:o,document:Vee(t,e)};throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet fixture-verified`)}if(e.allowUnknownCompoundFile)return{detection:o,document:Vee(t,e)};throw new yI("Compound file is not a recognized Altium PCB or schematic document")}if(o.container==="zip"||o.container==="xml")throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet implemented`);if(o.documentKind==="pcb-library"||o.documentKind==="schematic-library"||o.documentKind==="integrated-library")throw new dXe(`${o.documentKind} detection is supported, but semantic parsing is not yet fixture-verified`);const i=SXe(t,e.encoding);if(o.documentKind==="project"){const r=y1n(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind==="output-job"){const r=kqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind==="workspace"){const r=Uqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind==="ini-document"){if(!e.allowUnknownIni&&o.documentKind==="ini-document")throw new yI("INI input is not a recognized Altium project, workspace, or output job");const r=Nqi(i.text).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind==="pcb-document"){const r=E1e(i.text,e).setOriginalBytes(t,i.encoding);return{detection:o,document:r}}if(o.documentKind==="schematic-document")return{detection:o,document:jXe(t,e)};throw new yI("Text input is not a recognized Altium PCB or schematic document")}var LE=class{constructor(t=256,e=64*1024*1024){if(this.maximumLength=e,!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(e)||e<=0||t>e)throw new RangeError("Invalid binary writer capacity or limit");this.bytes=new Uint8Array(t),this.view=new DataView(this.bytes.buffer)}maximumLength;bytes;view;_length=0;get length(){return this._length}uint8(t){return this.ensure(1),this.view.setUint8(this._length,t),this._length++,this}int8(t){return this.ensure(1),this.view.setInt8(this._length,t),this._length++,this}uint16(t){return this.ensure(2),this.view.setUint16(this._length,t,!0),this._length+=2,this}int16(t){return this.ensure(2),this.view.setInt16(this._length,t,!0),this._length+=2,this}uint32(t){return this.ensure(4),this.view.setUint32(this._length,t,!0),this._length+=4,this}int32(t){return this.ensure(4),this.view.setInt32(this._length,t,!0),this._length+=4,this}float64(t){return this.ensure(8),this.view.setFloat64(this._length,t,!0),this._length+=8,this}writeBytes(t){return this.ensure(t.byteLength),this.bytes.set(t,this._length),this._length+=t.byteLength,this}uint32LengthPrefixedBytes(t){return this.uint32(t.byteLength).writeBytes(t)}pascalString(t,e="windows-1252"){const n=$Xi(t,e);if(n.byteLength>255)throw new RangeError("Pascal string exceeds 255 bytes");return this.uint8(n.byteLength).writeBytes(n)}guid(t){const e=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/iu.exec(t);if(!e)throw new TypeError("Invalid GUID");return this.uint32(Number.parseInt(e[1]??"",16)),this.uint16(Number.parseInt(e[2]??"",16)),this.uint16(Number.parseInt(e[3]??"",16)),this.writeBytes(Uint8Array.from(`${e[4]}${e[5]}`.match(/.{2}/gu)?.map(n=>Number.parseInt(n,16))??[]))}toUint8Array(){return this.bytes.slice(0,this._length)}ensure(t){const e=this._length+t;if(!Number.isSafeInteger(e)||e>this.maximumLength)throw new RangeError(`Binary output exceeds the ${this.maximumLength}-byte limit`);if(e<=this.bytes.byteLength)return;let n=Math.max(this.bytes.byteLength,1);for(;n<e;)if(n=Math.min(n*2,this.maximumLength),n<e&&n===this.maximumLength)throw new RangeError(`Binary output exceeds the ${this.maximumLength}-byte limit`);const o=new Uint8Array(n);o.set(this.bytes),this.bytes=o,this.view=new DataView(o.buffer)}};function $Xi(t,e){if(e==="utf-8")return new TextEncoder().encode(t);const n=[];for(const o of t){const i=o.codePointAt(0);if(i===void 0||i>255)throw new RangeError("Windows-1252 writer currently accepts only single-byte code points");n.push(i)}return Uint8Array.from(n)}var $Xe={exports:{}};const qXi=wit(xfn);var W1n;function XXi(){return W1n||(W1n=1,(function(t){var e={},n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(Y){for(var W="",te=0,j=0,J=0,oe=0,ie=0,ne=0,le=0,ge=0;ge<Y.length;)te=Y.charCodeAt(ge++),oe=te>>2,j=Y.charCodeAt(ge++),ie=(te&3)<<4|j>>4,J=Y.charCodeAt(ge++),ne=(j&15)<<2|J>>6,le=J&63,isNaN(j)?ne=le=64:isNaN(J)&&(le=64),W+=n.charAt(oe)+n.charAt(ie)+n.charAt(ne)+n.charAt(le);return W}function i(Y){var W="",te=0,j=0,J=0,oe=0,ie=0,ne=0,le=0;Y=Y.replace(/[^\w\+\/\=]/g,"");for(var ge=0;ge<Y.length;)oe=n.indexOf(Y.charAt(ge++)),ie=n.indexOf(Y.charAt(ge++)),te=oe<<2|ie>>4,W+=String.fromCharCode(te),ne=n.indexOf(Y.charAt(ge++)),j=(ie&15)<<4|ne>>2,ne!==64&&(W+=String.fromCharCode(j)),le=n.indexOf(Y.charAt(ge++)),J=(ne&3)<<6|le,le!==64&&(W+=String.fromCharCode(J));return W}var r=(function(){return typeof Buffer<"u"&&typeof e<"u"&&typeof e.versions<"u"&&!!e.versions.node})(),s=(function(){if(typeof Buffer<"u"){var Y=!Buffer.from;if(!Y)try{Buffer.from("foo","utf8")}catch{Y=!0}return Y?function(W,te){return te?new Buffer(W,te):new Buffer(W)}:Buffer.from.bind(Buffer)}return function(){}})();function a(Y){if(r){if(Buffer.alloc)return Buffer.alloc(Y);var W=new Buffer(Y);return W.fill(0),W}return typeof Uint8Array<"u"?new Uint8Array(Y):new Array(Y)}function A(Y){return r?Buffer.allocUnsafe?Buffer.allocUnsafe(Y):new Buffer(Y):typeof Uint8Array<"u"?new Uint8Array(Y):new Array(Y)}var c=function(W){return r?s(W,"binary"):W.split("").map(function(te){return te.charCodeAt(0)&255})},l=/\u0000/g,u=/[\u0001-\u0006]/g,g=function(Y){for(var W=[],te=0;te<Y[0].length;++te)W.push.apply(W,Y[0][te]);return W},h=g,d=function(Y,W,te){for(var j=[],J=W;J<te;J+=2)j.push(String.fromCharCode(y(Y,J)));return j.join("").replace(l,"")},p=d,m=function(Y,W,te){for(var j=[],J=W;J<W+te;++J)j.push(("0"+Y[J].toString(16)).slice(-2));return j.join("")},_=m,f=function(Y){if(Array.isArray(Y[0]))return[].concat.apply([],Y);var W=0,te=0;for(te=0;te<Y.length;++te)W+=Y[te].length;var j=new Uint8Array(W);for(te=0,W=0;te<Y.length;W+=Y[te].length,++te)j.set(Y[te],W);return j},I=f;r&&(d=function(Y,W,te){return Buffer.isBuffer(Y)?Y.toString("utf16le",W,te).replace(l,""):p(Y,W,te)},m=function(Y,W,te){return Buffer.isBuffer(Y)?Y.toString("hex",W,W+te):_(Y,W,te)},g=function(Y){return Y[0].length>0&&Buffer.isBuffer(Y[0][0])?Buffer.concat(Y[0]):h(Y)},c=function(Y){return s(Y,"binary")},I=function(Y){return Buffer.isBuffer(Y[0])?Buffer.concat(Y):f(Y)});var C=function(Y,W){return Y[W]},y=function(Y,W){return Y[W+1]*256+Y[W]},x=function(Y,W){var te=Y[W+1]*256+Y[W];return te<32768?te:(65535-te+1)*-1},E=function(Y,W){return Y[W+3]*(1<<24)+(Y[W+2]<<16)+(Y[W+1]<<8)+Y[W]},B=function(Y,W){return(Y[W+3]<<24)+(Y[W+2]<<16)+(Y[W+1]<<8)+Y[W]};function S(Y,W){var te,j,J=0;switch(Y){case 1:te=C(this,this.l);break;case 2:te=(W!=="i"?y:x)(this,this.l);break;case 4:te=B(this,this.l);break;case 16:J=2,j=m(this,this.l,Y)}return this.l+=Y,J===0?te:j}var Q=function(Y,W,te){Y[te]=W&255,Y[te+1]=W>>>8&255,Y[te+2]=W>>>16&255,Y[te+3]=W>>>24&255},w=function(Y,W,te){Y[te]=W&255,Y[te+1]=W>>8&255,Y[te+2]=W>>16&255,Y[te+3]=W>>24&255};function M(Y,W,te){var j=0,J=0;switch(te){case"hex":for(;J<Y;++J)this[this.l++]=parseInt(W.slice(2*J,2*J+2),16)||0;return this;case"utf16le":var oe=this.l+Y;for(J=0;J<Math.min(W.length,Y);++J){var ie=W.charCodeAt(J);this[this.l++]=ie&255,this[this.l++]=ie>>8}for(;this.l<oe;)this[this.l++]=0;return this}switch(Y){case 1:j=1,this[this.l]=W&255;break;case 2:j=2,this[this.l]=W&255,W>>>=8,this[this.l+1]=W&255;break;case 4:j=4,Q(this,W,this.l);break;case-4:j=4,w(this,W,this.l);break}return this.l+=j,this}function k(Y,W){var te=m(this,this.l,Y.length>>1);if(te!==Y)throw new Error(W+"Expected "+Y+" saw "+te);this.l+=Y.length>>1}function R(Y,W){Y.l=W,Y.read_shift=S,Y.chk=k,Y.write_shift=M}function F(Y){var W=a(Y);return R(W,0),W}var O=(function(){var Y={};Y.version="1.2.1";function W(){for(var Ee=0,ke=new Array(256),Ce=0;Ce!=256;++Ce)Ee=Ce,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,Ee=Ee&1?-306674912^Ee>>>1:Ee>>>1,ke[Ce]=Ee;return typeof Int32Array<"u"?new Int32Array(ke):ke}var te=W();function j(Ee){var ke=0,Ce=0,Le=0,Ye=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(Le=0;Le!=256;++Le)Ye[Le]=Ee[Le];for(Le=0;Le!=256;++Le)for(Ce=Ee[Le],ke=256+Le;ke<4096;ke+=256)Ce=Ye[ke]=Ce>>>8^Ee[Ce&255];var tt=[];for(Le=1;Le!=16;++Le)tt[Le-1]=typeof Int32Array<"u"?Ye.subarray(Le*256,Le*256+256):Ye.slice(Le*256,Le*256+256);return tt}var J=j(te),oe=J[0],ie=J[1],ne=J[2],le=J[3],ge=J[4],_e=J[5],ue=J[6],fe=J[7],pe=J[8],ye=J[9],Me=J[10],ve=J[11],he=J[12],Qe=J[13],Pe=J[14];function we(Ee,ke){for(var Ce=ke^-1,Le=0,Ye=Ee.length;Le<Ye;)Ce=Ce>>>8^te[(Ce^Ee.charCodeAt(Le++))&255];return~Ce}function Te(Ee,ke){for(var Ce=ke^-1,Le=Ee.length-15,Ye=0;Ye<Le;)Ce=Pe[Ee[Ye++]^Ce&255]^Qe[Ee[Ye++]^Ce>>8&255]^he[Ee[Ye++]^Ce>>16&255]^ve[Ee[Ye++]^Ce>>>24]^Me[Ee[Ye++]]^ye[Ee[Ye++]]^pe[Ee[Ye++]]^fe[Ee[Ye++]]^ue[Ee[Ye++]]^_e[Ee[Ye++]]^ge[Ee[Ye++]]^le[Ee[Ye++]]^ne[Ee[Ye++]]^ie[Ee[Ye++]]^oe[Ee[Ye++]]^te[Ee[Ye++]];for(Le+=15;Ye<Le;)Ce=Ce>>>8^te[(Ce^Ee[Ye++])&255];return~Ce}function Re(Ee,ke){for(var Ce=ke^-1,Le=0,Ye=Ee.length,tt=0,At=0;Le<Ye;)tt=Ee.charCodeAt(Le++),tt<128?Ce=Ce>>>8^te[(Ce^tt)&255]:tt<2048?(Ce=Ce>>>8^te[(Ce^(192|tt>>6&31))&255],Ce=Ce>>>8^te[(Ce^(128|tt&63))&255]):tt>=55296&&tt<57344?(tt=(tt&1023)+64,At=Ee.charCodeAt(Le++)&1023,Ce=Ce>>>8^te[(Ce^(240|tt>>8&7))&255],Ce=Ce>>>8^te[(Ce^(128|tt>>2&63))&255],Ce=Ce>>>8^te[(Ce^(128|At>>6&15|(tt&3)<<4))&255],Ce=Ce>>>8^te[(Ce^(128|At&63))&255]):(Ce=Ce>>>8^te[(Ce^(224|tt>>12&15))&255],Ce=Ce>>>8^te[(Ce^(128|tt>>6&63))&255],Ce=Ce>>>8^te[(Ce^(128|tt&63))&255]);return~Ce}return Y.table=te,Y.bstr=we,Y.buf=Te,Y.str=Re,Y})(),U=(function(){var W={};W.version="1.2.2";function te(Et,Gt){for(var Rt=Et.split("/"),Ht=Gt.split("/"),Qt=0,Nt=0,_n=Math.min(Rt.length,Ht.length);Qt<_n;++Qt){if(Nt=Rt[Qt].length-Ht[Qt].length)return Nt;if(Rt[Qt]!=Ht[Qt])return Rt[Qt]<Ht[Qt]?-1:1}return Rt.length-Ht.length}function j(Et){if(Et.charAt(Et.length-1)=="/")return Et.slice(0,-1).indexOf("/")===-1?Et:j(Et.slice(0,-1));var Gt=Et.lastIndexOf("/");return Gt===-1?Et:Et.slice(0,Gt+1)}function J(Et){if(Et.charAt(Et.length-1)=="/")return J(Et.slice(0,-1));var Gt=Et.lastIndexOf("/");return Gt===-1?Et:Et.slice(Gt+1)}function oe(Et,Gt){typeof Gt=="string"&&(Gt=new Date(Gt));var Rt=Gt.getHours();Rt=Rt<<6|Gt.getMinutes(),Rt=Rt<<5|Gt.getSeconds()>>>1,Et.write_shift(2,Rt);var Ht=Gt.getFullYear()-1980;Ht=Ht<<4|Gt.getMonth()+1,Ht=Ht<<5|Gt.getDate(),Et.write_shift(2,Ht)}function ie(Et){var Gt=Et.read_shift(2)&65535,Rt=Et.read_shift(2)&65535,Ht=new Date,Qt=Rt&31;Rt>>>=5;var Nt=Rt&15;Rt>>>=4,Ht.setMilliseconds(0),Ht.setFullYear(Rt+1980),Ht.setMonth(Nt-1),Ht.setDate(Qt);var _n=Gt&31;Gt>>>=5;var qn=Gt&63;return Gt>>>=6,Ht.setHours(Gt),Ht.setMinutes(qn),Ht.setSeconds(_n<<1),Ht}function ne(Et){R(Et,0);for(var Gt={},Rt=0;Et.l<=Et.length-4;){var Ht=Et.read_shift(2),Qt=Et.read_shift(2),Nt=Et.l+Qt,_n={};Ht===21589&&(Rt=Et.read_shift(1),Rt&1&&(_n.mtime=Et.read_shift(4)),Qt>5&&(Rt&2&&(_n.atime=Et.read_shift(4)),Rt&4&&(_n.ctime=Et.read_shift(4))),_n.mtime&&(_n.mt=new Date(_n.mtime*1e3))),Et.l=Nt,Gt[Ht]=_n}return Gt}var le;function ge(){return le||(le=qXi)}function _e(Et,Gt){if(Et[0]==80&&Et[1]==75)return Ro(Et,Gt);if((Et[0]|32)==109&&(Et[1]|32)==105)return Rs(Et,Gt);if(Et.length<512)throw new Error("CFB file size "+Et.length+" < 512");var Rt=3,Ht=512,Qt=0,Nt=0,_n=0,qn=0,En=0,Rn=[],Hn=Et.slice(0,512);R(Hn,0);var Lo=ue(Hn);switch(Rt=Lo[0],Rt){case 3:Ht=512;break;case 4:Ht=4096;break;case 0:if(Lo[1]==0)return Ro(Et,Gt);default:throw new Error("Major Version: Expected 3 or 4 saw "+Rt)}Ht!==512&&(Hn=Et.slice(0,Ht),R(Hn,28));var Io=Et.slice(0,Ht);fe(Hn,Rt);var gi=Hn.read_shift(4,"i");if(Rt===3&&gi!==0)throw new Error("# Directory Sectors: Expected 0 saw "+gi);Hn.l+=4,_n=Hn.read_shift(4,"i"),Hn.l+=4,Hn.chk("00100000","Mini Stream Cutoff Size: "),qn=Hn.read_shift(4,"i"),Qt=Hn.read_shift(4,"i"),En=Hn.read_shift(4,"i"),Nt=Hn.read_shift(4,"i");for(var jo=-1,oi=0;oi<109&&(jo=Hn.read_shift(4,"i"),!(jo<0));++oi)Rn[oi]=jo;var Ji=pe(Et,Ht);ve(En,Nt,Ji,Ht,Rn);var wi=Qe(Ji,_n,Rn,Ht);wi[_n].name="!Directory",Qt>0&&qn!==At&&(wi[qn].name="!MiniFAT"),wi[Rn[0]].name="!FAT",wi.fat_addrs=Rn,wi.ssz=Ht;var Br={},gr=[],oa=[],hs=[];Pe(_n,wi,Ji,gr,Qt,Br,oa,qn),ye(oa,hs,gr),gr.shift();var Li={FileIndex:oa,FullPaths:hs};return Gt&&Gt.raw&&(Li.raw={header:Io,sectors:Ji}),Li}function ue(Et){if(Et[Et.l]==80&&Et[Et.l+1]==75)return[0,0];Et.chk(at,"Header Signature: "),Et.l+=16;var Gt=Et.read_shift(2,"u");return[Et.read_shift(2,"u"),Gt]}function fe(Et,Gt){var Rt=9;switch(Et.l+=2,Rt=Et.read_shift(2)){case 9:if(Gt!=3)throw new Error("Sector Shift: Expected 9 saw "+Rt);break;case 12:if(Gt!=4)throw new Error("Sector Shift: Expected 12 saw "+Rt);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+Rt)}Et.chk("0600","Mini Sector Shift: "),Et.chk("000000000000","Reserved: ")}function pe(Et,Gt){for(var Rt=Math.ceil(Et.length/Gt)-1,Ht=[],Qt=1;Qt<Rt;++Qt)Ht[Qt-1]=Et.slice(Qt*Gt,(Qt+1)*Gt);return Ht[Rt-1]=Et.slice(Rt*Gt),Ht}function ye(Et,Gt,Rt){for(var Ht=0,Qt=0,Nt=0,_n=0,qn=0,En=Rt.length,Rn=[],Hn=[];Ht<En;++Ht)Rn[Ht]=Hn[Ht]=Ht,Gt[Ht]=Rt[Ht];for(;qn<Hn.length;++qn)Ht=Hn[qn],Qt=Et[Ht].L,Nt=Et[Ht].R,_n=Et[Ht].C,Rn[Ht]===Ht&&(Qt!==-1&&Rn[Qt]!==Qt&&(Rn[Ht]=Rn[Qt]),Nt!==-1&&Rn[Nt]!==Nt&&(Rn[Ht]=Rn[Nt])),_n!==-1&&(Rn[_n]=Ht),Qt!==-1&&Ht!=Rn[Ht]&&(Rn[Qt]=Rn[Ht],Hn.lastIndexOf(Qt)<qn&&Hn.push(Qt)),Nt!==-1&&Ht!=Rn[Ht]&&(Rn[Nt]=Rn[Ht],Hn.lastIndexOf(Nt)<qn&&Hn.push(Nt));for(Ht=1;Ht<En;++Ht)Rn[Ht]===Ht&&(Nt!==-1&&Rn[Nt]!==Nt?Rn[Ht]=Rn[Nt]:Qt!==-1&&Rn[Qt]!==Qt&&(Rn[Ht]=Rn[Qt]));for(Ht=1;Ht<En;++Ht)if(Et[Ht].type!==0){if(qn=Ht,qn!=Rn[qn])do qn=Rn[qn],Gt[Ht]=Gt[qn]+"/"+Gt[Ht];while(qn!==0&&Rn[qn]!==-1&&qn!=Rn[qn]);Rn[Ht]=-1}for(Gt[0]+="/",Ht=1;Ht<En;++Ht)Et[Ht].type!==2&&(Gt[Ht]+="/")}function Me(Et,Gt,Rt){for(var Ht=Et.start,Qt=Et.size,Nt=[],_n=Ht;Rt&&Qt>0&&_n>=0;)Nt.push(Gt.slice(_n*tt,_n*tt+tt)),Qt-=tt,_n=B(Rt,_n*4);return Nt.length===0?F(0):I(Nt).slice(0,Et.size)}function ve(Et,Gt,Rt,Ht,Qt){var Nt=At;if(Et===At){if(Gt!==0)throw new Error("DIFAT chain shorter than expected")}else if(Et!==-1){var _n=Rt[Et],qn=(Ht>>>2)-1;if(!_n)return;for(var En=0;En<qn&&(Nt=B(_n,En*4))!==At;++En)Qt.push(Nt);Gt>=1&&ve(B(_n,Ht-4),Gt-1,Rt,Ht,Qt)}}function he(Et,Gt,Rt,Ht,Qt){var Nt=[],_n=[];Qt||(Qt=[]);var qn=Ht-1,En=0,Rn=0;for(En=Gt;En>=0;){Qt[En]=!0,Nt[Nt.length]=En,_n.push(Et[En]);var Hn=Rt[Math.floor(En*4/Ht)];if(Rn=En*4&qn,Ht<4+Rn)throw new Error("FAT boundary crossed: "+En+" 4 "+Ht);if(!Et[Hn])break;En=B(Et[Hn],Rn)}return{nodes:Nt,data:g([_n])}}function Qe(Et,Gt,Rt,Ht){var Qt=Et.length,Nt=[],_n=[],qn=[],En=[],Rn=Ht-1,Hn=0,Lo=0,Io=0,gi=0;for(Hn=0;Hn<Qt;++Hn)if(qn=[],Io=Hn+Gt,Io>=Qt&&(Io-=Qt),!_n[Io]){En=[];var jo=[];for(Lo=Io;Lo>=0;){jo[Lo]=!0,_n[Lo]=!0,qn[qn.length]=Lo,En.push(Et[Lo]);var oi=Rt[Math.floor(Lo*4/Ht)];if(gi=Lo*4&Rn,Ht<4+gi)throw new Error("FAT boundary crossed: "+Lo+" 4 "+Ht);if(!Et[oi]||(Lo=B(Et[oi],gi),jo[Lo]))break}Nt[Io]={nodes:qn,data:g([En])}}return Nt}function Pe(Et,Gt,Rt,Ht,Qt,Nt,_n,qn){for(var En=0,Rn=Ht.length?2:0,Hn=Gt[Et].data,Lo=0,Io=0,gi;Lo<Hn.length;Lo+=128){var jo=Hn.slice(Lo,Lo+128);R(jo,64),Io=jo.read_shift(2),gi=d(jo,0,Io-Rn),Ht.push(gi);var oi={name:gi,type:jo.read_shift(1),color:jo.read_shift(1),L:jo.read_shift(4,"i"),R:jo.read_shift(4,"i"),C:jo.read_shift(4,"i"),clsid:jo.read_shift(16),state:jo.read_shift(4,"i"),start:0,size:0},Ji=jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2);Ji!==0&&(oi.ct=we(jo,jo.l-8));var wi=jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2)+jo.read_shift(2);wi!==0&&(oi.mt=we(jo,jo.l-8)),oi.start=jo.read_shift(4,"i"),oi.size=jo.read_shift(4,"i"),oi.size<0&&oi.start<0&&(oi.size=oi.type=0,oi.start=At,oi.name=""),oi.type===5?(En=oi.start,Qt>0&&En!==At&&(Gt[En].name="!StreamData")):oi.size>=4096?(oi.storage="fat",Gt[oi.start]===void 0&&(Gt[oi.start]=he(Rt,oi.start,Gt.fat_addrs,Gt.ssz)),Gt[oi.start].name=oi.name,oi.content=Gt[oi.start].data.slice(0,oi.size)):(oi.storage="minifat",oi.size<0?oi.size=0:En!==At&&oi.start!==At&&Gt[En]&&(oi.content=Me(oi,Gt[En].data,(Gt[qn]||{}).data))),oi.content&&R(oi.content,0),Nt[gi]=oi,_n.push(oi)}}function we(Et,Gt){return new Date((E(Et,Gt+4)/1e7*Math.pow(2,32)+E(Et,Gt)/1e7-11644473600)*1e3)}function Te(Et,Gt){return ge(),_e(le.readFileSync(Et),Gt)}function Re(Et,Gt){var Rt=Gt&&Gt.type;switch(Rt||r&&Buffer.isBuffer(Et)&&(Rt="buffer"),Rt||"base64"){case"file":return Te(Et,Gt);case"base64":return _e(c(i(Et)),Gt);case"binary":return _e(c(Et),Gt)}return _e(Et,Gt)}function Ee(Et,Gt){var Rt=Gt||{},Ht=Rt.root||"Root Entry";if(Et.FullPaths||(Et.FullPaths=[]),Et.FileIndex||(Et.FileIndex=[]),Et.FullPaths.length!==Et.FileIndex.length)throw new Error("inconsistent CFB structure");Et.FullPaths.length===0&&(Et.FullPaths[0]=Ht+"/",Et.FileIndex[0]={name:Ht,type:5}),Rt.CLSID&&(Et.FileIndex[0].clsid=Rt.CLSID),ke(Et)}function ke(Et){var Gt="Sh33tJ5";if(!U.find(Et,"/"+Gt)){var Rt=F(4);Rt[0]=55,Rt[1]=Rt[3]=50,Rt[2]=54,Et.FileIndex.push({name:Gt,type:2,content:Rt,size:4,L:69,R:69,C:69}),Et.FullPaths.push(Et.FullPaths[0]+Gt),Ce(Et)}}function Ce(Et,Gt){Ee(Et);for(var Rt=!1,Ht=!1,Qt=Et.FullPaths.length-1;Qt>=0;--Qt){var Nt=Et.FileIndex[Qt];switch(Nt.type){case 0:Ht?Rt=!0:(Et.FileIndex.pop(),Et.FullPaths.pop());break;case 1:case 2:case 5:Ht=!0,isNaN(Nt.R*Nt.L*Nt.C)&&(Rt=!0),Nt.R>-1&&Nt.L>-1&&Nt.R==Nt.L&&(Rt=!0);break;default:Rt=!0;break}}if(!(!Rt&&!Gt)){var _n=new Date(1987,1,19),qn=0,En=Object.create?Object.create(null):{},Rn=[];for(Qt=0;Qt<Et.FullPaths.length;++Qt)En[Et.FullPaths[Qt]]=!0,Et.FileIndex[Qt].type!==0&&Rn.push([Et.FullPaths[Qt],Et.FileIndex[Qt]]);for(Qt=0;Qt<Rn.length;++Qt){var Hn=j(Rn[Qt][0]);for(Ht=En[Hn];!Ht;){for(;j(Hn)&&!En[j(Hn)];)Hn=j(Hn);Rn.push([Hn,{name:J(Hn).replace("/",""),type:1,clsid:gt,ct:_n,mt:_n,content:null}]),En[Hn]=!0,Hn=j(Rn[Qt][0]),Ht=En[Hn]}}for(Rn.sort(function(gi,jo){return te(gi[0],jo[0])}),Et.FullPaths=[],Et.FileIndex=[],Qt=0;Qt<Rn.length;++Qt)Et.FullPaths[Qt]=Rn[Qt][0],Et.FileIndex[Qt]=Rn[Qt][1];for(Qt=0;Qt<Rn.length;++Qt){var Lo=Et.FileIndex[Qt],Io=Et.FullPaths[Qt];if(Lo.name=J(Io).replace("/",""),Lo.L=Lo.R=Lo.C=-(Lo.color=1),Lo.size=Lo.content?Lo.content.length:0,Lo.start=0,Lo.clsid=Lo.clsid||gt,Qt===0)Lo.C=Rn.length>1?1:-1,Lo.size=0,Lo.type=5;else if(Io.slice(-1)=="/"){for(qn=Qt+1;qn<Rn.length&&j(Et.FullPaths[qn])!=Io;++qn);for(Lo.C=qn>=Rn.length?-1:qn,qn=Qt+1;qn<Rn.length&&j(Et.FullPaths[qn])!=j(Io);++qn);Lo.R=qn>=Rn.length?-1:qn,Lo.type=1}else j(Et.FullPaths[Qt+1]||"")==j(Io)&&(Lo.R=Qt+1),Lo.type=2}}}function Le(Et,Gt){var Rt=Gt||{};if(Rt.fileType=="mad")return ur(Et,Rt);if(Ce(Et),Rt.fileType==="zip")return uo(Et,Rt);var Ht=(function(gi){for(var jo=0,oi=0,Ji=0;Ji<gi.FileIndex.length;++Ji){var wi=gi.FileIndex[Ji];if(wi.content){var Br=wi.content.length;Br>0&&(Br<4096?jo+=Br+63>>6:oi+=Br+511>>9)}}for(var gr=gi.FullPaths.length+3>>2,oa=jo+7>>3,hs=jo+127>>7,Li=oa+oi+gr+hs,ys=Li+127>>7,dr=ys<=109?0:Math.ceil((ys-109)/127);Li+ys+dr+127>>7>ys;)dr=++ys<=109?0:Math.ceil((ys-109)/127);var cA=[1,dr,ys,hs,gr,oi,jo,0];return gi.FileIndex[0].size=jo<<6,cA[7]=(gi.FileIndex[0].start=cA[0]+cA[1]+cA[2]+cA[3]+cA[4]+cA[5])+(cA[6]+7>>3),cA})(Et),Qt=F(Ht[7]<<9),Nt=0,_n=0;{for(Nt=0;Nt<8;++Nt)Qt.write_shift(1,nt[Nt]);for(Nt=0;Nt<8;++Nt)Qt.write_shift(2,0);for(Qt.write_shift(2,62),Qt.write_shift(2,3),Qt.write_shift(2,65534),Qt.write_shift(2,9),Qt.write_shift(2,6),Nt=0;Nt<3;++Nt)Qt.write_shift(2,0);for(Qt.write_shift(4,0),Qt.write_shift(4,Ht[2]),Qt.write_shift(4,Ht[0]+Ht[1]+Ht[2]+Ht[3]-1),Qt.write_shift(4,0),Qt.write_shift(4,4096),Qt.write_shift(4,Ht[3]?Ht[0]+Ht[1]+Ht[2]-1:At),Qt.write_shift(4,Ht[3]),Qt.write_shift(-4,Ht[1]?Ht[0]-1:At),Qt.write_shift(4,Ht[1]),Nt=0;Nt<109;++Nt)Qt.write_shift(-4,Nt<Ht[2]?Ht[1]+Nt:-1)}if(Ht[1])for(_n=0;_n<Ht[1];++_n){for(;Nt<236+_n*127;++Nt)Qt.write_shift(-4,Nt<Ht[2]?Ht[1]+Nt:-1);Qt.write_shift(-4,_n===Ht[1]-1?At:_n+1)}var qn=function(gi){for(_n+=gi;Nt<_n-1;++Nt)Qt.write_shift(-4,Nt+1);gi&&(++Nt,Qt.write_shift(-4,At))};for(_n=Nt=0,_n+=Ht[1];Nt<_n;++Nt)Qt.write_shift(-4,bt.DIFSECT);for(_n+=Ht[2];Nt<_n;++Nt)Qt.write_shift(-4,bt.FATSECT);qn(Ht[3]),qn(Ht[4]);for(var En=0,Rn=0,Hn=Et.FileIndex[0];En<Et.FileIndex.length;++En)Hn=Et.FileIndex[En],Hn.content&&(Rn=Hn.content.length,!(Rn<4096)&&(Hn.start=_n,qn(Rn+511>>9)));for(qn(Ht[6]+7>>3);Qt.l&511;)Qt.write_shift(-4,bt.ENDOFCHAIN);for(_n=Nt=0,En=0;En<Et.FileIndex.length;++En)Hn=Et.FileIndex[En],Hn.content&&(Rn=Hn.content.length,!(!Rn||Rn>=4096)&&(Hn.start=_n,qn(Rn+63>>6)));for(;Qt.l&511;)Qt.write_shift(-4,bt.ENDOFCHAIN);for(Nt=0;Nt<Ht[4]<<2;++Nt){var Lo=Et.FullPaths[Nt];if(!Lo||Lo.length===0){for(En=0;En<17;++En)Qt.write_shift(4,0);for(En=0;En<3;++En)Qt.write_shift(4,-1);for(En=0;En<12;++En)Qt.write_shift(4,0);continue}Hn=Et.FileIndex[Nt],Nt===0&&(Hn.start=Hn.size?Hn.start-1:At);var Io=Nt===0&&Rt.root||Hn.name;if(Io.length>32&&(console.error("Name "+Io+" will be truncated to "+Io.slice(0,32)),Io=Io.slice(0,32)),Rn=2*(Io.length+1),Qt.write_shift(64,Io,"utf16le"),Qt.write_shift(2,Rn),Qt.write_shift(1,Hn.type),Qt.write_shift(1,Hn.color),Qt.write_shift(-4,Hn.L),Qt.write_shift(-4,Hn.R),Qt.write_shift(-4,Hn.C),Hn.clsid)Qt.write_shift(16,Hn.clsid,"hex");else for(En=0;En<4;++En)Qt.write_shift(4,0);Qt.write_shift(4,Hn.state||0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,0),Qt.write_shift(4,Hn.start),Qt.write_shift(4,Hn.size),Qt.write_shift(4,0)}for(Nt=1;Nt<Et.FileIndex.length;++Nt)if(Hn=Et.FileIndex[Nt],Hn.size>=4096)if(Qt.l=Hn.start+1<<9,r&&Buffer.isBuffer(Hn.content))Hn.content.copy(Qt,Qt.l,0,Hn.size),Qt.l+=Hn.size+511&-512;else{for(En=0;En<Hn.size;++En)Qt.write_shift(1,Hn.content[En]);for(;En&511;++En)Qt.write_shift(1,0)}for(Nt=1;Nt<Et.FileIndex.length;++Nt)if(Hn=Et.FileIndex[Nt],Hn.size>0&&Hn.size<4096)if(r&&Buffer.isBuffer(Hn.content))Hn.content.copy(Qt,Qt.l,0,Hn.size),Qt.l+=Hn.size+63&-64;else{for(En=0;En<Hn.size;++En)Qt.write_shift(1,Hn.content[En]);for(;En&63;++En)Qt.write_shift(1,0)}if(r)Qt.l=Qt.length;else for(;Qt.l<Qt.length;)Qt.write_shift(1,0);return Qt}function Ye(Et,Gt){var Rt=Et.FullPaths.map(function(En){return En.toUpperCase()}),Ht=Rt.map(function(En){var Rn=En.split("/");return Rn[Rn.length-(En.slice(-1)=="/"?2:1)]}),Qt=!1;Gt.charCodeAt(0)===47?(Qt=!0,Gt=Rt[0].slice(0,-1)+Gt):Qt=Gt.indexOf("/")!==-1;var Nt=Gt.toUpperCase(),_n=Qt===!0?Rt.indexOf(Nt):Ht.indexOf(Nt);if(_n!==-1)return Et.FileIndex[_n];var qn=!Nt.match(u);for(Nt=Nt.replace(l,""),qn&&(Nt=Nt.replace(u,"!")),_n=0;_n<Rt.length;++_n)if((qn?Rt[_n].replace(u,"!"):Rt[_n]).replace(l,"")==Nt||(qn?Ht[_n].replace(u,"!"):Ht[_n]).replace(l,"")==Nt)return Et.FileIndex[_n];return null}var tt=64,At=-2,at="d0cf11e0a1b11ae1",nt=[208,207,17,224,161,177,26,225],gt="00000000000000000000000000000000",bt={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:At,FREESECT:-1,HEADER_SIGNATURE:at,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:gt,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function Ct(Et,Gt,Rt){ge();var Ht=Le(Et,Rt);le.writeFileSync(Gt,Ht)}function Dt(Et){for(var Gt=new Array(Et.length),Rt=0;Rt<Et.length;++Rt)Gt[Rt]=String.fromCharCode(Et[Rt]);return Gt.join("")}function kt(Et,Gt){var Rt=Le(Et,Gt);switch(Gt&&Gt.type||"buffer"){case"file":return ge(),le.writeFileSync(Gt.filename,Rt),Rt;case"binary":return typeof Rt=="string"?Rt:Dt(Rt);case"base64":return o(typeof Rt=="string"?Rt:Dt(Rt));case"buffer":if(r)return Buffer.isBuffer(Rt)?Rt:s(Rt);case"array":return typeof Rt=="string"?c(Rt):Rt}return Rt}var it;function Yt(Et){try{var Gt=Et.InflateRaw,Rt=new Gt;if(Rt._processChunk(new Uint8Array([3,0]),Rt._finishFlushFlag),Rt.bytesRead)it=Et;else throw new Error("zlib does not expose bytesRead")}catch(Ht){console.error("cannot use native zlib: "+(Ht.message||Ht))}}function pn(Et,Gt){if(!it)return To(Et,Gt);var Rt=it.InflateRaw,Ht=new Rt,Qt=Ht._processChunk(Et.slice(Et.l),Ht._finishFlushFlag);return Et.l+=Ht.bytesRead,Qt}function be(Et){return it?it.deflateRawSync(Et):qt(Et)}var et=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],It=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Bt=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];function mt(Et){var Gt=(Et<<1|Et<<11)&139536|(Et<<5|Et<<15)&558144;return(Gt>>16|Gt>>8|Gt)&255}for(var st=typeof Uint8Array<"u",xt=st?new Uint8Array(256):[],Xe=0;Xe<256;++Xe)xt[Xe]=mt(Xe);function Ze(Et,Gt){var Rt=xt[Et&255];return Gt<=8?Rt>>>8-Gt:(Rt=Rt<<8|xt[Et>>8&255],Gt<=16?Rt>>>16-Gt:(Rt=Rt<<8|xt[Et>>16&255],Rt>>>24-Gt))}function dt(Et,Gt){var Rt=Gt&7,Ht=Gt>>>3;return(Et[Ht]|(Rt<=6?0:Et[Ht+1]<<8))>>>Rt&3}function Ut(Et,Gt){var Rt=Gt&7,Ht=Gt>>>3;return(Et[Ht]|(Rt<=5?0:Et[Ht+1]<<8))>>>Rt&7}function Wt(Et,Gt){var Rt=Gt&7,Ht=Gt>>>3;return(Et[Ht]|(Rt<=4?0:Et[Ht+1]<<8))>>>Rt&15}function Xt(Et,Gt){var Rt=Gt&7,Ht=Gt>>>3;return(Et[Ht]|(Rt<=3?0:Et[Ht+1]<<8))>>>Rt&31}function Jt(Et,Gt){var Rt=Gt&7,Ht=Gt>>>3;return(Et[Ht]|(Rt<=1?0:Et[Ht+1]<<8))>>>Rt&127}function yn(Et,Gt,Rt){var Ht=Gt&7,Qt=Gt>>>3,Nt=(1<<Rt)-1,_n=Et[Qt]>>>Ht;return Rt<8-Ht||(_n|=Et[Qt+1]<<8-Ht,Rt<16-Ht)||(_n|=Et[Qt+2]<<16-Ht,Rt<24-Ht)||(_n|=Et[Qt+3]<<24-Ht),_n&Nt}function An(Et,Gt,Rt){var Ht=Gt&7,Qt=Gt>>>3;return Ht<=5?Et[Qt]|=(Rt&7)<<Ht:(Et[Qt]|=Rt<<Ht&255,Et[Qt+1]=(Rt&7)>>8-Ht),Gt+3}function kn(Et,Gt,Rt){var Ht=Gt&7,Qt=Gt>>>3;return Rt=(Rt&1)<<Ht,Et[Qt]|=Rt,Gt+1}function $n(Et,Gt,Rt){var Ht=Gt&7,Qt=Gt>>>3;return Rt<<=Ht,Et[Qt]|=Rt&255,Rt>>>=8,Et[Qt+1]=Rt,Gt+8}function ht(Et,Gt,Rt){var Ht=Gt&7,Qt=Gt>>>3;return Rt<<=Ht,Et[Qt]|=Rt&255,Rt>>>=8,Et[Qt+1]=Rt&255,Et[Qt+2]=Rt>>>8,Gt+16}function Kt(Et,Gt){var Rt=Et.length,Ht=2*Rt>Gt?2*Rt:Gt+5,Qt=0;if(Rt>=Gt)return Et;if(r){var Nt=A(Ht);if(Et.copy)Et.copy(Nt);else for(;Qt<Et.length;++Qt)Nt[Qt]=Et[Qt];return Nt}else if(st){var _n=new Uint8Array(Ht);if(_n.set)_n.set(Et);else for(;Qt<Rt;++Qt)_n[Qt]=Et[Qt];return _n}return Et.length=Ht,Et}function rn(Et){for(var Gt=new Array(Et),Rt=0;Rt<Et;++Rt)Gt[Rt]=0;return Gt}function Lt(Et,Gt,Rt){var Ht=1,Qt=0,Nt=0,_n=0,qn=0,En=Et.length,Rn=st?new Uint16Array(32):rn(32);for(Nt=0;Nt<32;++Nt)Rn[Nt]=0;for(Nt=En;Nt<Rt;++Nt)Et[Nt]=0;En=Et.length;var Hn=st?new Uint16Array(En):rn(En);for(Nt=0;Nt<En;++Nt)Rn[Qt=Et[Nt]]++,Ht<Qt&&(Ht=Qt),Hn[Nt]=0;for(Rn[0]=0,Nt=1;Nt<=Ht;++Nt)Rn[Nt+16]=qn=qn+Rn[Nt-1]<<1;for(Nt=0;Nt<En;++Nt)qn=Et[Nt],qn!=0&&(Hn[Nt]=Rn[qn+16]++);var Lo=0;for(Nt=0;Nt<En;++Nt)if(Lo=Et[Nt],Lo!=0)for(qn=Ze(Hn[Nt],Ht)>>Ht-Lo,_n=(1<<Ht+4-Lo)-1;_n>=0;--_n)Gt[qn|_n<<Lo]=Lo&15|Nt<<4;return Ht}var Ho=st?new Uint16Array(512):rn(512),Ao=st?new Uint16Array(32):rn(32);if(!st){for(var qe=0;qe<512;++qe)Ho[qe]=0;for(qe=0;qe<32;++qe)Ao[qe]=0}(function(){for(var Et=[],Gt=0;Gt<32;Gt++)Et.push(5);Lt(Et,Ao,32);var Rt=[];for(Gt=0;Gt<=143;Gt++)Rt.push(8);for(;Gt<=255;Gt++)Rt.push(9);for(;Gt<=279;Gt++)Rt.push(7);for(;Gt<=287;Gt++)Rt.push(8);Lt(Rt,Ho,288)})();var vt=(function(){for(var Gt=st?new Uint8Array(32768):[],Rt=0,Ht=0;Rt<Bt.length-1;++Rt)for(;Ht<Bt[Rt+1];++Ht)Gt[Ht]=Rt;for(;Ht<32768;++Ht)Gt[Ht]=29;var Qt=st?new Uint8Array(259):[];for(Rt=0,Ht=0;Rt<It.length-1;++Rt)for(;Ht<It[Rt+1];++Ht)Qt[Ht]=Rt;function Nt(qn,En){for(var Rn=0;Rn<qn.length;){var Hn=Math.min(65535,qn.length-Rn),Lo=Rn+Hn==qn.length;for(En.write_shift(1,+Lo),En.write_shift(2,Hn),En.write_shift(2,~Hn&65535);Hn-- >0;)En[En.l++]=qn[Rn++]}return En.l}function _n(qn,En){for(var Rn=0,Hn=0,Lo=st?new Uint16Array(32768):[];Hn<qn.length;){var Io=Math.min(65535,qn.length-Hn);if(Io<10){for(Rn=An(En,Rn,+(Hn+Io==qn.length)),Rn&7&&(Rn+=8-(Rn&7)),En.l=Rn/8|0,En.write_shift(2,Io),En.write_shift(2,~Io&65535);Io-- >0;)En[En.l++]=qn[Hn++];Rn=En.l*8;continue}Rn=An(En,Rn,+(Hn+Io==qn.length)+2);for(var gi=0;Io-- >0;){var jo=qn[Hn];gi=(gi<<5^jo)&32767;var oi=-1,Ji=0;if((oi=Lo[gi])&&(oi|=Hn&-32768,oi>Hn&&(oi-=32768),oi<Hn))for(;qn[oi+Ji]==qn[Hn+Ji]&&Ji<250;)++Ji;if(Ji>2){jo=Qt[Ji],jo<=22?Rn=$n(En,Rn,xt[jo+1]>>1)-1:($n(En,Rn,3),Rn+=5,$n(En,Rn,xt[jo-23]>>5),Rn+=3);var wi=jo<8?0:jo-4>>2;wi>0&&(ht(En,Rn,Ji-It[jo]),Rn+=wi),jo=Gt[Hn-oi],Rn=$n(En,Rn,xt[jo]>>3),Rn-=3;var Br=jo<4?0:jo-2>>1;Br>0&&(ht(En,Rn,Hn-oi-Bt[jo]),Rn+=Br);for(var gr=0;gr<Ji;++gr)Lo[gi]=Hn&32767,gi=(gi<<5^qn[Hn])&32767,++Hn;Io-=Ji-1}else jo<=143?jo=jo+48:Rn=kn(En,Rn,1),Rn=$n(En,Rn,xt[jo]),Lo[gi]=Hn&32767,++Hn}Rn=$n(En,Rn,0)-1}return En.l=(Rn+7)/8|0,En.l}return function(En,Rn){return En.length<8?Nt(En,Rn):_n(En,Rn)}})();function qt(Et){var Gt=F(50+Math.floor(Et.length*1.1)),Rt=vt(Et,Gt);return Gt.slice(0,Rt)}var Zt=st?new Uint16Array(32768):rn(32768),nn=st?new Uint16Array(32768):rn(32768),zn=st?new Uint16Array(128):rn(128),Nn=1,Co=1;function ei(Et,Gt){var Rt=Xt(Et,Gt)+257;Gt+=5;var Ht=Xt(Et,Gt)+1;Gt+=5;var Qt=Wt(Et,Gt)+4;Gt+=4;for(var Nt=0,_n=st?new Uint8Array(19):rn(19),qn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],En=1,Rn=st?new Uint8Array(8):rn(8),Hn=st?new Uint8Array(8):rn(8),Lo=_n.length,Io=0;Io<Qt;++Io)_n[et[Io]]=Nt=Ut(Et,Gt),En<Nt&&(En=Nt),Rn[Nt]++,Gt+=3;var gi=0;for(Rn[0]=0,Io=1;Io<=En;++Io)Hn[Io]=gi=gi+Rn[Io-1]<<1;for(Io=0;Io<Lo;++Io)(gi=_n[Io])!=0&&(qn[Io]=Hn[gi]++);var jo=0;for(Io=0;Io<Lo;++Io)if(jo=_n[Io],jo!=0){gi=xt[qn[Io]]>>8-jo;for(var oi=(1<<7-jo)-1;oi>=0;--oi)zn[gi|oi<<jo]=jo&7|Io<<3}var Ji=[];for(En=1;Ji.length<Rt+Ht;)switch(gi=zn[Jt(Et,Gt)],Gt+=gi&7,gi>>>=3){case 16:for(Nt=3+dt(Et,Gt),Gt+=2,gi=Ji[Ji.length-1];Nt-- >0;)Ji.push(gi);break;case 17:for(Nt=3+Ut(Et,Gt),Gt+=3;Nt-- >0;)Ji.push(0);break;case 18:for(Nt=11+Jt(Et,Gt),Gt+=7;Nt-- >0;)Ji.push(0);break;default:Ji.push(gi),En<gi&&(En=gi);break}var wi=Ji.slice(0,Rt),Br=Ji.slice(Rt);for(Io=Rt;Io<286;++Io)wi[Io]=0;for(Io=Ht;Io<30;++Io)Br[Io]=0;return Nn=Lt(wi,Zt,286),Co=Lt(Br,nn,30),Gt}function ro(Et,Gt){if(Et[0]==3&&!(Et[1]&3))return[a(Gt),2];for(var Rt=0,Ht=0,Qt=A(Gt||1<<18),Nt=0,_n=Qt.length>>>0,qn=0,En=0;(Ht&1)==0;){if(Ht=Ut(Et,Rt),Rt+=3,Ht>>>1)Ht>>1==1?(qn=9,En=5):(Rt=ei(Et,Rt),qn=Nn,En=Co);else{Rt&7&&(Rt+=8-(Rt&7));var Rn=Et[Rt>>>3]|Et[(Rt>>>3)+1]<<8;if(Rt+=32,Rn>0)for(!Gt&&_n<Nt+Rn&&(Qt=Kt(Qt,Nt+Rn),_n=Qt.length);Rn-- >0;)Qt[Nt++]=Et[Rt>>>3],Rt+=8;continue}for(;;){!Gt&&_n<Nt+32767&&(Qt=Kt(Qt,Nt+32767),_n=Qt.length);var Hn=yn(Et,Rt,qn),Lo=Ht>>>1==1?Ho[Hn]:Zt[Hn];if(Rt+=Lo&15,Lo>>>=4,(Lo>>>8&255)===0)Qt[Nt++]=Lo;else{if(Lo==256)break;Lo-=257;var Io=Lo<8?0:Lo-4>>2;Io>5&&(Io=0);var gi=Nt+It[Lo];Io>0&&(gi+=yn(Et,Rt,Io),Rt+=Io),Hn=yn(Et,Rt,En),Lo=Ht>>>1==1?Ao[Hn]:nn[Hn],Rt+=Lo&15,Lo>>>=4;var jo=Lo<4?0:Lo-2>>1,oi=Bt[Lo];for(jo>0&&(oi+=yn(Et,Rt,jo),Rt+=jo),!Gt&&_n<gi&&(Qt=Kt(Qt,gi+100),_n=Qt.length);Nt<gi;)Qt[Nt]=Qt[Nt-oi],++Nt}}}return Gt?[Qt,Rt+7>>>3]:[Qt.slice(0,Nt),Rt+7>>>3]}function To(Et,Gt){var Rt=Et.slice(Et.l||0),Ht=ro(Rt,Gt);return Et.l+=Ht[1],Ht[0]}function yo(Et,Gt){if(Et)typeof console<"u"&&console.error(Gt);else throw new Error(Gt)}function Ro(Et,Gt){var Rt=Et;R(Rt,0);var Ht=[],Qt=[],Nt={FileIndex:Ht,FullPaths:Qt};Ee(Nt,{root:Gt.root});for(var _n=Rt.length-4;(Rt[_n]!=80||Rt[_n+1]!=75||Rt[_n+2]!=5||Rt[_n+3]!=6)&&_n>=0;)--_n;Rt.l=_n+4,Rt.l+=4;var qn=Rt.read_shift(2);Rt.l+=6;var En=Rt.read_shift(4);for(Rt.l=En,_n=0;_n<qn;++_n){Rt.l+=20;var Rn=Rt.read_shift(4),Hn=Rt.read_shift(4),Lo=Rt.read_shift(2),Io=Rt.read_shift(2),gi=Rt.read_shift(2);Rt.l+=8;var jo=Rt.read_shift(4),oi=ne(Rt.slice(Rt.l+Lo,Rt.l+Lo+Io));Rt.l+=Lo+Io+gi;var Ji=Rt.l;Rt.l=jo+4,On(Rt,Rn,Hn,Nt,oi),Rt.l=Ji}return Nt}function On(Et,Gt,Rt,Ht,Qt){Et.l+=2;var Nt=Et.read_shift(2),_n=Et.read_shift(2),qn=ie(Et);if(Nt&8257)throw new Error("Unsupported ZIP encryption");for(var En=Et.read_shift(4),Rn=Et.read_shift(4),Hn=Et.read_shift(4),Lo=Et.read_shift(2),Io=Et.read_shift(2),gi="",jo=0;jo<Lo;++jo)gi+=String.fromCharCode(Et[Et.l++]);if(Io){var oi=ne(Et.slice(Et.l,Et.l+Io));(oi[21589]||{}).mt&&(qn=oi[21589].mt),((Qt||{})[21589]||{}).mt&&(qn=Qt[21589].mt)}Et.l+=Io;var Ji=Et.slice(Et.l,Et.l+Rn);switch(_n){case 8:Ji=pn(Et,Hn);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+_n)}var wi=!1;Nt&8&&(En=Et.read_shift(4),En==134695760&&(En=Et.read_shift(4),wi=!0),Rn=Et.read_shift(4),Hn=Et.read_shift(4)),Rn!=Gt&&yo(wi,"Bad compressed size: "+Gt+" != "+Rn),Hn!=Rt&&yo(wi,"Bad uncompressed size: "+Rt+" != "+Hn);var Br=O.buf(Ji,0);En>>0!=Br>>0&&yo(wi,"Bad CRC32 checksum: "+En+" != "+Br),bi(Ht,gi,Ji,{unsafe:!0,mt:qn})}function uo(Et,Gt){var Rt=Gt||{},Ht=[],Qt=[],Nt=F(1),_n=Rt.compression?8:0,qn=0,En=0,Rn=0,Hn=0,Lo=0,Io=Et.FullPaths[0],gi=Io,jo=Et.FileIndex[0],oi=[],Ji=0;for(En=1;En<Et.FullPaths.length;++En)if(gi=Et.FullPaths[En].slice(Io.length),jo=Et.FileIndex[En],!(!jo.size||!jo.content||gi=="Sh33tJ5")){var wi=Hn,Br=F(gi.length);for(Rn=0;Rn<gi.length;++Rn)Br.write_shift(1,gi.charCodeAt(Rn)&127);Br=Br.slice(0,Br.l),oi[Lo]=O.buf(jo.content,0);var gr=jo.content;_n==8&&(gr=be(gr)),Nt=F(30),Nt.write_shift(4,67324752),Nt.write_shift(2,20),Nt.write_shift(2,qn),Nt.write_shift(2,_n),jo.mt?oe(Nt,jo.mt):Nt.write_shift(4,0),Nt.write_shift(-4,oi[Lo]),Nt.write_shift(4,gr.length),Nt.write_shift(4,jo.content.length),Nt.write_shift(2,Br.length),Nt.write_shift(2,0),Hn+=Nt.length,Ht.push(Nt),Hn+=Br.length,Ht.push(Br),Hn+=gr.length,Ht.push(gr),Nt=F(46),Nt.write_shift(4,33639248),Nt.write_shift(2,0),Nt.write_shift(2,20),Nt.write_shift(2,qn),Nt.write_shift(2,_n),Nt.write_shift(4,0),Nt.write_shift(-4,oi[Lo]),Nt.write_shift(4,gr.length),Nt.write_shift(4,jo.content.length),Nt.write_shift(2,Br.length),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(4,0),Nt.write_shift(4,wi),Ji+=Nt.l,Qt.push(Nt),Ji+=Br.length,Qt.push(Br),++Lo}return Nt=F(22),Nt.write_shift(4,101010256),Nt.write_shift(2,0),Nt.write_shift(2,0),Nt.write_shift(2,Lo),Nt.write_shift(2,Lo),Nt.write_shift(4,Ji),Nt.write_shift(4,Hn),Nt.write_shift(2,0),I([I(Ht),I(Qt),Nt])}var Oo={htm:"text/html",xml:"text/xml",gif:"image/gif",jpg:"image/jpeg",png:"image/png",mso:"application/x-mso",thmx:"application/vnd.ms-officetheme",sh33tj5:"application/octet-stream"};function ko(Et,Gt){if(Et.ctype)return Et.ctype;var Rt=Et.name||"",Ht=Rt.match(/\.([^\.]+)$/);return Ht&&Oo[Ht[1]]||Gt&&(Ht=(Rt=Gt).match(/[\.\\]([^\.\\])+$/),Ht&&Oo[Ht[1]])?Oo[Ht[1]]:"application/octet-stream"}function Ko(Et){for(var Gt=o(Et),Rt=[],Ht=0;Ht<Gt.length;Ht+=76)Rt.push(Gt.slice(Ht,Ht+76));return Rt.join(`\r
`)+`\r
`}function mi(Et){var Gt=Et.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(Rn){var Hn=Rn.charCodeAt(0).toString(16).toUpperCase();return"="+(Hn.length==1?"0"+Hn:Hn)});Gt=Gt.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),Gt.charAt(0)==`
`&&(Gt="=0D"+Gt.slice(1)),Gt=Gt.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var Rt=[],Ht=Gt.split(`\r
`),Qt=0;Qt<Ht.length;++Qt){var Nt=Ht[Qt];if(Nt.length==0){Rt.push("");continue}for(var _n=0;_n<Nt.length;){var qn=76,En=Nt.slice(_n,_n+qn);En.charAt(qn-1)=="="?qn--:En.charAt(qn-2)=="="?qn-=2:En.charAt(qn-3)=="="&&(qn-=3),En=Nt.slice(_n,_n+qn),_n+=qn,_n<Nt.length&&(En+="="),Rt.push(En)}}return Rt.join(`\r
`)}function Fo(Et){for(var Gt=[],Rt=0;Rt<Et.length;++Rt){for(var Ht=Et[Rt];Rt<=Et.length&&Ht.charAt(Ht.length-1)=="=";)Ht=Ht.slice(0,Ht.length-1)+Et[++Rt];Gt.push(Ht)}for(var Qt=0;Qt<Gt.length;++Qt)Gt[Qt]=Gt[Qt].replace(/[=][0-9A-Fa-f]{2}/g,function(Nt){return String.fromCharCode(parseInt(Nt.slice(1),16))});return c(Gt.join(`\r
`))}function Nr(Et,Gt,Rt){for(var Ht="",Qt="",Nt="",_n,qn=0;qn<10;++qn){var En=Gt[qn];if(!En||En.match(/^\s*$/))break;var Rn=En.match(/^(.*?):\s*([^\s].*)$/);if(Rn)switch(Rn[1].toLowerCase()){case"content-location":Ht=Rn[2].trim();break;case"content-type":Nt=Rn[2].trim();break;case"content-transfer-encoding":Qt=Rn[2].trim();break}}switch(++qn,Qt.toLowerCase()){case"base64":_n=c(i(Gt.slice(qn).join("")));break;case"quoted-printable":_n=Fo(Gt.slice(qn));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+Qt)}var Hn=bi(Et,Ht.slice(Rt.length),_n,{unsafe:!0});Nt&&(Hn.ctype=Nt)}function Rs(Et,Gt){if(Dt(Et.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var Rt=Gt&&Gt.root||"",Ht=(r&&Buffer.isBuffer(Et)?Et.toString("binary"):Dt(Et)).split(`\r
`),Qt=0,Nt="";for(Qt=0;Qt<Ht.length;++Qt)if(Nt=Ht[Qt],!!/^Content-Location:/i.test(Nt)&&(Nt=Nt.slice(Nt.indexOf("file")),Rt||(Rt=Nt.slice(0,Nt.lastIndexOf("/")+1)),Nt.slice(0,Rt.length)!=Rt))for(;Rt.length>0&&(Rt=Rt.slice(0,Rt.length-1),Rt=Rt.slice(0,Rt.lastIndexOf("/")+1),Nt.slice(0,Rt.length)!=Rt););var _n=(Ht[1]||"").match(/boundary="(.*?)"/);if(!_n)throw new Error("MAD cannot find boundary");var qn="--"+(_n[1]||""),En=[],Rn=[],Hn={FileIndex:En,FullPaths:Rn};Ee(Hn);var Lo,Io=0;for(Qt=0;Qt<Ht.length;++Qt){var gi=Ht[Qt];gi!==qn&&gi!==qn+"--"||(Io++&&Nr(Hn,Ht.slice(Lo,Qt),Rt),Lo=Qt)}return Hn}function ur(Et,Gt){var Rt=Gt||{},Ht=Rt.boundary||"SheetJS";Ht="------="+Ht;for(var Qt=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+Ht.slice(2)+'"',"","",""],Nt=Et.FullPaths[0],_n=Nt,qn=Et.FileIndex[0],En=1;En<Et.FullPaths.length;++En)if(_n=Et.FullPaths[En].slice(Nt.length),qn=Et.FileIndex[En],!(!qn.size||!qn.content||_n=="Sh33tJ5")){_n=_n.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(Ji){return"_x"+Ji.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(Ji){return"_u"+Ji.charCodeAt(0).toString(16)+"_"});for(var Rn=qn.content,Hn=r&&Buffer.isBuffer(Rn)?Rn.toString("binary"):Dt(Rn),Lo=0,Io=Math.min(1024,Hn.length),gi=0,jo=0;jo<=Io;++jo)(gi=Hn.charCodeAt(jo))>=32&&gi<128&&++Lo;var oi=Lo>=Io*4/5;Qt.push(Ht),Qt.push("Content-Location: "+(Rt.root||"file:///C:/SheetJS/")+_n),Qt.push("Content-Transfer-Encoding: "+(oi?"quoted-printable":"base64")),Qt.push("Content-Type: "+ko(qn,_n)),Qt.push(""),Qt.push(oi?mi(Hn):Ko(Hn))}return Qt.push(Ht+`--\r
`),Qt.join(`\r
`)}function zi(Et){var Gt={};return Ee(Gt,Et),Gt}function bi(Et,Gt,Rt,Ht){var Qt=Ht&&Ht.unsafe;Qt||Ee(Et);var Nt=!Qt&&U.find(Et,Gt);if(!Nt){var _n=Et.FullPaths[0];Gt.slice(0,_n.length)==_n?_n=Gt:(_n.slice(-1)!="/"&&(_n+="/"),_n=(_n+Gt).replace("//","/")),Nt={name:J(Gt),type:2},Et.FileIndex.push(Nt),Et.FullPaths.push(_n),Qt||U.utils.cfb_gc(Et)}return Nt.content=Rt,Nt.size=Rt?Rt.length:0,Ht&&(Ht.CLSID&&(Nt.clsid=Ht.CLSID),Ht.mt&&(Nt.mt=Ht.mt),Ht.ct&&(Nt.ct=Ht.ct)),Nt}function Ar(Et,Gt){Ee(Et);var Rt=U.find(Et,Gt);if(Rt){for(var Ht=0;Ht<Et.FileIndex.length;++Ht)if(Et.FileIndex[Ht]==Rt)return Et.FileIndex.splice(Ht,1),Et.FullPaths.splice(Ht,1),!0}return!1}function ws(Et,Gt,Rt){Ee(Et);var Ht=U.find(Et,Gt);if(Ht){for(var Qt=0;Qt<Et.FileIndex.length;++Qt)if(Et.FileIndex[Qt]==Ht)return Et.FileIndex[Qt].name=J(Rt),Et.FullPaths[Qt]=Rt,!0}return!1}function ds(Et){Ce(Et,!0)}return W.find=Ye,W.read=Re,W.parse=_e,W.write=kt,W.writeFile=Ct,W.utils={cfb_new:zi,cfb_add:bi,cfb_del:Ar,cfb_mov:ws,cfb_gc:ds,ReadShift:S,CheckField:k,prep_blob:R,bconcat:I,use_zlib:Yt,_deflateRaw:qt,_inflateRaw:To,consts:bt},W})();typeof U8<"u"&&typeof DO_NOT_EXPORT_CFB>"u"&&(t.exports=U)})($Xe)),$Xe.exports}var ZXi=XXi();const A9=_y(ZXi);function j1n(t){return[...t].map(e=>e==="|"||new RegExp("\\p{Cc}","u").test(e)?" ":e).join("")}function $1n(){return A9.utils.cfb_new({root:"Root Entry"})}function rk({compoundFile:t,content:e,path:n}){A9.utils.cfb_add(t,n,e)}function aK(t){const e=new Uint8Array(t.reduce((o,i)=>o+i.byteLength,0));let n=0;for(const o of t)e.set(o,n),n+=o.byteLength;return e}function B1e(t){return new LE(4,4).uint32(t).toUint8Array()}function o3({compoundFile:t,content:e,name:n,recordCount:o}){rk({compoundFile:t,content:B1e(o),path:`/${n}/Header`}),rk({compoundFile:t,content:e,path:`/${n}/Data`})}function q1n(t){const e=A9.write(t,{type:"buffer",fileType:"cfb"});return new Uint8Array(e)}var X1n=65535,eZi=1e4;function Z1n(t){if(typeof t=="string")return t;if("sourceFormat"in t&&t.sourceFormat!=="ascii")throw new Yg("Binary Altium input is already a compound document");return t.getString()}function c9(t){return new Map(qXe(t).map(({fieldName:e,fieldText:n})=>[e,n]))}function tZi(t){return qXe(t).map(({fieldName:e})=>e)}function nZi(t){return c9(t).get("RECORD")??""}function rM(t){const e=[];for(const{fieldName:n,fieldText:o}of qXe(t))/[^\x20-\x7e]/u.test(o)&&e.push(...new TextEncoder().encode(`|%UTF8%${n}=${o}||`)),e.push(...tIn(`|${n}=${o.replace(/[^\x20-\x7e]/gu,"?")}`));return e.push(0),Uint8Array.from(e)}function b1e(t){const e=new LE;for(const n of t)e.uint32LengthPrefixedBytes(rM(n));return e.toUint8Array()}function oZi(t){const e=new LE;for(const n of t){const o=c9(n),i=iZi(o.get("BINARYRECORDTYPE")),r=n.split("|").filter(a=>a&&!/^BINARYRECORDTYPE=/iu.test(a)).map(a=>`|${a}`).join(""),s=rM(r);e.uint16(i).uint32(s.byteLength).writeBytes(s)}return e.toUint8Array()}function _c(t){if(t===void 0)return 0;const e=Gee(t);if(e===void 0||!Number.isFinite(e))throw new Yg(`Invalid Altium measurement: ${JSON.stringify(t)}`);return Math.round(e*eZi)}function S1e(t){if(t===void 0)return X1n;const e=Number(t);if(!Number.isInteger(e)||e<0||e>X1n)throw new Yg(`Invalid Altium record index: ${JSON.stringify(t)}`);return e}function iZi(t){if(t===void 0)return 0;const e=Number(t);if(!Number.isInteger(e)||e<0||e>65535)throw new Yg(`Invalid Altium binary record type: ${JSON.stringify(t)}`);return e}function E4(t){if(t===void 0)return 0;const e=Number(t);if(!Number.isFinite(e))throw new Yg(`Invalid finite Altium number: ${JSON.stringify(t)}`);return e}function i3(t){if(t===void 0||t.toUpperCase()==="FALSE")return!1;if(t.toUpperCase()==="TRUE")return!0;throw new Yg(`Invalid Altium boolean: ${JSON.stringify(t)}`)}function AK(t){const e=tIn(t.slice(0,255));return aK([Uint8Array.of(e.byteLength),e])}function eIn(t,e){const n=new Uint8Array(e??(t.length+1)*2),o=new DataView(n.buffer),i=Math.min(t.length,n.byteLength/2);for(let r=0;r<i;r++)o.setUint16(r*2,t.charCodeAt(r),!0);return n}function rZi(t){return t.replace(/[^\x20-\x7e]/gu,"?")}function qXe(t){return t.split("|").filter(Boolean).map(e=>{const n=e.indexOf("=");if(n<1)throw new Yg(`Invalid Altium record field: ${JSON.stringify(e)}`);return{fieldName:e.slice(0,n).toUpperCase(),fieldText:e.slice(n+1)}})}function tIn(t){return Uint8Array.from(t,e=>e.charCodeAt(0)&127)}var sZi={BACKGROUND:76,BOTTOM:32,BOTTOMOVERLAY:34,BOTTOMPASTE:36,BOTTOMSOLDER:38,CONNECTIONS:75,DRCERROR:77,DRILLDRAWING:73,DRILLGUIDE:55,KEEPOUT:56,MULTILAYER:74,PADHOLES:81,SELECTIONS:78,TOP:1,TOPOVERLAY:33,TOPPASTE:35,TOPSOLDER:37,VIAHOLES:82,VISIBLEGRID1:79,VISIBLEGRID2:80};function B4(t,e=1){if(t===void 0)return e;const n=t.toUpperCase(),o=sZi[n];if(o!==void 0)return o;const i=aZi(n);if(i!==void 0)return i;throw new Yg(`Unsupported Altium PCB layer: ${JSON.stringify(t)}`)}function aZi(t){const e=/^(MID-LAYER|INTERNALPLANE|MECHANICAL)(\d{1,2})$/u.exec(t),n=Number.parseInt(e?.[2]??"",10);if(!(!e||!Number.isInteger(n)||n<1)){if(e[1]==="MID-LAYER"&&n<=30)return n+1;if(e[1]==="INTERNALPLANE"&&n<=16)return n+38;if(e[1]==="MECHANICAL"&&n<=16)return n+56;if(e[1]==="MECHANICAL"&&n<=32)return n+66}}var sk=["COMPONENT","LAYER","LOCKED","NET","POLYGON","RECORD"],AZi={ComponentBody:new Set([...sk,"ARCRESOLUTION","BODYCOLOR3D","BODYOPACITY3D","BODYPROJECTION","CAVITYHEIGHT","HOLECOUNT","IDENTIFIER","ISSHAPEBASED","KEEPOUT","KIND","NAME","OVERALLHEIGHT","STANDOFFHEIGHT","SUBPOLYINDEX","TEARDROP","TEXTURE","TEXTURECENTERX","TEXTURECENTERY","TEXTUREROTATION","TEXTURESIZEX","TEXTURESIZEY","UNIONINDEX","V7_LAYER"]),Fill:new Set([...sk,"KEEPOUT","ROTATION","X1","X2","Y1","Y2"]),Pad:new Set([...sk,"HOLESHAPE","HOLESIZE","HOLEROTATION","HOLEWIDTH","NAME","PLATED","ROTATION","SHAPE","TENTEDBOTTOM","TENTEDTOP","X","XSIZE","Y","YSIZE"]),Region:new Set([...sk,"HOLECOUNT","KEEPOUT","REGIONKIND","TEARDROP"]),Text:new Set([...sk,"BOLD","COMMENT","DESIGNATOR","FONTNAME","HEIGHT","INVERTED","INVERTEDRECT","ITALIC","ISSHAPEBASED","JUSTIFICATION","MARGINBORDERWIDTH","MIRROR","ROTATION","STROKEFONT","TEXT","TEXTBOXHEIGHT","TEXTBOXWIDTH","TEXTOFFSET","USETTFONTS","WIDESTRING","WIDTH","X","Y"]),Track:new Set([...sk,"KEEPOUT","WIDTH","X1","X2","Y1","Y2"]),Via:new Set([...sk,"DIAMETER","ENDLAYER","HOLESIZE","STARTLAYER","STOPLAYER","TENTEDBOTTOM","TENTEDTOP","X","Y"])};function cZi(t,e){const n=tZi(t),o=n.filter((r,s)=>n.indexOf(r)!==s);if(o.length>0)throw new Yg(`${e} binary serialization does not support duplicate fields: ${[...new Set(o)].join(", ")}`);const i=n.filter(r=>!uZi(r,e));if(i.length>0)throw new Yg(`${e} binary serialization does not support fields: ${i.join(", ")}`);lZi(c9(t),e)}function nIn(t){if(t===void 0||t.toUpperCase()==="RECTANGLE")return 2;if(t.toUpperCase()==="ROUND")return 1;throw new Yg(`Unsupported Altium pad shape: ${JSON.stringify(t)}`)}function lZi(t,e){B4(t.get("LAYER"),e==="Via"?74:1);for(const n of["BOLD","COMMENT","DESIGNATOR","INVERTED","INVERTEDRECT","ITALIC","KEEPOUT","LOCKED","MIRROR","PLATED","TENTEDBOTTOM","TENTEDTOP","TEARDROP","USETTFONTS"])t.has(n)&&i3(t.get(n));if(e==="Pad"){nIn(t.get("SHAPE"));const n=t.get("HOLESHAPE")?.toUpperCase();if(n!==void 0&&n!=="ROUND"&&n!=="SLOT"&&n!=="SQUARE")throw new Yg(`Unsupported Altium pad hole shape: ${JSON.stringify(n)}`)}if(e==="Via"){const n=t.get("LAYER")?.toUpperCase();if(n!==void 0&&n!=="MULTILAYER")throw new Yg(`Via binary serialization requires MULTILAYER, got ${JSON.stringify(n)}`);B4(t.get("STARTLAYER"),1),B4(t.get("ENDLAYER")??t.get("STOPLAYER"),32)}if(e==="Region"){const n=t.get("REGIONKIND")?.toUpperCase()??"COPPER";if(n!=="COPPER"&&n!=="POLYGON_CUTOUT")throw new Yg(`Unsupported Altium region kind: ${JSON.stringify(n)}`)}}function uZi(t,e){return AZi[e].has(t)?!0:e!=="Region"&&e!=="ComponentBody"?!1:/^(?:KIND|VX|VY|CX|CY|R|SA|EA)\d+$/u.test(t)||/^HOLE\d+(?:COUNT|V[XY]\d+)$/u.test(t)}var oIn=65535,gZi=4,dZi=8,hZi=32,pZi=64,mZi=512,_Zi=209,ak={componentBody:12,fill:6,pad:2,region:11,text:5,track:4,via:3};function fZi(t){const e=c9(t),n=B4(e.get("LAYER")),o=nIn(e.get("SHAPE")),i=_c(e.get("XSIZE")),r=_c(e.get("YSIZE")),s=new LE;cK({defaultLayerId:n,fields:e,writer:s}),s.int32(_c(e.get("X"))).int32(_c(e.get("Y")));for(let a=0;a<3;a++)s.int32(i).int32(r);return s.int32(_c(e.get("HOLESIZE"))).uint8(o).uint8(o).uint8(o).float64(E4(e.get("ROTATION"))).uint8(i3(e.get("PLATED"))?1:0).uint8(0).uint8(0).int32(0).writeBytes(new Uint8Array(38)).uint8(0).float64(E4(e.get("HOLEROTATION"))),[AK(e.get("NAME")??""),AK(""),AK(""),AK(""),s.toUint8Array(),bZi(e)]}function IZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4(e.get("LAYER")),fields:e,writer:n}),n.int32(_c(e.get("X1"))).int32(_c(e.get("Y1"))).int32(_c(e.get("X2"))).int32(_c(e.get("Y2"))).int32(_c(e.get("WIDTH"))).uint16(0),[n.toUint8Array()]}function CZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4(e.get("LAYER")),fields:e,writer:n}),n.int32(_c(e.get("X1"))).int32(_c(e.get("Y1"))).int32(_c(e.get("X2"))).int32(_c(e.get("Y2"))).float64(E4(e.get("ROTATION"))),[n.toUint8Array()]}function yZi(t){const e=c9(t),n=new LE;return cK({defaultLayerId:B4("MULTILAYER"),fields:e,writer:n}),n.int32(_c(e.get("X"))).int32(_c(e.get("Y"))).int32(_c(e.get("DIAMETER"))).int32(_c(e.get("HOLESIZE"))).uint8(B4(e.get("STARTLAYER"),1)).uint8(B4(e.get("ENDLAYER")??e.get("STOPLAYER"),32)).writeBytes(new Uint8Array(_Zi-n.length)),[n.toUint8Array()]}function xZi(t,e){const n=c9(t),o=iIn(n),i=new LE(137,137);return cK({defaultLayerId:B4(n.get("LAYER")),fields:n,writer:i}),i.int32(_c(n.get("X"))).int32(_c(n.get("Y"))).int32(_c(n.get("HEIGHT"))).uint16(E4(n.get("STROKEFONT"))).float64(E4(n.get("ROTATION"))).uint8(i3(n.get("MIRROR"))?1:0).int32(_c(n.get("WIDTH"))).uint8(i3(n.get("COMMENT"))?1:0).uint8(i3(n.get("DESIGNATOR"))?1:0).uint8(0).uint8(i3(n.get("USETTFONTS"))?1:0).uint8(i3(n.get("BOLD"))?1:0).uint8(i3(n.get("ITALIC"))?1:0).writeBytes(eIn(n.get("FONTNAME")??"",64)).uint8(i3(n.get("INVERTED"))?1:0).int32(_c(n.get("MARGINBORDERWIDTH"))).uint32(e).writeBytes(new Uint8Array(4)).uint8(i3(n.get("INVERTEDRECT"))?1:0).int32(_c(n.get("TEXTBOXWIDTH"))).int32(_c(n.get("TEXTBOXHEIGHT"))).uint8(E4(n.get("JUSTIFICATION"))).int32(_c(n.get("TEXTOFFSET"))),[i.toUint8Array(),AK(rZi(o))]}function EZi(t){const e=new LE;for(const[n,o]of t.entries()){const i=eIn(iIn(c9(o)));e.uint32(n).uint32(i.byteLength),i.byteLength>2&&e.writeBytes(i)}return e.toUint8Array()}function iIn(t){const e=t.get("WIDESTRING");return e===void 0?t.get("TEXT")??"":N1n(e)}function Ak(t,e){const n=new LE;for(const o of e){n.uint8(t);for(const i of o)n.uint32LengthPrefixedBytes(i)}return n.toUint8Array()}function cK({defaultLayerId:t,fields:e,writer:n}){n.uint8(B4(e.get("LAYER"),t)).uint16(BZi(e)).uint16(S1e(e.get("NET"))).uint16(S1e(e.get("POLYGON"))).uint16(S1e(e.get("COMPONENT"))).uint16(oIn).uint16(oIn)}function BZi(t){let e=dZi;return i3(t.get("LOCKED"))||(e|=gZi),i3(t.get("TENTEDTOP"))&&(e|=hZi),i3(t.get("TENTEDBOTTOM"))&&(e|=pZi),i3(t.get("KEEPOUT"))&&(e|=mZi),e}function bZi(t){const e=t.get("HOLESHAPE")?.toUpperCase();if(e!=="SLOT"&&e!=="SQUARE")return new Uint8Array;const n=new Uint8Array(596),o=new DataView(n.buffer);return o.setUint8(262,e==="SLOT"?2:1),o.setInt32(263,_c(t.get("HOLEWIDTH")),!0),o.setFloat64(267,E4(t.get("HOLEROTATION")),!0),n}function rIn({fields:t,propertyBytes:e}){const n=SZi(t),o=QZi(t),i=new LE;cK({defaultLayerId:B4(t.get("LAYER")),fields:t,writer:i}),i.uint8(0).uint16(o).uint16(0).uint32(e.byteLength).writeBytes(e).uint32(n-1);for(let r=0;r<n;r++)vZi({fields:t,vertexIndex:r,writer:i});for(let r=0;r<o;r++)wZi({fields:t,holeIndex:r,writer:i});return[i.toUint8Array()]}function SZi(t){const e=[...t.keys()].flatMap(o=>{const i=/^VX(\d+)$/u.exec(o);return i?.[1]===void 0?[]:[Number(i[1])]}),n=Math.max(...e,-1)+1;if(n<4)throw new Yg("Altium contours require an explicitly closed outline");for(let o=0;o<n;o++)if(!t.has(`VX${o}`)||!t.has(`VY${o}`))throw new Yg(`Altium contour outline is missing vertex ${o}`);if(_c(t.get("VX0"))!==_c(t.get(`VX${n-1}`))||_c(t.get("VY0"))!==_c(t.get(`VY${n-1}`)))throw new Yg("Altium contour outline must repeat its first vertex");return n}function QZi(t){const e=E4(t.get("HOLECOUNT"));if(!Number.isInteger(e)||e<0||e>65535)throw new Yg(`Invalid Altium contour hole count: ${e}`);return e}function vZi({fields:t,vertexIndex:e,writer:n}){const o=E4(t.get(`KIND${e}`));if(o!==0&&o!==1)throw new Yg(`Unsupported Altium contour vertex kind at index ${e}: ${o}`);n.uint8(o).int32(_c(t.get(`VX${e}`))).int32(_c(t.get(`VY${e}`))).int32(_c(t.get(`CX${e}`))).int32(_c(t.get(`CY${e}`))).int32(_c(t.get(`R${e}`))).float64(E4(t.get(`SA${e}`))).float64(E4(t.get(`EA${e}`)))}function wZi({fields:t,holeIndex:e,writer:n}){const o=E4(t.get(`HOLE${e}COUNT`));if(!Number.isInteger(o)||o<3||o>4294967295)throw new Yg(`Invalid Altium contour hole ${e} vertex count: ${o}`);n.uint32(o);for(let i=0;i<o;i++){const r=t.get(`HOLE${e}VX${i}`),s=t.get(`HOLE${e}VY${i}`);if(r===void 0||s===void 0)throw new Yg(`Altium contour hole ${e} is missing vertex ${i}`);n.float64(_c(r)).float64(_c(s))}}var PZi=/^(?:KIND|VX|VY|CX|CY|R|SA|EA)\d+$|^HOLE\d+(?:COUNT|V[XY]\d+)$/u,MZi=new Set(["COMPONENT","HOLECOUNT","KEEPOUT","LAYER","LOCKED","NET","POLYGON","RECORD","SOURCESTREAM","TEARDROP"]);function DZi(t){const e=c9(t),n=[...e.entries()].filter(([o])=>!MZi.has(o)&&!PZi.test(o)).map(([o,i])=>`|${o}=${i}`).join("");return rIn({fields:e,propertyBytes:rM(n).subarray(1)})}var NZi=65535;function RZi(t){const e=c9(t);return rIn({fields:e,propertyBytes:TZi(e)})}function TZi(t){const e=t.get("LAYER")??"TOP",n=S1e(t.get("POLYGON")),o=kZi(t.get("REGIONKIND")),i=[`V7_LAYER=${e}`,"NAME= ",`KIND=${o}`,`SUBPOLYINDEX=${n===NZi?-1:n}`,"UNIONINDEX=0","ARCRESOLUTION=0.5mil","ISSHAPEBASED=FALSE","CAVITYHEIGHT=0mil"].join("|");return rM(`|${i}`).subarray(1)}function kZi(t){return t?.toUpperCase()==="POLYGON_CUTOUT"?1:0}var FZi=["Arcs6","Regions6","ComponentBodies6","Classes6","DifferentialPairs6","Connections6"];function LZi(t){const e=Z1n(t);if(E1e(e).boardGeometry.outline.vertices.length<3)throw new Yg("Cannot create a binary PcbDoc without a board outline");const o=HZi(e),i=$1n();YZi(i),o3({compoundFile:i,content:b1e(o.Board),name:"Board6",recordCount:o.Board.length}),o3({compoundFile:i,content:b1e(o.Net),name:"Nets6",recordCount:o.Net.length}),o3({compoundFile:i,content:b1e(o.Component),name:"Components6",recordCount:o.Component.length}),o3({compoundFile:i,content:b1e(o.Polygon),name:"Polygons6",recordCount:o.Polygon.length}),o3({compoundFile:i,content:oZi(o.Dimension),name:"Dimensions6",recordCount:o.Dimension.length}),o3({compoundFile:i,content:Ak(ak.pad,o.Pad.map(fZi)),name:"Pads6",recordCount:o.Pad.length}),o3({compoundFile:i,content:Ak(ak.via,o.Via.map(yZi)),name:"Vias6",recordCount:o.Via.length}),o3({compoundFile:i,content:Ak(ak.track,o.Track.map(IZi)),name:"Tracks6",recordCount:o.Track.length}),o3({compoundFile:i,content:Ak(ak.fill,o.Fill.map(CZi)),name:"Fills6",recordCount:o.Fill.length}),o3({compoundFile:i,content:Ak(ak.region,o.Region.map(RZi)),name:"ShapeBasedRegions6",recordCount:o.Region.length}),o3({compoundFile:i,content:Ak(ak.componentBody,o.ComponentBody.map(DZi)),name:"ShapeBasedComponentBodies6",recordCount:o.ComponentBody.length}),o3({compoundFile:i,content:Ak(ak.text,o.Text.map(xZi)),name:"Texts6",recordCount:o.Text.length}),o3({compoundFile:i,content:EZi(o.Text),name:"WideStrings6",recordCount:o.Text.length});for(const r of FZi)o3({compoundFile:i,content:new Uint8Array,name:r,recordCount:0});return q1n(i)}function HZi(t){const e={Board:[],Component:[],ComponentBody:[],Dimension:[],Fill:[],Net:[],Pad:[],Polygon:[],Region:[],Text:[],Track:[],Via:[]};for(const n of t.split(/\r?\n|\r/u).filter(Boolean)){const o=nZi(n);if(!OZi(o))throw new Yg(`Unsupported PCB record kind for binary serialization: ${JSON.stringify(o||"missing RECORD")}`);GZi(o)&&cZi(n,o),e[o].push(n)}return e}function OZi(t){return["Board","Component","ComponentBody","Dimension","Fill","Net","Pad","Polygon","Region","Text","Track","Via"].includes(t)}function GZi(t){return["ComponentBody","Fill","Pad","Region","Text","Track","Via"].includes(t)}function YZi(t){const e=new LE().uint32(19);for(const i of"PCB 5.0 Bi")e.uint16(i.charCodeAt(0));rk({compoundFile:t,content:e.toUint8Array(),path:"/FileHeader"});const n="PCB 6.0 Binary File",o=new LE().uint32(n.length).writeBytes(AK(n)).float64(5.01);rk({compoundFile:t,content:o.toUint8Array(),path:"/FileHeaderSix"})}function UZi(t,e={}){const o=Z1n(t).split(/\r?\n|\r/u).filter(Boolean).filter(a=>!a.startsWith("|HEADER=")),i="Protel for Windows - Schematic Capture Binary File Version 5.0",r=[Q1e(rM(`|HEADER=${i}|WEIGHT=${o.length}|MINORVERSION=0|UNIQUEID=ALTIUMTS`)),...o.map(a=>Q1e(rM(a)))],s=$1n();return rk({compoundFile:s,content:aK(r),path:"/FileHeader"}),rk({compoundFile:s,content:KZi(e.embeddedImages??[]),path:"/Storage"}),rk({compoundFile:s,content:Q1e(rM(`|HEADER=${i}`)),path:"/Additional"}),q1n(s)}function KZi(t){const e=Q1e(rM("|HEADER=Icon storage")),n=t.map(({compressedBytes:o,name:i})=>{const r=c1e(i,"windows-1252");if(r.byteLength===0||r.byteLength>255)throw new RangeError("Embedded schematic image names must be 1 to 255 Windows-1252 bytes");if(o.byteLength===0)throw new RangeError("Embedded schematic image compressed bytes must not be empty");const s=aK([Uint8Array.of(208,r.byteLength),r,B1e(o.byteLength),o]);if(s.byteLength>16777215)throw new RangeError("Embedded schematic image storage entries must fit in 24 bits");return aK([B1e(s.byteLength),s])});return aK([e,...n])}function Q1e(t){return aK([B1e(t.byteLength),t])}[...Array.from({length:30},(t,e)=>`MID${e+1}`),...Array.from({length:30},(t,e)=>`MIDLAYER${e+1}`)],[...Array.from({length:16},(t,e)=>`PLANE${e+1}`),...Array.from({length:16},(t,e)=>`INTERNALPLANE${e+1}`)],[...Array.from({length:32},(t,e)=>`MECHANICAL${e+1}`)];const sg=39.3700787402,VZi=100,zZi=80,fr=(t,e=0)=>typeof t=="number"&&Number.isFinite(t)?t:e,Tu=(t,e)=>{const n=fr(t,e);return n>0?n:e},ti=(t,e="")=>typeof t=="string"?t:e,HE=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),AA=t=>{if(HE(t)&&!(typeof t.x!="number"||!Number.isFinite(t.x)||typeof t.y!="number"||!Number.isFinite(t.y)))return{x:t.x,y:t.y}},uu=t=>{const e=typeof t=="number"&&Number.isFinite(t)?String(t):ti(t);return j1n(e).trim()},JZi=t=>{const e=t.replace(/[^a-z0-9._-]+/giu,"-").replace(/^[.-]+|[.-]+$/gu,"").slice(0,80);return e?/^(?:aux|con|nul|prn|com[1-9]|lpt[1-9])$/iu.test(e)?`board-${e}`:e:"board"},Sp=t=>{const e=Math.round(t*1e4)/1e4;return Number.isInteger(e)?String(e):e.toFixed(4)},Xi=t=>`${Sp(t)}mil`,Dd=(t,e)=>t.filter(n=>n.type===e),r3=(t,e)=>Math.abs(t.x-e.x)<1e-9&&Math.abs(t.y-e.y)<1e-9,v1e=t=>{let e=0;for(const[n,o]of t.entries()){const i=t[(n+1)%t.length];i&&(e+=o.x*i.y-i.x*o.y)}return Math.abs(e/2)};class w1e{constructor(e,n){this.maxIterations=1e3,this.iteration=0,this.finished=!1,this.input=e,this.context=n}step(){if(this.iteration++,this.iteration>this.maxIterations)throw new Error(`${this.constructor.name} exceeded ${this.maxIterations} iterations`);this._step()}runUntilFinished(){for(;!this.finished;)this.step()}}function sM(t){const e=(t%360+360)%360;return e===0?0:e}function WZi(t){const e=Math.min(...t.map(i=>i.x)),n=Math.min(...t.map(i=>i.y)),o=Ad(pA(1e3,1e3),dC(sg,sg),pA(-e,-n));return i=>Bn(o,i)}function jZi({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=XZi(t),i=[];for(const r of Dd(t,"cad_component")){const s=n.get(ti(r.pcb_component_id));if(s===void 0)continue;const a=sIn(r.position),A=sIn(r.size);if(!a||!A)continue;$Zi(A,ti(r.cad_component_id));const c=ZZi(r),l=qZi({position:a,rotationDegrees:eer(r),size:A}).map(e),u=ter({boardThicknessMm:o,layer:c,positionZMm:a.z,sizeZMm:A.z});i.push(["|RECORD=ComponentBody",`LAYER=${c==="bottom"?"MECHANICAL14":"MECHANICAL13"}`,"LOCKED=FALSE","KEEPOUT=FALSE","NET=65535","POLYGON=65535",`COMPONENT=${s}`,"TEARDROP=FALSE","HOLECOUNT=0","ISSHAPEBASED=TRUE","KIND=0",`STANDOFFHEIGHT=${Xi(u*sg)}`,`OVERALLHEIGHT=${Xi(A.z*sg)}`,`BODYOPACITY3D=${r.show_as_translucent_model===!0?"0.5":"1"}`,`V7_LAYER=${c==="bottom"?"14":"13"}`,...l.flatMap((g,h)=>[`KIND${h}=0`,`VX${h}=${Xi(g.x)}`,`VY${h}=${Xi(g.y)}`])].join("|"))}return i}function sIn(t){if(!HE(t))return;const e=AA(t);if(!(!e||typeof t.z!="number"||!Number.isFinite(t.z)))return{...e,z:t.z}}function $Zi(t,e){if(!(t.x>0&&t.y>0&&t.z>=0))throw new Error(`CAD component ${JSON.stringify(e)} has an invalid body size`)}function qZi({position:t,rotationDegrees:e,size:n}){const o=Ad(pA(t.x,t.y),vQ(e*Math.PI/180)),i=n.x/2,r=n.y/2;return[{x:-i,y:-r},{x:i,y:-r},{x:i,y:r},{x:-i,y:r},{x:-i,y:-r}].map(a=>Bn(o,a))}function XZi(t){const e=Dd(t,"pcb_board")[0];return Math.max(fr(e?.thickness),0)}function ZZi(t){return ti(t.layer).toLowerCase()==="bottom"?"bottom":"top"}function eer(t){return HE(t.rotation)?fr(t.rotation.z):0}function ter({boardThicknessMm:t,layer:e,positionZMm:n,sizeZMm:o}){const i=e==="bottom"?-t/2:t/2;return(e==="bottom"?i-n:n-i)-o/2}const ner=Math.PI/24;function oer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n,netEntries:o}){const i=new Map(o.flatMap(l=>l.sourceNetIds.map(u=>[u,l]))),r=t.flatMap(l=>l.type!=="pcb_copper_pour"?[]:[{copperPour:ixe.parse(l),polygonId:ier(l.altium_polygon_id),polygonRole:rer(l.altium_polygon_role),polygonCutoutCount:Math.max(0,Math.trunc(fr(l.altium_polygon_cutout_count))),pcbComponentId:ti(l.pcb_component_id)}]),s=[],a=new Set(r.flatMap(({polygonId:l})=>l===void 0?[]:[l]));let A=0;const c=()=>{for(;a.has(A);)A++;const l=A;return a.add(l),A++,l};for(const l of r){const{copperPour:u,pcbComponentId:g,polygonCutoutCount:h,polygonRole:d}=l,p=l.polygonId??c(),m=ser(u),_={outerRing:m.outerRing.map(e),innerRings:m.innerRings.map(S=>S.map(e))},f=cer(u.layer),I=Math.min(h,_.innerRings.length),C=_.innerRings.length-I,y=_.innerRings.slice(0,C),x=_.innerRings.slice(C),E=u.source_net_id?i.get(u.source_net_id):void 0,B=n.get(g);if(B!==void 0){s.push(Wee({altiumComponentIndex:B,innerRings:_.innerRings,layer:f,outerRing:_.outerRing})),!u.covered_with_solder_mask&&cIn(f)&&s.push(Wee({altiumComponentIndex:B,innerRings:_.innerRings,layer:f==="TOP"?"TOPSOLDER":"BOTTOMSOLDER",outerRing:_.outerRing}));continue}d!=="region"&&s.push(ler({layer:f,net:E,outerRing:_.outerRing,polygonIndex:p})),d!=="outline"&&s.push(Wee({innerRings:y,layer:f,net:E,outerRing:_.outerRing,polygonIndex:p})),s.push(...x.map(S=>Wee({innerRings:[],layer:f,net:E,outerRing:Jee(S),polygonIndex:p,regionKind:"POLYGON_CUTOUT"}))),d!=="outline"&&!u.covered_with_solder_mask&&cIn(f)&&s.push(Wee({innerRings:_.innerRings,layer:f==="TOP"?"TOPSOLDER":"BOTTOMSOLDER",outerRing:_.outerRing}))}return s}function ier(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<65535?t:void 0}function rer(t){return t==="outline"||t==="region"?t:void 0}function ser(t){return t.shape==="rect"?{innerRings:[],outerRing:Jee(aer(t))}:t.shape==="polygon"?{innerRings:[],outerRing:Jee(t.points)}:{innerRings:t.brep_shape.inner_rings.map(e=>AIn(aIn(e.vertices))),outerRing:Jee(aIn(t.brep_shape.outer_ring.vertices))}}function aer(t){const e=Ad(pA(t.center.x,t.center.y),vQ((t.rotation??0)*Math.PI/180)),n=t.width/2,o=t.height/2;return[{x:-n,y:-o},{x:n,y:-o},{x:n,y:o},{x:-n,y:o}].map(i=>Bn(e,i))}function aIn(t){const e=AIn(t);if(e.length<3)throw new Error("A PCB copper pour ring requires at least three vertices");const n=[];for(const[o,i]of e.entries()){const r=e[(o+1)%e.length];if(r){XXe(n,i);for(const s of Aer({bulge:i.bulge??0,end:r,start:i}))XXe(n,s)}}return Jee(n)}function Aer({bulge:t,end:e,start:n}){if(Math.abs(t)<1e-12||r3(n,e))return[e];const o=e.x-n.x,i=e.y-n.y,r=(1-t*t)/(4*t),s={x:(n.x+e.x)/2-i*r,y:(n.y+e.y)/2+o*r},a=Math.hypot(n.x-s.x,n.y-s.y),A=Math.atan2(n.y-s.y,n.x-s.x),c=4*Math.atan(t),l=Math.max(2,Math.ceil(Math.abs(c)/ner));return Array.from({length:l},(u,g)=>{const h=A+c*(g+1)/l;return{x:s.x+a*Math.cos(h),y:s.y+a*Math.sin(h)}})}function Jee(t){const e=[];for(const o of t)XXe(e,o);const n=e[0];if(n&&!r3(n,e.at(-1)??n)&&e.push(n),e.length<4)throw new Error("A PCB copper pour ring requires at least three vertices");return e}function AIn(t){const e=[...t],n=e[0],o=e.at(-1);return n&&o&&r3(n,o)&&e.pop(),e}function XXe(t,e){const n=t.at(-1);(!n||!r3(n,e))&&t.push(e)}function cer(t){if(t==="top")return"TOP";if(t==="bottom")return"BOTTOM";const e=/^inner(\d+)$/u.exec(t);if(!e?.[1])throw new Error(`Unsupported PCB copper pour layer: ${t}`);return`MID-LAYER${Number(e[1])}`}function cIn(t){return t==="TOP"||t==="BOTTOM"}function ler({layer:t,net:e,outerRing:n,polygonIndex:o}){return["|RECORD=Polygon",`NET=${e?.index??65535}`,`ID=${o}`,"POLYGONTYPE=Polygon","POUROVERSTYLE=1","HATCHSTYLE=Solid","SELECTION=FALSE",`LAYER=${t}`,"LOCKED=FALSE",...lIn(n)].join("|")}function Wee({altiumComponentIndex:t,innerRings:e,layer:n,net:o,outerRing:i,polygonIndex:r,regionKind:s="COPPER"}){return["|RECORD=Region",...t===void 0?[]:[`COMPONENT=${t}`],...o?[`NET=${o.index}`]:[],...r===void 0?[]:[`POLYGON=${r}`],`LAYER=${n}`,"LOCKED=FALSE","KEEPOUT=FALSE","TEARDROP=FALSE",`REGIONKIND=${s}`,`HOLECOUNT=${e.length}`,...lIn(i),...e.flatMap(uer)].join("|")}function lIn(t){return t.flatMap((e,n)=>[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function uer(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=>[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function lK({altiumComponentIndex:t,circuitPoints:e,circuitToAltiumPcbPoint:n,closePath:o=!1,isKeepout:i=!1,layer:r,strokeWidthMm:s}){const a=o?tZe(e):[...e],A=[];for(let c=1;c<a.length;c++){const l=a[c-1],u=a[c];if(!l||!u)continue;const g=n(l),h=n(u);r3(g,h)||A.push(["|RECORD=Track",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,...i?["KEEPOUT=TRUE"]:[],"LOCKED=FALSE",`X1=${Xi(g.x)}`,`Y1=${Xi(g.y)}`,`X2=${Xi(h.x)}`,`Y2=${Xi(h.y)}`,`WIDTH=${Xi(s*sg)}`].join("|"))}return A}function uIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,heightMm:o,isKeepout:i=!1,layer:r,rotationDegrees:s=0,widthMm:a}){const A=n({x:e.x-a/2,y:e.y-o/2}),c=n({x:e.x+a/2,y:e.y+o/2});return["|RECORD=Fill",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,`KEEPOUT=${i?"TRUE":"FALSE"}`,"LOCKED=FALSE",`X1=${Xi(A.x)}`,`Y1=${Xi(A.y)}`,`X2=${Xi(c.x)}`,`Y2=${Xi(c.y)}`,`ROTATION=${Sp(sM(s))}`].join("|")}function ZXe({altiumComponentIndex:t,circuitPoints:e,circuitToAltiumPcbPoint:n,innerRings:o=[],isKeepout:i=!1,layer:r}){const s=tZe(e).map(n),a=o.map(A=>tZe(A).map(n));if(s.length<4)throw new Error("An Altium PCB region requires at least three vertices");return["|RECORD=Region",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${r}`,"LOCKED=FALSE",`KEEPOUT=${i?"TRUE":"FALSE"}`,"TEARDROP=FALSE","REGIONKIND=COPPER",`HOLECOUNT=${a.length}`,...ger(s),...a.flatMap(der)].join("|")}function ger(t){return t.flatMap((e,n)=>[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function der(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=>[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function eZe({center:t,radiusMm:e}){return Array.from({length:48},(o,i)=>{const r=i*Math.PI*2/48;return{x:t.x+Math.cos(r)*e,y:t.y+Math.sin(r)*e}})}function jee({center:t,cornerRadiusMm:e,heightMm:n,rotationDegrees:o=0,widthMm:i}){const r=i/2,s=n/2,a=Math.min(Math.max(e,0),r,s),A=a===0?[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}]:her({halfHeightMm:s,halfWidthMm:r,radiusMm:a}),c=Ad(pA(t.x,t.y),vQ(o*Math.PI/180));return A.map(l=>Bn(c,l))}function her({halfHeightMm:t,halfWidthMm:e,radiusMm:n}){const o=[{x:e-n,y:t-n,start:0},{x:-e+n,y:t-n,start:90},{x:-e+n,y:-t+n,start:180},{x:e-n,y:-t+n,start:270}],i=8;return o.flatMap(r=>Array.from({length:i},(s,a)=>{const c=(r.start+a*90/i)*Math.PI/180;return{x:r.x+Math.cos(c)*n,y:r.y+Math.sin(c)*n}}))}function tZe(t){const e=[...t],n=e[0],o=e.at(-1);return n&&o&&!r3(n,o)&&e.push(n),e}const per=.05;function mer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){const r=_er(i);if(!r)continue;const s=n.get(r.pcbComponentId);if(s===void 0)throw new Error(`PCB courtyard references missing component ${r.pcbComponentId}`);o.push(...lK({altiumComponentIndex:s,circuitPoints:r.points,circuitToAltiumPcbPoint:e,closePath:!0,layer:fer(r.layer),strokeWidthMm:per}))}return o}function _er(t){if(t.type==="pcb_courtyard_outline"){const e=sxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:e.outline}}if(t.type==="pcb_courtyard_polygon"){const e=axe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:e.points}}if(t.type==="pcb_courtyard_rect"){const e=rxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:jee({center:e.center,cornerRadiusMm:0,heightMm:e.height,rotationDegrees:e.ccw_rotation,widthMm:e.width})}}if(t.type==="pcb_courtyard_circle"){const e=Axe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:eZe({center:e.center,radiusMm:e.radius})}}if(t.type==="pcb_courtyard_pill"){const e=cxe.parse(t);return{layer:e.layer,pcbComponentId:e.pcb_component_id,points:jee({center:e.center,cornerRadiusMm:e.radius,heightMm:e.height,widthMm:e.width})}}}function fer(t){return t.toLowerCase()==="bottom"?"MECHANICAL16":"MECHANICAL15"}const OE=1e-9,Ier=4,gIn=8;function Cer({circuitJson:t,circuitToAltiumPcbPoint:e}){const n=[];for(const o of t){if(o.type!=="pcb_cutout")continue;const i=Z2e.parse(o);for(const r of yer(i))n.push(ber({circuitToAltiumPcbPoint:e,innerRings:r.innerRings??[],outerRing:r.outerRing}))}return n}function yer(t){return t.shape==="rect"?[{outerRing:jee({center:t.center,cornerRadiusMm:t.corner_radius??0,heightMm:t.height,rotationDegrees:t.rotation??0,widthMm:t.width})}]:t.shape==="circle"?[{outerRing:eZe({center:t.center,radiusMm:t.radius})}]:t.shape==="polygon"?[{outerRing:t.points}]:xer(t)}function xer(t){const e=nZe(t.route),n=e[0],o=e.at(-1),i=e.length>=3&&n!==void 0&&o!==void 0&&r3(n,o);if(i&&e.pop(),e.length===0)return[];const r=t.slot_width/2,s=Math.min(Math.max(t.slot_corner_radius??r,0),r);if(e.length===1){const A=e[0];return A?[{outerRing:jee({center:A,cornerRadiusMm:s,heightMm:t.slot_width,widthMm:t.slot_width})}]:[]}if(t.slot_length!==void 0&&t.slot_length>OE&&t.space_between_slots!==void 0&&t.space_between_slots>OE){const A=i?[...e,e[0]]:e;return Ber({dashLength:t.slot_length,gapLength:t.space_between_slots,points:A}).flatMap(c=>dIn({cornerRadiusMm:s,halfWidthMm:r,points:c}))}return i?Eer({halfWidthMm:r,points:e}):dIn({cornerRadiusMm:s,halfWidthMm:r,points:e})}function dIn({cornerRadiusMm:t,halfWidthMm:e,points:n}){const o=nZe(n);if(o.length<2||e<=OE)return[];const i=o[0],r=o.at(-1),s=uK(i,o[1]),a=uK(o.at(-2),r);if(!i||!r||!s||!a)return[];const A=hIn(o,e),c=hIn(o,-e),l=s3(A[0],pm(s,-(e-t))),u=s3(A.at(-1),pm(a,e-t)),g=s3(c.at(-1),pm(a,e-t)),h=s3(c[0],pm(s,-(e-t)));A[0]=l,A[A.length-1]=u,c[0]=h,c[c.length-1]=g;const d=[...A];return _In({center:r,cornerRadiusMm:t,halfWidthMm:e,normal:gK(a),outward:a,points:d}),d.push(...c.slice(0,-1).reverse()),_In({center:i,cornerRadiusMm:t,halfWidthMm:e,normal:pm(gK(s),-1),outward:pm(s,-1),points:d}),[{outerRing:d}]}function Eer({halfWidthMm:t,points:e}){if(e.length<3||t<=OE)return[];const n=pIn(e,t),o=pIn(e,-t);if(n.length<3||o.length<3)return[];const[i,r]=v1e(n)>=v1e(o)?[n,o]:[o,n];return[{innerRings:[r],outerRing:i}]}function hIn(t,e){const n=uK(t[0],t[1]),o=uK(t.at(-2),t.at(-1)),i=t[0],r=t.at(-1);if(!i||!r||!n||!o)return[];const s=[s3(i,pm(gK(n),e))];for(let a=1;a<t.length-1;a++)mIn({boundary:s,index:a,offset:e,points:t});return s.push(s3(r,pm(gK(o),e))),s}function pIn(t,e){const n=[];for(const[o]of t.entries())mIn({boundary:n,index:o,offset:e,points:t,wrap:!0});return n}function mIn({boundary:t,index:e,offset:n,points:o,wrap:i=!1}){const r=o[e],s=o[i?(e-1+o.length)%o.length:e-1],a=o[i?(e+1)%o.length:e+1],A=uK(s,r),c=uK(r,a);if(!r||!A||!c)return;const l=s3(r,pm(gK(A),n)),u=s3(r,pm(gK(c),n)),g=ver({firstDirection:A,firstPoint:l,secondDirection:c,secondPoint:u});if(g&&Math.hypot(g.x-r.x,g.y-r.y)<=Math.abs(n)*Ier){aM(t,g);return}aM(t,l),aM(t,u)}function _In({center:t,cornerRadiusMm:e,halfWidthMm:n,normal:o,outward:i,points:r}){if(e<=OE){aM(r,s3(t,pm(i,n),pm(o,n))),aM(r,s3(t,pm(i,n),pm(o,-n)));return}const s=n-e,a=s3(t,pm(i,s),pm(o,s));fIn({center:a,endAngleRadians:0,normal:o,outward:i,points:r,radius:e,startAngleRadians:Math.PI/2});const A=s3(t,pm(i,s),pm(o,-s));fIn({center:A,endAngleRadians:-Math.PI/2,normal:o,outward:i,points:r,radius:e,startAngleRadians:0})}function fIn({center:t,endAngleRadians:e,normal:n,outward:o,points:i,radius:r,startAngleRadians:s}){for(let a=1;a<=gIn;a++){const A=s+(e-s)*a/gIn;aM(i,s3(t,pm(o,Math.cos(A)*r),pm(n,Math.sin(A)*r)))}}function Ber({dashLength:t,gapLength:e,points:n}){const o=[0];for(let s=1;s<n.length;s++){const a=n[s-1],A=n[s];!a||!A||o.push((o.at(-1)??0)+Math.hypot(A.x-a.x,A.y-a.y))}const i=o.at(-1)??0,r=[];for(let s=0;s<i-OE;s+=t+e){const a=Math.min(s+t,i),A=[],c=IIn({cumulativeLengths:o,distance:s,points:n}),l=IIn({cumulativeLengths:o,distance:a,points:n});if(!(!c||!l)){A.push(c);for(let u=1;u<n.length-1;u++){const g=o[u],h=n[u];h&&g!==void 0&&g>s+OE&&g<a-OE&&A.push(h)}aM(A,l),A.length>=2&&r.push(A)}}return r}function IIn({cumulativeLengths:t,distance:e,points:n}){for(let o=1;o<t.length;o++){const i=t[o-1],r=t[o],s=n[o-1],a=n[o];if(i===void 0||r===void 0||!s||!a||e>r+OE)continue;const A=r-i;if(A<=OE)continue;const c=Math.min(Math.max((e-i)/A,0),1);return{x:s.x+(a.x-s.x)*c,y:s.y+(a.y-s.y)*c}}return n.at(-1)}function ber({circuitToAltiumPcbPoint:t,innerRings:e,outerRing:n}){const o=CIn(n).map(t),i=e.map(r=>CIn(r).map(t));return["|RECORD=Region","LAYER=MULTILAYER","LOCKED=FALSE","KEEPOUT=FALSE","TEARDROP=FALSE","ISBOARDCUTOUT=TRUE","REGIONKIND=COPPER",`HOLECOUNT=${i.length}`,...Ser(o),...i.flatMap(Qer)].join("|")}function CIn(t){const e=nZe(t),n=e[0],o=e.at(-1);if(n&&o&&!r3(n,o)&&e.push(n),e.length<4||v1e(e)<=OE)throw new Error("A PCB board cutout requires at least three vertices");return e}function Ser(t){return t.flatMap((e,n)=>[`KIND${n}=0`,`VX${n}=${Xi(e.x)}`,`VY${n}=${Xi(e.y)}`])}function Qer(t,e){return[`HOLE${e}COUNT=${t.length}`,...t.flatMap((n,o)=>[`HOLE${e}VX${o}=${Xi(n.x)}`,`HOLE${e}VY${o}=${Xi(n.y)}`])]}function nZe(t){const e=[];for(const n of t)aM(e,n);return e}function aM(t,e){const n=t.at(-1);(!n||!r3(n,e))&&t.push(e)}function uK(t,e){if(!t||!e)return;const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!(i<=OE))return{x:n/i,y:o/i}}function gK(t){return{x:-t.y,y:t.x}}function pm(t,e){return{x:t.x*e,y:t.y*e}}function s3(...t){return t.reduce((e,n)=>({x:e.x+n.x,y:e.y+n.y}),{x:0,y:0})}function yIn(t,e){return t.x*e.y-t.y*e.x}function ver({firstDirection:t,firstPoint:e,secondDirection:n,secondPoint:o}){const i=yIn(t,n);if(Math.abs(i)<=OE)return;const r={x:o.x-e.x,y:o.y-e.y},s=yIn(r,n)/i;return s3(e,pm(t,s))}function xIn({altiumComponentIndex:t,circuitToAltiumPcbPoint:e,dimension:n,layer:o}){const i=n.to.x-n.from.x,r=n.to.y-n.from.y;if(Math.hypot(i,r)===0)throw new Error("A PCB dimension requires distinct from and to points");const a=wer({deltaX:i,deltaY:r,offsetDirection:n.offset_direction}),A="offset"in n?n.offset:void 0,c=n.offset_distance??A??0,l={x:n.from.x+a.x*c,y:n.from.y+a.y*c},u={x:n.to.x+a.x*c,y:n.to.y+a.y*c},g=e(n.from),h=e(n.to),d=e(l),p=e(u),m={x:(d.x+p.x)/2,y:(d.y+p.y)/2},_=n.font_size,f=n.arrow_size;return["|RECORD=Dimension",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${o}`,"DIMENSIONKIND=0",`TEXTFORMAT=${n.text?uu(n.text):"<>"}`,`HEIGHT=${Xi(Math.abs(c)*sg)}`,`LINEWIDTH=${Xi(Math.max(.05,_*.1)*sg)}`,`TEXTHEIGHT=${Xi(_*sg)}`,`TEXTLINEWIDTH=${Xi(Math.max(.05,_*.1)*sg)}`,"TEXTPRECISION=3","TEXTBOLD=FALSE","ITALIC=FALSE",`TEXTGAP=${Xi(_*.2*sg)}`,`ARROWSIZE=${Xi(f*sg)}`,"TEXTPOSITION=Manual",`X1=${Xi(d.x)}`,`Y1=${Xi(d.y)}`,"REFERENCES_COUNT=2",`REFERENCE0POINTX=${Xi(g.x)}`,`REFERENCE0POINTY=${Xi(g.y)}`,`REFERENCE1POINTX=${Xi(h.x)}`,`REFERENCE1POINTY=${Xi(h.y)}`,`TEXT1X=${Xi(m.x)}`,`TEXT1Y=${Xi(m.y)}`,"TEXTDIMENSIONUNIT=Millimeters","TEXTSUFFIX=mm",`ANGLE=${Sp(Per({end:p,start:d}))}`].join("|")}function wer({deltaX:t,deltaY:e,offsetDirection:n}){const o=n??{x:-e,y:t},i=Math.hypot(o.x,o.y);if(i===0)throw new Error("A PCB dimension offset direction cannot be zero");return{x:o.x/i,y:o.y/i}}function Per({end:t,start:e}){return(Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI%360+360)%360}function oZe({altiumComponentIndex:t,circuitText:e,circuitToAltiumPcbPoint:n,layer:o}){const i=AA(e.anchor_position)??AA(e.center)??{x:0,y:0},r=n(i),s=ti(e.layer).toLowerCase()==="bottom",a=typeof e.is_mirrored=="boolean"?e.is_mirrored:e.is_mirrored_from_top_view,A=typeof a=="boolean"?a:s,c=Tu(e.font_size,1);return["|RECORD=Text",...t===void 0?[]:[`COMPONENT=${t}`],`LAYER=${o}`,`X=${Xi(r.x)}`,`Y=${Xi(r.y)}`,`ROTATION=${Sp(sM(fr(e.ccw_rotation)))}`,`MIRROR=${A?"TRUE":"FALSE"}`,`HEIGHT=${Xi(c*sg)}`,`WIDTH=${Xi(Math.max(.05,c*.1)*sg)}`,"USETTFONTS=TRUE","FONTNAME=Arial",`JUSTIFICATION=${Mer(e.anchor_alignment)}`,`WIDESTRING=${Der(ti(e.text))}`].join("|")}function Mer(t){switch(t){case"top_left":return 1;case"center_left":return 2;case"bottom_left":return 3;case"top_center":return 4;case"center":return 5;case"bottom_center":return 6;case"top_right":return 7;case"center_right":return 8;case"bottom_right":return 9;default:return 5}}function Der(t){const e=[];for(const n of t){const o=n.codePointAt(0);o!==void 0&&e.push(o)}return e.join(",")}function Ner({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){if(!Rer(i))continue;const r=Ter({componentIndex:n,element:i});if(i.type==="pcb_fabrication_note_path"){const s=K2e.parse(i);o.push(...lK({altiumComponentIndex:r,circuitPoints:s.route,circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type==="pcb_note_path"){const s=j2e.parse(i);o.push(...lK({altiumComponentIndex:r,circuitPoints:s.route,circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type==="pcb_note_line"){const s=$2e.parse(i);if(s.is_dashed)throw new Error("Altium PCB note lines do not preserve dashed strokes");o.push(...lK({altiumComponentIndex:r,circuitPoints:[{x:s.x1,y:s.y1},{x:s.x2,y:s.y2}],circuitToAltiumPcbPoint:e,layer:HS(s.layer),strokeWidthMm:s.stroke_width}))}else if(i.type==="pcb_fabrication_note_rect"){const s=V2e.parse(i);o.push(...EIn({altiumComponentIndex:r,center:s.center,circuitToAltiumPcbPoint:e,cornerRadiusMm:s.corner_radius??0,hasStroke:s.has_stroke!==!1,heightMm:s.height,isFilled:s.is_filled===!0,isStrokeDashed:s.is_stroke_dashed===!0,layer:HS(s.layer),strokeWidthMm:s.stroke_width,widthMm:s.width}))}else if(i.type==="pcb_note_rect"){const s=W2e.parse(i);o.push(...EIn({altiumComponentIndex:r,center:s.center,circuitToAltiumPcbPoint:e,cornerRadiusMm:s.corner_radius??0,hasStroke:s.has_stroke!==!1,heightMm:s.height,isFilled:s.is_filled===!0,isStrokeDashed:s.is_stroke_dashed===!0,layer:HS(s.layer),strokeWidthMm:s.stroke_width,widthMm:s.width}))}else if(i.type==="pcb_fabrication_note_text"){const s=U2e.parse(i);o.push(oZe({altiumComponentIndex:r,circuitText:i,circuitToAltiumPcbPoint:e,layer:HS(s.layer)}))}else if(i.type==="pcb_note_text"){const s=J2e.parse(i);o.push(oZe({altiumComponentIndex:r,circuitText:i,circuitToAltiumPcbPoint:e,layer:HS(s.layer)}))}else if(i.type==="pcb_fabrication_note_dimension"){const s=z2e.parse(i);o.push(xIn({altiumComponentIndex:r,circuitToAltiumPcbPoint:e,dimension:s,layer:HS(s.layer)}))}else if(i.type==="pcb_note_dimension"){const s=q2e.parse(i);o.push(xIn({altiumComponentIndex:r,circuitToAltiumPcbPoint:e,dimension:s,layer:HS(s.layer)}))}}return o}function Rer(t){return["pcb_fabrication_note_dimension","pcb_fabrication_note_path","pcb_fabrication_note_rect","pcb_fabrication_note_text","pcb_note_dimension","pcb_note_line","pcb_note_path","pcb_note_rect","pcb_note_text"].includes(t.type??"")}function EIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,cornerRadiusMm:o,hasStroke:i,heightMm:r,isFilled:s,isStrokeDashed:a,layer:A,strokeWidthMm:c,widthMm:l}){if(a)throw new Error("Altium PCB note rectangles do not preserve dashed strokes");const u=jee({center:e,cornerRadiusMm:o,heightMm:r,widthMm:l}),g=[];return s&&g.push(o===0?uIn({altiumComponentIndex:t,center:e,circuitToAltiumPcbPoint:n,heightMm:r,layer:A,widthMm:l}):ZXe({altiumComponentIndex:t,circuitPoints:u,circuitToAltiumPcbPoint:n,layer:A})),i&&g.push(...lK({altiumComponentIndex:t,circuitPoints:u,circuitToAltiumPcbPoint:n,closePath:!0,layer:A,strokeWidthMm:c})),g}function Ter({componentIndex:t,element:e}){if(typeof e.pcb_component_id!="string")return;const n=t.get(e.pcb_component_id);if(n===void 0)throw new Error(`PCB annotation references missing component ${e.pcb_component_id}`);return n}function HS(t){return t.toLowerCase()==="bottom"?"MECHANICAL2":"MECHANICAL1"}class ker{constructor(e){this.parentByTraceIndex=Array.from({length:e},(n,o)=>o)}getRoot(e){if(!Number.isInteger(e)||e<0||e>=this.parentByTraceIndex.length)throw new RangeError(`Unknown trace index: ${e}`);let n=e,o=this.parentByTraceIndex[n];for(;o!==n;){if(o===void 0)throw new RangeError(`Unknown trace index: ${n}`);n=o,o=this.parentByTraceIndex[n]}let i=e;for(;this.parentByTraceIndex[i]!==i;){const r=this.parentByTraceIndex[i];if(r===void 0)throw new RangeError(`Unknown trace index: ${i}`);this.parentByTraceIndex[i]=n,i=r}return n}connect(e,n){const o=this.getRoot(e),i=this.getRoot(n);if(o===i)return;const r=Math.min(o,i);this.parentByTraceIndex[o]=r,this.parentByTraceIndex[i]=r}}function BIn({basePcbNetName:t,useCountByPcbNetName:e}){const n=(e.get(t)??0)+1;return e.set(t,n),n===1?t:`${t}-${n}`}function bIn(t,e){return Math.min(...t.sourceNetIds.map(n=>e.get(n)??Number.POSITIVE_INFINITY))}const SIn=t=>{const e=new Map(Dd(t,"source_net").flatMap(g=>{const h=ti(g.source_net_id);return h?[[h,uu(g.name)||h]]:[]})),n=new Map([...e.keys()].map((g,h)=>[g,h])),o=Dd(t,"source_trace"),i=new ker(o.length),r=new Map,s=new Map;for(const[g,h]of o.entries()){const d=Array.isArray(h.connected_source_port_ids)?h.connected_source_port_ids.map(m=>ti(m)):[],p=Array.isArray(h.connected_source_net_ids)?h.connected_source_net_ids.map(m=>ti(m)):[];for(const[m,_]of[...d.map(f=>[f,r]),...p.map(f=>[f,s])]){if(!m)continue;const f=_.get(m);f===void 0?_.set(m,g):i.connect(f,g)}}const a=new Map;for(const g of o.keys()){const h=i.getRoot(g);a.set(h,[...a.get(h)??[],g])}const A=new Map,c=[];for(const g of a.values()){const h=g.flatMap(I=>{const C=o[I];return C?[C]:[]}),d=[...new Set(h.flatMap(I=>Array.isArray(I.connected_source_net_ids)?I.connected_source_net_ids.map(C=>ti(C)).filter(Boolean):[]))],p=[...new Set(h.flatMap(I=>Array.isArray(I.connected_source_port_ids)?I.connected_source_port_ids.map(C=>ti(C)).filter(Boolean):[]))],m=h.map(I=>uu(I.name)||uu(I.display_name)).find(Boolean);if(d.length===0&&p.length===0&&!m)continue;const _=c.length,f=d.map(I=>e.get(I)).find(Boolean)||m||`Net-${_+1}`;c.push({index:_,name:BIn({basePcbNetName:f,useCountByPcbNetName:A}),sourceNetIds:d,sourcePortIds:p,traceIds:h.map((I,C)=>ti(I.source_trace_id)||`source_trace_${g[C]??C}`)})}const l=new Set(c.flatMap(g=>g.sourceNetIds)),u=new Set([...e.keys(),...Dd(t,"pcb_copper_pour").map(g=>ti(g.source_net_id)).filter(Boolean)]);for(const g of u){if(l.has(g))continue;const h=e.get(g)??g;c.push({index:c.length,name:BIn({basePcbNetName:h,useCountByPcbNetName:A}),sourceNetIds:[g],sourcePortIds:[],traceIds:[]}),l.add(g)}c.sort((g,h)=>{const d=bIn(g,n),p=bIn(h,n);return d!==p?d-p:g.index-h.index});for(const[g,h]of c.entries())h.index=g;return c};function QIn(t){if(/[\r\n|*?]/u.test(t))throw new Error(`Cannot represent keepout exclusion query name: ${JSON.stringify(t)}`);return`'${t.replaceAll("'","''")}'`}function Fer({circuitJson:t,excludedComponentIds:e,unionIndex:n}){const o=Dd(t,"pcb_component"),i=Dd(t,"source_component"),r=o.map((u,g)=>{const h=i.find(d=>d.source_component_id===u.source_component_id);return uu(h?.name)||`Component-${g+1}`}),s=new Set,a=[...new Set(e)].map(u=>{const g=o.findIndex(d=>d.pcb_component_id===u);if(g===-1)throw new Error(`Keepout exclusion references missing PCB component ${u}`);const h=r[g];if(r.filter(d=>d.toLowerCase()===h.toLowerCase()).length!==1)throw new Error(`Keepout exclusion has ambiguous Altium component name ${h}`);return s.add(ti(o[g].source_component_id)),QIn(h)}),A=new Set(Dd(t,"source_port").filter(u=>s.has(ti(u.source_component_id))).map(u=>ti(u.source_port_id))),c=SIn(t).filter(u=>u.sourcePortIds.some(g=>A.has(g))).map(u=>QIn(u.name)),l=[`InComponent(${a.join(", ")})`];return c.length&&l.push(`((IsTrack Or IsArc) And InNet(${c.join(", ")}))`),["|RECORD=Rule","BINARYRECORDTYPE=0","RULEKIND=Clearance","NETSCOPE=AnyNet","LAYERKIND=SameLayer",`SCOPE1EXPRESSION=IsKeepOut And InUnion(${n})`,`SCOPE2EXPRESSION=${l.join(" Or ")}`,`NAME=TscircuitKeepoutExclusion${n}`,"ENABLED=TRUE",`PRIORITY=${n}`,"GAP=0mil","DEFINEDBYLOGICALDOCUMENT=FALSE"].join("|")}function Ler({circuitJson:t,circuitToAltiumPcbPoint:e}){const n=[];let o=0;for(const i of t){if(i.type!=="pcb_keepout")continue;const r=X2e.parse(i),s=r.excluded_pcb_component_ids?.length?++o:void 0;s!==void 0&&n.push(Fer({circuitJson:t,excludedComponentIds:r.excluded_pcb_component_ids,unionIndex:s}));const a=A=>s===void 0?A:`${A}|UNIONINDEX=${s}`;if(r.shape==="outline"&&r.stroke_width<=0)throw new Error(`PCB keepout outline ${r.pcb_keepout_id} requires a stroke width`);for(const A of r.layers.map(Her)){if(r.shape==="rect"){n.push(a(uIn({center:r.center,circuitToAltiumPcbPoint:e,heightMm:r.height,isKeepout:!0,layer:A,widthMm:r.width})));continue}if(r.shape==="circle"){n.push(a(ZXe({circuitPoints:eZe({center:r.center,radiusMm:r.radius}),circuitToAltiumPcbPoint:e,isKeepout:!0,layer:A})));continue}n.push(...lK({circuitPoints:r.outline,circuitToAltiumPcbPoint:e,isKeepout:!0,layer:A,strokeWidthMm:r.stroke_width}).map(a))}}return n}function Her(t){const e=t.toLowerCase();if(e==="top")return"TOP";if(e==="bottom")return"BOTTOM";if(e==="all"||e==="multilayer")return"KEEPOUT";const n=/^inner(\d+)$/u.exec(e);if(n?.[1])return`MID-LAYER${Number(n[1])}`;throw new Error(`Unsupported PCB keepout layer: ${t}`)}function Oer({circuitJson:t,circuitToAltiumPcbPoint:e,componentIndex:n}){const o=[];for(const i of t){if(i.type!=="pcb_silkscreen_graphic")continue;const r=Ger(i);r&&o.push(ZXe({altiumComponentIndex:n.get(ti(i.pcb_component_id)),circuitPoints:r.outerRing,circuitToAltiumPcbPoint:e,innerRings:r.innerRings,layer:ti(i.layer).toLowerCase()==="bottom"?"BOTTOMOVERLAY":"TOPOVERLAY"}))}return o}function Ger(t){if(t.shape!=="brep"||!HE(t.brep_shape))return;const e=vIn(t.brep_shape.outer_ring);return e.length<3?void 0:{innerRings:Array.isArray(t.brep_shape.inner_rings)?t.brep_shape.inner_rings.map(vIn).filter(o=>o.length>=3):[],outerRing:e}}function vIn(t){return!HE(t)||!Array.isArray(t.vertices)?[]:t.vertices.flatMap(e=>{const n=AA(e);return n?[n]:[]})}function Yer({altiumComponentIndex:t,circuitToAltiumPcbPoint:e,silkscreenText:n}){const o=ti(n.layer).toLowerCase()==="bottom";return oZe({altiumComponentIndex:t,circuitText:n,circuitToAltiumPcbPoint:e,layer:o?"BOTTOMOVERLAY":"TOPOVERLAY"})}const Uer=t=>{const e=Array.isArray(t?.outline)?t.outline.map(AA):[],n=e.filter(c=>!!c),o=n.length===e.length,i=n[0],r=n.at(-1);if(n.length>1&&i&&r&&r3(i,r)&&n.pop(),o&&n.length>=3&&v1e(n)>1e-9)return n;const s=AA(t?.center)??{x:0,y:0},a=Tu(t?.width,VZi),A=Tu(t?.height,zZi);return[{x:s.x-a/2,y:s.y-A/2},{x:s.x+a/2,y:s.y-A/2},{x:s.x+a/2,y:s.y+A/2},{x:s.x-a/2,y:s.y+A/2}]};function wIn(t,e){const n=e.pcbPorts.get(ti(t.pcb_port_id));return e.netBySourcePortId.get(ti(n?.source_port_id))}function PIn(t,e){const n=e.pcbPorts.get(ti(t.pcb_port_id)),o=e.sourcePorts.get(ti(n?.source_port_id));return uu(o?.pin_number?.toString())||uu(o?.name)||"1"}const Ker=t=>{const e=Dd(t,"pcb_board")[0],n=Uer(e),o=WZi(n),i=n[0]??{x:0,y:0},a=[["|RECORD=Board","KIND=Protel_Advanced_PCB","VERSION=5.00",...[...n,i].flatMap((f,I)=>{const C=o(f);return[`KIND${I}=0`,`VX${I}=${Xi(C.x)}`,`VY${I}=${Xi(C.y)}`]})].join("|")],A=new Map(Dd(t,"source_component").filter(f=>typeof f.source_component_id=="string").map(f=>[ti(f.source_component_id),f])),c=new Map(Dd(t,"source_port").map(f=>[ti(f.source_port_id),f])),l=new Map(Dd(t,"pcb_port").map(f=>[ti(f.pcb_port_id),f])),u=SIn(t),g=new Map(u.flatMap(f=>f.traceIds.map(I=>[I,f]))),h=new Map(u.flatMap(f=>f.sourcePortIds.map(I=>[I,f]))),d=Dd(t,"pcb_component"),p=new Map(d.map((f,I)=>[ti(f.pcb_component_id)||`pcb_component_${I}`,I]));for(const f of u)a.push(`|RECORD=Net|ID=${f.index}|NAME=${uu(f.name)}|VISIBLE=FALSE|JUMPERSVISIBLE=FALSE`);a.push(...Cer({circuitJson:t,circuitToAltiumPcbPoint:o})),a.push(...oer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p,netEntries:u}));for(const[f,I]of d.entries()){const C=ti(I.pcb_component_id)||`pcb_component_${f}`,y=A.get(ti(I.source_component_id)),x=o(AA(I.center)??{x:0,y:0}),E=uu(y?.name)||`Component-${f+1}`,B=`TSCIRCUIT-${Sp(Tu(I.width,1))}x${Sp(Tu(I.height,1))}mm`,S=ti(I.layer).toLowerCase()==="bottom"?"BOTTOM":"TOP";a.push(["|RECORD=Component",`ID=${f}`,`LAYER=${S}`,`X=${Xi(x.x)}`,`Y=${Xi(x.y)}`,`ROTATION=${Sp(sM(fr(I.rotation)))}`,`PATTERN=${B}`,`SOURCEDESIGNATOR=${E}`,"NAMEON=TRUE","COMMENTON=TRUE",`SOURCEUNIQUEID=${uu(C)}`].join("|"))}a.push(...jZi({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p})),a.push(...Ler({circuitJson:t,circuitToAltiumPcbPoint:o}),...mer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}),...Ner({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}));const m={netBySourcePortId:h,pcbPorts:l,sourcePorts:c};for(const f of Dd(t,"pcb_smtpad")){const I=o({x:fr(f.x),y:fr(f.y)}),C=p.get(ti(f.pcb_component_id)),y=wIn(f,m),x=Tu(f.radius,.5)*2,E=Tu(f.width,x),B=Tu(f.height,E),S=f.shape==="circle"?"ROUND":"RECTANGLE",Q=ti(f.layer).toLowerCase()==="bottom"?"BOTTOM":"TOP";a.push(["|RECORD=Pad",...C===void 0?[]:[`COMPONENT=${C}`],...y?[`NET=${y.index}`]:[],`LAYER=${Q}`,`ROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,`NAME=${PIn(f,m)}`,"HOLESIZE=0mil","PLATED=TRUE","LOCKED=FALSE",`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`SHAPE=${S}`,`XSIZE=${Xi(E*sg)}`,`YSIZE=${Xi(B*sg)}`].join("|"))}for(const f of Dd(t,"pcb_plated_hole")){const I=o({x:fr(f.x),y:fr(f.y)}),C=p.get(ti(f.pcb_component_id)),y=wIn(f,m),x=Tu(f.outer_width,Tu(f.outer_diameter,1.6)),E=Tu(f.outer_height,x),B=Tu(f.hole_width,Tu(f.hole_diameter,.8)),S=Tu(f.hole_height,B),Q=Math.abs(B-S)>1e-9;a.push(["|RECORD=Pad",...C===void 0?[]:[`COMPONENT=${C}`],...y?[`NET=${y.index}`]:[],"LAYER=MULTILAYER",`ROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,`NAME=${PIn(f,m)}`,`HOLESIZE=${Xi(Math.min(B,S)*sg)}`,`HOLEWIDTH=${Xi(Math.max(B,S)*sg)}`,`HOLESHAPE=${Q?"SLOT":"ROUND"}`,`HOLEROTATION=${Sp(sM(fr(f.ccw_rotation)))}`,"PLATED=TRUE","LOCKED=FALSE",`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`SHAPE=${f.shape==="circle"||f.shape==="oval"||f.shape==="pill"?"ROUND":"RECTANGLE"}`,`XSIZE=${Xi(x*sg)}`,`YSIZE=${Xi(E*sg)}`].join("|"))}for(const[f,I]of Dd(t,"pcb_hole").entries()){const C=o({x:fr(I.x),y:fr(I.y)}),y=p.get(ti(I.pcb_component_id)),x=Tu(I.hole_diameter,1),E=Tu(I.hole_width,x),B=Tu(I.hole_height,x),S=Math.abs(E-B)>1e-9;a.push(["|RECORD=Pad",...y===void 0?[]:[`COMPONENT=${y}`],"LAYER=MULTILAYER",`ROTATION=${Sp(sM(fr(I.ccw_rotation)))}`,`NAME=NPTH-${f+1}`,`HOLESIZE=${Xi(Math.min(E,B)*sg)}`,`HOLEWIDTH=${Xi(Math.max(E,B)*sg)}`,`HOLESHAPE=${S?"SLOT":"ROUND"}`,`HOLEROTATION=${Sp(sM(fr(I.ccw_rotation)))}`,"PLATED=FALSE","LOCKED=FALSE",`X=${Xi(C.x)}`,`Y=${Xi(C.y)}`,`SHAPE=${S?"RECTANGLE":"ROUND"}`,`XSIZE=${Xi(E*sg)}`,`YSIZE=${Xi(B*sg)}`].join("|"))}for(const f of Dd(t,"pcb_trace")){const I=Array.isArray(f.route)?f.route.flatMap(y=>HE(y)&&AA(y)?[y]:[]):[],C=g.get(ti(f.source_trace_id));for(let y=1;y<I.length;y++){const x=I[y-1],E=I[y];if(!x||!E||x.route_type==="via"&&E.route_type==="via")continue;const B=o({x:fr(x.x),y:fr(x.y)}),S=o({x:fr(E.x),y:fr(E.y)});if(r3(B,S))continue;const Q=ti(E.layer,ti(x.layer)).toLowerCase()==="bottom"?"BOTTOM":"TOP";a.push(["|RECORD=Track",...C?[`NET=${C.index}`]:[],`LAYER=${Q}`,"LOCKED=FALSE",`X1=${Xi(B.x)}`,`Y1=${Xi(B.y)}`,`X2=${Xi(S.x)}`,`Y2=${Xi(S.y)}`,`WIDTH=${Xi(Tu(E.width,Tu(x.width,.2))*sg)}`].join("|"))}}const _=new Map(Dd(t,"pcb_trace").map(f=>[ti(f.pcb_trace_id),f]));for(const f of Dd(t,"pcb_via")){const I=o({x:fr(f.x),y:fr(f.y)}),C=_.get(ti(f.pcb_trace_id)),y=g.get(ti(f.source_trace_id,ti(C?.source_trace_id)));a.push(["|RECORD=Via",...y?[`NET=${y.index}`]:[],`X=${Xi(I.x)}`,`Y=${Xi(I.y)}`,`DIAMETER=${Xi(Tu(f.outer_diameter,.6)*sg)}`,`HOLESIZE=${Xi(Tu(f.hole_diameter,.3)*sg)}`,"STARTLAYER=TOP","STOPLAYER=BOTTOM","LOCKED=FALSE"].join("|"))}for(const f of Dd(t,"pcb_silkscreen_path")){const I=Array.isArray(f.route)?f.route.flatMap(x=>HE(x)&&AA(x)?[x]:[]):[],C=p.get(ti(f.pcb_component_id)),y=ti(f.layer).toLowerCase()==="bottom"?"BOTTOMOVERLAY":"TOPOVERLAY";for(let x=1;x<I.length;x++){const E=AA(I[x-1]),B=AA(I[x]);if(!E||!B)continue;const S=o(E),Q=o(B);r3(S,Q)||a.push(["|RECORD=Track",...C===void 0?[]:[`COMPONENT=${C}`],`LAYER=${y}`,"LOCKED=FALSE",`X1=${Xi(S.x)}`,`Y1=${Xi(S.y)}`,`X2=${Xi(Q.x)}`,`Y2=${Xi(Q.y)}`,`WIDTH=${Xi(Tu(f.stroke_width,.15)*sg)}`].join("|"))}}a.push(...Oer({circuitJson:t,circuitToAltiumPcbPoint:o,componentIndex:p}));for(const f of Dd(t,"pcb_silkscreen_text"))a.push(Yer({altiumComponentIndex:p.get(ti(f.pcb_component_id)),circuitToAltiumPcbPoint:o,silkscreenText:f}));return`${a.join(`\r
`)}\r
`},Ver=/(?:^|\|)RECORD=Region(?:\||$)/iu,P1e=/\|ISBOARDCUTOUT=TRUE(?=\||$)/giu,MIn="/ShapeBasedRegions6/Data",zer=11,DIn=18,NIn=22,M1e=new TextEncoder().encode("|ISBOARDCUTOUT=TRUE");function RIn(t){const{cutoutRegionIndexes:e,source:n}=Jer(t),o=LZi(n);if(e.size===0)return o;const i=A9.read(o,{type:"buffer"}),r=A9.find(i,MIn);if(!r)throw new Error(`Altium PCB is missing ${MIn}`);const s=Wer(Uint8Array.from(r.content),e);if(s.count!==e.size)throw new Error(`Expected to mark ${e.size} Altium board-cutout regions, marked ${s.count}`);return r.content=s.stream,r.size=s.stream.byteLength,new Uint8Array(A9.write(i,{fileType:"cfb",type:"buffer"}))}function Jer(t){let e=0;const n=new Set,o=t.split(new RegExp("(?<=\\n)","u")).map(i=>{if(!Ver.test(i))return i;const r=e++;return P1e.test(i)?(P1e.lastIndex=0,n.add(r),i.replace(P1e,"")):i});return P1e.lastIndex=0,{cutoutRegionIndexes:n,source:o.join("")}}function Wer(t,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength),o=[];let i=0,r=0,s=0;for(;i<t.byteLength;){if(t.byteLength-i<5)throw new Error("Truncated Altium region record header");const c=n.getUint8(i),l=n.getUint32(i+1,!0),u=i+5,g=u+l;if(g>t.byteLength)throw new Error("Truncated Altium region record payload");if(c!==zer)throw new Error(`Unexpected Altium region object ID ${c}`);const h=t.subarray(u,g),d=e.has(r)?jer(h,r):h;d!==h&&s++,o.push($er(c,d)),r++,i=g}const a=new Uint8Array(o.reduce((c,l)=>c+l.byteLength,0));let A=0;for(const c of o)a.set(c,A),A+=c.byteLength;return{count:s,stream:a}}function jer(t,e){if(t.byteLength<NIn)throw new Error(`Altium region ${e} has no property block`);const o=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(DIn,!0),i=NIn+o;if(o<1||i>t.byteLength)throw new Error(`Altium region ${e} has an invalid property block`);const r=i-1;if(t[r]!==0)throw new Error(`Altium region ${e} has an unterminated property block`);const s=new Uint8Array(t.byteLength+M1e.byteLength);return s.set(t.subarray(0,r),0),s.set(M1e,r),s.set(t.subarray(r),r+M1e.byteLength),new DataView(s.buffer).setUint32(DIn,o+M1e.byteLength,!0),s}function $er(t,e){const n=new Uint8Array(e.byteLength+5),o=new DataView(n.buffer);return o.setUint8(0,t),o.setUint32(1,e.byteLength,!0),n.set(e,5),n}const qer={Fill:"Fills6",Track:"Tracks6",Region:"ShapeBasedRegions6"};function Xer(t){const e=E1e(t,{mode:"strict"}),n=e.getRecordsByKind("Rule");if(!n.length)return RIn(t);const o=t.split(/\r?\n/u).filter(a=>!/^\|RECORD=Rule\|/u.test(a)).map(a=>a.replace(/\|UNIONINDEX=\d+/gu,"")).join(`\r
`),i=A9.read(RIn(o),{type:"buffer"}),r=n.map(a=>{if(a.get("RULEKIND")!=="Clearance"||a.getNumber("BINARYRECORDTYPE")!==0)throw new Error("Keepout rule serializer only supports native Clearance rules");const A=a.getString().trim().replace(/\|(?:RECORD|BINARYRECORDTYPE)=[^|]*/gu,"");if(/[^\x20-\x7e]/u.test(A))throw new Error("Keepout rule serialization requires ASCII query names");const c=new TextEncoder().encode(`${A}\0`),l=new Uint8Array(c.length+6);return new DataView(l.buffer).setUint32(2,c.length,!0),l.set(c,6),l}),s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,n.length,!0),A9.utils.cfb_add(i,"Rules6/Header",s),A9.utils.cfb_add(i,"Rules6/Data",iZe(r));for(const[a,A]of Object.entries(qer)){const c=e.getRecordsByKind(a);if(!c.some(p=>p.getNumber("UNIONINDEX")!==void 0))continue;const l=A9.find(i,`/${A}/Data`);if(!l)throw new Error(`Missing Altium ${A} stream`);const u=Uint8Array.from(l.content),g=new DataView(u.buffer),h=[];let d=0;for(const p of c){if(d+5>u.length)throw new Error(`Truncated ${A} header`);const m=g.getUint32(d+1,!0),_=d+5+m;if(_>u.length)throw new Error(`Truncated ${A} record`);const f=p.getNumber("UNIONINDEX"),I=u.slice(d+5,_),C=f===void 0?I:Zer(I,a,f),y=new Uint8Array(5+C.length);y[0]=u[d],new DataView(y.buffer).setUint32(1,C.length,!0),y.set(C,5),h.push(y),d=_}if(d!==u.length)throw new Error(`Unexpected trailing ${A} records`);l.content=iZe(h),l.size=l.content.length}return new Uint8Array(A9.write(i,{fileType:"cfb",type:"buffer"}))}function Zer(t,e,n){if(!Number.isInteger(n)||n<=0||n>4294967295)throw new Error("Invalid keepout union index");if(e==="Region"){if(t.length<22)throw new Error("Truncated region properties");const s=new DataView(t.buffer).getUint32(18,!0);if(22+s>t.length)throw new Error("Truncated region property block");const a=new TextDecoder().decode(t.subarray(22,22+s));if(!a.includes("UNIONINDEX=0"))throw new Error("Missing region union field");const A=new TextEncoder().encode(a.replace("UNIONINDEX=0",`UNIONINDEX=${n}`)),c=iZe([t.subarray(0,22),A,t.subarray(22+s)]);return new DataView(c.buffer).setUint32(18,A.length,!0),c}const o=e==="Track"?35:37,i=e==="Track"?36:37;if(t.length!==o)throw new Error(`Unexpected ${e} binary layout`);const r=new Uint8Array(i+9);return r.set(t),new DataView(r.buffer).setUint32(i,n,!0),r}function iZe(t){const e=new Uint8Array(t.reduce((o,i)=>o+i.length,0));let n=0;for(const o of t)e.set(o,n),n+=o.length;return e}class etr extends w1e{_step(){const e=Ker(this.input);this.context.pcb={asciiContent:e,content:Xer(e),filename:`${this.context.safeProjectName}.PcbDoc`},this.finished=!0}getOutput(){if(!this.context.pcb)throw new Error("PCB document stage has not finished");return this.context.pcb}}class ttr extends w1e{_step(){if(!this.context.pcb||!this.context.schematics)throw new Error("PCB and schematic stages must finish before the project");const e=["[Design]",`ProjectName=${this.context.safeProjectName}`,"",...[{path:this.context.pcb.filename,kind:"pcb-document"},...this.context.schematics.map(({filename:n})=>({path:n,kind:"schematic-document"}))].flatMap((n,o)=>[`[Document${o+1}]`,`DocumentPath=${n.path}`,`DocumentKind=${n.kind}`,""])].join(`\r
`);this.context.project={content:e,filename:`${this.context.safeProjectName}.PrjPcb`},this.finished=!0}getOutput(){if(!this.context.project)throw new Error("Project document stage has not finished");return this.context.project}}const rZe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const t in rZe)Object.freeze(rZe[t]);const $ee=Object.freeze(rZe),TIn=Object.create(null);for(const t in $ee)Object.hasOwn($ee,t)&&(TIn[$ee[t]]=t);const a3={to:{},get:{}};a3.get=function(t){const e=t.slice(0,3).toLowerCase();let n,o;switch(e){case"hsl":{n=a3.get.hsl(t),o="hsl";break}case"hwb":{n=a3.get.hwb(t),o="hwb";break}default:{n=a3.get.rgb(t),o="rgb";break}}return n?{model:o,value:n}:null},a3.get.rgb=function(t){if(!t)return null;const e=/^#([a-f\d]{3,4})$/i,n=/^#([a-f\d]{6})([a-f\d]{2})?$/i,o=/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i,i=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i,r=/^(\w+)$/;let s=[0,0,0,1],a,A,c;if(a=t.match(n)){for(c=a[2],a=a[1],A=0;A<3;A++){const l=A*2;s[A]=Number.parseInt(a.slice(l,l+2),16)}c&&(s[3]=Number.parseInt(c,16)/255)}else if(a=t.match(e)){for(a=a[1],c=a[3],A=0;A<3;A++)s[A]=Number.parseInt(a[A]+a[A],16);c&&(s[3]=Number.parseInt(c+c,16)/255)}else if(a=t.match(o)){for(A=0;A<3;A++)s[A]=Number.parseFloat(a[A+1]);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else if(a=t.match(i)){for(A=0;A<3;A++)s[A]=Math.round(Number.parseFloat(a[A+1])*2.55);a[4]&&(s[3]=a[5]?Number.parseFloat(a[4])*.01:Number.parseFloat(a[4]))}else return(a=t.toLowerCase().match(r))?a[1]==="transparent"?[0,0,0,0]:Object.hasOwn($ee,a[1])?(s=$ee[a[1]].slice(),s[3]=1,s):null:null;for(A=0;A<3;A++)s[A]=AM(s[A],0,255);return s[3]=AM(s[3],0,1),s},a3.get.hsl=function(t){if(!t)return null;const e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,n=t.match(e);if(n){const o=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,r=AM(Number.parseFloat(n[2]),0,100),s=AM(Number.parseFloat(n[3]),0,100),a=AM(Number.isNaN(o)?1:o,0,1);return[i,r,s,a]}return null},a3.get.hwb=function(t){if(!t)return null;const e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i,n=t.match(e);if(n){const o=Number.parseFloat(n[4]),i=(Number.parseFloat(n[1])%360+360)%360,r=AM(Number.parseFloat(n[2]),0,100),s=AM(Number.parseFloat(n[3]),0,100),a=AM(Number.isNaN(o)?1:o,0,1);return[i,r,s,a]}return null},a3.to.hex=function(...t){return"#"+D1e(t[0])+D1e(t[1])+D1e(t[2])+(t[3]<1?D1e(Math.round(t[3]*255)):"")},a3.to.rgb=function(...t){return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},a3.to.rgb.percent=function(...t){const e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),o=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+n+"%, "+o+"%)":"rgba("+e+"%, "+n+"%, "+o+"%, "+t[3]+")"},a3.to.hsl=function(...t){return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},a3.to.hwb=function(...t){let e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},a3.to.keyword=function(...t){return TIn[t.slice(0,3)]};function AM(t,e,n){return Math.min(Math.max(e,t),n)}function D1e(t){const e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}function qee({cssColor:t,fallbackAltiumColor:e}){const n=a3.get.rgb(t.trim());if(!n||n.length<3)return e;const[o=0,i=0,r=0]=n.map(Math.round);return o|i<<8|r<<16}const b4=132,kIn=16317695,Xee=16777215;function OS(t,e){const n=Math.round(e*1e5);if(!Number.isSafeInteger(n))throw new RangeError(`Invalid schematic coordinate ${t}: ${e}`);const o=Math.trunc(n/1e5),i=n-o*1e5;return[`${t}=${o}`,...i===0?[]:[`${t}_FRAC=${i<0?"-":""}${String(Math.abs(i)).padStart(5,"0")}`]]}const ntr=16777215,FIn=16711680,otr=16,itr=8,ck=3,rtr="Times New Roman",sZe=11;function str({hasInputArrow:t,hasOutputArrow:e}){return t&&e?3:t?1:e?2:0}function atr({altiumPortPosition:t,facingDirection:e,hasInputArrow:n,hasOutputArrow:o,portName:i}){const r=Math.max([...i].length*itr,otr);return["RECORD=18",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,`WIDTH=${r}`,`IOTYPE=${str({hasInputArrow:n,hasOutputArrow:o})}`,...e==="up"||e==="down"?["STYLE=4"]:[],`NAME=${i}`,`FONTID=${ck}`,`COLOR=${FIn}`,`AREACOLOR=${ntr}`,`TEXTCOLOR=${FIn}`]}const N1e=20,Zee=4,LIn="Arial",R1e=.18,HIn=.15,OIn=.2;function Atr({netLabelTextPresentations:t=[],schematicElements:e,templateFontFields:n=[]}){const o=new Map,i=new Map([[1,Zee],[2,Zee],[ck,sZe]]),r=sZe/N1e;o.set(r,ck);const s=e.some(d=>d.type==="schematic_net_label"),a=[...new Set([...s?[R1e]:[],...e.flatMap(d=>{const p=d.type==="schematic_text"?fr(d.font_size):0;return p>0?[p]:[]})])].sort((d,p)=>d-p),A=[];let c=ck+1;for(const d of a){if(o.has(d))continue;const p=c++;o.set(d,p),i.set(p,d*N1e),A.push(`SIZE${p}=${Sp(d*N1e)}`,`FONTNAME${p}=${LIn}`)}const l=new Map;for(const d of n){const p=c++;l.set(d.sourceFontId,p),A.push(...d.fields.map(m=>m.replace(/^(\w+?)\d+=/u,`$1${p}=`)))}const u=new Map(o),g=new Map([[Zee,1]]);for(const[d,p]of i)d>ck&&Number.isInteger(p)&&g.set(p,d);const h=[...e.flatMap(d=>d.type==="schematic_text"&&(ti(d.schematic_component_id)||ti(d.source_trace_id))?[fr(d.font_size)]:[]),...s?[R1e]:[],...t.map(d=>fr(d.font_size)),...e.flatMap(d=>d.type==="schematic_port"&&ti(d.schematic_component_id)?[OIn,Tu(d.display_pin_label_font_size,HIn)]:[])];for(const d of h){if(d<=0)continue;const p=u.get(d);if(p!==void 0&&Number.isInteger(i.get(p)))continue;const m=Math.max(1,Math.ceil(Number(Sp(d*N1e))));let _=g.get(m);_===void 0&&(_=c++,g.set(m,_),i.set(_,m),A.push(`SIZE${_}=${m}`,`FONTNAME${_}=${LIn}`)),u.set(d,_)}return{nativeTextFontIdBySizeCircuitUnits:u,fontIdBySizeCircuitUnits:o,fontSizePointsById:i,sheetRecordFields:[`FONTIDCOUNT=${c-1}`,`SIZE1=${Zee}`,"FONTNAME1=Arial",`SIZE2=${Zee}`,"FONTNAME2=Arial",`SIZE${ck}=${sZe}`,`FONTNAME${ck}=${rtr}`,...A],templateFontIdBySourceFontId:l}}const ctr=[.278,.333,.408,.556,.556,.889,.778,.191,.333,.333,.5,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.722,.667,.722,.722,.667,.611,.778,.722,.333,.5,.722,.611,.889,.722,.778,.667,.778,.722,.667,.611,.722,.722,.944,.722,.722,.611,.333,.278,.333,.469,.556,.333,.556,.556,.5,.556,.556,.333,.556,.556,.278,.278,.5,.278,.833,.556,.556,.556,.556,.333,.5,.278,.556,.5,.722,.5,.5,.5,.48,.259,.48,.584];function ltr(t,e){return[...t].reduce((n,o)=>n+(ctr[o.codePointAt(0)-32]??1)*e,0)}const utr={bottom:1,bottom_left:0,bottom_center:1,bottom_right:2,left:3,center_left:3,center:4,center_right:5,right:5,top:7,top_left:6,top_center:7,top_right:8};function aZe(t){return utr[t]??0}function AZe(t){const e=(t%360+360)%360;return e===90||e===270?1:0}function cZe({circuitToAltiumSchematicPoint:t,fallbackAltiumColor:e,fallbackAltiumPosition:n,fallbackFontId:o,fallbackJustification:i,fontTable:r,schematicText:s}){const a=AA(s?.position),A=fr(s?.font_size);return{color:qee({cssColor:ti(s?.color),fallbackAltiumColor:e}),fontId:r.fontIdBySizeCircuitUnits.get(A)??o,justification:s?aZe(ti(s.anchor)):i,orientation:AZe(fr(s?.rotation)),position:a?t(a):n}}const GIn=2,gtr=132,dtr=10,YIn={bottom:{x:0,y:1},left:{x:1,y:0},right:{x:-1,y:0},top:{x:0,y:-1}},htr={bottom:{justification:3,orientation:1},left:{justification:3,orientation:0},right:{justification:5,orientation:0},top:{justification:5,orientation:1}},ptr={bottom:1,left:3,right:5,top:7},UIn={right:0,up:1,left:2,down:3},KIn={rail:2,ground:4};function mtr(t){return t in UIn}function _tr(t){return t in KIn}function ftr(t){return t in YIn}function lZe(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXY";let o=Math.max(Math.floor(t),0),i="";for(let r=0;r<4;r++)i=n[o%n.length]+i,o=Math.floor(o/n.length);return`CJN${e}${i}`}function Itr({altiumLabelCenter:t,altiumLabelPosition:e,anchorSide:n,fontSize:o,textFontSize:i,labelText:r}){if(!ftr(n))return;const s=YIn[n],a={x:t.x-e.x,y:t.y-e.y},A=a.x*s.x+a.y*s.y,c=o*.3,l=o*.5,u=o*.2,g=ltr(r,i),h=Math.max(A*2,l+g+u,dtr),d={x:-s.y,y:s.x},p=(f,I=0)=>({x:e.x+s.x*f+d.x*I,y:e.y+s.y*f+d.y*I}),m=o*(.2/.18)/2,_=htr[n];return{orientation:_.orientation,outlinePoints:[p(0),p(c,m),p(h,m),p(h,-m),p(c,-m)],textJustification:_.justification,textPosition:p(l)}}function VIn(t){const e=t.lastIndexOf("_");if(e<1)return;const n=t.slice(0,e),o=t.slice(e+1);if(!(!_tr(n)||!mtr(o)))return{orientationIndex:UIn[o],styleIndex:KIn[n]}}function Ctr({anchorSide:t,altiumLabelCenter:e,altiumLabelPosition:n,decorationIndex:o,fontTable:i,labelText:r,symbolName:s,textPresentation:a}){const A=VIn(s),c=i.fontIdBySizeCircuitUnits.get(fr(a?.font_size))??(A?GIn:i.fontIdBySizeCircuitUnits.get(R1e)??GIn),l=A?c:i.nativeTextFontIdBySizeCircuitUnits.get(fr(a?.font_size))??i.nativeTextFontIdBySizeCircuitUnits.get(R1e)??c,u=qee({cssColor:ti(a?.color),fallbackAltiumColor:A?gtr:b4});if(A)return[["RECORD=17",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`FONTID=${l}`,`ORIENTATION=${A.orientationIndex}`,`STYLE=${A.styleIndex}`,`COLOR=${u}`,"SHOWNETNAME=T",`TEXT=${r}`]];const g=["RECORD=25",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`FONTID=${l}`,`ORIENTATION=${AZe(fr(a?.rotation))}`,`JUSTIFICATION=${a?aZe(ti(a.anchor)):ptr[t]??0}`,`COLOR=${u}`,`TEXT=${r}`];if(a&&r3(e,n))return[g];const h=Itr({altiumLabelCenter:e,altiumLabelPosition:n,anchorSide:t,fontSize:i.fontSizePointsById.get(c)??4,textFontSize:i.fontSizePointsById.get(l)??4,labelText:r});return h?[["RECORD=27","LINEWIDTH=0","LOCATIONCOUNT=2",...OS("X1",n.x),...OS("Y1",n.y),...OS("X2",h.textPosition.x),...OS("Y2",h.textPosition.y),"COLOR=34816",`UNIQUEID=${lZe(o,"W")}`],["RECORD=7","OWNERPARTID=-1","LINEWIDTH=0",`LOCATIONCOUNT=${h.outlinePoints.length}`,...h.outlinePoints.flatMap((d,p)=>[...OS(`X${p+1}`,d.x),...OS(`Y${p+1}`,d.y)]),`COLOR=${u}`,`AREACOLOR=${kIn}`,"ISSOLID=T",`UNIQUEID=${lZe(o,"P")}`],["RECORD=25",...OS("LOCATION.X",h.textPosition.x),...OS("LOCATION.Y",h.textPosition.y),`FONTID=${l}`,`ORIENTATION=${h.orientation}`,`JUSTIFICATION=${h.textJustification}`,`COLOR=${u}`,`TEXT=${r}`,`UNIQUEID=${lZe(o,"T")}`]]:[g]}const ytr=255;function zIn({altiumNoConnectPosition:t}){return["RECORD=22",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,"ISACTIVE=T","SYMBOL=Thin Cross","ORIENTATION=1","OWNERPARTID=-1",`COLOR=${ytr}`,"SUPPRESSALL=T"]}const xtr=new Set(["schematic_line","schematic_path","schematic_rect","schematic_text"]);function T1e(t){return xtr.has(t.type??"")&&!ti(t.schematic_component_id)&&!ti(t.schematic_symbol_id)}const Etr=20,k1e=3615007,JIn=16777215;function uZe(t){return Sp(Math.max(fr(t.stroke_width),0)*Etr)}function dK({annotation:t,colorFieldName:e,fallbackAltiumColor:n}){return qee({cssColor:ti(t[e]),fallbackAltiumColor:n})}function Btr({annotation:t,circuitToAltiumSchematicPoint:e,fontTable:n}){const o=j1n(ti(t.text)),i=AA(t.position),r=fr(t.font_size),s=n.fontIdBySizeCircuitUnits.get(r);if(!o||!i||!s)return;const a=e(i);return["RECORD=4",`LOCATION.X=${a.x}`,`LOCATION.Y=${a.y}`,`FONTID=${s}`,`TEXT=${o}`,`COLOR=${dK({annotation:t,colorFieldName:"color",fallbackAltiumColor:k1e})}`,`ORIENTATION=${AZe(fr(t.rotation))}`,`JUSTIFICATION=${aZe(ti(t.anchor))}`]}function btr({annotation:t,circuitToAltiumSchematicPoint:e}){const n=AA(t.center),o=fr(t.width),i=fr(t.height);if(!n||o<=0||i<=0)return;const r=e({x:n.x-o/2,y:n.y-i/2}),s=e({x:n.x+o/2,y:n.y+i/2}),a=dK({annotation:t,colorFieldName:"color",fallbackAltiumColor:k1e}),A=t.is_filled===!0;return["RECORD=14",`LOCATION.X=${r.x}`,`LOCATION.Y=${r.y}`,`CORNER.X=${s.x}`,`CORNER.Y=${s.y}`,`LINEWIDTH=${uZe(t)}`,`COLOR=${a}`,`AREACOLOR=${dK({annotation:t,colorFieldName:"fill_color",fallbackAltiumColor:A?a:JIn})}`,`ISSOLID=${A?"T":"F"}`]}function Str({annotation:t,circuitToAltiumSchematicPoint:e}){const n=e({x:fr(t.x1),y:fr(t.y1)}),o=e({x:fr(t.x2),y:fr(t.y2)});return["RECORD=13",`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`CORNER.X=${o.x}`,`CORNER.Y=${o.y}`,`LINEWIDTH=${uZe(t)}`,`LINESTYLE=${t.is_dashed===!0?1:0}`,`COLOR=${dK({annotation:t,colorFieldName:"color",fallbackAltiumColor:k1e})}`]}function Qtr({annotation:t,circuitToAltiumSchematicPoint:e}){if(!Array.isArray(t.points))return;const n=t.points.flatMap(r=>{const s=AA(r);return s?[s]:[]});if(n.length<2)return;const o=n.map(e),i=t.is_filled===!0;return[`RECORD=${i?7:6}`,`LINEWIDTH=${uZe(t)}`,`LOCATIONCOUNT=${o.length}`,...o.flatMap((r,s)=>[`X${s+1}=${r.x}`,`Y${s+1}=${r.y}`]),`COLOR=${dK({annotation:t,colorFieldName:"stroke_color",fallbackAltiumColor:k1e})}`,...i?[`AREACOLOR=${dK({annotation:t,colorFieldName:"fill_color",fallbackAltiumColor:JIn})}`,"ISSOLID=T"]:[]]}function WIn(t){if(T1e(t.annotation)){if(t.annotation.type==="schematic_text")return Btr(t);if(t.annotation.type==="schematic_line")return Str(t);if(t.annotation.type==="schematic_rect")return btr(t);if(t.annotation.type==="schematic_path")return Qtr(t)}}const vtr=10,wtr=10,Ptr=60,Mtr=160,gZe=132,jIn=12779519;function Dtr({childSheets:t,circuitJson:e}){const n=new Map(e.filter(o=>o.type==="source_port").map(o=>[ti(o.source_port_id),o]));return t.map(o=>{const i=e.find(c=>c.type==="schematic_component"&&c.is_schematic_group===!0&&!ti(c.schematic_sheet_id)&&o.subcircuitId!==void 0&&ti(c.subcircuit_id)===o.subcircuitId),r=e.filter(c=>c.type==="schematic_port"&&ti(c.schematic_sheet_id)===o.schematicSheetId&&!ti(c.schematic_component_id)),s={0:0,1:0},a=r.flatMap(c=>{const l=n.get(ti(c.source_port_id)),u=ti(c.display_pin_label)||ti(l?.name);if(!u)return[];const g=c.has_input_arrow===!0,h=c.has_output_arrow===!0,d=Ftr(c);return s[d]++,[{distanceFromTop:i?ktr({placementComponent:i,schematicPort:c}):s[d],doNotConnect:l?.do_not_connect===!0,ioType:g?h?3:1:h?2:0,name:u,side:d}]}),A=Math.max(o.name.length,o.filename.length,...a.map(c=>c.name.length*2));return{childSheet:o,entries:a,height:Math.max(Ptr,Math.max(s[0],s[1])*vtr+20),placementComponent:i,width:Math.max(Mtr,A*6+20)}})}function Ntr({location:t,plan:e}){return e.entries.flatMap(n=>n.doNotConnect?[zIn({altiumNoConnectPosition:{x:t.x+(n.side===1?e.width:0),y:t.y-n.distanceFromTop*wtr}})]:[])}function Rtr({altiumSymbolRecordIndex:t,location:e,plan:n}){const{childSheet:o,entries:i}=n;return[["RECORD=32",`OWNERINDEX=${t}`,"OWNERPARTID=-1",`LOCATION.X=${e.x}`,`LOCATION.Y=${e.y+10}`,"COLOR=8388608","FONTID=1",`TEXT=${uu(o.name)}`],["RECORD=33",`OWNERINDEX=${t}`,"OWNERPARTID=-1",`LOCATION.X=${e.x}`,`LOCATION.Y=${e.y}`,"COLOR=8388608","FONTID=1",`TEXT=${uu(o.filename)}`],...i.map(r=>["RECORD=16",`OWNERINDEX=${t}`,"OWNERPARTID=-1",...r.side===1?["SIDE=1"]:[],`DISTANCEFROMTOP=${r.distanceFromTop}`,`COLOR=${gZe}`,`AREACOLOR=${jIn}`,`TEXTCOLOR=${gZe}`,"TEXTFONTID=1","TEXTSTYLE=Full",`NAME=${uu(r.name)}`,`IOTYPE=${r.ioType}`,"ARROWKIND=Block & Triangle"])]}function Ttr({location:t,plan:e}){return["RECORD=15","OWNERPARTID=-1",`LOCATION.X=${t.x}`,`LOCATION.Y=${t.y}`,`XSIZE=${e.width}`,`YSIZE=${e.height}`,`COLOR=${gZe}`,`AREACOLOR=${jIn}`,"ISSOLID=T",`UNIQUEID=${uu(e.childSheet.schematicSheetId)}`,"SYMBOLTYPE=Normal"]}function ktr({placementComponent:t,schematicPort:e}){const n=AA(t.center),o=AA(e.center),i=HE(t.size)?t.size:void 0;if(!n||!o||!i)return 0;const r=n.y+fr(i.height)/2;return Math.max(Math.round((r-o.y)*2),0)}function Ftr(t){const e=ti(t.facing_direction);return e==="right"?1:e==="left"?0:t.has_output_arrow===!0&&t.has_input_arrow!==!0?1:0}function Ltr({graphicPrimitive:t,symbolMapping:e}){return t.type==="path"?Htr({pathPrimitive:t,symbolMapping:e}):t.type==="circle"?Otr({circlePrimitive:t,symbolMapping:e}):Gtr({boxPrimitive:t,symbolMapping:e})}function Htr({pathPrimitive:t,symbolMapping:e}){const n=t.points.map(r=>Utr({symbolMapping:e,symbolPoint:r})),o=n[0],i=n.at(-1);return t.closed&&o&&i&&!r3(o,i)&&n.push(o),[`RECORD=${t.fill?7:6}`,...ete(e.altiumComponentRecordIndex),"LINEWIDTH=1",`LOCATIONCOUNT=${n.length}`,...n.flatMap((r,s)=>[...qIn(`X${s+1}`,r.x),...qIn(`Y${s+1}`,r.y)]),`COLOR=${b4}`,...t.fill?[`AREACOLOR=${b4}`,"ISSOLID=T"]:[]]}const $In=5,dZe=10**$In;function qIn(t,e){const n=Math.round(e*dZe)/dZe,o=Math.trunc(n),i=Math.round(Math.abs(n-o)*dZe);return[`${t}=${o}`,...i>0?[`${t}_FRAC=${String(i).padStart($In,"0")}`]:[]]}function Otr({circlePrimitive:t,symbolMapping:e}){const n=lk({symbolMapping:e,symbolPoint:{x:t.x,y:t.y}}),o=lk({symbolMapping:e,symbolPoint:{x:t.x+t.radius,y:t.y}}),i=Math.max(1,Math.abs(o.x-n.x));return["RECORD=8",...ete(e.altiumComponentRecordIndex),`LOCATION.X=${n.x}`,`LOCATION.Y=${n.y}`,`RADIUS=${i}`,`SECONDARYRADIUS=${i}`,"LINEWIDTH=1",`COLOR=${b4}`,`AREACOLOR=${t.fill?b4:Xee}`,`ISSOLID=${t.fill?"T":"F"}`]}function Gtr({boxPrimitive:t,symbolMapping:e}){const n=Ytr(t),o=lk({symbolMapping:e,symbolPoint:{x:n.x-t.width/2,y:n.y-t.height/2}}),i=lk({symbolMapping:e,symbolPoint:{x:n.x+t.width/2,y:n.y+t.height/2}});return["RECORD=14",...ete(e.altiumComponentRecordIndex),`LOCATION.X=${o.x}`,`LOCATION.Y=${o.y}`,`CORNER.X=${i.x}`,`CORNER.Y=${i.y}`,"LINEWIDTH=1",`COLOR=${b4}`,`AREACOLOR=${Xee}`,"ISSOLID=F"]}function Ytr(t){const e=t.anchor.endsWith("_left")?t.width/2:t.anchor.endsWith("_right")?-t.width/2:0,n=t.anchor.startsWith("top_")?-t.height/2:t.anchor.startsWith("bottom_")?t.height/2:0;return{x:t.x+e,y:t.y+n}}function lk({symbolMapping:t,symbolPoint:e}){const n=Bn(t.symbolToCircuitMatrix,e);return t.circuitToAltiumSchematicPoint(n)}function Utr({symbolMapping:t,symbolPoint:e}){const n=Bn(t.symbolToCircuitMatrix,e);return t.circuitToAltiumSchematicPrecisePoint(n)}function ete(t){return[`OWNERINDEX=${t}`,"OWNERPARTID=1","OWNERPARTDISPLAYMODE=0"]}const Ktr=3615007;function XIn({altiumComponentRecordIndex:t,circuitToAltiumSchematicPoint:e,fontTable:n,schematicText:o}){const i=uu(ti(o.text));if(!i)return;const r=cZe({circuitToAltiumSchematicPoint:e,fallbackAltiumColor:Ktr,fallbackAltiumPosition:{x:0,y:0},fallbackFontId:2,fallbackJustification:0,fontTable:n,schematicText:o});return["RECORD=4",`OWNERINDEX=${t}`,"OWNERPARTID=1",`LOCATION.X=${r.position.x}`,`LOCATION.Y=${r.position.y}`,`FONTID=${r.fontId}`,`TEXT=${i}`,`COLOR=${r.color}`,`ORIENTATION=${r.orientation}`,`JUSTIFICATION=${r.justification}`]}const Vtr=new Set(["schematic_arc","schematic_circle","schematic_line","schematic_path","schematic_rect"]);function F1e(t){return Vtr.has(t.type??"")||t.type==="schematic_text"&&typeof t.schematic_symbol_id=="string"&&t.schematic_symbol_id.length>0}function ztr({circuitToAltiumSchematicLength:t,graphic:e}){return Sp(Math.max(1,t(Math.max(fr(e.stroke_width),0))))}function cM({colorFieldName:t,fallbackAltiumColor:e,graphic:n}){return qee({cssColor:ti(n[t]),fallbackAltiumColor:e})}function tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:n}){return[...ete(t),`LINEWIDTH=${ztr({circuitToAltiumSchematicLength:e,graphic:n})}`,`LINESTYLE=${n.is_dashed===!0?1:0}`]}function L1e({circuitToAltiumSchematicLength:t,radius:e}){return Math.max(1,t(e))}function Jtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){if(!Array.isArray(o.points))return;const i=o.points.flatMap(a=>{const A=AA(a);return A?[A]:[]});if(i.length<2)return;const r=i.map(n),s=o.is_filled===!0;return[`RECORD=${s?7:6}`,...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATIONCOUNT=${r.length}`,...r.flatMap((a,A)=>[`X${A+1}=${a.x}`,`Y${A+1}=${a.y}`]),`COLOR=${cM({graphic:o,colorFieldName:"stroke_color",fallbackAltiumColor:b4})}`,...s?[`AREACOLOR=${cM({graphic:o,colorFieldName:"fill_color",fallbackAltiumColor:Xee})}`,"ISSOLID=T"]:[]]}function Wtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.radius);if(!i||r<=0)return;const s=n(i),a=o.is_filled===!0;return["RECORD=8",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${s.x}`,`LOCATION.Y=${s.y}`,`RADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,`SECONDARYRADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,`COLOR=${cM({graphic:o,colorFieldName:"color",fallbackAltiumColor:b4})}`,`AREACOLOR=${cM({graphic:o,colorFieldName:"fill_color",fallbackAltiumColor:Xee})}`,`ISSOLID=${a?"T":"F"}`]}function jtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.radius);if(!i||r<=0)return;const s=n(i),a=fr(o.start_angle_degrees),A=fr(o.end_angle_degrees),c=ti(o.direction)==="clockwise",l=fr(o.altium_secondary_radius),u=l>0;return[`RECORD=${u?11:12}`,...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${s.x}`,`LOCATION.Y=${s.y}`,`RADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:r}))}`,...u?[`SECONDARYRADIUS=${Sp(L1e({circuitToAltiumSchematicLength:e,radius:l}))}`]:[],`STARTANGLE=${Sp(c?A:a)}`,`ENDANGLE=${Sp(c?a:A)}`,`COLOR=${cM({graphic:o,colorFieldName:"color",fallbackAltiumColor:b4})}`]}function $tr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=n({x:fr(o.x1),y:fr(o.y1)}),r=n({x:fr(o.x2),y:fr(o.y2)});return["RECORD=13",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${i.x}`,`LOCATION.Y=${i.y}`,`CORNER.X=${r.x}`,`CORNER.Y=${r.y}`,`COLOR=${cM({graphic:o,colorFieldName:"color",fallbackAltiumColor:b4})}`]}function qtr({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,circuitToAltiumSchematicPoint:n,graphic:o}){const i=AA(o.center),r=fr(o.width),s=fr(o.height),a=(fr(o.rotation)%360+360)%360;if(!i||r<=0||s<=0||a!==0)return;const A=n({x:i.x-r/2,y:i.y-s/2}),c=n({x:i.x+r/2,y:i.y+s/2}),l=o.is_filled===!0,u=cM({graphic:o,colorFieldName:"color",fallbackAltiumColor:b4});return["RECORD=14",...tte({altiumComponentRecordIndex:t,circuitToAltiumSchematicLength:e,graphic:o}),`LOCATION.X=${A.x}`,`LOCATION.Y=${A.y}`,`CORNER.X=${c.x}`,`CORNER.Y=${c.y}`,`COLOR=${u}`,`AREACOLOR=${cM({graphic:o,colorFieldName:"fill_color",fallbackAltiumColor:l?u:Xee})}`,`ISSOLID=${l?"T":"F"}`]}function Xtr(t){if(F1e(t.graphic)){if(t.graphic.type==="schematic_text")return XIn({altiumComponentRecordIndex:t.altiumComponentRecordIndex,circuitToAltiumSchematicPoint:t.circuitToAltiumSchematicPoint,fontTable:t.fontTable,schematicText:t.graphic});if(t.graphic.type==="schematic_path")return Jtr(t);if(t.graphic.type==="schematic_circle")return Wtr(t);if(t.graphic.type==="schematic_arc")return jtr(t);if(t.graphic.type==="schematic_line")return $tr(t);if(t.graphic.type==="schematic_rect")return qtr(t)}}function GE(t,e){return Array.isArray(e)?[t.a*e[0]+t.c*e[1]+t.e,t.b*e[0]+t.d*e[1]+t.f]:{x:t.a*e.x+t.c*e.y+t.e,y:t.b*e.x+t.d*e.y+t.f}}function ZIn(t){return typeof t>"u"}function eCn(t,e=0){return{a:1,c:0,e:t,b:0,d:1,f:e}}function H1e(...t){t=Array.isArray(t[0])?t[0]:t;let e=(n,o)=>({a:n.a*o.a+n.c*o.b,c:n.a*o.c+n.c*o.d,e:n.a*o.e+n.c*o.f+n.e,b:n.b*o.a+n.d*o.b,d:n.b*o.c+n.d*o.d,f:n.b*o.e+n.d*o.f+n.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return e(t[0],t[1]);default:{let[n,o,...i]=t,r=e(n,o);return H1e(r,...i)}}}var{cos:Ztr,sin:enr}=Math;function tnr(t,e,n){let o=Ztr(t),i=enr(t),r={a:o,c:-i,e:0,b:i,d:o,f:0};return ZIn(e)||ZIn(n)?r:H1e([eCn(e,n),r,eCn(-e,-n)])}function nnr(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function O1e(t,e,n,o){var i=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(i,O1e.prototype),i.expected=e,i.found=n,i.location=o,i.name="SyntaxError",i}nnr(O1e,Error);function hZe(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}O1e.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,o;for(o=0;o<t.length;o++)if(t[o].source===this.location.source){n=t[o].text.split(/\r\n|\n|\r/g);break}var i=this.location.start,r=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(i):i,s=this.location.source+":"+r.line+":"+r.column;if(n){var a=this.location.end,A=hZe("",r.line.toString().length," "),c=n[i.line-1],l=i.line===a.line?a.column:c.length+1,u=l-i.column||1;e+=`
 --> `+s+`
`+A+` |
`+r.line+" | "+c+`
`+A+" | "+hZe("",i.column-1," ")+hZe("",u,"^")}else e+=`
 at `+s}return e},O1e.buildMessage=function(t,e){var n={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var l=c.parts.map(function(u){return Array.isArray(u)?r(u[0])+"-"+r(u[1]):r(u)});return"["+(c.inverted?"^":"")+l.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function o(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(l){return"\\x0"+o(l)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(l){return"\\x"+o(l)})}function r(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(l){return"\\x0"+o(l)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(l){return"\\x"+o(l)})}function s(c){return n[c.type](c)}function a(c){var l=c.map(s),u,g;if(l.sort(),l.length>0){for(u=1,g=1;u<l.length;u++)l[u-1]!==l[u]&&(l[g]=l[u],g++);l.length=g}switch(l.length){case 1:return l[0];case 2:return l[0]+" or "+l[1];default:return l.slice(0,-1).join(", ")+", or "+l[l.length-1]}}function A(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(t)+" but "+A(e)+" found."};function GS(t){if(t.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let e=1/0,n=-1/0,o=1/0,i=-1/0,r=s=>{e=Math.min(e,s.x),n=Math.max(n,s.x),o=Math.min(o,s.y),i=Math.max(i,s.y)};return t.forEach(s=>{switch(s.type){case"path":s.points.forEach(r);break;case"text":r({x:s.x,y:s.y});break;case"circle":{let{x:a,y:A,radius:c}=s;r({x:a-c,y:A-c}),r({x:a+c,y:A+c});break}case"box":{let{x:a,y:A,width:c,height:l}=s,u=c/2,g=l/2;r({x:a-u,y:A-g}),r({x:a+u,y:A+g});break}}}),{minX:e,maxX:n,minY:o,maxY:i}}var onr=(t,e="right")=>{switch(e){case"down":switch(t){case"middle_top":return"middle_right";case"middle_bottom":return"middle_left";case"middle_left":return"middle_bottom";case"middle_right":return"middle_top"}break;case"up":switch(t){case"middle_top":return"middle_left";case"middle_bottom":return"middle_right";case"middle_left":return"middle_top";case"middle_right":return"middle_bottom"}break;case"left":switch(t){case"middle_top":return"middle_bottom";case"middle_bottom":return"middle_top";case"middle_left":return"middle_right";case"middle_right":return"middle_left"}break;case"right":return t}return t},hK=(t,e)=>{let{primitives:n,center:o,ports:i,size:r}=t,s=H1e({a:1,b:0,c:0,d:-1,e:0,f:2*o.y}),a=n.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(h=>GE(s,h))};case"text":let l=GE(s,{x:c.x,y:c.y}),u={top_left:"bottom_left",top_right:"bottom_right",bottom_left:"top_left",bottom_right:"top_right",center:"center",middle_top:"middle_bottom",middle_bottom:"middle_top",middle_left:"middle_left",middle_right:"middle_right"};return{...c,x:l.x,y:l.y,anchor:u[c.anchor]};case"circle":case"box":let g=GE(s,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),A=i.map(c=>({...c,...GE(s,c)}));return{primitives:a,center:o,ports:A,size:r,...e}},pK=(t,e)=>{let{primitives:n,center:o,ports:i,size:r}=t,s=H1e({a:-1,b:0,c:0,d:1,e:0,f:2*o.x}),a=n.map(c=>{switch(c={...c},c.type){case"path":return{...c,points:c.points.map(h=>GE(s,h))};case"text":let l=GE(s,{x:c.x,y:c.y}),u={top_left:"top_right",top_right:"top_left",bottom_left:"bottom_right",bottom_right:"bottom_left",center:"center",middle_top:"middle_top",middle_bottom:"middle_bottom",middle_left:"middle_right",middle_right:"middle_left"};return{...c,x:l.x,y:l.y,anchor:u[c.anchor]};case"circle":case"box":let g=GE(s,{x:c.x,y:c.y});return{...c,x:g.x,y:g.y}}}),A=i.map(c=>({...c,...GE(s,c)}));return{primitives:a,center:o,ports:A,size:r,...e}},nte=(t,e)=>{let{newOrientation:n,overrides:o}=e,i={up:Math.PI/2,right:0,down:-Math.PI/2,left:-Math.PI},r=tnr(n?i[n]:Math.PI/2,t.center.x,t.center.y),{primitives:s,center:a,size:A,ports:c}=t,l=s.map(h=>{switch(h={...h},h.type){case"path":return{...h,points:h.points.map(_=>GE(r,_))};case"text":let d=GE(r,{x:h.x,y:h.y});return h.anchor=onr(h.anchor,n??"right"),{...h,x:d.x,y:d.y};case"circle":let p=GE(r,{x:h.x,y:h.y});return{...h,x:p.x,y:p.y};case"box":let m=GE(r,{x:h.x,y:h.y});return{...h,x:m.x,y:m.y,width:h.height,height:h.width}}}),u=c.map(h=>({...h,...GE(r,h)})),g=GS(l);return{primitives:l,center:a,ports:u,size:{width:g.maxX-g.minX,height:g.maxY-g.minY},...o}},si=(t,e="down",n={})=>nte(t,{newOrientation:e,overrides:n}),inr=class{symbol;constructor(t){this.symbol=JSON.parse(JSON.stringify(t)),this.symbol.size=this.computeSize()}changeTextAnchor(t,e,n){return this.symbol={...this.symbol,primitives:this.symbol.primitives.map(o=>o.type==="text"&&o.text===t?{...o,anchor:e,...n?{x:o.x+n.x,y:o.y+n.y}:{}}:o)},this}labelPort(t,e){return this.symbol={...this.symbol,ports:this.symbol.ports.map(n=>n.labels.includes(t)?{...n,labels:e}:n)},this}rotateRightFacingSymbol(t){return this.symbol=nte(this.symbol,{newOrientation:t}),this}computeSize(){let t=GS(this.symbol.primitives);return{width:t.maxX-t.minX,height:t.maxY-t.minY}}build(){return{...this.symbol,size:this.computeSize()}}},Ln=t=>{let e=t.primitives??[...Object.values(t.paths??{}),...Object.values(t.texts??{}),...Object.values(t.circles??{}),...Object.values(t.rects??{})],n=t.ports??Object.entries(t.refblocks).flatMap(([i,r])=>[{...r,labels:[i]}]),o=t.center??{x:t.bounds.centerX,y:t.bounds.centerY};return n.length===2&&(o={x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2}),new inr({...t,primitives:e,ports:n,center:o})},mK={paths:{path11:{type:"path",points:[{x:-.54,y:.03},{x:-.3,y:.04}],color:"primary",fill:!1},path12:{type:"path",points:[{x:.29,y:.04},{x:.54,y:.04}],color:"primary",fill:!1},"path11-5-5":{type:"path",points:[{x:.1,y:.13},{x:0,y:-.06},{x:-.11,y:.13}],color:"primary",fill:!1},path17:{type:"path",points:[{x:0,y:-.13},{x:.07,y:-.11}],color:"primary",fill:!1},path18:{type:"path",points:[{x:.07,y:-.11},{x:.14,y:-.13}],color:"primary",fill:!1},path19:{type:"path",points:[{x:-.15,y:-.13},{x:-.07,y:-.11}],color:"primary",fill:!1},path20:{type:"path",points:[{x:-.07,y:-.11},{x:0,y:-.13}],color:"primary",fill:!1}},refblocks:{left1:{x:-.54,y:.03},right1:{x:.54,y:.04}},bounds:{width:1.14,height:.79,centerX:0,centerY:0},circles:{path1:{type:"circle",x:0,y:.04,radius:.29,color:"primary",fill:!1}}},{paths:rnr,bounds:G1e,refblocks:tCn,circles:snr}=mK,anr=Ln({primitives:[...Object.values(rnr),...Object.values(snr),{type:"text",text:"{REF}",x:-.15,y:.3894553499999995},{type:"text",text:"{VAL}",x:.15,y:.3894553499999995}],ports:[{...tCn.left1,labels:["1"]},{...tCn.right1,labels:["2"]}],size:{width:G1e.width,height:G1e.height},center:{x:G1e.centerX,y:G1e.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Anr,bounds:Y1e,refblocks:nCn,circles:cnr}=mK,lnr=Ln({primitives:[...Object.values(Anr),...Object.values(cnr),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...nCn.left1,labels:["1"]},{...nCn.right1,labels:["2"]}],size:{width:Y1e.width,height:Y1e.height},center:{x:Y1e.centerX,y:Y1e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:unr,bounds:U1e,refblocks:oCn,circles:gnr}=mK,dnr=Ln({primitives:[...Object.values(unr),...Object.values(gnr),{type:"text",text:"{REF}",x:-0,y:-.3094553499999995},{type:"text",text:"{VAL}",x:0,y:.4094553499999995}],ports:[{...oCn.left1,labels:["1"]},{...oCn.right1,labels:["2"]}],size:{width:U1e.width,height:U1e.height},center:{x:U1e.centerX,y:U1e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:hnr,bounds:K1e,refblocks:iCn,circles:pnr}=mK,mnr=Ln({primitives:[...Object.values(hnr),...Object.values(pnr),{type:"text",text:"{REF}",x:-0,y:.4094553499999995},{type:"text",text:"{VAL}",x:0,y:-.4094553499999995}],ports:[{...iCn.left1,labels:["1"]},{...iCn.right1,labels:["2"]}],size:{width:K1e.width,height:K1e.height},center:{x:K1e.centerX,y:K1e.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:_nr,bounds:V1e,refblocks:rCn,circles:fnr}=mK,Inr=Ln({primitives:[...Object.values(_nr),...Object.values(fnr),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...rCn.left1,labels:["1"]},{...rCn.right1,labels:["2"]}],size:{width:V1e.width,height:V1e.height},center:{x:V1e.centerX,y:V1e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Cnr,bounds:z1e,refblocks:sCn,circles:ynr}=mK,xnr=Ln({primitives:[...Object.values(Cnr),...Object.values(ynr),{type:"text",text:"{REF}",x:.15,y:-.2894553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2894553499999995}],ports:[{...sCn.left1,labels:["1"]},{...sCn.right1,labels:["2"]}],size:{width:z1e.width,height:z1e.height},center:{x:z1e.centerX,y:z1e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),_K={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.12,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.14,y:.18},{x:.08,y:.2}],color:"primary",fill:!1},"path43-8-3":{type:"path",points:[{x:.21,y:-.11},{x:.15,y:-.09}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.01,y:.27},bottom1:{type:"text",text:"{VAL}",x:0,y:-.27}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{minX:-.55,maxX:.55,minY:-.27,maxY:.27,width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Enr,texts:Vmr,bounds:J1e,refblocks:aCn,circles:Bnr}=_K,bnr=Ln({primitives:[...Object.values(Enr),...Object.values(Bnr),{type:"text",text:"{REF}",x:-.15,y:.3294553499999995},{type:"text",text:"{VAL}",x:.15,y:.3294553499999995}],ports:[{...aCn.left1,labels:["1"]},{...aCn.right1,labels:["2"]}],size:{width:J1e.width,height:J1e.height},center:{x:J1e.centerX,y:J1e.centerY}}).rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),Snr=Ln(_K).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Qnr,texts:zmr,bounds:W1e,refblocks:ACn,circles:vnr}=_K,wnr=Ln({primitives:[...Object.values(Qnr),...Object.values(vnr),{type:"text",text:"{REF}",x:-0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.3294553499999995}],ports:[{...ACn.left1,labels:["1"]},{...ACn.right1,labels:["2"]}],size:{width:W1e.width,height:W1e.height},center:{x:W1e.centerX,y:W1e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Pnr=Ln(_K).changeTextAnchor("{VAL}","middle_top").labelPort("left1",["1","neg"]).labelPort("right1",["2","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Mnr,texts:Jmr,bounds:j1e,refblocks:cCn,circles:Dnr}=_K,Nnr=Ln({primitives:[...Object.values(Mnr),...Object.values(Dnr),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...cCn.left1,labels:["1"]},{...cCn.right1,labels:["2"]}],size:{width:j1e.width,height:j1e.height},center:{x:j1e.centerX,y:j1e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Rnr,texts:Wmr,bounds:$1e,refblocks:lCn,circles:Tnr}=_K,knr=Ln({primitives:[...Object.values(Rnr),...Object.values(Tnr),{type:"text",text:"{REF}",x:.15,y:-.2294553499999995},{type:"text",text:"{VAL}",x:-.15,y:-.2294553499999995}],ports:[{...lCn.left1,labels:["1"]},{...lCn.right1,labels:["2"]}],size:{width:$1e.width,height:$1e.height},center:{x:$1e.centerX,y:$1e.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),pZe={paths:{path40:{type:"path",points:[{x:.14,y:.04},{x:-.12,y:-.09}],color:"primary",fill:!1},path41:{type:"path",points:[{x:-.12,y:.18},{x:.14,y:.04}],color:"primary",fill:!1},path42:{type:"path",points:[{x:-.12,y:-.09},{x:-.12,y:.18}],color:"primary",fill:!1},path43:{type:"path",points:[{x:.14,y:.18},{x:.14,y:-.09}],color:"primary",fill:!1},path44:{type:"path",points:[{x:.14,y:.04},{x:-.52,y:.04}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.52,y:.04},{x:.15,y:.04}],color:"primary",fill:!1},"path43-8":{type:"path",points:[{x:.18,y:.18},{x:.11,y:.18}],color:"primary",fill:!1},"path43-8-8":{type:"path",points:[{x:.18,y:-.09},{x:.11,y:-.09}],color:"primary",fill:!1}},refblocks:{left1:{x:-.52,y:.04},right1:{x:.52,y:.04}},bounds:{width:1.09,height:.55,centerX:0,centerY:0},circles:{}},{paths:Fnr,bounds:q1e,refblocks:uCn,circles:Lnr}=pZe,Hnr=Ln({primitives:[...Object.values(Fnr),...Object.values(Lnr),{type:"text",text:"{REF}",x:-.16,y:.2294553499999995},{type:"text",text:"{VAL}",x:.16,y:.2294553499999995}],ports:[{...uCn.left1,labels:["1"]},{...uCn.right1,labels:["2"]}],size:{width:q1e.width,height:q1e.height},center:{x:q1e.centerX,y:q1e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Onr,bounds:X1e,refblocks:gCn,circles:Gnr}=pZe,dCn=Ln({primitives:[...Object.values(Onr),...Object.values(Gnr),{type:"text",text:"{REF}",x:-1118e-7,y:-.18},{type:"text",text:"{VAL}",x:1118e-7,y:.2738453}],ports:[{...gCn.left1,labels:["1"]},{...gCn.right1,labels:["2"]}],size:{width:X1e.width,height:X1e.height},center:{x:X1e.centerX,y:X1e.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["2"]).labelPort("right1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),{paths:Ynr,bounds:Z1e,refblocks:hCn,circles:Unr}=pZe,Knr=Ln({primitives:[...Object.values(Ynr),...Object.values(Unr),{type:"text",text:"{REF}",x:-.0050250999999996715,y:.27384529999999985,anchor:"middle_left"},{type:"text",text:"{VAL}",x:-.00011179999999999524,y:-.27384530000000007,anchor:"middle_left"}],ports:[{...hCn.left1,labels:["1"]},{...hCn.right1,labels:["2"]}],size:{width:Z1e.width,height:Z1e.height},center:{x:Z1e.centerX,y:Z1e.centerY}}).changeTextAnchor("{VAL}","middle_top").labelPort("right1",["2"]).labelPort("left1",["1"]).changeTextAnchor("{REF}","middle_bottom").build(),mZe=si(dCn,"down"),_Ze=mZe.primitives.find(t=>t.type==="text"&&t.text==="{REF}"),fZe=mZe.primitives.find(t=>t.type==="text"&&t.text==="{VAL}");_Ze.anchor="middle_left",fZe.anchor="middle_left",_Ze.x=.25,_Ze.y+=.21,fZe.y-=.21,fZe.x=.25;var Vnr=mZe,ote={paths:{path43:{type:"path",points:[{x:-.06,y:.19},{x:-.06,y:-.12}],color:"primary",fill:!1},"path43-6":{type:"path",points:[{x:.02,y:.13},{x:.02,y:-.06}],color:"primary",fill:!1},path44:{type:"path",points:[{x:-.06,y:.03},{x:-.5,y:.03}],color:"primary",fill:!1},"path44-0":{type:"path",points:[{x:.5,y:.03},{x:.03,y:.03}],color:"primary",fill:!1}},texts:{top1:{type:"text",text:"{REF}",x:-.03,y:.27},bottom1:{type:"text",text:"{VAL}",x:-.03,y:-.28}},refblocks:{left1:{x:-.5,y:.03},right1:{x:.5,y:.03}},bounds:{width:1,height:.29,centerX:0,centerY:.06},circles:{}},{paths:znr,bounds:pCn,refblocks:mCn,circles:Jnr}=ote,Wnr=Ln({primitives:[...Object.values(znr),...Object.values(Jnr),{type:"text",text:"{REF}",x:-.2,y:.31},{type:"text",text:"{VAL}",x:.2,y:.31}],ports:[{...mCn.left1,labels:["1"]},{...mCn.right1,labels:["2"]}],center:{x:pCn.centerX,y:pCn.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").changeTextAnchor("{REF}","middle_left").build(),jnr={...Wnr,size:{width:1,height:.9}};function Gl(t){let e=t.size;if(!e){let n=GS(t.primitives);e={width:n.maxX-n.minX,height:n.maxY-n.minY}}return{...t,size:e}}var{paths:$nr,texts:_Cn,bounds:eIe,refblocks:fCn,circles:qnr}=ote,ICn=Gl({primitives:[...Object.values($nr),...Object.values(qnr),{..._Cn.top1,anchor:"middle_bottom"},{..._Cn.bottom1,anchor:"middle_top"}],ports:[{...fCn.left1,labels:["1"]},{...fCn.right1,labels:["2"]}],size:{width:eIe.width,height:eIe.height},center:{x:eIe.centerX,y:eIe.centerY}}),{paths:Xnr,bounds:CCn,refblocks:yCn,circles:Znr}=ote,eor=Ln({primitives:[...Object.values(Xnr),...Object.values(Znr),{type:"text",text:"{REF}",x:0,y:-.22},{type:"text",text:"{VAL}",x:0,y:.28}],ports:[{...yCn.left1,labels:["1"]},{...yCn.right1,labels:["2"]}],center:{x:CCn.centerX,y:CCn.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").changeTextAnchor("{REF}","middle_bottom").build(),tor={...eor,size:{width:1,height:.65}},{paths:nor,bounds:xCn,refblocks:ECn,circles:oor}=ote,ior=Ln({primitives:[...Object.values(nor),...Object.values(oor),{type:"text",text:"{REF}",x:0,y:.28},{type:"text",text:"{VAL}",x:0,y:-.22}],ports:[{...ECn.left1,labels:["1"]},{...ECn.right1,labels:["2"]}],center:{x:xCn.centerX,y:xCn.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").changeTextAnchor("{REF}","middle_bottom").build(),ror={...ior,size:{width:1,height:.65}},{paths:sor,bounds:BCn,refblocks:bCn,circles:aor}=ote,Aor=Ln({primitives:[...Object.values(sor),...Object.values(aor),{type:"text",text:"{REF}",x:.2,y:-.25},{type:"text",text:"{VAL}",x:-.2,y:-.25}],ports:[{...bCn.left1,labels:["1"]},{...bCn.right1,labels:["2"]}],center:{x:BCn.centerX,y:BCn.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").changeTextAnchor("{REF}","middle_left").build(),cor={...Aor,size:{width:1,height:.9}},lor=nte(ICn,{newOrientation:"up"}),tIe={paths:{path1:{type:"path",points:[{x:-.3,y:0},{x:-.19998,y:0}],color:"primary",fill:!1,strokeWidth:.012},path2:{type:"path",points:[{x:.19998,y:0},{x:.3,y:0}],color:"primary",fill:!1,strokeWidth:.012},path3:{type:"path",points:[{x:-.19998,y:.07998},{x:.19998,y:.07998},{x:.19998,y:-.07998},{x:-.19998,y:-.07998},{x:-.19998,y:.07998}],color:"primary",fill:!1,strokeWidth:.012}},refblocks:{left1:{x:-.3,y:0},right1:{x:.3,y:0}},bounds:{centerX:0,centerY:0},circles:{}},{paths:uor,bounds:SCn,refblocks:QCn,circles:gor}=tIe,dor=Ln({primitives:[...Object.values(uor),...Object.values(gor),{type:"text",text:"{REF}",x:-.16,y:.16},{type:"text",text:"{VAL}",x:.16,y:.16}],ports:[{...QCn.left1,labels:["1"]},{...QCn.right1,labels:["2"]}],center:{x:SCn.centerX,y:SCn.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),hor={...dor,size:{width:.9,height:.6}},{paths:por,bounds:vCn,refblocks:wCn,circles:mor}=tIe,_or=Ln({primitives:[...Object.values(por),...Object.values(mor),{type:"text",text:"{REF}",x:0,y:-.16},{type:"text",text:"{VAL}",x:0,y:.16}],ports:[{...wCn.left1,labels:["1"]},{...wCn.right1,labels:["2"]}],center:{x:vCn.centerX,y:vCn.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("left").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Ior={..._or,size:{width:.6,height:.65}},{paths:Cor,bounds:PCn,refblocks:MCn,circles:yor}=tIe,xor=Ln({primitives:[...Object.values(Cor),...Object.values(yor),{type:"text",text:"{REF}",x:0,y:.16},{type:"text",text:"{VAL}",x:0,y:-.16}],ports:[{...MCn.left1,labels:["1"]},{...MCn.right1,labels:["2"]}],center:{x:PCn.centerX,y:PCn.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Eor={...xor,size:{width:.6,height:.65}},nIe={paths:{path2:{type:"path",points:[{x:.15,y:-.01},{x:.55,y:-.01}],color:"primary",fill:!0},"path2-5":{type:"path",points:[{x:-.15,y:.06},{x:.14,y:.06}],color:"primary",fill:!0},"path2-5-1":{type:"path",points:[{x:.14,y:.06},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-5-1-6":{type:"path",points:[{x:-.16,y:.06},{x:-.16,y:-.08}],color:"primary",fill:!0},"path2-5-4":{type:"path",points:[{x:-.15,y:-.08},{x:.14,y:-.08}],color:"primary",fill:!0},"path2-9":{type:"path",points:[{x:-.55,y:-.01},{x:-.17,y:-.01}],color:"primary",fill:!0}},refblocks:{left1:{x:-.55,y:-.01},right1:{x:.55,y:-.01}},bounds:{width:1.16,height:.35,centerX:0,centerY:0},circles:{}},{paths:Bor,bounds:oIe,refblocks:DCn,circles:bor}=nIe,Sor=Ln({primitives:[...Object.values(Bor),...Object.values(bor),{type:"text",text:"{REF}",x:-.2,y:.1404553499999995},{type:"text",text:"{VAL}",x:.2,y:.1494553499999995}],ports:[{...DCn.left1,labels:["1"]},{...DCn.right1,labels:["2"]}],size:{width:oIe.width,height:oIe.height},center:{x:oIe.centerX,y:oIe.centerY}}).rotateRightFacingSymbol("down").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:Qor,bounds:iIe,refblocks:NCn,circles:vor}=nIe,wor=Ln({primitives:[...Object.values(Qor),...Object.values(vor),{type:"text",text:"{REF}",x:0,y:-.2294553499999995},{type:"text",text:"{VAL}",x:0,y:.1704553499999995}],ports:[{...NCn.left1,labels:["1"]},{...NCn.right1,labels:["2"]}],size:{width:iIe.width,height:iIe.height},center:{x:iIe.centerX,y:iIe.centerY}}).rotateRightFacingSymbol("left").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:Por,bounds:rIe,refblocks:RCn,circles:Mor}=nIe,Dor=Ln({primitives:[...Object.values(Por),...Object.values(Mor),{type:"text",text:"{REF}",x:0,y:.2294553499999995},{type:"text",text:"{VAL}",x:0,y:-.1704553499999995}],ports:[{...RCn.left1,labels:["1"]},{...RCn.right1,labels:["2"]}],size:{width:rIe.width,height:rIe.height},center:{x:rIe.centerX,y:rIe.centerY}}).rotateRightFacingSymbol("right").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_bottom").changeTextAnchor("{VAL}","middle_top").build(),{paths:Nor,bounds:sIe,refblocks:TCn,circles:Ror}=nIe,Tor=Ln({primitives:[...Object.values(Nor),...Object.values(Ror),{type:"text",text:"{REF}",x:.2,y:-.1404553499999995},{type:"text",text:"{VAL}",x:-.2,y:-.1494553499999995}],ports:[{...TCn.left1,labels:["1"]},{...TCn.right1,labels:["2"]}],size:{width:sIe.width,height:sIe.height},center:{x:sIe.centerX,y:sIe.centerY}}).rotateRightFacingSymbol("up").labelPort("left",["1"]).labelPort("right",["2"]).changeTextAnchor("{REF}","middle_left").changeTextAnchor("{VAL}","middle_left").build(),{paths:kor,bounds:kCn,refblocks:FCn,circles:For}=tIe,Lor=Ln({primitives:[...Object.values(kor),...Object.values(For),{type:"text",text:"{REF}",x:.16,y:-.16},{type:"text",text:"{VAL}",x:-.16,y:-.16}],ports:[{...FCn.left1,labels:["1"]},{...FCn.right1,labels:["2"]}],center:{x:kCn.centerX,y:kCn.centerY}}).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),Hor={...Lor,size:{width:.9,height:.6}},IZe={paths:{"horizontal-bar":{type:"path",points:[{x:-.4,y:0},{x:.4,y:0}],color:"primary",fill:!1},"middle-dash-1":{type:"path",points:[{x:0,y:.2},{x:0,y:.07}],color:"primary",fill:!1},"middle-dash-2":{type:"path",points:[{x:0,y:.01},{x:0,y:-.12}],color:"primary",fill:!1},"middle-dash-3":{type:"path",points:[{x:0,y:-.18},{x:0,y:-.31}],color:"primary",fill:!1},"left-vertical":{type:"path",points:[{x:-.25,y:0},{x:-.25,y:-.2}],color:"primary",fill:!1},"right-vertical":{type:"path",points:[{x:.25,y:0},{x:.25,y:-.2}],color:"primary",fill:!1},"left-ground":{type:"path",points:[{x:-.3,y:-.2},{x:-.25,y:-.3},{x:-.2,y:-.2},{x:-.3,y:-.2}],color:"primary",fill:!1},"right-ground":{type:"path",points:[{x:.2,y:-.2},{x:.25,y:-.3},{x:.3,y:-.2},{x:.2,y:-.2}],color:"primary",fill:!1}},refblocks:{left1:{x:-.4,y:0},right1:{x:.4,y:0}},bounds:{centerX:0,centerY:-.02},circles:{}},{paths:Oor,bounds:LCn,refblocks:HCn,circles:Gor}=IZe,Yor=Ln({primitives:[...Object.values(Oor),...Object.values(Gor),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...HCn.left1,labels:["1"]},{...HCn.right1,labels:["2"]}],center:{x:LCn.centerX,y:LCn.centerY}}).changeTextAnchor("{VAL}","middle_bottom").rotateRightFacingSymbol("down").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_left").build(),{paths:Uor,bounds:OCn,refblocks:GCn,circles:Kor}=IZe,YCn=Ln({primitives:[...Object.values(Uor),...Object.values(Kor),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...GCn.left1,labels:["1"]},{...GCn.right1,labels:["2"]}],center:{x:OCn.centerX,y:OCn.centerY}}).rotateRightFacingSymbol("right").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_bottom").build(),Vor=pK(YCn),{paths:zor,bounds:UCn,refblocks:KCn,circles:Jor}=IZe,Wor=Ln({primitives:[...Object.values(zor),...Object.values(Jor),{type:"text",text:"{REF}",x:0,y:.2594553499999995}],ports:[{...KCn.left1,labels:["1"]},{...KCn.right1,labels:["2"]}],center:{x:UCn.centerX,y:UCn.centerY}}).rotateRightFacingSymbol("up").labelPort("left1",["1"]).labelPort("right1",["2"]).changeTextAnchor("{REF}","middle_right").build(),aIe={paths:{path27:{type:"path",points:[{x:.3,y:0},{x:.06,y:0}],color:"primary",fill:!1,strokeWidth:.012},path28:{type:"path",points:[{x:-.06,y:0},{x:-.3,y:0}],color:"primary",fill:!1,strokeWidth:.012},path29:{type:"path",points:[{x:.06,y:.16002},{x:.06,y:-.16002}],color:"primary",fill:!1,strokeWidth:.012},path30:{type:"path",points:[{x:-.06,y:.16002},{x:-.06,y:-.16002}],color:"primary",fill:!1,strokeWidth:.012}},texts:{top1:{type:"text",text:"{REF}",x:0,y:.24,anchor:"middle_bottom"},bottom1:{type:"text",text:"{VAL}",x:0,y:-.24,anchor:"middle_top"}},refblocks:{left1:{x:-.3,y:0},right1:{x:.3,y:0}},bounds:{minX:-.3,maxX:.3,minY:-.24,maxY:.24,width:.6,height:.48,centerX:0,centerY:0},circles:{}},{paths:jor,texts:jmr,bounds:AIe,refblocks:VCn,circles:$or}=aIe,qor=Ln({primitives:[...Object.values(jor),...Object.values($or),{type:"text",text:"{REF}",x:-.2,y:.115},{type:"text",text:"{VAL}",x:.2,y:.115}],ports:[{...VCn.left1,labels:["1"]},{...VCn.right1,labels:["2"]}],size:{width:AIe.width,height:AIe.height},center:{x:AIe.centerX,y:AIe.centerY}}).changeTextAnchor("{VAL}","top_left").rotateRightFacingSymbol("down").labelPort("left1",["1","pos"]).labelPort("right1",["2","neg"]).changeTextAnchor("{REF}","bottom_left").build(),Xor={...qor,size:{width:.9,height:.6}},Zor=Ln(aIe).changeTextAnchor("{VAL}","middle_top").rotateRightFacingSymbol("right").labelPort("left1",["2","neg"]).labelPort("right1",["1","pos"]).changeTextAnchor("{REF}","middle_bottom").build(),eir={...Zor,size:{width:.6,height:.65}},cIe={paths:{path27:{type:"path",points:[{x:.3,y:0},{x:657e-6,y:0}],color:"primary",fill:!1,strokeWidth:.012},path28:{type:"path",points:[{x:-.038683,y:0},{x:-.3,y:0}],color:"primary",fill:!1,strokeWidth:.012},path30:{type:"path",points:[{x:-.074255,y:.16002},{x:-.074255,y:.16002},{x:-.069544,y:.149352},{x:-.065126,y:.138684},{x:-.061005,y:.128016},{x:-.057182,y:.117348},{x:-.053663,y:.10668},{x:-.05045,y:.096012},{x:-.047547,y:.085344},{x:-.044957,y:.074676},{x:-.042684,y:.064008},{x:-.040732,y:.05334},{x:-.039103,y:.042672},{x:-.037801,y:.032004},{x:-.03683,y:.021336},{x:-.036193,y:.010668},{x:-.035893,y:0},{x:-.036193,y:-.010668},{x:-.03683,y:-.021336},{x:-.037801,y:-.032004},{x:-.039103,y:-.042672},{x:-.040732,y:-.05334},{x:-.042684,y:-.064008},{x:-.044957,y:-.074676},{x:-.047547,y:-.085344},{x:-.05045,y:-.096012},{x:-.053663,y:-.10668},{x:-.057182,y:-.117348},{x:-.061005,y:-.128016},{x:-.065126,y:-.138684},{x:-.069544,y:-.149352},{x:-.074255,y:-.16002},{x:-.074255,y:-.16002}],color:"primary",fill:!1,strokeWidth:.012},"path30-7":{type:"path",points:[{x:-385e-6,y:.16002},{x:-385e-6,y:-.16002}],color:"primary",fill:!1,strokeWidth:.012},"path30-9-2":{type:"path",points:[{x:.156026,y:.2},{x:.085846,y:.2}],color:"primary",fill:!1,strokeWidth:.012},"path30-9-2-9":{type:"path",points:[{x:.120936,y:.16491},{x:.120936,y