(()=>{var KA=Object.create;var t2=Object.defineProperty;var $A=Object.getOwnPropertyDescriptor;var QA=Object.getOwnPropertyNames;var eC=Object.getPrototypeOf,tC=Object.prototype.hasOwnProperty;var dr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i2=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var iC=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of QA(t))!tC.call(e,s)&&s!==i&&t2(e,s,{get:()=>t[s],enumerable:!(r=$A(t,s))||r.enumerable});return e};var zO=(e,t,i)=>(i=e!=null?KA(eC(e)):{},iC(t||!e||!e.__esModule?t2(i,"default",{value:e,enumerable:!0}):i,e));var n2=i2((vJ,s2)=>{var r2=[];r2.push(`<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<title></title>
		<style>
			* {
				box-sizing: border-box;
				padding: 0px;
				margin: 0px;
			}

			body {
				overflow: hidden;
				background-color: #aaa;
			}

			#canvas {
				position: absolute;
				width: 100vw;
				height: 100vh;
				z-index: 1;
				left: 0;
				top: 0;
				outline-style: none;
			}
		</style>
	</head>

	<body>
		<canvas id="canvas" tabindex="0"></canvas>
	</body>
</html>
`);s2.exports=r2.join("")});var QO=i2((HJ,_2)=>{"use strict";var JO=Object.defineProperty,hC=Object.getOwnPropertyDescriptor,cC=Object.getOwnPropertyNames,uC=Object.prototype.hasOwnProperty,dC=(e,t)=>{for(var i in t)JO(e,i,{get:t[i],enumerable:!0})},fC=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of cC(t))!uC.call(e,s)&&s!==i&&JO(e,s,{get:()=>t[s],enumerable:!(r=hC(t,s))||r.enumerable});return e},pC=e=>fC(JO({},"__esModule",{value:!0}),e),l2={};dC(l2,{BroadcastChannelMessageBus:()=>LC,MessageBus:()=>SC,MessageBus2:()=>AC,MessageBusTask:()=>WO,MessageBusTask2:()=>Au,WindowMessageBridge:()=>TC,WorkerMessageBridge:()=>wC,createBroadcastP2PStream:()=>p2,createBufferedByteBufferStream:()=>f2,createBufferedStream:()=>$O,createBufferedStringStream:()=>d2,dropP2PStream:()=>DC,flowRead:()=>NC,flowWrite:()=>RC});_2.exports=pC(l2);var rp=class{constructor(e=1.5){this.growthFactor=e,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(e){if(this.count===this.capacity){let t=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,t);let i=new Array(t);for(let r=0;r<this.count;r++)i[r]=this.buffer[(this.head+r)%this.capacity];this.buffer=i,this.head=0,this.tail=this.count,this.capacity=t}this.buffer[this.tail]=e,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let e=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,e}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},ZO=new ArrayBuffer(8),UJ=new Float64Array(ZO),GJ=new Uint32Array(ZO),zJ=new Uint16Array(ZO),qO=ArrayBuffer;try{qO=self.HTMLImageElement||qO}catch{}var gC=typeof SharedArrayBuffer<"u";function sp(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer||gC&&e instanceof SharedArrayBuffer||e instanceof Blob||e instanceof FormData||e instanceof Function||e instanceof Uint8ClampedArray||e instanceof qO)return e;if(Array.isArray(e))return e.map(sp);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=sp(e[i]));return t}}function YO(e,t){return _C(e,t,()=>[])}function _C(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var OC=class{constructor(e){this.maxResources=e,this.idle=new rp,this.isClosed=!1,this.resources=e}acquire(e){this.isClosed?Promise.resolve(!1).then(e):this.resources>0?(this.resources--,Promise.resolve(!0).then(e)):this.idle.enqueue(e)}acquireSync(){return new Promise(e=>{this.acquire(e)})}release(){if(!this.isClosed){let e=this.idle.dequeue();e?Promise.resolve(!0).then(e):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let e=this.idle.dequeue();Promise.resolve(!1).then(e)}}};function mC(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function bC(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}var yC=mC(),vC=yC.WeakRef||(e=>e);function wl(e){if(e!=null){if(typeof e=="object")return new vC(e);console.error(e,e instanceof Object,typeof e);return}}function Co(e){return e==null?void 0:e.deref()}var xC="_MSG_BUS_RPC_",KO=300*1e3,EC=(e=>(e.PUBLISH="publish",e.SUBSCRIBE="subscribe",e.PUSH="push",e.PULL="pull",e))(EC||{}),h2=class{constructor(e){this.bus=e}processRemoteMessage(e,t){let i=wl(t),r=e.topic,s=e.type,n=e.message;switch(s){case"pull":this.bus.pull(r,a=>{this.push(r,a,Co(i))});break;case"subscribe":this.bus.subscribe(r,a=>{this.publish(r,a,Co(i))});break;case"publish":this.bus.publish(r,n,this,Co(i));break;case"push":this.bus.push(r,n,this,Co(i));break;default:console.debug("unknown message type "+s)}}rpcCall(e,t,i,r=KO){let s=wl(i),n=new Promise(a=>{let o=this.bus.uniqueRpcTopic(e);this.publish(e,{message:t,reply:o},Co(s)),this.bus.pull(o,(l,h,c)=>{a({message:l,bridge:h,source:wl(c)})})});return r>0?Promise.race([n,new Promise((a,o)=>{setTimeout(o,r)})]):n}},wC=class extends h2{constructor(e,t){super(e),this.worker=t,t.onmessage=i=>{this.processRemoteMessage(i.data,void 0)}}publish(e,t){this.postMessage(e,"publish",t)}subscribe(e){this.postMessage(e,"subscribe",null)}push(e,t){this.postMessage(e,"push",t)}pull(e){this.postMessage(e,"pull",null)}rpcCall(e,t,i=KO){return super.rpcCall(e,t,void 0,i)}postMessage(e,t,i){let r={topic:e,type:t,message:i};this.worker.postMessage(r)}discard(){this.worker.terminate()}},TC=class extends h2{constructor(e){super(e),window.addEventListener("message",t=>{this.processRemoteMessage(t.data,t.source)},!1)}publish(e,t,i){this.postMessage(e,"publish",t,i)}subscribe(e,t){if(t===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(e,"subscribe",null,t)}push(e,t,i){this.postMessage(e,"push",t,i)}pull(e,t){if(t===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(e,"pull",null,t)}postMessage(e,t,i,r){let s={topic:e,type:t,message:i};r&&r.postMessage(s,"*")}},WO=class{constructor(e){this.isRunning=!0,this.callback=e}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(e,t,i,r){try{e=r?e:sp(e),this.callback(e,t,i)}catch(s){console.error(s)}}},SC=class{constructor(e=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=e}uniqueRpcTopic(e){return`${xC}-${e}-${this.uuid}-${this.rpcTicket++}`}publish(e,t,i,r){let s=this.subscribed[e];if(s){let n;for(let a of s)a.running()?a.execute(t,i,r,this.unsafe):(n=n||new Array,n.push(a));if(n)for(let a of n)bC(s,a)}else console.debug("no sub on topic: "+e)}subscribe(e,t){let i=new WO(t);return YO(this.subscribed,e).push(i),i}push(e,t,i,r){let s=!1,n=this.pulled[e];if(n){for(;n.length>0;){let a=n.shift();if(a.running()){a.execute(t,i,r,this.unsafe),s=!0;break}}n.length===0&&delete this.pulled[e]}s||YO(this.pushed,e).push({message:t,bridge:i,source:wl(r)})}pull(e,t){let i=new WO(t),r=this.pushed[e];if(r){let s=r.shift();i.execute(s.message,s.bridge,Co(s.source),this.unsafe),r.length===0&&delete this.pushed[e]}else YO(this.pulled,e).push(i);return i}pullA(e){return new Promise(t=>{this.pull(e,(i,r,s)=>{t({message:i,bridge:r,source:wl(s)})})})}rpcService(e,t){this.subscribe(e,(i,r,s)=>{let{message:n,reply:a}=i;try{let o=t(n);if(o instanceof Promise){let l=wl(s);o.then(h=>{this.rpcReply(h,a,r,Co(l))},h=>{console.error(h),this.rpcReply(void 0,a,r,Co(l))})}else this.rpcReply(o,a,r,s)}catch(o){console.error(o),this.rpcReply(void 0,a,r,s)}})}rpcCall(e,t,i=KO){let r=new Promise(s=>{let n=this.uniqueRpcTopic(e);this.publish(e,{message:t,reply:n}),this.pull(n,(a,o,l)=>{s({message:a,bridge:o,source:wl(l)})})});return i>0?Promise.race([r,new Promise((s,n)=>{setTimeout(n,i)})]):r}rpcReply(e,t,i,r){i?i.push(t,e,r):this.push(t,e)}},IC="_MSG_BUS_RPC_";function XO(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}function wh(e,t){return PC(e,t,()=>[])}function PC(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var Au=class{constructor(e,t){this.callback=e,this.unsafe=t,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(e){try{e=this.unsafe?e:sp(e),this.callback(e)}catch(t){console.error(t)}}},c2=class{constructor(e=crypto.randomUUID()){this.uuid=e,this.rpcTicket=0}subscribeOnce(e,t){let i=this.subscribe(e,r=>{i.cancel(),t(r)});return i}pullA(e){return new Promise(t=>{this.pull(e,t)})}rpcService(e,t){let i=r=>{try{let{message:s,replyTopic:n}=r;try{let a=t(s);a instanceof Promise?a.then(o=>{this.publish(n,{success:!0,result:o})}).catch(o=>{console.error(o),this.publish(n,{success:!1,err:String(o)})}):this.publish(n,{success:!0,result:a})}catch(a){this.publish(n,{success:!1,err:String(a)})}}finally{this.pull(e,i)}};this.pull(e,i)}rpcCall(e,t,i=0){let r=new Promise((s,n)=>{let a=`${IC}-${e}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(a,o=>{o.success?s(o.result):n(new Error(o.err))}),this.push(e,{message:t,replyTopic:a})});return i>0?Promise.race([r,new Promise((s,n)=>{setTimeout(n,i)})]):r}},AC=class extends c2{constructor(e=!1){super(),this.unsafe=e,this.subscribed={},this.pulled={},this.pushed={}}publish(e,t){let i=this.subscribed[e];if(i){let r;for(let s of i)s.running()?s.execute(t):(r=r||new Array,r.push(s));if(r)for(let s of r)XO(i,s)}}subscribe(e,t){let i=new Au(t,this.unsafe);return wh(this.subscribed,e).push(i),i}push(e,t){let i=!1,r=this.pulled[e];if(r){for(;r.length>0;){let s=r.shift();if(s&&s.running()){s.execute(t),i=!0;break}}r.length===0&&delete this.pulled[e]}i||wh(this.pushed,e).push(t)}pull(e,t){let i=new Au(t,this.unsafe);return this.repull(e,i),i}repull(e,t){let i=this.pushed[e];if(i){let r=i.shift();r&&(t.execute(r),i.length===0&&delete this.pushed[e])}else wh(this.pulled,e).push(t)}},CC=class extends c2{constructor(e=crypto.randomUUID()){super(e),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(e,t){console.debug("BC",this.uuid,"PUBLISH",e,t),this.broadcastPublish(e,t)}subscribe(e,t){console.debug("BC",this.uuid,"SUBSCRIBE",e);let i=new Au(t,!0);return wh(this.subscribed,e).push(i),i}push(e,t){let i=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",e,`(${i})`,t),wh(this.pushed,e).push({id:i,message:t}),this.broadcastPushedHeadMessage(e)}pull(e,t){console.debug("BC",this.uuid,"PULL",e);let i=new Au(t,!0);return wh(this.pulled,e).push(i),this.broadcastWhoHas(e),i}broadcastPushedHeadMessage(e){let t=this.pushed[e];t&&t[0]&&this.broadcastIHave(e,t[0].id)}onReceivedPublish(e,t,i){console.debug("BCMSG(",this.uuid,")","from",e,"PUBLISH",t,"message",i);let r=this.subscribed[t];if(r){let s;for(let n of r)n.running()?n.execute(i):(s=s||new Array,s.push(n));if(s)for(let n of s)XO(r,n);r.length===0&&delete this.subscribed[t]}}onReceivedWhoHas(e,t){console.debug("BCMSG(",this.uuid,")","from",e,"WHOHAS",t),this.broadcastPushedHeadMessage(t)}onReceivedIHave(e,t,i){console.debug("BCMSG(",this.uuid,")","from",e,"IHAVE",t,"id",i);let r=this.pulled[t];if(r){let s;for(let n of r)if(n.running()){this.broadcastINeed(t,e,i);break}else s=s||new Array,s.push(n);if(s)for(let n of s)XO(r,n);r.length===0&&delete this.pulled[t]}}onReceivedINeed(e,t,i,r){if(console.debug("BCMSG(",this.uuid,")","from",e,"INEED",t,"source",i,"id",r),this.uuid===i){let s=this.pushed[t];if(s&&s[0]&&s[0].id===r){let{message:n}=s.shift();this.broadcastIGive(t,r,e,n),this.broadcastPushedHeadMessage(t),s.length===0&&delete this.pushed[t]}}}onReceivedIGive(e,t,i,r,s){console.debug("BCMSG(",this.uuid,")","from",e,"IGIVE",t,"id",i,"target",r,"message",s);let n=this.pulled[t];if(n&&this.uuid===r){let a=!1;for(;n.length>0;){let o=n.shift();if(o.running()){o.execute(s),a=!0;break}}a||this.push(t,s),n.length===0&&delete this.pulled[t]}}},LC=class extends CC{constructor(e,t=crypto.randomUUID()){super(t),this.bc=new BroadcastChannel(e),this.bc.onmessage=i=>{this.onMessage(i.data)}}onMessage(e){let{type:t,uuid:i,topic:r}=e;switch(t){case"PUBLISH":{let{message:s}=e;this.onReceivedPublish(i,r,s);break}case"WHOHAS":{this.onReceivedWhoHas(i,r);break}case"IHAVE":{let{id:s}=e;this.onReceivedIHave(i,r,s);break}case"INEED":{let{source:s,id:n}=e;this.onReceivedINeed(i,r,s,n);break}case"IGIVE":{let{target:s,id:n,message:a}=e;this.onReceivedIGive(i,r,n,s,a);break}default:console.warn("unsupported",e)}}broadcastPublish(e,t){this.post({type:"PUBLISH",uuid:this.uuid,topic:e,message:t})}broadcastWhoHas(e){this.post({type:"WHOHAS",uuid:this.uuid,topic:e})}broadcastIHave(e,t){this.post({type:"IHAVE",uuid:this.uuid,topic:e,id:t})}broadcastINeed(e,t,i){this.post({type:"INEED",uuid:this.uuid,topic:e,source:t,id:i})}broadcastIGive(e,t,i,r){this.post({type:"IGIVE",uuid:this.uuid,topic:e,id:t,target:i,message:r})}post(e){this.bc.postMessage(e),Promise.resolve().then(()=>{this.onMessage(e)})}},Th=Symbol("BLOCKING_QUEUE_RESET"),u2=class{constructor(e,t=()=>1){if(this.maxSize=e,this.itemSizeOf=t,this.queue=new rp,this.waitingConsumers=new rp,this.waitingProducers=new rp,this.queueSize=0,this.closePromise=null,this.closeResolve=null,e<=0)throw new Error("Max size must be greater than 0")}enqueue(e){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let t=await new Promise(i=>{this.waitingProducers.enqueue(i)});return console.debug("queue is not full",this.size(),t),t?(this.innerEnqueue(e),!0):!1})():(this.innerEnqueue(e),!0)}innerEnqueue(e){if(this.waitingConsumers.isEmpty())this.queue.enqueue(e),this.queueSize+=this.itemSizeOf(e),console.debug("queue pushed",e,"size",this.queueSize);else{let t=this.waitingConsumers.dequeue();Promise.resolve(e).then(t),console.debug("queue direct",e,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let e=this.waitingConsumers.dequeue();Promise.resolve(Th).then(e)}return setTimeout(()=>this.closeResolve(),0),Th}else return new Promise(e=>{this.waitingConsumers.enqueue(e)});else{let e=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(e),!this.waitingProducers.isEmpty()){let t=this.waitingProducers.dequeue();Promise.resolve(!0).then(t)}return e}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(e=>{for(this.closeResolve=e;!this.waitingProducers.isEmpty();){let t=this.waitingProducers.dequeue();Promise.resolve(!1).then(t)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let t=this.waitingConsumers.dequeue();Promise.resolve(Th).then(t)}e()}})),this.closePromise}};function $O(e,t,i=Number.MAX_SAFE_INTEGER){let r=new u2(i,t),s=new ReadableStream({pull(a){let o=!0,l=(async()=>{let h=new Array;do{let c=r.dequeue();if(c instanceof Promise){o=!1;let d=await c;d===Th?a.close():h.push(d)}else{let d=c;d===Th?a.close():h.push(d)}}while(r.size()>0);if(h.length>0){let c=e(h);a.enqueue(c)}})();if(!o)return console.debug("read stream stucked --------------------------------------"),l},async cancel(){console.debug("buffered readable cancel"),await r.close()}}),n=new WritableStream({write(a,o){let l=!0,h=(async()=>{let c=r.enqueue(a);typeof c=="boolean"?c||o.error(new Error("Write stream closed")):(l=!1,await c||o.error(new Error("Write stream closed")))})();if(!l)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),h},async close(){console.debug("buffered writable closing",r.size()),await r.close(),console.debug("buffered writable closed",r.size())},async abort(){console.debug("buffered writable aborting",r.size()),await r.close(),console.debug("buffered writable aborted",r.size())}});return{readable:s,writable:n}}function d2(e=Number.MAX_SAFE_INTEGER){return $O(t=>t.join(""),t=>t.length,e)}function f2(e=Number.MAX_SAFE_INTEGER){return $O(t=>{let i=new Uint8Array(t.reduce((s,n)=>s+n.byteLength,0)),r=0;return t.forEach(s=>{i.set(s,r),r+=s.byteLength}),i},t=>t.byteLength,e)}function p2(e){return new Promise((t,i)=>{let r=new BroadcastChannel(e),s=new u2(1),n=new OC(1),a=null,o=!1,l=!1,h=!1;r.onmessage=c=>{let d=c.data,{type:f}=d;if(console.debug("p2p",e,"type",f,"data",f==="DATA"&&d.data),f==="DATA")s.enqueue(d.data);else if(f==="HI"){if(!a){r.postMessage({type:"HI"});let _=0;a={rs:new ReadableStream({async pull(y){let m=await s.dequeue();m===Th?(await p(),y.close()):(y.enqueue(m),r.postMessage({type:"ACK"}))},cancel(){return p()}}),ws:new WritableStream({async write(y,m){await n.acquireSync()?r.postMessage({type:"DATA",id:_++,data:y}):(u(),m.error(new Error("Write stream closed")))},close(){u()},abort(){u()}})},t(a)}}else f==="REND"?a?n.close():g("REND1"):f==="WEND"?a?s.close():g("WEND1"):f==="ACK"&&n.release();function u(){o||(o=!0,console.debug(e,"p2p write stream closed"),n.close(),r.postMessage({type:"WEND"}),l&&(console.debug(e,"p2p channel closed on ws"),r.close()))}async function p(){l||(l=!0,console.debug(e,"p2p read stream closed"),r.postMessage({type:"REND"}),await s.close(),o&&(console.debug(e,"p2p channel closed on rs"),r.close()))}async function g(_){h||(h=!0,console.debug(e,"p2p channel connection released on",_),n.close(),s.close(),a?(a.rs.locked||(console.debug(e,"p2p unlocked read stream direct cancel"),a.rs.cancel()),a.ws.locked||(console.debug(e,"p2p unlocked write stream direct close"),a.ws.close())):(r.postMessage({type:"HI"}),r.close()),i(new Error("p2p channel connection released")))}},r.postMessage({type:"HI"})})}function DC(e){return new Promise(t=>{let i=new BroadcastChannel(e);i.onmessage=r=>{let s=r.data,{type:n}=s;n==="HI"&&(i.postMessage({type:"REND"}),i.close(),t())},i.postMessage({type:"REND"})})}async function g2(e){try{return await p2(e)}catch(t){t.message!=="p2p channel connection released"&&console.error(t)}}async function RC(e,t,i=10*1024*1024,r=!0){let s=await g2(e);if(!s)return!1;let n=!1;try{let a,o=l=>{if(!a)if(!r)a=s.ws.getWriter();else if(typeof l=="string"){let h=d2(i);h.readable.pipeTo(s.ws),a=h.writable.getWriter()}else{let h=f2(i);h.readable.pipeTo(s.ws),a=h.writable.getWriter()}return a.write(l)};if(Array.isArray(t))for(let l of t)await o(l);else await t({write:o,get desiredSize(){return((a==null?void 0:a.desiredSize)||0)+10}});a&&await a.close(),n=!0}catch(a){console.error(a)}finally{return s.rs.cancel(),n}}async function NC(e,t){var r,s;let i=await g2(e);if(i)try{let n=i.rs.getReader();for((r=t.start)==null?void 0:r.call(t);;){let{value:a,done:o}=await n.read();if(a!==void 0){let l;if(t.update instanceof Promise?l=await t.update(a):l=t.update(a),l){await n.cancel();break}}if(o){(s=t.end)==null||s.call(t);break}}}catch(n){console.error(n)}finally{i.ws.close()}}});var YA=zO(n2());var a2={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},EJ=(()=>{let e={};for(let t in a2)e[a2[t]]=t;return e})();var Kf=class Kf{constructor(t,i){this.ratio=t/i}wrap(t){return t*this.ratio}static convert(t,i,r){return t*i/r}};Kf.ASIS=new Kf(1,1);var Fa=Kf;var $f=class $f{conversion(t,i,r){if(t===i)return r;if(t[1]==="i"&&i[0]==="m"&&i[1]==="m")return this.mil2mm(r);if(t[0]==="m"&&t[1]==="m"&&i[1]==="i")return this.mm2mil(r);let s=t+2+i;return this[s](r)}conversion1(t,i,r){let s=t+2+i,n=this[s](r);return i=="mil"?Math.round(n*10)/10:Math.round(n*1e3)/1e3}mil2mil(t){return t}mil2mm(t){return t*.0254}mil2cm(t){return t*.00254}mil2inch(t){return t/1e3}mm2mm(t){return t}mm2mil(t){let i=Math.pow(10,5);return Math.round(t*39.37007874015748*i)/i}mm2cm(t){return t/10}mm2inch(t){let i=Math.pow(10,8);return Math.round(t*.03937007874015748*i)/i}cm2mil(t){let i=Math.pow(10,6);return Math.round(t*393.7007874015748*i)/i}cm2mm(t){return t*10}cm2inch(t){let i=Math.pow(10,7);return Math.round(t*.3937007874015748*i)/i}inch2mil(t){return t*1e3}inch2mm(t){return t*25.4}inch2cm(t){return t*2.54}};$f.ins=new $f;var Rs=$f;Rs.prototype["px(100)2mil"]=e=>e*10;Rs.prototype["px(100)2mm"]=e=>e*.254;Rs.prototype["mil2px(100)"]=e=>e/10;Rs.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var ep=null,VO=new ArrayBuffer(8),HO=new Float64Array(VO),jO=new Uint32Array(VO),o2=new Uint16Array(VO);var Ao=class{static repeat(t,i){let r=new Array(i);for(;i-- >0;)r[i]=t;return r.join("")}static lpad(t,i,r){let s=r-t.length;return s>0?this.repeat(i,s)+t:t}static rpad(t,i,r){let s=r-t.length;return s>0?t+this.repeat(i,s):t}static strHashcode(t){if(t.length>0){let i=0;for(let r=0;r<t.length;r++)i=31*i+t.charCodeAt(r)|0;return i}else return 0}static arraycopy(t,i,r,s,n){if(t.length>=i+n&&r.length>=s+n)for(;n-- >0;)r[s++]=t[i++];else throw new Error("arraycopy out of range")}static undefAsNull(t){return null}static reverse(t,i){for(let r=0,s=t.length-1;s>=0;r++,s--)i[r]=t[s];return i}static sortAsc(t,i){return t-i}static xmlDecode(t){let i=t.length,r=new Array,s=-1;for(let n=0;n<i;n++){let a=t.charAt(n);if(s>=0){if(a===";"){let o=t.substring(s+1,n);switch(o){case"lt":r.push("<");break;case"gt":r.push(">");break;case"quot":r.push('"');break;case"apos":r.push("'");break;case"amp":r.push("&");break;default:if(o.charAt(0)==="#"){let l=parseInt(o.substring(1));r.push(String.fromCharCode(l))}else r.push("&"+o+";")}s=-1}}else a==="&"?s=n:r.push(a)}return s>=0&&r.push(t.substring(s)),r.join("")}static queryItem(t,i,r){let s={index:-1,data:null};for(let n=0;n<t.length;n++){let a=t[n];if(a[i]===r)return s.index=n,s.data=a,s}return s}static addAll(t,i){for(let r of i)t.push(r)}static addAllSet(t,i){for(let r of i)t.add(r)}static contains(t,i){for(let r of t)if(r.equals(i))return!0;return!1}static equals(t,i){if(t.length==i.length){for(let r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}else return!1}static remove(t,i){let r=0,s=t.length;for(let n=0;n<s;n++)t[n]===i&&(t.splice(n,1),n--,s--,r++);return r}static getUrlVars(){for(var t={},i=location.href.slice(location.href.indexOf("?")+1).split("&"),r=0;r<i.length;r++){var s=i[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}static prefix(){if(!ep){let t=this.getUrlVars().version;t?ep="/analyzer/v"+t:ep="/analyzer"}return ep}static add2objS(t,i,r){if(i in t)return t[i];{let s=r(i);return t[i]=s,s}}static downloadFile(t,i){let r=document.createElement("a"),s=URL.createObjectURL(i);r.download=t,r.href=s,r.click(),URL.revokeObjectURL(s)}static uuid(){let t=new Array;HO[0]=new Date().getTime(),t.push(jO[1].toString(16)),HO[0]=Math.random(),t.push(o2[3].toString(16));let i=o2[2].toString(16);t.push("4"+i.substr(0,3)),HO[0]=performance.now();let r=jO[0].toString(16)+jO[1].toString(16);return t.push("0"+r.substr(0,3)),t.push(r.substr(3)),t.join("-")}static funcCopy(t){return(0,eval)("("+t.toString()+")")}static NVL(...t){for(let i of t)if(i!==null)return i;return null}static isSingle(t){return Array.from(new Set(t)).length===t.length}};var tp=class{static rgb(t){if(0<=t&&t<=255)return t;throw new Error(la.format("RGB should not nagative and not over 255(0xFF): %X",t))}static normal(t){if(isFinite(t))return t;throw new Error(la.format("%f is not permitted",t))}static positiveOr0(t){if(t>=0)return t;throw new Error(la.format("%f must >= 0",t))}static positive(t){if(t>0)return t;throw new Error(la.format("%f must > 0",t))}static notnull(t){if(t!=null)return t;throw new Error("invalid null value")}static mustnull(t){if(t===null)return null;throw new Error("value must be null")}static notEmpty(t){if(t==null||t.length===0)throw new Error("invalid empty string");return t}static nullOrEmpty(t){return t==null||t.length===0}static notNullOrUndef(t){if(t!=null)return t;throw new Error("null or undefined is not permitted")}};var nC=/(\.?0+)$/,la=class{static format(t,...i){return this.format1(t,i)}static format1(t,i){let r=this._format(t,i);if(typeof r=="string")return r;throw new Error(this.format("Invalid state on (%d) %s",r,t))}static _format(t,i){let r=[],s=0,n=0,a,o=0,l=0;for(let h=0;h<t.length;h++){let c=t.charAt(h),d=c.charCodeAt(0);switch(s){case 0:d===37?s=1:r.push(c);break;case 1:switch(d){case 100:if(a=i[n++],typeof a=="number")r.push(a.toFixed(0)),s=0;else return h;break;case 102:if(a=i[n++],typeof a=="number")r.push(a.toString()),s=0;else return h;break;case 120:if(a=i[n++],typeof a=="number")r.push((a|0).toString(16)),s=0;else return h;break;case 88:if(a=i[n++],typeof a=="number")r.push((a|0).toString(16).toUpperCase()),s=0;else return h;break;case 115:case 99:a=i[n++],r.push(a===null?"null":a.toString()),s=0;break;case 48:o=h+1,l=-1,s=2;break;case 37:r.push("%"),s=0;break;default:return h}break;case 2:switch(d){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:l=h;break;case 120:if(l>=o){let f=parseInt(t.substring(o,l+1));if(a=i[n++],typeof a=="number")r.push(Ao.lpad((a|0).toString(16),"0",f)),s=0;else return h}else return h;break;case 88:if(l>=o){let f=parseInt(t.substring(o,l+1));if(a=i[n++],typeof a=="number")r.push(Ao.lpad((a|0).toString(16).toUpperCase(),"0",f)),s=0;else return h}else return h;break;default:return h}break;default:return h}}return r.join("")}static startsWith(t,i){return t.length>=i.length?t.substring(0,i.length)===i:!1}static endsWith(t,i){return t.length>=i.length?t.substring(t.length-i.length)===i:!1}static split(t,i){let r=new Array,s=0;for(;;){let n=t.exec(i);if(n!==null){let a=t.lastIndex-n[0].length;r.push(i.substring(s,a)),s=t.lastIndex}else{let a=i.substring(s);tp.nullOrEmpty(a)||r.push(a);break}}return r}static fmtNumber(t){return t.toFixed(5).replace(nC,"")}};function aC(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var oC=(e,t)=>{e===3?console.error(t):console.log(t)},lC=(e,t)=>la.format("%s %s: %s",new Date,aC(e),t),Eh=class Eh{constructor(t,i=oC,r=lC){this.debug=!1;this.level=t,this.writer=i,this.fmt=r}static mix(...t){let i=4;for(let r of t)r.level<i&&(i=r.level);return new Eh(i,(r,s)=>{for(let n of t)n.write1(r,s)},(r,s)=>s)}wrap(t=null,i=null){let r=t===null?this.fmt:(n,a)=>(a=t(n,a),this.fmt(n,a)),s=i===null?this.writer:(n,a)=>{i(n,a),this.writer(n,a)};return new Eh(this.level,s,r)}chain(t){return t.wrap(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,la.format(i,...r)))}write2(t,i){this.include(t)&&(i instanceof Error?this.writer(t,this.fmt(t,i.stack)):this.writer(t,this.fmt(t,i.toString())))}write1(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}debug3(t,...i){this.write3(0,t,i)}debug2(t){this.write2(0,t)}debug1(t){this.write1(0,t)}info3(t,...i){this.write3(1,t,i)}info2(t){this.write2(1,t)}info1(t){this.write1(1,t)}warning3(t,...i){this.write3(2,t,i)}warning2(t){this.write2(2,t)}warning1(t){this.write1(2,t)}error3(t,...i){this.write3(3,t,i)}error2(t){this.write2(3,t)}error1(t){this.write1(3,t)}};Eh.DUMMY=new Eh(4);var ip=Eh;var GO=zO(QO());var MC=Object.create,lm=Object.defineProperty,BC=Object.getOwnPropertyDescriptor,kC=Object.getOwnPropertyNames,FC=Object.getPrototypeOf,UC=Object.prototype.hasOwnProperty,Sh=(e=>typeof dr<"u"?dr:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof dr<"u"?dr:t)[i]}):e)(function(e){if(typeof dr<"u")return dr.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),GC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zC=(e,t)=>{for(var i in t)lm(e,i,{get:t[i],enumerable:!0})},HC=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of kC(t))!UC.call(e,s)&&s!==i&&lm(e,s,{get:()=>t[s],enumerable:!(r=BC(t,s))||r.enumerable});return e},nd=(e,t,i)=>(i=e!=null?MC(FC(e)):{},HC(t||!e||!e.__esModule?lm(i,"default",{value:e,enumerable:!0}):i,e)),ad=GC((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a=(w,B)=>{for(var V in B)i(w,V,{get:B[V],enumerable:!0})},o=(w,B,V,Y)=>{if(B&&typeof B=="object"||typeof B=="function")for(let W of s(B))!n.call(w,W)&&W!==V&&i(w,W,{get:()=>B[W],enumerable:!(Y=r(B,W))||Y.enumerable});return w},l=w=>o(i({},"__esModule",{value:!0}),w),h={};a(h,{BroadcastChannelMessageBus:()=>he,MessageBus:()=>x,MessageBus2:()=>Z,MessageBusTask:()=>R,MessageBusTask2:()=>G,WindowMessageBridge:()=>L,WorkerMessageBridge:()=>j,createBroadcastP2PStream:()=>de,createBufferedByteBufferStream:()=>ie,createBufferedStream:()=>q,createBufferedStringStream:()=>X,dropP2PStream:()=>Ce,flowRead:()=>Pe,flowWrite:()=>Fe}),t.exports=l(h);var c=class{constructor(w=1.5){this.growthFactor=w,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(w){if(this.count===this.capacity){let B=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,B);let V=new Array(B);for(let Y=0;Y<this.count;Y++)V[Y]=this.buffer[(this.head+Y)%this.capacity];this.buffer=V,this.head=0,this.tail=this.count,this.capacity=B}this.buffer[this.tail]=w,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let w=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,w}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},d=new ArrayBuffer(8),f=new Float64Array(d),u=new Uint32Array(d),p=new Uint16Array(d),g=ArrayBuffer;try{g=self.HTMLImageElement||g}catch{}var _=typeof SharedArrayBuffer<"u";function y(w){if(typeof w!="object"||w===null||w instanceof Date||w instanceof ArrayBuffer||_&&w instanceof SharedArrayBuffer||w instanceof Blob||w instanceof FormData||w instanceof Function||w instanceof Uint8ClampedArray||w instanceof g)return w;if(Array.isArray(w))return w.map(y);{let B={};for(let V in w)Object.hasOwnProperty.call(w,V)&&(B[V]=y(w[V]));return B}}function m(w,B){return O(w,B,()=>[])}function O(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var b=class{constructor(w){this.maxResources=w,this.idle=new c,this.isClosed=!1,this.resources=w}acquire(w){this.isClosed?Promise.resolve(!1).then(w):this.resources>0?(this.resources--,Promise.resolve(!0).then(w)):this.idle.enqueue(w)}acquireSync(){return new Promise(w=>{this.acquire(w)})}release(){if(!this.isClosed){let w=this.idle.dequeue();w?Promise.resolve(!0).then(w):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let w=this.idle.dequeue();Promise.resolve(!1).then(w)}}};function v(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function E(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}var T=v(),P=T.WeakRef||(w=>w);function A(w){if(w!=null){if(typeof w=="object")return new P(w);console.error(w,w instanceof Object,typeof w);return}}function C(w){return w==null?void 0:w.deref()}var M="_MSG_BUS_RPC_",H=300*1e3,k=(w=>(w.PUBLISH="publish",w.SUBSCRIBE="subscribe",w.PUSH="push",w.PULL="pull",w))(k||{}),F=class{constructor(w){this.bus=w}processRemoteMessage(w,B){let V=A(B),Y=w.topic,W=w.type,ne=w.message;switch(W){case"pull":this.bus.pull(Y,ue=>{this.push(Y,ue,C(V))});break;case"subscribe":this.bus.subscribe(Y,ue=>{this.publish(Y,ue,C(V))});break;case"publish":this.bus.publish(Y,ne,this,C(V));break;case"push":this.bus.push(Y,ne,this,C(V));break;default:console.debug("unknown message type "+W)}}rpcCall(w,B,V,Y=H){let W=A(V),ne=new Promise(ue=>{let Re=this.bus.uniqueRpcTopic(w);this.publish(w,{message:B,reply:Re},C(W)),this.bus.pull(Re,(Ue,je,dt)=>{ue({message:Ue,bridge:je,source:A(dt)})})});return Y>0?Promise.race([ne,new Promise((ue,Re)=>{setTimeout(Re,Y)})]):ne}},j=class extends F{constructor(w,B){super(w),this.worker=B,B.onmessage=V=>{this.processRemoteMessage(V.data,void 0)}}publish(w,B){this.postMessage(w,"publish",B)}subscribe(w){this.postMessage(w,"subscribe",null)}push(w,B){this.postMessage(w,"push",B)}pull(w){this.postMessage(w,"pull",null)}rpcCall(w,B,V=H){return super.rpcCall(w,B,void 0,V)}postMessage(w,B,V){let Y={topic:w,type:B,message:V};this.worker.postMessage(Y)}discard(){this.worker.terminate()}},L=class extends F{constructor(w){super(w),window.addEventListener("message",B=>{this.processRemoteMessage(B.data,B.source)},!1)}publish(w,B,V){this.postMessage(w,"publish",B,V)}subscribe(w,B){if(B===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(w,"subscribe",null,B)}push(w,B,V){this.postMessage(w,"push",B,V)}pull(w,B){if(B===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(w,"pull",null,B)}postMessage(w,B,V,Y){let W={topic:w,type:B,message:V};Y&&Y.postMessage(W,"*")}},R=class{constructor(w){this.isRunning=!0,this.callback=w}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(w,B,V,Y){try{w=Y?w:y(w),this.callback(w,B,V)}catch(W){console.error(W)}}},x=class{constructor(w=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=w}uniqueRpcTopic(w){return`${M}-${w}-${this.uuid}-${this.rpcTicket++}`}publish(w,B,V,Y){let W=this.subscribed[w];if(W){let ne;for(let ue of W)ue.running()?ue.execute(B,V,Y,this.unsafe):(ne=ne||new Array,ne.push(ue));if(ne)for(let ue of ne)E(W,ue)}else console.debug("no sub on topic: "+w)}subscribe(w,B){let V=new R(B);return m(this.subscribed,w).push(V),V}push(w,B,V,Y){let W=!1,ne=this.pulled[w];if(ne){for(;ne.length>0;){let ue=ne.shift();if(ue.running()){ue.execute(B,V,Y,this.unsafe),W=!0;break}}ne.length===0&&delete this.pulled[w]}W||m(this.pushed,w).push({message:B,bridge:V,source:A(Y)})}pull(w,B){let V=new R(B),Y=this.pushed[w];if(Y){let W=Y.shift();V.execute(W.message,W.bridge,C(W.source),this.unsafe),Y.length===0&&delete this.pushed[w]}else m(this.pulled,w).push(V);return V}pullA(w){return new Promise(B=>{this.pull(w,(V,Y,W)=>{B({message:V,bridge:Y,source:A(W)})})})}rpcService(w,B){this.subscribe(w,(V,Y,W)=>{let{message:ne,reply:ue}=V;try{let Re=B(ne);if(Re instanceof Promise){let Ue=A(W);Re.then(je=>{this.rpcReply(je,ue,Y,C(Ue))},je=>{console.error(je),this.rpcReply(void 0,ue,Y,C(Ue))})}else this.rpcReply(Re,ue,Y,W)}catch(Re){console.error(Re),this.rpcReply(void 0,ue,Y,W)}})}rpcCall(w,B,V=H){let Y=new Promise(W=>{let ne=this.uniqueRpcTopic(w);this.publish(w,{message:B,reply:ne}),this.pull(ne,(ue,Re,Ue)=>{W({message:ue,bridge:Re,source:A(Ue)})})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}rpcReply(w,B,V,Y){V?V.push(B,w,Y):this.push(B,w)}},I="_MSG_BUS_RPC_";function S(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}function D(w,B){return N(w,B,()=>[])}function N(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var G=class{constructor(w,B){this.callback=w,this.unsafe=B,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(w){try{w=this.unsafe?w:y(w),this.callback(w)}catch(B){console.error(B)}}},z=class{constructor(w=crypto.randomUUID()){this.uuid=w,this.rpcTicket=0}subscribeOnce(w,B){let V=this.subscribe(w,Y=>{V.cancel(),B(Y)});return V}pullA(w){return new Promise(B=>{this.pull(w,B)})}rpcService(w,B){let V=Y=>{try{let{message:W,replyTopic:ne}=Y;try{let ue=B(W);ue instanceof Promise?ue.then(Re=>{this.publish(ne,{success:!0,result:Re})}).catch(Re=>{console.error(Re),this.publish(ne,{success:!1,err:String(Re)})}):this.publish(ne,{success:!0,result:ue})}catch(ue){this.publish(ne,{success:!1,err:String(ue)})}}finally{this.pull(w,V)}};this.pull(w,V)}rpcCall(w,B,V=0){let Y=new Promise((W,ne)=>{let ue=`${I}-${w}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ue,Re=>{Re.success?W(Re.result):ne(new Error(Re.err))}),this.push(w,{message:B,replyTopic:ue})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}},Z=class extends z{constructor(w=!1){super(),this.unsafe=w,this.subscribed={},this.pulled={},this.pushed={}}publish(w,B){let V=this.subscribed[w];if(V){let Y;for(let W of V)W.running()?W.execute(B):(Y=Y||new Array,Y.push(W));if(Y)for(let W of Y)S(V,W)}}subscribe(w,B){let V=new G(B,this.unsafe);return D(this.subscribed,w).push(V),V}push(w,B){let V=!1,Y=this.pulled[w];if(Y){for(;Y.length>0;){let W=Y.shift();if(W&&W.running()){W.execute(B),V=!0;break}}Y.length===0&&delete this.pulled[w]}V||D(this.pushed,w).push(B)}pull(w,B){let V=new G(B,this.unsafe);return this.repull(w,V),V}repull(w,B){let V=this.pushed[w];if(V){let Y=V.shift();Y&&(B.execute(Y),V.length===0&&delete this.pushed[w])}else D(this.pulled,w).push(B)}},se=class extends z{constructor(w=crypto.randomUUID()){super(w),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(w,B){console.debug("BC",this.uuid,"PUBLISH",w,B),this.broadcastPublish(w,B)}subscribe(w,B){console.debug("BC",this.uuid,"SUBSCRIBE",w);let V=new G(B,!0);return D(this.subscribed,w).push(V),V}push(w,B){let V=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",w,`(${V})`,B),D(this.pushed,w).push({id:V,message:B}),this.broadcastPushedHeadMessage(w)}pull(w,B){console.debug("BC",this.uuid,"PULL",w);let V=new G(B,!0);return D(this.pulled,w).push(V),this.broadcastWhoHas(w),V}broadcastPushedHeadMessage(w){let B=this.pushed[w];B&&B[0]&&this.broadcastIHave(w,B[0].id)}onReceivedPublish(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"PUBLISH",B,"message",V);let Y=this.subscribed[B];if(Y){let W;for(let ne of Y)ne.running()?ne.execute(V):(W=W||new Array,W.push(ne));if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.subscribed[B]}}onReceivedWhoHas(w,B){console.debug("BCMSG(",this.uuid,")","from",w,"WHOHAS",B),this.broadcastPushedHeadMessage(B)}onReceivedIHave(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"IHAVE",B,"id",V);let Y=this.pulled[B];if(Y){let W;for(let ne of Y)if(ne.running()){this.broadcastINeed(B,w,V);break}else W=W||new Array,W.push(ne);if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.pulled[B]}}onReceivedINeed(w,B,V,Y){if(console.debug("BCMSG(",this.uuid,")","from",w,"INEED",B,"source",V,"id",Y),this.uuid===V){let W=this.pushed[B];if(W&&W[0]&&W[0].id===Y){let{message:ne}=W.shift();this.broadcastIGive(B,Y,w,ne),this.broadcastPushedHeadMessage(B),W.length===0&&delete this.pushed[B]}}}onReceivedIGive(w,B,V,Y,W){console.debug("BCMSG(",this.uuid,")","from",w,"IGIVE",B,"id",V,"target",Y,"message",W);let ne=this.pulled[B];if(ne&&this.uuid===Y){let ue=!1;for(;ne.length>0;){let Re=ne.shift();if(Re.running()){Re.execute(W),ue=!0;break}}ue||this.push(B,W),ne.length===0&&delete this.pulled[B]}}},he=class extends se{constructor(w,B=crypto.randomUUID()){super(B),this.bc=new BroadcastChannel(w),this.bc.onmessage=V=>{this.onMessage(V.data)}}onMessage(w){let{type:B,uuid:V,topic:Y}=w;switch(B){case"PUBLISH":{let{message:W}=w;this.onReceivedPublish(V,Y,W);break}case"WHOHAS":{this.onReceivedWhoHas(V,Y);break}case"IHAVE":{let{id:W}=w;this.onReceivedIHave(V,Y,W);break}case"INEED":{let{source:W,id:ne}=w;this.onReceivedINeed(V,Y,W,ne);break}case"IGIVE":{let{target:W,id:ne,message:ue}=w;this.onReceivedIGive(V,Y,ne,W,ue);break}default:console.warn("unsupported",w)}}broadcastPublish(w,B){this.post({type:"PUBLISH",uuid:this.uuid,topic:w,message:B})}broadcastWhoHas(w){this.post({type:"WHOHAS",uuid:this.uuid,topic:w})}broadcastIHave(w,B){this.post({type:"IHAVE",uuid:this.uuid,topic:w,id:B})}broadcastINeed(w,B,V){this.post({type:"INEED",uuid:this.uuid,topic:w,source:B,id:V})}broadcastIGive(w,B,V,Y){this.post({type:"IGIVE",uuid:this.uuid,topic:w,id:B,target:V,message:Y})}post(w){this.bc.postMessage(w),Promise.resolve().then(()=>{this.onMessage(w)})}},pe=Symbol("BLOCKING_QUEUE_RESET"),Se=class{constructor(w,B=()=>1){if(this.maxSize=w,this.itemSizeOf=B,this.queue=new c,this.waitingConsumers=new c,this.waitingProducers=new c,this.queueSize=0,this.closePromise=null,this.closeResolve=null,w<=0)throw new Error("Max size must be greater than 0")}enqueue(w){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let B=await new Promise(V=>{this.waitingProducers.enqueue(V)});return console.debug("queue is not full",this.size(),B),B?(this.innerEnqueue(w),!0):!1})():(this.innerEnqueue(w),!0)}innerEnqueue(w){if(this.waitingConsumers.isEmpty())this.queue.enqueue(w),this.queueSize+=this.itemSizeOf(w),console.debug("queue pushed",w,"size",this.queueSize);else{let B=this.waitingConsumers.dequeue();Promise.resolve(w).then(B),console.debug("queue direct",w,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let w=this.waitingConsumers.dequeue();Promise.resolve(pe).then(w)}return setTimeout(()=>this.closeResolve(),0),pe}else return new Promise(w=>{this.waitingConsumers.enqueue(w)});else{let w=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(w),!this.waitingProducers.isEmpty()){let B=this.waitingProducers.dequeue();Promise.resolve(!0).then(B)}return w}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(w=>{for(this.closeResolve=w;!this.waitingProducers.isEmpty();){let B=this.waitingProducers.dequeue();Promise.resolve(!1).then(B)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let B=this.waitingConsumers.dequeue();Promise.resolve(pe).then(B)}w()}})),this.closePromise}};function q(w,B,V=Number.MAX_SAFE_INTEGER){let Y=new Se(V,B),W=new ReadableStream({pull(ue){let Re=!0,Ue=(async()=>{let je=new Array;do{let dt=Y.dequeue();if(dt instanceof Promise){Re=!1;let Ot=await dt;Ot===pe?ue.close():je.push(Ot)}else{let Ot=dt;Ot===pe?ue.close():je.push(Ot)}}while(Y.size()>0);if(je.length>0){let dt=w(je);ue.enqueue(dt)}})();if(!Re)return console.debug("read stream stucked --------------------------------------"),Ue},async cancel(){console.debug("buffered readable cancel"),await Y.close()}}),ne=new WritableStream({write(ue,Re){let Ue=!0,je=(async()=>{let dt=Y.enqueue(ue);typeof dt=="boolean"?dt||Re.error(new Error("Write stream closed")):(Ue=!1,await dt||Re.error(new Error("Write stream closed")))})();if(!Ue)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),je},async close(){console.debug("buffered writable closing",Y.size()),await Y.close(),console.debug("buffered writable closed",Y.size())},async abort(){console.debug("buffered writable aborting",Y.size()),await Y.close(),console.debug("buffered writable aborted",Y.size())}});return{readable:W,writable:ne}}function X(w=Number.MAX_SAFE_INTEGER){return q(B=>B.join(""),B=>B.length,w)}function ie(w=Number.MAX_SAFE_INTEGER){return q(B=>{let V=new Uint8Array(B.reduce((W,ne)=>W+ne.byteLength,0)),Y=0;return B.forEach(W=>{V.set(W,Y),Y+=W.byteLength}),V},B=>B.byteLength,w)}function de(w){return new Promise((B,V)=>{let Y=new BroadcastChannel(w),W=new Se(1),ne=new b(1),ue=null,Re=!1,Ue=!1,je=!1;Y.onmessage=dt=>{let Ot=dt.data,{type:Lt}=Ot;if(console.debug("p2p",w,"type",Lt,"data",Lt==="DATA"&&Ot.data),Lt==="DATA")W.enqueue(Ot.data);else if(Lt==="HI"){if(!ue){Y.postMessage({type:"HI"});let Ge=0;ue={rs:new ReadableStream({async pull(qe){let me=await W.dequeue();me===pe?(await Q(),qe.close()):(qe.enqueue(me),Y.postMessage({type:"ACK"}))},cancel(){return Q()}}),ws:new WritableStream({async write(qe,me){await ne.acquireSync()?Y.postMessage({type:"DATA",id:Ge++,data:qe}):(hi(),me.error(new Error("Write stream closed")))},close(){hi()},abort(){hi()}})},B(ue)}}else Lt==="REND"?ue?ne.close():ke("REND1"):Lt==="WEND"?ue?W.close():ke("WEND1"):Lt==="ACK"&&ne.release();function hi(){Re||(Re=!0,console.debug(w,"p2p write stream closed"),ne.close(),Y.postMessage({type:"WEND"}),Ue&&(console.debug(w,"p2p channel closed on ws"),Y.close()))}async function Q(){Ue||(Ue=!0,console.debug(w,"p2p read stream closed"),Y.postMessage({type:"REND"}),await W.close(),Re&&(console.debug(w,"p2p channel closed on rs"),Y.close()))}async function ke(Ge){je||(je=!0,console.debug(w,"p2p channel connection released on",Ge),ne.close(),W.close(),ue?(ue.rs.locked||(console.debug(w,"p2p unlocked read stream direct cancel"),ue.rs.cancel()),ue.ws.locked||(console.debug(w,"p2p unlocked write stream direct close"),ue.ws.close())):(Y.postMessage({type:"HI"}),Y.close()),V(new Error("p2p channel connection released")))}},Y.postMessage({type:"HI"})})}function Ce(w){return new Promise(B=>{let V=new BroadcastChannel(w);V.onmessage=Y=>{let W=Y.data,{type:ne}=W;ne==="HI"&&(V.postMessage({type:"REND"}),V.close(),B())},V.postMessage({type:"REND"})})}async function De(w){try{return await de(w)}catch(B){B.message!=="p2p channel connection released"&&console.error(B)}}async function Fe(w,B,V=10*1024*1024,Y=!0){let W=await De(w);if(!W)return!1;let ne=!1;try{let ue,Re=Ue=>{if(!ue)if(!Y)ue=W.ws.getWriter();else if(typeof Ue=="string"){let je=X(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}else{let je=ie(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}return ue.write(Ue)};if(Array.isArray(B))for(let Ue of B)await Re(Ue);else await B({write:Re,get desiredSize(){return((ue==null?void 0:ue.desiredSize)||0)+10}});ue&&await ue.close(),ne=!0}catch(ue){console.error(ue)}finally{return W.rs.cancel(),ne}}async function Pe(w,B){var V,Y;let W=await De(w);if(W)try{let ne=W.rs.getReader();for((V=B.start)==null?void 0:V.call(B);;){let{value:ue,done:Re}=await ne.read();if(ue!==void 0){let Ue;if(B.update instanceof Promise?Ue=await B.update(ue):Ue=B.update(ue),Ue){await ne.cancel();break}}if(Re){(Y=B.end)==null||Y.call(B);break}}}catch(ne){console.error(ne)}finally{W.ws.close()}}}),jC={UNAUTHORIZED:"Not logged in yet, please log in and try again",LOGIN_FAIL:"The login status is invalid",PERMISSION_DENIED:"No permission or project does not exist",PERMISSION_DENIED1:"No permission",PRJ_NOT_EXIST:"No permission or project does not exist",ERROR_PATH:"No permission or project does not exist",PROJECT_NOT_FOUND:"The project was not found",PERMISSION_DENIED_PARAMS:"No permission to operate {type}",DATA_NOT_FOUND:"Data not found",PARAMS_DATA_NOT_FOUND:"The {type} data was not found",REQUEST_PARAM_ILLEGAL:"Parameter error",REQUEST_PARAM_ILLEGAL1:"Parameter error",REQUEST_PARAMS_ILLEGAL2:"The {type} parameter request is incorrect",REQUEST_PARAMS_NOT_NULL:"The {type} parameter of the request cannot be empty",REQUEST_PARAMS_NOT_ALL_NULL:"The {type} parameter of the request cannot be empty simultaneously",REQUEST_PARAMS_MUST_ARRAY:"The request parameter {type} must be an array",REQUEST_PARAMS_MUST_STRING:"The request parameter {type} must be a string",REQUEST_PARAMS_MUST_NUMBER:"The request parameter {type} must be a number",REQUEST_PARAMS_MUST_NUMBER_ARRAY:"The request parameter {type} must be a numeric array",REQUEST_PARAMS_MUST_STRING_ARRAY:"The request parameter {type} must be a string array",REQUEST_PARAMS_LENGTH_ERROR:"The length of the request parameter {type} is incorrect",REQUEST_PARAMS_TYPE_ERROR:"The request parameter {type} is of incorrect type",ILLEGAL_NAME:'The name is illegal and contains illegal characters such as /:*?"<>|',ILLEGAL_NAME1:'The name is illegal and contains illegal characters such as /:*?"<>|',ILLEGAL_NAME_ZH:"The name cannot contain Chinese characters",UUID_ERROR:"uuid error",DUPLICATE_DATA:"Duplicate title",DUPLICATE_DATA1:"Library duplicate name",DUPLICATE_DATA_PARAMS:"{type} Duplicate data",UPLOAD_LIMIT:"Document {documentName} size over 15MB, it is too big to save in the server, please modify and then try again.",MORE_THAN_LIMIT:"Exceed the maximum limit",FILE_MORE_THAN_LIMIT:"Exceed the maximum upload limit of {type}",PARAMS_MORE_THAN_LIMIT:"Exceed the maximum upload limit of the parameter {type}",IMAGE_MORE_THAN_LIMIT_PARAMS:"The picture exceeds the maximum upload limit",FILE_MORE_THAN_LIMIT_PARAMS:"The file exceeds the maximum upload limit",END_MUST_AFTER_START:"The start time cannot be later than the end time",FILE_READ_ONLY:"The project file eprj or library file elib property was set as read only, please enable the read only property at File Manager and try again, and contact with support",FILE_READ_ONLY1:"The project file eprj or library file elib property was set as read only, please enable the read only property at File Manager and try again, and contact with support",DATA_NOT_EXIST:"document {documentName} not exists",REQUEST_PARAMS_TIME_ERROR:"The time request parameter is incorrect",FILES_PATH_NOT_FOUND:"The file address cannot be found",FILES_DATA_NOT_FOUND:"The file data cannot be found",FILES_TYPE_ERROR:"File type error",FILES_TYPE_MUST_BE_ONE:"The file type must be {type}",SET_WATERMARK_FAIL:"Watermark setting failed",MYSQL_CRUD_ERROR:"{type} data execution failed. Please contact technical support for resolution",PARAMS_JSON_FAILED:"{type} data parsing failed",MYSQL_ERROR:"Database operation anomaly",NOT_FOUND:"The request does not exist",PRJ_NAME_EXISTS:"The name of the project already exists",BACKUP_NAME_EXISTS:"Backup Name already exists",TITLE_ILLEGAL_LEN:"The {documentName} length must be 1~128 bytes!",LIB_NOT_EXIST:"The component library does not exist",CONFIG_API_URLS_ERROR:"Real-time prices and inventory are not enabled. Please contact the administrator",ONE_CLICK_ORDER_NOT_OPEN:"The order placement function is not enabled. Please contact the administrator",MATERIAL_NOT_OPEN:"The material warehouse is not open. Please contact the administrator",SNAPSHOT_DEPTH_LIMIT:"There is a snapshot near the latest node or the snapshot has been applied for",OCR_SYMBOL_URL_ERROR:"The OCR request address is not configured",USER_DATA_NOT_FOUND:"The user does not exist",USER_DISABLE_ERROR:"The account has been deactivated",USER_EXISTS_LOGIN_ERROR:"The user has logged in elsewhere",USER_UNAUTHORIZED_MODULES_ERROR:"This account has not authorized the module",USER_UNAUTHORIZED_ACCESS_ERROR:"Access type error",ADMIN_NOT_CHANGE_PASSWORD:"The super administrator cannot reset the password",SAME_PASSWORD_NEW_PASSWORD:"The original password is the same as the new one",USER_ONLINE_REGISTRATION_FAILED:"The registration of the user online failed",USER_PASSWORD_CAN_NOT_DEFAULT:"The default password cannot be used",USER_BEFORE_PASSWORD_ERROR:"The original password is incorrect",USER_PASSWORD_LENGTH_ERROR:"The password length is 8 to 255 characters",ORG_ROLE_NOT_CREATE:"System roles cannot be created. Please make the necessary modifications",ORG_ROLE_NAME_DUPLICATE:"The character name already exists. Please modify it",ORG_ROLE_ORIGIN_ERROR:"Unknown character source {message}",ORG_ROLE_NOT_DEFAULT:"This character is not a preset one and cannot be operated",ADMIN_ROLE_NOT_CHANGE:"Administrator privileges do not allow for modification",ADMIN_NOT_CHANGE_STATUS:"The admin account cannot change its status",PROJECT_ARCHIVED:"The project has been locked",PROJECT_UUID_NULL:"The project uuid cannot be empty",PROJECT_UUID_ERROR:"uuid error or the project uuid already exists",PROJECT_OR_TEAM_UUID_ERROR:"The project uuid is incorrect or the team uuid already exists",PROJECT_NOT_PERSON_ERROR:"Personal projects are not allowed to be created",PROJECT_DUPLICATE_NAME:"Duplicate title",ANNOTATION_HAS_BE_FOUND:"The annotation has been created",ANNOTATION_NOT_FOUND:"The annotation block does not exist",ANNOTATION_CREATE_ERROR:"The annotation block creation failed",ANNOTATION_UPDATE_ERROR:"The update of the annotation block failed",ANNOTATION_DELETE_ERROR:"The annotation failed to be deleted",PROJECT_DUPLICATE_PATH:"The same path cannot be created",TEAM_NOT_FOUND:"The team does not exist",TEAM_UUID_NULL:"The team uuid cannot be empty",TEAM_FOLDER_ERROR:"The parent folder does not exist or does not belong to the current team",TEAM_FOLDER_UUID_ERROR:"The folder uuid is incorrect or the project uuid already exists",TEAM_URL_DUPLICATE:"Team link repetition",TEAM_CAN_NOT_DELETE:"There are still projects in the team. Please transfer or delete them first",COMPONENT_UUID_NULL:"The uuid of a component cannot be empty",COMPONENT_DATA_NOT_FOUND:"The component library data does not exist",COMPONENT_NAME_DUPLICATE:"Component libraries cannot have the same name",COMPONENT_TYPE_ERROR:"Library type error",DELETE_SON_CATEGORY:"The subcategories need to be deleted first",LICENSE:"License not found",START_TIME:"The start time of the license is incorrect",END_TIME:"The end time of the license is incorrect",PROJECT_LIMIT:"Number of projects created exceeds the limit",USER_LIMIT:"The maximum number of accounts has been reached",ONLINE_NUMBER_LIMIT:"The maximum number of online users has been reached",LIMIT_PCB:"The PCB authorization quota has been reached and the addition failed",LIMIT_SCH:"The schematic authorization number is full, and the addition failed",LIMIT_PANEL:"The panel authorization number is full and the addition failed",TIME_ERROR:"If the system time is incorrect, please restart the server or fix the system time. After fixing, the private service needs to be restarted",LICENSE_ERROR:"Authorization error",LICENSE_TYPE_ERROR:"The type of authorized application is incorrect",LICENSE_ORIGIN_ERROR:"Unknown authorized application {type}",BRANCH_DATA_NOT_FOUND:"There is no engineering branch",PARENT_UUID_ERROR:"parent uuid error",BRANCH_MUST_AFTER_NODE:"The branch must be after the node",BRANCH_NAME_ERROR:"Incorrect branch name",BRANCH_NAME_DUPLICATE:"The branch name already exists",BRANCH_UUID_ERROR:"The branch uuid is incorrect",BRANCH_NODE_SET_ERROR:"Nodes cannot be set as default branches or marked as master",BRANCH_DELETE_MAIN_ERROR:"Nodes or branches on the main branch cannot be deleted",BRANCH_CHECK_OUT_ERROR:"There are documents that have been checked out",DOCUMENT_UUID_ERROR:"The document uuid is incorrect",UPDATE_FAILED:"Update failed",INNER_API_KEY_ERROR:"The ApiKey of the internal interface of the server is incorrect",BRANCH_MORE_THAN_LIMIT:"The version exceeds the maximum limit",WORKSPACE_API_ERROR:"The workspace request response is abnormal"},VC={UNAUTHORIZED:"\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u8BD5",LOGIN_FAIL:"\u767B\u5F55\u72B6\u6001\u5F02\u5E38",PERMISSION_DENIED:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",PERMISSION_DENIED1:"\u6CA1\u6709\u6743\u9650",PRJ_NOT_EXIST:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",ERROR_PATH:"\u6CA1\u6709\u6743\u9650\u6216\u5DE5\u7A0B\u4E0D\u5B58\u5728",PROJECT_NOT_FOUND:"\u5DE5\u7A0B\u672A\u627E\u5230",PERMISSION_DENIED_PARAMS:"\u6CA1\u6709\u6743\u9650\u64CD\u4F5C{type}",DATA_NOT_FOUND:"\u6570\u636E\u672A\u627E\u5230",PARAMS_DATA_NOT_FOUND:"{type}\u6570\u636E\u672A\u627E\u5230",REQUEST_PARAM_ILLEGAL:"\u53C2\u6570\u9519\u8BEF",REQUEST_PARAM_ILLEGAL1:"\u53C2\u6570\u9519\u8BEF",REQUEST_PARAMS_ILLEGAL2:"\u8BF7\u6C42{type}\u53C2\u6570\u9519\u8BEF",REQUEST_PARAMS_NOT_NULL:"\u8BF7\u6C42{type}\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A",REQUEST_PARAMS_NOT_ALL_NULL:"\u8BF7\u6C42{type}\u53C2\u6570\u4E0D\u80FD\u540C\u65F6\u4E3A\u7A7A",REQUEST_PARAMS_MUST_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u7EC4",REQUEST_PARAMS_MUST_STRING:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32",REQUEST_PARAMS_MUST_NUMBER:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u5B57",REQUEST_PARAMS_MUST_NUMBER_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u6570\u5B57\u6570\u7EC4",REQUEST_PARAMS_MUST_STRING_ARRAY:"\u8BF7\u6C42\u53C2\u6570{type}\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4",REQUEST_PARAMS_LENGTH_ERROR:"\u8BF7\u6C42\u53C2\u6570{type}\u957F\u5EA6\u9519\u8BEF",REQUEST_PARAMS_TYPE_ERROR:"\u8BF7\u6C42\u53C2\u6570{type}\u7C7B\u578B\u9519\u8BEF",ILLEGAL_NAME:'\u540D\u79F0\u975E\u6CD5, \u5305\u542B /:*?"<>| \u7B49\u975E\u6CD5\u5B57\u7B26',ILLEGAL_NAME1:'\u540D\u79F0\u975E\u6CD5, \u5305\u542B /:*?"<>| \u7B49\u975E\u6CD5\u5B57\u7B26',ILLEGAL_NAME_ZH:"\u540D\u79F0\u4E0D\u80FD\u5305\u542B\u4E2D\u6587",UUID_ERROR:"uuid \u9519\u8BEF",DUPLICATE_DATA:"\u6807\u9898\u5DF2\u5B58\u5728",DUPLICATE_DATA1:"\u5E93\u91CD\u540D",DUPLICATE_DATA_PARAMS:"{type}\u91CD\u590D\u6570\u636E",UPLOAD_LIMIT:"\u6587\u6863 {documentName} \u8D85\u8FC715MB\uFF0C\u5BFC\u81F4\u65E0\u6CD5\u6B63\u5E38\u4FDD\u5B58\uFF0C\u8BF7\u4FEE\u6539\u540E\u518D\u5BFC\u5165",MORE_THAN_LIMIT:"\u8D85\u8FC7\u6700\u5927\u9650\u5236",FILE_MORE_THAN_LIMIT:"\u8D85\u8FC7{type}\u6700\u5927\u4E0A\u4F20\u9650\u5236",PARAMS_MORE_THAN_LIMIT:"\u8D85\u8FC7\u53C2\u6570{type}\u7684\u6700\u5927\u4E0A\u4F20\u9650\u5236",IMAGE_MORE_THAN_LIMIT_PARAMS:"\u56FE\u7247\u8D85\u8FC7\u6700\u5927\u4E0A\u4F20\u9650\u5236",FILE_MORE_THAN_LIMIT_PARAMS:"\u6587\u4EF6\u8D85\u8FC7\u6700\u5927\u4E0A\u4F20\u9650\u5236",END_MUST_AFTER_START:"\u5F00\u59CB\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E\u7ED3\u675F\u65F6\u95F4",FILE_READ_ONLY:"\u5DE5\u7A0B\u6587\u4EF6eprj\u6216\u5E93\u6587\u4EF6elib\u5C5E\u6027\u53D8\u4E3A\u53EA\u8BFB\uFF0C\u8BF7\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u53D6\u6D88\u53EA\u8BFB\u540E\u518D\u8BD5\uFF0C\u5E76\u8054\u7CFB\u6280\u672F\u652F\u6301",FILE_READ_ONLY1:"\u5DE5\u7A0B\u6587\u4EF6eprj\u6216\u5E93\u6587\u4EF6elib\u5C5E\u6027\u53D8\u4E3A\u53EA\u8BFB\uFF0C\u8BF7\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u53D6\u6D88\u53EA\u8BFB\u540E\u518D\u8BD5\uFF0C\u5E76\u8054\u7CFB\u6280\u672F\u652F\u6301",DATA_NOT_EXIST:"\u6587\u6863{documentName}\u4E0D\u5B58\u5728",REQUEST_PARAMS_TIME_ERROR:"\u65F6\u95F4\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF",FILES_PATH_NOT_FOUND:"\u627E\u4E0D\u5230\u6587\u4EF6\u5730\u5740",FILES_DATA_NOT_FOUND:"\u627E\u4E0D\u5230\u6587\u4EF6\u6570\u636E",FILES_TYPE_ERROR:"\u6587\u4EF6\u7C7B\u578B\u9519\u8BEF",FILES_TYPE_MUST_BE_ONE:"\u6587\u4EF6\u7C7B\u578B\u5FC5\u987B\u4E3A{type}",SET_WATERMARK_FAIL:"\u6C34\u5370\u8BBE\u7F6E\u5931\u8D25",MYSQL_CRUD_ERROR:"{type}\u6570\u636E\u6267\u884C\u5931\u8D25, \u8BF7\u8054\u7CFB\u6280\u672F\u652F\u6301\u89E3\u51B3",PARAMS_JSON_FAILED:"{type}\u6570\u636E\u89E3\u6790\u5931\u8D25",MYSQL_ERROR:"\u6570\u636E\u5E93\u64CD\u4F5C\u5F02\u5E38",NOT_FOUND:"\u8BF7\u6C42\u4E0D\u5B58\u5728",PRJ_NAME_EXISTS:"\u5DE5\u7A0B\u540D\u79F0\u5DF2\u5B58\u5728",BACKUP_NAME_EXISTS:"\u5907\u4EFD\u540D\u79F0\u5DF2\u5B58\u5728",TITLE_ILLEGAL_LEN:"{documentName}\u957F\u5EA6\u5FC5\u987B\u4E3A1~128\u5B57\u7B26\u957F\u5EA6\uFF01",LIB_NOT_EXIST:"\u5143\u4EF6\u5E93\u4E0D\u5B58\u5728",CONFIG_API_URLS_ERROR:"\u5B9E\u65F6\u4EF7\u683C\u548C\u5E93\u5B58\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",ONE_CLICK_ORDER_NOT_OPEN:"\u4E00\u4EF6\u4E0B\u5355\u529F\u80FD\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",MATERIAL_NOT_OPEN:"\u7269\u6599\u5E93\u672A\u5F00\u542F, \u8BF7\u8054\u7CFB\u7BA1\u7406\u5458",SNAPSHOT_DEPTH_LIMIT:"\u6700\u65B0\u8282\u70B9\u9644\u8FD1\u5B58\u5728\u5FEB\u7167\u6216\u5FEB\u7167\u5DF2\u88AB\u7533\u8BF7",OCR_SYMBOL_URL_ERROR:"OCR\u8BF7\u6C42\u5730\u5740\u672A\u914D\u7F6E",USER_DATA_NOT_FOUND:"\u7528\u6237\u4E0D\u5B58\u5728",USER_DISABLE_ERROR:"\u8D26\u53F7\u5DF2\u505C\u7528",USER_EXISTS_LOGIN_ERROR:"\u7528\u6237\u5DF2\u5728\u522B\u7684\u5730\u65B9\u767B\u5F55",USER_UNAUTHORIZED_MODULES_ERROR:"\u8BE5\u8D26\u53F7\u672A\u6388\u6743\u6A21\u5757",USER_UNAUTHORIZED_ACCESS_ERROR:"\u8BBF\u95EE\u7C7B\u578B\u9519\u8BEF",ADMIN_NOT_CHANGE_PASSWORD:"\u8D85\u7EA7\u7BA1\u7406\u5458\u65E0\u6CD5\u91CD\u7F6E\u5BC6\u7801",SAME_PASSWORD_NEW_PASSWORD:"\u539F\u5BC6\u7801\u8DDF\u65B0\u5BC6\u7801\u76F8\u540C",USER_ONLINE_REGISTRATION_FAILED:"\u767B\u8BB0\u7528\u6237\u5728\u7EBF\u5931\u8D25",USER_PASSWORD_CAN_NOT_DEFAULT:"\u4E0D\u80FD\u4F7F\u7528\u9ED8\u8BA4\u5BC6\u7801",USER_BEFORE_PASSWORD_ERROR:"\u539F\u5BC6\u7801\u9519\u8BEF",USER_PASSWORD_LENGTH_ERROR:"\u5BC6\u7801\u957F\u5EA6\u4E3A8-255\u4F4D",ORG_ROLE_NOT_CREATE:"\u4E0D\u80FD\u521B\u5EFA\u7CFB\u7EDF\u89D2\u8272, \u8BF7\u4FEE\u6539",ORG_ROLE_NAME_DUPLICATE:"\u89D2\u8272\u540D\u79F0\u5DF2\u5B58\u5728, \u8BF7\u4FEE\u6539",ORG_ROLE_ORIGIN_ERROR:"\u672A\u77E5\u7684\u89D2\u8272\u6765\u6E90{message}",ORG_ROLE_NOT_DEFAULT:"\u8BE5\u89D2\u8272\u4E0D\u662F\u9884\u8BBE\u89D2\u8272, \u4E0D\u80FD\u64CD\u4F5C",ADMIN_ROLE_NOT_CHANGE:"\u7BA1\u7406\u5458\u6743\u9650\u4E0D\u5141\u8BB8\u4FEE\u6539",ADMIN_NOT_CHANGE_STATUS:"admin\u8D26\u53F7\u4E0D\u80FD\u66F4\u6539\u72B6\u6001",PROJECT_ARCHIVED:"\u5DE5\u7A0B\u5DF2\u88AB\u9501\u5B9A",PROJECT_UUID_NULL:"\u5DE5\u7A0Buuid\u4E0D\u80FD\u4E3A\u7A7A",PROJECT_UUID_ERROR:"uuid\u9519\u8BEF\u6216\u8005\u5DE5\u7A0Buuid\u5DF2\u5B58\u5728",PROJECT_OR_TEAM_UUID_ERROR:"\u5DE5\u7A0Buuid\u9519\u8BEF\u6216\u8005\u5DF2\u5B58\u5728\u56E2\u961Fuuid",PROJECT_NOT_PERSON_ERROR:"\u4E0D\u5141\u8BB8\u521B\u5EFA\u4E2A\u4EBA\u5DE5\u7A0B",PROJECT_DUPLICATE_NAME:"\u6807\u9898\u5DF2\u5B58\u5728",ANNOTATION_HAS_BE_FOUND:"\u6279\u6CE8\u5DF2\u521B\u5EFA",ANNOTATION_NOT_FOUND:"\u6279\u6CE8\u5757\u4E0D\u5B58\u5728",ANNOTATION_CREATE_ERROR:"\u6279\u6CE8\u5757\u521B\u5EFA\u5931\u8D25",ANNOTATION_UPDATE_ERROR:"\u66F4\u65B0\u6279\u6CE8\u5757\u5931\u8D25",ANNOTATION_DELETE_ERROR:"\u6279\u6CE8\u6761\u5220\u9664\u5931\u8D25",PROJECT_DUPLICATE_PATH:"\u4E0D\u80FD\u521B\u5EFA\u76F8\u540C\u7684\u8DEF\u5F84",TEAM_NOT_FOUND:"\u56E2\u961F\u4E0D\u5B58\u5728",TEAM_UUID_NULL:"\u56E2\u961Fuuid\u4E0D\u80FD\u4E3A\u7A7A",TEAM_FOLDER_ERROR:"\u7236\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\u6216\u4E0D\u5C5E\u4E8E\u5F53\u524D\u56E2\u961F",TEAM_FOLDER_UUID_ERROR:"\u6587\u4EF6\u5939uuid\u9519\u8BEF\u6216\u8005\u5DE5\u7A0Buuid\u5DF2\u5B58\u5728",TEAM_URL_DUPLICATE:"\u56E2\u961F\u94FE\u63A5\u91CD\u590D",TEAM_CAN_NOT_DELETE:"\u56E2\u961F\u4ECD\u5B58\u5728\u5DE5\u7A0B, \u8BF7\u5148\u8F6C\u79FB\u6216\u8005\u5220\u9664",COMPONENT_UUID_NULL:"\u5143\u4EF6uuid\u4E0D\u80FD\u4E3A\u7A7A",COMPONENT_DATA_NOT_FOUND:"\u5143\u4EF6\u5E93\u6570\u636E\u4E0D\u5B58\u5728",COMPONENT_NAME_DUPLICATE:"\u5143\u4EF6\u5E93\u4E0D\u80FD\u91CD\u540D",COMPONENT_TYPE_ERROR:"\u5E93\u7C7B\u578B\u9519\u8BEF",DELETE_SON_CATEGORY:"\u9700\u8981\u5148\u5220\u9664\u5B50\u7C7B\u522B",LICENSE:"\u672A\u627E\u5230\u8BB8\u53EF\u8BC1",START_TIME:"\u8BB8\u53EF\u8BC1\u5F00\u59CB\u65F6\u95F4\u9519\u8BEF",END_TIME:"\u8BB8\u53EF\u8BC1\u7ED3\u675F\u65F6\u95F4\u9519\u8BEF",PROJECT_LIMIT:"\u521B\u5EFA\u7684\u9879\u76EE\u6570\u91CF\u8D85\u8FC7\u9650\u5236",USER_LIMIT:"\u5DF2\u8FBE\u5230\u6700\u5927\u8D26\u53F7\u6570",ONLINE_NUMBER_LIMIT:"\u5DF2\u8FBE\u5230\u6700\u5927\u5728\u7EBF\u6570",LIMIT_PCB:"PCB\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",LIMIT_SCH:"\u539F\u7406\u56FE\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",LIMIT_PANEL:"\u9762\u677F\u6388\u6743\u6570\u5DF2\u6EE1, \u6DFB\u52A0\u5931\u8D25",TIME_ERROR:"\u7CFB\u7EDF\u65F6\u95F4\u9519\u8BEF\u8BF7\u91CD\u542F\u670D\u52A1\u5668\u6216\u4FEE\u590D\u7CFB\u7EDF\u65F6\u95F4, \u4FEE\u590D\u540E\u9700\u8981\u91CD\u542F\u79C1\u6709\u5316\u670D\u52A1",LICENSE_ERROR:"\u6388\u6743\u9519\u8BEF",LICENSE_TYPE_ERROR:"\u6388\u6743\u5E94\u7528\u7C7B\u578B\u9519\u8BEF",LICENSE_ORIGIN_ERROR:"\u672A\u77E5\u7684\u6388\u6743\u5E94\u7528{type}",BRANCH_DATA_NOT_FOUND:"\u5DE5\u7A0B\u5206\u652F\u4E0D\u5B58\u5728",PARENT_UUID_ERROR:"\u7236\u7EA7uuid\u9519\u8BEF",BRANCH_MUST_AFTER_NODE:"\u5206\u652F\u5FC5\u987B\u5728\u8282\u70B9\u540E",BRANCH_NAME_ERROR:"\u5206\u652F\u540D\u9519\u8BEF",BRANCH_NAME_DUPLICATE:"\u5206\u652F\u540D\u5DF2\u5B58\u5728",BRANCH_UUID_ERROR:"\u5206\u652Fuuid\u9519\u8BEF",BRANCH_NODE_SET_ERROR:"\u8282\u70B9\u4E0D\u80FD\u8BBE\u7F6E\u4E3A\u9ED8\u8BA4\u5206\u652F\u6216\u6807\u8BB0\u4E3Amaster",BRANCH_DELETE_MAIN_ERROR:"\u4E0D\u80FD\u5220\u9664\u4E3B\u5206\u652F\u4E0A\u7684\u8282\u70B9\u6216\u5206\u652F",BRANCH_CHECK_OUT_ERROR:"\u5B58\u5728\u6587\u6863\u5DF2\u7B7E\u51FA",DOCUMENT_UUID_ERROR:"\u6587\u6863uuid\u9519\u8BEF",UPDATE_FAILED:"\u66F4\u65B0\u5931\u8D25",INNER_API_KEY_ERROR:"\u670D\u52A1\u7AEF\u5185\u90E8\u63A5\u53E3 ApiKey \u9519\u8BEF",BRANCH_MORE_THAN_LIMIT:"\u7248\u672C\u8D85\u8FC7\u6700\u5927\u9650\u5236",WORKSPACE_API_ERROR:"\u5DE5\u4F5C\u533A\u8BF7\u6C42\u54CD\u5E94\u5F02\u5E38"},O2={codeEN:jC,codeCN:VC},xv=class Ev{static load(){typeof O2=="object"&&(Ev.cache=O2)}static match(t,i,r){if(!this.cache||!this.cache[t])return;let s=this.cache[t][i];if(r&&Object.prototype.toString.call(r)==="[object Object]")for(let n in r){let a=r[n];s=s.replace(`{${n}}`,a)}return s}};xv.cache={};var R0=xv;function YC(){console.log("common init----------------"),R0.load()}function Ws(e,t){throw new Error(`invalid format state on (${t}) of ${e}`)}function qC(e,...t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l);switch(r){case 0:h==="%"?r=1:i.push(h);break;case 1:switch(h){case"d":n=t[s++],typeof n=="number"?(i.push(n.toFixed(0)),r=0):Ws(e,l);break;case"f":n=t[s++],typeof n=="number"?(i.push(n.toString()),r=0):Ws(e,l);break;case"x":n=t[s++],typeof n=="number"?(i.push((n|0).toString(16)),r=0):Ws(e,l);break;case"X":n=t[s++],typeof n=="number"?(i.push((n|0).toString(16).toUpperCase()),r=0):Ws(e,l);break;case"s":case"c":n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case"0":a=l+1,o=-1,r=2;break;case"%":i.push("%"),r=0;break;default:Ws(e,l)}break;case 2:switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":o=l;break;case"d":if(o>=a){let c=parseInt(e.substring(a,o+1));n=t[s++],typeof n=="number"?(i.push((n|0).toString(10).padStart(c,"0")),r=0):Ws(e,l)}else Ws(e,l);break;case"x":if(o>=a){let c=parseInt(e.substring(a,o+1));n=t[s++],typeof n=="number"?(i.push((n|0).toString(16).padStart(c,"0")),r=0):Ws(e,l)}else Ws(e,l);break;case"X":if(o>=a){let c=parseInt(e.substring(a,o+1));n=t[s++],typeof n=="number"?(i.push((n|0).toString(16).toUpperCase().padStart(c,"0")),r=0):Ws(e,l)}else Ws(e,l);break;default:Ws(e,l)}break;default:Ws(e,l)}}return i.join("")}function wv(e){let t="";try{let i=/.*\\(.*)$/.exec(e);i&&i[1]&&typeof i[1]=="string"&&(t=i[1])}catch(i){console.error("Query Folder Name Error:",i)}return t}function Tv(e,t){let i=Math.max(e.length,t.length);for(let r=0;r<i;r++){let s=e[r],n=t[r],a=0;if(typeof s=="string"&&typeof n=="string")a=s.localeCompare(n);else if(typeof s=="number"&&typeof n=="number")a=s-n;else{if(typeof s=="number"&&typeof n=="string")return-1;if(typeof s=="string"&&typeof n=="number")return 1;if(s===void 0&&n!==void 0)return-1;if(s!==void 0&&n===void 0)return 1}if(a!==0)return a}return 0}function N0(e){let t=/\d+/g,i=new Array,r=0;for(;;){let s=t.exec(e);if(s)r<s.index&&i.push(e.substring(r,s.index)),r=s.index+s[0].length,i.push(parseInt(s[0]));else break}return i.push(e),i}function WC(e,t,i,r){var s,n;let a=[],o=[],l=[];for(let d=0,f=e.length;d<f;d++){a[d]=d;let u;if(Array.isArray(t)){let p="";for(let g=0;g<t.length;g++)if(Object.hasOwnProperty.call(e[d],t[g])){p=e[d][t[g]];break}}else u=t?e[d][t]||((n=(s=e[d])==null?void 0:s[r])==null?void 0:n[t])||"":e[d];if(o[d]=String(u).toUpperCase().match(/\D+|\d+(?:\.\d+)?/g),l[d]=[],o[d])for(let p=0;p<o[d].length;p++)l[d][p]=o[d][p].match(/\d/)?1:2}let h=function(d,f){let u=o[d],p=o[f],g=l[d],_=l[f];if(!u||!p)return i?u==p?0:u?-1:1:u==p?0:u?1:-1;let y=Math.max(u.length,p.length);for(let m=0;m<y;m++){if(i)if(u[m])if(p[m]){if(u[m]!=p[m])return g[m]!=_[m]?g[m]==1?1:-1:g[m]==1?p[m]-u[m]:u[m]<p[m]?1:-1}else return-1;else return 1;if(u[m])if(p[m]){if(u[m]!=p[m])return g[m]!=_[m]?g[m]==1?-1:1:g[m]==1?u[m]-p[m]:u[m]<p[m]?-1:1}else return 1;else return-1}return 0};a.sort(h);let c=[];for(let d=0;d<e.length;d++)c[d]=e[a[d]];return c}function XC(e,t,i){let r=[],s=[],n=[],a=[e,t];for(let o=0,l=a.length;o<l;o++){r[o]=o;let h=a[o];if(s[o]=String(h).toUpperCase().match(/\D+|\d+(?:\.\d+)?/g),n[o]=[],s[o])for(let c=0;c<s[o].length;c++)n[o][c]=s[o][c].match(/\d/)?1:2}return(function(o,l){let h=s[o],c=s[l],d=n[o],f=n[l];if(!h||!c)return i?h==c?0:h?-1:1:h==c?0:h?1:-1;let u=Math.max(h.length,c.length);for(let p=0;p<u;p++){if(i)if(h[p])if(c[p]){if(h[p]!=c[p])return d[p]!=f[p]?d[p]==1?1:-1:d[p]==1?c[p]-h[p]:h[p]<c[p]?1:-1}else return-1;else return 1;if(h[p])if(c[p]){if(h[p]!=c[p])return d[p]!=f[p]?d[p]==1?-1:1:d[p]==1?h[p]-c[p]:h[p]<c[p]?-1:1}else return 1;else return-1}return 0})(r[0],r[1])}function rg(e,t){let i=!1;for(let r in t)if(Object.hasOwnProperty.call(t,r)&&e.indexOf(r)!==-1){i=!0;break}return i}function JC(e,t=""){return e.sort((r,s)=>Tv(N0(i(r)),N0(i(s)))),e;function i(r){if(!r)return r;let s;if(Array.isArray(t)){let n="";for(let a=0;a<t.length;a++)if(Object.hasOwnProperty.call(r,t[a])){n=r[t[a]];break}}else s=r[t]||r;return s}}function ZC(e,t,i=1){var r,s,n,a;let o=(r=e.match(/^\D+/))==null?void 0:r[0],l=(s=e.match(/\d+$/))==null?void 0:s[0],h=(n=t.match(/^\D+/))==null?void 0:n[0],c=(a=t.match(/\d+$/))==null?void 0:a[0];return o&&h?o!==h?i===1?o.localeCompare(h):h.localeCompare(o):l!==c?+l>+c?1*i:-1*i:0:o?-1*i:h?1*i:0}function KC(e){return new Promise(t=>{setTimeout(t,e)})}var sZ=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(e=>e.charCodeAt(0));function $C(){try{if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis}catch{return null}}function Ri(){return self.EDITOR_TOP||self}var ai=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let s=0;s<r.length;s++){let n=r[s],a=n.substring(1,n.length-1);t[a]&&(e=e.replace(n,t[a]))}return e};function QC(e,t,i){t=t||1,i=i||32;var r="",s=t,n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];e&&(s=Math.round(Math.random()*(i-t))+t);for(var a=0;a<s;a++){let o=Math.round(Math.random()*(n.length-1));r+=n[o]}return r}function eL(e){try{return JSON.parse(e)}catch{return console.error(`ParseJSON failed:
`+e),null}}var tL=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.DUMMY=5]="DUMMY",e))(tL||{}),iL=(e,t)=>{switch(e){case 4:console.error(...t);break;case 3:console.warn(...t);break;case 2:console.info(...t);break;default:console.log(...t)}},rL=(e,t)=>t,sL=class ku{constructor(t,i=iL,r=rL){this.level=t,this.writer=i,this.formatter=r}wrap(t){return new ku(this.level,this.writer,(i,r)=>(r=this.formatter(i,r),t(i,r)))}inject(t){return new ku(this.level,this.writer,(i,r)=>(r=t(i,r),this.formatter(i,r)))}shadow(...t){return new ku(this.level,(i,r)=>{this.writer(i,r);for(let s of t)s(i,r)},this.formatter)}mix(...t){return new ku(0,(i,r)=>{this.process(i,r);for(let s of t)s.process(i,r)},(i,r)=>r)}process(t,i){this.level<=t&&this.writer(t,this.formatter(t,i))}process1(t,i,r){this.level<=t&&this.writer(t,this.formatter(t,[qC(i,...r)]))}trace(...t){this.process(0,t)}trace1(t,...i){this.process1(0,t,i)}debug(...t){this.process(1,t)}debug1(t,...i){this.process1(1,t,i)}info(...t){this.process(2,t)}info1(t,...i){this.process1(2,t,i)}warn(...t){this.process(3,t)}warn1(t,...i){this.process1(3,t,i)}error(...t){this.process(4,t)}error1(t,...i){this.process1(4,t,i)}},nZ=new sL(5),aZ=Date.now()-performance.now(),Sv=new ArrayBuffer(10),oZ=new Float64Array(Sv,0,1),lZ=new Uint8Array(Sv);var hm={};zC(hm,{HAS_PANEL:()=>SL,HAS_PCB:()=>TL,HAS_SCH:()=>wL,HAS_SIM:()=>IL,IS_CLIENT:()=>Mn,IS_CLIENT_HALF_OFFLINE:()=>Zu,IS_CLIENT_NOT_ONLINE:()=>mL,IS_CLIENT_OFFLINE:()=>Av,IS_CLIENT_ONLINE:()=>Up,IS_DEV:()=>lL,IS_EASYEDA:()=>Pv,IS_EASYEDA_CLIENT:()=>OL,IS_ECAD:()=>hL,IS_ENTERPRISE_CLIENT:()=>cL,IS_HALF_OFFLINE:()=>ng,IS_LCEDA:()=>Iv,IS_LCEDA_CLIENT:()=>_L,IS_OFFLINE:()=>ag,IS_ONLINE:()=>sg,IS_PCBLUXSHARE:()=>uL,IS_PRIVATE:()=>od,PRO_EDITOR_MODE:()=>bL,PRO_EDITOR_MODES:()=>xr,SSO_EXTERNAL_IDENTITY_DOMAIN:()=>fL,SSO_EXTERNAL_PERMISSION_DOMAIN:()=>pL,SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN:()=>gL,SSO_IDENTITY_CONNECT:()=>dL});var nL=(e=>(e.ruler="ruler",e.un_ruler="un_ruler",e))(nL||{}),aL=(e=>(e[e.HOME=-1]="HOME",e[e.BLANKTAB=0]="BLANKTAB",e[e.SCH=1]="SCH",e[e.PART=2]="PART",e[e.PCB=3]="PCB",e[e.FOOTPRINT=4]="FOOTPRINT",e[e.PRJ=5]="PRJ",e[e.SUBPART=6]="SUBPART",e[e.NGSPICE_MODEL=7]="NGSPICE_MODEL",e[e.NGSPICE=8]="NGSPICE",e[e.SIMULIDE=9]="SIMULIDE",e[e.WAVEFORM=10]="WAVEFORM",e[e.SCHLIB3D=11]="SCHLIB3D",e[e.PHOTOVIEW=12]="PHOTOVIEW",e[e.SCHMODULE=13]="SCHMODULE",e[e.PCBMODULE=14]="PCBMODULE",e[e.VIEW3D=15]="VIEW3D",e[e.PCBLIB3D=16]="PCBLIB3D",e[e.BLOCK_SYMBOL=17]="BLOCK_SYMBOL",e[e.NETFLAG=18]="NETFLAG",e[e.NETPORT=19]="NETPORT",e[e.SHEET_SYMBOL=20]="SHEET_SYMBOL",e[e.NONEELEC_SYMBOL=21]="NONEELEC_SYMBOL",e[e.SHORT_SYMBOL=22]="SHORT_SYMBOL",e[e.FOOTPRINTVIEW=23]="FOOTPRINTVIEW",e[e.CNCPRINTVIEW=24]="CNCPRINTVIEW",e[e.OFF_PAGE_CONNECTOR=25]="OFF_PAGE_CONNECTOR",e[e.PANEL=26]="PANEL",e[e.PANEL3D=27]="PANEL3D",e[e.DEVICE=28]="DEVICE",e[e.PANEL_LIB=29]="PANEL_LIB",e[e.ASSEMBLY_VARIANT=30]="ASSEMBLY_VARIANT",e[e.DIFF_PAIRS_FLAG=31]="DIFF_PAIRS_FLAG",e[e.SIMULIDE_MODEL=32]="SIMULIDE_MODEL",e))(aL||{}),oL=(e=>(e.SCH="SCH",e.PCB="PCB",e.PANEL="PANEL",e.SIM="SIM",e))(oL||{}),m2=$C(),xr=String((m2==null?void 0:m2.PRO_EDITOR_MODE)||"LCEDA").split("-"),lL=xr.indexOf("DEVPRO")>=0,Mn=xr.indexOf("CLIENT")>=0,Iv=xr.indexOf("LCEDA")>=0,Pv=xr.indexOf("EASYEDA")>=0,od=xr.indexOf("PRIVATE")>=0,sg=xr.indexOf("ONLINE")>=0,ng=xr.indexOf("HALF_OFFLINE")>=0,ag=xr.indexOf("OFFLINE")>=0,hL=xr.indexOf("ECAD")>=0,cL=xr.indexOf("ENTERPRISE")>=0,uL=xr.indexOf("PCB_LUXSHARE")>=0,dL=xr.indexOf("SSO_IDENTITY_CONNECT")>=0,fL=xr.indexOf("SSO_EXTERNAL_IDENTITY_DOMAIN")>=0,pL=xr.indexOf("SSO_EXTERNAL_PERMISSION_DOMAIN")>=0,gL=xr.indexOf("SSO_EXTERNAL_PERMISSION_MANAGED_DOMAIN")>=0,_L=Mn&&Iv,OL=Mn&&Pv,Zu=Mn&&ng,mL=Mn&&!sg,Av=Mn&&ag,Up=Mn&&sg,bL=Mn?sg?"ONLINE":ng?"HALF_OFFLINE":ag?"OFFLINE":"":"",yL=xr.indexOf("SCH")>=0,vL=xr.indexOf("PCB")>=0,xL=xr.indexOf("PANEL")>=0,EL=xr.indexOf("SIM")>=0,wL=yL,TL=vL,SL=xL,IL=EL,PL=(e=>(e.PROJECT_BACKUPS_MANUAL="Backup Project Manually",e.PROJECT_BACKUPS_AUTO="Backup Project Automatically",e.DELETE_BACKUPS="Delete Backup",e.SAVE="Save",e.CREATE_SHEET="New Page",e.DELETE_SHEET="Delete Page",e.RENAME_SHEET="Rename Page",e.SIGNED_SHEET="Check Out Page",e.SIGNIN_SHEET="Check In Page",e.CLEAR_SIGNED="Clear Check Out",e.PROJECT_LOCK="Lock Project",e.PROJECT_UNLOCK="Unlock Project",e.PROJECT_OPEN="Open Project",e.PROJECT_CLOSE="Close Project",e.DOCUMENT_PASTE="Paste Document",e.DOCUMENT_PASTE_ACROSS_PROJECT="Paste Document Across Projects",e.SCHEMATIC_PASTE="Paste Schematic",e.SCHEMATIC_PASTE_ACROSS_PROJECT="Paste Schematic Across Projects",e.PRIMITIVE_PASTE_ACROSS_PROJECT="Paste Elements Across Projects",e.PROJECT_SAVEAS_REMOTE="Save Project to Cloud",e.PROJECT_SAVEAS_LOCAL="Save Project to Local",e.LIBRARY_SAVEAS_LOCAL="Save Library to Local",e.DOCUMENT_SAVEAS_REMOTE="Save Document to Cloud",e.DOCUMENT_SAVEAS_LOCAL="Save Document to Local",e.CBB_SAVEAS_REMOTE="Save Reuse Module to Cloud",e.CBB_SAVEAS_LOCAL="Save Reuse Module to Local",e.SVG_EXPORT="Export SVG",e.PNG_EXPORT="Export PNG",e.PDF_EXPORT="Export PDF",e.BOM_EXPORT="Export BOM",e.PRINT="Print",e.GERBER_EXPORT="Export Gerber",e.COORDINATE_EXPORT="Export Pick and Place File",e.D3FILE_EXPORT="Export 3D File",e.D3SHELLFILE_EXPORT="Export 3D Shell File",e.TESTPOINT_REPORT_EXPORT="Export Test Point Report",e.DXF_EXPORT="Export DXF",e.ODBPLUSS_EXPORT="Export ODB++",e.AD_EXPORT="Export Altium Designer",e.DEVICE_REPLACE="Replace Device",e.FOOTPRINT_REPLACE="Replace Footprint",e.D3MODEL_REPLACE="Replace 3D Model",e.PROJECTLIB_UPDATE="Update Project Library",e.REPLACE="Find and Replace",e.TRACK_BATCH_RENAME="Rename Wires in Batch",e.SHEET_BATCH_RENAME="Rename Pages in Batch",e.NET_CREATED_AUTO="Automatic Network Generation",e.DESIGNATOR_ALLOCATION="Annotate Designator",e.UNIQUE_ID_RESET="Reset Unique ID",e.NET_TABLE_EXPORT="Export Netlist",e.REFRESH_PCB_BY_SCH="Update Schematic to PCB",e.REFRESH_SCH_BY_PCB="Update PCB to Schematic",e.CLEAR_DESIGNATOR="Clear Designator",e.UPDATE_PORT_BY_MODULE_SYMBOL="Update Ports from Module Symbol",e.DESIGN_RULE="Set Design Rules",e.NET_CLASS="Set Network Class",e.EQUAL_LENGTH_GROUP="Set Equal Length Group",e.DIFFERENTIAL_PAIR="Set Differential Pair",e))(PL||{}),Ih=class No{constructor(t,i=crypto.randomUUID()){this.fileName=t,this.uuid=i,this._params=new URLSearchParams,this._aTarget=document.createElement("a"),this._params.append("uuid",i),this._params.append("fileName",t)}static get URL_VERSION(){var t;try{let i=location.host,r="/";return((t=new RegExp(`${i}(/[\\w|.]+)${r}`).exec(location.href))==null?void 0:t[1])||""}catch{return""}}static getOpenedStream(t){return this._openedInstances.get(t)}get createURL(){return`${No.CREATE_URL}?${this._params}`}get writeURL(){return`${No.WRITE_URL}?${this._params}`}get closeURL(){return`${No.CLOSE_URL}?${this._params}`}get cancelURL(){return`${No.CANCEL_URL}?${this._params}`}async create(){this._aTarget.href=this.createURL,this._aTarget.click(),this._aTarget.remove(),No._openedInstances.set(this.uuid,this),await KC(100)}async write(t){await(await fetch(this.writeURL,{method:"post",body:t})).json()}async close(){await fetch(this.closeURL,{method:"post"}),No._openedInstances.delete(this.uuid)}async cancel(){await fetch(this.cancelURL,{method:"post"}),No._openedInstances.delete(this.uuid)}};Ih.CREATE_URL=`${Ih.URL_VERSION}/sw/download/stream/create`,Ih.WRITE_URL="/sw/download/stream/write",Ih.CLOSE_URL="/sw/download/stream/close",Ih.CANCEL_URL="/sw/download/stream/cancel",Ih._openedInstances=new Map;var AL=Object.create,Cv=Object.defineProperty,CL=Object.getOwnPropertyDescriptor,LL=Object.getOwnPropertyNames,DL=Object.getPrototypeOf,RL=Object.prototype.hasOwnProperty,b2=(e=>typeof Sh<"u"?Sh:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof Sh<"u"?Sh:t)[i]}):e)(function(e){if(typeof Sh<"u")return Sh.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Xt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),NL=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of LL(t))!RL.call(e,s)&&s!==i&&Cv(e,s,{get:()=>t[s],enumerable:!(r=CL(t,s))||r.enumerable});return e},ic=(e,t,i)=>(i=e!=null?AL(DL(e)):{},NL(t||!e||!e.__esModule?Cv(i,"default",{value:e,enumerable:!0}):i,e)),ld=Xt((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a=(w,B)=>{for(var V in B)i(w,V,{get:B[V],enumerable:!0})},o=(w,B,V,Y)=>{if(B&&typeof B=="object"||typeof B=="function")for(let W of s(B))!n.call(w,W)&&W!==V&&i(w,W,{get:()=>B[W],enumerable:!(Y=r(B,W))||Y.enumerable});return w},l=w=>o(i({},"__esModule",{value:!0}),w),h={};a(h,{BroadcastChannelMessageBus:()=>he,MessageBus:()=>x,MessageBus2:()=>Z,MessageBusTask:()=>R,MessageBusTask2:()=>G,WindowMessageBridge:()=>L,WorkerMessageBridge:()=>j,createBroadcastP2PStream:()=>de,createBufferedByteBufferStream:()=>ie,createBufferedStream:()=>q,createBufferedStringStream:()=>X,dropP2PStream:()=>Ce,flowRead:()=>Pe,flowWrite:()=>Fe}),t.exports=l(h);var c=class{constructor(w=1.5){this.growthFactor=w,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(w){if(this.count===this.capacity){let B=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,B);let V=new Array(B);for(let Y=0;Y<this.count;Y++)V[Y]=this.buffer[(this.head+Y)%this.capacity];this.buffer=V,this.head=0,this.tail=this.count,this.capacity=B}this.buffer[this.tail]=w,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let w=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,w}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},d=new ArrayBuffer(8),f=new Float64Array(d),u=new Uint32Array(d),p=new Uint16Array(d),g=ArrayBuffer;try{g=self.HTMLImageElement||g}catch{}var _=typeof SharedArrayBuffer<"u";function y(w){if(typeof w!="object"||w===null||w instanceof Date||w instanceof ArrayBuffer||_&&w instanceof SharedArrayBuffer||w instanceof Blob||w instanceof FormData||w instanceof Function||w instanceof Uint8ClampedArray||w instanceof g)return w;if(Array.isArray(w))return w.map(y);{let B={};for(let V in w)Object.hasOwnProperty.call(w,V)&&(B[V]=y(w[V]));return B}}function m(w,B){return O(w,B,()=>[])}function O(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var b=class{constructor(w){this.maxResources=w,this.idle=new c,this.isClosed=!1,this.resources=w}acquire(w){this.isClosed?Promise.resolve(!1).then(w):this.resources>0?(this.resources--,Promise.resolve(!0).then(w)):this.idle.enqueue(w)}acquireSync(){return new Promise(w=>{this.acquire(w)})}release(){if(!this.isClosed){let w=this.idle.dequeue();w?Promise.resolve(!0).then(w):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let w=this.idle.dequeue();Promise.resolve(!1).then(w)}}};function v(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function E(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}var T=v(),P=T.WeakRef||(w=>w);function A(w){if(w!=null){if(typeof w=="object")return new P(w);console.error(w,w instanceof Object,typeof w);return}}function C(w){return w==null?void 0:w.deref()}var M="_MSG_BUS_RPC_",H=300*1e3,k=(w=>(w.PUBLISH="publish",w.SUBSCRIBE="subscribe",w.PUSH="push",w.PULL="pull",w))(k||{}),F=class{constructor(w){this.bus=w}processRemoteMessage(w,B){let V=A(B),Y=w.topic,W=w.type,ne=w.message;switch(W){case"pull":this.bus.pull(Y,ue=>{this.push(Y,ue,C(V))});break;case"subscribe":this.bus.subscribe(Y,ue=>{this.publish(Y,ue,C(V))});break;case"publish":this.bus.publish(Y,ne,this,C(V));break;case"push":this.bus.push(Y,ne,this,C(V));break;default:console.debug("unknown message type "+W)}}rpcCall(w,B,V,Y=H){let W=A(V),ne=new Promise(ue=>{let Re=this.bus.uniqueRpcTopic(w);this.publish(w,{message:B,reply:Re},C(W)),this.bus.pull(Re,(Ue,je,dt)=>{ue({message:Ue,bridge:je,source:A(dt)})})});return Y>0?Promise.race([ne,new Promise((ue,Re)=>{setTimeout(Re,Y)})]):ne}},j=class extends F{constructor(w,B){super(w),this.worker=B,B.onmessage=V=>{this.processRemoteMessage(V.data,void 0)}}publish(w,B){this.postMessage(w,"publish",B)}subscribe(w){this.postMessage(w,"subscribe",null)}push(w,B){this.postMessage(w,"push",B)}pull(w){this.postMessage(w,"pull",null)}rpcCall(w,B,V=H){return super.rpcCall(w,B,void 0,V)}postMessage(w,B,V){let Y={topic:w,type:B,message:V};this.worker.postMessage(Y)}discard(){this.worker.terminate()}},L=class extends F{constructor(w){super(w),window.addEventListener("message",B=>{this.processRemoteMessage(B.data,B.source)},!1)}publish(w,B,V){this.postMessage(w,"publish",B,V)}subscribe(w,B){if(B===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(w,"subscribe",null,B)}push(w,B,V){this.postMessage(w,"push",B,V)}pull(w,B){if(B===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(w,"pull",null,B)}postMessage(w,B,V,Y){let W={topic:w,type:B,message:V};Y&&Y.postMessage(W,"*")}},R=class{constructor(w){this.isRunning=!0,this.callback=w}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(w,B,V,Y){try{w=Y?w:y(w),this.callback(w,B,V)}catch(W){console.error(W)}}},x=class{constructor(w=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=w}uniqueRpcTopic(w){return`${M}-${w}-${this.uuid}-${this.rpcTicket++}`}publish(w,B,V,Y){let W=this.subscribed[w];if(W){let ne;for(let ue of W)ue.running()?ue.execute(B,V,Y,this.unsafe):(ne=ne||new Array,ne.push(ue));if(ne)for(let ue of ne)E(W,ue)}else console.debug("no sub on topic: "+w)}subscribe(w,B){let V=new R(B);return m(this.subscribed,w).push(V),V}push(w,B,V,Y){let W=!1,ne=this.pulled[w];if(ne){for(;ne.length>0;){let ue=ne.shift();if(ue.running()){ue.execute(B,V,Y,this.unsafe),W=!0;break}}ne.length===0&&delete this.pulled[w]}W||m(this.pushed,w).push({message:B,bridge:V,source:A(Y)})}pull(w,B){let V=new R(B),Y=this.pushed[w];if(Y){let W=Y.shift();V.execute(W.message,W.bridge,C(W.source),this.unsafe),Y.length===0&&delete this.pushed[w]}else m(this.pulled,w).push(V);return V}pullA(w){return new Promise(B=>{this.pull(w,(V,Y,W)=>{B({message:V,bridge:Y,source:A(W)})})})}rpcService(w,B){this.subscribe(w,(V,Y,W)=>{let{message:ne,reply:ue}=V;try{let Re=B(ne);if(Re instanceof Promise){let Ue=A(W);Re.then(je=>{this.rpcReply(je,ue,Y,C(Ue))},je=>{console.error(je),this.rpcReply(void 0,ue,Y,C(Ue))})}else this.rpcReply(Re,ue,Y,W)}catch(Re){console.error(Re),this.rpcReply(void 0,ue,Y,W)}})}rpcCall(w,B,V=H){let Y=new Promise(W=>{let ne=this.uniqueRpcTopic(w);this.publish(w,{message:B,reply:ne}),this.pull(ne,(ue,Re,Ue)=>{W({message:ue,bridge:Re,source:A(Ue)})})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}rpcReply(w,B,V,Y){V?V.push(B,w,Y):this.push(B,w)}},I="_MSG_BUS_RPC_";function S(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}function D(w,B){return N(w,B,()=>[])}function N(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var G=class{constructor(w,B){this.callback=w,this.unsafe=B,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(w){try{w=this.unsafe?w:y(w),this.callback(w)}catch(B){console.error(B)}}},z=class{constructor(w=crypto.randomUUID()){this.uuid=w,this.rpcTicket=0}subscribeOnce(w,B){let V=this.subscribe(w,Y=>{V.cancel(),B(Y)});return V}pullA(w){return new Promise(B=>{this.pull(w,B)})}rpcService(w,B){let V=Y=>{try{let{message:W,replyTopic:ne}=Y;try{let ue=B(W);ue instanceof Promise?ue.then(Re=>{this.publish(ne,{success:!0,result:Re})}).catch(Re=>{console.error(Re),this.publish(ne,{success:!1,err:String(Re)})}):this.publish(ne,{success:!0,result:ue})}catch(ue){this.publish(ne,{success:!1,err:String(ue)})}}finally{this.pull(w,V)}};this.pull(w,V)}rpcCall(w,B,V=0){let Y=new Promise((W,ne)=>{let ue=`${I}-${w}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ue,Re=>{Re.success?W(Re.result):ne(new Error(Re.err))}),this.push(w,{message:B,replyTopic:ue})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}},Z=class extends z{constructor(w=!1){super(),this.unsafe=w,this.subscribed={},this.pulled={},this.pushed={}}publish(w,B){let V=this.subscribed[w];if(V){let Y;for(let W of V)W.running()?W.execute(B):(Y=Y||new Array,Y.push(W));if(Y)for(let W of Y)S(V,W)}}subscribe(w,B){let V=new G(B,this.unsafe);return D(this.subscribed,w).push(V),V}push(w,B){let V=!1,Y=this.pulled[w];if(Y){for(;Y.length>0;){let W=Y.shift();if(W&&W.running()){W.execute(B),V=!0;break}}Y.length===0&&delete this.pulled[w]}V||D(this.pushed,w).push(B)}pull(w,B){let V=new G(B,this.unsafe);return this.repull(w,V),V}repull(w,B){let V=this.pushed[w];if(V){let Y=V.shift();Y&&(B.execute(Y),V.length===0&&delete this.pushed[w])}else D(this.pulled,w).push(B)}},se=class extends z{constructor(w=crypto.randomUUID()){super(w),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(w,B){console.debug("BC",this.uuid,"PUBLISH",w,B),this.broadcastPublish(w,B)}subscribe(w,B){console.debug("BC",this.uuid,"SUBSCRIBE",w);let V=new G(B,!0);return D(this.subscribed,w).push(V),V}push(w,B){let V=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",w,`(${V})`,B),D(this.pushed,w).push({id:V,message:B}),this.broadcastPushedHeadMessage(w)}pull(w,B){console.debug("BC",this.uuid,"PULL",w);let V=new G(B,!0);return D(this.pulled,w).push(V),this.broadcastWhoHas(w),V}broadcastPushedHeadMessage(w){let B=this.pushed[w];B&&B[0]&&this.broadcastIHave(w,B[0].id)}onReceivedPublish(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"PUBLISH",B,"message",V);let Y=this.subscribed[B];if(Y){let W;for(let ne of Y)ne.running()?ne.execute(V):(W=W||new Array,W.push(ne));if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.subscribed[B]}}onReceivedWhoHas(w,B){console.debug("BCMSG(",this.uuid,")","from",w,"WHOHAS",B),this.broadcastPushedHeadMessage(B)}onReceivedIHave(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"IHAVE",B,"id",V);let Y=this.pulled[B];if(Y){let W;for(let ne of Y)if(ne.running()){this.broadcastINeed(B,w,V);break}else W=W||new Array,W.push(ne);if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.pulled[B]}}onReceivedINeed(w,B,V,Y){if(console.debug("BCMSG(",this.uuid,")","from",w,"INEED",B,"source",V,"id",Y),this.uuid===V){let W=this.pushed[B];if(W&&W[0]&&W[0].id===Y){let{message:ne}=W.shift();this.broadcastIGive(B,Y,w,ne),this.broadcastPushedHeadMessage(B),W.length===0&&delete this.pushed[B]}}}onReceivedIGive(w,B,V,Y,W){console.debug("BCMSG(",this.uuid,")","from",w,"IGIVE",B,"id",V,"target",Y,"message",W);let ne=this.pulled[B];if(ne&&this.uuid===Y){let ue=!1;for(;ne.length>0;){let Re=ne.shift();if(Re.running()){Re.execute(W),ue=!0;break}}ue||this.push(B,W),ne.length===0&&delete this.pulled[B]}}},he=class extends se{constructor(w,B=crypto.randomUUID()){super(B),this.bc=new BroadcastChannel(w),this.bc.onmessage=V=>{this.onMessage(V.data)}}onMessage(w){let{type:B,uuid:V,topic:Y}=w;switch(B){case"PUBLISH":{let{message:W}=w;this.onReceivedPublish(V,Y,W);break}case"WHOHAS":{this.onReceivedWhoHas(V,Y);break}case"IHAVE":{let{id:W}=w;this.onReceivedIHave(V,Y,W);break}case"INEED":{let{source:W,id:ne}=w;this.onReceivedINeed(V,Y,W,ne);break}case"IGIVE":{let{target:W,id:ne,message:ue}=w;this.onReceivedIGive(V,Y,ne,W,ue);break}default:console.warn("unsupported",w)}}broadcastPublish(w,B){this.post({type:"PUBLISH",uuid:this.uuid,topic:w,message:B})}broadcastWhoHas(w){this.post({type:"WHOHAS",uuid:this.uuid,topic:w})}broadcastIHave(w,B){this.post({type:"IHAVE",uuid:this.uuid,topic:w,id:B})}broadcastINeed(w,B,V){this.post({type:"INEED",uuid:this.uuid,topic:w,source:B,id:V})}broadcastIGive(w,B,V,Y){this.post({type:"IGIVE",uuid:this.uuid,topic:w,id:B,target:V,message:Y})}post(w){this.bc.postMessage(w),Promise.resolve().then(()=>{this.onMessage(w)})}},pe=Symbol("BLOCKING_QUEUE_RESET"),Se=class{constructor(w,B=()=>1){if(this.maxSize=w,this.itemSizeOf=B,this.queue=new c,this.waitingConsumers=new c,this.waitingProducers=new c,this.queueSize=0,this.closePromise=null,this.closeResolve=null,w<=0)throw new Error("Max size must be greater than 0")}enqueue(w){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let B=await new Promise(V=>{this.waitingProducers.enqueue(V)});return console.debug("queue is not full",this.size(),B),B?(this.innerEnqueue(w),!0):!1})():(this.innerEnqueue(w),!0)}innerEnqueue(w){if(this.waitingConsumers.isEmpty())this.queue.enqueue(w),this.queueSize+=this.itemSizeOf(w),console.debug("queue pushed",w,"size",this.queueSize);else{let B=this.waitingConsumers.dequeue();Promise.resolve(w).then(B),console.debug("queue direct",w,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let w=this.waitingConsumers.dequeue();Promise.resolve(pe).then(w)}return setTimeout(()=>this.closeResolve(),0),pe}else return new Promise(w=>{this.waitingConsumers.enqueue(w)});else{let w=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(w),!this.waitingProducers.isEmpty()){let B=this.waitingProducers.dequeue();Promise.resolve(!0).then(B)}return w}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(w=>{for(this.closeResolve=w;!this.waitingProducers.isEmpty();){let B=this.waitingProducers.dequeue();Promise.resolve(!1).then(B)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let B=this.waitingConsumers.dequeue();Promise.resolve(pe).then(B)}w()}})),this.closePromise}};function q(w,B,V=Number.MAX_SAFE_INTEGER){let Y=new Se(V,B),W=new ReadableStream({pull(ue){let Re=!0,Ue=(async()=>{let je=new Array;do{let dt=Y.dequeue();if(dt instanceof Promise){Re=!1;let Ot=await dt;Ot===pe?ue.close():je.push(Ot)}else{let Ot=dt;Ot===pe?ue.close():je.push(Ot)}}while(Y.size()>0);if(je.length>0){let dt=w(je);ue.enqueue(dt)}})();if(!Re)return console.debug("read stream stucked --------------------------------------"),Ue},async cancel(){console.debug("buffered readable cancel"),await Y.close()}}),ne=new WritableStream({write(ue,Re){let Ue=!0,je=(async()=>{let dt=Y.enqueue(ue);typeof dt=="boolean"?dt||Re.error(new Error("Write stream closed")):(Ue=!1,await dt||Re.error(new Error("Write stream closed")))})();if(!Ue)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),je},async close(){console.debug("buffered writable closing",Y.size()),await Y.close(),console.debug("buffered writable closed",Y.size())},async abort(){console.debug("buffered writable aborting",Y.size()),await Y.close(),console.debug("buffered writable aborted",Y.size())}});return{readable:W,writable:ne}}function X(w=Number.MAX_SAFE_INTEGER){return q(B=>B.join(""),B=>B.length,w)}function ie(w=Number.MAX_SAFE_INTEGER){return q(B=>{let V=new Uint8Array(B.reduce((W,ne)=>W+ne.byteLength,0)),Y=0;return B.forEach(W=>{V.set(W,Y),Y+=W.byteLength}),V},B=>B.byteLength,w)}function de(w){return new Promise((B,V)=>{let Y=new BroadcastChannel(w),W=new Se(1),ne=new b(1),ue=null,Re=!1,Ue=!1,je=!1;Y.onmessage=dt=>{let Ot=dt.data,{type:Lt}=Ot;if(console.debug("p2p",w,"type",Lt,"data",Lt==="DATA"&&Ot.data),Lt==="DATA")W.enqueue(Ot.data);else if(Lt==="HI"){if(!ue){Y.postMessage({type:"HI"});let Ge=0;ue={rs:new ReadableStream({async pull(qe){let me=await W.dequeue();me===pe?(await Q(),qe.close()):(qe.enqueue(me),Y.postMessage({type:"ACK"}))},cancel(){return Q()}}),ws:new WritableStream({async write(qe,me){await ne.acquireSync()?Y.postMessage({type:"DATA",id:Ge++,data:qe}):(hi(),me.error(new Error("Write stream closed")))},close(){hi()},abort(){hi()}})},B(ue)}}else Lt==="REND"?ue?ne.close():ke("REND1"):Lt==="WEND"?ue?W.close():ke("WEND1"):Lt==="ACK"&&ne.release();function hi(){Re||(Re=!0,console.debug(w,"p2p write stream closed"),ne.close(),Y.postMessage({type:"WEND"}),Ue&&(console.debug(w,"p2p channel closed on ws"),Y.close()))}async function Q(){Ue||(Ue=!0,console.debug(w,"p2p read stream closed"),Y.postMessage({type:"REND"}),await W.close(),Re&&(console.debug(w,"p2p channel closed on rs"),Y.close()))}async function ke(Ge){je||(je=!0,console.debug(w,"p2p channel connection released on",Ge),ne.close(),W.close(),ue?(ue.rs.locked||(console.debug(w,"p2p unlocked read stream direct cancel"),ue.rs.cancel()),ue.ws.locked||(console.debug(w,"p2p unlocked write stream direct close"),ue.ws.close())):(Y.postMessage({type:"HI"}),Y.close()),V(new Error("p2p channel connection released")))}},Y.postMessage({type:"HI"})})}function Ce(w){return new Promise(B=>{let V=new BroadcastChannel(w);V.onmessage=Y=>{let W=Y.data,{type:ne}=W;ne==="HI"&&(V.postMessage({type:"REND"}),V.close(),B())},V.postMessage({type:"REND"})})}async function De(w){try{return await de(w)}catch(B){B.message!=="p2p channel connection released"&&console.error(B)}}async function Fe(w,B,V=10*1024*1024,Y=!0){let W=await De(w);if(!W)return!1;let ne=!1;try{let ue,Re=Ue=>{if(!ue)if(!Y)ue=W.ws.getWriter();else if(typeof Ue=="string"){let je=X(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}else{let je=ie(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}return ue.write(Ue)};if(Array.isArray(B))for(let Ue of B)await Re(Ue);else await B({write:Re,get desiredSize(){return((ue==null?void 0:ue.desiredSize)||0)+10}});ue&&await ue.close(),ne=!0}catch(ue){console.error(ue)}finally{return W.rs.cancel(),ne}}async function Pe(w,B){var V,Y;let W=await De(w);if(W)try{let ne=W.rs.getReader();for((V=B.start)==null?void 0:V.call(B);;){let{value:ue,done:Re}=await ne.read();if(ue!==void 0){let Ue;if(B.update instanceof Promise?Ue=await B.update(ue):Ue=B.update(ue),Ue){await ne.cancel();break}}if(Re){(Y=B.end)==null||Y.call(B);break}}}catch(ne){console.error(ne)}finally{W.ws.close()}}}),ti=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r():typeof define=="function"&&define.amd?define([],r):i.CryptoJS=r()})(e,function(){var i=i||(function(r,s){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof b2=="function")try{n=b2("crypto")}catch{}var a=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function O(){}return function(b){var v;return O.prototype=b,v=new O,O.prototype=null,v}})(),l={},h=l.lib={},c=h.Base=(function(){return{extend:function(O){var b=o(this);return O&&b.mixIn(O),(!b.hasOwnProperty("init")||this.init===b.init)&&(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var O=this.extend();return O.init.apply(O,arguments),O},init:function(){},mixIn:function(O){for(var b in O)O.hasOwnProperty(b)&&(this[b]=O[b]);O.hasOwnProperty("toString")&&(this.toString=O.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),d=h.WordArray=c.extend({init:function(O,b){O=this.words=O||[],b!=s?this.sigBytes=b:this.sigBytes=O.length*4},toString:function(O){return(O||u).stringify(this)},concat:function(O){var b=this.words,v=O.words,E=this.sigBytes,T=O.sigBytes;if(this.clamp(),E%4)for(var P=0;P<T;P++){var A=v[P>>>2]>>>24-P%4*8&255;b[E+P>>>2]|=A<<24-(E+P)%4*8}else for(var C=0;C<T;C+=4)b[E+C>>>2]=v[C>>>2];return this.sigBytes+=T,this},clamp:function(){var O=this.words,b=this.sigBytes;O[b>>>2]&=4294967295<<32-b%4*8,O.length=r.ceil(b/4)},clone:function(){var O=c.clone.call(this);return O.words=this.words.slice(0),O},random:function(O){for(var b=[],v=0;v<O;v+=4)b.push(a());return new d.init(b,O)}}),f=l.enc={},u=f.Hex={stringify:function(O){for(var b=O.words,v=O.sigBytes,E=[],T=0;T<v;T++){var P=b[T>>>2]>>>24-T%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16))}return E.join("")},parse:function(O){for(var b=O.length,v=[],E=0;E<b;E+=2)v[E>>>3]|=parseInt(O.substr(E,2),16)<<24-E%8*4;return new d.init(v,b/2)}},p=f.Latin1={stringify:function(O){for(var b=O.words,v=O.sigBytes,E=[],T=0;T<v;T++){var P=b[T>>>2]>>>24-T%4*8&255;E.push(String.fromCharCode(P))}return E.join("")},parse:function(O){for(var b=O.length,v=[],E=0;E<b;E++)v[E>>>2]|=(O.charCodeAt(E)&255)<<24-E%4*8;return new d.init(v,b)}},g=f.Utf8={stringify:function(O){try{return decodeURIComponent(escape(p.stringify(O)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(O){return p.parse(unescape(encodeURIComponent(O)))}},_=h.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(O){typeof O=="string"&&(O=g.parse(O)),this._data.concat(O),this._nDataBytes+=O.sigBytes},_process:function(O){var b,v=this._data,E=v.words,T=v.sigBytes,P=this.blockSize,A=P*4,C=T/A;O?C=r.ceil(C):C=r.max((C|0)-this._minBufferSize,0);var M=C*P,H=r.min(M*4,T);if(M){for(var k=0;k<M;k+=P)this._doProcessBlock(E,k);b=E.splice(0,M),v.sigBytes-=H}return new d.init(b,H)},clone:function(){var O=c.clone.call(this);return O._data=this._data.clone(),O},_minBufferSize:0}),y=h.Hasher=_.extend({cfg:c.extend(),init:function(O){this.cfg=this.cfg.extend(O),this.reset()},reset:function(){_.reset.call(this),this._doReset()},update:function(O){return this._append(O),this._process(),this},finalize:function(O){O&&this._append(O);var b=this._doFinalize();return b},blockSize:512/32,_createHelper:function(O){return function(b,v){return new O.init(v).finalize(b)}},_createHmacHelper:function(O){return function(b,v){return new m.HMAC.init(O,v).finalize(b)}}}),m=l.algo={};return l})(Math);return i})}),og=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.Base,o=n.WordArray,l=s.x64={},h=l.Word=a.extend({init:function(d,f){this.high=d,this.low=f}}),c=l.WordArray=a.extend({init:function(d,f){d=this.words=d||[],f!=r?this.sigBytes=f:this.sigBytes=d.length*8},toX32:function(){for(var d=this.words,f=d.length,u=[],p=0;p<f;p++){var g=d[p];u.push(g.high),u.push(g.low)}return o.create(u,this.sigBytes)},clone:function(){for(var d=a.clone.call(this),f=d.words=this.words.slice(0),u=f.length,p=0;p<u;p++)f[p]=f[p].clone();return d}})})(),i})}),ML=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){if(typeof ArrayBuffer=="function"){var r=i,s=r.lib,n=s.WordArray,a=n.init,o=n.init=function(l){if(l instanceof ArrayBuffer&&(l=new Uint8Array(l)),(l instanceof Int8Array||typeof Uint8ClampedArray<"u"&&l instanceof Uint8ClampedArray||l instanceof Int16Array||l instanceof Uint16Array||l instanceof Int32Array||l instanceof Uint32Array||l instanceof Float32Array||l instanceof Float64Array)&&(l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),l instanceof Uint8Array){for(var h=l.byteLength,c=[],d=0;d<h;d++)c[d>>>2]|=l[d]<<24-d%4*8;a.call(this,c,h)}else a.apply(this,arguments)};o.prototype=n}})(),i.lib.WordArray})}),BL=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Utf16=a.Utf16BE={stringify:function(h){for(var c=h.words,d=h.sigBytes,f=[],u=0;u<d;u+=2){var p=c[u>>>2]>>>16-u%4*8&65535;f.push(String.fromCharCode(p))}return f.join("")},parse:function(h){for(var c=h.length,d=[],f=0;f<c;f++)d[f>>>1]|=h.charCodeAt(f)<<16-f%2*16;return n.create(d,c*2)}};a.Utf16LE={stringify:function(h){for(var c=h.words,d=h.sigBytes,f=[],u=0;u<d;u+=2){var p=l(c[u>>>2]>>>16-u%4*8&65535);f.push(String.fromCharCode(p))}return f.join("")},parse:function(h){for(var c=h.length,d=[],f=0;f<c;f++)d[f>>>1]|=l(h.charCodeAt(f)<<16-f%2*16);return n.create(d,c*2)}};function l(h){return h<<8&4278255360|h>>>8&16711935}})(),i.enc.Utf16})}),Ul=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Base64={stringify:function(h){var c=h.words,d=h.sigBytes,f=this._map;h.clamp();for(var u=[],p=0;p<d;p+=3)for(var g=c[p>>>2]>>>24-p%4*8&255,_=c[p+1>>>2]>>>24-(p+1)%4*8&255,y=c[p+2>>>2]>>>24-(p+2)%4*8&255,m=g<<16|_<<8|y,O=0;O<4&&p+O*.75<d;O++)u.push(f.charAt(m>>>6*(3-O)&63));var b=f.charAt(64);if(b)for(;u.length%4;)u.push(b);return u.join("")},parse:function(h){var c=h.length,d=this._map,f=this._reverseMap;if(!f){f=this._reverseMap=[];for(var u=0;u<d.length;u++)f[d.charCodeAt(u)]=u}var p=d.charAt(64);if(p){var g=h.indexOf(p);g!==-1&&(c=g)}return l(h,c,f)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function l(h,c,d){for(var f=[],u=0,p=0;p<c;p++)if(p%4){var g=d[h.charCodeAt(p-1)]<<p%4*2,_=d[h.charCodeAt(p)]>>>6-p%4*2,y=g|_;f[u>>>2]|=y<<24-u%4*8,u++}return n.create(f,u)}})(),i.enc.Base64})}),kL=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Base64url={stringify:function(h,c){c===void 0&&(c=!0);var d=h.words,f=h.sigBytes,u=c?this._safe_map:this._map;h.clamp();for(var p=[],g=0;g<f;g+=3)for(var _=d[g>>>2]>>>24-g%4*8&255,y=d[g+1>>>2]>>>24-(g+1)%4*8&255,m=d[g+2>>>2]>>>24-(g+2)%4*8&255,O=_<<16|y<<8|m,b=0;b<4&&g+b*.75<f;b++)p.push(u.charAt(O>>>6*(3-b)&63));var v=u.charAt(64);if(v)for(;p.length%4;)p.push(v);return p.join("")},parse:function(h,c){c===void 0&&(c=!0);var d=h.length,f=c?this._safe_map:this._map,u=this._reverseMap;if(!u){u=this._reverseMap=[];for(var p=0;p<f.length;p++)u[f.charCodeAt(p)]=p}var g=f.charAt(64);if(g){var _=h.indexOf(g);_!==-1&&(d=_)}return l(h,d,u)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function l(h,c,d){for(var f=[],u=0,p=0;p<c;p++)if(p%4){var g=d[h.charCodeAt(p-1)]<<p%4*2,_=d[h.charCodeAt(p)]>>>6-p%4*2,y=g|_;f[u>>>2]|=y<<24-u%4*8,u++}return n.create(f,u)}})(),i.enc.Base64url})}),Gl=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=[];(function(){for(var g=0;g<64;g++)h[g]=r.abs(r.sin(g+1))*4294967296|0})();var c=l.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,_){for(var y=0;y<16;y++){var m=_+y,O=g[m];g[m]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var b=this._hash.words,v=g[_+0],E=g[_+1],T=g[_+2],P=g[_+3],A=g[_+4],C=g[_+5],M=g[_+6],H=g[_+7],k=g[_+8],F=g[_+9],j=g[_+10],L=g[_+11],R=g[_+12],x=g[_+13],I=g[_+14],S=g[_+15],D=b[0],N=b[1],G=b[2],z=b[3];D=d(D,N,G,z,v,7,h[0]),z=d(z,D,N,G,E,12,h[1]),G=d(G,z,D,N,T,17,h[2]),N=d(N,G,z,D,P,22,h[3]),D=d(D,N,G,z,A,7,h[4]),z=d(z,D,N,G,C,12,h[5]),G=d(G,z,D,N,M,17,h[6]),N=d(N,G,z,D,H,22,h[7]),D=d(D,N,G,z,k,7,h[8]),z=d(z,D,N,G,F,12,h[9]),G=d(G,z,D,N,j,17,h[10]),N=d(N,G,z,D,L,22,h[11]),D=d(D,N,G,z,R,7,h[12]),z=d(z,D,N,G,x,12,h[13]),G=d(G,z,D,N,I,17,h[14]),N=d(N,G,z,D,S,22,h[15]),D=f(D,N,G,z,E,5,h[16]),z=f(z,D,N,G,M,9,h[17]),G=f(G,z,D,N,L,14,h[18]),N=f(N,G,z,D,v,20,h[19]),D=f(D,N,G,z,C,5,h[20]),z=f(z,D,N,G,j,9,h[21]),G=f(G,z,D,N,S,14,h[22]),N=f(N,G,z,D,A,20,h[23]),D=f(D,N,G,z,F,5,h[24]),z=f(z,D,N,G,I,9,h[25]),G=f(G,z,D,N,P,14,h[26]),N=f(N,G,z,D,k,20,h[27]),D=f(D,N,G,z,x,5,h[28]),z=f(z,D,N,G,T,9,h[29]),G=f(G,z,D,N,H,14,h[30]),N=f(N,G,z,D,R,20,h[31]),D=u(D,N,G,z,C,4,h[32]),z=u(z,D,N,G,k,11,h[33]),G=u(G,z,D,N,L,16,h[34]),N=u(N,G,z,D,I,23,h[35]),D=u(D,N,G,z,E,4,h[36]),z=u(z,D,N,G,A,11,h[37]),G=u(G,z,D,N,H,16,h[38]),N=u(N,G,z,D,j,23,h[39]),D=u(D,N,G,z,x,4,h[40]),z=u(z,D,N,G,v,11,h[41]),G=u(G,z,D,N,P,16,h[42]),N=u(N,G,z,D,M,23,h[43]),D=u(D,N,G,z,F,4,h[44]),z=u(z,D,N,G,R,11,h[45]),G=u(G,z,D,N,S,16,h[46]),N=u(N,G,z,D,T,23,h[47]),D=p(D,N,G,z,v,6,h[48]),z=p(z,D,N,G,H,10,h[49]),G=p(G,z,D,N,I,15,h[50]),N=p(N,G,z,D,C,21,h[51]),D=p(D,N,G,z,R,6,h[52]),z=p(z,D,N,G,P,10,h[53]),G=p(G,z,D,N,j,15,h[54]),N=p(N,G,z,D,E,21,h[55]),D=p(D,N,G,z,k,6,h[56]),z=p(z,D,N,G,S,10,h[57]),G=p(G,z,D,N,M,15,h[58]),N=p(N,G,z,D,x,21,h[59]),D=p(D,N,G,z,A,6,h[60]),z=p(z,D,N,G,L,10,h[61]),G=p(G,z,D,N,T,15,h[62]),N=p(N,G,z,D,F,21,h[63]),b[0]=b[0]+D|0,b[1]=b[1]+N|0,b[2]=b[2]+G|0,b[3]=b[3]+z|0},_doFinalize:function(){var g=this._data,_=g.words,y=this._nDataBytes*8,m=g.sigBytes*8;_[m>>>5]|=128<<24-m%32;var O=r.floor(y/4294967296),b=y;_[(m+64>>>9<<4)+15]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,_[(m+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,g.sigBytes=(_.length+1)*4,this._process();for(var v=this._hash,E=v.words,T=0;T<4;T++){var P=E[T];E[T]=(P<<8|P>>>24)&16711935|(P<<24|P>>>8)&4278255360}return v},clone:function(){var g=o.clone.call(this);return g._hash=this._hash.clone(),g}});function d(g,_,y,m,O,b,v){var E=g+(_&y|~_&m)+O+v;return(E<<b|E>>>32-b)+_}function f(g,_,y,m,O,b,v){var E=g+(_&m|y&~m)+O+v;return(E<<b|E>>>32-b)+_}function u(g,_,y,m,O,b,v){var E=g+(_^y^m)+O+v;return(E<<b|E>>>32-b)+_}function p(g,_,y,m,O,b,v){var E=g+(y^(_|~m))+O+v;return(E<<b|E>>>32-b)+_}s.MD5=o._createHelper(c),s.HmacMD5=o._createHmacHelper(c)})(Math),i.MD5})}),Lv=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=s.Hasher,o=r.algo,l=[],h=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(c,d){for(var f=this._hash.words,u=f[0],p=f[1],g=f[2],_=f[3],y=f[4],m=0;m<80;m++){if(m<16)l[m]=c[d+m]|0;else{var O=l[m-3]^l[m-8]^l[m-14]^l[m-16];l[m]=O<<1|O>>>31}var b=(u<<5|u>>>27)+y+l[m];m<20?b+=(p&g|~p&_)+1518500249:m<40?b+=(p^g^_)+1859775393:m<60?b+=(p&g|p&_|g&_)-1894007588:b+=(p^g^_)-899497514,y=_,_=g,g=p<<30|p>>>2,p=u,u=b}f[0]=f[0]+u|0,f[1]=f[1]+p|0,f[2]=f[2]+g|0,f[3]=f[3]+_|0,f[4]=f[4]+y|0},_doFinalize:function(){var c=this._data,d=c.words,f=this._nDataBytes*8,u=c.sigBytes*8;return d[u>>>5]|=128<<24-u%32,d[(u+64>>>9<<4)+14]=Math.floor(f/4294967296),d[(u+64>>>9<<4)+15]=f,c.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var c=a.clone.call(this);return c._hash=this._hash.clone(),c}});r.SHA1=a._createHelper(h),r.HmacSHA1=a._createHmacHelper(h)})(),i.SHA1})}),cm=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=[],c=[];(function(){function u(y){for(var m=r.sqrt(y),O=2;O<=m;O++)if(!(y%O))return!1;return!0}function p(y){return(y-(y|0))*4294967296|0}for(var g=2,_=0;_<64;)u(g)&&(_<8&&(h[_]=p(r.pow(g,1/2))),c[_]=p(r.pow(g,1/3)),_++),g++})();var d=[],f=l.SHA256=o.extend({_doReset:function(){this._hash=new a.init(h.slice(0))},_doProcessBlock:function(u,p){for(var g=this._hash.words,_=g[0],y=g[1],m=g[2],O=g[3],b=g[4],v=g[5],E=g[6],T=g[7],P=0;P<64;P++){if(P<16)d[P]=u[p+P]|0;else{var A=d[P-15],C=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,M=d[P-2],H=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;d[P]=C+d[P-7]+H+d[P-16]}var k=b&v^~b&E,F=_&y^_&m^y&m,j=(_<<30|_>>>2)^(_<<19|_>>>13)^(_<<10|_>>>22),L=(b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25),R=T+L+k+c[P]+d[P],x=j+F;T=E,E=v,v=b,b=O+R|0,O=m,m=y,y=_,_=R+x|0}g[0]=g[0]+_|0,g[1]=g[1]+y|0,g[2]=g[2]+m|0,g[3]=g[3]+O|0,g[4]=g[4]+b|0,g[5]=g[5]+v|0,g[6]=g[6]+E|0,g[7]=g[7]+T|0},_doFinalize:function(){var u=this._data,p=u.words,g=this._nDataBytes*8,_=u.sigBytes*8;return p[_>>>5]|=128<<24-_%32,p[(_+64>>>9<<4)+14]=r.floor(g/4294967296),p[(_+64>>>9<<4)+15]=g,u.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var u=o.clone.call(this);return u._hash=this._hash.clone(),u}});s.SHA256=o._createHelper(f),s.HmacSHA256=o._createHmacHelper(f)})(Math),i.SHA256})}),FL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),cm()):typeof define=="function"&&define.amd?define(["./core","./sha256"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.algo,o=a.SHA256,l=a.SHA224=o.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var h=o._doFinalize.call(this);return h.sigBytes-=4,h}});r.SHA224=o._createHelper(l),r.HmacSHA224=o._createHmacHelper(l)})(),i.SHA224})}),Dv=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),og()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Hasher,a=r.x64,o=a.Word,l=a.WordArray,h=r.algo;function c(){return o.create.apply(o,arguments)}var d=[c(1116352408,3609767458),c(1899447441,602891725),c(3049323471,3964484399),c(3921009573,2173295548),c(961987163,4081628472),c(1508970993,3053834265),c(2453635748,2937671579),c(2870763221,3664609560),c(3624381080,2734883394),c(310598401,1164996542),c(607225278,1323610764),c(1426881987,3590304994),c(1925078388,4068182383),c(2162078206,991336113),c(2614888103,633803317),c(3248222580,3479774868),c(3835390401,2666613458),c(4022224774,944711139),c(264347078,2341262773),c(604807628,2007800933),c(770255983,1495990901),c(1249150122,1856431235),c(1555081692,3175218132),c(1996064986,2198950837),c(2554220882,3999719339),c(2821834349,766784016),c(2952996808,2566594879),c(3210313671,3203337956),c(3336571891,1034457026),c(3584528711,2466948901),c(113926993,3758326383),c(338241895,168717936),c(666307205,1188179964),c(773529912,1546045734),c(1294757372,1522805485),c(1396182291,2643833823),c(1695183700,2343527390),c(1986661051,1014477480),c(2177026350,1206759142),c(2456956037,344077627),c(2730485921,1290863460),c(2820302411,3158454273),c(3259730800,3505952657),c(3345764771,106217008),c(3516065817,3606008344),c(3600352804,1432725776),c(4094571909,1467031594),c(275423344,851169720),c(430227734,3100823752),c(506948616,1363258195),c(659060556,3750685593),c(883997877,3785050280),c(958139571,3318307427),c(1322822218,3812723403),c(1537002063,2003034995),c(1747873779,3602036899),c(1955562222,1575990012),c(2024104815,1125592928),c(2227730452,2716904306),c(2361852424,442776044),c(2428436474,593698344),c(2756734187,3733110249),c(3204031479,2999351573),c(3329325298,3815920427),c(3391569614,3928383900),c(3515267271,566280711),c(3940187606,3454069534),c(4118630271,4000239992),c(116418474,1914138554),c(174292421,2731055270),c(289380356,3203993006),c(460393269,320620315),c(685471733,587496836),c(852142971,1086792851),c(1017036298,365543100),c(1126000580,2618297676),c(1288033470,3409855158),c(1501505948,4234509866),c(1607167915,987167468),c(1816402316,1246189591)],f=[];(function(){for(var p=0;p<80;p++)f[p]=c()})();var u=h.SHA512=n.extend({_doReset:function(){this._hash=new l.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(p,g){for(var _=this._hash.words,y=_[0],m=_[1],O=_[2],b=_[3],v=_[4],E=_[5],T=_[6],P=_[7],A=y.high,C=y.low,M=m.high,H=m.low,k=O.high,F=O.low,j=b.high,L=b.low,R=v.high,x=v.low,I=E.high,S=E.low,D=T.high,N=T.low,G=P.high,z=P.low,Z=A,se=C,he=M,pe=H,Se=k,q=F,X=j,ie=L,de=R,Ce=x,De=I,Fe=S,Pe=D,w=N,B=G,V=z,Y=0;Y<80;Y++){var W,ne,ue=f[Y];if(Y<16)ne=ue.high=p[g+Y*2]|0,W=ue.low=p[g+Y*2+1]|0;else{var Re=f[Y-15],Ue=Re.high,je=Re.low,dt=(Ue>>>1|je<<31)^(Ue>>>8|je<<24)^Ue>>>7,Ot=(je>>>1|Ue<<31)^(je>>>8|Ue<<24)^(je>>>7|Ue<<25),Lt=f[Y-2],hi=Lt.high,Q=Lt.low,ke=(hi>>>19|Q<<13)^(hi<<3|Q>>>29)^hi>>>6,Ge=(Q>>>19|hi<<13)^(Q<<3|hi>>>29)^(Q>>>6|hi<<26),qe=f[Y-7],me=qe.high,Me=qe.low,J=f[Y-16],ze=J.high,mt=J.low;W=Ot+Me,ne=dt+me+(W>>>0<Ot>>>0?1:0),W=W+Ge,ne=ne+ke+(W>>>0<Ge>>>0?1:0),W=W+mt,ne=ne+ze+(W>>>0<mt>>>0?1:0),ue.high=ne,ue.low=W}var U=de&De^~de&Pe,Le=Ce&Fe^~Ce&w,Ne=Z&he^Z&Se^he&Se,K=se&pe^se&q^pe&q,_e=(Z>>>28|se<<4)^(Z<<30|se>>>2)^(Z<<25|se>>>7),Ae=(se>>>28|Z<<4)^(se<<30|Z>>>2)^(se<<25|Z>>>7),ft=(de>>>14|Ce<<18)^(de>>>18|Ce<<14)^(de<<23|Ce>>>9),Ze=(Ce>>>14|de<<18)^(Ce>>>18|de<<14)^(Ce<<23|de>>>9),Ke=d[Y],Ft=Ke.high,Ps=Ke.low,vt=V+Ze,bt=B+ft+(vt>>>0<V>>>0?1:0),vt=vt+Le,bt=bt+U+(vt>>>0<Le>>>0?1:0),vt=vt+Ps,bt=bt+Ft+(vt>>>0<Ps>>>0?1:0),vt=vt+W,bt=bt+ne+(vt>>>0<W>>>0?1:0),ki=Ae+K,_r=_e+Ne+(ki>>>0<Ae>>>0?1:0);B=Pe,V=w,Pe=De,w=Fe,De=de,Fe=Ce,Ce=ie+vt|0,de=X+bt+(Ce>>>0<ie>>>0?1:0)|0,X=Se,ie=q,Se=he,q=pe,he=Z,pe=se,se=vt+ki|0,Z=bt+_r+(se>>>0<vt>>>0?1:0)|0}C=y.low=C+se,y.high=A+Z+(C>>>0<se>>>0?1:0),H=m.low=H+pe,m.high=M+he+(H>>>0<pe>>>0?1:0),F=O.low=F+q,O.high=k+Se+(F>>>0<q>>>0?1:0),L=b.low=L+ie,b.high=j+X+(L>>>0<ie>>>0?1:0),x=v.low=x+Ce,v.high=R+de+(x>>>0<Ce>>>0?1:0),S=E.low=S+Fe,E.high=I+De+(S>>>0<Fe>>>0?1:0),N=T.low=N+w,T.high=D+Pe+(N>>>0<w>>>0?1:0),z=P.low=z+V,P.high=G+B+(z>>>0<V>>>0?1:0)},_doFinalize:function(){var p=this._data,g=p.words,_=this._nDataBytes*8,y=p.sigBytes*8;g[y>>>5]|=128<<24-y%32,g[(y+128>>>10<<5)+30]=Math.floor(_/4294967296),g[(y+128>>>10<<5)+31]=_,p.sigBytes=g.length*4,this._process();var m=this._hash.toX32();return m},clone:function(){var p=n.clone.call(this);return p._hash=this._hash.clone(),p},blockSize:1024/32});r.SHA512=n._createHelper(u),r.HmacSHA512=n._createHmacHelper(u)})(),i.SHA512})}),UL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),og(),Dv()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./sha512"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.x64,n=s.Word,a=s.WordArray,o=r.algo,l=o.SHA512,h=o.SHA384=l.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var c=l._doFinalize.call(this);return c.sigBytes-=16,c}});r.SHA384=l._createHelper(h),r.HmacSHA384=l._createHmacHelper(h)})(),i.SHA384})}),GL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),og()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.x64,h=l.Word,c=s.algo,d=[],f=[],u=[];(function(){for(var _=1,y=0,m=0;m<24;m++){d[_+5*y]=(m+1)*(m+2)/2%64;var O=y%5,b=(2*_+3*y)%5;_=O,y=b}for(var _=0;_<5;_++)for(var y=0;y<5;y++)f[_+5*y]=y+(2*_+3*y)%5*5;for(var v=1,E=0;E<24;E++){for(var T=0,P=0,A=0;A<7;A++){if(v&1){var C=(1<<A)-1;C<32?P^=1<<C:T^=1<<C-32}v&128?v=v<<1^113:v<<=1}u[E]=h.create(T,P)}})();var p=[];(function(){for(var _=0;_<25;_++)p[_]=h.create()})();var g=c.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var _=this._state=[],y=0;y<25;y++)_[y]=new h.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(_,y){for(var m=this._state,O=this.blockSize/2,b=0;b<O;b++){var v=_[y+2*b],E=_[y+2*b+1];v=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,E=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360;var T=m[b];T.high^=E,T.low^=v}for(var P=0;P<24;P++){for(var A=0;A<5;A++){for(var C=0,M=0,H=0;H<5;H++){var T=m[A+5*H];C^=T.high,M^=T.low}var k=p[A];k.high=C,k.low=M}for(var A=0;A<5;A++)for(var F=p[(A+4)%5],j=p[(A+1)%5],L=j.high,R=j.low,C=F.high^(L<<1|R>>>31),M=F.low^(R<<1|L>>>31),H=0;H<5;H++){var T=m[A+5*H];T.high^=C,T.low^=M}for(var x=1;x<25;x++){var C,M,T=m[x],I=T.high,S=T.low,D=d[x];D<32?(C=I<<D|S>>>32-D,M=S<<D|I>>>32-D):(C=S<<D-32|I>>>64-D,M=I<<D-32|S>>>64-D);var N=p[f[x]];N.high=C,N.low=M}var G=p[0],z=m[0];G.high=z.high,G.low=z.low;for(var A=0;A<5;A++)for(var H=0;H<5;H++){var x=A+5*H,T=m[x],Z=p[x],se=p[(A+1)%5+5*H],he=p[(A+2)%5+5*H];T.high=Z.high^~se.high&he.high,T.low=Z.low^~se.low&he.low}var T=m[0],pe=u[P];T.high^=pe.high,T.low^=pe.low}},_doFinalize:function(){var _=this._data,y=_.words,m=this._nDataBytes*8,O=_.sigBytes*8,b=this.blockSize*32;y[O>>>5]|=1<<24-O%32,y[(r.ceil((O+1)/b)*b>>>5)-1]|=128,_.sigBytes=y.length*4,this._process();for(var v=this._state,E=this.cfg.outputLength/8,T=E/8,P=[],A=0;A<T;A++){var C=v[A],M=C.high,H=C.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,H=(H<<8|H>>>24)&16711935|(H<<24|H>>>8)&4278255360,P.push(H),P.push(M)}return new a.init(P,E)},clone:function(){for(var _=o.clone.call(this),y=_._state=this._state.slice(0),m=0;m<25;m++)y[m]=y[m].clone();return _}});s.SHA3=o._createHelper(g),s.HmacSHA3=o._createHmacHelper(g)})(Math),i.SHA3})}),zL=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),d=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=a.create([0,1518500249,1859775393,2400959708,2840853838]),p=a.create([1352829926,1548603684,1836072691,2053994217,0]),g=l.RIPEMD160=o.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(E,T){for(var P=0;P<16;P++){var A=T+P,C=E[A];E[A]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360}var M=this._hash.words,H=u.words,k=p.words,F=h.words,j=c.words,L=d.words,R=f.words,x,I,S,D,N,G,z,Z,se,he;G=x=M[0],z=I=M[1],Z=S=M[2],se=D=M[3],he=N=M[4];for(var pe,P=0;P<80;P+=1)pe=x+E[T+F[P]]|0,P<16?pe+=_(I,S,D)+H[0]:P<32?pe+=y(I,S,D)+H[1]:P<48?pe+=m(I,S,D)+H[2]:P<64?pe+=O(I,S,D)+H[3]:pe+=b(I,S,D)+H[4],pe=pe|0,pe=v(pe,L[P]),pe=pe+N|0,x=N,N=D,D=v(S,10),S=I,I=pe,pe=G+E[T+j[P]]|0,P<16?pe+=b(z,Z,se)+k[0]:P<32?pe+=O(z,Z,se)+k[1]:P<48?pe+=m(z,Z,se)+k[2]:P<64?pe+=y(z,Z,se)+k[3]:pe+=_(z,Z,se)+k[4],pe=pe|0,pe=v(pe,R[P]),pe=pe+he|0,G=he,he=se,se=v(Z,10),Z=z,z=pe;pe=M[1]+S+se|0,M[1]=M[2]+D+he|0,M[2]=M[3]+N+G|0,M[3]=M[4]+x+z|0,M[4]=M[0]+I+Z|0,M[0]=pe},_doFinalize:function(){var E=this._data,T=E.words,P=this._nDataBytes*8,A=E.sigBytes*8;T[A>>>5]|=128<<24-A%32,T[(A+64>>>9<<4)+14]=(P<<8|P>>>24)&16711935|(P<<24|P>>>8)&4278255360,E.sigBytes=(T.length+1)*4,this._process();for(var C=this._hash,M=C.words,H=0;H<5;H++){var k=M[H];M[H]=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360}return C},clone:function(){var E=o.clone.call(this);return E._hash=this._hash.clone(),E}});function _(E,T,P){return E^T^P}function y(E,T,P){return E&T|~E&P}function m(E,T,P){return(E|~T)^P}function O(E,T,P){return E&P|T&~P}function b(E,T,P){return E^(T|~P)}function v(E,T){return E<<T|E>>>32-T}s.RIPEMD160=o._createHelper(g),s.HmacRIPEMD160=o._createHmacHelper(g)})(Math),i.RIPEMD160})}),um=Xt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ti()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){(function(){var r=i,s=r.lib,n=s.Base,a=r.enc,o=a.Utf8,l=r.algo,h=l.HMAC=n.extend({init:function(c,d){c=this._hasher=new c.init,typeof d=="string"&&(d=o.parse(d));var f=c.blockSize,u=f*4;d.sigBytes>u&&(d=c.finalize(d)),d.clamp();for(var p=this._oKey=d.clone(),g=this._iKey=d.clone(),_=p.words,y=g.words,m=0;m<f;m++)_[m]^=1549556828,y[m]^=909522486;p.sigBytes=g.sigBytes=u,this.reset()},reset:function(){var c=this._hasher;c.reset(),c.update(this._iKey)},update:function(c){return this._hasher.update(c),this},finalize:function(c){var d=this._hasher,f=d.finalize(c);d.reset();var u=d.finalize(this._oKey.clone().concat(f));return u}})})()})}),HL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),cm(),um()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Base,a=s.WordArray,o=r.algo,l=o.SHA256,h=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:128/32,hasher:l,iterations:25e4}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,f){for(var u=this.cfg,p=h.create(u.hasher,d),g=a.create(),_=a.create([1]),y=g.words,m=_.words,O=u.keySize,b=u.iterations;y.length<O;){var v=p.update(f).finalize(_);p.reset();for(var E=v.words,T=E.length,P=v,A=1;A<b;A++){P=p.finalize(P),p.reset();for(var C=P.words,M=0;M<T;M++)E[M]^=C[M]}g.concat(v),m[0]++}return g.sigBytes=O*4,g}});r.PBKDF2=function(d,f,u){return c.create(u).compute(d,f)}})(),i.PBKDF2})}),Vo=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Lv(),um()):typeof define=="function"&&define.amd?define(["./core","./sha1","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Base,a=s.WordArray,o=r.algo,l=o.MD5,h=o.EvpKDF=n.extend({cfg:n.extend({keySize:128/32,hasher:l,iterations:1}),init:function(c){this.cfg=this.cfg.extend(c)},compute:function(c,d){for(var f,u=this.cfg,p=u.hasher.create(),g=a.create(),_=g.words,y=u.keySize,m=u.iterations;_.length<y;){f&&p.update(f),f=p.update(c).finalize(d),p.reset();for(var O=1;O<m;O++)f=p.finalize(f),p.reset();g.concat(f)}return g.sigBytes=y*4,g}});r.EvpKDF=function(c,d,f){return h.create(f).compute(c,d)}})(),i.EvpKDF})}),Vr=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vo()):typeof define=="function"&&define.amd?define(["./core","./evpkdf"],r):r(i.CryptoJS)})(e,function(i){i.lib.Cipher||(function(r){var s=i,n=s.lib,a=n.Base,o=n.WordArray,l=n.BufferedBlockAlgorithm,h=s.enc,c=h.Utf8,d=h.Base64,f=s.algo,u=f.EvpKDF,p=n.Cipher=l.extend({cfg:a.extend(),createEncryptor:function(k,F){return this.create(this._ENC_XFORM_MODE,k,F)},createDecryptor:function(k,F){return this.create(this._DEC_XFORM_MODE,k,F)},init:function(k,F,j){this.cfg=this.cfg.extend(j),this._xformMode=k,this._key=F,this.reset()},reset:function(){l.reset.call(this),this._doReset()},process:function(k){return this._append(k),this._process()},finalize:function(k){k&&this._append(k);var F=this._doFinalize();return F},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function k(F){return typeof F=="string"?H:A}return function(F){return{encrypt:function(j,L,R){return k(L).encrypt(F,j,L,R)},decrypt:function(j,L,R){return k(L).decrypt(F,j,L,R)}}}})()}),g=n.StreamCipher=p.extend({_doFinalize:function(){var k=this._process(!0);return k},blockSize:1}),_=s.mode={},y=n.BlockCipherMode=a.extend({createEncryptor:function(k,F){return this.Encryptor.create(k,F)},createDecryptor:function(k,F){return this.Decryptor.create(k,F)},init:function(k,F){this._cipher=k,this._iv=F}}),m=_.CBC=(function(){var k=y.extend();k.Encryptor=k.extend({processBlock:function(j,L){var R=this._cipher,x=R.blockSize;F.call(this,j,L,x),R.encryptBlock(j,L),this._prevBlock=j.slice(L,L+x)}}),k.Decryptor=k.extend({processBlock:function(j,L){var R=this._cipher,x=R.blockSize,I=j.slice(L,L+x);R.decryptBlock(j,L),F.call(this,j,L,x),this._prevBlock=I}});function F(j,L,R){var x,I=this._iv;I?(x=I,this._iv=r):x=this._prevBlock;for(var S=0;S<R;S++)j[L+S]^=x[S]}return k})(),O=s.pad={},b=O.Pkcs7={pad:function(k,F){for(var j=F*4,L=j-k.sigBytes%j,R=L<<24|L<<16|L<<8|L,x=[],I=0;I<L;I+=4)x.push(R);var S=o.create(x,L);k.concat(S)},unpad:function(k){var F=k.words[k.sigBytes-1>>>2]&255;k.sigBytes-=F}},v=n.BlockCipher=p.extend({cfg:p.cfg.extend({mode:m,padding:b}),reset:function(){var k;p.reset.call(this);var F=this.cfg,j=F.iv,L=F.mode;this._xformMode==this._ENC_XFORM_MODE?k=L.createEncryptor:(k=L.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==k?this._mode.init(this,j&&j.words):(this._mode=k.call(L,this,j&&j.words),this._mode.__creator=k)},_doProcessBlock:function(k,F){this._mode.processBlock(k,F)},_doFinalize:function(){var k,F=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(F.pad(this._data,this.blockSize),k=this._process(!0)):(k=this._process(!0),F.unpad(k)),k},blockSize:128/32}),E=n.CipherParams=a.extend({init:function(k){this.mixIn(k)},toString:function(k){return(k||this.formatter).stringify(this)}}),T=s.format={},P=T.OpenSSL={stringify:function(k){var F,j=k.ciphertext,L=k.salt;return L?F=o.create([1398893684,1701076831]).concat(L).concat(j):F=j,F.toString(d)},parse:function(k){var F,j=d.parse(k),L=j.words;return L[0]==1398893684&&L[1]==1701076831&&(F=o.create(L.slice(2,4)),L.splice(0,4),j.sigBytes-=16),E.create({ciphertext:j,salt:F})}},A=n.SerializableCipher=a.extend({cfg:a.extend({format:P}),encrypt:function(k,F,j,L){L=this.cfg.extend(L);var R=k.createEncryptor(j,L),x=R.finalize(F),I=R.cfg;return E.create({ciphertext:x,key:j,iv:I.iv,algorithm:k,mode:I.mode,padding:I.padding,blockSize:k.blockSize,formatter:L.format})},decrypt:function(k,F,j,L){L=this.cfg.extend(L),F=this._parse(F,L.format);var R=k.createDecryptor(j,L).finalize(F.ciphertext);return R},_parse:function(k,F){return typeof k=="string"?F.parse(k,this):k}}),C=s.kdf={},M=C.OpenSSL={execute:function(k,F,j,L,R){if(L||(L=o.random(64/8)),R)var x=u.create({keySize:F+j,hasher:R}).compute(k,L);else var x=u.create({keySize:F+j}).compute(k,L);var I=o.create(x.words.slice(F),j*4);return x.sigBytes=F*4,E.create({key:x,iv:I,salt:L})}},H=n.PasswordBasedCipher=A.extend({cfg:A.cfg.extend({kdf:M}),encrypt:function(k,F,j,L){L=this.cfg.extend(L);var R=L.kdf.execute(j,k.keySize,k.ivSize,L.salt,L.hasher);L.iv=R.iv;var x=A.encrypt.call(this,k,F,R.key,L);return x.mixIn(R),x},decrypt:function(k,F,j,L){L=this.cfg.extend(L),F=this._parse(F,L.format);var R=L.kdf.execute(j,k.keySize,k.ivSize,F.salt,L.hasher);L.iv=R.iv;var x=A.decrypt.call(this,k,F,R.key,L);return x}})})()})}),jL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CFB=(function(){var r=i.lib.BlockCipherMode.extend();r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize;s.call(this,n,a,l,o),this._prevBlock=n.slice(a,a+l)}}),r.Decryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=n.slice(a,a+l);s.call(this,n,a,l,o),this._prevBlock=h}});function s(n,a,o,l){var h,c=this._iv;c?(h=c.slice(0),this._iv=void 0):h=this._prevBlock,l.encryptBlock(h,0);for(var d=0;d<o;d++)n[a+d]^=h[d]}return r})(),i.mode.CFB})}),VL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTR=(function(){var r=i.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=this._iv,c=this._counter;h&&(c=this._counter=h.slice(0),this._iv=void 0);var d=c.slice(0);o.encryptBlock(d,0),c[l-1]=c[l-1]+1|0;for(var f=0;f<l;f++)n[a+f]^=d[f]}});return r.Decryptor=s,r})(),i.mode.CTR})}),YL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTRGladman=(function(){var r=i.lib.BlockCipherMode.extend();function s(o){if((o>>24&255)===255){var l=o>>16&255,h=o>>8&255,c=o&255;l===255?(l=0,h===255?(h=0,c===255?c=0:++c):++h):++l,o=0,o+=l<<16,o+=h<<8,o+=c}else o+=1<<24;return o}function n(o){return(o[0]=s(o[0]))===0&&(o[1]=s(o[1])),o}var a=r.Encryptor=r.extend({processBlock:function(o,l){var h=this._cipher,c=h.blockSize,d=this._iv,f=this._counter;d&&(f=this._counter=d.slice(0),this._iv=void 0),n(f);var u=f.slice(0);h.encryptBlock(u,0);for(var p=0;p<c;p++)o[l+p]^=u[p]}});return r.Decryptor=a,r})(),i.mode.CTRGladman})}),qL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.OFB=(function(){var r=i.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=this._iv,c=this._keystream;h&&(c=this._keystream=h.slice(0),this._iv=void 0),o.encryptBlock(c,0);for(var d=0;d<l;d++)n[a+d]^=c[d]}});return r.Decryptor=s,r})(),i.mode.OFB})}),WL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.ECB=(function(){var r=i.lib.BlockCipherMode.extend();return r.Encryptor=r.extend({processBlock:function(s,n){this._cipher.encryptBlock(s,n)}}),r.Decryptor=r.extend({processBlock:function(s,n){this._cipher.decryptBlock(s,n)}}),r})(),i.mode.ECB})}),XL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.AnsiX923={pad:function(r,s){var n=r.sigBytes,a=s*4,o=a-n%a,l=n+o-1;r.clamp(),r.words[l>>>2]|=o<<24-l%4*8,r.sigBytes+=o},unpad:function(r){var s=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=s}},i.pad.Ansix923})}),JL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso10126={pad:function(r,s){var n=s*4,a=n-r.sigBytes%n;r.concat(i.lib.WordArray.random(a-1)).concat(i.lib.WordArray.create([a<<24],1))},unpad:function(r){var s=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=s}},i.pad.Iso10126})}),ZL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso97971={pad:function(r,s){r.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(r,s)},unpad:function(r){i.pad.ZeroPadding.unpad(r),r.sigBytes--}},i.pad.Iso97971})}),KL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.ZeroPadding={pad:function(r,s){var n=s*4;r.clamp(),r.sigBytes+=n-(r.sigBytes%n||n)},unpad:function(r){for(var s=r.words,n=r.sigBytes-1,n=r.sigBytes-1;n>=0;n--)if(s[n>>>2]>>>24-n%4*8&255){r.sigBytes=n+1;break}}},i.pad.ZeroPadding})}),$L=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding})}),QL=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Vr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.CipherParams,o=s.enc,l=o.Hex,h=s.format,c=h.Hex={stringify:function(d){return d.ciphertext.toString(l)},parse:function(d){var f=l.parse(d);return a.create({ciphertext:f})}}})(),i.format.Hex})}),eD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.BlockCipher,a=r.algo,o=[],l=[],h=[],c=[],d=[],f=[],u=[],p=[],g=[],_=[];(function(){for(var O=[],b=0;b<256;b++)b<128?O[b]=b<<1:O[b]=b<<1^283;for(var v=0,E=0,b=0;b<256;b++){var T=E^E<<1^E<<2^E<<3^E<<4;T=T>>>8^T&255^99,o[v]=T,l[T]=v;var P=O[v],A=O[P],C=O[A],M=O[T]*257^T*16843008;h[v]=M<<24|M>>>8,c[v]=M<<16|M>>>16,d[v]=M<<8|M>>>24,f[v]=M;var M=C*16843009^A*65537^P*257^v*16843008;u[T]=M<<24|M>>>8,p[T]=M<<16|M>>>16,g[T]=M<<8|M>>>24,_[T]=M,v?(v=P^O[O[O[C^P]]],E^=O[O[E]]):v=E=1}})();var y=[0,1,2,4,8,16,32,64,128,27,54],m=a.AES=n.extend({_doReset:function(){var O;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var b=this._keyPriorReset=this._key,v=b.words,E=b.sigBytes/4,T=this._nRounds=E+6,P=(T+1)*4,A=this._keySchedule=[],C=0;C<P;C++)C<E?A[C]=v[C]:(O=A[C-1],C%E?E>6&&C%E==4&&(O=o[O>>>24]<<24|o[O>>>16&255]<<16|o[O>>>8&255]<<8|o[O&255]):(O=O<<8|O>>>24,O=o[O>>>24]<<24|o[O>>>16&255]<<16|o[O>>>8&255]<<8|o[O&255],O^=y[C/E|0]<<24),A[C]=A[C-E]^O);for(var M=this._invKeySchedule=[],H=0;H<P;H++){var C=P-H;if(H%4)var O=A[C];else var O=A[C-4];H<4||C<=4?M[H]=O:M[H]=u[o[O>>>24]]^p[o[O>>>16&255]]^g[o[O>>>8&255]]^_[o[O&255]]}}},encryptBlock:function(O,b){this._doCryptBlock(O,b,this._keySchedule,h,c,d,f,o)},decryptBlock:function(O,b){var v=O[b+1];O[b+1]=O[b+3],O[b+3]=v,this._doCryptBlock(O,b,this._invKeySchedule,u,p,g,_,l);var v=O[b+1];O[b+1]=O[b+3],O[b+3]=v},_doCryptBlock:function(O,b,v,E,T,P,A,C){for(var M=this._nRounds,H=O[b]^v[0],k=O[b+1]^v[1],F=O[b+2]^v[2],j=O[b+3]^v[3],L=4,R=1;R<M;R++){var x=E[H>>>24]^T[k>>>16&255]^P[F>>>8&255]^A[j&255]^v[L++],I=E[k>>>24]^T[F>>>16&255]^P[j>>>8&255]^A[H&255]^v[L++],S=E[F>>>24]^T[j>>>16&255]^P[H>>>8&255]^A[k&255]^v[L++],D=E[j>>>24]^T[H>>>16&255]^P[k>>>8&255]^A[F&255]^v[L++];H=x,k=I,F=S,j=D}var x=(C[H>>>24]<<24|C[k>>>16&255]<<16|C[F>>>8&255]<<8|C[j&255])^v[L++],I=(C[k>>>24]<<24|C[F>>>16&255]<<16|C[j>>>8&255]<<8|C[H&255])^v[L++],S=(C[F>>>24]<<24|C[j>>>16&255]<<16|C[H>>>8&255]<<8|C[k&255])^v[L++],D=(C[j>>>24]<<24|C[H>>>16&255]<<16|C[k>>>8&255]<<8|C[F&255])^v[L++];O[b]=x,O[b+1]=I,O[b+2]=S,O[b+3]=D},keySize:256/32});r.AES=n._createHelper(m)})(),i.AES})}),tD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=s.BlockCipher,o=r.algo,l=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],h=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=o.DES=a.extend({_doReset:function(){for(var y=this._key,m=y.words,O=[],b=0;b<56;b++){var v=l[b]-1;O[b]=m[v>>>5]>>>31-v%32&1}for(var E=this._subKeys=[],T=0;T<16;T++){for(var P=E[T]=[],A=c[T],b=0;b<24;b++)P[b/6|0]|=O[(h[b]-1+A)%28]<<31-b%6,P[4+(b/6|0)]|=O[28+(h[b+24]-1+A)%28]<<31-b%6;P[0]=P[0]<<1|P[0]>>>31;for(var b=1;b<7;b++)P[b]=P[b]>>>(b-1)*4+3;P[7]=P[7]<<5|P[7]>>>27}for(var C=this._invSubKeys=[],b=0;b<16;b++)C[b]=E[15-b]},encryptBlock:function(y,m){this._doCryptBlock(y,m,this._subKeys)},decryptBlock:function(y,m){this._doCryptBlock(y,m,this._invSubKeys)},_doCryptBlock:function(y,m,O){this._lBlock=y[m],this._rBlock=y[m+1],p.call(this,4,252645135),p.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),p.call(this,1,1431655765);for(var b=0;b<16;b++){for(var v=O[b],E=this._lBlock,T=this._rBlock,P=0,A=0;A<8;A++)P|=d[A][((T^v[A])&f[A])>>>0];this._lBlock=T,this._rBlock=E^P}var C=this._lBlock;this._lBlock=this._rBlock,this._rBlock=C,p.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),y[m]=this._lBlock,y[m+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function p(y,m){var O=(this._lBlock>>>y^this._rBlock)&m;this._rBlock^=O,this._lBlock^=O<<y}function g(y,m){var O=(this._rBlock>>>y^this._lBlock)&m;this._lBlock^=O,this._rBlock^=O<<y}r.DES=a._createHelper(u);var _=o.TripleDES=a.extend({_doReset:function(){var y=this._key,m=y.words;if(m.length!==2&&m.length!==4&&m.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var O=m.slice(0,2),b=m.length<4?m.slice(0,2):m.slice(2,4),v=m.length<6?m.slice(0,2):m.slice(4,6);this._des1=u.createEncryptor(n.create(O)),this._des2=u.createEncryptor(n.create(b)),this._des3=u.createEncryptor(n.create(v))},encryptBlock:function(y,m){this._des1.encryptBlock(y,m),this._des2.decryptBlock(y,m),this._des3.encryptBlock(y,m)},decryptBlock:function(y,m){this._des3.decryptBlock(y,m),this._des2.encryptBlock(y,m),this._des1.decryptBlock(y,m)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(_)})(),i.TripleDES})}),iD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=a.RC4=n.extend({_doReset:function(){for(var c=this._key,d=c.words,f=c.sigBytes,u=this._S=[],p=0;p<256;p++)u[p]=p;for(var p=0,g=0;p<256;p++){var _=p%f,y=d[_>>>2]>>>24-_%4*8&255;g=(g+u[p]+y)%256;var m=u[p];u[p]=u[g],u[g]=m}this._i=this._j=0},_doProcessBlock:function(c,d){c[d]^=l.call(this)},keySize:256/32,ivSize:0});function l(){for(var c=this._S,d=this._i,f=this._j,u=0,p=0;p<4;p++){d=(d+1)%256,f=(f+c[d])%256;var g=c[d];c[d]=c[f],c[f]=g,u|=c[(c[d]+c[f])%256]<<24-p*8}return this._i=d,this._j=f,u}r.RC4=n._createHelper(o);var h=a.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var c=this.cfg.drop;c>0;c--)l.call(this)}});r.RC4Drop=n._createHelper(h)})(),i.RC4})}),rD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=[],l=[],h=[],c=a.Rabbit=n.extend({_doReset:function(){for(var f=this._key.words,u=this.cfg.iv,p=0;p<4;p++)f[p]=(f[p]<<8|f[p]>>>24)&16711935|(f[p]<<24|f[p]>>>8)&4278255360;var g=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],_=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var p=0;p<4;p++)d.call(this);for(var p=0;p<8;p++)_[p]^=g[p+4&7];if(u){var y=u.words,m=y[0],O=y[1],b=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,v=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,E=b>>>16|v&4294901760,T=v<<16|b&65535;_[0]^=b,_[1]^=E,_[2]^=v,_[3]^=T,_[4]^=b,_[5]^=E,_[6]^=v,_[7]^=T;for(var p=0;p<4;p++)d.call(this)}},_doProcessBlock:function(f,u){var p=this._X;d.call(this),o[0]=p[0]^p[5]>>>16^p[3]<<16,o[1]=p[2]^p[7]>>>16^p[5]<<16,o[2]=p[4]^p[1]>>>16^p[7]<<16,o[3]=p[6]^p[3]>>>16^p[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,f[u+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var f=this._X,u=this._C,p=0;p<8;p++)l[p]=u[p];u[0]=u[0]+1295307597+this._b|0,u[1]=u[1]+3545052371+(u[0]>>>0<l[0]>>>0?1:0)|0,u[2]=u[2]+886263092+(u[1]>>>0<l[1]>>>0?1:0)|0,u[3]=u[3]+1295307597+(u[2]>>>0<l[2]>>>0?1:0)|0,u[4]=u[4]+3545052371+(u[3]>>>0<l[3]>>>0?1:0)|0,u[5]=u[5]+886263092+(u[4]>>>0<l[4]>>>0?1:0)|0,u[6]=u[6]+1295307597+(u[5]>>>0<l[5]>>>0?1:0)|0,u[7]=u[7]+3545052371+(u[6]>>>0<l[6]>>>0?1:0)|0,this._b=u[7]>>>0<l[7]>>>0?1:0;for(var p=0;p<8;p++){var g=f[p]+u[p],_=g&65535,y=g>>>16,m=((_*_>>>17)+_*y>>>15)+y*y,O=((g&4294901760)*g|0)+((g&65535)*g|0);h[p]=m^O}f[0]=h[0]+(h[7]<<16|h[7]>>>16)+(h[6]<<16|h[6]>>>16)|0,f[1]=h[1]+(h[0]<<8|h[0]>>>24)+h[7]|0,f[2]=h[2]+(h[1]<<16|h[1]>>>16)+(h[0]<<16|h[0]>>>16)|0,f[3]=h[3]+(h[2]<<8|h[2]>>>24)+h[1]|0,f[4]=h[4]+(h[3]<<16|h[3]>>>16)+(h[2]<<16|h[2]>>>16)|0,f[5]=h[5]+(h[4]<<8|h[4]>>>24)+h[3]|0,f[6]=h[6]+(h[5]<<16|h[5]>>>16)+(h[4]<<16|h[4]>>>16)|0,f[7]=h[7]+(h[6]<<8|h[6]>>>24)+h[5]|0}r.Rabbit=n._createHelper(c)})(),i.Rabbit})}),sD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=[],l=[],h=[],c=a.RabbitLegacy=n.extend({_doReset:function(){var f=this._key.words,u=this.cfg.iv,p=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],g=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var _=0;_<4;_++)d.call(this);for(var _=0;_<8;_++)g[_]^=p[_+4&7];if(u){var y=u.words,m=y[0],O=y[1],b=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,v=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,E=b>>>16|v&4294901760,T=v<<16|b&65535;g[0]^=b,g[1]^=E,g[2]^=v,g[3]^=T,g[4]^=b,g[5]^=E,g[6]^=v,g[7]^=T;for(var _=0;_<4;_++)d.call(this)}},_doProcessBlock:function(f,u){var p=this._X;d.call(this),o[0]=p[0]^p[5]>>>16^p[3]<<16,o[1]=p[2]^p[7]>>>16^p[5]<<16,o[2]=p[4]^p[1]>>>16^p[7]<<16,o[3]=p[6]^p[3]>>>16^p[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,f[u+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var f=this._X,u=this._C,p=0;p<8;p++)l[p]=u[p];u[0]=u[0]+1295307597+this._b|0,u[1]=u[1]+3545052371+(u[0]>>>0<l[0]>>>0?1:0)|0,u[2]=u[2]+886263092+(u[1]>>>0<l[1]>>>0?1:0)|0,u[3]=u[3]+1295307597+(u[2]>>>0<l[2]>>>0?1:0)|0,u[4]=u[4]+3545052371+(u[3]>>>0<l[3]>>>0?1:0)|0,u[5]=u[5]+886263092+(u[4]>>>0<l[4]>>>0?1:0)|0,u[6]=u[6]+1295307597+(u[5]>>>0<l[5]>>>0?1:0)|0,u[7]=u[7]+3545052371+(u[6]>>>0<l[6]>>>0?1:0)|0,this._b=u[7]>>>0<l[7]>>>0?1:0;for(var p=0;p<8;p++){var g=f[p]+u[p],_=g&65535,y=g>>>16,m=((_*_>>>17)+_*y>>>15)+y*y,O=((g&4294901760)*g|0)+((g&65535)*g|0);h[p]=m^O}f[0]=h[0]+(h[7]<<16|h[7]>>>16)+(h[6]<<16|h[6]>>>16)|0,f[1]=h[1]+(h[0]<<8|h[0]>>>24)+h[7]|0,f[2]=h[2]+(h[1]<<16|h[1]>>>16)+(h[0]<<16|h[0]>>>16)|0,f[3]=h[3]+(h[2]<<8|h[2]>>>24)+h[1]|0,f[4]=h[4]+(h[3]<<16|h[3]>>>16)+(h[2]<<16|h[2]>>>16)|0,f[5]=h[5]+(h[4]<<8|h[4]>>>24)+h[3]|0,f[6]=h[6]+(h[5]<<16|h[5]>>>16)+(h[4]<<16|h[4]>>>16)|0,f[7]=h[7]+(h[6]<<8|h[6]>>>24)+h[5]|0}r.RabbitLegacy=n._createHelper(c)})(),i.RabbitLegacy})}),nD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),Ul(),Gl(),Vo(),Vr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.BlockCipher,a=r.algo;let o=16,l=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],h=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var c={pbox:[],sbox:[]};function d(_,y){let m=y>>24&255,O=y>>16&255,b=y>>8&255,v=y&255,E=_.sbox[0][m]+_.sbox[1][O];return E=E^_.sbox[2][b],E=E+_.sbox[3][v],E}function f(_,y,m){let O=y,b=m,v;for(let E=0;E<o;++E)O=O^_.pbox[E],b=d(_,O)^b,v=O,O=b,b=v;return v=O,O=b,b=v,b=b^_.pbox[o],O=O^_.pbox[o+1],{left:O,right:b}}function u(_,y,m){let O=y,b=m,v;for(let E=o+1;E>1;--E)O=O^_.pbox[E],b=d(_,O)^b,v=O,O=b,b=v;return v=O,O=b,b=v,b=b^_.pbox[1],O=O^_.pbox[0],{left:O,right:b}}function p(_,y,m){for(let T=0;T<4;T++){_.sbox[T]=[];for(let P=0;P<256;P++)_.sbox[T][P]=h[T][P]}let O=0;for(let T=0;T<o+2;T++)_.pbox[T]=l[T]^y[O],O++,O>=m&&(O=0);let b=0,v=0,E=0;for(let T=0;T<o+2;T+=2)E=f(_,b,v),b=E.left,v=E.right,_.pbox[T]=b,_.pbox[T+1]=v;for(let T=0;T<4;T++)for(let P=0;P<256;P+=2)E=f(_,b,v),b=E.left,v=E.right,_.sbox[T][P]=b,_.sbox[T][P+1]=v;return!0}var g=a.Blowfish=n.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var _=this._keyPriorReset=this._key,y=_.words,m=_.sigBytes/4;p(c,y,m)}},encryptBlock:function(_,y){var m=f(c,_[y],_[y+1]);_[y]=m.left,_[y+1]=m.right},decryptBlock:function(_,y){var m=u(c,_[y],_[y+1]);_[y]=m.left,_[y+1]=m.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=n._createHelper(g)})(),i.Blowfish})}),aD=Xt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ti(),og(),ML(),BL(),Ul(),kL(),Gl(),Lv(),cm(),FL(),Dv(),UL(),GL(),zL(),um(),HL(),Vo(),Vr(),jL(),VL(),YL(),qL(),WL(),XL(),JL(),ZL(),KL(),$L(),QL(),eD(),tD(),iD(),rD(),sD(),nD()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./lib-typedarrays","./enc-utf16","./enc-base64","./enc-base64url","./md5","./sha1","./sha256","./sha224","./sha512","./sha384","./sha3","./ripemd160","./hmac","./pbkdf2","./evpkdf","./cipher-core","./mode-cfb","./mode-ctr","./mode-ctr-gladman","./mode-ofb","./mode-ecb","./pad-ansix923","./pad-iso10126","./pad-iso97971","./pad-zeropadding","./pad-nopadding","./format-hex","./aes","./tripledes","./rc4","./rabbit","./rabbit-legacy","./blowfish"],r):i.CryptoJS=r(i.CryptoJS)})(e,function(i){return i})}),oD=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e.OBJ="OBJ",e.ModelID="3D Model",e.ModelName="3D Model Title",e.OriginModelName="Origin 3D Model Title",e.ModelTransform="3D Model Transform",e.OriginFootprint="Origin Footprint",e))(oD||{}),qu=(e=>(e.DOCHEAD="DOCHEAD",e.EDIT_HEAD="EDIT_HEAD",e.SCH="SCH",e.SCH_PAGE="SCH_PAGE",e.PCB="PCB",e.PANEL="PANEL",e.PANEL_LIB="PANEL_LIB",e.SYMBOL="SYMBOL",e.FOOTPRINT="FOOTPRINT",e.DEVICE="DEVICE",e.BLOB="BLOB",e.INSTANCE="INSTANCE",e.CONFIG="CONFIG",e.BOARD="BOARD",e.FONT="FONT",e.VARIANT="VARIANT",e.COMPONENT_GROUP="COMPONENT_GROUP",e.COMPONENT_GROUP_DATA="COMPONENT_GROUP_DATA",e.SIMULATION="SIMULATION",e))(qu||{}),lD=(e=>(e.META="META",e.META_SORT="META_SORT",e.META_CREATE="META_CREATE",e.META_MODIFY="META_MODIFY",e.FONT="FONT",e.BLOB="BLOB",e.MAX_NUM="MAX_NUM",e.INSTANCE_ATTR="INSTANCE_ATTR",e.DELETE_DOC="DELETE_DOC",e.META_Z_INDEX="META_Z_INDEX",e.VARIANT_GROUPED="VARIANT_GROUPED",e.GROUP_INDEX="GROUP_INDEX",e.GROUP_DATA="GROUP_DATA",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.META_PLACEHOLDER="META_PLACEHOLDER",e))(lD||{});function Wu(e,t,i){return e.slice(t,i)}function Gp(e,t,i){let r=e.length,s=0;for(;s<r;){let n=e.indexOf(`|
`,s);if(n<0){if(i)return e.substring(s);n=r}let a=Wu(e,s,n);try{if(a){let o=a.indexOf("||"),l=o>-1,h=l?Wu(a,0,o):a,c=l?Wu(a,o+2):"";if(t(h,c,a,l?s+o+2:s)===!1){a=null;break}a=null}}catch(o){console.error(o)}s=n+2}e=null}var hD=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function e0(e,t){return hD.includes(t)?t:e}var cD=class{parseFull(e,t,i){let r=t,s=i,n,a=null;Gp(e,(o,l,h)=>{let c=JSON.parse(o);if(c.type==="EDIT_HEAD")a=JSON.parse(l),this.onEditHead&&this.onEditHead(a);else if(c.type==="DOCHEAD"){let d=JSON.parse(l);s=d.docType,r=d.uuid,n=d.client,d.ticket=c.ticket,this.onDocHead(d,a,h)}else this.onLine(c.id,c.ticket,l,c.type,c.client||n,s,r,c.firstTicket,c.pend,a,c.num,h)}),this.onEnd(),e=null}flowParseFull(e={}){let{cache:t,chunkLength:i=100*1024*1024,idsData:r,history:s}=e,n="",a=null,o,l=null,h=!0,c="",d=0,f=!1,u={},p=t?{}:void 0,g=new Set,_=O=>{p[O]===void 0&&(p[O]=-1),t(O,++p[O],u[O].data.join(`|
`)),u[O].data.length=0,u[O].size=0,u[O].data.push(u[O].head),u[O].size+=u[O].head.length},y=O=>{if(g.add(n),!t)return;let b=e0(n,a);u[b].data.push(O),u[b].size+=(u[b].size?2:0)+O.length,u[b].size+O.length>i&&_(b)},m=(O,b)=>Gp(O,(v,E,T,P)=>{var A,C,M,H,k,F,j,L;let R=JSON.parse(v);if(R.type==="EDIT_HEAD")l=JSON.parse(E),(A=this.onEditHead)==null||A.call(this,l),(C=e.onEditHead)==null||C.call(e,l),f=!0;else if(R.type==="DOCHEAD"){let x=JSON.parse(E);a=x.docType,n=x.uuid,o=x.client,x.ticket=R.ticket,f||(l={uuid:x.uuid,username:(M=x==null?void 0:x.user)==null?void 0:M.username,nickname:(H=x==null?void 0:x.user)==null?void 0:H.nickname,updateTime:x==null?void 0:x.updateTime},(k=e.onEditHead)==null||k.call(e,l),f=!0),this.onDocHead(x,l,T);let I=e0(n,a);t&&!u[I]&&(u[I]={size:0,data:[],head:""}),t&&(u[I].head=T),y(T)}else{let x=R.num,I=R.client||o;if(r){let S=(L=(j=(F=r.ids)==null?void 0:F[n])==null?void 0:j[I])==null?void 0:L[R.id];if(!S||S[0]!==R.ticket)return;x=S[1],r.size-=1,delete r.ids[n][I][R.id]}if(s){let S=e0(n,a);t&&(s.dNum=(p==null?void 0:p[S])===void 0?0:(p==null?void 0:p[S])+1),s.start=t?u[S].size+2+v.length+2:d+P}this.onLine(R.id,R.ticket,E,R.type,I,a,n,R.firstTicket,R.pend,l||(s==null?void 0:s.editHead),x,T,s),y(T)}},b);return{start:()=>{h=!0},end:()=>{if(c&&m(c,!1),t)for(let O in u)u[O].size&&u[O].data.length>1&&_(O),u[O]=null;h=!1,c="",n="",n=null,o="",l=null,this.onEnd()},update:O=>{if(!h)throw new Error("\u66F4\u65B0\u524D\u672A\u8C03\u7528 start \u65B9\u6CD5");let b=m(c+O,!0);d=d+c.length+O.length-((b==null?void 0:b.length)||0),c="",b&&(c=b)},docMap:p,getDocIds:()=>Array.from(g)}}parseLine(e,t,i){let r=e.indexOf("||"),s=r!==-1,n=s?Wu(e,0,r):e,a=s?Wu(e,r+2):"",o=JSON.parse(n);this.onLine(o.id,o.ticket,a,o.type,o.client,i,t,o.firstTicket,o.pend,void 0,o.num,e),e=null}onEditHead(e){}},t0=new Uint8Array(8);function pn(){crypto.getRandomValues(t0);let e="";for(let t=0;t<t0.length;t++)e+=t0[t].toString(16).padStart(2,"0");return e}function Dl(e,t,i,r,s,n,a){let o={docType:e,client:t,uuid:i};return(r||r===0)&&(o.updateTime=r),(s||o.updateTime||o.updateTime===0)&&(o.version=s||String(r)),n&&(o.user=n),`${JSON.stringify({type:"DOCHEAD",ticket:a})}||${JSON.stringify(o)}`}function Bs(e,t,i,r,s,n,a,o){let l={type:e,ticket:t,id:i};return n!==void 0&&(l.firstTicket=n),a!==void 0&&(l.pend=a),o!==void 0&&(l.num=o),s&&(l.client=s),`${JSON.stringify(l)}||${r}`}var Rv=class extends cD{constructor(e){super(),this.unique=pn(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||pn()}onLine(e,t,i,r,s,n,a,o,l,h,c){this.remoteChange(t,s,a,e,i,r,n,void 0,o,l,h,void 0,void 0,c)}getUnique(){return this.unique}setUnique(e){this.unique=e}setDocMaxTicket(e,t,i){i||(!this.docMaxTicket[e]||this.docMaxTicket[e]<t)&&(this.docMaxTicket[e]=t)}getDocMaxTicket(e){var t;return(t=this.docMaxTicket[e])!=null?t:0}onDocHead(e,t){}onEnd(){}setIsPendChange(e){this.isPendChange=e}getIsPendChange(){return this.isPendChange}getMaxTicket(){return this.maxTicket}setMaxTicket(e,t){e&&(t||this.maxTicket<e)&&(this.maxTicket=e)}setIsLocalChange(e){this.isLocalChange=e}getIsLocalChange(){return this.isLocalChange}revoke(e,t,i,r,s,n,a,o,l,h,c){var d;if(!((d=this.tempLocalIds[e])!=null&&d[t]))return c?c(t,s,i,a,`${r}-1`,e,n,void 0,void 0,!0,h):this.cbArr.forEach(f=>f(e,t,i,a,`${r}-1`,s,void 0,n,void 0,void 0,void 0,h)),!0}getRandomUuid(){return pn()}getClient(){return this.client}onChange(e){this.cbArr.push(e)}localChange(e,t,i,r,s,n){let a=this.maxTicket+1;return this.tempLocalIds[e]||(this.tempLocalIds[e]={}),this.tempLocalIds[e][t]=[this.getClient(),a],this.remoteChange(a,this.client,e,t,i,r,s,!0,void 0,!0,void 0,this.unique,void 0,n),a}remoteChange(e,t,i,r,s,n,a,o,l,h,c,d,f,u){var p;this.setMaxTicket(e);let g=d===this.unique,_=o||g,y=(!_||_&&this.isLocalChange)&&(!f||f&&this.isPendChange),m=(p=this.tempLocalIds[i])==null?void 0:p[r];!o&&g?m?(y=!1,m[0]===t&&m[1]===e&&delete this.tempLocalIds[i][r]):y=!0:!o&&m&&(m[1]>e||m[1]===e&&m[0]>t?y=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,h),y&&this.cbArr.forEach(O=>O(i,r,s,n,t,e,l,h,void 0,f,d,u))}},uD=class{constructor(e){this.item=e,this.parent=null,this.left=null,this.right=null,this.height=1}getParent(){return this.parent}getLeft(){return this.left}getRight(){return this.right}getHeight(){return this.height}setLeft(e){if(this.left!==null)throw new Error("insert exists left is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert left with node has parent is not permitted");this.left=e,e.parent=this,this.updateHeight()}}setRight(e){if(this.right!==null)throw new Error("insert exists right is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert right with node has parent is not permitted");this.right=e,e.parent=this,this.updateHeight()}}removeLeft(){if(this.left===null)return null;{let e=this.left;return e.parent=null,this.left=null,this.updateHeight(),e}}removeRight(){if(this.right===null)return null;{let e=this.right;return e.parent=null,this.right=null,this.updateHeight(),e}}rotateRight(e){let t=this.removeLeft();if(this.setLeft(t.removeRight()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setRight(this)}else t.setRight(this),e(t)}rotateLeft(e){let t=this.removeRight();if(this.setRight(t.removeLeft()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setLeft(this)}else t.setLeft(this),e(t)}updateHeight(){var e,t;let i=this;for(;i!==null;)i.height=Math.max(((e=i.left)==null?void 0:e.height)||0,((t=i.right)==null?void 0:t.height)||0)+1,i=i.parent}},dD=class{constructor(e){this.comparator=e,this.root=null,this.minNode=null,this.maxNode=null,this.size=0}balance(e){var t,i;let r=((t=e.getLeft())==null?void 0:t.getHeight())||0,s=((i=e.getRight())==null?void 0:i.getHeight())||0,n=e.getParent();r>s?r-s>1?(e.rotateRight(a=>this.root=a),this.verify()):n!==null?n.getRight()===e&&(e.rotateRight(a=>this.root=a),this.verify()):(e.rotateRight(a=>this.root=a),this.verify()):s>r&&(s-r>1?(e.rotateLeft(a=>this.root=a),this.verify()):n!==null?n.getLeft()===e&&(e.rotateLeft(a=>this.root=a),this.verify()):(e.rotateLeft(a=>this.root=a),this.verify())),n&&this.balance(n)}forwardTraverse(e){let t=new Array(10),i=this.minNode;for(;i;)switch(t.pop()||2){case 1:i.getLeft()!==null?(t.push(2),t.push(1),i=i.getLeft()):t.push(2);break;case 2:if(!e(i.item))return;i.getRight()!==null?(t.push(3),t.push(1),i=i.getRight()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}backwardTraverse(e){let t=new Array(10),i=this.maxNode;for(;i;)switch(t.pop()||2){case 1:i.getRight()!==null?(t.push(2),t.push(1),i=i.getRight()):t.push(2);break;case 2:if(!e(i.item))return;i.getLeft()!==null?(t.push(3),t.push(1),i=i.getLeft()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}display(e=this.root,t=new Array,i=0){let r="| ".repeat(i);return t.push(r+`\u25CF(${e.item})
`),e.getLeft()?this.display(e.getLeft(),t,i+1):t.push(r+`| \u2609
`),e.getRight()?this.display(e.getRight(),t,i+1):t.push(r+`| \u2609
`),t}getHeight(){var e;return((e=this.root)==null?void 0:e.getHeight())||0}getSize(){return this.size}updateMinMax(e){this.minNode?this.comparator(e.item,this.minNode.item)<0&&(this.minNode=e):this.minNode=e,this.maxNode?this.comparator(e.item,this.maxNode.item)>0&&(this.maxNode=e):this.maxNode=e}insert(e){let t=new uD(e);if(this.root===null)return this.root=t,this.size++,this.updateMinMax(t),!0;{let i=this.root;for(;;){let r=this.comparator(e,i.item);if(r<0){if(i.getLeft()===null)return i.setLeft(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getLeft()}else if(r>0){if(i.getRight()===null)return i.setRight(t),this.size++,this.updateMinMax(t),this.verify(),this.balance(i),!0;i=i.getRight()}else return!1}}}verify(){}remove(e){let t=this.root;for(this.verify();;){if(t===null)return!1;let i=this.comparator(e,t.item);if(i<0)t=t.getLeft();else if(i>0)t=t.getRight();else return this.minNode===t&&(t.getRight()?this.minNode=this.findMinChild(t.getRight()):this.minNode=t.getParent()),this.maxNode===t&&(t.getLeft()?this.maxNode=this.findMaxChild(t.getLeft()):this.maxNode=t.getParent()),this.removeNode(t),this.size--,this.verify(),!0}}removeNode(e){var t,i;let r=e.getParent();if(r===null)e.getLeft()===null&&e.getRight()===null?(this.root=null,this.minNode=null,this.maxNode=null):((((t=e.getLeft())==null?void 0:t.getHeight())||0)>(((i=e.getRight())==null?void 0:i.getHeight())||0)?(e.rotateRight(s=>this.root=s),this.verify()):(e.rotateLeft(s=>this.root=s),this.verify()),this.removeNode(e));else if(r.getLeft()===e){r.removeLeft();let s=this.combineNodes(e.removeLeft(),e.removeRight());r.setLeft(s),this.verify(),this.balance(r)}else{r.removeRight();let s=this.combineNodes(e.removeLeft(),e.removeRight());r.setRight(s),this.verify(),this.balance(r)}}combineNodes(e,t){if(e&&t)if(e.getHeight()>t.getHeight()){let i=this.findMaxChild(e);if(i){let r=i.getParent();return r.removeRight(),r.setRight(i.removeLeft()),i.setLeft(e),i.setRight(t),i}else return e.setRight(t),e}else{let i=this.findMinChild(t);if(i){let r=i.getParent();return r.removeLeft(),r.setLeft(i.removeRight()),i.setLeft(e),i.setRight(t),i}else return t.setLeft(e),t}else return e||t||null}findMinChild(e){let t=e;for(;;){if(t.getLeft()===null)return t!==e?t:null;t=t.getLeft()}}findMaxChild(e){let t=e;for(;;){if(t.getRight()===null)return t!==e?t:null;t=t.getRight()}}};var dm=/^[a-zA-Z]+(\d+)$/;function Ku(e){let t=e.match(dm);return t?Number(t[1]):null}function Ut(e){if(!e||typeof e!="string")return e;let t=e.match(/[a-zA-Z]+\d+/g);return t&&t.length===2&&t.join("")===e?t.join("-"):e}function Gr(e){return e&&typeof e=="number"&&!isNaN(e)?-e:e}function fD(e,t){let i=[];for(let r=0;r<e.length;r+=2){let s={x:e[r],y:t?Gr(e[r+1]):e[r+1]};i.push(s)}return i}function Ms(e,t){return JSON.stringify([t,e])}function Lo(e){try{let t=JSON.parse(e);return typeof t=="string"?e:t[1]}catch{return e}}function i0(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var pD=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.POLY="POLY",e.STRING="STRING",e.AUX_LINE="AUXLINE",e.DIMENSION="DIMENSION",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(pD||{}),gD=(e=>(e.META="META",e.CANVAS="CANVAS",e.LAYER="LAYER",e.LAYER_PHYS="LAYER_PHYS",e.ACTIVE_LAYER="ACTIVE_LAYER",e.PARTITION="PARTITION",e.NET="NET",e.PRIMITIVE="PRIMITIVE",e.GROUP="GROUP",e.SILK_OPTS="SILK_OPTS",e.PREFERENCE="PREFERENCE",e.VIA="VIA",e.PAD="PAD",e.LINE="LINE",e.ARC="ARC",e.OBJ="OBJ",e.EQLEN_GRP="EQLEN_GRP",e.POLY="POLY",e.FILL="FILL",e.LAYER_FILL="LAYER_FILL",e.REGION="REGION",e.POUR="POUR",e.POURED="POURED",e.IMAGE="IMAGE",e.TEARDROP="TEARDROP",e.FPC_FILL="FPC_FILL",e.SHELL="SHELL",e.CREASE="CREASE",e.SHELLCUT="SHELLCUT",e.SHELL_ENTITY="SHELL_ENTITY",e.BOSS="BOSS",e.STRING="STRING",e.ATTR="ATTR",e.DIMENSION="DIMENSION",e.COMPONENT="COMPONENT",e.PAD_NET="PAD_NET",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.PANELIZE="PANELIZE",e.BOARD="BOARD",e.X_SIGNALS_GROUP="X_SIGNAL_GROUP",e.X_SIGNALS="X_SIGNALS",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(gD||{}),_D=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.ATTR="ATTR",e.LINE="LINE",e.WIRE="WIRE",e.BUS="BUS",e.TEXT="TEXT",e.POLY="POLY",e.CIRCLE="CIRCLE",e.ARC="ARC",e.BUSENTRY="BUSENTRY",e.RECT="RECT",e.MASK_REGION="MASK_REGION",e.PIN="PIN",e.OBJ="OBJ",e.COMPONENT="COMPONENT",e.PART="PART",e.ELLIPSE="ELLIPSE",e.BEZIER="BEZIER",e.TABLE="TABLE",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.NG_SETTING="NG_SETTING",e))(_D||{}),OD=["PARTITION","VIA","PAD","LINE","ARC","OBJ","POLY","FILL","REGION","POUR","POURED","IMAGE","TEARDROP","FPC_FILL","SHELL","CREASE","SHELLCUT","SHELL_ENTITY","BOSS","STRING","ATTR","DIMENSION","COMPONENT"],hZ=ic(ld()),mD=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))(mD||{}),bD=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(bD||{}),yD=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(yD||{}),vD=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(vD||{}),xD=(e=>(e.LEFT_BOTTOM="LEFT_BOTTOM",e.CENTER_BOTTOM="CENTER_BOTTOM",e.RIGHT_BOTTOM="RIGHT_BOTTOM",e.LEFT_MIDDLE="LEFT_MIDDLE",e.CENTER_MIDDLE="CENTER_MIDDLE",e.RIGHT_MIDDLE="RIGHT_MIDDLE",e.LEFT_TOP="LEFT_TOP",e.CENTER_TOP="CENTER_TOP",e.RIGHT_TOP="RIGHT_TOP",e))(xD||{}),ED=(e=>(e.NONE="NONE",e.SOLID="SOLID",e.GRID="GRID",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e.RHOMBIC="RHOMBIC",e.LEFT_SLASH_LINE="LEFT_SLASH_LINE",e.RIGHT_SLASH_LINE="RIGHT_SLASH_LINE",e))(ED||{}),wD=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(wD||{}),TD=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(TD||{}),SD=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(SD||{}),ID=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(ID||{}),PD=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(PD||{}),AD=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(AD||{}),CD=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(CD||{}),LD=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(LD||{}),DD=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(DD||{}),RD=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(RD||{}),ND=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(ND||{}),MD=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(MD||{}),BD=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(BD||{}),kD=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(kD||{}),FD=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(FD||{}),UD=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(UD||{}),GD=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(GD||{}),zD=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(zD||{}),HD=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(HD||{}),jD=(e=>(e.PI="Polyimide",e.FR4="FR4",e.STEEL_SHEET="Stainless Steel",e.M3_DOUBLE_SIDED_TAPE="3M Tape",e.EMI_SHIELDING_FILM="EMI Shielding Film",e))(jD||{}),VD=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(VD||{}),YD=(e=>(e.X_AXIS_POSITIVE="X_AXIS_POSITIVE",e.X_AXIS_NEGATIVE="X_AXIS_NEGATIVE",e.Y_AXIS_POSITIVE="Y_AXIS_POSITIVE",e.Y_AXIS_NEGATIVE="Y_AXIS_NEGATIVE",e))(YD||{}),qD=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(qD||{}),WD=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(WD||{}),XD=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(XD||{}),JD=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(JD||{}),ZD=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))(ZD||{}),KD=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(KD||{}),$D=(e=>(e.SAFE="SAFE",e.OTHER="OTHER",e.TRACK="TRACK",e.BLIND="BLIND",e.RADIUS="RADIUS",e.PLANE="PLANE",e.COPPER="COPPER",e.PASTE="PASTE",e.SOLDER="SOLDER",e.DIFFER_ENTAIL="DIFFER_ENTAIL",e.NET_LENGTH="NET_LENGTH",e.AUTO_ROUTER="AUTO_ROUTER",e.NET_LENGTH_TOLERANCE="NET_LENGTH_TOLERANCE",e))($D||{}),QD=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(QD||{}),eR=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(eR||{}),tR=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(tR||{}),iR=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(iR||{}),rR=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(rR||{}),sR=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))(sR||{}),nR=(e=>(e.DesignRule="DesignRule",e.Board="Board",e.SlotRegion="SlotRegion",e.ProhibitedRegion="ProhibitedRegion",e.ConstraintRegion="ConstraintRegion",e.Component="Component",e.Track="Track",e.TestPoint="TestPoint",e.Pad="Pad",e.Via="Via",e.SutureHole="SutureHole",e.Text="Text",e.ColorfulImage="ColorfulImage",e.Image="Image",e.FPCStiffener="FPCStiffener",e.Dimension="Dimension",e.CopperRegion="CopperRegion",e.FillRegion="Fill Region",e.Line="Line",e.Teardrop="Teardrop",e.D3Shell="D3Shell",e))(nR||{}),aR=ic(aD());function M0(e,t,i,r,s,n,a,o){return JSON.stringify([e||"",t||"",i,r,s?1:0,n?1:0,a?1:0,o])}function oR(e){let t=JSON.parse(e);return{text:t[0],fontFamily:t[1],fontSize:t[2],thickness:t[3],bold:!!t[4],italic:!!t[5],reverse:!!t[6],expansion:t[7]}}function lg(e){return aR.default.SHA256(e).toString()}function lR(e,t){let i=[],r=[],s={};Gp(e,(h,c)=>{let d=JSON.parse(h);if(d.type==="DOCHEAD"||d.type==="META"||d.type==="META_CREATE"||d.type==="META_MODIFY"||d.type==="ELE_PLACEHOLDER"||d.type==="ELE_PLACEHOLDER"||d.type==="ELE_PLACEHOLDER")return;let{id:f}=d;s[f]=Object.assign(d,{data:c})});let n={};Gp(t,(h,c="")=>{let d=JSON.parse(h);if(d.type==="BLOB")i.push(h+"||"+c);else if(d.type==="FONT")r.push(h+"||"+c);else{if(d.type==="DOCHEAD"||d.type==="META_MODIFY")return;let{id:f}=d;n[f]=Object.assign(d,{data:c})}});let a={},o={},l={};for(let h in s)if(!n.hasOwnProperty(h))o[h]=s[h];else{let{ticket:c}=s[h],{type:d,data:f,client:u}=n[h];a[h]={type:d,ticket:c,data:f,client:u},delete n[h]}for(let h in n){let{type:c,data:d,ticket:f,client:u}=n[h];l[h]={type:c,data:d,ticket:f,client:u}}return{delete:o,cover:a,add:l,blobs:i,fonts:r}}function r0(e,t,i){let{docType:r,uuid:s,client:n,updateTime:a,version:o,user:l,ticket:h}=i,c=[Dl(r,n,s,a,o,l,h)],{delete:d,cover:f,add:u,blobs:p,fonts:g}=lR(e,t);for(let _ in d){let{ticket:y,type:m,client:O}=d[_];c.push(Bs(m,y+1,_,"",O))}for(let _ in f){let{type:y,ticket:m,data:O,client:b}=f[_];c.push(Bs(y,m+1,_,O,b))}for(let _ in u){let{type:y,ticket:m,data:O,client:b}=u[_];c.push(Bs(y,m,_,O,b))}return p.length&&(c.push(Dl("BLOB",n,"BLOB",a,o,l,h)),c=c.concat(p)),g.length&&(c.push(Dl("FONT",n,"FONT",a,o,l,h)),c=c.concat(g)),c.join(`|
`)}function hR(e,t){return e.ticket===t.ticket?e.client===t.client?e.id===t.id?0:e.id<t.id?-1:1:e.client<t.client?-1:1:e.ticket<t.ticket?-1:1}var cR=class{constructor(e=1){this.startNum=e,this.orderLists={},this.idOrderLists={},this.cbArr=new Array,this.maxNum={}}orderChange(e){this.cbArr.push(e)}setOrderNum(e,t,i,r,s=1){if(s<1)throw new Error("step must be greater than 0");let n=i0(this.orderLists,t,()=>new dD(hR)),a=i0(this.maxNum,t,()=>this.startNum-1),o=i0(this.idOrderLists,t,()=>new Map),l=o.get(e);if(l){if(l.ticket<=i)return;n.remove(l),a-=l.step}let h={id:e,ticket:i,num:0,client:r,step:s};o.set(e,h),n.insert(h),a+=s;let c=a,d=0;n.backwardTraverse(f=>(d++,f.num=c,this.cbArr.forEach(u=>u(f.id,t,f.num)),c-=f.step,f!==h)),this.maxNum[t]=a,d>1e4&&(console.log("------------------ notify --------",h,"height: ",n.getHeight(),"total: ",n.getSize(),"notifies: ",d),console.log("------------------ all --------"))}getOrderNum(e,t){var i,r,s,n;return(n=(s=(r=(i=this.idOrderLists)==null?void 0:i[t])==null?void 0:r.get)==null?void 0:s.call(r,e))==null?void 0:n.num}getMaxNum(e){var t;return((t=this.orderLists[e])==null?void 0:t.getSize())||0}clearNum(){for(let e in this.idOrderLists)this.idOrderLists[e].clear(),delete this.idOrderLists[e];for(let e in this.orderLists)delete this.orderLists[e]}},uR=class{constructor(e,t=1,i=[]){this.consistencyManager=e,this.startNum=t,this.needOrderType=i,this.initIng=!1,this.allOrderNum={},this.maxNum={},this.consistencyManager.onChange((r,s,n,a,o,l,h,c,d,f,u,p)=>{try{if(this.calculation)if(a==="ELE_PLACEHOLDER"){let g=n?JSON.parse(n):null;g&&this.calculation.setOrderNum(s,g.dataType,h!=null?h:l,o,g.max)}else this.calculation.setOrderNum(s,a,h!=null?h:l,o);this.onParseLine(s,a,n?JSON.parse(n):null,o,l,c,p)}catch(g){console.error(g)}})}initCalculation(){this.calculation=new cR(this.startNum)}setIsInit(e){this.initIng=e}setNeedNum(e){this.needNum=e}setOrderNum(e,t,i){this.needNum&&this.needOrderType&&this.needOrderType.includes(i)&&t!==void 0&&(this.allOrderNum[e]=t,this.setMaxNum(i,t))}deleteOrderNum(e){delete this.allOrderNum[e]}getOrderNum(e){return this.allOrderNum[e]}setMaxNum(e,t,i){(i||this.maxNum[e]===void 0||this.maxNum[e]<t)&&(this.maxNum[e]=t)}getMaxNum(e){return this.maxNum[e]===void 0&&(this.maxNum[e]=this.startNum-1),++this.maxNum[e]}};function Nv(e){switch(e=String(e),e){case"1":return"SAFE";case"2":return"OTHER";case"3":return"TRACK";case"4":return"BLIND";case"5":return"RADIUS";case"6":return"PLANE";case"7":return"COPPER";case"8":return"PASTE";case"9":return"SOLDER";case"10":return"DIFFER_ENTAIL";case"11":return"NET_LENGTH";case"12":return"AUTO_ROUTER";case"13":return"NET_LENGTH_TOLERANCE"}return e}function kh(e){if(!e)return{};let t=["1","2","3","4","5","6","7","8","9","10","11","12","13"];for(let i of t)if(e.hasOwnProperty(i)){let r=e[i];delete e[i],e[Nv(i)]=r}return e}var y2=class{constructor(){this.init=!1,this.defaultSafeData=null,this.defaultCopperSpace=null,this.defaultInnerSpace=null,this.copperChangeMap=new Map,this.innerChangeMap=new Map}addDefaultSafeSpaceData(e){this.init=!0,this.defaultSafeData=e}addDefaultCopperSpace(e,t){this.defaultCopperSpace={netClearance:e,boardClearance:t}}addDefaultInnerSpace(e,t){this.defaultInnerSpace={netClearance:e,boardClearance:t}}getNewDefaultData(e,t){if(e&&this.defaultSafeData==null||!e&&this.defaultInnerSpace==null)return null;let i=e?this.copperChangeMap.get(t):this.innerChangeMap.get(t);if(i==null)return null;let{netClearance:r,boardClearance:s}=i,n=this.defaultSafeData.safeSpacing[0].content,a=new Array(n.length);for(let o=0;o<n.length;o++)a[o]=Array.from(n[o]);return this.updateSafeData(a,r,s),a}fixSafeData(e){if(this.defaultCopperSpace!=null)for(let t of e.safeSpacing)this.updateSafeData(t.content,this.defaultCopperSpace.netClearance,this.defaultCopperSpace.netClearance)}updateSafeData(e,t,i){for(let r=0;r<e.length;r++){let s=e[r];for(let n=0;n<s.length;n++)r==7?n==11||n==8?s[n]=i:s[n]=t:n==7&&(r==11||r==8?s[n]=i:s[n]=t)}}addCopper2SafeChangeMap(e,t,i,r,s){this.copperChangeMap.set(e,{name:t,isDefault:i,netClearance:r,boardClearance:s})}addInner2SafeChangeMap(e,t,i,r,s){this.innerChangeMap.set(e,{name:t,isDefault:i,netClearance:r,boardClearance:s})}getSafeName4Copper(e){var t;return(t=this.copperChangeMap.get(e))==null?void 0:t.name}getSafeName4Plane(e){var t;return(t=this.innerChangeMap.get(e))==null?void 0:t.name}getDefaultCopper(){for(let[,e]of this.copperChangeMap)if(e.isDefault)return e.name;return null}getDefaultPlane(){for(let[,e]of this.innerChangeMap)if(e.isDefault)return e.name;return null}};function v2(e,t){let i=e,r={TWO_LAYERS_BOARD:"JLCPCB Capability(Two Layers Board)",SINGLE_LAYER_BOARD:"JLCPCB Capability(Single Layer Board)",MULTIPLE_LAYERS_BOARD:"JLCPCB Capability(Multiple Layers Board)",HIGH_FREQUENCY_BOARD:"JLCPCB Capability(High Frequency Board)",ALUMINUM_SUBSTRATE_BOARD:"JLCPCB Capability(Aluminum Substrate Board)",COPPER_SUBSTRATE_BOARD:"JLCPCB Capability(Copper Substrate Board)"};if(i.length==8){Object.values(r).includes(t)&&(i[4][0]=11.811,i[5][4]=11.811),i.splice(1,0,i[1].slice(0));for(let n=2;n<i.length;n++)i[n].splice(1,0,i[n][1]);i.push([].concat(i[1][0],i.slice(1).map(n=>n[1])))}i[1].push(i[1][i[1].length-1]),i.splice(3,0,[...i[1]]),i.splice(4,0,[...i[2]]),i[1].pop();for(let n=5;n<i.length;n++)i[n].splice(3,0,i[n][1]),i[n].splice(4,0,i[n][2]);i[3][3]=i[1][1],i[4][3]=i[2][1],i[4][4]=i[2][2];let s=6;i.splice(7,0,new Array(7).fill(s));for(let n=7;n<i.length;n++)i[n].splice(7,0,s);return i}function dR(e,t){let i=e[0],r=e[1],s=[],n="ALL";if(r instanceof Array){let a=v2(r,t);s.push({layerId:1,isOpen:!0,content:a})}else{for(let a in r){let o=r[a],l=v2(o,t);s.push({layerId:+a,isOpen:!0,content:l})}Object.keys(r).length>1&&(n="LAYERED")}return{unit:i,isForAll:n,safeSpacing:s}}function fR(e){let t=e[0],i=e[1],r=e[2];isNaN(r)&&(r=0);let s=e[3];return isNaN(s)&&(s=11.8),{unit:t,deviceClearance:i,thru2SmdClearance:r,holeClearance:s}}function pR(e){let t=e[0],i=e[1],r=!0,s=[];if(i instanceof Object)for(let n in i){let a=i[n];s.push({layerId:+n,stroMin:a[0],stroDef:a[1],stroMax:a[2]})}else s.push({layerId:1,stroMin:e[1],stroDef:e[2],stroMax:e[3]});return{unit:t,track:{isOpen:r,content:s}}}function gR(e){return{unit:e[0],netLenMin:e[1],netLenMax:e[2]}}function _R(e){return{unit:e[0],netLengthTolerance:e[1]}}function OR(e){let t=e[0],i=e[1],r=!0,s=[],n=[],a=0;if(i instanceof Object)for(let o in i){let l=i[o],{stroke:h,spacing:c,lenTolerMax:d}=l;s.push({layerId:+o,stroMin:h[0],stroDef:h[1],stroMax:h[2]}),n.push({layerId:+o,spacMin:c[0],spacDef:c[1]}),a=d}else s.push({layerId:1,stroMin:e[1],stroDef:e[2],stroMax:e[3]}),n.push({layerId:1,spacMin:e[4],spacDef:e[5]}),a=e[7];return{unit:t,stroWidth:{isOpen:r,content:s},spacing:{isOpen:r,content:n},differPairLenTolerMax:a}}function mR(e){let t=new Array;for(let i of e){let r=+i[1],s=+i[2];isNaN(r)||r<=0||isNaN(s)||s<=0||r===s||r===1&&s===2||r===2&&s===1||t.push({name:i[0],staLayerId:r,endLayerId:s,viaSizeRule:i[3]})}return{blinds:{content:t}}}function bR(e){return{unit:e[0],minRadius:e[1],defRadius:e[2],maxRadius:e[3],minInner:e[4],defInner:e[5],maxInner:e[6]}}function yR(e){let t=[{layerId:1,connType:Jh(e[7]!==void 0?e[7]:e[3]),spoWidth:e[8]!==void 0?e[8]:e[4],spoSpac:e[9]!==void 0?e[9]:e[5],spoAng:e[10]?e[10]:e[6]}];return{unit:e[0],mulPad:{isOpen:!0,content:t}}}function vR(e){let t=[{layerId:1,connType:Jh(e[3]),spoWidth:e[4],spoSpac:e[5],spoAng:e[6]}],i=[{layerId:1,connType:Number(e[7])?"NON_CONNECT":"DIRECT"}],r=[{layerId:1,connType:Jh(e[8]!==void 0?e[8]:e[3]),spoWidth:e[9]!==void 0?e[9]:e[4],spoSpac:e[10]!==void 0?e[10]:e[5],spoAng:e[11]?e[11]:e[6]}];return{unit:e[0],sglPad:{isOpen:!0,content:t},mulPad:{isOpen:!0,content:r},track:{isOpen:!0,content:i}}}function xR(e){return{unit:e[0],padTopExpan:e[1],padBotExpan:e[2],testPointTopExpan:e[3]?e[3]:-1e3,testPointBotExpan:e[4]?e[4]:-1e3}}function ER(e){return{unit:e[0],padTopExpan:e[1],padBotExpan:e[2],viaTopExpan:e[3],viaBotExpan:e[4],testPointTopExpan:e[5]?e[5]:2,testPointBotExpan:e[6]?e[6]:2}}function wR(e){function t(s){switch(s=s&&Number(s),s){case 0:return"L45";case 1:return"L90";case 2:return"A90";default:return"L45"}}function i(s){switch(s=s&&Number(s),s){case 0:return"LESS";case 1:return"MID";case 2:return"MORE";default:return"LESS"}}function r(s){switch(s=s&&Number(s),s){case 0:return"SPEED_FIRST";case 1:return"COMPLETION_FIRST";default:return"COMPLETION_FIRST"}}return{routingCorner:t(e[0]),isKeep:!!e[1],viaQuantity:i(e[2]),routingEffectPriority:r(e[3]),layers:e[5],ignoreNets:e[6]}}function Jh(e){switch(e=e&&Number(e),e){case 0:return"DIVERGENCE";case 1:return"DIRECT";case 2:return"NON_CONNECT";default:return null}}function TR(e,t){let i=t;switch(e){case"SAFE":{let r=t;if(r.isForAll=r.isForAll?"LAYERED":"ALL",r.safeSpacing)for(let s of r.safeSpacing)s.isOpen=!!s.isOpen;i=r;break}case"OTHER":break;case"TRACK":{let r=t;r!=null&&r.track&&(r.track.isOpen=!!r.track.isOpen),i=r;break}case"NET_LENGTH":break;case"NET_LENGTH_TOLERANCE":break;case"DIFFER_ENTAIL":{let r=t;r!=null&&r.stroWidth&&(r.stroWidth.isOpen=!!r.stroWidth.isOpen),r!=null&&r.spacing&&(r.spacing.isOpen=!!r.spacing.isOpen),i=r;break}case"BLIND":break;case"RADIUS":break;case"PLANE":{let r=t;if(r!=null&&r.mulPad&&(r.mulPad.isOpen=!!r.mulPad.isOpen),r.mulPad&&r.mulPad.content)for(let s of r.mulPad.content)s.connType=Jh(s.connType);i=r;break}case"COPPER":{let r=t;if(r!=null&&r.sglPad&&(r.sglPad.isOpen=!!r.sglPad.isOpen),r!=null&&r.mulPad&&(r.mulPad.isOpen=!!r.mulPad.isOpen),r!=null&&r.track&&(r.track.isOpen=!!r.track.isOpen),r.track&&r.track.content&&(r.track.content=r.track.content.map(s=>(s.connType=Number(s.connType)?"NON_CONNECT":"DIRECT",s))),r.sglPad&&r.sglPad.content)for(let s of r.sglPad.content)s.connType=Jh(s.connType);if(r.mulPad&&r.mulPad.content)for(let s of r.mulPad.content)s.connType=Jh(s.connType);i=r;break}case"PASTE":break;case"SOLDER":break;case"AUTO_ROUTER":break}return i}function SR(e,t,i,r,s,n){if(!(r instanceof Array))return TR(e,r);let a,o=!1;switch(i&&(i==="NORMAL"?o=!1:i==="DEFAULT"&&(o=!0)),e){case"SAFE":{a=dR(r,n),o&&s.addDefaultSafeSpaceData(a);break}case"OTHER":{a=fR(r);break}case"TRACK":{a=pR(r);break}case"NET_LENGTH":{a=gR(r);break}case"NET_LENGTH_TOLERANCE":{a=_R(r);break}case"DIFFER_ENTAIL":{a=OR(r);break}case"BLIND":{a=mR(r);break}case"RADIUS":{a=bR(r);break}case"PLANE":{let l=r[1],h=r[2];o&&s.addDefaultInnerSpace(l,h),s.addInner2SafeChangeMap(t,"Plane_"+t,o,l,h),a=yR(r);break}case"COPPER":{let l=r[1],h=r[2];o&&s.addDefaultCopperSpace(l,h),s.addCopper2SafeChangeMap(t,"Copper_"+t,o,l,h),a=vR(r);break}case"PASTE":{a=xR(r);break}case"SOLDER":{a=ER(r);break}case"AUTO_ROUTER":{a=wR(r);break}}return a}function IR(e,t,i,r){if(!r.init)return null;function s(n,a){let o=n?"Copper_":"Plane_",l=["RULE"];l[1]="SAFE",l[2]=o+t,l[3]=0;let h=a.getNewDefaultData(n,t);return h==null?null:(l[4]={unit:a.defaultSafeData.unit,isForAll:"ALL",safeSpacing:[{layerId:1,isOpen:!0,content:h}]},l)}switch(e){case"SAFE":return r.fixSafeData(i),null;case"PLANE":return s(!1,r);case"COPPER":return s(!0,r);default:return null}}function PR(e,t,i,r){if(!r.init)return{ruleKeyValue:i};let s=e[0],n,a;if(t==4){if(s==="NET_CLASS"||s==="NET"){for(let o in i)String(o)==="COPPER"&&(n={COPPER:r.getSafeName4Copper(i[o])}),String(o)==="PLANE"&&(a={PLANE:r.getSafeName4Plane(i[o])});e[1]==""?(n!=null&&n.COPPER||(n={COPPER:"default"}),a!=null&&a.PLANE||(a={PLANE:"default"})):(n!=null&&n.COPPER||(n={COPPER:r.getDefaultCopper()}),a!=null&&a.PLANE||(a={PLANE:r.getDefaultPlane()}))}}else for(let o in i){if(String(o)==="COPPER"){let l=i[o],h=r.getSafeName4Copper(l);if(h==null&&l=="default"&&(h=r.getDefaultCopper()),h==null)continue;n={COPPER:h}}if(String(o)==="PLANE"){let l=i[o],h=r.getSafeName4Plane(l);if(h==null&&l=="default"&&(h=r.getDefaultPlane()),h==null)continue;a={PLANE:h}}}return{ruleKeyValue:i,copperRuleValue:n,innerPlaneRuleValue:a}}function Mv(e,t){let i=e.length,r=0;for(;r<i;){let s=e.indexOf(`
`,r);s<0&&(s=i);let n=e.substring(r,s);try{if(t(n)===!1)break}catch(a){console.error(a)}r=s+1}}function AR(e){let t={};return Mv(e,i=>{if(i.startsWith('["PAD"')){let r=JSON.parse(i);t[r[5]]||(t[r[5]]=[]),t[r[5]].push(r[1])}}),t}var fm=class{parseFull(e){Mv(e,t=>this.onParseLine(JSON.parse(t))),this.onParseEnd()}},CR=class extends fm{constructor(e={},t={},i=[],r=[],s=!1){super(),this.deviceName=e,this.footprintName=t,this.footprints=i,this.devices=r,this.footprintIsConnectDevice=s,this.fontCache=[],this.poured={},this.curPartition="",this.eQLenData={},this.eQLenSort=1,this.cache={},this.components={},this.errorIds={},this.dimension={},this.connects={},this.specialColors={},this.reuseBlock={},this.panelize={data:[],stamp:{h:null,v:null},size:{h:null,v:null}},this.layerPhys=0,this.fac=new y2,this.rules=[],this.ruleSelectors=[],this.ruleTemplateName="",this.layerFill={},this.idsSet=new Set,this.oldId={},this.cachePadNet={},this.creaseIds=[],this.stringId={},this.substrateLayer=new Set,this.layerPhysCache=[],this.randomUuid=0,this.padNumId={},this.componentPadNum={}}getOldId(e){var t;return(t=this.oldId[e])!=null?t:e}handConnect(){for(let e of this.creaseIds)if(this.connects[e])for(let t of this.connects[e])this.connects[t]?this.connects[t].push(e):this.connects[t]=[e]}getConnect(e){return this.connects[e]||[]}transRuleType(e){return Nv(e)}transRuleStatus(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"DEFAULT";default:return"NORMAL"}}transGridType(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"GRID";case 2:return"OUTLETS";default:return"NONE"}}transLayerStatus(e){e=e&&Number(e);let t=!1,i=!1,r=!1;return e!=null&&!isNaN(e)?(e>=4&&(r=!0,e-=4),e>=2&&(i=!0,e-=2),e===1&&(t=!0)):t=!0,{use:t,show:i,locked:r}}transRoutingMode(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"PUSH";case 2:return"SURROUND";case 3:return"OBSTRUCT";case 4:return"SURROUND&PUSH";default:return"NONE"}}transPadDef(e){switch(e==null?void 0:e[0]){case"ELLIPSE":return{padType:"ELLIPSE",width:e[1],height:e[2]};case"RECT":return{padType:"RECT",width:e[1],height:e[2],radius:e[3]};case"OVAL":return{padType:"OVAL",width:e[1],height:e[2]};case"POLYGON":case"POLY":return{padType:"POLYGON",path:e[1]};default:return null}}transHoleDef(e){return e?{holeType:e[0],width:e[1],height:e[2]}:null}transPourDef(e){function t(i){switch(i=i&&Number(i),i){case 0:return"GRID_LINE";case 1:return"HORIZONTAL_LINE";case 2:return"VERTICAL_LINE";default:return"GRID_LINE"}}switch(e==null?void 0:e[0]){case"SOLID":return{pourType:"SOLID",fineness:e[1]};case"LINE":return{pourType:t(e[1]),angle:e[2],strokeWidth:e[3],strokeSpacing:e[4]};default:return null}}transUnusedPadRange(e){switch(e=e&&Number(e),e){case 1:return"ALL";case 2:return"PAD";case 3:return"VIA";default:return"VIA"}}transPathOptimization(e){switch(e=e&&Number(e),e){case 0:return"SINGLE";case 1:return"ALL";case 2:return"NONE";default:return"SINGLE"}}transViaType(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"SUTURE";default:return"NORMAL"}}transPadFuncType(e){switch(e=e&&Number(e),e){case 0:return"NORMAL";case 1:return"TEST";case 2:return"MARKER";default:return"NORMAL"}}transPadConnect(e){switch(e=e&&Number(e),e){case 0:return"DIVERGENCE";case 1:return"DIRECT";case 2:return"NON_CONNECT";default:return null}}transFillStyle(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"GRID";case 2:return"PLANE";default:return null}}transProhibitType(e){let t=new Set;if(!e)return[];for(let i of e)switch(i=i&&Number(i),i){case 1:t.add("TRACK"),t.add("FILL");break;case 2:t.add("COMPONENT");break;case 3:t.add("VIA");break;case 4:t.add("COPPER"),t.add("PLANE");break;case 5:t.add("TRACK");break;case 6:t.add("FILL");break;case 7:t.add("COPPER");break;case 8:t.add("PLANE");break}return Array.from(t)}transPushCoverDir(e){switch(e=e&&Number(e),e){case 1:return"X_AXIS_POSITIVE";case 2:return"X_AXIS_NEGATIVE";case 4:return"Y_AXIS_POSITIVE";case 8:return"Y_AXIS_NEGATIVE";default:return"X_AXIS_POSITIVE"}}transEntityBelong(e){switch(e=e&&Number(e),e){case 0:return"AUTO";case 1:return"UPPER_SHELLS";case 2:return"LOWER_SHELLS";default:return"AUTO"}}transSlotOption(e){e=e&&Number(e);let t=e;if(!t||t<4)return["OUTLINE","SCREW_PILLAR","ENTITY"];let i=[];return t>=16&&(i.push("ENTITY"),t-=16),t>=8&&(i.push("SCREW_PILLAR"),t-=8),t>=4&&(i.push("OUTLINE"),t-=4),i}transAlignType(e){switch(e=e&&Number(e),e){case 1:return"LEFT_TOP";case 4:return"CENTER_TOP";case 7:return"RIGHT_TOP";case 2:return"LEFT_MIDDLE";case 5:return"CENTER_MIDDLE";case 8:return"RIGHT_MIDDLE";case 3:return"LEFT_BOTTOM";case 6:return"CENTER_BOTTOM";case 9:return"RIGHT_BOTTOM";default:return"LEFT_BOTTOM"}}onParseLine(e){var t;let i=e[0];switch(i){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"CANVAS":this.parseCanvas(e);break;case"LAYER":this.parseLayer(e);break;case"LAYER_PHYS":this.layerPhysCache.push(e);break;case"ACTIVE_LAYER":this.parseActiveLayer(e);break;case"NET":this.parseNet(e);break;case"PRIMITIVE":this.parsePrimitive(e);break;case"GROUP":this.parseGroup(e);break;case"SILK_OPTS":this.parseSilkOpts(e);break;case"PREFERENCE":this.parsePreference(e);break;case"CONNECT":this.parseConnect(e);break;case"ITEM_ORDER":this.parseItemOrder(e);break;case"PROP":this.parseProp(e);break;case"EQLEN_GRP":this.parseEQLenGrp(e);break;case"EQLEN":this.parseEQLen(e);break;case"FONT":this.parseFont(e);break;case"PAD_NET":{this.cachePadNet[e[1]]||(this.cachePadNet[e[1]]=[]),this.cachePadNet[e[1]].push(e);break}case"REUSE_BLOCK":this.parseReuseBlock(e);break;case"RULE_TEMPLATE":this.parseRuleTemplate(e);break;case"RULE":this.rules.push(e);break;case"RULE_SELECTOR":this.ruleSelectors.push(e);break;case"PANELIZE":this.panelize.data=e;break;case"PANELIZE_STAMP":this.parsePanelizeStamp(e);break;case"PANELIZE_SIDE":this.parsePanelizeSide(e);break;case"POURED":{this.parsePoured(e);break}case"PARTITION":i==="PARTITION"&&(this.curPartition=e[3]?e[1]:"");case"VIA":case"PAD":case"LINE":case"ARC":case"CARC":case"OBJ":case"POLY":case"FILL":if(i==="FILL"&&e[6]===2){this.layerFill[e[4]]||(this.layerFill[e[4]]=[]),this.layerFill[e[4]].push(e);break}case"REGION":case"POUR":case"IMAGE":case"TEARDROP":case"FPC_FILL":case"SHELL":case"CREASE":i==="CREASE"&&this.creaseIds.push(e[1]);case"SHELLCUT":case"SHELL_ENTITY":case"BOSS":case"STRING":if(i==="STRING"&&!/^[a-zA-Z]+\d+$/.test(e[1])){let r=e[1],s=r.split(/([0-9].*)/);if(s.length>=2){let n=s[0],a=s[1];for(let o=0;o<a.length;o++){let l=a.charCodeAt(o);n+=l}r=n}this.stringId[r]=e[1],e[1]=r}case"DIMENSION":case"COMPONENT":{let r=i==="CARC"?"ARC":i,s=Ku(e[1]);this.cache[r]||(this.cache[r]={}),s!==null&&!this.cache[r][s]?this.cache[r][s]={part:this.curPartition,value:e}:(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPartition,value:e})),r==="COMPONENT"&&(this.components[e[1]]||(this.components[e[1]]={attrs:{},footprint:"",device:""}),this.components[e[1]].attrs=e[7]||{}),r==="DIMENSION"&&(this.dimension[e[1]]={attr:[]});break}case"ATTR":{if(this.docType==="PCB"&&!e[3])break;if(e[7]==="Footprint"&&(this.components[e[3]]||(this.components[e[3]]={attrs:{},footprint:"",device:""}),this.components[e[3]].footprint=e[8]),e[7]==="Device"&&(this.components[e[3]]||(this.components[e[3]]={attrs:{},footprint:"",device:""}),this.components[e[3]].device=e[8]),this.dimension[e[1]]){this.dimension[e[1]].attr=e;break}let r=Object.keys(((t=this.cache)==null?void 0:t.COMPONENT)||{}).find(n=>this.cache.COMPONENT[n].value[1]===e[3]);if(r){let n=this.cache.COMPONENT[r];n.attr||(n.attr=[]),n.attr.push({part:this.curPartition,value:e});break}let s=Ku(e[1]);this.cache[i]||(this.cache[i]={}),s!==null&&!this.cache[i][s]?this.cache[i][s]={part:this.curPartition,value:e}:(this.errorIds[i]||(this.errorIds[i]=[]),this.errorIds[i].push({part:this.curPartition,value:e}));break}default:console.warn("can not find hanlder with",e)}}async secondParseLine(e,t,i){let r=e[0];if(this.idsSet.has(e[1])||!e[1]){let s=`randomuuid${++this.randomUuid}`;if(this.oldId[s]=e[1],e[1]=s,i)for(let n of i)n[3]=s}else this.idsSet.add(e[1]);switch(r){case"DOCTYPE":case"HEAD":case"CANVAS":case"LAYER":case"LAYER_PHYS":case"ACTIVE_LAYER":case"NET":case"PRIMITIVE":case"GROUP":case"SILK_OPTS":case"PREFERENCE":case"ITEM_ORDER":case"RULE_TEMPLATE":case"RULE":case"RULE_SELECTOR":case"PANELIZE":case"PANELIZE_STAMP":case"PANELIZE_SIDE":case"CONNECT":case"EQLEN_GRP":case"EQLEN":case"FONT":case"PAD_NET":case"REUSE_BLOCK":case"PROP":break;case"PARTITION":this.parsePartition(e);break;case"VIA":this.parseVia(e);break;case"PAD":this.parsePad(e);break;case"LINE":await this.parseLine(e);break;case"ARC":this.parseArc(e);break;case"CARC":this.parseCArc(e);break;case"OBJ":this.parseObj(e);break;case"POLY":this.parsePoly(e);break;case"FILL":this.parseFill(e);break;case"REGION":this.parseRegion(e);break;case"POUR":this.parsePour(e);break;case"IMAGE":this.parseImage(e);break;case"TEARDROP":this.parseTeardrop(e);break;case"FPC_FILL":this.parseFpcFill(e);break;case"SHELL":this.parseShell(e);break;case"CREASE":this.parseCrease(e);break;case"SHELLCUT":this.parseShellCut(e);break;case"SHELL_ENTITY":this.parseShellEntity(e);break;case"BOSS":this.parseBoss(e);break;case"STRING":this.parseString(e);break;case"ATTR":this.parseAttr(e,t);break;case"DIMENSION":this.parseDimension(e);break;case"COMPONENT":this.parseComponent(e);break;default:console.warn("can not find hanlder with",e)}}onParseEnd(){for(let t of this.layerPhysCache)this.parseLayerPhys(t);this.layerPhysCache=[];for(let t of this.rules)t[1]=this.transRuleType(t[1]),t[3]=this.transRuleStatus(t[3]),t[4]=SR(t[1],t[2],t[3],t[4],this.fac,this.ruleTemplateName);if(this.fac.init){let t=Array.from(this.rules);for(let i of t){let r=IR(i[1],i[2],i[4],this.fac);r&&this.rules.push(r)}}for(let t of this.rules)this.parseRule(t);let e={};for(let t of this.ruleSelectors){let i=PR(t[1],t[2],kh(t[3]),this.fac),r=JSON.stringify(t[1]);e[r]?(t[2]&&(e[r].ruleOrder=t[2]),i.ruleKeyValue&&(e[r].ruleKeyValue=Object.assign(e[r].ruleKeyValue,i.ruleKeyValue)),(i.copperRuleValue||t[4])&&(e[r].copperValue=i.copperRuleValue||kh(t[4])),(i.innerPlaneRuleValue||t[5])&&(e[r].innerPlaneValue=i.innerPlaneRuleValue||kh(t[5]))):e[r]={ruleSelect:t[1],ruleOrder:t[2],ruleKeyValue:i.ruleKeyValue,copperValue:i.copperRuleValue||kh(t[4])||{},innerPlaneValue:i.innerPlaneRuleValue||kh(t[5])||{}}}for(let t in e)this.parseRuleSelector(e[t]);this.handConnect(),this.parseEQLenGrpFull(),this.parsePanelize(),this.parseLayerFill();for(let t in this.cache){let i=this.cache[t],r=Object.keys(i).sort((n,a)=>Number(n)-Number(a)),s=-1;for(let n of r){let a=Number(n),o=a-s-1;o>=1&&this.onPHolder(t,o),s=a,this.curPartition=i[a].part,this.secondParseLine(i[a].value,void 0,i[a].attr),i[a].attr&&i[a].attr.forEach(l=>{this.curPartition=l.part,this.secondParseLine(l.value)})}if(this.errorIds[t])for(let n of this.errorIds[t])this.curPartition=n.part,this.secondParseLine(n.value)}this.clearCache()}clearCache(){this.version=void 0,this.docType=void 0,this.curPartition="",this.eQLenData={},this.eQLenSort=1,this.cache={},this.components={},this.errorIds={},this.dimension={},this.connects={},this.specialColors={},this.reuseBlock={},this.panelize.data.length&&(this.panelize.data.length=0,this.panelize.stamp={h:null,v:null},this.panelize.size={h:null,v:null}),this.layerPhys=0,this.fac.init&&(this.fac=new y2),this.rules=[],this.ruleSelectors=[],this.ruleTemplateName="",this.layerFill={},this.idsSet.clear(),this.oldId={},this.creaseIds.length=0,this.substrateLayer.clear()}fixPolygon(e){if(e[0]=="R"){let t=parseFloat(e[3])/10,i=parseFloat(e[4])/10;e[6]=Math.min(t,i)/2*(parseFloat(e[6])||0)*10}}handleSimplePolygon(e){return!e||this.version>=1.5||this.fixPolygon(e),e}handlePolygon(e){if(this.version<1.5&&e&&e.length){if(!Array.isArray(e[0]))return this.handleSimplePolygon(e);for(let t of e)this.fixPolygon(t)}return e}parseEQLen(e){this.eQLenData[e[1]]?this.eQLenData[e[1]].pads?this.eQLenData[e[1]].pads.push(e[2]):this.eQLenData[e[1]].pads=[e[2]]:this.eQLenData[e[1]]={pads:[e[2]]}}parseEQLenGrp(e){this.eQLenData[e[1]]?(this.eQLenData[e[1]].id=e[1],this.eQLenData[e[1]].name=e[2],this.eQLenData[e[1]].sort=++this.eQLenSort):this.eQLenData[e[1]]={id:e[1],name:e[2],sort:++this.eQLenSort}}parseCanvas(e){this.onCanvas(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],this.transGridType(e[10]),this.transGridType(e[11]),e[12])}parseDocType(e){this.docType=e[1];let t=parseFloat(e[2]);this.version=t}parseHead(e){}parseLayer(e){let t=e[8];this.version<1.7&&(t=.5);let i=this.transLayerStatus(e[4]),r=Number(e[1]);if(e[2]==="SUBSTRATE"){if(this.substrateLayer.add(r),r<101)return;r<361&&(r=r+260)}this.onLayer(r,e[2],e[3],i.use,i.show,i.locked,e[5],e[6],e[7],t)}parseLayerPhys(e){let t=Number(e[1]);if(t>=101&&t<361&&this.substrateLayer.has(t))t=t+260;else if(t<101&&this.substrateLayer.has(t))return;this.onLayerPhys(t,e[2],e[3],e[4],e[5],!!e[6],++this.layerPhys)}parseActiveLayer(e){this.onActiveLayer(e[1])}parsePartition(e){this.onPartition(e[1],e[2],e[3],this.handlePolygon(e[4]))}parseNet(e){var t,i,r,s;this.onNet(e[1],(t=e[2])!=null?t:null,(i=e[3])!=null?i:null,!!e[4],(r=e[5])!=null?r:null,!!e[6],(s=e[7])!=null?s:null)}parsePrimitive(e){this.onPrimitive(e[1],!!e[2],!!e[3])}parseGroup(e){this.onGroup(e[1],e[2])}parseSilkOpts(e){this.onSilkOpts(e[1],e[2],e[3])}parsePreference(e){this.onPreference(!!e[1],e[2],!!e[3],e[4],e[5],!!e[6],this.transRoutingMode(e[7]),e[8],!!e[9],!!e[10],!!e[11],e[12],e[13],!!e[14],this.transUnusedPadRange(e[15]),e[16],this.transPathOptimization(e[17]),e[18],e[19],e[20])}parseConnect(e){this.connects[e[1]]=e[2]}parseVia(e){var t,i;this.onVia(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transViaType(e[9]),(t=e[10])!=null?t:null,(i=e[11])!=null?i:null,!!e[12],e[13])}parsePad(e){var t,i,r,s,n,a,o,l,h;this.onPad(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transHoleDef(e[9]),this.transPadDef(e[10]),e[11]&&(i=(t=e[11])==null?void 0:t.map(c=>({startLayer:c[0],endLayer:c[1],pad:this.transPadDef(c[2])})))!=null?i:null,e[12],e[13],e[14],!!e[15],this.transPadFuncType(e[16]),(r=e[17])!=null?r:null,(s=e[18])!=null?s:null,(n=e[19])!=null?n:null,(a=e[20])!=null?a:null,!!e[21],this.transPadConnect(e[22]),(o=e[23])!=null?o:null,(l=e[24])!=null?l:null,(h=e[25])!=null?h:null,e[26],this.getConnect(e[1]))}parseLine(e){this.onLine(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],!!e[10])}parseArc(e){this.onArc(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseCArc(e){this.onCArc(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseObj(e){this.onObj(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],!!e[10],e[11],!!e[12],this.specialColors[this.getOldId(e[1])])}parseItemOrder(e){this.itemOrder=e[1]}parseProp(e){this.specialColors[e[1]]=e[2]}parseEQLenGrpFull(){for(let e in this.eQLenData){let t=this.eQLenData[e];t.id&&this.onEQLenGrp(t.id,t.name,t.sort,t.pads||[])}this.eQLenData={},this.eQLenSort=1}parsePoly(e){this.onPoly(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handleSimplePolygon(e[6]),!!e[7],this.specialColors[this.getOldId(e[1])])}parseFill(e){this.onFill(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.transFillStyle(e[6]),this.handlePolygon(e[7]),!!e[8],this.getConnect(e[1]),this.specialColors[this.getOldId(e[1])])}getZIndex1(e){let t=e.match(dm);return t!=null&&t.length?t[1]:null}parseLayerFill(){for(let e in this.layerFill){let t=this.layerFill[e];this.onLayerFill(Number(e),{fill:t.map(i=>{let r=this.getZIndex1(i[1]);return{id:i[1],partitionId:this.curPartition||"",groupId:i[2],locked:!!i[8],zIndex:r===null?null:Number(r),netName:i[3],width:i[5],path:this.handlePolygon(i[7]),refs:this.getConnect(i[1]),specialColor:this.specialColors[this.getOldId(i[1])]}})})}}parseRegion(e){let t=e[5],i=t&&t.includes(9)?"CONSTRAINT":"PROHIBIT";t=i?t.filter(r=>r!==9):t,this.onRegion(e[1],this.curPartition||"",e[2],e[3],e[4],this.transProhibitType(t),this.handlePolygon(e[6]),!!e[7],e[8],i)}parsePour(e){let t=e[9];this.version<=1.7&&t&&t[0]==="SOLID"&&t[1]&&(t[1]=8),this.onPour(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],this.handlePolygon(e[8]),this.transPourDef(t),!!e[10],!!e[11]),this.poured[e[1]]&&this.onPoured(e[1],this.poured[e[1]])}parsePoured(e){if(this.version<1.1){if(this.curPourId){let t={id:e[1],strokeWidth:e[2],fill:e[3],path:this.handlePolygon(e[4])};this.poured[this.curPourId]||(this.poured[this.curPourId]={pourFill:[]}),this.poured[this.curPourId].pourFill.push(t)}}else{let t={id:e[1],strokeWidth:e[3],fill:e[4],path:this.handlePolygon(e[5])};this.poured[e[2]]||(this.poured[e[2]]={pourFill:[]}),this.poured[e[2]].pourFill.push(t)}}parseImage(e){this.onImage(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],!!e[9],e[10],!!e[11],this.specialColors[this.getOldId(e[1])])}parseTeardrop(e){let t,i,r;this.version<1.2?(t=e[5],r=e[4]):(t=e[4],i=e[5],r=this.getConnect(e[1])),this.onTeardrop(e[1],this.curPartition||"",e[2],e[3],this.handleSimplePolygon(t),i!=null?i:null,r)}parseFpcFill(e){this.onFpcFill(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handlePolygon(e[6]),!!e[7])}parseShell(e){let t=e[8];t&&t.Direction&&(t.Direction=this.transPushCoverDir(t.Direction)),this.onShell(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],this.handlePolygon(e[7]),t,!!e[9])}parseCrease(e){this.onCrease(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],e[7],e[8],!!e[9])}parseShellCut(e){this.onShellCut(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],this.handlePolygon(e[6]),!!e[7],this.getConnect(e[1]))}parseShellEntity(e){this.onShellEntity(e[1],this.curPartition||"",e[2],e[3],e[4],this.transEntityBelong(e[5]),this.transSlotOption(e[5]),e[6],e[7],this.handlePolygon(e[8]),!!e[9],this.getConnect(e[1]))}parseBoss(e){var t,i,r,s,n,a;this.version<1.4?this.onBoss(e[1],this.curPartition||"",e[2],e[3],e[5],e[6],(t=e[4])!=null?t:null,e[7],null,null,(i=e[8])!=null?i:null,(r=e[9])!=null?r:null,!!e[10]):this.onBoss(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],(s=e[6])!=null?s:null,e[7],e[8],e[9],(n=e[10])!=null?n:null,(a=e[11])!=null?a:null,!!e[12])}parseDimension(e){var t;let i=this.getOldId(e[1]),r=((t=this.dimension[i])==null?void 0:t.attr)||[];if(r.length){let n=this.fontCache.find(a=>a.id&&a.id===this.getOldId(r[1]));this.version<1.6&&n&&(n.text=r[8],n.fontFamily=r[11],n.fontSize=r[12]/10,n.thickness=r[13]/10,n.bold=r[15],n.italic=r[16],n.reverse=r[18],n.expansion=r[19]/10)}let s={groupId:r[2],layerId:r[4],x:r[5],y:r[6],text:r[8],fontFamily:r[11],fontSize:r[12],strokeWidth:r[13],bold:r[14],italic:r[15],origin:r[16],angle:r[17],reverse:r[18],expansion:r[19],mirror:r[20],locked:r[21],zIndex:null,specialColor:this.specialColors[this.getOldId(r[1])]};this.onDimension(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],!!e[7],e[8],!!e[9],s,this.specialColors[this.getOldId(e[1])],r[2]||"")}parseRuleTemplate(e){this.ruleTemplateName=e[1],this.onRuleTemplate(e[1])}parseRule(e){this.onRule(e[1],e[2],e[3],e[4])}parseRuleSelector(e){this.onRuleSelector(e.ruleSelect,e.ruleOrder,e.ruleKeyValue,e.copperValue,e.innerPlaneValue)}parsePanelize(){let e=this.panelize.data;e.length&&this.onPanelize(!!e[1],e[2],e[3],e[4],e[5],!!e[6],this.panelize.stamp.h,this.panelize.stamp.v,this.panelize.size.h,this.panelize.size.v)}parsePanelizeStamp(e){let t={on:!!e[2],stampHoleGroupQuantity:e[3],stampHoleDiameter:e[4],stampHoleQuantityPerGroup:e[5],stampHoleSpacing:e[6]};e[1]?this.panelize.stamp.v=t:this.panelize.stamp.h=t}parsePanelizeSide(e){let t={on:!!e[2],sideHeight:e[3],positionHoleDiameter:e[4],markDiameter:e[5],markExpansion:e[6]};e[1]?this.panelize.size.v=t:this.panelize.size.h=t}parseComponent(e){let t=this.getOldId(e[1]),i=e[7]||{},r=this.reuseBlock[t];if(r&&Object.assign(i,{"Group ID":r[2]||"","Channel ID":r[3]||""}),this.onComponent(e[1],this.curPartition||"",e[2],e[3],e[4],e[5],e[6],i,!!e[8],this.specialColors[t]),this.cachePadNet[t])for(let s of this.cachePadNet[t])this.parsePadNet(s)}parsePadNet(e){let t=this.getOldId(e[1]);if(e[4]===void 0&&this.components[t]){let i=this.components[t].footprint;if(!i){let s=this.components[t].device;i=this.devices.find(n=>n.uuid===s).attributes.Footprint}let r=this.padNumId[i];if(!r){let s=this.footprints.find(n=>n.uuid===i);s&&(this.padNumId[i]=AR(s==null?void 0:s.dataStr),r=this.padNumId[i])}if(r&&r[e[2]]){this.componentPadNum[t]||(this.componentPadNum[t]={}),this.componentPadNum[t][e[2]]===void 0&&(this.componentPadNum[t][e[2]]=-1);let s=++this.componentPadNum[t][e[2]];e[4]=r[e[2]][s]}else e[4]=e[2]}this.onPadNet(e[1],this.curPartition||"",e[2],e[3],e[4])}parseReuseBlock(e){this.reuseBlock[e[1]]=e}getFontCache(e,t,i,r,s,n,a,o){let l;return this.version<1.6?l=this.fontCache.find(h=>h.id===e):l=this.fontCache.find(h=>i==h.fontFamily&&t==h.text&&r/10==h.fontSize&&!!a==h.reverse&&o==h.expansion&&!!s==h.bold&&!!n==h.italic&&h.path.length>0),{paths:l==null?void 0:l.path,width:l==null?void 0:l.width,height:l==null?void 0:l.height}}getTextValue(e,t,i,r,s){let n="";return e!=""&&t===""&&this.docType!="PCB"&&!s&&e!="Footprint"&&!this.footprintIsConnectDevice&&(t=`<${e}>`),i?r?n=e+":"+t:n=e:r?n=t:n="",n}getFormulaName(e,t){if(!e||!e.startsWith("="))return e;e=e.slice(1);let i=/\{([^\}]+)\}/g,r=[],s=[];for(;r=i.exec(e);)s.push(r[1]);for(let n=0;n<s.length;n++){let a=s[n],o=`{${a}!}`;t.has(a)&&(o=t.get(a)),e=e.replace(`{${a}}`,o)}return e}parseAttr(e,t){let i=e[11],r=e[12];r&&this.version<1.2&&(i=="default"||i=="")&&(r*=1.5);let s=e[7],n=e[8],a=!!e[9],o=!!e[10],l=this.getOldId(e[3]),h=n;if(s==="Device"){let d=this.deviceName[n]||n;h=this.getTextValue(s,d,a,o,l)}else if(s==="Footprint"){let d=this.footprintName[n]||n;h=this.getTextValue(s,d,a,o,l)}else if(s==="Name"){let d=new Map;if(l){let f=this.components[l];if(d.set("ID",l),Object.entries(f.attrs).forEach(u=>d.set(u[0],u[1])),f.device){let u=this.devices.find(p=>p.uuid===f.device);u&&Object.entries(u.attributes).forEach(p=>d.set(p[0],p[1]))}}h=this.getTextValue(s,this.getFormulaName(n,d),a,o,l)}else h=this.getTextValue(s,n,a,o,l);let c=this.fontCache.find(d=>d.id&&d.id===this.getOldId(e[1]));this.version<1.6&&c&&(c.text=h,c.fontFamily=i,c.fontSize=r/10,c.thickness=e[13]/10,c.bold=e[15],c.italic=e[16],c.reverse=e[18],c.expansion=e[19]/10),this.onAttr(e[1],this.curPartition||"",e[2],l,e[4],e[5],e[6],s,n,a,o,i,r,e[13],!!e[14],!!e[15],this.transAlignType(e[16]),e[17],!!e[18],e[19],!!e[20],!!e[21],t,this.specialColors[this.getOldId(e[1])])}parseFont(e){let t;switch(this.version){case 1:case 1.1:t={id:e[1],path:e[2]};break;case 1.2:case 1.3:case 1.4:case 1.5:t={id:e[1],width:e[2],height:e[3],path:e[4]};break;default:t={text:e[1],fontFamily:e[2],fontSize:e[3],thickness:e[4],bold:!!e[5],italic:!!e[6],reverse:!!e[7],expansion:e[8],width:e[9],height:e[10],path:e[11]};break}this.fontCache.push(t)}parseString(e){var t;let[,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m]=e,O=(t=this.stringId[i])!=null?t:i;h&&this.version<1.2&&(l=="default"||l=="")&&(h*=1.5);let b=this.fontCache.find(v=>v.id&&v.id===this.getOldId(O));this.version<1.6&&b&&(b.text=o,b.fontFamily=l,b.fontSize=h/10,b.thickness=c/10,b.bold=d,b.italic=f,b.reverse=g,b.expansion=_/10),this.onString(i,this.curPartition||"",r,s,n,a,o,l,h,c,!!d,!!f,this.transAlignType(u),p,!!g,_,!!y,!!m,this.specialColors[this.getOldId(O)])}},LR=Object.create,Bv=Object.defineProperty,DR=Object.getOwnPropertyDescriptor,RR=Object.getOwnPropertyNames,NR=Object.getPrototypeOf,MR=Object.prototype.hasOwnProperty,BR=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kR=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of RR(t))!MR.call(e,s)&&s!==i&&Bv(e,s,{get:()=>t[s],enumerable:!(r=DR(t,s))||r.enumerable});return e},FR=(e,t,i)=>(i=e!=null?LR(NR(e)):{},kR(t||!e||!e.__esModule?Bv(i,"default",{value:e,enumerable:!0}):i,e)),UR=BR((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(x,I,S){S=S||2;var D=I&&I.length,N=D?I[0]*S:x.length,G=r(x,0,N,S,!0),z=[];if(!G||G.next===G.prev)return z;var Z,se,he,pe,Se,q,X;if(D&&(G=c(x,I,G,S)),x.length>80*S){Z=he=x[0],se=pe=x[1];for(var ie=S;ie<N;ie+=S)Se=x[ie],q=x[ie+1],Se<Z&&(Z=Se),q<se&&(se=q),Se>he&&(he=Se),q>pe&&(pe=q);X=Math.max(he-Z,pe-se),X=X!==0?32767/X:0}return n(G,z,S,Z,se,X,0),z}function r(x,I,S,D,N){var G,z;if(N===R(x,I,S,D)>0)for(G=I;G<S;G+=D)z=F(G,x[G],x[G+1],z);else for(G=S-D;G>=I;G-=D)z=F(G,x[G],x[G+1],z);return z&&E(z,z.next)&&(j(z),z=z.next),z}function s(x,I){if(!x)return x;I||(I=x);var S=x,D;do if(D=!1,!S.steiner&&(E(S,S.next)||v(S.prev,S,S.next)===0)){if(j(S),S=I=S.prev,S===S.next)break;D=!0}else S=S.next;while(D||S!==I);return I}function n(x,I,S,D,N,G,z){if(x){!z&&G&&g(x,D,N,G);for(var Z=x,se,he;x.prev!==x.next;){if(se=x.prev,he=x.next,G?o(x,D,N,G):a(x)){I.push(se.i/S|0),I.push(x.i/S|0),I.push(he.i/S|0),j(x),x=he.next,Z=he.next;continue}if(x=he,x===Z){z?z===1?(x=l(s(x),I,S),n(x,I,S,D,N,G,2)):z===2&&h(x,I,S,D,N,G):n(s(x),I,S,D,N,G,1);break}}}}function a(x){var I=x.prev,S=x,D=x.next;if(v(I,S,D)>=0)return!1;for(var N=I.x,G=S.x,z=D.x,Z=I.y,se=S.y,he=D.y,pe=N<G?N<z?N:z:G<z?G:z,Se=Z<se?Z<he?Z:he:se<he?se:he,q=N>G?N>z?N:z:G>z?G:z,X=Z>se?Z>he?Z:he:se>he?se:he,ie=D.next;ie!==I;){if(ie.x>=pe&&ie.x<=q&&ie.y>=Se&&ie.y<=X&&O(N,Z,G,se,z,he,ie.x,ie.y)&&v(ie.prev,ie,ie.next)>=0)return!1;ie=ie.next}return!0}function o(x,I,S,D){var N=x.prev,G=x,z=x.next;if(v(N,G,z)>=0)return!1;for(var Z=N.x,se=G.x,he=z.x,pe=N.y,Se=G.y,q=z.y,X=Z<se?Z<he?Z:he:se<he?se:he,ie=pe<Se?pe<q?pe:q:Se<q?Se:q,de=Z>se?Z>he?Z:he:se>he?se:he,Ce=pe>Se?pe>q?pe:q:Se>q?Se:q,De=y(X,ie,I,S,D),Fe=y(de,Ce,I,S,D),Pe=x.prevZ,w=x.nextZ;Pe&&Pe.z>=De&&w&&w.z<=Fe;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0||(Pe=Pe.prevZ,w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;Pe&&Pe.z>=De;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0)return!1;Pe=Pe.prevZ}for(;w&&w.z<=Fe;){if(w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function l(x,I,S){var D=x;do{var N=D.prev,G=D.next.next;!E(N,G)&&T(N,D,D.next,G)&&M(N,G)&&M(G,N)&&(I.push(N.i/S|0),I.push(D.i/S|0),I.push(G.i/S|0),j(D),j(D.next),D=x=G),D=D.next}while(D!==x);return s(D)}function h(x,I,S,D,N,G){var z=x;do{for(var Z=z.next.next;Z!==z.prev;){if(z.i!==Z.i&&b(z,Z)){var se=k(z,Z);z=s(z,z.next),se=s(se,se.next),n(z,I,S,D,N,G,0),n(se,I,S,D,N,G,0);return}Z=Z.next}z=z.next}while(z!==x)}function c(x,I,S,D){var N=[],G,z,Z,se,he;for(G=0,z=I.length;G<z;G++)Z=I[G]*D,se=G<z-1?I[G+1]*D:x.length,he=r(x,Z,se,D,!1),he===he.next&&(he.steiner=!0),N.push(m(he));for(N.sort(d),G=0;G<N.length;G++)S=f(N[G],S);return S}function d(x,I){return x.x-I.x}function f(x,I){var S=u(x,I);if(!S)return I;var D=k(S,x);return s(D,D.next),s(S,S.next)}function u(x,I){var S=I,D=x.x,N=x.y,G=-1/0,z;do{if(N<=S.y&&N>=S.next.y&&S.next.y!==S.y){var Z=S.x+(N-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(Z<=D&&Z>G&&(G=Z,z=S.x<S.next.x?S:S.next,Z===D))return z}S=S.next}while(S!==I);if(!z)return null;var se=z,he=z.x,pe=z.y,Se=1/0,q;S=z;do D>=S.x&&S.x>=he&&D!==S.x&&O(N<pe?D:G,N,he,pe,N<pe?G:D,N,S.x,S.y)&&(q=Math.abs(N-S.y)/(D-S.x),M(S,x)&&(q<Se||q===Se&&(S.x>z.x||S.x===z.x&&p(z,S)))&&(z=S,Se=q)),S=S.next;while(S!==se);return z}function p(x,I){return v(x.prev,x,I.prev)<0&&v(I.next,x,x.next)<0}function g(x,I,S,D){var N=x;do N.z===0&&(N.z=y(N.x,N.y,I,S,D)),N.prevZ=N.prev,N.nextZ=N.next,N=N.next;while(N!==x);N.prevZ.nextZ=null,N.prevZ=null,_(N)}function _(x){var I,S,D,N,G,z,Z,se,he=1;do{for(S=x,x=null,G=null,z=0;S;){for(z++,D=S,Z=0,I=0;I<he&&(Z++,D=D.nextZ,!!D);I++);for(se=he;Z>0||se>0&&D;)Z!==0&&(se===0||!D||S.z<=D.z)?(N=S,S=S.nextZ,Z--):(N=D,D=D.nextZ,se--),G?G.nextZ=N:x=N,N.prevZ=G,G=N;S=D}G.nextZ=null,he*=2}while(z>1);return x}function y(x,I,S,D,N){return x=(x-S)*N|0,I=(I-D)*N|0,x=(x|x<<8)&16711935,x=(x|x<<4)&252645135,x=(x|x<<2)&858993459,x=(x|x<<1)&1431655765,I=(I|I<<8)&16711935,I=(I|I<<4)&252645135,I=(I|I<<2)&858993459,I=(I|I<<1)&1431655765,x|I<<1}function m(x){var I=x,S=x;do(I.x<S.x||I.x===S.x&&I.y<S.y)&&(S=I),I=I.next;while(I!==x);return S}function O(x,I,S,D,N,G,z,Z){return(N-z)*(I-Z)>=(x-z)*(G-Z)&&(x-z)*(D-Z)>=(S-z)*(I-Z)&&(S-z)*(G-Z)>=(N-z)*(D-Z)}function b(x,I){return x.next.i!==I.i&&x.prev.i!==I.i&&!C(x,I)&&(M(x,I)&&M(I,x)&&H(x,I)&&(v(x.prev,x,I.prev)||v(x,I.prev,I))||E(x,I)&&v(x.prev,x,x.next)>0&&v(I.prev,I,I.next)>0)}function v(x,I,S){return(I.y-x.y)*(S.x-I.x)-(I.x-x.x)*(S.y-I.y)}function E(x,I){return x.x===I.x&&x.y===I.y}function T(x,I,S,D){var N=A(v(x,I,S)),G=A(v(x,I,D)),z=A(v(S,D,x)),Z=A(v(S,D,I));return!!(N!==G&&z!==Z||N===0&&P(x,S,I)||G===0&&P(x,D,I)||z===0&&P(S,x,D)||Z===0&&P(S,I,D))}function P(x,I,S){return I.x<=Math.max(x.x,S.x)&&I.x>=Math.min(x.x,S.x)&&I.y<=Math.max(x.y,S.y)&&I.y>=Math.min(x.y,S.y)}function A(x){return x>0?1:x<0?-1:0}function C(x,I){var S=x;do{if(S.i!==x.i&&S.next.i!==x.i&&S.i!==I.i&&S.next.i!==I.i&&T(S,S.next,x,I))return!0;S=S.next}while(S!==x);return!1}function M(x,I){return v(x.prev,x,x.next)<0?v(x,I,x.next)>=0&&v(x,x.prev,I)>=0:v(x,I,x.prev)<0||v(x,x.next,I)<0}function H(x,I){var S=x,D=!1,N=(x.x+I.x)/2,G=(x.y+I.y)/2;do S.y>G!=S.next.y>G&&S.next.y!==S.y&&N<(S.next.x-S.x)*(G-S.y)/(S.next.y-S.y)+S.x&&(D=!D),S=S.next;while(S!==x);return D}function k(x,I){var S=new L(x.i,x.x,x.y),D=new L(I.i,I.x,I.y),N=x.next,G=I.prev;return x.next=I,I.prev=x,S.next=N,N.prev=S,D.next=S,S.prev=D,G.next=D,D.prev=G,D}function F(x,I,S,D){var N=new L(x,I,S);return D?(N.next=D.next,N.prev=D,D.next.prev=N,D.next=N):(N.prev=N,N.next=N),N}function j(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function L(x,I,S){this.i=x,this.x=I,this.y=S,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(x,I,S,D){var N=I&&I.length,G=N?I[0]*S:x.length,z=Math.abs(R(x,0,G,S));if(N)for(var Z=0,se=I.length;Z<se;Z++){var he=I[Z]*S,pe=Z<se-1?I[Z+1]*S:x.length;z-=Math.abs(R(x,he,pe,S))}var Se=0;for(Z=0;Z<D.length;Z+=3){var q=D[Z]*S,X=D[Z+1]*S,ie=D[Z+2]*S;Se+=Math.abs((x[q]-x[ie])*(x[X+1]-x[q+1])-(x[q]-x[X])*(x[ie+1]-x[q+1]))}return z===0&&Se===0?0:Math.abs((Se-z)/z)};function R(x,I,S,D){for(var N=0,G=I,z=S-D;G<S;G+=D)N+=(x[z]-x[G])*(x[G+1]+x[z+1]),z=G;return N}i.flatten=function(x){for(var I=x[0][0].length,S={vertices:[],holes:[],dimensions:I},D=0,N=0;N<x.length;N++){for(var G=0;G<x[N].length;G++)for(var z=0;z<I;z++)S.vertices.push(x[N][G][z]);N>0&&(D+=x[N-1].length,S.holes.push(D))}return S}}),GR=(e=>(e[e.MIL=1]="MIL",e[e.INCH=1e3]="INCH",e[e.FT=12e3]="FT",e[e.YARD=36e3]="YARD",e[e.MILE=6336e4]="MILE",e[e.KM=3937007874e-2]="KM",e[e.M=39370]="M",e[e.DM=3937]="DM",e[e.CM=393.7]="CM",e[e.MM=39.37]="MM",e[e.UM=.039]="UM",e[e.NM=394e-7]="NM",e[e.PT=13.88888888888889]="PT",e[e.PX72=13.88888888888889]="PX72",e[e.PX96=10.416666666666666]="PX96",e[e.PX100=10]="PX100",e[e.LTSPICE=6.25]="LTSPICE",e[e.PX1=.1]="PX1",e[e.PX001=.001]="PX001",e))(GR||{}),zR=(e=>(e.MIL="mil",e.INCH="inch",e.FT="ft",e.YARD="yard",e.MILE="mile",e.KM="km",e.M="m",e.DM="dm",e.CM="cm",e.MM="mm",e.UM="um",e.NM="nm",e.PT="pt",e.PX72="px(72)",e.PX96="px(96)",e.PX100="px(100)",e))(zR||{}),x2={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},cZ=(()=>{let e={};for(let t in x2)e[x2[t]]=t;return e})(),np,uZ=(np=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},np.ASIS=new np(1,1),np),ap=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,s=this[r](i);return t=="mil"?Math.round(s*10)/10:Math.round(s*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};ap.prototype["px(100)2mil"]=e=>e*10,ap.prototype["px(100)2mm"]=e=>e*.254,ap.prototype["mil2px(100)"]=e=>e/10,ap.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var op=null,pm=new ArrayBuffer(8),s0=new Float64Array(pm),n0=new Uint32Array(pm),E2=new Uint16Array(pm),w2=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!op){let e=this.getUrlVars().version;e?op="/analyzer/v"+e:op="/analyzer"}return op}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;s0[0]=new Date().getTime(),e.push(n0[1].toString(16)),s0[0]=Math.random(),e.push(E2[3].toString(16));let t=E2[2].toString(16);e.push("4"+t.substr(0,3)),s0[0]=performance.now();let i=n0[0].toString(16)+n0[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},kv=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Vh.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Vh.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Vh.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Vh.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},HR=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(HR||{}),jR=/(\.?0+)$/,Vh=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(w2.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(w2.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);kv.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(jR,"")}},VR=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARNING=2]="WARNING",e[e.ERROR=3]="ERROR",e[e.DUMMY=4]="DUMMY",e))(VR||{});function YR(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var qR=(e,t)=>{e===3?console.error(t):console.log(t)},WR=(e,t)=>Vh.format("%s %s: %s",new Date,YR(e),t),Ph,hg=(Ph=class{constructor(e,t=qR,i=WR){this.debug=!1,this.level=e,this.writer=t,this.fmt=i}static mix(...e){let t=4;for(let i of e)i.level<t&&(t=i.level);return new Ph(t,(i,r)=>{for(let s of e)s.write1(i,r)},(i,r)=>r)}wrap(e=null,t=null){let i=e===null?this.fmt:(s,n)=>(n=e(s,n),this.fmt(s,n)),r=t===null?this.writer:(s,n)=>{t(s,n),this.writer(s,n)};return new Ph(this.level,r,i)}chain(e){return e.wrap(this.fmt.bind(this),this.writer.bind(this))}include(e){return this.level<=e}write3(e,t,i){this.include(e)&&this.writer(e,this.fmt(e,Vh.format(t,...i)))}write2(e,t){this.include(e)&&(t instanceof Error?this.writer(e,this.fmt(e,t.stack)):this.writer(e,this.fmt(e,t.toString())))}write1(e,t){this.include(e)&&this.writer(e,this.fmt(e,t))}debug3(e,...t){this.write3(0,e,t)}debug2(e){this.write2(0,e)}debug1(e){this.write1(0,e)}info3(e,...t){this.write3(1,e,t)}info2(e){this.write2(1,e)}info1(e){this.write1(1,e)}warning3(e,...t){this.write3(2,e,t)}warning2(e){this.write2(2,e)}warning1(e){this.write1(2,e)}error3(e,...t){this.write3(3,e,t)}error2(e){this.write2(3,e)}error1(e){this.write1(3,e)}},Ph.DUMMY=new Ph(4),Ph),gm=new ArrayBuffer(8),a0=new Float64Array(gm),o0=new Uint32Array(gm),T2=new Uint16Array(gm),S2=ArrayBuffer;try{S2=self.HTMLImageElement||S2}catch{}var lp=null;function Bl(e,t,i=0,r=e.length){s(e,null,t,i,r);function s(a,o,l,h,c){let d,f,u,p;if(h<c-1){let g=c-h;if(g>50)o===null&&(o=new Array(g+1)),n(a,o,l,h,(h+c)/2|0,c);else{d=a[h],f=h,u=h,p=c;let _=f+1;for(;_<p;){if(u!=p){if(p=p+-1,l(d,a[p])<=0)continue;a[u]=a[p],u=p;continue}if(l(d,a[_])>=0){f=_,_=f+1;continue}a[u]=a[_],f=_,u=_,_=f+1}a[u]=d,s(a,o,l,h,u),s(a,o,l,u+1,c)}}}function n(a,o,l,h,c,d){s(a,o,l,h,c),s(a,o,l,c,d);for(var f=h,u=c,p=0,g=a[f],_=a[u];f<c&&u<d;){var y=l(g,_);isNaN(y)?(o[p++]=_,_=a[++u]):(y<=0&&(o[p++]=g,g=a[++f]),y>=0&&(o[p++]=_,_=a[++u]))}for(;f<c;f++)o[p++]=a[f];for(;u<d;u++)o[p++]=a[u];for(f=h,u=0;u<p;f++,u++)a[f]=o[u]}}var Qr=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!lp){let e=this.getUrlVars().version;e?lp="/analyzer/v"+e:lp="/analyzer"}return lp}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;a0[0]=new Date().getTime(),e.push(o0[1].toString(16)),a0[0]=Math.random(),e.push(T2[3].toString(16));let t=T2[2].toString(16);e.push("4"+t.substr(0,3)),a0[0]=performance.now();let i=o0[0].toString(16)+o0[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},XR=[1,10,100,1e3],hp=0,Tl=0;function I2(e,t,i){return hp=Math.abs(e-t),i>=5&&hp>1e-5||isNaN(i)&&hp>1e-8?!1:hp<1e-13?!0:(Tl=Math.min(P2(e),P2(t)),Tl<10&&(Tl=10),isNaN(i)||(Tl=Math.min(Tl,i)),A2(e,Tl)===A2(t,Tl))}var cp=0,up=0;function P2(e){return cp=0,up=0,e>0?cp=e-Math.floor(e):cp=e-Math.ceil(e),up=(cp.toString()||"").length,up>2?up-2:0}function A2(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=XR[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}var JR=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(JR||{}),ZR=/(\.?0+)$/,Yh=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(Qr.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(Qr.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);Si.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(ZR,"")}},Si=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Yh.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Yh.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Yh.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Yh.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},dp,we=(dp=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}},dp.eps=1e-8,dp.precision=1e8,dp);function Zh(e,t){zp(e.iterator(),t)}function zp(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var KR=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function B0(e){return new KR(e)}var Kr,pt=(Kr=class{static toDegrees(e){return e*180/Math.PI}static toRadians(e){return e/180*Math.PI}static regularD(e){return e=e%360,e=e<0?360+e:e,e===360?0:e}static regular(e){return e=e%Kr.PIx2,e=e<0?Kr.PIx2+e:e,e===Kr.PIx2?0:e}static toQuarterBase(e){return Kr.regular((e+Kr.PI_4)/Kr.PI_2*Kr.PI_2)}static toQuarterBaseD(e){return Kr.regularD(((e+45)/90|0)*90)}static transformD(e,t){return Kr.toDegrees(Kr.transform(Kr.toRadians(e),t))}static transform(e,t){let i=Math.cos(e),r=Math.sin(e),s=new ge(t.data[6],t.data[7]),n=new ge(i,r).multiply3(t);return Kr.regular(n.angle(s))}},Kr.PIx2=Math.PI*2,Kr.PI_2=Math.PI/2,Kr.PI_4=Math.PI/4,Kr),Fi=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,s,n){return this.dotProd1(i-e,r-t,s-i,n-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,s,n){return this.crossProd1(i-e,r-t,s-i,n-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let s=i-e,n=r-t;return s*s+n*n}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},Fv=new ArrayBuffer(16),C2=new Float64Array(Fv),fp=new Int32Array(Fv),qt,ge=(qt=class{static sortByXAsc(e,t){return e.x-t.x}static sortByYAsc(e,t){return e.y-t.y}static sortByXYAsc(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y-t.y}static caculateAngle(e,t){let i=Math.cos(e),r=Math.sin(e),s=i*t.data[0]+r*t.data[4],n=i*t.data[1]+r*t.data[5],a=new qt(s,n).normalize();return Math.atan2(a.y,a.x)}static normal(e,t,i){let r=t.sub(e),s=i.sub(t);return r.cross(s)}static getVector2(e){return new qt(Math.cos(e),Math.sin(e))}static getCrossPoint1(e,t,i,r){if(e.equals1(t)||i.equals1(r)||we.eq(1,Math.abs(t.sub(e).normalize().dot(r.sub(i).normalize()))))return null;let s=t.y-e.y,n=e.x-t.x,a=t.x*e.y-e.x*t.y,o=r.y-i.y,l=i.x-r.x,h=r.x*i.y-i.x*r.y,c=s*l-o*n;return new qt((h*n-a*l)/c,(a*o-h*s)/c)}static getCrossPoint2(e,t,i,r){return this.getCrossPoint1(e,e.add(t),i,i.add(r))}constructor(e,t){this.x=Si.normal(e),this.y=Si.normal(t)}get hashed(){return this._hashed==null&&(C2[0]=this.x,C2[1]=this.y,this._hashed=fp[0]^fp[1]^fp[2]^fp[3]),this._hashed}dot(e){return this.x*e.x+this.y*e.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(e){var t=this.x-e.x,i=this.y-e.y;return new qt(t,i)}add(e){var t=this.x+e.x,i=this.y+e.y;return new qt(t,i)}div(e){return new qt(this.x/e,this.y/e)}add1(e,t){return new qt(this.x+e,this.y+t)}mul(e){return new qt(this.x*e,this.y*e)}cross(e){return this.x*e.y-this.y*e.x}getSin(){return this.y/this.length()}angle2(e){let t=this.y-e.y,i=this.x-e.x;return t=Math.abs(t-0)<10**-4?0:t,i=Math.abs(i-0)<10**-4?0:i,Math.atan2(t,i)}angleD2(e){return pt.toDegrees(this.angle2(e))}angle(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleX(e=qt.ORIGIN){let t=this.angle(e);return t<0&&(t=Math.PI*2+t),t}angleD(e){return pt.toDegrees(this.angle(e))}distance1(e){let t=e.x-this.x,i=e.y-this.y;return Fi.hypot(t,i)}distance2(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}rotateD(e,t){return this.rotate(e,pt.toRadians(t))}rotate(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,n=this.y-e.y,a=s*i+n*-r,o=s*r+n*i;return e.add1(a,o)}multiply3(e){let t=this.x*e.data[0]+this.y*e.data[3]+e.data[6],i=this.x*e.data[1]+this.y*e.data[4]+e.data[7];return new qt(t,i)}multiply4(e){let t=this.x*e.data[0]+this.y*e.data[4]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+e.data[13];return new qt(t,i)}hashCode(){return this.hashed}equals(e,t){return e instanceof qt?I2(e.x,this.x,t)&&I2(e.y,this.y,t):!1}equals1(e){return e?we.eq(this.x,e.x)&&we.eq(this.y,e.y):!1}equals2(e,t){return e instanceof qt?Math.abs(this.x-e.x)<=t&&Math.abs(this.y-e.y)<=t:!1}similarEquals(e,t=.5){return Math.abs(this.x*.1-e.x*.1)<=t&&Math.abs(this.y*.1-e.y*.1)<=t}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let e=this.x,t=this.y;return new $r(e,e,t,t)}normalize(){if(this.x===0&&this.y===0)return new qt(0,0);let e=this.x/this.length(),t=this.y/this.length();return new qt(e,t)}regular(e=1e-4){let t=Math.round(1/e);return new qt(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}round(e=4){let t=10**(e|0);return new qt(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}mirrorX(e=qt.ORIGIN){return new qt(this.x,2*e.y-this.y)}mirrorY(e=qt.ORIGIN){return new qt(2*e.x-this.x,this.y)}mirrorCenter(e=qt.ORIGIN){return new qt(2*e.x-this.x,2*e.y-this.y)}clone(){return new qt(this.x,this.y)}mirror(e=qt.ORIGIN){return new qt(2*e.x-this.x,2*e.y-this.y)}pointOnRays(e,t){let i=pt.toRadians(e);return new qt(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}pointOnRays2(e,t){let i=e.angle(this);return new qt(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}scale(e){return new qt(this.x*e,this.y*e)}},qt.ORIGIN=new qt(0,0),qt.X_UNIT_VECTOR=new qt(1,0),qt.Y_UNIT_VECTOR=new qt(0,1),qt),$R=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))($R||{}),QR=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(QR||{}),mr,Ua=(mr=class{constructor(e,t){this.horizontal=e,this.vertical=t}},mr.LT=new mr(0,0),mr.LC=new mr(0,1),mr.LB=new mr(0,2),mr.CT=new mr(1,0),mr.CC=new mr(1,1),mr.CB=new mr(1,2),mr.RT=new mr(2,0),mr.RC=new mr(2,1),mr.RB=new mr(2,2),mr),eN=(e=>(e[e.INNER=0]="INNER",e[e.OUTER=1]="OUTER",e[e.SEPARATED=2]="SEPARATED",e[e.INTERSECTED=3]="INTERSECTED",e[e.EQ=4]="EQ",e[e.INSIDE_TOUCHED=5]="INSIDE_TOUCHED",e[e.OUTSIDE_TOUCHED=6]="OUTSIDE_TOUCHED",e))(eN||{}),Cs=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return Zh(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new ge(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new $r(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new $r(this.minX,this.maxX,this.minY,this.maxY):new $r(0,0,0,0)}},Cu=new Float64Array(4),$r=class dn{static extendRect({x:t,y:i,width:r,height:s}){return new dn(t,t+r,i,i+s)}static extend1(t,i){if(t===null)return new dn(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),s=Math.max(t.maxX,i.x),n=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new dn(r,s,n,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),s=Math.max(t.maxX,i.maxX),n=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new dn(r,s,n,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),s=Math.max(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new dn(r,s,n,a)}static extend4(t,i,r){return new dn(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,s){if(this.minX=Si.normal(t),this.maxX=Si.normal(i),this.minY=Si.normal(r),this.maxY=Si.normal(s),t>i||r>s)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${s}]`)}get data(){return Cu[0]=this.minX,Cu[1]=this.maxX,Cu[2]=this.minY,Cu[3]=this.maxY,Cu}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return we.greatereq(t,this.minX)&&we.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return we.greatereq(t,this.minY)&&we.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return Si.positiveOr0(this.maxX-this.minX+t*2),Si.positiveOr0(this.maxY-this.minY+t*2),new dn(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return we.greatereq(this.maxX,t.maxX)&&we.lesseq(this.minX,t.minX)&&we.greatereq(this.maxY,t.maxY)&&we.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return s>n?null:new dn(i,r,s,n)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(we.greater(i,r))return null;i>r&&(r=i);let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return we.greater(s,n)?null:(s>n&&(n=s),new dn(i,r,s,n))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new ge(this.minX,this.maxY)}UR(){return new ge(this.maxX,this.maxY)}LL(){return new ge(this.minX,this.minY)}LR(){return new ge(this.maxX,this.minY)}center(){return new ge(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new Cs;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new Cs;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let s;this.minY>=t.minY?s=this.minY:s=t.minY;let n;return this.maxY<=t.maxY?n=this.maxY:n=t.maxY,s>n}}relation(t){let i=0,r=0,s;this.minX>t.minX?(i++,s=this.minX):this.minX===t.minX?s=this.minX:(r++,s=t.minX);let n;if(this.maxX<t.maxX?(i++,n=this.maxX):this.maxX===t.maxX?n=this.maxX:(r++,n=t.maxX),s>n)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:s===n||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),s=this.center();return t!=0&&(i/=t/2,r/=t/2),new dn(s.x-i,s.x+i,s.y-i,s.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),dn.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),s=this.width()*i/2,n=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>s?o>n?Ua.RT:o<-n?Ua.RB:Ua.RC:a<-s?o>n?Ua.LT:o<-n?Ua.LB:Ua.LC:o>n?Ua.CT:o<-n?Ua.CB:Ua.CC}bbox(){return this}},Hp=class Mt{static mul(t,i,r,s,n,a){let o=0,l=0;for(let h=0;h<t;h++){for(let c=0;c<r;c++){let d=c,f=0;for(let u=0;u<i;u++)f+=s[l+u]*n[d],d+=r;a[o++]=f}l+=i}}constructor(t,i,r){this.m=Si.normal(t),this.n=Si.normal(i);let s=t*i;if(r.length===s){for(let n=0;n<r.length;n++)Si.normal(r[n]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return Mt.mul(this.m,this.n,t.n,this.data,t.data,i),new Mt(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let s=0;s<this.n;s++){let n=this.data[i++].toString();s===0?(t.push(`
`),t.push("	"),t.push(n)):(t.push(", "),t.push(n))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,s=r*2,n=new Array(i*s);for(let a=0;a<i;a++)for(let o=0;o<s;o++)o<r?n[Mt.on(s,a,o)]=t[Mt.on(r,a,o)]:o===i+a?n[Mt.on(s,a,o)]=1:n[Mt.on(s,a,o)]=0;return n}inverseMatrix(t,i,r){for(let s=0;s<i;s++){let n=t[Mt.on(r,s,s)];for(let a=0;a<r;a++)t[Mt.on(r,s,a)]/=n}return t}getMatrixRank(t,i,r){let s=Math.min(i,r);for(let n=0;n<i;n++){if(t[Mt.on(r,n,n)]===0){let a=new Array(r),o;for(o=n;o<i;o++)if(t[Mt.on(r,o,n)]!==0){Qr.arraycopy(t,Mt.on(r,o,0),a,0,r),Qr.arraycopy(t,Mt.on(r,n,0),t,Mt.on(r,o,0),r),Qr.arraycopy(a,0,t,Mt.on(r,n,0),r);break}o>=i&&(s-=1)}if(!(s<i))for(let a=0;a<i;a++){if(a===n)continue;let o=t[Mt.on(r,a,n)]/t[Mt.on(r,n,n)];for(let l=0;l<r;l++)t[Mt.on(r,a,l)]-=t[Mt.on(r,n,l)]*o}}return s}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return we.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function s(a,o){for(let l=0;l<r;l++){let h=i[Mt.on(r,a,l)];i[Mt.on(r,a,l)]=i[Mt.on(r,o,l)],i[Mt.on(r,o,l)]=h}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Mt.on(r,a,a)]),l=a;if(t(i[Mt.on(r,a,a)]))for(let c=a+1;c<this.m;c++){if(t(i[Mt.on(r,c,a)])){Math.abs(i[Mt.on(r,c,a)])>o&&(o=Math.abs(i[Mt.on(r,c,a)]),l=c);continue}s(a,c);break}if(t(i[Mt.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&s(a,l)}let h=1/i[Mt.on(r,a,a)];for(let c=0;c<r;c++)i[Mt.on(r,a,c)]*=h;for(let c=0;c<this.m;c++){if(a===c)continue;let d=i[Mt.on(r,c,a)];for(let f=a;f<r;f++)i[Mt.on(r,c,f)]-=i[Mt.on(r,a,f)]*d}}let n=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)n[Mt.on(this.n,a,o-this.n)]=i[Mt.on(r,a,o)];return new Mt(this.m,this.n,n)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new Mt(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof Mt?!(this.m!=t.m||this.n!=t.n||!Qr.equals(this.data,t.data)):!1}},tN=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Li,Uv=(Li=class extends Hp{static translate(e,t,i){return new Li([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new Li([1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1])}static rotateX(e){let t=Math.cos(e),i=Math.sin(e);return new Li([1,0,0,0,0,t,i,0,0,-i,t,0,0,0,0,1])}static rotateY(e){let t=Math.cos(e),i=Math.sin(e);return new Li([t,0,-i,0,0,1,0,0,i,0,t,0,0,0,0,1])}static rotateZ(e){let t=Math.cos(e),i=Math.sin(e);return new Li([t,i,0,0,-i,t,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(e,t){e=e.normalize();let i=e.x,r=e.y,s=e.z,n=Math.sin(t),a=Math.cos(t);return new Li([i*i*(1-a)+a,i*r*(1-a)+s*n,i*s*(1-a)-r*n,0,i*r*(1-a)-s*n,r*r*(1-a)+a,r*s*(1-a)+i*n,0,i*s*(1-a)+r*n,r*s*(1-a)-i*n,s*s*(1-a)+a,0,0,0,0,1])}static scale(e,t=e,i=e){return new Li([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new Li([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new Li([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(e,t){return e.equals1(ge.ORIGIN)?Li.rotateZ(t):Li.translate(-e.x,-e.y,0).rotateZ(t).translate1(e.x,e.y,0)}static getMatrix4(e,t,i,r){let s=Math.cos(t),n=Math.sin(t),a=i*(e.x*s-e.y*n)+r.x,o=e.x*n+e.y*s+r.y,l=[i*s,n,0,0,-n*i,s,0,0,0,0,1,0,a,o,0,1];return new Li(l)}constructor(e=tN){super(4,4,e)}translate(e){return this.multiply4(Li.translate1(e))}translate1(e,t,i){return this.multiply4(Li.translate(e,t,i))}rotateX(e){return this.multiply4(Li.rotateX(e))}rotateY(e){return this.multiply4(Li.rotateY(e))}rotateZ(e){return this.multiply4(Li.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(Li.scale(e,t,i))}scale1(e){return this.multiply4(Li.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return Li.translate(-e,-t,-i).multiply4(this).translate1(e,t,i)}setOrigin1(e){return this.setOrigin(e.x,e.y,e.z)}multiply4(e){let t=new Array(16);return Hp.mul(4,4,4,this.data,e.data,t),new Li(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new Li(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Li(e.data)}inverse(){let e=this.getInverseMatrix();return new Li(e.data)}toMatrix3(){let e=this.data;return new $t([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},Li.ORIGIN=new Li,Li);function Lu(e){return kv.normal(parseFloat(e))}var iN=[1,0,0,0,1,0,0,0,1],xi,$t=(xi=class extends Hp{static translate(e,t){return new xi([1,0,0,0,1,0,e,t,1])}static translate1(e){return this.translate(e.x,e.y)}static rotate(e){let t=Math.cos(e),i=Math.sin(e);return new xi([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate(pt.toRadians(e))}static scale(e,t=e){return new xi([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new xi([e,0,0,0,t,0,0,0,1])}static toDOMMatrix(e){let[t,i,,r,s,,n,a]=e.data;return`matrix(${[t,i,r,s,n,a].join(",")})`}static svgTrasform(e){let t=e.split(" "),i=null;return t.forEach(r=>{r=r.trim();let s=r.trim().replace(")","").split("("),n=s[0],a=s[1].split(",");switch(n){case"translate":let o=Lu(a[0]),l=Lu(a[1]);i=i?i.translate(o,l):xi.translate(o,l);break;case"rotate":let h=Lu(a[0]),c=Lu(a[1]),d=Lu(a[2]);i=i?i.setOrigin(c,d):xi.translate(c,d),i=i.rotateD(h);break;default:return}}),i}constructor(e=iN){super(3,3,e);let t=e[0],i=e[3],r=e[1],s=e[4];this.iScale=Math.sqrt(t*t+r*r),this.jScale=Math.sqrt(i*i+s*s)}isMirrored(){return this.det()<0}multiply3(e){let t=new Array(9);return Hp.mul(3,3,3,this.data,e.data,t),new xi(t)}translate(e,t){return this.multiply3(xi.translate(e,t))}translate1(e){return this.multiply3(xi.translate1(e))}scale(e,t=e){return this.multiply3(xi.scale(e,t))}scale1(e,t){return this.multiply3(xi.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new xi(e.data)}rotateD(e){return this.multiply3(xi.rotateD(e))}rotate(e){return this.multiply3(xi.rotate(e))}resetOffset(){let e=this.data;return new xi([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return xi.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new xi(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new xi(e.data)}toMatrix4(){let e=this.data;return new Uv([e[0],e[1],0,e[2],e[3],e[4],0,e[5],0,0,1,0,e[6],e[7],0,e[8]])}scaleNum(e){return!e||isNaN(e)?e:e*this.iScale}},xi.ORIGIN=new xi,xi.MIRROR_Y=new xi([1,0,0,0,-1,0,0,0,1]),xi.MIRROR_X=new xi([-1,0,0,0,1,0,0,0,1]),xi.ROT_90=new xi([0,1,0,-1,0,0,0,0,1]),xi.ROT_N90=new xi([0,-1,0,1,0,0,0,0,1]),xi),rN=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(rN||{}),Bo=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(Bo||{}),hd=class{},k0=class Fu{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return Fu.barycentre(this.p1,this.p2,this.p3)}incentre(){return Fu.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let s=t.x+i.x+r.x,n=t.y+i.y+r.y;return new ge(s/3,n/3)}static incentre(t,i,r){let s=i.sub(r).length(),n=t.sub(r).length(),a=t.sub(i).length(),o=s+n+a,l=s*t.x+n*i.x+a*r.x,h=s*t.y+n*i.y+a*r.y;return new ge(l/o,h/o)}area(){return Fu.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,s,n,a){return Math.abs(Fi.crossProd2(t,i,r,s,n,a))}scale(t,i){let r=$t.translate(-t.x,-t.y).scale(i).translate1(t),s=this.p1.multiply3(r),n=this.p2.multiply3(r),a=this.p3.multiply3(r);return new Fu(s,n,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),s=r.length(),n=ge.ORIGIN.pointOnRays2(r,s+t).length()/s;return this.scaleOnIncentre(n)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),s=t.sub(this.p1),n=i.dot(i),a=i.dot(r),o=i.dot(s),l=r.dot(r),h=r.dot(s),c=1/(n*l-a*a),d=(l*o-a*h)*c;if(d<0||d>1)return!1;let f=(n*h-a*o)*c;return f<0||f>1?!1:d+f<=1}};function pp(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var Bn=class Mo{static getMinDistanceWithoutCross(t,i){let r=pp();return Mo.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return gn(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=pp();return Mo.minLine(t,i,r),new oe(r.start,r.end)}static getMinLine(t,i){return Mo.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=pp();if(i instanceof oe)this.point2LineMinLine(r,i,t);else if(i instanceof xe)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=Mo.intersection(t,i),this.minline)this.minDistance=0;else{let r=pp();Mo.minLine(t,i,r),this.minline=new oe(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=gn(t,i);if(r===0)return;let s=new Array;for(let n=0;n<r;n+=2){let a=new ge(ee[n],ee[n+1]);s.push(a)}return s.length>1?new oe(s[0],s[1]):new oe(s[0],s[0])}static minLine(t,i,r){if(t instanceof oe&&i instanceof oe)return this.minDistanceForLines(t,i,r);if(t instanceof xe&&i instanceof oe)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof oe&&i instanceof xe)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof xe&&i instanceof xe)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((s,n)=>{n<2?this.point2LineMinLine(r,i,s):this.point2LineMinLine(r,t,s)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let s=Mo.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(s)&&this.point2ArcMinLine(r,t,s),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(Cn(t,i.center)||Cn(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let s=t.pointOn(r.angleD(t.center)),n=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,s),this.arcShortestLine(t,i,r,n)}static arcInnerLineFootSegment(t,i,r){let s=r.distance1(t.center);if(s!==0){let n=t.rx*(r.y-t.center.y)/s+t.center.y,a=t.rx*(r.x-t.center.x)/s+t.center.x;s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=new ge(a,n),i.end=r)}else s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let s=t.center.angleD(i.center),n=i.center.angleD(t.center),a=t.pointOn(s),o=t.pointOn(n),l=i.pointOn(s),h=i.pointOn(n);Cn(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,h)),Cn(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,h)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let s=i.start().sub(t.center).normalize(),n=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(s.mul(t.rx)),h=t.center.add(n.mul(t.rx)),c=i.center.add(a.mul(i.rx)),d=i.center.add(o.mul(i.rx));Cn(t,l)&&we.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Cn(t,h)&&we.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),h),Cn(i,c)&&we.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),c),Cn(i,d)&&we.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),d)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let s=t.start().distance1(i.svgEnd);s<r.minDistance&&(r.minDistance=s,r.start=t.start(),r.end=i.svgEnd),s=i.start().distance1(t.svgEnd),s<r.minDistance&&(r.minDistance=s,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(Cn(i,t)){let s=i.pointOn(t.angleD(i.center)),n=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,s),this.arcShortestLine(i,r,t,n)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(Cn(i,r)){let s=r.distance1(i.center);s>i.rx||s>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let s=Mo.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(s)?this.minLineSegment(t,s,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let s=i.distance1(r);s<t.minDistance&&(t.minDistance=s,t.start=i,t.end=r)}static arcShortestLine(t,i,r,s){if(!Cn(t,s))return;let n=r.distance1(s);n<i.minDistance&&(i.minDistance=n,i.start=r,i.end=s)}static foot(t,i){if(t.isPoint())return t.start();if(!we.eq(t.b,0)&&!we.eq(t.a,0)){let r=t.start(),s=t.direct,n=(i.x-r.x)*s.x+(i.y-r.y)*s.y;return new ge(r.x+s.x*n,r.y+s.y*n)}else return we.eq(t.b,0)&&!we.eq(t.a,0)?new ge(t.start().x,i.y):!we.eq(t.b,0)&&we.eq(t.a,0)?new ge(i.x,t.start().y):i}};function Cn(e,t){if(we.eq(e.sweepAngle,360))return!0;let i=pt.regularD(t.angleD(e.center));return e.sweepAngle>0?(we.less(i,e.startAngle)&&(i+=360),we.greatereq(e.endAngle(),i)):(we.greater(i,e.startAngle)&&(i-=360),we.lesseq(e.endAngle(),i))}var sN=[1,10,100,1e3],L2="http://www.w3.org/2000/svg",D2="http://www.w3.org/1999/xlink",R2="http://www.w3.org/XML/1998/namespace",N2="https://easyeda.com/",dZ=(function(){var e={svg:L2,xlink:D2,xml:R2,c:N2};return e[L2]="svg",e[D2]="xlink",e[R2]="xml",e[N2]="c",e})(),Ki=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),fZ=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var s=[16,19,3,7,5,1],n=21;n<52;n++)s.push(n+32,n);return s.push(2,6,8,4,17),s})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Cr=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),pZ=(function(){var e=[],t=[];for(var i in Ki)if(Ki.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(Ki[i])}e.sort(),t.sort();var r={},s,n={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case Ki.TOPLAYER:s={name:Cr[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Ki.BOTTOMLAYER:s={name:Cr[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Ki.TOPSILKLAYER:s={name:Cr[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Ki.BOTTOMSILKLAYER:s={name:Cr[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Ki.TOPPASTERLAYER:s={name:Cr[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Ki.BOTTOMPASTERLAYER:s={name:Cr[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Ki.TOPSOLDERLAYER:s={name:Cr[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Ki.BOTTOMSOLDERLAYER:s={name:Cr[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Ki.RATLINES:s={name:Cr[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Ki.BOARDOUTLINE:s={name:Cr[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Ki.ALL:s={name:Cr[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Ki.DOCUMENT:s={name:Cr[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Ki.TOPASSEMBLY:s={name:Cr[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Ki.BOTTOMASSEMBLY:s={name:Cr[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Ki.MECHANICAL:s={name:Cr[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Ki.MODEL3D:s={name:Cr[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Ki.LIBBODY:s={name:Cr[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Ki.PADSURFACE:s={name:Cr[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Ki.INNER1&&o<=Ki.INNER32?s={name:Cr[o],color:n[o],darkColor:a(n[o]),visible:!1,active:!1,config:!1}:s=null;break}s&&(r[o]=s)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),h=.5,c=Math.min(255,Math.round((l>>16)*h)),d=Math.min(255,Math.round((l>>8&255)*h)),f=Math.min(255,Math.round((l&255)*h)),u=((c<<16)+(d<<8)+f).toString(16);return"#"+("00000"+u).substr(-6).toUpperCase()}return r})(),M2={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},gZ=(function(){var e={};for(let t in M2)e[M2[t]]=t;return e})(),cg=Math.PI*2,jp=Math.PI/2,_Z=Math.sin(Math.PI/180);function nN(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=sN[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}function Gv(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function aN(e,t,i){var r=c(e)&&c(t)&&c(i);if(!r)return console.warn("Bad arguments"),null;var s=t.x-i.x>0?t.x:i.x,n=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,h=e.y;return l<=s+.001&&l>=a-.001&&h<=n+.001&&h>=o-.001;function c(d){return d?(d.x=Number(d.x),d.y=Number(d.y),isNaN(d.x)||isNaN(d.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function oN(e,t,i,r,s,n){var a=(s-i)*(e-i)+(n-r)*(t-r),o=(s-i)*(s-i)+(n-r)*(n-r),l=a/o,h=i+(s-i)*l,c=r+(n-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-s)*(e-s)+(t-n)*(t-n)):Math.sqrt((e-h)*(e-h)+(c-t)*(c-t))}function lN(e,t,i){return aN(e,t,i)?Gv((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var Uu=1e-4,ee=new Float64Array(100);function gn(e,t){if(e instanceof oe&&t instanceof oe)return pa(e,t);if(e instanceof xe&&t instanceof oe)return F0(e,t);if(e instanceof oe&&t instanceof xe)return F0(t,e);if(e instanceof xe&&t instanceof xe)return Hv(e,t);if(e instanceof Ve&&t instanceof Ve)return Ap(e,t);if(e instanceof Ve&&t instanceof oe)return Ap(e,new Ve([t.start(),t.end()]));if(e instanceof oe&&t instanceof Ve)return Ap(new Ve([e.start(),e.end()]),t);if(e instanceof Ve&&t instanceof xe)return H2(t,e);if(e instanceof xe&&t instanceof Ve)return H2(e,t);throw new Error("not supported operation")}function hN(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new oe(new ge(i.minX-1,t),new ge(i.maxX+1,t));return pa(r,e)>0?1:0}else return 0}function cN(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new oe(new ge(i.minX-1,t),new ge(i.maxX+1,t));return Vp(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function B2(e,t){let i=e.bbox();return i.isContainsY1(t)&&Ap(new Ve([new ge(i.minX-1,t),new ge(i.maxX+1,t)]),e)>0?1:0}function k2(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function uN(e,t){let i=t.length(),r=Fi.crossProd3(t.start(),t.end(),e.start())/i,s=Fi.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(s)<1e-8||r*s<0}function pa(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return ee[0]=r.x,ee[1]=r.y,2}else return F2(t,e,i);else{if(t.isPoint())return F2(e,t,i);{let r=function(O,b){i.isContains2(O,b)&&(ee[m++]=O,ee[m++]=b)};if(!uN(e,t))return 0;let s=e.start().x,n=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,h=t.start().y,c=t.end().x,d=t.end().y,f=t.length(),u=Fi.crossProd2(s,n,l,h,c,d)/f,p=Fi.crossProd2(a,o,l,h,c,d)/f;if(u*p>0&&!we.eq(u,0)&&!we.eq(p,0))return 0;let g=e.length(),_=Fi.crossProd2(l,h,s,n,a,o)/g,y=Fi.crossProd2(c,d,s,n,a,o)/g;if(_*y>0&&!we.eq(_,0)&&!we.eq(y,0))return 0;let m=0;if(we.eq(u,0)&&we.eq(p,0)){let O=i.UL(),b=i.UR(),v=i.LL(),E=i.LR();if(we.eq(i.width(),0))we.eq(i.height(),0)?(ee[m++]=O.x,ee[m++]=O.y):(ee[m++]=O.x,ee[m++]=O.y,ee[m++]=v.x,ee[m++]=v.y);else if(we.eq(i.height(),0))ee[m++]=O.x,ee[m++]=O.y,ee[m++]=b.x,ee[m++]=b.y;else{let T=k0.area2(O.x,O.y,l,h,c,d),P=k0.area2(b.x,b.y,l,h,c,d);T<P?(ee[m++]=O.x,ee[m++]=O.y,ee[m++]=E.x,ee[m++]=E.y):(ee[m++]=b.x,ee[m++]=b.y,ee[m++]=v.x,ee[m++]=v.y)}}else if(we.eq(u,0))r(s,n);else if(we.eq(p,0))r(a,o);else{let O=Math.abs(u/(u-p));r(s+(a-s)*O,n+(o-n)*O)}return m}}}function F2(e,t,i){let r=t.start(),s=t.end(),n=Fi.crossProd3(e.start(),e.end(),t.start()),a=Fi.crossProd3(e.start(),e.end(),t.end());if(n*a<0){let o=i.center();return ee[0]=o.x,ee[1]=o.y,2}else if(Math.abs(n)<Math.abs(a)){if(we.eq(n/e.length(),0))return ee[0]=r.x,ee[1]=r.y,2}else if(we.eq(a/e.length(),0))return ee[0]=s.x,ee[1]=s.y,2;return 0}function Vp(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(Uu);let r=e.center.x,s=e.center.y,n=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,h=t.end().x,c=t.end().y,d=e.center.distance1(t.start()),f=e.center.distance1(t.end()),u=we.eq(d,n)?0:d>n?1:-1,p=we.eq(f,n)?0:f>n?1:-1,g=0;if(u===-1&&p===-1)return 0;if(u===0&&p===0)ee[g++]=o,ee[g++]=l,ee[g++]=h,ee[g++]=c;else if(u===1&&p===1){let _=Bn.foot(t,e.center),y=_.distance1(e.center);if(we.greater(y,n))return 0;if(we.eq(y,n))we.eq(t.distance2(e.start()),0)?(ee[g++]=e.start().x,ee[g++]=e.start().y,ee[g++]=e.start().x,ee[g++]=e.start().y):we.eq(t.distance2(e.end()),0)?(ee[g++]=e.end().x,ee[g++]=e.end().y,ee[g++]=e.end().x,ee[g++]=e.end().y):(ee[g++]=_.x,ee[g++]=_.y,ee[g++]=_.x,ee[g++]=_.y);else{g=zv(r,s,o,l,h,c,g,_);let m=ee[g-2],O=ee[g-1];g-=2;let b=Fi.distance1(r,s,m,O);if(we.eq(b,n))ee[g++]=m,ee[g++]=O,ee[g++]=m,ee[g++]=O;else if(b<n)g=zr(a,r,s,o,l,m,O,g),g=zr(a,r,s,m,O,h,c,g);else return 0}}else if(u===-1||p===-1)g=zr(a,r,s,o,l,h,c,g);else{let _=Bn.foot(t,e.center),y=_.distance1(e.center);if(we.eq(y,n)){let m=function(v){return k2(i,v.x,v.y)&&Yi(e,v)},O=e.start(),b=e.end();if(u===0){let v=t.start();if(m(v))return ee[g++]=v.x,ee[g++]=v.y,ee[g++]=v.x,ee[g++]=v.y,g;if(m(_))return ee[g++]=_.x,ee[g++]=_.y,ee[g++]=_.x,ee[g++]=_.y,g;if(we.eq(t.distance2(O),0)&&m(O))return ee[g++]=O.x,ee[g++]=O.y,ee[g++]=O.x,ee[g++]=O.y,g;if(we.eq(t.distance2(b),0)&&m(b))return ee[g++]=b.x,ee[g++]=b.y,ee[g++]=b.x,ee[g++]=b.y,g;if(d<=n)g=zr(a,r,s,_.x,_.y,h,c,g),g===2&&(ee[g++]=ee[0],ee[g++]=ee[1]);else if(y<n){if(g=zr(a,r,s,_.x,_.y,h,c,g),g===2&&m(new ge(ee[0],ee[1])))return ee[g++]=ee[0],ee[g++]=ee[1],g;g=zr(a,r,s,_.x,_.y,o,l,0),g===2&&(ee[g++]=ee[0],ee[g++]=ee[1])}}else{let v=t.end();if(m(v))return ee[g++]=v.x,ee[g++]=v.y,ee[g++]=v.x,ee[g++]=v.y,g;if(m(_))return ee[g++]=_.x,ee[g++]=_.y,ee[g++]=_.x,ee[g++]=_.y,g;if(we.eq(t.distance2(O),0)&&m(O))return ee[g++]=O.x,ee[g++]=O.y,ee[g++]=O.x,ee[g++]=O.y,g;if(we.eq(t.distance2(b),0)&&m(b))return ee[g++]=b.x,ee[g++]=b.y,ee[g++]=b.x,ee[g++]=b.y,g;if(f<=n)g=zr(a,r,s,_.x,_.y,o,l,g),g===2&&(ee[g++]=ee[0],ee[g++]=ee[1]);else if(y<n){if(g=zr(a,r,s,_.x,_.y,o,l,g),g===2&&m(new ge(ee[0],ee[1])))return ee[g++]=ee[0],ee[g++]=ee[1],g;g=zr(a,r,s,_.x,_.y,h,c,0),g===2&&(ee[g++]=ee[0],ee[g++]=ee[1])}}}else if(u===0){let m=t.start();ee[g++]=m.x,ee[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=zr(a,r,s,_.x,_.y,h,c,g))}else{let m=t.end();ee[g++]=m.x,ee[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=zr(a,r,s,_.x,_.y,o,l,g))}}if(g>0){let _=0;for(let y=0;y<g;y+=2){let m=ee[y],O=ee[y+1];isFinite(m)&&isFinite(O)&&k2(i,m,O)&&Yi(e,new ge(m,O))&&(ee[_++]=m,ee[_++]=O)}return _}else return 0}else return 0}function dN(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,s=e.rx2,n=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,h=e.center.distance2(t.start()),c=e.center.distance2(t.end()),d=we.eq(h,s)?0:h>s?1:-1,f=we.eq(c,s)?0:c>s?1:-1,u=0;if(d===-1&&f===-1)return 0;if(d===0&&f===0)ee[u++]=n,ee[u++]=a,ee[u++]=o,ee[u++]=l;else if(d===1&&f===1){let p=Bn.foot(t,e.center),g=p.distance2(e.center);if(we.greater(g,s))return 0;if(we.eq(g,s)){let _=p.distance2(e.start()),y=p.distance2(e.end());we.eq(_,0)?(ee[u++]=e.start().x,ee[u++]=e.start().y):we.eq(y,0)?(ee[u++]=e.end().x,ee[u++]=e.end().y):(ee[u++]=p.x,ee[u++]=p.y)}else{u=zv(i,r,n,a,o,l,u,p);let _=ee[u-2],y=ee[u-1],m=Fi.distance2(i,r,_,y);if(u-=2,we.eq(m,s))ee[u++]=_,ee[u++]=y;else if(m<s)u=zr(s,i,r,n,a,_,y,u),u=zr(s,i,r,_,y,o,l,u);else return 0}}else if(d===-1||f===-1)u=zr(s,i,r,n,a,o,l,u);else{let p=Bn.foot(t,e.center);d===0?(ee[u++]=t.start().x,ee[u++]=t.start().y,we.neq(p.distance2(t.start()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=zr(s,i,r,p.x,p.y,o,l,u))):(ee[u++]=t.end().x,ee[u++]=t.end().y,we.neq(p.distance2(t.end()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=zr(s,i,r,p.x,p.y,n,a,u)))}if(u>0){let p=0;for(let g=0;g<u;g+=2){let _=ee[g],y=ee[g+1];isFinite(_)&&isFinite(y)&&(ee[p++]=_,ee[p++]=y)}return p}else return 0}else return 0}function zr(e,t,i,r,s,n,a,o){if(s==a){let O=e-(s-i)*(s-i);if(we.greater(O,0)){let b=Math.sqrt(O),v=t-b,E=t+b,T=Math.min(r,n),P=Math.max(r,n);return v>=T&&v<=P&&(ee[o++]=v,ee[o++]=s),E>=T&&E<=P&&(ee[o++]=E,ee[o++]=s),o}}let l=Fi.distance2(r,s,t,i)-e;if(l===0)return ee[o++]=r,ee[o++]=s,o;let h=Fi.distance2(n,a,t,i)-e;if(h===0)return ee[o++]=n,ee[o++]=a,o;let c=r,d=s,f=n,u=a,p=NaN,g=NaN,_=Number.POSITIVE_INFINITY,y=0;for(;_!==0;){y++;let O=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(h)),.75),.25);if(p=c+(f-c)*O,g=d+(u-d)*O,c===p&&d===g||f===p&&u===g){Math.abs(l)>Math.abs(h)?(p=f,g=u,_=h):(p=c,g=d,_=l);break}else _=Fi.distance2(p,g,t,i)-e,_<0&&l>h||_>0&&l<h?(f=p,u=g,h=_):(c=p,d=g,l=_)}let m=Math.sqrt(e)-Fi.distance1(p,g,t,i);return(we.eq(0,_)||we.eq(0,m))&&(ee[o++]=p,ee[o++]=g),o}function zv(e,t,i,r,s,n,a,o){let l=Fi.dotProd2(i,r,s,n,e,t),h=Fi.dotProd2(s,n,i,r,e,t);if(l>=0)return ee[a++]=s,ee[a++]=n,a;if(h>=0)return ee[a++]=i,ee[a++]=r,a;if(Fi.crossProd2(i,r,s,n,e,t)==0)return ee[a++]=e,ee[a++]=t,a;{let c=NaN,d=NaN,f=i,u=r,p=s,g=n,_=Fi.distance2(i,r,e,t),y=Fi.distance2(s,n,e,t),m=Number.POSITIVE_INFINITY,O=0;for(;m>0&&(O++,c=f+(p-f)*.5,d=u+(g-u)*.5,!(_==y||f==c&&u==d||p==c&&g==d));){m=Fi.distance2(c,d,e,t);let b=Fi.dotProd2(f,u,c,d,e,t);if(b==0)break;b<0?(p=c,g=d,y=m):(f=c,u=d,_=m)}return Fi.distance2(c,d,e,t)<Fi.distance2(o.x,o.y,e,t)?(ee[a++]=c,ee[a++]=d):(ee[a++]=o.x,ee[a++]=o.y),a}}function F0(e,t){if(e.rx===e.ry)return Vp(e,t);throw new Error("not supported")}function fN(e,t){if(e.rx===e.ry)return dN(e,t);throw new Error("not supported")}function Hv(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return pN(e,t);throw new Error("not supported operation")}return 0}function pN(e,t){let i=e.center.x,r=e.center.y,s=t.center.x,n=t.center.y,a=e.rx,o=t.rx,l=e.rx2,h=t.rx2,c=e.center.distance1(t.center),d=Math.abs(a-o),f=a+o;if(we.greater(c,f)||we.less(c,d))return 0;if(we.eq(d+c,0)){let u=0,p;return Yi(e,t.start())&&(ee[u]=t.start().x,ee[u+1]=t.start().y,u+=2,p=t.start()),Yi(e,t.end())&&(ee[u]=t.end().x,ee[u+1]=t.end().y,u+=2,p=t.end()),u===0?(Yi(t,e.start())&&(ee[u]=e.start().x,ee[u+1]=e.start().y,u+=2),Yi(t,e.end())&&(ee[u]=e.end().x,ee[u+1]=e.end().y,u+=2)):u===2&&(!p.equals1(e.start())&&Yi(t,e.start())&&(ee[u]=e.start().x,ee[u+1]=e.start().y,u+=2),!p.equals1(e.end())&&Yi(t,e.end())&&(ee[u]=e.end().x,ee[u+1]=e.end().y,u+=2)),u}else if(we.eq(c,f)){if(U2(e,t))return 4;let u=new oe(e.center,t.center),p=Vp(t,u);return p=G2(e,p),p!==0?p:(p=Vp(e,u),G2(t,p))}else if(we.eq(c,d)){if(U2(e,t))return 4;if(a>o){let u=(a-o)/a;return ee[0]=i+(s-i)/u,ee[1]=r+(n-r)/u,z2(e,t,2)}else{let u=(o-a)/o;return ee[0]=s+(i-s)/u,ee[1]=n+(r-n)/u,z2(e,t,2)}}else{let u=(e.center.distance2(t.center)-h+l)/(c*2)/c,p=(s-i)*u+i,g=(n-r)*u+r,_=s-i,y=n-r,m=Math.max(a,o),O,b,v,E;if(Math.abs(_)<Math.abs(y)){let C=_/-y,M=g-C*p;O=p-m,b=C*O+M,v=p+m,E=C*v+M}else{let C=y/-_,M=p-C*g;b=g-m,O=C*b+M,E=g+m,v=C*E+M}let T=zr(l,i,r,O,b,p,g,0);if(T=zr(l,i,r,p,g,v,E,T),T!==4)throw new Error("cnt !== 4");let P=new ge(ee[0],ee[1]),A=new ge(ee[2],ee[3]);if(Yi(e,P)&&Yi(t,P))return Yi(e,A)&&Yi(t,A)?4:Do(e.start(),t,A,P)?(ee[2]=e.start().x,ee[3]=e.start().y,4):Do(e.end(),t,A,P)?(ee[2]=e.end().x,ee[3]=e.end().y,4):Do(t.start(),e,A,P)?(ee[2]=t.start().x,ee[3]=t.start().y,4):Do(t.end(),e,A,P)?(ee[2]=t.end().x,ee[3]=t.end().y,4):2;if(Yi(e,A)&&Yi(t,A))return Do(e.start(),t,P,A)?(ee[0]=e.start().x,ee[1]=e.start().y,4):Do(e.end(),t,P,A)?(ee[0]=e.end().x,ee[1]=e.end().y,4):Do(t.start(),e,P,A)?(ee[0]=t.start().x,ee[1]=t.start().y,4):Do(t.end(),e,P,A)?(ee[0]=t.end().x,ee[1]=t.end().y,4):(ee[0]=ee[2],ee[1]=ee[3],2);{let C=function(F,j){if(we.eq(F.distance1(j.center),j.rx)&&Yi(j,F)){if(F.distance2(P)<F.distance2(A)){if(M)return;M=!0}else{if(H)return;H=!0}ee[k++]=F.x,ee[k++]=F.y}},M=!1,H=!1,k=0;return C(e.start(),t),C(e.end(),t),C(t.start(),e),C(t.end(),e),k}}}function Do(e,t,i,r){return we.eq(e.distance1(t.center),t.rx)&&Yi(t,e)&&e.distance2(i)<e.distance2(r)}function U2(e,t){return we.eq(t.start().distance1(e.center),e.rx)&&Yi(e,t.start())?(ee[0]=t.start().x,ee[1]=t.start().y,ee[2]=t.start().x,ee[3]=t.start().y,!0):we.eq(t.end().distance1(e.center),e.rx)&&Yi(e,t.end())?(ee[0]=t.end().x,ee[1]=t.end().y,ee[2]=t.end().x,ee[3]=t.end().y,!0):we.eq(e.start().distance1(t.center),t.rx)&&Yi(t,e.start())?(ee[0]=e.start().x,ee[1]=e.start().y,ee[2]=e.start().x,ee[3]=e.start().y,!0):we.eq(e.end().distance1(t.center),t.rx)&&Yi(t,e.end())?(ee[0]=e.end().x,ee[1]=e.end().y,ee[2]=e.end().x,ee[3]=e.end().y,!0):!1}function G2(e,t){if(t===0)return 0;let i=ee[0],r=ee[1];return Yi(e,new ge(i,r))?(ee[0]=i,ee[1]=r,ee[2]=i,ee[3]=r,4):0}function z2(e,t,i){if(i===0)return 0;let r=ee[0],s=ee[1],n=new ge(r,s);return Yi(e,n)&&Yi(t,n)?(ee[0]=r,ee[1]=s,ee[2]=r,ee[3]=s,4):0}function Ah(e,t){return Math.abs(e-t)<=1e-6}function Yi(e,t){let i=e.bbox();if(t.x-i.minX>-Uu&&t.x-i.maxX<Uu&&t.y-i.minY>-Uu&&t.y-i.maxY<Uu){let r=pt.regularD(t.angleD(e.center));return Ah(r,e.startAngle)||Ah(r,e.startAngle+360)||Ah(r,e.startAngle-360)||Ah(r,e.endAngle())||Ah(r,e.endAngle()+360)||Ah(r,e.endAngle()-360)?!0:e.sweepAngle>0?(we.less(r,e.startAngle)&&(r+=360),we.greatereq(e.endAngle(),r)):(we.greater(r,e.startAngle)&&(r-=360),we.lesseq(e.endAngle(),r))}else return!1}function gN(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,s=t[1].x-t[0].x,n=t[1].y-t[0].y;if(i===0&&s!==0||i!==0&&s===0)return!1;if(i===0&&s===0)return!0;let a=r/i,o=n/s;return Gv(a,o,Math.sin(Math.PI/180))}function _N(e,t,i){var r,s=+t.x,n=+t.y,a=+i.x,o=+i.y,l=+e.x,h=+e.y,c=a-s,d=o-n,f=l-s,u=h-n,p,g,_,y,m,O;return c===0&&d===0?{d:Math.sqrt(f*f+u*u),point:new ge(s,n)}:(r=(f*c+u*d)/(c*c+d*d),r<0?{d:Math.sqrt(f*f+u*u),point:new ge(s,n)}:r>1?(p=l-a,g=h-o,{d:Math.sqrt(p*p+g*g),point:new ge(a,o)}):(m=s+r*c,O=n+r*d,_=l-m,y=h-O,{d:Math.sqrt(_*_+y*y),point:new ge(m,O)}))}function Nn(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,s)=>{let n=t[s],a=!1;return r&&n&&typeof r=="object"&&typeof n=="object"?typeof r[i]=="function"&&mN(r,n)?a=!r[i].call(r,n):a=!(r===n||r.toString()===n.toString()):typeof r=="number"&&typeof n=="number"?a=!(ON(r,n)||Number.isNaN(r)&&Number.isNaN(n)):a=r!==n,a})}function ON(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function mN(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var Et=new Float64Array(100);function Ap(e,t){if(e.bbox().extendOfSize(we.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=pa(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a(ee[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(we.eq(Et[L],Et[R])&&we.eq(Et[L+1],Et[R+1])){Et[R]=(Et[L]+Et[R])/2,Et[R+1]=(Et[L+1]+Et[R+1])/2;for(let x=s-3;x>=L;x--)Et[x]=Et[x+2];s-=2;break}if(s>r){s=0;let L=t.start(),R=new Float64Array(8);e.getPercent(L)!==null&&(R[s++]=L.x,R[s++]=L.y);let x=t.end();e.getPercent(x)!==null&&(R[s++]=x.x,R[s++]=x.y);let I=e.start();t.getPercent(I)!==null&&(R[s++]=I.x,R[s++]=I.y);let S=e.end();return t.getPercent(S)!==null&&(R[s++]=S.x,R[s++]=S.y),ee.set(R),s}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=pa(new oe(c[0],c[1]),new oe(d[0],d[1]));for(let R=0;R<L;R++)Et[s++]=ee[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),we.eq(m,O)){if(h.controls.length===2){let L=pa(new oe(l.start(),l.end()),new oe(h.start(),h.end()));for(let R=0;R<L;R++)Et[s++]=ee[R];if(L!==0)continue}l=new Ve([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(we.less(L,m))v=v|1;else if(we.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(we.less(R,E))v=v|1;else if(we.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=we.eps&&(n=we.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new oe(new ge(0,m),new ge(1,m)),F=new oe(new ge(0,O),new ge(1,O));for(let L=0;L<b.length-1;L++){let R=new ge(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new ge(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new oe(R,S),k),o(new oe(R,S),F)):o(new oe(R,S),k):x===2?D===1?(o(new oe(R,S),k),o(new oe(R,S),F)):o(new oe(R,S),F):D===1?o(new oe(R,S),k):o(new oe(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(we.eq(j.minX,j.maxX)&&we.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(we.less(R,E))v=v|1;else if(we.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new ge((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(Et[s++]=L.x,Et[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)ee[a]=Et[a];return s}function bN(e,t){if(e.bbox().extendOfSize(we.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=pa(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a(ee[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(we.eq(Et[L],Et[R])&&we.eq(Et[L+1],Et[R+1])){Et[R]=(Et[L]+Et[R])/2,Et[R+1]=(Et[L+1]+Et[R+1])/2;for(let x=s-3;x>=L;x--)Et[x]=Et[x+2];s-=2;break}if(s>r){s=0;let L=new Float64Array(8),R=t.end(),x=0;e.getPercent(R)!==null&&(L[s++]=R.x,L[s++]=R.y,x=2);let I=e.end();return t.getPercent(I)!==null&&(L[s++]=I.x,L[s++]=I.y,x=x===0?1:3),ee.set(L),{havOverlap:x,cnt:s}}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=pa(new oe(c[0],c[1]),new oe(d[0],d[1]));for(let R=0;R<L;R++)Et[s++]=ee[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),we.eq(m,O)){if(h.controls.length===2){let L=pa(new oe(l.start(),l.end()),new oe(h.start(),h.end()));for(let R=0;R<L;R++)Et[s++]=ee[R];if(L!==0)continue}l=new Ve([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(we.less(L,m))v=v|1;else if(we.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(we.less(R,E))v=v|1;else if(we.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=we.eps&&(n=we.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new oe(new ge(0,m),new ge(1,m)),F=new oe(new ge(0,O),new ge(1,O));for(let L=0;L<b.length-1;L++){let R=new ge(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new ge(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new oe(R,S),k),o(new oe(R,S),F)):o(new oe(R,S),k):x===2?D===1?(o(new oe(R,S),k),o(new oe(R,S),F)):o(new oe(R,S),F):D===1?o(new oe(R,S),k):o(new oe(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(we.eq(j.minX,j.maxX)&&we.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(we.less(R,E))v=v|1;else if(we.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new ge((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(Et[s++]=L.x,Et[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)ee[a]=Et[a];return{cnt:s}}var yN=class{constructor(e=we.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},Du=new yN;function H2(e,t){if(e.bbox().extendOfSize(we.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,s=0;for(;i.length!==0;){if(s>r){let a=function(){for(let h=0;h<s;h+=2)for(let c=h+2;c<s;c+=2)if(!(Du.eq(Et[h],Et[c])&&Du.eq(Et[h+1],Et[c+1]))){l(Et[c],Et[c+1],o);break}function l(h,c,d){let f=!1;for(let u=0;u<d.length;u+=2)if(Du.eq(h,d[u])&&Du.eq(c,d[u+1])){f=!0;break}f||d.push(h,c)}},o=[Et[0],Et[1]];if(a(),o.length>=100&&(Du.setEps(.001),o=[Et[0],Et[1]],a(),o.length>=100))throw new Error("clearSamePoint()");s=o.length,o.forEach((l,h)=>Et[h]=l)}let n=i.pop();if(n[0]instanceof xe){let a=function(F){A=Math.min(A,F),C=Math.max(C,F)},o=function(F,j){let L=pa(F,j);if(L===0)throw new Error("cnt === 0");for(let R=0;R<L;R+=2)a(ee[R])},[l,h]=n,c=h.controls;if(c.length===2){let F=F0(l,new oe(c[0],c[1]));for(let j=0;j<F;j++)Et[s++]=ee[j];continue}let d=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,u,p,g,_,y;if(Math.abs(l.sweepAngle)>359){let F=l.rx;u=l.center.add1(F,0),p=l.center.add1(-F,0),d=-F,f=F,g=0,_=1,y=-l.center.y}else{u=l.start(),p=l.end(),g=p.y-u.y,_=u.x-p.x,y=-g*u.x-_*u.y;let F=Math.sqrt(1/(g**2+_**2));g*=F,_*=F,y*=F;let j=g*l.center.x+_*l.center.y+y;l.isCCW?(f=l.rx+j,d=0):(d=j-l.rx,f=0)}let m=c.map(F=>g*F.x+_*F.y+y),O=0;for(let F of m){if(we.less(F,d))O=O|1;else if(we.greater(F,f))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let b=0,v=0,E=p.x-u.x,T=p.y-u.y,P=Math.sqrt(1/(E**2+T**2));if(E*=P,T*=P,Math.abs(l.sweepAngle)<=180)b=0,v=(p.x-u.x)*E+(p.y-u.y)*T;else throw new Error("not support");O=0;for(let F of c){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(we.less(j,b))O=O|1;else if(we.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let A=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;d-=we.eps,f+=we.eps,m.forEach((F,j)=>{F>=d&&F<=f&&a(j/(m.length-1))});let M=new oe(new ge(0,d),new ge(1,d)),H=new oe(new ge(0,f),new ge(1,f));for(let F=0;F<m.length-1;F++){let j=new ge(F/(m.length-1),m[F]),L=j.y<d?1:j.y>f?2:3;for(let R=0;R<m.length;R++){let x=new ge(R/(m.length-1),m[R]),I=x.y<d?1:x.y>f?2:3;L!==I&&(L===1?I===2?(o(new oe(j,x),M),o(new oe(j,x),H)):o(new oe(j,x),M):L===2?I===1?(o(new oe(j,x),M),o(new oe(j,x),H)):o(new oe(j,x),H):I===1?o(new oe(j,x),M):o(new oe(j,x),H))}}A!==0&&(h=h.clip(A)[1]),C!==1&&(h=h.clip((C-A)/(1-A))[0]);let k=h.bbox();if(we.eq(k.minX,k.maxX)&&we.eq(k.minY,k.maxY)){O=0;for(let F of h.controls){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(we.less(j,b))O=O|1;else if(we.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}O===3&&(Et[s++]=(k.minX+k.maxX)/2,Et[s++]=(k.minY+k.maxY)/2);continue}C-A>.8?h.clip(.5).forEach(F=>i.push([F,l])):i.push([h,l])}else{let[a,o]=n;i.push([xe.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([xe.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let n=0;n<s;n++)ee[n]=Et[n];return s}var vN=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let n=0;n<i-1;n++){let a=e[n],o=e[n+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],s=e[i-1];return t+=(r.x+s.x)*(r.y-s.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function xN(e){let t=e.primitives,i=t[0],r=i instanceof xe?i.sweepAngle%360:null;if(t.length===1&&i instanceof xe&&(we.eq(r,0)||we.eq(Math.abs(r),360)))return!!i.isCCW;let s=new Array;return e.points(.1,n=>{s.push(n)}),vN.getSweep(s)}var EN=class{static zoomCorner(e,t){let i=new Array,r=new Array,s=new Array;return this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?Pt.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,s=new Array;return xN(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?Pt.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(Pt.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let s=e.primitives;for(let n of s){let a=this.panDistance(n,r);a!==void 0&&(t.push(a),i.push(n))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],h=a==i-1?e[0]:e[a+1];if(!(l instanceof xe&&h instanceof xe)&&!this.isCW(l.end(),h.start(),o.end())){if(gn(l,h)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let s=this.start4Index(t,r),n=this.start4Index(e,r);t.length=0,e.length=0,s.forEach(a=>{t.push(a)}),n.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],s=e[0],n=t[i-1];if(!(r instanceof xe&&s instanceof xe)&&!this.isCW(r.end(),s.start(),n.end())){let a=gn(r,s);for(let o=0;o<a;o+=2){let l=new ge(ee[o],ee[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(s,l,s.end())}}}}static getResult(e,t,i,r){let s=e.length;for(let n=0;n<s;n++){let a=t[n],o=n===s-1?t[0]:t[n+1],l=n==s-1?0:n+1,h=l==s-1?t[0]:t[l+1],c=e[n],d=n==s-1?e[0]:e[n+1],f=l==s-1?e[0]:e[l+1];if(!(c instanceof xe&&d instanceof xe)&&!this.isCW(c.end(),d.start(),a.end())){let p=this.add(e,i,n,c,d,0);p=this.update(e,i,n,d,p);let g=this.generateArc(o,h,d,f,r);if(p=this.add(e,i,n,c,g,p),p=this.update(e,i,n,g,p),p>0)continue}i.push(c);let u=this.generateArc(a,o,c,d,r);u!==void 0&&i.push(u)}}static generateArc(e,t,i,r,s){if(s>0){let n=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(n.equals(a)){let h=o.angleD(n),c=l.angleD(n);return xe.build2(n,h,c,s,s,0)}else{let h=o.angleD(n),c=l.angleD(n),d=o.angleD(a),f=l.angleD(a),u=xe.build2(n,h,c,s,s,0),p=xe.build2(a,d,f,s,s,0);return u.pointOn(u.endAngle()).equals1(l)?u:p.pointOn(p.endAngle()).equals1(l)?p:u}}}static updateNews(e,t,i,r){let s=e.length,n=t==s-1?0:t+1;e[n]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,s,n){if(n>0)return n;if(r!=null&&s!=null){let a=gn(r,s);for(let o=0;o<a;o+=2){let l=new ge(ee[o],ee[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,s,l);break}return a}else return 0}static update(e,t,i,r,s){if(s>0)return s;let n=t.length;if(n>0&&r!=null){let a=t[n-1],o=gn(a,r);for(let l=0;l<o;l+=2){let h=new ge(ee[l],ee[l+1]);t[n-1]=this.generatePrimitive(a,a.start(),h),this.updateNews(e,i,r,h)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof oe)return new oe(t,i);if(e instanceof xe){let r=e,s=t.angleD(r.center),n=i.angleD(r.center);return xe.build2(r.center,s,n,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let s=t;s<i;s++)r.push(e[s]);for(let s=0;s<t;s++)r.push(e[s]);return r}static isCW(e,t,i){let r=new oe(i,e),s=new oe(i,t),n=r.end().x-r.start().x,a=r.end().y-r.start().y,o=s.end().x-s.start().x,l=s.end().y-s.start().y;return!(n*l-a*o>0)}static panDistance(e,t){if(e instanceof oe){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof xe){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||we.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},ot=.001,ts=ot**2;function $e(e,t){return e.distance2(t)<ts}function _a(e,t){return Math.abs(e-t)<=1e-4}function wN(e,t){if(e instanceof oe)return new oe(e.start(),t);if(e instanceof xe){let i=t.angleD(e.center);return _a(pt.regularD(e.startAngle),pt.regularD(i))?xe.build3(e.center,e.startAngle,0,e.rx,e.ry):xe.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof Ve)return e.clip(e.getPercent(t,ot))[0];throw new Error("not supported operation")}}function kn(e,t=pt.toRadians(e.startAngle)){return e.isCCW?t+=jp:t-=jp,new ge(Math.cos(t),Math.sin(t))}function $u(e,t=0){let i=e.controls;if(t===0){let r=i[0],s=i.slice(1).find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return s.sub(r)}else if(t===1){let r=i[i.length-1],s=i.slice(0,-1).reverse().find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(s)}if(i.length===3){let[r,s,n]=i;return s.sub(r).mul(2*(1-t)).add(n.sub(s).mul(2*t)).normalize()}else{let[r,s,n,a]=i;return s.sub(r).mul(3*(1-t)**2).add(n.sub(s).mul(6*(1-t)*t)).add(a.sub(n).mul(3*t**2)).normalize()}}function qh(e,t,i){let r=e.slice(1).findIndex(n=>!(n.x===t.x&&n.y===t.y)),s=e[r+1];if(i&&(i.getPercent(s,ot)!==null||new oe(i.start(),i.end()).distance(s)<=ot)&&(s=e[r+2]),!s)throw Error("getSecondPoint(controls: readonly Vector2[])");return s}function at(e,t){if(e instanceof oe)return e.end().sub(e.start()).normalize();if(e instanceof xe)return(t?kn(e,t.angle(e.center)):kn(e)).normalize();if(e instanceof Ve)if(e.controls.length===2){let[i,r]=e.controls;if($e(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?$u(e,e.getPercent(t,ot)):$u(e)).normalize();else throw new Error("not support")}function TN(e,t,i){let r=[],s=t**2-4*e*i;if(s>=0){let n=-t/(2*e),a=Math.sqrt(s)/(2*e),o=n+a;if(r.push(o),s>0){let l=n-a;r.push(l)}}return r}function SN(e,t,i,r,s=0,n=1){let a=[],o=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,l=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,h,c;if(o*l<0)for(;Math.abs(s-n)>ot;)if(h=(s+n)/2,c=e*Math.pow(h,3)+t*Math.pow(h,2)+i*h+r,Math.abs(c)<ot){a.push(h);break}else o*c<0?n=h:l*c<0&&(s=h);else o*l===0&&(o===0&&a.push(s),l===0&&a.push(n));return a}function l0(e,t,i){if(e instanceof oe||t.distance2(i)<=ts)return new oe(t,i);if(e instanceof xe)return xe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ve){let r=e.getPercent(t,ot),s=e.getPercent(i,ot);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function U0(e){return we.greater(e,0)&&we.less(e,1)}function Yp(e,t,i,r){let s=e[r]-2*t[r]+i[r],n=t[r]-e[r];if(s===0)return[];let a=-n/s,o=[];return U0(a)&&o.push(a),o}function qp(e,t,i,r,s){let n,a,o=-e[s]+3*t[s]-3*i[s]+r[s],l=2*(e[s]-2*t[s]+i[s]),h=t[s]-e[s],c=l**2-4*o*h;if(we.lesseq(c,0))n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else{let f=Math.sqrt(c);n=(-l-f)/(2*o),a=(-l+f)/(2*o);let u=o*2;if(we.lesseq(n,1)&&we.greatereq(n,0)){let p=Number.NEGATIVE_INFINITY;for(;we.neq(n,p);){p=n;let g=u*n+l;n=-(o*n**2+l*n+h-g*n)/g}}if(we.lesseq(a,1)&&we.greatereq(a,0)){let p=Number.NEGATIVE_INFINITY;for(;we.neq(a,p);){p=a;let g=u*a+l;a=-(o*a**2+l*a+h-g*a)/g}}}let d=[];return U0(a)&&d.push(a),U0(n)&&d.push(n),d}function jv(e,t){if(e.controls.length===2){let[o,l]=e.controls;$e(o,l)||t.push(new oe(o,l));return}let i,r;if(e.controls.length===3){let[o,l,h]=e.controls;i=Yp(o,l,h,"x"),r=Yp(o,l,h,"y")}else{let[o,l,h,c]=e.controls;i=qp(o,l,h,c,"x"),r=qp(o,l,h,c,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let s=i.pop()||1,n=r.pop()||1,a=0;for(;s!==1||n!==1;)if(we.eq(s,n))s=i.pop()||1,n=r.pop()||1;else if(s<n){let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=i.pop()||1}else{let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=r.pop()||1}t.push(e)}var IN=1e-5,_m=1,Ve=class gs extends hd{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new oe(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return Zh(t,(r,s)=>(i.push(s),!0)),new gs(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let s=1;s<i.length;s++){let n=i[s-1],a=i[s],o=(a.x-n.x)*t,l=(a.y-n.y)*t;r[s-1]=n.add1(o,l)}return gs.pointOn(t,r)}}clip1(t,i,r,s){if(r.push(i[0]),s.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let n=i[0],a=i[1],o=(a.x-n.x)*t,l=(a.y-n.y)*t,h=n.add1(o,l);r.push(h),s.push(h)}else{let n=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],h=(l.x-o.x)*t,c=(l.y-o.y)*t;n[a-1]=o.add1(h,c)}this.clip1(t,n,r,s)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new gs(i),new gs(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=we.eps){let r=this.controls.map(n=>n.y-t.y),s=0;for(let n of r){if(this.less(n,0,i))s=s|1;else if(this.greater(n,0,i))s=s|2;else{s=3;break}if(s===3)break}if(s!==3)return!1;s=0;for(let n of this.controls){let a=n.x-t.x;if(this.less(a,0,i))s=s|1;else if(this.greater(a,0,i))s=s|2;else{s=3;break}if(s===3)break}return s===3}getPercent(t,i=we.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,s=[[this,0,1]];for(;s.length!==0;){let n=function(_){c=Math.min(c,_),d=Math.max(d,_)},a=function(_,y){let m=pa(_,y);if(m===0)throw new Error("cnt === 0");for(let O=0;O<m;O+=2)n(ee[O])},[o,l,h]=s.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return h;let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,f=o.controls.map(_=>_.y-t.y);r=f.reduce((_,y)=>{let m=Math.abs(y);return m<_?m:_},r),r/=2,r<=i&&(r=i),f.forEach((_,y)=>{this.eq(_,0,i)&&n(y/(f.length-1))});let u=new oe(new ge(0,-r),new ge(1,-r)),p=new oe(new ge(0,r),new ge(1,r));for(let _=0;_<f.length-1;_++){let y=new ge(_/(f.length-1),f[_]),m=this.less(y.y,0,i)?1:this.greater(y.y,0,i)?2:3;for(let O=0;O<f.length;O++){let b=new ge(O/(f.length-1),f[O]),v=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;m!==v&&(m===1?v===2?(a(new oe(y,b),u),a(new oe(y,b),p)):a(new oe(y,b),u):m===2?v===1?(a(new oe(y,b),u),a(new oe(y,b),p)):a(new oe(y,b),p):v===1?a(new oe(y,b),u):a(new oe(y,b),p))}}if(!isFinite(c)){if(Math.max(...f.map(_=>Math.abs(_)))<i*4)return(l+h)/2;continue}if(c!==0&&(o=o.clip(c)[1],l=(h-l)*c+l),d!==1){let _=(d-c)/(1-c);o=o.clip(_)[0],h=(h-l)*_+l}if(!o.isInRange(t,i))continue;let g=o.controls.reduce((_,y)=>_.ext2(y),new Cs).build1();if(this.eq(g.minX,g.maxX,i)&&this.eq(g.minY,g.maxY,i))return(l+h)/2;if(d-c>.8){let[_,y]=o.clip(.5);_.isInRange(t,i)?(s.push([_,l,(l+h)/2]),y.isInRange(t,i)&&s.push([y,(l+h)/2,h])):s.push([y,(l+h)/2,h])}else s.push([o,l,h])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new Cs().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new Cs().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let s=this.controls[r];i[r]=s.multiply3(t)}return new gs(i)}stroke(t,i,r,s=_m){let n=EN.zoomLines(Pt.build4(this.points(s)),t);return r===0?n:n.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let n=r.pop(),a=new oe(n.start(),n.end());if(s(n.controls,a)<=t)i(n.end());else{let[o,l]=n.clip(.5);r.push(l,o)}}function s(n,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let h=l.y-o.y,c=o.x-l.x,d=-h*o.x-c*o.y,f=Math.sqrt(1/(h**2+c**2));h*=f,c*=f,d*=f;let u=n.map(p=>Math.abs(h*p.x+c*p.y+d));return Math.max(...u)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,s=this.controls[0],n=.5;for(;n>IN&&!(s.distance2(gs.pointOn(n,this.controls))<=r);n*=.5);let a=Math.ceil(1/n);n=1/a,i(s);let o=0;for(let l=1;l<a;l++)o+=n,i(gs.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,s,n]=this.controls,a=-3*i.x+9*r.x-9*s.x+3*n.x,o=6*i.x-12*r.x+6*s.x,l=-3*i.x+3*r.x,h=[];if(Number.isFinite(t)){let c=-3*i.y+9*r.y-9*s.y+3*n.y,d=6*i.y-12*r.y+6*s.y,f=-3*i.y+3*r.y,u=c-a*t,p=d-o*t,g=f-l*t,_=-p/(2*u),y=Math.sqrt(p**2-4*u*g)/(2*u),m=_+y;m>=0&&m<=1&&h.push(gs.pointOn(m,this.controls));let O=_-y;O>=0&&O<=1&&h.push(gs.pointOn(O,this.controls))}else{let c=-o/(2*a),d=Math.sqrt(o**2-4*a*l)/(2*a),f=c+d;f>=0&&f<=1&&h.push(gs.pointOn(f,this.controls));let u=c-d;u>=0&&u<=1&&h.push(gs.pointOn(u,this.controls))}return h}buildConverxHull(t=we.eps){let i=[...this.controls],r=[],s=i[0],n=1;do{let a=i[n%i.length];this.eqPP(s,a,t)||r.push(new oe(s,a)),s=a,n++}while(s!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return Pt.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),s=r.x-i.x,n=r.y-i.y;if(Math.abs(s)<=we.eps||Math.abs(n)<=we.eps)return a(this.controls);{let o=n/s;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,h=i.x-r.x,c=-l*i.x-h*i.y,d=Math.sqrt(1/(l**2+h**2));l*=d,h*=d,c*=d;let f=this.controls.map(g=>l*g.x+h*g.y+c),u=f[0]-2*f[1]+f[2],p=f[1]-f[0]-o/2;if(u!==0){let g=-p/u;if(we.greater(g,0)&&we.less(g,1))return[gs.pointOn(g,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,h;if(o.length===3){let[u,p,g]=o;l=Yp(u,p,g,"x"),h=Yp(u,p,g,"y")}else if(o.length===4){let[u,p,g,_]=o;l=qp(u,p,g,_,"x"),h=qp(u,p,g,_,"y")}l.sort((u,p)=>p-u),h.sort((u,p)=>p-u);let c=l.pop()||1,d=h.pop()||1,f=[];for(;c!==1||d!==1;)we.eq(c,d)?(c=l.pop()||1,d=h.pop()||1):c<d?(f.push(gs.pointOn(c,o)),c=l.pop()||1):(f.push(gs.pointOn(d,o)),d=h.pop()||1);return f}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),s=t.distance2(this.end()),n=Math.max(r,s);return i.forEach(o=>a(t.distance2(o))),n;function a(o){n=Math.max(n,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let s=r.y-i.y,n=i.x-r.x,a=-s*i.x-n*i.y,o=Math.sqrt(1/(s**2+n**2));s*=o,n*=o,a*=o;let l=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY;return this.controls.forEach(c=>{let d=s*c.x+n*c.y+a;d<l&&(l=d),d>h&&(h=d)}),{minDis:l,maxDis:h}}getPercentInLine(t){let i=[],r=[],s=this.controls,n=t.start(),a=t.end(),o=a.y-n.y,l=n.x-a.x,h=-o*n.x-l*n.y,c=Math.sqrt(1/(o**2+l**2));if(o*=c,l*=c,h*=c,o**2+l**2<=0)return i;if(s.length===3){let[d,f,u]=s,p=o*(d.x-2*f.x+u.x)+l*(d.y-2*f.y+u.y),g=2*(o*(f.x-d.x)+l*(f.y-d.y)),_=o*d.x+l*d.y+h;r=TN(p,g,_)}else if(s.length===4){let[d,f,u,p]=s,g=p.sub(u.mul(3)).add(f.mul(3)).sub(d),_=d.sub(f.mul(2)).add(u).mul(3),y=f.sub(d).mul(3),m=d,O=o*g.x+l*g.y,b=o*_.x+l*_.y,v=o*y.x+l*y.y,E=o*m.x+l*m.y+h,T=Math.sqrt(1/(O**2+b**2));O*=T,b*=T,v*=T,E*=T,r=SN(O,b,v,E)}else throw Error("not support getBeizerPointInLine");return r.forEach(d=>{d>=0&&d<=1&&i.push(d)}),i}reverse(){return new gs(this.controls.slice().reverse())}},Sl,Vv=(Sl=class{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=ge.ORIGIN,this.textOffsetCache[1]=new ge(0,-.5),this.textOffsetCache[2]=new ge(0,-1),this.textOffsetCache[3]=new ge(-.5,0),this.textOffsetCache[4]=new ge(-.5,-.5),this.textOffsetCache[5]=new ge(-.5,-1),this.textOffsetCache[6]=new ge(-1,0),this.textOffsetCache[7]=new ge(-1,-.5),this.textOffsetCache[8]=new ge(-1,-1)}static getCache(){return Sl.instance==null&&(Sl.instance=new Sl),Sl.instance}},Sl.instance=null,Sl),oe=class Pl extends hd{constructor(t,i){super(),this._a=null,this._b=null,this._c=null,this.__bbox=null,this._hashed=null,this._direct=null,this._start=t,this._end=i}get a(){return this._a===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(we.eq(this.distance(t),0)){let i=new Pl(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new Pl(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new Ve([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=this.length();i=i*t/s,r=-r*t/s;let n=new ge(this._start.x+r,this._start.y+i),a=new ge(this._end.x+r,this._end.y+i);return new Pl(n,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=Vv.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new $r(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new Pl(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return Nn(i,r)||Nn(i,r.reverse())}stroke(t,i,r){let s,n,a;this._end.x<this._start.x?(n=this._start.x-this._end.x,a=this._start.y-this._end.y,s=this._end):(n=this._end.x-this._start.x,a=this._end.y-this._start.y,s=this._start);let o=Math.sqrt(n*n+a*a),l=t/2,h,c,d;i===2?(c=-l,d=o+l):(c=0,d=o),i===0||i===2?r===0?h=Pt.build5([c,-l,c,l,d,l,d,-l]):h=Pt.build5([c,l,c,-l,d,-l,d,l]):r===0?h=Pt.build2([xe.build3(new ge(c,0),-90,-180,l,l),xe.build3(new ge(d,0),90,-180,l,l)]):h=Pt.build2([xe.build3(new ge(c,0),90,180,l,l),xe.build3(new ge(d,0),-90,180,l,l)]);let f=Math.atan2(a,n),u=$t.rotate(f).translate1(s);return h.asClose().multiply3(u)}points(t){return[this._start,this._end]}mirrorY(t){return new Pl(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new Pl(this._end,this._start)}inArea(t,i,r){let s=t.x,n=t.y,a=this._start,o=this._end,l=r==1,h=s-a.x,c=n-a.y,d=s-o.x,f=n-o.y,u=o.x-a.x,p=o.y-a.y,g=new ge(-p,u).normalize(),_=u+g.x*i/2,y=p+g.y*i/2,m=_*_+y*y,O=h*h+c*c,b=d*d+f*f,v=Math.abs(h*p-c*u)/2,E=Math.sqrt(u*u+p*p)*i/4;if(v<=E&&O<=m&&b<=m){if(l)return!0;{let T=new ge(s,n).sub(o).normalize(),P=new ge(s,n).sub(a).normalize(),A=new ge(g.x,g.y).cross(T),C=new ge(g.x,g.y).cross(P);return A>=0&&C<=0}}else if(l){let T=i/2;return O<=T*T?!0:b<=T*T}else return!1}isParallel(t,i=!1){let r=we.eq(Math.abs(this.direct.cross(t.direct)),0),s=!i||we.greatereq(this.direct.dot(t.direct),0);return r&&s}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:s,y:n}=this.start(),{x:a,y:o}=this.end();return((i-s)*(o-n)-(r-n)*(a-s))**2/((o-n)**2+(a-s)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function PN(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(n,a,o)=>oN(n.x,n.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let n=1;n<e.length-1;n+=2)r(e[n],e[n-1],e[n+1])>t&&i.push(e[n]),i.push(e[n+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let s=e[e.length-1];return i.push(s),i}var AN=FR(UR()),CN=class{constructor(){this.fac=new Cs,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},LN=new CN,Pt=class Vi{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return LN.calcBBox(t)}static build1(t){let i=[],r=null;return zp(t,(s,n)=>{let a=n.start();return r!==null&&!a.equals(r)&&i.push(new oe(r,a)),i.push(n),r=n.end(),!0}),i.length===0&&r!=null&&i.push(new oe(r,r)),new Vi(i)}static build2(t){return Vi.build1(B0(t))}static build3(t){let i=[],r=null;return zp(t,(s,n)=>(r!==null&&i.push(new oe(r,n)),r=n,!0)),new Vi(i)}static build4(t){return this.build3(B0(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new ge(t[r],t[r+1]));return this.build4(i)}static build6(t){return Vi.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Vi(t)}static build8(t){let i=new ge(t[0],t[1]),r,s=[],n,a=(o,l)=>o.length==l&&o.every(h=>typeof h=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?n=t[o]:o-=1,n){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let h=l[0];r=new ge(l[1],l[2]),s.push(xe.build5(i,r,h)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new ge(l[0],l[1]),s.push(new oe(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let h=new ge(l[0],l[1]),c=new ge(l[2],l[3]);r=new ge(l[4],l[5]),s.push(new Ve([i,h,c,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Vi.build2(s)}static buildBBox(t,i=0){return i===1?Vi.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Vi.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1){if(t.length===1){let l=new Array;t[0].asClose().points2(r,f=>l.push(f));let h,c=l[0],d=[];for(let f=0;f<l.length-2;f+=2){let u=l[f+1],p=l[f+2],g=u.sub(c).normalize().cross(p.sub(c).normalize());if(we.neq(g,0)){if(h===!0){if(g<0){d.length=0;break}}else if(h===!1){if(g>0){d.length=0;break}}else h=g>0;d.push(c),d.push(u),d.push(p)}l.push(c),c=p}if(d.length!==0){for(let f=0;f<d.length;f+=3)i(d[f],d[f+1],d[f+2]);return}}let s=[],n=[];t.forEach(l=>{s.length!==0&&n.push(s.length/2),l.asClose().points2(r,h=>s.push(h.x,h.y))});let a=AN.default(s,n),o=[];for(let l=1;l<s.length;l+=2)o.push(new ge(s[l-1],s[l]));for(let l=0;l<a.length;l+=3)i(o[a[l]],o[a[l+1]],o[a[l+2]])}lines(t,i){let r=new Array;this.points(t,n=>r.push(n));let s=r[0];for(let n=1;n<r.length;n++){let a=r[n];i(s),i(a),s=a}}triangles(t,i){Vi.triangulate([this],(...r)=>{r.forEach(s=>i(s))},t)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof oe)i=new oe(i.start().mirror(),i.end().mirror());else if(i instanceof xe)i=i.mirror();else if(i instanceof Ve){let r=i.controls.map(s=>s.mirror());i=new Ve(r)}else throw new Error("bug");t.push(i)}),new Vi(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let s of r.points(t))i.push(s);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let s=i[r];if(s instanceof oe){let n=s.start().round(t),a=s.end().round(t);i[r]=new oe(n,a)}else if(s instanceof Ve){let n=s.controls.map(a=>a.round(t));i[r]=new Ve(n)}else if(s instanceof xe){let n=s.start().round(t),a=s.end().round(t),o=s.sweepAngle;i[r]=xe.build5(n,a,o)}}return new Vi(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,s=[],n=this.closed();if(this.primitives.length<=1)return Vi.build2(this.primitives);let a=()=>{if(s.length>2){let l=PN(s,t);for(let h=1;h<l.length;h++)i.push(new oe(l[h-1],l[h]))}else i.push(new oe(s[0],s[1]));s.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let h=this.primitives[l];h instanceof oe?(r?s.push(h.end()):(s.length=0,s.push(h.start(),h.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(h))}let o=new Vi(i,this.__bbox);return n&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let s=t[r];if(s instanceof oe){if(s.end().equals1(s.start()))continue;if(i&&(s.end().equals1(i.start())||lN(s.end(),i.start(),i.end())))return!0;i=s}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(s=>{let n=s.start(),a=s.end();if(i+=(n.x+r.x)*(n.y-r.y),s instanceof oe)i+=(a.x+n.x)*(a.y-n.y);else if(s instanceof xe)i+=(a.x+n.x)*(a.y-n.y),i+=Math.PI*s.rx2*s.sweepAngle/180-ge.normal(s.center,s.start(),s.end());else if(s instanceof Ve){let o=n;s.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals(s))return this;{let n=new Array;return Qr.addAll(n,this.primitives),n.push(new oe(s,r)),Vi.build2(n)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals1(s))return this;{let n=new Array;return Qr.addAll(n,this.primitives),n.push(new oe(s,r)),new Vi(n)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof oe)s=new oe(s.end(),s.start());else if(s instanceof xe)s=s.exchangeSweep();else if(s instanceof Ve)s=new Ve(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new Vi(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof oe)s=new oe(s.end(),s.start());else if(s instanceof xe)s=s.exchangeSweep1();else if(s instanceof Ve)s=new Ve(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new Vi(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof oe)r=r.mirrorY(t);else if(r instanceof xe)r=r.mirrorY(t);else if(r instanceof Ve){let s=r.controls.map(n=>n.mirrorY(t));r=new Ve(s)}else throw new Error("bug");i.push(r)}),new Vi(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let s=this.primitives[r].points(t);s.pop(),s.forEach(n=>i(n))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof xe?n.points1(t):n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof xe?r.points1(t):r.points(t)).forEach(s=>i(s))}points2(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof xe?n.points2():n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof xe?r.points2():r.points(t)).forEach(s=>i(s))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return Vi.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Vi.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof xe))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof Vi&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let s=t.primitives[r],n=this.primitives[r];if(JSON.stringify(s)!=JSON.stringify(n))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let s=0;for(;s<i.length;){let n=i.slice(s).concat(i.slice(0,s));if(Nn(n,r)||Nn(n.reverse(),r))return!0;s++}return!1}else return Nn(this.primitives,t.primitives)}clone(){return Vi.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Vi)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let s=this.end();if(r.equals(s,i))return!1;let n=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(n,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(s.equals(n,i))o=!1,l=!0;else if(s.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=$r.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let s=this.start();if(!s){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let n=this.end();if(s.equals(n,i))return!1;let a=t.start(),o=t.end(),l=!1,h=!1;if(s.equals(a,i))l=!0,h=!1;else if(s.equals(o,i))l=!1,h=!1;else if(n.equals(a,i))l=!1,h=!0;else if(n.equals(o,i))l=!0,h=!0;else return!1;let c=l?t.reverse():t;return h?this.primitives.push(...c.primitives):this.primitives.unshift(...c.primitives),this.__bbox=$r.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),s=t.primitives[0].start(),n=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof oe&&t.primitives[0]instanceof oe&&gN([i,r],[s,n])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new oe(i,n)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,s=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(n(o),n(l),a instanceof xe){let h=t.angleD(ge.ORIGIN);if(a.angleIsInArc(h)){let c=a.pointOn(h).dot(i);n(c)}if(a.angleIsInArc(h+180)){let c=a.pointOn(h-180).dot(i);n(c)}}}),r-s<=0)throw new Error("getMaxBBoxHeightByVec");return r-s;function n(a){a>r&&(r=a),a<s&&(s=a)}}getWindingNum(t){let i=this.end(),r=0,{x:s,y:n}=t;for(let o of this.primitives){if(i.y>n?o.bbox().minY>n:o.bbox().maxY<=n){i=o.end();continue}if(o instanceof xe&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,h=o.endAngle();if(o.sweepAngle>0){let c=90;for(;c<=h;)c>l&&(a(xe.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c+=90;l<h&&a(xe.build3(o.center,l,h-l,o.rx,o.ry))}else{let c=270;for(;c>=h;)c<l&&(a(xe.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c-=90;l>h&&a(xe.build3(o.center,l,h-l,o.rx,o.ry))}}else if(o instanceof Ve){let l=[];jv(o,l),l.forEach(h=>a(h))}else a(o)}return r;function a(o){let l=o.start(),h=o.end();if(i.y>n!=l.y>n&&(i.x>s?l.x>s?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++:l.x>s&&(i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++)),l.y>n!=h.y>n){if(l.x>s)if(h.x>s)r+=h.y>l.y?1:-1;else if(o instanceof oe)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof xe){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof Ve){if(B2(o,n)===0)throw new Error("no inters");ee[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!");else if(h.x>s)if(o instanceof oe)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof xe){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof Ve){if(B2(o,n)===0)throw new Error("no inters");ee[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!")}i=h}}},gp=Math.PI*2,OZ=Math.PI/2,mZ=Math.sin(Math.PI/180),DN=4,xe=class di extends hd{constructor(t,i,r,s,n){super(),this._rx2=null,this._ry2=null,this._svgEnd=null,this._hashed=null,this.__bbox=null,this.rx=t,this.ry=i,this.center=r,this.startAngle=s,this.sweepAngle=n,this._start=ge.ORIGIN,this._end=ge.ORIGIN,this._start=this.pointOn(s),this._end=this.pointOn(s+n)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new ge(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new ge(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,s){let n=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(s)<2e-4;)n*=2,a+=n,s=this.pointOn(a);return s}static build1(t,i,r,s,n,a){Si.positive(r),Si.positive(s);let o=t.equals(i);if(o)return new di(r,s,t,0,n?360:0);{let l=t.x,h=-t.y,c=i.x,d=-i.y,f=a===0,u=(l-c)/2,p=(h-d)/2,g=Math.cos(0),_=Math.sin(0),y=g*u+_*p,m=-_*u+g*p;r=Math.abs(r),s=Math.abs(s);let O=r*r,b=s*s,v=y*y,E=m*m,T=n===f?-1:1,P=(O*b-O*E-b*v)/(O*E+b*v);P=P<0?0:P;let A=T*Math.sqrt(P),C=A*(r*m/s),M=A*-(s*y/r),H=(l+c)/2,k=(h+d)/2,F=H+(g*C-_*M),j=k+(_*C+g*M),L=(y-C)/r,R=(m-M)/s,x=(-y-C)/r,I=(-m-M)/s,S,D;D=Math.sqrt(L*L+R*R),S=L,T=R<0?-1:1;let N=pt.toDegrees(T*Math.acos(S/D));D=Math.sqrt((L*L+R*R)*(x*x+I*I)),S=L*x+R*I,T=L*I-R*x<0?-1:1;let G=S/D,z;G<-1?z=Math.acos(-1):G>1?z=Math.acos(1):z=Math.acos(G);let Z=pt.toDegrees(T*z);!f&&Z>0?Z-=360:f&&Z<0&&(Z+=360),Si.normal(N),Si.normal(Z);let se=u*u/O+p*p/b,he=t.distance1(i)/2;r<he&&s<he&&(r*=Math.sqrt(se),s*=Math.sqrt(se));let pe=o?0:pt.regularD(-N),Se=o?n?360:0:-Z;return new di(r,s,new ge(F,-j),pe,Se)}}static build2(t,i,r,s,n,a){Si.positive(s),Si.positive(n),Si.normal(i),Si.normal(r);let o;return i===r?(i=pt.regularD(i),r=pt.regularD(r),o=0):(i=pt.regularD(i),r=pt.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new di(s,n,t,pt.regularD(i),o)}static build3(t,i,r,s,n){return Si.positive(s),Si.positive(n),Si.normal(r),new di(s,n,t,pt.regularD(i),r)}static build4(t,i,r,s,n,a){let o=t.angleD(r),l=i.angleD(r);return di.build2(r,o,l,s,n,a)}static build5(t,i,r){r=pt.toRadians(r);let s=i.sub(t),n=new ge(-s.y,s.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=s.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=n.rotate(ge.ORIGIN,a),h,c;r>0?(h=1,c=i.add(l.scale(o))):(h=0,c=t.sub(l.scale(o)));let d=pt.toDegrees(t.angle(c)),f=pt.toDegrees(i.angle(c));return di.build2(c,d,f,o,o,h)}static buildCircle(t,i,r=0){return di.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=pt.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let s=this.rx2,n=this.ry2,a=Math.tan(pt.toRadians(t)),o=a*a,l=Math.sqrt(s*n/(s+n/o)),h=Math.sqrt(s*n/(n+s*o));return t>90&&t<270&&(h=-h),t>180&&t<360&&(l=-l),isNaN(h)&&(h=0),isNaN(l)&&(l=0),this.center.add1(h,l)}}exchangeSweep(){return di.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return di.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return di.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?di.build3(this.center.mirrorY(),0,360,this.rx,this.ry):di.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=ge.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?di.build3(this.center.mirror(t),0,360,this.rx,this.ry):di.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=k0.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals($t.ROT_90)?r=pt.regularD(this.startAngle+90):t.equals($t.ROT_N90)?r=pt.regularD(this.startAngle-90):r=pt.transformD(this.startAngle,t),di.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=pt.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=pt.toRadians(this.sweepAngle)/2,s=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new Ve([t,t.add(new ge(s,0).multiply3($t.rotateD(this.startAngle+90))),i.add(new ge(s,0).multiply3($t.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(s=>i.push(s.toBezier())),i;function r(s,n){if(Math.abs(s.sweepAngle)>n){let a=s.sweepAngle/2;r(di.build3(s.center,s.startAngle,a,s.rx,s.ry),n),r(di.build3(s.center,s.startAngle+a,a,s.rx,s.ry),n)}else t.push(s)}}buildBBox(){let t=Vv.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r-=90}}return new $r(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return Yh.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let s=t/2,n=this.rx+s,a=this.ry+s,o=this.rx-s,l=this.ry-s,h=new $t;o<0&&(o=-o,h=h.multiply3($t.MIRROR_Y)),l<0&&(l=-l,h=h.multiply3($t.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),h=h.setOrigin1(this.center);let c,d;switch(r===this.sweep()?(c=di.build3(this.center,this.startAngle,this.sweepAngle,n,a),d=di.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(c=di.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,n,a),d=di.build3(this.center,this.startAngle,this.sweepAngle,o,l)),d=d.multiply3(h),i){case 1:{let f=r===1?180:-180,u=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),p=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),g=c.pointOn(c.endAngle()).angleD(u),_=d.pointOn(d.endAngle()).angleD(p);return Pt.build2([c,di.build3(u,g,f,s,s),d,di.build3(p,_,f,s,s)])}default:return Pt.build2([c,d])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/DN),i=this.sweepAngle/t,r=[this._start];for(let s=1;s<t;s++)r.push(this.pointOn(this.startAngle+i*s));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/pt.toDegrees(Math.acos(r))/2)),n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle;for(let l=0;l<=s;l++,o+=a)n[l]=this.pointOn(o);return n}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/pt.toDegrees(Math.acos(r))/2));s=Math.max(s,2);let n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle+a;n[0]=this.start();for(let l=1;l<s;l++,o+=a)n[l]=this.pointOn(o);return n[s]=this.end(),n}panDistance(t){return this.sweepAngle>0?new di(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new di(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),di.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new di(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),di.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new di(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(nN(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=pt.toRadians(this.startAngle),i=pt.toRadians(this.endAngle()),r=this.sweep(),s=this.center,n=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return s.add(new ge(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new ge(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(i+gp-t)/2+t;return s.add(new ge(Math.cos(a),Math.sin(a)).mul(n))}}else if(i>t){let a=(t+gp-i)/2+i;return s.add(new ge(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new ge(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(t-i)/2+i;return s.add(new ge(Math.cos(a),Math.sin(a)).mul(n))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=pt.regularD(this.startAngle),r=pt.regularD(this.sweepAngle),s=pt.regularD(t.startAngle),n=pt.regularD(t.sweepAngle);return Nn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(Nn([r,i],[n,s])||Nn([pt.regularD(i+r)],[s]))}equals1(t){let i=pt.regularD(this.startAngle),r=pt.regularD(this.sweepAngle),s=pt.regularD(t.startAngle),n=pt.regularD(t.sweepAngle);return Nn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(Nn([r,i],[n,s])||Nn([pt.regularD(i+r)],[s]))}inArea(t,i){let r=t.x,s=t.y,n=this.center,a=this.rx,o=pt.toRadians(this.startAngle);this.sweep()==0&&(o=pt.toRadians(this.endAngle()));let l=pt.toRadians(this.endAngle());this.sweep()==0&&(l=pt.toRadians(this.startAngle));let h=a-i/2,c=a+i/2;var d=r-n.x,f=s-n.y,u=Math.atan2(f,d);if(u<0&&(u+=gp),o<=l&&u>=o&&u<=l||o>l&&(u>=o&&u<=gp||u>=0&&u<=l)||o==l){var p=Math.sqrt(d*d+f*f);return p<=c&&p>=h}else{var p=(c+h)/2,g=new ge(n.x+Math.cos(o)*p,n.y+Math.sin(o)*p),_=new ge(n.x+Math.cos(l)*p,n.y+Math.sin(l)*p),y=r-g.x,m=s-g.y,O=r-_.x,b=s-_.y;return y*y+m*m<=i*i/4?!0:O*O+b*b<=i*i/4}}isCircle(){return(we.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return di.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}},Yv=new ArrayBuffer(24),h0=new Float64Array(Yv),Ch=new Int32Array(Yv),Lr,bZ=(Lr=class{static normal(e,t,i){let r=t.sub(e),s=i.sub(t);return r.cross(s)}constructor(e,t,i){this.x=Si.normal(e),this.y=Si.normal(t),this.z=Si.normal(i),h0[0]=e,h0[1]=t,h0[2]=i,this.hashed=Ch[0]^Ch[1]^Ch[2]^Ch[3]^Ch[4]^Ch[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof Lr?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new Lr(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var e=this.length();return new Lr(this.x/e,this.y/e,this.z/e)}sub(e){return new Lr(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new Lr(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new Lr(this.x*e,this.y*e,this.z*e)}neg(){return new Lr(-this.x,-this.y,-this.z)}multiply4(e){var t=this.x*e.data[0]+this.y*e.data[4]+this.z*e.data[8]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+this.z*e.data[9]+e.data[13],r=this.x*e.data[2]+this.y*e.data[6]+this.z*e.data[10]+e.data[14],s=this.x*e.data[3]+this.y*e.data[7]+this.z*e.data[11]+e.data[15];return s!=0?new Lr(t/s,i/s,r/s):new Lr(t,i,r)}rotate(e,t){return this.multiply4(Uv.rotateAxis(e,t))}toVector2(){return new ge(this.x,this.y)}},Lr.ORIGIN=new Lr(0,0,0),Lr.X_UNIT_VECTOR=new Lr(1,0,0),Lr.Y_UNIT_VECTOR=new Lr(0,1,0),Lr.Z_UNIT_VECTOR=new Lr(0,0,1),Lr),Ui=class Fh{static build(t){return t instanceof Pt?new Fh([new nr([t])]):t instanceof nr?new Fh([t]):t}static buildByPolygon(t){return t?new Fh([t]):new Fh([])}static buildByStroke(t,i,r=1,s){return this.buildByPolygon(nr.buildByStroke(t,i,r,_m,s))}static buildCircle(t,i){return this.buildByPolygon(nr.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(nr.buildRect(t))}static buildBBox(t){return this.buildByPolygon(nr.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new Fh(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new Cs).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},ui,Gt=(ui=class{static isHexFormate(e){return!e||typeof e!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)}static of1(e){return this.of2(e>>16&255,e>>8&255,e&255)}static of2(e,t,i,r=255){return new ui(e/255,t/255,i/255,r/255)}static of3(e){e.startsWith("#")&&(e=e.substr(1));let t=e.length;if(t==3)return new ui(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new ui(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255);if(t==8)return new ui(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,parseInt(e.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(e){let t=parseInt(e.r*255+"").toString(16),i=parseInt(e.g*255+"").toString(16),r=parseInt(e.b*255+"").toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),("#"+t+i+r).toUpperCase()}static of5(e,t){if(e.startsWith("#")&&(e=e.substr(1)),e.length==3)return new ui(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new ui(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,t);throw new Error("invalid color string")}static of6(e,t){return new ui(e.r,e.g,e.b,t)}static of7(e){return e==null?null:ui.of3(e)}constructor(e,t,i,r=1){this.r=Si.positiveOr0(e),this.g=Si.positiveOr0(t),this.b=Si.positiveOr0(i),this.alpha=r}hashCode(){return this.r+this.g+this.b+this.alpha}equals(e,t=!1){let i=this.r===e.r&&this.g===e.g&&this.b===e.b;return t?i:i&&this.alpha===e.alpha}add(e,t,i,r){return new ui(Math.max(0,Math.min(1,this.r+e)),Math.max(0,Math.min(1,this.g+t)),Math.max(0,Math.min(1,this.b+i)),Math.max(0,Math.min(1,this.alpha+r)))}mul(e){return new ui(Math.max(0,Math.min(1,this.r*e)),Math.max(0,Math.min(1,this.g*e)),Math.max(0,Math.min(1,this.b*e)),this.alpha)}mul1(e){return new ui(Math.max(0,this.r*e),Math.max(0,this.g*e),Math.max(0,this.b*e),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)}toString1(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16),r=(this.alpha*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toRGBA(){let e=this.r*255,t=this.g*255,i=this.b*255;return[e,t,i,this.alpha]}toRGBAString(){let e=this.r*255,t=this.g*255,i=this.b*255;return`rgba(${e},${t},${i},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}},ui.WHITE=new ui(1,1,1,1),ui.BLACK=new ui(0,0,0,1),ui.RED=new ui(1,0,0,1),ui.GREEN=new ui(0,1,0,1),ui.BLUE=new ui(0,0,1,1),ui.Gray=ui.of3("#9966ff"),ui.Silver=ui.of3("#D2D2D2"),ui.Golden=ui.of3("#DCAA14"),ui.Pink=ui.of3("#ffaec9"),ui),j2=!1,qv=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,s,n){}onIntersect(e,t,i){}onSegment(e,t,i,r,s,n){}onSegment1(e,t,i){if(j2){let r=new ge(e.getX(i),i),s=new ge(t.getX(i),i);this.onSegment(r,e.weight,e,s,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if(j2){let r=new ge(e.getX(i),i),s=new ge(t.getX(i),i);this.onSweep(r,e.weight,e,s,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},Xu=class extends qv{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},cd=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let s=this.weights[r],n=e/s|0,a=e%s;a>(s/2|0)?(e=s-a,n++):e=a,this.result[r]=n>0}t=this.decide1(this.result),this.cache[i]=t}return t}},RN=e=>e!==0,NN=new class extends cd{decide1(e){return e[0]||e[1]}}(2),Cp=new class extends cd{decide1(e){return e[0]&&!e[1]}}(2),Lp=new class extends cd{decide1(e){return e[0]&&e[1]}}(2),c0=new class extends cd{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),MN=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(MN||{}),ec=class Uh{constructor(t,i,r,s,n,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,s.y>n.y?this.weight=-r:s.y==n.y?this.weight=0:this.weight=r,this.start=s,this.end=n,this.polyGrp=a,this.polyIndex=o,this._bbox=new Cs().ext1(i.bbox()).ext2(s).ext2(n).build1(),this.inters.push(s),this.inters.push(n);let l=31,h=1;h=l*h+this.polyGrp,h=l*h+this.polyIndex,this._hashcode=h}static rebuild(t,i,r){if(t instanceof oe||i.distance2(r)<1e-6)return new oe(i,r);if(t instanceof xe){let s=t,n=t.bbox().center().x,a;i.y>r.y?a=n>s.center.x?0:1:a=n>s.center.x?1:0;let o=i.angleD(s.center),l=r.angleD(s.center);return xe.build2(s.center,o,l,s.rx,s.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new Cs().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(jN(this,t)>0?this._x=ee[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=Uh.rebuild(this.shape,this.end,this.start),r=new Uh(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Qr.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=Uh.rebuild(this.shape,this.end,this.start),r=new Uh(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return Qr.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof Uh?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return Yh.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function BN(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minY+i.maxY)/2,n=(r.minY+r.maxY)/2;return s-n}function kN(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minX+i.maxX)/2,n=(r.minX+r.maxX)/2;return s-n}var Lh=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=$r.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},Qu=class{constructor(e){this.changed=!1,this.root=new Lh,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){Qr.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new Lh,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new Lh(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new Lh(e),this.changed=!1}}organize(e){Bl(e,kN,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let s=r+this.capacity2;Bl(e,BN,r,s);for(let n=r;n<s;n+=this.capacity){let a=new Lh(e.slice(n,n+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let s=new Lh(e.slice(r,r+this.capacity));i.push(s),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let s=r.items();if(s instanceof Array){for(let n of s)if(!e.isSeparated(n.bbox())){let a=n.items();a instanceof Array?i.push(n):t.push(a)}}else e.isSeparated(r.bbox())||t.push(s)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let s of r)this._walker(s,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function u0(e,t){FN(e.iterator(),t)}function FN(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var _p=new Error("list is empty"),Op=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},UN=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},GN=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},Ll=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw _p;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw _p;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new Op(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new Op(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw _p;return this.first.item}getLast(){if(this.last===null)throw _p;return this.last.item}insertAfter(e,t){let i=new Op(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Op(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new UN(this.first)}listIterator(){return new GN(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function d0(e){throw new Error("")}var mp=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},zN=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},HN=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},Wp=class{constructor(){this.innerList=new Ll,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new mp(e,t),s=this.innerMap[i];if(s===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(s instanceof mp){if(s.key.equals(e))return this.innerMap[i]=r,this.replace(s,r),s.value;{r.node1=this.innerList.add(r);let n=new Ll;return s.node2=n.add(s),r.node2=n.add(r),this.innerMap[i]=n,null}}if(s instanceof Ll){let n=null;return u0(s,(a,o)=>o.key.equals(e)?(this.replace(o,r),n=o.value,!1):!0),n===null?(r.node1=this.innerList.add(r),r.node2=s.push(r),null):n}return d0(s)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof mp)return i.key.equals(e)?i.value:null;if(i instanceof Ll){let r=null;return u0(i,(s,n)=>n.key.equals(e)?(r=n.value,!1):!0),r}return d0(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof mp)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Ll){let r=null;return u0(i,(s,n)=>n.key.equals(e)?(r=n.value,this.delete(n),!1):!0),r}return d0(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new zN(this.innerList.iterator())}values(){return new HN(this.innerList.iterator())}entries(){return this.innerList.iterator()}},Kh=class{constructor(){this.innerMap=new Wp}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},V2=Qr.funcCopy(Bl);function jN(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)ee[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)ee[i++]=e.end.x;else if(e.shape instanceof oe)i=hN(e.shape,t);else if(e.shape instanceof xe)i=cN(e.shape,t);else throw new Error("not supported operation");return i}var Dp=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let s of this.loader.buildGroup(e,t,i,r))this.sides.push(s),this.event.onOriginSide(s)}buildRTree(){let e=new Qu(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let s of e)s.needCountWeight()&&(t.push(s.start),t.push(s.end));V2(t,ge.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let s of t){let n=s.y;n>r&&(i.push(n),r=n)}return i}splitSides(e,t,i){let r=e.start,s=e.end,n=new ge(s.x+(r.x-s.x)*2,s.y+(r.y-s.y)*2);V2(e.inters,(o,l)=>o.distance2(n)-l.distance2(n),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=ec.rebuild(e.shape,a,o);l instanceof xe&&Math.abs(l.sweepAngle)>190&&(l=new oe(a,o));let h=new ec(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(h),h.updateBbox(),o.equals(s))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,s=null;do{let n=new Array;i=this.splitSides(t,n,i);for(let a of n)r!=null?(r.next=a,a.previous=r):s=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);s!=null&&r!=null&&(s.previous=r,r.next=s)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new Kh;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),s=i.shape instanceof oe;for(let n of e.search(r))if(!t.contains(n)){let a=n.shape instanceof oe;if(!(s&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(n)||i.previous.equals(n)))){let o=gn(i.shape,n.shape);for(let l=0;l<o;l+=2){let h=new ge(ee[l],ee[l+1]);i.inters.push(h),n.inters.push(h),this.event.onIntersect(h,i,n)}}}}}}},VN=class Wv{constructor(t){this.sides=new Kh,this.others=new Kh,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return Zh(this.sides,(i,r)=>(t.push(r.shape),!0)),Pt.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof Wv?this.id===t.id:!1}},Xv=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new oe(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let s of this.sides)(!this.noWeight0||s.weight!==0)&&(i!=null?(i.next=s,s.previous=i):r=s,i=s,t.push(s));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let s of e.primitives)if(s instanceof oe)this.addSide(s,t);else if(r&&s instanceof xe&&s.rx===s.ry)this.addArc(s,t);else{let n=null;for(let a of s.points(i))n!=null&&this.addSide(new oe(n,a),t),n=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=pt.regularD(e.startAngle),s=r+i;if(i>0){let n=90;for(;n<=s;)n>r&&(this.addSide(xe.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n+=90;r<s&&this.addSide(xe.build3(e.center,r,s-r,e.rx,e.ry),t)}else if(i<0){let n=270;for(;n>=s;)n<r&&(this.addSide(xe.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n-=90;r>s&&this.addSide(xe.build3(e.center,r,s-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new oe(this.prevSide.end,i),t),r=new ec(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new ec(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},Jv=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&we.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},Xp=new Error,Y2=new class extends cd{decide1(e){return e[0]&&e[1]}}(2),YN=new class extends qv{onPolylineGroup(e,t){throw Xp}onSegment(e,t,i,r,s,n){throw Xp}},qN=class{constructor(e,t){this.rtree=e,this.level=t}},WN=class Zv extends Dp{static isIntersect(t,i,r=hg.DUMMY){let s=new Zv(r),n=s.createGroup1(t.items),a=s.createGroup2(i.items);return n.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:s.isIntersect(n,a)}constructor(t){super(new Xv(!1),Y2.rule,t,YN)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=Y2.weight(i);for(let n of t)this.addPolyline(n,r);let s=this.buildRTree();return this.sides.length=0,new qN(s,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let s=(r.minY+r.maxY)/2;this.sweep(t,i,s)}catch(s){if(s===Xp)return!0;throw s}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let s=r.bbox().extendOfSize(1e-5);for(let n of i.rtree.search(s))if(n.trans=NaN,gn(r.shape,n.shape)>0)throw Xp}}sweep(t,i,r){let s=$r.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),n=new Array;this.fillValidSides(n,t.rtree.search(s),r),this.fillValidSides(n,i.rtree.search(s),r),Bl(n,(o,l)=>o.getX(r)-l.getX(r),0,n.length);let a=new Jv(this.rule,this,r);for(let o of n)a.onEp(o)}},Om=class Ha{constructor(t){this.items=new Array(t.length),Qr.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return zp(t,(r,s)=>(i.push(s),!0)),new Ha(i)}static build2(t){let i=t.map(r=>Pt.build8(r));return new Ha(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new Ha(i)}calcBBox(){let t=new Cs;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new Ha(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof Ha?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let s=0,n=t.length;s<n;s++){let a=t[s];if(!i.has(a)&&!r.has(a)){s+1>=n&&i.add(a);for(let o=s+1;o<n;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;WN.isIntersect(new Ha([a]),new Ha([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new Ha(i)}},XN=Qr.funcCopy(Bl),JN=Qr.funcCopy(Bl),ZN=Qr.funcCopy(Bl);function KN(e){return new Array}function $N(e,t){let i=new Xu(!1),r=new Ju(e,hg.DUMMY,i);for(let s of t)r.addPolyline(s);return r.simplify(),i.plGrps}var Ju=class extends Dp{constructor(e,t,i){super(new Xv(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,XN(t,Dp.sortByBBoxMinY,0,t.length);let r=new Ll;this.curNetIndex=0;let s=Number.POSITIVE_INFINITY;for(let n of e)n>s&&this.scan(r,(s+n)/2,t),s=n;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,s=e.listIterator();for(;s.hasNext();){let n=s.next(),a=n.item;we.less(a.bbox().maxY,t)?e.remove(n):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let n=i[this.curNetIndex];if(we.less(n.bbox().minY,t))we.greatereq(n.bbox().maxY,t)&&(this.add2AET(e,n),!r&&n.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let n=new Jv(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();n.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,s=t.bbox().minY,n=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,h=a.next(),c=h.item,d=c.bbox().minX,f=c.bbox().maxX;if(r<=d)l=-1;else if(f<=i)l=1;else{let p=c.bbox().minY,g=c.bbox().maxY,_=Math.max(s,p),y=Math.min(n,g);l=this.compareBySweep(t,c,(_+y)/2)}let u=c.shape;if(u instanceof oe&&u.length()<.001&&o==null&&l<0){o=h;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(h,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),s=this.getLineAngle(t);return we.eq(r,s)?-e.sweepAngle:s-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let s=t.getX(i);if(!isFinite(s))return 0;if(!we.eq(r,s))return r-s;if(e.shape instanceof oe)return t.shape instanceof oe?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof oe)return this.compareArcLine(e.shape,t.shape,i);{let n=e.shape,a=t.shape,o=this.getArcAngle(n,i),l=this.getArcAngle(a,i);return we.eq(o,l)?n.sweepAngle*a.sweepAngle<=0?n.sweepAngle<=0?1:-1:n.sweepAngle>0?n.rx-a.rx:a.rx-n.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let s=i.reverse(r);if(e){this.event.onResultSide(s);let n=s.shape.multiply3($t.ROT_N90),a=s.start.multiply3($t.ROT_N90),o=s.end.multiply3($t.ROT_N90);s=new ec(this,n,s.baseWeight,a,o,s.polyGrp,s.polyIndex)}this.finalSides.push(s),this.event.onResultSide(s)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3($t.ROT_90),s=e.start.multiply3($t.ROT_90),n=e.end.multiply3($t.ROT_90),a=new ec(this,r,e.baseWeight,s,n,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof xe){if(t&&i.rx<=t)return!1}else if(i instanceof oe&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new Wp,t=new Qu(10);for(let n of this.finalSides)e.computeIfAbsent(n.start,KN).push(n),t.add(n.start);let i=0,r=new Kh,s=new Array;for(let n of this.finalSides)if(!r.contains(n)){let a=new Kh,o=n.start,l=new Ll;l.add(n),r.add(n);let h=n.end;for(;l.size()>0;)if(this.isStart(o,h)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let c=e.get(h),d=this.findNext(r,c);if(d==null&&(h=this.findNeigber(h,a,t,.01),h!==null&&(c=e.get(h),d=this.findNext(r,c))),d!=null)l.add(d),r.add(d),h=d.end;else if(h!=null?a.add(h):(s.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),s.push(l.removeLast())),l.size()>0)h=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new VN(t);Zh(e,(r,s)=>(i.add(s),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new Wp;for(let r in this.sideGroups){let s=this.sideGroups[r];Zh(s.sides,(n,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new Kh;for(let r in this.sideGroups){let s=this.sideGroups[r];if(i.add(s)){let n=0,a=new Array;for(a.push(s);n<a.length;){let l=a[n],h=new Array;Zh(l.others,(d,f)=>{let u=t.get(f);return u!=null&&h.push(u.finalGrp),!0}),JN(h,Qr.sortAsc,0,h.length);let c=l.id;for(let d of h)if(d!=c&&d!=l.id){let f=this.sideGroups[d];i.add(f)&&a.push(f),c=d}n++}let o=new Array;for(let l of a)o.push(l.polyline());ZN(o,Dp.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new Om(o),e++)}}}findNeigber(e,t,i,r){let s=r*r,n=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<n&&(n=l,a=o)}return n<s?a:null}},QN=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof oe)this.lines.push(e);else if(e instanceof xe)this.arcs.push(e);else if(e instanceof Ve)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,s=!0){this.listText.push({pos:e,str:t,size:i,width:r}),s&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],s=[],n=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,pt.toRadians(a.startAngle),pt.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>s.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>n.push(a)),{points:e,lines:t,arcs:i,texts:s,beziers:r,fonts:n}}},Ru,ud=(Ru=class{constructor(e){this.map=new Wp,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new QN)}draw(){let e={},t=this.map.entries();for(;t.hasNext();){let i=t.next();e[i.key.toString()]=i.value.build()}this.bus.publish("/debug/draw",e)}clear(){this.map.clear()}static init(e){if(!e)throw new Error("bus is undefined!");this.palette=new Ru(e)}static initPalette(e){this.palette=e}static getDefaultColor(){for(let e of this.colorBuffersMap)if(e[0]!==null&&e[0])return e[0]=!1,e[1];return this.colorBuffersMap.forEach(e=>{if(e[0]===null){console.log(1);return}e[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(e,t=this.getDefaultColor()){if(Array.isArray(e))e.forEach(i=>{this.auto(i,t)});else if(e instanceof ge)this.point(e,t);else if(e instanceof $r)this.bbox(e,t);else if(e instanceof hd)this.primitive(e,t);else if(e instanceof Pt)this.polyline(e,t);else if(e instanceof nr)this.polygon(e,t);else if(e instanceof Ui)this.group(e,t);else if(e instanceof Om)this.auto(e.items,t);else{debugger;throw new Error("No incoming type!")}}static text(e,t,i=.5,r=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(r).addText(e,t,i,i/10),this.palette.draw()}static point(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.point(r,t)}):i.addPoint(e),this.palette.draw()}static bbox(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.bbox(i,t)}):(this.primitive(new oe(new ge(e.maxX,e.maxY),new ge(e.maxX,e.minY)),t),this.primitive(new oe(new ge(e.maxX,e.maxY),new ge(e.minX,e.maxY)),t),this.primitive(new oe(new ge(e.minX,e.minY),new ge(e.maxX,e.minY)),t),this.primitive(new oe(new ge(e.minX,e.minY),new ge(e.minX,e.maxY)),t))}static primitive(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.primitive(r,t)}):i.addPt(e),this.palette.draw()}static polyline(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polyline(i,t)}):e.primitives.forEach(i=>{this.primitive(i,t)})}static polygon(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polygon(i,t)}):e.items.forEach(i=>{this.polyline(i,t)})}static group(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.group(i,t)}):e.items.forEach(i=>{this.polygon(i,t)})}static async begin(){this.t1=performance.now()}static async end(e){console.log(e||"t1:",performance.now()-this.t1)}static async log(e){console.log(e||"==================")}},Ru.colorBuffersMap=[[!0,Gt.BLUE],[!0,Gt.GREEN],[!0,Gt.WHITE],[!0,Gt.RED],[!0,Gt.Golden],[!0,Gt.Gray]],Ru.t1=0,Ru),e4=0,dd=class G0{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=e4++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:s,y:n}=t;if(this.shape instanceof xe){let a=this.shape.rx,o=new ge((i+s)/2,(r+n)/2),l=this.shape.center,h;return o.x!==l.x||o.y!==l.y?(h=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(h+=h>=0?-180:180)):h=(this.shape.startAngle+this.shape.endAngle())/2,new ge(l.x+Math.cos(h)*a,l.y+Math.sin(h)*a)}else{if(this.shape instanceof oe)return new ge((i+s)/2,(r+n)/2);if(this.shape instanceof Ve){let a=this.shape.getPercent(t,ot);return Ve.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let s=t.cross(i)>0,n=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!s:s)&&(n=cg-n),n}sortInters(){if(this.shape instanceof xe){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((s,n)=>{let a=s.coord.sub(t),o=n.coord.sub(t);return G0.finalAngle(i,a,r)-G0.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof oe){let t=this.start,i=this.end,r=new ge(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((s,n)=>s.coord.distance2(r)-n.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof Ve){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,ot)-t.getPercent(r.coord,ot)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(Pt.build7(o))}),i.push(new nr(s))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(Pt.build7(o))}),i.push(new nr(s))}),new Ui(i)}static rebuild(t,i,r){let s;if(t instanceof oe||i.distance2(r)<1e-6)s=new oe(i,r);else if(t instanceof xe)s=xe.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof Ve){let n=t.getPercent(i,ot),a=t.clip(n)[1];s=a.clip(a.getPercent(r,ot))[0]}else throw new Error("not supported operation");return at(t,i).dot(at(s,i))<0?null:s}static returnPolyline(t){return Pt.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},t4=(e=>(e[e.END1=0]="END1",e[e.END2=1]="END2",e[e.END12=2]="END12",e[e.LEFT1=3]="LEFT1",e[e.LEFT2=4]="LEFT2",e))(t4||{});function es(e,t,i){if(e instanceof xe&&t instanceof xe)return s4(e,t);if(e instanceof xe&&t instanceof oe)return X2(e,t);if(e instanceof oe&&t instanceof xe)return W2(e,t);if(e instanceof oe&&t instanceof oe)return Rl(e,t);if(e instanceof Ve&&t instanceof oe)return e.controls.length===2||qa(e)?Rl(new oe(e.start(),e.end()),t):Kv(e,t);if(e instanceof oe&&t instanceof Ve)return t.controls.length===2||qa(t)?Rl(e,new oe(t.start(),t.end())):z0(e,t);if(e instanceof xe&&t instanceof Ve)return t.controls.length===2||qa(t)?X2(e,new oe(t.start(),t.end())):i4(e,t);if(e instanceof Ve&&t instanceof xe)return e.controls.length===2||qa(e)?W2(new oe(e.start(),e.end()),t):r4(e,t);if(e instanceof Ve&&t instanceof Ve)return mm(e,t);throw new Error("not support")}function Dh(e,t){return at(e,t.start()).dot(at(t,t.start()))<=0?!1:es(e,t).state<=2}function f0(e,t){let i=t.getPercent(e.end(),ot);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],s=e.buildConverxHull(ot),n=r.buildConverxHull(ot),a=h(s),o=h(n);return l(a,o);function l(c,d){let f=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),u=c[0],p=d[0];if(!u||!p)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let g=!0;do{let _=u.getShape(),y=p.getShape();if(_ instanceof oe&&y instanceof oe){let m=g?Rl(_,y).state:f.get(Rl(y,_).state);if(m===0)u=u.nextSide,g=!1;else if(m===1)p=p.nextSide,g=!0;else if(m===2)u=u.nextSide,p=p.nextSide,g=!0;else return!1}else throw Error("not support")}while(u!==c[0].prevSide&&p!==d[0].prevSide);return!0}function h(c){let d=c.primitives.map(u=>new dd(u)),f=d[d.length-1];return d.forEach(u=>{f.connect(u),f=u}),d}}function q2(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+ot)**2||i<(t.rx-ot)**2||!($e(e.end(),t.end())||bm(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),s=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let n=e.center.angleD(t.center);return e.rx>t.rx?!(r+s>ot&&ua(e,n))&&!(r-s>ot&&e.rx+t.rx-r>ot&&ua(e,n+180)):!(r-s>ot&&ua(e,n))&&!(e.rx+t.rx-r>ot&&ua(e,n+180))}else{if(r+s<=ot)return!0;let n=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return ua(e,n)?!1:r-s<=ot?!0:!ua(e,n+180)}}function i4(e,t){let i=ym(e,t.start()).toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=mm(a,t).state,r!==0)break}return r===2&&s!==i.length-1?{state:1}:{state:r}}function r4(e,t){let i=t.toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=mm(e,a).state,r!==1)break}return r===2&&s!==i.length-1?{state:0}:{state:r}}function mm(e,t){if(e.controls.length===2||qa(e))return t.controls.length===2||qa(t)?Rl(new oe(e.start(),t.end()),new oe(t.start(),t.end())):z0(new oe(t.start(),e.end()),t);if(t.controls.length===2||qa(t))return Kv(H0(e,t.start()),new oe(t.start(),t.end()));let i=H0(e,t.start());if(qa(i))return z0(new oe(t.start(),e.end()),t);let r=f0(i,t),s=f0(t,i);if(!r&&!s){let n=bN(i,t);if(n.havOverlap){let a=n.havOverlap!==2,o=n.havOverlap!==1;return Xa(e,t,a,o)}else{let a=function(){for(let d=0;d<h;d+=2)ee[d]=c[d],ee[d+1]=c[d+1]},o,l,h=n.cnt,c=new Array(h).fill(0).map((d,f)=>ee[f]);for(let d=0;d<h;d+=2){let f=new ge(ee[d],ee[d+1]),u=i.getPercent(f,ot),p=t.getPercent(f,ot);if(u===0||p===0)continue;let g=u===1?i:i.clip(u)[0],_=p===1?t:t.clip(p)[0];if(f0(g,_)){let y=at(e,f).cross(at(t,f));if(y===0){o=i.end(),l=t.end();break}return{state:y<0?3:4}}a()}return(!o||!l)&&(o=qh(i.controls,i.controls[0],t),l=qh(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return Xa(e,t,r,s)}function Kv(e,t){let i=H0(e,t.start());if(qa(i))return Rl(new oe(i.start(),i.end()),t);let r=Qv(i,t),{isIn:s,bezierIsInLeft:n}=$v(t,i);if(!r&&!s){if(n!==void 0)return{state:n?3:4};let a=null,o=e.getPercent(t.start(),ot)+.01;for(let l=o>1?1:o;l<=1;){let h=Ve.pointOn(l,e.controls);if(ed(t,h)>ts){a=h;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return Xa(i,t,r,s)}function z0(e,t){let{isIn:i,bezierIsInLeft:r}=$v(e,t),s=Qv(t,e);if(!i&&!s){if(r!==void 0)return{state:r?4:3};let n=null;for(let a=.01;a<=1;){let o=Ve.pointOn(a,t.controls);if(ed(e,o)>ts){n=o;break}a+=.01,a>1&&(a=1)}if(!n)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(n.sub(e.start()))<0?3:4}}return Xa(t,e,i,s)}function s4(e,t){let i=q2(ym(e,t.start()),t),r=q2(t,e);if(!i&&!r){let s=kn(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:s.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:s.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let n,a;return e.rx>t.rx?(n=e,a=t):(n=t,a=e),s.dot(a.center.sub(n.center))>0&&a.rx+a.center.distance1(n.center)-n.rx>ot?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>ot&&s.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return Xa(e,t,i,r)}function W2(e,t){let i=Bn.foot(e,t.center),r=e.end().distance2(t.center),s=e.end().sub(e.start()),n=(t.rx-ot)**2,a=r<=(t.rx+ot)**2&&r>=n&&(s.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=n)&&($e(e.end(),t.end())||bm(t,e.end())),o=ex(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=ts?{state:s.cross(kn(t))>0?4:3}:s.dot(i.sub(t.start()))>=0&&(r<n||e.start().distance2(t.center)<n||l<n)?{state:s.cross(t.center.sub(e.start()))<0?4:3}:{state:s.cross(t.center.sub(e.start()))>0?4:3}}return Xa(t,e,a,o)}function ua(e,t){return t=pt.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function bm(e,t){return $e(e.end(),t)||$e(e.start(),t)||ua(e,t.angleD(e.center))}function $v(e,t){let i=e.panDistance(ot),r=e.panDistance(-ot),s=J2(t,i),n=J2(t,r);if(!s.length&&!n.length)return{isIn:t.getPercent(e.end(),ot)!==null};let a=[...s,...n].sort((c,d)=>c.t-d.t),o=new oe(r.start(),i.start()),l=[];for(let c=0,d=a.length;c<d;c++){let f=a[c];if(l.push(f),o.distance(f.interP)>e.length()+ot)break;if(l.length===2){let u=(l[1].t*10+l.shift().t*10)/20,p=Ve.pointOn(u,t.controls);if(e.distance2(p)>ts)return{isIn:!1,bezierIsInLeft:e.direct.cross(p.sub(e.start()))>0}}}let h=l.length?o.distance(l[0].interP)>=e.length()+ot:!0;return{isIn:h,bezierIsInLeft:h?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function Qv(e,t){if(ed(t,e.end())>ts||e.getToLineMaxDis2(t)>ts)return!1;let i=a4(t,ts);return e.getToLineMaxDis2(i)<=(t.length()+ot)**2}function ex(e,t){let i=t.end().angleD(t.start()),r=n4(t,e.end());if(r>ts)return!1;if(ua(e,i+90)){if(Bn.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(ua(e,i-90)){if(Bn.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=ts&&($e(e.end(),t.end())||j0(t,e.end()))}var tx=(ot*2)**2;function ym(e,t){if($e(e.end(),t))return xe.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<tx)return e;let i=pt.regularD(t.angleD(e.center));if(!ua(e,i))throw new Error("!angleIsInArc(arc, angle)");return xe.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function H0(e,t){if($e(e.end(),t))return new Ve([t,t]);if(e.start().distance2(t)<tx)return e;let i=e.getPercent(t,ot);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function X2(e,t){let i=ex(ym(e,t.start()),t),r=t.end().distance2(e.center),s=t.end().sub(t.start()),n=Bn.foot(t,e.center),a=(e.rx-ot)**2,o=r<=(e.rx+ot)**2&&r>=a&&(s.dot(n.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(n)||n.distance2(e.center)>=a)&&($e(e.end(),t.end())||bm(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=ts?{state:s.cross(kn(e,t.start().angle(e.center)))>0?3:4}:s.dot(n.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:s.cross(e.center.sub(t.start()))>0?4:3}:{state:s.cross(e.center.sub(t.start()))<0?4:3}}return Xa(t,e,i,o)}function Rl(e,t){if($e(e.end(),t.end()))return Xa(e,t,!0,!0);let i=ed(t,e.end())<=ts&&j0(t,e.end()),r=ed(e,t.end())<=ts&&j0(e,t.end());if(!i&&!r){let s=e.direct.x===0&&e.direct.y===0,n=t.direct.x===0&&t.direct.y===0;if(s&&n)throw Error("2LineAllIsPoint");return s?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return Xa(e,t,i,r)}function j0(e,t){return Bn.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function Xa(e,t,i,r){if(i)return r?$e(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function ed(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function n4(e,t){return Math.min(e.distance2(t),Bn.foot(e,t).distance2(t))}function a4(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new oe(r.start(),i.start())}function qa(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,s=t.x-i.x,n=-r*t.x-s*t.y,a=Math.sqrt(1/(r**2+s**2));r*=a,s*=a,n*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(h=>{let c=r*h.x+s*h.y+n;c<o&&(o=c),c>l&&(l=c)}),_a(o,l)}function J2(e,t){let i=gn(e,t),r=[],s=new Array(i).fill(0).map((a,o)=>ee[o]);for(let a=0;a<i;a+=2){let o=new ge(ee[a],ee[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),n()}function n(){for(let a=0;a<i;a+=2)ee[a]=s[a],ee[a+1]=s[a+1]}return r}var ha=.01,o4=270;function zo(e){let t=ha**2,i=e.end(),r=[],s=[];for(let u=0,p=e.primitives.length;u<p;u++){let g=function(C,M){return C instanceof oe&&M instanceof oe&&Math.abs(C.direct.cross(M.direct))<we.eps&&C.direct.dot(M.direct)>0||C instanceof xe&&M instanceof xe&&Math.abs(C.rx-M.rx)<=we.eps&&C.center.distance2(M.center)<we.eps&&C.isCCW===M.isCCW},_=function(C){if(Js(C,ha))s.push(null);else{if(C instanceof oe)s.push(C);else if(C instanceof xe&&C.rx===C.ry)d(C,s);else if(C instanceof Ve){let M=[];jv(C,M),M.forEach(H=>{let k=H.start(),F=H.end();c(k,F)||s.push(H)})}else throw new Error("not support!");i=b}},y=function(C){if(C instanceof oe)return C.direct.x===0&&C.direct.y===0;if(C instanceof xe)return C.sweepAngle===0;if(C instanceof Ve){let M=new Set(C.controls.map(k=>k.x)),H=new Set(C.controls.map(k=>k.y));return M.size===1&&H.size===1}else throw new Error("not support")},m=e.primitives[u],O=m.start(),b=m.end();if(y(m))continue;c(i,O)||(s.push(new oe(i,O)),i=O);let v=(u+1)%p,E=e.primitives[v];for(;g(m,E)&&(v=(v+1)%p,E=e.primitives[v],E!==m););if(v===(u+1)%p){_(m);continue}if(E===m){if(!(m instanceof xe)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let C=m instanceof xe?m.isCCW:e.area(.1)>0;s.length=0;let M=C?180:-180;s.push(xe.build3(m.center,m.startAngle,M,m.rx,m.ry),xe.build3(m.center,m.startAngle+M,M,m.rx,m.ry));break}let T=(()=>{if(m instanceof oe)return(C,M)=>{let H=new oe(C,M);return Js(H,ha)?null:[H]};if(m instanceof xe)return(C,M)=>{let H;if(C.equals1(M)?H=xe.build3(m.center,m.startAngle,m.sweep()===1?360:-360,m.rx,m.ry):H=xe.build4(C,M,m.center,m.rx,m.ry,m.sweep()),Js(H,ha))return null;let k=H.pointOn(H.startAngle+H.sweepAngle/2),F=xe.build4(H.start(),k,m.center,m.rx,m.ry,m.sweep()),j=xe.build4(k,H.end(),m.center,m.rx,m.ry,m.sweep());return Js(F,ha)||Js(j,ha)?[H]:[F,j]};throw new Error("not support")})(),P=v===0;if(v<u&&!P&&(P=!T(e.primitives[0].start(),e.primitives[v-1].end()),!P)){let C=T(m.start(),e.primitives[p-1].end());if(C)s.push(...C);else{let M=T(m.start(),s[0].end());if(M.length===1)s[0]=M[0];else if(M.length===2)s[0]=M[1],s.push(M[0]);else throw new Error("!!!generatorPt")}break}u=v===0?p-1:v-1,E=e.primitives[u];let A=T(m.start(),E.end());if(A?(A.forEach(C=>s.push(C)),i=E.end()):_(null),P)break}let n=s.length;if(s.forEach((u,p)=>{if(u)r.push(u);else{let g,_;p===n-1&&(g=r[0],_=r[r.length-1]);let y=(p+1)%n;if(g=g!=null?g:s[y],g){let m=p,O=!1;for(;_=_!=null?_:s[(--m+n)%n],_!==g;)if(_){O=!0;break}if(O){if(g.start().equals1(_.end()))return;if(at(_,_.end()).dot(at(g,g.start()))<0){if(!c(_.end(),g.start())){let T=new oe(_.end(),g.start());r.push(T);return}let{rebuildPrevPt:b,rebuildNextPt:v,rebuildLinkLine:E}=Z2(s[(m-1+n)%n],_,new oe(_.end(),g.start()),g,s[(p+2)%n]);b&&v&&(b!==_?(s[(m+n)%n]=b,r[r.length-1]&&(r[r.length-1]=b)):v!==g&&(s[(p+1)%n]=v,r[0]===g&&(r[0]=v)),E&&r.push(E))}}}}}),r.length===0)return null;c(i,r[0].start())||r.push(new oe(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof xe?Pt.build7([xe.build2(a.center,0,180,a.rx,a.ry,a.sweep()),xe.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof Ve?Pt.build7(a.clip(.5)):null;let o=r.map(u=>new l4(u)),l=o[o.length-1];for(o.forEach(u=>{u.connect(l),l=u});!l.isVisited;){let u=function(){l.next.connect(g),l=l.next,l.isConnected=!1,l.isVisited=!1},p=function(){l.connect(g.prev),l.isConnected=!1},g=l.prev;if(l===g)break;let _=l.pt,y=g.pt,m=y.end();if(!l.isConnected&&!m.equals(_.start())){let O=function(v){l.isConnected=!0,l.pt=_=v,l.next.isVisited=!1},b=function(v){l.isConnected=!0,g.pt=v,g.isVisited=!1,l=g};if(_ instanceof oe)if(c(m,_.end())){u();continue}else O(new oe(m,_.end()));else if(y instanceof oe){c(y.start(),_.start())?p():b(new oe(y.start(),_.start()));continue}else if(_ instanceof Ve)if(c(m,_.end())&&!(_.controls.length!==2&&_.getToLineMaxDis2(_.startToEndL)>=t)){u();continue}else O(new Ve([m,..._.controls.slice(1)]));else if(y instanceof Ve)c(y.start(),_.start())&&!(y.controls.length!==2&&y.getToLineMaxDis2(y.startToEndL)>=t)?p():b(new Ve([...y.controls.slice(0,-1),_.start()]));else if(_ instanceof xe&&y instanceof xe)if(Math.abs(Math.abs(_.sweepAngle)-180)<Math.abs(Math.abs(y.sweepAngle)-180)){let v=xe.build5(m,_.end(),_.sweepAngle);if(c(v.start(),v.end())&&!(v.rx>=ha&&Math.abs(v.sweepAngle)>180)){u();continue}else O(v)}else{let v=xe.build5(y.start(),_.start(),y.sweepAngle);c(v.start(),v.end())&&!(v.rx>=ha&&Math.abs(v.sweepAngle)>180)?p():b(v);continue}else throw new Error("not support")}if(at(_,_.start()).dot(at(y,y.end()))<0){let O=function(E,T,P,A,C,M){if(l.next===g){l=null;return}let{rebuildLinkLine:H,rebuildPrevPt:k,rebuildNextPt:F}=Z2(E,T,P,A,C);k&&F&&(k!==T&&(g.prev.pt=k),F!==A&&(l.next.pt=F),H?M.pt=H:u())},b=function(){l.next===g?l=null:(l.next.connect(g.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},v=es(y.reverse(),_).state;if(v===0){let E=K2(_,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(at(P,P.start()).dot(at(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof oe?E:new oe(E.start(),E.end()),P,l.next.next.pt,l),!l)break}else l.pt=E;p();continue}else if(v===1){let E=K2(y,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(at(P,P.start()).dot(at(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof oe?E:new oe(E.start(),E.end()),P,l.next.next.pt,g),!l)break}else g.pt=E;u();continue}else if(v===2){if(b(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let h=l;for(r.push(l.pt),l=l.next;l!==h;)r.push(l.pt),l=l.next;if(r.length===1){let u=r[0];return u instanceof xe?(c(u.start(),u.end())?r[0]=xe.buildCircle(u.center,u.rx,u.sweep()):r.push(new oe(u.end(),u.start())),Pt.build7(r)):u instanceof Ve?(c(u.start(),u.end())||r.push(new oe(u.end(),u.start())),Pt.build7(r)):null}if(e=Pt.build7(r),Math.abs(e.area(.1))<t)return null;return e;function c(u,p){return u.distance2(p)<t}function d(u,p){if(Math.abs(u.sweepAngle)>o4){let g=u.sweepAngle/2;d(xe.build3(u.center,u.startAngle,g,u.rx,u.ry),p),d(xe.build3(u.center,u.startAngle+g,g,u.rx,u.ry),p)}else p.push(u)}function f(u){return u.start().distance2(u.end())<t&&!(u instanceof xe&&u.rx>=ha&&Math.abs(u.sweepAngle)>180||u instanceof Ve&&u.controls.length!==2&&u.getToLineMaxDis2(new oe(u.start().add1(1,0),u.end()))>=t)}}function Js(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof xe){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof Ve){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new oe(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function Rh(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(ha-e.length())+we.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new ge(r.x+i.x,r.y+i.y)}function Z2(e,t,i,r,s){if(!e)a();else if(!s)o();else{let l=at(e,e.end()),h=at(t,e.end()),c=l.dot(h);if(c>=0)a();else{let d=at(r,r.end()),f=at(s,r.end()),u=d.dot(f);if(u>=0)o();else if(_a(c,-1)&&_a(u,-1)){let p=i.center();n(p),i=null}else c>u?a():o()}}function n(l){let h;if(t instanceof oe)h=new oe(t.start(),l);else if(t instanceof Ve)h=new Ve([...t.controls.slice(0,-1),l]);else if(t instanceof xe)h=xe.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=Js(h,ot)?null:h;let c;if(r instanceof oe)c=new oe(l,r.end());else if(r instanceof Ve)c=new Ve([l,...r.controls.slice(1)]);else if(r instanceof xe)c=xe.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=Js(c,ot)?null:c}function a(){if(t instanceof oe){let l=Rh(i.reverse());i=new oe(l,i.end());let h=new oe(t.start(),l);t=Js(h,ot)?null:h}else if(t instanceof Ve){let l=Rh(i.reverse());i=new oe(l,i.end());let h=new Ve([...t.controls.slice(0,-1),l]);t=Js(h,ot)?null:h}else if(t instanceof xe){let l=Rh(i.reverse());i=new oe(l,i.end());let h=xe.build5(t.start(),l,t.sweepAngle);t=Js(h,ot)?null:h}else throw new Error("not supported")}function o(){if(r instanceof oe){let l=Rh(i);i=new oe(i.start(),l);let h=new oe(l,r.end());r=Js(h,ot)?null:h}else if(r instanceof Ve){let l=Rh(i);i=new oe(i.start(),l);let h=new Ve([l,...r.controls.slice(1)]);r=Js(h,ot)?null:h}else if(r instanceof xe){let l=Rh(i);i=new oe(i.start(),l);let h=xe.build5(l,r.end(),r.sweepAngle);r=Js(h,ot)?null:h}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function K2(e,t,i){if(e instanceof oe||t.distance2(i)<=ts)return new oe(t,i);if(e instanceof xe)return xe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ve){let r=e.getPercent(t,ot),s=e.getPercent(i,ot);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}var l4=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function Jp(e){let t=fd(),i;if(e instanceof Pt){let r=zo(e);if(r===null)return null;i=r}else if(e instanceof nr){let r=e.items.map(s=>Jp(s)).filter(s=>s!==null);if(r.length===0)return null;i=new nr(r)}else{let r=e.items.map(s=>Jp(s)).filter(s=>s!==null);if(r.length===0)return null;i=new Ui(r)}return fa.preprocessPolyline+=ko(t),i}var fa={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function fd(){return{timeIndex:Object.assign({},fa),start:performance.now()}}function $2(e){return Object.values(e).reduce((t,i)=>t+i,0)}function ko(e){return performance.now()-e.start-($2(fa)-$2(e.timeIndex))}function vr(e,t,i,r){let s=Gt.RED,n=Gt.Golden;function a(){if(!r)return;let f=r.initColor(Gt.Golden);f.addPt(o),f.addPoint(o.end()),r.initColor(Gt.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),h=at(o,l.start()),c=at(l),d=h.cross(c);if(_a(d,0))if(o instanceof oe)if(l instanceof oe){if(we.eq(d,0)&&(h.dot(c)>0?!$e(o.end(),l.start()):!$e(o.start(),l.start())))throw a(),new Error("line and line");return d<0}else{if(l instanceof xe)return h.cross(l.center.sub(o.start()))<0;if(l instanceof Ve){let f=l.getExtremePoints(o),u=f.length?f[0]:qh(l.controls,o.start());return h.cross(u.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof xe){if(l instanceof oe)return o.isCCW;if(l instanceof xe){if(l.center.equals1(o.center)&&(h.dot(c)>0?!$e(o.end(),l.start())&&o.end().sub(l.start()).dot(c)>0:!$e(o.start(),l.start())&&o.start().sub(l.start()).dot(c)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof Ve)if(l instanceof oe){let f=o.getPercent(l.start(),ot),u=o.clip(f)[1],p=u.getExtremePoints(l);return(p.length?p[0]:qh(u.controls,l.start())).sub(l.start()).cross(c)<0}else if(l instanceof Ve){let f=o.getPercent(l.start(),ot),u=o.clip(f)[1],p=u.getExtremePoints(new oe(l.start(),l.end())),g=l.getExtremePoints(new oe(u.start(),u.end())),_=p.length?p[0]:qh(u.controls,l.start()),y=g.length?g[0]:qh(l.controls,l.start()),m=_.sub(l.start()),O=y.sub(l.start());return m.cross(O)<0}else throw Error("not support");else throw new Error("not support");else return d<0}function kl(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof xe?kn(n,pt.toRadians(n.endAngle())):n instanceof Ve?$u(n,1):n.end().sub(n.start()).normalize(),l=at(a),h=o.dot(l);if(_a(h,-1))return vr(e,t,!0,s)?vr(e,i,r,s)&&vr(t,i,r,s):vr(e,i,r,s)||vr(t,i,r,s);{let c=o.scale(-1).angle(ge.ORIGIN),d=l.angle(ge.ORIGIN);c>d&&(c-=cg);let f=(c+d)/2,u=new ge(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=at(p);return u.cross(g)<0?vr(e,i,r,s):vr(t,i,r,s)}}function p0(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof xe?kn(n,pt.toRadians(n.endAngle())):n instanceof Ve?$u(n,1):n.end().sub(n.start()).normalize(),l=at(a),h=o.dot(l);if(_a(h,-1))return vr(e,t,!0,s)?vr(e,i,r,s)&&vr(t,i,r,s):vr(e,i,r,s)||vr(t,i,r,s);{let c=o.scale(-1).angle(ge.ORIGIN),d=l.angle(ge.ORIGIN);c>d&&(c-=cg);let f=(c+d)/2,u=new ge(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=at(p);if(u.cross(g)<0){let _=o.dot(g)<0,y=es(_?e.getShape().reverse():e.getShape(),p).state;return y!==3&&y!==4?vr(e,i,r,s):y===(_?4:3)}else{let _=l.dot(g)<0,y=es(_?t.getShape().reverse():t.getShape(),p).state;return y!==3&&y!==4?vr(t,i,r,s):y===(_?4:3)}}}var h4=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(h4||{}),c4=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(c4||{}),da,Uo=!1;function Zs(e,t,i,r,s,n,a,o=i.side===t,l=!0,h){return da=s,Uo=n,ix(rx(e,t,l,h,a,i,o,r),i,o,r,0)}function ja(e,t,i,r,s,n,a,o=r.side===i){da=s,Uo=n;let l=sx(e,t,i,new Map,r,o,a),h=l instanceof Array?-1:1;return ix(l,r,o,a,h)}function ix(e,t,i,r,s){for(;e instanceof Array;)s++,e.length===4?e=sx(...e,t,i,r):e=rx(...e,t,i,r);return{...e,existOverlap:s>0}}function rx(e,t,i,r,s,n,a,o){if(Zp===-1){o.initColor(Gt.RED).addPt(e.getShape()),o.initColor(Gt.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),h=a?t.getShape().reverse():t.getShape(),c=(l instanceof xe?kn(l,i?h.start().angle(l.center):r?pt.toRadians(l.endAngle()):void 0):l instanceof Ve?at(l,i?h.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),d=(h instanceof xe?kn(h,i?void 0:(r?l.end():l.start()).angle(h.center)):h instanceof Ve?at(h,i?void 0:r?l.end():l.start()):h.end().sub(h.start())).normalize();if(r===void 0){let p=c.dot(d);if(r=p<0,_a(p,0))return{state:vr(e,t,!a,o)?1:0,inter:Va(e,t,n,a,i,r,s)}}else if(r?c.dot(d)>0:c.dot(d)<0)if(i){let p,g=!0;if(l instanceof oe&&$e(Bn.foot(l,h.start()),r?l.end():l.start()))g=!1;else if(l instanceof xe||l instanceof Ve){let _=r?l.reverse():l,y=es(h,wN(_,h.start()).reverse()).state;(y===1||y===2)&&(g=!1)}if(g){let _=!r;p=es(_?l.reverse():l,h,o).state===(_?4:3)?1:0}else r?p=kl(e,e.nextSide,t,!a,o)?1:0:p=kl(e.prevSide,e,t,!a,o)?1:0;return{state:p,inter:Va(e,t,n,a,i,r,s)}}else return r?{state:vr(e,e.nextSide,!0,o)?0:1,inter:Va(e,t,n,a,i,r,s),isReversed:!0}:{state:vr(e.prevSide,e,!0,o)?0:1,inter:Va(e,t,n,a,i,r,s),isReversed:!0};let f,u=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!Uo){let p=e.judgeOverlapMap.get(t);f=r?u.get(p.state):p.state}else f=es(r?l.reverse():l,h).state,(f===3||f===4)&&e.judgeOverlapMap.set(t,{state:r?u.get(f):f});else{if(t.judgeOverlapMap.has(e)&&!Uo){let p=t.judgeOverlapMap.get(e);f=a?u.get(p.state):p.state}else f=es(h,r?l.reverse():l).state,(f===3||f===4)&&t.judgeOverlapMap.set(e,{state:a?u.get(f):f});f=u.get(f)}if(f===1||f===2){let p=a?t.prevSide:t,g=p.inters,_=p.getEnd();for(let y=g.length-1;y>=0;y--){let m=g[y];if(!(p.getShape()instanceof Ve)&&!$e(_,m.coord))break;if(m===n)return{state:2,inter:Va(e,t,n,a,i,r,s)}}}if(f===3||f===4)return{state:f===(r?4:3)?1:0,inter:Va(e,t,n,a,i,r,s)};if(s.has(e)?s.get(e).mapSideList.push(t):s.set(e,{sideIsReversed:r,mapSideList:[t]}),s.has(t)?s.get(t).mapSideList.push(e):s.set(t,{sideIsReversed:a,mapSideList:[e]}),f===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,s]:[e,e.nextSide,a?t.prevSide:t.nextSide,s];if(f===0)return[r?e.prevSide:e.nextSide,t,!1,r,s];if(f===1)return[e,a?t.prevSide:t.nextSide,!0,r,s];throw Error("not support")}function Va(e,t,i,r,s,n,a){if(Uo)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),h=r;if(!s){let u=t;t=e,e=u,r=n,i=i.getBindedInter()}let c=u=>!(s?n:h)&&$e(u,e.prevSide.getEnd())?e.prevSide:e;if(r){let u=t.inters;for(let p=0;p<u.length;p++){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&$e(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.nextSide;let p=t.inters;for(let g=0;g<p.length;g++){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||$e(_.coord,y.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(a.has(y)){let m=t.getShape().reverse(),O=at(m,_.coord).dot(at(y.getShape(),_.coord))<0,b=O?y.getShape().reverse():y.getShape(),v=es(m,O?l0(b,_.coord,b.end()):l0(b,b.start(),_.coord)).state;if(v===1||v===2)return f(_)}else a.has(y.nextSide)}else if(_.side===i.side&&d(_))return f(_)}}}else{let u=t.inters;for(let p=u.length-1;p>=0;p--){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&$e(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.prevSide;let p=t.inters;for(let g=p.length-1;g>=0;g--){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||$e(_.coord,_.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(!a.has(y)&&a.has(y.prevSide)){let m=t.getShape().reverse(),O=at(m,_.coord).dot(at(y.getShape(),_.coord))<0;if(a.has(y.prevSide)){let b=O?y.getShape().reverse():y.getShape(),v=es(t.getShape(),l0(b,_.coord,b.end())).state;if(v===1||v===2)return f(_)}}}else if(_.side===i.side&&d(_))return f(_)}}}function d(u){if(u.isInvalid||u.getBindedInter().side!==($e(u.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let p;if(s){if($e(u.coord,l.start()))return!0;p=es(n?o.reverse():o,g(l)).state}else{if($e(u.coord,n?o.end():o.start()))return!0;p=es(l,g(n?o.reverse():o)).state}return p===2||p===1;function g(_){if(_ instanceof oe)return $e(u.coord,_.end())?_:_.cutLine(u.coord);if(_ instanceof xe)return xe.build2(_.center,_.startAngle,u.coord.angleD(_.center),_.rx,_.ry,_.isCCW?1:0);if(_ instanceof Ve)return _.clip(_.getPercent(u.coord,ot))[0];throw new Error("not supported operation")}}function f(u){let p=i.getBindedInter(),g=i.side,_=p.side,y=i===u,m=i;if(r){let O=i.getIndex()-1;for(;g;){let b=g.inters;for(;O>=0;O--)if(i=b[O],i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(da===0)!i.isInvalid&&(!$e(i.coord,u.coord)||i.side===u.side&&i.getBindedInter().side===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(da===1){if(i.isInvalid)continue;let v=i.getBindedInter().side;a.has(g)&&a.get(g).mapSideList.includes(v)&&(i.setIsInvalid(),i.isDealed(),m=i)}g=g==null?void 0:g.prevSide,O=(g==null?void 0:g.inters.length)-1}}else{let O=i.getIndex()+1;for(;g;){let b=g.inters;for(;O<b.length;O++){i=b[O];let v=i.getBindedInter();if(i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(da===0)!i.isInvalid&&(!$e(i.coord,u.coord)||g===u.side&&($e(v.side.getEnd(),i.coord)?v.side.nextSide:v.side)===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(da===1){let E=v.side;a.has(g)&&a.get(g).mapSideList.includes(E)&&(i.setIsInvalid(),i.isDealed(),m=i)}}g=g==null?void 0:g.nextSide,O=0}}if(da===0&&!$e(p.coord,u.coord))if(s?a.has(_)?a.get(_).sideIsReversed:n:h){let O=p.getIndex()-1;for(;_;){let b=a.has(_),v=_.inters;for(;O>=0;O--){if(p=v[O],p===u.getBindedInter()){_=null;break}p.isInvalid||!b||(!$e(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.prevSide,O=(_==null?void 0:_.inters.length)-1}}else{let O=p.getIndex()+1;for(;_;){let b=_.inters,v=a.has(_);for(;O<b.length;O++){if(p=b[O],p===u.getBindedInter()){_=null;break}let E=$e(_.getEnd(),p.coord)?a.has(_.nextSide):!1;p.isInvalid||!(v||E)||(!$e(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.nextSide,O=0}}return s?m:m.getBindedInter()}}function sx(e,t,i,r,s,n,a){let o=e.getShape(),l=t.getShape(),h=n?i.getShape().reverse():i.getShape(),c=(o instanceof xe?kn(o,h.start().angle(o.center)):o instanceof Ve?at(o,h.start()):o.end().sub(o.start())).normalize(),d=(l instanceof xe?kn(l,h.start().angle(l.center)):l instanceof Ve?at(l,h.start()):l.end().sub(l.start())).normalize(),f=c.dot(d);if(_a(f,-1)){let u=n?i.getShape().reverse():i.getShape(),p=at(u).normalize(),g=c.add(d.scale(-1)).normalize().dot(p),_=es(o.reverse(),l,a).state;if(g>-.9&&(_===3||_===4))return{state:_===4?0:1,inter:Va(t,i,s,n,!0,!1,r)};let y=Zs(e,i,s,a,da,Uo,r.size===0?new Map:r,n);return y.state===2?y:_===4?y.state===0||y.inter!==s?y:Zs(t,i,s,a,da,Uo,r.size===0?new Map:r,n):y.state===1||y.inter!==s?y:Zs(t,i,s,a,da,Uo,r.size===0?new Map:r,n)}else{let u=c.scale(-1).angle(ge.ORIGIN),p=d.angle(ge.ORIGIN);u>p&&(u-=cg);let g=(u+p)/2,_=new ge(Math.cos(g),Math.sin(g)),y=at(h).normalize(),m=y.angle(ge.ORIGIN),O=u<m&&m<p&&o instanceof oe&&l instanceof oe&&h instanceof oe;if(_.cross(y)<=0){if(c.scale(-1).dot(y)<0){let b;return s.coord.equals1(h.start())?b=at(o,s.coord).dot(at(h,s.coord))<0:h instanceof oe&&(b=at(o,o.end()).dot(h.direct)<0),{state:kl(e,t,i,!n,a)?1:0,inter:Va(e,i,s,n,!0,b,r)}}return O&&o.distance2(h.start())>ts?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return d.dot(y)<=0?{state:kl(e,t,i,!n,a)?1:0,inter:Va(t,i,s,n,!0,void 0,r)}:O&&l.distance2(h.start())>ts?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var Zp=0;function u4(e,t,i,r){let s=t.getBindedInter(),n=t.side,a=s.side,o=n.getShape(),l=a.getShape();if(r&&(Zp++,Zp===-1)){r.initColor(Gt.RED).addPt(o),r.initColor(Gt.Golden).addPt(l),r.draw();debugger}let h=0,c=!1;if(e===-1){let T=ja(n,n.nextSide,a,s,h,c,r),P=T.state!==0;if(T.state===2){let C=at(o,t.coord).add(at(n.nextSide.getShape(),t.coord)).normalize(),M=at(l,t.coord).add(at(a.nextSide.getShape(),t.coord)).normalize();return E(P,C.dot(M)>0)}let A=ja(n,n.nextSide,a.nextSide,s,h,c,r);return T.state!==A.state?(v(T,A),1):E(P,T.state!==ja(a,a.nextSide,n,t,h,!0,r).state,T.inter,A.inter)}if(e===1){let T=Zs(n,a,s,r,h,c,new Map),P=T.state!==0;if(T.state===2)return E(P,at(o,t.coord).dot(at(l,t.coord))>0);let A;if(T.isReversed&&T.existOverlap&&$e(T.inter.coord,a.getEnd())&&T.inter.getBindedInter().side!==n){let H=T.inter.getBindedInter().side;if(H===n.nextSide)A={state:kl(n,H,a.nextSide,!0,r)?1:0,inter:s};else if(H===n.prevSide){if(A={state:kl(H,n,a.nextSide,!0,r)?1:0,inter:T.inter},T.state===A.state&&t!==T.inter){let k=at(l,t.coord),F=at(a.nextSide.getShape(),t.coord),j=at(H.getShape(),t.coord);return E(P,k.add(F).dot(j)>0,T.inter,A.inter)}}else A=Zs(n,a.nextSide,s,r,h,c,new Map)}else A=Zs(n,a.nextSide,s,r,h,c,new Map);if(T.state!==A.state)return v(T,A),1;let C=at(l,t.coord),M=at(a.nextSide.getShape(),t.coord);if(_a(C.dot(M),-1)){let H=vr(a,a.nextSide,!0,r);return E(P,T.state!==Zs(a.nextSide,n,t,r,h,!0,new Map,H?!P:P,!1).state,T.inter,A.inter)}else{let H=at(o,t.coord);return E(P,C.add(M).dot(H)>0,T.inter,A.inter)}}if(!(o instanceof Ve||l instanceof Ve))return 1;let d=at(o,t.coord),f=at(l,t.coord),u,p;if(l instanceof oe)u=new oe(t.coord,l.start()),p=new oe(t.coord,l.end());else if(l instanceof xe){let T=t.coord.angleD(l.center);u=xe.build2(l.center,T,l.startAngle,l.rx,l.ry,l.isCCW?0:1),p=xe.build2(l.center,T,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof Ve){let T=l.getPercent(t.coord,ot);[u,p]=l.clip(T),u=u.reverse()}else throw new Error("not support");let g=d.dot(f)>0,_,y;g?(_=es(o.reverse(),u).state,y=es(o,p).state):(_=es(o,u).state,y=es(o.reverse(),p).state);let m;_===0?m=Zs(g?n.prevSide:n.nextSide,a,s,r,h,c,new Map,!0,!1,g):_===1?m=Zs(n,a.prevSide,s,r,h,c,new Map,!0,!0,g):_===2?g?m=ja(n.prevSide,n,a.prevSide,s,h,c,r,!0):m=ja(n,n.nextSide,a.prevSide,s,h,c,r,!0):g?_===3?m={inter:s,state:0}:m={inter:s,state:1}:_===3?m={inter:s,state:1}:m={inter:s,state:0};let O=m.state!==0;if(m.state===2)return E(O,g);let b;if(y===0?b=Zs(g?n.nextSide:n.prevSide,a,s,r,h,c,new Map,!1,!1,!g):y===1?b=Zs(n,a.nextSide,s,r,h,c,new Map,!1,!0,!g):y===2?g?b=ja(n,n.nextSide,a.nextSide,s,h,c,r,!1):b=ja(n.prevSide,n,a.nextSide,s,h,c,r,!1):g?y===3?b={inter:s,state:1}:b={inter:s,state:0}:y===3?b={inter:s,state:0}:b={inter:s,state:1},m.state===b.state)return m.inter===b.inter?(t.setIsInvalid(),0):E(O,g,m.inter,b.inter);return v(m,b),1;function v(T,P){let A=T.state!==0;if(T.inter===P.inter){t.setOutToIn(A);return}else Nh(T.inter,P.inter,!0),Nh(P.inter,T.inter,!1);let C=[];if(e===-1){let H=at(o,t.coord),k=at(n.nextSide.getShape(),t.coord),F=at(l,t.coord),j=at(a.nextSide.getShape(),t.coord);C.push(H.dot(F)),C.push(H.dot(j)),C.push(k.dot(F)),C.push(k.dot(j))}else{let H=at(o,t.coord);C.push(at(l,t.coord).dot(H)),C.push(at(a.nextSide.getShape(),t.coord).dot(H))}if(C.reduce((H,k)=>Math.abs(H)>Math.abs(k)?H:k,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(A);else throw new Error("not support");else if(i===1)M(!A);else if(i===0||i===2||i===3)M(A);else throw new Error("not support");function M(H){t.setIsInvalid();let k=(H?T:P).inter;delete k.isInvalid,delete k.getBindedInter().isInvalid,k.setOutToIn(!A)}}function E(T,P,A,C){if(A===C){if(t.side.outline.inters.find(k=>!k.isInvalid&&k!==t&&$e(k.coord,t.coord)))return t.setIsInvalid(),0;let M=new Ya(t.coord,n,r),H=new Ya(t.coord,a,r);return M.bind(H),P?n.inters.splice(t.getIndex(),0,M):n.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,H),M.setOutToIn(T),t.setOutToIn(!T),M.isDealed(),n.inters.forEach((k,F)=>k.setIndex(F)),a.inters.forEach((k,F)=>k.setIndex(F)),2}else{let M=function(){let H=A.getBindedInter(),k=C.getBindedInter();delete A.isInvalid,delete H.isInvalid,delete C.isInvalid,delete k.isInvalid,A.setOutToIn(!T),C.setOutToIn(T),Nh(A,C,!0),Nh(C,A,!1),Nh(H,k,P),Nh(k,H,!P)};if(t.setIsInvalid(),P){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return T?0:(M(),2);if(i===0||i===2||i===3)return T?(M(),2):0;throw new Error("not support")}}}}function Nh(e,t,i){let{judge:r,changeNum:s}=a(),n=e.getIndex();for(let o=n+s,l=e.side.inters;r(o);o+=s){if(l[o].isInvalid)continue;if(!$e(l[o].coord,e.coord))break;l[o].setIndex(n),l[n].setIndex(o);let h=l[o];l[o]=l[n],l[n]=h,n=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:h=>h<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:h=>h>=l,changeNum:-1}}}}var Q2=0,Ya=class{constructor(e,t,i){this.id=Q2++,this.coord=e,this.side=t,i&&(this.id=Q2++,this.drawDebug=i);let r=new Cs;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof oe)return e.end().sub(e.start());if(e instanceof xe){let t=this.coord.angle(e.center);return e.isCCW?t+=jp:t-=jp,new ge(Math.cos(t),Math.sin(t))}else{if(e instanceof Ve)return $u(e,e.getPercent(this.coord,ot));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){g0++;let r=g0===-1,s=this.drawDebug.initColor(Gt.RED);if(r){this.drawDebug.draw();debugger}i=n=>{if(e.push(n),r){s.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(we.eq(o.distance2(l),0))return;let h=dd.rebuild(n.getShape(),o,l);if(!h)return!0;i(h)};t.visit();let s=t.getIndex(),n=t.side,a=n.inters[s+1];for(;a!=null&&a.isInvalid;)a=n.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,n.getEnd()),l=t.coord;for(n=n.nextSide,t=null;;){for(let h of n.inters)if(!h.isInvalid){t=h.bindedInter;break}if(t)break;o?(r(l,n.getEnd()),o=!1):i(n.getShape()),n=n.nextSide}o?(we.eq(l.distance2(t.coord),0)?r(l,n.getEnd()):r(l,t.coord),o=!1):we.eq(n.getEnd().distance2(t.coord),0)?i(n.getShape()):r(n.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:g0,handleId:Zp,boolId:zu})),new Error("inter !== this");return zo(Pt.build7(e))}},g0=0,_0=class V0{constructor(t,i,r,s,n){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=s,this.finalIsOutside=s,this.polyline=i,n&&(this.polygon=n),t.forEach(a=>a.outline=this)}static build(t,i,r,s,n){let a=t.primitives.map(l=>new dd(l,s)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),n?new V0(a,t,i,r,n):new V0(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,s;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,s=t.interOutlines):(r=t.interOutlines,s=this.interOutlines),s.forEach(n=>{r.push(n),n.interOutlines=r}),i.delete(s)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(ot).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(s=>!r.has(s)))return this.polyline}return Pt.build7(t)}};function ev(e,t,i){let r=[];return e.forEach(s=>s.forEach(n=>{if(n.hasInter&&!n.isAllInterIsInvalid())return;let a=n.bbox(),o=t.search(a.extendOfSize(ot)).filter(l=>l.bbox().extendOfSize(ot).isContainsBBox(a)).sort((l,h)=>l.bbox().area()-h.bbox().area());for(let l of o)if(l.isContain(n)){let h=i(!n.isOutside,l.isOutside),c=i(n.isOutside,l.isOutside);h!==c&&(r.push(n),n.setFinalIsOutSide(!h));return}i(n.isOutside,!1)!==i(!n.isOutside,!1)&&r.push(n)})),r}function d4(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let s=new Qu(10),n=new Qu(10);e.forEach(o=>o.forEach(l=>s.add(l))),t.forEach(o=>o.forEach(l=>n.add(l)));let a=ev(e,n,r);return ev(t,s,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var f4=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new p4(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let s=this.nodes[i];if(t.key.bbox().maxX<s.key.bbox().minX)break;s.getIsVisit()||t.isContain(s)&&(s.visit(),t.addChild(s),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},p4=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(n=>n.returnPolyline()),s=new Set(i.items);return r.some(n=>!s.has(n))?new nr(r):i}else return new nr(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function tv(e){let t="";return e.items.forEach((i,r)=>{let s="$";if(i.items.forEach((n,a)=>{let o="[";if(n.primitives.forEach((l,h)=>{let c="";if(l instanceof oe)c=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof xe)c=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof Ve)c=`Bezier,${l.controls.map(d=>`${d.x},${d.y}`).join(",")}`;else throw new Error("not supported");if(h===n.primitives.length-1){o+=`${c}]`;return}o+=`${c},`}),a===i.items.length-1){s+=`${o}$`;return}s+=`${o}_`}),r===e.items.length-1){t+=`${s}`;return}t+=`${s}^`}),console.log(t),t}function iv(e){let t=e.split("^"),i=[];return t.forEach(s=>{let n=/\$(.*?)\$/,a=s.match(n)[1].split("_"),o=[];a.forEach(h=>{let c=/\[(.*?)\]/,d=h.match(c)[1].split(","),f=[],u=[];for(let g=0;g<d.length;g++){let _=d[g];if(_==="Line"||_==="Arc"||_==="Bezier"){if(f.length){let y=r(f);u.push(y),f.length=0}f.push(_);continue}f.push(Number(_))}f.length&&(u.push(r(f)),f.length=0);let p=Pt.build7(u);o.push(p)});let l=new nr(o);i.push(l)}),new Ui(i);function r(s){let n=s[0];if(n==="Line")return new oe(new ge(s[1],s[2]),new ge(s[3],s[4]));if(n==="Arc")return xe.build3(new ge(s[1],s[2]),s[3],s[4],s[5],s[5]);if(n==="Bezier"){let a=[];for(let o=1;o<s.length;o+=2)a.push(new ge(s[o],s[o+1]));return new Ve(a)}else throw new Error("not support")}}var g4=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return iv(this.group1Str)}getGroup2(){return iv(this.group2Str)}},O0=new hg(2),Gu=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),$N(RN,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new Xu(!1),r=new Ju(Cp.rule,O0,i);for(let s of e){let n=Cp.weight(0);r.addPolyline(s,n)}for(let s of t){let n=Cp.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new Xu(!1),r=new Ju(Lp.rule,O0,i);for(let s of e){let n=Lp.weight(0);r.addPolyline(s,n)}for(let s of t){let n=Lp.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new Xu(!1),r=new Ju(c0.rule,O0,i);for(let s of e){let n=c0.weight(0);r.addPolyline(s,n)}for(let s of t){let n=c0.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}},zu=0,m0=!1;function Hu(e,t,i,r,s){let n=fd(),a=[],o=[],l=[],h=new Set,c;if(s){if(c=new ud(s),zu++,m0){debugger;m0=!1;let b=new g4;Hu(b.rule,b.getGroup1(),b.getGroup2(),r,s)}if(zu===-1||m0){console.table({rule:e,group1:tv(t),group2:tv(i)}),c.clear();let b=c.initColor(Gt.GREEN),v=c.initColor(Gt.WHITE),E=c.initColor(Gt.BLUE),T=c.initColor(Gt.Gray);t.items.forEach(P=>P.items.forEach((A,C)=>{C>0?v.addPly(A):b.addPly(A)})),i.items.forEach(P=>P.items.forEach((A,C)=>{C>0?T.addPly(A):E.addPly(A)})),c.draw();debugger}}let d=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(ot).intersection1(i.bbox().extendOfSize(ot)):null;if(d){let b=[],v=[];switch(e){case 0:{for(let E of t.items)E.bbox().isIntersect(d)&&b.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}case 1:case 3:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)?v.push(E):a.push(E);break}case 2:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}default:throw new Error("not support")}b.length!==t.items.length&&(t=new Ui(b)),v.length!==i.items.length&&(i=new Ui(v))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(b=>a.push(b)),i.items.forEach(b=>a.push(b));break}case 2:{t.items.forEach(b=>a.push(b));break}default:throw new Error("not support")}t=new Ui([]),i=new Ui([])}m(t,o,!0),m(i,l,!1);let f=e===2||e===3?(b,v)=>$e(b.getEnd(),v)?b.nextSide:b:(b,v)=>$e(b.prevSide.getEnd(),v)?b.prevSide:b,u=(b,v,E)=>{if($e(b.getEnd(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&$e(T.coord,b.getEnd()))===-1)return new Ya(E,b,c)}else return new Ya(E,b,c)},p=e===2||e===3?(b,v,E)=>{if($e(b.getStart(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&$e(T.coord,b.getStart()))===-1)return new Ya(E,b,c)}else return new Ya(E,b,c)}:u;r.seek(t,i,(b,v,E,T,P,A)=>{let C=o[b][v],M=l[T][P],H=C.sides[E],k=M.sides[A],F=gn(H.getShape(),k.getShape());if((H.getShape()instanceof Ve||k.getShape()instanceof Ve)&&F>=4){if(H.getShape()instanceof xe||k.getShape()instanceof xe){let L=function(x,I){let S=!1;for(let D=0;D<I.length;D+=2)$e(new ge(I[D],I[D+1]),x)&&(S=!0);S||I.push(x.x,x.y)},R=[ee[0],ee[1]];for(let x=0;x<F;x+=2){let I=new ge(ee[x],ee[x+1]);for(let S=x+2;S<F;S+=2){let D=new ge(ee[S],ee[S+1]);if(!$e(I,D)){L(D,R);break}}}F=R.length,R.forEach((x,I)=>ee[I]=x)}else for(let L=F-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if($e(new ge(ee[L],ee[L+1]),new ge(ee[R],ee[R+1]))){ee[R]=(ee[L]+ee[R])/2,ee[R+1]=(ee[L+1]+ee[R+1])/2;for(let x=F-3;x>=L;x--)ee[x]=ee[x+2];F-=2;break}}let j=0;if(F===4){let L=function(I){return $e(H.getEnd(),I)||$e(H.prevSide.getEnd(),I)||$e(k.prevSide.getEnd(),I)||$e(k.getEnd(),I)},R=new ge(ee[0],ee[1]),x=()=>{let I=new Ya(R,H,c),S=new Ya(R,k,c);I.bind(S),I.setIsInvalid(),I.isDealed(),C.inters.push(I),M.inters.push(S)};if(ee[0]===ee[2]&&ee[1]===ee[3])if(L(R))j=2;else{x();return}}for(;j<F;j+=2){let L=new ge(ee[j],ee[j+1]),R=H,x=k;if($e(R.prevSide.getEnd(),L)&&(R=R.prevSide),x=f(x,L),H!==R&&k!==x){let S=e===2||e===3?k.getEnd():x.getEnd();R.getEnd().distance1(L)<S.distance1(L)?(L=R.getEnd(),$e(S,L)||(x=k)):(L=S,$e(R.getEnd(),L)||(R=H))}let I=u(R,x,L);if(I){let S=p(x,R,L);S&&(R.addInter(I),C.inters.push(I),x.addInter(S),M.inters.push(S),I.bind(S),C.intersect(M,h))}}return F},s);let g=O(),_=d4(o,l,e);_.forEach(b=>!b.startAndEndIsSameOutsideFlag()&&b.reverse()),new f4(g.concat(_)).getPolygons().forEach(b=>a.push(b));let y=new Ui(a);if(c){if(zu===-1){let b=c.initColor(Gt.RED),v=c.initColor(Gt.Golden);a.forEach(E=>{b.addPly(E.items[0]),E.items.slice(1).forEach(T=>v.addPly(T))}),c.draw();debugger;throw new Error}y.id=zu}return fa.BooleanTools+=ko(n),y;function m(b,v,E){b.items.forEach(T=>{let P=[];P.push(_0.build(T.items[0],E,!0,c,T)),T.items.slice(1).forEach(A=>{P.push(_0.build(A,E,!1,c))}),v.push(P)})}function O(){let b=[];return h.forEach(E=>{e===2||e===3?E.forEach(P=>{P.isGroup1||P.reverse(),P.sides.forEach(A=>A.sortInters())}):E.forEach(P=>P.sides.forEach(A=>A.sortInters())),E.map(P=>P.sides.filter(A=>A.inters.length)).flat(2).sort((P,A)=>{let C=P.inters,M=A.inters,H=$e(C[C.length-1].coord,P.getEnd()),k=$e(M[M.length-1].coord,A.getEnd());if(H&&k){let F=0,j=0;for(let L=C.length-2;L>=0&&$e(C[L].coord,P.getEnd());L--)F++;for(let L=M.length-2;L>=0&&$e(M[L].coord,A.getEnd());L--)j++;return j-F}else return H?-1:1}).forEach(P=>{P.inters.forEach(A=>{if(A.dealed)return;let C=A.side,M=A.getBindedInter().side,H;$e(C.getEnd(),A.coord)&&$e(M.getEnd(),A.coord)?H=-1:$e(C.getEnd(),A.coord)?(H=1,A=A.getBindedInter()):$e(M.getEnd(),A.coord)&&(H=1);let k=u4(H,A,e,c);A.isDealed(),k&&(C.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),T(E),e===3&&(E.forEach(P=>{P.reverse(),P.sides.forEach(A=>{A.sortInters(),A.inters.forEach(C=>{C.resetVisitStatus()})})}),T(E));function T(P){P.forEach(A=>{A.inters.forEach(C=>{if(C.isInvalid||C.getVisited())return;let M=C.findStartInter(),H=v(e)?M.run():M.getBindedInter().run(),k=A.polyline.primitives;if(H){if(k.length===H.primitives.length){let F=new Set(k);if(!H.primitives.some(j=>!F.has(j))){b.push(A);return}}b.push(_0.build(H,!0,!0,c))}})})}}),b;function v(E){switch(E){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var bp=/\bstablilizetion\b/.test(self.location.href)||!0,yp={intersect(e,t,i,r){try{return Hu(0,e,t,i,r)}catch(s){if(bp){let n=new Gu().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Ui(n.map(a=>new nr(a.items)))}throw s}},union(e,t,i,r){try{return Hu(1,e,t,i,r)}catch(s){if(bp){let n=new Gu,a=e.items.map(l=>l.items.map(h=>h)).flat(2);t.items.forEach(l=>l.items.forEach(h=>a.push(h)));let o=n.getUnion(a);return new Ui(o.map(l=>new nr(l.items)))}throw s}},diff(e,t,i,r){try{return Hu(2,e,t,i,r)}catch(s){if(bp){let n=new Gu().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Ui(n.map(a=>new nr(a.items)))}throw s}},xor(e,t,i,r){try{return Hu(3,e,t,i,r)}catch(s){if(bp){let n=new Gu().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new Ui(n.map(a=>new nr(a.items)))}throw s}}},_4=class extends Ju{constructor(e,t,i,r,s,n){super(e.rule,hg.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=s,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=n}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let s=[];r.items.forEach(n=>{let a=this.sides.length;this.addPolyline(n,t),s.push(this.sides.slice(a))}),i.push(s)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,s,n)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][s][n],l=gn(a.shape,o.shape);for(let h=0;h<l;h+=2){let c=new ge(ee[h],ee[h+1]);a.inters.push(c),o.inters.push(c),this.event.onIntersect(c,a,o)}return l},this.bus)}},O4=class extends Xu{constructor(e){super(!!e),e&&(this.drawDebug=new ud(e),this.blueDrawing=this.drawDebug.initColor(Gt.BLUE),this.greenDrawing=this.drawDebug.initColor(Gt.GREEN),this.redDrawing=this.drawDebug.initColor(Gt.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function b0(e,t,i,r,s){let n=fd(),a=new O4(s);new _4(e,a,t,i,r,s).simplify();let o=[];a.plGrps.forEach(h=>{let c=h.items.map(d=>Jp(d));c[0]&&o.push(new nr(c.filter(d=>d)))});let l=new Ui(o);return fa.BooleanTools+=ko(n),l}var y0=!0,Nu={intersect(e,t,i,r){try{return yp.intersect(e,t,i,r)}catch(s){if(y0)throw s;return console.error(s),b0(Lp,e,t,i,r)}},union(e,t,i,r){try{return yp.union(e,t,i,r)}catch(s){if(y0)throw s;return console.error(s),b0(NN,e,t,i,r)}},diff(e,t,i,r){try{return yp.diff(e,t,i,r)}catch(s){if(y0)throw s;return console.error(s),b0(Cp,e,t,i,r)}},xor(e,t,i,r){return yp.xor(e,t,i,r)}},m4=class{init(e){}seek(e,t,i,r){let s=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!s)return;let n=fd(),a=[];for(let f=0,u=e.items.length;f<u;f++){let p=e.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&a.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let o=a.length;if(o===0){fa.IntersectionSeeker+=ko(n);return}let l=[];for(let f=0,u=t.items.length;f<u;f++){let p=t.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&l.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let h=l.length;if(h===0){fa.IntersectionSeeker+=ko(n);return}if(o<5||h<5){for(let f=0,u=a.length;f<u;f++)for(let p=0,g=l.length;p<g;p++)if(a[f].bbox.isIntersect(l[p].bbox.extendOfSize(1e-5))){let _=a[f],y=l[p];i(_.polygonIndex,_.polylineIndex,_.ptIndex,y.polygonIndex,y.polylineIndex,y.ptIndex)}fa.IntersectionSeeker+=ko(n);return}a.sort((f,u)=>f.bbox.minX-u.bbox.minX),l.sort((f,u)=>f.bbox.minX-u.bbox.minX);let c=0,d=0;for(;c<o&&d<h;)if(a[c].bbox.minX<l[d].bbox.minX){let f=a[c],u=f.bbox;for(let p=d;p<h;p++){let g=l[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(u.minY<_.minY?_.minY:u.minY)<(u.maxY<_.maxY?u.maxY:_.maxY)+1e-5&&i(f.polygonIndex,f.polylineIndex,f.ptIndex,g.polygonIndex,g.polylineIndex,g.ptIndex)}c++}else{let f=l[d],u=f.bbox;for(let p=c;p<o;p++){let g=a[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(_.minY<u.minY?u.minY:_.minY)<(_.maxY<u.maxY?_.maxY:u.maxY)+1e-5&&i(g.polygonIndex,g.polylineIndex,g.ptIndex,f.polygonIndex,f.polylineIndex,f.ptIndex)}d++}fa.IntersectionSeeker+=ko(n)}},ps,Hr=(ps=class{static getDebug(){return ps.drawDebug||(ps.drawDebug=new ud(ps.curBus)),ps.drawDebug}static getDrawing(e=Gt.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){ps.getDebug().clear()}static drawText(e,t,i=Gt.GREEN){ps.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=Gt.GREEN){if(!e)return;let i=ps.getDrawing(t),r=new oe(e.UL(),e.UR()),s=new oe(e.UR(),e.LR()),n=new oe(e.LR(),e.LL()),a=new oe(e.LL(),e.UL());i.addPt(r),i.addPt(s),i.addPt(n),i.addPt(a)}static drawPolyType(e,t){let i=ps.getDrawing(t);if(e instanceof Pt)i.addPly(e);else if(e instanceof nr)for(let r of e.items)r instanceof Pt?i.addPly(r):this.drawPolyType(r,t);else if(e instanceof Ui)for(let r of e.items)this.drawPolyType(r,t)}static translate(e){switch(e){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}},ps.UseRunArrange=!0,ps.UseOptimizeSplit=!0,ps.LocalBestThread=4,ps.HandleDiff=!0,ps.OcTreeSplitStep=4,ps.PrintStart=new ge(150,-200),ps),Mu=class Y0{static getPolyTypeLine(t){let i=[];if(t instanceof Pt)for(let r of t.primitives)i.push(r);else if(t instanceof nr)for(let r of t.items)if(r instanceof Pt)for(let s of r.primitives)i.push(s);else{let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}else if(t instanceof Ui)for(let r of t.items){let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof Pt)i.push(t);else if(t instanceof nr)for(let r of t.items)if(r instanceof Pt)i.push(r);else{let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}else if(t instanceof Ui)for(let r of t.items){let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}return i}static getListBBox(t){if(t.length<=0)return;let i=new Cs;for(let r of t){let s=Y0.getSingleBBox(r);i.ext1(s)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new Cs,r=Y0.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=Hr.PrintStart){if(t.length<2)return[i,i,i];let r=5,s=10,n=t[0],a=Hr.translate(n),o=[],l=i.y,h=i.x,c=i.x;i=i.add(new ge(0,-s));for(let u=1;u<t.length;u++){let p=t[u];if(p instanceof Array){i=i.add(new ge(r,0));let g=this.doDrawRule(p,i);o.push(g[0]),g[1].x<=h&&(h=g[1].x),g[2].x>=c&&(c=g[2].x),i=new ge(g[2].x+r,i.y)}else o.push(i.clone()),i.x<=h&&(h=i.x),i.x>=c&&(c=i.x),Hr.drawText(i,p.name),i=i.add(new ge(r,0))}let d=0;for(let u of o)d+=u.x;let f=new ge(d/o.length,i.y+s);Hr.drawText(f,"N:"+a);for(let u of o){let p=new oe(u,f),g=new Array;g.push(p);let _=Pt.build1(B0(g));Hr.drawPolyType(_,Gt.GREEN)}return[f,new ge(h,l),new ge(c,l)]}static drawRule(t,i=Hr.PrintStart,r=!1,s){Hr.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,s),Hr.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let s=1;s<t.length;s++){let n=t[s];if(n instanceof Array)this.doDrawRulePolygon(n,i);else{let a=i;r===2&&s===1&&(a=Gt.RED),n.name&&Hr.drawText(n.bbox().UL(),n.name,a),Hr.drawPolyType(n,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let s of i.items)if(s.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let s of i.items)if(s.bbox().isIntersect(r)){for(let n of s.items)if(n.bbox().isIntersect(r)){for(let a of n.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},b4=class Gh{static createNode(t,i,r){let s=t.UL(),n=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,h=s.x+l*n,c=s.y-(o+1)*a,d=h+n,f=c+a;return new $r(h,d,c,f)}static ocTreeSplitNode(t,i,r,s,n=2){if(t.length<=r)return t;let a=[],o=n**2,l=new Array(o),h=new Array(o);for(let u=0;u<o;u++)l[u]=new Array(t.length),h[u]=0;let c=i.UL(),d=i.width()/n,f=i.height()/n;for(let u of t){let p=s(u).center(),g=~~((p.x-c.x)/d),_=~~((c.y-p.y)/f)*n+g;try{l[_][h[_]]=u,h[_]+=1}catch{a.push(u)}}for(let u=0;u<l.length;u++){let p=h[u];if(p<=0)continue;let g=l[u].slice(0,p);if(g.length===t.length)return t;let _=Gh.createNode(i,n,u),y=Gh.ocTreeSplitNode(g,_,r,s,n);if(y.length===t.length)return t;a.push(y)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,s){let n=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),h=i.width()/(a+1),c=i.height()/(a+1),d=-(2**32),f=[],u=[];for(let p=1;p<=a;p++)for(let g=1;g<=a;g++){let _=o.x+h*p,y=o.y+c*g,m=[[],[],[],[]],O=new Array(4),b=new Array(4);b[0]=new $r(o.x,_,y,l.y),b[1]=new $r(_,l.x,y,l.y),b[2]=new $r(o.x,_,o.y,y),b[3]=new $r(_,l.x,o.y,y);for(let P of t){let A=s(P).center(),C=-1,M=-1;A.x===_?C=Math.random()>=.5?1:-1:A.x>_?C=1:A.x<_&&(C=-1),A.y===y?M=Math.random()>=.5?1:-1:A.y>y?M=1:A.y<y&&(M=-1),C===1&&M===1?m[1].push(P):C===1&&M===-1?m[3].push(P):C===-1&&M===-1?m[2].push(P):C===-1&&M===1&&m[0].push(P)}for(let P=0;P<4;P++){let A=m[P];if(A.length<=0)continue;let C=new Cs;for(let M of A)C.ext1(s(M));O[P]=C.build1()}let v=0,E=0;for(let P of O)P&&(v+=P.area());E=v;let T=(P,A)=>{if(!O[P]||!O[A])return 0;let C=O[P].intersection1(O[A]);return C?C.area():0};E-=T(0,1),E-=T(0,2),E-=T(0,3),E-=T(1,2),E-=T(1,3),E-=T(2,3),E/v>=d&&(f=m,u=b)}for(let p=0;p<f.length;p++){let g=f[p];if(g.length<=0)continue;let _=u[p],y;if(g.length===t.length?y=Gh.ocTreeSplitNode(g,_,r,s):y=Gh.ocTreeSplitNodeMinIntersect(g,_,r,s),y.length===t.length)return t;n.push(y)}return n}static ocTreeSplit(t,i,r,s){return Gh.ocTreeSplitNode(t,i,r,s,Hr.OcTreeSplitStep)}},y4=class nx{static simplifyRules(t,i){return Hr.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=Hr.LocalBestThread+1)return t;let r=t.slice(1),s=new Array(r.length);for(let h=1;h<t.length;h++)s[h-1]=h;let n=Mu.getListBBox(r),a=b4.ocTreeSplit(s,n,Hr.LocalBestThread,h=>{let c=t[h];return Mu.getSingleBBox(c)}),o=(h,c)=>{if(!(h.length<=0))for(let d of h)if(Array.isArray(d)){let f=[c[0]];o(d,f),c.push(f)}else{let f=t[d];c.push(f)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(Hr.HandleDiff){let n=t[1],a;if(Array.isArray(n)){let o=this.optimizeSplit(n,i);if(o.length<=1)return[2];a=q0(o,i)}else a=q0([2,n],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let h=t[l];if(Array.isArray(h)){let c=Mu.getListBBox([...h.slice(1)]);Mu.KeepBBoxPolygonGroup(c,a)&&o.push(h)}else Mu.KeepBBoxPolygonGroup(h.bbox(),a)&&o.push(h)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let n=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,n,...o.slice(1)]:n}}else if(r===1){if(t.length-1>Hr.LocalBestThread){let n=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){n=!0;break}}n&&(t=nx.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let s=[r];for(let n=1;n<t.length;n++){let a=t[n];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;s.push(o)}else s.push(a)}return s}},v4=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(v4||{});function ju(e){let t=e[0],i=[t];switch(t){case 0:for(let s=1;s<e.length;s++){let n=e[s];if(Array.isArray(n)&&(n=ju(n),!n))return null;i.push(n)}break;case 1:case 3:for(let s=1;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=ju(n),!n)||i.push(n)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=ju(r)),!r)return null;i.push(r);for(let s=2;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=ju(n),!n)||i.push(n)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function v0(e,t,i){return Array.isArray(e)?ax(e,t,i):e}function x0(e,t,i,r,s=!0){if(s)for(;e.length>1;){let n,a=[];for(e.length%2===1?(a.push(e[0]),n=1):n=0;n<e.length;n+=2)a.push(t(e[n],e[n+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function ax(e,t,i,r=!0){let s=new Array(e.length-1);for(let n=1;n<e.length;n++)s[n-1]=v0(e[n],t,i);switch(e[0]){case 0:return x0(s,Nu.intersect,t,i);case 1:return x0(s,Nu.union,t,i);case 2:let n=x0(s.slice(1),Nu.union,t,i);return n?Nu.diff(s[0],n,t,i):s[0];case 3:let a=v0(e[1],t,i);for(let o=2;o<e.length;o++)a=Nu.xor(a,v0(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function ox(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let s=ox(r);Array.isArray(s)?s.length>1&&t.push(s):t.push(s)}else{let s=Jp(r);s!==null&&t.push(Ui.build(s))}}return t}function x4(e,t){Hr.curBus=t,e=ox(e);let i;return Hr.UseRunArrange?i=y4.simplifyRules(e,t):i=ju(e),i.length<=1?new Ui([]):q0(i,t)}function q0(e,t,i=!0){if(!e||e.length===1)return new Ui([]);let r=e,s=new m4,n=[];function a(o){for(let l=1;l<o.length;l++){let h=o[l];Array.isArray(h)?a(h):n.push(h)}}return a(r),s.init(n),ax(r,s,t,i)}var vp=new Error("list is empty"),xp=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},E4=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},w4=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},T4=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw vp;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw vp;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new xp(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new xp(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw vp;return this.first.item}getLast(){if(this.last===null)throw vp;return this.last.item}insertAfter(e,t){let i=new xp(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new xp(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new E4(this.first)}listIterator(){return new w4(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},Rp=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>$e(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let s=i.coord,n=at(e,s),a=at(i.side.getShape(),s),o=at(r.side.getShape(),s);return n.dot(a)>n.dot(o)?i:r},void 0)}getEntryInter(){}},E0=0;function lx(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof xe&&Math.abs(i.sweepAngle)===360)return[e];let r=fd();E0++;let s,n=N4(e);if(n.length===0)return[];let a=P4(n);if(E0===-1){s=new ud(t);let c=s.initColor(Gt.BLUE);n.forEach(f=>c.addPt(f.getShape()));let d=s.initColor(Gt.GREEN);a.forEach(f=>d.addPoint(f.coord)),s.draw();debugger;throw new Error}if(a.length===0)return[Pt.build7(n.map(c=>c.getShape()))];A4(a);let o=[],l=!1;try{D4(a,s)}catch(c){c.customType==="IS_OVERLAP"?(l=!0,o=new Gu().getUnion([e]).map(d=>d.items).flat(2)):console.error(c)}if(l)return o;let h=L4(a);if(!h.length)return[Pt.build7(n.map(c=>c.getShape()))];if(o=S4(h,s),o.length===0)return console.warn("=====deSelfIntersection=====",E0),[];if(s)throw o.forEach(c=>{s.initColor(Gt.WHITE).addPly(c),s.draw();debugger}),new Error;return fa.deSelfIntersection+=ko(r),o}function S4(e,t){let i=[];return e.forEach(r=>{let s=r;r.inters.forEach(n=>{if(n.getVisited())return;let a=[],o=[],l;if(t){debugger;let c=t.initColor(Gt.RED);l=d=>{a.push(d),c.addPt(a[a.length-1]),t.draw();debugger}}else l=c=>a.push(c);do{let c=function(g,_){we.eq(g.distance2(_),0)||l(hx(u.getShape(),g,_))},d=o.findIndex(g=>g===n.group);if(d!==-1){let g=a.findIndex(m=>m===n.group),_=a.splice(g).filter(m=>!(m instanceof Rp));if(_.length){let m=zo(Pt.build7(_));m&&i.push(m)}let y=a.filter(m=>!(m instanceof Rp));if(n=o[d].getOutInter(y[y.length-1]),o.splice(d),!n)throw Error("interGroup not hav inter!!!2");continue}n.visitSelf(),o.push(n.group),a.push(n.group);let f=n.getIndex(),u=n.side,p=u.inters[f+1];for(;p!=null&&p.isInvalid||p&&p.group===n.group;)p=u.inters[p.getIndex()+1];if(p){c(n.coord,p.coord);let g=p.getBindedInter();if(n=g.getVisited()?g.group.getOutInter(g.side.getShape()):g,!n){if(p.group===s)break;throw new Error("interGroup not hav inter!!!3")}}else{for(c(n.coord,u.getEnd()),u=u.nextSide,n=null;;){for(let g of u.inters)if(!g.isInvalid){let _=g.group.getOutInter(u.getShape());if(!_){if(g.group===s){n=g;break}else if(g.getBindedInter().group===s){n=g.getBindedInter();break}continue}n=_;break}if(n)break;l(u.getShape()),u=u.nextSide}we.eq(u.getEnd().distance2(n.coord),0)?l(u.getShape()):c(u.getStart(),n.coord)}}while(n.group!==s);let h=zo(Pt.build7(a.filter(c=>!(c instanceof Rp))));h&&i.push(h)})}),i}function I4(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function P4(e){let t=[],i=new T4;for(let r of e.slice().sort((s,n)=>s.bbox().minY-n.bbox().minY)){for(let s of I4(i.listIterator())){let n=s.item;if(n.bbox().maxY<r.bbox().minY)i.remove(s);else{let a=function(f,u){let p=new Ya(u,f,null);return f.inters.push(p),t.push(p),p},o=function(f,u){let p=f.getEnd(),g=new ge(ee[0],ee[1]),_=new ge(ee[2],ee[3]),y=p.distance2(g)>p.distance2(_)?g:_,m=f.prevSide;a($e(m.getEnd(),y)?m:f,y).bind(a(u,y))},l=n.getShape(),h=r.getShape(),c=gn(l,h),d=c===4&&ee[0]===ee[2]&&ee[1]===ee[3];if(d&&(c-=2),n.nextSide===r)n.prevSide!==r&&c===4&&o(n,r);else if(n.prevSide===r)c===4&&o(r,n);else if(c!==0){let f=function(p,g){let _=p.prevSide;return a($e(_.getEnd(),g)?_:p,g)},u=new ge(ee[0],ee[1]);if(d&&!$e(u,n.prevSide.getEnd())&&!$e(u,r.prevSide.getEnd())&&at(l,u).dot(at(h,u))>0)continue;for(let p=0;p<c;p+=2){let g=new ge(ee[p],ee[p+1]);f(n,g).bind(f(r,g))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function A4(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!$e(t.coord,i))return;let r=t.side.inters,s=t.getBindedInter().side;for(let n=r.length-1;n>=0;n--){let a=r[n];if(!$e(a.coord,i))break;a!==t&&a.getBindedInter().side===s&&a.setIsInvalid()}})}function C4(e){let t=new Qu(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function L4(e){let t=[],i=C4(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let s=i.search(r.bbox().extendOfSize(we.eps)).filter(n=>!n.group);if(s.length){let n=new Set,a=new Rp(s);s.forEach(o=>{o.group=a,n.has(o.side)&&o.visitSelf(),n.add(o.side)}),t.push(a)}}),t}function D4(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,s=i.getBindedInter().side,n;$e(r.getEnd(),i.coord)&&$e(s.getEnd(),i.coord)?n=-1:$e(r.getEnd(),i.coord)?r.nextSide!==s&&(n=1,i=i.getBindedInter()):$e(s.getEnd(),i.coord)&&s.nextSide!==r&&(n=1),R4(n,i,t),i.isDealed()})}function R4(e,t,i){let r=t.getBindedInter(),s=t.side,n=r.side,a=s.getShape(),o=n.getShape(),l=1,h=!1;if(e===-1){if(Dh(a.reverse(),o.reverse())||Dh(s.nextSide.getShape(),n.nextSide.getShape())){let d=ja(s,s.nextSide,n,r,l,h,i);if(d.state===2){let u=new Error("info1.state === InState.IS_OVERLAP");throw u.customType="IS_OVERLAP",u}let f=ja(s,s.nextSide,n.nextSide,r,l,h,i);d.state===f.state&&c(d,f)}else if(!(Dh(a.reverse(),n.nextSide.getShape())||Dh(s.nextSide.getShape(),o.reverse()))){let d=p0(s,s.nextSide,n,!1,i);d===p0(s,s.nextSide,n.nextSide,!0,i)&&d!==p0(n,n.nextSide,s.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let d=function(f,u){return at(f,u.start()).dot(at(u,u.start()))>0};if(Dh(a.reverse(),o.reverse())||Dh(a,n.nextSide.getShape())){let f=Zs(s,n,r,i,l,h,new Map);if(f.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let u=Zs(s,n.nextSide,r,i,l,h,new Map);f.state===u.state&&c(f,u)}else if(d(a.reverse(),o.reverse())&&d(a,n.nextSide.getShape())){let f=vr(s,n,!1,i);f===vr(s,n.nextSide,!0,i)&&f!==kl(n,n.nextSide,new dd(hx(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function c(d,f){d.inter.setIsInvalid(),f.inter.setIsInvalid(),t.setIsInvalid()}}function hx(e,t,i){if(e instanceof oe||t.distance2(i)<1e-6)return new oe(t,i);if(e instanceof xe)return xe.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof Ve){let r=e.getPercent(t,ot),s=e.getPercent(i,ot);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function N4(e){let t=zo(e);if(!t)return[];let i=t.primitives.map(s=>new dd(s,null)),r=i[i.length-1];return i.forEach(s=>{r.connect(s),r=s}),i}var Mh,M4=(Mh=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new ud(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Gt.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(Gt.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof xe?i=xe.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new oe(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,s=Math.sqrt(i**2+r**2)+t;return[xe.buildCircle(e.center(),s)]}static getExtendPolyLine(e,t,i=!0,r){var s,n;if(!((s=e==null?void 0:e.primitives)!=null&&s.length))return[];let a=zo(e);if(!((n=a==null?void 0:a.primitives)!=null&&n.length)){if(this.isExpansion){let l=[1],h=t*2;e.primitives.forEach(d=>l.push(d.stroke(h,1,0)));let c=x4(l,r);if(c.items.length!==1)throw new Error("group.items.length !== 1 ");return[c.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.isExpansion=t>0,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(Gt.BLUE);this.rawOffsetPrimitive.forEach(h=>l.addPt(h)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[Pt.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Gt.RED);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(Gt.GREEN);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let s=!0,n=e[r].primitives;e:for(let a=0;a<n.length;a+=1){let o=n[a],l;if(o instanceof xe)l=o.midPoint;else if(o instanceof oe)l=o.start();else throw new Error("not support!");for(let h=0;h<this.originalPrimitive.length;h+=1){let c=this.originalPrimitive[h],d;if(c instanceof xe?d=this.pointArcClosest(l,c):d=_N(l,c.start(),c.end()).d,i-d>.01){s=!1;break e}}}s&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new ge(ee[i],ee[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let n=e.sub(i);return Math.abs(n.length()-t.rx)}let r=e.distance2(t.start()),s=e.distance2(t.end());return we.less(r,s)?Math.sqrt(r):Math.sqrt(s)}static createClippingEdge(e){let t=[],i=[],r=lx(Pt.build2(this.rawOffsetPrimitive),e);r.forEach(n=>{let a=n.area(.01);t.push(a)});let s=Math.min(...t.filter(n=>n<0));for(let n=0;n<t.length;n+=1){let a=t[n];we.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[n]===s||a>0))&&i.push(r[n])}return i}static createOffsetEdge(e){if(e instanceof xe)return e.panDistance1(this.offsetDistance);if(e instanceof oe)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof oe&&t.offsetEdge instanceof oe?this.lineToLineConnect(e,t):e.offsetEdge instanceof xe&&t.offsetEdge instanceof xe?this.arcToArcConnect(e,t):e.offsetEdge instanceof oe&&t.offsetEdge instanceof xe?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=t.index,n=this.originalPrimitive[s].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(n,i,r);else{let a=this.getLineToLineT(i,r),o=a[0],l=a[1];if(this.isFalseIntersection(o)||this.isFalseIntersection(l))o>1&&this.isFalseIntersection(l)?this.lineToLineUseArcToConnect(n,i,r):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(o)&&!this.isFalseIntersection(l)){let h=i.end().sub(i.start()),c=i.start().add(h.mul(o)),d=new oe(i.start(),c);this.rawOffsetPrimitive.push(d);let f=new oe(c,r.end());this.updateNextOffsetPrimitive(s,f)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new oe(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i){let r=this.getSweep(e,t),s=this.getSweepAngel(t.end(),i.start(),e,r);if(s===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let n=xe.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(n)}static getSweep(e,t,i){let r=null,s=i||i===0?this.originalPrimitive[i]:t;if(s instanceof xe){let n=s.center.sub(s.end()).normalize();s.isCCW?r=new ge(n.y,-n.x):r=new ge(-n.y,n.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),s=i.cross(r),n=t.start().sub(e.start()),a=e.start().sub(t.start()),o=n.cross(r)/s,l=a.cross(i)/-s;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.lineAndArcConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static lineAndArcConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new oe(e.start(),r);this.rawOffsetPrimitive.push(l);let h;!t.center.equals1(r)||t.sweepAngle>1e-4?(h=xe.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),h instanceof xe&&h.sweepAngle===0&&(h=new oe(h.start(),h.end()))):h=new oe(t.center,r),this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static lineAndArcUseArcConnect(e,t,i,r){let s=this.getSweep(e,t,r),n=this.getSweepAngel(t.end(),i.start(),e,s);if(n===0){this.useLineToConnect(t,i);return}let a=xe.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new oe(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new oe(e.start(),r):(l=xe.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof xe&&l.sweepAngle===0&&(l=new oe(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let h=new oe(r,t.end());this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static isTrueArcIntersection(e,t){return Yi(e,t)}static getSweepAngel(e,t,i,r){let s=e.angleD(i),n=t.angleD(i),a;return s===n?a=0:(s=pt.regularD(s),n=pt.regularD(n),r===1?n<=s&&(n+=360):n>=s&&(s+=360),a=n-s),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=fN(t,e);if(r){i.intersectionNum=r/2;for(let s=0;s<r-1;s+=2){let n=new ge(ee[s],ee[s+1]);i.points.push(n),n.sub(e.start()).x<1e-4||n.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(n.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.arcToLineConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=Hv(i,r);if(s){let n=this.getInters(s),a;if(n.length===2){let h=this.originalPrimitive[t.index].start(),c=n[0],d=n[1],f=c.distance2(h),u=d.distance2(h);f<u?a=c:a=d}else a=n[0];let o,l;a.equals1(i.center)?o=new oe(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new oe(i.start(),a):(o=xe.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof xe&&o.sweepAngle===0&&(o=new oe(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new oe(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new oe(a,r.end()):(l=xe.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof xe&&l.sweepAngle===0&&(l=new oe(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let n=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(n.sweep()),l=this.rxChangeStatus(a.sweep()),h=this.originalPrimitive[t.index].start(),c=this.getSweep(h,i,e.index),d=Math.abs(this.offsetDistance),f=xe.build2(h,o?n.endAngle():n.endAngle()+180,l?a.startAngle:a.startAngle+180,d,d,c);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(f)}}},Mh.originalPrimitive=[],Mh.offsetPrimitive=[],Mh.rawOffsetPrimitive=[],Mh.testI=0,Mh),B4=class Vu extends hd{constructor(t,i,r,s,n,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=s,this.isCCW=n,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new ge(this.radius,0).multiply3($t.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new ge(0,-this.height/2).multiply3($t.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new ge(this.width,-this.height/2).multiply3($t.rotateD(this.angle)))}extend(t){return new Vu(this.leftUpPoint.add(new ge(-t,t).rotateD(ge.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=$t.rotateD(this.angle),{leftUpPoint:i,width:r,height:s,radius:n}=this,a=i.add(new ge(n,-n).multiply3(t)),o=i.add(new ge(n,n-s).multiply3(t)),l=i.add(new ge(r-n,-n).multiply3(t)),h=i.add(new ge(r-n,n-s).multiply3(t));return new $r(Math.min(a.x,o.x,l.x,h.x)-n,Math.max(a.x,o.x,l.x,h.x)+n,Math.min(a.y,o.y,l.y,h.y)-n,Math.max(a.y,o.y,l.y,h.y)+n)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:s,radius:n}=this;if(n===0){let o=ge.ORIGIN,l=new ge(r,0),h=new ge(r,-s),c=new ge(0,-s);t.push(new oe(o,l),new oe(l,h),new oe(h,c),new oe(c,o))}else{let o=new ge(0,-n),l=new ge(n,0),h=new ge(r-n,0),c=new ge(r,-n),d=new ge(r,n-s),f=new ge(r-n,-s),u=new ge(n,-s),p=new ge(0,n-s);t.push(xe.build1(o,l,n,n,!1,0),new oe(l,h),xe.build1(h,c,n,n,!1,0),new oe(c,d),xe.build1(d,f,n,n,!1,0),new oe(f,u),xe.build1(u,p,n,n,!1,0),new oe(p,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=$t.rotateD(this.angle).translate1(i);return Pt.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new ge(this.width,0).multiply3($t.rotateD(this.angle)).multiply3(t),s=new ge(0,-this.height).multiply3($t.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new Vu(i,s.length(),r.length(),s.angleD(ge.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new Vu(i,r.length(),s.length(),r.angleD(ge.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new Vu(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let s=this.stroke1(t,i,r);if(s.length===1)return s[0];{let[n,a]=s;return Pt.build2(n.primitives.concat(new oe(n.primitives[0].start(),a.primitives[0].start()),a.primitives,new oe(a.primitives[0].start(),n.primitives[0].start())))}}stroke1(t,i,r){let s=r===this.isCCW?this:this.reverse(),n=t/2,a=Math.min(s.width,s.height)/2,o=s.extend(n).toPolyline();return a<=n?[o]:[o,s.extend(-n).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,s=>r.push(s)),r}toBezier(){throw new Error("Method not implemented.")}},k4=.01,nr=class Dn{static simplify(t){return t=zo(t),t?new Dn([t]):null}static buildByStroke(t,i,r=1,s=_m,n){if(t instanceof xe&&(t.rx<i/2+k4||Math.abs(t.sweepAngle)>180&&we.lesseq(t.start().distance1(t.end()),i))){let o=lx(t.stroke(i,r,0),n);if(o.length===0)return null;if(o.length===1)return new Dn(o);let l=[null],h=Number.POSITIVE_INFINITY;return o.forEach(c=>{let d=c.area(.1);d<0?d<h&&(l[0]=c,h=d):l.push(c)}),new Dn(l)}else if(t instanceof B4){let o=t.stroke1(i,r,0).map(l=>zo(l));return o[0]?o[1]?new Dn(o):new Dn([o[0]]):null}let a=t.stroke(i,r,0,s);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(Pt.build7([xe.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(Pt.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Dn(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Dn?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new Ui([this]);let r=this.items[0],s=[];for(let c of r.primitives)if(c instanceof oe)s.push(c);else if(c instanceof xe&&c.rx===c.ry)a(c);else if(c instanceof Ve)n(c);else throw new Error("not support!");r=Pt.build7(s);function n(c){let d=c.points(.1);for(let f=0;f<d.length-1;f++){let u=d[f],p=d[f+1];s.push(new oe(u,p))}}function a(c){if(Math.abs(c.sweepAngle)>270){let d=c.sweepAngle/2;a(xe.build3(c.center,c.startAngle,d,c.rx,c.ry)),a(xe.build3(c.center,c.startAngle+d,d,c.rx,c.ry))}else s.push(c)}let o=[],l=[];M4.getExtendPolyLine(r,t,!0,i).forEach(c=>{(c.area(.1)>0?l:o).push(c)});let h;if(o.length===1)l.forEach(c=>o.push(c)),h=new Ui([new Dn(o)]);else if(o.length===0)console.warn("outlines.length === 0"),h=new Ui([]);else if(l.length===0)h=new Ui(o.map(c=>new Dn([c])));else{let c=o.map(d=>[d]);l.forEach(d=>{let f=[],u=d.bbox();if(c.forEach(p=>{p[0].bbox().isContainsBBox1(u)&&f.push(p)}),f.length===1)f[0].push(d);else{if(f.length===0)throw new Error("inPlsArr.length === 0");for(let p of f.sort((g,_)=>g[0].bbox().area()-_[0].bbox().area()))if(p[0].getWindingNum(d.start())===-1){p.push(d);break}}}),h=new Ui(c.map(d=>new Dn(d)))}return h}toPolylineGroup(){return new Om(this.items)}},F4=(e=>(e[e.POLYGON=1]="POLYGON",e[e.POLYLINE=2]="POLYLINE",e[e.LINE=3]="LINE",e[e.ARC=4]="ARC",e[e.BEZIER2=5]="BEZIER2",e[e.BEZIER3=6]="BEZIER3",e[e.BOOLEAN_OUTPUT=7]="BOOLEAN_OUTPUT",e[e.BOOLEAN_INTERSECTION=8]="BOOLEAN_INTERSECTION",e[e.BOOLEAN_UNION=9]="BOOLEAN_UNION",e[e.BOOLEAN_DIFF=10]="BOOLEAN_DIFF",e[e.BOOLEAN_RESULT=11]="BOOLEAN_RESULT",e[e.LINES=12]="LINES",e[e.ARCS=13]="ARCS",e[e.BEZIER2S=14]="BEZIER2S",e[e.BEZIER3S=15]="BEZIER3S",e[e.CIRCLE_CW=16]="CIRCLE_CW",e[e.CIRCLE_CCW=17]="CIRCLE_CCW",e[e.POLYGON_GROUP=18]="POLYGON_GROUP",e))(F4||{}),U4=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function G4(e){return new U4(e)}function z4(e){return e===32||e===9||e===13||e===10}var H4=class{constructor(){this._line=1,this._col=0}line(){return this._line}col(){return this._col}_feed(e){return e===10?(this._col=0,this._line++):this._col++,this.feed(e)}parse(e){let t=e.length;for(let i=0;i<t;i++){let r=e.charCodeAt(i);if(!this._feed(r))return this}return this.finish(),this}},w0=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}},j4=/(\.?0+)$/,W0=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 100:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(w0.lpad((n|0).toString(10),"0",d)),r=0;else return l}else return l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(w0.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(w0.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static fmtNumber(e){return e.toFixed(5).replace(j4,"")}};function V4(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var Y4=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},q4=(e,t)=>[V4(e)].concat(t),X0=class J0{static mix(...t){return new J0(0,(i,r)=>{for(let s of t)s.write(i,r)},(i,r)=>r)}constructor(t,i=Y4,r=q4){this.level=t,this.writer=i,this.fmt=r}setLevel(t){this.level=t}prepend(t=null,i=null){let r=t===null?this.fmt:(n,a)=>(a=t(n,a),this.fmt(n,a)),s=i===null?this.writer:(n,a)=>{i(n,a),this.writer(n,a)};return new J0(this.level,s,r)}chain(t){return t.prepend(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}formatWrite(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[W0.format(i,...r)]))}write(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[W0.format(i,...r)]))}debug3(t,...i){this.write3(0,t,i)}warning3(t,...i){this.write3(2,t,i)}debugFmt(t,...i){this.formatWrite(0,t,i)}debug(...t){this.write(0,t)}infoFmt(t,...i){this.formatWrite(1,t,i)}info(...t){this.write(1,t)}warningFmt(t,...i){this.formatWrite(2,t,i)}warning(...t){this.write(2,t)}errorFmt(t,...i){this.formatWrite(3,t,i)}error(...t){this.write(3,t)}};X0.DUMMY=new X0(4);var W4=X0,T0=500,rv=String.fromCharCode,X4=class{constructor(){this.buffer=new Array}size(){return this.buffer.length}isEOF(){return!1}write(e){return this.buffer.push(e),1}writen1(e){return this.writen2(e,0,e.length)}writen2(e,t,i){let r=this.buffer;for(let s=0,n=t;s<i;s++,n++)r.push(e[n]);return i}writeAsync(e,t){t(this.write(e))}writenAsync1(e,t){t(this.writen1(e))}writenAsync2(e,t,i,r){r(this.writen2(e,t,i))}writeStr(e){let t=e.length,i=new Array(t);for(let r=0;r<t;r++)i[r]=e.charCodeAt(r);return this.writen1(i)}clear(){this.buffer.length=0}toString(){let e=this.buffer,t=e.length;if(t<=T0)return rv.apply(null,e);{let i=new Array;for(let r=0;r<e.length;r+=T0){let s=Math.min(t-r,T0),n=rv.apply(null,e.slice(r,r+s));i.push(n)}return i.join("")}}},cx=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.NUMBER_INTEGER=1]="NUMBER_INTEGER",e[e.NUMBER_DECIMAL=2]="NUMBER_DECIMAL",e[e.NUMBER_E=3]="NUMBER_E",e[e.NUMBER_E_SIGNED=4]="NUMBER_E_SIGNED",e))(cx||{}),ux=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.MOVE_X=1]="MOVE_X",e[e.MOVE_Y=2]="MOVE_Y",e[e.LINE_X=3]="LINE_X",e[e.LINE_Y=4]="LINE_Y",e[e.HORIZONTAL_X=5]="HORIZONTAL_X",e[e.VERTICAL_Y=6]="VERTICAL_Y",e[e.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",e[e.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",e[e.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",e[e.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",e[e.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",e[e.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",e[e.ARC_RX=13]="ARC_RX",e[e.ARC_RY=14]="ARC_RY",e[e.ARC_ROTATION=15]="ARC_ROTATION",e[e.ARC_LARGE=16]="ARC_LARGE",e[e.ARC_SWEEP=17]="ARC_SWEEP",e[e.ARC_X=18]="ARC_X",e[e.ARC_Y=19]="ARC_Y",e[e.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",e[e.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",e[e.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",e[e.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",e[e.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",e[e.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",e[e.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",e[e.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",e))(ux||{});function J4(e){return 97<=e&&e<=122||65<=e&&e<=90}function br(e){let t=parseFloat(e);if(isFinite(t))return t;throw new Error("expect number")}var sv=class extends H4{constructor(e,t=!0,i=W4.DUMMY){super(),this.buffer=new X4,this.group=new Array,this.subPartStart=ge.ORIGIN,this.curPoint=ge.ORIGIN,this.lexState=0,this.parseState=0,this.isAbsolute=!1,this.isLargeArc=!1,this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.x=Number.NaN,this.y=Number.NaN,this.rx=Number.NaN,this.ry=Number.NaN,this.rotation=Number.NaN,this.sweep=Bo.CCW,this.prevBezierCtrl2=null,this.logger=i,this.cb=e,this.yAxis=t?-1:1}on(e){return this.cb(e)}feed(e){switch(this.logger.include(0)&&this.logger.debug3("L: %c(%s)|%s",e,String.fromCharCode(e),cx[this.lexState]),this.lexState){case 0:return z4(e)?!0:48<=e&&e<=57||e===45||e===43?(this.pushBuffer(e),this.lexState=1,!0):e===46?(this.pushBuffer(e),this.lexState=2,!0):J4(e)?this.feedS(String.fromCharCode(e)):(this.logger.warning3("unknow letter %c",e),!0);case 1:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===46?(this.pushBuffer(e),this.lexState=2,!0):e===101||e===69?(this.pushBuffer(e),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 2:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===101||e===69?(this.pushBuffer(e),this.lexState=3,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 3:return 48<=e&&e<=57?(this.pushBuffer(e),!0):e===45||e===43?(this.pushBuffer(e),this.lexState=4,!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;case 4:return 48<=e&&e<=57?(this.pushBuffer(e),!0):this.feedS(this.getCleanBuffer())?(this.lexState=0,this.feed(e)):!1;default:return!0}}finish(){this.feed(32),this.tryNotify()}feedS(e){switch(this.logger.include(0)&&this.logger.debug3("P: %s|%s|%s|%s",e,ux[this.parseState],this.curPoint,this.subPartStart),this.parseState){case 0:switch(e){case"M":this.isAbsolute=!0,this.parseState=1;break;case"m":this.isAbsolute=!1,this.parseState=1;break;case"L":this.isAbsolute=!0,this.parseState=3;break;case"l":this.isAbsolute=!1,this.parseState=3;break;case"H":this.isAbsolute=!0,this.parseState=5;break;case"h":this.isAbsolute=!1,this.parseState=5;break;case"V":this.isAbsolute=!0,this.parseState=6;break;case"v":this.isAbsolute=!1,this.parseState=6;break;case"z":case"Z":{this.group.push(new oe(this.curPoint,this.subPartStart));let r=this.tryNotify();return this.curPoint=this.subPartStart,r}case"C":this.isAbsolute=!0,this.parseState=7;break;case"c":this.isAbsolute=!1,this.parseState=7;break;case"S":this.isAbsolute=!0,this.parseState=20;break;case"s":this.isAbsolute=!1,this.parseState=20;break;case"A":this.isAbsolute=!0,this.parseState=13;break;case"a":this.isAbsolute=!1,this.parseState=13;break;case"Q":this.isAbsolute=!0,this.parseState=24;break;case"q":this.isAbsolute=!1,this.parseState=24;break;default:this.logger.warning3("unknow %s",e)}return!0;case 1:let t=this.tryNotify();return this.x=br(e),this.parseState=2,t;case 2:{this.y=this.yAxis*br(e);let r;return this.isAbsolute?r=new ge(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.curPoint=r,this.subPartStart=r,this.parseState=3,!0}case 3:return this.x=parseFloat(e),isFinite(this.x)?(this.parseState=4,!0):(this.parseState=0,this.feedS(e));case 4:{this.y=this.yAxis*br(e);let r;return this.isAbsolute?r=new ge(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.group.push(new oe(this.curPoint,r)),this.curPoint=r,this.parseState=3,!0}case 5:if(this.x=parseFloat(e),isFinite(this.x)){let r;return this.isAbsolute?r=new ge(this.x,this.curPoint.y):r=this.curPoint.add1(this.x,0),this.group.push(new oe(this.curPoint,r)),this.curPoint=r,!0}else return this.parseState=0,this.feedS(e);case 6:if(this.y=parseFloat(e),isFinite(this.y)){this.y=this.yAxis*this.y;let r;return this.isAbsolute?r=new ge(this.curPoint.x,this.y):r=this.curPoint.add1(0,this.y),this.group.push(new oe(this.curPoint,r)),this.curPoint=r,!0}else return this.parseState=0,this.feedS(e);case 7:let i=parseFloat(e);return isFinite(i)?(this.x1=i,this.parseState=8,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 8:return this.y1=this.yAxis*br(e),this.parseState=9,!0;case 9:return this.x2=br(e),this.parseState=10,!0;case 10:return this.y2=this.yAxis*br(e),this.parseState=11,!0;case 11:return this.x=br(e),this.parseState=12,!0;case 12:{this.y=this.yAxis*br(e);let r,s,n;return this.isAbsolute?(r=new ge(this.x1,this.y1),s=new ge(this.x2,this.y2),n=new ge(this.x,this.y)):(r=this.curPoint.add1(this.x1,this.y1),s=this.curPoint.add1(this.x2,this.y2),n=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=s,this.group.push(new Ve([this.curPoint,r,s,n])),this.curPoint=n,this.parseState=7,!0}case 13:return this.rx=parseFloat(e),isFinite(this.rx)?(this.parseState=14,!0):(this.parseState=0,this.feedS(e));case 14:return this.ry=br(e),this.parseState=15,!0;case 15:return this.rotation=br(e),this.parseState=16,!0;case 16:return this.isLargeArc=br(e)===1,this.parseState=17,!0;case 17:return this.sweep=br(e)===1?Bo.CW:Bo.CCW,this.parseState=18,!0;case 18:return this.x=br(e),this.parseState=19,!0;case 19:{this.y=this.yAxis*br(e);let r;return this.isAbsolute?r=new ge(this.x,this.y):r=this.curPoint.add1(this.x,this.y),this.rx&&this.ry&&this.group.push(xe.build1(this.curPoint,r,this.rx,this.ry,this.isLargeArc,this.sweep)),this.curPoint=r,this.parseState=13,!0}case 20:return this.x2=parseFloat(e),isFinite(this.x2)?(this.parseState=21,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 21:return this.y2=this.yAxis*br(e),this.parseState=22,!0;case 22:return this.x=br(e),this.parseState=23,!0;case 23:{this.y=this.yAxis*br(e);let r,s;this.isAbsolute?(r=new ge(this.x2,this.y2),s=new ge(this.x,this.y)):(r=this.curPoint.add1(this.x2,this.y2),s=this.curPoint.add1(this.x,this.y));let n;return this.prevBezierCtrl2?n=this.curPoint.add(this.curPoint.sub(this.prevBezierCtrl2)):n=this.curPoint,this.prevBezierCtrl2=r,this.group.push(new Ve([this.curPoint,n,r,s])),this.curPoint=s,this.parseState=20,!0}case 24:return this.x1=parseFloat(e),isFinite(this.x1)?(this.parseState=25,!0):(e!=="s"&&e!=="S"&&(this.prevBezierCtrl2=null),this.parseState=0,this.feedS(e));case 25:return this.y1=this.yAxis*br(e),this.parseState=26,!0;case 26:return this.x=br(e),this.parseState=27,!0;case 27:{this.y=this.yAxis*br(e);let r,s;return this.isAbsolute?(r=new ge(this.x1,this.y1),s=new ge(this.x,this.y)):(r=this.curPoint.add1(this.x1,this.y1),s=this.curPoint.add1(this.x,this.y)),this.prevBezierCtrl2=r,this.group.push(new Ve([this.curPoint,r,s])),this.curPoint=s,this.parseState=24,!0}default:return this.logger.warning3("unsupported parse state %s",this.parseState),!0}}pushBuffer(e){this.buffer.write(e)}getCleanBuffer(){let e=this.buffer.toString();return this.buffer.clear(),e}tryNotify(){if(this.group.length===0)return!0;{let e=Pt.build1(G4(this.group));return this.group.length=0,this.on(e)}}onException(e){throw e}},yZ=W0.fmtNumber,nv=class{constructor(e=!0){this.buffer=new Array,this.state=0,this.prev=null,this.yAxis=e?-1:1}encPl(e){for(let t of e.primitives)this.encPt(t);return this}encPt(e){if(e instanceof oe)this.encLine1(e);else if(e instanceof xe)this.encArc(e);else if(e instanceof Ve)this.encBezier(e);else throw new Error("");return this}encBezier(e){if(e.controls.length===3){let t=e.controls[0],i=e.controls[1],r=e.controls[2];this.state===0?this.buffer.push("M",t.x,this.yAxis*t.y,"Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):t.equals1(this.prev)?this.state!==4?this.buffer.push("Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):this.buffer.push(i.x,this.yAxis*i.y,r.x,this.yAxis*r.y):this.buffer.push("L",t.x,this.yAxis*t.y,"Q",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y),this.prev=r,this.state=4}else if(e.controls.length===4){let t=e.controls[0],i=e.controls[1],r=e.controls[2],s=e.controls[3];this.state===0?this.buffer.push("M",t.x,this.yAxis*t.y,"C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,s.x,this.yAxis*s.y):t.equals1(this.prev)?this.state!==3?this.buffer.push("C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,s.x,this.yAxis*s.y):this.buffer.push(i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,s.x,this.yAxis*s.y):this.buffer.push("L",t.x,this.yAxis*t.y,"C",i.x,this.yAxis*i.y,r.x,this.yAxis*r.y,s.x,this.yAxis*s.y),this.prev=s,this.state=3}else throw new Error("only bezier has 3 or 4 control points supported");return this}encArc(e){let t=e.svgEnd;return this.state===0?this.buffer.push("M",e.start().x,this.yAxis*e.start().y,"A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===Bo.CCW?0:1,t.x,this.yAxis*t.y):e.start().equals1(this.prev)?this.state!==2?this.buffer.push("A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===Bo.CCW?0:1,t.x,this.yAxis*t.y):this.buffer.push(e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===Bo.CCW?0:1,t.x,this.yAxis*t.y):this.buffer.push("L",e.start().x,this.yAxis*e.start().y,"A",e.rx,e.ry,0,e.isLarge()?1:0,e.sweep()===Bo.CCW?0:1,t.x,this.yAxis*t.y),this.prev=t,this.state=2,this}encLine1(e){return this.encLine2(e.start(),e.end()),this}encLine2(e,t){return this.state===0?this.buffer.push("M",e.x,this.yAxis*e.y,"L",t.x,this.yAxis*t.y):(this.state!==1&&this.buffer.push("L"),e.equals1(this.prev)?this.buffer.push(t.x,this.yAxis*t.y):this.buffer.push(e.x,this.yAxis*e.y,t.x,this.yAxis*t.y)),this.prev=t,this.state=1,this}close(e){return this.state!==0&&(e&&this.buffer.push("Z"),this.state=0,this.prev=null),this}fixNumber(e=4){return this.buffer.forEach((t,i,r)=>{typeof t=="number"&&(t|0)!==t&&(r[i]=+t.toFixed(e))}),this}toString(){return this.buffer.join(" ")}toArray(){return this.buffer}},Z4=class extends fm{constructor(){super(),this.lockConfig=[],this.hideConfig=[],this.invisibleConfig=[],this.coverConfig={},this.commentConfig={},this.trnCtrlConfig={},this.transformConfig={},this.fontCache={},this.cache={},this.zIndex=0,this.zIndexMap=new Map}onParseLine(e){let t=e[0];switch(t){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"LOCK":this.parseLock(e);break;case"HIDE":this.parseHide(e);break;case"INVISIBLE":this.parseInvisible(e);break;case"COVER":this.parseCover(e);break;case"TRN_CTRL":this.parseTrnCtrl(e);break;case"COMMENT":this.parseComment(e);break;case"FONT_CACHE":this.parseFontCache(e);break;case"TRANSFORM":this.parseTransform(e);break;case"GROUP":{let i=e[1];this.cache[t]||(this.cache[t]={errorIds:[]}),i!==null&&!this.cache[t][i]?this.cache[t][i]=e:this.cache[t].errorIds.push(e);break}case"POLY":case"STRING":case"AUXLINE":case"DIMENSION":{this.zIndexMap.set(e[1],++this.zIndex);let i=Ku(e[1]);this.cache[t]||(this.cache[t]={errorIds:[]}),i!==null&&!this.cache[t][i]?this.cache[t][i]=e:this.cache[t].errorIds.push(e);break}default:console.warn("can not find hanlder with",e)}}getZIndex(e){var t;return(t=this.zIndexMap.get(e))!=null?t:null}secondParseLine(e){switch(e[0]){case"GROUP":this.parseGroup(e);break;case"POLY":this.parsePoly(e);break;case"STRING":this.parseString(e);break;case"AUXLINE":this.parseAuxLine(e);break;case"DIMENSION":this.parseDimension(e);break}}onParseEnd(){for(let e in this.cache){let t=this.cache[e],i=Object.keys(t).sort((s,n)=>Number(s)-Number(n)),r=0;for(let s of i){if(s==="errorIds")continue;let n=Number(s),a=n-r-1;a>=1&&this.onPHolder(e,a),r=n,this.secondParseLine(t[n])}t.errorIds.forEach(s=>this.secondParseLine(s))}this.clearCache()}clearCache(){this.lockConfig=[],this.hideConfig=[],this.invisibleConfig=[],this.coverConfig={},this.commentConfig={},this.trnCtrlConfig={},this.transformConfig={},this.fontCache={},this.cache={},this.version=void 0}parseDocType(e){this.version=Number(e[2])}parseHead(e){this.version<2&&e[1]&&e[1].print==="AHead Side"&&(e[1].print="Ahead Side"),this.onCanvas(e[1])}parseGroup(e){this.onGroup(e[1],e[2],e[3],!!e[4],!!e[5])}parseLock(e){this.lockConfig.push(...e[1])}parseHide(e){this.hideConfig.push(...e[1])}parseInvisible(e){this.invisibleConfig.push(...e[1])}parseCover(e){this.coverConfig[e[1]]=e[2]}parseTrnCtrl(e){this.trnCtrlConfig[e[1]]={scope:e[2],trans_print:e[3],trans_white:e[4]}}parseComment(e){this.commentConfig[e[1]]=e[2]}matrix2svg(e){let[t,i,r,s,n,a,o,l,h]=e.data;return[t,i,s,n,o,l]}encPath(e){let t=new Array;return new sv(i=>(t.push(new nv(!0).encPl(i).toArray().slice(1)),!0),!0).parse(e),t}parseRect(e){var t,i,r,s,n,a,o,l;let[,h,,c,d,f,u,p,g,,,_,y]=e,m=_[0],O=m[1],b=-m[2],v=m[1]+m[3],E=-m[2]+m[4],T=m[5],P=m[6],A=+m[7],C=+m[8],M=$t.scale(v-O,E-b).rotateD(-A);C&&(M=M.multiply3($t.MIRROR_X)),M=M.translate(O,b),M=this.matrix2svg(M),M=this.encMatrix(M),this.onPoly(h,0,c,-A,d,f,u,p,g,!0,[["R",0,0,1,1,T,P,0,0]],!0,!0,this.lockConfig.some(H=>H===e[1]),this.hideConfig.some(H=>H===e[1]),this.invisibleConfig.some(H=>H===e[1]),c===1?1:(t=this.coverConfig[e[1]])!=null?t:null,y||((i=this.commentConfig[e[1]])!=null?i:null),c===2?3:(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,c===2?g:(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,c===2?1-g:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,M!=null?M:null)}parseObj(e){var t,i,r,s,n,a,o,l;let[,h,,c,d,f,u,p,g,,,_,y]=e,[m,O,b,v,E,T,P,A,C]=_[0],M=$t.rotateD(A);C&&(M=M.multiply3($t.MIRROR_X));let H;C?H=new oe(new ge(0,0),new ge(0,-E)).multiply3(M):H=new oe(new ge(0,0),new ge(v,0)).multiply3(M);let k=H.end().angleD(H.start()),F=C===1;v=C===1?E:v,E=C===1?v:E;let j=$t.scale(v,E).rotateD(-k);F&&(j=j.multiply3($t.MIRROR_X)),j=j.translate(O,-b),j=this.matrix2svg(j),j=this.encMatrix(j),this.onPoly(h,0,c,-k,d,f,u,p,g,!0,[["R",0,0,1,1,0,0,0,0]],!1,!1,this.lockConfig.some(L=>L===e[1]),this.hideConfig.some(L=>L===e[1]),this.invisibleConfig.some(L=>L===e[1]),c===1?1:(t=this.coverConfig[e[1]])!=null?t:null,y||((i=this.commentConfig[e[1]])!=null?i:null),c===2?3:(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,c===2?g:(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,c===2?1-g:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,j!=null?j:null)}parseEllipse(e){var t,i,r,s,n,a,o,l;let[,h,,c,d,f,u,p,g,,,_,y]=e,m=_[0],O=m[1],b=-m[2],v=m[3],E=m[4],T=+m[5],P=+m[6],A=$t.scale(v,E).rotateD(-T);P&&(A=A.multiply3($t.MIRROR_X)),A=A.translate(O,b),A=this.matrix2svg(A),A=this.encMatrix(A),this.onPoly(h,0,c,-T,d,f,u,p,g,!0,[["ELLIPSE",0,0,1,1,0,0]],!0,!0,this.lockConfig.some(C=>C===e[1]),this.hideConfig.some(C=>C===e[1]),this.invisibleConfig.some(C=>C===e[1]),c===1?1:(t=this.coverConfig[e[1]])!=null?t:null,y||((i=this.commentConfig[e[1]])!=null?i:null),c===2?3:(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,c===2?g:(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,c===2?1-g:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,A!=null?A:null)}parsePolyGroup(e){var t,i,r,s,n,a,o,l;let[,h,,c,d,f,u,p,g,,,_,y]=e,m=!0,O=!0,b=this.decMultiPoly(_).d;this.onPoly(h,0,c,0,d,f,u,p,g,!0,this.encPath(b),m,O,this.lockConfig.some(v=>v===e[1]),this.hideConfig.some(v=>v===e[1]),this.invisibleConfig.some(v=>v===e[1]),c===1?1:(t=this.coverConfig[e[1]])!=null?t:null,y||((i=this.commentConfig[e[1]])!=null?i:null),c===2?3:(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,c===2?g:(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,c===2?1-g:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,null)}parsePoly(e){var t,i,r,s,n,a,o,l,h,c;if(this.version<2)if(e[11].length===1)switch(e[11][0][0]){case"R":{let d=e[7];return d.startsWith("data:")||d.startsWith("blob:")?this.parseObj(e):this.parseRect(e)}case"ELLIPSE":return this.parseEllipse(e);default:return this.parsePolyGroup(e)}else return this.parsePolyGroup(e);else this.onPoly(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],!!(e[12]||e[12]===void 0),!!(e[13]||e[13]===void 0),this.lockConfig.some(d=>d===e[1]),this.hideConfig.some(d=>d===e[1]),this.invisibleConfig.some(d=>d===e[1]),(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,(c=(h=this.transformConfig[e[1]])==null?void 0:h.matrix)!=null?c:null)}decMultiPoly(e){let t=new Cs,i=e.map(r=>{let s="";return new sv(n=>(t.ext1(n.bbox()),s=new nv().encPl(n).toString(),!1),!1).parse("M"+r.join(" ")),s}).join(" ");return{bbox:t.build(),d:i}}encMatrix(e){let[t,i,r,s,n,a]=e,o=new $t([t,i,0,r,s,0,n,a,1]);o=$t.MIRROR_Y.multiply3(o).multiply3($t.MIRROR_Y);let[l,h,c,d,f,u,p,g,_]=o.data;return[l,d,p,h,f,g]}parseString(e){var t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O;if(this.version<2){let[,b,v,E,T,P,A,C,M,H,k,F,j,L,R,x,I,S,D,N]=e;P=Gr(P);let G=M;C=C===1,j=j===1,L=L===1,R=R===1;let z=-(x[15]/3|0)+2,Z=x%3;D=D||1,N=N||1;let se=this.fontCache[e[1]],{bbox:he,d:pe}=this.decMultiPoly(se),Se=he.width(),q=he.height();q=q||0,Se=Se||0;let X=0;switch(Z){case 1:X=-Se/2;break;case 2:X=-Se;break}let ie=0;switch(z){case 1:ie=q/2;break;case 0:ie=q;break}let de=$t.translate(X,ie).scale(D,N).rotateD(-A);C&&(de=de.multiply3($t.MIRROR_X)),de=de.translate(T,P);let Ce=this.matrix2svg(de),De=this.encMatrix(Ce);this.onString(b,v,E,A,G,H,k,F,j,L,R,((-z||0)+2)*3+(Z||0),I,S,this.lockConfig.some(Fe=>Fe===e[1]),this.hideConfig.some(Fe=>Fe===e[1]),this.invisibleConfig.some(Fe=>Fe===e[1]),E===1?1:(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,E===2?3:(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,E===2?S:(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,E===2?1-S:(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,De,!!De,this.encPath(pe))}else this.onString(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9]===1,e[10]===1,e[11]===1,e[12],e[13],e[14],this.lockConfig.some(b=>b===e[1]),this.hideConfig.some(b=>b===e[1]),this.invisibleConfig.some(b=>b===e[1]),(h=this.coverConfig[e[1]])!=null?h:null,(c=this.commentConfig[e[1]])!=null?c:null,(f=(d=this.trnCtrlConfig[e[1]])==null?void 0:d.scope)!=null?f:null,(p=(u=this.trnCtrlConfig[e[1]])==null?void 0:u.trans_print)!=null?p:null,(_=(g=this.trnCtrlConfig[e[1]])==null?void 0:g.trans_white)!=null?_:null,(m=(y=this.transformConfig[e[1]])==null?void 0:y.matrix)!=null?m:null,!!((O=this.transformConfig[e[1]])!=null&&O.matrix),this.fontCache[e[1]])}parseFontCache(e){this.fontCache[e[1]]=e[2]}parseDimension(e){var t,i,r,s,n,a,o,l,h,c,d,f;this.onDimension(e[1],e[2],e[3],(t=e[4])!=null?t:null,e[5],e[6],e[7],e[8],this.lockConfig.some(u=>u===e[1]),this.hideConfig.some(u=>u===e[1]),this.invisibleConfig.some(u=>u===e[1]),(i=this.coverConfig[e[1]])!=null?i:null,(r=this.commentConfig[e[1]])!=null?r:null,(n=(s=this.trnCtrlConfig[e[1]])==null?void 0:s.scope)!=null?n:null,(o=(a=this.trnCtrlConfig[e[1]])==null?void 0:a.trans_print)!=null?o:null,(h=(l=this.trnCtrlConfig[e[1]])==null?void 0:l.trans_white)!=null?h:null,(d=(c=this.transformConfig[e[1]])==null?void 0:c.matrix)!=null?d:null,!!((f=this.transformConfig[e[1]])!=null&&f.matrix))}parseTransform(e){this.transformConfig[e[1]]={matrix:e[2],strokes:!!e[3]}}parseAuxLine(e){var t,i,r,s,n,a,o,l,h,c,d;this.onAuxLine(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],this.lockConfig.some(f=>f===e[1]),this.hideConfig.some(f=>f===e[1]),this.invisibleConfig.some(f=>f===e[1]),(t=this.coverConfig[e[1]])!=null?t:null,(i=this.commentConfig[e[1]])!=null?i:null,(s=(r=this.trnCtrlConfig[e[1]])==null?void 0:r.scope)!=null?s:null,(a=(n=this.trnCtrlConfig[e[1]])==null?void 0:n.trans_print)!=null?a:null,(l=(o=this.trnCtrlConfig[e[1]])==null?void 0:o.trans_white)!=null?l:null,(c=(h=this.transformConfig[e[1]])==null?void 0:h.matrix)!=null?c:null,!!((d=this.transformConfig[e[1]])!=null&&d.matrix))}},K4=class extends fm{constructor(e={},t=[]){super(),this.symbolPartIds=e,this.device=t,this.defaultPartId="pid8a0e77bacb214e",this.curPart="",this.onlyPart="",this.partIdMap={},this.fontStyleIndex={},this.lineStyleIndex={},this.groupIndex={},this.zIndex=0,this.zIndexMap=new Map,this.cache={},this.errorIds={},this.tableCell={},this.hasPart=!1,this.components={},this.busEntryMap={},this.defaultLineStyle={strokeColor:null,strokeStyle:null,fillColor:null,strokeWidth:null,fillStyle:null},this.defaultFontStyle={color:null,fillColor:null,fontFamily:null,fontSize:null,strikeout:null,underline:null,italic:null,fontWeight:null,hAlign:null,vAlign:null}}getZIndex(e){var t;return(t=this.zIndexMap.get(e))!=null?t:null}transPinAttrKey(e){switch(e){case"NUMBER":{e="Pin Number";break}case"NAME":{e="Pin Name";break}}return e}transFontStyle(e){return{color:e.color,fillColor:e.fillColor,fontFamily:e.fontFamily,fontSize:e.fontSize,strikeout:e.strikeout,underline:e.underline,italic:e.italic,fontWeight:e.fontWeight,align:this.transAlign(e.vAlign,e.hAlign)}}transTableFontStyle(e){return{color:e.color,fillColor:e.fillColor,fontFamily:e.fontFamily,fontSize:e.fontSize,strikeout:e.strikeout,underline:e.underline,italic:e.italic,fontWeight:e.fontWeight,vAlign:this.transVAlign(e.vAlign),hAlign:this.transHAlign(e.hAlign)}}transVAlign(e){switch(e=e&&Number(e),e){case 0:return"TOP";case 1:return"MIDDLE";case 2:return"BOTTOM";default:return null}}transHAlign(e){switch(e=e&&Number(e),e){case 0:return"LEFT";case 1:return"CENTER";case 2:return"RIGHT";default:return null}}transAlign(e,t){if(e=e&&Number(e),t=t&&Number(t),t===0)switch(e){case 0:return"LEFT_TOP";case 1:return"LEFT_MIDDLE";case 2:return"LEFT_BOTTOM";default:return"LEFT_BOTTOM"}if(t===1)switch(e){case 0:return"CENTER_TOP";case 1:return"CENTER_MIDDLE";case 2:return"CENTER_BOTTOM";default:return"CENTER_BOTTOM"}if(t===2)switch(e){case 0:return"RIGHT_TOP";case 1:return"RIGHT_MIDDLE";case 2:return"RIGHT_BOTTOM";default:return"RIGHT_BOTTOM"}switch(e){case 0:return"LEFT_TOP";case 1:return"LEFT_MIDDLE";case 2:return"LEFT_BOTTOM";default:return null}}transStrokeStyle(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"SHORT_DASH";case 2:return"DOT";case 3:return"DOT_DASH";default:return null}}transFillStyle(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"SOLID";case 2:return"GRID";case 3:return"HORIZONTAL_LINE";case 4:return"VERTICAL_LINE";case 5:return"RHOMBIC";case 6:return"LEFT_SLASH_LINE";case 7:return"RIGHT_SLASH_LINE";default:return null}}transPinShape(e){switch(e=e&&Number(e),e){case 0:return"NONE";case 1:return"CLOCK";case 2:return"INVERTED";case 3:return"INVERTED_CLOCK";default:return"NONE"}}onParseLine(e){var t,i;let r=e[0];switch(r){case"DOCTYPE":this.parseDocType(e);break;case"HEAD":this.parseHead(e);break;case"GROUP":this.parseGroup(e);break;case"FONTSTYLE":this.parseFontStyle(e);break;case"LINESTYLE":this.parseLineStyle(e);break;case"TERM":break;case"PART":this.hasPart=!0,this.parsePart(e);break;case"TABEL_CELL":this.parseTableCell(e);break;case"BUSENTRY":{this.parseBusEntry(e);break}case"WIRE":case"BUS":case"TEXT":case"POLY":case"CIRCLE":case"ARC":case"RECT":case"PIN":case"OBJ":case"COMPONENT":case"ELLIPSE":case"BEZIER":case"TABLE":{this.zIndexMap.set(e[1],++this.zIndex);let s=Ku(e[1]);this.cache[r]||(this.cache[r]={}),s!==null&&!this.cache[r][s]?this.cache[r][s]={part:this.curPart,value:e}:(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPart,value:e}));break}case"ATTR":{this.zIndexMap.set(e[1],++this.zIndex),e[3]==="Symbol"&&(this.components[e[2]]||(this.components[e[2]]={symbol:"",device:""}),this.components[e[2]].symbol=e[4]),e[3]==="Device"&&(this.components[e[3]]||(this.components[e[3]]={symbol:"",device:""}),this.components[e[3]].device=e[4]);let s=Object.keys(((t=this.cache)==null?void 0:t.COMPONENT)||{}).find(o=>this.cache.COMPONENT[o].value[1]===e[2]);if(s){let o=this.cache.COMPONENT[s];o.attr||(o.attr=[]),o.attr.push({part:this.curPart,value:e});break}let n=Object.keys(((i=this.cache)==null?void 0:i.PIN)||{}).find(o=>this.cache.PIN[o].value[1]===e[2]);if(n){let o=this.cache.PIN[n];o.attr||(o.attr=[]),o.attr.push({part:this.curPart,value:e});break}let a=Ku(e[1]);this.cache[r]||(this.cache[r]={}),a!==null&&!(this.cache[r][a]&&this.cache[r][a].value[1]!==e[1])?this.cache[r][a]||(this.cache[r][a]={part:this.curPart,value:e}):(this.errorIds[r]||(this.errorIds[r]=[]),this.errorIds[r].push({part:this.curPart,value:e}));break}default:console.warn("can not find hanlder with",e)}}secondParseLine(e){switch(e[0]){case"DOCTYPE":case"HEAD":case"GROUP":case"FONTSTYLE":case"LINESTYLE":break;case"ATTR":this.parseAttr(e);break;case"WIRE":this.parseWire(e);break;case"BUS":this.parseBus(e);break;case"TEXT":this.parseText(e);break;case"POLY":this.parsePoly(e);break;case"CIRCLE":this.parseCircle(e);break;case"ARC":this.parseArc(e);break;case"BUSENTRY":break;case"RECT":this.parseRect(e);break;case"PIN":this.parsePin(e);break;case"OBJ":this.parseObj(e);break;case"COMPONENT":this.parseComponent(e);break;case"ELLIPSE":this.parseEllipse(e);break;case"BEZIER":this.parseBezier(e);break;case"TABLE":this.parseTable(e);break;case"TABEL_CELL":break}}onParseEnd(){this.docType==="SYMBOL"&&!this.hasPart&&(this.curPart=this.defaultPartId,this.onlyPart=this.curPart,this.partIdMap[""]=this.curPart,this.onPart(this.curPart,{title:""}));for(let e in this.cache){let t=this.cache[e],i=Object.keys(t).sort((s,n)=>Number(s)-Number(n)),r=0;for(let s of i){let n=Number(s),a=n-r-1;a>=1&&this.onPHolder(e,a),r=n,this.curPart=this.hasPart?t[n].part||this.onlyPart:this.curPart,this.secondParseLine(t[n].value),t[n].attr&&t[n].attr.forEach(o=>{this.curPart=this.hasPart?o.part||this.onlyPart:this.curPart,this.secondParseLine(o.value)})}if(this.errorIds[e])for(let s of this.errorIds[e])this.curPart=this.hasPart?s.part||this.onlyPart:this.curPart,this.secondParseLine(s.value)}this.clearCache()}clearCache(){this.fontStyleIndex={},this.lineStyleIndex={},this.groupIndex={},this.cache={},this.errorIds={},this.curPart="",this.components={},this.tableCell={},this.hasPart=!1,this.version=void 0,this.docType=void 0}parseDocType(e){this.docType=e[1];let t=parseFloat(e[2]);this.version=t}parseHead(e){this.onCanvas(e[1])}parseFontStyle(e){this.fontStyleIndex[e[1]]={color:e[3]===""?"none":e[3],fillColor:e[2],fontFamily:e[4],fontSize:typeof e[5]=="number"?e[5]:null,strikeout:e[9]===null?null:e[9]===1,underline:e[8]===null?null:e[8]===1,italic:e[6]===null?null:e[6]===1,fontWeight:e[7]===null?null:e[7]===1,vAlign:e[10],hAlign:e[11]}}parseLineStyle(e){this.lineStyleIndex[e[1]]={strokeColor:e[2],strokeStyle:this.transStrokeStyle(e[3]),fillColor:e[4]===""?"none":e[4],strokeWidth:e[5],fillStyle:this.transFillStyle(e[6])}}getGroupId(e){let t=this;for(let i in t.groupIndex){let r=t.groupIndex[i];if(r!=null&&r.includes(e))return i}return""}parseBezier(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);for(let r=0;r<e[2].length;r+=2)e[2][r+1]=Gr(e[2][r+1]);this.onBezier(e[1],this.curPart,i,!!e[4],e[2],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseGroup(e){this.groupIndex[e[1]]=e[4]||[],this.onGroup(e[1],e[2]||"",e[3]||"")}parseBus(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=e[2]||[],r=this.getGroupId(e[1]);this.onBus(e[1],this.curPart,r,!!e[4],i,t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle,this.busEntryMap[e[1]]||{})}parseWire(e){let t=this.lineStyleIndex[e[3]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=e[2]||[],r=this.getGroupId(e[1]);this.onWire(e[1],this.curPart,r,!!e[4],i,t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseText(e){let t=this.fontStyleIndex[e[6]];t||(t=this.defaultFontStyle,console.warn("font not found",e));let i=this.transFontStyle(t),r=this.getGroupId(e[1]);this.onText(e[1],this.curPart,r,!!e[7],e[2],e[3],e[4],e[5],i.color,i.fillColor,i.fontFamily,i.fontSize,i.strikeout,i.underline,i.italic,i.fontWeight,i.align)}parsePoly(e){let t=this.lineStyleIndex[e[4]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onPoly(e[1],this.curPart,i,!!e[5],e[2]||[],!!e[3],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseCircle(e){let t=this.lineStyleIndex[e[5]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onCircle(e[1],this.curPart,i,!!e[6],e[2],e[3],e[4],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseArc(e){let t=this.lineStyleIndex[e[8]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onArc(e[1],this.curPart,i,!!e[9],e[2],e[3],e[4],e[5],e[6],e[7],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseBusEntry(e){let t=e[2],i={groupId:this.getGroupId(e[1]),locked:!1,zIndex:++this.zIndex,order:e[3],pointX:e[4],pointY:Gr(e[5]),rotation:e[6]};this.busEntryMap[t]||(this.busEntryMap[t]={}),this.busEntryMap[t][e[1]]=i}parseRect(e){let t=this.lineStyleIndex[e[9]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onRect(e[1],this.curPart,i,!!e[10],e[2],e[3],e[4],e[5],e[6],e[7],e[8],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parsePin(e){let t=this.getGroupId(e[1]);this.onPin(e[1],this.curPart,t,!!e[10],!!e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.transPinShape(e[9]))}parseObj(e){let t=this.getGroupId(e[1]);this.version>=1.1?this.onObj(e[1],this.curPart,t,!!e[10],e[2],e[3],e[4],e[5],e[6],e[7],!!e[8],e[9]):this.onObj(e[1],this.curPart,t,!!e[10],e[2],e[4],e[5],e[6],e[7],e[8],!1,`data:${e[3]},${e[9]}`)}parseComponent(e){var t,i,r;let s=this.getGroupId(e[1]),n=e[2],a=this.components[e[1]];if(a){if(a.symbol){let o=this.symbolPartIds[a.symbol];o&&(n=o[e[2]]||e[2]||o[(t=Object.keys(o))==null?void 0:t[0]]||"")}else if(a.device){let o=this.device.find(h=>h.uuid===a.device),l=o?this.symbolPartIds[(i=o==null?void 0:o.attributes)==null?void 0:i.Symbol]:null;l&&(n=l[e[2]]||e[2]||l[(r=Object.keys(l))==null?void 0:r[0]]||"")}}this.onComponent(e[1],!!e[8],n,s,e[3],e[4],e[5],e[6]===1,e[7])}parseEllipse(e){let t=this.lineStyleIndex[e[7]];t||(t=this.defaultLineStyle,console.warn("style not found",e));let i=this.getGroupId(e[1]);this.onEllipse(e[1],this.curPart,i,!!e[8],e[2],e[3],e[4],e[5],e[6],t.strokeColor,t.strokeStyle,t.fillColor,t.strokeWidth,t.fillStyle)}parseTable(e){let t=this.getGroupId(e[1]);this.onTable(e[1],this.curPart,t,e[2],e[3],e[4],e[5],e[6],e[7],e[8],this.tableCell[e[1]]||[])}parseTableCell(e){let t=this.lineStyleIndex[e[8]],i=this.lineStyleIndex[e[9]],r=this.lineStyleIndex[e[10]],s=this.lineStyleIndex[e[11]],n=this.fontStyleIndex[e[12]],a=Object.assign({},n);a.color=n.fillColor,a.fillColor=n.color,(!t||!i||!r||!s||!a)&&console.warn("style not found",e);let o={id:e[1],value:e[3],rowIndex:e[4],columnIndex:e[5],rowSpan:e[6],colSpan:e[7],topStyle:t||this.defaultLineStyle,rightStyle:i||this.defaultLineStyle,bottomStyle:r||this.defaultLineStyle,leftStyle:s||this.defaultLineStyle,fontStyle:this.transTableFontStyle(a||this.defaultFontStyle),lineHeight:e[13],zIndex:++this.zIndex};this.tableCell[e[2]]||(this.tableCell[e[2]]=[]),this.tableCell[e[2]].push(o)}parseAttr(e){let t=this.fontStyleIndex[e[10]];t||(t=this.defaultFontStyle,console.warn("fontStyle not found",e));let i=this.transFontStyle(t),r=this.getGroupId(e[1]);this.onAttr(e[1],this.curPart,r,!!e[11],e[2]||"",this.transPinAttrKey(String(e[3])),e[4],e[5]===null?null:!!e[5],e[6]===null?null:!!e[6],e[7]!==null?e[7]:null,e[8]!==null?e[8]:null,e[9],i.color,i.fillColor,i.fontFamily,i.fontSize,i.strikeout,i.underline,i.italic,i.fontWeight,i.align)}parsePart(e){this.curPart=e[1]||this.defaultPartId,this.onlyPart=this.curPart,this.partIdMap[e[1]]=this.curPart;let t=Object.assign(e[2]||{},{title:e[1]||""});this.onPart(this.curPart,t)}},$4=class{constructor(){}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodeAuxLine(e,t){return{id:e,dataType:"AUXLINE",data:JSON.stringify(t)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}},dx=class{constructor(){}editHead(e,t){let i={uuid:e.uuid,nickname:e.nickname,username:e.username,updateTime:t};return`${JSON.stringify({type:"EDIT_HEAD"})}||${JSON.stringify(i)}`}head(e){return Dl(this.doctype,e.client,e.doc,e.updateTime,e.version||String(e.updateTime),e.user,e.ticket)}creator(e,t){let i=typeof t=="string"?t:JSON.stringify(t);return Bs("META_CREATE",e,"META_CREATE",i)}modifier(e,t){let i=typeof t=="string"?t:JSON.stringify(t);return Bs("META_MODIFY",e,"META_MODIFY",i)}delete(e,t){let i=t||JSON.stringify({isDelete:!0});return Bs("DELETE_DOC",e,"DELETE_DOC",i)}},vm=class extends dx{constructor(){super(...arguments),this.doctype="BLOB"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return Bs("BLOB",e,t,r)}buildData(e){return{filename:e.filename,content:e.content}}};var fx=class{constructor(){}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodePanelize(e){return{id:"PANELIZE",dataType:"PANELIZE",data:JSON.stringify(e)}}encodeRuleSelector(e){let t=JSON.stringify(["RULE_SELECTOR",e.ruleSelect]),i={...e};return delete i.ruleSelect,{id:t,dataType:"RULE_SELECTOR",data:JSON.stringify(i)}}encodeRule(e){let t=JSON.stringify(["RULE",e.ruleType,e.ruleName]),i={...e};return delete i.ruleType,delete i.ruleName,{id:t,dataType:"RULE",data:JSON.stringify(i)}}encodeRuleTemplate(e){return{id:"RULE_TEMPLATE",dataType:"RULE_TEMPLATE",data:JSON.stringify(e)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeBoss(e,t){return{id:e,dataType:"BOSS",data:JSON.stringify(t)}}encodeShellEntity(e,t){return{id:e,dataType:"SHELL_ENTITY",data:JSON.stringify(t)}}encodeShellCut(e,t){return{id:e,dataType:"SHELLCUT",data:JSON.stringify(t)}}encodeCrease(e,t){return{id:e,dataType:"CREASE",data:JSON.stringify(t)}}encodeShell(e,t){return{id:e,dataType:"SHELL",data:JSON.stringify(t)}}encodeFpcFill(e,t){return{id:e,dataType:"FPC_FILL",data:JSON.stringify(t)}}encodeTeardrop(e,t){return{id:e,dataType:"TEARDROP",data:JSON.stringify(t)}}encodeImage(e,t){return{id:e,dataType:"IMAGE",data:JSON.stringify(t)}}encodePoured(e,t){return{id:Ms(e,"POURED"),dataType:"POURED",data:JSON.stringify(t)}}encodePour(e,t){return{id:e,dataType:"POUR",data:JSON.stringify(t)}}encodeRegion(e,t){return{id:e,dataType:"REGION",data:JSON.stringify(t)}}encodeFill(e,t){return{id:e,dataType:"FILL",data:JSON.stringify(t)}}encodeLayerFill(e,t){return{id:Ms(e,"LAYER_FILL"),dataType:"LAYER_FILL",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeEQLenGrp(e,t){return{id:e,dataType:"EQLEN_GRP",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeLine(e,t){return{id:e,dataType:"LINE",data:JSON.stringify(t)}}encodePad(e,t){return{id:e,dataType:"PAD",data:JSON.stringify(t)}}encodeVia(e,t){return{id:e,dataType:"VIA",data:JSON.stringify(t)}}encodePreference(e){return{id:"PREFERENCE",dataType:"PREFERENCE",data:JSON.stringify(e)}}encodeSilkOpts(e,t){return{id:Ms(e,"SILK_OPTS"),dataType:"SILK_OPTS",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodePrimitive(e,t){return{id:Ms(e,"PRIMITIVE"),dataType:"PRIMITIVE",data:JSON.stringify(t)}}encodeNet(e,t){return{id:Ms(e,"NET"),dataType:"NET",data:JSON.stringify(t)}}encodeActiveLayer(e){return{id:"ACTIVE_LAYER",dataType:"ACTIVE_LAYER",data:JSON.stringify(e)}}encodeLayerPhys(e,t){return{id:Ms(e,"LAYER_PHYS"),dataType:"LAYER_PHYS",data:JSON.stringify(t)}}encodeLayer(e,t){return{id:Ms(e,"LAYER"),dataType:"LAYER",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}},Q4=class extends CR{constructor(e=!1){super(void 0,void 0,void 0,void 0,e),this.encode=new fx,this.maxTicket=0,this.blobEncode=new vm,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+Bs(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=Bs(e.dataType,++this.maxTicket,e.id,e.data)}getZIndex(e){let t=e.match(dm);return t!=null&&t.length?t[1]:null}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}onLayerFill(e,t){this.handleData(this.encode.encodeLayerFill(e,t))}onString(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m){let O=this.getZIndex(e);this.handleData(this.encode.encodeString(Ut(e),{groupId:i,layerId:r,x:s,y:n,text:a,fontFamily:o,fontSize:l,strokeWidth:h,bold:c,italic:d,origin:f,angle:u,reverse:p,expansion:g,mirror:_,locked:y,zIndex:O===null?null:Number(O),specialColor:m}))}onAttr(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v,E,T){let P=this.getZIndex(e);P&&E&&(P=P+"."+String(E)),this.handleData(this.encode.encodeAttr(Ut(e),{groupId:i,parentId:r,layerId:s,x:n,y:a,key:o,value:l,keyVisible:h,valueVisible:c,fontFamily:d,fontSize:f,strokeWidth:u,bold:p,italic:g,origin:_,angle:y,reverse:m,expansion:O,mirror:b,locked:v,zIndex:P===null?null:Number(P),specialColor:T}))}onPadNet(e,t,i,r,s){}onComponent(e,t,i,r,s,n,a,o,l){}onPanelize(e,t,i,r,s,n,a,o,l,h){this.handleData(this.encode.encodePanelize({on:e,row:t,column:i,rowSpacing:r,columnSpacing:s,onlyOutline:n,horizontalStamp:a,verticalStamp:o,horizontalSize:l,verticalSize:h}))}onRuleSelector(e,t,i,r,s){this.handleData(this.encode.encodeRuleSelector({ruleSelect:e,ruleOrder:t,ruleKeyValue:i,copperValue:r,innerPlaneValue:s}))}onRule(e,t,i,r){this.handleData(this.encode.encodeRule({ruleType:e,ruleName:t,ruleState:i,ruleContext:r}))}onRuleTemplate(e){this.handleData(this.encode.encodeRuleTemplate({name:e}))}onDimension(e,t,i,r,s,n,a,o,l,h,c,d,f){let u=this.getZIndex(e);this.handleData(this.encode.encodeDimension(Ut(e),{type:i,layerId:r,unit:s,strokeWidth:n,precision:a,textFollow:o,coords:l,locked:h,zIndex:u===null?null:Number(u),text:c,specialColor:d,groupId:f}))}onBoss(e,t,i,r,s,n,a,o,l,h,c,d,f){let u=this.getZIndex(e);this.handleData(this.encode.encodeBoss(Ut(e),{groupId:i,layerId:r,centerX:s,centerY:n,specification:a,depth:o,thickness:l,holeDiameter:h,counterBore:c?{height:c[0],diameter:c[1]}:null,stiffener:d?{topWidth:d[0],bottomWidth:d[1],height:d[2],stiffThickness:d[3]}:null,locked:f,zIndex:u===null?null:Number(u)}))}onShellEntity(e,t,i,r,s,n,a,o,l,h,c,d){let f=this.getZIndex(e),u={groupId:i,layerId:r,type:s?"ENTITY":"SLOT",depth:o,strokeWidth:l,path:h,locked:c,zIndex:f===null?null:Number(f),refs:d};u.type==="ENTITY"&&(u.entityBelong=n),u.type==="SLOT"&&(u.slotOptions=a),this.handleData(this.encode.encodeShellEntity(Ut(e),u))}onShellCut(e,t,i,r,s,n,a,o,l){let h=this.getZIndex(e);this.handleData(this.encode.encodeShellCut(Ut(e),{groupId:i,layerId:r,depth:s,strokeWidth:n,path:a,locked:o,zIndex:h===null?null:Number(h),refs:l}))}onCrease(e,t,i,r,s,n,a,o,l,h){let c=this.getZIndex(e);this.handleData(this.encode.encodeCrease(Ut(e),{groupId:i,layerId:r,startX:s,startY:n,endX:a,endY:o,angle:l,locked:h,zIndex:c===null?null:Number(c)}))}onShell(e,t,i,r,s,n,a,o,l,h){let c=this.getZIndex(e),d={groupId:i,shellType:r,shellHeight:s,pcbHeight:n,strokeWidth:a,path:o,thickness:l.Thickness,locked:h,zIndex:c===null?null:Number(c)};r==="DRAWER"&&(d.direction=l.Direction),r==="T&B"&&(d.bottomHeight=l.BottomHeight,d.topInnerHeight=l.TopInnerHeight,d.bottomInnerHeight=l.BottomInnerHeight),this.handleData(this.encode.encodeShell(Ut(e),d))}onFpcFill(e,t,i,r,s,n,a,o){let l=this.getZIndex(e);this.handleData(this.encode.encodeFpcFill(Ut(e),{groupId:i,layerId:r,material:s,thickness:n,path:a,locked:o,zIndex:l===null?null:Number(l)}))}onTeardrop(e,t,i,r,s,n,a){this.handleData(this.encode.encodeTeardrop(Ut(e),{netName:i,layerId:r,path:s,groupId:n,refs:a,locked:!1}))}onImage(e,t,i,r,s,n,a,o,l,h,c,d,f){let u=this.getZIndex(e);this.handleData(this.encode.encodeImage(Ut(e),{groupId:i,layerId:r,startX:s,startY:n,width:a,height:o,angle:l,mirror:h,path:c,locked:d,zIndex:u===null?null:Number(u),specialColor:f}))}onPoured(e,t){this.handleData(this.encode.encodePoured(Ut(e),t))}onPour(e,t,i,r,s,n,a,o,l,h,c,d){let f=this.getZIndex(e);this.handleData(this.encode.encodePour(Ut(e),{groupId:i,netName:r,layerId:s,width:n,name:a,order:o,path:l,pourType:h,keepIsland:c,locked:d,zIndex:f===null?null:Number(f)}))}onRegion(e,t,i,r,s,n,a,o,l,h){let c=this.getZIndex(e);this.handleData(this.encode.encodeRegion(Ut(e),{groupId:i,layerId:r,width:s,prohibitType:n,path:a,locked:o,zIndex:c===null?null:Number(c),name:l,regionType:h}))}onFill(e,t,i,r,s,n,a,o,l,h,c){let d=this.getZIndex(e);this.handleData(this.encode.encodeFill(Ut(e),{groupId:i,netName:r,layerId:s,width:n,fillStyle:a,path:o,locked:l,zIndex:d===null?null:Number(d),isBridgingCopper:!1,networkList:[],refs:h,specialColor:c}))}onPoly(e,t,i,r,s,n,a,o,l){let h=this.getZIndex(e);this.handleData(this.encode.encodePoly(Ut(e),{groupId:i,netName:r,layerId:s,width:n,path:a,locked:o,zIndex:h===null?null:Number(h),specialColor:l,polyType:s==11?"BOARD_OUTLINE":"NORMAL"}))}onEQLenGrp(e,t,i,r){this.handleData(this.encode.encodeEQLenGrp(Ut(e),{name:t,sort:i,pads:r}))}onObj(e,t,i,r,s,n,a,o,l,h,c,d,f,u){if(d.startsWith("data:")){let g=lg(d);this.blobData.push(this.blobEncode.buildStr(1,g,{filename:s,content:d})),d=`blob:${g}`}let p=this.getZIndex(e);this.handleData(this.encode.encodeObj(Ut(e),{groupId:i,layerId:r,fileName:s,startX:n,startY:a,width:o,height:l,angle:h,mirror:c,path:d,locked:f,zIndex:p===null?null:Number(p),specialColor:u}))}onArc(e,t,i,r,s,n,a,o,l,h,c,d,f){let u=this.getZIndex(e);this.handleData(this.encode.encodeArc(Ut(e),{groupId:i,netName:r,layerId:s,startX:n,startY:a,endX:o,endY:l,angle:h,width:c,locked:d,zIndex:u===null?null:Number(u),arcType:"DOT",specialColor:f}))}onCArc(e,t,i,r,s,n,a,o,l,h,c,d,f){let u=this.getZIndex(e);this.handleData(this.encode.encodeArc(Ut(e),{groupId:i,netName:r,layerId:s,startX:n,startY:a,endX:o,endY:l,angle:h,width:c,locked:d,zIndex:u===null?null:Number(u),arcType:"CENT",specialColor:f}))}onLine(e,t,i,r,s,n,a,o,l,h,c){let d=this.getZIndex(e);this.handleData(this.encode.encodeLine(Ut(e),{groupId:i,netName:r,layerId:s,startX:n,startY:a,endX:o,endY:l,width:h,locked:c,zIndex:d===null?null:Number(d)}))}onPad(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v,E,T,P,A,C){let M=this.getZIndex(e);this.handleData(this.encode.encodePad(Ut(e),{groupId:i,netName:r,layerId:s,num:n,centerX:a,centerY:o,padAngle:l,hole:h,defaultPad:c,specialPad:d,padOffsetX:f,padOffsetY:u,relativeAngle:p,plated:g,padType:_,topSolderExpansion:y,bottomSolderExpansion:m,topPasteExpansion:O,bottomPasteExpansion:b,locked:v,zIndex:M===null?null:Number(M),connectMode:E,spokeSpace:T,spokeWidth:P,spokeAngle:A,unusedInnerLayers:C,padLen:0}))}onVia(e,t,i,r,s,n,a,o,l,h,c,d,f,u){let p=this.getZIndex(e);this.handleData(this.encode.encodeVia(Ut(e),{groupId:i,netName:r,ruleName:s,centerX:n,centerY:a,holeDiameter:o,viaDiameter:l,viaType:h,topSolderExpansion:c,bottomSolderExpansion:d,locked:f,zIndex:p===null?null:Number(p),unusedInnerLayers:u}))}onPreference(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O){this.handleData(this.encode.encodePreference({startTrackWidthFollowLast:e,lastTrackWidth:t,startViaSizeFollowLast:i,lastViaInnerDiameter:r,lastViaDiameter:s,snap:n,routingMode:a,routingCorner:o,removeLoop:l,rotatingObject:h,trackFollow:c,stretchTrackMinCorner:d,preferenceConfig:f,realTimeUpdateUnusedLayers:u,unusedPadRange:p,pushVia:g,pathOptimization4BePushed:_,currentPathOptimization4BePushed:y,removeCircuitsContainingVias:m,removeAntenna:O}))}onSilkOpts(e,t,i){this.handleData(this.encode.encodeSilkOpts(e,{defaultColor:t,baseColor:i}))}onGroup(e,t){this.handleData(this.encode.encodeGroup(e,{groupName:t}))}onPrimitive(e,t,i){this.handleData(this.encode.encodePrimitive(e,{display:t,pick:i}))}onNet(e,t,i,r,s,n,a){this.handleData(this.encode.encodeNet(e,{netType:t,specialColor:i,retLine:r,differentialName:s,isPositiveNet:n,equalLengthGroupName:a}))}onPartition(e,t,i,r){}onActiveLayer(e){this.handleData(this.encode.encodeActiveLayer({layerId:e}))}onLayerPhys(e,t,i,r,s,n,a){this.handleData(this.encode.encodeLayerPhys(e,{material:t,thickness:i,permittivity:r,lossTangent:s,isKeepIsland:n,zIndex:a}))}onLayer(e,t,i,r,s,n,a,o,l,h){this.handleData(this.encode.encodeLayer(e,{layerType:t,layerName:i,use:r,show:s,locked:n,activeColor:a,activateTransparency:o,inactiveColor:l,inactiveTransparency:h}))}onCanvas(e,t,i,r,s,n,a,o,l,h,c,d){this.handleData(this.encode.encodeCanvas({originX:e,originY:t,unit:i,gridXSize:r,gridYSize:s,snapXSize:n,snapYSize:a,altSnapXSize:o,altSnapYSize:l,gridType:h,multiGridType:c,multiGridRatio:d,highlightValue:.5}))}};function eM(e,t,i,r=new Date().getTime(),s=String(r),n){let a=new Q4(i),o="",l=pn();if(o=Dl("FOOTPRINT",l,e,r,s,n),a.parseFull(t),a.encodeData&&(o=o+`|
`+a.encodeData),a.blobData.length&&(o=o+`|
`+a.blobEncode.head({doc:"BLOB",client:l,updateTime:r,version:s,user:n})+`|
`+a.blobData.join(`|
`)),a.fontCache.length){let h=new sM,c=h.head({doc:"FONT",client:l,updateTime:r,version:s,user:n});for(let d of a.fontCache){let f=M0(d.text,d.fontFamily,d.fontSize,d.thickness,d.bold,d.italic,d.reverse,d.expansion),u=h.buildStr(1,f,d);c=c+`|
`+u}o=c+`|
`+o}return o}var tM=class{constructor(){}encodePart(e,t){return{id:e,dataType:"PART",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodeTable(e,t){return{id:e,dataType:"TABLE",data:JSON.stringify(t)}}encodeEllipse(e,t){return{id:e,dataType:"ELLIPSE",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodePin(e,t){return{id:e,dataType:"PIN",data:JSON.stringify(t)}}encodeRect(e,t){return{id:e,dataType:"RECT",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeCircle(e,t){return{id:e,dataType:"CIRCLE",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeText(e,t){return{id:e,dataType:"TEXT",data:JSON.stringify(t)}}encodeBezier(e,t){return{id:e,dataType:"BEZIER",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}},iM=class extends K4{constructor(){super(),this.encode=new tM,this.maxTicket=0,this.blobEncode=new vm,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+Bs(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=Bs(e.dataType,++this.maxTicket,e.id,e.data)}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}onPart(e,t){this.handleData(this.encode.encodePart(e,t||{}))}onAttr(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b){this.handleData(this.encode.encodeAttr(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),parentId:s,key:n,value:a,keyVisible:o,valueVisible:l,x:h,y:Gr(c),rotation:d,color:f,fillColor:u,fontFamily:p,fontSize:g,strikeout:_,underline:y,italic:m,fontWeight:O,align:b,version:"2.0"}))}onTable(e,t,i,r,s,n,a,o,l,h,c){this.handleData(this.encode.encodeTable(Ut(e),{partId:t,groupId:i,startX:r,startY:Gr(s),rowSizes:n,colSizes:a,rowLocked:o,colLocked:l,rotation:h,tableCell:c,zIndex:this.getZIndex(e)}))}onEllipse(e,t,i,r,s,n,a,o,l,h,c,d,f,u){this.handleData(this.encode.encodeEllipse(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:s,centerY:Gr(n),radiusX:a,radiusY:Gr(o),rotation:l,strokeColor:h,strokeStyle:c,fillColor:d,strokeWidth:f,fillStyle:u}))}onComponent(){}onObj(e,t,i,r,s,n,a,o,l,h,c,d){if(d.startsWith("data:")){let f=lg(d);this.blobData.push(this.blobEncode.buildStr(1,f,{filename:"",content:d})),d=`blob:${f}`}this.handleData(this.encode.encodeObj(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),fileName:s,startX:n,startY:Gr(a),width:o,height:l,rotation:h,isMirror:c,content:d}))}onPin(e,t,i,r,s,n,a,o,l,h,c,d){this.handleData(this.encode.encodePin(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),display:s,x:a,y:Gr(o),length:l,rotation:h,color:c,pinShape:d}))}onRect(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g){this.handleData(this.encode.encodeRect(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),dotX1:s,dotY1:Gr(n),dotX2:a,dotY2:Gr(o),radiusX:l,radiusY:h,rotation:c,strokeColor:d,strokeStyle:f,fillColor:u,strokeWidth:p,fillStyle:g}))}onArc(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p){this.handleData(this.encode.encodeArc(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),startX:s,startY:Gr(n),referX:a,referY:Gr(o),endX:l,endY:Gr(h),strokeColor:c,strokeStyle:d,fillColor:f,strokeWidth:u,fillStyle:p}))}onCircle(e,t,i,r,s,n,a,o,l,h,c,d){this.handleData(this.encode.encodeCircle(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),centerX:s,centerY:Gr(n),radius:a,strokeColor:o,strokeStyle:l,fillColor:h,strokeWidth:c,fillStyle:d}))}onPoly(e,t,i,r,s,n,a,o,l,h,c){this.handleData(this.encode.encodePoly(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),points:fD(s,!0),closed:n,strokeColor:a,strokeStyle:o,fillColor:l,strokeWidth:h,fillStyle:c}))}onText(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_){this.handleData(this.encode.encodeText(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),x:s,y:Gr(n),rotation:a,value:o,color:l,fillColor:h,fontFamily:c,fontSize:d,strikeout:f,underline:u,italic:p,fontWeight:g,align:_,version:"2.0"}))}onCanvas(e){this.handleData(this.encode.encodeCanvas({originX:e.originX,originY:Gr(e.originY)}))}onBezier(e,t,i,r,s,n,a,o,l,h){this.handleData(this.encode.encodeBezier(Ut(e),{partId:t,groupId:i,locked:r,zIndex:this.getZIndex(e),controls:s,strokeColor:n,strokeStyle:a,fillColor:o,strokeWidth:l,fillStyle:h}))}onGroup(e,t,i){this.handleData(this.encode.encodeGroup(String(e),{parentId:t,title:i}))}onBus(){}onWire(){}};function rM(e,t,i=new Date().getTime(),r=String(i),s){let n=new iM,a="";n.parseFull(t);let o=pn();n.encodeData&&(a=Dl("SYMBOL",o,e,i,r,s)+`|
`+n.encodeData),a&&n.blobData.length&&(a=a+`|
`+n.blobEncode.head({doc:"BLOB",client:o,updateTime:i,version:r,user:s})+`|
`+n.blobData.join(`|
`));let l=n.partIdMap;return n.partIdMap={},{dataStr:a,partIdMap:l}}var sM=class extends dx{constructor(){super(...arguments),this.doctype="FONT"}buildStr(e,t,i){let r=typeof i=="string"?i:JSON.stringify(this.buildData(i));return Bs("FONT",e,t,r)}buildData(e){return{width:e.width,height:e.height,path:e.path}}};var nM=class extends Z4{constructor(){super(),this.encode=new $4,this.maxTicket=0,this.blobEncode=new vm,this.blobData=[],this.encodeData="",this.placeholder=0}handleData(e){this.encodeData?this.encodeData=this.encodeData+`|
`+Bs(e.dataType,++this.maxTicket,e.id,e.data):this.encodeData=Bs(e.dataType,++this.maxTicket,e.id,e.data)}onPHolder(e,t){let i={dataType:e,max:t};this.handleData({id:`placeholder${++this.placeholder}`,dataType:"ELE_PLACEHOLDER",data:JSON.stringify(i)})}strokeStyleType(e){switch(e=e&&Number(e),e){case 0:return"SOLID";case 1:return"SHORT_DASH";case 2:return"DOT";case 3:return"DOT_DASH";default:return null}}transScopeType(e){switch(e=e&&Number(e),e){case 1:return"PRINT";case 2:return"COVER";case 3:return"PRINT&COVER";default:return null}}transAlignType(e){switch(e=e&&Number(e),e){case 0:return"LEFT_BOTTOM";case 1:return"CENTER_BOTTOM";case 2:return"RIGHT_BOTTOM";case 3:return"LEFT_MIDDLE";case 4:return"CENTER_MIDDLE";case 5:return"RIGHT_MIDDLE";case 6:return"LEFT_TOP";case 7:return"CENTER_TOP";case 8:return"RIGHT_TOP";default:return null}}onAuxLine(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O){this.handleData(this.encode.encodeAuxLine(Ut(e),{groupId:t?`e${t}`:"",layer:i,x:r,y:s,rotation:n,strokeWidth:a,strokeStyle:this.strokeStyleType(o),color:l,length:h,locked:c,zIndex:this.getZIndex(e),visible:!f,cover:u,name:p}))}onDimension(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y){this.handleData(this.encode.encodeDimension(Ut(e),{layer:t,dimensionType:i,unit:r,strokeWidth:s,accuracy:n,controlDot:a,relationIds:o,locked:l,zIndex:this.getZIndex(e),valid:!h,visible:!c,cover:d,name:f,rotation:0}))}onString(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v,E,T,P){this.handleData(this.encode.encodeString(Ut(e),{groupId:t?`e${t}`:"",layer:i,rotation:r,value:s,fontFamily:n,fontSize:a,fontWeight:o,italic:l,underline:h,strikeout:c,align:this.transAlignType(d),strokeColor:f,opacity:u,locked:p,zIndex:this.getZIndex(e),valid:!g,visible:!_,cover:y,transScope:this.transScopeType(O),transPrint:b,transWhite:v,matrix:E,strokes:T,path:P,name:m}))}onPoly(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v){if(typeof o=="string"&&o.startsWith("data:")){let E=lg(o);this.blobData.push(this.blobEncode.buildStr(1,E,{filename:"",content:o})),o=`blob:${E}`}this.handleData(this.encode.encodePoly(Ut(e),{groupId:t?`e${t}`:"",layer:i,rotation:r,strokeWidth:s,strokeStyle:this.strokeStyleType(n),strokeColor:a,fillColor:o,opacity:l,autoClose:h,ploys:c,displayFill:d,displayStroke:f,locked:u,zIndex:this.getZIndex(e),valid:!p,visible:!g,cover:_,transScope:this.transScopeType(m),transPrint:O,transWhite:b,matrix:v,name:y}))}onGroup(e,t,i,r,s){this.handleData(this.encode.encodeGroup(`e${e}`,{parentId:t?`e${t}`:"",title:i,visible:r,locked:s}))}onCanvas(e){this.handleData(this.encode.encodeCanvas(e))}};function aM(e,t,i,r=new Date().getTime(),s=String(r),n){let a=new nM,o="";a.parseFull(t);let l=pn();return a.encodeData&&(o=Dl(i,l,e,r,s,n)+`|
`+a.encodeData),o&&a.blobData.length&&(o=o+`|
`+a.blobEncode.head({doc:"BLOB",client:l,updateTime:r,version:s,user:n})+`|
`+a.blobData.join(`|
`)),o}var px=class extends uR{constructor(e){let t=e||new Rv;super(t,0,OD),this.cacheNum=null}onParseLine(e,t,i,r,s,n,a){switch(this.setOrderNum(e,a,t),this.cacheNum=a,t){case"MAX_NUM":if(i)for(let l in i)this.setMaxNum(l,i[l]);break;case"BLOB":i?this.onBlob(e,r,s,i,n):this.onDelBlob(e,r,s,n);break;case"FONT":this.parseFont(e,i,r,s,n);break;case"META":i&&this.parseDetail(i,r,s,n);break;case"ELE_PLACEHOLDER":break;case"CANVAS":i&&this.parseCanvas(i,r,s,n);break;case"BOARD":i?this.parseBoard(i,r,s,n):this.onDelBoard(r,s,n);break;case"LAYER":{let l=Lo(e);i?this.parseLayer(l,i,r,s,n):this.onDelLayer(l,r,s,n);break}case"LAYER_PHYS":{let l=Lo(e);i?this.parseLayerPhys(l,i,r,s,n):this.onDelLayerPhys(l,r,s,n);break}case"ACTIVE_LAYER":i&&this.parseActiveLayer(e,i,r,s,n);break;case"PARTITION":i?this.parsePartition(e,i,r,s,n):this.onDelPartition(e,r,s,n);break;case"NET":{let l=Lo(e);i?this.parseNet(l,i,r,s,n):this.onDelNet(l,r,s,n);break}case"PRIMITIVE":{let l=Lo(e);i?this.parsePrimitive(l,i,r,s,n):this.onDelPrimitive(l,r,s,n);break}case"GROUP":i?this.parseGroup(e,i,r,s,n):this.onDelGroup(e,r,s,n);break;case"X_SIGNAL_GROUP":i?this.parseXSignalsGroup(e,i,r,s,n):this.onDelXSignalsGroup(e,r,s,n);break;case"X_SIGNALS":i?this.parseXSignals(e,i,r,s,n):this.onDelXSignals(e,r,s,n);break;case"SILK_OPTS":{let l=Lo(e);i?this.parseSilkOpts(l,i,r,s,n):this.onDelSilkOpts(l,r,s,n);break}case"PREFERENCE":i&&this.parsePreference(e,i,r,s,n);break;case"VIA":i?this.parseVia(e,i,r,s,n):this.onDelVia(e,r,s,n);break;case"PAD":i?this.parsePad(e,i,r,s,n):this.onDelPad(e,r,s,n);break;case"LINE":i?this.parseLine(e,i,r,s,n):this.onDelLine(e,r,s,n);break;case"ARC":i?this.parseArc(e,i,r,s,n):this.onDelArc(e,r,s,n);break;case"OBJ":i?this.parseObj(e,i,r,s,n):this.onDelObj(e,r,s,n);break;case"EQLEN_GRP":i?this.parseEQLenGrp(e,i,r,s,n):this.onDelEQLenGrp(e,r,s,n);break;case"POLY":i?this.parsePoly(e,i,r,s,n):this.onDelPoly(e,r,s,n);break;case"FILL":i?this.parseFill(e,i,r,s,n):this.onDelFill(e,r,s,n);break;case"LAYER_FILL":let o=Lo(e);i?this.parseLayerFill(o,i,r,s,n):this.onDelLayerFill(o,r,s,n);break;case"REGION":i?this.parseRegion(e,i,r,s,n):this.onDelRegion(e,r,s,n);break;case"POUR":i?this.parsePour(e,i,r,s,n):this.onDelPour(e,r,s,n);break;case"POURED":{e=Lo(e),i?this.parsePoured(e,i,r,s,n):this.onDelPoured(e,r,s,n);break}case"IMAGE":i?this.parseImage(e,i,r,s,n):this.onDelImage(e,r,s,n);break;case"TEARDROP":i?this.parseTeardrop(e,i,r,s,n):this.onDelTeardrop(e,r,s,n);break;case"FPC_FILL":i?this.parseFpcFill(e,i,r,s,n):this.onDelFpcFill(e,r,s,n);break;case"SHELL":i?this.parseShell(e,i,r,s,n):this.onDelShell(e,r,s,n);break;case"CREASE":i?this.parseCrease(e,i,r,s,n):this.onDelCrease(e,r,s,n);break;case"SHELLCUT":i?this.parseShellCut(e,i,r,s,n):this.onDelShellCut(e,r,s,n);break;case"SHELL_ENTITY":i?this.parseShellEntity(e,i,r,s,n):this.onDelShellEntity(e,r,s,n);break;case"BOSS":i?this.parseBoss(e,i,r,s,n):this.onDelBoss(e,r,s,n);break;case"STRING":i?this.parseString(e,i,r,s,n):this.onDelString(e,r,s,n);break;case"ATTR":i?this.parseAttr(e,i,r,s,n):this.onDelAttr(e,r,s,n);break;case"DIMENSION":i?this.parseDimension(e,i,r,s,n):this.onDelDimension(e,r,s,n);break;case"COMPONENT":i?this.parseComponent(e,i,r,s,n):this.onDelComponent(e,r,s,n);break;case"PAD_NET":{let l=JSON.parse(e);i?(i.componentId=l[1],i.padNum=l[2],i.padId=l[3],this.parsePadNet(i,r,s,n)):this.onDelPadNet(l[1],l[2],l[3]||"",r,s,n);break}case"RULE_TEMPLATE":i&&this.parseRuleTemplate(e,i,r,s,n);break;case"RULE":{let l=JSON.parse(e);i?(i.ruleType=l[1],i.ruleName=l[2],this.parseRule(i,r,s,n)):this.onDelRule(l[1],l[2],r,s,n);break}case"RULE_SELECTOR":{let l=JSON.parse(e);i?(i.ruleSelect=l[1],this.parseRuleSelector(i,r,s,n)):this.onDelRuleSelector(l[1],r,s,n);break}case"PANELIZE":i?this.parsePanelize(e,i,r,s,n):this.onDelPanelize(r,s,n);break;default:console.warn("can not find hanlder with",i,r,s)}this.cacheNum=null}onOrderNum(e,t,i){switch(this.setOrderNum(e,i,t),t){case"PARTITION":this.onPartitionNum&&this.onPartitionNum(e,i);break;case"VIA":this.onViaNum&&this.onViaNum(e,i);break;case"PAD":this.onPadNum&&this.onPadNum(e,i);break;case"LINE":this.onLineNum&&this.onLineNum(e,i);break;case"ARC":this.onArcNum&&this.onArcNum(e,i);break;case"OBJ":this.onObjNum&&this.onObjNum(e,i);break;case"POLY":this.onPolyNum&&this.onPolyNum(e,i);break;case"FILL":this.onFillNum&&this.onFillNum(e,i);break;case"REGION":this.onRegionNum&&this.onRegionNum(e,i);break;case"POUR":this.onPourNum&&this.onPourNum(e,i);break;case"POURED":let r=Lo(e);this.onPouredNum&&this.onPouredNum(r,i);break;case"IMAGE":this.onImageNum&&this.onImageNum(e,i);break;case"TEARDROP":this.onTeardropNum&&this.onTeardropNum(e,i);break;case"FPC_FILL":this.onFpcFillNum&&this.onFpcFillNum(e,i);break;case"SHELL":this.onShellNum&&this.onShellNum(e,i);break;case"CREASE":this.onCreaseNum&&this.onCreaseNum(e,i);break;case"SHELLCUT":this.onShellCutNum&&this.onShellCutNum(e,i);break;case"SHELL_ENTITY":this.onShellEntityNum&&this.onShellEntityNum(e,i);break;case"BOSS":this.onBossNum&&this.onBossNum(e,i);break;case"STRING":this.onStringNum&&this.onStringNum(e,i);break;case"ATTR":this.onAttrNum&&this.onAttrNum(e,i);break;case"DIMENSION":this.onDimensionNum&&this.onDimensionNum(e,i);break;case"COMPONENT":this.onComponentNum&&this.onComponentNum(e,i);break}}onParseEnd(){}parseCanvas(e,t,i,r){this.onCanvas(t,i,e,r)}parseBoard(e,t,i,r){this.onBoard(e,t,i,r)}parseDetail(e,t,i,r){this.onDocDetail(t,i,e,r)}parseFont(e,t,i,r,s){let n=oR(e);t?this.onFont(i,r,Object.assign(t,n),s):this.onDelFont(n,i,r,s)}parseLayer(e,t,i,r,s){this.onLayer(e,i,r,t,s)}parseLayerPhys(e,t,i,r,s){this.onLayerPhys(e,i,r,t,s)}parseActiveLayer(e,t,i,r,s){this.onActiveLayer(i,r,t,s)}parsePartition(e,t,i,r,s){this.onPartition(e,this.cacheNum,i,r,t,s)}parseNet(e,t,i,r,s){this.onNet(e,i,r,t,s)}parsePrimitive(e,t,i,r,s){this.onPrimitive(e,i,r,t,s)}parseGroup(e,t,i,r,s){this.onGroup(e,i,r,t,s)}parseXSignalsGroup(e,t,i,r,s){this.onXSignalsGroup(e,t,i,r,s)}parseXSignals(e,t,i,r,s){this.onXSignals(e,t,i,r,s)}parseSilkOpts(e,t,i,r,s){this.onSilkOpts(e,i,r,t,s)}parsePreference(e,t,i,r,s){this.onPreference(i,r,t,s)}parseVia(e,t,i,r,s){this.onVia(e,this.cacheNum,i,r,t,s)}parsePad(e,t,i,r,s){this.onPad(e,this.cacheNum,i,r,t,s)}parseLine(e,t,i,r,s){this.onLine(e,this.cacheNum,i,r,t,s)}parseArc(e,t,i,r,s){this.onArc(e,this.cacheNum,i,r,t,s)}parseObj(e,t,i,r,s){this.onObj(e,this.cacheNum,i,r,t,s)}parseEQLenGrp(e,t,i,r,s){this.onEQLenGrp(e,i,r,t,s)}parsePoly(e,t,i,r,s){this.onPoly(e,this.cacheNum,i,r,t,s)}parseFill(e,t,i,r,s){t.fillStyle!=="PLANE"&&this.onFill(e,this.cacheNum,i,r,t,s)}parseLayerFill(e,t,i,r,s){this.onLayerFill(e,i,r,t,s)}parseRegion(e,t,i,r,s){this.onRegion(e,this.cacheNum,i,r,t,s)}parsePour(e,t,i,r,s){this.onPour(e,this.cacheNum,i,r,t,s)}parsePoured(e,t,i,r,s){let n=t;Array.isArray(t)&&(n={pourFill:t}),n.pourFill&&this.onPoured(e,this.cacheNum,i,r,n,s)}parseImage(e,t,i,r,s){this.onImage(e,this.cacheNum,i,r,t,s)}parseTeardrop(e,t,i,r,s){this.onTeardrop(e,this.cacheNum,i,r,t,s)}parseFpcFill(e,t,i,r,s){this.onFpcFill(e,this.cacheNum,i,r,t,s)}parseShell(e,t,i,r,s){this.onShell(e,this.cacheNum,i,r,t,s)}parseCrease(e,t,i,r,s){this.onCrease(e,this.cacheNum,i,r,t,s)}parseShellCut(e,t,i,r,s){this.onShellCut(e,this.cacheNum,i,r,t,s)}parseShellEntity(e,t,i,r,s){this.onShellEntity(e,this.cacheNum,i,r,t,s)}parseBoss(e,t,i,r,s){this.onBoss(e,this.cacheNum,i,r,t,s)}parseDimension(e,t,i,r,s){this.onDimension(e,this.cacheNum,i,r,t,s)}parseRuleTemplate(e,t,i,r,s){this.onRuleTemplate(i,r,t,s)}parseRule(e,t,i,r){this.onRule(t,i,e,r)}parseRuleSelector(e,t,i,r){if(e.ruleKeyValue&&(e.ruleKeyValue=kh(e.ruleKeyValue)),e.copperValue&&e.copperValue.hasOwnProperty("7")){let s=e.copperValue[7];delete e.copperValue[7],e.copperValue.COPPER=s}if(e.innerPlaneValue&&e.innerPlaneValue.hasOwnProperty("6")){let s=e.innerPlaneValue[6];delete e.innerPlaneValue[6],e.innerPlaneValue.PLANE=s}this.onRuleSelector(t,i,e,r)}parsePanelize(e,t,i,r,s){this.onPanelize(i,r,t,s)}parseComponent(e,t,i,r,s){this.onComponent(e,this.cacheNum,i,r,t,s)}parsePadNet(e,t,i,r){this.onPadNet(t,i,e,r)}parseAttr(e,t,i,r,s){this.onAttr(e,this.cacheNum,i,r,t,s)}parseString(e,t,i,r,s){this.onString(e,this.cacheNum,i,r,t,s)}},oM=(e=>(e.UNIVERSAL="UNIVERSAL",e))(oM||{}),lM=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))(lM||{}),hM=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(hM||{}),cM=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(cM||{}),uM=ic(ld());function td(){return self.EDITOR_TOP||self}function $h(e){return self[e]=self[e]||new uM.BroadcastChannelMessageBus(e)}var Al=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let s=0;s<r.length;s++){let n=r[s],a=n.substring(1,n.length-1);t[a]&&(e=e.replace(n,t[a]))}return e},dM=ic(ld()),fi={getTime:"/pro-mgr/serverTime/now",getUserL:"/pro-ui/loginUser/get",subMaxTick:"/pro-mgr/project/ticket",subBlob:"/pro-mgr/canvas/BLOB/update",subFont:"/pro-mgr/canvas/FONT/update",subRevoke:"/pro-mgr/{uuid}/revoke",pushPend:"/pro-mgr/worker/batchPendData",pushSync:"/pro-mgr/dataWorker/sync",pushRevoke:"/pro-mgr/worker/revoke",pullASync:"/pro-mgr/dataWorker/sync/{id}",personDestroy:"/mgr/libWorker/destroy",projectUpdate:"/pro-mgr/canvas/{uuid}/update",personUpdate:"/mgr/libWorker/component/{uuid}/update",personSave:"/mgr/libWorker/save",projectSave:"/mgr/projectWorker/setCanvas",canSavePend:"/mgr/projectWorker/canSavePend",hasSaveData:"/mgr/check/hasSaveData"},fM={projectUpdate:fi.projectUpdate,personUpdate:fi.personUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},pM={projectUpdate:fi.projectUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},vZ={projectUpdate:fi.projectUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},xZ={projectUpdate:fi.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},EZ={projectUpdate:fi.projectUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},wZ={projectUpdate:fi.projectUpdate,personUpdate:fi.personUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},TZ={projectUpdate:fi.projectUpdate,personUpdate:fi.personUpdate,projectCanSave:fi.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"},Ns={send:"/pro-mgr/notify/send",sendMsg:"/document/sendMsg/cooperation",unwatch:"/document/unwatch/cooperation",watch:"/document/watch/cooperation",message:"/pro-mgr/notify/message/{path}/{uuid}/cooperation",established:"/pro-mgr/notify/message/ws/established",getWsId:"/pro-mgr/notify/getWsId",disconnect:"/pro-mgr/notify/message/ws/disconnect"},xm=class{constructor(e=!0){this._lockerTicket=0,this.isPull=!1,this.compiler={},this.order={SYMBOL:1,FOOTPRINT:2,DEVICE:3,SCH_PAGE:4,PCB:5},this._locker=e?++this._lockerTicket:0}getOrder(e){return this.order[e]||6}publish(){if(!this.isPull){this.isPull=!0,this._temporaryUnlock=this._locker;try{let e=Object.keys(this.compiler).sort((i,r)=>this.getOrder(i)-this.getOrder(r)),t=!1;for(let i of e){for(let[,r]of this.compiler[i])if(t=r.publish(),t)break;if(t)break}}finally{this._temporaryUnlock=0,this.isPull=!1}}}canPush(){return!this._locker||this._locker===this._temporaryUnlock}addCompiler(e){this.compiler[e.headType]||(this.compiler[e.headType]=new Map),this.compiler[e.headType].set(e.uniqueId,e)}removeCompiler(e){var t,i,r;(r=(i=(t=this.compiler)==null?void 0:t[e.headType])==null?void 0:i.delete)==null||r.call(i,e.uniqueId)}pull(){if(!this._locker)throw Error("\u4E0D\u5141\u8BB8\u5728\u975E pause \u72B6\u6001\u4E0B\u62C9\u53D6\u6570\u636E");this.publish()}resume(){this._locker=0,this.publish()}pause(){this._locker=++this._lockerTicket}dispose(){for(let e in this.compiler)this.compiler[e].clear();this.compiler=null}},Ro={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},gM=class{constructor(e,t,i,r=(a=>(a=td())==null?void 0:a._TAB_ID_)(),s,n){this.uuid=e,this.path=t,this.user=i,this.windowId=r,this.initIds={},this.sub=[];var a;this.wsBus=n||$h(`/${this.windowId}/notify`),this.dataBus=s||this.wsBus,this._client=(a=td())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(Ns.send,{topic:Ns.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(Ns.send,{topic:Ns.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ro.publish,user:this.user,client:this.client,data:((e=this.getSelect)==null?void 0:e.call(this))||""}})}async init(){if(!this.isInit){if(this.sub.push(this.wsBus.subscribe(Ns.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(Ns.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(Ns.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(Al(Ns.message,{uuid:this.uuid,path:this.path}),e=>{if(e.type===1)e.connectId&&this.initIds[e.connectId]&&this.onDestroy(this.initIds[e.connectId],e.connectId);else if(e.msg){let t=e.msg;if(t.client===this.client)return;switch(t.type){case Ro.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case Ro.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case Ro.selected:this.onSelected(t.user,t.client,t.data||"");break;case Ro.publish:this.dataBus.publish(Ns.send,{topic:Ns.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ro.init,user:this.user,client:this.client,data:this.getSelect()||""}}),this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||"");break;default:break}}})),this.initPublish(),this.isInit=!0}}publishSelected(e,t){this.dataBus.publish(Ns.send,{topic:Ns.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Ro.selected,user:this.user,client:this.client,data:e}}),t&&this.onSelected(this.user,this.client,e)}destroy(){if(this.isInit){this.isInit=!1,this.dataBus.publish(Ns.send,{topic:Ns.unwatch,uuid:this.uuid,path:this.path,msg:{type:Ro.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},av=class extends gM{constructor(e,t,i,r,s,n,a,o){super(e,t,o,i,s,n),this.channel=r,this.selectedProps=a,this.cache=new Map,this.deleteCache=new Map}rePublish(){var e,t,i,r;if(this.channel.canPush()){for(let[s,n]of this.cache)(t=(e=this.selectedProps)==null?void 0:e.onSelect)==null||t.call(e,n.user,s,n.data);for(let[s,n]of this.deleteCache)(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,n,s)}}getSelect(){var e,t;return((t=(e=this.selectedProps)==null?void 0:e.getSelect)==null?void 0:t.call(e))||""}onSelected(e,t,i){var r,s;this.channel.canPush()?!this.deleteCache.has(t)&&this.cache.set(t,{user:e,data:i}):(s=(r=this.selectedProps)==null?void 0:r.onSelect)==null||s.call(r,e,t,i)}onDestroy(e,t){var i,r;this.channel.canPush()?(this.deleteCache.set(t,e),this.cache.delete(t)):(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,e,t)}dispose(){this.destroy(),this.cache.clear(),this.deleteCache.clear()}publishSelected(e,t){super.publishSelected(e,t)}},_M=class{constructor(e,t,i,r=(y=>(y=td())==null?void 0:y._TAB_ID_)(),s=new xm,n=null,a,o,l,h,c,d,f,u,p,g,_){this.uuid=e,this.path=t,this.isProject=i,this.windowId=r,this.channel=s,this.consistencyManager=n,this.selectedProps=l,this.setInit=h,this.onDocDetail=c,this.onUpdate=d,this.handleInit=f,this.onDelete=u,this.publishCache=p,this.onOrderNm=g,this.setMaxNum=_,this.isInit=!1,this.canSave=!0,this.sub=[],this.isInitIng=!1,this.cache={},this.deleteCache=new Map,this.pendTimer=null,this.pendCache={},this.pendCacheLength=0,this.wsBus=$h(`/${r}/notify`),n||(this._unique=pn()),this._headType=a,this.busTopic=o}get uniqueId(){return this._unique||this.consistencyManager.getUnique()}get headType(){return this._headType}setIsInitIng(e){var t;(t=this.setInit)==null||t.call(this,e),this.isInitIng=e}consoleDebug(...e){console.debug("[lc-protocol]",this._headType,this.uuid,...e)}publishLine(e,t,i,r,s,n=this.uuid,a,o,l,h,c){if(this.channel.canPush())return this.consistencyManager.remoteChange(t,s,n,e,i,r,void 0,void 0,void 0,a,void 0,o,l,c),!1;this.cache[n]||(this.cache[n]=new Map);let d=this.cache[n].get(e);return(h||!d||d.ticket<t||d.ticket===t&&(d.client<s||d.client===s&&!!d.pend!=!!a))&&this.cache[n].set(e,{client:s,ticket:t,dataType:r,data:i,pend:a,unique:o,pChange:d?void 0:l,num:c}),!0}onDocHead(){}onEnd(){}setDocType(e,t){e===this.uuid&&(this._headType=t)}setBusTopic(e){this.busTopic=e}publish(){var e,t,i;if(this.publishCache)return this.publishCache();let r=!1;for(let[s,n]of this.deleteCache){if(this.channel.canPush()){(e=this.onDelete)==null||e.call(this,n),delete this.cache[s];continue}r=!0;break}if(r)return r;for(let s in this.cache){let n=this.cache[s].keys();for(let a of n){let o=this.cache[s].get(a);if(r=this.publishLine(a,o.ticket,o.data,o.dataType,o.client,s,o.pend,o.unique,o.pChange,!1,o.num),r)break;this.cache[s].delete(a)}if(r)break}return(i=(t=this.selectManager)==null?void 0:t.rePublish)==null||i.call(t),r}publishSelected(e,t){this.selectManager.publishSelected(e,t)}clear(){var e,t;for(let i of this.sub)i.cancel();this.sub.length=0,this.cache={},this.deleteCache.clear(),this.setIsInitIng(!1),this.channel.removeCompiler(this),(t=(e=this.selectManager)==null?void 0:e.dispose)==null||t.call(e),this.selectManager=null,this.isInit=!1,this.setIsInitIng(!1)}async init(e=!0,t=!0,i=!0,r,s,n,a){try{if(this.isInit)return{success:!0};if(this.isInitIng)throw new Error("\u6B63\u5728\u521D\u59CB\u5316\u4E2D");return this.isProject?await this.initProject(e,t,i,r,n,a):await this.initLib(i,r,s,n,a)}catch(o){throw this.clear(),new Error(`${this._headType}+'Compiler' ${this.uuid} init false: ${(o==null?void 0:o.message)||o||""}`,{cause:o})}finally{this.isInitIng=!1}}async flowRead(e){let t=this.consistencyManager.flowParseFull(),i=t.update,r=this;t.update=s=>{if(r.isDestroy)return!0;i(s)},await(0,dM.flowRead)(e,t)}pushOnLine(e,t){if(this.consistencyManager)for(let i of e)this.publishLine(i[0],i[1],i[2],i[3],i[4],t,i[5],i[6],i[7],!1,i[8])}async initProject(e,t,i,r,s,n){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=$h(`/${this.windowId}/project/${this.path}`),s&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let h of l)this.onOrderNm(h[0],h[1],h[2])})),i&&this.busTopic.projectUpdate&&this.sub.push(this.dataBus.subscribe(Al(this.busTopic.projectUpdate,{uuid:this.uuid}),l=>{this.onUpdate?this.onUpdate(l):this.pushOnLine(l,this.uuid)})),i&&this.busTopic.projectCanSave&&this.sub.push(this.dataBus.subscribe(this.busTopic.projectCanSave,l=>{this.canSave=l})),i&&this.busTopic.subDelete&&this.sub.push(this.dataBus.subscribe(this.busTopic.subDelete,l=>{var h;this.channel.canPush()?(h=this.onDelete)==null||h.call(this,l):this.deleteCache.set(l[0],l)})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(fi.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(fi.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(fi.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Al(fi.subRevoke,{uuid:this.uuid}),l=>this.revoke(l))),!this.busTopic.getProject)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");this.isDestroy=!1;let a={doc:[this.uuid],watch:i,needNum:s,needDelete:n};t&&a.doc.push("BLOB"),e&&a.doc.push("FONT");let o=await this.dataBus.rpcCall(this.busTopic.getProject,a);if(this.isWatch=i,!this.isDestroy){if(!o.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",o);if(this.canSave=!(o!=null&&o.readOnly),this.consoleDebug("init",o.result),o.maxTicket&&this.consistencyManager&&this.consistencyManager.setMaxTicket(o.maxTicket),o.data&&this.onDocDetail&&this.onDocDetail(o.client||pn(),0,o.data,!1),o.channel&&await this.flowRead(o.channel),!this.isDestroy){if(this.handleInit?this.handleInit(o):o.result&&this.consistencyManager&&this.consistencyManager.parseFull(o.result,this.uuid,this._headType),r){let l=this.user=this.user||o.user||await this.wsBus.rpcCall(fi.getUserL);this.selectManager=new av(this.uuid,this.path,this.windowId,this.channel,this.dataBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}}async initLib(e,t,i,r,s){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=$h(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let n=i?pn():"";this.isDestroy=!1;let a=await this.dataBus.rpcCall(this.busTopic.getPerson,{uuid:this.uuid,path:this.path,watch:e,channel:n,needNum:r,needDelete:s});if(this.isWatch=e,this.isDestroy)return;if(!a.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",a);this.consoleDebug("init",a.dataStr);let o=a.data||a.result;if(o&&this.onDocDetail&&this.onDocDetail(a.client||pn(),0,o,!1),r&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let h of l)this.onOrderNm(h[0],h[1],h[2])})),e&&this.busTopic.personUpdate&&this.sub.push(this.dataBus.subscribe(Al(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(Al(Al(fi.subRevoke,{uuid:this.uuid}),{uuid:this.uuid}),l=>this.revoke(l))),n&&await this.flowRead(n),!this.isDestroy){if(a.dataStr&&this.consistencyManager&&this.consistencyManager.parseFull(a.dataStr),t){let l=this.user=this.user||a.user||await this.wsBus.rpcCall(fi.getUserL);this.selectManager=new av(this.uuid,this.path,this.windowId,this.channel,this.wsBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}revoke(e){for(let t of e)this.consistencyManager&&this.consistencyManager.revoke(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],(...i)=>this.publishLine(...i)),t[10]&&this.setMaxNum&&this.setMaxNum(t[6],t[10],t[1])}cachePendData(e,t,i,r,s,n){this.pendCache[e]||(this.pendCache[e]={type:n,pend:[]}),this.pendCache[e].pend.push([t,i,s,r]),this.pendCacheLength+=r.length+1,this.pendCacheLength>1e7&&this.publishPendData(),this.pendTimer||(this.pendTimer=setTimeout(()=>{this.publishPendData(),this.pendTimer=null},0))}publishPendData(){if(this.pendCacheLength){this.dataBus.publish(fi.pushPend,[this.pendCache,this.consistencyManager.getClient(),this.uniqueId,this.uuid]);for(let e in this.pendCache)this.pendCache[e].pend.length=0;this.pendCache={},this.pendCacheLength=0}}localChange(e,t,i,r=this.uuid,s,n){if(!this.isInit||!this.canSave||!this.consistencyManager)return 0;if(t&&!t.startsWith("{"))return console.error("\u4E0A\u4F20\u7684\u683C\u5F0F\u4E0D\u6B63\u786E",e,i,t),0;let a=this.consistencyManager.localChange(r,e,t,i,s,n);return this.cachePendData(r,e,a,t,i,s||this.headType),a}async sync(){if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u540C\u6B65");let e=pn();this.dataBus.publish(fi.pushSync,e),await this.dataBus.pullA(Al(fi.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&this.dataBus.publish(fi.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()]),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(fi.personDestroy,{uuid:this.uuid,path:this.path}),this.isWatch&&this.dataBus&&this.busTopic.unwatch&&this.dataBus.publish(this.busTopic.unwatch,this.uuid),this.isWatch=!1,{success:!0})}async save(e=[this.uuid,"BLOB","FONT"]){try{if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u4FDD\u5B58");if(!this.consistencyManager)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let t=this.isProject?fi.projectSave:fi.personSave;if(!t)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let i=await this.dataBus.rpcCall(t,{uuid:this.uuid,path:this.path,docIds:e,uniqueId:this.uniqueId,client:this.consistencyManager.getClient()});return this.consoleDebug("save",i),i}catch(t){throw new Error(`${this._headType}+'Compiler' ${this.uuid} \u4FDD\u5B58\u5931\u8D25: ${(t==null?void 0:t.message)||t||""}`,{cause:t})}}async getBlob(e){return this.dataBus.rpcCall("/mgr/projectWorker/blob/getBlob",e)}async getFont(e,t,i,r,s,n,a,o){let l={text:e,fontFamily:t,fontSize:i,thickness:r,bold:s,italic:n,reverse:a,expansion:o},h=await this.dataBus.rpcCall("/mgr/projectWorker/font/get",l);return h.success?{success:!0,result:Object.assign(l,JSON.parse(h.result))}:h}async checkSave(){return await this.dataBus.rpcCall(fi.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}},OM=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(OM||{}),mM=class extends px{constructor(e){super(e)}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}};var SZ=ic(ld()),IZ=ic(ld());var bM=class extends px{constructor(e,t,i,r,s,n,a,o=(l=>(l=td())==null?void 0:l._TAB_ID_)()){let l=new Rv(o);super(l),this.isProject=i,this.encode=n,this.base=new _M(e,t,i,o,r,l,s,s==="PCB"?pM:fM,a,(...h)=>this.setIsInit(...h),(...h)=>this.onDocDetail(...h),void 0,void 0,void 0,void 0,(h,c,d)=>this.onOrderNum(h,c,d),(h,c,d)=>{this.setMaxNum(h,c,!!d),d&&this.deleteOrderNum(d)})}get dataBus(){return this.base.dataBus}set dataBus(e){this.base.dataBus=e}async init(e=!0,t=!0,i=!0,r,s=!0,n){return this.setNeedNum(s),this.base.init(e,t,i,r,!0,s,n)}async sync(){return this.base.sync()}async destroy(){return this.base.destroy()}async save(){return this.base.save()}checkSave(){return this.base.checkSave()}publishSelected(e,t){this.base.publishSelected(e,t)}uploadBlob(e,t){let i=lg(t),r={filename:e,content:t};return{success:!0,ticket:this.localChange({id:i,data:JSON.stringify(r),dataType:"BLOB"},"BLOB","BLOB"),hash:i}}deleteBlob(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BLOB"},"BLOB","BLOB")}}uploadFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:s,bold:n,italic:a,reverse:o,expansion:l,width:h,height:c,path:d}=e,f={width:h,height:c,path:d},u=M0(t,i,r,s,n,a,o,l);return{success:!0,ticket:this.localChange({id:u,data:JSON.stringify(f),dataType:"FONT"},"FONT","FONT")}}deleteFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:s,bold:n,italic:a,reverse:o,expansion:l}=e,h=M0(t,i,r,s,n,a,o,l);return{success:!0,ticket:this.localChange({id:h,data:"",dataType:"FONT"},"FONT","FONT")}}async updateFootprint(e){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/update",e):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u76F4\u63A5\u4FEE\u6539\u5C01\u88C5\u4FE1\u606F"}}async generateTemplate(e,t){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/generateTemplate",{custom:e,renameKey:t}):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u8C03\u7528\u8BE5\u63A5\u53E3"}}localChange(e,t=this.base.uuid,i){var r,s;let n=this.getOrderNum(e.id);return(s=(r=this.needOrderType)==null?void 0:r.includes)!=null&&s.call(r,e.dataType)&&n===void 0&&(n=this.getMaxNum(e.dataType),this.setOrderNum(e.id,n,e.dataType),this.onOrderNum(e.id,e.dataType,n)),this.base.localChange(e.id,e.data,e.dataType,t,i,n)}uploadString(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeString(e,t))}}deleteString(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"STRING"})}}uploadAttr(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeAttr(e,t))}}deleteAttr(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ATTR"})}}uploadPanelize(e){return{success:!0,ticket:this.localChange(this.encode.encodePanelize(e))}}deletePanelize(){return{success:!0,ticket:this.localChange({id:"PANELIZE",data:"",dataType:"PANELIZE"})}}uploadRuleSelector(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleSelector(e))}}deleteRuleSelector(e){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE_SELECTOR",e]),data:"",dataType:"RULE_SELECTOR"})}}uploadRule(e){return{success:!0,ticket:this.localChange(this.encode.encodeRule(e))}}deleteRule(e,t){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE",e,t]),data:"",dataType:"RULE"})}}uploadRuleTemplate(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleTemplate(e))}}uploadDimension(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeDimension(e,t))}}deleteDimension(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"DIMENSION"})}}uploadBoss(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeBoss(e,t))}}deleteBoss(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BOSS"})}}uploadShellEntity(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellEntity(e,t))}}deleteShellEntity(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL_ENTITY"})}}uploadShellCut(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellCut(e,t))}}deleteShellCut(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELLCUT"})}}uploadCrease(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeCrease(e,t))}}deleteCrease(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"CREASE"})}}uploadShell(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShell(e,t))}}deleteShell(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL"})}}uploadFpcFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFpcFill(e,t))}}deleteFpcFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FPC_FILL"})}}uploadTeardrop(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeTeardrop(e,t))}}deleteTeardrop(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"TEARDROP"})}}uploadImage(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeImage(e,t))}}deleteImage(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"IMAGE"})}}uploadPoured(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoured(e,t))}}deletePoured(e){return{success:!0,ticket:this.localChange({id:Ms(e,"POURED"),data:"",dataType:"POURED"})}}uploadPour(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePour(e,t))}}deletePour(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POUR"})}}uploadRegion(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeRegion(e,t))}}deleteRegion(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"REGION"})}}uploadFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFill(e,t))}}deleteFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FILL"})}}uploadLayerFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerFill(e,t))}}deleteLayerFill(e){return{success:!0,ticket:this.localChange({id:Ms(e,"LAYER_FILL"),data:"",dataType:"LAYER_FILL"})}}uploadPoly(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoly(e,t))}}deletePoly(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POLY"})}}uploadEQLenGrp(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeEQLenGrp(e,t))}}deleteEQLenGrp(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"EQLEN_GRP"})}}uploadObj(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeObj(e,t))}}deleteObj(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"OBJ"})}}uploadArc(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeArc(e,t))}}deleteArc(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ARC"})}}uploadLine(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLine(e,t))}}deleteLine(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"LINE"})}}uploadPad(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePad(e,t))}}deletePad(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"PAD"})}}uploadVia(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeVia(e,t))}}deleteVia(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"VIA"})}}uploadPreference(e){return{success:!0,ticket:this.localChange(this.encode.encodePreference(e))}}uploadSilkOpts(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeSilkOpts(e,t))}}deleteSilkOpts(e){return{success:!0,ticket:this.localChange({id:Ms(e,"SILK_OPTS"),data:"",dataType:"SILK_OPTS"})}}uploadGroup(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeGroup(e,t))}}deleteGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"GROUP"})}}uploadPrimitive(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePrimitive(e,t))}}deletePrimitive(e){return{success:!0,ticket:this.localChange({id:Ms(e,"PRIMITIVE"),data:"",dataType:"PRIMITIVE"})}}uploadNet(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeNet(e,t))}}deleteNet(e){return{success:!0,ticket:this.localChange({id:Ms(e,"NET"),data:"",dataType:"NET"})}}uploadActiveLayer(e){return{success:!0,ticket:this.localChange(this.encode.encodeActiveLayer(e))}}uploadLayerPhys(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerPhys(e,t))}}deleteLayerPhys(e){return{success:!0,ticket:this.localChange({id:Ms(e,"LAYER_PHYS"),data:"",dataType:"LAYER_PHYS"})}}uploadLayer(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayer(e,t))}}deleteLayer(e){return{success:!0,ticket:this.localChange({id:Ms(e,"LAYER"),data:"",dataType:"LAYER"})}}uploadCanvas(e){return{success:!0,ticket:this.localChange(this.encode.encodeCanvas(e))}}uploadBoard(e){return{success:!0,ticket:this.localChange({id:"BOARD",data:JSON.stringify(e),dataType:"BOARD"})}}deleteBoard(){return{success:!0,ticket:this.localChange({id:"BOARD",data:"",dataType:"BOARD"})}}uploadXSignalsGroup(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNAL_GROUP"})}}deleteXSignalsGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNAL_GROUP"})}}uploadXSignals(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNALS"})}}deleteXSignals(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNALS"})}}},gx=class extends bM{constructor(e,t,i,r,s=(n=>(n=td())==null?void 0:n._TAB_ID_)()){super(e,t,i,r,"FOOTPRINT",new fx,{getSelect:()=>{var n;return(n=this.canvasSelected)==null?void 0:n.call(this)},onSelect:(...n)=>{var a;return(a=this.onSelectChange)==null?void 0:a.call(this,n[0],n[1],n[2])},onQuit:(...n)=>{var a;return(a=this.onSelectQuit)==null?void 0:a.call(this,n[0],n[1])}},s),this.uuid=e,this.path=t,this.isProject=i,this.windowId=s}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}},yM=class extends mM{constructor(){super(...arguments),this.data={}}onXSignalsGroup(e,t,i,r,s){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,s){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}onLayerFill(e,t,i,r,s){}onDelLayerFill(e,t,i,r){}onBlob(e,t,i,r,s){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}onString(e,t,i,r,s,n){this.data[e]=s}onDelString(e,t,i,r){delete this.data[e]}onStringNum(e,t){}onAttr(e,t,i,r,s,n){this.data[e]=s}onDelAttr(e,t,i,r){delete this.data[e]}onAttrNum(e,t){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,s){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,s,n){this.data[e]=s}onDelDimension(e,t,i,r){delete this.data[e]}onDimensionNum(e,t){}onBoss(e,t,i,r,s,n){this.data[e]=s}onDelBoss(e,t,i,r){delete this.data[e]}onBossNum(e,t){}onShellEntity(e,t,i,r,s,n){this.data[e]=s}onDelShellEntity(e,t,i,r){}onShellEntityNum(e,t){}onShellCut(e,t,i,r,s,n){this.data[e]=s}onDelShellCut(e,t,i,r){delete this.data[e]}onShellCutNum(e,t){}onCrease(e,t,i,r,s,n){this.data[e]=s}onDelCrease(e,t,i,r){delete this.data[e]}onCreaseNum(e,t){}onShell(e,t,i,r,s,n){this.data[e]=s}onDelShell(e,t,i,r){delete this.data[e]}onShellNum(e,t){}onFpcFill(e,t,i,r,s,n){this.data[e]=s}onDelFpcFill(e,t,i,r){delete this.data[e]}onFpcFillNum(e,t){}onTeardrop(e,t,i,r,s,n){this.data[e]=s}onDelTeardrop(e,t,i,r){delete this.data[e]}onTeardropNum(e,t){}onImage(e,t,i,r,s,n){this.data[e]=s}onDelImage(e,t,i,r){delete this.data[e]}onImageNum(e,t){}onPoured(e,t,i,r,s,n){this.data[e]=s}onDelPoured(e,t,i,r){delete this.data[e]}onPouredNum(e,t){}onPour(e,t,i,r,s,n){this.data[e]=s}onDelPour(e,t,i,r){delete this.data[e]}onPourNum(e,t){}onRegion(e,t,i,r,s,n){this.data[e]=s}onDelRegion(e,t,i,r){delete this.data[e]}onRegionNum(e,t){}onFill(e,t,i,r,s,n){this.data[e]=s}onDelFill(e,t,i,r){delete this.data[e]}onFillNum(e,t){}onPoly(e,t,i,r,s,n){this.data[e]=s}onDelPoly(e,t,i,r){delete this.data[e]}onPolyNum(e,t){}onEQLenGrp(e,t,i,r,s){this.data[e]=r}onDelEQLenGrp(e,t,i,r){delete this.data[e]}onDelProp(e,t,i,r){delete this.data[e]}onObj(e,t,i,r,s,n){this.data[e]=s}onDelObj(e,t,i,r){delete this.data[e]}onObjNum(e,t){}onArc(e,t,i,r,s,n){this.data[e]=s}onDelArc(e,t,i,r){delete this.data[e]}onArcNum(e,t){}onCArc(e,t,i,r,s,n){this.data[e]=s}onDelCArc(e,t,i,r){delete this.data[e]}onCArcNum(e,t){}onLine(e,t,i,r,s,n){this.data[e]=s}onDelLine(e,t,i,r){delete this.data[e]}onLineNum(e,t){}onPad(e,t,i,r,s,n){this.data[e]=s}onDelPad(e,t,i,r){delete this.data[e]}onPadNum(e,t){}onVia(e,t,i,r,s,n){this.data[e]=s}onDelVia(e,t,i,r){delete this.data[e]}onViaNum(e,t){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,s){this.data[e]=r}onDelSilkOpts(e,t,i,r){delete this.data[e]}onGroup(e,t,i,r,s){this.data[e]=r}onDelGroup(e,t,i,r){delete this.data[e]}onPrimitive(e,t,i,r,s){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,s){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,s,n){this.data[e]=s}onDelPartition(e,t,i,r){delete this.data[e]}onPartitionNum(e,t){}onEditorMeta(e,t,i,r){}onDocDetail(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,s){this.data[e]=r}onDelLayerPhys(e,t,i,r){delete this.data[e]}onLayer(e,t,i,r,s){this.data[e]=r}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}},vM=class extends gx{onXSignalsGroup(e,t,i,r,s){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,s){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}onLayerFill(e,t,i,r,s){}onDelLayerFill(e,t,i,r){}constructor(e,t,i,r){super(e,t,i,new xm,r)}canvasSelected(){return""}onSelectChange(e,t,i){}onSelectQuit(e,t){}async getByDataType(e){let t="";if(this.isProject?(this.dataBus=this.dataBus||$h(`/${this.windowId}/project/${this.path}`),t=await this.dataBus.rpcCall("/mgr/projectWorker/getDataByType",{doc:this.uuid,dataType:e})):(this.dataBus=this.dataBus||$h(`/${this.windowId}/libWorker`),t=await this.dataBus.rpcCall("/mgr/libWorker/getDataByType",{uuid:this.uuid,path:this.path,dataType:e,docType:"FOOTPRINT"})),!t)return{};let i=new yM;return i.consistencyManager.parseFull(t,this.uuid,"FOOTPRINT"),i.data}async getPads(){return this.getByDataType("PAD")}onBlob(e,t,i,r,s){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}onString(e,t,i,r,s,n){}onDelString(e,t,i,r){}onStringNum(e,t){}onAttr(e,t,i,r,s,n){}onDelAttr(e,t,i,r){}onAttrNum(e,t){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,s){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,s,n){}onDelDimension(e,t,i,r){}onDimensionNum(e,t){}onBoss(e,t,i,r,s,n){}onDelBoss(e,t,i,r){}onBossNum(e,t){}onShellEntity(e,t,i,r,s,n){}onDelShellEntity(e,t,i,r){}onShellEntityNum(e,t){}onShellCut(e,t,i,r,s,n){}onDelShellCut(e,t,i,r){}onShellCutNum(e,t){}onCrease(e,t,i,r,s,n){}onDelCrease(e,t,i,r){}onCreaseNum(e,t){}onShell(e,t,i,r,s,n){}onDelShell(e,t,i,r){}onShellNum(e,t){}onFpcFill(e,t,i,r,s,n){}onDelFpcFill(e,t,i,r){}onFpcFillNum(e,t){}onTeardrop(e,t,i,r,s,n){}onDelTeardrop(e,t,i,r){}onTeardropNum(e,t){}onImage(e,t,i,r,s,n){}onDelImage(e,t,i,r){}onImageNum(e,t){}onPoured(e,t,i,r,s,n){}onDelPoured(e,t,i,r){}onPouredNum(e,t){}onPour(e,t,i,r,s,n){}onDelPour(e,t,i,r){}onPourNum(e,t){}onRegion(e,t,i,r,s,n){}onDelRegion(e,t,i,r){}onRegionNum(e,t){}onFill(e,t,i,r,s,n){}onDelFill(e,t,i,r){}onFillNum(e,t){}onPoly(e,t,i,r,s,n){}onDelPoly(e,t,i,r){}onPolyNum(e,t){}onEQLenGrp(e,t,i,r,s){}onDelEQLenGrp(e,t,i,r){}onDelProp(e,t,i,r){}onObj(e,t,i,r,s,n){}onDelObj(e,t,i,r){}onObjNum(e,t){}onArc(e,t,i,r,s,n){}onDelArc(e,t,i,r){}onArcNum(e,t){}onCArc(e,t,i,r,s,n){}onDelCArc(e,t,i,r){}onCArcNum(e,t){}onLine(e,t,i,r,s,n){}onDelLine(e,t,i,r){}onLineNum(e,t){}onPad(e,t,i,r,s,n){}onDelPad(e,t,i,r){}onPadNum(e,t){}onVia(e,t,i,r,s,n){}onDelVia(e,t,i,r){}onViaNum(e,t){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,s){}onDelSilkOpts(e,t,i,r){}onGroup(e,t,i,r,s){}onDelGroup(e,t,i,r){}onPrimitive(e,t,i,r,s){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,s){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,s,n){}onDelPartition(e,t,i,r){}onPartitionNum(e,t){}onEditorMeta(e,t,i,r){}onDocDetail(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,s){}onDelLayerPhys(e,t,i,r){}onLayer(e,t,i,r,s){}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}},_x=(e=>(e.LIST="/pro-mgr/api/project/list",e.CREATE="/pro-mgr/api/project/create",e.GET="/pro-mgr/api/project/get",e.UPDATE="/pro-mgr/api/project/update",e.DELETE="/pro-mgr/api/project/delete",e.TICKET="/pro-mgr/api/project/ticket",e.TICKET1="/pro-mgr/api/project/ticket1",e.BACKUP_LIST="/pro-mgr/api/project/backupList",e.BACKUP="/pro-mgr/api/project/backup",e.GET_BACKUP="/pro-mgr/api/project/getBackup",e.DELETE_BACKUP="/pro-mgr/api/project/deleteBackup",e.ARCHIVE="/pro-mgr/api/project/archive",e.CREATE_BOARD="/pro-mgr/api/project/createBoards",e.STAR="/pro-mgr/api/project/star",e.UNSTAR="/pro-mgr/api/project/unstar",e.GET_PROFILE="/pro-mgr/api/project/getProfile",e))(_x||{}),Ox=(e=>(e.LIST="/pro-mgr/api/branch/list",e.GET="/pro-mgr/api/branch/get",e.CREATE="/pro-mgr/api/branch/create",e.UPDATE="/pro-mgr/api/branch/update",e.DELETE="/pro-mgr/api/branch/delete",e))(Ox||{}),mx=(e=>(e.LIST="/pro-mgr/api/schematic/list",e.CREATE="/pro-mgr/api/schematic/create",e.UPLOAD="/pro-mgr/api/schematic/upload",e.DELETE="/pro-mgr/api/schematic/delete",e.UPDATE="/pro-mgr/api/schematic/update",e))(mx||{}),bx=(e=>(e.LIST="/pro-mgr/api/document/list",e.SEARCH_LIST="/pro-mgr/api/document/searchList",e.CREATE="/pro-mgr/api/document/create",e.UPLOAD="/pro-mgr/api/document/upload",e.UPDATE="/pro-mgr/api/document/update",e.BATCH_UPDATE="/pro-mgr/api/document/batchUpdate",e.DELETE="/pro-mgr/api/document/delete",e.GET="/pro-mgr/api/document/get",e.GET_BY_SID="/pro-mgr/api/document/getBySid",e.MOVE="/pro-mgr/api/document/move",e.CHECK_IN="/pro-mgr/api/document/checkIn",e.CHECK_OUT="/pro-mgr/api/document/checkOut",e.GET_CHECK="/pro-mgr/api/document/getCheck",e.DELETE_PCB_RELATED="/pro-mgr/api/document/deletePcbRelated",e))(bx||{}),yx=(e=>(e.LIST="/pro-mgr/api/device/list",e.SEARCH_LIST="/pro-mgr/api/device/searchList",e.CREATE="/pro-mgr/api/device/create",e.UPLOAD="/pro-mgr/api/device/upload",e.UPDATE="/pro-mgr/api/device/update",e.BATCH_UPDATE="/pro-mgr/api/device/batchUpdate",e.GET="/pro-mgr/api/device/get",e.SEARCH_BY_USERS_AND_TITLES="/pro-mgr/api/device/searchByUsersAndTitles",e.GET_ATTR_VALUES="/pro-mgr/api/device/getAttributeValues",e.GET_ATTR_KEYS="/pro-mgr/api/device/getAttrKeys",e.DELETE="/pro-mgr/api/device/delete",e.STAR="/pro-mgr/api/device/star",e.UNSTAR="/pro-mgr/api/device/unstar",e.PLACE="/pro-mgr/api/device/place",e))(yx||{}),vx=(e=>(e.LIST="/pro-mgr/api/component/list",e.SEARCH_LIST="/pro-mgr/api/component/searchList",e.CREATE="/pro-mgr/api/component/create",e.UPLOAD="/pro-mgr/api/component/upload",e.UPDATE="/pro-mgr/api/component/update",e.BATCH_UPDATE="/pro-mgr/api/component/batchUpdate",e.DELETE="/pro-mgr/api/component/delete",e.GET="/pro-mgr/api/component/get",e.SEARCH_BY_USERS_AND_TITLES="/pro-mgr/api/component/searchByUsersAndTitles",e.STAR="/pro-mgr/api/component/star",e.UNSTAR="/pro-mgr/api/component/unstar",e.GET_HISTORY="/pro-mgr/api/component/getHistory",e.SET_HISTORY="/pro-mgr/api/component/setHistory",e.GET_HISTORY_DATA="/pro-mgr/api/component/getHistoryData",e))(vx||{}),xx=(e=>(e.LIST="/pro-mgr/api/tag/list",e.CREATE="/pro-mgr/api/tag/create",e.UPDATE="/pro-mgr/api/tag/update",e.DELETE="/pro-mgr/api/tag/delete",e))(xx||{}),Ex=(e=>(e.SEARCH_LIST="/pro-mgr/api/copper/searchList",e.SET="/pro-mgr/api/copper/set",e.DELETE="/pro-mgr/api/copper/delete",e))(Ex||{}),wx=(e=>(e.SEARCH_LIST="/pro-mgr/api/font/searchList",e.SET="/pro-mgr/api/font/set",e.DELETE="/pro-mgr/api/font/delete",e))(wx||{}),Tx=(e=>(e.SEARCH_LIST="/pro-mgr/api/blob/searchList",e.SET="/pro-mgr/api/blob/set",e))(Tx||{}),Sx=(e=>(e.LIST="/pro-mgr/api/attr/list",e.SEARCH_LIST="/pro-mgr/api/attr/searchList",e.CREATE="/pro-mgr/api/attr/create",e.UPLOAD="/pro-mgr/api/attr/upload",e.DELETE="/pro-mgr/api/attr/delete",e.TICKET="/pro-mgr/api/attr/ticket",e))(Sx||{}),Ix=(e=>(e.GET_BACKUP="/pro-mgr/api/client/getBackup",e.GET_LIBS="/pro-mgr/api/client/getLibs",e.CREATE_LIB="/pro-mgr/api/client/createLib",e.CREATE_PROJECT="/pro-mgr/api/client/createProject",e.OPEN_PROJECT="/pro-mgr/api/client/openProject",e.DELETE_PROJECT="/pro-mgr/api/client/deleteProject",e.COPY_PROJECT="/pro-mgr/api/client/copyProject",e.CLOSE_PROJECT="/pro-mgr/api/client/closeProject",e.GET_PROJECT_PATHS="/pro-mgr/api/client/getProjectPaths",e.SELECT_PATH="/pro-mgr/api/client/selectPath",e.OPEN_DIALOG="/pro-mgr/api/client/openDialog",e.SELECT_DIR="/pro-mgr/api/client/selectDir",e.SELECT_FILE="/pro-mgr/api/client/selectFile",e.EXPORT_FILE="/pro-mgr/api/client/exportFile",e.CACHE_LIST="/pro-mgr/api/client/cacheList",e.GET_CACHE="/pro-mgr/api/client/getCache",e.SET_CACHE="/pro-mgr/api/client/setCache",e.DELETE_CACHE="/pro-mgr/api/client/deleteCache",e.PROJECT_HISTORY="/pro-mgr/api/client/projectHistory",e.DELETE_HISTORY="/pro-mgr/api/client/deletHistory",e.IS_EXIST_KV_CACHE="/pro-mgr/api/client/isExistKVCache",e.OPEN_URL="/pro-mgr/api/client/openURL",e))(Ix||{}),Px=(e=>(e.LOG="/pro-mgr/api/other/log",e.COMPONENT_LOG="/pro-mgr/api/other/componentLog",e.TEAMS="/pro-mgr/api/other/teams",e.GET_EDITOR_VERSION="/pro-mgr/api/other/getEditorVersion",e.SET_EDITOR_VERSION="/pro-mgr/api/other/setEditorVersion",e))(Px||{}),Ja={PROJECT:_x,BRANCH:Ox,SCHEMATIC:mx,DOCUMENT:bx,DEVICE:yx,COMPONENT:vx,TAG:xx,COPPER:Ex,FONT:wx,BLOB:Tx,ATTR:Sx,CLIENT:Ix,OTHER:Px},Ep=nd(ad()),Yu={bus:void 0,get messageBus(){if(Yu.bus===void 0)if(typeof window<"u"){let e=Ri();e._MSG_BUS_=e._MSG_BUS_||new Ep.MessageBus,Yu.bus=e._MSG_BUS_}else self._WORKER_BUS_=self._WORKER_BUS_||new Ep.WorkerMessageBridge(new Ep.MessageBus,self),Yu.bus=self._WORKER_BUS_;return Yu.bus},get messageBus2(){return self._MSG_BUS2_=self._MSG_BUS2_||new Ep.MessageBus2},loginedUserUuid:void 0},Xe=Yu,xM=(e=>(e[e.COMPONENT=2]="COMPONENT",e[e.NET_FLAG=18]="NET_FLAG",e[e.NET_PORT=19]="NET_PORT",e[e.DRAWING=20]="DRAWING",e[e.NON_ELECTRICAL=21]="NON_ELECTRICAL",e[e.SHORT_CIRCUIT_FLAG=22]="SHORT_CIRCUIT_FLAG",e[e.BLOCK_SYMBOL=17]="BLOCK_SYMBOL",e))(xM||{}),EM=(e=>(e.SYMBOL="S",e.FOOTPRINT="F",e.PRODUCT="P",e.MODEL_3D="3D",e))(EM||{}),wM=(e=>(e.BOTTOM_COMPONENT_LIB="BOTTOM_COMPONENT_LIB",e.DIALOG="DIALOG",e))(wM||{}),TM=["S","F","P","3D"],SM=["F","3D"],IM=(e=>(e.ZIP=".zip",e.PRJ=".epro",e.PRJ2=".epro2",e.EPRU=".epru",e.SCH=".esch",e.PCB=".epcb",e.PANEL=".epan",e.PANEL_LIB=".epanl",e.SYMBOL=".esym",e.FOOTPRINT=".efoo",e.INSTANCE=".eins",e.COPPER=".ecop",e.BLOB=".eblob",e.FONT=".efon",e.ELIBZ=".elibz",e.ELIBZ2=".elibz2",e.ELIBU=".elibu",e.IMAGE=".webp",e))(IM||{}),Go="|",PM=/^[^|]+(\|[^|]+)?$/,AM=(e=>(e.Board="Board",e.Schematic="Schematic",e.Sheet="Sheet",e.Simulation="Simulation",e.Pcb="Pcb",e.Panel="Panel",e.SchCanvas="SchCanvas",e.PcbCanvas="PcbCanvas",e.PanelCanvas="PanelCanvas",e.SimulationCanvas="SimulationCanvas",e))(AM||{}),CM=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e))(CM||{}),ov=[{value:"",text:"All"},{value:2,text:"Component"},{value:20,text:{content:"symbolType",value:"Drawing",options:null}},{value:18,text:"Net Flag"},{value:19,text:"Net Port"},{value:25,text:"Off Page Connector"},{value:31,text:"Differential Pairs Flag"},{value:21,text:{content:"symbolType",value:"Non-Electronic Flag",options:null}},{value:22,text:"Short Flag"}],lv=[{value:"",text:"All"},{value:2,text:"Component Symbol"},{value:20,text:"Drawing Symbol"},{value:18,text:"Netflag Symbol"},{value:19,text:"Netport Symbol"},{value:25,text:"Off Page Connector Symbol"},{value:31,text:"Differential Pairs Flag Symbol"},{value:21,text:"Non-Electronic Symbol"},{value:22,text:"Short Flag"}],LM=["S"],DM=["S"],RM=["S"],NM=["3D"],MM={footprint:SM,device:TM,symbol:LM,model3D:NM,panelLib:DM,cbb:RM,modelSimLib:[]},BM=(e=>(e.eprj=".eprj",e.eprj_backup=".eprj_backup",e.eprj2=".eprj2",e))(BM||{});async function kM(e){let t=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")}var Ax=[2,20,18,19,21,22,17,25,31];function Kp(e){return e&&Ax.indexOf(e)>=0}function Cx(e){return Ax.indexOf(e)>=0&&e!==17}function FM(e){return e===""?!1:!!(e&&PM.test(e))}var UM=async e=>{let{keys:t,values:i}=Lx(e);return await kM([...t,...i].sort().join(""))},Lx=e=>{let t=new Set,i=new Set;for(let r in e){let s=e[r];if(t.add(r),Array.isArray(s))i.add(JSON.stringify(s.sort()));else if(Object.prototype.toString.call(s)==="[object Object]"){let{keys:n,values:a}=Lx(s);t=new Set([...t,...n]),i=new Set([...i,...a])}else i.add(JSON.stringify(s))}return{keys:t,values:i}};function hv(e){let{uuid:t,path:i}=e;return t?t+(i?`${Go}${i}`:""):void 0}function GM(e){let{source:t,path:i}=e;return t+(i?`${Go}${i}`:"")}async function S0(e,t){if(t)return t;let{updateTime:i}=e;return i?String(i):await UM(e)}async function zM(e){let{data:t,force:i=!0,defalut:r}=e,{source:s,version:n}=t;s?(FM(s)||(t.source=hv(t)),s.includes(Go)||(t.source=GM(t)),n?n==="1"&&(t.version=await S0(t)):t.version=await S0(t,r)):i&&(t.source=hv(t),t.version=await S0(t,r))}function Dx(){let e=navigator.userLanguage||navigator.language;return e&&e.includes("zh")?"zh-cn":"en"}function I0(e){let{tags:t,custom_tags:i="[]"}=e;if(i==="[object Object]"&&(i=""),(!i||typeof i!="string"||i==="[]")&&t){if(Array.isArray(t)&&t.length)i=JSON.stringify(t);else if(Object.prototype.toString.call(t)==="[object Object]"){let r=Dx()==="en",s=[];if(t.parent_tag){let{name:n,name_cn:a}=t.parent_tag;if(r&&n?s.push(n):!r&&a?s.push(a):n&&s.push(n),t.child_tag){let{name:o,name_cn:l}=t.child_tag;r&&o?s.push(o):!r&&l?s.push(l):o&&s.push(o)}}i=JSON.stringify(s)}}return e.custom_tags=i,e.custom_tags}function is(e){return String(e).length===13?Number(e):String(e).length===10?Number(e)*1e3:Number(e)}function rc(e){var t;return e.path||e.project_uuid||((t=e.owner)==null?void 0:t.uuid)}var HM=nd(ad()),Rx=(e=>e)(Rx||{}),Nx=(e=>(e.GET="/PrjDB/project/getData",e.UPDATE="/PrjDB/project/updateData",e.COUNT_DOC="/PrjDB/project/countDoc",e.GET_HISTORY_NODE="/PrjDB/project/getHistoricalNodes",e.GET_HISTORY_UPDATETIME="/PrjDB/project/getHistoryUpdatetime",e.GET_HISTORY_PROJECT="/PrjDB/project/getHistoricalProject",e.START_BATCH_UPLOAD="/PrjDB/project/startBatchUpload",e.END_BATCH_UPLOAD="/PrjDB/project/endBatchUpload",e.AWAIT_UPLOAD_END="/PrjDB/project/awaitUploadEnd",e.GET_MAX_TICKET="/PrjDB/project/getMaxTicket",e.GET_DOC_MAX_TICKET="/PrjDB/project/getDocMaxTicket",e.SAVE_PEND_DATA="/PrjDB/project/savePendData",e.REVOKE_PEND_DATA="/PrjDB/project/revokePendData",e.GET_CLIENT="/PrjDB/project/getClient",e.GET_BRANCH_DATA="/PrjDB/project/getBranchData",e.HISTORIES="/PrjDB/project/histories",e.COMPRESS="/PrjDB/project/compress",e.FLOW_WRITE="/PrjDB/project/flowWrite",e.GET_RELATED="/PrjDB/project/getRelated",e))(Nx||{}),Mx=(e=>(e.GET="/PrjDB/config/getData",e.UPDATE="/PrjDB/config/updateData",e))(Mx||{}),Bx=(e=>(e.GET="/PrjDB/board/getData",e.ADD="/PrjDB/board/addData",e.UPDATE="/PrjDB/board/updateData",e.DELETE="/PrjDB/board/deleteData",e.GET_ALL_KV="/PrjDB/board/getAllKVData",e.GET_ALL_ARR="/PrjDB/board/getAllArrData",e.TRY_RENAME="/PrjDB/board/tryRename",e.IS_RENAME="/PrjDB/board/isRename",e.BATCH_DELETE="/PrjDB/board/batchDelete",e.GET_BIND_KEYS="/PrjDB/board/getBindKeys",e))(Bx||{}),kx=(e=>(e.GET="/PrjDB/schematic/getData",e.GET_BY_NAME="/PrjDB/schematic/getDataByName",e.TRY_RENAME="/PrjDB/schematic/tryRename",e.UPDATE_IN_LOCAL="/PrjDB/schematic/updateDataInLocal",e.ADD="/PrjDB/schematic/addData",e.UPDATE="/PrjDB/schematic/updateData",e.DEL="/PrjDB/schematic/delData",e.GET_ALL_KV="/PrjDB/schematic/getAllKVDatas",e.GET_UUID_BY_NAME="/PrjDB/schematic/getIdByName",e.GET_NAME_BY_UUID="/PrjDB/schematic/getNameById",e.GET_DISPLAY_NAME_BY_UUID="/PrjDB/schematic/getDisplayNameById",e.GET_ALL_ARR="/PrjDB/schematic/getAllArrDatas",e.GET_BY_SOURCE_VERSION="/PrjDB/schematic/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/schematic/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/schematic/getAllArrDatasBySource",e.IS_RENAME="/PrjDB/schematic/isRename",e.BATCH_DELETE="/PrjDB/schematic/batchDelete",e))(kx||{}),Fx=(e=>(e.ADD="/PrjDB/sheet/addData",e.DEL="/PrjDB/sheet/delData",e.UPDATE="/PrjDB/sheet/updateData",e.UPDATE_LOTS="/PrjDB/sheet/updateLotDatas",e.GET_ALL_KV="/PrjDB/sheet/getAllKVDatas",e.GET="/PrjDB/sheet/getData",e.GET_ALL_ARR="/PrjDB/sheet/getAllArrDatas",e.GET_LOTS_ARR="/PrjDB/sheet/getLotsArrDatas",e.GET_CANVAS="/PrjDB/sheet/getCanvas",e.SET_CANVAS="/PrjDB/sheet/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/sheet/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/sheet/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/sheet/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/sheet/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/sheet/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/sheet/tryRename",e.IS_RENAME="/PrjDB/sheet/isRename",e.BATCH_DELETE="/PrjDB/sheet/batchDelete",e.GET_ALL_KEYS="/PrjDB/sheet/getAllPrimaryKeys",e))(Fx||{}),Ux=(e=>(e.ADD="/PrjDB/simulation/addData",e.DEL="/PrjDB/simulation/delData",e.UPDATE="/PrjDB/simulation/updateData",e.UPDATE_LOTS="/PrjDB/simulation/updateLotDatas",e.GET_ALL_KV="/PrjDB/simulation/getAllKVDatas",e.GET="/PrjDB/simulation/getData",e.GET_ALL_ARR="/PrjDB/simulation/getAllArrDatas",e.GET_LOTS_ARR="/PrjDB/simulation/getLotsArrDatas",e.GET_CANVAS="/PrjDB/simulation/getCanvas",e.SET_CANVAS="/PrjDB/simulation/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/simulation/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/simulation/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/simulation/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/simulation/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/simulation/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/simulation/tryRename",e.IS_RENAME="/PrjDB/simulation/isRename",e.BATCH_DELETE="/PrjDB/simulation/batchDelete",e.GET_ALL_KEYS="/PrjDB/simulation/getAllPrimaryKeys",e))(Ux||{}),Gx=(e=>(e.GET="/PrjDB/pcb/getData",e.GET_BY_TITLE="/PrjDB/pcb/getDataByTitle",e.GET_UUID_BY_TITLE="/PrjDB/pcb/getIdByTitle",e.ADD="/PrjDB/pcb/addData",e.DEL="/PrjDB/pcb/delData",e.CREATE_SUB="/PrjDB/pcb/createSub",e.UPDATE_SUB="/PrjDB/pcb/updateSubInherit",e.UPDATE="/PrjDB/pcb/updateData",e.UPDATE_LOTS="/PrjDB/pcb/updateLotDatas",e.GET_ALL_KV="/PrjDB/pcb/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/pcb/getAllArrDatas",e.GET_CANVAS="/PrjDB/pcb/getCanvas",e.SET_CANVAS="/PrjDB/pcb/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/pcb/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/pcb/unwatchCanvas",e.GET_BY_SOURCE_VERSION="/PrjDB/pcb/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/pcb/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/pcb/getAllArrDatasBySource",e.TRY_RENAME="/PrjDB/pcb/tryRename",e.IS_RENAME="/PrjDB/pcb/isRename",e.BATCH_DELETE="/PrjDB/pcb/batchDelete",e.GET_ALL_KEYS="/PrjDB/pcb/getAllPrimaryKeys",e))(Gx||{}),zx=(e=>(e.GET="/PrjDB/panel/getData",e.ADD="/PrjDB/panel/addData",e.DEL="/PrjDB/panel/delData",e.UPDATE="/PrjDB/panel/updateData",e.UPDATE_LOTS="/PrjDB/panel/updateLotDatas",e.GET_ALL_KV="/PrjDB/panel/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/panel/getAllArrDatas",e.GET_CANVAS="/PrjDB/panel/getCanvas",e.SET_CANVAS="/PrjDB/panel/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/panel/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/panel/unwatchCanvas",e.TRY_RENAME="/PrjDB/panel/tryRename",e.IS_RENAME="/PrjDB/panel/isRename",e.BATCH_DELETE="/PrjDB/panel/batchDelete",e.GET_ALL_KEYS="/PrjDB/panel/getAllPrimaryKeys",e))(zx||{}),Hx=(e=>(e.GET_BY_TITLE="/PrjDB/symbol/getDataByTitle",e.GET="/PrjDB/symbol/getData",e.ADD="/PrjDB/symbol/addData",e.CREATE="/PrjDB/symbol/createData",e.COVER="/PrjDB/symbol/coverData",e.CLONE="/PrjDB/symbol/cloneData",e.DEL="/PrjDB/symbol/delData",e.UPDATE="/PrjDB/symbol/updateData",e.GET_UUIDS_BY_TITLE="/PrjDB/symbol/getIdsByTitle",e.GET_TITLE_BY_UUID="/PrjDB/symbol/getTitleById",e.GET_ALL_KV="/PrjDB/symbol/getAllKVDatas",e.GET_BY_SOURCE_VERSION="/PrjDB/symbol/getDataBySourceAndVersion",e.GET_COMPARE_TICKET="/PrjDB/symbol/getDataCompareTicket",e.GET_LAST="/PrjDB/symbol/getLastData",e.IS_EXIST="/PrjDB/symbol/isExist",e.GET_ALL_KEYS="/PrjDB/symbol/getAllPrimaryKeys",e.GET_TYPE_KEYS="/PrjDB/symbol/getTypePrimaryKeys",e.GET_ALL_ARR="/PrjDB/symbol/getAllArrDatas",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/symbol/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/symbol/getKeysBySource",e.GET_ALL_ARR_BY_TYPE="/PrjDB/symbol/getTypeDatas",e.GET_STR="/PrjDB/symbol/getStr",e.GET_CANVAS="/PrjDB/symbol/getCanvas",e.SET_CANVAS="/PrjDB/symbol/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/symbol/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/symbol/unwatchCanvas",e.TRY_RENAME="/PrjDB/symbol/tryRename",e.WITH_ORIGINS="/PrjDB/symbol/withOrigins",e.IS_RENAME="/PrjDB/symbol/isRename",e.IS_CHANGE="/PrjDB/symbol/isChange",e.BATCH_DELETE="/PrjDB/symbol/batchDelete",e.GET_LIST="/PrjDB/symbol/getList",e))(Hx||{}),jx=(e=>(e.GET_BY_TITLE="/PrjDB/footprint/getDataByTitle",e.GET="/PrjDB/footprint/getData",e.IS_EXIST="/PrjDB/footprint/isExist",e.ADD="/PrjDB/footprint/addData",e.CREATE="/PrjDB/footprint/createData",e.COVER="/PrjDB/footprint/coverData",e.CLONE="/PrjDB/footprint/cloneData",e.DEL="/PrjDB/footprint/delData",e.GET_ALL_KV="/PrjDB/footprint/getAllKVDatas",e.UPDATE="/PrjDB/footprint/updateData",e.UPDATE_IN_LOCAL="/PrjDB/footprint/updateDataInLocal",e.GET_TITLE_BY_UUID="/PrjDB/footprint/getTitleById",e.GET_BY_SOURCE_VERSION="/PrjDB/footprint/getDataBySourceAndVersion",e.GET_COMPARE_TICKET="/PrjDB/footprint/getDataCompareTicket",e.GET_LAST="/PrjDB/footprint/getLastData",e.GET_ALL_KEYS="/PrjDB/footprint/getAllPrimaryKeys",e.GET_ALL_ARR="/PrjDB/footprint/getAllArrDatas",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/footprint/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/footprint/getKeysBySource",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/footprint/getAllArrDatasByPcbId",e.GET_KEYS_BY_PCB_UUID="/PrjDB/footprint/getKeysByPcbId",e.GET_STR="/PrjDB/footprint/getStr",e.GET_CANVAS="/PrjDB/footprint/getCanvas",e.SET_CANVAS="/PrjDB/footprint/setCanvas",e.WATCH_CANVAS_UPDATE="/PrjDB/footprint/watchCanvas",e.UNWATCH_CANVAS_UPDATE="/PrjDB/footprint/unwatchCanvas",e.TRY_RENAME="/PrjDB/footprint/tryRename",e.WITH_ORIGINS="/PrjDB/footprint/withOrigins",e.IS_CHANGE="/PrjDB/footprint/isChange",e.IS_RENAME="/PrjDB/footprint/isRename",e.BATCH_DELETE="/PrjDB/footprint/batchDelete",e.GET_LIST="/PrjDB/footprint/getList",e))(jx||{}),Vx=(e=>(e.GET="/PrjDB/device/getData",e.GET_ATTRIBUTES_KEYS="/PrjDB/device/getDeviceAttributesKeys",e.GET_ATTRIBUTES_VALUES="/PrjDB/device/getDeviceAttributesValues",e.GET_BY_TITLE="/PrjDB/device/getDataByTitle",e.ADD="/PrjDB/device/addData",e.CREATE="/PrjDB/device/createData",e.DEL="/PrjDB/device/delData",e.GET_ALL_KV="/PrjDB/device/getAllKVDatas",e.UPDATE="/PrjDB/device/updateData",e.GET_TITLE_BY_UUID="/PrjDB/device/getTitleById",e.GET_SYMBOL_UUID="/PrjDB/device/getSymbolIdById",e.GET_BY_SOURCE_VERSION="/PrjDB/device/getDataBySourceAndVersion",e.GET_LAST="/PrjDB/device/getLastData",e.GET_ALL_ARR_BY_SOURCE="/PrjDB/device/getAllArrDatasBySource",e.GET_KEYS_BY_SOURCE="/PrjDB/device/getKeysBySource",e.GET_COMPARE_TICKET="/PrjDB/device/getDataCompareTicket",e.IS_EXIST="/PrjDB/device/isExist",e.GET_ALL_KEYS="/PrjDB/device/getAllPrimaryKeys",e.GET_ALL_ARR="/PrjDB/device/getAllArrDatas",e.GET_ALL_ARR_BY_SYMBOL_UUID="/PrjDB/device/getAllArrDatasBySymbolId",e.GET_ALL_ARR_BY_FOOTPRINT_UUID="/PrjDB/device/getAllArrDatasByfootprintId",e.TRY_RENAME="/PrjDB/device/tryRename",e.BIND_SYMBOL="/PrjDB/device/bindSymbol",e.BIND_fOOTPRINT="/PrjDB/device/bindFootprint",e.WITH_ORIGINS="/PrjDB/device/withOrigins",e.IS_CHANGE="/PrjDB/device/isChange",e.IS_RENAME="/PrjDB/device/isRename",e.BATCH_DELETE="/PrjDB/device/batchDelete",e.GET_LIST="/PrjDB/device/getList",e))(Vx||{}),Yx=(e=>(e.GET="/PrjDB/attr/getData",e.UPDATE="/PrjDB/attr/updateData",e.BATCH_UPDATE="/PrjDB/attr/batchUpdateData",e.ADD="/PrjDB/attr/addData",e.DEL="/PrjDB/attr/delData",e.GET_ALL_KV="/PrjDB/attr/getAllKVDatas",e.GET_ALL_ARR="/PrjDB/attr/getAllArrDatas",e.GET_ALL_ARR_BY_HASH="/PrjDB/attr/getAllArrDatasByHash",e.BATCH_DELETE="/PrjDB/attr/batchDelete",e))(Yx||{}),qx=(e=>(e.GET="/PrjDB/blob/getData",e.ADD="/PrjDB/blob/addData",e.DEL="/PrjDB/blob/delData",e.GET_ALL_ARR="/PrjDB/blob/getAllArrDatas",e.BATCH_DELETE="/PrjDB/blob/batchDelete",e))(qx||{}),Wx=(e=>(e.GET="/PrjDB/copper/getData",e.ADD="/PrjDB/copper/addData",e.DEL_LOTS="/PrjDB/copper/delLotDatas",e.DEL="/PrjDB/copper/delData",e.GET_ALL_KEYS="/PrjDB/copper/getAllPrimaryKeys",e.UPDATE="/PrjDB/copper/updateData",e.GET_ALL_ARR="/PrjDB/copper/getAllArrDatas",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/copper/getAllArrDatasByPcbId",e.GET_ALL_KEYS_BY_PCB_UUID="/PrjDB/copper/getAllArrKeysByPcbId",e))(Wx||{}),Xx=(e=>(e.GET="/PrjDB/font/getData",e.ADD="/PrjDB/font/addData",e.DEL_LOTS="/PrjDB/font/delLotDatas",e.DEL="/PrjDB/font/delData",e.GET_ALL_KEYS="/PrjDB/font/getAllPrimaryKeys",e.UPDATE="/PrjDB/font/updateData",e.GET_ALL_ARR="/PrjDB/font/getAllArrDatas",e.GET_ALL_ARR_BY_PCB_UUID="/PrjDB/font/getAllArrDatasByPcbId",e.GET_ALL_KEYS_BY_PCB_UUID="/PrjDB/font/getAllArrKeysByPcbId",e))(Xx||{}),Jx=(e=>(e.BATCH_ADD="/PrjDB/variant/batchAddVariant",e.ADD="/PrjDB/variant/addData",e.DELETE="/PrjDB/variant/deleteData",e.BATCH_DELETE="/PrjDB/variant/batchDeleteData",e.BATCH_RESTORE="/PrjDB/variant/batchRestoreData",e.GET="/PrjDB/variant/getData",e.GET_ALL_ARR_BY_SID="/PrjDB/variant/getAllArrDatasBySid",e.UPDATE_TITLE="/PrjDB/variant/updateTitle",e.UPDATE_NOT_GROUPED="/PrjDB/variant/updateNotGrouped",e.BATCH_UPDATE_SORT="/PrjDB/variant/batchUpdateZIndex",e))(Jx||{}),Zx=(e=>(e.BATCH_ADD="/PrjDB/componentGroup/batchAddData",e.ADD="/PrjDB/componentGroup/addData",e.DELETE="/PrjDB/componentGroup/deleteData",e.BATCH_DELETE="/PrjDB/componentGroup/batchDeleteData",e.BATCH_RESTORE="/PrjDB/componentGroup/batchRestoreData",e.GET="/PrjDB/componentGroup/getData",e.GET_ALL_ARR_BY_SID="/PrjDB/componentGroup/getAllArrDatasBySid",e.GET_ATTR_DATA="/PrjDB/componentGroup/getComponentGroupData",e.UPDATE_TITLE="/PrjDB/componentGroup/updateTitle",e.BATCH_UPDATE_SORT="/PrjDB/componentGroup/batchUpdateZIndex",e.BATCH_UPLOAD_VARIANT_INDEX="/PrjDB/componentGroup/batchUploadGroupSortInVariant",e.BATCH_DELETE_VARIANT_INDEX="/PrjDB/componentGroup/batchDeleteGroupSortInVariant",e.UPLOAD_ATTR_DATA="/PrjDB/componentGroup/uploadComponentGroupData",e.BATCH_DELETE_ATTR_DATA="/PrjDB/componentGroup/batchDeleteComponentGroupData",e))(Zx||{}),yt={VARIANT:Jx,COMPONENT_GROUP:Zx,COMMON:Rx,PROJECT:Nx,CONFIG:Mx,BOARD:Bx,SCHEMATIC:kx,SHEET:Fx,SIMULATION:Ux,PCB:Gx,PANEL:zx,SYMBOL:Hx,FOOTPRINT:jx,DEVICE:Vx,ATTR:Yx,BLOB:qx,COPPER:Wx,FONT:Xx};function zl(e){return!e.data}function jM(e){return!!(e.path&&e.uuid&&e.docType&&e.isProject!==void 0&&Object.keys(e).length===4)}async function Yo(e){let{origin:t,target:i}=e;if(i.isProject){let r={uuid:i.uuid,data:t,overwriteCanvas:zl(t)};if(i.docType===4)return{success:(await Xe.messageBus.rpcCall(yt.FOOTPRINT.COVER,[r,i.path])).message.success};if(Kp(i.docType))return{success:(await Xe.messageBus.rpcCall(yt.SYMBOL.COVER,[r,i.path])).message.success};throw new Error("Api call error!")}else{let r=await vv.getProLibSource(t);if(r.success===!1)return{success:!1,code:r.code,message:r.message};let s=r.result,n=await vv.getProLibSource(i);if(n.success===!1)return{success:!1,code:n.code,message:n.message};let a=n.result,o=pn(),l;if(i.docType===4)l=r0(a,s,{docType:qu.FOOTPRINT,uuid:i.uuid,client:o});else if(i.docType===29)l=r0(a,s,{docType:qu.PANEL_LIB,uuid:i.uuid,client:o});else if(Kp(i.docType))l=r0(a,s,{docType:qu.SYMBOL,uuid:i.uuid,client:o});else throw new Error("Api call error!");let h={path:i.path,uuid:i.uuid,dataStr:l},{message:c}=await Xe.messageBus.rpcCall(Ja.COMPONENT.SET_HISTORY,h);return c.success===!1?{success:!1,code:c.code,message:c.message}:{success:!0}}}function Em(e){return self[e]=self[e]||new HM.BroadcastChannelMessageBus(e)}async function VM(e){let t=Ri();return Em(`/${t._TAB_ID_}/notify`).rpcCall("/pro-ui/libSource/getProLibSource",e)}var YM=(e=>(e.OPEN="/pro-mgr/project/open",e.CLOSE="/pro-mgr/project/close",e.TEMP_OPEN="/pro-mgr/project/tempOpen",e.TEMP_OPEN_BY_STRING="/pro-mgr/project/tempOpenByString",e.TEMP_CLOSE="/pro-mgr/project/tempClose",e.ON_OPENED="/pro-mgr/project/onOpened",e.ON_TEMP_OPENED="/pro-mgr/project/onTempOpened",e.BEFORE_CLOSE="/pro-mgr/project/beforeClose",e.ON_CLOSED="/pro-mgr/project/onClosed",e.ON_TEMP_CLOSED="/pro-mgr/project/onTempClosed",e.ON_FAILED="/pro-mgr/project/onFailed",e.GET_RECENT_PROJECT_LIST="/pro-mgr/getRecentPrjList",e.UPDATE_PROJECT="/pro-mgr/updateProject",e.DEL_PROJECT="/pro-mgr/deleteProject",e.HAS="/pro-mgr/hasProject",e))(YM||{}),qM=(e=>(e.SYSTEM="system",e.INTERNAL="Internal",e.PERSONAL="personal",e.PROJECT="project",e.STAR="star",e.TEAMS="teams",e.USER="user",e.CLIENT="client",e.PUBLIC="public",e.OSHWHUB="oshwhub",e.EXTEND="extend",e))(qM||{}),WM=(e=>(e.DEVICE="device",e.SYMBOL="symbol",e.FOOTPRINT="footprint",e.CBB="cbb",e.MODEL3D="model3D",e.PANEL_LIB="panelLib",e.MODEL_SIM_LIB="modelSimLib",e))(WM||{}),wm={D3Model:{client3DModelList:"api/client/steps"}},He=class{};He.CANVAS_UNIT_MM="mm",He.CANVAS_UNIT_MIL="mil",He.HEX_BLACK_COLOR="#000000",He.HEX_WHITE_COLOR="#FFFFFF",He.HEX_RED_COLOR="#FF0000",He.HEX_GREEN_COLOR="#00FF00",He.HEX_BLUE_COLOR="#0000FF",He.HEX_GRAY_COLOR1="#F1F1F1",He.HEX_GRAY_COLOR2="#EFEFEF",He.HEX_GRAY_COLOR3="#999999",He.HEX_GRAY_COLOR4="#666666",He.HEX_GRAY_COLOR5="#333333",He.HEX_GRAY_COLOR6="#CCCCCC",He.DEFAULT_PAGESIZE=50,He.SYMBOLTYPE_ITEM_ALL_VALUE="@all",He.SYMBOLTYPE_ITEM_ALL_TITLE="All",He.D3MVIEW_DEFAULT_TRANSFORM="0, 0, 0, 0, 0, 0, 0, 0, 0",He.DEVICE_INDEX_TAG="$_",He.DEVICE_SPLIT_TAG="@_",He.LIB_SPLIT_TAG="#_",He.CATEGORY_ITEM_ALL_VALUE="@all",He.CATEGORY_ITEM_ALL_TITLE="All",He.FAVORITELIB_UUID="star",He.SYSTEMLIB_UUID="0819f05c4eef4c71ace90d822a990e87",He.SYSTEMLIB_UUID_ALIAS="lcsc",He.USERLIB_ALIAS="mine",He.PUBLICLIB_ALIAS="user",He.STD_PUBLIC_LIB_UUID="stdPublic",He.RECENT_LIB_UUID="recent",He.INTERNAL_LIB_ALIAS="Internal",He.PERSIONAL_WORKSPACE="Personal",He.EDU_WORKSPACE="6d84b27f18f540b6a31c4d657314ab13",He.EDA_TEST_WORKSPACE="407ec92f2a2f4275bf08cbebf64f5e08",He.LIB_SYSTEM_KEY="system",He.LIB_PROJECT_KEY="project",He.LIB_PERSONAL_KEY="personal",He.LIB_PUBLIC_KEY="public",He.LIB_INTERNAL_KEY="Internal",He.LIB_FAVORITE_KEY="favorite",He.LIB_TEMAS_KEY="teams",He.API=wm,He.ERR_CODE={NORMAL:-1,DUP_NAME:-9001};var cv={},XM=(function(e,t,i,r,s){var n=new Worker(cv[t]||(cv[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return n.onmessage=function(a){var o=a.data,l=o.$e$;if(l){var h=new Error(l[0]);h.code=l[1],h.stack=l[2],s(h,null)}else s(null,o)},n.postMessage(i,r),n}),Qt=Uint8Array,As=Uint16Array,pd=Int32Array,sc=new Qt([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,0,0,0]),nc=new Qt([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,0,0]),id=new Qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kx=function(e,t){for(var i=new As(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];for(var s=new pd(i[30]),r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return{b:i,r:s}},$x=Kx(sc,2),Tm=$x.b,$p=$x.r;Tm[28]=258,$p[258]=28;var Qx=Kx(nc,0),eE=Qx.b,Z0=Qx.r,rd=new As(32768);for(pi=0;pi<32768;++pi)Ga=(pi&43690)>>1|(pi&21845)<<1,Ga=(Ga&52428)>>2|(Ga&13107)<<2,Ga=(Ga&61680)>>4|(Ga&3855)<<4,rd[pi]=((Ga&65280)>>8|(Ga&255)<<8)>>1;var Ga,pi,_n=(function(e,t,i){for(var r=e.length,s=0,n=new As(t);s<r;++s)e[s]&&++n[e[s]-1];var a=new As(t);for(s=1;s<t;++s)a[s]=a[s-1]+n[s-1]<<1;var o;if(i){o=new As(1<<t);var l=15-t;for(s=0;s<r;++s)if(e[s])for(var h=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,f=d|(1<<c)-1;d<=f;++d)o[rd[d]>>l]=h}else for(o=new As(r),s=0;s<r;++s)e[s]&&(o[s]=rd[a[e[s]-1]++]>>15-e[s]);return o}),Za=new Qt(288);for(pi=0;pi<144;++pi)Za[pi]=8;var pi;for(pi=144;pi<256;++pi)Za[pi]=9;var pi;for(pi=256;pi<280;++pi)Za[pi]=7;var pi;for(pi=280;pi<288;++pi)Za[pi]=8;var pi,tc=new Qt(32);for(pi=0;pi<32;++pi)tc[pi]=5;var pi,tE=_n(Za,9,0),iE=_n(Za,9,1),rE=_n(tc,5,0),sE=_n(tc,5,1),Np=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},fn=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&i},Mp=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(t&7)},ac=function(e){return(e+7)/8|0},ga=function(e,t,i){return(t==null||t<0)&&(t=0),(i==null||i>e.length)&&(i=e.length),new Qt(e.subarray(t,i))},nE=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Dt=function(e,t,i){var r=new Error(t||nE[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Dt),!i)throw r;return r},ug=function(e,t,i,r){var s=e.length,n=r?r.length:0;if(!s||t.f&&!t.l)return i||new Qt(0);var a=!i,o=a||t.i!=2,l=t.i;a&&(i=new Qt(s*3));var h=function(X){var ie=i.length;if(X>ie){var de=new Qt(Math.max(ie*2,X));de.set(i),i=de}},c=t.f||0,d=t.p||0,f=t.b||0,u=t.l,p=t.d,g=t.m,_=t.n,y=s*8;do{if(!u){c=fn(e,d,1);var m=fn(e,d+1,3);if(d+=3,m)if(m==1)u=iE,p=sE,g=9,_=5;else if(m==2){var O=fn(e,d,31)+257,b=fn(e,d+10,15)+4,v=O+fn(e,d+5,31)+1;d+=14;for(var E=new Qt(v),T=new Qt(19),P=0;P<b;++P)T[id[P]]=fn(e,d+P*3,7);d+=b*3;for(var A=Np(T),C=(1<<A)-1,M=_n(T,A,1),P=0;P<v;){var H=M[fn(e,d,C)];d+=H&15;var k=H>>4;if(k<16)E[P++]=k;else{var F=0,j=0;for(k==16?(j=3+fn(e,d,3),d+=2,F=E[P-1]):k==17?(j=3+fn(e,d,7),d+=3):k==18&&(j=11+fn(e,d,127),d+=7);j--;)E[P++]=F}}var L=E.subarray(0,O),R=E.subarray(O);g=Np(L),_=Np(R),u=_n(L,g,1),p=_n(R,_,1)}else Dt(1);else{var k=ac(d)+4,x=e[k-4]|e[k-3]<<8,I=k+x;if(I>s){l&&Dt(0);break}o&&h(f+x),i.set(e.subarray(k,I),f),t.b=f+=x,t.p=d=I*8,t.f=c;continue}if(d>y){l&&Dt(0);break}}o&&h(f+131072);for(var S=(1<<g)-1,D=(1<<_)-1,N=d;;N=d){var F=u[Mp(e,d)&S],G=F>>4;if(d+=F&15,d>y){l&&Dt(0);break}if(F||Dt(2),G<256)i[f++]=G;else if(G==256){N=d,u=null;break}else{var z=G-254;if(G>264){var P=G-257,Z=sc[P];z=fn(e,d,(1<<Z)-1)+Tm[P],d+=Z}var se=p[Mp(e,d)&D],he=se>>4;se||Dt(3),d+=se&15;var R=eE[he];if(he>3){var Z=nc[he];R+=Mp(e,d)&(1<<Z)-1,d+=Z}if(d>y){l&&Dt(0);break}o&&h(f+131072);var pe=f+z;if(f<R){var Se=n-R,q=Math.min(R,pe);for(Se+f<0&&Dt(3);f<q;++f)i[f]=r[Se+f]}for(;f<pe;++f)i[f]=i[f-R]}}t.l=u,t.p=N,t.b=f,t.f=c,u&&(c=1,t.m=g,t.d=p,t.n=_)}while(!c);return f!=i.length&&a?ga(i,0,f):i.subarray(0,f)},ca=function(e,t,i){i<<=t&7;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},zh=function(e,t,i){i<<=t&7;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},Bp=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return{t:Fo,l:0};if(s==1){var a=new Qt(i[0].s+1);return a[i[0].s]=1,{t:a,l:1}}i.sort(function(v,E){return v.f-E.f}),i.push({s:-1,f:25001});var o=i[0],l=i[1],h=0,c=1,d=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};c!=s-1;)o=i[i[h].f<i[d].f?h++:d++],l=i[h!=c&&i[h].f<i[d].f?h++:d++],i[c++]={s:-1,f:o.f+l.f,l:o,r:l};for(var f=n[0].s,r=1;r<s;++r)n[r].s>f&&(f=n[r].s);var u=new As(f+1),p=Qp(i[c-1],u,0);if(p>t){var r=0,g=0,_=p-t,y=1<<_;for(n.sort(function(E,T){return u[T.s]-u[E.s]||E.f-T.f});r<s;++r){var m=n[r].s;if(u[m]>t)g+=y-(1<<p-u[m]),u[m]=t;else break}for(g>>=_;g>0;){var O=n[r].s;u[O]<t?g-=1<<t-u[O]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;u[b]==t&&(--u[b],++g)}p=t}return{t:new Qt(u),l:p}},Qp=function(e,t,i){return e.s==-1?Math.max(Qp(e.l,t,i+1),Qp(e.r,t,i+1)):t[e.s]=i},K0=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new As(++t),r=0,s=e[0],n=1,a=function(l){i[r++]=l},o=1;o<=t;++o)if(e[o]==s&&o!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=e[o]}return{c:i.subarray(0,r),n:t}},Hh=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Sm=function(e,t,i){var r=i.length,s=ac(t+2);e[s]=r&255,e[s+1]=r>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var n=0;n<r;++n)e[s+n+4]=i[n];return(s+4+r)*8},$0=function(e,t,i,r,s,n,a,o,l,h,c){ca(t,c++,i),++s[256];for(var d=Bp(s,15),f=d.t,u=d.l,p=Bp(n,15),g=p.t,_=p.l,y=K0(f),m=y.c,O=y.n,b=K0(g),v=b.c,E=b.n,T=new As(19),P=0;P<m.length;++P)++T[m[P]&31];for(var P=0;P<v.length;++P)++T[v[P]&31];for(var A=Bp(T,7),C=A.t,M=A.l,H=19;H>4&&!C[id[H-1]];--H);var k=h+5<<3,F=Hh(s,Za)+Hh(n,tc)+a,j=Hh(s,f)+Hh(n,g)+a+14+3*H+Hh(T,C)+2*T[16]+3*T[17]+7*T[18];if(l>=0&&k<=F&&k<=j)return Sm(t,c,e.subarray(l,l+h));var L,R,x,I;if(ca(t,c,1+(j<F)),c+=2,j<F){L=_n(f,u,0),R=f,x=_n(g,_,0),I=g;var S=_n(C,M,0);ca(t,c,O-257),ca(t,c+5,E-1),ca(t,c+10,H-4),c+=14;for(var P=0;P<H;++P)ca(t,c+3*P,C[id[P]]);c+=3*H;for(var D=[m,v],N=0;N<2;++N)for(var G=D[N],P=0;P<G.length;++P){var z=G[P]&31;ca(t,c,S[z]),c+=C[z],z>15&&(ca(t,c,G[P]>>5&127),c+=G[P]>>12)}}else L=tE,R=Za,x=rE,I=tc;for(var P=0;P<o;++P){var Z=r[P];if(Z>255){var z=Z>>18&31;zh(t,c,L[z+257]),c+=R[z+257],z>7&&(ca(t,c,Z>>23&31),c+=sc[z]);var se=Z&31;zh(t,c,x[se]),c+=I[se],se>3&&(zh(t,c,Z>>5&8191),c+=nc[se])}else zh(t,c,L[Z]),c+=R[Z]}return zh(t,c,L[256]),c+R[256]},aE=new pd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fo=new Qt(0),oE=function(e,t,i,r,s,n){var a=n.z||e.length,o=new Qt(r+a+5*(1+Math.ceil(a/7e3))+s),l=o.subarray(r,o.length-s),h=n.l,c=(n.r||0)&7;if(t){c&&(l[0]=n.r>>3);for(var d=aE[t-1],f=d>>13,u=d&8191,p=(1<<i)-1,g=n.p||new As(32768),_=n.h||new As(p+1),y=Math.ceil(i/3),m=2*y,O=function(Ce){return(e[Ce]^e[Ce+1]<<y^e[Ce+2]<<m)&p},b=new pd(25e3),v=new As(288),E=new As(32),T=0,P=0,A=n.i||0,C=0,M=n.w||0,H=0;A+2<a;++A){var k=O(A),F=A&32767,j=_[k];if(g[F]=j,_[k]=F,M<=A){var L=a-A;if((T>7e3||C>24576)&&(L>423||!h)){c=$0(e,l,0,b,v,E,P,C,H,A-H,c),C=T=P=0,H=A;for(var R=0;R<286;++R)v[R]=0;for(var R=0;R<30;++R)E[R]=0}var x=2,I=0,S=u,D=F-j&32767;if(L>2&&k==O(A-D))for(var N=Math.min(f,L)-1,G=Math.min(32767,A),z=Math.min(258,L);D<=G&&--S&&F!=j;){if(e[A+x]==e[A+x-D]){for(var Z=0;Z<z&&e[A+Z]==e[A+Z-D];++Z);if(Z>x){if(x=Z,I=D,Z>N)break;for(var se=Math.min(D,Z-2),he=0,R=0;R<se;++R){var pe=A-D+R&32767,Se=g[pe],q=pe-Se&32767;q>he&&(he=q,j=pe)}}}F=j,j=g[F],D+=F-j&32767}if(I){b[C++]=268435456|$p[x]<<18|Z0[I];var X=$p[x]&31,ie=Z0[I]&31;P+=sc[X]+nc[ie],++v[257+X],++E[ie],M=A+x,++T}else b[C++]=e[A],++v[e[A]]}}for(A=Math.max(A,M);A<a;++A)b[C++]=e[A],++v[e[A]];c=$0(e,l,h,b,v,E,P,C,H,A-H,c),h||(n.r=c&7|l[c/8|0]<<3,c-=7,n.h=_,n.p=g,n.i=A,n.w=M)}else{for(var A=n.w||0;A<a+h;A+=65535){var de=A+65535;de>=a&&(l[c/8|0]=h,de=a),c=Sm(l,c+1,e.subarray(A,de))}n.i=a}return ga(o,0,r+ac(c)+s)},JM=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(i&1&&-306674912)^i>>>1;e[t]=i}return e})(),Im=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=JM[i&255^t[r]]^i>>>8;e=i},d:function(){return~e}}},lE=function(){var e=1,t=0;return{p:function(i){for(var r=e,s=t,n=i.length|0,a=0;a!=n;){for(var o=Math.min(a+2655,n);a<o;++a)s+=r+=i[a];r=(r&65535)+15*(r>>16),s=(s&65535)+15*(s>>16)}e=r,t=s},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},oc=function(e,t,i,r,s){if(!s&&(s={l:1},t.dictionary)){var n=t.dictionary.subarray(-32768),a=new Qt(n.length+e.length);a.set(n),a.set(e,n.length),e=a,s.w=n.length}return oE(e,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,i,r,s)},hE=function(e,t){var i={};for(var r in e)i[r]=e[r];for(var r in t)i[r]=t[r];return i},uv=function(e,t,i){for(var r=e(),s=e.toString(),n=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<r.length;++a){var o=r[a],l=n[a];if(typeof o=="function"){t+=";"+l+"=";var h=o.toString();if(o.prototype)if(h.indexOf("[native code]")!=-1){var c=h.indexOf(" ",8)+1;t+=h.slice(c,h.indexOf("(",c))}else{t+=h;for(var d in o.prototype)t+=";"+l+".prototype."+d+"="+o.prototype[d].toString()}else t+=h}else i[l]=o}return t},wp=[],ZM=function(e){var t=[];for(var i in e)e[i].buffer&&t.push((e[i]=new e[i].constructor(e[i])).buffer);return t},KM=function(e,t,i,r){if(!wp[i]){for(var s="",n={},a=e.length-1,o=0;o<a;++o)s=uv(e[o],s,n);wp[i]={c:uv(e[a],s,n),e:n}}var l=hE({},wp[i].e);return XM(wp[i].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",i,l,ZM(l),r)},Pm=function(){return[Qt,As,pd,sc,nc,id,Tm,eE,iE,sE,rd,nE,_n,Np,fn,Mp,ac,ga,Dt,ug,n5,cE,t5]},$M=function(){return[Qt,As,pd,sc,nc,id,$p,Z0,tE,Za,rE,tc,rd,aE,Fo,_n,ca,zh,Bp,Qp,K0,Hh,Sm,$0,ac,ga,oE,oc,s5,cE]},QM=function(){return[Am,dE]},e5=function(){return[pE]},cE=function(e){return postMessage(e,[e.buffer])},t5=function(e){return e&&{out:e.size&&new Qt(e.size),dictionary:e.dictionary}},Ho=function(e){return e.ondata=function(t,i){return postMessage([t,i],[t.buffer])},function(t){t.data.length?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush()}},dg=function(e,t,i,r,s,n,a){var o,l=KM(e,r,s,function(h,c){h?(l.terminate(),t.ondata.call(t,h)):Array.isArray(c)?c.length==1?(t.queuedSize-=c[0],t.ondrain&&t.ondrain(c[0])):(c[1]&&l.terminate(),t.ondata.call(t,h,c[0],c[1])):a(c)});l.postMessage(i),t.queuedSize=0,t.push=function(h,c){t.ondata||Dt(5),o&&t.ondata(Dt(4,0,1),null,!!c),t.queuedSize+=h.length,l.postMessage([h,o=c],[h.buffer])},t.terminate=function(){l.terminate()},n&&(t.flush=function(){l.postMessage([])})},Wh=function(e,t){return e[t]|e[t+1]<<8},Xh=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},P0=function(e,t){return Xh(e,t)+Xh(e,t+4)*4294967296},Di=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},uE=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Di(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}},Am=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&Dt(6,"invalid gzip data");var t=e[3],i=10;t&4&&(i+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(t&2)},dE=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},fE=function(e){return 10+(e.filename?e.filename.length+1:0)},i5=function(e,t){var i=t.level,r=i==0?0:i<6?1:i==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var s=lE();s.p(t.dictionary),Di(e,2,s.d())}},pE=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Dt(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Dt(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function gd(e,t){return typeof e=="function"&&(t=e,e={}),this.ondata=t,e}var Wa=(function(){function e(t,i){if(typeof t=="function"&&(i=t,t={}),this.ondata=i,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new Qt(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return e.prototype.p=function(t,i){this.ondata(oc(t,this.o,0,0,this.s),i)},e.prototype.push=function(t,i){this.ondata||Dt(5),this.s.l&&Dt(4);var r=t.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var s=new Qt(r&-32768);s.set(this.b.subarray(0,this.s.z)),this.b=s}var n=this.b.length-this.s.z;this.b.set(t.subarray(0,n),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(n),32768),this.s.z=t.length-n+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=i&1,(this.s.z>this.s.w+8191||i)&&(this.p(this.b,i||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||Dt(5),this.s.l&&Dt(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e})(),r5=(function(){function e(t,i){dg([$M,function(){return[Ho,Wa]}],this,gd.call(this,t,i),function(r){var s=new Wa(r.data);onmessage=Ho(s)},6,1)}return e})();function s5(e,t){return oc(e,t||{},0,0)}var Ks=(function(){function e(t,i){typeof t=="function"&&(i=t,t={}),this.ondata=i;var r=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new Qt(32768),this.p=new Qt(0),r&&this.o.set(r)}return e.prototype.e=function(t){if(this.ondata||Dt(5),this.d&&Dt(4),!this.p.length)this.p=t;else if(t.length){var i=new Qt(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length),this.p=i}},e.prototype.c=function(t){this.s.i=+(this.d=t||!1);var i=this.s.b,r=ug(this.p,this.s,this.o);this.ondata(ga(r,i,this.s.b),this.d),this.o=ga(r,this.s.b-32768),this.s.b=this.o.length,this.p=ga(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(t,i){this.e(t),this.c(i)},e})(),gE=(function(){function e(t,i){dg([Pm,function(){return[Ho,Ks]}],this,gd.call(this,t,i),function(r){var s=new Ks(r.data);onmessage=Ho(s)},7,0)}return e})();function n5(e,t){return ug(e,{i:2},t&&t.out,t&&t.dictionary)}var PZ=(function(){function e(t,i){this.c=Im(),this.l=0,this.v=1,Wa.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),this.l+=t.length,Wa.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=oc(t,this.o,this.v&&fE(this.o),i&&8,this.s);this.v&&(uE(r,this.o),this.v=0),i&&(Di(r,r.length-8,this.c.d()),Di(r,r.length-4,this.l)),this.ondata(r,i)},e.prototype.flush=function(){Wa.prototype.flush.call(this)},e})();function A0(e,t){t||(t={});var i=Im(),r=e.length;i.p(e);var s=oc(e,t,fE(t),8),n=s.length;return uE(s,t),Di(s,n-8,i.d()),Di(s,n-4,r),s}var Q0=(function(){function e(t,i){this.v=1,this.r=0,Ks.call(this,t,i)}return e.prototype.push=function(t,i){if(Ks.prototype.e.call(this,t),this.r+=t.length,this.v){var r=this.p.subarray(this.v-1),s=r.length>3?Am(r):4;if(s>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(s),this.v=0}Ks.prototype.c.call(this,i),this.s.f&&!this.s.l&&!i&&(this.v=ac(this.s.p)+9,this.s={i:0},this.o=new Qt(0),this.push(new Qt(0),i))},e})(),a5=(function(){function e(t,i){var r=this;dg([Pm,QM,function(){return[Ho,Ks,Q0]}],this,gd.call(this,t,i),function(s){var n=new Q0(s.data);n.onmember=function(a){return postMessage(a)},onmessage=Ho(n)},9,0,function(s){return r.onmember&&r.onmember(s)})}return e})();function o5(e,t){var i=Am(e);return i+8>e.length&&Dt(6,"invalid gzip data"),ug(e.subarray(i,-8),{i:2},t&&t.out||new Qt(dE(e)),t&&t.dictionary)}var AZ=(function(){function e(t,i){this.c=lE(),this.v=1,Wa.call(this,t,i)}return e.prototype.push=function(t,i){this.c.p(t),Wa.prototype.push.call(this,t,i)},e.prototype.p=function(t,i){var r=oc(t,this.o,this.v&&(this.o.dictionary?6:2),i&&4,this.s);this.v&&(i5(r,this.o),this.v=0),i&&Di(r,r.length-4,this.c.d()),this.ondata(r,i)},e.prototype.flush=function(){Wa.prototype.flush.call(this)},e})(),em=(function(){function e(t,i){Ks.call(this,t,i),this.v=t&&t.dictionary?2:1}return e.prototype.push=function(t,i){if(Ks.prototype.e.call(this,t),this.v){if(this.p.length<6&&!i)return;this.p=this.p.subarray(pE(this.p,this.v-1)),this.v=0}i&&(this.p.length<4&&Dt(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Ks.prototype.c.call(this,i)},e})(),l5=(function(){function e(t,i){dg([Pm,e5,function(){return[Ho,Ks,em]}],this,gd.call(this,t,i),function(r){var s=new em(r.data);onmessage=Ho(s)},11,0)}return e})(),dv=(function(){function e(t,i){this.o=gd.call(this,t,i)||{},this.G=Q0,this.I=Ks,this.Z=em}return e.prototype.i=function(){var t=this;this.s.ondata=function(i,r){t.ondata(i,r)}},e.prototype.push=function(t,i){if(this.ondata||Dt(5),this.s)this.s.push(t,i);else{if(this.p&&this.p.length){var r=new Qt(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(this.o):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,i),this.p=null)}},e})(),CZ=(function(){function e(t,i){dv.call(this,t,i),this.queuedSize=0,this.G=a5,this.I=gE,this.Z=l5}return e.prototype.i=function(){var t=this;this.s.ondata=function(i,r,s){t.ondata(i,r,s)},this.s.ondrain=function(i){t.queuedSize-=i,t.ondrain&&t.ondrain(i)}},e.prototype.push=function(t,i){this.queuedSize+=t.length,dv.prototype.push.call(this,t,i)},e})();var fv=typeof TextEncoder<"u"&&new TextEncoder,tm=typeof TextDecoder<"u"&&new TextDecoder,_E=0;try{tm.decode(Fo,{stream:!0}),_E=1}catch{}var OE=function(e){for(var t="",i=0;;){var r=e[i++],s=(r>127)+(r>223)+(r>239);if(i+s>e.length)return{s:t,r:ga(e,i-1)};s?s==3?(r=((r&15)<<18|(e[i++]&63)<<12|(e[i++]&63)<<6|e[i++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):s&1?t+=String.fromCharCode((r&31)<<6|e[i++]&63):t+=String.fromCharCode((r&15)<<12|(e[i++]&63)<<6|e[i++]&63):t+=String.fromCharCode(r)}},LZ=(function(){function e(t){this.ondata=t,_E?this.t=new TextDecoder:this.p=Fo}return e.prototype.push=function(t,i){if(this.ondata||Dt(5),i=!!i,this.t){this.ondata(this.t.decode(t,{stream:!0}),i),i&&(this.t.decode().length&&Dt(8),this.t=null);return}this.p||Dt(4);var r=new Qt(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length);var s=OE(r),n=s.s,a=s.r;i?(a.length&&Dt(8),this.p=null):this.p=a,this.ondata(n,i)},e})(),DZ=(function(){function e(t){this.ondata=t}return e.prototype.push=function(t,i){this.ondata||Dt(5),this.d&&Dt(4),this.ondata(im(t),this.d=i||!1)},e})();function im(e,t){if(t){for(var i=new Qt(e.length),r=0;r<e.length;++r)i[r]=e.charCodeAt(r);return i}if(fv)return fv.encode(e);for(var s=e.length,n=new Qt(e.length+(e.length>>1)),a=0,o=function(d){n[a++]=d},r=0;r<s;++r){if(a+5>n.length){var l=new Qt(a+8+(s-r<<1));l.set(n),n=l}var h=e.charCodeAt(r);h<128||t?o(h):h<2048?(o(192|h>>6),o(128|h&63)):h>55295&&h<57344?(h=65536+(h&1047552)|e.charCodeAt(++r)&1023,o(240|h>>18),o(128|h>>12&63),o(128|h>>6&63),o(128|h&63)):(o(224|h>>12),o(128|h>>6&63),o(128|h&63))}return ga(n,0,a)}function h5(e,t){if(t){for(var i="",r=0;r<e.length;r+=16384)i+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return i}else{if(tm)return tm.decode(e);var s=OE(e),n=s.s,i=s.r;return i.length&&Dt(8),n}}var mE=function(e){return e==1?3:e<6?2:e==9?1:0},c5=function(e,t){for(;Wh(e,t)!=1;t+=4+Wh(e,t+2));return[P0(e,t+12),P0(e,t+4),P0(e,t+20)]},kp=function(e){var t=0;if(e)for(var i in e){var r=e[i].length;r>65535&&Dt(9),t+=r+4}return t},pv=function(e,t,i,r,s,n,a,o){var l=r.length,h=i.extra,c=o&&o.length,d=kp(h);Di(e,t,a!=null?33639248:67324752),t+=4,a!=null&&(e[t++]=20,e[t++]=i.os),e[t]=20,t+=2,e[t++]=i.flag<<1|(n<0&&8),e[t++]=s&&8,e[t++]=i.compression&255,e[t++]=i.compression>>8;var f=new Date(i.mtime==null?Date.now():i.mtime),u=f.getFullYear()-1980;if((u<0||u>119)&&Dt(10),Di(e,t,u<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,n!=-1&&(Di(e,t,i.crc),Di(e,t+4,n<0?-n-2:n),Di(e,t+8,i.size)),Di(e,t+12,l),Di(e,t+14,d),t+=16,a!=null&&(Di(e,t,c),Di(e,t+6,i.attrs),Di(e,t+10,a),t+=14),e.set(r,t),t+=l,d)for(var p in h){var g=h[p],_=g.length;Di(e,t,+p),Di(e,t+2,_),e.set(g,t+4),t+=4+_}return c&&(e.set(o,t),t+=c),t},u5=function(e,t,i,r,s){Di(e,t,101010256),Di(e,t+8,i),Di(e,t+10,i),Di(e,t+12,r),Di(e,t+16,s)},eg=(function(){function e(t){this.filename=t,this.c=Im(),this.size=0,this.compression=0}return e.prototype.process=function(t,i){this.ondata(null,t,i)},e.prototype.push=function(t,i){this.ondata||Dt(5),this.c.p(t),this.size+=t.length,i&&(this.crc=this.c.d()),this.process(t,i||!1)},e})(),RZ=(function(){function e(t,i){var r=this;i||(i={}),eg.call(this,t),this.d=new Wa(i,function(s,n){r.ondata(null,s,n)}),this.compression=8,this.flag=mE(i.level)}return e.prototype.process=function(t,i){try{this.d.push(t,i)}catch(r){this.ondata(r,null,i)}},e.prototype.push=function(t,i){eg.prototype.push.call(this,t,i)},e})(),NZ=(function(){function e(t,i){var r=this;i||(i={}),eg.call(this,t),this.d=new r5(i,function(s,n,a){r.ondata(s,n,a)}),this.compression=8,this.flag=mE(i.level),this.terminate=this.d.terminate}return e.prototype.process=function(t,i){this.d.push(t,i)},e.prototype.push=function(t,i){eg.prototype.push.call(this,t,i)},e})(),MZ=(function(){function e(t){this.ondata=t,this.u=[],this.d=1}return e.prototype.add=function(t){var i=this;if(this.ondata||Dt(5),this.d&2)this.ondata(Dt(4+(this.d&1)*8,0,1),null,!1);else{var r=im(t.filename),s=r.length,n=t.comment,a=n&&im(n),o=s!=t.filename.length||a&&n.length!=a.length,l=s+kp(t.extra)+30;s>65535&&this.ondata(Dt(11,0,1),null,!1);var h=new Qt(l);pv(h,0,t,r,o,-1);var c=[h],d=function(){for(var _=0,y=c;_<y.length;_++){var m=y[_];i.ondata(null,m,!1)}c=[]},f=this.d;this.d=0;var u=this.u.length,p=hE(t,{f:r,u:o,o:a,t:function(){t.terminate&&t.terminate()},r:function(){if(d(),f){var _=i.u[u+1];_?_.r():i.d=1}f=1}}),g=0;t.ondata=function(_,y,m){if(_)i.ondata(_,y,m),i.terminate();else if(g+=y.length,c.push(y),m){var O=new Qt(16);Di(O,0,134695760),Di(O,4,t.crc),Di(O,8,g),Di(O,12,t.size),c.push(O),p.c=g,p.b=l+g+16,p.crc=t.crc,p.size=t.size,f&&p.r(),f=1}else f&&d()},this.u.push(p)}},e.prototype.end=function(){var t=this;if(this.d&2){this.ondata(Dt(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){t.d&1&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var t=0,i=0,r=0,s=0,n=this.u;s<n.length;s++){var a=n[s];r+=46+a.f.length+kp(a.extra)+(a.o?a.o.length:0)}for(var o=new Qt(r+22),l=0,h=this.u;l<h.length;l++){var a=h[l];pv(o,t,a,a.f,a.u,-a.c-2,i,a.o),t+=46+a.f.length+kp(a.extra)+(a.o?a.o.length:0),i+=a.b}u5(o,t,this.u.length,r,i),this.ondata(null,o,!0),this.d=2},e.prototype.terminate=function(){for(var t=0,i=this.u;t<i.length;t++){var r=i[t];r.t()}this.d=2},e})();var d5=(function(){function e(){}return e.prototype.push=function(t,i){this.ondata(null,t,i)},e.compression=0,e})(),BZ=(function(){function e(){var t=this;this.i=new Ks(function(i,r){t.ondata(null,i,r)})}return e.prototype.push=function(t,i){try{this.i.push(t,i)}catch(r){this.ondata(r,null,i)}},e.compression=8,e})(),kZ=(function(){function e(t,i){var r=this;i<32e4?this.i=new Ks(function(s,n){r.ondata(null,s,n)}):(this.i=new gE(function(s,n,a){r.ondata(s,n,a)}),this.terminate=this.i.terminate)}return e.prototype.push=function(t,i){this.i.terminate&&(t=ga(t,0)),this.i.push(t,i)},e.compression=8,e})(),FZ=(function(){function e(t){this.onfile=t,this.k=[],this.o={0:d5},this.p=Fo}return e.prototype.push=function(t,i){var r=this;if(this.onfile||Dt(5),this.p||Dt(4),this.c>0){var s=Math.min(this.c,t.length),n=t.subarray(0,s);if(this.c-=s,this.d?this.d.push(n,!this.c):this.k[0].push(n),t=t.subarray(s),t.length)return this.push(t,i)}else{var a=0,o=0,l=void 0,h=void 0;this.p.length?t.length?(h=new Qt(this.p.length+t.length),h.set(this.p),h.set(t,this.p.length)):h=this.p:h=t;for(var c=h.length,d=this.c,f=d&&this.d,u=function(){var y,m=Xh(h,o);if(m==67324752){a=1,l=o,p.d=null,p.c=0;var O=Wh(h,o+6),b=Wh(h,o+8),v=O&2048,E=O&8,T=Wh(h,o+26),P=Wh(h,o+28);if(c>o+30+T+P){var A=[];p.k.unshift(A),a=2;var C=Xh(h,o+18),M=Xh(h,o+22),H=h5(h.subarray(o+30,o+=30+T),!v);C==4294967295?(y=E?[-2]:c5(h,o),C=y[0],M=y[1]):E&&(C=-1),o+=P,p.c=C;var k,F={name:H,compression:b,start:function(){if(F.ondata||Dt(5),!C)F.ondata(null,Fo,!0);else{var j=r.o[b];j||F.ondata(Dt(14,"unknown compression type "+b,1),null,!1),k=C<0?new j(H):new j(H,C,M),k.ondata=function(I,S,D){F.ondata(I,S,D)};for(var L=0,R=A;L<R.length;L++){var x=R[L];k.push(x,!1)}r.k[0]==A&&r.c?r.d=k:k.push(Fo,!0)}},terminate:function(){k&&k.terminate&&k.terminate()}};C>=0&&(F.size=C,F.originalSize=M),p.onfile(F)}return"break"}else if(d){if(m==134695760)return l=o+=12+(d==-2&&8),a=3,p.c=0,"break";if(m==33639248)return l=o-=4,a=3,p.c=0,"break"}},p=this;o<c-4;++o){var g=u();if(g==="break")break}if(this.p=Fo,d<0){var _=a?h.subarray(0,l-12-(d==-2&&8)-(Xh(h,l-16)==134695760&&4)):h.subarray(0,o);f?f.push(_,!!a):this.k[+(a==2)].push(_)}if(a&2)return this.push(h.subarray(o),i);this.p=h.subarray(o)}i&&(this.c&&Dt(13),this.p=null)},e.prototype.register=function(t){this.o[t.compression]=t},e})(),f5=(e=>(e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.LOGIN_FAIL=402]="LOGIN_FAIL",e[e.PERMISSION_DENIED=422]="PERMISSION_DENIED",e[e.PERMISSION_DENIED1=1111111]="PERMISSION_DENIED1",e[e.PERMISSION_DENIED_PARAMS=1111112]="PERMISSION_DENIED_PARAMS",e[e.DATA_NOT_FOUND=1111113]="DATA_NOT_FOUND",e[e.PARAMS_DATA_NOT_FOUND=1111114]="PARAMS_DATA_NOT_FOUND",e[e.REQUEST_PARAM_ILLEGAL=42222]="REQUEST_PARAM_ILLEGAL",e[e.REQUEST_PARAM_ILLEGAL1=1111115]="REQUEST_PARAM_ILLEGAL1",e[e.REQUEST_PARAMS_ILLEGAL2=1111116]="REQUEST_PARAMS_ILLEGAL2",e[e.REQUEST_PARAMS_NOT_NULL=1111117]="REQUEST_PARAMS_NOT_NULL",e[e.REQUEST_PARAMS_NOT_ALL_NULL=1111118]="REQUEST_PARAMS_NOT_ALL_NULL",e[e.REQUEST_PARAMS_MUST_ARRAY=1111119]="REQUEST_PARAMS_MUST_ARRAY",e[e.REQUEST_PARAMS_MUST_STRING=1111120]="REQUEST_PARAMS_MUST_STRING",e[e.REQUEST_PARAMS_MUST_NUMBER=1111121]="REQUEST_PARAMS_MUST_NUMBER",e[e.REQUEST_PARAMS_MUST_NUMBER_ARRAY=1111122]="REQUEST_PARAMS_MUST_NUMBER_ARRAY",e[e.REQUEST_PARAMS_MUST_STRING_ARRAY=1111123]="REQUEST_PARAMS_MUST_STRING_ARRAY",e[e.REQUEST_PARAMS_LENGTH_ERROR=1111124]="REQUEST_PARAMS_LENGTH_ERROR",e[e.REQUEST_PARAMS_TYPE_ERROR=1111125]="REQUEST_PARAMS_TYPE_ERROR",e[e.ILLEGAL_NAME=2001]="ILLEGAL_NAME",e[e.ILLEGAL_NAME1=1111126]="ILLEGAL_NAME1",e[e.ILLEGAL_NAME_ZH=1111128]="ILLEGAL_NAME_ZH",e[e.UUID_ERROR=1111127]="UUID_ERROR",e[e.DUPLICATE_DATA=1000001]="DUPLICATE_DATA",e[e.DUPLICATE_DATA1=11e3]="DUPLICATE_DATA1",e[e.DUPLICATE_DATA_PARAMS=1000017]="DUPLICATE_DATA_PARAMS",e[e.UPLOAD_LIMIT=10034]="UPLOAD_LIMIT",e[e.MORE_THAN_LIMIT=1000003]="MORE_THAN_LIMIT",e[e.FILE_MORE_THAN_LIMIT=1000004]="FILE_MORE_THAN_LIMIT",e[e.PARAMS_MORE_THAN_LIMIT=1000005]="PARAMS_MORE_THAN_LIMIT",e[e.IMAGE_MORE_THAN_LIMIT_PARAMS=1000006]="IMAGE_MORE_THAN_LIMIT_PARAMS",e[e.FILE_MORE_THAN_LIMIT_PARAMS=1000007]="FILE_MORE_THAN_LIMIT_PARAMS",e[e.END_MUST_AFTER_START=1000019]="END_MUST_AFTER_START",e[e.REQUEST_PARAMS_TIME_ERROR=1000009]="REQUEST_PARAMS_TIME_ERROR",e[e.FILES_PATH_NOT_FOUND=1000018]="FILES_PATH_NOT_FOUND",e[e.FILES_DATA_NOT_FOUND=1000011]="FILES_DATA_NOT_FOUND",e[e.FILES_TYPE_ERROR=1000012]="FILES_TYPE_ERROR",e[e.FILES_TYPE_MUST_BE_ONE=1000013]="FILES_TYPE_MUST_BE_ONE",e[e.SET_WATERMARK_FAIL=1000014]="SET_WATERMARK_FAIL",e[e.MYSQL_CRUD_ERROR=1000015]="MYSQL_CRUD_ERROR",e[e.PARAMS_JSON_FAILED=1000016]="PARAMS_JSON_FAILED",e[e.MYSQL_ERROR=3000001]="MYSQL_ERROR",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.PRJ_NAME_EXISTS=2002]="PRJ_NAME_EXISTS",e[e.BACKUP_NAME_EXISTS=3002]="BACKUP_NAME_EXISTS",e[e.PRJ_NOT_EXIST=2000001]="PRJ_NOT_EXIST",e[e.ERROR_PATH=4000002]="ERROR_PATH",e[e.PROJECT_NOT_FOUND=6000001]="PROJECT_NOT_FOUND",e[e.TITLE_ILLEGAL_LEN=2003]="TITLE_ILLEGAL_LEN",e[e.FILE_READ_ONLY=1000002]="FILE_READ_ONLY",e[e.FILE_READ_ONLY1=1000008]="FILE_READ_ONLY1",e[e.DATA_NOT_EXIST=1000010]="DATA_NOT_EXIST",e[e.LIB_NOT_EXIST=2000001]="LIB_NOT_EXIST",e[e.CONFIG_API_URLS_ERROR=3001001]="CONFIG_API_URLS_ERROR",e[e.ONE_CLICK_ORDER_NOT_OPEN=3001002]="ONE_CLICK_ORDER_NOT_OPEN",e[e.MATERIAL_NOT_OPEN=3001003]="MATERIAL_NOT_OPEN",e[e.SNAPSHOT_DEPTH_LIMIT=3001004]="SNAPSHOT_DEPTH_LIMIT",e[e.OCR_SYMBOL_URL_ERROR=3001005]="OCR_SYMBOL_URL_ERROR",e[e.USER_DATA_NOT_FOUND=4000001]="USER_DATA_NOT_FOUND",e[e.USER_DISABLE_ERROR=4000012]="USER_DISABLE_ERROR",e[e.USER_EXISTS_LOGIN_ERROR=4000003]="USER_EXISTS_LOGIN_ERROR",e[e.USER_UNAUTHORIZED_MODULES_ERROR=4000004]="USER_UNAUTHORIZED_MODULES_ERROR",e[e.USER_UNAUTHORIZED_ACCESS_ERROR=4000005]="USER_UNAUTHORIZED_ACCESS_ERROR",e[e.ADMIN_NOT_CHANGE_PASSWORD=4000006]="ADMIN_NOT_CHANGE_PASSWORD",e[e.SAME_PASSWORD_NEW_PASSWORD=4000007]="SAME_PASSWORD_NEW_PASSWORD",e[e.USER_ONLINE_REGISTRATION_FAILED=4000008]="USER_ONLINE_REGISTRATION_FAILED",e[e.USER_PASSWORD_CAN_NOT_DEFAULT=4000009]="USER_PASSWORD_CAN_NOT_DEFAULT",e[e.USER_BEFORE_PASSWORD_ERROR=4000010]="USER_BEFORE_PASSWORD_ERROR",e[e.USER_PASSWORD_LENGTH_ERROR=4000011]="USER_PASSWORD_LENGTH_ERROR",e[e.ORG_ROLE_NOT_CREATE=5000001]="ORG_ROLE_NOT_CREATE",e[e.ORG_ROLE_NAME_DUPLICATE=5000002]="ORG_ROLE_NAME_DUPLICATE",e[e.ORG_ROLE_ORIGIN_ERROR=5000003]="ORG_ROLE_ORIGIN_ERROR",e[e.ORG_ROLE_NOT_DEFAULT=5000004]="ORG_ROLE_NOT_DEFAULT",e[e.ADMIN_ROLE_NOT_CHANGE=5000005]="ADMIN_ROLE_NOT_CHANGE",e[e.ADMIN_NOT_CHANGE_STATUS=5000006]="ADMIN_NOT_CHANGE_STATUS",e[e.PROJECT_ARCHIVED=6000002]="PROJECT_ARCHIVED",e[e.PROJECT_UUID_NULL=6000003]="PROJECT_UUID_NULL",e[e.PROJECT_UUID_ERROR=6000004]="PROJECT_UUID_ERROR",e[e.PROJECT_OR_TEAM_UUID_ERROR=6000005]="PROJECT_OR_TEAM_UUID_ERROR",e[e.PROJECT_NOT_PERSON_ERROR=6000006]="PROJECT_NOT_PERSON_ERROR",e[e.PROJECT_DUPLICATE_NAME=6000007]="PROJECT_DUPLICATE_NAME",e[e.ANNOTATION_HAS_BE_FOUND=6000008]="ANNOTATION_HAS_BE_FOUND",e[e.ANNOTATION_NOT_FOUND=6000009]="ANNOTATION_NOT_FOUND",e[e.ANNOTATION_CREATE_ERROR=6000010]="ANNOTATION_CREATE_ERROR",e[e.ANNOTATION_UPDATE_ERROR=6000011]="ANNOTATION_UPDATE_ERROR",e[e.ANNOTATION_DELETE_ERROR=6000012]="ANNOTATION_DELETE_ERROR",e[e.PROJECT_DUPLICATE_PATH=6000013]="PROJECT_DUPLICATE_PATH",e[e.TEAM_NOT_FOUND=7000001]="TEAM_NOT_FOUND",e[e.TEAM_UUID_NULL=7000002]="TEAM_UUID_NULL",e[e.TEAM_FOLDER_ERROR=7000003]="TEAM_FOLDER_ERROR",e[e.TEAM_FOLDER_DEEP_ERROR=7000004]="TEAM_FOLDER_DEEP_ERROR",e[e.TEAM_FOLDER_UUID_ERROR=7000005]="TEAM_FOLDER_UUID_ERROR",e[e.TEAM_URL_DUPLICATE=7000006]="TEAM_URL_DUPLICATE",e[e.TEAM_CAN_NOT_DELETE=7000007]="TEAM_CAN_NOT_DELETE",e[e.COMPONENT_UUID_NULL=8000001]="COMPONENT_UUID_NULL",e[e.COMPONENT_DATA_NOT_FOUND=8000002]="COMPONENT_DATA_NOT_FOUND",e[e.COMPONENT_NAME_DUPLICATE=8000003]="COMPONENT_NAME_DUPLICATE",e[e.COMPONENT_TYPE_ERROR=8000004]="COMPONENT_TYPE_ERROR",e[e.DELETE_SON_CATEGORY=8001001]="DELETE_SON_CATEGORY",e[e.LICENSE=9000001]="LICENSE",e[e.START_TIME=9000002]="START_TIME",e[e.END_TIME=9000003]="END_TIME",e[e.PROJECT_LIMIT=9000004]="PROJECT_LIMIT",e[e.USER_LIMIT=9000005]="USER_LIMIT",e[e.ONLINE_NUMBER_LIMIT=9000006]="ONLINE_NUMBER_LIMIT",e[e.COMPANY_CODE=9000007]="COMPANY_CODE",e[e.LIMIT_PCB=9000008]="LIMIT_PCB",e[e.LIMIT_SCH=9000009]="LIMIT_SCH",e[e.LIMIT_PANEL=9000011]="LIMIT_PANEL",e[e.TIME_ERROR=9000010]="TIME_ERROR",e[e.LICENSE_ERROR=9000012]="LICENSE_ERROR",e[e.LICENSE_TYPE_ERROR=9000013]="LICENSE_TYPE_ERROR",e[e.LICENSE_ORIGIN_ERROR=9000014]="LICENSE_ORIGIN_ERROR",e[e.BRANCH_DATA_NOT_FOUND=11000001]="BRANCH_DATA_NOT_FOUND",e[e.PARENT_UUID_ERROR=11000002]="PARENT_UUID_ERROR",e[e.BRANCH_MUST_AFTER_NODE=11000003]="BRANCH_MUST_AFTER_NODE",e[e.BRANCH_NAME_ERROR=11000004]="BRANCH_NAME_ERROR",e[e.BRANCH_NAME_DUPLICATE=11000005]="BRANCH_NAME_DUPLICATE",e[e.BRANCH_UUID_ERROR=11000006]="BRANCH_UUID_ERROR",e[e.BRANCH_NODE_SET_ERROR=11000007]="BRANCH_NODE_SET_ERROR",e[e.BRANCH_DELETE_MAIN_ERROR=11000008]="BRANCH_DELETE_MAIN_ERROR",e[e.BRANCH_CHECK_OUT_ERROR=11000009]="BRANCH_CHECK_OUT_ERROR",e[e.DOCUMENT_UUID_ERROR=12000001]="DOCUMENT_UUID_ERROR",e[e.UPDATE_FAILED=12000002]="UPDATE_FAILED",e[e.INNER_API_KEY_ERROR=1000020]="INNER_API_KEY_ERROR",e[e.BRANCH_MORE_THAN_LIMIT=11000010]="BRANCH_MORE_THAN_LIMIT",e[e.WORKSPACE_API_ERROR=1000021]="WORKSPACE_API_ERROR",e))(f5||{}),p5=(e=>(e[e.DB_INIT_ERROR=0]="DB_INIT_ERROR",e[e.PRJ_NOT_EXIST=1]="PRJ_NOT_EXIST",e[e.NET_ERROR=2]="NET_ERROR",e[e.IS_OPENING=3]="IS_OPENING",e[e.NOT_LOGGED_IN=4]="NOT_LOGGED_IN",e[e.HAS_UNSAVED=5]="HAS_UNSAVED",e[e.DIFF_TICKET=6]="DIFF_TICKET",e))(p5||{});function Nl(e,t={}){if(!e)return"";let{proCode:i,code:r,message:s}=e;switch(i||r){case 401:return Be("UNAUTHORIZED");case 402:return Be("LOGIN_FAIL");case 422:return Be("PERMISSION_DENIED");case 1111111:return Be("PERMISSION_DENIED1");case 2000001:return Be("PRJ_NOT_EXIST");case 4000002:return Be("ERROR_PATH");case 6000001:return Be("PROJECT_NOT_FOUND");case 1111112:return Be("PERMISSION_DENIED_PARAMS",{type:s});case 1111113:return Be("DATA_NOT_FOUND");case 1111114:return Be("PARAMS_DATA_NOT_FOUND",{type:s});case 42222:return Be("REQUEST_PARAM_ILLEGAL");case 1111115:return Be("REQUEST_PARAM_ILLEGAL1");case 1111116:return Be("REQUEST_PARAMS_ILLEGAL2",{type:s});case 1111117:return Be("REQUEST_PARAMS_NOT_NULL",{type:s});case 1111118:return Be("REQUEST_PARAMS_NOT_ALL_NULL",{type:s});case 1111119:return Be("REQUEST_PARAMS_MUST_ARRAY",{type:s});case 1111120:return Be("REQUEST_PARAMS_MUST_STRING",{type:s});case 1111121:return Be("REQUEST_PARAMS_MUST_NUMBER",{type:s});case 1111122:return Be("REQUEST_PARAMS_MUST_NUMBER_ARRAY",{type:s});case 1111123:return Be("REQUEST_PARAMS_MUST_STRING_ARRAY",{type:s});case 1111124:return Be("REQUEST_PARAMS_LENGTH_ERROR",{type:s});case 1111125:return Be("REQUEST_PARAMS_TYPE_ERROR",{type:s});case 2001:return Be("ILLEGAL_NAME");case 1111126:return Be("ILLEGAL_NAME1");case 1111128:return Be("ILLEGAL_NAME_ZH");case 1111127:return Be("UUID_ERROR");case 1000001:return Be("DUPLICATE_DATA");case 11e3:return Be("DUPLICATE_DATA1");case 1000017:return Be("DUPLICATE_DATA_PARAMS",{type:s});case 10034:return Be("UPLOAD_LIMIT");case 1000003:return Be("MORE_THAN_LIMIT");case 1000004:return Be("FILE_MORE_THAN_LIMIT",{type:s});case 1000005:return Be("PARAMS_MORE_THAN_LIMIT",{type:s});case 1000006:return Be("IMAGE_MORE_THAN_LIMIT_PARAMS");case 1000007:return Be("FILE_MORE_THAN_LIMIT_PARAMS");case 1000019:return Be("END_MUST_AFTER_START");case 1000002:return Be("FILE_READ_ONLY");case 1000008:return Be("FILE_READ_ONLY1");case 1000010:return Be("DATA_NOT_EXIST",{documentName:t.documentName});case 1000009:return Be("REQUEST_PARAMS_TIME_ERROR");case 1000018:return Be("FILES_PATH_NOT_FOUND");case 1000011:return Be("FILES_DATA_NOT_FOUND");case 1000012:return Be("FILES_TYPE_ERROR");case 1000013:return Be("FILES_TYPE_MUST_BE_ONE",{type:s});case 1000014:return Be("SET_WATERMARK_FAIL");case 1000015:return Be("MYSQL_CRUD_ERROR",{type:s});case 1000016:return Be("PARAMS_JSON_FAILED",{type:s});case 3000001:return Be("MYSQL_ERROR");case 404:return Be("NOT_FOUND");case 2002:return Be("PRJ_NAME_EXISTS");case 3002:return Be("BACKUP_NAME_EXISTS");case 2003:return Be("TITLE_ILLEGAL_LEN",{documentName:t.documentName});case 2000001:return Be("LIB_NOT_EXIST");case 3001001:return Be("CONFIG_API_URLS_ERROR");case 3001002:return Be("ONE_CLICK_ORDER_NOT_OPEN");case 3001003:return Be("MATERIAL_NOT_OPEN");case 3001004:return Be("SNAPSHOT_DEPTH_LIMIT");case 3001005:return Be("OCR_SYMBOL_URL_ERROR");case 4000001:return Be("USER_DATA_NOT_FOUND");case 4000012:return Be("USER_DISABLE_ERROR");case 4000003:return Be("USER_EXISTS_LOGIN_ERROR");case 4000004:return Be("USER_UNAUTHORIZED_MODULES_ERROR");case 4000005:return Be("USER_UNAUTHORIZED_ACCESS_ERROR");case 4000006:return Be("ADMIN_NOT_CHANGE_PASSWORD");case 4000007:return Be("SAME_PASSWORD_NEW_PASSWORD");case 4000008:return Be("USER_ONLINE_REGISTRATION_FAILED");case 4000009:return Be("USER_PASSWORD_CAN_NOT_DEFAULT");case 4000010:return Be("USER_BEFORE_PASSWORD_ERROR");case 4000011:return Be("USER_PASSWORD_LENGTH_ERROR");case 5000001:return Be("ORG_ROLE_NOT_CREATE");case 5000002:return Be("ORG_ROLE_NAME_DUPLICATE");case 5000003:return Be("ORG_ROLE_ORIGIN_ERROR",{message:s});case 5000004:return Be("ORG_ROLE_NOT_DEFAULT");case 5000005:return Be("ADMIN_ROLE_NOT_CHANGE");case 5000006:return Be("ADMIN_NOT_CHANGE_STATUS");case 6000002:return Be("PROJECT_ARCHIVED");case 6000003:return Be("PROJECT_UUID_NULL");case 6000004:return Be("PROJECT_UUID_ERROR");case 6000005:return Be("PROJECT_OR_TEAM_UUID_ERROR");case 6000006:return Be("PROJECT_NOT_PERSON_ERROR");case 6000007:return Be("PROJECT_DUPLICATE_NAME");case 6000008:return Be("ANNOTATION_HAS_BE_FOUND");case 6000009:return Be("ANNOTATION_NOT_FOUND");case 6000010:return Be("ANNOTATION_CREATE_ERROR");case 6000011:return Be("ANNOTATION_UPDATE_ERROR");case 6000012:return Be("ANNOTATION_DELETE_ERROR");case 6000013:return Be("PROJECT_DUPLICATE_PATH");case 7000001:return Be("TEAM_NOT_FOUND");case 7000002:return Be("TEAM_UUID_NULL");case 7000003:return Be("TEAM_FOLDER_ERROR");case 7000004:return Be("TEAM_FOLDER_DEEP_ERROR");case 7000005:return Be("TEAM_FOLDER_UUID_ERROR");case 7000006:return Be("TEAM_URL_DUPLICATE");case 7000007:return Be("TEAM_CAN_NOT_DELETE");case 8000001:return Be("COMPONENT_UUID_NULL");case 8000002:return Be("COMPONENT_DATA_NOT_FOUND");case 8000003:return Be("COMPONENT_NAME_DUPLICATE");case 8000004:return Be("COMPONENT_TYPE_ERROR");case 8001001:return Be("DELETE_SON_CATEGORY");case 9000001:return Be("LICENSE");case 9000002:return Be("START_TIME");case 9000003:return Be("END_TIME");case 9000004:return Be("PROJECT_LIMIT");case 9000005:return Be("USER_LIMIT");case 9000006:return Be("ONLINE_NUMBER_LIMIT");case 9000007:return Be("COMPANY_CODE");case 9000008:return Be("LIMIT_PCB");case 9000009:return Be("LIMIT_SCH");case 9000011:return Be("LIMIT_PANEL");case 9000010:return Be("TIME_ERROR");case 9000012:return Be("LICENSE_ERROR");case 9000013:return Be("LICENSE_TYPE_ERROR");case 9000014:return Be("LICENSE_ORIGIN_ERROR",{type:s});case 11000001:return Be("BRANCH_DATA_NOT_FOUND");case 11000002:return Be("PARENT_UUID_ERROR");case 11000003:return Be("BRANCH_MUST_AFTER_NODE");case 11000004:return Be("BRANCH_NAME_ERROR");case 11000005:return Be("BRANCH_NAME_DUPLICATE");case 11000006:return Be("BRANCH_UUID_ERROR");case 11000007:return Be("BRANCH_NODE_SET_ERROR");case 11000008:return Be("BRANCH_DELETE_MAIN_ERROR");case 11000009:return Be("BRANCH_CHECK_OUT_ERROR");case 12000001:return Be("DOCUMENT_UUID_ERROR");case 12000002:return Be("UPDATE_FAILED");case 1000020:return Be("INNER_API_KEY_ERROR");case 11000010:return Be("BRANCH_MORE_THAN_LIMIT");case 1000021:return Be("WORKSPACE_API_ERROR")}return s}function Be(e,t){return Dx()==="zh-cn"?R0.match("codeCN",e,t)||"":R0.match("codeEN",e,t)||""}function $s(e){return e===422||e===1111111||e===6000002}function On(e){return e===1000001||e===11e3||e===8000003}var g5=class{static blobToUint8Array(e){return new Promise((t,i)=>{let r=new FileReader;r.onload=()=>{r.result instanceof ArrayBuffer?t(new Uint8Array(r.result)):i(new Error("FileReader result is not an ArrayBuffer"))},r.onerror=()=>i(r.error),r.readAsArrayBuffer(e)})}static bufferToString(e,t="utf-8"){return new TextDecoder(t).decode(e)}},_5=(e=>(e.IsActive="/pro-ui/liveness/monitor/isActive",e))(_5||{});async function O5(){var e;if(!od)return!0;let t=!1,i=Ri();return typeof window>"u"&&i._TAB_ID_?t=await Em(`/${i._TAB_ID_}/notify`).rpcCall("/pro-ui/liveness/monitor/isActive"):t=(e=await Xe.messageBus.rpcCall("/pro-ui/liveness/monitor/isActive"))==null?void 0:e.message,t?!0:(console.error("[\u7F16\u8F91\u5668\u5904\u4E8E\u5931\u6D3B\u72B6\u6001, \u8BF7\u68B3\u7406\u903B\u8F91, \u4E0D\u8981\u53D1\u9001\u4E0D\u5FC5\u8981\u7684\u8BF7\u6C42!!!]"),!1)}var m5=(e=>(e.Text="text/plain;charset=UTF-8",e.Json="application/json",e.Form="application/x-www-form-urlencoded;charset=UTF-8",e.FormData="multipart/form-data",e))(m5||{}),b5=(e=>(e.ContentType="Content-Type",e.Editorversion="Editor-Version",e))(b5||{}),y5=(e=>(e.Json="json",e.Blob="blob",e))(y5||{});async function nt(e,t,i={},r={},s=!1){if(!await v5())throw new Error("\u975E\u6CD5\u8BF7\u6C42!!!");return await x5(e,t,i,r,s)}async function v5(){return await O5()}async function x5(e,t,i={},r={},s=!1){return new Promise(async(n,a)=>{let o=0,l=3,h=async()=>{try{var c;e=e||"GET",E5(e,i,r),c=i,r=r;let d=w5(e,t,c,r);c=d.params,t=d.url;let f=new XMLHttpRequest;r.withCredentials!==void 0&&(f.withCredentials=r.withCredentials),r.responseType!==void 0&&(f.responseType=r.responseType),f.open(e,t,!0),T5(f,e,r,s),c=await S5(f,e,t,c,r);let u=!1,p=()=>{if(!u)if(u=!0,f.status===200)try{if(r.responseType==="blob")n(f.response);else{let g=JSON.parse(f.responseText);g.success===!1&&(g.message=Nl(g)||g.message),n(g)}}catch(g){console.warn("catch ajax error...",g),n({success:!1,message:"Network Error!"})}else if(f.status===429)if(o<l){let g=f.getResponseHeader("Retry-After"),_=g?parseInt(g)*1e3:6e4;console.warn(`Too Many Requests, retry after ${_/1e3}s...`,f.status),o++,setTimeout(()=>{u=!1,h()},_)}else console.warn("Too Many Requests, max retry exceeded",f.status),n({success:!1,code:f.status,message:"\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"});else f.status===404?(console.warn("catch ajax error...",f.status),n({success:!1,code:f.status,message:"Network Error!"})):f.status===500?(console.warn("catch ajax error...",f.status),n({success:!1,code:f.status,message:"Network Error!"})):(console.warn("catch ajax error...",f.status),n({success:!1,code:f.status,message:"Network Error!"}))};if(f.onreadystatechange=function(){f.readyState===4&&p()},f.onerror=function(g){u||(console.warn("catch ajax error...",g),n({success:!1,message:"Network Error!"}))},f.ontimeout=function(){u||(u=!0,console.warn("ajax timeout..."),n({success:!1,message:"\u8BF7\u6C42\u8D85\u65F6"}))},f.onabort=function(){u||(u=!0,console.warn("ajax aborted..."),n({success:!1,message:"\u8BF7\u6C42\u5DF2\u53D6\u6D88"}))},c instanceof Uint8Array){let g=new Blob([c]);f.send(g)}else f.send(c)}catch(d){console.warn("catch ajax error...",d),n({success:!1,message:"Network Error!"})}};await h()})}function E5(e,t,i={}){var r;if(e.toLowerCase()!=="get"&&!(t instanceof FormData)&&typeof t!="string"&&(i==null?void 0:i.contentType)!==!1&&!((r=i==null?void 0:i.headers)!=null&&r["Content-Type"])&&(i=i||{},i.headers=Object.assign(i.headers||{},{"Content-Type":"application/json"})),i.headers){let s={};for(let n in i.headers){let a=i.headers[n];s[n]=a}i.headers=s}}function gv(e,t=50){return typeof e!="string"?!1:e.length*2>t*1024*1024}function w5(e,t,i,r={}){var s;let n,a,o,l=[],h=r.headers,c=!1;if(i instanceof FormData)n=i;else if(typeof i=="string")n=i;else if((s=h==null?void 0:h["Content-Type"])!=null&&s.includes("application/json")){if(typeof i=="object"&&i!==null){for(let u in i)if(gv(i[u])){c=!0;break}}if(c){let u=new FormData;for(let p in i){let g=i[p];gv(g)?u.append(p,new Blob([g],{type:"text/plain"})):u.append(p,typeof g=="object"?JSON.stringify(g):g)}n=u,r.headers&&(r.headers["Content-Type"]="multipart/form-data")}else n=JSON.stringify(i)}else{for(a in i)if(o=i[a],o instanceof Array)for(let u=0;u<o.length;u++){let p=o[u];l.push(encodeURIComponent(`${a}[]`)+"="+encodeURIComponent(p))}else if(Object.prototype.toString.call(o)==="[object Object]")for(let u in o){let p=o[u];l.push(encodeURIComponent(`${a}[${u}]`)+"="+(p?encodeURIComponent(p):""))}else l.push(encodeURIComponent(a)+"="+encodeURIComponent(o));n=l.join("&"),e==="GET"&&n&&typeof n=="string"&&r.searchParams===!0&&(t=t+"?"+n,n={})}let d=/{[a-zA-Z]+}/gim,f=[...new Set(t.match(d))];for(let u of f){let p=u.substring(1,u.length-1);t=t.replace(u,i[p]||"")}return{params:n,url:t}}function T5(e,t,i={},r=!1){let s=i.headers;if(s){for(let n in s){let a=s[n];e.setRequestHeader(encodeURI(n),encodeURI(a))}i.contentType!==!1&&!s["Content-Type"]&&e.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")}else i.contentType!==!1&&e.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");e.setRequestHeader("Editor-Version",self.PRO_EDITOR_VERSION||"");try{if(!r&&!s.path)throw new Error("Missing path")}catch(n){console.error(n)}if(self.document){let n=t.toUpperCase();if(n!=="GET"&&n!=="HEAD"){let a=/XSRF-TOKEN=(\S+);?/.exec(document.cookie);a&&e.setRequestHeader("X-XSRF-TOKEN",decodeURIComponent(a[1]))}}}var C0=1e4;async function S5(e,t,i,r,s={}){if(t.match(/post/i)&&i.startsWith("/")&&!i.startsWith("/servicecenter/")&&typeof r=="string"&&r.length>=C0&&(r=A0(new TextEncoder().encode(r),{level:1}),e.setRequestHeader("Content-Encoding","gzip")),t.match(/post/i)&&i.startsWith("/")&&!i.startsWith("/servicecenter/")&&r instanceof FormData&&s.gzipFormData===!0){let n=new Set;r.forEach((a,o)=>{n.add(o)});for(let a of n){let o=r.get(a);if(typeof o=="string"&&o.length>=C0){let l=new Blob([A0(new TextEncoder().encode(o),{level:1})]);r.set(a,l)}else if(o instanceof Blob&&o.size>=C0){let l=new Blob([A0(await g5.blobToUint8Array(o),{level:9})]);r.set(a,l,o.name)}}e.setRequestHeader("Content-Encoding","gzip")}return r}async function bE(e,t,i,r){if(!r||!i){let a=`invalid parameters ${r}|${i}.`;return{code:He.ERR_CODE.NORMAL,success:!1,msg:a,message:a,result:null}}let s=await nt("POST",t?ai(rt.DEVICE.DELETE,{uuid:r}):ai(rt.COMPONENT.DELETE,{uuid:r}),{},{headers:{"Content-Type":"application/json",path:i}});if(s.code===0&&s.success)return{code:0,success:!0,msg:"",message:"",result:{componentId:r}};let n=s.message||s.msg||"Request Error.";return{...s,msg:n,message:n,result:{componentId:r}}}async function I5(e,t,i){if(e){let c="operations not currently supported.";return{code:He.ERR_CODE.NORMAL,success:!1,msg:c,message:c,result:null}}let r={code:0,success:!0,result:{devices:{succeed:[],failed:[]},symbols:{succeed:[],failed:[]},footprints:{succeed:[],failed:[]},d3models:{succeed:[],failed:[]},cbbs:{succeed:[],failed:[]},panels:{succeed:[],failed:[]}},msg:"",message:""},s=await Bh(e,!0,t,i.devices||[]);r.result.devices={...s.result};let n=await Bh(e,!1,t,i.symbols||[]);r.result.symbols={...n.result};let a=await Bh(e,!1,t,i.footprints||[]);r.result.footprints={...a.result};let o=await Bh(e,!1,t,i.d3models||[]);r.result.d3models={...o.result};let l=await Bh(e,!1,t,i.cbbs||[]);r.result.cbbs={...l.result};let h=await Bh(e,!1,t,i.panels||[]);return r.result.panels={...h.result},r}async function Bh(e,t,i,r){let s=[],n=[];for(let a=0;a<r.length;a++){let o=await bE(e,t,i,r[a]);if(o.code===0&&o.success){s.push(r[a]);continue}s.push(r[a])}return{code:0,success:!0,result:{succeed:s,failed:n},msg:"",message:""}}function yE(e){if(!e)return[];if(e instanceof Array)return e;let t=[];return e!=null&&e.parent_tag&&e!=null&&e.parent_tag.uuid&&t.push(e==null?void 0:e.parent_tag.uuid),e!=null&&e.child_tag&&e!=null&&e.child_tag.uuid&&t.push(e==null?void 0:e.child_tag.uuid),t}function qo(e){if(!e)return[];if(e instanceof Array)return e;let t=[];return e!=null&&e.parent_tag&&e!=null&&e.parent_tag.name&&t.push(e==null?void 0:e.parent_tag.name),e!=null&&e.child_tag&&e!=null&&e.child_tag.name&&t.push(e==null?void 0:e.child_tag.name),t}function _d(e,t=!1){return e?t?_v(e):e.indexOf("@")>=0?P5(e):e.indexOf("_")>=0?A5(e):_v(e):{componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1}}function _v(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/\|/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("|");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}function P5(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/\@/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("@");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}function A5(e){let t={componentTitleOrId:void 0,path:void 0,isLocaleFilenameMode:!1};if(!/_/i.test(e))return t.isLocaleFilenameMode=!1,t.componentTitleOrId=e,t;let i=e.split("_");return t.componentTitleOrId=i[0],t.path=i[1],/\./.test(i[0])?(t.isLocaleFilenameMode=!0,t):(t.isLocaleFilenameMode=!1,t)}async function Cm(e,t){let i=_d(e,!0),r=i.path||t,s={code:He.ERR_CODE.NORMAL,success:!0,result:null,msg:""};return s.result={createTime:0,created_at:"",creator:null,dataStr:JSON.stringify({model:`${i.componentTitleOrId}|${r}`,unit:"mm"}),display_title:i.componentTitleOrId||"-",uuid:`${i.componentTitleOrId}|${r}`||"",path:r,description:"",docType:16,modifier:null,owner:null,source:"",tags:{child_tag:[],parent_tag:[]},title:i.componentTitleOrId||"",updateTime:0,updated_at:"",version:"",public:void 0},s}var C5=class{constructor(){if(!crypto||!crypto.subtle)throw new Error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301crypto api");this.tool=crypto.subtle}},L5=class extends C5{constructor(){super(),this.keyBuffer=null,this.key=null,this.iv=null}async init(e){try{return this.keyBuffer=e.key,this.key=await this.setKey(this.keyBuffer),this.iv=await this.setIV(e.iv),this}catch{throw new Error(`invalid key or iv! ${e}`)}}setKey(e){if(e instanceof ArrayBuffer)return this.tool.importKey("raw",e,"AES-GCM",!0,["encrypt","decrypt"]);throw new Error(`invalid key! ${e}`)}setIV(e){if(e instanceof ArrayBuffer)return e;throw new Error(`invalid iv! ${e}`)}encrypt(e){return this.tool.encrypt({name:"AES-GCM",iv:this.iv},this.key,e)}decrypt(e){return this.tool.decrypt({name:"AES-GCM",iv:this.iv},this.key,e)}decrypt2(e){return this.tool.decrypt({name:"AES-GCM",iv:this.iv,tagLength:128},this.key,e)}getKey(){return this.keyBuffer}getIV(){return this.iv}};function Ov(e){let t=e.match(/[\da-f]{2}/gi);return t?new Uint8Array(t.map(function(i){return parseInt(i,16)})).buffer:null}function D5(e,t="utf-8"){var i=new TextDecoder(t);return i.decode(e)}async function Od(e){try{if(e.dataStrId){let t=new Headers;t.append("Content-Type","text/plain;charset=UTF-8");let i=await(await fetch(e.dataStrId,{method:"GET",redirect:"error",headers:t})).arrayBuffer();if(i){let r=await R5(e,i);return D5(r)}}else if(e.dataStr)return e.dataStr;return null}catch(t){throw new Error("fetch\u5931\u8D25!!!"+t)}}async function R5(e,t){let i=new L5;try{let{key:r,iv:s}=e;if(t&&s&&r){let n=Ov(r),a=Ov(s);await i.init({key:n,iv:a});let o=await i.decrypt(t);return o5(new Uint8Array(o))}else throw new Error(`\u6570\u636E\u89E3\u5BC6\u5931\u8D25!!!\u6570\u636E\u4E0D\u6B63\u786E:data:${t},key:${r},iv:${s}`)}catch(r){throw new Error("\u6570\u636E\u89E3\u5BC6\u5931\u8D25!!!"+r)}}var vE=(e=>(e.LIST="/api/projects",e.CBB_LIST="/api/cbbProject",e.CREATE="/api/v4/projects/add",e.GET="/api/v4/projects/{uuid}",e.UPDATE="/api/projects/{uuid}/update",e.DELETE="/api/v4/projects/{uuid}/delete",e.TICKET="/api/projects/{uuid}/ticket",e.BACKUP_LIST="/api/backups",e.BACKUP="/api/backups",e.OPERATE_BACKUP="/api/backups/{uuid}",e.ARCHIVE="/api/backups/archive",e.CREATE_BOARD="/api/projects/{uuid}/boards",e.STAR="/api/projects/{uuid}/star",e.UNSTAR="/api/projects/{uuid}/unstar",e.CREATE_DRAFT="/api/v4/projects/{project_uuid}/draft-history",e.UPLOAD_DRAFT="/api/v4/projects/{project_uuid}/draft-history/{draft_uuid}",e.STRUCTURE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/structures",e.UPDATE_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs",e.DELETE_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs/{thumbUuid}",e.GET_IMAGES="/api/v4/projects/{projectUuid}/branches/{branchUuid}/thumbs",e))(vE||{}),xE=(e=>(e.CREATE="/api/v4/projects/{project_uuid}/branches",e.LIST="/api/v4/projects/{project_uuid}/branches",e.GET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e.UPDATE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e.DELETE="/api/v4/projects/{project_uuid}/branches/{branch_uuid}",e))(xE||{}),EE=(e=>(e.APPLY="/api/v4/snapshots/apply",e.CREATE="/api/v4/snapshots/create",e.GET="/api/v4/projects/branches/histories?path={path}&project={project}&branch={branch}&history={history}&limit={limit}",e.UPLOAD="/api/v4/snapshots/upload-signatures",e.CONFIRM="/api/v4/snapshots/upload-confirm",e))(EE||{}),wE=(e=>(e.SET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/histories",e.GET="/api/v4/projects/{project_uuid}/branches/{branch_uuid}/histories/{history_uuid}",e))(wE||{}),TE=(e=>(e.SET="/api/v4/components/{uuid}/histories",e.GET="/api/v4/components/{uuid}/histories/{historyUuid}",e))(TE||{}),SE=(e=>(e.LIST="/api/schematic/lists",e.CREATE="/api/schematic/create",e.UPLOAD="/api/schematic/upload",e.DELETE="/api/schematic/{uuid}/delete",e.UPDATE="/api/schematic/{uuid}/update",e.UPDATE_SORT="/api/schematic/{uuid}/update_sort",e.UPDATE_SORT1="/api/v2/documents/updateSorts",e))(SE||{}),IE=(e=>(e.LIST="/api/v2/documents/lists",e.CREATE="/api/v2/documents/create",e.UPLOAD="/api/v2/documents/upload",e.UPDATE="/api/v2/documents/{uuid}/update",e.UPDATE_CANVAS="/api/v2/documents/{uuid}/update_canvas",e.BATCH_UPDATE="/api/v2/documents/updateMany",e.DELETE="/api/v2/documents/{uuid}/delete",e.GET="/api/v2/documents/{uuid}",e.GET_BY_TITLE="/api/v2/documents/searchByName",e.GET_BY_SID="/api/v2/schematic/{schematicUuid}/documents",e.MOVE="/api/v2/documents/{uuid}/sort",e.CHECK_IN="/api/v4/documents/checkin/{project}/{branch}",e.CHECK_OUT="/api/v4/documents/checkout/{project}/{branch}",e.GET_CHECK="/api/v4/documents/checkout/{project}/{branch}",e.DELETE_PCB_RELATED="/api/v2/deleteCopperFontComponents",e))(IE||{}),PE=(e=>(e.LIST="/api/v2/devices",e.SEARCH_LIST="/api/devices/search",e.CREATE="/api/devices",e.UPLOAD="/api/devices/upload",e.UPDATE="/api/devices/{uuid}",e.BATCH_UPDATE="/api/devices/updateMany",e.GET="/api/v2/devices/{uuid}",e.GET_ATTR_VALUE="/api/devices/attributes",e.GET_ATTR_KEYS="/api/devices/attributeKeys",e.GET_BY_USER_AND_TITLE="/api/v2/devices/searchByUserUuidAndTitle",e.BATCH_GET="/api/devices/searchByIds",e.DELETE="/api/v4/devices/{uuid}/delete",e.STAR="/api/devices/{uuid}/star",e.UNSTAR="/api/devices/{uuid}/unstar",e.PLACE="/api/v2/upload",e))(PE||{}),AE=(e=>(e.LIST="/api/v2/components",e.SEARCH_LIST="/api/v2/components/search",e.CREATE="/api/v2/components/add",e.UPLOAD="/api/v2/components/upload",e.UPDATE="/api/v2/components/{uuid}/update",e.UPDATE_CANVAS="/api/v2/components/{uuid}/update_canvas",e.BATCH_UPDATE="/api/v2/components/updateMany",e.DELETE="/api/v4/components/{uuid}/delete",e.GET="/api/v2/components/{uuid}",e.GET_BY_TITLE="/api/v2/searchByTitles",e.GET_BY_DOC_UUID="/api/v2/components/searchByPcbId",e.GET_BY_USER_AND_TITLE="/api/v2/components/searchByUserUuidAndTitle",e.GET_BY_C="/api/searchProductByCode",e.BATCH_GET="/api/v2/components/searchByIds",e.STAR="/api/v2/components/{uuid}/star",e.UNSTAR="/api/v2/components/{uuid}/unstar",e.UPLOAD_3DMODEL="/api/3dmodel/upload",e))(AE||{}),CE=(e=>(e.LIST="/api/categories",e.CREATE="/api/categories",e.DELETE="/api/categories/{uuid}/delete",e.UPDATE="/api/categories/{uuid}",e.DEVICE_CATE="/api/open/deviceCate",e))(CE||{}),LE=(e=>(e.SEARCH_LIST="/api/coppers/search",e.SEARCH_BY_PCB_UUID="/api/coppers/searchByPcbId",e.SET="/api/coppers/upload",e.DELETE="/api/coppers/delete",e))(LE||{}),DE=(e=>(e.SEARCH_LIST="/api/textpath/search",e.SEARCH_BY_PCB_UUID="/api/textpath/searchByPcbId",e.SET="/api/textpath/upload",e.DELETE="/api/textpath/delete",e))(DE||{}),RE=(e=>(e.SEARCH_LIST="/api/v2/resources/search",e.SET="/api/v2/resources/upload",e))(RE||{}),NE=(e=>(e.LIST="/api/projects/projectUuid/attributes",e.SEARCH_LIST="/api/block_symbol_attributes/search",e.CREATE="/api/block_symbol_attributes",e.UPLOAD="/api/block_symbol_attributes/upload",e.DELETE="/api/block_symbol_attributes/delete",e.TICKET="/api/block_symbol_attributes/tickets",e))(NE||{}),ME=(e=>(e.GET_BACKUP="/api/backups/{name}",e.GET_COMPONENT="/api/v2/components/clientSearch",e.GET_DEVICE="/api/devices/clientSearch",e.GET_LIBS="/api/client/libraryPaths",e.CREATE_LIB="/api/client/createPath",e.CREATE_PROJECT="/api/client/createProject",e.OPEN_PROJECT="/api/client/openProject",e.CLOSE_PROJECT="/api/client/closeProject",e.COPY_PROJECT="/api/client/copyProject",e.DELETE_PROJECT="/api/client/deleteProject",e.GET_PROJECT_PATHS="/api/client/projectPaths",e.SELECT_PATH_ON_OFFLINE="/api/fileDialog/saveFile",e.SELECT_PATH_ON_LINE="app://api/fileDialog/saveFile",e.OPEN_DIALOG="/api/fileDialog/openPath",e.SELECT_DIR_ON_OFFLINE="/api/fileDialog/dirtory",e.SELECT_DIR_ON_LINE="app://api/client/openDir",e.SELECT_FILE="/api/fileDialog/file",e.EXPORT_FILE_ON_OFFLINE="/api/client/uploadFile",e.EXPORT_FILE_ON_LINE="app://api/client/uploadFile",e.GET_PRJ_CACHE_LIST="/api/client/tmpBackupList",e.OPERATE_PRJ_CACHE="/api/client/tmpBackup",e.CREATE_PRJ_CACHE_ONLINE="/api/client/tmpBackup/create",e.DELETE_PRJ_CACHE_ONLINE="/api/client/tmpBackup/delete",e.GET_RECENT_PROJECT="/api/client/projectHistory",e.DELETE_RECENT_PROJECT="/api/client/projectHistory/delete",e.SET_KV_CACHE="/api/client/setEditorCache",e.GET_KV_CACHE="/api/client/getEditorCache",e.IS_EXIST_KV_CACHE="/api/client/existEditorCache",e.SEARCH_SCHEMATIC_BY_NAME="/api/schematic/searchByName",e.OPEN_URL="app://api/system/openURL",e.FIND_3DMODEL="/api/client/model/find",e))(ME||{}),BE=(e=>(e.LOG="/api/v3/editor_log/upload",e.COMPONENT_LOG="/api/v4/componentLogs",e.TEAMS="/api/teams",e.GET_EDITOR_VERSION="/api/editor/version",e.SET_EDITOR_VERSION="/api/editor/changeVersion",e.ONLINE="/api/userStatistics/registerOnline",e))(BE||{}),rt={PROJECT:vE,BRANCH:xE,SNAPSHOT:EE,PROJECT_HISTORY:wE,COMPONENT_HISTORY:TE,SCHEMATIC:SE,DOCUMENT:IE,DEVICE:PE,COMPONENT:AE,TAG:CE,COPPER:LE,FONT:DE,BLOB:RE,ATTR:NE,CLIENT:ME,OTHER:BE};function jo(e=new Date,t="yyyy-MM-dd HH:ii:ss"){if(Number.isNaN(e.getTime()))return"-";let i={"M+":e.getMonth()+1,"d+":e.getDate(),"H+":e.getHours(),"h+":e.getHours(),"i+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(let r in i)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,RegExp.$1.length==1?i[r]:("00"+i[r]).substr((""+i[r]).length)));return t}function N5(e,t){function i(c){return c>=10?String(c):"0"+c}e instanceof Date?e.getTime().toString().length>13&&(e=new Date(e.getTime()/1e3)):Number.isNaN(Number(e))||e.toString().length>13&&(e=new Date(Number(e)/1e3));let r=new Date(e);if(Number.isNaN(r.getTime()))return"-";let s=r.getFullYear(),n=i(r.getMonth()+1),a=i(r.getDate()),o=i(r.getHours()),l=i(r.getMinutes()),h=i(r.getSeconds());return t==="downProject"?s+"-"+n+"-"+a:t==="migrateStandardProject"?s+"-"+n+"-"+a+"_"+o+"-"+l+"-"+h:t==="y-m-d"||t==="yyyy-MM-dd"?s+"-"+n+"-"+a:t==="y-m-d_h-m-s"?`${s}-${n}-${a}_${o}-${l}-${h}`:s+"-"+n+"-"+a+" "+o+":"+l+":"+h}function Lm(e,t,i){let r=new Date().getTime(),s=jo(new Date(r)),n={avatar:"",nickname:"",username:"",uuid:""},a=e+(i?`|${i}`:"");return{createTime:r,created_at:s,creator:{...n},dataStr:JSON.stringify({model:a,unit:"mm"}),description:"",display_title:t,docType:16,modifier:{...n},owner:{...n},path:i,public:!1,source:"",std_uuid:"",tags:{child_tag:[],parent_tag:[]},ticket:0,title:t,type:0,updateTime:r,updated_at:s,uuid:e,version:""}}async function kE(e){return e?new Promise((t,i)=>{window.fetch(`https://modules.lceda.cn/3dmodel/${e}`,{method:"GET"}).then(async r=>{let s=await r.blob();t({code:0,success:!0,result:s,message:""})}).catch(async r=>{t({code:r?r.code:-9,success:!1,result:null,message:"fetch 3D model file failed."})})}):{code:-1,success:!1,result:null,message:"missing uuid or path or detail data."}}async function md(e,t=He.SYSTEMLIB_UUID,i){if(!e)return null;let r=null,s=_d(e,!0),n=s.path||t;if(s.isLocaleFilenameMode)return r=(await Cm(s.componentTitleOrId,n)).result,r;let a=await nt("GET",ai(rt.COMPONENT.GET,{uuid:s.componentTitleOrId}),{},{headers:{"Content-Type":"application/json",path:n||void 0}});if(a.code===0&&a.success&&typeof a.result=="object"&&(r=a.result),r&&!r.dataStr)try{let o=await Od(r);r.dataStr=o}catch(o){console.error(o)}if(!r&&e&&i){let o=await kE(e);o.success&&o.result instanceof Blob&&(r=Lm(e,i,n))}return r}var M5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree,this.getFile=e.getDetail}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n,totalPage:a}=t;return{count:i,page:r,pageSize:s,totalPage:a,lists:n.map(o=>this.extendLib.transformer.transformCbbListItem(o))}}async getTransformedDetail(e){return await this.getDetail(e)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},B5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getSupportedSymbolTypes=e.getSupportedSymbolTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n,totalPage:a}=t;for(let o of n)await this.setItem3DModelTitle(o);return{count:i,page:r,pageSize:s,totalPage:a,lists:n.map(o=>this.extendLib.transformer.transformDeviceListItem(o))}}async setItem3DModelTitle(e){var t,i;let r=(t=e.attributes)==null?void 0:t["3D Model"];if(e.attributes&&r&&!((i=e.attributes)!=null&&i["3D Model Title"])){let[s,n=this.extendLib.id]=r.split("|")||[],a=await gi.getD3Model({uuid:s,path:n,isProject:!1});e.attributes["3D Model Title"]=a.title||a.display_title,e.attributes["3D Model"]=r.includes("|")?r:[s,n].join("|")}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.setItem3DModelTitle(i),this.extendLib.transformer.transformDeviceListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},k5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n=[],totalPage:a}=t,o=[];for(let l of n)o.push(await this.extendLib.transformer.transformFootprintListItem(l));return{count:i,page:r,pageSize:s,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformFootprintListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},F5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n=[],totalPage:a}=t,o=[];for(let l of n)o.push(await this.extendLib.transformer.transformModel3DListItem(l));return{count:i,page:r,pageSize:s,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformModel3DListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},U5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n=[],totalPage:a}=t,o=[];for(let l of n)o.push(await this.extendLib.transformer.transformPanelLibListItem(l));return{count:i,page:r,pageSize:s,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformPanelLibListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},G5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n=[],totalPage:a}=t,o=[];for(let l of n)o.push(await this.extendLib.transformer.transformSimModelListItem(l));return{count:i,page:r,pageSize:s,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformSimModelListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},z5=class{constructor(e,t){this.extendLib=t,this.getList=e.getList,this.getSupportedPreviewTypes=e.getSupportedPreviewTypes,this.getSupportedSymbolTypes=e.getSupportedSymbolTypes,this.getDetail=e.getDetail,this.getClassificationTree=e.getClassificationTree}async getTransformedList(e){let t=await this.getList(e),{count:i,page:r,pageSize:s,lists:n,totalPage:a}=t,o=[];for(let l of n)o.push(await this.extendLib.transformer.transformSymbolListItem(l));return{count:i,page:r,pageSize:s,totalPage:a,lists:o}}async getTransformedDetail(e,t){let i=await this.getDetail(e,t);return await this.extendLib.transformer.transformSymbolListItem(i)}async getTransformedClassificationTree(){var e,t;return(t=(e=await this.getClassificationTree())==null?void 0:e.map(i=>this.extendLib.transformer.transformCategory(i)))!=null?t:[]}},H5=class{constructor(e){this.extendLib=e}transformTime(e=Date.now()){return e.toString().length>13?e/1e3:e}transformTimeStr(e=Date.now()){let t=this.transformTime(e);return jo(new Date(t*1e3))}transformTags(e){let{primaryClassificationName:t,primaryClassificationUuid:i,secondaryClassificationName:r,secondaryClassificationUuid:s}=e||{};return{parent_tag:t?{uuid:i,name:t}:void 0,child_tag:r?{uuid:s,name:r}:void 0}}transformCategory(e,t){var i,r;let s=(i=e.uuid)!=null?i:crypto.randomUUID();return{id:s,title:e.name,titleAdditional:e.name_cn,children:(r=e.children)==null?void 0:r.map(n=>this.transformCategory(n,s)),parentId:t}}transformDeviceListItem(e){var t,i,r,s,n,a,o,l,h,c;return e.edaFormatedData?e.edaFormatedData:{title:e.name||"",description:e.description||"",images:[],uuid:e.uuid||this.extendLib.getDefaultItemId(),path:this.extendLib.id,source:"",version:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},attributes:{...(t=e.attributes)!=null?t:{},Footprint:((i=e.footprint)==null?void 0:i.uuid)||"",Symbol:((r=e.symbol)==null?void 0:r.uuid)||"",Value:e.value||((s=e.attributes)==null?void 0:s.value)||"","Supplier Part":e.supplierPart||((n=e.attributes)==null?void 0:n.supplierPart)||"",Manufacturer:e.manufacturer||((a=e.attributes)==null?void 0:a.manufacturer)||"",Description:e.description||((o=e.attributes)==null?void 0:o.description)||""},symbol:e.symbol?{display_title:e.symbol.name||"",title:((l=e.symbol.name)==null?void 0:l.toLocaleLowerCase())||"",docType:+e.symbol.symbolType,path:this.extendLib.id,uuid:e.symbol.uuid,description:void 0,version:void 0,ticket:void 0,updateTime:void 0,createTime:void 0,creator:void 0,modifier:void 0,owner:void 0,tags:void 0,source:void 0,has_device:void 0,dataStr:void 0,dataStrId:void 0}:void 0,footprint:e.footprint?{display_title:e.footprint.name||"",title:((h=e.footprint.name)==null?void 0:h.toLocaleLowerCase())||"",docType:4,path:this.extendLib.id,uuid:e.footprint.uuid,description:void 0,version:void 0,ticket:void 0,updateTime:void 0,createTime:void 0,creator:void 0,modifier:void 0,owner:void 0,tags:void 0,source:void 0,has_device:void 0,dataStr:void 0,dataStrId:void 0}:void 0,tags:this.transformTags(e.classification),symbol_type:(c=e.symbol)==null?void 0:c.symbolType}}async transformSymbolListItem(e){var t,i,r,s,n,a,o,l,h,c;return e.edaFormatedData?e.edaFormatedData:{docType:e.symbolType,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,source:"",version:(t=e.version)!=null?t:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(s=e.creator.uuid)!=null?s:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(l=e.owner.name)!=null?l:"",username:(h=e.owner.name)!=null?h:"",uuid:(c=e.owner.uuid)!=null?c:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},dataStr:e.data instanceof Blob?await e.data.text():e.data,tags:this.transformTags(e.classification)}}async transformFootprintListItem(e){var t,i,r,s,n,a,o,l,h,c;return e.edaFormatedData?e.edaFormatedData:{docType:4,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,source:"",version:(t=e.version)!=null?t:"",ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(s=e.creator.uuid)!=null?s:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(l=e.owner.name)!=null?l:"",username:(h=e.owner.name)!=null?h:"",uuid:(c=e.owner.uuid)!=null?c:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},dataStr:e.data instanceof Blob?await e.data.text():e.data,tags:this.transformTags(e.classification)}}async transformPanelLibListItem(e){var t,i,r,s,n,a,o,l,h;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,docType:29,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",description:e.description||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(n=e.modifier.name)!=null?n:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(h=e.owner.uuid)!=null?h:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}async transformModel3DListItem(e){var t,i,r,s,n,a,o,l,h;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",docType:16,description:e.description||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(n=e.modifier.name)!=null?n:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(h=e.owner.uuid)!=null?h:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}async transformSimModelListItem(e){var t,i,r,s,n,a,o,l,h;return e.edaFormatedData?e.edaFormatedData:{...e.edaFormatedData,uuid:e.uuid||this.extendLib.getDefaultItemId(),title:e.name||"",path:this.extendLib.id,ticket:0,updateTime:this.transformTime(e.updateTime),createTime:this.transformTime(e.createTime||e.updateTime),display_title:e.name||"",creator:e.creator?{nickname:(t=e.creator.name)!=null?t:"",username:(i=e.creator.name)!=null?i:"",uuid:(r=e.creator.uuid)!=null?r:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(s=e.modifier.name)!=null?s:"",username:(n=e.modifier.name)!=null?n:"",uuid:(a=e.modifier.uuid)!=null?a:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{nickname:(o=e.owner.name)!=null?o:"",username:(l=e.owner.name)!=null?l:"",uuid:(h=e.owner.uuid)!=null?h:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},tags:this.transformTags(e.classification)}}transformCbbListItem(e){var t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v,E,T,P,A,C,M,H,k,F,j,L,R,x,I,S,D;return e.edaFormatedData?e.edaFormatedData:{cbb_project:!0,content:(t=e.description)!=null?t:"",creator:e.creator?{avatar:"",nickname:(i=e.creator.name)!=null?i:"",username:(r=e.creator.name)!=null?r:"",uuid:(s=e.creator.uuid)!=null?s:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:e.modifier?{nickname:(n=e.modifier.name)!=null?n:"",username:(a=e.modifier.name)!=null?a:"",uuid:(o=e.modifier.uuid)!=null?o:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},owner:e.owner?{avatar:"",team:!1,nickname:(l=e.owner.name)!=null?l:"",username:(h=e.owner.name)!=null?h:"",uuid:(c=e.owner.uuid)!=null?c:""}:{avatar:"",team:!1,nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},name:e.name,path:this.extendLib.id,block_symbol:(f=(d=e.blockSymbols)==null?void 0:d.map(N=>{var G;return{uuid:N.uuid,display_title:N.name,docType:17,project_uuid:(G=e.uuid)!=null?G:e.name,title:N.name.toLocaleLowerCase()}}))!=null?f:[],schematics:(p=(u=e.schematics)==null?void 0:u.map(N=>{var G,z;let Z=(z=(G=e.sheets)==null?void 0:G.filter(se=>se.belongSchematicUuid===N.uuid).map(se=>({uuid:se.uuid,ticket:0})))!=null?z:[];return{create_at:this.transformTimeStr(N.createTime||N.updateTime),createtime:this.transformTime(N.createTime||N.updateTime),display_name:N.name,name:N.name.toLocaleLowerCase(),project_uuid:e.uuid,sheet_count:Z.length,sort:Z,ticket:0,update_at:this.transformTimeStr(N.updateTime),uuid:N.uuid,updateTime:this.transformTime(N.updateTime)}}))!=null?p:[],pcb:(_=(g=e.pcbs)==null?void 0:g.map(N=>{var G,z,Z,se,he,pe,Se,q,X,ie,de;return{description:(G=N.description)!=null?G:"",display_title:N.name,docType:3,project_uuid:(z=e.uuid)!=null?z:"",thumb:N.thumb,title:N.name.toLocaleLowerCase(),updateTime:this.transformTime(N.updateTime),uuid:N.uuid,creator:N.creator?{avatar:"",nickname:(se=(Z=N.creator)==null?void 0:Z.name)!=null?se:"",username:(pe=(he=N.creator)==null?void 0:he.name)!=null?pe:"",uuid:(q=(Se=N.creator)==null?void 0:Se.uuid)!=null?q:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:N.modifier?{nickname:(X=N==null?void 0:N.modifier.name)!=null?X:"",username:(ie=N==null?void 0:N.modifier.name)!=null?ie:"",uuid:(de=N==null?void 0:N.modifier.uuid)!=null?de:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id}}}))!=null?_:[],schs:(m=(y=e.sheets)==null?void 0:y.map(N=>{var G,z,Z,se,he,pe,Se,q;return{description:(G=N.description)!=null?G:"",display_title:N.name,docType:1,project_uuid:(z=e.uuid)!=null?z:"",schematic_uuid:N.belongSchematicUuid,thumb:N.thumb,title:N.name.toLocaleLowerCase(),updateTime:this.transformTime(N.updateTime),uuid:N.uuid,creator:N.creator?{avatar:"",nickname:(Z=N==null?void 0:N.creator.name)!=null?Z:"",username:(se=N==null?void 0:N.creator.name)!=null?se:"",uuid:(he=N==null?void 0:N.creator.uuid)!=null?he:""}:{avatar:"",nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id},modifier:N!=null&&N.modifier?{nickname:(pe=N==null?void 0:N.modifier.name)!=null?pe:"",username:(Se=N==null?void 0:N.modifier.name)!=null?Se:"",uuid:(q=N==null?void 0:N.modifier.uuid)!=null?q:""}:{nickname:this.extendLib.title,username:this.extendLib.title,uuid:this.extendLib.id}}}))!=null?m:[],tags:{parent_tag:{name:(b=(O=e.classification)==null?void 0:O.primaryClassificationName)!=null?b:"",name_cn:(E=(v=e.classification)==null?void 0:v.primaryClassificationName)!=null?E:"",title:(P=(T=e.classification)==null?void 0:T.primaryClassificationName)!=null?P:"",uuid:(C=(A=e.classification)==null?void 0:A.primaryClassificationUuid)!=null?C:""},child_tag:{name:(H=(M=e.classification)==null?void 0:M.secondaryClassificationName)!=null?H:"",name_cn:(F=(k=e.classification)==null?void 0:k.secondaryClassificationName)!=null?F:"",title:(L=(j=e.classification)==null?void 0:j.secondaryClassificationName)!=null?L:"",uuid:(x=(R=e.classification)==null?void 0:R.secondaryClassificationUuid)!=null?x:""}},updated_at:this.transformTimeStr(e.updateTime),uuid:(I=e.uuid)!=null?I:e.name,boards:(D=(S=e.boards)==null?void 0:S.map(N=>({name:N.name,pcb:N.pcbUuid,sch:N.schUuid})))!=null?D:[]}}},j5=class FE{constructor(t){this.transformer=new H5(this),this.id=t.id,this.isVisible=i=>t.isVisible?t.isVisible(i)&&this.isInTab(i.tabName):this.isInTab(i.tabName),this.title=t.title,this.position=t.position,t.device&&(this.device=new B5(t.device,this)),t.symbol&&(this.symbol=new z5(t.symbol,this)),t.footprint&&(this.footprint=new k5(t.footprint,this)),t.panelLib&&(this.panelLib=new U5(t.panelLib,this)),t.cbb&&(this.cbb=new M5(t.cbb,this)),t.model3D&&(this.model3D=new F5(t.model3D,this)),t.modelSimLib&&(this.modelSimLib=new G5(t.modelSimLib,this))}static async set(t){var i,r,s,n,a,o,l,h,c,d;let f=new FE(t);return f._deviceSupportedSymbolTypes=await((r=(i=t.device)==null?void 0:i.getSupportedSymbolTypes)==null?void 0:r.call(i)),f._symbolSupportedSymbolTypes=await((n=(s=t.symbol)==null?void 0:s.getSupportedSymbolTypes)==null?void 0:n.call(s)),f._deviceSupportedPreviewTypes=await((o=(a=t.device)==null?void 0:a.getSupportedPriviewTypes)==null?void 0:o.call(a)),f._footprintSupportedPreviewTypes=await((h=(l=t.footprint)==null?void 0:l.getSupportedPriviewTypes)==null?void 0:h.call(l)),f._panelLibSupportedPreviewTypes=await((d=(c=t.panelLib)==null?void 0:c.getSupportedPriviewTypes)==null?void 0:d.call(c)),f}getDefaultItemId(){return crypto.randomUUID().replace("-","")}getLibraryFunctionsClassInTab(t){switch(t){case"cbb":return this==null?void 0:this.cbb;case"device":return this==null?void 0:this.device;case"symbol":return this==null?void 0:this.symbol;case"footprint":return this==null?void 0:this.footprint;case"panelLib":return this==null?void 0:this.panelLib;case"model3D":return this==null?void 0:this.model3D;case"modelSimLib":return this==null?void 0:this.modelSimLib;default:return null}}isInTab(t){return!!this.getLibraryFunctionsClassInTab(t)}isHasCategoryTreeInTab(t){let i=this.getLibraryFunctionsClassInTab(t);return!!(i!=null&&i.getClassificationTree)}async getAmountByWd(t,i){var r;let s=this.getLibraryFunctionsClassInTab(t),n=await(s==null?void 0:s.getList({page:1,pageSize:1,query:{wd:i}}));return(r=n==null?void 0:n.count)!=null?r:0}getTabByCategoryType(t){switch(t){case 1:return"cbb";case 3:return"device";case 2:return"symbol";case 4:return"footprint";default:return null}}async getClassificationTreeInTab(t){var i;return this.isHasCategoryTreeInTab(t)?await((i=this.getLibraryFunctionsClassInTab(t))==null?void 0:i.getClassificationTree()):null}async getCategoryTreeDataItemsInTab(t){let i=await this.getClassificationTreeInTab(t);return i==null?void 0:i.map(r=>this.transformer.transformCategory(r))}async getClassificationTreeByCategoryType(t){let i=this.getTabByCategoryType(t);return i&&this.getClassificationTreeInTab(i)}async getCategoryTreeDataItemsByCategoryType(t){let i=this.getTabByCategoryType(t);return i&&this.getCategoryTreeDataItemsInTab(i)}getSelectTypeListInTab(t){let i=[];if(t==="device"){let r=this._deviceSupportedSymbolTypes;i=r?ov.filter(s=>r.includes(Number(s.value))||!s.value):ov}else if(t==="symbol"){let r=this._symbolSupportedSymbolTypes;i=r?lv.filter(s=>r.includes(Number(s.value))||!s.value):lv}return i.length>2?i:[]}getPreviewTypesInTab(t){let i=MM[t];return t==="device"&&this._deviceSupportedPreviewTypes?i=i.filter(r=>{var s;return(s=this._deviceSupportedPreviewTypes)==null?void 0:s.includes(r)}):t==="footprint"&&this._footprintSupportedPreviewTypes&&(i=i.filter(r=>{var s;return(s=this._footprintSupportedPreviewTypes)==null?void 0:s.includes(r)})),i}async getListInTab(t,i){var r;return await((r=this.getLibraryFunctionsClassInTab(t))==null?void 0:r.getList(i))}async getTransformedListInTab(t,i){var r;return await((r=this.getLibraryFunctionsClassInTab(t))==null?void 0:r.getTransformedList(i))}async getDetailInTab(t,i,r){var s;return await((s=this.getLibraryFunctionsClassInTab(t))==null?void 0:s.getDetail(i,r))}async getTransformedDetailInTab(t,i,r){var s;return await((s=this.getLibraryFunctionsClassInTab(t))==null?void 0:s.getTransformedDetail(i,r))}},V5=class{constructor(e=10){this._runingCount=0,this._handleCount=0,this._queue=[],this._results=[],this._windowSize=e,this._finishCallback=null,this._taskStartCallback=null,this._taskEndCallback=null}pushTask(e){this._queue.push(e)}setFinishCallback(e){this._finishCallback=e}setTaskStartCallback(e){this._taskStartCallback=e}setTaskEndCallback(e){this._taskEndCallback=e}next(){for(;this._runingCount<this._windowSize&&this._queue.length>0;){this._runingCount+=1,this._handleCount+=1;let e=this._handleCount-1,t=this._queue.shift();this._taskStartCallback&&this._taskStartCallback(e),t(e).then(i=>{this._results.push(i)}).catch(i=>{this._results.push(i)}).finally(()=>{this._runingCount-=1,this._taskEndCallback&&this._taskEndCallback(this._results[this._results.length-1]),this.next()})}this._runingCount<=0&&this._finishCallback&&this._finishCallback(this._results)}},Dm=class{onString(e,t,i){}onAttr(e,t,i){}onGroup(e,t,i,r,s){}onDelGroup(e,t,i,r){}onDelString(e,t,i,r){}onDelAttr(e,t,i,r){}onPanelizeSide(e,t,i,r){}onDelPanelizeSide(e,t,i,r){}onPanelizeStamp(e,t,i,r){}onDelPanelizeStamp(e,t,i,r){}onPanelize(e,t,i,r){}onDelPanelize(e,t,i){}onRuleSelector(e,t,i,r){}onDelRuleSelector(e,t,i,r){}onRule(e,t,i,r){}onDelRule(e,t,i,r,s){}onRuleTemplate(e,t,i,r){}onDimension(e,t,i,r,s,n){}onDelDimension(e,t,i,r){}onBoss(e,t,i,r,s,n){}onDelBoss(e,t,i,r){}onShellEntity(e,t,i,r,s,n){}onDelShellEntity(e,t,i,r){}onShellCut(e,t,i,r,s,n){}onDelShellCut(e,t,i,r){}onCrease(e,t,i,r,s,n){}onDelCrease(e,t,i,r){}onShell(e,t,i,r,s,n){}onDelShell(e,t,i,r){}onFpcFill(e,t,i,r,s,n){}onDelFpcFill(e,t,i,r){}onTeardrop(e,t,i,r,s,n){}onDelTeardrop(e,t,i,r){}onImage(e,t,i,r,s,n){}onDelImage(e,t,i,r){}onPoured(e,t,i,r,s,n){}onDelPoured(e,t,i,r){}onPour(e,t,i,r,s,n){}onDelPour(e,t,i,r){}onRegion(e,t,i,r,s,n){}onDelRegion(e,t,i,r){}onFill(e,t,i,r,s,n){}onDelFill(e,t,i,r){}onPoly(e,t,i,r,s,n){}onDelPoly(e,t,i,r){}onEQLenGrp(e,t,i,r,s){}onDelEQLenGrp(e,t,i,r){}onDelProp(e,t,i,r){}onObj(e,t,i,r,s,n){}onDelObj(e,t,i,r){}onArc(e,t,i,r,s,n){}onDelArc(e,t,i,r){}onCArc(e,t,i,r,s,n){}onDelCArc(e,t,i,r){}onLine(e,t,i,r,s,n){}onDelLine(e,t,i,r){}onPad(e,t,i,r,s,n){}onDelPad(e,t,i,r){}onVia(e,t,i,r,s,n){}onDelVia(e,t,i,r){}onDelConnect(e,t,i,r){}onPreference(e,t,i,r){}onSilkOpts(e,t,i,r,s){}onDelSilkOpts(e,t,i,r){}onPrimitive(e,t,i,r,s){}onDelPrimitive(e,t,i,r){}onNet(e,t,i,r,s){}onDelNet(e,t,i,r){}onPartition(e,t,i,r,s,n){}onDelPartition(e,t,i,r){}onActiveLayer(e,t,i,r){}onLayerPhys(e,t,i,r,s){}onDelLayerPhys(e,t,i,r){}onLayer(e,t,i,r,s){}onDelLayer(e,t,i,r){}onCanvas(e,t,i,r){}onDocDetail(e,t,i,r){}onStringNum(e,t){}onAttrNum(e,t){}onDimensionNum(e,t){}onBossNum(e,t){}onShellEntityNum(e,t){}onShellCutNum(e,t){}onCreaseNum(e,t){}onShellNum(e,t){}onFpcFillNum(e,t){}onTeardropNum(e,t){}onImageNum(e,t){}onPouredNum(e,t){}onPourNum(e,t){}onRegionNum(e,t){}onFillNum(e,t){}onPolyNum(e,t){}onObjNum(e,t){}onArcNum(e,t){}onCArcNum(e,t){}onLineNum(e,t){}onPadNum(e,t){}onViaNum(e,t){}onPartitionNum(e,t){}},Y5=class extends Dm{constructor(e){super(),this.source={},this._action=e}get action(){return this._action}getSource(){return this.source}onString(e,t,i){this.source[e]=t}onAttr(e,t,i){i||(this.action&&this.action(e,t),this.source[e]=t)}onDimension(e,t,i,r,s,n){this.source[e]=s}onBoss(e,t,i,r,s,n){this.source[e]=s}onShellEntity(e,t,i,r,s,n){this.source[e]=s}onShellCut(e,t,i,r,s,n){this.source[e]=s}onCrease(e,t,i,r,s,n){this.source[e]=s}onShell(e,t,i,r,s,n){this.source[e]=s}onFpcFill(e,t,i,r,s,n){this.source[e]=s}onTeardrop(e,t,i,r,s,n){this.source[e]=s}onImage(e,t,i,r,s,n){this.source[e]=s}onPoured(e,t,i,r,s,n){this.source[e]=s}onPour(e,t,i,r,s,n){this.source[e]=s}onRegion(e,t,i,r,s,n){this.source[e]=s}onFill(e,t,i,r,s,n){this.source[e]=s}onPoly(e,t,i,r,s,n){this.source[e]=s}onObj(e,t,i,r,s,n){this.source[e]=s}onArc(e,t,i,r,s,n){this.source[e]=s}onCArc(e,t,i,r,s,n){this.source[e]=s}onLine(e,t,i,r,s,n){this.source[e]=s}onPad(e,t,i,r,s,n){this.source[e]=s}onVia(e,t,i,r,s,n){this.source[e]=s}},UE=class extends gx{onXSignalsGroup(e,t,i,r,s){}onDelXSignalsGroup(e,t,i,r){}onXSignals(e,t,i,r,s){}onDelXSignals(e,t,i,r){}onBoard(e,t,i,r){}onDelBoard(e,t,i){}constructor(e,t,i){super(e,t,i,new xm(!1)),this._compilerHandler=null}async init(e=!1,t=!1,i=!1,r=!1){if(!this.uuid)debugger;return super.init(e,t,i,r)}onBlob(e,t,i,r,s){}onDelBlob(e,t,i,r){}onFont(e,t,i,r){}onDelFont(e,t,i,r){}canvasSelected(){return""}onSelectChange(e,t,i){}onSelectQuit(e,t){}onLayerFill(e,t,i,r,s){}onDelLayerFill(e,t,i,r){}setHandler(e){this._compilerHandler=e}onGroup(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onGroup(e,t,i,r,s)}onDelGroup(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelGroup(e,t,i,r)}onString(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onString(e,s,n)}onDelString(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelString(e,t,i,r)}onAttr(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onAttr(e,s,n)}onDelAttr(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelAttr(e,t,i,r)}onPanelizeSide(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelizeSide(e,t,i,r)}onDelPanelizeSide(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPanelizeSide(e,t,i,r)}onPanelizeStamp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelizeStamp(e,t,i,r)}onDelPanelizeStamp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPanelizeStamp(e,t,i,r)}onPanelize(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPanelize(e,t,i,r)}onDelPanelize(e,t,i){this._compilerHandler&&this._compilerHandler.onDelPanelize(e,t,i)}onRuleSelector(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRuleSelector(e,t,i,r)}onDelRuleSelector(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelRuleSelector(e,t,i,r)}onRule(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRule(e,t,i,r)}onDelRule(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onDelRule(e,t,i,r,s)}onRuleTemplate(e,t,i,r){this._compilerHandler&&this._compilerHandler.onRuleTemplate(e,t,i,r)}onDimension(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onDimension(e,t,i,r,s,n)}onDelDimension(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelDimension(e,t,i,r)}onBoss(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onBoss(e,t,i,r,s,n)}onDelBoss(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelBoss(e,t,i,r)}onShellEntity(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onShellEntity(e,t,i,r,s,n)}onDelShellEntity(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShellEntity(e,t,i,r)}onShellCut(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onShellCut(e,t,i,r,s,n)}onDelShellCut(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShellCut(e,t,i,r)}onCrease(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onCrease(e,t,i,r,s,n)}onDelCrease(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelCrease(e,t,i,r)}onShell(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onShell(e,t,i,r,s,n)}onDelShell(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelShell(e,t,i,r)}onFpcFill(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onFpcFill(e,t,i,r,s,n)}onDelFpcFill(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelFpcFill(e,t,i,r)}onTeardrop(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onTeardrop(e,t,i,r,s,n)}onDelTeardrop(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelTeardrop(e,t,i,r)}onImage(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onImage(e,t,i,r,s,n)}onDelImage(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelImage(e,t,i,r)}onPoured(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onPoured(e,t,i,r,s,n)}onDelPoured(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPoured(e,t,i,r)}onPour(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onPour(e,t,i,r,s,n)}onDelPour(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPour(e,t,i,r)}onRegion(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onRegion(e,t,i,r,s,n)}onDelRegion(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelRegion(e,t,i,r)}onFill(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onFill(e,t,i,r,s,n)}onDelFill(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelFill(e,t,i,r)}onPoly(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onPoly(e,t,i,r,s,n)}onDelPoly(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPoly(e,t,i,r)}onEQLenGrp(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onEQLenGrp(e,t,i,r,s)}onDelEQLenGrp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelEQLenGrp(e,t,i,r)}onDelProp(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelProp(e,t,i,r)}onObj(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onObj(e,t,i,r,s,n)}onDelObj(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelObj(e,t,i,r)}onArc(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onArc(e,t,i,r,s,n)}onDelArc(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelArc(e,t,i,r)}onCArc(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onCArc(e,t,i,r,s,n)}onDelCArc(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelCArc(e,t,i,r)}onLine(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onLine(e,t,i,r,s,n)}onDelLine(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLine(e,t,i,r)}onPad(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onPad(e,t,i,r,s,n)}onDelPad(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPad(e,t,i,r)}onVia(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onVia(e,t,i,r,s,n)}onDelVia(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelVia(e,t,i,r)}onDelConnect(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelConnect(e,t,i,r)}onPreference(e,t,i,r){this._compilerHandler&&this._compilerHandler.onPreference(e,t,i,r)}onSilkOpts(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onSilkOpts(e,t,i,r,s)}onDelSilkOpts(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelSilkOpts(e,t,i,r)}onPrimitive(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onPrimitive(e,t,i,r,s)}onDelPrimitive(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPrimitive(e,t,i,r)}onNet(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onNet(e,t,i,r,s)}onDelNet(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelNet(e,t,i,r)}onPartition(e,t,i,r,s,n){this._compilerHandler&&this._compilerHandler.onPartition(e,t,i,r,s,n)}onDelPartition(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelPartition(e,t,i,r)}onActiveLayer(e,t,i,r){this._compilerHandler&&this._compilerHandler.onActiveLayer(e,t,i,r)}onLayerPhys(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onLayerPhys(e,t,i,r,s)}onDelLayerPhys(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLayerPhys(e,t,i,r)}onLayer(e,t,i,r,s){this._compilerHandler&&this._compilerHandler.onLayer(e,t,i,r,s)}onDelLayer(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDelLayer(e,t,i,r)}onCanvas(e,t,i,r){this._compilerHandler&&this._compilerHandler.onCanvas(e,t,i,r)}onDocDetail(e,t,i,r){this._compilerHandler&&this._compilerHandler.onDocDetail(e,t,i,r)}onStringNum(e,t){this._compilerHandler&&this._compilerHandler.onStringNum(e,t)}onAttrNum(e,t){this._compilerHandler&&this._compilerHandler.onAttrNum(e,t)}onDimensionNum(e,t){this._compilerHandler&&this._compilerHandler.onDimensionNum(e,t)}onBossNum(e,t){this._compilerHandler&&this._compilerHandler.onBossNum(e,t)}onShellEntityNum(e,t){this._compilerHandler&&this._compilerHandler.onShellEntityNum(e,t)}onShellCutNum(e,t){this._compilerHandler&&this._compilerHandler.onShellCutNum(e,t)}onCreaseNum(e,t){this._compilerHandler&&this._compilerHandler.onCreaseNum(e,t)}onShellNum(e,t){this._compilerHandler&&this._compilerHandler.onShellNum(e,t)}onFpcFillNum(e,t){this._compilerHandler&&this._compilerHandler.onFpcFillNum(e,t)}onTeardropNum(e,t){this._compilerHandler&&this._compilerHandler.onTeardropNum(e,t)}onImageNum(e,t){this._compilerHandler&&this._compilerHandler.onImageNum(e,t)}onPouredNum(e,t){this._compilerHandler&&this._compilerHandler.onPouredNum(e,t)}onPourNum(e,t){this._compilerHandler&&this._compilerHandler.onPourNum(e,t)}onRegionNum(e,t){this._compilerHandler&&this._compilerHandler.onRegionNum(e,t)}onFillNum(e,t){this._compilerHandler&&this._compilerHandler.onFillNum(e,t)}onPolyNum(e,t){this._compilerHandler&&this._compilerHandler.onPolyNum(e,t)}onObjNum(e,t){this._compilerHandler&&this._compilerHandler.onObjNum(e,t)}onArcNum(e,t){this._compilerHandler&&this._compilerHandler.onArcNum(e,t)}onCArcNum(e,t){this._compilerHandler&&this._compilerHandler.onCArcNum(e,t)}onLineNum(e,t){this._compilerHandler&&this._compilerHandler.onLineNum(e,t)}onPadNum(e,t){this._compilerHandler&&this._compilerHandler.onPadNum(e,t)}onViaNum(e,t){this._compilerHandler&&this._compilerHandler.onViaNum(e,t)}onPartitionNum(e,t){this._compilerHandler&&this._compilerHandler.onPartitionNum(e,t)}};function q5(e,t){let i=0;return function(...r){let s=new Date().getTime();s-i>t&&(e.apply(this,r),i=s)}}function W5(e,t,i){let r,s,n,a,o,l,h=0,c=!1,d=!1,f=!0;if(typeof e!="function")throw new TypeError("Expected a function");t=Number(t)||0,typeof i=="object"&&(c=!!i.leading,d="maxWait"in i,n=d?Math.max(Number(i.maxWait)||0,t):n,f="trailing"in i?!!i.trailing:f);function u(E){let T=r,P=s;return r=s=void 0,h=E,a=e.apply(P,T),a}function p(E){return h=E,o=window.setTimeout(y,t),c?u(E):a}function g(E){let T=E-l,P=E-h,A=t-T;return d?Math.min(A,n-P):A}function _(E){let T=E-l,P=E-h;return l===void 0||T>=t||T<0||d&&P>=n}function y(){let E=Date.now();if(_(E))return m(E);o=window.setTimeout(y,g(E))}function m(E){return o=void 0,f&&r?u(E):(r=s=void 0,a)}function O(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?a:m(Date.now())}function v(){let E=Date.now(),T=_(E);if(r=arguments,s=this,l=E,T){if(o===void 0)return p(l);if(d)return o=window.setTimeout(y,t),u(l)}return o===void 0&&(o=window.setTimeout(y,t)),a}return v.cancel=O,v.flush=b,v}var Fl=new Map;Fl.set("<","&lt;");Fl.set(">","&gt;");Fl.set('"',"&quot;");Fl.set("'","&apos;");Fl.set("&","&amp;");function GE(e){if(typeof e!="string")return e;if(e==null)return"";function t(i){return Fl.get(i)}return e==null?"":rg(e,Fl)?(e+"").replace(/[<>'"&]/g,t):e}var Hl=new Map;Hl.set("&lt;","<");Hl.set("&gt;",">");Hl.set("&quot;",'"');Hl.set("&apos;","'");Hl.set("&amp;","&");Hl.set("&#039;","'");function X5(e){if(typeof e!="string")return e;if(e==null)return"";let t={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#039;":"'"};function i(r){return Hl.get(r)}return rg(e,t)?(e+"").replace(/&([^;]+);/g,i):e}var bd=new Map;bd.set("~","&#126;");bd.set("^","&#94;");bd.set("#@$","&#35;&#64;&#36;");bd.set("`","&#96;");function J5(e){if(typeof e!="string")return e;if(e==null)return"";let t={"~":"&#126;","^":"&#94;","#@$":"&#35;&#64;&#36;","`":"&#96;"};function i(r){return bd.get(r)}return rg(e,t)?e.replace(/(\~|\^|#@\$|\`)/g,i):e}function rm(e){if(typeof e!="object"||e===null||e===void 0)return e;if(Array.isArray(e))return e.map(rm);{let t={};for(let i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=rm(e[i]));return t}}function sm(e){if(typeof e!="object"||e===null||e instanceof Date)return typeof e=="string"&&e.includes("<")&&(e=GE(e)),e;if(Array.isArray(e))return e.map(sm);{let t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=sm(e[i]));return t}}function Z5(e,t){let i="",r="";for(let s=0;s<e.length;s++)String(e[s])&&(r+=e[s]+"	");r=r.slice(0,-1),i+=r+`\r
`;for(let s=0;s<t.length;s++){r="";for(let n=0;n<e.length;n++)r+='"'+(typeof t[s][n]<"u"?t[s][n]:"")+'"	';r=r.slice(0,r.length-1),i+=r+`\r
`}return i}function K5(e,t={targetType:"blob"}){let{targetType:i,width:r,height:s}=t,n=new Image(r,s);return new Promise((a,o)=>{n.onload=function(){let l=document.createElement("canvas"),h=l.getContext("2d");switch(l.width=n.width,l.height=n.height,h.drawImage(n,0,0,n.width,n.height),i){case"dataURL":{a(l.toDataURL());break}case"blob":default:{l.toBlob(c=>{a(c)});break}}},n.onerror=l=>{o(l)},n.src=e})}async function $5(e,t={}){return new Promise((i,r)=>{try{let{targetType:s="blob",imageType:n="image/png"}=t,a=document.createElement("canvas"),o=a.getContext("2d");switch(a.width=e.width,a.height=e.height,o.putImageData(e,0,0),s){case"dataURL":{i(a.toDataURL(n));break}case"blob":default:{a.toBlob(l=>{i(l)},n);break}}}catch(s){r(s)}})}function _s(e=[],t,i){if(!e||!e.length||!t)return{index:-1,data:null};let r={index:-1,data:null};for(let s=0;s<e.length;s++)if(typeof e[s]=="object"&&e[s][t]===i){r.data=e[s],r.index=s;break}return r}function Q5(e=[],t,i){if(!e||!e.length||!t)return{indexs:[],datas:[]};let r={indexs:[],datas:[]};for(let s=0;s<e.length;s++)typeof e[s]=="object"&&e[s][t]===i&&(r.datas.push(e[s]),r.indexs.push(s));return r}var e6=class extends Dm{constructor(e){super(),this._action=e}get action(){return this._action}onAttr(e,t,i){i||this.action(t.key,t.value)}};async function t6(e,t,i,r=!0){let s={initResponse:null,d3modelItem:null,d3modelItemName:void 0,d3modelItemTransform:void 0,d3modelItemPath:void 0,d3modelItemId:void 0,compiler:null},n=new Map;return new Promise(async a=>{let o=new UE(e,t,i);s.compiler=o,o.setHandler(new e6(async(l,h)=>{if(typeof h<"u"&&n.set(l,h),n.has("3D Model")&&n.has("3D Model Title")&&n.has("3D Model Transform")){s.d3modelItemId=n.get("3D Model"),s.d3modelItemName=n.get("3D Model Title"),s.d3modelItemTransform=n.get("3D Model Transform");let c=_d(s.d3modelItemId,!0);s.d3modelItemPath=c.path}})),s.initResponse=await o.init().catch(l=>({message:l.message,success:!1})),s.d3modelItemId&&r&&(s.d3modelItem=await md(s.d3modelItemId)),s.compiler.destroy(),n.clear(),a(s)})}async function i6(e,t){let i={padList:[]};return new Promise(async r=>{try{let s=new vM(e,t,!0),n=await s.getPads()||{},a=Object.keys(n);for(let o=0;o<a.length;o++)i.padList.push({...n[a[o]]});s.destroy(),r(i)}catch{r(i)}})}function r6(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);let r=[1,10,100,1e3][t]||Math.pow(10,t)||10;if(i){let s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),s+e}else return Math.round(e*r+1e-10)/r}function s6(e,t){typeof e=="string"&&(e=parseFloat(e));let i=Math.pow(10,t);return Math.round(e*i)/i}var n6={conversion(e,t,i){let r=e+2+t;return this[r](i)},conversion1(e,t,i){let r=e+2+t,s=this[r](i);return t=="mil"?Math.round(s*10)/10:Math.round(s*1e3)/1e3},mil2mil(e){return e},mil2mm(e){return e*.0254},mil2cm(e){return e*.00254},mil2inch(e){return e/1e3},mm2mm(e){return e},mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t},mm2cm(e){return e/10},mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t},cm2mil(e){let t=Math.pow(10,6);return Math.round(e*3.937007874015748*t)/t},cm2mm(e){return e*10},cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t},inch2mil(e){return e*1e3},inch2mm(e){return e*25.4},inch2cm(e){return e*2.54}};function a6(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function o6(e){return e<0?(360+e%360)%360:e>=360?e%360:e}function zE(e,t,i,r){var s=e-i,n=t-r;return s*s+n*n}function l6(e,t,i,r){return Math.sqrt(zE(e,t,i,r))}function h6(e,t,i,r){var s=i-e,n=r-t,a=Math.atan2(n,s);return a=a<0?a+Math.PI+Math.PI:a,a}function c6(e){return HE(e)&&Object.keys(e).length===0}function HE(e){return Object.prototype.toString.call(e).slice(8,-1)==="Object"}function u6(e){return jE(e)||VE(e)}function jE(e){return Object.prototype.toString.call(e).slice(8,-1)==="AsyncFunction"}function VE(e){return Object.prototype.toString.call(e).slice(8,-1)==="Function"}var Wt=class{};Wt.unitConversion=n6,Wt.ConcurrencyTaskQueue=V5,Wt.FootprintCompilerInstance=UE,Wt.FootprintCompilerHandlerProxy=Dm,Wt.FootprintCompilerAttr=Y5,Wt.createCSVString=Z5,Wt.svg2png=K5,Wt.imageData2NewImage=$5,Wt.htmlEncode=GE,Wt.htmlDecode=X5,Wt.strEncode=J5,Wt.isEmptyObj=c6,Wt.isPlainObject=HE,Wt.isFn=u6,Wt.isAsyncFunction=jE,Wt.isNormalFunction=VE,Wt.formatDate=jo,Wt.formatDate2=N5,Wt.deepClone=rm,Wt.deepCloneWithHtmlEncode=sm,Wt.naturalSortComparator=Tv,Wt.naturalSortSplitor=N0,Wt.naturalSort=WC,Wt.naturalStrSort=XC,Wt.naturalSort1=JC,Wt.naturalCompare=ZC,Wt.isObjKeyInStr=rg,Wt.throttle=q5,Wt.debounce=W5,Wt.findList=_s,Wt.findListAll=Q5,Wt.randomString=QC,Wt.parseJSON=eL,Wt.splitComponentId2FolderAndFilenameMixin=_d,Wt.getFootprintPadInfo=i6,Wt.getFootprint3DInfo=t6;var Il=class{};Il.toFixed=r6,Il.toFixed1=s6,Il.floatEqual=a6,Il.fixAngle=o6,Il.getDistance=l6,Il.getDistance2=zE,Il.getAngleByDot=h6;var YE=class nm{constructor(){this._changeCbs=new Set,this._map=new Map,this._debounceNotify=Wt.debounce(()=>{this._notify()},50)}static get context(){return Ri()}static getInstance(){var t;return(t=this.context.extendLibManager)!=null?t:this.context.extendLibManager=new nm}_notify(){for(let t of this._changeCbs)t()}onChange(t){this._changeCbs.add(t)}offChange(t){this._changeCbs.delete(t)}_getLibId(t){return`${nm.LIB_ID_PREFFIX}${t}`}async addLibWithId(t){this._map.set(t.id,await j5.set(t)),this._debounceNotify()}async addLib(t){let i=this._getLibId(t.title);return await this.addLibWithId({...t,id:i}),i}deleteLib(t){return this._debounceNotify(),this._map.delete(t)}hasLib(t){return this._map.has(t)}getLib(t){return this._map.get(t)}getLibs(){return Array.from(this._map.values())}updateLibTitle(t,i){let r=this._map.get(t);r&&(r.title=i,this._debounceNotify())}updateLibPosition(t,i){let r=this._map.get(t);r&&(r.position=i,this._debounceNotify())}};YE.LIB_ID_PREFFIX="extend_lib_";var $i=YE,Rm=class{},d6=(e=>(e.PROJECT_DOCUMENT_LOCKED="PROJECT_DOCUMENT_LOCKED",e.PROJECT_DOCUMENT_UPDATE_REJECT="PROJECT_DOCUMENT_UPDATE_REJECT",e.NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND="NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND",e.NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND="NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND",e.DEVICE_ATTRIBUTES_ERROR="DEVICE_ATTRIBUTES_ERROR",e.DEVICE_DESCRIPTION_ERROR="DEVICE_DESCRIPTION_ERROR",e.SYMBOL_DESCRIPTION_ERROR="SYMBOL_DESCRIPTION_ERROR",e.FOOTPRINT_DESCRIPTION_ERROR="FOOTPRINT_DESCRIPTION_ERROR",e.D3MODEL_DESCRIPTION_ERROR="D3MODEL_DESCRIPTION_ERROR",e.DEVICE_NAMA_ERROR="DEVICE_NAMA_ERROR",e.SYMBOL_NAMA_ERROR="SYMBOL_NAMA_ERROR",e.FOOTPRINT_NAMA_ERROR="FOOTPRINT_NAMA_ERROR",e.PANEL_LIB_NAMA_ERROR="PANEL_LIB_NAMA_ERROR",e.D3MODEL_NAMA_ERROR="D3MODEL_NAMA_ERROR",e.SIM_MODEL_NAMA_ERROR="SIM_MODEL_NAMA_ERROR",e.DEVICE_SAME_NAMA_EXISTS="DEVICE_SAME_NAMA_EXISTS",e.SYMBOL_SAME_NAMA_EXISTS="SYMBOL_SAME_NAMA_EXISTS",e.FOOTPRINT_SAME_NAMA_EXISTS="FOOTPRINT_SAME_NAMA_EXISTS",e.D3MODEL_SAME_NAMA_EXISTS="D3MODEL_SAME_NAMA_EXISTS",e.SIM_MODEL_SAME_NAMA_EXISTS="SIM_MODEL_SAME_NAMA_EXISTS",e.PANELLIB_SAME_NAMA_EXISTS="PANELLIB_SAME_NAMA_EXISTS",e.PARAMETER_VERIFICATION="PARAMETER_VERIFICATION",e.RESULT_VERIFICATION="RESULT_VERIFICATION",e.GET_DEVICE="GET_DEVICE",e.GET_DEVICE_ATTRIBUTES_KEYS="GET_DEVICE_ATTRIBUTES_KEYS",e.GET_DEVICE_ATTRIBUTES_VALUES="GET_DEVICE_ATTRIBUTES_VALUES",e.GET_DEVICE_NOT_FOUND="GET_DEVICE_NOT_FOUND",e.GET_DEVICE_LIST="GET_DEVICE_LIST",e.GET_DEVICE_SEARCH_LIST="GET_DEVICE_SEARCH_LIST",e.GET_DEVICE_SEARCH_UUIDS="GET_DEVICE_SEARCH_UUIDS",e.STAR_DEVICE="STAR_DEVICE",e.UNSTAR_DEVICE="UNSTAR_DEVICE",e.GET_SYMBOL="GET_SYMBOL",e.GET_SYMBOL_NOT_FOUND="GET_SYMBOL_NOT_FOUND",e.GET_SYMBOL_LIST="GET_SYMBOL_LIST",e.GET_SYMBOL_SEARCH_LIST="GET_SYMBOL_SEARCH_LIST",e.GET_SYMBOL_SEARCH_UUIDS="GET_SYMBOL_SEARCH_UUIDS",e.STAR_SYMBOL="STAR_SYMBOL",e.UNSTAR_SYMBOL="UNSTAR_SYMBOL",e.GET_FOOTPRINT="GET_FOOTPRINT",e.GET_FOOTPRINT_NOT_FOUND="GET_FOOTPRINT_NOT_FOUND",e.GET_FOOTPRINT_LIST="GET_FOOTPRINT_LIST",e.GET_FOOTPRINT_SEARCH_LIST="GET_FOOTPRINT_SEARCH_LIST",e.GET_FOOTPRINT_SEARCH_UUIDS="GET_FOOTPRINT_SEARCH_UUIDS",e.STAR_FOOTPRINT="STAR_FOOTPRINT",e.UNSTAR_FOOTPRINT="UNSTAR_FOOTPRINT",e.GET_PANEL_LIB="GET_PANEL_LIB",e.GET_PANEL_LIB_LIST="GET_PANEL_LIB_LIST",e.GET_PANEL_LIB_NOT_FOUND="GET_PANEL_LIB_NOT_FOUND",e.GET_PANEL_LIB_SEARCH_LIST="GET_PANEL_LIB_SEARCH_LIST",e.GET_PANEL_LIB_SEARCH_UUIDS="GET_PANEL_LIB_SEARCH_UUIDS",e.STAR_PANEL_LIB="STAR_PANEL_LIB",e.UNSTAR_PANEL_LIB="UNSTAR_PANEL_LIB",e.GET_D3MODEL="GET_D3MODEL",e.GET_D3MODEL_NOT_FOUND="GET_D3MODEL_NOT_FOUND",e.GET_D3MODEL_LIST="GET_D3MODEL_LIST",e.GET_D3MODEL_SEARCH_LIST="GET_D3MODEL_SEARCH_LIST",e.GET_D3MODEL_SEARCH_UUIDS="GET_D3MODEL_SEARCH_UUIDS",e.GET_SIM_MODEL="GET_SIM_MODEL",e.GET_SIM_NOT_FOUND="GET_SIM_NOT_FOUND",e.GET_SIM_MODEL_LIST="GET_SIM_MODEL_LIST",e.GET_SIM_MODEL_SEARCH_LIST="GET_SIM_MODEL_SEARCH_LIST",e.GET_SIM_MODEL_SEARCH_UUIDS="GET_SIM_MODEL_SEARCH_UUIDS",e.CROSS_BIND="CROSS_BIND",e.CROSS_BIND_EXIT="CROSS_BIND_EXIT",e.IMPORT_EXIST_PROJECT="IMPORT_EXIST_PROJECT",e.CREATE_PROJECT="CREATE_PROJECT",e.CREATE_DEVICE="CREATE_DEVICE",e.CREATE_DEVICE_PERMISSIONS="CREATE_DEVICE_PERMISSIONS",e.CREATE_DEVICE_GET_ORIGIN="CREATE_DEVICE_GET_ORIGIN",e.CREATE_SYMBOL="CREATE_SYMBOL",e.CREATE_SYMBOL_PERMISSIONS="CREATE_SYMBOL_PERMISSIONS",e.CREATE_SYMBOL_GET_ORIGIN="CREATE_SYMBOL_GET_ORIGIN",e.CREATE_SYMBOL_MIGRATE_CANVAS_ERROR="CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",e.CREATE_FOOTPRINT="CREATE_FOOTPRINT",e.CREATE_FOOTPRINT_PERMISSIONS="CREATE_FOOTPRINT_PERMISSIONS",e.CREATE_FOOTPRINT_GET_ORIGIN="CREATE_FOOTPRINT_GET_ORIGIN",e.CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR="CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",e.CREATE_D3MODEL="CREATE_D3MODEL",e.CREATE_D3MODEL_PERMISSIONS="CREATE_D3MODEL_PERMISSIONS",e.CREATE_PANEL_LIB="CREATE_PANEL_LIB",e.CREATE_PANEL_LIB_PERMISSIONS="CREATE_PANEL_LIB_PERMISSIONS",e.CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR="CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",e.CREATE_SIM_MODEL="CREATE_SIM_MODEL",e.CREATE_SIM_MODEL_PERMISSIONS="CREATE_SIM_MODEL_PERMISSIONS",e.CREATE_SIM_MODEL_MIGRATE_CANVAS_ERROR="CREATE_SIM_MODEL_MIGRATE_CANVAS_ERROR",e.UPDATE_DEVICE="UPDATE_DEVICE",e.UPDATE_DEVICE_ATTRIBUTES="UPDATE_DEVICE_ATTRIBUTES",e.UPDATE_DEVICE_PERMISSIONS="CREATE_DEVICE_PERMISSIONS",e.UPDATE_SYMBOL="UPDATE_SYMBOL",e.UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR="UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR",e.UPDATE_SYMBOL_PERMISSIONS="UPDATE_SYMBOL_PERMISSIONS",e.UPDATE_FOOTPRINT="UPDATE_FOOTPRINT",e.UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR="UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",e.UPDATE_FOOTPRINT_PERMISSIONS="UPDATE_FOOTPRINT_PERMISSIONS",e.UPDATE_D3MODEL="UPDATE_D3MODEL",e.UPDATE_D3MODEL_PERMISSIONS="UPDATE_D3MODEL_PERMISSIONS",e.UPDATE_SIM_MODEL="UPDATE_SIM_MODEL",e.UPDATE_SIM_MODEL_PERMISSIONS="UPDATE_SIM_MODEL_PERMISSIONS",e.UPDATE_PANEL_LIB="UPDATE_PANEL_LIB",e.UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR="UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",e.UPDATE_PANEL_LIB_PERMISSIONS="UPDATE_PANEL_LIB_PERMISSIONS",e.DELETE_DEVICE="DELETE_DEVICE",e.DELETE_SYMBOL="DELETE_SYMBOL",e.DELETE_FOOTPRINT="DELETE_FOOTPRINT",e.DELETE_PANEL_LIB="DELETE_PANEL_LIB",e.DELETE_SIM_MODEL="DELETE_SIM_MODEL",e.DELETE_3DMODEL="DELETE_3DMODEL",e))(d6||{}),re=class{constructor(e,t=""){this._message=t,this._action=e}get message(){return this._message}set message(e){this._message=e}get action(){return this._action}set action(e){this._action=e}toJSON(){return{message:this.message,action:this.action}}};function jr(e,t){let i=Object.keys(t);for(let r=0;r<i.length;r++)BB.indexOf(i[r])<=-1||(i[r]==="title"&&"display_title"in e&&t.title&&(e.display_title=String(t.title),e.title=String(t.title).toLocaleLowerCase()),e[i[r]]=t[i[r]])}function yd(e,t){return e[t]}function qE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("DEVICE_NAMA_ERROR",i)}}function WE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("SYMBOL_NAMA_ERROR",i)}}function XE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("FOOTPRINT_NAMA_ERROR",i)}}function JE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("PANEL_LIB_NAMA_ERROR",i)}}function ZE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("D3MODEL_NAMA_ERROR",i)}}function KE(e){let t=e.trim();if(!t||t.length<=0||t.length>128){let i="The title length must be between 1~128 characters!";throw new re("SIM_MODEL_NAMA_ERROR",i)}}async function Qh(e,t){let i=[],r=[],s=async o=>{let{message:l}=await Xe.messageBus.rpcCall(Ja.TAG.CREATE,o);return l},n=null;try{for(let o=0;o<e.length;o++){let l=await s({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let c={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(c),t&&t(c,o);continue}let h={...l,result:{...e[o]}};r.push(h)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){n=o}let a=n?n.msg||n.message:"Add Categories Batch Error";return{code:n?n.code:He.ERR_CODE.NORMAL,success:!1,result:null,message:a}}function Bu(e=0,t=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(t-e+1))+e}function sd(e=36){let t=[],i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let r=0;r<e;r++)t[r]=i.substr(Math.floor(Math.random()*16),1);return t[14]&&(t[14]=String(Bu(1,9))),t[19]&&(t[19]=i.substr(+t[19]&3|8,1)),t[8]&&(t[8]=String(Bu(1,9))),t[13]&&(t[13]=String(Bu(1,9))),t[18]&&(t[18]=String(Bu(1,9))),t[23]&&(t[23]=String(Bu(1,9))),t.join("")}function mv(e,t=!0){return(i,r)=>{let s=i[e],n=r[e];return typeof s<"u"&&typeof n<"u"?t?s-n:n-s:0}}var f6=0;async function vd(e,t,i,r,s=!0,n,a){let o=null,l="requestid"+ ++f6;n&&n(l);let h={user_uuid:e,path:t,type:i};r!==void 0&&(h.bindTypes=r),a&&a(h);try{if($i.getInstance().hasLib(e))return await p6(e,i,s);let d=await nt("GET",rt.TAG.LIST,h,{headers:{path:t},searchParams:!0});if(d.success)return{...d,result:await Nm(d.result,s)}}catch(d){o=d,console.error("Fetch Category List Error",d)}let c=o?o.msg||o.message:void 0;return{code:o?o.code:He.ERR_CODE.NORMAL,success:!1,result:null,msg:c||"Fetch Category List Error"}}async function p6(e,t,i){var r;let s=[];for(let n of t){let a=await((r=$i.getInstance().getLib(e))==null?void 0:r.getCategoryTreeDataItemsByCategoryType(n));a&&s.push(a)}return{code:0,success:!0,result:await Nm(s.flat().map(n=>({uuid:n.id,parent_uuid:n.parentId,user_uuid:e,type:void 0,order_no:void 0,name_cn:void 0,name:n.title,created_at:n.created_at,updated_at:n.updated_at,title:n.title})),i)}}async function g6(e=!0){let t=null;try{let r=await nt("POST",rt.TAG.DEVICE_CATE);if(r.success)return{...r,result:await Nm(r.result,e)}}catch(r){t=r,console.error("Fetch Category List Error",r)}let i=t?t.msg||t.message:void 0;return{code:t?t.code:He.ERR_CODE.NORMAL,success:!1,result:null,msg:i||"Fetch Category List Error"}}async function Nm(e,t=!0){let i=[],r=[],s=[],n={},a={};e.forEach(d=>{d.name&&(a[d.name]=d.name_cn||d.name)});let o=e.filter(d=>!d.parent_uuid),l=e.filter(d=>!!d.parent_uuid),h=[],c={};if(o.forEach((d,f)=>{h.push(d.uuid),s.push({name:d.name,name_cn:d.name_cn,title:d.name,titleAdditional:d.name_cn||d.name,disableTranslate:d.name_cn===""?!0:d.name_cn===d.name,id:d.uuid,children:[],order_no:+d.order_no||0,parentId:void 0,created_at:d.created_at,updated_at:d.updated_at}),n[d.uuid]=f}),l.forEach(d=>{h.push(d.uuid);let f=n[d.parent_uuid];if(typeof f<"u"&&s[f]){let u=s[f];u.children.push({name:d.name,name_cn:d.name_cn,title:d.name,titleAdditional:d.name_cn||d.name,disableTranslate:d.name_cn===""?!0:d.name_cn===d.name,id:d.uuid,order_no:+d.order_no||0,children:[],parentId:u.id,created_at:d.created_at,updated_at:d.updated_at})}c[d.uuid]=d.parent_uuid}),s.sort(mv("order_no")),s.forEach(d=>{d.children.length>1&&d.children.sort(mv("order_no"))}),s.forEach(d=>{i.push({...d})}),t){let d=(await Xe.messageBus.rpcCall("I18nTranslateService",{str:He.CATEGORY_ITEM_ALL_TITLE})).message;i.unshift({title:He.CATEGORY_ITEM_ALL_TITLE,titleAdditional:d||He.CATEGORY_ITEM_ALL_TITLE,id:He.CATEGORY_ITEM_ALL_VALUE,order_no:Number.MAX_SAFE_INTEGER,disableTranslate:!1,children:[],parentId:void 0}),r.push(He.CATEGORY_ITEM_ALL_VALUE)}return{languageHashtable:a,treeData:i,selectedIds:r,categoryIds:h,childCategory2ParentCategoryMap:c,sourceCategoryList:e}}async function Ml(e){let{categories:t,type:i,uuid:r}=e,s=await vd(r,r,i),n=s.result?s.result.treeData:[],a=[],o=[],l=[],h=[];for(let p=0;p<t.length;p++){let{parentName:g,childName:_,parent_order_no:y,child_order_no:m}=t[p];if(g){let O=_s(n,"title",g);if(O.index>=0){if(a.push({name:O.data.title,type:i,user_uuid:r,order_no:O.data.order_no,parent_uuid:void 0,uuid:O.data.id}),_){let E=_s(O.data.children,"title",_);if(E.index>=0){o.push({name:E.data.title,type:i,user_uuid:r,order_no:E.data.order_no,parent_uuid:O.data.id,uuid:E.data.id});continue}h.push({name:_,type:i,user_uuid:r,order_no:p+1,parent_uuid:O.data.id,uuid:void 0});continue}continue}let b=sd(),v=sd();l.push({name:g,type:i,user_uuid:r,order_no:typeof y<"u"?y:p+1,parent_uuid:void 0,uuid:b}),_&&h.push({name:_,type:i,user_uuid:r,order_no:typeof m<"u"?m:p+1,parent_uuid:b,uuid:v})}}let c=[];if(l.length){let p=await Qh(l,(g,_)=>{l[_].__remoteId=g.result.uuid});c=p.result?p.result.successList.map(g=>g.result):[]}let d=[];if(h.length){for(let g=0;g<h.length;g++){let _=_s(l,"uuid",h[g].parent_uuid);_.index>=0&&_.data.__remoteId&&(h[g].parent_uuid=_.data.__remoteId)}let p=await Qh(h);d=p.result?p.result.successList.map(g=>g.result):[]}let f=c.concat(a),u=d.concat(o);return{allParentCreated:f,allChildCreated:u}}async function Mm(e){let{uuid:t,path:i,types:r,names:s}=e;return new Promise(async(n,a)=>{let o=await vd(t,i,r,void 0,!1);if(o.code!==0){n({...o,code:He.ERR_CODE.NORMAL,success:!1,result:null});return}let l={detail:[],arguments:e},{treeData:h}=o.result;for(let c=0;c<s.length;c++){let d=s[c].primary,f=s[c].secondary,u={primary:{name:d,name_cn:"",uuid:"",exist:!1,undefine:!1},secondary:{name:f,name_cn:"",uuid:"",exist:!1,undefine:!1}};if(typeof d>"u"){u.primary.exist=!1,u.primary.undefine=!0;continue}let p=_s(h,"title",d);if(p.index<=-1){u.primary.exist=!1,u.secondary.exist=!1,l.detail.push(u);continue}if(u.primary.exist=!0,u.primary.uuid=p.data.id,u.primary.name_cn=p.data.titleAdditional||d,typeof f>"u"){u.secondary.exist=!1,u.secondary.undefine=!0,l.detail.push(u);continue}let g=_s(p.data.children,"title",f);if(g.index<=-1){u.secondary.exist=!1,l.detail.push(u);continue}u.secondary.exist=!0,u.secondary.uuid=g.data.id,u.secondary.name_cn=g.data.titleAdditional||f,l.detail.push(u)}n({code:0,success:!0,result:l})})}function _6(e){let t=new Map,i=[];for(let r of e)(!t.has(r.primary)||t.get(r.primary)!==r.secondary)&&(t.set(r.primary,r.secondary),i.push(r));return i}async function $E(e){try{let{uuid:t,path:i,types:r,names:s}=e,n={primary:s[0],secondary:s[1]},a=await Mm({uuid:t,path:i,types:r,names:[n]});if(!a.success)return{success:!1,code:a.code,message:a.message,result:null};let o=[],{detail:l}=a.result;if(l[0]){let{primary:h,secondary:c}=l[0];h!=null&&h.uuid&&o.push(h==null?void 0:h.uuid),c!=null&&c.uuid&&o.push(c==null?void 0:c.uuid)}return{success:!0,code:0,result:o}}catch(t){return{success:!1,code:He.ERR_CODE.NORMAL,message:t.message,result:null}}}async function O6(e,t,i,r=!1){let s=await Mm(e),n=[],a=[],o=[],l=[],h=[];if(!r&&s.success&&s.result.detail.length){let d=new Map,f=new Map,u=new Map;s.result.detail.forEach((p,g)=>{(p.primary.name||p.primary.name_cn)&&!p.primary.exist&&!d.has(p.primary.name||p.primary.name_cn)&&(d.set(p.primary.name||p.primary.name_cn,!0),n.push({name:p.primary.name||p.primary.name_cn,type:t,user_uuid:i,order_no:0})),(p.primary.name||p.primary.name_cn)&&!p.primary.exist&&(p.secondary.name||p.secondary.name_cn)&&!p.secondary.exist&&f.get(p.secondary.name||p.secondary.name_cn)!==(p.primary.name||p.primary.name_cn)?(f.set(p.secondary.name||p.secondary.name_cn,p.primary.name||p.primary.name_cn),a.push({name:p.secondary.name||p.secondary.name_cn,type:t,user_uuid:i,uuid:p.secondary.uuid,order_no:0,parent_uuid:p.primary.uuid,parent_title:p.primary.name||p.primary.name_cn})):p.primary.exist&&(p.secondary.name||p.secondary.name_cn)&&!p.secondary.exist&&f.get(p.secondary.name||p.secondary.name_cn)!==(p.primary.name||p.primary.name_cn)&&(f.set(p.secondary.name||p.secondary.name_cn,p.primary.name||p.primary.name_cn),a.push({name:p.secondary.name||p.secondary.name_cn,type:t,user_uuid:i,uuid:p.secondary.uuid,order_no:0,parent_uuid:p.primary.uuid,parent_title:p.primary.name||p.primary.name_cn})),p.primary.exist&&!u.has(p.primary.uuid)&&(u.set(p.primary.uuid,p.primary.name||p.primary.name_cn),h.push({title:p.primary.name||p.primary.name_cn,uuid:p.primary.uuid,parent_uuid:""})),p.secondary.exist&&!u.has(p.secondary.uuid)&&(u.set(p.secondary.uuid,p.secondary.name||p.secondary.name_cn),h.push({title:p.secondary.name||p.secondary.name_cn,uuid:p.secondary.uuid,parent_uuid:p.primary.uuid}))})}if(!r&&n.length){let d=await Qh(n);if(d.success&&d.result.successList.length&&(o=d.result.successList.map(f=>f.result),a.forEach(f=>{o.forEach(u=>{!f.parent_uuid&&f.parent_title===u.name&&(f.parent_uuid=u.uuid)})})),a.length){let f=await Qh(a);f.success&&f.result.successList.length&&(l=f.result.successList.map(u=>u.result))}}else if(!r&&a.length){let d=await Qh(a);d.success&&d.result.successList.length&&(l=d.result.successList.map(f=>f.result))}let c=[];return c=o.map(d=>({uuid:d.uuid,title:d.name,name:d.name,parent_uuid:d.parent_uuid})),c=c.concat(l.map(d=>({uuid:d.uuid,parent_uuid:d.parent_uuid,title:d.name,name:d.name}))),c=c.concat(h),c}async function m6(e,t){let i=[],r=[],s=async o=>{let{message:l}=await Xe.messageBus.rpcCall(Ja.TAG.DELETE,o);return l},n=null;try{for(let o=0;o<e.length;o++){let l=await s({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let c={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(c),t&&t(c,o);continue}let h={...l,result:{...e[o]}};r.push(h)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){n=o}let a=n?n.msg||n.message:"Del Categories Batch Error";return{code:n?n.code:He.ERR_CODE.NORMAL,success:!1,result:null,message:a}}async function b6(e){let{uuid:t,path:i,types:r,ids:s}=e;return new Promise(async(n,a)=>{let o=await vd(t,i,r,void 0,!1);if(o.code!==0){n({...o,code:He.ERR_CODE.NORMAL,success:!1,result:null});return}let l={detail:[],arguments:e},{treeData:h}=o.result;for(let c=0;c<s.length;c++){let d=s[c].primary,f=s[c].secondary,u={primary:{name:"",name_cn:"string",uuid:d,exist:!1,undefine:!1},secondary:{name:"",name_cn:"string",uuid:f,exist:!1,undefine:!1}};if(typeof d>"u"){u.primary.exist=!1,u.primary.undefine=!0;continue}let p=_s(h,"id",d);if(p.index<=-1){u.primary.exist=!1,u.secondary.exist=!1,l.detail.push(u);continue}if(u.primary.exist=!0,u.primary.name=p.data.title,u.primary.name_cn=p.data.titleAdditional||u.primary.name,typeof f>"u"){u.secondary.exist=!1,u.secondary.undefine=!0;continue}let g=_s(p.data.children,"id",f);if(g.index<=-1){u.secondary.exist=!1,l.detail.push(u);continue}u.secondary.exist=!0,u.secondary.name=g.data.title,u.secondary.name_cn=g.data.titleAdditional||u.secondary.name,l.detail.push(u)}n({code:0,success:!0,result:l})})}var y6=class{constructor(){this._actuatorMap=new Map}clearAll(){this._actuatorMap.clear()}async addActuator(e,t,i,r){let s=e.filter(d=>!!d),n=`${s[0]}_${t[0]||0}_${i}_${r}`,a=`${s[0]}_${s[1]}_${t[1]||t[0]||0}_${i}_${r}`;if(!s[1]){if(this._actuatorMap.has(n))return this._actuatorMap.get(n);let d=new Promise(async(f,u)=>{let p=await Ml({categories:[{parentName:s[0],parent_order_no:t[0]||0}],type:[r],uuid:i});f({uuids:p.allParentCreated.map(g=>g.uuid),titles:p.allParentCreated.map(g=>g.name)}),this._actuatorMap.delete(n)});return this._actuatorMap.set(n,d),d}let o=this._actuatorMap.get(n);o||(o=new Promise(async(d,f)=>{let u=await Ml({categories:[{parentName:s[0],parent_order_no:t[0]||0}],type:[r],uuid:i});d({uuids:u.allParentCreated.map(p=>p.uuid),titles:u.allParentCreated.map(p=>p.name)}),this._actuatorMap.delete(n)}),this._actuatorMap.set(n,o));let l=await o,h=this._actuatorMap.get(a);h||(h=new Promise(async(d,f)=>{let u=await Ml({categories:[{parentName:s[0],childName:s[1],parent_order_no:t[0]||0,child_order_no:t[1]||t[0]||0}],type:[r],uuid:i});d({uuids:u.allChildCreated.map(p=>p.uuid),titles:u.allChildCreated.map(p=>p.name)}),this._actuatorMap.delete(a)}),this._actuatorMap.set(a,h));let c=await h;return{uuids:[l.uuids[0],c.uuids[0]],titles:[l.titles[0],c.titles[0]]}}};async function v6(e,t){let i=[],r=[],s=async o=>{let{message:l}=await Xe.messageBus.rpcCall(Ja.TAG.UPDATE,o);return l},n=null;try{for(let o=0;o<e.length;o++){let l=await s({...e[o],path:e[o].user_uuid});if(l.code===0&&l.success){let c={...l,message:"",result:{...e[o],path:e[o].user_uuid,...l.result[0]}};i.push(c),t&&t(c,o);continue}let h={...l,result:{...e[o]}};r.push(h)}return{code:0,success:!0,result:{successList:i,failList:r},message:""}}catch(o){n=o}let a=n?n.msg||n.message:"Update Categories Batch Error";return{code:n?n.code:He.ERR_CODE.NORMAL,success:!1,result:null,message:a}}var yr=class{};yr.categoryAddtition=new y6,yr.fetchCategoryList=vd,yr.fetchInternalCategoryList=g6,yr.addCategoriesBatch=Qh,yr.deleteCategoriesBatch=m6,yr.updateCategoriesBatch=v6,yr.addCategoriesBatchByNameArray=Ml,yr.queryCategoryBatchByNames=Mm,yr.queryCategoryBatchByIds=b6,yr.formatRepeatCategoryArr=_6,yr.bindAndCreateCategory=O6,yr.getCategoryNamesByTags=$a;async function $a(e,t,i){if(!e)return[];if(e instanceof Array)return e;let r=qo(e);if(r=r.filter(h=>!!h),!r.length)return[];let s=(await Xe.messageBus.rpcCall("LocaleCurrFetch",{})).message||"en",n=await vd(t,t,i),a=n.result?n.result.sourceCategoryList:[],o=typeof r[1]<"u",l=[];for(let h=0;h<a.length;h++)if(a[h].name===r[0]||a[h].name_cn===r[0]){l.push(s=="en"?a[h].name:a[h].name_cn||a[h].name);break}if(o){for(let h=0;h<a.length;h++)if(a[h].name===r[1]||a[h].name_cn===r[1]){l.push(s=="en"?a[h].name:a[h].name_cn||a[h].name);break}}return l}async function QE(e,t,i){let r=null,s=null,n=[],a=[],o=!1,l,h;if(e)if("data"in e)r=e.data,r.tags&&(r.tags instanceof Array?a=r.tags:a=qo(r.tags));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing 3d-model uuid or path data.");l=e.uuid,h=e.path,s=await gi.getD3Model({isProject:e.isProject,uuid:e.uuid,path:e.path}),s&&(s.title=s.display_title,a=await $a(s.tags,e.path,[5]))}if(!i){let c=await yr.categoryAddtition.addActuator(a,[0],t,5);n=c.uuids,a=c.titles}return{d3modelItemOriginUuid:l,d3modelItemOriginPath:h,d3modelItemIn:r,d3modelItemOut:s,d3modelTagIds:n,d3modelTagTitles:a}}function lc(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function x6(e){return Array.isArray(e)?e:e?[e]:[]}function hc(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function cc(e){return e?{uuid:e.uuid,nickname:e.nickname,username:e.username}:{}}function e3(e,t){return{title:t.title,description:t.description,images:x6(t.images),attributes:t.attributes,uuid:t.uuid,path:rc(t)||e,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner),symbol_type:t.symbol_type}}function Wo(e,t){return{...e3(e,t),isFavorite:t.isFavorite,tags:t.tags,produce_code:t.produce_code}}function Tp(e,t){return{...e3(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function t3(e,t){return{title:t.title,description:t.description,docType:t.docType,path:rc(t)||e,uuid:t.uuid,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner)}}function Oa(e,t){return{...t3(e,t),tags:t.tags,has_device:t.has_device,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:t.dataStr,isFavorite:t.isFavorite}}function L0(e,t){return{...t3(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}function i3(e,t){return{title:t.title,description:t.description,docType:t.docType,uuid:t.uuid,path:rc(t)||e,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner)}}function ma(e,t){return{...i3(e,t),tags:t.tags,has_device:t.has_device,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:t.dataStr,isFavorite:t.isFavorite}}function D0(e,t){return{...i3(e,t),custom_tags:t.custom_tags,source:t.source,version:t.version}}async function uc(e,t){return{title:t.title,description:t.description,path:rc(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner),tags:t.tags,dataStrId:t.dataStrId,dataStr:await Od(t)}}function jl(e,t){return{title:t.title,description:t.description,path:rc(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner),tags:t.tags,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStr:t.dataStr,dataStrId:t.dataStrId,isFavorite:t.isFavorite}}async function Vl(e,t){return{title:t.title,path:rc(t)||e,docType:t.docType,uuid:t.uuid,ticket:t.ticket,updateTime:is(t.updateTime),createTime:is(t.createTime),display_title:t.display_title,creator:lc(t.creator),modifier:hc(t.modifier),owner:cc(t.owner),tags:t.tags,history_uuid:t.history_uuid,key:t.key,iv:t.iv,dataStrId:t.dataStrId,dataStr:await Od(t)}}async function E6(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:s}=await QE(e.d3model,e.path,e.isProject),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing 3d-model data.");ZE(n.title),"path"in e.d3model&&e.d3model.override&&jr(n,e.d3model.override);let a=await nt("POST",rt.COMPONENT.CREATE,{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;return await uc(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("D3MODEL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("CREATE_D3MODEL_PERMISSIONS",o):new re("CREATE_D3MODEL",o)}async function tg(e=!1,t,i,r,s,n){let a=t.toLocaleLowerCase(),o=n?!!n.forceAsSymbol:!1,l=[];try{if(o||r&&[2,18,19,20,21,22,25,31,7,32,6].indexOf(r)>=0){let h={isProject:e,path:i,titles:[a],docType:r};l=(await gi.getSymbolSearchList(h))[a]||[]}if(r===28){let h={isProject:e,path:i,titles:[a]};l=(await gi.getDeviceSearchList(h))[a]||[]}if(r===4){let h={isProject:e,path:i,titles:[a]};l=(await gi.getFootprintSearchList(h))[a]||[]}return r===16&&(l=(await gi.getD3ModelSearchList({isProject:e,uid:i,path:i,page:1,pageSize:void 0,wd:a})).lists),{code:0,success:!0,result:l,message:""}}catch(h){return console.error(h),{code:-1,success:!1,result:[],message:h instanceof re?`${String(h.action)}|${String(h.message)}`:h.message||"QueryComponentsByTitle call error."}}}function bv(e,t){return e.path==t}function yv(e){try{let t=JSON.parse(e);return{parentName:t[0],childName:t[1]}}catch{return{parentName:"",childName:""}}}function w6(e){let t={};return t["device-owner"]=e.userIdSelected,t["device-lib"]=e.userIdSelected,t["footprint-name"]=e.footprintItem?e.footprintItem.display_title:"",t["symbol-name"]=e.symbolItem?e.symbolItem.display_title:"",t["new-symbol"]=e.isNeedCreateSymbolAndAssocia,t}function r3(e,t){typeof e.footprintItemId<"u"&&(t.Footprint=e.footprintItemId),typeof e.symbolItemId<"u"&&(t.Symbol=e.symbolItemId)}async function s3(e,t){let i=w6(e),r=e.footprintItem,s=e.symbolItem,n={},a=async(O,b)=>{let v="",E="",T=!1,P=t==="zh-hans",A=O.parent_tag,C=O.child_tag;if(A&&A.uuid&&(T=!0,v=P&&A.name_cn||A.name),T&&C&&C.uuid){let M=P&&C.name_cn||C.name;v+=`:${M}`}if(v){let M=v.split(":")[0],H=v.split(":")[1],k=await Ml({categories:H?[{parentName:M,childName:H}]:[{parentName:M}],type:[+b],uuid:i["device-owner"]}),F=k.allParentCreated[0]?k.allParentCreated[0].uuid:void 0,j=k.allChildCreated[0]?k.allChildCreated[0].uuid:void 0;F&&(E=j?[F,j]:[F])}return E},o={"file-owner":i["device-owner"],"file-name":i["footprint-name"],"file-describe":"","file-category":await a((r==null?void 0:r.tags)||{},4),"file-lib":i["device-lib"],"file-customTags":[]};if(r&&r!=null&&r.custom_tags&&!(o!=null&&o["file-category"])){let{parentName:O,childName:b}=yv(r.custom_tags);if(O){let v=await Ml({categories:b?[{parentName:O,childName:b}]:[{parentName:O}],type:[4],uuid:i["device-owner"]}),E=v.allParentCreated[0]?v.allParentCreated[0].uuid:void 0,T=v.allChildCreated[0]?v.allChildCreated[0].uuid:void 0;E&&(o["file-customTags"]=T?[E,T]:[E])}}let l={"file-owner":i["device-owner"],"file-name":i["symbol-name"],"file-describe":"","file-category":await a((s==null?void 0:s.tags)||{},2),"file-lib":i["device-lib"],"file-customTags":[]};if(s&&s!=null&&s.custom_tags&&!l["file-category"]){let{parentName:O,childName:b}=yv(s.custom_tags);if(O){let v=await Ml({categories:b?[{parentName:O,childName:b}]:[{parentName:O}],type:[4],uuid:i["device-owner"]}),E=v.allParentCreated[0]?v.allParentCreated[0].uuid:void 0,T=v.allChildCreated[0]?v.allChildCreated[0].uuid:void 0;E&&(l["file-customTags"]=T?[E,T]:[E])}}let h,c,d,f,u=!1,p=!1,g=!1;async function _(){if(i["footprint-name"])if(bv(r,i["device-owner"]||i["device-lib"]))d=r,h=null;else{let O=await tg(!1,o["file-name"],i["device-lib"],4);O.result.length<=0||(p=!0,d=r,h=O.result)}else d=null,h=null}async function y(){if(!i["new-symbol"]&&i["symbol-name"]&&s)if(bv(s,i["device-owner"]||i["device-lib"]))f=s,c=null;else{let O=await tg(!1,l["file-name"],i["device-lib"],s.docType);O.result.length<=0||(u=!0,c=O.result,f=s)}else f=null,c=null}await _(),await y();let m={isNeedConfirm:!1,updateCache:n,formData:i,newFootPrint:h,oldFootPrint:d,newSymbol:c,oldSymbol:f,confirmRes:e};return!u&&!p&&!g?(m.isNeedConfirm=!1,m):(m.isNeedConfirm=!0,m)}async function Bm(e,t,i,r){let s=null,n=null,a=[],o=[],l=!1,h,c;if(e)if("data"in e)e.data&&(s=e.data,s.tags&&(s.tags instanceof Array?o=s.tags:o=qo(s.tags)));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing footprint uuid or path data.");h=e.uuid,c=e.path,n=await gi.getFootprint({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,r&&Array.isArray(r)?o=r:o=await $a(n.tags,e.path,[4]))}if(!i){let d=await yr.categoryAddtition.addActuator(o,[0],t,4);a=d.uuids,o=d.titles}return{footprintItemOriginUuid:h,footprintItemOriginPath:c,footprintItemIn:s,footprintItemOut:n,footprintTagIds:a,footprintTagTitles:o}}async function km(e,t,i,r){let s=null,n=null,a=[],o=[],l=!1,h,c;if(e)if("data"in e)e.data&&(s=e.data,s.tags&&(s.tags instanceof Array?o=s.tags:o=qo(s.tags)));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing symbol uuid or path data.");h=e.uuid,c=e.path,n=await gi.getSymbol({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,r&&Array.isArray(r)?o=r:o=await $a(n.tags,e.path,[2])),l=e.isProject}if(!i){let d=await yr.categoryAddtition.addActuator(o,[0],t,2);a=d.uuids,o=d.titles}return{symbolItemOriginUuid:h,symbolItemOriginPath:c,symbolItemIn:s,symbolItemOut:n,symbolTagIds:a,symbolTagTitles:o}}async function n3(e,t,i,r){let s=null,n=null,a=[],o=[],l=!1;if(e)if("data"in e)e.data&&(s=e.data,s.tags&&(s.tags instanceof Array?o=s.tags:o=qo(s.tags)));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing device uuid or path data.");n=await gi.getDevice({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,r&&Array.isArray(r)?o=r:o=await $a(n.tags,e.path,[3])),l=e.isProject}if(!i){let h=await yr.categoryAddtition.addActuator(o,[0],t,3);a=h.uuids,o=h.titles}return{deviceItemIn:s,deviceItemOut:n,deviceTagIds:a,deviceTagTitles:o,isDeviceFromProject:l}}async function a3(e,t,i,r,s,n){let a=null,o=null,l=[],h=[],c,d;if(e){let{symbolItemIn:f,symbolItemOut:u,symbolTagIds:p,symbolTagTitles:g,symbolItemOriginUuid:_,symbolItemOriginPath:y}=await km(e,i,r,"path"in e&&e.override&&Array.isArray(e.override.tags)?e.override.tags:void 0);a=f,o=u,l=p,h=g,c=_,d=y}else if(s)if(n){let f=await gi.getSymbol({isProject:t,uuid:s,path:n});if(c=s,d=n,f){f.title=f.display_title,o=f,h=await $a(f.tags,n,[2]);let u=await yr.categoryAddtition.addActuator(h,[0],i,2);l=u.uuids,h=u.titles}}else{let f=null;try{f=await gi.getSymbol({isProject:t,uuid:s,path:i}),c=s,d=i}catch(u){f=null,c=s,d=i,console.warn(u)}f||console.warn("[NOSYMBOL_ON_TARGETPATH_BY_DEVICE_BOUND]: the symbol bound to this device does not exist in the target library.")}return{symbolItemOriginUuid:c,symbolItemOriginPath:d,symbolItemIn:a,symbolItemOut:o,symbolTagIds:l,symbolTagTitles:h}}async function o3(e,t,i,r,s,n){let a=null,o=null,l=[],h=[],c,d;if(e){let{footprintItemIn:f,footprintItemOut:u,footprintTagIds:p,footprintTagTitles:g,footprintItemOriginUuid:_,footprintItemOriginPath:y}=await Bm(e,i,r,"path"in e&&e.override&&Array.isArray(e.override.tags)?e.override.tags:void 0);a=f,o=u,l=p,h=g,c=_,d=y}else if(s)if(n){let f=await gi.getFootprint({isProject:t,uuid:s,path:n});if(c=s,d=n,f){f.title=f.display_title,o=f,h=await $a(f.tags,n,[4]);let u=await yr.categoryAddtition.addActuator(h,[0],i,4);l=u.uuids,h=u.titles}}else{let f=null;try{f=await gi.getFootprint({isProject:t,uuid:s,path:i}),c=s,d=i}catch(u){f=null,c=s,d=i,console.warn(u)}f||console.warn("[NOFOOTPRINT_ON_TARGETPATH_BY_DEVICE_BOUND]: the footprint bound to this device does not exist in the target library.")}return{footprintItemOriginUuid:c,footprintItemOriginPath:d,footprintItemIn:a,footprintItemOut:o,footprintTagIds:l,footprintTagTitles:h}}async function l3(e,t,i,r,s,n){if(!r)return;let a=null;if("data"in r)s.title&&(a=await gi.createSymbol({isProject:e,path:t,symbol:{data:{...s,tags:n},ignoreDuplicateNameCheck:r.ignoreDuplicateNameCheck}})),i.attributes&&a&&typeof a=="object"&&(i.attributes.Symbol=a.uuid);else{r.override&&jr(s,r.override);try{a=await gi.getSymbol({isProject:e,path:t,uuid:r.uuid})}catch{a=null}if(a&&typeof a=="object")i.attributes&&(i.attributes.Symbol=a.uuid);else if(s.title&&(a=await gi.createSymbol({isProject:e,path:t,symbol:{data:{...s,tags:n},ignoreDuplicateNameCheck:r.ignoreDuplicateNameCheck}})),i.attributes&&a&&typeof a=="object"){i.attributes.Symbol=a.uuid;let o=await Yo({origin:{docType:s.docType,isProject:r.isProject,uuid:r.uuid,path:r.path},target:{docType:a.docType,isProject:e,uuid:a.uuid,path:a.path}});if(!o.success)throw new re("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function h3(e,t,i,r,s,n){if(!r)return;let a=null;if("data"in r)s.title&&(a=await gi.createFootprint({isProject:e,path:t,footprint:{data:{...s,tags:n}}})),i.attributes&&a&&typeof a=="object"&&(i.attributes.Footprint=a.uuid);else{r.override&&jr(s,r.override);try{a=await gi.getFootprint({isProject:e,path:t,uuid:r.uuid})}catch{a=null}if(a&&typeof a=="object")i.attributes&&(i.attributes.Footprint=a.uuid);else if(s.title&&(a=await gi.createFootprint({isProject:e,path:t,footprint:{data:{...s,tags:n}}})),i.attributes&&a&&typeof a=="object"){i.attributes.Footprint=a.uuid;let o=await Yo({origin:{docType:s.docType,isProject:r.isProject,uuid:r.uuid,path:r.path},target:{docType:a.docType,isProject:e,uuid:a.uuid,path:a.path}});if(!o.success)throw new re("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",o.message||"migrate canvas error.")}}}async function T6(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:s,isDeviceFromProject:n}=await n3(e.device,e.path,e.isProject,"path"in e.device&&e.device.override&&Array.isArray(e.device.override.tags)?e.device.override.tags:void 0),a=t||i;if(!a)throw new re("PARAMETER_VERIFICATION","missing device data.");a.title=e.device&&"path"in e.device&&e.device.override&&yd(e.device.override,"title")||a.title,qE(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:h,symbolTagTitles:c,symbolItemOriginUuid:d,symbolItemOriginPath:f}=await a3(e.symbol,n,e.path,e.isProject,a.attributes?a.attributes.Symbol:void 0,"data"in e.device?void 0:e.device.path),u=o||l,p=!!(e.symbol&&"data"in e.symbol);a.attributes&&l&&typeof l=="object"&&(a.attributes.Symbol=l.uuid),e.symbol&&"path"in e.symbol&&e.symbol.override&&jr(u,e.symbol.override);let{footprintItemIn:g,footprintItemOut:_,footprintTagIds:y,footprintTagTitles:m,footprintItemOriginUuid:O,footprintItemOriginPath:b}=await o3(e.footprint,n,e.path,e.isProject,a.attributes?a.attributes.Footprint:void 0,"data"in e.device?void 0:e.device.path),v=g||_;e.footprint&&"path"in e.footprint&&e.footprint.override&&jr(v,e.footprint.override),a.attributes&&_&&typeof _=="object"&&(a.attributes.Footprint=_.uuid);let E=!1,T=!1,P=await s3({symbolItem:u,footprintItem:v,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:p},void 0);if(P.isNeedConfirm){let M=(await Xe.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...P},31536e8)).message;if(!M){let H="an exception occurred while executing the cross-bind program.";throw new re("CROSS_BIND",H)}if(M.action==="cancel"||M.action==="close"){let H="quit operate while executing the cross-bind program.";throw new re("CROSS_BIND_EXIT",H)}P.updateCache=M.data,a.attributes&&Object.keys(P.updateCache).length&&(P.updateCache.symbolItemId&&(E=!0),P.updateCache.footprintItemId&&(T=!0),r3(P.updateCache,a.attributes))}!E&&u&&await l3(e.isProject,e.path,a,e.symbol,u,c),!T&&v&&await h3(e.isProject,e.path,a,e.footprint,v,m),"path"in e.device&&e.device.override&&(delete e.device.override.tags,jr(a,e.device.override));let A=await nt("POST",rt.DEVICE.CREATE,{...a,tags:r,owner:e.path,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(A.code===0&&A.success){let M=A.result;return Wo(e.path,M)}let C=A.message||A.msg||"Request Error.";throw On(A.code)?new re("DEVICE_SAME_NAMA_EXISTS",C):$s(A.code)?new re("CREATE_DEVICE_PERMISSIONS",C):new re("CREATE_DEVICE",C)}async function S6(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:s}=await Bm(e.footprint,e.path,e.isProject,"path"in e.footprint&&e.footprint.override&&Array.isArray(e.footprint.override.tags)?e.footprint.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing footprint data.");n.title="path"in e.footprint&&e.footprint.override&&yd(e.footprint.override,"title")||n.title,XE(n.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,jr(n,e.footprint.override));let a=await nt("POST",rt.COMPONENT.CREATE,{title:n.title,tags:r,docType:n.docType||4,description:n.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.footprint)&&e.footprint.uuid&&e.footprint.path){let h=await Yo({origin:{docType:n.docType,isProject:!!e.footprint.isProject,uuid:e.footprint.uuid,path:e.footprint.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!h.success)throw new re("CREATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return ma(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("FOOTPRINT_SAME_NAMA_EXISTS",o):$s(a.code)?new re("CREATE_FOOTPRINT_PERMISSIONS",o):new re("CREATE_FOOTPRINT",o)}async function c3(e,t,i,r){let s=null,n=null,a=[],o=[],l=!1,h,c;if(e)if("data"in e)s=e.data,s.tags&&(s.tags instanceof Array?o=s.tags:o=qo(s.tags));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing simModel uuid or path data.");h=e.uuid,c=e.path,n=await gi.getSimModel({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,r&&Array.isArray(r)?o=r:o=await $a(n.tags,e.path,[6]))}if(!i){let d=await yr.categoryAddtition.addActuator(o,[0],t,6);a=d.uuids,o=d.titles}return{simModelItemOriginUuid:h,simModelItemOriginPath:c,simModelItemIn:s,simModelItemOut:n,simModelTagIds:a,simModelTagTitles:o}}async function I6(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:s}=await c3(e.simModel,e.path,e.isProject,"path"in e.simModel&&e.simModel.override&&Array.isArray(e.simModel.override.tags)?e.simModel.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing sim-model data.");n.title="path"in e.simModel&&e.simModel.override&&yd(e.simModel.override,"title")||n.title,KE(n.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,jr(n,e.simModel.override));let a=await nt("POST",rt.COMPONENT.CREATE,{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;return await Vl(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("SIM_MODEL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("CREATE_SIM_MODEL_PERMISSIONS",o):new re("CREATE_SIM_MODEL",o)}async function P6(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:s}=await km(e.symbol,e.path,e.isProject,"path"in e.symbol&&e.symbol.override&&Array.isArray(e.symbol.override.tags)?e.symbol.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing symbol data.");n.title="path"in e.symbol&&e.symbol.override&&yd(e.symbol.override,"title")||n.title,WE(n.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,jr(n,e.symbol.override));let a=await nt("POST",rt.COMPONENT.CREATE,{title:n.title,tags:r,docType:n.docType,description:n.description,owner:e.path,ignoreDuplicateNameCheck:e.symbol.ignoreDuplicateNameCheck},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.symbol)&&e.symbol.uuid&&e.symbol.path){let h=await Yo({origin:{docType:n.docType,isProject:!!e.symbol.isProject,uuid:e.symbol.uuid,path:e.symbol.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!h.success)throw new re("CREATE_SYMBOL_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return Oa(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("SYMBOL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("CREATE_SYMBOL_PERMISSIONS",o):new re("CREATE_SYMBOL",o)}async function A6(e){let t=await nt("GET",ai(rt.DEVICE.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new re("GET_DEVICE_NOT_FOUND","data not found");return Wo(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new re("GET_DEVICE",i)}async function C6(e){let t=await nt("GET",ai(rt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new re("GET_FOOTPRINT_NOT_FOUND","data not found");return ma(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new re("GET_FOOTPRINT",i)}async function L6(e){let t=await nt("GET",ai(rt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;return await Vl(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new re("GET_SIM_MODEL",i)}function Fn(e={}){let t={},i=Object.keys(e);for(let r=0;r<i.length;r++)i[r]===""||String(i[r])==="undefined"||typeof e[i[r]]>"u"||e[i[r]]==null||(t[i[r]]=e[i[r]]);return t}async function D6(e){let t=await nt("GET",rt.COMPONENT.LIST,{...Fn(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:e.docType,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,s=[];for(let n of r.lists)s.push(await Vl(e.path,n));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:s}}let i=t.message||t.msg||"Request Error.";throw new re("GET_SIM_MODEL_LIST",i)}async function R6(e){let t=await nt("GET",ai(rt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new re("GET_SYMBOL_NOT_FOUND","data not found");return Oa(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new re("GET_SYMBOL",i)}async function N6(e){let{deviceItemIn:t,deviceItemOut:i,deviceTagIds:r,deviceTagTitles:s,isDeviceFromProject:n}=await n3(e.device,e.path,e.isProject,"path"in e.device&&e.device.override&&Array.isArray(e.device.override.tags)?e.device.override.tags:void 0),a=t||i;if(!a)throw new re("PARAMETER_VERIFICATION","missing device data.");a.title!==void 0&&qE(a.title);let{symbolItemIn:o,symbolItemOut:l,symbolTagIds:h,symbolTagTitles:c,symbolItemOriginUuid:d,symbolItemOriginPath:f}=await a3(e.symbol,n,e.path,e.isProject,a.attributes?a.attributes.Symbol:void 0,"data"in e.device?void 0:e.device.path),u=o||l,p=!!(e.symbol&&"data"in e.symbol);e.symbol&&"path"in e.symbol&&e.symbol.override&&jr(u,e.symbol.override),a.attributes&&l&&typeof l=="object"&&(a.attributes.Symbol=l.uuid);let{footprintItemIn:g,footprintItemOut:_,footprintTagIds:y,footprintTagTitles:m,footprintItemOriginUuid:O,footprintItemOriginPath:b}=await o3(e.footprint,n,e.path,e.isProject,a.attributes?a.attributes.Footprint:void 0,"data"in e.device?void 0:e.device.path),v=g||_;e.footprint&&"path"in e.footprint&&e.footprint.override&&jr(v,e.footprint.override),a.attributes&&_&&typeof _=="object"&&(a.attributes.Footprint=_.uuid);let E=!1,T=!1,P=await s3({symbolItem:u,footprintItem:v,userIdSelected:e.path,isNeedCreateSymbolAndAssocia:p},void 0);if(P.isNeedConfirm){let M=(await Xe.messageBus.rpcCall("OpenSameNameSaveAsDlgService",{...P},31536e8)).message;if(!M){let H="an exception occurred while executing the cross-bind program.";throw new re("CROSS_BIND",H)}if(M.action==="cancel"||M.action==="close"){let H="quit operate while executing the cross-bind program.";throw new re("CROSS_BIND_EXIT",H)}P.updateCache=M.data,a.attributes&&Object.keys(P.updateCache).length&&(P.updateCache.symbolItemId&&(E=!0),P.updateCache.footprintItemId&&(T=!0),r3(P.updateCache,a.attributes))}!E&&u&&await l3(e.isProject,e.path,a,e.symbol,u,c),!T&&v&&await h3(e.isProject,e.path,a,e.footprint,v,m),"path"in e.device&&e.device.override&&(delete e.device.override.tags,jr(a,e.device.override));let A=await nt("POST",ai(rt.DEVICE.UPDATE,{uuid:e.uuid}),{...a,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(A.code===0&&A.success&&A.result){let M=A.result;return Wo(e.path,M)}let C=A.message||A.msg||"Request Error.";throw On(A.code)?new re("DEVICE_SAME_NAMA_EXISTS",C):$s(A.code)?new re("CREATE_DEVICE_PERMISSIONS",C):new re("UPDATE_DEVICE",C)}async function M6(e){let{footprintItemIn:t,footprintItemOut:i,footprintTagIds:r,footprintTagTitles:s}=await Bm(e.footprint,e.path,e.isProject,"path"in e.footprint&&e.footprint.override&&Array.isArray(e.footprint.override.tags)?e.footprint.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing footprint data.");n.title!==void 0&&XE(n.title),"path"in e.footprint&&e.footprint.override&&(delete e.footprint.override.tags,jr(n,e.footprint.override));let a=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:n.title,tags:r,docType:n.docType||4,description:n.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.footprint)&&e.footprint.uuid&&e.footprint.path){let h=await Yo({origin:{docType:n.docType,isProject:e.footprint.isProject,uuid:e.footprint.uuid,path:e.footprint.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!h.success)throw new re("UPDATE_FOOTPRINT_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return ma(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("FOOTPRINT_SAME_NAMA_EXISTS",o):$s(a.code)?new re("UPDATE_FOOTPRINT_PERMISSIONS",o):new re("UPDATE_FOOTPRINT",o)}async function B6(e){let{simModelItemIn:t,simModelItemOut:i,simModelTagIds:r,simModelTagTitles:s}=await c3(e.simModel,e.path,e.isProject,"path"in e.simModel&&e.simModel.override&&Array.isArray(e.simModel.override.tags)?e.simModel.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing simModel data.");n.title!==void 0&&KE(n.title),"path"in e.simModel&&e.simModel.override&&(delete e.simModel.override.tags,jr(n,e.simModel.override));let a=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:e.uuid}),{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!a.success){let l=a.message||a.msg||"Request Error.";throw new re("UPDATE_SIM_MODEL",l)}if(n.dataStr){let l=await nt("POST",ai(rt.COMPONENT.UPDATE_CANVAS,{uuid:e.uuid}),{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!l.success){let h=l.message||l.msg||"Request Error.";throw new re("UPDATE_SIM_MODEL",h)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await Vl(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("SIM_MODEL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("UPDATE_SIM_MODEL_PERMISSIONS",o):new re("UPDATE_SYMBOL",o)}async function k6(e){let{symbolItemIn:t,symbolItemOut:i,symbolTagIds:r,symbolTagTitles:s}=await km(e.symbol,e.path,e.isProject,"path"in e.symbol&&e.symbol.override&&Array.isArray(e.symbol.override.tags)?e.symbol.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing symbol data.");n.title!==void 0&&WE(n.title),"path"in e.symbol&&e.symbol.override&&(delete e.symbol.override.tags,jr(n,e.symbol.override));let a=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:n.title,tags:r,docType:n.docType,description:n.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.symbol)&&e.symbol.uuid&&e.symbol.path){let h=await Yo({origin:{docType:n.docType,isProject:e.symbol.isProject,uuid:e.symbol.uuid,path:e.symbol.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!h.success)throw new re("UPDATE_SYMBOL_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return Oa(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("SYMBOL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("UPDATE_SYMBOL_PERMISSIONS",o):new re("UPDATE_SYMBOL",o)}async function F6(e){let t=await nt("GET",rt.COMPONENT.LIST,{...e.query||{},path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[16],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,s=[];for(let n of r.lists)s.push(await uc(e.path,n));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:s}}let i=t.message||t.msg||"Request Error.";throw new re("GET_D3MODEL_LIST",i)}async function U6(e){let t=await nt("GET",rt.COMPONENT.LIST,{...Fn(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[4],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,s=[];for(let n of r.lists)s.push(ma(e.path,n));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:s}}let i=t.message||t.msg||"Request Error.";throw new re("GET_FOOTPRINT_LIST",i)}async function G6(e){let t=await nt("GET",rt.COMPONENT.LIST,{...Fn(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:e.docType,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,s=[];for(let n of r.lists)s.push(Oa(e.path,n));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:s}}let i=t.message||t.msg||"Request Error.";throw new re("GET_SYMBOL_LIST",i)}async function z6(e){var t,i;let r=await nt("GET",rt.DEVICE.LIST,{...Fn(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(r.code===0&&r.success&&typeof r.result=="object"){let n=r.result,a=[];for(let o of n.lists){let l=Wo(e.path,o);e.withPackage&&(t=o.symbol_info)!=null&&t.uuid&&(l.symbol=Oa(e.path,o.symbol_info)),e.withPackage&&(i=o.footprint_info)!=null&&i.uuid&&(l.footprint=ma(e.path,o.footprint_info)),a.push(l)}return{count:n.count,page:n.page,pageSize:n.pageSize,totalPage:n.totalPage,lists:a}}let s=r.message||r.msg||"Request Error.";throw new re("GET_DEVICE_LIST",s)}async function H6(e){return e.titles?await j6(e):e.uuids?await V6(e):await Y6(e)}async function j6(e){var t,i;let{path:r,titles:s,user_uuids:n}=e,a=await nt("POST",rt.DEVICE.GET_BY_USER_AND_TITLE,{type:"device",titles:s,user_uuids:n||[r],path:r},{headers:{"Content-Type":"application/json",path:r}});if(a.code===0&&a.success&&a.result){let l={};for(let h in a.result){l[h]=[];let c=a.result[h];for(let d of c){let f=Wo(r,d);e.withPackage&&(t=d.symbol_info)!=null&&t.uuid&&(f.symbol=Oa(r,d.symbol_info)),e.withPackage&&(i=d.footprint_info)!=null&&i.uuid&&(f.footprint=ma(r,d.footprint_info)),l[h].push(f)}}return l}let o=a.message||a.msg||"Request Error.";throw new re("GET_DEVICE_SEARCH_LIST",o)}async function V6(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.DEVICE.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=Wo(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_DEVICE_SEARCH_UUIDS",s)}async function Y6(e){var t,i;let{path:r,query:s={},uid:n,page:a,pageSize:o,tags:l=[],wd:h}=e,c=await nt("POST",rt.DEVICE.SEARCH_LIST,{...Fn(s),path:r,uid:n,page:a,pageSize:o,tag:l,wd:h},{headers:{path:r},searchParams:!0});if(c.code===0&&c.success&&typeof c.result=="object"){let f=c.result,u=[],p=Object.keys(f.lists);for(let g=0;g<p.length;g++){let _=f.lists[p[g]];if(Array.isArray(_)&&_.length)for(let y=0;y<_.length;y++){let m=_[y],O=Wo(r,m);e.withPackage&&(t=m.symbol_info)!=null&&t.uuid&&(O.symbol=Oa(r,m.symbol_info)),e.withPackage&&(i=m.footprint_info)!=null&&i.uuid&&(O.footprint=ma(r,m.footprint_info)),u.push(O)}}return{count:f.count,page:f.page,pageSize:f.pageSize,totalPage:f.totalPage,lists:u,facets:f.facets}}let d=c.message||c.msg||"Request Error.";throw new re("GET_DEVICE_SEARCH_LIST",d)}async function q6(e){return e.titles?await W6(e):e.uuids?await X6(e):await J6(e)}async function W6(e){let{path:t,titles:i,docType:r,user_uuids:s}=e,n=await nt("POST",rt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:r,titles:i,user_uuids:s||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(n.code===0&&n.success&&n.result){let o={};for(let l in n.result){o[l]=[];let h=n.result[l];for(let c of h){let d=Oa(t,c);o[l].push(d)}}return o}let a=n.message||n.msg||"Request Error.";throw new re("GET_SYMBOL_SEARCH_LIST",a)}async function X6(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=Oa(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_SYMBOL_SEARCH_UUIDS",s)}async function J6(e){let{path:t,query:i,uid:r,page:s,pageSize:n,tags:a=[],wd:o,docType:l}=e,h=await nt("POST",rt.COMPONENT.SEARCH_LIST,{...Fn(i||{}),path:t,uid:r,page:s,pageSize:n,docType:l,tag:a,wd:o},{headers:{path:t},searchParams:!0});if(h.code===0&&h.success&&typeof h.result=="object"){let d=h.result,f=[],u=Object.keys(d.lists);for(let p=0;p<u.length;p++){let g=d.lists[u[p]];if(Array.isArray(g)&&g.length)for(let _=0;_<g.length;_++){let y=g[_],m=Oa(t,y);f.push(m)}}return{count:d.count,page:d.page,pageSize:d.pageSize,totalPage:d.totalPage,lists:f,facets:d.facets}}let c=h.message||h.msg||"Request Error.";throw new re("GET_SYMBOL_SEARCH_LIST",c)}async function Z6(e){return e.titles?await K6(e):e.uuids?await $6(e):await Q6(e)}async function K6(e){let{path:t,titles:i,user_uuids:r}=e,s=await nt("POST",rt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:4,titles:i,user_uuids:r||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(s.code===0&&s.success&&s.result){let a={};for(let o in s.result){a[o]=[];let l=s.result[o];for(let h of l){let c=ma(t,h);a[o].push(c)}}return a}let n=s.message||s.msg||"Request Error.";throw new re("GET_FOOTPRINT_SEARCH_LIST",n)}async function $6(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=ma(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_FOOTPRINT_SEARCH_UUIDS",s)}async function Q6(e){let{path:t,query:i={},uid:r,page:s,pageSize:n,tags:a=[],wd:o}=e,l=await nt("POST",rt.COMPONENT.SEARCH_LIST,{...Fn(i),path:t,uid:r,page:s,pageSize:n,docType:[4],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let c=l.result,d=[],f=Object.keys(c.lists);for(let u=0;u<f.length;u++){let p=c.lists[f[u]];if(Array.isArray(p)&&p.length)for(let g=0;g<p.length;g++){let _=p[g],y=ma(t,_);d.push(y)}}return{count:c.count,page:c.page,pageSize:c.pageSize,totalPage:c.totalPage,lists:d,facets:c.facets}}let h=l.message||l.msg||"Request Error.";throw new re("GET_FOOTPRINT_SEARCH_LIST",h)}async function eB(e){return e.titles?await tB(e):e.uuids?await iB(e):await rB(e)}async function tB(e){let{path:t,docType:i,titles:r}=e,s=await nt("POST",rt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:i,titles:r,user_uuids:[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(s.code===0&&s.success&&s.result){let a={};for(let o in s.result){a[o]=[];let l=s.result[o];for(let h of l){let c=await Vl(e.path,h);a[o].push(c)}}return a}let n=s.message||s.msg||"Request Error.";throw new re("GET_SIM_MODEL_SEARCH_LIST",n)}async function iB(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=await Vl(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_SIM_MODEL_SEARCH_UUIDS",s)}async function rB(e){let{path:t,query:i={},uid:r,page:s,pageSize:n,docType:a,tags:o=[],wd:l}=e,h=await nt("POST",rt.COMPONENT.SEARCH_LIST,{...Fn(i),path:t,uid:r,page:s,pageSize:n,docType:a,tag:o,wd:l},{headers:{path:t},searchParams:!0});if(h.code===0&&h.success&&typeof h.result=="object"){let d=h.result,f=[],u=Object.keys(d.lists);for(let p=0;p<u.length;p++){let g=d.lists[u[p]];if(Array.isArray(g)&&g.length)for(let _=0;_<g.length;_++){let y=g[_];f.push(await Vl(e.path,y))}}return{count:d.count,page:d.page,pageSize:d.pageSize,totalPage:d.totalPage,lists:f,facets:d.facets}}let c=h.message||h.msg||"Request Error.";throw new re("GET_SIM_MODEL_SEARCH_LIST",c)}async function sB(e){if(e.attributes.Symbol){let n=await gi.getSymbol({isProject:e.isProject,uuid:e.attributes.Symbol,path:e.path})}if(e.attributes.Footprint){let n=await gi.getFootprint({isProject:e.isProject,uuid:e.attributes.Footprint,path:e.path})}let t=await gi.getDevice({isProject:e.isProject,uuid:e.uuid,path:e.path}),i=Object.keys(e.attributes||{});for(let n=0;n<i.length;n++)t.attributes[i[n]]=e.attributes[i[n]];let r=await nt("POST",ai(rt.DEVICE.UPDATE,{uuid:e.uuid}),{...t,title:t.display_title||t.title,tags:t.tags?yE(t.tags):[],owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(r.code===0&&r.success&&r.result){let n=r.result;return Wo(e.path,n)}let s=r.message||r.msg||"Request Error.";throw $s(r.code)?new re("CREATE_DEVICE_PERMISSIONS",s):new re("UPDATE_DEVICE_ATTRIBUTES",s)}async function nB(e){return e.titles?await aB(e):e.uuids?await oB(e):await lB(e)}async function aB(e){let{path:t,titles:i,user_uuids:r}=e;if(Av||Zu&&t!==He.SYSTEMLIB_UUID){let s=await nt("POST",rt.CLIENT.FIND_3DMODEL,{titles:i},{headers:{"Content-Type":"application/json",path:t}});if(s.code===0&&s.success&&s.result){let a={};for(let o in s.result){a[o]=[];let l=s.result[o];for(let h of l){let c={fileName:h.fileName,path:h.path,lib:h.lib};a[o].push(c)}}return a}let n=s.message||s.msg||"Request Error.";throw new re("GET_D3MODEL_SEARCH_LIST",n)}else{let s=await nt("POST",rt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:16,titles:i,user_uuids:r||[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(s.code===0&&s.success&&s.result){let a={};for(let o in s.result){a[o]=[];let l=s.result[o];for(let h of l){let c=await uc(e.path,h);a[o].push(c)}}return a}let n=s.message||s.msg||"Request Error.";throw new re("GET_D3MODEL_SEARCH_LIST",n)}}async function oB(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=await uc(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_D3MODEL_SEARCH_UUIDS",s)}async function lB(e){let{path:t,query:i={},uid:r,page:s,pageSize:n,tags:a=[],wd:o}=e,l=await nt("POST",rt.COMPONENT.SEARCH_LIST,{...Fn(i),path:t,uid:r,page:s,pageSize:n,docType:[16],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let c=l.result,d=[],f=Object.keys(c.lists);for(let u=0;u<f.length;u++){let p=c.lists[f[u]];if(Array.isArray(p)&&p.length)for(let g=0;g<p.length;g++){let _=p[g];d.push(await uc(e.path,_))}}return{count:c.count,page:c.page,pageSize:c.pageSize,totalPage:c.totalPage,lists:d,facets:c.facets}}let h=l.message||l.msg||"Request Error.";throw new re("GET_D3MODEL_SEARCH_LIST",h)}async function hB(e){return e.titles?await cB(e):e.uuids?await uB(e):await dB(e)}async function cB(e){let{path:t,titles:i}=e,r=await nt("POST",rt.COMPONENT.GET_BY_USER_AND_TITLE,{docType:29,titles:i,user_uuids:[t],path:t},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n={};for(let a in r.result){n[a]=[];let o=r.result[a];for(let l of o){let h=jl(e.path,l);n[a].push(h)}}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_PANEL_LIB_SEARCH_LIST",s)}async function uB(e){let{path:t,uuids:i}=e,r=await nt("POST",rt.COMPONENT.BATCH_GET,{uuids:i},{headers:{"Content-Type":"application/json",path:t}});if(r.code===0&&r.success&&r.result){let n=[];for(let a of r.result){let o=jl(t,a);n.push(o)}return n}let s=r.message||r.msg||"Request Error.";throw new re("GET_PANEL_LIB_SEARCH_UUIDS",s)}async function dB(e){let{path:t,query:i={},uid:r,page:s,pageSize:n,tags:a=[],wd:o}=e,l=await nt("POST",rt.COMPONENT.SEARCH_LIST,{...Fn(i),path:t,uid:r,page:s,pageSize:n,docType:[29],tag:a,wd:o},{headers:{path:t},searchParams:!0});if(l.code===0&&l.success&&typeof l.result=="object"){let c=l.result,d=[],f=Object.keys(c.lists);for(let u=0;u<f.length;u++){let p=c.lists[f[u]];if(Array.isArray(p)&&p.length)for(let g=0;g<p.length;g++){let _=p[g];d.push(jl(e.path,_))}}return{count:c.count,page:c.page,pageSize:c.pageSize,totalPage:c.totalPage,lists:d,facets:c.facets}}let h=l.message||l.msg||"Request Error.";throw new re("GET_PANEL_LIB_SEARCH_LIST",h)}async function fB(e){let t=await nt("GET",ai(rt.COMPONENT.GET,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result;if(typeof r.path<"u"&&r.path!==e.path)throw new re("GET_PANEL_LIB_NOT_FOUND","data not found");return jl(e.path,r)}let i=t.message||t.msg||"Request Error.";throw new re("GET_PANEL_LIB",i)}async function u3(e,t,i,r){let s=null,n=null,a=[],o=[],l=!1,h,c;if(e)if("data"in e)s=e.data,s.tags&&(s.tags instanceof Array?o=s.tags:o=qo(s.tags));else{if(!e.uuid||!e.path)throw new re("PARAMETER_VERIFICATION","missing panelLib uuid or path data.");h=e.uuid,c=e.path,n=await gi.getPanelLib({isProject:e.isProject,uuid:e.uuid,path:e.path}),n&&(n.title=n.display_title,r&&Array.isArray(r)?o=r:o=await $a(n.tags,e.path,[29]))}if(!i){let d=await yr.categoryAddtition.addActuator(o,[0],t,29);a=d.uuids,o=d.titles}return{panelLibItemOriginUuid:h,panelLibItemOriginPath:c,panelLibItemIn:s,panelLibItemOut:n,panelLibTagIds:a,panelLibTagTitles:o}}async function pB(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:s}=await u3(e.panelLib,e.path,e.isProject,"path"in e.panelLib&&e.panelLib.override&&Array.isArray(e.panelLib.override.tags)?e.panelLib.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing panelLib data.");n.title="path"in e.panelLib&&e.panelLib.override&&yd(e.panelLib.override,"title")||n.title,JE(n.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,jr(n,e.panelLib.override));let a=await nt("POST",rt.COMPONENT.CREATE,{title:n.title,tags:r,docType:n.docType||29,description:n.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success){let l=a.result;if(!("data"in e.panelLib)&&e.panelLib.uuid&&e.panelLib.path){let h=await Yo({origin:{docType:n.docType,isProject:!!e.panelLib.isProject,uuid:e.panelLib.uuid,path:e.panelLib.path},target:{docType:l.docType,isProject:!1,uuid:l.uuid,path:l.path}});if(!h.success)throw new re("CREATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return jl(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("PANELLIB_SAME_NAMA_EXISTS",o):$s(a.code)?new re("CREATE_PANEL_LIB_PERMISSIONS",o):new re("CREATE_PANEL_LIB",o)}async function gB(e){let{panelLibItemIn:t,panelLibItemOut:i,panelLibTagIds:r,panelLibTagTitles:s}=await u3(e.panelLib,e.path,e.isProject,"path"in e.panelLib&&e.panelLib.override&&Array.isArray(e.panelLib.override.tags)?e.panelLib.override.tags:void 0),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing panelLib data.");n.title!==void 0&&JE(n.title),"path"in e.panelLib&&e.panelLib.override&&(delete e.panelLib.override.tags,jr(n,e.panelLib.override));let a=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:e.uuid}),{title:n.title,tags:r,docType:29,description:n.description,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;if(!("data"in e.panelLib)&&e.panelLib.uuid&&e.panelLib.path){let h=await Yo({origin:{docType:n.docType,isProject:e.panelLib.isProject,uuid:e.panelLib.uuid,path:e.panelLib.path},target:{docType:l.docType,isProject:e.isProject,uuid:e.uuid,path:e.path}});if(!h.success)throw new re("UPDATE_PANEL_LIB_MIGRATE_CANVAS_ERROR",h.message||"migrate canvas error.")}return jl(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("PANELLIB_SAME_NAMA_EXISTS",o):$s(a.code)?new re("UPDATE_PANEL_LIB_PERMISSIONS",o):new re("UPDATE_PANEL_LIB",o)}async function _B(e){let t=await nt("GET",rt.COMPONENT.LIST,{...Fn(e.query||{}),path:e.path,uid:e.uid,page:e.page,pageSize:e.pageSize,docType:[29],tag:e.tags||[]},{headers:{path:e.path},searchParams:!0});if(t.code===0&&t.success&&typeof t.result=="object"){let r=t.result,s=[];for(let n of r.lists)s.push(jl(e.path,n));return{count:r.count,page:r.page,pageSize:r.pageSize,totalPage:r.totalPage,lists:s}}let i=t.message||t.msg||"Request Error.";throw new re("GET_PANEL_LIB_LIST",i)}async function OB(e){let{d3modelItemIn:t,d3modelItemOut:i,d3modelTagIds:r,d3modelTagTitles:s}=await QE(e.d3model,e.path,e.isProject),n=t||i;if(!n)throw new re("PARAMETER_VERIFICATION","missing d3Model data.");n.title!==void 0&&ZE(n.title),"path"in e.d3model&&e.d3model.override&&jr(n,e.d3model.override);let a=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:e.uuid}),{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!a.success){let l=a.message||a.msg||"Request Error.";throw new re("UPDATE_D3MODEL",l)}if(n.dataStr){let l=await nt("POST",ai(rt.COMPONENT.UPDATE_CANVAS,{uuid:e.uuid}),{...n,tags:r,owner:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!l.success){let h=l.message||l.msg||"Request Error.";throw new re("UPDATE_D3MODEL",h)}}if(a.code===0&&a.success&&typeof a.result=="object"){let l=a.result;return await uc(e.path,l)}let o=a.message||a.msg||"Request Error.";throw On(a.code)?new re("D3MODEL_SAME_NAMA_EXISTS",o):$s(a.code)?new re("UPDATE_D3MODEL_PERMISSIONS",o):new re("UPDATE_SYMBOL",o)}async function mB(e){let t={uid:e.uid,path:e.path};if(e.tags){let{result:s}=await $E({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=s}let i=await nt("POST",rt.DEVICE.GET_ATTR_KEYS,t,{headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",path:e.path}});if(i.code===0&&i.success&&typeof i.result=="object")return i.result;let r=i.message||i.msg||"Request Error.";throw new re("GET_DEVICE_ATTRIBUTES_KEYS",r)}async function bB(e){let t={uid:e.uid,path:e.path,key:e.key};if(e.tags){let{result:s}=await $E({uuid:e.uid,path:e.path,types:[3],names:e.tags});t.tag=s}let i=await nt("POST",rt.DEVICE.GET_ATTR_VALUE,t,{headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",path:e.path}});if(i.code===0&&i.success&&typeof i.result=="object")return i.result;let r=i.message||i.msg||"Request Error.";throw new re("GET_DEVICE_ATTRIBUTES_VALUES",r)}var yB=class extends Rm{async getDevice(e){return await A6(e)}async getDeviceAttributesKeys(e){return await mB(e)}async getDeviceAttributesValues(e){return bB(e)}async getSymbol(e){return await R6(e)}async getFootprint(e){return await C6(e)}async getPanelLib(e){return await fB(e)}async getD3Model(e){return await md(e.uuid,e.path)}async getSimModel(e){return await L6(e)}async getDeviceList(e){return await z6(e)}async getSymbolList(e){return await G6(e)}async getFootprintList(e){return await U6(e)}async getPanelLibList(e){return await _B(e)}async getD3ModelList(e){return await F6(e)}async getSimModelList(e){return D6(e)}async getDeviceSearchList(e){return await H6(e)}async getSymbolSearchList(e){return await q6(e)}async getFootprintSearchList(e){return await Z6(e)}async getPanelLibSearchList(e){return await hB(e)}async getD3ModelSearchList(e){return await nB(e)}async getSimModelSearchList(e){return eB(e)}async createDevice(e){return await T6(e)}async createSymbol(e){return await P6(e)}async createFootprint(e){return await S6(e)}async createD3Model(e){return await E6(e)}async createPanelLib(e){return await pB(e)}async createSimModel(e){return await I6(e)}async updateDevice(e){return await N6(e)}async updateDeviceAttributes(e){return await sB(e)}async updateSymbol(e){return await k6(e)}async updateFootprint(e){return await M6(e)}async updatePanelLib(e){return await gB(e)}async updateD3Model(e){return await OB(e)}async updateSimModel(e){return await B6(e)}async deleteDevice(e){let t=await nt("POST",ai(rt.DEVICE.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_DEVICE",i)}}async deleteSymbol(e){let t=await nt("POST",ai(rt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_SYMBOL",i)}}async deleteFootprint(e){let t=await nt("POST",ai(rt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_FOOTPRINT",i)}}async deletePanelLib(e){let t=await nt("POST",ai(rt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_PANEL_LIB",i)}}async deleteSimModel(e){let t=await nt("POST",ai(rt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_SIM_MODEL",i)}}async delete3DModel(e){let t=await nt("POST",ai(rt.COMPONENT.DELETE,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("DELETE_3DMODEL",i)}}async starDevice(e){let t=await nt("POST",ai(rt.DEVICE.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("STAR_DEVICE",i)}}async starSymbol(e){let t=await nt("POST",ai(rt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("STAR_SYMBOL",i)}}async starFootprint(e){let t=await nt("POST",ai(rt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("STAR_FOOTPRINT",i)}}async starPanelLib(e){let t=await nt("POST",ai(rt.COMPONENT.STAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("STAR_PANEL_LIB",i)}}async unstarDevice(e){let t=await nt("POST",ai(rt.DEVICE.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("UNSTAR_DEVICE",i)}}async unstarSymbol(e){let t=await nt("POST",ai(rt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("UNSTAR_SYMBOL",i)}}async unstarFootprint(e){let t=await nt("POST",ai(rt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("UNSTAR_FOOTPRINT",i)}}async unstarPanelLib(e){let t=await nt("POST",ai(rt.COMPONENT.UNSTAR,{uuid:e.uuid}),{uuid:e.uuid,path:e.path},{headers:{"Content-Type":"application/json",path:e.path}});if(!(t.code===0&&t.success)){let i=t.message||t.msg||"Request Error.";throw new re("UNSTAR_PANEL_LIB",i)}}},Ka=class{static diffVersionDevice(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(s=>({device:s})));Xe.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Devices have not been added to the project library, project library has devices with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static diffVersionSymbol(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(s=>({symbol:s})));Xe.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Symbols have not been added to the project library, project library has symbols with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static diffVersionFootprint(e){let t=Object.keys(e);if(!t||!t.length)return;let i=[];for(let r of t)i.push(...e[r].map(s=>({footprint:s})));Xe.messageBus.publish("logI18nLogView1",{type:"warn",msg:["Footprints have not been added to the project library, project library has footprints with different versions from the same source,",{text:"It is recommended to update the project library:",call:{cmd:"updateComponent",args:{uuids:i,needTipModal:!1}}},t.join("\u3001")],onlyTranslateText:!0})}static sameVersionDevice(e){}static sameVersionSymbol(e){}static sameVersionFootprint(e){}static renamedDevice(e){Xe.messageBus.publish("logI18nLogView",{type:"warn",msg:["Devices are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedSymbol(e){Xe.messageBus.publish("logI18nLogView",{type:"warn",msg:["Symbols are automatically renamed when they are added to the project library :",e.join("\u3001")]})}static renamedFootprint(e){Xe.messageBus.publish("logI18nLogView",{type:"warn",msg:["Footprints are automatically renamed when they are added to the project library :",e.join("\u3001")]})}},vB=class{constructor(e){let{renameKey:t=!0}=e;this.renameKey=t}async rename(e,...t){if(await this.hack(e,...t))return{success:!0};let i=(await Xe.messageBus.rpcCall("allowDuplicateNames",...t)).message;return this.renameKey||!i?this.renaming(e,...t):i?{success:!0}:this.isRename(e,...t)}async hack(e,...t){return!1}},xB=class extends vB{constructor(e){let{matchKey:t=!0,byUUID:i=!1,byVersion:r=!1,bySource:s=!1}=e;super(e),this.matchKey=t,this.byUUID=i,this.byVersion=r,this.bySource=s}async match(e){if(this.matchKey)return this.matching(e)}},Fm=class extends xB{constructor(e){let{path:t,data:i,printLog:r=!0}=e;super(e),this.origin={},this.path=t,this.data=i,this.printLog=r}async onAdd(e){let t=JSON.parse(JSON.stringify(e));return t.path||(t.path=this.path),await zM({data:t}),I0(t),t.project_uuid=t.path=this.path,t}async onUpdate(e){let t=JSON.parse(JSON.stringify(e));return I0(t),t}async getTemplate(e,t={}){let{uuid:i,path:r,updateTime:s}=e,n=`${i}${Go}${r}`,a=s==null?void 0:s.toString(),o=Object.assign(e,{path:r,source:n,version:a},t);return I0(o),o}},d3=class extends Fm{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(zl(this.data)){let{override:s}=this.data;if(s&&s.attributes)throw new re("CREATE_DEVICE_GET_ORIGIN","Api call error!");if(r){let{message:n}=await Xe.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(n){let a=[i,t],o=(await Xe.messageBus.rpcCall(yt.DEVICE.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else throw new re("CREATE_DEVICE_GET_ORIGIN","Get project library data source Project is not open!")}else if($i.getInstance().hasLib(t)){let n=$i.getInstance().getLib(t),a=await((e=n==null?void 0:n.device)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,s)}else throw new re("CREATE_DEVICE_GET_ORIGIN","Device details data does not exist")}else{let n={path:t,uuid:i},{message:a}=await Xe.messageBus.rpcCall(Ja.DEVICE.GET,n);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_DEVICE_GET_ORIGIN",a.message||"Device details data does not exist")}}else{let s=this.data.data,n=Object.assign(s,{isProject:r});this.origin=await this.onHandle(n)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await Xe.messageBus.rpcCall(yt.DEVICE.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),this.printLog&&t!==r&&Ka.renamedDevice([t]),{success:!0}}},EB=class extends d3{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=await(await Xe.messageBus.rpcCall(yt.DEVICE.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await Xe.messageBus.rpcCall(yt.DEVICE.GET_BY_SOURCE_VERSION,t)).message;return this.printLog&&i&&Ka.sameVersionDevice([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await Xe.messageBus.rpcCall(yt.DEVICE.GET_LAST,t)).message;return this.printLog&&i&&Ka.diffVersionDevice({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await Xe.messageBus.rpcCall(yt.DEVICE.IS_RENAME,t)).message)throw new re("DEVICE_SAME_NAMA_EXISTS","Device duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("CREATE_DEVICE",e.message||"Creation of the device failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let s=await this.rename(this.origin,{path:this.path});if(!s.success)throw new re("CREATE_DEVICE",s.message||"Creation of the device failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},f3=class extends Fm{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(zl(this.data)){let{override:s}=this.data;if(r){let{message:n}=await Xe.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(n){let a=[i,t],o=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else throw new re("CREATE_FOOTPRINT_GET_ORIGIN","Get project library data source Project is not open!")}else if($i.getInstance().hasLib(t)){let n=$i.getInstance().getLib(t),a=await((e=n==null?void 0:n.footprint)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,s)}else throw new re("CREATE_FOOTPRINT_GET_ORIGIN","Footprint details data does not exist")}else{let n={path:t,uuid:i},{message:a}=await Xe.messageBus.rpcCall(Ja.COMPONENT.GET,n);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_FOOTPRINT_GET_ORIGIN",a.message||"Footprint details data does not exist")}}else{let s=this.data.data,n=Object.assign(s,{isProject:r});this.origin=await this.onHandle(n)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),this.printLog&&t!==r&&Ka.renamedFootprint([t]),{success:!0}}},Um=class extends f3{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET_BY_SOURCE_VERSION,t)).message;return this.printLog&&i&&Ka.sameVersionFootprint([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET_LAST,t)).message;return this.printLog&&i&&Ka.diffVersionFootprint({[i.display_title||i.title]:[i.uuid]}),i}}}async isRename(e){let t=[e.display_title||e.title,this.path];if((await Xe.messageBus.rpcCall(yt.FOOTPRINT.IS_RENAME,t)).message)throw new re("CREATE_FOOTPRINT","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("CREATE_FOOTPRINT",e.message||"Creation of the footprint failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let s=await this.rename(this.origin,{path:this.path});if(!s.success)throw new re("CREATE_FOOTPRINT",s.message||"Creation of the footprint failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},p3=class extends Fm{async getOrigin(){var e;let{path:t,uuid:i,isProject:r}=this.data;if(zl(this.data)){let{override:s}=this.data;if(r){let{message:n}=await Xe.messageBus.rpcCall("/pro-mgr/hasProject",[t]);if(n){let a=[i,t],o=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET,a)).message;if(o){let l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else throw new re("CREATE_SYMBOL_GET_ORIGIN","Get project library data source Project is not open!")}else if($i.getInstance().hasLib(t)){let n=$i.getInstance().getLib(t),a=await((e=n==null?void 0:n.symbol)==null?void 0:e.getTransformedDetail(i));if(a){let o=Object.assign(a,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(o,s)}else throw new re("CREATE_SYMBOL_GET_ORIGIN","Symbol details data does not exist")}else{let n={path:t,uuid:i},{message:a}=await Xe.messageBus.rpcCall(Ja.COMPONENT.GET,n);if(a.success){let o=a.result,l=Object.assign(o,{uuid:i,path:t,isProject:r});this.origin=await this.getTemplate(l,s)}else throw new re("CREATE_SYMBOL_GET_ORIGIN",a.message||"Symbol details data does not exist")}}else{let s=this.data.data,n=Object.assign(s,{isProject:r});this.origin=await this.onHandle(n)}return{success:!0,result:this.origin}}async renaming(e){let t=e.display_title||e.title,i=[t,this.path],r=(await Xe.messageBus.rpcCall(yt.SYMBOL.TRY_RENAME,i)).message;return r&&(e.display_title=e.title=r),this.printLog&&t!==r&&Ka.renamedSymbol([t]),{success:!0}}},Gm=class extends p3{onHandle(e){return this.onAdd(e)}async matching(e){if(this.byUUID){let t=[e.uuid,this.path],i=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET,t)).message;if(e.ticket&&i!=null&&i.ticket&&(i==null?void 0:i.ticket)===e.ticket)return i}if(e.source){if(this.byVersion){let t=[e.source,e.version,this.path],i=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET_BY_SOURCE_VERSION,t)).message;return this.printLog&&i&&Ka.sameVersionSymbol([e.display_title||e.title]),i}if(this.bySource){let t=[e.source,this.path],i=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET_LAST,t)).message;return this.printLog&&i&&Ka.diffVersionSymbol({[i.display_title||i.title]:[i.uuid]}),i}}}async hack(e){let{docType:t}=e;return t===17}async isRename(e){let t=[e.display_title||e.title,this.path];if((await Xe.messageBus.rpcCall(yt.SYMBOL.IS_RENAME,t)).message)throw new re("CREATE_SYMBOL","Library duplicate name");return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("CREATE_SYMBOL",e.message||"Creation of the symbol failed!");let t,i;if(this.origin){let r=await this.match(this.origin);if(r)t={success:!0,result:r};else{let s=await this.rename(this.origin,{path:this.path});if(!s.success)throw new re("CREATE_SYMBOL",s.message||"Creation of the symbol failed!");i=this.origin}}return{success:!0,result:{respond:t,addData:i}}}},dc=class{constructor(e){this.path=e}async check(){let{message:{hasPermission:e,errMsg:t}}=await Xe.messageBus.rpcCall("canAddLib",[this.path]);if(!e)throw new re("CREATE_DEVICE_PERMISSIONS",t||"You don't have permission!");return{success:!0}}},wB=class extends dc{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:s=!0,byUUID:n=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.addData={},this.result={device:null,symbol:null,footprint:null},this.data=i,this.matchKey=s,this.byUUID=n,this.byVersion=a,this.bySource=o,this.renameKey=l}async start(){var e,t,i,r,s,n,a,o,l,h,c,d;try{await this.check(),await this.onbefore();let f={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey};if(this.data.device){let g={...f,data:this.data.device},_=await new EB(g).start();if(_.success===!1)throw new re("CREATE_DEVICE",_.message||"Creation of the device failed!");let{respond:y,addData:m}=_.result;if(this.result.device=y,m&&(this.addData.device=m),this.getBind(),!this.addData.device&&(e=this.result.device)!=null&&e.success&&(t=this.result.device)!=null&&t.result){let{attributes:O}=this.result.device.result,{Symbol:b,Footprint:v}=O,E=b&&(await Xe.messageBus.rpcCall(yt.SYMBOL.GET,[b,this.path])).message,T=v&&(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET,[v,this.path])).message;this.result.symbol={success:!0,result:E},this.result.footprint={success:!0,result:T}}}if(this.data.symbol){let g={...f,data:this.data.symbol},_=await new Gm(g).start();if(_.success===!1&&_.code===404){if(this.addData.device){this.addData.device.attributes.Symbol="";let{display_title:y,title:m}=this.addData.device,O=y||m;Xe.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound symbol data!",O]})}}else{if(_.success===!1)throw new re("CREATE_DEVICE",_.message||"Creation of the device failed!");{let{respond:y,addData:m}=_.result;if(this.result.symbol=y,m&&(this.addData.symbol=m),this.addData.device&&(i=this.result.symbol)!=null&&i.success&&(r=this.result.symbol)!=null&&r.result)this.addData.device.attributes.Symbol=this.result.symbol.result.uuid;else if((s=this.addData.device)!=null&&s.attributes.Symbol&&(n=this.result.symbol)!=null&&n.success&&!((a=this.result.symbol)!=null&&a.result)&&!this.addData.symbol){let O="The symbol associated with the device does not exist!";throw new re("CREATE_DEVICE",O)}}}}if(this.data.footprint){let g={...f,data:this.data.footprint},_=await new Um(g).start();if(_.success===!1&&_.code===404){if(this.addData.device){this.addData.device.attributes.Footprint="";let{display_title:y,title:m}=this.addData.device,O=y||m;Xe.messageBus.publish("logI18nLogView",{type:"warn",msg:["The following devices lose bound footprint data!",O]})}}else{if(_.success===!1)throw new re("CREATE_DEVICE",_.message||"Creation of the device failed!");{let{respond:y,addData:m}=_.result;if(this.result.footprint=y,m&&(this.addData.footprint=m),this.addData.device&&(o=this.result.footprint)!=null&&o.success&&(l=this.result.footprint)!=null&&l.result)this.addData.device.attributes.Footprint=this.result.footprint.result.uuid;else if((h=this.addData.device)!=null&&h.attributes.Footprint&&(c=this.result.footprint)!=null&&c.success&&!((d=this.result.footprint)!=null&&d.result)&&!this.addData.footprint){let O="The footprint associated with the device does not exist!";throw new re("CREATE_DEVICE",O)}}}}let u=await this.create();if(!u.success)throw new re("CREATE_DEVICE",u.message||"Creation of the device failed!");let p=await this.updateBind();if(!p.success)throw new re("CREATE_DEVICE",p.message||"Creation of the device failed!");if(!this.result)throw new re("CREATE_DEVICE","Project library device added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}catch(f){throw new re("CREATE_DEVICE",f.message||"Creation of the device failed!")}}getBind(){if(this.addData.device){let{attributes:e}=this.addData.device,{Symbol:t,Footprint:i}=e,{isProject:r}=this.data.device;if(r===void 0)!this.data.symbol&&t&&(this.data.symbol={isProject:!0,path:this.path,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:!0,path:this.path,uuid:i});else{let[s,n]=this.addData.device.source.split(Go);!this.data.symbol&&t&&(this.data.symbol={isProject:r,path:n,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:r,path:n,uuid:i})}}}onbeforeCreate(){var e,t,i,r;if((e=this.addData.symbol)!=null&&e.docType&&!Cx((t=this.addData.symbol)==null?void 0:t.docType))throw new re("CREATE_DEVICE","invalid symbol docType");if((i=this.addData.footprint)!=null&&i.docType&&((r=this.addData.footprint)==null?void 0:r.docType)!==4)throw new re("CREATE_DEVICE","invalid footprint docType");if(this.addData.footprint&&(this.addData.footprint.isConnectDevice=!0),this.addData.device&&this.addData.device.attributes["3D Model"]){let s=this.addData.device.attributes["3D Model"];s.includes(Go)||(this.addData.device.attributes["3D Model"]=`${s}${Go}${this.addData.device.path}`)}return{success:!0}}async create(){if(Object.keys(this.addData).length>0){this.onbeforeCreate();let e=[this.addData,this.path],{message:t}=await Xe.messageBus.rpcCall(yt.DEVICE.CREATE,e);if(!t.success)throw new re("CREATE_DEVICE",t.message||"Creation of the device failed!");let{device:i,symbol:r,footprint:s}=t.result;i&&(this.result.device={success:!0,result:i}),r&&(this.result.symbol={success:!0,result:r}),s&&(this.result.footprint={success:!0,result:s})}return{success:!0}}async updateBind(){let{device:e,symbol:t,footprint:i}=this.result,r=e!=null&&e.success?e==null?void 0:e.result:null,s=t!=null&&t.success?t==null?void 0:t.result:null,n=i!=null&&i.success?i==null?void 0:i.result:null;if(r){let a=!1;if(s!=null&&s.uuid&&r.attributes.Symbol&&s.uuid!==r.attributes.Symbol&&(r.attributes.Symbol=s.uuid,a=!0),n!=null&&n.uuid&&r.attributes.Footprint&&n.uuid!==r.attributes.Footprint&&(r.attributes.Footprint=n.uuid,a=!0),a){let o=(await Xe.messageBus.rpcCall(yt.DEVICE.UPDATE,[r,this.path])).message;this.result.device={success:!!o,result:o}}}return{success:!0}}async onbefore(){}async onsuccess(e){e.symbol&&!e.symbol.success&&(e.symbol.message=Nl(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Nl(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Nl(e.device)||e.device.message)}},TB=class extends d3{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("UPDATE_DEVICE",e.message||"Update of the device failed!");if(!this.origin)throw new re("UPDATE_DEVICE","Device details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await Xe.messageBus.rpcCall(yt.DEVICE.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new re("UPDATE_DEVICE",r.message||"Update of the device failed!")}return{success:!0,result:this.origin}}},SB=class extends dc{constructor(e){let{path:t,uuid:i,data:r,options:s={}}=e,{matchKey:n=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:h=!1}=s;super(t),this.addData={},this.map={},this.result={device:null,symbol:null,footprint:null,map:{}},this.uuid=i,this.data=r,this.matchKey=n,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=h}async start(){var e,t,i,r,s,n,a,o,l,h;try{await this.check(),await this.onbefore();let c={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey};if(this.data.device){let u={...c,data:this.data.device},p=await new TB(this.uuid,u).start();if(p.success){let g=p.result;g&&(this.updateData=g),this.getBind()}else throw new re("UPDATE_DEVICE",p.message||"Update of the device failed!")}if(this.data.symbol){let u={...c,data:this.data.symbol,renameKey:this.renameKey,printLog:!1},p=await new Gm(u).start();if(!p.success)throw new re("UPDATE_DEVICE",p.message||"Update of the device failed!");let{respond:g,addData:_}=p.result;if(this.result.symbol=g,_&&(this.addData.symbol=_),this.updateData&&this.addData.symbol)this.updateData.attributes.Symbol=this.addData.symbol.uuid;else if(this.updateData&&(e=this.result.symbol)!=null&&e.success&&this.result.symbol.result)this.updateData.attributes.Symbol=this.result.symbol.result.uuid;else if((t=this.updateData)!=null&&t.attributes.Symbol&&(i=this.result.symbol)!=null&&i.success&&!((r=this.result.symbol)!=null&&r.result)&&!this.addData.symbol){let y="The symbol associated with the device does not exist!";throw new re("UPDATE_DEVICE",y)}}if(this.data.footprint){let u={...c,data:this.data.footprint,renameKey:this.renameKey,printLog:!1},p=await new Um(u).start();if(!p.success)throw new re("UPDATE_DEVICE",p.message||"Update of the device failed!");let{respond:g,addData:_}=p.result;if(this.result.footprint=g,_&&(this.addData.footprint=_),this.updateData&&this.addData.footprint)this.updateData.attributes.Footprint=this.addData.footprint.uuid;else if(this.updateData&&(s=this.result.footprint)!=null&&s.success&&this.result.footprint.result)this.updateData.attributes.Footprint=this.result.footprint.result.uuid;else if((n=this.updateData)!=null&&n.attributes.Footprint&&(a=this.result.footprint)!=null&&a.success&&!((o=this.result.footprint)!=null&&o.result)&&!this.addData.footprint){let y="The footprint associated with the device does not exist!";throw new re("UPDATE_DEVICE",y)}}let d=await this.create();if(!d.success)throw new re("UPDATE_DEVICE",d.message||"Update of the device failed!");let f=await this.update();if(!f.success)throw new re("UPDATE_DEVICE",f.message||"Update of the device failed!");if(!this.result){let u={text:"Failed to update project library device {title}!",args:{title:((l=this.updateData)==null?void 0:l.display_title)||((h=this.updateData)==null?void 0:h.title)||""}};throw new re("UPDATE_DEVICE",u)}return await this.onsuccess(this.result),{success:!0,result:Object.assign(this.result,{map:this.map})}}catch(c){throw new re("UPDATE_DEVICE",c.message||"Update of the device failed!")}}getBind(){if(this.updateData){let{attributes:e}=this.updateData,{Symbol:t,Footprint:i}=e||{},{isProject:r}=this.data.device;if(r===void 0)!this.data.symbol&&t&&(this.data.symbol={isProject:!0,path:this.path,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:!0,path:this.path,uuid:i});else{let[s,n]=this.updateData.source.split(Go);!this.data.symbol&&t&&(this.data.symbol={isProject:r,path:n,uuid:t}),!this.data.footprint&&i&&(this.data.footprint={isProject:r,path:n,uuid:i})}}}onbeforeCreate(){var e,t,i,r;if((e=this.addData.symbol)!=null&&e.docType&&!Cx((t=this.addData.symbol)==null?void 0:t.docType))throw new re("UPDATE_DEVICE","invalid symbol docType");if((i=this.addData.footprint)!=null&&i.docType&&((r=this.addData.footprint)==null?void 0:r.docType)!==4)throw new re("UPDATE_DEVICE","invalid footprint docType");return this.addData.footprint&&(this.addData.footprint.isConnectDevice=!0),{success:!0}}async create(){let{symbol:e,footprint:t}=this.addData;if(this.onbeforeCreate(),e){let i=(await Xe.messageBus.rpcCall(yt.SYMBOL.CREATE,[e,this.path])).message;if(!i.success)throw new re("UPDATE_DEVICE",i.message||"Project library symbol added failed!");let r=i.result;this.result.symbol={success:!0,result:r},this.map[e.uuid]=r.uuid}if(t){let i=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.CREATE,[t,this.path])).message;if(!i.success)throw new re("UPDATE_DEVICE",i.message||"Project library footprint added failed!");let r=i.result;this.result.footprint={success:!0,result:r},this.map[t.uuid]=r.uuid}return{success:!0}}async update(){var e,t,i;let r=this.updateData;if(r){(e=this.result.symbol)!=null&&e.success&&this.result.symbol.result&&(r.attributes.Symbol=(t=this.result.symbol)==null?void 0:t.result.uuid),(i=this.result.footprint)!=null&&i.success&&this.result.footprint.result&&(r.attributes.Footprint=this.result.footprint.result.uuid);let s=[{...r,uuid:this.uuid,keepVersion:this.keepVersion},this.path],n=(await Xe.messageBus.rpcCall(yt.DEVICE.UPDATE,s)).message;if(!n){let a=r.display_title||r.title||"";throw new re("UPDATE_DEVICE",`Update of the device failed! title: ${a}`)}this.result.device={success:!0,result:n}}return{success:!0}}async onbefore(){zl(this.data.device)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){e.symbol&&!e.symbol.success&&(e.symbol.message=Nl(e.symbol)||e.symbol.message),e.footprint&&!e.footprint.success&&(e.footprint.message=Nl(e.footprint)||e.footprint.message),e.device&&!e.device.success&&(e.device.message=Nl(e.device)||e.device.message)}},IB=class extends dc{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:s=!0,byUUID:n=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.data=i,this.byUUID=n,this.byVersion=a,this.bySource=o,this.renameKey=l,this.matchKey=s}async start(){await this.check(),await this.onbefore();let e={path:this.path,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey,matchKey:this.matchKey},t=await new Gm({...e,data:this.data}).start();if(!t.success)throw new re("CREATE_SYMBOL",t.message||"Project library symbol added failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new re("CREATE_SYMBOL",r.message||"Project library symbol added failed!");if(r&&r.success)this.result=r.result;else if(i){let s=(await Xe.messageBus.rpcCall(yt.SYMBOL.CREATE,[i,this.path])).message;if(!s.success)throw new re("CREATE_SYMBOL","Project library symbol added failed!");this.result=s.result}if(!this.result)throw new re("CREATE_SYMBOL","Project library symbol added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},PB=class extends dc{constructor(e){let{path:t,data:i,options:r={}}=e,{matchKey:s=!0,byUUID:n=!0,byVersion:a=!0,bySource:o=!1,renameKey:l=!1}=r;super(t),this.data=i,this.byUUID=n,this.byVersion=a,this.bySource=o,this.renameKey=l,this.matchKey=s}async start(){await this.check(),await this.onbefore();let e={path:this.path,byUUID:this.byUUID,byVersion:this.byVersion,bySource:this.bySource,renameKey:this.renameKey,matchKey:this.matchKey},t=await new Um({...e,data:this.data}).start();if(!t.success)throw new re("CREATE_FOOTPRINT",t.message||"Creation of the footprint failed!");let{addData:i,respond:r}=t.result;if(r&&!r.success)throw new re("CREATE_FOOTPRINT",r.message||"Creation of the footprint failed!");if(r&&r.success)this.result=r.result;else if(i){let s=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.CREATE,[i,this.path])).message;if(!s.success)throw new re("CREATE_FOOTPRINT","Project library footprint added failed!");this.result=s.result}if(!this.result)throw new re("CREATE_FOOTPRINT","Project library footprint added failed!");return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){}async onsuccess(e){}},AB=class extends p3{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async hack(e){let{docType:t}=e;return t===17}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("UPDATE_SYMBOL",e.message||"Update of the symbol failed!");if(!this.origin)throw new re("UPDATE_SYMBOL","Symbol details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await Xe.messageBus.rpcCall(yt.SYMBOL.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new re("UPDATE_SYMBOL",r.message||"Update of the symbol failed!")}return{success:!0,result:this.origin}}},CB=class extends dc{constructor(e){let{path:t,uuid:i,data:r,options:s={}}=e,{matchKey:n=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:h=!1}=s;super(t),this.uuid=i,this.data=r,this.matchKey=n,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=h}async start(){var e,t;await this.check(),await this.onbefore();let i={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey,data:this.data},r=await new AB(this.uuid,i).start();if(!r.success)throw new re("UPDATE_SYMBOL",r.message||"Update of the symbol failed!");this.updateData=r.result;let s={uuid:this.uuid,data:this.updateData,overwriteCanvas:this.onlyIdentity,keepVersion:this.keepVersion},n=(await Xe.messageBus.rpcCall(yt.SYMBOL.COVER,[s,this.path])).message;if(!n.success)throw new re("UPDATE_SYMBOL",n.message||"Update of the symbol failed!");if(this.result=n.result,!this.result){let a=((e=this.updateData)==null?void 0:e.display_title)||((t=this.updateData)==null?void 0:t.title)||"",o="Failed to update project library symbol {title}!";throw new re("UPDATE_SYMBOL",{text:o,args:{title:a}})}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){zl(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},LB=class extends f3{constructor(e,t){super(t),this.uuid=e}onHandle(e){return this.onUpdate(e)}matching(e){throw new Error("Method not implemented.")}async isRename(e){return{success:!0}}async start(){let e=await this.getOrigin();if(!e.success)throw new re("UPDATE_FOOTPRINT",e.message||"Update of the footprint failed!");if(!this.origin)throw new re("UPDATE_FOOTPRINT","Footprint details data does not exist");let t=this.origin.display_title||this.origin.title,i=[{uuid:this.uuid,title:t},this.path];if((await Xe.messageBus.rpcCall(yt.FOOTPRINT.IS_CHANGE,i)).message){let r=await this.rename(this.origin,{path:this.path});if(!r.success)throw new re("UPDATE_FOOTPRINT",r.message||"Update of the footprint failed!")}return{success:!0,result:this.origin}}},DB=class extends dc{constructor(e){let{path:t,uuid:i,data:r,options:s={}}=e,{matchKey:n=!0,byUUID:a=!0,bySource:o=!0,byVersion:l=!1,renameKey:h=!1}=s;super(t),this.uuid=i,this.data=r,this.matchKey=n,this.byUUID=a,this.bySource=o,this.byVersion=l,this.renameKey=h}async start(){var e,t;await this.check(),await this.onbefore();let i={path:this.path,matchKey:this.matchKey,byUUID:this.byUUID,bySource:this.bySource,byVersion:this.byVersion,renameKey:this.renameKey,data:this.data},r=await new LB(this.uuid,i).start();if(!r.success)throw new re("UPDATE_FOOTPRINT",r.message||"Update of the footprint failed!");this.updateData=r.result;let s={uuid:this.uuid,data:this.updateData,overwriteCanvas:this.onlyIdentity,keepVersion:this.keepVersion},n=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.COVER,[s,this.path])).message;if(!n.success)throw new re("UPDATE_FOOTPRINT",n.message||"Update of the footprint failed!");if(this.result=n.result,!this.result){let a={text:"Failed to update project library footprint {title}!",args:{title:((e=this.updateData)==null?void 0:e.display_title)||((t=this.updateData)==null?void 0:t.title)||""}};throw new re("UPDATE_FOOTPRINT",a)}return await this.onsuccess(this.result),{success:!0,result:this.result}}async onbefore(){zl(this.data)?(this.onlyIdentity=!0,this.keepVersion=!0):(this.onlyIdentity=!1,this.keepVersion=!1)}async onsuccess(e){}},RB=class extends Rm{async getDevice(e){let t=[e.uuid,e.path],{message:i}=await Xe.messageBus.rpcCall(yt.DEVICE.GET,t);if(!i)throw new re("GET_DEVICE","Device details data does not exist");return Tp(e.path,i)}async getDeviceAttributesKeys(e){let{message:t}=await Xe.messageBus.rpcCall(yt.DEVICE.GET_ATTRIBUTES_KEYS,e);if(!t.success)throw new re("GET_DEVICE_ATTRIBUTES_KEYS",t.message);return t.result}async getDeviceAttributesValues(e){let{message:t}=await Xe.messageBus.rpcCall(yt.DEVICE.GET_ATTRIBUTES_VALUES,e);if(!t.success)throw new re("GET_DEVICE_ATTRIBUTES_VALUES",t.message);return t.result}async getSymbol(e){let t=[e.uuid,e.path],{message:i}=await Xe.messageBus.rpcCall(yt.SYMBOL.GET,t);if(!i)throw new re("GET_SYMBOL","Symbol details data does not exist");return L0(e.path,i)}async getFootprint(e){let t=[e.uuid,e.path],{message:i}=await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET,t);if(!i)throw new re("GET_FOOTPRINT","Footprint details data does not exist");return D0(e.path,i)}async createDevice(e){let{path:t,device:i,symbol:r,footprint:s}=e,n={path:t,data:{device:i,symbol:r,footprint:s}},a=await new wB(n).start();if(!a.success)throw new re("CREATE_DEVICE",a.message);let o=a.result.device;if(!(o!=null&&o.success))throw new re("CREATE_DEVICE",o==null?void 0:o.message);let l=o.result;return Tp(e.path,l)}async createSymbol(e){let{path:t,symbol:i}=e,r={path:t,data:i},s=await new IB(r).start();if(!s.success)throw new re("CREATE_SYMBOL",s.message);let n=s.result;return L0(e.path,n)}async createFootprint(e){let{path:t,footprint:i}=e,r={path:t,data:i},s=await new PB(r).start();if(!s.success)throw new re("CREATE_FOOTPRINT",s.message);let n=s.result;return D0(e.path,n)}async updateDevice(e){let{uuid:t,path:i,device:r,symbol:s,footprint:n}=e,a={path:i,uuid:t,data:{device:r,symbol:s,footprint:n}},o=await new SB(a).start();if(!o.success)throw new re("UPDATE_DEVICE",o.message);let l=o.result.device;if(!(l!=null&&l.success))throw new re("CREATE_DEVICE",l==null?void 0:l.message);let h=l.result;return Tp(e.path,h)}async updateDeviceAttributes(e){let t=(await Xe.messageBus.rpcCall(yt.DEVICE.UPDATE,[e,e.path])).message;if(!t)throw new re("UPDATE_DEVICE_ATTRIBUTES",t.message);return Tp(e.path,t)}async updateSymbol(e){let{uuid:t,path:i,symbol:r}=e,s={path:i,uuid:t,data:r},n=await new CB(s).start();if(!n.success)throw new re("UPDATE_SYMBOL",n.message);let a=n.result;return L0(e.path,a)}async updateFootprint(e){let{uuid:t,path:i,footprint:r}=e,s={path:i,uuid:t,data:r},n=await new DB(s).start();if(!n.success)throw new re("UPDATE_FOOTPRINT",n.message);let a=n.result;return D0(e.path,a)}async deleteDevice(e){if(!(await Xe.messageBus.rpcCall(yt.DEVICE.DEL,[e.uuid,e.path])).message)throw new re("DELETE_DEVICE","delete failed!")}async deleteSymbol(e){if(!(await Xe.messageBus.rpcCall(yt.SYMBOL.DEL,[e.uuid,e.path])).message)throw new re("DELETE_SYMBOL","delete failed!")}async deleteFootprint(e){if(!(await Xe.messageBus.rpcCall(yt.FOOTPRINT.DEL,[e.uuid,e.path])).message)throw new re("DELETE_FOOTPRINT","delete failed!")}async getDeviceList(e){let t=(await Xe.messageBus.rpcCall(yt.DEVICE.GET_LIST,e)).message;if(!t.success)throw new re("GET_DEVICE_LIST",t.message);return t.result}async getDeviceSearchList(e){let t=(await Xe.messageBus.rpcCall(yt.DEVICE.GET_LIST,e)).message;if(!t.success)throw new re("GET_DEVICE_LIST",t.message);return t.result}async getSymbolList(e){let t=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new re("GET_SYMBOL_LIST",t.message);return t.result}async getSymbolSearchList(e){let t=(await Xe.messageBus.rpcCall(yt.SYMBOL.GET_LIST,e)).message;if(!t.success)throw new re("GET_SYMBOL_LIST",t.message);return t.result}async getFootprintList(e){let t=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new re("GET_FOOTPRINT_LIST",t.message);return t.result}async getFootprintSearchList(e){let t=(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET_LIST,e)).message;if(!t.success)throw new re("GET_FOOTPRINT_LIST",t.message);return t.result}},NB=class extends Rm{constructor(){super(...arguments),this._normalErrorMsg="Request Error.",this._extendLibManager=$i.getInstance()}async getDevice(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("device",e.uuid,e.path));if(i)return i;throw new re("GET_DEVICE",this._normalErrorMsg)}async getSymbol(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("symbol",e.uuid,e.path));if(i)return i;throw new re("GET_SYMBOL",this._normalErrorMsg)}async getFootprint(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("footprint",e.uuid,e.path));if(i)return i;throw new re("GET_FOOTPRINT",this._normalErrorMsg)}async getModel3D(e){var t;let i=await((t=this._extendLibManager.getLib(e.path))==null?void 0:t.getTransformedDetailInTab("model3D",e.uuid,e.path));if(i)return i;throw new re("GET_D3MODEL",this._normalErrorMsg)}async getDeviceList(e){var t,i,r,s,n,a,o,l;let h=await((l=this._extendLibManager.getLib(e.path))==null?void 0:l.getTransformedListInTab("device",{query:{attributes:(i=(t=e.query)==null?void 0:t.attributes)!=null?i:{},symbolType:(r=e.query)==null?void 0:r.symbol_type,classification:{primaryClassificationUuid:(n=(s=e.tags)==null?void 0:s[0])!=null?n:"",secondaryClassificationUuid:(o=(a=e.tags)==null?void 0:a[1])!=null?o:""}},page:e.page,pageSize:e.pageSize}));if(h)return h;throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolList(e){var t,i,r,s,n,a;let o=await((a=this._extendLibManager.getLib(e.path))==null?void 0:a.getTransformedListInTab("symbol",{query:{symbolType:(t=e.docType)==null?void 0:t[0],classification:{primaryClassificationUuid:(r=(i=e.tags)==null?void 0:i[0])!=null?r:"",secondaryClassificationUuid:(n=(s=e.tags)==null?void 0:s[1])!=null?n:""}},page:e.page,pageSize:e.pageSize}));if(o)return o;throw new re("GET_SYMBOL_LIST",this._normalErrorMsg)}async getFootprintList(e){var t,i,r,s,n;let a=await((n=this._extendLibManager.getLib(e.path))==null?void 0:n.getTransformedListInTab("footprint",{query:{classification:{primaryClassificationUuid:(i=(t=e.tags)==null?void 0:t[0])!=null?i:"",secondaryClassificationUuid:(s=(r=e.tags)==null?void 0:r[1])!=null?s:""}},page:e.page,pageSize:e.pageSize}));if(a)return a;throw new re("GET_FOOTPRINT_LIST",this._normalErrorMsg)}async getD3ModelSearchList1(e){var t,i,r;let{path:s,wd:n,query:a,tags:o,page:l,pageSize:h}=e,c=await((r=this._extendLibManager.getLib(s))==null?void 0:r.getTransformedListInTab("model3D",{query:{wd:n,classification:{primaryClassificationUuid:(t=o==null?void 0:o[0])!=null?t:"",secondaryClassificationUuid:(i=o==null?void 0:o[1])!=null?i:""}},page:l,pageSize:h}));if(c)return{...c,facets:{[s]:c.count}};throw new re("GET_D3MODEL_LIST",this._normalErrorMsg)}async getD3ModelSearchList2(e){var t;let{path:i,titles:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("model3D",{query:{listByTitles:r},page:1,pageSize:1e8}));if(s)return s.lists.reduce((n,a)=>((n[a.display_title]||(n[a.display_title]=[])).push(a),n),{});throw new re("GET_D3MODEL_LIST",this._normalErrorMsg)}async getD3ModelSearchList3(e){var t;let{path:i,uuids:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("model3D",{query:{listByUuids:r},page:1,pageSize:1e8}));if(s)return s.lists;throw new re("GET_D3MODEL_LIST",this._normalErrorMsg)}async getD3ModelSearchList(e){return e.titles?await this.getD3ModelSearchList2(e):e.uuids?await this.getD3ModelSearchList3(e):await this.getD3ModelSearchList1(e)}async getDeviceSearchList1(e){var t,i,r,s;let{path:n,wd:a,query:o,tags:l,page:h,pageSize:c}=e,d=await((s=this._extendLibManager.getLib(n))==null?void 0:s.getTransformedListInTab("device",{query:{wd:a,attributes:(t=o==null?void 0:o.attributes)!=null?t:{},symbolType:o==null?void 0:o.symbol_type,classification:{primaryClassificationUuid:(i=l==null?void 0:l[0])!=null?i:"",secondaryClassificationUuid:(r=l==null?void 0:l[1])!=null?r:""}},page:h,pageSize:c}));if(d)return{...d,facets:{[n]:d.count}};throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList2(e){var t;let{path:i,titles:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("device",{query:{listByTitles:r},page:1,pageSize:1e8}));if(s)return s.lists.reduce((n,a)=>((n[a.display_title]||(n[a.display_title]=[])).push(a),n),{});throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList3(e){var t;let{path:i,uuids:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("device",{query:{listByUuids:r},page:1,pageSize:1e8}));if(s)return s.lists;throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getDeviceSearchList(e){return e.titles?await this.getDeviceSearchList2(e):e.uuids?await this.getDeviceSearchList3(e):await this.getDeviceSearchList1(e)}async getSymbolSearchList1(e){var t,i,r,s;let{path:n,wd:a,query:o,tags:l,page:h,pageSize:c}=e,d=await((s=this._extendLibManager.getLib(n))==null?void 0:s.getTransformedListInTab("symbol",{query:{wd:a,symbolType:(t=e.docType)==null?void 0:t[0],classification:{primaryClassificationUuid:(i=l==null?void 0:l[0])!=null?i:"",secondaryClassificationUuid:(r=l==null?void 0:l[1])!=null?r:""}},page:h,pageSize:c}));if(d)return{...d,facets:{[n]:d.count}};throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList2(e){var t;let{path:i,titles:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("symbol",{query:{listByTitles:r},page:1,pageSize:1e8}));if(s)return s.lists.reduce((n,a)=>((n[a.display_title]||(n[a.display_title]=[])).push(a),n),{});throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList3(e){var t;let{path:i,uuids:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("symbol",{query:{listByUuids:r},page:1,pageSize:1e8}));if(s)return s.lists;throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getSymbolSearchList(e){return e.titles?await this.getSymbolSearchList2(e):e.uuids?await this.getSymbolSearchList3(e):await this.getSymbolSearchList1(e)}async getFootprintSearchList1(e){var t,i,r;let{path:s,wd:n,query:a,tags:o,page:l,pageSize:h}=e,c=await((r=this._extendLibManager.getLib(s))==null?void 0:r.getTransformedListInTab("footprint",{query:{wd:n,classification:{primaryClassificationUuid:(t=o==null?void 0:o[0])!=null?t:"",secondaryClassificationUuid:(i=o==null?void 0:o[1])!=null?i:""}},page:l,pageSize:h}));if(c)return{...c,facets:{[s]:c.count}};throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList2(e){var t;let{path:i,titles:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("footprint",{query:{listByTitles:r},page:1,pageSize:1e8}));if(s)return s.lists.reduce((n,a)=>((n[a.display_title]||(n[a.display_title]=[])).push(a),n),{});throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList3(e){var t;let{path:i,uuids:r}=e,s=await((t=this._extendLibManager.getLib(i))==null?void 0:t.getTransformedListInTab("footprint",{query:{listByUuids:r},page:1,pageSize:1e8}));if(s)return s.lists;throw new re("GET_DEVICE_LIST",this._normalErrorMsg)}async getFootprintSearchList(e){return e.titles?await this.getFootprintSearchList2(e):e.uuids?await this.getFootprintSearchList3(e):await this.getFootprintSearchList1(e)}createDevice(e){throw new re("CREATE_DEVICE","Not Supported.")}createSymbol(e){throw new re("GET_SYMBOL","Not Supported.")}createFootprint(e){throw new re("CREATE_FOOTPRINT","Not Supported.")}updateDevice(e){throw new re("UPDATE_DEVICE","Not Supported.")}updateSymbol(e){throw new re("GET_SYMBOL","Not Supported.")}updateFootprint(e){throw new re("GET_SYMBOL","Not Supported.")}deleteDevice(e){throw new re("GET_SYMBOL","Not Supported.")}deleteSymbol(e){throw new re("GET_SYMBOL","Not Supported.")}deleteFootprint(e){throw new re("GET_SYMBOL","Not Supported.")}},MB=(e=>(e[e.CBB=1]="CBB",e[e.SYMBOL=2]="SYMBOL",e[e.DEVICE=3]="DEVICE",e[e.FOOTPRINT=4]="FOOTPRINT",e[e.MODEL3D=5]="MODEL3D",e[e.MODELSIM=6]="MODELSIM",e[e.PANEL_LIB=29]="PANEL_LIB",e))(MB||{}),BB=["title","description","tags","images"],St=new yB,fr=new RB,Ln=new NB,gi=class{static getDevice(e){return $i.getInstance().hasLib(e.path)?Ln.getDevice(e):e.isProject?fr.getDevice(e):St.getDevice(e)}static getDeviceAttributesKeys(e){return e.isProject?fr.getDeviceAttributesKeys(e):St.getDeviceAttributesKeys(e)}static getDeviceAttributesValues(e){return e.isProject?fr.getDeviceAttributesValues(e):St.getDeviceAttributesValues(e)}static getSymbol(e){return $i.getInstance().hasLib(e.path)?Ln.getSymbol(e):e.isProject?fr.getSymbol(e):St.getSymbol(e)}static getFootprint(e){return $i.getInstance().hasLib(e.path)?Ln.getFootprint(e):e.isProject?fr.getFootprint(e):St.getFootprint(e)}static getPanelLib(e){if(e.isProject)throw new re("GET_PANEL_LIB","Api call error!");return St.getPanelLib(e)}static getD3Model(e){return $i.getInstance().hasLib(e.path)?Ln.getModel3D(e):e.isProject?null:St.getD3Model(e)}static getSimModel(e){if(e.isProject)throw new re("GET_SIM_MODEL","Api call error!");return St.getSimModel(e)}static getDeviceList(e){return $i.getInstance().hasLib(e.path)?Ln.getDeviceList(e):e.isProject?fr.getDeviceList(e):St.getDeviceList(e)}static getSymbolList(e){return $i.getInstance().hasLib(e.path)?Ln.getSymbolList(e):e.isProject?fr.getSymbolList(e):St.getSymbolList(e)}static getFootprintList(e){return $i.getInstance().hasLib(e.path)?Ln.getFootprintList(e):e.isProject?fr.getFootprintList(e):St.getFootprintList(e)}static getPanelLibList(e){if(e.isProject)throw new re("GET_D3MODEL_LIST","Api call error!");return St.getPanelLibList(e)}static getD3ModelList(e){if(e.isProject)throw new re("GET_D3MODEL_LIST","Api call error!");return St.getD3ModelList(e)}static getSimModelList(e){if(e.isProject)throw new re("GET_SIM_MODEL_LIST","Api call error!");return St.getSimModelList(e)}static getDeviceSearchList(e){return $i.getInstance().hasLib(e.path)?Ln.getDeviceSearchList(e):e.isProject?fr.getDeviceSearchList(e):St.getDeviceSearchList(e)}static getSymbolSearchList(e){return $i.getInstance().hasLib(e.path)?Ln.getSymbolSearchList(e):e.isProject?fr.getSymbolSearchList(e):St.getSymbolSearchList(e)}static getFootprintSearchList(e){return $i.getInstance().hasLib(e.path)?Ln.getFootprintSearchList(e):e.isProject?fr.getFootprintSearchList(e):St.getFootprintSearchList(e)}static getPanelLibSearchList(e){if(e.isProject)throw new re("GET_PANEL_LIB_SEARCH_LIST","Api call error!");return St.getPanelLibSearchList(e)}static getD3ModelSearchList(e){if(e.isProject)throw new re("GET_D3MODEL_SEARCH_LIST","Api call error!");return $i.getInstance().hasLib(e.path)?Ln.getD3ModelSearchList(e):St.getD3ModelSearchList(e)}static getSimModelSearchList(e){if(e.isProject)throw new re("GET_SIM_MODEL_SEARCH_LIST","Api call error!");return St.getSimModelSearchList(e)}static createDevice(e){return e.isProject?fr.createDevice(e):St.createDevice(e)}static createSymbol(e){return e.isProject?fr.createSymbol(e):St.createSymbol(e)}static createFootprint(e){return e.isProject?fr.createFootprint(e):St.createFootprint(e)}static createD3Model(e){return e.isProject?null:St.createD3Model(e)}static createPanelLib(e){if(e.isProject)throw new re("CREATE_PANEL_LIB","Api call error!");return St.createPanelLib(e)}static createSimModel(e){if(e.isProject)throw new re("CREATE_SIM_MODEL","Api call error!");return St.createSimModel(e)}static updateDevice(e){return e.isProject?fr.updateDevice(e):St.updateDevice(e)}static updateDeviceAttributes(e){return e.isProject?fr.updateDeviceAttributes(e):St.updateDeviceAttributes(e)}static updateSymbol(e){return e.isProject?fr.updateSymbol(e):St.updateSymbol(e)}static updateFootprint(e){return e.isProject?fr.updateFootprint(e):St.updateFootprint(e)}static updatePanelLib(e){if(e.isProject)throw new re("UPDATE_PANEL_LIB","Api call error!");return St.updatePanelLib(e)}static updateD3Model(e){if(e.isProject)throw new re("UPDATE_D3MODEL","Api call error!");return St.updateD3Model(e)}static updateSimModel(e){if(e.isProject)throw new re("UPDATE_SIM_MODEL","Api call error!");return St.updateSimModel(e)}static deleteDevice(e){return e.isProject?fr.deleteDevice(e):St.deleteDevice(e)}static deleteSymbol(e){return e.isProject?fr.deleteSymbol(e):St.deleteSymbol(e)}static deleteFootprint(e){return e.isProject?fr.deleteFootprint(e):St.deleteFootprint(e)}static deletePanelLib(e){if(e.isProject)throw new re("DELETE_PANEL_LIB","Api call error!");return St.deletePanelLib(e)}static deleteSimModel(e){if(e.isProject)throw new re("DELETE_SIM_MODEL","Api call error!");return St.deleteSimModel(e)}static deleteD3Model(e){if(e.isProject)throw new re("DELETE_3DMODEL","Api call error!");return St.delete3DModel(e)}static starDevice(e){if(e.isProject)throw new re("STAR_DEVICE","Api call error!");return St.starDevice(e)}static starSymbol(e){if(e.isProject)throw new re("STAR_SYMBOL","Api call error!");return St.starSymbol(e)}static starFootprint(e){if(e.isProject)throw new re("STAR_FOOTPRINT","Api call error!");return St.starFootprint(e)}static starPanelLib(e){if(e.isProject)throw new re("STAR_PANEL_LIB","Api call error!");return St.starPanelLib(e)}static unstarDevice(e){if(e.isProject)throw new re("UNSTAR_DEVICE","Api call error!");return St.unstarDevice(e)}static unstarSymbol(e){if(e.isProject)throw new re("UNSTAR_SYMBOL","Api call error!");return St.unstarSymbol(e)}static unstarFootprint(e){if(e.isProject)throw new re("UNSTAR_FOOTPRINT","Api call error!");return St.unstarFootprint(e)}static unstarPanelLib(e){if(e.isProject)throw new re("UNSTAR_PANEL_LIB","Api call error!");return St.unstarPanelLib(e)}};async function g3(e,t,i,r={}){r.eachProcessHook&&r.eachProcessHook(.01);let s=i||He.SYSTEMLIB_UUID,n=null;if(t)try{n=await gi.getDevice({isProject:e,path:i,uuid:t})}catch(c){console.warn(c)}r.eachProcessHook&&r.eachProcessHook(.25);let a=null,o={Footprint:!1,symbol:!1,d3DModel:!1};if(n){let c=(n.attributes||{}).Symbol;if(c){try{a=await gi.getSymbol({isProject:e,path:i,uuid:c})}catch(d){console.warn(d)}a||(o.symbol=!0)}}r.eachProcessHook&&r.eachProcessHook(.5);let l=null;if(n){let c=(n.attributes||{}).Footprint;if(c){try{l=await gi.getFootprint({isProject:e,path:i,uuid:c})}catch(d){console.warn(d)}l||(o.Footprint=!0)}}r.eachProcessHook&&r.eachProcessHook(.75);let h=null;if(n){let c=n.attributes||{},d=c["3D Model"],f=c["3D Model Title"],u=_d(d,!0),p=u.path||He.SYSTEMLIB_UUID||s;if($i.getInstance().hasLib(u.path||s)?h=await gi.getD3Model({uuid:u.componentTitleOrId,path:u.path,isProject:!1}):u.componentTitleOrId&&(u.isLocaleFilenameMode?h=(await Cm(u.componentTitleOrId,p)).result:h=await md(u.componentTitleOrId,p)),!h&&d&&f){if(r.isCheckD3ModelFileExist){let g=await kE(d);g.success&&g.result instanceof Blob?o.d3DModel=!1:o.d3DModel=!0}else o.d3DModel=!0;h=Lm(d,f,u.path)}}return r.eachProcessHook&&r.eachProcessHook(1),{setPath:s,deviceItem:n,symbolItem:a,footprintItem:l,d3modelItem:h,hasIdButNotFound:o}}async function kB(e=!1,t,i,r,s){let n=s?!!s.forceAsSymbol:!1,a=s?!!s.ignoreDoctypeCheck:!1,o=s?!!s.isDevice:!1,l=s?!!s.isCheckD3ModelFileExist:!1;if(!a){if(r===28){let d=s?!!s.attachedDeviceBindingExtra:!1,f=s?s.eachProcessHook:null;try{let u=null;return d?u=await g3(e,t,i,{eachProcessHook:f,isCheckD3ModelFileExist:l}):u=await gi.getDevice({isProject:e,path:i,uuid:t}),{code:0,success:!0,result:u,message:""}}catch(u){return{code:-1,success:!1,result:null,message:u.message.toString()}}}if(r===4)try{return{code:0,success:!0,result:await gi.getFootprint({isProject:e,path:i,uuid:t}),message:""}}catch(d){return{code:-1,success:!1,result:null,message:d.message.toString()}}if(n||r&&[2,18,19,20,21,22,25,31,7,32,6].indexOf(r)>=0)try{return{code:0,success:!0,result:await gi.getSymbol({isProject:e,path:i,uuid:t}),message:""}}catch(d){return{code:-1,success:!1,result:null,message:d.message.toString()}}if(r===16)try{return{code:0,success:!0,result:await md(t,i),message:""}}catch(d){return{code:-1,success:!1,result:null,message:d.message.toString()}}}let h=await nt("GET",o?ai(rt.DEVICE.GET,{uuid:t}):ai(rt.COMPONENT.GET,{uuid:t}),{uuid:t,path:i},{headers:{"Content-Type":"application/json",path:i}});if(h.code===0&&h.success&&typeof h.result=="object")return{code:0,success:!0,result:h.result,message:""};let c=h.message||h.msg||"Request Error.";return{code:h.code||-1,success:!1,result:null,message:c}}function am(e,t){let i=e.owner||{},r=typeof e.updated_at=="string"?e.updated_at:typeof e.updated_at=="number"?jo(new Date(e.updated_at)):"",s=typeof e.updateTime=="string"?e.updateTime:typeof e.updateTime=="number"?jo(new Date(is(e.updateTime))):"";return{...e,$id:String(t),numberIndex:t+1,ownerBelong:i.username,updateTimeString:r||s}}function FB(e,t,i){let r=[];for(let s=0;s<e.length;s++){let n=e[s][t]?e[s][t].toLocaleLowerCase():"",a=i?i.toLocaleLowerCase():"";n.indexOf(a)>=0&&r.push(e[s])}return r}async function UB(e,t,i,r){let s=await new Promise(a=>{fetch(wm.D3Model.client3DModelList+`?step_path=${e}`,{method:"GET"}).then(o=>{o.json().then(l=>{if(l){a(l);return}a(null)})})}),n={code:0,success:!0,result:{count:0,page:1,pageSize:r,totalPage:1,lists:[]},msg:""};return s&&s.success?(n.result.lists=(s.result||[]).map((a,o)=>{let l=jo(new Date(a.mtime*1e3)),h={uuid:`${a.fileName}|${t}`,rowFileTag:`${a.fileName}|${t}`,path:t,display_title:a.fileName,description:"",docType:16,isFavorite:!1,modifier:null,owner:null,tags:{child_tag:[],parent_tag:[]},title:a.fileName,updateTime:is(a.mtime),updated_at:l,createTime:is(a.mtime),created_at:l,creator:null,dataStr:"",public:void 0,type:16};return{...am(h,o)}}),n.result.count=s.result.length):(n.code=He.ERR_CODE.NORMAL,n.success=!1,n.msg=s.message||"Fetch local 3D model list error."),n}async function GB(e,t,i,r,s){let n={};for(let h=0;h<t.length;h++){let c=t[h].id,d=await new Promise(f=>{fetch(wm.D3Model.client3DModelList+`?step_path=${c}`,{method:"GET"}).then(u=>{u.json().then(p=>{if(p){f(p);return}f(null)})})});if(d&&d.success){n[c]={list:d.result.map((f,u)=>am(f,u))};continue}n[c]=null}let a={},o={},l={count:0};for(let h=0;h<t.length;h++){let c=t[h].id;if(n[c]){let d=FB(n[c].list,"fileName",r);if(!d.length){a[c]=0,o[c]=[];continue}a[c]=d.length,o[c]=d.map((f,u)=>{let p=jo(new Date(f.mtime*1e3)),g={uuid:`${f.fileName}|${f.path}`,path:f.path,rowFileTag:`${f.fileName}|${f.path}`,display_title:f.fileName,description:"",docType:16,isFavorite:!1,modifier:null,owner:null,tags:{child_tag:[],parent_tag:[]},title:f.fileName,updateTime:is(f.mtime),updated_at:p,createTime:is(f.mtime),created_at:p,creator:null,dataStr:"",public:void 0,source:void 0,std_uuid:void 0,ticket:0,type:16};return{...am(g,u)}}),l.count++;continue}a[c]=0,o[c]=[]}return{code:0,success:!0,result:{count:l.count,facets:a,lists:o[e]||[],uid:e,wd:r,page:1,pageSize:s,totalPage:1},msg:""}}function _3(e){let t=null;return t=zm(e.title),!t.success||(t=O3(e.description),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function zB(e){let t=null;return t=zm(e.name),!t.success||(t=HB(e.type),!t.success)||(t=jB(e.model),!t.success)?t:{code:0,success:!0,message:"",key:"",result:null}}function zm(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function O3(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function HB(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model type is incorrect!"),t}function jB(e){let t={code:0,success:!0,message:"",key:"",result:null};return e||(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The 3D model is incorrect!"),t}async function VB(e,t,i,r){if(!t||!i||!r)return{code:-1,success:!1,result:null,message:"missing uuid or path or detail data."};let s=_3({title:r.title,description:r.description});if(!s.success)return{code:s.code,success:!1,result:null,message:s.message};let n=await nt("POST",ai(rt.COMPONENT.UPDATE,{uuid:t}),{...r,owner:i},{headers:{"Content-Type":"application/json",path:i}});if(n.code===0&&n.success&&typeof n.result=="object")return{code:0,success:!0,result:n.result,message:""};let a=n.message||n.msg||"Request Error.";return{code:n.code||-1,success:!1,result:null,message:a}}async function YB(e){let t=zB(e);if(!t.success)return{code:t.code,success:!1,message:t.message};let i=new FormData;e.content&&i.append("src",new Blob([e.content]),e.name),i.append("mesh",new Blob([e.model]),"model.obj");let r=await nt("POST",rt.COMPONENT.UPLOAD_3DMODEL,i,{contentType:!1,gzipFormData:!0},!0);if(r.success)return{success:!0,result:r.result};let s=r.message||r.msg||"Request Error.";return{success:!1,code:r.code,message:s}}var Rn=class{};Rn.createDefaultD3modelItem=Lm,Rn.fetchD3ModelItemHandle=md,Rn.updateD3ModelItem=VB,Rn.uploadD3ModelItem=YB,Rn.d3modelInfoVerify=_3,Rn.d3modelInfoTitleVerify=zm,Rn.d3modelInfoDescriptionVerify=O3,Rn.fetchD3ModelListOnLocaleFolder=UB,Rn.fetchD3ModelListBySearchOnLocaleFolder=GB,Rn.fetchD3ModelItemOnLocaleFolder=Cm;function qB(e,t=void 0){let i=null;if(i=m3(e.title),!i.success||(i=b3(e.description),!i.success)||(i=y3(e.attributes),!i.success))return i;let r={code:0,success:!0,message:"",key:"",result:null};return typeof t<"u"&&(t.length<=0||t.length>128)&&(r.code=He.ERR_CODE.NORMAL,r.success=!1,r.message="The title length must be between 1~128 characters!"),r}function m3(e){let t={code:0,success:!0,message:"",key:"",result:null};return(!e||e.length<=0||e.length>128)&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function b3(e){let t={code:0,success:!0,message:"",key:"",result:null};return e&&e.length>255&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="Description should be no more than 255 letters"),t}function y3(e){let t={code:0,success:!0,message:"",key:"",result:null},i=Object.keys(e);for(let r=0;r<i.length;r++){let s=i[r],n=e[s];if(typeof n=="string"&&n.trim().length>255)return t.code=He.ERR_CODE.NORMAL,t.message="{0} should be no more than 255 letters",t.key=s,t}return t}var jh=class{};jh.deviceInfoVerify=qB,jh.deviceInfoTitleVerify=m3,jh.deviceInfoDescriptionVerify=b3,jh.deviceInfoAttributesVerify=y3,jh.fetchDeviceItem=g3;function WB(){return[["DOCTYPE","FOOTPRINT",""],["HEAD",{editorVersion:"dev",importFlag:0}],["CANVAS",0,0,"mm",5,5,5,5,5,5,2,2,5]].map(e=>JSON.stringify(e)).join(`
`)}function XB(e="",t="",i=""){let r=t||"[Empty Footprint Component Item]",s=new Date().getTime(),n=jo(new Date(s)),a={avatar:"",nickname:"",username:"",uuid:""};return{$emptyItem:!0,createTime:s,created_at:n,creator:{...a},dataStr:e,description:"",display_title:r,docType:4,modifier:{...a},owner:{...a},path:He.SYSTEMLIB_UUID,public:!1,source:"",std_uuid:"",tags:{child_tag:null,parent_tag:null},ticket:0,title:r,type:0,updateTime:s,updated_at:n,uuid:i||"",version:""}}function JB(e){let t=null;return t=ZB(e.title),t.success?{code:0,success:!0,message:"",key:void 0,result:null}:t}function ZB(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}var Fp=class{};Fp.footprintInfoVerify=JB,Fp.createEmptyFootprintItem=XB,Fp.createEmptyFootprintDataStr=WB;function KB(e){let t=null;return t=$B(e.title),!t.success||(t=QB(e.docType),!t.success)?t:{code:0,success:!0,message:"",key:void 0,result:null}}function $B(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(!e||e.length<=0||e.length>128)&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="The title length must be between 1~128 characters!"),t}function QB(e){let t={code:0,success:!0,message:"",key:void 0,result:null};return(typeof e>"u"||!e)&&(t.code=He.ERR_CODE.NORMAL,t.success=!1,t.message="Document data abnormality"),t}var v3=class{};v3.symbolInfoVerify=KB;async function ek(e=!1,t,i,r,s=[]){let n={isDuplicate:!1,path:r,uuids:[]},a=i.toLocaleLowerCase(),o=await tg(e,a,r,t,Xe.loginedUserUuid);if(o.success&&o.result&&o.result.length){let l=[];for(let h=0;h<o.result.length;h++){if(s.indexOf(o.result[h].uuid)>=0)continue;let c=(o.result[h].title||o.result[h].display_title).toLocaleLowerCase();if(a===c&&o.result[h].path===r){if(typeof t>"u"||t===28){l.push(o.result[h]);continue}if(typeof o.result[h].docType>"u"){l.push(o.result[h]);continue}if(o.result[h].docType===t){l.push(o.result[h]);continue}}}for(let h=0;h<l.length;h++)n.uuids.push(l[h].uuid);n.isDuplicate=!!n.uuids.length}return n}var tk=(e=>(e.UNZIP="/pro-mgr/unzip",e.EXTRACT="/pro-mgr/unzip/extract",e.FLOW="/pro-mgr/unzip/flow",e.PARSE="/pro-mgr/unzip/parse",e.CHECK="/pro-mgr/unzip/check",e.GET_PROJECT_IN_CLOUD="/pro-mgr/getProjectInCloud",e.GET_PROJECT_IN_LOCAL="/pro-mgr/getProjectInLocal",e.GET_PROJECT_BY_IN_LOCAL="/pro-mgr/getProjectByInLocal",e.EXPORT_ZIP="/pro-mgr/export/zip",e.EXPORT_DOCUMENT="/pro-mgr/export/document",e.EXPORT_DEVICE="/pro-mgr/export/lib/device",e.EXPORT_SYMBOL="/pro-mgr/export/lib/symbol",e.EXPORT_FOOTPRIN="/pro-mgr/export/lib/footprint",e.EXPORT_PANEL_LIB="/pro-mgr/export/lib/panelLib",e.DOWNLOAD_PROJECT="/pro-mgr/export/download/project",e.DOWNLOAD_CBB="/pro-mgr/export/download/cbb",e.DOWNLOAD_DOCUMENT="/pro-mgr/export/download/document",e.BACKUP="/pro-mgr/backup",e.ARCHIVE="/pro-mgr/archive",e.LOAD_FILE="/pro-mgr/loadFile",e.CONVERT_PROJECT="/pro-mgr/convertProject/start",e.CONVERT_PROJECT_FLOWWIRTE="/pro-mgr/convertProject/flowWrite",e.CONVERT_PROJECT_FLOWREAD="/pro-mgr/convertProject/flowRead",e.IMPORT_NEW_PROJECT="/pro-mgr/importNewProject",e.PROJECT_AS_CLOUD="/pro-mgr/projectAsCloud",e.CBB_AS_CLOUD="/pro-mgr/cbbAsCloud",e.DOCUMENT_AS_CLOUD="/pro-mgr/documentAsCloud",e.COMPONENT_AS_CLOUD="/pro-mgr/componentAsCloud",e.IMPORT_TARGET_PROJECT="/pro-mgr/importTargetProject",e.UPDATE_BLOCK_SYMBOL_CONNECT="/pro-mgr/updateBlockSymbolConnect",e.IMPORT_SYMBOLS="/pro-mgr/importSymbols",e.IMPORT_FOOTPRINTS="/pro-mgr/importFootprints",e.IMPORT_DEVICES="/pro-mgr/importDevices",e.COPY_BOARD="/pro-mgr/copyBoards",e.COPY_SCHEMATIC="/pro-mgr/copySchematics",e.COPY_PAGE="/pro-mgr/copyPages",e.COPY_SIMULATION_CANVAS="/pro-mgr/copySimulationCanvas",e.COPY_SCH_CANVAS="/pro-mgr/copySchCanvas",e.COPY_PCB_CANVAS="/pro-mgr/copyPcbCanvas",e.COPY_PANEL_CANVAS="/pro-mgr/copyPanelCanvas",e.PASTE_BOARD="/pro-mgr/pasteBoards",e.PASTE_SCHEMATIC="/pro-mgr/pasteSchematics",e.PASTE_PAGE="/pro-mgr/pastePages",e.PASTE_SCH_TOP="/pro-mgr/pasteSchTop",e.PASTE_PCB="/pro-mgr/pastePcb",e.PASTE_PANEL="/pro-mgr/pastePanel",e.PASTE_SIMULATION="/pro-mgr/pasteSimulation",e.PASTE_SCH_BOTTOM="/pro-mgr/pasteSchBottom",e.BUILD_EXPORT="/pro-mgr/buildExport",e.BUILD_TARGET="/pro-mgr/buildTarget",e.PARSE_PROJECT="/pro-mgr/parseProject",e.COMPARE_LOCAL="/pro-mgr/compare/local",e.COMPARE_CLOUD="/pro-mgr/compare/cloud",e.COMPARE_DESTORY="/pro-mgr/compare/destory",e.UPDATE_REUSE_BLOCK="/pro-mgr/updateReuseBlock",e))(tk||{});async function x3(){let e=await new Promise(t=>{fetch("/api/client/config",{method:"GET"}).then(i=>{i.json().then(r=>{t(r)})})});if(e&&e.success&&e.result){let t=e.result,i=t.projectDir instanceof Array?t.projectDir:[t.projectDir];return{basePath:t.appBaseDir,cbbPath:t.reuseBlock,libPath:t.systemLib,projectPath:i,onlinePrjBackupPath:t.appOnlineBackupDir,appBaseDir:t.appBaseDir,autoCheckVersionUpdate:!!t.checkUpdate,activation:t.activation,appTmpBackupDir:t.appTmpBackupDir,cacheDir:t.cacheDir,proxy:t.proxy,log:t.log}}else return null}function fg(e,t){let i=[],r=[];od?r=e:t&&t.length?r=t:r=e;let s=null;return r.forEach(n=>{n.uuid===He.SYSTEMLIB_UUID?s={title:n.nickname,id:n.uuid,key:He.LIB_SYSTEM_KEY}:i.push({title:n.nickname,id:n.uuid,key:He.LIB_PERSONAL_KEY})}),s&&i.unshift(s),i}async function pg(e,t){let i=fg(e,t)||[],r=[],s=null;return i.forEach((n,a)=>{n.id===He.SYSTEMLIB_UUID?s=a:r.push({title:n.title,id:n.id,key:n.key})}),(s||s===0)&&r.splice(0,0,{title:i[s].title,id:i[s].id,key:i[s].key}),r.splice(1,0,{title:"Project",id:"",key:He.LIB_PROJECT_KEY}),[...r]}async function ik(e,t){let i=await x3();if(!i)return await pg(e,t);let r=fg(e,t),s=_s(r,"id",He.SYSTEMLIB_UUID),n=[];s.index>=0&&n.splice(0,0,{...s.data});let{projectPath:a,cbbPath:o,libPath:l=[],onlinePrjBackupPath:h,autoCheckVersionUpdate:c}=i;return l.forEach(d=>{n.push({title:wv(d),id:d,key:d})}),n.splice(1,0,{title:"Project",id:"",key:He.LIB_PROJECT_KEY}),[...n]}function rk(e,t,i,r){let s=[],n=[],a={},o=[];return e.forEach(l=>{switch(l.titleAdditional=l.title,l.title){case"Project":{if(!r||!i||!i.uuid)return;l.id=i.uuid,o.push(i.uuid);break}default:}l.id||(l.id="@"+sd(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+He.LIB_SPLIT_TAG+a[l.id]):a[l.id]=0,t&&t.indexOf(l.id)>=0&&n.push(l.id),s.push(l)}),{treeData:s,projectsIds:o,selectedIds:n}}async function E3(e,t){let i=fg(e,t)||[],r=[],s=null;return i.forEach((n,a)=>{n.id===He.SYSTEMLIB_UUID?s=a:r.push({title:n.title,id:n.id,key:n.key})}),(s||s===0)&&r.splice(0,0,{title:i[s].title,id:i[s].id,key:i[s].key}),r.splice(1,0,{title:"Project",id:"",key:He.LIB_PROJECT_KEY}),[...r]}async function sk(e,t){let i=await x3();if(!i)return await pg(e,t);let r=[],{projectPath:s,cbbPath:n,libPath:a=[],onlinePrjBackupPath:o,autoCheckVersionUpdate:l}=i;return a.forEach(h=>{r.push({title:wv(h),id:h,key:h})}),r.splice(1,0,{title:"Project",id:"",key:He.LIB_PROJECT_KEY}),[...r]}function nk(e,t,i,r){let s=[],n=[],a={},o=[];return e.forEach(l=>{switch(l.titleAdditional=l.title,l.title){case"Project":{if(!r||!i||!i.uuid)return;l.id=i.uuid,o.push(i.uuid);break}default:}l.id||(l.id="@"+sd(new Date().getTime())),typeof a[l.id]<"u"?(a[l.id]+=1,l.id=l.id+He.LIB_SPLIT_TAG+a[l.id]):a[l.id]=0,t&&t.indexOf(l.id)>=0&&n.push(l.id),s.push(l)}),{treeData:s,projectsIds:o,selectedIds:n}}function w3(e,t){let i=[],r=[];return od?r=e:t&&t.length?r=t:r=e,r.forEach(s=>{i.push({title:s.nickname,id:s.uuid,key:He.LIB_TEMAS_KEY})}),i}async function ig(e,t){let i=w3(e,t);return[{title:"System",id:He.SYSTEMLIB_UUID,key:He.LIB_SYSTEM_KEY},{title:"Project",id:"",key:He.LIB_PROJECT_KEY},{title:"Personal",id:"",key:He.LIB_PERSONAL_KEY},{title:"Favorite",id:He.FAVORITELIB_UUID,key:He.LIB_FAVORITE_KEY},...i]}function T3(e,t,i,r,s){let n=[],a=[],o={},l=[];return e.forEach(h=>{switch(h.title){case"Project":{if(!s||!r||!r.uuid)return;h.id=r.uuid,l.push(r.uuid);break}case"Personal":{if(!i||!i.uuid)return;h.id=i.uuid;break}case"Public":{h.id=He.PUBLICLIB_ALIAS;break}default:}h.id||(h.id="@"+sd(new Date().getTime())),typeof o[h.id]<"u"?(o[h.id]+=1,h.id=h.id+He.LIB_SPLIT_TAG+o[h.id]):o[h.id]=0,t&&t.indexOf(h.id)>=0&&a.push(h.id),n.push(h)}),{treeData:n,projectsIds:l,selectedIds:a}}async function om(e,t){return await ig(e,t)}function ak(e,t,i,r,s){return T3(e,t,i,r,s)}function S3(e,t,i,r,s,n,a){if(!Mn){let l=T3(e,i,r,s,typeof n<"u"?!!n:a);return Sp(l,t),Ip(l)}if(Up){let l=ak(e,i,r,s,typeof n<"u"?!!n:a);return Sp(l,t),Ip(l)}if(Zu){let l=rk(e,i,s,typeof n<"u"?!!n:a);return Sp(l,t),Ip(l)}let o=nk(e,i,s,typeof n<"u"?!!n:a);return Sp(o,t),Ip(o)}function Sp(e,t){let i=_s(e.treeData,"key",He.LIB_SYSTEM_KEY);i.index>=0&&e.treeData.splice(i.index,1);let r=_s(e.treeData,"key",He.LIB_PERSONAL_KEY);r.index>=0&&e.treeData.splice(r.index,1);let s=_s(e.treeData,"key","project");s.index>=0&&e.treeData.splice(s.index,1);let n=_s(e.treeData,"key",He.LIB_FAVORITE_KEY);n.index>=0&&e.treeData.splice(n.index,1);let a=_s(e.treeData,"key","selected");a.index>=0&&e.treeData.splice(a.index,1);let o=_s(e.treeData,"key","oshwhub");o.index>=0&&e.treeData.splice(o.index,1),e.treeData.sort((l,h)=>(l.title||"").localeCompare(h.title||"")),n.index>=0&&e.treeData.unshift(n.data),s.index>=0&&e.treeData.unshift(s.data),t==="Personal"?od||r.index>=0&&e.treeData.unshift(r.data):e.selectedIds=e.selectedIds.filter(l=>{var h;return l!==((h=r==null?void 0:r.data)==null?void 0:h.id)}),o.index>=0&&e.treeData.unshift(o.data),i.index>=0&&e.treeData.unshift(i.data),a.index>=0&&e.treeData.push(a.data)}function Ip(e){return e.selectedIds.length?e.selectedIds:e.selectedIds.push(e.treeData[0].id),e}async function ok(e,t,i,r,s,n,a,o,l=!0,h=!0,c=!0){let d={username:n.username,uuid:n.uuid},{projectId:f,title:u,isCBB:p}=s,g={uuid:f,title:u,isCBB:p},_=await I3(t,a,o,e,i,l),y=S3(_,r,[],d,g,!l),m=[];for(let O=0;O<y.treeData.length;O++){let b=y.treeData[O];b.id===He.SYSTEMLIB_UUID&&h||b.id===He.FAVORITELIB_UUID&&c||(ng||ag||b.key===He.LIB_PERSONAL_KEY&&(b.title=b.titleAdditional=d.username),b.title&&m.push(b))}return m}var lk=(e=>(e.Normal="Normal",e.D3Model="D3Model",e.AssociateDeviceDialog="associateDeviceDialog",e.Cbb="Cbb",e))(lk||{}),za=class{};za.createInitLibList=I3,za.createFixLibList=ok,za.filterInitLibList=S3,za.fetchTeamsLibsFromGVars=w3,za.fetchClientTeamsLibsFromGVars=fg,za.createSourceLibListByWebMode=ig,za.createSourceLibListByOnlineClientMode=om,za.createSourceLibListByOfflineClientMode=E3,za.createSourceLibListByHalfofflineClientMode=pg;async function I3(e,t,i,r,s,n){let a=[];return e==="Normal"?Mn?Up?(a=await om(t,i),n&&Pp(a),a):Zu?(a=await pg(t,i),n&&Pp(a),a):(a=await E3(t,i),n&&Pp(a),a):(a=await ig(t,i),n&&Pp(a),a):e==="D3Model"?Mn?Up?(a=await om(t,i),a):Zu?(a=await ik(t,i),a):(a=await sk(t,i),a):(a=await ig(t,i),a):[]}function Pp(e){let t=_s(e,"key",He.LIB_PROJECT_KEY);t.index>=0&&e.splice(t.index,1)}var UZ=nd(ad());var GZ=nd(ad());var zZ=nd(ad());var Xs=class{};Xs.D3Model=Rn,Xs.Device=jh,Xs.Footprint=Fp,Xs.Symbol=v3,Xs.deleteComponentItem=bE,Xs.deleteComponents=I5,Xs.fetchComponentItem=kB,Xs.queryComponentsByTitle=tg,Xs.pickUpComponentTags2Ids=yE,Xs.pickUpComponentTags2Names=qo,Xs.getDataStrById=Od,Xs.duplicateNameDetection=ek;var vv=class Cl{static async getOldLibByNet(t){try{let{dataStrId:i,dataStr:r}=t;return i||r?{success:!0,result:await Od(t)||""}:{success:!1,message:"Failed to obtain the source code of the existing component library!"}}catch(i){return{success:!1,message:i.message}}}static transform(t,i){let{uuid:r,docType:s}=i,n="";if(s===4){let a=i.isConnectDevice;n=eM(r,t,a)}else s===29?n=aM(r,t,qu.PANEL_LIB):Kp(s)&&(n=rM(r,t).dataStr);return n}static async getOtherLibByNet(t){try{let{isProject:i,uuid:r,path:s,docType:n}=t;if(jM(t)){let h={ignoreDoctypeCheck:!0},c=(await Xs.fetchComponentItem(i,r,s,n,h)).result;t=Object.assign(t,c)}let{history_uuid:a,dataStrId:o,dataStr:l}=t;if(a){let h={path:s,uuid:r,historyUuid:a},c=(await Xe.messageBus.rpcCall(Ja.COMPONENT.GET_HISTORY,h)).message;if(!c.success){let d=["Conversion component format failed!",c.message];return{success:!1,code:c.code,message:d}}return{success:!0,result:(await Xe.messageBus.rpcCall(Ja.COMPONENT.GET_HISTORY_DATA,[c.result])).message}}else if(o||l){let h=await Cl.getOldLibByNet(t);if(!h.success){let f=["Conversion component format failed!",h.message];return{success:!1,code:h.code,message:f}}let c=h.result,d=Cl.transform(c,t);return d?{success:!0,result:d}:{success:!1,message:["Conversion component format failed!","Illegal docType!"]}}else return{success:!0,result:""}}catch(i){return{success:!1,message:i.message}}}static async getOtherLibByWorker(t){try{let i=Ri();return{success:!0,result:await Em(`/${i._TAB_ID_}/libWorker`).rpcCall("/mgr/libWorker/getDataByType",t)}}catch(i){return{success:!1,message:i.message}}}static async getProjectLibByWorker(t){try{let{path:i,uuid:r,docType:s}=t,{message:n}=await Xe.messageBus.rpcCall("/pro-mgr/hasProject",[i]);return n?s===4?{success:!0,result:(await Xe.messageBus.rpcCall(yt.FOOTPRINT.GET_STR,[r,i])).message||""}:Kp(s)?{success:!0,result:(await Xe.messageBus.rpcCall(yt.SYMBOL.GET_STR,[r,i])).message||""}:{success:!1,message:"Api call error! The api does not exist!"}:{success:!1,message:"Get project library data source Project is not open!"}}catch(i){return{success:!1,message:i.message}}}static async getExtendLib(t){var i,r;let{path:s,uuid:n,docType:a}=t,o=$i.getInstance().getLib(s),l;if(a===4?l=await((i=o==null?void 0:o.footprint)==null?void 0:i.getTransformedDetail(n)):l=await((r=o==null?void 0:o.symbol)==null?void 0:r.getTransformedDetail(n)),!(l!=null&&l.dataStr))return{success:!1,message:["Conversion component format failed!","Failed to obtain the source code of the existing component library!"]};let h;return l.dataStr.trim().startsWith("[")?h=Cl.transform(l.dataStr,t):h=l.dataStr,h?{success:!0,result:h}:{success:!1,message:["Conversion component format failed!","Illegal docType!"]}}static async getProLibSource(t){if(typeof window>"u")return await VM(t);try{let{isProject:i,path:r}=t;return $i.getInstance().hasLib(r)?Cl.getExtendLib(t):i?Cl.getProjectLibByWorker(t):Cl.getOtherLibByWorker(t)}catch(i){return{success:!1,message:i.message}}}},hk=(e=>(e.INIT_DB="/CommonDB/initDB",e))(hk||{}),ck=(e=>(e.GET="/CommonDB/project/getData",e.GET_ALL="/CommonDB/project/getAllArrData",e))(ck||{}),uk=(e=>(e.GET="/CommonDB/copyAndPaste/getData",e.SET="/CommonDB/copyAndPaste/setData",e.IS_EXIST="/CommonDB/copyAndPaste/isExist",e.GET_DATA_FROM_PCB_CANVAS="/CommonDB/copyAndPaste/getDataFromPcbCanvas",e))(uk||{}),dk=(e=>(e.GET="/CommonDB/copyAndPasteTableCell/getData",e.SET="/CommonDB/copyAndPasteTableCell/setData",e.IS_EXIST="/CommonDB/copyAndPasteTableCell/isExist",e))(dk||{}),fk=(e=>(e.SET="/CommonDB/log/setData",e.DEL="/CommonDB/log/delData",e.DEL_LOTS="/CommonDB/log/delLotsData",e.GET_ALL="/CommonDB/log/getAllArrData",e))(fk||{}),pk=(e=>(e.SET="/CommonDB/Component/log/setData",e.DEL="/CommonDB/Component/log/delData",e.DEL_LOTS="/CommonDB/Component/log/delLotsData",e.GET_ALL="/CommonDB/Component/log/getAllArrData",e))(pk||{}),gk=(e=>(e.SET="/CommonDB/basicLibraryList/addData",e.GET="/CommonDB/basicLibraryList/getData",e.IS_EXIST="/CommonDB/basicLibraryList/isExist",e))(gk||{}),_k=(e=>(e.SET="/CommonDB/clipBoard/addData",e.GET="/CommonDB/clipBoard/getData",e.IS_EXIST="/CommonDB/clipBoard/isExist",e))(_k||{}),Ok=(e=>(e.GET="/CommonDB/lockPrj/getData",e.READ_WRITE="/CommonDB/lockPrj/readwriteData",e))(Ok||{}),mk=(e=>(e.GET="/CommonDB/prjCache/getData",e.SET="/CommonDB/prjCache/addData",e.DEL="/CommonDB/prjCache/delData",e.DEL_LOTS="/CommonDB/prjCache/delLotsData",e.GET_INDEXS="/CommonDB/prjCache/getAllIndexs",e.GET_COUNT="/CommonDB/prjCache/getCount",e.GET_EARLIEST="/CommonDB/prjCache/getEarliest",e))(mk||{});var bk=(e=>(e.CREATE="/pro-mg/cbb/create",e.DRAW="/pro-mg/cbb/draw",e.GET_EXPORT="/pro-mg/cbb/getExport",e.GET_TARGET="/pro-mg/cbb/getTarget",e.LIST="/pro-mg/cbb/list",e.SEARCH="/pro-mg/cbb/search",e.PLACE="/pro-mg/cbb/place",e))(bk||{}),yk=(e=>(e.GET="/pro-mg/thumb/get",e.UPLOAD="/pro-mg/thumb/upload",e.DELETE="/pro-mg/thumb/delete",e.LIST="/pro-mg/thumb/list",e))(yk||{}),vk=(e=>(e.CREATE="/pro-mgr/new/cloud/create",e.PROJECT="/pro-mgr/new/cloud/project",e.BOARD="/pro-mgr/new/cloud/board",e.SCHEMATIC="/pro-mgr/new/cloud/schematic",e.SHEET="/pro-mgr/new/cloud/sheet",e.SIMULATION="/pro-mgr/new/cloud/simulation",e.PCB="/pro-mgr/new/cloud/pcb",e.PANEL="/pro-mgr/new/cloud/panel",e))(vk||{}),xk=(e=>(e.BOARD="/pro-mgr/new/local/board",e.SCHEMATIC="/pro-mgr/new/local/schematic",e.SHEET="/pro-mgr/new/local/sheet",e.SIMULATION="/pro-mgr/new/local/simulation",e.PCB="/pro-mgr/new/local/pcb",e.PANEL="/pro-mgr/new/local/panel",e))(xk||{});var Ek=(e=>(e.FORCE="/pro-mgr/project/updateData/force",e.SUSPEND="/pro-mgr/project/updateData/suspend",e.RESUME="/pro-mgr/project/updateData/resume",e.GET="/pro-mgr/project/updateData/getLastest",e.IS_PUBLIC="/pro-mgr/project/updateData/isPublic",e.UPDATE_TEAM="/pro-mgr/project/updateData/updateTeam",e))(Ek||{}),wk=(e=>(e.UPDATE="/pro-mgr/project/updateData/schematic/update",e.GET="/pro-mgr/project/updateData/schematic/getData",e.MAP="/pro-mgr/project/updateData/schematic/map",e.NOTIFY="/pro-mgr/project/updateData/schematic/notify",e))(wk||{}),Tk=(e=>(e.UPDATE="/pro-mgr/project/updateData/sheet/update",e.GET="/pro-mgr/project/updateData/sheet/getData",e.MAP="/pro-mgr/project/updateData/sheet/map",e.NOTIFY="/pro-mgr/project/updateData/sheet/notify",e))(Tk||{}),Sk=(e=>(e.UPDATE="/pro-mgr/project/updateData/pcb/update",e.GET="/pro-mgr/project/updateData/pcb/getData",e.MAP="/pro-mgr/project/updateData/pcb/map",e.NOTIFY="/pro-mgr/project/updateData/pcb/notify",e))(Sk||{}),Ik=(e=>(e.UPDATE="/pro-mgr/project/updateData/blockSymbol/update",e.GET="/pro-mgr/project/updateData/blockSymbol/getData",e.MAP="/pro-mgr/project/updateData/blockSymbol/map",e.NOTIFY="/pro-mgr/project/updateData/blockSymbol/notify",e))(Ik||{}),Pk=(e=>(e.UPDATE="/pro-mgr/project/updateData/symbol/update",e.GET="/pro-mgr/project/updateData/symbol/getData",e.MAP="/pro-mgr/project/updateData/symbol/map",e.NOTIFY="/pro-mgr/project/updateData/symbol/notify",e))(Pk||{}),Ak=(e=>(e.UPDATE="/pro-mgr/project/updateData/footprint/update",e.GET="/pro-mgr/project/updateData/footprint/getData",e.MAP="/pro-mgr/project/updateData/footprint/map",e.NOTIFY="/pro-mgr/project/updateData/footprint/notify",e))(Ak||{}),Ck=(e=>(e.UPDATE="/pro-mgr/project/updateData/device/update",e.GET="/pro-mgr/project/updateData/device/getData",e.MAP="/pro-mgr/project/updateData/device/map",e.NOTIFY="/pro-mgr/project/updateData/device/notify",e))(Ck||{});var Lk=(e=>(e.PROGRESS="/pro-ui/progressUpdate",e.OPENED_PROJECT="/pro-ui/project/openedProject",e.HAS_UNSAVED="/pro-ui/project/hasUnsaved",e.OPEN="/pro-ui/project/open",e.CLOSE="/pro-ui/project/close",e.ON_OPENED="/pro-ui/project/onOpened",e.ON_FAILED="/pro-mgr/project/onFailed",e.ON_CLOSED="/pro-ui/project/onClosed",e.ADD_HASH="/pro-ui/hash/add/id",e.REMOVE_HASH="/pro-ui/hash/remove/id",e))(Lk||{}),Dk=(e=>(e.ON_UPDATE="/pro-mgr/project/project/onUpdate",e.UPLOAD_FAILED="/pro-mgr/project/upload/onfailed",e))(Dk||{}),Rk=(e=>(e.ON_UPDATE="/pro-mgr/project/config/onUpdate",e))(Rk||{}),Nk=(e=>(e.ON_ADD="/pro-mgr/project/board/onAdd",e.ON_DELETE="/pro-mgr/project/board/onDelete",e.ON_UPDATE="/pro-mgr/project/board/onUpdate",e))(Nk||{}),Mk=(e=>(e.ON_ADD="/pro-mgr/project/schematic/onAdd",e.ON_DELETE="/pro-mgr/project/schematic/onDelete",e.ON_UPDATE="/pro-mgr/project/schematic/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/schematic/onUpdateTime",e))(Mk||{}),Bk=(e=>(e.ON_ADD="/pro-mgr/project/sheet/onAdd",e.ON_DELETE="/pro-mgr/project/sheet/onDelete",e.ON_UPDATE="/pro-mgr/project/sheet/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/sheet/onUpdateTime",e))(Bk||{}),kk=(e=>(e.ON_ADD="/pro-mgr/project/pcb/onAdd",e.ON_DELETE="/pro-mgr/project/pcb/onDelete",e.ON_UPDATE="/pro-mgr/project/pcb/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/pcb/onUpdateTime",e))(kk||{}),Fk=(e=>(e.ON_ADD="/pro-mgr/project/panel/onAdd",e.ON_DELETE="/pro-mgr/project/panel/onDelete",e.ON_UPDATE="/pro-mgr/project/panel/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/panel/onUpdateTime",e))(Fk||{}),Uk=(e=>(e.ON_ADD="/pro-mgr/project/simulation/onAdd",e.ON_DELETE="/pro-mgr/project/simulation/onDelete",e.ON_UPDATE="/pro-mgr/project/simulation/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/simulation/onUpdateTime",e))(Uk||{}),Gk=(e=>(e.ON_ADD="/pro-mgr/project/device/onAdd",e.ON_DELETE="/pro-mgr/project/device/onDelete",e.ON_UPDATE="/pro-mgr/project/device/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/device/onUpdateTime",e))(Gk||{}),zk=(e=>(e.ON_ADD="/pro-mgr/project/symbol/onAdd",e.ON_DELETE="/pro-mgr/project/symbol/onDelete",e.ON_UPDATE="/pro-mgr/project/symbol/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/symbol/onUpdateTime",e))(zk||{}),Hk=(e=>(e.ON_ADD="/pro-mgr/project/footprint/onAdd",e.ON_DELETE="/pro-mgr/project/footprint/onDelete",e.ON_UPDATE="/pro-mgr/project/footprint/onUpdate",e.ON_UPDATETIME="/pro-mgr/project/footprint/onUpdateTime",e))(Hk||{}),jk=(e=>(e.ON_ADD="/pro-mgr/project/attr/onAdd",e.ON_DELETE="/pro-mgr/project/attr/onDelete",e.ON_UPDATE="/pro-mgr/project/attr/onUpdate",e))(jk||{}),Vk=(e=>(e.ON_ADD="/pro-mgr/project/blob/onAdd",e.ON_DELETE="/pro-mgr/project/blob/onDelete",e.ON_UPDATE="/pro-mgr/project/blob/onUpdate",e))(Vk||{}),Yk=(e=>(e.ON_ADD="/pro-mgr/project/variant/onAdd",e.ON_DELETE="/pro-mgr/project/variant/onDelete",e.ON_UPDATE_TITLE="/pro-mgr/project/variant/onUpdatetitle",e.ON_UPDATE_NOT_GROUPED="/pro-mgr/project/variant/onUpdateNotGrouped",e.ON_UPDATE_ZINDEX="/pro-mgr/project/variant/onUpdateZIndex",e.ON_ADD_COMPONENT_GROUP="/pro-mgr/project/variant/onAddComponentGroup",e.ON_DELETE_COMPONENT_GROUP="/pro-mgr/project/variant/onDeleteComponentGroup",e.ON_UPDATE_COMPONENT_GROUP_TITLE="/pro-mgr/project/variant/onUpdateComponentGroupTitle",e.ON_UPDATE_COMPONENT_GROUP_ZINDEX="/pro-mgr/project/variant/onUpdateComponentGroupZIndex",e.ON_UPLOAD_COMPONENT_GROUP_INDEX_IN_VARIANT="/pro-mgr/project/variant/onUploadComponentGroupZIndexInVariant",e.ON_DELETE_COMPONENT_GROUP_INDEX_IN_VARIANT="/pro-mgr/project/variant/onDeleteComponentGroupZIndexInVariant",e.ON_UPLOAD_COMPONENT_GROUP_DATA="/pro-mgr/project/variant/onUploadComponentGroupData",e.ON_DELETE_COMPONENT_GROUP_DATA="/pro-mgr/project/variant/onDeleteComponentGroupData",e))(Yk||{});var HZ=new Error("list is empty");var qk=(e=>(e.ALL_VALUE="@all",e.ALL_TITLE="All",e.ComponentSymbol="2",e.NetflagSymbol="18",e.NetportSymbol="19",e.DrawingSymbol="20",e.NonElectronicSymbol="21",e.OffPageConnectorSymbol="25",e.DiffPairsFlagSymbol="31",e))(qk||{});var Wk=class{};Wk.syncLoginedUserInfo=e=>{Xe.loginedUserUuid=e.uuid};var Xk=(e=>(e.PROJECT="project.json",e.DEVICE="device.json",e.SYMBOL="symbol.json",e.FOOTPRINT="footprint.json",e.PANEL_LIB="panel-lib.json",e.PROJECT2="project2.json",e.DEVICE2="device2.json",e.SYMBOL2="symbol2.json",e.FOOTPRINT2="footprint2.json",e.PANEL_LIB2="panel-lib2.json",e))(Xk||{});YC();var{IS_CLIENT:Hm,IS_LCEDA:_ee,IS_EASYEDA:Oee,IS_ONLINE:mee,IS_OFFLINE:bee,IS_HALF_OFFLINE:yee,IS_PRIVATE:vee,HAS_SCH:xee,IS_ENTERPRISE_CLIENT:Eee}=hm;var Jk=Object.create,pw=Object.defineProperty,Zk=Object.getOwnPropertyDescriptor,Kk=Object.getOwnPropertyNames,$k=Object.getPrototypeOf,Qk=Object.prototype.hasOwnProperty,P3=(e=>typeof dr<"u"?dr:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof dr<"u"?dr:t)[i]}):e)(function(e){if(typeof dr<"u")return dr.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Zt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),e8=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Kk(t))!Qk.call(e,s)&&s!==i&&pw(e,s,{get:()=>t[s],enumerable:!(r=Zk(t,s))||r.enumerable});return e},Cc=(e,t,i)=>(i=e!=null?Jk($k(e)):{},e8(t||!e||!e.__esModule?pw(i,"default",{value:e,enumerable:!0}):i,e)),Hd=Zt((e,t)=>{"use strict";var i=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a=(w,B)=>{for(var V in B)i(w,V,{get:B[V],enumerable:!0})},o=(w,B,V,Y)=>{if(B&&typeof B=="object"||typeof B=="function")for(let W of s(B))!n.call(w,W)&&W!==V&&i(w,W,{get:()=>B[W],enumerable:!(Y=r(B,W))||Y.enumerable});return w},l=w=>o(i({},"__esModule",{value:!0}),w),h={};a(h,{BroadcastChannelMessageBus:()=>he,MessageBus:()=>x,MessageBus2:()=>Z,MessageBusTask:()=>R,MessageBusTask2:()=>G,WindowMessageBridge:()=>L,WorkerMessageBridge:()=>j,createBroadcastP2PStream:()=>de,createBufferedByteBufferStream:()=>ie,createBufferedStream:()=>q,createBufferedStringStream:()=>X,dropP2PStream:()=>Ce,flowRead:()=>Pe,flowWrite:()=>Fe}),t.exports=l(h);var c=class{constructor(w=1.5){this.growthFactor=w,this.capacity=10,this.buffer=new Array(this.capacity),this.head=0,this.tail=0,this.count=0}enqueue(w){if(this.count===this.capacity){let B=Math.floor(this.capacity*this.growthFactor);console.log("grow",this.capacity,B);let V=new Array(B);for(let Y=0;Y<this.count;Y++)V[Y]=this.buffer[(this.head+Y)%this.capacity];this.buffer=V,this.head=0,this.tail=this.count,this.capacity=B}this.buffer[this.tail]=w,this.tail=(this.tail+1)%this.capacity,this.count++}dequeue(){if(this.isEmpty())return;let w=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,w}peek(){return this.buffer[this.head]}isEmpty(){return this.count===0}clear(){this.buffer.length=0,this.head=0,this.tail=0,this.count=0}},d=new ArrayBuffer(8),f=new Float64Array(d),u=new Uint32Array(d),p=new Uint16Array(d),g=ArrayBuffer;try{g=self.HTMLImageElement||g}catch{}var _=typeof SharedArrayBuffer<"u";function y(w){if(typeof w!="object"||w===null||w instanceof Date||w instanceof ArrayBuffer||_&&w instanceof SharedArrayBuffer||w instanceof Blob||w instanceof FormData||w instanceof Function||w instanceof Uint8ClampedArray||w instanceof g)return w;if(Array.isArray(w))return w.map(y);{let B={};for(let V in w)Object.hasOwnProperty.call(w,V)&&(B[V]=y(w[V]));return B}}function m(w,B){return O(w,B,()=>[])}function O(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var b=class{constructor(w){this.maxResources=w,this.idle=new c,this.isClosed=!1,this.resources=w}acquire(w){this.isClosed?Promise.resolve(!1).then(w):this.resources>0?(this.resources--,Promise.resolve(!0).then(w)):this.idle.enqueue(w)}acquireSync(){return new Promise(w=>{this.acquire(w)})}release(){if(!this.isClosed){let w=this.idle.dequeue();w?Promise.resolve(!0).then(w):this.resources++}}close(){if(!this.isClosed)for(this.isClosed=!0;!this.idle.isEmpty();){let w=this.idle.dequeue();Promise.resolve(!1).then(w)}}};function v(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}function E(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}var T=v(),P=T.WeakRef||(w=>w);function A(w){if(w!=null){if(typeof w=="object")return new P(w);console.error(w,w instanceof Object,typeof w);return}}function C(w){return w==null?void 0:w.deref()}var M="_MSG_BUS_RPC_",H=300*1e3,k=(w=>(w.PUBLISH="publish",w.SUBSCRIBE="subscribe",w.PUSH="push",w.PULL="pull",w))(k||{}),F=class{constructor(w){this.bus=w}processRemoteMessage(w,B){let V=A(B),Y=w.topic,W=w.type,ne=w.message;switch(W){case"pull":this.bus.pull(Y,ue=>{this.push(Y,ue,C(V))});break;case"subscribe":this.bus.subscribe(Y,ue=>{this.publish(Y,ue,C(V))});break;case"publish":this.bus.publish(Y,ne,this,C(V));break;case"push":this.bus.push(Y,ne,this,C(V));break;default:console.debug("unknown message type "+W)}}rpcCall(w,B,V,Y=H){let W=A(V),ne=new Promise(ue=>{let Re=this.bus.uniqueRpcTopic(w);this.publish(w,{message:B,reply:Re},C(W)),this.bus.pull(Re,(Ue,je,dt)=>{ue({message:Ue,bridge:je,source:A(dt)})})});return Y>0?Promise.race([ne,new Promise((ue,Re)=>{setTimeout(Re,Y)})]):ne}},j=class extends F{constructor(w,B){super(w),this.worker=B,B.onmessage=V=>{this.processRemoteMessage(V.data,void 0)}}publish(w,B){this.postMessage(w,"publish",B)}subscribe(w){this.postMessage(w,"subscribe",null)}push(w,B){this.postMessage(w,"push",B)}pull(w){this.postMessage(w,"pull",null)}rpcCall(w,B,V=H){return super.rpcCall(w,B,void 0,V)}postMessage(w,B,V){let Y={topic:w,type:B,message:V};this.worker.postMessage(Y)}discard(){this.worker.terminate()}},L=class extends F{constructor(w){super(w),window.addEventListener("message",B=>{this.processRemoteMessage(B.data,B.source)},!1)}publish(w,B,V){this.postMessage(w,"publish",B,V)}subscribe(w,B){if(B===window)throw new Error("regist remote subscribe from current window is not permitted");this.postMessage(w,"subscribe",null,B)}push(w,B,V){this.postMessage(w,"push",B,V)}pull(w,B){if(B===window)throw new Error("regist remote pull from current window is not permitted");this.postMessage(w,"pull",null,B)}postMessage(w,B,V,Y){let W={topic:w,type:B,message:V};Y&&Y.postMessage(W,"*")}},R=class{constructor(w){this.isRunning=!0,this.callback=w}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}execute(w,B,V,Y){try{w=Y?w:y(w),this.callback(w,B,V)}catch(W){console.error(W)}}},x=class{constructor(w=!1){this.subscribed={},this.pulled={},this.pushed={},this.uuid=crypto.randomUUID().replace(/-/g,""),this.rpcTicket=0,this.unsafe=w}uniqueRpcTopic(w){return`${M}-${w}-${this.uuid}-${this.rpcTicket++}`}publish(w,B,V,Y){let W=this.subscribed[w];if(W){let ne;for(let ue of W)ue.running()?ue.execute(B,V,Y,this.unsafe):(ne=ne||new Array,ne.push(ue));if(ne)for(let ue of ne)E(W,ue)}else console.debug("no sub on topic: "+w)}subscribe(w,B){let V=new R(B);return m(this.subscribed,w).push(V),V}push(w,B,V,Y){let W=!1,ne=this.pulled[w];if(ne){for(;ne.length>0;){let ue=ne.shift();if(ue.running()){ue.execute(B,V,Y,this.unsafe),W=!0;break}}ne.length===0&&delete this.pulled[w]}W||m(this.pushed,w).push({message:B,bridge:V,source:A(Y)})}pull(w,B){let V=new R(B),Y=this.pushed[w];if(Y){let W=Y.shift();V.execute(W.message,W.bridge,C(W.source),this.unsafe),Y.length===0&&delete this.pushed[w]}else m(this.pulled,w).push(V);return V}pullA(w){return new Promise(B=>{this.pull(w,(V,Y,W)=>{B({message:V,bridge:Y,source:A(W)})})})}rpcService(w,B){this.subscribe(w,(V,Y,W)=>{let{message:ne,reply:ue}=V;try{let Re=B(ne);if(Re instanceof Promise){let Ue=A(W);Re.then(je=>{this.rpcReply(je,ue,Y,C(Ue))},je=>{console.error(je),this.rpcReply(void 0,ue,Y,C(Ue))})}else this.rpcReply(Re,ue,Y,W)}catch(Re){console.error(Re),this.rpcReply(void 0,ue,Y,W)}})}rpcCall(w,B,V=H){let Y=new Promise(W=>{let ne=this.uniqueRpcTopic(w);this.publish(w,{message:B,reply:ne}),this.pull(ne,(ue,Re,Ue)=>{W({message:ue,bridge:Re,source:A(Ue)})})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}rpcReply(w,B,V,Y){V?V.push(B,w,Y):this.push(B,w)}},I="_MSG_BUS_RPC_";function S(w,B){let V=0,Y=w.length;for(let W=0;W<Y;W++)w[W]===B&&(w.splice(W,1),W--,Y--,V++);return V}function D(w,B){return N(w,B,()=>[])}function N(w,B,V){let Y=w[B];return Y!==void 0||(Y=V(B),w[B]=Y),Y}var G=class{constructor(w,B){this.callback=w,this.unsafe=B,this.isRunning=!0}cancel(){this.callback=null,this.isRunning=!1}running(){return this.isRunning}async execute(w){try{w=this.unsafe?w:y(w),this.callback(w)}catch(B){console.error(B)}}},z=class{constructor(w=crypto.randomUUID()){this.uuid=w,this.rpcTicket=0}subscribeOnce(w,B){let V=this.subscribe(w,Y=>{V.cancel(),B(Y)});return V}pullA(w){return new Promise(B=>{this.pull(w,B)})}rpcService(w,B){let V=Y=>{try{let{message:W,replyTopic:ne}=Y;try{let ue=B(W);ue instanceof Promise?ue.then(Re=>{this.publish(ne,{success:!0,result:Re})}).catch(Re=>{console.error(Re),this.publish(ne,{success:!1,err:String(Re)})}):this.publish(ne,{success:!0,result:ue})}catch(ue){this.publish(ne,{success:!1,err:String(ue)})}}finally{this.pull(w,V)}};this.pull(w,V)}rpcCall(w,B,V=0){let Y=new Promise((W,ne)=>{let ue=`${I}-${w}-${this.uuid}-${this.rpcTicket++}`;this.subscribeOnce(ue,Re=>{Re.success?W(Re.result):ne(new Error(Re.err))}),this.push(w,{message:B,replyTopic:ue})});return V>0?Promise.race([Y,new Promise((W,ne)=>{setTimeout(ne,V)})]):Y}},Z=class extends z{constructor(w=!1){super(),this.unsafe=w,this.subscribed={},this.pulled={},this.pushed={}}publish(w,B){let V=this.subscribed[w];if(V){let Y;for(let W of V)W.running()?W.execute(B):(Y=Y||new Array,Y.push(W));if(Y)for(let W of Y)S(V,W)}}subscribe(w,B){let V=new G(B,this.unsafe);return D(this.subscribed,w).push(V),V}push(w,B){let V=!1,Y=this.pulled[w];if(Y){for(;Y.length>0;){let W=Y.shift();if(W&&W.running()){W.execute(B),V=!0;break}}Y.length===0&&delete this.pulled[w]}V||D(this.pushed,w).push(B)}pull(w,B){let V=new G(B,this.unsafe);return this.repull(w,V),V}repull(w,B){let V=this.pushed[w];if(V){let Y=V.shift();Y&&(B.execute(Y),V.length===0&&delete this.pushed[w])}else D(this.pulled,w).push(B)}},se=class extends z{constructor(w=crypto.randomUUID()){super(w),this.subscribed={},this.pushed={},this.pulled={},this.pushCnt=0}publish(w,B){console.debug("BC",this.uuid,"PUBLISH",w,B),this.broadcastPublish(w,B)}subscribe(w,B){console.debug("BC",this.uuid,"SUBSCRIBE",w);let V=new G(B,!0);return D(this.subscribed,w).push(V),V}push(w,B){let V=this.pushCnt++;console.debug("BC",this.uuid,"PUSH",w,`(${V})`,B),D(this.pushed,w).push({id:V,message:B}),this.broadcastPushedHeadMessage(w)}pull(w,B){console.debug("BC",this.uuid,"PULL",w);let V=new G(B,!0);return D(this.pulled,w).push(V),this.broadcastWhoHas(w),V}broadcastPushedHeadMessage(w){let B=this.pushed[w];B&&B[0]&&this.broadcastIHave(w,B[0].id)}onReceivedPublish(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"PUBLISH",B,"message",V);let Y=this.subscribed[B];if(Y){let W;for(let ne of Y)ne.running()?ne.execute(V):(W=W||new Array,W.push(ne));if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.subscribed[B]}}onReceivedWhoHas(w,B){console.debug("BCMSG(",this.uuid,")","from",w,"WHOHAS",B),this.broadcastPushedHeadMessage(B)}onReceivedIHave(w,B,V){console.debug("BCMSG(",this.uuid,")","from",w,"IHAVE",B,"id",V);let Y=this.pulled[B];if(Y){let W;for(let ne of Y)if(ne.running()){this.broadcastINeed(B,w,V);break}else W=W||new Array,W.push(ne);if(W)for(let ne of W)S(Y,ne);Y.length===0&&delete this.pulled[B]}}onReceivedINeed(w,B,V,Y){if(console.debug("BCMSG(",this.uuid,")","from",w,"INEED",B,"source",V,"id",Y),this.uuid===V){let W=this.pushed[B];if(W&&W[0]&&W[0].id===Y){let{message:ne}=W.shift();this.broadcastIGive(B,Y,w,ne),this.broadcastPushedHeadMessage(B),W.length===0&&delete this.pushed[B]}}}onReceivedIGive(w,B,V,Y,W){console.debug("BCMSG(",this.uuid,")","from",w,"IGIVE",B,"id",V,"target",Y,"message",W);let ne=this.pulled[B];if(ne&&this.uuid===Y){let ue=!1;for(;ne.length>0;){let Re=ne.shift();if(Re.running()){Re.execute(W),ue=!0;break}}ue||this.push(B,W),ne.length===0&&delete this.pulled[B]}}},he=class extends se{constructor(w,B=crypto.randomUUID()){super(B),this.bc=new BroadcastChannel(w),this.bc.onmessage=V=>{this.onMessage(V.data)}}onMessage(w){let{type:B,uuid:V,topic:Y}=w;switch(B){case"PUBLISH":{let{message:W}=w;this.onReceivedPublish(V,Y,W);break}case"WHOHAS":{this.onReceivedWhoHas(V,Y);break}case"IHAVE":{let{id:W}=w;this.onReceivedIHave(V,Y,W);break}case"INEED":{let{source:W,id:ne}=w;this.onReceivedINeed(V,Y,W,ne);break}case"IGIVE":{let{target:W,id:ne,message:ue}=w;this.onReceivedIGive(V,Y,ne,W,ue);break}default:console.warn("unsupported",w)}}broadcastPublish(w,B){this.post({type:"PUBLISH",uuid:this.uuid,topic:w,message:B})}broadcastWhoHas(w){this.post({type:"WHOHAS",uuid:this.uuid,topic:w})}broadcastIHave(w,B){this.post({type:"IHAVE",uuid:this.uuid,topic:w,id:B})}broadcastINeed(w,B,V){this.post({type:"INEED",uuid:this.uuid,topic:w,source:B,id:V})}broadcastIGive(w,B,V,Y){this.post({type:"IGIVE",uuid:this.uuid,topic:w,id:B,target:V,message:Y})}post(w){this.bc.postMessage(w),Promise.resolve().then(()=>{this.onMessage(w)})}},pe=Symbol("BLOCKING_QUEUE_RESET"),Se=class{constructor(w,B=()=>1){if(this.maxSize=w,this.itemSizeOf=B,this.queue=new c,this.waitingConsumers=new c,this.waitingProducers=new c,this.queueSize=0,this.closePromise=null,this.closeResolve=null,w<=0)throw new Error("Max size must be greater than 0")}enqueue(w){return this.closePromise?!1:this.isFull()?(async()=>{console.debug("queue is full",this.queueSize,this.maxSize);let B=await new Promise(V=>{this.waitingProducers.enqueue(V)});return console.debug("queue is not full",this.size(),B),B?(this.innerEnqueue(w),!0):!1})():(this.innerEnqueue(w),!0)}innerEnqueue(w){if(this.waitingConsumers.isEmpty())this.queue.enqueue(w),this.queueSize+=this.itemSizeOf(w),console.debug("queue pushed",w,"size",this.queueSize);else{let B=this.waitingConsumers.dequeue();Promise.resolve(w).then(B),console.debug("queue direct",w,"size",this.queueSize)}}dequeue(){if(this.queue.isEmpty())if(this.closePromise){for(;!this.waitingConsumers.isEmpty();){let w=this.waitingConsumers.dequeue();Promise.resolve(pe).then(w)}return setTimeout(()=>this.closeResolve(),0),pe}else return new Promise(w=>{this.waitingConsumers.enqueue(w)});else{let w=this.queue.dequeue();if(this.queueSize-=this.itemSizeOf(w),!this.waitingProducers.isEmpty()){let B=this.waitingProducers.dequeue();Promise.resolve(!0).then(B)}return w}}size(){return this.queueSize}isEmpty(){return this.queueSize===0}isFull(){return this.queueSize>=this.maxSize}close(){return this.closePromise||(this.closePromise=new Promise(w=>{for(this.closeResolve=w;!this.waitingProducers.isEmpty();){let B=this.waitingProducers.dequeue();Promise.resolve(!1).then(B)}if(this.queueSize===0){for(;!this.waitingConsumers.isEmpty();){let B=this.waitingConsumers.dequeue();Promise.resolve(pe).then(B)}w()}})),this.closePromise}};function q(w,B,V=Number.MAX_SAFE_INTEGER){let Y=new Se(V,B),W=new ReadableStream({pull(ue){let Re=!0,Ue=(async()=>{let je=new Array;do{let dt=Y.dequeue();if(dt instanceof Promise){Re=!1;let Ot=await dt;Ot===pe?ue.close():je.push(Ot)}else{let Ot=dt;Ot===pe?ue.close():je.push(Ot)}}while(Y.size()>0);if(je.length>0){let dt=w(je);ue.enqueue(dt)}})();if(!Re)return console.debug("read stream stucked --------------------------------------"),Ue},async cancel(){console.debug("buffered readable cancel"),await Y.close()}}),ne=new WritableStream({write(ue,Re){let Ue=!0,je=(async()=>{let dt=Y.enqueue(ue);typeof dt=="boolean"?dt||Re.error(new Error("Write stream closed")):(Ue=!1,await dt||Re.error(new Error("Write stream closed")))})();if(!Ue)return console.debug("read stream stucked >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"),je},async close(){console.debug("buffered writable closing",Y.size()),await Y.close(),console.debug("buffered writable closed",Y.size())},async abort(){console.debug("buffered writable aborting",Y.size()),await Y.close(),console.debug("buffered writable aborted",Y.size())}});return{readable:W,writable:ne}}function X(w=Number.MAX_SAFE_INTEGER){return q(B=>B.join(""),B=>B.length,w)}function ie(w=Number.MAX_SAFE_INTEGER){return q(B=>{let V=new Uint8Array(B.reduce((W,ne)=>W+ne.byteLength,0)),Y=0;return B.forEach(W=>{V.set(W,Y),Y+=W.byteLength}),V},B=>B.byteLength,w)}function de(w){return new Promise((B,V)=>{let Y=new BroadcastChannel(w),W=new Se(1),ne=new b(1),ue=null,Re=!1,Ue=!1,je=!1;Y.onmessage=dt=>{let Ot=dt.data,{type:Lt}=Ot;if(console.debug("p2p",w,"type",Lt,"data",Lt==="DATA"&&Ot.data),Lt==="DATA")W.enqueue(Ot.data);else if(Lt==="HI"){if(!ue){Y.postMessage({type:"HI"});let Ge=0;ue={rs:new ReadableStream({async pull(qe){let me=await W.dequeue();me===pe?(await Q(),qe.close()):(qe.enqueue(me),Y.postMessage({type:"ACK"}))},cancel(){return Q()}}),ws:new WritableStream({async write(qe,me){await ne.acquireSync()?Y.postMessage({type:"DATA",id:Ge++,data:qe}):(hi(),me.error(new Error("Write stream closed")))},close(){hi()},abort(){hi()}})},B(ue)}}else Lt==="REND"?ue?ne.close():ke("REND1"):Lt==="WEND"?ue?W.close():ke("WEND1"):Lt==="ACK"&&ne.release();function hi(){Re||(Re=!0,console.debug(w,"p2p write stream closed"),ne.close(),Y.postMessage({type:"WEND"}),Ue&&(console.debug(w,"p2p channel closed on ws"),Y.close()))}async function Q(){Ue||(Ue=!0,console.debug(w,"p2p read stream closed"),Y.postMessage({type:"REND"}),await W.close(),Re&&(console.debug(w,"p2p channel closed on rs"),Y.close()))}async function ke(Ge){je||(je=!0,console.debug(w,"p2p channel connection released on",Ge),ne.close(),W.close(),ue?(ue.rs.locked||(console.debug(w,"p2p unlocked read stream direct cancel"),ue.rs.cancel()),ue.ws.locked||(console.debug(w,"p2p unlocked write stream direct close"),ue.ws.close())):(Y.postMessage({type:"HI"}),Y.close()),V(new Error("p2p channel connection released")))}},Y.postMessage({type:"HI"})})}function Ce(w){return new Promise(B=>{let V=new BroadcastChannel(w);V.onmessage=Y=>{let W=Y.data,{type:ne}=W;ne==="HI"&&(V.postMessage({type:"REND"}),V.close(),B())},V.postMessage({type:"REND"})})}async function De(w){try{return await de(w)}catch(B){B.message!=="p2p channel connection released"&&console.error(B)}}async function Fe(w,B,V=10*1024*1024,Y=!0){let W=await De(w);if(!W)return!1;let ne=!1;try{let ue,Re=Ue=>{if(!ue)if(!Y)ue=W.ws.getWriter();else if(typeof Ue=="string"){let je=X(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}else{let je=ie(V);je.readable.pipeTo(W.ws),ue=je.writable.getWriter()}return ue.write(Ue)};if(Array.isArray(B))for(let Ue of B)await Re(Ue);else await B({write:Re,get desiredSize(){return((ue==null?void 0:ue.desiredSize)||0)+10}});ue&&await ue.close(),ne=!0}catch(ue){console.error(ue)}finally{return W.rs.cancel(),ne}}async function Pe(w,B){var V,Y;let W=await De(w);if(W)try{let ne=W.rs.getReader();for((V=B.start)==null?void 0:V.call(B);;){let{value:ue,done:Re}=await ne.read();if(ue!==void 0){let Ue;if(B.update instanceof Promise?Ue=await B.update(ue):Ue=B.update(ue),Ue){await ne.cancel();break}}if(Re){(Y=B.end)==null||Y.call(B);break}}}catch(ne){console.error(ne)}finally{W.ws.close()}}}),ii=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r():typeof define=="function"&&define.amd?define([],r):i.CryptoJS=r()})(e,function(){var i=i||(function(r,s){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof P3=="function")try{n=P3("crypto")}catch{}var a=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function O(){}return function(b){var v;return O.prototype=b,v=new O,O.prototype=null,v}})(),l={},h=l.lib={},c=h.Base=(function(){return{extend:function(O){var b=o(this);return O&&b.mixIn(O),(!b.hasOwnProperty("init")||this.init===b.init)&&(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var O=this.extend();return O.init.apply(O,arguments),O},init:function(){},mixIn:function(O){for(var b in O)O.hasOwnProperty(b)&&(this[b]=O[b]);O.hasOwnProperty("toString")&&(this.toString=O.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),d=h.WordArray=c.extend({init:function(O,b){O=this.words=O||[],b!=s?this.sigBytes=b:this.sigBytes=O.length*4},toString:function(O){return(O||u).stringify(this)},concat:function(O){var b=this.words,v=O.words,E=this.sigBytes,T=O.sigBytes;if(this.clamp(),E%4)for(var P=0;P<T;P++){var A=v[P>>>2]>>>24-P%4*8&255;b[E+P>>>2]|=A<<24-(E+P)%4*8}else for(var C=0;C<T;C+=4)b[E+C>>>2]=v[C>>>2];return this.sigBytes+=T,this},clamp:function(){var O=this.words,b=this.sigBytes;O[b>>>2]&=4294967295<<32-b%4*8,O.length=r.ceil(b/4)},clone:function(){var O=c.clone.call(this);return O.words=this.words.slice(0),O},random:function(O){for(var b=[],v=0;v<O;v+=4)b.push(a());return new d.init(b,O)}}),f=l.enc={},u=f.Hex={stringify:function(O){for(var b=O.words,v=O.sigBytes,E=[],T=0;T<v;T++){var P=b[T>>>2]>>>24-T%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16))}return E.join("")},parse:function(O){for(var b=O.length,v=[],E=0;E<b;E+=2)v[E>>>3]|=parseInt(O.substr(E,2),16)<<24-E%8*4;return new d.init(v,b/2)}},p=f.Latin1={stringify:function(O){for(var b=O.words,v=O.sigBytes,E=[],T=0;T<v;T++){var P=b[T>>>2]>>>24-T%4*8&255;E.push(String.fromCharCode(P))}return E.join("")},parse:function(O){for(var b=O.length,v=[],E=0;E<b;E++)v[E>>>2]|=(O.charCodeAt(E)&255)<<24-E%4*8;return new d.init(v,b)}},g=f.Utf8={stringify:function(O){try{return decodeURIComponent(escape(p.stringify(O)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(O){return p.parse(unescape(encodeURIComponent(O)))}},_=h.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(O){typeof O=="string"&&(O=g.parse(O)),this._data.concat(O),this._nDataBytes+=O.sigBytes},_process:function(O){var b,v=this._data,E=v.words,T=v.sigBytes,P=this.blockSize,A=P*4,C=T/A;O?C=r.ceil(C):C=r.max((C|0)-this._minBufferSize,0);var M=C*P,H=r.min(M*4,T);if(M){for(var k=0;k<M;k+=P)this._doProcessBlock(E,k);b=E.splice(0,M),v.sigBytes-=H}return new d.init(b,H)},clone:function(){var O=c.clone.call(this);return O._data=this._data.clone(),O},_minBufferSize:0}),y=h.Hasher=_.extend({cfg:c.extend(),init:function(O){this.cfg=this.cfg.extend(O),this.reset()},reset:function(){_.reset.call(this),this._doReset()},update:function(O){return this._append(O),this._process(),this},finalize:function(O){O&&this._append(O);var b=this._doFinalize();return b},blockSize:512/32,_createHelper:function(O){return function(b,v){return new O.init(v).finalize(b)}},_createHmacHelper:function(O){return function(b,v){return new m.HMAC.init(O,v).finalize(b)}}}),m=l.algo={};return l})(Math);return i})}),Jg=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.Base,o=n.WordArray,l=s.x64={},h=l.Word=a.extend({init:function(d,f){this.high=d,this.low=f}}),c=l.WordArray=a.extend({init:function(d,f){d=this.words=d||[],f!=r?this.sigBytes=f:this.sigBytes=d.length*8},toX32:function(){for(var d=this.words,f=d.length,u=[],p=0;p<f;p++){var g=d[p];u.push(g.high),u.push(g.low)}return o.create(u,this.sigBytes)},clone:function(){for(var d=a.clone.call(this),f=d.words=this.words.slice(0),u=f.length,p=0;p<u;p++)f[p]=f[p].clone();return d}})})(),i})}),t8=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){if(typeof ArrayBuffer=="function"){var r=i,s=r.lib,n=s.WordArray,a=n.init,o=n.init=function(l){if(l instanceof ArrayBuffer&&(l=new Uint8Array(l)),(l instanceof Int8Array||typeof Uint8ClampedArray<"u"&&l instanceof Uint8ClampedArray||l instanceof Int16Array||l instanceof Uint16Array||l instanceof Int32Array||l instanceof Uint32Array||l instanceof Float32Array||l instanceof Float64Array)&&(l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),l instanceof Uint8Array){for(var h=l.byteLength,c=[],d=0;d<h;d++)c[d>>>2]|=l[d]<<24-d%4*8;a.call(this,c,h)}else a.apply(this,arguments)};o.prototype=n}})(),i.lib.WordArray})}),i8=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Utf16=a.Utf16BE={stringify:function(h){for(var c=h.words,d=h.sigBytes,f=[],u=0;u<d;u+=2){var p=c[u>>>2]>>>16-u%4*8&65535;f.push(String.fromCharCode(p))}return f.join("")},parse:function(h){for(var c=h.length,d=[],f=0;f<c;f++)d[f>>>1]|=h.charCodeAt(f)<<16-f%2*16;return n.create(d,c*2)}};a.Utf16LE={stringify:function(h){for(var c=h.words,d=h.sigBytes,f=[],u=0;u<d;u+=2){var p=l(c[u>>>2]>>>16-u%4*8&65535);f.push(String.fromCharCode(p))}return f.join("")},parse:function(h){for(var c=h.length,d=[],f=0;f<c;f++)d[f>>>1]|=l(h.charCodeAt(f)<<16-f%2*16);return n.create(d,c*2)}};function l(h){return h<<8&4278255360|h>>>8&16711935}})(),i.enc.Utf16})}),Ql=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Base64={stringify:function(h){var c=h.words,d=h.sigBytes,f=this._map;h.clamp();for(var u=[],p=0;p<d;p+=3)for(var g=c[p>>>2]>>>24-p%4*8&255,_=c[p+1>>>2]>>>24-(p+1)%4*8&255,y=c[p+2>>>2]>>>24-(p+2)%4*8&255,m=g<<16|_<<8|y,O=0;O<4&&p+O*.75<d;O++)u.push(f.charAt(m>>>6*(3-O)&63));var b=f.charAt(64);if(b)for(;u.length%4;)u.push(b);return u.join("")},parse:function(h){var c=h.length,d=this._map,f=this._reverseMap;if(!f){f=this._reverseMap=[];for(var u=0;u<d.length;u++)f[d.charCodeAt(u)]=u}var p=d.charAt(64);if(p){var g=h.indexOf(p);g!==-1&&(c=g)}return l(h,c,f)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function l(h,c,d){for(var f=[],u=0,p=0;p<c;p++)if(p%4){var g=d[h.charCodeAt(p-1)]<<p%4*2,_=d[h.charCodeAt(p)]>>>6-p%4*2,y=g|_;f[u>>>2]|=y<<24-u%4*8,u++}return n.create(f,u)}})(),i.enc.Base64})}),r8=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.enc,o=a.Base64url={stringify:function(h,c){c===void 0&&(c=!0);var d=h.words,f=h.sigBytes,u=c?this._safe_map:this._map;h.clamp();for(var p=[],g=0;g<f;g+=3)for(var _=d[g>>>2]>>>24-g%4*8&255,y=d[g+1>>>2]>>>24-(g+1)%4*8&255,m=d[g+2>>>2]>>>24-(g+2)%4*8&255,O=_<<16|y<<8|m,b=0;b<4&&g+b*.75<f;b++)p.push(u.charAt(O>>>6*(3-b)&63));var v=u.charAt(64);if(v)for(;p.length%4;)p.push(v);return p.join("")},parse:function(h,c){c===void 0&&(c=!0);var d=h.length,f=c?this._safe_map:this._map,u=this._reverseMap;if(!u){u=this._reverseMap=[];for(var p=0;p<f.length;p++)u[f.charCodeAt(p)]=p}var g=f.charAt(64);if(g){var _=h.indexOf(g);_!==-1&&(d=_)}return l(h,d,u)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function l(h,c,d){for(var f=[],u=0,p=0;p<c;p++)if(p%4){var g=d[h.charCodeAt(p-1)]<<p%4*2,_=d[h.charCodeAt(p)]>>>6-p%4*2,y=g|_;f[u>>>2]|=y<<24-u%4*8,u++}return n.create(f,u)}})(),i.enc.Base64url})}),eh=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=[];(function(){for(var g=0;g<64;g++)h[g]=r.abs(r.sin(g+1))*4294967296|0})();var c=l.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,_){for(var y=0;y<16;y++){var m=_+y,O=g[m];g[m]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var b=this._hash.words,v=g[_+0],E=g[_+1],T=g[_+2],P=g[_+3],A=g[_+4],C=g[_+5],M=g[_+6],H=g[_+7],k=g[_+8],F=g[_+9],j=g[_+10],L=g[_+11],R=g[_+12],x=g[_+13],I=g[_+14],S=g[_+15],D=b[0],N=b[1],G=b[2],z=b[3];D=d(D,N,G,z,v,7,h[0]),z=d(z,D,N,G,E,12,h[1]),G=d(G,z,D,N,T,17,h[2]),N=d(N,G,z,D,P,22,h[3]),D=d(D,N,G,z,A,7,h[4]),z=d(z,D,N,G,C,12,h[5]),G=d(G,z,D,N,M,17,h[6]),N=d(N,G,z,D,H,22,h[7]),D=d(D,N,G,z,k,7,h[8]),z=d(z,D,N,G,F,12,h[9]),G=d(G,z,D,N,j,17,h[10]),N=d(N,G,z,D,L,22,h[11]),D=d(D,N,G,z,R,7,h[12]),z=d(z,D,N,G,x,12,h[13]),G=d(G,z,D,N,I,17,h[14]),N=d(N,G,z,D,S,22,h[15]),D=f(D,N,G,z,E,5,h[16]),z=f(z,D,N,G,M,9,h[17]),G=f(G,z,D,N,L,14,h[18]),N=f(N,G,z,D,v,20,h[19]),D=f(D,N,G,z,C,5,h[20]),z=f(z,D,N,G,j,9,h[21]),G=f(G,z,D,N,S,14,h[22]),N=f(N,G,z,D,A,20,h[23]),D=f(D,N,G,z,F,5,h[24]),z=f(z,D,N,G,I,9,h[25]),G=f(G,z,D,N,P,14,h[26]),N=f(N,G,z,D,k,20,h[27]),D=f(D,N,G,z,x,5,h[28]),z=f(z,D,N,G,T,9,h[29]),G=f(G,z,D,N,H,14,h[30]),N=f(N,G,z,D,R,20,h[31]),D=u(D,N,G,z,C,4,h[32]),z=u(z,D,N,G,k,11,h[33]),G=u(G,z,D,N,L,16,h[34]),N=u(N,G,z,D,I,23,h[35]),D=u(D,N,G,z,E,4,h[36]),z=u(z,D,N,G,A,11,h[37]),G=u(G,z,D,N,H,16,h[38]),N=u(N,G,z,D,j,23,h[39]),D=u(D,N,G,z,x,4,h[40]),z=u(z,D,N,G,v,11,h[41]),G=u(G,z,D,N,P,16,h[42]),N=u(N,G,z,D,M,23,h[43]),D=u(D,N,G,z,F,4,h[44]),z=u(z,D,N,G,R,11,h[45]),G=u(G,z,D,N,S,16,h[46]),N=u(N,G,z,D,T,23,h[47]),D=p(D,N,G,z,v,6,h[48]),z=p(z,D,N,G,H,10,h[49]),G=p(G,z,D,N,I,15,h[50]),N=p(N,G,z,D,C,21,h[51]),D=p(D,N,G,z,R,6,h[52]),z=p(z,D,N,G,P,10,h[53]),G=p(G,z,D,N,j,15,h[54]),N=p(N,G,z,D,E,21,h[55]),D=p(D,N,G,z,k,6,h[56]),z=p(z,D,N,G,S,10,h[57]),G=p(G,z,D,N,M,15,h[58]),N=p(N,G,z,D,x,21,h[59]),D=p(D,N,G,z,A,6,h[60]),z=p(z,D,N,G,L,10,h[61]),G=p(G,z,D,N,T,15,h[62]),N=p(N,G,z,D,F,21,h[63]),b[0]=b[0]+D|0,b[1]=b[1]+N|0,b[2]=b[2]+G|0,b[3]=b[3]+z|0},_doFinalize:function(){var g=this._data,_=g.words,y=this._nDataBytes*8,m=g.sigBytes*8;_[m>>>5]|=128<<24-m%32;var O=r.floor(y/4294967296),b=y;_[(m+64>>>9<<4)+15]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,_[(m+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,g.sigBytes=(_.length+1)*4,this._process();for(var v=this._hash,E=v.words,T=0;T<4;T++){var P=E[T];E[T]=(P<<8|P>>>24)&16711935|(P<<24|P>>>8)&4278255360}return v},clone:function(){var g=o.clone.call(this);return g._hash=this._hash.clone(),g}});function d(g,_,y,m,O,b,v){var E=g+(_&y|~_&m)+O+v;return(E<<b|E>>>32-b)+_}function f(g,_,y,m,O,b,v){var E=g+(_&m|y&~m)+O+v;return(E<<b|E>>>32-b)+_}function u(g,_,y,m,O,b,v){var E=g+(_^y^m)+O+v;return(E<<b|E>>>32-b)+_}function p(g,_,y,m,O,b,v){var E=g+(y^(_|~m))+O+v;return(E<<b|E>>>32-b)+_}s.MD5=o._createHelper(c),s.HmacMD5=o._createHmacHelper(c)})(Math),i.MD5})}),gw=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=s.Hasher,o=r.algo,l=[],h=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(c,d){for(var f=this._hash.words,u=f[0],p=f[1],g=f[2],_=f[3],y=f[4],m=0;m<80;m++){if(m<16)l[m]=c[d+m]|0;else{var O=l[m-3]^l[m-8]^l[m-14]^l[m-16];l[m]=O<<1|O>>>31}var b=(u<<5|u>>>27)+y+l[m];m<20?b+=(p&g|~p&_)+1518500249:m<40?b+=(p^g^_)+1859775393:m<60?b+=(p&g|p&_|g&_)-1894007588:b+=(p^g^_)-899497514,y=_,_=g,g=p<<30|p>>>2,p=u,u=b}f[0]=f[0]+u|0,f[1]=f[1]+p|0,f[2]=f[2]+g|0,f[3]=f[3]+_|0,f[4]=f[4]+y|0},_doFinalize:function(){var c=this._data,d=c.words,f=this._nDataBytes*8,u=c.sigBytes*8;return d[u>>>5]|=128<<24-u%32,d[(u+64>>>9<<4)+14]=Math.floor(f/4294967296),d[(u+64>>>9<<4)+15]=f,c.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var c=a.clone.call(this);return c._hash=this._hash.clone(),c}});r.SHA1=a._createHelper(h),r.HmacSHA1=a._createHmacHelper(h)})(),i.SHA1})}),S1=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=[],c=[];(function(){function u(y){for(var m=r.sqrt(y),O=2;O<=m;O++)if(!(y%O))return!1;return!0}function p(y){return(y-(y|0))*4294967296|0}for(var g=2,_=0;_<64;)u(g)&&(_<8&&(h[_]=p(r.pow(g,1/2))),c[_]=p(r.pow(g,1/3)),_++),g++})();var d=[],f=l.SHA256=o.extend({_doReset:function(){this._hash=new a.init(h.slice(0))},_doProcessBlock:function(u,p){for(var g=this._hash.words,_=g[0],y=g[1],m=g[2],O=g[3],b=g[4],v=g[5],E=g[6],T=g[7],P=0;P<64;P++){if(P<16)d[P]=u[p+P]|0;else{var A=d[P-15],C=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,M=d[P-2],H=(M<<15|M>>>17)^(M<<13|M>>>19)^M>>>10;d[P]=C+d[P-7]+H+d[P-16]}var k=b&v^~b&E,F=_&y^_&m^y&m,j=(_<<30|_>>>2)^(_<<19|_>>>13)^(_<<10|_>>>22),L=(b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25),R=T+L+k+c[P]+d[P],x=j+F;T=E,E=v,v=b,b=O+R|0,O=m,m=y,y=_,_=R+x|0}g[0]=g[0]+_|0,g[1]=g[1]+y|0,g[2]=g[2]+m|0,g[3]=g[3]+O|0,g[4]=g[4]+b|0,g[5]=g[5]+v|0,g[6]=g[6]+E|0,g[7]=g[7]+T|0},_doFinalize:function(){var u=this._data,p=u.words,g=this._nDataBytes*8,_=u.sigBytes*8;return p[_>>>5]|=128<<24-_%32,p[(_+64>>>9<<4)+14]=r.floor(g/4294967296),p[(_+64>>>9<<4)+15]=g,u.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var u=o.clone.call(this);return u._hash=this._hash.clone(),u}});s.SHA256=o._createHelper(f),s.HmacSHA256=o._createHmacHelper(f)})(Math),i.SHA256})}),s8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),S1()):typeof define=="function"&&define.amd?define(["./core","./sha256"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=r.algo,o=a.SHA256,l=a.SHA224=o.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var h=o._doFinalize.call(this);return h.sigBytes-=4,h}});r.SHA224=o._createHelper(l),r.HmacSHA224=o._createHmacHelper(l)})(),i.SHA224})}),_w=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Jg()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Hasher,a=r.x64,o=a.Word,l=a.WordArray,h=r.algo;function c(){return o.create.apply(o,arguments)}var d=[c(1116352408,3609767458),c(1899447441,602891725),c(3049323471,3964484399),c(3921009573,2173295548),c(961987163,4081628472),c(1508970993,3053834265),c(2453635748,2937671579),c(2870763221,3664609560),c(3624381080,2734883394),c(310598401,1164996542),c(607225278,1323610764),c(1426881987,3590304994),c(1925078388,4068182383),c(2162078206,991336113),c(2614888103,633803317),c(3248222580,3479774868),c(3835390401,2666613458),c(4022224774,944711139),c(264347078,2341262773),c(604807628,2007800933),c(770255983,1495990901),c(1249150122,1856431235),c(1555081692,3175218132),c(1996064986,2198950837),c(2554220882,3999719339),c(2821834349,766784016),c(2952996808,2566594879),c(3210313671,3203337956),c(3336571891,1034457026),c(3584528711,2466948901),c(113926993,3758326383),c(338241895,168717936),c(666307205,1188179964),c(773529912,1546045734),c(1294757372,1522805485),c(1396182291,2643833823),c(1695183700,2343527390),c(1986661051,1014477480),c(2177026350,1206759142),c(2456956037,344077627),c(2730485921,1290863460),c(2820302411,3158454273),c(3259730800,3505952657),c(3345764771,106217008),c(3516065817,3606008344),c(3600352804,1432725776),c(4094571909,1467031594),c(275423344,851169720),c(430227734,3100823752),c(506948616,1363258195),c(659060556,3750685593),c(883997877,3785050280),c(958139571,3318307427),c(1322822218,3812723403),c(1537002063,2003034995),c(1747873779,3602036899),c(1955562222,1575990012),c(2024104815,1125592928),c(2227730452,2716904306),c(2361852424,442776044),c(2428436474,593698344),c(2756734187,3733110249),c(3204031479,2999351573),c(3329325298,3815920427),c(3391569614,3928383900),c(3515267271,566280711),c(3940187606,3454069534),c(4118630271,4000239992),c(116418474,1914138554),c(174292421,2731055270),c(289380356,3203993006),c(460393269,320620315),c(685471733,587496836),c(852142971,1086792851),c(1017036298,365543100),c(1126000580,2618297676),c(1288033470,3409855158),c(1501505948,4234509866),c(1607167915,987167468),c(1816402316,1246189591)],f=[];(function(){for(var p=0;p<80;p++)f[p]=c()})();var u=h.SHA512=n.extend({_doReset:function(){this._hash=new l.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(p,g){for(var _=this._hash.words,y=_[0],m=_[1],O=_[2],b=_[3],v=_[4],E=_[5],T=_[6],P=_[7],A=y.high,C=y.low,M=m.high,H=m.low,k=O.high,F=O.low,j=b.high,L=b.low,R=v.high,x=v.low,I=E.high,S=E.low,D=T.high,N=T.low,G=P.high,z=P.low,Z=A,se=C,he=M,pe=H,Se=k,q=F,X=j,ie=L,de=R,Ce=x,De=I,Fe=S,Pe=D,w=N,B=G,V=z,Y=0;Y<80;Y++){var W,ne,ue=f[Y];if(Y<16)ne=ue.high=p[g+Y*2]|0,W=ue.low=p[g+Y*2+1]|0;else{var Re=f[Y-15],Ue=Re.high,je=Re.low,dt=(Ue>>>1|je<<31)^(Ue>>>8|je<<24)^Ue>>>7,Ot=(je>>>1|Ue<<31)^(je>>>8|Ue<<24)^(je>>>7|Ue<<25),Lt=f[Y-2],hi=Lt.high,Q=Lt.low,ke=(hi>>>19|Q<<13)^(hi<<3|Q>>>29)^hi>>>6,Ge=(Q>>>19|hi<<13)^(Q<<3|hi>>>29)^(Q>>>6|hi<<26),qe=f[Y-7],me=qe.high,Me=qe.low,J=f[Y-16],ze=J.high,mt=J.low;W=Ot+Me,ne=dt+me+(W>>>0<Ot>>>0?1:0),W=W+Ge,ne=ne+ke+(W>>>0<Ge>>>0?1:0),W=W+mt,ne=ne+ze+(W>>>0<mt>>>0?1:0),ue.high=ne,ue.low=W}var U=de&De^~de&Pe,Le=Ce&Fe^~Ce&w,Ne=Z&he^Z&Se^he&Se,K=se&pe^se&q^pe&q,_e=(Z>>>28|se<<4)^(Z<<30|se>>>2)^(Z<<25|se>>>7),Ae=(se>>>28|Z<<4)^(se<<30|Z>>>2)^(se<<25|Z>>>7),ft=(de>>>14|Ce<<18)^(de>>>18|Ce<<14)^(de<<23|Ce>>>9),Ze=(Ce>>>14|de<<18)^(Ce>>>18|de<<14)^(Ce<<23|de>>>9),Ke=d[Y],Ft=Ke.high,Ps=Ke.low,vt=V+Ze,bt=B+ft+(vt>>>0<V>>>0?1:0),vt=vt+Le,bt=bt+U+(vt>>>0<Le>>>0?1:0),vt=vt+Ps,bt=bt+Ft+(vt>>>0<Ps>>>0?1:0),vt=vt+W,bt=bt+ne+(vt>>>0<W>>>0?1:0),ki=Ae+K,_r=_e+Ne+(ki>>>0<Ae>>>0?1:0);B=Pe,V=w,Pe=De,w=Fe,De=de,Fe=Ce,Ce=ie+vt|0,de=X+bt+(Ce>>>0<ie>>>0?1:0)|0,X=Se,ie=q,Se=he,q=pe,he=Z,pe=se,se=vt+ki|0,Z=bt+_r+(se>>>0<vt>>>0?1:0)|0}C=y.low=C+se,y.high=A+Z+(C>>>0<se>>>0?1:0),H=m.low=H+pe,m.high=M+he+(H>>>0<pe>>>0?1:0),F=O.low=F+q,O.high=k+Se+(F>>>0<q>>>0?1:0),L=b.low=L+ie,b.high=j+X+(L>>>0<ie>>>0?1:0),x=v.low=x+Ce,v.high=R+de+(x>>>0<Ce>>>0?1:0),S=E.low=S+Fe,E.high=I+De+(S>>>0<Fe>>>0?1:0),N=T.low=N+w,T.high=D+Pe+(N>>>0<w>>>0?1:0),z=P.low=z+V,P.high=G+B+(z>>>0<V>>>0?1:0)},_doFinalize:function(){var p=this._data,g=p.words,_=this._nDataBytes*8,y=p.sigBytes*8;g[y>>>5]|=128<<24-y%32,g[(y+128>>>10<<5)+30]=Math.floor(_/4294967296),g[(y+128>>>10<<5)+31]=_,p.sigBytes=g.length*4,this._process();var m=this._hash.toX32();return m},clone:function(){var p=n.clone.call(this);return p._hash=this._hash.clone(),p},blockSize:1024/32});r.SHA512=n._createHelper(u),r.HmacSHA512=n._createHmacHelper(u)})(),i.SHA512})}),n8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Jg(),_w()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./sha512"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.x64,n=s.Word,a=s.WordArray,o=r.algo,l=o.SHA512,h=o.SHA384=l.extend({_doReset:function(){this._hash=new a.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var c=l._doFinalize.call(this);return c.sigBytes-=16,c}});r.SHA384=l._createHelper(h),r.HmacSHA384=l._createHmacHelper(h)})(),i.SHA384})}),a8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Jg()):typeof define=="function"&&define.amd?define(["./core","./x64-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.x64,h=l.Word,c=s.algo,d=[],f=[],u=[];(function(){for(var _=1,y=0,m=0;m<24;m++){d[_+5*y]=(m+1)*(m+2)/2%64;var O=y%5,b=(2*_+3*y)%5;_=O,y=b}for(var _=0;_<5;_++)for(var y=0;y<5;y++)f[_+5*y]=y+(2*_+3*y)%5*5;for(var v=1,E=0;E<24;E++){for(var T=0,P=0,A=0;A<7;A++){if(v&1){var C=(1<<A)-1;C<32?P^=1<<C:T^=1<<C-32}v&128?v=v<<1^113:v<<=1}u[E]=h.create(T,P)}})();var p=[];(function(){for(var _=0;_<25;_++)p[_]=h.create()})();var g=c.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var _=this._state=[],y=0;y<25;y++)_[y]=new h.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(_,y){for(var m=this._state,O=this.blockSize/2,b=0;b<O;b++){var v=_[y+2*b],E=_[y+2*b+1];v=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,E=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360;var T=m[b];T.high^=E,T.low^=v}for(var P=0;P<24;P++){for(var A=0;A<5;A++){for(var C=0,M=0,H=0;H<5;H++){var T=m[A+5*H];C^=T.high,M^=T.low}var k=p[A];k.high=C,k.low=M}for(var A=0;A<5;A++)for(var F=p[(A+4)%5],j=p[(A+1)%5],L=j.high,R=j.low,C=F.high^(L<<1|R>>>31),M=F.low^(R<<1|L>>>31),H=0;H<5;H++){var T=m[A+5*H];T.high^=C,T.low^=M}for(var x=1;x<25;x++){var C,M,T=m[x],I=T.high,S=T.low,D=d[x];D<32?(C=I<<D|S>>>32-D,M=S<<D|I>>>32-D):(C=S<<D-32|I>>>64-D,M=I<<D-32|S>>>64-D);var N=p[f[x]];N.high=C,N.low=M}var G=p[0],z=m[0];G.high=z.high,G.low=z.low;for(var A=0;A<5;A++)for(var H=0;H<5;H++){var x=A+5*H,T=m[x],Z=p[x],se=p[(A+1)%5+5*H],he=p[(A+2)%5+5*H];T.high=Z.high^~se.high&he.high,T.low=Z.low^~se.low&he.low}var T=m[0],pe=u[P];T.high^=pe.high,T.low^=pe.low}},_doFinalize:function(){var _=this._data,y=_.words,m=this._nDataBytes*8,O=_.sigBytes*8,b=this.blockSize*32;y[O>>>5]|=1<<24-O%32,y[(r.ceil((O+1)/b)*b>>>5)-1]|=128,_.sigBytes=y.length*4,this._process();for(var v=this._state,E=this.cfg.outputLength/8,T=E/8,P=[],A=0;A<T;A++){var C=v[A],M=C.high,H=C.low;M=(M<<8|M>>>24)&16711935|(M<<24|M>>>8)&4278255360,H=(H<<8|H>>>24)&16711935|(H<<24|H>>>8)&4278255360,P.push(H),P.push(M)}return new a.init(P,E)},clone:function(){for(var _=o.clone.call(this),y=_._state=this._state.slice(0),m=0;m<25;m++)y[m]=y[m].clone();return _}});s.SHA3=o._createHelper(g),s.HmacSHA3=o._createHmacHelper(g)})(Math),i.SHA3})}),o8=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.WordArray,o=n.Hasher,l=s.algo,h=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),d=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=a.create([0,1518500249,1859775393,2400959708,2840853838]),p=a.create([1352829926,1548603684,1836072691,2053994217,0]),g=l.RIPEMD160=o.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(E,T){for(var P=0;P<16;P++){var A=T+P,C=E[A];E[A]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360}var M=this._hash.words,H=u.words,k=p.words,F=h.words,j=c.words,L=d.words,R=f.words,x,I,S,D,N,G,z,Z,se,he;G=x=M[0],z=I=M[1],Z=S=M[2],se=D=M[3],he=N=M[4];for(var pe,P=0;P<80;P+=1)pe=x+E[T+F[P]]|0,P<16?pe+=_(I,S,D)+H[0]:P<32?pe+=y(I,S,D)+H[1]:P<48?pe+=m(I,S,D)+H[2]:P<64?pe+=O(I,S,D)+H[3]:pe+=b(I,S,D)+H[4],pe=pe|0,pe=v(pe,L[P]),pe=pe+N|0,x=N,N=D,D=v(S,10),S=I,I=pe,pe=G+E[T+j[P]]|0,P<16?pe+=b(z,Z,se)+k[0]:P<32?pe+=O(z,Z,se)+k[1]:P<48?pe+=m(z,Z,se)+k[2]:P<64?pe+=y(z,Z,se)+k[3]:pe+=_(z,Z,se)+k[4],pe=pe|0,pe=v(pe,R[P]),pe=pe+he|0,G=he,he=se,se=v(Z,10),Z=z,z=pe;pe=M[1]+S+se|0,M[1]=M[2]+D+he|0,M[2]=M[3]+N+G|0,M[3]=M[4]+x+z|0,M[4]=M[0]+I+Z|0,M[0]=pe},_doFinalize:function(){var E=this._data,T=E.words,P=this._nDataBytes*8,A=E.sigBytes*8;T[A>>>5]|=128<<24-A%32,T[(A+64>>>9<<4)+14]=(P<<8|P>>>24)&16711935|(P<<24|P>>>8)&4278255360,E.sigBytes=(T.length+1)*4,this._process();for(var C=this._hash,M=C.words,H=0;H<5;H++){var k=M[H];M[H]=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360}return C},clone:function(){var E=o.clone.call(this);return E._hash=this._hash.clone(),E}});function _(E,T,P){return E^T^P}function y(E,T,P){return E&T|~E&P}function m(E,T,P){return(E|~T)^P}function O(E,T,P){return E&P|T&~P}function b(E,T,P){return E^(T|~P)}function v(E,T){return E<<T|E>>>32-T}s.RIPEMD160=o._createHelper(g),s.HmacRIPEMD160=o._createHmacHelper(g)})(Math),i.RIPEMD160})}),I1=Zt((e,t)=>{(function(i,r){typeof e=="object"?t.exports=e=r(ii()):typeof define=="function"&&define.amd?define(["./core"],r):r(i.CryptoJS)})(e,function(i){(function(){var r=i,s=r.lib,n=s.Base,a=r.enc,o=a.Utf8,l=r.algo,h=l.HMAC=n.extend({init:function(c,d){c=this._hasher=new c.init,typeof d=="string"&&(d=o.parse(d));var f=c.blockSize,u=f*4;d.sigBytes>u&&(d=c.finalize(d)),d.clamp();for(var p=this._oKey=d.clone(),g=this._iKey=d.clone(),_=p.words,y=g.words,m=0;m<f;m++)_[m]^=1549556828,y[m]^=909522486;p.sigBytes=g.sigBytes=u,this.reset()},reset:function(){var c=this._hasher;c.reset(),c.update(this._iKey)},update:function(c){return this._hasher.update(c),this},finalize:function(c){var d=this._hasher,f=d.finalize(c);d.reset();var u=d.finalize(this._oKey.clone().concat(f));return u}})})()})}),l8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),S1(),I1()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Base,a=s.WordArray,o=r.algo,l=o.SHA256,h=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:128/32,hasher:l,iterations:25e4}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,f){for(var u=this.cfg,p=h.create(u.hasher,d),g=a.create(),_=a.create([1]),y=g.words,m=_.words,O=u.keySize,b=u.iterations;y.length<O;){var v=p.update(f).finalize(_);p.reset();for(var E=v.words,T=E.length,P=v,A=1;A<b;A++){P=p.finalize(P),p.reset();for(var C=P.words,M=0;M<T;M++)E[M]^=C[M]}g.concat(v),m[0]++}return g.sigBytes=O*4,g}});r.PBKDF2=function(d,f,u){return c.create(u).compute(d,f)}})(),i.PBKDF2})}),tl=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),gw(),I1()):typeof define=="function"&&define.amd?define(["./core","./sha1","./hmac"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.Base,a=s.WordArray,o=r.algo,l=o.MD5,h=o.EvpKDF=n.extend({cfg:n.extend({keySize:128/32,hasher:l,iterations:1}),init:function(c){this.cfg=this.cfg.extend(c)},compute:function(c,d){for(var f,u=this.cfg,p=u.hasher.create(),g=a.create(),_=g.words,y=u.keySize,m=u.iterations;_.length<y;){f&&p.update(f),f=p.update(c).finalize(d),p.reset();for(var O=1;O<m;O++)f=p.finalize(f),p.reset();g.concat(f)}return g.sigBytes=y*4,g}});r.EvpKDF=function(c,d,f){return h.create(f).compute(c,d)}})(),i.EvpKDF})}),Wr=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),tl()):typeof define=="function"&&define.amd?define(["./core","./evpkdf"],r):r(i.CryptoJS)})(e,function(i){i.lib.Cipher||(function(r){var s=i,n=s.lib,a=n.Base,o=n.WordArray,l=n.BufferedBlockAlgorithm,h=s.enc,c=h.Utf8,d=h.Base64,f=s.algo,u=f.EvpKDF,p=n.Cipher=l.extend({cfg:a.extend(),createEncryptor:function(k,F){return this.create(this._ENC_XFORM_MODE,k,F)},createDecryptor:function(k,F){return this.create(this._DEC_XFORM_MODE,k,F)},init:function(k,F,j){this.cfg=this.cfg.extend(j),this._xformMode=k,this._key=F,this.reset()},reset:function(){l.reset.call(this),this._doReset()},process:function(k){return this._append(k),this._process()},finalize:function(k){k&&this._append(k);var F=this._doFinalize();return F},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:(function(){function k(F){return typeof F=="string"?H:A}return function(F){return{encrypt:function(j,L,R){return k(L).encrypt(F,j,L,R)},decrypt:function(j,L,R){return k(L).decrypt(F,j,L,R)}}}})()}),g=n.StreamCipher=p.extend({_doFinalize:function(){var k=this._process(!0);return k},blockSize:1}),_=s.mode={},y=n.BlockCipherMode=a.extend({createEncryptor:function(k,F){return this.Encryptor.create(k,F)},createDecryptor:function(k,F){return this.Decryptor.create(k,F)},init:function(k,F){this._cipher=k,this._iv=F}}),m=_.CBC=(function(){var k=y.extend();k.Encryptor=k.extend({processBlock:function(j,L){var R=this._cipher,x=R.blockSize;F.call(this,j,L,x),R.encryptBlock(j,L),this._prevBlock=j.slice(L,L+x)}}),k.Decryptor=k.extend({processBlock:function(j,L){var R=this._cipher,x=R.blockSize,I=j.slice(L,L+x);R.decryptBlock(j,L),F.call(this,j,L,x),this._prevBlock=I}});function F(j,L,R){var x,I=this._iv;I?(x=I,this._iv=r):x=this._prevBlock;for(var S=0;S<R;S++)j[L+S]^=x[S]}return k})(),O=s.pad={},b=O.Pkcs7={pad:function(k,F){for(var j=F*4,L=j-k.sigBytes%j,R=L<<24|L<<16|L<<8|L,x=[],I=0;I<L;I+=4)x.push(R);var S=o.create(x,L);k.concat(S)},unpad:function(k){var F=k.words[k.sigBytes-1>>>2]&255;k.sigBytes-=F}},v=n.BlockCipher=p.extend({cfg:p.cfg.extend({mode:m,padding:b}),reset:function(){var k;p.reset.call(this);var F=this.cfg,j=F.iv,L=F.mode;this._xformMode==this._ENC_XFORM_MODE?k=L.createEncryptor:(k=L.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==k?this._mode.init(this,j&&j.words):(this._mode=k.call(L,this,j&&j.words),this._mode.__creator=k)},_doProcessBlock:function(k,F){this._mode.processBlock(k,F)},_doFinalize:function(){var k,F=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(F.pad(this._data,this.blockSize),k=this._process(!0)):(k=this._process(!0),F.unpad(k)),k},blockSize:128/32}),E=n.CipherParams=a.extend({init:function(k){this.mixIn(k)},toString:function(k){return(k||this.formatter).stringify(this)}}),T=s.format={},P=T.OpenSSL={stringify:function(k){var F,j=k.ciphertext,L=k.salt;return L?F=o.create([1398893684,1701076831]).concat(L).concat(j):F=j,F.toString(d)},parse:function(k){var F,j=d.parse(k),L=j.words;return L[0]==1398893684&&L[1]==1701076831&&(F=o.create(L.slice(2,4)),L.splice(0,4),j.sigBytes-=16),E.create({ciphertext:j,salt:F})}},A=n.SerializableCipher=a.extend({cfg:a.extend({format:P}),encrypt:function(k,F,j,L){L=this.cfg.extend(L);var R=k.createEncryptor(j,L),x=R.finalize(F),I=R.cfg;return E.create({ciphertext:x,key:j,iv:I.iv,algorithm:k,mode:I.mode,padding:I.padding,blockSize:k.blockSize,formatter:L.format})},decrypt:function(k,F,j,L){L=this.cfg.extend(L),F=this._parse(F,L.format);var R=k.createDecryptor(j,L).finalize(F.ciphertext);return R},_parse:function(k,F){return typeof k=="string"?F.parse(k,this):k}}),C=s.kdf={},M=C.OpenSSL={execute:function(k,F,j,L,R){if(L||(L=o.random(64/8)),R)var x=u.create({keySize:F+j,hasher:R}).compute(k,L);else var x=u.create({keySize:F+j}).compute(k,L);var I=o.create(x.words.slice(F),j*4);return x.sigBytes=F*4,E.create({key:x,iv:I,salt:L})}},H=n.PasswordBasedCipher=A.extend({cfg:A.cfg.extend({kdf:M}),encrypt:function(k,F,j,L){L=this.cfg.extend(L);var R=L.kdf.execute(j,k.keySize,k.ivSize,L.salt,L.hasher);L.iv=R.iv;var x=A.encrypt.call(this,k,F,R.key,L);return x.mixIn(R),x},decrypt:function(k,F,j,L){L=this.cfg.extend(L),F=this._parse(F,L.format);var R=L.kdf.execute(j,k.keySize,k.ivSize,F.salt,L.hasher);L.iv=R.iv;var x=A.decrypt.call(this,k,F,R.key,L);return x}})})()})}),h8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CFB=(function(){var r=i.lib.BlockCipherMode.extend();r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize;s.call(this,n,a,l,o),this._prevBlock=n.slice(a,a+l)}}),r.Decryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=n.slice(a,a+l);s.call(this,n,a,l,o),this._prevBlock=h}});function s(n,a,o,l){var h,c=this._iv;c?(h=c.slice(0),this._iv=void 0):h=this._prevBlock,l.encryptBlock(h,0);for(var d=0;d<o;d++)n[a+d]^=h[d]}return r})(),i.mode.CFB})}),c8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTR=(function(){var r=i.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=this._iv,c=this._counter;h&&(c=this._counter=h.slice(0),this._iv=void 0);var d=c.slice(0);o.encryptBlock(d,0),c[l-1]=c[l-1]+1|0;for(var f=0;f<l;f++)n[a+f]^=d[f]}});return r.Decryptor=s,r})(),i.mode.CTR})}),u8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.CTRGladman=(function(){var r=i.lib.BlockCipherMode.extend();function s(o){if((o>>24&255)===255){var l=o>>16&255,h=o>>8&255,c=o&255;l===255?(l=0,h===255?(h=0,c===255?c=0:++c):++h):++l,o=0,o+=l<<16,o+=h<<8,o+=c}else o+=1<<24;return o}function n(o){return(o[0]=s(o[0]))===0&&(o[1]=s(o[1])),o}var a=r.Encryptor=r.extend({processBlock:function(o,l){var h=this._cipher,c=h.blockSize,d=this._iv,f=this._counter;d&&(f=this._counter=d.slice(0),this._iv=void 0),n(f);var u=f.slice(0);h.encryptBlock(u,0);for(var p=0;p<c;p++)o[l+p]^=u[p]}});return r.Decryptor=a,r})(),i.mode.CTRGladman})}),d8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.OFB=(function(){var r=i.lib.BlockCipherMode.extend(),s=r.Encryptor=r.extend({processBlock:function(n,a){var o=this._cipher,l=o.blockSize,h=this._iv,c=this._keystream;h&&(c=this._keystream=h.slice(0),this._iv=void 0),o.encryptBlock(c,0);for(var d=0;d<l;d++)n[a+d]^=c[d]}});return r.Decryptor=s,r})(),i.mode.OFB})}),f8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.mode.ECB=(function(){var r=i.lib.BlockCipherMode.extend();return r.Encryptor=r.extend({processBlock:function(s,n){this._cipher.encryptBlock(s,n)}}),r.Decryptor=r.extend({processBlock:function(s,n){this._cipher.decryptBlock(s,n)}}),r})(),i.mode.ECB})}),p8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.AnsiX923={pad:function(r,s){var n=r.sigBytes,a=s*4,o=a-n%a,l=n+o-1;r.clamp(),r.words[l>>>2]|=o<<24-l%4*8,r.sigBytes+=o},unpad:function(r){var s=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=s}},i.pad.Ansix923})}),g8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso10126={pad:function(r,s){var n=s*4,a=n-r.sigBytes%n;r.concat(i.lib.WordArray.random(a-1)).concat(i.lib.WordArray.create([a<<24],1))},unpad:function(r){var s=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=s}},i.pad.Iso10126})}),_8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.Iso97971={pad:function(r,s){r.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(r,s)},unpad:function(r){i.pad.ZeroPadding.unpad(r),r.sigBytes--}},i.pad.Iso97971})}),O8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.ZeroPadding={pad:function(r,s){var n=s*4;r.clamp(),r.sigBytes+=n-(r.sigBytes%n||n)},unpad:function(r){for(var s=r.words,n=r.sigBytes-1,n=r.sigBytes-1;n>=0;n--)if(s[n>>>2]>>>24-n%4*8&255){r.sigBytes=n+1;break}}},i.pad.ZeroPadding})}),m8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding})}),b8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Wr()):typeof define=="function"&&define.amd?define(["./core","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(r){var s=i,n=s.lib,a=n.CipherParams,o=s.enc,l=o.Hex,h=s.format,c=h.Hex={stringify:function(d){return d.ciphertext.toString(l)},parse:function(d){var f=l.parse(d);return a.create({ciphertext:f})}}})(),i.format.Hex})}),y8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.BlockCipher,a=r.algo,o=[],l=[],h=[],c=[],d=[],f=[],u=[],p=[],g=[],_=[];(function(){for(var O=[],b=0;b<256;b++)b<128?O[b]=b<<1:O[b]=b<<1^283;for(var v=0,E=0,b=0;b<256;b++){var T=E^E<<1^E<<2^E<<3^E<<4;T=T>>>8^T&255^99,o[v]=T,l[T]=v;var P=O[v],A=O[P],C=O[A],M=O[T]*257^T*16843008;h[v]=M<<24|M>>>8,c[v]=M<<16|M>>>16,d[v]=M<<8|M>>>24,f[v]=M;var M=C*16843009^A*65537^P*257^v*16843008;u[T]=M<<24|M>>>8,p[T]=M<<16|M>>>16,g[T]=M<<8|M>>>24,_[T]=M,v?(v=P^O[O[O[C^P]]],E^=O[O[E]]):v=E=1}})();var y=[0,1,2,4,8,16,32,64,128,27,54],m=a.AES=n.extend({_doReset:function(){var O;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var b=this._keyPriorReset=this._key,v=b.words,E=b.sigBytes/4,T=this._nRounds=E+6,P=(T+1)*4,A=this._keySchedule=[],C=0;C<P;C++)C<E?A[C]=v[C]:(O=A[C-1],C%E?E>6&&C%E==4&&(O=o[O>>>24]<<24|o[O>>>16&255]<<16|o[O>>>8&255]<<8|o[O&255]):(O=O<<8|O>>>24,O=o[O>>>24]<<24|o[O>>>16&255]<<16|o[O>>>8&255]<<8|o[O&255],O^=y[C/E|0]<<24),A[C]=A[C-E]^O);for(var M=this._invKeySchedule=[],H=0;H<P;H++){var C=P-H;if(H%4)var O=A[C];else var O=A[C-4];H<4||C<=4?M[H]=O:M[H]=u[o[O>>>24]]^p[o[O>>>16&255]]^g[o[O>>>8&255]]^_[o[O&255]]}}},encryptBlock:function(O,b){this._doCryptBlock(O,b,this._keySchedule,h,c,d,f,o)},decryptBlock:function(O,b){var v=O[b+1];O[b+1]=O[b+3],O[b+3]=v,this._doCryptBlock(O,b,this._invKeySchedule,u,p,g,_,l);var v=O[b+1];O[b+1]=O[b+3],O[b+3]=v},_doCryptBlock:function(O,b,v,E,T,P,A,C){for(var M=this._nRounds,H=O[b]^v[0],k=O[b+1]^v[1],F=O[b+2]^v[2],j=O[b+3]^v[3],L=4,R=1;R<M;R++){var x=E[H>>>24]^T[k>>>16&255]^P[F>>>8&255]^A[j&255]^v[L++],I=E[k>>>24]^T[F>>>16&255]^P[j>>>8&255]^A[H&255]^v[L++],S=E[F>>>24]^T[j>>>16&255]^P[H>>>8&255]^A[k&255]^v[L++],D=E[j>>>24]^T[H>>>16&255]^P[k>>>8&255]^A[F&255]^v[L++];H=x,k=I,F=S,j=D}var x=(C[H>>>24]<<24|C[k>>>16&255]<<16|C[F>>>8&255]<<8|C[j&255])^v[L++],I=(C[k>>>24]<<24|C[F>>>16&255]<<16|C[j>>>8&255]<<8|C[H&255])^v[L++],S=(C[F>>>24]<<24|C[j>>>16&255]<<16|C[H>>>8&255]<<8|C[k&255])^v[L++],D=(C[j>>>24]<<24|C[H>>>16&255]<<16|C[k>>>8&255]<<8|C[F&255])^v[L++];O[b]=x,O[b+1]=I,O[b+2]=S,O[b+3]=D},keySize:256/32});r.AES=n._createHelper(m)})(),i.AES})}),v8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.WordArray,a=s.BlockCipher,o=r.algo,l=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],h=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=o.DES=a.extend({_doReset:function(){for(var y=this._key,m=y.words,O=[],b=0;b<56;b++){var v=l[b]-1;O[b]=m[v>>>5]>>>31-v%32&1}for(var E=this._subKeys=[],T=0;T<16;T++){for(var P=E[T]=[],A=c[T],b=0;b<24;b++)P[b/6|0]|=O[(h[b]-1+A)%28]<<31-b%6,P[4+(b/6|0)]|=O[28+(h[b+24]-1+A)%28]<<31-b%6;P[0]=P[0]<<1|P[0]>>>31;for(var b=1;b<7;b++)P[b]=P[b]>>>(b-1)*4+3;P[7]=P[7]<<5|P[7]>>>27}for(var C=this._invSubKeys=[],b=0;b<16;b++)C[b]=E[15-b]},encryptBlock:function(y,m){this._doCryptBlock(y,m,this._subKeys)},decryptBlock:function(y,m){this._doCryptBlock(y,m,this._invSubKeys)},_doCryptBlock:function(y,m,O){this._lBlock=y[m],this._rBlock=y[m+1],p.call(this,4,252645135),p.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),p.call(this,1,1431655765);for(var b=0;b<16;b++){for(var v=O[b],E=this._lBlock,T=this._rBlock,P=0,A=0;A<8;A++)P|=d[A][((T^v[A])&f[A])>>>0];this._lBlock=T,this._rBlock=E^P}var C=this._lBlock;this._lBlock=this._rBlock,this._rBlock=C,p.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),y[m]=this._lBlock,y[m+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function p(y,m){var O=(this._lBlock>>>y^this._rBlock)&m;this._rBlock^=O,this._lBlock^=O<<y}function g(y,m){var O=(this._rBlock>>>y^this._lBlock)&m;this._lBlock^=O,this._rBlock^=O<<y}r.DES=a._createHelper(u);var _=o.TripleDES=a.extend({_doReset:function(){var y=this._key,m=y.words;if(m.length!==2&&m.length!==4&&m.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var O=m.slice(0,2),b=m.length<4?m.slice(0,2):m.slice(2,4),v=m.length<6?m.slice(0,2):m.slice(4,6);this._des1=u.createEncryptor(n.create(O)),this._des2=u.createEncryptor(n.create(b)),this._des3=u.createEncryptor(n.create(v))},encryptBlock:function(y,m){this._des1.encryptBlock(y,m),this._des2.decryptBlock(y,m),this._des3.encryptBlock(y,m)},decryptBlock:function(y,m){this._des3.decryptBlock(y,m),this._des2.encryptBlock(y,m),this._des1.decryptBlock(y,m)},keySize:192/32,ivSize:64/32,blockSize:64/32});r.TripleDES=a._createHelper(_)})(),i.TripleDES})}),x8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=a.RC4=n.extend({_doReset:function(){for(var c=this._key,d=c.words,f=c.sigBytes,u=this._S=[],p=0;p<256;p++)u[p]=p;for(var p=0,g=0;p<256;p++){var _=p%f,y=d[_>>>2]>>>24-_%4*8&255;g=(g+u[p]+y)%256;var m=u[p];u[p]=u[g],u[g]=m}this._i=this._j=0},_doProcessBlock:function(c,d){c[d]^=l.call(this)},keySize:256/32,ivSize:0});function l(){for(var c=this._S,d=this._i,f=this._j,u=0,p=0;p<4;p++){d=(d+1)%256,f=(f+c[d])%256;var g=c[d];c[d]=c[f],c[f]=g,u|=c[(c[d]+c[f])%256]<<24-p*8}return this._i=d,this._j=f,u}r.RC4=n._createHelper(o);var h=a.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var c=this.cfg.drop;c>0;c--)l.call(this)}});r.RC4Drop=n._createHelper(h)})(),i.RC4})}),E8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=[],l=[],h=[],c=a.Rabbit=n.extend({_doReset:function(){for(var f=this._key.words,u=this.cfg.iv,p=0;p<4;p++)f[p]=(f[p]<<8|f[p]>>>24)&16711935|(f[p]<<24|f[p]>>>8)&4278255360;var g=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],_=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var p=0;p<4;p++)d.call(this);for(var p=0;p<8;p++)_[p]^=g[p+4&7];if(u){var y=u.words,m=y[0],O=y[1],b=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,v=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,E=b>>>16|v&4294901760,T=v<<16|b&65535;_[0]^=b,_[1]^=E,_[2]^=v,_[3]^=T,_[4]^=b,_[5]^=E,_[6]^=v,_[7]^=T;for(var p=0;p<4;p++)d.call(this)}},_doProcessBlock:function(f,u){var p=this._X;d.call(this),o[0]=p[0]^p[5]>>>16^p[3]<<16,o[1]=p[2]^p[7]>>>16^p[5]<<16,o[2]=p[4]^p[1]>>>16^p[7]<<16,o[3]=p[6]^p[3]>>>16^p[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,f[u+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var f=this._X,u=this._C,p=0;p<8;p++)l[p]=u[p];u[0]=u[0]+1295307597+this._b|0,u[1]=u[1]+3545052371+(u[0]>>>0<l[0]>>>0?1:0)|0,u[2]=u[2]+886263092+(u[1]>>>0<l[1]>>>0?1:0)|0,u[3]=u[3]+1295307597+(u[2]>>>0<l[2]>>>0?1:0)|0,u[4]=u[4]+3545052371+(u[3]>>>0<l[3]>>>0?1:0)|0,u[5]=u[5]+886263092+(u[4]>>>0<l[4]>>>0?1:0)|0,u[6]=u[6]+1295307597+(u[5]>>>0<l[5]>>>0?1:0)|0,u[7]=u[7]+3545052371+(u[6]>>>0<l[6]>>>0?1:0)|0,this._b=u[7]>>>0<l[7]>>>0?1:0;for(var p=0;p<8;p++){var g=f[p]+u[p],_=g&65535,y=g>>>16,m=((_*_>>>17)+_*y>>>15)+y*y,O=((g&4294901760)*g|0)+((g&65535)*g|0);h[p]=m^O}f[0]=h[0]+(h[7]<<16|h[7]>>>16)+(h[6]<<16|h[6]>>>16)|0,f[1]=h[1]+(h[0]<<8|h[0]>>>24)+h[7]|0,f[2]=h[2]+(h[1]<<16|h[1]>>>16)+(h[0]<<16|h[0]>>>16)|0,f[3]=h[3]+(h[2]<<8|h[2]>>>24)+h[1]|0,f[4]=h[4]+(h[3]<<16|h[3]>>>16)+(h[2]<<16|h[2]>>>16)|0,f[5]=h[5]+(h[4]<<8|h[4]>>>24)+h[3]|0,f[6]=h[6]+(h[5]<<16|h[5]>>>16)+(h[4]<<16|h[4]>>>16)|0,f[7]=h[7]+(h[6]<<8|h[6]>>>24)+h[5]|0}r.Rabbit=n._createHelper(c)})(),i.Rabbit})}),w8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.StreamCipher,a=r.algo,o=[],l=[],h=[],c=a.RabbitLegacy=n.extend({_doReset:function(){var f=this._key.words,u=this.cfg.iv,p=this._X=[f[0],f[3]<<16|f[2]>>>16,f[1],f[0]<<16|f[3]>>>16,f[2],f[1]<<16|f[0]>>>16,f[3],f[2]<<16|f[1]>>>16],g=this._C=[f[2]<<16|f[2]>>>16,f[0]&4294901760|f[1]&65535,f[3]<<16|f[3]>>>16,f[1]&4294901760|f[2]&65535,f[0]<<16|f[0]>>>16,f[2]&4294901760|f[3]&65535,f[1]<<16|f[1]>>>16,f[3]&4294901760|f[0]&65535];this._b=0;for(var _=0;_<4;_++)d.call(this);for(var _=0;_<8;_++)g[_]^=p[_+4&7];if(u){var y=u.words,m=y[0],O=y[1],b=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,v=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,E=b>>>16|v&4294901760,T=v<<16|b&65535;g[0]^=b,g[1]^=E,g[2]^=v,g[3]^=T,g[4]^=b,g[5]^=E,g[6]^=v,g[7]^=T;for(var _=0;_<4;_++)d.call(this)}},_doProcessBlock:function(f,u){var p=this._X;d.call(this),o[0]=p[0]^p[5]>>>16^p[3]<<16,o[1]=p[2]^p[7]>>>16^p[5]<<16,o[2]=p[4]^p[1]>>>16^p[7]<<16,o[3]=p[6]^p[3]>>>16^p[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,f[u+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var f=this._X,u=this._C,p=0;p<8;p++)l[p]=u[p];u[0]=u[0]+1295307597+this._b|0,u[1]=u[1]+3545052371+(u[0]>>>0<l[0]>>>0?1:0)|0,u[2]=u[2]+886263092+(u[1]>>>0<l[1]>>>0?1:0)|0,u[3]=u[3]+1295307597+(u[2]>>>0<l[2]>>>0?1:0)|0,u[4]=u[4]+3545052371+(u[3]>>>0<l[3]>>>0?1:0)|0,u[5]=u[5]+886263092+(u[4]>>>0<l[4]>>>0?1:0)|0,u[6]=u[6]+1295307597+(u[5]>>>0<l[5]>>>0?1:0)|0,u[7]=u[7]+3545052371+(u[6]>>>0<l[6]>>>0?1:0)|0,this._b=u[7]>>>0<l[7]>>>0?1:0;for(var p=0;p<8;p++){var g=f[p]+u[p],_=g&65535,y=g>>>16,m=((_*_>>>17)+_*y>>>15)+y*y,O=((g&4294901760)*g|0)+((g&65535)*g|0);h[p]=m^O}f[0]=h[0]+(h[7]<<16|h[7]>>>16)+(h[6]<<16|h[6]>>>16)|0,f[1]=h[1]+(h[0]<<8|h[0]>>>24)+h[7]|0,f[2]=h[2]+(h[1]<<16|h[1]>>>16)+(h[0]<<16|h[0]>>>16)|0,f[3]=h[3]+(h[2]<<8|h[2]>>>24)+h[1]|0,f[4]=h[4]+(h[3]<<16|h[3]>>>16)+(h[2]<<16|h[2]>>>16)|0,f[5]=h[5]+(h[4]<<8|h[4]>>>24)+h[3]|0,f[6]=h[6]+(h[5]<<16|h[5]>>>16)+(h[4]<<16|h[4]>>>16)|0,f[7]=h[7]+(h[6]<<8|h[6]>>>24)+h[5]|0}r.RabbitLegacy=n._createHelper(c)})(),i.RabbitLegacy})}),T8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Ql(),eh(),tl(),Wr()):typeof define=="function"&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],r):r(i.CryptoJS)})(e,function(i){return(function(){var r=i,s=r.lib,n=s.BlockCipher,a=r.algo;let o=16,l=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],h=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var c={pbox:[],sbox:[]};function d(_,y){let m=y>>24&255,O=y>>16&255,b=y>>8&255,v=y&255,E=_.sbox[0][m]+_.sbox[1][O];return E=E^_.sbox[2][b],E=E+_.sbox[3][v],E}function f(_,y,m){let O=y,b=m,v;for(let E=0;E<o;++E)O=O^_.pbox[E],b=d(_,O)^b,v=O,O=b,b=v;return v=O,O=b,b=v,b=b^_.pbox[o],O=O^_.pbox[o+1],{left:O,right:b}}function u(_,y,m){let O=y,b=m,v;for(let E=o+1;E>1;--E)O=O^_.pbox[E],b=d(_,O)^b,v=O,O=b,b=v;return v=O,O=b,b=v,b=b^_.pbox[1],O=O^_.pbox[0],{left:O,right:b}}function p(_,y,m){for(let T=0;T<4;T++){_.sbox[T]=[];for(let P=0;P<256;P++)_.sbox[T][P]=h[T][P]}let O=0;for(let T=0;T<o+2;T++)_.pbox[T]=l[T]^y[O],O++,O>=m&&(O=0);let b=0,v=0,E=0;for(let T=0;T<o+2;T+=2)E=f(_,b,v),b=E.left,v=E.right,_.pbox[T]=b,_.pbox[T+1]=v;for(let T=0;T<4;T++)for(let P=0;P<256;P+=2)E=f(_,b,v),b=E.left,v=E.right,_.sbox[T][P]=b,_.sbox[T][P+1]=v;return!0}var g=a.Blowfish=n.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var _=this._keyPriorReset=this._key,y=_.words,m=_.sigBytes/4;p(c,y,m)}},encryptBlock:function(_,y){var m=f(c,_[y],_[y+1]);_[y]=m.left,_[y+1]=m.right},decryptBlock:function(_,y){var m=u(c,_[y],_[y+1]);_[y]=m.left,_[y+1]=m.right},blockSize:64/32,keySize:128/32,ivSize:64/32});r.Blowfish=n._createHelper(g)})(),i.Blowfish})}),S8=Zt((e,t)=>{(function(i,r,s){typeof e=="object"?t.exports=e=r(ii(),Jg(),t8(),i8(),Ql(),r8(),eh(),gw(),S1(),s8(),_w(),n8(),a8(),o8(),I1(),l8(),tl(),Wr(),h8(),c8(),u8(),d8(),f8(),p8(),g8(),_8(),O8(),m8(),b8(),y8(),v8(),x8(),E8(),w8(),T8()):typeof define=="function"&&define.amd?define(["./core","./x64-core","./lib-typedarrays","./enc-utf16","./enc-base64","./enc-base64url","./md5","./sha1","./sha256","./sha224","./sha512","./sha384","./sha3","./ripemd160","./hmac","./pbkdf2","./evpkdf","./cipher-core","./mode-cfb","./mode-ctr","./mode-ctr-gladman","./mode-ofb","./mode-ecb","./pad-ansix923","./pad-iso10126","./pad-iso97971","./pad-zeropadding","./pad-nopadding","./format-hex","./aes","./tripledes","./rc4","./rabbit","./rabbit-legacy","./blowfish"],r):i.CryptoJS=r(i.CryptoJS)})(e,function(i){return i})}),I8=(e=>(e.Device="Device",e.Symbol="Symbol",e.Footprint="Footprint",e.OBJ="OBJ",e.ModelID="3D Model",e.ModelName="3D Model Title",e.OriginModelName="Origin 3D Model Title",e.ModelTransform="3D Model Transform",e.OriginFootprint="Origin Footprint",e))(I8||{}),P8=(e=>(e.DOCHEAD="DOCHEAD",e.EDIT_HEAD="EDIT_HEAD",e.SCH="SCH",e.SCH_PAGE="SCH_PAGE",e.PCB="PCB",e.PANEL="PANEL",e.PANEL_LIB="PANEL_LIB",e.SYMBOL="SYMBOL",e.FOOTPRINT="FOOTPRINT",e.DEVICE="DEVICE",e.BLOB="BLOB",e.INSTANCE="INSTANCE",e.CONFIG="CONFIG",e.BOARD="BOARD",e.FONT="FONT",e.VARIANT="VARIANT",e.COMPONENT_GROUP="COMPONENT_GROUP",e.COMPONENT_GROUP_DATA="COMPONENT_GROUP_DATA",e.SIMULATION="SIMULATION",e))(P8||{}),A8=(e=>(e.META="META",e.META_SORT="META_SORT",e.META_CREATE="META_CREATE",e.META_MODIFY="META_MODIFY",e.FONT="FONT",e.BLOB="BLOB",e.MAX_NUM="MAX_NUM",e.INSTANCE_ATTR="INSTANCE_ATTR",e.DELETE_DOC="DELETE_DOC",e.META_Z_INDEX="META_Z_INDEX",e.VARIANT_GROUPED="VARIANT_GROUPED",e.GROUP_INDEX="GROUP_INDEX",e.GROUP_DATA="GROUP_DATA",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.META_PLACEHOLDER="META_PLACEHOLDER",e))(A8||{});function Md(e,t,i){return e.slice(t,i)}function A3(e,t,i){let r=e.length,s=0;for(;s<r;){let n=e.indexOf(`|
`,s);if(n<0){if(i)return e.substring(s);n=r}let a=Md(e,s,n);try{if(a){let o=a.indexOf("||"),l=o>-1,h=l?Md(a,0,o):a,c=l?Md(a,o+2):"";if(t(h,c,a,l?s+o+2:s)===!1){a=null;break}a=null}}catch(o){console.error(o)}s=n+2}e=null}var C8=["SYMBOL","FOOTPRINT","BLOB","FONT","PANEL_LIB","DEVICE","BOARD","INSTANCE","CONFIG","VARIANT","COMPONENT_GROUP","COMPONENT_GROUP_DATA"];function jm(e,t){return C8.includes(t)?t:e}var L8=class{parseFull(e,t,i){let r=t,s=i,n,a=null;A3(e,(o,l,h)=>{let c=JSON.parse(o);if(c.type==="EDIT_HEAD")a=JSON.parse(l),this.onEditHead&&this.onEditHead(a);else if(c.type==="DOCHEAD"){let d=JSON.parse(l);s=d.docType,r=d.uuid,n=d.client,d.ticket=c.ticket,this.onDocHead(d,a,h)}else this.onLine(c.id,c.ticket,l,c.type,c.client||n,s,r,c.firstTicket,c.pend,a,c.num,h)}),this.onEnd(),e=null}flowParseFull(e={}){let{cache:t,chunkLength:i=100*1024*1024,idsData:r,history:s}=e,n="",a=null,o,l=null,h=!0,c="",d=0,f=!1,u={},p=t?{}:void 0,g=new Set,_=O=>{p[O]===void 0&&(p[O]=-1),t(O,++p[O],u[O].data.join(`|
`)),u[O].data.length=0,u[O].size=0,u[O].data.push(u[O].head),u[O].size+=u[O].head.length},y=O=>{if(g.add(n),!t)return;let b=jm(n,a);u[b].data.push(O),u[b].size+=(u[b].size?2:0)+O.length,u[b].size+O.length>i&&_(b)},m=(O,b)=>A3(O,(v,E,T,P)=>{var A,C,M,H,k,F,j,L;let R=JSON.parse(v);if(R.type==="EDIT_HEAD")l=JSON.parse(E),(A=this.onEditHead)==null||A.call(this,l),(C=e.onEditHead)==null||C.call(e,l),f=!0;else if(R.type==="DOCHEAD"){let x=JSON.parse(E);a=x.docType,n=x.uuid,o=x.client,x.ticket=R.ticket,f||(l={uuid:x.uuid,username:(M=x==null?void 0:x.user)==null?void 0:M.username,nickname:(H=x==null?void 0:x.user)==null?void 0:H.nickname,updateTime:x==null?void 0:x.updateTime},(k=e.onEditHead)==null||k.call(e,l),f=!0),this.onDocHead(x,l,T,s);let I=jm(n,a);t&&!u[I]&&(u[I]={size:0,data:[],head:""}),t&&(u[I].head=T),y(T)}else{let x=R.num,I=R.client||o;if(r){let S=(L=(j=(F=r.ids)==null?void 0:F[n])==null?void 0:j[I])==null?void 0:L[R.id];if(!S||S[0]!==R.ticket)return;x=S[1],r.size-=1,delete r.ids[n][I][R.id]}if(s){let S=jm(n,a);t&&(s.dNum=(p==null?void 0:p[S])===void 0?0:(p==null?void 0:p[S])+1),s.start=t?u[S].size+2+v.length+2:d+P,s.size=T.length,R.client&&(s.hClient=!0)}this.onLine(R.id,R.ticket,E,R.type,I,a,n,R.firstTicket,R.pend,l||(s==null?void 0:s.editHead),x,T,s),y(T)}},b);return{start:()=>{h=!0},end:()=>{if(c&&m(c,!1),t)for(let O in u)u[O].size&&u[O].data.length>1&&_(O),u[O]=null;h=!1,c="",n="",n=null,o="",l=null,this.onEnd()},update:O=>{if(!h)throw new Error("\u66F4\u65B0\u524D\u672A\u8C03\u7528 start \u65B9\u6CD5");let b=m(c+O,!0);d=d+c.length+O.length-((b==null?void 0:b.length)||0),c="",b&&(c=b)},docMap:p,getDocIds:()=>Array.from(g)}}parseLine(e,t,i){let r=e.indexOf("||"),s=r!==-1,n=s?Md(e,0,r):e,a=s?Md(e,r+2):"",o=JSON.parse(n);this.onLine(o.id,o.ticket,a,o.type,o.client,i,t,o.firstTicket,o.pend,void 0,o.num,e),e=null}onEditHead(e){}},Vm=new Uint8Array(8);function so(){crypto.getRandomValues(Vm);let e="";for(let t=0;t<Vm.length;t++)e+=Vm[t].toString(16).padStart(2,"0");return e}var Ow=class extends L8{constructor(e){super(),this.unique=so(),this.maxTicket=0,this.isPendChange=!0,this.isLocalChange=!0,this.cbArr=[],this.tempLocalIds={},this.docMaxTicket={},this.client=e||so()}onLine(e,t,i,r,s,n,a,o,l,h,c){this.remoteChange(t,s,a,e,i,r,n,void 0,o,l,h,void 0,void 0,c)}getUnique(){return this.unique}setUnique(e){this.unique=e}setDocMaxTicket(e,t,i){i||(!this.docMaxTicket[e]||this.docMaxTicket[e]<t)&&(this.docMaxTicket[e]=t)}getDocMaxTicket(e){var t;return(t=this.docMaxTicket[e])!=null?t:0}onDocHead(e,t){}onEnd(){}setIsPendChange(e){this.isPendChange=e}getIsPendChange(){return this.isPendChange}getMaxTicket(){return this.maxTicket}setMaxTicket(e,t){e&&(t||this.maxTicket<e)&&(this.maxTicket=e)}setIsLocalChange(e){this.isLocalChange=e}getIsLocalChange(){return this.isLocalChange}revoke(e,t,i,r,s,n,a,o,l,h,c){var d;if(!((d=this.tempLocalIds[e])!=null&&d[t]))return c?c(t,s,i,a,`${r}-1`,e,n,void 0,void 0,!0,h):this.cbArr.forEach(f=>f(e,t,i,a,`${r}-1`,s,void 0,n,void 0,void 0,void 0,h)),!0}getRandomUuid(){return so()}getClient(){return this.client}onChange(e){this.cbArr.push(e)}localChange(e,t,i,r,s,n){let a=this.maxTicket+1;return this.tempLocalIds[e]||(this.tempLocalIds[e]={}),this.tempLocalIds[e][t]=[this.getClient(),a],this.remoteChange(a,this.client,e,t,i,r,s,!0,void 0,!0,void 0,this.unique,void 0,n),a}remoteChange(e,t,i,r,s,n,a,o,l,h,c,d,f,u){var p;this.setMaxTicket(e);let g=d===this.unique,_=o||g,y=(!_||_&&this.isLocalChange)&&(!f||f&&this.isPendChange),m=(p=this.tempLocalIds[i])==null?void 0:p[r];!o&&g?m?(y=!1,m[0]===t&&m[1]===e&&delete this.tempLocalIds[i][r]):y=!0:!o&&m&&(m[1]>e||m[1]===e&&m[0]>t?y=!1:delete this.tempLocalIds[i][r]),this.setDocMaxTicket(i,e,h),y&&this.cbArr.forEach(O=>O(i,r,s,n,t,e,l,h,void 0,f,d,u))}},D8=class{constructor(e){this.item=e,this.parent=null,this.left=null,this.right=null,this.height=1}getParent(){return this.parent}getLeft(){return this.left}getRight(){return this.right}getHeight(){return this.height}setLeft(e){if(this.left!==null)throw new Error("insert exists left is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert left with node has parent is not permitted");this.left=e,e.parent=this,this.updateHeight()}}setRight(e){if(this.right!==null)throw new Error("insert exists right is not permitted");if(e!==null){if(e.parent!==null)throw new Error("insert right with node has parent is not permitted");this.right=e,e.parent=this,this.updateHeight()}}removeLeft(){if(this.left===null)return null;{let e=this.left;return e.parent=null,this.left=null,this.updateHeight(),e}}removeRight(){if(this.right===null)return null;{let e=this.right;return e.parent=null,this.right=null,this.updateHeight(),e}}rotateRight(e){let t=this.removeLeft();if(this.setLeft(t.removeRight()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setRight(this)}else t.setRight(this),e(t)}rotateLeft(e){let t=this.removeRight();if(this.setRight(t.removeLeft()),this.parent){let i=this.parent;i.getLeft()===this?(i.removeLeft(),i.setLeft(t)):(i.removeRight(),i.setRight(t)),t.setLeft(this)}else t.setLeft(this),e(t)}updateHeight(){var e,t;let i=this;for(;i!==null;)i.height=Math.max(((e=i.left)==null?void 0:e.height)||0,((t=i.right)==null?void 0:t.height)||0)+1,i=i.parent}},R8=class{constructor(e){this.comparator=e,this.root=null,this.size=0}balance(e){var t,i;let r=((t=e.getLeft())==null?void 0:t.getHeight())||0,s=((i=e.getRight())==null?void 0:i.getHeight())||0,n=e.getParent();r>s?r-s>1?(e.rotateRight(a=>this.root=a),this.verify()):n!==null?n.getRight()===e&&(e.rotateRight(a=>this.root=a),this.verify()):(e.rotateRight(a=>this.root=a),this.verify()):s>r&&(s-r>1?(e.rotateLeft(a=>this.root=a),this.verify()):n!==null?n.getLeft()===e&&(e.rotateLeft(a=>this.root=a),this.verify()):(e.rotateLeft(a=>this.root=a),this.verify())),n&&this.balance(n)}forwardTraverse(e){let t=new Array(10),i=this.findMin();for(;i;)switch(t.pop()||2){case 1:i.getLeft()!==null?(t.push(2),t.push(1),i=i.getLeft()):t.push(2);break;case 2:if(!e(i.item))return;i.getRight()!==null?(t.push(3),t.push(1),i=i.getRight()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}backwardTraverse(e){let t=new Array(10),i=this.findMax();for(;i;)switch(t.pop()||2){case 1:i.getRight()!==null?(t.push(2),t.push(1),i=i.getRight()):t.push(2);break;case 2:if(!e(i.item))return;i.getLeft()!==null?(t.push(3),t.push(1),i=i.getLeft()):t.push(3);break;case 3:i=i.getParent();break;default:throw new Error("invalid status")}}display(e=this.root,t=new Array,i=0){let r="| ".repeat(i);return e?(t.push(r+`\u25CF(${JSON.stringify(e.item)})
`),this.display(e.getLeft(),t,i+1),this.display(e.getRight(),t,i+1)):t.push(r+`\u2609
`),t}getHeight(){var e;return((e=this.root)==null?void 0:e.getHeight())||0}getSize(){return this.size}insert(e){let t=new D8(e);if(this.root===null)return this.root=t,this.size++,!0;{let i=this.root;for(;;){let r=this.comparator(e,i.item);if(r<0){if(i.getLeft()===null)return i.setLeft(t),this.size++,this.verify(),this.balance(i),!0;i=i.getLeft()}else if(r>0){if(i.getRight()===null)return i.setRight(t),this.size++,this.verify(),this.balance(i),!0;i=i.getRight()}else return!1}}}verify(){}remove(e){let t=this.root;for(this.verify();;){if(t===null)return!1;let i=this.comparator(e,t.item);if(i<0)t=t.getLeft();else if(i>0)t=t.getRight();else return this.removeNode(t),this.size--,this.verify(),!0}}removeNode(e){var t,i;let r=e.getParent();if(r===null)e.getLeft()===null&&e.getRight()===null?this.root=null:((((t=e.getLeft())==null?void 0:t.getHeight())||0)>(((i=e.getRight())==null?void 0:i.getHeight())||0)?(e.rotateRight(s=>this.root=s),this.verify()):(e.rotateLeft(s=>this.root=s),this.verify()),this.removeNode(e));else if(r.getLeft()===e){r.removeLeft();let s=this.combineNodes(e.removeLeft(),e.removeRight());r.setLeft(s),this.verify(),this.balance(r)}else{r.removeRight();let s=this.combineNodes(e.removeLeft(),e.removeRight());r.setRight(s),this.verify(),this.balance(r)}}combineNodes(e,t){if(e&&t)if(e.getHeight()>t.getHeight()){let i=this.findMaxChild(e);if(i){let r=i.getParent();return r.removeRight(),r.setRight(i.removeLeft()),i.setLeft(e),i.setRight(t),i}else return e.setRight(t),e}else{let i=this.findMinChild(t);if(i){let r=i.getParent();return r.removeLeft(),r.setLeft(i.removeRight()),i.setLeft(e),i.setRight(t),i}else return t.setLeft(e),t}else return e||t||null}findMax(){let e=this.root;for(;;){let t=e==null?void 0:e.getRight();if(t)e=t;else return e}}findMin(){let e=this.root;for(;;){let t=e==null?void 0:e.getLeft();if(t)e=t;else return e}}findMinChild(e){let t=e;for(;;){if(t.getLeft()===null)return t!==e?t:null;t=t.getLeft()}}findMaxChild(e){let t=e;for(;;){if(t.getRight()===null)return t!==e?t:null;t=t.getRight()}}};function pr(e,t){return JSON.stringify([t,e])}function Xo(e){try{let t=JSON.parse(e);return typeof t=="string"?e:t[1]}catch{return e}}function Ym(e,t,i){let r=e[t];return r!==void 0||(r=i(t),e[t]=r),r}var N8=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.POLY="POLY",e.STRING="STRING",e.AUX_LINE="AUXLINE",e.DIMENSION="DIMENSION",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(N8||{}),M8=(e=>(e.META="META",e.CANVAS="CANVAS",e.LAYER="LAYER",e.LAYER_PHYS="LAYER_PHYS",e.ACTIVE_LAYER="ACTIVE_LAYER",e.PARTITION="PARTITION",e.NET="NET",e.PRIMITIVE="PRIMITIVE",e.GROUP="GROUP",e.SILK_OPTS="SILK_OPTS",e.PREFERENCE="PREFERENCE",e.VIA="VIA",e.PAD="PAD",e.LINE="LINE",e.ARC="ARC",e.OBJ="OBJ",e.EQLEN_GRP="EQLEN_GRP",e.POLY="POLY",e.FILL="FILL",e.LAYER_FILL="LAYER_FILL",e.REGION="REGION",e.POUR="POUR",e.POURED="POURED",e.IMAGE="IMAGE",e.TEARDROP="TEARDROP",e.FPC_FILL="FPC_FILL",e.SHELL="SHELL",e.CREASE="CREASE",e.SHELLCUT="SHELLCUT",e.SHELL_ENTITY="SHELL_ENTITY",e.BOSS="BOSS",e.STRING="STRING",e.ATTR="ATTR",e.DIMENSION="DIMENSION",e.COMPONENT="COMPONENT",e.PAD_NET="PAD_NET",e.RULE_TEMPLATE="RULE_TEMPLATE",e.RULE="RULE",e.RULE_SELECTOR="RULE_SELECTOR",e.PANELIZE="PANELIZE",e.BOARD="BOARD",e.X_SIGNALS_GROUP="X_SIGNAL_GROUP",e.X_SIGNALS="X_SIGNALS",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e))(M8||{}),B8=(e=>(e.META="META",e.CANVAS="CANVAS",e.GROUP="GROUP",e.ATTR="ATTR",e.LINE="LINE",e.WIRE="WIRE",e.BUS="BUS",e.TEXT="TEXT",e.POLY="POLY",e.CIRCLE="CIRCLE",e.ARC="ARC",e.BUSENTRY="BUSENTRY",e.RECT="RECT",e.MASK_REGION="MASK_REGION",e.PIN="PIN",e.OBJ="OBJ",e.COMPONENT="COMPONENT",e.PART="PART",e.ELLIPSE="ELLIPSE",e.BEZIER="BEZIER",e.TABLE="TABLE",e.ELE_PLACEHOLDER="ELE_PLACEHOLDER",e.NG_SETTING="NG_SETTING",e))(B8||{});var k8=["PARTITION","VIA","PAD","LINE","ARC","OBJ","POLY","FILL","REGION","POUR","POURED","IMAGE","TEARDROP","FPC_FILL","SHELL","CREASE","SHELLCUT","SHELL_ENTITY","BOSS","STRING","ATTR","DIMENSION","COMPONENT"];var Tee=Cc(Hd()),F8=(e=>(e.SOLID="SOLID",e.SHORT_DASH="SHORT_DASH",e.DOT="DOT",e.DOT_DASH="DOT_DASH",e))(F8||{}),U8=(e=>(e.PRINT="PRINT",e.COVER="COVER",e.PRINT_AND_COVER="PRINT&COVER",e))(U8||{}),G8=(e=>(e.LEFT="LEFT",e.CENTER="CENTER",e.RIGHT="RIGHT",e))(G8||{}),z8=(e=>(e.TOP="TOP",e.MIDDLE="MIDDLE",e.BOTTOM="BOTTOM",e))(z8||{}),H8=(e=>(e.LEFT_BOTTOM="LEFT_BOTTOM",e.CENTER_BOTTOM="CENTER_BOTTOM",e.RIGHT_BOTTOM="RIGHT_BOTTOM",e.LEFT_MIDDLE="LEFT_MIDDLE",e.CENTER_MIDDLE="CENTER_MIDDLE",e.RIGHT_MIDDLE="RIGHT_MIDDLE",e.LEFT_TOP="LEFT_TOP",e.CENTER_TOP="CENTER_TOP",e.RIGHT_TOP="RIGHT_TOP",e))(H8||{}),j8=(e=>(e.NONE="NONE",e.SOLID="SOLID",e.GRID="GRID",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e.RHOMBIC="RHOMBIC",e.LEFT_SLASH_LINE="LEFT_SLASH_LINE",e.RIGHT_SLASH_LINE="RIGHT_SLASH_LINE",e))(j8||{}),V8=(e=>(e.NONE="NONE",e.CLOCK="CLOCK",e.INVERTED="INVERTED",e.INVERTED_CLOCK="INVERTED_CLOCK",e))(V8||{}),Y8=(e=>(e.NONE="NONE",e.GRID="GRID",e.OUTLETS="OUTLETS",e))(Y8||{}),q8=(e=>(e.NONE="NONE",e.PUSH="PUSH",e.SURROUND="SURROUND",e.OBSTRUCT="OBSTRUCT",e.SURROUND_AND_PUSH="SURROUND&PUSH",e))(q8||{}),W8=(e=>(e.ELLIPSE="ELLIPSE",e.RECT="RECT",e.OVAL="OVAL",e.POLYGON="POLYGON",e))(W8||{}),X8=(e=>(e.ROUND="ROUND",e.RECT="RECT",e.SLOT="SLOT",e))(X8||{}),J8=(e=>(e.SOLID="SOLID",e.GRID_LINE="GRID_LINE",e.HORIZONTAL_LINE="HORIZONTAL_LINE",e.VERTICAL_LINE="VERTICAL_LINE",e))(J8||{}),Z8=(e=>(e.ALL="ALL",e.PAD="PAD",e.VIA="VIA",e))(Z8||{}),K8=(e=>(e.NONE="NONE",e.SINGLE="SINGLE",e.ALL="ALL",e))(K8||{}),$8=(e=>(e.OPTIMIZA_OPEN="OPTIMIZA_OPEN",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))($8||{}),Q8=(e=>(e.OPTIMIZA_STRONG="OPTIMIZA_STRONG",e.OPTIMIZA_WEAK="OPTIMIZA_WEAK",e.OPTIMIZA_NONE="OPTIMIZA_NONE",e))(Q8||{}),e7=(e=>(e.L45="L45",e.L90="L90",e.L="L",e.R45="R45",e.R90="R90",e.R="R",e))(e7||{}),t7=(e=>(e.NORMAL="NORMAL",e.BLIND="BLIND",e.SUTURE="SUTURE",e))(t7||{}),i7=(e=>(e.NORMAL="NORMAL",e.TEST="TEST",e.MARKER="MARKER",e))(i7||{}),r7=(e=>(e.DIVERGENCE="DIVERGENCE",e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(r7||{}),s7=(e=>(e.DOT="DOT",e.CENTER="CENT",e))(s7||{}),n7=(e=>(e.NORMAL="NORMAL",e.BOARD_OUTLINE="BOARD_OUTLINE",e))(n7||{}),jd=(e=>(e.SOLID="SOLID",e.GRID="GRID",e.PLANE="PLANE",e))(jd||{}),a7=(e=>(e.PROHIBIT="PROHIBIT",e.CONSTRAINT="CONSTRAINT",e))(a7||{}),o7=(e=>(e.COMPONENT="COMPONENT",e.VIA="VIA",e.TRACK="TRACK",e.FILL="FILL",e.COPPER="COPPER",e.PLANE="PLANE",e))(o7||{}),l7=(e=>(e.PI="Polyimide",e.FR4="FR4",e.STEEL_SHEET="Stainless Steel",e.M3_DOUBLE_SIDED_TAPE="3M Tape",e.EMI_SHIELDING_FILM="EMI Shielding Film",e))(l7||{}),h7=(e=>(e.PUSH_COVER="DRAWER",e.UPPER_LOWER_SHELLS="T&B",e))(h7||{}),c7=(e=>(e.X_AXIS_POSITIVE="X_AXIS_POSITIVE",e.X_AXIS_NEGATIVE="X_AXIS_NEGATIVE",e.Y_AXIS_POSITIVE="Y_AXIS_POSITIVE",e.Y_AXIS_NEGATIVE="Y_AXIS_NEGATIVE",e))(c7||{}),u7=(e=>(e.SLOT="SLOT",e.ENTITY="ENTITY",e))(u7||{}),d7=(e=>(e.AUTO="AUTO",e.UPPER_SHELLS="UPPER_SHELLS",e.LOWER_SHELLS="LOWER_SHELLS",e))(d7||{}),f7=(e=>(e.OUTLINE="OUTLINE",e.SCREW_PILLAR="SCREW_PILLAR",e.ENTITY="ENTITY",e))(f7||{}),p7=(e=>(e.M2="M2",e.M3="M3",e.M4="M4",e.M5="M5",e.M6="M6",e))(p7||{}),g7=(e=>(e.LENGTH="LENGTH",e.RADIUS="RADIUS",e.ANGLE="ANGLE",e))(g7||{}),_7=(e=>(e.MIL="mil",e.INCH="inch",e.CM="cm",e.MM="mm",e))(_7||{}),O7=(e=>(e.SAFE="SAFE",e.OTHER="OTHER",e.CREEPAGE="CREEPAGE",e.TRACK="TRACK",e.BLIND="BLIND",e.RADIUS="RADIUS",e.PLANE="PLANE",e.COPPER="COPPER",e.PASTE="PASTE",e.SOLDER="SOLDER",e.DIFFER_ENTAIL="DIFFER_ENTAIL",e.NET_LENGTH="NET_LENGTH",e.AUTO_ROUTER="AUTO_ROUTER",e.NET_LENGTH_TOLERANCE="NET_LENGTH_TOLERANCE",e))(O7||{}),m7=(e=>(e.NORMAL="NORMAL",e.DEFAULT="DEFAULT",e))(m7||{}),b7=(e=>(e.ALL="ALL",e.LAYERED="LAYERED",e))(b7||{}),y7=(e=>(e.DIRECT="DIRECT",e.NON_CONNECT="NON_CONNECT",e))(y7||{}),v7=(e=>(e.FORTY_FIVE="L45",e.NINETY="L90",e.NINETY_ARC="A90",e))(v7||{}),x7=(e=>(e.LESS="LESS",e.MID="MID",e.MORE="MORE",e))(x7||{}),E7=(e=>(e.SPEED_FIRST="SPEED_FIRST",e.COMPLETION_FIRST="COMPLETION_FIRST",e))(E7||{}),w7=(e=>(e.DesignRule="DesignRule",e.Board="Board",e.SlotRegion="SlotRegion",e.ProhibitedRegion="ProhibitedRegion",e.ConstraintRegion="ConstraintRegion",e.Component="Component",e.Track="Track",e.TestPoint="TestPoint",e.Pad="Pad",e.Via="Via",e.SutureHole="SutureHole",e.Text="Text",e.ColorfulImage="ColorfulImage",e.Image="Image",e.FPCStiffener="FPCStiffener",e.Dimension="Dimension",e.CopperRegion="CopperRegion",e.FillRegion="Fill Region",e.Line="Line",e.Teardrop="Teardrop",e.D3Shell="D3Shell",e))(w7||{}),T7=Cc(S8());function C3(e,t,i,r,s,n,a,o){return JSON.stringify([e||"",t||"",i,r,s?1:0,n?1:0,a?1:0,o])}function S7(e){let t=JSON.parse(e);return{text:t[0],fontFamily:t[1],fontSize:t[2],thickness:t[3],bold:!!t[4],italic:!!t[5],reverse:!!t[6],expansion:t[7]}}function I7(e){return T7.default.SHA256(e).toString()}function P7(e,t){return e.ticket===t.ticket?e.client===t.client?e.id===t.id?0:e.id<t.id?-1:1:e.client<t.client?-1:1:e.ticket<t.ticket?-1:1}var A7=class{constructor(e=1){this.startNum=e,this.orderLists={},this.idOrderLists={},this.cbArr=new Array,this.maxNum={}}orderChange(e){this.cbArr.push(e)}setOrderNum(e,t,i,r,s=1){if(s<1)throw new Error("step must be greater than 0");let n=Ym(this.orderLists,t,()=>new R8(P7)),a=Ym(this.maxNum,t,()=>this.startNum-1),o=Ym(this.idOrderLists,t,()=>new Map),l=o.get(e);if(l){if(l.ticket<=i)return;n.remove(l),a-=l.step}let h={id:e,ticket:i,num:0,client:r,step:s};o.set(e,h),n.insert(h),a+=s;let c=a,d=0;n.backwardTraverse(f=>(d++,f.num=c,this.cbArr.forEach(u=>u(f.id,t,f.num)),c-=f.step,f!==h)),this.maxNum[t]=a,d>1e4&&(console.log("------------------ notify --------",h,"height: ",n.getHeight(),"total: ",n.getSize(),"notifies: ",d),console.log("------------------ all --------"))}getOrderNum(e,t){var i,r,s,n;return(n=(s=(r=(i=this.idOrderLists)==null?void 0:i[t])==null?void 0:r.get)==null?void 0:s.call(r,e))==null?void 0:n.num}getMaxNum(e){var t;return((t=this.orderLists[e])==null?void 0:t.getSize())||0}clearNum(){for(let e in this.idOrderLists)this.idOrderLists[e].clear(),delete this.idOrderLists[e];for(let e in this.orderLists)delete this.orderLists[e]}},C7=class{constructor(e,t=1,i=[]){this.consistencyManager=e,this.startNum=t,this.needOrderType=i,this.initIng=!1,this.allOrderNum={},this.maxNum={},this.consistencyManager.onChange((r,s,n,a,o,l,h,c,d,f,u,p)=>{try{if(this.calculation)if(a==="ELE_PLACEHOLDER"){let g=n?JSON.parse(n):null;g&&this.calculation.setOrderNum(s,g.dataType,h!=null?h:l,o,g.max)}else this.calculation.setOrderNum(s,a,h!=null?h:l,o);this.onParseLine(s,a,n?JSON.parse(n):null,o,l,c,p)}catch(g){console.error(g)}})}initCalculation(){this.calculation=new A7(this.startNum)}setIsInit(e){this.initIng=e}setNeedNum(e){this.needNum=e}setOrderNum(e,t,i){this.needNum&&this.needOrderType&&this.needOrderType.includes(i)&&t!==void 0&&(this.allOrderNum[e]=t,this.setMaxNum(i,t))}deleteOrderNum(e){delete this.allOrderNum[e]}getOrderNum(e){return this.allOrderNum[e]}setMaxNum(e,t,i){(i||this.maxNum[e]===void 0||this.maxNum[e]<t)&&(this.maxNum[e]=t)}getMaxNum(e){return this.maxNum[e]===void 0&&(this.maxNum[e]=this.startNum-1),++this.maxNum[e]}};function L7(e){switch(e=String(e),e){case"1":return"SAFE";case"2":return"OTHER";case"3":return"TRACK";case"4":return"BLIND";case"5":return"RADIUS";case"6":return"PLANE";case"7":return"COPPER";case"8":return"PASTE";case"9":return"SOLDER";case"10":return"DIFFER_ENTAIL";case"11":return"NET_LENGTH";case"12":return"AUTO_ROUTER";case"13":return"NET_LENGTH_TOLERANCE"}return e}function D7(e){if(!e)return{};let t=["1","2","3","4","5","6","7","8","9","10","11","12","13"];for(let i of t)if(e.hasOwnProperty(i)){let r=e[i];delete e[i],e[L7(i)]=r}return e}var R7=Object.create,mw=Object.defineProperty,N7=Object.getOwnPropertyDescriptor,M7=Object.getOwnPropertyNames,B7=Object.getPrototypeOf,k7=Object.prototype.hasOwnProperty,F7=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),U7=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of M7(t))!k7.call(e,s)&&s!==i&&mw(e,s,{get:()=>t[s],enumerable:!(r=N7(t,s))||r.enumerable});return e},G7=(e,t,i)=>(i=e!=null?R7(B7(e)):{},U7(t||!e||!e.__esModule?mw(i,"default",{value:e,enumerable:!0}):i,e)),z7=F7((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(x,I,S){S=S||2;var D=I&&I.length,N=D?I[0]*S:x.length,G=r(x,0,N,S,!0),z=[];if(!G||G.next===G.prev)return z;var Z,se,he,pe,Se,q,X;if(D&&(G=c(x,I,G,S)),x.length>80*S){Z=he=x[0],se=pe=x[1];for(var ie=S;ie<N;ie+=S)Se=x[ie],q=x[ie+1],Se<Z&&(Z=Se),q<se&&(se=q),Se>he&&(he=Se),q>pe&&(pe=q);X=Math.max(he-Z,pe-se),X=X!==0?32767/X:0}return n(G,z,S,Z,se,X,0),z}function r(x,I,S,D,N){var G,z;if(N===R(x,I,S,D)>0)for(G=I;G<S;G+=D)z=F(G,x[G],x[G+1],z);else for(G=S-D;G>=I;G-=D)z=F(G,x[G],x[G+1],z);return z&&E(z,z.next)&&(j(z),z=z.next),z}function s(x,I){if(!x)return x;I||(I=x);var S=x,D;do if(D=!1,!S.steiner&&(E(S,S.next)||v(S.prev,S,S.next)===0)){if(j(S),S=I=S.prev,S===S.next)break;D=!0}else S=S.next;while(D||S!==I);return I}function n(x,I,S,D,N,G,z){if(x){!z&&G&&g(x,D,N,G);for(var Z=x,se,he;x.prev!==x.next;){if(se=x.prev,he=x.next,G?o(x,D,N,G):a(x)){I.push(se.i/S|0),I.push(x.i/S|0),I.push(he.i/S|0),j(x),x=he.next,Z=he.next;continue}if(x=he,x===Z){z?z===1?(x=l(s(x),I,S),n(x,I,S,D,N,G,2)):z===2&&h(x,I,S,D,N,G):n(s(x),I,S,D,N,G,1);break}}}}function a(x){var I=x.prev,S=x,D=x.next;if(v(I,S,D)>=0)return!1;for(var N=I.x,G=S.x,z=D.x,Z=I.y,se=S.y,he=D.y,pe=N<G?N<z?N:z:G<z?G:z,Se=Z<se?Z<he?Z:he:se<he?se:he,q=N>G?N>z?N:z:G>z?G:z,X=Z>se?Z>he?Z:he:se>he?se:he,ie=D.next;ie!==I;){if(ie.x>=pe&&ie.x<=q&&ie.y>=Se&&ie.y<=X&&O(N,Z,G,se,z,he,ie.x,ie.y)&&v(ie.prev,ie,ie.next)>=0)return!1;ie=ie.next}return!0}function o(x,I,S,D){var N=x.prev,G=x,z=x.next;if(v(N,G,z)>=0)return!1;for(var Z=N.x,se=G.x,he=z.x,pe=N.y,Se=G.y,q=z.y,X=Z<se?Z<he?Z:he:se<he?se:he,ie=pe<Se?pe<q?pe:q:Se<q?Se:q,de=Z>se?Z>he?Z:he:se>he?se:he,Ce=pe>Se?pe>q?pe:q:Se>q?Se:q,De=y(X,ie,I,S,D),Fe=y(de,Ce,I,S,D),Pe=x.prevZ,w=x.nextZ;Pe&&Pe.z>=De&&w&&w.z<=Fe;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0||(Pe=Pe.prevZ,w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;Pe&&Pe.z>=De;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0)return!1;Pe=Pe.prevZ}for(;w&&w.z<=Fe;){if(w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function l(x,I,S){var D=x;do{var N=D.prev,G=D.next.next;!E(N,G)&&T(N,D,D.next,G)&&M(N,G)&&M(G,N)&&(I.push(N.i/S|0),I.push(D.i/S|0),I.push(G.i/S|0),j(D),j(D.next),D=x=G),D=D.next}while(D!==x);return s(D)}function h(x,I,S,D,N,G){var z=x;do{for(var Z=z.next.next;Z!==z.prev;){if(z.i!==Z.i&&b(z,Z)){var se=k(z,Z);z=s(z,z.next),se=s(se,se.next),n(z,I,S,D,N,G,0),n(se,I,S,D,N,G,0);return}Z=Z.next}z=z.next}while(z!==x)}function c(x,I,S,D){var N=[],G,z,Z,se,he;for(G=0,z=I.length;G<z;G++)Z=I[G]*D,se=G<z-1?I[G+1]*D:x.length,he=r(x,Z,se,D,!1),he===he.next&&(he.steiner=!0),N.push(m(he));for(N.sort(d),G=0;G<N.length;G++)S=f(N[G],S);return S}function d(x,I){return x.x-I.x}function f(x,I){var S=u(x,I);if(!S)return I;var D=k(S,x);return s(D,D.next),s(S,S.next)}function u(x,I){var S=I,D=x.x,N=x.y,G=-1/0,z;do{if(N<=S.y&&N>=S.next.y&&S.next.y!==S.y){var Z=S.x+(N-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(Z<=D&&Z>G&&(G=Z,z=S.x<S.next.x?S:S.next,Z===D))return z}S=S.next}while(S!==I);if(!z)return null;var se=z,he=z.x,pe=z.y,Se=1/0,q;S=z;do D>=S.x&&S.x>=he&&D!==S.x&&O(N<pe?D:G,N,he,pe,N<pe?G:D,N,S.x,S.y)&&(q=Math.abs(N-S.y)/(D-S.x),M(S,x)&&(q<Se||q===Se&&(S.x>z.x||S.x===z.x&&p(z,S)))&&(z=S,Se=q)),S=S.next;while(S!==se);return z}function p(x,I){return v(x.prev,x,I.prev)<0&&v(I.next,x,x.next)<0}function g(x,I,S,D){var N=x;do N.z===0&&(N.z=y(N.x,N.y,I,S,D)),N.prevZ=N.prev,N.nextZ=N.next,N=N.next;while(N!==x);N.prevZ.nextZ=null,N.prevZ=null,_(N)}function _(x){var I,S,D,N,G,z,Z,se,he=1;do{for(S=x,x=null,G=null,z=0;S;){for(z++,D=S,Z=0,I=0;I<he&&(Z++,D=D.nextZ,!!D);I++);for(se=he;Z>0||se>0&&D;)Z!==0&&(se===0||!D||S.z<=D.z)?(N=S,S=S.nextZ,Z--):(N=D,D=D.nextZ,se--),G?G.nextZ=N:x=N,N.prevZ=G,G=N;S=D}G.nextZ=null,he*=2}while(z>1);return x}function y(x,I,S,D,N){return x=(x-S)*N|0,I=(I-D)*N|0,x=(x|x<<8)&16711935,x=(x|x<<4)&252645135,x=(x|x<<2)&858993459,x=(x|x<<1)&1431655765,I=(I|I<<8)&16711935,I=(I|I<<4)&252645135,I=(I|I<<2)&858993459,I=(I|I<<1)&1431655765,x|I<<1}function m(x){var I=x,S=x;do(I.x<S.x||I.x===S.x&&I.y<S.y)&&(S=I),I=I.next;while(I!==x);return S}function O(x,I,S,D,N,G,z,Z){return(N-z)*(I-Z)>=(x-z)*(G-Z)&&(x-z)*(D-Z)>=(S-z)*(I-Z)&&(S-z)*(G-Z)>=(N-z)*(D-Z)}function b(x,I){return x.next.i!==I.i&&x.prev.i!==I.i&&!C(x,I)&&(M(x,I)&&M(I,x)&&H(x,I)&&(v(x.prev,x,I.prev)||v(x,I.prev,I))||E(x,I)&&v(x.prev,x,x.next)>0&&v(I.prev,I,I.next)>0)}function v(x,I,S){return(I.y-x.y)*(S.x-I.x)-(I.x-x.x)*(S.y-I.y)}function E(x,I){return x.x===I.x&&x.y===I.y}function T(x,I,S,D){var N=A(v(x,I,S)),G=A(v(x,I,D)),z=A(v(S,D,x)),Z=A(v(S,D,I));return!!(N!==G&&z!==Z||N===0&&P(x,S,I)||G===0&&P(x,D,I)||z===0&&P(S,x,D)||Z===0&&P(S,I,D))}function P(x,I,S){return I.x<=Math.max(x.x,S.x)&&I.x>=Math.min(x.x,S.x)&&I.y<=Math.max(x.y,S.y)&&I.y>=Math.min(x.y,S.y)}function A(x){return x>0?1:x<0?-1:0}function C(x,I){var S=x;do{if(S.i!==x.i&&S.next.i!==x.i&&S.i!==I.i&&S.next.i!==I.i&&T(S,S.next,x,I))return!0;S=S.next}while(S!==x);return!1}function M(x,I){return v(x.prev,x,x.next)<0?v(x,I,x.next)>=0&&v(x,x.prev,I)>=0:v(x,I,x.prev)<0||v(x,x.next,I)<0}function H(x,I){var S=x,D=!1,N=(x.x+I.x)/2,G=(x.y+I.y)/2;do S.y>G!=S.next.y>G&&S.next.y!==S.y&&N<(S.next.x-S.x)*(G-S.y)/(S.next.y-S.y)+S.x&&(D=!D),S=S.next;while(S!==x);return D}function k(x,I){var S=new L(x.i,x.x,x.y),D=new L(I.i,I.x,I.y),N=x.next,G=I.prev;return x.next=I,I.prev=x,S.next=N,N.prev=S,D.next=S,S.prev=D,G.next=D,D.prev=G,D}function F(x,I,S,D){var N=new L(x,I,S);return D?(N.next=D.next,N.prev=D,D.next.prev=N,D.next=N):(N.prev=N,N.next=N),N}function j(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function L(x,I,S){this.i=x,this.x=I,this.y=S,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(x,I,S,D){var N=I&&I.length,G=N?I[0]*S:x.length,z=Math.abs(R(x,0,G,S));if(N)for(var Z=0,se=I.length;Z<se;Z++){var he=I[Z]*S,pe=Z<se-1?I[Z+1]*S:x.length;z-=Math.abs(R(x,he,pe,S))}var Se=0;for(Z=0;Z<D.length;Z+=3){var q=D[Z]*S,X=D[Z+1]*S,ie=D[Z+2]*S;Se+=Math.abs((x[q]-x[ie])*(x[X+1]-x[q+1])-(x[q]-x[X])*(x[ie+1]-x[q+1]))}return z===0&&Se===0?0:Math.abs((Se-z)/z)};function R(x,I,S,D){for(var N=0,G=I,z=S-D;G<S;G+=D)N+=(x[z]-x[G])*(x[G+1]+x[z+1]),z=G;return N}i.flatten=function(x){for(var I=x[0][0].length,S={vertices:[],holes:[],dimensions:I},D=0,N=0;N<x.length;N++){for(var G=0;G<x[N].length;G++)for(var z=0;z<I;z++)S.vertices.push(x[N][G][z]);N>0&&(D+=x[N-1].length,S.holes.push(D))}return S}}),H7=(e=>(e[e.MIL=1]="MIL",e[e.INCH=1e3]="INCH",e[e.FT=12e3]="FT",e[e.YARD=36e3]="YARD",e[e.MILE=6336e4]="MILE",e[e.KM=3937007874e-2]="KM",e[e.M=39370]="M",e[e.DM=3937]="DM",e[e.CM=393.7]="CM",e[e.MM=39.37]="MM",e[e.UM=.039]="UM",e[e.NM=394e-7]="NM",e[e.PT=13.88888888888889]="PT",e[e.PX72=13.88888888888889]="PX72",e[e.PX96=10.416666666666666]="PX96",e[e.PX100=10]="PX100",e[e.LTSPICE=6.25]="LTSPICE",e[e.PX1=.1]="PX1",e[e.PX001=.001]="PX001",e))(H7||{}),j7=(e=>(e.MIL="mil",e.INCH="inch",e.FT="ft",e.YARD="yard",e.MILE="mile",e.KM="km",e.M="m",e.DM="dm",e.CM="cm",e.MM="mm",e.UM="um",e.NM="nm",e.PT="pt",e.PX72="px(72)",e.PX96="px(96)",e.PX100="px(100)",e))(j7||{}),L3={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},See=(()=>{let e={};for(let t in L3)e[L3[t]]=t;return e})(),gg,Iee=(gg=class{constructor(e,t){this.ratio=e/t}wrap(e){return e*this.ratio}static convert(e,t,i){return e*t/i}},gg.ASIS=new gg(1,1),gg),_g=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,s=this[r](i);return t=="mil"?Math.round(s*10)/10:Math.round(s*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};_g.prototype["px(100)2mil"]=e=>e*10,_g.prototype["px(100)2mm"]=e=>e*.254,_g.prototype["mil2px(100)"]=e=>e/10,_g.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var Og=null,P1=new ArrayBuffer(8),qm=new Float64Array(P1),Wm=new Uint32Array(P1),D3=new Uint16Array(P1),R3=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!Og){let e=this.getUrlVars().version;e?Og="/analyzer/v"+e:Og="/analyzer"}return Og}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;qm[0]=new Date().getTime(),e.push(Wm[1].toString(16)),qm[0]=Math.random(),e.push(D3[3].toString(16));let t=D3[2].toString(16);e.push("4"+t.substr(0,3)),qm[0]=performance.now();let i=Wm[0].toString(16)+Wm[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},bw=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(wc.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(wc.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(wc.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(wc.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},V7=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(V7||{}),Y7=/(\.?0+)$/,wc=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(R3.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(R3.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);bw.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(Y7,"")}},q7=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARNING=2]="WARNING",e[e.ERROR=3]="ERROR",e[e.DUMMY=4]="DUMMY",e))(q7||{});function W7(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var X7=(e,t)=>{e===3?console.error(t):console.log(t)},J7=(e,t)=>wc.format("%s %s: %s",new Date,W7(e),t),fc,Zg=(fc=class{constructor(e,t=X7,i=J7){this.debug=!1,this.level=e,this.writer=t,this.fmt=i}static mix(...e){let t=4;for(let i of e)i.level<t&&(t=i.level);return new fc(t,(i,r)=>{for(let s of e)s.write1(i,r)},(i,r)=>r)}wrap(e=null,t=null){let i=e===null?this.fmt:(s,n)=>(n=e(s,n),this.fmt(s,n)),r=t===null?this.writer:(s,n)=>{t(s,n),this.writer(s,n)};return new fc(this.level,r,i)}chain(e){return e.wrap(this.fmt.bind(this),this.writer.bind(this))}include(e){return this.level<=e}write3(e,t,i){this.include(e)&&this.writer(e,this.fmt(e,wc.format(t,...i)))}write2(e,t){this.include(e)&&(t instanceof Error?this.writer(e,this.fmt(e,t.stack)):this.writer(e,this.fmt(e,t.toString())))}write1(e,t){this.include(e)&&this.writer(e,this.fmt(e,t))}debug3(e,...t){this.write3(0,e,t)}debug2(e){this.write2(0,e)}debug1(e){this.write1(0,e)}info3(e,...t){this.write3(1,e,t)}info2(e){this.write2(1,e)}info1(e){this.write1(1,e)}warning3(e,...t){this.write3(2,e,t)}warning2(e){this.write2(2,e)}warning1(e){this.write1(2,e)}error3(e,...t){this.write3(3,e,t)}error2(e){this.write2(3,e)}error1(e){this.write1(3,e)}},fc.DUMMY=new fc(4),fc),A1=new ArrayBuffer(8),Xm=new Float64Array(A1),Jm=new Uint32Array(A1),N3=new Uint16Array(A1),M3=ArrayBuffer;try{M3=self.HTMLImageElement||M3}catch{}var mg=null;function Kl(e,t,i=0,r=e.length){s(e,null,t,i,r);function s(a,o,l,h,c){let d,f,u,p;if(h<c-1){let g=c-h;if(g>50)o===null&&(o=new Array(g+1)),n(a,o,l,h,(h+c)/2|0,c);else{d=a[h],f=h,u=h,p=c;let _=f+1;for(;_<p;){if(u!=p){if(p=p+-1,l(d,a[p])<=0)continue;a[u]=a[p],u=p;continue}if(l(d,a[_])>=0){f=_,_=f+1;continue}a[u]=a[_],f=_,u=_,_=f+1}a[u]=d,s(a,o,l,h,u),s(a,o,l,u+1,c)}}}function n(a,o,l,h,c,d){s(a,o,l,h,c),s(a,o,l,c,d);for(var f=h,u=c,p=0,g=a[f],_=a[u];f<c&&u<d;){var y=l(g,_);isNaN(y)?(o[p++]=_,_=a[++u]):(y<=0&&(o[p++]=g,g=a[++f]),y>=0&&(o[p++]=_,_=a[++u]))}for(;f<c;f++)o[p++]=a[f];for(;u<d;u++)o[p++]=a[u];for(f=h,u=0;u<p;f++,u++)a[f]=o[u]}}var ns=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!mg){let e=this.getUrlVars().version;e?mg="/analyzer/v"+e:mg="/analyzer"}return mg}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;Xm[0]=new Date().getTime(),e.push(Jm[1].toString(16)),Xm[0]=Math.random(),e.push(N3[3].toString(16));let t=N3[2].toString(16);e.push("4"+t.substr(0,3)),Xm[0]=performance.now();let i=Jm[0].toString(16)+Jm[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},Z7=[1,10,100,1e3],bg=0,Yl=0;function B3(e,t,i){return bg=Math.abs(e-t),i>=5&&bg>1e-5||isNaN(i)&&bg>1e-8?!1:bg<1e-13?!0:(Yl=Math.min(k3(e),k3(t)),Yl<10&&(Yl=10),isNaN(i)||(Yl=Math.min(Yl,i)),F3(e,Yl)===F3(t,Yl))}var yg=0,vg=0;function k3(e){return yg=0,vg=0,e>0?yg=e-Math.floor(e):yg=e-Math.ceil(e),vg=(yg.toString()||"").length,vg>2?vg-2:0}function F3(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=Z7[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}var K7=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PERCENT=1]="PERCENT",e[e.LEFT_PAD0=2]="LEFT_PAD0",e))(K7||{}),$7=/(\.?0+)$/,Tc=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(ns.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(ns.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);Ii.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace($7,"")}},Ii=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Tc.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Tc.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Tc.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Tc.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},xg,Te=(xg=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}},xg.eps=1e-8,xg.precision=1e8,xg);function Ic(e,t){Ug(e.iterator(),t)}function Ug(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var Q7=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function f1(e){return new Q7(e)}var rs,gt=(rs=class{static toDegrees(e){return e*180/Math.PI}static toRadians(e){return e/180*Math.PI}static regularD(e){return e=e%360,e=e<0?360+e:e,e===360?0:e}static regular(e){return e=e%rs.PIx2,e=e<0?rs.PIx2+e:e,e===rs.PIx2?0:e}static toQuarterBase(e){return rs.regular((e+rs.PI_4)/rs.PI_2*rs.PI_2)}static toQuarterBaseD(e){return rs.regularD(((e+45)/90|0)*90)}static transformD(e,t){return rs.toDegrees(rs.transform(rs.toRadians(e),t))}static transform(e,t){let i=Math.cos(e),r=Math.sin(e),s=new be(t.data[6],t.data[7]),n=new be(i,r).multiply3(t);return rs.regular(n.angle(s))}},rs.PIx2=Math.PI*2,rs.PI_2=Math.PI/2,rs.PI_4=Math.PI/4,rs),Gi=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,s,n){return this.dotProd1(i-e,r-t,s-i,n-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,s,n){return this.crossProd1(i-e,r-t,s-i,n-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let s=i-e,n=r-t;return s*s+n*n}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},yw=new ArrayBuffer(16),U3=new Float64Array(yw),Eg=new Int32Array(yw),Jt,be=(Jt=class{static sortByXAsc(e,t){return e.x-t.x}static sortByYAsc(e,t){return e.y-t.y}static sortByXYAsc(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y-t.y}static caculateAngle(e,t){let i=Math.cos(e),r=Math.sin(e),s=i*t.data[0]+r*t.data[4],n=i*t.data[1]+r*t.data[5],a=new Jt(s,n).normalize();return Math.atan2(a.y,a.x)}static normal(e,t,i){let r=t.sub(e),s=i.sub(t);return r.cross(s)}static getVector2(e){return new Jt(Math.cos(e),Math.sin(e))}static getCrossPoint1(e,t,i,r){if(e.equals1(t)||i.equals1(r)||Te.eq(1,Math.abs(t.sub(e).normalize().dot(r.sub(i).normalize()))))return null;let s=t.y-e.y,n=e.x-t.x,a=t.x*e.y-e.x*t.y,o=r.y-i.y,l=i.x-r.x,h=r.x*i.y-i.x*r.y,c=s*l-o*n;return new Jt((h*n-a*l)/c,(a*o-h*s)/c)}static getCrossPoint2(e,t,i,r){return this.getCrossPoint1(e,e.add(t),i,i.add(r))}constructor(e,t){this.x=Ii.normal(e),this.y=Ii.normal(t)}get hashed(){return this._hashed==null&&(U3[0]=this.x,U3[1]=this.y,this._hashed=Eg[0]^Eg[1]^Eg[2]^Eg[3]),this._hashed}dot(e){return this.x*e.x+this.y*e.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(e){var t=this.x-e.x,i=this.y-e.y;return new Jt(t,i)}add(e){var t=this.x+e.x,i=this.y+e.y;return new Jt(t,i)}div(e){return new Jt(this.x/e,this.y/e)}add1(e,t){return new Jt(this.x+e,this.y+t)}mul(e){return new Jt(this.x*e,this.y*e)}cross(e){return this.x*e.y-this.y*e.x}getSin(){return this.y/this.length()}angle2(e){let t=this.y-e.y,i=this.x-e.x;return t=Math.abs(t-0)<10**-4?0:t,i=Math.abs(i-0)<10**-4?0:i,Math.atan2(t,i)}angleD2(e){return gt.toDegrees(this.angle2(e))}angle(e){return Math.atan2(this.y-e.y,this.x-e.x)}angleX(e=Jt.ORIGIN){let t=this.angle(e);return t<0&&(t=Math.PI*2+t),t}angleD(e){return gt.toDegrees(this.angle(e))}distance1(e){let t=e.x-this.x,i=e.y-this.y;return Gi.hypot(t,i)}distance2(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i}rotateD(e,t){return this.rotate(e,gt.toRadians(t))}rotate(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,n=this.y-e.y,a=s*i+n*-r,o=s*r+n*i;return e.add1(a,o)}multiply3(e){let t=this.x*e.data[0]+this.y*e.data[3]+e.data[6],i=this.x*e.data[1]+this.y*e.data[4]+e.data[7];return new Jt(t,i)}multiply4(e){let t=this.x*e.data[0]+this.y*e.data[4]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+e.data[13];return new Jt(t,i)}hashCode(){return this.hashed}equals(e,t){return e instanceof Jt?B3(e.x,this.x,t)&&B3(e.y,this.y,t):!1}equals1(e){return e?Te.eq(this.x,e.x)&&Te.eq(this.y,e.y):!1}equals2(e,t){return e instanceof Jt?Math.abs(this.x-e.x)<=t&&Math.abs(this.y-e.y)<=t:!1}similarEquals(e,t=.5){return Math.abs(this.x*.1-e.x*.1)<=t&&Math.abs(this.y*.1-e.y*.1)<=t}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let e=this.x,t=this.y;return new ss(e,e,t,t)}normalize(){if(this.x===0&&this.y===0)return new Jt(0,0);let e=this.x/this.length(),t=this.y/this.length();return new Jt(e,t)}regular(e=1e-4){let t=Math.round(1/e);return new Jt(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}round(e=4){let t=10**(e|0);return new Jt(Math.round(this.x*t)/t,Math.round(this.y*t)/t)}mirrorX(e=Jt.ORIGIN){return new Jt(this.x,2*e.y-this.y)}mirrorY(e=Jt.ORIGIN){return new Jt(2*e.x-this.x,this.y)}mirrorCenter(e=Jt.ORIGIN){return new Jt(2*e.x-this.x,2*e.y-this.y)}clone(){return new Jt(this.x,this.y)}mirror(e=Jt.ORIGIN){return new Jt(2*e.x-this.x,2*e.y-this.y)}pointOnRays(e,t){let i=gt.toRadians(e);return new Jt(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}pointOnRays2(e,t){let i=e.angle(this);return new Jt(this.x+Math.cos(i)*t,this.y+Math.sin(i)*t)}scale(e){return new Jt(this.x*e,this.y*e)}},Jt.ORIGIN=new Jt(0,0),Jt.X_UNIT_VECTOR=new Jt(1,0),Jt.Y_UNIT_VECTOR=new Jt(0,1),Jt),e9=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(e9||{}),t9=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(t9||{}),Er,Qa=(Er=class{constructor(e,t){this.horizontal=e,this.vertical=t}},Er.LT=new Er(0,0),Er.LC=new Er(0,1),Er.LB=new Er(0,2),Er.CT=new Er(1,0),Er.CC=new Er(1,1),Er.CB=new Er(1,2),Er.RT=new Er(2,0),Er.RC=new Er(2,1),Er.RB=new Er(2,2),Er),i9=(e=>(e[e.INNER=0]="INNER",e[e.OUTER=1]="OUTER",e[e.SEPARATED=2]="SEPARATED",e[e.INTERSECTED=3]="INTERSECTED",e[e.EQ=4]="EQ",e[e.INSIDE_TOUCHED=5]="INSIDE_TOUCHED",e[e.OUTSIDE_TOUCHED=6]="OUTSIDE_TOUCHED",e))(i9||{}),Fs=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return Ic(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new be(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new ss(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new ss(this.minX,this.maxX,this.minY,this.maxY):new ss(0,0,0,0)}},xd=new Float64Array(4),ss=class mn{static extendRect({x:t,y:i,width:r,height:s}){return new mn(t,t+r,i,i+s)}static extend1(t,i){if(t===null)return new mn(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),s=Math.max(t.maxX,i.x),n=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new mn(r,s,n,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),s=Math.max(t.maxX,i.maxX),n=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new mn(r,s,n,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),s=Math.max(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new mn(r,s,n,a)}static extend4(t,i,r){return new mn(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,s){if(this.minX=Ii.normal(t),this.maxX=Ii.normal(i),this.minY=Ii.normal(r),this.maxY=Ii.normal(s),t>i||r>s)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${s}]`)}get data(){return xd[0]=this.minX,xd[1]=this.maxX,xd[2]=this.minY,xd[3]=this.maxY,xd}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return Te.greatereq(t,this.minX)&&Te.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return Te.greatereq(t,this.minY)&&Te.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return Ii.positiveOr0(this.maxX-this.minX+t*2),Ii.positiveOr0(this.maxY-this.minY+t*2),new mn(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return Te.greatereq(this.maxX,t.maxX)&&Te.lesseq(this.minX,t.minX)&&Te.greatereq(this.maxY,t.maxY)&&Te.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return s>n?null:new mn(i,r,s,n)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(Te.greater(i,r))return null;i>r&&(r=i);let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return Te.greater(s,n)?null:(s>n&&(n=s),new mn(i,r,s,n))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new be(this.minX,this.maxY)}UR(){return new be(this.maxX,this.maxY)}LL(){return new be(this.minX,this.minY)}LR(){return new be(this.maxX,this.minY)}center(){return new be(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new Fs;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new Fs;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let s;this.minY>=t.minY?s=this.minY:s=t.minY;let n;return this.maxY<=t.maxY?n=this.maxY:n=t.maxY,s>n}}relation(t){let i=0,r=0,s;this.minX>t.minX?(i++,s=this.minX):this.minX===t.minX?s=this.minX:(r++,s=t.minX);let n;if(this.maxX<t.maxX?(i++,n=this.maxX):this.maxX===t.maxX?n=this.maxX:(r++,n=t.maxX),s>n)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:s===n||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),s=this.center();return t!=0&&(i/=t/2,r/=t/2),new mn(s.x-i,s.x+i,s.y-i,s.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),mn.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),s=this.width()*i/2,n=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>s?o>n?Qa.RT:o<-n?Qa.RB:Qa.RC:a<-s?o>n?Qa.LT:o<-n?Qa.LB:Qa.LC:o>n?Qa.CT:o<-n?Qa.CB:Qa.CC}bbox(){return this}},Gg=class Bt{static mul(t,i,r,s,n,a){let o=0,l=0;for(let h=0;h<t;h++){for(let c=0;c<r;c++){let d=c,f=0;for(let u=0;u<i;u++)f+=s[l+u]*n[d],d+=r;a[o++]=f}l+=i}}constructor(t,i,r){this.m=Ii.normal(t),this.n=Ii.normal(i);let s=t*i;if(r.length===s){for(let n=0;n<r.length;n++)Ii.normal(r[n]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return Bt.mul(this.m,this.n,t.n,this.data,t.data,i),new Bt(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let s=0;s<this.n;s++){let n=this.data[i++].toString();s===0?(t.push(`
`),t.push("	"),t.push(n)):(t.push(", "),t.push(n))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,s=r*2,n=new Array(i*s);for(let a=0;a<i;a++)for(let o=0;o<s;o++)o<r?n[Bt.on(s,a,o)]=t[Bt.on(r,a,o)]:o===i+a?n[Bt.on(s,a,o)]=1:n[Bt.on(s,a,o)]=0;return n}inverseMatrix(t,i,r){for(let s=0;s<i;s++){let n=t[Bt.on(r,s,s)];for(let a=0;a<r;a++)t[Bt.on(r,s,a)]/=n}return t}getMatrixRank(t,i,r){let s=Math.min(i,r);for(let n=0;n<i;n++){if(t[Bt.on(r,n,n)]===0){let a=new Array(r),o;for(o=n;o<i;o++)if(t[Bt.on(r,o,n)]!==0){ns.arraycopy(t,Bt.on(r,o,0),a,0,r),ns.arraycopy(t,Bt.on(r,n,0),t,Bt.on(r,o,0),r),ns.arraycopy(a,0,t,Bt.on(r,n,0),r);break}o>=i&&(s-=1)}if(!(s<i))for(let a=0;a<i;a++){if(a===n)continue;let o=t[Bt.on(r,a,n)]/t[Bt.on(r,n,n)];for(let l=0;l<r;l++)t[Bt.on(r,a,l)]-=t[Bt.on(r,n,l)]*o}}return s}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return Te.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function s(a,o){for(let l=0;l<r;l++){let h=i[Bt.on(r,a,l)];i[Bt.on(r,a,l)]=i[Bt.on(r,o,l)],i[Bt.on(r,o,l)]=h}}for(let a=0;a<this.m;a++){let o=Math.abs(i[Bt.on(r,a,a)]),l=a;if(t(i[Bt.on(r,a,a)]))for(let c=a+1;c<this.m;c++){if(t(i[Bt.on(r,c,a)])){Math.abs(i[Bt.on(r,c,a)])>o&&(o=Math.abs(i[Bt.on(r,c,a)]),l=c);continue}s(a,c);break}if(t(i[Bt.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&s(a,l)}let h=1/i[Bt.on(r,a,a)];for(let c=0;c<r;c++)i[Bt.on(r,a,c)]*=h;for(let c=0;c<this.m;c++){if(a===c)continue;let d=i[Bt.on(r,c,a)];for(let f=a;f<r;f++)i[Bt.on(r,c,f)]-=i[Bt.on(r,a,f)]*d}}let n=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)n[Bt.on(this.n,a,o-this.n)]=i[Bt.on(r,a,o)];return new Bt(this.m,this.n,n)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new Bt(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof Bt?!(this.m!=t.m||this.n!=t.n||!ns.equals(this.data,t.data)):!1}},r9=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ni,vw=(Ni=class extends Gg{static translate(e,t,i){return new Ni([1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1])}static translate1(e){return new Ni([1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1])}static rotateX(e){let t=Math.cos(e),i=Math.sin(e);return new Ni([1,0,0,0,0,t,i,0,0,-i,t,0,0,0,0,1])}static rotateY(e){let t=Math.cos(e),i=Math.sin(e);return new Ni([t,0,-i,0,0,1,0,0,i,0,t,0,0,0,0,1])}static rotateZ(e){let t=Math.cos(e),i=Math.sin(e);return new Ni([t,i,0,0,-i,t,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(e,t){e=e.normalize();let i=e.x,r=e.y,s=e.z,n=Math.sin(t),a=Math.cos(t);return new Ni([i*i*(1-a)+a,i*r*(1-a)+s*n,i*s*(1-a)-r*n,0,i*r*(1-a)-s*n,r*r*(1-a)+a,r*s*(1-a)+i*n,0,i*s*(1-a)+r*n,r*s*(1-a)-i*n,s*s*(1-a)+a,0,0,0,0,1])}static scale(e,t=e,i=e){return new Ni([e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1])}static flipX(){return new Ni([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new Ni([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(e,t){return e.equals1(be.ORIGIN)?Ni.rotateZ(t):Ni.translate(-e.x,-e.y,0).rotateZ(t).translate1(e.x,e.y,0)}static getMatrix4(e,t,i,r){let s=Math.cos(t),n=Math.sin(t),a=i*(e.x*s-e.y*n)+r.x,o=e.x*n+e.y*s+r.y,l=[i*s,n,0,0,-n*i,s,0,0,0,0,1,0,a,o,0,1];return new Ni(l)}constructor(e=r9){super(4,4,e)}translate(e){return this.multiply4(Ni.translate1(e))}translate1(e,t,i){return this.multiply4(Ni.translate(e,t,i))}rotateX(e){return this.multiply4(Ni.rotateX(e))}rotateY(e){return this.multiply4(Ni.rotateY(e))}rotateZ(e){return this.multiply4(Ni.rotateZ(e))}scale(e,t=e,i=e){return this.multiply4(Ni.scale(e,t,i))}scale1(e){return this.multiply4(Ni.scale(e.x,e.y,e.z))}setOrigin(e,t,i){return Ni.translate(-e,-t,-i).multiply4(this).translate1(e,t,i)}setOrigin1(e){return this.setOrigin(e.x,e.y,e.z)}multiply4(e){let t=new Array(16);return Gg.mul(4,4,4,this.data,e.data,t),new Ni(t)}getInverseMatrix(){let e=super.getInverseMatrix();return new Ni(e.data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Ni(e.data)}inverse(){let e=this.getInverseMatrix();return new Ni(e.data)}toMatrix3(){let e=this.data;return new er([e[0],e[1],0,e[4],e[5],0,e[12],e[13],1])}},Ni.ORIGIN=new Ni,Ni);function Ed(e){return bw.normal(parseFloat(e))}var s9=[1,0,0,0,1,0,0,0,1],Ei,er=(Ei=class extends Gg{static translate(e,t){return new Ei([1,0,0,0,1,0,e,t,1])}static translate1(e){return this.translate(e.x,e.y)}static rotate(e){let t=Math.cos(e),i=Math.sin(e);return new Ei([t,i,0,-i,t,0,0,0,1])}static rotateD(e){return this.rotate(gt.toRadians(e))}static scale(e,t=e){return new Ei([e,0,0,0,t,0,0,0,1])}static scale1(e,t){return new Ei([e,0,0,0,t,0,0,0,1])}static toDOMMatrix(e){let[t,i,,r,s,,n,a]=e.data;return`matrix(${[t,i,r,s,n,a].join(",")})`}static svgTrasform(e){let t=e.split(" "),i=null;return t.forEach(r=>{r=r.trim();let s=r.trim().replace(")","").split("("),n=s[0],a=s[1].split(",");switch(n){case"translate":let o=Ed(a[0]),l=Ed(a[1]);i=i?i.translate(o,l):Ei.translate(o,l);break;case"rotate":let h=Ed(a[0]),c=Ed(a[1]),d=Ed(a[2]);i=i?i.setOrigin(c,d):Ei.translate(c,d),i=i.rotateD(h);break;default:return}}),i}constructor(e=s9){super(3,3,e);let t=e[0],i=e[3],r=e[1],s=e[4];this.iScale=Math.sqrt(t*t+r*r),this.jScale=Math.sqrt(i*i+s*s)}isMirrored(){return this.det()<0}multiply3(e){let t=new Array(9);return Gg.mul(3,3,3,this.data,e.data,t),new Ei(t)}translate(e,t){return this.multiply3(Ei.translate(e,t))}translate1(e){return this.multiply3(Ei.translate1(e))}scale(e,t=e){return this.multiply3(Ei.scale(e,t))}scale1(e,t){return this.multiply3(Ei.scale1(e,t))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let e=this.getInverseMatrix();return new Ei(e.data)}rotateD(e){return this.multiply3(Ei.rotateD(e))}rotate(e){return this.multiply3(Ei.rotate(e))}resetOffset(){let e=this.data;return new Ei([e[0],e[1],0,e[3],e[4],0,0,0,1])}setOrigin(e,t){return Ei.translate(-e,-t).multiply3(this).translate(e,t)}setOrigin1(e){return this.setOrigin(e.x,e.y)}getInverseMatrix(){return new Ei(super.getInverseMatrix().data)}getTransposeMatrix(){let e=super.getTransposeMatrix();return new Ei(e.data)}toMatrix4(){let e=this.data;return new vw([e[0],e[1],0,e[2],e[3],e[4],0,e[5],0,0,1,0,e[6],e[7],0,e[8]])}scaleNum(e){return!e||isNaN(e)?e:e*this.iScale}},Ei.ORIGIN=new Ei,Ei.MIRROR_Y=new Ei([1,0,0,0,-1,0,0,0,1]),Ei.MIRROR_X=new Ei([-1,0,0,0,1,0,0,0,1]),Ei.ROT_90=new Ei([0,1,0,-1,0,0,0,0,1]),Ei.ROT_N90=new Ei([0,-1,0,1,0,0,0,0,1]),Ei),n9=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(n9||{}),a9=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(a9||{}),Vd=class{},p1=class Pd{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return Pd.barycentre(this.p1,this.p2,this.p3)}incentre(){return Pd.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let s=t.x+i.x+r.x,n=t.y+i.y+r.y;return new be(s/3,n/3)}static incentre(t,i,r){let s=i.sub(r).length(),n=t.sub(r).length(),a=t.sub(i).length(),o=s+n+a,l=s*t.x+n*i.x+a*r.x,h=s*t.y+n*i.y+a*r.y;return new be(l/o,h/o)}area(){return Pd.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,s,n,a){return Math.abs(Gi.crossProd2(t,i,r,s,n,a))}scale(t,i){let r=er.translate(-t.x,-t.y).scale(i).translate1(t),s=this.p1.multiply3(r),n=this.p2.multiply3(r),a=this.p3.multiply3(r);return new Pd(s,n,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),s=r.length(),n=be.ORIGIN.pointOnRays2(r,s+t).length()/s;return this.scaleOnIncentre(n)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),s=t.sub(this.p1),n=i.dot(i),a=i.dot(r),o=i.dot(s),l=r.dot(r),h=r.dot(s),c=1/(n*l-a*a),d=(l*o-a*h)*c;if(d<0||d>1)return!1;let f=(n*h-a*o)*c;return f<0||f>1?!1:d+f<=1}};function wg(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var Hn=class Ko{static getMinDistanceWithoutCross(t,i){let r=wg();return Ko.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return bn(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=wg();return Ko.minLine(t,i,r),new ce(r.start,r.end)}static getMinLine(t,i){return Ko.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=wg();if(i instanceof ce)this.point2LineMinLine(r,i,t);else if(i instanceof Ee)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=Ko.intersection(t,i),this.minline)this.minDistance=0;else{let r=wg();Ko.minLine(t,i,r),this.minline=new ce(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=bn(t,i);if(r===0)return;let s=new Array;for(let n=0;n<r;n+=2){let a=new be(te[n],te[n+1]);s.push(a)}return s.length>1?new ce(s[0],s[1]):new ce(s[0],s[0])}static minLine(t,i,r){if(t instanceof ce&&i instanceof ce)return this.minDistanceForLines(t,i,r);if(t instanceof Ee&&i instanceof ce)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof ce&&i instanceof Ee)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof Ee&&i instanceof Ee)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((s,n)=>{n<2?this.point2LineMinLine(r,i,s):this.point2LineMinLine(r,t,s)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let s=Ko.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(s)&&this.point2ArcMinLine(r,t,s),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(Un(t,i.center)||Un(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let s=t.pointOn(r.angleD(t.center)),n=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,s),this.arcShortestLine(t,i,r,n)}static arcInnerLineFootSegment(t,i,r){let s=r.distance1(t.center);if(s!==0){let n=t.rx*(r.y-t.center.y)/s+t.center.y,a=t.rx*(r.x-t.center.x)/s+t.center.x;s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=new be(a,n),i.end=r)}else s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let s=t.center.angleD(i.center),n=i.center.angleD(t.center),a=t.pointOn(s),o=t.pointOn(n),l=i.pointOn(s),h=i.pointOn(n);Un(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,h)),Un(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,h)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let s=i.start().sub(t.center).normalize(),n=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(s.mul(t.rx)),h=t.center.add(n.mul(t.rx)),c=i.center.add(a.mul(i.rx)),d=i.center.add(o.mul(i.rx));Un(t,l)&&Te.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Un(t,h)&&Te.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),h),Un(i,c)&&Te.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),c),Un(i,d)&&Te.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),d)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let s=t.start().distance1(i.svgEnd);s<r.minDistance&&(r.minDistance=s,r.start=t.start(),r.end=i.svgEnd),s=i.start().distance1(t.svgEnd),s<r.minDistance&&(r.minDistance=s,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(Un(i,t)){let s=i.pointOn(t.angleD(i.center)),n=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,s),this.arcShortestLine(i,r,t,n)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(Un(i,r)){let s=r.distance1(i.center);s>i.rx||s>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let s=Ko.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(s)?this.minLineSegment(t,s,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let s=i.distance1(r);s<t.minDistance&&(t.minDistance=s,t.start=i,t.end=r)}static arcShortestLine(t,i,r,s){if(!Un(t,s))return;let n=r.distance1(s);n<i.minDistance&&(i.minDistance=n,i.start=r,i.end=s)}static foot(t,i){if(t.isPoint())return t.start();if(!Te.eq(t.b,0)&&!Te.eq(t.a,0)){let r=t.start(),s=t.direct,n=(i.x-r.x)*s.x+(i.y-r.y)*s.y;return new be(r.x+s.x*n,r.y+s.y*n)}else return Te.eq(t.b,0)&&!Te.eq(t.a,0)?new be(t.start().x,i.y):!Te.eq(t.b,0)&&Te.eq(t.a,0)?new be(i.x,t.start().y):i}};function Un(e,t){if(Te.eq(e.sweepAngle,360))return!0;let i=gt.regularD(t.angleD(e.center));return e.sweepAngle>0?(Te.less(i,e.startAngle)&&(i+=360),Te.greatereq(e.endAngle(),i)):(Te.greater(i,e.startAngle)&&(i-=360),Te.lesseq(e.endAngle(),i))}var o9=[1,10,100,1e3],G3="http://www.w3.org/2000/svg",z3="http://www.w3.org/1999/xlink",H3="http://www.w3.org/XML/1998/namespace",j3="https://easyeda.com/",Pee=(function(){var e={svg:G3,xlink:z3,xml:H3,c:j3};return e[G3]="svg",e[z3]="xlink",e[H3]="xml",e[j3]="c",e})(),Qi=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),Aee=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var s=[16,19,3,7,5,1],n=21;n<52;n++)s.push(n+32,n);return s.push(2,6,8,4,17),s})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Dr=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),Cee=(function(){var e=[],t=[];for(var i in Qi)if(Qi.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(Qi[i])}e.sort(),t.sort();var r={},s,n={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case Qi.TOPLAYER:s={name:Dr[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case Qi.BOTTOMLAYER:s={name:Dr[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case Qi.TOPSILKLAYER:s={name:Dr[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case Qi.BOTTOMSILKLAYER:s={name:Dr[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case Qi.TOPPASTERLAYER:s={name:Dr[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case Qi.BOTTOMPASTERLAYER:s={name:Dr[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case Qi.TOPSOLDERLAYER:s={name:Dr[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case Qi.BOTTOMSOLDERLAYER:s={name:Dr[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case Qi.RATLINES:s={name:Dr[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case Qi.BOARDOUTLINE:s={name:Dr[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case Qi.ALL:s={name:Dr[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case Qi.DOCUMENT:s={name:Dr[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case Qi.TOPASSEMBLY:s={name:Dr[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case Qi.BOTTOMASSEMBLY:s={name:Dr[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case Qi.MECHANICAL:s={name:Dr[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case Qi.MODEL3D:s={name:Dr[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case Qi.LIBBODY:s={name:Dr[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case Qi.PADSURFACE:s={name:Dr[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=Qi.INNER1&&o<=Qi.INNER32?s={name:Dr[o],color:n[o],darkColor:a(n[o]),visible:!1,active:!1,config:!1}:s=null;break}s&&(r[o]=s)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),h=.5,c=Math.min(255,Math.round((l>>16)*h)),d=Math.min(255,Math.round((l>>8&255)*h)),f=Math.min(255,Math.round((l&255)*h)),u=((c<<16)+(d<<8)+f).toString(16);return"#"+("00000"+u).substr(-6).toUpperCase()}return r})(),V3={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},Lee=(function(){var e={};for(let t in V3)e[V3[t]]=t;return e})(),Kg=Math.PI*2,zg=Math.PI/2,Dee=Math.sin(Math.PI/180);function l9(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=o9[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}function xw(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function h9(e,t,i){var r=c(e)&&c(t)&&c(i);if(!r)return console.warn("Bad arguments"),null;var s=t.x-i.x>0?t.x:i.x,n=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,h=e.y;return l<=s+.001&&l>=a-.001&&h<=n+.001&&h>=o-.001;function c(d){return d?(d.x=Number(d.x),d.y=Number(d.y),isNaN(d.x)||isNaN(d.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function c9(e,t,i,r,s,n){var a=(s-i)*(e-i)+(n-r)*(t-r),o=(s-i)*(s-i)+(n-r)*(n-r),l=a/o,h=i+(s-i)*l,c=r+(n-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-s)*(e-s)+(t-n)*(t-n)):Math.sqrt((e-h)*(e-h)+(c-t)*(c-t))}function u9(e,t,i){return h9(e,t,i)?xw((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var Ad=1e-4,te=new Float64Array(100);function bn(e,t){if(e instanceof ce&&t instanceof ce)return Ea(e,t);if(e instanceof Ee&&t instanceof ce)return g1(e,t);if(e instanceof ce&&t instanceof Ee)return g1(t,e);if(e instanceof Ee&&t instanceof Ee)return ww(e,t);if(e instanceof We&&t instanceof We)return Rg(e,t);if(e instanceof We&&t instanceof ce)return Rg(e,new We([t.start(),t.end()]));if(e instanceof ce&&t instanceof We)return Rg(new We([e.start(),e.end()]),t);if(e instanceof We&&t instanceof Ee)return K3(t,e);if(e instanceof Ee&&t instanceof We)return K3(e,t);throw new Error("not supported operation")}function d9(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new ce(new be(i.minX-1,t),new be(i.maxX+1,t));return Ea(r,e)>0?1:0}else return 0}function f9(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new ce(new be(i.minX-1,t),new be(i.maxX+1,t));return Hg(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function Y3(e,t){let i=e.bbox();return i.isContainsY1(t)&&Rg(new We([new be(i.minX-1,t),new be(i.maxX+1,t)]),e)>0?1:0}function q3(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function p9(e,t){let i=t.length(),r=Gi.crossProd3(t.start(),t.end(),e.start())/i,s=Gi.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(s)<1e-8||r*s<0}function Ea(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return te[0]=r.x,te[1]=r.y,2}else return W3(t,e,i);else{if(t.isPoint())return W3(e,t,i);{let r=function(O,b){i.isContains2(O,b)&&(te[m++]=O,te[m++]=b)};if(!p9(e,t))return 0;let s=e.start().x,n=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,h=t.start().y,c=t.end().x,d=t.end().y,f=t.length(),u=Gi.crossProd2(s,n,l,h,c,d)/f,p=Gi.crossProd2(a,o,l,h,c,d)/f;if(u*p>0&&!Te.eq(u,0)&&!Te.eq(p,0))return 0;let g=e.length(),_=Gi.crossProd2(l,h,s,n,a,o)/g,y=Gi.crossProd2(c,d,s,n,a,o)/g;if(_*y>0&&!Te.eq(_,0)&&!Te.eq(y,0))return 0;let m=0;if(Te.eq(u,0)&&Te.eq(p,0)){let O=i.UL(),b=i.UR(),v=i.LL(),E=i.LR();if(Te.eq(i.width(),0))Te.eq(i.height(),0)?(te[m++]=O.x,te[m++]=O.y):(te[m++]=O.x,te[m++]=O.y,te[m++]=v.x,te[m++]=v.y);else if(Te.eq(i.height(),0))te[m++]=O.x,te[m++]=O.y,te[m++]=b.x,te[m++]=b.y;else{let T=p1.area2(O.x,O.y,l,h,c,d),P=p1.area2(b.x,b.y,l,h,c,d);T<P?(te[m++]=O.x,te[m++]=O.y,te[m++]=E.x,te[m++]=E.y):(te[m++]=b.x,te[m++]=b.y,te[m++]=v.x,te[m++]=v.y)}}else if(Te.eq(u,0))r(s,n);else if(Te.eq(p,0))r(a,o);else{let O=Math.abs(u/(u-p));r(s+(a-s)*O,n+(o-n)*O)}return m}}}function W3(e,t,i){let r=t.start(),s=t.end(),n=Gi.crossProd3(e.start(),e.end(),t.start()),a=Gi.crossProd3(e.start(),e.end(),t.end());if(n*a<0){let o=i.center();return te[0]=o.x,te[1]=o.y,2}else if(Math.abs(n)<Math.abs(a)){if(Te.eq(n/e.length(),0))return te[0]=r.x,te[1]=r.y,2}else if(Te.eq(a/e.length(),0))return te[0]=s.x,te[1]=s.y,2;return 0}function Hg(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(Ad);let r=e.center.x,s=e.center.y,n=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,h=t.end().x,c=t.end().y,d=e.center.distance1(t.start()),f=e.center.distance1(t.end()),u=Te.eq(d,n)?0:d>n?1:-1,p=Te.eq(f,n)?0:f>n?1:-1,g=0;if(u===-1&&p===-1)return 0;if(u===0&&p===0)te[g++]=o,te[g++]=l,te[g++]=h,te[g++]=c;else if(u===1&&p===1){let _=Hn.foot(t,e.center),y=_.distance1(e.center);if(Te.greater(y,n))return 0;if(Te.eq(y,n))Te.eq(t.distance2(e.start()),0)?(te[g++]=e.start().x,te[g++]=e.start().y,te[g++]=e.start().x,te[g++]=e.start().y):Te.eq(t.distance2(e.end()),0)?(te[g++]=e.end().x,te[g++]=e.end().y,te[g++]=e.end().x,te[g++]=e.end().y):(te[g++]=_.x,te[g++]=_.y,te[g++]=_.x,te[g++]=_.y);else{g=Ew(r,s,o,l,h,c,g,_);let m=te[g-2],O=te[g-1];g-=2;let b=Gi.distance1(r,s,m,O);if(Te.eq(b,n))te[g++]=m,te[g++]=O,te[g++]=m,te[g++]=O;else if(b<n)g=Yr(a,r,s,o,l,m,O,g),g=Yr(a,r,s,m,O,h,c,g);else return 0}}else if(u===-1||p===-1)g=Yr(a,r,s,o,l,h,c,g);else{let _=Hn.foot(t,e.center),y=_.distance1(e.center);if(Te.eq(y,n)){let m=function(v){return q3(i,v.x,v.y)&&Wi(e,v)},O=e.start(),b=e.end();if(u===0){let v=t.start();if(m(v))return te[g++]=v.x,te[g++]=v.y,te[g++]=v.x,te[g++]=v.y,g;if(m(_))return te[g++]=_.x,te[g++]=_.y,te[g++]=_.x,te[g++]=_.y,g;if(Te.eq(t.distance2(O),0)&&m(O))return te[g++]=O.x,te[g++]=O.y,te[g++]=O.x,te[g++]=O.y,g;if(Te.eq(t.distance2(b),0)&&m(b))return te[g++]=b.x,te[g++]=b.y,te[g++]=b.x,te[g++]=b.y,g;if(d<=n)g=Yr(a,r,s,_.x,_.y,h,c,g),g===2&&(te[g++]=te[0],te[g++]=te[1]);else if(y<n){if(g=Yr(a,r,s,_.x,_.y,h,c,g),g===2&&m(new be(te[0],te[1])))return te[g++]=te[0],te[g++]=te[1],g;g=Yr(a,r,s,_.x,_.y,o,l,0),g===2&&(te[g++]=te[0],te[g++]=te[1])}}else{let v=t.end();if(m(v))return te[g++]=v.x,te[g++]=v.y,te[g++]=v.x,te[g++]=v.y,g;if(m(_))return te[g++]=_.x,te[g++]=_.y,te[g++]=_.x,te[g++]=_.y,g;if(Te.eq(t.distance2(O),0)&&m(O))return te[g++]=O.x,te[g++]=O.y,te[g++]=O.x,te[g++]=O.y,g;if(Te.eq(t.distance2(b),0)&&m(b))return te[g++]=b.x,te[g++]=b.y,te[g++]=b.x,te[g++]=b.y,g;if(f<=n)g=Yr(a,r,s,_.x,_.y,o,l,g),g===2&&(te[g++]=te[0],te[g++]=te[1]);else if(y<n){if(g=Yr(a,r,s,_.x,_.y,o,l,g),g===2&&m(new be(te[0],te[1])))return te[g++]=te[0],te[g++]=te[1],g;g=Yr(a,r,s,_.x,_.y,h,c,0),g===2&&(te[g++]=te[0],te[g++]=te[1])}}}else if(u===0){let m=t.start();te[g++]=m.x,te[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=Yr(a,r,s,_.x,_.y,h,c,g))}else{let m=t.end();te[g++]=m.x,te[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=Yr(a,r,s,_.x,_.y,o,l,g))}}if(g>0){let _=0;for(let y=0;y<g;y+=2){let m=te[y],O=te[y+1];isFinite(m)&&isFinite(O)&&q3(i,m,O)&&Wi(e,new be(m,O))&&(te[_++]=m,te[_++]=O)}return _}else return 0}else return 0}function g9(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,s=e.rx2,n=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,h=e.center.distance2(t.start()),c=e.center.distance2(t.end()),d=Te.eq(h,s)?0:h>s?1:-1,f=Te.eq(c,s)?0:c>s?1:-1,u=0;if(d===-1&&f===-1)return 0;if(d===0&&f===0)te[u++]=n,te[u++]=a,te[u++]=o,te[u++]=l;else if(d===1&&f===1){let p=Hn.foot(t,e.center),g=p.distance2(e.center);if(Te.greater(g,s))return 0;if(Te.eq(g,s)){let _=p.distance2(e.start()),y=p.distance2(e.end());Te.eq(_,0)?(te[u++]=e.start().x,te[u++]=e.start().y):Te.eq(y,0)?(te[u++]=e.end().x,te[u++]=e.end().y):(te[u++]=p.x,te[u++]=p.y)}else{u=Ew(i,r,n,a,o,l,u,p);let _=te[u-2],y=te[u-1],m=Gi.distance2(i,r,_,y);if(u-=2,Te.eq(m,s))te[u++]=_,te[u++]=y;else if(m<s)u=Yr(s,i,r,n,a,_,y,u),u=Yr(s,i,r,_,y,o,l,u);else return 0}}else if(d===-1||f===-1)u=Yr(s,i,r,n,a,o,l,u);else{let p=Hn.foot(t,e.center);d===0?(te[u++]=t.start().x,te[u++]=t.start().y,Te.neq(p.distance2(t.start()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=Yr(s,i,r,p.x,p.y,o,l,u))):(te[u++]=t.end().x,te[u++]=t.end().y,Te.neq(p.distance2(t.end()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=Yr(s,i,r,p.x,p.y,n,a,u)))}if(u>0){let p=0;for(let g=0;g<u;g+=2){let _=te[g],y=te[g+1];isFinite(_)&&isFinite(y)&&(te[p++]=_,te[p++]=y)}return p}else return 0}else return 0}function Yr(e,t,i,r,s,n,a,o){if(s==a){let O=e-(s-i)*(s-i);if(Te.greater(O,0)){let b=Math.sqrt(O),v=t-b,E=t+b,T=Math.min(r,n),P=Math.max(r,n);return v>=T&&v<=P&&(te[o++]=v,te[o++]=s),E>=T&&E<=P&&(te[o++]=E,te[o++]=s),o}}let l=Gi.distance2(r,s,t,i)-e;if(l===0)return te[o++]=r,te[o++]=s,o;let h=Gi.distance2(n,a,t,i)-e;if(h===0)return te[o++]=n,te[o++]=a,o;let c=r,d=s,f=n,u=a,p=NaN,g=NaN,_=Number.POSITIVE_INFINITY,y=0;for(;_!==0;){y++;let O=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(h)),.75),.25);if(p=c+(f-c)*O,g=d+(u-d)*O,c===p&&d===g||f===p&&u===g){Math.abs(l)>Math.abs(h)?(p=f,g=u,_=h):(p=c,g=d,_=l);break}else _=Gi.distance2(p,g,t,i)-e,_<0&&l>h||_>0&&l<h?(f=p,u=g,h=_):(c=p,d=g,l=_)}let m=Math.sqrt(e)-Gi.distance1(p,g,t,i);return(Te.eq(0,_)||Te.eq(0,m))&&(te[o++]=p,te[o++]=g),o}function Ew(e,t,i,r,s,n,a,o){let l=Gi.dotProd2(i,r,s,n,e,t),h=Gi.dotProd2(s,n,i,r,e,t);if(l>=0)return te[a++]=s,te[a++]=n,a;if(h>=0)return te[a++]=i,te[a++]=r,a;if(Gi.crossProd2(i,r,s,n,e,t)==0)return te[a++]=e,te[a++]=t,a;{let c=NaN,d=NaN,f=i,u=r,p=s,g=n,_=Gi.distance2(i,r,e,t),y=Gi.distance2(s,n,e,t),m=Number.POSITIVE_INFINITY,O=0;for(;m>0&&(O++,c=f+(p-f)*.5,d=u+(g-u)*.5,!(_==y||f==c&&u==d||p==c&&g==d));){m=Gi.distance2(c,d,e,t);let b=Gi.dotProd2(f,u,c,d,e,t);if(b==0)break;b<0?(p=c,g=d,y=m):(f=c,u=d,_=m)}return Gi.distance2(c,d,e,t)<Gi.distance2(o.x,o.y,e,t)?(te[a++]=c,te[a++]=d):(te[a++]=o.x,te[a++]=o.y),a}}function g1(e,t){if(e.rx===e.ry)return Hg(e,t);throw new Error("not supported")}function _9(e,t){if(e.rx===e.ry)return g9(e,t);throw new Error("not supported")}function ww(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return O9(e,t);throw new Error("not supported operation")}return 0}function O9(e,t){let i=e.center.x,r=e.center.y,s=t.center.x,n=t.center.y,a=e.rx,o=t.rx,l=e.rx2,h=t.rx2,c=e.center.distance1(t.center),d=Math.abs(a-o),f=a+o;if(Te.greater(c,f)||Te.less(c,d))return 0;if(Te.eq(d+c,0)){let u=0,p;return Wi(e,t.start())&&(te[u]=t.start().x,te[u+1]=t.start().y,u+=2,p=t.start()),Wi(e,t.end())&&(te[u]=t.end().x,te[u+1]=t.end().y,u+=2,p=t.end()),u===0?(Wi(t,e.start())&&(te[u]=e.start().x,te[u+1]=e.start().y,u+=2),Wi(t,e.end())&&(te[u]=e.end().x,te[u+1]=e.end().y,u+=2)):u===2&&(!p.equals1(e.start())&&Wi(t,e.start())&&(te[u]=e.start().x,te[u+1]=e.start().y,u+=2),!p.equals1(e.end())&&Wi(t,e.end())&&(te[u]=e.end().x,te[u+1]=e.end().y,u+=2)),u}else if(Te.eq(c,f)){if(X3(e,t))return 4;let u=new ce(e.center,t.center),p=Hg(t,u);return p=J3(e,p),p!==0?p:(p=Hg(e,u),J3(t,p))}else if(Te.eq(c,d)){if(X3(e,t))return 4;if(a>o){let u=(a-o)/a;return te[0]=i+(s-i)/u,te[1]=r+(n-r)/u,Z3(e,t,2)}else{let u=(o-a)/o;return te[0]=s+(i-s)/u,te[1]=n+(r-n)/u,Z3(e,t,2)}}else{let u=(e.center.distance2(t.center)-h+l)/(c*2)/c,p=(s-i)*u+i,g=(n-r)*u+r,_=s-i,y=n-r,m=Math.max(a,o),O,b,v,E;if(Math.abs(_)<Math.abs(y)){let C=_/-y,M=g-C*p;O=p-m,b=C*O+M,v=p+m,E=C*v+M}else{let C=y/-_,M=p-C*g;b=g-m,O=C*b+M,E=g+m,v=C*E+M}let T=Yr(l,i,r,O,b,p,g,0);if(T=Yr(l,i,r,p,g,v,E,T),T!==4)throw new Error("cnt !== 4");let P=new be(te[0],te[1]),A=new be(te[2],te[3]);if(Wi(e,P)&&Wi(t,P))return Wi(e,A)&&Wi(t,A)?4:Jo(e.start(),t,A,P)?(te[2]=e.start().x,te[3]=e.start().y,4):Jo(e.end(),t,A,P)?(te[2]=e.end().x,te[3]=e.end().y,4):Jo(t.start(),e,A,P)?(te[2]=t.start().x,te[3]=t.start().y,4):Jo(t.end(),e,A,P)?(te[2]=t.end().x,te[3]=t.end().y,4):2;if(Wi(e,A)&&Wi(t,A))return Jo(e.start(),t,P,A)?(te[0]=e.start().x,te[1]=e.start().y,4):Jo(e.end(),t,P,A)?(te[0]=e.end().x,te[1]=e.end().y,4):Jo(t.start(),e,P,A)?(te[0]=t.start().x,te[1]=t.start().y,4):Jo(t.end(),e,P,A)?(te[0]=t.end().x,te[1]=t.end().y,4):(te[0]=te[2],te[1]=te[3],2);{let C=function(F,j){if(Te.eq(F.distance1(j.center),j.rx)&&Wi(j,F)){if(F.distance2(P)<F.distance2(A)){if(M)return;M=!0}else{if(H)return;H=!0}te[k++]=F.x,te[k++]=F.y}},M=!1,H=!1,k=0;return C(e.start(),t),C(e.end(),t),C(t.start(),e),C(t.end(),e),k}}}function Jo(e,t,i,r){return Te.eq(e.distance1(t.center),t.rx)&&Wi(t,e)&&e.distance2(i)<e.distance2(r)}function X3(e,t){return Te.eq(t.start().distance1(e.center),e.rx)&&Wi(e,t.start())?(te[0]=t.start().x,te[1]=t.start().y,te[2]=t.start().x,te[3]=t.start().y,!0):Te.eq(t.end().distance1(e.center),e.rx)&&Wi(e,t.end())?(te[0]=t.end().x,te[1]=t.end().y,te[2]=t.end().x,te[3]=t.end().y,!0):Te.eq(e.start().distance1(t.center),t.rx)&&Wi(t,e.start())?(te[0]=e.start().x,te[1]=e.start().y,te[2]=e.start().x,te[3]=e.start().y,!0):Te.eq(e.end().distance1(t.center),t.rx)&&Wi(t,e.end())?(te[0]=e.end().x,te[1]=e.end().y,te[2]=e.end().x,te[3]=e.end().y,!0):!1}function J3(e,t){if(t===0)return 0;let i=te[0],r=te[1];return Wi(e,new be(i,r))?(te[0]=i,te[1]=r,te[2]=i,te[3]=r,4):0}function Z3(e,t,i){if(i===0)return 0;let r=te[0],s=te[1],n=new be(r,s);return Wi(e,n)&&Wi(t,n)?(te[0]=r,te[1]=s,te[2]=r,te[3]=s,4):0}function pc(e,t){return Math.abs(e-t)<=1e-6}function Wi(e,t){let i=e.bbox();if(t.x-i.minX>-Ad&&t.x-i.maxX<Ad&&t.y-i.minY>-Ad&&t.y-i.maxY<Ad){let r=gt.regularD(t.angleD(e.center));return pc(r,e.startAngle)||pc(r,e.startAngle+360)||pc(r,e.startAngle-360)||pc(r,e.endAngle())||pc(r,e.endAngle()+360)||pc(r,e.endAngle()-360)?!0:e.sweepAngle>0?(Te.less(r,e.startAngle)&&(r+=360),Te.greatereq(e.endAngle(),r)):(Te.greater(r,e.startAngle)&&(r-=360),Te.lesseq(e.endAngle(),r))}else return!1}function m9(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,s=t[1].x-t[0].x,n=t[1].y-t[0].y;if(i===0&&s!==0||i!==0&&s===0)return!1;if(i===0&&s===0)return!0;let a=r/i,o=n/s;return xw(a,o,Math.sin(Math.PI/180))}function b9(e,t,i){var r,s=+t.x,n=+t.y,a=+i.x,o=+i.y,l=+e.x,h=+e.y,c=a-s,d=o-n,f=l-s,u=h-n,p,g,_,y,m,O;return c===0&&d===0?{d:Math.sqrt(f*f+u*u),point:new be(s,n)}:(r=(f*c+u*d)/(c*c+d*d),r<0?{d:Math.sqrt(f*f+u*u),point:new be(s,n)}:r>1?(p=l-a,g=h-o,{d:Math.sqrt(p*p+g*g),point:new be(a,o)}):(m=s+r*c,O=n+r*d,_=l-m,y=h-O,{d:Math.sqrt(_*_+y*y),point:new be(m,O)}))}function zn(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,s)=>{let n=t[s],a=!1;return r&&n&&typeof r=="object"&&typeof n=="object"?typeof r[i]=="function"&&v9(r,n)?a=!r[i].call(r,n):a=!(r===n||r.toString()===n.toString()):typeof r=="number"&&typeof n=="number"?a=!(y9(r,n)||Number.isNaN(r)&&Number.isNaN(n)):a=r!==n,a})}function y9(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function v9(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var wt=new Float64Array(100);function Rg(e,t){if(e.bbox().extendOfSize(Te.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=Ea(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a(te[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(Te.eq(wt[L],wt[R])&&Te.eq(wt[L+1],wt[R+1])){wt[R]=(wt[L]+wt[R])/2,wt[R+1]=(wt[L+1]+wt[R+1])/2;for(let x=s-3;x>=L;x--)wt[x]=wt[x+2];s-=2;break}if(s>r){s=0;let L=t.start(),R=new Float64Array(8);e.getPercent(L)!==null&&(R[s++]=L.x,R[s++]=L.y);let x=t.end();e.getPercent(x)!==null&&(R[s++]=x.x,R[s++]=x.y);let I=e.start();t.getPercent(I)!==null&&(R[s++]=I.x,R[s++]=I.y);let S=e.end();return t.getPercent(S)!==null&&(R[s++]=S.x,R[s++]=S.y),te.set(R),s}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=Ea(new ce(c[0],c[1]),new ce(d[0],d[1]));for(let R=0;R<L;R++)wt[s++]=te[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),Te.eq(m,O)){if(h.controls.length===2){let L=Ea(new ce(l.start(),l.end()),new ce(h.start(),h.end()));for(let R=0;R<L;R++)wt[s++]=te[R];if(L!==0)continue}l=new We([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(Te.less(L,m))v=v|1;else if(Te.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(Te.less(R,E))v=v|1;else if(Te.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=Te.eps&&(n=Te.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new ce(new be(0,m),new be(1,m)),F=new ce(new be(0,O),new be(1,O));for(let L=0;L<b.length-1;L++){let R=new be(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new be(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new ce(R,S),k),o(new ce(R,S),F)):o(new ce(R,S),k):x===2?D===1?(o(new ce(R,S),k),o(new ce(R,S),F)):o(new ce(R,S),F):D===1?o(new ce(R,S),k):o(new ce(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(Te.eq(j.minX,j.maxX)&&Te.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(Te.less(R,E))v=v|1;else if(Te.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new be((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(wt[s++]=L.x,wt[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)te[a]=wt[a];return s}function x9(e,t){if(e.bbox().extendOfSize(Te.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=Ea(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a(te[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(Te.eq(wt[L],wt[R])&&Te.eq(wt[L+1],wt[R+1])){wt[R]=(wt[L]+wt[R])/2,wt[R+1]=(wt[L+1]+wt[R+1])/2;for(let x=s-3;x>=L;x--)wt[x]=wt[x+2];s-=2;break}if(s>r){s=0;let L=new Float64Array(8),R=t.end(),x=0;e.getPercent(R)!==null&&(L[s++]=R.x,L[s++]=R.y,x=2);let I=e.end();return t.getPercent(I)!==null&&(L[s++]=I.x,L[s++]=I.y,x=x===0?1:3),te.set(L),{havOverlap:x,cnt:s}}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=Ea(new ce(c[0],c[1]),new ce(d[0],d[1]));for(let R=0;R<L;R++)wt[s++]=te[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),Te.eq(m,O)){if(h.controls.length===2){let L=Ea(new ce(l.start(),l.end()),new ce(h.start(),h.end()));for(let R=0;R<L;R++)wt[s++]=te[R];if(L!==0)continue}l=new We([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(Te.less(L,m))v=v|1;else if(Te.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(Te.less(R,E))v=v|1;else if(Te.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=Te.eps&&(n=Te.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new ce(new be(0,m),new be(1,m)),F=new ce(new be(0,O),new be(1,O));for(let L=0;L<b.length-1;L++){let R=new be(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new be(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new ce(R,S),k),o(new ce(R,S),F)):o(new ce(R,S),k):x===2?D===1?(o(new ce(R,S),k),o(new ce(R,S),F)):o(new ce(R,S),F):D===1?o(new ce(R,S),k):o(new ce(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(Te.eq(j.minX,j.maxX)&&Te.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(Te.less(R,E))v=v|1;else if(Te.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new be((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(wt[s++]=L.x,wt[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)te[a]=wt[a];return{cnt:s}}var E9=class{constructor(e=Te.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},wd=new E9;function K3(e,t){if(e.bbox().extendOfSize(Te.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,s=0;for(;i.length!==0;){if(s>r){let a=function(){for(let h=0;h<s;h+=2)for(let c=h+2;c<s;c+=2)if(!(wd.eq(wt[h],wt[c])&&wd.eq(wt[h+1],wt[c+1]))){l(wt[c],wt[c+1],o);break}function l(h,c,d){let f=!1;for(let u=0;u<d.length;u+=2)if(wd.eq(h,d[u])&&wd.eq(c,d[u+1])){f=!0;break}f||d.push(h,c)}},o=[wt[0],wt[1]];if(a(),o.length>=100&&(wd.setEps(.001),o=[wt[0],wt[1]],a(),o.length>=100))throw new Error("clearSamePoint()");s=o.length,o.forEach((l,h)=>wt[h]=l)}let n=i.pop();if(n[0]instanceof Ee){let a=function(F){A=Math.min(A,F),C=Math.max(C,F)},o=function(F,j){let L=Ea(F,j);if(L===0)throw new Error("cnt === 0");for(let R=0;R<L;R+=2)a(te[R])},[l,h]=n,c=h.controls;if(c.length===2){let F=g1(l,new ce(c[0],c[1]));for(let j=0;j<F;j++)wt[s++]=te[j];continue}let d=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,u,p,g,_,y;if(Math.abs(l.sweepAngle)>359){let F=l.rx;u=l.center.add1(F,0),p=l.center.add1(-F,0),d=-F,f=F,g=0,_=1,y=-l.center.y}else{u=l.start(),p=l.end(),g=p.y-u.y,_=u.x-p.x,y=-g*u.x-_*u.y;let F=Math.sqrt(1/(g**2+_**2));g*=F,_*=F,y*=F;let j=g*l.center.x+_*l.center.y+y;l.isCCW?(f=l.rx+j,d=0):(d=j-l.rx,f=0)}let m=c.map(F=>g*F.x+_*F.y+y),O=0;for(let F of m){if(Te.less(F,d))O=O|1;else if(Te.greater(F,f))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let b=0,v=0,E=p.x-u.x,T=p.y-u.y,P=Math.sqrt(1/(E**2+T**2));if(E*=P,T*=P,Math.abs(l.sweepAngle)<=180)b=0,v=(p.x-u.x)*E+(p.y-u.y)*T;else throw new Error("not support");O=0;for(let F of c){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(Te.less(j,b))O=O|1;else if(Te.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let A=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;d-=Te.eps,f+=Te.eps,m.forEach((F,j)=>{F>=d&&F<=f&&a(j/(m.length-1))});let M=new ce(new be(0,d),new be(1,d)),H=new ce(new be(0,f),new be(1,f));for(let F=0;F<m.length-1;F++){let j=new be(F/(m.length-1),m[F]),L=j.y<d?1:j.y>f?2:3;for(let R=0;R<m.length;R++){let x=new be(R/(m.length-1),m[R]),I=x.y<d?1:x.y>f?2:3;L!==I&&(L===1?I===2?(o(new ce(j,x),M),o(new ce(j,x),H)):o(new ce(j,x),M):L===2?I===1?(o(new ce(j,x),M),o(new ce(j,x),H)):o(new ce(j,x),H):I===1?o(new ce(j,x),M):o(new ce(j,x),H))}}A!==0&&(h=h.clip(A)[1]),C!==1&&(h=h.clip((C-A)/(1-A))[0]);let k=h.bbox();if(Te.eq(k.minX,k.maxX)&&Te.eq(k.minY,k.maxY)){O=0;for(let F of h.controls){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(Te.less(j,b))O=O|1;else if(Te.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}O===3&&(wt[s++]=(k.minX+k.maxX)/2,wt[s++]=(k.minY+k.maxY)/2);continue}C-A>.8?h.clip(.5).forEach(F=>i.push([F,l])):i.push([h,l])}else{let[a,o]=n;i.push([Ee.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([Ee.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let n=0;n<s;n++)te[n]=wt[n];return s}var w9=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let n=0;n<i-1;n++){let a=e[n],o=e[n+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],s=e[i-1];return t+=(r.x+s.x)*(r.y-s.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function T9(e){let t=e.primitives,i=t[0],r=i instanceof Ee?i.sweepAngle%360:null;if(t.length===1&&i instanceof Ee&&(Te.eq(r,0)||Te.eq(Math.abs(r),360)))return!!i.isCCW;let s=new Array;return e.points(.1,n=>{s.push(n)}),w9.getSweep(s)}var S9=class{static zoomCorner(e,t){let i=new Array,r=new Array,s=new Array;return this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?At.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,s=new Array;return T9(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?At.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(At.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let s=e.primitives;for(let n of s){let a=this.panDistance(n,r);a!==void 0&&(t.push(a),i.push(n))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],h=a==i-1?e[0]:e[a+1];if(!(l instanceof Ee&&h instanceof Ee)&&!this.isCW(l.end(),h.start(),o.end())){if(bn(l,h)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let s=this.start4Index(t,r),n=this.start4Index(e,r);t.length=0,e.length=0,s.forEach(a=>{t.push(a)}),n.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],s=e[0],n=t[i-1];if(!(r instanceof Ee&&s instanceof Ee)&&!this.isCW(r.end(),s.start(),n.end())){let a=bn(r,s);for(let o=0;o<a;o+=2){let l=new be(te[o],te[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(s,l,s.end())}}}}static getResult(e,t,i,r){let s=e.length;for(let n=0;n<s;n++){let a=t[n],o=n===s-1?t[0]:t[n+1],l=n==s-1?0:n+1,h=l==s-1?t[0]:t[l+1],c=e[n],d=n==s-1?e[0]:e[n+1],f=l==s-1?e[0]:e[l+1];if(!(c instanceof Ee&&d instanceof Ee)&&!this.isCW(c.end(),d.start(),a.end())){let p=this.add(e,i,n,c,d,0);p=this.update(e,i,n,d,p);let g=this.generateArc(o,h,d,f,r);if(p=this.add(e,i,n,c,g,p),p=this.update(e,i,n,g,p),p>0)continue}i.push(c);let u=this.generateArc(a,o,c,d,r);u!==void 0&&i.push(u)}}static generateArc(e,t,i,r,s){if(s>0){let n=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(n.equals(a)){let h=o.angleD(n),c=l.angleD(n);return Ee.build2(n,h,c,s,s,0)}else{let h=o.angleD(n),c=l.angleD(n),d=o.angleD(a),f=l.angleD(a),u=Ee.build2(n,h,c,s,s,0),p=Ee.build2(a,d,f,s,s,0);return u.pointOn(u.endAngle()).equals1(l)?u:p.pointOn(p.endAngle()).equals1(l)?p:u}}}static updateNews(e,t,i,r){let s=e.length,n=t==s-1?0:t+1;e[n]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,s,n){if(n>0)return n;if(r!=null&&s!=null){let a=bn(r,s);for(let o=0;o<a;o+=2){let l=new be(te[o],te[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,s,l);break}return a}else return 0}static update(e,t,i,r,s){if(s>0)return s;let n=t.length;if(n>0&&r!=null){let a=t[n-1],o=bn(a,r);for(let l=0;l<o;l+=2){let h=new be(te[l],te[l+1]);t[n-1]=this.generatePrimitive(a,a.start(),h),this.updateNews(e,i,r,h)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof ce)return new ce(t,i);if(e instanceof Ee){let r=e,s=t.angleD(r.center),n=i.angleD(r.center);return Ee.build2(r.center,s,n,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let s=t;s<i;s++)r.push(e[s]);for(let s=0;s<t;s++)r.push(e[s]);return r}static isCW(e,t,i){let r=new ce(i,e),s=new ce(i,t),n=r.end().x-r.start().x,a=r.end().y-r.start().y,o=s.end().x-s.start().x,l=s.end().y-s.start().y;return!(n*l-a*o>0)}static panDistance(e,t){if(e instanceof ce){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof Ee){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||Te.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},ht=.001,os=ht**2;function Qe(e,t){return e.distance2(t)<os}function wa(e,t){return Math.abs(e-t)<=1e-4}function I9(e,t){if(e instanceof ce)return new ce(e.start(),t);if(e instanceof Ee){let i=t.angleD(e.center);return wa(gt.regularD(e.startAngle),gt.regularD(i))?Ee.build3(e.center,e.startAngle,0,e.rx,e.ry):Ee.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof We)return e.clip(e.getPercent(t,ht))[0];throw new Error("not supported operation")}}function jn(e,t=gt.toRadians(e.startAngle)){return e.isCCW?t+=zg:t-=zg,new be(Math.cos(t),Math.sin(t))}function Fd(e,t=0){let i=e.controls;if(t===0){let r=i[0],s=i.slice(1).find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return s.sub(r)}else if(t===1){let r=i[i.length-1],s=i.slice(0,-1).reverse().find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(s)}if(i.length===3){let[r,s,n]=i;return s.sub(r).mul(2*(1-t)).add(n.sub(s).mul(2*t)).normalize()}else{let[r,s,n,a]=i;return s.sub(r).mul(3*(1-t)**2).add(n.sub(s).mul(6*(1-t)*t)).add(a.sub(n).mul(3*t**2)).normalize()}}function Sc(e,t,i){let r=e.slice(1).findIndex(n=>!(n.x===t.x&&n.y===t.y)),s=e[r+1];if(i&&(i.getPercent(s,ht)!==null||new ce(i.start(),i.end()).distance(s)<=ht)&&(s=e[r+2]),!s)throw Error("getSecondPoint(controls: readonly Vector2[])");return s}function lt(e,t){if(e instanceof ce)return e.end().sub(e.start()).normalize();if(e instanceof Ee)return(t?jn(e,t.angle(e.center)):jn(e)).normalize();if(e instanceof We)if(e.controls.length===2){let[i,r]=e.controls;if(Qe(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?Fd(e,e.getPercent(t,ht)):Fd(e)).normalize();else throw new Error("not support")}function P9(e,t,i){let r=[],s=t**2-4*e*i;if(s>=0){let n=-t/(2*e),a=Math.sqrt(s)/(2*e),o=n+a;if(r.push(o),s>0){let l=n-a;r.push(l)}}return r}function A9(e,t,i,r,s=0,n=1){let a=[],o=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,l=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,h,c;if(o*l<0)for(;Math.abs(s-n)>ht;)if(h=(s+n)/2,c=e*Math.pow(h,3)+t*Math.pow(h,2)+i*h+r,Math.abs(c)<ht){a.push(h);break}else o*c<0?n=h:l*c<0&&(s=h);else o*l===0&&(o===0&&a.push(s),l===0&&a.push(n));return a}function Zm(e,t,i){if(e instanceof ce||t.distance2(i)<=os)return new ce(t,i);if(e instanceof Ee)return Ee.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof We){let r=e.getPercent(t,ht),s=e.getPercent(i,ht);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function _1(e){return Te.greater(e,0)&&Te.less(e,1)}function jg(e,t,i,r){let s=e[r]-2*t[r]+i[r],n=t[r]-e[r];if(s===0)return[];let a=-n/s,o=[];return _1(a)&&o.push(a),o}function Vg(e,t,i,r,s){let n,a,o=-e[s]+3*t[s]-3*i[s]+r[s],l=2*(e[s]-2*t[s]+i[s]),h=t[s]-e[s],c=l**2-4*o*h;if(Te.lesseq(c,0))n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else{let f=Math.sqrt(c);n=(-l-f)/(2*o),a=(-l+f)/(2*o);let u=o*2;if(Te.lesseq(n,1)&&Te.greatereq(n,0)){let p=Number.NEGATIVE_INFINITY;for(;Te.neq(n,p);){p=n;let g=u*n+l;n=-(o*n**2+l*n+h-g*n)/g}}if(Te.lesseq(a,1)&&Te.greatereq(a,0)){let p=Number.NEGATIVE_INFINITY;for(;Te.neq(a,p);){p=a;let g=u*a+l;a=-(o*a**2+l*a+h-g*a)/g}}}let d=[];return _1(a)&&d.push(a),_1(n)&&d.push(n),d}function Tw(e,t){if(e.controls.length===2){let[o,l]=e.controls;Qe(o,l)||t.push(new ce(o,l));return}let i,r;if(e.controls.length===3){let[o,l,h]=e.controls;i=jg(o,l,h,"x"),r=jg(o,l,h,"y")}else{let[o,l,h,c]=e.controls;i=Vg(o,l,h,c,"x"),r=Vg(o,l,h,c,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let s=i.pop()||1,n=r.pop()||1,a=0;for(;s!==1||n!==1;)if(Te.eq(s,n))s=i.pop()||1,n=r.pop()||1;else if(s<n){let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=i.pop()||1}else{let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=r.pop()||1}t.push(e)}var C9=1e-5,C1=1,We=class ms extends Vd{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new ce(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return Ic(t,(r,s)=>(i.push(s),!0)),new ms(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let s=1;s<i.length;s++){let n=i[s-1],a=i[s],o=(a.x-n.x)*t,l=(a.y-n.y)*t;r[s-1]=n.add1(o,l)}return ms.pointOn(t,r)}}clip1(t,i,r,s){if(r.push(i[0]),s.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let n=i[0],a=i[1],o=(a.x-n.x)*t,l=(a.y-n.y)*t,h=n.add1(o,l);r.push(h),s.push(h)}else{let n=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],h=(l.x-o.x)*t,c=(l.y-o.y)*t;n[a-1]=o.add1(h,c)}this.clip1(t,n,r,s)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new ms(i),new ms(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=Te.eps){let r=this.controls.map(n=>n.y-t.y),s=0;for(let n of r){if(this.less(n,0,i))s=s|1;else if(this.greater(n,0,i))s=s|2;else{s=3;break}if(s===3)break}if(s!==3)return!1;s=0;for(let n of this.controls){let a=n.x-t.x;if(this.less(a,0,i))s=s|1;else if(this.greater(a,0,i))s=s|2;else{s=3;break}if(s===3)break}return s===3}getPercent(t,i=Te.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,s=[[this,0,1]];for(;s.length!==0;){let n=function(_){c=Math.min(c,_),d=Math.max(d,_)},a=function(_,y){let m=Ea(_,y);if(m===0)throw new Error("cnt === 0");for(let O=0;O<m;O+=2)n(te[O])},[o,l,h]=s.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return h;let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,f=o.controls.map(_=>_.y-t.y);r=f.reduce((_,y)=>{let m=Math.abs(y);return m<_?m:_},r),r/=2,r<=i&&(r=i),f.forEach((_,y)=>{this.eq(_,0,i)&&n(y/(f.length-1))});let u=new ce(new be(0,-r),new be(1,-r)),p=new ce(new be(0,r),new be(1,r));for(let _=0;_<f.length-1;_++){let y=new be(_/(f.length-1),f[_]),m=this.less(y.y,0,i)?1:this.greater(y.y,0,i)?2:3;for(let O=0;O<f.length;O++){let b=new be(O/(f.length-1),f[O]),v=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;m!==v&&(m===1?v===2?(a(new ce(y,b),u),a(new ce(y,b),p)):a(new ce(y,b),u):m===2?v===1?(a(new ce(y,b),u),a(new ce(y,b),p)):a(new ce(y,b),p):v===1?a(new ce(y,b),u):a(new ce(y,b),p))}}if(!isFinite(c)){if(Math.max(...f.map(_=>Math.abs(_)))<i*4)return(l+h)/2;continue}if(c!==0&&(o=o.clip(c)[1],l=(h-l)*c+l),d!==1){let _=(d-c)/(1-c);o=o.clip(_)[0],h=(h-l)*_+l}if(!o.isInRange(t,i))continue;let g=o.controls.reduce((_,y)=>_.ext2(y),new Fs).build1();if(this.eq(g.minX,g.maxX,i)&&this.eq(g.minY,g.maxY,i))return(l+h)/2;if(d-c>.8){let[_,y]=o.clip(.5);_.isInRange(t,i)?(s.push([_,l,(l+h)/2]),y.isInRange(t,i)&&s.push([y,(l+h)/2,h])):s.push([y,(l+h)/2,h])}else s.push([o,l,h])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new Fs().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new Fs().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let s=this.controls[r];i[r]=s.multiply3(t)}return new ms(i)}stroke(t,i,r,s=C1){let n=S9.zoomLines(At.build4(this.points(s)),t);return r===0?n:n.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let n=r.pop(),a=new ce(n.start(),n.end());if(s(n.controls,a)<=t)i(n.end());else{let[o,l]=n.clip(.5);r.push(l,o)}}function s(n,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let h=l.y-o.y,c=o.x-l.x,d=-h*o.x-c*o.y,f=Math.sqrt(1/(h**2+c**2));h*=f,c*=f,d*=f;let u=n.map(p=>Math.abs(h*p.x+c*p.y+d));return Math.max(...u)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,s=this.controls[0],n=.5;for(;n>C9&&!(s.distance2(ms.pointOn(n,this.controls))<=r);n*=.5);let a=Math.ceil(1/n);n=1/a,i(s);let o=0;for(let l=1;l<a;l++)o+=n,i(ms.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,s,n]=this.controls,a=-3*i.x+9*r.x-9*s.x+3*n.x,o=6*i.x-12*r.x+6*s.x,l=-3*i.x+3*r.x,h=[];if(Number.isFinite(t)){let c=-3*i.y+9*r.y-9*s.y+3*n.y,d=6*i.y-12*r.y+6*s.y,f=-3*i.y+3*r.y,u=c-a*t,p=d-o*t,g=f-l*t,_=-p/(2*u),y=Math.sqrt(p**2-4*u*g)/(2*u),m=_+y;m>=0&&m<=1&&h.push(ms.pointOn(m,this.controls));let O=_-y;O>=0&&O<=1&&h.push(ms.pointOn(O,this.controls))}else{let c=-o/(2*a),d=Math.sqrt(o**2-4*a*l)/(2*a),f=c+d;f>=0&&f<=1&&h.push(ms.pointOn(f,this.controls));let u=c-d;u>=0&&u<=1&&h.push(ms.pointOn(u,this.controls))}return h}buildConverxHull(t=Te.eps){let i=[...this.controls],r=[],s=i[0],n=1;do{let a=i[n%i.length];this.eqPP(s,a,t)||r.push(new ce(s,a)),s=a,n++}while(s!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return At.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),s=r.x-i.x,n=r.y-i.y;if(Math.abs(s)<=Te.eps||Math.abs(n)<=Te.eps)return a(this.controls);{let o=n/s;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,h=i.x-r.x,c=-l*i.x-h*i.y,d=Math.sqrt(1/(l**2+h**2));l*=d,h*=d,c*=d;let f=this.controls.map(g=>l*g.x+h*g.y+c),u=f[0]-2*f[1]+f[2],p=f[1]-f[0]-o/2;if(u!==0){let g=-p/u;if(Te.greater(g,0)&&Te.less(g,1))return[ms.pointOn(g,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,h;if(o.length===3){let[u,p,g]=o;l=jg(u,p,g,"x"),h=jg(u,p,g,"y")}else if(o.length===4){let[u,p,g,_]=o;l=Vg(u,p,g,_,"x"),h=Vg(u,p,g,_,"y")}l.sort((u,p)=>p-u),h.sort((u,p)=>p-u);let c=l.pop()||1,d=h.pop()||1,f=[];for(;c!==1||d!==1;)Te.eq(c,d)?(c=l.pop()||1,d=h.pop()||1):c<d?(f.push(ms.pointOn(c,o)),c=l.pop()||1):(f.push(ms.pointOn(d,o)),d=h.pop()||1);return f}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),s=t.distance2(this.end()),n=Math.max(r,s);return i.forEach(o=>a(t.distance2(o))),n;function a(o){n=Math.max(n,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let s=r.y-i.y,n=i.x-r.x,a=-s*i.x-n*i.y,o=Math.sqrt(1/(s**2+n**2));s*=o,n*=o,a*=o;let l=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY;return this.controls.forEach(c=>{let d=s*c.x+n*c.y+a;d<l&&(l=d),d>h&&(h=d)}),{minDis:l,maxDis:h}}getPercentInLine(t){let i=[],r=[],s=this.controls,n=t.start(),a=t.end(),o=a.y-n.y,l=n.x-a.x,h=-o*n.x-l*n.y,c=Math.sqrt(1/(o**2+l**2));if(o*=c,l*=c,h*=c,o**2+l**2<=0)return i;if(s.length===3){let[d,f,u]=s,p=o*(d.x-2*f.x+u.x)+l*(d.y-2*f.y+u.y),g=2*(o*(f.x-d.x)+l*(f.y-d.y)),_=o*d.x+l*d.y+h;r=P9(p,g,_)}else if(s.length===4){let[d,f,u,p]=s,g=p.sub(u.mul(3)).add(f.mul(3)).sub(d),_=d.sub(f.mul(2)).add(u).mul(3),y=f.sub(d).mul(3),m=d,O=o*g.x+l*g.y,b=o*_.x+l*_.y,v=o*y.x+l*y.y,E=o*m.x+l*m.y+h,T=Math.sqrt(1/(O**2+b**2));O*=T,b*=T,v*=T,E*=T,r=A9(O,b,v,E)}else throw Error("not support getBeizerPointInLine");return r.forEach(d=>{d>=0&&d<=1&&i.push(d)}),i}reverse(){return new ms(this.controls.slice().reverse())}},ql,Sw=(ql=class{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=be.ORIGIN,this.textOffsetCache[1]=new be(0,-.5),this.textOffsetCache[2]=new be(0,-1),this.textOffsetCache[3]=new be(-.5,0),this.textOffsetCache[4]=new be(-.5,-.5),this.textOffsetCache[5]=new be(-.5,-1),this.textOffsetCache[6]=new be(-1,0),this.textOffsetCache[7]=new be(-1,-.5),this.textOffsetCache[8]=new be(-1,-1)}static getCache(){return ql.instance==null&&(ql.instance=new ql),ql.instance}},ql.instance=null,ql),ce=class Wl extends Vd{constructor(t,i){super(),this._a=null,this._b=null,this._c=null,this.__bbox=null,this._hashed=null,this._direct=null,this._start=t,this._end=i}get a(){return this._a===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c===null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(Te.eq(this.distance(t),0)){let i=new Wl(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new Wl(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new We([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=this.length();i=i*t/s,r=-r*t/s;let n=new be(this._start.x+r,this._start.y+i),a=new be(this._end.x+r,this._end.y+i);return new Wl(n,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=Sw.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new ss(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new Wl(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return zn(i,r)||zn(i,r.reverse())}stroke(t,i,r){let s,n,a;this._end.x<this._start.x?(n=this._start.x-this._end.x,a=this._start.y-this._end.y,s=this._end):(n=this._end.x-this._start.x,a=this._end.y-this._start.y,s=this._start);let o=Math.sqrt(n*n+a*a),l=t/2,h,c,d;i===2?(c=-l,d=o+l):(c=0,d=o),i===0||i===2?r===0?h=At.build5([c,-l,c,l,d,l,d,-l]):h=At.build5([c,l,c,-l,d,-l,d,l]):r===0?h=At.build2([Ee.build3(new be(c,0),-90,-180,l,l),Ee.build3(new be(d,0),90,-180,l,l)]):h=At.build2([Ee.build3(new be(c,0),90,180,l,l),Ee.build3(new be(d,0),-90,180,l,l)]);let f=Math.atan2(a,n),u=er.rotate(f).translate1(s);return h.asClose().multiply3(u)}points(t){return[this._start,this._end]}mirrorY(t){return new Wl(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new Wl(this._end,this._start)}inArea(t,i,r){let s=t.x,n=t.y,a=this._start,o=this._end,l=r==1,h=s-a.x,c=n-a.y,d=s-o.x,f=n-o.y,u=o.x-a.x,p=o.y-a.y,g=new be(-p,u).normalize(),_=u+g.x*i/2,y=p+g.y*i/2,m=_*_+y*y,O=h*h+c*c,b=d*d+f*f,v=Math.abs(h*p-c*u)/2,E=Math.sqrt(u*u+p*p)*i/4;if(v<=E&&O<=m&&b<=m){if(l)return!0;{let T=new be(s,n).sub(o).normalize(),P=new be(s,n).sub(a).normalize(),A=new be(g.x,g.y).cross(T),C=new be(g.x,g.y).cross(P);return A>=0&&C<=0}}else if(l){let T=i/2;return O<=T*T?!0:b<=T*T}else return!1}isParallel(t,i=!1){let r=Te.eq(Math.abs(this.direct.cross(t.direct)),0),s=!i||Te.greatereq(this.direct.dot(t.direct),0);return r&&s}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:s,y:n}=this.start(),{x:a,y:o}=this.end();return((i-s)*(o-n)-(r-n)*(a-s))**2/((o-n)**2+(a-s)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function L9(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(n,a,o)=>c9(n.x,n.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let n=1;n<e.length-1;n+=2)r(e[n],e[n-1],e[n+1])>t&&i.push(e[n]),i.push(e[n+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let s=e[e.length-1];return i.push(s),i}var D9=G7(z7()),R9=class{constructor(){this.fac=new Fs,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},N9=new R9,At=class qi{constructor(t,i){this.__bbox=null,this.primitives=t,this.__bbox=i}static calcBBox(t){return N9.calcBBox(t)}static build1(t){let i=[],r=null;return Ug(t,(s,n)=>{let a=n.start();return r!==null&&!a.equals(r)&&i.push(new ce(r,a)),i.push(n),r=n.end(),!0}),i.length===0&&r!=null&&i.push(new ce(r,r)),new qi(i)}static build2(t){return qi.build1(f1(t))}static build3(t){let i=[],r=null;return Ug(t,(s,n)=>(r!==null&&i.push(new ce(r,n)),r=n,!0)),new qi(i)}static build4(t){return this.build3(f1(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new be(t[r],t[r+1]));return this.build4(i)}static build6(t){return qi.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new qi(t)}static build8(t){let i=new be(t[0],t[1]),r,s=[],n,a=(o,l)=>o.length==l&&o.every(h=>typeof h=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?n=t[o]:o-=1,n){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let h=l[0];r=new be(l[1],l[2]),s.push(Ee.build5(i,r,h)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new be(l[0],l[1]),s.push(new ce(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let h=new be(l[0],l[1]),c=new be(l[2],l[3]);r=new be(l[4],l[5]),s.push(new We([i,h,c,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return qi.build2(s)}static buildBBox(t,i=0){return i===1?qi.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):qi.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1){if(t.length===1){let l=new Array;t[0].asClose().points2(r,f=>l.push(f));let h,c=l[0],d=[];for(let f=0;f<l.length-2;f+=2){let u=l[f+1],p=l[f+2],g=u.sub(c).normalize().cross(p.sub(c).normalize());if(Te.neq(g,0)){if(h===!0){if(g<0){d.length=0;break}}else if(h===!1){if(g>0){d.length=0;break}}else h=g>0;d.push(c),d.push(u),d.push(p)}l.push(c),c=p}if(d.length!==0){for(let f=0;f<d.length;f+=3)i(d[f],d[f+1],d[f+2]);return}}let s=[],n=[];t.forEach(l=>{s.length!==0&&n.push(s.length/2),l.asClose().points2(r,h=>s.push(h.x,h.y))});let a=D9.default(s,n),o=[];for(let l=1;l<s.length;l+=2)o.push(new be(s[l-1],s[l]));for(let l=0;l<a.length;l+=3)i(o[a[l]],o[a[l+1]],o[a[l+2]])}lines(t,i){let r=new Array;this.points(t,n=>r.push(n));let s=r[0];for(let n=1;n<r.length;n++){let a=r[n];i(s),i(a),s=a}}triangles(t,i){qi.triangulate([this],(...r)=>{r.forEach(s=>i(s))},t)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof ce)i=new ce(i.start().mirror(),i.end().mirror());else if(i instanceof Ee)i=i.mirror();else if(i instanceof We){let r=i.controls.map(s=>s.mirror());i=new We(r)}else throw new Error("bug");t.push(i)}),new qi(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let s of r.points(t))i.push(s);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let s=i[r];if(s instanceof ce){let n=s.start().round(t),a=s.end().round(t);i[r]=new ce(n,a)}else if(s instanceof We){let n=s.controls.map(a=>a.round(t));i[r]=new We(n)}else if(s instanceof Ee){let n=s.start().round(t),a=s.end().round(t),o=s.sweepAngle;i[r]=Ee.build5(n,a,o)}}return new qi(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,s=[],n=this.closed();if(this.primitives.length<=1)return qi.build2(this.primitives);let a=()=>{if(s.length>2){let l=L9(s,t);for(let h=1;h<l.length;h++)i.push(new ce(l[h-1],l[h]))}else i.push(new ce(s[0],s[1]));s.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let h=this.primitives[l];h instanceof ce?(r?s.push(h.end()):(s.length=0,s.push(h.start(),h.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(h))}let o=new qi(i,this.__bbox);return n&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let s=t[r];if(s instanceof ce){if(s.end().equals1(s.start()))continue;if(i&&(s.end().equals1(i.start())||u9(s.end(),i.start(),i.end())))return!0;i=s}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(s=>{let n=s.start(),a=s.end();if(i+=(n.x+r.x)*(n.y-r.y),s instanceof ce)i+=(a.x+n.x)*(a.y-n.y);else if(s instanceof Ee)i+=(a.x+n.x)*(a.y-n.y),i+=Math.PI*s.rx2*s.sweepAngle/180-be.normal(s.center,s.start(),s.end());else if(s instanceof We){let o=n;s.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals(s))return this;{let n=new Array;return ns.addAll(n,this.primitives),n.push(new ce(s,r)),qi.build2(n)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals1(s))return this;{let n=new Array;return ns.addAll(n,this.primitives),n.push(new ce(s,r)),new qi(n)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof ce)s=new ce(s.end(),s.start());else if(s instanceof Ee)s=s.exchangeSweep();else if(s instanceof We)s=new We(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new qi(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof ce)s=new ce(s.end(),s.start());else if(s instanceof Ee)s=s.exchangeSweep1();else if(s instanceof We)s=new We(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new qi(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof ce)r=r.mirrorY(t);else if(r instanceof Ee)r=r.mirrorY(t);else if(r instanceof We){let s=r.controls.map(n=>n.mirrorY(t));r=new We(s)}else throw new Error("bug");i.push(r)}),new qi(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let s=this.primitives[r].points(t);s.pop(),s.forEach(n=>i(n))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof Ee?n.points1(t):n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Ee?r.points1(t):r.points(t)).forEach(s=>i(s))}points2(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof Ee?n.points2():n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof Ee?r.points2():r.points(t)).forEach(s=>i(s))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return qi.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=qi.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof Ee))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof qi&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let s=t.primitives[r],n=this.primitives[r];if(JSON.stringify(s)!=JSON.stringify(n))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let s=0;for(;s<i.length;){let n=i.slice(s).concat(i.slice(0,s));if(zn(n,r)||zn(n.reverse(),r))return!0;s++}return!1}else return zn(this.primitives,t.primitives)}clone(){return qi.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof qi)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let s=this.end();if(r.equals(s,i))return!1;let n=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(n,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(s.equals(n,i))o=!1,l=!0;else if(s.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=ss.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let s=this.start();if(!s){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let n=this.end();if(s.equals(n,i))return!1;let a=t.start(),o=t.end(),l=!1,h=!1;if(s.equals(a,i))l=!0,h=!1;else if(s.equals(o,i))l=!1,h=!1;else if(n.equals(a,i))l=!1,h=!0;else if(n.equals(o,i))l=!0,h=!0;else return!1;let c=l?t.reverse():t;return h?this.primitives.push(...c.primitives):this.primitives.unshift(...c.primitives),this.__bbox=ss.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),s=t.primitives[0].start(),n=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof ce&&t.primitives[0]instanceof ce&&m9([i,r],[s,n])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new ce(i,n)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,s=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(n(o),n(l),a instanceof Ee){let h=t.angleD(be.ORIGIN);if(a.angleIsInArc(h)){let c=a.pointOn(h).dot(i);n(c)}if(a.angleIsInArc(h+180)){let c=a.pointOn(h-180).dot(i);n(c)}}}),r-s<=0)throw new Error("getMaxBBoxHeightByVec");return r-s;function n(a){a>r&&(r=a),a<s&&(s=a)}}getWindingNum(t){let i=this.end(),r=0,{x:s,y:n}=t;for(let o of this.primitives){if(i.y>n?o.bbox().minY>n:o.bbox().maxY<=n){i=o.end();continue}if(o instanceof Ee&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,h=o.endAngle();if(o.sweepAngle>0){let c=90;for(;c<=h;)c>l&&(a(Ee.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c+=90;l<h&&a(Ee.build3(o.center,l,h-l,o.rx,o.ry))}else{let c=270;for(;c>=h;)c<l&&(a(Ee.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c-=90;l>h&&a(Ee.build3(o.center,l,h-l,o.rx,o.ry))}}else if(o instanceof We){let l=[];Tw(o,l),l.forEach(h=>a(h))}else a(o)}return r;function a(o){let l=o.start(),h=o.end();if(i.y>n!=l.y>n&&(i.x>s?l.x>s?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++:l.x>s&&(i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++)),l.y>n!=h.y>n){if(l.x>s)if(h.x>s)r+=h.y>l.y?1:-1;else if(o instanceof ce)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof Ee){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof We){if(Y3(o,n)===0)throw new Error("no inters");te[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!");else if(h.x>s)if(o instanceof ce)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof Ee){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof We){if(Y3(o,n)===0)throw new Error("no inters");te[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!")}i=h}}},Tg=Math.PI*2,Ree=Math.PI/2,Nee=Math.sin(Math.PI/180),M9=4,Ee=class Oi extends Vd{constructor(t,i,r,s,n){super(),this._rx2=null,this._ry2=null,this._svgEnd=null,this._hashed=null,this.__bbox=null,this.rx=t,this.ry=i,this.center=r,this.startAngle=s,this.sweepAngle=n,this._start=be.ORIGIN,this._end=be.ORIGIN,this._start=this.pointOn(s),this._end=this.pointOn(s+n)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new be(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new be(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,s){let n=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(s)<2e-4;)n*=2,a+=n,s=this.pointOn(a);return s}static build1(t,i,r,s,n,a){Ii.positive(r),Ii.positive(s);let o=t.equals(i);if(o)return new Oi(r,s,t,0,n?360:0);{let l=t.x,h=-t.y,c=i.x,d=-i.y,f=a===0,u=(l-c)/2,p=(h-d)/2,g=Math.cos(0),_=Math.sin(0),y=g*u+_*p,m=-_*u+g*p;r=Math.abs(r),s=Math.abs(s);let O=r*r,b=s*s,v=y*y,E=m*m,T=n===f?-1:1,P=(O*b-O*E-b*v)/(O*E+b*v);P=P<0?0:P;let A=T*Math.sqrt(P),C=A*(r*m/s),M=A*-(s*y/r),H=(l+c)/2,k=(h+d)/2,F=H+(g*C-_*M),j=k+(_*C+g*M),L=(y-C)/r,R=(m-M)/s,x=(-y-C)/r,I=(-m-M)/s,S,D;D=Math.sqrt(L*L+R*R),S=L,T=R<0?-1:1;let N=gt.toDegrees(T*Math.acos(S/D));D=Math.sqrt((L*L+R*R)*(x*x+I*I)),S=L*x+R*I,T=L*I-R*x<0?-1:1;let G=S/D,z;G<-1?z=Math.acos(-1):G>1?z=Math.acos(1):z=Math.acos(G);let Z=gt.toDegrees(T*z);!f&&Z>0?Z-=360:f&&Z<0&&(Z+=360),Ii.normal(N),Ii.normal(Z);let se=u*u/O+p*p/b,he=t.distance1(i)/2;r<he&&s<he&&(r*=Math.sqrt(se),s*=Math.sqrt(se));let pe=o?0:gt.regularD(-N),Se=o?n?360:0:-Z;return new Oi(r,s,new be(F,-j),pe,Se)}}static build2(t,i,r,s,n,a){Ii.positive(s),Ii.positive(n),Ii.normal(i),Ii.normal(r);let o;return i===r?(i=gt.regularD(i),r=gt.regularD(r),o=0):(i=gt.regularD(i),r=gt.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new Oi(s,n,t,gt.regularD(i),o)}static build3(t,i,r,s,n){return Ii.positive(s),Ii.positive(n),Ii.normal(r),new Oi(s,n,t,gt.regularD(i),r)}static build4(t,i,r,s,n,a){let o=t.angleD(r),l=i.angleD(r);return Oi.build2(r,o,l,s,n,a)}static build5(t,i,r){r=gt.toRadians(r);let s=i.sub(t),n=new be(-s.y,s.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=s.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=n.rotate(be.ORIGIN,a),h,c;r>0?(h=1,c=i.add(l.scale(o))):(h=0,c=t.sub(l.scale(o)));let d=gt.toDegrees(t.angle(c)),f=gt.toDegrees(i.angle(c));return Oi.build2(c,d,f,o,o,h)}static buildCircle(t,i,r=0){return Oi.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=gt.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let s=this.rx2,n=this.ry2,a=Math.tan(gt.toRadians(t)),o=a*a,l=Math.sqrt(s*n/(s+n/o)),h=Math.sqrt(s*n/(n+s*o));return t>90&&t<270&&(h=-h),t>180&&t<360&&(l=-l),isNaN(h)&&(h=0),isNaN(l)&&(l=0),this.center.add1(h,l)}}exchangeSweep(){return Oi.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return Oi.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return Oi.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?Oi.build3(this.center.mirrorY(),0,360,this.rx,this.ry):Oi.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=be.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?Oi.build3(this.center.mirror(t),0,360,this.rx,this.ry):Oi.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=p1.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals(er.ROT_90)?r=gt.regularD(this.startAngle+90):t.equals(er.ROT_N90)?r=gt.regularD(this.startAngle-90):r=gt.transformD(this.startAngle,t),Oi.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=gt.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=gt.toRadians(this.sweepAngle)/2,s=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new We([t,t.add(new be(s,0).multiply3(er.rotateD(this.startAngle+90))),i.add(new be(s,0).multiply3(er.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(s=>i.push(s.toBezier())),i;function r(s,n){if(Math.abs(s.sweepAngle)>n){let a=s.sweepAngle/2;r(Oi.build3(s.center,s.startAngle,a,s.rx,s.ry),n),r(Oi.build3(s.center,s.startAngle+a,a,s.rx,s.ry),n)}else t.push(s)}}buildBBox(){let t=Sw.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r-=90}}return new ss(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return Tc.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let s=t/2,n=this.rx+s,a=this.ry+s,o=this.rx-s,l=this.ry-s,h=new er;o<0&&(o=-o,h=h.multiply3(er.MIRROR_Y)),l<0&&(l=-l,h=h.multiply3(er.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),h=h.setOrigin1(this.center);let c,d;switch(r===this.sweep()?(c=Oi.build3(this.center,this.startAngle,this.sweepAngle,n,a),d=Oi.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(c=Oi.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,n,a),d=Oi.build3(this.center,this.startAngle,this.sweepAngle,o,l)),d=d.multiply3(h),i){case 1:{let f=r===1?180:-180,u=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),p=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),g=c.pointOn(c.endAngle()).angleD(u),_=d.pointOn(d.endAngle()).angleD(p);return At.build2([c,Oi.build3(u,g,f,s,s),d,Oi.build3(p,_,f,s,s)])}default:return At.build2([c,d])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/M9),i=this.sweepAngle/t,r=[this._start];for(let s=1;s<t;s++)r.push(this.pointOn(this.startAngle+i*s));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/gt.toDegrees(Math.acos(r))/2)),n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle;for(let l=0;l<=s;l++,o+=a)n[l]=this.pointOn(o);return n}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/gt.toDegrees(Math.acos(r))/2));s=Math.max(s,2);let n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle+a;n[0]=this.start();for(let l=1;l<s;l++,o+=a)n[l]=this.pointOn(o);return n[s]=this.end(),n}panDistance(t){return this.sweepAngle>0?new Oi(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new Oi(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),Oi.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new Oi(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),Oi.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new Oi(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(l9(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=gt.toRadians(this.startAngle),i=gt.toRadians(this.endAngle()),r=this.sweep(),s=this.center,n=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return s.add(new be(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new be(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(i+Tg-t)/2+t;return s.add(new be(Math.cos(a),Math.sin(a)).mul(n))}}else if(i>t){let a=(t+Tg-i)/2+i;return s.add(new be(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new be(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(t-i)/2+i;return s.add(new be(Math.cos(a),Math.sin(a)).mul(n))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=gt.regularD(this.startAngle),r=gt.regularD(this.sweepAngle),s=gt.regularD(t.startAngle),n=gt.regularD(t.sweepAngle);return zn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(zn([r,i],[n,s])||zn([gt.regularD(i+r)],[s]))}equals1(t){let i=gt.regularD(this.startAngle),r=gt.regularD(this.sweepAngle),s=gt.regularD(t.startAngle),n=gt.regularD(t.sweepAngle);return zn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(zn([r,i],[n,s])||zn([gt.regularD(i+r)],[s]))}inArea(t,i){let r=t.x,s=t.y,n=this.center,a=this.rx,o=gt.toRadians(this.startAngle);this.sweep()==0&&(o=gt.toRadians(this.endAngle()));let l=gt.toRadians(this.endAngle());this.sweep()==0&&(l=gt.toRadians(this.startAngle));let h=a-i/2,c=a+i/2;var d=r-n.x,f=s-n.y,u=Math.atan2(f,d);if(u<0&&(u+=Tg),o<=l&&u>=o&&u<=l||o>l&&(u>=o&&u<=Tg||u>=0&&u<=l)||o==l){var p=Math.sqrt(d*d+f*f);return p<=c&&p>=h}else{var p=(c+h)/2,g=new be(n.x+Math.cos(o)*p,n.y+Math.sin(o)*p),_=new be(n.x+Math.cos(l)*p,n.y+Math.sin(l)*p),y=r-g.x,m=s-g.y,O=r-_.x,b=s-_.y;return y*y+m*m<=i*i/4?!0:O*O+b*b<=i*i/4}}isCircle(){return(Te.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return Oi.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}},Iw=new ArrayBuffer(24),Km=new Float64Array(Iw),gc=new Int32Array(Iw),Rr,Mee=(Rr=class{static normal(e,t,i){let r=t.sub(e),s=i.sub(t);return r.cross(s)}constructor(e,t,i){this.x=Ii.normal(e),this.y=Ii.normal(t),this.z=Ii.normal(i),Km[0]=e,Km[1]=t,Km[2]=i,this.hashed=gc[0]^gc[1]^gc[2]^gc[3]^gc[4]^gc[5]}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(e){return e instanceof Rr?e.x===this.x&&e.y===this.y&&e.z===this.z:!1}cross(e){return new Rr(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var e=this.length();return new Rr(this.x/e,this.y/e,this.z/e)}sub(e){return new Rr(this.x-e.x,this.y-e.y,this.z-e.z)}add(e){return new Rr(this.x+e.x,this.y+e.y,this.z+e.z)}scale(e){return new Rr(this.x*e,this.y*e,this.z*e)}neg(){return new Rr(-this.x,-this.y,-this.z)}multiply4(e){var t=this.x*e.data[0]+this.y*e.data[4]+this.z*e.data[8]+e.data[12],i=this.x*e.data[1]+this.y*e.data[5]+this.z*e.data[9]+e.data[13],r=this.x*e.data[2]+this.y*e.data[6]+this.z*e.data[10]+e.data[14],s=this.x*e.data[3]+this.y*e.data[7]+this.z*e.data[11]+e.data[15];return s!=0?new Rr(t/s,i/s,r/s):new Rr(t,i,r)}rotate(e,t){return this.multiply4(vw.rotateAxis(e,t))}toVector2(){return new be(this.x,this.y)}},Rr.ORIGIN=new Rr(0,0,0),Rr.X_UNIT_VECTOR=new Rr(1,0,0),Rr.Y_UNIT_VECTOR=new Rr(0,1,0),Rr.Z_UNIT_VECTOR=new Rr(0,0,1),Rr),zi=class vc{static build(t){return t instanceof At?new vc([new ar([t])]):t instanceof ar?new vc([t]):t}static buildByPolygon(t){return t?new vc([t]):new vc([])}static buildByStroke(t,i,r=1,s){return this.buildByPolygon(ar.buildByStroke(t,i,r,C1,s))}static buildCircle(t,i){return this.buildByPolygon(ar.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(ar.buildRect(t))}static buildBBox(t){return this.buildByPolygon(ar.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new vc(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new Fs).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},_i,zt=(_i=class{static isHexFormate(e){return!e||typeof e!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)}static of1(e){return this.of2(e>>16&255,e>>8&255,e&255)}static of2(e,t,i,r=255){return new _i(e/255,t/255,i/255,r/255)}static of3(e){e.startsWith("#")&&(e=e.substr(1));let t=e.length;if(t==3)return new _i(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15);if(t==6)return new _i(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255);if(t==8)return new _i(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,parseInt(e.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(e){let t=parseInt(e.r*255+"").toString(16),i=parseInt(e.g*255+"").toString(16),r=parseInt(e.b*255+"").toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),("#"+t+i+r).toUpperCase()}static of5(e,t){if(e.startsWith("#")&&(e=e.substr(1)),e.length==3)return new _i(parseInt(e[0],16)/15,parseInt(e[1],16)/15,parseInt(e[2],16)/15,t);if(e.length==6)return new _i(parseInt(e.substr(0,2),16)/255,parseInt(e.substr(2,2),16)/255,parseInt(e.substr(4,2),16)/255,t);throw new Error("invalid color string")}static of6(e,t){return new _i(e.r,e.g,e.b,t)}static of7(e){return e==null?null:_i.of3(e)}constructor(e,t,i,r=1){this.r=Ii.positiveOr0(e),this.g=Ii.positiveOr0(t),this.b=Ii.positiveOr0(i),this.alpha=r}hashCode(){return this.r+this.g+this.b+this.alpha}equals(e,t=!1){let i=this.r===e.r&&this.g===e.g&&this.b===e.b;return t?i:i&&this.alpha===e.alpha}add(e,t,i,r){return new _i(Math.max(0,Math.min(1,this.r+e)),Math.max(0,Math.min(1,this.g+t)),Math.max(0,Math.min(1,this.b+i)),Math.max(0,Math.min(1,this.alpha+r)))}mul(e){return new _i(Math.max(0,Math.min(1,this.r*e)),Math.max(0,Math.min(1,this.g*e)),Math.max(0,Math.min(1,this.b*e)),this.alpha)}mul1(e){return new _i(Math.max(0,this.r*e),Math.max(0,this.g*e),Math.max(0,this.b*e),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)}toString1(){let e=(this.r*255).toString(16),t=(this.g*255).toString(16),i=(this.b*255).toString(16),r=(this.alpha*255).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+e.substr(0,2)+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toRGBA(){let e=this.r*255,t=this.g*255,i=this.b*255;return[e,t,i,this.alpha]}toRGBAString(){let e=this.r*255,t=this.g*255,i=this.b*255;return`rgba(${e},${t},${i},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}},_i.WHITE=new _i(1,1,1,1),_i.BLACK=new _i(0,0,0,1),_i.RED=new _i(1,0,0,1),_i.GREEN=new _i(0,1,0,1),_i.BLUE=new _i(0,0,1,1),_i.Gray=_i.of3("#9966ff"),_i.Silver=_i.of3("#D2D2D2"),_i.Golden=_i.of3("#DCAA14"),_i.Pink=_i.of3("#ffaec9"),_i),$3=!1,Pw=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,s,n){}onIntersect(e,t,i){}onSegment(e,t,i,r,s,n){}onSegment1(e,t,i){if($3){let r=new be(e.getX(i),i),s=new be(t.getX(i),i);this.onSegment(r,e.weight,e,s,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if($3){let r=new be(e.getX(i),i),s=new be(t.getX(i),i);this.onSweep(r,e.weight,e,s,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},Bd=class extends Pw{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},Yd=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let s=this.weights[r],n=e/s|0,a=e%s;a>(s/2|0)?(e=s-a,n++):e=a,this.result[r]=n>0}t=this.decide1(this.result),this.cache[i]=t}return t}},B9=e=>e!==0,k9=new class extends Yd{decide1(e){return e[0]||e[1]}}(2),Ng=new class extends Yd{decide1(e){return e[0]&&!e[1]}}(2),Mg=new class extends Yd{decide1(e){return e[0]&&e[1]}}(2),$m=new class extends Yd{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),F9=(e=>(e[e.UNMARKED=0]="UNMARKED",e[e.INSIDE=1]="INSIDE",e[e.OUTSIDE=2]="OUTSIDE",e[e.INVALID=3]="INVALID",e))(F9||{}),Ac=class xc{constructor(t,i,r,s,n,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,s.y>n.y?this.weight=-r:s.y==n.y?this.weight=0:this.weight=r,this.start=s,this.end=n,this.polyGrp=a,this.polyIndex=o,this._bbox=new Fs().ext1(i.bbox()).ext2(s).ext2(n).build1(),this.inters.push(s),this.inters.push(n);let l=31,h=1;h=l*h+this.polyGrp,h=l*h+this.polyIndex,this._hashcode=h}static rebuild(t,i,r){if(t instanceof ce||i.distance2(r)<1e-6)return new ce(i,r);if(t instanceof Ee){let s=t,n=t.bbox().center().x,a;i.y>r.y?a=n>s.center.x?0:1:a=n>s.center.x?1:0;let o=i.angleD(s.center),l=r.angleD(s.center);return Ee.build2(s.center,o,l,s.rx,s.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new Fs().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(q9(this,t)>0?this._x=te[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=xc.rebuild(this.shape,this.end,this.start),r=new xc(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return ns.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=xc.rebuild(this.shape,this.end,this.start),r=new xc(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return ns.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof xc?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return Tc.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function U9(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minY+i.maxY)/2,n=(r.minY+r.maxY)/2;return s-n}function G9(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minX+i.maxX)/2,n=(r.minX+r.maxX)/2;return s-n}var _c=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=ss.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},Ud=class{constructor(e){this.changed=!1,this.root=new _c,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){ns.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new _c,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new _c(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new _c(e),this.changed=!1}}organize(e){Kl(e,G9,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let s=r+this.capacity2;Kl(e,U9,r,s);for(let n=r;n<s;n+=this.capacity){let a=new _c(e.slice(n,n+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let s=new _c(e.slice(r,r+this.capacity));i.push(s),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let s=r.items();if(s instanceof Array){for(let n of s)if(!e.isSeparated(n.bbox())){let a=n.items();a instanceof Array?i.push(n):t.push(a)}}else e.isSeparated(r.bbox())||t.push(s)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let s of r)this._walker(s,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function Qm(e,t){z9(e.iterator(),t)}function z9(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var Sg=new Error("list is empty"),Ig=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},H9=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},j9=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},Jl=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw Sg;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Sg;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new Ig(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new Ig(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw Sg;return this.first.item}getLast(){if(this.last===null)throw Sg;return this.last.item}insertAfter(e,t){let i=new Ig(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Ig(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new H9(this.first)}listIterator(){return new j9(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function e1(e){throw new Error("")}var Pg=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},V9=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},Y9=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},Yg=class{constructor(){this.innerList=new Jl,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new Pg(e,t),s=this.innerMap[i];if(s===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(s instanceof Pg){if(s.key.equals(e))return this.innerMap[i]=r,this.replace(s,r),s.value;{r.node1=this.innerList.add(r);let n=new Jl;return s.node2=n.add(s),r.node2=n.add(r),this.innerMap[i]=n,null}}if(s instanceof Jl){let n=null;return Qm(s,(a,o)=>o.key.equals(e)?(this.replace(o,r),n=o.value,!1):!0),n===null?(r.node1=this.innerList.add(r),r.node2=s.push(r),null):n}return e1(s)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof Pg)return i.key.equals(e)?i.value:null;if(i instanceof Jl){let r=null;return Qm(i,(s,n)=>n.key.equals(e)?(r=n.value,!1):!0),r}return e1(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof Pg)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof Jl){let r=null;return Qm(i,(s,n)=>n.key.equals(e)?(r=n.value,this.delete(n),!1):!0),r}return e1(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new V9(this.innerList.iterator())}values(){return new Y9(this.innerList.iterator())}entries(){return this.innerList.iterator()}},Pc=class{constructor(){this.innerMap=new Yg}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},Q3=ns.funcCopy(Kl);function q9(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)te[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)te[i++]=e.end.x;else if(e.shape instanceof ce)i=d9(e.shape,t);else if(e.shape instanceof Ee)i=f9(e.shape,t);else throw new Error("not supported operation");return i}var Bg=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let s of this.loader.buildGroup(e,t,i,r))this.sides.push(s),this.event.onOriginSide(s)}buildRTree(){let e=new Ud(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let s of e)s.needCountWeight()&&(t.push(s.start),t.push(s.end));Q3(t,be.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let s of t){let n=s.y;n>r&&(i.push(n),r=n)}return i}splitSides(e,t,i){let r=e.start,s=e.end,n=new be(s.x+(r.x-s.x)*2,s.y+(r.y-s.y)*2);Q3(e.inters,(o,l)=>o.distance2(n)-l.distance2(n),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=Ac.rebuild(e.shape,a,o);l instanceof Ee&&Math.abs(l.sweepAngle)>190&&(l=new ce(a,o));let h=new Ac(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(h),h.updateBbox(),o.equals(s))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,s=null;do{let n=new Array;i=this.splitSides(t,n,i);for(let a of n)r!=null?(r.next=a,a.previous=r):s=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);s!=null&&r!=null&&(s.previous=r,r.next=s)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new Pc;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),s=i.shape instanceof ce;for(let n of e.search(r))if(!t.contains(n)){let a=n.shape instanceof ce;if(!(s&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(n)||i.previous.equals(n)))){let o=bn(i.shape,n.shape);for(let l=0;l<o;l+=2){let h=new be(te[l],te[l+1]);i.inters.push(h),n.inters.push(h),this.event.onIntersect(h,i,n)}}}}}}},W9=class Aw{constructor(t){this.sides=new Pc,this.others=new Pc,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return Ic(this.sides,(i,r)=>(t.push(r.shape),!0)),At.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof Aw?this.id===t.id:!1}},Cw=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new ce(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let s of this.sides)(!this.noWeight0||s.weight!==0)&&(i!=null?(i.next=s,s.previous=i):r=s,i=s,t.push(s));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let s of e.primitives)if(s instanceof ce)this.addSide(s,t);else if(r&&s instanceof Ee&&s.rx===s.ry)this.addArc(s,t);else{let n=null;for(let a of s.points(i))n!=null&&this.addSide(new ce(n,a),t),n=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=gt.regularD(e.startAngle),s=r+i;if(i>0){let n=90;for(;n<=s;)n>r&&(this.addSide(Ee.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n+=90;r<s&&this.addSide(Ee.build3(e.center,r,s-r,e.rx,e.ry),t)}else if(i<0){let n=270;for(;n>=s;)n<r&&(this.addSide(Ee.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n-=90;r>s&&this.addSide(Ee.build3(e.center,r,s-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new ce(this.prevSide.end,i),t),r=new Ac(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new Ac(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},Lw=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&Te.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},qg=new Error,ew=new class extends Yd{decide1(e){return e[0]&&e[1]}}(2),X9=new class extends Pw{onPolylineGroup(e,t){throw qg}onSegment(e,t,i,r,s,n){throw qg}},J9=class{constructor(e,t){this.rtree=e,this.level=t}},Z9=class Dw extends Bg{static isIntersect(t,i,r=Zg.DUMMY){let s=new Dw(r),n=s.createGroup1(t.items),a=s.createGroup2(i.items);return n.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:s.isIntersect(n,a)}constructor(t){super(new Cw(!1),ew.rule,t,X9)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=ew.weight(i);for(let n of t)this.addPolyline(n,r);let s=this.buildRTree();return this.sides.length=0,new J9(s,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let s=(r.minY+r.maxY)/2;this.sweep(t,i,s)}catch(s){if(s===qg)return!0;throw s}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let s=r.bbox().extendOfSize(1e-5);for(let n of i.rtree.search(s))if(n.trans=NaN,bn(r.shape,n.shape)>0)throw qg}}sweep(t,i,r){let s=ss.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),n=new Array;this.fillValidSides(n,t.rtree.search(s),r),this.fillValidSides(n,i.rtree.search(s),r),Kl(n,(o,l)=>o.getX(r)-l.getX(r),0,n.length);let a=new Lw(this.rule,this,r);for(let o of n)a.onEp(o)}},L1=class eo{constructor(t){this.items=new Array(t.length),ns.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return Ug(t,(r,s)=>(i.push(s),!0)),new eo(i)}static build2(t){let i=t.map(r=>At.build8(r));return new eo(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new eo(i)}calcBBox(){let t=new Fs;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new eo(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof eo?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let s=0,n=t.length;s<n;s++){let a=t[s];if(!i.has(a)&&!r.has(a)){s+1>=n&&i.add(a);for(let o=s+1;o<n;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;Z9.isIntersect(new eo([a]),new eo([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new eo(i)}},K9=ns.funcCopy(Kl),$9=ns.funcCopy(Kl),Q9=ns.funcCopy(Kl);function eF(e){return new Array}function tF(e,t){let i=new Bd(!1),r=new kd(e,Zg.DUMMY,i);for(let s of t)r.addPolyline(s);return r.simplify(),i.plGrps}var kd=class extends Bg{constructor(e,t,i){super(new Cw(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,K9(t,Bg.sortByBBoxMinY,0,t.length);let r=new Jl;this.curNetIndex=0;let s=Number.POSITIVE_INFINITY;for(let n of e)n>s&&this.scan(r,(s+n)/2,t),s=n;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,s=e.listIterator();for(;s.hasNext();){let n=s.next(),a=n.item;Te.less(a.bbox().maxY,t)?e.remove(n):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let n=i[this.curNetIndex];if(Te.less(n.bbox().minY,t))Te.greatereq(n.bbox().maxY,t)&&(this.add2AET(e,n),!r&&n.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let n=new Lw(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();n.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,s=t.bbox().minY,n=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,h=a.next(),c=h.item,d=c.bbox().minX,f=c.bbox().maxX;if(r<=d)l=-1;else if(f<=i)l=1;else{let p=c.bbox().minY,g=c.bbox().maxY,_=Math.max(s,p),y=Math.min(n,g);l=this.compareBySweep(t,c,(_+y)/2)}let u=c.shape;if(u instanceof ce&&u.length()<.001&&o==null&&l<0){o=h;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(h,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),s=this.getLineAngle(t);return Te.eq(r,s)?-e.sweepAngle:s-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let s=t.getX(i);if(!isFinite(s))return 0;if(!Te.eq(r,s))return r-s;if(e.shape instanceof ce)return t.shape instanceof ce?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof ce)return this.compareArcLine(e.shape,t.shape,i);{let n=e.shape,a=t.shape,o=this.getArcAngle(n,i),l=this.getArcAngle(a,i);return Te.eq(o,l)?n.sweepAngle*a.sweepAngle<=0?n.sweepAngle<=0?1:-1:n.sweepAngle>0?n.rx-a.rx:a.rx-n.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let s=i.reverse(r);if(e){this.event.onResultSide(s);let n=s.shape.multiply3(er.ROT_N90),a=s.start.multiply3(er.ROT_N90),o=s.end.multiply3(er.ROT_N90);s=new Ac(this,n,s.baseWeight,a,o,s.polyGrp,s.polyIndex)}this.finalSides.push(s),this.event.onResultSide(s)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3(er.ROT_90),s=e.start.multiply3(er.ROT_90),n=e.end.multiply3(er.ROT_90),a=new Ac(this,r,e.baseWeight,s,n,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof Ee){if(t&&i.rx<=t)return!1}else if(i instanceof ce&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new Yg,t=new Ud(10);for(let n of this.finalSides)e.computeIfAbsent(n.start,eF).push(n),t.add(n.start);let i=0,r=new Pc,s=new Array;for(let n of this.finalSides)if(!r.contains(n)){let a=new Pc,o=n.start,l=new Jl;l.add(n),r.add(n);let h=n.end;for(;l.size()>0;)if(this.isStart(o,h)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let c=e.get(h),d=this.findNext(r,c);if(d==null&&(h=this.findNeigber(h,a,t,.01),h!==null&&(c=e.get(h),d=this.findNext(r,c))),d!=null)l.add(d),r.add(d),h=d.end;else if(h!=null?a.add(h):(s.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),s.push(l.removeLast())),l.size()>0)h=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new W9(t);Ic(e,(r,s)=>(i.add(s),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new Yg;for(let r in this.sideGroups){let s=this.sideGroups[r];Ic(s.sides,(n,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new Pc;for(let r in this.sideGroups){let s=this.sideGroups[r];if(i.add(s)){let n=0,a=new Array;for(a.push(s);n<a.length;){let l=a[n],h=new Array;Ic(l.others,(d,f)=>{let u=t.get(f);return u!=null&&h.push(u.finalGrp),!0}),$9(h,ns.sortAsc,0,h.length);let c=l.id;for(let d of h)if(d!=c&&d!=l.id){let f=this.sideGroups[d];i.add(f)&&a.push(f),c=d}n++}let o=new Array;for(let l of a)o.push(l.polyline());Q9(o,Bg.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new L1(o),e++)}}}findNeigber(e,t,i,r){let s=r*r,n=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<n&&(n=l,a=o)}return n<s?a:null}},iF=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof ce)this.lines.push(e);else if(e instanceof Ee)this.arcs.push(e);else if(e instanceof We)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,s=!0){this.listText.push({pos:e,str:t,size:i,width:r}),s&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],s=[],n=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,gt.toRadians(a.startAngle),gt.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>s.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>n.push(a)),{points:e,lines:t,arcs:i,texts:s,beziers:r,fonts:n}}},Td,qd=(Td=class{constructor(e){this.map=new Yg,this.bus=e}initColor(e){return this.map.computeIfAbsent(e,()=>new iF)}draw(){let e={},t=this.map.entries();for(;t.hasNext();){let i=t.next();e[i.key.toString()]=i.value.build()}this.bus.publish("/debug/draw",e)}clear(){this.map.clear()}static init(e){if(!e)throw new Error("bus is undefined!");this.palette=new Td(e)}static initPalette(e){this.palette=e}static getDefaultColor(){for(let e of this.colorBuffersMap)if(e[0]!==null&&e[0])return e[0]=!1,e[1];return this.colorBuffersMap.forEach(e=>{if(e[0]===null){console.log(1);return}e[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(e,t=this.getDefaultColor()){if(Array.isArray(e))e.forEach(i=>{this.auto(i,t)});else if(e instanceof be)this.point(e,t);else if(e instanceof ss)this.bbox(e,t);else if(e instanceof Vd)this.primitive(e,t);else if(e instanceof At)this.polyline(e,t);else if(e instanceof ar)this.polygon(e,t);else if(e instanceof zi)this.group(e,t);else if(e instanceof L1)this.auto(e.items,t);else{debugger;throw new Error("No incoming type!")}}static text(e,t,i=.5,r=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(r).addText(e,t,i,i/10),this.palette.draw()}static point(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.point(r,t)}):i.addPoint(e),this.palette.draw()}static bbox(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.bbox(i,t)}):(this.primitive(new ce(new be(e.maxX,e.maxY),new be(e.maxX,e.minY)),t),this.primitive(new ce(new be(e.maxX,e.maxY),new be(e.minX,e.maxY)),t),this.primitive(new ce(new be(e.minX,e.minY),new be(e.maxX,e.minY)),t),this.primitive(new ce(new be(e.minX,e.minY),new be(e.minX,e.maxY)),t))}static primitive(e,t=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let i=this.palette.initColor(t);Array.isArray(e)?e.forEach(r=>{this.primitive(r,t)}):i.addPt(e),this.palette.draw()}static polyline(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polyline(i,t)}):e.primitives.forEach(i=>{this.primitive(i,t)})}static polygon(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.polygon(i,t)}):e.items.forEach(i=>{this.polyline(i,t)})}static group(e,t=this.getDefaultColor()){Array.isArray(e)?e.forEach(i=>{this.group(i,t)}):e.items.forEach(i=>{this.polygon(i,t)})}static async begin(){this.t1=performance.now()}static async end(e){console.log(e||"t1:",performance.now()-this.t1)}static async log(e){console.log(e||"==================")}},Td.colorBuffersMap=[[!0,zt.BLUE],[!0,zt.GREEN],[!0,zt.WHITE],[!0,zt.RED],[!0,zt.Golden],[!0,zt.Gray]],Td.t1=0,Td),rF=0,Wd=class O1{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=rF++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:s,y:n}=t;if(this.shape instanceof Ee){let a=this.shape.rx,o=new be((i+s)/2,(r+n)/2),l=this.shape.center,h;return o.x!==l.x||o.y!==l.y?(h=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(h+=h>=0?-180:180)):h=(this.shape.startAngle+this.shape.endAngle())/2,new be(l.x+Math.cos(h)*a,l.y+Math.sin(h)*a)}else{if(this.shape instanceof ce)return new be((i+s)/2,(r+n)/2);if(this.shape instanceof We){let a=this.shape.getPercent(t,ht);return We.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let s=t.cross(i)>0,n=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!s:s)&&(n=Kg-n),n}sortInters(){if(this.shape instanceof Ee){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((s,n)=>{let a=s.coord.sub(t),o=n.coord.sub(t);return O1.finalAngle(i,a,r)-O1.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof ce){let t=this.start,i=this.end,r=new be(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((s,n)=>s.coord.distance2(r)-n.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof We){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,ht)-t.getPercent(r.coord,ht)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(At.build7(o))}),i.push(new ar(s))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(At.build7(o))}),i.push(new ar(s))}),new zi(i)}static rebuild(t,i,r){let s;if(t instanceof ce||i.distance2(r)<1e-6)s=new ce(i,r);else if(t instanceof Ee)s=Ee.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof We){let n=t.getPercent(i,ht),a=t.clip(n)[1];s=a.clip(a.getPercent(r,ht))[0]}else throw new Error("not supported operation");return lt(t,i).dot(lt(s,i))<0?null:s}static returnPolyline(t){return At.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}},sF=(e=>(e[e.END1=0]="END1",e[e.END2=1]="END2",e[e.END12=2]="END12",e[e.LEFT1=3]="LEFT1",e[e.LEFT2=4]="LEFT2",e))(sF||{});function as(e,t,i){if(e instanceof Ee&&t instanceof Ee)return oF(e,t);if(e instanceof Ee&&t instanceof ce)return rw(e,t);if(e instanceof ce&&t instanceof Ee)return iw(e,t);if(e instanceof ce&&t instanceof ce)return Zl(e,t);if(e instanceof We&&t instanceof ce)return e.controls.length===2||no(e)?Zl(new ce(e.start(),e.end()),t):Rw(e,t);if(e instanceof ce&&t instanceof We)return t.controls.length===2||no(t)?Zl(e,new ce(t.start(),t.end())):m1(e,t);if(e instanceof Ee&&t instanceof We)return t.controls.length===2||no(t)?rw(e,new ce(t.start(),t.end())):nF(e,t);if(e instanceof We&&t instanceof Ee)return e.controls.length===2||no(e)?iw(new ce(e.start(),e.end()),t):aF(e,t);if(e instanceof We&&t instanceof We)return D1(e,t);throw new Error("not support")}function Oc(e,t){return lt(e,t.start()).dot(lt(t,t.start()))<=0?!1:as(e,t).state<=2}function t1(e,t){let i=t.getPercent(e.end(),ht);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],s=e.buildConverxHull(ht),n=r.buildConverxHull(ht),a=h(s),o=h(n);return l(a,o);function l(c,d){let f=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),u=c[0],p=d[0];if(!u||!p)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let g=!0;do{let _=u.getShape(),y=p.getShape();if(_ instanceof ce&&y instanceof ce){let m=g?Zl(_,y).state:f.get(Zl(y,_).state);if(m===0)u=u.nextSide,g=!1;else if(m===1)p=p.nextSide,g=!0;else if(m===2)u=u.nextSide,p=p.nextSide,g=!0;else return!1}else throw Error("not support")}while(u!==c[0].prevSide&&p!==d[0].prevSide);return!0}function h(c){let d=c.primitives.map(u=>new Wd(u)),f=d[d.length-1];return d.forEach(u=>{f.connect(u),f=u}),d}}function tw(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+ht)**2||i<(t.rx-ht)**2||!(Qe(e.end(),t.end())||R1(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),s=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let n=e.center.angleD(t.center);return e.rx>t.rx?!(r+s>ht&&ya(e,n))&&!(r-s>ht&&e.rx+t.rx-r>ht&&ya(e,n+180)):!(r-s>ht&&ya(e,n))&&!(e.rx+t.rx-r>ht&&ya(e,n+180))}else{if(r+s<=ht)return!0;let n=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return ya(e,n)?!1:r-s<=ht?!0:!ya(e,n+180)}}function nF(e,t){let i=N1(e,t.start()).toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=D1(a,t).state,r!==0)break}return r===2&&s!==i.length-1?{state:1}:{state:r}}function aF(e,t){let i=t.toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=D1(e,a).state,r!==1)break}return r===2&&s!==i.length-1?{state:0}:{state:r}}function D1(e,t){if(e.controls.length===2||no(e))return t.controls.length===2||no(t)?Zl(new ce(e.start(),t.end()),new ce(t.start(),t.end())):m1(new ce(t.start(),e.end()),t);if(t.controls.length===2||no(t))return Rw(b1(e,t.start()),new ce(t.start(),t.end()));let i=b1(e,t.start());if(no(i))return m1(new ce(t.start(),e.end()),t);let r=t1(i,t),s=t1(t,i);if(!r&&!s){let n=x9(i,t);if(n.havOverlap){let a=n.havOverlap!==2,o=n.havOverlap!==1;return ao(e,t,a,o)}else{let a=function(){for(let d=0;d<h;d+=2)te[d]=c[d],te[d+1]=c[d+1]},o,l,h=n.cnt,c=new Array(h).fill(0).map((d,f)=>te[f]);for(let d=0;d<h;d+=2){let f=new be(te[d],te[d+1]),u=i.getPercent(f,ht),p=t.getPercent(f,ht);if(u===0||p===0)continue;let g=u===1?i:i.clip(u)[0],_=p===1?t:t.clip(p)[0];if(t1(g,_)){let y=lt(e,f).cross(lt(t,f));if(y===0){o=i.end(),l=t.end();break}return{state:y<0?3:4}}a()}return(!o||!l)&&(o=Sc(i.controls,i.controls[0],t),l=Sc(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return ao(e,t,r,s)}function Rw(e,t){let i=b1(e,t.start());if(no(i))return Zl(new ce(i.start(),i.end()),t);let r=Mw(i,t),{isIn:s,bezierIsInLeft:n}=Nw(t,i);if(!r&&!s){if(n!==void 0)return{state:n?3:4};let a=null,o=e.getPercent(t.start(),ht)+.01;for(let l=o>1?1:o;l<=1;){let h=We.pointOn(l,e.controls);if(Gd(t,h)>os){a=h;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return ao(i,t,r,s)}function m1(e,t){let{isIn:i,bezierIsInLeft:r}=Nw(e,t),s=Mw(t,e);if(!i&&!s){if(r!==void 0)return{state:r?4:3};let n=null;for(let a=.01;a<=1;){let o=We.pointOn(a,t.controls);if(Gd(e,o)>os){n=o;break}a+=.01,a>1&&(a=1)}if(!n)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(n.sub(e.start()))<0?3:4}}return ao(t,e,i,s)}function oF(e,t){let i=tw(N1(e,t.start()),t),r=tw(t,e);if(!i&&!r){let s=jn(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:s.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:s.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let n,a;return e.rx>t.rx?(n=e,a=t):(n=t,a=e),s.dot(a.center.sub(n.center))>0&&a.rx+a.center.distance1(n.center)-n.rx>ht?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>ht&&s.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return ao(e,t,i,r)}function iw(e,t){let i=Hn.foot(e,t.center),r=e.end().distance2(t.center),s=e.end().sub(e.start()),n=(t.rx-ht)**2,a=r<=(t.rx+ht)**2&&r>=n&&(s.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=n)&&(Qe(e.end(),t.end())||R1(t,e.end())),o=Bw(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=os?{state:s.cross(jn(t))>0?4:3}:s.dot(i.sub(t.start()))>=0&&(r<n||e.start().distance2(t.center)<n||l<n)?{state:s.cross(t.center.sub(e.start()))<0?4:3}:{state:s.cross(t.center.sub(e.start()))>0?4:3}}return ao(t,e,a,o)}function ya(e,t){return t=gt.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function R1(e,t){return Qe(e.end(),t)||Qe(e.start(),t)||ya(e,t.angleD(e.center))}function Nw(e,t){let i=e.panDistance(ht),r=e.panDistance(-ht),s=sw(t,i),n=sw(t,r);if(!s.length&&!n.length)return{isIn:t.getPercent(e.end(),ht)!==null};let a=[...s,...n].sort((c,d)=>c.t-d.t),o=new ce(r.start(),i.start()),l=[];for(let c=0,d=a.length;c<d;c++){let f=a[c];if(l.push(f),o.distance(f.interP)>e.length()+ht)break;if(l.length===2){let u=(l[1].t*10+l.shift().t*10)/20,p=We.pointOn(u,t.controls);if(e.distance2(p)>os)return{isIn:!1,bezierIsInLeft:e.direct.cross(p.sub(e.start()))>0}}}let h=l.length?o.distance(l[0].interP)>=e.length()+ht:!0;return{isIn:h,bezierIsInLeft:h?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function Mw(e,t){if(Gd(t,e.end())>os||e.getToLineMaxDis2(t)>os)return!1;let i=hF(t,os);return e.getToLineMaxDis2(i)<=(t.length()+ht)**2}function Bw(e,t){let i=t.end().angleD(t.start()),r=lF(t,e.end());if(r>os)return!1;if(ya(e,i+90)){if(Hn.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(ya(e,i-90)){if(Hn.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=os&&(Qe(e.end(),t.end())||y1(t,e.end()))}var kw=(ht*2)**2;function N1(e,t){if(Qe(e.end(),t))return Ee.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<kw)return e;let i=gt.regularD(t.angleD(e.center));if(!ya(e,i))throw new Error("!angleIsInArc(arc, angle)");return Ee.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function b1(e,t){if(Qe(e.end(),t))return new We([t,t]);if(e.start().distance2(t)<kw)return e;let i=e.getPercent(t,ht);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function rw(e,t){let i=Bw(N1(e,t.start()),t),r=t.end().distance2(e.center),s=t.end().sub(t.start()),n=Hn.foot(t,e.center),a=(e.rx-ht)**2,o=r<=(e.rx+ht)**2&&r>=a&&(s.dot(n.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(n)||n.distance2(e.center)>=a)&&(Qe(e.end(),t.end())||R1(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=os?{state:s.cross(jn(e,t.start().angle(e.center)))>0?3:4}:s.dot(n.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:s.cross(e.center.sub(t.start()))>0?4:3}:{state:s.cross(e.center.sub(t.start()))<0?4:3}}return ao(t,e,i,o)}function Zl(e,t){if(Qe(e.end(),t.end()))return ao(e,t,!0,!0);let i=Gd(t,e.end())<=os&&y1(t,e.end()),r=Gd(e,t.end())<=os&&y1(e,t.end());if(!i&&!r){let s=e.direct.x===0&&e.direct.y===0,n=t.direct.x===0&&t.direct.y===0;if(s&&n)throw Error("2LineAllIsPoint");return s?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return ao(e,t,i,r)}function y1(e,t){return Hn.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function ao(e,t,i,r){if(i)return r?Qe(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function Gd(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function lF(e,t){return Math.min(e.distance2(t),Hn.foot(e,t).distance2(t))}function hF(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new ce(r.start(),i.start())}function no(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,s=t.x-i.x,n=-r*t.x-s*t.y,a=Math.sqrt(1/(r**2+s**2));r*=a,s*=a,n*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(h=>{let c=r*h.x+s*h.y+n;c<o&&(o=c),c>l&&(l=c)}),wa(o,l)}function sw(e,t){let i=bn(e,t),r=[],s=new Array(i).fill(0).map((a,o)=>te[o]);for(let a=0;a<i;a+=2){let o=new be(te[a],te[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),n()}function n(){for(let a=0;a<i;a+=2)te[a]=s[a],te[a+1]=s[a+1]}return r}var ba=.01,cF=270;function el(e){let t=ba**2,i=e.end(),r=[],s=[];for(let u=0,p=e.primitives.length;u<p;u++){let g=function(C,M){return C instanceof ce&&M instanceof ce&&Math.abs(C.direct.cross(M.direct))<Te.eps&&C.direct.dot(M.direct)>0||C instanceof Ee&&M instanceof Ee&&Math.abs(C.rx-M.rx)<=Te.eps&&C.center.distance2(M.center)<Te.eps&&C.isCCW===M.isCCW},_=function(C){if(Qs(C,ba))s.push(null);else{if(C instanceof ce)s.push(C);else if(C instanceof Ee&&C.rx===C.ry)d(C,s);else if(C instanceof We){let M=[];Tw(C,M),M.forEach(H=>{let k=H.start(),F=H.end();c(k,F)||s.push(H)})}else throw new Error("not support!");i=b}},y=function(C){if(C instanceof ce)return C.direct.x===0&&C.direct.y===0;if(C instanceof Ee)return C.sweepAngle===0;if(C instanceof We){let M=new Set(C.controls.map(k=>k.x)),H=new Set(C.controls.map(k=>k.y));return M.size===1&&H.size===1}else throw new Error("not support")},m=e.primitives[u],O=m.start(),b=m.end();if(y(m))continue;c(i,O)||(s.push(new ce(i,O)),i=O);let v=(u+1)%p,E=e.primitives[v];for(;g(m,E)&&(v=(v+1)%p,E=e.primitives[v],E!==m););if(v===(u+1)%p){_(m);continue}if(E===m){if(!(m instanceof Ee)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let C=m instanceof Ee?m.isCCW:e.area(.1)>0;s.length=0;let M=C?180:-180;s.push(Ee.build3(m.center,m.startAngle,M,m.rx,m.ry),Ee.build3(m.center,m.startAngle+M,M,m.rx,m.ry));break}let T=(()=>{if(m instanceof ce)return(C,M)=>{let H=new ce(C,M);return Qs(H,ba)?null:[H]};if(m instanceof Ee)return(C,M)=>{let H;if(C.equals1(M)?H=Ee.build3(m.center,m.startAngle,m.sweep()===1?360:-360,m.rx,m.ry):H=Ee.build4(C,M,m.center,m.rx,m.ry,m.sweep()),Qs(H,ba))return null;let k=H.pointOn(H.startAngle+H.sweepAngle/2),F=Ee.build4(H.start(),k,m.center,m.rx,m.ry,m.sweep()),j=Ee.build4(k,H.end(),m.center,m.rx,m.ry,m.sweep());return Qs(F,ba)||Qs(j,ba)?[H]:[F,j]};throw new Error("not support")})(),P=v===0;if(v<u&&!P&&(P=!T(e.primitives[0].start(),e.primitives[v-1].end()),!P)){let C=T(m.start(),e.primitives[p-1].end());if(C)s.push(...C);else{let M=T(m.start(),s[0].end());if(M.length===1)s[0]=M[0];else if(M.length===2)s[0]=M[1],s.push(M[0]);else throw new Error("!!!generatorPt")}break}u=v===0?p-1:v-1,E=e.primitives[u];let A=T(m.start(),E.end());if(A?(A.forEach(C=>s.push(C)),i=E.end()):_(null),P)break}let n=s.length;if(s.forEach((u,p)=>{if(u)r.push(u);else{let g,_;p===n-1&&(g=r[0],_=r[r.length-1]);let y=(p+1)%n;if(g=g!=null?g:s[y],g){let m=p,O=!1;for(;_=_!=null?_:s[(--m+n)%n],_!==g;)if(_){O=!0;break}if(O){if(g.start().equals1(_.end()))return;if(lt(_,_.end()).dot(lt(g,g.start()))<0){if(!c(_.end(),g.start())){let T=new ce(_.end(),g.start());r.push(T);return}let{rebuildPrevPt:b,rebuildNextPt:v,rebuildLinkLine:E}=nw(s[(m-1+n)%n],_,new ce(_.end(),g.start()),g,s[(p+2)%n]);b&&v&&(b!==_?(s[(m+n)%n]=b,r[r.length-1]&&(r[r.length-1]=b)):v!==g&&(s[(p+1)%n]=v,r[0]===g&&(r[0]=v)),E&&r.push(E))}}}}}),r.length===0)return null;c(i,r[0].start())||r.push(new ce(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof Ee?At.build7([Ee.build2(a.center,0,180,a.rx,a.ry,a.sweep()),Ee.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof We?At.build7(a.clip(.5)):null;let o=r.map(u=>new uF(u)),l=o[o.length-1];for(o.forEach(u=>{u.connect(l),l=u});!l.isVisited;){let u=function(){l.next.connect(g),l=l.next,l.isConnected=!1,l.isVisited=!1},p=function(){l.connect(g.prev),l.isConnected=!1},g=l.prev;if(l===g)break;let _=l.pt,y=g.pt,m=y.end();if(!l.isConnected&&!m.equals(_.start())){let O=function(v){l.isConnected=!0,l.pt=_=v,l.next.isVisited=!1},b=function(v){l.isConnected=!0,g.pt=v,g.isVisited=!1,l=g};if(_ instanceof ce)if(c(m,_.end())){u();continue}else O(new ce(m,_.end()));else if(y instanceof ce){c(y.start(),_.start())?p():b(new ce(y.start(),_.start()));continue}else if(_ instanceof We)if(c(m,_.end())&&!(_.controls.length!==2&&_.getToLineMaxDis2(_.startToEndL)>=t)){u();continue}else O(new We([m,..._.controls.slice(1)]));else if(y instanceof We)c(y.start(),_.start())&&!(y.controls.length!==2&&y.getToLineMaxDis2(y.startToEndL)>=t)?p():b(new We([...y.controls.slice(0,-1),_.start()]));else if(_ instanceof Ee&&y instanceof Ee)if(Math.abs(Math.abs(_.sweepAngle)-180)<Math.abs(Math.abs(y.sweepAngle)-180)){let v=Ee.build5(m,_.end(),_.sweepAngle);if(c(v.start(),v.end())&&!(v.rx>=ba&&Math.abs(v.sweepAngle)>180)){u();continue}else O(v)}else{let v=Ee.build5(y.start(),_.start(),y.sweepAngle);c(v.start(),v.end())&&!(v.rx>=ba&&Math.abs(v.sweepAngle)>180)?p():b(v);continue}else throw new Error("not support")}if(lt(_,_.start()).dot(lt(y,y.end()))<0){let O=function(E,T,P,A,C,M){if(l.next===g){l=null;return}let{rebuildLinkLine:H,rebuildPrevPt:k,rebuildNextPt:F}=nw(E,T,P,A,C);k&&F&&(k!==T&&(g.prev.pt=k),F!==A&&(l.next.pt=F),H?M.pt=H:u())},b=function(){l.next===g?l=null:(l.next.connect(g.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},v=as(y.reverse(),_).state;if(v===0){let E=aw(_,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(lt(P,P.start()).dot(lt(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof ce?E:new ce(E.start(),E.end()),P,l.next.next.pt,l),!l)break}else l.pt=E;p();continue}else if(v===1){let E=aw(y,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(lt(P,P.start()).dot(lt(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof ce?E:new ce(E.start(),E.end()),P,l.next.next.pt,g),!l)break}else g.pt=E;u();continue}else if(v===2){if(b(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let h=l;for(r.push(l.pt),l=l.next;l!==h;)r.push(l.pt),l=l.next;if(r.length===1){let u=r[0];return u instanceof Ee?(c(u.start(),u.end())?r[0]=Ee.buildCircle(u.center,u.rx,u.sweep()):r.push(new ce(u.end(),u.start())),At.build7(r)):u instanceof We?(c(u.start(),u.end())||r.push(new ce(u.end(),u.start())),At.build7(r)):null}if(e=At.build7(r),Math.abs(e.area(.1))<t)return null;return e;function c(u,p){return u.distance2(p)<t}function d(u,p){if(Math.abs(u.sweepAngle)>cF){let g=u.sweepAngle/2;d(Ee.build3(u.center,u.startAngle,g,u.rx,u.ry),p),d(Ee.build3(u.center,u.startAngle+g,g,u.rx,u.ry),p)}else p.push(u)}function f(u){return u.start().distance2(u.end())<t&&!(u instanceof Ee&&u.rx>=ba&&Math.abs(u.sweepAngle)>180||u instanceof We&&u.controls.length!==2&&u.getToLineMaxDis2(new ce(u.start().add1(1,0),u.end()))>=t)}}function Qs(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof Ee){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof We){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new ce(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function mc(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(ba-e.length())+Te.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new be(r.x+i.x,r.y+i.y)}function nw(e,t,i,r,s){if(!e)a();else if(!s)o();else{let l=lt(e,e.end()),h=lt(t,e.end()),c=l.dot(h);if(c>=0)a();else{let d=lt(r,r.end()),f=lt(s,r.end()),u=d.dot(f);if(u>=0)o();else if(wa(c,-1)&&wa(u,-1)){let p=i.center();n(p),i=null}else c>u?a():o()}}function n(l){let h;if(t instanceof ce)h=new ce(t.start(),l);else if(t instanceof We)h=new We([...t.controls.slice(0,-1),l]);else if(t instanceof Ee)h=Ee.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=Qs(h,ht)?null:h;let c;if(r instanceof ce)c=new ce(l,r.end());else if(r instanceof We)c=new We([l,...r.controls.slice(1)]);else if(r instanceof Ee)c=Ee.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=Qs(c,ht)?null:c}function a(){if(t instanceof ce){let l=mc(i.reverse());i=new ce(l,i.end());let h=new ce(t.start(),l);t=Qs(h,ht)?null:h}else if(t instanceof We){let l=mc(i.reverse());i=new ce(l,i.end());let h=new We([...t.controls.slice(0,-1),l]);t=Qs(h,ht)?null:h}else if(t instanceof Ee){let l=mc(i.reverse());i=new ce(l,i.end());let h=Ee.build5(t.start(),l,t.sweepAngle);t=Qs(h,ht)?null:h}else throw new Error("not supported")}function o(){if(r instanceof ce){let l=mc(i);i=new ce(i.start(),l);let h=new ce(l,r.end());r=Qs(h,ht)?null:h}else if(r instanceof We){let l=mc(i);i=new ce(i.start(),l);let h=new We([l,...r.controls.slice(1)]);r=Qs(h,ht)?null:h}else if(r instanceof Ee){let l=mc(i);i=new ce(i.start(),l);let h=Ee.build5(l,r.end(),r.sweepAngle);r=Qs(h,ht)?null:h}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function aw(e,t,i){if(e instanceof ce||t.distance2(i)<=os)return new ce(t,i);if(e instanceof Ee)return Ee.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof We){let r=e.getPercent(t,ht),s=e.getPercent(i,ht);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}var uF=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function Wg(e){let t=Xd(),i;if(e instanceof At){let r=el(e);if(r===null)return null;i=r}else if(e instanceof ar){let r=e.items.map(s=>Wg(s)).filter(s=>s!==null);if(r.length===0)return null;i=new ar(r)}else{let r=e.items.map(s=>Wg(s)).filter(s=>s!==null);if(r.length===0)return null;i=new zi(r)}return xa.preprocessPolyline+=$o(t),i}var xa={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function Xd(){return{timeIndex:Object.assign({},xa),start:performance.now()}}function ow(e){return Object.values(e).reduce((t,i)=>t+i,0)}function $o(e){return performance.now()-e.start-(ow(xa)-ow(e.timeIndex))}function wr(e,t,i,r){let s=zt.RED,n=zt.Golden;function a(){if(!r)return;let f=r.initColor(zt.Golden);f.addPt(o),f.addPoint(o.end()),r.initColor(zt.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),h=lt(o,l.start()),c=lt(l),d=h.cross(c);if(wa(d,0))if(o instanceof ce)if(l instanceof ce){if(Te.eq(d,0)&&(h.dot(c)>0?!Qe(o.end(),l.start()):!Qe(o.start(),l.start())))throw a(),new Error("line and line");return d<0}else{if(l instanceof Ee)return h.cross(l.center.sub(o.start()))<0;if(l instanceof We){let f=l.getExtremePoints(o),u=f.length?f[0]:Sc(l.controls,o.start());return h.cross(u.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof Ee){if(l instanceof ce)return o.isCCW;if(l instanceof Ee){if(l.center.equals1(o.center)&&(h.dot(c)>0?!Qe(o.end(),l.start())&&o.end().sub(l.start()).dot(c)>0:!Qe(o.start(),l.start())&&o.start().sub(l.start()).dot(c)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof We)if(l instanceof ce){let f=o.getPercent(l.start(),ht),u=o.clip(f)[1],p=u.getExtremePoints(l);return(p.length?p[0]:Sc(u.controls,l.start())).sub(l.start()).cross(c)<0}else if(l instanceof We){let f=o.getPercent(l.start(),ht),u=o.clip(f)[1],p=u.getExtremePoints(new ce(l.start(),l.end())),g=l.getExtremePoints(new ce(u.start(),u.end())),_=p.length?p[0]:Sc(u.controls,l.start()),y=g.length?g[0]:Sc(l.controls,l.start()),m=_.sub(l.start()),O=y.sub(l.start());return m.cross(O)<0}else throw Error("not support");else throw new Error("not support");else return d<0}function $l(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof Ee?jn(n,gt.toRadians(n.endAngle())):n instanceof We?Fd(n,1):n.end().sub(n.start()).normalize(),l=lt(a),h=o.dot(l);if(wa(h,-1))return wr(e,t,!0,s)?wr(e,i,r,s)&&wr(t,i,r,s):wr(e,i,r,s)||wr(t,i,r,s);{let c=o.scale(-1).angle(be.ORIGIN),d=l.angle(be.ORIGIN);c>d&&(c-=Kg);let f=(c+d)/2,u=new be(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=lt(p);return u.cross(g)<0?wr(e,i,r,s):wr(t,i,r,s)}}function i1(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof Ee?jn(n,gt.toRadians(n.endAngle())):n instanceof We?Fd(n,1):n.end().sub(n.start()).normalize(),l=lt(a),h=o.dot(l);if(wa(h,-1))return wr(e,t,!0,s)?wr(e,i,r,s)&&wr(t,i,r,s):wr(e,i,r,s)||wr(t,i,r,s);{let c=o.scale(-1).angle(be.ORIGIN),d=l.angle(be.ORIGIN);c>d&&(c-=Kg);let f=(c+d)/2,u=new be(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=lt(p);if(u.cross(g)<0){let _=o.dot(g)<0,y=as(_?e.getShape().reverse():e.getShape(),p).state;return y!==3&&y!==4?wr(e,i,r,s):y===(_?4:3)}else{let _=l.dot(g)<0,y=as(_?t.getShape().reverse():t.getShape(),p).state;return y!==3&&y!==4?wr(t,i,r,s):y===(_?4:3)}}}var dF=(e=>(e[e.NOT_IN=0]="NOT_IN",e[e.IS_IN=1]="IS_IN",e[e.IS_OVERLAP=2]="IS_OVERLAP",e))(dF||{}),fF=(e=>(e[e.AllClear=0]="AllClear",e[e.MapClear=1]="MapClear",e))(fF||{}),va,Qo=!1;function en(e,t,i,r,s,n,a,o=i.side===t,l=!0,h){return va=s,Qo=n,Fw(Uw(e,t,l,h,a,i,o,r),i,o,r,0)}function to(e,t,i,r,s,n,a,o=r.side===i){va=s,Qo=n;let l=Gw(e,t,i,new Map,r,o,a),h=l instanceof Array?-1:1;return Fw(l,r,o,a,h)}function Fw(e,t,i,r,s){for(;e instanceof Array;)s++,e.length===4?e=Gw(...e,t,i,r):e=Uw(...e,t,i,r);return{...e,existOverlap:s>0}}function Uw(e,t,i,r,s,n,a,o){if(Xg===-1){o.initColor(zt.RED).addPt(e.getShape()),o.initColor(zt.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),h=a?t.getShape().reverse():t.getShape(),c=(l instanceof Ee?jn(l,i?h.start().angle(l.center):r?gt.toRadians(l.endAngle()):void 0):l instanceof We?lt(l,i?h.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),d=(h instanceof Ee?jn(h,i?void 0:(r?l.end():l.start()).angle(h.center)):h instanceof We?lt(h,i?void 0:r?l.end():l.start()):h.end().sub(h.start())).normalize();if(r===void 0){let p=c.dot(d);if(r=p<0,wa(p,0))return{state:wr(e,t,!a,o)?1:0,inter:io(e,t,n,a,i,r,s)}}else if(r?c.dot(d)>0:c.dot(d)<0)if(i){let p,g=!0;if(l instanceof ce&&Qe(Hn.foot(l,h.start()),r?l.end():l.start()))g=!1;else if(l instanceof Ee||l instanceof We){let _=r?l.reverse():l,y=as(h,I9(_,h.start()).reverse()).state;(y===1||y===2)&&(g=!1)}if(g){let _=!r;p=as(_?l.reverse():l,h,o).state===(_?4:3)?1:0}else r?p=$l(e,e.nextSide,t,!a,o)?1:0:p=$l(e.prevSide,e,t,!a,o)?1:0;return{state:p,inter:io(e,t,n,a,i,r,s)}}else return r?{state:wr(e,e.nextSide,!0,o)?0:1,inter:io(e,t,n,a,i,r,s),isReversed:!0}:{state:wr(e.prevSide,e,!0,o)?0:1,inter:io(e,t,n,a,i,r,s),isReversed:!0};let f,u=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!Qo){let p=e.judgeOverlapMap.get(t);f=r?u.get(p.state):p.state}else f=as(r?l.reverse():l,h).state,(f===3||f===4)&&e.judgeOverlapMap.set(t,{state:r?u.get(f):f});else{if(t.judgeOverlapMap.has(e)&&!Qo){let p=t.judgeOverlapMap.get(e);f=a?u.get(p.state):p.state}else f=as(h,r?l.reverse():l).state,(f===3||f===4)&&t.judgeOverlapMap.set(e,{state:a?u.get(f):f});f=u.get(f)}if(f===1||f===2){let p=a?t.prevSide:t,g=p.inters,_=p.getEnd();for(let y=g.length-1;y>=0;y--){let m=g[y];if(!(p.getShape()instanceof We)&&!Qe(_,m.coord))break;if(m===n)return{state:2,inter:io(e,t,n,a,i,r,s)}}}if(f===3||f===4)return{state:f===(r?4:3)?1:0,inter:io(e,t,n,a,i,r,s)};if(s.has(e)?s.get(e).mapSideList.push(t):s.set(e,{sideIsReversed:r,mapSideList:[t]}),s.has(t)?s.get(t).mapSideList.push(e):s.set(t,{sideIsReversed:a,mapSideList:[e]}),f===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,s]:[e,e.nextSide,a?t.prevSide:t.nextSide,s];if(f===0)return[r?e.prevSide:e.nextSide,t,!1,r,s];if(f===1)return[e,a?t.prevSide:t.nextSide,!0,r,s];throw Error("not support")}function io(e,t,i,r,s,n,a){if(Qo)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),h=r;if(!s){let u=t;t=e,e=u,r=n,i=i.getBindedInter()}let c=u=>!(s?n:h)&&Qe(u,e.prevSide.getEnd())?e.prevSide:e;if(r){let u=t.inters;for(let p=0;p<u.length;p++){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&Qe(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.nextSide;let p=t.inters;for(let g=0;g<p.length;g++){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||Qe(_.coord,y.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(a.has(y)){let m=t.getShape().reverse(),O=lt(m,_.coord).dot(lt(y.getShape(),_.coord))<0,b=O?y.getShape().reverse():y.getShape(),v=as(m,O?Zm(b,_.coord,b.end()):Zm(b,b.start(),_.coord)).state;if(v===1||v===2)return f(_)}else a.has(y.nextSide)}else if(_.side===i.side&&d(_))return f(_)}}}else{let u=t.inters;for(let p=u.length-1;p>=0;p--){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&Qe(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.prevSide;let p=t.inters;for(let g=p.length-1;g>=0;g--){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||Qe(_.coord,_.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(!a.has(y)&&a.has(y.prevSide)){let m=t.getShape().reverse(),O=lt(m,_.coord).dot(lt(y.getShape(),_.coord))<0;if(a.has(y.prevSide)){let b=O?y.getShape().reverse():y.getShape(),v=as(t.getShape(),Zm(b,_.coord,b.end())).state;if(v===1||v===2)return f(_)}}}else if(_.side===i.side&&d(_))return f(_)}}}function d(u){if(u.isInvalid||u.getBindedInter().side!==(Qe(u.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let p;if(s){if(Qe(u.coord,l.start()))return!0;p=as(n?o.reverse():o,g(l)).state}else{if(Qe(u.coord,n?o.end():o.start()))return!0;p=as(l,g(n?o.reverse():o)).state}return p===2||p===1;function g(_){if(_ instanceof ce)return Qe(u.coord,_.end())?_:_.cutLine(u.coord);if(_ instanceof Ee)return Ee.build2(_.center,_.startAngle,u.coord.angleD(_.center),_.rx,_.ry,_.isCCW?1:0);if(_ instanceof We)return _.clip(_.getPercent(u.coord,ht))[0];throw new Error("not supported operation")}}function f(u){let p=i.getBindedInter(),g=i.side,_=p.side,y=i===u,m=i;if(r){let O=i.getIndex()-1;for(;g;){let b=g.inters;for(;O>=0;O--)if(i=b[O],i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(va===0)!i.isInvalid&&(!Qe(i.coord,u.coord)||i.side===u.side&&i.getBindedInter().side===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(va===1){if(i.isInvalid)continue;let v=i.getBindedInter().side;a.has(g)&&a.get(g).mapSideList.includes(v)&&(i.setIsInvalid(),i.isDealed(),m=i)}g=g==null?void 0:g.prevSide,O=(g==null?void 0:g.inters.length)-1}}else{let O=i.getIndex()+1;for(;g;){let b=g.inters;for(;O<b.length;O++){i=b[O];let v=i.getBindedInter();if(i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(va===0)!i.isInvalid&&(!Qe(i.coord,u.coord)||g===u.side&&(Qe(v.side.getEnd(),i.coord)?v.side.nextSide:v.side)===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(va===1){let E=v.side;a.has(g)&&a.get(g).mapSideList.includes(E)&&(i.setIsInvalid(),i.isDealed(),m=i)}}g=g==null?void 0:g.nextSide,O=0}}if(va===0&&!Qe(p.coord,u.coord))if(s?a.has(_)?a.get(_).sideIsReversed:n:h){let O=p.getIndex()-1;for(;_;){let b=a.has(_),v=_.inters;for(;O>=0;O--){if(p=v[O],p===u.getBindedInter()){_=null;break}p.isInvalid||!b||(!Qe(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.prevSide,O=(_==null?void 0:_.inters.length)-1}}else{let O=p.getIndex()+1;for(;_;){let b=_.inters,v=a.has(_);for(;O<b.length;O++){if(p=b[O],p===u.getBindedInter()){_=null;break}let E=Qe(_.getEnd(),p.coord)?a.has(_.nextSide):!1;p.isInvalid||!(v||E)||(!Qe(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.nextSide,O=0}}return s?m:m.getBindedInter()}}function Gw(e,t,i,r,s,n,a){let o=e.getShape(),l=t.getShape(),h=n?i.getShape().reverse():i.getShape(),c=(o instanceof Ee?jn(o,h.start().angle(o.center)):o instanceof We?lt(o,h.start()):o.end().sub(o.start())).normalize(),d=(l instanceof Ee?jn(l,h.start().angle(l.center)):l instanceof We?lt(l,h.start()):l.end().sub(l.start())).normalize(),f=c.dot(d);if(wa(f,-1)){let u=n?i.getShape().reverse():i.getShape(),p=lt(u).normalize(),g=c.add(d.scale(-1)).normalize().dot(p),_=as(o.reverse(),l,a).state;if(g>-.9&&(_===3||_===4))return{state:_===4?0:1,inter:io(t,i,s,n,!0,!1,r)};let y=en(e,i,s,a,va,Qo,r.size===0?new Map:r,n);return y.state===2?y:_===4?y.state===0||y.inter!==s?y:en(t,i,s,a,va,Qo,r.size===0?new Map:r,n):y.state===1||y.inter!==s?y:en(t,i,s,a,va,Qo,r.size===0?new Map:r,n)}else{let u=c.scale(-1).angle(be.ORIGIN),p=d.angle(be.ORIGIN);u>p&&(u-=Kg);let g=(u+p)/2,_=new be(Math.cos(g),Math.sin(g)),y=lt(h).normalize(),m=y.angle(be.ORIGIN),O=u<m&&m<p&&o instanceof ce&&l instanceof ce&&h instanceof ce;if(_.cross(y)<=0){if(c.scale(-1).dot(y)<0){let b;return s.coord.equals1(h.start())?b=lt(o,s.coord).dot(lt(h,s.coord))<0:h instanceof ce&&(b=lt(o,o.end()).dot(h.direct)<0),{state:$l(e,t,i,!n,a)?1:0,inter:io(e,i,s,n,!0,b,r)}}return O&&o.distance2(h.start())>os?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return d.dot(y)<=0?{state:$l(e,t,i,!n,a)?1:0,inter:io(t,i,s,n,!0,void 0,r)}:O&&l.distance2(h.start())>os?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var Xg=0;function pF(e,t,i,r){let s=t.getBindedInter(),n=t.side,a=s.side,o=n.getShape(),l=a.getShape();if(r&&(Xg++,Xg===-1)){r.initColor(zt.RED).addPt(o),r.initColor(zt.Golden).addPt(l),r.draw();debugger}let h=0,c=!1;if(e===-1){let T=to(n,n.nextSide,a,s,h,c,r),P=T.state!==0;if(T.state===2){let C=lt(o,t.coord).add(lt(n.nextSide.getShape(),t.coord)).normalize(),M=lt(l,t.coord).add(lt(a.nextSide.getShape(),t.coord)).normalize();return E(P,C.dot(M)>0)}let A=to(n,n.nextSide,a.nextSide,s,h,c,r);return T.state!==A.state?(v(T,A),1):E(P,T.state!==to(a,a.nextSide,n,t,h,!0,r).state,T.inter,A.inter)}if(e===1){let T=en(n,a,s,r,h,c,new Map),P=T.state!==0;if(T.state===2)return E(P,lt(o,t.coord).dot(lt(l,t.coord))>0);let A;if(T.isReversed&&T.existOverlap&&Qe(T.inter.coord,a.getEnd())&&T.inter.getBindedInter().side!==n){let H=T.inter.getBindedInter().side;if(H===n.nextSide)A={state:$l(n,H,a.nextSide,!0,r)?1:0,inter:s};else if(H===n.prevSide){if(A={state:$l(H,n,a.nextSide,!0,r)?1:0,inter:T.inter},T.state===A.state&&t!==T.inter){let k=lt(l,t.coord),F=lt(a.nextSide.getShape(),t.coord),j=lt(H.getShape(),t.coord);return E(P,k.add(F).dot(j)>0,T.inter,A.inter)}}else A=en(n,a.nextSide,s,r,h,c,new Map)}else A=en(n,a.nextSide,s,r,h,c,new Map);if(T.state!==A.state)return v(T,A),1;let C=lt(l,t.coord),M=lt(a.nextSide.getShape(),t.coord);if(wa(C.dot(M),-1)){let H=wr(a,a.nextSide,!0,r);return E(P,T.state!==en(a.nextSide,n,t,r,h,!0,new Map,H?!P:P,!1).state,T.inter,A.inter)}else{let H=lt(o,t.coord);return E(P,C.add(M).dot(H)>0,T.inter,A.inter)}}if(!(o instanceof We||l instanceof We))return 1;let d=lt(o,t.coord),f=lt(l,t.coord),u,p;if(l instanceof ce)u=new ce(t.coord,l.start()),p=new ce(t.coord,l.end());else if(l instanceof Ee){let T=t.coord.angleD(l.center);u=Ee.build2(l.center,T,l.startAngle,l.rx,l.ry,l.isCCW?0:1),p=Ee.build2(l.center,T,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof We){let T=l.getPercent(t.coord,ht);[u,p]=l.clip(T),u=u.reverse()}else throw new Error("not support");let g=d.dot(f)>0,_,y;g?(_=as(o.reverse(),u).state,y=as(o,p).state):(_=as(o,u).state,y=as(o.reverse(),p).state);let m;_===0?m=en(g?n.prevSide:n.nextSide,a,s,r,h,c,new Map,!0,!1,g):_===1?m=en(n,a.prevSide,s,r,h,c,new Map,!0,!0,g):_===2?g?m=to(n.prevSide,n,a.prevSide,s,h,c,r,!0):m=to(n,n.nextSide,a.prevSide,s,h,c,r,!0):g?_===3?m={inter:s,state:0}:m={inter:s,state:1}:_===3?m={inter:s,state:1}:m={inter:s,state:0};let O=m.state!==0;if(m.state===2)return E(O,g);let b;if(y===0?b=en(g?n.nextSide:n.prevSide,a,s,r,h,c,new Map,!1,!1,!g):y===1?b=en(n,a.nextSide,s,r,h,c,new Map,!1,!0,!g):y===2?g?b=to(n,n.nextSide,a.nextSide,s,h,c,r,!1):b=to(n.prevSide,n,a.nextSide,s,h,c,r,!1):g?y===3?b={inter:s,state:1}:b={inter:s,state:0}:y===3?b={inter:s,state:0}:b={inter:s,state:1},m.state===b.state)return m.inter===b.inter?(t.setIsInvalid(),0):E(O,g,m.inter,b.inter);return v(m,b),1;function v(T,P){let A=T.state!==0;if(T.inter===P.inter){t.setOutToIn(A);return}else bc(T.inter,P.inter,!0),bc(P.inter,T.inter,!1);let C=[];if(e===-1){let H=lt(o,t.coord),k=lt(n.nextSide.getShape(),t.coord),F=lt(l,t.coord),j=lt(a.nextSide.getShape(),t.coord);C.push(H.dot(F)),C.push(H.dot(j)),C.push(k.dot(F)),C.push(k.dot(j))}else{let H=lt(o,t.coord);C.push(lt(l,t.coord).dot(H)),C.push(lt(a.nextSide.getShape(),t.coord).dot(H))}if(C.reduce((H,k)=>Math.abs(H)>Math.abs(k)?H:k,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(A);else throw new Error("not support");else if(i===1)M(!A);else if(i===0||i===2||i===3)M(A);else throw new Error("not support");function M(H){t.setIsInvalid();let k=(H?T:P).inter;delete k.isInvalid,delete k.getBindedInter().isInvalid,k.setOutToIn(!A)}}function E(T,P,A,C){if(A===C){if(t.side.outline.inters.find(k=>!k.isInvalid&&k!==t&&Qe(k.coord,t.coord)))return t.setIsInvalid(),0;let M=new ro(t.coord,n,r),H=new ro(t.coord,a,r);return M.bind(H),P?n.inters.splice(t.getIndex(),0,M):n.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,H),M.setOutToIn(T),t.setOutToIn(!T),M.isDealed(),n.inters.forEach((k,F)=>k.setIndex(F)),a.inters.forEach((k,F)=>k.setIndex(F)),2}else{let M=function(){let H=A.getBindedInter(),k=C.getBindedInter();delete A.isInvalid,delete H.isInvalid,delete C.isInvalid,delete k.isInvalid,A.setOutToIn(!T),C.setOutToIn(T),bc(A,C,!0),bc(C,A,!1),bc(H,k,P),bc(k,H,!P)};if(t.setIsInvalid(),P){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return T?0:(M(),2);if(i===0||i===2||i===3)return T?(M(),2):0;throw new Error("not support")}}}}function bc(e,t,i){let{judge:r,changeNum:s}=a(),n=e.getIndex();for(let o=n+s,l=e.side.inters;r(o);o+=s){if(l[o].isInvalid)continue;if(!Qe(l[o].coord,e.coord))break;l[o].setIndex(n),l[n].setIndex(o);let h=l[o];l[o]=l[n],l[n]=h,n=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:h=>h<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:h=>h>=l,changeNum:-1}}}}var lw=0,ro=class{constructor(e,t,i){this.id=lw++,this.coord=e,this.side=t,i&&(this.id=lw++,this.drawDebug=i);let r=new Fs;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof ce)return e.end().sub(e.start());if(e instanceof Ee){let t=this.coord.angle(e.center);return e.isCCW?t+=zg:t-=zg,new be(Math.cos(t),Math.sin(t))}else{if(e instanceof We)return Fd(e,e.getPercent(this.coord,ht));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){r1++;let r=r1===-1,s=this.drawDebug.initColor(zt.RED);if(r){this.drawDebug.draw();debugger}i=n=>{if(e.push(n),r){s.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(Te.eq(o.distance2(l),0))return;let h=Wd.rebuild(n.getShape(),o,l);if(!h)return!0;i(h)};t.visit();let s=t.getIndex(),n=t.side,a=n.inters[s+1];for(;a!=null&&a.isInvalid;)a=n.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,n.getEnd()),l=t.coord;for(n=n.nextSide,t=null;;){for(let h of n.inters)if(!h.isInvalid){t=h.bindedInter;break}if(t)break;o?(r(l,n.getEnd()),o=!1):i(n.getShape()),n=n.nextSide}o?(Te.eq(l.distance2(t.coord),0)?r(l,n.getEnd()):r(l,t.coord),o=!1):Te.eq(n.getEnd().distance2(t.coord),0)?i(n.getShape()):r(n.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:r1,handleId:Xg,boolId:Ld})),new Error("inter !== this");return el(At.build7(e))}},r1=0,s1=class v1{constructor(t,i,r,s,n){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=s,this.finalIsOutside=s,this.polyline=i,n&&(this.polygon=n),t.forEach(a=>a.outline=this)}static build(t,i,r,s,n){let a=t.primitives.map(l=>new Wd(l,s)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),n?new v1(a,t,i,r,n):new v1(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,s;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,s=t.interOutlines):(r=t.interOutlines,s=this.interOutlines),s.forEach(n=>{r.push(n),n.interOutlines=r}),i.delete(s)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(ht).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(s=>!r.has(s)))return this.polyline}return At.build7(t)}};function hw(e,t,i){let r=[];return e.forEach(s=>s.forEach(n=>{if(n.hasInter&&!n.isAllInterIsInvalid())return;let a=n.bbox(),o=t.search(a.extendOfSize(ht)).filter(l=>l.bbox().extendOfSize(ht).isContainsBBox(a)).sort((l,h)=>l.bbox().area()-h.bbox().area());for(let l of o)if(l.isContain(n)){let h=i(!n.isOutside,l.isOutside),c=i(n.isOutside,l.isOutside);h!==c&&(r.push(n),n.setFinalIsOutSide(!h));return}i(n.isOutside,!1)!==i(!n.isOutside,!1)&&r.push(n)})),r}function gF(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let s=new Ud(10),n=new Ud(10);e.forEach(o=>o.forEach(l=>s.add(l))),t.forEach(o=>o.forEach(l=>n.add(l)));let a=hw(e,n,r);return hw(t,s,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var _F=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new OF(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let s=this.nodes[i];if(t.key.bbox().maxX<s.key.bbox().minX)break;s.getIsVisit()||t.isContain(s)&&(s.visit(),t.addChild(s),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},OF=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(n=>n.returnPolyline()),s=new Set(i.items);return r.some(n=>!s.has(n))?new ar(r):i}else return new ar(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function cw(e){let t="";return e.items.forEach((i,r)=>{let s="$";if(i.items.forEach((n,a)=>{let o="[";if(n.primitives.forEach((l,h)=>{let c="";if(l instanceof ce)c=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof Ee)c=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof We)c=`Bezier,${l.controls.map(d=>`${d.x},${d.y}`).join(",")}`;else throw new Error("not supported");if(h===n.primitives.length-1){o+=`${c}]`;return}o+=`${c},`}),a===i.items.length-1){s+=`${o}$`;return}s+=`${o}_`}),r===e.items.length-1){t+=`${s}`;return}t+=`${s}^`}),console.log(t),t}function uw(e){let t=e.split("^"),i=[];return t.forEach(s=>{let n=/\$(.*?)\$/,a=s.match(n)[1].split("_"),o=[];a.forEach(h=>{let c=/\[(.*?)\]/,d=h.match(c)[1].split(","),f=[],u=[];for(let g=0;g<d.length;g++){let _=d[g];if(_==="Line"||_==="Arc"||_==="Bezier"){if(f.length){let y=r(f);u.push(y),f.length=0}f.push(_);continue}f.push(Number(_))}f.length&&(u.push(r(f)),f.length=0);let p=At.build7(u);o.push(p)});let l=new ar(o);i.push(l)}),new zi(i);function r(s){let n=s[0];if(n==="Line")return new ce(new be(s[1],s[2]),new be(s[3],s[4]));if(n==="Arc")return Ee.build3(new be(s[1],s[2]),s[3],s[4],s[5],s[5]);if(n==="Bezier"){let a=[];for(let o=1;o<s.length;o+=2)a.push(new be(s[o],s[o+1]));return new We(a)}else throw new Error("not support")}}var mF=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return uw(this.group1Str)}getGroup2(){return uw(this.group2Str)}},n1=new Zg(2),Cd=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),tF(B9,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new Bd(!1),r=new kd(Ng.rule,n1,i);for(let s of e){let n=Ng.weight(0);r.addPolyline(s,n)}for(let s of t){let n=Ng.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new Bd(!1),r=new kd(Mg.rule,n1,i);for(let s of e){let n=Mg.weight(0);r.addPolyline(s,n)}for(let s of t){let n=Mg.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new Bd(!1),r=new kd($m.rule,n1,i);for(let s of e){let n=$m.weight(0);r.addPolyline(s,n)}for(let s of t){let n=$m.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}},Ld=0,a1=!1;function Dd(e,t,i,r,s){let n=Xd(),a=[],o=[],l=[],h=new Set,c;if(s){if(c=new qd(s),Ld++,a1){debugger;a1=!1;let b=new mF;Dd(b.rule,b.getGroup1(),b.getGroup2(),r,s)}if(Ld===-1||a1){console.table({rule:e,group1:cw(t),group2:cw(i)}),c.clear();let b=c.initColor(zt.GREEN),v=c.initColor(zt.WHITE),E=c.initColor(zt.BLUE),T=c.initColor(zt.Gray);t.items.forEach(P=>P.items.forEach((A,C)=>{C>0?v.addPly(A):b.addPly(A)})),i.items.forEach(P=>P.items.forEach((A,C)=>{C>0?T.addPly(A):E.addPly(A)})),c.draw();debugger}}let d=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(ht).intersection1(i.bbox().extendOfSize(ht)):null;if(d){let b=[],v=[];switch(e){case 0:{for(let E of t.items)E.bbox().isIntersect(d)&&b.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}case 1:case 3:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)?v.push(E):a.push(E);break}case 2:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}default:throw new Error("not support")}b.length!==t.items.length&&(t=new zi(b)),v.length!==i.items.length&&(i=new zi(v))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(b=>a.push(b)),i.items.forEach(b=>a.push(b));break}case 2:{t.items.forEach(b=>a.push(b));break}default:throw new Error("not support")}t=new zi([]),i=new zi([])}m(t,o,!0),m(i,l,!1);let f=e===2||e===3?(b,v)=>Qe(b.getEnd(),v)?b.nextSide:b:(b,v)=>Qe(b.prevSide.getEnd(),v)?b.prevSide:b,u=(b,v,E)=>{if(Qe(b.getEnd(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&Qe(T.coord,b.getEnd()))===-1)return new ro(E,b,c)}else return new ro(E,b,c)},p=e===2||e===3?(b,v,E)=>{if(Qe(b.getStart(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&Qe(T.coord,b.getStart()))===-1)return new ro(E,b,c)}else return new ro(E,b,c)}:u;r.seek(t,i,(b,v,E,T,P,A)=>{let C=o[b][v],M=l[T][P],H=C.sides[E],k=M.sides[A],F=bn(H.getShape(),k.getShape());if((H.getShape()instanceof We||k.getShape()instanceof We)&&F>=4){if(H.getShape()instanceof Ee||k.getShape()instanceof Ee){let L=function(x,I){let S=!1;for(let D=0;D<I.length;D+=2)Qe(new be(I[D],I[D+1]),x)&&(S=!0);S||I.push(x.x,x.y)},R=[te[0],te[1]];for(let x=0;x<F;x+=2){let I=new be(te[x],te[x+1]);for(let S=x+2;S<F;S+=2){let D=new be(te[S],te[S+1]);if(!Qe(I,D)){L(D,R);break}}}F=R.length,R.forEach((x,I)=>te[I]=x)}else for(let L=F-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(Qe(new be(te[L],te[L+1]),new be(te[R],te[R+1]))){te[R]=(te[L]+te[R])/2,te[R+1]=(te[L+1]+te[R+1])/2;for(let x=F-3;x>=L;x--)te[x]=te[x+2];F-=2;break}}let j=0;if(F===4){let L=function(I){return Qe(H.getEnd(),I)||Qe(H.prevSide.getEnd(),I)||Qe(k.prevSide.getEnd(),I)||Qe(k.getEnd(),I)},R=new be(te[0],te[1]),x=()=>{let I=new ro(R,H,c),S=new ro(R,k,c);I.bind(S),I.setIsInvalid(),I.isDealed(),C.inters.push(I),M.inters.push(S)};if(te[0]===te[2]&&te[1]===te[3])if(L(R))j=2;else{x();return}}for(;j<F;j+=2){let L=new be(te[j],te[j+1]),R=H,x=k;if(Qe(R.prevSide.getEnd(),L)&&(R=R.prevSide),x=f(x,L),H!==R&&k!==x){let S=e===2||e===3?k.getEnd():x.getEnd();R.getEnd().distance1(L)<S.distance1(L)?(L=R.getEnd(),Qe(S,L)||(x=k)):(L=S,Qe(R.getEnd(),L)||(R=H))}let I=u(R,x,L);if(I){let S=p(x,R,L);S&&(R.addInter(I),C.inters.push(I),x.addInter(S),M.inters.push(S),I.bind(S),C.intersect(M,h))}}return F},s);let g=O(),_=gF(o,l,e);_.forEach(b=>!b.startAndEndIsSameOutsideFlag()&&b.reverse()),new _F(g.concat(_)).getPolygons().forEach(b=>a.push(b));let y=new zi(a);if(c){if(Ld===-1){let b=c.initColor(zt.RED),v=c.initColor(zt.Golden);a.forEach(E=>{b.addPly(E.items[0]),E.items.slice(1).forEach(T=>v.addPly(T))}),c.draw();debugger;throw new Error}y.id=Ld}return xa.BooleanTools+=$o(n),y;function m(b,v,E){b.items.forEach(T=>{let P=[];P.push(s1.build(T.items[0],E,!0,c,T)),T.items.slice(1).forEach(A=>{P.push(s1.build(A,E,!1,c))}),v.push(P)})}function O(){let b=[];return h.forEach(E=>{e===2||e===3?E.forEach(P=>{P.isGroup1||P.reverse(),P.sides.forEach(A=>A.sortInters())}):E.forEach(P=>P.sides.forEach(A=>A.sortInters())),E.map(P=>P.sides.filter(A=>A.inters.length)).flat(2).sort((P,A)=>{let C=P.inters,M=A.inters,H=Qe(C[C.length-1].coord,P.getEnd()),k=Qe(M[M.length-1].coord,A.getEnd());if(H&&k){let F=0,j=0;for(let L=C.length-2;L>=0&&Qe(C[L].coord,P.getEnd());L--)F++;for(let L=M.length-2;L>=0&&Qe(M[L].coord,A.getEnd());L--)j++;return j-F}else return H?-1:1}).forEach(P=>{P.inters.forEach(A=>{if(A.dealed)return;let C=A.side,M=A.getBindedInter().side,H;Qe(C.getEnd(),A.coord)&&Qe(M.getEnd(),A.coord)?H=-1:Qe(C.getEnd(),A.coord)?(H=1,A=A.getBindedInter()):Qe(M.getEnd(),A.coord)&&(H=1);let k=pF(H,A,e,c);A.isDealed(),k&&(C.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),T(E),e===3&&(E.forEach(P=>{P.reverse(),P.sides.forEach(A=>{A.sortInters(),A.inters.forEach(C=>{C.resetVisitStatus()})})}),T(E));function T(P){P.forEach(A=>{A.inters.forEach(C=>{if(C.isInvalid||C.getVisited())return;let M=C.findStartInter(),H=v(e)?M.run():M.getBindedInter().run(),k=A.polyline.primitives;if(H){if(k.length===H.primitives.length){let F=new Set(k);if(!H.primitives.some(j=>!F.has(j))){b.push(A);return}}b.push(s1.build(H,!0,!0,c))}})})}}),b;function v(E){switch(E){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var Ag=/\bstablilizetion\b/.test(self.location.href)||!0,Cg={intersect(e,t,i,r){try{return Dd(0,e,t,i,r)}catch(s){if(Ag){let n=new Cd().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new zi(n.map(a=>new ar(a.items)))}throw s}},union(e,t,i,r){try{return Dd(1,e,t,i,r)}catch(s){if(Ag){let n=new Cd,a=e.items.map(l=>l.items.map(h=>h)).flat(2);t.items.forEach(l=>l.items.forEach(h=>a.push(h)));let o=n.getUnion(a);return new zi(o.map(l=>new ar(l.items)))}throw s}},diff(e,t,i,r){try{return Dd(2,e,t,i,r)}catch(s){if(Ag){let n=new Cd().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new zi(n.map(a=>new ar(a.items)))}throw s}},xor(e,t,i,r){try{return Dd(3,e,t,i,r)}catch(s){if(Ag){let n=new Cd().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new zi(n.map(a=>new ar(a.items)))}throw s}}},bF=class extends kd{constructor(e,t,i,r,s,n){super(e.rule,Zg.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=s,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=n}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let s=[];r.items.forEach(n=>{let a=this.sides.length;this.addPolyline(n,t),s.push(this.sides.slice(a))}),i.push(s)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,s,n)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][s][n],l=bn(a.shape,o.shape);for(let h=0;h<l;h+=2){let c=new be(te[h],te[h+1]);a.inters.push(c),o.inters.push(c),this.event.onIntersect(c,a,o)}return l},this.bus)}},yF=class extends Bd{constructor(e){super(!!e),e&&(this.drawDebug=new qd(e),this.blueDrawing=this.drawDebug.initColor(zt.BLUE),this.greenDrawing=this.drawDebug.initColor(zt.GREEN),this.redDrawing=this.drawDebug.initColor(zt.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function o1(e,t,i,r,s){let n=Xd(),a=new yF(s);new bF(e,a,t,i,r,s).simplify();let o=[];a.plGrps.forEach(h=>{let c=h.items.map(d=>Wg(d));c[0]&&o.push(new ar(c.filter(d=>d)))});let l=new zi(o);return xa.BooleanTools+=$o(n),l}var l1=!0,Sd={intersect(e,t,i,r){try{return Cg.intersect(e,t,i,r)}catch(s){if(l1)throw s;return console.error(s),o1(Mg,e,t,i,r)}},union(e,t,i,r){try{return Cg.union(e,t,i,r)}catch(s){if(l1)throw s;return console.error(s),o1(k9,e,t,i,r)}},diff(e,t,i,r){try{return Cg.diff(e,t,i,r)}catch(s){if(l1)throw s;return console.error(s),o1(Ng,e,t,i,r)}},xor(e,t,i,r){return Cg.xor(e,t,i,r)}},vF=class{init(e){}seek(e,t,i,r){let s=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!s)return;let n=Xd(),a=[];for(let f=0,u=e.items.length;f<u;f++){let p=e.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&a.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let o=a.length;if(o===0){xa.IntersectionSeeker+=$o(n);return}let l=[];for(let f=0,u=t.items.length;f<u;f++){let p=t.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&l.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let h=l.length;if(h===0){xa.IntersectionSeeker+=$o(n);return}if(o<5||h<5){for(let f=0,u=a.length;f<u;f++)for(let p=0,g=l.length;p<g;p++)if(a[f].bbox.isIntersect(l[p].bbox.extendOfSize(1e-5))){let _=a[f],y=l[p];i(_.polygonIndex,_.polylineIndex,_.ptIndex,y.polygonIndex,y.polylineIndex,y.ptIndex)}xa.IntersectionSeeker+=$o(n);return}a.sort((f,u)=>f.bbox.minX-u.bbox.minX),l.sort((f,u)=>f.bbox.minX-u.bbox.minX);let c=0,d=0;for(;c<o&&d<h;)if(a[c].bbox.minX<l[d].bbox.minX){let f=a[c],u=f.bbox;for(let p=d;p<h;p++){let g=l[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(u.minY<_.minY?_.minY:u.minY)<(u.maxY<_.maxY?u.maxY:_.maxY)+1e-5&&i(f.polygonIndex,f.polylineIndex,f.ptIndex,g.polygonIndex,g.polylineIndex,g.ptIndex)}c++}else{let f=l[d],u=f.bbox;for(let p=c;p<o;p++){let g=a[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(_.minY<u.minY?u.minY:_.minY)<(_.maxY<u.maxY?_.maxY:u.maxY)+1e-5&&i(g.polygonIndex,g.polylineIndex,g.ptIndex,f.polygonIndex,f.polylineIndex,f.ptIndex)}d++}xa.IntersectionSeeker+=$o(n)}},Os,qr=(Os=class{static getDebug(){return Os.drawDebug||(Os.drawDebug=new qd(Os.curBus)),Os.drawDebug}static getDrawing(e=zt.GREEN){return this.getDebug().initColor(e)}static clearDrawing(){Os.getDebug().clear()}static drawText(e,t,i=zt.GREEN){Os.getDrawing(i).addText(e,t,1.5,.1,!0)}static drawBBox(e,t=zt.GREEN){if(!e)return;let i=Os.getDrawing(t),r=new ce(e.UL(),e.UR()),s=new ce(e.UR(),e.LR()),n=new ce(e.LR(),e.LL()),a=new ce(e.LL(),e.UL());i.addPt(r),i.addPt(s),i.addPt(n),i.addPt(a)}static drawPolyType(e,t){let i=Os.getDrawing(t);if(e instanceof At)i.addPly(e);else if(e instanceof ar)for(let r of e.items)r instanceof At?i.addPly(r):this.drawPolyType(r,t);else if(e instanceof zi)for(let r of e.items)this.drawPolyType(r,t)}static translate(e){switch(e){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}},Os.UseRunArrange=!0,Os.UseOptimizeSplit=!0,Os.LocalBestThread=4,Os.HandleDiff=!0,Os.OcTreeSplitStep=4,Os.PrintStart=new be(150,-200),Os),Id=class x1{static getPolyTypeLine(t){let i=[];if(t instanceof At)for(let r of t.primitives)i.push(r);else if(t instanceof ar)for(let r of t.items)if(r instanceof At)for(let s of r.primitives)i.push(s);else{let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}else if(t instanceof zi)for(let r of t.items){let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof At)i.push(t);else if(t instanceof ar)for(let r of t.items)if(r instanceof At)i.push(r);else{let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}else if(t instanceof zi)for(let r of t.items){let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}return i}static getListBBox(t){if(t.length<=0)return;let i=new Fs;for(let r of t){let s=x1.getSingleBBox(r);i.ext1(s)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new Fs,r=x1.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=qr.PrintStart){if(t.length<2)return[i,i,i];let r=5,s=10,n=t[0],a=qr.translate(n),o=[],l=i.y,h=i.x,c=i.x;i=i.add(new be(0,-s));for(let u=1;u<t.length;u++){let p=t[u];if(p instanceof Array){i=i.add(new be(r,0));let g=this.doDrawRule(p,i);o.push(g[0]),g[1].x<=h&&(h=g[1].x),g[2].x>=c&&(c=g[2].x),i=new be(g[2].x+r,i.y)}else o.push(i.clone()),i.x<=h&&(h=i.x),i.x>=c&&(c=i.x),qr.drawText(i,p.name),i=i.add(new be(r,0))}let d=0;for(let u of o)d+=u.x;let f=new be(d/o.length,i.y+s);qr.drawText(f,"N:"+a);for(let u of o){let p=new ce(u,f),g=new Array;g.push(p);let _=At.build1(f1(g));qr.drawPolyType(_,zt.GREEN)}return[f,new be(h,l),new be(c,l)]}static drawRule(t,i=qr.PrintStart,r=!1,s){qr.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,s),qr.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let s=1;s<t.length;s++){let n=t[s];if(n instanceof Array)this.doDrawRulePolygon(n,i);else{let a=i;r===2&&s===1&&(a=zt.RED),n.name&&qr.drawText(n.bbox().UL(),n.name,a),qr.drawPolyType(n,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let s of i.items)if(s.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let s of i.items)if(s.bbox().isIntersect(r)){for(let n of s.items)if(n.bbox().isIntersect(r)){for(let a of n.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},xF=class Ec{static createNode(t,i,r){let s=t.UL(),n=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,h=s.x+l*n,c=s.y-(o+1)*a,d=h+n,f=c+a;return new ss(h,d,c,f)}static ocTreeSplitNode(t,i,r,s,n=2){if(t.length<=r)return t;let a=[],o=n**2,l=new Array(o),h=new Array(o);for(let u=0;u<o;u++)l[u]=new Array(t.length),h[u]=0;let c=i.UL(),d=i.width()/n,f=i.height()/n;for(let u of t){let p=s(u).center(),g=~~((p.x-c.x)/d),_=~~((c.y-p.y)/f)*n+g;try{l[_][h[_]]=u,h[_]+=1}catch{a.push(u)}}for(let u=0;u<l.length;u++){let p=h[u];if(p<=0)continue;let g=l[u].slice(0,p);if(g.length===t.length)return t;let _=Ec.createNode(i,n,u),y=Ec.ocTreeSplitNode(g,_,r,s,n);if(y.length===t.length)return t;a.push(y)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,s){let n=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),h=i.width()/(a+1),c=i.height()/(a+1),d=-(2**32),f=[],u=[];for(let p=1;p<=a;p++)for(let g=1;g<=a;g++){let _=o.x+h*p,y=o.y+c*g,m=[[],[],[],[]],O=new Array(4),b=new Array(4);b[0]=new ss(o.x,_,y,l.y),b[1]=new ss(_,l.x,y,l.y),b[2]=new ss(o.x,_,o.y,y),b[3]=new ss(_,l.x,o.y,y);for(let P of t){let A=s(P).center(),C=-1,M=-1;A.x===_?C=Math.random()>=.5?1:-1:A.x>_?C=1:A.x<_&&(C=-1),A.y===y?M=Math.random()>=.5?1:-1:A.y>y?M=1:A.y<y&&(M=-1),C===1&&M===1?m[1].push(P):C===1&&M===-1?m[3].push(P):C===-1&&M===-1?m[2].push(P):C===-1&&M===1&&m[0].push(P)}for(let P=0;P<4;P++){let A=m[P];if(A.length<=0)continue;let C=new Fs;for(let M of A)C.ext1(s(M));O[P]=C.build1()}let v=0,E=0;for(let P of O)P&&(v+=P.area());E=v;let T=(P,A)=>{if(!O[P]||!O[A])return 0;let C=O[P].intersection1(O[A]);return C?C.area():0};E-=T(0,1),E-=T(0,2),E-=T(0,3),E-=T(1,2),E-=T(1,3),E-=T(2,3),E/v>=d&&(f=m,u=b)}for(let p=0;p<f.length;p++){let g=f[p];if(g.length<=0)continue;let _=u[p],y;if(g.length===t.length?y=Ec.ocTreeSplitNode(g,_,r,s):y=Ec.ocTreeSplitNodeMinIntersect(g,_,r,s),y.length===t.length)return t;n.push(y)}return n}static ocTreeSplit(t,i,r,s){return Ec.ocTreeSplitNode(t,i,r,s,qr.OcTreeSplitStep)}},EF=class zw{static simplifyRules(t,i){return qr.UseOptimizeSplit&&(t=this.optimizeSplit(t,i)),t}static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=qr.LocalBestThread+1)return t;let r=t.slice(1),s=new Array(r.length);for(let h=1;h<t.length;h++)s[h-1]=h;let n=Id.getListBBox(r),a=xF.ocTreeSplit(s,n,qr.LocalBestThread,h=>{let c=t[h];return Id.getSingleBBox(c)}),o=(h,c)=>{if(!(h.length<=0))for(let d of h)if(Array.isArray(d)){let f=[c[0]];o(d,f),c.push(f)}else{let f=t[d];c.push(f)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(qr.HandleDiff){let n=t[1],a;if(Array.isArray(n)){let o=this.optimizeSplit(n,i);if(o.length<=1)return[2];a=E1(o,i)}else a=E1([2,n],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let h=t[l];if(Array.isArray(h)){let c=Id.getListBBox([...h.slice(1)]);Id.KeepBBoxPolygonGroup(c,a)&&o.push(h)}else Id.KeepBBoxPolygonGroup(h.bbox(),a)&&o.push(h)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let n=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,n,...o.slice(1)]:n}}else if(r===1){if(t.length-1>qr.LocalBestThread){let n=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){n=!0;break}}n&&(t=zw.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let s=[r];for(let n=1;n<t.length;n++){let a=t[n];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;s.push(o)}else s.push(a)}return s}},wF=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(wF||{});function Rd(e){let t=e[0],i=[t];switch(t){case 0:for(let s=1;s<e.length;s++){let n=e[s];if(Array.isArray(n)&&(n=Rd(n),!n))return null;i.push(n)}break;case 1:case 3:for(let s=1;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=Rd(n),!n)||i.push(n)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=Rd(r)),!r)return null;i.push(r);for(let s=2;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=Rd(n),!n)||i.push(n)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i}function h1(e,t,i){return Array.isArray(e)?Hw(e,t,i):e}function c1(e,t,i,r,s=!0){if(s)for(;e.length>1;){let n,a=[];for(e.length%2===1?(a.push(e[0]),n=1):n=0;n<e.length;n+=2)a.push(t(e[n],e[n+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function Hw(e,t,i,r=!0){let s=new Array(e.length-1);for(let n=1;n<e.length;n++)s[n-1]=h1(e[n],t,i);switch(e[0]){case 0:return c1(s,Sd.intersect,t,i);case 1:return c1(s,Sd.union,t,i);case 2:let n=c1(s.slice(1),Sd.union,t,i);return n?Sd.diff(s[0],n,t,i):s[0];case 3:let a=h1(e[1],t,i);for(let o=2;o<e.length;o++)a=Sd.xor(a,h1(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function jw(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let s=jw(r);Array.isArray(s)?s.length>1&&t.push(s):t.push(s)}else{let s=Wg(r);s!==null&&t.push(zi.build(s))}}return t}function TF(e,t){qr.curBus=t,e=jw(e);let i;return qr.UseRunArrange?i=EF.simplifyRules(e,t):i=Rd(e),i.length<=1?new zi([]):E1(i,t)}function E1(e,t,i=!0){if(!e||e.length===1)return new zi([]);let r=e,s=new vF,n=[];function a(o){for(let l=1;l<o.length;l++){let h=o[l];Array.isArray(h)?a(h):n.push(h)}}return a(r),s.init(n),Hw(r,s,t,i)}var Lg=new Error("list is empty"),Dg=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},SF=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},IF=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},PF=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw Lg;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw Lg;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new Dg(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new Dg(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw Lg;return this.first.item}getLast(){if(this.last===null)throw Lg;return this.last.item}insertAfter(e,t){let i=new Dg(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new Dg(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new SF(this.first)}listIterator(){return new IF(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},kg=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>Qe(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let s=i.coord,n=lt(e,s),a=lt(i.side.getShape(),s),o=lt(r.side.getShape(),s);return n.dot(a)>n.dot(o)?i:r},void 0)}getEntryInter(){}},u1=0;function Vw(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof Ee&&Math.abs(i.sweepAngle)===360)return[e];let r=Xd();u1++;let s,n=kF(e);if(n.length===0)return[];let a=LF(n);if(u1===-1){s=new qd(t);let c=s.initColor(zt.BLUE);n.forEach(f=>c.addPt(f.getShape()));let d=s.initColor(zt.GREEN);a.forEach(f=>d.addPoint(f.coord)),s.draw();debugger;throw new Error}if(a.length===0)return[At.build7(n.map(c=>c.getShape()))];DF(a);let o=[],l=!1;try{MF(a,s)}catch(c){c.customType==="IS_OVERLAP"?(l=!0,o=new Cd().getUnion([e]).map(d=>d.items).flat(2)):console.error(c)}if(l)return o;let h=NF(a);if(!h.length)return[At.build7(n.map(c=>c.getShape()))];if(o=AF(h,s),o.length===0)return console.warn("=====deSelfIntersection=====",u1),[];if(s)throw o.forEach(c=>{s.initColor(zt.WHITE).addPly(c),s.draw();debugger}),new Error;return xa.deSelfIntersection+=$o(r),o}function AF(e,t){let i=[];return e.forEach(r=>{let s=r;r.inters.forEach(n=>{if(n.getVisited())return;let a=[],o=[],l;if(t){debugger;let c=t.initColor(zt.RED);l=d=>{a.push(d),c.addPt(a[a.length-1]),t.draw();debugger}}else l=c=>a.push(c);do{let c=function(g,_){Te.eq(g.distance2(_),0)||l(Yw(u.getShape(),g,_))},d=o.findIndex(g=>g===n.group);if(d!==-1){let g=a.findIndex(m=>m===n.group),_=a.splice(g).filter(m=>!(m instanceof kg));if(_.length){let m=el(At.build7(_));m&&i.push(m)}let y=a.filter(m=>!(m instanceof kg));if(n=o[d].getOutInter(y[y.length-1]),o.splice(d),!n)throw Error("interGroup not hav inter!!!2");continue}n.visitSelf(),o.push(n.group),a.push(n.group);let f=n.getIndex(),u=n.side,p=u.inters[f+1];for(;p!=null&&p.isInvalid||p&&p.group===n.group;)p=u.inters[p.getIndex()+1];if(p){c(n.coord,p.coord);let g=p.getBindedInter();if(n=g.getVisited()?g.group.getOutInter(g.side.getShape()):g,!n){if(p.group===s)break;throw new Error("interGroup not hav inter!!!3")}}else{for(c(n.coord,u.getEnd()),u=u.nextSide,n=null;;){for(let g of u.inters)if(!g.isInvalid){let _=g.group.getOutInter(u.getShape());if(!_){if(g.group===s){n=g;break}else if(g.getBindedInter().group===s){n=g.getBindedInter();break}continue}n=_;break}if(n)break;l(u.getShape()),u=u.nextSide}Te.eq(u.getEnd().distance2(n.coord),0)?l(u.getShape()):c(u.getStart(),n.coord)}}while(n.group!==s);let h=el(At.build7(a.filter(c=>!(c instanceof kg))));h&&i.push(h)})}),i}function CF(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function LF(e){let t=[],i=new PF;for(let r of e.slice().sort((s,n)=>s.bbox().minY-n.bbox().minY)){for(let s of CF(i.listIterator())){let n=s.item;if(n.bbox().maxY<r.bbox().minY)i.remove(s);else{let a=function(f,u){let p=new ro(u,f,null);return f.inters.push(p),t.push(p),p},o=function(f,u){let p=f.getEnd(),g=new be(te[0],te[1]),_=new be(te[2],te[3]),y=p.distance2(g)>p.distance2(_)?g:_,m=f.prevSide;a(Qe(m.getEnd(),y)?m:f,y).bind(a(u,y))},l=n.getShape(),h=r.getShape(),c=bn(l,h),d=c===4&&te[0]===te[2]&&te[1]===te[3];if(d&&(c-=2),n.nextSide===r)n.prevSide!==r&&c===4&&o(n,r);else if(n.prevSide===r)c===4&&o(r,n);else if(c!==0){let f=function(p,g){let _=p.prevSide;return a(Qe(_.getEnd(),g)?_:p,g)},u=new be(te[0],te[1]);if(d&&!Qe(u,n.prevSide.getEnd())&&!Qe(u,r.prevSide.getEnd())&&lt(l,u).dot(lt(h,u))>0)continue;for(let p=0;p<c;p+=2){let g=new be(te[p],te[p+1]);f(n,g).bind(f(r,g))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function DF(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!Qe(t.coord,i))return;let r=t.side.inters,s=t.getBindedInter().side;for(let n=r.length-1;n>=0;n--){let a=r[n];if(!Qe(a.coord,i))break;a!==t&&a.getBindedInter().side===s&&a.setIsInvalid()}})}function RF(e){let t=new Ud(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function NF(e){let t=[],i=RF(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let s=i.search(r.bbox().extendOfSize(Te.eps)).filter(n=>!n.group);if(s.length){let n=new Set,a=new kg(s);s.forEach(o=>{o.group=a,n.has(o.side)&&o.visitSelf(),n.add(o.side)}),t.push(a)}}),t}function MF(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,s=i.getBindedInter().side,n;Qe(r.getEnd(),i.coord)&&Qe(s.getEnd(),i.coord)?n=-1:Qe(r.getEnd(),i.coord)?r.nextSide!==s&&(n=1,i=i.getBindedInter()):Qe(s.getEnd(),i.coord)&&s.nextSide!==r&&(n=1),BF(n,i,t),i.isDealed()})}function BF(e,t,i){let r=t.getBindedInter(),s=t.side,n=r.side,a=s.getShape(),o=n.getShape(),l=1,h=!1;if(e===-1){if(Oc(a.reverse(),o.reverse())||Oc(s.nextSide.getShape(),n.nextSide.getShape())){let d=to(s,s.nextSide,n,r,l,h,i);if(d.state===2){let u=new Error("info1.state === InState.IS_OVERLAP");throw u.customType="IS_OVERLAP",u}let f=to(s,s.nextSide,n.nextSide,r,l,h,i);d.state===f.state&&c(d,f)}else if(!(Oc(a.reverse(),n.nextSide.getShape())||Oc(s.nextSide.getShape(),o.reverse()))){let d=i1(s,s.nextSide,n,!1,i);d===i1(s,s.nextSide,n.nextSide,!0,i)&&d!==i1(n,n.nextSide,s.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let d=function(f,u){return lt(f,u.start()).dot(lt(u,u.start()))>0};if(Oc(a.reverse(),o.reverse())||Oc(a,n.nextSide.getShape())){let f=en(s,n,r,i,l,h,new Map);if(f.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let u=en(s,n.nextSide,r,i,l,h,new Map);f.state===u.state&&c(f,u)}else if(d(a.reverse(),o.reverse())&&d(a,n.nextSide.getShape())){let f=wr(s,n,!1,i);f===wr(s,n.nextSide,!0,i)&&f!==$l(n,n.nextSide,new Wd(Yw(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function c(d,f){d.inter.setIsInvalid(),f.inter.setIsInvalid(),t.setIsInvalid()}}function Yw(e,t,i){if(e instanceof ce||t.distance2(i)<1e-6)return new ce(t,i);if(e instanceof Ee)return Ee.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof We){let r=e.getPercent(t,ht),s=e.getPercent(i,ht);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function kF(e){let t=el(e);if(!t)return[];let i=t.primitives.map(s=>new Wd(s,null)),r=i[i.length-1];return i.forEach(s=>{r.connect(s),r=s}),i}var yc,FF=(yc=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new qd(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(zt.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(zt.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof Ee?i=Ee.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new ce(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,s=Math.sqrt(i**2+r**2)+t;return[Ee.buildCircle(e.center(),s)]}static getExtendPolyLine(e,t,i=!0,r){var s,n;if(!((s=e==null?void 0:e.primitives)!=null&&s.length))return[];let a=el(e);if(!((n=a==null?void 0:a.primitives)!=null&&n.length)){if(this.isExpansion){let l=[1],h=t*2;e.primitives.forEach(d=>l.push(d.stroke(h,1,0)));let c=TF(l,r);if(c.items.length!==1)throw new Error("group.items.length !== 1 ");return[c.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.isExpansion=t>0,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(zt.BLUE);this.rawOffsetPrimitive.forEach(h=>l.addPt(h)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[At.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(zt.RED);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(zt.GREEN);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let s=!0,n=e[r].primitives;e:for(let a=0;a<n.length;a+=1){let o=n[a],l;if(o instanceof Ee)l=o.midPoint;else if(o instanceof ce)l=o.start();else throw new Error("not support!");for(let h=0;h<this.originalPrimitive.length;h+=1){let c=this.originalPrimitive[h],d;if(c instanceof Ee?d=this.pointArcClosest(l,c):d=b9(l,c.start(),c.end()).d,i-d>.01){s=!1;break e}}}s&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new be(te[i],te[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let n=e.sub(i);return Math.abs(n.length()-t.rx)}let r=e.distance2(t.start()),s=e.distance2(t.end());return Te.less(r,s)?Math.sqrt(r):Math.sqrt(s)}static createClippingEdge(e){let t=[],i=[],r=Vw(At.build2(this.rawOffsetPrimitive),e);r.forEach(n=>{let a=n.area(.01);t.push(a)});let s=Math.min(...t.filter(n=>n<0));for(let n=0;n<t.length;n+=1){let a=t[n];Te.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[n]===s||a>0))&&i.push(r[n])}return i}static createOffsetEdge(e){if(e instanceof Ee)return e.panDistance1(this.offsetDistance);if(e instanceof ce)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof ce&&t.offsetEdge instanceof ce?this.lineToLineConnect(e,t):e.offsetEdge instanceof Ee&&t.offsetEdge instanceof Ee?this.arcToArcConnect(e,t):e.offsetEdge instanceof ce&&t.offsetEdge instanceof Ee?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=t.index,n=this.originalPrimitive[s].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(n,i,r);else{let a=this.getLineToLineT(i,r),o=a[0],l=a[1];if(this.isFalseIntersection(o)||this.isFalseIntersection(l))o>1&&this.isFalseIntersection(l)?this.lineToLineUseArcToConnect(n,i,r):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(o)&&!this.isFalseIntersection(l)){let h=i.end().sub(i.start()),c=i.start().add(h.mul(o)),d=new ce(i.start(),c);this.rawOffsetPrimitive.push(d);let f=new ce(c,r.end());this.updateNextOffsetPrimitive(s,f)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new ce(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i){let r=this.getSweep(e,t),s=this.getSweepAngel(t.end(),i.start(),e,r);if(s===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let n=Ee.build5(t.end(),i.start(),s);this.rawOffsetPrimitive.push(n)}static getSweep(e,t,i){let r=null,s=i||i===0?this.originalPrimitive[i]:t;if(s instanceof Ee){let n=s.center.sub(s.end()).normalize();s.isCCW?r=new be(n.y,-n.x):r=new be(-n.y,n.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),s=i.cross(r),n=t.start().sub(e.start()),a=e.start().sub(t.start()),o=n.cross(r)/s,l=a.cross(i)/-s;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.lineAndArcConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static lineAndArcConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new ce(e.start(),r);this.rawOffsetPrimitive.push(l);let h;!t.center.equals1(r)||t.sweepAngle>1e-4?(h=Ee.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),h instanceof Ee&&h.sweepAngle===0&&(h=new ce(h.start(),h.end()))):h=new ce(t.center,r),this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static lineAndArcUseArcConnect(e,t,i,r){let s=this.getSweep(e,t,r),n=this.getSweepAngel(t.end(),i.start(),e,s);if(n===0){this.useLineToConnect(t,i);return}let a=Ee.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new ce(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new ce(e.start(),r):(l=Ee.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof Ee&&l.sweepAngle===0&&(l=new ce(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let h=new ce(r,t.end());this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static isTrueArcIntersection(e,t){return Wi(e,t)}static getSweepAngel(e,t,i,r){let s=e.angleD(i),n=t.angleD(i),a;return s===n?a=0:(s=gt.regularD(s),n=gt.regularD(n),r===1?n<=s&&(n+=360):n>=s&&(s+=360),a=n-s),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=_9(t,e);if(r){i.intersectionNum=r/2;for(let s=0;s<r-1;s+=2){let n=new be(te[s],te[s+1]);i.points.push(n),n.sub(e.start()).x<1e-4||n.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(n.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.arcToLineConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=ww(i,r);if(s){let n=this.getInters(s),a;if(n.length===2){let h=this.originalPrimitive[t.index].start(),c=n[0],d=n[1],f=c.distance2(h),u=d.distance2(h);f<u?a=c:a=d}else a=n[0];let o,l;a.equals1(i.center)?o=new ce(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new ce(i.start(),a):(o=Ee.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof Ee&&o.sweepAngle===0&&(o=new ce(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new ce(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new ce(a,r.end()):(l=Ee.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof Ee&&l.sweepAngle===0&&(l=new ce(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let n=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(n.sweep()),l=this.rxChangeStatus(a.sweep()),h=this.originalPrimitive[t.index].start(),c=this.getSweep(h,i,e.index),d=Math.abs(this.offsetDistance),f=Ee.build2(h,o?n.endAngle():n.endAngle()+180,l?a.startAngle:a.startAngle+180,d,d,c);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(f)}}},yc.originalPrimitive=[],yc.offsetPrimitive=[],yc.rawOffsetPrimitive=[],yc.testI=0,yc),UF=class Nd extends Vd{constructor(t,i,r,s,n,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=s,this.isCCW=n,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new be(this.radius,0).multiply3(er.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new be(0,-this.height/2).multiply3(er.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new be(this.width,-this.height/2).multiply3(er.rotateD(this.angle)))}extend(t){return new Nd(this.leftUpPoint.add(new be(-t,t).rotateD(be.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=er.rotateD(this.angle),{leftUpPoint:i,width:r,height:s,radius:n}=this,a=i.add(new be(n,-n).multiply3(t)),o=i.add(new be(n,n-s).multiply3(t)),l=i.add(new be(r-n,-n).multiply3(t)),h=i.add(new be(r-n,n-s).multiply3(t));return new ss(Math.min(a.x,o.x,l.x,h.x)-n,Math.max(a.x,o.x,l.x,h.x)+n,Math.min(a.y,o.y,l.y,h.y)-n,Math.max(a.y,o.y,l.y,h.y)+n)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:s,radius:n}=this;if(n===0){let o=be.ORIGIN,l=new be(r,0),h=new be(r,-s),c=new be(0,-s);t.push(new ce(o,l),new ce(l,h),new ce(h,c),new ce(c,o))}else{let o=new be(0,-n),l=new be(n,0),h=new be(r-n,0),c=new be(r,-n),d=new be(r,n-s),f=new be(r-n,-s),u=new be(n,-s),p=new be(0,n-s);t.push(Ee.build1(o,l,n,n,!1,0),new ce(l,h),Ee.build1(h,c,n,n,!1,0),new ce(c,d),Ee.build1(d,f,n,n,!1,0),new ce(f,u),Ee.build1(u,p,n,n,!1,0),new ce(p,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=er.rotateD(this.angle).translate1(i);return At.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new be(this.width,0).multiply3(er.rotateD(this.angle)).multiply3(t),s=new be(0,-this.height).multiply3(er.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new Nd(i,s.length(),r.length(),s.angleD(be.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new Nd(i,r.length(),s.length(),r.angleD(be.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new Nd(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let s=this.stroke1(t,i,r);if(s.length===1)return s[0];{let[n,a]=s;return At.build2(n.primitives.concat(new ce(n.primitives[0].start(),a.primitives[0].start()),a.primitives,new ce(a.primitives[0].start(),n.primitives[0].start())))}}stroke1(t,i,r){let s=r===this.isCCW?this:this.reverse(),n=t/2,a=Math.min(s.width,s.height)/2,o=s.extend(n).toPolyline();return a<=n?[o]:[o,s.extend(-n).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,s=>r.push(s)),r}toBezier(){throw new Error("Method not implemented.")}},GF=.01,ar=class Gn{static simplify(t){return t=el(t),t?new Gn([t]):null}static buildByStroke(t,i,r=1,s=C1,n){if(t instanceof Ee&&(t.rx<i/2+GF||Math.abs(t.sweepAngle)>180&&Te.lesseq(t.start().distance1(t.end()),i))){let o=Vw(t.stroke(i,r,0),n);if(o.length===0)return null;if(o.length===1)return new Gn(o);let l=[null],h=Number.POSITIVE_INFINITY;return o.forEach(c=>{let d=c.area(.1);d<0?d<h&&(l[0]=c,h=d):l.push(c)}),new Gn(l)}else if(t instanceof UF){let o=t.stroke1(i,r,0).map(l=>el(l));return o[0]?o[1]?new Gn(o):new Gn([o[0]]):null}let a=t.stroke(i,r,0,s);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(At.build7([Ee.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(At.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Gn(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Gn?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new zi([this]);let r=this.items[0],s=[];for(let c of r.primitives)if(c instanceof ce)s.push(c);else if(c instanceof Ee&&c.rx===c.ry)a(c);else if(c instanceof We)n(c);else throw new Error("not support!");r=At.build7(s);function n(c){let d=c.points(.1);for(let f=0;f<d.length-1;f++){let u=d[f],p=d[f+1];s.push(new ce(u,p))}}function a(c){if(Math.abs(c.sweepAngle)>270){let d=c.sweepAngle/2;a(Ee.build3(c.center,c.startAngle,d,c.rx,c.ry)),a(Ee.build3(c.center,c.startAngle+d,d,c.rx,c.ry))}else s.push(c)}let o=[],l=[];FF.getExtendPolyLine(r,t,!0,i).forEach(c=>{(c.area(.1)>0?l:o).push(c)});let h;if(o.length===1)l.forEach(c=>o.push(c)),h=new zi([new Gn(o)]);else if(o.length===0)console.warn("outlines.length === 0"),h=new zi([]);else if(l.length===0)h=new zi(o.map(c=>new Gn([c])));else{let c=o.map(d=>[d]);l.forEach(d=>{let f=[],u=d.bbox();if(c.forEach(p=>{p[0].bbox().isContainsBBox1(u)&&f.push(p)}),f.length===1)f[0].push(d);else{if(f.length===0)throw new Error("inPlsArr.length === 0");for(let p of f.sort((g,_)=>g[0].bbox().area()-_[0].bbox().area()))if(p[0].getWindingNum(d.start())===-1){p.push(d);break}}}),h=new zi(c.map(d=>new Gn(d)))}return h}toPolylineGroup(){return new L1(this.items)}},zF=(e=>(e[e.POLYGON=1]="POLYGON",e[e.POLYLINE=2]="POLYLINE",e[e.LINE=3]="LINE",e[e.ARC=4]="ARC",e[e.BEZIER2=5]="BEZIER2",e[e.BEZIER3=6]="BEZIER3",e[e.BOOLEAN_OUTPUT=7]="BOOLEAN_OUTPUT",e[e.BOOLEAN_INTERSECTION=8]="BOOLEAN_INTERSECTION",e[e.BOOLEAN_UNION=9]="BOOLEAN_UNION",e[e.BOOLEAN_DIFF=10]="BOOLEAN_DIFF",e[e.BOOLEAN_RESULT=11]="BOOLEAN_RESULT",e[e.LINES=12]="LINES",e[e.ARCS=13]="ARCS",e[e.BEZIER2S=14]="BEZIER2S",e[e.BEZIER3S=15]="BEZIER3S",e[e.CIRCLE_CW=16]="CIRCLE_CW",e[e.CIRCLE_CCW=17]="CIRCLE_CCW",e[e.POLYGON_GROUP=18]="POLYGON_GROUP",e))(zF||{});var d1=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}},HF=/(\.?0+)$/,w1=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 100:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(d1.lpad((n|0).toString(10),"0",d)),r=0;else return l}else return l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(d1.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(d1.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static fmtNumber(e){return e.toFixed(5).replace(HF,"")}};function jF(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var VF=(e,t)=>{e===3?console.error(...t):e===2?console.warn(...t):console.log(...t)},YF=(e,t)=>[jF(e)].concat(t),dw=class T1{static mix(...t){return new T1(0,(i,r)=>{for(let s of t)s.write(i,r)},(i,r)=>r)}constructor(t,i=VF,r=YF){this.level=t,this.writer=i,this.fmt=r}setLevel(t){this.level=t}prepend(t=null,i=null){let r=t===null?this.fmt:(n,a)=>(a=t(n,a),this.fmt(n,a)),s=i===null?this.writer:(n,a)=>{i(n,a),this.writer(n,a)};return new T1(this.level,s,r)}chain(t){return t.prepend(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}formatWrite(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[w1.format(i,...r)]))}write(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,[w1.format(i,...r)]))}debug3(t,...i){this.write3(0,t,i)}warning3(t,...i){this.write3(2,t,i)}debugFmt(t,...i){this.formatWrite(0,t,i)}debug(...t){this.write(0,t)}infoFmt(t,...i){this.formatWrite(1,t,i)}info(...t){this.write(1,t)}warningFmt(t,...i){this.formatWrite(2,t,i)}warning(...t){this.write(2,t)}errorFmt(t,...i){this.formatWrite(3,t,i)}error(...t){this.write(3,t)}};dw.DUMMY=new dw(4);var Bee=String.fromCharCode;var qF=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.NUMBER_INTEGER=1]="NUMBER_INTEGER",e[e.NUMBER_DECIMAL=2]="NUMBER_DECIMAL",e[e.NUMBER_E=3]="NUMBER_E",e[e.NUMBER_E_SIGNED=4]="NUMBER_E_SIGNED",e))(qF||{}),WF=(e=>(e[e.UNKNOW=0]="UNKNOW",e[e.MOVE_X=1]="MOVE_X",e[e.MOVE_Y=2]="MOVE_Y",e[e.LINE_X=3]="LINE_X",e[e.LINE_Y=4]="LINE_Y",e[e.HORIZONTAL_X=5]="HORIZONTAL_X",e[e.VERTICAL_Y=6]="VERTICAL_Y",e[e.CUBIC_BEZIER_X1=7]="CUBIC_BEZIER_X1",e[e.CUBIC_BEZIER_Y1=8]="CUBIC_BEZIER_Y1",e[e.CUBIC_BEZIER_X2=9]="CUBIC_BEZIER_X2",e[e.CUBIC_BEZIER_Y2=10]="CUBIC_BEZIER_Y2",e[e.CUBIC_BEZIER_X=11]="CUBIC_BEZIER_X",e[e.CUBIC_BEZIER_Y=12]="CUBIC_BEZIER_Y",e[e.ARC_RX=13]="ARC_RX",e[e.ARC_RY=14]="ARC_RY",e[e.ARC_ROTATION=15]="ARC_ROTATION",e[e.ARC_LARGE=16]="ARC_LARGE",e[e.ARC_SWEEP=17]="ARC_SWEEP",e[e.ARC_X=18]="ARC_X",e[e.ARC_Y=19]="ARC_Y",e[e.SMOOTH_CUBIC_BEZIER_X2=20]="SMOOTH_CUBIC_BEZIER_X2",e[e.SMOOTH_CUBIC_BEZIER_Y2=21]="SMOOTH_CUBIC_BEZIER_Y2",e[e.SMOOTH_CUBIC_BEZIER_X=22]="SMOOTH_CUBIC_BEZIER_X",e[e.SMOOTH_CUBIC_BEZIER_Y=23]="SMOOTH_CUBIC_BEZIER_Y",e[e.QUADRATIC_BEZIER_X1=24]="QUADRATIC_BEZIER_X1",e[e.QUADRATIC_BEZIER_Y1=25]="QUADRATIC_BEZIER_Y1",e[e.QUADRATIC_BEZIER_X=26]="QUADRATIC_BEZIER_X",e[e.QUADRATIC_BEZIER_Y=27]="QUADRATIC_BEZIER_Y",e))(WF||{});var kee=w1.fmtNumber;var XF=class{constructor(){}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodePadNet(e){let t=JSON.stringify(["PAD_NET",e.componentId,e.padNum,e.padId||""]),i={...e};return delete i.componentId,delete i.padNum,delete i.padId,{id:t,dataType:"PAD_NET",data:JSON.stringify(i)}}encodeComponent(e,t){return{id:e,dataType:"COMPONENT",data:JSON.stringify(t)}}encodePanelize(e){return{id:"PANELIZE",dataType:"PANELIZE",data:JSON.stringify(e)}}encodeRuleSelector(e){let t=JSON.stringify(["RULE_SELECTOR",e.ruleSelect]),i={...e};return delete i.ruleSelect,{id:t,dataType:"RULE_SELECTOR",data:JSON.stringify(i)}}encodeRule(e){let t=JSON.stringify(["RULE",e.ruleType,e.ruleName]),i={...e};return delete i.ruleType,delete i.ruleName,{id:t,dataType:"RULE",data:JSON.stringify(i)}}encodeRuleTemplate(e){return{id:"RULE_TEMPLATE",dataType:"RULE_TEMPLATE",data:JSON.stringify(e)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeBoss(e,t){return{id:e,dataType:"BOSS",data:JSON.stringify(t)}}encodeShellEntity(e,t){return{id:e,dataType:"SHELL_ENTITY",data:JSON.stringify(t)}}encodeShellCut(e,t){return{id:e,dataType:"SHELLCUT",data:JSON.stringify(t)}}encodeCrease(e,t){return{id:e,dataType:"CREASE",data:JSON.stringify(t)}}encodeShell(e,t){return{id:e,dataType:"SHELL",data:JSON.stringify(t)}}encodeFpcFill(e,t){return{id:e,dataType:"FPC_FILL",data:JSON.stringify(t)}}encodeTeardrop(e,t){return{id:e,dataType:"TEARDROP",data:JSON.stringify(t)}}encodeImage(e,t){return{id:e,dataType:"IMAGE",data:JSON.stringify(t)}}encodePoured(e,t){return{id:pr(e,"POURED"),dataType:"POURED",data:JSON.stringify(t)}}encodePour(e,t){return{id:e,dataType:"POUR",data:JSON.stringify(t)}}encodeRegion(e,t){return{id:e,dataType:"REGION",data:JSON.stringify(t)}}encodeFill(e,t){return{id:e,dataType:"FILL",data:JSON.stringify(t)}}encodeLayerFill(e,t){return{id:pr(e,"LAYER_FILL"),dataType:"LAYER_FILL",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeEQLenGrp(e,t){return{id:e,dataType:"EQLEN_GRP",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeLine(e,t){return{id:e,dataType:"LINE",data:JSON.stringify(t)}}encodePad(e,t){return{id:e,dataType:"PAD",data:JSON.stringify(t)}}encodeVia(e,t){return{id:e,dataType:"VIA",data:JSON.stringify(t)}}encodePreference(e){return{id:"PREFERENCE",dataType:"PREFERENCE",data:JSON.stringify(e)}}encodeSilkOpts(e,t){return{id:pr(e,"SILK_OPTS"),dataType:"SILK_OPTS",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodePrimitive(e,t){return{id:pr(e,"PRIMITIVE"),dataType:"PRIMITIVE",data:JSON.stringify(t)}}encodeNet(e,t){return{id:pr(e,"NET"),dataType:"NET",data:JSON.stringify(t)}}encodePartition(e,t){return{id:e,dataType:"PARTITION",data:JSON.stringify(t)}}encodeActiveLayer(e){return{id:"ACTIVE_LAYER",dataType:"ACTIVE_LAYER",data:JSON.stringify(e)}}encodeLayerPhys(e,t){return{id:pr(e,"LAYER_PHYS"),dataType:"LAYER_PHYS",data:JSON.stringify(t)}}encodeLayer(e,t){return{id:pr(e,"LAYER"),dataType:"LAYER",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}},JF=class{constructor(){}encodeString(e,t){return{id:e,dataType:"STRING",data:JSON.stringify(t)}}encodeAttr(e,t){return{id:e,dataType:"ATTR",data:JSON.stringify(t)}}encodePanelize(e){return{id:"PANELIZE",dataType:"PANELIZE",data:JSON.stringify(e)}}encodeRuleSelector(e){let t=JSON.stringify(["RULE_SELECTOR",e.ruleSelect]),i={...e};return delete i.ruleSelect,{id:t,dataType:"RULE_SELECTOR",data:JSON.stringify(i)}}encodeRule(e){let t=JSON.stringify(["RULE",e.ruleType,e.ruleName]),i={...e};return delete i.ruleType,delete i.ruleName,{id:t,dataType:"RULE",data:JSON.stringify(i)}}encodeRuleTemplate(e){return{id:"RULE_TEMPLATE",dataType:"RULE_TEMPLATE",data:JSON.stringify(e)}}encodeDimension(e,t){return{id:e,dataType:"DIMENSION",data:JSON.stringify(t)}}encodeBoss(e,t){return{id:e,dataType:"BOSS",data:JSON.stringify(t)}}encodeShellEntity(e,t){return{id:e,dataType:"SHELL_ENTITY",data:JSON.stringify(t)}}encodeShellCut(e,t){return{id:e,dataType:"SHELLCUT",data:JSON.stringify(t)}}encodeCrease(e,t){return{id:e,dataType:"CREASE",data:JSON.stringify(t)}}encodeShell(e,t){return{id:e,dataType:"SHELL",data:JSON.stringify(t)}}encodeFpcFill(e,t){return{id:e,dataType:"FPC_FILL",data:JSON.stringify(t)}}encodeTeardrop(e,t){return{id:e,dataType:"TEARDROP",data:JSON.stringify(t)}}encodeImage(e,t){return{id:e,dataType:"IMAGE",data:JSON.stringify(t)}}encodePoured(e,t){return{id:pr(e,"POURED"),dataType:"POURED",data:JSON.stringify(t)}}encodePour(e,t){return{id:e,dataType:"POUR",data:JSON.stringify(t)}}encodeRegion(e,t){return{id:e,dataType:"REGION",data:JSON.stringify(t)}}encodeFill(e,t){return{id:e,dataType:"FILL",data:JSON.stringify(t)}}encodeLayerFill(e,t){return{id:pr(e,"LAYER_FILL"),dataType:"LAYER_FILL",data:JSON.stringify(t)}}encodePoly(e,t){return{id:e,dataType:"POLY",data:JSON.stringify(t)}}encodeEQLenGrp(e,t){return{id:e,dataType:"EQLEN_GRP",data:JSON.stringify(t)}}encodeObj(e,t){return{id:e,dataType:"OBJ",data:JSON.stringify(t)}}encodeArc(e,t){return{id:e,dataType:"ARC",data:JSON.stringify(t)}}encodeLine(e,t){return{id:e,dataType:"LINE",data:JSON.stringify(t)}}encodePad(e,t){return{id:e,dataType:"PAD",data:JSON.stringify(t)}}encodeVia(e,t){return{id:e,dataType:"VIA",data:JSON.stringify(t)}}encodePreference(e){return{id:"PREFERENCE",dataType:"PREFERENCE",data:JSON.stringify(e)}}encodeSilkOpts(e,t){return{id:pr(e,"SILK_OPTS"),dataType:"SILK_OPTS",data:JSON.stringify(t)}}encodeGroup(e,t){return{id:e,dataType:"GROUP",data:JSON.stringify(t)}}encodePrimitive(e,t){return{id:pr(e,"PRIMITIVE"),dataType:"PRIMITIVE",data:JSON.stringify(t)}}encodeNet(e,t){return{id:pr(e,"NET"),dataType:"NET",data:JSON.stringify(t)}}encodeActiveLayer(e){return{id:"ACTIVE_LAYER",dataType:"ACTIVE_LAYER",data:JSON.stringify(e)}}encodeLayerPhys(e,t){return{id:pr(e,"LAYER_PHYS"),dataType:"LAYER_PHYS",data:JSON.stringify(t)}}encodeLayer(e,t){return{id:pr(e,"LAYER"),dataType:"LAYER",data:JSON.stringify(t)}}encodeCanvas(e){return{id:"CANVAS",dataType:"CANVAS",data:JSON.stringify(e)}}};var ZF=class extends C7{constructor(e){let t=e||new Ow;super(t,0,k8),this.cacheNum=null}onParseLine(e,t,i,r,s,n,a){switch(this.setOrderNum(e,a,t),this.cacheNum=a,t){case"MAX_NUM":if(i)for(let l in i)this.setMaxNum(l,i[l]);break;case"BLOB":i?this.onBlob(e,r,s,i,n):this.onDelBlob(e,r,s,n);break;case"FONT":this.parseFont(e,i,r,s,n);break;case"META":i&&this.parseDetail(i,r,s,n);break;case"ELE_PLACEHOLDER":break;case"CANVAS":i&&this.parseCanvas(i,r,s,n);break;case"BOARD":i?this.parseBoard(i,r,s,n):this.onDelBoard(r,s,n);break;case"LAYER":{let l=Xo(e);i?this.parseLayer(l,i,r,s,n):this.onDelLayer(l,r,s,n);break}case"LAYER_PHYS":{let l=Xo(e);i?this.parseLayerPhys(l,i,r,s,n):this.onDelLayerPhys(l,r,s,n);break}case"ACTIVE_LAYER":i&&this.parseActiveLayer(e,i,r,s,n);break;case"PARTITION":i?this.parsePartition(e,i,r,s,n):this.onDelPartition(e,r,s,n);break;case"NET":{let l=Xo(e);i?this.parseNet(l,i,r,s,n):this.onDelNet(l,r,s,n);break}case"PRIMITIVE":{let l=Xo(e);i?this.parsePrimitive(l,i,r,s,n):this.onDelPrimitive(l,r,s,n);break}case"GROUP":i?this.parseGroup(e,i,r,s,n):this.onDelGroup(e,r,s,n);break;case"X_SIGNAL_GROUP":i?this.parseXSignalsGroup(e,i,r,s,n):this.onDelXSignalsGroup(e,r,s,n);break;case"X_SIGNALS":i?this.parseXSignals(e,i,r,s,n):this.onDelXSignals(e,r,s,n);break;case"SILK_OPTS":{let l=Xo(e);i?this.parseSilkOpts(l,i,r,s,n):this.onDelSilkOpts(l,r,s,n);break}case"PREFERENCE":i&&this.parsePreference(e,i,r,s,n);break;case"VIA":i?this.parseVia(e,i,r,s,n):this.onDelVia(e,r,s,n);break;case"PAD":i?this.parsePad(e,i,r,s,n):this.onDelPad(e,r,s,n);break;case"LINE":i?this.parseLine(e,i,r,s,n):this.onDelLine(e,r,s,n);break;case"ARC":i?this.parseArc(e,i,r,s,n):this.onDelArc(e,r,s,n);break;case"OBJ":i?this.parseObj(e,i,r,s,n):this.onDelObj(e,r,s,n);break;case"EQLEN_GRP":i?this.parseEQLenGrp(e,i,r,s,n):this.onDelEQLenGrp(e,r,s,n);break;case"POLY":i?this.parsePoly(e,i,r,s,n):this.onDelPoly(e,r,s,n);break;case"FILL":i?this.parseFill(e,i,r,s,n):this.onDelFill(e,r,s,n);break;case"LAYER_FILL":let o=Xo(e);i?this.parseLayerFill(o,i,r,s,n):this.onDelLayerFill(o,r,s,n);break;case"REGION":i?this.parseRegion(e,i,r,s,n):this.onDelRegion(e,r,s,n);break;case"POUR":i?this.parsePour(e,i,r,s,n):this.onDelPour(e,r,s,n);break;case"POURED":{e=Xo(e),i?this.parsePoured(e,i,r,s,n):this.onDelPoured(e,r,s,n);break}case"IMAGE":i?this.parseImage(e,i,r,s,n):this.onDelImage(e,r,s,n);break;case"TEARDROP":i?this.parseTeardrop(e,i,r,s,n):this.onDelTeardrop(e,r,s,n);break;case"FPC_FILL":i?this.parseFpcFill(e,i,r,s,n):this.onDelFpcFill(e,r,s,n);break;case"SHELL":i?this.parseShell(e,i,r,s,n):this.onDelShell(e,r,s,n);break;case"CREASE":i?this.parseCrease(e,i,r,s,n):this.onDelCrease(e,r,s,n);break;case"SHELLCUT":i?this.parseShellCut(e,i,r,s,n):this.onDelShellCut(e,r,s,n);break;case"SHELL_ENTITY":i?this.parseShellEntity(e,i,r,s,n):this.onDelShellEntity(e,r,s,n);break;case"BOSS":i?this.parseBoss(e,i,r,s,n):this.onDelBoss(e,r,s,n);break;case"STRING":i?this.parseString(e,i,r,s,n):this.onDelString(e,r,s,n);break;case"ATTR":i?this.parseAttr(e,i,r,s,n):this.onDelAttr(e,r,s,n);break;case"DIMENSION":i?this.parseDimension(e,i,r,s,n):this.onDelDimension(e,r,s,n);break;case"COMPONENT":i?this.parseComponent(e,i,r,s,n):this.onDelComponent(e,r,s,n);break;case"PAD_NET":{let l=JSON.parse(e);i?(i.componentId=l[1],i.padNum=l[2],i.padId=l[3],this.parsePadNet(i,r,s,n)):this.onDelPadNet(l[1],l[2],l[3]||"",r,s,n);break}case"RULE_TEMPLATE":i&&this.parseRuleTemplate(e,i,r,s,n);break;case"RULE":{let l=JSON.parse(e);i?(i.ruleType=l[1],i.ruleName=l[2],this.parseRule(i,r,s,n)):this.onDelRule(l[1],l[2],r,s,n);break}case"RULE_SELECTOR":{let l=JSON.parse(e);i?(i.ruleSelect=l[1],this.parseRuleSelector(i,r,s,n)):this.onDelRuleSelector(l[1],r,s,n);break}case"PANELIZE":i?this.parsePanelize(e,i,r,s,n):this.onDelPanelize(r,s,n);break;default:console.warn("can not find hanlder with",i,r,s)}this.cacheNum=null}onOrderNum(e,t,i){switch(this.setOrderNum(e,i,t),t){case"PARTITION":this.onPartitionNum&&this.onPartitionNum(e,i);break;case"VIA":this.onViaNum&&this.onViaNum(e,i);break;case"PAD":this.onPadNum&&this.onPadNum(e,i);break;case"LINE":this.onLineNum&&this.onLineNum(e,i);break;case"ARC":this.onArcNum&&this.onArcNum(e,i);break;case"OBJ":this.onObjNum&&this.onObjNum(e,i);break;case"POLY":this.onPolyNum&&this.onPolyNum(e,i);break;case"FILL":this.onFillNum&&this.onFillNum(e,i);break;case"REGION":this.onRegionNum&&this.onRegionNum(e,i);break;case"POUR":this.onPourNum&&this.onPourNum(e,i);break;case"POURED":let r=Xo(e);this.onPouredNum&&this.onPouredNum(r,i);break;case"IMAGE":this.onImageNum&&this.onImageNum(e,i);break;case"TEARDROP":this.onTeardropNum&&this.onTeardropNum(e,i);break;case"FPC_FILL":this.onFpcFillNum&&this.onFpcFillNum(e,i);break;case"SHELL":this.onShellNum&&this.onShellNum(e,i);break;case"CREASE":this.onCreaseNum&&this.onCreaseNum(e,i);break;case"SHELLCUT":this.onShellCutNum&&this.onShellCutNum(e,i);break;case"SHELL_ENTITY":this.onShellEntityNum&&this.onShellEntityNum(e,i);break;case"BOSS":this.onBossNum&&this.onBossNum(e,i);break;case"STRING":this.onStringNum&&this.onStringNum(e,i);break;case"ATTR":this.onAttrNum&&this.onAttrNum(e,i);break;case"DIMENSION":this.onDimensionNum&&this.onDimensionNum(e,i);break;case"COMPONENT":this.onComponentNum&&this.onComponentNum(e,i);break}}onParseEnd(){}parseCanvas(e,t,i,r){this.onCanvas(t,i,e,r)}parseBoard(e,t,i,r){this.onBoard(e,t,i,r)}parseDetail(e,t,i,r){this.onDocDetail(t,i,e,r)}parseFont(e,t,i,r,s){let n=S7(e);t?this.onFont(i,r,Object.assign(t,n),s):this.onDelFont(n,i,r,s)}parseLayer(e,t,i,r,s){this.onLayer(e,i,r,t,s)}parseLayerPhys(e,t,i,r,s){this.onLayerPhys(e,i,r,t,s)}parseActiveLayer(e,t,i,r,s){this.onActiveLayer(i,r,t,s)}parsePartition(e,t,i,r,s){this.onPartition(e,this.cacheNum,i,r,t,s)}parseNet(e,t,i,r,s){this.onNet(e,i,r,t,s)}parsePrimitive(e,t,i,r,s){this.onPrimitive(e,i,r,t,s)}parseGroup(e,t,i,r,s){this.onGroup(e,i,r,t,s)}parseXSignalsGroup(e,t,i,r,s){this.onXSignalsGroup(e,t,i,r,s)}parseXSignals(e,t,i,r,s){this.onXSignals(e,t,i,r,s)}parseSilkOpts(e,t,i,r,s){this.onSilkOpts(e,i,r,t,s)}parsePreference(e,t,i,r,s){this.onPreference(i,r,t,s)}parseVia(e,t,i,r,s){this.onVia(e,this.cacheNum,i,r,t,s)}parsePad(e,t,i,r,s){this.onPad(e,this.cacheNum,i,r,t,s)}parseLine(e,t,i,r,s){this.onLine(e,this.cacheNum,i,r,t,s)}parseArc(e,t,i,r,s){this.onArc(e,this.cacheNum,i,r,t,s)}parseObj(e,t,i,r,s){this.onObj(e,this.cacheNum,i,r,t,s)}parseEQLenGrp(e,t,i,r,s){this.onEQLenGrp(e,i,r,t,s)}parsePoly(e,t,i,r,s){this.onPoly(e,this.cacheNum,i,r,t,s)}parseFill(e,t,i,r,s){t.fillStyle!=="PLANE"&&this.onFill(e,this.cacheNum,i,r,t,s)}parseLayerFill(e,t,i,r,s){this.onLayerFill(e,i,r,t,s)}parseRegion(e,t,i,r,s){this.onRegion(e,this.cacheNum,i,r,t,s)}parsePour(e,t,i,r,s){this.onPour(e,this.cacheNum,i,r,t,s)}parsePoured(e,t,i,r,s){let n=t;Array.isArray(t)&&(n={pourFill:t}),n.pourFill&&this.onPoured(e,this.cacheNum,i,r,n,s)}parseImage(e,t,i,r,s){this.onImage(e,this.cacheNum,i,r,t,s)}parseTeardrop(e,t,i,r,s){this.onTeardrop(e,this.cacheNum,i,r,t,s)}parseFpcFill(e,t,i,r,s){this.onFpcFill(e,this.cacheNum,i,r,t,s)}parseShell(e,t,i,r,s){this.onShell(e,this.cacheNum,i,r,t,s)}parseCrease(e,t,i,r,s){this.onCrease(e,this.cacheNum,i,r,t,s)}parseShellCut(e,t,i,r,s){this.onShellCut(e,this.cacheNum,i,r,t,s)}parseShellEntity(e,t,i,r,s){this.onShellEntity(e,this.cacheNum,i,r,t,s)}parseBoss(e,t,i,r,s){this.onBoss(e,this.cacheNum,i,r,t,s)}parseDimension(e,t,i,r,s){this.onDimension(e,this.cacheNum,i,r,t,s)}parseRuleTemplate(e,t,i,r,s){this.onRuleTemplate(i,r,t,s)}parseRule(e,t,i,r){this.onRule(t,i,e,r)}parseRuleSelector(e,t,i,r){if(e.ruleKeyValue&&(e.ruleKeyValue=D7(e.ruleKeyValue)),e.copperValue&&e.copperValue.hasOwnProperty("7")){let s=e.copperValue[7];delete e.copperValue[7],e.copperValue.COPPER=s}if(e.innerPlaneValue&&e.innerPlaneValue.hasOwnProperty("6")){let s=e.innerPlaneValue[6];delete e.innerPlaneValue[6],e.innerPlaneValue.PLANE=s}this.onRuleSelector(t,i,e,r)}parsePanelize(e,t,i,r,s){this.onPanelize(i,r,t,s)}parseComponent(e,t,i,r,s){this.onComponent(e,this.cacheNum,i,r,t,s)}parsePadNet(e,t,i,r){this.onPadNet(t,i,e,r)}parseAttr(e,t,i,r,s){this.onAttr(e,this.cacheNum,i,r,t,s)}parseString(e,t,i,r,s){this.onString(e,this.cacheNum,i,r,t,s)}};var KF=(e=>(e.UNIVERSAL="UNIVERSAL",e))(KF||{}),$F=(e=>(e.SINGLE="SINGLE",e.MULTIPLE="MULTIPLE",e))($F||{}),QF=(e=>(e.NONE="NONE",e.NAME="NAME",e.NUMBER="NUMBER",e))(QF||{}),eU=(e=>(e.NONE="NONE",e.ZONE="ZONE",e))(eU||{});var tU=Cc(Hd());function zd(){return self.EDITOR_TOP||self}function Fg(e){return self[e]=self[e]||new tU.BroadcastChannelMessageBus(e)}var Xl=(e,t)=>{let i=/{([^}]*)}/gim,r=[...new Set(e.match(i))];for(let s=0;s<r.length;s++){let n=r[s],a=n.substring(1,n.length-1);t[a]&&(e=e.replace(n,t[a]))}return e};var iU=Cc(Hd()),mi={getTime:"/pro-mgr/serverTime/now",getUserL:"/pro-ui/loginUser/get",subMaxTick:"/pro-mgr/project/ticket",subBlob:"/pro-mgr/canvas/BLOB/update",subFont:"/pro-mgr/canvas/FONT/update",subRevoke:"/pro-mgr/{uuid}/revoke",pushPend:"/pro-mgr/worker/batchPendData",pushSync:"/pro-mgr/dataWorker/sync",pushRevoke:"/pro-mgr/worker/revoke",pullASync:"/pro-mgr/dataWorker/sync/{id}",personDestroy:"/mgr/libWorker/destroy",projectUpdate:"/pro-mgr/canvas/{uuid}/update",personUpdate:"/mgr/libWorker/component/{uuid}/update",personSave:"/mgr/libWorker/save",projectSave:"/mgr/projectWorker/setCanvas",canSavePend:"/mgr/projectWorker/canSavePend",hasSaveData:"/mgr/check/hasSaveData"},rU={projectUpdate:mi.projectUpdate,personUpdate:mi.personUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/footprint/getCanvas",getPerson:"/mgr/libWorker/getFootprint",unwatch:"/mgr/projectWorker/footprint/unwatchCanvas"},sU={projectUpdate:mi.projectUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/pcb/getCanvas",unwatch:"/mgr/projectWorker/pcb/unwatchCanvas"},Fee={projectUpdate:mi.projectUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/sheet/getCanvas",unwatch:"/mgr/projectWorker/sheet/unwatchCanvas"},Uee={projectUpdate:mi.projectUpdate,getProject:"/mgr/projectWorker/schematic/getCanvas",unwatch:"/mgr/projectWorker/schematic/unwatchCanvas"},Gee={projectUpdate:mi.projectUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/simulation/getCanvas",unwatch:"/mgr/projectWorker/simulation/unwatchCanvas"},zee={projectUpdate:mi.projectUpdate,personUpdate:mi.personUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/symbol/getCanvasOnCompiler",getPerson:"/mgr/libWorker/getSymbol",unwatch:"/mgr/projectWorker/symbol/unwatchCanvas"},Hee={projectUpdate:mi.projectUpdate,personUpdate:mi.personUpdate,projectCanSave:mi.canSavePend,getProject:"/mgr/projectWorker/panel/getCanvas",getPerson:"/mgr/libWorker/getPanelLib",unwatch:"/mgr/projectWorker/panel/unwatchCanvas"};var ks={send:"/pro-mgr/notify/send",sendMsg:"/document/sendMsg/cooperation",unwatch:"/document/unwatch/cooperation",watch:"/document/watch/cooperation",message:"/pro-mgr/notify/message/{path}/{uuid}/cooperation",established:"/pro-mgr/notify/message/ws/established",getWsId:"/pro-mgr/notify/getWsId",disconnect:"/pro-mgr/notify/message/ws/disconnect"},M1=class{constructor(e=!0){this._lockerTicket=0,this.isPull=!1,this.compiler={},this.order={SYMBOL:1,FOOTPRINT:2,DEVICE:3,SCH_PAGE:4,PCB:5},this._locker=e?++this._lockerTicket:0}getOrder(e){return this.order[e]||6}publish(){if(!this.isPull){this.isPull=!0,this._temporaryUnlock=this._locker;try{let e=Object.keys(this.compiler).sort((i,r)=>this.getOrder(i)-this.getOrder(r)),t=!1;for(let i of e){for(let[,r]of this.compiler[i])if(t=r.publish(),t)break;if(t)break}}finally{this._temporaryUnlock=0,this.isPull=!1}}}canPush(){return!this._locker||this._locker===this._temporaryUnlock}addCompiler(e){this.compiler[e.headType]||(this.compiler[e.headType]=new Map),this.compiler[e.headType].set(e.uniqueId,e)}removeCompiler(e){var t,i,r;(r=(i=(t=this.compiler)==null?void 0:t[e.headType])==null?void 0:i.delete)==null||r.call(i,e.uniqueId)}pull(){if(!this._locker)throw Error("\u4E0D\u5141\u8BB8\u5728\u975E pause \u72B6\u6001\u4E0B\u62C9\u53D6\u6570\u636E");this.publish()}resume(){this._locker=0,this.publish()}pause(){this._locker=++this._lockerTicket}dispose(){for(let e in this.compiler)this.compiler[e].clear();this.compiler=null}},Zo={publish:"publish",destroy:"destroy",init:"init",selected:"selected"},nU=class{constructor(e,t,i,r=(a=>(a=zd())==null?void 0:a._TAB_ID_)(),s,n){this.uuid=e,this.path=t,this.user=i,this.windowId=r,this.initIds={},this.sub=[];var a;this.wsBus=n||Fg(`/${this.windowId}/notify`),this.dataBus=s||this.wsBus,this._client=(a=zd())==null?void 0:a._WS_ID_}get client(){return this._client}watch(){this.dataBus.publish(ks.send,{topic:ks.watch,uuid:this.uuid,path:this.path})}initPublish(){var e;this.dataBus.publish(ks.send,{topic:ks.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zo.publish,user:this.user,client:this.client,data:((e=this.getSelect)==null?void 0:e.call(this))||""}})}async init(){if(!this.isInit){if(this.sub.push(this.wsBus.subscribe(ks.established,e=>{this._client=e,this.watch(),this.initPublish()})),!this.client){let e=await this.wsBus.rpcCall(ks.getWsId);if(!e||this.client)return;this._client=e}this.watch(),this.sub.push(this.wsBus.subscribe(ks.disconnect,e=>{this.initIds[e]&&this.onDestroy(this.initIds[e],e)})),this.sub.push(this.dataBus.subscribe(Xl(ks.message,{uuid:this.uuid,path:this.path}),e=>{if(e.type===1)e.connectId&&this.initIds[e.connectId]&&this.onDestroy(this.initIds[e.connectId],e.connectId);else if(e.msg){let t=e.msg;if(t.client===this.client)return;switch(t.type){case Zo.destroy:this.onDestroy(t.userId,t.client),delete this.initIds[t.client];break;case Zo.init:this.initIds[t.client]||(this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||""));break;case Zo.selected:this.onSelected(t.user,t.client,t.data||"");break;case Zo.publish:this.dataBus.publish(ks.send,{topic:ks.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zo.init,user:this.user,client:this.client,data:this.getSelect()||""}}),this.initIds[t.client]=t.user.uuid,this.onSelected(t.user,t.client,t.data||"");break;default:break}}})),this.initPublish(),this.isInit=!0}}publishSelected(e,t){this.dataBus.publish(ks.send,{topic:ks.sendMsg,uuid:this.uuid,path:this.path,msg:{type:Zo.selected,user:this.user,client:this.client,data:e}}),t&&this.onSelected(this.user,this.client,e)}destroy(){if(this.isInit){this.isInit=!1,this.dataBus.publish(ks.send,{topic:ks.unwatch,uuid:this.uuid,path:this.path,msg:{type:Zo.destroy,userId:this.user.uuid,client:this.client}});for(let e of this.sub)e.cancel();this.sub=[],this.initIds={}}}},fw=class extends nU{constructor(e,t,i,r,s,n,a,o){super(e,t,o,i,s,n),this.channel=r,this.selectedProps=a,this.cache=new Map,this.deleteCache=new Map}rePublish(){var e,t,i,r;if(this.channel.canPush()){for(let[s,n]of this.cache)(t=(e=this.selectedProps)==null?void 0:e.onSelect)==null||t.call(e,n.user,s,n.data);for(let[s,n]of this.deleteCache)(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,n,s)}}getSelect(){var e,t;return((t=(e=this.selectedProps)==null?void 0:e.getSelect)==null?void 0:t.call(e))||""}onSelected(e,t,i){var r,s;this.channel.canPush()?!this.deleteCache.has(t)&&this.cache.set(t,{user:e,data:i}):(s=(r=this.selectedProps)==null?void 0:r.onSelect)==null||s.call(r,e,t,i)}onDestroy(e,t){var i,r;this.channel.canPush()?(this.deleteCache.set(t,e),this.cache.delete(t)):(r=(i=this.selectedProps)==null?void 0:i.onQuit)==null||r.call(i,e,t)}dispose(){this.destroy(),this.cache.clear(),this.deleteCache.clear()}publishSelected(e,t){super.publishSelected(e,t)}},aU=class{constructor(e,t,i,r=(y=>(y=zd())==null?void 0:y._TAB_ID_)(),s=new M1,n=null,a,o,l,h,c,d,f,u,p,g,_){this.uuid=e,this.path=t,this.isProject=i,this.windowId=r,this.channel=s,this.consistencyManager=n,this.selectedProps=l,this.setInit=h,this.onDocDetail=c,this.onUpdate=d,this.handleInit=f,this.onDelete=u,this.publishCache=p,this.onOrderNm=g,this.setMaxNum=_,this.isInit=!1,this.canSave=!0,this.sub=[],this.isInitIng=!1,this.cache={},this.deleteCache=new Map,this.pendTimer=null,this.pendPromise=null,this.pendCache={},this.pendCacheLength=0,this.wsBus=Fg(`/${r}/notify`),n||(this._unique=so()),this._headType=a,this.busTopic=o}get uniqueId(){return this._unique||this.consistencyManager.getUnique()}get headType(){return this._headType}setIsInitIng(e){var t;(t=this.setInit)==null||t.call(this,e),this.isInitIng=e}consoleDebug(...e){console.debug("[lc-protocol]",this._headType,this.uuid,...e)}publishLine(e,t,i,r,s,n=this.uuid,a,o,l,h,c){if(this.channel.canPush())return this.consistencyManager.remoteChange(t,s,n,e,i,r,void 0,void 0,void 0,a,void 0,o,l,c),!1;this.cache[n]||(this.cache[n]=new Map);let d=this.cache[n].get(e);return(h||!d||d.ticket<t||d.ticket===t&&(d.client<s||d.client===s&&!!d.pend!=!!a))&&this.cache[n].set(e,{client:s,ticket:t,dataType:r,data:i,pend:a,unique:o,pChange:d?void 0:l,num:c}),!0}onDocHead(){}onEnd(){}setDocType(e,t){e===this.uuid&&(this._headType=t)}setBusTopic(e){this.busTopic=e}publish(){var e,t,i;if(this.publishCache)return this.publishCache();let r=!1;for(let[s,n]of this.deleteCache){if(this.channel.canPush()){(e=this.onDelete)==null||e.call(this,n),delete this.cache[s];continue}r=!0;break}if(r)return r;for(let s in this.cache){let n=this.cache[s].keys();for(let a of n){let o=this.cache[s].get(a);if(r=this.publishLine(a,o.ticket,o.data,o.dataType,o.client,s,o.pend,o.unique,o.pChange,!1,o.num),r)break;this.cache[s].delete(a)}if(r)break}return(i=(t=this.selectManager)==null?void 0:t.rePublish)==null||i.call(t),r}publishSelected(e,t){this.selectManager.publishSelected(e,t)}clear(){var e,t;for(let i of this.sub)i.cancel();this.sub.length=0,this.cache={},this.deleteCache.clear(),this.setIsInitIng(!1),this.channel.removeCompiler(this),(t=(e=this.selectManager)==null?void 0:e.dispose)==null||t.call(e),this.selectManager=null,this.isInit=!1,this.setIsInitIng(!1)}async init(e=!0,t=!0,i=!0,r,s,n,a){try{if(this.isInit)return{success:!0};if(this.isInitIng)throw new Error("\u6B63\u5728\u521D\u59CB\u5316\u4E2D");return this.isProject?await this.initProject(e,t,i,r,n,a):await this.initLib(i,r,s,n,a)}catch(o){throw this.clear(),new Error(`${this._headType}+'Compiler' ${this.uuid} init false: ${(o==null?void 0:o.message)||o||""}`,{cause:o})}finally{this.isInitIng=!1}}async flowRead(e){let t=this.consistencyManager.flowParseFull(),i=t.update,r=this;t.update=s=>{if(r.isDestroy)return!0;i(s)},await(0,iU.flowRead)(e,t)}pushOnLine(e,t){if(this.consistencyManager)for(let i of e)this.publishLine(i[0],i[1],i[2],i[3],i[4],t,i[5],i[6],i[7],!1,i[8])}async initProject(e,t,i,r,s,n){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=Fg(`/${this.windowId}/project/${this.path}`),s&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let h of l)this.onOrderNm(h[0],h[1],h[2])})),i&&this.busTopic.projectUpdate&&this.sub.push(this.dataBus.subscribe(Xl(this.busTopic.projectUpdate,{uuid:this.uuid}),l=>{this.onUpdate?this.onUpdate(l):this.pushOnLine(l,this.uuid)})),i&&this.busTopic.projectCanSave&&this.sub.push(this.dataBus.subscribe(this.busTopic.projectCanSave,l=>{this.canSave=l})),i&&this.busTopic.subDelete&&this.sub.push(this.dataBus.subscribe(this.busTopic.subDelete,l=>{var h;this.channel.canPush()?(h=this.onDelete)==null||h.call(this,l):this.deleteCache.set(l[0],l)})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(mi.subMaxTick,l=>{this.consistencyManager.setMaxTicket(l.ticket,l.force)})),i&&t&&this.sub.push(this.dataBus.subscribe(mi.subBlob,l=>{this.pushOnLine(l,"BLOB")})),i&&e&&this.sub.push(this.dataBus.subscribe(mi.subFont,l=>{this.pushOnLine(l,"FONT")})),i&&this.consistencyManager&&this.sub.push(this.dataBus.subscribe(Xl(mi.subRevoke,{uuid:this.uuid}),l=>this.revoke(l))),!this.busTopic.getProject)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");this.isDestroy=!1;let a={doc:[this.uuid],watch:i,needNum:s,needDelete:n};t&&a.doc.push("BLOB"),e&&a.doc.push("FONT");let o=await this.dataBus.rpcCall(this.busTopic.getProject,a);if(this.isWatch=i,!this.isDestroy){if(!o.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",o);if(this.canSave=!(o!=null&&o.readOnly),this.consoleDebug("init",o.result),o.maxTicket&&this.consistencyManager&&this.consistencyManager.setMaxTicket(o.maxTicket),o.data&&this.onDocDetail&&this.onDocDetail(o.client||so(),0,o.data,!1),o.channel&&await this.flowRead(o.channel),!this.isDestroy){if(this.handleInit?this.handleInit(o):o.result&&this.consistencyManager&&this.consistencyManager.parseFull(o.result,this.uuid,this._headType),r){let l=this.user=this.user||o.user||await this.wsBus.rpcCall(mi.getUserL);this.selectManager=new fw(this.uuid,this.path,this.windowId,this.channel,this.dataBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}}async initLib(e,t,i,r,s){if(this.setIsInitIng(!0),this.channel.addCompiler(this),this.dataBus=Fg(`/${this.windowId}/libWorker`),!this.busTopic.getPerson)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01");let n=i?so():"";this.isDestroy=!1;let a=await this.dataBus.rpcCall(this.busTopic.getPerson,{uuid:this.uuid,path:this.path,watch:e,channel:n,needNum:r,needDelete:s});if(this.isWatch=e,this.isDestroy)return;if(!a.success)throw new Error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF01\uFF01\uFF01",a);this.consoleDebug("init",a.dataStr);let o=a.data||a.result;if(o&&this.onDocDetail&&this.onDocDetail(a.client||so(),0,o,!1),r&&this.sub.push(this.dataBus.subscribe(`/pro-mgr/${this.uuid}/number/update`,l=>{if(this.onOrderNm)for(let h of l)this.onOrderNm(h[0],h[1],h[2])})),e&&this.busTopic.personUpdate&&this.sub.push(this.dataBus.subscribe(Xl(this.busTopic.personUpdate,{uuid:this.uuid}),l=>{this.pushOnLine(l,this.uuid)})),e&&this.sub.push(this.dataBus.subscribe(Xl(Xl(mi.subRevoke,{uuid:this.uuid}),{uuid:this.uuid}),l=>this.revoke(l))),n&&await this.flowRead(n),!this.isDestroy){if(a.dataStr&&this.consistencyManager&&this.consistencyManager.parseFull(a.dataStr),t){let l=this.user=this.user||a.user||await this.wsBus.rpcCall(mi.getUserL);this.selectManager=new fw(this.uuid,this.path,this.windowId,this.channel,this.wsBus,this.wsBus,this.selectedProps,l),await this.selectManager.init()}return this.isInit=!0,this.setIsInitIng(!1),{success:!0}}}revoke(e){for(let t of e)this.consistencyManager&&this.consistencyManager.revoke(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],(...i)=>this.publishLine(...i)),t[10]&&this.setMaxNum&&this.setMaxNum(t[6],t[10],t[1])}cachePendData(e,t,i,r,s,n){if(this.pendCache[e]||(this.pendCache[e]={type:n,pend:[]}),this.pendCache[e].pend.push([t,i,s,r]),this.pendCacheLength+=r.length+1,this.pendCacheLength>1e7&&this.publishPendData(),!this.pendTimer){let a;this.pendPromise=new Promise(o=>a=o),this.pendTimer=setTimeout(()=>{this.publishPendData(),a&&a(),this.pendTimer=null},0)}}publishPendData(){if(this.pendCacheLength){this.dataBus.publish(mi.pushPend,[this.pendCache,this.consistencyManager.getClient(),this.uniqueId,this.uuid]);for(let e in this.pendCache)this.pendCache[e].pend.length=0;this.pendCache={},this.pendCacheLength=0}}localChange(e,t,i,r=this.uuid,s,n){if(!this.isInit||!this.canSave||!this.consistencyManager)return 0;if(t&&!t.startsWith("{"))return console.error("\u4E0A\u4F20\u7684\u683C\u5F0F\u4E0D\u6B63\u786E",e,i,t),0;let a=this.consistencyManager.localChange(r,e,t,i,s,n);return this.cachePendData(r,e,a,t,i,s||this.headType),a}async sync(){if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u540C\u6B65");let e=so();this.dataBus.publish(mi.pushSync,e),await this.dataBus.pullA(Xl(mi.pullASync,{id:e}))}async destroy(){return this.isDestroy?{success:!1}:(this.consistencyManager&&this.dataBus&&(this.pendPromise&&await this.pendPromise,this.dataBus.publish(mi.pushRevoke,[this.uuid,this.uniqueId,this.consistencyManager.getClient()])),this.clear(),this.isDestroy=!0,this.isWatch&&this.dataBus&&!this.isProject&&this.dataBus.publish(mi.personDestroy,{uuid:this.uuid,path:this.path}),this.isWatch&&this.dataBus&&this.busTopic.unwatch&&this.dataBus.publish(this.busTopic.unwatch,this.uuid),this.isWatch=!1,{success:!0})}async save(e=[this.uuid,"BLOB","FONT"]){try{if(!this.isInit)throw new Error("\u6570\u636E\u672A\u521D\u59CB\u5316\uFF0C\u65E0\u6CD5\u4FDD\u5B58");if(!this.consistencyManager)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");let t=this.isProject?mi.projectSave:mi.personSave;if(!t)throw new Error("\u65E0\u6CD5\u652F\u6301\u4FDD\u5B58");this.pendPromise&&await this.pendPromise;let i=await this.dataBus.rpcCall(t,{uuid:this.uuid,path:this.path,docIds:e,uniqueId:this.uniqueId,client:this.consistencyManager.getClient()});return this.consoleDebug("save",i),i}catch(t){throw new Error(`${this._headType}+'Compiler' ${this.uuid} \u4FDD\u5B58\u5931\u8D25: ${(t==null?void 0:t.message)||t||""}`,{cause:t})}}async getBlob(e){return this.dataBus.rpcCall("/mgr/projectWorker/blob/getBlob",e)}async getFont(e,t,i,r,s,n,a,o){let l={text:e,fontFamily:t,fontSize:i,thickness:r,bold:s,italic:n,reverse:a,expansion:o},h=await this.dataBus.rpcCall("/mgr/projectWorker/font/get",l);return h.success?{success:!0,result:Object.assign(l,JSON.parse(h.result))}:h}async checkSave(){return this.pendPromise&&await this.pendPromise,await this.dataBus.rpcCall(mi.hasSaveData,{uuid:this.uuid,uniqueId:this.uniqueId})}};var oU=(e=>(e.DIFFERENTIAL_PAIR="DIFFERENTIAL_PAIR",e.NET_CLASS="NET_CLASS",e.EQL_NET_GRP="EQL_NET_GRP",e))(oU||{});var jee=Cc(Hd()),Vee=Cc(Hd());var qw=class extends ZF{constructor(e,t,i,r,s,n,a,o=(l=>(l=zd())==null?void 0:l._TAB_ID_)()){let l=new Ow(o);super(l),this.isProject=i,this.encode=n,this.base=new aU(e,t,i,o,r,l,s,s==="PCB"?sU:rU,a,(...h)=>this.setIsInit(...h),(...h)=>this.onDocDetail(...h),void 0,void 0,void 0,void 0,(h,c,d)=>this.onOrderNum(h,c,d),(h,c,d)=>{this.setMaxNum(h,c,!!d),d&&this.deleteOrderNum(d)})}get dataBus(){return this.base.dataBus}set dataBus(e){this.base.dataBus=e}async init(e=!0,t=!0,i=!0,r,s=!0,n){return this.setNeedNum(s),this.base.init(e,t,i,r,!0,s,n)}async sync(){return this.base.sync()}async destroy(){return this.base.destroy()}async save(){return this.base.save()}checkSave(){return this.base.checkSave()}publishSelected(e,t){this.base.publishSelected(e,t)}uploadBlob(e,t){let i=I7(t),r={filename:e,content:t};return{success:!0,ticket:this.localChange({id:i,data:JSON.stringify(r),dataType:"BLOB"},"BLOB","BLOB"),hash:i}}deleteBlob(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BLOB"},"BLOB","BLOB")}}uploadFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:s,bold:n,italic:a,reverse:o,expansion:l,width:h,height:c,path:d}=e,f={width:h,height:c,path:d},u=C3(t,i,r,s,n,a,o,l);return{success:!0,ticket:this.localChange({id:u,data:JSON.stringify(f),dataType:"FONT"},"FONT","FONT")}}deleteFont(e){let{text:t,fontFamily:i,fontSize:r,thickness:s,bold:n,italic:a,reverse:o,expansion:l}=e,h=C3(t,i,r,s,n,a,o,l);return{success:!0,ticket:this.localChange({id:h,data:"",dataType:"FONT"},"FONT","FONT")}}async updateFootprint(e){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/update",e):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u76F4\u63A5\u4FEE\u6539\u5C01\u88C5\u4FE1\u606F"}}async generateTemplate(e,t){return this.isProject?this.dataBus.rpcCall("/mgr/projectWorker/footprint/generateTemplate",{custom:e,renameKey:t}):{success:!1,message:"compiler \u6682\u4E0D\u652F\u6301\u4E2A\u4EBA\u5E93\u8C03\u7528\u8BE5\u63A5\u53E3"}}localChange(e,t=this.base.uuid,i){var r,s;let n=this.getOrderNum(e.id);return(s=(r=this.needOrderType)==null?void 0:r.includes)!=null&&s.call(r,e.dataType)&&n===void 0&&(n=this.getMaxNum(e.dataType),this.setOrderNum(e.id,n,e.dataType),this.onOrderNum(e.id,e.dataType,n)),this.base.localChange(e.id,e.data,e.dataType,t,i,n)}uploadString(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeString(e,t))}}deleteString(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"STRING"})}}uploadAttr(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeAttr(e,t))}}deleteAttr(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ATTR"})}}uploadPanelize(e){return{success:!0,ticket:this.localChange(this.encode.encodePanelize(e))}}deletePanelize(){return{success:!0,ticket:this.localChange({id:"PANELIZE",data:"",dataType:"PANELIZE"})}}uploadRuleSelector(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleSelector(e))}}deleteRuleSelector(e){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE_SELECTOR",e]),data:"",dataType:"RULE_SELECTOR"})}}uploadRule(e){return{success:!0,ticket:this.localChange(this.encode.encodeRule(e))}}deleteRule(e,t){return{success:!0,ticket:this.localChange({id:JSON.stringify(["RULE",e,t]),data:"",dataType:"RULE"})}}uploadRuleTemplate(e){return{success:!0,ticket:this.localChange(this.encode.encodeRuleTemplate(e))}}uploadDimension(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeDimension(e,t))}}deleteDimension(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"DIMENSION"})}}uploadBoss(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeBoss(e,t))}}deleteBoss(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"BOSS"})}}uploadShellEntity(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellEntity(e,t))}}deleteShellEntity(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL_ENTITY"})}}uploadShellCut(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShellCut(e,t))}}deleteShellCut(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELLCUT"})}}uploadCrease(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeCrease(e,t))}}deleteCrease(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"CREASE"})}}uploadShell(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeShell(e,t))}}deleteShell(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"SHELL"})}}uploadFpcFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFpcFill(e,t))}}deleteFpcFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FPC_FILL"})}}uploadTeardrop(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeTeardrop(e,t))}}deleteTeardrop(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"TEARDROP"})}}uploadImage(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeImage(e,t))}}deleteImage(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"IMAGE"})}}uploadPoured(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoured(e,t))}}deletePoured(e){return{success:!0,ticket:this.localChange({id:pr(e,"POURED"),data:"",dataType:"POURED"})}}uploadPour(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePour(e,t))}}deletePour(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POUR"})}}uploadRegion(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeRegion(e,t))}}deleteRegion(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"REGION"})}}uploadFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeFill(e,t))}}deleteFill(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"FILL"})}}uploadLayerFill(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerFill(e,t))}}deleteLayerFill(e){return{success:!0,ticket:this.localChange({id:pr(e,"LAYER_FILL"),data:"",dataType:"LAYER_FILL"})}}uploadPoly(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePoly(e,t))}}deletePoly(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"POLY"})}}uploadEQLenGrp(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeEQLenGrp(e,t))}}deleteEQLenGrp(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"EQLEN_GRP"})}}uploadObj(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeObj(e,t))}}deleteObj(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"OBJ"})}}uploadArc(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeArc(e,t))}}deleteArc(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"ARC"})}}uploadLine(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLine(e,t))}}deleteLine(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"LINE"})}}uploadPad(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePad(e,t))}}deletePad(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"PAD"})}}uploadVia(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeVia(e,t))}}deleteVia(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"VIA"})}}uploadPreference(e){return{success:!0,ticket:this.localChange(this.encode.encodePreference(e))}}uploadSilkOpts(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeSilkOpts(e,t))}}deleteSilkOpts(e){return{success:!0,ticket:this.localChange({id:pr(e,"SILK_OPTS"),data:"",dataType:"SILK_OPTS"})}}uploadGroup(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeGroup(e,t))}}deleteGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"GROUP"})}}uploadPrimitive(e,t){return{success:!0,ticket:this.localChange(this.encode.encodePrimitive(e,t))}}deletePrimitive(e){return{success:!0,ticket:this.localChange({id:pr(e,"PRIMITIVE"),data:"",dataType:"PRIMITIVE"})}}uploadNet(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeNet(e,t))}}deleteNet(e){return{success:!0,ticket:this.localChange({id:pr(e,"NET"),data:"",dataType:"NET"})}}uploadActiveLayer(e){return{success:!0,ticket:this.localChange(this.encode.encodeActiveLayer(e))}}uploadLayerPhys(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayerPhys(e,t))}}deleteLayerPhys(e){return{success:!0,ticket:this.localChange({id:pr(e,"LAYER_PHYS"),data:"",dataType:"LAYER_PHYS"})}}uploadLayer(e,t){return{success:!0,ticket:this.localChange(this.encode.encodeLayer(e,t))}}deleteLayer(e){return{success:!0,ticket:this.localChange({id:pr(e,"LAYER"),data:"",dataType:"LAYER"})}}uploadCanvas(e){return{success:!0,ticket:this.localChange(this.encode.encodeCanvas(e))}}uploadBoard(e){return{success:!0,ticket:this.localChange({id:"BOARD",data:JSON.stringify(e),dataType:"BOARD"})}}deleteBoard(){return{success:!0,ticket:this.localChange({id:"BOARD",data:"",dataType:"BOARD"})}}uploadXSignalsGroup(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNAL_GROUP"})}}deleteXSignalsGroup(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNAL_GROUP"})}}uploadXSignals(e,t){return{success:!0,ticket:this.localChange({id:e,data:JSON.stringify(t),dataType:"X_SIGNALS"})}}deleteXSignals(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"X_SIGNALS"})}}},Ww=class extends qw{constructor(e,t,i,r){let s=new XF;super(e,t,!0,i,"PCB",s,{getSelect:()=>{var n;return(n=this.canvasSelected)==null?void 0:n.call(this)},onSelect:(...n)=>{var a;return(a=this.onSelectChange)==null?void 0:a.call(this,n[0],n[1],n[2])},onQuit:(...n)=>{var a;return(a=this.onSelectQuit)==null?void 0:a.call(this,n[0],n[1])}},r),this.uuid=e,this.project=t,this.windowId=r,this.encoder=s}async customFootprint(e,t){return this.dataBus.rpcCall("/mgr/projectWorker/footprint/clone",{uuid:e,source:t})}async footprintIsExist(e){var t;return(t=await this.dataBus.rpcCall("/mgr/projectWorker/footprint/isExist",e))==null?void 0:t.result}uploadPadNet(e){return{success:!0,ticket:this.localChange(this.encoder.encodePadNet(e))}}deletePadNet(e,t,i){return{success:!0,ticket:this.localChange({id:JSON.stringify(["PAD_NET",e,t,i||""]),data:"",dataType:"PAD_NET"})}}uploadComponent(e,t){return{success:!0,ticket:this.localChange(this.encoder.encodeComponent(e,t))}}deleteComponent(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"COMPONENT"})}}uploadPartition(e,t){return{success:!0,ticket:this.localChange(this.encoder.encodePartition(e,t))}}deletePartition(e){return{success:!0,ticket:this.localChange({id:e,data:"",dataType:"PARTITION"})}}},Xw=class extends qw{constructor(e,t,i,r,s=(n=>(n=zd())==null?void 0:n._TAB_ID_)()){super(e,t,i,r,"FOOTPRINT",new JF,{getSelect:()=>{var n;return(n=this.canvasSelected)==null?void 0:n.call(this)},onSelect:(...n)=>{var a;return(a=this.onSelectChange)==null?void 0:a.call(this,n[0],n[1],n[2])},onQuit:(...n)=>{var a;return(a=this.onSelectQuit)==null?void 0:a.call(this,n[0],n[1])}},s),this.uuid=e,this.path=t,this.isProject=i,this.windowId=s}onComponent(){}onComponentNum(){}onDelComponent(){}onPadNet(){}onDelPadNet(){}};var lU=Object.create,LT=Object.defineProperty,hU=Object.getOwnPropertyDescriptor,cU=Object.getOwnPropertyNames,uU=Object.getPrototypeOf,dU=Object.prototype.hasOwnProperty,fU=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pU=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of cU(t))!dU.call(e,s)&&s!==i&&LT(e,s,{get:()=>t[s],enumerable:!(r=hU(t,s))||r.enumerable});return e},gU=(e,t,i)=>(i=e!=null?lU(uU(e)):{},pU(t||!e||!e.__esModule?LT(i,"default",{value:e,enumerable:!0}):i,e)),_U=fU((e,t)=>{"use strict";t.exports=i,t.exports.default=i;function i(x,I,S){S=S||2;var D=I&&I.length,N=D?I[0]*S:x.length,G=r(x,0,N,S,!0),z=[];if(!G||G.next===G.prev)return z;var Z,se,he,pe,Se,q,X;if(D&&(G=c(x,I,G,S)),x.length>80*S){Z=he=x[0],se=pe=x[1];for(var ie=S;ie<N;ie+=S)Se=x[ie],q=x[ie+1],Se<Z&&(Z=Se),q<se&&(se=q),Se>he&&(he=Se),q>pe&&(pe=q);X=Math.max(he-Z,pe-se),X=X!==0?32767/X:0}return n(G,z,S,Z,se,X,0),z}function r(x,I,S,D,N){var G,z;if(N===R(x,I,S,D)>0)for(G=I;G<S;G+=D)z=F(G,x[G],x[G+1],z);else for(G=S-D;G>=I;G-=D)z=F(G,x[G],x[G+1],z);return z&&E(z,z.next)&&(j(z),z=z.next),z}function s(x,I){if(!x)return x;I||(I=x);var S=x,D;do if(D=!1,!S.steiner&&(E(S,S.next)||v(S.prev,S,S.next)===0)){if(j(S),S=I=S.prev,S===S.next)break;D=!0}else S=S.next;while(D||S!==I);return I}function n(x,I,S,D,N,G,z){if(x){!z&&G&&g(x,D,N,G);for(var Z=x,se,he;x.prev!==x.next;){if(se=x.prev,he=x.next,G?o(x,D,N,G):a(x)){I.push(se.i/S|0),I.push(x.i/S|0),I.push(he.i/S|0),j(x),x=he.next,Z=he.next;continue}if(x=he,x===Z){z?z===1?(x=l(s(x),I,S),n(x,I,S,D,N,G,2)):z===2&&h(x,I,S,D,N,G):n(s(x),I,S,D,N,G,1);break}}}}function a(x){var I=x.prev,S=x,D=x.next;if(v(I,S,D)>=0)return!1;for(var N=I.x,G=S.x,z=D.x,Z=I.y,se=S.y,he=D.y,pe=N<G?N<z?N:z:G<z?G:z,Se=Z<se?Z<he?Z:he:se<he?se:he,q=N>G?N>z?N:z:G>z?G:z,X=Z>se?Z>he?Z:he:se>he?se:he,ie=D.next;ie!==I;){if(ie.x>=pe&&ie.x<=q&&ie.y>=Se&&ie.y<=X&&O(N,Z,G,se,z,he,ie.x,ie.y)&&v(ie.prev,ie,ie.next)>=0)return!1;ie=ie.next}return!0}function o(x,I,S,D){var N=x.prev,G=x,z=x.next;if(v(N,G,z)>=0)return!1;for(var Z=N.x,se=G.x,he=z.x,pe=N.y,Se=G.y,q=z.y,X=Z<se?Z<he?Z:he:se<he?se:he,ie=pe<Se?pe<q?pe:q:Se<q?Se:q,de=Z>se?Z>he?Z:he:se>he?se:he,Ce=pe>Se?pe>q?pe:q:Se>q?Se:q,De=y(X,ie,I,S,D),Fe=y(de,Ce,I,S,D),Pe=x.prevZ,w=x.nextZ;Pe&&Pe.z>=De&&w&&w.z<=Fe;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0||(Pe=Pe.prevZ,w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;Pe&&Pe.z>=De;){if(Pe.x>=X&&Pe.x<=de&&Pe.y>=ie&&Pe.y<=Ce&&Pe!==N&&Pe!==z&&O(Z,pe,se,Se,he,q,Pe.x,Pe.y)&&v(Pe.prev,Pe,Pe.next)>=0)return!1;Pe=Pe.prevZ}for(;w&&w.z<=Fe;){if(w.x>=X&&w.x<=de&&w.y>=ie&&w.y<=Ce&&w!==N&&w!==z&&O(Z,pe,se,Se,he,q,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function l(x,I,S){var D=x;do{var N=D.prev,G=D.next.next;!E(N,G)&&T(N,D,D.next,G)&&M(N,G)&&M(G,N)&&(I.push(N.i/S|0),I.push(D.i/S|0),I.push(G.i/S|0),j(D),j(D.next),D=x=G),D=D.next}while(D!==x);return s(D)}function h(x,I,S,D,N,G){var z=x;do{for(var Z=z.next.next;Z!==z.prev;){if(z.i!==Z.i&&b(z,Z)){var se=k(z,Z);z=s(z,z.next),se=s(se,se.next),n(z,I,S,D,N,G,0),n(se,I,S,D,N,G,0);return}Z=Z.next}z=z.next}while(z!==x)}function c(x,I,S,D){var N=[],G,z,Z,se,he;for(G=0,z=I.length;G<z;G++)Z=I[G]*D,se=G<z-1?I[G+1]*D:x.length,he=r(x,Z,se,D,!1),he===he.next&&(he.steiner=!0),N.push(m(he));for(N.sort(d),G=0;G<N.length;G++)S=f(N[G],S);return S}function d(x,I){return x.x-I.x}function f(x,I){var S=u(x,I);if(!S)return I;var D=k(S,x);return s(D,D.next),s(S,S.next)}function u(x,I){var S=I,D=x.x,N=x.y,G=-1/0,z;do{if(N<=S.y&&N>=S.next.y&&S.next.y!==S.y){var Z=S.x+(N-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(Z<=D&&Z>G&&(G=Z,z=S.x<S.next.x?S:S.next,Z===D))return z}S=S.next}while(S!==I);if(!z)return null;var se=z,he=z.x,pe=z.y,Se=1/0,q;S=z;do D>=S.x&&S.x>=he&&D!==S.x&&O(N<pe?D:G,N,he,pe,N<pe?G:D,N,S.x,S.y)&&(q=Math.abs(N-S.y)/(D-S.x),M(S,x)&&(q<Se||q===Se&&(S.x>z.x||S.x===z.x&&p(z,S)))&&(z=S,Se=q)),S=S.next;while(S!==se);return z}function p(x,I){return v(x.prev,x,I.prev)<0&&v(I.next,x,x.next)<0}function g(x,I,S,D){var N=x;do N.z===0&&(N.z=y(N.x,N.y,I,S,D)),N.prevZ=N.prev,N.nextZ=N.next,N=N.next;while(N!==x);N.prevZ.nextZ=null,N.prevZ=null,_(N)}function _(x){var I,S,D,N,G,z,Z,se,he=1;do{for(S=x,x=null,G=null,z=0;S;){for(z++,D=S,Z=0,I=0;I<he&&(Z++,D=D.nextZ,!!D);I++);for(se=he;Z>0||se>0&&D;)Z!==0&&(se===0||!D||S.z<=D.z)?(N=S,S=S.nextZ,Z--):(N=D,D=D.nextZ,se--),G?G.nextZ=N:x=N,N.prevZ=G,G=N;S=D}G.nextZ=null,he*=2}while(z>1);return x}function y(x,I,S,D,N){return x=(x-S)*N|0,I=(I-D)*N|0,x=(x|x<<8)&16711935,x=(x|x<<4)&252645135,x=(x|x<<2)&858993459,x=(x|x<<1)&1431655765,I=(I|I<<8)&16711935,I=(I|I<<4)&252645135,I=(I|I<<2)&858993459,I=(I|I<<1)&1431655765,x|I<<1}function m(x){var I=x,S=x;do(I.x<S.x||I.x===S.x&&I.y<S.y)&&(S=I),I=I.next;while(I!==x);return S}function O(x,I,S,D,N,G,z,Z){return(N-z)*(I-Z)>=(x-z)*(G-Z)&&(x-z)*(D-Z)>=(S-z)*(I-Z)&&(S-z)*(G-Z)>=(N-z)*(D-Z)}function b(x,I){return x.next.i!==I.i&&x.prev.i!==I.i&&!C(x,I)&&(M(x,I)&&M(I,x)&&H(x,I)&&(v(x.prev,x,I.prev)||v(x,I.prev,I))||E(x,I)&&v(x.prev,x,x.next)>0&&v(I.prev,I,I.next)>0)}function v(x,I,S){return(I.y-x.y)*(S.x-I.x)-(I.x-x.x)*(S.y-I.y)}function E(x,I){return x.x===I.x&&x.y===I.y}function T(x,I,S,D){var N=A(v(x,I,S)),G=A(v(x,I,D)),z=A(v(S,D,x)),Z=A(v(S,D,I));return!!(N!==G&&z!==Z||N===0&&P(x,S,I)||G===0&&P(x,D,I)||z===0&&P(S,x,D)||Z===0&&P(S,I,D))}function P(x,I,S){return I.x<=Math.max(x.x,S.x)&&I.x>=Math.min(x.x,S.x)&&I.y<=Math.max(x.y,S.y)&&I.y>=Math.min(x.y,S.y)}function A(x){return x>0?1:x<0?-1:0}function C(x,I){var S=x;do{if(S.i!==x.i&&S.next.i!==x.i&&S.i!==I.i&&S.next.i!==I.i&&T(S,S.next,x,I))return!0;S=S.next}while(S!==x);return!1}function M(x,I){return v(x.prev,x,x.next)<0?v(x,I,x.next)>=0&&v(x,x.prev,I)>=0:v(x,I,x.prev)<0||v(x,x.next,I)<0}function H(x,I){var S=x,D=!1,N=(x.x+I.x)/2,G=(x.y+I.y)/2;do S.y>G!=S.next.y>G&&S.next.y!==S.y&&N<(S.next.x-S.x)*(G-S.y)/(S.next.y-S.y)+S.x&&(D=!D),S=S.next;while(S!==x);return D}function k(x,I){var S=new L(x.i,x.x,x.y),D=new L(I.i,I.x,I.y),N=x.next,G=I.prev;return x.next=I,I.prev=x,S.next=N,N.prev=S,D.next=S,S.prev=D,G.next=D,D.prev=G,D}function F(x,I,S,D){var N=new L(x,I,S);return D?(N.next=D.next,N.prev=D,D.next.prev=N,D.next=N):(N.prev=N,N.next=N),N}function j(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function L(x,I,S){this.i=x,this.x=I,this.y=S,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}i.deviation=function(x,I,S,D){var N=I&&I.length,G=N?I[0]*S:x.length,z=Math.abs(R(x,0,G,S));if(N)for(var Z=0,se=I.length;Z<se;Z++){var he=I[Z]*S,pe=Z<se-1?I[Z+1]*S:x.length;z-=Math.abs(R(x,he,pe,S))}var Se=0;for(Z=0;Z<D.length;Z+=3){var q=D[Z]*S,X=D[Z+1]*S,ie=D[Z+2]*S;Se+=Math.abs((x[q]-x[ie])*(x[X+1]-x[q+1])-(x[q]-x[X])*(x[ie+1]-x[q+1]))}return z===0&&Se===0?0:Math.abs((Se-z)/z)};function R(x,I,S,D){for(var N=0,G=I,z=S-D;G<S;G+=D)N+=(x[z]-x[G])*(x[G+1]+x[z+1]),z=G;return N}i.flatten=function(x){for(var I=x[0][0].length,S={vertices:[],holes:[],dimensions:I},D=0,N=0;N<x.length;N++){for(var G=0;G<x[N].length;G++)for(var z=0;z<I;z++)S.vertices.push(x[N][G][z]);N>0&&(D+=x[N-1].length,S.holes.push(D))}return S}}),Jw={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},Uie=(()=>{let e={};for(let t in Jw)e[Jw[t]]=t;return e})(),Zw=class{constructor(t,i){this.ratio=t/i}wrap(t){return t*this.ratio}static convert(t,i,r){return t*i/r}};Zw.ASIS=new Zw(1,1);var C_=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,s=this[r](i);return t=="mil"?Math.round(s*10)/10:Math.round(s*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};C_.prototype["px(100)2mil"]=e=>e*10;C_.prototype["px(100)2mm"]=e=>e*.254;C_.prototype["mil2px(100)"]=e=>e/10;C_.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var $g=null,Ob=new ArrayBuffer(8),B1=new Float64Array(Ob),k1=new Uint32Array(Ob),Kw=new Uint16Array(Ob),$w=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!$g){let e=this.getUrlVars().version;e?$g="/analyzer/v"+e:$g="/analyzer"}return $g}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;B1[0]=new Date().getTime(),e.push(k1[1].toString(16)),B1[0]=Math.random(),e.push(Kw[3].toString(16));let t=Kw[2].toString(16);e.push("4"+t.substr(0,3)),B1[0]=performance.now();let i=k1[0].toString(16)+k1[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},DT=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(zc.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(zc.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(zc.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(zc.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},OU=/(\.?0+)$/,zc=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push($w.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push($w.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);DT.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(OU,"")}};function mU(e){switch(e){case 0:return"DEBUG";case 1:return"INFO";case 2:return"WARNING";case 3:return"ERROR";case 4:return"DUMMY"}}var bU=(e,t)=>{e===3?console.error(t):console.log(t)},yU=(e,t)=>zc.format("%s %s: %s",new Date,mU(e),t),ib=class rb{constructor(t,i=bU,r=yU){this.debug=!1,this.level=t,this.writer=i,this.fmt=r}static mix(...t){let i=4;for(let r of t)r.level<i&&(i=r.level);return new rb(i,(r,s)=>{for(let n of t)n.write1(r,s)},(r,s)=>s)}wrap(t=null,i=null){let r=t===null?this.fmt:(n,a)=>(a=t(n,a),this.fmt(n,a)),s=i===null?this.writer:(n,a)=>{i(n,a),this.writer(n,a)};return new rb(this.level,s,r)}chain(t){return t.wrap(this.fmt.bind(this),this.writer.bind(this))}include(t){return this.level<=t}write3(t,i,r){this.include(t)&&this.writer(t,this.fmt(t,zc.format(i,...r)))}write2(t,i){this.include(t)&&(i instanceof Error?this.writer(t,this.fmt(t,i.stack)):this.writer(t,this.fmt(t,i.toString())))}write1(t,i){this.include(t)&&this.writer(t,this.fmt(t,i))}debug3(t,...i){this.write3(0,t,i)}debug2(t){this.write2(0,t)}debug1(t){this.write1(0,t)}info3(t,...i){this.write3(1,t,i)}info2(t){this.write2(1,t)}info1(t){this.write1(1,t)}warning3(t,...i){this.write3(2,t,i)}warning2(t){this.write2(2,t)}warning1(t){this.write1(2,t)}error3(t,...i){this.write3(3,t,i)}error2(t){this.write2(3,t)}error1(t){this.write1(3,t)}};ib.DUMMY=new ib(4);var L_=ib,mb=new ArrayBuffer(8),F1=new Float64Array(mb),U1=new Uint32Array(mb),Qw=new Uint16Array(mb),eT=ArrayBuffer;try{eT=self.HTMLImageElement||eT}catch{}var Qg=null;function ah(e,t,i=0,r=e.length){s(e,null,t,i,r);function s(a,o,l,h,c){let d,f,u,p;if(h<c-1){let g=c-h;if(g>50)o===null&&(o=new Array(g+1)),n(a,o,l,h,(h+c)/2|0,c);else{d=a[h],f=h,u=h,p=c;let _=f+1;for(;_<p;){if(u!=p){if(p=p+-1,l(d,a[p])<=0)continue;a[u]=a[p],u=p;continue}if(l(d,a[_])>=0){f=_,_=f+1;continue}a[u]=a[_],f=_,u=_,_=f+1}a[u]=d,s(a,o,l,h,u),s(a,o,l,u+1,c)}}}function n(a,o,l,h,c,d){s(a,o,l,h,c),s(a,o,l,c,d);for(var f=h,u=c,p=0,g=a[f],_=a[u];f<c&&u<d;){var y=l(g,_);isNaN(y)?(o[p++]=_,_=a[++u]):(y<=0&&(o[p++]=g,g=a[++f]),y>=0&&(o[p++]=_,_=a[++u]))}for(;f<c;f++)o[p++]=a[f];for(;u<d;u++)o[p++]=a[u];for(f=h,u=0;u<p;f++,u++)a[f]=o[u]}}var hs=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!Qg){let e=this.getUrlVars().version;e?Qg="/analyzer/v"+e:Qg="/analyzer"}return Qg}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;F1[0]=new Date().getTime(),e.push(U1[1].toString(16)),F1[0]=Math.random(),e.push(Qw[3].toString(16));let t=Qw[2].toString(16);e.push("4"+t.substr(0,3)),F1[0]=performance.now();let i=U1[0].toString(16)+U1[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},vU=[1,10,100,1e3],e_=0,th=0;function tT(e,t,i){return e_=Math.abs(e-t),i>=5&&e_>1e-5||isNaN(i)&&e_>1e-8?!1:e_<1e-13?!0:(th=Math.min(iT(e),iT(t)),th<10&&(th=10),isNaN(i)||(th=Math.min(th,i)),rT(e,th)===rT(t,th))}var t_=0,i_=0;function iT(e){return t_=0,i_=0,e>0?t_=e-Math.floor(e):t_=e-Math.ceil(e),i_=(t_.toString()||"").length,i_>2?i_-2:0}function rT(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=vU[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}var xU=/(\.?0+)$/,Hc=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(hs.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(hs.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);si.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(xU,"")}},si=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(Hc.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(Hc.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(Hc.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(Hc.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},ve=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<=this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>=-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}};ve.eps=1e-8,ve.precision=1e8;function Vc(e,t){b_(e.iterator(),t)}function b_(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var EU=class{constructor(e){this.idx=-1,this.lst=e}hasNext(){return this.idx<this.lst.length-1}next(){if(this.idx<this.lst.length-1)return this.idx++,this.lst[this.idx];throw new Error("bug")}};function sb(e){return new EU(e)}var f_=class tn{static toDegrees(t){return t*180/Math.PI}static toRadians(t){return t/180*Math.PI}static regularD(t){return t=t%360,t=t<0?360+t:t,t===360?0:t}static regular(t){return t=t%tn.PIx2,t=t<0?tn.PIx2+t:t,t===tn.PIx2?0:t}static toQuarterBase(t){return tn.regular((t+tn.PI_4)/tn.PI_2*tn.PI_2)}static toQuarterBaseD(t){return tn.regularD(((t+45)/90|0)*90)}static transformD(t,i){return tn.toDegrees(tn.transform(tn.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),s=Math.sin(t),n=new ae(i.data[6],i.data[7]),a=new ae(r,s).multiply3(i);return tn.regular(a.angle(n))}};f_.PIx2=Math.PI*2,f_.PI_2=Math.PI/2,f_.PI_4=Math.PI/4;var _t=f_,Zi=class{static dotProd1(e,t,i,r){return e*i+t*r}static dotProd2(e,t,i,r,s,n){return this.dotProd1(i-e,r-t,s-i,n-r)}static dotProd3(e,t,i){return this.dotProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static crossProd1(e,t,i,r){return e*r-t*i}static crossProd2(e,t,i,r,s,n){return this.crossProd1(i-e,r-t,s-i,n-r)}static crossProd3(e,t,i){return this.crossProd2(e.x,e.y,t.x,t.y,i.x,i.y)}static distance2(e,t,i,r){let s=i-e,n=r-t;return s*s+n*n}static distance1(e,t,i,r){return this.hypot(i-e,r-t)}static distance1p(e,t){return this.distance1(e.x,e.y,t.x,t.y)}static hypot(e,t){if(e=Math.abs(e),t=Math.abs(t),t>e){var i=t;t=e,e=i}if(e===0)return t;var r=t/e;return e*Math.sqrt(1+r*r)}},RT=new ArrayBuffer(16),sT=new Float64Array(RT),r_=new Int32Array(RT),ih=class wi{static sortByXAsc(t,i){return t.x-i.x}static sortByYAsc(t,i){return t.y-i.y}static sortByXYAsc(t,i){return t.x<i.x?-1:t.x>i.x?1:t.y-i.y}static caculateAngle(t,i){let r=Math.cos(t),s=Math.sin(t),n=r*i.data[0]+s*i.data[4],a=r*i.data[1]+s*i.data[5],o=new wi(n,a).normalize();return Math.atan2(o.y,o.x)}static normal(t,i,r){let s=i.sub(t),n=r.sub(i);return s.cross(n)}static getVector2(t){return new wi(Math.cos(t),Math.sin(t))}static getCrossPoint1(t,i,r,s){if(t.equals1(i)||r.equals1(s)||ve.eq(1,Math.abs(i.sub(t).normalize().dot(s.sub(r).normalize()))))return null;let n=i.y-t.y,a=t.x-i.x,o=i.x*t.y-t.x*i.y,l=s.y-r.y,h=r.x-s.x,c=s.x*r.y-r.x*s.y,d=n*h-l*a;return new wi((c*a-o*h)/d,(o*l-c*n)/d)}static getCrossPoint2(t,i,r,s){return this.getCrossPoint1(t,t.add(i),r,r.add(s))}constructor(t,i){this.x=si.normal(t),this.y=si.normal(i)}get hashed(){return this._hashed==null&&(sT[0]=this.x,sT[1]=this.y,this._hashed=r_[0]^r_[1]^r_[2]^r_[3]),this._hashed}dot(t){return this.x*t.x+this.y*t.y}length(){return Math.sqrt(this.dot(this))}getCos(){return this.x/this.length()}sub(t){var i=this.x-t.x,r=this.y-t.y;return new wi(i,r)}add(t){var i=this.x+t.x,r=this.y+t.y;return new wi(i,r)}div(t){return new wi(this.x/t,this.y/t)}add1(t,i){return new wi(this.x+t,this.y+i)}mul(t){return new wi(this.x*t,this.y*t)}cross(t){return this.x*t.y-this.y*t.x}getSin(){return this.y/this.length()}angle2(t){let i=this.y-t.y,r=this.x-t.x;return i=Math.abs(i-0)<10**-4?0:i,r=Math.abs(r-0)<10**-4?0:r,Math.atan2(i,r)}angleD2(t){return _t.toDegrees(this.angle2(t))}angle(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleX(t=wi.ORIGIN){let i=this.angle(t);return i<0&&(i=Math.PI*2+i),i}angleD(t){return _t.toDegrees(this.angle(t))}distance1(t){let i=t.x-this.x,r=t.y-this.y;return Zi.hypot(i,r)}distance2(t){let i=t.x-this.x,r=t.y-this.y;return i*i+r*r}rotateD(t,i){return this.rotate(t,_t.toRadians(i))}rotate(t,i){let r=Math.cos(i),s=Math.sin(i),n=this.x-t.x,a=this.y-t.y,o=n*r+a*-s,l=n*s+a*r;return t.add1(o,l)}multiply3(t){let i=this.x*t.data[0]+this.y*t.data[3]+t.data[6],r=this.x*t.data[1]+this.y*t.data[4]+t.data[7];return new wi(i,r)}multiply4(t){let i=this.x*t.data[0]+this.y*t.data[4]+t.data[12],r=this.x*t.data[1]+this.y*t.data[5]+t.data[13];return new wi(i,r)}hashCode(){return this.hashed}equals(t,i){return t instanceof wi?tT(t.x,this.x,i)&&tT(t.y,this.y,i):!1}equals1(t){return t?ve.eq(this.x,t.x)&&ve.eq(this.y,t.y):!1}equals2(t,i){return t instanceof wi?Math.abs(this.x-t.x)<=i&&Math.abs(this.y-t.y)<=i:!1}similarEquals(t,i=.5){return Math.abs(this.x*.1-t.x*.1)<=i&&Math.abs(this.y*.1-t.y*.1)<=i}toString(){return"Vector [X="+this.x+", Y="+this.y+"]"}bbox(){let t=this.x,i=this.y;return new Pi(t,t,i,i)}normalize(){if(this.x===0&&this.y===0)return new wi(0,0);let t=this.x/this.length(),i=this.y/this.length();return new wi(t,i)}regular(t=1e-4){let i=Math.round(1/t);return new wi(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}round(t=4){let i=10**(t|0);return new wi(Math.round(this.x*i)/i,Math.round(this.y*i)/i)}mirrorX(t=wi.ORIGIN){return new wi(this.x,2*t.y-this.y)}mirrorY(t=wi.ORIGIN){return new wi(2*t.x-this.x,this.y)}mirrorCenter(t=wi.ORIGIN){return new wi(2*t.x-this.x,2*t.y-this.y)}clone(){return new wi(this.x,this.y)}mirror(t=wi.ORIGIN){return new wi(2*t.x-this.x,2*t.y-this.y)}pointOnRays(t,i){let r=_t.toRadians(t);return new wi(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}pointOnRays2(t,i){let r=t.angle(this);return new wi(this.x+Math.cos(r)*i,this.y+Math.sin(r)*i)}scale(t){return new wi(this.x*t,this.y*t)}};ih.ORIGIN=new ih(0,0),ih.X_UNIT_VECTOR=new ih(1,0),ih.Y_UNIT_VECTOR=new ih(0,1);var ae=ih,wU=(e=>(e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT",e))(wU||{}),TU=(e=>(e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM",e))(TU||{}),Mr=class{constructor(t,i){this.horizontal=t,this.vertical=i}};Mr.LT=new Mr(0,0),Mr.LC=new Mr(0,1),Mr.LB=new Mr(0,2),Mr.CT=new Mr(1,0),Mr.CC=new Mr(1,1),Mr.CB=new Mr(1,2),Mr.RT=new Mr(2,0),Mr.RC=new Mr(2,1),Mr.RB=new Mr(2,2);var oo=Mr,yi=class{constructor(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}ext1(e){return this.minX=Math.min(this.minX,e.minX),this.maxX=Math.max(this.maxX,e.maxX),this.minY=Math.min(this.minY,e.minY),this.maxY=Math.max(this.maxY,e.maxY),this}ext2(e){return this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y),this}ext3(e){for(let t=0;t<e.length;t++){let i=e[t];this.ext2(i)}return this}ext4(e){return Vc(e,(t,i)=>(this.ext2(i),!0)),this}ext5(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,t),this.minY=Math.min(this.minY,i),this.maxY=Math.max(this.maxY,r),this}ext6(e,t){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t),this}ext7(e){if(e<0){let t=e*2;if(t<this.minX-this.maxX||t<this.minY-this.maxY)throw new Error("")}return this.minX-=e,this.maxX+=e,this.minY-=e,this.maxY+=e,this}ext8(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(new ae(e[i],e[i+1]));return this.ext3(t)}ext9(e,t,i,r){return this.minX=Math.min(this.minX,e),this.maxX=Math.max(this.maxX,e+i),this.minY=Math.min(this.minY,t),this.maxY=Math.max(this.maxY,t+r),this}ext10({x:e,y:t,width:i,height:r}){return this.ext9(e,t,i,r)}valid(){return isFinite(this.minX)&&isFinite(this.maxX)&&isFinite(this.minY)&&isFinite(this.maxY)}clear(){this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY}build(){return new Pi(this.minX,this.maxX,this.minY,this.maxY)}build1(){return this.valid()?new Pi(this.minX,this.maxX,this.minY,this.maxY):new Pi(0,0,0,0)}},Jd=new Float64Array(4),Pi=class yn{static extendRect({x:t,y:i,width:r,height:s}){return new yn(t,t+r,i,i+s)}static extend1(t,i){if(t===null)return new yn(i.x,i.x,i.y,i.y);{let r=Math.min(t.minX,i.x),s=Math.max(t.maxX,i.x),n=Math.min(t.minY,i.y),a=Math.max(t.maxY,i.y);return new yn(r,s,n,a)}}static extend2(t,i){if(t){let r=Math.min(t.minX,i.minX),s=Math.max(t.maxX,i.maxX),n=Math.min(t.minY,i.minY),a=Math.max(t.maxY,i.maxY);return new yn(r,s,n,a)}else return i}static extend3(t,i){let r=Math.min(t.x,i.x),s=Math.max(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.y,i.y);return new yn(r,s,n,a)}static extend4(t,i,r){return new yn(t.x-i/2,t.x+i/2,t.y-r/2,t.y+r/2)}constructor(t,i,r,s){if(this.minX=si.normal(t),this.maxX=si.normal(i),this.minY=si.normal(r),this.maxY=si.normal(s),t>i||r>s)throw new Error(`min > max is not permitted: [${t}, ${i}, ${r}, ${s}]`)}get data(){return Jd[0]=this.minX,Jd[1]=this.maxX,Jd[2]=this.minY,Jd[3]=this.maxY,Jd}isContains(t){return this.isContains1(t.x,t.y)}points(){return[this.LL(),this.LR(),this.UR(),this.UL(),this.LL()]}isContains1(t,i){return this.isContainsX(t)&&this.isContainsY(i)}isContains2(t,i){return this.isContainsX1(t)&&this.isContainsY1(i)}isContainsX(t){return t>=this.minX&&t<=this.maxX}isContainsX1(t){return ve.greatereq(t,this.minX)&&ve.lesseq(t,this.maxX)}isContainsY(t){return t>=this.minY&&t<=this.maxY}isContainsY1(t){return ve.greatereq(t,this.minY)&&ve.lesseq(t,this.maxY)}isIntersect(t){return!(this.maxX<t.minX||this.minX>t.maxX||this.maxY<t.minY||this.minY>t.maxY)}extendOfSize(t){return si.positiveOr0(this.maxX-this.minX+t*2),si.positiveOr0(this.maxY-this.minY+t*2),new yn(this.minX-t,this.maxX+t,this.minY-t,this.maxY+t)}isInside(t){return this.minX>=t.minX&&this.maxX<=t.maxX&&this.minY>=t.minY&&this.maxY<=t.maxY}isContainsBBox(t){return this.maxX>=t.maxX&&this.minX<=t.minX&&this.maxY>=t.maxY&&this.minY<=t.minY}isContainsBBox1(t){return ve.greatereq(this.maxX,t.maxX)&&ve.lesseq(this.minX,t.minX)&&ve.greatereq(this.maxY,t.maxY)&&ve.lesseq(this.minY,t.minY)}intersect(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(i>r)return null;let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return s>n?null:new yn(i,r,s,n)}intersection1(t){let i=Math.max(this.minX,t.minX),r=Math.min(this.maxX,t.maxX);if(ve.greater(i,r))return null;i>r&&(r=i);let s=Math.max(this.minY,t.minY),n=Math.min(this.maxY,t.maxY);return ve.greater(s,n)?null:(s>n&&(n=s),new yn(i,r,s,n))}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new ae(this.minX,this.maxY)}UR(){return new ae(this.maxX,this.maxY)}LL(){return new ae(this.minX,this.minY)}LR(){return new ae(this.maxX,this.minY)}center(){return new ae(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}area(){return this.width()*this.height()}transform(t){let i=new yi;return i.ext2(this.LL().multiply3(t)),i.ext2(this.LR().multiply3(t)),i.ext2(this.UR().multiply3(t)),i.ext2(this.UL().multiply3(t)),i.build()}transform4(t){let i=new yi;return i.ext2(this.LL().multiply4(t)),i.ext2(this.LR().multiply4(t)),i.ext2(this.UR().multiply4(t)),i.ext2(this.UL().multiply4(t)),i.build()}isSeparated(t){if(t==null||t==null)return!1;let i;this.minX>=t.minX?i=this.minX:i=t.minX;let r;if(this.maxX<=t.maxX?r=this.maxX:r=t.maxX,i>r)return!0;{let s;this.minY>=t.minY?s=this.minY:s=t.minY;let n;return this.maxY<=t.maxY?n=this.maxY:n=t.maxY,s>n}}relation(t){let i=0,r=0,s;this.minX>t.minX?(i++,s=this.minX):this.minX===t.minX?s=this.minX:(r++,s=t.minX);let n;if(this.maxX<t.maxX?(i++,n=this.maxX):this.maxX===t.maxX?n=this.maxX:(r++,n=t.maxX),s>n)return 2;{let a;this.minY>t.minY?(i++,a=this.minY):this.minY===t.minY?a=this.minY:(r++,a=t.minY);let o;return this.maxY<t.maxY?(i++,o=this.maxY):this.maxY===t.maxY?o=this.maxY:(r++,o=t.maxY),a>o?2:i===4?0:r===4?1:i===0&&r===0?4:s===n||a===o?6:i!==r?5:3}}zoom(t){let i=this.width(),r=this.height(),s=this.center();return t!=0&&(i/=t/2,r/=t/2),new yn(s.x-i,s.x+i,s.y-i,s.y+i)}toString(){return"BBox [minX="+this.minX+", maxX="+this.maxX+", minY="+this.minY+", maxY="+this.maxY+"]"}equals(t){return this.minY==t.minY&&this.minX==t.minX&&this.maxX==t.maxX&&this.maxY==t.maxY}extendSize(t,i){return Object.is(void 0,i)&&(i=t),yn.extend4(this.center(),this.width()+t,this.height()+i)}positionOnBBox(t,i=0){let r=this.center(),s=this.width()*i/2,n=this.height()*i/2,a=t.x-r.x,o=t.y-r.y;return a>s?o>n?oo.RT:o<-n?oo.RB:oo.RC:a<-s?o>n?oo.LT:o<-n?oo.LB:oo.LC:o>n?oo.CT:o<-n?oo.CB:oo.CC}bbox(){return this}},y_=class kt{static mul(t,i,r,s,n,a){let o=0,l=0;for(let h=0;h<t;h++){for(let c=0;c<r;c++){let d=c,f=0;for(let u=0;u<i;u++)f+=s[l+u]*n[d],d+=r;a[o++]=f}l+=i}}constructor(t,i,r){this.m=si.normal(t),this.n=si.normal(i);let s=t*i;if(r.length===s){for(let n=0;n<r.length;n++)si.normal(r[n]);this.data=r}else throw new Error("invalid matrix size")}mul(t){if(this.n===t.m){let i=new Array(this.m*t.n);return kt.mul(this.m,this.n,t.n,this.data,t.data,i),new kt(this.m,t.n,i)}else throw new Error("m !== p")}toString(){let t=[];t.push("Matrix ("),t.push(this.m.toString()),t.push(" x "),t.push(this.n.toString()),t.push(")");let i=0;for(let r=0;r<this.m;r++)for(let s=0;s<this.n;s++){let n=this.data[i++].toString();s===0?(t.push(`
`),t.push("	"),t.push(n)):(t.push(", "),t.push(n))}return t.join("")}static on(t,i,r){return t*i+r}initExpandMatrix(t){let i=this.m,r=this.n,s=r*2,n=new Array(i*s);for(let a=0;a<i;a++)for(let o=0;o<s;o++)o<r?n[kt.on(s,a,o)]=t[kt.on(r,a,o)]:o===i+a?n[kt.on(s,a,o)]=1:n[kt.on(s,a,o)]=0;return n}inverseMatrix(t,i,r){for(let s=0;s<i;s++){let n=t[kt.on(r,s,s)];for(let a=0;a<r;a++)t[kt.on(r,s,a)]/=n}return t}getMatrixRank(t,i,r){let s=Math.min(i,r);for(let n=0;n<i;n++){if(t[kt.on(r,n,n)]===0){let a=new Array(r),o;for(o=n;o<i;o++)if(t[kt.on(r,o,n)]!==0){hs.arraycopy(t,kt.on(r,o,0),a,0,r),hs.arraycopy(t,kt.on(r,n,0),t,kt.on(r,o,0),r),hs.arraycopy(a,0,t,kt.on(r,n,0),r);break}o>=i&&(s-=1)}if(!(s<i))for(let a=0;a<i;a++){if(a===n)continue;let o=t[kt.on(r,a,n)]/t[kt.on(r,n,n)];for(let l=0;l<r;l++)t[kt.on(r,a,l)]-=t[kt.on(r,n,l)]*o}}return s}getInverseMatrix(){if(this.m!==this.n)throw new Error("The matrix is an "+this.m+"x"+this.n+" order matrix, non-square matrix, please check!");function t(a){return ve.lesseq(Math.abs(a),0)}let i=this.initExpandMatrix(this.data.slice(0)),r=this.n*2;function s(a,o){for(let l=0;l<r;l++){let h=i[kt.on(r,a,l)];i[kt.on(r,a,l)]=i[kt.on(r,o,l)],i[kt.on(r,o,l)]=h}}for(let a=0;a<this.m;a++){let o=Math.abs(i[kt.on(r,a,a)]),l=a;if(t(i[kt.on(r,a,a)]))for(let c=a+1;c<this.m;c++){if(t(i[kt.on(r,c,a)])){Math.abs(i[kt.on(r,c,a)])>o&&(o=Math.abs(i[kt.on(r,c,a)]),l=c);continue}s(a,c);break}if(t(i[kt.on(r,a,a)])){if(o===0)throw new Error("The matrix is a non-full rank matrix, please check!");console.warn("The matrix may be a non-full rank matrix, please check!"),l!==a&&s(a,l)}let h=1/i[kt.on(r,a,a)];for(let c=0;c<r;c++)i[kt.on(r,a,c)]*=h;for(let c=0;c<this.m;c++){if(a===c)continue;let d=i[kt.on(r,c,a)];for(let f=a;f<r;f++)i[kt.on(r,c,f)]-=i[kt.on(r,a,f)]*d}}let n=[];for(let a=0;a<this.m;a++)for(let o=this.n;o<r;o++)n[kt.on(this.n,a,o-this.n)]=i[kt.on(r,a,o)];return new kt(this.m,this.n,n)}getTransposeMatrix(){let t=new Array(this.data.length);for(let i=0;i<this.m;i++)for(let r=0;r<this.n;r++)t[r*this.n+i]=this.data[i*this.m+r];return new kt(this.n,this.m,t)}hashCode(){let t=0;for(let i of this.data)t+=i;return t}equals(t){return this===t?!0:t===null?!1:t instanceof kt?!(this.m!=t.m||this.n!=t.n||!hs.equals(this.data,t.data)):!1}},SU=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],nb=class Hi extends y_{static translate(t,i,r){return new Hi([1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1])}static translate1(t){return new Hi([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}static rotateX(t){let i=Math.cos(t),r=Math.sin(t);return new Hi([1,0,0,0,0,i,r,0,0,-r,i,0,0,0,0,1])}static rotateY(t){let i=Math.cos(t),r=Math.sin(t);return new Hi([i,0,-r,0,0,1,0,0,r,0,i,0,0,0,0,1])}static rotateZ(t){let i=Math.cos(t),r=Math.sin(t);return new Hi([i,r,0,0,-r,i,0,0,0,0,1,0,0,0,0,1])}static rotateAxis(t,i){t=t.normalize();let r=t.x,s=t.y,n=t.z,a=Math.sin(i),o=Math.cos(i);return new Hi([r*r*(1-o)+o,r*s*(1-o)+n*a,r*n*(1-o)-s*a,0,r*s*(1-o)-n*a,s*s*(1-o)+o,s*n*(1-o)+r*a,0,r*n*(1-o)+s*a,s*n*(1-o)-r*a,n*n*(1-o)+o,0,0,0,0,1])}static scale(t,i=t,r=t){return new Hi([t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1])}static flipX(){return new Hi([1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1])}static flipY(){return new Hi([-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static rotateZForPoint(t,i){return t.equals1(ae.ORIGIN)?Hi.rotateZ(i):Hi.translate(-t.x,-t.y,0).rotateZ(i).translate1(t.x,t.y,0)}static getMatrix4(t,i,r,s){let n=Math.cos(i),a=Math.sin(i),o=r*(t.x*n-t.y*a)+s.x,l=t.x*a+t.y*n+s.y,h=[r*n,a,0,0,-a*r,n,0,0,0,0,1,0,o,l,0,1];return new Hi(h)}constructor(t=SU){super(4,4,t)}translate(t){return this.multiply4(Hi.translate1(t))}translate1(t,i,r){return this.multiply4(Hi.translate(t,i,r))}rotateX(t){return this.multiply4(Hi.rotateX(t))}rotateY(t){return this.multiply4(Hi.rotateY(t))}rotateZ(t){return this.multiply4(Hi.rotateZ(t))}scale(t,i=t,r=t){return this.multiply4(Hi.scale(t,i,r))}scale1(t){return this.multiply4(Hi.scale(t.x,t.y,t.z))}setOrigin(t,i,r){return Hi.translate(-t,-i,-r).multiply4(this).translate1(t,i,r)}setOrigin1(t){return this.setOrigin(t.x,t.y,t.z)}multiply4(t){let i=new Array(16);return y_.mul(4,4,4,this.data,t.data,i),new Hi(i)}getInverseMatrix(){let t=super.getInverseMatrix();return new Hi(t.data)}getTransposeMatrix(){let t=super.getTransposeMatrix();return new Hi(t.data)}inverse(){let t=this.getInverseMatrix();return new Hi(t.data)}toMatrix3(){let t=this.data;return new ci([t[0],t[1],0,t[4],t[5],0,t[12],t[13],1])}};nb.ORIGIN=new nb;var Bi=nb;function Zd(e){return DT.normal(parseFloat(e))}var IU=[1,0,0,0,1,0,0,0,1],Yn=class Br extends y_{static translate(t,i){return new Br([1,0,0,0,1,0,t,i,1])}static translate1(t){return this.translate(t.x,t.y)}static rotate(t){let i=Math.cos(t),r=Math.sin(t);return new Br([i,r,0,-r,i,0,0,0,1])}static rotateD(t){return this.rotate(_t.toRadians(t))}static scale(t,i=t){return new Br([t,0,0,0,i,0,0,0,1])}static scale1(t,i){return new Br([t,0,0,0,i,0,0,0,1])}static toDOMMatrix(t){let[i,r,,s,n,,a,o]=t.data;return`matrix(${[i,r,s,n,a,o].join(",")})`}static svgTrasform(t){let i=t.split(" "),r=null;return i.forEach(s=>{s=s.trim();let n=s.trim().replace(")","").split("("),a=n[0],o=n[1].split(",");switch(a){case"translate":let l=Zd(o[0]),h=Zd(o[1]);r=r?r.translate(l,h):Br.translate(l,h);break;case"rotate":let c=Zd(o[0]),d=Zd(o[1]),f=Zd(o[2]);r=r?r.setOrigin(d,f):Br.translate(d,f),r=r.rotateD(c);break;default:return}}),r}constructor(t=IU){super(3,3,t);let i=t[0],r=t[3],s=t[1],n=t[4];this.iScale=Math.sqrt(i*i+s*s),this.jScale=Math.sqrt(r*r+n*n)}isMirrored(){return this.det()<0}multiply3(t){let i=new Array(9);return y_.mul(3,3,3,this.data,t.data,i),new Br(i)}translate(t,i){return this.multiply3(Br.translate(t,i))}translate1(t){return this.multiply3(Br.translate1(t))}scale(t,i=t){return this.multiply3(Br.scale(t,i))}scale1(t,i){return this.multiply3(Br.scale1(t,i))}det(){return this.data[0]*this.data[4]-this.data[3]*this.data[1]}invert(){let t=this.getInverseMatrix();return new Br(t.data)}rotateD(t){return this.multiply3(Br.rotateD(t))}rotate(t){return this.multiply3(Br.rotate(t))}resetOffset(){let t=this.data;return new Br([t[0],t[1],0,t[3],t[4],0,0,0,1])}setOrigin(t,i){return Br.translate(-t,-i).multiply3(this).translate(t,i)}setOrigin1(t){return this.setOrigin(t.x,t.y)}getInverseMatrix(){return new Br(super.getInverseMatrix().data)}getTransposeMatrix(){let t=super.getTransposeMatrix();return new Br(t.data)}toMatrix4(){let t=this.data;return new Bi([t[0],t[1],0,t[2],t[3],t[4],0,t[5],0,0,1,0,t[6],t[7],0,t[8]])}scaleNum(t){return!t||isNaN(t)?t:t*this.iScale}};Yn.ORIGIN=new Yn,Yn.MIRROR_Y=new Yn([1,0,0,0,-1,0,0,0,1]),Yn.MIRROR_X=new Yn([-1,0,0,0,1,0,0,0,1]),Yn.ROT_90=new Yn([0,1,0,-1,0,0,0,0,1]),Yn.ROT_N90=new Yn([0,-1,0,1,0,0,0,0,1]);var ci=Yn,PU=(e=>(e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE",e))(PU||{}),D_=(e=>(e[e.CW=0]="CW",e[e.CCW=1]="CCW",e))(D_||{}),gf=class{},ab=class ef{constructor(t,i,r){this.p1=t,this.p2=i,this.p3=r}barycentre(){return ef.barycentre(this.p1,this.p2,this.p3)}incentre(){return ef.incentre(this.p1,this.p2,this.p3)}static barycentre(t,i,r){let s=t.x+i.x+r.x,n=t.y+i.y+r.y;return new ae(s/3,n/3)}static incentre(t,i,r){let s=i.sub(r).length(),n=t.sub(r).length(),a=t.sub(i).length(),o=s+n+a,l=s*t.x+n*i.x+a*r.x,h=s*t.y+n*i.y+a*r.y;return new ae(l/o,h/o)}area(){return ef.area(this.p1,this.p2,this.p3)}static area(t,i,r){return this.area2(t.x,t.y,i.x,i.y,r.x,r.y)/2}static area2(t,i,r,s,n,a){return Math.abs(Zi.crossProd2(t,i,r,s,n,a))}scale(t,i){let r=ci.translate(-t.x,-t.y).scale(i).translate1(t),s=this.p1.multiply3(r),n=this.p2.multiply3(r),a=this.p3.multiply3(r);return new ef(s,n,a)}scaleOnBarycentre(t){return this.scale(this.barycentre(),t)}scaleOnIncentre(t){return this.scale(this.incentre(),t)}extend(t){let i=this.incentre(),r=this.p1.add(this.p2).sub(i).scale(1/2),s=r.length(),n=ae.ORIGIN.pointOnRays2(r,s+t).length()/s;return this.scaleOnIncentre(n)}container(t){let i=this.p3.sub(this.p1),r=this.p2.sub(this.p1),s=t.sub(this.p1),n=i.dot(i),a=i.dot(r),o=i.dot(s),l=r.dot(r),h=r.dot(s),c=1/(n*l-a*a),d=(l*o-a*h)*c;if(d<0||d>1)return!1;let f=(n*h-a*o)*c;return f<0||f>1?!1:d+f<=1}};function s_(){return{minDistance:Number.POSITIVE_INFINITY,start:null,end:null}}var Jn=class rl{static getMinDistanceWithoutCross(t,i){let r=s_();return rl.minLine(t,i,r),r.minDistance}static getMinDistance(t,i){return xn(t,i)?0:this.getMinDistanceWithoutCross(t,i)}static getMinLineWithCross(t,i){let r=s_();return rl.minLine(t,i,r),new le(r.start,r.end)}static getMinLine(t,i){return rl.intersection(t,i)||this.getMinLineWithCross(t,i)}static getMinDistanceFromPoint(t,i){let r=s_();if(i instanceof le)this.point2LineMinLine(r,i,t);else if(i instanceof ye)this.point2ArcMinDistance(t,i,r);else throw new Error("not support");return r.minDistance}constructor(t,i){if(this.pt1=t,this.pt2=i,this.minline=rl.intersection(t,i),this.minline)this.minDistance=0;else{let r=s_();rl.minLine(t,i,r),this.minline=new le(r.start,r.end),this.minDistance=r.minDistance}}getDistance(){return this.minDistance}getLine(){return this.minline}static intersection(t,i){let r=xn(t,i);if(r===0)return;let s=new Array;for(let n=0;n<r;n+=2){let a=new ae($[n],$[n+1]);s.push(a)}return s.length>1?new le(s[0],s[1]):new le(s[0],s[0])}static minLine(t,i,r){if(t instanceof le&&i instanceof le)return this.minDistanceForLines(t,i,r);if(t instanceof ye&&i instanceof le)return this.minDistanceForLineAndArc(t,i,r);if(t instanceof le&&i instanceof ye)return this.minDistanceForLineAndArc(i,t,r);if(t instanceof ye&&i instanceof ye)return this.minDistanceForArcs(t,i,r);throw new Error("not support")}static minDistanceForLines(t,i,r){[t.start(),t.end(),i.start(),i.end()].forEach((s,n)=>{n<2?this.point2LineMinLine(r,i,s):this.point2LineMinLine(r,t,s)})}static minDistanceForLineAndArc(t,i,r){this.point2LineMinLine(r,i,t.start()),this.point2LineMinLine(r,i,t.svgEnd);let s=rl.foot(i,t.center);i.bbox().extendOfSize(1e-8).isContains(s)&&this.point2ArcMinLine(r,t,s),this.point2ArcMinLine(r,t,i.start()),this.point2ArcMinLine(r,t,i.end())}static minDistanceForArcs(t,i,r){this.concentricArc(t,i,r),this.point2ArcMinDistance(i.start(),t,r),this.point2ArcMinDistance(i.svgEnd,t,r),this.point2ArcMinDistance(t.start(),i,r),this.point2ArcMinDistance(t.svgEnd,i,r),(Vn(t,i.center)||Vn(i,t.center))&&this.shortestLineForArcs(t,i,r)}static minLineForArcAndLine(t,i,r){let s=t.pointOn(r.angleD(t.center)),n=t.pointOn(t.center.angleD(r));this.arcShortestLine(t,i,r,s),this.arcShortestLine(t,i,r,n)}static arcInnerLineFootSegment(t,i,r){let s=r.distance1(t.center);if(s!==0){let n=t.rx*(r.y-t.center.y)/s+t.center.y,a=t.rx*(r.x-t.center.x)/s+t.center.x;s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=new ae(a,n),i.end=r)}else s=t.rx-s,s<i.minDistance&&(i.minDistance=s,i.start=t.start(),i.end=r)}static shortestLineForArcs(t,i,r){let s=t.center.angleD(i.center),n=i.center.angleD(t.center),a=t.pointOn(s),o=t.pointOn(n),l=i.pointOn(s),h=i.pointOn(n);Vn(t,a)&&(this.arcShortestLine(i,r,a,l),this.arcShortestLine(i,r,a,h)),Vn(t,o)&&(this.arcShortestLine(i,r,o,l),this.arcShortestLine(i,r,o,h)),this.shortestLineForArcs1(t,i,r)}static shortestLineForArcs1(t,i,r){let s=i.start().sub(t.center).normalize(),n=i.end().sub(t.center).normalize(),a=t.start().sub(i.center).normalize(),o=t.end().sub(i.center).normalize(),l=t.center.add(s.mul(t.rx)),h=t.center.add(n.mul(t.rx)),c=i.center.add(a.mul(i.rx)),d=i.center.add(o.mul(i.rx));Vn(t,l)&&ve.greater(i.start().distance2(t.center),0)&&this.arcShortestLine(t,r,i.start(),l),Vn(t,h)&&ve.greater(i.end().distance2(t.center),0)&&this.arcShortestLine(t,r,i.end(),h),Vn(i,c)&&ve.greater(t.start().distance2(i.center),0)&&this.arcShortestLine(i,r,t.start(),c),Vn(i,d)&&ve.greater(t.end().distance2(i.center),0)&&this.arcShortestLine(i,r,t.end(),d)}static concentricArc(t,i,r){if(!(t.center.distance1(i.center)<1e-5&&t.rx===i.rx&&t.ry===i.ry))return;let s=t.start().distance1(i.svgEnd);s<r.minDistance&&(r.minDistance=s,r.start=t.start(),r.end=i.svgEnd),s=i.start().distance1(t.svgEnd),s<r.minDistance&&(r.minDistance=s,r.start=i.start(),r.end=t.svgEnd)}static point2ArcMinDistance(t,i,r){if(Vn(i,t)){let s=i.pointOn(t.angleD(i.center)),n=i.pointOn(i.center.angleD(t));this.arcShortestLine(i,r,t,s),this.arcShortestLine(i,r,t,n)}else this.minLineSegment(r,i.start(),t),this.minLineSegment(r,i.svgEnd,t)}static point2ArcMinLine(t,i,r){if(Vn(i,r)){let s=r.distance1(i.center);s>i.rx||s>i.ry?this.minLineForArcAndLine(i,t,r):this.arcInnerLineFootSegment(i,t,r)}}static point2LineMinLine(t,i,r){let s=rl.foot(i,r);i.bbox().extendOfSize(1e-8).isContains(s)?this.minLineSegment(t,s,r):(this.minLineSegment(t,i.start(),r),this.minLineSegment(t,i.end(),r))}static minLineSegment(t,i,r){let s=i.distance1(r);s<t.minDistance&&(t.minDistance=s,t.start=i,t.end=r)}static arcShortestLine(t,i,r,s){if(!Vn(t,s))return;let n=r.distance1(s);n<i.minDistance&&(i.minDistance=n,i.start=r,i.end=s)}static foot(t,i){if(t.isPoint())return t.start();if(!ve.eq(t.b,0)&&!ve.eq(t.a,0)){let r=t.start(),s=t.direct,n=(i.x-r.x)*s.x+(i.y-r.y)*s.y;return new ae(r.x+s.x*n,r.y+s.y*n)}else return ve.eq(t.b,0)&&!ve.eq(t.a,0)?new ae(t.start().x,i.y):!ve.eq(t.b,0)&&ve.eq(t.a,0)?new ae(i.x,t.start().y):i}};function Vn(e,t){if(ve.eq(e.sweepAngle,360))return!0;let i=_t.regularD(t.angleD(e.center));return e.sweepAngle>0?(ve.less(i,e.startAngle)&&(i+=360),ve.greatereq(e.endAngle(),i)):(ve.greater(i,e.startAngle)&&(i-=360),ve.lesseq(e.endAngle(),i))}var AU=[1,10,100,1e3],nT="http://www.w3.org/2000/svg",aT="http://www.w3.org/1999/xlink",oT="http://www.w3.org/XML/1998/namespace",lT="https://easyeda.com/",Hie=(function(){var e={svg:nT,xlink:aT,xml:oT,c:lT};return e[nT]="svg",e[aT]="xlink",e[oT]="xml",e[lT]="c",e})(),tr=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),jie=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var s=[16,19,3,7,5,1],n=21;n<52;n++)s.push(n+32,n);return s.push(2,6,8,4,17),s})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Nr=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),Vie=(function(){var e=[],t=[];for(var i in tr)if(tr.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(tr[i])}e.sort(),t.sort();var r={},s,n={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case tr.TOPLAYER:s={name:Nr[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case tr.BOTTOMLAYER:s={name:Nr[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case tr.TOPSILKLAYER:s={name:Nr[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case tr.BOTTOMSILKLAYER:s={name:Nr[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case tr.TOPPASTERLAYER:s={name:Nr[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case tr.BOTTOMPASTERLAYER:s={name:Nr[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case tr.TOPSOLDERLAYER:s={name:Nr[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case tr.BOTTOMSOLDERLAYER:s={name:Nr[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case tr.RATLINES:s={name:Nr[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case tr.BOARDOUTLINE:s={name:Nr[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case tr.ALL:s={name:Nr[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case tr.DOCUMENT:s={name:Nr[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case tr.TOPASSEMBLY:s={name:Nr[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case tr.BOTTOMASSEMBLY:s={name:Nr[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case tr.MECHANICAL:s={name:Nr[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case tr.MODEL3D:s={name:Nr[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case tr.LIBBODY:s={name:Nr[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case tr.PADSURFACE:s={name:Nr[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=tr.INNER1&&o<=tr.INNER32?s={name:Nr[o],color:n[o],darkColor:a(n[o]),visible:!1,active:!1,config:!1}:s=null;break}s&&(r[o]=s)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),h=.5,c=Math.min(255,Math.round((l>>16)*h)),d=Math.min(255,Math.round((l>>8&255)*h)),f=Math.min(255,Math.round((l&255)*h)),u=((c<<16)+(d<<8)+f).toString(16);return"#"+("00000"+u).substr(-6).toUpperCase()}return r})(),hT={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,CNCPRINTVIEW:24,PCB2D:31,PCB3D:32},Yie=(function(){var e={};for(let t in hT)e[hT[t]]=t;return e})(),R_=Math.PI*2,v_=Math.PI/2,qie=Math.sin(Math.PI/180);function CU(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=AU[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}function NT(e,t,i){var r=e-t;return i||(i=1e-10),(r>0?r:-r)<i}function LU(e,t,i){var r=c(e)&&c(t)&&c(i);if(!r)return console.warn("Bad arguments"),null;var s=t.x-i.x>0?t.x:i.x,n=t.y-i.y>0?t.y:i.y,a=t.x-i.x>0?i.x:t.x,o=t.y-i.y>0?i.y:t.y,l=e.x,h=e.y;return l<=s+.001&&l>=a-.001&&h<=n+.001&&h>=o-.001;function c(d){return d?(d.x=Number(d.x),d.y=Number(d.y),isNaN(d.x)||isNaN(d.y)?(console.warn("Can not convert to Number, NaN found"),!1):!0):(console.warn("Empty input!"),!1)}}function DU(e,t,i,r,s,n){var a=(s-i)*(e-i)+(n-r)*(t-r),o=(s-i)*(s-i)+(n-r)*(n-r),l=a/o,h=i+(s-i)*l,c=r+(n-r)*l;return a<=0?Math.sqrt((e-i)*(e-i)+(t-r)*(t-r)):a>=o?Math.sqrt((e-s)*(e-s)+(t-n)*(t-n)):Math.sqrt((e-h)*(e-h)+(c-t)*(c-t))}function RU(e,t,i){return LU(e,t,i)?NT((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.001):!1}var tf=1e-4,$=new Float64Array(100);function xn(e,t){if(e instanceof le&&t instanceof le)return Aa(e,t);if(e instanceof ye&&t instanceof le)return ob(e,t);if(e instanceof le&&t instanceof ye)return ob(t,e);if(e instanceof ye&&t instanceof ye)return BT(e,t);if(e instanceof Ye&&t instanceof Ye)return p_(e,t);if(e instanceof Ye&&t instanceof le)return p_(e,new Ye([t.start(),t.end()]));if(e instanceof le&&t instanceof Ye)return p_(new Ye([e.start(),e.end()]),t);if(e instanceof Ye&&t instanceof ye)return _T(t,e);if(e instanceof ye&&t instanceof Ye)return _T(e,t);throw new Error("not supported operation")}function NU(e,t){let i=e.bbox();if(i.isContainsY1(t)){let r=new le(new ae(i.minX-1,t),new ae(i.maxX+1,t));return Aa(r,e)>0?1:0}else return 0}function MU(e,t){if(e.rx===e.ry){let i=e.bbox();if(i.isContainsY1(t)){let r=new le(new ae(i.minX-1,t),new ae(i.maxX+1,t));return x_(e,r)>0?1:0}else return 0}else throw new Error("not supported operation")}function cT(e,t){let i=e.bbox();return i.isContainsY1(t)&&p_(new Ye([new ae(i.minX-1,t),new ae(i.maxX+1,t)]),e)>0?1:0}function uT(e,t,i){return isFinite(t)&&isFinite(i)?e.isContains2(t,i):!1}function BU(e,t){let i=t.length(),r=Zi.crossProd3(t.start(),t.end(),e.start())/i,s=Zi.crossProd3(t.start(),t.end(),e.end())/i;return Math.abs(r)<1e-8||Math.abs(s)<1e-8||r*s<0}function Aa(e,t){let i=e.bbox().intersection1(t.bbox());if(!i)return 0;if(e.isPoint())if(t.isPoint()){let r=i.center();return $[0]=r.x,$[1]=r.y,2}else return dT(t,e,i);else{if(t.isPoint())return dT(e,t,i);{let r=function(O,b){i.isContains2(O,b)&&($[m++]=O,$[m++]=b)};if(!BU(e,t))return 0;let s=e.start().x,n=e.start().y,a=e.end().x,o=e.end().y,l=t.start().x,h=t.start().y,c=t.end().x,d=t.end().y,f=t.length(),u=Zi.crossProd2(s,n,l,h,c,d)/f,p=Zi.crossProd2(a,o,l,h,c,d)/f;if(u*p>0&&!ve.eq(u,0)&&!ve.eq(p,0))return 0;let g=e.length(),_=Zi.crossProd2(l,h,s,n,a,o)/g,y=Zi.crossProd2(c,d,s,n,a,o)/g;if(_*y>0&&!ve.eq(_,0)&&!ve.eq(y,0))return 0;let m=0;if(ve.eq(u,0)&&ve.eq(p,0)){let O=i.UL(),b=i.UR(),v=i.LL(),E=i.LR();if(ve.eq(i.width(),0))ve.eq(i.height(),0)?($[m++]=O.x,$[m++]=O.y):($[m++]=O.x,$[m++]=O.y,$[m++]=v.x,$[m++]=v.y);else if(ve.eq(i.height(),0))$[m++]=O.x,$[m++]=O.y,$[m++]=b.x,$[m++]=b.y;else{let T=ab.area2(O.x,O.y,l,h,c,d),P=ab.area2(b.x,b.y,l,h,c,d);T<P?($[m++]=O.x,$[m++]=O.y,$[m++]=E.x,$[m++]=E.y):($[m++]=b.x,$[m++]=b.y,$[m++]=v.x,$[m++]=v.y)}}else if(ve.eq(u,0))r(s,n);else if(ve.eq(p,0))r(a,o);else{let O=Math.abs(u/(u-p));r(s+(a-s)*O,n+(o-n)*O)}return m}}}function dT(e,t,i){let r=t.start(),s=t.end(),n=Zi.crossProd3(e.start(),e.end(),t.start()),a=Zi.crossProd3(e.start(),e.end(),t.end());if(n*a<0){let o=i.center();return $[0]=o.x,$[1]=o.y,2}else if(Math.abs(n)<Math.abs(a)){if(ve.eq(n/e.length(),0))return $[0]=r.x,$[1]=r.y,2}else if(ve.eq(a/e.length(),0))return $[0]=s.x,$[1]=s.y,2;return 0}function x_(e,t){let i=e.bbox().intersection1(t.bbox());if(i!=null){i=i.extendOfSize(tf);let r=e.center.x,s=e.center.y,n=e.rx,a=e.rx2,o=t.start().x,l=t.start().y,h=t.end().x,c=t.end().y,d=e.center.distance1(t.start()),f=e.center.distance1(t.end()),u=ve.eq(d,n)?0:d>n?1:-1,p=ve.eq(f,n)?0:f>n?1:-1,g=0;if(u===-1&&p===-1)return 0;if(u===0&&p===0)$[g++]=o,$[g++]=l,$[g++]=h,$[g++]=c;else if(u===1&&p===1){let _=Jn.foot(t,e.center),y=_.distance1(e.center);if(ve.greater(y,n))return 0;if(ve.eq(y,n))ve.eq(t.distance2(e.start()),0)?($[g++]=e.start().x,$[g++]=e.start().y,$[g++]=e.start().x,$[g++]=e.start().y):ve.eq(t.distance2(e.end()),0)?($[g++]=e.end().x,$[g++]=e.end().y,$[g++]=e.end().x,$[g++]=e.end().y):($[g++]=_.x,$[g++]=_.y,$[g++]=_.x,$[g++]=_.y);else{g=MT(r,s,o,l,h,c,g,_);let m=$[g-2],O=$[g-1];g-=2;let b=Zi.distance1(r,s,m,O);if(ve.eq(b,n))$[g++]=m,$[g++]=O,$[g++]=m,$[g++]=O;else if(b<n)g=Tr(a,r,s,o,l,m,O,g),g=Tr(a,r,s,m,O,h,c,g);else return 0}}else if(u===-1||p===-1)g=Tr(a,r,s,o,l,h,c,g);else{let _=Jn.foot(t,e.center),y=_.distance1(e.center);if(ve.eq(y,n)){let m=function(v){return uT(i,v.x,v.y)&&Ji(e,v)},O=e.start(),b=e.end();if(u===0){let v=t.start();if(m(v))return $[g++]=v.x,$[g++]=v.y,$[g++]=v.x,$[g++]=v.y,g;if(m(_))return $[g++]=_.x,$[g++]=_.y,$[g++]=_.x,$[g++]=_.y,g;if(ve.eq(t.distance2(O),0)&&m(O))return $[g++]=O.x,$[g++]=O.y,$[g++]=O.x,$[g++]=O.y,g;if(ve.eq(t.distance2(b),0)&&m(b))return $[g++]=b.x,$[g++]=b.y,$[g++]=b.x,$[g++]=b.y,g;if(d<=n)g=Tr(a,r,s,_.x,_.y,h,c,g),g===2&&($[g++]=$[0],$[g++]=$[1]);else if(y<n){if(g=Tr(a,r,s,_.x,_.y,h,c,g),g===2&&m(new ae($[0],$[1])))return $[g++]=$[0],$[g++]=$[1],g;g=Tr(a,r,s,_.x,_.y,o,l,0),g===2&&($[g++]=$[0],$[g++]=$[1])}}else{let v=t.end();if(m(v))return $[g++]=v.x,$[g++]=v.y,$[g++]=v.x,$[g++]=v.y,g;if(m(_))return $[g++]=_.x,$[g++]=_.y,$[g++]=_.x,$[g++]=_.y,g;if(ve.eq(t.distance2(O),0)&&m(O))return $[g++]=O.x,$[g++]=O.y,$[g++]=O.x,$[g++]=O.y,g;if(ve.eq(t.distance2(b),0)&&m(b))return $[g++]=b.x,$[g++]=b.y,$[g++]=b.x,$[g++]=b.y,g;if(f<=n)g=Tr(a,r,s,_.x,_.y,o,l,g),g===2&&($[g++]=$[0],$[g++]=$[1]);else if(y<n){if(g=Tr(a,r,s,_.x,_.y,o,l,g),g===2&&m(new ae($[0],$[1])))return $[g++]=$[0],$[g++]=$[1],g;g=Tr(a,r,s,_.x,_.y,h,c,0),g===2&&($[g++]=$[0],$[g++]=$[1])}}}else if(u===0){let m=t.start();$[g++]=m.x,$[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=Tr(a,r,s,_.x,_.y,h,c,g))}else{let m=t.end();$[g++]=m.x,$[g++]=m.y,(o-_.x)*(h-_.x)+(l-_.y)*(c-_.y)<0&&(g=Tr(a,r,s,_.x,_.y,o,l,g))}}if(g>0){let _=0;for(let y=0;y<g;y+=2){let m=$[y],O=$[y+1];isFinite(m)&&isFinite(O)&&uT(i,m,O)&&Ji(e,new ae(m,O))&&($[_++]=m,$[_++]=O)}return _}else return 0}else return 0}function kU(e,t){if(e.bbox()){let i=e.center.x,r=e.center.y,s=e.rx2,n=t.start().x,a=t.start().y,o=t.end().x,l=t.end().y,h=e.center.distance2(t.start()),c=e.center.distance2(t.end()),d=ve.eq(h,s)?0:h>s?1:-1,f=ve.eq(c,s)?0:c>s?1:-1,u=0;if(d===-1&&f===-1)return 0;if(d===0&&f===0)$[u++]=n,$[u++]=a,$[u++]=o,$[u++]=l;else if(d===1&&f===1){let p=Jn.foot(t,e.center),g=p.distance2(e.center);if(ve.greater(g,s))return 0;if(ve.eq(g,s)){let _=p.distance2(e.start()),y=p.distance2(e.end());ve.eq(_,0)?($[u++]=e.start().x,$[u++]=e.start().y):ve.eq(y,0)?($[u++]=e.end().x,$[u++]=e.end().y):($[u++]=p.x,$[u++]=p.y)}else{u=MT(i,r,n,a,o,l,u,p);let _=$[u-2],y=$[u-1],m=Zi.distance2(i,r,_,y);if(u-=2,ve.eq(m,s))$[u++]=_,$[u++]=y;else if(m<s)u=Tr(s,i,r,n,a,_,y,u),u=Tr(s,i,r,_,y,o,l,u);else return 0}}else if(d===-1||f===-1)u=Tr(s,i,r,n,a,o,l,u);else{let p=Jn.foot(t,e.center);d===0?($[u++]=t.start().x,$[u++]=t.start().y,ve.neq(p.distance2(t.start()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=Tr(s,i,r,p.x,p.y,o,l,u))):($[u++]=t.end().x,$[u++]=t.end().y,ve.neq(p.distance2(t.end()),0)&&(n-p.x)*(o-p.x)+(a-p.y)*(l-p.y)<0&&(u=Tr(s,i,r,p.x,p.y,n,a,u)))}if(u>0){let p=0;for(let g=0;g<u;g+=2){let _=$[g],y=$[g+1];isFinite(_)&&isFinite(y)&&($[p++]=_,$[p++]=y)}return p}else return 0}else return 0}function Tr(e,t,i,r,s,n,a,o){if(s==a){let m=e-(s-i)*(s-i);if(ve.greater(m,0)){let O=Math.sqrt(m),b=t-O,v=t+O,E=Math.min(r,n),T=Math.max(r,n);return b>=E&&b<=T&&($[o++]=b,$[o++]=s),v>=E&&v<=T&&($[o++]=v,$[o++]=s),o}}let l=Zi.distance2(r,s,t,i)-e;if(l===0)return $[o++]=r,$[o++]=s,o;let h=Zi.distance2(n,a,t,i)-e;if(h===0)return $[o++]=n,$[o++]=a,o;if(l<0&&h<0)return l>h?ve.eq(l,0)&&($[o++]=r,$[o++]=s):ve.eq(h,0)&&($[o++]=n,$[o++]=a),o;if(l>0&&h>0&&(r-t)*(n-t)+(s-i)*(a-i)>0)return l<h?ve.eq(l,0)&&($[o++]=r,$[o++]=s):ve.eq(h,0)&&($[o++]=n,$[o++]=a),o;let c=r,d=s,f=n,u=a,p=NaN,g=NaN,_=Number.POSITIVE_INFINITY,y=0;for(;_!==0;){y++;let m=Math.max(Math.min(Math.abs(l)/(Math.abs(l)+Math.abs(h)),.75),.25);if(p=c+(f-c)*m,g=d+(u-d)*m,c===p&&d===g||f===p&&u===g){Math.abs(l)>Math.abs(h)?(p=f,g=u,_=h):(p=c,g=d,_=l);break}else _=Zi.distance2(p,g,t,i)-e,(_<0?l>h:l<h)?(f=p,u=g,h=_):(c=p,d=g,l=_)}return $[o++]=p,$[o++]=g,o}function MT(e,t,i,r,s,n,a,o){let l=Zi.dotProd2(i,r,s,n,e,t),h=Zi.dotProd2(s,n,i,r,e,t);if(l>=0)return $[a++]=s,$[a++]=n,a;if(h>=0)return $[a++]=i,$[a++]=r,a;if(Zi.crossProd2(i,r,s,n,e,t)==0)return $[a++]=e,$[a++]=t,a;{let c=NaN,d=NaN,f=i,u=r,p=s,g=n,_=Zi.distance2(i,r,e,t),y=Zi.distance2(s,n,e,t),m=Number.POSITIVE_INFINITY,O=0;for(;m>0&&(O++,c=f+(p-f)*.5,d=u+(g-u)*.5,!(_==y||f==c&&u==d||p==c&&g==d));){m=Zi.distance2(c,d,e,t);let b=Zi.dotProd2(f,u,c,d,e,t);if(b==0)break;b<0?(p=c,g=d,y=m):(f=c,u=d,_=m)}return Zi.distance2(c,d,e,t)<Zi.distance2(o.x,o.y,e,t)?($[a++]=c,$[a++]=d):($[a++]=o.x,$[a++]=o.y),a}}function ob(e,t){if(e.rx===e.ry)return x_(e,t);throw new Error("not supported")}function FU(e,t){if(e.rx===e.ry)return kU(e,t);throw new Error("not supported")}function BT(e,t){if(e.bbox().intersection1(t.bbox())!=null){if(e.rx===e.ry&&t.rx===t.ry)return UU(e,t);throw new Error("not supported operation")}return 0}function UU(e,t){let i=e.center.x,r=e.center.y,s=t.center.x,n=t.center.y,a=e.rx,o=t.rx,l=e.rx2,h=t.rx2,c=e.center.distance1(t.center),d=Math.abs(a-o),f=a+o;if(ve.greater(c,f)||ve.less(c,d))return 0;if(ve.eq(d+c,0)){let u=0,p;return Ji(e,t.start())&&($[u]=t.start().x,$[u+1]=t.start().y,u+=2,p=t.start()),Ji(e,t.end())&&($[u]=t.end().x,$[u+1]=t.end().y,u+=2,p=t.end()),u===0?(Ji(t,e.start())&&($[u]=e.start().x,$[u+1]=e.start().y,u+=2),Ji(t,e.end())&&($[u]=e.end().x,$[u+1]=e.end().y,u+=2)):u===2&&(!p.equals1(e.start())&&Ji(t,e.start())&&($[u]=e.start().x,$[u+1]=e.start().y,u+=2),!p.equals1(e.end())&&Ji(t,e.end())&&($[u]=e.end().x,$[u+1]=e.end().y,u+=2)),u}else if(ve.eq(c,f)){if(fT(e,t))return 4;let u=new le(e.center,t.center),p=x_(t,u);return p=pT(e,p),p!==0?p:(p=x_(e,u),pT(t,p))}else if(ve.eq(c,d)){if(fT(e,t))return 4;if(a>o){let u=(a-o)/a;return $[0]=i+(s-i)/u,$[1]=r+(n-r)/u,gT(e,t,2)}else{let u=(o-a)/o;return $[0]=s+(i-s)/u,$[1]=n+(r-n)/u,gT(e,t,2)}}else{let u,p;if(e.rx>t.rx){let A=(e.center.distance2(t.center)-l+h)/(c*2)/c;u=(i-s)*A+s,p=(r-n)*A+n}else{let A=(e.center.distance2(t.center)-h+l)/(c*2)/c;u=(s-i)*A+i,p=(n-r)*A+r}let g=s-i,_=n-r,y=Math.max(a,o)*2,m,O,b,v;if(Math.abs(g)<Math.abs(_)){let A=g/-_,C=p-A*u;m=u-y,O=A*m+C,b=u+y,v=A*b+C}else{let A=_/-g,C=u-A*p;O=p-y,m=A*O+C,v=p+y,b=A*v+C}let E;if(e.rx>t.rx?(E=Tr(h,s,n,m,O,u,p,0),E=Tr(h,s,n,u,p,b,v,E)):(E=Tr(l,i,r,m,O,u,p,0),E=Tr(l,i,r,u,p,b,v,E)),E!==4)throw new Error("cnt !== 4");let T=new ae($[0],$[1]),P=new ae($[2],$[3]);if(Ji(e,T)&&Ji(t,T))return Ji(e,P)&&Ji(t,P)?4:il(e.start(),t,P,T)?($[2]=e.start().x,$[3]=e.start().y,4):il(e.end(),t,P,T)?($[2]=e.end().x,$[3]=e.end().y,4):il(t.start(),e,P,T)?($[2]=t.start().x,$[3]=t.start().y,4):il(t.end(),e,P,T)?($[2]=t.end().x,$[3]=t.end().y,4):2;if(Ji(e,P)&&Ji(t,P))return il(e.start(),t,T,P)?($[0]=e.start().x,$[1]=e.start().y,4):il(e.end(),t,T,P)?($[0]=e.end().x,$[1]=e.end().y,4):il(t.start(),e,T,P)?($[0]=t.start().x,$[1]=t.start().y,4):il(t.end(),e,T,P)?($[0]=t.end().x,$[1]=t.end().y,4):($[0]=$[2],$[1]=$[3],2);{let A=function(k,F){if(ve.eq(k.distance1(F.center),F.rx)&&Ji(F,k)){if(k.distance2(T)<k.distance2(P)){if(C)return;C=!0}else{if(M)return;M=!0}$[H++]=k.x,$[H++]=k.y}},C=!1,M=!1,H=0;return A(e.start(),t),A(e.end(),t),A(t.start(),e),A(t.end(),e),H}}}function il(e,t,i,r){return ve.eq(e.distance1(t.center),t.rx)&&Ji(t,e)&&e.distance2(i)<e.distance2(r)}function fT(e,t){return ve.eq(t.start().distance1(e.center),e.rx)&&Ji(e,t.start())?($[0]=t.start().x,$[1]=t.start().y,$[2]=t.start().x,$[3]=t.start().y,!0):ve.eq(t.end().distance1(e.center),e.rx)&&Ji(e,t.end())?($[0]=t.end().x,$[1]=t.end().y,$[2]=t.end().x,$[3]=t.end().y,!0):ve.eq(e.start().distance1(t.center),t.rx)&&Ji(t,e.start())?($[0]=e.start().x,$[1]=e.start().y,$[2]=e.start().x,$[3]=e.start().y,!0):ve.eq(e.end().distance1(t.center),t.rx)&&Ji(t,e.end())?($[0]=e.end().x,$[1]=e.end().y,$[2]=e.end().x,$[3]=e.end().y,!0):!1}function pT(e,t){if(t===0)return 0;let i=$[0],r=$[1];return Ji(e,new ae(i,r))?($[0]=i,$[1]=r,$[2]=i,$[3]=r,4):0}function gT(e,t,i){if(i===0)return 0;let r=$[0],s=$[1],n=new ae(r,s);return Ji(e,n)&&Ji(t,n)?($[0]=r,$[1]=s,$[2]=r,$[3]=s,4):0}function Lc(e,t){return Math.abs(e-t)<=1e-6}function Ji(e,t){let i=e.bbox();if(t.x-i.minX>-tf&&t.x-i.maxX<tf&&t.y-i.minY>-tf&&t.y-i.maxY<tf){let r=_t.regularD(t.angleD(e.center));return Lc(r,e.startAngle)||Lc(r,e.startAngle+360)||Lc(r,e.startAngle-360)||Lc(r,e.endAngle())||Lc(r,e.endAngle()+360)||Lc(r,e.endAngle()-360)?!0:e.sweepAngle>0?(ve.less(r,e.startAngle)&&(r+=360),ve.greatereq(e.endAngle(),r)):(ve.greater(r,e.startAngle)&&(r-=360),ve.lesseq(e.endAngle(),r))}else return!1}function GU(e,t){let i=e[1].x-e[0].x,r=e[1].y-e[0].y,s=t[1].x-t[0].x,n=t[1].y-t[0].y;if(i===0&&s!==0||i!==0&&s===0)return!1;if(i===0&&s===0)return!0;let a=r/i,o=n/s;return NT(a,o,Math.sin(Math.PI/180))}function zU(e,t,i){var r,s=+t.x,n=+t.y,a=+i.x,o=+i.y,l=+e.x,h=+e.y,c=a-s,d=o-n,f=l-s,u=h-n,p,g,_,y,m,O;return c===0&&d===0?{d:Math.sqrt(f*f+u*u),point:new ae(s,n)}:(r=(f*c+u*d)/(c*c+d*d),r<0?{d:Math.sqrt(f*f+u*u),point:new ae(s,n)}:r>1?(p=l-a,g=h-o,{d:Math.sqrt(p*p+g*g),point:new ae(a,o)}):(m=s+r*c,O=n+r*d,_=l-m,y=h-O,{d:Math.sqrt(_*_+y*y),point:new ae(m,O)}))}function Xn(e,t){if(!e||!t||e.length!=t.length)return!1;let i="equals1";return!e.some((r,s)=>{let n=t[s],a=!1;return r&&n&&typeof r=="object"&&typeof n=="object"?typeof r[i]=="function"&&jU(r,n)?a=!r[i].call(r,n):a=!(r===n||r.toString()===n.toString()):typeof r=="number"&&typeof n=="number"?a=!(HU(r,n)||Number.isNaN(r)&&Number.isNaN(n)):a=r!==n,a})}function HU(e,t,i=5){return Math.abs(e-t)*Math.pow(10,i)<1}function jU(e,t){return!e||!t||typeof e!="object"||typeof t!="object"?e===t:e.constructor===t.constructor}var Tt=new Float64Array(100);function p_(e,t){if(e.bbox().extendOfSize(ve.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=Aa(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a($[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(ve.eq(Tt[L],Tt[R])&&ve.eq(Tt[L+1],Tt[R+1])){Tt[R]=(Tt[L]+Tt[R])/2,Tt[R+1]=(Tt[L+1]+Tt[R+1])/2;for(let x=s-3;x>=L;x--)Tt[x]=Tt[x+2];s-=2;break}if(s>r){s=0;let L=t.start(),R=new Float64Array(8);e.getPercent(L)!==null&&(R[s++]=L.x,R[s++]=L.y);let x=t.end();e.getPercent(x)!==null&&(R[s++]=x.x,R[s++]=x.y);let I=e.start();t.getPercent(I)!==null&&(R[s++]=I.x,R[s++]=I.y);let S=e.end();return t.getPercent(S)!==null&&(R[s++]=S.x,R[s++]=S.y),$.set(R),s}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=Aa(new le(c[0],c[1]),new le(d[0],d[1]));for(let R=0;R<L;R++)Tt[s++]=$[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),ve.eq(m,O)){if(h.controls.length===2){let L=Aa(new le(l.start(),l.end()),new le(h.start(),h.end()));for(let R=0;R<L;R++)Tt[s++]=$[R];if(L!==0)continue}l=new Ye([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(ve.less(L,m))v=v|1;else if(ve.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(ve.less(R,E))v=v|1;else if(ve.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=ve.eps&&(n=ve.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new le(new ae(0,m),new ae(1,m)),F=new le(new ae(0,O),new ae(1,O));for(let L=0;L<b.length-1;L++){let R=new ae(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new ae(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new le(R,S),k),o(new le(R,S),F)):o(new le(R,S),k):x===2?D===1?(o(new le(R,S),k),o(new le(R,S),F)):o(new le(R,S),F):D===1?o(new le(R,S),k):o(new le(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(ve.eq(j.minX,j.maxX)&&ve.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(ve.less(R,E))v=v|1;else if(ve.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new ae((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(Tt[s++]=L.x,Tt[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)$[a]=Tt[a];return s}function VU(e,t){if(e.bbox().extendOfSize(ve.eps).isSeparated(t.bbox()))return{cnt:0};let i=[[e,t]],r=(e.controls.length-1)*(t.controls.length-1)*8,s=0,n=Number.POSITIVE_INFINITY;for(;i.length!==0;){let a=function(L){M=Math.min(M,L),H=Math.max(H,L)},o=function(L,R){let x=Aa(L,R);if(x===0)throw new Error("cnt === 0");for(let I=0;I<x;I+=2)a($[I])};if(s>r){for(let L=s-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(ve.eq(Tt[L],Tt[R])&&ve.eq(Tt[L+1],Tt[R+1])){Tt[R]=(Tt[L]+Tt[R])/2,Tt[R+1]=(Tt[L+1]+Tt[R+1])/2;for(let x=s-3;x>=L;x--)Tt[x]=Tt[x+2];s-=2;break}if(s>r){s=0;let L=new Float64Array(8),R=t.end(),x=0;e.getPercent(R)!==null&&(L[s++]=R.x,L[s++]=R.y,x=2);let I=e.end();return t.getPercent(I)!==null&&(L[s++]=I.x,L[s++]=I.y,x=x===0?1:3),$.set(L),{havOverlap:x,cnt:s}}}let[l,h]=i.pop(),c=l.controls,d=h.controls;if(c.length===2&&d.length===2){let L=Aa(new le(c[0],c[1]),new le(d[0],d[1]));for(let R=0;R<L;R++)Tt[s++]=$[R];continue}let f=c[0],u=c[c.length-1];f.equals1(u)&&(u=f.add1(1,0));let p=u.y-f.y,g=f.x-u.x,_=-p*f.x-g*f.y,y=Math.sqrt(1/(p**2+g**2));p*=y,g*=y,_*=y;let m=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;if(c.forEach(L=>{let R=p*L.x+g*L.y+_;R<m&&(m=R),R>O&&(O=R)}),ve.eq(m,O)){if(h.controls.length===2){let L=Aa(new le(l.start(),l.end()),new le(h.start(),h.end()));for(let R=0;R<L;R++)Tt[s++]=$[R];if(L!==0)continue}l=new Ye([c[0],c[c.length-1]]),c=l.controls}let b=d.map(L=>{let R=p*L.x+g*L.y+_,x=Math.abs(R);return x<n&&(n=x),R}),v=0;for(let L of b){if(ve.less(L,m))v=v|1;else if(ve.greater(L,O))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let E=0,T=0,P=u.x-f.x,A=u.y-f.y,C=Math.sqrt(1/(P**2+A**2));P*=C,A*=C;for(let L=1;L<c.length;L++){let R=c[L],x=(R.x-f.x)*P+(R.y-f.y)*A;x<E?E=x:x>T&&(T=x)}v=0;for(let L of d){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(ve.less(R,E))v=v|1;else if(ve.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v!==3)continue;let M=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY;n/=2,n<=ve.eps&&(n=ve.eps),m-=n,O+=n,b.forEach((L,R)=>{L>=m&&L<=O&&a(R/(b.length-1))});let k=new le(new ae(0,m),new ae(1,m)),F=new le(new ae(0,O),new ae(1,O));for(let L=0;L<b.length-1;L++){let R=new ae(L/(b.length-1),b[L]),x=R.y<m?1:R.y>O?2:3;for(let I=0;I<b.length;I++){let S=new ae(I/(b.length-1),b[I]),D=S.y<m?1:S.y>O?2:3;x!==D&&(x===1?D===2?(o(new le(R,S),k),o(new le(R,S),F)):o(new le(R,S),k):x===2?D===1?(o(new le(R,S),k),o(new le(R,S),F)):o(new le(R,S),F):D===1?o(new le(R,S),k):o(new le(R,S),F))}}M!==0&&(h=h.clip(M)[1]),H!==1&&(h=h.clip((H-M)/(1-M))[0]);let j=h.bbox();if(ve.eq(j.minX,j.maxX)&&ve.eq(j.minY,j.maxY)){v=0;for(let L of h.controls){let R=(L.x-f.x)*P+(L.y-f.y)*A;if(ve.less(R,E))v=v|1;else if(ve.greater(R,T))v=v|2;else{v=3;break}if(v===3)break}if(v===3){let L=new ae((j.minX+j.maxX)/2,(j.minY+j.maxY)/2);l.getPercent(L)&&(Tt[s++]=L.x,Tt[s++]=L.y)}continue}if(H-M>.8){let[L,R]=h.clip(.5);i.push([L,l]),i.push([R,l])}else i.push([h,l])}for(let a=0;a<s;a++)$[a]=Tt[a];return{cnt:s}}var YU=class{constructor(e=ve.eps){this.eps=e}eq(e,t){return Math.abs(e-t)<=this.eps}setEps(e){this.eps=e}},Kd=new YU;function _T(e,t){if(e.bbox().extendOfSize(ve.eps).isSeparated(t.bbox()))return 0;let i=[[e,t]],r=(t.controls.length-1)*16,s=0;for(;i.length!==0;){if(s>r){let a=function(){for(let h=0;h<s;h+=2)for(let c=h+2;c<s;c+=2)if(!(Kd.eq(Tt[h],Tt[c])&&Kd.eq(Tt[h+1],Tt[c+1]))){l(Tt[c],Tt[c+1],o);break}function l(h,c,d){let f=!1;for(let u=0;u<d.length;u+=2)if(Kd.eq(h,d[u])&&Kd.eq(c,d[u+1])){f=!0;break}f||d.push(h,c)}},o=[Tt[0],Tt[1]];if(a(),o.length>=100&&(Kd.setEps(.001),o=[Tt[0],Tt[1]],a(),o.length>=100))throw new Error("clearSamePoint()");s=o.length,o.forEach((l,h)=>Tt[h]=l)}let n=i.pop();if(n[0]instanceof ye){let a=function(F){A=Math.min(A,F),C=Math.max(C,F)},o=function(F,j){let L=Aa(F,j);if(L===0)throw new Error("cnt === 0");for(let R=0;R<L;R+=2)a($[R])},[l,h]=n,c=h.controls;if(c.length===2){let F=ob(l,new le(c[0],c[1]));for(let j=0;j<F;j++)Tt[s++]=$[j];continue}let d=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,u,p,g,_,y;if(Math.abs(l.sweepAngle)>359){let F=l.rx;u=l.center.add1(F,0),p=l.center.add1(-F,0),d=-F,f=F,g=0,_=1,y=-l.center.y}else{u=l.start(),p=l.end(),g=p.y-u.y,_=u.x-p.x,y=-g*u.x-_*u.y;let F=Math.sqrt(1/(g**2+_**2));g*=F,_*=F,y*=F;let j=g*l.center.x+_*l.center.y+y;l.isCCW?(f=l.rx+j,d=0):(d=j-l.rx,f=0)}let m=c.map(F=>g*F.x+_*F.y+y),O=0;for(let F of m){if(ve.less(F,d))O=O|1;else if(ve.greater(F,f))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let b=0,v=0,E=p.x-u.x,T=p.y-u.y,P=Math.sqrt(1/(E**2+T**2));if(E*=P,T*=P,Math.abs(l.sweepAngle)<=180)b=0,v=(p.x-u.x)*E+(p.y-u.y)*T;else throw new Error("not support");O=0;for(let F of c){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(ve.less(j,b))O=O|1;else if(ve.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}if(O!==3)continue;let A=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;d-=ve.eps,f+=ve.eps,m.forEach((F,j)=>{F>=d&&F<=f&&a(j/(m.length-1))});let M=new le(new ae(0,d),new ae(1,d)),H=new le(new ae(0,f),new ae(1,f));for(let F=0;F<m.length-1;F++){let j=new ae(F/(m.length-1),m[F]),L=j.y<d?1:j.y>f?2:3;for(let R=0;R<m.length;R++){let x=new ae(R/(m.length-1),m[R]),I=x.y<d?1:x.y>f?2:3;L!==I&&(L===1?I===2?(o(new le(j,x),M),o(new le(j,x),H)):o(new le(j,x),M):L===2?I===1?(o(new le(j,x),M),o(new le(j,x),H)):o(new le(j,x),H):I===1?o(new le(j,x),M):o(new le(j,x),H))}}A!==0&&(h=h.clip(A)[1]),C!==1&&(h=h.clip((C-A)/(1-A))[0]);let k=h.bbox();if(ve.eq(k.minX,k.maxX)&&ve.eq(k.minY,k.maxY)){O=0;for(let F of h.controls){let j=(F.x-u.x)*E+(F.y-u.y)*T;if(ve.less(j,b))O=O|1;else if(ve.greater(j,v))O=O|2;else{O=3;break}if(O===3)break}O===3&&(Tt[s++]=(k.minX+k.maxX)/2,Tt[s++]=(k.minY+k.maxY)/2);continue}C-A>.8?h.clip(.5).forEach(F=>i.push([F,l])):i.push([h,l])}else{let[a,o]=n;i.push([ye.build3(o.center,o.startAngle,o.sweepAngle/2,o.rx,o.ry),a]),i.push([ye.build3(o.center,o.startAngle+o.sweepAngle/2,o.sweepAngle/2,o.rx,o.ry),a])}}for(let n=0;n<s;n++)$[n]=Tt[n];return s}var qU=class{static getSweep(e){if(e.length>2){let t=0,i=e.length;for(let n=0;n<i-1;n++){let a=e[n],o=e[n+1];t+=(o.x+a.x)*(o.y-a.y)}let r=e[0],s=e[i-1];return t+=(r.x+s.x)*(r.y-s.y),t>0}else throw new Error("Unable to determine the direction of rotation!")}static isClose(e){return!!(e.primitives.length>0&&e.primitives[0].start().equals1(e.primitives[e.primitives.length-1].end()))}};function WU(e){let t=e.primitives,i=t[0],r=i instanceof ye?i.sweepAngle%360:null;if(t.length===1&&i instanceof ye&&(ve.eq(r,0)||ve.eq(Math.abs(r),360)))return!!i.isCCW;let s=new Array;return e.points(.1,n=>{s.push(n)}),qU.getSweep(s)}var XU=class{static zoomCorner(e,t){let i=new Array,r=new Array,s=new Array;return this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?It.build2(r):null}static zoomPolygon(e,t){let i=new Array,r=new Array,s=new Array;return WU(e)&&(e=e.reverse().asClose()),this.getPanPrimitive(e,i,s,t),this.rearrange(i,s),this.processStart(i,s),this.getResult(i,s,r,t),r.length>0?It.build2(r):null}static zoomLines(e,t){return this.zoomPolygon(It.build2(e.primitives.concat(e.reverse().primitives)),t/2)}static getPanPrimitive(e,t,i,r){let s=e.primitives;for(let n of s){let a=this.panDistance(n,r);a!==void 0&&(t.push(a),i.push(n))}}static rearrange(e,t){let i=e.length,r=0;for(let a=0;a<i;a++){let o=t[a],l=e[a],h=a==i-1?e[0]:e[a+1];if(!(l instanceof ye&&h instanceof ye)&&!this.isCW(l.end(),h.start(),o.end())){if(xn(l,h)!=0){r=a==i-1?0:a+1;break}}else{r=a;break}}let s=this.start4Index(t,r),n=this.start4Index(e,r);t.length=0,e.length=0,s.forEach(a=>{t.push(a)}),n.forEach(a=>{e.push(a)})}static processStart(e,t){let i=e.length;if(i>2){let r=e[i-1],s=e[0],n=t[i-1];if(!(r instanceof ye&&s instanceof ye)&&!this.isCW(r.end(),s.start(),n.end())){let a=xn(r,s);for(let o=0;o<a;o+=2){let l=new ae($[o],$[o+1]);e[i-1]=this.generatePrimitive(r,r.start(),l),e[0]=this.generatePrimitive(s,l,s.end())}}}}static getResult(e,t,i,r){let s=e.length;for(let n=0;n<s;n++){let a=t[n],o=n===s-1?t[0]:t[n+1],l=n==s-1?0:n+1,h=l==s-1?t[0]:t[l+1],c=e[n],d=n==s-1?e[0]:e[n+1],f=l==s-1?e[0]:e[l+1];if(!(c instanceof ye&&d instanceof ye)&&!this.isCW(c.end(),d.start(),a.end())){let p=this.add(e,i,n,c,d,0);p=this.update(e,i,n,d,p);let g=this.generateArc(o,h,d,f,r);if(p=this.add(e,i,n,c,g,p),p=this.update(e,i,n,g,p),p>0)continue}i.push(c);let u=this.generateArc(a,o,c,d,r);u!==void 0&&i.push(u)}}static generateArc(e,t,i,r,s){if(s>0){let n=e.end(),a=t.start(),o=i.end(),l=r.start();if(o.distance2(l)>1e-8)if(n.equals(a)){let h=o.angleD(n),c=l.angleD(n);return ye.build2(n,h,c,s,s,0)}else{let h=o.angleD(n),c=l.angleD(n),d=o.angleD(a),f=l.angleD(a),u=ye.build2(n,h,c,s,s,0),p=ye.build2(a,d,f,s,s,0);return u.pointOn(u.endAngle()).equals1(l)?u:p.pointOn(p.endAngle()).equals1(l)?p:u}}}static updateNews(e,t,i,r){let s=e.length,n=t==s-1?0:t+1;e[n]=this.generatePrimitive(i,r,i.end())}static add(e,t,i,r,s,n){if(n>0)return n;if(r!=null&&s!=null){let a=xn(r,s);for(let o=0;o<a;o+=2){let l=new ae($[o],$[o+1]);t.push(this.generatePrimitive(r,r.start(),l)),this.updateNews(e,i,s,l);break}return a}else return 0}static update(e,t,i,r,s){if(s>0)return s;let n=t.length;if(n>0&&r!=null){let a=t[n-1],o=xn(a,r);for(let l=0;l<o;l+=2){let h=new ae($[l],$[l+1]);t[n-1]=this.generatePrimitive(a,a.start(),h),this.updateNews(e,i,r,h)}return o}else return 0}static generatePrimitive(e,t,i){if(e instanceof le)return new le(t,i);if(e instanceof ye){let r=e,s=t.angleD(r.center),n=i.angleD(r.center);return ye.build2(r.center,s,n,r.rx,r.ry,r.sweep())}else throw new Error("not supported operation")}static start4Index(e,t){let i=e.length,r=new Array;for(let s=t;s<i;s++)r.push(e[s]);for(let s=0;s<t;s++)r.push(e[s]);return r}static isCW(e,t,i){let r=new le(i,e),s=new le(i,t),n=r.end().x-r.start().x,a=r.end().y-r.start().y,o=s.end().x-s.start().x,l=s.end().y-s.start().y;return!(n*l-a*o>0)}static panDistance(e,t){if(e instanceof le){if(e.isPoint())return;{let i=e.panDistance(t);return i.length()>1e-5?i:void 0}}else if(e instanceof ye){let i=e;if(i.sweepAngle>0){if(i.rx-t<=0||i.ry-t<=0)return}else if(i.sweepAngle<0&&(i.rx+t<=0||i.ry+t<=0))return;return i=i.panDistance(t),i.start().distance1(i.end())>1e-5||ve.eq(Math.abs(i.sweepAngle),360)?i:void 0}else throw new Error("not supported operation")}},ut=.001,us=ut**2;function et(e,t){return e.distance2(t)<us}function Ca(e,t){return Math.abs(e-t)<=1e-4}function JU(e,t){if(e instanceof le)return new le(e.start(),t);if(e instanceof ye){let i=t.angleD(e.center);return Ca(_t.regularD(e.startAngle),_t.regularD(i))?ye.build3(e.center,e.startAngle,0,e.rx,e.ry):ye.build2(e.center,e.startAngle,i,e.rx,e.ry,e.isCCW?1:0)}else{if(e instanceof Ye)return e.clip(e.getPercent(t,ut))[0];throw new Error("not supported operation")}}function Zn(e,t=_t.toRadians(e.startAngle)){return e.isCCW?t+=v_:t-=v_,new ae(Math.cos(t),Math.sin(t))}function df(e,t=0){let i=e.controls;if(t===0){let r=i[0],s=i.slice(1).find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return s.sub(r)}else if(t===1){let r=i[i.length-1],s=i.slice(0,-1).reverse().find(n=>!(n.x===r.x&&n.y===r.y));if(!s)throw Error("getTangentBezier(bezier: Bezier, t: number = 0)");return r.sub(s)}if(i.length===3){let[r,s,n]=i;return s.sub(r).mul(2*(1-t)).add(n.sub(s).mul(2*t)).normalize()}else{let[r,s,n,a]=i;return s.sub(r).mul(3*(1-t)**2).add(n.sub(s).mul(6*(1-t)*t)).add(a.sub(n).mul(3*t**2)).normalize()}}function jc(e,t,i){let r=e.slice(1).findIndex(n=>!(n.x===t.x&&n.y===t.y)),s=e[r+1];if(i&&(i.getPercent(s,ut)!==null||new le(i.start(),i.end()).distance(s)<=ut)&&(s=e[r+2]),!s)throw Error("getSecondPoint(controls: readonly Vector2[])");return s}function ct(e,t){if(e instanceof le)return e.end().sub(e.start()).normalize();if(e instanceof ye)return(t?Zn(e,t.angle(e.center)):Zn(e)).normalize();if(e instanceof Ye)if(e.controls.length===2){let[i,r]=e.controls;if(et(i,r))throw Error("equalsPP(p0, p1)");return r.sub(i).normalize()}else return(t?df(e,e.getPercent(t,ut)):df(e)).normalize();else throw new Error("not support")}function ZU(e,t,i){let r=[],s=t**2-4*e*i;if(s>=0){let n=-t/(2*e),a=Math.sqrt(s)/(2*e),o=n+a;if(r.push(o),s>0){let l=n-a;r.push(l)}}return r}function KU(e,t,i,r,s=0,n=1){let a=[],o=e*Math.pow(s,3)+t*Math.pow(s,2)+i*s+r,l=e*Math.pow(n,3)+t*Math.pow(n,2)+i*n+r,h,c;if(o*l<0)for(;Math.abs(s-n)>ut;)if(h=(s+n)/2,c=e*Math.pow(h,3)+t*Math.pow(h,2)+i*h+r,Math.abs(c)<ut){a.push(h);break}else o*c<0?n=h:l*c<0&&(s=h);else o*l===0&&(o===0&&a.push(s),l===0&&a.push(n));return a}function G1(e,t,i){if(e instanceof le||t.distance2(i)<=us)return new le(t,i);if(e instanceof ye)return ye.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ye){let r=e.getPercent(t,ut),s=e.getPercent(i,ut);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function lb(e){return ve.greater(e,0)&&ve.less(e,1)}function E_(e,t,i,r){let s=e[r]-2*t[r]+i[r],n=t[r]-e[r];if(s===0)return[];let a=-n/s,o=[];return lb(a)&&o.push(a),o}function w_(e,t,i,r,s){let n,a,o=-e[s]+3*t[s]-3*i[s]+r[s],l=2*(e[s]-2*t[s]+i[s]),h=t[s]-e[s],c=l**2-4*o*h;if(ve.lesseq(c,0))n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;else{let f=Math.sqrt(c);n=(-l-f)/(2*o),a=(-l+f)/(2*o);let u=o*2;if(ve.lesseq(n,1)&&ve.greatereq(n,0)){let p=Number.NEGATIVE_INFINITY;for(;ve.neq(n,p);){p=n;let g=u*n+l;n=-(o*n**2+l*n+h-g*n)/g}}if(ve.lesseq(a,1)&&ve.greatereq(a,0)){let p=Number.NEGATIVE_INFINITY;for(;ve.neq(a,p);){p=a;let g=u*a+l;a=-(o*a**2+l*a+h-g*a)/g}}}let d=[];return lb(a)&&d.push(a),lb(n)&&d.push(n),d}function kT(e,t){if(e.controls.length===2){let[o,l]=e.controls;et(o,l)||t.push(new le(o,l));return}let i,r;if(e.controls.length===3){let[o,l,h]=e.controls;i=E_(o,l,h,"x"),r=E_(o,l,h,"y")}else{let[o,l,h,c]=e.controls;i=w_(o,l,h,c,"x"),r=w_(o,l,h,c,"y")}i.sort((o,l)=>l-o),r.sort((o,l)=>l-o);let s=i.pop()||1,n=r.pop()||1,a=0;for(;s!==1||n!==1;)if(ve.eq(s,n))s=i.pop()||1,n=r.pop()||1;else if(s<n){let[o,l]=e.clip((s-a)/(1-a));a=s,t.push(o),e=l,s=i.pop()||1}else{let[o,l]=e.clip((n-a)/(1-a));a=n,t.push(o),e=l,n=r.pop()||1}t.push(e)}var $U=1e-5,bb=1,Ye=class bs extends gf{constructor(t){if(super(),this._startToEndL=null,t.length<2)throw new Error("Bezier needs at least 2 endpoints");this.controls=t.slice()}get startToEndL(){return this._startToEndL===null&&(this._startToEndL=new le(this.start(),this.end())),this._startToEndL}build1(t){let i=[];return Vc(t,(r,s)=>(i.push(s),!0)),new bs(i)}start(){return this.controls[0]}end(){return this.controls[this.controls.length-1]}static pointOn(t,i){if(i.length<1)throw new Error("bezier must have at least 1 point");if(i.length===1)return i[0];{let r=new Array(i.length-1);for(let s=1;s<i.length;s++){let n=i[s-1],a=i[s],o=(a.x-n.x)*t,l=(a.y-n.y)*t;r[s-1]=n.add1(o,l)}return bs.pointOn(t,r)}}clip1(t,i,r,s){if(r.push(i[0]),s.push(i[i.length-1]),i.length<2)throw new Error("bezier clip must have at least 2 point");if(i.length===2){let n=i[0],a=i[1],o=(a.x-n.x)*t,l=(a.y-n.y)*t,h=n.add1(o,l);r.push(h),s.push(h)}else{let n=new Array(i.length-1);for(let a=1;a<i.length;a++){let o=i[a-1],l=i[a],h=(l.x-o.x)*t,c=(l.y-o.y)*t;n[a-1]=o.add1(h,c)}this.clip1(t,n,r,s)}}clip(t){let i=[],r=[];return this.clip1(t,this.controls,i,r),[new bs(i),new bs(r.reverse())]}greater(t,i,r){return t-i>r}less(t,i,r){return t-i<-r}eq(t,i,r){return Math.abs(t-i)<=r}eqPP(t,i,r){return!t||!i?!1:this.eq(t.x,i.x,r)&&this.eq(t.y,i.y,r)}isInRange(t,i=ve.eps){let r=this.controls.map(n=>n.y-t.y),s=0;for(let n of r){if(this.less(n,0,i))s=s|1;else if(this.greater(n,0,i))s=s|2;else{s=3;break}if(s===3)break}if(s!==3)return!1;s=0;for(let n of this.controls){let a=n.x-t.x;if(this.less(a,0,i))s=s|1;else if(this.greater(a,0,i))s=s|2;else{s=3;break}if(s===3)break}return s===3}getPercent(t,i=ve.eps){if(!this.isInRange(t,i))return null;let r=Number.POSITIVE_INFINITY,s=[[this,0,1]];for(;s.length!==0;){let n=function(_){c=Math.min(c,_),d=Math.max(d,_)},a=function(_,y){let m=Aa(_,y);if(m===0)throw new Error("cnt === 0");for(let O=0;O<m;O+=2)n($[O])},[o,l,h]=s.pop();if(this.eqPP(o.start(),t,i))return l;if(this.eqPP(o.end(),t,i))return h;let c=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,f=o.controls.map(_=>_.y-t.y);r=f.reduce((_,y)=>{let m=Math.abs(y);return m<_?m:_},r),r/=2,r<=i&&(r=i),f.forEach((_,y)=>{this.eq(_,0,i)&&n(y/(f.length-1))});let u=new le(new ae(0,-r),new ae(1,-r)),p=new le(new ae(0,r),new ae(1,r));for(let _=0;_<f.length-1;_++){let y=new ae(_/(f.length-1),f[_]),m=this.less(y.y,0,i)?1:this.greater(y.y,0,i)?2:3;for(let O=0;O<f.length;O++){let b=new ae(O/(f.length-1),f[O]),v=this.less(b.y,0,i)?1:this.greater(b.y,0,i)?2:3;m!==v&&(m===1?v===2?(a(new le(y,b),u),a(new le(y,b),p)):a(new le(y,b),u):m===2?v===1?(a(new le(y,b),u),a(new le(y,b),p)):a(new le(y,b),p):v===1?a(new le(y,b),u):a(new le(y,b),p))}}if(!isFinite(c)){if(Math.max(...f.map(_=>Math.abs(_)))<i*4)return(l+h)/2;continue}if(c!==0&&(o=o.clip(c)[1],l=(h-l)*c+l),d!==1){let _=(d-c)/(1-c);o=o.clip(_)[0],h=(h-l)*_+l}if(!o.isInRange(t,i))continue;let g=o.controls.reduce((_,y)=>_.ext2(y),new yi).build1();if(this.eq(g.minX,g.maxX,i)&&this.eq(g.minY,g.maxY,i))return(l+h)/2;if(d-c>.8){let[_,y]=o.clip(.5);_.isInRange(t,i)?(s.push([_,l,(l+h)/2]),y.isInRange(t,i)&&s.push([y,(l+h)/2,h])):s.push([y,(l+h)/2,h])}else s.push([o,l,h])}return null}toBezier(){return this}toString(){return"Bezier ["+this.controls.join(" ")+"]"}bbox(){return this._bbox||(this._bbox=new yi().ext3(this.points(.1)).build1()),this._bbox}bboxWithControls(){return this._bbox_controls||(this._bbox_controls=new yi().ext3(this.controls).build()),this._bbox_controls}multiply3(t){let i=new Array(this.controls.length);for(let r=0;r<this.controls.length;r++){let s=this.controls[r];i[r]=s.multiply3(t)}return new bs(i)}stroke(t,i,r,s=bb){let n=XU.zoomLines(It.build4(this.points(s)),t);return r===0?n:n.reverse()}points(t){let i=[];return this.getBezierPoints(t,r=>i.push(r)),i}getBezierPoints(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=[this];for(i(this.start());r.length!==0;){let n=r.pop(),a=new le(n.start(),n.end());if(s(n.controls,a)<=t)i(n.end());else{let[o,l]=n.clip(.5);r.push(l,o)}}function s(n,a){let o=a.start(),l=a.end();o.equals1(l)&&(l=o.add1(1,0));let h=l.y-o.y,c=o.x-l.x,d=-h*o.x-c*o.y,f=Math.sqrt(1/(h**2+c**2));h*=f,c*=f,d*=f;let u=n.map(p=>Math.abs(h*p.x+c*p.y+d));return Math.max(...u)}}getBezierPoints3(t,i){if(this.controls.length===2){i(this.start()),i(this.end());return}let r=t*t,s=this.controls[0],n=.5;for(;n>$U&&!(s.distance2(bs.pointOn(n,this.controls))<=r);n*=.5);let a=Math.ceil(1/n);n=1/a,i(s);let o=0;for(let l=1;l<a;l++)o+=n,i(bs.pointOn(o,this.controls));i(this.end())}getPointsBySlope(t){if(this.controls.length===4)return this.getPointsBySlope4(t);throw new Error("Currently, only 4 control points are supported!")}getPointsBySlope4(t){let[i,r,s,n]=this.controls,a=-3*i.x+9*r.x-9*s.x+3*n.x,o=6*i.x-12*r.x+6*s.x,l=-3*i.x+3*r.x,h=[];if(Number.isFinite(t)){let c=-3*i.y+9*r.y-9*s.y+3*n.y,d=6*i.y-12*r.y+6*s.y,f=-3*i.y+3*r.y,u=c-a*t,p=d-o*t,g=f-l*t,_=-p/(2*u),y=Math.sqrt(p**2-4*u*g)/(2*u),m=_+y;m>=0&&m<=1&&h.push(bs.pointOn(m,this.controls));let O=_-y;O>=0&&O<=1&&h.push(bs.pointOn(O,this.controls))}else{let c=-o/(2*a),d=Math.sqrt(o**2-4*a*l)/(2*a),f=c+d;f>=0&&f<=1&&h.push(bs.pointOn(f,this.controls));let u=c-d;u>=0&&u<=1&&h.push(bs.pointOn(u,this.controls))}return h}buildConverxHull(t=ve.eps){let i=[...this.controls],r=[],s=i[0],n=1;do{let a=i[n%i.length];this.eqPP(s,a,t)||r.push(new le(s,a)),s=a,n++}while(s!==i[0]);if(r.length===0)throw Error("buildConverxHull(diff = DoubleKit.eps)");return It.build7(r).asClose()}getExtremePoints(t){if(!t)return a(this.controls);let i=t.start(),r=t.end(),s=r.x-i.x,n=r.y-i.y;if(Math.abs(s)<=ve.eps||Math.abs(n)<=ve.eps)return a(this.controls);{let o=n/s;if(this.controls.length===3){i.equals1(r)&&(r=i.add1(1,0));let l=r.y-i.y,h=i.x-r.x,c=-l*i.x-h*i.y,d=Math.sqrt(1/(l**2+h**2));l*=d,h*=d,c*=d;let f=this.controls.map(g=>l*g.x+h*g.y+c),u=f[0]-2*f[1]+f[2],p=f[1]-f[0]-o/2;if(u!==0){let g=-p/u;if(ve.greater(g,0)&&ve.less(g,1))return[bs.pointOn(g,this.controls)]}}else if(this.controls.length===4)return this.getPointsBySlope(o)}return[];function a(o){let l,h;if(o.length===3){let[u,p,g]=o;l=E_(u,p,g,"x"),h=E_(u,p,g,"y")}else if(o.length===4){let[u,p,g,_]=o;l=w_(u,p,g,_,"x"),h=w_(u,p,g,_,"y")}l.sort((u,p)=>p-u),h.sort((u,p)=>p-u);let c=l.pop()||1,d=h.pop()||1,f=[];for(;c!==1||d!==1;)ve.eq(c,d)?(c=l.pop()||1,d=h.pop()||1):c<d?(f.push(bs.pointOn(c,o)),c=l.pop()||1):(f.push(bs.pointOn(d,o)),d=h.pop()||1);return f}}getToLineMaxDis2(t){let i=this.getExtremePoints(t),r=t.distance2(this.start()),s=t.distance2(this.end()),n=Math.max(r,s);return i.forEach(o=>a(t.distance2(o))),n;function a(o){n=Math.max(n,o)}}getToLineMinAndMaxDis_Controls(t){let i=t.start(),r=t.end();t.start().equals1(t.end())&&(r=i.add1(1,0));let s=r.y-i.y,n=i.x-r.x,a=-s*i.x-n*i.y,o=Math.sqrt(1/(s**2+n**2));s*=o,n*=o,a*=o;let l=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY;return this.controls.forEach(c=>{let d=s*c.x+n*c.y+a;d<l&&(l=d),d>h&&(h=d)}),{minDis:l,maxDis:h}}getPercentInLine(t){let i=[],r=[],s=this.controls,n=t.start(),a=t.end(),o=a.y-n.y,l=n.x-a.x,h=-o*n.x-l*n.y,c=Math.sqrt(1/(o**2+l**2));if(o*=c,l*=c,h*=c,o**2+l**2<=0)return i;if(s.length===3){let[d,f,u]=s,p=o*(d.x-2*f.x+u.x)+l*(d.y-2*f.y+u.y),g=2*(o*(f.x-d.x)+l*(f.y-d.y)),_=o*d.x+l*d.y+h;r=ZU(p,g,_)}else if(s.length===4){let[d,f,u,p]=s,g=p.sub(u.mul(3)).add(f.mul(3)).sub(d),_=d.sub(f.mul(2)).add(u).mul(3),y=f.sub(d).mul(3),m=d,O=o*g.x+l*g.y,b=o*_.x+l*_.y,v=o*y.x+l*y.y,E=o*m.x+l*m.y+h,T=Math.sqrt(1/(O**2+b**2));O*=T,b*=T,v*=T,E*=T,r=KU(O,b,v,E)}else throw Error("not support getBeizerPointInLine");return r.forEach(d=>{d>=0&&d<=1&&i.push(d)}),i}reverse(){return new bs(this.controls.slice().reverse())}},FT=class rf{constructor(){this.textCache=new Map,this.numCache=new Array(20),this.boxCache=new Array(4),this.textOffsetCache=new Array(9),this.BuildLineCache=new Array(7),this.BuildTrackCache=new Array(7),this.BuildViaCache=new Array(11),this.BuildBoxCache=new Array(10),this.BuildArcCache=new Array(10),this.BuildArcTrackCache=new Array(10),this.BuildTextCache=new Array(7),this.BuildPadStyleCache=new Array(4),this.BuildPadCache=new Array(12),this.ARRAY1=new Array(1),this.ARRAY2=new Array(2),this.ARRAY3=new Array(3),this.ARRAY4=new Array(4),this.ARRAY5=new Array(5),this.ARRAY6=new Array(6),this.ARRAY7=new Array(7),this.ARRAY8=new Array(8),this.ARRAY9=new Array(9),this.ARRAY10=new Array(10),this.ARRAY11=new Array(11),this.ARRAY12=new Array(12),this.textOffsetCache[0]=ae.ORIGIN,this.textOffsetCache[1]=new ae(0,-.5),this.textOffsetCache[2]=new ae(0,-1),this.textOffsetCache[3]=new ae(-.5,0),this.textOffsetCache[4]=new ae(-.5,-.5),this.textOffsetCache[5]=new ae(-.5,-1),this.textOffsetCache[6]=new ae(-1,0),this.textOffsetCache[7]=new ae(-1,-.5),this.textOffsetCache[8]=new ae(-1,-1)}static getCache(){return rf.instance==null&&(rf.instance=new rf),rf.instance}};FT.instance=null;var UT=FT,le=class rh extends gf{constructor(t,i){super(),this._start=t,this._end=i}get a(){return this._a==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._a}get b(){return this._b==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._b}get c(){return this._c==null&&(this._start.equals1(this._end)?(this._a=NaN,this._b=NaN,this._c=NaN):(this._a=this._end.y-this._start.y,this._b=this._start.x-this._end.x,this._c=this._end.x*this._start.y-this._start.x*this._end.y)),this._c}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}get direct(){return this._direct==null&&(this._direct=this._end.sub(this._start).normalize()),this._direct}cutLine(t){if(ve.eq(this.distance(t),0)){let i=new rh(this._start,t);return i._a=this._a,i._b=this._b,i._c=this._c,i}return new rh(this._start,t)}get midPoint(){return this._start.add(this._end).mul(.5)}toBezier(){return new Ye([this._start,this._end])}_hashCode(){let t=31,i=1;return i=t*i+this._start.hashCode(),i=t*i+this._end.hashCode(),i}start(){return this._start}end(){return this._end}center(){let t=this.start(),i=this.end();return t.add(i).mul(.5)}panDistance(t){let i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=this.length();i=i*t/s,r=-r*t/s;let n=new ae(this._start.x+r,this._start.y+i),a=new ae(this._end.x+r,this._end.y+i);return new rh(n,a)}isPoint(){return this._start.distance2(this._end)<=1e-8}length(){return this._start.distance1(this._end)}toString(){return"Line [start="+this._start+", end="+this._end+"]"}bbox(){if(this.__bbox==null){let t=UT.getCache().boxCache;t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.__bbox=new Pi(t[0],t[1],t[2],t[3])}return this.__bbox}multiply3(t){return new rh(this._start.multiply3(t),this._end.multiply3(t))}hashCode(){return this.hashed}equals(t){let i=t;return this.hashed===i.hashed&&this._start.equals(i._start)&&this._end.equals(i._end)}equals1(t){let i=t;return this.hashed===i.hashed&&this._start.equals1(i._start)&&this._end.equals1(i._end)}equals2(t){let i=[this.start(),this.end()],r=[t.start(),t.end()];return Xn(i,r)||Xn(i,r.reverse())}stroke(t,i,r){let s,n,a;this._end.x<this._start.x?(n=this._start.x-this._end.x,a=this._start.y-this._end.y,s=this._end):(n=this._end.x-this._start.x,a=this._end.y-this._start.y,s=this._start);let o=Math.sqrt(n*n+a*a),l=t/2,h,c,d;i===2?(c=-l,d=o+l):(c=0,d=o),i===0||i===2?r===0?h=It.build5([c,-l,c,l,d,l,d,-l]):h=It.build5([c,l,c,-l,d,-l,d,l]):r===0?h=It.build2([ye.build3(new ae(c,0),-90,-180,l,l),ye.build3(new ae(d,0),90,-180,l,l)]):h=It.build2([ye.build3(new ae(c,0),90,180,l,l),ye.build3(new ae(d,0),-90,180,l,l)]);let f=Math.atan2(a,n),u=ci.rotate(f).translate1(s);return h.asClose().multiply3(u)}points(t){return[this._start,this._end]}mirrorY(t){return new rh(this.start().mirrorY(t),this.end().mirrorY(t))}reverse(){return new rh(this._end,this._start)}inArea(t,i,r){let s=t.x,n=t.y,a=this._start,o=this._end,l=r==1,h=s-a.x,c=n-a.y,d=s-o.x,f=n-o.y,u=o.x-a.x,p=o.y-a.y,g=new ae(-p,u).normalize(),_=u+g.x*i/2,y=p+g.y*i/2,m=_*_+y*y,O=h*h+c*c,b=d*d+f*f,v=Math.abs(h*p-c*u)/2,E=Math.sqrt(u*u+p*p)*i/4;if(v<=E&&O<=m&&b<=m){if(l)return!0;{let T=new ae(s,n).sub(o).normalize(),P=new ae(s,n).sub(a).normalize(),A=new ae(g.x,g.y).cross(T),C=new ae(g.x,g.y).cross(P);return A>=0&&C<=0}}else if(l){let T=i/2;return O<=T*T?!0:b<=T*T}else return!1}isParallel(t,i=!1){let r=ve.eq(Math.abs(this.direct.cross(t.direct)),0),s=!i||ve.greatereq(this.direct.dot(t.direct),0);return r&&s}distance2(t){return(this.a*t.x+this.b*t.y+this.c)**2/(this.a**2+this.b**2)}distance2ForPP(t){let{x:i,y:r}=t,{x:s,y:n}=this.start(),{x:a,y:o}=this.end();return((i-s)*(o-n)-(r-n)*(a-s))**2/((o-n)**2+(a-s)**2)}distance(t){return Math.abs(this.a*t.x+this.b*t.y+this.c)/Math.sqrt(this.a**2+this.b**2)}};function QU(e,t=.05){if(e.length<3)return e.slice();let i=e.slice(0,1),r=(n,a,o)=>DU(n.x,n.y,a.x,a.y,o.x,o.y);for(;;){i=e.slice(0,1);for(let n=1;n<e.length-1;n+=2)r(e[n],e[n-1],e[n+1])>t&&i.push(e[n]),i.push(e[n+1]);if(i.at(-1).equals1(e.at(-1))||i.push(e.at(-1)),e.length==i.length)break;e=i}let s=e[e.length-1];return i.push(s),i}var eG=gU(_U());var tG=class{constructor(){this.fac=new yi,this.length=0,this.box=null,this.pt=null,this.i=0}calcBBox(e){for(this.fac.clear(),this.length=e.length,this.box=null,this.pt=null,this.i=0;this.i<this.length;this.i++)this.pt=e[this.i],this.box=this.pt.bbox(),this.fac.ext1(this.box);return this.fac.build1()}},iG=new tG,It=class Xi{constructor(t,i){this.primitives=t,this.__bbox=i}static calcBBox(t){return iG.calcBBox(t)}static build1(t){let i=[],r=null;return b_(t,(s,n)=>{let a=n.start();return r!==null&&!a.equals(r)&&i.push(new le(r,a)),i.push(n),r=n.end(),!0}),i.length===0&&r!=null&&i.push(new le(r,r)),new Xi(i)}static build2(t){return Xi.build1(sb(t))}static build3(t){let i=[],r=null;return b_(t,(s,n)=>(r!==null&&i.push(new le(r,n)),r=n,!0)),new Xi(i)}static build4(t){return this.build3(sb(t))}static build5(t){let i=[];for(let r=0;r<t.length;r+=2)i.push(new ae(t[r],t[r+1]));return this.build4(i)}static build6(t){return Xi.build4([t.LL(),t.LR(),t.UR(),t.UL(),t.LL()])}static build7(t){return new Xi(t)}static build8(t){let i=new ae(t[0],t[1]),r,s=[],n,a=(o,l)=>o.length==l&&o.every(h=>typeof h=="number");for(let o=2;o<t.length;)switch(typeof t[o]=="string"?n=t[o]:o-=1,n){case"ARC":{let l=t.slice(o+1,o+4);if(!a(l,3))throw new Error("invalid rawData");let h=l[0];r=new ae(l[1],l[2]),s.push(ye.build5(i,r,h)),i=r,o+=4;break}case"L":{let l=t.slice(o+1,o+3);if(!a(l,2))throw new Error("invalid rawData");r=new ae(l[0],l[1]),s.push(new le(i,r)),i=r,o+=3;break}case"C":{let l=t.slice(o+1,o+7);if(!a(l,7))throw new Error("invalid rawData");let h=new ae(l[0],l[1]),c=new ae(l[2],l[3]);r=new ae(l[4],l[5]),s.push(new Ye([i,h,c,r])),i=r,o+=7;break}default:throw new Error("invalid rawData")}return Xi.build2(s)}static buildBBox(t,i=0){return i===1?Xi.build5([t.minX,t.minY,t.maxX,t.minY,t.maxX,t.maxY,t.minX,t.maxY,t.minX,t.minY]):Xi.build5([t.minX,t.minY,t.minX,t.maxY,t.maxX,t.maxY,t.maxX,t.minY,t.minX,t.minY])}static triangulate(t,i,r=1,s=!1){let n=s?(c,d)=>{c.points(r,d)}:(c,d)=>{c.points2(r,d)};if(t.length===1){let c=new Array;n(t[0].asClose(),p=>c.push(p));let d,f=c[0],u=[];for(let p=0;p<c.length-2;p+=2){let g=c[p+1],_=c[p+2],y=g.sub(f).normalize().cross(_.sub(f).normalize());if(ve.neq(y,0)){if(d===!0){if(y<0){u.length=0;break}}else if(d===!1){if(y>0){u.length=0;break}}else d=y>0;u.push(f),u.push(g),u.push(_)}c.push(f),f=_}if(u.length!==0){for(let p=0;p<u.length;p+=3)i(u[p],u[p+1],u[p+2]);return}}let a=[],o=[];t.forEach(c=>{a.length!==0&&o.push(a.length/2),n(c.asClose(),d=>a.push(d.x,d.y))});let l=eG.default(a,o),h=[];for(let c=1;c<a.length;c+=2)h.push(new ae(a[c-1],a[c]));for(let c=0;c<l.length;c+=3)i(h[l[c]],h[l[c+1]],h[l[c+2]])}lines(t,i){let r=new Array;this.points(t,n=>r.push(n));let s=r[0];for(let n=1;n<r.length;n++){let a=r[n];i(s),i(a),s=a}}triangles(t,i,r=!1){Xi.triangulate([this],(...s)=>{s.forEach(n=>i(n))},t,r)}mirror(){let t=[];return this.primitives.forEach(i=>{if(i instanceof le)i=new le(i.start().mirror(),i.end().mirror());else if(i instanceof ye)i=i.mirror();else if(i instanceof Ye){let r=i.controls.map(s=>s.mirror());i=new Ye(r)}else throw new Error("bug");t.push(i)}),new Xi(t,this.__bbox)}getPoints(t){let i=[];for(let r of this.primitives)for(let s of r.points(t))i.push(s);return i}round(t=4){let i=this.primitives.slice();for(let r=0;r<i.length;r++){let s=i[r];if(s instanceof le){let n=s.start().round(t),a=s.end().round(t);i[r]=new le(n,a)}else if(s instanceof Ye){let n=s.controls.map(a=>a.round(t));i[r]=new Ye(n)}else if(s instanceof ye){let n=s.start().round(t),a=s.end().round(t),o=s.sweepAngle;i[r]=ye.build5(n,a,o)}}return new Xi(i,this.__bbox)}simplify(t=.05){let i=[],r=!1,s=[],n=this.closed();if(this.primitives.length<=1)return Xi.build2(this.primitives);let a=()=>{if(s.length>2){let l=QU(s,t);for(let h=1;h<l.length;h++)i.push(new le(l[h-1],l[h]))}else i.push(new le(s[0],s[1]));s.length=0,r=!1};for(let l=0;l<this.primitives.length;l++){let h=this.primitives[l];h instanceof le?(r?s.push(h.end()):(s.length=0,s.push(h.start(),h.end()),r=!0),l===this.primitives.length-1&&a()):(r&&a(),i.push(h))}let o=new Xi(i,this.__bbox);return n&&!o.closed()&&(o=o.asClose()),o}hasBackLine(){let{primitives:t}=this,i;for(let r=0;r<t.length;r++){let s=t[r];if(s instanceof le){if(s.end().equals1(s.start()))continue;if(i&&(s.end().equals1(i.start())||RU(s.end(),i.start(),i.end())))return!0;i=s}else i=null}return!1}area(t=.1){let i=0,r=this.end();return this.primitives.forEach(s=>{let n=s.start(),a=s.end();if(i+=(n.x+r.x)*(n.y-r.y),s instanceof le)i+=(a.x+n.x)*(a.y-n.y);else if(s instanceof ye)i+=(a.x+n.x)*(a.y-n.y),i+=Math.PI*s.rx2*s.sweepAngle/180-ae.normal(s.center,s.start(),s.end());else if(s instanceof Ye){let o=n;s.points(t).forEach(l=>{i+=(l.x+o.x)*(l.y-o.y),o=l}),i+=(a.x+o.x)*(a.y-o.y)}r=a}),i/2}closed(t){return this.primitives.length===0?!1:this.start().equals(this.end(),t)}asClose(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals(s))return this;{let n=new Array;return hs.addAll(n,this.primitives),n.push(new le(s,r)),Xi.build2(n)}}closeEndpoint(){let t=this.primitives[0],i=this.primitives[this.primitives.length-1],r=t.start(),s=i.end();if(r.equals1(s))return this;{let n=new Array;return hs.addAll(n,this.primitives),n.push(new le(s,r)),new Xi(n)}}reverse(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof le)s=new le(s.end(),s.start());else if(s instanceof ye)s=s.exchangeSweep();else if(s instanceof Ye)s=new Ye(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new Xi(t,this.__bbox)}reverse1(){let t=new Array(this.primitives.length);for(let i=0,r=this.primitives.length-1;r>=0;i++,r--){let s=this.primitives[r];if(s instanceof le)s=new le(s.end(),s.start());else if(s instanceof ye)s=s.exchangeSweep1();else if(s instanceof Ye)s=new Ye(s.controls.slice().reverse());else throw new Error("bug");t[i]=s}return new Xi(t,this.__bbox)}mirrorY(t){let i=[];return this.primitives.forEach(r=>{if(r instanceof le)r=r.mirrorY(t);else if(r instanceof ye)r=r.mirrorY(t);else if(r instanceof Ye){let s=r.controls.map(n=>n.mirrorY(t));r=new Ye(s)}else throw new Error("bug");i.push(r)}),new Xi(i,this.__bbox)}points(t,i){if(this.primitives.length!==0){for(let r=0;r<this.primitives.length-1;r++){let s=this.primitives[r].points(t);s.pop(),s.forEach(n=>i(n))}this.primitives[this.primitives.length-1].points(t).forEach(r=>i(r))}}points1(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof ye?n.points1(t):n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof ye?r.points1(t):r.points(t)).forEach(s=>i(s))}points2(t,i){if(this.primitives.length===0)return;for(let s=0;s<this.primitives.length-1;s++){let n=this.primitives[s],a=n instanceof ye?n.points2():n.points(t);a.pop(),a.forEach(o=>i(o))}let r=this.primitives[this.primitives.length-1];(r instanceof ye?r.points2():r.points(t)).forEach(s=>i(s))}multiply3(t){let i=new Array(this.primitives.length);for(let r=0;r<this.primitives.length;r++)i[r]=this.primitives[r].multiply3(t);return Xi.build7(i)}bbox(){return this.__bbox==null&&(this.__bbox=Xi.calcBBox(this.primitives)),this.__bbox}start(){return this.primitives.length!==0?this.primitives[0].start():null}end(){return this.primitives.length!==0?this.primitives[this.primitives.length-1].end():null}isClose(t){if(this.primitives.length<=1&&!(this.primitives[0]instanceof ye))return!1;{let i=this.primitives[0],r=this.primitives[this.primitives.length-1];return i.start().equals(r.end(),t)}}isEqual(t){if(t instanceof Xi&&t.primitives.length==this.primitives.length){let i=t.primitives.length;for(let r=0;r<i;r++){let s=t.primitives[r],n=this.primitives[r];if(JSON.stringify(s)!=JSON.stringify(n))return!1}return!0}return!1}equals(t){if(!t)return!1;let i=this.primitives,r=t.primitives;if(i.length!=r.length)return!1;if(t.isClose()){let s=0;for(;s<i.length;){let n=i.slice(s).concat(i.slice(0,s));if(Xn(n,r)||Xn(n.reverse(),r))return!0;s++}return!1}else return Xn(this.primitives,t.primitives)}clone(){return Xi.build2(this.primitives)}putItem(t,i){if(!t)return!1;if(t instanceof Xi)return this.mergePolyline(t,i);let r=this.start();if(!r){this.primitives.push(t),this.__bbox=t.bbox();return}let s=this.end();if(r.equals(s,i))return!1;let n=t.start(),a=t.end(),o=!1,l=!1;if(r.equals(n,i))o=!0,l=!1;else if(r.equals(a,i))o=!1,l=!1;else if(s.equals(n,i))o=!1,l=!0;else if(s.equals(a,i))o=!0,l=!0;else return!1;return l?this.primitives.push(o?t.reverse():t):this.primitives.unshift(o?t.reverse():t),this.__bbox=Pi.extend2(this.__bbox,t.bbox()),!0}mergePolyline(t,i,r=0){if(!t)return!1;let s=this.start();if(!s){this.primitives.push(...t.primitives),this.__bbox=t.bbox();return}let n=this.end();if(s.equals(n,i))return!1;let a=t.start(),o=t.end(),l=!1,h=!1;if(s.equals(a,i))l=!0,h=!1;else if(s.equals(o,i))l=!1,h=!1;else if(n.equals(a,i))l=!1,h=!0;else if(n.equals(o,i))l=!0,h=!0;else return!1;let c=l?t.reverse():t;return h?this.primitives.push(...c.primitives):this.primitives.unshift(...c.primitives),this.__bbox=Pi.extend2(this.__bbox,t.bbox()),!0}deDuplicationPoint(t){let i=this.primitives[this.primitives.length-1].start(),r=this.primitives[this.primitives.length-1].end(),s=t.primitives[0].start(),n=t.primitives[0].end();if(this.primitives[this.primitives.length-1]instanceof le&&t.primitives[0]instanceof le&&GU([i,r],[s,n])){this.primitives.pop(),t.primitives.shift();let a=[];a.push(new le(i,n)),this.primitives.push(...a)}}getMaxBBoxHeightByVec(t){let i=t.normalize(),r=-1/0,s=1/0;if(this.primitives.forEach(a=>{let o=a.start().dot(i),l=a.end().dot(i);if(n(o),n(l),a instanceof ye){let h=t.angleD(ae.ORIGIN);if(a.angleIsInArc(h)){let c=a.pointOn(h).dot(i);n(c)}if(a.angleIsInArc(h+180)){let c=a.pointOn(h-180).dot(i);n(c)}}}),r-s<=0)throw new Error("getMaxBBoxHeightByVec");return r-s;function n(a){a>r&&(r=a),a<s&&(s=a)}}getWindingNum(t){let i=this.end(),r=0,{x:s,y:n}=t;for(let o of this.primitives){if(i.y>n?o.bbox().minY>n:o.bbox().maxY<=n){i=o.end();continue}if(o instanceof ye&&(o.isCCW?Math.floor(o.startAngle/90)+1!==Math.ceil(o.endAngle()/90):Math.ceil(o.startAngle/90)-1!==Math.floor(o.endAngle()/90))){let l=o.startAngle,h=o.endAngle();if(o.sweepAngle>0){let c=90;for(;c<=h;)c>l&&(a(ye.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c+=90;l<h&&a(ye.build3(o.center,l,h-l,o.rx,o.ry))}else{let c=270;for(;c>=h;)c<l&&(a(ye.build3(o.center,l,c-l,o.rx,o.ry)),l=c),c-=90;l>h&&a(ye.build3(o.center,l,h-l,o.rx,o.ry))}}else if(o instanceof Ye){let l=[];kT(o,l),l.forEach(h=>a(h))}else a(o)}return r;function a(o){let l=o.start(),h=o.end();if(i.y>n!=l.y>n&&(i.x>s?l.x>s?r+=l.y>i.y?1:-1:i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++:l.x>s&&(i.y>l.y?(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)<0&&r--:(i.x-s)*(l.y-n)-(i.y-n)*(l.x-s)>0&&r++)),l.y>n!=h.y>n){if(l.x>s)if(h.x>s)r+=h.y>l.y?1:-1;else if(o instanceof le)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof ye){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof Ye){if(cT(o,n)===0)throw new Error("no inters");$[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!");else if(h.x>s)if(o instanceof le)l.y>h.y?(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)<0&&r--:(l.x-s)*(h.y-n)-(l.y-n)*(h.x-s)>0&&r++;else if(o instanceof ye){let{center:c,isCCW:d,rx2:f}=o,u=(c.x-s)**2+(c.y-n)**2;l.y>h.y?(d?u>f:u<f)&&r--:(d?u<f:u>f)&&r++}else if(o instanceof Ye){if(cT(o,n)===0)throw new Error("no inters");$[0]>s&&(r+=h.y>l.y?1:-1)}else throw new Error("not support!")}i=h}}},n_=Math.PI*2,Wie=Math.PI/2,Xie=Math.sin(Math.PI/180),rG=4,ye=class ri extends gf{constructor(t,i,r,s,n){super(),this.rx=t,this.ry=i,this.center=r,this.startAngle=s,this.sweepAngle=n,this._start=ae.ORIGIN,this._end=ae.ORIGIN,this._start=this.pointOn(s),this._end=this.pointOn(s+n)}get hashed(){return this._hashed==null&&(this._hashed=this._hashCode()),this._hashed}hashCode(){return this.hashed}_hashCode(){let t=31,i=1;return i=t*i+new ae(this.rx,this.rx).hashCode(),i=t*i+this.center.hashCode(),i=t*i+new ae(this.startAngle,this.sweepAngle).hashCode(),i}get rx2(){return this._rx2==null&&(this._rx2=this.rx*this.rx),this._rx2}get ry2(){return this._ry2==null&&(this._ry2=this.ry*this.ry),this._ry2}get svgEnd(){return this._svgEnd==null&&(this._svgEnd=this.getSvgEnd(this.startAngle,this.sweepAngle,this._start,this._end)),this._svgEnd}getSvgEnd(t,i,r,s){let n=i>=0?-.01:.01,a=t+i;for(;(i>=0&&a>t||i<0&&a<t)&&r.distance2(s)<2e-4;)n*=2,a+=n,s=this.pointOn(a);return s}static build1(t,i,r,s,n,a){si.positive(r),si.positive(s);let o=t.equals(i);if(o)return new ri(r,s,t,0,n?360:0);{let l=t.x,h=-t.y,c=i.x,d=-i.y,f=a===0,u=(l-c)/2,p=(h-d)/2,g=Math.cos(0),_=Math.sin(0),y=g*u+_*p,m=-_*u+g*p;r=Math.abs(r),s=Math.abs(s);let O=r*r,b=s*s,v=y*y,E=m*m,T=n===f?-1:1,P=(O*b-O*E-b*v)/(O*E+b*v);P=P<0?0:P;let A=T*Math.sqrt(P),C=A*(r*m/s),M=A*-(s*y/r),H=(l+c)/2,k=(h+d)/2,F=H+(g*C-_*M),j=k+(_*C+g*M),L=(y-C)/r,R=(m-M)/s,x=(-y-C)/r,I=(-m-M)/s,S,D;D=Math.sqrt(L*L+R*R),S=L,T=R<0?-1:1;let N=_t.toDegrees(T*Math.acos(S/D));D=Math.sqrt((L*L+R*R)*(x*x+I*I)),S=L*x+R*I,T=L*I-R*x<0?-1:1;let G=S/D,z;G<-1?z=Math.acos(-1):G>1?z=Math.acos(1):z=Math.acos(G);let Z=_t.toDegrees(T*z);!f&&Z>0?Z-=360:f&&Z<0&&(Z+=360),si.normal(N),si.normal(Z);let se=u*u/O+p*p/b,he=t.distance1(i)/2;r<he&&s<he&&(r*=Math.sqrt(se),s*=Math.sqrt(se));let pe=o?0:_t.regularD(-N),Se=o?n?360:0:-Z;return new ri(r,s,new ae(F,-j),pe,Se)}}static build2(t,i,r,s,n,a){si.positive(s),si.positive(n),si.normal(i),si.normal(r);let o;return i===r?(i=_t.regularD(i),r=_t.regularD(r),o=0):(i=_t.regularD(i),r=_t.regularD(r),a===1?r<=i&&(r+=360):r>=i&&(i+=360),o=r-i),new ri(s,n,t,_t.regularD(i),o)}static build3(t,i,r,s,n){return si.positive(s),si.positive(n),si.normal(r),new ri(s,n,t,_t.regularD(i),r)}static build4(t,i,r,s,n,a){let o=t.angleD(r),l=i.angleD(r);return ri.build2(r,o,l,s,n,a)}static build5(t,i,r){r=_t.toRadians(r);let s=i.sub(t),n=new ae(-s.y,s.x).normalize(),a=Math.abs(r)/2,o;if(a!=0)o=s.length()/2/Math.sin(a);else throw new Error("Can't represent circle!!!");let l=n.rotate(ae.ORIGIN,a),h,c;r>0?(h=1,c=i.add(l.scale(o))):(h=0,c=t.sub(l.scale(o)));let d=_t.toDegrees(t.angle(c)),f=_t.toDegrees(i.angle(c));return ri.build2(c,d,f,o,o,h)}static buildCircle(t,i,r=0){return ri.build2(t,0,360,i,i,r)}start(){return this._start}end(){return this._end}isLarge(){return Math.abs(this.sweepAngle)>180}sweep(){return this.sweepAngle>=0?1:0}get isCCW(){return this.sweepAngle>=0}endAngle(){return this.startAngle+this.sweepAngle}pointOn(t){t=_t.regularD(t);let i=this.rx,r=this.ry;if(t===0)return this.center.add1(i,0);if(t===90)return this.center.add1(0,r);if(t===180)return this.center.add1(-i,0);if(t===270)return this.center.add1(0,-r);{let s=this.rx2,n=this.ry2,a=Math.tan(_t.toRadians(t)),o=a*a,l=Math.sqrt(s*n/(s+n/o)),h=Math.sqrt(s*n/(n+s*o));return t>90&&t<270&&(h=-h),t>180&&t<360&&(l=-l),isNaN(h)&&(h=0),isNaN(l)&&(l=0),this.center.add1(h,l)}}exchangeSweep(){return ri.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,this.rx,this.ry)}exchangeSweepAndStart(){return ri.build1(this.end(),this.start(),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}exchangeSweep1(){return ri.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle+.01,this.rx,this.ry)}mirrorY(t){let i=this.start(),r=this.end();return i.equals(r)?ri.build3(this.center.mirrorY(),0,360,this.rx,this.ry):ri.build1(i.mirrorY(t),r.mirrorY(t),this.rx,this.ry,this.isLarge(),this.sweepAngle>=0?0:1)}mirror(t=ae.ORIGIN){let i=this.start(),r=this.end();return i.equals(r)?ri.build3(this.center.mirror(t),0,360,this.rx,this.ry):ri.build1(i.mirror(t),r.mirror(t),this.rx,this.ry,this.isLarge(),this.sweep())}sectorArea(){return Math.abs(this.sweepAngle)/360*Math.PI*this.rx*this.ry}area(){let t=ab.area(this.center,this._start,this.pointOn(this.endAngle()));return this.sectorArea()-t}multiply3(t){let i;t.isMirrored()?i=-this.sweepAngle:i=this.sweepAngle;let r;return t.equals(ci.ROT_90)?r=_t.regularD(this.startAngle+90):t.equals(ci.ROT_N90)?r=_t.regularD(this.startAngle-90):r=_t.transformD(this.startAngle,t),ri.build3(this.center.multiply3(t),r,i,t.iScale*this.rx,t.iScale*this.ry)}angleIsInArc(t){return t=_t.regularD(t),this.sweepAngle>0?(t<this.startAngle&&(t+=360),this.endAngle()>t):(t>this.startAngle&&(t-=360),this.endAngle()<t)}toBezier(){if(Math.abs(this.sweepAngle)>90)throw new Error("not support!");let t=this.start(),i=this.end(),r=_t.toRadians(this.sweepAngle)/2,s=4/3*(1-Math.cos(r))/Math.sin(r)*this.rx;return new Ye([t,t.add(new ae(s,0).multiply3(ci.rotateD(this.startAngle+90))),i.add(new ae(s,0).multiply3(ci.rotateD(this.endAngle()-90))),i])}toBezier2(){let t=[];r(this,90);let i=[];return t.forEach(s=>i.push(s.toBezier())),i;function r(s,n){if(Math.abs(s.sweepAngle)>n){let a=s.sweepAngle/2;r(ri.build3(s.center,s.startAngle,a,s.rx,s.ry),n),r(ri.build3(s.center,s.startAngle+a,a,s.rx,s.ry),n)}else t.push(s)}}buildBBox(){let t=UT.getCache().boxCache,i=this.startAngle+this.sweepAngle;if(t[0]=Math.min(this._start.x,this._end.x),t[1]=Math.max(this._start.x,this._end.x),t[2]=Math.min(this._start.y,this._end.y),t[3]=Math.max(this._start.y,this._end.y),this.sweepAngle>0){let r=0;for(;r<i;){if(r>this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r+=90}}else if(this.sweepAngle<0){let r=360;for(;r>i;){if(r<this.startAngle){let s=this.pointOn(r);t[0]=Math.min(t[0],s.x),t[1]=Math.max(t[1],s.x),t[2]=Math.min(t[2],s.y),t[3]=Math.max(t[3],s.y)}r-=90}}return new Pi(t[0],t[1],t[2],t[3])}bbox(){return this.__bbox==null&&(this.__bbox=this.buildBBox()),this.__bbox}length(){return Math.abs(this.rx*this.sweepAngle*Math.PI/180)}toString(){return Hc.format("Arc [start=%s, end=%s, rx=%s, ry=%s, center=%s, startAngle=%s, sweepAngle=%s]",this._start,this._end,this.rx,this.ry,this.center,this.startAngle,this.sweepAngle)}stroke(t,i,r){let s=t/2,n=this.rx+s,a=this.ry+s,o=this.rx-s,l=this.ry-s,h=new ci;o<0&&(o=-o,h=h.multiply3(ci.MIRROR_Y)),l<0&&(l=-l,h=h.multiply3(ci.MIRROR_X)),o===0&&(o=.001),l===0&&(l=.001),h=h.setOrigin1(this.center);let c,d;switch(r===this.sweep()?(c=ri.build3(this.center,this.startAngle,this.sweepAngle,n,a),d=ri.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,o,l)):(c=ri.build3(this.center,this.startAngle+this.sweepAngle,-this.sweepAngle,n,a),d=ri.build3(this.center,this.startAngle,this.sweepAngle,o,l)),d=d.multiply3(h),i){case 1:{let f=r===1?180:-180,u=r===this.sweep()?this.pointOn(this.endAngle()):this.pointOn(this.startAngle),p=r===this.sweep()?this.pointOn(this.startAngle):this.pointOn(this.endAngle()),g=c.pointOn(c.endAngle()).angleD(u),_=d.pointOn(d.endAngle()).angleD(p);return It.build2([c,ri.build3(u,g,f,s,s),d,ri.build3(p,_,f,s,s)])}default:return It.build2([c,d])}}points2(){let t=Math.ceil(Math.abs(this.sweepAngle)/rG),i=this.sweepAngle/t,r=[this._start];for(let s=1;s<t;s++)r.push(this.pointOn(this.startAngle+i*s));return r.push(this._end),r}points1(t){let i=Math.max(this.rx,this.ry);if(i<=t)return[this.start(),this.svgEnd];let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/_t.toDegrees(Math.acos(r))/2)),n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle;for(let l=0;l<=s;l++,o+=a)n[l]=this.pointOn(o);return n}points(t){let i=Math.max(this.rx,this.ry);if(t=Math.abs(t),i<=t)return[this.start(),this.svgEnd];t=Math.max(t,i*1e-5),t=Math.min(t,i*(1-Math.SQRT1_2));let r=(i-t)/i,s=Math.ceil(Math.abs(this.sweepAngle/_t.toDegrees(Math.acos(r))/2));s=Math.max(s,2);let n=new Array(s+1),a=this.sweepAngle/s,o=this.startAngle+a;n[0]=this.start();for(let l=1;l<s;l++,o+=a)n[l]=this.pointOn(o);return n[s]=this.end(),n}panDistance(t){return this.sweepAngle>0?new ri(this.rx-t,this.ry-t,this.center,this.startAngle,this.sweepAngle):new ri(this.rx+t,this.ry+t,this.center,this.startAngle,this.sweepAngle)}panDistance1(t){if(this.sweepAngle>0){let i=this.rx-t;return i<0?(i=Math.abs(i),ri.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new ri(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;return i<0?(i=Math.abs(i),ri.build3(this.center,this.startAngle-180,this.sweepAngle,i,i)):new ri(i,i,this.center,this.startAngle,this.sweepAngle)}}get bulge(){let t=Math.abs(CU(this.sweepAngle,3))/180*Math.PI;return Math.tan(t/4)}get midPoint(){let t=_t.toRadians(this.startAngle),i=_t.toRadians(this.endAngle()),r=this.sweep(),s=this.center,n=this.rx;if(r==1)if(i>t){let a=(i-t)/2+t;return s.add(new ae(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new ae(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(i+n_-t)/2+t;return s.add(new ae(Math.cos(a),Math.sin(a)).mul(n))}}else if(i>t){let a=(t+n_-i)/2+i;return s.add(new ae(Math.cos(a),Math.sin(a)).mul(n))}else{if(i==t)return s.add(new ae(Math.cos(Math.PI*3/2),Math.sin(Math.PI*3/2)).mul(n));{let a=(t-i)/2+i;return s.add(new ae(Math.cos(a),Math.sin(a)).mul(n))}}}get svgPathData(){return[{type:"M",values:[this._start.x,this._start.y]},{type:"A",values:[this.rx,this.ry,0,this.isLarge()?1:0,this.isCCW,this._end.x,this._end.y]}]}equals(t){let i=_t.regularD(this.startAngle),r=_t.regularD(this.sweepAngle),s=_t.regularD(t.startAngle),n=_t.regularD(t.sweepAngle);return Xn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(Xn([r,i],[n,s])||Xn([_t.regularD(i+r)],[s]))}equals1(t){let i=_t.regularD(this.startAngle),r=_t.regularD(this.sweepAngle),s=_t.regularD(t.startAngle),n=_t.regularD(t.sweepAngle);return Xn([this.rx,this.ry,this.center,Math.abs(r)],[t.rx,t.ry,t.center,Math.abs(n)])&&(Xn([r,i],[n,s])||Xn([_t.regularD(i+r)],[s]))}inArea(t,i){let r=t.x,s=t.y,n=this.center,a=this.rx,o=_t.toRadians(this.startAngle);this.sweep()==0&&(o=_t.toRadians(this.endAngle()));let l=_t.toRadians(this.endAngle());this.sweep()==0&&(l=_t.toRadians(this.startAngle));let h=a-i/2,c=a+i/2;var d=r-n.x,f=s-n.y,u=Math.atan2(f,d);if(u<0&&(u+=n_),o<=l&&u>=o&&u<=l||o>l&&(u>=o&&u<=n_||u>=0&&u<=l)||o==l){var p=Math.sqrt(d*d+f*f);return p<=c&&p>=h}else{var p=(c+h)/2,g=new ae(n.x+Math.cos(o)*p,n.y+Math.sin(o)*p),_=new ae(n.x+Math.cos(l)*p,n.y+Math.sin(l)*p),y=r-g.x,m=s-g.y,O=r-_.x,b=s-_.y;return y*y+m*m<=i*i/4?!0:O*O+b*b<=i*i/4}}isCircle(){return(ve.eq(Math.abs(this.sweepAngle),360)||this._start.equals1(this._end))&&this.rx==this.ry}reverse(){return ri.build3(this.center,this.endAngle(),-this.sweepAngle,this.rx,this.ry)}getAngle(){let t=Math.PI*2;return this.sweep()==1?(this.endAngle()-this.startAngle+t)%t:(this.startAngle-this.endAngle()+t)%t}isValid(){return this.rx>0&&this.ry>0}panDistance2(t){if(this.sweepAngle>0){let i=this.rx-t;if(i===0)return new le(this.center,this.center);if(i<ve.eps){i=Math.abs(i);let r=ri.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new le(r.start(),r.end()):r}return new ri(i,i,this.center,this.startAngle,this.sweepAngle)}else{let i=this.rx+t;if(i===0)return new le(this.center,this.center);if(i<ve.eps){i=Math.abs(i);let r=ri.build3(this.center,this.startAngle-180,this.sweepAngle,i,i);return r.area()<1e-5?new le(r.start(),r.end()):r}return new ri(i,i,this.center,this.startAngle,this.sweepAngle)}}},GT=new ArrayBuffer(24),z1=new Float64Array(GT),Dc=new Int32Array(GT),lo=class qn{static normal(t,i,r){let s=i.sub(t),n=r.sub(i);return s.cross(n)}static random(){return new qn(t(),t(),t()).normalize();function t(){return Math.sqrt(-2*Math.log(Math.random()))*Math.cos(2*Math.PI*Math.random())}}constructor(t,i,r){this.x=si.normal(t),this.y=si.normal(i),this.z=si.normal(r),z1[0]=t,z1[1]=i,z1[2]=r,this.hashed=Dc[0]^Dc[1]^Dc[2]^Dc[3]^Dc[4]^Dc[5]}isNormalized(){return ve.eq(this.length(),1)}isZeroVector(){return this.x===0&&this.y===0&&this.z===0}hashCode(){return this.hashed}equals(t){return t instanceof qn?t.x===this.x&&t.y===this.y&&t.z===this.z:!1}cross(t){return new qn(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){var t=this.length();return new qn(this.x/t,this.y/t,this.z/t)}sub(t){return new qn(this.x-t.x,this.y-t.y,this.z-t.z)}add(t){return new qn(this.x+t.x,this.y+t.y,this.z+t.z)}scale(t){return new qn(this.x*t,this.y*t,this.z*t)}neg(){return new qn(-this.x,-this.y,-this.z)}multiply4(t){var i=this.x*t.data[0]+this.y*t.data[4]+this.z*t.data[8]+t.data[12],r=this.x*t.data[1]+this.y*t.data[5]+this.z*t.data[9]+t.data[13],s=this.x*t.data[2]+this.y*t.data[6]+this.z*t.data[10]+t.data[14],n=this.x*t.data[3]+this.y*t.data[7]+this.z*t.data[11]+t.data[15];return n!=0?new qn(i/n,r/n,s/n):new qn(i,r,s)}rotate(t,i){return this.multiply4(Bi.rotateAxis(t,i))}toVector2(){return new ae(this.x,this.y)}};lo.ORIGIN=new lo(0,0,0),lo.X_UNIT_VECTOR=new lo(1,0,0),lo.Y_UNIT_VECTOR=new lo(0,1,0),lo.Z_UNIT_VECTOR=new lo(0,0,1);var xt=lo,Kn=class{constructor(){this.clear()}clear(){this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.minZ=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY,this.maxZ=Number.NEGATIVE_INFINITY}ext1(e,t,i,r,s,n){if(e<=r&&t<=s&&i<=n)this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,t),this.minZ=Math.min(this.minZ,i),this.maxX=Math.max(this.maxX,r),this.maxY=Math.max(this.maxY,s),this.maxZ=Math.max(this.maxZ,n);else throw new Error("min > max is not permitted");return this}ext2(e,t,i){return this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,t),this.minZ=Math.min(this.minZ,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,t),this.maxZ=Math.max(this.maxZ,i),this}ext3(e){return this.ext2(e.x,e.y,e.z)}ext4(e){return this.ext1(e.minX,e.minY,e.minZ,e.maxX,e.maxY,e.maxZ)}ext5(e,t){return this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,t),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,t),this}ext6(e){return this.minZ=Math.min(this.minZ,e),this.maxZ=Math.max(this.maxZ,e),this}ext7(e){return this.minX=Math.min(this.minX,e.minX),this.minY=Math.min(this.minY,e.minY),this.maxX=Math.max(this.maxX,e.maxX),this.maxY=Math.max(this.maxY,e.maxY),this}isValid(){return isFinite(this.minX)&&isFinite(this.minY)&&isFinite(this.minZ)&&isFinite(this.maxX)&&isFinite(this.maxY)&&isFinite(this.maxZ)}build(){return new Oo(this.minX,this.minY,this.minZ,this.maxX,this.maxY,this.maxZ)}},Oo=class{constructor(e,t,i,r,s,n){if(e<=r&&t<=s&&i<=n)this.minX=si.normal(e),this.minY=si.normal(t),this.minZ=si.normal(i),this.maxX=si.normal(r),this.maxY=si.normal(s),this.maxZ=si.normal(n);else throw new Error("min > max is not permitted")}center(){return new xt((this.minX+this.maxX)/2,(this.minY+this.maxY)/2,(this.minZ+this.maxZ)/2)}transform(e){let t=new Kn;for(let i of this.getVertexes())t.ext3(i.multiply4(e));return t.build()}isContains(e){return!(e.x<this.minX||e.y<this.minY||e.z<this.minZ||e.x>this.maxX||e.y>this.maxY||e.z>this.maxZ)}getVertexes(){return[new xt(this.minX,this.minY,this.minZ),new xt(this.minX,this.minY,this.maxZ),new xt(this.minX,this.maxY,this.minZ),new xt(this.minX,this.maxY,this.maxZ),new xt(this.maxX,this.minY,this.minZ),new xt(this.maxX,this.minY,this.maxZ),new xt(this.maxX,this.maxY,this.minZ),new xt(this.maxX,this.maxY,this.maxZ)]}diagonalLength(){let e=this.maxX-this.minX,t=this.maxY-this.minY,i=this.maxZ-this.minZ;return Math.sqrt(e*e+t*t+i*i)}toBBox2(){return new Pi(this.minX,this.maxX,this.minY,this.maxY)}},bi=class kc{static build(t){return t instanceof It?new kc([new or([t])]):t instanceof or?new kc([t]):t}static buildByPolygon(t){return t?new kc([t]):new kc([])}static buildByStroke(t,i,r=1,s){return this.buildByPolygon(or.buildByStroke(t,i,r,bb,s))}static buildCircle(t,i){return this.buildByPolygon(or.buildCircle(t,i))}static buildRect(t){return this.buildByPolygon(or.buildRect(t))}static buildBBox(t){return this.buildByPolygon(or.buildBBox(t))}constructor(t){this.items=t.slice()}multiply3(t){return new kc(this.items.map(i=>i.multiply3(t)))}bbox(){return this._bbox||(this._bbox=this.items.reduce((t,i)=>t.ext1(i.bbox()),new yi).build1()),this._bbox}toPolylineGroups(){return this.items.map(t=>t.toPolylineGroup())}},kr=class vn{static isHexFormate(t){return!t||typeof t!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}static of1(t){return this.of2(t>>16&255,t>>8&255,t&255)}static of2(t,i,r,s=255){return new vn(t/255,i/255,r/255,s/255)}static of3(t){t.startsWith("#")&&(t=t.substr(1));let i=t.length;if(i==3)return new vn(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return new vn(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255);if(i==8)return new vn(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,parseInt(t.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(t){let i=parseInt(t.r*255+"").toString(16),r=parseInt(t.g*255+"").toString(16),s=parseInt(t.b*255+"").toString(16);return i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),s.length<2&&(s="0"+s),("#"+i+r+s).toUpperCase()}static of5(t,i){if(t.startsWith("#")&&(t=t.substr(1)),t.length==3)return new vn(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return new vn(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,i);throw new Error("invalid color string")}static of6(t,i){return new vn(t.r,t.g,t.b,i)}static of7(t){return t==null?null:vn.of3(t)}constructor(t,i,r,s=1){this.r=si.positiveOr0(t),this.g=si.positiveOr0(i),this.b=si.positiveOr0(r),this.alpha=s}hashCode(){return this.r+this.g+this.b+this.alpha}equals(t,i=!1){let r=this.r===t.r&&this.g===t.g&&this.b===t.b;return i?r:r&&this.alpha===t.alpha}add(t,i,r,s){return new vn(Math.max(0,Math.min(1,this.r+t)),Math.max(0,Math.min(1,this.g+i)),Math.max(0,Math.min(1,this.b+r)),Math.max(0,Math.min(1,this.alpha+s)))}mul(t){return new vn(Math.max(0,Math.min(1,this.r*t)),Math.max(0,Math.min(1,this.g*t)),Math.max(0,Math.min(1,this.b*t)),this.alpha)}mul1(t){return new vn(Math.max(0,this.r*t),Math.max(0,this.g*t),Math.max(0,this.b*t),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toString1(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16),s=(this.alpha*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),s.length<2&&(s="0"+s),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)+s.substr(0,2)}toRGBA(){let t=this.r*255,i=this.g*255,r=this.b*255;return[t,i,r,this.alpha]}toRGBAString(){let t=this.r*255,i=this.g*255,r=this.b*255;return`rgba(${t},${i},${r},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}};kr.WHITE=new kr(1,1,1,1),kr.BLACK=new kr(0,0,0,1),kr.RED=new kr(1,0,0,1),kr.GREEN=new kr(0,1,0,1),kr.BLUE=new kr(0,0,1,1),kr.Gray=kr.of3("#9966ff"),kr.Silver=kr.of3("#D2D2D2"),kr.Golden=kr.of3("#DCAA14"),kr.Pink=kr.of3("#ffaec9");var Ht=kr,OT=!1,zT=class{onRTreeBBox(e){}onResultSide(e){}onOriginSide(e){}onSplitedSide(e){}onDebugSide(e){}onSweep(e,t,i,r,s,n){}onIntersect(e,t,i){}onSegment(e,t,i,r,s,n){}onSegment1(e,t,i){if(OT){let r=new ae(e.getX(i),i),s=new ae(t.getX(i),i);this.onSegment(r,e.weight,e,s,t.weight,t)}else this.onSegment(e.start,e.weight,e,t.end,t.weight,t)}onSweep1(e,t,i){if(OT){let r=new ae(e.getX(i),i),s=new ae(t.getX(i),i);this.onSweep(r,e.weight,e,s,t.weight,t)}else this.onSweep(e.start,e.weight,e,t.end,t.weight,t)}},cf=class extends zT{constructor(e){super(),this.plGrps=new Array,this.debug=e}onPolylineGroup(e,t){this.plGrps.push(e)}},_f=class{constructor(e){this.cache={},this.levels=e,this.result=new Array(e),this.weights=new Array(e),this.maxIdx=e-1,this.rule=this.decide.bind(this);let t=1;for(let i=0;i<e;i++)this.weights[i]=t,t*=50}weight(e){return this.weights[e]}decide(e){e=Math.abs(e);let t=this.cache[e];if(t===void 0){let i=e;for(let r=this.maxIdx;r>=0;r--){let s=this.weights[r],n=e/s|0,a=e%s;a>(s/2|0)?(e=s-a,n++):e=a,this.result[r]=n>0}t=this.decide1(this.result),this.cache[i]=t}return t}},sG=e=>e!==0;var nG=new class extends _f{decide1(e){return e[0]||e[1]}}(2),g_=new class extends _f{decide1(e){return e[0]&&!e[1]}}(2),__=new class extends _f{decide1(e){return e[0]&&e[1]}}(2),H1=new class extends _f{decide1(e){return e[0]&&!e[1]||!e[0]&&e[1]}}(2),qc=class Fc{constructor(t,i,r,s,n,a,o){this.inters=[],this.connect=new Array,this.previous=null,this.next=null,this.finalGrp=-1,this.trans=NaN,this.outsideWeight=0,this.insideWeight=0,this.invalidWeight=0,this._confidence=0,this._confidence_y=NaN,this._x=NaN,this._x_y=NaN,this.status=0,this.bo=t,this.shape=i,this.baseWeight=r,s.y>n.y?this.weight=-r:s.y==n.y?this.weight=0:this.weight=r,this.start=s,this.end=n,this.polyGrp=a,this.polyIndex=o,this._bbox=new yi().ext1(i.bbox()).ext2(s).ext2(n).build1(),this.inters.push(s),this.inters.push(n);let l=31,h=1;h=l*h+this.polyGrp,h=l*h+this.polyIndex,this._hashcode=h}static rebuild(t,i,r){if(t instanceof le||i.distance2(r)<1e-6)return new le(i,r);if(t instanceof ye){let s=t,n=t.bbox().center().x,a;i.y>r.y?a=n>s.center.x?0:1:a=n>s.center.x?1:0;let o=i.angleD(s.center),l=r.angleD(s.center);return ye.build2(s.center,o,l,s.rx,s.ry,a)}else throw new Error("not supported operation")}updateBbox(){this._bbox=new yi().ext2(this.start).ext2(this.end).build1()}is(t,i){return t===this.polyGrp&&i===this.polyIndex}confidence(t){if(this._confidence_y!=t){let i=this._bbox.height();if(i!==0)if(Math.abs(t-this._bbox.maxY)>5e-4&&Math.abs(t-this._bbox.minY)>5e-4){let r=1-Math.abs(2*t-this._bbox.maxY-this._bbox.minY)/i;this._confidence=r*1e4|0}else this._confidence=0;else this._confidence=1;this._confidence_y=t}return this._confidence}needCountWeight(){return this.outsideWeight+this.insideWeight+this.invalidWeight<5e3}revokeOutside(t){let i=this.confidence(t);return this.outsideWeight-=i,this.invalidWeight+=i,i}revokeInside(t){let i=this.confidence(t);return this.insideWeight-=i,this.invalidWeight+=i,i}setOutside(t){let i=this.confidence(t);return this.outsideWeight+=i,i}setInside(t){let i=this.confidence(t);return this.insideWeight+=i,i}setInvalid(t){let i=this.confidence(t);return this.invalidWeight+=i,i}prevNot0(){let t=this.previous;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.previous}return null}nextNot0(){let t=this.next;for(;t!=null&&t!=this;){if(t.weight!=0)return t;t=t.next}return null}getX(t){if(this.bo!==null)return(this._x_y!=t||isNaN(this._x))&&(fG(this,t)>0?this._x=$[0]:this._x=NaN,this._x_y=t),this._x;throw new Error("not supported operation")}voteStatus(){return this.outsideWeight>this.insideWeight&&this.outsideWeight>this.invalidWeight?2:this.insideWeight>this.outsideWeight&&this.insideWeight>this.invalidWeight?1:this.invalidWeight>this.outsideWeight&&this.invalidWeight>this.insideWeight?3:0}reverse(t){if(t===2)if(this.start.y>this.end.y){let i=Fc.rebuild(this.shape,this.end,this.start),r=new Fc(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return hs.addAll(r.connect,this.connect),r}else return this;else if(t===1)if(this.start.y<this.end.y){let i=Fc.rebuild(this.shape,this.end,this.start),r=new Fc(this.bo,i,this.baseWeight,this.end,this.start,this.polyGrp,this.polyIndex);return hs.addAll(r.connect,this.connect),r}else return this;return this}isNeedScan(t){return this.needCountWeight()&&this.confidence(t)>0}hashCode(){return this._hashcode}equals(t){return t instanceof Fc?!(this.polyGrp!==t.polyGrp||this.polyIndex!==t.polyIndex):!1}bbox(){return this._bbox}toString(){return Hc.format("(%d,%d,%d) (%d,%d,%d) %s %s",this.polyGrp,this.polyIndex,this.weight,this.outsideWeight,this.invalidWeight,this.insideWeight,this.start,this.end)}};function aG(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minY+i.maxY)/2,n=(r.minY+r.maxY)/2;return s-n}function oG(e,t){let i=e.bbox(),r=t.bbox(),s=(i.minX+i.maxX)/2,n=(r.minX+r.maxX)/2;return s-n}var Rc=class{constructor(e){if(this.__bbox=null,typeof e<"u")if(e instanceof Array){this.__items=[];for(let t of e)this.add(t)}else this.__items=e,this.__bbox=e.bbox();else this.__items=[]}add(e){if(this.__items instanceof Array)this.__items.push(e),this.__bbox=Pi.extend2(this.__bbox,e.bbox());else throw new Error("can't insert multiple item into leaf node")}items(){return this.__items}bbox(){if(this.__bbox!==null)return this.__bbox;throw new Error("bug")}},ff=class{constructor(e){this.changed=!1,this.root=new Rc,this.capacity=e,this.capacity2=e*e,this.itemList=[]}size(){return this.itemList.length}items(){return this.flushWhenNeed(),this.itemList}add(e){this.itemList.push(e),this.changed=!0}remove(e){hs.remove(this.itemList,e),this.changed=!0}clear(){this.changed=!1,this.root=new Rc,this.itemList.length=0}flushWhenNeed(){if(this.changed){let e=new Array;for(let t of this.itemList)e.push(new Rc(t));for(;;){let t=this.organize(e);if(t.length>1)e=t;else break}this.root=new Rc(e),this.changed=!1}}organize(e){ah(e,oG,0,e.length);let t=e.length,i=[];for(let r=0;r<t;)if(r+this.capacity2<=t){let s=r+this.capacity2;ah(e,aG,r,s);for(let n=r;n<s;n+=this.capacity){let a=new Rc(e.slice(n,n+this.capacity));i.push(a)}r=r+this.capacity*this.capacity}else{let s=new Rc(e.slice(r,r+this.capacity));i.push(s),r=r+this.capacity}return i}search(e){this.flushWhenNeed();let t=[],i=[];for(i.push(this.root);;){let r=i.shift();if(typeof r<"u"){let s=r.items();if(s instanceof Array){for(let n of s)if(!e.isSeparated(n.bbox())){let a=n.items();a instanceof Array?i.push(n):t.push(a)}}else e.isSeparated(r.bbox())||t.push(s)}else break}return t}walker(e){this.flushWhenNeed(),this._walker(this.root,0,e)}_walker(e,t,i){this.flushWhenNeed();let r=e.items();if(r instanceof Array)for(let s of r)this._walker(s,t+1,i);else i(r,t)}bbox(){return this.flushWhenNeed(),this.root.bbox()}};function j1(e,t){lG(e.iterator(),t)}function lG(e,t){let i=0;for(;e.hasNext();){let r=e.next();t(i++,r)}}var a_=new Error("list is empty"),o_=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},hG=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},cG=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},sh=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw a_;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw a_;return this.remove(e),e.item}addLast(e){return this.first===null||this.last===null?(this.first=new o_(this,e),this.last=this.first,this.cnt=1,this.first):this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new o_(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw a_;return this.first.item}getLast(){if(this.last===null)throw a_;return this.last.item}insertAfter(e,t){let i=new o_(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new o_(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new hG(this.first)}listIterator(){return new cG(this.first)}toArray(){let e=new Array(this.cnt),t=this.first,i=0;for(;t!=null;)e[i]=t.item,t=t.next,i++;return e}};function V1(e){throw new Error("")}var l_=class{constructor(e,t){this.node1=null,this.node2=null,this.key=e,this.value=t}},uG=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().key}},dG=class{constructor(e){this.itors=e}hasNext(){return this.itors.hasNext()}next(){return this.itors.next().value}},T_=class{constructor(){this.innerList=new sh,this.innerMap={}}replace(e,t){e.node1!==null&&(e.node1.set(t),t.node1=e.node1),e.node2!==null&&(e.node2.set(t),t.node2=e.node2)}clear(){this.innerList.clear();for(let e in this.innerMap)delete this.innerMap[e]}put(e,t){let i=e.hashCode(),r=new l_(e,t),s=this.innerMap[i];if(s===void 0)return r.node1=this.innerList.add(r),this.innerMap[i]=r,null;if(s instanceof l_){if(s.key.equals(e))return this.innerMap[i]=r,this.replace(s,r),s.value;{r.node1=this.innerList.add(r);let n=new sh;return s.node2=n.add(s),r.node2=n.add(r),this.innerMap[i]=n,null}}if(s instanceof sh){let n=null;return j1(s,(a,o)=>o.key.equals(e)?(this.replace(o,r),n=o.value,!1):!0),n===null?(r.node1=this.innerList.add(r),r.node2=s.push(r),null):n}return V1(s)}get(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof l_)return i.key.equals(e)?i.value:null;if(i instanceof sh){let r=null;return j1(i,(s,n)=>n.key.equals(e)?(r=n.value,!1):!0),r}return V1(i)}containsKey(e){return this.get(e)!==null}delete(e){e.node1!==null&&e.node1.parent.remove(e.node1),e.node2===null?delete this.innerMap[e.key.hashCode()]:e.node2.parent.remove(e.node2)}remove(e){let t=e.hashCode(),i=this.innerMap[t];if(i===void 0)return null;if(i instanceof l_)return i.key.equals(e)?(this.delete(i),i.value):null;if(i instanceof sh){let r=null;return j1(i,(s,n)=>n.key.equals(e)?(r=n.value,this.delete(n),!1):!0),r}return V1(i)}computeIfAbsent(e,t){let i=this.get(e);if(i===null){let r=t(e);return this.put(e,r),r}else return i}size(){return this.innerList.size()}isEmpty(){return this.innerList.size()===0}keys(){return new uG(this.innerList.iterator())}values(){return new dG(this.innerList.iterator())}entries(){return this.innerList.iterator()}},Yc=class{constructor(){this.innerMap=new T_}add(e){return this.innerMap.put(e,!0)!==!0}remove(e){this.innerMap.remove(e)}contains(e){return this.innerMap.get(e)===!0}iterator(){return this.innerMap.keys()}addAll(e){let t=e.iterator();for(;t.hasNext();)this.add(t.next())}size(){return this.innerMap.size()}clear(){let e=this.iterator();for(;e.hasNext();){let t=e.next();this.remove(t)}}},mT=hs.funcCopy(ah);function fG(e,t){let i=0;if(Math.abs(e.start.y-t)<=1e-4)$[i++]=e.start.x;else if(Math.abs(e.end.y-t)<=1e-4)$[i++]=e.end.x;else if(e.shape instanceof le)i=NU(e.shape,t);else if(e.shape instanceof ye)i=MU(e.shape,t);else throw new Error("not supported operation");return i}var O_=class{constructor(e,t,i,r){this.sides=new Array,this.loader=e,this.loader.bo=this,this.logger=i,this.rule=t,this.event=r}static sortByBBoxMinY(e,t){return e.bbox().minY-t.bbox().minY}static sortByBBoxAreaDesc(e,t){return t.bbox().area()-e.bbox().area()}addPolyline(e,t=1,i=.01,r=!0){for(let s of this.loader.buildGroup(e,t,i,r))this.sides.push(s),this.event.onOriginSide(s)}buildRTree(){let e=new ff(10);for(let t of this.sides)e.add(t);return e}fillValidSides(e,t,i){for(let r of t)isFinite(r.getX(i))&&e.push(r)}getSortedEndpointsLineAsc(e){let t=new Array;for(let s of e)s.needCountWeight()&&(t.push(s.start),t.push(s.end));mT(t,ae.sortByYAsc,0,t.length);let i=new Array,r=Number.NEGATIVE_INFINITY;for(let s of t){let n=s.y;n>r&&(i.push(n),r=n)}return i}splitSides(e,t,i){let r=e.start,s=e.end,n=new ae(s.x+(r.x-s.x)*2,s.y+(r.y-s.y)*2);mT(e.inters,(o,l)=>o.distance2(n)-l.distance2(n),0,e.inters.length);let a=null;for(let o of e.inters)if(a==null)o.equals(r)&&(a=o);else if(!o.equals(a)){let l=qc.rebuild(e.shape,a,o);l instanceof ye&&Math.abs(l.sweepAngle)>190&&(l=new le(a,o));let h=new qc(this,l,e.baseWeight,a,o,e.polyGrp,i++);if(t.push(h),h.updateBbox(),o.equals(s))break;a=o}return i}splitSidesByInters(){let e=new Array;for(let t of this.sides)if(t.polyIndex==0){let i=0,r=null,s=null;do{let n=new Array;i=this.splitSides(t,n,i);for(let a of n)r!=null?(r.next=a,a.previous=r):s=a,r=a,this.event.onSplitedSide(a),e.push(a);if(t.next===null)throw new Error("not supported operation");t=t.next}while(t.polyIndex!==0);s!=null&&r!=null&&(s.previous=r,r.next=s)}this.sides.length=0;for(let t of e)this.sides.push(t)}seekIntersection(){if(this.sides.length>0){let e=this.buildRTree(),t=new Yc;for(let i of this.sides){t.add(i);let r=i.bbox().extendOfSize(1e-5),s=i.shape instanceof le;for(let n of e.search(r))if(!t.contains(n)){let a=n.shape instanceof le;if(!(s&&a&&i.next!==null&&i.previous!==null&&(i.next.equals(n)||i.previous.equals(n)))){let o=xn(i.shape,n.shape);for(let l=0;l<o;l+=2){let h=new ae($[l],$[l+1]);i.inters.push(h),n.inters.push(h),this.event.onIntersect(h,i,n)}}}}}}},pG=class HT{constructor(t){this.sides=new Yc,this.others=new Yc,this.id=t}add(t){this.sides.add(t),t.finalGrp=this.id;for(let i of t.connect)this.others.add(i)}polyline(){let t=new Array;return Vc(this.sides,(i,r)=>(t.push(r.shape),!0)),It.build2(t).asClose()}hashCode(){return this.id}equals(t){return t!=null&&t instanceof HT?this.id===t.id:!1}},jT=class{constructor(e){this.bo=null,this.sides=new Array,this.polyGrp=0,this.polyIndex=0,this.prevSide=null,this.firstSide=null,this.noWeight0=e}completeGroup(e){this.prevSide!=null&&this.firstSide!=null&&!this.prevSide.end.equals(this.firstSide.start)&&this.addSide(new le(this.prevSide.end,this.firstSide.start),e);let t=new Array,i=null,r=null;for(let s of this.sides)(!this.noWeight0||s.weight!==0)&&(i!=null?(i.next=s,s.previous=i):r=s,i=s,t.push(s));return i!=null&&r!=null&&(r.previous=i,i.next=r),this.polyGrp++,this.sides.length=0,this.prevSide=null,this.firstSide=null,this.polyIndex=0,t}buildGroup(e,t,i,r=!0){for(let s of e.primitives)if(s instanceof le)this.addSide(s,t);else if(r&&s instanceof ye&&s.rx===s.ry)this.addArc(s,t);else{let n=null;for(let a of s.points(i))n!=null&&this.addSide(new le(n,a),t),n=a}return this.completeGroup(t)}addArc(e,t){let i=e.sweepAngle,r=_t.regularD(e.startAngle),s=r+i;if(i>0){let n=90;for(;n<=s;)n>r&&(this.addSide(ye.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n+=90;r<s&&this.addSide(ye.build3(e.center,r,s-r,e.rx,e.ry),t)}else if(i<0){let n=270;for(;n>=s;)n<r&&(this.addSide(ye.build3(e.center,r,n-r,e.rx,e.ry),t),r=n),n-=90;r>s&&this.addSide(ye.build3(e.center,r,s-r,e.rx,e.ry),t)}}addSide(e,t){if(e.start().equals(e.end()))return;let i=e.start(),r;this.prevSide!=null?(this.prevSide.end.equals(i)||this.addSide(new le(this.prevSide.end,i),t),r=new qc(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++)):(r=new qc(this.bo,e,t,e.start(),e.end(),this.polyGrp,this.polyIndex++),this.firstSide=r),this.prevSide=r,this.sides.push(r)}},VT=class{constructor(e,t,i){this.eps=new Array,this.curWeight=0,this.start=null,this.last=null,this.prevStart=null,this.prevEnd=null,this.y=i,this.rule=e,this.bo=t,this.event=t.event}onEp(e){this.tuningWeight(e),this.start===null?this.rule(this.curWeight)?this.in(e):e.setInvalid(this.y):this.rule(this.curWeight)?e.setInvalid(this.y):this.out(e,this.start),this.last!==null&&this.event.onSweep1(this.last,e,this.y),this.last=e}in(e){this.prevEnd!=null&&this.onSameX(e,this.prevEnd)?(this.start=this.prevStart,this.prevStart=null,this.prevEnd.revokeInside(this.y),this.prevEnd=null):(this.start=e,this.start.setOutside(this.y))}out(e,t){if(this.onSameX(t,e))t.revokeOutside(this.y);else{if(e.setInside(this.y)>0&&t.confidence(this.y)>0){let i=t.voteStatus(),r=e.voteStatus();this.isValid(i)&&this.isValid(r)?i==2&&r==1&&(e.connect.push(t),t.connect.push(e)):(e.connect.push(t),t.connect.push(e))}this.event.onSegment1(t,e,this.y),this.eps.push(t),this.eps.push(e),this.prevStart=t,this.prevEnd=e}this.start=null}isValid(e){return e==1||e==2}onSameX(e,t){return e.bbox().isIntersect(t.bbox())&&ve.eq(e.getX(this.y),t.getX(this.y))}tuningWeight(e){this.curWeight+=e.weight;let t=e.nextNot0(),i=e.prevNot0();t!=null&&e.weight===t.weight&&t.trans===this.y&&(this.curWeight-=e.weight),i!=null&&e.weight===i.weight&&i.trans===this.y&&(this.curWeight-=e.weight),e.trans=this.y}},S_=new Error,bT=new class extends _f{decide1(e){return e[0]&&e[1]}}(2),gG=new class extends zT{onPolylineGroup(e,t){throw S_}onSegment(e,t,i,r,s,n){throw S_}},_G=class{constructor(e,t){this.rtree=e,this.level=t}},OG=class YT extends O_{static isIntersect(t,i,r=L_.DUMMY){let s=new YT(r),n=s.createGroup1(t.items),a=s.createGroup2(i.items);return n.rtree.itemList.length==0||a.rtree.itemList.length==0?!1:s.isIntersect(n,a)}constructor(t){super(new jT(!1),bT.rule,t,gG)}createGroup1(t){return this.createGroup(t,0)}createGroup2(t){return this.createGroup(t,1)}createGroup(t,i){let r=bT.weight(i);for(let n of t)this.addPolyline(n,r);let s=this.buildRTree();return this.sides.length=0,new _G(s,i)}isIntersect(t,i){if(t.level!==i.level){let r=t.rtree.bbox().intersection1(i.rtree.bbox());if(r!==null){try{this.inters(t,i);let s=(r.minY+r.maxY)/2;this.sweep(t,i,s)}catch(s){if(s===S_)return!0;throw s}return!1}else return!1}else throw new Error("inersection detection should not in same group")}inters(t,i){if(t.rtree.size()>i.rtree.size()){let r=t;t=i,i=r}for(let r of t.rtree.items()){r.trans=NaN;let s=r.bbox().extendOfSize(1e-5);for(let n of i.rtree.search(s))if(n.trans=NaN,xn(r.shape,n.shape)>0)throw S_}}sweep(t,i,r){let s=Pi.extend2(t.rtree.bbox(),i.rtree.bbox()).extendOfSize(1e-5),n=new Array;this.fillValidSides(n,t.rtree.search(s),r),this.fillValidSides(n,i.rtree.search(s),r),ah(n,(o,l)=>o.getX(r)-l.getX(r),0,n.length);let a=new VT(this.rule,this,r);for(let o of n)a.onEp(o)}},yb=class ho{constructor(t){this.items=new Array(t.length),hs.arraycopy(t,0,this.items,0,t.length),this.__bbox=this.calcBBox()}static build1(t){let i=[];return b_(t,(r,s)=>(i.push(s),!0)),new ho(i)}static build2(t){let i=t.map(r=>It.build8(r));return new ho(i)}static combinePolylineGroupArr(t){let i=[];for(let r of t)i=i.concat(r.items);return new ho(i)}calcBBox(){let t=new yi;for(let i=0;i<this.items.length;i++)t.ext1(this.items[i].bbox());return t.build1()}multiply3(t){let i=new Array(this.items.length);for(let r=0;r<i.length;r++)i[r]=this.items[r].multiply3(t);return new ho(i)}bbox(){return this.__bbox}asClose(){return this.items.forEach(t=>t.asClose()),this}mirrorY(t){return this.items.forEach(i=>i.mirrorY(t)),this}closeEndpoint(){return this.items.forEach(t=>t.closeEndpoint()),this}get primitives(){return this.items.map(t=>t.primitives).flat(2)}isEqual(t){return t instanceof ho?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items.reduce((t,i)=>i.bbox().area()>t.bbox().area()?i:t,this.items[0])}getOutline(){let t=this.items;if(t.length===1)return{outline:t,hole:new Array};let i=new Set,r=new Set;for(let s=0,n=t.length;s<n;s++){let a=t[s];if(!i.has(a)&&!r.has(a)){s+1>=n&&i.add(a);for(let o=s+1;o<n;o++){let l=t[o];if(!i.has(l)&&!r.has(l)){if(!a.bbox().isInside(l.bbox().extendOfSize(1e-4))&&!l.bbox().isInside(a.bbox().extendOfSize(1e-4)))continue;OG.isIntersect(new ho([a]),new ho([l]))&&(a.bbox().area()>l.bbox().area()?(i.add(a),r.add(l)):(i.add(l),r.add(a)))}}!i.has(a)&&!r.has(a)&&i.add(a)}}return{outline:[...i],hole:[...r]}}round(t=4){let i=this.items.map(r=>r.round(t));return new ho(i)}},mG=hs.funcCopy(ah),bG=hs.funcCopy(ah),yG=hs.funcCopy(ah);function vG(e){return new Array}function xG(e,t){let i=new cf(!1),r=new uf(e,L_.DUMMY,i);for(let s of t)r.addPolyline(s);return r.simplify(),i.plGrps}var uf=class extends O_{constructor(e,t,i){super(new jT(!1),e,t,i),this.finalSides=new Array,this.sideGroups={},this.vecSides=new Array,this.scanY=NaN,this.curNetIndex=0,this.curIndex=-1,this.scanLines=0}sweep(e,t,i){this.scanY=NaN,this.scanLines=0,mG(t,O_.sortByBBoxMinY,0,t.length);let r=new sh;this.curNetIndex=0;let s=Number.POSITIVE_INFINITY;for(let n of e)n>s&&this.scan(r,(s+n)/2,t),s=n;this.getAllMarkPrimitive(i,t),this.logger.debug3("scan %s %d",i,this.scanLines)}simplify(){this.seekIntersection(),this.splitSidesByInters(),this.sweep(this.getSortedEndpointsLineAsc(this.sides),this.sides,!1),this.flipSides(),this.sweep(this.getSortedEndpointsLineAsc(this.vecSides),this.vecSides,!0),this.connectSides(),this.fillResult()}addPolyline(e,t=1,i=.01,r=!0){super.addPolyline(e,t,i,r)}scan(e,t,i){if(this.scanY==t)return;this.scanY=t;let r=!1,s=e.listIterator();for(;s.hasNext();){let n=s.next(),a=n.item;ve.less(a.bbox().maxY,t)?e.remove(n):!r&&a.isNeedScan(t)&&(r=!0)}for(;this.curNetIndex<i.length;){let n=i[this.curNetIndex];if(ve.less(n.bbox().minY,t))ve.greatereq(n.bbox().maxY,t)&&(this.add2AET(e,n),!r&&n.isNeedScan(t)&&(r=!0)),this.curNetIndex++;else break}if(r){this.scanLines++;let n=new VT(this.rule,this,t),a=e.iterator();for(;a.hasNext();){let o=a.next();n.onEp(o)}}}add2AET(e,t){let i=t.bbox().minX,r=t.bbox().maxX,s=t.bbox().minY,n=t.bbox().maxY,a=e.listIterator(),o=null;for(;a.hasNext();){let l,h=a.next(),c=h.item,d=c.bbox().minX,f=c.bbox().maxX;if(r<=d)l=-1;else if(f<=i)l=1;else{let p=c.bbox().minY,g=c.bbox().maxY,_=Math.max(s,p),y=Math.min(n,g);l=this.compareBySweep(t,c,(_+y)/2)}let u=c.shape;if(u instanceof le&&u.length()<.001&&o==null&&l<0){o=h;continue}if(o!=null&&l<0){e.insertBefore(o,t);return}if(l<0){e.insertBefore(h,t);return}else o=null}e.add(t)}getLineAngle(e){let t=e.start().angle(e.end());return t<0&&(t+=Math.PI),t}getArcAngle(e,t){let i=Math.asin((t-e.center.y)/e.rx);return e.startAngle>90&&e.startAngle<270&&(i=-i),i<0&&(i+=Math.PI),(i+Math.PI/2)%Math.PI}compareArcLine(e,t,i){let r=this.getArcAngle(e,i),s=this.getLineAngle(t);return ve.eq(r,s)?-e.sweepAngle:s-r}compareBySweep(e,t,i){let r=e.getX(i);if(!isFinite(r))return 0;let s=t.getX(i);if(!isFinite(s))return 0;if(!ve.eq(r,s))return r-s;if(e.shape instanceof le)return t.shape instanceof le?this.getLineAngle(t.shape)-this.getLineAngle(e.shape):-this.compareArcLine(t.shape,e.shape,i);if(t.shape instanceof le)return this.compareArcLine(e.shape,t.shape,i);{let n=e.shape,a=t.shape,o=this.getArcAngle(n,i),l=this.getArcAngle(a,i);return ve.eq(o,l)?n.sweepAngle*a.sweepAngle<=0?n.sweepAngle<=0?1:-1:n.sweepAngle>0?n.rx-a.rx:a.rx-n.rx:l-o}}getAllMarkPrimitive(e,t){for(let i of t)if(i.status===0&&i.bbox().height()!=0){let r=i.voteStatus();if(r===2||r===1){i.status=r;let s=i.reverse(r);if(e){this.event.onResultSide(s);let n=s.shape.multiply3(ci.ROT_N90),a=s.start.multiply3(ci.ROT_N90),o=s.end.multiply3(ci.ROT_N90);s=new qc(this,n,s.baseWeight,a,o,s.polyGrp,s.polyIndex)}this.finalSides.push(s),this.event.onResultSide(s)}}}flipSides(){for(let e of this.sides)if(e.polyIndex==0){let t=null,i=null;do{let r=e.shape.multiply3(ci.ROT_90),s=e.start.multiply3(ci.ROT_90),n=e.end.multiply3(ci.ROT_90),a=new qc(this,r,e.baseWeight,s,n,e.polyGrp,e.polyIndex);if(a.outsideWeight=e.outsideWeight,a.insideWeight=e.insideWeight,a.invalidWeight=e.invalidWeight,a.status=e.status,t!=null?(t.next=a,a.previous=t):i=a,this.vecSides.push(a),this.event.onSplitedSide(a),t=a,e.next!==null)e=e.next;else break}while(e.polyIndex!=0);i!=null&&(i.previous=t,t.next=i)}}canBeEnd(e,t){if(e.size()==1){let i=e.getFirst().shape;if(i instanceof ye){if(t&&i.rx<=t)return!1}else if(i instanceof le&&t&&i.length()<=t)return!1}return!0}connectSides(){let e=new T_,t=new ff(10);for(let n of this.finalSides)e.computeIfAbsent(n.start,vG).push(n),t.add(n.start);let i=0,r=new Yc,s=new Array;for(let n of this.finalSides)if(!r.contains(n)){let a=new Yc,o=n.start,l=new sh;l.add(n),r.add(n);let h=n.end;for(;l.size()>0;)if(this.isStart(o,h)&&this.canBeEnd(l,.01)){l.size()>1&&this.fillSideGroups(l,i++);break}else{let c=e.get(h),d=this.findNext(r,c);if(d==null&&(h=this.findNeigber(h,a,t,.01),h!==null&&(c=e.get(h),d=this.findNext(r,c))),d!=null)l.add(d),r.add(d),h=d.end;else if(h!=null?a.add(h):(s.length==0&&l.size()>1&&this.logger.warning3("unable to connect at %s",l.getLast()),s.push(l.removeLast())),l.size()>0)h=l.getLast().end;else break}}}fillSideGroups(e,t){let i=new pG(t);Vc(e,(r,s)=>(i.add(s),!0)),this.sideGroups[i.id]=i}isStart(e,t){return e.distance2(t)<=1e-4}findNext(e,t){if(t!=null){for(let i of t)if(!e.contains(i))return i}return null}fillResult(){let e=0,t=new T_;for(let r in this.sideGroups){let s=this.sideGroups[r];Vc(s.sides,(n,a)=>(a.polyGrp!=-2&&t.put(a,a),!0))}let i=new Yc;for(let r in this.sideGroups){let s=this.sideGroups[r];if(i.add(s)){let n=0,a=new Array;for(a.push(s);n<a.length;){let l=a[n],h=new Array;Vc(l.others,(d,f)=>{let u=t.get(f);return u!=null&&h.push(u.finalGrp),!0}),bG(h,hs.sortAsc,0,h.length);let c=l.id;for(let d of h)if(d!=c&&d!=l.id){let f=this.sideGroups[d];i.add(f)&&a.push(f),c=d}n++}let o=new Array;for(let l of a)o.push(l.polyline());yG(o,O_.sortByBBoxAreaDesc,0,o.length),this.event.onPolylineGroup(new yb(o),e++)}}}findNeigber(e,t,i,r){let s=r*r,n=Number.MAX_VALUE,a=null;for(let o of i.search(e.bbox().extendOfSize(r)))if(!t.contains(o)){let l=e.distance2(o);l<n&&(n=l,a=o)}return n<s?a:null}},EG=class{constructor(){this.points=[],this.lines=[],this.arcs=[],this.beziers=[],this.listText=[],this.fonts=[]}addPt(e,t=!0){if(e instanceof le)this.lines.push(e);else if(e instanceof ye)this.arcs.push(e);else if(e instanceof Ye)this.beziers.push(e);else throw new Error("not support");t&&this.points.push(e.start())}addPoint(e){this.points.push(e)}addText(e,t,i=1,r=.1,s=!0){this.listText.push({pos:e,str:t,size:i,width:r}),s&&this.points.push(e)}addPly(e,t=!0){e.primitives.forEach(i=>this.addPt(i,t))}build(){let e=[],t=[],i=[],r=[],s=[],n=[];return this.points.forEach(a=>e.push(a.x,a.y)),this.lines.forEach(a=>t.push(a.start().x,a.start().y,a.end().x,a.end().y)),this.arcs.forEach(a=>i.push(a.center.x,a.center.y,a.rx,_t.toRadians(a.startAngle),_t.toRadians(a.endAngle()),a.sweep())),this.beziers.forEach(a=>{a.controls.forEach(o=>{r.push(o.x,o.y)}),r.push("end")}),this.listText.forEach(a=>s.push(a.pos.x,a.pos.y,a.str,a.width,a.size)),this.fonts.forEach(a=>n.push(a)),{points:e,lines:t,arcs:i,texts:s,beziers:r,fonts:n}}},hb=class qT{constructor(t){this.map=new T_,this.bus=t}initColor(t){return this.map.computeIfAbsent(t,()=>new EG)}draw(){let t={},i=this.map.entries();for(;i.hasNext();){let r=i.next();t[r.key.toString()]=r.value.build()}this.bus.publish("/debug/draw",t)}clear(){this.map.clear()}static init(t){if(!t)throw new Error("bus is undefined!");this.palette=new qT(t)}static initPalette(t){this.palette=t}static getDefaultColor(){for(let t of this.colorBuffersMap)if(t[0]!==null&&t[0])return t[0]=!1,t[1];return this.colorBuffersMap.forEach(t=>{if(t[0]===null){console.log(1);return}t[0]=!0}),this.getDefaultColor()}static clear(){this.palette.clear()}static auto(t,i=this.getDefaultColor()){if(Array.isArray(t))t.forEach(r=>{this.auto(r,i)});else if(t instanceof ae)this.point(t,i);else if(t instanceof Pi)this.bbox(t,i);else if(t instanceof gf)this.primitive(t,i);else if(t instanceof It)this.polyline(t,i);else if(t instanceof or)this.polygon(t,i);else if(t instanceof bi)this.group(t,i);else if(t instanceof yb)this.auto(t.items,i);else{debugger;throw new Error("No incoming type!")}}static text(t,i,r=.5,s=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");this.palette.initColor(s).addText(t,i,r,r/10),this.palette.draw()}static point(t,i=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let r=this.palette.initColor(i);Array.isArray(t)?t.forEach(s=>{this.point(s,i)}):r.addPoint(t),this.palette.draw()}static bbox(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.bbox(r,i)}):(this.primitive(new le(new ae(t.maxX,t.maxY),new ae(t.maxX,t.minY)),i),this.primitive(new le(new ae(t.maxX,t.maxY),new ae(t.minX,t.maxY)),i),this.primitive(new le(new ae(t.minX,t.minY),new ae(t.maxX,t.minY)),i),this.primitive(new le(new ae(t.minX,t.minY),new ae(t.minX,t.maxY)),i))}static primitive(t,i=this.getDefaultColor()){if(!this.palette)throw new Error("palette  is not initialised!");let r=this.palette.initColor(i);Array.isArray(t)?t.forEach(s=>{this.primitive(s,i)}):r.addPt(t),this.palette.draw()}static polyline(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.polyline(r,i)}):t.primitives.forEach(r=>{this.primitive(r,i)})}static polygon(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.polygon(r,i)}):t.items.forEach(r=>{this.polyline(r,i)})}static group(t,i=this.getDefaultColor()){Array.isArray(t)?t.forEach(r=>{this.group(r,i)}):t.items.forEach(r=>{this.polygon(r,i)})}static async begin(){this.t1=performance.now()}static async end(t){console.log(t||"t1:",performance.now()-this.t1)}static async log(t){console.log(t||"==================")}};hb.colorBuffersMap=[[!0,Ht.BLUE],[!0,Ht.GREEN],[!0,Ht.WHITE],[!0,Ht.RED],[!0,Ht.Golden],[!0,Ht.Gray]],hb.t1=0;var Of=hb,wG=0,mf=class cb{constructor(t,i){this.inters=[],this.shape=t,this.start=t.start(),this.end=t.end(),this.judgeOverlapMap=new Map,i&&(this.id=wG++)}reverse(){this.shape=this.shape.reverse();let t=this.start;this.start=this.end,this.end=t}getCenterPoint(t=this.end){let{x:i,y:r}=this.start,{x:s,y:n}=t;if(this.shape instanceof ye){let a=this.shape.rx,o=new ae((i+s)/2,(r+n)/2),l=this.shape.center,h;return o.x!==l.x||o.y!==l.y?(h=o.angle(l),Math.abs(this.shape.sweepAngle)>180&&(h+=h>=0?-180:180)):h=(this.shape.startAngle+this.shape.endAngle())/2,new ae(l.x+Math.cos(h)*a,l.y+Math.sin(h)*a)}else{if(this.shape instanceof le)return new ae((i+s)/2,(r+n)/2);if(this.shape instanceof Ye){let a=this.shape.getPercent(t,ut);return Ye.pointOn(a/2,this.shape.controls)}else throw Error("not support")}}static finalAngle(t,i,r){let s=t.cross(i)>0,n=Math.acos(Math.min(1,Math.max(-1,t.dot(i)/i.length())));return(r?!s:s)&&(n=R_-n),n}sortInters(){if(this.shape instanceof ye){let t=this.shape.center,i=this.shape.start().sub(t).normalize(),r=this.shape.isCCW;this.inters.sort((s,n)=>{let a=s.coord.sub(t),o=n.coord.sub(t);return cb.finalAngle(i,a,r)-cb.finalAngle(i,o,r)<=0?-1:1})}else if(this.shape instanceof le){let t=this.start,i=this.end,r=new ae(i.x+(t.x-i.x)*2,i.y+(t.y-i.y)*2);this.inters.sort((s,n)=>s.coord.distance2(r)-n.coord.distance2(r)<=0?-1:1)}else if(this.shape instanceof Ye){let t=this.shape;this.inters.sort((i,r)=>t.getPercent(i.coord,ut)-t.getPercent(r.coord,ut)<=0?-1:1)}else throw Error("not support the primitive type");this.inters.forEach((t,i)=>t.setIndex(i))}getStart(){return this.start}getEnd(){return this.end}getShape(){return this.shape}connect(t){this.nextSide=t,t.prevSide=this}static returnPolygonList(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(It.build7(o))}),i.push(new or(s))}),i}addInter(t){this.inters.push(t)}static returnPolygonGroup(t){let i=[];return t.forEach(r=>{let s=[];r.forEach((n,a)=>{let o=[];n.forEach(l=>{o.push(l.shape)}),s.push(It.build7(o))}),i.push(new or(s))}),new bi(i)}static rebuild(t,i,r){let s;if(t instanceof le||i.distance2(r)<1e-6)s=new le(i,r);else if(t instanceof ye)s=ye.build2(t.center,i.angleD(t.center),r.angleD(t.center),t.rx,t.ry,t.isCCW?1:0);else if(t instanceof Ye){let n=t.getPercent(i,ut),a=t.clip(n)[1];s=a.clip(a.getPercent(r,ut))[0]}else throw new Error("not supported operation");return ct(t,i).dot(ct(s,i))<0?null:s}static returnPolyline(t){return It.build7(t.map(i=>i.shape))}bbox(){return this.shape.bbox()}};function cs(e,t,i){if(e instanceof ye&&t instanceof ye)return IG(e,t);if(e instanceof ye&&t instanceof le)return xT(e,t);if(e instanceof le&&t instanceof ye)return vT(e,t);if(e instanceof le&&t instanceof le)return nh(e,t);if(e instanceof Ye&&t instanceof le)return e.controls.length===2||go(e)?nh(new le(e.start(),e.end()),t):WT(e,t);if(e instanceof le&&t instanceof Ye)return t.controls.length===2||go(t)?nh(e,new le(t.start(),t.end())):ub(e,t);if(e instanceof ye&&t instanceof Ye)return t.controls.length===2||go(t)?xT(e,new le(t.start(),t.end())):TG(e,t);if(e instanceof Ye&&t instanceof ye)return e.controls.length===2||go(e)?vT(new le(e.start(),e.end()),t):SG(e,t);if(e instanceof Ye&&t instanceof Ye)return vb(e,t);throw new Error("not support")}function Nc(e,t){return ct(e,t.start()).dot(ct(t,t.start()))<=0?!1:cs(e,t).state<=2}function Y1(e,t){let i=t.getPercent(e.end(),ut);if(i===null)return!1;if(i===0)return!0;let r=t.clip(i)[0],s=e.buildConverxHull(ut),n=r.buildConverxHull(ut),a=h(s),o=h(n);return l(a,o);function l(c,d){let f=new Map([[0,1],[1,0],[2,2],[3,4],[4,3]]),u=c[0],p=d[0];if(!u||!p)throw Error("isAllOverlap(sides1: PackSide[], sides2: PackSide[])");let g=!0;do{let _=u.getShape(),y=p.getShape();if(_ instanceof le&&y instanceof le){let m=g?nh(_,y).state:f.get(nh(y,_).state);if(m===0)u=u.nextSide,g=!1;else if(m===1)p=p.nextSide,g=!0;else if(m===2)u=u.nextSide,p=p.nextSide,g=!0;else return!1}else throw Error("not support")}while(u!==c[0].prevSide&&p!==d[0].prevSide);return!0}function h(c){let d=c.primitives.map(u=>new mf(u)),f=d[d.length-1];return d.forEach(u=>{f.connect(u),f=u}),d}}function yT(e,t){let i=e.end().distance2(t.center);if(i>(t.rx+ut)**2||i<(t.rx-ut)**2||!(et(e.end(),t.end())||xb(t,e.end())))return!1;if(e.center.equals1(t.center))return!0;let r=e.center.distance1(t.center),s=Math.abs(e.rx-t.rx);if(r>Math.min(e.rx,t.rx)){let n=e.center.angleD(t.center);return e.rx>t.rx?!(r+s>ut&&Sa(e,n))&&!(r-s>ut&&e.rx+t.rx-r>ut&&Sa(e,n+180)):!(r-s>ut&&Sa(e,n))&&!(e.rx+t.rx-r>ut&&Sa(e,n+180))}else{if(r+s<=ut)return!0;let n=e.rx>t.rx?e.center.angleD(t.center):t.center.angleD(e.center);return Sa(e,n)?!1:r-s<=ut?!0:!Sa(e,n+180)}}function TG(e,t){let i=Eb(e,t.start()).toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=vb(a,t).state,r!==0)break}return r===2&&s!==i.length-1?{state:1}:{state:r}}function SG(e,t){let i=t.toBezier2(),r,s=0;for(let n=i.length;s<n;s++){let a=i[s];if(r=vb(e,a).state,r!==1)break}return r===2&&s!==i.length-1?{state:0}:{state:r}}function vb(e,t){if(e.controls.length===2||go(e))return t.controls.length===2||go(t)?nh(new le(e.start(),t.end()),new le(t.start(),t.end())):ub(new le(t.start(),e.end()),t);if(t.controls.length===2||go(t))return WT(db(e,t.start()),new le(t.start(),t.end()));let i=db(e,t.start());if(go(i))return ub(new le(t.start(),e.end()),t);let r=Y1(i,t),s=Y1(t,i);if(!r&&!s){let n=VU(i,t);if(n.havOverlap){let a=n.havOverlap!==2,o=n.havOverlap!==1;return _o(e,t,a,o)}else{let a=function(){for(let d=0;d<h;d+=2)$[d]=c[d],$[d+1]=c[d+1]},o,l,h=n.cnt,c=new Array(h).fill(0).map((d,f)=>$[f]);for(let d=0;d<h;d+=2){let f=new ae($[d],$[d+1]),u=i.getPercent(f,ut),p=t.getPercent(f,ut);if(u===0||p===0)continue;let g=u===1?i:i.clip(u)[0],_=p===1?t:t.clip(p)[0];if(Y1(g,_)){let y=ct(e,f).cross(ct(t,f));if(y===0){o=i.end(),l=t.end();break}return{state:y<0?3:4}}a()}return(!o||!l)&&(o=jc(i.controls,i.controls[0],t),l=jc(t.controls,i.controls[0],i)),{state:o.sub(i.controls[0]).cross(l.sub(i.controls[0]))>0?4:3}}}return _o(e,t,r,s)}function WT(e,t){let i=db(e,t.start());if(go(i))return nh(new le(i.start(),i.end()),t);let r=JT(i,t),{isIn:s,bezierIsInLeft:n}=XT(t,i);if(!r&&!s){if(n!==void 0)return{state:n?3:4};let a=null,o=e.getPercent(t.start(),ut)+.01;for(let l=o>1?1:o;l<=1;){let h=Ye.pointOn(l,e.controls);if(pf(t,h)>us){a=h;break}l+=.01,l>1&&(l=1)}if(!a)throw Error("!end1 && !end2 not result");return{state:t.direct.cross(a.sub(t.start()))<0?4:3}}return _o(i,t,r,s)}function ub(e,t){let{isIn:i,bezierIsInLeft:r}=XT(e,t),s=JT(t,e);if(!i&&!s){if(r!==void 0)return{state:r?4:3};let n=null;for(let a=.01;a<=1;){let o=Ye.pointOn(a,t.controls);if(pf(e,o)>us){n=o;break}a+=.01,a>1&&(a=1)}if(!n)throw Error("!end1 && !end2 not result");return{state:e.direct.cross(n.sub(e.start()))<0?3:4}}return _o(t,e,i,s)}function IG(e,t){let i=yT(Eb(e,t.start()),t),r=yT(t,e);if(!i&&!r){let s=Zn(t);if(e.center.sub(t.start()).dot(t.center.sub(t.start()))>0){if(e.rx===t.rx)return e.isCCW?{state:s.dot(e.center.sub(t.center))<0?3:4,exitIsInvalid:!1}:{state:s.dot(e.center.sub(t.center))>0?3:4,exitIsInvalid:!1};let n,a;return e.rx>t.rx?(n=e,a=t):(n=t,a=e),s.dot(a.center.sub(n.center))>0&&a.rx+a.center.distance1(n.center)-n.rx>ut?e.isCCW?{state:e.rx>t.rx?3:4,exitIsInvalid:!1}:{state:e.rx<t.rx?3:4,exitIsInvalid:!1}:e.isCCW?{state:e.rx<t.rx?3:4,exitIsInvalid:!0}:{state:e.rx>t.rx?3:4,exitIsInvalid:!0}}else return e.rx+t.rx-e.center.distance1(t.center)>ut&&s.dot(e.center.sub(t.center))>0?{state:t.isCCW?3:4,exitIsInvalid:!1}:{state:e.isCCW?3:4,exitIsInvalid:!0}}return _o(e,t,i,r)}function vT(e,t){let i=Jn.foot(e,t.center),r=e.end().distance2(t.center),s=e.end().sub(e.start()),n=(t.rx-ut)**2,a=r<=(t.rx+ut)**2&&r>=n&&(s.dot(i.sub(t.start()))<=0||e.start().distance2(e.end())<=e.start().distance2(i)||i.distance2(t.center)>=n)&&(et(e.end(),t.end())||xb(t,e.end())),o=ZT(t,e);if(!a&&!o){let l=e.distance2(t.center);return l<=us?{state:s.cross(Zn(t))>0?4:3}:s.dot(i.sub(t.start()))>=0&&(r<n||e.start().distance2(t.center)<n||l<n)?{state:s.cross(t.center.sub(e.start()))<0?4:3}:{state:s.cross(t.center.sub(e.start()))>0?4:3}}return _o(t,e,a,o)}function Sa(e,t){return t=_t.regularD(t),e.sweepAngle>0?(t<e.startAngle&&(t+=360),e.endAngle()>t):(t>e.startAngle&&(t-=360),e.endAngle()<t)}function xb(e,t){return et(e.end(),t)||et(e.start(),t)||Sa(e,t.angleD(e.center))}function XT(e,t){let i=e.panDistance(ut),r=e.panDistance(-ut),s=ET(t,i),n=ET(t,r);if(!s.length&&!n.length)return{isIn:t.getPercent(e.end(),ut)!==null};let a=[...s,...n].sort((c,d)=>c.t-d.t),o=new le(r.start(),i.start()),l=[];for(let c=0,d=a.length;c<d;c++){let f=a[c];if(l.push(f),o.distance(f.interP)>e.length()+ut)break;if(l.length===2){let u=(l[1].t*10+l.shift().t*10)/20,p=Ye.pointOn(u,t.controls);if(e.distance2(p)>us)return{isIn:!1,bezierIsInLeft:e.direct.cross(p.sub(e.start()))>0}}}let h=l.length?o.distance(l[0].interP)>=e.length()+ut:!0;return{isIn:h,bezierIsInLeft:h?void 0:e.direct.cross(l[0].interP.sub(e.start()))>0}}function JT(e,t){if(pf(t,e.end())>us||e.getToLineMaxDis2(t)>us)return!1;let i=AG(t,us);return e.getToLineMaxDis2(i)<=(t.length()+ut)**2}function ZT(e,t){let i=t.end().angleD(t.start()),r=PG(t,e.end());if(r>us)return!1;if(Sa(e,i+90)){if(Jn.foot(t,e.center).distance1(e.pointOn(i+90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}if(Sa(e,i-90)){if(Jn.foot(t,e.center).distance1(e.pointOn(i-90))>e.rx)return!1;r=Math.max(r,(e.rx-t.distance(e.center))**2)}return r<=us&&(et(e.end(),t.end())||fb(t,e.end()))}var KT=(ut*2)**2;function Eb(e,t){if(et(e.end(),t))return ye.build3(e.center,e.endAngle(),0,e.rx,e.ry);if(e.start().distance2(t)<KT)return e;let i=_t.regularD(t.angleD(e.center));if(!Sa(e,i))throw new Error("!angleIsInArc(arc, angle)");return ye.build2(e.center,i,e.endAngle(),e.rx,e.ry,e.isCCW?1:0)}function db(e,t){if(et(e.end(),t))return new Ye([t,t]);if(e.start().distance2(t)<KT)return e;let i=e.getPercent(t,ut);if(i===null)throw new Error("!cutBezier(bezier: Bezier, p: Vector2)");return e.clip(i)[1]}function xT(e,t){let i=ZT(Eb(e,t.start()),t),r=t.end().distance2(e.center),s=t.end().sub(t.start()),n=Jn.foot(t,e.center),a=(e.rx-ut)**2,o=r<=(e.rx+ut)**2&&r>=a&&(s.dot(n.sub(t.start()))<=0||t.start().distance2(t.end())<=t.start().distance2(n)||n.distance2(e.center)>=a)&&(et(e.end(),t.end())||xb(e,t.end()));if(!i&&!o){let l=t.distance2(e.center);return l<=us?{state:s.cross(Zn(e,t.start().angle(e.center)))>0?3:4}:s.dot(n.sub(t.start()))>=0&&(r<a||t.start().distance2(e.center)<a||l<a)?{state:s.cross(e.center.sub(t.start()))>0?4:3}:{state:s.cross(e.center.sub(t.start()))<0?4:3}}return _o(t,e,i,o)}function nh(e,t){if(et(e.end(),t.end()))return _o(e,t,!0,!0);let i=pf(t,e.end())<=us&&fb(t,e.end()),r=pf(e,t.end())<=us&&fb(e,t.end());if(!i&&!r){let s=e.direct.x===0&&e.direct.y===0,n=t.direct.x===0&&t.direct.y===0;if(s&&n)throw Error("2LineAllIsPoint");return s?{state:t.direct.cross(e.end().sub(t.start()))>0?3:4}:{state:e.end().sub(e.start()).cross(t.end().sub(e.start()))>0?4:3}}return _o(e,t,i,r)}function fb(e,t){return Jn.foot(e,t).distance2(e.start())<e.end().distance2(e.start())}function _o(e,t,i,r){if(i)return r?et(e.end(),t.end())?{state:2}:{state:0}:{state:0};if(r)return{state:1};throw new Error("!end1 && !end2")}function pf(e,t){return(e.a*t.x+e.b*t.y+e.c)**2/(e.a**2+e.b**2)}function PG(e,t){return Math.min(e.distance2(t),Jn.foot(e,t).distance2(t))}function AG(e,t){let i=e.panDistance(t),r=e.panDistance(-t);return new le(r.start(),i.start())}function go(e){let t=e.start(),i=e.end();t.equals1(i)&&(i=t.add1(1,0));let r=i.y-t.y,s=t.x-i.x,n=-r*t.x-s*t.y,a=Math.sqrt(1/(r**2+s**2));r*=a,s*=a,n*=a;let o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.controls.forEach(h=>{let c=r*h.x+s*h.y+n;c<o&&(o=c),c>l&&(l=c)}),Ca(o,l)}function ET(e,t){let i=xn(e,t),r=[],s=new Array(i).fill(0).map((a,o)=>$[o]);for(let a=0;a<i;a+=2){let o=new ae($[a],$[a+1]),l=e.getPercent(o);r.push({interP:o,t:l}),n()}function n(){for(let a=0;a<i;a+=2)$[a]=s[a],$[a+1]=s[a+1]}return r}var Ta=.01,CG=270;function ol(e){let t=Ta**2,i=e.end(),r=[],s=[];for(let u=0,p=e.primitives.length;u<p;u++){let g=function(C,M){return C instanceof le&&M instanceof le&&Math.abs(C.direct.cross(M.direct))<ve.eps&&C.direct.dot(M.direct)>0||C instanceof ye&&M instanceof ye&&Math.abs(C.rx-M.rx)<=ve.eps&&C.center.distance2(M.center)<ve.eps&&C.isCCW===M.isCCW},_=function(C){if(rn(C,Ta))s.push(null);else{if(C instanceof le)s.push(C);else if(C instanceof ye&&C.rx===C.ry)d(C,s);else if(C instanceof Ye){let M=[];kT(C,M),M.forEach(H=>{let k=H.start(),F=H.end();c(k,F)||s.push(H)})}else throw new Error("not support!");i=b}},y=function(C){if(C instanceof le)return C.direct.x===0&&C.direct.y===0;if(C instanceof ye)return C.sweepAngle===0;if(C instanceof Ye){let M=new Set(C.controls.map(k=>k.x)),H=new Set(C.controls.map(k=>k.y));return M.size===1&&H.size===1}else throw new Error("not support")},m=e.primitives[u],O=m.start(),b=m.end();if(y(m))continue;c(i,O)||(s.push(new le(i,O)),i=O);let v=(u+1)%p,E=e.primitives[v];for(;g(m,E)&&(v=(v+1)%p,E=e.primitives[v],E!==m););if(v===(u+1)%p){_(m);continue}if(E===m){if(!(m instanceof ye)){if(Math.abs(e.area(.1))<t)return null;throw new Error("simplifyPolyline not support")}let C=m instanceof ye?m.isCCW:e.area(.1)>0;s.length=0;let M=C?180:-180;s.push(ye.build3(m.center,m.startAngle,M,m.rx,m.ry),ye.build3(m.center,m.startAngle+M,M,m.rx,m.ry));break}let T=(()=>{if(m instanceof le)return(C,M)=>{let H=new le(C,M);return rn(H,Ta)?null:[H]};if(m instanceof ye)return(C,M)=>{let H;if(C.equals1(M)?H=ye.build3(m.center,m.startAngle,m.sweep()===1?360:-360,m.rx,m.ry):H=ye.build4(C,M,m.center,m.rx,m.ry,m.sweep()),rn(H,Ta))return null;let k=H.pointOn(H.startAngle+H.sweepAngle/2),F=ye.build4(H.start(),k,m.center,m.rx,m.ry,m.sweep()),j=ye.build4(k,H.end(),m.center,m.rx,m.ry,m.sweep());return rn(F,Ta)||rn(j,Ta)?[H]:[F,j]};throw new Error("not support")})(),P=v===0;if(v<u&&!P&&(P=!T(e.primitives[0].start(),e.primitives[v-1].end()),!P)){let C=T(m.start(),s[0].end());if(C.length===1)s[0]=C[0];else if(C.length===2)s[0]=C[1],s.push(C[0]);else throw new Error("!!!generatorPt");break}u=v===0?p-1:v-1,E=e.primitives[u];let A=T(m.start(),E.end());if(A?(A.forEach(C=>s.push(C)),i=E.end()):_(null),P)break}let n=s.length;if(s.forEach((u,p)=>{if(u)r.push(u);else{let g,_;p===n-1&&(g=r[0],_=r[r.length-1]);let y=(p+1)%n;if(g=g!=null?g:s[y],g){let m=p,O=!1;for(;_=_!=null?_:s[(--m+n)%n],_!==g;)if(_){O=!0;break}if(O){if(g.start().equals1(_.end()))return;if(ct(_,_.end()).dot(ct(g,g.start()))<0){if(!c(_.end(),g.start())){let T=new le(_.end(),g.start());r.push(T);return}let{rebuildPrevPt:b,rebuildNextPt:v,rebuildLinkLine:E}=wT(s[(m-1+n)%n],_,new le(_.end(),g.start()),g,s[(p+2)%n]);b&&v&&(b!==_?(s[(m+n)%n]=b,r[r.length-1]&&(r[r.length-1]=b)):v!==g&&(s[(p+1)%n]=v,r[0]===g&&(r[0]=v)),E&&r.push(E))}}}}}),r.length===0)return null;c(i,r[0].start())||r.push(new le(i,r[0].start()));let a=r[r.length-1];if(r.length===1)return a instanceof ye?It.build7([ye.build2(a.center,0,180,a.rx,a.ry,a.sweep()),ye.build2(a.center,180,360,a.rx,a.ry,a.sweep())]):a instanceof Ye?It.build7(a.clip(.5)):null;let o=r.map(u=>new LG(u)),l=o[o.length-1];for(o.forEach(u=>{u.connect(l),l=u});!l.isVisited;){let u=function(){l.next.connect(g),l=l.next,l.isConnected=!1,l.isVisited=!1},p=function(){l.connect(g.prev),l.isConnected=!1},g=l.prev;if(l===g)break;let _=l.pt,y=g.pt,m=y.end();if(!l.isConnected&&!m.equals(_.start())){let O=function(v){l.isConnected=!0,l.pt=_=v,l.next.isVisited=!1},b=function(v){l.isConnected=!0,g.pt=v,g.isVisited=!1,l=g};if(_ instanceof le)if(c(m,_.end())){u();continue}else O(new le(m,_.end()));else if(y instanceof le){c(y.start(),_.start())?p():b(new le(y.start(),_.start()));continue}else if(_ instanceof Ye)if(c(m,_.end())&&!(_.controls.length!==2&&_.getToLineMaxDis2(_.startToEndL)>=t)){u();continue}else O(new Ye([m,..._.controls.slice(1)]));else if(y instanceof Ye)c(y.start(),_.start())&&!(y.controls.length!==2&&y.getToLineMaxDis2(y.startToEndL)>=t)?p():b(new Ye([...y.controls.slice(0,-1),_.start()]));else if(_ instanceof ye&&y instanceof ye)if(Math.abs(Math.abs(_.sweepAngle)-180)<Math.abs(Math.abs(y.sweepAngle)-180)){let v=ye.build5(m,_.end(),_.sweepAngle);if(c(v.start(),v.end())&&!(v.rx>=Ta&&Math.abs(v.sweepAngle)>180)){u();continue}else O(v)}else{let v=ye.build5(y.start(),_.start(),y.sweepAngle);c(v.start(),v.end())&&!(v.rx>=Ta&&Math.abs(v.sweepAngle)>180)?p():b(v);continue}else throw new Error("not support")}if(ct(_,_.start()).dot(ct(y,y.end()))<0){let O=function(E,T,P,A,C,M){if(l.next===g){l=null;return}let{rebuildLinkLine:H,rebuildPrevPt:k,rebuildNextPt:F}=wT(E,T,P,A,C);k&&F&&(k!==T&&(g.prev.pt=k),F!==A&&(l.next.pt=F),H?M.pt=H:u())},b=function(){l.next===g?l=null:(l.next.connect(g.prev),l=l.next,l.isConnected=!1,l.isVisited=!1)},v=cs(y.reverse(),_).state;if(v===0){let E=TT(_,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(ct(P,P.start()).dot(ct(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof le?E:new le(E.start(),E.end()),P,l.next.next.pt,l),!l)break}else l.pt=E;p();continue}else if(v===1){let E=TT(y,y.start(),_.end());if(f(E)){let T=g.prev.pt,P=l.next.pt;if(ct(P,P.start()).dot(ct(T,T.end()))>=0){if(b(),!l)break;continue}if(O(g.prev.prev.pt,T,E instanceof le?E:new le(E.start(),E.end()),P,l.next.next.pt,g),!l)break}else g.pt=E;u();continue}else if(v===2){if(b(),!l)break;continue}}l.isVisited=!0,l=l.next}if(!l)return null;r.length=0;let h=l;for(r.push(l.pt),l=l.next;l!==h;)r.push(l.pt),l=l.next;if(r.length===1){let u=r[0];return u instanceof ye?(c(u.start(),u.end())?r[0]=ye.buildCircle(u.center,u.rx,u.sweep()):r.push(new le(u.end(),u.start())),It.build7(r)):u instanceof Ye?(c(u.start(),u.end())||r.push(new le(u.end(),u.start())),It.build7(r)):null}if(e=It.build7(r),Math.abs(e.area(.1))<t)return null;return e;function c(u,p){return u.distance2(p)<t}function d(u,p){if(Math.abs(u.sweepAngle)>CG){let g=u.sweepAngle/2;d(ye.build3(u.center,u.startAngle,g,u.rx,u.ry),p),d(ye.build3(u.center,u.startAngle+g,g,u.rx,u.ry),p)}else p.push(u)}function f(u){return u.start().distance2(u.end())<t&&!(u instanceof ye&&u.rx>=Ta&&Math.abs(u.sweepAngle)>180||u instanceof Ye&&u.controls.length!==2&&u.getToLineMaxDis2(new le(u.start().add1(1,0),u.end()))>=t)}}function rn(e,t){if(!e)return!0;let i=e.start(),r=e.end();if(i.distance2(r)<t**2)if(e instanceof ye){if(!(e.rx>=t&&Math.abs(e.sweepAngle)>180))return!0}else if(e instanceof Ye){if(!(e.controls.length!==2&&e.getToLineMaxDis2(new le(e.start().add1(1,0),e.end()))>=t))return!0}else return!0;return!1}function Mc(e){if(e.direct.x===0&&e.direct.y===0)throw Error("getEndOfExtendLine(line: Line, distance: number)");let t=Math.abs(Ta-e.length())+ve.eps,i={x:e.direct.normalize().x*t,y:e.direct.normalize().y*t},r=e.end();return new ae(r.x+i.x,r.y+i.y)}function wT(e,t,i,r,s){if(!e)a();else if(!s)o();else{let l=ct(e,e.end()),h=ct(t,e.end()),c=l.dot(h);if(c>=0)a();else{let d=ct(r,r.end()),f=ct(s,r.end()),u=d.dot(f);if(u>=0)o();else if(Ca(c,-1)&&Ca(u,-1)){let p=i.center();n(p),i=null}else c>u?a():o()}}function n(l){let h;if(t instanceof le)h=new le(t.start(),l);else if(t instanceof Ye)h=new Ye([...t.controls.slice(0,-1),l]);else if(t instanceof ye)h=ye.build5(t.start(),l,t.sweepAngle);else throw new Error("not supported");t=rn(h,ut)?null:h;let c;if(r instanceof le)c=new le(l,r.end());else if(r instanceof Ye)c=new Ye([l,...r.controls.slice(1)]);else if(r instanceof ye)c=ye.build5(l,r.end(),r.sweepAngle);else throw new Error("supported");r=rn(c,ut)?null:c}function a(){if(t instanceof le){let l=Mc(i.reverse());i=new le(l,i.end());let h=new le(t.start(),l);t=rn(h,ut)?null:h}else if(t instanceof Ye){let l=Mc(i.reverse());i=new le(l,i.end());let h=new Ye([...t.controls.slice(0,-1),l]);t=rn(h,ut)?null:h}else if(t instanceof ye){let l=Mc(i.reverse());i=new le(l,i.end());let h=ye.build5(t.start(),l,t.sweepAngle);t=rn(h,ut)?null:h}else throw new Error("not supported")}function o(){if(r instanceof le){let l=Mc(i);i=new le(i.start(),l);let h=new le(l,r.end());r=rn(h,ut)?null:h}else if(r instanceof Ye){let l=Mc(i);i=new le(i.start(),l);let h=new Ye([l,...r.controls.slice(1)]);r=rn(h,ut)?null:h}else if(r instanceof ye){let l=Mc(i);i=new le(i.start(),l);let h=ye.build5(l,r.end(),r.sweepAngle);r=rn(h,ut)?null:h}else throw new Error("not supported")}return{rebuildPrevPt:t,rebuildNextPt:r,rebuildLinkLine:i}}function TT(e,t,i){if(e instanceof le||t.distance2(i)<=us)return new le(t,i);if(e instanceof ye)return ye.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.isCCW?1:0);if(e instanceof Ye){let r=e.getPercent(t,ut),s=e.getPercent(i,ut);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}var LG=class{constructor(e){this.pt=e}connect(e){this.prev=e,e.next=this}};function I_(e){let t=bf(),i;if(e instanceof It){let r=ol(e);if(r===null)return null;i=r}else if(e instanceof or){let r=e.items.map(s=>I_(s)).filter(s=>s!==null);if(r.length===0)return null;i=new or(r)}else{let r=e.items.map(s=>I_(s)).filter(s=>s!==null);if(r.length===0)return null;i=new bi(r)}return Pa.preprocessPolyline+=nl(t),i}var Pa={addDocShapes2RTree:0,getPour:0,prepare:0,getSinglePourLayerPolyline:0,combindOutlines:0,mergeSameNet:0,run:0,end:0,deSelfIntersection:0,changeDirect:0,extend:0,preprocessPolyline:0,runBoolean:0,IntersectionSeeker:0,BooleanTools:0,totalBool:0};function bf(){return{timeIndex:Object.assign({},Pa),start:performance.now()}}function ST(e){return Object.values(e).reduce((t,i)=>t+i,0)}function nl(e){return performance.now()-e.start-(ST(Pa)-ST(e.timeIndex))}function Sr(e,t,i,r){let s=Ht.RED,n=Ht.Golden;function a(){if(!r)return;let f=r.initColor(Ht.Golden);f.addPt(o),f.addPoint(o.end()),r.initColor(Ht.RED).addPt(l),r.draw();debugger}let o=e.getShape(),l=i?t.getShape():t.getShape().reverse(),h=ct(o,l.start()),c=ct(l),d=h.cross(c);if(Ca(d,0))if(o instanceof le)if(l instanceof le){if(ve.eq(d,0)&&(h.dot(c)>0?!et(o.end(),l.start()):!et(o.start(),l.start())))throw a(),new Error("line and line");return d<0}else{if(l instanceof ye)return h.cross(l.center.sub(o.start()))<0;if(l instanceof Ye){let f=l.getExtremePoints(o),u=f.length?f[0]:jc(l.controls,o.start());return h.cross(u.sub(o.start()))<0}else throw new Error("not support")}else if(o instanceof ye){if(l instanceof le)return o.isCCW;if(l instanceof ye){if(l.center.equals1(o.center)&&(h.dot(c)>0?!et(o.end(),l.start())&&o.end().sub(l.start()).dot(c)>0:!et(o.start(),l.start())&&o.start().sub(l.start()).dot(c)>0))throw a(),new Error("arc and arc");return l.rx>=o.rx||l.center.distance2(o.center)>o.rx2?o.isCCW:!o.isCCW}else throw new Error("not support")}else if(o instanceof Ye)if(l instanceof le){let f=o.getPercent(l.start(),ut),u=o.clip(f)[1],p=u.getExtremePoints(l);return(p.length?p[0]:jc(u.controls,l.start())).sub(l.start()).cross(c)<0}else if(l instanceof Ye){let f=o.getPercent(l.start(),ut),u=o.clip(f)[1],p=u.getExtremePoints(new le(l.start(),l.end())),g=l.getExtremePoints(new le(u.start(),u.end())),_=p.length?p[0]:jc(u.controls,l.start()),y=g.length?g[0]:jc(l.controls,l.start()),m=_.sub(l.start()),O=y.sub(l.start());return m.cross(O)<0}else throw Error("not support");else throw new Error("not support");else return d<0}function oh(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof ye?Zn(n,_t.toRadians(n.endAngle())):n instanceof Ye?df(n,1):n.end().sub(n.start()).normalize(),l=ct(a),h=o.dot(l);if(Ca(h,-1))return Sr(e,t,!0,s)?Sr(e,i,r,s)&&Sr(t,i,r,s):Sr(e,i,r,s)||Sr(t,i,r,s);{let c=o.scale(-1).angle(ae.ORIGIN),d=l.angle(ae.ORIGIN);c>d&&(c-=R_);let f=(c+d)/2,u=new ae(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=ct(p);return u.cross(g)<0?Sr(e,i,r,s):Sr(t,i,r,s)}}function q1(e,t,i,r,s){let n=e.getShape(),a=t.getShape(),o=n instanceof ye?Zn(n,_t.toRadians(n.endAngle())):n instanceof Ye?df(n,1):n.end().sub(n.start()).normalize(),l=ct(a),h=o.dot(l);if(Ca(h,-1))return Sr(e,t,!0,s)?Sr(e,i,r,s)&&Sr(t,i,r,s):Sr(e,i,r,s)||Sr(t,i,r,s);{let c=o.scale(-1).angle(ae.ORIGIN),d=l.angle(ae.ORIGIN);c>d&&(c-=R_);let f=(c+d)/2,u=new ae(Math.cos(f),Math.sin(f)),p=r?i.getShape():i.getShape().reverse(),g=ct(p);if(u.cross(g)<0){let _=o.dot(g)<0,y=cs(_?e.getShape().reverse():e.getShape(),p).state;return y!==3&&y!==4?Sr(e,i,r,s):y===(_?4:3)}else{let _=l.dot(g)<0,y=cs(_?t.getShape().reverse():t.getShape(),p).state;return y!==3&&y!==4?Sr(t,i,r,s):y===(_?4:3)}}}var Ia,al=!1;function sn(e,t,i,r,s,n,a,o=i.side===t,l=!0,h){return Ia=s,al=n,$T(QT(e,t,l,h,a,i,o,r),i,o,r,0)}function uo(e,t,i,r,s,n,a,o=r.side===i){Ia=s,al=n;let l=eS(e,t,i,new Map,r,o,a),h=l instanceof Array?-1:1;return $T(l,r,o,a,h)}function $T(e,t,i,r,s){for(;e instanceof Array;)s++,e.length===4?e=eS(...e,t,i,r):e=QT(...e,t,i,r);return{...e,existOverlap:s>0}}function QT(e,t,i,r,s,n,a,o){if(P_===-1){o.initColor(Ht.RED).addPt(e.getShape()),o.initColor(Ht.Golden).addPt(t.getShape()),o.draw();debugger}let l=e.getShape(),h=a?t.getShape().reverse():t.getShape(),c=(l instanceof ye?Zn(l,i?h.start().angle(l.center):r?_t.toRadians(l.endAngle()):void 0):l instanceof Ye?ct(l,i?h.start():r?l.end():l.start()):l.end().sub(l.start())).normalize(),d=(h instanceof ye?Zn(h,i?void 0:(r?l.end():l.start()).angle(h.center)):h instanceof Ye?ct(h,i?void 0:r?l.end():l.start()):h.end().sub(h.start())).normalize();if(r===void 0){let p=c.dot(d);if(r=p<0,Ca(p,0))return{state:Sr(e,t,!a,o)?1:0,inter:fo(e,t,n,a,i,r,s)}}else if(r?c.dot(d)>0:c.dot(d)<0)if(i){let p,g=!0;if(l instanceof le&&et(Jn.foot(l,h.start()),r?l.end():l.start()))g=!1;else if(l instanceof ye||l instanceof Ye){let _=r?l.reverse():l,y=cs(h,JU(_,h.start()).reverse()).state;(y===1||y===2)&&(g=!1)}if(g){let _=!r;p=cs(_?l.reverse():l,h,o).state===(_?4:3)?1:0}else r?p=oh(e,e.nextSide,t,!a,o)?1:0:p=oh(e.prevSide,e,t,!a,o)?1:0;return{state:p,inter:fo(e,t,n,a,i,r,s)}}else return r?{state:Sr(e,e.nextSide,!0,o)?0:1,inter:fo(e,t,n,a,i,r,s),isReversed:!0}:{state:Sr(e.prevSide,e,!0,o)?0:1,inter:fo(e,t,n,a,i,r,s),isReversed:!0};let f,u=new Map([[3,4],[4,3],[0,1],[1,0],[2,2]]);if(i)if(e.judgeOverlapMap.has(t)&&!al){let p=e.judgeOverlapMap.get(t);f=r?u.get(p.state):p.state}else f=cs(r?l.reverse():l,h).state,(f===3||f===4)&&e.judgeOverlapMap.set(t,{state:r?u.get(f):f});else{if(t.judgeOverlapMap.has(e)&&!al){let p=t.judgeOverlapMap.get(e);f=a?u.get(p.state):p.state}else f=cs(h,r?l.reverse():l).state,(f===3||f===4)&&t.judgeOverlapMap.set(e,{state:a?u.get(f):f});f=u.get(f)}if(f===1||f===2){let p=a?t.prevSide:t,g=p.inters,_=p.getEnd();for(let y=g.length-1;y>=0;y--){let m=g[y];if(!(p.getShape()instanceof Ye)&&!et(_,m.coord))break;if(m===n)return{state:2,inter:fo(e,t,n,a,i,r,s)}}}if(f===3||f===4)return{state:f===(r?4:3)?1:0,inter:fo(e,t,n,a,i,r,s)};if(s.has(e)?s.get(e).mapSideList.push(t):s.set(e,{sideIsReversed:r,mapSideList:[t]}),s.has(t)?s.get(t).mapSideList.push(e):s.set(t,{sideIsReversed:a,mapSideList:[e]}),f===2)return r?[e.prevSide,e,a?t.prevSide:t.nextSide,s]:[e,e.nextSide,a?t.prevSide:t.nextSide,s];if(f===0)return[r?e.prevSide:e.nextSide,t,!1,r,s];if(f===1)return[e,a?t.prevSide:t.nextSide,!0,r,s];throw Error("not support")}function fo(e,t,i,r,s,n,a){if(al)return null;let o=e.getShape(),l=r?t.getShape().reverse():t.getShape(),h=r;if(!s){let u=t;t=e,e=u,r=n,i=i.getBindedInter()}let c=u=>!(s?n:h)&&et(u,e.prevSide.getEnd())?e.prevSide:e;if(r){let u=t.inters;for(let p=0;p<u.length;p++){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&et(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.nextSide;let p=t.inters;for(let g=0;g<p.length;g++){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||et(_.coord,y.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(a.has(y)){let m=t.getShape().reverse(),O=ct(m,_.coord).dot(ct(y.getShape(),_.coord))<0,b=O?y.getShape().reverse():y.getShape(),v=cs(m,O?G1(b,_.coord,b.end()):G1(b,b.start(),_.coord)).state;if(v===1||v===2)return f(_)}else a.has(y.nextSide)}else if(_.side===i.side&&d(_))return f(_)}}}else{let u=t.inters;for(let p=u.length-1;p>=0;p--){let g=u[p];if(g.isInvalid&&n===void 0)continue;if(g===i&&et(l.start(),i.coord))return s?g:g.getBindedInter();let _=g.getBindedInter().side,y=c(g.coord);if(_===y&&d(g))return f(g)}for(;;){t=t.prevSide;let p=t.inters;for(let g=p.length-1;g>=0;g--){let _=p[g];if(_===i)return s?_:_.getBindedInter();if(a.has(t)){let y=_.getBindedInter().side;if(a.get(t).mapSideList.includes(y)||et(_.coord,_.getBindedInter().side.getEnd())&&a.get(t).mapSideList.includes(y.nextSide))return f(_);if(!a.has(y)&&a.has(y.prevSide)){let m=t.getShape().reverse(),O=ct(m,_.coord).dot(ct(y.getShape(),_.coord))<0;if(a.has(y.prevSide)){let b=O?y.getShape().reverse():y.getShape(),v=cs(t.getShape(),G1(b,_.coord,b.end())).state;if(v===1||v===2)return f(_)}}}else if(_.side===i.side&&d(_))return f(_)}}}function d(u){if(u.isInvalid||u.getBindedInter().side!==(et(u.coord,e.prevSide.getEnd())?e.prevSide:e))return!1;let p;if(s){if(et(u.coord,l.start()))return!0;p=cs(n?o.reverse():o,g(l)).state}else{if(et(u.coord,n?o.end():o.start()))return!0;p=cs(l,g(n?o.reverse():o)).state}return p===2||p===1;function g(_){if(_ instanceof le)return et(u.coord,_.end())?_:_.cutLine(u.coord);if(_ instanceof ye)return ye.build2(_.center,_.startAngle,u.coord.angleD(_.center),_.rx,_.ry,_.isCCW?1:0);if(_ instanceof Ye)return _.clip(_.getPercent(u.coord,ut))[0];throw new Error("not supported operation")}}function f(u){let p=i.getBindedInter(),g=i.side,_=p.side,y=i===u,m=i;if(r){let O=i.getIndex()-1;for(;g;){let b=g.inters;for(;O>=0;O--)if(i=b[O],i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(Ia===0)!i.isInvalid&&(!et(i.coord,u.coord)||i.side===u.side&&i.getBindedInter().side===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(Ia===1){if(i.isInvalid)continue;let v=i.getBindedInter().side;a.has(g)&&a.get(g).mapSideList.includes(v)&&(i.setIsInvalid(),i.isDealed(),m=i)}g=g==null?void 0:g.prevSide,O=(g==null?void 0:g.inters.length)-1}}else{let O=i.getIndex()+1;for(;g;){let b=g.inters;for(;O<b.length;O++){i=b[O];let v=i.getBindedInter();if(i===u){y||(i.setIsInvalid(),i.isDealed(),m=i),g=null;break}else if(Ia===0)!i.isInvalid&&(!et(i.coord,u.coord)||g===u.side&&(et(v.side.getEnd(),i.coord)?v.side.nextSide:v.side)===u.getBindedInter().side)&&(i.setIsInvalid(),i.isDealed(),m=i);else if(Ia===1){let E=v.side;a.has(g)&&a.get(g).mapSideList.includes(E)&&(i.setIsInvalid(),i.isDealed(),m=i)}}g=g==null?void 0:g.nextSide,O=0}}if(Ia===0&&!et(p.coord,u.coord))if(s?a.has(_)?a.get(_).sideIsReversed:n:h){let O=p.getIndex()-1;for(;_;){let b=a.has(_),v=_.inters;for(;O>=0;O--){if(p=v[O],p===u.getBindedInter()){_=null;break}p.isInvalid||!b||(!et(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.prevSide,O=(_==null?void 0:_.inters.length)-1}}else{let O=p.getIndex()+1;for(;_;){let b=_.inters,v=a.has(_);for(;O<b.length;O++){if(p=b[O],p===u.getBindedInter()){_=null;break}let E=et(_.getEnd(),p.coord)?a.has(_.nextSide):!1;p.isInvalid||!(v||E)||(!et(p.coord,u.getBindedInter().coord)||p.side===u.side&&p.getBindedInter().side===u.getBindedInter().side)&&(p.setIsInvalid(),p.isDealed())}_=_==null?void 0:_.nextSide,O=0}}return s?m:m.getBindedInter()}}function eS(e,t,i,r,s,n,a){let o=e.getShape(),l=t.getShape(),h=n?i.getShape().reverse():i.getShape(),c=(o instanceof ye?Zn(o,h.start().angle(o.center)):o instanceof Ye?ct(o,h.start()):o.end().sub(o.start())).normalize(),d=(l instanceof ye?Zn(l,h.start().angle(l.center)):l instanceof Ye?ct(l,h.start()):l.end().sub(l.start())).normalize(),f=c.dot(d);if(Ca(f,-1)){let u=n?i.getShape().reverse():i.getShape(),p=ct(u).normalize(),g=c.add(d.scale(-1)).normalize().dot(p),_=cs(o.reverse(),l,a).state;if(g>-.9&&(_===3||_===4))return{state:_===4?0:1,inter:fo(t,i,s,n,!0,!1,r)};let y=sn(e,i,s,a,Ia,al,r.size===0?new Map:r,n);return y.state===2?y:_===4?y.state===0||y.inter!==s?y:sn(t,i,s,a,Ia,al,r.size===0?new Map:r,n):y.state===1||y.inter!==s?y:sn(t,i,s,a,Ia,al,r.size===0?new Map:r,n)}else{let u=c.scale(-1).angle(ae.ORIGIN),p=d.angle(ae.ORIGIN);u>p&&(u-=R_);let g=(u+p)/2,_=new ae(Math.cos(g),Math.sin(g)),y=ct(h).normalize(),m=y.angle(ae.ORIGIN),O=u<m&&m<p&&o instanceof le&&l instanceof le&&h instanceof le;if(_.cross(y)<=0){if(c.scale(-1).dot(y)<0){let b;return s.coord.equals1(h.start())?b=ct(o,s.coord).dot(ct(h,s.coord))<0:h instanceof le&&(b=ct(o,o.end()).dot(h.direct)<0),{state:oh(e,t,i,!n,a)?1:0,inter:fo(e,i,s,n,!0,b,r)}}return O&&o.distance2(h.start())>us?[t,i,!0,void 0,r]:[e,i,!0,void 0,r]}else return d.dot(y)<=0?{state:oh(e,t,i,!n,a)?1:0,inter:fo(t,i,s,n,!0,void 0,r)}:O&&l.distance2(h.start())>us?[e,i,!0,void 0,r]:[t,i,!0,void 0,r]}}var P_=0;function DG(e,t,i,r){let s=t.getBindedInter(),n=t.side,a=s.side,o=n.getShape(),l=a.getShape();if(r&&(P_++,P_===-1)){r.initColor(Ht.RED).addPt(o),r.initColor(Ht.Golden).addPt(l),r.draw();debugger}let h=0,c=!1;if(e===-1){let T=uo(n,n.nextSide,a,s,h,c,r),P=T.state!==0;if(T.state===2){let C=ct(o,t.coord).add(ct(n.nextSide.getShape(),t.coord)).normalize(),M=ct(l,t.coord).add(ct(a.nextSide.getShape(),t.coord)).normalize();return E(P,C.dot(M)>0)}let A=uo(n,n.nextSide,a.nextSide,s,h,c,r);return T.state!==A.state?(v(T,A),1):E(P,T.state!==uo(a,a.nextSide,n,t,h,!0,r).state,T.inter,A.inter)}if(e===1){let T=sn(n,a,s,r,h,c,new Map),P=T.state!==0;if(T.state===2)return E(P,ct(o,t.coord).dot(ct(l,t.coord))>0);let A;if(T.isReversed&&T.existOverlap&&et(T.inter.coord,a.getEnd())&&T.inter.getBindedInter().side!==n){let H=T.inter.getBindedInter().side;if(H===n.nextSide)A={state:oh(n,H,a.nextSide,!0,r)?1:0,inter:s};else if(H===n.prevSide){if(A={state:oh(H,n,a.nextSide,!0,r)?1:0,inter:T.inter},T.state===A.state&&t!==T.inter){let k=ct(l,t.coord),F=ct(a.nextSide.getShape(),t.coord),j=ct(H.getShape(),t.coord);return E(P,k.add(F).dot(j)>0,T.inter,A.inter)}}else A=sn(n,a.nextSide,s,r,h,c,new Map)}else A=sn(n,a.nextSide,s,r,h,c,new Map);if(T.state!==A.state)return v(T,A),1;let C=ct(l,t.coord),M=ct(a.nextSide.getShape(),t.coord);if(Ca(C.dot(M),-1)){let H=Sr(a,a.nextSide,!0,r);return E(P,T.state!==sn(a.nextSide,n,t,r,h,!0,new Map,H?!P:P,!1).state,T.inter,A.inter)}else{let H=ct(o,t.coord);return E(P,C.add(M).dot(H)>0,T.inter,A.inter)}}if(!(o instanceof Ye||l instanceof Ye))return 1;let d=ct(o,t.coord),f=ct(l,t.coord),u,p;if(l instanceof le)u=new le(t.coord,l.start()),p=new le(t.coord,l.end());else if(l instanceof ye){let T=t.coord.angleD(l.center);u=ye.build2(l.center,T,l.startAngle,l.rx,l.ry,l.isCCW?0:1),p=ye.build2(l.center,T,l.endAngle(),l.rx,l.ry,l.isCCW?1:0)}else if(l instanceof Ye){let T=l.getPercent(t.coord,ut);[u,p]=l.clip(T),u=u.reverse()}else throw new Error("not support");let g=d.dot(f)>0,_,y;g?(_=cs(o.reverse(),u).state,y=cs(o,p).state):(_=cs(o,u).state,y=cs(o.reverse(),p).state);let m;_===0?m=sn(g?n.prevSide:n.nextSide,a,s,r,h,c,new Map,!0,!1,g):_===1?m=sn(n,a.prevSide,s,r,h,c,new Map,!0,!0,g):_===2?g?m=uo(n.prevSide,n,a.prevSide,s,h,c,r,!0):m=uo(n,n.nextSide,a.prevSide,s,h,c,r,!0):g?_===3?m={inter:s,state:0}:m={inter:s,state:1}:_===3?m={inter:s,state:1}:m={inter:s,state:0};let O=m.state!==0;if(m.state===2)return E(O,g);let b;if(y===0?b=sn(g?n.nextSide:n.prevSide,a,s,r,h,c,new Map,!1,!1,!g):y===1?b=sn(n,a.nextSide,s,r,h,c,new Map,!1,!0,!g):y===2?g?b=uo(n,n.nextSide,a.nextSide,s,h,c,r,!1):b=uo(n.prevSide,n,a.nextSide,s,h,c,r,!1):g?y===3?b={inter:s,state:1}:b={inter:s,state:0}:y===3?b={inter:s,state:0}:b={inter:s,state:1},m.state===b.state)return m.inter===b.inter?(t.setIsInvalid(),0):E(O,g,m.inter,b.inter);return v(m,b),1;function v(T,P){let A=T.state!==0;if(T.inter===P.inter){t.setOutToIn(A);return}else Bc(T.inter,P.inter,!0),Bc(P.inter,T.inter,!1);let C=[];if(e===-1){let H=ct(o,t.coord),k=ct(n.nextSide.getShape(),t.coord),F=ct(l,t.coord),j=ct(a.nextSide.getShape(),t.coord);C.push(H.dot(F)),C.push(H.dot(j)),C.push(k.dot(F)),C.push(k.dot(j))}else{let H=ct(o,t.coord);C.push(ct(l,t.coord).dot(H)),C.push(ct(a.nextSide.getShape(),t.coord).dot(H))}if(C.reduce((H,k)=>Math.abs(H)>Math.abs(k)?H:k,0)>0)if(i===1||i===0||i===2||i===3)t.setOutToIn(A);else throw new Error("not support");else if(i===1)M(!A);else if(i===0||i===2||i===3)M(A);else throw new Error("not support");function M(H){t.setIsInvalid();let k=(H?T:P).inter;delete k.isInvalid,delete k.getBindedInter().isInvalid,k.setOutToIn(!A)}}function E(T,P,A,C){if(A===C){if(t.side.outline.inters.find(k=>!k.isInvalid&&k!==t&&et(k.coord,t.coord)))return t.setIsInvalid(),0;let M=new po(t.coord,n,r),H=new po(t.coord,a,r);return M.bind(H),P?n.inters.splice(t.getIndex(),0,M):n.inters.splice(t.getIndex()+1,0,M),a.inters.splice(t.getBindedInter().getIndex(),0,H),M.setOutToIn(T),t.setOutToIn(!T),M.isDealed(),n.inters.forEach((k,F)=>k.setIndex(F)),a.inters.forEach((k,F)=>k.setIndex(F)),2}else{let M=function(){let H=A.getBindedInter(),k=C.getBindedInter();delete A.isInvalid,delete H.isInvalid,delete C.isInvalid,delete k.isInvalid,A.setOutToIn(!T),C.setOutToIn(T),Bc(A,C,!0),Bc(C,A,!1),Bc(H,k,P),Bc(k,H,!P)};if(t.setIsInvalid(),P){if(i===1||i===0||i===2||i===3)return M(),2;throw new Error("not support")}else{if(i===1)return T?0:(M(),2);if(i===0||i===2||i===3)return T?(M(),2):0;throw new Error("not support")}}}}function Bc(e,t,i){let{judge:r,changeNum:s}=a(),n=e.getIndex();for(let o=n+s,l=e.side.inters;r(o);o+=s){if(l[o].isInvalid)continue;if(!et(l[o].coord,e.coord))break;l[o].setIndex(n),l[n].setIndex(o);let h=l[o];l[o]=l[n],l[n]=h,n=o}function a(){let o=e.side===t.side;if(i){let l=o?t.getIndex():e.side.inters.length;return{judge:h=>h<l,changeNum:1}}else{let l=o?t.getIndex()+1:0;return{judge:h=>h>=l,changeNum:-1}}}}var IT=0,po=class{constructor(e,t,i){this.id=IT++,this.coord=e,this.side=t,i&&(this.id=IT++,this.drawDebug=i);let r=new yi;r.ext2(e),this._bbox=r.build1()}bbox(){return this._bbox}resetVisitStatus(){this.visited=!1,this.bindedInter.visited=!1}isDealed(){this.dealed=!0,this.getBindedInter().dealed=!0}setOutToIn(e){this.outToIn=e,this.bindedInter.outToIn=!e}setIsInvalid(){this.isInvalid=!0,this.getBindedInter().isInvalid=!0}getBindedInter(){return this.bindedInter}bind(e){this.bindedInter=e,e.bindedInter=this}setIndex(e){this.index=e}isSorted(){return this.index!==void 0}getIndex(){return this.index}getVisited(){return this.visited}visitSelf(){this.visited=!0}visit(){this.visited=!0,this.bindedInter.visited=!0}getPrevPoint(){let e=this.getIndex(),t=this.side.getStart();return e&&(t=this.side.inters[e-1].coord),t}getTangent(){let e=this.side.getShape();if(e instanceof le)return e.end().sub(e.start());if(e instanceof ye){let t=this.coord.angle(e.center);return e.isCCW?t+=v_:t-=v_,new ae(Math.cos(t),Math.sin(t))}else{if(e instanceof Ye)return df(e,e.getPercent(this.coord,ut));throw new Error("not support")}}findStartInter(){return this.outToIn===void 0?this.getTangent().cross(this.bindedInter.getTangent())>0?this:this.bindedInter:this.outToIn?this:this.bindedInter}run(){let e=[],t=this,i;if(this.drawDebug){W1++;let r=W1===-1,s=this.drawDebug.initColor(Ht.RED);if(r){this.drawDebug.draw();debugger}i=n=>{if(e.push(n),r){s.addPt(e[e.length-1]),this.drawDebug.draw();debugger}}}else i=r=>e.push(r);for(;!t.visited;){let r=function(o,l){if(ve.eq(o.distance2(l),0))return;let h=mf.rebuild(n.getShape(),o,l);if(!h)return!0;i(h)};t.visit();let s=t.getIndex(),n=t.side,a=n.inters[s+1];for(;a!=null&&a.isInvalid;)a=n.inters[a.getIndex()+1];if(a)r(t.coord,a.coord),t=a.bindedInter;else{let o=r(t.coord,n.getEnd()),l=t.coord;for(n=n.nextSide,t=null;;){for(let h of n.inters)if(!h.isInvalid){t=h.bindedInter;break}if(t)break;o?(r(l,n.getEnd()),o=!1):i(n.getShape()),n=n.nextSide}o?(ve.eq(l.distance2(t.coord),0)?r(l,n.getEnd()):r(l,t.coord),o=!1):ve.eq(n.getEnd().distance2(t.coord),0)?i(n.getShape()):r(n.getStart(),t.coord)}}if(t!==this)throw this.drawDebug&&console.log(JSON.stringify({runId:W1,handleId:P_,boolId:nf})),new Error("inter !== this");return ol(It.build7(e))}},W1=0,X1=class pb{constructor(t,i,r,s,n){this.inters=[],this.allInterIsInvalid=!0,this.isVisit=!1,this.sides=t,this.isGroup1=r,this.isOutside=s,this.finalIsOutside=s,this.polyline=i,n&&(this.polygon=n),t.forEach(a=>a.outline=this)}static build(t,i,r,s,n){let a=t.primitives.map(l=>new mf(l,s)),o=a[a.length-1];return a.forEach(l=>{o.connect(l),o=l}),n?new pb(a,t,i,r,n):new pb(a,t,i,r)}setFinalIsOutSide(t){this.finalIsOutside=t}startAndEndIsSameOutsideFlag(){return this.isOutside===this.finalIsOutside}get hasInter(){return!!this.interOutlines}isAllInterIsInvalid(){return this.allInterIsInvalid}setAllInterIsInvalidToFalse(){this.allInterIsInvalid=!1}resetVisited(){this.isVisit=!1}intersect(t,i){if(!(t.interOutlines&&t.interOutlines===this.interOutlines))if(t.interOutlines)if(this.interOutlines){let r,s;this.interOutlines.length>t.interOutlines.length?(r=this.interOutlines,s=t.interOutlines):(r=t.interOutlines,s=this.interOutlines),s.forEach(n=>{r.push(n),n.interOutlines=r}),i.delete(s)}else t.interOutlines.push(this),this.interOutlines=t.interOutlines;else this.interOutlines?(this.interOutlines.push(t),t.interOutlines=this.interOutlines):(t.interOutlines=this.interOutlines=[this,t],i.add(this.interOutlines))}isContain(t){if(!this.polyline.bbox().extendOfSize(ut).isContainsBBox(t.polyline.bbox()))return!1;let i=t.polyline.primitives[0].start();if(t.hasInter&&t.isAllInterIsInvalid()){let r=t.inters[0];r.getBindedInter().side.outline!==this?i=r.side.getCenterPoint():i=r.side.getCenterPoint(r.coord)}return!!this.polyline.getWindingNum(i)}isInternally(t){return!!this.polyline.getWindingNum(t)}isEqual(t){return this.polyline===t.polyline}bbox(){return this.polyline.bbox()}reverse(){this.sides.reverse();let t=this.sides[this.sides.length-1];this.sides.forEach(i=>{i.reverse(),t.connect(i),t=i})}returnPolyline(){let t=this.sides.map(r=>r.getShape()),i=this.polyline.primitives;if(this.sides.length===i.length){let r=new Set(i);if(!t.some(s=>!r.has(s)))return this.polyline}return It.build7(t)}};function PT(e,t,i){let r=[];return e.forEach(s=>s.forEach(n=>{if(n.hasInter&&!n.isAllInterIsInvalid())return;let a=n.bbox(),o=t.search(a.extendOfSize(ut)).filter(l=>l.bbox().extendOfSize(ut).isContainsBBox(a)).sort((l,h)=>l.bbox().area()-h.bbox().area());for(let l of o)if(l.isContain(n)){let h=i(!n.isOutside,l.isOutside),c=i(n.isOutside,l.isOutside);h!==c&&(r.push(n),n.setFinalIsOutSide(!h));return}i(n.isOutside,!1)!==i(!n.isOutside,!1)&&r.push(n)})),r}function RG(e,t,i){let r;switch(i){case 0:r=(o,l)=>o&&l;break;case 1:r=(o,l)=>o||l;break;case 2:r=(o,l)=>o&&!l;break;case 3:r=(o,l)=>o&&!l||!o&&l;break;default:throw Error("not support the rule")}let s=new ff(10),n=new ff(10);e.forEach(o=>o.forEach(l=>s.add(l))),t.forEach(o=>o.forEach(l=>n.add(l)));let a=PT(e,n,r);return PT(t,s,(o,l)=>r(l,o)).forEach(o=>a.push(o)),a}var NG=class{constructor(e){this.roots=[],this.nodes=e.sort((t,i)=>t.bbox().minX-i.bbox().minX).map(t=>new MG(t)),this.nodes.forEach((t,i)=>{t.visit()&&(this.roots.push(t),this.build(i))})}build(e){let t=this.nodes[e];for(let i=e+1,r=this.nodes.length;i<r;i++){let s=this.nodes[i];if(t.key.bbox().maxX<s.key.bbox().minX)break;s.getIsVisit()||t.isContain(s)&&(s.visit(),t.addChild(s),this.build(i))}}getPolygons(){let e=[];return this.roots.forEach(t=>t.getPolygons().forEach(i=>e.push(i))),e}},MG=class{constructor(e){this.children=[],this.isVisit=!1,this.key=e}getIsVisit(){return this.isVisit}isContain(e){return this.key.isContain(e.key)}addChild(e){this.children.push(e)}getPolygons(){let e=[];return this.getPolylineList(e),e.map(t=>{let i=t[0].polygon;if(i&&i.items.length===t.length){let r=t.map(n=>n.returnPolyline()),s=new Set(i.items);return r.some(n=>!s.has(n))?new or(r):i}else return new or(t.map(r=>r.returnPolyline()))})}getPolylineList(e,t){t?(t.push(this.key),t=null):(t=[this.key],e.push(t)),this.children.forEach(i=>i.getPolylineList(e,t))}visit(){return this.isVisit?!1:(this.isVisit=!0,!0)}};function AT(e){let t="";return e.items.forEach((i,r)=>{let s="$";if(i.items.forEach((n,a)=>{let o="[";if(n.primitives.forEach((l,h)=>{let c="";if(l instanceof le)c=`Line,${l.start().x},${l.start().y},${l.end().x},${l.end().y}`;else if(l instanceof ye)c=`Arc,${l.center.x},${l.center.y},${l.startAngle},${l.sweepAngle},${l.rx}`;else if(l instanceof Ye)c=`Bezier,${l.controls.map(d=>`${d.x},${d.y}`).join(",")}`;else throw new Error("not supported");if(h===n.primitives.length-1){o+=`${c}]`;return}o+=`${c},`}),a===i.items.length-1){s+=`${o}$`;return}s+=`${o}_`}),r===e.items.length-1){t+=`${s}`;return}t+=`${s}^`}),console.log(t),t}function CT(e){let t=e.split("^"),i=[];return t.forEach(s=>{let n=/\$(.*?)\$/,a=s.match(n)[1].split("_"),o=[];a.forEach(h=>{let c=/\[(.*?)\]/,d=h.match(c)[1].split(","),f=[],u=[];for(let g=0;g<d.length;g++){let _=d[g];if(_==="Line"||_==="Arc"||_==="Bezier"){if(f.length){let y=r(f);u.push(y),f.length=0}f.push(_);continue}f.push(Number(_))}f.length&&(u.push(r(f)),f.length=0);let p=It.build7(u);o.push(p)});let l=new or(o);i.push(l)}),new bi(i);function r(s){let n=s[0];if(n==="Line")return new le(new ae(s[1],s[2]),new ae(s[3],s[4]));if(n==="Arc")return ye.build3(new ae(s[1],s[2]),s[3],s[4],s[5],s[5]);if(n==="Bezier"){let a=[];for(let o=1;o<s.length;o+=2)a.push(new ae(s[o],s[o+1]));return new Ye(a)}else throw new Error("not support")}}var BG=class{constructor(e=1){this.group1Str="$[Line,20193.777980000017,4122.200439600661,20193.77082,4211.848760073709,Arc,20193.972672902382,4211.8487570980205,179.99915535323618,-89.99540000050294,0.2018529024026465,Line,20193.972659672283,4212.050609999989,20193.972660393258,4212.039610000013,Arc,20193.97217289501,4211.848257065248,89.85403133887164,89.99540000041924,0.19135355574930143,Line,20193.78082,4211.848759926291,20193.78897999998,4122.200440479205,Line,20193.78897999998,4122.200440479205,20193.777980000017,4122.200439600661]$",this.group2Str="$[Arc,20209.72784128151,4122.2007625157785,258.46768032837986,-75.66780748375947,4.138846238512183,Line,20205.593935808283,4121.998590004101,20193.97982992629,4121.998600000001,Arc,20193.97983290198,4122.2004529023825,269.9991553532362,-89.99540000050297,0.20185290240401074,Arc,20193.782979999996,4122.20044,180.00375535340328,-180.0000000000027,0.004999999999025513,Arc,20193.979332869207,4122.200952909754,180.15347936671733,89.99540000008247,0.19135355575111057,Line,20193.97983008845,4122.009599999999,20205.603694309226,4122.003828485546,Arc,20209.733142304296,4122.194577876843,182.64475341258483,75.73379999998886,4.133851239977064,Line,20208.900400396684,4118.145470939558,20208.902599535475,4118.156248870184,Arc,20206.972515961093,4108.700057667588,78.46393309088245,-78.46759999998636,9.65115405866796,Arc,20216.618669999996,4108.69944,359.99996825446135,-180,0.004999999999200412,Arc,20206.973015966745,4108.699445349495,359.99996822365375,78.46759999998409,9.640654033253735]$^$[Line,20193.997796883676,4095.399470032799,20205.596133314026,4095.4013992171836,Arc,20209.72470159858,4095.1923799234505,177.10172964919312,-75.64935037184974,4.133855965730166,Arc,20209.73000213952,4095.198565517174,101.5415133143569,75.7293000000185,4.128850963459707,Line,20205.605834328744,4095.395161923586,20193.997203529463,4095.389485743675,Arc,20193.994588809255,4095.197684525904,89.21896662213764,4.544099999999517,0.19181903946188483,Arc,20193.981499796217,4095.1977402038,89.85034659953621,89.9999999995926,0.19135044893494071,Arc,20193.78515,4095.19824,0,-180,0.005,Arc,20193.98200016982,4095.1982398301675,179.99995179248322,-89.99999999974185,0.20185016982129908,Arc,20193.981986624152,4095.198185381971,89.9961078637802,-4.487285276547311,0.2019046184835962]$",this.rule=e}getGroup1(){return CT(this.group1Str)}getGroup2(){return CT(this.group2Str)}},J1=new L_(2),sf=class{getUnion(e,t=!0){return t&&(e=e.map(i=>this.asSameSweep([i])[0])),xG(sG,e)}asSameSweep(e){let t=0;return e.forEach(i=>t+=i.area(.01)),t>0?e.map(i=>i.reverse()):e}getSubtraction(e,t){let i=new cf(!1),r=new uf(g_.rule,J1,i);for(let s of e){let n=g_.weight(0);r.addPolyline(s,n)}for(let s of t){let n=g_.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getIntersection(e,t){let i=new cf(!1),r=new uf(__.rule,J1,i);for(let s of e){let n=__.weight(0);r.addPolyline(s,n)}for(let s of t){let n=__.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}getMutuallyExclusive(e,t){let i=new cf(!1),r=new uf(H1.rule,J1,i);for(let s of e){let n=H1.weight(0);r.addPolyline(s,n)}for(let s of t){let n=H1.weight(1);r.addPolyline(s,n)}return r.simplify(),i.plGrps}},nf=0,Z1=!1;function af(e,t,i,r,s){let n=bf(),a=[],o=[],l=[],h=new Set,c;if(s){if(c=new Of(s),nf++,Z1){debugger;Z1=!1;let b=new BG;af(b.rule,b.getGroup1(),b.getGroup2(),r,s)}if(nf===-1||Z1){console.table({rule:e,group1:AT(t),group2:AT(i)}),c.clear();let b=c.initColor(Ht.GREEN),v=c.initColor(Ht.WHITE),E=c.initColor(Ht.BLUE),T=c.initColor(Ht.Gray);t.items.forEach(P=>P.items.forEach((A,C)=>{C>0?v.addPly(A):b.addPly(A)})),i.items.forEach(P=>P.items.forEach((A,C)=>{C>0?T.addPly(A):E.addPly(A)})),c.draw();debugger}}let d=t.items.length!==0&&i.items.length!==0?t.bbox().extendOfSize(ut).intersection1(i.bbox().extendOfSize(ut)):null;if(d){let b=[],v=[];switch(e){case 0:{for(let E of t.items)E.bbox().isIntersect(d)&&b.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}case 1:case 3:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)?v.push(E):a.push(E);break}case 2:{for(let E of t.items)E.bbox().isIntersect(d)?b.push(E):a.push(E);for(let E of i.items)E.bbox().isIntersect(d)&&v.push(E);break}default:throw new Error("not support")}b.length!==t.items.length&&(t=new bi(b)),v.length!==i.items.length&&(i=new bi(v))}else{switch(e){case 0:break;case 1:case 3:{t.items.forEach(b=>a.push(b)),i.items.forEach(b=>a.push(b));break}case 2:{t.items.forEach(b=>a.push(b));break}default:throw new Error("not support")}t=new bi([]),i=new bi([])}m(t,o,!0),m(i,l,!1);let f=e===2||e===3?(b,v)=>et(b.getEnd(),v)?b.nextSide:b:(b,v)=>et(b.prevSide.getEnd(),v)?b.prevSide:b,u=(b,v,E)=>{if(et(b.getEnd(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&et(T.coord,b.getEnd()))===-1)return new po(E,b,c)}else return new po(E,b,c)},p=e===2||e===3?(b,v,E)=>{if(et(b.getStart(),E)){if(b.inters.findIndex(T=>T.getBindedInter().side===v&&et(T.coord,b.getStart()))===-1)return new po(E,b,c)}else return new po(E,b,c)}:u;r.seek(t,i,(b,v,E,T,P,A)=>{let C=o[b][v],M=l[T][P],H=C.sides[E],k=M.sides[A],F=xn(H.getShape(),k.getShape());if((H.getShape()instanceof Ye||k.getShape()instanceof Ye)&&F>=4){if(H.getShape()instanceof ye||k.getShape()instanceof ye){let L=function(x,I){let S=!1;for(let D=0;D<I.length;D+=2)et(new ae(I[D],I[D+1]),x)&&(S=!0);S||I.push(x.x,x.y)},R=[$[0],$[1]];for(let x=0;x<F;x+=2){let I=new ae($[x],$[x+1]);for(let S=x+2;S<F;S+=2){let D=new ae($[S],$[S+1]);if(!et(I,D)){L(D,R);break}}}F=R.length,R.forEach((x,I)=>$[I]=x)}else for(let L=F-2;L>=2;L-=2)for(let R=L-2;R>=0;R-=2)if(et(new ae($[L],$[L+1]),new ae($[R],$[R+1]))){$[R]=($[L]+$[R])/2,$[R+1]=($[L+1]+$[R+1])/2;for(let x=F-3;x>=L;x--)$[x]=$[x+2];F-=2;break}}let j=0;if(F===4){let L=function(I){return et(H.getEnd(),I)||et(H.prevSide.getEnd(),I)||et(k.prevSide.getEnd(),I)||et(k.getEnd(),I)},R=new ae($[0],$[1]),x=()=>{let I=new po(R,H,c),S=new po(R,k,c);I.bind(S),I.setIsInvalid(),I.isDealed(),C.inters.push(I),M.inters.push(S)};if($[0]===$[2]&&$[1]===$[3])if(L(R))j=2;else{x();return}}for(;j<F;j+=2){let L=new ae($[j],$[j+1]),R=H,x=k;if(et(R.prevSide.getEnd(),L)&&(R=R.prevSide),x=f(x,L),H!==R&&k!==x){let S=e===2||e===3?k.getEnd():x.getEnd();R.getEnd().distance1(L)<S.distance1(L)?(L=R.getEnd(),et(S,L)||(x=k)):(L=S,et(R.getEnd(),L)||(R=H))}let I=u(R,x,L);if(I){let S=p(x,R,L);S&&(R.addInter(I),C.inters.push(I),x.addInter(S),M.inters.push(S),I.bind(S),C.intersect(M,h))}}return F},s);let g=O(),_=RG(o,l,e);_.forEach(b=>!b.startAndEndIsSameOutsideFlag()&&b.reverse()),new NG(g.concat(_)).getPolygons().forEach(b=>a.push(b));let y=new bi(a);if(c){if(nf===-1){let b=c.initColor(Ht.RED),v=c.initColor(Ht.Golden);a.forEach(E=>{b.addPly(E.items[0]),E.items.slice(1).forEach(T=>v.addPly(T))}),c.draw();debugger;throw new Error}y.id=nf}return Pa.BooleanTools+=nl(n),y;function m(b,v,E){b.items.forEach(T=>{let P=[];P.push(X1.build(T.items[0],E,!0,c,T)),T.items.slice(1).forEach(A=>{P.push(X1.build(A,E,!1,c))}),v.push(P)})}function O(){let b=[];return h.forEach(E=>{e===2||e===3?E.forEach(P=>{P.isGroup1||P.reverse(),P.sides.forEach(A=>A.sortInters())}):E.forEach(P=>P.sides.forEach(A=>A.sortInters())),E.map(P=>P.sides.filter(A=>A.inters.length)).flat(2).sort((P,A)=>{let C=P.inters,M=A.inters,H=et(C[C.length-1].coord,P.getEnd()),k=et(M[M.length-1].coord,A.getEnd());if(H&&k){let F=0,j=0;for(let L=C.length-2;L>=0&&et(C[L].coord,P.getEnd());L--)F++;for(let L=M.length-2;L>=0&&et(M[L].coord,A.getEnd());L--)j++;return j-F}else return H?-1:1}).forEach(P=>{P.inters.forEach(A=>{if(A.dealed)return;let C=A.side,M=A.getBindedInter().side,H;et(C.getEnd(),A.coord)&&et(M.getEnd(),A.coord)?H=-1:et(C.getEnd(),A.coord)?(H=1,A=A.getBindedInter()):et(M.getEnd(),A.coord)&&(H=1);let k=DG(H,A,e,c);A.isDealed(),k&&(C.outline.setAllInterIsInvalidToFalse(),M.outline.setAllInterIsInvalidToFalse())})}),T(E),e===3&&(E.forEach(P=>{P.reverse(),P.sides.forEach(A=>{A.sortInters(),A.inters.forEach(C=>{C.resetVisitStatus()})})}),T(E));function T(P){P.forEach(A=>{A.inters.forEach(C=>{if(C.isInvalid||C.getVisited())return;let M=C.findStartInter(),H=v(e)?M.run():M.getBindedInter().run(),k=A.polyline.primitives;if(H){if(k.length===H.primitives.length){let F=new Set(k);if(!H.primitives.some(j=>!F.has(j))){b.push(A);return}}b.push(X1.build(H,!0,!0,c))}})})}}),b;function v(E){switch(E){case 0:case 2:case 3:return!0;case 1:return!1;default:throw Error("not support the rule")}}}}var h_=/\bstablilizetion\b/.test(self.location.href)||!0,c_={intersect(e,t,i,r){try{return af(0,e,t,i,r)}catch(s){if(h_){let n=new sf().getIntersection(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new bi(n.map(a=>new or(a.items)))}throw s}},union(e,t,i,r){try{return af(1,e,t,i,r)}catch(s){if(h_){let n=new sf,a=e.items.map(l=>l.items.map(h=>h)).flat(2);t.items.forEach(l=>l.items.forEach(h=>a.push(h)));let o=n.getUnion(a);return new bi(o.map(l=>new or(l.items)))}throw s}},diff(e,t,i,r){try{return af(2,e,t,i,r)}catch(s){if(h_){let n=new sf().getSubtraction(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new bi(n.map(a=>new or(a.items)))}throw s}},xor(e,t,i,r){try{return af(3,e,t,i,r)}catch(s){if(h_){let n=new sf().getMutuallyExclusive(e.items.map(a=>a.items.map(o=>o)).flat(2),t.items.map(a=>a.items.map(o=>o)).flat(2));return new bi(n.map(a=>new or(a.items)))}throw s}}},kG=class extends uf{constructor(e,t,i,r,s,n){super(e.rule,L_.DUMMY,t),this.sideGroup1=[],this.sideGroup2=[],this.group1=i,this.group2=r,this.seeker=s,this.addGroup(i,e.weight(0),this.sideGroup1),this.addGroup(r,e.weight(1),this.sideGroup2),this.bus=n}addGroup(e,t,i){if(!e)debugger;e.items.forEach(r=>{let s=[];r.items.forEach(n=>{let a=this.sides.length;this.addPolyline(n,t),s.push(this.sides.slice(a))}),i.push(s)})}seekIntersection(){this.seeker.seek(this.group1,this.group2,(e,t,i,r,s,n)=>{let a=this.sideGroup1[e][t][i],o=this.sideGroup2[r][s][n],l=xn(a.shape,o.shape);for(let h=0;h<l;h+=2){let c=new ae($[h],$[h+1]);a.inters.push(c),o.inters.push(c),this.event.onIntersect(c,a,o)}return l},this.bus)}},FG=class extends cf{constructor(e){super(!!e),e&&(this.drawDebug=new Of(e),this.blueDrawing=this.drawDebug.initColor(Ht.BLUE),this.greenDrawing=this.drawDebug.initColor(Ht.GREEN),this.redDrawing=this.drawDebug.initColor(Ht.RED))}onOriginSide(e){super.onOriginSide(e),this.debug&&this.blueDrawing.addPt(e.shape)}onPolylineGroup(e,t){super.onPolylineGroup(e,t),this.debug&&e.items.forEach(i=>this.greenDrawing.addPly(i))}draw(){this.drawDebug.draw()}};function K1(e,t,i,r,s){let n=bf(),a=new FG(s);new kG(e,a,t,i,r,s).simplify();let o=[];a.plGrps.forEach(h=>{let c=h.items.map(d=>I_(d));c[0]&&o.push(new or(c.filter(d=>d)))});let l=new bi(o);return Pa.BooleanTools+=nl(n),l}var $1=!0,$d={intersect(e,t,i,r){try{return c_.intersect(e,t,i,r)}catch(s){if($1)throw s;return console.error(s),K1(__,e,t,i,r)}},union(e,t,i,r){try{return c_.union(e,t,i,r)}catch(s){if($1)throw s;return console.error(s),K1(nG,e,t,i,r)}},diff(e,t,i,r){try{return c_.diff(e,t,i,r)}catch(s){if($1)throw s;return console.error(s),K1(g_,e,t,i,r)}},xor(e,t,i,r){return c_.xor(e,t,i,r)}},UG=class{init(e){}seek(e,t,i,r){let s=e.bbox().extendOfSize(5e-6).intersection1(t.bbox().extendOfSize(5e-6));if(!s)return;let n=bf(),a=[];for(let f=0,u=e.items.length;f<u;f++){let p=e.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&a.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let o=a.length;if(o===0){Pa.IntersectionSeeker+=nl(n);return}let l=[];for(let f=0,u=t.items.length;f<u;f++){let p=t.items[f];if(s.isIntersect(p.bbox()))for(let g=0,_=p.items.length;g<_;g++){let y=p.items[g];if(s.isIntersect(y.bbox()))for(let m=0,O=y.primitives.length;m<O;m++){let b=y.primitives[m].bbox();s.isIntersect(b)&&l.push({bbox:b,polygonIndex:f,polylineIndex:g,ptIndex:m})}}}let h=l.length;if(h===0){Pa.IntersectionSeeker+=nl(n);return}if(o<5||h<5){for(let f=0,u=a.length;f<u;f++)for(let p=0,g=l.length;p<g;p++)if(a[f].bbox.isIntersect(l[p].bbox.extendOfSize(1e-5))){let _=a[f],y=l[p];i(_.polygonIndex,_.polylineIndex,_.ptIndex,y.polygonIndex,y.polylineIndex,y.ptIndex)}Pa.IntersectionSeeker+=nl(n);return}a.sort((f,u)=>f.bbox.minX-u.bbox.minX),l.sort((f,u)=>f.bbox.minX-u.bbox.minX);let c=0,d=0;for(;c<o&&d<h;)if(a[c].bbox.minX<l[d].bbox.minX){let f=a[c],u=f.bbox;for(let p=d;p<h;p++){let g=l[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(u.minY<_.minY?_.minY:u.minY)<(u.maxY<_.maxY?u.maxY:_.maxY)+1e-5&&i(f.polygonIndex,f.polylineIndex,f.ptIndex,g.polygonIndex,g.polylineIndex,g.ptIndex)}c++}else{let f=l[d],u=f.bbox;for(let p=c;p<o;p++){let g=a[p],_=g.bbox;if(_.minX>u.maxX+1e-5)break;(_.minY<u.minY?u.minY:_.minY)<(_.maxY<u.maxY?_.maxY:u.maxY)+1e-5&&i(g.polygonIndex,g.polylineIndex,g.ptIndex,f.polygonIndex,f.polylineIndex,f.ptIndex)}d++}Pa.IntersectionSeeker+=nl(n)}},Uc=class co{static getDebug(){return co.drawDebug||(co.drawDebug=new Of(co.curBus)),co.drawDebug}static getDrawing(t=Ht.GREEN){return this.getDebug().initColor(t)}static clearDrawing(){co.getDebug().clear()}static drawText(t,i,r=Ht.GREEN){co.getDrawing(r).addText(t,i,1.5,.1,!0)}static drawBBox(t,i=Ht.GREEN){if(!t)return;let r=co.getDrawing(i),s=new le(t.UL(),t.UR()),n=new le(t.UR(),t.LR()),a=new le(t.LR(),t.LL()),o=new le(t.LL(),t.UL());r.addPt(s),r.addPt(n),r.addPt(a),r.addPt(o)}static drawPolyType(t,i){let r=co.getDrawing(i);if(t instanceof It)r.addPly(t);else if(t instanceof or)for(let s of t.items)s instanceof It?r.addPly(s):this.drawPolyType(s,i);else if(t instanceof bi)for(let s of t.items)this.drawPolyType(s,i)}static translate(t){switch(t){case 0:return"\u2229";case 2:return"-";case 1:return"U";case 3:return"X";default:break}}};Uc.UseOptimizeSplit=!0,Uc.LocalBestThread=4,Uc.HandleDiff=!0,Uc.OcTreeSplitStep=4,Uc.PrintStart=new ae(150,-200);var ls=Uc,Qd=class gb{static getPolyTypeLine(t){let i=[];if(t instanceof It)for(let r of t.primitives)i.push(r);else if(t instanceof or)for(let r of t.items)if(r instanceof It)for(let s of r.primitives)i.push(s);else{let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}else if(t instanceof bi)for(let r of t.items){let s=this.getPolyTypeLine(r);for(let n of s)i.push(n)}return i}static getPolyTypePolyLine(t){let i=[];if(t instanceof It)i.push(t);else if(t instanceof or)for(let r of t.items)if(r instanceof It)i.push(r);else{let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}else if(t instanceof bi)for(let r of t.items){let s=this.getPolyTypePolyLine(r);for(let n of s)i.push(n)}return i}static getListBBox(t){if(t.length<=0)return;let i=new yi;for(let r of t){let s=gb.getSingleBBox(r);i.ext1(s)}return i.build1()}static getSingleBBox(t){if(t instanceof Array){let i=new yi,r=gb.getListBBox(t.slice(1));return i.ext1(r),i.build1()}else return t.bbox()}static doDrawRule(t,i=ls.PrintStart){if(t.length<2)return[i,i,i];let r=5,s=10,n=t[0],a=ls.translate(n),o=[],l=i.y,h=i.x,c=i.x;i=i.add(new ae(0,-s));for(let u=1;u<t.length;u++){let p=t[u];if(p instanceof Array){i=i.add(new ae(r,0));let g=this.doDrawRule(p,i);o.push(g[0]),g[1].x<=h&&(h=g[1].x),g[2].x>=c&&(c=g[2].x),i=new ae(g[2].x+r,i.y)}else o.push(i.clone()),i.x<=h&&(h=i.x),i.x>=c&&(c=i.x),ls.drawText(i,p.name),i=i.add(new ae(r,0))}let d=0;for(let u of o)d+=u.x;let f=new ae(d/o.length,i.y+s);ls.drawText(f,"N:"+a);for(let u of o){let p=new le(u,f),g=new Array;g.push(p);let _=It.build1(sb(g));ls.drawPolyType(_,Ht.GREEN)}return[f,new ae(h,l),new ae(c,l)]}static drawRule(t,i=ls.PrintStart,r=!1,s){ls.clearDrawing(),this.doDrawRule(t,i),r&&this.doDrawRulePolygon(t,s),ls.getDebug().draw()}static doDrawRulePolygon(t,i){let r=t[0];for(let s=1;s<t.length;s++){let n=t[s];if(n instanceof Array)this.doDrawRulePolygon(n,i);else{let a=i;r===2&&s===1&&(a=Ht.RED),n.name&&ls.drawText(n.bbox().UL(),n.name,a),ls.drawPolyType(n,a)}}}static IsCenterBBoxPointInPolygonType(t,i){let r=t.center();for(let s of i.items)if(s.getOutMostPolyline().getWindingNum(r))return!0;return!1}static KeepBBoxPolygonGroup(t,i){let r=i.bbox().intersection1(t);if(!r)return!1;for(let s of i.items)if(s.bbox().isIntersect(r)){for(let n of s.items)if(n.bbox().isIntersect(r)){for(let a of n.primitives)if(r.isIntersect(a.bbox()))return!0}}return!!this.IsCenterBBoxPointInPolygonType(t,i)}},GG=class Gc{static createNode(t,i,r){let s=t.UL(),n=t.width()/i,a=t.height()/i,o=~~(r/i),l=r-o*i,h=s.x+l*n,c=s.y-(o+1)*a,d=h+n,f=c+a;return new Pi(h,d,c,f)}static ocTreeSplitNode(t,i,r,s,n=2){if(t.length<=r)return t;let a=[],o=n**2,l=new Array(o),h=new Array(o);for(let u=0;u<o;u++)l[u]=new Array(t.length),h[u]=0;let c=i.UL(),d=i.width()/n,f=i.height()/n;for(let u of t){let p=s(u).center(),g=~~((p.x-c.x)/d),_=~~((c.y-p.y)/f)*n+g;try{l[_][h[_]]=u,h[_]+=1}catch{a.push(u)}}for(let u=0;u<l.length;u++){let p=h[u];if(p<=0)continue;let g=l[u].slice(0,p);if(g.length===t.length)return t;let _=Gc.createNode(i,n,u),y=Gc.ocTreeSplitNode(g,_,r,s,n);if(y.length===t.length)return t;a.push(y)}return a}static ocTreeSplitNodeMinIntersect(t,i,r,s){let n=[];if(t.length<=r)return t;let a=3,o=i.LL(),l=i.UR(),h=i.width()/(a+1),c=i.height()/(a+1),d=-(2**32),f=[],u=[];for(let p=1;p<=a;p++)for(let g=1;g<=a;g++){let _=o.x+h*p,y=o.y+c*g,m=[[],[],[],[]],O=new Array(4),b=new Array(4);b[0]=new Pi(o.x,_,y,l.y),b[1]=new Pi(_,l.x,y,l.y),b[2]=new Pi(o.x,_,o.y,y),b[3]=new Pi(_,l.x,o.y,y);for(let P of t){let A=s(P).center(),C=-1,M=-1;A.x===_?C=Math.random()>=.5?1:-1:A.x>_?C=1:A.x<_&&(C=-1),A.y===y?M=Math.random()>=.5?1:-1:A.y>y?M=1:A.y<y&&(M=-1),C===1&&M===1?m[1].push(P):C===1&&M===-1?m[3].push(P):C===-1&&M===-1?m[2].push(P):C===-1&&M===1&&m[0].push(P)}for(let P=0;P<4;P++){let A=m[P];if(A.length<=0)continue;let C=new yi;for(let M of A)C.ext1(s(M));O[P]=C.build1()}let v=0,E=0;for(let P of O)P&&(v+=P.area());E=v;let T=(P,A)=>{if(!O[P]||!O[A])return 0;let C=O[P].intersection1(O[A]);return C?C.area():0};E-=T(0,1),E-=T(0,2),E-=T(0,3),E-=T(1,2),E-=T(1,3),E-=T(2,3),E/v>=d&&(f=m,u=b)}for(let p=0;p<f.length;p++){let g=f[p];if(g.length<=0)continue;let _=u[p],y;if(g.length===t.length?y=Gc.ocTreeSplitNode(g,_,r,s):y=Gc.ocTreeSplitNodeMinIntersect(g,_,r,s),y.length===t.length)return t;n.push(y)}return n}static ocTreeSplit(t,i,r,s){return Gc.ocTreeSplitNode(t,i,r,s,ls.OcTreeSplitStep)}},zG=class tS{static OcTreeOptimizeSplit(t){let i=t[0];if(i!==1||t.length<=ls.LocalBestThread+1)return t;let r=t.slice(1),s=new Array(r.length);for(let h=1;h<t.length;h++)s[h-1]=h;let n=Qd.getListBBox(r),a=GG.ocTreeSplit(s,n,ls.LocalBestThread,h=>{let c=t[h];return Qd.getSingleBBox(c)}),o=(h,c)=>{if(!(h.length<=0))for(let d of h)if(Array.isArray(d)){let f=[c[0]];o(d,f),c.push(f)}else{let f=t[d];c.push(f)}},l=[i];return o(a,l),l}static optimizeSplit(t,i){let r=t[0];if(r===2){if(ls.HandleDiff){let n=t[1],a;if(Array.isArray(n)){let o=this.optimizeSplit(n,i);if(o.length<=1)return[2];a=A_(o,i)}else a=A_([2,n],i);if(t.length>3){let o;o=[1];for(let l=2;l<t.length;l++){let h=t[l];if(Array.isArray(h)){let c=Qd.getListBBox([...h.slice(1)]);Qd.KeepBBoxPolygonGroup(c,a)&&o.push(h)}else Qd.KeepBBoxPolygonGroup(h.bbox(),a)&&o.push(h)}return o.length<=1?[2,a]:(o=this.optimizeSplit(o,i),o.length>1?[2,a,...o.slice(1)]:[2,a])}else{let o=t[2];if(Array.isArray(o)&&o[0]===1&&o.length>2){let l=o.slice(1);return this.optimizeSplit([2,a,...l],i)}}}else if(t.slice(1).length>2){let n=t[1],a=t.slice(2),o=this.optimizeSplit([1,...a],i);return o.length>1?[2,n,...o.slice(1)]:n}}else if(r===1){if(t.length-1>ls.LocalBestThread){let n=!1;for(let a=1;a<t.length;a++){let o=t[a];if(!Array.isArray(o)){n=!0;break}}n&&(t=tS.OcTreeOptimizeSplit(t))}}else if(r===0&&t.length<=2)return[0];let s=[r];for(let n=1;n<t.length;n++){let a=t[n];if(Array.isArray(a)){let o=this.optimizeSplit(a,i);if(o.length<=1)continue;s.push(o)}else s.push(a)}return s}},HG=(e=>(e[e.INTERSECT=0]="INTERSECT",e[e.UNION=1]="UNION",e[e.DIFF=2]="DIFF",e[e.XOR=3]="XOR",e))(HG||{});function of(e){let t=e[0],i=[t];switch(t){case 0:for(let s=1;s<e.length;s++){let n=e[s];if(Array.isArray(n)&&(n=of(n),!n))return null;i.push(n)}break;case 1:case 3:for(let s=1;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=of(n),!n)||i.push(n)}break;case 2:let r=e[1];if(Array.isArray(r)&&(r=of(r)),!r)return null;i.push(r);for(let s=2;s<e.length;s++){let n=e[s];Array.isArray(n)&&(n=of(n),!n)||i.push(n)}break;default:throw new Error("not support boolean rule!")}return i.length===1?null:i.length===2?i[1]:i}function Q1(e,t,i){return Array.isArray(e)?iS(e,t,i):e}function eb(e,t,i,r,s=!0){if(s)for(;e.length>1;){let n,a=[];for(e.length%2===1?(a.push(e[0]),n=1):n=0;n<e.length;n+=2)a.push(t(e[n],e[n+1],i,r));e=a}else for(;e.length>1;){if(e.length===2)return t(e[0],e[1],i,r);e=[t(e[0],e[1],i,r),...e.slice(2)]}return e[0]}function iS(e,t,i,r=!0){let s=new Array(e.length-1);for(let n=1;n<e.length;n++)s[n-1]=Q1(e[n],t,i);switch(e[0]){case 0:return eb(s,$d.intersect,t,i);case 1:return eb(s,$d.union,t,i);case 2:let n=eb(s.slice(1),$d.union,t,i);return n?$d.diff(s[0],n,t,i):s[0];case 3:let a=Q1(e[1],t,i);for(let o=2;o<e.length;o++)a=$d.xor(a,Q1(e[o],t,i),t,i);return a;default:throw new Error("not support boolean rule! "+e[0])}}function rS(e){let t=[e[0]];for(let i=1;i<e.length;i++){let r=e[i];if(Array.isArray(r)){let s=rS(r);Array.isArray(s)?s.length>1&&t.push(s):t.push(s)}else{let s=I_(r);s!==null&&t.push(bi.build(s))}}return t}function jG(e){let t=[];for(let i=0;i<e.length;i+=2){let r=e[i],s=e[i+1];s?t.push({xor:sl([3,r,s]),union:sl([1,r,s])}):t.push({xor:r,union:r})}for(;t.length!==1;){for(let i=0;i<t.length;i+=2){let r=t[i],s=t[i+1],n=i/2;if(!s){t[n]=r;break}let a=sl([2,r.xor,s.union]),o=sl([2,s.xor,r.union]),l=[];a.items.forEach(h=>l.push(h)),o.items.forEach(h=>l.push(h)),t[n]={xor:new bi(l),union:sl([1,r.union,s.union])}}t.length=Math.ceil(t.length/2)}return t[0].xor}function _b(e){let t=e[0];if(t===3&&e.length>3){let r=[];for(let s=1;s<e.length;s++){let n=e[s];if(n instanceof bi)r.push(n);else{let a=_b(n);a instanceof bi?r.push(a):r.push(sl(a))}}return jG(r)}let i=[t];for(let r=1;r<e.length;r++){let s=e[r];s instanceof bi?i.push(s):i.push(_b(s))}return sl(i)}function sl(e,t){if(!ls.UseOptimizeSplit)return A_(e,t);let i=zG.optimizeSplit(e,t);return i.length<=1?new bi([]):A_(i,t)}function VG(e,t){ls.curBus=t;let i=rS(e),r=of(i);if(!(r instanceof Array))return r||new bi([]);let s=_b(r);return s instanceof bi?s:sl(s)}function A_(e,t,i=!0){if(!e||e.length===1)return new bi([]);let r=e,s=new UG,n=[];function a(o){for(let l=1;l<o.length;l++){let h=o[l];Array.isArray(h)?a(h):n.push(h)}}return a(r),s.init(n),iS(r,s,t,i)}var u_=new Error("list is empty"),d_=class{constructor(e,t){this.prev=null,this.next=null,this.parent=e,this.item=t}insertAfter(e){e.next=this.next,this.next=e,e.prev=this,e.next!==null&&(e.next.prev=e)}insertBefore(e){e.prev=this.prev,this.prev=e,e.next=this,e.prev!==null&&(e.prev.next=e)}remove(){this.prev!==null&&(this.prev.next=this.next),this.next!==null&&(this.next.prev=this.prev)}set(e){this.item=e}},YG=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e.item;throw new Error("iterator is null")}},qG=class{constructor(e){this._next=e}hasNext(){return this._next!==null}next(){let e=this._next;if(e!==null)return this._next=e.next,e;throw new Error("iterator is null")}},WG=class{constructor(){this.first=null,this.last=null,this.cnt=0}add(e){return this.addLast(e)}push(e){return this.addLast(e)}pop(){return this.removeLast()}shift(){return this.removeFirst()}removeFirst(){let e=this.first;if(e===null)throw u_;return this.remove(e),e.item}removeLast(){let e=this.last;if(e===null)throw u_;return this.remove(e),e.item}addLast(e){if(this.first===null||this.last===null){let t=new d_(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertAfter(this.last,e)}addFirst(e){if(this.first===null||this.last===null){let t=new d_(this,e);return this.first=t,this.last=t,this.cnt++,t}else return this.insertBefore(this.first,e)}getFirst(){if(this.first===null)throw u_;return this.first.item}getLast(){if(this.last===null)throw u_;return this.last.item}insertAfter(e,t){let i=new d_(this,t);return e.insertAfter(i),e===this.last&&(this.last=i),this.cnt++,i}insertBefore(e,t){let i=new d_(this,t);return e.insertBefore(i),e===this.first&&(this.first=i),this.cnt++,i}remove(e){e.remove(),e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev),this.cnt--}size(){return this.cnt}clear(){this.first=null,this.last=null,this.cnt=0}iterator(){return new YG(this.first)}listIterator(){return new qG(this.first)}toArray(){let e=new Array,t=this.first;for(;t!=null;)e.push(t.item),t=t.next;return e}},m_=class{constructor(e){this.inters=[],e&&(this.inters=e)}addInter(e){this.inters.push(e),e.group=this}findInter(e){let t=this.inters.find(i=>et(i.coord,e.coord));return t&&this.inters.find(i=>i.side===e.side)&&e.visitSelf(),t}getOutInter(e){let t=this.inters.filter(i=>!i.getVisited());if(t.length!==0)return t.length===1?t[0]:t.reduce((i,r)=>{if(!i||i.side.getShape()===e)return r;if(r.side.getShape()===e)return i;let s=i.coord,n=ct(e,s),a=ct(i.side.getShape(),s),o=ct(r.side.getShape(),s);return n.dot(a)>n.dot(o)?i:r},void 0)}getEntryInter(){}},tb=0;function sS(e,t){let i=e.primitives[0];if(e.primitives.length===1&&i instanceof ye&&Math.abs(i.sweepAngle)===360)return[e];let r=bf();tb++;let s,n=iz(e);if(n.length===0)return[];let a=ZG(n);if(tb===-1){s=new Of(t);let c=s.initColor(Ht.BLUE);n.forEach(f=>c.addPt(f.getShape()));let d=s.initColor(Ht.GREEN);a.forEach(f=>d.addPoint(f.coord)),s.draw();debugger;throw new Error}if(a.length===0)return[It.build7(n.map(c=>c.getShape()))];KG(a);let o=[],l=!1;try{ez(a,s)}catch(c){c.customType==="IS_OVERLAP"?(l=!0,o=new sf().getUnion([e]).map(d=>d.items).flat(2)):console.error(c)}if(l)return o;let h=QG(a);if(!h.length)return[It.build7(n.map(c=>c.getShape()))];if(o=XG(h,s),o.length===0)return console.warn("=====deSelfIntersection=====",tb),[];if(s)throw o.forEach(c=>{s.initColor(Ht.WHITE).addPly(c),s.draw();debugger}),new Error;return Pa.deSelfIntersection+=nl(r),o}function XG(e,t){let i=[];return e.forEach(r=>{let s=r;r.inters.forEach(n=>{if(n.getVisited())return;let a=[],o=[],l;if(t){debugger;let c=t.initColor(Ht.RED);l=d=>{a.push(d),c.addPt(a[a.length-1]),t.draw();debugger}}else l=c=>a.push(c);do{let c=function(g,_){ve.eq(g.distance2(_),0)||l(nS(u.getShape(),g,_))},d=o.findIndex(g=>g===n.group);if(d!==-1){let g=a.findIndex(m=>m===n.group),_=a.splice(g).filter(m=>!(m instanceof m_));if(_.length){let m=ol(It.build7(_));m&&i.push(m)}let y=a.filter(m=>!(m instanceof m_));if(n=o[d].getOutInter(y[y.length-1]),o.splice(d),!n)throw Error("interGroup not hav inter!!!2");continue}n.visitSelf(),o.push(n.group),a.push(n.group);let f=n.getIndex(),u=n.side,p=u.inters[f+1];for(;p!=null&&p.isInvalid||p&&p.group===n.group;)p=u.inters[p.getIndex()+1];if(p){c(n.coord,p.coord);let g=p.getBindedInter();if(n=g.getVisited()?g.group.getOutInter(g.side.getShape()):g,!n){if(p.group===s)break;throw new Error("interGroup not hav inter!!!3")}}else{for(c(n.coord,u.getEnd()),u=u.nextSide,n=null;;){for(let g of u.inters)if(!g.isInvalid){let _=g.group.getOutInter(u.getShape());if(!_){if(g.group===s){n=g;break}else if(g.getBindedInter().group===s){n=g.getBindedInter();break}continue}n=_;break}if(n)break;l(u.getShape()),u=u.nextSide}ve.eq(u.getEnd().distance2(n.coord),0)?l(u.getShape()):c(u.getStart(),n.coord)}}while(n.group!==s);let h=ol(It.build7(a.filter(c=>!(c instanceof m_))));h&&i.push(h)})}),i}function JG(e){return{next(){return e.hasNext()?{value:e.next()}:{done:!0,value:void 0}},[Symbol.iterator](){return this}}}function ZG(e){let t=[],i=new WG;for(let r of e.slice().sort((s,n)=>s.bbox().minY-n.bbox().minY)){for(let s of JG(i.listIterator())){let n=s.item;if(n.bbox().maxY<r.bbox().minY)i.remove(s);else{let a=function(f,u){let p=new po(u,f,null);return f.inters.push(p),t.push(p),p},o=function(f,u){let p=f.getEnd(),g=new ae($[0],$[1]),_=new ae($[2],$[3]),y=p.distance2(g)>p.distance2(_)?g:_,m=f.prevSide;a(et(m.getEnd(),y)?m:f,y).bind(a(u,y))},l=n.getShape(),h=r.getShape(),c=xn(l,h),d=c===4&&$[0]===$[2]&&$[1]===$[3];if(d&&(c-=2),n.nextSide===r)n.prevSide!==r&&c===4&&o(n,r);else if(n.prevSide===r)c===4&&o(r,n);else if(c!==0){let f=function(p,g){let _=p.prevSide;return a(et(_.getEnd(),g)?_:p,g)},u=new ae($[0],$[1]);if(d&&!et(u,n.prevSide.getEnd())&&!et(u,r.prevSide.getEnd())&&ct(l,u).dot(ct(h,u))>0)continue;for(let p=0;p<c;p+=2){let g=new ae($[p],$[p+1]);f(n,g).bind(f(r,g))}}}}i.add(r)}return t.forEach(r=>{r.getIndex()===void 0&&r.side.sortInters()}),t}function KG(e){e.forEach(t=>{let i=t.side.getEnd();if(t.isInvalid||!et(t.coord,i))return;let r=t.side.inters,s=t.getBindedInter().side;for(let n=r.length-1;n>=0;n--){let a=r[n];if(!et(a.coord,i))break;a!==t&&a.getBindedInter().side===s&&a.setIsInvalid()}})}function $G(e){let t=new ff(10);return e.forEach(i=>{i.isInvalid||t.add(i)}),t}function QG(e){let t=[],i=$G(e);return e.forEach(r=>{if(r.isInvalid||r.group)return;let s=i.search(r.bbox().extendOfSize(ve.eps)).filter(n=>!n.group);if(s.length){let n=new Set,a=new m_(s);s.forEach(o=>{o.group=a,n.has(o.side)&&o.visitSelf(),n.add(o.side)}),t.push(a)}}),t}function ez(e,t){e.forEach(i=>{if(i.isInvalid||i.dealed)return;let r=i.side,s=i.getBindedInter().side,n;et(r.getEnd(),i.coord)&&et(s.getEnd(),i.coord)?n=-1:et(r.getEnd(),i.coord)?r.nextSide!==s&&(n=1,i=i.getBindedInter()):et(s.getEnd(),i.coord)&&s.nextSide!==r&&(n=1),tz(n,i,t),i.isDealed()})}function tz(e,t,i){let r=t.getBindedInter(),s=t.side,n=r.side,a=s.getShape(),o=n.getShape(),l=1,h=!1;if(e===-1){if(Nc(a.reverse(),o.reverse())||Nc(s.nextSide.getShape(),n.nextSide.getShape())){let d=uo(s,s.nextSide,n,r,l,h,i);if(d.state===2){let u=new Error("info1.state === InState.IS_OVERLAP");throw u.customType="IS_OVERLAP",u}let f=uo(s,s.nextSide,n.nextSide,r,l,h,i);d.state===f.state&&c(d,f)}else if(!(Nc(a.reverse(),n.nextSide.getShape())||Nc(s.nextSide.getShape(),o.reverse()))){let d=q1(s,s.nextSide,n,!1,i);d===q1(s,s.nextSide,n.nextSide,!0,i)&&d!==q1(n,n.nextSide,s.nextSide,!0,i)&&t.setIsInvalid()}}else if(e===1){let d=function(f,u){return ct(f,u.start()).dot(ct(u,u.start()))>0};if(Nc(a.reverse(),o.reverse())||Nc(a,n.nextSide.getShape())){let f=sn(s,n,r,i,l,h,new Map);if(f.state===2){let p=new Error("info1.state === InState.IS_OVERLAP");throw p.customType="IS_OVERLAP",p}let u=sn(s,n.nextSide,r,i,l,h,new Map);f.state===u.state&&c(f,u)}else if(d(a.reverse(),o.reverse())&&d(a,n.nextSide.getShape())){let f=Sr(s,n,!1,i);f===Sr(s,n.nextSide,!0,i)&&f!==oh(n,n.nextSide,new mf(nS(a,t.coord,a.end()),i),!0,i)&&t.setIsInvalid()}}function c(d,f){d.inter.setIsInvalid(),f.inter.setIsInvalid(),t.setIsInvalid()}}function nS(e,t,i){if(e instanceof le||t.distance2(i)<1e-6)return new le(t,i);if(e instanceof ye)return ye.build2(e.center,t.angleD(e.center),i.angleD(e.center),e.rx,e.ry,e.sweep());if(e instanceof Ye){let r=e.getPercent(t,ut),s=e.getPercent(i,ut);return e.clip(r)[1].clip((s-r)/(1-r))[0]}else throw new Error("not supported operation")}function iz(e){let t=ol(e);if(!t)return[];let i=t.primitives.map(s=>new mf(s,null)),r=i[i.length-1];return i.forEach(s=>{r.connect(s),r=s}),i}var lf=class{static clearData(e){this.originalPrimitive=[],this.offsetPrimitive=[],this.rawOffsetPrimitive=[],this.offsetDistance=0,this.testI++,this.testI===0?this.drawDebug=new Of(e):delete this.drawDebug}static createRawOffsetEdge(){if(this.drawDebug){let e=this.drawDebug.initColor(Ht.WHITE);this.originalPrimitive.forEach(t=>e.addPt(t)),this.drawDebug.draw();debugger}for(let e=0;e<this.originalPrimitive.length;e+=1){let t=this.originalPrimitive[e];this.offsetPrimitive.push({index:e,offsetEdge:this.createOffsetEdge(t)})}if(this.drawDebug){let e=this.drawDebug.initColor(Ht.Golden);this.offsetPrimitive.forEach(t=>e.addPt(t.offsetEdge)),this.drawDebug.draw();debugger}if(this.offsetPrimitive.length>1)for(let e=0;e<this.offsetPrimitive.length;e+=1)if(e===this.offsetPrimitive.length-1){this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[0]);let t=this.rawOffsetPrimitive[0],i;t instanceof ye?i=ye.build4(this.offsetPrimitive[0].offsetEdge.start(),t.end(),t.center,t.rx,t.ry,t.sweep()):i=new le(this.offsetPrimitive[0].offsetEdge.start(),t.end()),this.rawOffsetPrimitive.shift(),this.rawOffsetPrimitive.unshift(i)}else this.connectPrimitive(this.offsetPrimitive[e],this.offsetPrimitive[e+1]);else this.rawOffsetPrimitive=[]}static createCirclePrimitive(e,t){let i=e.width()*.5,r=e.height()*.5,s=Math.sqrt(i**2+r**2)+t;return[ye.buildCircle(e.center(),s)]}static getExtendPolyLine(e,t,i=!0,r){var s,n;if(!((s=e==null?void 0:e.primitives)!=null&&s.length))return[];this.isExpansion=t>0;let a=ol(e);if(!((n=a==null?void 0:a.primitives)!=null&&n.length)){if(this.isExpansion){let l=[1],h=t*2;e.primitives.forEach(d=>l.push(d.stroke(h,1,0)));let c=VG(l,r);if(c.items.length!==1)throw new Error("group.items.length !== 1 ");return[c.items[0].items[0]]}return[]}if(e=a,this.clearData(r),this.originalPrimitive=e.primitives,this.offsetDistance=t,this.createRawOffsetEdge(),this.drawDebug){let l=this.drawDebug.initColor(Ht.BLUE);this.rawOffsetPrimitive.forEach(h=>l.addPt(h)),this.drawDebug.draw();debugger}let o=i?this.createClippingEdge(r):[It.build2(this.rawOffsetPrimitive)];if(this.drawDebug){let l=this.drawDebug.initColor(Ht.RED);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger}if(o.length&&(!this.isExpansion||this.isExpansion&&o.length>1)&&(o=this.getValidityPrimitive(o)),this.drawDebug){let l=this.drawDebug.initColor(Ht.GREEN);o.forEach(h=>l.addPly(h)),this.drawDebug.draw();debugger;throw new Error}return o}static getValidityPrimitive(e){let t=[],i=Math.abs(this.offsetDistance);for(let r=0;r<e.length;r+=1){let s=!0,n=e[r].primitives;e:for(let a=0;a<n.length;a+=1){let o=n[a],l;if(o instanceof ye)l=o.midPoint;else if(o instanceof le)l=o.start();else throw new Error("not support!");for(let h=0;h<this.originalPrimitive.length;h+=1){let c=this.originalPrimitive[h],d;if(c instanceof ye?d=this.pointArcClosest(l,c):d=zU(l,c.start(),c.end()).d,i-d>.01){s=!1;break e}}}s&&t.push(e[r])}return t}static getInters(e){let t=[];for(let i=0;i<e;i+=2)t.push(new ae($[i],$[i+1]));return t}static pointArcClosest(e,t){let i=t.center;if(e.equals1(t.center))return t.rx;if(t.inArea(e,0)){let n=e.sub(i);return Math.abs(n.length()-t.rx)}let r=e.distance2(t.start()),s=e.distance2(t.end());return ve.less(r,s)?Math.sqrt(r):Math.sqrt(s)}static createClippingEdge(e){let t=[],i=[],r=sS(It.build2(this.rawOffsetPrimitive),e);r.forEach(n=>{let a=n.area(.01);t.push(a)});let s=Math.min(...t.filter(n=>n<0));for(let n=0;n<t.length;n+=1){let a=t[n];ve.eq(a,0)||(!this.isExpansion&&a<0||this.isExpansion&&(a<0&&t[n]===s||a>0))&&i.push(r[n])}return i}static createOffsetEdge(e){if(e instanceof ye)return e.panDistance2(this.offsetDistance);if(e instanceof le)return e.panDistance(this.offsetDistance);throw new Error("not support!")}static connectPrimitive(e,t){e.offsetEdge instanceof le&&t.offsetEdge instanceof le?this.lineToLineConnect(e,t):e.offsetEdge instanceof ye&&t.offsetEdge instanceof ye?this.arcToArcConnect(e,t):e.offsetEdge instanceof le&&t.offsetEdge instanceof ye?this.lineToArcConnect(e,t):this.arcToLineConnect(e,t)}static isFalseIntersection(e){return e>1||e<0}static lineToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.originalPrimitive[n].start();if(i.isParallel(r))i.bbox().intersection1(r.bbox())?this.rawOffsetPrimitive.push(i):this.lineToLineUseArcToConnect(a,i,r,s);else{let o=this.getLineToLineT(i,r),l=o[0],h=o[1];if(this.isFalseIntersection(l)||this.isFalseIntersection(h))l>1&&this.isFalseIntersection(h)?this.lineToLineUseArcToConnect(a,i,r,s):this.useLineToConnect(i,r);else if(!this.isFalseIntersection(l)&&!this.isFalseIntersection(h)){let c=i.end().sub(i.start()),d=i.start().add(c.mul(l)),f=new le(i.start(),d);this.rawOffsetPrimitive.push(f);let u=new le(d,r.end());this.updateNextOffsetPrimitive(n,u)}}}static updateNextOffsetPrimitive(e,t){this.offsetPrimitive[e].offsetEdge=t}static useLineToConnect(e,t){this.rawOffsetPrimitive.push(e);let i=new le(e.end(),t.start());this.rawOffsetPrimitive.push(i)}static lineToLineUseArcToConnect(e,t,i,r){let s=this.getSweep(e,t,r),n=this.getSweepAngel(t.end(),i.start(),e,s);if(n===0){this.useLineToConnect(t,i);return}this.rawOffsetPrimitive.push(t);let a=ye.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(a)}static getSweep(e,t,i){let r=null,s=i||i===0?this.originalPrimitive[i]:t;if(s instanceof ye){let n=s.center.sub(s.end()).normalize();s.isCCW?r=new ae(n.y,-n.x):r=new ae(-n.y,n.x)}else r=t.end().sub(t.start()).normalize();return e.sub(t.end()).normalize().cross(r)>0?0:1}static getLineToLineT(e,t){let i=e.end().sub(e.start()),r=t.end().sub(t.start()),s=i.cross(r),n=t.start().sub(e.start()),a=e.start().sub(t.start()),o=n.cross(r)/s,l=a.cross(i)/-s;return[o,l]}static lineToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(i,r),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.lineAndArcConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.lineAndArcConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static lineAndArcConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(t,r);if(!this.isFalseIntersection(i)&&o){let l=new le(e.start(),r);this.rawOffsetPrimitive.push(l);let h;!t.center.equals1(r)||t.sweepAngle>1e-4?(h=ye.build4(r,t.end(),t.center,t.rx,t.ry,t.sweep()),h instanceof ye&&h.sweepAngle===0&&(h=new le(h.start(),h.end()))):h=new le(t.center,r),this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static lineAndArcUseArcConnect(e,t,i,r){let s=this.getSweep(e,t,r),n=this.getSweepAngel(t.end(),i.start(),e,s);if(n===0){this.useLineToConnect(t,i);return}let a=ye.build5(t.end(),i.start(),n);this.rawOffsetPrimitive.push(t),this.rawOffsetPrimitive.push(a)}static arcToLineConnectionDetail(e,t,i,r,s,n,a){let o=this.isTrueArcIntersection(e,r);if(!this.isFalseIntersection(i)&&o){let l;e.center.equals1(r)?l=new le(e.center,r):Math.abs(e.sweepAngle)<1e-4?l=new le(e.start(),r):(l=ye.build4(e.start(),r,e.center,e.rx,e.ry,e.sweep()),l instanceof ye&&l.sweepAngle===0&&(l=new le(l.start(),l.end()))),this.rawOffsetPrimitive.push(l);let h=new le(r,t.end());this.updateNextOffsetPrimitive(a,h)}else o?this.useLineToConnect(e,t):this.lineAndArcUseArcConnect(s,e,t,n)}static isTrueArcIntersection(e,t){return Ji(e,t)}static getSweepAngel(e,t,i,r){let s=e.angleD(i),n=t.angleD(i),a;return s===n?a=0:(s=_t.regularD(s),n=_t.regularD(n),r===1?n<=s&&(n+=360):n>=s&&(s+=360),a=n-s),a}static getLineJoinArcScalarAndIntersectionNum(e,t){let i={t:[],intersectionNum:0,points:[]},r=FU(t,e);if(r){i.intersectionNum=r/2;for(let s=0;s<r-1;s+=2){let n=new ae($[s],$[s+1]);i.points.push(n),n.sub(e.start()).x<1e-4||n.sub(e.start()).y<1e-4?i.t.push(0):i.t.push(n.sub(e.start()).x/e.end().sub(e.start()).x)}}else i.intersectionNum=0;return i}static arcToLineConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=e.index,n=t.index,a=this.getLineJoinArcScalarAndIntersectionNum(r,i),o=this.originalPrimitive[n].start();if(a.intersectionNum===0)this.lineAndArcUseArcConnect(o,i,r,s);else if(a.intersectionNum===1){let l=a.points[0];this.arcToLineConnectionDetail(i,r,a.t[0],l,o,s,n)}else if(a.intersectionNum===2){let l=a.points[0],h=a.points[1],c=l.distance2(o),d=h.distance2(o);this.arcToLineConnectionDetail(i,r,c<d?a.t[0]:a.t[1],c<d?l:h,o,s,n)}}static rxChangeStatus(e){return e===1?!this.isExpansion:this.isExpansion}static arcToArcConnect(e,t){let i=e.offsetEdge,r=t.offsetEdge,s=BT(i,r);if(s){let n=this.getInters(s),a;if(n.length===2){let h=this.originalPrimitive[t.index].start(),c=n[0],d=n[1],f=c.distance2(h),u=d.distance2(h);f<u?a=c:a=d}else a=n[0];let o,l;a.equals1(i.center)?o=new le(i.center,a):Math.abs(i.sweepAngle)<1e-4?o=new le(i.start(),a):(o=ye.build4(i.start(),a,i.center,i.rx,i.ry,i.sweep()),o instanceof ye&&o.sweepAngle===0&&(o=new le(o.start(),o.end()))),this.rawOffsetPrimitive.push(o),a.equals1(r.center)?l=new le(a,r.center):Math.abs(r.sweepAngle)<1e-4?l=new le(a,r.end()):(l=ye.build4(a,r.end(),r.center,r.rx,r.ry,r.sweep()),l instanceof ye&&l.sweepAngle===0&&(l=new le(l.start(),l.end()))),this.updateNextOffsetPrimitive(t.index,l)}else{let n=this.originalPrimitive[e.index],a=this.originalPrimitive[t.index],o=this.rxChangeStatus(n.sweep()),l=this.rxChangeStatus(a.sweep()),h=this.originalPrimitive[t.index].start(),c=this.getSweep(h,i,e.index),d=Math.abs(this.offsetDistance),f=ye.build2(h,o?n.endAngle():n.endAngle()+180,l?a.startAngle:a.startAngle+180,d,d,c);this.rawOffsetPrimitive.push(i),this.rawOffsetPrimitive.push(f)}}};lf.originalPrimitive=[],lf.offsetPrimitive=[],lf.rawOffsetPrimitive=[],lf.testI=0;var rz=class hf extends gf{constructor(t,i,r,s,n,a){if(super(),i<0||r<0)throw new Error("The width and height of rect can't be less than 0!");this.leftUpPoint=t,this.width=i,this.height=r,this.angle=s,this.isCCW=n,this.radius=Math.min(Math.max(a,0),i/2,r/2)}get radiusRatio(){return this.radius/Math.min(this.width,this.height)}start(){return this.leftUpPoint.add(new ae(this.radius,0).multiply3(ci.rotateD(this.angle)))}end(){return this.start()}getLeftPoint(){return this.leftUpPoint.add(new ae(0,-this.height/2).multiply3(ci.rotateD(this.angle)))}getRightPoint(){return this.leftUpPoint.add(new ae(this.width,-this.height/2).multiply3(ci.rotateD(this.angle)))}extend(t){return new hf(this.leftUpPoint.add(new ae(-t,t).rotateD(ae.ORIGIN,this.angle)),this.width+t*2,this.height+t*2,this.angle,this.isCCW,this.radius+t)}bbox(){let t=ci.rotateD(this.angle),{leftUpPoint:i,width:r,height:s,radius:n}=this,a=i.add(new ae(n,-n).multiply3(t)),o=i.add(new ae(n,n-s).multiply3(t)),l=i.add(new ae(r-n,-n).multiply3(t)),h=i.add(new ae(r-n,n-s).multiply3(t));return new Pi(Math.min(a.x,o.x,l.x,h.x)-n,Math.max(a.x,o.x,l.x,h.x)+n,Math.min(a.y,o.y,l.y,h.y)-n,Math.max(a.y,o.y,l.y,h.y)+n)}toPolyline(){let t=[],{leftUpPoint:i,width:r,height:s,radius:n}=this;if(n===0){let o=ae.ORIGIN,l=new ae(r,0),h=new ae(r,-s),c=new ae(0,-s);t.push(new le(o,l),new le(l,h),new le(h,c),new le(c,o))}else{let o=new ae(0,-n),l=new ae(n,0),h=new ae(r-n,0),c=new ae(r,-n),d=new ae(r,n-s),f=new ae(r-n,-s),u=new ae(n,-s),p=new ae(0,n-s);t.push(ye.build1(o,l,n,n,!1,0),new le(l,h),ye.build1(h,c,n,n,!1,0),new le(c,d),ye.build1(d,f,n,n,!1,0),new le(f,u),ye.build1(u,p,n,n,!1,0),new le(p,o))}t=t.filter(o=>!o.start().equals1(o.end())),this.isCCW&&(t.forEach((o,l)=>t[l]=o.reverse()),t.reverse());let a=ci.rotateD(this.angle).translate1(i);return It.build2(t.map(o=>o.multiply3(a)))}center(){return this.leftUpPoint.add1(this.width/2,this.height/2).rotateD(this.leftUpPoint,this.angle)}multiply3(t){let i=this.leftUpPoint.multiply3(t),r=new ae(this.width,0).multiply3(ci.rotateD(this.angle)).multiply3(t),s=new ae(0,-this.height).multiply3(ci.rotateD(this.angle)).multiply3(t);return t.isMirrored()?new hf(i,s.length(),r.length(),s.angleD(ae.ORIGIN),this.isCCW===1?0:1,this.radius*r.length()/this.width):new hf(i,r.length(),s.length(),r.angleD(ae.ORIGIN),this.isCCW,this.radius*r.length()/this.width)}reverse(){return new hf(this.leftUpPoint,this.width,this.height,this.angle,this.isCCW===1?0:1,this.radius)}stroke(t,i,r){let s=this.stroke1(t,i,r);if(s.length===1)return s[0];{let[n,a]=s;return It.build2(n.primitives.concat(new le(n.primitives[0].start(),a.primitives[0].start()),a.primitives,new le(a.primitives[0].start(),n.primitives[0].start())))}}stroke1(t,i,r){let s=r===this.isCCW?this:this.reverse(),n=t/2,a=Math.min(s.width,s.height)/2,o=s.extend(n).toPolyline();return a<=n?[o]:[o,s.extend(-n).toPolyline().reverse()]}points(t){let i=this.toPolyline(),r=[];return i.points(t,s=>r.push(s)),r}toBezier(){throw new Error("Method not implemented.")}},sz=.01,or=class Wn{static simplify(t){return t=ol(t),t?new Wn([t]):null}static buildByStroke(t,i,r=1,s=bb,n){if(t instanceof ye&&(t.rx<i/2+sz||Math.abs(t.sweepAngle)>180&&ve.lesseq(t.start().distance1(t.end()),i))){let o=sS(t.stroke(i,r,0),n);if(o.length===0)return null;if(o.length===1)return new Wn(o);let l=[null],h=Number.POSITIVE_INFINITY;return o.forEach(c=>{let d=c.area(.1);d<0?d<h&&(l[0]=c,h=d):l.push(c)}),new Wn(l)}else if(t instanceof rz){let o=t.stroke1(i,r,0).map(l=>ol(l));return o[0]?o[1]?new Wn(o):new Wn([o[0]]):null}let a=t.stroke(i,r,0,s);return a?this.simplify(a):null}static buildCircle(t,i){return this.simplify(It.build7([ye.buildCircle(t,i,0)]))}static buildRect(t){return this.simplify(t.toPolyline())}static buildBBox(t){return this.simplify(It.buildBBox(t,0))}constructor(t){this.items=t.slice()}multiply3(t){return new Wn(this.items.map(i=>i.multiply3(t)))}bbox(){return this.items[0].bbox()}isEqual(t){return t instanceof Wn?this.items.every(i=>t.items.some(r=>r.isEqual(i))):!1}getOutMostPolyline(){return this.items[0]}extend(t,i){if(this.items.length!==1)throw new Error("this.items.length !== 1");if(t===0)return new bi([this]);let r=this.items[0],s=[];for(let c of r.primitives)if(c instanceof le)s.push(c);else if(c instanceof ye&&c.rx===c.ry)a(c);else if(c instanceof Ye)n(c);else throw new Error("not support!");r=It.build7(s);function n(c){let d=c.points(.1);for(let f=0;f<d.length-1;f++){let u=d[f],p=d[f+1];s.push(new le(u,p))}}function a(c){if(Math.abs(c.sweepAngle)>270){let d=c.sweepAngle/2;a(ye.build3(c.center,c.startAngle,d,c.rx,c.ry)),a(ye.build3(c.center,c.startAngle+d,d,c.rx,c.ry))}else s.push(c)}let o=[],l=[];lf.getExtendPolyLine(r,t,!0,i).forEach(c=>{(c.area(.1)>0?l:o).push(c)});let h;if(o.length===1)l.forEach(c=>o.push(c)),h=new bi([new Wn(o)]);else if(o.length===0)console.warn("outlines.length === 0"),h=new bi([]);else if(l.length===0)h=new bi(o.map(c=>new Wn([c])));else{let c=o.map(d=>[d]);l.forEach(d=>{let f=[],u=d.bbox();if(c.forEach(p=>{p[0].bbox().isContainsBBox1(u)&&f.push(p)}),f.length===1)f[0].push(d);else{if(f.length===0)throw new Error("inPlsArr.length === 0");for(let p of f.sort((g,_)=>g[0].bbox().area()-_[0].bbox().area()))if(p[0].getWindingNum(d.start())===-1){p.push(d);break}}}),h=new bi(c.map(d=>new Wn(d)))}return h}toPolylineGroup(){return new yb(this.items)}};var nz=Object.create,vI=Object.defineProperty,az=Object.getOwnPropertyDescriptor,oz=Object.getOwnPropertyNames,lz=Object.getPrototypeOf,hz=Object.prototype.hasOwnProperty,So=(e=>typeof dr<"u"?dr:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof dr<"u"?dr:t)[i]}):e)(function(e){if(typeof dr<"u")return dr.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cz=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oz(t))!hz.call(e,s)&&s!==i&&vI(e,s,{get:()=>t[s],enumerable:!(r=az(t,s))||r.enumerable});return e},xI=(e,t,i)=>(i=e!=null?nz(lz(e)):{},cz(t||!e||!e.__esModule?vI(i,"default",{value:e,enumerable:!0}):i,e)),xO=st((e,t)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?t.exports={nextTick:i}:t.exports=process;function i(r,s,n,a){if(typeof r!="function")throw new TypeError('"callback" argument must be a function');var o=arguments.length,l,h;switch(o){case 0:case 1:return process.nextTick(r);case 2:return process.nextTick(function(){r.call(null,s)});case 3:return process.nextTick(function(){r.call(null,s,n)});case 4:return process.nextTick(function(){r.call(null,s,n,a)});default:for(l=new Array(o-1),h=0;h<l.length;)l[h++]=arguments[h];return process.nextTick(function(){r.apply(null,l)})}}}),uz=st((e,t)=>{var i={}.toString;t.exports=Array.isArray||function(r){return i.call(r)=="[object Array]"}}),EI=st((e,t)=>{t.exports=So("stream")}),EO=st((e,t)=>{var i=So("buffer"),r=i.Buffer;function s(a,o){for(var l in a)o[l]=a[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=n);function n(a,o,l){return r(a,o,l)}s(r,n),n.from=function(a,o,l){if(typeof a=="number")throw new TypeError("Argument must not be a number");return r(a,o,l)},n.alloc=function(a,o,l){if(typeof a!="number")throw new TypeError("Argument must be a number");var h=r(a);return o!==void 0?typeof l=="string"?h.fill(o,l):h.fill(o):h.fill(0),h},n.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r(a)},n.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i.SlowBuffer(a)}}),Df=st(e=>{function t(_){return Array.isArray?Array.isArray(_):g(_)==="[object Array]"}e.isArray=t;function i(_){return typeof _=="boolean"}e.isBoolean=i;function r(_){return _===null}e.isNull=r;function s(_){return _==null}e.isNullOrUndefined=s;function n(_){return typeof _=="number"}e.isNumber=n;function a(_){return typeof _=="string"}e.isString=a;function o(_){return typeof _=="symbol"}e.isSymbol=o;function l(_){return _===void 0}e.isUndefined=l;function h(_){return g(_)==="[object RegExp]"}e.isRegExp=h;function c(_){return typeof _=="object"&&_!==null}e.isObject=c;function d(_){return g(_)==="[object Date]"}e.isDate=d;function f(_){return g(_)==="[object Error]"||_ instanceof Error}e.isError=f;function u(_){return typeof _=="function"}e.isFunction=u;function p(_){return _===null||typeof _=="boolean"||typeof _=="number"||typeof _=="string"||typeof _=="symbol"||typeof _>"u"}e.isPrimitive=p,e.isBuffer=So("buffer").Buffer.isBuffer;function g(_){return Object.prototype.toString.call(_)}}),dz=st((e,t)=>{typeof Object.create=="function"?t.exports=function(i,r){r&&(i.super_=r,i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(i,r){if(r){i.super_=r;var s=function(){};s.prototype=r.prototype,i.prototype=new s,i.prototype.constructor=i}}}),Rf=st((e,t)=>{try{if(i=So("util"),typeof i.inherits!="function")throw"";t.exports=i.inherits}catch{t.exports=dz()}var i}),fz=st((e,t)=>{"use strict";function i(a,o){if(!(a instanceof o))throw new TypeError("Cannot call a class as a function")}var r=EO().Buffer,s=So("util");function n(a,o,l){a.copy(o,l)}t.exports=(function(){function a(){i(this,a),this.head=null,this.tail=null,this.length=0}return a.prototype.push=function(o){var l={data:o,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length},a.prototype.unshift=function(o){var l={data:o,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length},a.prototype.shift=function(){if(this.length!==0){var o=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,o}},a.prototype.clear=function(){this.head=this.tail=null,this.length=0},a.prototype.join=function(o){if(this.length===0)return"";for(var l=this.head,h=""+l.data;l=l.next;)h+=o+l.data;return h},a.prototype.concat=function(o){if(this.length===0)return r.alloc(0);for(var l=r.allocUnsafe(o>>>0),h=this.head,c=0;h;)n(h.data,l,c),c+=h.data.length,h=h.next;return l},a})(),s&&s.inspect&&s.inspect.custom&&(t.exports.prototype[s.inspect.custom]=function(){var a=s.inspect({length:this.length});return this.constructor.name+" "+a})}),wI=st((e,t)=>{"use strict";var i=xO();function r(a,o){var l=this,h=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return h||c?(o?o(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(n,this,a)):i.nextTick(n,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(d){!o&&d?l._writableState?l._writableState.errorEmitted||(l._writableState.errorEmitted=!0,i.nextTick(n,l,d)):i.nextTick(n,l,d):o&&o(d)}),this)}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function n(a,o){a.emit("error",o)}t.exports={destroy:r,undestroy:s}}),pz=st((e,t)=>{t.exports=So("util").deprecate}),TI=st((e,t)=>{"use strict";var i=xO();t.exports=y;function r(I){var S=this;this.next=null,this.entry=null,this.finish=function(){x(S,I)}}var s=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:i.nextTick,n;y.WritableState=g;var a=Object.create(Df());a.inherits=Rf();var o={deprecate:pz()},l=EI(),h=EO().Buffer,c=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function d(I){return h.from(I)}function f(I){return h.isBuffer(I)||I instanceof c}var u=wI();a.inherits(y,l);function p(){}function g(I,S){n=n||_u(),I=I||{};var D=S instanceof n;this.objectMode=!!I.objectMode,D&&(this.objectMode=this.objectMode||!!I.writableObjectMode);var N=I.highWaterMark,G=I.writableHighWaterMark,z=this.objectMode?16:16*1024;N||N===0?this.highWaterMark=N:D&&(G||G===0)?this.highWaterMark=G:this.highWaterMark=z,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Z=I.decodeStrings===!1;this.decodeStrings=!Z,this.defaultEncoding=I.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(se){A(S,se)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}g.prototype.getBuffer=function(){for(var I=this.bufferedRequest,S=[];I;)S.push(I),I=I.next;return S},(function(){try{Object.defineProperty(g.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var _;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(_=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(I){return _.call(this,I)?!0:this!==y?!1:I&&I._writableState instanceof g}})):_=function(I){return I instanceof this};function y(I){if(n=n||_u(),!_.call(y,this)&&!(this instanceof n))return new y(I);this._writableState=new g(I,this),this.writable=!0,I&&(typeof I.write=="function"&&(this._write=I.write),typeof I.writev=="function"&&(this._writev=I.writev),typeof I.destroy=="function"&&(this._destroy=I.destroy),typeof I.final=="function"&&(this._final=I.final)),l.call(this)}y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function m(I,S){var D=new Error("write after end");I.emit("error",D),i.nextTick(S,D)}function O(I,S,D,N){var G=!0,z=!1;return D===null?z=new TypeError("May not write null values to stream"):typeof D!="string"&&D!==void 0&&!S.objectMode&&(z=new TypeError("Invalid non-string/buffer chunk")),z&&(I.emit("error",z),i.nextTick(N,z),G=!1),G}y.prototype.write=function(I,S,D){var N=this._writableState,G=!1,z=!N.objectMode&&f(I);return z&&!h.isBuffer(I)&&(I=d(I)),typeof S=="function"&&(D=S,S=null),z?S="buffer":S||(S=N.defaultEncoding),typeof D!="function"&&(D=p),N.ended?m(this,D):(z||O(this,N,I,D))&&(N.pendingcb++,G=v(this,N,z,I,S,D)),G},y.prototype.cork=function(){var I=this._writableState;I.corked++},y.prototype.uncork=function(){var I=this._writableState;I.corked&&(I.corked--,!I.writing&&!I.corked&&!I.bufferProcessing&&I.bufferedRequest&&H(this,I))},y.prototype.setDefaultEncoding=function(I){if(typeof I=="string"&&(I=I.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((I+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+I);return this._writableState.defaultEncoding=I,this};function b(I,S,D){return!I.objectMode&&I.decodeStrings!==!1&&typeof S=="string"&&(S=h.from(S,D)),S}Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function v(I,S,D,N,G,z){if(!D){var Z=b(S,N,G);N!==Z&&(D=!0,G="buffer",N=Z)}var se=S.objectMode?1:N.length;S.length+=se;var he=S.length<S.highWaterMark;if(he||(S.needDrain=!0),S.writing||S.corked){var pe=S.lastBufferedRequest;S.lastBufferedRequest={chunk:N,encoding:G,isBuf:D,callback:z,next:null},pe?pe.next=S.lastBufferedRequest:S.bufferedRequest=S.lastBufferedRequest,S.bufferedRequestCount+=1}else E(I,S,!1,se,N,G,z);return he}function E(I,S,D,N,G,z,Z){S.writelen=N,S.writecb=Z,S.writing=!0,S.sync=!0,D?I._writev(G,S.onwrite):I._write(G,z,S.onwrite),S.sync=!1}function T(I,S,D,N,G){--S.pendingcb,D?(i.nextTick(G,N),i.nextTick(L,I,S),I._writableState.errorEmitted=!0,I.emit("error",N)):(G(N),I._writableState.errorEmitted=!0,I.emit("error",N),L(I,S))}function P(I){I.writing=!1,I.writecb=null,I.length-=I.writelen,I.writelen=0}function A(I,S){var D=I._writableState,N=D.sync,G=D.writecb;if(P(D),S)T(I,D,N,S,G);else{var z=k(D);!z&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&H(I,D),N?s(C,I,D,z,G):C(I,D,z,G)}}function C(I,S,D,N){D||M(I,S),S.pendingcb--,N(),L(I,S)}function M(I,S){S.length===0&&S.needDrain&&(S.needDrain=!1,I.emit("drain"))}function H(I,S){S.bufferProcessing=!0;var D=S.bufferedRequest;if(I._writev&&D&&D.next){var N=S.bufferedRequestCount,G=new Array(N),z=S.corkedRequestsFree;z.entry=D;for(var Z=0,se=!0;D;)G[Z]=D,D.isBuf||(se=!1),D=D.next,Z+=1;G.allBuffers=se,E(I,S,!0,S.length,G,"",z.finish),S.pendingcb++,S.lastBufferedRequest=null,z.next?(S.corkedRequestsFree=z.next,z.next=null):S.corkedRequestsFree=new r(S),S.bufferedRequestCount=0}else{for(;D;){var he=D.chunk,pe=D.encoding,Se=D.callback,q=S.objectMode?1:he.length;if(E(I,S,!1,q,he,pe,Se),D=D.next,S.bufferedRequestCount--,S.writing)break}D===null&&(S.lastBufferedRequest=null)}S.bufferedRequest=D,S.bufferProcessing=!1}y.prototype._write=function(I,S,D){D(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(I,S,D){var N=this._writableState;typeof I=="function"?(D=I,I=null,S=null):typeof S=="function"&&(D=S,S=null),I!=null&&this.write(I,S),N.corked&&(N.corked=1,this.uncork()),N.ending||R(this,N,D)};function k(I){return I.ending&&I.length===0&&I.bufferedRequest===null&&!I.finished&&!I.writing}function F(I,S){I._final(function(D){S.pendingcb--,D&&I.emit("error",D),S.prefinished=!0,I.emit("prefinish"),L(I,S)})}function j(I,S){!S.prefinished&&!S.finalCalled&&(typeof I._final=="function"?(S.pendingcb++,S.finalCalled=!0,i.nextTick(F,I,S)):(S.prefinished=!0,I.emit("prefinish")))}function L(I,S){var D=k(S);return D&&(j(I,S),S.pendingcb===0&&(S.finished=!0,I.emit("finish"))),D}function R(I,S,D){S.ending=!0,L(I,S),D&&(S.finished?i.nextTick(D):I.once("finish",D)),S.ended=!0,I.writable=!1}function x(I,S,D){var N=I.entry;for(I.entry=null;N;){var G=N.callback;S.pendingcb--,G(D),N=N.next}S.corkedRequestsFree.next=I}Object.defineProperty(y.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(I){this._writableState&&(this._writableState.destroyed=I)}}),y.prototype.destroy=u.destroy,y.prototype._undestroy=u.undestroy,y.prototype._destroy=function(I,S){this.end(),S(I)}}),_u=st((e,t)=>{"use strict";var i=xO(),r=Object.keys||function(u){var p=[];for(var g in u)p.push(g);return p};t.exports=c;var s=Object.create(Df());s.inherits=Rf();var n=SI(),a=TI();for(s.inherits(c,n),o=r(a.prototype),h=0;h<o.length;h++)l=o[h],c.prototype[l]||(c.prototype[l]=a.prototype[l]);var o,l,h;function c(u){if(!(this instanceof c))return new c(u);n.call(this,u),a.call(this,u),u&&u.readable===!1&&(this.readable=!1),u&&u.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,u&&u.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",d)}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function d(){this.allowHalfOpen||this._writableState.ended||i.nextTick(f,this)}function f(u){u.end()}Object.defineProperty(c.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(u){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=u,this._writableState.destroyed=u)}}),c.prototype._destroy=function(u,p){this.push(null),this.end(),i.nextTick(p,u)}}),aS=st(e=>{"use strict";var t=EO().Buffer,i=t.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(m){if(!m)return"utf8";for(var O;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(O)return;m=(""+m).toLowerCase(),O=!0}}function s(m){var O=r(m);if(typeof O!="string"&&(t.isEncoding===i||!i(m)))throw new Error("Unknown encoding: "+m);return O||m}e.StringDecoder=n;function n(m){this.encoding=s(m);var O;switch(this.encoding){case"utf16le":this.text=f,this.end=u,O=4;break;case"utf8":this.fillLast=h,O=4;break;case"base64":this.text=p,this.end=g,O=3;break;default:this.write=_,this.end=y;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(O)}n.prototype.write=function(m){if(m.length===0)return"";var O,b;if(this.lastNeed){if(O=this.fillLast(m),O===void 0)return"";b=this.lastNeed,this.lastNeed=0}else b=0;return b<m.length?O?O+this.text(m,b):this.text(m,b):O||""},n.prototype.end=d,n.prototype.text=c,n.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function a(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function o(m,O,b){var v=O.length-1;if(v<b)return 0;var E=a(O[v]);return E>=0?(E>0&&(m.lastNeed=E-1),E):--v<b||E===-2?0:(E=a(O[v]),E>=0?(E>0&&(m.lastNeed=E-2),E):--v<b||E===-2?0:(E=a(O[v]),E>=0?(E>0&&(E===2?E=0:m.lastNeed=E-3),E):0))}function l(m,O,b){if((O[0]&192)!==128)return m.lastNeed=0,"\uFFFD";if(m.lastNeed>1&&O.length>1){if((O[1]&192)!==128)return m.lastNeed=1,"\uFFFD";if(m.lastNeed>2&&O.length>2&&(O[2]&192)!==128)return m.lastNeed=2,"\uFFFD"}}function h(m){var O=this.lastTotal-this.lastNeed,b=l(this,m,O);if(b!==void 0)return b;if(this.lastNeed<=m.length)return m.copy(this.lastChar,O,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,O,0,m.length),this.lastNeed-=m.length}function c(m,O){var b=o(this,m,O);if(!this.lastNeed)return m.toString("utf8",O);this.lastTotal=b;var v=m.length-(b-this.lastNeed);return m.copy(this.lastChar,0,v),m.toString("utf8",O,v)}function d(m){var O=m&&m.length?this.write(m):"";return this.lastNeed?O+"\uFFFD":O}function f(m,O){if((m.length-O)%2===0){var b=m.toString("utf16le",O);if(b){var v=b.charCodeAt(b.length-1);if(v>=55296&&v<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],b.slice(0,-1)}return b}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",O,m.length-1)}function u(m){var O=m&&m.length?this.write(m):"";if(this.lastNeed){var b=this.lastTotal-this.lastNeed;return O+this.lastChar.toString("utf16le",0,b)}return O}function p(m,O){var b=(m.length-O)%3;return b===0?m.toString("base64",O):(this.lastNeed=3-b,this.lastTotal=3,b===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",O,m.length-b))}function g(m){var O=m&&m.length?this.write(m):"";return this.lastNeed?O+this.lastChar.toString("base64",0,3-this.lastNeed):O}function _(m){return m.toString(this.encoding)}function y(m){return m&&m.length?this.write(m):""}}),SI=st((e,t)=>{"use strict";var i=xO();t.exports=v;var r=uz(),s;v.ReadableState=b;var n=So("events").EventEmitter,a=function(q,X){return q.listeners(X).length},o=EI(),l=EO().Buffer,h=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(q){return l.from(q)}function d(q){return l.isBuffer(q)||q instanceof h}var f=Object.create(Df());f.inherits=Rf();var u=So("util"),p=void 0;u&&u.debuglog?p=u.debuglog("stream"):p=function(){};var g=fz(),_=wI(),y;f.inherits(v,o);var m=["error","close","destroy","pause","resume"];function O(q,X,ie){if(typeof q.prependListener=="function")return q.prependListener(X,ie);!q._events||!q._events[X]?q.on(X,ie):r(q._events[X])?q._events[X].unshift(ie):q._events[X]=[ie,q._events[X]]}function b(q,X){s=s||_u(),q=q||{};var ie=X instanceof s;this.objectMode=!!q.objectMode,ie&&(this.objectMode=this.objectMode||!!q.readableObjectMode);var de=q.highWaterMark,Ce=q.readableHighWaterMark,De=this.objectMode?16:16*1024;de||de===0?this.highWaterMark=de:ie&&(Ce||Ce===0)?this.highWaterMark=Ce:this.highWaterMark=De,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=q.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,q.encoding&&(y||(y=aS().StringDecoder),this.decoder=new y(q.encoding),this.encoding=q.encoding)}function v(q){if(s=s||_u(),!(this instanceof v))return new v(q);this._readableState=new b(q,this),this.readable=!0,q&&(typeof q.read=="function"&&(this._read=q.read),typeof q.destroy=="function"&&(this._destroy=q.destroy)),o.call(this)}Object.defineProperty(v.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(q){this._readableState&&(this._readableState.destroyed=q)}}),v.prototype.destroy=_.destroy,v.prototype._undestroy=_.undestroy,v.prototype._destroy=function(q,X){this.push(null),X(q)},v.prototype.push=function(q,X){var ie=this._readableState,de;return ie.objectMode?de=!0:typeof q=="string"&&(X=X||ie.defaultEncoding,X!==ie.encoding&&(q=l.from(q,X),X=""),de=!0),E(this,q,X,!1,de)},v.prototype.unshift=function(q){return E(this,q,null,!0,!1)};function E(q,X,ie,de,Ce){var De=q._readableState;if(X===null)De.reading=!1,k(q,De);else{var Fe;Ce||(Fe=P(De,X)),Fe?q.emit("error",Fe):De.objectMode||X&&X.length>0?(typeof X!="string"&&!De.objectMode&&Object.getPrototypeOf(X)!==l.prototype&&(X=c(X)),de?De.endEmitted?q.emit("error",new Error("stream.unshift() after end event")):T(q,De,X,!0):De.ended?q.emit("error",new Error("stream.push() after EOF")):(De.reading=!1,De.decoder&&!ie?(X=De.decoder.write(X),De.objectMode||X.length!==0?T(q,De,X,!1):L(q,De)):T(q,De,X,!1))):de||(De.reading=!1)}return A(De)}function T(q,X,ie,de){X.flowing&&X.length===0&&!X.sync?(q.emit("data",ie),q.read(0)):(X.length+=X.objectMode?1:ie.length,de?X.buffer.unshift(ie):X.buffer.push(ie),X.needReadable&&F(q)),L(q,X)}function P(q,X){var ie;return!d(X)&&typeof X!="string"&&X!==void 0&&!q.objectMode&&(ie=new TypeError("Invalid non-string/buffer chunk")),ie}function A(q){return!q.ended&&(q.needReadable||q.length<q.highWaterMark||q.length===0)}v.prototype.isPaused=function(){return this._readableState.flowing===!1},v.prototype.setEncoding=function(q){return y||(y=aS().StringDecoder),this._readableState.decoder=new y(q),this._readableState.encoding=q,this};var C=8388608;function M(q){return q>=C?q=C:(q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++),q}function H(q,X){return q<=0||X.length===0&&X.ended?0:X.objectMode?1:q!==q?X.flowing&&X.length?X.buffer.head.data.length:X.length:(q>X.highWaterMark&&(X.highWaterMark=M(q)),q<=X.length?q:X.ended?X.length:(X.needReadable=!0,0))}v.prototype.read=function(q){p("read",q),q=parseInt(q,10);var X=this._readableState,ie=q;if(q!==0&&(X.emittedReadable=!1),q===0&&X.needReadable&&(X.length>=X.highWaterMark||X.ended))return p("read: emitReadable",X.length,X.ended),X.length===0&&X.ended?he(this):F(this),null;if(q=H(q,X),q===0&&X.ended)return X.length===0&&he(this),null;var de=X.needReadable;p("need readable",de),(X.length===0||X.length-q<X.highWaterMark)&&(de=!0,p("length less than watermark",de)),X.ended||X.reading?(de=!1,p("reading or ended",de)):de&&(p("do read"),X.reading=!0,X.sync=!0,X.length===0&&(X.needReadable=!0),this._read(X.highWaterMark),X.sync=!1,X.reading||(q=H(ie,X)));var Ce;return q>0?Ce=G(q,X):Ce=null,Ce===null?(X.needReadable=!0,q=0):X.length-=q,X.length===0&&(X.ended||(X.needReadable=!0),ie!==q&&X.ended&&he(this)),Ce!==null&&this.emit("data",Ce),Ce};function k(q,X){if(!X.ended){if(X.decoder){var ie=X.decoder.end();ie&&ie.length&&(X.buffer.push(ie),X.length+=X.objectMode?1:ie.length)}X.ended=!0,F(q)}}function F(q){var X=q._readableState;X.needReadable=!1,X.emittedReadable||(p("emitReadable",X.flowing),X.emittedReadable=!0,X.sync?i.nextTick(j,q):j(q))}function j(q){p("emit readable"),q.emit("readable"),N(q)}function L(q,X){X.readingMore||(X.readingMore=!0,i.nextTick(R,q,X))}function R(q,X){for(var ie=X.length;!X.reading&&!X.flowing&&!X.ended&&X.length<X.highWaterMark&&(p("maybeReadMore read 0"),q.read(0),ie!==X.length);)ie=X.length;X.readingMore=!1}v.prototype._read=function(q){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(q,X){var ie=this,de=this._readableState;switch(de.pipesCount){case 0:de.pipes=q;break;case 1:de.pipes=[de.pipes,q];break;default:de.pipes.push(q);break}de.pipesCount+=1,p("pipe count=%d opts=%j",de.pipesCount,X);var Ce=(!X||X.end!==!1)&&q!==process.stdout&&q!==process.stderr,De=Ce?Pe:Ue;de.endEmitted?i.nextTick(De):ie.once("end",De),q.on("unpipe",Fe);function Fe(je,dt){p("onunpipe"),je===ie&&dt&&dt.hasUnpiped===!1&&(dt.hasUnpiped=!0,V())}function Pe(){p("onend"),q.end()}var w=x(ie);q.on("drain",w);var B=!1;function V(){p("cleanup"),q.removeListener("close",ue),q.removeListener("finish",Re),q.removeListener("drain",w),q.removeListener("error",ne),q.removeListener("unpipe",Fe),ie.removeListener("end",Pe),ie.removeListener("end",Ue),ie.removeListener("data",W),B=!0,de.awaitDrain&&(!q._writableState||q._writableState.needDrain)&&w()}var Y=!1;ie.on("data",W);function W(je){p("ondata"),Y=!1;var dt=q.write(je);dt===!1&&!Y&&((de.pipesCount===1&&de.pipes===q||de.pipesCount>1&&Se(de.pipes,q)!==-1)&&!B&&(p("false write response, pause",de.awaitDrain),de.awaitDrain++,Y=!0),ie.pause())}function ne(je){p("onerror",je),Ue(),q.removeListener("error",ne),a(q,"error")===0&&q.emit("error",je)}O(q,"error",ne);function ue(){q.removeListener("finish",Re),Ue()}q.once("close",ue);function Re(){p("onfinish"),q.removeListener("close",ue),Ue()}q.once("finish",Re);function Ue(){p("unpipe"),ie.unpipe(q)}return q.emit("pipe",ie),de.flowing||(p("pipe resume"),ie.resume()),q};function x(q){return function(){var X=q._readableState;p("pipeOnDrain",X.awaitDrain),X.awaitDrain&&X.awaitDrain--,X.awaitDrain===0&&a(q,"data")&&(X.flowing=!0,N(q))}}v.prototype.unpipe=function(q){var X=this._readableState,ie={hasUnpiped:!1};if(X.pipesCount===0)return this;if(X.pipesCount===1)return q&&q!==X.pipes?this:(q||(q=X.pipes),X.pipes=null,X.pipesCount=0,X.flowing=!1,q&&q.emit("unpipe",this,ie),this);if(!q){var de=X.pipes,Ce=X.pipesCount;X.pipes=null,X.pipesCount=0,X.flowing=!1;for(var De=0;De<Ce;De++)de[De].emit("unpipe",this,{hasUnpiped:!1});return this}var Fe=Se(X.pipes,q);return Fe===-1?this:(X.pipes.splice(Fe,1),X.pipesCount-=1,X.pipesCount===1&&(X.pipes=X.pipes[0]),q.emit("unpipe",this,ie),this)},v.prototype.on=function(q,X){var ie=o.prototype.on.call(this,q,X);if(q==="data")this._readableState.flowing!==!1&&this.resume();else if(q==="readable"){var de=this._readableState;!de.endEmitted&&!de.readableListening&&(de.readableListening=de.needReadable=!0,de.emittedReadable=!1,de.reading?de.length&&F(this):i.nextTick(I,this))}return ie},v.prototype.addListener=v.prototype.on;function I(q){p("readable nexttick read 0"),q.read(0)}v.prototype.resume=function(){var q=this._readableState;return q.flowing||(p("resume"),q.flowing=!0,S(this,q)),this};function S(q,X){X.resumeScheduled||(X.resumeScheduled=!0,i.nextTick(D,q,X))}function D(q,X){X.reading||(p("resume read 0"),q.read(0)),X.resumeScheduled=!1,X.awaitDrain=0,q.emit("resume"),N(q),X.flowing&&!X.reading&&q.read(0)}v.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function N(q){var X=q._readableState;for(p("flow",X.flowing);X.flowing&&q.read()!==null;);}v.prototype.wrap=function(q){var X=this,ie=this._readableState,de=!1;q.on("end",function(){if(p("wrapped end"),ie.decoder&&!ie.ended){var Fe=ie.decoder.end();Fe&&Fe.length&&X.push(Fe)}X.push(null)}),q.on("data",function(Fe){if(p("wrapped data"),ie.decoder&&(Fe=ie.decoder.write(Fe)),!(ie.objectMode&&Fe==null)&&!(!ie.objectMode&&(!Fe||!Fe.length))){var Pe=X.push(Fe);Pe||(de=!0,q.pause())}});for(var Ce in q)this[Ce]===void 0&&typeof q[Ce]=="function"&&(this[Ce]=(function(Fe){return function(){return q[Fe].apply(q,arguments)}})(Ce));for(var De=0;De<m.length;De++)q.on(m[De],this.emit.bind(this,m[De]));return this._read=function(Fe){p("wrapped _read",Fe),de&&(de=!1,q.resume())},this},Object.defineProperty(v.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),v._fromList=G;function G(q,X){if(X.length===0)return null;var ie;return X.objectMode?ie=X.buffer.shift():!q||q>=X.length?(X.decoder?ie=X.buffer.join(""):X.buffer.length===1?ie=X.buffer.head.data:ie=X.buffer.concat(X.length),X.buffer.clear()):ie=z(q,X.buffer,X.decoder),ie}function z(q,X,ie){var de;return q<X.head.data.length?(de=X.head.data.slice(0,q),X.head.data=X.head.data.slice(q)):q===X.head.data.length?de=X.shift():de=ie?Z(q,X):se(q,X),de}function Z(q,X){var ie=X.head,de=1,Ce=ie.data;for(q-=Ce.length;ie=ie.next;){var De=ie.data,Fe=q>De.length?De.length:q;if(Fe===De.length?Ce+=De:Ce+=De.slice(0,q),q-=Fe,q===0){Fe===De.length?(++de,ie.next?X.head=ie.next:X.head=X.tail=null):(X.head=ie,ie.data=De.slice(Fe));break}++de}return X.length-=de,Ce}function se(q,X){var ie=l.allocUnsafe(q),de=X.head,Ce=1;for(de.data.copy(ie),q-=de.data.length;de=de.next;){var De=de.data,Fe=q>De.length?De.length:q;if(De.copy(ie,ie.length-q,0,Fe),q-=Fe,q===0){Fe===De.length?(++Ce,de.next?X.head=de.next:X.head=X.tail=null):(X.head=de,de.data=De.slice(Fe));break}++Ce}return X.length-=Ce,ie}function he(q){var X=q._readableState;if(X.length>0)throw new Error('"endReadable()" called on non-empty stream');X.endEmitted||(X.ended=!0,i.nextTick(pe,X,q))}function pe(q,X){!q.endEmitted&&q.length===0&&(q.endEmitted=!0,X.readable=!1,X.emit("end"))}function Se(q,X){for(var ie=0,de=q.length;ie<de;ie++)if(q[ie]===X)return ie;return-1}}),II=st((e,t)=>{"use strict";t.exports=n;var i=_u(),r=Object.create(Df());r.inherits=Rf(),r.inherits(n,i);function s(l,h){var c=this._transformState;c.transforming=!1;var d=c.writecb;if(!d)return this.emit("error",new Error("write callback called multiple times"));c.writechunk=null,c.writecb=null,h!=null&&this.push(h),d(l);var f=this._readableState;f.reading=!1,(f.needReadable||f.length<f.highWaterMark)&&this._read(f.highWaterMark)}function n(l){if(!(this instanceof n))return new n(l);i.call(this,l),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,l&&(typeof l.transform=="function"&&(this._transform=l.transform),typeof l.flush=="function"&&(this._flush=l.flush)),this.on("prefinish",a)}function a(){var l=this;typeof this._flush=="function"?this._flush(function(h,c){o(l,h,c)}):o(this,null,null)}n.prototype.push=function(l,h){return this._transformState.needTransform=!1,i.prototype.push.call(this,l,h)},n.prototype._transform=function(l,h,c){throw new Error("_transform() is not implemented")},n.prototype._write=function(l,h,c){var d=this._transformState;if(d.writecb=c,d.writechunk=l,d.writeencoding=h,!d.transforming){var f=this._readableState;(d.needTransform||f.needReadable||f.length<f.highWaterMark)&&this._read(f.highWaterMark)}},n.prototype._read=function(l){var h=this._transformState;h.writechunk!==null&&h.writecb&&!h.transforming?(h.transforming=!0,this._transform(h.writechunk,h.writeencoding,h.afterTransform)):h.needTransform=!0},n.prototype._destroy=function(l,h){var c=this;i.prototype._destroy.call(this,l,function(d){h(d),c.emit("close")})};function o(l,h,c){if(h)return l.emit("error",h);if(c!=null&&l.push(c),l._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(l._transformState.transforming)throw new Error("Calling transform done when still transforming");return l.push(null)}}),gz=st((e,t)=>{"use strict";t.exports=s;var i=II(),r=Object.create(Df());r.inherits=Rf(),r.inherits(s,i);function s(n){if(!(this instanceof s))return new s(n);i.call(this,n)}s.prototype._transform=function(n,a,o){o(null,n)}}),PI=st((e,t)=>{var i=So("stream");process.env.READABLE_STREAM==="disable"&&i?(t.exports=i,e=t.exports=i.Readable,e.Readable=i.Readable,e.Writable=i.Writable,e.Duplex=i.Duplex,e.Transform=i.Transform,e.PassThrough=i.PassThrough,e.Stream=i):(e=t.exports=SI(),e.Stream=i||e,e.Readable=e,e.Writable=TI(),e.Duplex=_u(),e.Transform=II(),e.PassThrough=gz())}),pl=st(e=>{"use strict";if(e.base64=!0,e.array=!0,e.string=!0,e.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",e.nodebuffer=typeof Buffer<"u",e.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")e.blob=!1;else{t=new ArrayBuffer(0);try{e.blob=new Blob([t],{type:"application/zip"}).size===0}catch{try{i=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,r=new i,r.append(t),e.blob=r.getBlob("application/zip").size===0}catch{e.blob=!1}}}var t,i,r;try{e.nodestream=!!PI().Readable}catch{e.nodestream=!1}}),AI=st(e=>{"use strict";var t=hr(),i=pl(),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.encode=function(s){for(var n=[],a,o,l,h,c,d,f,u=0,p=s.length,g=p,_=t.getTypeOf(s)!=="string";u<s.length;)g=p-u,_?(a=s[u++],o=u<p?s[u++]:0,l=u<p?s[u++]:0):(a=s.charCodeAt(u++),o=u<p?s.charCodeAt(u++):0,l=u<p?s.charCodeAt(u++):0),h=a>>2,c=(a&3)<<4|o>>4,d=g>1?(o&15)<<2|l>>6:64,f=g>2?l&63:64,n.push(r.charAt(h)+r.charAt(c)+r.charAt(d)+r.charAt(f));return n.join("")},e.decode=function(s){var n,a,o,l,h,c,d,f=0,u=0,p="data:";if(s.substr(0,p.length)===p)throw new Error("Invalid base64 input, it looks like a data url.");s=s.replace(/[^A-Za-z0-9+/=]/g,"");var g=s.length*3/4;if(s.charAt(s.length-1)===r.charAt(64)&&g--,s.charAt(s.length-2)===r.charAt(64)&&g--,g%1!==0)throw new Error("Invalid base64 input, bad content length.");var _;for(i.uint8array?_=new Uint8Array(g|0):_=new Array(g|0);f<s.length;)l=r.indexOf(s.charAt(f++)),h=r.indexOf(s.charAt(f++)),c=r.indexOf(s.charAt(f++)),d=r.indexOf(s.charAt(f++)),n=l<<2|h>>4,a=(h&15)<<4|c>>2,o=(c&3)<<6|d,_[u++]=n,c!==64&&(_[u++]=a),d!==64&&(_[u++]=o);return _}}),wO=st((e,t)=>{"use strict";t.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,r);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,r)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var r=new Buffer(i);return r.fill(0),r},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}}),_z=st((e,t)=>{"use strict";var i=global.MutationObserver||global.WebKitMutationObserver,r;process.browser?i?(s=0,n=new i(c),a=global.document.createTextNode(""),n.observe(a,{characterData:!0}),r=function(){a.data=s=++s%2}):!global.setImmediate&&typeof global.MessageChannel<"u"?(o=new global.MessageChannel,o.port1.onmessage=c,r=function(){o.port2.postMessage(0)}):"document"in global&&"onreadystatechange"in global.document.createElement("script")?r=function(){var f=global.document.createElement("script");f.onreadystatechange=function(){c(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},global.document.documentElement.appendChild(f)}:r=function(){setTimeout(c,0)}:r=function(){process.nextTick(c)};var s,n,a,o,l,h=[];function c(){l=!0;for(var f,u,p=h.length;p;){for(u=h,h=[],f=-1;++f<p;)u[f]();p=h.length}l=!1}t.exports=d;function d(f){h.push(f)===1&&!l&&r()}}),Oz=st((e,t)=>{"use strict";var i=_z();function r(){}var s={},n=["REJECTED"],a=["FULFILLED"],o=["PENDING"];process.browser||(l=["UNHANDLED"]);var l;t.exports=h;function h(O){if(typeof O!="function")throw new TypeError("resolver must be a function");this.state=o,this.queue=[],this.outcome=void 0,process.browser||(this.handled=l),O!==r&&u(this,O)}h.prototype.finally=function(O){if(typeof O!="function")return this;var b=this.constructor;return this.then(v,E);function v(T){function P(){return T}return b.resolve(O()).then(P)}function E(T){function P(){throw T}return b.resolve(O()).then(P)}},h.prototype.catch=function(O){return this.then(null,O)},h.prototype.then=function(O,b){if(typeof O!="function"&&this.state===a||typeof b!="function"&&this.state===n)return this;var v=new this.constructor(r);if(process.browser||this.handled===l&&(this.handled=null),this.state!==o){var E=this.state===a?O:b;d(v,E,this.outcome)}else this.queue.push(new c(v,O,b));return v};function c(O,b,v){this.promise=O,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof v=="function"&&(this.onRejected=v,this.callRejected=this.otherCallRejected)}c.prototype.callFulfilled=function(O){s.resolve(this.promise,O)},c.prototype.otherCallFulfilled=function(O){d(this.promise,this.onFulfilled,O)},c.prototype.callRejected=function(O){s.reject(this.promise,O)},c.prototype.otherCallRejected=function(O){d(this.promise,this.onRejected,O)};function d(O,b,v){i(function(){var E;try{E=b(v)}catch(T){return s.reject(O,T)}E===O?s.reject(O,new TypeError("Cannot resolve promise with itself")):s.resolve(O,E)})}s.resolve=function(O,b){var v=p(f,b);if(v.status==="error")return s.reject(O,v.value);var E=v.value;if(E)u(O,E);else{O.state=a,O.outcome=b;for(var T=-1,P=O.queue.length;++T<P;)O.queue[T].callFulfilled(b)}return O},s.reject=function(O,b){O.state=n,O.outcome=b,process.browser||O.handled===l&&i(function(){O.handled===l&&process.emit("unhandledRejection",b,O)});for(var v=-1,E=O.queue.length;++v<E;)O.queue[v].callRejected(b);return O};function f(O){var b=O&&O.then;if(O&&(typeof O=="object"||typeof O=="function")&&typeof b=="function")return function(){b.apply(O,arguments)}}function u(O,b){var v=!1;function E(C){v||(v=!0,s.reject(O,C))}function T(C){v||(v=!0,s.resolve(O,C))}function P(){b(T,E)}var A=p(P);A.status==="error"&&E(A.value)}function p(O,b){var v={};try{v.value=O(b),v.status="success"}catch(E){v.status="error",v.value=E}return v}h.resolve=g;function g(O){return O instanceof this?O:s.resolve(new this(r),O)}h.reject=_;function _(O){var b=new this(r);return s.reject(b,O)}h.all=y;function y(O){var b=this;if(Object.prototype.toString.call(O)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=O.length,E=!1;if(!v)return this.resolve([]);for(var T=new Array(v),P=0,A=-1,C=new this(r);++A<v;)M(O[A],A);return C;function M(H,k){b.resolve(H).then(F,function(j){E||(E=!0,s.reject(C,j))});function F(j){T[k]=j,++P===v&&!E&&(E=!0,s.resolve(C,T))}}}h.race=m;function m(O){var b=this;if(Object.prototype.toString.call(O)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=O.length,E=!1;if(!v)return this.resolve([]);for(var T=-1,P=new this(r);++T<v;)A(O[T]);return P;function A(C){b.resolve(C).then(function(M){E||(E=!0,s.resolve(P,M))},function(M){E||(E=!0,s.reject(P,M))})}}}),Nf=st((e,t)=>{"use strict";var i=null;typeof Promise<"u"?i=Promise:i=Oz(),t.exports={Promise:i}}),mz=st(e=>{(function(t,i){"use strict";if(t.setImmediate)return;var r=1,s={},n=!1,a=t.document,o;function l(O){typeof O!="function"&&(O=new Function(""+O));for(var b=new Array(arguments.length-1),v=0;v<b.length;v++)b[v]=arguments[v+1];var E={callback:O,args:b};return s[r]=E,o(r),r++}function h(O){delete s[O]}function c(O){var b=O.callback,v=O.args;switch(v.length){case 0:b();break;case 1:b(v[0]);break;case 2:b(v[0],v[1]);break;case 3:b(v[0],v[1],v[2]);break;default:b.apply(i,v);break}}function d(O){if(n)setTimeout(d,0,O);else{var b=s[O];if(b){n=!0;try{c(b)}finally{h(O),n=!1}}}}function f(){o=function(O){process.nextTick(function(){d(O)})}}function u(){if(t.postMessage&&!t.importScripts){var O=!0,b=t.onmessage;return t.onmessage=function(){O=!1},t.postMessage("","*"),t.onmessage=b,O}}function p(){var O="setImmediate$"+Math.random()+"$",b=function(v){v.source===t&&typeof v.data=="string"&&v.data.indexOf(O)===0&&d(+v.data.slice(O.length))};t.addEventListener?t.addEventListener("message",b,!1):t.attachEvent("onmessage",b),o=function(v){t.postMessage(O+v,"*")}}function g(){var O=new MessageChannel;O.port1.onmessage=function(b){var v=b.data;d(v)},o=function(b){O.port2.postMessage(b)}}function _(){var O=a.documentElement;o=function(b){var v=a.createElement("script");v.onreadystatechange=function(){d(b),v.onreadystatechange=null,O.removeChild(v),v=null},O.appendChild(v)}}function y(){o=function(O){setTimeout(d,0,O)}}var m=Object.getPrototypeOf&&Object.getPrototypeOf(t);m=m&&m.setTimeout?m:t,{}.toString.call(t.process)==="[object process]"?f():u()?p():t.MessageChannel?g():a&&"onreadystatechange"in a.createElement("script")?_():y(),m.setImmediate=l,m.clearImmediate=h})(typeof self>"u"?typeof global>"u"?e:global:self)}),hr=st(e=>{"use strict";var t=pl(),i=AI(),r=wO(),s=Nf();mz();function n(f){var u=null;return t.uint8array?u=new Uint8Array(f.length):u=new Array(f.length),o(f,u)}e.newBlob=function(f,u){e.checkSupport("blob");try{return new Blob([f],{type:u})}catch{try{var p=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,g=new p;return g.append(f),g.getBlob(u)}catch{throw new Error("Bug : can't construct the Blob.")}}};function a(f){return f}function o(f,u){for(var p=0;p<f.length;++p)u[p]=f.charCodeAt(p)&255;return u}var l={stringifyByChunk:function(f,u,p){var g=[],_=0,y=f.length;if(y<=p)return String.fromCharCode.apply(null,f);for(;_<y;)u==="array"||u==="nodebuffer"?g.push(String.fromCharCode.apply(null,f.slice(_,Math.min(_+p,y)))):g.push(String.fromCharCode.apply(null,f.subarray(_,Math.min(_+p,y)))),_+=p;return g.join("")},stringifyByChar:function(f){for(var u="",p=0;p<f.length;p++)u+=String.fromCharCode(f[p]);return u},applyCanBeUsed:{uint8array:(function(){try{return t.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return t.nodebuffer&&String.fromCharCode.apply(null,r.allocBuffer(1)).length===1}catch{return!1}})()}};function h(f){var u=65536,p=e.getTypeOf(f),g=!0;if(p==="uint8array"?g=l.applyCanBeUsed.uint8array:p==="nodebuffer"&&(g=l.applyCanBeUsed.nodebuffer),g)for(;u>1;)try{return l.stringifyByChunk(f,p,u)}catch{u=Math.floor(u/2)}return l.stringifyByChar(f)}e.applyFromCharCode=h;function c(f,u){for(var p=0;p<f.length;p++)u[p]=f[p];return u}var d={};d.string={string:a,array:function(f){return o(f,new Array(f.length))},arraybuffer:function(f){return d.string.uint8array(f).buffer},uint8array:function(f){return o(f,new Uint8Array(f.length))},nodebuffer:function(f){return o(f,r.allocBuffer(f.length))}},d.array={string:h,array:a,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return r.newBufferFrom(f)}},d.arraybuffer={string:function(f){return h(new Uint8Array(f))},array:function(f){return c(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:a,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return r.newBufferFrom(new Uint8Array(f))}},d.uint8array={string:h,array:function(f){return c(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:a,nodebuffer:function(f){return r.newBufferFrom(f)}},d.nodebuffer={string:h,array:function(f){return c(f,new Array(f.length))},arraybuffer:function(f){return d.nodebuffer.uint8array(f).buffer},uint8array:function(f){return c(f,new Uint8Array(f.length))},nodebuffer:a},e.transformTo=function(f,u){if(u||(u=""),!f)return u;e.checkSupport(f);var p=e.getTypeOf(u),g=d[p][f](u);return g},e.resolve=function(f){for(var u=f.split("/"),p=[],g=0;g<u.length;g++){var _=u[g];_==="."||_===""&&g!==0&&g!==u.length-1||(_===".."?p.pop():p.push(_))}return p.join("/")},e.getTypeOf=function(f){if(typeof f=="string")return"string";if(Object.prototype.toString.call(f)==="[object Array]")return"array";if(t.nodebuffer&&r.isBuffer(f))return"nodebuffer";if(t.uint8array&&f instanceof Uint8Array)return"uint8array";if(t.arraybuffer&&f instanceof ArrayBuffer)return"arraybuffer"},e.checkSupport=function(f){var u=t[f.toLowerCase()];if(!u)throw new Error(f+" is not supported by this platform")},e.MAX_VALUE_16BITS=65535,e.MAX_VALUE_32BITS=-1,e.pretty=function(f){var u="",p,g;for(g=0;g<(f||"").length;g++)p=f.charCodeAt(g),u+="\\x"+(p<16?"0":"")+p.toString(16).toUpperCase();return u},e.delay=function(f,u,p){setImmediate(function(){f.apply(p||null,u||[])})},e.inherits=function(f,u){var p=function(){};p.prototype=u.prototype,f.prototype=new p},e.extend=function(){var f={},u,p;for(u=0;u<arguments.length;u++)for(p in arguments[u])Object.prototype.hasOwnProperty.call(arguments[u],p)&&typeof f[p]>"u"&&(f[p]=arguments[u][p]);return f},e.prepareContent=function(f,u,p,g,_){var y=s.Promise.resolve(u).then(function(m){var O=t.blob&&(m instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(m))!==-1);return O&&typeof FileReader<"u"?new s.Promise(function(b,v){var E=new FileReader;E.onload=function(T){b(T.target.result)},E.onerror=function(T){v(T.target.error)},E.readAsArrayBuffer(m)}):m});return y.then(function(m){var O=e.getTypeOf(m);return O?(O==="arraybuffer"?m=e.transformTo("uint8array",m):O==="string"&&(_?m=i.decode(m):p&&g!==!0&&(m=n(m))),m):s.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}}),Pn=st((e,t)=>{"use strict";function i(r){this.name=r||"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}i.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return this.isFinished?!1:(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,s){return this._listeners[r].push(s),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,s){if(this._listeners[r])for(var n=0;n<this._listeners[r].length;n++)this._listeners[r][n].call(this,s)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var s=this;return r.on("data",function(n){s.processChunk(n)}),r.on("end",function(){s.end()}),r.on("error",function(n){s.error(n)}),this},pause:function(){return this.isPaused||this.isFinished?!1:(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var r=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,s){return this.extraStreamInfo[r]=s,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},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 r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},t.exports=i}),Mf=st(e=>{"use strict";var t=hr(),i=pl(),r=wO(),s=Pn(),n=new Array(256);for(a=0;a<256;a++)n[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;var a;n[254]=n[254]=1;var o=function(f){var u,p,g,_,y,m=f.length,O=0;for(_=0;_<m;_++)p=f.charCodeAt(_),(p&64512)===55296&&_+1<m&&(g=f.charCodeAt(_+1),(g&64512)===56320&&(p=65536+(p-55296<<10)+(g-56320),_++)),O+=p<128?1:p<2048?2:p<65536?3:4;for(i.uint8array?u=new Uint8Array(O):u=new Array(O),y=0,_=0;y<O;_++)p=f.charCodeAt(_),(p&64512)===55296&&_+1<m&&(g=f.charCodeAt(_+1),(g&64512)===56320&&(p=65536+(p-55296<<10)+(g-56320),_++)),p<128?u[y++]=p:p<2048?(u[y++]=192|p>>>6,u[y++]=128|p&63):p<65536?(u[y++]=224|p>>>12,u[y++]=128|p>>>6&63,u[y++]=128|p&63):(u[y++]=240|p>>>18,u[y++]=128|p>>>12&63,u[y++]=128|p>>>6&63,u[y++]=128|p&63);return u},l=function(f,u){var p;for(u=u||f.length,u>f.length&&(u=f.length),p=u-1;p>=0&&(f[p]&192)===128;)p--;return p<0||p===0?u:p+n[f[p]]>u?p:u},h=function(f){var u,p,g,_,y=f.length,m=new Array(y*2);for(p=0,u=0;u<y;){if(g=f[u++],g<128){m[p++]=g;continue}if(_=n[g],_>4){m[p++]=65533,u+=_-1;continue}for(g&=_===2?31:_===3?15:7;_>1&&u<y;)g=g<<6|f[u++]&63,_--;if(_>1){m[p++]=65533;continue}g<65536?m[p++]=g:(g-=65536,m[p++]=55296|g>>10&1023,m[p++]=56320|g&1023)}return m.length!==p&&(m.subarray?m=m.subarray(0,p):m.length=p),t.applyFromCharCode(m)};e.utf8encode=function(f){return i.nodebuffer?r.newBufferFrom(f,"utf-8"):o(f)},e.utf8decode=function(f){return i.nodebuffer?t.transformTo("nodebuffer",f).toString("utf-8"):(f=t.transformTo(i.uint8array?"uint8array":"array",f),h(f))};function c(){s.call(this,"utf-8 decode"),this.leftOver=null}t.inherits(c,s),c.prototype.processChunk=function(f){var u=t.transformTo(i.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var p=u;u=new Uint8Array(p.length+this.leftOver.length),u.set(this.leftOver,0),u.set(p,this.leftOver.length)}else u=this.leftOver.concat(u);this.leftOver=null}var g=l(u),_=u;g!==u.length&&(i.uint8array?(_=u.subarray(0,g),this.leftOver=u.subarray(g,u.length)):(_=u.slice(0,g),this.leftOver=u.slice(g,u.length))),this.push({data:e.utf8decode(_),meta:f.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:e.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},e.Utf8DecodeWorker=c;function d(){s.call(this,"utf-8 encode")}t.inherits(d,s),d.prototype.processChunk=function(f){this.push({data:e.utf8encode(f.data),meta:f.meta})},e.Utf8EncodeWorker=d}),bz=st((e,t)=>{"use strict";var i=Pn(),r=hr();function s(n){i.call(this,"ConvertWorker to "+n),this.destType=n}r.inherits(s,i),s.prototype.processChunk=function(n){this.push({data:r.transformTo(this.destType,n.data),meta:n.meta})},t.exports=s}),yz=st((e,t)=>{"use strict";var i=PI().Readable,r=hr();r.inherits(s,i);function s(n,a,o){i.call(this,a),this._helper=n;var l=this;n.on("data",function(h,c){l.push(h)||l._helper.pause(),o&&o(c)}).on("error",function(h){l.emit("error",h)}).on("end",function(){l.push(null)})}s.prototype._read=function(){this._helper.resume()},t.exports=s}),CI=st((e,t)=>{"use strict";var i=hr(),r=bz(),s=Pn(),n=AI(),a=pl(),o=Nf(),l=null;if(a.nodestream)try{l=yz()}catch{}function h(u,p,g){switch(u){case"blob":return i.newBlob(i.transformTo("arraybuffer",p),g);case"base64":return n.encode(p);default:return i.transformTo(u,p)}}function c(u,p){var g,_=0,y=null,m=0;for(g=0;g<p.length;g++)m+=p[g].length;switch(u){case"string":return p.join("");case"array":return Array.prototype.concat.apply([],p);case"uint8array":for(y=new Uint8Array(m),g=0;g<p.length;g++)y.set(p[g],_),_+=p[g].length;return y;case"nodebuffer":return Buffer.concat(p);default:throw new Error("concat : unsupported type '"+u+"'")}}function d(u,p){return new o.Promise(function(g,_){var y=[],m=u._internalType,O=u._outputType,b=u._mimeType;u.on("data",function(v,E){y.push(v),p&&p(E)}).on("error",function(v){y=[],_(v)}).on("end",function(){try{var v=h(O,c(m,y),b);g(v)}catch(E){_(E)}y=[]}).resume()})}function f(u,p,g){var _=p;switch(p){case"blob":case"arraybuffer":_="uint8array";break;case"base64":_="string";break}try{this._internalType=_,this._outputType=p,this._mimeType=g,i.checkSupport(_),this._worker=u.pipe(new r(_)),u.lock()}catch(y){this._worker=new s("error"),this._worker.error(y)}}f.prototype={accumulate:function(u){return d(this,u)},on:function(u,p){var g=this;return u==="data"?this._worker.on(u,function(_){p.call(g,_.data,_.meta)}):this._worker.on(u,function(){i.delay(p,arguments,g)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(u){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new l(this,{objectMode:this._outputType!=="nodebuffer"},u)}},t.exports=f}),LI=st(e=>{"use strict";e.base64=!1,e.binary=!1,e.dir=!1,e.createFolders=!0,e.date=null,e.compression=null,e.compressionOptions=null,e.comment=null,e.unixPermissions=null,e.dosPermissions=null}),DI=st((e,t)=>{"use strict";var i=hr(),r=Pn(),s=16*1024;function n(a){r.call(this,"DataWorker");var o=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(l){o.dataIsReady=!0,o.data=l,o.max=l&&l.length||0,o.type=i.getTypeOf(l),o.isPaused||o._tickAndRepeat()},function(l){o.error(l)})}i.inherits(n,r),n.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return r.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0):!1},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=s,o=null,l=Math.min(this.max,this.index+a);if(this.index>=this.max)return this.end();switch(this.type){case"string":o=this.data.substring(this.index,l);break;case"uint8array":o=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":o=this.data.slice(this.index,l);break}return this.index=l,this.push({data:o,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=n}),my=st((e,t)=>{"use strict";var i=hr();function r(){for(var o,l=[],h=0;h<256;h++){o=h;for(var c=0;c<8;c++)o=o&1?3988292384^o>>>1:o>>>1;l[h]=o}return l}var s=r();function n(o,l,h,c){var d=s,f=c+h;o=o^-1;for(var u=c;u<f;u++)o=o>>>8^d[(o^l[u])&255];return o^-1}function a(o,l,h,c){var d=s,f=c+h;o=o^-1;for(var u=c;u<f;u++)o=o>>>8^d[(o^l.charCodeAt(u))&255];return o^-1}t.exports=function(o,l){if(typeof o>"u"||!o.length)return 0;var h=i.getTypeOf(o)!=="string";return h?n(l|0,o,o.length,0):a(l|0,o,o.length,0)}}),RI=st((e,t)=>{"use strict";var i=Pn(),r=my(),s=hr();function n(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}s.inherits(n,i),n.prototype.processChunk=function(a){this.streamInfo.crc32=r(a.data,this.streamInfo.crc32||0),this.push(a)},t.exports=n}),vz=st((e,t)=>{"use strict";var i=hr(),r=Pn();function s(n){r.call(this,"DataLengthProbe for "+n),this.propName=n,this.withStreamInfo(n,0)}i.inherits(s,r),s.prototype.processChunk=function(n){if(n){var a=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=a+n.data.length}r.prototype.processChunk.call(this,n)},t.exports=s}),by=st((e,t)=>{"use strict";var i=Nf(),r=DI(),s=RI(),n=vz();function a(o,l,h,c,d){this.compressedSize=o,this.uncompressedSize=l,this.crc32=h,this.compression=c,this.compressedContent=d}a.prototype={getContentWorker:function(){var o=new r(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new n("data_length")),l=this;return o.on("end",function(){if(this.streamInfo.data_length!==l.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),o},getCompressedWorker:function(){return new r(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(o,l,h){return o.pipe(new s).pipe(new n("uncompressedSize")).pipe(l.compressWorker(h)).pipe(new n("compressedSize")).withStreamInfo("compression",l)},t.exports=a}),xz=st((e,t)=>{"use strict";var i=CI(),r=DI(),s=Mf(),n=by(),a=Pn(),o=function(d,f,u){this.name=d,this.dir=u.dir,this.date=u.date,this.comment=u.comment,this.unixPermissions=u.unixPermissions,this.dosPermissions=u.dosPermissions,this._data=f,this._dataBinary=u.binary,this.options={compression:u.compression,compressionOptions:u.compressionOptions}};o.prototype={internalStream:function(d){var f=null,u="string";try{if(!d)throw new Error("No output type specified.");u=d.toLowerCase();var p=u==="string"||u==="text";(u==="binarystring"||u==="text")&&(u="string"),f=this._decompressWorker();var g=!this._dataBinary;g&&!p&&(f=f.pipe(new s.Utf8EncodeWorker)),!g&&p&&(f=f.pipe(new s.Utf8DecodeWorker))}catch(_){f=new a("error"),f.error(_)}return new i(f,u,"")},async:function(d,f){return this.internalStream(d).accumulate(f)},nodeStream:function(d,f){return this.internalStream(d||"nodebuffer").toNodejsStream(f)},_compressWorker:function(d,f){if(this._data instanceof n&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var u=this._decompressWorker();return this._dataBinary||(u=u.pipe(new s.Utf8EncodeWorker)),n.createWorkerFrom(u,d,f)},_decompressWorker:function(){return this._data instanceof n?this._data.getContentWorker():this._data instanceof a?this._data:new r(this._data)}};var l=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(c=0;c<l.length;c++)o.prototype[l[c]]=h;var c;t.exports=o}),gl=st(e=>{"use strict";var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(n,a){return Object.prototype.hasOwnProperty.call(n,a)}e.assign=function(n){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var o=a.shift();if(o){if(typeof o!="object")throw new TypeError(o+"must be non-object");for(var l in o)i(o,l)&&(n[l]=o[l])}}return n},e.shrinkBuf=function(n,a){return n.length===a?n:n.subarray?n.subarray(0,a):(n.length=a,n)};var r={arraySet:function(n,a,o,l,h){if(a.subarray&&n.subarray){n.set(a.subarray(o,o+l),h);return}for(var c=0;c<l;c++)n[h+c]=a[o+c]},flattenChunks:function(n){var a,o,l,h,c,d;for(l=0,a=0,o=n.length;a<o;a++)l+=n[a].length;for(d=new Uint8Array(l),h=0,a=0,o=n.length;a<o;a++)c=n[a],d.set(c,h),h+=c.length;return d}},s={arraySet:function(n,a,o,l,h){for(var c=0;c<l;c++)n[h+c]=a[o+c]},flattenChunks:function(n){return[].concat.apply([],n)}};e.setTyped=function(n){n?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,r)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,s))},e.setTyped(t)}),Ez=st(e=>{"use strict";var t=gl(),i=4,r=0,s=1,n=2;function a(Q){for(var ke=Q.length;--ke>=0;)Q[ke]=0}var o=0,l=1,h=2,c=3,d=258,f=29,u=256,p=u+1+f,g=30,_=19,y=2*p+1,m=15,O=16,b=7,v=256,E=16,T=17,P=18,A=[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],C=[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],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],H=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],k=512,F=new Array((p+2)*2);a(F);var j=new Array(g*2);a(j);var L=new Array(k);a(L);var R=new Array(d-c+1);a(R);var x=new Array(f);a(x);var I=new Array(g);a(I);function S(Q,ke,Ge,qe,me){this.static_tree=Q,this.extra_bits=ke,this.extra_base=Ge,this.elems=qe,this.max_length=me,this.has_stree=Q&&Q.length}var D,N,G;function z(Q,ke){this.dyn_tree=Q,this.max_code=0,this.stat_desc=ke}function Z(Q){return Q<256?L[Q]:L[256+(Q>>>7)]}function se(Q,ke){Q.pending_buf[Q.pending++]=ke&255,Q.pending_buf[Q.pending++]=ke>>>8&255}function he(Q,ke,Ge){Q.bi_valid>O-Ge?(Q.bi_buf|=ke<<Q.bi_valid&65535,se(Q,Q.bi_buf),Q.bi_buf=ke>>O-Q.bi_valid,Q.bi_valid+=Ge-O):(Q.bi_buf|=ke<<Q.bi_valid&65535,Q.bi_valid+=Ge)}function pe(Q,ke,Ge){he(Q,Ge[ke*2],Ge[ke*2+1])}function Se(Q,ke){var Ge=0;do Ge|=Q&1,Q>>>=1,Ge<<=1;while(--ke>0);return Ge>>>1}function q(Q){Q.bi_valid===16?(se(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0):Q.bi_valid>=8&&(Q.pending_buf[Q.pending++]=Q.bi_buf&255,Q.bi_buf>>=8,Q.bi_valid-=8)}function X(Q,ke){var Ge=ke.dyn_tree,qe=ke.max_code,me=ke.stat_desc.static_tree,Me=ke.stat_desc.has_stree,J=ke.stat_desc.extra_bits,ze=ke.stat_desc.extra_base,mt=ke.stat_desc.max_length,U,Le,Ne,K,_e,Ae,ft=0;for(K=0;K<=m;K++)Q.bl_count[K]=0;for(Ge[Q.heap[Q.heap_max]*2+1]=0,U=Q.heap_max+1;U<y;U++)Le=Q.heap[U],K=Ge[Ge[Le*2+1]*2+1]+1,K>mt&&(K=mt,ft++),Ge[Le*2+1]=K,!(Le>qe)&&(Q.bl_count[K]++,_e=0,Le>=ze&&(_e=J[Le-ze]),Ae=Ge[Le*2],Q.opt_len+=Ae*(K+_e),Me&&(Q.static_len+=Ae*(me[Le*2+1]+_e)));if(ft!==0){do{for(K=mt-1;Q.bl_count[K]===0;)K--;Q.bl_count[K]--,Q.bl_count[K+1]+=2,Q.bl_count[mt]--,ft-=2}while(ft>0);for(K=mt;K!==0;K--)for(Le=Q.bl_count[K];Le!==0;)Ne=Q.heap[--U],!(Ne>qe)&&(Ge[Ne*2+1]!==K&&(Q.opt_len+=(K-Ge[Ne*2+1])*Ge[Ne*2],Ge[Ne*2+1]=K),Le--)}}function ie(Q,ke,Ge){var qe=new Array(m+1),me=0,Me,J;for(Me=1;Me<=m;Me++)qe[Me]=me=me+Ge[Me-1]<<1;for(J=0;J<=ke;J++){var ze=Q[J*2+1];ze!==0&&(Q[J*2]=Se(qe[ze]++,ze))}}function de(){var Q,ke,Ge,qe,me,Me=new Array(m+1);for(Ge=0,qe=0;qe<f-1;qe++)for(x[qe]=Ge,Q=0;Q<1<<A[qe];Q++)R[Ge++]=qe;for(R[Ge-1]=qe,me=0,qe=0;qe<16;qe++)for(I[qe]=me,Q=0;Q<1<<C[qe];Q++)L[me++]=qe;for(me>>=7;qe<g;qe++)for(I[qe]=me<<7,Q=0;Q<1<<C[qe]-7;Q++)L[256+me++]=qe;for(ke=0;ke<=m;ke++)Me[ke]=0;for(Q=0;Q<=143;)F[Q*2+1]=8,Q++,Me[8]++;for(;Q<=255;)F[Q*2+1]=9,Q++,Me[9]++;for(;Q<=279;)F[Q*2+1]=7,Q++,Me[7]++;for(;Q<=287;)F[Q*2+1]=8,Q++,Me[8]++;for(ie(F,p+1,Me),Q=0;Q<g;Q++)j[Q*2+1]=5,j[Q*2]=Se(Q,5);D=new S(F,A,u+1,p,m),N=new S(j,C,0,g,m),G=new S(new Array(0),M,0,_,b)}function Ce(Q){var ke;for(ke=0;ke<p;ke++)Q.dyn_ltree[ke*2]=0;for(ke=0;ke<g;ke++)Q.dyn_dtree[ke*2]=0;for(ke=0;ke<_;ke++)Q.bl_tree[ke*2]=0;Q.dyn_ltree[v*2]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function De(Q){Q.bi_valid>8?se(Q,Q.bi_buf):Q.bi_valid>0&&(Q.pending_buf[Q.pending++]=Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0}function Fe(Q,ke,Ge,qe){De(Q),qe&&(se(Q,Ge),se(Q,~Ge)),t.arraySet(Q.pending_buf,Q.window,ke,Ge,Q.pending),Q.pending+=Ge}function Pe(Q,ke,Ge,qe){var me=ke*2,Me=Ge*2;return Q[me]<Q[Me]||Q[me]===Q[Me]&&qe[ke]<=qe[Ge]}function w(Q,ke,Ge){for(var qe=Q.heap[Ge],me=Ge<<1;me<=Q.heap_len&&(me<Q.heap_len&&Pe(ke,Q.heap[me+1],Q.heap[me],Q.depth)&&me++,!Pe(ke,qe,Q.heap[me],Q.depth));)Q.heap[Ge]=Q.heap[me],Ge=me,me<<=1;Q.heap[Ge]=qe}function B(Q,ke,Ge){var qe,me,Me=0,J,ze;if(Q.last_lit!==0)do qe=Q.pending_buf[Q.d_buf+Me*2]<<8|Q.pending_buf[Q.d_buf+Me*2+1],me=Q.pending_buf[Q.l_buf+Me],Me++,qe===0?pe(Q,me,ke):(J=R[me],pe(Q,J+u+1,ke),ze=A[J],ze!==0&&(me-=x[J],he(Q,me,ze)),qe--,J=Z(qe),pe(Q,J,Ge),ze=C[J],ze!==0&&(qe-=I[J],he(Q,qe,ze)));while(Me<Q.last_lit);pe(Q,v,ke)}function V(Q,ke){var Ge=ke.dyn_tree,qe=ke.stat_desc.static_tree,me=ke.stat_desc.has_stree,Me=ke.stat_desc.elems,J,ze,mt=-1,U;for(Q.heap_len=0,Q.heap_max=y,J=0;J<Me;J++)Ge[J*2]!==0?(Q.heap[++Q.heap_len]=mt=J,Q.depth[J]=0):Ge[J*2+1]=0;for(;Q.heap_len<2;)U=Q.heap[++Q.heap_len]=mt<2?++mt:0,Ge[U*2]=1,Q.depth[U]=0,Q.opt_len--,me&&(Q.static_len-=qe[U*2+1]);for(ke.max_code=mt,J=Q.heap_len>>1;J>=1;J--)w(Q,Ge,J);U=Me;do J=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],w(Q,Ge,1),ze=Q.heap[1],Q.heap[--Q.heap_max]=J,Q.heap[--Q.heap_max]=ze,Ge[U*2]=Ge[J*2]+Ge[ze*2],Q.depth[U]=(Q.depth[J]>=Q.depth[ze]?Q.depth[J]:Q.depth[ze])+1,Ge[J*2+1]=Ge[ze*2+1]=U,Q.heap[1]=U++,w(Q,Ge,1);while(Q.heap_len>=2);Q.heap[--Q.heap_max]=Q.heap[1],X(Q,ke),ie(Ge,mt,Q.bl_count)}function Y(Q,ke,Ge){var qe,me=-1,Me,J=ke[1],ze=0,mt=7,U=4;for(J===0&&(mt=138,U=3),ke[(Ge+1)*2+1]=65535,qe=0;qe<=Ge;qe++)Me=J,J=ke[(qe+1)*2+1],!(++ze<mt&&Me===J)&&(ze<U?Q.bl_tree[Me*2]+=ze:Me!==0?(Me!==me&&Q.bl_tree[Me*2]++,Q.bl_tree[E*2]++):ze<=10?Q.bl_tree[T*2]++:Q.bl_tree[P*2]++,ze=0,me=Me,J===0?(mt=138,U=3):Me===J?(mt=6,U=3):(mt=7,U=4))}function W(Q,ke,Ge){var qe,me=-1,Me,J=ke[1],ze=0,mt=7,U=4;for(J===0&&(mt=138,U=3),qe=0;qe<=Ge;qe++)if(Me=J,J=ke[(qe+1)*2+1],!(++ze<mt&&Me===J)){if(ze<U)do pe(Q,Me,Q.bl_tree);while(--ze!==0);else Me!==0?(Me!==me&&(pe(Q,Me,Q.bl_tree),ze--),pe(Q,E,Q.bl_tree),he(Q,ze-3,2)):ze<=10?(pe(Q,T,Q.bl_tree),he(Q,ze-3,3)):(pe(Q,P,Q.bl_tree),he(Q,ze-11,7));ze=0,me=Me,J===0?(mt=138,U=3):Me===J?(mt=6,U=3):(mt=7,U=4)}}function ne(Q){var ke;for(Y(Q,Q.dyn_ltree,Q.l_desc.max_code),Y(Q,Q.dyn_dtree,Q.d_desc.max_code),V(Q,Q.bl_desc),ke=_-1;ke>=3&&Q.bl_tree[H[ke]*2+1]===0;ke--);return Q.opt_len+=3*(ke+1)+5+5+4,ke}function ue(Q,ke,Ge,qe){var me;for(he(Q,ke-257,5),he(Q,Ge-1,5),he(Q,qe-4,4),me=0;me<qe;me++)he(Q,Q.bl_tree[H[me]*2+1],3);W(Q,Q.dyn_ltree,ke-1),W(Q,Q.dyn_dtree,Ge-1)}function Re(Q){var ke=4093624447,Ge;for(Ge=0;Ge<=31;Ge++,ke>>>=1)if(ke&1&&Q.dyn_ltree[Ge*2]!==0)return r;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return s;for(Ge=32;Ge<u;Ge++)if(Q.dyn_ltree[Ge*2]!==0)return s;return r}var Ue=!1;function je(Q){Ue||(de(),Ue=!0),Q.l_desc=new z(Q.dyn_ltree,D),Q.d_desc=new z(Q.dyn_dtree,N),Q.bl_desc=new z(Q.bl_tree,G),Q.bi_buf=0,Q.bi_valid=0,Ce(Q)}function dt(Q,ke,Ge,qe){he(Q,(o<<1)+(qe?1:0),3),Fe(Q,ke,Ge,!0)}function Ot(Q){he(Q,l<<1,3),pe(Q,v,F),q(Q)}function Lt(Q,ke,Ge,qe){var me,Me,J=0;Q.level>0?(Q.strm.data_type===n&&(Q.strm.data_type=Re(Q)),V(Q,Q.l_desc),V(Q,Q.d_desc),J=ne(Q),me=Q.opt_len+3+7>>>3,Me=Q.static_len+3+7>>>3,Me<=me&&(me=Me)):me=Me=Ge+5,Ge+4<=me&&ke!==-1?dt(Q,ke,Ge,qe):Q.strategy===i||Me===me?(he(Q,(l<<1)+(qe?1:0),3),B(Q,F,j)):(he(Q,(h<<1)+(qe?1:0),3),ue(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,J+1),B(Q,Q.dyn_ltree,Q.dyn_dtree)),Ce(Q),qe&&De(Q)}function hi(Q,ke,Ge){return Q.pending_buf[Q.d_buf+Q.last_lit*2]=ke>>>8&255,Q.pending_buf[Q.d_buf+Q.last_lit*2+1]=ke&255,Q.pending_buf[Q.l_buf+Q.last_lit]=Ge&255,Q.last_lit++,ke===0?Q.dyn_ltree[Ge*2]++:(Q.matches++,ke--,Q.dyn_ltree[(R[Ge]+u+1)*2]++,Q.dyn_dtree[Z(ke)*2]++),Q.last_lit===Q.lit_bufsize-1}e._tr_init=je,e._tr_stored_block=dt,e._tr_flush_block=Lt,e._tr_tally=hi,e._tr_align=Ot}),NI=st((e,t)=>{"use strict";function i(r,s,n,a){for(var o=r&65535|0,l=r>>>16&65535|0,h=0;n!==0;){h=n>2e3?2e3:n,n-=h;do o=o+s[a++]|0,l=l+o|0;while(--h);o%=65521,l%=65521}return o|l<<16|0}t.exports=i}),MI=st((e,t)=>{"use strict";function i(){for(var n,a=[],o=0;o<256;o++){n=o;for(var l=0;l<8;l++)n=n&1?3988292384^n>>>1:n>>>1;a[o]=n}return a}var r=i();function s(n,a,o,l){var h=r,c=l+o;n^=-1;for(var d=l;d<c;d++)n=n>>>8^h[(n^a[d])&255];return n^-1}t.exports=s}),yy=st((e,t)=>{"use strict";t.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"}}),wz=st(e=>{"use strict";var t=gl(),i=Ez(),r=NI(),s=MI(),n=yy(),a=0,o=1,l=3,h=4,c=5,d=0,f=1,u=-2,p=-3,g=-5,_=-1,y=1,m=2,O=3,b=4,v=0,E=2,T=8,P=9,A=15,C=8,M=29,H=256,k=H+1+M,F=30,j=19,L=2*k+1,R=15,x=3,I=258,S=I+x+1,D=32,N=42,G=69,z=73,Z=91,se=103,he=113,pe=666,Se=1,q=2,X=3,ie=4,de=3;function Ce(U,Le){return U.msg=n[Le],Le}function De(U){return(U<<1)-(U>4?9:0)}function Fe(U){for(var Le=U.length;--Le>=0;)U[Le]=0}function Pe(U){var Le=U.state,Ne=Le.pending;Ne>U.avail_out&&(Ne=U.avail_out),Ne!==0&&(t.arraySet(U.output,Le.pending_buf,Le.pending_out,Ne,U.next_out),U.next_out+=Ne,Le.pending_out+=Ne,U.total_out+=Ne,U.avail_out-=Ne,Le.pending-=Ne,Le.pending===0&&(Le.pending_out=0))}function w(U,Le){i._tr_flush_block(U,U.block_start>=0?U.block_start:-1,U.strstart-U.block_start,Le),U.block_start=U.strstart,Pe(U.strm)}function B(U,Le){U.pending_buf[U.pending++]=Le}function V(U,Le){U.pending_buf[U.pending++]=Le>>>8&255,U.pending_buf[U.pending++]=Le&255}function Y(U,Le,Ne,K){var _e=U.avail_in;return _e>K&&(_e=K),_e===0?0:(U.avail_in-=_e,t.arraySet(Le,U.input,U.next_in,_e,Ne),U.state.wrap===1?U.adler=r(U.adler,Le,_e,Ne):U.state.wrap===2&&(U.adler=s(U.adler,Le,_e,Ne)),U.next_in+=_e,U.total_in+=_e,_e)}function W(U,Le){var Ne=U.max_chain_length,K=U.strstart,_e,Ae,ft=U.prev_length,Ze=U.nice_match,Ke=U.strstart>U.w_size-S?U.strstart-(U.w_size-S):0,Ft=U.window,Ps=U.w_mask,vt=U.prev,bt=U.strstart+I,ki=Ft[K+ft-1],_r=Ft[K+ft];U.prev_length>=U.good_match&&(Ne>>=2),Ze>U.lookahead&&(Ze=U.lookahead);do if(_e=Le,!(Ft[_e+ft]!==_r||Ft[_e+ft-1]!==ki||Ft[_e]!==Ft[K]||Ft[++_e]!==Ft[K+1])){K+=2,_e++;do;while(Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&Ft[++K]===Ft[++_e]&&K<bt);if(Ae=I-(bt-K),K=bt-I,Ae>ft){if(U.match_start=Le,ft=Ae,Ae>=Ze)break;ki=Ft[K+ft-1],_r=Ft[K+ft]}}while((Le=vt[Le&Ps])>Ke&&--Ne!==0);return ft<=U.lookahead?ft:U.lookahead}function ne(U){var Le=U.w_size,Ne,K,_e,Ae,ft;do{if(Ae=U.window_size-U.lookahead-U.strstart,U.strstart>=Le+(Le-S)){t.arraySet(U.window,U.window,Le,Le,0),U.match_start-=Le,U.strstart-=Le,U.block_start-=Le,K=U.hash_size,Ne=K;do _e=U.head[--Ne],U.head[Ne]=_e>=Le?_e-Le:0;while(--K);K=Le,Ne=K;do _e=U.prev[--Ne],U.prev[Ne]=_e>=Le?_e-Le:0;while(--K);Ae+=Le}if(U.strm.avail_in===0)break;if(K=Y(U.strm,U.window,U.strstart+U.lookahead,Ae),U.lookahead+=K,U.lookahead+U.insert>=x)for(ft=U.strstart-U.insert,U.ins_h=U.window[ft],U.ins_h=(U.ins_h<<U.hash_shift^U.window[ft+1])&U.hash_mask;U.insert&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[ft+x-1])&U.hash_mask,U.prev[ft&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=ft,ft++,U.insert--,!(U.lookahead+U.insert<x)););}while(U.lookahead<S&&U.strm.avail_in!==0)}function ue(U,Le){var Ne=65535;for(Ne>U.pending_buf_size-5&&(Ne=U.pending_buf_size-5);;){if(U.lookahead<=1){if(ne(U),U.lookahead===0&&Le===a)return Se;if(U.lookahead===0)break}U.strstart+=U.lookahead,U.lookahead=0;var K=U.block_start+Ne;if((U.strstart===0||U.strstart>=K)&&(U.lookahead=U.strstart-K,U.strstart=K,w(U,!1),U.strm.avail_out===0)||U.strstart-U.block_start>=U.w_size-S&&(w(U,!1),U.strm.avail_out===0))return Se}return U.insert=0,Le===h?(w(U,!0),U.strm.avail_out===0?X:ie):(U.strstart>U.block_start&&(w(U,!1),U.strm.avail_out),Se)}function Re(U,Le){for(var Ne,K;;){if(U.lookahead<S){if(ne(U),U.lookahead<S&&Le===a)return Se;if(U.lookahead===0)break}if(Ne=0,U.lookahead>=x&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+x-1])&U.hash_mask,Ne=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),Ne!==0&&U.strstart-Ne<=U.w_size-S&&(U.match_length=W(U,Ne)),U.match_length>=x)if(K=i._tr_tally(U,U.strstart-U.match_start,U.match_length-x),U.lookahead-=U.match_length,U.match_length<=U.max_lazy_match&&U.lookahead>=x){U.match_length--;do U.strstart++,U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+x-1])&U.hash_mask,Ne=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart;while(--U.match_length!==0);U.strstart++}else U.strstart+=U.match_length,U.match_length=0,U.ins_h=U.window[U.strstart],U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+1])&U.hash_mask;else K=i._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++;if(K&&(w(U,!1),U.strm.avail_out===0))return Se}return U.insert=U.strstart<x-1?U.strstart:x-1,Le===h?(w(U,!0),U.strm.avail_out===0?X:ie):U.last_lit&&(w(U,!1),U.strm.avail_out===0)?Se:q}function Ue(U,Le){for(var Ne,K,_e;;){if(U.lookahead<S){if(ne(U),U.lookahead<S&&Le===a)return Se;if(U.lookahead===0)break}if(Ne=0,U.lookahead>=x&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+x-1])&U.hash_mask,Ne=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),U.prev_length=U.match_length,U.prev_match=U.match_start,U.match_length=x-1,Ne!==0&&U.prev_length<U.max_lazy_match&&U.strstart-Ne<=U.w_size-S&&(U.match_length=W(U,Ne),U.match_length<=5&&(U.strategy===y||U.match_length===x&&U.strstart-U.match_start>4096)&&(U.match_length=x-1)),U.prev_length>=x&&U.match_length<=U.prev_length){_e=U.strstart+U.lookahead-x,K=i._tr_tally(U,U.strstart-1-U.prev_match,U.prev_length-x),U.lookahead-=U.prev_length-1,U.prev_length-=2;do++U.strstart<=_e&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+x-1])&U.hash_mask,Ne=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart);while(--U.prev_length!==0);if(U.match_available=0,U.match_length=x-1,U.strstart++,K&&(w(U,!1),U.strm.avail_out===0))return Se}else if(U.match_available){if(K=i._tr_tally(U,0,U.window[U.strstart-1]),K&&w(U,!1),U.strstart++,U.lookahead--,U.strm.avail_out===0)return Se}else U.match_available=1,U.strstart++,U.lookahead--}return U.match_available&&(K=i._tr_tally(U,0,U.window[U.strstart-1]),U.match_available=0),U.insert=U.strstart<x-1?U.strstart:x-1,Le===h?(w(U,!0),U.strm.avail_out===0?X:ie):U.last_lit&&(w(U,!1),U.strm.avail_out===0)?Se:q}function je(U,Le){for(var Ne,K,_e,Ae,ft=U.window;;){if(U.lookahead<=I){if(ne(U),U.lookahead<=I&&Le===a)return Se;if(U.lookahead===0)break}if(U.match_length=0,U.lookahead>=x&&U.strstart>0&&(_e=U.strstart-1,K=ft[_e],K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e])){Ae=U.strstart+I;do;while(K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&K===ft[++_e]&&_e<Ae);U.match_length=I-(Ae-_e),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=x?(Ne=i._tr_tally(U,1,U.match_length-x),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(Ne=i._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),Ne&&(w(U,!1),U.strm.avail_out===0))return Se}return U.insert=0,Le===h?(w(U,!0),U.strm.avail_out===0?X:ie):U.last_lit&&(w(U,!1),U.strm.avail_out===0)?Se:q}function dt(U,Le){for(var Ne;;){if(U.lookahead===0&&(ne(U),U.lookahead===0)){if(Le===a)return Se;break}if(U.match_length=0,Ne=i._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,Ne&&(w(U,!1),U.strm.avail_out===0))return Se}return U.insert=0,Le===h?(w(U,!0),U.strm.avail_out===0?X:ie):U.last_lit&&(w(U,!1),U.strm.avail_out===0)?Se:q}function Ot(U,Le,Ne,K,_e){this.good_length=U,this.max_lazy=Le,this.nice_length=Ne,this.max_chain=K,this.func=_e}var Lt;Lt=[new Ot(0,0,0,0,ue),new Ot(4,4,8,4,Re),new Ot(4,5,16,8,Re),new Ot(4,6,32,32,Re),new Ot(4,4,16,16,Ue),new Ot(8,16,32,32,Ue),new Ot(8,16,128,128,Ue),new Ot(8,32,128,256,Ue),new Ot(32,128,258,1024,Ue),new Ot(32,258,258,4096,Ue)];function hi(U){U.window_size=2*U.w_size,Fe(U.head),U.max_lazy_match=Lt[U.level].max_lazy,U.good_match=Lt[U.level].good_length,U.nice_match=Lt[U.level].nice_length,U.max_chain_length=Lt[U.level].max_chain,U.strstart=0,U.block_start=0,U.lookahead=0,U.insert=0,U.match_length=U.prev_length=x-1,U.match_available=0,U.ins_h=0}function Q(){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=T,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 t.Buf16(L*2),this.dyn_dtree=new t.Buf16((2*F+1)*2),this.bl_tree=new t.Buf16((2*j+1)*2),Fe(this.dyn_ltree),Fe(this.dyn_dtree),Fe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new t.Buf16(R+1),this.heap=new t.Buf16(2*k+1),Fe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new t.Buf16(2*k+1),Fe(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 ke(U){var Le;return!U||!U.state?Ce(U,u):(U.total_in=U.total_out=0,U.data_type=E,Le=U.state,Le.pending=0,Le.pending_out=0,Le.wrap<0&&(Le.wrap=-Le.wrap),Le.status=Le.wrap?N:he,U.adler=Le.wrap===2?0:1,Le.last_flush=a,i._tr_init(Le),d)}function Ge(U){var Le=ke(U);return Le===d&&hi(U.state),Le}function qe(U,Le){return!U||!U.state||U.state.wrap!==2?u:(U.state.gzhead=Le,d)}function me(U,Le,Ne,K,_e,Ae){if(!U)return u;var ft=1;if(Le===_&&(Le=6),K<0?(ft=0,K=-K):K>15&&(ft=2,K-=16),_e<1||_e>P||Ne!==T||K<8||K>15||Le<0||Le>9||Ae<0||Ae>b)return Ce(U,u);K===8&&(K=9);var Ze=new Q;return U.state=Ze,Ze.strm=U,Ze.wrap=ft,Ze.gzhead=null,Ze.w_bits=K,Ze.w_size=1<<Ze.w_bits,Ze.w_mask=Ze.w_size-1,Ze.hash_bits=_e+7,Ze.hash_size=1<<Ze.hash_bits,Ze.hash_mask=Ze.hash_size-1,Ze.hash_shift=~~((Ze.hash_bits+x-1)/x),Ze.window=new t.Buf8(Ze.w_size*2),Ze.head=new t.Buf16(Ze.hash_size),Ze.prev=new t.Buf16(Ze.w_size),Ze.lit_bufsize=1<<_e+6,Ze.pending_buf_size=Ze.lit_bufsize*4,Ze.pending_buf=new t.Buf8(Ze.pending_buf_size),Ze.d_buf=1*Ze.lit_bufsize,Ze.l_buf=3*Ze.lit_bufsize,Ze.level=Le,Ze.strategy=Ae,Ze.method=Ne,Ge(U)}function Me(U,Le){return me(U,Le,T,A,C,v)}function J(U,Le){var Ne,K,_e,Ae;if(!U||!U.state||Le>c||Le<0)return U?Ce(U,u):u;if(K=U.state,!U.output||!U.input&&U.avail_in!==0||K.status===pe&&Le!==h)return Ce(U,U.avail_out===0?g:u);if(K.strm=U,Ne=K.last_flush,K.last_flush=Le,K.status===N)if(K.wrap===2)U.adler=0,B(K,31),B(K,139),B(K,8),K.gzhead?(B(K,(K.gzhead.text?1:0)+(K.gzhead.hcrc?2:0)+(K.gzhead.extra?4:0)+(K.gzhead.name?8:0)+(K.gzhead.comment?16:0)),B(K,K.gzhead.time&255),B(K,K.gzhead.time>>8&255),B(K,K.gzhead.time>>16&255),B(K,K.gzhead.time>>24&255),B(K,K.level===9?2:K.strategy>=m||K.level<2?4:0),B(K,K.gzhead.os&255),K.gzhead.extra&&K.gzhead.extra.length&&(B(K,K.gzhead.extra.length&255),B(K,K.gzhead.extra.length>>8&255)),K.gzhead.hcrc&&(U.adler=s(U.adler,K.pending_buf,K.pending,0)),K.gzindex=0,K.status=G):(B(K,0),B(K,0),B(K,0),B(K,0),B(K,0),B(K,K.level===9?2:K.strategy>=m||K.level<2?4:0),B(K,de),K.status=he);else{var ft=T+(K.w_bits-8<<4)<<8,Ze=-1;K.strategy>=m||K.level<2?Ze=0:K.level<6?Ze=1:K.level===6?Ze=2:Ze=3,ft|=Ze<<6,K.strstart!==0&&(ft|=D),ft+=31-ft%31,K.status=he,V(K,ft),K.strstart!==0&&(V(K,U.adler>>>16),V(K,U.adler&65535)),U.adler=1}if(K.status===G)if(K.gzhead.extra){for(_e=K.pending;K.gzindex<(K.gzhead.extra.length&65535)&&!(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),Pe(U),_e=K.pending,K.pending===K.pending_buf_size));)B(K,K.gzhead.extra[K.gzindex]&255),K.gzindex++;K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),K.gzindex===K.gzhead.extra.length&&(K.gzindex=0,K.status=z)}else K.status=z;if(K.status===z)if(K.gzhead.name){_e=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),Pe(U),_e=K.pending,K.pending===K.pending_buf_size)){Ae=1;break}K.gzindex<K.gzhead.name.length?Ae=K.gzhead.name.charCodeAt(K.gzindex++)&255:Ae=0,B(K,Ae)}while(Ae!==0);K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),Ae===0&&(K.gzindex=0,K.status=Z)}else K.status=Z;if(K.status===Z)if(K.gzhead.comment){_e=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),Pe(U),_e=K.pending,K.pending===K.pending_buf_size)){Ae=1;break}K.gzindex<K.gzhead.comment.length?Ae=K.gzhead.comment.charCodeAt(K.gzindex++)&255:Ae=0,B(K,Ae)}while(Ae!==0);K.gzhead.hcrc&&K.pending>_e&&(U.adler=s(U.adler,K.pending_buf,K.pending-_e,_e)),Ae===0&&(K.status=se)}else K.status=se;if(K.status===se&&(K.gzhead.hcrc?(K.pending+2>K.pending_buf_size&&Pe(U),K.pending+2<=K.pending_buf_size&&(B(K,U.adler&255),B(K,U.adler>>8&255),U.adler=0,K.status=he)):K.status=he),K.pending!==0){if(Pe(U),U.avail_out===0)return K.last_flush=-1,d}else if(U.avail_in===0&&De(Le)<=De(Ne)&&Le!==h)return Ce(U,g);if(K.status===pe&&U.avail_in!==0)return Ce(U,g);if(U.avail_in!==0||K.lookahead!==0||Le!==a&&K.status!==pe){var Ke=K.strategy===m?dt(K,Le):K.strategy===O?je(K,Le):Lt[K.level].func(K,Le);if((Ke===X||Ke===ie)&&(K.status=pe),Ke===Se||Ke===X)return U.avail_out===0&&(K.last_flush=-1),d;if(Ke===q&&(Le===o?i._tr_align(K):Le!==c&&(i._tr_stored_block(K,0,0,!1),Le===l&&(Fe(K.head),K.lookahead===0&&(K.strstart=0,K.block_start=0,K.insert=0))),Pe(U),U.avail_out===0))return K.last_flush=-1,d}return Le!==h?d:K.wrap<=0?f:(K.wrap===2?(B(K,U.adler&255),B(K,U.adler>>8&255),B(K,U.adler>>16&255),B(K,U.adler>>24&255),B(K,U.total_in&255),B(K,U.total_in>>8&255),B(K,U.total_in>>16&255),B(K,U.total_in>>24&255)):(V(K,U.adler>>>16),V(K,U.adler&65535)),Pe(U),K.wrap>0&&(K.wrap=-K.wrap),K.pending!==0?d:f)}function ze(U){var Le;return!U||!U.state?u:(Le=U.state.status,Le!==N&&Le!==G&&Le!==z&&Le!==Z&&Le!==se&&Le!==he&&Le!==pe?Ce(U,u):(U.state=null,Le===he?Ce(U,p):d))}function mt(U,Le){var Ne=Le.length,K,_e,Ae,ft,Ze,Ke,Ft,Ps;if(!U||!U.state||(K=U.state,ft=K.wrap,ft===2||ft===1&&K.status!==N||K.lookahead))return u;for(ft===1&&(U.adler=r(U.adler,Le,Ne,0)),K.wrap=0,Ne>=K.w_size&&(ft===0&&(Fe(K.head),K.strstart=0,K.block_start=0,K.insert=0),Ps=new t.Buf8(K.w_size),t.arraySet(Ps,Le,Ne-K.w_size,K.w_size,0),Le=Ps,Ne=K.w_size),Ze=U.avail_in,Ke=U.next_in,Ft=U.input,U.avail_in=Ne,U.next_in=0,U.input=Le,ne(K);K.lookahead>=x;){_e=K.strstart,Ae=K.lookahead-(x-1);do K.ins_h=(K.ins_h<<K.hash_shift^K.window[_e+x-1])&K.hash_mask,K.prev[_e&K.w_mask]=K.head[K.ins_h],K.head[K.ins_h]=_e,_e++;while(--Ae);K.strstart=_e,K.lookahead=x-1,ne(K)}return K.strstart+=K.lookahead,K.block_start=K.strstart,K.insert=K.lookahead,K.lookahead=0,K.match_length=K.prev_length=x-1,K.match_available=0,U.next_in=Ke,U.input=Ft,U.avail_in=Ze,K.wrap=ft,d}e.deflateInit=Me,e.deflateInit2=me,e.deflateReset=Ge,e.deflateResetKeep=ke,e.deflateSetHeader=qe,e.deflate=J,e.deflateEnd=ze,e.deflateSetDictionary=mt,e.deflateInfo="pako deflate (from Nodeca project)"}),BI=st(e=>{"use strict";var t=gl(),i=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{r=!1}var s=new t.Buf8(256);for(n=0;n<256;n++)s[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;var n;s[254]=s[254]=1,e.string2buf=function(o){var l,h,c,d,f,u=o.length,p=0;for(d=0;d<u;d++)h=o.charCodeAt(d),(h&64512)===55296&&d+1<u&&(c=o.charCodeAt(d+1),(c&64512)===56320&&(h=65536+(h-55296<<10)+(c-56320),d++)),p+=h<128?1:h<2048?2:h<65536?3:4;for(l=new t.Buf8(p),f=0,d=0;f<p;d++)h=o.charCodeAt(d),(h&64512)===55296&&d+1<u&&(c=o.charCodeAt(d+1),(c&64512)===56320&&(h=65536+(h-55296<<10)+(c-56320),d++)),h<128?l[f++]=h:h<2048?(l[f++]=192|h>>>6,l[f++]=128|h&63):h<65536?(l[f++]=224|h>>>12,l[f++]=128|h>>>6&63,l[f++]=128|h&63):(l[f++]=240|h>>>18,l[f++]=128|h>>>12&63,l[f++]=128|h>>>6&63,l[f++]=128|h&63);return l};function a(o,l){if(l<65534&&(o.subarray&&r||!o.subarray&&i))return String.fromCharCode.apply(null,t.shrinkBuf(o,l));for(var h="",c=0;c<l;c++)h+=String.fromCharCode(o[c]);return h}e.buf2binstring=function(o){return a(o,o.length)},e.binstring2buf=function(o){for(var l=new t.Buf8(o.length),h=0,c=l.length;h<c;h++)l[h]=o.charCodeAt(h);return l},e.buf2string=function(o,l){var h,c,d,f,u=l||o.length,p=new Array(u*2);for(c=0,h=0;h<u;){if(d=o[h++],d<128){p[c++]=d;continue}if(f=s[d],f>4){p[c++]=65533,h+=f-1;continue}for(d&=f===2?31:f===3?15:7;f>1&&h<u;)d=d<<6|o[h++]&63,f--;if(f>1){p[c++]=65533;continue}d<65536?p[c++]=d:(d-=65536,p[c++]=55296|d>>10&1023,p[c++]=56320|d&1023)}return a(p,c)},e.utf8border=function(o,l){var h;for(l=l||o.length,l>o.length&&(l=o.length),h=l-1;h>=0&&(o[h]&192)===128;)h--;return h<0||h===0?l:h+s[o[h]]>l?h:l}}),kI=st((e,t)=>{"use strict";function i(){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}t.exports=i}),Tz=st(e=>{"use strict";var t=wz(),i=gl(),r=BI(),s=yy(),n=kI(),a=Object.prototype.toString,o=0,l=4,h=0,c=1,d=2,f=-1,u=0,p=8;function g(O){if(!(this instanceof g))return new g(O);this.options=i.assign({level:f,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},O||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new n,this.strm.avail_out=0;var v=t.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(v!==h)throw new Error(s[v]);if(b.header&&t.deflateSetHeader(this.strm,b.header),b.dictionary){var E;if(typeof b.dictionary=="string"?E=r.string2buf(b.dictionary):a.call(b.dictionary)==="[object ArrayBuffer]"?E=new Uint8Array(b.dictionary):E=b.dictionary,v=t.deflateSetDictionary(this.strm,E),v!==h)throw new Error(s[v]);this._dict_set=!0}}g.prototype.push=function(O,b){var v=this.strm,E=this.options.chunkSize,T,P;if(this.ended)return!1;P=b===~~b?b:b===!0?l:o,typeof O=="string"?v.input=r.string2buf(O):a.call(O)==="[object ArrayBuffer]"?v.input=new Uint8Array(O):v.input=O,v.next_in=0,v.avail_in=v.input.length;do{if(v.avail_out===0&&(v.output=new i.Buf8(E),v.next_out=0,v.avail_out=E),T=t.deflate(v,P),T!==c&&T!==h)return this.onEnd(T),this.ended=!0,!1;(v.avail_out===0||v.avail_in===0&&(P===l||P===d))&&(this.options.to==="string"?this.onData(r.buf2binstring(i.shrinkBuf(v.output,v.next_out))):this.onData(i.shrinkBuf(v.output,v.next_out)))}while((v.avail_in>0||v.avail_out===0)&&T!==c);return P===l?(T=t.deflateEnd(this.strm),this.onEnd(T),this.ended=!0,T===h):(P===d&&(this.onEnd(h),v.avail_out=0),!0)},g.prototype.onData=function(O){this.chunks.push(O)},g.prototype.onEnd=function(O){O===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=O,this.msg=this.strm.msg};function _(O,b){var v=new g(b);if(v.push(O,!0),v.err)throw v.msg||s[v.err];return v.result}function y(O,b){return b=b||{},b.raw=!0,_(O,b)}function m(O,b){return b=b||{},b.gzip=!0,_(O,b)}e.Deflate=g,e.deflate=_,e.deflateRaw=y,e.gzip=m}),Sz=st((e,t)=>{"use strict";var i=30,r=12;t.exports=function(s,n){var a,o,l,h,c,d,f,u,p,g,_,y,m,O,b,v,E,T,P,A,C,M,H,k,F;a=s.state,o=s.next_in,k=s.input,l=o+(s.avail_in-5),h=s.next_out,F=s.output,c=h-(n-s.avail_out),d=h+(s.avail_out-257),f=a.dmax,u=a.wsize,p=a.whave,g=a.wnext,_=a.window,y=a.hold,m=a.bits,O=a.lencode,b=a.distcode,v=(1<<a.lenbits)-1,E=(1<<a.distbits)-1;e:do{m<15&&(y+=k[o++]<<m,m+=8,y+=k[o++]<<m,m+=8),T=O[y&v];t:for(;;){if(P=T>>>24,y>>>=P,m-=P,P=T>>>16&255,P===0)F[h++]=T&65535;else if(P&16){A=T&65535,P&=15,P&&(m<P&&(y+=k[o++]<<m,m+=8),A+=y&(1<<P)-1,y>>>=P,m-=P),m<15&&(y+=k[o++]<<m,m+=8,y+=k[o++]<<m,m+=8),T=b[y&E];i:for(;;){if(P=T>>>24,y>>>=P,m-=P,P=T>>>16&255,P&16){if(C=T&65535,P&=15,m<P&&(y+=k[o++]<<m,m+=8,m<P&&(y+=k[o++]<<m,m+=8)),C+=y&(1<<P)-1,C>f){s.msg="invalid distance too far back",a.mode=i;break e}if(y>>>=P,m-=P,P=h-c,C>P){if(P=C-P,P>p&&a.sane){s.msg="invalid distance too far back",a.mode=i;break e}if(M=0,H=_,g===0){if(M+=u-P,P<A){A-=P;do F[h++]=_[M++];while(--P);M=h-C,H=F}}else if(g<P){if(M+=u+g-P,P-=g,P<A){A-=P;do F[h++]=_[M++];while(--P);if(M=0,g<A){P=g,A-=P;do F[h++]=_[M++];while(--P);M=h-C,H=F}}}else if(M+=g-P,P<A){A-=P;do F[h++]=_[M++];while(--P);M=h-C,H=F}for(;A>2;)F[h++]=H[M++],F[h++]=H[M++],F[h++]=H[M++],A-=3;A&&(F[h++]=H[M++],A>1&&(F[h++]=H[M++]))}else{M=h-C;do F[h++]=F[M++],F[h++]=F[M++],F[h++]=F[M++],A-=3;while(A>2);A&&(F[h++]=F[M++],A>1&&(F[h++]=F[M++]))}}else if((P&64)===0){T=b[(T&65535)+(y&(1<<P)-1)];continue i}else{s.msg="invalid distance code",a.mode=i;break e}break}}else if((P&64)===0){T=O[(T&65535)+(y&(1<<P)-1)];continue t}else if(P&32){a.mode=r;break e}else{s.msg="invalid literal/length code",a.mode=i;break e}break}}while(o<l&&h<d);A=m>>3,o-=A,m-=A<<3,y&=(1<<m)-1,s.next_in=o,s.next_out=h,s.avail_in=o<l?5+(l-o):5-(o-l),s.avail_out=h<d?257+(d-h):257-(h-d),a.hold=y,a.bits=m}}),Iz=st((e,t)=>{"use strict";var i=gl(),r=15,s=852,n=592,a=0,o=1,l=2,h=[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],c=[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],d=[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],f=[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];t.exports=function(u,p,g,_,y,m,O,b){var v=b.bits,E=0,T=0,P=0,A=0,C=0,M=0,H=0,k=0,F=0,j=0,L,R,x,I,S,D=null,N=0,G,z=new i.Buf16(r+1),Z=new i.Buf16(r+1),se=null,he=0,pe,Se,q;for(E=0;E<=r;E++)z[E]=0;for(T=0;T<_;T++)z[p[g+T]]++;for(C=v,A=r;A>=1&&z[A]===0;A--);if(C>A&&(C=A),A===0)return y[m++]=1<<24|64<<16|0,y[m++]=1<<24|64<<16|0,b.bits=1,0;for(P=1;P<A&&z[P]===0;P++);for(C<P&&(C=P),k=1,E=1;E<=r;E++)if(k<<=1,k-=z[E],k<0)return-1;if(k>0&&(u===a||A!==1))return-1;for(Z[1]=0,E=1;E<r;E++)Z[E+1]=Z[E]+z[E];for(T=0;T<_;T++)p[g+T]!==0&&(O[Z[p[g+T]]++]=T);if(u===a?(D=se=O,G=19):u===o?(D=h,N-=257,se=c,he-=257,G=256):(D=d,se=f,G=-1),j=0,T=0,E=P,S=m,M=C,H=0,x=-1,F=1<<C,I=F-1,u===o&&F>s||u===l&&F>n)return 1;for(;;){pe=E-H,O[T]<G?(Se=0,q=O[T]):O[T]>G?(Se=se[he+O[T]],q=D[N+O[T]]):(Se=96,q=0),L=1<<E-H,R=1<<M,P=R;do R-=L,y[S+(j>>H)+R]=pe<<24|Se<<16|q|0;while(R!==0);for(L=1<<E-1;j&L;)L>>=1;if(L!==0?(j&=L-1,j+=L):j=0,T++,--z[E]===0){if(E===A)break;E=p[g+O[T]]}if(E>C&&(j&I)!==x){for(H===0&&(H=C),S+=P,M=E-H,k=1<<M;M+H<A&&(k-=z[M+H],!(k<=0));)M++,k<<=1;if(F+=1<<M,u===o&&F>s||u===l&&F>n)return 1;x=j&I,y[x]=C<<24|M<<16|S-m|0}}return j!==0&&(y[S+j]=E-H<<24|64<<16|0),b.bits=C,0}}),Pz=st(e=>{"use strict";var t=gl(),i=NI(),r=MI(),s=Sz(),n=Iz(),a=0,o=1,l=2,h=4,c=5,d=6,f=0,u=1,p=2,g=-2,_=-3,y=-4,m=-5,O=8,b=1,v=2,E=3,T=4,P=5,A=6,C=7,M=8,H=9,k=10,F=11,j=12,L=13,R=14,x=15,I=16,S=17,D=18,N=19,G=20,z=21,Z=22,se=23,he=24,pe=25,Se=26,q=27,X=28,ie=29,de=30,Ce=31,De=32,Fe=852,Pe=592,w=15,B=w;function V(me){return(me>>>24&255)+(me>>>8&65280)+((me&65280)<<8)+((me&255)<<24)}function Y(){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 t.Buf16(320),this.work=new t.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function W(me){var Me;return!me||!me.state?g:(Me=me.state,me.total_in=me.total_out=Me.total=0,me.msg="",Me.wrap&&(me.adler=Me.wrap&1),Me.mode=b,Me.last=0,Me.havedict=0,Me.dmax=32768,Me.head=null,Me.hold=0,Me.bits=0,Me.lencode=Me.lendyn=new t.Buf32(Fe),Me.distcode=Me.distdyn=new t.Buf32(Pe),Me.sane=1,Me.back=-1,f)}function ne(me){var Me;return!me||!me.state?g:(Me=me.state,Me.wsize=0,Me.whave=0,Me.wnext=0,W(me))}function ue(me,Me){var J,ze;return!me||!me.state||(ze=me.state,Me<0?(J=0,Me=-Me):(J=(Me>>4)+1,Me<48&&(Me&=15)),Me&&(Me<8||Me>15))?g:(ze.window!==null&&ze.wbits!==Me&&(ze.window=null),ze.wrap=J,ze.wbits=Me,ne(me))}function Re(me,Me){var J,ze;return me?(ze=new Y,me.state=ze,ze.window=null,J=ue(me,Me),J!==f&&(me.state=null),J):g}function Ue(me){return Re(me,B)}var je=!0,dt,Ot;function Lt(me){if(je){var Me;for(dt=new t.Buf32(512),Ot=new t.Buf32(32),Me=0;Me<144;)me.lens[Me++]=8;for(;Me<256;)me.lens[Me++]=9;for(;Me<280;)me.lens[Me++]=7;for(;Me<288;)me.lens[Me++]=8;for(n(o,me.lens,0,288,dt,0,me.work,{bits:9}),Me=0;Me<32;)me.lens[Me++]=5;n(l,me.lens,0,32,Ot,0,me.work,{bits:5}),je=!1}me.lencode=dt,me.lenbits=9,me.distcode=Ot,me.distbits=5}function hi(me,Me,J,ze){var mt,U=me.state;return U.window===null&&(U.wsize=1<<U.wbits,U.wnext=0,U.whave=0,U.window=new t.Buf8(U.wsize)),ze>=U.wsize?(t.arraySet(U.window,Me,J-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(mt=U.wsize-U.wnext,mt>ze&&(mt=ze),t.arraySet(U.window,Me,J-ze,mt,U.wnext),ze-=mt,ze?(t.arraySet(U.window,Me,J-ze,ze,0),U.wnext=ze,U.whave=U.wsize):(U.wnext+=mt,U.wnext===U.wsize&&(U.wnext=0),U.whave<U.wsize&&(U.whave+=mt))),0}function Q(me,Me){var J,ze,mt,U,Le,Ne,K,_e,Ae,ft,Ze,Ke,Ft,Ps,vt=0,bt,ki,_r,Ds,Jf,Zf,Or,un,Zr=new t.Buf8(4),ka,oa,e2=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!me||!me.state||!me.output||!me.input&&me.avail_in!==0)return g;J=me.state,J.mode===j&&(J.mode=L),Le=me.next_out,mt=me.output,K=me.avail_out,U=me.next_in,ze=me.input,Ne=me.avail_in,_e=J.hold,Ae=J.bits,ft=Ne,Ze=K,un=f;e:for(;;)switch(J.mode){case b:if(J.wrap===0){J.mode=L;break}for(;Ae<16;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(J.wrap&2&&_e===35615){J.check=0,Zr[0]=_e&255,Zr[1]=_e>>>8&255,J.check=r(J.check,Zr,2,0),_e=0,Ae=0,J.mode=v;break}if(J.flags=0,J.head&&(J.head.done=!1),!(J.wrap&1)||(((_e&255)<<8)+(_e>>8))%31){me.msg="incorrect header check",J.mode=de;break}if((_e&15)!==O){me.msg="unknown compression method",J.mode=de;break}if(_e>>>=4,Ae-=4,Or=(_e&15)+8,J.wbits===0)J.wbits=Or;else if(Or>J.wbits){me.msg="invalid window size",J.mode=de;break}J.dmax=1<<Or,me.adler=J.check=1,J.mode=_e&512?k:j,_e=0,Ae=0;break;case v:for(;Ae<16;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(J.flags=_e,(J.flags&255)!==O){me.msg="unknown compression method",J.mode=de;break}if(J.flags&57344){me.msg="unknown header flags set",J.mode=de;break}J.head&&(J.head.text=_e>>8&1),J.flags&512&&(Zr[0]=_e&255,Zr[1]=_e>>>8&255,J.check=r(J.check,Zr,2,0)),_e=0,Ae=0,J.mode=E;case E:for(;Ae<32;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.head&&(J.head.time=_e),J.flags&512&&(Zr[0]=_e&255,Zr[1]=_e>>>8&255,Zr[2]=_e>>>16&255,Zr[3]=_e>>>24&255,J.check=r(J.check,Zr,4,0)),_e=0,Ae=0,J.mode=T;case T:for(;Ae<16;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.head&&(J.head.xflags=_e&255,J.head.os=_e>>8),J.flags&512&&(Zr[0]=_e&255,Zr[1]=_e>>>8&255,J.check=r(J.check,Zr,2,0)),_e=0,Ae=0,J.mode=P;case P:if(J.flags&1024){for(;Ae<16;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.length=_e,J.head&&(J.head.extra_len=_e),J.flags&512&&(Zr[0]=_e&255,Zr[1]=_e>>>8&255,J.check=r(J.check,Zr,2,0)),_e=0,Ae=0}else J.head&&(J.head.extra=null);J.mode=A;case A:if(J.flags&1024&&(Ke=J.length,Ke>Ne&&(Ke=Ne),Ke&&(J.head&&(Or=J.head.extra_len-J.length,J.head.extra||(J.head.extra=new Array(J.head.extra_len)),t.arraySet(J.head.extra,ze,U,Ke,Or)),J.flags&512&&(J.check=r(J.check,ze,Ke,U)),Ne-=Ke,U+=Ke,J.length-=Ke),J.length))break e;J.length=0,J.mode=C;case C:if(J.flags&2048){if(Ne===0)break e;Ke=0;do Or=ze[U+Ke++],J.head&&Or&&J.length<65536&&(J.head.name+=String.fromCharCode(Or));while(Or&&Ke<Ne);if(J.flags&512&&(J.check=r(J.check,ze,Ke,U)),Ne-=Ke,U+=Ke,Or)break e}else J.head&&(J.head.name=null);J.length=0,J.mode=M;case M:if(J.flags&4096){if(Ne===0)break e;Ke=0;do Or=ze[U+Ke++],J.head&&Or&&J.length<65536&&(J.head.comment+=String.fromCharCode(Or));while(Or&&Ke<Ne);if(J.flags&512&&(J.check=r(J.check,ze,Ke,U)),Ne-=Ke,U+=Ke,Or)break e}else J.head&&(J.head.comment=null);J.mode=H;case H:if(J.flags&512){for(;Ae<16;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(_e!==(J.check&65535)){me.msg="header crc mismatch",J.mode=de;break}_e=0,Ae=0}J.head&&(J.head.hcrc=J.flags>>9&1,J.head.done=!0),me.adler=J.check=0,J.mode=j;break;case k:for(;Ae<32;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}me.adler=J.check=V(_e),_e=0,Ae=0,J.mode=F;case F:if(J.havedict===0)return me.next_out=Le,me.avail_out=K,me.next_in=U,me.avail_in=Ne,J.hold=_e,J.bits=Ae,p;me.adler=J.check=1,J.mode=j;case j:if(Me===c||Me===d)break e;case L:if(J.last){_e>>>=Ae&7,Ae-=Ae&7,J.mode=q;break}for(;Ae<3;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}switch(J.last=_e&1,_e>>>=1,Ae-=1,_e&3){case 0:J.mode=R;break;case 1:if(Lt(J),J.mode=G,Me===d){_e>>>=2,Ae-=2;break e}break;case 2:J.mode=S;break;case 3:me.msg="invalid block type",J.mode=de}_e>>>=2,Ae-=2;break;case R:for(_e>>>=Ae&7,Ae-=Ae&7;Ae<32;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if((_e&65535)!==(_e>>>16^65535)){me.msg="invalid stored block lengths",J.mode=de;break}if(J.length=_e&65535,_e=0,Ae=0,J.mode=x,Me===d)break e;case x:J.mode=I;case I:if(Ke=J.length,Ke){if(Ke>Ne&&(Ke=Ne),Ke>K&&(Ke=K),Ke===0)break e;t.arraySet(mt,ze,U,Ke,Le),Ne-=Ke,U+=Ke,K-=Ke,Le+=Ke,J.length-=Ke;break}J.mode=j;break;case S:for(;Ae<14;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(J.nlen=(_e&31)+257,_e>>>=5,Ae-=5,J.ndist=(_e&31)+1,_e>>>=5,Ae-=5,J.ncode=(_e&15)+4,_e>>>=4,Ae-=4,J.nlen>286||J.ndist>30){me.msg="too many length or distance symbols",J.mode=de;break}J.have=0,J.mode=D;case D:for(;J.have<J.ncode;){for(;Ae<3;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.lens[e2[J.have++]]=_e&7,_e>>>=3,Ae-=3}for(;J.have<19;)J.lens[e2[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,ka={bits:J.lenbits},un=n(a,J.lens,0,19,J.lencode,0,J.work,ka),J.lenbits=ka.bits,un){me.msg="invalid code lengths set",J.mode=de;break}J.have=0,J.mode=N;case N:for(;J.have<J.nlen+J.ndist;){for(;vt=J.lencode[_e&(1<<J.lenbits)-1],bt=vt>>>24,ki=vt>>>16&255,_r=vt&65535,!(bt<=Ae);){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(_r<16)_e>>>=bt,Ae-=bt,J.lens[J.have++]=_r;else{if(_r===16){for(oa=bt+2;Ae<oa;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(_e>>>=bt,Ae-=bt,J.have===0){me.msg="invalid bit length repeat",J.mode=de;break}Or=J.lens[J.have-1],Ke=3+(_e&3),_e>>>=2,Ae-=2}else if(_r===17){for(oa=bt+3;Ae<oa;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}_e>>>=bt,Ae-=bt,Or=0,Ke=3+(_e&7),_e>>>=3,Ae-=3}else{for(oa=bt+7;Ae<oa;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}_e>>>=bt,Ae-=bt,Or=0,Ke=11+(_e&127),_e>>>=7,Ae-=7}if(J.have+Ke>J.nlen+J.ndist){me.msg="invalid bit length repeat",J.mode=de;break}for(;Ke--;)J.lens[J.have++]=Or}}if(J.mode===de)break;if(J.lens[256]===0){me.msg="invalid code -- missing end-of-block",J.mode=de;break}if(J.lenbits=9,ka={bits:J.lenbits},un=n(o,J.lens,0,J.nlen,J.lencode,0,J.work,ka),J.lenbits=ka.bits,un){me.msg="invalid literal/lengths set",J.mode=de;break}if(J.distbits=6,J.distcode=J.distdyn,ka={bits:J.distbits},un=n(l,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,ka),J.distbits=ka.bits,un){me.msg="invalid distances set",J.mode=de;break}if(J.mode=G,Me===d)break e;case G:J.mode=z;case z:if(Ne>=6&&K>=258){me.next_out=Le,me.avail_out=K,me.next_in=U,me.avail_in=Ne,J.hold=_e,J.bits=Ae,s(me,Ze),Le=me.next_out,mt=me.output,K=me.avail_out,U=me.next_in,ze=me.input,Ne=me.avail_in,_e=J.hold,Ae=J.bits,J.mode===j&&(J.back=-1);break}for(J.back=0;vt=J.lencode[_e&(1<<J.lenbits)-1],bt=vt>>>24,ki=vt>>>16&255,_r=vt&65535,!(bt<=Ae);){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(ki&&(ki&240)===0){for(Ds=bt,Jf=ki,Zf=_r;vt=J.lencode[Zf+((_e&(1<<Ds+Jf)-1)>>Ds)],bt=vt>>>24,ki=vt>>>16&255,_r=vt&65535,!(Ds+bt<=Ae);){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}_e>>>=Ds,Ae-=Ds,J.back+=Ds}if(_e>>>=bt,Ae-=bt,J.back+=bt,J.length=_r,ki===0){J.mode=Se;break}if(ki&32){J.back=-1,J.mode=j;break}if(ki&64){me.msg="invalid literal/length code",J.mode=de;break}J.extra=ki&15,J.mode=Z;case Z:if(J.extra){for(oa=J.extra;Ae<oa;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.length+=_e&(1<<J.extra)-1,_e>>>=J.extra,Ae-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=se;case se:for(;vt=J.distcode[_e&(1<<J.distbits)-1],bt=vt>>>24,ki=vt>>>16&255,_r=vt&65535,!(bt<=Ae);){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if((ki&240)===0){for(Ds=bt,Jf=ki,Zf=_r;vt=J.distcode[Zf+((_e&(1<<Ds+Jf)-1)>>Ds)],bt=vt>>>24,ki=vt>>>16&255,_r=vt&65535,!(Ds+bt<=Ae);){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}_e>>>=Ds,Ae-=Ds,J.back+=Ds}if(_e>>>=bt,Ae-=bt,J.back+=bt,ki&64){me.msg="invalid distance code",J.mode=de;break}J.offset=_r,J.extra=ki&15,J.mode=he;case he:if(J.extra){for(oa=J.extra;Ae<oa;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}J.offset+=_e&(1<<J.extra)-1,_e>>>=J.extra,Ae-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){me.msg="invalid distance too far back",J.mode=de;break}J.mode=pe;case pe:if(K===0)break e;if(Ke=Ze-K,J.offset>Ke){if(Ke=J.offset-Ke,Ke>J.whave&&J.sane){me.msg="invalid distance too far back",J.mode=de;break}Ke>J.wnext?(Ke-=J.wnext,Ft=J.wsize-Ke):Ft=J.wnext-Ke,Ke>J.length&&(Ke=J.length),Ps=J.window}else Ps=mt,Ft=Le-J.offset,Ke=J.length;Ke>K&&(Ke=K),K-=Ke,J.length-=Ke;do mt[Le++]=Ps[Ft++];while(--Ke);J.length===0&&(J.mode=z);break;case Se:if(K===0)break e;mt[Le++]=J.length,K--,J.mode=z;break;case q:if(J.wrap){for(;Ae<32;){if(Ne===0)break e;Ne--,_e|=ze[U++]<<Ae,Ae+=8}if(Ze-=K,me.total_out+=Ze,J.total+=Ze,Ze&&(me.adler=J.check=J.flags?r(J.check,mt,Ze,Le-Ze):i(J.check,mt,Ze,Le-Ze)),Ze=K,(J.flags?_e:V(_e))!==J.check){me.msg="incorrect data check",J.mode=de;break}_e=0,Ae=0}J.mode=X;case X:if(J.wrap&&J.flags){for(;Ae<32;){if(Ne===0)break e;Ne--,_e+=ze[U++]<<Ae,Ae+=8}if(_e!==(J.total&4294967295)){me.msg="incorrect length check",J.mode=de;break}_e=0,Ae=0}J.mode=ie;case ie:un=u;break e;case de:un=_;break e;case Ce:return y;case De:default:return g}return me.next_out=Le,me.avail_out=K,me.next_in=U,me.avail_in=Ne,J.hold=_e,J.bits=Ae,(J.wsize||Ze!==me.avail_out&&J.mode<de&&(J.mode<q||Me!==h))&&hi(me,me.output,me.next_out,Ze-me.avail_out)?(J.mode=Ce,y):(ft-=me.avail_in,Ze-=me.avail_out,me.total_in+=ft,me.total_out+=Ze,J.total+=Ze,J.wrap&&Ze&&(me.adler=J.check=J.flags?r(J.check,mt,Ze,me.next_out-Ze):i(J.check,mt,Ze,me.next_out-Ze)),me.data_type=J.bits+(J.last?64:0)+(J.mode===j?128:0)+(J.mode===G||J.mode===x?256:0),(ft===0&&Ze===0||Me===h)&&un===f&&(un=m),un)}function ke(me){if(!me||!me.state)return g;var Me=me.state;return Me.window&&(Me.window=null),me.state=null,f}function Ge(me,Me){var J;return!me||!me.state||(J=me.state,(J.wrap&2)===0)?g:(J.head=Me,Me.done=!1,f)}function qe(me,Me){var J=Me.length,ze,mt,U;return!me||!me.state||(ze=me.state,ze.wrap!==0&&ze.mode!==F)?g:ze.mode===F&&(mt=1,mt=i(mt,Me,J,0),mt!==ze.check)?_:(U=hi(me,Me,J,J),U?(ze.mode=Ce,y):(ze.havedict=1,f))}e.inflateReset=ne,e.inflateReset2=ue,e.inflateResetKeep=W,e.inflateInit=Ue,e.inflateInit2=Re,e.inflate=Q,e.inflateEnd=ke,e.inflateGetHeader=Ge,e.inflateSetDictionary=qe,e.inflateInfo="pako inflate (from Nodeca project)"}),FI=st((e,t)=>{"use strict";t.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}}),Az=st((e,t)=>{"use strict";function i(){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}t.exports=i}),Cz=st(e=>{"use strict";var t=Pz(),i=gl(),r=BI(),s=FI(),n=yy(),a=kI(),o=Az(),l=Object.prototype.toString;function h(f){if(!(this instanceof h))return new h(f);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},f||{});var u=this.options;u.raw&&u.windowBits>=0&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),u.windowBits>=0&&u.windowBits<16&&!(f&&f.windowBits)&&(u.windowBits+=32),u.windowBits>15&&u.windowBits<48&&(u.windowBits&15)===0&&(u.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var p=t.inflateInit2(this.strm,u.windowBits);if(p!==s.Z_OK)throw new Error(n[p]);if(this.header=new o,t.inflateGetHeader(this.strm,this.header),u.dictionary&&(typeof u.dictionary=="string"?u.dictionary=r.string2buf(u.dictionary):l.call(u.dictionary)==="[object ArrayBuffer]"&&(u.dictionary=new Uint8Array(u.dictionary)),u.raw&&(p=t.inflateSetDictionary(this.strm,u.dictionary),p!==s.Z_OK)))throw new Error(n[p])}h.prototype.push=function(f,u){var p=this.strm,g=this.options.chunkSize,_=this.options.dictionary,y,m,O,b,v,E=!1;if(this.ended)return!1;m=u===~~u?u:u===!0?s.Z_FINISH:s.Z_NO_FLUSH,typeof f=="string"?p.input=r.binstring2buf(f):l.call(f)==="[object ArrayBuffer]"?p.input=new Uint8Array(f):p.input=f,p.next_in=0,p.avail_in=p.input.length;do{if(p.avail_out===0&&(p.output=new i.Buf8(g),p.next_out=0,p.avail_out=g),y=t.inflate(p,s.Z_NO_FLUSH),y===s.Z_NEED_DICT&&_&&(y=t.inflateSetDictionary(this.strm,_)),y===s.Z_BUF_ERROR&&E===!0&&(y=s.Z_OK,E=!1),y!==s.Z_STREAM_END&&y!==s.Z_OK)return this.onEnd(y),this.ended=!0,!1;p.next_out&&(p.avail_out===0||y===s.Z_STREAM_END||p.avail_in===0&&(m===s.Z_FINISH||m===s.Z_SYNC_FLUSH))&&(this.options.to==="string"?(O=r.utf8border(p.output,p.next_out),b=p.next_out-O,v=r.buf2string(p.output,O),p.next_out=b,p.avail_out=g-b,b&&i.arraySet(p.output,p.output,O,b,0),this.onData(v)):this.onData(i.shrinkBuf(p.output,p.next_out))),p.avail_in===0&&p.avail_out===0&&(E=!0)}while((p.avail_in>0||p.avail_out===0)&&y!==s.Z_STREAM_END);return y===s.Z_STREAM_END&&(m=s.Z_FINISH),m===s.Z_FINISH?(y=t.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===s.Z_OK):(m===s.Z_SYNC_FLUSH&&(this.onEnd(s.Z_OK),p.avail_out=0),!0)},h.prototype.onData=function(f){this.chunks.push(f)},h.prototype.onEnd=function(f){f===s.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function c(f,u){var p=new h(u);if(p.push(f,!0),p.err)throw p.msg||n[p.err];return p.result}function d(f,u){return u=u||{},u.raw=!0,c(f,u)}e.Inflate=h,e.inflate=c,e.inflateRaw=d,e.ungzip=c}),Lz=st((e,t)=>{"use strict";var i=gl().assign,r=Tz(),s=Cz(),n=FI(),a={};i(a,r,s,n),t.exports=a}),Dz=st(e=>{"use strict";var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=Lz(),r=hr(),s=Pn(),n=t?"uint8array":"array";e.magic="\b\0";function a(o,l){s.call(this,"FlateWorker/"+o),this._pako=null,this._pakoAction=o,this._pakoOptions=l,this.meta={}}r.inherits(a,s),a.prototype.processChunk=function(o){this.meta=o.meta,this._pako===null&&this._createPako(),this._pako.push(r.transformTo(n,o.data),!1)},a.prototype.flush=function(){s.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},a.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var o=this;this._pako.onData=function(l){o.push({data:l,meta:o.meta})}},e.compressWorker=function(o){return new a("Deflate",o)},e.uncompressWorker=function(){return new a("Inflate",{})}}),UI=st(e=>{"use strict";var t=Pn();e.STORE={magic:"\0\0",compressWorker:function(){return new t("STORE compression")},uncompressWorker:function(){return new t("STORE decompression")}},e.DEFLATE=Dz()}),GI=st(e=>{"use strict";e.LOCAL_FILE_HEADER="PK",e.CENTRAL_FILE_HEADER="PK",e.CENTRAL_DIRECTORY_END="PK",e.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",e.ZIP64_CENTRAL_DIRECTORY_END="PK",e.DATA_DESCRIPTOR="PK\x07\b"}),Rz=st((e,t)=>{"use strict";var i=hr(),r=Pn(),s=Mf(),n=my(),a=GI(),o=function(p,g){var _="",y;for(y=0;y<g;y++)_+=String.fromCharCode(p&255),p=p>>>8;return _},l=function(p,g){var _=p;return p||(_=g?16893:33204),(_&65535)<<16},h=function(p){return(p||0)&63},c=function(p,g,_,y,m,O){var b=p.file,v=p.compression,E=O!==s.utf8encode,T=i.transformTo("string",O(b.name)),P=i.transformTo("string",s.utf8encode(b.name)),A=b.comment,C=i.transformTo("string",O(A)),M=i.transformTo("string",s.utf8encode(A)),H=P.length!==b.name.length,k=M.length!==A.length,F,j,L="",R="",x="",I=b.dir,S=b.date,D={crc32:0,compressedSize:0,uncompressedSize:0};(!g||_)&&(D.crc32=p.crc32,D.compressedSize=p.compressedSize,D.uncompressedSize=p.uncompressedSize);var N=0;g&&(N|=8),!E&&(H||k)&&(N|=2048);var G=0,z=0;I&&(G|=16),m==="UNIX"?(z=798,G|=l(b.unixPermissions,I)):(z=20,G|=h(b.dosPermissions,I)),F=S.getUTCHours(),F=F<<6,F=F|S.getUTCMinutes(),F=F<<5,F=F|S.getUTCSeconds()/2,j=S.getUTCFullYear()-1980,j=j<<4,j=j|S.getUTCMonth()+1,j=j<<5,j=j|S.getUTCDate(),H&&(R=o(1,1)+o(n(T),4)+P,L+="up"+o(R.length,2)+R),k&&(x=o(1,1)+o(n(C),4)+M,L+="uc"+o(x.length,2)+x);var Z="";Z+=`
\0`,Z+=o(N,2),Z+=v.magic,Z+=o(F,2),Z+=o(j,2),Z+=o(D.crc32,4),Z+=o(D.compressedSize,4),Z+=o(D.uncompressedSize,4),Z+=o(T.length,2),Z+=o(L.length,2);var se=a.LOCAL_FILE_HEADER+Z+T+L,he=a.CENTRAL_FILE_HEADER+o(z,2)+Z+o(C.length,2)+"\0\0\0\0"+o(G,4)+o(y,4)+T+L+C;return{fileRecord:se,dirRecord:he}},d=function(p,g,_,y,m){var O="",b=i.transformTo("string",m(y));return O=a.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(p,2)+o(p,2)+o(g,4)+o(_,4)+o(b.length,2)+b,O},f=function(p){var g="";return g=a.DATA_DESCRIPTOR+o(p.crc32,4)+o(p.compressedSize,4)+o(p.uncompressedSize,4),g};function u(p,g,_,y){r.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=_,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(u,r),u.prototype.push=function(p){var g=p.meta.percent||0,_=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,r.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:_?(g+100*(_-y-1))/_:100}}))},u.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var g=this.streamFiles&&!p.file.dir;if(g){var _=c(p,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:_.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(p){this.accumulate=!1;var g=this.streamFiles&&!p.file.dir,_=c(p,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(_.dirRecord),g)this.push({data:f(p),meta:{percent:100}});else for(this.push({data:_.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var p=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var _=this.bytesWritten-p,y=d(this.dirRecords.length,_,p,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},u.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},u.prototype.registerPrevious=function(p){this._sources.push(p);var g=this;return p.on("data",function(_){g.processChunk(_)}),p.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),p.on("error",function(_){g.error(_)}),this},u.prototype.resume=function(){if(!r.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0},u.prototype.error=function(p){var g=this._sources;if(!r.prototype.error.call(this,p))return!1;for(var _=0;_<g.length;_++)try{g[_].error(p)}catch{}return!0},u.prototype.lock=function(){r.prototype.lock.call(this);for(var p=this._sources,g=0;g<p.length;g++)p[g].lock()},t.exports=u}),Nz=st(e=>{"use strict";var t=UI(),i=Rz(),r=function(s,n){var a=s||n,o=t[a];if(!o)throw new Error(a+" is not a valid compression method !");return o};e.generateWorker=function(s,n,a){var o=new i(n.streamFiles,a,n.platform,n.encodeFileName),l=0;try{s.forEach(function(h,c){l++;var d=r(c.options.compression,n.compression),f=c.options.compressionOptions||n.compressionOptions||{},u=c.dir,p=c.date;c._compressWorker(d,f).withStreamInfo("file",{name:h,dir:u,date:p,comment:c.comment||"",unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions}).pipe(o)}),o.entriesCount=l}catch(h){o.error(h)}return o}}),Mz=st((e,t)=>{"use strict";var i=hr(),r=Pn();function s(n,a){r.call(this,"Nodejs stream input adapter for "+n),this._upstreamEnded=!1,this._bindStream(a)}i.inherits(s,r),s.prototype._bindStream=function(n){var a=this;this._stream=n,n.pause(),n.on("data",function(o){a.push({data:o,meta:{percent:0}})}).on("error",function(o){a.isPaused?this.generatedError=o:a.error(o)}).on("end",function(){a.isPaused?a._upstreamEnded=!0:a.end()})},s.prototype.pause=function(){return r.prototype.pause.call(this)?(this._stream.pause(),!0):!1},s.prototype.resume=function(){return r.prototype.resume.call(this)?(this._upstreamEnded?this.end():this._stream.resume(),!0):!1},t.exports=s}),Bz=st((e,t)=>{"use strict";var i=Mf(),r=hr(),s=Pn(),n=CI(),a=LI(),o=by(),l=xz(),h=Nz(),c=wO(),d=Mz(),f=function(m,O,b){var v=r.getTypeOf(O),E,T=r.extend(b||{},a);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&T.unixPermissions&16384&&(T.dir=!0),T.dosPermissions&&T.dosPermissions&16&&(T.dir=!0),T.dir&&(m=p(m)),T.createFolders&&(E=u(m))&&g.call(this,E,!0);var P=v==="string"&&T.binary===!1&&T.base64===!1;(!b||typeof b.binary>"u")&&(T.binary=!P);var A=O instanceof o&&O.uncompressedSize===0;(A||T.dir||!O||O.length===0)&&(T.base64=!1,T.binary=!0,O="",T.compression="STORE",v="string");var C=null;O instanceof o||O instanceof s?C=O:c.isNode&&c.isStream(O)?C=new d(m,O):C=r.prepareContent(m,O,T.binary,T.optimizedBinaryString,T.base64);var M=new l(m,C,T);this.files[m]=M},u=function(m){m.slice(-1)==="/"&&(m=m.substring(0,m.length-1));var O=m.lastIndexOf("/");return O>0?m.substring(0,O):""},p=function(m){return m.slice(-1)!=="/"&&(m+="/"),m},g=function(m,O){return O=typeof O<"u"?O:a.createFolders,m=p(m),this.files[m]||f.call(this,m,null,{dir:!0,createFolders:O}),this.files[m]};function _(m){return Object.prototype.toString.call(m)==="[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(m){var O,b,v;for(O in this.files)v=this.files[O],b=O.slice(this.root.length,O.length),b&&O.slice(0,this.root.length)===this.root&&m(b,v)},filter:function(m){var O=[];return this.forEach(function(b,v){m(b,v)&&O.push(v)}),O},file:function(m,O,b){if(arguments.length===1)if(_(m)){var v=m;return this.filter(function(T,P){return!P.dir&&v.test(T)})}else{var E=this.files[this.root+m];return E&&!E.dir?E:null}else m=this.root+m,f.call(this,m,O,b);return this},folder:function(m){if(!m)return this;if(_(m))return this.filter(function(E,T){return T.dir&&m.test(E)});var O=this.root+m,b=g.call(this,O),v=this.clone();return v.root=b.name,v},remove:function(m){m=this.root+m;var O=this.files[m];if(O||(m.slice(-1)!=="/"&&(m+="/"),O=this.files[m]),O&&!O.dir)delete this.files[m];else for(var b=this.filter(function(E,T){return T.name.slice(0,m.length)===m}),v=0;v<b.length;v++)delete this.files[b[v].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(m){var O,b={};try{if(b=r.extend(m||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode}),b.type=b.type.toLowerCase(),b.compression=b.compression.toUpperCase(),b.type==="binarystring"&&(b.type="string"),!b.type)throw new Error("No output type specified.");r.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 v=b.comment||this.comment||"";O=h.generateWorker(this,b,v)}catch(E){O=new s("error"),O.error(E)}return new n(O,b.type||"string",b.mimeType)},generateAsync:function(m,O){return this.generateInternalStream(m).accumulate(O)},generateNodeStream:function(m,O){return m=m||{},m.type||(m.type="nodebuffer"),this.generateInternalStream(m).toNodejsStream(O)}};t.exports=y}),zI=st((e,t)=>{"use strict";var i=hr();function r(s){this.data=s,this.length=s.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(s){this.checkIndex(this.index+s)},checkIndex:function(s){if(this.length<this.zero+s||s<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+s+"). Corrupted zip ?")},setIndex:function(s){this.checkIndex(s),this.index=s},skip:function(s){this.setIndex(this.index+s)},byteAt:function(){},readInt:function(s){var n=0,a;for(this.checkOffset(s),a=this.index+s-1;a>=this.index;a--)n=(n<<8)+this.byteAt(a);return this.index+=s,n},readString:function(s){return i.transformTo("string",this.readData(s))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var s=this.readInt(4);return new Date(Date.UTC((s>>25&127)+1980,(s>>21&15)-1,s>>16&31,s>>11&31,s>>5&63,(s&31)<<1))}},t.exports=r}),HI=st((e,t)=>{"use strict";var i=zI(),r=hr();function s(n){i.call(this,n);for(var a=0;a<this.data.length;a++)n[a]=n[a]&255}r.inherits(s,i),s.prototype.byteAt=function(n){return this.data[this.zero+n]},s.prototype.lastIndexOfSignature=function(n){for(var a=n.charCodeAt(0),o=n.charCodeAt(1),l=n.charCodeAt(2),h=n.charCodeAt(3),c=this.length-4;c>=0;--c)if(this.data[c]===a&&this.data[c+1]===o&&this.data[c+2]===l&&this.data[c+3]===h)return c-this.zero;return-1},s.prototype.readAndCheckSignature=function(n){var a=n.charCodeAt(0),o=n.charCodeAt(1),l=n.charCodeAt(2),h=n.charCodeAt(3),c=this.readData(4);return a===c[0]&&o===c[1]&&l===c[2]&&h===c[3]},s.prototype.readData=function(n){if(this.checkOffset(n),n===0)return[];var a=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,a},t.exports=s}),kz=st((e,t)=>{"use strict";var i=zI(),r=hr();function s(n){i.call(this,n)}r.inherits(s,i),s.prototype.byteAt=function(n){return this.data.charCodeAt(this.zero+n)},s.prototype.lastIndexOfSignature=function(n){return this.data.lastIndexOf(n)-this.zero},s.prototype.readAndCheckSignature=function(n){var a=this.readData(4);return n===a},s.prototype.readData=function(n){this.checkOffset(n);var a=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,a},t.exports=s}),jI=st((e,t)=>{"use strict";var i=HI(),r=hr();function s(n){i.call(this,n)}r.inherits(s,i),s.prototype.readData=function(n){if(this.checkOffset(n),n===0)return new Uint8Array(0);var a=this.data.subarray(this.zero+this.index,this.zero+this.index+n);return this.index+=n,a},t.exports=s}),Fz=st((e,t)=>{"use strict";var i=jI(),r=hr();function s(n){i.call(this,n)}r.inherits(s,i),s.prototype.readData=function(n){this.checkOffset(n);var a=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,a},t.exports=s}),VI=st((e,t)=>{"use strict";var i=hr(),r=pl(),s=HI(),n=kz(),a=Fz(),o=jI();t.exports=function(l){var h=i.getTypeOf(l);return i.checkSupport(h),h==="string"&&!r.uint8array?new n(l):h==="nodebuffer"?new a(l):r.uint8array?new o(i.transformTo("uint8array",l)):new s(i.transformTo("array",l))}}),Uz=st((e,t)=>{"use strict";var i=VI(),r=hr(),s=by(),n=my(),a=Mf(),o=UI(),l=pl(),h=0,c=3,d=function(u){for(var p in o)if(Object.prototype.hasOwnProperty.call(o,p)&&o[p].magic===u)return o[p];return null};function f(u,p){this.options=u,this.loadOptions=p}f.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(u){var p,g;if(u.skip(22),this.fileNameLength=u.readInt(2),g=u.readInt(2),this.fileName=u.readData(this.fileNameLength),u.skip(g),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=d(this.compressionMethod),p===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,p,u.readData(this.compressedSize))},readCentralPart:function(u){this.versionMadeBy=u.readInt(2),u.skip(2),this.bitFlag=u.readInt(2),this.compressionMethod=u.readString(2),this.date=u.readDate(),this.crc32=u.readInt(4),this.compressedSize=u.readInt(4),this.uncompressedSize=u.readInt(4);var p=u.readInt(2);if(this.extraFieldsLength=u.readInt(2),this.fileCommentLength=u.readInt(2),this.diskNumberStart=u.readInt(2),this.internalFileAttributes=u.readInt(2),this.externalFileAttributes=u.readInt(4),this.localHeaderOffset=u.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");u.skip(p),this.readExtraFields(u),this.parseZIP64ExtraField(u),this.fileComment=u.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var u=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),u===h&&(this.dosPermissions=this.externalFileAttributes&63),u===c&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=i(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var p=u.index+this.extraFieldsLength,g,_,y;for(this.extraFields||(this.extraFields={});u.index+4<p;)g=u.readInt(2),_=u.readInt(2),y=u.readData(_),this.extraFields[g]={id:g,length:_,value:y};u.setIndex(p)},handleUTF8:function(){var u=l.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var g=r.transformTo(u,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var _=this.findExtraFieldUnicodeComment();if(_!==null)this.fileCommentStr=_;else{var y=r.transformTo(u,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var u=this.extraFields[28789];if(u){var p=i(u.value);return p.readInt(1)!==1||n(this.fileName)!==p.readInt(4)?null:a.utf8decode(p.readData(u.length-5))}return null},findExtraFieldUnicodeComment:function(){var u=this.extraFields[25461];if(u){var p=i(u.value);return p.readInt(1)!==1||n(this.fileComment)!==p.readInt(4)?null:a.utf8decode(p.readData(u.length-5))}return null}},t.exports=f}),Gz=st((e,t)=>{"use strict";var i=VI(),r=hr(),s=GI(),n=Uz(),a=pl();function o(l){this.files=[],this.loadOptions=l}o.prototype={checkSignature:function(l){if(!this.reader.readAndCheckSignature(l)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(h)+", expected "+r.pretty(l)+")")}},isSignature:function(l,h){var c=this.reader.index;this.reader.setIndex(l);var d=this.reader.readString(4),f=d===h;return this.reader.setIndex(c),f},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 l=this.reader.readData(this.zipCommentLength),h=a.uint8array?"uint8array":"array",c=r.transformTo(h,l);this.zipComment=this.loadOptions.decodeFileName(c)},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 l=this.zip64EndOfCentralSize-44,h=0,c,d,f;h<l;)c=this.reader.readInt(2),d=this.reader.readInt(4),f=this.reader.readData(d),this.zip64ExtensibleData[c]={id:c,length:d,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var l,h;for(l=0;l<this.files.length;l++)h=this.files[l],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var l;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)l=new n({zip64:this.zip64},this.loadOptions),l.readCentralPart(this.reader),this.files.push(l);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 l=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(l<0){var h=!this.isSignature(0,s.LOCAL_FILE_HEADER);throw h?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"):new Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(l);var c=l;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,l=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),l<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(l),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.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(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var f=c-d;if(f>0)this.isSignature(c,s.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(l){this.reader=i(l)},load:function(l){this.prepareReader(l),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=o}),zz=st((e,t)=>{"use strict";var i=hr(),r=Nf(),s=Mf(),n=Gz(),a=RI(),o=wO();function l(h){return new r.Promise(function(c,d){var f=h.decompressed.getContentWorker().pipe(new a);f.on("error",function(u){d(u)}).on("end",function(){f.streamInfo.crc32!==h.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):c()}).resume()})}t.exports=function(h,c){var d=this;return c=i.extend(c||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),o.isNode&&o.isStream(h)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",h,!0,c.optimizedBinaryString,c.base64).then(function(f){var u=new n(c);return u.load(f),u}).then(function(f){var u=[r.Promise.resolve(f)],p=f.files;if(c.checkCRC32)for(var g=0;g<p.length;g++)u.push(l(p[g]));return r.Promise.all(u)}).then(function(f){for(var u=f.shift(),p=u.files,g=0;g<p.length;g++){var _=p[g],y=_.fileNameStr,m=i.resolve(_.fileNameStr);d.file(m,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:c.createFolders}),_.dir||(d.file(m).unsafeOriginalName=y)}return u.zipComment.length&&(d.comment=u.zipComment),d})}}),YI=st((e,t)=>{"use strict";function i(){if(!(this instanceof i))return new i;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 r=new i;for(var s in this)typeof this[s]!="function"&&(r[s]=this[s]);return r}}i.prototype=Bz(),i.prototype.loadAsync=zz(),i.support=pl(),i.defaults=LI(),i.version="3.10.1",i.loadAsync=function(r,s){return new i().loadAsync(r,s)},i.external=Nf(),t.exports=i});var oS={mil:1,inch:1e3,ft:12e3,yard:36e3,mile:6336e4,km:3937007874e-2,dm:3937,mm:39.37,um:.039,nm:394e-7,pt:13.88888888888889,"px(72)":13.88888888888889,"px(96)":10.416666666666666,"px(100)":10},cse=(()=>{let e={};for(let t in oS)e[oS[t]]=t;return e})(),lS=class{constructor(t,i){this.ratio=t/i}wrap(t){return t*this.ratio}static convert(t,i,r){return t*i/r}};lS.ASIS=new lS(1,1);var Bf=class{conversion(e,t,i){if(e===t)return i;let r=e+2+t;return this[r](i)}conversion1(e,t,i){let r=e+2+t,s=this[r](i);return t=="mil"?Math.round(s*10)/10:Math.round(s*1e3)/1e3}mil2mil(e){return e}mil2mm(e){return e*.0254}mil2cm(e){return e*.00254}mil2inch(e){return e/1e3}mm2mm(e){return e}mm2mil(e){let t=Math.pow(10,5);return Math.round(e*39.37007874015748*t)/t}mm2cm(e){return e/10}mm2inch(e){let t=Math.pow(10,8);return Math.round(e*.03937007874015748*t)/t}cm2mil(e){let t=Math.pow(10,6);return Math.round(e*393.7007874015748*t)/t}cm2mm(e){return e*10}cm2inch(e){let t=Math.pow(10,7);return Math.round(e*.3937007874015748*t)/t}inch2mil(e){return e*1e3}inch2mm(e){return e*25.4}inch2cm(e){return e*2.54}};Bf.prototype["px(100)2mil"]=e=>e*10;Bf.prototype["px(100)2mm"]=e=>e*.254;Bf.prototype["mil2px(100)"]=e=>e/10;Bf.prototype["mm2px(100)"]=e=>{let t=Math.pow(10,5);return Math.round(e*3.937007874015748*t)/t};var N_=null,vy=new ArrayBuffer(8),wb=new Float64Array(vy),Tb=new Uint32Array(vy),hS=new Uint16Array(vy),In=Math.PI*2,Io=Math.PI/2,cS=class{static repeat(e,t){let i=new Array(t);for(;t-- >0;)i[t]=e;return i.join("")}static lpad(e,t,i){let r=i-e.length;return r>0?this.repeat(t,r)+e:e}static rpad(e,t,i){let r=i-e.length;return r>0?e+this.repeat(t,r):e}static strHashcode(e){if(e.length>0){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)|0;return t}else return 0}static arraycopy(e,t,i,r,s){if(e.length>=t+s&&i.length>=r+s)for(;s-- >0;)i[r++]=e[t++];else throw new Error("arraycopy out of range")}static undefAsNull(e){return null}static reverse(e,t){for(let i=0,r=e.length-1;r>=0;i++,r--)t[i]=e[r];return t}static sortAsc(e,t){return e-t}static xmlDecode(e){let t=e.length,i=new Array,r=-1;for(let s=0;s<t;s++){let n=e.charAt(s);if(r>=0){if(n===";"){let a=e.substring(r+1,s);switch(a){case"lt":i.push("<");break;case"gt":i.push(">");break;case"quot":i.push('"');break;case"apos":i.push("'");break;case"amp":i.push("&");break;default:if(a.charAt(0)==="#"){let o=parseInt(a.substring(1));i.push(String.fromCharCode(o))}else i.push("&"+a+";")}r=-1}}else n==="&"?r=s:i.push(n)}return r>=0&&i.push(e.substring(r)),i.join("")}static addAll(e,t){for(let i of t)e.push(i)}static addAllSet(e,t){for(let i of t)e.add(i)}static contains(e,t){for(let i of e)if(i.equals(t))return!0;return!1}static equals(e,t){if(e.length==t.length){for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}else return!1}static remove(e,t){let i=0,r=e.length;for(let s=0;s<r;s++)e[s]===t&&(e.splice(s,1),s--,r--,i++);return i}static getUrlVars(){for(var e={},t=location.href.slice(location.href.indexOf("?")+1).split("&"),i=0;i<t.length;i++){var r=t[i].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}static prefix(){if(!N_){let e=this.getUrlVars().version;e?N_="/analyzer/v"+e:N_="/analyzer"}return N_}static add2objS(e,t,i){if(t in e)return e[t];{let r=i(t);return e[t]=r,r}}static downloadFile(e,t){let i=document.createElement("a"),r=URL.createObjectURL(t);i.download=e,i.href=r,i.click(),URL.revokeObjectURL(r)}static uuid(){let e=new Array;wb[0]=new Date().getTime(),e.push(Tb[1].toString(16)),wb[0]=Math.random(),e.push(hS[3].toString(16));let t=hS[2].toString(16);e.push("4"+t.substr(0,3)),wb[0]=performance.now();let i=Tb[0].toString(16)+Tb[1].toString(16);return e.push("0"+i.substr(0,3)),e.push(i.substr(3)),e.join("-")}static funcCopy(e){return(0,eval)("("+e.toString()+")")}static NVL(...e){for(let t of e)if(t!==null)return t;return null}static isSingle(e){return Array.from(new Set(e)).length===e.length}},Hz=[1,10,100,1e3];function uS(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=Hz[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}function jz(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global}var Vz=/(\.?0+)$/,M_=class{static format(e,...t){return this.format1(e,t)}static format1(e,t){let i=this._format(e,t);if(typeof i=="string")return i;throw new Error(this.format("Invalid state on (%d) %s",i,e))}static _format(e,t){let i=[],r=0,s=0,n,a=0,o=0;for(let l=0;l<e.length;l++){let h=e.charAt(l),c=h.charCodeAt(0);switch(r){case 0:c===37?r=1:i.push(h);break;case 1:switch(c){case 100:if(n=t[s++],typeof n=="number")i.push(n.toFixed(0)),r=0;else return l;break;case 102:if(n=t[s++],typeof n=="number")i.push(n.toString()),r=0;else return l;break;case 120:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16)),r=0;else return l;break;case 88:if(n=t[s++],typeof n=="number")i.push((n|0).toString(16).toUpperCase()),r=0;else return l;break;case 115:case 99:n=t[s++],i.push(n===null?"null":n.toString()),r=0;break;case 48:a=l+1,o=-1,r=2;break;case 37:i.push("%"),r=0;break;default:return l}break;case 2:switch(c){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:o=l;break;case 120:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(cS.lpad((n|0).toString(16),"0",d)),r=0;else return l}else return l;break;case 88:if(o>=a){let d=parseInt(e.substring(a,o+1));if(n=t[s++],typeof n=="number")i.push(cS.lpad((n|0).toString(16).toUpperCase(),"0",d)),r=0;else return l}else return l;break;default:return l}break;default:return l}}return i.join("")}static startsWith(e,t){return e.length>=t.length?e.substring(0,t.length)===t:!1}static endsWith(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}static split(e,t){let i=new Array,r=0;for(;;){let s=e.exec(t);if(s!==null){let n=e.lastIndex-s[0].length;i.push(t.substring(r,n)),r=e.lastIndex}else{let n=t.substring(r);uO.nullOrEmpty(n)||i.push(n);break}}return i}static fmtNumber(e){return e.toFixed(5).replace(Vz,"")}},uO=class{static rgb(e){if(0<=e&&e<=255)return e;throw new Error(M_.format("RGB should not nagative and not over 255(0xFF): %X",e))}static normal(e){if(isFinite(e))return e;throw new Error(M_.format("%f is not permitted",e))}static positiveOr0(e){if(e>=0)return e;throw new Error(M_.format("%f must >= 0",e))}static positive(e){if(e>0)return e;throw new Error(M_.format("%f must > 0",e))}static notnull(e){if(e!=null)return e;throw new Error("invalid null value")}static mustnull(e){if(e===null)return null;throw new Error("value must be null")}static notEmpty(e){if(e==null||e.length===0)throw new Error("invalid empty string");return e}static nullOrEmpty(e){return e==null||e.length===0}static notNullOrUndef(e){if(e!=null)return e;throw new Error("null or undefined is not permitted")}},oi=class Es{static build(t,i,r,s=1){let n=this.getHash(t,i,r,s),a=this._colorCache[n];return a||(a=new Es(t,i,r,s),this._colorCache[n]=a),a}static getHash(t,i,r,s=1){return 31*(31*(31*t+i)+r)+s}static isHexFormate(t){return!t||typeof t!="string"?!1:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}static of1(t){return this.of2(t>>16&255,t>>8&255,t&255)}static of2(t,i,r,s=255){return Es.build(t/255,i/255,r/255,s/255)}static of3(t){t.startsWith("#")&&(t=t.substr(1));let i=t.length;if(i==3)return Es.build(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15);if(i==6)return Es.build(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255);if(i==8)return Es.build(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,parseInt(t.substr(6,2),16)/255);throw new Error("invalid color string")}static of4(t){let i=parseInt(t.r*255+"").toString(16),r=parseInt(t.g*255+"").toString(16),s=parseInt(t.b*255+"").toString(16);return i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),s.length<2&&(s="0"+s),("#"+i+r+s).toUpperCase()}static of5(t,i){if(t.startsWith("#")&&(t=t.substr(1)),t.length==3)return Es.build(parseInt(t[0],16)/15,parseInt(t[1],16)/15,parseInt(t[2],16)/15,i);if(t.length==6)return Es.build(parseInt(t.substr(0,2),16)/255,parseInt(t.substr(2,2),16)/255,parseInt(t.substr(4,2),16)/255,i);throw new Error("invalid color string")}static of6(t,i){return Es.build(t.r,t.g,t.b,i)}static of7(t){return t==null?null:Es.of3(t)}static ofNew(t){return Es.build(t.r,t.g,t.b,t.alpha)}constructor(t,i,r,s=1){this.r=uO.positiveOr0(t),this.g=uO.positiveOr0(i),this.b=uO.positiveOr0(r),this.alpha=s}mulAlpha(t){return new Es(this.r,this.g,this.b,this.alpha*t)}hashCode(){return Es.getHash(this.r,this.g,this.b,this.alpha)}equals(t,i=!1){if(!t)return!1;let r=this.r===t.r&&this.g===t.g&&this.b===t.b;return i?r:r&&this.alpha===t.alpha}add(t,i,r,s){return Es.build(Math.max(0,Math.min(1,this.r+t)),Math.max(0,Math.min(1,this.g+i)),Math.max(0,Math.min(1,this.b+r)),Math.max(0,Math.min(1,this.alpha+s)))}mul(t){return Es.build(Math.max(0,Math.min(1,this.r*t)),Math.max(0,Math.min(1,this.g*t)),Math.max(0,Math.min(1,this.b*t)),this.alpha)}mul1(t){return Es.build(Math.max(0,this.r*t),Math.max(0,this.g*t),Math.max(0,this.b*t),this.alpha)}getData(){return[this.r,this.g,this.b,this.alpha]}toString(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)}toString1(){let t=(this.r*255).toString(16),i=(this.g*255).toString(16),r=(this.b*255).toString(16),s=(this.alpha*255).toString(16);return t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),r.length<2&&(r="0"+r),s.length<2&&(s="0"+s),"#"+t.substr(0,2)+i.substr(0,2)+r.substr(0,2)+s.substr(0,2)}toRGBA(){let t=this.r*255,i=this.g*255,r=this.b*255;return[t,i,r,this.alpha]}toRGBAString(){let t=this.r*255,i=this.g*255,r=this.b*255;return`rgba(${t},${i},${r},${this.alpha})`}isWHITE(){return this.r===1&&this.g===1&&this.b===1&&this.alpha===1}toCSS(){return`rgba(${this.r*255}, ${this.g*255}, ${this.b*255}, ${this.alpha})`}};oi._colorCache={},oi.WHITE=oi.build(1,1,1,1),oi.BLACK=oi.build(0,0,0,1),oi.RED=oi.build(1,0,0,1),oi.GREEN=oi.build(0,1,0,1),oi.BLUE=oi.build(0,0,1,1),oi.Gray=oi.of3("#9966ff"),oi.Silver=oi.of3("#D2D2D2"),oi.Golden=oi.of3("#DCAA14"),oi.DefaultHighLightColor=oi.build(1,1,1,.5),oi.YELLOW=new oi(1,1,0,1),oi.PURPLE=new oi(1,0,1,1),oi.CYAN=new oi(0,1,1,1),oi.LightGray=oi.of3("#d9d9d9"),oi.ZERO=new oi(0,0,0,0),oi.ORANGE=oi.of3("#ffa500"),oi.AMARANTH=oi.of3("#ff00ff");var rr=oi,Ct=10,xy=7,gse=2**xy-1<<Ct,_se=2**Ct-1,Rt=1<<Ct+xy,dS=2**32-1-Rt,cr=class{constructor(e,t,i){this.DataIndex=i,this.length=t,fS[e]=t,Yz[e]=(r,s,n,a)=>this.getBBox(r,s,n,a),Kz[e]=(r,s)=>this.compare(r,s),qz[e]=(r,s,n)=>this.getOrder(r,s,n),Xz[e]=(r,s,n)=>this.getGroupIdByBuilder(r,s,n),Wz[e]=(r,s,n)=>this.getGroupId(r,s,n),Jz[e]=(r,s,n)=>this.getTemplateId(r,s,n),Zz[e]=(r,s,n)=>this.getColorIndex(r,s,n),$z[e]=this,this.type=e}updateLength(e,t){this.length=e,fS[t]=e}compare(e,t){if((e[0]&dS)!==(t[0]&dS))return!1;for(let i=1;i<this.length;i++)if(e[i]!==t[i])return!1;return!0}createBBox(e,t,i,r){let s=this.getBBox(e,t,i,r);return new Pi(s.minX,s.maxX,s.minY,s.maxY)}getOrder(e,t,i){if(!this.DataIndex.ORDER)throw new Error("GetOrder error ");return e[t+this.DataIndex.ORDER]}getGroupIdByBuilder(e,t,i){if(!this.DataIndex.GROUP_ID)throw new Error("GetGroupId error ");return e.get(t+this.DataIndex.GROUP_ID)}getGroupId(e,t,i){if(!this.DataIndex.GROUP_ID)throw new Error("GetGroupId error ");return e[t+this.DataIndex.GROUP_ID]}getTemplateId(e,t,i){if(!this.DataIndex.TEMPLATE)throw new Error("GetTemplateId error ");return e[t+this.DataIndex.TEMPLATE]}getColorIndex(e,t,i){if(!this.DataIndex.COLOR_INDEX)throw new Error("GetColorIndex error ");return e[t+this.DataIndex.COLOR_INDEX]}},fS=new Float64Array(70),Yz=[],qz=[],Wz=[],Xz=[],Jz=[],Zz=[],Kz=[],$z=[];var Qz=[];function _h(e,t){Qz.push(e,t)}var fl=12;var eH=class{constructor(){this._minX=0,this._maxX=0,this._minY=0,this._maxY=0}modify(e,t,i,r){return this._minX=e,this._maxX=t,this._minY=i,this._maxY=r,this}get minX(){return this._minX}get maxX(){return this._maxX}get minY(){return this._minY}get maxY(){return this._maxY}modify1(e){return this._minX=e.minX,this._maxX=e.maxX,this._minY=e.minY,this._maxY=e.maxY,this}center(){return new ae(this.maxX-(this.maxX-this.minX)/2,this.maxY-(this.maxY-this.minY)/2)}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}UL(){return new ae(this.minX,this.maxY)}UR(){return new ae(this.maxX,this.maxY)}LL(){return new ae(this.minX,this.minY)}LR(){return new ae(this.maxX,this.minY)}transform4(e){let t=new yi;return t.ext2(this.LL().multiply4(e)),t.ext2(this.LR().multiply4(e)),t.ext2(this.UR().multiply4(e)),t.ext2(this.UL().multiply4(e)),t.build()}build(){return new Pi(this.minX,this.maxX,this.minY,this.maxY)}},Kt=new eH;var B_=512,pS="#000000",gS="#000000",_S=[1,0,0,1,0,0],OS="10px sans-serif",tH=class{constructor(e){this.stateStack=[],this.operateStack=[],this.transformMatrix=_S,this.fillStyle=pS,this.strokeStyle=gS,this.font=OS,this.context=e}getContext(){return this.context}originSave(){this.context.save()}originRestore(){this.context.restore(),this.reset()}reset(){delete this.lastState,delete this.lastOperate,this.transformMatrix=_S,this.fillStyle=pS,this.strokeStyle=gS,this.font=OS}save(){this.lastState={},this.stateStack.push(this.lastState),this.lastOperate=[],this.operateStack.push(this.lastOperate)}restore(){let e=Object.keys(this.lastState).filter(i=>i==="transform");for(let i in this.lastState){let r=this.lastState[i];switch(i){case"transform":{this.context.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transformMatrix=r;break}case"lineDash":{this.context.setLineDash(r);break}default:{switch(i){case"fillStyle":{this.fillStyle=r;break}case"strokeStyle":{this.strokeStyle=r;break}case"font":{this.font=r;break}}this.context[i]=r}}}let t=[];if(!e.length)for(let i of this.lastOperate.reverse())if(typeof i=="string")switch(i){case"translate":{this.context.translate(t[1],t[0]),t=[];break}case"rotate":{this.context.rotate(t[0]),t=[];break}case"scale":{this.context.scale(t[1],t[0]),t=[];break}}else t.push(i);this.stateStack.pop(),this.lastState=this.stateStack[this.stateStack.length-1],this.operateStack.pop(),this.lastOperate=this.operateStack[this.operateStack.length-1]}setFillStyle(e){e!==this.fillStyle&&(this.lastState&&this.lastState.fillStyle===void 0&&(this.lastState.fillStyle=this.fillStyle),this.fillStyle=e,this.context.fillStyle=e)}setStrokeStyle(e){e!==this.strokeStyle&&(this.lastState&&this.lastState.strokeStyle===void 0&&(this.lastState.strokeStyle=this.strokeStyle),this.strokeStyle=e,this.context.strokeStyle=e)}setLineCap(e){e!==this.context.lineCap&&(this.lastState&&this.lastState.lineCap===void 0&&(this.lastState.lineCap=this.context.lineCap),this.context.lineCap=e)}setTranslate(e,t){var i;(i=this.lastOperate)==null||i.push("translate",-e,-t),this.context.translate(e,t)}setRotate(e){var t;(t=this.lastOperate)==null||t.push("rotate",-e),this.context.rotate(e)}setScale(e,t){var i;(i=this.lastOperate)==null||i.push("scale",1/e,1/t),this.context.scale(e,t)}setTransform(e){this.lastState&&this.lastState.transform===void 0&&(this.lastState.transform=this.transformMatrix),this.transformMatrix=[e[0],e[1],e[2],e[3],e[4],e[5]],this.context.setTransform(e[0],e[1],e[2],e[3],e[4],e[5])}setLineDash(e){let t=this.context.getLineDash();JSON.stringify(e)!==JSON.stringify(t)&&(this.lastState&&this.lastState.lineDash===void 0&&(this.lastState.lineDash=t),this.context.setLineDash(e))}setLineWidth(e){e!==this.context.lineWidth&&(this.lastState&&this.lastState.lineWidth===void 0&&(this.lastState.lineWidth=this.context.lineWidth),this.context.lineWidth=e)}setTextAlign(e){e!==this.context.textAlign&&(this.lastState&&this.lastState.textAlign===void 0&&(this.lastState.textAlign=this.context.textAlign),this.context.textAlign=e)}setTextBaseLine(e){e!==this.context.textBaseline&&(this.lastState&&this.lastState.textBaseline===void 0&&(this.lastState.textBaseline=this.context.textBaseline),this.context.textBaseline=e)}setFont(e){e!==this.font&&(this.lastState&&this.lastState.font===void 0&&(this.lastState.font=this.font),this.font=e,this.context.font=e)}setGlobalAlpha(e){e!==this.context.globalAlpha&&(this.lastState&&this.lastState.globalAlpha===void 0&&(this.lastState.globalAlpha=this.context.globalAlpha),this.context.globalAlpha=e)}setShadowBlur(e){e!==this.context.shadowBlur&&(this.lastState&&this.lastState.shadowBlur===void 0&&(this.lastState.shadowBlur=this.context.shadowBlur),this.context.shadowBlur=e)}setShadowColor(e){e!==this.context.shadowColor&&(this.lastState&&this.lastState.shadowColor===void 0&&(this.lastState.shadowColor=this.context.shadowColor),this.context.shadowColor=e)}setShadowOffsetX(e){e!==this.context.shadowOffsetX&&(this.lastState&&this.lastState.shadowOffsetX===void 0&&(this.lastState.shadowOffsetX=this.context.shadowOffsetX),this.context.shadowOffsetX=e)}setShadowOffsetY(e){e!==this.context.shadowOffsetY&&(this.lastState&&this.lastState.shadowOffsetY===void 0&&(this.lastState.shadowOffsetY=this.context.shadowOffsetY),this.context.shadowOffsetY=e)}setGlobalCompositeOperation(e){e!==this.context.globalCompositeOperation&&(this.lastState&&this.lastState.globalCompositeOperation===void 0&&(this.lastState.globalCompositeOperation=this.context.globalCompositeOperation),this.context.globalCompositeOperation=e)}};var iH="Consolas, SimHei";var qI=64,rH=qI*2;var sH=["L","P","V","S","H","K","O","C","W","N","D","I"],bse=sH.length*qI*rH;var k_=.5,lh=Math.sqrt(.5),yse=1-(Math.acos(k_/lh)*lh*lh-k_*Math.sqrt(lh*lh-k_*k_))/Math.PI/(lh*lh);var nH=4,aH=2**30/nH,vse=aH/2,xse=2**(2**7-1),Ese=2**31-1;var ry="sans-serif";function Sb(e,t){return`${e["font-style"]||"normal"} ${e["font-weight"]||"normal"} ${`${t||parseFloat(e["font-size"])||10}px`} "${e["font-family"]}", ${ry}`}var oH=class Tf{constructor(){this.lastFontStyleString="",this.lastRatio=0,this.ctx=new tH(document.createElement("canvas").getContext("2d")),this.recordFontFamily=new Map}static getInstance(){return Tf.instance==null&&(Tf.instance=new Tf),Tf.instance}isFontApplied(t,i,r){let s=t.getContext().font.toLowerCase();return s.includes(i.toString())&&r.split(",").some(n=>(n=n.trim(),n=n.replace(/^['"]|['"]$/g,""),s.includes(n.toLowerCase())))}getApplyFontFamily(t,i){if(!i)return t;let r=this.recordFontFamily.get(t);if(r)return r;let s=ry;return this.ctx.setFont(`${B_}px "${t}"`),this.isFontApplied(this.ctx,B_,t)&&(s=t),this.ctx.setFont(`10px ${ry}`),this.recordFontFamily.set(t,s),s}getTextInfo(t,i,r=!0,s=!0){if(i["font-family"]=this.getApplyFontFamily(i["font-family"],s),this.ctx.setTextBaseLine("bottom"),!r)return this.getTextInfoDisableCorrection(t,i);let n=parseFloat(i["font-size"]),a=JSON.stringify(i);if(!this.lastFontStyleString||!this.lastRatio||a!==this.lastFontStyleString){let h=Sb(i,B_);this.ctx.setFont(h);let c=this.ctx.getContext().measureText(t),d=Math.abs(c.fontBoundingBoxAscent)+Math.abs(c.fontBoundingBoxDescent);this.lastRatio=B_/d,this.lastFontStyleString=a}let o=n*this.lastRatio,l=Sb(i,o);return this.ctx.setFont(l),{width:this.ctx.getContext().measureText(t).width,height:n,fontFamily:i["font-family"],renderFontSize:o}}getTextInfoDisableCorrection(t,i){let r=parseFloat(i["font-size"]),s=Sb(i,r);this.ctx.setFont(s);let n=this.ctx.getContext().measureText(t);return{width:n.width,height:Math.abs(n.fontBoundingBoxAscent)+Math.abs(n.fontBoundingBoxDescent),fontFamily:i["font-family"],renderFontSize:r}}};oH.instance=null;var WI=class{};WI.value=null;function mS(e,t,i){return{x:t*e[0]+i*e[3]+e[6],y:t*e[1]+i*e[4]+e[7]}}function Yt(e,t,i){return{x:e*Math.cos(i)-t*Math.sin(i),y:e*Math.sin(i)+t*Math.cos(i)}}function bS(e,t,i,r){return{x:e*i,y:t*r}}var lH=Io*3,Ey=(e=>(e[e.ID=0]="ID",e[e.POSITION_X=1]="POSITION_X",e[e.POSITION_Y=2]="POSITION_Y",e[e.WIDTH=3]="WIDTH",e[e.HEIGHT=4]="HEIGHT",e[e.ANGLE=5]="ANGLE",e[e.STRING_LENGTH=6]="STRING_LENGTH",e[e.STRING_INDEX=7]="STRING_INDEX",e[e.MAX_PX_HEIGHT=8]="MAX_PX_HEIGHT",e[e.LIMIT_MAX=9]="LIMIT_MAX",e[e.GROUP_ID=10]="GROUP_ID",e[e.COLOR_INDEX=11]="COLOR_INDEX",e[e.ORDER=12]="ORDER",e[e.WIDTH_OFFSET_RATIO=13]="WIDTH_OFFSET_RATIO",e[e.HEIGHT_OFFSET_RATIO=14]="HEIGHT_OFFSET_RATIO",e[e.TEMPLATE_ID=15]="TEMPLATE_ID",e))(Ey||{}),XI=15,Fr=[],JI=class extends cr{create(e,t,i,r,s,n,a,o,l,h=-1,c,d,f,u){return Fr[0]=e+(10<<Ct)+Rt,Fr[1]=t.x,Fr[2]=t.y,Fr[3]=i,Fr[4]=r,Fr[5]=(s%In+In)%In,Fr[6]=n,Fr[7]=a,Fr[8]=r/o,Fr[9]=l,Fr[10]=h,Fr[11]=c||0,Fr[12]=d||0,Fr[13]=f||0,Fr[14]=u||0,Fr}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+5],n=e[t+3]/2,a=e[t+4]/2,o=e[t+13],l=e[t+14];if(i+=o*n*2,r+=l*a*2,s===0||s===Math.PI)return Kt.modify(i-n,i+n,r-a,r+a);if(s===Io||s===lH)return Kt.modify(i-a,i+a,r-n,r+n);let h=Yt(n,-a,s),c=Yt(n,a,s),d=Yt(-n,-a,s),f=Yt(-n,a,s),u={x:i+f.x,y:r+f.y},p={x:i+d.x,y:r+d.y},g={x:i+c.x,y:r+c.y},_={x:i+h.x,y:r+h.y};return Kt.modify(Math.min(u.x,p.x,g.x,_.x),Math.max(u.x,p.x,g.x,_.x),Math.min(u.y,p.y,g.y,_.y),Math.max(u.y,p.y,g.y,_.y))}},hH=class extends JI{create(e,t,i,r,s,n,a,o,l,h,c,d,f,u,p){return super.create(e,t,i,r,s,n,a,o,l,h,c,d,f,u),Fr[0]=e+(60<<Ct)+Rt,Fr[14]=p,Fr}},wse=new JI(10,XI,Ey),Tse=new hH(60,XI+1,Ey);var cH=Io*3,ZI=(e=>(e[e.ID=0]="ID",e[e.POSITION_X=1]="POSITION_X",e[e.POSITION_Y=2]="POSITION_Y",e[e.WIDTH=3]="WIDTH",e[e.HEIGHT=4]="HEIGHT",e[e.ANGLE=5]="ANGLE",e[e.MAX_PX_LENGTH=6]="MAX_PX_LENGTH",e[e.LIMIT_MAX=7]="LIMIT_MAX",e[e.LEFT_STRING_INDEX=8]="LEFT_STRING_INDEX",e[e.RIGHT_STRING_INDEX=9]="RIGHT_STRING_INDEX",e[e.ORDER=10]="ORDER",e[e.GROUP_ID=11]="GROUP_ID",e[e.COLOR_INDEX=12]="COLOR_INDEX",e[e.TEMPLATE_ID=13]="TEMPLATE_ID",e))(ZI||{}),uH=13,Us=[],dH=class extends cr{create(e,t,i,r,s,n,a,o,l,h=-1,c,d){return Us[0]=e+(19<<Ct)+Rt,Us[1]=t.x,Us[2]=t.y,Us[3]=i,Us[4]=r,Us[5]=(s%In+In)%In,Us[6]=r/n,Us[7]=a,Us[8]=o,Us[9]=l,Us[10]=d||0,Us[11]=h,Us[12]=c||0,Us}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+5],n=e[t+3]/2,a=e[t+4]/2;if(s===0||s===Math.PI)return Kt.modify(i-n,i+n,r-a,r+a);if(s===Io||s===cH)return Kt.modify(i-a,i+a,r-n,r+n);let o=Yt(n,-a,s),l=Yt(n,a,s),h=Yt(-n,-a,s),c=Yt(-n,a,s),d={x:i+c.x,y:r+c.y},f={x:i+h.x,y:r+h.y},u={x:i+l.x,y:r+l.y},p={x:i+o.x,y:r+o.y};return Kt.modify(Math.min(d.x,f.x,u.x,p.x),Math.max(d.x,f.x,u.x,p.x),Math.min(d.y,f.y,u.y,p.y),Math.max(d.y,f.y,u.y,p.y))}},Sse=new dH(19,uH,ZI),kf=class extends cr{getOrder(e,t,i){let r=e[t+this.DataIndex.GROUP_ID]*fl+6;return i.get(r)}getGroupIdByBuilder(e,t,i){if(!this.DataIndex.GROUP_ID)throw new Error("GetGroupId error ");let r=e.get(t+this.DataIndex.GROUP_ID)*fl+8;return i.get(r)}getTemplateId(e,t,i){let r=e[t+this.DataIndex.GROUP_ID]*fl+9;return i.get(r)}getColorIndex(e,t,i){let r=e[t+this.DataIndex.GROUP_ID]*fl+7;return i.get(r)}},vi=(e=>(e[e.ID=0]="ID",e[e.INDEX=1]="INDEX",e[e.TEMPLATE_INSTANCE_INDEX=2]="TEMPLATE_INSTANCE_INDEX",e[e.COLOR_INDEX=3]="COLOR_INDEX",e[e.GROUP_ID=4]="GROUP_ID",e))(vi||{}),Ti=5,Wc=[];function KI(e,t,i,r,s=-1){return Wc[0]=e+(this.type<<Ct)+Rt,Wc[1]=t,Wc[2]=i,Wc[3]=r||0,Wc[4]=s,Wc}var ur=class extends cr{create(e,t,i,r,s=-1){return KI(e,t,i,r,s)}getBBox(e,t){return Kt}},_l=class extends kf{create(e,t,i,r,s=-1){return KI(e,t,i,r,s)}getBBox(e,t){return Kt}},Ise=new ur(21,Ti,vi),Pse=new ur(22,Ti,vi),Ase=new ur(23,Ti,vi),Cse=new ur(24,Ti,vi),Lse=new ur(25,Ti,vi),Dse=new ur(26,Ti,vi),Rse=new ur(27,Ti,vi),Nse=new _l(28,Ti,vi),Mse=new _l(29,Ti,vi),Bse=new ur(30,Ti,vi),kse=new ur(31,Ti,vi),Fse=new ur(32,Ti,vi),Use=new _l(33,Ti,vi),Gse=new _l(34,Ti,vi),zse=new ur(35,Ti,vi),Hse=new ur(36,Ti,vi),jse=new ur(37,Ti,vi),Vse=new ur(38,Ti,vi),Yse=new ur(39,Ti,vi),qse=new ur(40,Ti,vi),Wse=new ur(41,Ti,vi),Xse=new ur(42,Ti,vi),Jse=new _l(43,Ti,vi),Zse=new _l(44,Ti,vi),Kse=new ur(45,Ti,vi),$se=new ur(46,Ti,vi),Qse=new ur(47,Ti,vi),ene=new _l(48,Ti,vi),tne=new _l(49,Ti,vi),ine=new ur(50,Ti,vi),fH=4,rne=2**fH-1;var sne=2**xy-1;var $I=(e=>(e[e.ID=0]="ID",e[e.POSITION_X=1]="POSITION_X",e[e.POSITION_Y=2]="POSITION_Y",e[e.IS_TRIANGLE=3]="IS_TRIANGLE",e[e.SIZE=4]="SIZE",e[e.ORDER=5]="ORDER",e[e.COLOR_INDEX=6]="COLOR_INDEX",e[e.GROUP_ID=7]="GROUP_ID",e[e.TEMPLATE_ID=8]="TEMPLATE_ID",e))($I||{}),pH=8,mo=[],gH=class extends cr{create(e,t,i,r,s,n,a=-1){return mo[0]=e+(5<<Ct)+Rt,mo[1]=t.x,mo[2]=t.y,mo[3]=r?1.5:1,mo[4]=i,mo[5]=n||0,mo[6]=s||0,mo[7]=a,mo}getBBox(e,t){let i=e[t+1],r=e[t+2];return Kt.modify(i,i,r,r)}},nne=new gH(5,pH,$I),wy=(e=>(e[e.ID=0]="ID",e[e.START_X=1]="START_X",e[e.START_Y=2]="START_Y",e[e.END_X=3]="END_X",e[e.END_Y=4]="END_Y",e[e.LEN_ADD_GAP=5]="LEN_ADD_GAP",e[e.LEN=6]="LEN",e[e.ORDER=7]="ORDER",e[e.COLOR_INDEX=8]="COLOR_INDEX",e[e.GROUP_ID=9]="GROUP_ID",e[e.TEMPLATE_ID=10]="TEMPLATE_ID",e))(wy||{}),QI=10,js=[],eP=class extends cr{create(e,t,i,r,s,n,a,o,l=-1){return js[0]=e+(3<<Ct)+Rt,js[1]=t.x,js[2]=t.y,js[3]=i.x,js[4]=i.y,js[5]=r?1:s+n,js[6]=r?1:s,js[7]=a||0,js[8]=o||0,js[9]=l,js}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=Math.max(i,s),o=Math.min(i,s),l=Math.max(r,n),h=Math.min(r,n);return Kt.modify(o,a,h,l)}},_H=class extends eP{create(e,t,i,r,s,n,a,o,l=-1,h=-1){return super.create(e,t,i,r,s,n,a,o,l),js[0]=e+(54<<Ct)+Rt,js[10]=h,js}},ane=new eP(3,QI,wy),one=new _H(54,QI+1,wy);var dO=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.WIDTH=4]="WIDTH",e[e.START_ANGLE=5]="START_ANGLE",e[e.SWEEP_ANGLE=6]="SWEEP_ANGLE",e[e.ORDER=7]="ORDER",e[e.COLOR_INDEX=8]="COLOR_INDEX",e[e.GROUP_ID=9]="GROUP_ID",e[e.DASH_ARR_INDEX=10]="DASH_ARR_INDEX",e[e.LINE_CAP=11]="LINE_CAP",e))(dO||{}),yS=10,OH=12,Jr=[],Ty=class extends cr{create(e,t,i,r,s,n,a,o,l=-1){return Jr[0]=e+(1<<Ct)+Rt,Jr[1]=t.x,Jr[2]=t.y,Jr[3]=i,Jr[4]=r,Jr[5]=s,Jr[6]=n,Jr[7]=a||0,Jr[8]=o||0,Jr[9]=l,Jr}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=e[t+5],o=a+e[t+6],{x:l,y:h}=Yt(1,0,a),{x:c,y:d}=Yt(1,0,o),f=Math.min(l,c),u=Math.max(l,c),p=Math.min(h,d),g=Math.max(h,d),_=n/2;for(let y=Math.ceil(a/(Math.PI/2))*(Math.PI/2);y<o;y+=Math.PI/2){let{x:m,y:O}=Yt(1,0,y);f=Math.min(m,f),u=Math.max(m,u),p=Math.min(O,p),g=Math.max(O,g)}return Kt.modify(f*s+i-_,u*s+i+_,p*s+r-_,g*s+r+_)}},mH=class extends Ty{create(e,t,i,r,s,n,a,o,l=-1,h=-1,c="round"){return super.create(e,t,i,r,s,n,a,o,l),Jr[10]=h,Jr[11]=AP[c],Jr}},bH=class extends Ty{create(e,t,i,r,s,n,a,o,l=-1){return super.create(e,t,i,r,s,n,a,o,l),Jr}},yH=class extends Ty{create(e,t,i,r,s,n,a,o,l=-1,h=-1){return super.create(e,t,i,r,s,n,a,o,l),Jr[0]=e+(52<<Ct)+Rt,Jr[10]=h,Jr}},vH,xH,EH;_h(()=>vH=new mH(1,OH,dO),()=>{xH=new bH(1,yS,dO),EH=new yH(52,yS+1,dO)});var Sy=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.COLOR_INDEX1=4]="COLOR_INDEX1",e[e.COLOR_INDEX2=5]="COLOR_INDEX2",e[e.ORDER=6]="ORDER",e[e.GROUP_ID=7]="GROUP_ID",e[e.TEMPLATE_ID=8]="TEMPLATE_ID",e))(Sy||{}),tP=8,Tn=[],iP=class extends cr{create(e,t,i,r,s,n,a=-1){return Tn[0]=e+(4<<Ct)+Rt,Tn[1]=t.x,Tn[2]=t.y,Tn[3]=i,Tn[4]=r,Tn[5]=s,Tn[6]=n||0,Tn[7]=a,Tn}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3];return Kt.modify(i-s,i+s,r-s,r+s)}},wH=class extends iP{create(e,t,i,r,s,n,a,o){return super.create(e,t,i,r,s,n,a),Tn[0]=e+(55<<Ct)+Rt,Tn[8]=o,Tn}},lne=new iP(4,tP,Sy),hne=new wH(55,tP+1,Sy),vS=10,TH=11,fO=(e=>(e[e.ID=0]="ID",e[e.LEFT_POINT_X=1]="LEFT_POINT_X",e[e.LEFT_POINT_Y=2]="LEFT_POINT_Y",e[e.WIDTH=3]="WIDTH",e[e.HEIGHT=4]="HEIGHT",e[e.ANGLE=5]="ANGLE",e[e.RADIUS=6]="RADIUS",e[e.ORDER=7]="ORDER",e[e.COLOR_INDEX=8]="COLOR_INDEX",e[e.GROUP_ID=9]="GROUP_ID",e[e.TEMPLATE_ID=10]="TEMPLATE_ID",e))(fO||{}),ws=[],Iy=class extends cr{create(e,t,i,r,s,n,a,o,l=-1){return ws[0]=e+(2<<Ct)+Rt,ws[1]=t.x,ws[2]=t.y,ws[3]=i,ws[4]=r,ws[5]=s,ws[6]=n,ws[7]=a||0,ws[8]=o||0,ws[9]=l,ws}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=e[t+5];if(a===0)return Kt.modify(i,i+s,r-n,r);let o=e[t+6],l=Yt(o,-o,a),h=Yt(o,o-n,a),c=Yt(s-o,-o,a),d=Yt(s-o,o-n,a),f={x:i+l.x,y:r+l.y},u={x:i+h.x,y:r+h.y},p={x:i+c.x,y:r+c.y},g={x:i+d.x,y:r+d.y};return Kt.modify(Math.min(f.x,u.x,p.x,g.x)-o,Math.max(f.x,u.x,p.x,g.x)+o,Math.min(f.y,u.y,p.y,g.y)-o,Math.max(f.y,u.y,p.y,g.y)+o)}},SH=class extends Iy{create(e,t,i,r,s,n,a,o,l=-1,h=1){return super.create(e,t,i,r,s,n,a,o,l),ws[10]=h,ws}},IH=class extends Iy{create(e,t,i,r,s,n,a,o,l=-1){return super.create(e,t,i,r,s,n,a,o,l)}},PH=class extends Iy{create(e,t,i,r,s,n,a,o,l=-1,h=-1){return super.create(e,t,i,r,s,n,a,o,l),ws[0]=e+(53<<Ct)+Rt,ws[10]=h,ws}},AH,CH,LH;_h(()=>AH=new SH(2,TH,fO),()=>{CH=new IH(2,vS,fO),LH=new PH(53,vS+1,fO)});var Py=(e=>(e[e.ID=0]="ID",e[e.POINT1_X=1]="POINT1_X",e[e.POINT1_Y=2]="POINT1_Y",e[e.POINT2_X=3]="POINT2_X",e[e.POINT2_Y=4]="POINT2_Y",e[e.POINT3_X=5]="POINT3_X",e[e.POINT3_Y=6]="POINT3_Y",e[e.GROUP_ID=7]="GROUP_ID",e[e.FillStyle=8]="FillStyle",e))(Py||{}),rP=9,wn=[],sP=class extends kf{create(e,t,i,r,s,n=1){return wn[0]=e+(8<<Ct)+Rt,wn[1]=t.x,wn[2]=t.y,wn[3]=i.x,wn[4]=i.y,wn[5]=r.x,wn[6]=r.y,wn[7]=s,wn[8]=n,wn}getBBox(e,t,i){let r=e[t+1],s=e[t+2],n=e[t+3],a=e[t+4],o=e[t+5],l=e[t+6],h=e[t+7]*fl,c=i.get(h),d=i.get(h+1),f=i.get(h+2),u=i.get(h+3),p=i.get(h+4),g=i.get(h+5),_=r*c+s*f+p,y=r*d+s*u+g,m=n*c+a*f+p,O=n*d+a*u+g,b=o*c+l*f+p,v=o*d+l*u+g;return Kt.modify(Math.min(_,m,b),Math.max(_,m,b),Math.min(y,O,v),Math.max(y,O,v))}},DH=class extends sP{create(e,t,i,r,s,n){return super.create(e,t,i,r,s,n),wn[0]=e+(58<<Ct)+Rt,wn}},cne=new sP(8,rP,Py),une=new DH(58,rP,Py),xS=class{static regular(e){return Math.round(e*this.precision)/this.precision}static eq(e,t){return Math.abs(e-t)<=this.eps}static neq(e,t){return Math.abs(e-t)>this.eps}static less(e,t){return e-t<-this.eps}static lesseq(e,t){return e-t<this.eps}static greater(e,t){return e-t>this.eps}static greatereq(e,t){return e-t>-this.eps}static sqrt(e){return Math.abs(e)<=1e-10?0:Math.sqrt(e)}static sortAsc(e,t){return e-t}static sortDesc(e,t){return t-e}};xS.eps=1e-8,xS.precision=1e8;var pO=class on{static toDegrees(t){return t*180/Math.PI}static toRadians(t){return t/180*Math.PI}static regularD(t){return t=t%360,t=t<0?360+t:t,t===360?0:t}static regular(t){return t=t%on.PIx2,t=t<0?on.PIx2+t:t,t===on.PIx2?0:t}static toQuarterBase(t){return on.regular((t+on.PI_4)/on.PI_2*on.PI_2)}static toQuarterBaseD(t){return on.regularD(((t+45)/90|0)*90)}static transformD(t,i){return on.toDegrees(on.transform(on.toRadians(t),i))}static transform(t,i){let r=Math.cos(t),s=Math.sin(t),n=new ae(i.data[6],i.data[7]),a=new ae(r,s).multiply3(i);return on.regular(a.angle(n))}};pO.PIx2=Math.PI*2,pO.PI_2=Math.PI/2,pO.PI_4=Math.PI/4;var Ib=pO,Ay=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.START_ANGLE=4]="START_ANGLE",e[e.SWEEP_ANGLE=5]="SWEEP_ANGLE",e[e.START_X=6]="START_X",e[e.START_Y=7]="START_Y",e[e.END_X=8]="END_X",e[e.END_Y=9]="END_Y",e[e.GROUP_ID=10]="GROUP_ID",e[e.FillStyle=11]="FillStyle",e))(Ay||{}),nP=12,Ls=[],aP=class extends kf{create(e,t,i,r,s,n,a,o,l=1){return Ls[0]=e+(9<<Ct)+Rt,Ls[1]=t.x,Ls[2]=t.y,Ls[3]=i,Ls[4]=r,Ls[5]=s,Ls[6]=n.x,Ls[7]=n.y,Ls[8]=a.x,Ls[9]=a.y,Ls[10]=o,Ls[11]=l,Ls}getBBox(e,t,i){let r=e[t+1],s=e[t+2],n=e[t+3],a=e[t+4],o=a+e[t+5],l=e[t+10]*fl,h=new yi;function c(f){let{x:u,y:p}=Yt(n,0,f);u+=r,p+=s,h.ext6(u*i.get(l)+p*i.get(l+2)+i.get(l+4),u*i.get(l+1)+p*i.get(l+3)+i.get(l+5))}if(c(a),c(o),a<o)for(let f=Math.ceil(a/(Math.PI/2))*(Math.PI/2);f<o;f+=Math.PI/2)c(f);else for(let f=Math.floor(a/(Math.PI/2))*(Math.PI/2);f>o;f-=Math.PI/2)c(f);let d=h.build1();return Kt.modify(d.minX,d.maxX,d.minY,d.maxY)}},RH=class extends aP{create(e,t,i,r,s,n,a,o,l){return super.create(e,t,i,r,s,n,a,o,l),Ls[0]=e+(59<<Ct)+Rt,Ls}},pne=new aP(9,nP,Ay),gne=new RH(59,nP,Ay),Cy=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.START_ANGLE=4]="START_ANGLE",e[e.SWEEP_ANGLE=5]="SWEEP_ANGLE",e[e.ORDER=6]="ORDER",e[e.COLOR_INDEX=7]="COLOR_INDEX",e[e.GROUP_ID=8]="GROUP_ID",e[e.TEMPLATE_ID=9]="TEMPLATE_ID",e))(Cy||{}),oP=9,ln=[],lP=class extends cr{create(e,t,i,r,s,n,a,o=-1){return ln[0]=e+(12<<Ct)+Rt,ln[1]=t.x,ln[2]=t.y,ln[3]=i,ln[4]=r,ln[5]=s,ln[6]=n||0,ln[7]=a||0,ln[8]=o,ln}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=n+e[t+5],{x:o,y:l}=Yt(1,0,n),{x:h,y:c}=Yt(1,0,a),d=Math.min(o,h),f=Math.max(o,h),u=Math.min(l,c),p=Math.max(l,c);for(let g=Math.ceil(n/(Math.PI/2))*(Math.PI/2);g<a;g+=Math.PI/2){let{x:_,y}=Yt(1,0,g);d=Math.min(_,d),f=Math.max(_,f),u=Math.min(y,u),p=Math.max(y,p)}return Kt.modify(d*s+i,f*s+i,u*s+r,p*s+r)}},NH=class extends lP{create(e,t,i,r,s,n,a,o=-1,l=-1){return super.create(e,t,i,r,s,n,a,o),ln[0]=e+(62<<Ct)+Rt,ln[9]=l,ln}},_ne=new lP(12,oP,Cy),One=new NH(62,oP+1,Cy),Ly=(e=>(e[e.ID=0]="ID",e[e.START_X=1]="START_X",e[e.START_Y=2]="START_Y",e[e.END_X=3]="END_X",e[e.END_Y=4]="END_Y",e[e.ORDER=5]="ORDER",e[e.COLOR_INDEX=6]="COLOR_INDEX",e[e.GROUP_ID=7]="GROUP_ID",e[e.TEMPLATE_ID=8]="TEMPLATE_ID",e))(Ly||{}),hP=8,Sn=[],cP=class extends cr{create(e,t,i,r,s,n=-1){return Sn[0]=e+(11<<Ct)+Rt,Sn[1]=t.x,Sn[2]=t.y,Sn[3]=i.x,Sn[4]=i.y,Sn[5]=r||0,Sn[6]=s||0,Sn[7]=n,Sn}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=Math.max(i,s),o=Math.min(i,s),l=Math.max(r,n),h=Math.min(r,n);return Kt.modify(o,a,h,l)}},MH=class extends cP{create(e,t,i,r,s,n,a){return super.create(e,t,i,r,s,n),Sn[0]=e+(61<<Ct)+Rt,Sn[8]=a,Sn}},mne=new cP(11,hP,Ly),bne=new MH(61,hP+1,Ly),Dy=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.START_ANGLE=4]="START_ANGLE",e[e.SWEEP_ANGLE=5]="SWEEP_ANGLE",e[e.GROUP_ID=6]="GROUP_ID",e))(Dy||{}),La=[],uP=7,dP=class extends kf{create(e,t,i,r,s,n){return La[0]=e+(14<<Ct)+Rt,La[1]=t.x,La[2]=t.y,La[3]=i,La[4]=r,La[5]=s,La[6]=n,La}getBBox(e,t,i){let r=e[t+1],s=e[t+2],n=e[t+3],a=e[t+4],o=a+e[t+5],l=e[t+6]*fl,h=new yi;function c(f){let{x:u,y:p}=Yt(n,0,f);u+=r,p+=s,h.ext6(u*i.get(l)+p*i.get(l+2)+i.get(l+4),u*i.get(l+1)+p*i.get(l+3)+i.get(l+5))}if(c(a),c(o),a<o)for(let f=Math.ceil(a/(Math.PI/2))*(Math.PI/2);f<o;f+=Math.PI/2)c(f);else for(let f=Math.floor(a/(Math.PI/2))*(Math.PI/2);f>o;f-=Math.PI/2)c(f);let d=h.build1();return Kt.modify(d.minX,d.maxX,d.minY,d.maxY)}},BH=class extends dP{create(e,t,i,r,s,n){return super.create(e,t,i,r,s,n),La[0]=e+(64<<Ct)+Rt,La}},vne=new dP(14,uP,Dy),xne=new BH(64,uP,Dy),Ry=(e=>(e[e.ID=0]="ID",e[e.START_X=1]="START_X",e[e.START_Y=2]="START_Y",e[e.END_X=3]="END_X",e[e.END_Y=4]="END_Y",e[e.GROUP_ID=5]="GROUP_ID",e))(Ry||{}),fP=6,wo=[],pP=class extends kf{create(e,t,i,r){return wo[0]=e+(13<<Ct)+Rt,wo[1]=t.x,wo[2]=t.y,wo[3]=i.x,wo[4]=i.y,wo[5]=r,wo}getBBox(e,t,i){let r=e[t+1],s=e[t+2],n=e[t+3],a=e[t+4],o=e[t+5]*fl,l=i.get(o),h=i.get(o+1),c=i.get(o+2),d=i.get(o+3),f=i.get(o+4),u=i.get(o+5),p=r*l+s*c+f,g=r*h+s*d+u,_=n*l+a*c+f,y=n*h+a*d+u;return Kt.modify(Math.min(p,_),Math.max(p,_),Math.min(g,y),Math.max(g,y))}},kH=class extends pP{create(e,t,i,r){return super.create(e,t,i,r),wo[0]=e+(63<<Ct)+Rt,wo}},Ene=new pP(13,fP,Ry),wne=new kH(63,fP,Ry),gP=(e=>(e[e.ID=0]="ID",e[e.CenterX=1]="CenterX",e[e.CenterY=2]="CenterY",e[e.A=3]="A",e[e.B=4]="B",e[e.StartAngle=5]="StartAngle",e[e.EndAngle=6]="EndAngle",e[e.Rotation=7]="Rotation",e[e.Stroke=8]="Stroke",e[e.StrokeColorIndex=9]="StrokeColorIndex",e[e.DashArrayIndex=10]="DashArrayIndex",e[e.LineCapIndex=11]="LineCapIndex",e[e.FillColorIndex=12]="FillColorIndex",e[e.FillStyleIndex=13]="FillStyleIndex",e[e.ORDER=14]="ORDER",e[e.GROUP_ID=15]="GROUP_ID",e))(gP||{}),ds=[],FH=class extends cr{create(e,t,i,r,s,n,a,o,l=0,h=-1,c=1,d=0,f=1,u=0,p=-1){return ds[0]=e+(16<<Ct)+Rt,ds[1]=t.x,ds[2]=t.y,ds[3]=i,ds[4]=r,ds[5]=s,ds[6]=n,ds[7]=a,ds[8]=o,ds[9]=l,ds[10]=h,ds[11]=c,ds[12]=d,ds[13]=f,ds[14]=u,ds[15]=p,ds}getBBox(e,t){let i=new ae(e[t+1],e[t+2]),r=e[t+3],s=e[t+4],n=e[t+5],a=e[t+6],o=e[t+7],l=e[t+8]/2,h=r+l,c=s+l,d=new ae(h,0),f=new ae(-h,0),u=new ae(0,c),p=new ae(0,-c),g=P(r,s,-n),_=P(r,s,-a),y=uS(Ib.regular(n),3),m=uS(y,3);y==m&&y==0&&(a<n?y=Ib.PIx2:m=Ib.PIx2);let O=Math.PI,b=O/2,v=O*3/2,E=new yi;y==0?m==0?E.ext5(-l,l,-l,l):m<b?(E.ext2(d),E.ext2(_)):m<O?(E.ext2(d),E.ext2(p),E.ext2(_)):m<v?(E.ext2(d),E.ext2(p),E.ext2(f),E.ext2(_)):(E.ext2(d),E.ext2(p),E.ext2(f),E.ext2(u),E.ext2(_)):m==0?(E.ext2(g),E.ext2(p),E.ext2(f),E.ext2(u),E.ext2(d)):m<b?(E.ext2(g),E.ext2(_)):m<O?(E.ext2(g),E.ext2(p),E.ext2(_)):m<v?(E.ext2(g),E.ext2(p),E.ext2(f),E.ext2(_)):(E.ext2(g),E.ext2(p),E.ext2(f),E.ext2(u),E.ext2(_));let T=E.build().transform(ci.rotate(-o).translate1(i));return Kt.modify(T.minX,T.maxX,T.minY,T.maxY);function P(A,C,M){let H=A*Math.cos(M),k=C*Math.sin(M);return new ae(H,k)}}},Ine=new FH(16,16,gP),ys=[],_P=(e=>(e[e.ID=0]="ID",e[e.EndPointX1=1]="EndPointX1",e[e.EndPointY1=2]="EndPointY1",e[e.EndPointX2=3]="EndPointX2",e[e.EndPointY2=4]="EndPointY2",e[e.ControlX1=5]="ControlX1",e[e.ControlY1=6]="ControlY1",e[e.ControlX2=7]="ControlX2",e[e.ControlY2=8]="ControlY2",e[e.Stroke=9]="Stroke",e[e.StrokeColorIndex=10]="StrokeColorIndex",e[e.DashArrayIndex=11]="DashArrayIndex",e[e.LineCapIndex=12]="LineCapIndex",e[e.ORDER=13]="ORDER",e[e.GROUP_ID=14]="GROUP_ID",e))(_P||{}),UH=class extends cr{create(e,t,i,r,s,n,a=0,o=-1,l=1,h=0,c=-1){return ys[0]=e+(17<<Ct)+Rt,ys[1]=t.x,ys[2]=t.y,ys[3]=i.x,ys[4]=i.y,ys[5]=r.x,ys[6]=r.y,ys[7]=s.x,ys[8]=s.y,ys[9]=n,ys[10]=a,ys[11]=o,ys[12]=l,ys[13]=h,ys[14]=c,ys}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=e[t+5],o=e[t+6],l=e[t+7],h=e[t+8],c=e[t+9]/2,d=new Ye([new ae(i,r),new ae(a,o),new ae(l,h),new ae(s,n)]).bbox().extendOfSize(c);return Kt.modify1(d)}},Cne=new UH(17,15,_P);var OP=(e=>(e[e.ID=0]="ID",e[e.START_X=1]="START_X",e[e.START_Y=2]="START_Y",e[e.END_X=3]="END_X",e[e.END_Y=4]="END_Y",e[e.WIDTH=5]="WIDTH",e[e.ORDER=6]="ORDER",e[e.COLOR_INDEX=7]="COLOR_INDEX",e[e.GROUP_ID=8]="GROUP_ID",e[e.LINE_CAP=9]="LINE_CAP",e[e.DASH_ARR_INDEX=10]="DASH_ARR_INDEX",e[e.SHADOW_COLOR_INDEX=11]="SHADOW_COLOR_INDEX",e[e.SHADOW_BLUR=12]="SHADOW_BLUR",e[e.SHADOW_OFFSET_X=13]="SHADOW_OFFSET_X",e[e.SHADOW_OFFSET_Y=14]="SHADOW_OFFSET_Y",e[e.TEMPLATE_ID=15]="TEMPLATE_ID",e))(OP||{}),sy=(e=>(e[e.ID=0]="ID",e[e.START_X=1]="START_X",e[e.START_Y=2]="START_Y",e[e.END_X=3]="END_X",e[e.END_Y=4]="END_Y",e[e.WIDTH=5]="WIDTH",e[e.ORDER=6]="ORDER",e[e.COLOR_INDEX=7]="COLOR_INDEX",e[e.GROUP_ID=8]="GROUP_ID",e[e.LINE_CAP=9]="LINE_CAP",e[e.TEMPLATE_ID=10]="TEMPLATE_ID",e))(sy||{}),GH=15,ES=10,Ar=[],Ny=class extends cr{create(e,t,i,r,s="round",n,a,o=-1){return Ar[0]=e+(15<<Ct)+Rt,Ar[1]=t.x,Ar[2]=t.y,Ar[3]=i.x,Ar[4]=i.y,Ar[5]=r,Ar[6]=n||0,Ar[7]=a||0,Ar[8]=o,Ar[9]=AP[s],Ar}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=e[t+5],o=Math.max(i,s),l=Math.min(i,s),h=Math.max(r,n),c=Math.min(r,n),d=a/2;return Kt.modify(l-d,o+d,c-d,h+d)}},zH=class extends Ny{create(e,t,i,r,s="round",n,a,o=-1,l=-1,h,c,d,f){return super.create(e,t,i,r,s,n,a,o),Ar[10]=l,Ar[11]=h||0,Ar[12]=c||0,Ar[13]=d||0,Ar[14]=f||0,Ar}},HH=class extends Ny{create(e,t,i,r,s="round",n,a,o=-1){return super.create(e,t,i,r,s,n,a,o)}},jH=class extends Ny{create(e,t,i,r,s="round",n,a,o=-1,l=-1){return super.create(e,t,i,r,s,n,a,o),Ar[0]=e+(65<<Ct)+Rt,Ar[10]=l,Ar}},VH,YH,qH;_h(()=>VH=new zH(15,GH,OP),()=>{YH=new HH(15,ES,sy),qH=new jH(65,ES+1,sy)});var mP=(e=>(e[e.ID=0]="ID",e[e.POINT1_X=1]="POINT1_X",e[e.POINT1_Y=2]="POINT1_Y",e[e.POINT2_X=3]="POINT2_X",e[e.POINT2_Y=4]="POINT2_Y",e[e.POINT3_X=5]="POINT3_X",e[e.POINT3_Y=6]="POINT3_Y",e[e.ORDER=7]="ORDER",e[e.COLOR_INDEX=8]="COLOR_INDEX",e[e.GROUP_ID=9]="GROUP_ID",e[e.FILL_STYLE=10]="FILL_STYLE",e))(mP||{}),wS=10,WH=11,Ts=[],gO=(e=>(e[e.ID=0]="ID",e[e.POINT1_X=1]="POINT1_X",e[e.POINT1_Y=2]="POINT1_Y",e[e.POINT2_X=3]="POINT2_X",e[e.POINT2_Y=4]="POINT2_Y",e[e.POINT3_X=5]="POINT3_X",e[e.POINT3_Y=6]="POINT3_Y",e[e.ORDER=7]="ORDER",e[e.COLOR_INDEX=8]="COLOR_INDEX",e[e.GROUP_ID=9]="GROUP_ID",e[e.TEMPLATE_ID=10]="TEMPLATE_ID",e))(gO||{}),My=class extends cr{create(e,t,i,r,s,n,a=-1){return Ts[0]=e+(6<<Ct)+Rt,Ts[1]=t.x,Ts[2]=t.y,Ts[3]=i.x,Ts[4]=i.y,Ts[5]=r.x,Ts[6]=r.y,Ts[7]=s||0,Ts[8]=n||0,Ts[9]=a,Ts}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=e[t+5],o=e[t+6];return Kt.modify(Math.min(i,s,a),Math.max(i,s,a),Math.min(r,n,o),Math.max(r,n,o))}},XH=class extends My{create(e,t,i,r,s,n,a=-1,o=1){return super.create(e,t,i,r,s,n,a),Ts[10]=o,Ts}},JH=class extends My{create(e,t,i,r,s,n,a=-1){return super.create(e,t,i,r,s,n,a)}},ZH=class extends My{create(e,t,i,r,s,n,a=-1,o=-1){return super.create(e,t,i,r,s,n,a),Ts[0]=e+(56<<Ct)+Rt,Ts[10]=o,Ts}},KH,$H,QH;_h(()=>(KH=new XH(6,WH,mP),gO),()=>{$H=new JH(6,wS,gO),QH=new ZH(56,wS+1,gO)});var bP=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.START_ANGLE=4]="START_ANGLE",e[e.SWEEP_ANGLE=5]="SWEEP_ANGLE",e[e.START_X=6]="START_X",e[e.START_Y=7]="START_Y",e[e.END_X=8]="END_X",e[e.END_Y=9]="END_Y",e[e.ORDER=10]="ORDER",e[e.COLOR_INDEX=11]="COLOR_INDEX",e[e.GROUP_ID=12]="GROUP_ID",e[e.FillStyle=13]="FillStyle",e))(bP||{}),ny=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.START_ANGLE=4]="START_ANGLE",e[e.SWEEP_ANGLE=5]="SWEEP_ANGLE",e[e.START_X=6]="START_X",e[e.START_Y=7]="START_Y",e[e.END_X=8]="END_X",e[e.END_Y=9]="END_Y",e[e.ORDER=10]="ORDER",e[e.COLOR_INDEX=11]="COLOR_INDEX",e[e.GROUP_ID=12]="GROUP_ID",e[e.TEMPLATE_ID=13]="TEMPLATE_ID",e))(ny||{}),TS=13,ej=14,Pr=[],By=class extends cr{create(e,t,i,r,s,n,a,o,l,h=-1){return Pr[0]=e+(7<<Ct)+Rt,Pr[1]=t.x,Pr[2]=t.y,Pr[3]=i,Pr[4]=r,Pr[5]=s,Pr[6]=n.x,Pr[7]=n.y,Pr[8]=a.x,Pr[9]=a.y,Pr[10]=o||0,Pr[11]=l||0,Pr[12]=h,Pr}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3],n=e[t+4],a=n+e[t+5],{x:o,y:l}=Yt(1,0,n),{x:h,y:c}=Yt(1,0,a),d=Math.min(o,h),f=Math.max(o,h),u=Math.min(l,c),p=Math.max(l,c);if(n<a)for(let g=Math.ceil(n/(Math.PI/2))*(Math.PI/2);g<a;g+=Math.PI/2){let{x:_,y}=Yt(1,0,g);d=Math.min(_,d),f=Math.max(_,f),u=Math.min(y,u),p=Math.max(y,p)}else for(let g=Math.floor(n/(Math.PI/2))*(Math.PI/2);g>a;g-=Math.PI/2){let _=Math.cos(g),y=Math.sin(g);d=Math.min(_,d),f=Math.max(_,f),u=Math.min(y,u),p=Math.max(y,p)}return Kt.modify(d*s+i,f*s+i,u*s+r,p*s+r)}},tj=class extends By{create(e,t,i,r,s,n,a,o,l,h=-1,c=1){return super.create(e,t,i,r,s,n,a,o,l,h),Pr[13]=c,Pr}},ij=class extends By{create(e,t,i,r,s,n,a,o,l,h=-1){return super.create(e,t,i,r,s,n,a,o,l,h),Pr}},rj=class extends By{create(e,t,i,r,s,n,a,o,l,h=-1,c=-1){return super.create(e,t,i,r,s,n,a,o,l,h),Pr[0]=e+(57<<Ct)+Rt,Pr[13]=c,Pr}},sj,nj,aj;_h(()=>sj=new tj(7,ej,bP),()=>{nj=new ij(7,TS,ny),aj=new rj(57,TS+1,ny)});var yP=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.ORDER=4]="ORDER",e[e.COLOR_INDEX=5]="COLOR_INDEX",e[e.GROUP_ID=6]="GROUP_ID",e[e.FILL_STYLE=7]="FILL_STYLE",e))(yP||{}),ay=(e=>(e[e.ID=0]="ID",e[e.CENTER_X=1]="CENTER_X",e[e.CENTER_Y=2]="CENTER_Y",e[e.RADIUS=3]="RADIUS",e[e.ORDER=4]="ORDER",e[e.COLOR_INDEX=5]="COLOR_INDEX",e[e.GROUP_ID=6]="GROUP_ID",e[e.TEMPLATE_ID=7]="TEMPLATE_ID",e))(ay||{}),SS=7,oj=8,hn=[],ky=class extends cr{create(e,t,i,r,s,n=-1){return hn[0]=e+(0<<Ct)+Rt,hn[1]=t.x,hn[2]=t.y,hn[3]=i,hn[4]=r||0,hn[5]=s||0,hn[6]=n,hn}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+3];return Kt.modify(i-s,i+s,r-s,r+s)}},lj=class extends ky{create(e,t,i,r,s,n=-1,a=1){return super.create(e,t,i,r,s,n),hn[7]=a,hn}},hj=class extends ky{create(e,t,i,r,s,n){return super.create(e,t,i,r,s,n)}},cj=class extends ky{create(e,t,i,r,s,n,a=-1){return super.create(e,t,i,r,s,n),hn[0]=e+(51<<Ct)+Rt,hn[7]=a,hn}},uj,dj,fj;_h(()=>uj=new lj(0,oj,yP),()=>{dj=new hj(0,SS,ay),fj=new cj(51,SS+1,ay)});var vP=(e=>(e[e.ID=0]="ID",e[e.STRING_INDEX=1]="STRING_INDEX",e[e.CONTENT_WIDTH=2]="CONTENT_WIDTH",e[e.CONTENT_HEIGHT=3]="CONTENT_HEIGHT",e[e.Matrix3Start=4]="Matrix3Start",e[e.Matrix3End=12]="Matrix3End",e[e.COLOR_INDEX=13]="COLOR_INDEX",e[e.ORDER=14]="ORDER",e[e.GROUP_ID=15]="GROUP_ID",e[e.TEXT_WRAP=16]="TEXT_WRAP",e[e.TEXT_ALIGN=17]="TEXT_ALIGN",e[e.TEXT_VERTICAL_ALIGN=18]="TEXT_VERTICAL_ALIGN",e[e.OVERFLOW=19]="OVERFLOW",e[e.LINE_HEIGHT=20]="LINE_HEIGHT",e[e.SHADOW_COLOR_INDEX=21]="SHADOW_COLOR_INDEX",e[e.SHADOW_BLUR=22]="SHADOW_BLUR",e))(vP||{}),pj=23,ni=[],gj=class extends cr{create(e,t,i,r,s,n,a,o=-1,l=0,h=0,c=0,d=1,f,u,p){return ni[0]=e+(18<<Ct)+Rt,ni[1]=t,ni[2]=r,ni[3]=s,ni[4]=i.data[0],ni[5]=i.data[1],ni[6]=i.data[2],ni[7]=i.data[3],ni[8]=i.data[4],ni[9]=i.data[5],ni[10]=i.data[6],ni[11]=i.data[7],ni[12]=i.data[8],ni[13]=n||0,ni[14]=a||0,ni[15]=o,ni[16]=l,ni[17]=h,ni[18]=c,ni[19]=d,ni[20]=f||1,ni[21]=u,ni[22]=p||0,ni}getBBox(e,t){let i=e[t+2],r=e[t+3],s=e.slice(t+4,t+12+1),{x:n,y:a}=mS(s,0,0),{x:o,y:l}=mS(s,i,r);return Kt.modify(Math.min(n,o),Math.max(n,o),Math.min(a,l),Math.max(a,l))}},_j=Io*3,Oj=10,xP=(e=>(e[e.ID=0]="ID",e[e.STRING_INDEX=1]="STRING_INDEX",e[e.POSITION_X=2]="POSITION_X",e[e.POSITION_Y=3]="POSITION_Y",e[e.ANGLE=4]="ANGLE",e[e.WIDTH=5]="WIDTH",e[e.HEIGHT=6]="HEIGHT",e[e.COLOR_INDEX=7]="COLOR_INDEX",e[e.ORDER=8]="ORDER",e[e.GROUP_ID=9]="GROUP_ID",e))(xP||{}),mj=class extends cr{create(e,t,i,r,s,n,a,o,l=-1){return ni[0]=e+(18<<Ct)+Rt,ni[1]=t,ni[2]=i.x,ni[3]=i.y,ni[4]=(r%In+In)%In,ni[5]=s,ni[6]=n,ni[7]=a||0,ni[8]=o||0,ni[9]=l,ni}getBBox(e,t){let i=e[t+5],r=e[t+6],s=e[t+2]+i/2,n=e[t+3]+r/2,a=e[t+4],o=i/2,l=r/2;if(a===0||a===Math.PI){let u=Math.min(s-o,s+o),p=Math.max(s-o,s+o),g=Math.min(n-l,n+l),_=Math.max(n-l,n+l);return Kt.modify(u,p,g,_)}if(a===Io||a===_j){let u=Math.min(s-l,s+l),p=Math.max(s-l,s+l),g=Math.min(n-o,n+o),_=Math.max(n-o,n+o);return Kt.modify(u,p,g,_)}let h=Yt(o,l,a),c=Yt(-o,-l,a),d=i>0?1:-1,f=r>0?1:-1;return h=bS(h.x,h.y,d,f),c=bS(c.x,c.y,d,f),Kt.modify(Math.min(h.x,c.x)+s,Math.max(h.x,c.x)+s,Math.min(h.y,c.y)+n,Math.max(h.y,c.y)+n)}},bj,yj;_h(()=>bj=new gj(18,pj,vP),()=>{yj=new mj(18,Oj,xP)});var EP=(e=>(e[e.ID=0]="ID",e[e.LEFT_POINT_X=1]="LEFT_POINT_X",e[e.LEFT_POINT_Y=2]="LEFT_POINT_Y",e[e.WIDTH=3]="WIDTH",e[e.HEIGHT=4]="HEIGHT",e[e.ANGLE=5]="ANGLE",e[e.ORDER=6]="ORDER",e[e.SHADOW_COLOR_INDEX=7]="SHADOW_COLOR_INDEX",e[e.SHADOW_BLUR=8]="SHADOW_BLUR",e[e.GROUP_ID=9]="GROUP_ID",e))(EP||{}),vj=10,$n=[],xj=class extends cr{create(e,t,i,r,s,n,a,o,l=-1){return $n[0]=e+(20<<Ct)+Rt,$n[1]=t.x,$n[2]=t.y,$n[3]=i,$n[4]=r,$n[5]=s,$n[6]=o||0,$n[7]=n||0,$n[8]=a||0,$n[9]=l,$n}getBBox(e,t){let i=new ae(e[t+1],e[t+2]),r=e[t+3],s=e[t+4],n=e[t+5];if(n===0)return Kt.modify(i.x,i.x+r,i.y-s,i.y);let a=Yt(0,0,n),o=Yt(0,-s,n),l=Yt(r,0,n),h=Yt(r,-s,n),c=i.add1(a.x,a.y),d=i.add1(o.x,o.y),f=i.add1(l.x,l.y),u=i.add1(h.x,h.y);return Kt.modify(Math.min(c.x,d.x,f.x,u.x),Math.max(c.x,d.x,f.x,u.x),Math.min(c.y,d.y,f.y,u.y),Math.max(c.y,d.y,f.y,u.y))}},Qne=new xj(20,vj,EP);var Da=class{static init(e){let t=!1;try{WI.value.location.search}catch{t=!0}t||(this.url=new URLSearchParams(e.location.search),this._useProxy=this.url.has("useProxy"),this._useCpuEngine=this.url.has("cpuEngine"),this._useGpuEngine=this.url.has("gpuEngine"),this._minRenderGridWH=Number(this.url.get("minRenderGridWH"))||0,this._enableLog=this.url.has("enableLog"),this._infiniteScaling=this.url.has("infiniteScaling"),this._isContinuedRender=this.url.has("isContinuedRender"))}static useProxy(){return this._useProxy}static useCpuEngine(){return this._useCpuEngine}static useGpuEngine(){return this._useGpuEngine}static getMinRenderGridWH(){return this._minRenderGridWH}static isEnableLog(){return this._enableLog}static getInfiniteScaling(){return this._infiniteScaling}static isContinuedRender(){return this._isContinuedRender}};Da.url=null,Da._useProxy=!1,Da._useCpuEngine=!1,Da._useGpuEngine=!1,Da._minRenderGridWH=0,Da._enableLog=!1,Da._infiniteScaling=!1,Da._isContinuedRender=!1;var Xc=class extends Da{static init(e){super.init(e),this.url&&(this._logFps=this.url.has("logFps"),this._forceRender=this.url.has("render"),this._textureSize=Number(this.url.get("textureSize"))||0,this._macNoOnSubmittedWorkDone=this.url.has("macNoOnSubmittedWorkDone"),this._closeGridMulAcc=this.url.has("closeGridMulAcc"),this._closeGirdRender=this.url.has("closeGridRender"))}static macNoOnSubmittedWorkDone(){return this._macNoOnSubmittedWorkDone}static useLogFps(){return this._logFps}static useForceRender(){return this._forceRender}static getTextureSize(){return this._textureSize}static isCloseGridMulAcc(){return this._closeGridMulAcc}static isCloseGridRender(){return this._closeGirdRender}};Xc._logFps=!1,Xc._forceRender=!1,Xc._textureSize=0,Xc._macNoOnSubmittedWorkDone=!1,Xc._closeGridMulAcc=!1,Xc._closeGirdRender=!1;var Ej=class extends Da{static init(e){super.init(e),this.url&&this.url.get("alpha")&&(this._alpha=Number(this.url.get("alpha")))}static getAlpha(){return this._alpha}};Ej._alpha=void 0;var wj=Io*3,wP=(e=>(e[e.ID=0]="ID",e[e.POSITION_X=1]="POSITION_X",e[e.POSITION_Y=2]="POSITION_Y",e[e.WIDTH=3]="WIDTH",e[e.HEIGHT=4]="HEIGHT",e[e.ANGLE=5]="ANGLE",e[e.STRING_LENGTH=6]="STRING_LENGTH",e[e.STRING_INDEX=7]="STRING_INDEX",e[e.GROUP_ID=8]="GROUP_ID",e[e.COLOR_INDEX=9]="COLOR_INDEX",e[e.ORDER=10]="ORDER",e[e.WIDTH_OFFSET_RATIO=11]="WIDTH_OFFSET_RATIO",e[e.HEIGHT_OFFSET_RATIO=12]="HEIGHT_OFFSET_RATIO",e))(wP||{}),Tj=13,Gs=[],Sj=class extends cr{create(e,t,i,r,s,n,a,o=-1,l,h,c,d){return Gs[0]=e+(66<<Ct)+Rt,Gs[1]=t.x,Gs[2]=t.y,Gs[3]=i,Gs[4]=r,Gs[5]=(s%In+In)%In,Gs[6]=n,Gs[7]=a,Gs[8]=o,Gs[9]=l||0,Gs[10]=h||0,Gs[11]=c||0,Gs[12]=d||0,Gs}getBBox(e,t){let i=e[t+1],r=e[t+2],s=e[t+5],n=e[t+3]/2,a=e[t+4]/2,o=e[t+11],l=e[t+12];if(i+=o*n*2,r+=l*a*2,s===0||s===Math.PI)return Kt.modify(i-n,i+n,r-a,r+a);if(s===Io||s===wj)return Kt.modify(i-a,i+a,r-n,r+n);let h=Yt(n,-a,s),c=Yt(n,a,s),d=Yt(-n,-a,s),f=Yt(-n,a,s),u={x:i+f.x,y:r+f.y},p={x:i+d.x,y:r+d.y},g={x:i+c.x,y:r+c.y},_={x:i+h.x,y:r+h.y};return Kt.modify(Math.min(u.x,p.x,g.x,_.x),Math.max(u.x,p.x,g.x,_.x),Math.min(u.y,p.y,g.y,_.y),Math.max(u.y,p.y,g.y,_.y))}},tae=new Sj(66,Tj,wP);var sae=Io*3,Fy=(e=>(e[e.ID=0]="ID",e[e.POSITION_X=1]="POSITION_X",e[e.POSITION_Y=2]="POSITION_Y",e[e.ANGLE=3]="ANGLE",e[e.ORDER=4]="ORDER",e[e.GROUP_ID=5]="GROUP_ID",e))(Fy||{}),TP=6,Na=[],SP=class extends cr{create(e,t,i,r,s=-1){return Na[1]=t.x,Na[2]=t.y,Na[3]=i,Na[4]=r||0,Na[5]=s,Na}getBBox(e,t,i,r){let s=r[1],n=s+r[3],a=r[2],o=r[4]/2,l=a/2,h=e[t+1],c=e[t+2],d=e[t+3];if(d===0)return Kt.modify(h,h+n,c-l,c+l);let f=Yt(0,0,d),u=Yt(s,l,d),p=Yt(s,-l,d),g=Yt(n,o,d),_=Yt(n,-o,d),y={x:h+f.x,y:c+f.y},m={x:h+u.x,y:c+u.y},O={x:h+p.x,y:c+p.y},b={x:h+g.x,y:c+g.y},v={x:h+_.x,y:c+_.y};return Kt.modify(Math.min(y.x,m.x,O.x,b.x,v.x),Math.max(y.x,m.x,O.x,b.x,v.x),Math.min(y.y,m.y,O.y,b.y,v.y),Math.max(y.y,m.y,O.y,b.y,v.y))}},Ij=class extends SP{create(e,t,i,r,s=-1){return super.create(e,t,i,r,s),Na[0]=e+(67<<Ct)+Rt,Na}},Pj=class extends SP{create(e,t,i,r,s=-1){return super.create(e,t,i,r,s),Na[0]=e+(68<<Ct)+Rt,Na}},nae=new Ij(67,TP,Fy),aae=new Pj(68,TP,Fy);var lae=2*Math.PI;var hae=new Error("list is empty");var sa=(e=>(e[e.NOTSHOW=0]="NOTSHOW",e[e.ONLYAXIS=1]="ONLYAXIS",e[e.SHOW=2]="SHOW",e))(sa||{}),Oh=(e=>(e[e.Line=0]="Line",e[e.Point=1]="Point",e[e.None=2]="None",e))(Oh||{});function Aj(e,t,i,r){let s=e.getScale(),n=0,a=s;for(;;)if(a>=1){if(a=a/10,a<1)break;n++}else if(a=a*10,n--,a>=1)break;let o=s/Math.pow(10,n);return o>=1&&o<2?s=Math.pow(10,n):o>=2&&o<5?s=2*Math.pow(10,n):s=5*Math.pow(10,n),s=s>500?500:s,t.conversion1("mil",i,r)/s}function IP(e){return rr.build(e.r,e.g,e.b,e.alpha+.1)}var Sf=class{constructor(t){this.bgRuler=new Cj(t),this.scaleRuler=new Lj}render(t,i,r,s,n){n=IP(n),this.bgRuler.render(t,s,n),this.scaleRuler.render(t,i,r,n)}};Sf.DELTA=18,Sf.canvasOrigin=new ae(Sf.DELTA,Sf.DELTA);var Ai=Sf,Cj=class{constructor(e){this.sceneType=e}render(e,t,i){let r=e.getContext();e.setFillStyle(t.toRGBAString()),r.fillRect(0,0,r.canvas.width,Ai.DELTA),r.fillRect(0,0,Ai.DELTA,r.canvas.height),qj.includes(this.sceneType)&&(e.setLineWidth(1),e.setStrokeStyle(i.toRGBAString()),r.beginPath(),r.moveTo(Ai.DELTA,Ai.DELTA),r.lineTo(Ai.DELTA,r.canvas.height),r.stroke(),r.beginPath(),r.moveTo(Ai.DELTA,Ai.DELTA),r.lineTo(r.canvas.width,Ai.DELTA),r.stroke())}},Lj=class{constructor(){this.primitives=[],this.spacing=2,this.scale=1,this.ratio=5,this.delta=1,this.unit="mil",this.magnification=10,this.unitConversion=new Bf,this.fontSize=14,this.offNum=5}get spacing10(){return this.spacing*this.ratio*this.scale*10}modifyUnit(e){e!=this.unit&&(e!="mil"?this.scale=this.unitConversion.conversion(e,"mil",1)/100:this.scale=1,this.unit=e)}clearPrimitives(){this.primitives.length=0}updateMagnification(e){this.magnification=Ra(e)}updateDelta(e){this.delta=Ra(e)}createRuler(e,t,i,r){let s,n,a;t===0?(s=-1,n=0,a=2):(s=1,n=1,a=3);let o=Ra(s*Math.floor(i/r)*this.delta),l=i%r;if(t===0)if(i>=0){let h=10-Math.abs(Ra(o/this.delta)%10),c=Ra(o+s*this.delta*h),d=c.toString(),f=this.ctx.getContext().measureText(d).width;if((h-1)*r<f){let u=Ai.DELTA-h*r+Math.abs(l),p=new U_(d,c,t,new xt(u+f+3,Ai.DELTA/2,0),!0);this.primitives.push(p)}}else{let h=Math.abs(o/this.delta)%10;if(h!==0){let c=Ra(o+s*this.delta*h),d=c.toString(),f=this.ctx.getContext().measureText(d).width;if((h-1)*r<f){let u=Ai.DELTA-h*r+(l+r),p=new U_(d,c,t,new xt(u+f+3,Ai.DELTA/2,0),!0);this.primitives.push(p)}}}for(let h=l<0?l+r:l;h<=e;h+=r){let c=h+Ai.DELTA,d=[Ai.DELTA,Ai.DELTA,Ai.DELTA-this.offNum,Ai.DELTA-this.offNum];d[n]=c,d[a]=c,this.createScale(d,o,t),o=Ra(o-s*this.delta)}}createScale(e,t,i){let r=IS(t,this.magnification)===0,s=IS(t,this.magnification/2)===0;r?i===0?e[3]=0:e[2]=0:s&&(i===0?e[3]=Ai.DELTA/2:e[2]=Ai.DELTA/2);let n=new F_(i,e);if(this.primitives.push(n),r){let a=t.toString(),o=new U_(a,t,i,new xt(i===0?e[0]+3:Ai.DELTA/2,i===0?Ai.DELTA/2:e[1]-3,0));this.primitives.push(o)}}createScaleIdentification(e){let t=e.getScreenPosition().multiply4(e.get2dCameraMatrix().getInverseMatrix()),{x:i,y:r}=t.multiply4(e.getRenderMatrix()).scale(1/e.getSampling());if(i>=Ai.canvasOrigin.x){let s=[i,Ai.DELTA,i,0];this.primitives.push(new F_(0,s))}if(r>=Ai.canvasOrigin.y){let s=[Ai.DELTA,r,0,r];this.primitives.push(new F_(1,s))}}autoScale(e){let t=Aj(e,this.unitConversion,this.unit,this.spacing10),i=10,r=1;this.unit=="inch"&&(i=1,r=.1),this.updateMagnification(t*i),this.updateDelta(t*r)}render(e,t,i,r){this.autoScale(t);let s=e.getContext();this.ctx=e,e.save();let n=IP(r).toRGBAString();e.setStrokeStyle(n),e.setLineWidth(1),e.setFillStyle(n),e.setTextBaseLine("middle"),e.setFont(`normal ${this.fontSize}px ${iH}`);let a=s.canvas.width,o=s.canvas.height,l=i,h=l.multiply4(t.getRenderMatrix()).scale(1/t.getSampling()),c=h.sub(Ai.canvasOrigin),d=this.unitConversion.conversion1(this.unit,"mil",this.magnification)/10,f=new ae(d,0).add(l).multiply4(t.getRenderMatrix()).scale(1/t.getSampling()),u=Math.abs(f.x-h.x)/10,p=Ra(-1*Math.floor(Math.max(Math.abs(c.x),Math.abs(c.y))/u)*this.delta);this.ctx.getContext().measureText(p.toString()).width>u*10&&(this.magnification*=2),this.createRuler(a,0,c.x,u),this.createRuler(o,1,c.y,u),this.createScaleIdentification(t);let g=7;this.primitives.forEach(_=>{if(s.beginPath(),_ instanceof F_){let{startPoint:{x:y,y:m},width:O,height:b}=_.getRectInfo();s.fillRect(y,m,O,b)}else if(_ instanceof U_){if(_.text==="")return;let{x:y,y:m}=_.getPosition();if(_.direction===1){let O=0,b=0;if(_.text[0]==="-"){if(m-s.measureText("-").width<=Ai.DELTA)return;e.save(),e.setTranslate(y,m),e.setRotate(-Math.PI/2),s.fillText("-",0,0),e.restore(),b=g/2,O=1}for(;O<_.text.length;O++){let v=m-O*g+b;if(v-s.measureText(_.text[O]).width<=Ai.DELTA)return;e.save(),e.setTranslate(y,v),e.setRotate(-Math.PI/2),s.fillText(_.text[O],0,0),e.restore()}}else if(_.isSpecial){e.save();let O=s.measureText(_.text).width,b=y-O;e.setTranslate(b,m);let v=0;for(let E=0;E<_.text.length;E++){let T=_.text[E],P=s.measureText(T).width;b+v>=Ai.DELTA&&s.fillText(T,v,0),v=v+P}e.restore()}else s.fillText(_.text,y,m)}else throw Error("not support")}),e.restore(),this.clearPrimitives()}},F_=class{constructor(e,t){if(this.lineWidth=1,this.direction=e,e===0)this.rectInfo={startPoint:new xt(t[2],t[3],0),width:this.lineWidth,height:Ra(t[1]-t[3])};else if(e===1)this.rectInfo={startPoint:new xt(t[2],t[3],0),width:Ra(t[0]-t[2]),height:this.lineWidth};else throw new Error("not support the DIRECTION")}getRectInfo(){return this.rectInfo}},U_=class{constructor(e,t,i,r,s){this.text=e,this.scale=t,this.direction=i,this.position=r,this.isSpecial=s}getPosition(){return this.position}};function Ra(e){return Math.round(e*1e3)/1e3}function IS(e,t){let{integerPart:i,divisor:r}=a(e),{integerPart:s,divisor:n}=a(t);if(r>n)return i%Math.round(t*r)/r;return r<n?Math.round(e*n)%s/n:i%s/r;function a(o){let l=o.toString(),h=l.indexOf(".");if(h===-1)return{integerPart:o,divisor:1};let c=l.length-h-1,d=Math.pow(10,c);return{integerPart:Math.round(o*d),divisor:d}}}var Dj=6,yae=Dj-1,vae=2**16;var Rj=(e=>(e[e.ID=0]="ID",e[e.LD_POINT_X=1]="LD_POINT_X",e[e.LD_POINT_y=2]="LD_POINT_y",e[e.LU_POINT_X=3]="LU_POINT_X",e[e.LU_POINT_Y=4]="LU_POINT_Y",e[e.RD_POINT_X=5]="RD_POINT_X",e[e.RD_POINT_Y=6]="RD_POINT_Y",e[e.RU_POINT_X=7]="RU_POINT_X",e[e.RU_POINT_Y=8]="RU_POINT_Y",e[e.ORDER=9]="ORDER",e))(Rj||{});var PP=new ArrayBuffer(40),Iae=new Float64Array(PP),Pae=new Int32Array(PP);var oy=jz(),_O=oy.top||oy;try{_O.location&&_O.location.search}catch{_O=null}var Rae=_O&&Nj();function Nj(){let e=oy.PRO_LOG_LEVEL;return e=="trace"||e=="debug"}var Mj=(e=>(e.Auto="auto",e.WebGPU="webgpu",e.Canvas2D="canvas2d",e))(Mj||{}),Bj=(e=>(e[e.PCB=0]="PCB",e[e.SCH=1]="SCH",e[e.FOOTPRINT=2]="FOOTPRINT",e[e.ECAD=3]="ECAD",e[e.SYMBOL=4]="SYMBOL",e[e.DEFAULT=5]="DEFAULT",e))(Bj||{});var Uy=(e=>(e[e.USE_COLOR=0]="USE_COLOR",e[e.WIREFRAME=1]="WIREFRAME",e[e.USE_MATERIAL=2]="USE_MATERIAL",e[e.RELY_ON_OTHER=3]="RELY_ON_OTHER",e[e.FORCE_TO_USE_SINGLE_COLOR=4]="FORCE_TO_USE_SINGLE_COLOR",e))(Uy||{});var kj=(e=>(e[e.FIXED=0]="FIXED",e[e.ZOOM=1]="ZOOM",e))(kj||{}),Fj=(e=>(e[e.CROSS=0]="CROSS",e[e.TRIANGLE=1]="TRIANGLE",e))(Fj||{}),mu=(e=>(e[e.MASK=0]="MASK",e[e.PT=1]="PT",e))(mu||{}),Uj=(e=>(e[e.FOLLOW_SCALE=0]="FOLLOW_SCALE",e[e.ALWAYS_ONE_PX=1]="ALWAYS_ONE_PX",e))(Uj||{}),Gj=(e=>(e.BUTT="butt",e.ROUND="round",e.SQUARE="square",e))(Gj||{}),AP={butt:0,round:1,square:2};var zj=(e=>(e[e.None=0]="None",e[e.Solid=1]="Solid",e[e.Grid=2]="Grid",e[e.HorizontalLine=3]="HorizontalLine",e[e.VerticalLine=4]="VerticalLine",e[e.RhombicGrid=5]="RhombicGrid",e[e.LeftSlashLine=6]="LeftSlashLine",e[e.RightSlashLine=7]="RightSlashLine",e))(zj||{}),Hj=(e=>(e[e.NoWrap=0]="NoWrap",e[e.Wrap=1]="Wrap",e))(Hj||{}),jj=(e=>(e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Center=2]="Center",e))(jj||{}),Vj=(e=>(e[e.Top=0]="Top",e[e.Bottom=1]="Bottom",e[e.Middle=2]="Middle",e))(Vj||{}),Yj=(e=>(e[e.HIDE=0]="HIDE",e[e.VISIBLE=1]="VISIBLE",e))(Yj||{}),PS=class{};PS.LogState=!0,PS.LogTextureChange=!0;var qj=[1,3,4];var Wj=(e=>(e[e.FOLLOW_SCENE=0]="FOLLOW_SCENE",e[e.WIREFRAME=1]="WIREFRAME",e[e.USE_COLOR=2]="USE_COLOR",e))(Wj||{});var Bae=2**31;var Xj=64*2**10,Jj=256;if(!Number.isInteger(Xj/Jj))throw new Error("!Number.isInteger(MIN_BUFFER_SIZE / CHUNK_SIZE)");var CP=Symbol("release"),AS=2**32;function Pb(e,t,i,r){return`${e}-${t}-${i}-${r}`}var Gae=class{constructor(e,...t){this.gpu=e,this.size=0,this.texturesIndex={};for(let i of t){let[r,s,n,a,o]=i,l=this.getOrInitTextures(r,s,n,a);for(let h=0;h<o;h++)l.push(this.createTexture(r,s,n,a))}}getOrInitTextures(e,t,i,r){let s=Pb(e,t,i,r);return this.texturesIndex[s]||(this.texturesIndex[s]=[])}createTexture(e,t,i,r){return this.size+=e*t*4,new Zj(this,this.gpu.createDynamicTexture(e,t,i,r,"texturePool-"+Pb(e,t,i,r)))}getTexture(e,t,i,r){let s=this.getOrInitTextures(e,t,i,r);return s.length===0?this.createTexture(e,t,i,r):s.pop()}[CP](e){let{width:t,height:i,format:r,usage:s}=e.texture;this.texturesIndex[Pb(t,i,r,s)].push(e)}recall(){if(this.size<=AS)return;let e=Object.values(this.texturesIndex),t=e.pop();for(;this.size>AS&&t;){let i=t.pop();if(i){let r=i.texture;this.size-=r.width*r.height*4,r.destroy()}else t=e.pop()}}},Zj=class{constructor(e,t){this.pool=e,this.texture=t}release(){this.pool[CP](this)}};var jae=Symbol("ruler");var Wae=xI(YI()),ly=0,Kj=1,CS=1,LS=100,DS=204,RS=205,NS=0,MS=1,BS=2,bO=3,kS=4,FS=5,US=6,GS=7,$j=0,LP=300,Qj=301,zS=1e3,uu=1001,HS=1002,Ou=1003,eV=1006,tV=1008,iV=1009,rV=1014,sV=1015;var nV=1020,aV=1023,Ab=1026,jS=1027,yO=2300,hy=2301,Cb=2302,VS=2400,YS=2401,qS=2402,DP="",ra="srgb",WS="srgb-linear",XS="linear",Lb="srgb",Jc=7680,JS=519,ZS=35044,ph=2e3,cy=2001,TO=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}},vs=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],oV=Math.PI/180,Jae=180/Math.PI;function bu(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(vs[e&255]+vs[e>>8&255]+vs[e>>16&255]+vs[e>>24&255]+"-"+vs[t&255]+vs[t>>8&255]+"-"+vs[t>>16&15|64]+vs[t>>24&255]+"-"+vs[i&63|128]+vs[i>>8&255]+"-"+vs[i>>16&255]+vs[i>>24&255]+vs[r&255]+vs[r>>8&255]+vs[r>>16&255]+vs[r>>24&255]).toLowerCase()}function Vt(e,t,i){return Math.max(t,Math.min(i,e))}function lV(e,t){return(e%t+t)%t}function Db(e,t,i){return(1-i)*e+i*t}function yf(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function zs(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}var Je=class RP{constructor(t=0,i=0){RP.prototype.isVector2=!0,this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let i=this.x,r=this.y,s=t.elements;return this.x=s[0]*i+s[3]*r+s[6],this.y=s[1]*i+s[4]*r+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=Vt(this.x,t.x,i.x),this.y=Vt(this.y,t.y,i.y),this}clampScalar(t,i){return this.x=Vt(this.x,t,i),this.y=Vt(this.y,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Vt(r,t,i))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;let r=this.dot(t)/i;return Math.acos(Vt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let i=this.x-t.x,r=this.y-t.y;return i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){let r=Math.cos(i),s=Math.sin(i),n=this.x-t.x,a=this.y-t.y;return this.x=n*r-a*s+t.x,this.y=n*s+a*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jt=class NP{constructor(t,i,r,s,n,a,o,l,h){NP.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,r,s,n,a,o,l,h)}set(t,i,r,s,n,a,o,l,h){let c=this.elements;return c[0]=t,c[1]=s,c[2]=o,c[3]=i,c[4]=n,c[5]=l,c[6]=r,c[7]=a,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let i=this.elements,r=t.elements;return i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],this}extractBasis(t,i,r){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){let r=t.elements,s=i.elements,n=this.elements,a=r[0],o=r[3],l=r[6],h=r[1],c=r[4],d=r[7],f=r[2],u=r[5],p=r[8],g=s[0],_=s[3],y=s[6],m=s[1],O=s[4],b=s[7],v=s[2],E=s[5],T=s[8];return n[0]=a*g+o*m+l*v,n[3]=a*_+o*O+l*E,n[6]=a*y+o*b+l*T,n[1]=h*g+c*m+d*v,n[4]=h*_+c*O+d*E,n[7]=h*y+c*b+d*T,n[2]=f*g+u*m+p*v,n[5]=f*_+u*O+p*E,n[8]=f*y+u*b+p*T,this}multiplyScalar(t){let i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8];return i*a*c-i*o*h-r*n*c+r*o*l+s*n*h-s*a*l}invert(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],d=c*a-o*h,f=o*l-c*n,u=h*n-a*l,p=i*d+r*f+s*u;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/p;return t[0]=d*g,t[1]=(s*h-c*r)*g,t[2]=(o*r-s*a)*g,t[3]=f*g,t[4]=(c*i-s*l)*g,t[5]=(s*n-o*i)*g,t[6]=u*g,t[7]=(r*l-h*i)*g,t[8]=(a*i-r*n)*g,this}transpose(){let t,i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,r,s,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(r*l,r*h,-r*(l*a+h*o)+a+t,-s*h,s*l,-s*(-h*a+l*o)+o+i,0,0,1),this}scale(t,i){return this.premultiply(Rb.makeScale(t,i)),this}rotate(t){return this.premultiply(Rb.makeRotation(-t)),this}translate(t,i){return this.premultiply(Rb.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,-r,0,r,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){let i=this.elements,r=t.elements;for(let s=0;s<9;s++)if(i[s]!==r[s])return!1;return!0}fromArray(t,i=0){for(let r=0;r<9;r++)this.elements[r]=t[r+i];return this}toArray(t=[],i=0){let r=this.elements;return t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2],t[i+3]=r[3],t[i+4]=r[4],t[i+5]=r[5],t[i+6]=r[6],t[i+7]=r[7],t[i+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}},Rb=new jt;function hV(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function KS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var $S=new jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),QS=new jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cV(){let e={enabled:!0,workingColorSpace:WS,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Lb&&(s.r=To(s.r),s.g=To(s.g),s.b=To(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Lb&&(s.r=fu(s.r),s.g=fu(s.g),s.b=fu(s.b))),s},fromWorkingColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===DP?XS:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[WS]:{primaries:t,whitePoint:r,transfer:XS,toXYZ:$S,fromXYZ:QS,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:ra},outputColorSpaceConfig:{drawingBufferColorSpace:ra}},[ra]:{primaries:t,whitePoint:r,transfer:Lb,toXYZ:$S,fromXYZ:QS,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:ra}}}),e}var Qn=cV();function To(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function fu(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var Zc,uV=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Zc===void 0&&(Zc=KS("canvas")),Zc.width=e.width,Zc.height=e.height;let i=Zc.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Zc}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=KS("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let n=0;n<s.length;n++)s[n]=To(s[n]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(To(t[i]/255)*255):t[i]=To(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},dV=0,fV=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:dV++}),this.uuid=bu(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let n=0,a=r.length;n<a;n++)r[n].isDataTexture?s.push(Nb(r[n].image)):s.push(Nb(r[n]))}else s=Nb(r);i.url=s}return t||(e.images[this.uuid]=i),i}};function Nb(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?uV.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var pV=0,Ol=class OO extends TO{constructor(t=OO.DEFAULT_IMAGE,i=OO.DEFAULT_MAPPING,r=uu,s=uu,n=eV,a=tV,o=aV,l=iV,h=OO.DEFAULT_ANISOTROPY,c=DP){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:pV++}),this.uuid=bu(),this.name="",this.source=new fV(t),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=r,this.wrapT=s,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Je(0,0),this.repeat=new Je(1,1),this.center=new Je(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let i=t===void 0||typeof t=="string";if(!i&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),i||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==LP)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case zS:t.x=t.x-Math.floor(t.x);break;case uu:t.x=t.x<0?0:1;break;case HS:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case zS:t.y=t.y-Math.floor(t.y);break;case uu:t.y=t.y<0?0:1;break;case HS:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Ol.DEFAULT_IMAGE=null;Ol.DEFAULT_MAPPING=LP;Ol.DEFAULT_ANISOTROPY=1;var Ff=class MP{constructor(t=0,i=0,r=0,s=1){MP.prototype.isVector4=!0,this.x=t,this.y=i,this.z=r,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,r,s){return this.x=t,this.y=i,this.z=r,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let i=this.x,r=this.y,s=this.z,n=this.w,a=t.elements;return this.x=a[0]*i+a[4]*r+a[8]*s+a[12]*n,this.y=a[1]*i+a[5]*r+a[9]*s+a[13]*n,this.z=a[2]*i+a[6]*r+a[10]*s+a[14]*n,this.w=a[3]*i+a[7]*r+a[11]*s+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,r,s,n,a=t.elements,o=a[0],l=a[4],h=a[8],c=a[1],d=a[5],f=a[9],u=a[2],p=a[6],g=a[10];if(Math.abs(l-c)<.01&&Math.abs(h-u)<.01&&Math.abs(f-p)<.01){if(Math.abs(l+c)<.1&&Math.abs(h+u)<.1&&Math.abs(f+p)<.1&&Math.abs(o+d+g-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;let y=(o+1)/2,m=(d+1)/2,O=(g+1)/2,b=(l+c)/4,v=(h+u)/4,E=(f+p)/4;return y>m&&y>O?y<.01?(r=0,s=.707106781,n=.707106781):(r=Math.sqrt(y),s=b/r,n=v/r):m>O?m<.01?(r=.707106781,s=0,n=.707106781):(s=Math.sqrt(m),r=b/s,n=E/s):O<.01?(r=.707106781,s=.707106781,n=0):(n=Math.sqrt(O),r=v/n,s=E/n),this.set(r,s,n,i),this}let _=Math.sqrt((p-f)*(p-f)+(h-u)*(h-u)+(c-l)*(c-l));return Math.abs(_)<.001&&(_=1),this.x=(p-f)/_,this.y=(h-u)/_,this.z=(c-l)/_,this.w=Math.acos((o+d+g-1)/2),this}setFromMatrixPosition(t){let i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this.w=i[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=Vt(this.x,t.x,i.x),this.y=Vt(this.y,t.y,i.y),this.z=Vt(this.z,t.z,i.z),this.w=Vt(this.w,t.w,i.w),this}clampScalar(t,i){return this.x=Vt(this.x,t,i),this.y=Vt(this.y,t,i),this.z=Vt(this.z,t,i),this.w=Vt(this.w,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Vt(r,t,i))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this.z=t.z+(i.z-t.z)*r,this.w=t.w+(i.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},gV=class extends Ol{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ou,this.minFilter=Ou,this.wrapR=uu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},_V=class extends Ol{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ou,this.minFilter=Ou,this.wrapR=uu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ml=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,n,a){let o=i[r+0],l=i[r+1],h=i[r+2],c=i[r+3],d=s[n+0],f=s[n+1],u=s[n+2],p=s[n+3];if(a===0){e[t+0]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=u,e[t+3]=p;return}if(c!==p||o!==d||l!==f||h!==u){let g=1-a,_=o*d+l*f+h*u+c*p,y=_>=0?1:-1,m=1-_*_;if(m>Number.EPSILON){let b=Math.sqrt(m),v=Math.atan2(b,_*y);g=Math.sin(g*v)/b,a=Math.sin(a*v)/b}let O=a*y;if(o=o*g+d*O,l=l*g+f*O,h=h*g+u*O,c=c*g+p*O,g===1-a){let b=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=b,l*=b,h*=b,c*=b}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,r,s,n){let a=i[r],o=i[r+1],l=i[r+2],h=i[r+3],c=s[n],d=s[n+1],f=s[n+2],u=s[n+3];return e[t]=a*u+h*c+o*f-l*d,e[t+1]=o*u+h*d+l*c-a*f,e[t+2]=l*u+h*f+a*d-o*c,e[t+3]=h*u-a*c-o*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,n=e._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(r/2),c=a(s/2),d=o(i/2),f=o(r/2),u=o(s/2);switch(n){case"XYZ":this._x=d*h*c+l*f*u,this._y=l*f*c-d*h*u,this._z=l*h*u+d*f*c,this._w=l*h*c-d*f*u;break;case"YXZ":this._x=d*h*c+l*f*u,this._y=l*f*c-d*h*u,this._z=l*h*u-d*f*c,this._w=l*h*c+d*f*u;break;case"ZXY":this._x=d*h*c-l*f*u,this._y=l*f*c+d*h*u,this._z=l*h*u+d*f*c,this._w=l*h*c-d*f*u;break;case"ZYX":this._x=d*h*c-l*f*u,this._y=l*f*c+d*h*u,this._z=l*h*u-d*f*c,this._w=l*h*c+d*f*u;break;case"YZX":this._x=d*h*c+l*f*u,this._y=l*f*c+d*h*u,this._z=l*h*u-d*f*c,this._w=l*h*c-d*f*u;break;case"XZY":this._x=d*h*c-l*f*u,this._y=l*f*c-d*h*u,this._z=l*h*u+d*f*c,this._w=l*h*c+d*f*u;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],c=t[10],d=i+a+c;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-o)*f,this._y=(s-l)*f,this._z=(n-r)*f}else if(i>a&&i>c){let f=2*Math.sqrt(1+i-a-c);this._w=(h-o)/f,this._x=.25*f,this._y=(r+n)/f,this._z=(s+l)/f}else if(a>c){let f=2*Math.sqrt(1+a-i-c);this._w=(s-l)/f,this._x=(r+n)/f,this._y=.25*f,this._z=(o+h)/f}else{let f=2*Math.sqrt(1+c-i-a);this._w=(n-r)/f,this._x=(s+l)/f,this._y=(o+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Vt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,n=e._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+n*a+r*l-s*o,this._y=r*h+n*o+s*a-i*l,this._z=s*h+n*l+i*o-r*a,this._w=n*h-i*a-r*o-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,n=this._w,a=n*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=n,this._x=i,this._y=r,this._z=s,this;let o=1-a*a;if(o<=Number.EPSILON){let f=1-t;return this._w=f*n+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=n*c+this._w*d,this._x=i*c+this._x*d,this._y=r*c+this._y*d,this._z=s*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},fe=class BP{constructor(t=0,i=0,r=0){BP.prototype.isVector3=!0,this.x=t,this.y=i,this.z=r}set(t,i,r){return r===void 0&&(r=this.z),this.x=t,this.y=i,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(eI.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(eI.setFromAxisAngle(t,i))}applyMatrix3(t){let i=this.x,r=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[3]*r+n[6]*s,this.y=n[1]*i+n[4]*r+n[7]*s,this.z=n[2]*i+n[5]*r+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let i=this.x,r=this.y,s=this.z,n=t.elements,a=1/(n[3]*i+n[7]*r+n[11]*s+n[15]);return this.x=(n[0]*i+n[4]*r+n[8]*s+n[12])*a,this.y=(n[1]*i+n[5]*r+n[9]*s+n[13])*a,this.z=(n[2]*i+n[6]*r+n[10]*s+n[14])*a,this}applyQuaternion(t){let i=this.x,r=this.y,s=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*s-o*r),c=2*(o*i-n*s),d=2*(n*r-a*i);return this.x=i+l*h+a*d-o*c,this.y=r+l*c+o*h-n*d,this.z=s+l*d+n*c-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let i=this.x,r=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[4]*r+n[8]*s,this.y=n[1]*i+n[5]*r+n[9]*s,this.z=n[2]*i+n[6]*r+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=Vt(this.x,t.x,i.x),this.y=Vt(this.y,t.y,i.y),this.z=Vt(this.z,t.z,i.z),this}clampScalar(t,i){return this.x=Vt(this.x,t,i),this.y=Vt(this.y,t,i),this.z=Vt(this.z,t,i),this}clampLength(t,i){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Vt(r,t,i))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this.z=t.z+(i.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){let r=t.x,s=t.y,n=t.z,a=i.x,o=i.y,l=i.z;return this.x=s*l-n*o,this.y=n*a-r*l,this.z=r*o-s*a,this}projectOnVector(t){let i=t.lengthSq();if(i===0)return this.set(0,0,0);let r=t.dot(this)/i;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Mb.copy(this).projectOnVector(t),this.sub(Mb)}reflect(t){return this.sub(Mb.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;let r=this.dot(t)/i;return Math.acos(Vt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let i=this.x-t.x,r=this.y-t.y,s=this.z-t.z;return i*i+r*r+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,r){let s=Math.sin(i)*t;return this.x=s*Math.sin(r),this.y=Math.cos(i)*t,this.z=s*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,r){return this.x=t*Math.sin(i),this.y=r,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){let i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){let i=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=r,this.z=s,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,i=Math.random()*2-1,r=Math.sqrt(1-i*i);return this.x=r*Math.cos(t),this.y=i,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Mb=new fe,eI=new ml,bl=class{constructor(e=new fe(1/0,1/0,1/0),t=new fe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ea.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ea.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=ea.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let n=0,a=s.count;n<a;n++)e.isMesh===!0?e.getVertexPosition(n,ea):ea.fromBufferAttribute(s,n),ea.applyMatrix4(e.matrixWorld),this.expandByPoint(ea);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),G_.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),G_.copy(i.boundingBox)),G_.applyMatrix4(e.matrixWorld),this.union(G_)}let r=e.children;for(let s=0,n=r.length;s<n;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ea),ea.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(vf),z_.subVectors(this.max,vf),Kc.subVectors(e.a,vf),$c.subVectors(e.b,vf),Qc.subVectors(e.c,vf),ll.subVectors($c,Kc),hl.subVectors(Qc,$c),hh.subVectors(Kc,Qc);let t=[0,-ll.z,ll.y,0,-hl.z,hl.y,0,-hh.z,hh.y,ll.z,0,-ll.x,hl.z,0,-hl.x,hh.z,0,-hh.x,-ll.y,ll.x,0,-hl.y,hl.x,0,-hh.y,hh.x,0];return!Bb(t,Kc,$c,Qc,z_)||(t=[1,0,0,0,1,0,0,0,1],!Bb(t,Kc,$c,Qc,z_))?!1:(H_.crossVectors(ll,hl),t=[H_.x,H_.y,H_.z],Bb(t,Kc,$c,Qc,z_))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ea).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ea).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(bo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),bo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),bo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),bo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),bo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),bo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),bo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),bo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(bo),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},bo=[new fe,new fe,new fe,new fe,new fe,new fe,new fe,new fe],ea=new fe,G_=new bl,Kc=new fe,$c=new fe,Qc=new fe,ll=new fe,hl=new fe,hh=new fe,vf=new fe,z_=new fe,H_=new fe,ch=new fe;function Bb(e,t,i,r,s){for(let n=0,a=e.length-3;n<=a;n+=3){ch.fromArray(e,n);let o=s.x*Math.abs(ch.x)+s.y*Math.abs(ch.y)+s.z*Math.abs(ch.z),l=t.dot(ch),h=i.dot(ch),c=r.dot(ch);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}var OV=new bl,xf=new fe,kb=new fe,yl=class{constructor(e=new fe,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):OV.setFromPoints(e).getCenter(i);let r=0;for(let s=0,n=e.length;s<n;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xf.subVectors(e,this.center);let t=xf.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(xf,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(kb.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xf.copy(e.center).add(kb)),this.expandByPoint(xf.copy(e.center).sub(kb))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},yo=new fe,Fb=new fe,j_=new fe,cl=new fe,Ub=new fe,V_=new fe,Gb=new fe,SO=class{constructor(e=new fe,t=new fe(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yo)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=yo.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yo.copy(this.origin).addScaledVector(this.direction,t),yo.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Fb.copy(e).add(t).multiplyScalar(.5),j_.copy(t).sub(e).normalize(),cl.copy(this.origin).sub(Fb);let s=e.distanceTo(t)*.5,n=-this.direction.dot(j_),a=cl.dot(this.direction),o=-cl.dot(j_),l=cl.lengthSq(),h=Math.abs(1-n*n),c,d,f,u;if(h>0)if(c=n*o-a,d=n*a-o,u=s*h,c>=0)if(d>=-u)if(d<=u){let p=1/h;c*=p,d*=p,f=c*(c+n*d+2*a)+d*(n*c+d+2*o)+l}else d=s,c=Math.max(0,-(n*d+a)),f=-c*c+d*(d+2*o)+l;else d=-s,c=Math.max(0,-(n*d+a)),f=-c*c+d*(d+2*o)+l;else d<=-u?(c=Math.max(0,-(-n*s+a)),d=c>0?-s:Math.min(Math.max(-s,-o),s),f=-c*c+d*(d+2*o)+l):d<=u?(c=0,d=Math.min(Math.max(-s,-o),s),f=d*(d+2*o)+l):(c=Math.max(0,-(n*s+a)),d=c>0?s:Math.min(Math.max(-s,-o),s),f=-c*c+d*(d+2*o)+l);else d=n>0?-s:s,c=Math.max(0,-(n*d+a)),f=-c*c+d*(d+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),r&&r.copy(Fb).addScaledVector(j_,d),f}intersectSphere(e,t){yo.subVectors(e.center,this.origin);let i=yo.dot(this.direction),r=yo.dot(yo)-i*i,s=e.radius*e.radius;if(r>s)return null;let n=Math.sqrt(s-r),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,n,a,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,n=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,n=(e.min.y-d.y)*h),i>n||s>r||((s>i||isNaN(i))&&(i=s),(n<r||isNaN(r))&&(r=n),c>=0?(a=(e.min.z-d.z)*c,o=(e.max.z-d.z)*c):(a=(e.max.z-d.z)*c,o=(e.min.z-d.z)*c),i>o||a>r)||((a>i||i!==i)&&(i=a),(o<r||r!==r)&&(r=o),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,yo)!==null}intersectTriangle(e,t,i,r,s){Ub.subVectors(t,e),V_.subVectors(i,e),Gb.crossVectors(Ub,V_);let n=this.direction.dot(Gb),a;if(n>0){if(r)return null;a=1}else if(n<0)a=-1,n=-n;else return null;cl.subVectors(this.origin,e);let o=a*this.direction.dot(V_.crossVectors(cl,V_));if(o<0)return null;let l=a*this.direction.dot(Ub.cross(cl));if(l<0||o+l>n)return null;let h=-a*cl.dot(Gb);return h<0?null:this.at(h/n,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},li=class uy{constructor(t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_){uy.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_)}set(t,i,r,s,n,a,o,l,h,c,d,f,u,p,g,_){let y=this.elements;return y[0]=t,y[4]=i,y[8]=r,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=c,y[10]=d,y[14]=f,y[3]=u,y[7]=p,y[11]=g,y[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new uy().fromArray(this.elements)}copy(t){let i=this.elements,r=t.elements;return i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],i[9]=r[9],i[10]=r[10],i[11]=r[11],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],this}copyPosition(t){let i=this.elements,r=t.elements;return i[12]=r[12],i[13]=r[13],i[14]=r[14],this}setFromMatrix3(t){let i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,r){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,i,r){return this.set(t.x,i.x,r.x,0,t.y,i.y,r.y,0,t.z,i.z,r.z,0,0,0,0,1),this}extractRotation(t){let i=this.elements,r=t.elements,s=1/eu.setFromMatrixColumn(t,0).length(),n=1/eu.setFromMatrixColumn(t,1).length(),a=1/eu.setFromMatrixColumn(t,2).length();return i[0]=r[0]*s,i[1]=r[1]*s,i[2]=r[2]*s,i[3]=0,i[4]=r[4]*n,i[5]=r[5]*n,i[6]=r[6]*n,i[7]=0,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){let i=this.elements,r=t.x,s=t.y,n=t.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(s),h=Math.sin(s),c=Math.cos(n),d=Math.sin(n);if(t.order==="XYZ"){let f=a*c,u=a*d,p=o*c,g=o*d;i[0]=l*c,i[4]=-l*d,i[8]=h,i[1]=u+p*h,i[5]=f-g*h,i[9]=-o*l,i[2]=g-f*h,i[6]=p+u*h,i[10]=a*l}else if(t.order==="YXZ"){let f=l*c,u=l*d,p=h*c,g=h*d;i[0]=f+g*o,i[4]=p*o-u,i[8]=a*h,i[1]=a*d,i[5]=a*c,i[9]=-o,i[2]=u*o-p,i[6]=g+f*o,i[10]=a*l}else if(t.order==="ZXY"){let f=l*c,u=l*d,p=h*c,g=h*d;i[0]=f-g*o,i[4]=-a*d,i[8]=p+u*o,i[1]=u+p*o,i[5]=a*c,i[9]=g-f*o,i[2]=-a*h,i[6]=o,i[10]=a*l}else if(t.order==="ZYX"){let f=a*c,u=a*d,p=o*c,g=o*d;i[0]=l*c,i[4]=p*h-u,i[8]=f*h+g,i[1]=l*d,i[5]=g*h+f,i[9]=u*h-p,i[2]=-h,i[6]=o*l,i[10]=a*l}else if(t.order==="YZX"){let f=a*l,u=a*h,p=o*l,g=o*h;i[0]=l*c,i[4]=g-f*d,i[8]=p*d+u,i[1]=d,i[5]=a*c,i[9]=-o*c,i[2]=-h*c,i[6]=u*d+p,i[10]=f-g*d}else if(t.order==="XZY"){let f=a*l,u=a*h,p=o*l,g=o*h;i[0]=l*c,i[4]=-d,i[8]=h*c,i[1]=f*d+g,i[5]=a*c,i[9]=u*d-p,i[2]=p*d-u,i[6]=o*c,i[10]=g*d+f}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(mV,t,bV)}lookAt(t,i,r){let s=this.elements;return nn.subVectors(t,i),nn.lengthSq()===0&&(nn.z=1),nn.normalize(),ul.crossVectors(r,nn),ul.lengthSq()===0&&(Math.abs(r.z)===1?nn.x+=1e-4:nn.z+=1e-4,nn.normalize(),ul.crossVectors(r,nn)),ul.normalize(),Y_.crossVectors(nn,ul),s[0]=ul.x,s[4]=Y_.x,s[8]=nn.x,s[1]=ul.y,s[5]=Y_.y,s[9]=nn.y,s[2]=ul.z,s[6]=Y_.z,s[10]=nn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){let r=t.elements,s=i.elements,n=this.elements,a=r[0],o=r[4],l=r[8],h=r[12],c=r[1],d=r[5],f=r[9],u=r[13],p=r[2],g=r[6],_=r[10],y=r[14],m=r[3],O=r[7],b=r[11],v=r[15],E=s[0],T=s[4],P=s[8],A=s[12],C=s[1],M=s[5],H=s[9],k=s[13],F=s[2],j=s[6],L=s[10],R=s[14],x=s[3],I=s[7],S=s[11],D=s[15];return n[0]=a*E+o*C+l*F+h*x,n[4]=a*T+o*M+l*j+h*I,n[8]=a*P+o*H+l*L+h*S,n[12]=a*A+o*k+l*R+h*D,n[1]=c*E+d*C+f*F+u*x,n[5]=c*T+d*M+f*j+u*I,n[9]=c*P+d*H+f*L+u*S,n[13]=c*A+d*k+f*R+u*D,n[2]=p*E+g*C+_*F+y*x,n[6]=p*T+g*M+_*j+y*I,n[10]=p*P+g*H+_*L+y*S,n[14]=p*A+g*k+_*R+y*D,n[3]=m*E+O*C+b*F+v*x,n[7]=m*T+O*M+b*j+v*I,n[11]=m*P+O*H+b*L+v*S,n[15]=m*A+O*k+b*R+v*D,this}multiplyScalar(t){let i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){let t=this.elements,i=t[0],r=t[4],s=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],c=t[2],d=t[6],f=t[10],u=t[14],p=t[3],g=t[7],_=t[11],y=t[15];return p*(+n*l*d-s*h*d-n*o*f+r*h*f+s*o*u-r*l*u)+g*(+i*l*u-i*h*f+n*a*f-s*a*u+s*h*c-n*l*c)+_*(+i*h*d-i*o*u-n*a*d+r*a*u+n*o*c-r*h*c)+y*(-s*o*c-i*l*d+i*o*f+s*a*d-r*a*f+r*l*c)}transpose(){let t=this.elements,i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,r){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=i,s[14]=r),this}invert(){let t=this.elements,i=t[0],r=t[1],s=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],d=t[9],f=t[10],u=t[11],p=t[12],g=t[13],_=t[14],y=t[15],m=d*_*h-g*f*h+g*l*u-o*_*u-d*l*y+o*f*y,O=p*f*h-c*_*h-p*l*u+a*_*u+c*l*y-a*f*y,b=c*g*h-p*d*h+p*o*u-a*g*u-c*o*y+a*d*y,v=p*d*l-c*g*l-p*o*f+a*g*f+c*o*_-a*d*_,E=i*m+r*O+s*b+n*v;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/E;return t[0]=m*T,t[1]=(g*f*n-d*_*n-g*s*u+r*_*u+d*s*y-r*f*y)*T,t[2]=(o*_*n-g*l*n+g*s*h-r*_*h-o*s*y+r*l*y)*T,t[3]=(d*l*n-o*f*n-d*s*h+r*f*h+o*s*u-r*l*u)*T,t[4]=O*T,t[5]=(c*_*n-p*f*n+p*s*u-i*_*u-c*s*y+i*f*y)*T,t[6]=(p*l*n-a*_*n-p*s*h+i*_*h+a*s*y-i*l*y)*T,t[7]=(a*f*n-c*l*n+c*s*h-i*f*h-a*s*u+i*l*u)*T,t[8]=b*T,t[9]=(p*d*n-c*g*n-p*r*u+i*g*u+c*r*y-i*d*y)*T,t[10]=(a*g*n-p*o*n+p*r*h-i*g*h-a*r*y+i*o*y)*T,t[11]=(c*o*n-a*d*n-c*r*h+i*d*h+a*r*u-i*o*u)*T,t[12]=v*T,t[13]=(c*g*s-p*d*s+p*r*f-i*g*f-c*r*_+i*d*_)*T,t[14]=(p*o*s-a*g*s-p*r*l+i*g*l+a*r*_-i*o*_)*T,t[15]=(a*d*s-c*o*s+c*r*l-i*d*l-a*r*f+i*o*f)*T,this}scale(t){let i=this.elements,r=t.x,s=t.y,n=t.z;return i[0]*=r,i[4]*=s,i[8]*=n,i[1]*=r,i[5]*=s,i[9]*=n,i[2]*=r,i[6]*=s,i[10]*=n,i[3]*=r,i[7]*=s,i[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,r,s))}makeTranslation(t,i,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,i,0,0,1,r,0,0,0,1),this}makeRotationX(t){let i=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,i,-r,0,0,r,i,0,0,0,0,1),this}makeRotationY(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,0,r,0,0,1,0,0,-r,0,i,0,0,0,0,1),this}makeRotationZ(t){let i=Math.cos(t),r=Math.sin(t);return this.set(i,-r,0,0,r,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){let r=Math.cos(i),s=Math.sin(i),n=1-r,a=t.x,o=t.y,l=t.z,h=n*a,c=n*o;return this.set(h*a+r,h*o-s*l,h*l+s*o,0,h*o+s*l,c*o+r,c*l-s*a,0,h*l-s*o,c*l+s*a,n*l*l+r,0,0,0,0,1),this}makeScale(t,i,r){return this.set(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,i,r,s,n,a){return this.set(1,r,n,0,t,1,a,0,i,s,1,0,0,0,0,1),this}compose(t,i,r){let s=this.elements,n=i._x,a=i._y,o=i._z,l=i._w,h=n+n,c=a+a,d=o+o,f=n*h,u=n*c,p=n*d,g=a*c,_=a*d,y=o*d,m=l*h,O=l*c,b=l*d,v=r.x,E=r.y,T=r.z;return s[0]=(1-(g+y))*v,s[1]=(u+b)*v,s[2]=(p-O)*v,s[3]=0,s[4]=(u-b)*E,s[5]=(1-(f+y))*E,s[6]=(_+m)*E,s[7]=0,s[8]=(p+O)*T,s[9]=(_-m)*T,s[10]=(1-(f+g))*T,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,i,r){let s=this.elements,n=eu.set(s[0],s[1],s[2]).length(),a=eu.set(s[4],s[5],s[6]).length(),o=eu.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],ta.copy(this);let l=1/n,h=1/a,c=1/o;return ta.elements[0]*=l,ta.elements[1]*=l,ta.elements[2]*=l,ta.elements[4]*=h,ta.elements[5]*=h,ta.elements[6]*=h,ta.elements[8]*=c,ta.elements[9]*=c,ta.elements[10]*=c,i.setFromRotationMatrix(ta),r.x=n,r.y=a,r.z=o,this}makePerspective(t,i,r,s,n,a,o=ph){let l=this.elements,h=2*n/(i-t),c=2*n/(r-s),d=(i+t)/(i-t),f=(r+s)/(r-s),u,p;if(o===ph)u=-(a+n)/(a-n),p=-2*a*n/(a-n);else if(o===cy)u=-a/(a-n),p=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=c,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=u,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,i,r,s,n,a,o=ph){let l=this.elements,h=1/(i-t),c=1/(r-s),d=1/(a-n),f=(i+t)*h,u=(r+s)*c,p,g;if(o===ph)p=(a+n)*d,g=-2*d;else if(o===cy)p=n*d,g=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*c,l[9]=0,l[13]=-u,l[2]=0,l[6]=0,l[10]=g,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let i=this.elements,r=t.elements;for(let s=0;s<16;s++)if(i[s]!==r[s])return!1;return!0}fromArray(t,i=0){for(let r=0;r<16;r++)this.elements[r]=t[r+i];return this}toArray(t=[],i=0){let r=this.elements;return t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2],t[i+3]=r[3],t[i+4]=r[4],t[i+5]=r[5],t[i+6]=r[6],t[i+7]=r[7],t[i+8]=r[8],t[i+9]=r[9],t[i+10]=r[10],t[i+11]=r[11],t[i+12]=r[12],t[i+13]=r[13],t[i+14]=r[14],t[i+15]=r[15],t}},eu=new fe,ta=new li,mV=new fe(0,0,0),bV=new fe(1,1,1),ul=new fe,Y_=new fe,nn=new fe,tI=new li,iI=new ml,Uf=class kP{constructor(t=0,i=0,r=0,s=kP.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=r,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,r,s=this._order){return this._x=t,this._y=i,this._z=r,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i=this._order,r=!0){let s=t.elements,n=s[0],a=s[4],o=s[8],l=s[1],h=s[5],c=s[9],d=s[2],f=s[6],u=s[10];switch(i){case"XYZ":this._y=Math.asin(Vt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(f,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Vt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,n),this._z=0);break;case"ZXY":this._x=Math.asin(Vt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,u),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-Vt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,u),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(Vt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-d,n)):(this._x=0,this._y=Math.atan2(o,u));break;case"XZY":this._z=Math.asin(-Vt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,r){return tI.makeRotationFromQuaternion(t),this.setFromRotationMatrix(tI,i,r)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return iI.setFromEuler(this),this.setFromQuaternion(iI,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Uf.DEFAULT_ORDER="XYZ";var yV=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},vV=0,rI=new fe,tu=new ml,vo=new li,q_=new fe,Ef=new fe,xV=new fe,EV=new ml,sI=new fe(1,0,0),nI=new fe(0,1,0),aI=new fe(0,0,1),oI={type:"added"},wV={type:"removed"},iu={type:"childadded",child:null},zb={type:"childremoved",child:null},yu=class mO extends TO{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vV++}),this.uuid=bu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=mO.DEFAULT_UP.clone();let t=new fe,i=new Uf,r=new ml,s=new fe(1,1,1);function n(){r.setFromEuler(i,!1)}function a(){i.setFromQuaternion(r,void 0,!1)}i._onChange(n),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:i},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new li},normalMatrix:{value:new jt}}),this.matrix=new li,this.matrixWorld=new li,this.matrixAutoUpdate=mO.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=mO.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yV,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,i){this.quaternion.setFromAxisAngle(t,i)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,i){return tu.setFromAxisAngle(t,i),this.quaternion.multiply(tu),this}rotateOnWorldAxis(t,i){return tu.setFromAxisAngle(t,i),this.quaternion.premultiply(tu),this}rotateX(t){return this.rotateOnAxis(sI,t)}rotateY(t){return this.rotateOnAxis(nI,t)}rotateZ(t){return this.rotateOnAxis(aI,t)}translateOnAxis(t,i){return rI.copy(t).applyQuaternion(this.quaternion),this.position.add(rI.multiplyScalar(i)),this}translateX(t){return this.translateOnAxis(sI,t)}translateY(t){return this.translateOnAxis(nI,t)}translateZ(t){return this.translateOnAxis(aI,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vo.copy(this.matrixWorld).invert())}lookAt(t,i,r){t.isVector3?q_.copy(t):q_.set(t,i,r);let s=this.parent;this.updateWorldMatrix(!0,!1),Ef.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vo.lookAt(Ef,q_,this.up):vo.lookAt(q_,Ef,this.up),this.quaternion.setFromRotationMatrix(vo),s&&(vo.extractRotation(s.matrixWorld),tu.setFromRotationMatrix(vo),this.quaternion.premultiply(tu.invert()))}add(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.add(arguments[i]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(oI),iu.child=t,this.dispatchEvent(iu),iu.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}let i=this.children.indexOf(t);return i!==-1&&(t.parent=null,this.children.splice(i,1),t.dispatchEvent(wV),zb.child=t,this.dispatchEvent(zb),zb.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vo.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),vo.multiply(t.parent.matrixWorld)),t.applyMatrix4(vo),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(oI),iu.child=t,this.dispatchEvent(iu),iu.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,i){if(this[t]===i)return this;for(let r=0,s=this.children.length;r<s;r++){let n=this.children[r].getObjectByProperty(t,i);if(n!==void 0)return n}}getObjectsByProperty(t,i,r=[]){this[t]===i&&r.push(this);let s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].getObjectsByProperty(t,i,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ef,t,xV),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ef,EV,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let i=this.matrixWorld.elements;return t.set(i[8],i[9],i[10]).normalize()}raycast(){}traverse(t){t(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].traverseVisible(t)}traverseAncestors(t){let i=this.parent;i!==null&&(t(i),i.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),i===!0){let s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){let i=t===void 0||typeof t=="string",r={};i&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let h=0,c=l.length;h<c;h++){let d=l[h];n(t.shapes,d)}else n(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(t.materials,this.material[l]));s.material=o}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];s.animations.push(n(t.animations,l))}}if(i){let o=a(t.geometries),l=a(t.materials),h=a(t.textures),c=a(t.images),d=a(t.shapes),f=a(t.skeletons),u=a(t.animations),p=a(t.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),h.length>0&&(r.textures=h),c.length>0&&(r.images=c),d.length>0&&(r.shapes=d),f.length>0&&(r.skeletons=f),u.length>0&&(r.animations=u),p.length>0&&(r.nodes=p)}return r.object=s,r;function a(o){let l=[];for(let h in o){let c=o[h];delete c.metadata,l.push(c)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),i===!0)for(let r=0;r<t.children.length;r++){let s=t.children[r];this.add(s.clone())}return this}};yu.DEFAULT_UP=new fe(0,1,0);yu.DEFAULT_MATRIX_AUTO_UPDATE=!0;yu.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var ia=new fe,xo=new fe,Hb=new fe,Eo=new fe,ru=new fe,su=new fe,lI=new fe,jb=new fe,Vb=new fe,Yb=new fe,qb=new Ff,Wb=new Ff,Xb=new Ff,lu=class hu{constructor(t=new fe,i=new fe,r=new fe){this.a=t,this.b=i,this.c=r}static getNormal(t,i,r,s){s.subVectors(r,i),ia.subVectors(t,i),s.cross(ia);let n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,i,r,s,n){ia.subVectors(s,i),xo.subVectors(r,i),Hb.subVectors(t,i);let a=ia.dot(ia),o=ia.dot(xo),l=ia.dot(Hb),h=xo.dot(xo),c=xo.dot(Hb),d=a*h-o*o;if(d===0)return n.set(0,0,0),null;let f=1/d,u=(h*l-o*c)*f,p=(a*c-o*l)*f;return n.set(1-u-p,p,u)}static containsPoint(t,i,r,s){return this.getBarycoord(t,i,r,s,Eo)===null?!1:Eo.x>=0&&Eo.y>=0&&Eo.x+Eo.y<=1}static getInterpolation(t,i,r,s,n,a,o,l){return this.getBarycoord(t,i,r,s,Eo)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(n,Eo.x),l.addScaledVector(a,Eo.y),l.addScaledVector(o,Eo.z),l)}static getInterpolatedAttribute(t,i,r,s,n,a){return qb.setScalar(0),Wb.setScalar(0),Xb.setScalar(0),qb.fromBufferAttribute(t,i),Wb.fromBufferAttribute(t,r),Xb.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(qb,n.x),a.addScaledVector(Wb,n.y),a.addScaledVector(Xb,n.z),a}static isFrontFacing(t,i,r,s){return ia.subVectors(r,i),xo.subVectors(t,i),ia.cross(xo).dot(s)<0}set(t,i,r){return this.a.copy(t),this.b.copy(i),this.c.copy(r),this}setFromPointsAndIndices(t,i,r,s){return this.a.copy(t[i]),this.b.copy(t[r]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,i,r,s){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ia.subVectors(this.c,this.b),xo.subVectors(this.a,this.b),ia.cross(xo).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return hu.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return hu.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,r,s,n){return hu.getInterpolation(t,this.a,this.b,this.c,i,r,s,n)}containsPoint(t){return hu.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return hu.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){let r=this.a,s=this.b,n=this.c,a,o;ru.subVectors(s,r),su.subVectors(n,r),jb.subVectors(t,r);let l=ru.dot(jb),h=su.dot(jb);if(l<=0&&h<=0)return i.copy(r);Vb.subVectors(t,s);let c=ru.dot(Vb),d=su.dot(Vb);if(c>=0&&d<=c)return i.copy(s);let f=l*d-c*h;if(f<=0&&l>=0&&c<=0)return a=l/(l-c),i.copy(r).addScaledVector(ru,a);Yb.subVectors(t,n);let u=ru.dot(Yb),p=su.dot(Yb);if(p>=0&&u<=p)return i.copy(n);let g=u*h-l*p;if(g<=0&&h>=0&&p<=0)return o=h/(h-p),i.copy(r).addScaledVector(su,o);let _=c*p-u*d;if(_<=0&&d-c>=0&&u-p>=0)return lI.subVectors(n,s),o=(d-c)/(d-c+(u-p)),i.copy(s).addScaledVector(lI,o);let y=1/(_+g+f);return a=g*y,o=f*y,i.copy(r).addScaledVector(ru,a).addScaledVector(su,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},FP={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dl={h:0,s:0,l:0},W_={h:0,s:0,l:0};function Jb(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}var gr=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ra){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qn.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Qn.workingColorSpace){return this.r=e,this.g=t,this.b=i,Qn.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Qn.workingColorSpace){if(e=lV(e,1),t=Vt(t,0,1),i=Vt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,n=2*i-s;this.r=Jb(n,s,e+1/3),this.g=Jb(n,s,e),this.b=Jb(n,s,e-1/3)}return Qn.toWorkingColorSpace(this,r),this}setStyle(e,t=ra){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,n=r[1],a=r[2];switch(n){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],n=s.length;if(n===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(n===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ra){let i=FP[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=To(e.r),this.g=To(e.g),this.b=To(e.b),this}copyLinearToSRGB(e){return this.r=fu(e.r),this.g=fu(e.g),this.b=fu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ra){return Qn.fromWorkingColorSpace(xs.copy(this),e),Math.round(Vt(xs.r*255,0,255))*65536+Math.round(Vt(xs.g*255,0,255))*256+Math.round(Vt(xs.b*255,0,255))}getHexString(e=ra){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qn.workingColorSpace){Qn.fromWorkingColorSpace(xs.copy(this),t);let i=xs.r,r=xs.g,s=xs.b,n=Math.max(i,r,s),a=Math.min(i,r,s),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let c=n-a;switch(l=h<=.5?c/(n+a):c/(2-n-a),n){case i:o=(r-s)/c+(r<s?6:0);break;case r:o=(s-i)/c+2;break;case s:o=(i-r)/c+4;break}o/=6}return e.h=o,e.s=l,e.l=h,e}getRGB(e,t=Qn.workingColorSpace){return Qn.fromWorkingColorSpace(xs.copy(this),t),e.r=xs.r,e.g=xs.g,e.b=xs.b,e}getStyle(e=ra){Qn.fromWorkingColorSpace(xs.copy(this),e);let t=xs.r,i=xs.g,r=xs.b;return e!==ra?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(dl),this.setHSL(dl.h+e,dl.s+t,dl.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(dl),e.getHSL(W_);let i=Db(dl.h,W_.h,t),r=Db(dl.s,W_.s,t),s=Db(dl.l,W_.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},xs=new gr;gr.NAMES=FP;var TV=0,SV=class extends TO{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:TV++}),this.uuid=bu(),this.name="",this.type="Material",this.blending=CS,this.side=ly,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=DS,this.blendDst=RS,this.blendEquation=LS,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new gr(0,0,0),this.blendAlpha=0,this.depthFunc=bO,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=JS,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Jc,this.stencilZFail=Jc,this.stencilZPass=Jc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==CS&&(i.blending=this.blending),this.side!==ly&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==DS&&(i.blendSrc=this.blendSrc),this.blendDst!==RS&&(i.blendDst=this.blendDst),this.blendEquation!==LS&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==bO&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==JS&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Jc&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Jc&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Jc&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let n=[];for(let a in s){let o=s[a];delete o.metadata,n.push(o)}return n}if(t){let s=r(e.textures),n=r(e.images);s.length>0&&(i.textures=s),n.length>0&&(i.images=n)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}},IV=class extends SV{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new gr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Uf,this.combine=$j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Zae=PV();function PV(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,n[l]=h|c}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:n,exponentTable:a,offsetTable:o}}var Ir=new fe,X_=new Je,pu=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ZS,this.updateRanges=[],this.gpuType=sV,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)X_.fromBufferAttribute(this,t),X_.applyMatrix3(e),this.setXY(t,X_.x,X_.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.applyMatrix3(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.applyMatrix4(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.applyNormalMatrix(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.transformDirection(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=yf(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=zs(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=yf(t,this.array)),t}setX(e,t){return this.normalized&&(t=zs(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=yf(t,this.array)),t}setY(e,t){return this.normalized&&(t=zs(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=yf(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zs(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=yf(t,this.array)),t}setW(e,t){return this.normalized&&(t=zs(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=zs(t,this.array),i=zs(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=zs(t,this.array),i=zs(i,this.array),r=zs(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=zs(t,this.array),i=zs(i,this.array),r=zs(r,this.array),s=zs(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ZS&&(e.usage=this.usage),e}},AV=class extends pu{constructor(e,t,i){super(new Uint16Array(e),t,i)}},CV=class extends pu{constructor(e,t,i){super(new Uint32Array(e),t,i)}},Nt=class extends pu{constructor(e,t,i){super(new Float32Array(e),t,i)}},LV=0,En=new li,Zb=new yu,nu=new fe,an=new bl,wf=new bl,Xr=new fe,Ss=class UP extends TO{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:LV++}),this.uuid=bu(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(hV(t)?CV:AV)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,i){return this.attributes[t]=i,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,i,r=0){this.groups.push({start:t,count:i,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,i){this.drawRange.start=t,this.drawRange.count=i}applyMatrix4(t){let i=this.attributes.position;i!==void 0&&(i.applyMatrix4(t),i.needsUpdate=!0);let r=this.attributes.normal;if(r!==void 0){let n=new jt().getNormalMatrix(t);r.applyNormalMatrix(n),r.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return En.makeRotationFromQuaternion(t),this.applyMatrix4(En),this}rotateX(t){return En.makeRotationX(t),this.applyMatrix4(En),this}rotateY(t){return En.makeRotationY(t),this.applyMatrix4(En),this}rotateZ(t){return En.makeRotationZ(t),this.applyMatrix4(En),this}translate(t,i,r){return En.makeTranslation(t,i,r),this.applyMatrix4(En),this}scale(t,i,r){return En.makeScale(t,i,r),this.applyMatrix4(En),this}lookAt(t){return Zb.lookAt(t),Zb.updateMatrix(),this.applyMatrix4(Zb.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nu).negate(),this.translate(nu.x,nu.y,nu.z),this}setFromPoints(t){let i=this.getAttribute("position");if(i===void 0){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Nt(r,3))}else{let r=Math.min(t.length,i.count);for(let s=0;s<r;s++){let n=t[s];i.setXYZ(s,n.x,n.y,n.z||0)}t.length>i.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),i.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bl);let t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new fe(-1/0,-1/0,-1/0),new fe(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),i)for(let r=0,s=i.length;r<s;r++){let n=i[r];an.setFromBufferAttribute(n),this.morphTargetsRelative?(Xr.addVectors(this.boundingBox.min,an.min),this.boundingBox.expandByPoint(Xr),Xr.addVectors(this.boundingBox.max,an.max),this.boundingBox.expandByPoint(Xr)):(this.boundingBox.expandByPoint(an.min),this.boundingBox.expandByPoint(an.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new yl);let t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new fe,1/0);return}if(t){let r=this.boundingSphere.center;if(an.setFromBufferAttribute(t),i)for(let n=0,a=i.length;n<a;n++){let o=i[n];wf.setFromBufferAttribute(o),this.morphTargetsRelative?(Xr.addVectors(an.min,wf.min),an.expandByPoint(Xr),Xr.addVectors(an.max,wf.max),an.expandByPoint(Xr)):(an.expandByPoint(wf.min),an.expandByPoint(wf.max))}an.getCenter(r);let s=0;for(let n=0,a=t.count;n<a;n++)Xr.fromBufferAttribute(t,n),s=Math.max(s,r.distanceToSquared(Xr));if(i)for(let n=0,a=i.length;n<a;n++){let o=i[n],l=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)Xr.fromBufferAttribute(o,h),l&&(nu.fromBufferAttribute(t,h),Xr.add(nu)),s=Math.max(s,r.distanceToSquared(Xr))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,i=this.attributes;if(t===null||i.position===void 0||i.normal===void 0||i.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let r=i.position,s=i.normal,n=i.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new pu(new Float32Array(4*r.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let P=0;P<r.count;P++)o[P]=new fe,l[P]=new fe;let h=new fe,c=new fe,d=new fe,f=new Je,u=new Je,p=new Je,g=new fe,_=new fe;function y(P,A,C){h.fromBufferAttribute(r,P),c.fromBufferAttribute(r,A),d.fromBufferAttribute(r,C),f.fromBufferAttribute(n,P),u.fromBufferAttribute(n,A),p.fromBufferAttribute(n,C),c.sub(h),d.sub(h),u.sub(f),p.sub(f);let M=1/(u.x*p.y-p.x*u.y);isFinite(M)&&(g.copy(c).multiplyScalar(p.y).addScaledVector(d,-u.y).multiplyScalar(M),_.copy(d).multiplyScalar(u.x).addScaledVector(c,-p.x).multiplyScalar(M),o[P].add(g),o[A].add(g),o[C].add(g),l[P].add(_),l[A].add(_),l[C].add(_))}let m=this.groups;m.length===0&&(m=[{start:0,count:t.count}]);for(let P=0,A=m.length;P<A;++P){let C=m[P],M=C.start,H=C.count;for(let k=M,F=M+H;k<F;k+=3)y(t.getX(k+0),t.getX(k+1),t.getX(k+2))}let O=new fe,b=new fe,v=new fe,E=new fe;function T(P){v.fromBufferAttribute(s,P),E.copy(v);let A=o[P];O.copy(A),O.sub(v.multiplyScalar(v.dot(A))).normalize(),b.crossVectors(E,A);let C=b.dot(l[P])<0?-1:1;a.setXYZW(P,O.x,O.y,O.z,C)}for(let P=0,A=m.length;P<A;++P){let C=m[P],M=C.start,H=C.count;for(let k=M,F=M+H;k<F;k+=3)T(t.getX(k+0)),T(t.getX(k+1)),T(t.getX(k+2))}}computeVertexNormals(){let t=this.index,i=this.getAttribute("position");if(i!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new pu(new Float32Array(i.count*3),3),this.setAttribute("normal",r);else for(let f=0,u=r.count;f<u;f++)r.setXYZ(f,0,0,0);let s=new fe,n=new fe,a=new fe,o=new fe,l=new fe,h=new fe,c=new fe,d=new fe;if(t)for(let f=0,u=t.count;f<u;f+=3){let p=t.getX(f+0),g=t.getX(f+1),_=t.getX(f+2);s.fromBufferAttribute(i,p),n.fromBufferAttribute(i,g),a.fromBufferAttribute(i,_),c.subVectors(a,n),d.subVectors(s,n),c.cross(d),o.fromBufferAttribute(r,p),l.fromBufferAttribute(r,g),h.fromBufferAttribute(r,_),o.add(c),l.add(c),h.add(c),r.setXYZ(p,o.x,o.y,o.z),r.setXYZ(g,l.x,l.y,l.z),r.setXYZ(_,h.x,h.y,h.z)}else for(let f=0,u=i.count;f<u;f+=3)s.fromBufferAttribute(i,f+0),n.fromBufferAttribute(i,f+1),a.fromBufferAttribute(i,f+2),c.subVectors(a,n),d.subVectors(s,n),c.cross(d),r.setXYZ(f+0,c.x,c.y,c.z),r.setXYZ(f+1,c.x,c.y,c.z),r.setXYZ(f+2,c.x,c.y,c.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let i=0,r=t.count;i<r;i++)Xr.fromBufferAttribute(t,i),Xr.normalize(),t.setXYZ(i,Xr.x,Xr.y,Xr.z)}toNonIndexed(){function t(o,l){let h=o.array,c=o.itemSize,d=o.normalized,f=new h.constructor(l.length*c),u=0,p=0;for(let g=0,_=l.length;g<_;g++){o.isInterleavedBufferAttribute?u=l[g]*o.data.stride+o.offset:u=l[g]*c;for(let y=0;y<c;y++)f[p++]=h[u++]}return new pu(f,c,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let i=new UP,r=this.index.array,s=this.attributes;for(let o in s){let l=s[o],h=t(l,r);i.setAttribute(o,h)}let n=this.morphAttributes;for(let o in n){let l=[],h=n[o];for(let c=0,d=h.length;c<d;c++){let f=h[c],u=t(f,r);l.push(u)}i.morphAttributes[o]=l}i.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let h=a[o];i.addGroup(h.start,h.count,h.materialIndex)}return i}toJSON(){let t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let h in l)l[h]!==void 0&&(t[h]=l[h]);return t}t.data={attributes:{}};let i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});let r=this.attributes;for(let l in r){let h=r[l];t.data.attributes[l]=h.toJSON(t.data)}let s={},n=!1;for(let l in this.morphAttributes){let h=this.morphAttributes[l],c=[];for(let d=0,f=h.length;d<f;d++){let u=h[d];c.push(u.toJSON(t.data))}c.length>0&&(s[l]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let i={};this.name=t.name;let r=t.index;r!==null&&this.setIndex(r.clone(i));let s=t.attributes;for(let h in s){let c=s[h];this.setAttribute(h,c.clone(i))}let n=t.morphAttributes;for(let h in n){let c=[],d=n[h];for(let f=0,u=d.length;f<u;f++)c.push(d[f].clone(i));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let h=0,c=a.length;h<c;h++){let d=a[h];this.addGroup(d.start,d.count,d.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},hI=new li,uh=new SO,J_=new yl,cI=new fe,Z_=new fe,K_=new fe,$_=new fe,Kb=new fe,Q_=new fe,uI=new fe,eO=new fe,GP=class extends yu{constructor(e=new Ss,t=new IV){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,n=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Q_.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let h=a[o],c=s[o];h!==0&&(Kb.fromBufferAttribute(c,e),n?Q_.addScaledVector(Kb,h):Q_.addScaledVector(Kb.sub(t),h))}t.add(Q_)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),J_.copy(i.boundingSphere),J_.applyMatrix4(s),uh.copy(e.ray).recast(e.near),!(J_.containsPoint(uh.origin)===!1&&(uh.intersectSphere(J_,cI)===null||uh.origin.distanceToSquared(cI)>(e.far-e.near)**2))&&(hI.copy(s).invert(),uh.copy(e.ray).applyMatrix4(hI),!(i.boundingBox!==null&&uh.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,uh)))}_computeIntersections(e,t,i){let r,s=this.geometry,n=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,c=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(n))for(let u=0,p=d.length;u<p;u++){let g=d[u],_=n[g.materialIndex],y=Math.max(g.start,f.start),m=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let O=y,b=m;O<b;O+=3){let v=a.getX(O),E=a.getX(O+1),T=a.getX(O+2);r=tO(this,_,e,i,l,h,c,v,E,T),r&&(r.faceIndex=Math.floor(O/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let u=Math.max(0,f.start),p=Math.min(a.count,f.start+f.count);for(let g=u,_=p;g<_;g+=3){let y=a.getX(g),m=a.getX(g+1),O=a.getX(g+2);r=tO(this,n,e,i,l,h,c,y,m,O),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(o!==void 0)if(Array.isArray(n))for(let u=0,p=d.length;u<p;u++){let g=d[u],_=n[g.materialIndex],y=Math.max(g.start,f.start),m=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let O=y,b=m;O<b;O+=3){let v=O,E=O+1,T=O+2;r=tO(this,_,e,i,l,h,c,v,E,T),r&&(r.faceIndex=Math.floor(O/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let u=Math.max(0,f.start),p=Math.min(o.count,f.start+f.count);for(let g=u,_=p;g<_;g+=3){let y=g,m=g+1,O=g+2;r=tO(this,n,e,i,l,h,c,y,m,O),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function DV(e,t,i,r,s,n,a,o){let l;if(t.side===Kj?l=r.intersectTriangle(a,n,s,!0,o):l=r.intersectTriangle(s,n,a,t.side===ly,o),l===null)return null;eO.copy(o),eO.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo(eO);return h<i.near||h>i.far?null:{distance:h,point:eO.clone(),object:e}}function tO(e,t,i,r,s,n,a,o,l,h){e.getVertexPosition(o,Z_),e.getVertexPosition(l,K_),e.getVertexPosition(h,$_);let c=DV(e,t,i,r,Z_,K_,$_,uI);if(c){let d=new fe;lu.getBarycoord(uI,Z_,K_,$_,d),s&&(c.uv=lu.getInterpolatedAttribute(s,o,l,h,d,new Je)),n&&(c.uv1=lu.getInterpolatedAttribute(n,o,l,h,d,new Je)),a&&(c.normal=lu.getInterpolatedAttribute(a,o,l,h,d,new fe),c.normal.dot(r.direction)>0&&c.normal.multiplyScalar(-1));let f={a:o,b:l,c:h,normal:new fe,materialIndex:0};lu.getNormal(Z_,K_,$_,f.normal),c.face=f,c.barycoord=d}return c}var RV=class zP extends Ss{constructor(t=1,i=1,r=1,s=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a};let o=this;s=Math.floor(s),n=Math.floor(n),a=Math.floor(a);let l=[],h=[],c=[],d=[],f=0,u=0;p("z","y","x",-1,-1,r,i,t,a,n,0),p("z","y","x",1,-1,r,i,-t,a,n,1),p("x","z","y",1,1,t,r,i,s,a,2),p("x","z","y",1,-1,t,r,-i,s,a,3),p("x","y","z",1,-1,t,i,r,s,n,4),p("x","y","z",-1,-1,t,i,-r,s,n,5),this.setIndex(l),this.setAttribute("position",new Nt(h,3)),this.setAttribute("normal",new Nt(c,3)),this.setAttribute("uv",new Nt(d,2));function p(g,_,y,m,O,b,v,E,T,P,A){let C=b/T,M=v/P,H=b/2,k=v/2,F=E/2,j=T+1,L=P+1,R=0,x=0,I=new fe;for(let S=0;S<L;S++){let D=S*M-k;for(let N=0;N<j;N++){let G=N*C-H;I[g]=G*m,I[_]=D*O,I[y]=F,h.push(I.x,I.y,I.z),I[g]=0,I[_]=0,I[y]=E>0?1:-1,c.push(I.x,I.y,I.z),d.push(N/T),d.push(1-S/P),R+=1}}for(let S=0;S<P;S++)for(let D=0;D<T;D++){let N=f+D+j*S,G=f+D+j*(S+1),z=f+(D+1)+j*(S+1),Z=f+(D+1)+j*S;l.push(N,G,Z),l.push(G,z,Z),x+=6}o.addGroup(u,x,A),u+=x,f+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zP(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function NV(e){let t={};for(let i in e){t[i]={};for(let r in e[i]){let s=e[i][r];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[i][r]=null):t[i][r]=s.clone():Array.isArray(s)?t[i][r]=s.slice():t[i][r]=s}}return t}function Hs(e){let t={};for(let i=0;i<e.length;i++){let r=NV(e[i]);for(let s in r)t[s]=r[s]}return t}var HP=class extends yu{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new li,this.projectionMatrix=new li,this.projectionMatrixInverse=new li,this.coordinateSystem=ph}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Kae=new fe,$ae=new Je,Qae=new Je,MV=class extends Ol{constructor(e,t,i,r,s,n,a,o,l,h){e=e!==void 0?e:[],t=t!==void 0?t:Qj,super(e,t,i,r,s,n,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},eoe=new fe,toe=new fe,ioe=new fe,roe=new fe,soe=new Je,noe=new Je,aoe=new li,ooe=new fe,loe=new fe,hoe=new fe,coe=new Je,uoe=new Je,doe=new Je,foe=new fe,poe=new fe,goe=new fe,_oe=new Ff,Ooe=new Ff,moe=new fe,boe=new li,yoe=new fe,voe=new yl,xoe=new li,Eoe=new SO;var woe=new li,Toe=new li,Soe=new li,Ioe=new li,Poe=new bl,Aoe=new li,Coe=new GP,Loe=new yl,$b=new fe,BV=new fe,kV=new jt,au=class{constructor(e=new fe(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=$b.subVectors(i,t).cross(BV.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta($b),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||kV.getNormalMatrix(e),r=this.coplanarPoint($b).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},dh=new yl,iO=new fe,FV=class{constructor(e=new au,t=new au,i=new au,r=new au,s=new au,n=new au){this.planes=[e,t,i,r,s,n]}set(e,t,i,r,s,n){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(n),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ph){let i=this.planes,r=e.elements,s=r[0],n=r[1],a=r[2],o=r[3],l=r[4],h=r[5],c=r[6],d=r[7],f=r[8],u=r[9],p=r[10],g=r[11],_=r[12],y=r[13],m=r[14],O=r[15];if(i[0].setComponents(o-s,d-l,g-f,O-_).normalize(),i[1].setComponents(o+s,d+l,g+f,O+_).normalize(),i[2].setComponents(o+n,d+h,g+u,O+y).normalize(),i[3].setComponents(o-n,d-h,g-u,O-y).normalize(),i[4].setComponents(o-a,d-c,g-p,O-m).normalize(),t===ph)i[5].setComponents(o+a,d+c,g+p,O+m).normalize();else if(t===cy)i[5].setComponents(a,c,p,m).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),dh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),dh.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(dh)}intersectsSprite(e){return dh.center.set(0,0,0),dh.radius=.7071067811865476,dh.applyMatrix4(e.matrixWorld),this.intersectsSphere(dh)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(iO.x=r.normal.x>0?e.max.x:e.min.x,iO.y=r.normal.y>0?e.max.y:e.min.y,iO.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(iO)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},UV=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,r){let s=this.pool,n=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});let a=s[this.index];n.push(a),this.index++,a.start=e,a.count=t,a.z=i,a.index=r}reset(){this.list.length=0,this.index=0}},Doe=new li,Roe=new gr(1,1,1),Noe=new FV,Moe=new bl,Boe=new yl,koe=new fe,Foe=new fe,Uoe=new fe,Goe=new UV,zoe=new GP,Hoe=new fe,joe=new fe,Voe=new li,Yoe=new SO,qoe=new yl,Woe=new fe,Xoe=new fe,Joe=new fe,Zoe=new fe,Koe=new li,$oe=new SO,Qoe=new yl,ele=new fe,GV=class extends Ol{constructor(e,t,i,r,s,n,a,o,l,h=Ab){if(h!==Ab&&h!==jS)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Ab&&(i=rV),i===void 0&&h===jS&&(i=nV),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ou,this.minFilter=o!==void 0?o:Ou,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ma=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],c=i[r+1]-h,d=(n-h)/c;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new Je:new fe);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new fe,r=[],s=[],n=[],a=new fe,o=new li;for(let f=0;f<=e;f++){let u=f/e;r[f]=this.getTangentAt(u,new fe)}s[0]=new fe,n[0]=new fe;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),d<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),n[f]=n[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let u=Math.acos(Vt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(o.makeRotationAxis(a,u))}n[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(Vt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let u=1;u<=e;u++)s[u].applyMatrix4(o.makeRotationAxis(r[u],f*u)),n[u].crossVectors(r[u],s[u])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Gy=class extends Ma{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t=new Je){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),d=o-this.aX,f=l-this.aY;o=d*h-f*c+this.aX,l=d*c+f*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},zV=class extends Gy{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function zy(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,c,d){let f=(a-n)/h-(o-n)/(h+c)+(o-a)/c,u=(o-a)/c-(l-a)/(c+d)+(l-o)/d;f*=c,u*=c,s(a,o,f,u)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var rO=new fe,Qb=new zy,ey=new zy,ty=new zy,HV=class extends Ma{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new fe){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(rO.subVectors(r[0],r[1]).add(r[0]),l=rO);let c=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(rO.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=rO),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,u=Math.pow(l.distanceToSquared(c),f),p=Math.pow(c.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);p<1e-4&&(p=1),u<1e-4&&(u=p),g<1e-4&&(g=p),Qb.initNonuniformCatmullRom(l.x,c.x,d.x,h.x,u,p,g),ey.initNonuniformCatmullRom(l.y,c.y,d.y,h.y,u,p,g),ty.initNonuniformCatmullRom(l.z,c.z,d.z,h.z,u,p,g)}else this.curveType==="catmullrom"&&(Qb.initCatmullRom(l.x,c.x,d.x,h.x,this.tension),ey.initCatmullRom(l.y,c.y,d.y,h.y,this.tension),ty.initCatmullRom(l.z,c.z,d.z,h.z,this.tension));return i.set(Qb.calc(o),ey.calc(o),ty.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new fe().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function dI(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function jV(e,t){let i=1-e;return i*i*t}function VV(e,t){return 2*(1-e)*e*t}function YV(e,t){return e*e*t}function If(e,t,i,r){return jV(e,t)+VV(e,i)+YV(e,r)}function qV(e,t){let i=1-e;return i*i*i*t}function WV(e,t){let i=1-e;return 3*i*i*e*t}function XV(e,t){return 3*(1-e)*e*e*t}function JV(e,t){return e*e*e*t}function Pf(e,t,i,r,s){return qV(e,t)+WV(e,i)+XV(e,r)+JV(e,s)}var jP=class extends Ma{constructor(e=new Je,t=new Je,i=new Je,r=new Je){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Je){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Pf(e,r.x,s.x,n.x,a.x),Pf(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ZV=class extends Ma{constructor(e=new fe,t=new fe,i=new fe,r=new fe){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new fe){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(Pf(e,r.x,s.x,n.x,a.x),Pf(e,r.y,s.y,n.y,a.y),Pf(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},VP=class extends Ma{constructor(e=new Je,t=new Je){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Je){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Je){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},KV=class extends Ma{constructor(e=new fe,t=new fe){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new fe){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new fe){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},YP=class extends Ma{constructor(e=new Je,t=new Je,i=new Je){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Je){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(If(e,r.x,s.x,n.x),If(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},qP=class extends Ma{constructor(e=new fe,t=new fe,i=new fe){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new fe){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(If(e,r.x,s.x,n.x),If(e,r.y,s.y,n.y),If(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},WP=class extends Ma{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Je){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],c=r[n>r.length-3?r.length-1:n+2];return i.set(dI(a,o.x,l.x,h.x,c.x),dI(a,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new Je().fromArray(r))}return this}},vO=Object.freeze({__proto__:null,ArcCurve:zV,CatmullRomCurve3:HV,CubicBezierCurve:jP,CubicBezierCurve3:ZV,EllipseCurve:Gy,LineCurve:VP,LineCurve3:KV,QuadraticBezierCurve:YP,QuadraticBezierCurve3:qP,SplineCurve:WP}),$V=class extends Ma{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new vO[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new vO[r.type]().fromJSON(r))}return this}},dy=class extends $V{constructor(e){super(),this.type="Path",this.currentPoint=new Je,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new VP(this.currentPoint.clone(),new Je(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new YP(this.currentPoint.clone(),new Je(e,t),new Je(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new jP(this.currentPoint.clone(),new Je(e,t),new Je(i,r),new Je(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new WP(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new Gy(e,t,i,r,s,n,a,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},XP=class JP extends Ss{constructor(t=[new Je(0,-.5),new Je(.5,0),new Je(0,.5)],i=12,r=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:i,phiStart:r,phiLength:s},i=Math.floor(i),s=Vt(s,0,Math.PI*2);let n=[],a=[],o=[],l=[],h=[],c=1/i,d=new fe,f=new Je,u=new fe,p=new fe,g=new fe,_=0,y=0;for(let m=0;m<=t.length-1;m++)switch(m){case 0:_=t[m+1].x-t[m].x,y=t[m+1].y-t[m].y,u.x=y*1,u.y=-_,u.z=y*0,g.copy(u),u.normalize(),l.push(u.x,u.y,u.z);break;case t.length-1:l.push(g.x,g.y,g.z);break;default:_=t[m+1].x-t[m].x,y=t[m+1].y-t[m].y,u.x=y*1,u.y=-_,u.z=y*0,p.copy(u),u.x+=g.x,u.y+=g.y,u.z+=g.z,u.normalize(),l.push(u.x,u.y,u.z),g.copy(p)}for(let m=0;m<=i;m++){let O=r+m*c*s,b=Math.sin(O),v=Math.cos(O);for(let E=0;E<=t.length-1;E++){d.x=t[E].x*b,d.y=t[E].y,d.z=t[E].x*v,a.push(d.x,d.y,d.z),f.x=m/i,f.y=E/(t.length-1),o.push(f.x,f.y);let T=l[3*E+0]*b,P=l[3*E+1],A=l[3*E+0]*v;h.push(T,P,A)}}for(let m=0;m<i;m++)for(let O=0;O<t.length-1;O++){let b=O+m*t.length,v=b,E=b+t.length,T=b+t.length+1,P=b+1;n.push(v,E,P),n.push(T,P,E)}this.setIndex(n),this.setAttribute("position",new Nt(a,3)),this.setAttribute("uv",new Nt(o,2)),this.setAttribute("normal",new Nt(h,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new JP(t.points,t.segments,t.phiStart,t.phiLength)}},QV=class ZP extends XP{constructor(t=1,i=1,r=4,s=8){let n=new dy;n.absarc(0,-i/2,t,Math.PI*1.5,0),n.absarc(0,i/2,t,0,Math.PI*.5),super(n.getPoints(r),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:i,capSegments:r,radialSegments:s}}static fromJSON(t){return new ZP(t.radius,t.length,t.capSegments,t.radialSegments)}},eY=class KP extends Ss{constructor(t=1,i=32,r=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:i,thetaStart:r,thetaLength:s},i=Math.max(3,i);let n=[],a=[],o=[],l=[],h=new fe,c=new Je;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,f=3;d<=i;d++,f+=3){let u=r+d/i*s;h.x=t*Math.cos(u),h.y=t*Math.sin(u),a.push(h.x,h.y,h.z),o.push(0,0,1),c.x=(a[f]/t+1)/2,c.y=(a[f+1]/t+1)/2,l.push(c.x,c.y)}for(let d=1;d<=i;d++)n.push(d,d+1,0);this.setIndex(n),this.setAttribute("position",new Nt(a,3)),this.setAttribute("normal",new Nt(o,3)),this.setAttribute("uv",new Nt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new KP(t.radius,t.segments,t.thetaStart,t.thetaLength)}},$P=class QP extends Ss{constructor(t=1,i=1,r=1,s=32,n=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l};let h=this;s=Math.floor(s),n=Math.floor(n);let c=[],d=[],f=[],u=[],p=0,g=[],_=r/2,y=0;m(),a===!1&&(t>0&&O(!0),i>0&&O(!1)),this.setIndex(c),this.setAttribute("position",new Nt(d,3)),this.setAttribute("normal",new Nt(f,3)),this.setAttribute("uv",new Nt(u,2));function m(){let b=new fe,v=new fe,E=0,T=(i-t)/r;for(let P=0;P<=n;P++){let A=[],C=P/n,M=C*(i-t)+t;for(let H=0;H<=s;H++){let k=H/s,F=k*l+o,j=Math.sin(F),L=Math.cos(F);v.x=M*j,v.y=-C*r+_,v.z=M*L,d.push(v.x,v.y,v.z),b.set(j,T,L).normalize(),f.push(b.x,b.y,b.z),u.push(k,1-C),A.push(p++)}g.push(A)}for(let P=0;P<s;P++)for(let A=0;A<n;A++){let C=g[A][P],M=g[A+1][P],H=g[A+1][P+1],k=g[A][P+1];(t>0||A!==0)&&(c.push(C,M,k),E+=3),(i>0||A!==n-1)&&(c.push(M,H,k),E+=3)}h.addGroup(y,E,0),y+=E}function O(b){let v=p,E=new Je,T=new fe,P=0,A=b===!0?t:i,C=b===!0?1:-1;for(let H=1;H<=s;H++)d.push(0,_*C,0),f.push(0,C,0),u.push(.5,.5),p++;let M=p;for(let H=0;H<=s;H++){let k=H/s*l+o,F=Math.cos(k),j=Math.sin(k);T.x=A*j,T.y=_*C,T.z=A*F,d.push(T.x,T.y,T.z),f.push(0,C,0),E.x=F*.5+.5,E.y=j*.5*C+.5,u.push(E.x,E.y),p++}for(let H=0;H<s;H++){let k=v+H,F=M+H;b===!0?c.push(F,F+1,k):c.push(F+1,F,k),P+=3}h.addGroup(y,P,b===!0?1:2),y+=P}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new QP(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},tY=class eA extends $P{constructor(t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(0,t,i,r,s,n,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o}}static fromJSON(t){return new eA(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Gf=class tA extends Ss{constructor(t=[],i=[],r=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:i,radius:r,detail:s};let n=[],a=[];o(s),h(r),c(),this.setAttribute("position",new Nt(n,3)),this.setAttribute("normal",new Nt(n.slice(),3)),this.setAttribute("uv",new Nt(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(m){let O=new fe,b=new fe,v=new fe;for(let E=0;E<i.length;E+=3)u(i[E+0],O),u(i[E+1],b),u(i[E+2],v),l(O,b,v,m)}function l(m,O,b,v){let E=v+1,T=[];for(let P=0;P<=E;P++){T[P]=[];let A=m.clone().lerp(b,P/E),C=O.clone().lerp(b,P/E),M=E-P;for(let H=0;H<=M;H++)H===0&&P===E?T[P][H]=A:T[P][H]=A.clone().lerp(C,H/M)}for(let P=0;P<E;P++)for(let A=0;A<2*(E-P)-1;A++){let C=Math.floor(A/2);A%2===0?(f(T[P][C+1]),f(T[P+1][C]),f(T[P][C])):(f(T[P][C+1]),f(T[P+1][C+1]),f(T[P+1][C]))}}function h(m){let O=new fe;for(let b=0;b<n.length;b+=3)O.x=n[b+0],O.y=n[b+1],O.z=n[b+2],O.normalize().multiplyScalar(m),n[b+0]=O.x,n[b+1]=O.y,n[b+2]=O.z}function c(){let m=new fe;for(let O=0;O<n.length;O+=3){m.x=n[O+0],m.y=n[O+1],m.z=n[O+2];let b=_(m)/2/Math.PI+.5,v=y(m)/Math.PI+.5;a.push(b,1-v)}p(),d()}function d(){for(let m=0;m<a.length;m+=6){let O=a[m+0],b=a[m+2],v=a[m+4],E=Math.max(O,b,v),T=Math.min(O,b,v);E>.9&&T<.1&&(O<.2&&(a[m+0]+=1),b<.2&&(a[m+2]+=1),v<.2&&(a[m+4]+=1))}}function f(m){n.push(m.x,m.y,m.z)}function u(m,O){let b=m*3;O.x=t[b+0],O.y=t[b+1],O.z=t[b+2]}function p(){let m=new fe,O=new fe,b=new fe,v=new fe,E=new Je,T=new Je,P=new Je;for(let A=0,C=0;A<n.length;A+=9,C+=6){m.set(n[A+0],n[A+1],n[A+2]),O.set(n[A+3],n[A+4],n[A+5]),b.set(n[A+6],n[A+7],n[A+8]),E.set(a[C+0],a[C+1]),T.set(a[C+2],a[C+3]),P.set(a[C+4],a[C+5]),v.copy(m).add(O).add(b).divideScalar(3);let M=_(v);g(E,C+0,m,M),g(T,C+2,O,M),g(P,C+4,b,M)}}function g(m,O,b,v){v<0&&m.x===1&&(a[O]=m.x-1),b.x===0&&b.z===0&&(a[O]=v/2/Math.PI+.5)}function _(m){return Math.atan2(m.z,-m.x)}function y(m){return Math.atan2(-m.y,Math.sqrt(m.x*m.x+m.z*m.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new tA(t.vertices,t.indices,t.radius,t.details)}},iY=class iA extends Gf{constructor(t=1,i=0){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(n,a,t,i),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:i}}static fromJSON(t){return new iA(t.radius,t.detail)}},sO=new fe,nO=new fe,iy=new fe,aO=new lu,rY=class extends Ss{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let i=Math.pow(10,4),r=Math.cos(oV*t),s=e.getIndex(),n=e.getAttribute("position"),a=s?s.count:n.count,o=[0,0,0],l=["a","b","c"],h=new Array(3),c={},d=[];for(let f=0;f<a;f+=3){s?(o[0]=s.getX(f),o[1]=s.getX(f+1),o[2]=s.getX(f+2)):(o[0]=f,o[1]=f+1,o[2]=f+2);let{a:u,b:p,c:g}=aO;if(u.fromBufferAttribute(n,o[0]),p.fromBufferAttribute(n,o[1]),g.fromBufferAttribute(n,o[2]),aO.getNormal(iy),h[0]=`${Math.round(u.x*i)},${Math.round(u.y*i)},${Math.round(u.z*i)}`,h[1]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,h[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){let y=(_+1)%3,m=h[_],O=h[y],b=aO[l[_]],v=aO[l[y]],E=`${m}_${O}`,T=`${O}_${m}`;T in c&&c[T]?(iy.dot(c[T].normal)<=r&&(d.push(b.x,b.y,b.z),d.push(v.x,v.y,v.z)),c[T]=null):E in c||(c[E]={index0:o[_],index1:o[y],normal:iy.clone()})}}for(let f in c)if(c[f]){let{index0:u,index1:p}=c[f];sO.fromBufferAttribute(n,u),nO.fromBufferAttribute(n,p),d.push(sO.x,sO.y,sO.z),d.push(nO.x,nO.y,nO.z)}this.setAttribute("position",new Nt(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},rA=class extends dy{constructor(e){super(e),this.uuid=bu(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new dy().fromJSON(r))}return this}},sY={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=sA(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,c,d,f,u;if(r&&(n=hY(e,t,n,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let p=i;p<s;p+=i)d=e[p],f=e[p+1],d<o&&(o=d),f<l&&(l=f),d>h&&(h=d),f>c&&(c=f);u=Math.max(h-o,c-l),u=u!==0?32767/u:0}return Af(n,a,i,o,l,u,0),a}};function sA(e,t,i,r,s){let n,a;if(s===yY(e,t,i,r)>0)for(n=t;n<i;n+=r)a=fI(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=fI(n,e[n],e[n+1],a);return a&&IO(a,a.next)&&(Lf(a),a=a.next),a}function gh(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(IO(i,i.next)||ir(i.prev,i,i.next)===0)){if(Lf(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Af(e,t,i,r,s,n,a){if(!e)return;!a&&n&&pY(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?aY(e,r,s,n):nY(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Lf(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=oY(gh(e),t,i),Af(e,t,i,r,s,n,2)):a===2&&lY(e,t,i,r,s,n):Af(gh(e),t,i,r,s,n,1);break}}}function nY(e){let t=e.prev,i=e,r=e.next;if(ir(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,c=s<n?s<a?s:a:n<a?n:a,d=o<l?o<h?o:h:l<h?l:h,f=s>n?s>a?s:a:n>a?n:a,u=o>l?o>h?o:h:l>h?l:h,p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=d&&p.y<=u&&du(s,o,n,l,a,h,p.x,p.y)&&ir(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function aY(e,t,i,r){let s=e.prev,n=e,a=e.next;if(ir(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,c=s.y,d=n.y,f=a.y,u=o<l?o<h?o:h:l<h?l:h,p=c<d?c<f?c:f:d<f?d:f,g=o>l?o>h?o:h:l>h?l:h,_=c>d?c>f?c:f:d>f?d:f,y=fy(u,p,t,i,r),m=fy(g,_,t,i,r),O=e.prevZ,b=e.nextZ;for(;O&&O.z>=y&&b&&b.z<=m;){if(O.x>=u&&O.x<=g&&O.y>=p&&O.y<=_&&O!==s&&O!==a&&du(o,c,l,d,h,f,O.x,O.y)&&ir(O.prev,O,O.next)>=0||(O=O.prevZ,b.x>=u&&b.x<=g&&b.y>=p&&b.y<=_&&b!==s&&b!==a&&du(o,c,l,d,h,f,b.x,b.y)&&ir(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;O&&O.z>=y;){if(O.x>=u&&O.x<=g&&O.y>=p&&O.y<=_&&O!==s&&O!==a&&du(o,c,l,d,h,f,O.x,O.y)&&ir(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;b&&b.z<=m;){if(b.x>=u&&b.x<=g&&b.y>=p&&b.y<=_&&b!==s&&b!==a&&du(o,c,l,d,h,f,b.x,b.y)&&ir(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function oY(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!IO(s,n)&&nA(s,r,r.next,n)&&Cf(s,n)&&Cf(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),Lf(r),Lf(r.next),r=e=n),r=r.next}while(r!==e);return gh(r)}function lY(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&OY(a,o)){let l=aA(a,o);a=gh(a,a.next),l=gh(l,l.next),Af(a,t,i,r,s,n,0),Af(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function hY(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=sA(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(_Y(h));for(s.sort(cY),n=0;n<s.length;n++)i=uY(s[n],i);return i}function cY(e,t){return e.x-t.x}function uY(e,t){let i=dY(e,t);if(!i)return t;let r=aA(i,e);return gh(r,r.next),gh(i,i.next)}function dY(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let f=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(f<=n&&f>r&&(r=f,s=i.x<i.next.x?i:i.next,f===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,c=1/0,d;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&du(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(d=Math.abs(a-i.y)/(n-i.x),Cf(i,e)&&(d<c||d===c&&(i.x>s.x||i.x===s.x&&fY(s,i)))&&(s=i,c=d)),i=i.next;while(i!==o);return s}function fY(e,t){return ir(e.prev,e,t.prev)<0&&ir(t.next,e,e.next)<0}function pY(e,t,i,r){let s=e;do s.z===0&&(s.z=fy(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,gY(s)}function gY(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function fy(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function _Y(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function du(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function OY(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!mY(e,t)&&(Cf(e,t)&&Cf(t,e)&&bY(e,t)&&(ir(e.prev,e,t.prev)||ir(e,t.prev,t))||IO(e,t)&&ir(e.prev,e,e.next)>0&&ir(t.prev,t,t.next)>0)}function ir(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function IO(e,t){return e.x===t.x&&e.y===t.y}function nA(e,t,i,r){let s=lO(ir(e,t,i)),n=lO(ir(e,t,r)),a=lO(ir(i,r,e)),o=lO(ir(i,r,t));return!!(s!==n&&a!==o||s===0&&oO(e,i,t)||n===0&&oO(e,r,t)||a===0&&oO(i,e,r)||o===0&&oO(i,t,r))}function oO(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function lO(e){return e>0?1:e<0?-1:0}function mY(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&nA(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Cf(e,t){return ir(e.prev,e,e.next)<0?ir(e,t,e.next)>=0&&ir(e,e.prev,t)>=0:ir(e,t,e.prev)<0||ir(e,e.next,t)<0}function bY(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function aA(e,t){let i=new py(e.i,e.x,e.y),r=new py(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function fI(e,t,i,r){let s=new py(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Lf(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function py(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yY(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var gu=class oA{static area(t){let i=t.length,r=0;for(let s=i-1,n=0;n<i;s=n++)r+=t[s].x*t[n].y-t[n].x*t[s].y;return r*.5}static isClockWise(t){return oA.area(t)<0}static triangulateShape(t,i){let r=[],s=[],n=[];pI(t),gI(r,t);let a=t.length;i.forEach(pI);for(let l=0;l<i.length;l++)s.push(a),a+=i[l].length,gI(r,i[l]);let o=sY.triangulate(r,s);for(let l=0;l<o.length;l+=3)n.push(o.slice(l,l+3));return n}};function pI(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function gI(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var vY=class lA extends Ss{constructor(t=new rA([new Je(.5,.5),new Je(-.5,.5),new Je(-.5,-.5),new Je(.5,-.5)]),i={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:i},t=Array.isArray(t)?t:[t];let r=this,s=[],n=[];for(let o=0,l=t.length;o<l;o++){let h=t[o];a(h)}this.setAttribute("position",new Nt(s,3)),this.setAttribute("uv",new Nt(n,2)),this.computeVertexNormals();function a(o){let l=[],h=i.curveSegments!==void 0?i.curveSegments:12,c=i.steps!==void 0?i.steps:1,d=i.depth!==void 0?i.depth:1,f=i.bevelEnabled!==void 0?i.bevelEnabled:!0,u=i.bevelThickness!==void 0?i.bevelThickness:.2,p=i.bevelSize!==void 0?i.bevelSize:u-.1,g=i.bevelOffset!==void 0?i.bevelOffset:0,_=i.bevelSegments!==void 0?i.bevelSegments:3,y=i.extrudePath,m=i.UVGenerator!==void 0?i.UVGenerator:xY,O,b=!1,v,E,T,P;y&&(O=y.getSpacedPoints(c),b=!0,f=!1,v=y.computeFrenetFrames(c,!1),E=new fe,T=new fe,P=new fe),f||(_=0,u=0,p=0,g=0);let A=o.extractPoints(h),C=A.shape,M=A.holes;if(!gu.isClockWise(C)){C=C.reverse();for(let X=0,ie=M.length;X<ie;X++){let de=M[X];gu.isClockWise(de)&&(M[X]=de.reverse())}}let H=gu.triangulateShape(C,M),k=C;for(let X=0,ie=M.length;X<ie;X++){let de=M[X];C=C.concat(de)}function F(X,ie,de){return ie||console.error("THREE.ExtrudeGeometry: vec does not exist"),X.clone().addScaledVector(ie,de)}let j=C.length,L=H.length;function R(X,ie,de){let Ce,De,Fe,Pe=X.x-ie.x,w=X.y-ie.y,B=de.x-X.x,V=de.y-X.y,Y=Pe*Pe+w*w,W=Pe*V-w*B;if(Math.abs(W)>Number.EPSILON){let ne=Math.sqrt(Y),ue=Math.sqrt(B*B+V*V),Re=ie.x-w/ne,Ue=ie.y+Pe/ne,je=de.x-V/ue,dt=de.y+B/ue,Ot=((je-Re)*V-(dt-Ue)*B)/(Pe*V-w*B);Ce=Re+Pe*Ot-X.x,De=Ue+w*Ot-X.y;let Lt=Ce*Ce+De*De;if(Lt<=2)return new Je(Ce,De);Fe=Math.sqrt(Lt/2)}else{let ne=!1;Pe>Number.EPSILON?B>Number.EPSILON&&(ne=!0):Pe<-Number.EPSILON?B<-Number.EPSILON&&(ne=!0):Math.sign(w)===Math.sign(V)&&(ne=!0),ne?(Ce=-w,De=Pe,Fe=Math.sqrt(Y)):(Ce=Pe,De=w,Fe=Math.sqrt(Y/2))}return new Je(Ce/Fe,De/Fe)}let x=[];for(let X=0,ie=k.length,de=ie-1,Ce=X+1;X<ie;X++,de++,Ce++)de===ie&&(de=0),Ce===ie&&(Ce=0),x[X]=R(k[X],k[de],k[Ce]);let I=[],S,D=x.concat();for(let X=0,ie=M.length;X<ie;X++){let de=M[X];S=[];for(let Ce=0,De=de.length,Fe=De-1,Pe=Ce+1;Ce<De;Ce++,Fe++,Pe++)Fe===De&&(Fe=0),Pe===De&&(Pe=0),S[Ce]=R(de[Ce],de[Fe],de[Pe]);I.push(S),D=D.concat(S)}for(let X=0;X<_;X++){let ie=X/_,de=u*Math.cos(ie*Math.PI/2),Ce=p*Math.sin(ie*Math.PI/2)+g;for(let De=0,Fe=k.length;De<Fe;De++){let Pe=F(k[De],x[De],Ce);se(Pe.x,Pe.y,-de)}for(let De=0,Fe=M.length;De<Fe;De++){let Pe=M[De];S=I[De];for(let w=0,B=Pe.length;w<B;w++){let V=F(Pe[w],S[w],Ce);se(V.x,V.y,-de)}}}let N=p+g;for(let X=0;X<j;X++){let ie=f?F(C[X],D[X],N):C[X];b?(T.copy(v.normals[0]).multiplyScalar(ie.x),E.copy(v.binormals[0]).multiplyScalar(ie.y),P.copy(O[0]).add(T).add(E),se(P.x,P.y,P.z)):se(ie.x,ie.y,0)}for(let X=1;X<=c;X++)for(let ie=0;ie<j;ie++){let de=f?F(C[ie],D[ie],N):C[ie];b?(T.copy(v.normals[X]).multiplyScalar(de.x),E.copy(v.binormals[X]).multiplyScalar(de.y),P.copy(O[X]).add(T).add(E),se(P.x,P.y,P.z)):se(de.x,de.y,d/c*X)}for(let X=_-1;X>=0;X--){let ie=X/_,de=u*Math.cos(ie*Math.PI/2),Ce=p*Math.sin(ie*Math.PI/2)+g;for(let De=0,Fe=k.length;De<Fe;De++){let Pe=F(k[De],x[De],Ce);se(Pe.x,Pe.y,d+de)}for(let De=0,Fe=M.length;De<Fe;De++){let Pe=M[De];S=I[De];for(let w=0,B=Pe.length;w<B;w++){let V=F(Pe[w],S[w],Ce);b?se(V.x,V.y+O[c-1].y,O[c-1].x+de):se(V.x,V.y,d+de)}}}G(),z();function G(){let X=s.length/3;if(f){let ie=0,de=j*ie;for(let Ce=0;Ce<L;Ce++){let De=H[Ce];he(De[2]+de,De[1]+de,De[0]+de)}ie=c+_*2,de=j*ie;for(let Ce=0;Ce<L;Ce++){let De=H[Ce];he(De[0]+de,De[1]+de,De[2]+de)}}else{for(let ie=0;ie<L;ie++){let de=H[ie];he(de[2],de[1],de[0])}for(let ie=0;ie<L;ie++){let de=H[ie];he(de[0]+j*c,de[1]+j*c,de[2]+j*c)}}r.addGroup(X,s.length/3-X,0)}function z(){let X=s.length/3,ie=0;Z(k,ie),ie+=k.length;for(let de=0,Ce=M.length;de<Ce;de++){let De=M[de];Z(De,ie),ie+=De.length}r.addGroup(X,s.length/3-X,1)}function Z(X,ie){let de=X.length;for(;--de>=0;){let Ce=de,De=de-1;De<0&&(De=X.length-1);for(let Fe=0,Pe=c+_*2;Fe<Pe;Fe++){let w=j*Fe,B=j*(Fe+1),V=ie+Ce+w,Y=ie+De+w,W=ie+De+B,ne=ie+Ce+B;pe(V,Y,W,ne)}}}function se(X,ie,de){l.push(X),l.push(ie),l.push(de)}function he(X,ie,de){Se(X),Se(ie),Se(de);let Ce=s.length/3,De=m.generateTopUV(r,s,Ce-3,Ce-2,Ce-1);q(De[0]),q(De[1]),q(De[2])}function pe(X,ie,de,Ce){Se(X),Se(ie),Se(Ce),Se(ie),Se(de),Se(Ce);let De=s.length/3,Fe=m.generateSideWallUV(r,s,De-6,De-3,De-2,De-1);q(Fe[0]),q(Fe[1]),q(Fe[3]),q(Fe[1]),q(Fe[2]),q(Fe[3])}function Se(X){s.push(l[X*3+0]),s.push(l[X*3+1]),s.push(l[X*3+2])}function q(X){n.push(X.x),n.push(X.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),i=this.parameters.shapes,r=this.parameters.options;return EY(i,r,t)}static fromJSON(t,i){let r=[];for(let n=0,a=t.shapes.length;n<a;n++){let o=i[t.shapes[n]];r.push(o)}let s=t.options.extrudePath;return s!==void 0&&(t.options.extrudePath=new vO[s.type]().fromJSON(s)),new lA(r,t.options)}},xY={generateTopUV:function(e,t,i,r,s){let n=t[i*3],a=t[i*3+1],o=t[r*3],l=t[r*3+1],h=t[s*3],c=t[s*3+1];return[new Je(n,a),new Je(o,l),new Je(h,c)]},generateSideWallUV:function(e,t,i,r,s,n){let a=t[i*3],o=t[i*3+1],l=t[i*3+2],h=t[r*3],c=t[r*3+1],d=t[r*3+2],f=t[s*3],u=t[s*3+1],p=t[s*3+2],g=t[n*3],_=t[n*3+1],y=t[n*3+2];return Math.abs(o-c)<Math.abs(a-h)?[new Je(a,1-l),new Je(h,1-d),new Je(f,1-p),new Je(g,1-y)]:[new Je(o,1-l),new Je(c,1-d),new Je(u,1-p),new Je(_,1-y)]}};function EY(e,t,i){if(i.shapes=[],Array.isArray(e))for(let r=0,s=e.length;r<s;r++){let n=e[r];i.shapes.push(n.uuid)}else i.shapes.push(e.uuid);return i.options=Object.assign({},t),t.extrudePath!==void 0&&(i.options.extrudePath=t.extrudePath.toJSON()),i}var wY=class hA extends Gf{constructor(t=1,i=0){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(s,n,t,i),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:i}}static fromJSON(t){return new hA(t.radius,t.detail)}},TY=class cA extends Gf{constructor(t=1,i=0){let r=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],s=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(r,s,t,i),this.type="OctahedronGeometry",this.parameters={radius:t,detail:i}}static fromJSON(t){return new cA(t.radius,t.detail)}},SY=class uA extends Ss{constructor(t=1,i=1,r=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:i,widthSegments:r,heightSegments:s};let n=t/2,a=i/2,o=Math.floor(r),l=Math.floor(s),h=o+1,c=l+1,d=t/o,f=i/l,u=[],p=[],g=[],_=[];for(let y=0;y<c;y++){let m=y*f-a;for(let O=0;O<h;O++){let b=O*d-n;p.push(b,-m,0),g.push(0,0,1),_.push(O/o),_.push(1-y/l)}}for(let y=0;y<l;y++)for(let m=0;m<o;m++){let O=m+h*y,b=m+h*(y+1),v=m+1+h*(y+1),E=m+1+h*y;u.push(O,b,E),u.push(b,v,E)}this.setIndex(u),this.setAttribute("position",new Nt(p,3)),this.setAttribute("normal",new Nt(g,3)),this.setAttribute("uv",new Nt(_,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new uA(t.width,t.height,t.widthSegments,t.heightSegments)}},IY=class dA extends Ss{constructor(t=.5,i=1,r=32,s=1,n=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:i,thetaSegments:r,phiSegments:s,thetaStart:n,thetaLength:a},r=Math.max(3,r),s=Math.max(1,s);let o=[],l=[],h=[],c=[],d=t,f=(i-t)/s,u=new fe,p=new Je;for(let g=0;g<=s;g++){for(let _=0;_<=r;_++){let y=n+_/r*a;u.x=d*Math.cos(y),u.y=d*Math.sin(y),l.push(u.x,u.y,u.z),h.push(0,0,1),p.x=(u.x/i+1)/2,p.y=(u.y/i+1)/2,c.push(p.x,p.y)}d+=f}for(let g=0;g<s;g++){let _=g*(r+1);for(let y=0;y<r;y++){let m=y+_,O=m,b=m+r+1,v=m+r+2,E=m+1;o.push(O,b,E),o.push(b,v,E)}}this.setIndex(o),this.setAttribute("position",new Nt(l,3)),this.setAttribute("normal",new Nt(h,3)),this.setAttribute("uv",new Nt(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dA(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},PY=class fA extends Ss{constructor(t=new rA([new Je(0,.5),new Je(-.5,-.5),new Je(.5,-.5)]),i=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:i};let r=[],s=[],n=[],a=[],o=0,l=0;if(Array.isArray(t)===!1)h(t);else for(let c=0;c<t.length;c++)h(t[c]),this.addGroup(o,l,c),o+=l,l=0;this.setIndex(r),this.setAttribute("position",new Nt(s,3)),this.setAttribute("normal",new Nt(n,3)),this.setAttribute("uv",new Nt(a,2));function h(c){let d=s.length/3,f=c.extractPoints(i),u=f.shape,p=f.holes;gu.isClockWise(u)===!1&&(u=u.reverse());for(let _=0,y=p.length;_<y;_++){let m=p[_];gu.isClockWise(m)===!0&&(p[_]=m.reverse())}let g=gu.triangulateShape(u,p);for(let _=0,y=p.length;_<y;_++){let m=p[_];u=u.concat(m)}for(let _=0,y=u.length;_<y;_++){let m=u[_];s.push(m.x,m.y,0),n.push(0,0,1),a.push(m.x,m.y)}for(let _=0,y=g.length;_<y;_++){let m=g[_],O=m[0]+d,b=m[1]+d,v=m[2]+d;r.push(O,b,v),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),i=this.parameters.shapes;return AY(i,t)}static fromJSON(t,i){let r=[];for(let s=0,n=t.shapes.length;s<n;s++){let a=i[t.shapes[s]];r.push(a)}return new fA(r,t.curveSegments)}};function AY(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,r=e.length;i<r;i++){let s=e[i];t.shapes.push(s.uuid)}else t.shapes.push(e.uuid);return t}var CY=class pA extends Ss{constructor(t=1,i=32,r=16,s=0,n=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:i,heightSegments:r,phiStart:s,phiLength:n,thetaStart:a,thetaLength:o},i=Math.max(3,Math.floor(i)),r=Math.max(2,Math.floor(r));let l=Math.min(a+o,Math.PI),h=0,c=[],d=new fe,f=new fe,u=[],p=[],g=[],_=[];for(let y=0;y<=r;y++){let m=[],O=y/r,b=0;y===0&&a===0?b=.5/i:y===r&&l===Math.PI&&(b=-.5/i);for(let v=0;v<=i;v++){let E=v/i;d.x=-t*Math.cos(s+E*n)*Math.sin(a+O*o),d.y=t*Math.cos(a+O*o),d.z=t*Math.sin(s+E*n)*Math.sin(a+O*o),p.push(d.x,d.y,d.z),f.copy(d).normalize(),g.push(f.x,f.y,f.z),_.push(E+b,1-O),m.push(h++)}c.push(m)}for(let y=0;y<r;y++)for(let m=0;m<i;m++){let O=c[y][m+1],b=c[y][m],v=c[y+1][m],E=c[y+1][m+1];(y!==0||a>0)&&u.push(O,b,E),(y!==r-1||l<Math.PI)&&u.push(b,v,E)}this.setIndex(u),this.setAttribute("position",new Nt(p,3)),this.setAttribute("normal",new Nt(g,3)),this.setAttribute("uv",new Nt(_,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pA(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},LY=class gA extends Gf{constructor(t=1,i=0){let r=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],s=[2,1,0,0,3,2,1,3,0,2,3,1];super(r,s,t,i),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:i}}static fromJSON(t){return new gA(t.radius,t.detail)}},DY=class _A extends Ss{constructor(t=1,i=.4,r=12,s=48,n=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:i,radialSegments:r,tubularSegments:s,arc:n},r=Math.floor(r),s=Math.floor(s);let a=[],o=[],l=[],h=[],c=new fe,d=new fe,f=new fe;for(let u=0;u<=r;u++)for(let p=0;p<=s;p++){let g=p/s*n,_=u/r*Math.PI*2;d.x=(t+i*Math.cos(_))*Math.cos(g),d.y=(t+i*Math.cos(_))*Math.sin(g),d.z=i*Math.sin(_),o.push(d.x,d.y,d.z),c.x=t*Math.cos(g),c.y=t*Math.sin(g),f.subVectors(d,c).normalize(),l.push(f.x,f.y,f.z),h.push(p/s),h.push(u/r)}for(let u=1;u<=r;u++)for(let p=1;p<=s;p++){let g=(s+1)*u+p-1,_=(s+1)*(u-1)+p-1,y=(s+1)*(u-1)+p,m=(s+1)*u+p;a.push(g,_,m),a.push(_,y,m)}this.setIndex(a),this.setAttribute("position",new Nt(o,3)),this.setAttribute("normal",new Nt(l,3)),this.setAttribute("uv",new Nt(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new _A(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},RY=class OA extends Ss{constructor(t=1,i=.4,r=64,s=8,n=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a},r=Math.floor(r),s=Math.floor(s);let o=[],l=[],h=[],c=[],d=new fe,f=new fe,u=new fe,p=new fe,g=new fe,_=new fe,y=new fe;for(let O=0;O<=r;++O){let b=O/r*n*Math.PI*2;m(b,n,a,t,u),m(b+.01,n,a,t,p),_.subVectors(p,u),y.addVectors(p,u),g.crossVectors(_,y),y.crossVectors(g,_),g.normalize(),y.normalize();for(let v=0;v<=s;++v){let E=v/s*Math.PI*2,T=-i*Math.cos(E),P=i*Math.sin(E);d.x=u.x+(T*y.x+P*g.x),d.y=u.y+(T*y.y+P*g.y),d.z=u.z+(T*y.z+P*g.z),l.push(d.x,d.y,d.z),f.subVectors(d,u).normalize(),h.push(f.x,f.y,f.z),c.push(O/r),c.push(v/s)}}for(let O=1;O<=r;O++)for(let b=1;b<=s;b++){let v=(s+1)*(O-1)+(b-1),E=(s+1)*O+(b-1),T=(s+1)*O+b,P=(s+1)*(O-1)+b;o.push(v,E,P),o.push(E,T,P)}this.setIndex(o),this.setAttribute("position",new Nt(l,3)),this.setAttribute("normal",new Nt(h,3)),this.setAttribute("uv",new Nt(c,2));function m(O,b,v,E,T){let P=Math.cos(O),A=Math.sin(O),C=v/b*O,M=Math.cos(C);T.x=E*(2+M)*.5*P,T.y=E*(2+M)*A*.5,T.z=E*Math.sin(C)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new OA(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},NY=class mA extends Ss{constructor(t=new qP(new fe(-1,-1,0),new fe(-1,1,0),new fe(1,1,0)),i=64,r=1,s=8,n=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:i,radius:r,radialSegments:s,closed:n};let a=t.computeFrenetFrames(i,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new fe,l=new fe,h=new Je,c=new fe,d=[],f=[],u=[],p=[];g(),this.setIndex(p),this.setAttribute("position",new Nt(d,3)),this.setAttribute("normal",new Nt(f,3)),this.setAttribute("uv",new Nt(u,2));function g(){for(let O=0;O<i;O++)_(O);_(n===!1?i:0),m(),y()}function _(O){c=t.getPointAt(O/i,c);let b=a.normals[O],v=a.binormals[O];for(let E=0;E<=s;E++){let T=E/s*Math.PI*2,P=Math.sin(T),A=-Math.cos(T);l.x=A*b.x+P*v.x,l.y=A*b.y+P*v.y,l.z=A*b.z+P*v.z,l.normalize(),f.push(l.x,l.y,l.z),o.x=c.x+r*l.x,o.y=c.y+r*l.y,o.z=c.z+r*l.z,d.push(o.x,o.y,o.z)}}function y(){for(let O=1;O<=i;O++)for(let b=1;b<=s;b++){let v=(s+1)*(O-1)+(b-1),E=(s+1)*O+(b-1),T=(s+1)*O+b,P=(s+1)*(O-1)+b;p.push(v,E,P),p.push(E,T,P)}}function m(){for(let O=0;O<=i;O++)for(let b=0;b<=s;b++)h.x=O/i,h.y=b/s,u.push(h.x,h.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new mA(new vO[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},MY=class extends Ss{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new fe,s=new fe;if(e.index!==null){let n=e.attributes.position,a=e.index,o=e.groups;o.length===0&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,h=o.length;l<h;++l){let c=o[l],d=c.start,f=c.count;for(let u=d,p=d+f;u<p;u+=3)for(let g=0;g<3;g++){let _=a.getX(u+g),y=a.getX(u+(g+1)%3);r.fromBufferAttribute(n,_),s.fromBufferAttribute(n,y),_I(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let n=e.attributes.position;for(let a=0,o=n.count/3;a<o;a++)for(let l=0;l<3;l++){let h=3*a+l,c=3*a+(l+1)%3;r.fromBufferAttribute(n,h),s.fromBufferAttribute(n,c),_I(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Nt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function _I(e,t,i){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,s=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return i.has(r)===!0||i.has(s)===!0?!1:(i.add(r),i.add(s),!0)}var tle=Object.freeze({__proto__:null,BoxGeometry:RV,CapsuleGeometry:QV,CircleGeometry:eY,ConeGeometry:tY,CylinderGeometry:$P,DodecahedronGeometry:iY,EdgesGeometry:rY,ExtrudeGeometry:vY,IcosahedronGeometry:wY,LatheGeometry:XP,OctahedronGeometry:TY,PlaneGeometry:SY,PolyhedronGeometry:Gf,RingGeometry:IY,ShapeGeometry:PY,SphereGeometry:CY,TetrahedronGeometry:LY,TorusGeometry:DY,TorusKnotGeometry:RY,TubeGeometry:NY,WireframeGeometry:MY});function hO(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function BY(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var PO=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let n;i:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}n=t.length;break i}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}n=i,i=0;break i}break e}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},kY=class extends PO{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:VS,endingEnd:VS}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case YS:s=e,a=2*t-i;break;case qS:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case YS:n=e,o=2*i-t;break;case qS:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,f=this._weightNext,u=(i-t)/(r-t),p=u*u,g=p*u,_=-d*g+2*d*p-d*u,y=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*u+1,m=(-1-f)*g+(1.5+f)*p+.5*u,O=f*g-f*p;for(let b=0;b!==a;++b)s[b]=_*n[h+b]+y*n[l+b]+m*n[o+b]+O*n[c+b];return s}},FY=class extends PO{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),c=1-h;for(let d=0;d!==a;++d)s[d]=n[l+d]*c+n[o+d]*h;return s}},UY=class extends PO{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Po=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=hO(t,this.TimeBufferType),this.values=hO(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:hO(e.times,Array),values:hO(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new UY(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new FY(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new kY(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yO:t=this.InterpolantFactoryMethodDiscrete;break;case hy:t=this.InterpolantFactoryMethodLinear;break;case Cb:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yO;case this.InterpolantFactoryMethodLinear:return hy;case this.InterpolantFactoryMethodSmooth:return Cb}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=i.slice(s,n),this.values=this.values.slice(s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&BY(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Cb,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let c=a*i,d=c-i,f=c+i;for(let u=0;u!==i;++u){let p=t[c+u];if(p!==t[d+u]||p!==t[f+u]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let c=a*i,d=n*i;for(let f=0;f!==i;++f)t[d+f]=t[c+f]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=e.slice(0,n),this.values=t.slice(0,n*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Po.prototype.TimeBufferType=Float32Array;Po.prototype.ValueBufferType=Float32Array;Po.prototype.DefaultInterpolation=hy;var zf=class extends Po{constructor(e,t,i){super(e,t,i)}};zf.prototype.ValueTypeName="bool";zf.prototype.ValueBufferType=Array;zf.prototype.DefaultInterpolation=yO;zf.prototype.InterpolantFactoryMethodLinear=void 0;zf.prototype.InterpolantFactoryMethodSmooth=void 0;var GY=class extends Po{};GY.prototype.ValueTypeName="color";var zY=class extends Po{};zY.prototype.ValueTypeName="number";var HY=class extends PO{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)ml.slerpFlat(s,0,n,l-a,n,l,o);return s}},bA=class extends Po{InterpolantFactoryMethodLinear(e){return new HY(this.times,this.values,this.getValueSize(),e)}};bA.prototype.ValueTypeName="quaternion";bA.prototype.InterpolantFactoryMethodSmooth=void 0;var Hf=class extends Po{constructor(e,t,i){super(e,t,i)}};Hf.prototype.ValueTypeName="string";Hf.prototype.ValueBufferType=Array;Hf.prototype.DefaultInterpolation=yO;Hf.prototype.InterpolantFactoryMethodLinear=void 0;Hf.prototype.InterpolantFactoryMethodSmooth=void 0;var jY=class extends Po{};jY.prototype.ValueTypeName="vector";var VY=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,d=l.length;c<d;c+=2){let f=l[c],u=l[c+1];if(f.global&&(f.lastIndex=0),f.test(h))return u}return null}}},YY=new VY,qY=class{constructor(e){this.manager=e!==void 0?e:YY,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};qY.DEFAULT_MATERIAL_NAME="__DEFAULT";var ile=new li,rle=new fe,sle=new fe,nle=new li,ale=new fe,ole=new fe,WY=class extends HP{constructor(e=-1,t=1,i=1,r=-1,s=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=n,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,n){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,n=i+e,a=r+t,o=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,n=s+l*this.view.width,a-=h*this.view.offsetY,o=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,n,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},lle=new li,hle=new li,cle=new li,ule=new fe,dle=new ml,fle=new fe,ple=new fe,gle=new fe,_le=new ml,Ole=new fe,mle=new fe,Hy="\\[\\]\\.:\\/",XY=new RegExp("["+Hy+"]","g"),jy="[^"+Hy+"]",JY="[^"+Hy.replace("\\.","")+"]",ZY=/((?:WC+[\/:])*)/.source.replace("WC",jy),KY=/(WCOD+)?/.source.replace("WCOD",JY),$Y=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jy),QY=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jy),eq=new RegExp("^"+ZY+KY+$Y+QY+"$"),tq=["material","materials","bones","map"],iq=class{constructor(e,t,i){let r=i||lr.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},lr=class cu{constructor(t,i,r){this.path=i,this.parsedPath=r||cu.parseTrackName(i),this.node=cu.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,i,r){return t&&t.isAnimationObjectGroup?new cu.Composite(t,i,r):new cu(t,i,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(XY,"")}static parseTrackName(t){let i=eq.exec(t);if(i===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:i[2],objectName:i[3],objectIndex:i[4],propertyName:i[5],propertyIndex:i[6]},s=r.nodeName&&r.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let n=r.nodeName.substring(s+1);tq.indexOf(n)!==-1&&(r.nodeName=r.nodeName.substring(0,s),r.objectName=n)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,i){if(i===void 0||i===""||i==="."||i===-1||i===t.name||i===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(i);if(r!==void 0)return r}if(t.children){let r=function(n){for(let a=0;a<n.length;a++){let o=n[a];if(o.name===i||o.uuid===i)return o;let l=r(o.children);if(l)return l}return null},s=r(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,i){t[i]=this.targetObject[this.propertyName]}_getValue_array(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)t[i++]=r[s]}_getValue_arrayElement(t,i){t[i]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,i){this.resolvedProperty.toArray(t,i)}_setValue_direct(t,i){this.targetObject[this.propertyName]=t[i]}_setValue_direct_setNeedsUpdate(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,i){this.targetObject[this.propertyName]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++]}_setValue_array_setNeedsUpdate(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,i){let r=this.resolvedProperty;for(let s=0,n=r.length;s!==n;++s)r[s]=t[i++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,i){this.resolvedProperty[this.propertyIndex]=t[i]}_setValue_arrayElement_setNeedsUpdate(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,i){this.resolvedProperty[this.propertyIndex]=t[i],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,i){this.resolvedProperty.fromArray(t,i)}_setValue_fromArray_setNeedsUpdate(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,i){this.resolvedProperty.fromArray(t,i),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,i){this.bind(),this.getValue(t,i)}_setValue_unbound(t,i){this.bind(),this.setValue(t,i)}bind(){let t=this.node,i=this.parsedPath,r=i.objectName,s=i.propertyName,n=i.propertyIndex;if(t||(t=cu.findNode(this.rootNode,i.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let h=i.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===h){h=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(h!==void 0){if(t[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[h]}}let a=t[s];if(a===void 0){let h=i.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(n!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[n]!==void 0&&(n=t.morphTargetDictionary[n])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};lr.Composite=iq;lr.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};lr.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};lr.prototype.GetterByBindingType=[lr.prototype._getValue_direct,lr.prototype._getValue_array,lr.prototype._getValue_arrayElement,lr.prototype._getValue_toArray];lr.prototype.SetterByBindingTypeAndVersioning=[[lr.prototype._setValue_direct,lr.prototype._setValue_direct_setNeedsUpdate,lr.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[lr.prototype._setValue_array,lr.prototype._setValue_array_setNeedsUpdate,lr.prototype._setValue_array_setMatrixWorldNeedsUpdate],[lr.prototype._setValue_arrayElement,lr.prototype._setValue_arrayElement_setNeedsUpdate,lr.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[lr.prototype._setValue_fromArray,lr.prototype._setValue_fromArray_setNeedsUpdate,lr.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var ble=new Float32Array(1),yle=new li,vle=new Je,xle=new fe,Ele=new fe,wle=new fe,Tle=new fe,Sle=new li,Ile=new li,Ple=new fe,Ale=new gr,Cle=new gr,Lle=new fe,Dle=new fe,Rle=new fe,Nle=new fe,Mle=new HP,Ble=new bl,kle=new fe;typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"172"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="172");var rq=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,sq=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,nq=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,aq=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,oq=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,lq=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,hq=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,cq=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,uq=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,dq=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,fq=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,pq=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,gq=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,_q=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,Oq=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,mq=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,bq=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,yq=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,vq=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,xq=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,Eq=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,wq=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,Tq=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,Sq=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,Iq=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,Pq=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,Aq=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,Cq=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,Lq=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Dq=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,Rq="gl_FragColor = linearToOutputTexel( gl_FragColor );",Nq=`vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,Mq=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,Bq=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,kq=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,Fq=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,Uq=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,Gq=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,zq=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,Hq=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,jq=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,Vq=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,Yq=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,qq=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,Wq=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,Xq=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,Jq=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,Zq=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,Kq=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,$q=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,Qq=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,eW=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,tW=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,iW=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,rW=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,sW=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,nW=`#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,aW=`#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,oW=`#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,lW=`#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,hW=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,cW=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,uW=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,dW=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,fW=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,pW=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,gW=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,_W=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,OW=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,mW=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,bW=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,yW=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,vW=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,xW=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,EW=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,wW=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,TW=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,SW=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,IW=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,PW=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,AW=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,CW=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,LW=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,DW=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,RW=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,NW=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,MW=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,BW=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,kW=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,FW=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,UW=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,GW=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,zW=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,HW=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,jW=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,VW=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,YW=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,qW=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,WW=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,XW=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,JW=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,ZW=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,KW=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		#else
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,$W=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,QW=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,eX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,tX=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,iX=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,rX=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,sX=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,nX=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,aX=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,oX=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,lX=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,hX=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,cX=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,uX=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,dX=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,fX=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,pX=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,gX=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,_X=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,OX=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,mX=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,bX=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,yX=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,vX=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,xX=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,EX=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,wX=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,TX=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,SX=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,IX=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,PX=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,AX=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,CX=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,LX=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,DX=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,RX=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,NX=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,MX=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,ei={alphahash_fragment:rq,alphahash_pars_fragment:sq,alphamap_fragment:nq,alphamap_pars_fragment:aq,alphatest_fragment:oq,alphatest_pars_fragment:lq,aomap_fragment:hq,aomap_pars_fragment:cq,batching_pars_vertex:uq,batching_vertex:dq,begin_vertex:fq,beginnormal_vertex:pq,bsdfs:gq,iridescence_fragment:_q,bumpmap_pars_fragment:Oq,clipping_planes_fragment:mq,clipping_planes_pars_fragment:bq,clipping_planes_pars_vertex:yq,clipping_planes_vertex:vq,color_fragment:xq,color_pars_fragment:Eq,color_pars_vertex:wq,color_vertex:Tq,common:Sq,cube_uv_reflection_fragment:Iq,defaultnormal_vertex:Pq,displacementmap_pars_vertex:Aq,displacementmap_vertex:Cq,emissivemap_fragment:Lq,emissivemap_pars_fragment:Dq,colorspace_fragment:Rq,colorspace_pars_fragment:Nq,envmap_fragment:Mq,envmap_common_pars_fragment:Bq,envmap_pars_fragment:kq,envmap_pars_vertex:Fq,envmap_physical_pars_fragment:Jq,envmap_vertex:Uq,fog_vertex:Gq,fog_pars_vertex:zq,fog_fragment:Hq,fog_pars_fragment:jq,gradientmap_pars_fragment:Vq,lightmap_pars_fragment:Yq,lights_lambert_fragment:qq,lights_lambert_pars_fragment:Wq,lights_pars_begin:Xq,lights_toon_fragment:Zq,lights_toon_pars_fragment:Kq,lights_phong_fragment:$q,lights_phong_pars_fragment:Qq,lights_physical_fragment:eW,lights_physical_pars_fragment:tW,lights_fragment_begin:iW,lights_fragment_maps:rW,lights_fragment_end:sW,logdepthbuf_fragment:nW,logdepthbuf_pars_fragment:aW,logdepthbuf_pars_vertex:oW,logdepthbuf_vertex:lW,map_fragment:hW,map_pars_fragment:cW,map_particle_fragment:uW,map_particle_pars_fragment:dW,metalnessmap_fragment:fW,metalnessmap_pars_fragment:pW,morphinstance_vertex:gW,morphcolor_vertex:_W,morphnormal_vertex:OW,morphtarget_pars_vertex:mW,morphtarget_vertex:bW,normal_fragment_begin:yW,normal_fragment_maps:vW,normal_pars_fragment:xW,normal_pars_vertex:EW,normal_vertex:wW,normalmap_pars_fragment:TW,clearcoat_normal_fragment_begin:SW,clearcoat_normal_fragment_maps:IW,clearcoat_pars_fragment:PW,iridescence_pars_fragment:AW,opaque_fragment:CW,packing:LW,premultiplied_alpha_fragment:DW,project_vertex:RW,dithering_fragment:NW,dithering_pars_fragment:MW,roughnessmap_fragment:BW,roughnessmap_pars_fragment:kW,shadowmap_pars_fragment:FW,shadowmap_pars_vertex:UW,shadowmap_vertex:GW,shadowmask_pars_fragment:zW,skinbase_vertex:HW,skinning_pars_vertex:jW,skinning_vertex:VW,skinnormal_vertex:YW,specularmap_fragment:qW,specularmap_pars_fragment:WW,tonemapping_fragment:XW,tonemapping_pars_fragment:JW,transmission_fragment:ZW,transmission_pars_fragment:KW,uv_pars_fragment:$W,uv_pars_vertex:QW,uv_vertex:eX,worldpos_vertex:tX,background_vert:iX,background_frag:rX,backgroundCube_vert:sX,backgroundCube_frag:nX,cube_vert:aX,cube_frag:oX,depth_vert:lX,depth_frag:hX,distanceRGBA_vert:cX,distanceRGBA_frag:uX,equirect_vert:dX,equirect_frag:fX,linedashed_vert:pX,linedashed_frag:gX,meshbasic_vert:_X,meshbasic_frag:OX,meshlambert_vert:mX,meshlambert_frag:bX,meshmatcap_vert:yX,meshmatcap_frag:vX,meshnormal_vert:xX,meshnormal_frag:EX,meshphong_vert:wX,meshphong_frag:TX,meshphysical_vert:SX,meshphysical_frag:IX,meshtoon_vert:PX,meshtoon_frag:AX,points_vert:CX,points_frag:LX,shadow_vert:DX,shadow_frag:RX,sprite_vert:NX,sprite_frag:MX},it={common:{diffuse:{value:new gr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new jt},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new jt}},envmap:{envMap:{value:null},envMapRotation:{value:new jt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new jt},normalScale:{value:new Je(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new gr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new gr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0},uvTransform:{value:new jt}},sprite:{diffuse:{value:new gr(16777215)},opacity:{value:1},center:{value:new Je(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new jt},alphaMap:{value:null},alphaMapTransform:{value:new jt},alphaTest:{value:0}}},OI={basic:{uniforms:Hs([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.fog]),vertexShader:ei.meshbasic_vert,fragmentShader:ei.meshbasic_frag},lambert:{uniforms:Hs([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new gr(0)}}]),vertexShader:ei.meshlambert_vert,fragmentShader:ei.meshlambert_frag},phong:{uniforms:Hs([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new gr(0)},specular:{value:new gr(1118481)},shininess:{value:30}}]),vertexShader:ei.meshphong_vert,fragmentShader:ei.meshphong_frag},standard:{uniforms:Hs([it.common,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.roughnessmap,it.metalnessmap,it.fog,it.lights,{emissive:{value:new gr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag},toon:{uniforms:Hs([it.common,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.gradientmap,it.fog,it.lights,{emissive:{value:new gr(0)}}]),vertexShader:ei.meshtoon_vert,fragmentShader:ei.meshtoon_frag},matcap:{uniforms:Hs([it.common,it.bumpmap,it.normalmap,it.displacementmap,it.fog,{matcap:{value:null}}]),vertexShader:ei.meshmatcap_vert,fragmentShader:ei.meshmatcap_frag},points:{uniforms:Hs([it.points,it.fog]),vertexShader:ei.points_vert,fragmentShader:ei.points_frag},dashed:{uniforms:Hs([it.common,it.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ei.linedashed_vert,fragmentShader:ei.linedashed_frag},depth:{uniforms:Hs([it.common,it.displacementmap]),vertexShader:ei.depth_vert,fragmentShader:ei.depth_frag},normal:{uniforms:Hs([it.common,it.bumpmap,it.normalmap,it.displacementmap,{opacity:{value:1}}]),vertexShader:ei.meshnormal_vert,fragmentShader:ei.meshnormal_frag},sprite:{uniforms:Hs([it.sprite,it.fog]),vertexShader:ei.sprite_vert,fragmentShader:ei.sprite_frag},background:{uniforms:{uvTransform:{value:new jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ei.background_vert,fragmentShader:ei.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new jt}},vertexShader:ei.backgroundCube_vert,fragmentShader:ei.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ei.cube_vert,fragmentShader:ei.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ei.equirect_vert,fragmentShader:ei.equirect_frag},distanceRGBA:{uniforms:Hs([it.common,it.displacementmap,{referencePosition:{value:new fe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ei.distanceRGBA_vert,fragmentShader:ei.distanceRGBA_frag},shadow:{uniforms:Hs([it.lights,it.fog,{color:{value:new gr(0)},opacity:{value:1}}]),vertexShader:ei.shadow_vert,fragmentShader:ei.shadow_frag}};OI.physical={uniforms:Hs([OI.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new jt},clearcoatNormalScale:{value:new Je(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new jt},sheen:{value:0},sheenColor:{value:new gr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new jt},transmissionSamplerSize:{value:new Je},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new jt},attenuationDistance:{value:0},attenuationColor:{value:new gr(0)},specularColor:{value:new gr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new jt},anisotropyVector:{value:new Je},anisotropyMap:{value:null},anisotropyMapTransform:{value:new jt}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag};var Fle=new Uf,Ule=new li,Gle=new WY,zle=new gr,fh=(1+Math.sqrt(5))/2,ou=1/fh,Hle=[new fe(-fh,ou,0),new fe(fh,ou,0),new fe(-ou,0,fh),new fe(ou,0,fh),new fe(0,fh,-ou),new fe(0,fh,ou),new fe(-1,1,-1),new fe(1,1,-1),new fe(-1,1,1),new fe(1,1,1)],jle=new Ol,Vle=new GV(1,1),Yle=new gV,qle=new _V,Wle=new MV,Xle=new Float32Array(16),Jle=new Float32Array(9),Zle=new Float32Array(4),Kle=new jt,$le=new fe,Qle={[NS]:MS,[BS]:US,[kS]:GS,[bO]:FS,[MS]:NS,[US]:BS,[GS]:kS,[FS]:bO},ehe=new Uf,the=new li;function BX(e){return new Promise(t=>setTimeout(t,e))}function gy(e,t){let i=[],r=1,s=Object.values(e);for(let n=0;n<s.length;n++){let a=o=>{if(o instanceof Array&&o.forEach(l=>a(l)),typeof o=="number")r=Math.max(r,1),i.push(o);else if(o instanceof xt||o instanceof rr){r=Math.max(r,4);for(let l=i.length;l%4!=0;l++)i.push(t);o instanceof rr?i.push(o.r,o.g,o.b):i.push(o.x,o.y,o.z)}else if(typeof o=="boolean")r=Math.max(r,1),i.push(o?1:0);else{let l=gy(o,t);r=Math.max(r,l.alignmentRequirement);for(let h=i.length;h%l.alignmentRequirement!=0;h++)i.push(t);l.bufferData.forEach(h=>{i.push(h)})}};a(s[n])}for(let n=i.length;n%r!=0;n++)i.push(t);return{bufferData:i,alignmentRequirement:r}}function yA(e){try{return gy(e,0).bufferData}catch{debugger;gy(e,0).bufferData}}var kX=class{constructor(){this.shaderCodes=[],this.isCompiling=!1}addShaderCode(e){if(this.isCompiling)throw new Error("Cannot add shader code while compiling");this.shaderCodes.push(e)}async compileAll(e){if(!(this.isCompiling||!this.shaderCodes)){this.isCompiling=!0,await BX(10);for(let t of this.shaderCodes)if((await e.createShaderModule({code:t}).getCompilationInfo()).messages.length!==0){console.log(this.shaderCodes),await e.createShaderModule({code:t}).getCompilationInfo();debugger}}}},vl=new kX;var mI={decode(e){try{let{data:t}=JSON.parse(e);return rr.build(t[0],t[1],t[2],t[3])}catch{return null}},encode(e){return JSON.stringify({data:[e.r,e.g,e.b,e.alpha]})}},cO={decode(e){let{data:t}=JSON.parse(e);return new xt(t[0],t[1],t[2])},encode(e){return JSON.stringify({data:[e.x,e.y,e.z]})}};function FX(e,t){let i=new Map;return e.forEach((r,s)=>{let n=t(r,s);n!==null&&i.set(s,n)}),i}var lhe=(1.51+.035+.035+.01+.01)*3.93701;var bI={log(e,...t){console.log(e,...t)},time(e){return console.time(e)},timeEnd(e){return console.timeEnd(e)}},vA=Math.PI,che=180/vA,UX=vA/180;function GX(e){return e*UX}var zX=class xA{constructor(t,i){this.gpu=t,this.areas=i,this.buffer=t.createUniformDynamicBuffer(this.getData(),"light soure")}static async build(t,i){let r=await this.createConfig(i),s=new xA(t,r);return s.setListen(()=>{}),s.setIsOpen(!0),s}static async createConfig(t){if(!t)return a();let i=await t.text(),r=JSON.parse(i);if(s(r))return a();return r.map((o,l)=>({name:o.name?o.name:"a"+l,color:mI.decode(o.color),power:o.power,normalize:o.normalize,size:o.size,position:cO.decode(o.position),rotate:cO.decode(o.rotate),hide:o.hide,castShadow:o.castShadow,rayVisibilityDiffuse:o.rayVisibilityDiffuse,rayVisibilityGlossy:o.rayVisibilityGlossy,spread:o.spread}));function s(o){return!!o.find(l=>n(l))}function n(o){return o.name===void 0||o.color===void 0||o.power===void 0||o.normalize===void 0||o.size===void 0||o.position===void 0||o.rotate===void 0||o.hide===void 0||o.castShadow===void 0||o.rayVisibilityDiffuse===void 0||o.rayVisibilityGlossy===void 0||o.spread===void 0}function a(){return[o("a0"),o("a1"),o("a2")];function o(l){return{name:l,color:rr.WHITE,power:10,size:{width:2,height:2},normalize:!1,position:new xt(0,0,10),rotate:xt.ORIGIN,hide:!1,castShadow:!0,rayVisibilityDiffuse:!0,rayVisibilityGlossy:!0,spread:180}}}}getBlob(){let t=Array.from(this.areas.values()).map(i=>({name:i.name,color:mI.encode(i.color),power:i.power,normalize:i.normalize,size:i.size,position:cO.encode(i.position),rotate:cO.encode(i.rotate),hide:i.hide,castShadow:i.castShadow,rayVisibilityDiffuse:i.rayVisibilityDiffuse,rayVisibilityGlossy:i.rayVisibilityGlossy,spread:i.spread}));return new Blob([JSON.stringify(t)])}get(t){return this.areas.find(i=>i.name===t)}set(t){for(let i=0;i<this.areas.length;i++)if(this.areas[i].name===t.name){this.areas[i]=t,this.isChange=!0;return}throw new Error}getAll(){return this.areas.map(t=>t.name)}setListen(t){this.listen=t}getIsOpen(){return this.isOpen}setIsOpen(t){this.isOpen=t,this.listen()}checkAndUpdate(){return this.isChange?(this.gpu.writeBuffer(this.buffer,0,new Float32Array(this.getData())),this.isChange=!1,!0):!1}getBBox(){return new Kn().build()}getData(){let t=Array.from(this.areas.values()).map(r=>{let s=xt.X_UNIT_VECTOR,n=xt.Y_UNIT_VECTOR;return s=s.multiply4(Bi.rotateX(r.rotate.x*Math.PI/180)).normalize(),s=s.multiply4(Bi.rotateY(r.rotate.y*Math.PI/180)).normalize(),s=s.multiply4(Bi.rotateZ(r.rotate.z*Math.PI/180)).normalize(),s=s.scale(r.size.width),n=n.multiply4(Bi.rotateX(r.rotate.x*Math.PI/180)).normalize(),n=n.multiply4(Bi.rotateY(r.rotate.y*Math.PI/180)).normalize(),n=n.multiply4(Bi.rotateZ(r.rotate.z*Math.PI/180)).normalize(),n=n.scale(r.size.height),{hide:r.hide,color:r.color,power:r.power,position:r.position.sub(s.scale(.5)).sub(n.scale(.5)),u:s,v:n,cast_shadow:r.castShadow,diffuse:r.rayVisibilityDiffuse,glossy:r.rayVisibilityGlossy,spread:i(r.spread),normalize:r.normalize}});return yA(t);function i(r){return GX(r)}}};zX.maxAreaLights=3;var HX=class _y{constructor(t,i){this.data=t,this.size=i}static async fromBlob(t){return new Promise((i,r)=>{let s=new Image,n=document.createElement("canvas"),a=n.getContext("2d",{willReadFrequently:!0});if(!a){r(new Error("Canvas 2D context not supported"));return}let o=URL.createObjectURL(t);s.src=o,s.onload=()=>{try{n.width=s.width,n.height=s.height,a.drawImage(s,0,0);let l=a.getImageData(0,0,n.width,n.height).data,h=new Float32Array(l.length);for(let c=0;c<l.length;c++)h[c]=l[c]/255;i(new _y(h,{width:n.width,height:n.height}))}catch(l){r(l)}finally{URL.revokeObjectURL(o)}},s.onerror=r})}binarize(){let t=this._calculateColorRatios(),{primary:i,secondary:r}=n(t),s=this._binarizationData(i,r);return new _y(s,this.size);function n(a){let o,l=-1,h,c=-1;for(let[d,f]of a.entries())f>l?(o=d,l=f):f>c&&(h=d,c=f);if(l<0||c<0)throw new Error("Insufficient color data for binarization");return{primary:o,secondary:h}}}_binarizationData(t,i){let{data:r}=this,s=new Float32Array(this.data.length);for(let a=0;a<r.length;a+=4){let o=rr.build(r[a],r[a+1],r[a+2],r[a+3]),l=n(o,t),h=n(o,i);s[a/4]=l>h?1:0}return s;function n(a,o){let l=a.r-o.r,h=a.g-o.g,c=a.b-o.b;return l*l+h*h+c*c}}_calculateColorRatios(){let{data:t,size:i}=this,r=new Map;for(let n=0;n<t.length;n+=4){let a=rr.build(t[n],t[n+1],t[n+2],t[n+3]),o=!1;for(let[l,h]of r.entries())if(l.equals(a)){o=!0,r.set(l,h+1);break}o||r.set(a,1)}let s=t.length/4;return FX(r,n=>n/s)}};var jX=class{constructor(e={width:2048,height:2048}){this.size=e}width(){return this.size.width}height(){return this.size.height}async toData(e,t){let{data:i,size:r}=await HX.fromBlob(t);if(this.width()!==r.width||this.height()!==r.height)throw new Error(`Invalid texture dimensions: expected ${this.size}, got ${r}`);switch(e){case 0:{let s=new Float32Array(i.length);for(let n=0;n<i.length;n+=4){let a=new xt(i[n]-.5,i[n+1]-.5,i[n+2]-.5).normalize();s[n]=a.x,s[n+1]=a.y,s[n+2]=a.z}return s}case 1:{let s=new Float32Array(i.length);for(let n=0;n<i.length;n+=4)s[n]=i[n],s[n+1]=i[n+1],s[n+2]=i[n+2];return s}case 2:{let s=new Float32Array(i.length);for(let n=0;n<i.length;n+=4)s[n]=i[n],s[n+1]=i[n+1],s[n+2]=i[n+2];return s}case 3:{let s=new Float32Array(i.length);for(let n=0;n<i.length;n+=4)s[n]=i[n],s[n+1]=i[n+1],s[n+2]=i[n+2];return s}default:throw new Error}}},dhe=new jX;var VX=class{static isPCB(e){return Math.abs(e.r-this.pcb.r)<.01&&Math.abs(e.g-this.pcb.g)<.01&&Math.abs(e.b-this.pcb.b)<.01}};VX.pcb=rr.build(0,.15,.36);var EA="struct O_a { O_b : vec3 < f32 > , O_c : vec3f , O_d : vec3f , O_e : f32 , O_f : f32 , O_g : f32 , } @ group ( 0 ) @ binding ( 0 ) var < storage , read > O_h : array < O_a > ; @ group ( 0 ) @ binding ( 1 ) var < storage , read_write > O_i : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 2 ) var < storage , read_write > O_j : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 3 ) var < storage , read_write > O_k : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 4 ) var < storage , read_write > O_l : array < f32 > ; @ group ( 0 ) @ binding ( 5 ) var < storage , read_write > O_m : array < f32 > ; override Width : u32 ; override Height : u32 ; @ compute @ workgroup_size ( 8 , 8 ) fn main ( @ builtin ( global_invocation_id ) O_n : vec3 < u32 > , ) { if ( O_n . x >= Width || O_n . y >= Height ) { return ; } let O_o = O_n . x + O_n . y * u32 ( Width ) ; let O_p = O_h [ O_o ] ; O_i [ O_o ] = O_p . O_b ; O_j [ O_o ] = O_p . O_c ; O_k [ O_o ] = O_p . O_d ; O_l [ O_o ] = O_p . O_f ; O_m [ O_o ] = O_p . O_g ; } ";vl.addShaderCode(EA);var YX=class{constructor(e,t,i){this.gpu=e,this.size=t,this.geometry=i,this.initializeBuffer(),this.initializePipeline(),this.initializeBindGroup()}getBuffers(){return this.buffers}run(){let e=this.gpu.device.createCommandEncoder(),t=e.beginComputePass();t.setPipeline(this.pipeline),t.setBindGroup(0,this.bindGroup),t.dispatchWorkgroups(Math.ceil(this.size.width/8),Math.ceil(this.size.height/8)),t.end(),this.gpu.submit(e)}async runAsync(){let e=performance.now();return this.run(),await this.gpu.device.queue.onSubmittedWorkDone(),performance.now()-e}initializeBuffer(){let e=this.size.width*this.size.height;this.buffers={geometry:this.geometry,hdrColor:this.gpu.createStorageDynamicBuffer(e*4,"hdrColor"),position:this.gpu.createStorageDynamicBuffer(e*4,"position"),normal:this.gpu.createStorageDynamicBuffer(e*4,"normal"),depth:this.gpu.createStorageDynamicBuffer(e,"depth"),type:this.gpu.createStorageDynamicBuffer(e,"type")}}initializeBindGroup(){this.bindGroup=this.gpu.createBindGroup("geometry buffer dismantle",this.pipeline.getBindGroupLayout(0),0,this.buffers.geometry,1,this.buffers.hdrColor,2,this.buffers.position,3,this.buffers.normal,4,this.buffers.depth,5,this.buffers.type)}initializePipeline(){this.pipeline=this.gpu.createComputePipeline(EA,"main","geometry buffer dismantle","auto",{Width:this.size.width,Height:this.size.height})}},wA="override Image_Width : u32 ; override Image_Height : u32 ; fn O_a ( O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_h : vec3 < f32 > , O_i : vec3 < f32 > , ) -> vec3 < f32 > { let O_j = normalize ( O_i ) ; let O_k = normalize ( O_h ) ; let O_l = max ( dot ( O_g , O_k ) , 0.0 ) ; let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; if ( O_l <= 0.0 || O_m <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } let O_n = O_o ( O_b , O_d , O_e , O_f ) ; let O_p = O_q ( O_n , O_m ) ; let O_r = ( 1.0 - O_p ) * ( 1.0 - O_d ) ; let O_s = O_b * O_r * O_t ; let O_u = O_v ( O_b , O_c , O_d , O_e , O_f , O_g , O_j , O_k ) ; return O_s + O_u ; } const O_w : f32 = 2e-10 ; fn O_x ( O_y : f32 , O_z : f32 , ) -> f32 { let O_aa = abs ( O_z ) ; if ( O_aa >= 1.0 - 1e-5 ) { return 0.0 ; } let O_ab = max ( O_aa , 1e-5 ) ; let O_ac = 1.0 / ( O_ab * O_ab ) ; let O_ad = max ( O_ac - 1.0 , 0.0 ) ; let O_ae = O_y * O_ad ; let O_af = sqrt ( 1.0 + O_ae ) ; return 0.5 * ( O_af - 1.0 ) ; } fn O_ag ( O_ah : f32 , O_c : f32 , ) -> f32 { let O_ai = O_c * O_c ; let O_y = O_ai * O_ai ; if ( O_y <= O_w ) { return 0.0 ; } let O_aj = clamp ( O_ah , - 1.0 , 1.0 ) ; let O_ak = min ( O_aj * O_aj , 1.0 ) ; let O_al = 1.0 - O_ak ; let O_am = O_al + O_y * O_ak ; let O_an = O_am * O_am ; return O_y / max ( O_ao * O_an , 1e-10 ) ; } fn O_ap ( O_m : f32 , O_l : f32 , O_c : f32 , ) -> f32 { let O_ai = O_c * O_c ; let O_y = O_ai * O_ai ; if ( O_y <= O_w ) { return 1.0 ; } let O_aq = O_x ( O_y , O_l ) ; let O_ar = O_x ( O_y , O_m ) ; let O_as = 1.0 + O_aq + O_ar ; return 1.0 / max ( O_as , 1e-7 ) ; } fn O_v ( O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_j : vec3 < f32 > , O_k : vec3 < f32 > , ) -> vec3 < f32 > { let O_at = O_j + O_k ; let O_au = length ( O_at ) ; if ( O_au < 1e-6 ) { return vec3 < f32 > ( 0.0 ) ; } let O_av = O_at / O_au ; let O_l = max ( dot ( O_g , O_k ) , 0.0 ) ; let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; let O_ah = dot ( O_g , O_av ) ; let O_aw = max ( dot ( O_j , O_av ) , 0.0 ) ; if ( O_l <= 0.0 || O_m <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } if ( O_ah <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } let O_n = O_o ( O_b , O_d , O_e , O_f ) ; let O_p = O_q ( O_n , O_aw ) ; let O_ax = O_ag ( O_ah , O_c ) ; if ( O_ax <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } let O_ay = O_ap ( O_m , O_l , O_c ) ; let O_ai = O_c * O_c ; let O_y = O_ai * O_ai ; let O_aq = O_x ( O_y , O_l ) ; let O_ar = O_x ( O_y , O_m ) ; let O_az = O_ax / max ( O_l , 1e-10 ) * 0.25 ; let O_ba = 1.0 + O_ar + O_aq ; let O_bb = O_p * O_az / max ( O_ba , 1e-10 ) ; return clamp ( O_bb , vec3 < f32 > ( 0.0 ) , vec3 < f32 > ( 1e4 ) ) ; } fn O_bc ( O_b : vec3f , O_bd : vec3f , O_be : vec3f , ) -> O_bf { var O_bg : O_bf ; var O_i : vec3f ; O_i = O_bh ( ) ; O_i = O_bi ( O_i , O_be ) ; if ( dot ( O_i , O_bd ) < 0.0 ) { return O_bg ; } O_bg . O_i = O_i ; O_bg . O_bj = O_b ; return O_bg ; } fn O_bh ( ) -> vec3f { let O_bk = O_bl ( ) ; let O_bm = O_bl ( ) ; let O_bn = sqrt ( O_bk ) ; let O_bo = 2.0 * O_ao * O_bm ; return vec3f ( cos ( O_bo ) * O_bn , sin ( O_bo ) * O_bn , sqrt ( 1.0 - O_bk ) ) ; } fn O_bi ( O_bp : vec3f , O_bq : vec3f , ) -> vec3f { var O_br : vec3f ; if ( abs ( O_bq . z ) > 0.999 ) { O_br = vec3f ( 1.0 , 0.0 , 0.0 ) ; } else { O_br = normalize ( cross ( vec3f ( 0.0 , 0.0 , 1.0 ) , O_bq ) ) ; } let O_bs = cross ( O_bq , O_br ) ; return O_bp . x * O_br + O_bp . y * O_bs + O_bp . z * O_bq ; } fn O_bt ( O_b : vec3 < f32 > , O_bu : vec3 < f32 > , O_h : vec3 < f32 > , ) -> vec3 < f32 > { return O_b * dot ( O_h , O_bu ) ; } fn O_bv ( O_bw : vec3f , O_b : vec3f , O_bx : vec3f , O_by : vec3f , O_c : f32 , ) -> O_bf { var O_bz : vec3f = O_bx ; if ( dot ( - O_bw , O_bz ) < 0.0 ) { O_bz = - O_bz ; } let O_bq = O_ca ( O_bz , O_c * O_c ) ; var O_cb = O_cc ( O_bw , O_bq ) ; if ( dot ( O_cb , O_by ) < 0.0 ) { O_cb = - O_cb ; } let O_cd = O_ce ( max ( dot ( - O_bw , O_bz ) , 0.0 ) , O_b ) ; return O_bf ( O_cb , O_cd ) ; } fn O_ca ( O_bu : vec3 < f32 > , O_c : f32 , ) -> vec3 < f32 > { var O_cf : f32 = O_cg ( O_c ) ; return O_ch ( O_bu , O_cf ) ; } fn O_cg ( O_bn : f32 , ) -> f32 { if ( O_bn > 0.99999 ) { return O_bl ( ) ; } if ( O_bn < 0.00001 ) { return 1.0 ; } let O_ci = O_bn * O_bn ; let O_cj = O_ck ( O_ci , 1.0 ) ; return sqrt ( ( 1.0 - sqrt ( O_ci / O_cj ) ) / ( 1.0 - O_bn ) ) ; } fn O_ch ( O_cl : vec3 < f32 > , O_cf : f32 , ) -> vec3 < f32 > { let O_bu = normalize ( O_cl ) ; if ( O_cf == 1.0 ) { return O_bu ; } var O_cm : vec3 < f32 > ; if abs ( O_bu . x ) < 0.9 { O_cm = cross ( O_bu , vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ) ; } else { O_cm = cross ( O_bu , vec3 < f32 > ( 0.0 , 1.0 , 0.0 ) ) ; } O_cm = normalize ( O_cm ) ; let O_cn = cross ( O_bu , O_cm ) ; let O_co = O_cp ( ) ; let O_bn = O_cf * O_bu + sqrt ( 1.0 - O_cf * O_cf ) * ( cos ( O_co ) * O_cm + sin ( O_co ) * O_cn ) ; return normalize ( O_bn ) ; } const O_ao : f32 = 3.14159265359 ; const O_cq : f32 = 2.718281828459045 ; const O_cr : f32 = O_ao * 2.0 ; const O_cs : f32 = 1.5707963267948966 ; const O_ct : f32 = 0.7853981633974830 ; const O_t : f32 = 0.3183098861837907 ; const O_cu : f32 = 1e-7 ; const O_cv : f32 = 3.402823466e+38 ; const O_cw : u32 = 10 ; const O_cx : bool = true ; const O_cy : f32 = 1.4426950408889634 ; const O_cz : bool = true ; const O_da : u32 = 0 ; const O_db : u32 = 1 ; const O_dc : u32 = 2 ; const O_dd : u32 = 3 ; const O_de : u32 = 0 ; const O_df : u32 = 1 ; const O_dg : u32 = 2 ; const O_dh : u32 = 3 ; const O_di : u32 = 4 ; const O_dj : u32 = 5 ; const O_dk : u32 = 6 ; const O_dl : u32 = 7 ; const O_dm : u32 = 8 ; const O_dn : u32 = 9 ; const O_do : u32 = 10 ; const O_dp : u32 = 11 ; const O_dq : u32 = 12 ; const O_dr : u32 = 13 ; const O_ds : u32 = 14 ; const O_dt : u32 = 15 ; const O_du : u32 = 16 ; const O_dv : u32 = 17 ; const O_dw : u32 = 18 ; const O_dx : u32 = 19 ; const O_dy : u32 = 20 ; const O_dz : u32 = 20 ; const O_ea = 30 ; const O_eb : i32 = 1 ; const O_ec : i32 = 2 ; const O_ed : i32 = 3 ; const O_ee : i32 = 4 ; const O_ef : i32 = 5 ; const O_eg = 6 ; const O_eh : i32 = 3 ; const O_ei : u32 = 0 ; const O_ej : u32 = 1 ; const O_ek : u32 = 2 ; const O_el : u32 = 3 ; const O_em : u32 = 4 ; const O_en = 0 ; const O_eo = 1 ; const O_ep = 2 ; const O_eq = 3 ; const O_er : u32 = 0u ; const O_es : u32 = 1u ; @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_et : array < O_eu > ; @ group ( 0 ) @ binding ( 1 ) var < uniform > O_ev : O_ew ; @ group ( 0 ) @ binding ( 2 ) var < uniform > O_ex : O_ey ; @ group ( 0 ) @ binding ( 3 ) var < uniform > O_ez : O_fa ; @ group ( 0 ) @ binding ( 4 ) var < uniform > O_fb : O_fc ; @ group ( 0 ) @ binding ( 5 ) var < uniform > O_fd : O_fe ; @ group ( 0 ) @ binding ( 6 ) var O_ff : texture_2d < f32 > ; @ group ( 0 ) @ binding ( 7 ) var < uniform > O_fg : array < O_fh , 3 > ; @ group ( 1 ) @ binding ( 0 ) var O_fi : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 1 ) var O_fj : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 2 ) var O_fk : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 3 ) var O_fl : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 4 ) var O_fm : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 5 ) var O_fn : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 6 ) var O_fo : texture_2d < f32 > ; @ group ( 1 ) @ binding ( 7 ) var < storage , read > O_fp : array < O_fq > ; @ group ( 2 ) @ binding ( 0 ) var < storage , read > O_fr : array < O_fs > ; @ group ( 2 ) @ binding ( 1 ) var < storage , read > O_ft : array < f32 > ; @ group ( 2 ) @ binding ( 2 ) var < storage , read > O_fu : array < O_fv > ; @ group ( 2 ) @ binding ( 3 ) var < storage , read > O_fw : array < vec3 < f32 > > ; @ group ( 2 ) @ binding ( 4 ) var < storage , read > O_fx : array < O_fy > ; @ group ( 2 ) @ binding ( 5 ) var < storage , read > O_fz : array < f32 > ; @ group ( 2 ) @ binding ( 6 ) var < storage , read_write > O_ga : array < f32 , 3 > ; @ group ( 2 ) @ binding ( 7 ) var < uniform > O_gb : O_gc ; @ group ( 2 ) @ binding ( 8 ) var < uniform > O_gd : O_ge ; @ group ( 3 ) @ binding ( 0 ) var O_gf : texture_2d < f32 > ; @ group ( 3 ) @ binding ( 1 ) var < storage , read_write > O_gg : array < vec2 < f32 > > ; var < private > O_gh : vec2 < u32 > ; var < private > O_gi : u32 ; var < private > O_gj : f32 ; var < private > O_gk : bool = false ; var < private > O_gl : u32 = 0 ; fn O_gm ( O_gn : vec3 < u32 > , ) { O_go ( O_gn ) ; O_gp ( ) ; } fn O_go ( O_gn : vec3 < u32 > , ) { let O_gq = u32 ( O_ev . O_gr ) + O_gn . x ; let O_gs = O_gg [ O_gq ] ; O_gh = vec2 < u32 > ( u32 ( O_gs . x ) , u32 ( O_gs . y ) ) ; O_gi = O_gh . x + O_gh . y * Image_Width ; } @ compute @ workgroup_size ( 64 ) fn main ( @ builtin ( global_invocation_id ) O_gn : vec3 < u32 > , ) { let O_gq = u32 ( O_ev . O_gr ) + O_gn . x ; if ( O_gq >= Image_Width * Image_Height ) { return ; } O_gm ( O_gn ) ; if ( O_gh . x >= Image_Width || O_gh . y >= Image_Height ) { return ; } let O_gt = O_gu ( ) ; let O_gv = O_gw ( O_gt ) ; O_gx ( O_gv , O_gt ) ; } @ compute @ workgroup_size ( 1 , 1 ) fn main_hit ( @ builtin ( global_invocation_id ) O_gn : vec3 < u32 > , ) { O_gm ( O_gn ) ; if ( O_gh . x >= Image_Width || O_gh . y >= Image_Height ) { return ; } let O_gt = O_fs ( O_ex . O_gy , normalize ( O_ex . O_gz ) ) ; let O_ha = O_hb ( O_gt , true , false , false ) ; O_ga [ 0 ] = f32 ( O_ha . O_hc ) ; O_ga [ 1 ] = O_ha . O_hd ; O_ga [ 2 ] = f32 ( O_ha . O_he ) ; } @ compute @ workgroup_size ( 8 , 8 ) fn main_demo ( @ builtin ( global_invocation_id ) O_gn : vec3 < u32 > , ) { if ( O_gn . x >= Image_Width || O_gn . y >= Image_Height ) { return ; } O_gi = O_gn . x + O_gn . y * Image_Width ; O_bl ( ) ; O_bl ( ) ; let O_gt = O_gu ( ) ; let O_ha = O_hb ( O_gt , true , false , false ) ; if ( O_ha . O_hc >= 0 ) { O_hf ( O_fp [ O_ha . O_hc ] . O_b ) ; } } fn O_o ( O_b : vec3f , O_d : f32 , O_e : f32 , O_hg : f32 , ) -> vec3f { if ( O_d >= 1.0 ) { return O_b ; } var O_hh = max ( O_e , 1e-5 ) ; var O_hi = O_hj ( O_hh ) ; if ( abs ( O_hg - 0.5 ) > 1e-5 ) { O_hi *= 2.0 * max ( O_hg , 0.0 ) ; O_hh = O_hk ( O_hi ) ; if ( O_e < 1.0 ) { O_hh = 1.0 / O_hh ; } } let O_hl = vec3f ( O_hi ) ; return mix ( O_hl , O_b , O_d ) ; } fn O_hj ( O_e : f32 , ) -> f32 { let O_hh = max ( O_e , 1e-5 ) ; let O_hm = ( O_hh - 1.0 ) / ( O_hh + 1.0 ) ; return O_hm * O_hm ; } fn O_hk ( O_hi : f32 , ) -> f32 { let O_hn = sqrt ( clamp ( O_hi , 0.0 , 0.99 ) ) ; return ( 1.0 + O_hn ) / ( 1.0 - O_hn ) ; } fn O_q ( O_n : vec3 < f32 > , O_ho : f32 , ) -> vec3 < f32 > { return O_n + ( vec3 < f32 > ( 1.0 ) - O_n ) * pow ( 1.0 - O_ho , 5.0 ) ; } fn O_ce ( O_hp : f32 , O_n : vec3 < f32 > , ) -> vec3 < f32 > { return O_n + ( vec3 < f32 > ( 1.0 ) - O_n ) * pow ( 1.0 - O_hp , 5.0 ) ; } fn O_hq ( O_bn : f32 , O_bo : f32 , ) -> vec2 < f32 > { return vec2 < f32 > ( O_bn * cos ( O_bo ) , O_bn * sin ( O_bo ) ) ; } fn O_hr ( O_hs : vec2 < f32 > , ) -> vec2 < f32 > { let O_ht = 2.0 * O_hs . x - 1.0 ; let O_hu = 2.0 * O_hs . y - 1.0 ; if ( O_ht == 0.0 && O_hu == 0.0 ) { return vec2 < f32 > ( 0.0 ) ; } var O_bn : f32 ; var O_bo : f32 ; if ( O_ht * O_ht > O_hu * O_hu ) { O_bn = O_ht ; O_bo = O_ct * ( O_hu / O_ht ) ; } else { O_bn = O_hu ; O_bo = O_cs - O_ct * ( O_ht / O_hu ) ; } return O_hq ( O_bn , O_bo ) ; } fn O_hv ( O_hw : vec3 < f32 > , O_hx : vec3 < f32 > , O_hs : vec2 < f32 > , ) -> vec3 < f32 > { return O_hw * ( 2.0 * O_hs . x - 1.0 ) + O_hx * ( 2.0 * O_hs . y - 1.0 ) ; } fn O_hy ( O_hw : vec3 < f32 > , O_hx : vec3 < f32 > , O_hs : vec2 < f32 > , ) -> vec3 < f32 > { let O_hz = O_hr ( O_hs ) ; return O_hw * O_hz . x + O_hx * O_hz . y ; } fn O_ia ( O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , ) -> f32 { let O_ib = cross ( O_ht , O_hu ) ; let O_ic = dot ( O_ht , O_hu ) ; return O_id ( O_ib ) / O_ic ; } fn O_ie ( O_if : vec3 < f32 > , O_ig : vec3 < f32 > , O_co : f32 , ) -> vec3 < f32 > { let O_ih = cos ( O_co ) ; let O_ii = sin ( O_co ) ; let O_ij = 1.0 - O_ih ; return vec3 < f32 > ( ( O_ih + O_ij * O_ig . x * O_ig . x ) * O_if . x + ( O_ij * O_ig . x * O_ig . y - O_ig . z * O_ii ) * O_if . y + ( O_ij * O_ig . x * O_ig . z + O_ig . y * O_ii ) * O_if . z , ( O_ij * O_ig . x * O_ig . y + O_ig . z * O_ii ) * O_if . x + ( O_ih + O_ij * O_ig . y * O_ig . y ) * O_if . y + ( O_ij * O_ig . y * O_ig . z - O_ig . x * O_ii ) * O_if . z , ( O_ij * O_ig . x * O_ig . z - O_ig . y * O_ii ) * O_if . x + ( O_ij * O_ig . y * O_ig . z + O_ig . x * O_ii ) * O_if . y + ( O_ih + O_ij * O_ig . z * O_ig . z ) * O_if . z ) ; } fn O_ik ( radians : f32 , ) -> f32 { return radians * 180.0 / O_ao ; } fn O_il ( O_im : f32 , ) -> f32 { return O_im * O_ao / 180.0 ; } fn O_id ( O_cm : vec3 < f32 > , ) -> f32 { return length ( O_cm ) ; } fn O_in ( O_cm : vec3 < f32 > , ) -> f32 { return dot ( O_cm , O_cm ) ; } fn O_io ( O_cm : vec2 < f32 > , ) -> f32 { return dot ( O_cm , O_cm ) ; } fn O_ip ( O_cj : f32 , ) -> f32 { return O_cj * O_cj ; } fn O_iq ( O_cm : vec3 < f32 > , ) -> vec3 < f32 > { return O_cm * O_cm ; } fn O_ir ( O_cm : vec4 < f32 > , ) -> vec4 < f32 > { return O_cm * O_cm ; } fn O_is ( O_cm : vec3 < f32 > , ) -> f32 { return min ( min ( O_cm . x , O_cm . y ) , O_cm . z ) ; } fn O_it ( O_cm : vec4 < f32 > , ) -> f32 { return min ( min ( min ( O_cm . x , O_cm . y ) , O_cm . z ) , O_cm . w ) ; } fn O_iu ( O_cj : f32 , ) -> f32 { return select ( 0.0 , sqrt ( O_cj ) , O_cj > 0.0 ) ; } fn O_iv ( O_cm : vec3 < f32 > , ) -> vec3 < f32 > { let O_iw = O_id ( O_cm ) ; return select ( O_cm , O_cm / O_iw , O_iw > O_cu ) ; } fn O_ix ( O_cm : vec3 < f32 > , ) -> vec4 < f32 > { let O_iw = O_id ( O_cm ) ; let O_iy = select ( O_cm , O_cm / O_iw , O_iw > O_cu ) ; return vec4 < f32 > ( O_iy , O_iw ) ; } fn O_iz ( O_cj : f32 , ) -> f32 { return asin ( clamp ( O_cj , - 1.0 , 1.0 ) ) ; } fn O_ja ( O_ht : f32 , O_hu : f32 , ) -> f32 { return select ( 0.0 , O_ht / O_hu , abs ( O_hu ) > O_cu ) ; } fn O_jb ( O_ht : vec3 < f32 > , O_hu : f32 , ) -> vec3 < f32 > { return select ( vec3 < f32 > ( 0.0 ) , O_ht / O_hu , abs ( O_hu ) > O_cu ) ; } fn O_jc ( O_cj : f32 , O_jd : f32 , ) -> f32 { let O_je = select ( 1.0 , - 1.0 , O_jd < 0.0 ) ; return abs ( O_cj ) * O_je ; } fn O_jf ( O_if : vec2 < f32 > , ) -> vec3 < f32 > { let O_jg = dot ( O_if , O_if ) ; return vec3 < f32 > ( O_if . x , O_if . y , O_iu ( 1.0 - O_jg ) ) ; } fn O_jh ( O_if : vec3 < f32 > , O_ji : vec3 < f32 > , O_jj : vec3 < f32 > , O_jk : vec3 < f32 > , ) -> vec3 < f32 > { return O_if . x * O_ji + O_if . y * O_jj + O_if . z * O_jk ; } fn O_jl ( O_cj : f32 , ) -> f32 { return O_cj * O_cj ; } fn O_jm ( O_cj : f32 , ) -> f32 { return 1.0 / sqrt ( max ( O_cj , 1e-10 ) ) ; } fn O_jn ( O_cm : vec3 < f32 > , ) -> f32 { return ( O_cm . x + O_cm . y + O_cm . z ) / 3.0 ; } struct O_jo { O_jp : f32 , O_jq : f32 , O_jr : f32 , O_js : f32 , O_jt : f32 , O_ju : f32 , } fn O_jv ( O_jw : vec3 < f32 > , O_jx : O_jo , ) -> bool { return ( O_jw . x >= O_jx . O_jp && O_jw . x <= O_jx . O_js ) && ( O_jw . y >= O_jx . O_jq && O_jw . y <= O_jx . O_jt ) && ( O_jw . z >= O_jx . O_jr && O_jw . z <= O_jx . O_ju ) ; } fn O_jy ( O_jx : O_jo , ) -> vec3 < f32 > { let O_if = vec3 < f32 > ( O_jx . O_jp + O_jx . O_js , O_jx . O_jq + O_jx . O_jt , O_jx . O_jr + O_jx . O_ju ) ; return O_if / vec3 < f32 > ( 2.0 ) ; } fn O_jz ( O_gy : vec3 < f32 > , O_ka : f32 , ) -> O_jo { let O_kb = O_ka / 2.0 ; return O_jo ( O_gy . x - O_kb , O_gy . y - O_kb , O_gy . z - O_kb , O_gy . x + O_kb , O_gy . y + O_kb , O_gy . z + O_kb , ) ; } fn O_kc ( O_kd : O_jo , O_jw : vec3 < f32 > , ) -> vec3 < f32 > { let O_ke : f32 = 1e-5 ; if abs ( O_jw . x - O_kd . O_jp ) < O_ke { return vec3 < f32 > ( - 1.0 , 0.0 , 0.0 ) ; } if abs ( O_jw . x - O_kd . O_js ) < O_ke { return vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ; } if abs ( O_jw . y - O_kd . O_jq ) < O_ke { return vec3 < f32 > ( 0.0 , - 1.0 , 0.0 ) ; } if abs ( O_jw . y - O_kd . O_jt ) < O_ke { return vec3 < f32 > ( 0.0 , 1.0 , 0.0 ) ; } if abs ( O_jw . z - O_kd . O_jr ) < O_ke { return vec3 < f32 > ( 0.0 , 0.0 , - 1.0 ) ; } if abs ( O_jw . z - O_kd . O_ju ) < O_ke { return vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ; } return vec3 < f32 > ( 0.0 , 0.0 , 0.0 ) ; } struct O_kf { O_jp : f32 , O_js : f32 , O_jq : f32 , O_jt : f32 , } fn O_kg ( O_kd : O_kf , O_kh : f32 , ) -> O_kf { return O_kf ( ( O_kd . O_jp + O_kh ) , ( O_kd . O_js - O_kh ) , ( O_kd . O_jq + O_kh ) , ( O_kd . O_jt - O_kh ) ) ; } fn O_ki ( O_kd : O_kf , O_jw : vec2 < f32 > , ) -> bool { let O_kj = O_jw . x >= O_kd . O_jp && O_jw . x <= O_kd . O_js ; let O_kk = O_jw . y >= O_kd . O_jq && O_jw . y <= O_kd . O_jt ; return O_kj && O_kk ; } fn O_kl ( O_km : O_kf , O_kn : O_kf , ) -> bool { let O_ko = O_km . O_jp <= O_kn . O_js && O_km . O_js >= O_kn . O_jp ; let O_kp = O_km . O_jq <= O_kn . O_jt && O_km . O_jt >= O_kn . O_jq ; return O_ko && O_kp ; } struct O_ey { O_gy : vec3 < f32 > , O_kq : vec3 < f32 > , O_kr : vec3 < f32 > , O_ks : vec3 < f32 > , O_gz : vec3 < f32 > , O_kt : f32 , O_ku : f32 , O_kv : f32 , O_kw : f32 , O_kx : vec3 < f32 > , } struct O_fv { O_ky : f32 , O_kz : f32 , O_la : f32 , O_lb : f32 , O_lc : f32 , O_ld : f32 , O_le : f32 , } struct O_eu { O_bb : vec3f , O_gy : vec3f , O_bq : vec3f , O_lf : f32 , O_lg : f32 , O_lh : f32 , } struct O_li { O_hd : f32 , O_bq : vec3 < f32 > , O_lf : O_fq , O_hc : i32 , } fn O_lj ( ) -> O_li { return O_li ( - 1 , O_lk ( ) , O_ll ( ) , - 1 ) ; } struct O_fy { O_jp : f32 , O_js : f32 , O_jq : f32 , O_jt : f32 , O_lm : f32 , O_ln : f32 , } struct O_lo { O_jp : f32 , O_jq : f32 , O_jr : f32 , O_js : f32 , O_jt : f32 , O_ju : f32 , O_lm : f32 , O_ln : f32 , } struct O_fq { O_b : vec3 < f32 > , O_d : f32 , O_c : f32 , O_e : f32 , O_hg : f32 , O_lp : f32 , O_lq : f32 , O_lr : f32 , O_ls : f32 , O_lt : vec3 < f32 > , O_lu : f32 , O_lv : f32 , O_lw : f32 , O_lx : f32 , O_ly : f32 , O_lz : f32 , O_ma : f32 , O_mb : f32 , O_mc : f32 , } fn O_ll ( ) -> O_fq { return O_fq ( vec3f ( 0 ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , vec3f ( 0 ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ; } fn O_md ( O_bn : f32 , O_me : f32 , O_hu : f32 , ) -> O_fq { return O_fq ( vec3f ( O_bn , O_me , O_hu ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , vec3f ( 0 ) , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ; } struct O_mf { O_mg : vec3f , O_mh : vec3f , O_mi : vec3f , } struct O_mj { O_hd : u32 , O_mk : O_mf , } fn O_ml ( O_mk : O_mf , ) -> vec3f { return cross ( O_mk . O_mh , O_mk . O_mi ) ; } fn O_mm ( O_jw : vec3f , O_mk : O_mf , O_ke : f32 , ) -> bool { let O_bq = O_ml ( O_mk ) ; let O_mn = dot ( O_bq , O_jw - O_mk . O_mg ) ; return abs ( O_mn ) <= O_ke ; } fn O_mo ( O_mp : O_mf , O_mq : O_mf , O_ke : f32 , ) -> bool { let O_lc = O_ml ( O_mp ) ; let O_ld = O_ml ( O_mq ) ; let O_mr = length ( O_lc ) ; let O_ms = length ( O_ld ) ; if ( O_mr < O_ke || O_ms < O_ke ) { return false ; } let O_mt = normalize ( O_lc ) ; let O_mu = normalize ( O_ld ) ; let O_mv = dot ( O_mt , O_mu ) ; if ( abs ( O_mv ) < 1.0 - O_ke ) { return false ; } return O_mm ( O_mq . O_mg , O_mp , O_ke ) ; } fn O_mw ( O_mp : O_mf , O_mq : O_mf , ) -> O_mf { let O_mx = O_mp . O_mg ; let O_my = O_mp . O_mg + O_mp . O_mh ; let O_mz = O_mp . O_mg + O_mp . O_mi ; let O_na = O_mp . O_mg + O_mp . O_mh + O_mp . O_mi ; let O_nb = O_mq . O_mg ; let O_nc = O_mq . O_mg + O_mq . O_mh ; let O_nd = O_mq . O_mg + O_mq . O_mi ; let O_ne = O_mq . O_mg + O_mq . O_mh + O_mq . O_mi ; let O_ml = normalize ( O_ml ( O_mp ) ) ; var O_nf = vec3f ( 1.0 , 0.0 , 0.0 ) ; if ( abs ( dot ( O_ml , O_nf ) ) > 0.9 ) { O_nf = vec3f ( 0.0 , 1.0 , 0.0 ) ; } let O_ng = normalize ( cross ( O_ml , O_nf ) ) ; let O_nh = cross ( O_ml , O_ng ) ; let O_ni = array < vec2f , 4 > ( O_nj ( O_mx , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_my , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_mz , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_na , O_mp . O_mg , O_ng , O_nh ) ) ; let O_nk = array < vec2f , 4 > ( O_nj ( O_nb , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_nc , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_nd , O_mp . O_mg , O_ng , O_nh ) , O_nj ( O_ne , O_mp . O_mg , O_ng , O_nh ) ) ; let O_nl = O_nm ( O_ni ) ; let O_nn = O_nm ( O_nk ) ; let O_no = max ( O_nl . x , O_nn . x ) ; let O_np = max ( O_nl . y , O_nn . y ) ; let O_nq = min ( O_nl . z , O_nn . z ) ; let O_nr = min ( O_nl . w , O_nn . w ) ; if ( O_no >= O_nq || O_np >= O_nr ) { return O_mf ( O_mp . O_mg , vec3f ( 0.0 ) , vec3f ( 0.0 ) ) ; } let O_ns = vec2f ( O_no , O_np ) ; let O_nt = vec2f ( O_nq - O_no , O_nr - O_np ) ; let O_nu = O_mp . O_mg + O_ns . x * O_ng + O_ns . y * O_nh ; let O_nv = O_nt . x * O_ng ; let O_nw = O_nt . y * O_nh ; return O_mf ( O_nu , O_nv , O_nw ) ; } fn O_nx ( O_mp : O_mf , O_mq : O_mf , O_ke : f32 , ) -> O_mj { if ( ! O_mo ( O_mp , O_mq , O_ke ) ) { return O_mj ( O_er , O_mp ) ; } let O_ny = O_mw ( O_mp , O_mq ) ; return O_mj ( O_es , O_ny ) ; } fn O_nj ( O_jw : vec3f , O_nz : vec3f , O_ng : vec3f , O_nh : vec3f , ) -> vec2f { let O_oa = O_jw - O_nz ; return vec2f ( dot ( O_oa , O_ng ) , dot ( O_oa , O_nh ) ) ; } fn O_nm ( O_ob : array < vec2f , 4 > , ) -> vec4f { var O_oc = O_ob [ 0 ] ; var O_od = O_ob [ 0 ] ; for ( var O_oe = 1 ; O_oe < 4 ; O_oe ++ ) { O_oc = min ( O_oc , O_ob [ O_oe ] ) ; O_od = max ( O_od , O_ob [ O_oe ] ) ; } return vec4f ( O_oc . x , O_oc . y , O_od . x , O_od . y ) ; } struct O_of { O_gj : f32 , O_og : f32 , O_oh : f32 , O_oi : f32 , O_oj : f32 , O_ok : f32 , O_ol : f32 , O_om : f32 , O_on : f32 , O_oo : f32 , O_op : f32 , O_oq : f32 , } struct O_ew { O_gj : f32 , O_gr : f32 , O_oi : f32 , O_oj : f32 , O_ok : f32 , O_ol : f32 , O_om : f32 , O_on : f32 , O_oo : f32 , O_op : f32 , O_oq : f32 , O_or : f32 , O_os : vec3f , O_ot : f32 , O_ou : f32 , } struct O_gc { O_ov : O_ow , O_ox : O_ow , } struct O_ow { O_jw : vec3 < f32 > , O_bq : vec3 < f32 > , } struct O_fs { O_nz : vec3 < f32 > , O_oy : vec3 < f32 > , } fn O_oz ( ) -> O_fs { return O_fs ( vec3 < f32 > ( 0 ) , vec3 < f32 > ( 0 ) ) ; } fn O_pa ( O_gt : O_fs , O_hd : f32 , ) -> vec3 < f32 > { return O_gt . O_nz + O_hd * O_gt . O_oy ; } struct O_pb { O_hd : f32 , O_bq : vec3 < f32 > , } fn O_pc ( O_gt : O_fs , O_kd : O_jo , ) -> O_pb { let O_pd = vec3 < f32 > ( O_kd . O_jp , O_kd . O_jq , O_kd . O_jr ) ; let O_pe = vec3 < f32 > ( O_kd . O_js , O_kd . O_jt , O_kd . O_ju ) ; let O_pf = 1.0 / O_gt . O_oy ; let sign = vec3 < u32 > ( u32 ( O_pf . x < 0.0 ) , u32 ( O_pf . y < 0.0 ) , u32 ( O_pf . z < 0.0 ) ) ; var O_pg = array < vec3 < f32 > , 2 > ( O_pd , O_pe ) ; var O_ph = ( O_pg [ sign . x ] . x - O_gt . O_nz . x ) * O_pf . x ; var O_pi = ( O_pg [ 1 - sign . x ] . x - O_gt . O_nz . x ) * O_pf . x ; var O_pj = ( O_pg [ sign . y ] . y - O_gt . O_nz . y ) * O_pf . y ; var O_pk = ( O_pg [ 1 - sign . y ] . y - O_gt . O_nz . y ) * O_pf . y ; if ( O_ph > O_pk ) || ( O_pj > O_pi ) { return O_pb ( - 1.0 , vec3 < f32 > ( 0.0 ) ) ; } O_ph = max ( O_ph , O_pj ) ; O_pi = min ( O_pi , O_pk ) ; let O_pl = ( O_pg [ sign . z ] . z - O_gt . O_nz . z ) * O_pf . z ; let O_pm = ( O_pg [ 1 - sign . z ] . z - O_gt . O_nz . z ) * O_pf . z ; if ( O_ph > O_pm ) || ( O_pl > O_pi ) { return O_pb ( - 1.0 , vec3 < f32 > ( 0.0 ) ) ; } O_ph = max ( O_ph , O_pl ) ; O_pi = min ( O_pi , O_pm ) ; if ( O_ph < 0.0 ) { return O_pb ( - 1.0 , vec3 < f32 > ( 0.0 ) ) ; } var O_bq = vec3 < f32 > ( 0.0 ) ; let O_jw = O_gt . O_nz + O_ph * O_gt . O_oy ; let O_pn = 0.001 ; if ( abs ( O_jw . x - O_pd . x ) < O_pn ) { O_bq = vec3 < f32 > ( - 1.0 , 0.0 , 0.0 ) ; } else if ( abs ( O_jw . x - O_pe . x ) < O_pn ) { O_bq = vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ; } else if ( abs ( O_jw . y - O_pd . y ) < O_pn ) { O_bq = vec3 < f32 > ( 0.0 , - 1.0 , 0.0 ) ; } else if ( abs ( O_jw . y - O_pe . y ) < O_pn ) { O_bq = vec3 < f32 > ( 0.0 , 1.0 , 0.0 ) ; } else if ( abs ( O_jw . z - O_pd . z ) < O_pn ) { O_bq = vec3 < f32 > ( 0.0 , 0.0 , - 1.0 ) ; } else if ( abs ( O_jw . z - O_pe . z ) < O_pn ) { O_bq = vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ; } return O_pb ( O_ph , O_bq ) ; } fn O_cc ( O_po : vec3 < f32 > , O_bq : vec3 < f32 > , ) -> vec3 < f32 > { let O_pp = dot ( O_po , O_bq ) ; return normalize ( O_po - 2.0 * O_pp * O_bq ) ; } fn O_pq ( O_gt : O_fs , O_jx : O_jo , ) -> f32 { if O_jv ( O_gt . O_nz , O_jx ) { return 0.0 ; } var O_pr : f32 = ( O_jx . O_jp - O_gt . O_nz . x ) / O_gt . O_oy . x ; var O_ps : f32 = ( O_jx . O_js - O_gt . O_nz . x ) / O_gt . O_oy . x ; if O_pr > O_ps { let O_pt = O_pr ; O_pr = O_ps ; O_ps = O_pt ; } var O_pu : f32 = ( O_jx . O_jq - O_gt . O_nz . y ) / O_gt . O_oy . y ; var O_pv : f32 = ( O_jx . O_jt - O_gt . O_nz . y ) / O_gt . O_oy . y ; if O_pu > O_pv { let O_pt = O_pu ; O_pu = O_pv ; O_pv = O_pt ; } if ( O_pr > O_pv ) || ( O_pu > O_ps ) { return - 1.0 ; } if O_pu > O_pr { O_pr = O_pu ; } if O_pv < O_ps { O_ps = O_pv ; } var O_pw : f32 = ( O_jx . O_jr - O_gt . O_nz . z ) / O_gt . O_oy . z ; var O_px : f32 = ( O_jx . O_ju - O_gt . O_nz . z ) / O_gt . O_oy . z ; if O_pw > O_px { let O_pt = O_pw ; O_pw = O_px ; O_px = O_pt ; } if ( O_pr > O_px ) || ( O_pw > O_ps ) { return - 1.0 ; } if O_pw > O_pr { O_pr = O_pw ; } if O_px < O_ps { O_ps = O_px ; } if O_pr < 0.0 { if O_ps < 0.0 { return - 1.0 ; } return O_ps ; } return O_pr ; } fn O_py ( O_gt : O_fs , O_pz : vec3 < f32 > , O_mx : vec3 < f32 > , O_my : vec3 < f32 > , O_mz : vec3 < f32 > , ) -> bool { let O_qa = O_qb ( O_pz , O_mx , O_my ) ; let O_qc = O_qb ( O_mx , O_my , O_mz ) ; return O_qd ( O_gt , O_qa ) > 0.0 || O_qd ( O_gt , O_qc ) > 0.0 ; } fn O_qd ( O_gt : O_fs , O_qe : O_qb , ) -> f32 { let O_ke = 0.00000001 ; let O_qf = O_qe . O_kz - O_qe . O_ky ; let O_qg = O_qe . O_la - O_qe . O_ky ; let O_qh = cross ( O_gt . O_oy , O_qg ) ; let O_ht = dot ( O_qf , O_qh ) ; if O_ht > - O_ke && O_ht < O_ke { return - 1.0 ; } let O_qi = 1.0 / O_ht ; let O_qj = O_gt . O_nz - O_qe . O_ky ; let O_cn = O_qi * dot ( O_qj , O_qh ) ; if O_cn < 0.0 || O_cn > 1.0 { return - 1.0 ; } let O_qk = cross ( O_qj , O_qf ) ; let O_cm = O_qi * dot ( O_gt . O_oy , O_qk ) ; if O_cm < 0.0 || O_cn + O_cm > 1.0 { return - 1.0 ; } let O_hd = O_qi * dot ( O_qg , O_qk ) ; if O_hd > O_ke { return O_hd ; } else { return - 1.0 ; } } fn O_ql ( O_gt : O_fs , O_qm : O_qn , ) -> f32 { let O_qo = O_gt . O_nz - O_qm . O_qp ; let O_ht = dot ( O_gt . O_oy , O_gt . O_oy ) ; let O_hu = 2.0 * dot ( O_qo , O_gt . O_oy ) ; let O_qq = dot ( O_qo , O_qo ) - O_qm . O_qr * O_qm . O_qr ; let O_qs = O_hu * O_hu - 4.0 * O_ht * O_qq ; if O_qs < 0.0 { return - 1.0 ; } else { return ( - O_hu - sqrt ( O_qs ) ) / ( 2.0 * O_ht ) ; } } struct O_qt { O_hd : bool , O_jw : vec3 < f32 > , } fn O_qu ( O_gt : O_fs , O_qv : O_ow , ) -> O_qt { let O_hd = O_qw ( O_gt , O_qv ) ; if O_hd < 0.0 { return O_qt ( false , vec3 < f32 > ( 0 ) ) ; } let O_qx = O_gt . O_nz + O_hd * O_gt . O_oy ; return O_qt ( true , O_qx ) ; } struct O_qy { O_hd : f32 , O_jw : vec3 < f32 > , } fn O_qz ( O_gt : O_fs , O_qv : O_ow , ) -> O_qy { let O_hd = O_qw ( O_gt , O_qv ) ; if O_hd < 0.0 { return O_qy ( - 1 , vec3 < f32 > ( 0 ) ) ; } let O_qx = O_gt . O_nz + O_hd * O_gt . O_oy ; return O_qy ( O_hd , O_qx ) ; } fn O_qw ( O_gt : O_fs , O_qv : O_ow , ) -> f32 { let O_jw = O_qv . O_jw ; let O_bq = O_qv . O_bq ; let O_am = dot ( O_gt . O_oy , O_bq ) ; if ( O_ra ( O_gt . O_oy , O_qv . O_bq ) ) { return - 1.0 ; } let O_rb = O_jw - O_gt . O_nz ; let O_hd = dot ( O_rb , O_bq ) / O_am ; return O_hd ; } struct O_rc { O_rd : vec3 < f32 > , O_re : vec3 < f32 > , } fn O_rf ( O_rg : O_rc , O_kd : O_jo , ) -> bool { var O_ph : f32 = 0.0 ; var O_pi : f32 = 1.0 ; let O_iy : vec3 < f32 > = O_rg . O_re - O_rg . O_rd ; for ( var O_oe : i32 = 0 ; O_oe < 3 ; O_oe = O_oe + 1 ) { let O_rh : f32 = 1.0 / O_iy [ O_oe ] ; var O_qa : f32 ; var O_qc : f32 ; if O_oe == 0 { O_qa = ( O_kd . O_jp - O_rg . O_rd . x ) * O_rh ; O_qc = ( O_kd . O_js - O_rg . O_rd . x ) * O_rh ; } else if O_oe == 1 { O_qa = ( O_kd . O_jq - O_rg . O_rd . y ) * O_rh ; O_qc = ( O_kd . O_jt - O_rg . O_rd . y ) * O_rh ; } else { O_qa = ( O_kd . O_jr - O_rg . O_rd . z ) * O_rh ; O_qc = ( O_kd . O_ju - O_rg . O_rd . z ) * O_rh ; } if O_rh < 0.0 { let O_pt : f32 = O_qa ; O_qa = O_qc ; O_qc = O_pt ; } O_ph = max ( O_ph , O_qa ) ; O_pi = min ( O_pi , O_qc ) ; if O_pi <= O_ph { return false ; } } return true ; } struct O_qn { O_qp : vec3 < f32 > , O_qr : f32 , } fn O_ri ( O_qm : O_qn , O_jw : vec3 < f32 > , ) -> vec3 < f32 > { return normalize ( O_jw - O_qm . O_qp ) ; } fn O_rj ( O_po : vec3 < f32 > , O_bq : vec3 < f32 > , ) -> vec3 < f32 > { return O_po - 2.0 * dot ( O_po , O_bq ) * O_bq ; } struct O_qb { O_ky : vec3 < f32 > , O_kz : vec3 < f32 > , O_la : vec3 < f32 > , } ; fn O_rk ( ) -> O_qb { return O_qb ( vec3 < f32 > ( 0 ) , vec3 < f32 > ( 0 ) , vec3 < f32 > ( 0 ) ) ; } fn O_rl ( O_qe : O_qb , ) -> vec3 < f32 > { return normalize ( O_qe . O_ky - O_qe . O_kz ) ; } fn O_rm ( O_if : vec3 < f32 > , O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , O_qq : vec3 < f32 > , ) -> bool { let O_ky = O_qq - O_ht ; let O_kz = O_hu - O_ht ; let O_la = O_if - O_ht ; let O_rn = dot ( O_ky , O_ky ) ; let O_ro = dot ( O_ky , O_kz ) ; let O_rp = dot ( O_ky , O_la ) ; let O_rq = dot ( O_kz , O_kz ) ; let O_rr = dot ( O_kz , O_la ) ; let O_rs = 1.0 / ( O_rn * O_rq - O_ro * O_ro ) ; let O_cn = ( O_rq * O_rp - O_ro * O_rr ) * O_rs ; let O_cm = ( O_rn * O_rr - O_ro * O_rp ) * O_rs ; return ( O_cn >= 0.0 ) && ( O_cm >= 0.0 ) && ( O_cn + O_cm < 1.0 ) ; } fn O_rt ( O_rg : O_rc , O_qe : O_qb , ) -> bool { let O_pz = O_rg . O_rd ; let O_mx = O_rg . O_re ; let O_ht : vec3 < f32 > = O_qe . O_ky ; let O_hu : vec3 < f32 > = O_qe . O_kz ; let O_qq : vec3 < f32 > = O_qe . O_la ; let O_ru = O_hu - O_ht ; let O_rv = O_qq - O_ht ; let O_bu = cross ( O_ru , O_rv ) ; let O_rw = dot ( O_bu , O_ht ) ; let O_hd = ( O_rw - dot ( O_bu , O_pz ) ) / dot ( O_bu , O_mx - O_pz ) ; if O_hd < 0.0 || O_hd > 1.0 { return false ; } let O_if = O_pz + O_hd * ( O_mx - O_pz ) ; return O_rm ( O_if , O_ht , O_hu , O_qq ) ; } fn O_rx ( O_if : vec3 < f32 > , O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , O_qq : vec3 < f32 > , ) -> vec3 < f32 > { let O_ky = O_hu - O_ht ; let O_kz = O_qq - O_ht ; let O_la = O_if - O_ht ; let O_ry = dot ( O_ky , O_ky ) ; let O_rz = dot ( O_ky , O_kz ) ; let O_sa = dot ( O_kz , O_kz ) ; let O_sb = dot ( O_la , O_ky ) ; let O_sc = dot ( O_la , O_kz ) ; let O_am = O_ry * O_sa - O_rz * O_rz ; let O_cm = ( O_sa * O_sb - O_rz * O_sc ) / O_am ; let O_sd = ( O_ry * O_sc - O_rz * O_sb ) / O_am ; let O_cn = 1.0 - O_cm - O_sd ; return vec3 < f32 > ( O_cn , O_cm , O_sd ) ; } fn O_se ( O_qe : O_qb , O_bq : array < vec3 < f32 > , 3 > , O_sf : vec3 < f32 > , ) -> vec3 < f32 > { let O_sg = O_rx ( O_sf , O_qe . O_ky , O_qe . O_kz , O_qe . O_la ) ; return normalize ( O_sg . x * O_bq [ 0 ] + O_sg . y * O_bq [ 1 ] + O_sg . z * O_bq [ 2 ] ) ; } fn O_lk ( ) -> vec3 < f32 > { return vec3 < f32 > ( 0 , 0 , 0 ) ; } fn O_ra ( O_sh : vec3 < f32 > , O_la : vec3 < f32 > , ) -> bool { let O_pp = dot ( O_sh , O_la ) ; let O_si = length ( O_sh ) ; let O_sj = length ( O_la ) ; return ( O_si > 0.0 ) && ( O_sj > 0.0 ) && ( O_pp >= 0.0 ) ; } fn O_sk ( O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , ) -> f32 { let O_pp = dot ( O_ht , O_hu ) ; let O_sl = length ( O_ht ) * length ( O_hu ) ; return O_pp / O_sl ; } fn O_sm ( O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , ) -> bool { let O_oa = 1.0 / 255.0 ; return abs ( O_ht . x - O_hu . x ) < O_oa && abs ( O_ht . y - O_hu . y ) < O_oa && abs ( O_ht . z - O_hu . z ) < O_oa ; } fn O_sn ( O_bu : vec3f , O_cm : vec3f , ) -> f32 { let O_hp = max ( dot ( normalize ( O_bu ) , normalize ( O_cm ) ) , 0.0 ) ; return O_hp ; } fn O_so ( O_bu : vec3f , O_cm : vec3f , ) -> f32 { let dot = O_sn ( O_bu , O_cm ) ; return acos ( dot ) ; } struct O_fa { O_sp : f32 , O_sq : f32 , O_sr : f32 , O_ss : f32 , O_st : f32 , O_su : f32 , O_sv : f32 , } struct O_fc { O_sw : f32 , O_sx : f32 , O_sy : f32 , O_sz : f32 , O_ta : f32 , } struct O_fe { O_qv : f32 , O_sx : f32 , O_ka : f32 , O_tb : f32 , O_tc : f32 , O_td : f32 , O_te : f32 , O_tf : f32 , O_tg : f32 , O_th : f32 , } struct O_bf { O_i : vec3f , O_bj : vec3f , } fn O_ti ( O_tj : vec3 < f32 > , ) -> vec3 < f32 > { var O_tk : vec3 < f32 > = O_tj ; if ( O_tk . x != O_tk . x ) { O_tk . x = 0 ; } if ( O_tk . y != O_tk . y ) { O_tk . y = 0 ; } if ( O_tk . z != O_tk . z ) { O_tk . z = 0 ; } return O_tk ; } fn O_gu ( ) -> O_fs { O_bl ( ) ; O_bl ( ) ; return O_fr [ O_gi ] ; } fn O_tl ( O_if : vec3 < f32 > , O_ht : vec3 < f32 > , O_hu : vec3 < f32 > , O_qq : vec3 < f32 > , ) -> vec3 < f32 > { let O_ky = O_hu - O_ht ; let O_kz = O_qq - O_ht ; let O_la = O_if - O_ht ; let O_ry = dot ( O_ky , O_ky ) ; let O_rz = dot ( O_ky , O_kz ) ; let O_sa = dot ( O_kz , O_kz ) ; let O_sb = dot ( O_la , O_ky ) ; let O_sc = dot ( O_la , O_kz ) ; let O_am = O_ry * O_sa - O_rz * O_rz ; let O_cm = ( O_sa * O_sb - O_rz * O_sc ) / O_am ; let O_sd = ( O_ry * O_sc - O_rz * O_sb ) / O_am ; let O_cn = 1.0 - O_cm - O_sd ; return vec3 < f32 > ( O_cn , O_cm , O_sd ) ; } fn O_tm ( O_qe : O_qb , O_bq : array < vec3 < f32 > , 3 > , O_sf : vec3 < f32 > , ) -> vec3 < f32 > { let O_sg = O_tl ( O_sf , O_qe . O_ky , O_qe . O_kz , O_qe . O_la ) ; return normalize ( O_sg . x * O_bq [ 0 ] + O_sg . y * O_bq [ 1 ] + O_sg . z * O_bq [ 2 ] ) ; } fn O_hf ( O_tk : vec3 < f32 > , ) { if ( O_gk ) { return ; } O_et [ O_gi ] . O_bb = O_ti ( O_tk ) ; O_gk = true ; } fn O_gx ( O_gv : O_tn , O_gt : O_fs , ) { O_hf ( O_gv . O_tk ) ; O_et [ O_gi ] . O_lh = f32 ( O_gv . O_bb ) ; O_et [ O_gi ] . O_bq = O_gv . O_by ; O_et [ O_gi ] . O_gy = O_gv . O_gy ; O_et [ O_gi ] . O_lf = f32 ( O_gv . O_hc ) ; O_et [ O_gi ] . O_lg = length ( O_gv . O_gy - O_gt . O_nz ) ; } fn O_to ( O_tp : vec3 < f32 > , ) { var O_bq = normalize ( O_tp ) ; O_bq = O_bq + vec3 < f32 > ( 1.0 ) ; O_bq = O_bq * 0.5 ; O_hf ( O_bq ) ; } fn O_tq ( ) { O_hf ( vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ) ; } fn O_tr ( ) { O_hf ( vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ) ; } fn O_ts ( O_tt : u32 , O_tu : u32 , ) { let O_tv = f32 ( O_tt ) / f32 ( O_tu ) ; O_hf ( vec3 < f32 > ( O_tv , O_tv , O_tv ) ) ; } fn O_tw ( O_tk : u32 , ) { let O_qi = 1.0 / f32 ( O_tk + 1 ) ; O_hf ( vec3 < f32 > ( O_qi , O_qi , O_qi ) ) ; } fn O_tx ( O_tk : vec3 < f32 > , ) -> bool { return O_tk . x > 0.0 && O_tk . y > 0.0 && O_tk . z > 0.0 ; } fn O_ty ( O_tj : vec3 < f32 > , ) -> vec3 < f32 > { var O_tk : vec3 < f32 > = O_tj ; let O_tz : f32 = 1.0 / 2.2 ; O_tk . x = pow ( O_tk . x , O_tz ) ; O_tk . y = pow ( O_tk . y , O_tz ) ; O_tk . z = pow ( O_tk . z , O_tz ) ; return O_tk ; } fn O_gp ( ) { let O_ua = O_ev . O_gj ; O_gj = O_ua * ( f32 ( O_gi ) / f32 ( Image_Width * Image_Height ) ) ; O_gj = O_ub ( O_gj ) ; } fn O_bl ( ) -> f32 { let O_uc = O_ud ( O_gj ) ; O_gj = O_uc ; return O_uc ; } fn O_ue ( O_ua : f32 , ) -> f32 { var O_uf = u32 ( O_ua * 1e6 ) ; O_uf ^= O_uf << 13 ; O_uf ^= O_uf >> 17 ; O_uf ^= O_uf << 5 ; return f32 ( O_uf ) * 2.3283064e-10 ; } fn O_ug ( O_ua : f32 , ) -> f32 { var O_ky = u32 ( O_ua * 1e6 ) ; var O_kz = u32 ( O_ua * 1e6 + 1.0 ) ; var O_uh = 0u ; for ( var O_oe = 0u ; O_oe < 4u ; O_oe ++ ) { O_uh += 0x9e3779b9u ; O_ky += ( ( O_kz << 4u ) + 0xa341316cu ) ^ ( O_kz + O_uh ) ^ ( ( O_kz >> 5u ) + 0xc8013ea4u ) ; O_kz += ( ( O_ky << 4u ) + 0xad90777du ) ^ ( O_ky + O_uh ) ^ ( ( O_ky >> 5u ) + 0x7e95761eu ) ; } return f32 ( O_ky ^ O_kz ) / 4294967296.0 ; } fn O_ui ( O_ua : f32 , ) -> f32 { var O_uf = u32 ( O_ua * 1e6 ) ; O_uf = O_uf * 0x53a2f814u + 0x74736975u ; O_uf = ( O_uf ^ ( O_uf >> 16 ) ) * 0x7feb352du ; O_uf = ( O_uf ^ ( O_uf >> 15 ) ) * 0x846ca68bu ; return f32 ( O_uf ^ ( O_uf >> 16 ) ) / 4294967296.0 ; } fn O_ud ( O_ua : f32 , ) -> f32 { let O_ht : f32 = 1664525.0 ; let O_qq : f32 = 1013904223.0 ; let O_le : f32 = 4294967296.0 ; return fract ( ( O_ht * O_ua * 100000.0 + O_qq ) / O_le ) ; } fn O_uj ( O_ua : f32 , ) -> f32 { var O_uf = u32 ( O_ua * 1e6 ) ; O_uf = O_uf * 747796405u + 2891336453u ; let O_uk = ( ( O_uf >> ( ( O_uf >> 28u ) + 4u ) ) ^ O_uf ) * 277803737u ; return f32 ( ( O_uk >> 22u ) ^ O_uk ) / 4294967296.0 ; } fn O_ub ( O_ua : f32 , ) -> f32 { return fract ( sin ( O_ua * 43758.5453 ) * 12345.6789 ) ; } fn O_ul ( ) -> f32 { return 2.0 * O_bl ( ) - 1.0 ; } fn O_cp ( ) -> f32 { return O_ul ( ) * O_ao ; } fn O_ck ( min : f32 , max : f32 , ) -> f32 { return min + ( max - min ) * O_bl ( ) ; } fn O_um ( ) -> vec3 < f32 > { while ( true ) { let O_iy = normalize ( vec3 < f32 > ( O_un ( ) , O_un ( ) , O_un ( ) ) ) ; if ( length ( O_iy ) != 0 ) { return O_iy ; } } return vec3 < f32 > ( 0 ) ; } fn O_un ( ) -> f32 { return sqrt ( - 2 * log ( O_bl ( ) ) ) * cos ( 2 * O_ao * O_bl ( ) ) ; } fn O_gw ( O_gt : O_fs , ) -> O_tn { var O_uo = O_up ( O_gt , true , true , O_gd . O_uq == 1.0 ) ; if ( O_uo . O_bb != O_el ) { return O_uo ; } O_uo . O_tk = O_ur ( O_uo ) ; var O_h = O_gt . O_oy ; var O_bj = vec3f ( 1 ) ; var O_gv = O_uo ; for ( var O_oe = 0 ; O_oe < i32 ( O_ev . O_oi ) ; O_oe += 1 ) { var O_bg : O_us = O_ut ( O_gv . O_b , O_gv . O_c , O_gv . O_d , O_gv . O_e , O_gv . O_hg , O_gv . O_bz , - O_gv . O_bw , vec3f ( O_bl ( ) , O_bl ( ) , O_bl ( ) ) ) ; O_h = O_bg . O_i ; O_bj *= ( O_bg . O_qi / O_bg . O_uu ) ; O_gv = O_up ( O_fs ( O_gv . O_gy + 0.001 * O_h , O_h ) , false , false , false ) ; if ( O_gv . O_bb != O_el ) { O_uo . O_tk += O_gv . O_tk * O_bj ; return O_uo ; } O_uo . O_tk += O_ur ( O_gv ) * O_bj ; } return O_uo ; } fn O_ut ( O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_j : vec3 < f32 > , O_hs : vec3 < f32 > , ) -> O_us { let O_uv = O_o ( vec3 < f32 > ( 1.0 ) , O_d , O_e , O_f ) ; let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; let O_p = O_q ( O_uv , O_m ) ; let O_uw = O_jn ( O_p ) * O_d + ( 1.0 - O_d ) * O_f ; let O_ux = 1.0 - O_uw ; if ( O_uw < 1e-5 ) { let O_uy = O_uz ( O_g , O_hs . xy ) ; let O_r = ( 1.0 - O_jn ( O_p ) ) * ( 1.0 - O_d ) ; let O_va = O_b * O_r * O_t ; return O_us ( O_uy . O_i , O_uy . O_uu , O_va ) ; } if ( O_ux < 1e-5 ) { return O_vb ( O_b , O_c , O_d , O_e , O_f , O_g , O_j , O_hs ) ; } if ( O_hs . z < O_uw ) { let O_vc = O_vb ( O_b , O_c , O_d , O_e , O_f , O_g , O_j , O_hs ) ; if ( O_vc . O_uu > 0.0 ) { let O_i = O_vc . O_i ; if ( O_c < 1e-5 ) { let O_n = O_o ( O_b , O_d , O_e , O_f ) ; let O_vd = max ( dot ( O_g , O_i ) , 0.0 ) ; let O_p = O_q ( O_n , O_vd ) ; let O_ve = O_uw ; let O_vf = O_p * O_ve ; return O_us ( O_i , O_ve , O_vf ) ; } let O_vd = max ( dot ( O_g , O_i ) , 0.0 ) ; let O_vg = O_vd * O_t ; let O_vh = O_uw * O_vc . O_uu + O_ux * O_vg ; let O_vi = O_a ( O_b , O_c , O_d , O_e , O_f , O_g , O_i , O_j ) ; return O_us ( O_i , O_vh , O_vi ) ; } } let O_uy = O_uz ( O_g , O_hs . xy ) ; let O_i = O_uy . O_i ; let O_av = normalize ( O_j + O_i ) ; let O_ah = max ( dot ( O_g , O_av ) , 0.0 ) ; let O_aw = max ( dot ( O_j , O_av ) , 0.0 ) ; let O_ax = O_ag ( O_ah , O_c ) ; let O_vj = O_ax * O_ah / max ( 4.0 * O_aw , 1e-10 ) ; let O_vh = O_uw * O_vj + O_ux * O_uy . O_uu ; let O_vi = O_a ( O_b , O_c , O_d , O_e , O_f , O_g , O_i , O_j ) ; return O_us ( O_i , O_vh , O_vi ) ; } fn O_vb ( O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_j : vec3 < f32 > , O_hs : vec3 < f32 > , ) -> O_us { if ( O_d < 1e-5 && O_f < 1e-5 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } if ( O_c < 1e-5 ) { let O_vk = normalize ( O_j ) ; let O_m = max ( dot ( O_g , O_vk ) , 0.0 ) ; if ( O_m <= 0.0 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } let O_i = 2.0 * O_m * O_g - O_vk ; let O_vl = normalize ( O_i ) ; let O_uu = 1.0 ; let O_qi = O_v ( O_b , O_c , O_d , O_e , O_f , O_g , O_j , O_vl ) ; return O_us ( O_vl , O_uu , O_qi ) ; } let O_ai = O_c * O_c ; let O_vm = O_ai ; let O_vn = O_ai ; var O_ji : vec3 < f32 > ; var O_jj : vec3 < f32 > ; if ( abs ( O_g . z ) < 0.9 ) { O_ji = normalize ( cross ( O_g , vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ) ) ; } else { O_ji = normalize ( cross ( O_g , vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ) ) ; } O_jj = cross ( O_g , O_ji ) ; let O_vo = vec3 < f32 > ( dot ( O_ji , O_j ) , dot ( O_jj , O_j ) , dot ( O_g , O_j ) ) ; let O_vp = O_vq ( O_vo , O_vm , O_vn , O_hs . xy ) ; let O_av = O_jh ( O_vp , O_ji , O_jj , O_g ) ; let O_aw = max ( dot ( O_j , O_av ) , 0.0 ) ; let O_i = 2.0 * O_aw * O_av - O_j ; let O_vl = normalize ( O_i ) ; let O_vd = dot ( O_g , O_vl ) ; if ( O_vd <= 0.0 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; let O_ah = max ( dot ( O_g , O_av ) , 0.0 ) ; let O_y = O_ai * O_ai ; let O_ax = O_ag ( O_ah , O_c ) ; let O_uu = O_ax * O_ah / max ( 4.0 * O_aw , 1e-10 ) ; let O_qi = O_v ( O_b , O_c , O_d , O_e , O_f , O_g , O_j , O_vl ) ; return O_us ( O_vl , O_uu , O_qi ) ; } fn O_uz ( O_g : vec3 < f32 > , O_hs : vec2 < f32 > , ) -> O_us { let O_bn = sqrt ( O_hs . x ) ; let O_vr = 2.0 * O_ao * O_hs . y ; let O_cj = O_bn * cos ( O_vr ) ; let O_jd = O_bn * sin ( O_vr ) ; let O_vs = sqrt ( max ( 1.0 - O_cj * O_cj - O_jd * O_jd , 0.0 ) ) ; var O_vt : vec3 < f32 > ; var O_vu : vec3 < f32 > ; if ( abs ( O_g . z ) < 0.9 ) { O_vt = normalize ( cross ( O_g , vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ) ) ; } else { O_vt = normalize ( cross ( O_g , vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ) ) ; } O_vu = cross ( O_g , O_vt ) ; let O_i = O_cj * O_vt + O_jd * O_vu + O_vs * O_g ; let O_vl = normalize ( O_i ) ; let O_uu = O_vs * O_t ; return O_us ( O_vl , O_uu , vec3 < f32 > ( 0.0 ) ) ; } fn O_ur ( O_gv : O_tn , ) -> vec3f { if ( O_ev . O_ou == 0.0 ) { return vec3f ( ) ; } var O_tk : vec3f ; let O_vv = O_gv . O_gy ; let O_vw = O_gv . O_by ; let O_vx = O_gv . O_bz ; let O_b = O_gv . O_b ; let O_c = O_gv . O_c ; let O_d = O_gv . O_d ; let O_vy = - O_gv . O_bw ; let O_e = O_gv . O_e ; let O_vz = O_gv . O_hg ; for ( var O_oe = 0 ; O_oe < O_eh ; O_oe ++ ) { let O_wa = O_fg [ O_oe ] ; if ( O_wa . O_wb == 1.0 || O_wa . O_wc == 0.0 ) { continue ; } let O_wd = O_we ( O_wa . O_wf ) ; let O_wg = O_wh ( O_wa . O_gy + 0.50 * O_wa . O_cn + 0.5 * O_wa . O_cm , O_wi ( normalize ( O_wa . O_cn ) , normalize ( O_wa . O_cm ) , length ( O_wa . O_cn ) , length ( O_wa . O_cm ) , normalize ( cross ( O_wa . O_cn , O_wa . O_cm ) ) , 1.0 / ( length ( O_wa . O_cn ) * length ( O_wa . O_cm ) ) , O_wd . O_wj , O_wd . O_wk , ) ) ; let O_wl = O_wa . O_tk * O_wa . O_wc ; let O_wm = vec2f ( O_bl ( ) , O_bl ( ) ) ; let O_wn = vec3f ( O_bl ( ) , O_bl ( ) , O_bl ( ) ) ; let O_wo = O_wa . O_wp > 0.0 ; O_tk += O_wq ( O_vv , O_vw , O_vx , O_b , O_c , O_d , O_e , O_vz , O_vy , O_wg , O_wl , O_wm , O_wn , O_wo ) ; } return O_tk ; } fn O_wq ( O_vv : vec3 < f32 > , O_vw : vec3 < f32 > , O_vx : vec3 < f32 > , O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_vy : vec3 < f32 > , O_wg : O_wh , O_wl : vec3 < f32 > , O_wr : vec2 < f32 > , O_wn : vec3 < f32 > , O_wo : bool , ) -> vec3 < f32 > { var O_bj = vec3 < f32 > ( 0.0 ) ; let O_ws = O_wt ( O_vv , O_vw , O_vx , O_b , O_c , O_d , O_e , O_f , O_vy , O_wg , O_wl , O_wr , O_wo ) ; let O_wu = O_wv ( O_wg , O_vv , O_wg . O_ww , O_wr , true , false ) ; let O_wx = O_wu . O_wy . O_uu ; if ( O_wx > 0.0 && O_wu . O_wz ) { let O_h = O_wu . O_wy . O_ax ; let O_xa = O_xb ( O_c , O_d , O_e , O_f , O_vx , O_h , O_vy ) ; let O_xc = O_xd ( O_wx , O_xa ) ; O_bj += O_ws * O_xc ; } let O_xe = O_xf ( O_c , O_d , O_e , O_f , O_vx , O_vy , O_wn ) ; if ( O_xe . O_uu > 0.0 ) { let O_i = O_xe . O_i ; let O_xg = O_xe . O_uu ; let O_xh = O_a ( O_b , O_c , O_d , O_e , O_f , O_vx , O_i , O_vy ) ; let O_xi = dot ( O_vw , O_i ) ; if ( O_xi > 0.0 ) { let O_xj = O_wg . O_wa . O_iy ; let O_xk = O_wg . O_ww ; let O_xl = O_xk - O_vv ; let O_xm = dot ( O_xl , O_xj ) ; let O_xn = O_xm / max ( dot ( O_i , O_xj ) , 1e-10 ) ; if ( O_xn > 0.0 ) { let O_xo = O_vv + O_i * O_xn ; let O_xp = O_xo - O_xk ; let O_xq = dot ( O_xp , O_wg . O_wa . O_xr ) ; let O_xs = dot ( O_xp , O_wg . O_wa . O_xt ) ; let O_xu = O_wg . O_wa . O_xv * 0.5 ; let O_xw = O_wg . O_wa . O_xx * 0.5 ; let O_xy = ( O_wg . O_wa . O_xz < 0.0 ) ; var O_ya = false ; if ( O_xy ) { let O_yb = O_xq / O_xu ; let O_yc = O_xs / O_xw ; O_ya = ( O_yb * O_yb + O_yc * O_yc <= 1.0 ) ; } else { O_ya = ( abs ( O_xq ) <= O_xu && abs ( O_xs ) <= O_xw ) ; } if ( O_ya ) { var O_uq = true ; if ( O_wo ) { let O_yd = O_vv + O_vw * 0.001 ; O_uq = O_ye ( O_yd , O_i , O_xn - 0.001 ) ; } if ( O_uq ) { let O_yf = O_xo - O_vv ; let O_yg = length ( O_yf ) ; let O_yh = O_yf / max ( O_yg , 1e-10 ) ; let O_yi = O_wv ( O_wg , O_vv , O_xo , vec2 < f32 > ( 0.0 ) , false , false ) ; if ( O_yi . O_wz ) { let O_yj = O_yi . O_wy . O_uu ; if ( O_yj > 0.0 ) { let O_yk = O_wl * O_yi . O_wy . O_yl ; let O_ym = max ( dot ( O_vx , O_i ) , 0.0 ) ; var O_yn : vec3 < f32 > ; if ( O_c < 1e-5 ) { let O_n = O_o ( O_b , O_d , O_e , O_f ) ; let O_yo = max ( dot ( O_vx , O_vy ) , 0.0 ) ; let O_p = O_q ( O_n , O_yo ) ; O_yn = O_yk * O_p * O_ym ; } else { O_yn = ( O_yk * O_xh * O_ym ) / max ( O_xg , 1e-10 ) ; } let O_yp = O_xd ( O_xg , O_yj ) ; O_bj += O_yn * O_yp ; } } } } } } } return clamp ( O_bj , vec3 < f32 > ( 0.0 ) , vec3 < f32 > ( 1e4 ) ) ; } fn O_yq ( O_c : f32 , O_g : vec3 < f32 > , O_j : vec3 < f32 > , O_k : vec3 < f32 > , ) -> f32 { let O_at = O_j + O_k ; let O_au = length ( O_at ) ; if ( O_au < 1e-6 ) { return 0.0 ; } let O_av = O_at / O_au ; let O_l = max ( dot ( O_g , O_k ) , 0.0 ) ; let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; let O_ah = dot ( O_g , O_av ) ; if ( O_l <= 0.0 || O_m <= 0.0 || O_ah <= 0.0 ) { return 0.0 ; } let O_ai = O_c * O_c ; let O_y = O_ai * O_ai ; if ( O_y <= O_w ) { return 0.0 ; } let O_aj = clamp ( O_ah , - 1.0 , 1.0 ) ; let O_ak = min ( O_aj * O_aj , 1.0 ) ; let O_al = 1.0 - O_ak ; let O_am = O_al + O_y * O_ak ; let O_ax = O_y / max ( O_ao * O_am * O_am , 1e-10 ) ; let O_aq = O_x ( O_y , O_l ) ; let O_az = O_ax * 0.25 ; return O_az / max ( O_l * ( 1.0 + O_aq ) , 1e-10 ) ; } fn O_xd ( O_yr : f32 , O_ys : f32 , ) -> f32 { let O_yt = O_yr * O_yr ; let O_yu = O_ys * O_ys ; return O_yt / max ( O_yt + O_yu , 1e-10 ) ; } struct O_us { O_i : vec3 < f32 > , O_uu : f32 , O_qi : vec3 < f32 > , } fn O_xf ( O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_j : vec3 < f32 > , O_hs : vec3 < f32 > , ) -> O_us { if ( O_d < 1e-5 && O_f < 1e-5 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } if ( O_c < 1e-5 ) { let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; if ( O_m <= 0.0 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } let O_i = 2.0 * O_m * O_g - O_j ; let O_vl = normalize ( O_i ) ; let O_uu = 1e10 ; let O_yv = vec3 < f32 > ( 1.0 ) ; let O_qi = O_v ( O_yv , O_c , O_d , O_e , O_f , O_g , O_j , O_vl ) ; return O_us ( O_vl , O_uu , O_qi ) ; } let O_ai = max ( O_c * O_c , 1e-6 ) ; let O_vm = O_ai ; let O_vn = O_ai ; var O_ji : vec3 < f32 > ; var O_jj : vec3 < f32 > ; if ( abs ( O_g . z ) < 0.9 ) { O_ji = normalize ( cross ( O_g , vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) ) ) ; } else { O_ji = normalize ( cross ( O_g , vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ) ) ; } O_jj = cross ( O_g , O_ji ) ; let O_vo = vec3 < f32 > ( dot ( O_ji , O_j ) , dot ( O_jj , O_j ) , dot ( O_g , O_j ) ) ; let O_vp = O_vq ( O_vo , O_vm , O_vn , O_hs . xy ) ; let O_av = O_jh ( O_vp , O_ji , O_jj , O_g ) ; let O_aw = max ( dot ( O_j , O_av ) , 0.0 ) ; let O_i = 2.0 * O_aw * O_av - O_j ; let O_vl = normalize ( O_i ) ; let O_vd = dot ( O_g , O_vl ) ; if ( O_vd <= 0.0 ) { return O_us ( vec3 < f32 > ( 0.0 ) , 0.0 , vec3 < f32 > ( 0.0 ) ) ; } let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; let O_ah = max ( dot ( O_g , O_av ) , 0.0 ) ; let O_y = O_ai * O_ai ; let O_ax = O_ag ( O_ah , O_c ) ; let O_uu = O_ax * O_ah / max ( 4.0 * O_aw , 1e-10 ) ; let O_yv = vec3 < f32 > ( 1.0 ) ; let O_qi = O_v ( O_yv , O_c , O_d , O_e , O_f , O_g , O_j , O_vl ) ; return O_us ( O_vl , O_uu , O_qi ) ; } fn O_vq ( O_h : vec3 < f32 > , O_vm : f32 , O_vn : f32 , O_hs : vec2 < f32 > , ) -> vec3 < f32 > { let O_yw = normalize ( vec3 < f32 > ( O_vm * O_h . x , O_vn * O_h . y , O_h . z ) ) ; let O_yx = O_jl ( O_yw . x ) + O_jl ( O_yw . y ) ; var O_yy : vec3 < f32 > ; var O_yz : vec3 < f32 > ; if ( O_yx > 1e-7 ) { O_yy = vec3 < f32 > ( - O_yw . y , O_yw . x , 0.0 ) * O_jm ( O_yx ) ; O_yz = cross ( O_yw , O_yy ) ; } else { O_yy = vec3 < f32 > ( 1.0 , 0.0 , 0.0 ) ; O_yz = vec3 < f32 > ( 0.0 , 1.0 , 0.0 ) ; } let O_hd = O_hr ( O_hs ) ; let O_za = mix ( O_iu ( 1.0 - O_jl ( O_hd . x ) ) , O_hd . y , 0.5 * ( 1.0 + O_yw . z ) ) ; let O_zb = vec2 < f32 > ( O_hd . x , O_za ) ; let O_zc = O_jh ( O_jf ( O_zb ) , O_yy , O_yz , O_yw ) ; return normalize ( vec3 < f32 > ( O_vm * O_zc . x , O_vn * O_zc . y , max ( 0.0 , O_zc . z ) ) ) ; } fn O_wt ( O_vv : vec3 < f32 > , O_vw : vec3 < f32 > , O_vx : vec3 < f32 > , O_b : vec3 < f32 > , O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_vy : vec3 < f32 > , O_wg : O_wh , O_wl : vec3 < f32 > , O_wm : vec2 < f32 > , O_wo : bool , ) -> vec3 < f32 > { let O_wu = O_wv ( O_wg , O_vv , O_wg . O_ww , O_wm , true , false ) ; if ( ! O_wu . O_wz || O_wu . O_wy . O_uu <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } let O_zd = O_wu . O_wy . O_ax ; let distance = O_wu . O_wy . O_hd ; let O_uu = O_wu . O_wy . O_uu ; let O_yl = O_wu . O_wy . O_yl ; let O_h = O_zd ; let O_ze = dot ( O_vw , O_h ) ; if ( O_ze <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } if ( O_wo ) { let O_yd = O_vv + O_vw * 0.001 ; if ( ! O_ye ( O_yd , O_h , distance - 0.001 ) ) { return vec3 < f32 > ( 0.0 ) ; } } let O_zf = dot ( O_vx , O_h ) ; if ( O_zf <= 0.0 ) { return vec3 < f32 > ( 0.0 ) ; } let O_zg = O_wl * O_yl ; let O_qi = O_a ( O_b , O_c , O_d , O_e , O_f , O_vx , O_h , O_vy ) ; let O_bj = ( O_zg * O_qi * O_zf ) / max ( O_uu , 1e-10 ) ; return clamp ( O_bj , vec3 < f32 > ( 0.0 ) , vec3 < f32 > ( 1e4 ) ) ; } fn O_xb ( O_c : f32 , O_d : f32 , O_e : f32 , O_f : f32 , O_g : vec3 < f32 > , O_h : vec3 < f32 > , O_i : vec3 < f32 > , ) -> f32 { let O_j = normalize ( O_i ) ; let O_k = normalize ( O_h ) ; let O_l = max ( dot ( O_g , O_k ) , 0.0 ) ; let O_m = max ( dot ( O_g , O_j ) , 0.0 ) ; if ( O_l <= 0.0 || O_m <= 0.0 ) { return 0.0 ; } let O_uv = O_o ( vec3 < f32 > ( 1.0 ) , O_d , O_e , O_f ) ; let O_p = O_q ( O_uv , O_m ) ; let O_uw = O_jn ( O_p ) * O_d + ( 1.0 - O_d ) * O_f ; let O_ux = 1.0 - O_uw ; let O_vg = O_l * O_t ; let O_av = normalize ( O_j + O_k ) ; let O_ah = max ( dot ( O_g , O_av ) , 0.0 ) ; let O_aw = max ( dot ( O_j , O_av ) , 0.0 ) ; let O_ax = O_ag ( O_ah , O_c ) ; let O_vj = O_ax * O_ah / max ( 4.0 * O_aw , 1e-10 ) ; return O_ux * O_vg + O_uw * O_vj ; } fn O_zh ( O_gt : O_fs , ) -> O_li { let O_ha = O_zi ( O_gt ) ; if ( O_ha . O_hd < 0 ) { return O_lj ( ) ; } var O_hc : i32 ; if ( O_zj ( O_ha . O_jw ) ) { O_hc = i32 ( O_fd . O_sx ) ; } else { O_hc = i32 ( O_fd . O_qv ) ; } let O_lf = O_fp [ O_hc ] ; return O_li ( O_ha . O_hd , vec3 < f32 > ( 0.0 , 0.0 , 1.0 ) , O_lf , O_hc ) ; } fn O_zj ( O_jw : vec2f , ) -> bool { { let O_kb = O_fd . O_ka / 2.0 ; let O_zk = O_fd . O_tb / 2.0 ; let O_zl = vec2f ( O_kb - O_fd . O_td , O_zk - O_fd . O_td ) ; let O_kd = O_kf ( O_zl . x - O_fd . O_tg , O_zl . x , O_zl . y - O_fd . O_th , O_zl . y ) ; if ( O_ki ( O_kd , O_jw ) ) { let O_zm = O_kd . O_js - O_kd . O_jp ; let O_zn = O_kd . O_jt - O_kd . O_jq ; let O_zo = vec2f ( ( O_jw . x - O_kd . O_jp ) / O_zm , 1.0 - ( O_jw . y - O_kd . O_jq ) / O_zn ) ; let O_zp = vec2 < i32 > ( O_zo * vec2 < f32 > ( textureDimensions ( O_gf ) ) ) ; var O_tk = textureLoad ( O_gf , O_zp , 0 ) ; return O_tk . x < 0.5 ; } } { let O_kb = O_fd . O_ka / 2.0 ; let O_zk = O_fd . O_tb / 2.0 ; var O_km = O_kf ( - O_kb , O_kb , - O_zk , O_zk ) ; O_km = O_kg ( O_km , O_fd . O_td ) ; if ( ! O_ki ( O_km , O_jw ) ) { return false ; } } { let O_zq = O_fd . O_tf ; var O_zr : f32 ; if ( O_jw . x < 0 ) { O_zr = ( O_jw . x - ( O_jw . x % O_zq ) ) - O_zq ; } else { O_zr = ( O_jw . x - ( O_jw . x % O_zq ) ) ; } var O_zs : f32 ; if ( O_jw . y < 0 ) { O_zs = ( O_jw . y - ( O_jw . y % O_zq ) ) - O_zq ; } else { O_zs = ( O_jw . y - ( O_jw . y % O_zq ) ) ; } var O_kd = O_kf ( O_zr , O_zr + O_zq , O_zs , O_zs + O_zq ) ; O_kd = O_kg ( O_kd , O_fd . O_te / 2.0 ) ; if ( ! O_ki ( O_kd , O_jw ) ) { return true ; } } return false ; } struct O_zt { O_hd : f32 , O_jw : vec2f , } fn O_zi ( O_gt : O_fs , ) -> O_zt { let O_zu = O_qz ( O_gt , O_zv ( ) ) ; let O_hd = O_zu . O_hd ; let O_zw = O_zu . O_jw . xy ; if ( O_hd < 0 || O_zx ( O_zw ) ) { return O_zt ( - 1 , vec2f ( 0 ) ) ; } else { return O_zt ( O_hd , O_zw ) ; } } fn O_zx ( O_zw : vec2 < f32 > , ) -> bool { let O_zy = vec2 < f32 > ( - O_fd . O_ka / 2.0 , O_fd . O_tb / 2.0 ) ; if ( O_zw . x > O_zy . x + O_fd . O_tc && O_zw . x < O_zy . x + O_fd . O_ka - O_fd . O_tc ) { if ( O_zw . y > O_zy . y - O_fd . O_tb && O_zw . y < O_zy . y ) { return false ; } } if ( O_zw . x > O_zy . x && O_zw . x < O_zy . x + O_fd . O_ka ) { if ( O_zw . y > O_zy . y - O_fd . O_tb + O_fd . O_tc && O_zw . y < O_zy . y - O_fd . O_tc ) { return false ; } } if ( length ( O_zw - ( O_zy + vec2f ( O_fd . O_tc , - O_fd . O_tc ) ) ) < O_fd . O_tc ) { return false ; } if ( length ( O_zw - ( O_zy + vec2f ( O_fd . O_ka - O_fd . O_tc , - O_fd . O_tc ) ) ) < O_fd . O_tc ) { return false ; } if ( length ( O_zw - ( O_zy + vec2f ( O_fd . O_tc , O_fd . O_tc - O_fd . O_tb ) ) ) < O_fd . O_tc ) { return false ; } if ( length ( O_zw - ( O_zy + vec2f ( O_fd . O_ka - O_fd . O_tc , O_fd . O_tc - O_fd . O_tb ) ) ) < O_fd . O_tc ) { return false ; } return true ; } fn O_zv ( ) -> O_ow { return O_ow ( vec3 < f32 > ( 0.0 , 0.0 , O_ft [ 2 ] ) , vec3 < f32 > ( 0.0 , 0.0 , 1.0 , ) ) ; } fn O_zz ( ) -> f32 { return O_ft [ 1 ] ; } fn O_aaa ( O_gt : O_fs , ) -> O_li { var O_lf : O_fq = O_fq ( ) ; var O_hd : f32 = - 1.0 ; let O_bn = 0.001 ; let O_cj = O_aab ( O_gt , vec3f ( ) , vec3 < f32 > ( 1 , 0 , 0 ) , O_bn ) ; if ( O_cj . x != - 1.0 ) { if ( O_cj . y > 0 ) { O_lf = O_md ( 1 , 1 , 0 ) ; } else { O_lf = O_md ( 1 , 1 , 1 ) ; } O_hd = O_cj . x ; } let O_jd = O_aab ( O_gt , vec3f ( ) , vec3 < f32 > ( 0 , 1 , 0 ) , O_bn ) ; if ( O_jd . x != - 1.0 ) { if ( O_jd . y > 0 ) { O_lf = O_md ( 0 , 1 , 0 ) ; } else { O_lf = O_md ( 1 , 1 , 1 ) ; } O_hd = O_jd . x ; } let O_vs = O_aab ( O_gt , vec3f ( ) , vec3 < f32 > ( 0 , 0 , 1 ) , O_bn ) ; if ( O_vs . x != - 1.0 ) { if ( O_vs . y > 0 ) { O_lf = O_md ( 0 , 0 , 1 ) ; } else { O_lf = O_md ( 1 , 1 , 1 ) ; } O_hd = O_vs . x ; } return O_li ( O_hd , vec3f ( ) , O_lf , - 1 ) ; } fn O_aab ( O_gt : O_fs , O_aac : vec3 < f32 > , O_aad : vec3 < f32 > , O_qr : f32 , ) -> vec2f { let O_aae = O_gt . O_nz - O_aac ; let O_aaf = dot ( O_gt . O_oy , O_aad ) ; let O_aag = dot ( O_aae , O_aad ) ; let O_aah = O_gt . O_oy - O_aaf * O_aad ; let O_aai = O_aae - O_aag * O_aad ; let O_ht = dot ( O_aah , O_aah ) ; let O_hu = 2.0 * dot ( O_aai , O_aah ) ; let O_qq = dot ( O_aai , O_aai ) - O_qr * O_qr ; if abs ( O_ht ) < O_cu { let O_aaj = dot ( O_aai , O_aai ) ; if abs ( O_aaj - O_qr * O_qr ) < O_cu * O_qr { let O_aak = dot ( O_aae , O_aad ) ; var O_aal : f32 = 0.5 ; if O_aak > O_cu { O_aal = 1.0 ; } else if O_aak < - O_cu { O_aal = - 1.0 ; } return vec2 ( 0.0 , O_aal ) ; } return vec2 ( - 1.0 , 0.0 ) ; } let O_qs = O_hu * O_hu - 4.0 * O_ht * O_qq ; if O_qs < 0.0 { return vec2 ( - 1.0 , 0.0 ) ; } let O_aam = sqrt ( O_qs ) ; let O_qa = ( - O_hu - O_aam ) / ( 2.0 * O_ht ) ; let O_qc = ( - O_hu + O_aam ) / ( 2.0 * O_ht ) ; var O_aan = f32 ( - 1.0 ) ; if O_qa > O_cu { O_aan = O_qa ; } else if O_qc > O_cu { O_aan = O_qc ; } else { return vec2 ( - 1.0 , 0.0 ) ; } let O_aao = O_gt . O_nz + O_aan * O_gt . O_oy ; let O_aap = O_aao - O_aac ; let O_aaq = dot ( O_aap , O_aad ) ; var O_aal : f32 = 0.5 ; if O_aaq > O_cu { O_aal = 1.0 ; } else if O_aaq < - O_cu { O_aal = - 1.0 ; } return vec2 ( O_aan , O_aal ) ; } fn O_aar ( O_gt : O_fs , ) -> vec3 < f32 > { var O_tk : vec3f ; if ( O_ev . O_ot == 1.0 ) { O_tk = O_ev . O_os ; } else { let O_iy = O_aas ( O_gt . O_oy , O_ev . O_oq ) ; let O_zo = vec2 < f32 > ( 0.5 + atan2 ( - O_iy . y , O_iy . x ) / ( 2.0 * O_ao ) , 0.5 - asin ( O_iy . z ) / O_ao ) ; let O_zp = vec2 < i32 > ( O_zo * vec2 < f32 > ( textureDimensions ( O_ff ) ) ) ; var O_aat = textureLoad ( O_ff , O_zp , 0 ) ; O_tk = vec3 < f32 > ( O_aat . x , O_aat . y , O_aat . z ) ; } return O_tk * O_ev . O_or ; } fn O_aas ( O_aau : vec3 < f32 > , O_aav : f32 , ) -> vec3 < f32 > { let O_aaw = O_aav * 3.14159265359 / 180.0 ; let O_aax = cos ( O_aaw ) ; let O_aay = sin ( O_aaw ) ; let O_aaz = O_aau . x * O_aax - O_aau . y * O_aay ; let O_aba = O_aau . x * O_aay + O_aau . y * O_aax ; let O_abb = O_aau . z ; return vec3 < f32 > ( O_aaz , O_aba , O_abb ) ; } struct O_tn { O_bb : u32 , O_bw : vec3f , O_b : vec3f , O_d : f32 , O_c : f32 , O_e : f32 , O_hg : f32 , O_lp : f32 , O_lq : f32 , O_lr : f32 , O_lt : vec3f , O_by : vec3f , O_bz : vec3f , O_gy : vec3f , O_tk : vec3 < f32 > , O_ho : f32 , O_hc : f32 , } fn O_abc ( ) -> O_tn { let O_cm = vec3 < f32 > ( 0 ) ; return O_tn ( 0 , O_cm , O_cm , 0 , 0 , 0 , 0 , 0 , 0 , 0 , O_cm , O_cm , O_cm , O_cm , O_cm , 0 , 0 ) ; } fn O_up ( O_gt : O_fs , O_abd : bool , O_abe : bool , O_abf : bool , ) -> O_tn { var O_gv = O_abc ( ) ; O_gv . O_bw = O_gt . O_oy ; let O_abg = O_hb ( O_gt , O_abd , O_abe , O_abf ) ; if ( O_abg . O_hd < 0.0 ) { O_gv . O_bb = O_ei ; O_gv . O_tk = O_aar ( O_gt ) ; return O_gv ; } O_gv . O_gy = O_pa ( O_gt , O_abg . O_hd ) ; O_gv . O_by = normalize ( O_abg . O_bq ) ; let O_lf = O_abg . O_lf ; if ( O_abg . O_he == O_eg ) { O_gv . O_bb = O_em ; O_gv . O_tk = O_lf . O_b ; return O_gv ; } if ( O_abg . O_he == O_ef ) { O_gv . O_bb = O_ej ; O_gv . O_tk = O_abh ( ) ; return O_gv ; } O_gv . O_e = O_lf . O_e ; O_gv . O_hg = O_lf . O_hg ; O_gv . O_lp = O_lf . O_lp ; O_gv . O_lq = pow ( O_lf . O_lq , 2.0 ) ; O_gv . O_lr = O_lf . O_lr ; O_gv . O_lt = O_lf . O_lt ; if ( O_lf . O_lv < 0.0 ) { O_gv . O_bz = O_gv . O_by ; } else { O_gv . O_bz = O_abi ( O_gv . O_gy , O_gv . O_by , O_lf . O_lv , O_lf . O_lw , O_lf . O_lu ) ; } if ( O_lf . O_lx < 0.0 ) { O_gv . O_d = O_lf . O_d ; } else { O_gv . O_d = O_abj ( O_gv . O_gy , O_gv . O_by , O_lf . O_lx , O_lf . O_ly ) . x * O_lf . O_d ; } if ( O_lf . O_lz < 0.0 ) { O_gv . O_b = O_abk ( O_lf . O_b ) ; } else { O_gv . O_b = O_abk ( O_abj ( O_gv . O_gy , O_gv . O_by , O_lf . O_lz , O_lf . O_ma ) ) * O_lf . O_b ; } if ( O_lf . O_mb < 0.0 ) { O_gv . O_c = O_lf . O_c ; } else { O_gv . O_c = O_abj ( O_gv . O_gy , O_gv . O_by , O_lf . O_mb , O_lf . O_mc ) . x * O_lf . O_c ; } O_gv . O_ho = O_sn ( O_gv . O_bz , - O_gt . O_oy ) ; O_gv . O_bb = O_el ; return O_gv ; } fn O_abk ( O_tk : vec3f , ) -> vec3f { return select ( pow ( ( O_tk + 0.055 ) / 1.055 , vec3f ( 2.4 ) ) , O_tk / 12.92 , O_tk <= vec3f ( 0.04045 ) ) ; } fn O_abi ( O_gy : vec3 < f32 > , O_abl : vec3 < f32 > , O_abm : f32 , O_abn : f32 , O_wc : f32 , ) -> vec3 < f32 > { var O_abo = normalize ( O_abj ( O_gy , O_abl , O_abm , O_abn ) ) ; O_abo . x = O_abo . x * O_wc ; O_abo . y = O_abo . y * O_wc ; O_abo = normalize ( O_abo ) ; let O_abp = select ( vec3f ( 0.0 , 1.0 , 0.0 ) , vec3f ( 0.0 , 0.0 , 1.0 ) , abs ( O_abl . z ) < 0.999 ) ; let O_br = normalize ( cross ( O_abp , O_abl ) ) ; let O_bs = normalize ( cross ( O_abl , O_br ) ) ; return mat3x3 < f32 > ( O_br , O_bs , O_abl ) * O_abo ; } fn O_abj ( O_gy : vec3 < f32 > , O_bq : vec3 < f32 > , O_abm : f32 , O_abn : f32 , ) -> vec3f { let O_abq = floor ( O_abm / 32.0 ) ; let O_abr = i32 ( O_abm - O_abq * 32 ) ; let O_abs = vec2 < i32 > ( ( O_abr % 8 ) * 2048 , O_abr / 8 * 2048 ) ; let O_abt = O_abu ( O_gy . xy , O_abn ) + O_abs ; let O_abv = O_abu ( O_gy . xz , O_abn ) + O_abs ; let O_abw = O_abu ( O_gy . yz , O_abn ) + O_abs ; var O_abx : vec3 < f32 > ; var O_aby : vec3 < f32 > ; var O_abz : vec3 < f32 > ; if ( O_abq == 0 ) { O_abx = textureLoad ( O_fi , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fi , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fi , O_abw , 0 ) . rgb ; } else if ( O_abq == 1 ) { O_abx = textureLoad ( O_fj , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fj , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fj , O_abw , 0 ) . rgb ; } else if ( O_abq == 2 ) { O_abx = textureLoad ( O_fk , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fk , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fk , O_abw , 0 ) . rgb ; } else if ( O_abq == 3 ) { O_abx = textureLoad ( O_fl , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fl , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fl , O_abw , 0 ) . rgb ; } else if ( O_abq == 4 ) { O_abx = textureLoad ( O_fm , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fm , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fm , O_abw , 0 ) . rgb ; } else if ( O_abq == 5 ) { O_abx = textureLoad ( O_fn , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fn , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fn , O_abw , 0 ) . rgb ; } else if ( O_abq == 6 ) { O_abx = textureLoad ( O_fo , O_abt , 0 ) . rgb ; O_aby = textureLoad ( O_fo , O_abv , 0 ) . rgb ; O_abz = textureLoad ( O_fo , O_abw , 0 ) . rgb ; } var O_aca = abs ( O_bq ) ; O_aca = O_aca / ( O_aca . x + O_aca . y + O_aca . z ) ; return O_abx * O_aca . z + O_aby * O_aca . y + O_abz * O_aca . x ; } fn O_abu ( O_gy : vec2f , O_abn : f32 , ) -> vec2 < i32 > { return ( vec2 < i32 > ( round ( O_gy * O_abn ) ) % 2048 + 2048 ) % 2048 ; } struct O_acb { O_he : i32 , O_hd : f32 , O_bq : vec3 < f32 > , O_lf : O_fq , O_hc : i32 , } fn O_hb ( O_gt : O_fs , O_abd : bool , O_abe : bool , O_abf : bool , ) -> O_acb { var O_acc : O_li = O_lj ( ) ; var O_he : i32 = - 1 ; if ( O_ev . O_on == 0.0 ) { let O_acd = O_ace ( O_gt ) ; if O_acd . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_acd . O_hd < O_acc . O_hd ) { O_acc = O_acd ; O_he = O_ed ; } } if ( O_ev . O_om == 0.0 ) { let O_acf = O_acg ( O_gt ) ; if O_acf . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_acf . O_hd < O_acc . O_hd ) { O_acc = O_acf ; O_he = O_ee ; } } if ( O_ev . O_ok == 0.0 ) { let O_ach = O_zh ( O_gt ) ; if O_ach . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_ach . O_hd < O_acc . O_hd ) { O_acc = O_ach ; O_he = O_eb ; } } if ( O_abf && O_ev . O_ol == 0.0 ) { let O_aci = O_acj ( O_gt ) ; if O_aci . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_aci . O_hd < O_acc . O_hd ) { O_acc = O_aci ; O_he = O_ec ; } } if ( O_abd && O_ev . O_oo == 0.0 ) { let O_ack = O_acl ( O_gt ) ; if O_ack . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_ack . O_hd < O_acc . O_hd ) { O_acc = O_ack ; O_he = O_ef ; } } if ( O_abe && O_ev . O_op == 0.0 ) { let O_acm = O_aaa ( O_gt ) ; if ( O_acm . O_hd > 0.0 && ( O_acc . O_hd < 0.0 || O_acm . O_hd < O_acc . O_hd ) ) { O_acc = O_acm ; O_he = O_eg ; } } return O_acb ( O_he , O_acc . O_hd , O_acc . O_bq , O_acc . O_lf , O_acc . O_hc ) ; } fn O_ye ( O_acn : vec3 < f32 > , O_k : vec3 < f32 > , O_ps : f32 , ) -> bool { let O_gt = O_fs ( O_acn , O_k ) ; let O_ha = O_hb ( O_gt , true , false , true ) ; return O_ha . O_he == O_ef || O_ha . O_hd < 0.00 ; } fn O_acl ( O_gt : O_fs , ) -> O_li { var O_ha = O_pb ( - 1.0 , vec3f ( 0 ) ) ; for ( var O_oe : i32 = 0 ; O_oe < O_eh ; O_oe ++ ) { if ( O_fg [ O_oe ] . O_wb == 1.0 ) { continue ; } let O_bn = O_aco ( O_gt , O_fg [ O_oe ] ) ; if ( O_bn . O_hd > 0 && ( O_ha . O_hd < 0 || O_bn . O_hd < O_ha . O_hd ) ) { O_ha = O_bn ; } } return O_li ( O_ha . O_hd , O_ha . O_bq , O_ll ( ) , - 1 ) ; } fn O_aco ( O_gt : O_fs , O_wg : O_fh , ) -> O_pb { let O_pz = O_wg . O_gy + O_wg . O_cn + O_wg . O_cm ; let O_mx = O_wg . O_gy + O_wg . O_cn ; let O_my = O_wg . O_gy + O_wg . O_cm ; let O_mz = O_wg . O_gy ; var O_hd = - 1.0 ; let O_qa = O_qd ( O_gt , O_qb ( O_pz , O_mx , O_my ) ) ; if ( O_qa > 0.0 && ( O_hd < 0.0 || O_qa < O_hd ) ) { O_hd = O_qa ; } let O_qc = O_qd ( O_gt , O_qb ( O_mx , O_my , O_mz ) ) ; if ( O_qc > 0.0 && ( O_hd < 0.0 || O_qc < O_hd ) ) { O_hd = O_qc ; } return O_pb ( O_hd , normalize ( cross ( O_wg . O_cn , O_wg . O_cm ) ) ) ; } fn O_ace ( O_gt : O_fs , ) -> O_li { var O_acp : i32 = 0 ; var O_acq = array < u32 , O_ea > ( ) ; O_acq [ 0 ] = 0 ; var O_hd = - 1.0 ; var O_bq : vec3 < f32 > ; var O_acr : u32 ; while ( O_acp >= 0 ) { let O_abm = O_acq [ O_acp ] ; O_acp -= 1 ; let O_kd = O_jo ( O_ft [ O_abm ] , O_ft [ O_abm + 1 ] , O_ft [ O_abm + 2 ] , O_ft [ O_abm + 3 ] , O_ft [ O_abm + 4 ] , O_ft [ O_abm + 5 ] ) ; let O_acs = O_pq ( O_gt , O_kd ) ; if ( O_acs < 0.0 || ( O_hd > 0.0 && O_acs > O_hd ) ) { continue ; } for ( var O_oe : u32 = 0 ; O_oe < 4 ; O_oe += 1 ) { var O_act = O_ft [ O_abm + 6 + O_oe ] ; if ( O_act > 0.0 ) { O_acp += 1 ; if ( O_acp >= O_ea ) { O_tq ( ) ; return O_lj ( ) ; } O_acq [ O_acp ] = u32 ( O_act ) - 1 ; } else if ( O_act < 0.0 ) { let O_acu = u32 ( - O_act ) - 1 ; let O_qe = O_acv ( O_acu ) ; let O_acw = O_qd ( O_gt , O_qe ) ; if ( O_acw < 0.0 || ( O_hd > 0.0 && O_acw > O_hd ) ) { continue ; } O_hd = O_acw ; O_acr = O_acu ; O_bq = O_se ( O_qe , O_acx ( O_acu ) , O_pa ( O_gt , O_acw ) ) ; } } } if ( O_hd < 0 ) { return O_lj ( ) ; } let O_hc = i32 ( O_fu [ O_acr ] . O_le ) ; let O_lf = O_fp [ O_hc ] ; return O_li ( O_hd , O_bq , O_lf , O_hc ) ; } fn O_acv ( O_abm : u32 , ) -> O_qb { let O_acy = u32 ( O_fu [ O_abm ] . O_ky ) ; let O_acz = u32 ( O_fu [ O_abm ] . O_kz ) ; let O_ada = u32 ( O_fu [ O_abm ] . O_la ) ; let O_ky = O_fw [ O_acy ] ; let O_kz = O_fw [ O_acz ] ; let O_la = O_fw [ O_ada ] ; return O_qb ( O_ky , O_kz , O_la ) ; } fn O_acx ( O_abm : u32 , ) -> array < vec3 < f32 > , 3 > { let O_adb = u32 ( O_fu [ O_abm ] . O_lb ) ; let O_adc = u32 ( O_fu [ O_abm ] . O_lc ) ; let O_add = u32 ( O_fu [ O_abm ] . O_ld ) ; let O_lb = O_fw [ O_adb ] ; let O_lc = O_fw [ O_adc ] ; let O_ld = O_fw [ O_add ] ; return array < vec3 < f32 > , 3 > ( O_lb , O_lc , O_ld ) ; } struct O_ge { O_gy : vec3f , O_ka : f32 , O_tb : f32 , O_ade : f32 , O_wb : f32 , O_uq : f32 , } fn O_acj ( O_gt : O_fs , ) -> O_li { let O_kb = O_gd . O_ka / 2.0 ; let O_zk = O_gd . O_tb / 2.0 ; let O_mg = O_gd . O_gy ; let O_kd = O_jo ( O_mg . x - O_kb , O_mg . y - O_zk , O_mg . z , O_mg . x + O_kb , O_mg . y + O_zk , O_mg . z + 0.5 ) ; let O_ha = O_pc ( O_gt , O_kd ) ; if ( O_ha . O_hd < 0 ) { return O_lj ( ) ; } let O_hc = i32 ( O_gd . O_ade ) ; let O_lf = O_fp [ O_hc ] ; return O_li ( O_ha . O_hd , O_ha . O_bq , O_lf , O_hc ) ; } fn O_acg ( O_gt : O_fs , ) -> O_li { var O_abg : O_li = O_adf ( O_gt ) ; if ( O_abg . O_hd < 0.0 ) { O_abg = O_adg ( O_gt ) ; } return O_abg ; } fn O_adf ( O_gt : O_fs , ) -> O_li { let O_adh = O_adi ( O_gt , O_gb . O_ov ) ; if ( O_adh . O_hd < 0.0 ) { return O_lj ( ) ; } let O_jw = O_adh . O_jw ; let O_hc = O_adj ( O_jw ) ; let O_lf = O_fp [ O_hc ] ; return O_li ( O_adh . O_hd , O_gb . O_ov . O_bq , O_lf , O_hc ) ; } fn O_adj ( O_jw : vec2 < f32 > , ) -> i32 { if ( O_adk ( O_jw , i32 ( O_ez . O_sq ) ) ) { return i32 ( O_fb . O_sx ) ; } let O_sz = ! O_adk ( O_jw , i32 ( O_ez . O_sr ) ) ; let O_sy = O_adk ( O_jw , i32 ( O_ez . O_ss ) ) ; if ( O_sz ) { if ( O_sy ) { return i32 ( O_fb . O_ta ) ; } else { return i32 ( O_fb . O_sz ) ; } } else { if ( O_sy ) { return i32 ( O_fb . O_sy ) ; } else { return i32 ( O_fb . O_sw ) ; } } } fn O_adg ( O_gt : O_fs , ) -> O_li { let O_adh = O_adi ( O_gt , O_gb . O_ox ) ; if ( O_adh . O_hd < 0.0 ) { return O_lj ( ) ; } let O_jw = O_adh . O_jw ; let O_hc = O_adl ( O_jw ) ; let O_lf = O_fp [ O_hc ] ; return O_li ( O_adh . O_hd , O_gb . O_ox . O_bq , O_lf , O_hc ) ; } fn O_adl ( O_jw : vec2 < f32 > , ) -> i32 { let O_sx = O_adk ( O_jw , i32 ( O_ez . O_st ) ) ; if ( O_sx ) { return i32 ( O_fb . O_sx ) ; } let O_sz = ! O_adk ( O_jw , i32 ( O_ez . O_su ) ) ; let O_sy = O_adk ( O_jw , i32 ( O_ez . O_sv ) ) ; if ( O_sz ) { if ( O_sy ) { return i32 ( O_fb . O_ta ) ; } else { return i32 ( O_fb . O_sz ) ; } } else { if ( O_sy ) { return i32 ( O_fb . O_sy ) ; } else { return i32 ( O_fb . O_sw ) ; } } } fn O_adm ( O_jw : vec3 < f32 > , ) -> vec2 < f32 > { return vec2 < f32 > ( O_jw . x , O_jw . y ) ; } fn O_adn ( ) -> O_kf { let O_ado = O_fx [ u32 ( O_ez . O_sp ) ] ; let O_kd = O_kf ( O_ado . O_jp , O_ado . O_js , O_ado . O_jq , O_ado . O_jt ) ; return O_kg ( O_kd , 1 ) ; } struct O_adp { O_hd : f32 , O_jw : vec2 < f32 > , } fn O_adi ( O_gt : O_fs , O_qv : O_ow , ) -> O_adp { let O_adh = O_qz ( O_gt , O_qv ) ; if ( O_adh . O_hd < 0.0 ) { return O_adp ( - 1.0 , vec2 < f32 > ( 0.0 ) ) ; } let O_adq = O_adm ( O_adh . O_jw ) ; let O_kd = O_adn ( ) ; if ( ! O_ki ( O_kd , O_adq ) ) { return O_adp ( - 1.0 , vec2 < f32 > ( 0.0 ) ) ; } return O_adp ( O_adh . O_hd , O_adq ) ; } fn O_adk ( O_jw : vec2f , O_adr : i32 , ) -> bool { if ( O_adr < 0 ) { return false ; } var O_acq = array < i32 , 22 > ( ) ; O_acq [ 0 ] = i32 ( O_adr ) ; var O_acp : i32 = 1 ; var O_ads : i32 = 0 ; while ( O_acp > 0 ) { let O_abm = O_acq [ O_acp - 1 ] ; O_acp -= 1 ; let O_adt = O_fx [ O_abm ] ; let O_kd = O_kf ( O_adt . O_jp , O_adt . O_js , O_adt . O_jq , O_adt . O_jt ) ; if ( ! O_ki ( O_kd , O_jw ) ) { continue ; } var O_adu = array < i32 , 2 > ( ) ; O_adu [ 0 ] = i32 ( O_adt . O_lm ) ; O_adu [ 1 ] = i32 ( O_adt . O_ln ) ; for ( var O_oe = 0 ; O_oe < 2 ; O_oe += 1 ) { let O_adv = O_adu [ O_oe ] ; if ( O_adv > 0 ) { O_acq [ O_acp ] = O_adv - 1 ; O_acp += 1 ; } else if ( O_adv < 0 ) { let O_adw = - 1 * O_adv - 1 ; let O_ha = O_adx ( O_jw , O_adw ) ; if ( O_ha == O_da ) { return true ; } if ( O_ha == O_dd ) { O_ads -= 1 ; } if ( O_ha == O_dc ) { O_ads += 1 ; } } } } return O_ads != 0 ; } fn O_adx ( O_jw : vec2f , O_adw : i32 , ) -> u32 { let O_ady = i32 ( O_adw ) ; switch u32 ( O_fz [ O_ady ] ) { case O_dt : { let O_adz = O_jw ; var O_aea = vec2 ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; var O_aeb = vec2 ( O_fz [ O_ady + 3 ] , O_fz [ O_ady + 4 ] ) ; var O_iy = normalize ( O_aeb - O_aea ) ; let O_aec = O_fz [ O_ady + 5 ] ; O_aea = O_aea + O_iy * O_aec * 0.5 ; O_aeb = O_aeb - O_iy * O_aec * 0.5 ; if ( ( length ( O_jw - O_aeb ) < ( O_aec / 2.0 ) ) || ( length ( O_jw - O_aea ) < ( O_aec / 2.0 ) ) ) { return O_da ; } let O_oy = O_aeb - O_aea ; let O_aed = dot ( O_oy , O_oy ) ; let O_aee = O_adz - O_aea ; let O_hd = dot ( O_aee , O_oy ) / O_aed ; if ( O_hd < 0.0 || O_hd > 1.0 ) { return O_db ; } let O_aef = O_aea + O_hd * O_oy ; let distance = length ( O_adz - O_aef ) ; if ( distance <= O_aec / 2.0 ) { return O_da ; } else { return O_db ; } } case O_de : { let O_qp = vec2f ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; let O_bn = O_fz [ O_ady + 3 ] ; if ( length ( O_jw - O_qp ) < O_bn ) { return O_da ; } else { return O_db ; } } case O_dg : { let O_aeg : vec2 < f32 > = vec2f ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; let O_ka : f32 = O_fz [ O_ady + 3 ] ; let O_tb : f32 = O_fz [ O_ady + 4 ] ; let O_co : f32 = O_fz [ O_ady + 5 ] ; let O_qr : f32 = O_fz [ O_ady + 6 ] ; if ( O_jw . x > O_aeg . x + O_qr && O_jw . x < O_aeg . x + O_ka - O_qr ) { if ( O_jw . y > O_aeg . y - O_tb && O_jw . y < O_aeg . y ) { return O_da ; } } if ( O_jw . x > O_aeg . x && O_jw . x < O_aeg . x + O_ka ) { if ( O_jw . y > O_aeg . y - O_tb + O_qr && O_jw . y < O_aeg . y - O_qr ) { return O_da ; } } if ( length ( O_jw - ( O_aeg + vec2f ( O_qr , - O_qr ) ) ) < O_qr ) { return O_da ; } if ( length ( O_jw - ( O_aeg + vec2f ( O_ka - O_qr , - O_qr ) ) ) < O_qr ) { return O_da ; } if ( length ( O_jw - ( O_aeg + vec2f ( O_qr , O_qr - O_tb ) ) ) < O_qr ) { return O_da ; } if ( length ( O_jw - ( O_aeg + vec2f ( O_ka - O_qr , O_qr - O_tb ) ) ) < O_qr ) { return O_da ; } return O_db ; } case O_dk : { let O_ky : vec2 < f32 > = vec2f ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; let O_kz : vec2 < f32 > = vec2f ( O_fz [ O_ady + 3 ] , O_fz [ O_ady + 4 ] ) ; let O_la : vec2 < f32 > = vec2f ( O_fz [ O_ady + 5 ] , O_fz [ O_ady + 6 ] ) ; let O_aeh = O_fz [ O_ady + 6 ] ; let O_aei = O_kz - O_ky ; let O_aej = O_la - O_ky ; let O_aek = O_jw - O_ky ; let O_rn = dot ( O_aej , O_aej ) ; let O_ro = dot ( O_aej , O_aei ) ; let O_rp = dot ( O_aej , O_aek ) ; let O_rq = dot ( O_aei , O_aei ) ; let O_rr = dot ( O_aei , O_aek ) ; let O_rs = 1.0 / ( O_rn * O_rq - O_ro * O_ro ) ; let O_cn = ( O_rq * O_rp - O_ro * O_rr ) * O_rs ; let O_cm = ( O_rn * O_rr - O_ro * O_rp ) * O_rs ; if ( ( O_cn >= 0.0 ) && ( O_cm >= 0.0 ) && ( O_cn + O_cm <= 1.0 ) ) { if ( 0.5 * ( O_ky . x * ( O_kz . y - O_la . y ) + O_kz . x * ( O_la . y - O_ky . y ) + O_la . x * ( O_ky . y - O_kz . y ) ) < 0.0 ) { return O_dc ; } else { return O_dd ; } } else { return O_db ; } } case O_dl : { let O_qp = vec2f ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; let O_bn = O_fz [ O_ady + 3 ] ; var O_ael = O_fz [ O_ady + 4 ] ; let O_aem = O_fz [ O_ady + 5 ] ; let O_aen = vec2f ( O_fz [ O_ady + 6 ] , O_fz [ O_ady + 7 ] ) ; let O_aeo = vec2f ( O_fz [ O_ady + 8 ] , O_fz [ O_ady + 9 ] ) ; let O_aep = O_jw . x - O_qp . x ; let O_aeq = O_jw . y - O_qp . y ; let O_aer = O_aep * O_aep + O_aeq * O_aeq ; if ( O_aer > O_bn * O_bn ) { return O_db ; } let O_ky = O_qp ; let O_kz = O_aen ; let O_la = O_aeo ; let O_aei = O_kz - O_ky ; let O_aej = O_la - O_ky ; let O_aek = O_jw - O_ky ; let O_rn = dot ( O_aej , O_aej ) ; let O_ro = dot ( O_aej , O_aei ) ; let O_rp = dot ( O_aej , O_aek ) ; let O_rq = dot ( O_aei , O_aei ) ; let O_rr = dot ( O_aei , O_aek ) ; let O_rs = 1.0 / ( O_rn * O_rq - O_ro * O_ro ) ; let O_cn = ( O_rq * O_rp - O_ro * O_rr ) * O_rs ; let O_cm = ( O_rn * O_rr - O_ro * O_rp ) * O_rs ; if ( ( O_cn >= 0.0 ) && ( O_cm >= 0.0 ) && ( O_cn + O_cm <= 1.0 ) ) { if ( abs ( O_aem ) >= O_ao ) { if ( O_aem > 0.0 ) { return O_dd ; } else { return O_dc ; } } else { return O_db ; } } if ( abs ( O_aem ) >= O_cr ) { if ( O_aem > 0 ) { return O_dd ; } else { return O_dc ; } } O_ael = O_ael % O_cr ; if ( O_ael < 0.0 ) { O_ael = O_ael + O_cr ; } var O_aes = atan2 ( O_aeq , O_aep ) ; if ( O_aes < 0.0 ) { O_aes = O_aes + O_cr ; } var O_aet = O_ael + O_aem ; if ( O_aem >= 0.0 ) { if ( O_aet >= O_cr ) { O_aet = O_aet - O_cr ; } if ( O_aet > O_ael ) { if ( O_aes > O_ael && O_aes < O_aet ) { return O_dd ; } else { return O_db ; } } else { if ( O_aes > O_ael || O_aes < O_aet ) { return O_dd ; } else { return O_db ; } } } else { if ( O_aet < 0.0 ) { O_aet = O_aet + O_cr ; } if ( O_aet < O_ael ) { if ( O_aes > O_ael && O_aes < O_aet ) { return O_dc ; } else { return O_db ; } } else { if ( O_aes < O_ael || O_aes > O_aet ) { return O_dc ; } else { return O_db ; } } } } case O_df : { let O_qp = vec2f ( O_fz [ O_ady + 1 ] , O_fz [ O_ady + 2 ] ) ; let O_qr = O_fz [ O_ady + 3 ] ; let O_ka = O_fz [ O_ady + 4 ] ; var O_ael = O_fz [ O_ady + 5 ] ; let O_aem = O_fz [ O_ady + 6 ] ; let O_aeu = O_ka / 2.0 ; let O_aev = length ( O_jw - O_qp ) ; if ( O_aev < ( O_qr - O_aeu ) || O_aev > ( O_qr + O_aeu ) ) { return O_db ; } var O_aet = O_ael + O_aem ; let O_aen = vec2f ( O_qp . x + cos ( O_ael ) * O_qr , O_qp . y + sin ( O_ael ) * O_qr ) ; let O_aeo = vec2f ( O_qp . x + cos ( O_aet ) * O_qr , O_qp . y + sin ( O_aet ) * O_qr ) ; if ( length ( O_jw - O_aen ) < O_aeu || length ( O_jw - O_aeo ) < O_aeu ) { return O_da ; } O_ael = O_ael % O_cr ; if ( O_ael < 0.0 ) { O_ael = O_ael + O_cr ; } var O_aes = atan2 ( O_jw . y - O_qp . y , O_jw . x - O_qp . x ) ; if ( O_aes < 0.0 ) { O_aes = O_aes + O_cr ; } if ( O_aem >= 0.0 ) { if ( O_aet >= O_cr ) { O_aet = O_aet - O_cr ; } if ( O_aet > O_ael ) { if ( O_aes > O_ael && O_aes < O_aet ) { return O_da ; } else { return O_db ; } } else { if ( O_aes > O_ael || O_aes < O_aet ) { return O_da ; } else { return O_db ; } } } else { if ( O_aet < 0.0 ) { O_aet = O_aet + O_cr ; } if ( O_aet < O_ael ) { if ( O_aes > O_ael && O_aes < O_aet ) { return O_da ; } else { return O_db ; } } else { if ( O_aes < O_ael || O_aes > O_aet ) { return O_da ; } else { return O_db ; } } } } default : { O_hf ( vec3 < f32 > ( 1 , 0 , 0 ) ) ; break ; } } return O_db ; } struct O_fh { O_wb : f32 , O_tk : vec3 < f32 > , O_wc : f32 , O_gy : vec3 < f32 > , O_cn : vec3 < f32 > , O_cm : vec3 < f32 > , O_wp : f32 , O_s : f32 , O_aew : f32 , O_wf : f32 , O_aex : f32 , } fn O_abh ( ) -> vec3 < f32 > { let O_wa = O_aey ( ) ; return O_wa . O_tk * O_wa . O_wc ; } fn O_aey ( ) -> O_fh { var O_abm = i32 ( O_bl ( ) * 3.0 ) ; if ( O_abm >= 3 ) { O_abm = 0 ; } return O_fg [ O_abm ] ; } struct O_wi { O_xr : vec3 < f32 > , O_xt : vec3 < f32 > , O_xv : f32 , O_xx : f32 , O_iy : vec3 < f32 > , O_xz : f32 , O_wj : f32 , O_wk : f32 , } struct O_wh { O_ww : vec3 < f32 > , O_wa : O_wi , } struct O_aez { O_acn : vec3 < f32 > , O_afa : vec3 < f32 > , O_ax : vec3 < f32 > , O_hd : f32 , O_uu : f32 , O_yl : f32 , O_cn : f32 , O_cm : f32 , } struct O_afb { O_wz : bool , O_afc : vec3 < f32 > , O_wy : O_aez , } fn O_afd ( O_wg : O_wi , ) -> bool { return O_wg . O_xz < 0.0 ; } fn O_afe ( O_afa : vec3 < f32 > , O_aff : vec3 < f32 > , O_hd : f32 , ) -> f32 { let O_afg = dot ( O_afa , O_aff ) ; if ( O_afg <= 0.0 ) { return 0.0 ; } return O_hd * O_hd / O_afg ; } fn O_afh ( O_ax : vec3 < f32 > , O_afi : vec3 < f32 > , O_wj : f32 , O_wk : f32 , ) -> f32 { let O_afj = O_ia ( - O_ax , O_afi ) ; if ( O_wj == 0.0 ) { return select ( 0.0 , O_ao , O_afj > 1e-5 ) ; } return max ( ( O_wj - O_afj ) * O_wk , 0.0 ) ; } struct O_afk { O_wz : bool , O_afl : vec3 < f32 > , O_xr : vec3 < f32 > , O_xv : f32 , O_xt : vec3 < f32 > , O_xx : f32 , O_afm : bool , } fn O_afn ( O_acn : vec3 < f32 > , O_afi : vec3 < f32 > , O_afl : vec3 < f32 > , O_xr : vec3 < f32 > , O_xv : f32 , O_xt : vec3 < f32 > , O_xx : f32 , O_wj : f32 , O_afm : bool , ) -> O_afk { let O_hd = dot ( O_afi , O_acn - O_afl ) ; let O_afo = O_acn - O_hd * O_afi ; let O_afp = O_hd * O_wj ; let O_afq = dot ( O_xr , O_afo - O_afl ) ; let O_afr = dot ( O_xt , O_afo - O_afl ) ; var O_bb : O_afk ; O_bb . O_afl = O_afl ; O_bb . O_xr = O_xr ; O_bb . O_xv = O_xv ; O_bb . O_xt = O_xt ; O_bb . O_xx = O_xx ; O_bb . O_afm = O_afm ; let O_afs = ! O_afm && ( O_xv == O_xx ) ; var O_aft = ( O_afp == 0.0 ) ; if ( O_afs && ! O_aft ) { let O_mn = length ( vec2 < f32 > ( O_afq , O_afr ) ) ; let O_bn = O_xv * 0.5 ; if ( O_mn >= O_bn + O_afp ) { O_bb . O_wz = false ; return O_bb ; } O_aft = ( O_mn <= abs ( O_bn - O_afp ) ) && ( O_afp < O_bn ) ; if ( O_mn > abs ( O_bn - O_afp ) ) { let O_afu = O_bn + O_afp - O_mn ; let O_afv = select ( 2.0 * min ( O_bn , O_afp ) , sqrt ( O_ip ( 2.0 * O_afp ) - O_ip ( O_mn + ( O_ip ( O_afp ) - O_ip ( O_bn ) ) / O_mn ) ) , abs ( O_ip ( O_bn ) - O_ip ( O_afp ) ) >= O_ip ( O_mn ) ) ; let O_afw = O_afu * O_afv ; let O_afx = O_ao * O_ip ( O_bn ) ; let O_afy = O_ao * O_ip ( O_afp ) ; if ( O_afw < min ( O_afx , O_afy ) ) { O_bb . O_afm = true ; O_bb . O_xr = O_iv ( O_bb . O_afl - O_afo ) ; O_bb . O_xt = O_ie ( O_bb . O_xr , O_afi , O_cs ) ; O_bb . O_xv = O_afu ; O_bb . O_xx = O_afv ; O_bb . O_afl = 0.5 * ( O_bb . O_afl + O_afo + O_bb . O_xr * ( O_afp - O_bn ) ) ; O_bb . O_wz = true ; return O_bb ; } O_aft = ( O_afy < O_afx ) ; } } else if ( ! O_afs && ! O_aft ) { let O_afz = max ( O_afq - O_afp , - O_bb . O_xv * 0.5 ) ; let O_aga = min ( O_afq + O_afp , O_bb . O_xv * 0.5 ) ; let O_agb = max ( O_afr - O_afp , - O_bb . O_xx * 0.5 ) ; let O_agc = min ( O_afr + O_afp , O_bb . O_xx * 0.5 ) ; if ( O_afz >= O_aga || O_agb >= O_agc ) { O_bb . O_wz = false ; return O_bb ; } let O_agd = O_aga - O_afz ; let O_age = O_agc - O_agb ; let O_afw = O_agd * O_age ; let O_agf = select ( O_cv , O_ao * 0.25 * O_bb . O_xv * O_bb . O_xx , ! O_bb . O_afm ) ; let O_afy = O_ao * O_ip ( O_afp ) ; if ( O_bb . O_afm || O_afw < min ( O_agf , O_afy ) ) { O_bb . O_afm = true ; let O_agg = 0.5 * ( O_afz + O_aga ) ; let O_agh = 0.5 * ( O_agb + O_agc ) ; O_bb . O_xv = O_agd ; O_bb . O_xx = O_age ; O_bb . O_afl = O_bb . O_afl + O_bb . O_xr * O_agg + O_bb . O_xt * O_agh ; O_bb . O_wz = true ; return O_bb ; } O_bb . O_afm = false ; O_aft = ( O_afy < O_agf ) ; } if ( O_aft ) { O_bb . O_afm = false ; O_bb . O_afl = O_bb . O_afl + O_bb . O_xr * O_afq + O_bb . O_xt * O_afr ; O_bb . O_xv = O_afp * 2.0 ; O_bb . O_xx = O_afp * 2.0 ; O_bb . O_wz = true ; return O_bb ; } O_bb . O_wz = true ; return O_bb ; } struct O_agi { O_uu : f32 , O_agj : vec3 < f32 > , } fn O_agk ( O_acn : vec3 < f32 > , O_agj : vec3 < f32 > , O_xr : vec3 < f32 > , O_xv : f32 , O_xt : vec3 < f32 > , O_xx : f32 , O_hs : vec2 < f32 > , O_agl : bool , ) -> O_agi { let O_cj = O_xr ; let O_jd = O_xt ; var O_vs = cross ( O_cj , O_jd ) ; var O_agm = O_agj ; let O_iy = O_agm - O_acn ; var O_agn = dot ( O_iy , O_vs ) ; if ( O_agn > 0.0 ) { O_vs = - O_vs ; O_agn = - O_agn ; } let O_ago = dot ( O_iy , O_cj ) ; let O_agp = dot ( O_iy , O_jd ) ; let O_agq = O_ago - 0.5 * O_xv ; let O_agr = O_ago + 0.5 * O_xv ; let O_ags = O_agp - 0.5 * O_xx ; let O_agt = O_agp + 0.5 * O_xx ; var O_agu = vec4 < f32 > ( - O_ags , O_agr , O_agt , - O_agq ) ; O_agu = O_agu / sqrt ( O_agu * O_agu + vec4 < f32 > ( O_agn * O_agn ) ) ; let O_agv = O_iz ( - O_agu . x * O_agu . y ) ; let O_agw = O_iz ( - O_agu . y * O_agu . z ) ; let O_agx = O_iz ( - O_agu . z * O_agu . w ) ; let O_agy = O_iz ( - O_agu . w * O_agu . x ) ; let O_agz = - ( O_agv + O_agw + O_agx + O_agy ) ; if ( O_agl ) { let O_aha = O_agu . x ; let O_ahb = O_agu . z ; let O_ahc = O_aha * O_aha ; let O_ahd = O_hs . x * O_agz + O_agx + O_agy ; let O_ahe = O_ja ( cos ( O_ahd ) * O_aha + O_ahb , sin ( O_ahd ) ) ; var O_ahf = O_jc ( 1.0 / sqrt ( O_ahe * O_ahe + O_ahc ) , O_ahe ) ; O_ahf = clamp ( O_ahf , - 1.0 , 1.0 ) ; var O_ahg = - ( O_ahf * O_agn ) / max ( sqrt ( 1.0 - O_ahf * O_ahf ) , 1e-7 ) ; O_ahg = clamp ( O_ahg , O_agq , O_agr ) ; let O_ahh = O_ip ( O_ahg ) + O_ip ( O_agn ) ; let O_ahi = O_ags / sqrt ( O_ahh + O_ip ( O_ags ) ) ; let O_ahj = O_agt / sqrt ( O_ahh + O_ip ( O_agt ) ) ; let O_ahk = O_ahi + O_hs . y * ( O_ahj - O_ahi ) ; let O_ahl = O_ahk * O_ahk ; let O_ahm = select ( O_agt , O_ahk * sqrt ( O_ahh / ( 1.0 - O_ahl ) ) , O_ahl < 1.0 - 1e-6 ) ; O_agm = O_acn + O_ahg * O_cj + O_ahm * O_jd + O_agn * O_vs ; } var O_bb : O_agi ; O_bb . O_agj = O_agm ; if ( O_agz < 1e-5 || O_it ( O_ir ( O_agu ) ) > 0.99999 ) { let O_hd = O_id ( O_iy ) ; O_bb . O_uu = O_ja ( - O_hd * O_hd * O_hd , ( O_agn * O_xv * O_xx ) ) ; } else { O_bb . O_uu = 1.0 / O_agz ; } return O_bb ; } fn O_wv ( O_ahn : O_wh , O_aho : vec3 < f32 > , O_ahp : vec3 < f32 > , O_hs : vec2 < f32 > , O_agl : bool , O_ahq : bool , ) -> O_afb { var O_xr = O_ahn . O_wa . O_xr ; var O_xt = O_ahn . O_wa . O_xt ; var O_xv = O_ahn . O_wa . O_xv ; var O_xx = O_ahn . O_wa . O_xx ; let O_afa = - O_ahn . O_wa . O_iy ; let O_xz = abs ( O_ahn . O_wa . O_xz ) ; var O_afm = O_ahn . O_wa . O_xz > 0.0 ; var O_ahr = O_ahp ; var O_wy : O_aez ; O_wy . O_acn = O_ahp ; O_wy . O_afa = O_afa ; O_wy . O_ax = vec3 < f32 > ( 0.0 ) ; O_wy . O_hd = 0.0 ; O_wy . O_uu = 0.0 ; O_wy . O_yl = 0.0 ; O_wy . O_cn = 0.0 ; O_wy . O_cm = 0.0 ; if ( O_ahq ) { if ( O_afm ) { O_ahr = O_ahr + O_hv ( O_xr * ( O_xv * 0.5 ) , O_xt * ( O_xx * 0.5 ) , O_hs ) ; } else { O_ahr = O_ahr + O_hy ( O_xr * ( O_xv * 0.5 ) , O_xt * ( O_xx * 0.5 ) , O_hs ) ; } O_wy . O_uu = O_xz ; } else { if ( O_ahn . O_wa . O_wk > 0.0 ) { let O_ahs = O_afn ( O_aho , O_afa , O_ahr , O_xr , O_xv , O_xt , O_xx , O_ahn . O_wa . O_wj , O_afm ) ; if ( ! O_ahs . O_wz ) { return O_afb ( false , O_ahp , O_wy ) ; } O_ahr = O_ahs . O_afl ; O_xr = O_ahs . O_xr ; O_xv = O_ahs . O_xv ; O_xt = O_ahs . O_xt ; O_xx = O_ahs . O_xx ; O_afm = O_ahs . O_afm ; } if ( O_afm ) { let O_aht = O_agk ( O_aho , O_ahr , O_xr , O_xv , O_xt , O_xx , O_hs , O_agl ) ; O_wy . O_uu = O_aht . O_uu ; O_ahr = O_aht . O_agj ; } else { if ( O_ahn . O_wa . O_wj == 0.0 ) { O_wy . O_uu = 1.0 ; } else { if ( O_agl ) { O_ahr = O_ahr + O_hy ( O_xr * ( O_xv * 0.5 ) , O_xt * ( O_xx * 0.5 ) , O_hs ) ; } O_wy . O_uu = 4.0 * O_t / ( O_xv * O_xx ) ; } } } O_wy . O_acn = O_ahr ; let O_bu = O_ix ( O_wy . O_acn - O_aho ) ; O_wy . O_ax = O_bu . xyz ; O_wy . O_hd = O_bu . w ; O_wy . O_yl = O_t * O_xz ; if ( O_ahn . O_wa . O_wk > 0.0 ) { let O_wf = O_afh ( O_wy . O_ax , O_afa , O_ahn . O_wa . O_wj , O_ahn . O_wa . O_wk ) ; O_wy . O_yl = O_wy . O_yl * O_wf ; } if ( O_ahq || ( ! O_afm && O_ahn . O_wa . O_wj > 0.0 ) ) { O_wy . O_uu = O_wy . O_uu * O_afe ( O_afa , - O_wy . O_ax , O_wy . O_hd ) ; } let O_wz = O_ahq || ( O_wy . O_yl > 0.0 ) ; return O_afb ( O_wz , O_ahr , O_wy ) ; } fn O_ahu ( O_wf : f32 , ) -> f32 { let O_ahv = 0.5 * max ( O_wf , 0.0 ) ; if ( O_ahv <= 0.0 ) { return O_cv ; } let O_wj = select ( O_cv , tan ( O_ahv ) , O_wf < O_ao ) ; if ( O_ahv > 0.05 ) { return 1.0 / ( O_wj - O_ahv ) ; } else { let O_ahw = O_ahv * O_ahv * O_ahv ; return 3.0 / O_ahw ; } } struct O_ahx { O_wj : f32 , O_wk : f32 , } fn O_we ( O_wf : f32 , ) -> O_ahx { let O_ahv = 0.5 * max ( O_wf , 0.0 ) ; var O_bb : O_ahx ; if ( O_ahv <= 0.0 ) { O_bb . O_wj = 0.0 ; O_bb . O_wk = O_cv ; return O_bb ; } O_bb . O_wj = select ( O_cv , tan ( O_ahv ) , O_wf < O_ao ) ; if ( O_ahv > 0.05 ) { O_bb . O_wk = 1.0 / ( O_bb . O_wj - O_ahv ) ; } else { let O_ahw = O_ahv * O_ahv * O_ahv ; O_bb . O_wk = 3.0 / O_ahw ; } return O_bb ; } ";vl.addShaderCode(wA);var qX=class Oy{constructor(t,i,r,s,n,a,o){this.gpu=t,this.camera=i,this.light=r,this.model=s,this.background=n,this.ray=a,this.pixelTool=o,this.parameter=new WX(t,n,r),this.initBuffers(),this.initLayout(),this.initBind(),this.initPipeline()}static async warm(t,i){bI.time("path tracing warm"),await t.device.queue.onSubmittedWorkDone(),this.cache.set(t,await this.createCache(t,i)),await t.device.queue.onSubmittedWorkDone(),bI.timeEnd("path tracing warm")}static async createCache(t,i){let r=l(t,[["storage","uniform","uniform","uniform","uniform","uniform","float","uniform"],["float","float","float","float","float","float","float","read-only-storage"],["read-only-storage","read-only-storage","read-only-storage","read-only-storage","read-only-storage","read-only-storage","storage","uniform","uniform"],["float","storage"]]),s=await o("main","path tracing pipeline  entrypoint main"),n=await o("main_hit","ray tracing calculation 1"),a=await o("main_demo","ray ");return{layouts:{0:r[0],1:r[1],2:r[2],3:r[3]},pipeline:{pathTracing:s,rayHitQuery:n,directColor:a}};async function o(c,d){let f=t.device.createPipelineLayout({bindGroupLayouts:Object.values(r)}),u={Image_Width:i.width,Image_Height:i.height};return await t.createComputePipelineAsync(wA,c,d,f,u)}function l(c,d){return d.map(f=>{let u=[];return f.forEach((p,g)=>{let _={binding:g,visibility:GPUShaderStage.COMPUTE},y=h(p);u.push({..._,...y})}),c.device.createBindGroupLayout({entries:u})})}function h(c){switch(c){case"uniform":case"storage":case"read-only-storage":return{buffer:{type:c}};case"float":case"unfilterable-float":case"depth":case"sint":case"uint":return{texture:{sampleType:c}}}}}getParameter(){return this.parameter}getBuffer(){return this.buffers}rebind(){this.initBind()}reset(){let t=this.gpu.device.createCommandEncoder();this.buffers.geometry.clear(t),this.buffers.hdrColor.clear(t),this.buffers.depth.clear(t),this.buffers.position.clear(t),this.gpu.submit(t),this.updateParameter()}run(){this.updateParameter();{let t=this.gpu.device.createCommandEncoder(),i=t.beginComputePass();i.setPipeline(this.pipelines.pathTracing);for(let[r,s]of Object.entries(this.bindGroups))i.setBindGroup(Number(r),s);i.dispatchWorkgroups(this.pixelTool.workgroupInfo.count),i.end(),this.gpu.submit(t)}this.geometryDismantle.run()}async runAsync(){await this.gpu.device.queue.onSubmittedWorkDone();let t=performance.now();return this.run(),await this.gpu.device.queue.onSubmittedWorkDone(),performance.now()-t}async runRayHitQueryAsync(){await this.gpu.device.queue.onSubmittedWorkDone();{let i=this.gpu.device.createCommandEncoder(),r=i.beginComputePass();r.setPipeline(this.pipelines.rayHitQuery);for(let[s,n]of Object.entries(this.bindGroups))r.setBindGroup(Number(s),n);r.dispatchWorkgroups(1),r.end(),this.gpu.submit(i)}await this.gpu.device.queue.onSubmittedWorkDone();let t=await this.buffers.log.read();return{isLight:t[2]===5,...t[1]===-1?{}:{materialIndex:t[0],depth:t[1]}}}runDirectColor(){let t=this.gpu.device.createCommandEncoder(),i=t.beginComputePass();i.setPipeline(this.pipelines.directColor);for(let[r,s]of Object.entries(this.bindGroups))i.setBindGroup(Number(r),s);i.dispatchWorkgroups(Math.ceil(this.getSize().width/8),Math.ceil(this.getSize().height/8)),i.end(),this.gpu.submit(t),this.geometryDismantle.run()}async runDirectColorAsync(){await this.gpu.device.queue.onSubmittedWorkDone();let t=performance.now();return this.runDirectColor(),await this.gpu.device.queue.onSubmittedWorkDone(),performance.now()-t}getSize(){return this.camera.size}updateParameter(){let t=this.pixelTool.pixelStart,i=Math.random();this.parameter.update({pixelStart:t,randomSeed:i})}initPipeline(){this.pipelines=Oy.cache.get(this.gpu).pipeline}initBuffers(){let t=this.gpu.createStorageDynamicBuffer(this.camera.size.width*this.camera.size.height*4*4,"RayTracerCalculationRenderer image buffer");this.geometryDismantle=new YX(this.gpu,this.camera.size,t),this.buffers={depth:this.geometryDismantle.getBuffers().depth,position:this.geometryDismantle.getBuffers().position,hdrColor:this.geometryDismantle.getBuffers().hdrColor,normal:this.geometryDismantle.getBuffers().normal,type:this.geometryDismantle.getBuffers().type,geometry:t,pixel:this.pixelTool.buffer,log:this.gpu.createDynamicBuffer(3,GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC,"log buffer")}}initLayout(){this.layouts=Oy.cache.get(this.gpu).layouts}initBind(){this.bindGroups={0:this.gpu.device.createBindGroup({label:"ray tracing calculation bind group 0",layout:this.layouts[0],entries:[{binding:0,resource:{buffer:this.buffers.geometry.getBuffer()}},{binding:1,resource:{buffer:this.parameter.buffer.getBuffer()}},{binding:2,resource:{buffer:this.camera.buffer.getBuffer()}},{binding:3,resource:{buffer:this.model.pcb.bvhIndex.getBuffer()}},{binding:4,resource:{buffer:this.model.pcb.material.getBuffer()}},{binding:5,resource:{buffer:this.model.board.parameter.getBuffer()}},{binding:6,resource:this.background.texture.view},{binding:7,resource:{buffer:this.light.buffer.getBuffer()}}]}),1:this.model.material.bindGroup,2:this.gpu.device.createBindGroup({label:"ray tracing calculation bind group 2",layout:this.layouts[2],entries:[{binding:0,resource:{buffer:this.ray.getBuffer()}},{binding:1,resource:{buffer:this.model.obj.getBVH().getBuffer()}},{binding:2,resource:{buffer:this.model.obj.getFace().getBuffer()}},{binding:3,resource:{buffer:this.model.obj.getVertexAndNormal().getBuffer()}},{binding:4,resource:{buffer:this.model.pcb.bvh.getBuffer()}},{binding:5,resource:{buffer:this.model.pcb.pt.getBuffer()}},{binding:6,resource:{buffer:this.buffers.log.getBuffer()}},{binding:7,resource:{buffer:this.model.pcb.layerInfo.getBuffer()}},{binding:8,resource:{buffer:this.model.occluder.buffer.getBuffer()}}]}),3:this.gpu.device.createBindGroup({label:"ray tracing calculation bind group 3",layout:this.layouts[3],entries:[{binding:0,resource:this.model.board.texture.view},{binding:1,resource:{buffer:this.buffers.pixel.getBuffer()}}]})}}};qX.cache=new Map;var TA=class{static get lambert(){return this.cache[0]}static get disney(){return this.cache[1]}static get(e){return this.cache.find(t=>t[0]===e)}static all(){return this.cache.map(e=>e[0])}};TA.cache=[["lambert",0],["disney",1]];var WX=class{constructor(e,t,i){this.gpu=e,this._background=t,this._light=i,this._maxRayBounces=1,this._randomSeed=Math.random(),this._pixelStart=0,this._diffuseMode=TA.disney,this._hideBoard=!1,this._hideOccluder=!1,this._hidePCB=!1,this._hideOBJ=!1,this._hideLight=!1,this._hideCoordinate=!1,this.buffer=this.gpu.createUniformDynamicBuffer(this._getData(),"parameters buffer of raytracer."),this._light.setListen(this._update.bind(this)),this._background.setListen(this._update.bind(this))}get hideCoordinate(){return this._hideCoordinate}set hideCoordinate(e){this._hideCoordinate=e,this._update()}get hideBoard(){return this._hideBoard}set hideBoard(e){this._hideBoard=e,this._update()}get hideOccluder(){return this._hideOccluder}set hideOccluder(e){this._hideOccluder=e,this._update()}get hidePCB(){return this._hidePCB}set hidePCB(e){this._hidePCB=e,this._update()}get hideOBJ(){return this._hideOBJ}set hideOBJ(e){this._hideOBJ=e,this._update()}get hideLight(){return this._hideLight}set hideLight(e){this._hideLight=e,this._update()}get maxRayBounces(){return this._maxRayBounces}set diffuseMode(e){this._diffuseMode=e,this._update()}get diffuseMode(){return this._diffuseMode}setMaxRayBounces(e){this._maxRayBounces=e,this._update()}update(e){let{pixelStart:t,randomSeed:i}=e;this._randomSeed=i,this._pixelStart=t,this._update()}_getData(){let e={random_seed:this._randomSeed,pixelStart:this._pixelStart,max_ray_bounces:this._maxRayBounces,diffuseMode:this._diffuseMode[1],hideBoard:this._hideBoard,hideOccluder:this._hideOccluder,hidePCB:this._hidePCB,hideOBJ:this._hideOBJ,hideLight:this._hideLight,hide_coordinate:this._hideCoordinate,backgroundRotation:this._background.getRotatoin(),backgroundIntensity:this._background.getIntensity(),backgroundColor:this._background.getColor(),backgroundSource:this._background.isUseColor(),lightIsOpen:this._light.getIsOpen()},t=yA(e);return new Float32Array(t)}_update(){this.gpu.writeBuffer(this.buffer,0,new Float32Array(this._getData()))}};var XX="struct O_a { O_b : vec3 < f32 > , O_c : vec3 < f32 > , O_d : vec3 < f32 > , O_e : vec3 < f32 > , O_f : vec3 < f32 > , O_g : f32 , O_h : f32 , O_i : f32 , O_j : f32 , O_k : vec3f , } struct O_l { O_m : f32 , O_n : f32 , } @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_o : array < f32 > ; @ group ( 0 ) @ binding ( 1 ) var < uniform > O_p : O_a ; @ group ( 0 ) @ binding ( 2 ) var < uniform > O_q : O_l ; @ group ( 0 ) @ binding ( 3 ) var < storage , read_write > O_r : array < vec2 < f32 > > ; override Image_Width : u32 ; override Image_Height : u32 ; var < private > O_m : f32 ; @ compute @ workgroup_size ( 64 ) fn main ( @ builtin ( global_invocation_id ) O_s : vec3 < u32 > , ) { let O_t = vec2 < u32 > ( u32 ( O_r [ O_s . x + u32 ( O_q . O_n ) ] . x ) , u32 ( O_r [ O_s . x + u32 ( O_q . O_n ) ] . y ) ) ; if ( O_t . x >= Image_Width || O_t . y >= Image_Height ) { return ; } let O_u = O_t . x + O_t . y * Image_Width ; let O_v = Image_Width * Image_Height * 8 - u32 ( O_u ) * 8 ; O_m = f32 ( O_u ) * O_q . O_m ; var O_w = O_p . O_c ; O_w = O_w + ( f32 ( O_t . x ) + O_x ( ) ) * O_p . O_d ; O_w = O_w + ( f32 ( O_t . y ) + O_x ( ) ) * O_p . O_e ; O_o [ O_v ] = O_w . x ; O_o [ O_v + 1 ] = O_w . y ; O_o [ O_v + 2 ] = O_w . z ; O_o [ O_v + 3 ] = 0 ; let O_b = O_p . O_b ; var O_y = normalize ( O_b - O_w ) ; O_o [ O_v + 4 ] = O_y . x ; O_o [ O_v + 5 ] = O_y . y ; O_o [ O_v + 6 ] = O_y . z ; O_o [ O_v + 7 ] = 0 ; } fn O_x ( ) -> f32 { let O_z : f32 = 1664525.0 ; let O_aa : f32 = 1013904223.0 ; let O_ab : f32 = 4294967296.0 ; let O_ac = fract ( ( O_z * O_m + O_aa ) / O_ab ) ; O_m = 100000 * O_ac ; return O_ac ; } ";vl.addShaderCode(XX);var JX="struct O_a { O_b : vec3 < f32 > , O_c : vec3 < f32 > , O_d : vec3 < f32 > , O_e : vec3 < f32 > , O_f : vec3 < f32 > , O_g : f32 , O_h : f32 , O_i : f32 , O_j : f32 , O_k : vec3f , } @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_l : array < f32 > ; @ group ( 0 ) @ binding ( 1 ) var < uniform > O_m : O_a ; @ group ( 0 ) @ binding ( 2 ) var < uniform > O_n : f32 ; override Image_Width : u32 ; override Image_Height : u32 ; var < private > O_o : f32 ; @ compute @ workgroup_size ( 8 , 8 ) fn main ( @ builtin ( global_invocation_id ) O_p : vec3 < u32 > , ) { if ( O_p . x >= Image_Width || O_p . y >= Image_Height ) { return ; } let O_q = O_p . x + O_p . y * Image_Width ; let O_r = Image_Width * Image_Height * 8 - u32 ( O_q ) * 8 - 8 ; O_o = f32 ( O_q ) * O_n ; var O_s = O_m . O_c ; O_s = O_s + ( f32 ( O_p . x ) + O_t ( ) ) * O_m . O_d ; O_s = O_s + ( f32 ( O_p . y ) + O_t ( ) ) * O_m . O_e ; O_l [ O_r ] = O_s . x ; O_l [ O_r + 1 ] = O_s . y ; O_l [ O_r + 2 ] = O_s . z ; O_l [ O_r + 3 ] = 0 ; let O_b = O_m . O_b ; var O_u = normalize ( O_b - O_s ) ; O_l [ O_r + 4 ] = O_u . x ; O_l [ O_r + 5 ] = O_u . y ; O_l [ O_r + 6 ] = O_u . z ; O_l [ O_r + 7 ] = 0 ; } fn O_t ( ) -> f32 { let O_v : f32 = 1664525.0 ; let O_w : f32 = 1013904223.0 ; let O_x : f32 = 4294967296.0 ; let O_y = fract ( ( O_v * O_o + O_w ) / O_x ) ; O_o = 100000 * O_y ; return O_y ; } fn O_z ( O_aa : vec3f , O_ab : vec3f , O_ac : vec3f , O_ad : f32 , ) -> vec3f { let O_ae = 2.0 * 3.1415926 * O_t ( ) ; let O_af = O_t ( ) * O_ad ; let O_ag = O_af * cos ( O_ae ) ; let O_ah = O_af * sin ( O_ae ) ; return O_aa + O_ag * O_ab + O_ah * O_ac ; } ";vl.addShaderCode(JX);var ZX="struct O_a { O_b : vec3 < f32 > , O_c : vec3 < f32 > , O_d : vec3 < f32 > , O_e : vec3 < f32 > , O_f : vec3 < f32 > , O_g : f32 , O_h : f32 , O_i : f32 , O_j : f32 , O_k : vec3f , } @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_l : array < f32 > ; @ group ( 0 ) @ binding ( 1 ) var < uniform > O_m : O_a ; override Image_Width : u32 ; override Image_Height : u32 ; @ compute @ workgroup_size ( 8 , 8 ) fn main ( @ builtin ( global_invocation_id ) O_n : vec3 < u32 > , ) { if ( O_n . x >= Image_Width || O_n . y >= Image_Height ) { return ; } let O_o = O_n . x + O_n . y * Image_Width ; let O_p = Image_Width * Image_Height * 8 - u32 ( O_o ) * 8 ; var O_q = O_m . O_c ; O_q = O_q + f32 ( O_n . x ) * O_m . O_d ; O_q = O_q + f32 ( O_n . y ) * O_m . O_e ; O_l [ O_p ] = O_q . x ; O_l [ O_p + 1 ] = O_q . y ; O_l [ O_p + 2 ] = O_q . z ; O_l [ O_p + 3 ] = 0 ; let O_b = O_m . O_b ; var O_r = normalize ( O_b - O_q ) ; O_l [ O_p + 4 ] = O_r . x ; O_l [ O_p + 5 ] = O_r . y ; O_l [ O_p + 6 ] = O_r . z ; O_l [ O_p + 7 ] = 0 ; } ";vl.addShaderCode(ZX);var KX="@ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_a : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 1 ) var < storage , read > O_b : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 2 ) var < storage , read > O_c : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 3 ) var < storage , read > O_d : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 4 ) var < storage , read > O_e : array < f32 > ; @ group ( 0 ) @ binding ( 5 ) var < storage , read > O_f : array < f32 > ; override Width : u32 ; override Height : u32 ; @ compute @ workgroup_size ( 8 , 8 ) fn main ( @ builtin ( global_invocation_id ) O_g : vec3 < u32 > , ) { if ( O_g . x >= Width || O_g . y >= Height ) { return ; } let O_h = O_g . x + O_g . y * u32 ( Width ) ; let O_i = O_d [ O_h ] ; let O_j : u32 = 10 ; let O_k : u32 = O_j / 2 ; var O_l : vec3f ; var O_m = 0 ; for ( var O_n : u32 = 0 ; O_n < O_j ; O_n += 1 ) { for ( var O_o : u32 = 0 ; O_o < O_j ; O_o += 1 ) { let O_p = O_g . x + ( O_n - O_k ) ; let O_q = O_g . y + ( O_o - O_k ) ; if ( O_p >= Width ) { continue ; } if ( O_q >= Height ) { continue ; } let O_r = O_p + O_q * Width ; let O_s = O_d [ O_r ] ; if ( dot ( O_s , O_i ) < 0.98 ) { continue ; } O_l += O_b [ O_r ] ; O_m += 1 ; } } O_a [ O_h ] = O_l / f32 ( O_m ) ; } ";vl.addShaderCode(KX);var $X="struct O_a { O_b : f32 , O_c : f32 , } @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_d : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 1 ) var < storage , read > O_e : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 2 ) var < storage , read_write > O_f : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 3 ) var < storage , read_write > O_g : array < vec2 < f32 > > ; @ group ( 0 ) @ binding ( 4 ) var < uniform > O_h : O_a ; @ group ( 0 ) @ binding ( 5 ) var < storage , read_write > O_i : array < vec3 < f32 > > ; override Width : u32 ; override Height : u32 ; @ compute @ workgroup_size ( 64 ) fn main ( @ builtin ( global_invocation_id ) O_j : vec3 < u32 > , ) { let O_k = u32 ( O_h . O_c ) + O_j . x ; let O_l = O_g [ O_k ] ; let O_m = vec2 < u32 > ( u32 ( O_l . x ) , u32 ( O_l . y ) ) ; if ( O_m . x >= Width || O_m . y >= Height ) { return ; } var O_n = O_m . x + O_m . y * u32 ( Width ) ; O_d [ O_n ] = O_d [ O_n ] + O_e [ O_n ] ; O_f [ O_n ] = O_d [ O_n ] / O_h . O_b ; } @ compute @ workgroup_size ( 8 , 8 ) fn main2 ( @ builtin ( global_invocation_id ) O_j : vec3 < u32 > , ) { if ( O_j . x >= Width || O_j . y >= Height ) { return ; } let O_n = O_j . x + O_j . y * u32 ( Width ) ; O_d [ O_n ] -= O_e [ O_n ] ; O_d [ O_n ] += O_i [ O_n ] ; O_f [ O_n ] = O_d [ O_n ] / O_h . O_b ; } ";vl.addShaderCode($X);var QX="struct O_a { O_b : f32 , O_c : f32 , O_d : f32 , O_e : f32 , } @ group ( 0 ) @ binding ( 0 ) var < storage , read_write > O_f : array < vec3 < f32 > > ; @ group ( 0 ) @ binding ( 1 ) var O_g : sampler ; @ group ( 0 ) @ binding ( 2 ) var O_h : texture_3d < f32 > ; @ group ( 0 ) @ binding ( 3 ) var < uniform > O_i : O_a ; @ group ( 0 ) @ binding ( 4 ) var < storage , read_write > O_j : array < vec3 < f32 > > ; @ compute @ workgroup_size ( 8 , 8 ) fn main ( @ builtin ( global_invocation_id ) O_k : vec3 < u32 > , ) { if ( O_k . x >= u32 ( O_i . O_b ) || O_k . y >= u32 ( O_i . O_c ) ) { return ; } let O_l = O_k . x + O_k . y * u32 ( O_i . O_b ) ; var O_m = O_f [ O_l ] . rgb ; O_m = clamp ( O_m , vec3f ( 0 ) , vec3f ( 1 ) ) ; if ( O_i . O_e == 1.0 ) { O_j [ O_l ] = O_m ; } else { let O_n = O_m * ( ( O_i . O_d - 1.0 ) / O_i . O_d ) + ( 0.5 / O_i . O_d ) ; let O_o = textureSampleLevel ( O_h , O_g , O_n , 0.0 ) . rgb ; O_j [ O_l ] = O_o ; } } ";vl.addShaderCode(QX);var Ohe=xI(YI()),eJ=(e=>(e.model="model",e.obj="obj",e.material="material",e.globalParam="global_param",e.areaLight="area_light",e.log="log",e.cMatrix="c_matrix",e.textureNormal="texture_normal",e.textureMetallic="texture_metallic",e.textureColor="texture_color",e.textureRoughness="texture_roughness",e.camera="camera",e.background="background",e.lut="lut",e))(eJ||{});var yI=new xt(-1,1,4).normalize(),mhe=yI.cross(new xt(0,1,0)).cross(yI).normalize();var SA="3.2.131",IA="05/06/2026";var tJ={ui_instance:!1,ui_module:!0,messageBus:void 0,windowBridge:void 0,pcbMessageBus:void 0,moveRocord:void 0,moveRocordNext:void 0,selectBox1:void 0,gControlDots:void 0,gRotateHelper:void 0,gControlRects:void 0,gControlLines:void 0,gCopperAreaOutlineCushions:void 0,gPanelizedOutlines:void 0,gPanelizedOutlinesOverG1:void 0,gCanvas:void 0,Canvas:void 0,doctype:void 0,cmdToken:void 0,gZoom:1,currZoom:100,jsonMgr:void 0,svgRoot:void 0,activeElement:void 0,helperCursor:void 0,showControlDots:void 0,_RotateCache:{},moveAction:void 0,localStorageDisabled:void 0,data3D:void 0,defaultImage:{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA1MCA0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB4PSIxIiB5PSIxIiB3aWR0aD0iNDgiIGhlaWdodD0iMzgiIGZpbGw9IiNGRkYiIHN0cm9rZT0iI0NDQyIgc3Ryb2tlLXdpZHRoPSIyIi8+PHBvbHlsaW5lIHBvaW50cz0iMS41LDIzLDE2LDEzLDM0LDI2LDQ4LjUsMjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0NDQyIgc3Ryb2tlLXdpZHRoPSIyIi8+PGNpcmNsZSBjeD0iMzUiIGN5PSIxMiIgcj0iNCIgZmlsbD0iI0NDQyIgc3Ryb2tlPSJub25lIi8+PC9zdmc+",width:50,height:40},worker:void 0,tearDropWorker:null,notCheckPrefix:void 0,drawing:void 0,loading:void 0,userAvatar:void 0,loginHandle:void 0,isMouseOnEditFrame:!1,isOn3dView:void 0,terminalWorker:void 0,hoverCache:void 0,contextmenuDisableOnce:void 0,pcbNetTextVisible:void 0,gRecover:void 0,gNets:void 0,updateNetTextTimer:void 0,netTextCharWidth:void 0,helperCursorConfig:{},rotateParts:void 0,waveFormObj:void 0,setCanvas:void 0,preMgr:void 0,sheetMgr:void 0,findShape:void 0,moveSelectedObjs:void 0,rotateSelectedObjs:void 0,vectorEffectSupported:void 0,modifyText:void 0,prjData:void 0,importChanges:void 0,DragAction:void 0,DragAction2:void 0,DragAction3:void 0,Draw:void 0,toggleTrackWidthPanel:void 0,arrowKeyMove:void 0,importShape:void 0,zoom:void 0,getCanvas:void 0,moveSelectedObjsTo:void 0,bringSelectedObjsToFront:void 0,sendSelectedObjsToBack:void 0,getComponents:void 0,isDragging:void 0,groupSymbol:void 0,cutSelectedObjs:void 0,copySelectedObjs:void 0,pasteFromGlobalClipboard:void 0,pasteFromClipboardAfterCloseRatline:void 0,cloneObjects:void 0,flipSelectedObjects:void 0,attrpanelApply:void 0,attrpanelGetData:void 0,deletePathNode:void 0,dragMoveSwitch:void 0,dragMoveCheck:void 0,dragMoveEndHandlerForPaste:void 0,importJsonCache:void 0,fixedDecimal:!1,decimalPlaces:2,decimalPlacesShow:2,schDecimalPlaces:2,schDecimalPlacesShow:2,pcbDecimalPlaces:4,pcbDecimalPlacesShow:3,pcbServersFonts:["NotoSerifCJKsc-Medium","NotoSansCJKjp-DemiLight"],pcbFontsRegExp:/[^!"\\#\$%&'`\(\)\*\+,\-\.\/a-zA-z0-9:<;\=\?>@\[\]\^_\{\|\}~°\s\t\r\n]/,checkNotificationInterval:12e4,checkUpdateInterval:36e5,saveFileTimeout:3e5,autoSaveMaxCount:1e3,autoSaveMaxBackupLevel:10,autoGzipAjaxPostSize:1e4,cooperationSites:["elektroda","amobbs","allaboutcircuits","diyaudio","hifidiy","edaboard"],cushionShape:null,cushionShapeFor:null,fileOperationAPI:"/EditorBridge/fileOperation",svgFileAPI:"/EditorBridge/svgFile",treeDataAPI:"/EditorBridge/treeData",anonymousPid:"441bd07389f646ac82c8d1dbc45a6021",version:"V"+SA,buildDate:IA,lcscUUID:"0819f05c4eef4c71ace90d822a990e87",easyedaUUID:"4251c6ae97414f38bb1d929da02c4173",ignoreConfirmClose:!1,globalVariableCookieData:{},teams:[],networkWarn:"Network Error! Please check your network and try again!",updatePcbFileInfo:[],multiSelect:!1,copperNetRelation:{},isSaving:!1,pasteCount:0,pasteFrom:null,canvasStrTolerance:10,logTypes:{BOM_EXPORT:1,BOM_LCSC:2,GERBER_DOWNLOAD:3,GERBER_JLC:4},apis:{model:{upload:"/api/3dmodel/upload"}},deleteObjs:void 0,currentProject:{projectId:void 0,title:void 0},blockSymbolAttr:void 0,selectableObjMap:{SCH:{symbol:!0,wire:!0,pin:!1,name:!0,property:!0,text:!0,arc:!0,rect:!0,circle:!0,polyline:!0,table:!0,sheet:!0},SYMBOL:{pin:!0,name:!0,property:!0,text:!0,arc:!0,rect:!0,circle:!0,polyline:!0}},importFileDataStr:void 0,profileSetting:null,defaultFont:null,batchExportInfo:null,extensionApiMessageBus2:void 0},$ue=(function(){try{var e=location.hostname;return e.indexOf("lceda")>-1?"lceda":(e.indexOf("easyeda")>-1,"easyeda")}catch{}})(),Que=(function(){try{var e=location.hostname,t=e.split(".");return t.length>2?t.length===3&&(t[0]==="www"||t[0]==="alpha")?"online":"dev":"online"}catch{}})();var PA=["green","blue","red","white","yellow","black","purple","coppery"];function xl(e){if(typeof e!="object"||e===null||e instanceof Date||e instanceof ArrayBuffer)return e;if(Array.isArray(e))return e.map(xl);{let t={};for(let i in e)e.hasOwnProperty(i)&&(t[i]=xl(e[i]));return t}}function AA(e){let t=!0,i;return async()=>(t&&(i=await e(),t=!1),i)}function CA(e){let t=n=>/^rgba?\(\s*\d{1,3}\s*(?:,\s*\d{1,3}\s*,\s*\d{1,3}\s*(?:,\s*(?:\d*\.?\d+|\d+%)\s*)?)?\)$/.test(n)||/^rgba?\(\s*\d{1,3}\s+\d{1,3}\s+\d{1,3}\s*(?:\/\s*(?:\d*\.?\d+|\d+%)\s*)?\)$/.test(n),i=n=>/^hsla?\(\s*\d{1,3}\s*(?:,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(?:,\s*(?:\d*\.?\d+|\d+%)\s*)?)?\)$/.test(n)||/^hsla?\(\s*\d{1,3}\s+\d{1,3}%\s+\d{1,3}%\s*(?:\/\s*(?:\d*\.?\d+|\d+%)\s*)?\)$/.test(n),r=n=>{let o=/^rgba?\(\s*(\d{1,3})\s*(?:,\s*|\s+)(\d{1,3})\s*(?:,\s*|\s+)(\d{1,3})\s*(?:,\s*(\d*\.?\d+|\d+%)\s*|\/\s*(\d*\.?\d+|\d+%)\s*)?\)$/.exec(n);if(!o)throw new Error("Invalid RGBA or RGB string");let l=parseInt(o[1],10)/255,h=parseInt(o[2],10)/255,c=parseInt(o[3],10)/255,d=1;return o[4]!==void 0?d=o[4].endsWith("%")?parseFloat(o[4])/100:parseFloat(o[4]):o[5]!==void 0&&(d=o[5].endsWith("%")?parseFloat(o[5])/100:parseFloat(o[5])),[l,h,c,d]},s=n=>{let o=/^hsla?\(\s*(\d{1,3})\s*(?:,\s*|\s+)(\d{1,3})%\s*(?:,\s*|\s+)(\d{1,3})%\s*(?:,\s*(\d*\.?\d+|\d+%)\s*|\/\s*(\d*\.?\d+|\d+%)\s*)?\)$/.exec(n);if(!o)throw new Error("Invalid HSLA or HSL string");let l=parseInt(o[1],10)/360,h=parseInt(o[2],10)/100,c=parseInt(o[3],10)/100,d=1;o[4]!==void 0?d=o[4].endsWith("%")?parseFloat(o[4])/100:parseFloat(o[4]):o[5]!==void 0&&(d=o[5].endsWith("%")?parseFloat(o[5])/100:parseFloat(o[5]));let f=(1-Math.abs(2*c-1))*h,u=f*(1-Math.abs(l*6%2-1)),p=c-f/2,g=0,_=0,y=0;return 0<=l&&l<.16666666666666666?(g=f,_=u,y=0):.16666666666666666<=l&&l<.3333333333333333?(g=u,_=f,y=0):.3333333333333333<=l&&l<.5?(g=0,_=f,y=u):.5<=l&&l<.6666666666666666?(g=0,_=u,y=f):.6666666666666666<=l&&l<.8333333333333334?(g=u,_=0,y=f):.8333333333333334<=l&&l<=1&&(g=f,_=0,y=u),g=g+p,_=_+p,y=y+p,[g,_,y,d]};if(t(e)){let n=r(e);return rr.build(n[0],n[1],n[2],n[3])}else if(i(e)){let n=s(e);return rr.build(n[0],n[1],n[2],n[3])}else{if(rr.isHexFormate(e))return rr.of3(e);throw new Error("Invalid color string")}}var LA=[{layerName:"Top Solder Mask Layer","Layer Type":"TOP_SOLDER_MASK",Thickness:.010000000000000002},{layerName:"Top Layer","Layer Type":"TOP",Thickness:.035},{layerName:"Dielectric1","Layer Type":"SUBSTRATE",Thickness:1.5100030480060962},{layerName:"Bottom Layer","Layer Type":"BOTTOM",Thickness:.035},{layerName:"Bottom Solder Mask Layer","Layer Type":"BOT_SOLDER_MASK",Thickness:.010000000000000002}],DA=[{layerName:"Top Solder Mask Layer","Layer Type":"TOP_SOLDER_MASK",Thickness:.027},{layerName:"Top Layer","Layer Type":"TOP",Thickness:.012},{layerName:"Dielectric1","Layer Type":"SUBSTRATE",Thickness:.025},{layerName:"Bottom Layer","Layer Type":"BOTTOM",Thickness:.012},{layerName:"Bottom Solder Mask Layer","Layer Type":"BOT_SOLDER_MASK",Thickness:.027}];var mh=zO(QO());var AO=class{constructor(){this.workerBus=null;this.messageBus2=new mh.MessageBus2(!0);let t=vu(),i=!!t.frameElement&&!t["USE-IFRAME-FOR-MAIN"]&&!t["META-PANELIZE-ENV"];t["META-PANELIZE-ENV"]&&t._MSG_BUS_&&(t._MSG_BUS_.unsafe=!0),this.globalMessageBus=t._MSG_BUS_=t._MSG_BUS_||new mh.MessageBus(!i),this.messageBus=i?new mh.MessageBus(!0):this.globalMessageBus,this.windowBridge=i?new mh.WindowMessageBridge(this.messageBus):this.messageBus,this.workerBus=null,this.extensionApiMessageBus2=()=>t.top._MSG_BUS2_EXTAPI_}publish(t,i,r){r!=null&&r!=null?this.windowBridge.publish(t,i,r):this.messageBus.publish(t,i)}subscribe(t,i,r){let s=vu();r!=null&&r!=null&&r!==s&&this.windowBridge.subscribe(t,r),this.messageBus.subscribe(t,i)}push(t,i,r){r!=null&&r!=null?this.windowBridge.push(t,i,r):this.messageBus.push(t,i)}pull(t,i,r){r!=null&&r!=null&&this.windowBridge.pull(t,r),this.messageBus.pull(t,i)}};function vu(){if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof CO<"u")return CO}var CO=vu(),Vy=CO.MSG_BUS_PCB=CO.MSG_BUS_PCB||new AO;function RA(e,t={},...i){e||(e=""),t=Object.assign({color:"#75de75","font-style":"italic","background-color":"#333",padding:"2px","font-size":"16px"},t),e.includes("%c")||(e="%c "+e),console.log(e,JSON.stringify(t).replace(/[\"\{\}]/g,"").replace(/,/g,";"),...i)}var Yy=vu(),na=Yy.top||Yy;try{na.location&&na.location.search}catch{na=null}var iJ="-time-diff",NA=na&&rJ();function rJ(){let e=Yy.PRO_LOG_LEVEL;return e=="trace"||e=="debug"}function sJ(e){return e+iJ}function nJ(e,t){let i=sJ(e);Array.isArray(na[i])?na[i].push(t):na[i]=[t]}function aJ(e,t=3){return+e.toFixed(t)}function jf(e,t=!1){if(!NA)return;let i=new Date().getTime();t&&na[e]||(na[e]=i)}function bh(e,t=0){if(!NA)return;let i=na[e];if(isNaN(i))return!1;let r=new Date().getTime(),s=aJ((r-i)/1e3);return s>=t&&RA(e,void 0,`${s}s`),nJ(e,s),delete na[e],!0}function oJ(){let e=document.querySelector(window.canvas_2d_selector||"#canvas-2d")||document.getElementById("canvas");return e instanceof HTMLCanvasElement||(e=document.createElement("canvas")),e.style.width="100%",e.style.height="100%",e}var lJ=oJ();function qy(e){lJ.style.cursor=e,document.documentElement.style.cursor=e}var LO=class{};var DO=class extends LO{constructor(){super(...arguments);this.errorLayerData=new Set;this.errorLayerPhyData=new Set}clear(){this.errorLayerData.clear(),this.errorLayerPhyData.clear()}deleteLayerId(i){this.errorLayerData.delete(i)}deleteLayerPhyId(i){this.errorLayerPhyData.delete(i)}fix(i,r){let s=new Map,n=new Map,a=new Map;for(let l of i)s.set(l.layerId,l),l.getType()=="SUBSTRATE"&&a.set(l.layerId,l);for(let l of r)n.set(l.layerId,l);let o=260;for(let[l,h]of a)if(l>=101&&l<361){this.errorLayerData.add(l),this.errorLayerPhyData.add(l);let c=l+o;if(a.has(c))s.delete(l),n.delete(l);else{h.layerId=c;let d=n.get(l);d!=null&&(d.layerId=c)}}i.length=0,r.length=0;for(let[,l]of s)i.push(l);for(let[,l]of n)r.push(l)}};var xu=class{constructor(){this.layerPhyFix=new DO}};var Vf=class extends Ww{constructor(i,r,s,n){super(i,r,s,n);this.hasSynced=new Map;this.initFinished=!1;this.mgr=new xu}onXSignalsGroup(i,r,s,n,a){throw new Error("Method not implemented.")}onDelXSignalsGroup(i,r,s,n){throw new Error("Method not implemented.")}onXSignals(i,r,s,n,a){throw new Error("Method not implemented.")}onDelXSignals(i,r,s,n){throw new Error("Method not implemented.")}getSelectHandle(){return this.selectHandle}setSelectHandle(i){this.selectHandle=i}getDocDetail(){return this.docDetail}canvasSelected(){var i;return(i=this.selectHandle)==null?void 0:i.getSelect()}onSelectChange(i,r,s){var n;(n=this.selectHandle)==null||n.onSelected(i,r,s)}onSelectQuit(i,r){var s;(s=this.selectHandle)==null||s.onDestroy(i,r)}setHandle(i,r){this.handle!=null&&!r&&this.handle.destory(),this.handle=i,this.handle.setClient(this.consistencyManager.getClient())}destroy(){return new Promise(i=>{super.destroy().then(r=>{this.handle=null,i(r)})})}setTicket(i=this.consistencyManager.getMaxTicket()+1){this.handle.setTicket(i)}getHandle(){return this.handle}onBoard(i,r,s,n){this.handle.onBoard(i,r,s,n)}onDelBoard(i,r,s){this.handle.onDelBoard(i,r,s)}onLayerFill(i,r,s,n,a){this.handle.onLayerFill(i,r,s,n,a)}onDelLayerFill(i,r,s,n){this.handle.onDelLayerFill(i,r,s,n)}onBlob(i,r,s,n,a){this.handle.onBlob(i,r,s,n,a)}onDelBlob(i,r,s,n){this.handle.onDelBlob(i,r,s,n)}onFont(i,r,s,n){this.handle.onFont(i,r,s,n)}onDelFont(i,r,s,n){this.handle.onDelFont(i,r,s,n)}onString(i,r,s,n,a,o){this.handle.onString(i,r,s,n,a,o)}onDelString(i,r,s,n){this.handle.onDelString(i,r,s,n)}onAttr(i,r,s,n,a,o){this.handle.onAttr(i,r,s,n,a,o)}onDelAttr(i,r,s,n){this.handle.onDelAttr(i,r,s,n)}onPadNet(i,r,s,n){this.handle.onPadNet(i,r,s,n)}onDelPadNet(i,r,s,n,a,o){this.handle.onDelPadNet(i,r,n,s,a,o)}onComponent(i,r,s,n,a,o){this.handle.onComponent(i,r,s,n,a,o)}onDelComponent(i,r,s,n){this.handle.onDelComponent(i,r,s,n)}onPanelize(i,r,s,n){this.handle.onPanelize(i,r,s,n)}onDelPanelize(i,r,s){this.handle.onDelPanelize(i,r,s)}onRuleSelector(i,r,s,n){this.handle.onRuleSelector(i,r,s,n)}onDelRuleSelector(i,r,s,n){this.handle.onDelRuleSelector(i,r,s,n)}onRule(i,r,s,n){this.handle.onRule(i,r,s,n)}onDelRule(i,r,s,n,a){this.handle.onDelRule(i,r,s,n,a)}onRuleTemplate(i,r,s,n){this.handle.onRuleTemplate(i,r,s,n)}onDimension(i,r,s,n,a,o){this.handle.onDimension(i,r,s,n,a,o)}onDelDimension(i,r,s,n){this.handle.onDelDimension(i,r,s,n)}onBoss(i,r,s,n,a,o){this.handle.onBoss(i,r,s,n,a,o)}onDelBoss(i,r,s,n){this.handle.onDelBoss(i,r,s,n)}onShellEntity(i,r,s,n,a,o){this.handle.onShellEntity(i,r,s,n,a,o)}onDelShellEntity(i,r,s,n){this.handle.onDelShellEntity(i,r,s,n)}onShellCut(i,r,s,n,a,o){this.handle.onShellCut(i,r,s,n,a,o)}onDelShellCut(i,r,s,n){this.handle.onDelShellCut(i,r,s,n)}onCrease(i,r,s,n,a,o){this.handle.onCrease(i,r,s,n,a,o)}onDelCrease(i,r,s,n){this.handle.onDelCrease(i,r,s,n)}onShell(i,r,s,n,a,o){this.handle.onShell(i,r,s,n,a,o)}onDelShell(i,r,s,n){this.handle.onDelShell(i,r,s,n)}onFpcFill(i,r,s,n,a,o){this.handle.onFpcFill(i,r,s,n,a,o)}onDelFpcFill(i,r,s,n){this.handle.onDelFpcFill(i,r,s,n)}onTeardrop(i,r,s,n,a,o){this.handle.onTeardrop(i,r,s,n,a,o)}onDelTeardrop(i,r,s,n){this.handle.onDelTeardrop(i,r,s,n)}onImage(i,r,s,n,a,o){this.handle.onImage(i,r,s,n,a,o)}onDelImage(i,r,s,n){this.handle.onDelImage(i,r,s,n)}onPoured(i,r,s,n,a,o){this.handle.onPoured(i,r,s,n,a,o)}onDelPoured(i,r,s,n){this.handle.onDelPoured(i,r,s,n)}onPour(i,r,s,n,a,o){this.handle.onPour(i,r,s,n,a,o)}onDelPour(i,r,s,n){this.handle.onDelPour(i,r,s,n)}onRegion(i,r,s,n,a,o){this.handle.onRegion(i,r,s,n,a,o)}onDelRegion(i,r,s,n){this.handle.onDelRegion(i,r,s,n)}onFill(i,r,s,n,a,o){a.fillStyle!=jd.PLANE&&this.handle.onFill(i,r,s,n,a,o)}onDelFill(i,r,s,n){this.handle.onDelFill(i,r,s,n)}onPoly(i,r,s,n,a,o){this.handle.onPoly(i,r,s,n,a,o)}onDelPoly(i,r,s,n){this.handle.onDelPoly(i,r,s,n)}onEQLenGrp(i,r,s,n,a){this.handle.onEQLenGrp(i,r,s,n,a)}onDelEQLenGrp(i,r,s,n){this.handle.onDelEQLenGrp(i,r,s,n)}onObj(i,r,s,n,a,o){this.handle.onObj(i,r,s,n,a,o)}onDelObj(i,r,s,n){this.handle.onDelObj(i,r,s,n)}onArc(i,r,s,n,a,o){this.handle.onArc(i,r,s,n,a,o)}onDelArc(i,r,s,n){this.handle.onDelArc(i,r,s,n)}onLine(i,r,s,n,a,o){this.initFinished&&this.hasSynced.set(i,n),this.handle.onLine(i,r,s,n,a,o)}onDelLine(i,r,s,n){this.handle.onDelLine(i,r,s,n)}onPad(i,r,s,n,a,o){this.handle.onPad(i,r,s,n,a,o)}onDelPad(i,r,s,n){this.handle.onDelPad(i,r,s,n)}onVia(i,r,s,n,a,o){this.handle.onVia(i,r,s,n,a,o)}onDelVia(i,r,s,n){this.handle.onDelVia(i,r,s,n)}onPreference(i,r,s,n){this.handle.onPreference(i,r,s,n)}onSilkOpts(i,r,s,n,a){this.handle.onSilkOpts(i,r,s,n,a)}onDelSilkOpts(i,r,s,n){this.handle.onDelSilkOpts(i,r,s,n)}onGroup(i,r,s,n,a){this.handle.onGroup(i,r,s,n,a)}onDelGroup(i,r,s,n){this.handle.onDelGroup(i,r,s,n)}onPrimitive(i,r,s,n,a){this.handle.onPrimitive(i,r,s,n,a)}onDelPrimitive(i,r,s,n){this.handle.onDelPrimitive(i,r,s,n)}onNet(i,r,s,n,a){this.handle.onNet(i,r,s,n,a)}onDelNet(i,r,s,n){this.handle.onDelNet(i,r,s,n)}onPartition(i,r,s,n,a,o){this.handle.onPartition(i,r,s,n,a,o)}onDelPartition(i,r,s,n){this.handle.onDelPartition(i,r,s,n)}onActiveLayer(i,r,s,n){this.handle.onActiveLayer(i,r,s,n)}onLayerPhys(i,r,s,n,a){this.handle.onLayerPhys(i,r,s,n,a)}onDelLayerPhys(i,r,s,n){this.mgr.layerPhyFix.deleteLayerPhyId(i),this.handle.onDelLayerPhys(i,r,s,n)}onLayer(i,r,s,n,a){this.handle.onLayer(i,r,s,n,a)}onDelLayer(i,r,s,n){this.mgr.layerPhyFix.deleteLayerId(i),this.handle.onDelLayer(i,r,s,n)}onCanvas(i,r,s,n){this.handle.onCanvas(i,r,s,n)}onDocDetail(i,r,s,n){this.docDetail=s,this.handle.onDocDetail(i,r,s,n)}onStringNum(i,r){this.handle.onStringNum(i,r)}onAttrNum(i,r){this.handle.onAttrNum(i,r)}onComponentNum(i,r){this.handle.onComponentNum(i,r)}onDimensionNum(i,r){this.handle.onDimensionNum(i,r)}onBossNum(i,r){this.handle.onBossNum(i,r)}onShellEntityNum(i,r){this.handle.onShellEntityNum(i,r)}onShellCutNum(i,r){this.handle.onShellCutNum(i,r)}onCreaseNum(i,r){this.handle.onCreaseNum(i,r)}onShellNum(i,r){this.handle.onShellNum(i,r)}onFpcFillNum(i,r){this.handle.onFpcFillNum(i,r)}onTeardropNum(i,r){this.handle.onTeardropNum(i,r)}onImageNum(i,r){this.handle.onImageNum(i,r)}onPouredNum(i,r){this.handle.onPouredNum(i,r)}onPourNum(i,r){this.handle.onPourNum(i,r)}onRegionNum(i,r){this.handle.onRegionNum(i,r)}onFillNum(i,r){this.handle.onFillNum(i,r)}onPolyNum(i,r){this.handle.onPolyNum(i,r)}onObjNum(i,r){this.handle.onObjNum(i,r)}onArcNum(i,r){this.handle.onArcNum(i,r)}onLineNum(i,r){this.handle.onLineNum(i,r)}onPadNum(i,r){this.handle.onPadNum(i,r)}onViaNum(i,r){this.handle.onViaNum(i,r)}onPartitionNum(i,r){this.handle.onPartitionNum(i,r)}uploadRuleSelector(i){return i.ruleSelect.length==0?{success:!1,message:"rule selector data error."}:super.uploadRuleSelector(i)}};var RO=class extends Xw{constructor(i,r,s,n=Eu.getInstance().currOpenProjectId===r){super(i,r,n,s,void 0);this.mgr=new xu}onXSignalsGroup(i,r,s,n,a){throw new Error("Method not implemented.")}onDelXSignalsGroup(i,r,s,n){throw new Error("Method not implemented.")}onXSignals(i,r,s,n,a){throw new Error("Method not implemented.")}onDelXSignals(i,r,s,n){throw new Error("Method not implemented.")}getDocDetail(){return this.docDetail}canvasSelected(){var i;return(i=this.selectHandle)==null?void 0:i.getSelect()}onSelectChange(i,r,s){var n;(n=this.selectHandle)==null||n.onSelected(i,r,s)}onSelectQuit(i,r){var s;(s=this.selectHandle)==null||s.onDestroy(i,r)}getHandle(){return this.handle}setHandle(i){this.handle!=null&&this.handle.destory(),this.handle=i,this.handle.setClient(this.consistencyManager.getClient())}destroy(){return this.handle=null,super.destroy()}setTicket(){this.handle.setTicket(this.consistencyManager.getMaxTicket()+1)}onLayerFill(i,r,s,n,a){this.handle.onLayerFill(i,r,s,n,a)}onDelLayerFill(i,r,s,n){this.handle.onDelLayerFill(i,r,s,n)}onBlob(i,r,s,n,a){this.handle.onBlob(i,r,s,n,a)}onDelBlob(i,r,s,n){this.handle.onDelBlob(i,r,s,n)}onFont(i,r,s,n){this.handle.onFont(i,r,s,n)}onDelFont(i,r,s,n){this.handle.onDelFont(i,r,s,n)}onGroup(i,r,s,n,a){this.handle.onGroup(i,r,s,n,a)}onDelGroup(i,r,s,n){this.handle.onDelGroup(i,r,s,n)}onString(i,r,s,n,a,o){this.handle.onString(i,r,s,n,a,o)}onDelString(i,r,s,n){this.handle.onDelString(i,r,s,n)}onAttr(i,r,s,n,a,o){this.handle.onAttr(i,r,s,n,a,o)}onDelAttr(i,r,s,n){this.handle.onDelAttr(i,r,s,n)}onPanelize(i,r,s,n){this.handle.onPanelize(i,r,s,n)}onDelPanelize(i,r,s){this.handle.onDelPanelize(i,r,s)}onRuleSelector(i,r,s,n){this.handle.onRuleSelector(i,r,s,n)}onDelRuleSelector(i,r,s,n){this.handle.onDelRuleSelector(i,r,s,n)}onRule(i,r,s,n){this.handle.onRule(i,r,s,n)}onDelRule(i,r,s,n,a){this.handle.onDelRule(i,r,s,n,a)}onRuleTemplate(i,r,s,n){this.handle.onRuleTemplate(i,r,s,n)}onDimension(i,r,s,n,a,o){this.handle.onDimension(i,r,s,n,a,o)}onDelDimension(i,r,s,n){this.handle.onDelDimension(i,r,s,n)}onBoss(i,r,s,n,a,o){this.handle.onBoss(i,r,s,n,a,o)}onDelBoss(i,r,s,n){this.handle.onDelBoss(i,r,s,n)}onShellEntity(i,r,s,n,a,o){this.handle.onShellEntity(i,r,s,n,a,o)}onDelShellEntity(i,r,s,n){this.handle.onDelShellEntity(i,r,s,n)}onShellCut(i,r,s,n,a,o){this.handle.onShellCut(i,r,s,n,a,o)}onDelShellCut(i,r,s,n){this.handle.onDelShellCut(i,r,s,n)}onCrease(i,r,s,n,a,o){this.handle.onCrease(i,r,s,n,a,o)}onDelCrease(i,r,s,n){this.handle.onDelCrease(i,r,s,n)}onShell(i,r,s,n,a,o){this.handle.onShell(i,r,s,n,a,o)}onDelShell(i,r,s,n){this.handle.onDelShell(i,r,s,n)}onFpcFill(i,r,s,n,a,o){this.handle.onFpcFill(i,r,s,n,a,o)}onDelFpcFill(i,r,s,n){this.handle.onDelFpcFill(i,r,s,n)}onTeardrop(i,r,s,n,a,o){let l={...a,width:.2,fillStyle:jd.SOLID,path:[a.path],locked:!1,zIndex:0};this.handle.onFill(i,r,s,n,l,o)}onDelTeardrop(i,r,s,n){this.handle.onDelTeardrop(i,r,s,n)}onImage(i,r,s,n,a,o){this.handle.onImage(i,r,s,n,a,o)}onDelImage(i,r,s,n){this.handle.onDelImage(i,r,s,n)}onPoured(i,r,s,n,a,o){this.handle.onPoured(i,r,s,n,a,o)}onDelPoured(i,r,s,n){this.handle.onDelPoured(i,r,s,n)}onPour(i,r,s,n,a,o){this.handle.onPour(i,r,s,n,a,o)}onDelPour(i,r,s,n){this.handle.onDelPour(i,r,s,n)}onRegion(i,r,s,n,a,o){this.handle.onRegion(i,r,s,n,a,o)}onDelRegion(i,r,s,n){this.handle.onDelRegion(i,r,s,n)}onFill(i,r,s,n,a,o){this.handle.onFill(i,r,s,n,a,o)}onDelFill(i,r,s,n){this.handle.onDelFill(i,r,s,n)}onPoly(i,r,s,n,a,o){this.handle.onPoly(i,r,s,n,a,o)}onDelPoly(i,r,s,n){this.handle.onDelPoly(i,r,s,n)}onEQLenGrp(i,r,s,n,a){this.handle.onEQLenGrp(i,r,s,n,a)}onDelEQLenGrp(i,r,s,n){this.handle.onDelEQLenGrp(i,r,s,n)}onObj(i,r,s,n,a,o){this.handle.onObj(i,r,s,n,a,o)}onDelObj(i,r,s,n){this.handle.onDelObj(i,r,s,n)}onArc(i,r,s,n,a,o){this.handle.onArc(i,r,s,n,a,o)}onDelArc(i,r,s,n){this.handle.onDelArc(i,r,s,n)}onLine(i,r,s,n,a,o){this.handle.onLine(i,r,s,n,a,o)}onDelLine(i,r,s,n){this.handle.onDelLine(i,r,s,n)}onPad(i,r,s,n,a,o){this.handle.onPad(i,r,s,n,a,o)}onDelPad(i,r,s,n){this.handle.onDelPad(i,r,s,n)}onVia(i,r,s,n,a,o){this.handle.onVia(i,r,s,n,a,o)}onDelVia(i,r,s,n){this.handle.onDelVia(i,r,s,n)}onPreference(i,r,s,n){this.handle.onPreference(i,r,s,n)}onSilkOpts(i,r,s,n,a){this.handle.onSilkOpts(i,r,s,n,a)}onDelSilkOpts(i,r,s,n){this.handle.onDelSilkOpts(i,r,s,n)}onPrimitive(i,r,s,n,a){this.handle.onPrimitive(i,r,s,n,a)}onDelPrimitive(i,r,s,n){this.handle.onDelPrimitive(i,r,s,n)}onNet(i,r,s,n,a){this.handle.onNet(i,r,s,n,a)}onDelNet(i,r,s,n){this.handle.onDelNet(i,r,s,n)}onPartition(i,r,s,n,a,o){this.handle.onPartition(i,r,s,n,a,o)}onDelPartition(i,r,s,n){this.handle.onDelPartition(i,r,s,n)}onActiveLayer(i,r,s,n){this.handle.onActiveLayer(i,r,s,n)}onLayerPhys(i,r,s,n,a){this.handle.onLayerPhys(i,r,s,n,a)}onDelLayerPhys(i,r,s,n){this.mgr.layerPhyFix.deleteLayerPhyId(i),this.handle.onDelLayerPhys(i,r,s,n)}onLayer(i,r,s,n,a){this.mgr.layerPhyFix.deleteLayerId(i),this.handle.onLayer(i,r,s,n,a)}onDelLayer(i,r,s,n){this.handle.onDelLayer(i,r,s,n)}onCanvas(i,r,s,n){this.handle.onCanvas(i,r,s,n)}onDocDetail(i,r,s,n){this.docDetail=s,this.handle.onDocDetail(i,r,s,n)}onBoard(i,r,s,n){this.handle.onBoard(i,r,s,n)}onDelBoard(i,r,s){this.handle.onDelBoard(i,r,s)}onStringNum(i,r){this.handle.onStringNum(i,r)}onAttrNum(i,r){this.handle.onAttrNum(i,r)}onDimensionNum(i,r){this.handle.onDimensionNum(i,r)}onBossNum(i,r){this.handle.onBossNum(i,r)}onShellEntityNum(i,r){this.handle.onShellEntityNum(i,r)}onShellCutNum(i,r){this.handle.onShellCutNum(i,r)}onCreaseNum(i,r){this.handle.onCreaseNum(i,r)}onShellNum(i,r){this.handle.onShellNum(i,r)}onFpcFillNum(i,r){this.handle.onFpcFillNum(i,r)}onTeardropNum(i,r){this.handle.onTeardropNum(i,r)}onImageNum(i,r){this.handle.onImageNum(i,r)}onPouredNum(i,r){this.handle.onPouredNum(i,r)}onPourNum(i,r){this.handle.onPourNum(i,r)}onRegionNum(i,r){this.handle.onRegionNum(i,r)}onFillNum(i,r){this.handle.onFillNum(i,r)}onPolyNum(i,r){this.handle.onPolyNum(i,r)}onObjNum(i,r){this.handle.onObjNum(i,r)}onArcNum(i,r){this.handle.onArcNum(i,r)}onLineNum(i,r){this.handle.onLineNum(i,r)}onPadNum(i,r){this.handle.onPadNum(i,r)}onViaNum(i,r){this.handle.onViaNum(i,r)}onPartitionNum(i,r){this.handle.onPartitionNum(i,r)}uploadRuleSelector(i){return i.ruleSelect.length==0?{success:!1,message:"rule selector data error."}:super.uploadRuleSelector(i)}};var Yf=Math.PI*2;var Lpe=Math.PI/2,Dpe=Math.sin(Math.PI/180);var qf=class qf{constructor(){this.param=null;this._visible=sa.SHOW;this._flip=!1;this._currentCoord=!0;this._gridColor=rr.WHITE;this._transparency=.3;this._multiGridColor=rr.WHITE;this._multiTransparency=.55;this._coordinateAxisColor=rr.WHITE;this._coordinateAxisTransparency=1;this._stepX=.5;this._stepY=.5;this._snapX=.5;this._snapY=.5;this._pattern=!0;this._multiRatio=5;this._multiStyle=Oh.None;this._angleDelta=Math.PI/4;this._startAngle=0;this._endAngle=Yf;this._step=39.37;this._minRadius=3.937;this._maxRadius=393.7;this._renderGrid=!0}static getInstance(){return this.ins==null&&(this.ins=new qf),this.ins}modify(t,i,r,s,n){this._stepX=t,this._stepY=i,this._snapX=r,this._snapY=s,this._pattern=n,this.param!=null&&this.param.modify(t,i,r,s,n)}attach(t){this.param=t,this.param!=null&&(this.param.visible=this._visible,this.param.flip=this._flip,this.param.currentCoord=this._currentCoord,this.param.gridColor=this._gridColor,this.param.transparency=this._transparency,this.param.multiGridColor=this._multiGridColor,this.param.multiTransparency=this._multiTransparency,this.param.coordinateAxisColor=this._coordinateAxisColor,this.param.coordinateAxisTransparency=this._coordinateAxisTransparency,this.param.modify(this._stepX,this._stepY,this._snapX,this._snapY,this._pattern),this.param.setMultiRatio(this._multiRatio),this.param.setMultiStyle(this._multiStyle),this.param.angleDelta=this._angleDelta,this.param.startAngle=this._startAngle,this.param.endAngle=this._endAngle,this.param.radius=this._step,this.param.minRadius=this._minRadius,this.param.maxRadius=this._maxRadius)}set visible(t){this._visible=t,this.param!=null&&(this.param.visible=t)}get visible(){var t;return((t=this.param)==null?void 0:t.visible)||this._visible}set renderGrid(t){this._renderGrid=t,this.param!=null&&(this.param.renderGrid=t)}get renderGrid(){var t;return((t=this.param)==null?void 0:t.renderGrid)||this._renderGrid}get flip(){var t;return((t=this.param)==null?void 0:t.flip)||this._flip}set flip(t){this._flip=t,this.param!=null&&(this.param.flip=t)}get gridColor(){var t;return((t=this.param)==null?void 0:t.gridColor)||this._gridColor}set gridColor(t){this._gridColor=t,this.param!=null&&(this.param.gridColor=t)}get currentCoord(){var t;return((t=this.param)==null?void 0:t.currentCoord)||this._currentCoord}set currentCoord(t){this._currentCoord=t,this.param!=null&&(this.param.currentCoord=t)}get minRadius(){var t;return((t=this.param)==null?void 0:t.minRadius)||this._minRadius}set minRadius(t){this._minRadius=t,this.param!=null&&(this.param.minRadius=t)}get maxRadius(){var t;return((t=this.param)==null?void 0:t.maxRadius)||this._maxRadius}set maxRadius(t){this._maxRadius=t,this.param!=null&&(this.param.maxRadius=t)}get angleDelta(){var t;return((t=this.param)==null?void 0:t.angleDelta)||this._angleDelta}set angleDelta(t){this._angleDelta=t,this.param!=null&&(this.param.angleDelta=t)}get radius(){var t;return((t=this.param)==null?void 0:t.radius)||this._step}set radius(t){this._step=t,this.param!=null&&(this.param.radius=t)}get startAngle(){var t;return((t=this.param)==null?void 0:t.startAngle)||this._startAngle}set startAngle(t){t%=Yf,t<0&&(t+=Yf),this._startAngle=t,this.param!=null&&(this.param.startAngle=t)}get endAngle(){var t;return((t=this.param)==null?void 0:t.endAngle)||this._endAngle}set endAngle(t){this._endAngle=t,this.param!=null&&(this.param.endAngle=t)}get sweepAngle(){var i;let t=(i=this.param)==null?void 0:i.sweepAngle;return t==null?this.endAngle>this.startAngle?this.endAngle-this.startAngle:this.endAngle-this.startAngle+Yf:t}updateGridParam(t,i,r,s){let n=t?sa.SHOW:sa.ONLYAXIS;this._stepX=i,this._stepY=r,t!==void 0&&(this.visible=n),s!==void 0&&(this._pattern=s),this.param!=null&&this.param.updateGridParam(t,i,r,s)}setGridX(t){t>0&&(this._stepX=t),this.param!=null&&this.param.setGridX(t)}getGridX(){var t;return((t=this.param)==null?void 0:t.getGridX())||this._stepX}setGridY(t){t>0&&(this._stepY=t),this.param!=null&&this.param.setGridY(t)}getGridY(){var t;return((t=this.param)==null?void 0:t.getGridY())||this._stepY}getMultiRatio(){var t;return((t=this.param)==null?void 0:t.getMultiRatio())||this._multiRatio}setMultiRatio(t){t>=1&&(this._multiRatio=t),this.param!=null&&this.param.setMultiRatio(t)}getMultiStyle(){var t;return((t=this.param)==null?void 0:t.getMultiStyle())||this._multiStyle}setMultiStyle(t){this._multiStyle=t,this.param!=null&&this.param.setMultiStyle(t)}setSnapX(t){t>0&&(this._snapX=t),this.param!=null&&this.param.setSnapX(t)}getSnapX(){var t;return((t=this.param)==null?void 0:t.getSnapX())||this._snapX}setSnapY(t){t>0&&(this._snapY=t),this.param!=null&&this.param.setSnapY(t)}getSnapY(){var t;return((t=this.param)==null?void 0:t.getSnapY())||this._snapY}get pattern(){var t;return((t=this.param)==null?void 0:t.pattern)||this._pattern}set pattern(t){this._pattern=t,this.param!=null&&(this.param.pattern=t)}get transparency(){var t;return((t=this.param)==null?void 0:t.transparency)||this._transparency}set transparency(t){this._transparency=t,this.param!=null&&(this.param.transparency=t)}get multiGridColor(){var t;return((t=this.param)==null?void 0:t.multiGridColor)||this._multiGridColor}set multiGridColor(t){this._multiGridColor=t,this.param!=null&&(this.param.multiGridColor=t)}get multiTransparency(){var t;return((t=this.param)==null?void 0:t.multiTransparency)||this._multiTransparency}set multiTransparency(t){this._multiTransparency=t,this.param!=null&&(this.param.multiTransparency=t)}get coordinateAxisColor(){var t;return((t=this.param)==null?void 0:t.coordinateAxisColor)||this._coordinateAxisColor}set coordinateAxisColor(t){this._coordinateAxisColor=t,this.param!=null&&(this.param.coordinateAxisColor=t)}get coordinateAxisTransparency(){var t;return((t=this.param)==null?void 0:t.coordinateAxisTransparency)||this._coordinateAxisTransparency}set coordinateAxisTransparency(t){this._coordinateAxisTransparency=t,this.param!=null&&(this.param.coordinateAxisTransparency=t)}};qf.scenes=[],qf.ins=null;var Is=qf;var An=class An{constructor(){this._isConcurrentStrictMode=!1;this._isReadOnlyMode=!1;this._origin=ae.ORIGIN;this._doctype=0;this._id="";this._tabId="";this._isactive=!1;this._owner=null;this._customerCode=void 0;this._clientOnlineService=void 0;this._unit="mil";this.scenes=new Array(0);this._footprintIsConnectDevice=!1;this._editorVersion="";this._projectTitle="";this._importFlag=0;this._source="";this._envFlag=null;this.partitionId="";this.name="";this.currOpenProjectId=void 0;this.currVersionUUid=void 0;this._compiler=null;this._altGridSize={GridX:{number:5,unit:this.unit},GridY:{number:5,unit:this.unit}};this._gridType="grid";this._multiType="none";this._multiRatio=5;this._forceDeactive=!1;this._forceValue=.5;this.highLightModeIsDark=!0;this._forceVisibleHighLightPt=!1;this._forceVisibleRange=!1;this._backgroundColor=rr.build(0,0,0,1);this._openRuler=!1;this._rulerBackgroundColor=null;this._rulerStringColor=null;this.antialias=!1;this._needRenderPanelize=!1;this._renderMode=Uy.USE_COLOR;this.time=new Date().getTime();this.num=Math.floor(Math.random()*100);this._panelizeParam={success:!1,on:!1,row:1,column:1,offset:new ae(0,0),onlyOutline:!0};this._coreRenderingEngine="auto";this._isPreview=!1;this.compilerChannel=new M1;this._isHistoryMode=!1;this.workerName="";this.needNum=!0}static getInstance(){return An.env==null&&(An.env=new An),An.env}get isPreview(){return this._isPreview}set isPreview(t){this._isPreview=t,t&&(this.openRuler=!1)}get isHistoryMode(){return this._isHistoryMode}set isHistoryMode(t){this._isHistoryMode=t}get compiler(){return this._compiler==null&&(this._doctype==4?this._compiler=new RO(this._id,this.projectId,this.compilerChannel,void 0):this._doctype==3?(this._compiler=new Vf(this._id,this.projectId,this.compilerChannel,void 0),this._compiler.consistencyManager.setIsLocalChange(!1),this._compiler.consistencyManager.setIsPendChange(!1)):(this._compiler=new Vf(this._id,this.projectId,this.compilerChannel,void 0),this._compiler.consistencyManager.setIsLocalChange(!1),this._compiler.consistencyManager.setIsPendChange(!1))),this._compiler}get channel(){return(this.time+this.num).toString()}async resetCompiler(){this._compiler&&(await this._compiler.destroy(),this._compiler=null)}modify(t,i,r,s,n,a,o,l){this.doctype=t,this.id=i,this.tabId=r,this.isactive=s,this.owner=n,this.customerCode=a,this.name=o,this.origin=l}get gridType(){return this._gridType}set gridType(t){if(t!=null&&this._gridType!=t&&Is.getInstance().visible!=sa.NOTSHOW)switch(this._gridType=t,t){case"grid":Is.getInstance().pattern=!0,Is.getInstance().visible=sa.SHOW;break;case"outlets":Is.getInstance().pattern=!1,Is.getInstance().visible=sa.SHOW;break;case"none":Is.getInstance().visible=sa.ONLYAXIS;break}}get altGridSize(){return this._altGridSize}set altGridSize(t){this._altGridSize=t}getAltGridSize(){let t=this._altGridSize.GridX,i=this._altGridSize.GridY,r=t.number/10,s=i.number/10,n=new Rs;return An.getInstance().unit=="mil"?t.unit!=An.getInstance().unit&&(r=n.conversion(t.unit,An.getInstance().unit,r),s=n.conversion(i.unit,An.getInstance().unit,s)):t.unit==An.getInstance().unit&&(r=n.conversion(t.unit,"mil",r),s=n.conversion(i.unit,"mil",s)),{snapX:r,snapY:s}}set forceValue(t){this._forceDeactive&&this._forceValue!=t&&this.updateForceDeactivateRatio(t,this._forceDeactive),this._forceValue=t}get forceValue(){return this._forceValue}set forceDeactive(t){this._forceDeactive=t,this.updateForceDeactivateRatio(this._forceValue,t)}updateForceDeactivateRatio(t,i){t=t>.99?.99:t;for(let r of this.scenes)r.setForceDeactivateRatio(i?t:1)}set forceVisibleHighLightPt(t){this._forceVisibleHighLightPt=t,this.forceVisible()}set forceVisibleHighRange(t){this._forceVisibleRange!=t&&(this._forceVisibleRange=t,this.forceVisible())}get forceVisibleHighRange(){return this._forceVisibleRange}forceVisible(){let t=this._forceVisibleRange&&this._forceVisibleHighLightPt;for(let i of this.scenes)i.setForceVisibleHighLightPt(t)}setHighLightMode(t){if(this.highLightModeIsDark!=t){for(let i of this.scenes)i.setGlobalHighLightType(t?mu.PT:mu.MASK);this.highLightModeIsDark=t}}get forceVisibleHighLightPt(){return this._forceVisibleHighLightPt}get forceDeactive(){return this._forceDeactive}get projectTitle(){return this._projectTitle}set projectTitle(t){this._projectTitle=t||""}get editorVersion(){return this._editorVersion}set editorVersion(t){this._editorVersion=t||""}get isReadOnlyMode(){return this._isReadOnlyMode}set isReadOnlyMode(t){this._isReadOnlyMode=t}get isConcurrentStrictMode(){return this._isConcurrentStrictMode}set isConcurrentStrictMode(t){this._isConcurrentStrictMode=t}get importFlag(){return this._importFlag}set importFlag(t){this._importFlag=t||0}get source(){return this._source}set source(t){this._source=t||""}get envFlag(){return this._envFlag}set envFlag(t){this._envFlag=t}get multiType(){return this._multiType}set multiType(t){let i=Is.getInstance();if(this._multiType!=t&&i.visible!=sa.NOTSHOW)switch(this._multiType=t,t){case"grid":i.setMultiStyle(Oh.Line);break;case"outlets":i.setMultiStyle(Oh.Point);break;case"none":i.setMultiStyle(Oh.None);break}}get multiRatio(){return this._multiRatio}set multiRatio(t){let i=Is.getInstance();this._multiRatio!=t&&(this._multiRatio=t,i.setMultiRatio(t))}get unit(){return this._unit}set unit(t){this._unit=t;for(let i of this.scenes)i.modifyUnit(t)}get projectId(){let t=this._tabId.split("@");return t.length>=2?t[1]:""}getRatio(){for(let t of this.scenes)return(t==null?void 0:t.getPixelRatio())||1;return 1}attachScene(t){return!this.scenes.includes(t)&&t!=null&&(this.scenes.push(t),t.modifyUnit(this._unit),t.modifyBgColor(this._backgroundColor),t.resize(),t.setAntialias(this.antialias),t.openRuler=this._openRuler,this._rulerBackgroundColor&&t.setRulerBackgroundColor(this._rulerBackgroundColor),this._rulerStringColor&&t.setRulerStringColor(this._rulerStringColor),t.needRenderPanelize=this._needRenderPanelize,t.setRenderMode(this._renderMode),t.group.setRenderMode(this._renderMode),this._panelizeParam.success&&!this._panelizeParam.onlyOutline?t.setPanelizeInfo(this._panelizeParam.offset,this._panelizeParam.row,this._panelizeParam.column):t.setPanelizeInfo(),t.setForceVisibleHighLightPt(this._forceVisibleRange&&this._forceVisibleHighLightPt),t.setGlobalHighLightType(this.highLightModeIsDark?mu.PT:mu.MASK)),!0}getBgColor(){return this._backgroundColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t;for(let i of this.scenes)i.modifyBgColor(t)}get rulerBackgroundColor(){return this._rulerBackgroundColor}set rulerBackgroundColor(t){if(this._rulerBackgroundColor=t,t!=null)for(let i of this.scenes)i.setRulerBackgroundColor(t)}get rulerStringColor(){return this._rulerStringColor}set rulerStringColor(t){if(this._rulerStringColor=t,t!=null)for(let i of this.scenes)i.setRulerStringColor(t)}resize(t,i){for(let r of this.scenes)r.resize()}get openRuler(){return this._openRuler}set openRuler(t){this._openRuler=t;for(let i of this.scenes)i.openRuler=t}get needRenderPanelize(){return this._needRenderPanelize}set needRenderPanelize(t){this._needRenderPanelize=t;for(let i of this.scenes)i.needRenderPanelize=t}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode=t;for(let i of this.scenes)i.setRenderMode(t),i.group.setRenderMode(t)}getAntialias(){return this.antialias}setAntialias(t){this.antialias=t;for(let i of this.scenes)i.setAntialias(t)}get origin(){return this._origin}set origin(t){this._origin=t,this.scenes.forEach(i=>{i.setOrigin(this._origin)})}get customerCode(){return this._customerCode}set customerCode(t){this._customerCode=t}get owner(){return this._owner}set owner(t){this._owner=t}get clientOnlineService(){return this._clientOnlineService}set clientOnlineService(t){this._clientOnlineService=t}get doctype(){return this._isPreview&&(this._doctype==4||this._doctype==3)?23:this._doctype}set doctype(t){this._doctype=t}get id(){return this._id}set id(t){this._id=t}get tabId(){return this._tabId}set tabId(t){this._tabId=t}get isactive(){return this._isactive}set isactive(t){this._isactive=t}get footprintIsConnectDevice(){return this._footprintIsConnectDevice}set footprintIsConnectDevice(t){this._footprintIsConnectDevice=t}get panelizeParam(){return this._panelizeParam}set panelizeParam(t){this._panelizeParam=t,this.scenes.forEach(i=>{this._panelizeParam.success&&!this._panelizeParam.onlyOutline?i.setPanelizeInfo(this._panelizeParam.offset,this._panelizeParam.row,this._panelizeParam.column):i.setPanelizeInfo()})}get coreRenderingEngine(){return this._coreRenderingEngine}set coreRenderingEngine(t){typeof t<"u"&&this._coreRenderingEngine!=t&&(this._coreRenderingEngine=t)}getSceneBbox(){let t=new Kn;return this.scenes.forEach(i=>{t.ext4(i.getBBox3())}),t.build()}};An.env=null;var Eu=An;function Wy(e,t=3,i=Eu.getInstance().unit,r=new Rs){e=e*10,t==null&&(t=3);let s=r||new Rs;i!="mil"&&(e=s.conversion("mil",i,e)),i=="mil"&&t==3&&(t=1);let n=Math.pow(10,t);return Math.round(e*n)/n}var MA=new Rs;var zA=[1,10,100,1e3],BA="http://www.w3.org/2000/svg",kA="http://www.w3.org/1999/xlink",FA="http://www.w3.org/XML/1998/namespace",UA="https://easyeda.com/",Oge=(function(){var e={svg:BA,xlink:kA,xml:FA,c:UA};return e[BA]="svg",e[kA]="xlink",e[FA]="xml",e[UA]="c",e})();var sr=(function(){var e={RATLINES:9,MODEL3D:19,ALL:11,TOPSILKLAYER:3,TOPLAYER:1,TOPPASTERLAYER:5,TOPSOLDERLAYER:7,LIBBODY:99,PADSURFACE:100,BOARDOUTLINE:10,DOCUMENT:12,TOPASSEMBLY:13,MECHANICAL:15,TOPCOMPONENT:16,SUBSTRATE:18},t;for(t=21;t<53;t++)e["INNER"+(t-20)]=t;for(e.BOTTOMSILKLAYER=4,e.BOTTOMLAYER=2,e.BOTTOMPASTERLAYER=6,e.BOTTOMSOLDERLAYER=8,e.BOTTOMASSEMBLY=14,e.BOTTOMCOMPONENT=17,t=53;t<85;t++)e["BOARD"+(t-52)]=t;return e})(),mge=(function(){var e={COPPERAREA:[1,2,21,22,23,24],PLANEZONE:[1,2,21,22,23,24],RECT:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,99],TRACK:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],PAD:[11,1,2],VIA:[11],HOLE:[11],TEXT:[3,4,1,2,7,8,12,13,14,15,21,22,23,24],ARC:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],ELLIPSE:[3,4,12,13,14,15],CIRCLE:[1,2,3,4,5,6,7,8,10,12,13,14,15,21,22,23,24,99],DIMENSION:[3,4,12,13,14,15],FOOTPRINT:[1,2],SOLIDREGION:[1,2,3,4,5,6,7,8,12,13,14,15,21,22,23,24,11,99,100],SVGNODE:[1,2,3,4,7,8,12,13,14,15],PROTRACTOR:[3,4,12,13,14,15],SHEET:[12,13,14,15]};e["3D"]=(function(){for(var s=[16,19,3,7,5,1],n=21;n<52;n++)s.push(n+32,n);return s.push(2,6,8,4,17),s})();var t,i,r;for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],r.indexOf(21)>0&&r.indexOf(25)===-1))for(i=25;i<=52;i++)r.push(i);return e})(),Ur=(function(){var e={1:"TopLayer",2:"BottomLayer",3:"TopSilkLayer",4:"BottomSilkLayer",5:"TopPasteMaskLayer",6:"BottomPasteMaskLayer",7:"TopSolderMaskLayer",8:"BottomSolderMaskLayer",9:"Ratlines",10:"BoardOutLine",11:"Multi-Layer",12:"Document",13:"TopAssembly",14:"BottomAssembly",15:"Mechanical",16:"TopComponents",17:"BottomComponents",18:"Substrate",19:"3DModel",99:"ComponentShapeLayer",100:"LeadShapeLayer"},t;for(t=21;t<53;t++)e[t]="Inner"+(t-20);for(t=53;t<85;t++)e[t]="Substrate"+(t-52);return e})(),bge=(function(){var e=[],t=[];for(var i in sr)if(sr.hasOwnProperty(i)){if(i.match(/^BOARD\d+/))continue;e.push(sr[i])}e.sort(),t.sort();var r={},s,n={21:"#999966",22:"#008000",23:"#00FF00",24:"#BC8E00",25:"#70DBFA",26:"#00CC66",27:"#9966FF",28:"#800080",29:"#008080",30:"#15935F",31:"#000080",32:"#00B400",33:"#2E4756",34:"#99842F",35:"#FFFFAA",36:"#99842F",37:"#2E4756",38:"#3535FF",39:"#8000BC",40:"#43AE5F",41:"#C3ECCE",42:"#728978",43:"#39503F",44:"#0C715D",45:"#5A8A80",46:"#2B937E",47:"#23999D",48:"#45B4E3",49:"#215DA1",50:"#4564D7",51:"#6969E9",52:"#9069E9"};e.forEach(function(o){switch(o){case sr.TOPLAYER:s={name:Ur[o],color:"#FF0000",darkColor:"#CC0000",visible:!0,active:!0,config:!0};break;case sr.BOTTOMLAYER:s={name:Ur[o],color:"#0000FF",darkColor:"#000080",visible:!0,active:!1,config:!0};break;case sr.TOPSILKLAYER:s={name:Ur[o],color:"#FFCC00",darkColor:"#806600",visible:!0,active:!1,config:!0};break;case sr.BOTTOMSILKLAYER:s={name:Ur[o],color:"#66CC33",darkColor:"#33661A",visible:!0,active:!1,config:!0};break;case sr.TOPPASTERLAYER:s={name:Ur[o],color:"#808080",darkColor:"#666666",visible:!0,active:!1,config:!0};break;case sr.BOTTOMPASTERLAYER:s={name:Ur[o],color:"#800000",darkColor:"#660000",visible:!0,active:!1,config:!0};break;case sr.TOPSOLDERLAYER:s={name:Ur[o],color:"#800080",darkColor:"#660066",visible:!0,active:!1,transparency:.3,config:!0};break;case sr.BOTTOMSOLDERLAYER:s={name:Ur[o],color:"#AA00FF",darkColor:"#8800CC",visible:!0,active:!1,transparency:.3,config:!0};break;case sr.RATLINES:s={name:Ur[o],color:"#6464FF",darkColor:"#5050CC",visible:!1,active:!1,config:!0};break;case sr.BOARDOUTLINE:s={name:Ur[o],color:"#FF00FF",darkColor:"#CC00CC",visible:!0,active:!1,config:!0};break;case sr.ALL:s={name:Ur[o],color:"#C0C0C0",darkColor:"#999999",visible:!0,active:!1,config:!0};break;case sr.DOCUMENT:s={name:Ur[o],color:"#FFFFFF",darkColor:"#CCCCCC",visible:!0,active:!1,config:!0};break;case sr.TOPASSEMBLY:s={name:Ur[o],color:"#33CC99",darkColor:"#33AA99",visible:!1,active:!1,config:!1};break;case sr.BOTTOMASSEMBLY:s={name:Ur[o],color:"#5555FF",darkColor:"#8888FF",visible:!1,active:!1,config:!1};break;case sr.MECHANICAL:s={name:Ur[o],color:"#F022F0",darkColor:"#F088F0",visible:!1,active:!1,config:!1};break;case sr.MODEL3D:s={name:Ur[o],color:"#66CCFF",visible:!1,active:!1,config:!1};break;case sr.LIBBODY:s={name:Ur[o],color:"#00CCCC",visible:!1,active:!1,config:!1};break;case sr.PADSURFACE:s={name:Ur[o],color:"#CC9999",visible:!1,active:!1,config:!1};break;default:o>=sr.INNER1&&o<=sr.INNER32?s={name:Ur[o],color:n[o],darkColor:a(n[o]),visible:!1,active:!1,config:!1}:s=null;break}s&&(r[o]=s)}),r.Hole={config:!0,name:"Hole",darkColor:"#222222",color:"#222222"},r.DRCError={config:!0,name:"DRCError",color:"#FAD609",darkColor:"#FAD609"};function a(o){if(typeof o!="string"||!o.match(/#?([\da-f]{6})/i))return o;var l=parseInt(RegExp.$1,16),h=.5,c=Math.min(255,Math.round((l>>16)*h)),d=Math.min(255,Math.round((l>>8&255)*h)),f=Math.min(255,Math.round((l&255)*h)),u=((c<<16)+(d<<8)+f).toString(16);return"#"+("00000"+u).substr(-6).toUpperCase()}return r})(),GA={BLANK:0,SCH:1,PART:2,PCB:3,FOOTPRINT:4,PRJ:5,SUBPART:6,SPICESYMBOL:7,SUBCKT:8,NETLIST:9,WAVEFORM:10,SCHLIB3D:11,PHOTOVIEW:12,SCHMODULE:13,PCBMODULE:14,VIEW3D:15,PCBLIB3D:16,BLOCK_SYMBOL:17,NETFLAG:18,NETPORT:19,SHEET_SYMBOL:20,NONEELEC_SYMBOL:21,SHORT_SYMBOL:22,FOOTPRINTVIEW:23,PCB2D:31,PCB3D:32},yge=(function(){var e={};for(let t in GA)e[GA[t]]=t;return e})();var Ege=Math.PI*2,wge=Math.PI/2,Tge=Math.sin(Math.PI/180);function HA(e,t,i){if(typeof e!="number"&&(e=+e),isNaN(e))return NaN;if(t=t|0,t<=0||!e&&!i)return Math.round(e);var r=zA[t]||Math.pow(10,t)||10;if(i){var s=e<0?"-":"";for(e=e<0?-e:e,e=Math.round(e*r)+"";e.length<=t;)e="0"+e;return e=e.slice(0,-t)+"."+e.slice(-t),parseFloat(s+e)}else return Math.round(e*r+1e-10)/r}var cJ=Math.PI*2;var uJ=Math.PI/2,Ige=Math.PI/4,Pge=Math.sin(Math.PI/180);function jA(e){return e*180/Math.PI}var UO=new Fa(39.37,1).ratio,dJ=new Fa(39.37,10).ratio,Jy=new Fa(1,39.37).ratio,fJ=new Fa(393.7,1).ratio,pJ=new Fa(39370,1).ratio,gJ=new Fa(1e3,1).ratio,Vs=window["META-PANELIZE-ENV"]?window:Ri().location.search.search("entry=pcb3dview")!==-1?Ri().opener.top:Ri(),Pu=!!window.frameElement,Xy=!!window["USE-IFRAME-FOR-MAIN"]||window["META-PANELIZE-ENV"];if(!Xy)try{Ri().sensorsDataFromTopWindow}catch{Xy=window["USE-IFRAME-FOR-MAIN"]=!0}Pu&&!Xy&&document.write(YA.default);function qA(){let e=document.querySelector(window.canvas_3d_selector||"#canvas-3d")||document.getElementById("canvas");if(e instanceof HTMLCanvasElement)return e;{let t=document.createElement("canvas");return t.style.width="100%",t.style.height="100%",t}}var ji="0",Ba=qA(),vh=new ip(1),Oe=window._MSG_BUS_=window._MSG_BUS_||new GO.MessageBus(!Pu),Mi=Pu?new GO.WindowMessageBridge(Oe):Oe;Pu||(Oe.unsafe=!0);var VA={top:[0,-90,0],bottom:[0,90,180],left:[-90,0,0],right:[90,0,0],front:[0,0,0],back:[180,0,0]};function aa(e,t,i=Ri()){Mi.subscribe(e,i),Oe.subscribe(e,t)}var Zy=null,cn=null,tt={dx:0,dy:0,dz:0,rx:0,ry:0,rz:0,x:0,y:0,z:0,ox:0,oy:0,oz:0},Ys={},Ci={},fs=[],wu=Pu?"#000000":"",Ie={material:"substrate_yellow",bgColor:wu,solderMaskColor:"blue",sprayColor:"gold",unit:"mm",silkTechnology:"standardSilk",topSilkDefaultColor:"#000000",topSilkBackgroundColor:"#000000",botSilkDefaultColor:"#000000",botSilkBackgroundColor:"#000000",isUsedJLCColorSilk:void 0,dragMiddleMouseButton:"",mode:"normal",pcbUuid:"",tabid:"",isActive:!0,isFpcStiffener:[],thicknessArr:[],pcbDefaultThicknessArr:[],expose:0,substrateHeight:0,gridSetting:{startAngle:0,endAngle:360,minRadius:39.37,maxRadius:3937,gridX:5,gridY:5,polarAngle:45,polarRadius:393.7,isCartesian:!0,gridType:"outlets",unit:"mil"},coord:{x:0,y:0,dx:0,dy:0,s:1},showSilk:"yes",flip:!1};function _J(){tt.dx=tt.dx,tt.dy=tt.dy,tt.dz=tt.dz,tt.rx=tt.rx,tt.ry=tt.ry,tt.rz=tt.rz,tt.x=tt.x,tt.y=tt.y,tt.z=tt.z}function OJ(e){switch(e){case"mm":return UO;case"cm":return fJ;case"m":return pJ;case"inch":return gJ;default:return 1}}function mJ(e,t,i){if(e){let r=e.maxX-e.minX,s=e.maxY-e.minY,n=e.maxZ-e.minZ,a=[tt.dx/r,tt.dy/s,tt.dz/n].filter(l=>isFinite(l)&&l>0),o=Math.min(...a);o=isFinite(o)&&o>0?o:i||1,tt.dx=r*o,tt.dy=s*o,tt.dz=n*o,tt.ox=r*t,tt.oy=s*t,tt.oz=n*t}}function WA(e){return new Promise((t,i)=>{let r=new FileReader;r.onload=s=>{t({data:r.result,error:null})},r.oneror=s=>{t({data:null,error:s})},r.readAsArrayBuffer(e)})}var Wf=Promise.resolve();async function Ky(){let e;for(;e!==Wf;)e=Wf,await Wf;let t;return Wf=new Promise(i=>t=i),t}Oe.rpcService("/pcb/3d/sync/unlock",()=>(Wf=void 0,!0));var $y,El=0;async function Iu(e=!1,t){El=(El+1)%Number.MAX_SAFE_INTEGER;let i=El,r=await Ky();if(i!==El){r();return}let s=new Promise(async a=>{if(cn){let o=tt.dx===0&&tt.dy===0&&tt.dz===0;_J();let l=OJ(cn.unit),h=o?{scale:l}:{},c={uuid:cn.model,path:Zy},d=Object.assign(c,tt,h);if(t){let y=JSON.parse(t.trim().slice(3)),O=new Bi([y[0],y[1],y[2],0,y[3],y[4],y[5],0,y[6],y[7],y[8],0,y[9],y[10],y[11],1]).data;d=Object.assign(c,{transformV2:JSON.stringify([O[0],O[1],O[2],O[4],O[5],O[6],O[8],O[9],O[10],O[12],O[13],O[14]])})}let u=[["DOCTYPE","PREVIEW","1.0"],["LAYER","9","TOP_ASSEMBLY","Top Assembly Layer",3,"#33cc99",1,"#33cc99",1],["COMPONENT","e1",0,9,0,0,0,d,0]].map(y=>JSON.stringify(y)).join(`
`);$y=u;let p,g=new Promise(y=>p=y),_=Oe.subscribe("/engine/model/finishLoading",async y=>{_.cancel();let m=(await Oe.rpcCall("/engine/model/originBBox","e1")).message;mJ(m,l,d.scale);let O=y.e1,b=[tt.dx,tt.dy,tt.dz,tt.rz,tt.rx,tt.ry,tt.x,tt.y,tt.z].join(",");Mi.publish("/pcb/3d/model/updated",{transform:b,ox:tt.ox,oy:tt.oy,oz:tt.oz,status:O.modelStatus===0},Ri()),p()});await Oe.rpcCall("/engine/load/data",[u,!0,e]),await g,delete d.uuid,await Oe.rpcCall("/engine/model/setComponentInfo",d)}a()}),n=new Promise((a,o)=>{setTimeout(()=>o(new Error("timeout")),30*1e3)});try{await Promise.race([s,n])}catch(a){Vy.publish("ui/toastMsg",{type:"info",msg:a.message=="timeout"?"3D model is too large to load":a.message},Ri())}r()}var xh=AA(async()=>{await Oe.rpcCall("/engine/init",{canvasId:qA().id,defaultModel:"gray_cuboid"}),await Oe.rpcCall("/engine/camera/add",[ji,-1,1,-1,1]),await Oe.rpcCall("/engine/camera/set3DType",[ji,!1]),await Oe.rpcCall("/engine/pcb/setMode",1),await Oe.rpcCall("/engine/layer/setTypeGroup",{TOP_SILK:0,TOP_SPRAY:0,TOP_SOLDER_MASK:0,TOP:0,BOTTOM:0,BOT_SOLDER_MASK:0,BOT_SPRAY:0,BOT_SILK:0}),await Oe.rpcCall("/engine/setSampling",2),await Oe.rpcCall("/engine/layer/setBuildBoardWaitTime",1e4),await Oe.rpcCall("/engine/layer/setUsePaste",!1);let e=Ba.style.cursor,t=i=>{Ba.setAttribute("dragging","true")};Ba.addEventListener("mousedown",i=>{(i.button===2||i.button===1&&Ie.dragMiddleMouseButton==="moveCanvas")&&(qy("grabbing"),Ba.addEventListener("mousemove",t))}),Ba.addEventListener("mouseup",i=>{i.button===2&&window.frameElement.id.startsWith("frame_preview_")&&(!Ba.hasAttribute("dragging")&&Mi.publish("showPreviewRightClickMenu",{x:i.clientX,y:i.clientY,iframeElementId:window.frameElement.id,isEnableRemovableByBlur:!0},Ri()),Ba.removeAttribute("dragging"),Ba.removeEventListener("mousemove",t))}),window.addEventListener("mouseup",i=>{qy(e)})});function NO(e,t=3){let i=Math.pow(10,t);return Math.round(e*Jy*i)/i}function yh(){function e(i){return i.map(r=>({text:r,value:r}))}let t={"attr-board-material":{value:Ie.material,disabled:!1,options:e(["substrate_yellow","substrate_fpc","aluminum","substrate_coppery","substrate_white","substrate_grey"])},"attr-board-side":{value:Ie.flip?"bottomSide":"topSide",disabled:!1,options:e(["topSide","bottomSide"])},"attr-silk-technology":{value:Ie.silkTechnology,disabled:!1,options:e(["colorfulSilk","standardSilk"])},"attr-background-color":{value:Ie.bgColor,disabled:!1,defaultValue:wu},"attr-board-color":{value:Ie.solderMaskColor,disabled:!1,options:e(PA.map(i=>i))},"attr-top-side-board-color":{disabled:!0,value:Ie.topSilkBackgroundColor},"attr-top-side-silkscreen-color":{disabled:!0,value:Ie.topSilkDefaultColor,defaultValue:wu},"attr-bottom-side-board-color":{disabled:!0,value:Ie.botSilkBackgroundColor,defaultValue:wu},"attr-bottom-side-silkscreen-color":{disabled:!0,value:Ie.botSilkDefaultColor,defaultValue:wu},"attr-pad-plating-color":{value:Ie.sprayColor,disabled:!1,options:e(["gold","silver"])},"attr-silk":{value:Ie.showSilk,disabled:!1,options:[{text:"Visible",value:"yes"},{text:"Hide",value:"no"}]}};Mi.publish("renderPhotoPanel",{attrlists:[{title:"Property",data:t,status:Ie}]},Ri())}var XA=()=>{};aa("updateIFrameState",e=>{Ie.isActive=e.head.to===Ie.tabid,Ie.isActive&&XA()});var kO=-1,FO=-1;window.addEventListener("mousemove",e=>{kO=e.clientX,FO=e.clientY});aa("centerViewByCursor",async()=>{let e=Ba.getBoundingClientRect();kO<e.left||kO>e.right||FO<e.top||FO>e.bottom||Oe.rpcCall("/engine/camera/move",[ji,e.x+e.width/2-kO,e.y+e.height/2-FO])});aa("photoView_centerByCur_hotkey",e=>{Ie.isActive&&e.key==="4-2-centerViewByCursor"&&Oe.publish("centerViewByCursor")});Oe.rpcService("/pcb/3d/sync/2dview",async e=>{let t="Preview2DInit-time";jf(t),[Ie.tabid,Ie.pcbUuid]=e;function i(){Mi.publish("renderPhotoCoord",{x:NO(Ie.coord.x),y:NO(Ie.coord.y),dx:NO(Ie.coord.dx),dy:NO(Ie.coord.dy),gridX:Wy(Is.getInstance().getGridX(),3,Ie.unit),gridY:Wy(Is.getInstance().getGridY(),3,Ie.unit),polarAngleStep:HA(jA(Is.getInstance().angleDelta),1,!0),polarRadiuStep:MA.conversion1("mil",Ie.unit,Is.getInstance().radius*10),unit:Ie.unit,scale:Ie.coord.s,tabId:Ie.tabid},Ri())}function r(){let a={};a.flipBoard=Ie.flip,a[`Grid(${Ie.gridSetting.gridX}mil,${Ie.gridSetting.gridY}mil)`]=!0,a[`GridPolar(${Ie.gridSetting.polarAngle},${Ie.gridSetting.polarRadius})`]=!0,a[`swithCoordinate(${Ie.gridSetting.isCartesian?"cartesian":"polar"})`]=!0,a[`switchGridType(${Ie.gridSetting.gridType})`]=!0,Mi.publish("setPcbMenuItemChecked",a,Ri())}async function s(){await Oe.rpcCall("/engine/scene/setPolarRadius",[Ie.gridSetting.minRadius,Ie.gridSetting.maxRadius]),await Oe.rpcCall("/engine/scene/setPolarAngle",[Ie.gridSetting.startAngle,Ie.gridSetting.endAngle]),await Oe.rpcCall("/engine/scene/setUnit",Ie.unit)}Oe.subscribe("/engine/camera/update",a=>{Ie.coord.s=a.scale*10,i()}),Oe.subscribe("/engine/mouse/moved",a=>{Ie.coord.x=a.pcbX,Ie.coord.y=a.pcbY,Ie.coord.dx=a.deltaX,Ie.coord.dy=a.deltaY,i()}),Oe.subscribe("modifyPhotoAttr",a=>{let{key:o,value:l}=a;if(o==="attr-board-material")Ie.material=l,JA("SUBSTRATE",l),Ie.material=="substrate_fpc"?(["yellow","black"].includes(Ie.solderMaskColor)||(Ie.solderMaskColor="yellow",qs("TOP_SOLDER_MASK","solder_mask_yellow"),qs("BOT_SOLDER_MASK","solder_mask_yellow")),fs.SilkTechnologyCacheTo2D=xl(Ie.silkTechnology),fs.sprayColorTo2D=xl(Ie.sprayColor),Ie.silkTechnology="standardSilk",Tu("standardSilk"),Su("gold")):(fs.SilkTechnologyCacheTo2D&&fs.sprayColorTo2D&&(Ie.silkTechnology=fs.SilkTechnologyCacheTo2D,Ie.sprayColor=fs.sprayColorTo2D,Tu(Ie.silkTechnology),Su(Ie.sprayColor)),Oe.publish("modifyPhotoAttr",{key:"attr-board-color",value:"blue"}));else if(o==="attr-background-color")l==="none"&&(l=wu),Ie.bgColor=l,document.body.style.backgroundColor=l,Oe.rpcCall("/engine/scene/setBackgroundColor",[l,1]);else if(o==="attr-board-color")Ie.solderMaskColor=l,qs("TOP_SOLDER_MASK",`solder_mask_${l}`),qs("BOT_SOLDER_MASK",`solder_mask_${l}`);else if(o==="attr-pad-plating-color")Su(l);else if(o==="attr-silk"){Ie.showSilk=l;let h=Ci.TOP_SILK,c=Ci.BOT_SILK,d=l==="yes";h&&(Oe.rpcCall("/engine/layer/setVisible",[h[0],d]),Ys[h[0]].isVisible=d),c&&(Oe.rpcCall("/engine/layer/setVisible",[c[0],d]),Ys[c[0]].isVisible=d)}else o==="attr-board-side"?(l==="bottomSide"&&!Ie.flip||l==="topSide"&&Ie.flip)&&Oe.publish("flipBoard"):o==="attr-silk-technology"&&(Ie.material!=="substrate_fpc"&&(fs.SilkTechnologyCacheTo2D=l),Tu(l));yh()}),aa("adaptAll",async()=>{let a=(await Oe.rpcCall("/engine/layer/getBoardBBox","")).message;if(!a){await Oe.rpcCall("/engine/setAbleRender",!0);return}let[o,l,h,c]=a,d=(h-o)/4,f=(c-l)/4;await Oe.rpcCall("/engine/camera/adaptBBox",[ji,o-d,l-f,0,h+d,c+f,0]),await Oe.rpcCall("/engine/setAbleRender",!0)}),XA=()=>{r(),yh(),i()},aa("updateGridRange",a=>{Ie.gridSetting.startAngle=parseFloat(a.startAngle),Ie.gridSetting.endAngle=parseFloat(a.endAngle),Ie.gridSetting.minRadius=parseFloat(a.minRadius),Ie.gridSetting.maxRadius=parseFloat(a.maxRadius),s()}),Oe.rpcService("/pcb/3d/getDefaultPngSize",async()=>(await Oe.rpcCall("/engine/capture/getInfo",[ji,{fixedWidth:2160}])).message),Oe.rpcService("/pcb/3d/export/png",async a=>{let o=(await Oe.rpcCall("/engine/capture/png",[ji,{fixedWidth:a.width||2160,watermarkConfig:a.watermarkConfig}])).message;if(Hm){let h={data:{fileData:(await WA(o)).data,fileTitle:a.fileName,extension:"png"}};Mi.publish("exportFileClientWay",h,Ri())}else Ao.downloadFile(a.fileName,o)}),Oe.rpcService("/pcb/3d/exportViewBox/png",async a=>({data:(await Oe.rpcCall("/engine/capture/png",[ji,{fixedWidth:2160},void 0,void 0,!0])).message,width:2160,height:1080})),Oe.subscribe("switchCoordinate",a=>{Ie.gridSetting.isCartesian=a,Oe.rpcCall("/engine/scene/setCoordSys",a)}),aa("zoom",a=>{a=="in"?Oe.rpcCall("/engine/camera/mulScale",[ji,1.5]):Oe.rpcCall("/engine/camera/mulScale",[ji,1/1.5])}),aa("flipBoard",()=>{Oe.rpcCall("/engine/camera/set2DType",[ji,Ie.flip]),Ie.flip=!Ie.flip,yh(),r()}),aa("home_hotkey",a=>{Ie.isActive&&a.message.key==="4-2-Flip Board"&&Oe.publish("flipBoard")}),aa("blank_tab_hotkey",a=>{Ie.isActive&&a.message.key==="4-3-Flip Board"&&Oe.publish("flipBoard")}),Oe.rpcService("getGridRange",()=>Ie.gridSetting),aa("doPcbCommand",a=>{let{cmd:o,args:l}=a;var h=o.match(/\((.*?)\)$/);if(!h)return;let c=o.split(h[0])[0],d=h[1];if(c==="Grid"){let f=d.split(",").map(u=>parseFloat(u));Oe.rpcCall("/engine/scene/setGridDelta",f),Ie.gridSetting.gridX=f[0],Ie.gridSetting.gridY=f[1],i()}else c==="GridPolar"&&Oe.rpcCall("/engine/scene/setPolarDelta",d.split(",").map(f=>parseFloat(f)))}),Oe.subscribe("switchGridType",a=>{Ie.gridSetting.gridType=a,a==="outlets"?(Oe.rpcCall("/engine/scene/setGridPattern",!1),Oe.rpcCall("/engine/scene/setGridType",2)):a==="grid"?(Oe.rpcCall("/engine/scene/setGridPattern",!0),Oe.rpcCall("/engine/scene/setGridType",2)):Oe.rpcCall("/engine/scene/setGridType",1)}),Oe.subscribe("from/ui/canvas/scale",({scale:a})=>{Oe.rpcCall("/engine/camera/scale",[ji,a/10])}),await xh(),await Oe.rpcCall("/engine/camera/set2DType",[ji,!0]),await Oe.rpcCall("/engine/camera/setAxisVisible",[ji,!1]),await Oe.rpcCall("/engine/scene/setBackgroundColor",["#000",1]),await Oe.rpcCall("/engine/scene/setCoordSys",!0),await Oe.rpcCall("/engine/scene/setGridType",2),await Oe.rpcCall("/engine/scene/setGridPattern",!1),await Oe.rpcCall("/engine/scene/setGridColor",["#fff",1]),await Oe.rpcCall("/engine/scene/setGridDelta",[5,5]),await Oe.rpcCall("/engine/scene/setPolarDelta",[45,393.7]),await Oe.rpcCall("/engine/scene/setOpenRuler",!0),await s();let n=await(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/materialSelected",""],Vs)).message;Oe.publish("modifyPhotoAttr",{key:"attr-board-material",value:n[0]?"substrate_fpc":Ie.material}),Oe.publish("modifyPhotoAttr",{key:"attr-board-color",value:Ie.solderMaskColor}),Oe.publish("modifyPhotoAttr",{key:"attr-pad-plating-color",value:Ie.sprayColor}),Oe.publish("modifyPhotoAttr",{key:"attr-background-color",value:Ie.bgColor}),Oe.publish("modifyPhotoAttr",{key:"attr-silk-technology",value:Ie.silkTechnology}),Oe.publish("adaptAll"),yh(),Oe.rpcService("toggleView(importChanges)",async()=>{let a=Object.values(Ys);await Oe.rpcCall("/pcb/3d/load/data",(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/source",{type:1,withModel:!1,withShell:!1,needPanelize:!0,outlineFixedWidth:!1}],Vs)).message),Oe.publish("3DViewLayerVisible",a),await Oe.rpcCall("/pcb/3d/load/blob",(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/blob",""],Vs)).message);let o=Object.assign({},Ie);Oe.publish("modifyPhotoAttr",{key:"attr-board-material",value:o.material}),Oe.publish("modifyPhotoAttr",{key:"attr-board-color",value:o.solderMaskColor}),Oe.publish("modifyPhotoAttr",{key:"attr-pad-plating-color",value:o.sprayColor}),Oe.publish("modifyPhotoAttr",{key:"attr-background-color",value:o.bgColor}),Oe.publish("modifyPhotoAttr",{key:"attr-silk-technology",value:o.silkTechnology}),Oe.publish("adaptAll"),yh()}),bh(t)});var MO=0;Oe.rpcService("/pcb/3d/load/data",async e=>{let t="3dStreamPreview",i="load3DSource-time";jf(i);let r="",s=NaN;typeof e=="object"?(r=e.source,s=e.renderTimeout_3d):r=e;let n=r.startsWith(t);MO=(MO+1)%Number.MAX_SAFE_INTEGER;let a=MO,o=await Ky();if(a!==MO){o(),bh(i);return}vh.debug3("%s,%s","/pcb/3d/load/data",r),$y=null,await xh(),isNaN(s)||await Oe.rpcCall("/engine/shell/setGnrResultTimeout",s),await Oe.rpcCall("/engine/setAbleRender",!1);let l=(await Oe.rpcCall("/engine/loadData",[r,!0,n,!0])).message;if(!l)return bh(i),o();Object.keys(Ci).forEach(h=>delete Ci[h]),Object.keys(Ys).forEach(h=>delete Ys[h]);for(let{id:h,name:c,type:d}of l){let f=Ci[d];if(f||(Ci[d]=f=[]),f.push(h),d.endsWith("PASTE_MASK"))await Oe.rpcCall("/engine/layer/setVisible",[h,!1]);else if(!d.endsWith("SPRAY")){let u={id:h,isVisible:!0,title:c};Ys[u.id]=u}}return Ys[52]={id:52,isVisible:!0,title:"3D Model"},Ci.COMPONENT_MODEL=[52],Ys[54]={id:54,isVisible:!0,title:"Top Layer"},Ci["3D_SHELL_TOP"]=[54],Ys[55]={id:55,isVisible:!0,title:"Bottom Layer"},Ci["3D_SHELL_BOTTOM"]=[55],Ci.TOP_SILK&&(Ie.topSilkDefaultColor=(await Oe.rpcCall("/engine/layer/getDefaultColor",Ci.TOP_SILK[0])).message,Ie.topSilkBackgroundColor=(await Oe.rpcCall("/engine/layer/getBackgroundColor",Ci.TOP_SILK[0])).message,Ie.topSilkDefaultColor=BO(Ie.topSilkDefaultColor),Ie.topSilkBackgroundColor=BO(Ie.topSilkBackgroundColor)),Ci.BOT_SILK&&(Ie.botSilkDefaultColor=(await Oe.rpcCall("/engine/layer/getDefaultColor",Ci.BOT_SILK[0])).message,Ie.botSilkBackgroundColor=(await Oe.rpcCall("/engine/layer/getBackgroundColor",Ci.BOT_SILK[0])).message,Ie.botSilkDefaultColor=BO(Ie.botSilkDefaultColor),Ie.botSilkBackgroundColor=BO(Ie.botSilkBackgroundColor)),await Qy(),fs.layerConfigsCache=xl(Ie.thicknessArr),o(!0),r&&await Iu(),bh(i),!0});function BO(e){if(e)return e.toLocaleUpperCase()}Oe.rpcService("getPcb3DBoardColor",async()=>Ie.solderMaskColor);async function Qy(){let e=[],t=[],i={};for(let r of(await Oe.rpcCall("/engine/layer/getConfigs",null)).message)r.thickness&&(r.type==="SIGNAL"?e.push(r):r.type==="SUBSTRATE"?t.push(r):i[r.type]=r);Ie.thicknessArr.length=0;for(let r of["TOP_ASSEMBLY","TOP_PASTE_MASK","TOP_SILK","TOP_SOLDER_MASK","TOP"]){let s=i[r];s&&Ie.thicknessArr.push({layerName:s.name,layerType:s.type,thickness:s.thickness})}for(let r=0;r<Math.max(e.length,t.length);r++){let s=e[r],n=t[r];n&&Ie.thicknessArr.push({layerName:n.name,layerType:n.type,thickness:n.thickness}),s&&Ie.thicknessArr.push({layerName:s.name,layerType:s.type,thickness:s.thickness})}for(let r of["BOTTOM","BOT_SOLDER_MASK","BOT_SILK","BOT_PASTE_MASK","BOT_ASSEMBLY"]){let s=i[r];s&&Ie.thicknessArr.push({layerName:s.name,layerType:s.type,thickness:s.thickness})}for(let r of Ie.thicknessArr)r.thickness*=Jy}Oe.rpcService("/pcb/3d/load/blob",async e=>{let t="load3DBlob-time";jf(t),await Oe.rpcCall("/engine/layer/loadBlob",e),bh(t)});Oe.subscribe("/engine/shell/initSubstrateHeight",e=>{Ie.substrateHeight=e*Jy,Xf()});Oe.subscribe("3DViewLayerVisible",e=>{e.forEach(t=>{let i=Number(t.id);Ys[i]&&(Ys[i].isVisible=t.isVisible,Ci.COMPONENT_MODEL[0]===i?Oe.rpcCall("/engine/model/setModelDisplay",t.isVisible):Ci["3D_SHELL_TOP"][0]===i?Oe.rpcCall("/engine/shell/setVisible",[!0,t.isVisible]):Ci["3D_SHELL_BOTTOM"][0]===i?Oe.rpcCall("/engine/shell/setVisible",[!1,t.isVisible]):Oe.rpcCall("/engine/layer/setVisible",[i,t.isVisible]))}),Xf()});function qs(e,t){e in Ci&&(Ci[e].forEach(i=>Oe.rpcCall("/engine/layer/setMaterial",[i,t])),e==="TOP_SOLDER_MASK"&&qs("TOP_SILK",t==="solder_mask_white"?"silk_black":"silk_white"),e==="BOT_SOLDER_MASK"&&qs("BOT_SILK",t==="solder_mask_white"?"silk_black":"silk_white"))}function JA(e,t){var i;(i=Ci[e])==null||i.forEach(r=>Oe.rpcCall("/engine/layer/setMaterial",[r,t]))}function ZA(e,t){if(isNaN(t))return;let i=t*UO;return Oe.rpcCall("/engine/layer/setThickness",[e,i])}function Xf(){Mi.publish("render3DViewLayerPanel",{layerList:Object.values(Ys)},Ri()),Mi.publish("render3DViewAttributePanel",Ie,Ri())}Oe.subscribe("toggle3DView",async e=>{await xh();let{cmd:t,isSilkPreview:i}=e;if(t in VA)await Oe.rpcCall("/engine/camera/set3DType",[ji,!0]),await Oe.rpcCall("/engine/camera/rotateTo",[].concat([ji],VA[t])),await Oe.rpcCall("/engine/camera/adapt",ji),await Oe.rpcCall("/engine/setAbleRender",!0);else if(t.startsWith("explode"))Oe.rpcCall("/engine/shell/explode",parseFloat(t.split(" ")[1]));else switch(t){case"refresh":let s=i?[ji,0,-90,0]:[ji,0,-45,0];await Oe.rpcCall("/engine/camera/set3DType",[ji,!1]),await Oe.rpcCall("/engine/camera/rotateTo",s),await Oe.rpcCall("/engine/camera/adapt",ji),await Oe.rpcCall("/engine/setAbleRender",!0);break;case"adaptAll":await Oe.rpcCall("/engine/camera/adapt",ji),await Oe.rpcCall("/engine/setAbleRender",!0);break;case"normal":Ie.mode="normal",await r(),await Oe.rpcCall("/engine/shell/setShowMode",[!0,!0]),Mi.publish("UIswitch3dView","normal",Ri());break;case"outline":{Ie.mode="outline",await r(),await Oe.rpcCall("/engine/shell/setShowMode",[!1,!0]),Mi.publish("UIswitch3dView","outline",Ri());break}case"gerber":Ie.mode="gerber",await Oe.rpcCall("/engine/pcb/setMode",0),await Oe.rpcCall("/engine/model/setRenderMode",0);let n=Ci.TOP_SILK,a=Ci.BOT_SILK;n&&(await Oe.rpcCall("/engine/layer/setColorful",[n[0],!1]),await Oe.rpcCall("/engine/layer/setRenderTexture",[n[0],!1])),a&&(await Oe.rpcCall("/engine/layer/setColorful",[a[0],!1]),await Oe.rpcCall("/engine/layer/setRenderTexture",[a[0],!1])),Mi.publish("UIswitch3dView","gerber",Ri());break;default:vh.error3("%s,%s","unsupported command",t)}async function r(){if(await Oe.rpcCall("/engine/pcb/setMode",1),await Oe.rpcCall("/engine/model/setRenderMode",0),Ie.silkTechnology==="colorfulSilk"){let s=Ci.TOP_SILK,n=Ci.BOT_SILK;s&&(await Oe.rpcCall("/engine/layer/setColorful",[s[0],!0]),await Oe.rpcCall("/engine/layer/setRenderTexture",[s[0],!0])),n&&(await Oe.rpcCall("/engine/layer/setColorful",[n[0],!0]),await Oe.rpcCall("/engine/layer/setRenderTexture",[n[0],!0]))}}});Oe.subscribe("getPcbCurrentDefaultThickness",e=>Ie.pcbDefaultThicknessArr=e);async function bJ(){let e,t,i;Ie.pcbDefaultThicknessArr[0]&&(t=Ie.pcbDefaultThicknessArr[0][0]),i=Ie.pcbDefaultThicknessArr[1][0],Ie.isFpcStiffener[0]?(t==null?void 0:t.layerCount)==2&&(t!=null&&t.list)?e=t.list:e=LA:e=(i==null?void 0:i.list)||DA,console.log("-----defaultParams",e);for(let r of Ie.thicknessArr)for(let s of e)r.layerType==(s["Layer Type"]||s.Type)&&await ZA(s["Layer Id"],s.Thickness);Qy()}function Tu(e){Ie.silkTechnology=e;let t=e==="colorfulSilk",i=Ci.TOP_SILK,r=Ci.BOT_SILK;i&&(Oe.rpcCall("/engine/layer/setColorful",[i[0],t]),Oe.rpcCall("/engine/layer/setRenderTexture",[i[0],t])),r&&(Oe.rpcCall("/engine/layer/setColorful",[r[0],t]),Oe.rpcCall("/engine/layer/setRenderTexture",[r[0],t])),t?(qs("TOP_SOLDER_MASK","solder_mask_white"),qs("BOT_SOLDER_MASK","solder_mask_white")):(qs("TOP_SOLDER_MASK",`solder_mask_${Ie.solderMaskColor}`),qs("BOT_SOLDER_MASK",`solder_mask_${Ie.solderMaskColor}`))}function Su(e){let t=e!=="None",i=Ci.TOP_SPRAY,r=Ci.BOT_SPRAY;i&&t&&qs("TOP_SPRAY",e),r&&t&&qs("BOT_SPRAY",e),Ie.sprayColor=e}Oe.subscribe("3DViewModifyAttr",e=>{var t,i;switch(e.key){case"attr-board-material":{JA("SUBSTRATE",e.value),Ie.material=e.value;let r=Ie.isFpcStiffener[0]?"substrate_fpc":"m_FR4",s=e.value!="substrate_fpc"?"m_FR4":"substrate_fpc";if(r!==s)((t=Ie.isFpcStiffener[1])==null?void 0:t.length)==2&&bJ();else if(fs.layerConfigsCache){for(let n of fs.layerConfigsCache){let a=(i=Object.values(Ys).find(o=>o.title==n.layerName))==null?void 0:i.id;a&&ZA(a,n.thickness)}Qy()}if(Ie.material=="substrate_fpc"){["yellow","black"].includes(Ie.solderMaskColor)||Oe.publish("3DViewModifyAttr",{key:"attr-board-color",value:"yellow"}),fs.silkTechnologyCache=xl(Ie.silkTechnology),fs.sprayColor=xl(Ie.sprayColor),Ie.silkTechnology="standardSilk",Tu("standardSilk"),Su("gold");return}Ie.material!=="substrate_fpc"&&(fs.silkTechnologyCache&&fs.sprayColor&&(Ie.silkTechnology=fs.silkTechnologyCache,Ie.sprayColor=fs.sprayColor,Tu(Ie.silkTechnology),Su(Ie.sprayColor)),Oe.publish("3DViewModifyAttr",{key:"attr-board-color",value:"blue"}));break}case"attr-board-color":{qs("TOP_SOLDER_MASK",`solder_mask_${e.value}`),qs("BOT_SOLDER_MASK",`solder_mask_${e.value}`),Ie.solderMaskColor=e.value;break}case"attr-pad-plating-color":{Su(e.value);break}case"attr-background-color":{document.body.style.backgroundColor=e.value,Ie.bgColor=e.value;break}case"attr-layer-expose":{Oe.rpcCall("/engine/setLayerDistance",parseFloat(e.value)*UO),Ie.expose=parseFloat(e.value);break}case"attr-substrate-height":{Oe.rpcCall("/engine/shell/setSubstrateHeight",parseFloat(e.value)*UO),Ie.substrateHeight=parseFloat(e.value),Ri().location.search.search("entry=pcb3dview")!==-1&&Ie.pcbUuid&&Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"updateAllD3ShellOutlineSubstrateHeight",{substrateHeight:parseFloat(e.value)*dJ}],Vs);break}case"attr-silk-technology":{Ie.material!=="substrate_fpc"&&(fs.silkTechnologyCache=e.value),Tu(e.value);break}}yh()});Oe.rpcService("/pcb/3d/sync/3dview",async e=>{let t="Preview3DInit-time";jf(t),await xh(),[Ie.tabid,Ie.pcbUuid]=e;let i=e[2],r=e[3]=="silk-preview";Mi.publish("UIswitch3dView","normal",Ri()),Oe.subscribe("refresh3DViewPanel",Xf),Xf(),Ba.addEventListener("mousedown",s=>{s.button===0&&Oe.rpcCall("/engine/camera/set3DType",[ji,!1])}),!r&&Oe.rpcService("/pcb/3d/getDefaultPngSize",async()=>(await Oe.rpcCall("/engine/capture/getInfo",[ji,{fixedWidth:2160}])).message),!r&&Oe.rpcService("/pcb/3d/export/png",async s=>{let n=(await Oe.rpcCall("/engine/capture/png",[ji,{fixedWidth:s.width||2160,watermarkConfig:s.watermarkConfig}])).message;if(Hm){let o={data:{fileData:(await WA(n)).data,fileTitle:s.fileName,extension:"png"}};Mi.publish("exportFileClientWay",o,Ri())}else Ao.downloadFile(s.fileName,n)}),!r&&Oe.rpcService("/pcb/3d/exportViewBox/png",async s=>({data:(await Oe.rpcCall("/engine/capture/png",[ji,{fixedWidth:2160},void 0,void 0,!0])).message,width:2160,height:1080})),Ie.isFpcStiffener=r?[]:await(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/materialSelected",""],Vs)).message,Oe.publish("3DViewModifyAttr",{key:"attr-board-material",value:Ie.isFpcStiffener[0]?"substrate_fpc":Ie.material}),Oe.publish("3DViewModifyAttr",{key:"attr-board-color",value:Ie.solderMaskColor}),Oe.publish("3DViewModifyAttr",{key:"attr-pad-plating-color",value:Ie.sprayColor}),Oe.publish("3DViewModifyAttr",{key:"attr-background-color",value:Ie.bgColor}),Oe.publish("3DViewModifyAttr",{key:"attr-layer-expose",value:Ie.expose}),Oe.publish("3DViewModifyAttr",{key:"attr-silk-technology",value:Ie.silkTechnology}),Oe.publish("toggle3DView",{cmd:"refresh",isSilkPreview:r}),/\braytracer\b/.test(Vs.location.search)&&await Oe.rpcCall("/engine/initRayTracer"),!r&&Oe.rpcService("toggleView(importChanges)",async()=>{let s=Object.values(Ys),n=(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/source",{exportDetails:!0}],Vs)).message,a=(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/footprint/3d/modelInfo",void 0],Vs)).message;if(a)if(a.dataStr==="")cn={model:"",src:"",type:(cn==null?void 0:cn.type)||"",unit:(cn==null?void 0:cn.unit)||""};else{let h=JSON.parse(a.dataStr);cn={model:h.model,type:h.type,unit:h.unit,src:h.src||""}}let o=n.dataStr;delete n.dataStr,Mi.publish("/pcb/3d/changeInfo",[Ie.tabid,n],Vs),await Oe.rpcCall("/pcb/3d/load/data",o),Oe.publish("3DViewLayerVisible",s),await Oe.rpcCall("/pcb/3d/load/blob",(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/blob",""],Vs)).message);let l=Object.assign({},Ie);Oe.publish("3DViewModifyAttr",{key:"attr-board-material",value:l.material}),Oe.publish("3DViewModifyAttr",{key:"attr-board-color",value:l.solderMaskColor}),Oe.publish("3DViewModifyAttr",{key:"attr-pad-plating-color",value:l.sprayColor}),Oe.publish("3DViewModifyAttr",{key:"attr-background-color",value:l.bgColor}),Oe.publish("3DViewModifyAttr",{key:"attr-layer-expose",value:l.expose}),Oe.publish("3DViewModifyAttr",{key:"attr-silk-technology",value:l.silkTechnology}),Oe.publish("toggle3DView",{cmd:"refresh"})}),!r&&Oe.rpcService("/pcb/3d/model/export",async s=>(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/model/export",s],Vs)).message),bh(t)});Oe.subscribe("/engine/model/updateComponentInfo",e=>{Object.assign(tt,e);let t=[tt.dx,tt.dy,tt.dz,tt.rz,tt.rx,tt.ry,tt.x,tt.y,tt.z].join(",");Iu(!0),Mi.publish("/pcb/3d/model/updated",{transform:t,ox:tt.ox,oy:tt.oy,oz:tt.oz},Ri())});Oe.rpcService("/pcb/3d/load/model",async e=>{let{dataStr:t,path:i}=e;await xh(),vh.debug3("%s,%s","/pcb/3d/load/model",t);let r;try{r=JSON.parse(t)}catch(s){t&&vh.error1(s)}if(cn=r,Zy=i,r)await Iu();else{El=(El+1)%Number.MAX_SAFE_INTEGER;let s=El,n=await Ky();s===El&&await Oe.rpcCall("/engine/model/clear",""),n()}});Oe.rpcService("/pcb/3d/model/update",async e=>{if(await xh(),vh.debug3("%s,%s","/pcb/3d/model/update",e),e.startsWith("v2:")){await Iu(!1,e);let t=(await Oe.rpcCall("/engine/model/reverse3DModelTransformByV2","e1")).message;Object.assign(tt,t),Mi.publish("/ui/updateV2transfrom",tt,Vs);return}else{let t=e.split(",").map(i=>parseFloat(i));return Object.assign(tt,{dx:t[0],dy:t[1],dz:t[2],rz:t[3],rx:t[4],ry:t[5],x:t[6],y:t[7],z:t[8]}),await Iu()}});Oe.rpcService("/pcb/3d/model/closeEditMode",async()=>{cn=null,Zy=null,Object.assign(tt,{dx:0,dy:0,dz:0,rx:0,ry:0,rz:0,x:0,y:0,z:0,ox:0,oy:0,oz:0}),await Oe.rpcCall("/engine/model/setComponentInfo",null)});Oe.rpcService("/pcb/3d/model/autofit",async()=>{if(!$y)return;await xh();let e=(await Oe.rpcCall("/engine/layer/getBoardBBox","")).message,t,i=(await Oe.rpcCall("/engine/layer/getBBox",48)).message,r=(await Oe.rpcCall("/engine/layer/getBBox",50)).message,s=(await Oe.rpcCall("/engine/layer/getBBox",51)).message,n=1,a=new yi;if(i&&a.ext5(i.minX,i.maxX,i.minY,i.maxY),r&&a.ext5(r.minX,r.maxX,r.minY,r.maxY),s&&a.ext5(s.minX,s.maxX,s.minY,s.maxY),a.valid()){let o=a.build();t=new Oo(o.minX,o.minY,0,o.maxX,o.maxY,0)}else t=(await Oe.rpcCall("/engine/model/originBBox","e1")).message,n=.8;if(e&&t){let[o,l,h,c]=e,{minX:d,minY:f,maxX:u,maxY:p}=t,g=h-o,_=c-l,y=u-d,m=p-f,O=g/_,b=y/m;Math.abs(O-b)<Math.abs(O-1/b)?(tt.dx=g*n,tt.dy=_*n,tt.rz=0):(tt.dx=_*n,tt.dy=g*n,tt.rz=90),tt.x=(o+h)/2,tt.y=(l+c)/2,tt.dz=0,tt.z=0,tt.rx=0,tt.ry=0,await Iu()}});Pu&&Oe.rpcService("/pcb/3d/shell/export_inframe",async e=>(await Mi.rpcCall("/ui/forward/tabid",[Ie.pcbUuid,"/pcb/3d/shell/export_inframe",e],Vs)).message);Oe.rpcService("/pcb/3d/shell/refresh",async e=>{await Oe.rpcCall("/engine/shell/clear",""),await Oe.rpcCall("/engine/load/data",[e,!0])});Oe.rpcService("/pcb/3d/getShellInfo",async()=>{let{message:e}=await Oe.rpcCall("/engine/shell/getShellInfo");if(!e)throw new Error('"/engine/shell/getShellInfo" ---Missing response data');let{d3SlotNum:t=0,d3EntityNum:i=0,d3DcrewNum:r=0}=e;return{d3SlotNum:t,d3EntityNum:i,d3DcrewNum:r}});Oe.rpcService("/pcb/3d/model/refresh",async e=>{await Oe.rpcCall("/engine/model/clearExceptCache",""),await Oe.rpcCall("/engine/load/data",[e,!0])});Oe.rpcService("/pcb/3d/getAssemblyID",async e=>(await Oe.rpcCall("/engine/model/getPartIdList",[e])).message);Oe.rpcService("/pcb/3d/highLightAssembly",async e=>{await Oe.rpcCall("/engine/model/setPartSelect",e)});Oe.rpcService("/pcb/3d/shell/setShowMode",async e=>{Ie.mode==="normal"&&await Oe.rpcCall("/engine/shell/setShowMode",e)});aa("/pcb/3d/model/updateSystemConfig",async e=>{vh.debug3("%s,%s","3d....UpdateSystemConfig",e.commSystemSetting),Ie.isUsedJLCColorSilk===void 0&&(Ie.isUsedJLCColorSilk=e.commSystemSetting.PCB_FOOTPRINT.isUsedJLCColorSilk,Xf(),yh()),await Oe.rpcCall("/engine/control/setCtrlWheel",e.commSystemSetting.SYSTEM.canvasZoomType==="ctrlRoller"),await Oe.rpcCall("/engine/control/setMidMouseMove",e.commSystemSetting.SYSTEM.dragMiddleMouseButton),Ie.dragMiddleMouseButton=e.commSystemSetting.SYSTEM.dragMiddleMouseButton});Oe.subscribe("/engine/model/finishLoading",e=>{Mi.publish("/pcb/3d/model/finishLoading",[Ie.tabid,e],Vs)});Oe.rpcService("/pcb/format/toPcb",async e=>!e||!e.source?"":(await Oe.rpcCall("/engine/format/toPcb",[e.source,e.layers])).message);Oe.rpcService("/pcb/layer/clear",async e=>{if(!(!e||!e.layerId))return await Oe.rpcCall("/engine/layer/clear",e.layerId)});Oe.rpcService("/pcb/modifyRulerTheme",async e=>{if(!e)return;let{rulerBgColor:t,rulerStringColor:i}=e,r={rulerBgColor:rr.build(1,1,1).getData(),rulerStringColor:rr.build(0,0,0).getData(),rulerTextColor:rr.build(.4,.4,.4,.8).getData()},s={rulerBgColor:"/engine/scene/setRulerBackgroundColor",rulerStringColor:"/engine/scene/setRulerStringColor",rulerTextColor:"/engine/scene/setRulerTextColor"},n=async(a,o)=>{let l=s[a];try{await Oe.rpcCall(l,CA(o).getData())}catch(h){console.error(`Error setting ${a} color:`,h),await Oe.rpcCall(l,r[a])}};await n("rulerBgColor",t),await n("rulerStringColor",i),await n("rulerTextColor",i)});vh.info1("pcb 3d initialized");})();
/*! Bundled license information:

lc-editor-common/dist/index.js:
  (*! Bundled license information:
  
  lc-protocol/dist/index.js:
    (*! Bundled license information:
    
    crypto-js/ripemd160.js:
      (** @preserve
      	(c) 2012 by Cédric Mesnil. All rights reserved.
      
      	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
      
      	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
      	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
      
      	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      	*)
    
    crypto-js/mode-ctr-gladman.js:
      (** @preserve
       * Counter block mode compatible with  Dr Brian Gladman fileenc.c
       * derived from CryptoJS.mode.CTR
       * Jan Hruby jhruby.web@gmail.com
       *)
    *)
  *)

lc-protocol/dist/index.js:
  (*! Bundled license information:
  
  crypto-js/ripemd160.js:
    (** @preserve
    	(c) 2012 by Cédric Mesnil. All rights reserved.
    
    	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    
    	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
    	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    	*)
  
  crypto-js/mode-ctr-gladman.js:
    (** @preserve
     * Counter block mode compatible with  Dr Brian Gladman fileenc.c
     * derived from CryptoJS.mode.CTR
     * Jan Hruby jhruby.web@gmail.com
     *)
  *)

kitsune/dist/index.js:
  (*! Bundled license information:
  
  three/build/three.core.js:
  three/build/three.module.js:
    (**
     * @license
     * Copyright 2010-2024 Three.js Authors
     * SPDX-License-Identifier: MIT
     *)
  *)
*/
//# sourceMappingURL=https://modules.lceda.cn/pro-pcb/3.2.131.14eacd6b/js/pcb3d.js.map
