@threepipe/plugins-extra-importers 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dependencies.txt +1 -1
- package/dist/index.d.ts +72 -72
- package/dist/index.js +15163 -0
- package/dist/index.js.map +1 -0
- package/package.json +14 -4
- package/dist/index.mjs +0 -17
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* @threepipe/plugins-extra-importers v0.2.0
|
|
4
|
-
* Copyright 2022-2024 repalash <palash@shaders.app>
|
|
5
|
-
* Apache-2.0 License
|
|
6
|
-
* See ./dependencies.txt for any bundled third-party dependencies and licenses.
|
|
7
|
-
*/
|
|
8
|
-
import{Loader as e,LoaderUtils as t,FileLoader as n,Group as r,MeshPhongMaterial as o,DoubleSide as i,AdditiveBlending as a,BufferGeometry as s,Mesh as c,Float32BufferAttribute as l,Matrix4 as u,TextureLoader as d,Color as p,SRGBColorSpace as f,BufferAttribute as h,MeshStandardMaterial as m,RepeatWrapping as g,ClampToEdgeWrapping as y,MirroredRepeatWrapping as v,LinearFilter as E,LinearMipmapLinearFilter as T,NearestFilter as b,DataTextureLoader as A,Vector3 as x,Quaternion as N,MeshBasicMaterial as R,Scene as k,MathUtils as O,AnimationClip as I,VectorKeyframeTrack as _,QuaternionKeyframeTrack as w,MeshLambertMaterial as S,Vector2 as C,FrontSide as L,PerspectiveCamera as P,OrthographicCamera as M,AmbientLight as F,SpotLight as D,PointLight as U,DirectionalLight as V,Bone as B,LineBasicMaterial as j,SkinnedMesh as z,Line as G,LineSegments as W,Skeleton as H,NumberKeyframeTrack as Y,Int32BufferAttribute as K,PointsMaterial as q,Points as X,RawShaderMaterial as $,Object3D as Z,SphereGeometry as J,BackSide as Q,DataTexture as ee,BoxGeometry as te,ConeGeometry as ne,CylinderGeometry as re,ShapeUtils as oe,Ray as ie,ShaderMaterial as ae,UniformsUtils as se,UniformsLib as ce,BaseImporterPlugin as le,Importer as ue,SkeletonHelper as de,PhysicalMaterial as pe}from"threepipe";class fe extends e{constructor(e){super(e),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(e,r,o,i){const a=this,s=""===this.path?t.extractUrlBase(e):this.path,c=new n(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,(function(t){try{r(a.parse(t,s))}catch(t){i?i(t):console.error(t),a.manager.itemError(e)}}),o,i)}parse(e,t){this.group=new r,this.materials=[],this.meshes=[],this.readFile(e,t);for(let e=0;e<this.meshes.length;e++)this.group.add(this.meshes[e]);return this.group}readFile(e,t){const n=new DataView(e),r=new he(n,0,this.debugMessage);if(r.id===ge||r.id===ye||r.id===me){let e=r.readChunk();for(;e;){if(e.id===ve){const t=e.readDWord();this.debugMessage("3DS file version: "+t)}else e.id===Re?this.readMeshData(e,t):this.debugMessage("Unknown main chunk: "+e.hexId);e=r.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(e,t){let n=e.readChunk();for(;n;){if(n.id===ke){const e=+n.readDWord();this.debugMessage("Mesh Version: "+e)}else if(n.id===Oe){const e=n.readFloat();this.debugMessage("Master scale: "+e),this.group.scale.set(e,e,e)}else n.id===qe?(this.debugMessage("Named Object"),this.readNamedObject(n)):n.id===Ie?(this.debugMessage("Material"),this.readMaterialEntry(n,t)):this.debugMessage("Unknown MDATA chunk: "+n.hexId);n=e.readChunk()}}readNamedObject(e){const t=e.readString();let n=e.readChunk();for(;n;){if(n.id===Xe){const e=this.readMesh(n);e.name=t,this.meshes.push(e)}else this.debugMessage("Unknown named object chunk: "+n.hexId);n=e.readChunk()}}readMaterialEntry(e,t){let n=e.readChunk();const r=new o;for(;n;){if(n.id===_e)r.name=n.readString(),this.debugMessage(" Name: "+r.name);else if(n.id===De)this.debugMessage(" Wireframe"),r.wireframe=!0;else if(n.id===Ue){const e=n.readByte();r.wireframeLinewidth=e,this.debugMessage(" Wireframe Thickness: "+e)}else if(n.id===Me)r.side=i,this.debugMessage(" DoubleSided");else if(n.id===Fe)this.debugMessage(" Additive Blending"),r.blending=a;else if(n.id===Se)this.debugMessage(" Diffuse Color"),r.color=this.readColor(n);else if(n.id===Ce)this.debugMessage(" Specular Color"),r.specular=this.readColor(n);else if(n.id===we)this.debugMessage(" Ambient color"),r.color=this.readColor(n);else if(n.id===Le){const e=this.readPercentage(n);r.shininess=100*e,this.debugMessage(" Shininess : "+e)}else if(n.id===Pe){const e=this.readPercentage(n);r.opacity=1-e,this.debugMessage(" Transparency : "+e),r.transparent=r.opacity<1}else n.id===Ve?(this.debugMessage(" ColorMap"),r.map=this.readMap(n,t)):n.id===je?(this.debugMessage(" BumpMap"),r.bumpMap=this.readMap(n,t)):n.id===Be?(this.debugMessage(" OpacityMap"),r.alphaMap=this.readMap(n,t)):n.id===ze?(this.debugMessage(" SpecularMap"),r.specularMap=this.readMap(n,t)):this.debugMessage(" Unknown material chunk: "+n.hexId);n=e.readChunk()}this.materials[r.name]=r}readMesh(e){let t=e.readChunk();const n=new s,r=new o,i=new c(n,r);for(i.name="mesh";t;){if(t.id===$e){const e=t.readWord();this.debugMessage(" Vertex: "+e);const r=[];for(let n=0;n<e;n++)r.push(t.readFloat()),r.push(t.readFloat()),r.push(t.readFloat());n.setAttribute("position",new l(r,3))}else if(t.id===Ze)this.readFaceArray(t,i);else if(t.id===Qe){const e=t.readWord();this.debugMessage(" UV: "+e);const r=[];for(let n=0;n<e;n++)r.push(t.readFloat()),r.push(t.readFloat());n.setAttribute("uv",new l(r,2))}else if(t.id===et){this.debugMessage(" Tranformation Matrix (TODO)");const e=[];for(let n=0;n<12;n++)e[n]=t.readFloat();const r=new u;r.elements[0]=e[0],r.elements[1]=e[6],r.elements[2]=e[3],r.elements[3]=e[9],r.elements[4]=e[2],r.elements[5]=e[8],r.elements[6]=e[5],r.elements[7]=e[11],r.elements[8]=e[1],r.elements[9]=e[7],r.elements[10]=e[4],r.elements[11]=e[10],r.elements[12]=0,r.elements[13]=0,r.elements[14]=0,r.elements[15]=1,r.transpose();const o=new u;o.copy(r).invert(),n.applyMatrix4(o),r.decompose(i.position,i.quaternion,i.scale)}else this.debugMessage(" Unknown mesh chunk: "+t.hexId);t=e.readChunk()}return n.computeVertexNormals(),i}readFaceArray(e,t){const n=e.readWord();this.debugMessage(" Faces: "+n);const r=[];for(let t=0;t<n;++t)r.push(e.readWord(),e.readWord(),e.readWord()),e.readWord();t.geometry.setIndex(r);let o=0,i=0;for(;!e.endOfChunk;){const n=e.readChunk();if(n.id===Je){this.debugMessage(" Material Group");const e=this.readMaterialGroup(n),r=3*e.index.length;t.geometry.addGroup(i,r,o),i+=r,o++;const a=this.materials[e.name];!1===Array.isArray(t.material)&&(t.material=[]),void 0!==a&&t.material.push(a)}else this.debugMessage(" Unknown face array chunk: "+n.hexId)}1===t.material.length&&(t.material=t.material[0])}readMap(e,t){let n=e.readChunk(),r={};const o=new d(this.manager);for(o.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);n;){if(n.id===Ge){const e=n.readString();r=o.load(e),this.debugMessage(" File: "+t+e)}else n.id===Ye?(r.offset.x=n.readFloat(),this.debugMessage(" OffsetX: "+r.offset.x)):n.id===Ke?(r.offset.y=n.readFloat(),this.debugMessage(" OffsetY: "+r.offset.y)):n.id===We?(r.repeat.x=n.readFloat(),this.debugMessage(" RepeatX: "+r.repeat.x)):n.id===He?(r.repeat.y=n.readFloat(),this.debugMessage(" RepeatY: "+r.repeat.y)):this.debugMessage(" Unknown map chunk: "+n.hexId);n=e.readChunk()}return r}readMaterialGroup(e){const t=e.readString(),n=e.readWord();this.debugMessage(" Name: "+t),this.debugMessage(" Faces: "+n);const r=[];for(let t=0;t<n;++t)r.push(e.readWord());return{name:t,index:r}}readColor(e){const t=e.readChunk(),n=new p;if(t.id===Te||t.id===be){const e=t.readByte(),r=t.readByte(),o=t.readByte();n.setRGB(e/255,r/255,o/255),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else if(t.id===Ee||t.id===Ae){const e=t.readFloat(),r=t.readFloat(),o=t.readFloat();n.setRGB(e,r,o),this.debugMessage(" Color: "+n.r+", "+n.g+", "+n.b)}else this.debugMessage(" Unknown color chunk: "+t.hexId);return n}readPercentage(e){const t=e.readChunk();switch(t.id){case xe:return t.readShort()/100;case Ne:return t.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+t.hexId),0}}debugMessage(e){this.debug&&console.log(e)}}class he{constructor(e,t,n){this.data=e,this.offset=t,this.position=t,this.debugMessage=n,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>e.byteLength&&this.debugMessage("Bad chunk size for chunk at "+t)}readChunk(){if(this.endOfChunk)return null;try{const e=new he(this.data,this.position,this.debugMessage);return this.position+=e.size,e}catch(e){return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const e=this.data.getUint8(this.position,!0);return this.position+=1,e}readFloat(){try{const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}catch(e){return this.debugMessage(e+" "+this.position+" "+this.data.byteLength),0}}readInt(){const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readShort(){const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readDWord(){const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readWord(){const e=this.data.getUint16(this.position,!0);return this.position+=2,e}readString(){let e="",t=this.readByte();for(;t;)e+=String.fromCharCode(t),t=this.readByte();return e}}const me=19789,ge=15786,ye=49725,ve=2,Ee=16,Te=17,be=18,Ae=19,xe=48,Ne=49,Re=15677,ke=15678,Oe=256,Ie=45055,_e=40960,we=40976,Se=40992,Ce=41008,Le=41024,Pe=41040,Me=41089,Fe=41091,De=41093,Ue=41095,Ve=41472,Be=41488,je=41520,ze=41476,Ge=41728,We=41812,He=41814,Ye=41816,Ke=41818,qe=16384,Xe=16640,$e=16656,Ze=16672,Je=16688,Qe=16704,et=16736;
|
|
9
|
-
/*!
|
|
10
|
-
fflate - fast JavaScript compression/decompression
|
|
11
|
-
<https://101arrowz.github.io/fflate>
|
|
12
|
-
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
13
|
-
version 0.6.9
|
|
14
|
-
*/
|
|
15
|
-
var tt=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(tt(""))}catch(e){tt=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var nt=Uint8Array,rt=Uint16Array,ot=Uint32Array,it=new nt([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]),at=new nt([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]),st=new nt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ct=function(e,t){for(var n=new rt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new ot(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},lt=ct(it,2),ut=lt[0],dt=lt[1];ut[28]=258,dt[258]=28;for(var pt=ct(at,0)[0],ft=new rt(32768),ht=0;ht<32768;++ht){var mt=(43690&ht)>>>1|(21845&ht)<<1;mt=(61680&(mt=(52428&mt)>>>2|(13107&mt)<<2))>>>4|(3855&mt)<<4,ft[ht]=((65280&mt)>>>8|(255&mt)<<8)>>>1}var gt=function(e,t,n){for(var r=e.length,o=0,i=new rt(t);o<r;++o)++i[e[o]-1];var a,s=new rt(t);for(o=0;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;if(n){a=new rt(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=s[e[o]-1]++<<u,p=d|(1<<u)-1;d<=p;++d)a[ft[d]>>>c]=l}else for(a=new rt(r),o=0;o<r;++o)e[o]&&(a[o]=ft[s[e[o]-1]++]>>>15-e[o]);return a},yt=new nt(288);for(ht=0;ht<144;++ht)yt[ht]=8;for(ht=144;ht<256;++ht)yt[ht]=9;for(ht=256;ht<280;++ht)yt[ht]=7;for(ht=280;ht<288;++ht)yt[ht]=8;var vt=new nt(32);for(ht=0;ht<32;++ht)vt[ht]=5;var Et=gt(yt,9,1),Tt=gt(vt,5,1),bt=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},At=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},xt=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Nt=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof rt?rt:e instanceof ot?ot:nt)(n-t);return r.set(e.subarray(t,n)),r},Rt=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new nt(0);var o=!t||n,i=!n||n.i;n||(n={}),t||(t=new nt(3*r));var a,s=function(e){var n=t.length;if(e>n){var r=new nt(Math.max(2*n,e));r.set(t),t=r}},c=n.f||0,l=n.p||0,u=n.b||0,d=n.l,p=n.d,f=n.m,h=n.n,m=8*r;do{if(!d){n.f=c=At(e,l,1);var g=At(e,l+1,3);if(l+=3,!g){var y=e[(I=((a=l)/8|0)+(7&a&&1)+4)-4]|e[I-3]<<8,v=I+y;if(v>r){if(i)throw"unexpected EOF";break}o&&s(u+y),t.set(e.subarray(I,v),u),n.b=u+=y,n.p=l=8*v;continue}if(1==g)d=Et,p=Tt,f=9,h=5;else{if(2!=g)throw"invalid block type";var E=At(e,l,31)+257,T=At(e,l+10,15)+4,b=E+At(e,l+5,31)+1;l+=14;for(var A=new nt(b),x=new nt(19),N=0;N<T;++N)x[st[N]]=At(e,l+3*N,7);l+=3*T;var R=bt(x),k=(1<<R)-1,O=gt(x,R,1);for(N=0;N<b;){var I,_=O[At(e,l,k)];if(l+=15&_,(I=_>>>4)<16)A[N++]=I;else{var w=0,S=0;for(16==I?(S=3+At(e,l,3),l+=2,w=A[N-1]):17==I?(S=3+At(e,l,7),l+=3):18==I&&(S=11+At(e,l,127),l+=7);S--;)A[N++]=w}}var C=A.subarray(0,E),L=A.subarray(E);f=bt(C),h=bt(L),d=gt(C,f,1),p=gt(L,h,1)}if(l>m){if(i)throw"unexpected EOF";break}}o&&s(u+131072);for(var P=(1<<f)-1,M=(1<<h)-1,F=l;;F=l){var D=(w=d[xt(e,l)&P])>>>4;if((l+=15&w)>m){if(i)throw"unexpected EOF";break}if(!w)throw"invalid length/literal";if(D<256)t[u++]=D;else{if(256==D){F=l,d=null;break}var U=D-254;if(D>264){var V=it[N=D-257];U=At(e,l,(1<<V)-1)+ut[N],l+=V}var B=p[xt(e,l)&M],j=B>>>4;if(!B)throw"invalid distance";l+=15&B;L=pt[j];if(j>3){V=at[j];L+=xt(e,l)&(1<<V)-1,l+=V}if(l>m){if(i)throw"unexpected EOF";break}o&&s(u+131072);for(var z=u+U;u<z;u+=4)t[u]=t[u-L],t[u+1]=t[u+1-L],t[u+2]=t[u+2-L],t[u+3]=t[u+3-L];u=z}}n.l=d,n.p=F,n.b=u,d&&(c=1,n.m=f,n.d=p,n.n=h)}while(!c);return u==t.length?t:Nt(t,0,u)},kt=new nt(0),Ot=function(e,t){return e[t]|e[t+1]<<8},It=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},_t=function(e,t){return It(e,t)+4294967296*It(e,t+4)};function wt(e,t){return Rt(e,t)}function St(e,t){return Rt((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var Ct="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ct.decode(kt,{stream:!0}),1}catch(e){}function Lt(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(Ct)return Ct.decode(e);var o=function(e){for(var t="",n=0;;){var r=e[n++],o=(r>127)+(r>223)+(r>239);if(n+o>e.length)return[t,Nt(e,n-1)];o?3==o?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&o?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}}(e),i=o[0];if(o[1].length)throw"invalid utf-8 data";return i}var Pt=function(e,t){return t+30+Ot(e,t+26)+Ot(e,t+28)},Mt=function(e,t,n){var r=Ot(e,t+28),o=Lt(e.subarray(t+46,t+46+r),!(2048&Ot(e,t+8))),i=t+46+r,a=It(e,t+20),s=n&&4294967295==a?Ft(e,i):[a,It(e,t+24),It(e,t+42)],c=s[0],l=s[1],u=s[2];return[Ot(e,t+10),c,l,o,i+Ot(e,t+30)+Ot(e,t+32),u]},Ft=function(e,t){for(;1!=Ot(e,t);t+=4+Ot(e,t+2));return[_t(e,t+12),_t(e,t+4),_t(e,t+20)]};function Dt(e){for(var t={},n=e.length-22;101010256!=It(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=Ot(e,n+8);if(!r)return{};var o=It(e,n+16),i=4294967295==o;if(i){if(n=It(e,n-12),101075792!=It(e,n))throw"invalid zip file";r=It(e,n+32),o=It(e,n+48)}for(var a=0;a<r;++a){var s=Mt(e,o,i),c=s[0],l=s[1],u=s[2],d=s[3],p=s[4],f=s[5],h=Pt(e,f);if(o=p,c){if(8!=c)throw"unknown compression type "+c;t[d]=wt(e.subarray(h,h+l),new nt(u))}else t[d]=Nt(e,h,h+l)}return t}const Ut=f;class Vt extends e{constructor(e){super(e),this.availableExtensions=[]}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const t=this,n=new d(this.manager);function i(e){const t=[],n=(new DOMParser).parseFromString(e,"application/xml").querySelectorAll("Relationship");for(let e=0;e<n.length;e++){const r=n[e],o={target:r.getAttribute("Target"),id:r.getAttribute("Id"),type:r.getAttribute("Type")};t.push(o)}return t}function a(e){const t={id:e.getAttribute("id"),basematerials:[]},n=e.querySelectorAll("base");for(let e=0;e<n.length;e++){const r=N(n[e]);r.index=e,t.basematerials.push(r)}return t}function f(e){const t={id:e.getAttribute("id"),texid:e.getAttribute("texid"),displaypropertiesid:e.getAttribute("displaypropertiesid")},n=e.querySelectorAll("tex2coord"),r=[];for(let e=0;e<n.length;e++){const t=n[e],o=t.getAttribute("u"),i=t.getAttribute("v");r.push(parseFloat(o),parseFloat(i))}return t.uvs=new Float32Array(r),t}function A(e){const t={id:e.getAttribute("id"),displaypropertiesid:e.getAttribute("displaypropertiesid")},n=e.querySelectorAll("color"),r=[],o=new p;for(let e=0;e<n.length;e++){const t=n[e].getAttribute("color");o.setStyle(t.substring(0,7),Ut),r.push(o.r,o.g,o.b)}return t.colors=new Float32Array(r),t}function x(e){const t={id:e.getAttribute("id")},n=e.querySelectorAll("pbmetallic"),r=[];for(let e=0;e<n.length;e++){const t=n[e];r.push({name:t.getAttribute("name"),metallicness:parseFloat(t.getAttribute("metallicness")),roughness:parseFloat(t.getAttribute("roughness"))})}return t.data=r,t}function N(e){const t={};return t.name=e.getAttribute("name"),t.displaycolor=e.getAttribute("displaycolor"),t.displaypropertiesid=e.getAttribute("displaypropertiesid"),t}function R(e){const t={};t.objectId=e.getAttribute("objectid");const n=e.getAttribute("transform");return n&&(t.transform=k(n)),t}function k(e){const t=[];e.split(" ").forEach((function(e){t.push(parseFloat(e))}));const n=new u;return n.set(t[0],t[3],t[6],t[9],t[1],t[4],t[7],t[10],t[2],t[5],t[8],t[11],0,0,0,1),n}function O(e){const t={type:e.getAttribute("type")},n=e.getAttribute("id");n&&(t.id=n);const r=e.getAttribute("pid");r&&(t.pid=r);const o=e.getAttribute("pindex");o&&(t.pindex=o);const i=e.getAttribute("thumbnail");i&&(t.thumbnail=i);const a=e.getAttribute("partnumber");a&&(t.partnumber=a);const s=e.getAttribute("name");s&&(t.name=s);const c=e.querySelector("mesh");c&&(t.mesh=function(e){const t={},n=[],r=e.querySelectorAll("vertices vertex");for(let e=0;e<r.length;e++){const t=r[e],o=t.getAttribute("x"),i=t.getAttribute("y"),a=t.getAttribute("z");n.push(parseFloat(o),parseFloat(i),parseFloat(a))}t.vertices=new Float32Array(n);const o=[],i=[],a=e.querySelectorAll("triangles triangle");for(let e=0;e<a.length;e++){const t=a[e],n=t.getAttribute("v1"),r=t.getAttribute("v2"),s=t.getAttribute("v3"),c=t.getAttribute("p1"),l=t.getAttribute("p2"),u=t.getAttribute("p3"),d=t.getAttribute("pid"),p={};p.v1=parseInt(n,10),p.v2=parseInt(r,10),p.v3=parseInt(s,10),i.push(p.v1,p.v2,p.v3),c&&(p.p1=parseInt(c,10)),l&&(p.p2=parseInt(l,10)),u&&(p.p3=parseInt(u,10)),d&&(p.pid=d),0<Object.keys(p).length&&o.push(p)}return t.triangleProperties=o,t.triangles=new Uint32Array(i),t}(c));const l=e.querySelector("components");return l&&(t.components=function(e){const t=[],n=e.querySelectorAll("component");for(let e=0;e<n.length;e++){const r=R(n[e]);t.push(r)}return t}(l)),t}function I(e){const t={unit:e.getAttribute("unit")||"millimeter"},n=e.querySelectorAll("metadata");n&&(t.metadata=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n],o=r.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(o)&&(t[o]=r.textContent)}return t}(n));const r=e.querySelector("resources");r&&(t.resources=function(e){const t={basematerials:{}},n=e.querySelectorAll("basematerials");for(let e=0;e<n.length;e++){const r=a(n[e]);t.basematerials[r.id]=r}t.texture2d={};const r=e.querySelectorAll("texture2d");for(let e=0;e<r.length;e++){const n={id:(o=r[e]).getAttribute("id"),path:o.getAttribute("path"),contenttype:o.getAttribute("contenttype"),tilestyleu:o.getAttribute("tilestyleu"),tilestylev:o.getAttribute("tilestylev"),filter:o.getAttribute("filter")};t.texture2d[n.id]=n}var o;t.colorgroup={};const i=e.querySelectorAll("colorgroup");for(let e=0;e<i.length;e++){const n=A(i[e]);t.colorgroup[n.id]=n}t.pbmetallicdisplayproperties={};const s=e.querySelectorAll("pbmetallicdisplayproperties");for(let e=0;e<s.length;e++){const n=x(s[e]);t.pbmetallicdisplayproperties[n.id]=n}t.texture2dgroup={};const c=e.querySelectorAll("texture2dgroup");for(let e=0;e<c.length;e++){const n=f(c[e]);t.texture2dgroup[n.id]=n}t.object={};const l=e.querySelectorAll("object");for(let e=0;e<l.length;e++){const n=O(l[e]);t.object[n.id]=n}return t}(r));const o=e.querySelector("build");return o&&(t.build=function(e){const t=[],n=e.querySelectorAll("item");for(let e=0;e<n.length;e++){const r=n[e],o={objectId:r.getAttribute("objectid")},i=r.getAttribute("transform");i&&(o.transform=k(i)),t.push(o)}return t}(o)),t}function _(e,t,r,o){const i=e.texid,a=r.resources.texture2d[i];if(a){const e=o[a.path],t=a.contenttype,r=new Blob([e],{type:t}),i=URL.createObjectURL(r),s=n.load(i,(function(){URL.revokeObjectURL(i)}));switch(s.colorSpace=Ut,a.tilestyleu){case"wrap":default:s.wrapS=g;break;case"mirror":s.wrapS=v;break;case"none":case"clamp":s.wrapS=y}switch(a.tilestylev){case"wrap":default:s.wrapT=g;break;case"mirror":s.wrapT=v;break;case"none":case"clamp":s.wrapT=y}switch(a.filter){case"auto":default:s.magFilter=E,s.minFilter=T;break;case"linear":s.magFilter=E,s.minFilter=E;break;case"nearest":s.magFilter=b,s.minFilter=b}return s}return null}function w(e,t,n,r,o,i,a){const u=a.pindex,d={};for(let e=0,n=t.length;e<n;e++){const n=t[e],r=void 0!==n.p1?n.p1:u;void 0===d[r]&&(d[r]=[]),d[r].push(n)}const p=Object.keys(d),f=[];for(let t=0,u=p.length;t<u;t++){const u=p[t],h=d[u],m=F(e.basematerials[u],r,o,i,a,D),g=new s,y=[],v=n.vertices;for(let e=0,t=h.length;e<t;e++){const t=h[e];y.push(v[3*t.v1+0]),y.push(v[3*t.v1+1]),y.push(v[3*t.v1+2]),y.push(v[3*t.v2+0]),y.push(v[3*t.v2+1]),y.push(v[3*t.v2+2]),y.push(v[3*t.v3+0]),y.push(v[3*t.v3+1]),y.push(v[3*t.v3+2])}g.setAttribute("position",new l(y,3));const E=new c(g,m);f.push(E)}return f}function S(e,t,n,r,i,a,u){const d=new s,p=[],f=[],h=n.vertices,m=e.uvs;for(let e=0,n=t.length;e<n;e++){const n=t[e];p.push(h[3*n.v1+0]),p.push(h[3*n.v1+1]),p.push(h[3*n.v1+2]),p.push(h[3*n.v2+0]),p.push(h[3*n.v2+1]),p.push(h[3*n.v2+2]),p.push(h[3*n.v3+0]),p.push(h[3*n.v3+1]),p.push(h[3*n.v3+2]),f.push(m[2*n.p1+0]),f.push(m[2*n.p1+1]),f.push(m[2*n.p2+0]),f.push(m[2*n.p2+1]),f.push(m[2*n.p3+0]),f.push(m[2*n.p3+1])}d.setAttribute("position",new l(p,3)),d.setAttribute("uv",new l(f,2));const g=F(e,r,i,a,u,_),y=new o({map:g,flatShading:!0});return new c(d,y)}function C(e,t,n,r){const i=new s,a=[],u=[],d=n.vertices,p=e.colors;for(let e=0,n=t.length;e<n;e++){const n=t[e],o=n.v1,i=n.v2,s=n.v3;a.push(d[3*o+0]),a.push(d[3*o+1]),a.push(d[3*o+2]),a.push(d[3*i+0]),a.push(d[3*i+1]),a.push(d[3*i+2]),a.push(d[3*s+0]),a.push(d[3*s+1]),a.push(d[3*s+2]);const c=void 0!==n.p1?n.p1:r.pindex,l=void 0!==n.p2?n.p2:c,f=void 0!==n.p3?n.p3:c;u.push(p[3*c+0]),u.push(p[3*c+1]),u.push(p[3*c+2]),u.push(p[3*l+0]),u.push(p[3*l+1]),u.push(p[3*l+2]),u.push(p[3*f+0]),u.push(p[3*f+1]),u.push(p[3*f+2])}i.setAttribute("position",new l(a,3)),i.setAttribute("color",new l(u,3));const f=new o({vertexColors:!0,flatShading:!0});return new c(i,f)}function L(e){const t=new s;t.setIndex(new h(e.triangles,1)),t.setAttribute("position",new h(e.vertices,3));const n=new o({color:16777215,flatShading:!0});return new c(t,n)}function P(e,t){return void 0!==t.resources.texture2dgroup[e]?"texture":void 0!==t.resources.basematerials[e]?"material":void 0!==t.resources.colorgroup[e]?"vertexColors":"default"===e?"default":void 0}function M(e,t,n,o,i){const a=new r,s=function(e,t){const n={},r=e.triangleProperties,o=t.pid;for(let e=0,t=r.length;e<t;e++){const t=r[e];let i=void 0!==t.pid?t.pid:o;void 0===i&&(i="default"),void 0===n[i]&&(n[i]=[]),n[i].push(t)}return n}(e,i),c=function(e,t,n,r,o,i){const a=Object.keys(e),s=[];for(let c=0,l=a.length;c<l;c++){const l=a[c],u=e[l];switch(P(l,r)){case"material":const e=w(r.resources.basematerials[l],u,t,n,r,o,i);for(let t=0,n=e.length;t<n;t++)s.push(e[t]);break;case"texture":const a=r.resources.texture2dgroup[l];s.push(S(a,u,t,n,r,o,i));break;case"vertexColors":const c=r.resources.colorgroup[l];s.push(C(c,u,t,i));break;case"default":s.push(L(t));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(i.name)for(let e=0;e<s.length;e++)s[e].name=i.name;return s}(s,e,t,n,o,i);for(let e=0,t=c.length;e<t;e++)a.add(c[e]);return a}function F(e,t,n,r,o,i){return void 0!==e.build||(e.build=i(e,t,n,r,o)),e.build}function D(e,t,n){let r;const i=e.displaypropertiesid,a=n.resources.pbmetallicdisplayproperties;if(null!==i&&void 0!==a[i]){const t=a[i].data[e.index];r=new m({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new o({flatShading:!0});r.name=e.name;const s=e.displaycolor,c=s.substring(0,7);return r.color.setStyle(c,Ut),9===s.length&&(r.opacity=parseInt(s.charAt(7)+s.charAt(8),16)/255),r}function U(e,t,n,o){const i=new r;for(let r=0;r<e.length;r++){const a=e[r];let s=t[a.objectId];void 0===s&&(V(a.objectId,t,n,o),s=t[a.objectId]);const c=s.clone(),l=a.transform;l&&c.applyMatrix4(l),i.add(c)}return i}function V(e,n,r,o){const i=r.resources.object[e];if(i.mesh){const e=i.mesh;!function(e,n,r){if(!e)return;const o=[],i=Object.keys(e);for(let e=0;e<i.length;e++){const n=i[e];for(let e=0;e<t.availableExtensions.length;e++){const r=t.availableExtensions[e];r.ns===n&&o.push(r)}}for(let t=0;t<o.length;t++){const i=o[t];i.apply(r,e[i.ns],n)}}(r.extensions,e,r.xml),n[i.id]=F(e,n,r,o,i,M)}else{const e=i.components;n[i.id]=F(e,n,r,o,i,U)}i.name&&(n[i.id].name=i.name)}const B=function(e){let t,n,r=null,o=null;const a=[],s=[];let c;const l={},u={},d=new TextDecoder;try{r=Dt(new Uint8Array(e))}catch(e){if(e instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}for(o in r)o.match(/\_rels\/.rels$/)?t=o:o.match(/3D\/_rels\/.*\.model\.rels$/)?n=o:o.match(/^3D\/.*\.model$/)?a.push(o):o.match(/^3D\/Textures?\/.*/)&&s.push(o);const p=r[t],f=i(d.decode(p));if(n){const e=r[n];c=i(d.decode(e))}for(let e=0;e<a.length;e++){const t=a[e],n=r[t],o=d.decode(n),i=(new DOMParser).parseFromString(o,"application/xml");"model"!==i.documentElement.nodeName.toLowerCase()&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",t);const s=i.querySelector("model"),c={};for(let e=0;e<s.attributes.length;e++){const t=s.attributes[e];t.name.match(/^xmlns:(.+)$/)&&(c[t.value]=RegExp.$1)}const u=I(s);u.xml=s,0<Object.keys(c).length&&(u.extensions=c),l[t]=u}for(let e=0;e<s.length;e++){const t=s[e];u[t]=r[t].buffer}return{rels:f,modelRels:c,model:l,printTicket:{},texture:u}}(e),j=function(e){const t=e.model,n=e.modelRels,r={},o=Object.keys(t),i={};if(n)for(let t=0,r=n.length;t<r;t++){const r=n[t],o=r.target.substring(1);e.texture[o]&&(i[r.target]=e.texture[o])}for(let e=0;e<o.length;e++){const n=t[o[e]],a=Object.keys(n.resources.object);for(let e=0;e<a.length;e++){V(a[e],r,n,i)}}return r}(B);return function(e,t){const n=new r,o=function(e){for(let t=0;t<e.length;t++){const n=e[t];if("model"===n.target.split(".").pop().toLowerCase())return n}}(t.rels),i=t.model[o.target.substring(1)].build;for(let t=0;t<i.length;t++){const r=i[t],o=e[r.objectId].clone(),a=r.transform;a&&o.applyMatrix4(a),n.add(o)}return n}(j,B)}addExtension(e){this.availableExtensions.push(e)}}class Bt extends A{constructor(e){super(e)}parse(e){const t=0,n=1,r=2,o=3,i=9,a=10,s=11,c=48,l=4,u=0,d=1,p=2,f=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let h=0;const m=new Uint8Array(e),g={id_length:m[h++],colormap_type:m[h++],image_type:m[h++],colormap_index:m[h++]|m[h++]<<8,colormap_length:m[h++]|m[h++]<<8,colormap_size:m[h++],origin:[m[h++]|m[h++]<<8,m[h++]|m[h++]<<8],width:m[h++]|m[h++]<<8,height:m[h++]|m[h++]<<8,pixel_size:m[h++],flags:m[h++]};!function(e){switch(e.image_type){case n:case i:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case r:case o:case a:case s:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+h>e.length&&console.error("THREE.TGALoader: No data."),h+=g.id_length;let y=!1,v=!1,E=!1;switch(g.image_type){case i:y=!0,v=!0;break;case n:v=!0;break;case a:y=!0;break;case r:break;case s:y=!0,E=!0;break;case o:E=!0}const b=new Uint8Array(g.width*g.height*4),A=function(e,t,n,r,o){let i,a;const s=n.pixel_size>>3,c=n.width*n.height*s;if(t&&(a=o.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;i=new Uint8Array(c);let a=0;const l=new Uint8Array(s);for(;a<c;)if(e=o[r++],t=1+(127&e),128&e){for(n=0;n<s;++n)l[n]=o[r++];for(n=0;n<t;++n)i.set(l,a+n*s);a+=s*t}else{for(t*=s,n=0;n<t;++n)i[a+n]=o[r++];a+=t}}else i=o.subarray(r,r+=t?n.width*n.height:c);return{pixel_data:i,palettes:a}}(y,v,g,h,m);return function(e,t,n,r,o){let i,a,s,h,m,y;switch((g.flags&c)>>l){default:case p:i=0,s=1,m=t,a=0,h=1,y=n;break;case u:i=0,s=1,m=t,a=n-1,h=-1,y=-1;break;case f:i=t-1,s=-1,m=-1,a=0,h=1,y=n;break;case d:i=t-1,s=-1,m=-1,a=n-1,h=-1,y=-1}if(E)switch(g.pixel_size){case 8:!function(e,t,n,r,o,i,a,s){let c,l,u,d=0;const p=g.width;for(u=t;u!==r;u+=n)for(l=o;l!==a;l+=i,d++)c=s[d],e[4*(l+p*u)+0]=c,e[4*(l+p*u)+1]=c,e[4*(l+p*u)+2]=c,e[4*(l+p*u)+3]=255}(e,a,h,y,i,s,m,r);break;case 16:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=g.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=2)e[4*(c+d*l)+0]=s[u+0],e[4*(c+d*l)+1]=s[u+0],e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+3]=s[u+1]}(e,a,h,y,i,s,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,r,o,i,a,s,c){const l=c;let u,d,p,f=0;const h=g.width;for(p=t;p!==r;p+=n)for(d=o;d!==a;d+=i,f++)u=s[f],e[4*(d+h*p)+3]=255,e[4*(d+h*p)+2]=l[3*u+0],e[4*(d+h*p)+1]=l[3*u+1],e[4*(d+h*p)+0]=l[3*u+2]}(e,a,h,y,i,s,m,r,o);break;case 16:!function(e,t,n,r,o,i,a,s){let c,l,u,d=0;const p=g.width;for(u=t;u!==r;u+=n)for(l=o;l!==a;l+=i,d+=2)c=s[d+0]+(s[d+1]<<8),e[4*(l+p*u)+0]=(31744&c)>>7,e[4*(l+p*u)+1]=(992&c)>>2,e[4*(l+p*u)+2]=(31&c)<<3,e[4*(l+p*u)+3]=32768&c?0:255}(e,a,h,y,i,s,m,r);break;case 24:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=g.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=3)e[4*(c+d*l)+3]=255,e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+1]=s[u+1],e[4*(c+d*l)+0]=s[u+2]}(e,a,h,y,i,s,m,r);break;case 32:!function(e,t,n,r,o,i,a,s){let c,l,u=0;const d=g.width;for(l=t;l!==r;l+=n)for(c=o;c!==a;c+=i,u+=4)e[4*(c+d*l)+2]=s[u+0],e[4*(c+d*l)+1]=s[u+1],e[4*(c+d*l)+0]=s[u+2],e[4*(c+d*l)+3]=s[u+3]}(e,a,h,y,i,s,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(b,g.width,g.height,A.pixel_data,A.palettes),{data:b,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:T}}}class jt extends e{constructor(e){super(e)}load(e,r,o,i){const a=this,s=""===a.path?t.extractUrlBase(e):a.path,c=new n(a.manager);c.setPath(a.path),c.setRequestHeader(a.requestHeader),c.setWithCredentials(a.withCredentials),c.load(e,(function(t){try{r(a.parse(t,s))}catch(t){i?i(t):console.error(t),a.manager.itemError(e)}}),o,i)}parse(e,t){function n(e,t){const n=[],r=e.childNodes;for(let e=0,o=r.length;e<o;e++){const o=r[e];o.nodeName===t&&n.push(o)}return n}function a(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=t[e];return n}function h(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseFloat(t[e]);return n}function m(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseInt(t[e]);return n}function v(e){return e.substring(1)}function E(e){return 0===Object.keys(e).length}function T(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function b(e){return void 0!==e?e.textContent:"Y_UP"}function A(e,t,r,o){const i=n(e,t)[0];if(void 0!==i){const e=n(i,r);for(let t=0;t<e.length;t++)o(e[t])}}function Y(e,t){for(const n in e){e[n].build=t(e[n])}}function K(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function q(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=v(r.getAttribute("source")),n=r.getAttribute("semantic");t.inputs[n]=e}}return t}function X(e){const t={};let n=e.getAttribute("target").split("/");const r=n.shift();let o=n.shift();const i=-1!==o.indexOf("("),a=-1!==o.indexOf(".");if(a)n=o.split("."),o=n.shift(),t.member=n.shift();else if(i){const e=o.split("(");o=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=r,t.sid=o,t.arraySyntax=i,t.memberSyntax=a,t.sampler=v(e.getAttribute("source")),t}function $(e){const t=[],n=e.channels,r=e.samplers,o=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const i=n[e],a=r[i.sampler],s=a.inputs.INPUT,c=a.inputs.OUTPUT;ne(J(i,o[s],o[c]),t)}return t}function Z(e){return K(St.animations[e],$)}function J(e,t,n){const r=St.nodes[e.id],o=yt(r.id),i=r.transforms[e.sid],a=r.matrix.clone().transpose();let s,c,l,u,d,p;const f={};switch(i){case"matrix":for(l=0,u=t.array.length;l<u;l++)if(s=t.array[l],c=l*n.stride,void 0===f[s]&&(f[s]={}),!0===e.arraySyntax){const t=n.array[c],r=e.indices[0]+4*e.indices[1];f[s][r]=t}else for(d=0,p=n.stride;d<p;d++)f[s][d]=n.array[c+d];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',i)}const h=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(r);for(let e=0;e<16;e++)re(n,e,t.elements[e]);return n;function r(e,t){return e.time-t.time}}(f,a);return{name:o.uuid,keyframes:h}}const Q=new x,ee=new x,te=new N;function ne(e,t){const n=e.keyframes,r=e.name,o=[],i=[],a=[],s=[];for(let e=0,t=n.length;e<t;e++){const t=n[e],r=t.time,c=t.value;at.fromArray(c).transpose(),at.decompose(Q,te,ee),o.push(r),i.push(Q.x,Q.y,Q.z),a.push(te.x,te.y,te.z,te.w),s.push(ee.x,ee.y,ee.z)}return i.length>0&&t.push(new _(r+".position",o,i)),a.length>0&&t.push(new w(r+".quaternion",o,a)),s.length>0&&t.push(new _(r+".scale",o,s)),t}function re(e,t,n){let r,o,i,a=!0;for(o=0,i=e.length;o<i;o++)r=e[o],void 0===r.value[t]?r.value[t]=null:a=!1;if(!0===a)for(o=0,i=e.length;o<i;o++)r=e[o],r.value[t]=n;else!function(e,t){let n,r;for(let o=0,i=e.length;o<i;o++){const i=e[o];if(null===i.value[t]){if(n=oe(e,o,t),r=ie(e,o,t),null===n){i.value[t]=r.value[t];continue}if(null===r){i.value[t]=n.value[t];continue}ae(i,n,r,t)}}}(e,t)}function oe(e,t,n){for(;t>=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function ie(e,t,n){for(;t<e.length;){const r=e[t];if(null!==r.value[n])return r;t++}return null}function ae(e,t,n,r){n.time-t.time!=0?e.value[r]=(e.time-t.time)*(n.value[r]-t.value[r])/(n.time-t.time)+t.value[r]:e.value[r]=t.value[r]}function se(e){const t=[],n=e.name,r=e.end-e.start||-1,o=e.animations;for(let e=0,n=o.length;e<n;e++){const n=Z(o[e]);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return new I(n,r,t)}function ce(e){return K(St.clips[e],se)}function le(e){const t={sources:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=h(r.textContent);break;case"source":const e=r.getAttribute("id");t.sources[e]=Be(r);break;case"joints":t.joints=ue(r);break;case"vertex_weights":t.vertexWeights=de(r)}}return t}function ue(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=r.getAttribute("semantic"),n=v(r.getAttribute("source"));t.inputs[e]=n}}return t}function de(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=r.getAttribute("semantic"),n=v(r.getAttribute("source")),o=parseInt(r.getAttribute("offset"));t.inputs[e]={id:n,offset:o};break;case"vcount":t.vcount=m(r.textContent);break;case"v":t.v=m(r.textContent)}}return t}function pe(e){const t={id:e.id},n=St.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){const t=4,n={joints:[],indices:{array:[],stride:t},weights:{array:[],stride:t}},r=e.sources,o=e.vertexWeights,i=o.vcount,a=o.v,s=o.inputs.JOINT.offset,c=o.inputs.WEIGHT.offset,l=e.sources[e.joints.inputs.JOINT],d=e.sources[e.joints.inputs.INV_BIND_MATRIX],p=r[o.inputs.WEIGHT.id].array;let f,h,m,g=0;for(f=0,m=i.length;f<m;f++){const e=i[f],r=[];for(h=0;h<e;h++){const e=a[g+s],t=p[a[g+c]];r.push({index:e,weight:t}),g+=2}for(r.sort(y),h=0;h<t;h++){const e=r[h];void 0!==e?(n.indices.array.push(e.index),n.weights.array.push(e.weight)):(n.indices.array.push(0),n.weights.array.push(0))}}e.bindShapeMatrix?n.bindMatrix=(new u).fromArray(e.bindShapeMatrix).transpose():n.bindMatrix=(new u).identity();for(f=0,m=l.array.length;f<m;f++){const e=l.array[f],t=(new u).fromArray(d.array,f*d.stride).transpose();n.joints.push({name:e,boneInverse:t})}return n;function y(e,t){return t.weight-e.weight}}(e.skin),n.sources.skinIndices=t.skin.indices,n.sources.skinWeights=t.skin.weights),t}function fe(e){return void 0!==e.build?e.build:e.init_from}function he(e){const t=St.images[e];return void 0!==t?K(t,fe):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function me(e){const t={surfaces:{},samplers:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"newparam":ge(r,t);break;case"technique":t.technique=Ee(r);break;case"extra":t.extra=Re(r)}}return t}function ge(e,t){const n=e.getAttribute("sid");for(let r=0,o=e.childNodes.length;r<o;r++){const o=e.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[n]=ye(o);break;case"sampler2D":t.samplers[n]=ve(o)}}}function ye(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"init_from"===r.nodeName)t.init_from=r.textContent}return t}function ve(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"source"===r.nodeName)t.source=r.textContent}return t}function Ee(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=r.nodeName,t.parameters=Te(r);break;case"extra":t.extra=Re(r)}}return t}function Te(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[r.nodeName]=be(r);break;case"transparent":t[r.nodeName]={opaque:r.hasAttribute("opaque")?r.getAttribute("opaque"):"A_ONE",data:be(r)}}}return t}function be(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":t[r.nodeName]=h(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:Ae(r)}}}return t}function Ae(e){const t={technique:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"extra"===r.nodeName)xe(r,t)}return t}function xe(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)Ne(r,t)}}function Ne(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=0:t.technique[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=Oe(r)}}}function Re(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)t.technique=ke(r)}return t}function ke(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"double_sided":t[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=Oe(r)}}return t}function Oe(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"texture"===r.nodeName)t[r.nodeName]={id:r.getAttribute("texture"),texcoord:r.getAttribute("texcoord"),extra:Ae(r)}}return t}function Ie(e){return e}function _e(e){const t=(n=e.url,K(St.effects[n],Ie));var n;const r=t.profile.technique;let a;switch(r.type){case"phong":case"blinn":a=new o;break;case"lambert":a=new S;break;default:a=new R}function s(e,n=null){const r=t.profile.samplers[e.id];let o=null;if(void 0!==r){o=he(t.profile.surfaces[r.source].init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),o=he(e.id);if(null!==o){const t=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));n=n.toLowerCase(),t="tga"===n?kt:Rt;return t}(o);if(void 0!==t){const r=t.load(o),i=e.extra;if(void 0!==i&&void 0!==i.technique&&!1===E(i.technique)){const e=i.technique;r.wrapS=e.wrapU?g:y,r.wrapT=e.wrapV?g:y,r.offset.set(e.offsetU||0,e.offsetV||0),r.repeat.set(e.repeatU||1,e.repeatV||1)}else r.wrapS=g,r.wrapT=g;return null!==n&&(r.colorSpace=n),r}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",o),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}a.name=e.name||"";const c=r.parameters;for(const e in c){const t=c[e];switch(e){case"diffuse":t.color&&a.color.fromArray(t.color),t.texture&&(a.map=s(t.texture,f));break;case"specular":t.color&&a.specular&&a.specular.fromArray(t.color),t.texture&&(a.specularMap=s(t.texture));break;case"bump":t.texture&&(a.normalMap=s(t.texture));break;case"ambient":t.texture&&(a.lightMap=s(t.texture,f));break;case"shininess":t.float&&a.shininess&&(a.shininess=t.float);break;case"emission":t.color&&a.emissive&&a.emissive.fromArray(t.color),t.texture&&(a.emissiveMap=s(t.texture,f))}}a.color.convertSRGBToLinear(),a.specular&&a.specular.convertSRGBToLinear(),a.emissive&&a.emissive.convertSRGBToLinear();let l=c.transparent,u=c.transparency;if(void 0===u&&l&&(u={float:1}),void 0===l&&u&&(l={opaque:"A_ONE",data:{color:[1,1,1,1]}}),l&&u)if(l.data.texture)a.transparent=!0;else{const e=l.data.color;switch(l.opaque){case"A_ONE":a.opacity=e[3]*u.float;break;case"RGB_ZERO":a.opacity=1-e[0]*u.float;break;case"A_ZERO":a.opacity=1-e[3]*u.float;break;case"RGB_ONE":a.opacity=e[0]*u.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',l.opaque)}a.opacity<1&&(a.transparent=!0)}if(void 0!==r.extra&&void 0!==r.extra.technique){const e=r.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":a.side=1===n?i:L;break;case"bump":a.normalMap=s(n.texture),a.normalScale=new C(1,1)}}}return a}function we(e){return K(St.materials[e],_e)}function Se(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return Ce(n)}return{}}function Ce(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"perspective":case"orthographic":t.technique=r.nodeName,t.parameters=Le(r)}}return t}function Le(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[r.nodeName]=parseFloat(r.textContent)}}return t}function Pe(e){let t;switch(e.optics.technique){case"perspective":t=new P(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let n=e.optics.parameters.ymag,r=e.optics.parameters.xmag;const o=e.optics.parameters.aspect_ratio;r=void 0===r?n*o:r,n=void 0===n?r/o:n,r*=.5,n*=.5,t=new M(-r,r,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new P}return t.name=e.name||"",t}function Me(e){const t=St.cameras[e];return void 0!==t?K(t,Pe):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function Fe(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=r.nodeName,t.parameters=De(r)}}return t}function De(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":const e=h(r.textContent);t.color=(new p).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(r.textContent);break;case"quadratic_attenuation":const n=parseFloat(r.textContent);t.distance=n?Math.sqrt(1/n):0}}return t}function Ue(e){let t;switch(e.technique){case"directional":t=new V;break;case"point":t=new U;break;case"spot":t=new D;break;case"ambient":t=new F}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function Ve(e){const t=St.lights[e];return void 0!==t?K(t,Ue):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function Be(e){const t={array:[],stride:3};for(let r=0;r<e.childNodes.length;r++){const o=e.childNodes[r];if(1===o.nodeType)switch(o.nodeName){case"float_array":t.array=h(o.textContent);break;case"Name_array":t.array=a(o.textContent);break;case"technique_common":const e=n(o,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function je(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&(t[r.getAttribute("semantic")]=v(r.getAttribute("source")))}return t}function ze(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=v(r.getAttribute("source")),n=r.getAttribute("semantic"),o=parseInt(r.getAttribute("offset")),i=parseInt(r.getAttribute("set")),a=i>0?n+i:n;t.inputs[a]={id:e,offset:o},t.stride=Math.max(t.stride,o+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=m(r.textContent);break;case"p":t.p=m(r.textContent)}}return t}function Ge(e){let t=0;for(let n=0,r=e.length;n<r;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function We(e){const t={},n=e.sources,r=e.vertices,o=e.primitives;if(0===o.length)return{};const i=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];void 0===t[r.type]&&(t[r.type]=[]),t[r.type].push(r)}return t}(o);for(const e in i){const o=i[e];Ge(o),t[e]=He(o,n,r)}return t}function He(e,t,n){const r={},o={array:[],stride:0},i={array:[],stride:0},a={array:[],stride:0},c={array:[],stride:0},u={array:[],stride:0},d=[],p=4,f=[],h=4,m=new s,g=[];let y=0;for(let r=0;r<e.length;r++){const s=e[r],l=s.inputs;let p=0;switch(s.type){case"lines":case"linestrips":p=2*s.count;break;case"triangles":p=3*s.count;break;case"polylist":for(let e=0;e<s.count;e++){const t=s.vcount[e];switch(t){case 3:p+=3;break;case 4:p+=6;break;default:p+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",s.type)}m.addGroup(y,p,r),y+=p,s.material&&g.push(s.material);for(const r in l){const p=l[r];switch(r){case"VERTEX":for(const r in n){const l=n[r];switch(r){case"POSITION":const n=o.array.length;if(Ye(s,t[l],p.offset,o.array),o.stride=t[l].stride,t.skinWeights&&t.skinIndices&&(Ye(s,t.skinIndices,p.offset,d),Ye(s,t.skinWeights,p.offset,f)),!1===s.hasUV&&!0===e.uvsNeedsFix){const e=(o.array.length-n)/o.stride;for(let t=0;t<e;t++)a.array.push(0,0)}break;case"NORMAL":Ye(s,t[l],p.offset,i.array),i.stride=t[l].stride;break;case"COLOR":Ye(s,t[l],p.offset,u.array),u.stride=t[l].stride;break;case"TEXCOORD":Ye(s,t[l],p.offset,a.array),a.stride=t[l].stride;break;case"TEXCOORD1":Ye(s,t[l],p.offset,c.array),a.stride=t[l].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',r)}}break;case"NORMAL":Ye(s,t[p.id],p.offset,i.array),i.stride=t[p.id].stride;break;case"COLOR":Ye(s,t[p.id],p.offset,u.array,!0),u.stride=t[p.id].stride;break;case"TEXCOORD":Ye(s,t[p.id],p.offset,a.array),a.stride=t[p.id].stride;break;case"TEXCOORD1":Ye(s,t[p.id],p.offset,c.array),c.stride=t[p.id].stride}}}return o.array.length>0&&m.setAttribute("position",new l(o.array,o.stride)),i.array.length>0&&m.setAttribute("normal",new l(i.array,i.stride)),u.array.length>0&&m.setAttribute("color",new l(u.array,u.stride)),a.array.length>0&&m.setAttribute("uv",new l(a.array,a.stride)),c.array.length>0&&m.setAttribute("uv1",new l(c.array,c.stride)),d.length>0&&m.setAttribute("skinIndex",new l(d,p)),f.length>0&&m.setAttribute("skinWeight",new l(f,h)),r.data=m,r.type=e[0].type,r.materialKeys=g,r}function Ye(e,t,n,r,o=!1){const i=e.p,a=e.stride,s=e.vcount;function c(e){let t=i[e+n]*u;const a=t+u;for(;t<a;t++)r.push(l[t]);if(o){const e=r.length-u-1;Ot.setRGB(r[e+0],r[e+1],r[e+2]).convertSRGBToLinear(),r[e+0]=Ot.r,r[e+1]=Ot.g,r[e+2]=Ot.b}}const l=t.array,u=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=s.length;t<n;t++){const n=s[t];if(4===n){const t=e+1*a,n=e+2*a,r=e+3*a;c(e+0*a),c(t),c(r),c(t),c(n),c(r)}else if(3===n){const t=e+1*a,n=e+2*a;c(e+0*a),c(t),c(n)}else if(n>4)for(let t=1,r=n-2;t<=r;t++){const n=e+a*t,r=e+a*(t+1);c(e+0*a),c(n),c(r)}e+=a*n}}else for(let e=0,t=i.length;e<t;e+=a)c(e)}function Ke(e){return K(St.geometries[e],We)}function qe(e){return void 0!==e.build?e.build:e}function Xe(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"joint":t.joints[r.getAttribute("sid")]=$e(r);break;case"link":t.links.push(Je(r))}}}function $e(e){let t;for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"prismatic":case"revolute":t=Ze(r)}}return t}function Ze(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new x,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"axis":const e=h(r.textContent);t.axis.fromArray(e);break;case"limits":const n=r.getElementsByTagName("max")[0],o=r.getElementsByTagName("min")[0];t.limits.max=parseFloat(n.textContent),t.limits.min=parseFloat(o.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function Je(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"attachment_full":t.attachments.push(Qe(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(et(r))}}return t}function Qe(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"link":t.links.push(Je(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(et(r))}}return t}function et(e){const t={type:e.nodeName},n=h(e.textContent);switch(t.type){case"matrix":t.obj=new u,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new x,t.obj.fromArray(n);break;case"rotate":t.obj=new x,t.obj.fromArray(n),t.angle=O.degToRad(n[3])}return t}function tt(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)nt(r,t)}}function nt(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"inertia":t.inertia=h(r.textContent);break;case"mass":t.mass=h(r.textContent)[0]}}}function rt(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"axis"===r.nodeName){const e=r.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function ot(e){return void 0!==e.build?e.build:e}function it(e){const t=[],n=bt.querySelector('[id="'+e.id+'"]');for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];if(1!==r.nodeType)continue;let o,i;switch(r.nodeName){case"matrix":o=h(r.textContent);const e=(new u).fromArray(o).transpose();t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:e});break;case"translate":case"scale":o=h(r.textContent),i=(new x).fromArray(o),t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:i});break;case"rotate":o=h(r.textContent),i=(new x).fromArray(o);const n=O.degToRad(o[3]);t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:i,angle:n})}}return t}const at=new u,st=new x;function ct(e){const t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new u,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1!==r.nodeType)continue;let o;switch(r.nodeName){case"node":t.nodes.push(r.getAttribute("id")),ct(r);break;case"instance_camera":t.instanceCameras.push(v(r.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(lt(r));break;case"instance_light":t.instanceLights.push(v(r.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(lt(r));break;case"instance_node":t.instanceNodes.push(v(r.getAttribute("url")));break;case"matrix":o=h(r.textContent),t.matrix.multiply(at.fromArray(o).transpose()),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"translate":o=h(r.textContent),st.fromArray(o),t.matrix.multiply(at.makeTranslation(st.x,st.y,st.z)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"rotate":o=h(r.textContent);const e=O.degToRad(o[3]);t.matrix.multiply(at.makeRotationAxis(st.fromArray(o),e)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"scale":o=h(r.textContent),t.matrix.scale(st.fromArray(o)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"extra":break;default:console.log(r)}}return gt(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):St.nodes[t.id]=t,t}function lt(e){const t={id:v(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"bind_material":const e=r.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const r=e[n],o=r.getAttribute("symbol"),i=r.getAttribute("target");t.materials[o]=v(i)}break;case"skeleton":t.skeletons.push(v(r.textContent))}}return t}function ut(e,t){const n=[],r=[];let o,i,a;for(o=0;o<e.length;o++){const r=e[o];let i;if(gt(r))i=yt(r),dt(i,t,n);else if(s=r,void 0!==St.visualScenes[s]){const e=St.visualScenes[r].children;for(let r=0;r<e.length;r++){const o=e[r];if("JOINT"===o.type){dt(yt(o.id),t,n)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}var s;for(o=0;o<t.length;o++)for(i=0;i<n.length;i++)if(a=n[i],a.bone.name===t[o].name){r[o]=a,a.processed=!0;break}for(o=0;o<n.length;o++)a=n[o],!1===a.processed&&(r.push(a),a.processed=!0);const c=[],l=[];for(o=0;o<r.length;o++)a=r[o],c.push(a.bone),l.push(a.boneInverse);return new H(c,l)}function dt(e,t,n){e.traverse((function(e){if(!0===e.isBone){let r;for(let n=0;n<t.length;n++){const o=t[n];if(o.name===e.name){r=o.boneInverse;break}}void 0===r&&(r=new u),n.push({bone:e,boneInverse:r,processed:!1})}}))}function pt(e){const t=[],n=e.matrix,o=e.nodes,i=e.type,a=e.instanceCameras,s=e.instanceControllers,c=e.instanceLights,l=e.instanceGeometries,u=e.instanceNodes;for(let e=0,n=o.length;e<n;e++)t.push(yt(o[e]));for(let e=0,n=a.length;e<n;e++){const n=Me(a[e]);null!==n&&t.push(n.clone())}for(let e=0,n=s.length;e<n;e++){const n=s[e],r=(d=n.id,K(St.controllers[d],pe)),o=mt(Ke(r.id),n.materials),i=ut(n.skeletons,r.skin.joints);for(let e=0,n=o.length;e<n;e++){const n=o[e];n.isSkinnedMesh&&(n.bind(i,r.skin.bindMatrix),n.normalizeSkinWeights()),t.push(n)}}var d;for(let e=0,n=c.length;e<n;e++){const n=Ve(c[e]);null!==n&&t.push(n.clone())}for(let e=0,n=l.length;e<n;e++){const n=l[e],r=mt(Ke(n.id),n.materials);for(let e=0,n=r.length;e<n;e++)t.push(r[e])}for(let e=0,n=u.length;e<n;e++)t.push(yt(u[e]).clone());let p;if(0===o.length&&1===t.length)p=t[0];else{p="JOINT"===i?new B:new r;for(let e=0;e<t.length;e++)p.add(t[e])}return p.name="JOINT"===i?e.sid:e.name,p.matrix.copy(n),p.matrix.decompose(p.position,p.quaternion,p.scale),p}const ft=new R({color:16711935});function ht(e,t){const n=[];for(let r=0,o=e.length;r<o;r++){const o=t[e[r]];void 0===o?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[r]),n.push(ft)):n.push(we(o))}return n}function mt(e,t){const n=[];for(const r in e){const i=e[r],a=ht(i.materialKeys,t);if(0===a.length&&("lines"===r||"linestrips"===r?a.push(new j):a.push(new o)),"lines"===r||"linestrips"===r)for(let e=0,t=a.length;e<t;e++){const t=a[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){const n=new j;n.color.copy(t.color),n.opacity=t.opacity,n.transparent=t.transparent,a[e]=n}}const s=void 0!==i.data.attributes.skinIndex,l=1===a.length?a[0]:a;let u;switch(r){case"lines":u=new W(i.data,l);break;case"linestrips":u=new G(i.data,l);break;case"triangles":case"polylist":u=s?new z(i.data,l):new c(i.data,l)}n.push(u)}return n}function gt(e){return void 0!==St.nodes[e]}function yt(e){return K(St.nodes[e],pt)}function vt(e){const t=new r;t.name=e.name;const n=e.children;for(let e=0;e<n.length;e++){const r=n[e];t.add(yt(r.id))}return t}function Et(e){return K(St.visualScenes[e],vt)}if(0===e.length)return{scene:new k};const Tt=(new DOMParser).parseFromString(e,"application/xml"),bt=n(Tt,"COLLADA")[0],At=Tt.getElementsByTagName("parsererror")[0];if(void 0!==At){const e=n(At,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(At),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const xt=bt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",xt);const Nt=function(e){return{unit:T(n(e,"unit")[0]),upAxis:b(n(e,"up_axis")[0])}}(n(bt,"asset")[0]),Rt=new d(this.manager);let kt;Rt.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),Bt&&(kt=new Bt(this.manager),kt.setPath(this.resourcePath||t));const Ot=new p,It=[];let _t={},wt=0;const St={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};A(bt,"library_animations","animation",(function e(t){const n={sources:{},samplers:{},channels:{}};let r=!1;for(let o=0,i=t.childNodes.length;o<i;o++){const i=t.childNodes[o];if(1!==i.nodeType)continue;let a;switch(i.nodeName){case"source":a=i.getAttribute("id"),n.sources[a]=Be(i);break;case"sampler":a=i.getAttribute("id"),n.samplers[a]=q(i);break;case"channel":a=i.getAttribute("target"),n.channels[a]=X(i);break;case"animation":e(i),r=!0;break;default:console.log(i)}}!1===r&&(St.animations[t.getAttribute("id")||O.generateUUID()]=n)})),A(bt,"library_animation_clips","animation_clip",(function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_animation"===r.nodeName)t.animations.push(v(r.getAttribute("url")))}St.clips[e.getAttribute("id")]=t})),A(bt,"library_controllers","controller",(function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"skin":t.id=v(r.getAttribute("source")),t.skin=le(r);break;case"morph":t.id=v(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}St.controllers[e.getAttribute("id")]=t})),A(bt,"library_images","image",(function(e){const t={init_from:n(e,"init_from")[0].textContent};St.images[e.getAttribute("id")]=t})),A(bt,"library_effects","effect",(function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"profile_COMMON"===r.nodeName)t.profile=me(r)}St.effects[e.getAttribute("id")]=t})),A(bt,"library_materials","material",(function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_effect"===r.nodeName)t.url=v(r.getAttribute("url"))}St.materials[e.getAttribute("id")]=t})),A(bt,"library_cameras","camera",(function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"optics"===r.nodeName)t.optics=Se(r)}St.cameras[e.getAttribute("id")]=t})),A(bt,"library_lights","light",(function(e){let t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)t=Fe(r)}St.lights[e.getAttribute("id")]=t})),A(bt,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},r=n(e,"mesh")[0];if(void 0!==r){for(let e=0;e<r.childNodes.length;e++){const n=r.childNodes[e];if(1!==n.nodeType)continue;const o=n.getAttribute("id");switch(n.nodeName){case"source":t.sources[o]=Be(n);break;case"vertices":t.vertices=je(n);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(ze(n));break;default:console.log(n)}}St.geometries[e.getAttribute("id")]=t}})),A(bt,"library_nodes","node",ct),A(bt,"library_visual_scenes","visual_scene",(function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id","three_default_"+wt++)}}(e);const r=n(e,"node");for(let e=0;e<r.length;e++)t.children.push(ct(r[e]));St.visualScenes[e.getAttribute("id")]=t})),A(bt,"library_kinematics_models","kinematics_model",(function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)Xe(r,t)}St.kinematicsModels[e.getAttribute("id")]=t})),A(bt,"library_physics_models","physics_model",(function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"rigid_body"===r.nodeName)t.rigidBodies[r.getAttribute("name")]={},tt(r,t.rigidBodies[r.getAttribute("name")])}St.physicsModels[e.getAttribute("id")]=t})),A(bt,"scene","instance_kinematics_scene",(function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"bind_joint_axis"===r.nodeName)t.bindJointAxis.push(rt(r))}St.kinematicsScenes[v(e.getAttribute("url"))]=t})),Y(St.animations,$),Y(St.clips,se),Y(St.controllers,pe),Y(St.images,fe),Y(St.effects,Ie),Y(St.materials,_e),Y(St.cameras,Pe),Y(St.lights,Ue),Y(St.geometries,We),Y(St.visualScenes,vt),function(){const e=St.clips;if(!0===E(e)){if(!1===E(St.animations)){const e=[];for(const t in St.animations){const n=Z(t);for(let t=0,r=n.length;t<r;t++)e.push(n[t])}It.push(new I("default",-1,e))}}else for(const t in e)It.push(ce(t))}(),function(){const e=Object.keys(St.kinematicsModels)[0],t=Object.keys(St.kinematicsScenes)[0],n=Object.keys(St.visualScenes)[0];if(void 0===e||void 0===t)return;const r=(o=e,K(St.kinematicsModels[o],qe));var o;const i=function(e){return K(St.kinematicsScenes[e],ot)}(t),a=Et(n),s=i.bindJointAxis,c={};for(let e=0,t=s.length;e<t;e++){const t=s[e],n=bt.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;l(t.jointIndex,e)}}function l(e,t){const n=t.getAttribute("name"),o=r.joints[e];a.traverse((function(r){r.name===n&&(c[e]={object:r,transforms:it(t),joint:o,position:o.zeroPosition})}))}const d=new u;_t={joints:r&&r.joints,getJointValue:function(e){const t=c[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){const n=c[e];if(n){const r=n.joint;if(t>r.limits.max||t<r.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+r.limits.min+", max: "+r.limits.max+").");else if(r.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{const o=n.object,i=r.axis,a=n.transforms;at.identity();for(let n=0;n<a.length;n++){const o=a[n];if(o.sid&&-1!==o.sid.indexOf(e))switch(r.type){case"revolute":at.multiply(d.makeRotationAxis(i,O.degToRad(t)));break;case"prismatic":at.multiply(d.makeTranslation(i.x*t,i.y*t,i.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+r.type)}else switch(o.type){case"matrix":at.multiply(o.obj);break;case"translate":at.multiply(d.makeTranslation(o.obj.x,o.obj.y,o.obj.z));break;case"scale":at.scale(o.obj);break;case"rotate":at.multiply(d.makeRotationAxis(o.obj,o.angle))}}o.matrix.copy(at),o.matrix.decompose(o.position,o.quaternion,o.scale),c[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}();const Ct=function(e){return Et(v(n(e,"instance_visual_scene")[0].getAttribute("url")))}(n(bt,"scene")[0]);return Ct.animations=It,"Z_UP"===Nt.upAxis&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),Ct.rotation.set(-Math.PI/2,0,0)),Ct.scale.multiplyScalar(Nt.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),It},kinematics:_t,library:St,scene:Ct}}}class zt extends e{constructor(e){super(e)}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){function t(e){let t="AMF Material";const r=e.attributes.id.textContent;let i={r:1,g:1,b:1,a:1},a=null;for(let r=0;r<e.childNodes.length;r++){const o=e.childNodes[r];"metadata"===o.nodeName&&void 0!==o.attributes.type?"name"===o.attributes.type.value&&(t=o.textContent):"color"===o.nodeName&&(i=n(o))}return a=new o({flatShading:!0,color:new p(i.r,i.g,i.b),name:t}),1!==i.a&&(a.transparent=!0,a.opacity=i.a),{id:r,material:a}}function n(e){const t={r:1,g:1,b:1,a:1};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];"r"===r.nodeName?t.r=r.textContent:"g"===r.nodeName?t.g=r.textContent:"b"===r.nodeName?t.b=r.textContent:"a"===r.nodeName&&(t.a=r.textContent)}return t}function i(e){const t={name:"",triangles:[],materialid:null};let n=e.firstElementChild;for(void 0!==e.attributes.materialid&&(t.materialId=e.attributes.materialid.nodeValue);n;){if("metadata"===n.nodeName)void 0!==n.attributes.type&&"name"===n.attributes.type.value&&(t.name=n.textContent);else if("triangle"===n.nodeName){const e=n.getElementsByTagName("v1")[0].textContent,r=n.getElementsByTagName("v2")[0].textContent,o=n.getElementsByTagName("v3")[0].textContent;t.triangles.push(e,r,o)}n=n.nextElementSibling}return t}function a(e){const t=[],n=[];let r=e.firstElementChild;for(;r;){if("vertex"===r.nodeName){let e=r.firstElementChild;for(;e;){if("coordinates"===e.nodeName){const n=e.getElementsByTagName("x")[0].textContent,r=e.getElementsByTagName("y")[0].textContent,o=e.getElementsByTagName("z")[0].textContent;t.push(n,r,o)}else if("normal"===e.nodeName){const t=e.getElementsByTagName("nx")[0].textContent,r=e.getElementsByTagName("ny")[0].textContent,o=e.getElementsByTagName("nz")[0].textContent;n.push(t,r,o)}e=e.nextElementSibling}}r=r.nextElementSibling}return{vertices:t,normals:n}}function u(e){const t=e.attributes.id.textContent,r={name:"amfobject",meshes:[]};let o=null,s=e.firstElementChild;for(;s;){if("metadata"===s.nodeName)void 0!==s.attributes.type&&"name"===s.attributes.type.value&&(r.name=s.textContent);else if("color"===s.nodeName)o=n(s);else if("mesh"===s.nodeName){let e=s.firstElementChild;const t={vertices:[],normals:[],volumes:[],color:o};for(;e;){if("vertices"===e.nodeName){const n=a(e);t.normals=t.normals.concat(n.normals),t.vertices=t.vertices.concat(n.vertices)}else"volume"===e.nodeName&&t.volumes.push(i(e));e=e.nextElementSibling}r.meshes.push(t)}s=s.nextElementSibling}return{id:t,obj:r}}const d=function(e){let t=new DataView(e);if("PK"===String.fromCharCode(t.getUint8(0),t.getUint8(1))){let n=null,r=null;console.log("THREE.AMFLoader: Loading Zip");try{n=Dt(new Uint8Array(e))}catch(e){if(e instanceof ReferenceError)return console.log("THREE.AMFLoader: fflate missing and file is compressed."),null}for(r in n)if(".amf"===r.toLowerCase().slice(-4))break;console.log("THREE.AMFLoader: Trying to load file asset: "+r),t=new DataView(n[r].buffer)}const n=(new TextDecoder).decode(t),r=(new DOMParser).parseFromString(n,"application/xml");return"amf"!==r.documentElement.nodeName.toLowerCase()?(console.log("THREE.AMFLoader: Error loading AMF - no AMF document found."),null):r}(e);let f="",h="";const m=function(e){let t=1,n="millimeter";void 0!==e.documentElement.attributes.unit&&(n=e.documentElement.attributes.unit.value.toLowerCase());const r={millimeter:1,inch:25.4,feet:304.8,meter:1e3,micron:.001};return void 0!==r[n]&&(t=r[n]),console.log("THREE.AMFLoader: Unit scale: "+t),t}(d),g={},y={},v=d.documentElement.childNodes;let E,T;for(E=0;E<v.length;E++){const e=v[E];if("metadata"===e.nodeName)void 0!==e.attributes.type&&("name"===e.attributes.type.value?f=e.textContent:"author"===e.attributes.type.value&&(h=e.textContent));else if("material"===e.nodeName){const n=t(e);g[n.id]=n.material}else if("object"===e.nodeName){const t=u(e);y[t.id]=t.obj}}const b=new r,A=new o({color:11184895,flatShading:!0});b.name=f,b.userData.author=h,b.userData.loader="AMF";for(const e in y){const t=y[e],n=t.meshes,o=new r;for(o.name=t.name||"",E=0;E<n.length;E++){let e=A;const t=n[E],r=new l(t.vertices,3);let i=null;if(t.normals.length&&(i=new l(t.normals,3)),t.color){const n=t.color;e=A.clone(),e.color=new p(n.r,n.g,n.b),1!==n.a&&(e.transparent=!0,e.opacity=n.a)}const a=t.volumes;for(T=0;T<a.length;T++){const t=a[T],n=new s;let l=e;n.setIndex(t.triangles),n.setAttribute("position",r.clone()),i&&n.setAttribute("normal",i.clone()),void 0!==g[t.materialId]&&(l=g[t.materialId]),n.scale(m,m,m),o.add(new c(n,l.clone()))}}b.add(o)}return b}}class Gt extends e{constructor(e){super(e),this.splitLayer=!1}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){let t={x:0,y:0,z:0,e:0,f:0,extruding:!1,relative:!1};const n=[];let o;const i=new j({color:16711680});i.name="path";const a=new j({color:65280});function c(e){o={vertex:[],pathVertex:[],z:e.z},n.push(o)}function u(e,n){return t.relative?n:n-e}function d(e,n){return t.relative?e+n:n}a.name="extruded";const p=e.replace(/;.+/g,"").split("\n");for(let e=0;e<p.length;e++){const n=p[e].split(" "),r=n[0].toUpperCase(),i={};if(n.splice(1).forEach((function(e){if(void 0!==e[0]){const t=e[0].toLowerCase(),n=parseFloat(e.substring(1));i[t]=n}})),"G0"===r||"G1"===r){const e={x:void 0!==i.x?d(t.x,i.x):t.x,y:void 0!==i.y?d(t.y,i.y):t.y,z:void 0!==i.z?d(t.z,i.z):t.z,e:void 0!==i.e?d(t.e,i.e):t.e,f:void 0!==i.f?d(t.f,i.f):t.f};u(t.e,e.e)>0&&(t.extruding=u(t.e,e.e)>0,null!=o&&e.z==o.z||c(e)),f=t,h=e,void 0===o&&c(f),t.extruding?(o.vertex.push(f.x,f.y,f.z),o.vertex.push(h.x,h.y,h.z)):(o.pathVertex.push(f.x,f.y,f.z),o.pathVertex.push(h.x,h.y,h.z)),t=e}else if("G2"===r||"G3"===r);else if("G90"===r)t.relative=!1;else if("G91"===r)t.relative=!0;else if("G92"===r){const e=t;e.x=void 0!==i.x?i.x:e.x,e.y=void 0!==i.y?i.y:e.y,e.z=void 0!==i.z?i.z:e.z,e.e=void 0!==i.e?i.e:e.e}}var f,h;function m(e,t,n){const r=new s;r.setAttribute("position",new l(e,3));const o=new W(r,t?a:i);o.name="layer"+n,g.add(o)}const g=new r;if(g.name="gcode",this.splitLayer)for(let e=0;e<n.length;e++){const t=n[e];m(t.vertex,!0,e),m(t.pathVertex,!1,e)}else{const e=[],t=[];for(let r=0;r<n.length;r++){const o=n[r],i=o.vertex,a=o.pathVertex;for(let t=0;t<i.length;t++)e.push(i[t]);for(let e=0;e<a.length;e++)t.push(a[e])}m(e,!0,n.length),m(t,!1,n.length)}return g.rotation.set(-Math.PI/2,0,0),g}}class Wt extends e{constructor(e){super(e),this.animateBonePositions=!0,this.animateBoneRotations=!0}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){function t(e,n,r){if("ENDSITE"===r.type)return;const o={time:n,position:new x,rotation:new N};r.frames.push(o);const i=new N,a=new x(1,0,0),s=new x(0,1,0),c=new x(0,0,1);for(let t=0;t<r.channels.length;t++)switch(r.channels[t]){case"Xposition":o.position.x=parseFloat(e.shift().trim());break;case"Yposition":o.position.y=parseFloat(e.shift().trim());break;case"Zposition":o.position.z=parseFloat(e.shift().trim());break;case"Xrotation":i.setFromAxisAngle(a,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(i);break;case"Yrotation":i.setFromAxisAngle(s,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(i);break;case"Zrotation":i.setFromAxisAngle(c,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(i);break;default:console.warn("THREE.BVHLoader: Invalid channel type.")}for(let o=0;o<r.children.length;o++)t(e,n,r.children[o])}function n(e,t,o){const i={name:"",type:"",frames:[]};o.push(i);let a=t.split(/[\s]+/);"END"===a[0].toUpperCase()&&"SITE"===a[1].toUpperCase()?(i.type="ENDSITE",i.name="ENDSITE"):(i.name=a[1],i.type=a[0].toUpperCase()),"{"!==r(e)&&console.error("THREE.BVHLoader: Expected opening { after type & name"),a=r(e).split(/[\s]+/),"OFFSET"!==a[0]&&console.error("THREE.BVHLoader: Expected OFFSET but got: "+a[0]),4!==a.length&&console.error("THREE.BVHLoader: Invalid number of values for OFFSET.");const s=new x(parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3]));if((isNaN(s.x)||isNaN(s.y)||isNaN(s.z))&&console.error("THREE.BVHLoader: Invalid values of OFFSET."),i.offset=s,"ENDSITE"!==i.type){a=r(e).split(/[\s]+/),"CHANNELS"!==a[0]&&console.error("THREE.BVHLoader: Expected CHANNELS definition.");const t=parseInt(a[1]);i.channels=a.splice(2,t),i.children=[]}for(;;){const t=r(e);if("}"===t)return i;i.children.push(n(e,t,o))}}function r(e){let t;for(;0===(t=e.shift().trim()).length;);return t}const o=this,i=function(e){"HIERARCHY"!==r(e)&&console.error("THREE.BVHLoader: HIERARCHY expected.");const o=[],i=n(e,r(e),o);"MOTION"!==r(e)&&console.error("THREE.BVHLoader: MOTION expected.");let a=r(e).split(/[\s]+/);const s=parseInt(a[1]);isNaN(s)&&console.error("THREE.BVHLoader: Failed to read number of frames."),a=r(e).split(/[\s]+/);const c=parseFloat(a[2]);isNaN(c)&&console.error("THREE.BVHLoader: Failed to read frame time.");for(let n=0;n<s;n++)a=r(e).split(/[\s]+/),t(a,n*c,i);return o}(e.split(/[\r\n]+/g)),a=[];!function e(t,n){const r=new B;if(n.push(r),r.position.add(t.offset),r.name=t.name,"ENDSITE"!==t.type)for(let o=0;o<t.children.length;o++)r.add(e(t.children[o],n));return r}(i[0],a);const s=function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if("ENDSITE"===r.type)continue;const i=[],a=[],s=[];for(let e=0;e<r.frames.length;e++){const t=r.frames[e];i.push(t.time),a.push(t.position.x+r.offset.x),a.push(t.position.y+r.offset.y),a.push(t.position.z+r.offset.z),s.push(t.rotation.x),s.push(t.rotation.y),s.push(t.rotation.z),s.push(t.rotation.w)}o.animateBonePositions&&t.push(new _(r.name+".position",i,a)),o.animateBoneRotations&&t.push(new w(r.name+".quaternion",i,s))}return new I("animation",-1,t)}(i);return{skeleton:new H(a),clip:s}}}class Ht extends e{load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const t=new DataView(e),n=t.getUint32(0,!0),r=t.getUint32(4,!0);if(542658390!==n||150!==r)return void console.error("Not a valid VOX file");const o=[0,4294967295,4291624959,4288282623,4284940287,4281597951,4278255615,4294954239,4291611903,4288269567,4284927231,4281584895,4278242559,4294941183,4291598847,4288256511,4284914175,4281571839,4278229503,4294928127,4291585791,4288243455,4284901119,4281558783,4278216447,4294915071,4291572735,4288230399,4284888063,4281545727,4278203391,4294902015,4291559679,4288217343,4284875007,4281532671,4278190335,4294967244,4291624908,4288282572,4284940236,4281597900,4278255564,4294954188,4291611852,4288269516,4284927180,4281584844,4278242508,4294941132,4291598796,4288256460,4284914124,4281571788,4278229452,4294928076,4291585740,4288243404,4284901068,4281558732,4278216396,4294915020,4291572684,4288230348,4284888012,4281545676,4278203340,4294901964,4291559628,4288217292,4284874956,4281532620,4278190284,4294967193,4291624857,4288282521,4284940185,4281597849,4278255513,4294954137,4291611801,4288269465,4284927129,4281584793,4278242457,4294941081,4291598745,4288256409,4284914073,4281571737,4278229401,4294928025,4291585689,4288243353,4284901017,4281558681,4278216345,4294914969,4291572633,4288230297,4284887961,4281545625,4278203289,4294901913,4291559577,4288217241,4284874905,4281532569,4278190233,4294967142,4291624806,4288282470,4284940134,4281597798,4278255462,4294954086,4291611750,4288269414,4284927078,4281584742,4278242406,4294941030,4291598694,4288256358,4284914022,4281571686,4278229350,4294927974,4291585638,4288243302,4284900966,4281558630,4278216294,4294914918,4291572582,4288230246,4284887910,4281545574,4278203238,4294901862,4291559526,4288217190,4284874854,4281532518,4278190182,4294967091,4291624755,4288282419,4284940083,4281597747,4278255411,4294954035,4291611699,4288269363,4284927027,4281584691,4278242355,4294940979,4291598643,4288256307,4284913971,4281571635,4278229299,4294927923,4291585587,4288243251,4284900915,4281558579,4278216243,4294914867,4291572531,4288230195,4284887859,4281545523,4278203187,4294901811,4291559475,4288217139,4284874803,4281532467,4278190131,4294967040,4291624704,4288282368,4284940032,4281597696,4278255360,4294953984,4291611648,4288269312,4284926976,4281584640,4278242304,4294940928,4291598592,4288256256,4284913920,4281571584,4278229248,4294927872,4291585536,4288243200,4284900864,4281558528,4278216192,4294914816,4291572480,4288230144,4284887808,4281545472,4278203136,4294901760,4291559424,4288217088,4284874752,4281532416,4278190318,4278190301,4278190267,4278190250,4278190216,4278190199,4278190165,4278190148,4278190114,4278190097,4278251008,4278246656,4278237952,4278233600,4278224896,4278220544,4278211840,4278207488,4278198784,4278194432,4293787648,4292673536,4290445312,4289331200,4287102976,4285988864,4283760640,4282646528,4280418304,4279304192,4293848814,4292730333,4290493371,4289374890,4287137928,4286019447,4283782485,4282664004,4280427042,4279308561];let i,a=8;const s=[];for(;a<t.byteLength;){let n="";for(let e=0;e<4;e++)n+=String.fromCharCode(t.getUint8(a++));const r=t.getUint32(a,!0);if(a+=4,a+=4,"SIZE"===n){const e=t.getUint32(a,!0);a+=4;const n=t.getUint32(a,!0);a+=4;const c=t.getUint32(a,!0);a+=4,i={palette:o,size:{x:e,y:n,z:c}},s.push(i),a+=r-12}else if("XYZI"===n){const n=t.getUint32(a,!0);a+=4,i.data=new Uint8Array(e,a,4*n),a+=4*n}else if("RGBA"===n){const e=[0];for(let n=0;n<256;n++)e[n+1]=t.getUint32(a,!0),a+=4;i.palette=e}else a+=r}return s}}class Yt extends c{constructor(e){const t=e.data,n=e.size,r=e.palette,o=[],i=[],a=[0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1],c=[1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0],u=[0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1],d=[0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0],h=[0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0],g=[0,1,1,1,1,1,0,1,0,1,1,0,0,1,0,1,1,1],y=new p;function v(e,t,r,a,s,c,l){t-=n.x/2,r-=n.z/2,a+=n.y/2;for(let n=0;n<18;n+=3)y.setRGB(s,c,l,f),o.push(e[n+0]+t,e[n+1]+r,e[n+2]+a),i.push(y.r,y.g,y.b)}const E=n.x,T=n.x*n.y,b=new Uint8Array(n.x*n.y*n.z);for(let e=0;e<t.length;e+=4){b[t[e+0]+t[e+1]*E+t[e+2]*T]=255}let A=!1;for(let e=0;e<t.length;e+=4){const o=t[e+0],i=t[e+1],s=t[e+2],l=r[t[e+3]],p=(l>>0&255)/255,f=(l>>8&255)/255,m=(l>>16&255)/255;(p>0||f>0||m>0)&&(A=!0);const y=o+i*E+s*T;0!==b[y+1]&&o!==n.x-1||v(c,o,s,-i,p,f,m),0!==b[y-1]&&0!==o||v(a,o,s,-i,p,f,m),0!==b[y+E]&&i!==n.y-1||v(d,o,s,-i,p,f,m),0!==b[y-E]&&0!==i||v(u,o,s,-i,p,f,m),0!==b[y+T]&&s!==n.z-1||v(g,o,s,-i,p,f,m),0!==b[y-T]&&0!==s||v(h,o,s,-i,p,f,m)}const x=new s;x.setAttribute("position",new l(o,3)),x.computeVertexNormals();const N=new m;A&&(x.setAttribute("color",new l(i,3)),N.vertexColors=!0),super(x,N)}}class Kt extends e{constructor(e){super(e)}load(e,t,r,o){const i=this,a=new n(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.load(e,(function(e){t(i.parse(e))}),r,o)}parse(e){const t=new DataView(e),n=t.getUint32(0),r=t.getUint32(4);let o=8;const i=new Float32Array(n),a=new Float32Array(n*n).fill(0);for(let e=0;e<n;e++)i[e]=t.getFloat32(o),o+=4,a[n*e+e]=1;const s=new Y(".morphTargetInfluences",i,a),c=new I("default",i[i.length-1],[s]),l=[];for(let e=0;e<n;e++){const n=new Float32Array(3*r);for(let e=0;e<r;e++){const r=3*e;n[r+0]=t.getFloat32(o),o+=4,n[r+1]=t.getFloat32(o),o+=4,n[r+2]=t.getFloat32(o),o+=4}const i=new h(n,3);i.name="morph_"+e,l.push(i)}return{morphTargets:l,clip:c}}}class qt extends e{constructor(e){super(e),this.littleEndian=!0}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const t=(new TextDecoder).decode(e),n=function(e){const t={},n=e.search(/[\r\n]DATA\s(\S*)\s/i),r=/[\r\n]DATA\s(\S*)\s/i.exec(e.slice(n-1));if(t.data=r[1],t.headerLen=r[0].length+n,t.str=e.slice(0,t.headerLen),t.str=t.str.replace(/#.*/gi,""),t.version=/VERSION (.*)/i.exec(t.str),t.fields=/FIELDS (.*)/i.exec(t.str),t.size=/SIZE (.*)/i.exec(t.str),t.type=/TYPE (.*)/i.exec(t.str),t.count=/COUNT (.*)/i.exec(t.str),t.width=/WIDTH (.*)/i.exec(t.str),t.height=/HEIGHT (.*)/i.exec(t.str),t.viewpoint=/VIEWPOINT (.*)/i.exec(t.str),t.points=/POINTS (.*)/i.exec(t.str),null!==t.version&&(t.version=parseFloat(t.version[1])),t.fields=null!==t.fields?t.fields[1].split(" "):[],null!==t.type&&(t.type=t.type[1].split(" ")),null!==t.width&&(t.width=parseInt(t.width[1])),null!==t.height&&(t.height=parseInt(t.height[1])),null!==t.viewpoint&&(t.viewpoint=t.viewpoint[1]),null!==t.points&&(t.points=parseInt(t.points[1],10)),null===t.points&&(t.points=t.width*t.height),null!==t.size&&(t.size=t.size[1].split(" ").map((function(e){return parseInt(e,10)}))),null!==t.count)t.count=t.count[1].split(" ").map((function(e){return parseInt(e,10)}));else{t.count=[];for(let e=0,n=t.fields.length;e<n;e++)t.count.push(1)}t.offset={};let o=0;for(let e=0,n=t.fields.length;e<n;e++)"ascii"===t.data?t.offset[t.fields[e]]=e:(t.offset[t.fields[e]]=o,o+=t.size[e]*t.count[e]);return t.rowSize=o,t}(t),r=[],o=[],i=[],a=[],c=[];if("ascii"===n.data){const e=n.offset,s=t.slice(n.headerLen).split("\n");for(let t=0,l=s.length;t<l;t++){if(""===s[t])continue;const l=s[t].split(" ");if(void 0!==e.x&&(r.push(parseFloat(l[e.x])),r.push(parseFloat(l[e.y])),r.push(parseFloat(l[e.z]))),void 0!==e.rgb){const t=n.fields.findIndex((e=>"rgb"===e)),r=n.type[t],o=parseFloat(l[e.rgb]);let a=o;if("F"===r){const e=new Float32Array(1);e[0]=o,a=new Int32Array(e.buffer)[0]}const s=a>>16&255,c=a>>8&255,u=a>>0&255;i.push(s/255,c/255,u/255)}void 0!==e.normal_x&&(o.push(parseFloat(l[e.normal_x])),o.push(parseFloat(l[e.normal_y])),o.push(parseFloat(l[e.normal_z]))),void 0!==e.intensity&&a.push(parseFloat(l[e.intensity])),void 0!==e.label&&c.push(parseInt(l[e.label]))}}if("binary_compressed"===n.data){const t=new Uint32Array(e.slice(n.headerLen,n.headerLen+8)),s=t[0],l=t[1],u=function(e,t){const n=e.length,r=new Uint8Array(t);let o,i,a,s=0,c=0;do{if(o=e[s++],o<32){if(o++,c+o>t)throw new Error("Output buffer is not large enough");if(s+o>n)throw new Error("Invalid compressed data");do{r[c++]=e[s++]}while(--o)}else{if(i=o>>5,a=c-((31&o)<<8)-1,s>=n)throw new Error("Invalid compressed data");if(7===i&&(i+=e[s++],s>=n))throw new Error("Invalid compressed data");if(a-=e[s++],c+i+2>t)throw new Error("Output buffer is not large enough");if(a<0)throw new Error("Invalid compressed data");if(a>=c)throw new Error("Invalid compressed data");do{r[c++]=r[a++]}while(2+--i)}}while(s<n);return r}(new Uint8Array(e,n.headerLen+8,s),l),d=new DataView(u.buffer),p=n.offset;for(let e=0;e<n.points;e++){if(void 0!==p.x){const t=n.fields.indexOf("x"),o=n.fields.indexOf("y"),i=n.fields.indexOf("z");r.push(d.getFloat32(n.points*p.x+n.size[t]*e,this.littleEndian)),r.push(d.getFloat32(n.points*p.y+n.size[o]*e,this.littleEndian)),r.push(d.getFloat32(n.points*p.z+n.size[i]*e,this.littleEndian))}if(void 0!==p.rgb){const t=n.fields.indexOf("rgb");i.push(d.getUint8(n.points*p.rgb+n.size[t]*e+2)/255),i.push(d.getUint8(n.points*p.rgb+n.size[t]*e+1)/255),i.push(d.getUint8(n.points*p.rgb+n.size[t]*e+0)/255)}if(void 0!==p.normal_x){const t=n.fields.indexOf("normal_x"),r=n.fields.indexOf("normal_y"),i=n.fields.indexOf("normal_z");o.push(d.getFloat32(n.points*p.normal_x+n.size[t]*e,this.littleEndian)),o.push(d.getFloat32(n.points*p.normal_y+n.size[r]*e,this.littleEndian)),o.push(d.getFloat32(n.points*p.normal_z+n.size[i]*e,this.littleEndian))}if(void 0!==p.intensity){const t=n.fields.indexOf("intensity");a.push(d.getFloat32(n.points*p.intensity+n.size[t]*e,this.littleEndian))}if(void 0!==p.label){const t=n.fields.indexOf("label");c.push(d.getInt32(n.points*p.label+n.size[t]*e,this.littleEndian))}}}if("binary"===n.data){const t=new DataView(e,n.headerLen),s=n.offset;for(let e=0,l=0;e<n.points;e++,l+=n.rowSize)void 0!==s.x&&(r.push(t.getFloat32(l+s.x,this.littleEndian)),r.push(t.getFloat32(l+s.y,this.littleEndian)),r.push(t.getFloat32(l+s.z,this.littleEndian))),void 0!==s.rgb&&(i.push(t.getUint8(l+s.rgb+2)/255),i.push(t.getUint8(l+s.rgb+1)/255),i.push(t.getUint8(l+s.rgb+0)/255)),void 0!==s.normal_x&&(o.push(t.getFloat32(l+s.normal_x,this.littleEndian)),o.push(t.getFloat32(l+s.normal_y,this.littleEndian)),o.push(t.getFloat32(l+s.normal_z,this.littleEndian))),void 0!==s.intensity&&a.push(t.getFloat32(l+s.intensity,this.littleEndian)),void 0!==s.label&&c.push(t.getInt32(l+s.label,this.littleEndian))}const u=new s;r.length>0&&u.setAttribute("position",new l(r,3)),o.length>0&&u.setAttribute("normal",new l(o,3)),i.length>0&&u.setAttribute("color",new l(i,3)),a.length>0&&u.setAttribute("intensity",new l(a,1)),c.length>0&&u.setAttribute("label",new K(c,1)),u.computeBoundingSphere();const d=new q({size:.005});return i.length>0&&(d.vertexColors=!0),new X(u,d)}}class Xt extends e{load(e,t,r,o){const i=this,a=new n(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const t=new r,n=Dt(new Uint8Array(e.slice(16))),o=JSON.parse(Lt(n["metadata.json"])),i=new DataView(n["data.sketch"].buffer),a=i.getInt32(16,!0),s={};let l=20;for(let e=0;e<a;e++){const e=i.getInt32(l,!0),t=[i.getFloat32(l+4,!0),i.getFloat32(l+8,!0),i.getFloat32(l+12,!0),i.getFloat32(l+16,!0)],n=i.getFloat32(l+20,!0),r=i.getUint32(l+24,!0),o=i.getUint32(l+28,!0);let a=0,c=0;for(let e=0;e<4;e++){const t=1<<e;(r&t)>0&&(a+=4),(o&t)>0&&(c+=4)}l=l+28+a+4;const u=i.getInt32(l,!0),d=new Float32Array(3*u),p=new Float32Array(4*u);l+=4;for(let e=0,t=0;e<d.length;e+=3,t+=4)d[e+0]=i.getFloat32(l+0,!0),d[e+1]=i.getFloat32(l+4,!0),d[e+2]=i.getFloat32(l+8,!0),p[t+0]=i.getFloat32(l+12,!0),p[t+1]=i.getFloat32(l+16,!0),p[t+2]=i.getFloat32(l+20,!0),p[t+3]=i.getFloat32(l+24,!0),l=l+28+c;e in s==!1&&(s[e]=[]),s[e].push([d,p,n,t])}for(const e in s){const n=new $t(s[e]),r=en(o.BrushIndex[e]);t.add(new c(n,r))}return t}}class $t extends s{constructor(e){super();const t=[],n=[],r=[],o=new x,i=new x,a=new N,s=new N,c=new x,l=new x,u=new x,d=new x,f=new p;for(const p in e){const h=e[p],m=h[0],g=h[1],y=h[2],v=h[3],E=h[3][3];f.fromArray(v).convertSRGBToLinear(),i.fromArray(m,0),s.fromArray(g,0);for(let e=3,p=4,h=m.length;e<h;e+=3,p+=4){o.fromArray(m,e),a.fromArray(g,p),c.set(-y,0,0),c.applyQuaternion(a),c.add(o),l.set(y,0,0),l.applyQuaternion(a),l.add(o),u.set(y,0,0),u.applyQuaternion(s),u.add(i),d.set(-y,0,0),d.applyQuaternion(s),d.add(i),t.push(c.x,c.y,-c.z),t.push(l.x,l.y,-l.z),t.push(d.x,d.y,-d.z),t.push(l.x,l.y,-l.z),t.push(u.x,u.y,-u.z),t.push(d.x,d.y,-d.z),i.copy(o),s.copy(a),n.push(...f,E),n.push(...f,E),n.push(...f,E),n.push(...f,E),n.push(...f,E),n.push(...f,E);const v=e/h,T=(e-3)/h;r.push(v,0),r.push(v,1),r.push(T,0),r.push(v,1),r.push(T,1),r.push(T,0)}}this.setAttribute("position",new h(new Float32Array(t),3)),this.setAttribute("color",new h(new Float32Array(n),4)),this.setAttribute("uv",new h(new Float32Array(r),2))}}const Zt={"89d104cd-d012-426b-b5b3-bbaee63ac43c":"Bubbles","700f3aa8-9a7c-2384-8b8a-ea028905dd8c":"CelVinyl","0f0ff7b2-a677-45eb-a7d6-0cd7206f4816":"ChromaticWave","1161af82-50cf-47db-9706-0c3576d43c43":"CoarseBristles","79168f10-6961-464a-8be1-57ed364c5600":"CoarseBristlesSingleSided","1caa6d7d-f015-3f54-3a4b-8b5354d39f81":"Comet","c8313697-2563-47fc-832e-290f4c04b901":"DiamondHull","4391aaaa-df73-4396-9e33-31e4e4930b27":"Disco","d1d991f2-e7a0-4cf1-b328-f57e915e6260":"DotMarker","6a1cf9f9-032c-45ec-9b1d-a6680bee30f7":"Dots","0d3889f3-3ede-470c-8af4-f44813306126":"DoubleTaperedFlat","0d3889f3-3ede-470c-8af4-de4813306126":"DoubleTaperedMarker","d0262945-853c-4481-9cbd-88586bed93cb":"DuctTape","3ca16e2f-bdcd-4da2-8631-dcef342f40f1":"DuctTapeSingleSided","f6e85de3-6dcc-4e7f-87fd-cee8c3d25d51":"Electricity","02ffb866-7fb2-4d15-b761-1012cefb1360":"Embers","cb92b597-94ca-4255-b017-0e3f42f12f9e":"Fire","2d35bcf0-e4d8-452c-97b1-3311be063130":"Flat","55303bc4-c749-4a72-98d9-d23e68e76e18":"FlatDeprecated","280c0a7a-aad8-416c-a7d2-df63d129ca70":"FlatSingleSided","cf019139-d41c-4eb0-a1d0-5cf54b0a42f3":"Highlighter","6a1cf9f9-032c-45ec-9b6e-a6680bee32e9":"HyperGrid","dce872c2-7b49-4684-b59b-c45387949c5c":"Hypercolor","e8ef32b1-baa8-460a-9c2c-9cf8506794f5":"HypercolorSingleSided","2f212815-f4d3-c1a4-681a-feeaf9c6dc37":"Icing","f5c336cf-5108-4b40-ade9-c687504385ab":"Ink","c0012095-3ffd-4040-8ee1-fc180d346eaa":"InkSingleSided","4a76a27a-44d8-4bfe-9a8c-713749a499b0":"Leaves","ea19de07-d0c0-4484-9198-18489a3c1487":"LeavesSingleSided","2241cd32-8ba2-48a5-9ee7-2caef7e9ed62":"Light","4391aaaa-df81-4396-9e33-31e4e4930b27":"LightWire","d381e0f5-3def-4a0d-8853-31e9200bcbda":"Lofted","429ed64a-4e97-4466-84d3-145a861ef684":"Marker","79348357-432d-4746-8e29-0e25c112e3aa":"MatteHull","b2ffef01-eaaa-4ab5-aa64-95a2c4f5dbc6":"NeonPulse","f72ec0e7-a844-4e38-82e3-140c44772699":"OilPaint","c515dad7-4393-4681-81ad-162ef052241b":"OilPaintSingleSided","f1114e2e-eb8d-4fde-915a-6e653b54e9f5":"Paper","759f1ebd-20cd-4720-8d41-234e0da63716":"PaperSingleSided","e0abbc80-0f80-e854-4970-8924a0863dcc":"Petal","c33714d1-b2f9-412e-bd50-1884c9d46336":"Plasma","ad1ad437-76e2-450d-a23a-e17f8310b960":"Rainbow","faaa4d44-fcfb-4177-96be-753ac0421ba3":"ShinyHull","70d79cca-b159-4f35-990c-f02193947fe8":"Smoke","d902ed8b-d0d1-476c-a8de-878a79e3a34c":"Snow","accb32f5-4509-454f-93f8-1df3fd31df1b":"SoftHighlighter","cf7f0059-7aeb-53a4-2b67-c83d863a9ffa":"Spikes","8dc4a70c-d558-4efd-a5ed-d4e860f40dc3":"Splatter","7a1c8107-50c5-4b70-9a39-421576d6617e":"SplatterSingleSided","0eb4db27-3f82-408d-b5a1-19ebd7d5b711":"Stars","44bb800a-fbc3-4592-8426-94ecb05ddec3":"Streamers","0077f88c-d93a-42f3-b59b-b31c50cdb414":"Taffy","b468c1fb-f254-41ed-8ec9-57030bc5660c":"TaperedFlat","c8ccb53d-ae13-45ef-8afb-b730d81394eb":"TaperedFlatSingleSided","d90c6ad8-af0f-4b54-b422-e0f92abe1b3c":"TaperedMarker","1a26b8c0-8a07-4f8a-9fac-d2ef36e0cad0":"TaperedMarker_Flat","75b32cf0-fdd6-4d89-a64b-e2a00b247b0f":"ThickPaint","fdf0326a-c0d1-4fed-b101-9db0ff6d071f":"ThickPaintSingleSided","4391385a-df73-4396-9e33-31e4e4930b27":"Toon","a8fea537-da7c-4d4b-817f-24f074725d6d":"UnlitHull","d229d335-c334-495a-a801-660ac8a87360":"VelvetInk","10201aa3-ebc2-42d8-84b7-2e63f6eeb8ab":"Waveform","b67c0e81-ce6d-40a8-aeb0-ef036b081aa3":"WetPaint","dea67637-cd1a-27e4-c9b1-52f4bbcb84e5":"WetPaintSingleSided","5347acf0-a8e2-47b6-8346-30c70719d763":"WigglyGraphite","e814fef1-97fd-7194-4a2f-50c2bb918be2":"WigglyGraphiteSingleSided","4391385a-cf83-4396-9e33-31e4e4930b27":"Wire"},Jt={colors:{BloomColor:"\n\t\t\tvec3 BloomColor(vec3 color, float gain) {\n\t\t\t\t// Guarantee that there's at least a little bit of all 3 channels.\n\t\t\t\t// This makes fully-saturated strokes (which only have 2 non-zero\n\t\t\t\t// color channels) eventually clip to white rather than to a secondary.\n\t\t\t\tfloat cmin = length(color.rgb) * .05;\n\t\t\t\tcolor.rgb = max(color.rgb, vec3(cmin, cmin, cmin));\n\t\t\t\t// If we try to remove this pow() from .a, it brightens up\n\t\t\t\t// pressure-sensitive strokes; looks better as-is.\n\t\t\t\tcolor = pow(color, vec3(2.2));\n\t\t\t\tcolor.rgb *= 2. * exp(gain * 10.);\n\t\t\t\treturn color;\n\t\t\t}\n\t\t",LinearToSrgb:"\n\t\t\tvec3 LinearToSrgb(vec3 color) {\n\t\t\t\t// Approximation http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html\n\t\t\t\tvec3 linearColor = color.rgb;\n\t\t\t\tvec3 S1 = sqrt(linearColor);\n\t\t\t\tvec3 S2 = sqrt(S1);\n\t\t\t\tvec3 S3 = sqrt(S2);\n\t\t\t\tcolor.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * linearColor;\n\t\t\t\treturn color;\n\t\t\t}\n\t\t",hsv:"\n\t\t\t// uniform sampler2D lookupTex;\n\t\t\tvec4 lookup(vec4 textureColor) {\n\t\t\t\treturn textureColor;\n\t\t\t}\n\n\t\t\tvec3 lookup(vec3 textureColor) {\n\t\t\t\treturn textureColor;\n\t\t\t}\n\n\t\t\tvec3 hsv2rgb( vec3 hsv ) {\n\t\t\t\tvec3 rgb = clamp( abs(mod(hsv.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );\n\t\t\t\treturn hsv.z * mix( vec3(1.0), rgb, hsv.y);\n\t\t\t}\n\n\t\t\tvec3 rgb2hsv( vec3 rgb ) {\n\t\t\t\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\t\t\t\tvec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n\t\t\t\tvec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n\t\t\t\tfloat d = q.x - min(q.w, q.y);\n\t\t\t\tfloat e = 1.0e-10;\n\n\t\t\t\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n\t\t\t}\n\t\t",SrgbToLinear:"\n\t\t\tvec3 SrgbToLinear(vec3 color) {\n\t\t\t\t// Approximation http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html\n\t\t\t\tvec3 sRGB = color.rgb;\n\t\t\t\tcolor.rgb = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);\n\t\t\t\treturn color;\n\t\t\t}\n\t\t"}};let Qt=null;function en(e){return"Light"===Zt[e]?new $(function(){if(null===Qt){const e=(new d).setPath("./textures/tiltbrush/");Qt={Light:{uniforms:{mainTex:{value:e.load("Light.webp")},alphaTest:{value:.067},emission_gain:{value:.45},alpha:{value:1}},vertexShader:`\n\t\t\t\t\tprecision highp float;\n\t\t\t\t\tprecision highp int;\n\n\t\t\t\t\tattribute vec2 uv;\n\t\t\t\t\tattribute vec4 color;\n\t\t\t\t\tattribute vec3 position;\n\n\t\t\t\t\tuniform mat4 modelMatrix;\n\t\t\t\t\tuniform mat4 modelViewMatrix;\n\t\t\t\t\tuniform mat4 projectionMatrix;\n\t\t\t\t\tuniform mat4 viewMatrix;\n\t\t\t\t\tuniform mat3 normalMatrix;\n\t\t\t\t\tuniform vec3 cameraPosition;\n\n\t\t\t\t\tvarying vec2 vUv;\n\t\t\t\t\tvarying vec3 vColor;\n\n\t\t\t\t\t${Jt.colors.LinearToSrgb}\n\t\t\t\t\t${Jt.colors.hsv}\n\n\t\t\t\t\tvoid main() {\n\n\t\t\t\t\t\tvUv = uv;\n\n\t\t\t\t\t\tvColor = lookup(color.rgb);\n\n\t\t\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t\t}\n\t\t\t\t`,fragmentShader:`\n\t\t\t\t\tprecision highp float;\n\t\t\t\t\tprecision highp int;\n\n\t\t\t\t\tuniform float emission_gain;\n\n\t\t\t\t\tuniform sampler2D mainTex;\n\t\t\t\t\tuniform float alphaTest;\n\n\t\t\t\t\tvarying vec2 vUv;\n\t\t\t\t\tvarying vec3 vColor;\n\n\t\t\t\t\t${Jt.colors.BloomColor}\n\t\t\t\t\t${Jt.colors.SrgbToLinear}\n\n\t\t\t\t\tvoid main(){\n\t\t\t\t\t\tvec4 col = texture2D(mainTex, vUv);\n\t\t\t\t\t\tvec3 color = vColor;\n\t\t\t\t\t\tcolor = BloomColor(color, emission_gain);\n\t\t\t\t\t\tcolor = color * col.rgb;\n\t\t\t\t\t\tcolor = color * col.a;\n\t\t\t\t\t\tcolor = SrgbToLinear(color);\n\t\t\t\t\t\tgl_FragColor = vec4(color, 1.0);\n\t\t\t\t\t}\n\t\t\t\t`,side:2,transparent:!0,depthFunc:2,depthWrite:!0,depthTest:!1,blending:5,blendDst:201,blendDstAlpha:201,blendEquation:100,blendEquationAlpha:100,blendSrc:201,blendSrcAlpha:201}}}return Qt}().Light):new R({vertexColors:!0,side:i})}
|
|
16
|
-
/*! chevrotain - v9.0.1 */var tn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),nn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION="9.0.1"})),rn=tn(((e,t)=>{var n=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};function r(e){return e&&0===e.length}function o(e){return null==e?[]:Object.keys(e)}function i(e){for(var t=[],n=Object.keys(e),r=0;r<n.length;r++)t.push(e[n[r]]);return t}function a(e,t){if(Array.isArray(e))for(var n=0;n<e.length;n++)t.call(null,e[n],n);else{if(!m(e))throw Error("non exhaustive match");var r=o(e);for(n=0;n<r.length;n++){var i=r[n],a=e[i];t.call(null,a,i)}}}function s(e,t){var n=[];if(Array.isArray(e))for(var r=0;r<e.length;r++){var o=e[r];t.call(null,o)&&n.push(o)}return n}function c(e,t){return s(e,(function(e){return!t(e)}))}function l(e,t){return!!m(e)&&e.hasOwnProperty(t)}function u(e,t){return void 0!==f(e,(function(e){return e===t}))}function d(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n]);return t}function p(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}function f(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(t.call(null,r))return r}}function h(e,t,n){for(var r=Array.isArray(e),a=r?e:i(e),s=r?[]:o(e),c=n,l=0;l<a.length;l++)c=t.call(null,c,a[l],r?l:s[l]);return c}function m(e){return e instanceof Object}function g(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++)for(var i=t[r],a=o(i),s=0;s<a.length;s++){var c=a[s];l(e,c)||(e[c]=i[c])}return e}Object.defineProperty(e,"__esModule",{value:!0}),e.toFastProperties=e.timer=e.peek=e.isES2015MapSupported=e.PRINT_WARNING=e.PRINT_ERROR=e.packArray=e.IDENTITY=e.NOOP=e.merge=e.groupBy=e.defaults=e.assignNoOverwrite=e.assign=e.zipObject=e.sortBy=e.indexOf=e.some=e.difference=e.every=e.isObject=e.isRegExp=e.isArray=e.partial=e.uniq=e.compact=e.reduce=e.findAll=e.find=e.cloneObj=e.cloneArr=e.contains=e.has=e.pick=e.reject=e.filter=e.dropRight=e.drop=e.isFunction=e.isUndefined=e.isString=e.forEach=e.last=e.first=e.flatten=e.map=e.mapValues=e.values=e.keys=e.isEmpty=void 0,e.isEmpty=r,e.keys=o,e.values=i,e.mapValues=function(e,t){for(var n=[],r=o(e),i=0;i<r.length;i++){var a=r[i];n.push(t.call(null,e[a],a))}return n},e.map=function(e,t){for(var n=[],r=0;r<e.length;r++)n.push(t.call(null,e[r],r));return n},e.flatten=function e(t){for(var n=[],r=0;r<t.length;r++){var o=t[r];Array.isArray(o)?n=n.concat(e(o)):n.push(o)}return n},e.first=function(e){return r(e)?void 0:e[0]},e.last=function(e){var t=e&&e.length;return t?e[t-1]:void 0},e.forEach=a,e.isString=function(e){return"string"==typeof e},e.isUndefined=function(e){return void 0===e},e.isFunction=function(e){return e instanceof Function},e.drop=function(e,t){return void 0===t&&(t=1),e.slice(t,e.length)},e.dropRight=function(e,t){return void 0===t&&(t=1),e.slice(0,e.length-t)},e.filter=s,e.reject=c,e.pick=function(e,t){for(var n=Object.keys(e),r={},o=0;o<n.length;o++){var i=n[o],a=e[i];t(a)&&(r[i]=a)}return r},e.has=l,e.contains=u,e.cloneArr=d,e.cloneObj=p,e.find=f,e.findAll=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r];t.call(null,o)&&n.push(o)}return n},e.reduce=h,e.compact=function(e){return c(e,(function(e){return null==e}))},e.uniq=function(e,t){void 0===t&&(t=function(e){return e});var n=[];return h(e,(function(e,r){var o=t(r);return u(n,o)?e:(n.push(o),e.concat(r))}),[])},e.partial=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=[null].concat(t);return Function.bind.apply(e,r)},e.isArray=function(e){return Array.isArray(e)},e.isRegExp=function(e){return e instanceof RegExp},e.isObject=m,e.every=function(e,t){for(var n=0;n<e.length;n++)if(!t(e[n],n))return!1;return!0},e.difference=function(e,t){return c(e,(function(e){return u(t,e)}))},e.some=function(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return!0;return!1},e.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},e.sortBy=function(e,t){var n=d(e);return n.sort((function(e,n){return t(e)-t(n)})),n},e.zipObject=function(e,t){if(e.length!==t.length)throw Error("can't zipObject with different number of keys and values!");for(var n={},r=0;r<e.length;r++)n[e[r]]=t[r];return n},e.assign=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++)for(var i=t[r],a=o(i),s=0;s<a.length;s++){var c=a[s];e[c]=i[c]}return e},e.assignNoOverwrite=g,e.defaults=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g.apply(void 0,n([{}],e))},e.groupBy=function(e,t){var n={};return a(e,(function(e){var r=t(e),o=n[r];o?o.push(e):n[r]=[e]})),n},e.merge=function(e,t){for(var n=p(e),r=o(t),i=0;i<r.length;i++){var a=r[i],s=t[a];n[a]=s}return n},e.NOOP=function(){},e.IDENTITY=function(e){return e},e.packArray=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(void 0!==r?r:void 0)}return t},e.PRINT_ERROR=function(e){console&&console.error&&console.error("Error: "+e)},e.PRINT_WARNING=function(e){console&&console.warn&&console.warn("Warning: "+e)},e.isES2015MapSupported=function(){return"function"==typeof Map},e.peek=function(e){return e[e.length-1]},e.timer=function(e){var t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}},e.toFastProperties=function(e){function t(){}t.prototype=e;var n=new t;function r(){return typeof n.bar}return r(),r(),e}})),on=tn(((e,t)=>{var n,r;n="undefined"!=typeof self?self:e,r=function(){function e(){}e.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},e.prototype.restoreState=function(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx},e.prototype.pattern=function(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");var t=this.disjunction();this.consumeChar("/");for(var n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":a(n,"global");break;case"i":a(n,"ignoreCase");break;case"m":a(n,"multiLine");break;case"u":a(n,"unicode");break;case"y":a(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:t,loc:this.loc(0)}},e.prototype.disjunction=function(){var e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}},e.prototype.alternative=function(){for(var e=[],t=this.idx;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}},e.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},e.prototype.assertion=function(){var e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":var t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead"}s(t);var n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}!function(){throw Error("Internal Error - Should never get here!")}()},e.prototype.quantifier=function(e){var t,n=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":var r=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:r,atMost:r};break;case",":t=this.isDigit()?{atLeast:r,atMost:this.integerIncludingZero()}:{atLeast:r,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;s(t)}if(!0!==e||void 0!==t)return s(t),"?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t},e.prototype.atom=function(){var e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),s(e),e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e},e.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o("\n"),o("\r"),o("\u2028"),o("\u2029")]}},e.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},e.prototype.decimalEscapeAtom=function(){return{type:"GroupBackReference",value:this.positiveInteger()}},e.prototype.characterClassEscape=function(){var e,t=!1;switch(this.popChar()){case"d":e=l;break;case"D":e=l,t=!0;break;case"s":e=d;break;case"S":e=d,t=!0;break;case"w":e=u;break;case"W":e=u,t=!0}return s(e),{type:"Set",value:e,complement:t}},e.prototype.controlEscapeAtom=function(){var e;switch(this.popChar()){case"f":e=o("\f");break;case"n":e=o("\n");break;case"r":e=o("\r");break;case"t":e=o("\t");break;case"v":e=o("\v")}return s(e),{type:"Character",value:e}},e.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}},e.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},e.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},e.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},e.prototype.identityEscapeAtom=function(){return{type:"Character",value:o(this.popChar())}},e.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:o(this.popChar())}}},e.prototype.characterClass=function(){var e=[],t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){var n=this.classAtom();if("Character"===n.type&&this.isRangeDash()){this.consumeChar("-");var r=this.classAtom();if("Character"===r.type){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else i(n.value,e),e.push(o("-")),i(r.value,e)}else i(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}},e.prototype.classAtom=function(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},e.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},e.prototype.group=function(){var e=!0;"?"===(this.consumeChar("("),this.peekChar(0))?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;var t=this.disjunction();this.consumeChar(")");var n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n},e.prototype.positiveInteger=function(){var e=this.popChar();if(!1===r.test(e))throw Error("Expecting a positive integer");for(;n.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)},e.prototype.integerIncludingZero=function(){var e=this.popChar();if(!1===n.test(e))throw Error("Expecting an integer");for(;n.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)},e.prototype.patternCharacter=function(){var e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(e)}}},e.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},e.prototype.isRangeDash=function(){return"-"===this.peekChar()&&this.isClassAtom(1)},e.prototype.isDigit=function(){return n.test(this.peekChar(0))},e.prototype.isClassAtom=function(e){switch(void 0===e&&(e=0),this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},e.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},e.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},e.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2));default:return!1}},e.prototype.isQuantifier=function(){var e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}},e.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},e.prototype.parseHexDigits=function(e){for(var n="",r=0;r<e;r++){var o=this.popChar();if(!1===t.test(o))throw Error("Expecting a HexDecimal digits");n+=o}return{type:"Character",value:parseInt(n,16)}},e.prototype.peekChar=function(e){return void 0===e&&(e=0),this.input[this.idx+e]},e.prototype.popChar=function(){var e=this.peekChar(0);return this.consumeChar(),e},e.prototype.consumeChar=function(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},e.prototype.loc=function(e){return{begin:e,end:this.idx}};var t=/[0-9a-fA-F]/,n=/[0-9]/,r=/[1-9]/;function o(e){return e.charCodeAt(0)}function i(e,t){void 0!==e.length?e.forEach((function(e){t.push(e)})):t.push(e)}function a(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t]=!0}function s(e){if(void 0===e)throw Error("Internal Error - Should never get here!")}var c,l=[];for(c=o("0");c<=o("9");c++)l.push(c);var u=[o("_")].concat(l);for(c=o("a");c<=o("z");c++)u.push(c);for(c=o("A");c<=o("Z");c++)u.push(c);var d=[o(" "),o("\f"),o("\n"),o("\r"),o("\t"),o("\v"),o("\t"),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o("\u2028"),o("\u2029"),o(" "),o(" "),o(" "),o("\ufeff")];function p(){}return p.prototype.visitChildren=function(e){for(var t in e){var n=e[t];e.hasOwnProperty(t)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((function(e){this.visit(e)}),this))}},p.prototype.visit=function(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)},p.prototype.visitPattern=function(e){},p.prototype.visitFlags=function(e){},p.prototype.visitDisjunction=function(e){},p.prototype.visitAlternative=function(e){},p.prototype.visitStartAnchor=function(e){},p.prototype.visitEndAnchor=function(e){},p.prototype.visitWordBoundary=function(e){},p.prototype.visitNonWordBoundary=function(e){},p.prototype.visitLookahead=function(e){},p.prototype.visitNegativeLookahead=function(e){},p.prototype.visitCharacter=function(e){},p.prototype.visitSet=function(e){},p.prototype.visitGroup=function(e){},p.prototype.visitGroupBackReference=function(e){},p.prototype.visitQuantifier=function(e){},{RegExpParser:e,BaseRegExpVisitor:p,VERSION:"0.5.0"}},"function"==typeof define&&define.amd?define([],r):"object"==typeof t&&t.exports?t.exports=r():n.regexpToAst=r()})),an=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.clearRegExpParserCache=e.getRegExpAst=void 0;var t=on(),n={},r=new t.RegExpParser;e.getRegExpAst=function(e){var t=e.toString();if(n.hasOwnProperty(t))return n[t];var o=r.pattern(t);return n[t]=o,o},e.clearRegExpParserCache=function(){n={}}})),sn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.canMatchCharCode=e.firstCharOptimizedIndices=e.getOptimizedStartCodesIndices=e.failedOptimizationPrefixMsg=void 0;var r=on(),o=rn(),i=an(),a=cn(),s="Complement Sets are not supported for first char optimization";function c(e,t,n){switch(e.type){case"Disjunction":for(var r=0;r<e.value.length;r++)c(e.value[r],t,n);break;case"Alternative":var i=e.value;for(r=0;r<i.length;r++){var u=i[r];switch(u.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var p=u;switch(p.type){case"Character":l(p.value,t,n);break;case"Set":if(!0===p.complement)throw Error(s);o.forEach(p.value,(function(e){if("number"==typeof e)l(e,t,n);else{var r=e;if(!0===n)for(var o=r.from;o<=r.to;o++)l(o,t,n);else{for(o=r.from;o<=r.to&&o<a.minOptimizationVal;o++)l(o,t,n);if(r.to>=a.minOptimizationVal)for(var i=r.from>=a.minOptimizationVal?r.from:a.minOptimizationVal,s=r.to,c=a.charCodeToOptimizedIndex(i),u=a.charCodeToOptimizedIndex(s),d=c;d<=u;d++)t[d]=d}}}));break;case"Group":c(p.value,t,n);break;default:throw Error("Non Exhaustive Match")}var f=void 0!==p.quantifier&&0===p.quantifier.atLeast;if("Group"===p.type&&!1===d(p)||"Group"!==p.type&&!1===f)break}break;default:throw Error("non exhaustive match!")}return o.values(t)}function l(e,t,n){var r=a.charCodeToOptimizedIndex(e);t[r]=r,!0===n&&function(e,t){var n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){t[o=a.charCodeToOptimizedIndex(r.charCodeAt(0))]=o}else{var o,i=n.toLowerCase();if(i!==n)t[o=a.charCodeToOptimizedIndex(i.charCodeAt(0))]=o}}(e,t)}function u(e,t){return o.find(e.value,(function(e){if("number"==typeof e)return o.contains(t,e);var n=e;return void 0!==o.find(t,(function(e){return n.from<=e&&e<=n.to}))}))}function d(e){return!(!e.quantifier||0!==e.quantifier.atLeast)||!!e.value&&(o.isArray(e.value)?o.every(e.value,d):d(e.value))}e.failedOptimizationPrefixMsg='Unable to use "first char" lexer optimizations:\n',e.getOptimizedStartCodesIndices=function(t,n){void 0===n&&(n=!1);try{var a=i.getRegExpAst(t);return c(a.value,{},a.flags.ignoreCase)}catch(i){if(i.message===s)n&&o.PRINT_WARNING(e.failedOptimizationPrefixMsg+"\tUnable to optimize: < "+t.toString()+" >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.");else{var l="";n&&(l="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),o.PRINT_ERROR(e.failedOptimizationPrefixMsg+"\n\tFailed parsing: < "+t.toString()+" >\n\tUsing the regexp-to-ast library version: "+r.VERSION+"\n\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues"+l)}}return[]},e.firstCharOptimizedIndices=c;var p=function(e){function t(t){var n=e.call(this)||this;return n.targetCharCodes=t,n.found=!1,n}return n(t,e),t.prototype.visitChildren=function(t){if(!0!==this.found){switch(t.type){case"Lookahead":return void this.visitLookahead(t);case"NegativeLookahead":return void this.visitNegativeLookahead(t)}e.prototype.visitChildren.call(this,t)}},t.prototype.visitCharacter=function(e){o.contains(this.targetCharCodes,e.value)&&(this.found=!0)},t.prototype.visitSet=function(e){e.complement?void 0===u(e,this.targetCharCodes)&&(this.found=!0):void 0!==u(e,this.targetCharCodes)&&(this.found=!0)},t}(r.BaseRegExpVisitor);e.canMatchCharCode=function(e,t){if(t instanceof RegExp){var n=i.getRegExpAst(t),r=new p(e);return r.visit(n),r.found}return void 0!==o.find(t,(function(t){return o.contains(e,t.charCodeAt(0))}))}})),cn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.charCodeToOptimizedIndex=e.minOptimizationVal=e.buildLineBreakIssueMessage=e.LineTerminatorOptimizedTester=e.isShortPattern=e.isCustomPattern=e.cloneEmptyGroups=e.performWarningRuntimeChecks=e.performRuntimeChecks=e.addStickyFlag=e.addStartOfInput=e.findUnreachablePatterns=e.findModesThatDoNotExist=e.findInvalidGroupType=e.findDuplicatePatterns=e.findUnsupportedFlags=e.findStartOfInputAnchor=e.findEmptyMatchRegExps=e.findEndOfInputAnchor=e.findInvalidPatterns=e.findMissingPatterns=e.validatePatterns=e.analyzeTokenTypes=e.enableSticky=e.disableSticky=e.SUPPORT_STICKY=e.MODES=e.DEFAULT_MODE=void 0;var r=on(),o=dn(),i=rn(),a=sn(),s=an(),c="PATTERN";function l(e){var t=i.filter(e,(function(e){return!i.has(e,c)})),n=i.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:o.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[e]}}));return{errors:n,valid:i.difference(e,t)}}function u(e){var t=i.filter(e,(function(e){var t=e[c];return!(i.isRegExp(t)||i.isFunction(t)||i.has(t,"exec")||i.isString(t))})),n=i.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:o.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[e]}}));return{errors:n,valid:i.difference(e,t)}}e.DEFAULT_MODE="defaultMode",e.MODES="modes",e.SUPPORT_STICKY="boolean"==typeof new RegExp("(?:)").sticky,e.disableSticky=function(){e.SUPPORT_STICKY=!1},e.enableSticky=function(){e.SUPPORT_STICKY=!0},e.analyzeTokenTypes=function(t,n){var r,s=(n=i.defaults(n,{useSticky:e.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(e,t){return t()}})).tracer;s("initCharCodeToOptimizedIndexMap",(function(){!function(){if(i.isEmpty(_)){_=new Array(65536);for(var e=0;e<65536;e++)_[e]=e>255?255+~~(e/255):e}}()})),s("Reject Lexer.NA",(function(){r=i.reject(t,(function(e){return e[c]===o.Lexer.NA}))}));var l,u,d,p,f,h,m,g,y,v,E,T=!1;s("Transform Patterns",(function(){T=!1,l=i.map(r,(function(e){var t=e[c];if(i.isRegExp(t)){var r=t.source;return 1!==r.length||"^"===r||"$"===r||"."===r||t.ignoreCase?2!==r.length||"\\"!==r[0]||i.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?n.useSticky?A(t):b(t):r[1]:r}if(i.isFunction(t))return T=!0,{exec:t};if(i.has(t,"exec"))return T=!0,t;if("string"==typeof t){if(1===t.length)return t;var o=t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),a=new RegExp(o);return n.useSticky?A(a):b(a)}throw Error("non exhaustive match")}))})),s("misc mapping",(function(){u=i.map(r,(function(e){return e.tokenTypeIdx})),d=i.map(r,(function(e){var t=e.GROUP;if(t!==o.Lexer.SKIPPED){if(i.isString(t))return t;if(i.isUndefined(t))return!1;throw Error("non exhaustive match")}})),p=i.map(r,(function(e){var t=e.LONGER_ALT;if(t)return i.indexOf(r,t)})),f=i.map(r,(function(e){return e.PUSH_MODE})),h=i.map(r,(function(e){return i.has(e,"POP_MODE")}))})),s("Line Terminator Handling",(function(){var e=O(n.lineTerminatorCharacters);m=i.map(r,(function(e){return!1})),"onlyOffset"!==n.positionTracking&&(m=i.map(r,(function(t){return i.has(t,"LINE_BREAKS")?t.LINE_BREAKS:!1===R(t,e)?a.canMatchCharCode(e,t.PATTERN):void 0})))})),s("Misc Mapping #2",(function(){g=i.map(r,x),y=i.map(l,N),v=i.reduce(r,(function(e,t){var n=t.GROUP;return i.isString(n)&&n!==o.Lexer.SKIPPED&&(e[n]=[]),e}),{}),E=i.map(l,(function(e,t){return{pattern:l[t],longerAlt:p[t],canLineTerminator:m[t],isCustom:g[t],short:y[t],group:d[t],push:f[t],pop:h[t],tokenTypeIdx:u[t],tokenType:r[t]}}))}));var k=!0,S=[];return n.safeMode||s("First Char Optimization",(function(){S=i.reduce(r,(function(e,t,r){if("string"==typeof t.PATTERN){var o=w(t.PATTERN.charCodeAt(0));I(e,o,E[r])}else if(i.isArray(t.START_CHARS_HINT)){var s;i.forEach(t.START_CHARS_HINT,(function(t){var n=w("string"==typeof t?t.charCodeAt(0):t);s!==n&&(s=n,I(e,n,E[r]))}))}else if(i.isRegExp(t.PATTERN))if(t.PATTERN.unicode)k=!1,n.ensureOptimizations&&i.PRINT_ERROR(a.failedOptimizationPrefixMsg+"\tUnable to analyze < "+t.PATTERN.toString()+" > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");else{var c=a.getOptimizedStartCodesIndices(t.PATTERN,n.ensureOptimizations);i.isEmpty(c)&&(k=!1),i.forEach(c,(function(t){I(e,t,E[r])}))}else n.ensureOptimizations&&i.PRINT_ERROR(a.failedOptimizationPrefixMsg+"\tTokenType: <"+t.name+"> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"),k=!1;return e}),[])})),s("ArrayPacking",(function(){S=i.packArray(S)})),{emptyGroups:v,patternIdxToConfig:E,charCodeToPatternIdxToConfig:S,hasCustom:T,canBeOptimized:k}},e.validatePatterns=function(e,t){var n=[],r=l(e);n=n.concat(r.errors);var o=u(r.valid),a=o.valid;return n=(n=n.concat(o.errors)).concat(function(e){var t=[],n=i.filter(e,(function(e){return i.isRegExp(e[c])}));return t=t.concat(p(n)),t=t.concat(m(n)),t=t.concat(g(n)),t=t.concat(y(n)),t=t.concat(f(n)),t}(a)),n=(n=(n=n.concat(v(a))).concat(E(a,t))).concat(T(a))},e.findMissingPatterns=l,e.findInvalidPatterns=u;var d=/[^\\][\$]/;function p(e){var t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.found=!1,t}return n(t,e),t.prototype.visitEndAnchor=function(e){this.found=!0},t}(r.BaseRegExpVisitor),a=i.filter(e,(function(e){var n=e[c];try{var r=s.getRegExpAst(n),o=new t;return o.visit(r),o.found}catch(e){return d.test(n.source)}})),l=i.map(a,(function(e){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:o.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[e]}}));return l}function f(e){var t=i.filter(e,(function(e){return e[c].test("")}));return i.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:o.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[e]}}))}e.findEndOfInputAnchor=p,e.findEmptyMatchRegExps=f;var h=/[^\\[][\^]|^\^/;function m(e){var t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.found=!1,t}return n(t,e),t.prototype.visitStartAnchor=function(e){this.found=!0},t}(r.BaseRegExpVisitor),a=i.filter(e,(function(e){var n=e[c];try{var r=s.getRegExpAst(n),o=new t;return o.visit(r),o.found}catch(e){return h.test(n.source)}})),l=i.map(a,(function(e){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:o.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[e]}}));return l}function g(e){var t=i.filter(e,(function(e){var t=e[c];return t instanceof RegExp&&(t.multiline||t.global)}));return i.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:o.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}}))}function y(e){var t=[],n=i.map(e,(function(n){return i.reduce(e,(function(e,r){return n.PATTERN.source===r.PATTERN.source&&!i.contains(t,r)&&r.PATTERN!==o.Lexer.NA&&(t.push(r),e.push(r)),e}),[])}));n=i.compact(n);var r=i.filter(n,(function(e){return e.length>1}));return i.map(r,(function(e){var t=i.map(e,(function(e){return e.name}));return{message:"The same RegExp pattern ->"+i.first(e).PATTERN+"<-has been used in all of the following Token Types: "+t.join(", ")+" <-",type:o.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}}))}function v(e){var t=i.filter(e,(function(e){if(!i.has(e,"GROUP"))return!1;var t=e.GROUP;return t!==o.Lexer.SKIPPED&&t!==o.Lexer.NA&&!i.isString(t)}));return i.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:o.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}}))}function E(e,t){var n=i.filter(e,(function(e){return void 0!==e.PUSH_MODE&&!i.contains(t,e.PUSH_MODE)})),r=i.map(n,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+e.PUSH_MODE+"<-which does not exist",type:o.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}}));return r}function T(e){var t=[],n=i.reduce(e,(function(e,t,n){var r=t.PATTERN;return r===o.Lexer.NA||(i.isString(r)?e.push({str:r,idx:n,tokenType:t}):i.isRegExp(r)&&function(e){var t=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return void 0===i.find(t,(function(t){return-1!==e.source.indexOf(t)}))}(r)&&e.push({str:r.source,idx:n,tokenType:t})),e}),[]);return i.forEach(e,(function(e,r){i.forEach(n,(function(n){var a=n.str,s=n.idx,c=n.tokenType;if(r<s&&function(e,t){if(i.isRegExp(t)){var n=t.exec(e);return null!==n&&0===n.index}if(i.isFunction(t))return t(e,0,[],{});if(i.has(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(a,e.PATTERN)){var l="Token: ->"+c.name+"<- can never be matched.\nBecause it appears AFTER the Token Type ->"+e.name+"<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE";t.push({message:l,type:o.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[e,c]})}}))})),t}function b(e){var t=e.ignoreCase?"i":"";return new RegExp("^(?:"+e.source+")",t)}function A(e){var t=e.ignoreCase?"iy":"y";return new RegExp(""+e.source,t)}function x(e){var t=e.PATTERN;if(i.isRegExp(t))return!1;if(i.isFunction(t))return!0;if(i.has(t,"exec"))return!0;if(i.isString(t))return!1;throw Error("non exhaustive match")}function N(e){return!(!i.isString(e)||1!==e.length)&&e.charCodeAt(0)}function R(e,t){if(i.has(e,"LINE_BREAKS"))return!1;if(i.isRegExp(e.PATTERN)){try{a.canMatchCharCode(t,e.PATTERN)}catch(e){return{issue:o.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(i.isString(e.PATTERN))return!1;if(x(e))return{issue:o.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function k(e,t){if(t.issue===o.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return"Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <"+e.name+"> Token Type\n\t Root cause: "+t.errMsg+".\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(t.issue===o.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return"Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <"+e.name+"> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}function O(e){return i.map(e,(function(e){return i.isString(e)&&e.length>0?e.charCodeAt(0):e}))}function I(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}e.findStartOfInputAnchor=m,e.findUnsupportedFlags=g,e.findDuplicatePatterns=y,e.findInvalidGroupType=v,e.findModesThatDoNotExist=E,e.findUnreachablePatterns=T,e.addStartOfInput=b,e.addStickyFlag=A,e.performRuntimeChecks=function(t,n,r){var a=[];return i.has(t,e.DEFAULT_MODE)||a.push({message:"A MultiMode Lexer cannot be initialized without a <"+e.DEFAULT_MODE+"> property in its definition\n",type:o.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),i.has(t,e.MODES)||a.push({message:"A MultiMode Lexer cannot be initialized without a <"+e.MODES+"> property in its definition\n",type:o.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),i.has(t,e.MODES)&&i.has(t,e.DEFAULT_MODE)&&!i.has(t.modes,t.defaultMode)&&a.push({message:"A MultiMode Lexer cannot be initialized with a "+e.DEFAULT_MODE+": <"+t.defaultMode+">which does not exist\n",type:o.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),i.has(t,e.MODES)&&i.forEach(t.modes,(function(e,t){i.forEach(e,(function(e,n){i.isUndefined(e)&&a.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:<"+t+"> at index: <"+n+">\n",type:o.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})}))})),a},e.performWarningRuntimeChecks=function(e,t,n){var r=[],s=!1,l=i.compact(i.flatten(i.mapValues(e.modes,(function(e){return e})))),u=i.reject(l,(function(e){return e[c]===o.Lexer.NA})),d=O(n);return t&&i.forEach(u,(function(e){var t=R(e,d);if(!1!==t){var n={message:k(e,t),type:t.issue,tokenType:e};r.push(n)}else i.has(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(s=!0):a.canMatchCharCode(d,e.PATTERN)&&(s=!0)})),t&&!s&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS\n\tfor details.",type:o.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),r},e.cloneEmptyGroups=function(e){var t={},n=i.keys(e);return i.forEach(n,(function(n){var r=e[n];if(!i.isArray(r))throw Error("non exhaustive match");t[n]=[]})),t},e.isCustomPattern=x,e.isShortPattern=N,e.LineTerminatorOptimizedTester={test:function(e){for(var t=e.length,n=this.lastIndex;n<t;n++){var r=e.charCodeAt(n);if(10===r)return this.lastIndex=n+1,!0;if(13===r)return 10===e.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0},e.buildLineBreakIssueMessage=k,e.minOptimizationVal=256;var _=[];function w(t){return t<e.minOptimizationVal?t:_[t]}e.charCodeToOptimizedIndex=w})),ln=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenType=e.hasExtendingTokensTypesMapProperty=e.hasExtendingTokensTypesProperty=e.hasCategoriesProperty=e.hasShortKeyProperty=e.singleAssignCategoriesToksMap=e.assignCategoriesMapProp=e.assignCategoriesTokensProp=e.assignTokenDefaultProps=e.expandCategories=e.augmentTokenTypes=e.tokenIdxToClass=e.tokenShortNameIdx=e.tokenStructuredMatcherNoCategories=e.tokenStructuredMatcher=void 0;var t=rn();function n(e){for(var n=t.cloneArr(e),r=e,o=!0;o;){r=t.compact(t.flatten(t.map(r,(function(e){return e.CATEGORIES}))));var i=t.difference(r,n);n=n.concat(i),t.isEmpty(i)?o=!1:r=i}return n}function r(n){t.forEach(n,(function(n){s(n)||(e.tokenIdxToClass[e.tokenShortNameIdx]=n,n.tokenTypeIdx=e.tokenShortNameIdx++),c(n)&&!t.isArray(n.CATEGORIES)&&(n.CATEGORIES=[n.CATEGORIES]),c(n)||(n.CATEGORIES=[]),l(n)||(n.categoryMatches=[]),u(n)||(n.categoryMatchesMap={})}))}function o(n){t.forEach(n,(function(n){n.categoryMatches=[],t.forEach(n.categoryMatchesMap,(function(t,r){n.categoryMatches.push(e.tokenIdxToClass[r].tokenTypeIdx)}))}))}function i(e){t.forEach(e,(function(e){a([],e)}))}function a(e,n){t.forEach(e,(function(e){n.categoryMatchesMap[e.tokenTypeIdx]=!0})),t.forEach(n.CATEGORIES,(function(r){var o=e.concat(n);t.contains(o,r)||a(o,r)}))}function s(e){return t.has(e,"tokenTypeIdx")}function c(e){return t.has(e,"CATEGORIES")}function l(e){return t.has(e,"categoryMatches")}function u(e){return t.has(e,"categoryMatchesMap")}e.tokenStructuredMatcher=function(e,t){var n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]},e.tokenStructuredMatcherNoCategories=function(e,t){return e.tokenTypeIdx===t.tokenTypeIdx},e.tokenShortNameIdx=1,e.tokenIdxToClass={},e.augmentTokenTypes=function(e){var a=n(e);r(a),i(a),o(a),t.forEach(a,(function(e){e.isParent=e.categoryMatches.length>0}))},e.expandCategories=n,e.assignTokenDefaultProps=r,e.assignCategoriesTokensProp=o,e.assignCategoriesMapProp=i,e.singleAssignCategoriesToksMap=a,e.hasShortKeyProperty=s,e.hasCategoriesProperty=c,e.hasExtendingTokensTypesProperty=l,e.hasExtendingTokensTypesMapProperty=u,e.isTokenType=function(e){return t.has(e,"tokenTypeIdx")}})),un=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLexerErrorProvider=void 0,e.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,r,o){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+", skipped "+n+" characters."}}})),dn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Lexer=e.LexerDefinitionErrorType=void 0;var t,n=cn(),r=rn(),o=ln(),i=un(),a=an();(t=e.LexerDefinitionErrorType||(e.LexerDefinitionErrorType={}))[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK";var s={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:i.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(s);var c=function(){function e(e,t){var i=this;if(void 0===t&&(t=s),this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=r.merge(s,t);var c=this.config.traceInitPerf;!0===c?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof c&&(this.traceInitMaxIdent=c,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(function(){var c,l=!0;i.TRACE_INIT("Lexer Config handling",(function(){if(i.config.lineTerminatorsPattern===s.lineTerminatorsPattern)i.config.lineTerminatorsPattern=n.LineTerminatorOptimizedTester;else if(i.config.lineTerminatorCharacters===s.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');i.trackStartLines=/full|onlyStart/i.test(i.config.positionTracking),i.trackEndLines=/full/i.test(i.config.positionTracking),r.isArray(e)?((c={modes:{}}).modes[n.DEFAULT_MODE]=r.cloneArr(e),c[n.DEFAULT_MODE]=n.DEFAULT_MODE):(l=!1,c=r.cloneObj(e))})),!1===i.config.skipValidations&&(i.TRACE_INIT("performRuntimeChecks",(function(){i.lexerDefinitionErrors=i.lexerDefinitionErrors.concat(n.performRuntimeChecks(c,i.trackStartLines,i.config.lineTerminatorCharacters))})),i.TRACE_INIT("performWarningRuntimeChecks",(function(){i.lexerDefinitionWarning=i.lexerDefinitionWarning.concat(n.performWarningRuntimeChecks(c,i.trackStartLines,i.config.lineTerminatorCharacters))}))),c.modes=c.modes?c.modes:{},r.forEach(c.modes,(function(e,t){c.modes[t]=r.reject(e,(function(e){return r.isUndefined(e)}))}));var u=r.keys(c.modes);if(r.forEach(c.modes,(function(e,a){i.TRACE_INIT("Mode: <"+a+"> processing",(function(){var s;(i.modes.push(a),!1===i.config.skipValidations&&i.TRACE_INIT("validatePatterns",(function(){i.lexerDefinitionErrors=i.lexerDefinitionErrors.concat(n.validatePatterns(e,u))})),r.isEmpty(i.lexerDefinitionErrors))&&(o.augmentTokenTypes(e),i.TRACE_INIT("analyzeTokenTypes",(function(){s=n.analyzeTokenTypes(e,{lineTerminatorCharacters:i.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:i.TRACE_INIT.bind(i)})})),i.patternIdxToConfig[a]=s.patternIdxToConfig,i.charCodeToPatternIdxToConfig[a]=s.charCodeToPatternIdxToConfig,i.emptyGroups=r.merge(i.emptyGroups,s.emptyGroups),i.hasCustom=s.hasCustom||i.hasCustom,i.canModeBeOptimized[a]=s.canBeOptimized)}))})),i.defaultMode=c.defaultMode,!r.isEmpty(i.lexerDefinitionErrors)&&!i.config.deferDefinitionErrorsHandling){var d=r.map(i.lexerDefinitionErrors,(function(e){return e.message})).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+d)}r.forEach(i.lexerDefinitionWarning,(function(e){r.PRINT_WARNING(e.message)})),i.TRACE_INIT("Choosing sub-methods implementations",(function(){if(n.SUPPORT_STICKY?(i.chopInput=r.IDENTITY,i.match=i.matchWithTest):(i.updateLastIndex=r.NOOP,i.match=i.matchWithExec),l&&(i.handleModes=r.NOOP),!1===i.trackStartLines&&(i.computeNewColumn=r.IDENTITY),!1===i.trackEndLines&&(i.updateTokenEndLineColumnLocation=r.NOOP),/full/i.test(i.config.positionTracking))i.createTokenInstance=i.createFullToken;else if(/onlyStart/i.test(i.config.positionTracking))i.createTokenInstance=i.createStartOnlyToken;else{if(!/onlyOffset/i.test(i.config.positionTracking))throw Error('Invalid <positionTracking> config option: "'+i.config.positionTracking+'"');i.createTokenInstance=i.createOffsetOnlyToken}i.hasCustom?(i.addToken=i.addTokenUsingPush,i.handlePayload=i.handlePayloadWithCustom):(i.addToken=i.addTokenUsingMemberAccess,i.handlePayload=i.handlePayloadNoCustom)})),i.TRACE_INIT("Failed Optimization Warnings",(function(){var e=r.reduce(i.canModeBeOptimized,(function(e,t,n){return!1===t&&e.push(n),e}),[]);if(t.ensureOptimizations&&!r.isEmpty(e))throw Error("Lexer Modes: < "+e.join(", ")+' > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.')})),i.TRACE_INIT("clearRegExpParserCache",(function(){a.clearRegExpParserCache()})),i.TRACE_INIT("toFastProperties",(function(){r.toFastProperties(i)}))}))}return e.prototype.tokenize=function(e,t){if(void 0===t&&(t=this.defaultMode),!r.isEmpty(this.lexerDefinitionErrors)){var n=r.map(this.lexerDefinitionErrors,(function(e){return e.message})).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+n)}return this.tokenizeInternal(e,t)},e.prototype.tokenizeInternal=function(e,t){var o,i,a,s,c,l,u,d,p,f,h,m,g,y,v=this,E=e,T=E.length,b=0,A=0,x=this.hasCustom?0:Math.floor(e.length/10),N=new Array(x),R=[],k=this.trackStartLines?1:void 0,O=this.trackStartLines?1:void 0,I=n.cloneEmptyGroups(this.emptyGroups),_=this.trackStartLines,w=this.config.lineTerminatorsPattern,S=0,C=[],L=[],P=[],M=[];Object.freeze(M);var F=void 0;function D(){return C}function U(e){var t=n.charCodeToOptimizedIndex(e),r=L[t];return void 0===r?M:r}var V,B=function(e){if(1===P.length&&void 0===e.tokenType.PUSH_MODE){var t=v.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);R.push({offset:e.startOffset,line:void 0!==e.startLine?e.startLine:void 0,column:void 0!==e.startColumn?e.startColumn:void 0,length:e.image.length,message:t})}else{P.pop();var n=r.last(P);C=v.patternIdxToConfig[n],L=v.charCodeToPatternIdxToConfig[n],S=C.length;var o=v.canModeBeOptimized[n]&&!1===v.config.safeMode;F=L&&o?U:D}};function j(e){P.push(e),L=this.charCodeToPatternIdxToConfig[e],C=this.patternIdxToConfig[e],S=C.length,S=C.length;var t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;F=L&&t?U:D}for(j.call(this,t);b<T;){c=null;var z=E.charCodeAt(b),G=F(z),W=G.length;for(o=0;o<W;o++){var H=(V=G[o]).pattern;if(l=null,!1!==(te=V.short)?z===te&&(c=H):!0===V.isCustom?null!==(y=H.exec(E,b,N,I))?(c=y[0],void 0!==y.payload&&(l=y.payload)):c=null:(this.updateLastIndex(H,b),c=this.match(H,e,b)),null!==c){if(void 0!==(s=V.longerAlt)){var Y=C[s],K=Y.pattern;u=null,!0===Y.isCustom?null!==(y=K.exec(E,b,N,I))?(a=y[0],void 0!==y.payload&&(u=y.payload)):a=null:(this.updateLastIndex(K,b),a=this.match(K,e,b)),a&&a.length>c.length&&(c=a,l=u,V=Y)}break}}if(null!==c){if(d=c.length,void 0!==(p=V.group)&&(f=V.tokenTypeIdx,h=this.createTokenInstance(c,b,f,V.tokenType,k,O,d),this.handlePayload(h,l),!1===p?A=this.addToken(N,A,h):I[p].push(h)),e=this.chopInput(e,d),b+=d,O=this.computeNewColumn(O,d),!0===_&&!0===V.canLineTerminator){var q=0,X=void 0,$=void 0;w.lastIndex=0;do{!0===(X=w.test(c))&&($=w.lastIndex-1,q++)}while(!0===X);0!==q&&(k+=q,O=d-$,this.updateTokenEndLineColumnLocation(h,p,$,q,k,O,d))}this.handleModes(V,B,j,h)}else{for(var Z=b,J=k,Q=O,ee=!1;!ee&&b<T;)for(E.charCodeAt(b),e=this.chopInput(e,1),b++,i=0;i<S;i++){var te,ne=C[i];H=ne.pattern;if(!1!==(te=ne.short)?E.charCodeAt(b)===te&&(ee=!0):!0===ne.isCustom?ee=null!==H.exec(E,b,N,I):(this.updateLastIndex(H,b),ee=null!==H.exec(e)),!0===ee)break}m=b-Z,g=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,Z,m,J,Q),R.push({offset:Z,line:J,column:Q,length:m,message:g})}}return this.hasCustom||(N.length=A),{tokens:N,groups:I,errors:R}},e.prototype.handleModes=function(e,t,n,r){if(!0===e.pop){var o=e.push;t(r),void 0!==o&&n.call(this,o)}else void 0!==e.push&&n.call(this,e.push)},e.prototype.chopInput=function(e,t){return e.substring(t)},e.prototype.updateLastIndex=function(e,t){e.lastIndex=t},e.prototype.updateTokenEndLineColumnLocation=function(e,t,n,r,o,i,a){var s,c;void 0!==t&&(c=(s=n===a-1)?-1:0,1===r&&!0===s||(e.endLine=o+c,e.endColumn=i-1-c))},e.prototype.computeNewColumn=function(e,t){return e+t},e.prototype.createTokenInstance=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null},e.prototype.createOffsetOnlyToken=function(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}},e.prototype.createStartOnlyToken=function(e,t,n,r,o,i){return{image:e,startOffset:t,startLine:o,startColumn:i,tokenTypeIdx:n,tokenType:r}},e.prototype.createFullToken=function(e,t,n,r,o,i,a){return{image:e,startOffset:t,endOffset:t+a-1,startLine:o,endLine:o,startColumn:i,endColumn:i+a-1,tokenTypeIdx:n,tokenType:r}},e.prototype.addToken=function(e,t,n){return 666},e.prototype.addTokenUsingPush=function(e,t,n){return e.push(n),t},e.prototype.addTokenUsingMemberAccess=function(e,t,n){return e[t]=n,++t},e.prototype.handlePayload=function(e,t){},e.prototype.handlePayloadNoCustom=function(e,t){},e.prototype.handlePayloadWithCustom=function(e,t){null!==t&&(e.payload=t)},e.prototype.match=function(e,t,n){return null},e.prototype.matchWithTest=function(e,t,n){return!0===e.test(t)?t.substring(n,e.lastIndex):null},e.prototype.matchWithExec=function(e,t){var n=e.exec(t);return null!==n?n[0]:n},e.prototype.TRACE_INIT=function(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--\x3e <"+e+">");var o=r.timer(t),i=o.time,a=o.value,s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(n+"<-- <"+e+"> time: "+i+"ms"),this.traceInitIndent--,a}return t()},e.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",e.NA=/NOT_APPLICABLE/,e}();e.Lexer=c})),pn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tokenMatcher=e.createTokenInstance=e.EOF=e.createToken=e.hasTokenLabel=e.tokenName=e.tokenLabel=void 0;var t=rn(),n=dn(),r=ln();function o(e){return t.isString(e.LABEL)&&""!==e.LABEL}e.tokenLabel=function(e){return o(e)?e.LABEL:e.name},e.tokenName=function(e){return e.name},e.hasTokenLabel=o;var i="parent",a="categories",s="label",c="group",l="push_mode",u="pop_mode",d="longer_alt",p="line_breaks",f="start_chars_hint";function h(e){return function(e){var n=e.pattern,o={};if(o.name=e.name,t.isUndefined(n)||(o.PATTERN=n),t.has(e,i))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";return t.has(e,a)&&(o.CATEGORIES=e[a]),r.augmentTokenTypes([o]),t.has(e,s)&&(o.LABEL=e[s]),t.has(e,c)&&(o.GROUP=e[c]),t.has(e,u)&&(o.POP_MODE=e[u]),t.has(e,l)&&(o.PUSH_MODE=e[l]),t.has(e,d)&&(o.LONGER_ALT=e[d]),t.has(e,p)&&(o.LINE_BREAKS=e[p]),t.has(e,f)&&(o.START_CHARS_HINT=e[f]),o}(e)}e.createToken=h,e.EOF=h({name:"EOF",pattern:n.Lexer.NA}),r.augmentTokenTypes([e.EOF]),e.createTokenInstance=function(e,t,n,r,o,i,a,s){return{image:t,startOffset:n,endOffset:r,startLine:o,endLine:i,startColumn:a,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}},e.tokenMatcher=function(e,t){return r.tokenStructuredMatcher(e,t)}})),fn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.serializeProduction=e.serializeGrammar=e.Terminal=e.Alternation=e.RepetitionWithSeparator=e.Repetition=e.RepetitionMandatoryWithSeparator=e.RepetitionMandatory=e.Option=e.Alternative=e.Rule=e.NonTerminal=e.AbstractProduction=void 0;var r=rn(),o=pn(),i=function(){function e(e){this._definition=e}return Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),e.prototype.accept=function(e){e.visit(this),r.forEach(this.definition,(function(t){t.accept(e)}))},e}();e.AbstractProduction=i;var a=function(e){function t(t){var n=e.call(this,[])||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),Object.defineProperty(t.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.accept=function(e){e.visit(this)},t}(i);e.NonTerminal=a;var s=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.orgText="",r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.Rule=s;var c=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.ignoreAmbiguities=!1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.Alternative=c;var l=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.Option=l;var u=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.RepetitionMandatory=u;var d=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.RepetitionMandatoryWithSeparator=d;var p=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.Repetition=p;var f=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(i);e.RepetitionWithSeparator=f;var h=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),Object.defineProperty(t.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),t}(i);e.Alternation=h;var m=function(){function e(e){this.idx=1,r.assign(this,r.pick(e,(function(e){return void 0!==e})))}return e.prototype.accept=function(e){e.visit(this)},e}();function g(e){function t(e){return r.map(e,g)}if(e instanceof a)return{type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(e instanceof c)return{type:"Alternative",definition:t(e.definition)};if(e instanceof l)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof u)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof d)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:g(new m({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof f)return{type:"RepetitionWithSeparator",idx:e.idx,separator:g(new m({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof p)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof h)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof m){var n={type:"Terminal",name:e.terminalType.name,label:o.tokenLabel(e.terminalType),idx:e.idx},i=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(n.pattern=r.isRegExp(i)?i.source:i),n}if(e instanceof s)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}e.Terminal=m,e.serializeGrammar=function(e){return r.map(e,g)},e.serializeProduction=g})),hn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RestWalker=void 0;var t=rn(),n=fn(),r=function(){function e(){}return e.prototype.walk=function(e,r){var o=this;void 0===r&&(r=[]),t.forEach(e.definition,(function(i,a){var s=t.drop(e.definition,a+1);if(i instanceof n.NonTerminal)o.walkProdRef(i,s,r);else if(i instanceof n.Terminal)o.walkTerminal(i,s,r);else if(i instanceof n.Alternative)o.walkFlat(i,s,r);else if(i instanceof n.Option)o.walkOption(i,s,r);else if(i instanceof n.RepetitionMandatory)o.walkAtLeastOne(i,s,r);else if(i instanceof n.RepetitionMandatoryWithSeparator)o.walkAtLeastOneSep(i,s,r);else if(i instanceof n.RepetitionWithSeparator)o.walkManySep(i,s,r);else if(i instanceof n.Repetition)o.walkMany(i,s,r);else{if(!(i instanceof n.Alternation))throw Error("non exhaustive match");o.walkOr(i,s,r)}}))},e.prototype.walkTerminal=function(e,t,n){},e.prototype.walkProdRef=function(e,t,n){},e.prototype.walkFlat=function(e,t,n){var r=t.concat(n);this.walk(e,r)},e.prototype.walkOption=function(e,t,n){var r=t.concat(n);this.walk(e,r)},e.prototype.walkAtLeastOne=function(e,t,r){var o=[new n.Option({definition:e.definition})].concat(t,r);this.walk(e,o)},e.prototype.walkAtLeastOneSep=function(e,t,n){var r=o(e,t,n);this.walk(e,r)},e.prototype.walkMany=function(e,t,r){var o=[new n.Option({definition:e.definition})].concat(t,r);this.walk(e,o)},e.prototype.walkManySep=function(e,t,n){var r=o(e,t,n);this.walk(e,r)},e.prototype.walkOr=function(e,r,o){var i=this,a=r.concat(o);t.forEach(e.definition,(function(e){var t=new n.Alternative({definition:[e]});i.walk(t,a)}))},e}();function o(e,t,r){return[new n.Option({definition:[new n.Terminal({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}e.RestWalker=r})),mn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GAstVisitor=void 0;var t=fn(),n=function(){function e(){}return e.prototype.visit=function(e){var n=e;switch(n.constructor){case t.NonTerminal:return this.visitNonTerminal(n);case t.Alternative:return this.visitAlternative(n);case t.Option:return this.visitOption(n);case t.RepetitionMandatory:return this.visitRepetitionMandatory(n);case t.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(n);case t.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(n);case t.Repetition:return this.visitRepetition(n);case t.Alternation:return this.visitAlternation(n);case t.Terminal:return this.visitTerminal(n);case t.Rule:return this.visitRule(n);default:throw Error("non exhaustive match")}},e.prototype.visitNonTerminal=function(e){},e.prototype.visitAlternative=function(e){},e.prototype.visitOption=function(e){},e.prototype.visitRepetition=function(e){},e.prototype.visitRepetitionMandatory=function(e){},e.prototype.visitRepetitionMandatoryWithSeparator=function(e){},e.prototype.visitRepetitionWithSeparator=function(e){},e.prototype.visitAlternation=function(e){},e.prototype.visitTerminal=function(e){},e.prototype.visitRule=function(e){},e}();e.GAstVisitor=n})),gn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.collectMethods=e.DslMethodsCollectorVisitor=e.getProductionDslName=e.isBranchingProd=e.isOptionalProd=e.isSequenceProd=void 0;var r=rn(),o=fn(),i=mn();e.isSequenceProd=function(e){return e instanceof o.Alternative||e instanceof o.Option||e instanceof o.Repetition||e instanceof o.RepetitionMandatory||e instanceof o.RepetitionMandatoryWithSeparator||e instanceof o.RepetitionWithSeparator||e instanceof o.Terminal||e instanceof o.Rule},e.isOptionalProd=function e(t,n){return void 0===n&&(n=[]),!!(t instanceof o.Option||t instanceof o.Repetition||t instanceof o.RepetitionWithSeparator)||(t instanceof o.Alternation?r.some(t.definition,(function(t){return e(t,n)})):!(t instanceof o.NonTerminal&&r.contains(n,t))&&(t instanceof o.AbstractProduction&&(t instanceof o.NonTerminal&&n.push(t),r.every(t.definition,(function(t){return e(t,n)})))))},e.isBranchingProd=function(e){return e instanceof o.Alternation},e.getProductionDslName=function(e){if(e instanceof o.NonTerminal)return"SUBRULE";if(e instanceof o.Option)return"OPTION";if(e instanceof o.Alternation)return"OR";if(e instanceof o.RepetitionMandatory)return"AT_LEAST_ONE";if(e instanceof o.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(e instanceof o.RepetitionWithSeparator)return"MANY_SEP";if(e instanceof o.Repetition)return"MANY";if(e instanceof o.Terminal)return"CONSUME";throw Error("non exhaustive match")};var a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.separator="-",t.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},t}return n(t,e),t.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},t.prototype.visitTerminal=function(e){var t=e.terminalType.name+this.separator+"Terminal";r.has(this.dslMethods,t)||(this.dslMethods[t]=[]),this.dslMethods[t].push(e)},t.prototype.visitNonTerminal=function(e){var t=e.nonTerminalName+this.separator+"Terminal";r.has(this.dslMethods,t)||(this.dslMethods[t]=[]),this.dslMethods[t].push(e)},t.prototype.visitOption=function(e){this.dslMethods.option.push(e)},t.prototype.visitRepetitionWithSeparator=function(e){this.dslMethods.repetitionWithSeparator.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.dslMethods.repetitionMandatory.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)},t.prototype.visitRepetition=function(e){this.dslMethods.repetition.push(e)},t.prototype.visitAlternation=function(e){this.dslMethods.alternation.push(e)},t}(i.GAstVisitor);e.DslMethodsCollectorVisitor=a;var s=new a;e.collectMethods=function(e){s.reset(),e.accept(s);var t=s.dslMethods;return s.reset(),t}})),yn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.firstForTerminal=e.firstForBranching=e.firstForSequence=e.first=void 0;var t=rn(),n=fn(),r=gn();function o(e){if(e instanceof n.NonTerminal)return o(e.referencedRule);if(e instanceof n.Terminal)return s(e);if(r.isSequenceProd(e))return i(e);if(r.isBranchingProd(e))return a(e);throw Error("non exhaustive match")}function i(e){for(var n,i=[],a=e.definition,s=0,c=a.length>s,l=!0;c&&l;)n=a[s],l=r.isOptionalProd(n),i=i.concat(o(n)),s+=1,c=a.length>s;return t.uniq(i)}function a(e){var n=t.map(e.definition,(function(e){return o(e)}));return t.uniq(t.flatten(n))}function s(e){return[e.terminalType]}e.first=o,e.firstForSequence=i,e.firstForBranching=a,e.firstForTerminal=s})),vn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IN=void 0,e.IN="_~IN~_"})),En=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.buildInProdFollowPrefix=e.buildBetweenProdsFollowPrefix=e.computeAllProdsFollows=e.ResyncFollowsWalker=void 0;var r=hn(),o=yn(),i=rn(),a=vn(),s=fn(),c=function(e){function t(t){var n=e.call(this)||this;return n.topProd=t,n.follows={},n}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},t.prototype.walkTerminal=function(e,t,n){},t.prototype.walkProdRef=function(e,t,n){var r=l(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(n),a=new s.Alternative({definition:i}),c=o.first(a);this.follows[r]=c},t}(r.RestWalker);function l(e,t){return e.name+t+a.IN}e.ResyncFollowsWalker=c,e.computeAllProdsFollows=function(e){var t={};return i.forEach(e,(function(e){var n=new c(e).startWalking();i.assign(t,n)})),t},e.buildBetweenProdsFollowPrefix=l,e.buildInProdFollowPrefix=function(e){return e.terminalType.name+e.idx+a.IN}})),Tn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultGrammarValidatorErrorProvider=e.defaultGrammarResolverErrorProvider=e.defaultParserErrorProvider=void 0;var t=pn(),n=rn(),r=rn(),o=fn(),i=gn();e.defaultParserErrorProvider={buildMismatchTokenMessage:function(e){var n=e.expected,r=e.actual;return e.previous,e.ruleName,"Expecting "+(t.hasTokenLabel(n)?"--\x3e "+t.tokenLabel(n)+" <--":"token of type --\x3e "+n.name+" <--")+" but found --\x3e '"+r.image+"' <--"},buildNotAllInputParsedMessage:function(e){var t=e.firstRedundant;return e.ruleName,"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage:function(e){var n=e.expectedPathsPerAlt,o=e.actual;e.previous;var i=e.customUserDescription;e.ruleName;var a="Expecting: ",s="\nbut found: '"+r.first(o).image+"'";if(i)return a+i+s;var c=r.reduce(n,(function(e,t){return e.concat(t)}),[]),l=r.map(c,(function(e){return"["+r.map(e,(function(e){return t.tokenLabel(e)})).join(", ")+"]"}));return a+("one of these possible Token sequences:\n"+r.map(l,(function(e,t){return" "+(t+1)+". "+e})).join("\n"))+s},buildEarlyExitMessage:function(e){var n=e.expectedIterationPaths,o=e.actual,i=e.customUserDescription;e.ruleName;var a="Expecting: ",s="\nbut found: '"+r.first(o).image+"'";return i?a+i+s:a+("expecting at least one iteration which starts with one of these possible Token sequences::\n <"+r.map(n,(function(e){return"["+r.map(e,(function(e){return t.tokenLabel(e)})).join(",")+"]"})).join(" ,")+">")+s}},Object.freeze(e.defaultParserErrorProvider),e.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"}},e.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(e,t){var n,a=e.name,s=r.first(t),c=s.idx,l=i.getProductionDslName(s),u=(n=s)instanceof o.Terminal?n.terminalType.name:n instanceof o.NonTerminal?n.nonTerminalName:"",d="->"+l+(c>0?c:"")+"<- "+(u?"with argument: ->"+u+"<-":"")+"\n appears more than once ("+t.length+" times) in the top level rule: ->"+a+"<-.\n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES\n ";return d=(d=d.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:function(e){return"Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+e.name+">.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter."},buildAlternationPrefixAmbiguityError:function(e){var n=r.map(e.prefixPath,(function(e){return t.tokenLabel(e)})).join(", "),o=0===e.alternation.idx?"":e.alternation.idx;return"Ambiguous alternatives: <"+e.ambiguityIndices.join(" ,")+"> due to common lookahead prefix\nin <OR"+o+"> inside <"+e.topLevelRule.name+"> Rule,\n<"+n+"> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details."},buildAlternationAmbiguityError:function(e){var n=r.map(e.prefixPath,(function(e){return t.tokenLabel(e)})).join(", "),o=0===e.alternation.idx?"":e.alternation.idx,i="Ambiguous Alternatives Detected: <"+e.ambiguityIndices.join(" ,")+"> in <OR"+o+"> inside <"+e.topLevelRule.name+"> Rule,\n<"+n+"> may appears as a prefix path in all these alternatives.\n";return i+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details."},buildEmptyRepetitionError:function(e){var t=i.getProductionDslName(e.repetition);return 0!==e.repetition.idx&&(t+=e.repetition.idx),"The repetition <"+t+"> within Rule <"+e.topLevelRule.name+"> can never consume any tokens.\nThis could lead to an infinite loop."},buildTokenNameError:function(e){return"deprecated"},buildEmptyAlternationError:function(e){return"Ambiguous empty alternative: <"+(e.emptyChoiceIdx+1)+"> in <OR"+e.alternation.idx+"> inside <"+e.topLevelRule.name+"> Rule.\nOnly the last alternative may be an empty alternative."},buildTooManyAlternativesError:function(e){return"An Alternation cannot have more than 256 alternatives:\n<OR"+e.alternation.idx+"> inside <"+e.topLevelRule.name+"> Rule.\n has "+(e.alternation.definition.length+1)+" alternatives."},buildLeftRecursionError:function(e){var t=e.topLevelRule.name;return"Left Recursion found in grammar.\nrule: <"+t+"> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is:\n "+(t+" --\x3e "+n.map(e.leftRecursionPath,(function(e){return e.name})).concat([t]).join(" --\x3e "))+"\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."},buildInvalidRuleNameError:function(e){return"deprecated"},buildDuplicateRuleNameError:function(e){return"Duplicate definition, rule: ->"+(e.topLevelRule instanceof o.Rule?e.topLevelRule.name:e.topLevelRule)+"<- is already defined in the grammar: ->"+e.grammarName+"<-"}}})),bn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.GastRefResolverVisitor=e.resolveGrammar=void 0;var r=zn(),o=rn(),i=mn();e.resolveGrammar=function(e,t){var n=new a(e,t);return n.resolveRefs(),n.errors};var a=function(e){function t(t,n){var r=e.call(this)||this;return r.nameToTopRule=t,r.errMsgProvider=n,r.errors=[],r}return n(t,e),t.prototype.resolveRefs=function(){var e=this;o.forEach(o.values(this.nameToTopRule),(function(t){e.currTopLevel=t,t.accept(e)}))},t.prototype.visitNonTerminal=function(e){var t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{var n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:r.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}},t}(i.GAstVisitor);e.GastRefResolverVisitor=a})),An=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.nextPossibleTokensAfter=e.possiblePathsFrom=e.NextTerminalAfterAtLeastOneSepWalker=e.NextTerminalAfterAtLeastOneWalker=e.NextTerminalAfterManySepWalker=e.NextTerminalAfterManyWalker=e.AbstractNextTerminalAfterProductionWalker=e.NextAfterTokenWalker=e.AbstractNextPossibleTokensWalker=void 0;var r=hn(),o=rn(),i=yn(),a=fn(),s=function(e){function t(t,n){var r=e.call(this)||this;return r.topProd=t,r.path=n,r.possibleTokTypes=[],r.nextProductionName="",r.nextProductionOccurrence=0,r.found=!1,r.isAtEndOfPath=!1,r}return n(t,e),t.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=o.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=o.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},t.prototype.walk=function(t,n){void 0===n&&(n=[]),this.found||e.prototype.walk.call(this,t,n)},t.prototype.walkProdRef=function(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){var r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}},t.prototype.updateExpectedNext=function(){o.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},t}(r.RestWalker);e.AbstractNextPossibleTokensWalker=s;var c=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.path=n,r.nextTerminalName="",r.nextTerminalOccurrence=0,r.nextTerminalName=r.path.lastTok.name,r.nextTerminalOccurrence=r.path.lastTokOccurrence,r}return n(t,e),t.prototype.walkTerminal=function(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){var r=t.concat(n),o=new a.Alternative({definition:r});this.possibleTokTypes=i.first(o),this.found=!0}},t}(s);e.NextAfterTokenWalker=c;var l=function(e){function t(t,n){var r=e.call(this)||this;return r.topRule=t,r.occurrence=n,r.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},r}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topRule),this.result},t}(r.RestWalker);e.AbstractNextTerminalAfterProductionWalker=l;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkMany=function(t,n,r){if(t.idx===this.occurrence){var i=o.first(n.concat(r));this.result.isEndOfRule=void 0===i,i instanceof a.Terminal&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else e.prototype.walkMany.call(this,t,n,r)},t}(l);e.NextTerminalAfterManyWalker=u;var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkManySep=function(t,n,r){if(t.idx===this.occurrence){var i=o.first(n.concat(r));this.result.isEndOfRule=void 0===i,i instanceof a.Terminal&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else e.prototype.walkManySep.call(this,t,n,r)},t}(l);e.NextTerminalAfterManySepWalker=d;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkAtLeastOne=function(t,n,r){if(t.idx===this.occurrence){var i=o.first(n.concat(r));this.result.isEndOfRule=void 0===i,i instanceof a.Terminal&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else e.prototype.walkAtLeastOne.call(this,t,n,r)},t}(l);e.NextTerminalAfterAtLeastOneWalker=p;var f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkAtLeastOneSep=function(t,n,r){if(t.idx===this.occurrence){var i=o.first(n.concat(r));this.result.isEndOfRule=void 0===i,i instanceof a.Terminal&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else e.prototype.walkAtLeastOneSep.call(this,t,n,r)},t}(l);function h(e,t,n,r){var i=o.cloneArr(n);i.push(e.name);var a=o.cloneArr(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}e.NextTerminalAfterAtLeastOneSepWalker=f,e.possiblePathsFrom=function e(t,n,r){void 0===r&&(r=[]),r=o.cloneArr(r);var i=[],s=0;function c(a){var c=e(function(e){return e.concat(o.drop(t,s+1))}(a),n,r);return i.concat(c)}for(;r.length<n&&s<t.length;){var l=t[s];if(l instanceof a.Alternative)return c(l.definition);if(l instanceof a.NonTerminal)return c(l.definition);if(l instanceof a.Option)i=c(l.definition);else{if(l instanceof a.RepetitionMandatory)return c(u=l.definition.concat([new a.Repetition({definition:l.definition})]));if(l instanceof a.RepetitionMandatoryWithSeparator)return c(u=[new a.Alternative({definition:l.definition}),new a.Repetition({definition:[new a.Terminal({terminalType:l.separator})].concat(l.definition)})]);if(l instanceof a.RepetitionWithSeparator){var u=l.definition.concat([new a.Repetition({definition:[new a.Terminal({terminalType:l.separator})].concat(l.definition)})]);i=c(u)}else if(l instanceof a.Repetition){u=l.definition.concat([new a.Repetition({definition:l.definition})]);i=c(u)}else{if(l instanceof a.Alternation)return o.forEach(l.definition,(function(e){!1===o.isEmpty(e.definition)&&(i=c(e.definition))})),i;if(!(l instanceof a.Terminal))throw Error("non exhaustive match");r.push(l.terminalType)}}s++}return i.push({partialPath:r,suffixDef:o.drop(t,s)}),i},e.nextPossibleTokensAfter=function(e,t,n,r){var i="EXIT_NONE_TERMINAL",s=[i],c="EXIT_ALTERNATIVE",l=!1,u=t.length,d=u-r-1,p=[],f=[];for(f.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!o.isEmpty(f);){var m=f.pop();if(m!==c){var g=m.def,y=m.idx,v=m.ruleStack,E=m.occurrenceStack;if(!o.isEmpty(g)){var T=g[0];if(T===i){var b={idx:y,def:o.drop(g),ruleStack:o.dropRight(v),occurrenceStack:o.dropRight(E)};f.push(b)}else if(T instanceof a.Terminal)if(y<u-1){var A=y+1;if(n(t[A],T.terminalType)){b={idx:A,def:o.drop(g),ruleStack:v,occurrenceStack:E};f.push(b)}}else{if(y!==u-1)throw Error("non exhaustive match");p.push({nextTokenType:T.terminalType,nextTokenOccurrence:T.idx,ruleStack:v,occurrenceStack:E}),l=!0}else if(T instanceof a.NonTerminal){var x=o.cloneArr(v);x.push(T.nonTerminalName);var N=o.cloneArr(E);N.push(T.idx);b={idx:y,def:T.definition.concat(s,o.drop(g)),ruleStack:x,occurrenceStack:N};f.push(b)}else if(T instanceof a.Option){var R={idx:y,def:o.drop(g),ruleStack:v,occurrenceStack:E};f.push(R),f.push(c);var k={idx:y,def:T.definition.concat(o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(k)}else if(T instanceof a.RepetitionMandatory){var O=new a.Repetition({definition:T.definition,idx:T.idx});b={idx:y,def:T.definition.concat([O],o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(b)}else if(T instanceof a.RepetitionMandatoryWithSeparator){var I=new a.Terminal({terminalType:T.separator});O=new a.Repetition({definition:[I].concat(T.definition),idx:T.idx}),b={idx:y,def:T.definition.concat([O],o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(b)}else if(T instanceof a.RepetitionWithSeparator){R={idx:y,def:o.drop(g),ruleStack:v,occurrenceStack:E};f.push(R),f.push(c);I=new a.Terminal({terminalType:T.separator});var _=new a.Repetition({definition:[I].concat(T.definition),idx:T.idx});k={idx:y,def:T.definition.concat([_],o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(k)}else if(T instanceof a.Repetition){R={idx:y,def:o.drop(g),ruleStack:v,occurrenceStack:E};f.push(R),f.push(c);_=new a.Repetition({definition:T.definition,idx:T.idx}),k={idx:y,def:T.definition.concat([_],o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(k)}else if(T instanceof a.Alternation)for(var w=T.definition.length-1;w>=0;w--){var S={idx:y,def:T.definition[w].definition.concat(o.drop(g)),ruleStack:v,occurrenceStack:E};f.push(S),f.push(c)}else if(T instanceof a.Alternative)f.push({idx:y,def:T.definition.concat(o.drop(g)),ruleStack:v,occurrenceStack:E});else{if(!(T instanceof a.Rule))throw Error("non exhaustive match");f.push(h(T,y,v,E))}}}else l&&o.last(f).idx<=d&&f.pop()}return p}})),xn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.areTokenCategoriesNotUsed=e.isStrictPrefixOfPath=e.containsPath=e.getLookaheadPathsForOptionalProd=e.getLookaheadPathsForOr=e.lookAheadSequenceFromAlternatives=e.buildSingleAlternativeLookaheadFunction=e.buildAlternativesLookAheadFunc=e.buildLookaheadFuncForOptionalProd=e.buildLookaheadFuncForOr=e.getProdType=e.PROD_TYPE=void 0;var r,o=rn(),i=An(),a=hn(),s=ln(),c=fn(),l=mn();!function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"}(r=e.PROD_TYPE||(e.PROD_TYPE={})),e.getProdType=function(e){if(e instanceof c.Option)return r.OPTION;if(e instanceof c.Repetition)return r.REPETITION;if(e instanceof c.RepetitionMandatory)return r.REPETITION_MANDATORY;if(e instanceof c.RepetitionMandatoryWithSeparator)return r.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof c.RepetitionWithSeparator)return r.REPETITION_WITH_SEPARATOR;if(e instanceof c.Alternation)return r.ALTERNATION;throw Error("non exhaustive match")},e.buildLookaheadFuncForOr=function(e,t,n,r,o,i){var a=g(e,t,n);return i(a,r,E(a)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher,o)},e.buildLookaheadFuncForOptionalProd=function(e,t,n,r,o,i){var a=y(e,t,o,n),c=E(a)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return i(a[0],c,r)},e.buildAlternativesLookAheadFunc=function(e,t,n,r){var i=e.length,a=o.every(e,(function(e){return o.every(e,(function(e){return 1===e.length}))}));if(t)return function(t){for(var r=o.map(t,(function(e){return e.GATE})),a=0;a<i;a++){var s=e[a],c=s.length,l=r[a];if(void 0===l||!1!==l.call(this))e:for(var u=0;u<c;u++){for(var d=s[u],p=d.length,f=0;f<p;f++){var h=this.LA(f+1);if(!1===n(h,d[f]))continue e}return a}}};if(a&&!r){var s=o.map(e,(function(e){return o.flatten(e)})),c=o.reduce(s,(function(e,t,n){return o.forEach(t,(function(t){o.has(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),o.forEach(t.categoryMatches,(function(t){o.has(e,t)||(e[t]=n)}))})),e}),[]);return function(){var e=this.LA(1);return c[e.tokenTypeIdx]}}return function(){for(var t=0;t<i;t++){var r=e[t],o=r.length;e:for(var a=0;a<o;a++){for(var s=r[a],c=s.length,l=0;l<c;l++){var u=this.LA(l+1);if(!1===n(u,s[l]))continue e}return t}}}},e.buildSingleAlternativeLookaheadFunction=function(e,t,n){var r=o.every(e,(function(e){return 1===e.length})),i=e.length;if(r&&!n){var a=o.flatten(e);if(1===a.length&&o.isEmpty(a[0].categoryMatches)){var s=a[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===s}}var c=o.reduce(a,(function(e,t,n){return e[t.tokenTypeIdx]=!0,o.forEach(t.categoryMatches,(function(t){e[t]=!0})),e}),[]);return function(){var e=this.LA(1);return!0===c[e.tokenTypeIdx]}}return function(){e:for(var n=0;n<i;n++){for(var r=e[n],o=r.length,a=0;a<o;a++){var s=this.LA(a+1);if(!1===t(s,r[a]))continue e}return!0}return!1}};var u=function(e){function t(t,n,r){var o=e.call(this)||this;return o.topProd=t,o.targetOccurrence=n,o.targetProdType=r,o}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},t.prototype.checkIsTarget=function(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)},t.prototype.walkOption=function(t,n,o){this.checkIsTarget(t,r.OPTION,n,o)||e.prototype.walkOption.call(this,t,n,o)},t.prototype.walkAtLeastOne=function(t,n,o){this.checkIsTarget(t,r.REPETITION_MANDATORY,n,o)||e.prototype.walkOption.call(this,t,n,o)},t.prototype.walkAtLeastOneSep=function(t,n,o){this.checkIsTarget(t,r.REPETITION_MANDATORY_WITH_SEPARATOR,n,o)||e.prototype.walkOption.call(this,t,n,o)},t.prototype.walkMany=function(t,n,o){this.checkIsTarget(t,r.REPETITION,n,o)||e.prototype.walkOption.call(this,t,n,o)},t.prototype.walkManySep=function(t,n,o){this.checkIsTarget(t,r.REPETITION_WITH_SEPARATOR,n,o)||e.prototype.walkOption.call(this,t,n,o)},t}(a.RestWalker),d=function(e){function t(t,n,r){var o=e.call(this)||this;return o.targetOccurrence=t,o.targetProdType=n,o.targetRef=r,o.result=[],o}return n(t,e),t.prototype.checkIsTarget=function(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(void 0===this.targetRef||e===this.targetRef)&&(this.result=e.definition)},t.prototype.visitOption=function(e){this.checkIsTarget(e,r.OPTION)},t.prototype.visitRepetition=function(e){this.checkIsTarget(e,r.REPETITION)},t.prototype.visitRepetitionMandatory=function(e){this.checkIsTarget(e,r.REPETITION_MANDATORY)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.checkIsTarget(e,r.REPETITION_MANDATORY_WITH_SEPARATOR)},t.prototype.visitRepetitionWithSeparator=function(e){this.checkIsTarget(e,r.REPETITION_WITH_SEPARATOR)},t.prototype.visitAlternation=function(e){this.checkIsTarget(e,r.ALTERNATION)},t}(l.GAstVisitor);function p(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=[];return t}function f(e){for(var t=[""],n=0;n<e.length;n++){for(var r=e[n],o=[],i=0;i<t.length;i++){var a=t[i];o.push(a+"_"+r.tokenTypeIdx);for(var s=0;s<r.categoryMatches.length;s++){var c="_"+r.categoryMatches[s];o.push(a+c)}}t=o}return t}function h(e,t,n){for(var r=0;r<e.length;r++)if(r!==n)for(var o=e[r],i=0;i<t.length;i++){if(!0===o[t[i]])return!1}return!0}function m(e,t){for(var n=o.map(e,(function(e){return i.possiblePathsFrom([e],1)})),r=p(n.length),a=o.map(n,(function(e){var t={};return o.forEach(e,(function(e){var n=f(e.partialPath);o.forEach(n,(function(e){t[e]=!0}))})),t})),s=n,c=1;c<=t;c++){var l=s;s=p(l.length);for(var u=function(e){for(var n=l[e],u=0;u<n.length;u++){var d=n[u].partialPath,p=n[u].suffixDef,m=f(d);if(h(a,m,e)||o.isEmpty(p)||d.length===t){var g=r[e];if(!1===v(g,d)){g.push(d);for(var y=0;y<m.length;y++){var E=m[y];a[e][E]=!0}}}else{var T=i.possiblePathsFrom(p,c+1,d);s[e]=s[e].concat(T),o.forEach(T,(function(t){var n=f(t.partialPath);o.forEach(n,(function(t){a[e][t]=!0}))}))}}},d=0;d<l.length;d++)u(d)}return r}function g(e,t,n,o){var i=new d(e,r.ALTERNATION,o);return t.accept(i),m(i.result,n)}function y(e,t,n,r){var o=new d(e,n);t.accept(o);var i=o.result,a=new u(t,e,n).startWalking();return m([new c.Alternative({definition:i}),new c.Alternative({definition:a})],r)}function v(e,t){e:for(var n=0;n<e.length;n++){var r=e[n];if(r.length===t.length){for(var o=0;o<r.length;o++){var i=t[o],a=r[o];if(!1===(i===a||void 0!==a.categoryMatchesMap[i.tokenTypeIdx]))continue e}return!0}}return!1}function E(e){return o.every(e,(function(e){return o.every(e,(function(e){return o.every(e,(function(e){return o.isEmpty(e.categoryMatches)}))}))}))}e.lookAheadSequenceFromAlternatives=m,e.getLookaheadPathsForOr=g,e.getLookaheadPathsForOptionalProd=y,e.containsPath=v,e.isStrictPrefixOfPath=function(e,t){return e.length<t.length&&o.every(e,(function(e,n){var r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]}))},e.areTokenCategoriesNotUsed=E})),Nn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.checkPrefixAlternativesAmbiguities=e.validateSomeNonEmptyLookaheadPath=e.validateTooManyAlts=e.RepetionCollector=e.validateAmbiguousAlternationAlternatives=e.validateEmptyOrAlternative=e.getFirstNoneTerminal=e.validateNoLeftRecursion=e.validateRuleIsOverridden=e.validateRuleDoesNotAlreadyExist=e.OccurrenceValidationCollector=e.identifyProductionForDuplicates=e.validateGrammar=void 0;var r=rn(),o=rn(),i=zn(),a=gn(),s=xn(),c=An(),l=fn(),u=mn();function d(e){return a.getProductionDslName(e)+"_#_"+e.idx+"_#_"+p(e)}function p(e){return e instanceof l.Terminal?e.terminalType.name:e instanceof l.NonTerminal?e.nonTerminalName:""}e.validateGrammar=function(e,t,n,s,c){var l=r.map(e,(function(e){return function(e,t){var n=new f;e.accept(n);var o=n.allProductions,s=r.groupBy(o,d),c=r.pick(s,(function(e){return e.length>1})),l=r.map(r.values(c),(function(n){var o=r.first(n),s=t.buildDuplicateFoundError(e,n),c=a.getProductionDslName(o),l={message:s,type:i.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:c,occurrence:o.idx},u=p(o);return u&&(l.parameter=u),l}));return l}(e,s)})),u=r.map(e,(function(e){return m(e,e,s)})),g=[],y=[],T=[];o.every(u,o.isEmpty)&&(g=o.map(e,(function(e){return v(e,s)})),y=o.map(e,(function(e){return E(e,t,s)})),T=A(e,t,s));var x=function(e,t,n){var r=[],a=o.map(t,(function(e){return e.name}));return o.forEach(e,(function(e){var t=e.name;if(o.contains(a,t)){var s=n.buildNamespaceConflictError(e);r.push({message:s,type:i.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}})),r}(e,n,s),N=o.map(e,(function(e){return b(e,s)})),R=o.map(e,(function(t){return h(t,e,c,s)}));return r.flatten(l.concat(T,u,g,y,x,N,R))},e.identifyProductionForDuplicates=d;var f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allProductions=[],t}return n(t,e),t.prototype.visitNonTerminal=function(e){this.allProductions.push(e)},t.prototype.visitOption=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetition=function(e){this.allProductions.push(e)},t.prototype.visitAlternation=function(e){this.allProductions.push(e)},t.prototype.visitTerminal=function(e){this.allProductions.push(e)},t}(u.GAstVisitor);function h(e,t,n,r){var a=[];if(o.reduce(t,(function(t,n){return n.name===e.name?t+1:t}),0)>1){var s=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});a.push({message:s,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e.name})}return a}function m(e,t,n,o){void 0===o&&(o=[]);var a=[],s=g(t.definition);if(r.isEmpty(s))return[];var c=e.name;r.contains(s,e)&&a.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:o}),type:i.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:c});var l=r.difference(s,o.concat([e])),u=r.map(l,(function(t){var i=r.cloneArr(o);return i.push(t),m(e,t,n,i)}));return a.concat(r.flatten(u))}function g(e){var t=[];if(r.isEmpty(e))return t;var n=r.first(e);if(n instanceof l.NonTerminal)t.push(n.referencedRule);else if(n instanceof l.Alternative||n instanceof l.Option||n instanceof l.RepetitionMandatory||n instanceof l.RepetitionMandatoryWithSeparator||n instanceof l.RepetitionWithSeparator||n instanceof l.Repetition)t=t.concat(g(n.definition));else if(n instanceof l.Alternation)t=r.flatten(r.map(n.definition,(function(e){return g(e.definition)})));else if(!(n instanceof l.Terminal))throw Error("non exhaustive match");var o=a.isOptionalProd(n),i=e.length>1;if(o&&i){var s=r.drop(e);return t.concat(g(s))}return t}e.OccurrenceValidationCollector=f,e.validateRuleDoesNotAlreadyExist=h,e.validateRuleIsOverridden=function(e,t,n){var o,a=[];return r.contains(t,e)||(o="Invalid rule override, rule: ->"+e+"<- cannot be overridden in the grammar: ->"+n+"<-as it is not defined in any of the super grammars ",a.push({message:o,type:i.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:e})),a},e.validateNoLeftRecursion=m,e.getFirstNoneTerminal=g;var y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.alternations=[],t}return n(t,e),t.prototype.visitAlternation=function(e){this.alternations.push(e)},t}(u.GAstVisitor);function v(e,t){var n=new y;e.accept(n);var o=n.alternations;return r.reduce(o,(function(n,o){var a=r.dropRight(o.definition),s=r.map(a,(function(n,a){var s=c.nextPossibleTokensAfter([n],[],null,1);return r.isEmpty(s)?{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:a}),type:i.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:a+1}:null}));return n.concat(r.compact(s))}),[])}function E(e,t,n){var a=new y;e.accept(a);var c=a.alternations;c=o.reject(c,(function(e){return!0===e.ignoreAmbiguities}));var l=r.reduce(c,(function(a,c){var l=c.idx,u=c.maxLookahead||t,d=s.getLookaheadPathsForOr(l,e,u,c),p=function(e,t,n,a){var c=[],l=o.reduce(e,(function(n,r,i){return!0===t.definition[i].ignoreAmbiguities||o.forEach(r,(function(r){var a=[i];o.forEach(e,(function(e,n){i!==n&&s.containsPath(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&a.push(n)})),a.length>1&&!s.containsPath(c,r)&&(c.push(r),n.push({alts:a,path:r}))})),n}),[]),u=r.map(l,(function(e){var r=o.map(e.alts,(function(e){return e+1}));return{message:a.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:r,prefixPath:e.path}),type:i.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:[e.alts]}}));return u}(d,c,e,n),f=x(d,c,e,n);return a.concat(p,f)}),[]);return l}e.validateEmptyOrAlternative=v,e.validateAmbiguousAlternationAlternatives=E;var T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allProductions=[],t}return n(t,e),t.prototype.visitRepetitionWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetition=function(e){this.allProductions.push(e)},t}(u.GAstVisitor);function b(e,t){var n=new y;e.accept(n);var o=n.alternations;return r.reduce(o,(function(n,r){return r.definition.length>255&&n.push({message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:r}),type:i.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:e.name,occurrence:r.idx}),n}),[])}function A(e,t,n){var r=[];return o.forEach(e,(function(e){var a=new T;e.accept(a);var c=a.allProductions;o.forEach(c,(function(a){var c=s.getProdType(a),l=a.maxLookahead||t,u=a.idx,d=s.getLookaheadPathsForOptionalProd(u,e,c,l)[0];if(o.isEmpty(o.flatten(d))){var p=n.buildEmptyRepetitionError({topLevelRule:e,repetition:a});r.push({message:p,type:i.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}}))})),r}function x(e,t,n,r){var a=[],c=o.reduce(e,(function(e,t,n){var r=o.map(t,(function(e){return{idx:n,path:e}}));return e.concat(r)}),[]);return o.forEach(c,(function(e){if(!0!==t.definition[e.idx].ignoreAmbiguities){var l=e.idx,u=e.path,d=o.findAll(c,(function(e){return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<l&&s.isStrictPrefixOfPath(e.path,u)})),p=o.map(d,(function(e){var o=[e.idx+1,l+1],a=0===t.idx?"":t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:o,prefixPath:e.path}),type:i.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:o}}));a=a.concat(p)}})),a}e.RepetionCollector=T,e.validateTooManyAlts=b,e.validateSomeNonEmptyLookaheadPath=A,e.checkPrefixAlternativesAmbiguities=x})),Rn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateGrammar=e.resolveGrammar=void 0;var t=rn(),n=bn(),r=Nn(),o=Tn();e.resolveGrammar=function(e){e=t.defaults(e,{errMsgProvider:o.defaultGrammarResolverErrorProvider});var r={};return t.forEach(e.rules,(function(e){r[e.name]=e})),n.resolveGrammar(r,e.errMsgProvider)},e.validateGrammar=function(e){return e=t.defaults(e,{errMsgProvider:o.defaultGrammarValidatorErrorProvider}),r.validateGrammar(e.rules,e.maxLookahead,e.tokenTypes,e.errMsgProvider,e.grammarName)}})),kn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.EarlyExitException=e.NotAllInputParsedException=e.NoViableAltException=e.MismatchedTokenException=e.isRecognitionException=void 0;var r=rn(),o="MismatchedTokenException",i="NoViableAltException",a="EarlyExitException",s="NotAllInputParsedException",c=[o,i,a,s];Object.freeze(c),e.isRecognitionException=function(e){return r.contains(c,e.name)};var l=function(e){function t(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.token=n,o.resyncedTokens=[],Object.setPrototypeOf(o,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(o,o.constructor),o}return n(t,e),t}(Error),u=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i.previousToken=r,i.name=o,i}return n(t,e),t}(l);e.MismatchedTokenException=u;var d=function(e){function t(t,n,r){var o=e.call(this,t,n)||this;return o.previousToken=r,o.name=i,o}return n(t,e),t}(l);e.NoViableAltException=d;var p=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=s,r}return n(t,e),t}(l);e.NotAllInputParsedException=p;var f=function(e){function t(t,n,r){var o=e.call(this,t,n)||this;return o.previousToken=r,o.name=a,o}return n(t,e),t}(l);e.EarlyExitException=f})),On=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.attemptInRepetitionRecovery=e.Recoverable=e.InRuleRecoveryException=e.IN_RULE_RECOVERY_EXCEPTION=e.EOF_FOLLOW_KEY=void 0;var t=pn(),n=rn(),r=kn(),o=vn(),i=zn();function a(t){this.name=e.IN_RULE_RECOVERY_EXCEPTION,this.message=t}e.EOF_FOLLOW_KEY={},e.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException",e.InRuleRecoveryException=a,a.prototype=Error.prototype;var s=function(){function s(){}return s.prototype.initRecoverable=function(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=n.has(e,"recoveryEnabled")?e.recoveryEnabled:i.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},s.prototype.getTokenToInsert=function(e){var n=t.createTokenInstance(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return n.isInsertedInRecovery=!0,n},s.prototype.canTokenTypeBeInsertedInRecovery=function(e){return!0},s.prototype.tryInRepetitionRecovery=function(e,t,o,i){for(var a=this,s=this.findReSyncTokenType(),c=this.exportLexerState(),l=[],u=!1,d=this.LA(1),p=this.LA(1),f=function(){var e=a.LA(0),t=a.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:d,previous:e,ruleName:a.getCurrRuleFullName()}),o=new r.MismatchedTokenException(t,d,a.LA(0));o.resyncedTokens=n.dropRight(l),a.SAVE_ERROR(o)};!u;){if(this.tokenMatcher(p,i))return void f();if(o.call(this))return f(),void e.apply(this,t);this.tokenMatcher(p,s)?u=!0:(p=this.SKIP_TOKEN(),this.addToResyncTokens(p,l))}this.importLexerState(c)},s.prototype.shouldInRepetitionRecoveryBeTried=function(e,t,n){return!(!1===n||void 0===e||void 0===t||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))},s.prototype.getFollowsForInRuleRecovery=function(e,t){var n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)},s.prototype.tryInRuleRecovery=function(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){var n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new a("sad sad panda")},s.prototype.canPerformInRuleRecovery=function(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)},s.prototype.canRecoverWithSingleTokenInsertion=function(e,t){var r=this;if(!this.canTokenTypeBeInsertedInRecovery(e)||n.isEmpty(t))return!1;var o=this.LA(1);return void 0!==n.find(t,(function(e){return r.tokenMatcher(o,e)}))},s.prototype.canRecoverWithSingleTokenDeletion=function(e){return this.tokenMatcher(this.LA(2),e)},s.prototype.isInCurrentRuleReSyncSet=function(e){var t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return n.contains(r,e)},s.prototype.findReSyncTokenType=function(){for(var e=this.flattenFollowSet(),t=this.LA(1),r=2;;){var o=t.tokenType;if(n.contains(e,o))return o;t=this.LA(r),r++}},s.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return e.EOF_FOLLOW_KEY;var t=this.getLastExplicitRuleShortName(),n=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:n,inRule:this.shortRuleNameToFullName(r)}},s.prototype.buildFullFollowKeyStack=function(){var t=this,r=this.RULE_STACK,o=this.RULE_OCCURRENCE_STACK;return n.map(r,(function(n,i){return 0===i?e.EOF_FOLLOW_KEY:{ruleName:t.shortRuleNameToFullName(n),idxInCallingRule:o[i],inRule:t.shortRuleNameToFullName(r[i-1])}}))},s.prototype.flattenFollowSet=function(){var e=this,t=n.map(this.buildFullFollowKeyStack(),(function(t){return e.getFollowSetFromFollowKey(t)}));return n.flatten(t)},s.prototype.getFollowSetFromFollowKey=function(n){if(n===e.EOF_FOLLOW_KEY)return[t.EOF];var r=n.ruleName+n.idxInCallingRule+o.IN+n.inRule;return this.resyncFollows[r]},s.prototype.addToResyncTokens=function(e,n){return this.tokenMatcher(e,t.EOF)||n.push(e),n},s.prototype.reSyncTo=function(e){for(var t=[],r=this.LA(1);!1===this.tokenMatcher(r,e);)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return n.dropRight(t)},s.prototype.attemptInRepetitionRecovery=function(e,t,n,r,o,i,a){},s.prototype.getCurrentGrammarPath=function(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:n.cloneArr(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}},s.prototype.getHumanReadableRuleStack=function(){var e=this;return n.map(this.RULE_STACK,(function(t){return e.shortRuleNameToFullName(t)}))},s}();function c(e,n,r,o,i,a,s){var c=this.getKeyForAutomaticLookahead(o,i),l=this.firstAfterRepMap[c];if(void 0===l){var u=this.getCurrRuleFullName();l=new a(this.getGAstProductions()[u],i).startWalking(),this.firstAfterRepMap[c]=l}var d=l.token,p=l.occurrence,f=l.isEndOfRule;1===this.RULE_STACK.length&&f&&void 0===d&&(d=t.EOF,p=1),this.shouldInRepetitionRecoveryBeTried(d,p,s)&&this.tryInRepetitionRecovery(e,n,r,d)}e.Recoverable=s,e.attemptInRepetitionRecovery=c})),In=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getKeyForAutomaticLookahead=e.AT_LEAST_ONE_SEP_IDX=e.MANY_SEP_IDX=e.AT_LEAST_ONE_IDX=e.MANY_IDX=e.OPTION_IDX=e.OR_IDX=e.BITS_FOR_ALT_IDX=e.BITS_FOR_RULE_IDX=e.BITS_FOR_OCCURRENCE_IDX=e.BITS_FOR_METHOD_TYPE=void 0,e.BITS_FOR_METHOD_TYPE=4,e.BITS_FOR_OCCURRENCE_IDX=8,e.BITS_FOR_RULE_IDX=12,e.BITS_FOR_ALT_IDX=8,e.OR_IDX=1<<e.BITS_FOR_OCCURRENCE_IDX,e.OPTION_IDX=2<<e.BITS_FOR_OCCURRENCE_IDX,e.MANY_IDX=3<<e.BITS_FOR_OCCURRENCE_IDX,e.AT_LEAST_ONE_IDX=4<<e.BITS_FOR_OCCURRENCE_IDX,e.MANY_SEP_IDX=5<<e.BITS_FOR_OCCURRENCE_IDX,e.AT_LEAST_ONE_SEP_IDX=6<<e.BITS_FOR_OCCURRENCE_IDX,e.getKeyForAutomaticLookahead=function(e,t,n){return n|t|e},e.BITS_FOR_ALT_IDX})),_n=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LooksAhead=void 0;var t=xn(),n=rn(),r=zn(),o=In(),i=gn(),a=function(){function e(){}return e.prototype.initLooksAhead=function(e){this.dynamicTokensEnabled=n.has(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:r.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=n.has(e,"maxLookahead")?e.maxLookahead:r.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=n.isES2015MapSupported()?new Map:[],n.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},e.prototype.preComputeLookaheadFunctions=function(e){var r=this;n.forEach(e,(function(e){r.TRACE_INIT(e.name+" Rule Lookahead",(function(){var a=i.collectMethods(e),s=a.alternation,c=a.repetition,l=a.option,u=a.repetitionMandatory,d=a.repetitionMandatoryWithSeparator,p=a.repetitionWithSeparator;n.forEach(s,(function(n){var a=0===n.idx?"":n.idx;r.TRACE_INIT(""+i.getProductionDslName(n)+a,(function(){var i=t.buildLookaheadFuncForOr(n.idx,e,n.maxLookahead||r.maxLookahead,n.hasPredicates,r.dynamicTokensEnabled,r.lookAheadBuilderForAlternatives),a=o.getKeyForAutomaticLookahead(r.fullRuleNameToShort[e.name],o.OR_IDX,n.idx);r.setLaFuncCache(a,i)}))})),n.forEach(c,(function(n){r.computeLookaheadFunc(e,n.idx,o.MANY_IDX,t.PROD_TYPE.REPETITION,n.maxLookahead,i.getProductionDslName(n))})),n.forEach(l,(function(n){r.computeLookaheadFunc(e,n.idx,o.OPTION_IDX,t.PROD_TYPE.OPTION,n.maxLookahead,i.getProductionDslName(n))})),n.forEach(u,(function(n){r.computeLookaheadFunc(e,n.idx,o.AT_LEAST_ONE_IDX,t.PROD_TYPE.REPETITION_MANDATORY,n.maxLookahead,i.getProductionDslName(n))})),n.forEach(d,(function(n){r.computeLookaheadFunc(e,n.idx,o.AT_LEAST_ONE_SEP_IDX,t.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,n.maxLookahead,i.getProductionDslName(n))})),n.forEach(p,(function(n){r.computeLookaheadFunc(e,n.idx,o.MANY_SEP_IDX,t.PROD_TYPE.REPETITION_WITH_SEPARATOR,n.maxLookahead,i.getProductionDslName(n))}))}))}))},e.prototype.computeLookaheadFunc=function(e,n,r,i,a,s){var c=this;this.TRACE_INIT(""+s+(0===n?"":n),(function(){var s=t.buildLookaheadFuncForOptionalProd(n,e,a||c.maxLookahead,c.dynamicTokensEnabled,i,c.lookAheadBuilderForOptional),l=o.getKeyForAutomaticLookahead(c.fullRuleNameToShort[e.name],r,n);c.setLaFuncCache(l,s)}))},e.prototype.lookAheadBuilderForOptional=function(e,n,r){return t.buildSingleAlternativeLookaheadFunction(e,n,r)},e.prototype.lookAheadBuilderForAlternatives=function(e,n,r,o){return t.buildAlternativesLookAheadFunc(e,n,r,o)},e.prototype.getKeyForAutomaticLookahead=function(e,t){var n=this.getLastExplicitRuleShortName();return o.getKeyForAutomaticLookahead(n,e,t)},e.prototype.getLaFuncFromCache=function(e){},e.prototype.getLaFuncFromMap=function(e){return this.lookAheadFuncsCache.get(e)},e.prototype.getLaFuncFromObj=function(e){return this.lookAheadFuncsCache[e]},e.prototype.setLaFuncCache=function(e,t){},e.prototype.setLaFuncCacheUsingMap=function(e,t){this.lookAheadFuncsCache.set(e,t)},e.prototype.setLaFuncUsingObj=function(e,t){this.lookAheadFuncsCache[e]=t},e}();e.LooksAhead=a})),wn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.addNoneTerminalToCst=e.addTerminalToCst=e.setNodeLocationFull=e.setNodeLocationOnlyOffset=void 0,e.setNodeLocationOnlyOffset=function(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)},e.setNodeLocationFull=function(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)},e.addTerminalToCst=function(e,t,n){void 0===e.children[n]?e.children[n]=[t]:e.children[n].push(t)},e.addNoneTerminalToCst=function(e,t,n){void 0===e.children[t]?e.children[t]=[n]:e.children[t].push(n)}})),Sn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineNameProp=e.functionName=e.classNameFromInstance=void 0;var t=rn();e.classNameFromInstance=function(e){return r(e.constructor)};var n="name";function r(e){return e.name||"anonymous"}e.functionName=r,e.defineNameProp=function(e,r){var o=Object.getOwnPropertyDescriptor(e,n);return!(!t.isUndefined(o)&&!o.configurable)&&(Object.defineProperty(e,n,{enumerable:!1,configurable:!0,writable:!1,value:r}),!0)}})),Cn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateRedundantMethods=e.validateMissingCstMethods=e.validateVisitor=e.CstVisitorDefinitionError=e.createBaseVisitorConstructorWithDefaults=e.createBaseSemanticVisitorConstructor=e.defaultVisit=void 0;var t,n,r=rn(),o=Sn();function i(e,t){for(var n=r.keys(e),o=n.length,i=0;i<o;i++)for(var a=e[n[i]],s=a.length,c=0;c<s;c++){var l=a[c];void 0===l.tokenTypeIdx&&this[l.name](l.children,t)}}function a(e,t){var n=s(e,t),r=l(e,t);return n.concat(r)}function s(e,n){var i=r.map(n,(function(n){if(!r.isFunction(e[n]))return{msg:"Missing visitor method: <"+n+"> on "+o.functionName(e.constructor)+" CST Visitor.",type:t.MISSING_METHOD,methodName:n}}));return r.compact(i)}e.defaultVisit=i,e.createBaseSemanticVisitorConstructor=function(e,t){var n=function(){};o.defineNameProp(n,e+"BaseSemantics");var i={visit:function(e,t){if(r.isArray(e)&&(e=e[0]),!r.isUndefined(e))return this[e.name](e.children,t)},validateVisitor:function(){var e=a(this,t);if(!r.isEmpty(e)){var n=r.map(e,(function(e){return e.msg}));throw Error("Errors Detected in CST Visitor <"+o.functionName(this.constructor)+">:\n\t"+n.join("\n\n").replace(/\n/g,"\n\t"))}}};return(n.prototype=i).constructor=n,n._RULE_NAMES=t,n},e.createBaseVisitorConstructorWithDefaults=function(e,t,n){var a=function(){};o.defineNameProp(a,e+"BaseSemanticsWithDefaults");var s=Object.create(n.prototype);return r.forEach(t,(function(e){s[e]=i})),(a.prototype=s).constructor=a,a},(n=t=e.CstVisitorDefinitionError||(e.CstVisitorDefinitionError={}))[n.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",n[n.MISSING_METHOD=1]="MISSING_METHOD",e.validateVisitor=a,e.validateMissingCstMethods=s;var c=["constructor","visit","validateVisitor"];function l(e,n){var i=[];for(var a in e)r.isFunction(e[a])&&!r.contains(c,a)&&!r.contains(n,a)&&i.push({msg:"Redundant visitor method: <"+a+"> on "+o.functionName(e.constructor)+" CST Visitor\nThere is no Grammar Rule corresponding to this method's name.\n",type:t.REDUNDANT_METHOD,methodName:a});return i}e.validateRedundantMethods=l})),Ln=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TreeBuilder=void 0;var t=wn(),n=rn(),r=Cn(),o=zn(),i=function(){function e(){}return e.prototype.initTreeBuilder=function(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=n.has(e,"nodeLocationTracking")?e.nodeLocationTracking:o.DEFAULT_PARSER_CONFIG.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=t.setNodeLocationFull,this.setNodeLocationFromNode=t.setNodeLocationFull,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=t.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=t.setNodeLocationOnlyOffset,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error('Invalid <nodeLocationTracking> config option: "'+e.nodeLocationTracking+'"');this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=n.NOOP}else this.cstInvocationStateUpdate=n.NOOP,this.cstFinallyStateUpdate=n.NOOP,this.cstPostTerminal=n.NOOP,this.cstPostNonTerminal=n.NOOP,this.cstPostRule=n.NOOP},e.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(e){e.location={startOffset:NaN,endOffset:NaN}},e.prototype.setInitialNodeLocationOnlyOffsetRegular=function(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},e.prototype.setInitialNodeLocationFullRecovery=function(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},e.prototype.setInitialNodeLocationFullRegular=function(e){var t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},e.prototype.cstInvocationStateUpdate=function(e,t){var n={name:e,children:{}};this.setInitialNodeLocation(n),this.CST_STACK.push(n)},e.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},e.prototype.cstPostRuleFull=function(e){var t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)},e.prototype.cstPostRuleOnlyOffset=function(e){var t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN},e.prototype.cstPostTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];t.addTerminalToCst(r,n,e),this.setNodeLocationFromToken(r.location,n)},e.prototype.cstPostNonTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];t.addNoneTerminalToCst(r,n,e),this.setNodeLocationFromNode(r.location,e.location)},e.prototype.getBaseCstVisitorConstructor=function(){if(n.isUndefined(this.baseCstVisitorConstructor)){var e=r.createBaseSemanticVisitorConstructor(this.className,n.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor},e.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(n.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var e=r.createBaseVisitorConstructorWithDefaults(this.className,n.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor},e.prototype.getLastExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-1]},e.prototype.getPreviousExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-2]},e.prototype.getLastExplicitRuleOccurrenceIndex=function(){var e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]},e}();e.TreeBuilder=i})),Pn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LexerAdapter=void 0;var t=zn(),n=function(){function e(){}return e.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(e.prototype,"input",{get:function(){return this.tokVector},set:function(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length},enumerable:!1,configurable:!0}),e.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):t.END_OF_FILE},e.prototype.LA=function(e){var n=this.currIdx+e;return n<0||this.tokVectorLength<=n?t.END_OF_FILE:this.tokVector[n]},e.prototype.consumeToken=function(){this.currIdx++},e.prototype.exportLexerState=function(){return this.currIdx},e.prototype.importLexerState=function(e){this.currIdx=e},e.prototype.resetLexerState=function(){this.currIdx=-1},e.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},e.prototype.getLexerPosition=function(){return this.exportLexerState()},e}();e.LexerAdapter=n})),Mn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecognizerApi=void 0;var t=rn(),n=kn(),r=zn(),o=Tn(),i=Nn(),a=fn(),s=function(){function e(){}return e.prototype.ACTION=function(e){return e.call(this)},e.prototype.consume=function(e,t,n){return this.consumeInternal(t,e,n)},e.prototype.subrule=function(e,t,n){return this.subruleInternal(t,e,n)},e.prototype.option=function(e,t){return this.optionInternal(t,e)},e.prototype.or=function(e,t){return this.orInternal(t,e)},e.prototype.many=function(e,t){return this.manyInternal(e,t)},e.prototype.atLeastOne=function(e,t){return this.atLeastOneInternal(e,t)},e.prototype.CONSUME=function(e,t){return this.consumeInternal(e,0,t)},e.prototype.CONSUME1=function(e,t){return this.consumeInternal(e,1,t)},e.prototype.CONSUME2=function(e,t){return this.consumeInternal(e,2,t)},e.prototype.CONSUME3=function(e,t){return this.consumeInternal(e,3,t)},e.prototype.CONSUME4=function(e,t){return this.consumeInternal(e,4,t)},e.prototype.CONSUME5=function(e,t){return this.consumeInternal(e,5,t)},e.prototype.CONSUME6=function(e,t){return this.consumeInternal(e,6,t)},e.prototype.CONSUME7=function(e,t){return this.consumeInternal(e,7,t)},e.prototype.CONSUME8=function(e,t){return this.consumeInternal(e,8,t)},e.prototype.CONSUME9=function(e,t){return this.consumeInternal(e,9,t)},e.prototype.SUBRULE=function(e,t){return this.subruleInternal(e,0,t)},e.prototype.SUBRULE1=function(e,t){return this.subruleInternal(e,1,t)},e.prototype.SUBRULE2=function(e,t){return this.subruleInternal(e,2,t)},e.prototype.SUBRULE3=function(e,t){return this.subruleInternal(e,3,t)},e.prototype.SUBRULE4=function(e,t){return this.subruleInternal(e,4,t)},e.prototype.SUBRULE5=function(e,t){return this.subruleInternal(e,5,t)},e.prototype.SUBRULE6=function(e,t){return this.subruleInternal(e,6,t)},e.prototype.SUBRULE7=function(e,t){return this.subruleInternal(e,7,t)},e.prototype.SUBRULE8=function(e,t){return this.subruleInternal(e,8,t)},e.prototype.SUBRULE9=function(e,t){return this.subruleInternal(e,9,t)},e.prototype.OPTION=function(e){return this.optionInternal(e,0)},e.prototype.OPTION1=function(e){return this.optionInternal(e,1)},e.prototype.OPTION2=function(e){return this.optionInternal(e,2)},e.prototype.OPTION3=function(e){return this.optionInternal(e,3)},e.prototype.OPTION4=function(e){return this.optionInternal(e,4)},e.prototype.OPTION5=function(e){return this.optionInternal(e,5)},e.prototype.OPTION6=function(e){return this.optionInternal(e,6)},e.prototype.OPTION7=function(e){return this.optionInternal(e,7)},e.prototype.OPTION8=function(e){return this.optionInternal(e,8)},e.prototype.OPTION9=function(e){return this.optionInternal(e,9)},e.prototype.OR=function(e){return this.orInternal(e,0)},e.prototype.OR1=function(e){return this.orInternal(e,1)},e.prototype.OR2=function(e){return this.orInternal(e,2)},e.prototype.OR3=function(e){return this.orInternal(e,3)},e.prototype.OR4=function(e){return this.orInternal(e,4)},e.prototype.OR5=function(e){return this.orInternal(e,5)},e.prototype.OR6=function(e){return this.orInternal(e,6)},e.prototype.OR7=function(e){return this.orInternal(e,7)},e.prototype.OR8=function(e){return this.orInternal(e,8)},e.prototype.OR9=function(e){return this.orInternal(e,9)},e.prototype.MANY=function(e){this.manyInternal(0,e)},e.prototype.MANY1=function(e){this.manyInternal(1,e)},e.prototype.MANY2=function(e){this.manyInternal(2,e)},e.prototype.MANY3=function(e){this.manyInternal(3,e)},e.prototype.MANY4=function(e){this.manyInternal(4,e)},e.prototype.MANY5=function(e){this.manyInternal(5,e)},e.prototype.MANY6=function(e){this.manyInternal(6,e)},e.prototype.MANY7=function(e){this.manyInternal(7,e)},e.prototype.MANY8=function(e){this.manyInternal(8,e)},e.prototype.MANY9=function(e){this.manyInternal(9,e)},e.prototype.MANY_SEP=function(e){this.manySepFirstInternal(0,e)},e.prototype.MANY_SEP1=function(e){this.manySepFirstInternal(1,e)},e.prototype.MANY_SEP2=function(e){this.manySepFirstInternal(2,e)},e.prototype.MANY_SEP3=function(e){this.manySepFirstInternal(3,e)},e.prototype.MANY_SEP4=function(e){this.manySepFirstInternal(4,e)},e.prototype.MANY_SEP5=function(e){this.manySepFirstInternal(5,e)},e.prototype.MANY_SEP6=function(e){this.manySepFirstInternal(6,e)},e.prototype.MANY_SEP7=function(e){this.manySepFirstInternal(7,e)},e.prototype.MANY_SEP8=function(e){this.manySepFirstInternal(8,e)},e.prototype.MANY_SEP9=function(e){this.manySepFirstInternal(9,e)},e.prototype.AT_LEAST_ONE=function(e){this.atLeastOneInternal(0,e)},e.prototype.AT_LEAST_ONE1=function(e){return this.atLeastOneInternal(1,e)},e.prototype.AT_LEAST_ONE2=function(e){this.atLeastOneInternal(2,e)},e.prototype.AT_LEAST_ONE3=function(e){this.atLeastOneInternal(3,e)},e.prototype.AT_LEAST_ONE4=function(e){this.atLeastOneInternal(4,e)},e.prototype.AT_LEAST_ONE5=function(e){this.atLeastOneInternal(5,e)},e.prototype.AT_LEAST_ONE6=function(e){this.atLeastOneInternal(6,e)},e.prototype.AT_LEAST_ONE7=function(e){this.atLeastOneInternal(7,e)},e.prototype.AT_LEAST_ONE8=function(e){this.atLeastOneInternal(8,e)},e.prototype.AT_LEAST_ONE9=function(e){this.atLeastOneInternal(9,e)},e.prototype.AT_LEAST_ONE_SEP=function(e){this.atLeastOneSepFirstInternal(0,e)},e.prototype.AT_LEAST_ONE_SEP1=function(e){this.atLeastOneSepFirstInternal(1,e)},e.prototype.AT_LEAST_ONE_SEP2=function(e){this.atLeastOneSepFirstInternal(2,e)},e.prototype.AT_LEAST_ONE_SEP3=function(e){this.atLeastOneSepFirstInternal(3,e)},e.prototype.AT_LEAST_ONE_SEP4=function(e){this.atLeastOneSepFirstInternal(4,e)},e.prototype.AT_LEAST_ONE_SEP5=function(e){this.atLeastOneSepFirstInternal(5,e)},e.prototype.AT_LEAST_ONE_SEP6=function(e){this.atLeastOneSepFirstInternal(6,e)},e.prototype.AT_LEAST_ONE_SEP7=function(e){this.atLeastOneSepFirstInternal(7,e)},e.prototype.AT_LEAST_ONE_SEP8=function(e){this.atLeastOneSepFirstInternal(8,e)},e.prototype.AT_LEAST_ONE_SEP9=function(e){this.atLeastOneSepFirstInternal(9,e)},e.prototype.RULE=function(e,n,i){if(void 0===i&&(i=r.DEFAULT_RULE_CONFIG),t.contains(this.definedRulesNames,e)){var a={message:o.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);var s=this.defineRule(e,n,i);return this[e]=s,s},e.prototype.OVERRIDE_RULE=function(e,t,n){void 0===n&&(n=r.DEFAULT_RULE_CONFIG);var o=[];o=o.concat(i.validateRuleIsOverridden(e,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(o);var a=this.defineRule(e,t,n);return this[e]=a,a},e.prototype.BACKTRACK=function(e,t){return function(){this.isBackTrackingStack.push(1);var r=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(n.isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(r),this.isBackTrackingStack.pop()}}},e.prototype.getGAstProductions=function(){return this.gastProductionsCache},e.prototype.getSerializedGastProductions=function(){return a.serializeGrammar(t.values(this.gastProductionsCache))},e}();e.RecognizerApi=s})),Fn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecognizerEngine=void 0;var t=rn(),n=In(),r=kn(),o=xn(),i=An(),a=zn(),s=On(),c=pn(),l=ln(),u=Sn(),d=function(){function e(){}return e.prototype.initRecognizerEngine=function(e,n){if(this.className=u.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=l.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},t.has(n,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(t.isArray(e)){if(t.isEmpty(e))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(t.isArray(e))this.tokensMap=t.reduce(e,(function(e,t){return e[t.name]=t,e}),{});else if(t.has(e,"modes")&&t.every(t.flatten(t.values(e.modes)),l.isTokenType)){var r=t.flatten(t.values(e.modes)),o=t.uniq(r);this.tokensMap=t.reduce(o,(function(e,t){return e[t.name]=t,e}),{})}else{if(!t.isObject(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=t.cloneObj(e)}this.tokensMap.EOF=c.EOF;var i=t.every(t.values(e),(function(e){return t.isEmpty(e.categoryMatches)}));this.tokenMatcher=i?l.tokenStructuredMatcherNoCategories:l.tokenStructuredMatcher,l.augmentTokenTypes(t.values(this.tokensMap))},e.prototype.defineRule=function(e,r,o){if(this.selfAnalysisDone)throw Error("Grammar rule <"+e+"> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.");var i=t.has(o,"resyncEnabled")?o.resyncEnabled:a.DEFAULT_RULE_CONFIG.resyncEnabled,s=t.has(o,"recoveryValueFunc")?o.recoveryValueFunc:a.DEFAULT_RULE_CONFIG.recoveryValueFunc,c=this.ruleShortNameIdx<<n.BITS_FOR_METHOD_TYPE+n.BITS_FOR_OCCURRENCE_IDX;function l(e){try{if(!0===this.outputCst){r.apply(this,e);var t=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(t),t}return r.apply(this,e)}catch(e){return this.invokeRuleCatch(e,i,s)}finally{this.ruleFinallyStateUpdate()}}this.ruleShortNameIdx++,this.shortRuleNameToFull[c]=e,this.fullRuleNameToShort[e]=c;var u=function(t,n){return void 0===t&&(t=0),this.ruleInvocationStateUpdate(c,e,t),l.call(this,n)};return u.ruleName=e,u.originalGrammarAction=r,u},e.prototype.invokeRuleCatch=function(e,t,n){var o=1===this.RULE_STACK.length,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(r.isRecognitionException(e)){var a=e;if(i){var s,c=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(c))return a.resyncedTokens=this.reSyncTo(c),this.outputCst?((s=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,s):n();throw this.outputCst&&((s=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,a.partialCstResult=s),a}if(o)return this.moveToTerminatedState(),n();throw a}throw e},e.prototype.optionInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.OPTION_IDX,t);return this.optionInternalLogic(e,t,r)},e.prototype.optionInternalLogic=function(e,t,n){var r,o,i=this,a=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(o=e.GATE)){var s=a;a=function(){return o.call(i)&&s.call(i)}}}else r=e;if(!0===a.call(this))return r.call(this)},e.prototype.atLeastOneInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.AT_LEAST_ONE_IDX,e);return this.atLeastOneInternalLogic(e,t,r)},e.prototype.atLeastOneInternalLogic=function(e,t,r){var a,s,c=this,l=this.getLaFuncFromCache(r);if(void 0!==t.DEF){if(a=t.DEF,void 0!==(s=t.GATE)){var u=l;l=function(){return s.call(c)&&u.call(c)}}}else a=t;if(!0!==l.call(this))throw this.raiseEarlyExitException(e,o.PROD_TYPE.REPETITION_MANDATORY,t.ERR_MSG);for(var d=this.doSingleRepetition(a);!0===l.call(this)&&!0===d;)d=this.doSingleRepetition(a);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],l,n.AT_LEAST_ONE_IDX,e,i.NextTerminalAfterAtLeastOneWalker)},e.prototype.atLeastOneSepFirstInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.AT_LEAST_ONE_SEP_IDX,e);this.atLeastOneSepFirstInternalLogic(e,t,r)},e.prototype.atLeastOneSepFirstInternalLogic=function(e,t,r){var a=this,s=t.DEF,c=t.SEP;if(!0!==this.getLaFuncFromCache(r).call(this))throw this.raiseEarlyExitException(e,o.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);s.call(this);for(var l=function(){return a.tokenMatcher(a.LA(1),c)};!0===this.tokenMatcher(this.LA(1),c);)this.CONSUME(c),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,c,l,s,i.NextTerminalAfterAtLeastOneSepWalker],l,n.AT_LEAST_ONE_SEP_IDX,e,i.NextTerminalAfterAtLeastOneSepWalker)},e.prototype.manyInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.MANY_IDX,e);return this.manyInternalLogic(e,t,r)},e.prototype.manyInternalLogic=function(e,t,r){var o,a,s=this,c=this.getLaFuncFromCache(r);if(void 0!==t.DEF){if(o=t.DEF,void 0!==(a=t.GATE)){var l=c;c=function(){return a.call(s)&&l.call(s)}}}else o=t;for(var u=!0;!0===c.call(this)&&!0===u;)u=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],c,n.MANY_IDX,e,i.NextTerminalAfterManyWalker,u)},e.prototype.manySepFirstInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.MANY_SEP_IDX,e);this.manySepFirstInternalLogic(e,t,r)},e.prototype.manySepFirstInternalLogic=function(e,t,r){var o=this,a=t.DEF,s=t.SEP;if(!0===this.getLaFuncFromCache(r).call(this)){a.call(this);for(var c=function(){return o.tokenMatcher(o.LA(1),s)};!0===this.tokenMatcher(this.LA(1),s);)this.CONSUME(s),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,c,a,i.NextTerminalAfterManySepWalker],c,n.MANY_SEP_IDX,e,i.NextTerminalAfterManySepWalker)}},e.prototype.repetitionSepSecondInternal=function(e,t,r,o,i){for(;r();)this.CONSUME(t),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,o,i],r,n.AT_LEAST_ONE_SEP_IDX,e,i)},e.prototype.doSingleRepetition=function(e){var t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t},e.prototype.orInternal=function(e,r){var o=this.getKeyForAutomaticLookahead(n.OR_IDX,r),i=t.isArray(e)?e:e.DEF,a=this.getLaFuncFromCache(o).call(this,i);if(void 0!==a)return i[a].ALT.call(this);this.raiseNoAltException(r,e.ERR_MSG)},e.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){var e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new r.NotAllInputParsedException(t,e))}},e.prototype.subruleInternal=function(e,t,n){var r;try{var o=void 0!==n?n.ARGS:void 0;return r=e.call(this,t,o),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:e.ruleName),r}catch(t){this.subruleInternalError(t,n,e.ruleName)}},e.prototype.subruleInternalError=function(e,t,n){throw r.isRecognitionException(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:n),delete e.partialCstResult),e},e.prototype.consumeInternal=function(e,t,n){var r;try{var o=this.LA(1);!0===this.tokenMatcher(o,e)?(this.consumeToken(),r=o):this.consumeInternalError(e,o,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:e.name,r),r},e.prototype.consumeInternalError=function(e,t,n){var o,i=this.LA(0);throw o=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new r.MismatchedTokenException(o,t,i))},e.prototype.consumeInternalRecovery=function(e,t,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;var r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===s.IN_RULE_RECOVERY_EXCEPTION?n:e}},e.prototype.saveRecogState=function(){var e=this.errors,n=t.cloneArr(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:n,CST_STACK:this.CST_STACK}},e.prototype.reloadRecogState=function(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK},e.prototype.ruleInvocationStateUpdate=function(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t,e)},e.prototype.isBackTracking=function(){return 0!==this.isBackTrackingStack.length},e.prototype.getCurrRuleFullName=function(){var e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]},e.prototype.shortRuleNameToFullName=function(e){return this.shortRuleNameToFull[e]},e.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},e.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},e}();e.RecognizerEngine=d})),Dn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorHandler=void 0;var t=kn(),n=rn(),r=xn(),o=zn(),i=function(){function e(){}return e.prototype.initErrorHandler=function(e){this._errors=[],this.errorMessageProvider=n.has(e,"errorMessageProvider")?e.errorMessageProvider:o.DEFAULT_PARSER_CONFIG.errorMessageProvider},e.prototype.SAVE_ERROR=function(e){if(t.isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:n.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(e.prototype,"errors",{get:function(){return n.cloneArr(this._errors)},set:function(e){this._errors=e},enumerable:!1,configurable:!0}),e.prototype.raiseEarlyExitException=function(e,n,o){for(var i=this.getCurrRuleFullName(),a=this.getGAstProductions()[i],s=r.getLookaheadPathsForOptionalProd(e,a,n,this.maxLookahead)[0],c=[],l=1;l<=this.maxLookahead;l++)c.push(this.LA(l));var u=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:s,actual:c,previous:this.LA(0),customUserDescription:o,ruleName:i});throw this.SAVE_ERROR(new t.EarlyExitException(u,this.LA(1),this.LA(0)))},e.prototype.raiseNoAltException=function(e,n){for(var o=this.getCurrRuleFullName(),i=this.getGAstProductions()[o],a=r.getLookaheadPathsForOr(e,i,this.maxLookahead),s=[],c=1;c<=this.maxLookahead;c++)s.push(this.LA(c));var l=this.LA(0),u=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:a,actual:s,previous:l,customUserDescription:n,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new t.NoViableAltException(u,this.LA(1),l))},e}();e.ErrorHandler=i})),Un=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentAssist=void 0;var t=An(),n=rn(),r=function(){function e(){}return e.prototype.initContentAssist=function(){},e.prototype.computeContentAssist=function(e,r){var o=this.gastProductionsCache[e];if(n.isUndefined(o))throw Error("Rule ->"+e+"<- does not exist in this grammar.");return t.nextPossibleTokensAfter([o],r,this.tokenMatcher,this.maxLookahead)},e.prototype.getNextPossibleTokenTypes=function(e){var r=n.first(e.ruleStack),o=this.getGAstProductions()[r];return new t.NextAfterTokenWalker(o,e).startWalking()},e}();e.ContentAssist=r})),Vn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GastRecorder=void 0;var t=rn(),n=fn(),r=dn(),o=ln(),i=pn(),a=zn(),s=In(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var l=Math.pow(2,s.BITS_FOR_OCCURRENCE_IDX)-1,u=i.createToken({name:"RECORDING_PHASE_TOKEN",pattern:r.Lexer.NA});o.augmentTokenTypes([u]);var d=i.createTokenInstance(u,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(d);var p={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}},f=function(){function e(){}return e.prototype.initGastRecorder=function(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1},e.prototype.enableRecording=function(){var e=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",(function(){for(var t=function(t){var n=t>0?t:"";e["CONSUME"+n]=function(e,n){return this.consumeInternalRecord(e,t,n)},e["SUBRULE"+n]=function(e,n){return this.subruleInternalRecord(e,t,n)},e["OPTION"+n]=function(e){return this.optionInternalRecord(e,t)},e["OR"+n]=function(e){return this.orInternalRecord(e,t)},e["MANY"+n]=function(e){this.manyInternalRecord(t,e)},e["MANY_SEP"+n]=function(e){this.manySepFirstInternalRecord(t,e)},e["AT_LEAST_ONE"+n]=function(e){this.atLeastOneInternalRecord(t,e)},e["AT_LEAST_ONE_SEP"+n]=function(e){this.atLeastOneSepFirstInternalRecord(t,e)}},n=0;n<10;n++)t(n);e.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},e.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},e.option=function(e,t){return this.optionInternalRecord(t,e)},e.or=function(e,t){return this.orInternalRecord(t,e)},e.many=function(e,t){this.manyInternalRecord(e,t)},e.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},e.ACTION=e.ACTION_RECORD,e.BACKTRACK=e.BACKTRACK_RECORD,e.LA=e.LA_RECORD}))},e.prototype.disableRecording=function(){var e=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",(function(){for(var t=0;t<10;t++){var n=t>0?t:"";delete e["CONSUME"+n],delete e["SUBRULE"+n],delete e["OPTION"+n],delete e["OR"+n],delete e["MANY"+n],delete e["MANY_SEP"+n],delete e["AT_LEAST_ONE"+n],delete e["AT_LEAST_ONE_SEP"+n]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA}))},e.prototype.ACTION_RECORD=function(e){},e.prototype.BACKTRACK_RECORD=function(e,t){return function(){return!0}},e.prototype.LA_RECORD=function(e){return a.END_OF_FILE},e.prototype.topLevelRuleRecord=function(e,t){try{var r=new n.Rule({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(t){throw e}throw e}},e.prototype.optionInternalRecord=function(e,t){return h.call(this,n.Option,e,t)},e.prototype.atLeastOneInternalRecord=function(e,t){h.call(this,n.RepetitionMandatory,t,e)},e.prototype.atLeastOneSepFirstInternalRecord=function(e,t){h.call(this,n.RepetitionMandatoryWithSeparator,t,e,true)},e.prototype.manyInternalRecord=function(e,t){h.call(this,n.Repetition,t,e)},e.prototype.manySepFirstInternalRecord=function(e,t){h.call(this,n.RepetitionWithSeparator,t,e,true)},e.prototype.orInternalRecord=function(e,t){return m.call(this,e,t)},e.prototype.subruleInternalRecord=function(e,r,o){if(y(r),!e||!1===t.has(e,"ruleName")){var i=new Error("<SUBRULE"+g(r)+"> argument is invalid expecting a Parser method reference but got: <"+JSON.stringify(e)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw i.KNOWN_RECORDER_ERROR=!0,i}var a=t.peek(this.recordingProdStack),s=e.ruleName,l=new n.NonTerminal({idx:r,nonTerminalName:s,referencedRule:void 0});return a.definition.push(l),this.outputCst?p:c},e.prototype.consumeInternalRecord=function(e,r,i){if(y(r),!o.hasShortKeyProperty(e)){var a=new Error("<CONSUME"+g(r)+"> argument is invalid expecting a TokenType reference but got: <"+JSON.stringify(e)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw a.KNOWN_RECORDER_ERROR=!0,a}var s=t.peek(this.recordingProdStack),c=new n.Terminal({idx:r,terminalType:e});return s.definition.push(c),d},e}();function h(e,n,r,o){void 0===o&&(o=!1),y(r);var i=t.peek(this.recordingProdStack),a=t.isFunction(n)?n:n.DEF,s=new e({definition:[],idx:r});return o&&(s.separator=n.SEP),t.has(n,"MAX_LOOKAHEAD")&&(s.maxLookahead=n.MAX_LOOKAHEAD),this.recordingProdStack.push(s),a.call(this),i.definition.push(s),this.recordingProdStack.pop(),c}function m(e,r){var o=this;y(r);var i=t.peek(this.recordingProdStack),a=!1===t.isArray(e),s=!1===a?e:e.DEF,l=new n.Alternation({definition:[],idx:r,ignoreAmbiguities:a&&!0===e.IGNORE_AMBIGUITIES});t.has(e,"MAX_LOOKAHEAD")&&(l.maxLookahead=e.MAX_LOOKAHEAD);var u=t.some(s,(function(e){return t.isFunction(e.GATE)}));return l.hasPredicates=u,i.definition.push(l),t.forEach(s,(function(e){var r=new n.Alternative({definition:[]});l.definition.push(r),t.has(e,"IGNORE_AMBIGUITIES")?r.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:t.has(e,"GATE")&&(r.ignoreAmbiguities=!0),o.recordingProdStack.push(r),e.ALT.call(o),o.recordingProdStack.pop()})),c}function g(e){return 0===e?"":""+e}function y(e){if(e<0||e>l){var t=new Error("Invalid DSL Method idx value: <"+e+">\n\tIdx value must be a none negative value smaller than "+(l+1));throw t.KNOWN_RECORDER_ERROR=!0,t}}e.GastRecorder=f})),Bn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PerformanceTracer=void 0;var t=rn(),n=zn(),r=function(){function e(){}return e.prototype.initPerformanceTracer=function(e){if(t.has(e,"traceInitPerf")){var r=e.traceInitPerf,o="number"==typeof r;this.traceInitMaxIdent=o?r:1/0,this.traceInitPerf=o?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=n.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},e.prototype.TRACE_INIT=function(e,n){if(!0===this.traceInitPerf){this.traceInitIndent++;var r=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(r+"--\x3e <"+e+">");var o=t.timer(n),i=o.time,a=o.value,s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(r+"<-- <"+e+"> time: "+i+"ms"),this.traceInitIndent--,a}return n()},e}();e.PerformanceTracer=r})),jn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.applyMixins=void 0,e.applyMixins=function(e,t){t.forEach((function(t){var n=t.prototype;Object.getOwnPropertyNames(n).forEach((function(r){if("constructor"!==r){var o=Object.getOwnPropertyDescriptor(n,r);o&&(o.get||o.set)?Object.defineProperty(e.prototype,r,o):e.prototype[r]=t.prototype[r]}}))}))}})),zn=tn((e=>{var t,n=e&&e.__extends||(t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.EmbeddedActionsParser=e.CstParser=e.Parser=e.EMPTY_ALT=e.ParserDefinitionErrorType=e.DEFAULT_RULE_CONFIG=e.DEFAULT_PARSER_CONFIG=e.END_OF_FILE=void 0;var r=rn(),o=En(),i=pn(),a=Tn(),s=Rn(),c=On(),l=_n(),u=Ln(),d=Pn(),p=Mn(),f=Fn(),h=Dn(),m=Un(),g=Vn(),y=Bn(),v=jn();e.END_OF_FILE=i.createTokenInstance(i.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(e.END_OF_FILE),e.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:a.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),e.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0}),function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"}(e.ParserDefinitionErrorType||(e.ParserDefinitionErrorType={})),e.EMPTY_ALT=function(e){return void 0===e&&(e=void 0),function(){return e}};var E=function(){function t(t,n){this.definitionErrors=[],this.selfAnalysisDone=!1;var o=this;if(o.initErrorHandler(n),o.initLexerAdapter(),o.initLooksAhead(n),o.initRecognizerEngine(t,n),o.initRecoverable(n),o.initTreeBuilder(n),o.initContentAssist(),o.initGastRecorder(n),o.initPerformanceTracer(n),r.has(n,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=r.has(n,"skipValidations")?n.skipValidations:e.DEFAULT_PARSER_CONFIG.skipValidations}return t.performSelfAnalysis=function(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")},t.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",(function(){var n;e.selfAnalysisDone=!0;var i=e.className;e.TRACE_INIT("toFastProps",(function(){r.toFastProperties(e)})),e.TRACE_INIT("Grammar Recording",(function(){try{e.enableRecording(),r.forEach(e.definedRulesNames,(function(t){var n=e[t].originalGrammarAction,r=void 0;e.TRACE_INIT(t+" Rule",(function(){r=e.topLevelRuleRecord(t,n)})),e.gastProductionsCache[t]=r}))}finally{e.disableRecording()}}));var c=[];if(e.TRACE_INIT("Grammar Resolving",(function(){c=s.resolveGrammar({rules:r.values(e.gastProductionsCache)}),e.definitionErrors=e.definitionErrors.concat(c)})),e.TRACE_INIT("Grammar Validations",(function(){if(r.isEmpty(c)&&!1===e.skipValidations){var t=s.validateGrammar({rules:r.values(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:r.values(e.tokensMap),errMsgProvider:a.defaultGrammarValidatorErrorProvider,grammarName:i});e.definitionErrors=e.definitionErrors.concat(t)}})),r.isEmpty(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",(function(){var t=o.computeAllProdsFollows(r.values(e.gastProductionsCache));e.resyncFollows=t})),e.TRACE_INIT("ComputeLookaheadFunctions",(function(){e.preComputeLookaheadFunctions(r.values(e.gastProductionsCache))}))),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!r.isEmpty(e.definitionErrors))throw n=r.map(e.definitionErrors,(function(e){return e.message})),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"))}))},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t}();e.Parser=E,v.applyMixins(E,[c.Recoverable,l.LooksAhead,u.TreeBuilder,d.LexerAdapter,f.RecognizerEngine,p.RecognizerApi,h.ErrorHandler,m.ContentAssist,g.GastRecorder,y.PerformanceTracer]);var T=function(t){function o(n,o){void 0===o&&(o=e.DEFAULT_PARSER_CONFIG);var i=r.cloneObj(o);return i.outputCst=!0,t.call(this,n,i)||this}return n(o,t),o}(E);e.CstParser=T;var b=function(t){function o(n,o){void 0===o&&(o=e.DEFAULT_PARSER_CONFIG);var i=r.cloneObj(o);return i.outputCst=!1,t.call(this,n,i)||this}return n(o,t),o}(E);e.EmbeddedActionsParser=b})),Gn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createSyntaxDiagramsCode=void 0;var t=nn();e.createSyntaxDiagramsCode=function(e,n){var r=void 0===n?{}:n,o=r.resourceBase,i=void 0===o?"https://unpkg.com/chevrotain@"+t.VERSION+"/diagrams/":o,a=r.css;return'\n\x3c!-- This is a generated file --\x3e\n<!DOCTYPE html>\n<meta charset="utf-8">\n<style>\n body {\n background-color: hsl(30, 20%, 95%)\n }\n</style>\n\n'+("\n<link rel='stylesheet' href='"+(void 0===a?"https://unpkg.com/chevrotain@"+t.VERSION+"/diagrams/diagrams.css":a)+"'>\n")+("\n<script src='"+i+"vendor/railroad-diagrams.js'><\/script>\n<script src='"+i+"src/diagrams_builder.js'><\/script>\n<script src='"+i+"src/diagrams_behavior.js'><\/script>\n<script src='"+i+"src/main.js'><\/script>\n")+'\n<div id="diagrams" align="center"></div>\n'+("\n<script>\n window.serializedGrammar = "+JSON.stringify(e,null," ")+";\n<\/script>\n")+'\n<script>\n var diagramsDiv = document.getElementById("diagrams");\n main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);\n<\/script>\n'}})),Wn=tn((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Parser=e.createSyntaxDiagramsCode=e.clearCache=e.GAstVisitor=e.serializeProduction=e.serializeGrammar=e.Terminal=e.Rule=e.RepetitionWithSeparator=e.RepetitionMandatoryWithSeparator=e.RepetitionMandatory=e.Repetition=e.Option=e.NonTerminal=e.Alternative=e.Alternation=e.defaultLexerErrorProvider=e.NoViableAltException=e.NotAllInputParsedException=e.MismatchedTokenException=e.isRecognitionException=e.EarlyExitException=e.defaultParserErrorProvider=e.tokenName=e.tokenMatcher=e.tokenLabel=e.EOF=e.createTokenInstance=e.createToken=e.LexerDefinitionErrorType=e.Lexer=e.EMPTY_ALT=e.ParserDefinitionErrorType=e.EmbeddedActionsParser=e.CstParser=e.VERSION=void 0;var t=nn();Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return t.VERSION}});var n=zn();Object.defineProperty(e,"CstParser",{enumerable:!0,get:function(){return n.CstParser}}),Object.defineProperty(e,"EmbeddedActionsParser",{enumerable:!0,get:function(){return n.EmbeddedActionsParser}}),Object.defineProperty(e,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return n.ParserDefinitionErrorType}}),Object.defineProperty(e,"EMPTY_ALT",{enumerable:!0,get:function(){return n.EMPTY_ALT}});var r=dn();Object.defineProperty(e,"Lexer",{enumerable:!0,get:function(){return r.Lexer}}),Object.defineProperty(e,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return r.LexerDefinitionErrorType}});var o=pn();Object.defineProperty(e,"createToken",{enumerable:!0,get:function(){return o.createToken}}),Object.defineProperty(e,"createTokenInstance",{enumerable:!0,get:function(){return o.createTokenInstance}}),Object.defineProperty(e,"EOF",{enumerable:!0,get:function(){return o.EOF}}),Object.defineProperty(e,"tokenLabel",{enumerable:!0,get:function(){return o.tokenLabel}}),Object.defineProperty(e,"tokenMatcher",{enumerable:!0,get:function(){return o.tokenMatcher}}),Object.defineProperty(e,"tokenName",{enumerable:!0,get:function(){return o.tokenName}});var i=Tn();Object.defineProperty(e,"defaultParserErrorProvider",{enumerable:!0,get:function(){return i.defaultParserErrorProvider}});var a=kn();Object.defineProperty(e,"EarlyExitException",{enumerable:!0,get:function(){return a.EarlyExitException}}),Object.defineProperty(e,"isRecognitionException",{enumerable:!0,get:function(){return a.isRecognitionException}}),Object.defineProperty(e,"MismatchedTokenException",{enumerable:!0,get:function(){return a.MismatchedTokenException}}),Object.defineProperty(e,"NotAllInputParsedException",{enumerable:!0,get:function(){return a.NotAllInputParsedException}}),Object.defineProperty(e,"NoViableAltException",{enumerable:!0,get:function(){return a.NoViableAltException}});var s=un();Object.defineProperty(e,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return s.defaultLexerErrorProvider}});var c=fn();Object.defineProperty(e,"Alternation",{enumerable:!0,get:function(){return c.Alternation}}),Object.defineProperty(e,"Alternative",{enumerable:!0,get:function(){return c.Alternative}}),Object.defineProperty(e,"NonTerminal",{enumerable:!0,get:function(){return c.NonTerminal}}),Object.defineProperty(e,"Option",{enumerable:!0,get:function(){return c.Option}}),Object.defineProperty(e,"Repetition",{enumerable:!0,get:function(){return c.Repetition}}),Object.defineProperty(e,"RepetitionMandatory",{enumerable:!0,get:function(){return c.RepetitionMandatory}}),Object.defineProperty(e,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return c.RepetitionMandatoryWithSeparator}}),Object.defineProperty(e,"RepetitionWithSeparator",{enumerable:!0,get:function(){return c.RepetitionWithSeparator}}),Object.defineProperty(e,"Rule",{enumerable:!0,get:function(){return c.Rule}}),Object.defineProperty(e,"Terminal",{enumerable:!0,get:function(){return c.Terminal}});var l=fn();Object.defineProperty(e,"serializeGrammar",{enumerable:!0,get:function(){return l.serializeGrammar}}),Object.defineProperty(e,"serializeProduction",{enumerable:!0,get:function(){return l.serializeProduction}});var u=mn();Object.defineProperty(e,"GAstVisitor",{enumerable:!0,get:function(){return u.GAstVisitor}}),e.clearCache=function(){console.warn("The clearCache function was 'soft' removed from the Chevrotain API.\n\t It performs no action other than printing this message.\n\t Please avoid using it as it will be completely removed in the future")};var d=Gn();Object.defineProperty(e,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return d.createSyntaxDiagramsCode}});var p=function(){throw new Error("The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.\nSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0")};e.Parser=p}))();class Hn extends e{constructor(e){super(e)}load(e,r,o,i){const a=this,s=""===a.path?t.extractUrlBase(e):a.path,c=new n(a.manager);c.setPath(a.path),c.setRequestHeader(a.requestHeader),c.setWithCredentials(a.withCredentials),c.load(e,(function(t){try{r(a.parse(t,s))}catch(t){i?i(t):console.error(t),a.manager.itemError(e)}}),o,i)}parse(e,t){const n={};function a(e){e.DEF&&(n[e.DEF]=e);const t=e.fields;for(let e=0,n=t.length;e<n;e++){const n=t[e];if("node"===n.type){const e=n.values;for(let t=0,n=e.length;t<n;t++)a(e[t])}}}function u(e){return e.USE?function(e){const t=n[e],r=u(t);return r.isObject3D||r.isMaterial?r.clone():r}(e.USE):(void 0!==e.build||(e.build=function(e){const t=e.name;let n;switch(t){case"Anchor":case"Group":case"Transform":case"Collision":n=function(e){const t=new r,n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;switch(o){case"bboxCenter":case"bboxSize":case"center":case"description":case"collide":case"parameter":case"scaleOrientation":case"proxy":case"url":break;case"children":v(i,t);break;case"rotation":const e=new x(i[0],i[1],i[2]),n=i[3];t.quaternion.setFromAxisAngle(e,n);break;case"scale":t.scale.set(i[0],i[1],i[2]);break;case"translation":t.position.set(i[0],i[1],i[2]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(e);break;case"Background":n=function(e){const t=new r;let n,o,i,a;const s=e.fields;for(let e=0,t=s.length;e<t;e++){const t=s[e],r=t.name,c=t.values;switch(r){case"groundAngle":n=c;break;case"groundColor":o=c;break;case"backUrl":case"bottomUrl":case"frontUrl":case"leftUrl":case"rightUrl":case"topUrl":break;case"skyAngle":i=c;break;case"skyColor":a=c;break;default:console.warn("THREE.VRMLLoader: Unknown field:",r)}}const l=1e4;if(a){const e=new J(l,32,16),n=new R({fog:!1,side:Q,depthWrite:!1,depthTest:!1});a.length>3?(K(e,l,i,Y(a),!0),n.vertexColors=!0):n.color.setRGB(a[0],a[1],a[2]);const r=new c(e,n);t.add(r)}if(o&&o.length>0){const e=new J(l,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),r=new R({fog:!1,side:Q,vertexColors:!0,depthWrite:!1,depthTest:!1});K(e,l,n,Y(o),!1);const i=new c(e,r);t.add(i)}return t.renderOrder=-1/0,t}(e);break;case"Shape":n=function(e){const t=e.fields;let n,r,o=new R({color:0});for(let e=0,r=t.length;e<r;e++){const r=t[e],i=r.name,a=r.values;switch(i){case"appearance":null!==a[0]&&(o=u(a[0]));break;case"geometry":null!==a[0]&&(n=u(a[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}if(n&&n.attributes.position){const e=n._type;if("points"===e){const e=new q({color:16777215});void 0!==n.attributes.color?e.vertexColors=!0:o.isMeshPhongMaterial&&e.color.copy(o.emissive),r=new X(n,e)}else if("line"===e){const e=new j({color:16777215});void 0!==n.attributes.color?e.vertexColors=!0:o.isMeshPhongMaterial&&e.color.copy(o.emissive),r=new W(n,e)}else void 0!==n._solid&&(o.side=n._solid?L:i),void 0!==n.attributes.color&&(o.vertexColors=!0),r=new c(n,o)}else r=new Z,r.visible=!1;return r}(e);break;case"Appearance":n=function(e){let t,n=new o;const r=e.fields;for(let e=0,o=r.length;e<o;e++){const o=r[e],i=o.name,a=o.values;switch(i){case"material":if(null!==a[0]){const e=u(a[0]);e.diffuseColor&&n.color.copy(e.diffuseColor),e.emissiveColor&&n.emissive.copy(e.emissiveColor),e.shininess&&(n.shininess=e.shininess),e.specularColor&&n.specular.copy(e.specularColor),e.transparency&&(n.opacity=1-e.transparency),e.transparency>0&&(n.transparent=!0)}else n=new R({color:0});break;case"texture":const e=a[0];null!==e&&("ImageTexture"!==e.name&&"PixelTexture"!==e.name||(n.map=u(e)));break;case"textureTransform":null!==a[0]&&(t=u(a[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}if(n.map){if(n.map.__type){switch(n.map.__type){case $n.INTENSITY_ALPHA:n.opacity=1;break;case $n.RGB:n.color.set(16777215);break;case $n.RGBA:n.color.set(16777215),n.opacity=1}delete n.map.__type}t&&(n.map.center.copy(t.center),n.map.rotation=t.rotation,n.map.repeat.copy(t.scale),n.map.offset.copy(t.translation))}return n}(e);break;case"Material":n=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;switch(o){case"ambientIntensity":break;case"diffuseColor":t.diffuseColor=new p(i[0],i[1],i[2]);break;case"emissiveColor":case"specularColor":t.emissiveColor=new p(i[0],i[1],i[2]);break;case"shininess":t.shininess=i[0];break;case"transparency":t.transparency=i[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(e);break;case"ImageTexture":n=function(e){let t,n=g,r=g;const o=e.fields;for(let e=0,i=o.length;e<i;e++){const i=o[e],a=i.name,s=i.values;switch(a){case"url":const e=s[0];e&&(t=$.load(e));break;case"repeatS":!1===s[0]&&(n=y);break;case"repeatT":!1===s[0]&&(r=y);break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}t&&(t.wrapS=n,t.wrapT=r);return t}(e);break;case"PixelTexture":n=function(e){let t,n=g,r=g;const o=e.fields;for(let e=0,i=o.length;e<i;e++){const i=o[e],a=i.name,s=i.values;switch(a){case"image":const e=s[0],o=s[1],i=m(s[2]),c=new Uint8Array(4*e*o),l={r:0,g:0,b:0,a:0};for(let e=3,t=0,n=s.length;e<n;e++,t++){f(s[e],i,l);const n=4*t;c[n+0]=l.r,c[n+1]=l.g,c[n+2]=l.b,c[n+3]=l.a}t=new ee(c,e,o),t.needsUpdate=!0,t.__type=i;break;case"repeatS":!1===s[0]&&(n=y);break;case"repeatT":!1===s[0]&&(r=y);break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}t&&(t.wrapS=n,t.wrapT=r);return t}(e);break;case"TextureTransform":n=function(e){const t={center:new C,rotation:new C,scale:new C,translation:new C},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;switch(o){case"center":t.center.set(i[0],i[1]);break;case"rotation":t.rotation=i[0];break;case"scale":t.scale.set(i[0],i[1]);break;case"translation":t.translation.set(i[0],i[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(e);break;case"IndexedFaceSet":n=function(e){let t,n,r,o,i,a,c,d,p=!0,f=!0,h=0,m=!0,g=!0;const y=e.fields;for(let e=0,s=y.length;e<s;e++){const s=y[e],l=s.name,v=s.values;switch(l){case"color":const e=v[0];null!==e&&(t=u(e));break;case"coord":const s=v[0];null!==s&&(n=u(s));break;case"normal":const y=v[0];null!==y&&(r=u(y));break;case"texCoord":const E=v[0];null!==E&&(o=u(E));break;case"ccw":p=v[0];break;case"colorIndex":i=v;break;case"colorPerVertex":m=v[0];break;case"convex":break;case"coordIndex":a=v;break;case"creaseAngle":h=v[0];break;case"normalIndex":c=v;break;case"normalPerVertex":g=v[0];break;case"solid":f=v[0];break;case"texCoordIndex":d=v;break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}if(void 0===a)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new s;const v=E(a,p);let A,x,N;if(t)if(!0===m)if(i&&i.length>0){A=F(v,E(i,p),t,3)}else A=V(v,new l(t,3));else if(i&&i.length>0){A=D(v,T(b(t,i),a))}else{A=D(v,T(t,a))}if(r)if(!0===g)if(c&&c.length>0){x=F(v,E(c,p),r,3)}else x=V(v,new l(r,3));else if(c&&c.length>0){x=D(v,T(b(r,c),a))}else{x=D(v,T(r,a))}else x=G(v,n,h);if(o)if(d&&d.length>0){N=F(v,E(d,p),o,2)}else N=V(v,new l(o,2));const R=new s,k=V(v,new l(n,3));R.setAttribute("position",k),R.setAttribute("normal",x),A&&R.setAttribute("color",A);N&&R.setAttribute("uv",N);return R._solid=f,R._type="mesh",R}(e);break;case"IndexedLineSet":n=function(e){let t,n,r,o,i=!0;const a=e.fields;for(let e=0,s=a.length;e<s;e++){const s=a[e],c=s.name,l=s.values;switch(c){case"color":const e=l[0];null!==e&&(t=u(e));break;case"coord":const a=l[0];null!==a&&(n=u(a));break;case"colorIndex":r=l;break;case"colorPerVertex":i=l[0];break;case"coordIndex":o=l;break;default:console.warn("THREE.VRMLLoader: Unknown field:",c)}}let c;const d=A(o);if(t)if(!0===i)if(r.length>0){c=F(d,A(r),t,3)}else c=V(d,new l(t,3));else if(r.length>0){c=U(d,O(b(t,r),o))}else{c=U(d,O(t,o))}const p=new s,f=V(d,new l(n,3));p.setAttribute("position",f),c&&p.setAttribute("color",c);return p._type="line",p}(e);break;case"PointSet":n=function(e){let t,n;const r=e.fields;for(let e=0,o=r.length;e<o;e++){const o=r[e],i=o.name,a=o.values;switch(i){case"color":const e=a[0];null!==e&&(t=u(e));break;case"coord":const r=a[0];null!==r&&(n=u(r));break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}const o=new s;o.setAttribute("position",new l(n,3)),t&&o.setAttribute("color",new l(t,3));return o._type="points",o}(e);break;case"Box":n=function(e){const t=new x(2,2,2),n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;if("size"===o)t.x=i[0],t.y=i[1],t.z=i[2];else console.warn("THREE.VRMLLoader: Unknown field:",o)}return new te(t.x,t.y,t.z)}(e);break;case"Cone":n=function(e){let t=1,n=2,r=!1;const o=e.fields;for(let e=0,i=o.length;e<i;e++){const i=o[e],a=i.name,s=i.values;switch(a){case"bottom":r=!s[0];break;case"bottomRadius":t=s[0];break;case"height":n=s[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return new ne(t,n,16,1,r)}(e);break;case"Cylinder":n=function(e){let t=1,n=2;const r=e.fields;for(let e=0,o=r.length;e<o;e++){const o=r[e],i=o.name,a=o.values;switch(i){case"bottom":case"side":case"top":break;case"radius":t=a[0];break;case"height":n=a[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}return new re(t,t,n,16,1)}(e);break;case"Sphere":n=function(e){let t=1;const n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;if("radius"===o)t=i[0];else console.warn("THREE.VRMLLoader: Unknown field:",o)}return new J(t,16,16)}(e);break;case"ElevationGrid":n=function(e){let t,n,r,o,i=!0,a=!0,c=!0,d=!0,p=0,f=2,h=2,m=1,g=1;const y=e.fields;for(let e=0,s=y.length;e<s;e++){const s=y[e],l=s.name,v=s.values;switch(l){case"color":const e=v[0];null!==e&&(t=u(e));break;case"normal":const s=v[0];null!==s&&(n=u(s));break;case"texCoord":const y=v[0];null!==y&&(r=u(y));break;case"height":o=v;break;case"ccw":d=v[0];break;case"colorPerVertex":i=v[0];break;case"creaseAngle":p=v[0];break;case"normalPerVertex":a=v[0];break;case"solid":c=v[0];break;case"xDimension":f=v[0];break;case"xSpacing":m=v[0];break;case"zDimension":h=v[0];break;case"zSpacing":g=v[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}const v=[],E=[],T=[],b=[];for(let e=0;e<h;e++)for(let s=0;s<f;s++){const c=e*f+s,l=m*e,u=o[c],d=g*s;if(v.push(l,u,d),t&&!0===i){const e=t[3*c+0],n=t[3*c+1],r=t[3*c+2];T.push(e,n,r)}if(n&&!0===a){const e=n[3*c+0],t=n[3*c+1],r=n[3*c+2];E.push(e,t,r)}if(r){const e=r[2*c+0],t=r[2*c+1];b.push(e,t)}else b.push(e/(f-1),s/(h-1))}const A=[];for(let e=0;e<f-1;e++)for(let t=0;t<h-1;t++){const n=e+t*f,r=e+(t+1)*f,o=e+1+(t+1)*f,i=e+1+t*f;!0===d?(A.push(n,o,r),A.push(o,n,i)):(A.push(n,r,o),A.push(o,i,n))}const x=V(A,new l(v,3)),N=V(A,new l(b,2));let R,k;if(t)if(!1===i){for(let e=0;e<f-1;e++)for(let n=0;n<h-1;n++){const r=e+n*(f-1),o=t[3*r+0],i=t[3*r+1],a=t[3*r+2];T.push(o,i,a),T.push(o,i,a),T.push(o,i,a),T.push(o,i,a),T.push(o,i,a),T.push(o,i,a)}R=new l(T,3)}else R=V(A,new l(T,3));if(n)if(!1===a){for(let e=0;e<f-1;e++)for(let t=0;t<h-1;t++){const r=e+t*(f-1),o=n[3*r+0],i=n[3*r+1],a=n[3*r+2];E.push(o,i,a),E.push(o,i,a),E.push(o,i,a),E.push(o,i,a),E.push(o,i,a),E.push(o,i,a)}k=new l(E,3)}else k=V(A,new l(E,3));else k=G(A,v,p);const O=new s;O.setAttribute("position",x),O.setAttribute("normal",k),O.setAttribute("uv",N),R&&O.setAttribute("color",R);return O._solid=c,O._type="mesh",O}(e);break;case"Extrusion":n=function(e){let t,n,r=[1,1,1,-1,-1,-1,-1,1,1,1],o=[0,0,0,0,1,0],i=!0,a=!0,c=0,u=!0,d=!0;const p=e.fields;for(let e=0,s=p.length;e<s;e++){const s=p[e],l=s.name,f=s.values;switch(l){case"beginCap":i=f[0];break;case"ccw":a=f[0];break;case"convex":break;case"creaseAngle":c=f[0];break;case"crossSection":r=f;break;case"endCap":u=f[0];break;case"orientation":n=f;break;case"scale":t=f;break;case"solid":d=f[0];break;case"spine":o=f;break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}const f=r[0]===r[r.length-2]&&r[1]===r[r.length-1],h=[],m=new x,g=new x,y=new x,v=new x,E=new N;for(let e=0,i=0,a=0,s=o.length;e<s;e+=3,i+=2,a+=4){m.fromArray(o,e),g.x=t?t[i+0]:1,g.y=1,g.z=t?t[i+1]:1,y.x=n?n[a+0]:0,y.y=n?n[a+1]:0,y.z=n?n[a+2]:1;const s=n?n[a+3]:0;for(let e=0,t=r.length;e<t;e+=2)v.x=r[e+0],v.y=0,v.z=r[e+1],v.multiply(g),E.setFromAxisAngle(y,s),v.applyQuaternion(E),v.add(m),h.push(v.x,v.y,v.z)}const T=[],b=o.length/3,A=r.length/2;for(let e=0;e<b-1;e++)for(let t=0;t<A-1;t++){const n=t+e*A;let r=t+1+e*A;const o=t+(e+1)*A;let i=t+1+(e+1)*A;t===A-2&&!0===f&&(r=e*A,i=(e+1)*A),!0===a?(T.push(n,r,o),T.push(o,r,i)):(T.push(n,o,r),T.push(o,i,r))}if(!0===i||!0===u){const e=[];for(let t=0,n=r.length;t<n;t+=2)e.push(new C(r[t],r[t+1]));const t=oe.triangulateShape(e,[]),n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e];n.push(r[0],r[1],r[2])}if(!0===i)for(let e=0,t=n.length;e<t;e+=3)!0===a?T.push(n[e+0],n[e+1],n[e+2]):T.push(n[e+0],n[e+2],n[e+1]);if(!0===u){const e=A*(b-1);for(let t=0,r=n.length;t<r;t+=3)!0===a?T.push(e+n[t+0],e+n[t+2],e+n[t+1]):T.push(e+n[t+0],e+n[t+1],e+n[t+2])}}const R=V(T,new l(h,3)),k=G(T,h,c),O=new s;return O.setAttribute("position",R),O.setAttribute("normal",k),O._solid=d,O._type="mesh",O}(e);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":n=function(e){return e.fields[0].values}(e);break;case"WorldInfo":n=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,i=r.values;switch(o){case"title":t.title=i[0];break;case"info":t.info=i;break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(e);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",t)}void 0!==n&&void 0!==e.DEF&&!0===n.hasOwnProperty("name")&&(n.name=e.DEF);return n}(e)),e.build)}function f(e,t,n){let r;switch(t){case $n.INTENSITY:r=parseInt(e),n.r=r,n.g=r,n.b=r,n.a=1;break;case $n.INTENSITY_ALPHA:r=parseInt("0x"+e.substring(2,4)),n.r=r,n.g=r,n.b=r,n.a=parseInt("0x"+e.substring(4,6));break;case $n.RGB:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=1;break;case $n.RGBA:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=parseInt("0x"+e.substring(8,10))}}function m(e){let t;switch(e){case 1:t=$n.INTENSITY;break;case 2:t=$n.INTENSITY_ALPHA;break;case 3:t=$n.RGB;break;case 4:t=$n.RGBA}return t}function v(e,t){for(let n=0,r=e.length;n<r;n++){const r=u(e[n]);r instanceof Z&&t.add(r)}}function E(e,t){const n=[];let r=0;for(let o=0,i=e.length;o<i;o++){const a=e[r],s=e[o+(t?1:2)],c=e[o+(t?2:1)];n.push(a,s,c),(-1===e[o+3]||o+3>=i)&&(o+=3,r=o+1)}return n}function T(e,t){const n=[];let r=0;for(let o=0,i=t.length;o<i;o++){const a=3*r,s=e[a],c=e[a+1],l=e[a+2];n.push(s,c,l),(-1===t[o+3]||o+3>=i)&&(o+=3,r++)}return n}function b(e,t){const n=[];for(let r=0,o=t.length;r<o;r++){const o=3*t[r],i=e[o],a=e[o+1],s=e[o+2];n.push(i,a,s)}return n}function A(e){const t=[];for(let n=0,r=e.length;n<r;n++){const o=e[n],i=e[n+1];t.push(o,i),(-1===e[n+2]||n+2>=r)&&(n+=2)}return t}function O(e,t){const n=[];let r=0;for(let o=0,i=t.length;o<i;o++){const a=3*r,s=e[a],c=e[a+1],l=e[a+2];n.push(s,c,l),(-1===t[o+2]||o+2>=i)&&(o+=2,r++)}return n}const I=new x,_=new x,w=new x,S=new C,P=new C,M=new C;function F(e,t,n,r){const o=[];for(let i=0,a=e.length;i<a;i+=3){const e=t[i],a=t[i+1],s=t[i+2];2===r?(S.fromArray(n,e*r),P.fromArray(n,a*r),M.fromArray(n,s*r),o.push(S.x,S.y),o.push(P.x,P.y),o.push(M.x,M.y)):(I.fromArray(n,e*r),_.fromArray(n,a*r),w.fromArray(n,s*r),o.push(I.x,I.y,I.z),o.push(_.x,_.y,_.z),o.push(w.x,w.y,w.z))}return new l(o,r)}function D(e,t){const n=[];for(let r=0,o=0,i=e.length;r<i;r+=3,o++)I.fromArray(t,3*o),n.push(I.x,I.y,I.z),n.push(I.x,I.y,I.z),n.push(I.x,I.y,I.z);return new l(n,3)}function U(e,t){const n=[];for(let r=0,o=0,i=e.length;r<i;r+=2,o++)I.fromArray(t,3*o),n.push(I.x,I.y,I.z),n.push(I.x,I.y,I.z);return new l(n,3)}function V(e,t){const n=t.array,r=t.itemSize,o=new n.constructor(e.length*r);let i=0,a=0;for(let t=0,s=e.length;t<s;t++){i=e[t]*r;for(let e=0;e<r;e++)o[a++]=n[i++]}return new l(o,r)}const B=new x,z=new x;function G(e,t,n){const r=[],o={};for(let n=0,i=e.length;n<i;n+=3){const i=e[n],a=e[n+1],s=e[n+2],c=new Xn(i,a,s);I.fromArray(t,3*i),_.fromArray(t,3*a),w.fromArray(t,3*s),z.subVectors(w,_),B.subVectors(I,_),z.cross(B),z.normalize(),c.normal.copy(z),void 0===o[i]&&(o[i]=[]),void 0===o[a]&&(o[a]=[]),void 0===o[s]&&(o[s]=[]),o[i].push(c.normal),o[a].push(c.normal),o[s].push(c.normal),r.push(c)}const i=[];for(let e=0,a=r.length;e<a;e++){const a=r[e],s=H(o[a.a],a.normal,n),c=H(o[a.b],a.normal,n),l=H(o[a.c],a.normal,n);I.fromArray(t,3*a.a),_.fromArray(t,3*a.b),w.fromArray(t,3*a.c),i.push(s.x,s.y,s.z),i.push(c.x,c.y,c.z),i.push(l.x,l.y,l.z)}return new l(i,3)}function H(e,t,n){const r=new x;if(0===n)r.copy(t);else for(let o=0,i=e.length;o<i;o++)e[o].angleTo(t)<n&&r.add(e[o]);return r.normalize()}function Y(e){const t=[];for(let n=0,r=e.length;n<r;n+=3)t.push(new p(e[n],e[n+1],e[n+2]));return t}function K(e,t,n,r,o){const i=[],a=!0===o?0:Math.PI;for(let e=0,s=r.length;e<s;e++){let r=0===e?0:n[e-1];r=!0===o?r:a-r;const s=new x;s.setFromSphericalCoords(t,r,0),i.push(s)}const s=e.index,c=e.attributes.position,l=new h(new Float32Array(3*e.attributes.position.count),3),u=new x,d=new p;for(let e=0;e<s.count;e++){const t=s.getX(e);let n,a;u.fromBufferAttribute(c,t);let p=1;for(let e=1;e<i.length;e++){n=e-1,a=e;const t=i[n],r=i[a];if(!0===o){if(u.y<=t.y&&u.y>r.y){p=Math.abs(t.y-u.y)/Math.abs(t.y-r.y);break}}else if(u.y>=t.y&&u.y<r.y){p=Math.abs(t.y-u.y)/Math.abs(t.y-r.y);break}}const f=r[n],h=r[a];d.copy(f).lerp(h,p),l.setXYZ(t,d.r,d.g,d.b)}e.setAttribute("color",l)}const $=new d(this.manager);if($.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),-1===e.indexOf("#VRML V2.0"))throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const ie=function(e){const t=function(){const e=Wn.createToken,t=e({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),n=e({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,longer_alt:t}),r=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],o=e({name:"Version",pattern:/#VRML.*/,longer_alt:n}),i=e({name:"NodeName",pattern:new RegExp(r.join("|")),longer_alt:n}),a=e({name:"DEF",pattern:/DEF/,longer_alt:n}),s=e({name:"USE",pattern:/USE/,longer_alt:n}),c=e({name:"ROUTE",pattern:/ROUTE/,longer_alt:n}),l=e({name:"TO",pattern:/TO/,longer_alt:n}),u=e({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),d=e({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),p=e({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),f=e({name:"TrueLiteral",pattern:/TRUE/}),h=e({name:"FalseLiteral",pattern:/FALSE/}),m=e({name:"NullLiteral",pattern:/NULL/}),g=e({name:"LSquare",pattern:/\[/}),y=e({name:"RSquare",pattern:/]/}),v=e({name:"LCurly",pattern:/{/}),E=e({name:"RCurly",pattern:/}/}),T=e({name:"Comment",pattern:/#.*/,group:Wn.Lexer.SKIPPED}),b=[e({name:"WhiteSpace",pattern:/[ ,\s]/,group:Wn.Lexer.SKIPPED}),i,a,s,c,l,f,h,m,o,n,t,u,d,p,g,y,v,E,T],A={};for(let e=0,t=b.length;e<t;e++){const t=b[e];A[t.name]=t}return{tokens:b,tokenVocabulary:A}}(),n=new Yn(t.tokens),r=new qn(t.tokenVocabulary),o=function(e){class t extends e{constructor(){super(),this.validateVisitor()}vrml(e){const t={version:this.visit(e.version),nodes:[],routes:[]};for(let n=0,r=e.node.length;n<r;n++){const r=e.node[n];t.nodes.push(this.visit(r))}if(e.route)for(let n=0,r=e.route.length;n<r;n++){const r=e.route[n];t.routes.push(this.visit(r))}return t}version(e){return e.Version[0].image}node(e){const t={name:e.NodeName[0].image,fields:[]};if(e.field)for(let n=0,r=e.field.length;n<r;n++){const r=e.field[n];t.fields.push(this.visit(r))}return e.def&&(t.DEF=this.visit(e.def[0])),t}field(e){const t={name:e.Identifier[0].image,type:null,values:null};let n;return e.singleFieldValue&&(n=this.visit(e.singleFieldValue[0])),e.multiFieldValue&&(n=this.visit(e.multiFieldValue[0])),t.type=n.type,t.values=n.values,t}def(e){return(e.Identifier||e.NodeName)[0].image}use(e){return{USE:(e.Identifier||e.NodeName)[0].image}}singleFieldValue(e){return n(this,e)}multiFieldValue(e){return n(this,e)}route(e){return{FROM:e.RouteIdentifier[0].image,TO:e.RouteIdentifier[1].image}}}function n(e,t){const n={type:null,values:[]};if(t.node){n.type="node";for(let r=0,o=t.node.length;r<o;r++){const o=t.node[r];n.values.push(e.visit(o))}}if(t.use){n.type="use";for(let r=0,o=t.use.length;r<o;r++){const o=t.use[r];n.values.push(e.visit(o))}}if(t.StringLiteral){n.type="string";for(let e=0,r=t.StringLiteral.length;e<r;e++){const r=t.StringLiteral[e];n.values.push(r.image.replace(/'|"/g,""))}}if(t.NumberLiteral){n.type="number";for(let e=0,r=t.NumberLiteral.length;e<r;e++){const r=t.NumberLiteral[e];n.values.push(parseFloat(r.image))}}if(t.HexLiteral){n.type="hex";for(let e=0,r=t.HexLiteral.length;e<r;e++){const r=t.HexLiteral[e];n.values.push(r.image)}}if(t.TrueLiteral){n.type="boolean";for(let e=0,r=t.TrueLiteral.length;e<r;e++){"TRUE"===t.TrueLiteral[e].image&&n.values.push(!0)}}if(t.FalseLiteral){n.type="boolean";for(let e=0,r=t.FalseLiteral.length;e<r;e++){"FALSE"===t.FalseLiteral[e].image&&n.values.push(!1)}}return t.NullLiteral&&(n.type="null",t.NullLiteral.forEach((function(){n.values.push(null)}))),n}return new t}(r.getBaseCstVisitorConstructor()),i=n.lex(e);r.input=i.tokens;const a=r.vrml();if(r.errors.length>0)throw console.error(r.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return o.visit(a)}(e),ae=function(e){const t=e.nodes,n=new k;for(let e=0,n=t.length;e<n;e++){a(t[e])}for(let e=0,r=t.length;e<r;e++){const r=t[e],o=u(r);o instanceof Z&&n.add(o),"WorldInfo"===r.name&&(n.userData.worldInfo=o)}return n}(ie);return ae}}class Yn{constructor(e){this.lexer=new Wn.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}const Kn=Wn.CstParser;class qn extends Kn{constructor(e){super(e);const t=this,n=e.Version,r=e.LCurly,o=e.RCurly,i=e.LSquare,a=e.RSquare,s=e.Identifier,c=e.RouteIdentifier,l=e.StringLiteral,u=e.HexLiteral,d=e.NumberLiteral,p=e.TrueLiteral,f=e.FalseLiteral,h=e.NullLiteral,m=e.DEF,g=e.USE,y=e.ROUTE,v=e.TO,E=e.NodeName;t.RULE("vrml",(function(){t.SUBRULE(t.version),t.AT_LEAST_ONE((function(){t.SUBRULE(t.node)})),t.MANY((function(){t.SUBRULE(t.route)}))})),t.RULE("version",(function(){t.CONSUME(n)})),t.RULE("node",(function(){t.OPTION((function(){t.SUBRULE(t.def)})),t.CONSUME(E),t.CONSUME(r),t.MANY((function(){t.SUBRULE(t.field)})),t.CONSUME(o)})),t.RULE("field",(function(){t.CONSUME(s),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])})),t.RULE("def",(function(){t.CONSUME(m),t.OR([{ALT:function(){t.CONSUME(s)}},{ALT:function(){t.CONSUME(E)}}])})),t.RULE("use",(function(){t.CONSUME(g),t.OR([{ALT:function(){t.CONSUME(s)}},{ALT:function(){t.CONSUME(E)}}])})),t.RULE("singleFieldValue",(function(){t.AT_LEAST_ONE((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}}])}))})),t.RULE("multiFieldValue",(function(){t.CONSUME(i),t.MANY((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(h)}}])})),t.CONSUME(a)})),t.RULE("route",(function(){t.CONSUME(y),t.CONSUME(c),t.CONSUME(v),t.CONSUME2(c)})),this.performSelfAnalysis()}}class Xn{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new x}}const $n={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4},Zn="16",Jn="24",Qn=f,er=new x,tr=new x;class nr extends ae{constructor(e){super({uniforms:se.merge([ce.fog,{diffuse:{value:new p},opacity:{value:1}}]),vertexShader:"\n\t\t\t\tattribute vec3 control0;\n\t\t\t\tattribute vec3 control1;\n\t\t\t\tattribute vec3 direction;\n\t\t\t\tvarying float discardFlag;\n\n\t\t\t\t#include <common>\n\t\t\t\t#include <color_pars_vertex>\n\t\t\t\t#include <fog_pars_vertex>\n\t\t\t\t#include <logdepthbuf_pars_vertex>\n\t\t\t\t#include <clipping_planes_pars_vertex>\n\t\t\t\tvoid main() {\n\t\t\t\t\t#include <color_vertex>\n\n\t\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t\t// Transform the line segment ends and control points into camera clip space\n\t\t\t\t\tvec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );\n\t\t\t\t\tvec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );\n\t\t\t\t\tvec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tvec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );\n\n\t\t\t\t\tc0.xy /= c0.w;\n\t\t\t\t\tc1.xy /= c1.w;\n\t\t\t\t\tp0.xy /= p0.w;\n\t\t\t\t\tp1.xy /= p1.w;\n\n\t\t\t\t\t// Get the direction of the segment and an orthogonal vector\n\t\t\t\t\tvec2 dir = p1.xy - p0.xy;\n\t\t\t\t\tvec2 norm = vec2( -dir.y, dir.x );\n\n\t\t\t\t\t// Get control point directions from the line\n\t\t\t\t\tvec2 c0dir = c0.xy - p1.xy;\n\t\t\t\t\tvec2 c1dir = c1.xy - p1.xy;\n\n\t\t\t\t\t// If the vectors to the controls points are pointed in different directions away\n\t\t\t\t\t// from the line segment then the line should not be drawn.\n\t\t\t\t\tfloat d0 = dot( normalize( norm ), normalize( c0dir ) );\n\t\t\t\t\tfloat d1 = dot( normalize( norm ), normalize( c1dir ) );\n\t\t\t\t\tdiscardFlag = float( sign( d0 ) != sign( d1 ) );\n\n\t\t\t\t\t#include <logdepthbuf_vertex>\n\t\t\t\t\t#include <clipping_planes_vertex>\n\t\t\t\t\t#include <fog_vertex>\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\tuniform vec3 diffuse;\n\t\t\tuniform float opacity;\n\t\t\tvarying float discardFlag;\n\n\t\t\t#include <common>\n\t\t\t#include <color_pars_fragment>\n\t\t\t#include <fog_pars_fragment>\n\t\t\t#include <logdepthbuf_pars_fragment>\n\t\t\t#include <clipping_planes_pars_fragment>\n\t\t\tvoid main() {\n\n\t\t\t\tif ( discardFlag > 0.5 ) discard;\n\n\t\t\t\t#include <clipping_planes_fragment>\n\t\t\t\tvec3 outgoingLight = vec3( 0.0 );\n\t\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\t\t\t#include <logdepthbuf_fragment>\n\t\t\t\t#include <color_fragment>\n\t\t\t\toutgoingLight = diffuseColor.rgb; // simple shader\n\t\t\t\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t\t\t\t#include <tonemapping_fragment>\n\t\t\t\t#include <encodings_fragment>\n\t\t\t\t#include <fog_fragment>\n\t\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t}\n\t\t\t"}),Object.defineProperties(this,{opacity:{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},color:{get:function(){return this.uniforms.diffuse.value}}}),this.setValues(e),this.isLDrawConditionalLineMaterial=!0}}class rr extends W{constructor(e,t){super(e,t),this.isConditionalLine=!0}}const or=new ie;function ir(e){return"Part"===e||"Unofficial_Part"===e}class ar{constructor(e,t){this.line=e,this.lineLength=e.length,this.currentCharIndex=0,this.currentChar=" ",this.lineNumber=t}seekNonSpace(){for(;this.currentCharIndex<this.lineLength;){if(this.currentChar=this.line.charAt(this.currentCharIndex)," "!==this.currentChar&&"\t"!==this.currentChar)return;this.currentCharIndex++}}getToken(){const e=this.currentCharIndex++;for(;this.currentCharIndex<this.lineLength&&(this.currentChar=this.line.charAt(this.currentCharIndex)," "!==this.currentChar&&"\t"!==this.currentChar);)this.currentCharIndex++;const t=this.currentCharIndex;return this.seekNonSpace(),this.line.substring(e,t)}getVector(){return new x(parseFloat(this.getToken()),parseFloat(this.getToken()),parseFloat(this.getToken()))}getRemainingString(){return this.line.substring(this.currentCharIndex,this.lineLength)}isAtTheEnd(){return this.currentCharIndex>=this.lineLength}setToEnd(){this.currentCharIndex=this.lineLength}getLineNumberString(){return this.lineNumber>=0?" at line "+this.lineNumber:""}}class sr{constructor(e){this.loader=e,this._cache={}}cloneResult(e){const t={};return t.faces=e.faces.map((e=>({colorCode:e.colorCode,material:e.material,vertices:e.vertices.map((e=>e.clone())),normals:e.normals.map((()=>null)),faceNormal:null}))),t.conditionalSegments=e.conditionalSegments.map((e=>({colorCode:e.colorCode,material:e.material,vertices:e.vertices.map((e=>e.clone())),controlPoints:e.controlPoints.map((e=>e.clone()))}))),t.lineSegments=e.lineSegments.map((e=>({colorCode:e.colorCode,material:e.material,vertices:e.vertices.map((e=>e.clone()))}))),t.type=e.type,t.category=e.category,t.keywords=e.keywords,t.author=e.author,t.subobjects=e.subobjects,t.fileName=e.fileName,t.totalFaces=e.totalFaces,t.startingBuildingStep=e.startingBuildingStep,t.materials=e.materials,t.group=null,t}async fetchData(e){let t=!1,r=0;for(;6!==r;){let o=e;switch(r){case 3:r+=1;break;case 0:o="parts/"+o,r+=1;break;case 1:o="p/"+o,r+=1;break;case 2:o="models/"+o,r+=1;break;case 4:o=e.substring(0,e.lastIndexOf("/")+1)+o,r+=1;break;case 5:t?r=6:(o=e=e.toLowerCase(),t=!0,r=0)}const i=this.loader,a=new n(i.manager);a.setPath(i.partsLibraryPath),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials);try{return await a.loadAsync(o)}catch{continue}}throw new Error('LDrawLoader: Subobject "'+e+'" could not be loaded.')}parse(e,t=null){const n=this.loader,r=[],o=[],i=[],a=[],s={},c=e=>s[e]||null;let l="Model",d=null,p=null,f=null,h=0;-1!==e.indexOf("\r\n")&&(e=e.replace(/\r\n/g,"\n"));const m=e.split("\n"),g=m.length;let y=!1,v=null,E=null,T=!1,b=!0,A=!1,x=!0,N=!1;for(let e=0;e<g;e++){const t=m[e];if(0===t.length)continue;if(y){t.startsWith("0 FILE ")?(this.setData(v,E),v=t.substring(7),E=""):E+=t+"\n";continue}const g=new ar(t,e+1);if(g.seekNonSpace(),g.isAtTheEnd())continue;const R=g.getToken();let k,O,I,_,w,S,C,L,P,M,F;switch(R){case"0":const t=g.getToken();if(t)switch(t){case"!LDRAW_ORG":l=g.getToken();break;case"!COLOUR":k=n.parseColorMetaDirective(g),k?s[k.userData.code]=k:console.warn("LDrawLoader: Error parsing material"+g.getLineNumberString());break;case"!CATEGORY":d=g.getToken();break;case"!KEYWORDS":const t=g.getRemainingString().split(",");t.length>0&&(p||(p=[]),t.forEach((function(e){p.push(e.trim())})));break;case"FILE":e>0&&(y=!0,v=g.getRemainingString(),E="",T=!1,b=!0);break;case"BFC":for(;!g.isAtTheEnd();){const e=g.getToken();switch(e){case"CERTIFY":case"NOCERTIFY":T="CERTIFY"===e,b=!0;break;case"CW":case"CCW":b="CCW"===e;break;case"INVERTNEXT":A=!0;break;case"CLIP":case"NOCLIP":x="CLIP"===e;break;default:console.warn('THREE.LDrawLoader: BFC directive "'+e+'" is unknown.')}}break;case"STEP":N=!0;break;case"Author:":f=g.getToken()}break;case"1":O=g.getToken(),k=c(O);const m=parseFloat(g.getToken()),D=parseFloat(g.getToken()),U=parseFloat(g.getToken()),V=parseFloat(g.getToken()),B=parseFloat(g.getToken()),j=parseFloat(g.getToken()),z=parseFloat(g.getToken()),G=parseFloat(g.getToken()),W=parseFloat(g.getToken()),H=parseFloat(g.getToken()),Y=parseFloat(g.getToken()),K=parseFloat(g.getToken()),q=(new u).set(V,B,j,m,z,G,W,D,H,Y,K,U,0,0,0,1);let X=g.getRemainingString().trim().replace(/\\/g,"/");n.fileMap[X]?X=n.fileMap[X]:X.startsWith("s/")?X="parts/"+X:X.startsWith("48/")&&(X="p/"+X),a.push({material:k,colorCode:O,matrix:q,fileName:X,inverted:A,startingBuildingStep:N}),N=!1,A=!1;break;case"2":O=g.getToken(),k=c(O),S=g.getVector(),C=g.getVector(),I={material:k,colorCode:O,vertices:[S,C]},o.push(I);break;case"5":O=g.getToken(),k=c(O),S=g.getVector(),C=g.getVector(),M=g.getVector(),F=g.getVector(),I={material:k,colorCode:O,vertices:[S,C],controlPoints:[M,F]},i.push(I);break;case"3":O=g.getToken(),k=c(O),_=b,w=!T||!x,!0===_?(S=g.getVector(),C=g.getVector(),L=g.getVector()):(L=g.getVector(),C=g.getVector(),S=g.getVector()),r.push({material:k,colorCode:O,faceNormal:null,vertices:[S,C,L],normals:[null,null,null]}),h++,!0===w&&(r.push({material:k,colorCode:O,faceNormal:null,vertices:[L,C,S],normals:[null,null,null]}),h++);break;case"4":O=g.getToken(),k=c(O),_=b,w=!T||!x,!0===_?(S=g.getVector(),C=g.getVector(),L=g.getVector(),P=g.getVector()):(P=g.getVector(),L=g.getVector(),C=g.getVector(),S=g.getVector()),r.push({material:k,colorCode:O,faceNormal:null,vertices:[S,C,L,P],normals:[null,null,null,null]}),h+=2,!0===w&&(r.push({material:k,colorCode:O,faceNormal:null,vertices:[P,L,C,S],normals:[null,null,null,null]}),h+=2);break;default:throw new Error('LDrawLoader: Unknown line type "'+R+'"'+g.getLineNumberString()+".")}}return y&&this.setData(v,E),{faces:r,conditionalSegments:i,lineSegments:o,type:l,category:d,keywords:p,author:f,subobjects:a,totalFaces:h,startingBuildingStep:N,materials:s,fileName:t,group:null}}getData(e,t=!0){const n=e.toLowerCase(),r=this._cache[n];return null===r||r instanceof Promise?null:t?this.cloneResult(r):r}async ensureDataLoaded(e){const t=e.toLowerCase();t in this._cache||(this._cache[t]=this.fetchData(e).then((n=>{const r=this.parse(n,e);return this._cache[t]=r,r}))),await this._cache[t]}setData(e,t){const n=e.toLowerCase();this._cache[n]=this.parse(t,e)}}function cr(e,t,n,r){return(!r&&e===Zn||r&&e===Jn)&&(e=t),n[e]||null}class lr{constructor(e){this.loader=e,this.parseCache=new sr(e),this._cache={}}async processIntoMesh(e){const t=this.loader,n=this.parseCache,o=new Set,i=async(e,a=null)=>{const s=e.subobjects,c=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],r=n.ensureDataLoaded(t.fileName).then((()=>{const e=n.getData(t.fileName,!1);return r=e.type,/primitive/i.test(r)||"Subpart"===r?i(n.getData(t.fileName),t):this.loadModel(t.fileName).catch((e=>(console.warn(e),null)));var r}));c.push(r)}const l=new r;l.userData.category=e.category,l.userData.keywords=e.keywords,l.userData.author=e.author,l.userData.type=e.type,l.userData.fileName=e.fileName,e.group=l;const u=await Promise.all(c);for(let n=0,r=u.length;n<r;n++){const r=e.subobjects[n],i=u[n];if(null===i)continue;if(i.isGroup){const n=i;r.matrix.decompose(n.position,n.quaternion,n.scale),n.userData.startingBuildingStep=r.startingBuildingStep,n.name=r.fileName,t.applyMaterialsToMesh(n,r.colorCode,e.materials),n.userData.colorCode=r.colorCode,l.add(n);continue}i.group.children.length&&l.add(i.group);const a=e.lineSegments,s=e.conditionalSegments,c=e.faces,d=i.lineSegments,p=i.conditionalSegments,f=i.faces,h=r.matrix,m=r.inverted,g=h.determinant()<0,y=r.colorCode,v=y===Zn?Jn:y;for(let t=0,n=d.length;t<n;t++){const n=d[t],r=n.vertices;r[0].applyMatrix4(h),r[1].applyMatrix4(h),n.colorCode=n.colorCode===Jn?v:n.colorCode,n.material=n.material||cr(n.colorCode,n.colorCode,e.materials,!0),a.push(n)}for(let t=0,n=p.length;t<n;t++){const n=p[t],r=n.vertices,o=n.controlPoints;r[0].applyMatrix4(h),r[1].applyMatrix4(h),o[0].applyMatrix4(h),o[1].applyMatrix4(h),n.colorCode=n.colorCode===Jn?v:n.colorCode,n.material=n.material||cr(n.colorCode,n.colorCode,e.materials,!0),s.push(n)}for(let t=0,n=f.length;t<n;t++){const n=f[t],r=n.vertices;for(let e=0,t=r.length;e<t;e++)r[e].applyMatrix4(h);n.colorCode=n.colorCode===Zn?y:n.colorCode,n.material=n.material||cr(n.colorCode,y,e.materials,!1),o.add(n.colorCode),g!==m&&r.reverse(),c.push(n)}e.totalFaces+=i.totalFaces}return a&&(t.applyMaterialsToMesh(l,a.colorCode,e.materials),l.userData.colorCode=a.colorCode),e};for(let t=0,n=e.faces;t<n;t++)o.add(e.faces[t].colorCode);if(await i(e),t.smoothNormals){const t=o.size>1;!function(e){for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.vertices,o=r[0],i=r[1],a=r[2];er.subVectors(i,o),tr.subVectors(a,i),n.faceNormal=(new x).crossVectors(er,tr).normalize()}}(e.faces),function(e,t,n=!1){const r=100*(1+1e-10);function o(e){return`${~~(e.x*r)},${~~(e.y*r)},${~~(e.z*r)}`}function i(e,t){return`${o(e)}_${o(t)}`}function a(e,t,n){n.direction.subVectors(t,e).normalize();const r=e.dot(n.direction);return n.origin.copy(e).addScaledVector(n.direction,-r),n}function s(e){return i(e.origin,e.direction)}const c=new Set,l=new Map,u={},d=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].vertices,o=r[0],u=r[1];if(c.add(i(o,u)),c.add(i(u,o)),n){const e=a(o,u,new ie),t=s(e);if(!l.has(t)){a(u,o,e);const n=s(e),r={ray:e,distances:[]};l.set(t,r),l.set(n,r)}const n=l.get(t);let r=n.ray.direction.dot(o),i=n.ray.direction.dot(u);r>i&&([r,i]=[i,r]),n.distances.push(r,i)}}for(let t=0,r=e.length;t<r;t++){const r=e[t],o=r.vertices,d=o.length;for(let e=0;e<d;e++){const t=e,p=(e+1)%d,f=o[t],h=o[p],m=i(f,h);if(c.has(m))continue;if(n){a(f,h,or);const e=s(or);if(l.has(e)){const t=l.get(e),{ray:n,distances:r}=t;let o=n.direction.dot(f),i=n.direction.dot(h);o>i&&([o,i]=[i,o]);let a=!1;for(let e=0,t=r.length;e<t;e+=2)if(o>=r[e]&&i<=r[e+1]){a=!0;break}if(a)continue}}const g={index:t,tri:r};u[m]=g}}for(;;){let e=null;for(const t in u){e=u[t];break}if(null===e)break;const t=[e];for(;t.length>0;){const e=t.pop().tri,n=e.vertices,r=e.normals,o=e.faceNormal,a=n.length;for(let s=0;s<a;s++){const c=s,l=(s+1)%a,p=n[c],f=n[l];delete u[i(p,f)];const h=i(f,p),m=u[h];if(m){const n=m.tri,i=m.index,a=n.normals,s=a.length,p=n.faceNormal;if(Math.abs(n.faceNormal.dot(e.faceNormal))<.25)continue;h in u&&(t.push(m),delete u[h]);const f=(i+1)%s;r[c]&&a[f]&&r[c]!==a[f]&&(a[f].norm.add(r[c].norm),r[c].norm=a[f].norm);let g=r[c]||a[f];null===g&&(g={norm:new x},d.push(g.norm)),null===r[c]&&(r[c]=g,g.norm.add(o)),null===a[f]&&(a[f]=g,g.norm.add(p)),r[l]&&a[i]&&r[l]!==a[i]&&(a[i].norm.add(r[l].norm),r[l].norm=a[i].norm);let y=r[l]||a[i];null===y&&(y={norm:new x},d.push(y.norm)),null===r[l]&&(r[l]=y,y.norm.add(o)),null===a[i]&&(a[i]=y,y.norm.add(p))}}}}for(let e=0,t=d.length;e<t;e++)d[e].normalize()}(e.faces,e.lineSegments,t)}const a=e.group;return e.faces.length>0&&a.add(dr(e.faces,3,!1,e.totalFaces)),e.lineSegments.length>0&&a.add(dr(e.lineSegments,2)),e.conditionalSegments.length>0&&a.add(dr(e.conditionalSegments,2,!0)),a}hasCachedModel(e){return null!==e&&e.toLowerCase()in this._cache}async getCachedModel(e){if(null!==e&&this.hasCachedModel(e)){const t=e.toLowerCase();return(await this._cache[t]).clone()}return null}async loadModel(e){const t=this.parseCache,n=e.toLowerCase();if(this.hasCachedModel(e))return this.getCachedModel(e);{await t.ensureDataLoaded(e);const r=t.getData(e),o=this.processIntoMesh(r);if(this.hasCachedModel(e))return this.getCachedModel(e);ir(r.type)&&(this._cache[n]=o);return(await o).clone()}}async parseModel(e){const t=this.parseCache.parse(e);return ir(t.type)&&this.hasCachedModel(t.fileName)?this.getCachedModel(t.fileName):this.processIntoMesh(t)}}function ur(e,t){return e.colorCode===t.colorCode?0:e.colorCode<t.colorCode?-1:1}function dr(e,t,n=!1,r=null){e.sort(ur),null===r&&(r=e.length);const o=new Float32Array(t*r*3),i=3===t?new Float32Array(t*r*3):null,a=[],l=new Array(6),u=new s;let d=null,p=0,f=0,m=0;for(let r=0,s=e.length;r<s;r++){const s=e[r];let c=s.vertices;4===c.length&&(l[0]=c[0],l[1]=c[1],l[2]=c[2],l[3]=c[0],l[4]=c[2],l[5]=c[3],c=l);for(let e=0,t=c.length;e<t;e++){const t=c[e],n=m+3*e;o[n+0]=t.x,o[n+1]=t.y,o[n+2]=t.z}if(3===t){if(!s.faceNormal){const e=c[0],t=c[1],n=c[2];er.subVectors(t,e),tr.subVectors(n,t),s.faceNormal=(new x).crossVectors(er,tr).normalize()}let e=s.normals;4===e.length&&(l[0]=e[0],l[1]=e[1],l[2]=e[2],l[3]=e[0],l[4]=e[2],l[5]=e[3],e=l);for(let t=0,n=e.length;t<n;t++){let n=s.faceNormal;e[t]&&(n=e[t].norm);const r=m+3*t;i[r+0]=n.x,i[r+1]=n.y,i[r+2]=n.z}}if(d!==s.colorCode){null!==d&&u.addGroup(p,f,a.length-1);const e=s.material;null!==e?3===t?a.push(e):2===t&&(n?a.push(e.userData.edgeMaterial.userData.conditionalEdgeMaterial):a.push(e.userData.edgeMaterial)):a.push(s.colorCode),d=s.colorCode,p=m/3,f=c.length}else f+=c.length;m+=3*c.length}f>0&&u.addGroup(p,1/0,a.length-1),u.setAttribute("position",new h(o,3)),null!==i&&u.setAttribute("normal",new h(i,3));let g=null;if(2===t?g=n?new rr(u,1===a.length?a[0]:a):new W(u,1===a.length?a[0]:a):3===t&&(g=new c(u,1===a.length?a[0]:a)),n){g.isConditionalLine=!0;const t=new Float32Array(3*e.length*2),n=new Float32Array(3*e.length*2),r=new Float32Array(3*e.length*2);for(let o=0,i=e.length;o<i;o++){const i=e[o],a=i.vertices,s=i.controlPoints,c=s[0],l=s[1],u=a[0],d=a[1],p=3*o*2;t[p+0]=c.x,t[p+1]=c.y,t[p+2]=c.z,t[p+3]=c.x,t[p+4]=c.y,t[p+5]=c.z,n[p+0]=l.x,n[p+1]=l.y,n[p+2]=l.z,n[p+3]=l.x,n[p+4]=l.y,n[p+5]=l.z,r[p+0]=d.x-u.x,r[p+1]=d.y-u.y,r[p+2]=d.z-u.z,r[p+3]=d.x-u.x,r[p+4]=d.y-u.y,r[p+5]=d.z-u.z}u.setAttribute("control0",new h(t,3,!1)),u.setAttribute("control1",new h(n,3,!1)),u.setAttribute("direction",new h(r,3,!1))}return g}class pr extends e{constructor(e){super(e),this.materials=[],this.materialLibrary={},this.partsCache=new lr(this),this.fileMap={},this.setMaterials([]),this.smoothNormals=!0,this.partsLibraryPath="",this.missingColorMaterial=new m({color:16711935,roughness:.3,metalness:0}),this.missingColorMaterial.name="Missing material",this.missingEdgeColorMaterial=new j({color:16711935}),this.missingEdgeColorMaterial.name="Missing material - Edge",this.missingConditionalEdgeColorMaterial=new nr({fog:!0,color:16711935}),this.missingConditionalEdgeColorMaterial.name="Missing material - Conditional Edge",this.missingColorMaterial.userData.edgeMaterial=this.missingEdgeColorMaterial,this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial=this.missingConditionalEdgeColorMaterial}setPartsLibraryPath(e){return this.partsLibraryPath=e,this}async preloadMaterials(e){const t=new n(this.manager);t.setPath(this.path),t.setRequestHeader(this.requestHeader),t.setWithCredentials(this.withCredentials);const r=/^0 !COLOUR/,o=(await t.loadAsync(e)).split(/[\n\r]/g),i=[];for(let e=0,t=o.length;e<t;e++){const t=o[e];if(r.test(t)){const e=t.replace(r,""),n=this.parseColorMetaDirective(new ar(e));i.push(n)}}this.setMaterials(i)}load(e,t,r,o){const i=new n(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(n=>{this.partsCache.parseModel(n,this.materialLibrary).then((n=>{this.applyMaterialsToMesh(n,Zn,this.materialLibrary,!0),this.computeBuildingSteps(n),n.userData.fileName=e,t(n)})).catch(o)}),r,o)}parse(e,t){this.partsCache.parseModel(e,this.materialLibrary).then((e=>{this.applyMaterialsToMesh(e,Zn,this.materialLibrary,!0),this.computeBuildingSteps(e),e.userData.fileName="",t(e)}))}setMaterials(e){this.materialLibrary={},this.materials=[];for(let t=0,n=e.length;t<n;t++)this.addMaterial(e[t]);return this.addMaterial(this.parseColorMetaDirective(new ar("Main_Colour CODE 16 VALUE #FF8080 EDGE #333333"))),this.addMaterial(this.parseColorMetaDirective(new ar("Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333"))),this}setFileMap(e){return this.fileMap=e,this}addMaterial(e){const t=this.materialLibrary;return t[e.userData.code]||(this.materials.push(e),t[e.userData.code]=e),this}getMaterial(e){if(e.startsWith("0x2")){const t=e.substring(3);return this.parseColorMetaDirective(new ar("Direct_Color_"+t+" CODE -1 VALUE #"+t+" EDGE #"+t))}return this.materialLibrary[e]||null}applyMaterialsToMesh(e,t,n,r=!1){const o=this,i=t===Zn;function a(e,a){if(i&&!(a in n)&&!r)return a;const s=e.isLineSegments||e.isConditionalLine;(!s&&a===Zn||s&&a===Jn)&&(a=t);let c=null;if(a in n)c=n[a];else{if(!r)return a;c=o.getMaterial(a),null===c&&(console.warn(`LDrawLoader: Material properties for code ${a} not available.`),c=o.missingColorMaterial)}return e.isLineSegments&&(c=c.userData.edgeMaterial,e.isConditionalLine&&(c=c.userData.conditionalEdgeMaterial)),c}e.traverse((e=>{if(e.isMesh||e.isLineSegments)if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)e.material[t].isMaterial||(e.material[t]=a(e,e.material[t]));else e.material.isMaterial||(e.material=a(e,e.material))}))}getMainMaterial(){return this.getMaterial(Zn)}getMainEdgeMaterial(){const e=this.getMaterial(Jn);return e?e.userData.edgeMaterial:null}parseColorMetaDirective(e){let t=null,n="#FF00FF",r="#FF00FF",o=1,i=!1,a=0,s=0,c=null;const l=e.getToken();if(!l)throw new Error('LDrawLoader: Material name was expected after "!COLOUR tag'+e.getLineNumberString()+".");let u=null;for(;u=e.getToken(),u;)if(!f(u))switch(u.toUpperCase()){case"CODE":t=e.getToken();break;case"VALUE":if(n=e.getToken(),n.startsWith("0x"))n="#"+n.substring(2);else if(!n.startsWith("#"))throw new Error("LDrawLoader: Invalid color while parsing material"+e.getLineNumberString()+".");break;case"EDGE":if(r=e.getToken(),r.startsWith("0x"))r="#"+r.substring(2);else if(!r.startsWith("#")){if(c=this.getMaterial(r),!c)throw new Error("LDrawLoader: Invalid edge color while parsing material"+e.getLineNumberString()+".");c=c.userData.edgeMaterial}break;case"ALPHA":if(o=parseInt(e.getToken()),isNaN(o))throw new Error("LDrawLoader: Invalid alpha value in material definition"+e.getLineNumberString()+".");o=Math.max(0,Math.min(1,o/255)),o<1&&(i=!0);break;case"LUMINANCE":if(!f(e.getToken()))throw new Error("LDrawLoader: Invalid luminance value in material definition"+ar.getLineNumberString()+".");break;case"CHROME":s=1;break;case"PEARLESCENT":s=2;break;case"RUBBER":s=3;break;case"MATTE_METALLIC":s=4;break;case"METAL":s=5;break;case"MATERIAL":e.setToEnd();break;default:throw new Error('LDrawLoader: Unknown token "'+u+'" while parsing material'+e.getLineNumberString()+".")}let d=null;switch(s){case 0:d=new m({roughness:.3,metalness:0});break;case 2:d=new m({roughness:.3,metalness:.25});break;case 1:d=new m({roughness:0,metalness:1});break;case 3:d=new m({roughness:.9,metalness:0});break;case 4:d=new m({roughness:.8,metalness:.4});break;case 5:d=new m({roughness:.2,metalness:.85})}return d.color.setStyle(n,Qn),d.transparent=i,d.premultipliedAlpha=!0,d.opacity=o,d.depthWrite=!i,d.polygonOffset=!0,d.polygonOffsetFactor=1,0!==a&&d.emissive.setStyle(n,Qn).multiplyScalar(a),c||(c=new j({color:(new p).setStyle(r,Qn),transparent:i,opacity:o,depthWrite:!i}),c.color,c.userData.code=t,c.name=l+" - Edge",c.userData.conditionalEdgeMaterial=new nr({fog:!0,transparent:i,depthWrite:!i,color:(new p).setStyle(r,Qn),opacity:o}),c.userData.conditionalEdgeMaterial.userData.code=t,c.userData.conditionalEdgeMaterial.name=l+" - Conditional Edge"),d.userData.code=t,d.name=l,d.userData.edgeMaterial=c,this.addMaterial(d),d;function f(e){let t;return t=e.startsWith("LUMINANCE")?parseInt(e.substring(9)):parseInt(e),!isNaN(t)&&(a=Math.max(0,Math.min(1,t/255)),!0)}}computeBuildingSteps(e){let t=0;e.traverse((e=>{e.isGroup&&(e.userData.startingBuildingStep&&t++,e.userData.buildingStep=t)})),e.userData.numBuildingSteps=t+1}}class fr extends e{constructor(e){super(e)}load(e,t,r,o){const i=this,a=new n(i.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){function t(e,t){const n=e.length,r=new Float32Array(n+t.length);return r.set(e),r.set(t,n),r}function n(e,t){const n=e.length,r=new Int32Array(n+t.length);return r.set(e),r.set(t,n),r}const r=new TextDecoder,o=r.decode(new Uint8Array(e,0,250)).split("\n");return-1!==o[0].indexOf("xml")?function(e){function r(e){const t="undefined"!=typeof Uint8Array?Uint8Array:Array,n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let e=0,t=64;e<t;++e)n[r.charCodeAt(e)]=e;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;const o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");const i="="===e[o-2]?2:"="===e[o-1]?1:0,a=new t(3*o/4-i),s=i>0?o-4:o;let c,l,u=0;for(c=0,l=0;c<s;c+=4,l+=3){const t=n[e.charCodeAt(c)]<<18|n[e.charCodeAt(c+1)]<<12|n[e.charCodeAt(c+2)]<<6|n[e.charCodeAt(c+3)];a[u++]=(16711680&t)>>16,a[u++]=(65280&t)>>8,a[u++]=255&t}if(2===i){const t=n[e.charCodeAt(c)]<<2|n[e.charCodeAt(c+1)]>>4;a[u++]=255&t}else if(1===i){const t=n[e.charCodeAt(c)]<<10|n[e.charCodeAt(c+1)]<<4|n[e.charCodeAt(c+2)]>>2;a[u++]=t>>8&255,a[u++]=255&t}return a}function o(e,o){let a,s,c=0;if("UInt64"===i.attributes.header_type?c=8:"UInt32"===i.attributes.header_type&&(c=4),"binary"===e.attributes.format&&o){"Float32"===e.attributes.type?a=new Float32Array:"Int32"!==e.attributes.type&&"Int64"!==e.attributes.type||(a=new Int32Array);const o=e["#text"],i=r(Array.isArray(o)?o[0]:o),l=8;let u=i[0];for(let e=1;e<c-1;e++)u|=i[e]<<e*l;let d=(u+3)*c;d+=d%3>0?3-d%3:0;const p=[];let f=d;p.push(f);const h=3*c;for(let e=0;e<u;e++){let t=i[e*c+h];for(let n=1;n<c-1;n++)t|=i[e*c+h+n]<<n*l;f+=t,p.push(f)}for(let r=0;r<p.length-1;r++)s=St(i.slice(p[r],p[r+1])).buffer,"Float32"===e.attributes.type?(s=new Float32Array(s),a=t(a,s)):"Int32"!==e.attributes.type&&"Int64"!==e.attributes.type||(s=new Int32Array(s),a=n(a,s));delete e["#text"],"Int64"===e.attributes.type&&"binary"===e.attributes.format&&(a=a.filter((function(e,t){if(t%2!=1)return!0})))}else"binary"!==e.attributes.format||o?s=e["#text"]?e["#text"].split(/\s+/).filter((function(e){if(""!==e)return e})):new Int32Array(0).buffer:(s=r(e["#text"]),s=s.slice(c).buffer),delete e["#text"],"Float32"===e.attributes.type?a=new Float32Array(s):"Int32"===e.attributes.type?a=new Int32Array(s):"Int64"===e.attributes.type&&(a=new Int32Array(s),"binary"===e.attributes.format&&(a=a.filter((function(e,t){if(t%2!=1)return!0}))));return a}const i=function e(t){let n={};if(1===t.nodeType){if(t.attributes&&t.attributes.length>0){n.attributes={};for(let e=0;e<t.attributes.length;e++){const r=t.attributes.item(e);n.attributes[r.nodeName]=r.nodeValue.trim()}}}else 3===t.nodeType&&(n=t.nodeValue.trim());if(t.hasChildNodes())for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes.item(r),i=o.nodeName;if(void 0===n[i]){const t=e(o);""!==t&&(n[i]=t)}else{if(void 0===n[i].push){const e=n[i];n[i]=[e]}const t=e(o);""!==t&&n[i].push(t)}}return n}((new DOMParser).parseFromString(e,"application/xml").documentElement);let a=[],c=[],l=[];if(i.PolyData){const e=i.PolyData.Piece,t=i.attributes.hasOwnProperty("compressor"),n=["PointData","Points","Strips","Polys"];let r=0;const u=n.length;for(;r<u;){const i=e[n[r]];if(i&&i.DataArray){let s;s=Array.isArray(i.DataArray)?i.DataArray:[i.DataArray];let u=0;const d=s.length;for(;u<d;)"#text"in s[u]&&s[u]["#text"].length>0&&(s[u].text=o(s[u],t)),u++;switch(n[r]){case"PointData":{const t=parseInt(e.attributes.NumberOfPoints),n=i.attributes.Normals;if(t>0)for(let e=0,r=s.length;e<r;e++)if(n===s[e].attributes.Name){const n=s[e].attributes.NumberOfComponents;c=new Float32Array(t*n),c.set(s[e].text,0)}}break;case"Points":{const t=parseInt(e.attributes.NumberOfPoints);if(t>0){const e=i.DataArray.attributes.NumberOfComponents;a=new Float32Array(t*e),a.set(i.DataArray.text,0)}}break;case"Strips":{const t=parseInt(e.attributes.NumberOfStrips);if(t>0){const e=new Int32Array(i.DataArray[0].text.length),n=new Int32Array(i.DataArray[1].text.length);e.set(i.DataArray[0].text,0),n.set(i.DataArray[1].text,0);const r=t+e.length;l=new Uint32Array(3*r-9*t);let o=0;for(let r=0,i=t;r<i;r++){const t=[];for(let o=0,i=n[r],a=0;o<i-a;o++)t.push(e[o]),r>0&&(a=n[r-1]);for(let e=0,i=n[r],a=0;e<i-a-2;e++)e%2?(l[o++]=t[e],l[o++]=t[e+2],l[o++]=t[e+1]):(l[o++]=t[e],l[o++]=t[e+1],l[o++]=t[e+2]),r>0&&(a=n[r-1])}}}break;case"Polys":{const t=parseInt(e.attributes.NumberOfPolys);if(t>0){const e=new Int32Array(i.DataArray[0].text.length),n=new Int32Array(i.DataArray[1].text.length);e.set(i.DataArray[0].text,0),n.set(i.DataArray[1].text,0);const r=t+e.length;l=new Uint32Array(3*r-9*t);let o=0,a=0,s=0,c=0;const u=t;for(;s<u;){const t=[];let r=0;const i=n[s];for(;r<i-c;)t.push(e[a++]),r++;let u=1;for(;u<i-c-1;)l[o++]=t[0],l[o++]=t[u],l[o++]=t[u+1],u++;s++,c=n[s-1]}}}}}r++}const d=new s;return d.setIndex(new h(l,1)),d.setAttribute("position",new h(a,3)),c.length===a.length&&d.setAttribute("normal",new h(c,3)),d}throw new Error("Unsupported DATASET type")}(r.decode(e)):o[2].includes("ASCII")?function(e){const t=[],n=[],r=[],o=[];let i;const a=/^[^\d.\s-]+/,c=/(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g,u=/^(\d+)\s+([\s\d]*)/,d=/^POINTS /,p=/^POLYGONS /,f=/^TRIANGLE_STRIPS /,h=/^POINT_DATA[ ]+(\d+)/,m=/^CELL_DATA[ ]+(\d+)/,g=/^COLOR_SCALARS[ ]+(\w+)[ ]+3/,y=/^NORMALS[ ]+(\w+)[ ]+(\w+)/;let v=!1,E=!1,T=!1,b=!1,A=!1,x=!1,N=!1;const R=e.split("\n");for(const e in R){const s=R[e].trim();if(0===s.indexOf("DATASET")){const e=s.split(" ")[1];if("POLYDATA"!==e)throw new Error("Unsupported DATASET type: "+e)}else if(v)for(;null!==(i=c.exec(s))&&null===a.exec(s);){const e=parseFloat(i[1]),t=parseFloat(i[2]),r=parseFloat(i[3]);n.push(e,t,r)}else if(E){if(null!==(i=u.exec(s))){const e=parseInt(i[1]),n=i[2].split(/\s+/);if(e>=3){const r=parseInt(n[0]);let o=1;for(let i=0;i<e-2;++i){const e=parseInt(n[o]),i=parseInt(n[o+1]);t.push(r,e,i),o++}}}}else if(T){if(null!==(i=u.exec(s))){const e=parseInt(i[1]),n=i[2].split(/\s+/);if(e>=3)for(let r=0;r<e-2;r++)if(r%2==1){const e=parseInt(n[r]),o=parseInt(n[r+2]),i=parseInt(n[r+1]);t.push(e,o,i)}else{const e=parseInt(n[r]),o=parseInt(n[r+1]),i=parseInt(n[r+2]);t.push(e,o,i)}}}else if(b||A)if(x)for(;null!==(i=c.exec(s))&&null===a.exec(s);){const e=parseFloat(i[1]),t=parseFloat(i[2]),n=parseFloat(i[3]);r.push(e,t,n)}else if(N)for(;null!==(i=c.exec(s))&&null===a.exec(s);){const e=parseFloat(i[1]),t=parseFloat(i[2]),n=parseFloat(i[3]);o.push(e,t,n)}null!==p.exec(s)?(E=!0,v=!1,T=!1):null!==d.exec(s)?(E=!1,v=!0,T=!1):null!==f.exec(s)?(E=!1,v=!1,T=!0):null!==h.exec(s)?(b=!0,v=!1,E=!1,T=!1):null!==m.exec(s)?(A=!0,v=!1,E=!1,T=!1):null!==g.exec(s)?(x=!0,N=!1,v=!1,E=!1,T=!1):null!==y.exec(s)&&(N=!0,x=!1,v=!1,E=!1,T=!1)}let k=new s;if(k.setIndex(t),k.setAttribute("position",new l(n,3)),o.length===n.length&&k.setAttribute("normal",new l(o,3)),r.length!==t.length)r.length===n.length&&k.setAttribute("color",new l(r,3));else{k=k.toNonIndexed();const e=k.attributes.position.count/3;if(r.length===3*e){const t=[];for(let n=0;n<e;n++){const e=r[3*n+0],o=r[3*n+1],i=r[3*n+2];t.push(e,o,i),t.push(e,o,i),t.push(e,o,i)}k.setAttribute("color",new l(t,3))}}return k}(r.decode(e)):function(e){const t=new Uint8Array(e),n=new DataView(e);let r,o,i=[],a=[],c=[],l=0;function u(e,t){let n=t,r=e[n];const o=[];for(;10!==r;)o.push(String.fromCharCode(r)),n++,r=e[n];return{start:t,end:n,next:n+1,parsedString:o.join("")}}for(;;){if(r=u(t,l),o=r.parsedString,0===o.indexOf("DATASET")){const e=o.split(" ")[1];if("POLYDATA"!==e)throw new Error("Unsupported DATASET type: "+e)}else if(0===o.indexOf("POINTS")){const e=parseInt(o.split(" ")[1],10),t=4*e*3;i=new Float32Array(3*e);let a=r.next;for(let t=0;t<e;t++)i[3*t]=n.getFloat32(a,!1),i[3*t+1]=n.getFloat32(a+4,!1),i[3*t+2]=n.getFloat32(a+8,!1),a+=12;r.next=r.next+t+1}else if(0===o.indexOf("TRIANGLE_STRIPS")){const e=parseInt(o.split(" ")[1],10),t=parseInt(o.split(" ")[2],10),i=4*t;c=new Uint32Array(3*t-9*e);let a=0,s=r.next;for(let t=0;t<e;t++){const e=n.getInt32(s,!1),t=[];s+=4;for(let r=0;r<e;r++)t.push(n.getInt32(s,!1)),s+=4;for(let n=0;n<e-2;n++)n%2?(c[a++]=t[n],c[a++]=t[n+2],c[a++]=t[n+1]):(c[a++]=t[n],c[a++]=t[n+1],c[a++]=t[n+2])}r.next=r.next+i+1}else if(0===o.indexOf("POLYGONS")){const e=parseInt(o.split(" ")[1],10),t=parseInt(o.split(" ")[2],10),i=4*t;c=new Uint32Array(3*t-9*e);let a=0,s=r.next;for(let t=0;t<e;t++){const e=n.getInt32(s,!1),t=[];s+=4;for(let r=0;r<e;r++)t.push(n.getInt32(s,!1)),s+=4;for(let n=1;n<e-1;n++)c[a++]=t[0],c[a++]=t[n],c[a++]=t[n+1]}r.next=r.next+i+1}else if(0===o.indexOf("POINT_DATA")){const e=parseInt(o.split(" ")[1],10);r=u(t,r.next);const i=4*e*3;a=new Float32Array(3*e);let s=r.next;for(let t=0;t<e;t++)a[3*t]=n.getFloat32(s,!1),a[3*t+1]=n.getFloat32(s+4,!1),a[3*t+2]=n.getFloat32(s+8,!1),s+=12;r.next=r.next+i}if(l=r.next,l>=t.byteLength)break}const d=new s;return d.setIndex(new h(c,1)),d.setAttribute("position",new h(i,3)),a.length===i.length&&d.setAttribute("normal",new h(a,3)),d}(e)}}class hr extends e{load(e,t,r,o){const i=this,a=new n(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(i.parse(n))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const t=e.split("\n"),n=[],r=[];for(let e of t){if(e=e.trim(),"#"===e.charAt(0))continue;const t=e.split(/\s+/);3===t.length&&(n.push(parseFloat(t[0])),n.push(parseFloat(t[1])),n.push(parseFloat(t[2]))),6===t.length&&(n.push(parseFloat(t[0])),n.push(parseFloat(t[1])),n.push(parseFloat(t[2])),r.push(parseFloat(t[3])/255),r.push(parseFloat(t[4])/255),r.push(parseFloat(t[5])/255))}const o=new s;return o.setAttribute("position",new l(n,3)),r.length>0&&o.setAttribute("color",new l(r,3)),o}}class mr extends le{constructor(){super(...arguments),this._importer=new ue(fe,["3ds"],["image/x-3ds","application/x-3ds"],!1)}}mr.PluginType="TDSLoadPlugin";class gr extends le{constructor(){super(...arguments),this._importer=new ue(Vt,["3mf"],["model/3mf"],!1)}}gr.PluginType="ThreeMFLoadPlugin";class yr extends le{constructor(){super(...arguments),this._importer=new ue(class extends jt{transform(e,t){return e.scene.userData.kinematics=e.kinematics,e.scene.userData.library=e.library,e.scene}},["dae"],["model/vnd.collada+xml"],!1)}}yr.PluginType="ColladaLoadPlugin";class vr extends le{constructor(){super(...arguments),this._importer=new ue(zt,["amf"],["application/amf"],!1)}}vr.PluginType="AMFLoadPlugin";class Er extends le{constructor(){super(...arguments),this._importer=new ue(Gt,["gcode"],["application/gcode"],!1)}}Er.PluginType="GCodeLoadPlugin";class Tr extends le{constructor(){super(...arguments),this._importer=new ue(class extends Wt{transform(e,t){const n=new Z,r=new de(e.skeleton.bones[0]);return n.add(e.skeleton.bones[0]),n.add(r),n.animations=[e.clip],n.scale.set(.1,.1,.1),n}},["bvh"],["application/bvh"],!1)}}Tr.PluginType="BVHLoadPlugin";class br extends le{constructor(){super(...arguments),this._importer=new ue(class extends Ht{transform(e,t){const n=new Z;for(const t of e){const e=new Yt(t);e.scale.setScalar(.0015),n.add(e)}return n}},["vox"],[""],!1)}}br.PluginType="VOXLoadPlugin";class Ar extends le{constructor(){super(...arguments),this._importer=new ue(class extends Kt{transform(e,t){const n=e.morphTargets,r=new te;r.morphAttributes.position=n;const o=new c(r,new pe),i=new Z;return i.add(o),e.clip.tracks.forEach((e=>e.name=o.uuid+e.name)),i.animations=[e.clip],i}},["mdd"],["application/mdd"],!1)}}Ar.PluginType="MDDLoadPlugin";class xr extends le{constructor(){super(...arguments),this._importer=new ue(class extends qt{transform(e,t){return t.autoCenter&&e.geometry.center(),e.geometry.rotateX(Math.PI),e}},["pcd"],["application/pcd"],!1)}}xr.PluginType="PCDLoadPlugin";class Nr extends le{constructor(){super(...arguments),this._importer=new ue(Xt,["tilt"],["application/tilt"],!1)}}Nr.PluginType="TiltLoadPlugin";class Rr extends le{constructor(){super(...arguments),this._importer=new ue(Hn,["wrl"],["model/vrml"],!1)}}Rr.PluginType="VRMLLoadPlugin";class kr extends le{constructor(){super(...arguments),this._importer=new ue(class extends pr{transform(e,t){return e.rotation.x=Math.PI,e}},["mpd"],["application/ldraw"],!1)}}kr.PluginType="LDrawLoadPlugin";class Or extends le{constructor(){super(...arguments),this._importer=new ue(class extends fr{transform(e,t){return e.attributes?.normal||e.computeVertexNormals(),e?new c(e,new pe({color:new p(1,1,1),vertexColors:e.hasAttribute("color")})):void 0}},["vtk","vtp"],["application/vtk"],!1)}}Or.PluginType="VTKLoadPlugin";class Ir extends le{constructor(){super(...arguments),this._importer=new ue(class extends hr{transform(e,t){return e.attributes?.normal||e.computeVertexNormals(),t.autoCenter&&e.center(),e?new X(e,new q({size:.1,vertexColors:e.hasAttribute("color")})):void 0}},["xyz"],["text/plain+xyz"],!1)}}Ir.PluginType="XYZLoadPlugin";const _r=[mr,gr,yr,vr,Er,Tr,br,Ar,xr,Nr,Rr,kr,Or,Ir];export{vr as AMFLoadPlugin,Tr as BVHLoadPlugin,yr as ColladaLoadPlugin,Er as GCodeLoadPlugin,kr as LDrawLoadPlugin,Ar as MDDLoadPlugin,xr as PCDLoadPlugin,mr as TDSLoadPlugin,gr as ThreeMFLoadPlugin,Nr as TiltLoadPlugin,br as VOXLoadPlugin,Rr as VRMLLoadPlugin,Or as VTKLoadPlugin,Ir as XYZLoadPlugin,_r as extraImportPlugins};
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|