a3js 0.0.24 → 0.0.25

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/a3js.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nn=Object.create;var zt=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var Pn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kn(e))!Mn.call(n,r)&&r!==t&&zt(n,r,{get:()=>e[r],enumerable:!(i=wn(e,r))||i.enumerable});return n};var Dn=(n,e,t)=>(t=n!=null?Nn(Cn(n)):{},Pn(e||!n||!n.__esModule?zt(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("three"),en=require("fflate");function Fn(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const se=Fn(R);function tn(n){return typeof n=="string"}function Pt(n){return n.isMesh===!0}function Un(n){return n.type==="RoundedBoxGeometry"}function jn(n){return n.type==="BoxGeometry"}function Bn(n){return n.type==="SphereGeometry"}function Gn(n){return n.type==="IcosahedronGeometry"}function zn(n){return n.type==="CylinderGeometry"}function Vn(n){return n.type==="CapsuleGeometry"}function Hn(n){return n.isBone===!0}function Wn(n){return n.isPerspectiveCamera===!0}const nn={rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};class Kn{object;option;constructor(e,t){this.object=e,this.option=t}}class ke{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,i,r){typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}clone(){return new ke(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t,this._w/=t):console.warn("Quat.normalize."),this}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}set(e,t,i,r){return typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}mul(e,t,i,r){const a=new ke(this),o=new ke;return typeof e=="number"?o.set(e,t,i,r):o.set(e),this._x=a.w*o.x+a.x*o.w+a.y*o.z-a.z*o.y,this._y=a.w*o.y-a.x*o.z+a.y*o.w+a.z*o.x,this._z=a.w*o.z+a.x*o.y-a.y*o.x+a.z*o.w,this._w=a.w*o.w-a.x*o.x-a.y*o.y-a.z*o.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w}slerp(e,t,i){if(i<0||i>1){console.warn("Quat.slerp(): t must be in [0,1]");return}const r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(r<.9995){const a=Math.acos(r),o=Math.sin((1-i)*a)/Math.sin(a),u=Math.sin(i*a)/Math.sin(a);this._x=o*e.x+u*t.x,this._y=o*e.y+u*t.y,this._z=o*e.z+u*t.z,this._w=o*e.w+u*t.w}else{this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w;const a=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);a<1e-4?(console.warn("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/a,this._y*=1/a,this._z*=1/a,this._w*=1/a)}}}function ct(n,e,t){t.normalize();const i=e.clone().sub(n).normalize(),r=new Ae().cross(i,t).normalize(),a=new Ae().cross(r,i),o=r.x,u=a.x,c=-i.x,s=r.y,f=a.y,h=-i.y,g=r.z,p=a.z,T=-i.z,m=o+f+T;if(m>0){const l=Math.sqrt(m+1)*2;return new ke((p-h)/l,(c-g)/l,(s-u)/l,.25*l)}else if(o>f&&o>T){const l=Math.sqrt(1+o-f-T)*2;return new ke(.25*l,(u+s)/l,(c+g)/l,(p-h)/l)}else if(f>T){const l=Math.sqrt(1+f-o-T)*2;return new ke((u+s)/l,.25*l,(h+p)/l,(c-g)/l)}else{const l=Math.sqrt(1+T-o-f)*2;return new ke((c+g)/l,(h+p)/l,.25*l,(s-u)/l)}}function rn(n,e="XYZ"){const t=new ke(0,0,0,1);for(let i=0;i<3;i++)switch(e.charAt(i)){case"X":t.mul(new ke(Math.sin(n.x),0,0,Math.cos(n.x)));break;case"Y":t.mul(new ke(0,Math.sin(n.y),0,Math.cos(n.y)));break;case"Z":t.mul(new ke(0,0,Math.sin(n.z),Math.cos(n.z)));break}return t}class Ae{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,i){typeof e=="number"?(this._x=e,this._y=t,this._z=i):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}clone(){return new Ae(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t):console.warn("Vec3.normalize."),this}negate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}set(e,t,i){return typeof e=="number"?(this._x=e,this._y=t,this._z=i):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e,t,i){return typeof e=="number"?(this._x+=e,this._y+=t,this._z+=i):(this._x+=e.x,this._y+=e.y,this._z+=e.z),this}sub(e,t,i){return typeof e=="number"?(this._x-=e,this._y-=t,this._z-=i):(this._x-=e.x,this._y-=e.y,this._z-=e.z),this}scale(e){return this._x*=e,this._y*=e,this._z*=e,this}cross(e,t){return this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this}apply(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e);const o=new ke(this._x,this._y,this._z,0),u=new ke(a).conjugate();return a.mul(o).mul(u),this._x=a.x,this._y=a.y,this._z=a.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z}}class tt{objectA3;object3D;interpolation;billboard;constructor(e){this.objectA3=e,this.object3D=e?.object}setObject(e){this.objectA3=e,this.object3D=e.object}detachObject(e){this.objectA3=void 0,this.object3D=void 0}enableInterpolation(e){e&&!this.interpolation&&this.object3D?this.interpolation=new Yn(this.object3D):!e&&this.interpolation&&(this.interpolation=void 0)}enableBillboard(e){e&&this.billboard?this.billboard.setTarget(e.object):e&&!this.billboard&&this.objectA3?this.billboard=new Xn(this.objectA3,e.object):this.billboard=void 0}update(e){this.interpolation&&this.interpolation.update(e),this.billboard&&this.billboard.update()}setLocation(e){this.interpolation?this.interpolation.setLocation(e):this.object3D?.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setLocationNow(e){this.interpolation?this.interpolation.setLocationNow(e):this.object3D?.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setQuat(e){this.billboard||(this.interpolation?this.interpolation.setQuat(e):this.object3D?.quaternion.set(e.x,e.y,e.z,e.w))}setQuatNow(e){this.billboard||(this.interpolation?this.interpolation.setQuatNow(e):this.object3D?.quaternion.set(e.x,e.y,e.z,e.w))}setScale(e){this.interpolation?this.interpolation.setScale(e):this.object3D?.scale.set(e.x,e.y,e.z)}setScaleNow(e){this.interpolation?this.interpolation.setScaleNow(e):this.object3D?.scale.set(e.x,e.y,e.z)}controlMotion(...e){}setPause(e){}setTime(e){}addOnselfToPhysics(e){}removeOnselfFromPhysics(e){}}class Yn{obj;firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.obj=e,this.firstLoc=new Ae(e.position),this.firstRot=new ke(e.quaternion),this.firstScale=new Ae(e.scale),this.nowLoc=new Ae(e.position),this.nowRot=new ke(e.quaternion),this.nowScale=new Ae(e.scale),this.lastLoc=new Ae(e.position),this.lastRot=new ke(e.quaternion),this.lastScale=new Ae(e.scale),this.nowTime=0,this.duration=1}setLocation(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastLoc.set(e),this.nowTime=0}setLocationNow(e){this.setLocation(e),this.nowTime=1}setQuat(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastRot.set(e),this.nowTime=0}setQuatNow(e){this.setQuat(e),this.nowTime=1}setScale(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastScale.set(e),this.nowTime=0}setScaleNow(e){this.setScale(e),this.nowTime=1}smoothstep(e){return e*e*(3-2*e)}update(e){this.nowTime+=e,this.nowTime>this.duration&&(this.nowTime=this.duration);const t=this.nowTime/this.duration,i=this.smoothstep(t);this.nowLoc.lerp(this.firstLoc,this.lastLoc,i),this.nowRot.slerp(this.firstRot,this.lastRot,i),this.nowScale.lerp(this.firstScale,this.lastScale,i),this.obj.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),this.obj.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),this.obj.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class Xn{up;obj;target;tmpObjLoc=new Ae;tmpTargetLoc=new Ae;constructor(e,t){this.up=new Ae,e.upVector?this.up.set(e.upVector):this.up.set(je.defaultUpVector),this.obj=e.object,this.target=t}setTarget(e){this.target=e}update(){this.tmpObjLoc.set(this.obj.position),this.tmpTargetLoc.set(this.target.position);const e=ct(this.tmpObjLoc,this.tmpTargetLoc,this.up);this.obj.quaternion.set(e.x,e.y,e.z,e.w)}}let Ve;class lt{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!lt.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),lt.RAPIER=e,Ve=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOption(e)&&(t=e.timestep);const i=new Ve.World(e.gravity);return new xt(i,t)}isRapierWorldOption(e){return"timestep"in e}}class xt{world;timestep;collisionEventQueue;constructor(e,t){this.world=e,this.timestep=t,this.collisionEventQueue=new Ve.EventQueue(!0),this.world.integrationParameters.dt=this.timestep}add(e){Vt(e)&&e.addOneself(this)}remove(e){Vt(e)&&e.removeOneself(this)}update(e){const t=Math.ceil(e/this.timestep);for(let i=0;i<t;i++)this.world.step(this.collisionEventQueue)}getCollisions(){const e=[];return this.collisionEventQueue.drainCollisionEvents((t,i,r)=>{const a=It.collisionMap.get(t),o=It.collisionMap.get(i);a&&o&&e.push({objectA:a,partOfA:t,objectB:o,partOfB:i,started:r})}),e}}class It extends Kn{static collisionMap=new Map}function Vt(n){return"addOneself"in n&&"removeOneself"in n}class qn extends tt{bodyDesc;body;colliderDescs;colliders;completeOption;constructor(e,t={}){super(e),this.colliderDescs=[],this.colliders=[],this.completeOption={...nn,...t}}setObject(e){super.setObject(e),this.bodyDesc=void 0,this.body=void 0,this.colliderDescs=[],this.colliders=[],this.myInitialize(e)}detachObject(e){this.bodyDesc=void 0,this.body=void 0,this.colliderDescs=[],this.colliders=[]}myInitialize(e){const t=this.completeOption;switch(t.rigidBody){case"dynamic":this.bodyDesc=Ve.RigidBodyDesc.dynamic();break;case"kinematic":this.bodyDesc=Ve.RigidBodyDesc.kinematicPositionBased();break;case"fixed":this.bodyDesc=Ve.RigidBodyDesc.fixed();break}this.bodyDesc.setTranslation(e.object.position.x,e.object.position.y,e.object.position.z),this.bodyDesc.setRotation({x:e.object.quaternion.x,y:e.object.quaternion.y,z:e.object.quaternion.z,w:e.object.quaternion.w});const i=[];e.object.traverse(a=>{if(Pt(a)){const o=Jn(a.geometry),u=t.membership<<16|t.filter;if(o)o.colliderDesc.setCollisionGroups(u),t.collisionDetection&&o.colliderDesc.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(o.colliderDesc),o.colliderDesc.setRestitution(t.restitution).setFriction(t.friction),i.push(o.volume);else{let c,s;switch(t.meshCollider){case"tri_mesh":c=Qn(a),s=Ht(a.geometry);break;case"convex_hull":c=Zn(a),s=Ht(a.geometry);break}c&&(c.setCollisionGroups(u),t.collisionDetection&&c.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(c),i.push(s))}}});let r=i.reduce((a,o)=>a+o,0);for(let a=0;a<this.colliderDescs.length;a++)this.colliderDescs[a].setRestitution(t.restitution),this.colliderDescs[a].setFriction(t.friction),this.colliderDescs[a].setMass(t.mass*(i[a]/r))}update(e){if(this.body){const t=this.body.translation();this.object3D?.position.set(t.x,t.y,t.z);const i=this.body.rotation();this.object3D?.quaternion.set(i.x,i.y,i.z,i.w)}}setLocation(e){}setLocationNow(e){this.body&&this.body.setTranslation(e,!0)}setQuat(e){}setQuatNow(e){this.body&&this.body.setRotation(e,!0)}setScale(e){}setScaleNow(e){}addOnselfToPhysics(e){this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc)),this.colliderDescs.forEach(t=>{const i=e.world.createCollider(t,this.body);this.colliders.push(i),this.objectA3&&It.collisionMap.set(i.handle,this.objectA3)})}removeOnselfFromPhysics(e){this.body&&e.world.removeRigidBody(this.body),this.colliders.forEach(t=>{e.world.removeCollider(t,!1)})}}function Qn(n){let e=null;if(Pt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;let a=i.index?i.index.array:null;if(a)a instanceof Uint32Array||(a=new Uint32Array(a));else{const o=i.attributes.position.count;a=new Uint32Array(o);for(let u=0;u<o;u++)a[u]=u}r instanceof Float32Array&&(e=Ve.ColliderDesc.trimesh(r,a))}return e}function Zn(n){let e=null;if(Pt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;r instanceof Float32Array&&(e=Ve.ColliderDesc.convexHull(r))}return e}function Ht(n){const e=n.attributes.position;if(!e)throw new Error("position attribute not found");const t=n.index,i=e.array;let r=0;const a=new se.Vector3,o=new se.Vector3,u=new se.Vector3;if(t){const c=t.array;for(let s=0;s<c.length;s+=3){const f=c[s]*3,h=c[s+1]*3,g=c[s+2]*3;a.set(i[f],i[f+1],i[f+2]),o.set(i[h],i[h+1],i[h+2]),u.set(i[g],i[g+1],i[g+2]),r+=a.dot(o.clone().cross(u))}}else for(let c=0;c<i.length;c+=9)a.set(i[c],i[c+1],i[c+2]),o.set(i[c+3],i[c+4],i[c+5]),u.set(i[c+6],i[c+7],i[c+8]),r+=a.dot(o.clone().cross(u));return Math.abs(r)/6}function Jn(n){if(Un(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,a=.1;return{colliderDesc:Ve.ColliderDesc.roundCuboid(t-a,i-a,r-a,a),volume:2*t*2*i*2*r}}else if(jn(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Ve.ColliderDesc.cuboid(t,i,r),volume:2*t*2*i*2*r}}else if(Bn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Gn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(zn(n)){const e=n.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.cylinder(i/2,t),volume:Math.PI*t*t*i}}else if(Vn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.capsule(i/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*i}}return null}const Nt=new lt;async function $n(){await Nt.init()}class on{scene;objects;physicsWorld=null;physicsDt=1/60;collisionListener;constructor(){this.scene=new se.Scene,this.objects=[],Nt.isInitialized&&(this.physicsWorld=Nt.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt}))}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,this.physicsWorld instanceof xt&&e.motion.addOnselfToPhysics(this.physicsWorld)}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,this.physicsWorld instanceof xt&&e.motion.removeOnselfFromPhysics(this.physicsWorld)}setCollisionListener(e){this.collisionListener=e}update(e){if(this.physicsWorld){this.physicsWorld.update(e);const t=this.physicsWorld.getCollisions();t.forEach(i=>{i.objectA.handleCollision(i.objectB,i.started,i.partOfA,i.partOfB),i.objectB.handleCollision(i.objectA,i.started,i.partOfB,i.partOfA)}),this.collisionListener&&t.length>0&&this.collisionListener(t)}for(const t of this.objects)t.update(e)}}class je{static defaultRotationOrder="XYZ";static defaultUpVector=new Ae(0,1,0);rotationOrder=null;upVector=null;object;scene=null;balloon=null;motion;parent=null;children=[];clickListener;constructor(e){this.object=this.initObject(e),this.object.traverse(t=>{t.userData.a3js={objectA3:this}}),this.motion=this.initMotion(),this.motion.setObject(this)}initMotion(e){return new tt(this)}setMotion(e){e.setObject(this),this.motion=e}detachMotion(){const e=new tt(this),t=this.motion;return t.detachObject(this),this.motion=e,e.setObject(this),t}replaceMotion(e){const t=this.motion;return t.detachObject(this),this.motion=e,e.setObject(this),t}controlMotion(...e){this.motion.controlMotion(...e)}enableInterpolation(e){this.motion.enableInterpolation(e)}initDefaultPhysics(e){const t={...nn,...e};this.motion=new qn(this,t),this.motion.setObject(this)}update(e){this.motion.update(e),this.children.forEach(t=>{t.update(e)})}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object.add(e.object)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=null,this.object.remove(e.object)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new er(e)}setClickListener(e){this.clickListener=e}handleCollision(e,t,i,r){}async clicked(){this.clickListener&&await this.clickListener(this)}get locX(){return this.object.position.x}get locY(){return this.object.position.y}get locZ(){return this.object.position.z}setLocation(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocation(r)}setLocationNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocationNow(r),this.object.position.set(r.x,r.y,r.z)}get quatX(){return this.object.quaternion.x}get quatY(){return this.object.quaternion.y}get quatZ(){return this.object.quaternion.z}get quatW(){return this.object.quaternion.w}setQuat(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e),this.motion.setQuat(a)}setQuatNow(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e),this.motion.setQuatNow(a)}get scaleX(){return this.object.scale.x}get scaleY(){return this.object.scale.y}get scaleZ(){return this.object.scale.z}setScale(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScale(r)}setScaleNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScaleNow(r)}setRotation(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),r.scale(Math.PI/360);const a=this.rotationOrder?this.rotationOrder:je.defaultRotationOrder,o=rn(r,a);this.setQuat(o)}setRotationNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e);const a=this.rotationOrder?this.rotationOrder:je.defaultRotationOrder,o=new ke(0,0,0,1);for(let u=0;u<3;u++)switch(a.charAt(u)){case"X":o.mul(new ke(Math.sin(r.x),0,0,Math.cos(r.x)));break;case"Y":o.mul(new ke(0,Math.sin(r.y),0,Math.cos(r.y)));break;case"Z":o.mul(new ke(0,0,Math.sin(r.z),Math.cos(r.z)));break}this.setQuatNow(o)}lookAt(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):e instanceof je?r.set(e.locX,e.locY,e.locZ):r.set(e);const a=this.upVector?this.upVector:je.defaultUpVector,o=ct(new Ae(this.object.position),r,a);this.setQuat(o)}lookAtNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):e instanceof je?r.set(e.locX,e.locY,e.locZ):r.set(e);const a=this.upVector?this.upVector:je.defaultUpVector,o=ct(new Ae(this.object.position),r,a);this.setQuatNow(o)}getUnitVecX(){return new Ae(1,0,0).apply(this.object.quaternion)}getUnitVecY(){return new Ae(0,1,0).apply(this.object.quaternion)}getUnitVecZ(){return new Ae(0,0,1).apply(this.object.quaternion)}}class er{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class sn extends je{controller;setController(e){this.controller=e}setLocation(e,t,i){typeof e=="number"?super.setLocation(e,t,i):super.setLocation(e),this.controller?.setCameraLocation(this.object.position)}}class an{view;constructor(e){this.view=e,e.setController(this)}update(e){}activate(){}deactivate(){}keyDown(e){}keyUp(e){}keyPress(e){}mouseDown(e){}mouseUp(e){}mouseMove(e){}mouseClick(e){}mouseEnter(e){}mouseLeave(e){}mouseWheel(e){}touchStart(e){}touchEnd(e){}touchMove(e){}touchCancel(e){}setCameraLocation(e){}setCameraLocationNow(e){}setCameraQuat(e){}setCameraQuatNow(e){}setCameraScale(e){}setCameraScaleNow(e){}}class cn extends an{preMouse;leftClick=!1;target;cameraLoc=new Ae(0,0,3);cameraQuat=new ke(0,0,0,1);constructor(e,t,i,r){super(e),this.preMouse={x:0,y:0},typeof t=="number"?this.target=new Ae(t,i,r):this.target=new Ae(t)}update(e){this.view.camera.setLocation(this.cameraLoc),this.view.camera.setQuat(this.cameraQuat)}mouseDown(e){e.button===0&&(this.leftClick=!0,this.preMouse.x=e.clientX,this.preMouse.y=e.clientY)}mouseMove(e){if(this.leftClick===!1)return;const t=.01,i=t*(e.clientX-this.preMouse.x),r=t*(e.clientY-this.preMouse.y),a=Math.sin(-i),o=Math.cos(-i),u=Math.sin(-r),c=Math.cos(-r),s=new Ae(1,0,0).apply(this.cameraQuat),f=new Ae(0,1,0).apply(this.cameraQuat),h=new ke(s.x*u,s.y*u,s.z*u,c),g=new ke(f.x*a,f.y*a,f.z*a,o),p=new Ae(this.cameraLoc);p.sub(this.target),p.apply(h),p.apply(g),p.add(this.target),this.cameraLoc.set(p);const T=ct(this.cameraLoc,this.target,new Ae(0,1,0));this.cameraQuat.set(T),this.preMouse.x=e.clientX,this.preMouse.y=e.clientY}mouseUp(e){e.button===0&&(this.leftClick=!1)}mouseWheel(e){const t=new Ae(this.target).sub(this.cameraLoc);e.deltaY>0?t.scale(.05):e.deltaY<0&&t.scale(-.05),this.cameraLoc.add(t)}setCameraLocation(e){this.cameraLoc.set(e)}setCameraLocationNow(e){this.cameraLoc.set(e)}}function tr(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}async function ln(n){const t=await(await fetch(n)).arrayBuffer(),i=await new Promise((r,a)=>{en.unzip(new Uint8Array(t),(o,u)=>{o?a(o):r(u)})});return{zipUrl:n,unzipped:i}}function Dt(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n.unzipped[e])return en.strFromU8(n.unzipped[e]);throw new Error(`readStringFromUnzippedA3(): no file at ${e}`)}function nr(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n.unzipped[e]){const t=ir(e);return new Blob([new Uint8Array(n.unzipped[e])],{type:t})}else throw new Error(`readBlobFromUnzippedA3(): no file at ${e}`)}const rr={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function ir(n){for(const[e,t]of Object.entries(rr))if(t.test(n))return e;return"application/octet-stream"}function yt(n,e){if(!e)return n;const t={...n};for(const i in e)typeof n[i]=="object"&&typeof e[i]=="object"?t[i]=yt(n[i],e[i]):t[i]=e[i];return t}const or={type:"audio",autoplay:!1,loop:!1,volume:1,positional:{refDistance:1,maxDistance:1e3,rolloffFactor:1,directional:{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0}}};async function sr(){try{$e.listener.context.state!=="running"&&await $e.listener.context.resume()}catch{console.warn("AudioContext resume failed. Did you call on user gesture?")}}class $e extends je{static listener=new se.AudioListener;static audioLoader=new se.AudioLoader;ready;config;sound;constructor(e,t={}){super(),this.config=yt(or,t),this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}async asyncInit(e){if(this.config.type==="positional"){const t=new se.PositionalAudio($e.listener);t.setRefDistance(this.config.positional.refDistance),t.setMaxDistance(this.config.positional.maxDistance),t.setRolloffFactor(this.config.positional.rolloffFactor);const i=this.config.positional.directional;t.setDirectionalCone(i.coneInnerAngle,i.coneOuterAngle,i.coneOuterGain),t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}else{const t=new se.Audio($e.listener);t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}return this.object.add(this.sound),new Promise(t=>{$e.audioLoader.load(e,i=>{this.sound&&this.sound.setBuffer(i),t(this)})})}play(){this.sound?.play()}}class Ft{scene;camera;controller;constructor(e){this.scene=new on,this.camera=e,this.camera.setAudioListener($e.listener),this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3),this.controller=new cn(this,0,0,0),this.camera.setController(this.controller)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e),this.controller?.update(e),this.camera.update(e)}setController(e){this.controller?.deactivate(),this.controller=e,this.controller.activate(),this.camera.setController(e)}worldToScreen(e){throw new Error("ViewBaseはworldToScreen()は実装していません")}screenToWorld(e,t,i){throw new Error("ViewBaseはscreenToWorld()は実装していません")}cameraToScreen(e){throw new Error("ViewBaseはcameraToScreen()は実装していません")}screenToCamera(e,t,i){throw new Error("ViewBaseはscreenToCamera()は実装していません")}}class ut extends sn{camera;headLight;constructor(e){super(),this.camera=e,this.headLight=new se.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new se.Object3D}setAudioListener(e){this.camera.add(e)}getHeadLight(){return this.headLight}setAspect(e){Wn(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}calcNDC(e){const t=new se.Vector3(e.x,e.y,e.z);return t.project(this.camera),{x:t.x,y:t.y}}}class un extends R.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new R.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const rt=new R.Vector3,Wt=new R.Matrix4,Kt=new R.Matrix4,Yt=new R.Vector3,Xt=new R.Vector3;class hn{constructor(e={}){const t=this;let i,r,a,o;const u={objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(T,m){T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),m.parent===null&&m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),Wt.copy(m.matrixWorldInverse),Kt.multiplyMatrices(m.projectionMatrix,Wt),f(T,T,m),this.sortObjects&&p(T)},this.setSize=function(T,m){i=T,r=m,a=i/2,o=r/2,c.style.width=T+"px",c.style.height=m+"px"};function s(T){T.isCSS2DObject&&(T.element.style.display="none");for(let m=0,l=T.children.length;m<l;m++)s(T.children[m])}function f(T,m,l){if(T.visible===!1){s(T);return}if(T.isCSS2DObject){rt.setFromMatrixPosition(T.matrixWorld),rt.applyMatrix4(Kt);const d=rt.z>=-1&&rt.z<=1&&T.layers.test(l.layers)===!0,y=T.element;y.style.display=d===!0?"":"none",d===!0&&(T.onBeforeRender(t,m,l),y.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(rt.x*a+a)+"px,"+(-rt.y*o+o)+"px)",y.parentNode!==c&&c.appendChild(y),T.onAfterRender(t,m,l));const v={distanceToCameraSquared:h(l,T)};u.objects.set(T,v)}for(let d=0,y=T.children.length;d<y;d++)f(T.children[d],m,l)}function h(T,m){return Yt.setFromMatrixPosition(T.matrixWorld),Xt.setFromMatrixPosition(m.matrixWorld),Yt.distanceToSquared(Xt)}function g(T){const m=[];return T.traverseVisible(function(l){l.isCSS2DObject&&m.push(l)}),m}function p(T){const m=g(T).sort(function(d,y){if(d.renderOrder!==y.renderOrder)return y.renderOrder-d.renderOrder;const v=u.objects.get(d).distanceToCameraSquared,E=u.objects.get(y).distanceToCameraSquared;return v-E}),l=m.length;for(let d=0,y=m.length;d<y;d++)m[d].element.style.zIndex=l-d}}}class fn extends HTMLElement{ro;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;_canvas;_css2DCanvas;constructor(e){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
1
+ "use strict";var Nn=Object.create;var Gt=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var Pn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kn(e))!Mn.call(n,r)&&r!==t&&Gt(n,r,{get:()=>e[r],enumerable:!(i=wn(e,r))||i.enumerable});return n};var Dn=(n,e,t)=>(t=n!=null?Nn(Cn(n)):{},Pn(e||!n||!n.__esModule?Gt(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("three"),$t=require("fflate");function Fn(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const se=Fn(R);function en(n){return typeof n=="string"}function Mt(n){return n.isMesh===!0}function Un(n){return n.type==="RoundedBoxGeometry"}function jn(n){return n.type==="BoxGeometry"}function Bn(n){return n.type==="SphereGeometry"}function Gn(n){return n.type==="IcosahedronGeometry"}function zn(n){return n.type==="CylinderGeometry"}function Vn(n){return n.type==="CapsuleGeometry"}function Hn(n){return n.isBone===!0}function Wn(n){return n.isPerspectiveCamera===!0}class ke{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,i,r){typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}clone(){return new ke(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t,this._w/=t):console.warn("Quat.normalize."),this}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}set(e,t,i,r){return typeof e=="number"?(this._x=e,this._y=t,this._z=i,this._w=r):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}mul(e,t,i,r){const a=new ke(this),o=new ke;return typeof e=="number"?o.set(e,t,i,r):o.set(e),this._x=a.w*o.x+a.x*o.w+a.y*o.z-a.z*o.y,this._y=a.w*o.y-a.x*o.z+a.y*o.w+a.z*o.x,this._z=a.w*o.z+a.x*o.y-a.y*o.x+a.z*o.w,this._w=a.w*o.w-a.x*o.x-a.y*o.y-a.z*o.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w}slerp(e,t,i){if(i<0||i>1){console.warn("Quat.slerp(): t must be in [0,1]");return}const r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(r<.9995){const a=Math.acos(r),o=Math.sin((1-i)*a)/Math.sin(a),u=Math.sin(i*a)/Math.sin(a);this._x=o*e.x+u*t.x,this._y=o*e.y+u*t.y,this._z=o*e.z+u*t.z,this._w=o*e.w+u*t.w}else{this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z,this._w=(1-i)*e.w+i*t.w;const a=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);a<1e-4?(console.warn("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/a,this._y*=1/a,this._z*=1/a,this._w*=1/a)}}}function ct(n,e,t){t.normalize();const i=e.clone().sub(n).normalize(),r=new Ae().cross(i,t).normalize(),a=new Ae().cross(r,i),o=r.x,u=a.x,c=-i.x,s=r.y,f=a.y,h=-i.y,g=r.z,p=a.z,T=-i.z,m=o+f+T;if(m>0){const l=Math.sqrt(m+1)*2;return new ke((p-h)/l,(c-g)/l,(s-u)/l,.25*l)}else if(o>f&&o>T){const l=Math.sqrt(1+o-f-T)*2;return new ke(.25*l,(u+s)/l,(c+g)/l,(p-h)/l)}else if(f>T){const l=Math.sqrt(1+f-o-T)*2;return new ke((u+s)/l,.25*l,(h+p)/l,(c-g)/l)}else{const l=Math.sqrt(1+T-o-f)*2;return new ke((c+g)/l,(h+p)/l,.25*l,(s-u)/l)}}function tn(n,e="XYZ"){const t=new ke(0,0,0,1);for(let i=0;i<3;i++)switch(e.charAt(i)){case"X":t.mul(new ke(Math.sin(n.x),0,0,Math.cos(n.x)));break;case"Y":t.mul(new ke(0,Math.sin(n.y),0,Math.cos(n.y)));break;case"Z":t.mul(new ke(0,0,Math.sin(n.z),Math.cos(n.z)));break}return t}class Ae{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,i){typeof e=="number"?(this._x=e,this._y=t,this._z=i):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}clone(){return new Ae(this)}normalize(){const e=this._x*this._x+this._y*this._y+this._z*this._z,t=Math.sqrt(e);return t!==0?(this._x/=t,this._y/=t,this._z/=t):console.warn("Vec3.normalize."),this}negate(){return this._x*=-1,this._y*=-1,this._z*=-1,this}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}set(e,t,i){return typeof e=="number"?(this._x=e,this._y=t,this._z=i):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e,t,i){return typeof e=="number"?(this._x+=e,this._y+=t,this._z+=i):(this._x+=e.x,this._y+=e.y,this._z+=e.z),this}sub(e,t,i){return typeof e=="number"?(this._x-=e,this._y-=t,this._z-=i):(this._x-=e.x,this._y-=e.y,this._z-=e.z),this}scale(e){return this._x*=e,this._y*=e,this._z*=e,this}cross(e,t){return this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this}apply(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e);const o=new ke(this._x,this._y,this._z,0),u=new ke(a).conjugate();return a.mul(o).mul(u),this._x=a.x,this._y=a.y,this._z=a.z,this}lerp(e,t,i){this._x=(1-i)*e.x+i*t.x,this._y=(1-i)*e.y+i*t.y,this._z=(1-i)*e.z+i*t.z}}class tt{objectA3;object3D;interpolation;billboard;constructor(e){this.objectA3=e,this.object3D=e?.object}setObject(e){this.objectA3=e,this.object3D=e.object}detachObject(e){this.objectA3=void 0,this.object3D=void 0}enableInterpolation(e){e&&!this.interpolation&&this.object3D?this.interpolation=new Kn(this.object3D):!e&&this.interpolation&&(this.interpolation=void 0)}enableBillboard(e){e&&this.billboard?this.billboard.setTarget(e.object):e&&!this.billboard&&this.objectA3?this.billboard=new Yn(this.objectA3,e.object):this.billboard=void 0}update(e){this.interpolation&&this.interpolation.update(e),this.billboard&&this.billboard.update()}setLocation(e){this.interpolation?this.interpolation.setLocation(e):this.object3D?.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setLocationNow(e){this.interpolation?this.interpolation.setLocationNow(e):this.object3D?.position.set(e.x,e.y,e.z),this.billboard&&this.billboard.update()}setQuat(e){this.billboard||(this.interpolation?this.interpolation.setQuat(e):this.object3D?.quaternion.set(e.x,e.y,e.z,e.w))}setQuatNow(e){this.billboard||(this.interpolation?this.interpolation.setQuatNow(e):this.object3D?.quaternion.set(e.x,e.y,e.z,e.w))}setScale(e){this.interpolation?this.interpolation.setScale(e):this.object3D?.scale.set(e.x,e.y,e.z)}setScaleNow(e){this.interpolation?this.interpolation.setScaleNow(e):this.object3D?.scale.set(e.x,e.y,e.z)}controlMotion(...e){}setPause(e){}setTime(e){}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}}class Kn{obj;firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.obj=e,this.firstLoc=new Ae(e.position),this.firstRot=new ke(e.quaternion),this.firstScale=new Ae(e.scale),this.nowLoc=new Ae(e.position),this.nowRot=new ke(e.quaternion),this.nowScale=new Ae(e.scale),this.lastLoc=new Ae(e.position),this.lastRot=new ke(e.quaternion),this.lastScale=new Ae(e.scale),this.nowTime=0,this.duration=1}setLocation(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastLoc.set(e),this.nowTime=0}setLocationNow(e){this.setLocation(e),this.nowTime=1}setQuat(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastRot.set(e),this.nowTime=0}setQuatNow(e){this.setQuat(e),this.nowTime=1}setScale(e){this.firstLoc.set(this.obj.position),this.firstRot.set(this.obj.quaternion),this.firstScale.set(this.obj.scale),this.lastScale.set(e),this.nowTime=0}setScaleNow(e){this.setScale(e),this.nowTime=1}smoothstep(e){return e*e*(3-2*e)}update(e){this.nowTime+=e,this.nowTime>this.duration&&(this.nowTime=this.duration);const t=this.nowTime/this.duration,i=this.smoothstep(t);this.nowLoc.lerp(this.firstLoc,this.lastLoc,i),this.nowRot.slerp(this.firstRot,this.lastRot,i),this.nowScale.lerp(this.firstScale,this.lastScale,i),this.obj.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),this.obj.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),this.obj.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class Yn{up;obj;target;tmpObjLoc=new Ae;tmpTargetLoc=new Ae;constructor(e,t){this.up=new Ae,e.upVector?this.up.set(e.upVector):this.up.set(je.defaultUpVector),this.obj=e.object,this.target=t}setTarget(e){this.target=e}update(){this.tmpObjLoc.set(this.obj.position),this.tmpTargetLoc.set(this.target.position);const e=ct(this.tmpObjLoc,this.tmpTargetLoc,this.up);this.obj.quaternion.set(e.x,e.y,e.z,e.w)}}const nn={rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};class rn extends tt{}let Ve;const xt=new Map;class lt{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!lt.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),lt.RAPIER=e,Ve=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOption(e)&&(t=e.timestep);const i=new Ve.World(e.gravity);return new Xn(i,t)}isRapierWorldOption(e){return"timestep"in e}}class Xn{world;timestep;collisionEventQueue;constructor(e,t){this.world=e,this.timestep=t,this.collisionEventQueue=new Ve.EventQueue(!0),this.world.integrationParameters.dt=this.timestep}add(e){e instanceof zt&&e.addOneselfToPhysics(this)}remove(e){e instanceof zt&&e.removeOneselfFromPhysics(this)}update(e){const t=Math.ceil(e/this.timestep);for(let i=0;i<t;i++)this.world.step(this.collisionEventQueue)}getCollisions(){const e=[];return this.collisionEventQueue.drainCollisionEvents((t,i,r)=>{const a=xt.get(t),o=xt.get(i);a&&o&&e.push({objectA:a,partOfA:t,objectB:o,partOfB:i,started:r})}),e}}class zt extends rn{}class qn extends rn{bodyDesc;body;colliderDescs;colliders;completeOption;constructor(e,t={}){super(e),this.colliderDescs=[],this.colliders=[],this.completeOption={...nn,...t}}setObject(e){super.setObject(e),this.bodyDesc=void 0,this.body=void 0,this.colliderDescs=[],this.colliders=[],this.myInitialize(e)}detachObject(e){this.bodyDesc=void 0,this.body=void 0,this.colliderDescs=[],this.colliders=[]}myInitialize(e){const t=this.completeOption;switch(t.rigidBody){case"dynamic":this.bodyDesc=Ve.RigidBodyDesc.dynamic();break;case"kinematic":this.bodyDesc=Ve.RigidBodyDesc.kinematicPositionBased();break;case"fixed":this.bodyDesc=Ve.RigidBodyDesc.fixed();break}this.bodyDesc.setTranslation(e.object.position.x,e.object.position.y,e.object.position.z),this.bodyDesc.setRotation({x:e.object.quaternion.x,y:e.object.quaternion.y,z:e.object.quaternion.z,w:e.object.quaternion.w});const i=[];e.object.traverse(a=>{if(Mt(a)){const o=Jn(a.geometry),u=t.membership<<16|t.filter;if(o)o.colliderDesc.setCollisionGroups(u),t.collisionDetection&&o.colliderDesc.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(o.colliderDesc),o.colliderDesc.setRestitution(t.restitution).setFriction(t.friction),i.push(o.volume);else{let c,s;switch(t.meshCollider){case"tri_mesh":c=Qn(a),s=Vt(a.geometry);break;case"convex_hull":c=Zn(a),s=Vt(a.geometry);break}c&&(c.setCollisionGroups(u),t.collisionDetection&&c.setActiveEvents(Ve.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(c),i.push(s))}}});let r=i.reduce((a,o)=>a+o,0);for(let a=0;a<this.colliderDescs.length;a++)this.colliderDescs[a].setRestitution(t.restitution),this.colliderDescs[a].setFriction(t.friction),this.colliderDescs[a].setMass(t.mass*(i[a]/r))}update(e){if(this.body){const t=this.body.translation();this.object3D?.position.set(t.x,t.y,t.z);const i=this.body.rotation();this.object3D?.quaternion.set(i.x,i.y,i.z,i.w)}}setLocation(e){}setLocationNow(e){this.body&&this.body.setTranslation(e,!0)}setQuat(e){}setQuatNow(e){this.body&&this.body.setRotation(e,!0)}setScale(e){}setScaleNow(e){}addOneselfToPhysics(e){this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc)),this.colliderDescs.forEach(t=>{const i=e.world.createCollider(t,this.body);this.colliders.push(i),this.objectA3&&xt.set(i.handle,this.objectA3)})}removeOneselfFromPhysics(e){this.body&&e.world.removeRigidBody(this.body),this.colliders.forEach(t=>{e.world.removeCollider(t,!1)})}}function Qn(n){let e=null;if(Mt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;let a=i.index?i.index.array:null;if(a)a instanceof Uint32Array||(a=new Uint32Array(a));else{const o=i.attributes.position.count;a=new Uint32Array(o);for(let u=0;u<o;u++)a[u]=u}r instanceof Float32Array&&(e=Ve.ColliderDesc.trimesh(r,a))}return e}function Zn(n){let e=null;if(Mt(n)){const t=n;t.updateWorldMatrix(!0,!0);const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position.array;r instanceof Float32Array&&(e=Ve.ColliderDesc.convexHull(r))}return e}function Vt(n){const e=n.attributes.position;if(!e)throw new Error("position attribute not found");const t=n.index,i=e.array;let r=0;const a=new se.Vector3,o=new se.Vector3,u=new se.Vector3;if(t){const c=t.array;for(let s=0;s<c.length;s+=3){const f=c[s]*3,h=c[s+1]*3,g=c[s+2]*3;a.set(i[f],i[f+1],i[f+2]),o.set(i[h],i[h+1],i[h+2]),u.set(i[g],i[g+1],i[g+2]),r+=a.dot(o.clone().cross(u))}}else for(let c=0;c<i.length;c+=9)a.set(i[c],i[c+1],i[c+2]),o.set(i[c+3],i[c+4],i[c+5]),u.set(i[c+6],i[c+7],i[c+8]),r+=a.dot(o.clone().cross(u));return Math.abs(r)/6}function Jn(n){if(Un(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,a=.1;return{colliderDesc:Ve.ColliderDesc.roundCuboid(t-a,i-a,r-a,a),volume:2*t*2*i*2*r}}else if(jn(n)){const e=n.parameters,t=typeof e?.width=="number"?e.width/2:.5,i=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Ve.ColliderDesc.cuboid(t,i,r),volume:2*t*2*i*2*r}}else if(Bn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Gn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Ve.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(zn(n)){const e=n.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.cylinder(i/2,t),volume:Math.PI*t*t*i}}else if(Vn(n)){const e=n.parameters,t=typeof e?.radius=="number"?e.radius:.5,i=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Ve.ColliderDesc.capsule(i/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*i}}return null}const It=new lt;async function $n(){await It.init()}class on{scene;objects;physicsWorld=null;physicsDt=1/60;collisionListener;constructor(){this.scene=new se.Scene,this.objects=[],It.isInitialized&&(this.physicsWorld=It.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt}))}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,this.physicsWorld&&e.motion.addOneselfToPhysics(this.physicsWorld)}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,this.physicsWorld&&e.motion.removeOneselfFromPhysics(this.physicsWorld)}setCollisionListener(e){this.collisionListener=e}update(e){if(this.physicsWorld){this.physicsWorld.update(e);const t=this.physicsWorld.getCollisions();t.forEach(i=>{i.objectA.handleCollision(i.objectB,i.started,i.partOfA,i.partOfB),i.objectB.handleCollision(i.objectA,i.started,i.partOfB,i.partOfA)}),this.collisionListener&&t.length>0&&this.collisionListener(t)}for(const t of this.objects)t.update(e)}}class je{static defaultRotationOrder="XYZ";static defaultUpVector=new Ae(0,1,0);rotationOrder=null;upVector=null;object;scene=null;balloon=null;motion;parent=null;children=[];clickListener;constructor(e){this.object=this.initObject(e),this.object.traverse(t=>{t.userData.a3js={objectA3:this}}),this.motion=this.initMotion(),this.motion.setObject(this)}initMotion(e){return new tt(this)}setMotion(e){e.setObject(this),this.motion=e}detachMotion(){const e=new tt(this),t=this.motion;return t.detachObject(this),this.motion=e,e.setObject(this),t}replaceMotion(e){const t=this.motion;return t.detachObject(this),this.motion=e,e.setObject(this),t}controlMotion(...e){this.motion.controlMotion(...e)}enableInterpolation(e){this.motion.enableInterpolation(e)}initDefaultPhysics(e){const t={...nn,...e};this.motion=new qn(this,t),this.motion.setObject(this)}update(e){this.motion.update(e),this.children.forEach(t=>{t.update(e)})}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object.add(e.object)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=null,this.object.remove(e.object)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new er(e)}setClickListener(e){this.clickListener=e}handleCollision(e,t,i,r){}async clicked(){this.clickListener&&await this.clickListener(this)}get locX(){return this.object.position.x}get locY(){return this.object.position.y}get locZ(){return this.object.position.z}setLocation(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocation(r)}setLocationNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setLocationNow(r),this.object.position.set(r.x,r.y,r.z)}get quatX(){return this.object.quaternion.x}get quatY(){return this.object.quaternion.y}get quatZ(){return this.object.quaternion.z}get quatW(){return this.object.quaternion.w}setQuat(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e),this.motion.setQuat(a)}setQuatNow(e,t,i,r){const a=new ke;typeof e=="number"?a.set(e,t,i,r):a.set(e),this.motion.setQuatNow(a)}get scaleX(){return this.object.scale.x}get scaleY(){return this.object.scale.y}get scaleZ(){return this.object.scale.z}setScale(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScale(r)}setScaleNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),this.motion.setScaleNow(r)}setRotation(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e),r.scale(Math.PI/360);const a=this.rotationOrder?this.rotationOrder:je.defaultRotationOrder,o=tn(r,a);this.setQuat(o)}setRotationNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):r.set(e);const a=this.rotationOrder?this.rotationOrder:je.defaultRotationOrder,o=new ke(0,0,0,1);for(let u=0;u<3;u++)switch(a.charAt(u)){case"X":o.mul(new ke(Math.sin(r.x),0,0,Math.cos(r.x)));break;case"Y":o.mul(new ke(0,Math.sin(r.y),0,Math.cos(r.y)));break;case"Z":o.mul(new ke(0,0,Math.sin(r.z),Math.cos(r.z)));break}this.setQuatNow(o)}lookAt(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):e instanceof je?r.set(e.locX,e.locY,e.locZ):r.set(e);const a=this.upVector?this.upVector:je.defaultUpVector,o=ct(new Ae(this.object.position),r,a);this.setQuat(o)}lookAtNow(e,t,i){const r=new Ae;typeof e=="number"?r.set(e,t,i):e instanceof je?r.set(e.locX,e.locY,e.locZ):r.set(e);const a=this.upVector?this.upVector:je.defaultUpVector,o=ct(new Ae(this.object.position),r,a);this.setQuatNow(o)}getUnitVecX(){return new Ae(1,0,0).apply(this.object.quaternion)}getUnitVecY(){return new Ae(0,1,0).apply(this.object.quaternion)}getUnitVecZ(){return new Ae(0,0,1).apply(this.object.quaternion)}}class er{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class sn extends je{controller;setController(e){this.controller=e}setLocation(e,t,i){typeof e=="number"?super.setLocation(e,t,i):super.setLocation(e),this.controller?.setCameraLocation(this.object.position)}}class an{view;constructor(e){this.view=e,e.setController(this)}update(e){}activate(){}deactivate(){}keyDown(e){}keyUp(e){}keyPress(e){}mouseDown(e){}mouseUp(e){}mouseMove(e){}mouseClick(e){}mouseEnter(e){}mouseLeave(e){}mouseWheel(e){}touchStart(e){}touchEnd(e){}touchMove(e){}touchCancel(e){}setCameraLocation(e){}setCameraLocationNow(e){}setCameraQuat(e){}setCameraQuatNow(e){}setCameraScale(e){}setCameraScaleNow(e){}}class cn extends an{preMouse;leftClick=!1;target;cameraLoc=new Ae(0,0,3);cameraQuat=new ke(0,0,0,1);constructor(e,t,i,r){super(e),this.preMouse={x:0,y:0},typeof t=="number"?this.target=new Ae(t,i,r):this.target=new Ae(t)}update(e){this.view.camera.setLocation(this.cameraLoc),this.view.camera.setQuat(this.cameraQuat)}mouseDown(e){e.button===0&&(this.leftClick=!0,this.preMouse.x=e.clientX,this.preMouse.y=e.clientY)}mouseMove(e){if(this.leftClick===!1)return;const t=.01,i=t*(e.clientX-this.preMouse.x),r=t*(e.clientY-this.preMouse.y),a=Math.sin(-i),o=Math.cos(-i),u=Math.sin(-r),c=Math.cos(-r),s=new Ae(1,0,0).apply(this.cameraQuat),f=new Ae(0,1,0).apply(this.cameraQuat),h=new ke(s.x*u,s.y*u,s.z*u,c),g=new ke(f.x*a,f.y*a,f.z*a,o),p=new Ae(this.cameraLoc);p.sub(this.target),p.apply(h),p.apply(g),p.add(this.target),this.cameraLoc.set(p);const T=ct(this.cameraLoc,this.target,new Ae(0,1,0));this.cameraQuat.set(T),this.preMouse.x=e.clientX,this.preMouse.y=e.clientY}mouseUp(e){e.button===0&&(this.leftClick=!1)}mouseWheel(e){const t=new Ae(this.target).sub(this.cameraLoc);e.deltaY>0?t.scale(.05):e.deltaY<0&&t.scale(-.05),this.cameraLoc.add(t)}setCameraLocation(e){this.cameraLoc.set(e)}setCameraLocationNow(e){this.cameraLoc.set(e)}}function tr(n){return new Promise(e=>{setTimeout(()=>{e()},n)})}async function ln(n){const t=await(await fetch(n)).arrayBuffer(),i=await new Promise((r,a)=>{$t.unzip(new Uint8Array(t),(o,u)=>{o?a(o):r(u)})});return{zipUrl:n,unzipped:i}}function Pt(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n.unzipped[e])return $t.strFromU8(n.unzipped[e]);throw new Error(`readStringFromUnzippedA3(): no file at ${e}`)}function nr(n,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),n.unzipped[e]){const t=ir(e);return new Blob([new Uint8Array(n.unzipped[e])],{type:t})}else throw new Error(`readBlobFromUnzippedA3(): no file at ${e}`)}const rr={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function ir(n){for(const[e,t]of Object.entries(rr))if(t.test(n))return e;return"application/octet-stream"}function yt(n,e){if(!e)return n;const t={...n};for(const i in e)typeof n[i]=="object"&&typeof e[i]=="object"?t[i]=yt(n[i],e[i]):t[i]=e[i];return t}const or={type:"audio",autoplay:!1,loop:!1,volume:1,positional:{refDistance:1,maxDistance:1e3,rolloffFactor:1,directional:{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0}}};async function sr(){try{$e.listener.context.state!=="running"&&await $e.listener.context.resume()}catch{console.warn("AudioContext resume failed. Did you call on user gesture?")}}class $e extends je{static listener=new se.AudioListener;static audioLoader=new se.AudioLoader;ready;config;sound;constructor(e,t={}){super(),this.config=yt(or,t),this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}async asyncInit(e){if(this.config.type==="positional"){const t=new se.PositionalAudio($e.listener);t.setRefDistance(this.config.positional.refDistance),t.setMaxDistance(this.config.positional.maxDistance),t.setRolloffFactor(this.config.positional.rolloffFactor);const i=this.config.positional.directional;t.setDirectionalCone(i.coneInnerAngle,i.coneOuterAngle,i.coneOuterGain),t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}else{const t=new se.Audio($e.listener);t.setVolume(this.config.volume),t.setLoop(this.config.loop),this.sound=t}return this.object.add(this.sound),new Promise(t=>{$e.audioLoader.load(e,i=>{this.sound&&this.sound.setBuffer(i),t(this)})})}play(){this.sound?.play()}}class Dt{scene;camera;controller;constructor(e){this.scene=new on,this.camera=e,this.camera.setAudioListener($e.listener),this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3),this.controller=new cn(this,0,0,0),this.camera.setController(this.controller)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e),this.controller?.update(e),this.camera.update(e)}setController(e){this.controller?.deactivate(),this.controller=e,this.controller.activate(),this.camera.setController(e)}worldToScreen(e){throw new Error("ViewBaseはworldToScreen()は実装していません")}screenToWorld(e,t,i){throw new Error("ViewBaseはscreenToWorld()は実装していません")}cameraToScreen(e){throw new Error("ViewBaseはcameraToScreen()は実装していません")}screenToCamera(e,t,i){throw new Error("ViewBaseはscreenToCamera()は実装していません")}}class ut extends sn{camera;headLight;constructor(e){super(),this.camera=e,this.headLight=new se.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new se.Object3D}setAudioListener(e){this.camera.add(e)}getHeadLight(){return this.headLight}setAspect(e){Wn(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}calcNDC(e){const t=new se.Vector3(e.x,e.y,e.z);return t.project(this.camera),{x:t.x,y:t.y}}}class un extends R.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new R.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const rt=new R.Vector3,Ht=new R.Matrix4,Wt=new R.Matrix4,Kt=new R.Vector3,Yt=new R.Vector3;class hn{constructor(e={}){const t=this;let i,r,a,o;const u={objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(T,m){T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),m.parent===null&&m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),Ht.copy(m.matrixWorldInverse),Wt.multiplyMatrices(m.projectionMatrix,Ht),f(T,T,m),this.sortObjects&&p(T)},this.setSize=function(T,m){i=T,r=m,a=i/2,o=r/2,c.style.width=T+"px",c.style.height=m+"px"};function s(T){T.isCSS2DObject&&(T.element.style.display="none");for(let m=0,l=T.children.length;m<l;m++)s(T.children[m])}function f(T,m,l){if(T.visible===!1){s(T);return}if(T.isCSS2DObject){rt.setFromMatrixPosition(T.matrixWorld),rt.applyMatrix4(Wt);const d=rt.z>=-1&&rt.z<=1&&T.layers.test(l.layers)===!0,y=T.element;y.style.display=d===!0?"":"none",d===!0&&(T.onBeforeRender(t,m,l),y.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(rt.x*a+a)+"px,"+(-rt.y*o+o)+"px)",y.parentNode!==c&&c.appendChild(y),T.onAfterRender(t,m,l));const v={distanceToCameraSquared:h(l,T)};u.objects.set(T,v)}for(let d=0,y=T.children.length;d<y;d++)f(T.children[d],m,l)}function h(T,m){return Kt.setFromMatrixPosition(T.matrixWorld),Yt.setFromMatrixPosition(m.matrixWorld),Kt.distanceToSquared(Yt)}function g(T){const m=[];return T.traverseVisible(function(l){l.isCSS2DObject&&m.push(l)}),m}function p(T){const m=g(T).sort(function(d,y){if(d.renderOrder!==y.renderOrder)return y.renderOrder-d.renderOrder;const v=u.objects.get(d).distanceToCameraSquared,E=u.objects.get(y).distanceToCameraSquared;return v-E}),l=m.length;for(let d=0,y=m.length;d<y;d++)m[d].element.style.zIndex=l-d}}}class fn extends HTMLElement{ro;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;_canvas;_css2DCanvas;constructor(e){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  :host {
4
4
  width: 100%;
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </style>
23
23
  <slot></slog>
24
- `,e||(e={}),e.camera||(e.camera=new se.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new ut(e.camera);this.base=new Ft(t),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new se.Clock;const i={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new se.WebGLRenderer(i),this.renderer.setSize(600,300),"opaque"in e&&this.renderer.setClearAlpha(0),this._canvas=this.renderer.domElement,this._canvas.width=600,this._canvas.height=300,this.appendChild(this._canvas),this.css2DRenderer=new hn,this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="0px",this.appendChild(this._css2DCanvas),this.animationFrameId=requestAnimationFrame(this.renderingLoop),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)})}connectedCallback(){this.ro=new ResizeObserver(()=>{const e=window.devicePixelRatio||1,t=Math.floor(this.clientWidth*e),i=Math.floor(this.clientHeight*e);(this._canvas.width!==t||this._canvas.height!==i)&&(this._canvas.width=t,this._canvas.height=i,ar(this.camera3js)&&(this.camera3js.aspect=t/i,this.camera3js.updateProjectionMatrix()),this.renderer.setSize(t,i),this.css2DRenderer.setSize(t,i))}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new se.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new se.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,a=(1-t.y)/2*i.y;return{x:r,y:a}}screenToWorld(e,t,i){const r=new se.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const a=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(a.multiplyScalar(i))}cameraToScreen(e){const i=new se.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new se.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=async e=>{if(this.camera instanceof ut){const t=new se.Raycaster,i=new se.Vector2,r=e.target.getBoundingClientRect(),a=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(a/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),c=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;c.push({three:s.object,a3js:f})}),c.length>0&&await c[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 0px; width: 100%; height: 100%; display: flex; flex-direction: column;";const a=document.createElement("p");a.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",a.textContent=e,r.appendChild(a);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("canvas-a3",fn);function ar(n){return n.isPerspectiveCamera===!0}class dn extends HTMLElement{_resizeObserver;_dragging=!1;_resizing=!1;_resizeDir="";_startMouseX=0;_startMouseY=0;_startLeft=0;_startTop=0;_startWidth=0;_startHeight=0;_borderSize=5;_canvas;_css2DCanvas;_titleEl=null;_titleBar=null;_closeBtn=null;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;constructor(e=600,t=300){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
24
+ `,e||(e={}),e.camera||(e.camera=new se.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new ut(e.camera);this.base=new Dt(t),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new se.Clock;const i={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new se.WebGLRenderer(i),this.renderer.setSize(600,300),"opaque"in e&&this.renderer.setClearAlpha(0),this._canvas=this.renderer.domElement,this._canvas.width=600,this._canvas.height=300,this.appendChild(this._canvas),this.css2DRenderer=new hn,this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="0px",this.appendChild(this._css2DCanvas),this.animationFrameId=requestAnimationFrame(this.renderingLoop),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)})}connectedCallback(){this.ro=new ResizeObserver(()=>{const e=window.devicePixelRatio||1,t=Math.floor(this.clientWidth*e),i=Math.floor(this.clientHeight*e);(this._canvas.width!==t||this._canvas.height!==i)&&(this._canvas.width=t,this._canvas.height=i,ar(this.camera3js)&&(this.camera3js.aspect=t/i,this.camera3js.updateProjectionMatrix()),this.renderer.setSize(t,i),this.css2DRenderer.setSize(t,i))}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new se.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new se.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,a=(1-t.y)/2*i.y;return{x:r,y:a}}screenToWorld(e,t,i){const r=new se.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const a=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(a.multiplyScalar(i))}cameraToScreen(e){const i=new se.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new se.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=async e=>{if(this.camera instanceof ut){const t=new se.Raycaster,i=new se.Vector2,r=e.target.getBoundingClientRect(),a=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(a/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),c=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;c.push({three:s.object,a3js:f})}),c.length>0&&await c[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 0px; width: 100%; height: 100%; display: flex; flex-direction: column;";const a=document.createElement("p");a.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",a.textContent=e,r.appendChild(a);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("canvas-a3",fn);function ar(n){return n.isPerspectiveCamera===!0}class dn extends HTMLElement{_resizeObserver;_dragging=!1;_resizing=!1;_resizeDir="";_startMouseX=0;_startMouseY=0;_startLeft=0;_startTop=0;_startWidth=0;_startHeight=0;_borderSize=5;_canvas;_css2DCanvas;_titleEl=null;_titleBar=null;_closeBtn=null;base;renderer;css2DRenderer;scene;camera;controller;camera3js;clock;constructor(e=600,t=300){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
25
25
  <style>
26
26
  :host {
27
27
  position: absolute;
@@ -66,7 +66,7 @@
66
66
  <div class="content">
67
67
  <slot></slot>
68
68
  </div>
69
- `,this.camera3js=new se.PerspectiveCamera(75,e/t,.1,1e3),this.camera3js.aspect=e/t;const i=new ut(this.camera3js);this.base=new Ft(i),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new se.Clock,this.renderer=new se.WebGLRenderer,this.renderer.setSize(e,t),this._canvas=this.renderer.domElement,this._canvas.width=e,this._canvas.width=t,this.appendChild(this._canvas),this.css2DRenderer=new hn,this.css2DRenderer.setSize(e,t),this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="28px",this.appendChild(this._css2DCanvas),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)}),document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0}),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}_resizeCanvasToContent(){const e=this.shadowRoot.querySelector(".content");let t=e.clientWidth,i=e.clientHeight;const r=window.devicePixelRatio||1,a=Math.floor(t*r),o=Math.floor(i*r);(this._canvas.width!==a||this._canvas.height!==o)&&(this._canvas.width=a,this._canvas.height=o,this.camera3js.aspect=a/o,this.camera3js.updateProjectionMatrix(),this.renderer.setSize(a,o),this.css2DRenderer.setSize(a,o))}connectedCallback(){this._titleEl=this.shadowRoot.querySelector(".title"),this._titleEl.textContent=this.getAttribute("title")??"Window",this._titleBar=this.shadowRoot.querySelector(".titlebar"),this._closeBtn=this.shadowRoot.querySelector(".close"),this._titleBar.addEventListener("mousedown",this._onDragStart),this._closeBtn.addEventListener("click",()=>this.remove()),this.addEventListener("mousemove",this._onHover),this.addEventListener("mousedown",this._onResizeStart),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),this._resizeObserver=new ResizeObserver(()=>{this._canvas&&this._resizeCanvasToContent()});const e=this.shadowRoot.querySelector(".content");this._resizeObserver.observe(e),this._resizeCanvasToContent()}disconnectedCallback(){document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._resizeObserver?.disconnect()}_onDragStart=e=>{this._resizeDir||(this._dragging=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop)};_onHover=e=>{if(this._dragging||this._resizing)return;const t=this.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,a=this._borderSize;let o="";r<a?o+="n":r>t.height-a&&(o+="s"),i<a?o+="w":i>t.width-a&&(o+="e"),this._resizeDir=o,this.style.cursor=this._cursorFromDir(o)};_cursorFromDir(e){switch(e){case"n":return"ns-resize";case"s":return"ns-resize";case"e":return"ew-resize";case"w":return"ew-resize";case"ne":return"nesw-resize";case"sw":return"nesw-resize";case"nw":return"nwse-resize";case"se":return"nwse-resize";default:return"default"}}_onResizeStart=e=>{this._resizeDir&&(this._resizing=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop,this._startWidth=this.offsetWidth,this._startHeight=this.offsetHeight)};_onMouseMove=e=>{if(this._dragging&&(this.style.left=`${this._startLeft+(e.clientX-this._startMouseX)}px`,this.style.top=`${this._startTop+(e.clientY-this._startMouseY)}px`),this._resizing){const t=e.clientX-this._startMouseX,i=e.clientY-this._startMouseY;this._resizeDir.includes("e")&&(this.style.width=`${this._startWidth+t}px`),this._resizeDir.includes("s")&&(this.style.height=`${this._startHeight+i}px`),this._resizeDir.includes("w")&&(this.style.width=`${this._startWidth-t}px`,this.style.left=`${this._startLeft+t}px`),this._resizeDir.includes("n")&&(this.style.height=`${this._startHeight-i}px`,this.style.top=`${this._startTop+i}px`)}};_onMouseUp=()=>{this._dragging=!1,this._resizing=!1};replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new se.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new se.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,a=(1-t.y)/2*i.y;return{x:r,y:a}}screenToWorld(e,t,i){const r=new se.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const a=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(a.multiplyScalar(i))}cameraToScreen(e){const i=new se.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new se.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=async e=>{if(this.camera instanceof ut){const t=new se.Raycaster,i=new se.Vector2,r=e.target.getBoundingClientRect(),a=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(a/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),c=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;c.push({three:s.object,a3js:f})}),c.length>0&&await c[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 28px; width: 100%; height: 100%; display: flex; flex-direction: column;";const a=document.createElement("p");a.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",a.textContent=e,r.appendChild(a);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("window-a3",dn);const cr=`
69
+ `,this.camera3js=new se.PerspectiveCamera(75,e/t,.1,1e3),this.camera3js.aspect=e/t;const i=new ut(this.camera3js);this.base=new Dt(i),this.scene=this.base.scene,this.camera=this.base.camera,this.controller=this.base.controller,this.clock=new se.Clock,this.renderer=new se.WebGLRenderer,this.renderer.setSize(e,t),this._canvas=this.renderer.domElement,this._canvas.width=e,this._canvas.width=t,this.appendChild(this._canvas),this.css2DRenderer=new hn,this.css2DRenderer.setSize(e,t),this._css2DCanvas=this.css2DRenderer.domElement,this._css2DCanvas.style.position="absolute",this._css2DCanvas.style.top="28px",this.appendChild(this._css2DCanvas),this._css2DCanvas.addEventListener("click",this.myMouseClickedListener),window.addEventListener("keydown",r=>{this.controller?.keyDown(r)}),window.addEventListener("keyup",r=>{this.controller?.keyUp(r)}),window.addEventListener("keypress",r=>{this.controller?.keyPress(r)}),this._css2DCanvas.addEventListener("mousedown",r=>{this.controller?.mouseDown(r)}),this._css2DCanvas.addEventListener("mouseup",r=>{this.controller?.mouseUp(r)}),this._css2DCanvas.addEventListener("mousemove",r=>{this.controller?.mouseMove(r)}),this._css2DCanvas.addEventListener("click",r=>{this.controller?.mouseClick(r)}),this._css2DCanvas.addEventListener("mouseenter",r=>{this.controller?.mouseEnter(r)}),this._css2DCanvas.addEventListener("mouseleave",r=>{this.controller?.mouseLeave(r)}),this._css2DCanvas.addEventListener("wheel",r=>{this.controller?.mouseWheel(r)}),this._css2DCanvas.addEventListener("touchstart",r=>{this.controller?.touchStart(r)}),this._css2DCanvas.addEventListener("touchmove",r=>{this.controller?.touchMove(r)}),this._css2DCanvas.addEventListener("touchend",r=>{this.controller?.touchEnd(r)}),this._css2DCanvas.addEventListener("touchcancel",r=>{this.controller?.touchCancel(r)}),document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0}),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}_resizeCanvasToContent(){const e=this.shadowRoot.querySelector(".content");let t=e.clientWidth,i=e.clientHeight;const r=window.devicePixelRatio||1,a=Math.floor(t*r),o=Math.floor(i*r);(this._canvas.width!==a||this._canvas.height!==o)&&(this._canvas.width=a,this._canvas.height=o,this.camera3js.aspect=a/o,this.camera3js.updateProjectionMatrix(),this.renderer.setSize(a,o),this.css2DRenderer.setSize(a,o))}connectedCallback(){this._titleEl=this.shadowRoot.querySelector(".title"),this._titleEl.textContent=this.getAttribute("title")??"Window",this._titleBar=this.shadowRoot.querySelector(".titlebar"),this._closeBtn=this.shadowRoot.querySelector(".close"),this._titleBar.addEventListener("mousedown",this._onDragStart),this._closeBtn.addEventListener("click",()=>this.remove()),this.addEventListener("mousemove",this._onHover),this.addEventListener("mousedown",this._onResizeStart),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),this._resizeObserver=new ResizeObserver(()=>{this._canvas&&this._resizeCanvasToContent()});const e=this.shadowRoot.querySelector(".content");this._resizeObserver.observe(e),this._resizeCanvasToContent()}disconnectedCallback(){document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._resizeObserver?.disconnect()}_onDragStart=e=>{this._resizeDir||(this._dragging=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop)};_onHover=e=>{if(this._dragging||this._resizing)return;const t=this.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,a=this._borderSize;let o="";r<a?o+="n":r>t.height-a&&(o+="s"),i<a?o+="w":i>t.width-a&&(o+="e"),this._resizeDir=o,this.style.cursor=this._cursorFromDir(o)};_cursorFromDir(e){switch(e){case"n":return"ns-resize";case"s":return"ns-resize";case"e":return"ew-resize";case"w":return"ew-resize";case"ne":return"nesw-resize";case"sw":return"nesw-resize";case"nw":return"nwse-resize";case"se":return"nwse-resize";default:return"default"}}_onResizeStart=e=>{this._resizeDir&&(this._resizing=!0,this._startMouseX=e.clientX,this._startMouseY=e.clientY,this._startLeft=this.offsetLeft,this._startTop=this.offsetTop,this._startWidth=this.offsetWidth,this._startHeight=this.offsetHeight)};_onMouseMove=e=>{if(this._dragging&&(this.style.left=`${this._startLeft+(e.clientX-this._startMouseX)}px`,this.style.top=`${this._startTop+(e.clientY-this._startMouseY)}px`),this._resizing){const t=e.clientX-this._startMouseX,i=e.clientY-this._startMouseY;this._resizeDir.includes("e")&&(this.style.width=`${this._startWidth+t}px`),this._resizeDir.includes("s")&&(this.style.height=`${this._startHeight+i}px`),this._resizeDir.includes("w")&&(this.style.width=`${this._startWidth-t}px`,this.style.left=`${this._startLeft+t}px`),this._resizeDir.includes("n")&&(this.style.height=`${this._startHeight-i}px`,this.style.top=`${this._startTop+i}px`)}};_onMouseUp=()=>{this._dragging=!1,this._resizing=!1};replaceScene(e){return this.scene=e,this.base.replaceScene(e)}setController(e){this.controller=e,this.base.setController(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js),this.css2DRenderer.render(this.scene.scene,this.camera3js)};worldToScreen(e){const t=new se.Vector3(e.x,e.y,e.z);t.project(this.camera3js);const i=new se.Vector2;this.renderer.getSize(i);const r=(t.x+1)/2*i.x,a=(1-t.y)/2*i.y;return{x:r,y:a}}screenToWorld(e,t,i){const r=new se.Vector3(e/this._canvas.clientWidth*2-1,-(t/this._canvas.clientHeight)*2+1,.5);r.unproject(this.camera3js);const a=r.sub(this.camera3js.position).normalize();return this.camera3js.position.clone().add(a.multiplyScalar(i))}cameraToScreen(e){const i=new se.Vector3(e.x,e.y,e.z).applyMatrix4(this.camera3js.matrixWorld);return this.worldToScreen(i)}screenToCamera(e,t,i){const r=this.screenToWorld(e,t,i);return new se.Vector3(r.x,r.y,r.z).applyMatrix4(this.camera3js.matrixWorldInverse)}myMouseClickedListener=async e=>{if(this.camera instanceof ut){const t=new se.Raycaster,i=new se.Vector2,r=e.target.getBoundingClientRect(),a=e.clientX-r.left,o=e.clientY-r.top;i.x=2*(a/r.width)-1,i.y=-2*(o/r.height)+1,t.setFromCamera(i,this.camera.camera);const u=t.intersectObjects(this.scene.scene.children),c=[];u.forEach(s=>{const f=s.object.userData.a3js?.objectA3;c.push({three:s.object,a3js:f})}),c.length>0&&await c[0].a3js.clicked(),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}};alert(e,t){return new Promise(i=>{const r=document.createElement("div");r.style.cssText="position: absolute; top: 28px; width: 100%; height: 100%; display: flex; flex-direction: column;";const a=document.createElement("p");a.style.cssText="width: 80%; margin: 0 auto; color: red; text-align: center; border: 3px solid red;",a.textContent=e,r.appendChild(a);const o=document.createElement("button");o.textContent="OK!",r.appendChild(o),this.appendChild(r),o.addEventListener("click",async()=>{t&&await t(),this.removeChild(r),i()})})}}customElements.define("window-a3",dn);const cr=`
70
70
  color: white;
71
71
  padding: 5px 10px;
72
72
  background: rgba(0, 0, 0, 0.6);
@@ -76,8 +76,8 @@
76
76
  font-size: 14px;
77
77
  pointer-events: none; /* マウスイベントを透過させて背後の操作を邪魔しない */
78
78
  `,lr={testMode:!0};class ur extends je{constructor(e){super(e)}initObject(){const e=new se.BoxGeometry,t=new se.MeshStandardMaterial({color:65280}),i=new se.Mesh(e,t),r=document.createElement("div");r.textContent="Hello Box!",r.style.cssText=cr;const a=new un(r);return a.position.set(0,.8,0),i.add(a),i}initMotion(e){const t=yt(lr,e);return new hr(this,t)}}class hr extends tt{testMode=!0;constructor(e,t){super(e),this.testMode=t.testMode}update(e){this.testMode&&this.object3D?(this.object3D.rotation.x+=e,this.object3D.rotation.y+=e,this.object3D.rotation.z+=e):super.update(e)}}class fr extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const a=this,o=new R.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(u){const c=a.parse(JSON.parse(u));t&&t(c)},i,r)}parse(e){return new pn(e)}}class pn{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,i="ltr"){const r=[],a=dr(e,t,this.data,i);for(let o=0,u=a.length;o<u;o++)r.push(...a[o].toShapes());return r}}function dr(n,e,t,i){const r=Array.from(n),a=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*a,u=[];let c=0,s=0;(i=="rtl"||i=="tb")&&r.reverse();for(let f=0;f<r.length;f++){const h=r[f];if(h===`
79
- `)c=0,s-=o;else{const g=pr(h,a,c,s,t);i=="tb"?(c=0,s+=t.ascender*a):c+=g.offsetX,u.push(g.path)}}return u}function pr(n,e,t,i,r){const a=r.glyphs[n]||r.glyphs["?"];if(!a){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const o=new R.ShapePath;let u,c,s,f,h,g,p,T;if(a.o){const m=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let l=0,d=m.length;l<d;)switch(m[l++]){case"m":u=m[l++]*e+t,c=m[l++]*e+i,o.moveTo(u,c);break;case"l":u=m[l++]*e+t,c=m[l++]*e+i,o.lineTo(u,c);break;case"q":s=m[l++]*e+t,f=m[l++]*e+i,h=m[l++]*e+t,g=m[l++]*e+i,o.quadraticCurveTo(h,g,s,f);break;case"b":s=m[l++]*e+t,f=m[l++]*e+i,h=m[l++]*e+t,g=m[l++]*e+i,p=m[l++]*e+t,T=m[l++]*e+i,o.bezierCurveTo(h,g,p,T,s,f);break}}return{offsetX:a.ha*e,path:o}}class mr extends R.ExtrudeGeometry{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const r=i.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t)}this.type="TextGeometry"}}let mt=null;async function yr(n){if(n.match(/.zip$/i)){let e=n.substring(n.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await ln(n),i=Dt(t,e);mt=new pn(JSON.parse(i))}else mt=await new fr().loadAsync(n)}class gr extends je{initObject(e){let t;if(tn(e)?t=e:t="ERROR",mt==null){const i=new se.BoxGeometry,r=new se.MeshStandardMaterial({color:16711680});return new se.Mesh(i,r)}else{const i={font:mt,size:1,depth:.5,curveSegments:12},r=new mr(t,i);r.center();const a=new se.MeshStandardMaterial({color:65280});return new se.Mesh(r,a)}}}function qt(n,e){if(e===R.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===R.TriangleFanDrawMode||e===R.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],u=n.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===R.TriangleFanDrawMode)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=n.clone();return a.setIndex(r),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class Tr extends R.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new _r(t)}),this.register(function(t){return new br(t)}),this.register(function(t){return new Cr(t)}),this.register(function(t){return new Mr(t)}),this.register(function(t){return new Pr(t)}),this.register(function(t){return new Sr(t)}),this.register(function(t){return new Or(t)}),this.register(function(t){return new xr(t)}),this.register(function(t){return new Ir(t)}),this.register(function(t){return new Ar(t)}),this.register(function(t){return new Nr(t)}),this.register(function(t){return new Lr(t)}),this.register(function(t){return new kr(t)}),this.register(function(t){return new wr(t)}),this.register(function(t){return new vr(t)}),this.register(function(t){return new Dr(t)}),this.register(function(t){return new Fr(t)})}load(e,t,i,r){const a=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const s=R.LoaderUtils.extractUrlBase(e);o=R.LoaderUtils.resolveURL(s,this.path)}else o=R.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const u=function(s){r?r(s):console.error(s),a.manager.itemError(e),a.manager.itemEnd(e)},c=new R.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(s){try{a.parse(s,o,function(f){t(f),a.manager.itemEnd(e)},u)}catch(f){u(f)}},i,u)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let a;const o={},u={},c=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===mn){try{o[_e.KHR_BINARY_GLTF]=new Ur(e)}catch(h){r&&r(h);return}a=JSON.parse(o[_e.KHR_BINARY_GLTF].content)}else a=JSON.parse(c.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const s=new Zr(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const h=this.pluginCallbacks[f](s);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[h.name]=h,o[h.name]=!0}if(a.extensionsUsed)for(let f=0;f<a.extensionsUsed.length;++f){const h=a.extensionsUsed[f],g=a.extensionsRequired||[];switch(h){case _e.KHR_MATERIALS_UNLIT:o[h]=new Rr;break;case _e.KHR_DRACO_MESH_COMPRESSION:o[h]=new jr(a,this.dracoLoader);break;case _e.KHR_TEXTURE_TRANSFORM:o[h]=new Br;break;case _e.KHR_MESH_QUANTIZATION:o[h]=new Gr;break;default:g.indexOf(h)>=0&&u[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}s.setExtensions(o),s.setPlugins(u),s.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,a){i.parse(e,t,r,a)})}}function Er(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const _e={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vr{constructor(e){this.parser=e,this.name=_e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,c=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let s;const f=new R.Color(16777215);c.color!==void 0&&f.setRGB(c.color[0],c.color[1],c.color[2],R.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":s=new R.DirectionalLight(f),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new R.PointLight(f),s.distance=h;break;case"spot":s=new R.SpotLight(f),s.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,s.angle=c.spot.outerConeAngle,s.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return s.position.set(0,0,0),qe(s,c),c.intensity!==void 0&&(s.intensity=c.intensity),s.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(s),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,a=i.json.nodes[e],u=(a.extensions&&a.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(c){return i._getNodeRef(t.cache,u,c)})}}class Rr{constructor(){this.name=_e.KHR_MATERIALS_UNLIT}getMaterialType(){return R.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new R.Color(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const o=a.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],R.LinearSRGBColorSpace),e.opacity=o[3]}a.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",a.baseColorTexture,R.SRGBColorSpace))}return Promise.all(r)}}class Ar{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name].emissiveStrength;return a!==void 0&&(t.emissiveIntensity=a),Promise.resolve()}}class _r{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const u=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new R.Vector2(u,u)}return Promise.all(a)}}class br{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.dispersion=a.dispersion!==void 0?a.dispersion:0,Promise.resolve()}}class Lr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(a)}}class Sr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[];t.sheenColor=new R.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){const u=o.sheenColorFactor;t.sheenColor.setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&a.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,R.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(a)}}class Or{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&a.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(a)}}class xr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&a.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const u=o.attenuationColor||[1,1,1];return t.attenuationColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),Promise.all(a)}}class Ir{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.ior=a.ior!==void 0?a.ior:1.5,Promise.resolve()}}class Nr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&a.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const u=o.specularColorFactor||[1,1,1];return t.specularColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&a.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,R.SRGBColorSpace)),Promise.all(a)}}class wr{constructor(e){this.parser=e,this.name=_e.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&a.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(a)}}class kr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&a.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(a)}}class Cr{constructor(e){this.parser=e,this.name=_e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,o)}}class Mr{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],u=r.images[o.source];let c=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class Pr{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],u=r.images[o.source];let c=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class Dr{constructor(e){this.name=_e.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],a=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then(function(u){const c=r.byteOffset||0,s=r.byteLength||0,f=r.count,h=r.byteStride,g=new Uint8Array(u,c,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,h,g,r.mode,r.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(f*h);return o.decodeGltfBuffer(new Uint8Array(p),f,h,g,r.mode,r.filter),p})})}else return null}}class Fr{constructor(e){this.name=_e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const s of r.primitives)if(s.mode!==Ke.TRIANGLES&&s.mode!==Ke.TRIANGLE_STRIP&&s.mode!==Ke.TRIANGLE_FAN&&s.mode!==void 0)return null;const o=i.extensions[this.name].attributes,u=[],c={};for(const s in o)u.push(this.parser.getDependency("accessor",o[s]).then(f=>(c[s]=f,c[s])));return u.length<1?null:(u.push(this.parser.createNodeMesh(e)),Promise.all(u).then(s=>{const f=s.pop(),h=f.isGroup?f.children:[f],g=s[0].count,p=[];for(const T of h){const m=new R.Matrix4,l=new R.Vector3,d=new R.Quaternion,y=new R.Vector3(1,1,1),v=new R.InstancedMesh(T.geometry,T.material,g);for(let E=0;E<g;E++)c.TRANSLATION&&l.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&d.fromBufferAttribute(c.ROTATION,E),c.SCALE&&y.fromBufferAttribute(c.SCALE,E),v.setMatrixAt(E,m.compose(l,d,y));for(const E in c)if(E==="_COLOR_0"){const S=c[E];v.instanceColor=new R.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&T.geometry.setAttribute(E,c[E]);R.Object3D.prototype.copy.call(v,T),this.parser.assignFinalMaterial(v),p.push(v)}return f.isGroup?(f.clear(),f.add(...p),f):p[0]}))}}const mn="glTF",ot=12,Qt={JSON:1313821514,BIN:5130562};class Ur{constructor(e){this.name=_e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ot),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==mn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-ot,a=new DataView(e,ot);let o=0;for(;o<r;){const u=a.getUint32(o,!0);o+=4;const c=a.getUint32(o,!0);if(o+=4,c===Qt.JSON){const s=new Uint8Array(e,ot+o,u);this.content=i.decode(s)}else if(c===Qt.BIN){const s=ot+o;this.body=e.slice(s,s+u)}o+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class jr{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,u={},c={},s={};for(const f in o){const h=wt[f]||f.toLowerCase();u[h]=o[f]}for(const f in e.attributes){const h=wt[f]||f.toLowerCase();if(o[f]!==void 0){const g=i.accessors[e.attributes[f]],p=it[g.componentType];s[h]=p.name,c[h]=g.normalized===!0}}return t.getDependency("bufferView",a).then(function(f){return new Promise(function(h,g){r.decodeDracoFile(f,function(p){for(const T in p.attributes){const m=p.attributes[T],l=c[T];l!==void 0&&(m.normalized=l)}h(p)},u,s,R.LinearSRGBColorSpace,g)})})}}class Br{constructor(){this.name=_e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Gr{constructor(){this.name=_e.KHR_MESH_QUANTIZATION}}class yn extends R.Interpolant{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[a+o];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,o=this.sampleValues,u=this.valueSize,c=u*2,s=u*3,f=r-t,h=(i-t)/f,g=h*h,p=g*h,T=e*s,m=T-s,l=-2*p+3*g,d=p-g,y=1-l,v=d-g+h;for(let E=0;E!==u;E++){const S=o[m+E+u],I=o[m+E+c]*f,k=o[T+E+u],H=o[T+E]*f;a[E]=y*S+v*I+l*k+d*H}return a}}const zr=new R.Quaternion;class Vr extends yn{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return zr.fromArray(a).normalize().toArray(a),a}}const Ke={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},it={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Zt={9728:R.NearestFilter,9729:R.LinearFilter,9984:R.NearestMipmapNearestFilter,9985:R.LinearMipmapNearestFilter,9986:R.NearestMipmapLinearFilter,9987:R.LinearMipmapLinearFilter},Jt={33071:R.ClampToEdgeWrapping,33648:R.MirroredRepeatWrapping,10497:R.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Je={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Hr={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete},bt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Wr(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new R.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:R.FrontSide})),n.DefaultMaterial}function et(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function qe(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Kr(n,e,t){let i=!1,r=!1,a=!1;for(let s=0,f=e.length;s<f;s++){const h=e[s];if(h.POSITION!==void 0&&(i=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(n);const o=[],u=[],c=[];for(let s=0,f=e.length;s<f;s++){const h=e[s];if(i){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;o.push(g)}if(r){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;u.push(g)}if(a){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;c.push(g)}}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(c)]).then(function(s){const f=s[0],h=s[1],g=s[2];return i&&(n.morphAttributes.position=f),r&&(n.morphAttributes.normal=h),a&&(n.morphAttributes.color=g),n.morphTargetsRelative=!0,n})}function Yr(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xr(n){let e;const t=n.extensions&&n.extensions[_e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Lt(t.attributes):e=n.indices+":"+Lt(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+Lt(n.targets[i]);return e}function Lt(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function kt(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function qr(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Qr=new R.Matrix4;class Zr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Er,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=-1,a=!1,o=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const c=u.match(/Version\/(\d+)/);r=i&&c?parseInt(c[1],10):-1,a=u.indexOf("Firefox")>-1,o=a?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||a&&o<98?this.textureLoader=new R.TextureLoader(this.options.manager):this.textureLoader=new R.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new R.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const u={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return et(a,u,r),qe(u,r),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(u)})).then(function(){for(const c of u.scenes)c.updateMatrixWorld();e(u)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const o=t[r].joints;for(let u=0,c=o.length;u<c;u++)e[o[u]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(o,u)=>{const c=this.associations.get(o);c!=null&&this.associations.set(u,c);for(const[s,f]of o.children.entries())a(f,u.children[s])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":r=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(a,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_e.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(a,o){i.load(R.LoaderUtils.resolveURL(t.uri,r.path),a,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const r=t.byteLength||0,a=t.byteOffset||0;return i.slice(a,a+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=_t[r.type],u=it[r.componentType],c=r.normalized===!0,s=new u(r.count*o);return Promise.resolve(new R.BufferAttribute(s,o,c))}const a=[];return r.bufferView!==void 0?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),r.sparse!==void 0&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then(function(o){const u=o[0],c=_t[r.type],s=it[r.componentType],f=s.BYTES_PER_ELEMENT,h=f*c,g=r.byteOffset||0,p=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,T=r.normalized===!0;let m,l;if(p&&p!==h){const d=Math.floor(g/p),y="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+d+":"+r.count;let v=t.cache.get(y);v||(m=new s(u,d*p,r.count*p/f),v=new R.InterleavedBuffer(m,p/f),t.cache.add(y,v)),l=new R.InterleavedBufferAttribute(v,c,g%p/f,T)}else u===null?m=new s(r.count*c):m=new s(u,g,r.count*c),l=new R.BufferAttribute(m,c,T);if(r.sparse!==void 0){const d=_t.SCALAR,y=it[r.sparse.indices.componentType],v=r.sparse.indices.byteOffset||0,E=r.sparse.values.byteOffset||0,S=new y(o[1],v,r.sparse.count*d),I=new s(o[2],E,r.sparse.count*c);u!==null&&(l=new R.BufferAttribute(l.array.slice(),l.itemSize,l.normalized)),l.normalized=!1;for(let k=0,H=S.length;k<H;k++){const x=S[k];if(l.setX(x,I[k*c]),c>=2&&l.setY(x,I[k*c+1]),c>=3&&l.setZ(x,I[k*c+2]),c>=4&&l.setW(x,I[k*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}l.normalized=T}return l})}loadTexture(e){const t=this.json,i=this.options,a=t.textures[e].source,o=t.images[a];let u=this.textureLoader;if(o.uri){const c=i.manager.getHandler(o.uri);c!==null&&(u=c)}return this.loadTextureImage(e,a,u)}loadTextureImage(e,t,i){const r=this,a=this.json,o=a.textures[e],u=a.images[t],c=(u.uri||u.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const s=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=o.name||u.name||"",f.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(f.name=u.uri);const g=(a.samplers||{})[o.sampler]||{};return f.magFilter=Zt[g.magFilter]||R.LinearFilter,f.minFilter=Zt[g.minFilter]||R.LinearMipmapLinearFilter,f.wrapS=Jt[g.wrapS]||R.RepeatWrapping,f.wrapT=Jt[g.wrapT]||R.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==R.NearestFilter&&f.minFilter!==R.LinearFilter,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[c]=s,s}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=r.images[e],u=self.URL||self.webkitURL;let c=o.uri||"",s=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(h){s=!0;const g=new Blob([h],{type:o.mimeType});return c=u.createObjectURL(g),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(c).then(function(h){return new Promise(function(g,p){let T=g;t.isImageBitmapLoader===!0&&(T=function(m){const l=new R.Texture(m);l.needsUpdate=!0,g(l)}),t.load(R.LoaderUtils.resolveURL(h,a.path),T,void 0,p)})}).then(function(h){return s===!0&&u.revokeObjectURL(c),qe(h,o),h.userData.mimeType=o.mimeType||qr(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=f,f}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),a.extensions[_e.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[_e.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const c=a.associations.get(o);o=a.extensions[_e.KHR_TEXTURE_TRANSFORM].extendTexture(o,u),a.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const u="PointsMaterial:"+i.uuid;let c=this.cache.get(u);c||(c=new R.PointsMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(u,c)),i=c}else if(e.isLine){const u="LineBasicMaterial:"+i.uuid;let c=this.cache.get(u);c||(c=new R.LineBasicMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(u,c)),i=c}if(r||a||o){let u="ClonedMaterial:"+i.uuid+":";r&&(u+="derivative-tangents:"),a&&(u+="vertex-colors:"),o&&(u+="flat-shading:");let c=this.cache.get(u);c||(c=i.clone(),a&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(u,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return R.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let o;const u={},c=a.extensions||{},s=[];if(c[_e.KHR_MATERIALS_UNLIT]){const h=r[_e.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),s.push(h.extendParams(u,a,t))}else{const h=a.pbrMetallicRoughness||{};if(u.color=new R.Color(1,1,1),u.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;u.color.setRGB(g[0],g[1],g[2],R.LinearSRGBColorSpace),u.opacity=g[3]}h.baseColorTexture!==void 0&&s.push(t.assignTexture(u,"map",h.baseColorTexture,R.SRGBColorSpace)),u.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,u.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(s.push(t.assignTexture(u,"metalnessMap",h.metallicRoughnessTexture)),s.push(t.assignTexture(u,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),s.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,u)})))}a.doubleSided===!0&&(u.side=R.DoubleSide);const f=a.alphaMode||bt.OPAQUE;if(f===bt.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,f===bt.MASK&&(u.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"normalMap",a.normalTexture)),u.normalScale=new R.Vector2(1,1),a.normalTexture.scale!==void 0)){const h=a.normalTexture.scale;u.normalScale.set(h,h)}if(a.occlusionTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==R.MeshBasicMaterial){const h=a.emissiveFactor;u.emissive=new R.Color().setRGB(h[0],h[1],h[2],R.LinearSRGBColorSpace)}return a.emissiveTexture!==void 0&&o!==R.MeshBasicMaterial&&s.push(t.assignTexture(u,"emissiveMap",a.emissiveTexture,R.SRGBColorSpace)),Promise.all(s).then(function(){const h=new o(u);return a.name&&(h.name=a.name),qe(h,a),t.associations.set(h,{materials:e}),a.extensions&&et(r,h,a),h})}createUniqueName(e){const t=R.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(u){return i[_e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,t).then(function(c){return $t(c,u,t)})}const o=[];for(let u=0,c=e.length;u<c;u++){const s=e[u],f=Xr(s),h=r[f];if(h)o.push(h.promise);else{let g;s.extensions&&s.extensions[_e.KHR_DRACO_MESH_COMPRESSION]?g=a(s):g=$t(new R.BufferGeometry,s,t),r[f]={primitive:s,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],o=a.primitives,u=[];for(let c=0,s=o.length;c<s;c++){const f=o[c].material===void 0?Wr(this.cache):this.getDependency("material",o[c].material);u.push(f)}return u.push(t.loadGeometries(o)),Promise.all(u).then(function(c){const s=c.slice(0,c.length-1),f=c[c.length-1],h=[];for(let p=0,T=f.length;p<T;p++){const m=f[p],l=o[p];let d;const y=s[p];if(l.mode===Ke.TRIANGLES||l.mode===Ke.TRIANGLE_STRIP||l.mode===Ke.TRIANGLE_FAN||l.mode===void 0)d=a.isSkinnedMesh===!0?new R.SkinnedMesh(m,y):new R.Mesh(m,y),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),l.mode===Ke.TRIANGLE_STRIP?d.geometry=qt(d.geometry,R.TriangleStripDrawMode):l.mode===Ke.TRIANGLE_FAN&&(d.geometry=qt(d.geometry,R.TriangleFanDrawMode));else if(l.mode===Ke.LINES)d=new R.LineSegments(m,y);else if(l.mode===Ke.LINE_STRIP)d=new R.Line(m,y);else if(l.mode===Ke.LINE_LOOP)d=new R.LineLoop(m,y);else if(l.mode===Ke.POINTS)d=new R.Points(m,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);Object.keys(d.geometry.morphAttributes).length>0&&Yr(d,a),d.name=t.createUniqueName(a.name||"mesh_"+e),qe(d,a),l.extensions&&et(r,d,l),t.assignFinalMaterial(d),h.push(d)}for(let p=0,T=h.length;p<T;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return a.extensions&&et(r,h[0],a),h[0];const g=new R.Group;a.extensions&&et(r,g,a),t.associations.set(g,{meshes:e});for(let p=0,T=h.length;p<T;p++)g.add(h[p]);return g})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new R.PerspectiveCamera(R.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new R.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),qe(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const a=r.pop(),o=r,u=[],c=[];for(let s=0,f=o.length;s<f;s++){const h=o[s];if(h){u.push(h);const g=new R.Matrix4;a!==null&&g.fromArray(a.array,s*16),c.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new R.Skeleton(u,c)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,o=[],u=[],c=[],s=[],f=[];for(let h=0,g=r.channels.length;h<g;h++){const p=r.channels[h],T=r.samplers[p.sampler],m=p.target,l=m.node,d=r.parameters!==void 0?r.parameters[T.input]:T.input,y=r.parameters!==void 0?r.parameters[T.output]:T.output;m.node!==void 0&&(o.push(this.getDependency("node",l)),u.push(this.getDependency("accessor",d)),c.push(this.getDependency("accessor",y)),s.push(T),f.push(m))}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(c),Promise.all(s),Promise.all(f)]).then(function(h){const g=h[0],p=h[1],T=h[2],m=h[3],l=h[4],d=[];for(let v=0,E=g.length;v<E;v++){const S=g[v],I=p[v],k=T[v],H=m[v],x=l[v];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const B=i._createAnimationTracks(S,I,k,H,x);if(B)for(let P=0;P<B.length;P++)d.push(B[P])}const y=new R.AnimationClip(a,void 0,d);return qe(y,r),y})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(a){const o=i._getNodeRef(i.meshCache,r.mesh,a);return r.weights!==void 0&&o.traverse(function(u){if(u.isMesh)for(let c=0,s=r.weights.length;c<s;c++)u.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],a=i._loadNodeShallow(e),o=[],u=r.children||[];for(let s=0,f=u.length;s<f;s++)o.push(i.getDependency("node",u[s]));const c=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([a,Promise.all(o),c]).then(function(s){const f=s[0],h=s[1],g=s[2];g!==null&&f.traverse(function(p){p.isSkinnedMesh&&p.bind(g,Qr)});for(let p=0,T=h.length;p<T;p++)f.add(h[p]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const a=t.nodes[e],o=a.name?r.createUniqueName(a.name):"",u=[],c=r._invokeOne(function(s){return s.createNodeMesh&&s.createNodeMesh(e)});return c&&u.push(c),a.camera!==void 0&&u.push(r.getDependency("camera",a.camera).then(function(s){return r._getNodeRef(r.cameraCache,a.camera,s)})),r._invokeAll(function(s){return s.createNodeAttachment&&s.createNodeAttachment(e)}).forEach(function(s){u.push(s)}),this.nodeCache[e]=Promise.all(u).then(function(s){let f;if(a.isBone===!0?f=new R.Bone:s.length>1?f=new R.Group:s.length===1?f=s[0]:f=new R.Object3D,f!==s[0])for(let h=0,g=s.length;h<g;h++)f.add(s[h]);if(a.name&&(f.userData.name=a.name,f.name=o),qe(f,a),a.extensions&&et(i,f,a),a.matrix!==void 0){const h=new R.Matrix4;h.fromArray(a.matrix),f.applyMatrix4(h)}else a.translation!==void 0&&f.position.fromArray(a.translation),a.rotation!==void 0&&f.quaternion.fromArray(a.rotation),a.scale!==void 0&&f.scale.fromArray(a.scale);if(!r.associations.has(f))r.associations.set(f,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){const h=r.associations.get(f);r.associations.set(f,{...h})}return r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new R.Group;i.name&&(a.name=r.createUniqueName(i.name)),qe(a,i),i.extensions&&et(t,a,i);const o=i.nodes||[],u=[];for(let c=0,s=o.length;c<s;c++)u.push(r.getDependency("node",o[c]));return Promise.all(u).then(function(c){for(let f=0,h=c.length;f<h;f++)a.add(c[f]);const s=f=>{const h=new Map;for(const[g,p]of r.associations)(g instanceof R.Material||g instanceof R.Texture)&&h.set(g,p);return f.traverse(g=>{const p=r.associations.get(g);p!=null&&h.set(g,p)}),h};return r.associations=s(a),a})}_createAnimationTracks(e,t,i,r,a){const o=[],u=e.name?e.name:e.uuid,c=[];Je[a.path]===Je.weights?e.traverse(function(g){g.morphTargetInfluences&&c.push(g.name?g.name:g.uuid)}):c.push(u);let s;switch(Je[a.path]){case Je.weights:s=R.NumberKeyframeTrack;break;case Je.rotation:s=R.QuaternionKeyframeTrack;break;case Je.translation:case Je.scale:s=R.VectorKeyframeTrack;break;default:i.itemSize===1?s=R.NumberKeyframeTrack:s=R.VectorKeyframeTrack;break}const f=r.interpolation!==void 0?Hr[r.interpolation]:R.InterpolateLinear,h=this._getArrayFromAccessor(i);for(let g=0,p=c.length;g<p;g++){const T=new s(c[g]+"."+Je[a.path],t.array,h,f);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),o.push(T)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=kt(t.constructor),r=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a++)r[a]=t[a]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const r=this instanceof R.QuaternionKeyframeTrack?Vr:yn;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Jr(n,e,t){const i=e.attributes,r=new R.Box3;if(i.POSITION!==void 0){const u=t.json.accessors[i.POSITION],c=u.min,s=u.max;if(c!==void 0&&s!==void 0){if(r.set(new R.Vector3(c[0],c[1],c[2]),new R.Vector3(s[0],s[1],s[2])),u.normalized){const f=kt(it[u.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=e.targets;if(a!==void 0){const u=new R.Vector3,c=new R.Vector3;for(let s=0,f=a.length;s<f;s++){const h=a[s];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],p=g.min,T=g.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),g.normalized){const m=kt(it[g.componentType]);c.multiplyScalar(m)}u.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(u)}n.boundingBox=r;const o=new R.Sphere;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function $t(n,e,t){const i=e.attributes,r=[];function a(o,u){return t.getDependency("accessor",o).then(function(c){n.setAttribute(u,c)})}for(const o in i){const u=wt[o]||o.toLowerCase();u in n.attributes||r.push(a(i[o],u))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(u){n.setIndex(u)});r.push(o)}return R.ColorManagement.workingColorSpace!==R.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${R.ColorManagement.workingColorSpace}" not supported.`),qe(n,e),Jr(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Kr(n,e.targets,t):n})}const St=new WeakMap;class $r extends R.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){const a=new R.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,o=>{this.parse(o,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,R.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,r,a=R.LinearSRGBColorSpace,o=()=>{}){const u={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,u).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(St.has(e)){const c=St.get(e);if(c.key===i)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,o=e.byteLength,u=this._getWorker(a,o).then(c=>(r=c,new Promise((s,f)=>{r._callbacks[a]={resolve:s,reject:f},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return u.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),St.set(e,{key:i,promise:u}),u}_createGeometry(e){const t=new R.BufferGeometry;e.index&&t.setIndex(new R.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:a,itemSize:o,stride:u,vertexColorSpace:c}=e.attributes[i];let s;if(o===u)s=new R.BufferAttribute(a,o);else{const f=new R.InterleavedBuffer(a,u);s=new R.InterleavedBufferAttribute(f,o,0)}r==="color"&&(this._assignVertexColorSpace(s,c),s.normalized=!(a instanceof Float32Array)),t.setAttribute(r,s)}return t}_assignVertexColorSpace(e,t){if(t!==R.SRGBColorSpace)return;const i=new R.Color;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r),R.ColorManagement.colorSpaceToWorking(i,R.SRGBColorSpace),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new R.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const a=ei.toString(),o=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
80
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){const o=a.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function ei(){let n,e;onmessage=function(o){const u=o.data;switch(u.type){case"init":n=u.decoderConfig,e=new Promise(function(f){n.onModuleLoaded=function(h){f({draco:h})},DracoDecoderModule(n)});break;case"decode":const c=u.buffer,s=u.taskConfig;e.then(f=>{const h=f.draco,g=new h.Decoder;try{const p=t(h,g,new Int8Array(c),s),T=p.attributes.map(m=>m.array.buffer);p.index&&T.push(p.index.array.buffer),self.postMessage({type:"decode",id:u.id,geometry:p},T)}catch(p){console.error(p),self.postMessage({type:"error",id:u.id,error:p.message})}finally{h.destroy(g)}});break}};function t(o,u,c,s){const f=s.attributeIDs,h=s.attributeTypes;let g,p;const T=u.GetEncodedGeometryType(c);if(T===o.TRIANGULAR_MESH)g=new o.Mesh,p=u.DecodeArrayToMesh(c,c.byteLength,g);else if(T===o.POINT_CLOUD)g=new o.PointCloud,p=u.DecodeArrayToPointCloud(c,c.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const m={index:null,attributes:[]};for(const l in f){const d=self[h[l]];let y,v;if(s.useUniqueIDs)v=f[l],y=u.GetAttributeByUniqueId(g,v);else{if(v=u.GetAttributeId(g,o[f[l]]),v===-1)continue;y=u.GetAttribute(g,v)}const E=r(o,u,g,l,d,y);l==="color"&&(E.vertexColorSpace=s.vertexColorSpace),m.attributes.push(E)}return T===o.TRIANGULAR_MESH&&(m.index=i(o,u,g)),o.destroy(g),m}function i(o,u,c){const f=c.num_faces()*3,h=f*4,g=o._malloc(h);u.GetTrianglesUInt32Array(c,h,g);const p=new Uint32Array(o.HEAPF32.buffer,g,f).slice();return o._free(g),{array:p,itemSize:1}}function r(o,u,c,s,f,h){const g=c.num_points(),p=h.num_components(),T=a(o,f),m=p*f.BYTES_PER_ELEMENT,l=Math.ceil(m/4)*4,d=l/f.BYTES_PER_ELEMENT,y=g*m,v=g*l,E=o._malloc(y);u.GetAttributeDataArrayForAllPoints(c,h,T,y,E);const S=new f(o.HEAPF32.buffer,E,y/f.BYTES_PER_ELEMENT);let I;if(m===l)I=S.slice();else{I=new f(v/f.BYTES_PER_ELEMENT);let k=0;for(let H=0,x=S.length;H<x;H++){for(let B=0;B<p;B++)I[k+B]=S[H*p+B];k+=d}}return o._free(E),{name:s,count:g,itemSize:p,array:I,stride:d}}function a(o,u){switch(u){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function ti(n){return"morphTargetDictionary"in n&&n.morphTargetDictionary!==void 0&&"morphTargetInfluences"in n&&Array.isArray(n.morphTargetInfluences)}const gn=new Tr,Tn=new $r;Tn.setDecoderPath("/examples/jsm/libs/draco/");gn.setDRACOLoader(Tn);class En extends je{ready;gltf;constructor(e){super(),this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}initMotion(){return new vn(this)}async asyncInit(e){if(tn(e))console.log(`File: ${e}`),this.gltf=await gn.loadAsync(e),this.gltf.scene.traverse(t=>{t.userData.a3js={objectA3:this}}),this.object.add(this.gltf.scene);else{const t=new se.BoxGeometry,i=new se.MeshStandardMaterial({color:16711680}),r=new se.Mesh(t,i);this.object.add(r)}return this.motion.setObject(this),this}}class vn extends tt{isPaused;gltf;mixer;clips;actions;morphs;constructor(e){super(e),this.isPaused=!1,this.clips={},this.actions={},this.morphs={}}setObject(e){e instanceof En?(super.setObject(e),this.gltf=e.gltf,this.myInitialize(e)):console.warn("GLTFMotion can set only GLTF object.")}myInitialize(e){if(this.gltf){this.mixer=new se.AnimationMixer(this.gltf.scene),this.actions={},console.log(" actions(from model):");const t={};for(let i=0;i<this.gltf.animations.length;i++){const r=this.gltf.animations[i];t[r.name]=r,this.actions[r.name]=this.mixer.clipAction(r),console.log(` ${r.name}`)}console.log(" actions(from motion):");for(const i of Object.values(this.clips))t[i.name]=i,this.actions[i.name]=this.mixer.clipAction(i),console.log(` ${i.name}`);this.clips=t,console.log(" morphs:"),this.morphs={},this.gltf.scene.traverse(i=>{if(ti(i)){const{morphTargetDictionary:r,morphTargetInfluences:a}=i;Object.keys(r).forEach(o=>{const u=i.name+"."+o,c=r[o];this.morphs[u]={array:a,idx:c},console.log(` ${u}`)})}})}}detachObject(e){this.mixer?.stopAllAction(),this.gltf&&this.mixer?.uncacheRoot(this.gltf.scene),this.mixer=void 0,this.actions={},this.morphs={},this.gltf=void 0,this.isPaused=!1}update(e){super.update(e),this.isPaused||this.mixer?.update(e)}controlMotion(...e){if(e[0]){this.mixer?.stopAllAction();const t=this.actions[e[0]];t&&t.play()}if(e[1]){const t=e[1];if(e[2]){const i=Number(e[2]);if(t in this.morphs){const{array:r,idx:a}=this.morphs[e[1]];r[a]=i}}}}setPause(e){this.isPaused=e}setTime(e){this.mixer?.setTime(e)}}var ve=(n,e)=>()=>(e||(e={exports:{}},n(e.exports,e)),e.exports),Rn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.VERSION=void 0,n.VERSION="9.0.1"}),xe=ve((n,e)=>{var t=n&&n.__spreadArray||function(F,Y){for(var z=0,ee=Y.length,de=F.length;z<ee;z++,de++)F[de]=Y[z];return F};Object.defineProperty(n,"__esModule",{value:!0}),n.toFastProperties=n.timer=n.peek=n.isES2015MapSupported=n.PRINT_WARNING=n.PRINT_ERROR=n.packArray=n.IDENTITY=n.NOOP=n.merge=n.groupBy=n.defaults=n.assignNoOverwrite=n.assign=n.zipObject=n.sortBy=n.indexOf=n.some=n.difference=n.every=n.isObject=n.isRegExp=n.isArray=n.partial=n.uniq=n.compact=n.reduce=n.findAll=n.find=n.cloneObj=n.cloneArr=n.contains=n.has=n.pick=n.reject=n.filter=n.dropRight=n.drop=n.isFunction=n.isUndefined=n.isString=n.forEach=n.last=n.first=n.flatten=n.map=n.mapValues=n.values=n.keys=n.isEmpty=void 0;function i(F){return F&&F.length===0}n.isEmpty=i;function r(F){return F==null?[]:Object.keys(F)}n.keys=r;function a(F){for(var Y=[],z=Object.keys(F),ee=0;ee<z.length;ee++)Y.push(F[z[ee]]);return Y}n.values=a;function o(F,Y){for(var z=[],ee=r(F),de=0;de<ee.length;de++){var be=ee[de];z.push(Y.call(null,F[be],be))}return z}n.mapValues=o;function u(F,Y){for(var z=[],ee=0;ee<F.length;ee++)z.push(Y.call(null,F[ee],ee));return z}n.map=u;function c(F){for(var Y=[],z=0;z<F.length;z++){var ee=F[z];Array.isArray(ee)?Y=Y.concat(c(ee)):Y.push(ee)}return Y}n.flatten=c;function s(F){return i(F)?void 0:F[0]}n.first=s;function f(F){var Y=F&&F.length;return Y?F[Y-1]:void 0}n.last=f;function h(F,Y){if(Array.isArray(F))for(var z=0;z<F.length;z++)Y.call(null,F[z],z);else if(Q(F))for(var ee=r(F),z=0;z<ee.length;z++){var de=ee[z],be=F[de];Y.call(null,be,de)}else throw Error("non exhaustive match")}n.forEach=h;function g(F){return typeof F=="string"}n.isString=g;function p(F){return F===void 0}n.isUndefined=p;function T(F){return F instanceof Function}n.isFunction=T;function m(F,Y){return Y===void 0&&(Y=1),F.slice(Y,F.length)}n.drop=m;function l(F,Y){return Y===void 0&&(Y=1),F.slice(0,F.length-Y)}n.dropRight=l;function d(F,Y){var z=[];if(Array.isArray(F))for(var ee=0;ee<F.length;ee++){var de=F[ee];Y.call(null,de)&&z.push(de)}return z}n.filter=d;function y(F,Y){return d(F,function(z){return!Y(z)})}n.reject=y;function v(F,Y){for(var z=Object.keys(F),ee={},de=0;de<z.length;de++){var be=z[de],b=F[be];Y(b)&&(ee[be]=b)}return ee}n.pick=v;function E(F,Y){return Q(F)?F.hasOwnProperty(Y):!1}n.has=E;function S(F,Y){return H(F,function(z){return z===Y})!==void 0}n.contains=S;function I(F){for(var Y=[],z=0;z<F.length;z++)Y.push(F[z]);return Y}n.cloneArr=I;function k(F){var Y={};for(var z in F)Object.prototype.hasOwnProperty.call(F,z)&&(Y[z]=F[z]);return Y}n.cloneObj=k;function H(F,Y){for(var z=0;z<F.length;z++){var ee=F[z];if(Y.call(null,ee))return ee}}n.find=H;function x(F,Y){for(var z=[],ee=0;ee<F.length;ee++){var de=F[ee];Y.call(null,de)&&z.push(de)}return z}n.findAll=x;function B(F,Y,z){for(var ee=Array.isArray(F),de=ee?F:a(F),be=ee?[]:r(F),b=z,A=0;A<de.length;A++)b=Y.call(null,b,de[A],ee?A:be[A]);return b}n.reduce=B;function P(F){return y(F,function(Y){return Y==null})}n.compact=P;function O(F,Y){Y===void 0&&(Y=function(ee){return ee});var z=[];return B(F,function(ee,de){var be=Y(de);return S(z,be)?ee:(z.push(be),ee.concat(de))},[])}n.uniq=O;function M(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];var ee=[null],de=ee.concat(Y);return Function.bind.apply(F,de)}n.partial=M;function C(F){return Array.isArray(F)}n.isArray=C;function X(F){return F instanceof RegExp}n.isRegExp=X;function Q(F){return F instanceof Object}n.isObject=Q;function W(F,Y){for(var z=0;z<F.length;z++)if(!Y(F[z],z))return!1;return!0}n.every=W;function $(F,Y){return y(F,function(z){return S(Y,z)})}n.difference=$;function te(F,Y){for(var z=0;z<F.length;z++)if(Y(F[z]))return!0;return!1}n.some=te;function ce(F,Y){for(var z=0;z<F.length;z++)if(F[z]===Y)return z;return-1}n.indexOf=ce;function ae(F,Y){var z=I(F);return z.sort(function(ee,de){return Y(ee)-Y(de)}),z}n.sortBy=ae;function le(F,Y){if(F.length!==Y.length)throw Error("can't zipObject with different number of keys and values!");for(var z={},ee=0;ee<F.length;ee++)z[F[ee]]=Y[ee];return z}n.zipObject=le;function ne(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];for(var ee=0;ee<Y.length;ee++)for(var de=Y[ee],be=r(de),b=0;b<be.length;b++){var A=be[b];F[A]=de[A]}return F}n.assign=ne;function pe(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];for(var ee=0;ee<Y.length;ee++)for(var de=Y[ee],be=r(de),b=0;b<be.length;b++){var A=be[b];E(F,A)||(F[A]=de[A])}return F}n.assignNoOverwrite=pe;function U(){for(var F=[],Y=0;Y<arguments.length;Y++)F[Y]=arguments[Y];return pe.apply(void 0,t([{}],F))}n.defaults=U;function G(F,Y){var z={};return h(F,function(ee){var de=Y(ee),be=z[de];be?be.push(ee):z[de]=[ee]}),z}n.groupBy=G;function K(F,Y){for(var z=k(F),ee=r(Y),de=0;de<ee.length;de++){var be=ee[de],b=Y[be];z[be]=b}return z}n.merge=K;function q(){}n.NOOP=q;function J(F){return F}n.IDENTITY=J;function ie(F){for(var Y=[],z=0;z<F.length;z++){var ee=F[z];Y.push(ee!==void 0?ee:void 0)}return Y}n.packArray=ie;function Te(F){console&&console.error&&console.error("Error: "+F)}n.PRINT_ERROR=Te;function ye(F){console&&console.warn&&console.warn("Warning: "+F)}n.PRINT_WARNING=ye;function we(){return typeof Map=="function"}n.isES2015MapSupported=we;function Be(F){return F[F.length-1]}n.peek=Be;function We(F){var Y=new Date().getTime(),z=F(),ee=new Date().getTime(),de=ee-Y;return{time:de,value:z}}n.timer=We;function Ue(F){function Y(){}Y.prototype=F;var z=new Y;function ee(){return typeof z.bar}return ee(),ee(),F}n.toFastProperties=Ue}),Ut=ve((n,e)=>{(function(t,i){typeof define=="function"&&define.amd?define([],i):typeof e=="object"&&e.exports?e.exports=i():t.regexpToAst=i()})(typeof self<"u"?self:n,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(l){this.idx=l.idx,this.input=l.input,this.groupIdx=l.groupIdx},t.prototype.pattern=function(l){this.idx=0,this.input=l,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var y={type:"Flags",loc:{begin:this.idx,end:l.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(y,"global");break;case"i":c(y,"ignoreCase");break;case"m":c(y,"multiLine");break;case"u":c(y,"unicode");break;case"y":c(y,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:y,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var l=[],d=this.idx;for(l.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),l.push(this.alternative());return{type:"Disjunction",value:l,loc:this.loc(d)}},t.prototype.alternative=function(){for(var l=[],d=this.idx;this.isTerm();)l.push(this.term());return{type:"Alternative",value:l,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var l=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(l)};case"$":return{type:"EndAnchor",loc:this.loc(l)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(l)};case"B":return{type:"NonWordBoundary",loc:this.loc(l)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}s(d);var y=this.disjunction();return this.consumeChar(")"),{type:d,value:y,loc:this.loc(l)}}f()},t.prototype.quantifier=function(l){var d,y=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var v=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:v,atMost:v};break;case",":var E;this.isDigit()?(E=this.integerIncludingZero(),d={atLeast:v,atMost:E}):d={atLeast:v,atMost:1/0},this.consumeChar("}");break}if(l===!0&&d===void 0)return;s(d);break}if(!(l===!0&&d===void 0))return s(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(y),d},t.prototype.atom=function(){var l,d=this.idx;switch(this.peekChar()){case".":l=this.dotAll();break;case"\\":l=this.atomEscape();break;case"[":l=this.characterClass();break;case"(":l=this.group();break}return l===void 0&&this.isPatternCharacter()&&(l=this.patternCharacter()),s(l),l.loc=this.loc(d),this.isQuantifier()&&(l.quantifier=this.quantifier()),l},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
79
+ `)c=0,s-=o;else{const g=pr(h,a,c,s,t);i=="tb"?(c=0,s+=t.ascender*a):c+=g.offsetX,u.push(g.path)}}return u}function pr(n,e,t,i,r){const a=r.glyphs[n]||r.glyphs["?"];if(!a){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const o=new R.ShapePath;let u,c,s,f,h,g,p,T;if(a.o){const m=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let l=0,d=m.length;l<d;)switch(m[l++]){case"m":u=m[l++]*e+t,c=m[l++]*e+i,o.moveTo(u,c);break;case"l":u=m[l++]*e+t,c=m[l++]*e+i,o.lineTo(u,c);break;case"q":s=m[l++]*e+t,f=m[l++]*e+i,h=m[l++]*e+t,g=m[l++]*e+i,o.quadraticCurveTo(h,g,s,f);break;case"b":s=m[l++]*e+t,f=m[l++]*e+i,h=m[l++]*e+t,g=m[l++]*e+i,p=m[l++]*e+t,T=m[l++]*e+i,o.bezierCurveTo(h,g,p,T,s,f);break}}return{offsetX:a.ha*e,path:o}}class mr extends R.ExtrudeGeometry{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const r=i.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t)}this.type="TextGeometry"}}let mt=null;async function yr(n){if(n.match(/.zip$/i)){let e=n.substring(n.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await ln(n),i=Pt(t,e);mt=new pn(JSON.parse(i))}else mt=await new fr().loadAsync(n)}class gr extends je{initObject(e){let t;if(en(e)?t=e:t="ERROR",mt==null){const i=new se.BoxGeometry,r=new se.MeshStandardMaterial({color:16711680});return new se.Mesh(i,r)}else{const i={font:mt,size:1,depth:.5,curveSegments:12},r=new mr(t,i);r.center();const a=new se.MeshStandardMaterial({color:65280});return new se.Mesh(r,a)}}}function Xt(n,e){if(e===R.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===R.TriangleFanDrawMode||e===R.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],u=n.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===R.TriangleFanDrawMode)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=n.clone();return a.setIndex(r),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class Tr extends R.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new _r(t)}),this.register(function(t){return new br(t)}),this.register(function(t){return new Cr(t)}),this.register(function(t){return new Mr(t)}),this.register(function(t){return new Pr(t)}),this.register(function(t){return new Sr(t)}),this.register(function(t){return new Or(t)}),this.register(function(t){return new xr(t)}),this.register(function(t){return new Ir(t)}),this.register(function(t){return new Ar(t)}),this.register(function(t){return new Nr(t)}),this.register(function(t){return new Lr(t)}),this.register(function(t){return new kr(t)}),this.register(function(t){return new wr(t)}),this.register(function(t){return new vr(t)}),this.register(function(t){return new Dr(t)}),this.register(function(t){return new Fr(t)})}load(e,t,i,r){const a=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const s=R.LoaderUtils.extractUrlBase(e);o=R.LoaderUtils.resolveURL(s,this.path)}else o=R.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const u=function(s){r?r(s):console.error(s),a.manager.itemError(e),a.manager.itemEnd(e)},c=new R.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(s){try{a.parse(s,o,function(f){t(f),a.manager.itemEnd(e)},u)}catch(f){u(f)}},i,u)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let a;const o={},u={},c=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===mn){try{o[_e.KHR_BINARY_GLTF]=new Ur(e)}catch(h){r&&r(h);return}a=JSON.parse(o[_e.KHR_BINARY_GLTF].content)}else a=JSON.parse(c.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const s=new Zr(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const h=this.pluginCallbacks[f](s);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[h.name]=h,o[h.name]=!0}if(a.extensionsUsed)for(let f=0;f<a.extensionsUsed.length;++f){const h=a.extensionsUsed[f],g=a.extensionsRequired||[];switch(h){case _e.KHR_MATERIALS_UNLIT:o[h]=new Rr;break;case _e.KHR_DRACO_MESH_COMPRESSION:o[h]=new jr(a,this.dracoLoader);break;case _e.KHR_TEXTURE_TRANSFORM:o[h]=new Br;break;case _e.KHR_MESH_QUANTIZATION:o[h]=new Gr;break;default:g.indexOf(h)>=0&&u[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}s.setExtensions(o),s.setPlugins(u),s.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,a){i.parse(e,t,r,a)})}}function Er(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const _e={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vr{constructor(e){this.parser=e,this.name=_e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,c=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let s;const f=new R.Color(16777215);c.color!==void 0&&f.setRGB(c.color[0],c.color[1],c.color[2],R.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":s=new R.DirectionalLight(f),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new R.PointLight(f),s.distance=h;break;case"spot":s=new R.SpotLight(f),s.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,s.angle=c.spot.outerConeAngle,s.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return s.position.set(0,0,0),qe(s,c),c.intensity!==void 0&&(s.intensity=c.intensity),s.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(s),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,a=i.json.nodes[e],u=(a.extensions&&a.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(c){return i._getNodeRef(t.cache,u,c)})}}class Rr{constructor(){this.name=_e.KHR_MATERIALS_UNLIT}getMaterialType(){return R.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new R.Color(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const o=a.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],R.LinearSRGBColorSpace),e.opacity=o[3]}a.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",a.baseColorTexture,R.SRGBColorSpace))}return Promise.all(r)}}class Ar{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name].emissiveStrength;return a!==void 0&&(t.emissiveIntensity=a),Promise.resolve()}}class _r{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const u=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new R.Vector2(u,u)}return Promise.all(a)}}class br{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.dispersion=a.dispersion!==void 0?a.dispersion:0,Promise.resolve()}}class Lr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(a)}}class Sr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[];t.sheenColor=new R.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){const u=o.sheenColorFactor;t.sheenColor.setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&a.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,R.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(a)}}class Or{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&a.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(a)}}class xr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&a.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const u=o.attenuationColor||[1,1,1];return t.attenuationColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),Promise.all(a)}}class Ir{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.ior=a.ior!==void 0?a.ior:1.5,Promise.resolve()}}class Nr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&a.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const u=o.specularColorFactor||[1,1,1];return t.specularColor=new R.Color().setRGB(u[0],u[1],u[2],R.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&a.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,R.SRGBColorSpace)),Promise.all(a)}}class wr{constructor(e){this.parser=e,this.name=_e.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&a.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(a)}}class kr{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:R.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&a.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(a)}}class Cr{constructor(e){this.parser=e,this.name=_e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,o)}}class Mr{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],u=r.images[o.source];let c=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class Pr{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const o=a.extensions[t],u=r.images[o.source];let c=i.textureLoader;if(u.uri){const s=i.options.manager.getHandler(u.uri);s!==null&&(c=s)}return i.loadTextureImage(e,o.source,c)}}class Dr{constructor(e){this.name=_e.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],a=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then(function(u){const c=r.byteOffset||0,s=r.byteLength||0,f=r.count,h=r.byteStride,g=new Uint8Array(u,c,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,h,g,r.mode,r.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(f*h);return o.decodeGltfBuffer(new Uint8Array(p),f,h,g,r.mode,r.filter),p})})}else return null}}class Fr{constructor(e){this.name=_e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const s of r.primitives)if(s.mode!==Ke.TRIANGLES&&s.mode!==Ke.TRIANGLE_STRIP&&s.mode!==Ke.TRIANGLE_FAN&&s.mode!==void 0)return null;const o=i.extensions[this.name].attributes,u=[],c={};for(const s in o)u.push(this.parser.getDependency("accessor",o[s]).then(f=>(c[s]=f,c[s])));return u.length<1?null:(u.push(this.parser.createNodeMesh(e)),Promise.all(u).then(s=>{const f=s.pop(),h=f.isGroup?f.children:[f],g=s[0].count,p=[];for(const T of h){const m=new R.Matrix4,l=new R.Vector3,d=new R.Quaternion,y=new R.Vector3(1,1,1),v=new R.InstancedMesh(T.geometry,T.material,g);for(let E=0;E<g;E++)c.TRANSLATION&&l.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&d.fromBufferAttribute(c.ROTATION,E),c.SCALE&&y.fromBufferAttribute(c.SCALE,E),v.setMatrixAt(E,m.compose(l,d,y));for(const E in c)if(E==="_COLOR_0"){const S=c[E];v.instanceColor=new R.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&T.geometry.setAttribute(E,c[E]);R.Object3D.prototype.copy.call(v,T),this.parser.assignFinalMaterial(v),p.push(v)}return f.isGroup?(f.clear(),f.add(...p),f):p[0]}))}}const mn="glTF",ot=12,qt={JSON:1313821514,BIN:5130562};class Ur{constructor(e){this.name=_e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ot),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==mn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-ot,a=new DataView(e,ot);let o=0;for(;o<r;){const u=a.getUint32(o,!0);o+=4;const c=a.getUint32(o,!0);if(o+=4,c===qt.JSON){const s=new Uint8Array(e,ot+o,u);this.content=i.decode(s)}else if(c===qt.BIN){const s=ot+o;this.body=e.slice(s,s+u)}o+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class jr{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,u={},c={},s={};for(const f in o){const h=Nt[f]||f.toLowerCase();u[h]=o[f]}for(const f in e.attributes){const h=Nt[f]||f.toLowerCase();if(o[f]!==void 0){const g=i.accessors[e.attributes[f]],p=it[g.componentType];s[h]=p.name,c[h]=g.normalized===!0}}return t.getDependency("bufferView",a).then(function(f){return new Promise(function(h,g){r.decodeDracoFile(f,function(p){for(const T in p.attributes){const m=p.attributes[T],l=c[T];l!==void 0&&(m.normalized=l)}h(p)},u,s,R.LinearSRGBColorSpace,g)})})}}class Br{constructor(){this.name=_e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Gr{constructor(){this.name=_e.KHR_MESH_QUANTIZATION}}class yn extends R.Interpolant{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[a+o];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,o=this.sampleValues,u=this.valueSize,c=u*2,s=u*3,f=r-t,h=(i-t)/f,g=h*h,p=g*h,T=e*s,m=T-s,l=-2*p+3*g,d=p-g,y=1-l,v=d-g+h;for(let E=0;E!==u;E++){const S=o[m+E+u],I=o[m+E+c]*f,k=o[T+E+u],H=o[T+E]*f;a[E]=y*S+v*I+l*k+d*H}return a}}const zr=new R.Quaternion;class Vr extends yn{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return zr.fromArray(a).normalize().toArray(a),a}}const Ke={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},it={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Qt={9728:R.NearestFilter,9729:R.LinearFilter,9984:R.NearestMipmapNearestFilter,9985:R.LinearMipmapNearestFilter,9986:R.NearestMipmapLinearFilter,9987:R.LinearMipmapLinearFilter},Zt={33071:R.ClampToEdgeWrapping,33648:R.MirroredRepeatWrapping,10497:R.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Nt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Je={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Hr={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete},bt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Wr(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new R.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:R.FrontSide})),n.DefaultMaterial}function et(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function qe(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Kr(n,e,t){let i=!1,r=!1,a=!1;for(let s=0,f=e.length;s<f;s++){const h=e[s];if(h.POSITION!==void 0&&(i=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(n);const o=[],u=[],c=[];for(let s=0,f=e.length;s<f;s++){const h=e[s];if(i){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;o.push(g)}if(r){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;u.push(g)}if(a){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;c.push(g)}}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(c)]).then(function(s){const f=s[0],h=s[1],g=s[2];return i&&(n.morphAttributes.position=f),r&&(n.morphAttributes.normal=h),a&&(n.morphAttributes.color=g),n.morphTargetsRelative=!0,n})}function Yr(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xr(n){let e;const t=n.extensions&&n.extensions[_e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Lt(t.attributes):e=n.indices+":"+Lt(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+Lt(n.targets[i]);return e}function Lt(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function wt(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function qr(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Qr=new R.Matrix4;class Zr{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Er,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=-1,a=!1,o=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const c=u.match(/Version\/(\d+)/);r=i&&c?parseInt(c[1],10):-1,a=u.indexOf("Firefox")>-1,o=a?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||a&&o<98?this.textureLoader=new R.TextureLoader(this.options.manager):this.textureLoader=new R.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new R.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const u={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return et(a,u,r),qe(u,r),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(u)})).then(function(){for(const c of u.scenes)c.updateMatrixWorld();e(u)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const o=t[r].joints;for(let u=0,c=o.length;u<c;u++)e[o[u]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(o,u)=>{const c=this.associations.get(o);c!=null&&this.associations.set(u,c);for(const[s,f]of o.children.entries())a(f,u.children[s])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":r=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(a,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_e.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(a,o){i.load(R.LoaderUtils.resolveURL(t.uri,r.path),a,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const r=t.byteLength||0,a=t.byteOffset||0;return i.slice(a,a+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=_t[r.type],u=it[r.componentType],c=r.normalized===!0,s=new u(r.count*o);return Promise.resolve(new R.BufferAttribute(s,o,c))}const a=[];return r.bufferView!==void 0?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),r.sparse!==void 0&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then(function(o){const u=o[0],c=_t[r.type],s=it[r.componentType],f=s.BYTES_PER_ELEMENT,h=f*c,g=r.byteOffset||0,p=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,T=r.normalized===!0;let m,l;if(p&&p!==h){const d=Math.floor(g/p),y="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+d+":"+r.count;let v=t.cache.get(y);v||(m=new s(u,d*p,r.count*p/f),v=new R.InterleavedBuffer(m,p/f),t.cache.add(y,v)),l=new R.InterleavedBufferAttribute(v,c,g%p/f,T)}else u===null?m=new s(r.count*c):m=new s(u,g,r.count*c),l=new R.BufferAttribute(m,c,T);if(r.sparse!==void 0){const d=_t.SCALAR,y=it[r.sparse.indices.componentType],v=r.sparse.indices.byteOffset||0,E=r.sparse.values.byteOffset||0,S=new y(o[1],v,r.sparse.count*d),I=new s(o[2],E,r.sparse.count*c);u!==null&&(l=new R.BufferAttribute(l.array.slice(),l.itemSize,l.normalized)),l.normalized=!1;for(let k=0,H=S.length;k<H;k++){const x=S[k];if(l.setX(x,I[k*c]),c>=2&&l.setY(x,I[k*c+1]),c>=3&&l.setZ(x,I[k*c+2]),c>=4&&l.setW(x,I[k*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}l.normalized=T}return l})}loadTexture(e){const t=this.json,i=this.options,a=t.textures[e].source,o=t.images[a];let u=this.textureLoader;if(o.uri){const c=i.manager.getHandler(o.uri);c!==null&&(u=c)}return this.loadTextureImage(e,a,u)}loadTextureImage(e,t,i){const r=this,a=this.json,o=a.textures[e],u=a.images[t],c=(u.uri||u.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const s=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=o.name||u.name||"",f.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(f.name=u.uri);const g=(a.samplers||{})[o.sampler]||{};return f.magFilter=Qt[g.magFilter]||R.LinearFilter,f.minFilter=Qt[g.minFilter]||R.LinearMipmapLinearFilter,f.wrapS=Zt[g.wrapS]||R.RepeatWrapping,f.wrapT=Zt[g.wrapT]||R.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==R.NearestFilter&&f.minFilter!==R.LinearFilter,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[c]=s,s}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=r.images[e],u=self.URL||self.webkitURL;let c=o.uri||"",s=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(h){s=!0;const g=new Blob([h],{type:o.mimeType});return c=u.createObjectURL(g),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(c).then(function(h){return new Promise(function(g,p){let T=g;t.isImageBitmapLoader===!0&&(T=function(m){const l=new R.Texture(m);l.needsUpdate=!0,g(l)}),t.load(R.LoaderUtils.resolveURL(h,a.path),T,void 0,p)})}).then(function(h){return s===!0&&u.revokeObjectURL(c),qe(h,o),h.userData.mimeType=o.mimeType||qr(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=f,f}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),a.extensions[_e.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[_e.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const c=a.associations.get(o);o=a.extensions[_e.KHR_TEXTURE_TRANSFORM].extendTexture(o,u),a.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const u="PointsMaterial:"+i.uuid;let c=this.cache.get(u);c||(c=new R.PointsMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(u,c)),i=c}else if(e.isLine){const u="LineBasicMaterial:"+i.uuid;let c=this.cache.get(u);c||(c=new R.LineBasicMaterial,R.Material.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(u,c)),i=c}if(r||a||o){let u="ClonedMaterial:"+i.uuid+":";r&&(u+="derivative-tangents:"),a&&(u+="vertex-colors:"),o&&(u+="flat-shading:");let c=this.cache.get(u);c||(c=i.clone(),a&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(u,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return R.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let o;const u={},c=a.extensions||{},s=[];if(c[_e.KHR_MATERIALS_UNLIT]){const h=r[_e.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),s.push(h.extendParams(u,a,t))}else{const h=a.pbrMetallicRoughness||{};if(u.color=new R.Color(1,1,1),u.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;u.color.setRGB(g[0],g[1],g[2],R.LinearSRGBColorSpace),u.opacity=g[3]}h.baseColorTexture!==void 0&&s.push(t.assignTexture(u,"map",h.baseColorTexture,R.SRGBColorSpace)),u.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,u.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(s.push(t.assignTexture(u,"metalnessMap",h.metallicRoughnessTexture)),s.push(t.assignTexture(u,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),s.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,u)})))}a.doubleSided===!0&&(u.side=R.DoubleSide);const f=a.alphaMode||bt.OPAQUE;if(f===bt.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,f===bt.MASK&&(u.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"normalMap",a.normalTexture)),u.normalScale=new R.Vector2(1,1),a.normalTexture.scale!==void 0)){const h=a.normalTexture.scale;u.normalScale.set(h,h)}if(a.occlusionTexture!==void 0&&o!==R.MeshBasicMaterial&&(s.push(t.assignTexture(u,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==R.MeshBasicMaterial){const h=a.emissiveFactor;u.emissive=new R.Color().setRGB(h[0],h[1],h[2],R.LinearSRGBColorSpace)}return a.emissiveTexture!==void 0&&o!==R.MeshBasicMaterial&&s.push(t.assignTexture(u,"emissiveMap",a.emissiveTexture,R.SRGBColorSpace)),Promise.all(s).then(function(){const h=new o(u);return a.name&&(h.name=a.name),qe(h,a),t.associations.set(h,{materials:e}),a.extensions&&et(r,h,a),h})}createUniqueName(e){const t=R.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(u){return i[_e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,t).then(function(c){return Jt(c,u,t)})}const o=[];for(let u=0,c=e.length;u<c;u++){const s=e[u],f=Xr(s),h=r[f];if(h)o.push(h.promise);else{let g;s.extensions&&s.extensions[_e.KHR_DRACO_MESH_COMPRESSION]?g=a(s):g=Jt(new R.BufferGeometry,s,t),r[f]={primitive:s,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],o=a.primitives,u=[];for(let c=0,s=o.length;c<s;c++){const f=o[c].material===void 0?Wr(this.cache):this.getDependency("material",o[c].material);u.push(f)}return u.push(t.loadGeometries(o)),Promise.all(u).then(function(c){const s=c.slice(0,c.length-1),f=c[c.length-1],h=[];for(let p=0,T=f.length;p<T;p++){const m=f[p],l=o[p];let d;const y=s[p];if(l.mode===Ke.TRIANGLES||l.mode===Ke.TRIANGLE_STRIP||l.mode===Ke.TRIANGLE_FAN||l.mode===void 0)d=a.isSkinnedMesh===!0?new R.SkinnedMesh(m,y):new R.Mesh(m,y),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),l.mode===Ke.TRIANGLE_STRIP?d.geometry=Xt(d.geometry,R.TriangleStripDrawMode):l.mode===Ke.TRIANGLE_FAN&&(d.geometry=Xt(d.geometry,R.TriangleFanDrawMode));else if(l.mode===Ke.LINES)d=new R.LineSegments(m,y);else if(l.mode===Ke.LINE_STRIP)d=new R.Line(m,y);else if(l.mode===Ke.LINE_LOOP)d=new R.LineLoop(m,y);else if(l.mode===Ke.POINTS)d=new R.Points(m,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);Object.keys(d.geometry.morphAttributes).length>0&&Yr(d,a),d.name=t.createUniqueName(a.name||"mesh_"+e),qe(d,a),l.extensions&&et(r,d,l),t.assignFinalMaterial(d),h.push(d)}for(let p=0,T=h.length;p<T;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return a.extensions&&et(r,h[0],a),h[0];const g=new R.Group;a.extensions&&et(r,g,a),t.associations.set(g,{meshes:e});for(let p=0,T=h.length;p<T;p++)g.add(h[p]);return g})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new R.PerspectiveCamera(R.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new R.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),qe(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const a=r.pop(),o=r,u=[],c=[];for(let s=0,f=o.length;s<f;s++){const h=o[s];if(h){u.push(h);const g=new R.Matrix4;a!==null&&g.fromArray(a.array,s*16),c.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new R.Skeleton(u,c)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,o=[],u=[],c=[],s=[],f=[];for(let h=0,g=r.channels.length;h<g;h++){const p=r.channels[h],T=r.samplers[p.sampler],m=p.target,l=m.node,d=r.parameters!==void 0?r.parameters[T.input]:T.input,y=r.parameters!==void 0?r.parameters[T.output]:T.output;m.node!==void 0&&(o.push(this.getDependency("node",l)),u.push(this.getDependency("accessor",d)),c.push(this.getDependency("accessor",y)),s.push(T),f.push(m))}return Promise.all([Promise.all(o),Promise.all(u),Promise.all(c),Promise.all(s),Promise.all(f)]).then(function(h){const g=h[0],p=h[1],T=h[2],m=h[3],l=h[4],d=[];for(let v=0,E=g.length;v<E;v++){const S=g[v],I=p[v],k=T[v],H=m[v],x=l[v];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const B=i._createAnimationTracks(S,I,k,H,x);if(B)for(let P=0;P<B.length;P++)d.push(B[P])}const y=new R.AnimationClip(a,void 0,d);return qe(y,r),y})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(a){const o=i._getNodeRef(i.meshCache,r.mesh,a);return r.weights!==void 0&&o.traverse(function(u){if(u.isMesh)for(let c=0,s=r.weights.length;c<s;c++)u.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],a=i._loadNodeShallow(e),o=[],u=r.children||[];for(let s=0,f=u.length;s<f;s++)o.push(i.getDependency("node",u[s]));const c=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([a,Promise.all(o),c]).then(function(s){const f=s[0],h=s[1],g=s[2];g!==null&&f.traverse(function(p){p.isSkinnedMesh&&p.bind(g,Qr)});for(let p=0,T=h.length;p<T;p++)f.add(h[p]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const a=t.nodes[e],o=a.name?r.createUniqueName(a.name):"",u=[],c=r._invokeOne(function(s){return s.createNodeMesh&&s.createNodeMesh(e)});return c&&u.push(c),a.camera!==void 0&&u.push(r.getDependency("camera",a.camera).then(function(s){return r._getNodeRef(r.cameraCache,a.camera,s)})),r._invokeAll(function(s){return s.createNodeAttachment&&s.createNodeAttachment(e)}).forEach(function(s){u.push(s)}),this.nodeCache[e]=Promise.all(u).then(function(s){let f;if(a.isBone===!0?f=new R.Bone:s.length>1?f=new R.Group:s.length===1?f=s[0]:f=new R.Object3D,f!==s[0])for(let h=0,g=s.length;h<g;h++)f.add(s[h]);if(a.name&&(f.userData.name=a.name,f.name=o),qe(f,a),a.extensions&&et(i,f,a),a.matrix!==void 0){const h=new R.Matrix4;h.fromArray(a.matrix),f.applyMatrix4(h)}else a.translation!==void 0&&f.position.fromArray(a.translation),a.rotation!==void 0&&f.quaternion.fromArray(a.rotation),a.scale!==void 0&&f.scale.fromArray(a.scale);if(!r.associations.has(f))r.associations.set(f,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){const h=r.associations.get(f);r.associations.set(f,{...h})}return r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new R.Group;i.name&&(a.name=r.createUniqueName(i.name)),qe(a,i),i.extensions&&et(t,a,i);const o=i.nodes||[],u=[];for(let c=0,s=o.length;c<s;c++)u.push(r.getDependency("node",o[c]));return Promise.all(u).then(function(c){for(let f=0,h=c.length;f<h;f++)a.add(c[f]);const s=f=>{const h=new Map;for(const[g,p]of r.associations)(g instanceof R.Material||g instanceof R.Texture)&&h.set(g,p);return f.traverse(g=>{const p=r.associations.get(g);p!=null&&h.set(g,p)}),h};return r.associations=s(a),a})}_createAnimationTracks(e,t,i,r,a){const o=[],u=e.name?e.name:e.uuid,c=[];Je[a.path]===Je.weights?e.traverse(function(g){g.morphTargetInfluences&&c.push(g.name?g.name:g.uuid)}):c.push(u);let s;switch(Je[a.path]){case Je.weights:s=R.NumberKeyframeTrack;break;case Je.rotation:s=R.QuaternionKeyframeTrack;break;case Je.translation:case Je.scale:s=R.VectorKeyframeTrack;break;default:i.itemSize===1?s=R.NumberKeyframeTrack:s=R.VectorKeyframeTrack;break}const f=r.interpolation!==void 0?Hr[r.interpolation]:R.InterpolateLinear,h=this._getArrayFromAccessor(i);for(let g=0,p=c.length;g<p;g++){const T=new s(c[g]+"."+Je[a.path],t.array,h,f);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),o.push(T)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=wt(t.constructor),r=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a++)r[a]=t[a]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const r=this instanceof R.QuaternionKeyframeTrack?Vr:yn;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Jr(n,e,t){const i=e.attributes,r=new R.Box3;if(i.POSITION!==void 0){const u=t.json.accessors[i.POSITION],c=u.min,s=u.max;if(c!==void 0&&s!==void 0){if(r.set(new R.Vector3(c[0],c[1],c[2]),new R.Vector3(s[0],s[1],s[2])),u.normalized){const f=wt(it[u.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=e.targets;if(a!==void 0){const u=new R.Vector3,c=new R.Vector3;for(let s=0,f=a.length;s<f;s++){const h=a[s];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],p=g.min,T=g.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),g.normalized){const m=wt(it[g.componentType]);c.multiplyScalar(m)}u.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(u)}n.boundingBox=r;const o=new R.Sphere;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function Jt(n,e,t){const i=e.attributes,r=[];function a(o,u){return t.getDependency("accessor",o).then(function(c){n.setAttribute(u,c)})}for(const o in i){const u=Nt[o]||o.toLowerCase();u in n.attributes||r.push(a(i[o],u))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(u){n.setIndex(u)});r.push(o)}return R.ColorManagement.workingColorSpace!==R.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${R.ColorManagement.workingColorSpace}" not supported.`),qe(n,e),Jr(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Kr(n,e.targets,t):n})}const St=new WeakMap;class $r extends R.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){const a=new R.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,o=>{this.parse(o,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,R.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,r,a=R.LinearSRGBColorSpace,o=()=>{}){const u={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,u).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(St.has(e)){const c=St.get(e);if(c.key===i)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,o=e.byteLength,u=this._getWorker(a,o).then(c=>(r=c,new Promise((s,f)=>{r._callbacks[a]={resolve:s,reject:f},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return u.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),St.set(e,{key:i,promise:u}),u}_createGeometry(e){const t=new R.BufferGeometry;e.index&&t.setIndex(new R.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:a,itemSize:o,stride:u,vertexColorSpace:c}=e.attributes[i];let s;if(o===u)s=new R.BufferAttribute(a,o);else{const f=new R.InterleavedBuffer(a,u);s=new R.InterleavedBufferAttribute(f,o,0)}r==="color"&&(this._assignVertexColorSpace(s,c),s.normalized=!(a instanceof Float32Array)),t.setAttribute(r,s)}return t}_assignVertexColorSpace(e,t){if(t!==R.SRGBColorSpace)return;const i=new R.Color;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r),R.ColorManagement.colorSpaceToWorking(i,R.SRGBColorSpace),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new R.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const a=ei.toString(),o=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
80
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){const o=a.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function ei(){let n,e;onmessage=function(o){const u=o.data;switch(u.type){case"init":n=u.decoderConfig,e=new Promise(function(f){n.onModuleLoaded=function(h){f({draco:h})},DracoDecoderModule(n)});break;case"decode":const c=u.buffer,s=u.taskConfig;e.then(f=>{const h=f.draco,g=new h.Decoder;try{const p=t(h,g,new Int8Array(c),s),T=p.attributes.map(m=>m.array.buffer);p.index&&T.push(p.index.array.buffer),self.postMessage({type:"decode",id:u.id,geometry:p},T)}catch(p){console.error(p),self.postMessage({type:"error",id:u.id,error:p.message})}finally{h.destroy(g)}});break}};function t(o,u,c,s){const f=s.attributeIDs,h=s.attributeTypes;let g,p;const T=u.GetEncodedGeometryType(c);if(T===o.TRIANGULAR_MESH)g=new o.Mesh,p=u.DecodeArrayToMesh(c,c.byteLength,g);else if(T===o.POINT_CLOUD)g=new o.PointCloud,p=u.DecodeArrayToPointCloud(c,c.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const m={index:null,attributes:[]};for(const l in f){const d=self[h[l]];let y,v;if(s.useUniqueIDs)v=f[l],y=u.GetAttributeByUniqueId(g,v);else{if(v=u.GetAttributeId(g,o[f[l]]),v===-1)continue;y=u.GetAttribute(g,v)}const E=r(o,u,g,l,d,y);l==="color"&&(E.vertexColorSpace=s.vertexColorSpace),m.attributes.push(E)}return T===o.TRIANGULAR_MESH&&(m.index=i(o,u,g)),o.destroy(g),m}function i(o,u,c){const f=c.num_faces()*3,h=f*4,g=o._malloc(h);u.GetTrianglesUInt32Array(c,h,g);const p=new Uint32Array(o.HEAPF32.buffer,g,f).slice();return o._free(g),{array:p,itemSize:1}}function r(o,u,c,s,f,h){const g=c.num_points(),p=h.num_components(),T=a(o,f),m=p*f.BYTES_PER_ELEMENT,l=Math.ceil(m/4)*4,d=l/f.BYTES_PER_ELEMENT,y=g*m,v=g*l,E=o._malloc(y);u.GetAttributeDataArrayForAllPoints(c,h,T,y,E);const S=new f(o.HEAPF32.buffer,E,y/f.BYTES_PER_ELEMENT);let I;if(m===l)I=S.slice();else{I=new f(v/f.BYTES_PER_ELEMENT);let k=0;for(let H=0,x=S.length;H<x;H++){for(let B=0;B<p;B++)I[k+B]=S[H*p+B];k+=d}}return o._free(E),{name:s,count:g,itemSize:p,array:I,stride:d}}function a(o,u){switch(u){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function ti(n){return"morphTargetDictionary"in n&&n.morphTargetDictionary!==void 0&&"morphTargetInfluences"in n&&Array.isArray(n.morphTargetInfluences)}const gn=new Tr,Tn=new $r;Tn.setDecoderPath("/examples/jsm/libs/draco/");gn.setDRACOLoader(Tn);class En extends je{ready;gltf;constructor(e){super(),this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}initMotion(){return new vn(this)}async asyncInit(e){if(en(e))console.log(`File: ${e}`),this.gltf=await gn.loadAsync(e),this.gltf.scene.traverse(t=>{t.userData.a3js={objectA3:this}}),this.object.add(this.gltf.scene);else{const t=new se.BoxGeometry,i=new se.MeshStandardMaterial({color:16711680}),r=new se.Mesh(t,i);this.object.add(r)}return this.motion.setObject(this),this}}class vn extends tt{isPaused;gltf;mixer;clips;actions;morphs;constructor(e){super(e),this.isPaused=!1,this.clips={},this.actions={},this.morphs={}}setObject(e){e instanceof En?(super.setObject(e),this.gltf=e.gltf,this.myInitialize(e)):console.warn("GLTFMotion can set only GLTF object.")}myInitialize(e){if(this.gltf){this.mixer=new se.AnimationMixer(this.gltf.scene),this.actions={},console.log(" actions(from model):");const t={};for(let i=0;i<this.gltf.animations.length;i++){const r=this.gltf.animations[i];t[r.name]=r,this.actions[r.name]=this.mixer.clipAction(r),console.log(` ${r.name}`)}console.log(" actions(from motion):");for(const i of Object.values(this.clips))t[i.name]=i,this.actions[i.name]=this.mixer.clipAction(i),console.log(` ${i.name}`);this.clips=t,console.log(" morphs:"),this.morphs={},this.gltf.scene.traverse(i=>{if(ti(i)){const{morphTargetDictionary:r,morphTargetInfluences:a}=i;Object.keys(r).forEach(o=>{const u=i.name+"."+o,c=r[o];this.morphs[u]={array:a,idx:c},console.log(` ${u}`)})}})}}detachObject(e){this.mixer?.stopAllAction(),this.gltf&&this.mixer?.uncacheRoot(this.gltf.scene),this.mixer=void 0,this.actions={},this.morphs={},this.gltf=void 0,this.isPaused=!1}update(e){super.update(e),this.isPaused||this.mixer?.update(e)}controlMotion(...e){if(e[0]){this.mixer?.stopAllAction();const t=this.actions[e[0]];t&&t.play()}if(e[1]){const t=e[1];if(e[2]){const i=Number(e[2]);if(t in this.morphs){const{array:r,idx:a}=this.morphs[e[1]];r[a]=i}}}}setPause(e){this.isPaused=e}setTime(e){this.mixer?.setTime(e)}}var ve=(n,e)=>()=>(e||(e={exports:{}},n(e.exports,e)),e.exports),Rn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.VERSION=void 0,n.VERSION="9.0.1"}),xe=ve((n,e)=>{var t=n&&n.__spreadArray||function(F,Y){for(var z=0,ee=Y.length,de=F.length;z<ee;z++,de++)F[de]=Y[z];return F};Object.defineProperty(n,"__esModule",{value:!0}),n.toFastProperties=n.timer=n.peek=n.isES2015MapSupported=n.PRINT_WARNING=n.PRINT_ERROR=n.packArray=n.IDENTITY=n.NOOP=n.merge=n.groupBy=n.defaults=n.assignNoOverwrite=n.assign=n.zipObject=n.sortBy=n.indexOf=n.some=n.difference=n.every=n.isObject=n.isRegExp=n.isArray=n.partial=n.uniq=n.compact=n.reduce=n.findAll=n.find=n.cloneObj=n.cloneArr=n.contains=n.has=n.pick=n.reject=n.filter=n.dropRight=n.drop=n.isFunction=n.isUndefined=n.isString=n.forEach=n.last=n.first=n.flatten=n.map=n.mapValues=n.values=n.keys=n.isEmpty=void 0;function i(F){return F&&F.length===0}n.isEmpty=i;function r(F){return F==null?[]:Object.keys(F)}n.keys=r;function a(F){for(var Y=[],z=Object.keys(F),ee=0;ee<z.length;ee++)Y.push(F[z[ee]]);return Y}n.values=a;function o(F,Y){for(var z=[],ee=r(F),de=0;de<ee.length;de++){var be=ee[de];z.push(Y.call(null,F[be],be))}return z}n.mapValues=o;function u(F,Y){for(var z=[],ee=0;ee<F.length;ee++)z.push(Y.call(null,F[ee],ee));return z}n.map=u;function c(F){for(var Y=[],z=0;z<F.length;z++){var ee=F[z];Array.isArray(ee)?Y=Y.concat(c(ee)):Y.push(ee)}return Y}n.flatten=c;function s(F){return i(F)?void 0:F[0]}n.first=s;function f(F){var Y=F&&F.length;return Y?F[Y-1]:void 0}n.last=f;function h(F,Y){if(Array.isArray(F))for(var z=0;z<F.length;z++)Y.call(null,F[z],z);else if(Q(F))for(var ee=r(F),z=0;z<ee.length;z++){var de=ee[z],be=F[de];Y.call(null,be,de)}else throw Error("non exhaustive match")}n.forEach=h;function g(F){return typeof F=="string"}n.isString=g;function p(F){return F===void 0}n.isUndefined=p;function T(F){return F instanceof Function}n.isFunction=T;function m(F,Y){return Y===void 0&&(Y=1),F.slice(Y,F.length)}n.drop=m;function l(F,Y){return Y===void 0&&(Y=1),F.slice(0,F.length-Y)}n.dropRight=l;function d(F,Y){var z=[];if(Array.isArray(F))for(var ee=0;ee<F.length;ee++){var de=F[ee];Y.call(null,de)&&z.push(de)}return z}n.filter=d;function y(F,Y){return d(F,function(z){return!Y(z)})}n.reject=y;function v(F,Y){for(var z=Object.keys(F),ee={},de=0;de<z.length;de++){var be=z[de],b=F[be];Y(b)&&(ee[be]=b)}return ee}n.pick=v;function E(F,Y){return Q(F)?F.hasOwnProperty(Y):!1}n.has=E;function S(F,Y){return H(F,function(z){return z===Y})!==void 0}n.contains=S;function I(F){for(var Y=[],z=0;z<F.length;z++)Y.push(F[z]);return Y}n.cloneArr=I;function k(F){var Y={};for(var z in F)Object.prototype.hasOwnProperty.call(F,z)&&(Y[z]=F[z]);return Y}n.cloneObj=k;function H(F,Y){for(var z=0;z<F.length;z++){var ee=F[z];if(Y.call(null,ee))return ee}}n.find=H;function x(F,Y){for(var z=[],ee=0;ee<F.length;ee++){var de=F[ee];Y.call(null,de)&&z.push(de)}return z}n.findAll=x;function B(F,Y,z){for(var ee=Array.isArray(F),de=ee?F:a(F),be=ee?[]:r(F),b=z,A=0;A<de.length;A++)b=Y.call(null,b,de[A],ee?A:be[A]);return b}n.reduce=B;function P(F){return y(F,function(Y){return Y==null})}n.compact=P;function O(F,Y){Y===void 0&&(Y=function(ee){return ee});var z=[];return B(F,function(ee,de){var be=Y(de);return S(z,be)?ee:(z.push(be),ee.concat(de))},[])}n.uniq=O;function M(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];var ee=[null],de=ee.concat(Y);return Function.bind.apply(F,de)}n.partial=M;function C(F){return Array.isArray(F)}n.isArray=C;function X(F){return F instanceof RegExp}n.isRegExp=X;function Q(F){return F instanceof Object}n.isObject=Q;function W(F,Y){for(var z=0;z<F.length;z++)if(!Y(F[z],z))return!1;return!0}n.every=W;function $(F,Y){return y(F,function(z){return S(Y,z)})}n.difference=$;function te(F,Y){for(var z=0;z<F.length;z++)if(Y(F[z]))return!0;return!1}n.some=te;function ce(F,Y){for(var z=0;z<F.length;z++)if(F[z]===Y)return z;return-1}n.indexOf=ce;function ae(F,Y){var z=I(F);return z.sort(function(ee,de){return Y(ee)-Y(de)}),z}n.sortBy=ae;function le(F,Y){if(F.length!==Y.length)throw Error("can't zipObject with different number of keys and values!");for(var z={},ee=0;ee<F.length;ee++)z[F[ee]]=Y[ee];return z}n.zipObject=le;function ne(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];for(var ee=0;ee<Y.length;ee++)for(var de=Y[ee],be=r(de),b=0;b<be.length;b++){var A=be[b];F[A]=de[A]}return F}n.assign=ne;function pe(F){for(var Y=[],z=1;z<arguments.length;z++)Y[z-1]=arguments[z];for(var ee=0;ee<Y.length;ee++)for(var de=Y[ee],be=r(de),b=0;b<be.length;b++){var A=be[b];E(F,A)||(F[A]=de[A])}return F}n.assignNoOverwrite=pe;function U(){for(var F=[],Y=0;Y<arguments.length;Y++)F[Y]=arguments[Y];return pe.apply(void 0,t([{}],F))}n.defaults=U;function G(F,Y){var z={};return h(F,function(ee){var de=Y(ee),be=z[de];be?be.push(ee):z[de]=[ee]}),z}n.groupBy=G;function K(F,Y){for(var z=k(F),ee=r(Y),de=0;de<ee.length;de++){var be=ee[de],b=Y[be];z[be]=b}return z}n.merge=K;function q(){}n.NOOP=q;function J(F){return F}n.IDENTITY=J;function ie(F){for(var Y=[],z=0;z<F.length;z++){var ee=F[z];Y.push(ee!==void 0?ee:void 0)}return Y}n.packArray=ie;function Te(F){console&&console.error&&console.error("Error: "+F)}n.PRINT_ERROR=Te;function ye(F){console&&console.warn&&console.warn("Warning: "+F)}n.PRINT_WARNING=ye;function we(){return typeof Map=="function"}n.isES2015MapSupported=we;function Be(F){return F[F.length-1]}n.peek=Be;function We(F){var Y=new Date().getTime(),z=F(),ee=new Date().getTime(),de=ee-Y;return{time:de,value:z}}n.timer=We;function Ue(F){function Y(){}Y.prototype=F;var z=new Y;function ee(){return typeof z.bar}return ee(),ee(),F}n.toFastProperties=Ue}),Ft=ve((n,e)=>{(function(t,i){typeof define=="function"&&define.amd?define([],i):typeof e=="object"&&e.exports?e.exports=i():t.regexpToAst=i()})(typeof self<"u"?self:n,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(l){this.idx=l.idx,this.input=l.input,this.groupIdx=l.groupIdx},t.prototype.pattern=function(l){this.idx=0,this.input=l,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var y={type:"Flags",loc:{begin:this.idx,end:l.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(y,"global");break;case"i":c(y,"ignoreCase");break;case"m":c(y,"multiLine");break;case"u":c(y,"unicode");break;case"y":c(y,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:y,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var l=[],d=this.idx;for(l.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),l.push(this.alternative());return{type:"Disjunction",value:l,loc:this.loc(d)}},t.prototype.alternative=function(){for(var l=[],d=this.idx;this.isTerm();)l.push(this.term());return{type:"Alternative",value:l,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var l=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(l)};case"$":return{type:"EndAnchor",loc:this.loc(l)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(l)};case"B":return{type:"NonWordBoundary",loc:this.loc(l)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}s(d);var y=this.disjunction();return this.consumeChar(")"),{type:d,value:y,loc:this.loc(l)}}f()},t.prototype.quantifier=function(l){var d,y=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var v=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:v,atMost:v};break;case",":var E;this.isDigit()?(E=this.integerIncludingZero(),d={atLeast:v,atMost:E}):d={atLeast:v,atMost:1/0},this.consumeChar("}");break}if(l===!0&&d===void 0)return;s(d);break}if(!(l===!0&&d===void 0))return s(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(y),d},t.prototype.atom=function(){var l,d=this.idx;switch(this.peekChar()){case".":l=this.dotAll();break;case"\\":l=this.atomEscape();break;case"[":l=this.characterClass();break;case"(":l=this.group();break}return l===void 0&&this.isPatternCharacter()&&(l=this.patternCharacter()),s(l),l.loc=this.loc(d),this.isQuantifier()&&(l.quantifier=this.quantifier()),l},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
81
81
  `),o("\r"),o("\u2028"),o("\u2029")]}},t.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()}},t.prototype.decimalEscapeAtom=function(){var l=this.positiveInteger();return{type:"GroupBackReference",value:l}},t.prototype.characterClassEscape=function(){var l,d=!1;switch(this.popChar()){case"d":l=g;break;case"D":l=g,d=!0;break;case"s":l=T;break;case"S":l=T,d=!0;break;case"w":l=p;break;case"W":l=p,d=!0;break}return s(l),{type:"Set",value:l,complement:d}},t.prototype.controlEscapeAtom=function(){var l;switch(this.popChar()){case"f":l=o("\f");break;case"n":l=o(`
82
82
  `);break;case"r":l=o("\r");break;case"t":l=o(" ");break;case"v":l=o("\v");break}return s(l),{type:"Character",value:l}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var l=this.popChar();if(/[a-zA-Z]/.test(l)===!1)throw Error("Invalid ");var d=l.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:d}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var l=this.popChar();return{type:"Character",value:o(l)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
83
83
  `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var l=this.popChar();return{type:"Character",value:o(l)}}},t.prototype.characterClass=function(){var l=[],d=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),d=!0);this.isClassAtom();){var y=this.classAtom(),v=y.type==="Character";if(v&&this.isRangeDash()){this.consumeChar("-");var E=this.classAtom(),S=E.type==="Character";if(S){if(E.value<y.value)throw Error("Range out of order in character class");l.push({from:y.value,to:E.value})}else u(y.value,l),l.push(o("-")),u(E.value,l)}else u(y.value,l)}return this.consumeChar("]"),{type:"Set",complement:d,value:l}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
@@ -85,7 +85,7 @@
85
85
  `: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(l)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return this.peekChar()==="-"&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(l){switch(l===void 0&&(l=0),this.peekChar(l)){case"]":case`
86
86
  `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.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}},t.prototype.isQuantifier=function(){var l=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(l)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
87
87
  `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(l){for(var d="",y=0;y<l;y++){var v=this.popChar();if(i.test(v)===!1)throw Error("Expecting a HexDecimal digits");d+=v}var E=parseInt(d,16);return{type:"Character",value:E}},t.prototype.peekChar=function(l){return l===void 0&&(l=0),this.input[this.idx+l]},t.prototype.popChar=function(){var l=this.peekChar(0);return this.consumeChar(),l},t.prototype.consumeChar=function(l){if(l!==void 0&&this.input[this.idx]!==l)throw Error("Expected: '"+l+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(l){return{begin:l,end:this.idx}};var i=/[0-9a-fA-F]/,r=/[0-9]/,a=/[1-9]/;function o(l){return l.charCodeAt(0)}function u(l,d){l.length!==void 0?l.forEach(function(y){d.push(y)}):d.push(l)}function c(l,d){if(l[d]===!0)throw"duplicate flag "+d;l[d]=!0}function s(l){if(l===void 0)throw Error("Internal Error - Should never get here!")}function f(){throw Error("Internal Error - Should never get here!")}var h,g=[];for(h=o("0");h<=o("9");h++)g.push(h);var p=[o("_")].concat(g);for(h=o("a");h<=o("z");h++)p.push(h);for(h=o("A");h<=o("Z");h++)p.push(h);var T=[o(" "),o("\f"),o(`
88
- `),o("\r"),o(" "),o("\v"),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o("\u2028"),o("\u2029"),o(" "),o(" "),o(" "),o("\uFEFF")];function m(){}return m.prototype.visitChildren=function(l){for(var d in l){var y=l[d];l.hasOwnProperty(d)&&(y.type!==void 0?this.visit(y):Array.isArray(y)&&y.forEach(function(v){this.visit(v)},this))}},m.prototype.visit=function(l){switch(l.type){case"Pattern":this.visitPattern(l);break;case"Flags":this.visitFlags(l);break;case"Disjunction":this.visitDisjunction(l);break;case"Alternative":this.visitAlternative(l);break;case"StartAnchor":this.visitStartAnchor(l);break;case"EndAnchor":this.visitEndAnchor(l);break;case"WordBoundary":this.visitWordBoundary(l);break;case"NonWordBoundary":this.visitNonWordBoundary(l);break;case"Lookahead":this.visitLookahead(l);break;case"NegativeLookahead":this.visitNegativeLookahead(l);break;case"Character":this.visitCharacter(l);break;case"Set":this.visitSet(l);break;case"Group":this.visitGroup(l);break;case"GroupBackReference":this.visitGroupBackReference(l);break;case"Quantifier":this.visitQuantifier(l);break}this.visitChildren(l)},m.prototype.visitPattern=function(l){},m.prototype.visitFlags=function(l){},m.prototype.visitDisjunction=function(l){},m.prototype.visitAlternative=function(l){},m.prototype.visitStartAnchor=function(l){},m.prototype.visitEndAnchor=function(l){},m.prototype.visitWordBoundary=function(l){},m.prototype.visitNonWordBoundary=function(l){},m.prototype.visitLookahead=function(l){},m.prototype.visitNegativeLookahead=function(l){},m.prototype.visitCharacter=function(l){},m.prototype.visitSet=function(l){},m.prototype.visitGroup=function(l){},m.prototype.visitGroupBackReference=function(l){},m.prototype.visitQuantifier=function(l){},{RegExpParser:t,BaseRegExpVisitor:m,VERSION:"0.5.0"}})}),jt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clearRegExpParserCache=n.getRegExpAst=void 0;var e=Ut(),t={},i=new e.RegExpParser;function r(o){var u=o.toString();if(t.hasOwnProperty(u))return t[u];var c=i.pattern(u);return t[u]=c,c}n.getRegExpAst=r;function a(){t={}}n.clearRegExpParserCache=a}),ni=ve(n=>{var e=n&&n.__extends||(function(){var m=function(l,d){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,v){y.__proto__=v}||function(y,v){for(var E in v)Object.prototype.hasOwnProperty.call(v,E)&&(y[E]=v[E])},m(l,d)};return function(l,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");m(l,d);function y(){this.constructor=l}l.prototype=d===null?Object.create(d):(y.prototype=d.prototype,new y)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.canMatchCharCode=n.firstCharOptimizedIndices=n.getOptimizedStartCodesIndices=n.failedOptimizationPrefixMsg=void 0;var t=Ut(),i=xe(),r=jt(),a=An(),o="Complement Sets are not supported for first char optimization";n.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
88
+ `),o("\r"),o(" "),o("\v"),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o(" "),o("\u2028"),o("\u2029"),o(" "),o(" "),o(" "),o("\uFEFF")];function m(){}return m.prototype.visitChildren=function(l){for(var d in l){var y=l[d];l.hasOwnProperty(d)&&(y.type!==void 0?this.visit(y):Array.isArray(y)&&y.forEach(function(v){this.visit(v)},this))}},m.prototype.visit=function(l){switch(l.type){case"Pattern":this.visitPattern(l);break;case"Flags":this.visitFlags(l);break;case"Disjunction":this.visitDisjunction(l);break;case"Alternative":this.visitAlternative(l);break;case"StartAnchor":this.visitStartAnchor(l);break;case"EndAnchor":this.visitEndAnchor(l);break;case"WordBoundary":this.visitWordBoundary(l);break;case"NonWordBoundary":this.visitNonWordBoundary(l);break;case"Lookahead":this.visitLookahead(l);break;case"NegativeLookahead":this.visitNegativeLookahead(l);break;case"Character":this.visitCharacter(l);break;case"Set":this.visitSet(l);break;case"Group":this.visitGroup(l);break;case"GroupBackReference":this.visitGroupBackReference(l);break;case"Quantifier":this.visitQuantifier(l);break}this.visitChildren(l)},m.prototype.visitPattern=function(l){},m.prototype.visitFlags=function(l){},m.prototype.visitDisjunction=function(l){},m.prototype.visitAlternative=function(l){},m.prototype.visitStartAnchor=function(l){},m.prototype.visitEndAnchor=function(l){},m.prototype.visitWordBoundary=function(l){},m.prototype.visitNonWordBoundary=function(l){},m.prototype.visitLookahead=function(l){},m.prototype.visitNegativeLookahead=function(l){},m.prototype.visitCharacter=function(l){},m.prototype.visitSet=function(l){},m.prototype.visitGroup=function(l){},m.prototype.visitGroupBackReference=function(l){},m.prototype.visitQuantifier=function(l){},{RegExpParser:t,BaseRegExpVisitor:m,VERSION:"0.5.0"}})}),Ut=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clearRegExpParserCache=n.getRegExpAst=void 0;var e=Ft(),t={},i=new e.RegExpParser;function r(o){var u=o.toString();if(t.hasOwnProperty(u))return t[u];var c=i.pattern(u);return t[u]=c,c}n.getRegExpAst=r;function a(){t={}}n.clearRegExpParserCache=a}),ni=ve(n=>{var e=n&&n.__extends||(function(){var m=function(l,d){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,v){y.__proto__=v}||function(y,v){for(var E in v)Object.prototype.hasOwnProperty.call(v,E)&&(y[E]=v[E])},m(l,d)};return function(l,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");m(l,d);function y(){this.constructor=l}l.prototype=d===null?Object.create(d):(y.prototype=d.prototype,new y)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.canMatchCharCode=n.firstCharOptimizedIndices=n.getOptimizedStartCodesIndices=n.failedOptimizationPrefixMsg=void 0;var t=Ft(),i=xe(),r=Ut(),a=An(),o="Complement Sets are not supported for first char optimization";n.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
89
89
  `;function u(m,l){l===void 0&&(l=!1);try{var d=r.getRegExpAst(m),y=c(d.value,{},d.flags.ignoreCase);return y}catch(E){if(E.message===o)l&&i.PRINT_WARNING(""+n.failedOptimizationPrefixMsg+(" Unable to optimize: < "+m.toString()+` >
90
90
  `)+` Complement Sets cannot be automatically optimized.
91
91
  This will disable the lexer's first char optimizations.
@@ -94,7 +94,7 @@
94
94
  See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),i.PRINT_ERROR(n.failedOptimizationPrefixMsg+`
95
95
  `+(" Failed parsing: < "+m.toString()+` >
96
96
  `)+(" Using the regexp-to-ast library version: "+t.VERSION+`
97
- `)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+v)}}return[]}n.getOptimizedStartCodesIndices=u;function c(m,l,d){switch(m.type){case"Disjunction":for(var y=0;y<m.value.length;y++)c(m.value[y],l,d);break;case"Alternative":for(var v=m.value,y=0;y<v.length;y++){var E=v[y];switch(E.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var S=E;switch(S.type){case"Character":s(S.value,l,d);break;case"Set":if(S.complement===!0)throw Error(o);i.forEach(S.value,function(H){if(typeof H=="number")s(H,l,d);else{var x=H;if(d===!0)for(var B=x.from;B<=x.to;B++)s(B,l,d);else{for(var B=x.from;B<=x.to&&B<a.minOptimizationVal;B++)s(B,l,d);if(x.to>=a.minOptimizationVal)for(var P=x.from>=a.minOptimizationVal?x.from:a.minOptimizationVal,O=x.to,M=a.charCodeToOptimizedIndex(P),C=a.charCodeToOptimizedIndex(O),X=M;X<=C;X++)l[X]=X}}});break;case"Group":c(S.value,l,d);break;default:throw Error("Non Exhaustive Match")}var I=S.quantifier!==void 0&&S.quantifier.atLeast===0;if(S.type==="Group"&&g(S)===!1||S.type!=="Group"&&I===!1)break}break;default:throw Error("non exhaustive match!")}return i.values(l)}n.firstCharOptimizedIndices=c;function s(m,l,d){var y=a.charCodeToOptimizedIndex(m);l[y]=y,d===!0&&f(m,l)}function f(m,l){var d=String.fromCharCode(m),y=d.toUpperCase();if(y!==d){var v=a.charCodeToOptimizedIndex(y.charCodeAt(0));l[v]=v}else{var E=d.toLowerCase();if(E!==d){var v=a.charCodeToOptimizedIndex(E.charCodeAt(0));l[v]=v}}}function h(m,l){return i.find(m.value,function(d){if(typeof d=="number")return i.contains(l,d);var y=d;return i.find(l,function(v){return y.from<=v&&v<=y.to})!==void 0})}function g(m){return m.quantifier&&m.quantifier.atLeast===0?!0:m.value?i.isArray(m.value)?i.every(m.value,g):g(m.value):!1}var p=(function(m){e(l,m);function l(d){var y=m.call(this)||this;return y.targetCharCodes=d,y.found=!1,y}return l.prototype.visitChildren=function(d){if(this.found!==!0){switch(d.type){case"Lookahead":this.visitLookahead(d);return;case"NegativeLookahead":this.visitNegativeLookahead(d);return}m.prototype.visitChildren.call(this,d)}},l.prototype.visitCharacter=function(d){i.contains(this.targetCharCodes,d.value)&&(this.found=!0)},l.prototype.visitSet=function(d){d.complement?h(d,this.targetCharCodes)===void 0&&(this.found=!0):h(d,this.targetCharCodes)!==void 0&&(this.found=!0)},l})(t.BaseRegExpVisitor);function T(m,l){if(l instanceof RegExp){var d=r.getRegExpAst(l),y=new p(m);return y.visit(d),y.found}else return i.find(l,function(v){return i.contains(m,v.charCodeAt(0))})!==void 0}n.canMatchCharCode=T}),An=ve(n=>{var e=n&&n.__extends||(function(){var U=function(G,K){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(q,J){q.__proto__=J}||function(q,J){for(var ie in J)Object.prototype.hasOwnProperty.call(J,ie)&&(q[ie]=J[ie])},U(G,K)};return function(G,K){if(typeof K!="function"&&K!==null)throw new TypeError("Class extends value "+String(K)+" is not a constructor or null");U(G,K);function q(){this.constructor=G}G.prototype=K===null?Object.create(K):(q.prototype=K.prototype,new q)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.charCodeToOptimizedIndex=n.minOptimizationVal=n.buildLineBreakIssueMessage=n.LineTerminatorOptimizedTester=n.isShortPattern=n.isCustomPattern=n.cloneEmptyGroups=n.performWarningRuntimeChecks=n.performRuntimeChecks=n.addStickyFlag=n.addStartOfInput=n.findUnreachablePatterns=n.findModesThatDoNotExist=n.findInvalidGroupType=n.findDuplicatePatterns=n.findUnsupportedFlags=n.findStartOfInputAnchor=n.findEmptyMatchRegExps=n.findEndOfInputAnchor=n.findInvalidPatterns=n.findMissingPatterns=n.validatePatterns=n.analyzeTokenTypes=n.enableSticky=n.disableSticky=n.SUPPORT_STICKY=n.MODES=n.DEFAULT_MODE=void 0;var t=Ut(),i=gt(),r=xe(),a=ni(),o=jt(),u="PATTERN";n.DEFAULT_MODE="defaultMode",n.MODES="modes",n.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function c(){n.SUPPORT_STICKY=!1}n.disableSticky=c;function s(){n.SUPPORT_STICKY=!0}n.enableSticky=s;function f(U,G){G=r.defaults(G,{useSticky:n.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
97
+ `)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+v)}}return[]}n.getOptimizedStartCodesIndices=u;function c(m,l,d){switch(m.type){case"Disjunction":for(var y=0;y<m.value.length;y++)c(m.value[y],l,d);break;case"Alternative":for(var v=m.value,y=0;y<v.length;y++){var E=v[y];switch(E.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var S=E;switch(S.type){case"Character":s(S.value,l,d);break;case"Set":if(S.complement===!0)throw Error(o);i.forEach(S.value,function(H){if(typeof H=="number")s(H,l,d);else{var x=H;if(d===!0)for(var B=x.from;B<=x.to;B++)s(B,l,d);else{for(var B=x.from;B<=x.to&&B<a.minOptimizationVal;B++)s(B,l,d);if(x.to>=a.minOptimizationVal)for(var P=x.from>=a.minOptimizationVal?x.from:a.minOptimizationVal,O=x.to,M=a.charCodeToOptimizedIndex(P),C=a.charCodeToOptimizedIndex(O),X=M;X<=C;X++)l[X]=X}}});break;case"Group":c(S.value,l,d);break;default:throw Error("Non Exhaustive Match")}var I=S.quantifier!==void 0&&S.quantifier.atLeast===0;if(S.type==="Group"&&g(S)===!1||S.type!=="Group"&&I===!1)break}break;default:throw Error("non exhaustive match!")}return i.values(l)}n.firstCharOptimizedIndices=c;function s(m,l,d){var y=a.charCodeToOptimizedIndex(m);l[y]=y,d===!0&&f(m,l)}function f(m,l){var d=String.fromCharCode(m),y=d.toUpperCase();if(y!==d){var v=a.charCodeToOptimizedIndex(y.charCodeAt(0));l[v]=v}else{var E=d.toLowerCase();if(E!==d){var v=a.charCodeToOptimizedIndex(E.charCodeAt(0));l[v]=v}}}function h(m,l){return i.find(m.value,function(d){if(typeof d=="number")return i.contains(l,d);var y=d;return i.find(l,function(v){return y.from<=v&&v<=y.to})!==void 0})}function g(m){return m.quantifier&&m.quantifier.atLeast===0?!0:m.value?i.isArray(m.value)?i.every(m.value,g):g(m.value):!1}var p=(function(m){e(l,m);function l(d){var y=m.call(this)||this;return y.targetCharCodes=d,y.found=!1,y}return l.prototype.visitChildren=function(d){if(this.found!==!0){switch(d.type){case"Lookahead":this.visitLookahead(d);return;case"NegativeLookahead":this.visitNegativeLookahead(d);return}m.prototype.visitChildren.call(this,d)}},l.prototype.visitCharacter=function(d){i.contains(this.targetCharCodes,d.value)&&(this.found=!0)},l.prototype.visitSet=function(d){d.complement?h(d,this.targetCharCodes)===void 0&&(this.found=!0):h(d,this.targetCharCodes)!==void 0&&(this.found=!0)},l})(t.BaseRegExpVisitor);function T(m,l){if(l instanceof RegExp){var d=r.getRegExpAst(l),y=new p(m);return y.visit(d),y.found}else return i.find(l,function(v){return i.contains(m,v.charCodeAt(0))})!==void 0}n.canMatchCharCode=T}),An=ve(n=>{var e=n&&n.__extends||(function(){var U=function(G,K){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(q,J){q.__proto__=J}||function(q,J){for(var ie in J)Object.prototype.hasOwnProperty.call(J,ie)&&(q[ie]=J[ie])},U(G,K)};return function(G,K){if(typeof K!="function"&&K!==null)throw new TypeError("Class extends value "+String(K)+" is not a constructor or null");U(G,K);function q(){this.constructor=G}G.prototype=K===null?Object.create(K):(q.prototype=K.prototype,new q)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.charCodeToOptimizedIndex=n.minOptimizationVal=n.buildLineBreakIssueMessage=n.LineTerminatorOptimizedTester=n.isShortPattern=n.isCustomPattern=n.cloneEmptyGroups=n.performWarningRuntimeChecks=n.performRuntimeChecks=n.addStickyFlag=n.addStartOfInput=n.findUnreachablePatterns=n.findModesThatDoNotExist=n.findInvalidGroupType=n.findDuplicatePatterns=n.findUnsupportedFlags=n.findStartOfInputAnchor=n.findEmptyMatchRegExps=n.findEndOfInputAnchor=n.findInvalidPatterns=n.findMissingPatterns=n.validatePatterns=n.analyzeTokenTypes=n.enableSticky=n.disableSticky=n.SUPPORT_STICKY=n.MODES=n.DEFAULT_MODE=void 0;var t=Ft(),i=gt(),r=xe(),a=ni(),o=Ut(),u="PATTERN";n.DEFAULT_MODE="defaultMode",n.MODES="modes",n.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function c(){n.SUPPORT_STICKY=!1}n.disableSticky=c;function s(){n.SUPPORT_STICKY=!0}n.enableSticky=s;function f(U,G){G=r.defaults(G,{useSticky:n.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
98
98
  `],tracer:function(b,A){return A()}});var K=G.tracer;K("initCharCodeToOptimizedIndexMap",function(){pe()});var q;K("Reject Lexer.NA",function(){q=r.reject(U,function(b){return b[u]===i.Lexer.NA})});var J=!1,ie;K("Transform Patterns",function(){J=!1,ie=r.map(q,function(b){var A=b[u];if(r.isRegExp(A)){var _=A.source;return _.length===1&&_!=="^"&&_!=="$"&&_!=="."&&!A.ignoreCase?_:_.length===2&&_[0]==="\\"&&!r.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],_[1])?_[1]:G.useSticky?O(A):P(A)}else{if(r.isFunction(A))return J=!0,{exec:A};if(r.has(A,"exec"))return J=!0,A;if(typeof A=="string"){if(A.length===1)return A;var N=A.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),L=new RegExp(N);return G.useSticky?O(L):P(L)}else throw Error("non exhaustive match")}})});var Te,ye,we,Be,We;K("misc mapping",function(){Te=r.map(q,function(b){return b.tokenTypeIdx}),ye=r.map(q,function(b){var A=b.GROUP;if(A!==i.Lexer.SKIPPED){if(r.isString(A))return A;if(r.isUndefined(A))return!1;throw Error("non exhaustive match")}}),we=r.map(q,function(b){var A=b.LONGER_ALT;if(A){var _=r.indexOf(q,A);return _}}),Be=r.map(q,function(b){return b.PUSH_MODE}),We=r.map(q,function(b){return r.has(b,"POP_MODE")})});var Ue;K("Line Terminator Handling",function(){var b=ce(G.lineTerminatorCharacters);Ue=r.map(q,function(A){return!1}),G.positionTracking!=="onlyOffset"&&(Ue=r.map(q,function(A){if(r.has(A,"LINE_BREAKS"))return A.LINE_BREAKS;if($(A,b)===!1)return a.canMatchCharCode(b,A.PATTERN)}))});var F,Y,z,ee;K("Misc Mapping #2",function(){F=r.map(q,Q),Y=r.map(ie,W),z=r.reduce(q,function(b,A){var _=A.GROUP;return r.isString(_)&&_!==i.Lexer.SKIPPED&&(b[_]=[]),b},{}),ee=r.map(ie,function(b,A){return{pattern:ie[A],longerAlt:we[A],canLineTerminator:Ue[A],isCustom:F[A],short:Y[A],group:ye[A],push:Be[A],pop:We[A],tokenTypeIdx:Te[A],tokenType:q[A]}})});var de=!0,be=[];return G.safeMode||K("First Char Optimization",function(){be=r.reduce(q,function(b,A,_){if(typeof A.PATTERN=="string"){var N=A.PATTERN.charCodeAt(0),L=ne(N);ae(b,L,ee[_])}else if(r.isArray(A.START_CHARS_HINT)){var w;r.forEach(A.START_CHARS_HINT,function(j){var V=typeof j=="string"?j.charCodeAt(0):j,Z=ne(V);w!==Z&&(w=Z,ae(b,Z,ee[_]))})}else if(r.isRegExp(A.PATTERN))if(A.PATTERN.unicode)de=!1,G.ensureOptimizations&&r.PRINT_ERROR(""+a.failedOptimizationPrefixMsg+(" Unable to analyze < "+A.PATTERN.toString()+` > pattern.
99
99
  `)+` The regexp unicode flag is not currently supported by the regexp-to-ast library.
100
100
  This will disable the lexer's first char optimizations.
@@ -119,7 +119,7 @@ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;G.
119
119
  `)+(" Root cause: "+G.errMsg+`.
120
120
  `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(G.issue===i.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
121
121
  `+(" The problem is in the <"+U.name+`> Token Type
122
- `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}n.buildLineBreakIssueMessage=te;function ce(U){var G=r.map(U,function(K){return r.isString(K)&&K.length>0?K.charCodeAt(0):K});return G}function ae(U,G,K){U[G]===void 0?U[G]=[K]:U[G].push(K)}n.minOptimizationVal=256;var le=[];function ne(U){return U<n.minOptimizationVal?U:le[U]}n.charCodeToOptimizedIndex=ne;function pe(){if(r.isEmpty(le)){le=new Array(65536);for(var U=0;U<65536;U++)le[U]=U>255?255+~~(U/255):U}}}),ht=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isTokenType=n.hasExtendingTokensTypesMapProperty=n.hasExtendingTokensTypesProperty=n.hasCategoriesProperty=n.hasShortKeyProperty=n.singleAssignCategoriesToksMap=n.assignCategoriesMapProp=n.assignCategoriesTokensProp=n.assignTokenDefaultProps=n.expandCategories=n.augmentTokenTypes=n.tokenIdxToClass=n.tokenShortNameIdx=n.tokenStructuredMatcherNoCategories=n.tokenStructuredMatcher=void 0;var e=xe();function t(m,l){var d=m.tokenTypeIdx;return d===l.tokenTypeIdx?!0:l.isParent===!0&&l.categoryMatchesMap[d]===!0}n.tokenStructuredMatcher=t;function i(m,l){return m.tokenTypeIdx===l.tokenTypeIdx}n.tokenStructuredMatcherNoCategories=i,n.tokenShortNameIdx=1,n.tokenIdxToClass={};function r(m){var l=a(m);o(l),c(l),u(l),e.forEach(l,function(d){d.isParent=d.categoryMatches.length>0})}n.augmentTokenTypes=r;function a(m){for(var l=e.cloneArr(m),d=m,y=!0;y;){d=e.compact(e.flatten(e.map(d,function(E){return E.CATEGORIES})));var v=e.difference(d,l);l=l.concat(v),e.isEmpty(v)?y=!1:d=v}return l}n.expandCategories=a;function o(m){e.forEach(m,function(l){f(l)||(n.tokenIdxToClass[n.tokenShortNameIdx]=l,l.tokenTypeIdx=n.tokenShortNameIdx++),h(l)&&!e.isArray(l.CATEGORIES)&&(l.CATEGORIES=[l.CATEGORIES]),h(l)||(l.CATEGORIES=[]),g(l)||(l.categoryMatches=[]),p(l)||(l.categoryMatchesMap={})})}n.assignTokenDefaultProps=o;function u(m){e.forEach(m,function(l){l.categoryMatches=[],e.forEach(l.categoryMatchesMap,function(d,y){l.categoryMatches.push(n.tokenIdxToClass[y].tokenTypeIdx)})})}n.assignCategoriesTokensProp=u;function c(m){e.forEach(m,function(l){s([],l)})}n.assignCategoriesMapProp=c;function s(m,l){e.forEach(m,function(d){l.categoryMatchesMap[d.tokenTypeIdx]=!0}),e.forEach(l.CATEGORIES,function(d){var y=m.concat(l);e.contains(y,d)||s(y,d)})}n.singleAssignCategoriesToksMap=s;function f(m){return e.has(m,"tokenTypeIdx")}n.hasShortKeyProperty=f;function h(m){return e.has(m,"CATEGORIES")}n.hasCategoriesProperty=h;function g(m){return e.has(m,"categoryMatches")}n.hasExtendingTokensTypesProperty=g;function p(m){return e.has(m,"categoryMatchesMap")}n.hasExtendingTokensTypesMapProperty=p;function T(m){return e.has(m,"tokenTypeIdx")}n.isTokenType=T}),_n=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultLexerErrorProvider=void 0,n.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,i,r,a){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+i+" characters.")}}}),gt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Lexer=n.LexerDefinitionErrorType=void 0;var e=An(),t=xe(),i=ht(),r=_n(),a=jt();(function(c){c[c.MISSING_PATTERN=0]="MISSING_PATTERN",c[c.INVALID_PATTERN=1]="INVALID_PATTERN",c[c.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",c[c.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",c[c.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",c[c.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",c[c.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",c[c.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",c[c.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",c[c.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",c[c.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",c[c.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",c[c.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",c[c.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",c[c.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",c[c.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",c[c.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(n.LexerDefinitionErrorType||(n.LexerDefinitionErrorType={}));var o={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
122
+ `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}n.buildLineBreakIssueMessage=te;function ce(U){var G=r.map(U,function(K){return r.isString(K)&&K.length>0?K.charCodeAt(0):K});return G}function ae(U,G,K){U[G]===void 0?U[G]=[K]:U[G].push(K)}n.minOptimizationVal=256;var le=[];function ne(U){return U<n.minOptimizationVal?U:le[U]}n.charCodeToOptimizedIndex=ne;function pe(){if(r.isEmpty(le)){le=new Array(65536);for(var U=0;U<65536;U++)le[U]=U>255?255+~~(U/255):U}}}),ht=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isTokenType=n.hasExtendingTokensTypesMapProperty=n.hasExtendingTokensTypesProperty=n.hasCategoriesProperty=n.hasShortKeyProperty=n.singleAssignCategoriesToksMap=n.assignCategoriesMapProp=n.assignCategoriesTokensProp=n.assignTokenDefaultProps=n.expandCategories=n.augmentTokenTypes=n.tokenIdxToClass=n.tokenShortNameIdx=n.tokenStructuredMatcherNoCategories=n.tokenStructuredMatcher=void 0;var e=xe();function t(m,l){var d=m.tokenTypeIdx;return d===l.tokenTypeIdx?!0:l.isParent===!0&&l.categoryMatchesMap[d]===!0}n.tokenStructuredMatcher=t;function i(m,l){return m.tokenTypeIdx===l.tokenTypeIdx}n.tokenStructuredMatcherNoCategories=i,n.tokenShortNameIdx=1,n.tokenIdxToClass={};function r(m){var l=a(m);o(l),c(l),u(l),e.forEach(l,function(d){d.isParent=d.categoryMatches.length>0})}n.augmentTokenTypes=r;function a(m){for(var l=e.cloneArr(m),d=m,y=!0;y;){d=e.compact(e.flatten(e.map(d,function(E){return E.CATEGORIES})));var v=e.difference(d,l);l=l.concat(v),e.isEmpty(v)?y=!1:d=v}return l}n.expandCategories=a;function o(m){e.forEach(m,function(l){f(l)||(n.tokenIdxToClass[n.tokenShortNameIdx]=l,l.tokenTypeIdx=n.tokenShortNameIdx++),h(l)&&!e.isArray(l.CATEGORIES)&&(l.CATEGORIES=[l.CATEGORIES]),h(l)||(l.CATEGORIES=[]),g(l)||(l.categoryMatches=[]),p(l)||(l.categoryMatchesMap={})})}n.assignTokenDefaultProps=o;function u(m){e.forEach(m,function(l){l.categoryMatches=[],e.forEach(l.categoryMatchesMap,function(d,y){l.categoryMatches.push(n.tokenIdxToClass[y].tokenTypeIdx)})})}n.assignCategoriesTokensProp=u;function c(m){e.forEach(m,function(l){s([],l)})}n.assignCategoriesMapProp=c;function s(m,l){e.forEach(m,function(d){l.categoryMatchesMap[d.tokenTypeIdx]=!0}),e.forEach(l.CATEGORIES,function(d){var y=m.concat(l);e.contains(y,d)||s(y,d)})}n.singleAssignCategoriesToksMap=s;function f(m){return e.has(m,"tokenTypeIdx")}n.hasShortKeyProperty=f;function h(m){return e.has(m,"CATEGORIES")}n.hasCategoriesProperty=h;function g(m){return e.has(m,"categoryMatches")}n.hasExtendingTokensTypesProperty=g;function p(m){return e.has(m,"categoryMatchesMap")}n.hasExtendingTokensTypesMapProperty=p;function T(m){return e.has(m,"tokenTypeIdx")}n.isTokenType=T}),_n=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultLexerErrorProvider=void 0,n.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,i,r,a){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+i+" characters.")}}}),gt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Lexer=n.LexerDefinitionErrorType=void 0;var e=An(),t=xe(),i=ht(),r=_n(),a=Ut();(function(c){c[c.MISSING_PATTERN=0]="MISSING_PATTERN",c[c.INVALID_PATTERN=1]="INVALID_PATTERN",c[c.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",c[c.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",c[c.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",c[c.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",c[c.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",c[c.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",c[c.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",c[c.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",c[c.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",c[c.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",c[c.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",c[c.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",c[c.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",c[c.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",c[c.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(n.LexerDefinitionErrorType||(n.LexerDefinitionErrorType={}));var o={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
123
123
  `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:r.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(o);var u=(function(){function c(s,f){var h=this;if(f===void 0&&(f=o),this.lexerDefinition=s,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={},typeof f=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
124
124
  a boolean 2nd argument is no longer supported`);this.config=t.merge(o,f);var g=this.config.traceInitPerf;g===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof g=="number"&&(this.traceInitMaxIdent=g,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var p,T=!0;h.TRACE_INIT("Lexer Config handling",function(){if(h.config.lineTerminatorsPattern===o.lineTerminatorsPattern)h.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(h.config.lineTerminatorCharacters===o.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
125
125
  For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(f.safeMode&&f.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');h.trackStartLines=/full|onlyStart/i.test(h.config.positionTracking),h.trackEndLines=/full/i.test(h.config.positionTracking),t.isArray(s)?(p={modes:{}},p.modes[e.DEFAULT_MODE]=t.cloneArr(s),p[e.DEFAULT_MODE]=e.DEFAULT_MODE):(T=!1,p=t.cloneObj(s))}),h.config.skipValidations===!1&&(h.TRACE_INIT("performRuntimeChecks",function(){h.lexerDefinitionErrors=h.lexerDefinitionErrors.concat(e.performRuntimeChecks(p,h.trackStartLines,h.config.lineTerminatorCharacters))}),h.TRACE_INIT("performWarningRuntimeChecks",function(){h.lexerDefinitionWarning=h.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(p,h.trackStartLines,h.config.lineTerminatorCharacters))})),p.modes=p.modes?p.modes:{},t.forEach(p.modes,function(y,v){p.modes[v]=t.reject(y,function(E){return t.isUndefined(E)})});var m=t.keys(p.modes);if(t.forEach(p.modes,function(y,v){h.TRACE_INIT("Mode: <"+v+"> processing",function(){if(h.modes.push(v),h.config.skipValidations===!1&&h.TRACE_INIT("validatePatterns",function(){h.lexerDefinitionErrors=h.lexerDefinitionErrors.concat(e.validatePatterns(y,m))}),t.isEmpty(h.lexerDefinitionErrors)){i.augmentTokenTypes(y);var E;h.TRACE_INIT("analyzeTokenTypes",function(){E=e.analyzeTokenTypes(y,{lineTerminatorCharacters:h.config.lineTerminatorCharacters,positionTracking:f.positionTracking,ensureOptimizations:f.ensureOptimizations,safeMode:f.safeMode,tracer:h.TRACE_INIT.bind(h)})}),h.patternIdxToConfig[v]=E.patternIdxToConfig,h.charCodeToPatternIdxToConfig[v]=E.charCodeToPatternIdxToConfig,h.emptyGroups=t.merge(h.emptyGroups,E.emptyGroups),h.hasCustom=E.hasCustom||h.hasCustom,h.canModeBeOptimized[v]=E.canBeOptimized}})}),h.defaultMode=p.defaultMode,!t.isEmpty(h.lexerDefinitionErrors)&&!h.config.deferDefinitionErrorsHandling){var l=t.map(h.lexerDefinitionErrors,function(y){return y.message}),d=l.join(`-----------------------
@@ -129,7 +129,7 @@ a boolean 2nd argument is no longer supported`);this.config=t.merge(o,f);var g=t
129
129
  Or inspect the console log for details on how to resolve these issues.`)}),h.TRACE_INIT("clearRegExpParserCache",function(){a.clearRegExpParserCache()}),h.TRACE_INIT("toFastProperties",function(){t.toFastProperties(h)})})}return c.prototype.tokenize=function(s,f){if(f===void 0&&(f=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var h=t.map(this.lexerDefinitionErrors,function(T){return T.message}),g=h.join(`-----------------------
130
130
  `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
131
131
  `+g)}var p=this.tokenizeInternal(s,f);return p},c.prototype.tokenizeInternal=function(s,f){var h=this,g,p,T,m,l,d,y,v,E,S,I,k,H,x,B=s,P=B.length,O=0,M=0,C=this.hasCustom?0:Math.floor(s.length/10),X=new Array(C),Q=[],W=this.trackStartLines?1:void 0,$=this.trackStartLines?1:void 0,te=e.cloneEmptyGroups(this.emptyGroups),ce=this.trackStartLines,ae=this.config.lineTerminatorsPattern,le=0,ne=[],pe=[],U=[],G=[];Object.freeze(G);var K=void 0;function q(){return ne}function J(w){var D=e.charCodeToOptimizedIndex(w),j=pe[D];return j===void 0?G:j}var ie=function(w){if(U.length===1&&w.tokenType.PUSH_MODE===void 0){var D=h.config.errorMessageProvider.buildUnableToPopLexerModeMessage(w);Q.push({offset:w.startOffset,line:w.startLine!==void 0?w.startLine:void 0,column:w.startColumn!==void 0?w.startColumn:void 0,length:w.image.length,message:D})}else{U.pop();var j=t.last(U);ne=h.patternIdxToConfig[j],pe=h.charCodeToPatternIdxToConfig[j],le=ne.length;var V=h.canModeBeOptimized[j]&&h.config.safeMode===!1;pe&&V?K=J:K=q}};function Te(w){U.push(w),pe=this.charCodeToPatternIdxToConfig[w],ne=this.patternIdxToConfig[w],le=ne.length,le=ne.length;var D=this.canModeBeOptimized[w]&&this.config.safeMode===!1;pe&&D?K=J:K=q}Te.call(this,f);for(var ye;O<P;){l=null;var we=B.charCodeAt(O),Be=K(we),We=Be.length;for(g=0;g<We;g++){ye=Be[g];var Ue=ye.pattern;d=null;var F=ye.short;if(F!==!1?we===F&&(l=Ue):ye.isCustom===!0?(x=Ue.exec(B,O,X,te),x!==null?(l=x[0],x.payload!==void 0&&(d=x.payload)):l=null):(this.updateLastIndex(Ue,O),l=this.match(Ue,s,O)),l!==null){if(m=ye.longerAlt,m!==void 0){var Y=ne[m],z=Y.pattern;y=null,Y.isCustom===!0?(x=z.exec(B,O,X,te),x!==null?(T=x[0],x.payload!==void 0&&(y=x.payload)):T=null):(this.updateLastIndex(z,O),T=this.match(z,s,O)),T&&T.length>l.length&&(l=T,d=y,ye=Y)}break}}if(l!==null){if(v=l.length,E=ye.group,E!==void 0&&(S=ye.tokenTypeIdx,I=this.createTokenInstance(l,O,S,ye.tokenType,W,$,v),this.handlePayload(I,d),E===!1?M=this.addToken(X,M,I):te[E].push(I)),s=this.chopInput(s,v),O=O+v,$=this.computeNewColumn($,v),ce===!0&&ye.canLineTerminator===!0){var ee=0,de=void 0,be=void 0;ae.lastIndex=0;do de=ae.test(l),de===!0&&(be=ae.lastIndex-1,ee++);while(de===!0);ee!==0&&(W=W+ee,$=v-be,this.updateTokenEndLineColumnLocation(I,E,be,ee,W,$,v))}this.handleModes(ye,ie,Te,I)}else{for(var b=O,A=W,_=$,N=!1;!N&&O<P;)for(B.charCodeAt(O),s=this.chopInput(s,1),O++,p=0;p<le;p++){var L=ne[p],Ue=L.pattern,F=L.short;if(F!==!1?B.charCodeAt(O)===F&&(N=!0):L.isCustom===!0?N=Ue.exec(B,O,X,te)!==null:(this.updateLastIndex(Ue,O),N=Ue.exec(s)!==null),N===!0)break}k=O-b,H=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(B,b,k,A,_),Q.push({offset:b,line:A,column:_,length:k,message:H})}}return this.hasCustom||(X.length=M),{tokens:X,groups:te,errors:Q}},c.prototype.handleModes=function(s,f,h,g){if(s.pop===!0){var p=s.push;f(g),p!==void 0&&h.call(this,p)}else s.push!==void 0&&h.call(this,s.push)},c.prototype.chopInput=function(s,f){return s.substring(f)},c.prototype.updateLastIndex=function(s,f){s.lastIndex=f},c.prototype.updateTokenEndLineColumnLocation=function(s,f,h,g,p,T,m){var l,d;f!==void 0&&(l=h===m-1,d=l?-1:0,g===1&&l===!0||(s.endLine=p+d,s.endColumn=T-1+-d))},c.prototype.computeNewColumn=function(s,f){return s+f},c.prototype.createTokenInstance=function(){for(var s=[],f=0;f<arguments.length;f++)s[f]=arguments[f];return null},c.prototype.createOffsetOnlyToken=function(s,f,h,g){return{image:s,startOffset:f,tokenTypeIdx:h,tokenType:g}},c.prototype.createStartOnlyToken=function(s,f,h,g,p,T){return{image:s,startOffset:f,startLine:p,startColumn:T,tokenTypeIdx:h,tokenType:g}},c.prototype.createFullToken=function(s,f,h,g,p,T,m){return{image:s,startOffset:f,endOffset:f+m-1,startLine:p,endLine:p,startColumn:T,endColumn:T+m-1,tokenTypeIdx:h,tokenType:g}},c.prototype.addToken=function(s,f,h){return 666},c.prototype.addTokenUsingPush=function(s,f,h){return s.push(h),f},c.prototype.addTokenUsingMemberAccess=function(s,f,h){return s[f]=h,f++,f},c.prototype.handlePayload=function(s,f){},c.prototype.handlePayloadNoCustom=function(s,f){},c.prototype.handlePayloadWithCustom=function(s,f){f!==null&&(s.payload=f)},c.prototype.match=function(s,f,h){return null},c.prototype.matchWithTest=function(s,f,h){var g=s.test(f);return g===!0?f.substring(h,s.lastIndex):null},c.prototype.matchWithExec=function(s,f){var h=s.exec(f);return h!==null?h[0]:h},c.prototype.TRACE_INIT=function(s,f){if(this.traceInitPerf===!0){this.traceInitIndent++;var h=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(h+"--> <"+s+">");var g=t.timer(f),p=g.time,T=g.value,m=p>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&m(h+"<-- <"+s+"> time: "+p+"ms"),this.traceInitIndent--,T}else return f()},c.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.",c.NA=/NOT_APPLICABLE/,c})();n.Lexer=u}),nt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tokenMatcher=n.createTokenInstance=n.EOF=n.createToken=n.hasTokenLabel=n.tokenName=n.tokenLabel=void 0;var e=xe(),t=gt(),i=ht();function r(E){return o(E)?E.LABEL:E.name}n.tokenLabel=r;function a(E){return E.name}n.tokenName=a;function o(E){return e.isString(E.LABEL)&&E.LABEL!==""}n.hasTokenLabel=o;var u="parent",c="categories",s="label",f="group",h="push_mode",g="pop_mode",p="longer_alt",T="line_breaks",m="start_chars_hint";function l(E){return d(E)}n.createToken=l;function d(E){var S=E.pattern,I={};if(I.name=E.name,e.isUndefined(S)||(I.PATTERN=S),e.has(E,u))throw`The parent property is no longer supported.
132
- See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(E,c)&&(I.CATEGORIES=E[c]),i.augmentTokenTypes([I]),e.has(E,s)&&(I.LABEL=E[s]),e.has(E,f)&&(I.GROUP=E[f]),e.has(E,g)&&(I.POP_MODE=E[g]),e.has(E,h)&&(I.PUSH_MODE=E[h]),e.has(E,p)&&(I.LONGER_ALT=E[p]),e.has(E,T)&&(I.LINE_BREAKS=E[T]),e.has(E,m)&&(I.START_CHARS_HINT=E[m]),I}n.EOF=l({name:"EOF",pattern:t.Lexer.NA}),i.augmentTokenTypes([n.EOF]);function y(E,S,I,k,H,x,B,P){return{image:S,startOffset:I,endOffset:k,startLine:H,endLine:x,startColumn:B,endColumn:P,tokenTypeIdx:E.tokenTypeIdx,tokenType:E}}n.createTokenInstance=y;function v(E,S){return i.tokenStructuredMatcher(E,S)}n.tokenMatcher=v}),He=ve(n=>{var e=n&&n.__extends||(function(){var d=function(y,v){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,S){E.__proto__=S}||function(E,S){for(var I in S)Object.prototype.hasOwnProperty.call(S,I)&&(E[I]=S[I])},d(y,v)};return function(y,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");d(y,v);function E(){this.constructor=y}y.prototype=v===null?Object.create(v):(E.prototype=v.prototype,new E)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.serializeProduction=n.serializeGrammar=n.Terminal=n.Alternation=n.RepetitionWithSeparator=n.Repetition=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Option=n.Alternative=n.Rule=n.NonTerminal=n.AbstractProduction=void 0;var t=xe(),i=nt(),r=(function(){function d(y){this._definition=y}return Object.defineProperty(d.prototype,"definition",{get:function(){return this._definition},set:function(y){this._definition=y},enumerable:!1,configurable:!0}),d.prototype.accept=function(y){y.visit(this),t.forEach(this.definition,function(v){v.accept(y)})},d})();n.AbstractProduction=r;var a=(function(d){e(y,d);function y(v){var E=d.call(this,[])||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(v){},enumerable:!1,configurable:!0}),y.prototype.accept=function(v){v.visit(this)},y})(r);n.NonTerminal=a;var o=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.orgText="",t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Rule=o;var u=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.ignoreAmbiguities=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Alternative=u;var c=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Option=c;var s=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionMandatory=s;var f=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionMandatoryWithSeparator=f;var h=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Repetition=h;var g=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionWithSeparator=g;var p=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,E.ignoreAmbiguities=!1,E.hasPredicates=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),y})(r);n.Alternation=p;var T=(function(){function d(y){this.idx=1,t.assign(this,t.pick(y,function(v){return v!==void 0}))}return d.prototype.accept=function(y){y.visit(this)},d})();n.Terminal=T;function m(d){return t.map(d,l)}n.serializeGrammar=m;function l(d){function y(S){return t.map(S,l)}if(d instanceof a)return{type:"NonTerminal",name:d.nonTerminalName,idx:d.idx};if(d instanceof u)return{type:"Alternative",definition:y(d.definition)};if(d instanceof c)return{type:"Option",idx:d.idx,definition:y(d.definition)};if(d instanceof s)return{type:"RepetitionMandatory",idx:d.idx,definition:y(d.definition)};if(d instanceof f)return{type:"RepetitionMandatoryWithSeparator",idx:d.idx,separator:l(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof g)return{type:"RepetitionWithSeparator",idx:d.idx,separator:l(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof h)return{type:"Repetition",idx:d.idx,definition:y(d.definition)};if(d instanceof p)return{type:"Alternation",idx:d.idx,definition:y(d.definition)};if(d instanceof T){var v={type:"Terminal",name:d.terminalType.name,label:i.tokenLabel(d.terminalType),idx:d.idx},E=d.terminalType.PATTERN;return d.terminalType.PATTERN&&(v.pattern=t.isRegExp(E)?E.source:E),v}else{if(d instanceof o)return{type:"Rule",name:d.name,orgText:d.orgText,definition:y(d.definition)};throw Error("non exhaustive match")}}n.serializeProduction=l}),Bt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RestWalker=void 0;var e=xe(),t=He(),i=(function(){function a(){}return a.prototype.walk=function(o,u){var c=this;u===void 0&&(u=[]),e.forEach(o.definition,function(s,f){var h=e.drop(o.definition,f+1);if(s instanceof t.NonTerminal)c.walkProdRef(s,h,u);else if(s instanceof t.Terminal)c.walkTerminal(s,h,u);else if(s instanceof t.Alternative)c.walkFlat(s,h,u);else if(s instanceof t.Option)c.walkOption(s,h,u);else if(s instanceof t.RepetitionMandatory)c.walkAtLeastOne(s,h,u);else if(s instanceof t.RepetitionMandatoryWithSeparator)c.walkAtLeastOneSep(s,h,u);else if(s instanceof t.RepetitionWithSeparator)c.walkManySep(s,h,u);else if(s instanceof t.Repetition)c.walkMany(s,h,u);else if(s instanceof t.Alternation)c.walkOr(s,h,u);else throw Error("non exhaustive match")})},a.prototype.walkTerminal=function(o,u,c){},a.prototype.walkProdRef=function(o,u,c){},a.prototype.walkFlat=function(o,u,c){var s=u.concat(c);this.walk(o,s)},a.prototype.walkOption=function(o,u,c){var s=u.concat(c);this.walk(o,s)},a.prototype.walkAtLeastOne=function(o,u,c){var s=[new t.Option({definition:o.definition})].concat(u,c);this.walk(o,s)},a.prototype.walkAtLeastOneSep=function(o,u,c){var s=r(o,u,c);this.walk(o,s)},a.prototype.walkMany=function(o,u,c){var s=[new t.Option({definition:o.definition})].concat(u,c);this.walk(o,s)},a.prototype.walkManySep=function(o,u,c){var s=r(o,u,c);this.walk(o,s)},a.prototype.walkOr=function(o,u,c){var s=this,f=u.concat(c);e.forEach(o.definition,function(h){var g=new t.Alternative({definition:[h]});s.walk(g,f)})},a})();n.RestWalker=i;function r(a,o,u){var c=[new t.Option({definition:[new t.Terminal({terminalType:a.separator})].concat(a.definition)})],s=c.concat(o,u);return s}}),ft=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GAstVisitor=void 0;var e=He(),t=(function(){function i(){}return i.prototype.visit=function(r){var a=r;switch(a.constructor){case e.NonTerminal:return this.visitNonTerminal(a);case e.Alternative:return this.visitAlternative(a);case e.Option:return this.visitOption(a);case e.RepetitionMandatory:return this.visitRepetitionMandatory(a);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(a);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(a);case e.Repetition:return this.visitRepetition(a);case e.Alternation:return this.visitAlternation(a);case e.Terminal:return this.visitTerminal(a);case e.Rule:return this.visitRule(a);default:throw Error("non exhaustive match")}},i.prototype.visitNonTerminal=function(r){},i.prototype.visitAlternative=function(r){},i.prototype.visitOption=function(r){},i.prototype.visitRepetition=function(r){},i.prototype.visitRepetitionMandatory=function(r){},i.prototype.visitRepetitionMandatoryWithSeparator=function(r){},i.prototype.visitRepetitionWithSeparator=function(r){},i.prototype.visitAlternation=function(r){},i.prototype.visitTerminal=function(r){},i.prototype.visitRule=function(r){},i})();n.GAstVisitor=t}),Tt=ve(n=>{var e=n&&n.__extends||(function(){var g=function(p,T){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,l){m.__proto__=l}||function(m,l){for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(m[d]=l[d])},g(p,T)};return function(p,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");g(p,T);function m(){this.constructor=p}p.prototype=T===null?Object.create(T):(m.prototype=T.prototype,new m)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.collectMethods=n.DslMethodsCollectorVisitor=n.getProductionDslName=n.isBranchingProd=n.isOptionalProd=n.isSequenceProd=void 0;var t=xe(),i=He(),r=ft();function a(g){return g instanceof i.Alternative||g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionMandatory||g instanceof i.RepetitionMandatoryWithSeparator||g instanceof i.RepetitionWithSeparator||g instanceof i.Terminal||g instanceof i.Rule}n.isSequenceProd=a;function o(g,p){p===void 0&&(p=[]);var T=g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionWithSeparator;return T?!0:g instanceof i.Alternation?t.some(g.definition,function(m){return o(m,p)}):g instanceof i.NonTerminal&&t.contains(p,g)?!1:g instanceof i.AbstractProduction?(g instanceof i.NonTerminal&&p.push(g),t.every(g.definition,function(m){return o(m,p)})):!1}n.isOptionalProd=o;function u(g){return g instanceof i.Alternation}n.isBranchingProd=u;function c(g){if(g instanceof i.NonTerminal)return"SUBRULE";if(g instanceof i.Option)return"OPTION";if(g instanceof i.Alternation)return"OR";if(g instanceof i.RepetitionMandatory)return"AT_LEAST_ONE";if(g instanceof i.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(g instanceof i.RepetitionWithSeparator)return"MANY_SEP";if(g instanceof i.Repetition)return"MANY";if(g instanceof i.Terminal)return"CONSUME";throw Error("non exhaustive match")}n.getProductionDslName=c;var s=(function(g){e(p,g);function p(){var T=g!==null&&g.apply(this,arguments)||this;return T.separator="-",T.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},T}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(T){var m=T.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitNonTerminal=function(T){var m=T.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitOption=function(T){this.dslMethods.option.push(T)},p.prototype.visitRepetitionWithSeparator=function(T){this.dslMethods.repetitionWithSeparator.push(T)},p.prototype.visitRepetitionMandatory=function(T){this.dslMethods.repetitionMandatory.push(T)},p.prototype.visitRepetitionMandatoryWithSeparator=function(T){this.dslMethods.repetitionMandatoryWithSeparator.push(T)},p.prototype.visitRepetition=function(T){this.dslMethods.repetition.push(T)},p.prototype.visitAlternation=function(T){this.dslMethods.alternation.push(T)},p})(r.GAstVisitor);n.DslMethodsCollectorVisitor=s;var f=new s;function h(g){f.reset(),g.accept(f);var p=f.dslMethods;return f.reset(),p}n.collectMethods=h}),bn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.firstForTerminal=n.firstForBranching=n.firstForSequence=n.first=void 0;var e=xe(),t=He(),i=Tt();function r(c){if(c instanceof t.NonTerminal)return r(c.referencedRule);if(c instanceof t.Terminal)return u(c);if(i.isSequenceProd(c))return a(c);if(i.isBranchingProd(c))return o(c);throw Error("non exhaustive match")}n.first=r;function a(c){for(var s=[],f=c.definition,h=0,g=f.length>h,p,T=!0;g&&T;)p=f[h],T=i.isOptionalProd(p),s=s.concat(r(p)),h=h+1,g=f.length>h;return e.uniq(s)}n.firstForSequence=a;function o(c){var s=e.map(c.definition,function(f){return r(f)});return e.uniq(e.flatten(s))}n.firstForBranching=o;function u(c){return[c.terminalType]}n.firstForTerminal=u}),Ln=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IN=void 0,n.IN="_~IN~_"}),ri=ve(n=>{var e=n&&n.__extends||(function(){var h=function(g,p){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,m){T.__proto__=m}||function(T,m){for(var l in m)Object.prototype.hasOwnProperty.call(m,l)&&(T[l]=m[l])},h(g,p)};return function(g,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");h(g,p);function T(){this.constructor=g}g.prototype=p===null?Object.create(p):(T.prototype=p.prototype,new T)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.buildInProdFollowPrefix=n.buildBetweenProdsFollowPrefix=n.computeAllProdsFollows=n.ResyncFollowsWalker=void 0;var t=Bt(),i=bn(),r=xe(),a=Ln(),o=He(),u=(function(h){e(g,h);function g(p){var T=h.call(this)||this;return T.topProd=p,T.follows={},T}return g.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},g.prototype.walkTerminal=function(p,T,m){},g.prototype.walkProdRef=function(p,T,m){var l=s(p.referencedRule,p.idx)+this.topProd.name,d=T.concat(m),y=new o.Alternative({definition:d}),v=i.first(y);this.follows[l]=v},g})(t.RestWalker);n.ResyncFollowsWalker=u;function c(h){var g={};return r.forEach(h,function(p){var T=new u(p).startWalking();r.assign(g,T)}),g}n.computeAllProdsFollows=c;function s(h,g){return h.name+g+a.IN}n.buildBetweenProdsFollowPrefix=s;function f(h){var g=h.terminalType.name;return g+h.idx+a.IN}n.buildInProdFollowPrefix=f}),Et=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultGrammarValidatorErrorProvider=n.defaultGrammarResolverErrorProvider=n.defaultParserErrorProvider=void 0;var e=nt(),t=xe(),i=xe(),r=He(),a=Tt();n.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var u=o.expected,c=o.actual;o.previous,o.ruleName;var s=e.hasTokenLabel(u),f=s?"--> "+e.tokenLabel(u)+" <--":"token of type --> "+u.name+" <--",h="Expecting "+f+" but found --> '"+c.image+"' <--";return h},buildNotAllInputParsedMessage:function(o){var u=o.firstRedundant;return o.ruleName,"Redundant input, expecting EOF but found: "+u.image},buildNoViableAltMessage:function(o){var u=o.expectedPathsPerAlt,c=o.actual;o.previous;var s=o.customUserDescription;o.ruleName;var f="Expecting: ",h=i.first(c).image,g=`
132
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(E,c)&&(I.CATEGORIES=E[c]),i.augmentTokenTypes([I]),e.has(E,s)&&(I.LABEL=E[s]),e.has(E,f)&&(I.GROUP=E[f]),e.has(E,g)&&(I.POP_MODE=E[g]),e.has(E,h)&&(I.PUSH_MODE=E[h]),e.has(E,p)&&(I.LONGER_ALT=E[p]),e.has(E,T)&&(I.LINE_BREAKS=E[T]),e.has(E,m)&&(I.START_CHARS_HINT=E[m]),I}n.EOF=l({name:"EOF",pattern:t.Lexer.NA}),i.augmentTokenTypes([n.EOF]);function y(E,S,I,k,H,x,B,P){return{image:S,startOffset:I,endOffset:k,startLine:H,endLine:x,startColumn:B,endColumn:P,tokenTypeIdx:E.tokenTypeIdx,tokenType:E}}n.createTokenInstance=y;function v(E,S){return i.tokenStructuredMatcher(E,S)}n.tokenMatcher=v}),He=ve(n=>{var e=n&&n.__extends||(function(){var d=function(y,v){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,S){E.__proto__=S}||function(E,S){for(var I in S)Object.prototype.hasOwnProperty.call(S,I)&&(E[I]=S[I])},d(y,v)};return function(y,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");d(y,v);function E(){this.constructor=y}y.prototype=v===null?Object.create(v):(E.prototype=v.prototype,new E)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.serializeProduction=n.serializeGrammar=n.Terminal=n.Alternation=n.RepetitionWithSeparator=n.Repetition=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Option=n.Alternative=n.Rule=n.NonTerminal=n.AbstractProduction=void 0;var t=xe(),i=nt(),r=(function(){function d(y){this._definition=y}return Object.defineProperty(d.prototype,"definition",{get:function(){return this._definition},set:function(y){this._definition=y},enumerable:!1,configurable:!0}),d.prototype.accept=function(y){y.visit(this),t.forEach(this.definition,function(v){v.accept(y)})},d})();n.AbstractProduction=r;var a=(function(d){e(y,d);function y(v){var E=d.call(this,[])||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(v){},enumerable:!1,configurable:!0}),y.prototype.accept=function(v){v.visit(this)},y})(r);n.NonTerminal=a;var o=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.orgText="",t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Rule=o;var u=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.ignoreAmbiguities=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Alternative=u;var c=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Option=c;var s=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionMandatory=s;var f=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionMandatoryWithSeparator=f;var h=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.Repetition=h;var g=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return y})(r);n.RepetitionWithSeparator=g;var p=(function(d){e(y,d);function y(v){var E=d.call(this,v.definition)||this;return E.idx=1,E.ignoreAmbiguities=!1,E.hasPredicates=!1,t.assign(E,t.pick(v,function(S){return S!==void 0})),E}return Object.defineProperty(y.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),y})(r);n.Alternation=p;var T=(function(){function d(y){this.idx=1,t.assign(this,t.pick(y,function(v){return v!==void 0}))}return d.prototype.accept=function(y){y.visit(this)},d})();n.Terminal=T;function m(d){return t.map(d,l)}n.serializeGrammar=m;function l(d){function y(S){return t.map(S,l)}if(d instanceof a)return{type:"NonTerminal",name:d.nonTerminalName,idx:d.idx};if(d instanceof u)return{type:"Alternative",definition:y(d.definition)};if(d instanceof c)return{type:"Option",idx:d.idx,definition:y(d.definition)};if(d instanceof s)return{type:"RepetitionMandatory",idx:d.idx,definition:y(d.definition)};if(d instanceof f)return{type:"RepetitionMandatoryWithSeparator",idx:d.idx,separator:l(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof g)return{type:"RepetitionWithSeparator",idx:d.idx,separator:l(new T({terminalType:d.separator})),definition:y(d.definition)};if(d instanceof h)return{type:"Repetition",idx:d.idx,definition:y(d.definition)};if(d instanceof p)return{type:"Alternation",idx:d.idx,definition:y(d.definition)};if(d instanceof T){var v={type:"Terminal",name:d.terminalType.name,label:i.tokenLabel(d.terminalType),idx:d.idx},E=d.terminalType.PATTERN;return d.terminalType.PATTERN&&(v.pattern=t.isRegExp(E)?E.source:E),v}else{if(d instanceof o)return{type:"Rule",name:d.name,orgText:d.orgText,definition:y(d.definition)};throw Error("non exhaustive match")}}n.serializeProduction=l}),jt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RestWalker=void 0;var e=xe(),t=He(),i=(function(){function a(){}return a.prototype.walk=function(o,u){var c=this;u===void 0&&(u=[]),e.forEach(o.definition,function(s,f){var h=e.drop(o.definition,f+1);if(s instanceof t.NonTerminal)c.walkProdRef(s,h,u);else if(s instanceof t.Terminal)c.walkTerminal(s,h,u);else if(s instanceof t.Alternative)c.walkFlat(s,h,u);else if(s instanceof t.Option)c.walkOption(s,h,u);else if(s instanceof t.RepetitionMandatory)c.walkAtLeastOne(s,h,u);else if(s instanceof t.RepetitionMandatoryWithSeparator)c.walkAtLeastOneSep(s,h,u);else if(s instanceof t.RepetitionWithSeparator)c.walkManySep(s,h,u);else if(s instanceof t.Repetition)c.walkMany(s,h,u);else if(s instanceof t.Alternation)c.walkOr(s,h,u);else throw Error("non exhaustive match")})},a.prototype.walkTerminal=function(o,u,c){},a.prototype.walkProdRef=function(o,u,c){},a.prototype.walkFlat=function(o,u,c){var s=u.concat(c);this.walk(o,s)},a.prototype.walkOption=function(o,u,c){var s=u.concat(c);this.walk(o,s)},a.prototype.walkAtLeastOne=function(o,u,c){var s=[new t.Option({definition:o.definition})].concat(u,c);this.walk(o,s)},a.prototype.walkAtLeastOneSep=function(o,u,c){var s=r(o,u,c);this.walk(o,s)},a.prototype.walkMany=function(o,u,c){var s=[new t.Option({definition:o.definition})].concat(u,c);this.walk(o,s)},a.prototype.walkManySep=function(o,u,c){var s=r(o,u,c);this.walk(o,s)},a.prototype.walkOr=function(o,u,c){var s=this,f=u.concat(c);e.forEach(o.definition,function(h){var g=new t.Alternative({definition:[h]});s.walk(g,f)})},a})();n.RestWalker=i;function r(a,o,u){var c=[new t.Option({definition:[new t.Terminal({terminalType:a.separator})].concat(a.definition)})],s=c.concat(o,u);return s}}),ft=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GAstVisitor=void 0;var e=He(),t=(function(){function i(){}return i.prototype.visit=function(r){var a=r;switch(a.constructor){case e.NonTerminal:return this.visitNonTerminal(a);case e.Alternative:return this.visitAlternative(a);case e.Option:return this.visitOption(a);case e.RepetitionMandatory:return this.visitRepetitionMandatory(a);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(a);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(a);case e.Repetition:return this.visitRepetition(a);case e.Alternation:return this.visitAlternation(a);case e.Terminal:return this.visitTerminal(a);case e.Rule:return this.visitRule(a);default:throw Error("non exhaustive match")}},i.prototype.visitNonTerminal=function(r){},i.prototype.visitAlternative=function(r){},i.prototype.visitOption=function(r){},i.prototype.visitRepetition=function(r){},i.prototype.visitRepetitionMandatory=function(r){},i.prototype.visitRepetitionMandatoryWithSeparator=function(r){},i.prototype.visitRepetitionWithSeparator=function(r){},i.prototype.visitAlternation=function(r){},i.prototype.visitTerminal=function(r){},i.prototype.visitRule=function(r){},i})();n.GAstVisitor=t}),Tt=ve(n=>{var e=n&&n.__extends||(function(){var g=function(p,T){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,l){m.__proto__=l}||function(m,l){for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(m[d]=l[d])},g(p,T)};return function(p,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");g(p,T);function m(){this.constructor=p}p.prototype=T===null?Object.create(T):(m.prototype=T.prototype,new m)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.collectMethods=n.DslMethodsCollectorVisitor=n.getProductionDslName=n.isBranchingProd=n.isOptionalProd=n.isSequenceProd=void 0;var t=xe(),i=He(),r=ft();function a(g){return g instanceof i.Alternative||g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionMandatory||g instanceof i.RepetitionMandatoryWithSeparator||g instanceof i.RepetitionWithSeparator||g instanceof i.Terminal||g instanceof i.Rule}n.isSequenceProd=a;function o(g,p){p===void 0&&(p=[]);var T=g instanceof i.Option||g instanceof i.Repetition||g instanceof i.RepetitionWithSeparator;return T?!0:g instanceof i.Alternation?t.some(g.definition,function(m){return o(m,p)}):g instanceof i.NonTerminal&&t.contains(p,g)?!1:g instanceof i.AbstractProduction?(g instanceof i.NonTerminal&&p.push(g),t.every(g.definition,function(m){return o(m,p)})):!1}n.isOptionalProd=o;function u(g){return g instanceof i.Alternation}n.isBranchingProd=u;function c(g){if(g instanceof i.NonTerminal)return"SUBRULE";if(g instanceof i.Option)return"OPTION";if(g instanceof i.Alternation)return"OR";if(g instanceof i.RepetitionMandatory)return"AT_LEAST_ONE";if(g instanceof i.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(g instanceof i.RepetitionWithSeparator)return"MANY_SEP";if(g instanceof i.Repetition)return"MANY";if(g instanceof i.Terminal)return"CONSUME";throw Error("non exhaustive match")}n.getProductionDslName=c;var s=(function(g){e(p,g);function p(){var T=g!==null&&g.apply(this,arguments)||this;return T.separator="-",T.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},T}return p.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},p.prototype.visitTerminal=function(T){var m=T.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitNonTerminal=function(T){var m=T.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,m)||(this.dslMethods[m]=[]),this.dslMethods[m].push(T)},p.prototype.visitOption=function(T){this.dslMethods.option.push(T)},p.prototype.visitRepetitionWithSeparator=function(T){this.dslMethods.repetitionWithSeparator.push(T)},p.prototype.visitRepetitionMandatory=function(T){this.dslMethods.repetitionMandatory.push(T)},p.prototype.visitRepetitionMandatoryWithSeparator=function(T){this.dslMethods.repetitionMandatoryWithSeparator.push(T)},p.prototype.visitRepetition=function(T){this.dslMethods.repetition.push(T)},p.prototype.visitAlternation=function(T){this.dslMethods.alternation.push(T)},p})(r.GAstVisitor);n.DslMethodsCollectorVisitor=s;var f=new s;function h(g){f.reset(),g.accept(f);var p=f.dslMethods;return f.reset(),p}n.collectMethods=h}),bn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.firstForTerminal=n.firstForBranching=n.firstForSequence=n.first=void 0;var e=xe(),t=He(),i=Tt();function r(c){if(c instanceof t.NonTerminal)return r(c.referencedRule);if(c instanceof t.Terminal)return u(c);if(i.isSequenceProd(c))return a(c);if(i.isBranchingProd(c))return o(c);throw Error("non exhaustive match")}n.first=r;function a(c){for(var s=[],f=c.definition,h=0,g=f.length>h,p,T=!0;g&&T;)p=f[h],T=i.isOptionalProd(p),s=s.concat(r(p)),h=h+1,g=f.length>h;return e.uniq(s)}n.firstForSequence=a;function o(c){var s=e.map(c.definition,function(f){return r(f)});return e.uniq(e.flatten(s))}n.firstForBranching=o;function u(c){return[c.terminalType]}n.firstForTerminal=u}),Ln=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IN=void 0,n.IN="_~IN~_"}),ri=ve(n=>{var e=n&&n.__extends||(function(){var h=function(g,p){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,m){T.__proto__=m}||function(T,m){for(var l in m)Object.prototype.hasOwnProperty.call(m,l)&&(T[l]=m[l])},h(g,p)};return function(g,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");h(g,p);function T(){this.constructor=g}g.prototype=p===null?Object.create(p):(T.prototype=p.prototype,new T)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.buildInProdFollowPrefix=n.buildBetweenProdsFollowPrefix=n.computeAllProdsFollows=n.ResyncFollowsWalker=void 0;var t=jt(),i=bn(),r=xe(),a=Ln(),o=He(),u=(function(h){e(g,h);function g(p){var T=h.call(this)||this;return T.topProd=p,T.follows={},T}return g.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},g.prototype.walkTerminal=function(p,T,m){},g.prototype.walkProdRef=function(p,T,m){var l=s(p.referencedRule,p.idx)+this.topProd.name,d=T.concat(m),y=new o.Alternative({definition:d}),v=i.first(y);this.follows[l]=v},g})(t.RestWalker);n.ResyncFollowsWalker=u;function c(h){var g={};return r.forEach(h,function(p){var T=new u(p).startWalking();r.assign(g,T)}),g}n.computeAllProdsFollows=c;function s(h,g){return h.name+g+a.IN}n.buildBetweenProdsFollowPrefix=s;function f(h){var g=h.terminalType.name;return g+h.idx+a.IN}n.buildInProdFollowPrefix=f}),Et=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defaultGrammarValidatorErrorProvider=n.defaultGrammarResolverErrorProvider=n.defaultParserErrorProvider=void 0;var e=nt(),t=xe(),i=xe(),r=He(),a=Tt();n.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var u=o.expected,c=o.actual;o.previous,o.ruleName;var s=e.hasTokenLabel(u),f=s?"--> "+e.tokenLabel(u)+" <--":"token of type --> "+u.name+" <--",h="Expecting "+f+" but found --> '"+c.image+"' <--";return h},buildNotAllInputParsedMessage:function(o){var u=o.firstRedundant;return o.ruleName,"Redundant input, expecting EOF but found: "+u.image},buildNoViableAltMessage:function(o){var u=o.expectedPathsPerAlt,c=o.actual;o.previous;var s=o.customUserDescription;o.ruleName;var f="Expecting: ",h=i.first(c).image,g=`
133
133
  but found: '`+h+"'";if(s)return f+s+g;var p=i.reduce(u,function(d,y){return d.concat(y)},[]),T=i.map(p,function(d){return"["+i.map(d,function(y){return e.tokenLabel(y)}).join(", ")+"]"}),m=i.map(T,function(d,y){return" "+(y+1)+". "+d}),l=`one of these possible Token sequences:
134
134
  `+m.join(`
135
135
  `);return f+l+g},buildEarlyExitMessage:function(o){var u=o.expectedIterationPaths,c=o.actual,s=o.customUserDescription;o.ruleName;var f="Expecting: ",h=i.first(c).image,g=`
@@ -159,20 +159,20 @@ This could lead to an infinite loop.`;return c},buildTokenNameError:function(o){
159
159
  `)+(`without consuming any Tokens. The grammar path that causes this is:
160
160
  `+s+`
161
161
  `)+` To fix this refactor your grammar to remove the left recursion.
162
- see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return f},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var u;o.topLevelRule instanceof r.Rule?u=o.topLevelRule.name:u=o.topLevelRule;var c="Duplicate definition, rule: ->"+u+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return c}}}),ii=ve(n=>{var e=n&&n.__extends||(function(){var u=function(c,s){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,h){f.__proto__=h}||function(f,h){for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(f[g]=h[g])},u(c,s)};return function(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");u(c,s);function f(){this.constructor=c}c.prototype=s===null?Object.create(s):(f.prototype=s.prototype,new f)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.GastRefResolverVisitor=n.resolveGrammar=void 0;var t=Ye(),i=xe(),r=ft();function a(u,c){var s=new o(u,c);return s.resolveRefs(),s.errors}n.resolveGrammar=a;var o=(function(u){e(c,u);function c(s,f){var h=u.call(this)||this;return h.nameToTopRule=s,h.errMsgProvider=f,h.errors=[],h}return c.prototype.resolveRefs=function(){var s=this;i.forEach(i.values(this.nameToTopRule),function(f){s.currTopLevel=f,f.accept(s)})},c.prototype.visitNonTerminal=function(s){var f=this.nameToTopRule[s.nonTerminalName];if(f)s.referencedRule=f;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,s);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:s.nonTerminalName})}},c})(r.GAstVisitor);n.GastRefResolverVisitor=o}),vt=ve(n=>{var e=n&&n.__extends||(function(){var l=function(d,y){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,E){v.__proto__=E}||function(v,E){for(var S in E)Object.prototype.hasOwnProperty.call(E,S)&&(v[S]=E[S])},l(d,y)};return function(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");l(d,y);function v(){this.constructor=d}d.prototype=y===null?Object.create(y):(v.prototype=y.prototype,new v)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.nextPossibleTokensAfter=n.possiblePathsFrom=n.NextTerminalAfterAtLeastOneSepWalker=n.NextTerminalAfterAtLeastOneWalker=n.NextTerminalAfterManySepWalker=n.NextTerminalAfterManyWalker=n.AbstractNextTerminalAfterProductionWalker=n.NextAfterTokenWalker=n.AbstractNextPossibleTokensWalker=void 0;var t=Bt(),i=xe(),r=bn(),a=He(),o=(function(l){e(d,l);function d(y,v){var E=l.call(this)||this;return E.topProd=y,E.path=v,E.possibleTokTypes=[],E.nextProductionName="",E.nextProductionOccurrence=0,E.found=!1,E.isAtEndOfPath=!1,E}return d.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=i.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=i.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},d.prototype.walk=function(y,v){v===void 0&&(v=[]),this.found||l.prototype.walk.call(this,y,v)},d.prototype.walkProdRef=function(y,v,E){if(y.referencedRule.name===this.nextProductionName&&y.idx===this.nextProductionOccurrence){var S=v.concat(E);this.updateExpectedNext(),this.walk(y.referencedRule,S)}},d.prototype.updateExpectedNext=function(){i.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},d})(t.RestWalker);n.AbstractNextPossibleTokensWalker=o;var u=(function(l){e(d,l);function d(y,v){var E=l.call(this,y,v)||this;return E.path=v,E.nextTerminalName="",E.nextTerminalOccurrence=0,E.nextTerminalName=E.path.lastTok.name,E.nextTerminalOccurrence=E.path.lastTokOccurrence,E}return d.prototype.walkTerminal=function(y,v,E){if(this.isAtEndOfPath&&y.terminalType.name===this.nextTerminalName&&y.idx===this.nextTerminalOccurrence&&!this.found){var S=v.concat(E),I=new a.Alternative({definition:S});this.possibleTokTypes=r.first(I),this.found=!0}},d})(o);n.NextAfterTokenWalker=u;var c=(function(l){e(d,l);function d(y,v){var E=l.call(this)||this;return E.topRule=y,E.occurrence=v,E.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},E}return d.prototype.startWalking=function(){return this.walk(this.topRule),this.result},d})(t.RestWalker);n.AbstractNextTerminalAfterProductionWalker=c;var s=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkMany=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkMany.call(this,y,v,E)},d})(c);n.NextTerminalAfterManyWalker=s;var f=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkManySep=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkManySep.call(this,y,v,E)},d})(c);n.NextTerminalAfterManySepWalker=f;var h=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOne=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOne.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneWalker=h;var g=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOneSep=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOneSep.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneSepWalker=g;function p(l,d,y){y===void 0&&(y=[]),y=i.cloneArr(y);var v=[],E=0;function S(x){return x.concat(i.drop(l,E+1))}function I(x){var B=p(S(x),d,y);return v.concat(B)}for(;y.length<d&&E<l.length;){var k=l[E];if(k instanceof a.Alternative||k instanceof a.NonTerminal)return I(k.definition);if(k instanceof a.Option)v=I(k.definition);else if(k instanceof a.RepetitionMandatory){var H=k.definition.concat([new a.Repetition({definition:k.definition})]);return I(H)}else if(k instanceof a.RepetitionMandatoryWithSeparator){var H=[new a.Alternative({definition:k.definition}),new a.Repetition({definition:[new a.Terminal({terminalType:k.separator})].concat(k.definition)})];return I(H)}else if(k instanceof a.RepetitionWithSeparator){var H=k.definition.concat([new a.Repetition({definition:[new a.Terminal({terminalType:k.separator})].concat(k.definition)})]);v=I(H)}else if(k instanceof a.Repetition){var H=k.definition.concat([new a.Repetition({definition:k.definition})]);v=I(H)}else{if(k instanceof a.Alternation)return i.forEach(k.definition,function(x){i.isEmpty(x.definition)===!1&&(v=I(x.definition))}),v;if(k instanceof a.Terminal)y.push(k.terminalType);else throw Error("non exhaustive match")}E++}return v.push({partialPath:y,suffixDef:i.drop(l,E)}),v}n.possiblePathsFrom=p;function T(l,d,y,v){var E="EXIT_NONE_TERMINAL",S=[E],I="EXIT_ALTERNATIVE",k=!1,H=d.length,x=H-v-1,B=[],P=[];for(P.push({idx:-1,def:l,ruleStack:[],occurrenceStack:[]});!i.isEmpty(P);){var O=P.pop();if(O===I){k&&i.last(P).idx<=x&&P.pop();continue}var M=O.def,C=O.idx,X=O.ruleStack,Q=O.occurrenceStack;if(!i.isEmpty(M)){var W=M[0];if(W===E){var $={idx:C,def:i.drop(M),ruleStack:i.dropRight(X),occurrenceStack:i.dropRight(Q)};P.push($)}else if(W instanceof a.Terminal)if(C<H-1){var te=C+1,ce=d[te];if(y(ce,W.terminalType)){var $={idx:te,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push($)}}else if(C===H-1)B.push({nextTokenType:W.terminalType,nextTokenOccurrence:W.idx,ruleStack:X,occurrenceStack:Q}),k=!0;else throw Error("non exhaustive match");else if(W instanceof a.NonTerminal){var ae=i.cloneArr(X);ae.push(W.nonTerminalName);var le=i.cloneArr(Q);le.push(W.idx);var $={idx:C,def:W.definition.concat(S,i.drop(M)),ruleStack:ae,occurrenceStack:le};P.push($)}else if(W instanceof a.Option){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var pe={idx:C,def:W.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.RepetitionMandatory){var U=new a.Repetition({definition:W.definition,idx:W.idx}),G=W.definition.concat([U],i.drop(M)),$={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push($)}else if(W instanceof a.RepetitionMandatoryWithSeparator){var K=new a.Terminal({terminalType:W.separator}),U=new a.Repetition({definition:[K].concat(W.definition),idx:W.idx}),G=W.definition.concat([U],i.drop(M)),$={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push($)}else if(W instanceof a.RepetitionWithSeparator){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var K=new a.Terminal({terminalType:W.separator}),q=new a.Repetition({definition:[K].concat(W.definition),idx:W.idx}),G=W.definition.concat([q],i.drop(M)),pe={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.Repetition){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var q=new a.Repetition({definition:W.definition,idx:W.idx}),G=W.definition.concat([q],i.drop(M)),pe={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.Alternation)for(var J=W.definition.length-1;J>=0;J--){var ie=W.definition[J],Te={idx:C,def:ie.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q};P.push(Te),P.push(I)}else if(W instanceof a.Alternative)P.push({idx:C,def:W.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q});else if(W instanceof a.Rule)P.push(m(W,C,X,Q));else throw Error("non exhaustive match")}}return B}n.nextPossibleTokensAfter=T;function m(l,d,y,v){var E=i.cloneArr(y);E.push(l.name);var S=i.cloneArr(v);return S.push(1),{idx:d,def:l.definition,ruleStack:E,occurrenceStack:S}}}),Rt=ve(n=>{var e=n&&n.__extends||(function(){var x=function(B,P){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var C in M)Object.prototype.hasOwnProperty.call(M,C)&&(O[C]=M[C])},x(B,P)};return function(B,P){if(typeof P!="function"&&P!==null)throw new TypeError("Class extends value "+String(P)+" is not a constructor or null");x(B,P);function O(){this.constructor=B}B.prototype=P===null?Object.create(P):(O.prototype=P.prototype,new O)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.areTokenCategoriesNotUsed=n.isStrictPrefixOfPath=n.containsPath=n.getLookaheadPathsForOptionalProd=n.getLookaheadPathsForOr=n.lookAheadSequenceFromAlternatives=n.buildSingleAlternativeLookaheadFunction=n.buildAlternativesLookAheadFunc=n.buildLookaheadFuncForOptionalProd=n.buildLookaheadFuncForOr=n.getProdType=n.PROD_TYPE=void 0;var t=xe(),i=vt(),r=Bt(),a=ht(),o=He(),u=ft(),c;(function(x){x[x.OPTION=0]="OPTION",x[x.REPETITION=1]="REPETITION",x[x.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",x[x.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",x[x.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",x[x.ALTERNATION=5]="ALTERNATION"})(c=n.PROD_TYPE||(n.PROD_TYPE={}));function s(x){if(x instanceof o.Option)return c.OPTION;if(x instanceof o.Repetition)return c.REPETITION;if(x instanceof o.RepetitionMandatory)return c.REPETITION_MANDATORY;if(x instanceof o.RepetitionMandatoryWithSeparator)return c.REPETITION_MANDATORY_WITH_SEPARATOR;if(x instanceof o.RepetitionWithSeparator)return c.REPETITION_WITH_SEPARATOR;if(x instanceof o.Alternation)return c.ALTERNATION;throw Error("non exhaustive match")}n.getProdType=s;function f(x,B,P,O,M,C){var X=E(x,B,P),Q=H(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return C(X,O,Q,M)}n.buildLookaheadFuncForOr=f;function h(x,B,P,O,M,C){var X=S(x,B,M,P),Q=H(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return C(X[0],Q,O)}n.buildLookaheadFuncForOptionalProd=h;function g(x,B,P,O){var M=x.length,C=t.every(x,function(W){return t.every(W,function($){return $.length===1})});if(B)return function(W){for(var $=t.map(W,function(q){return q.GATE}),te=0;te<M;te++){var ce=x[te],ae=ce.length,le=$[te];if(!(le!==void 0&&le.call(this)===!1))e:for(var ne=0;ne<ae;ne++){for(var pe=ce[ne],U=pe.length,G=0;G<U;G++){var K=this.LA(G+1);if(P(K,pe[G])===!1)continue e}return te}}};if(C&&!O){var X=t.map(x,function(W){return t.flatten(W)}),Q=t.reduce(X,function(W,$,te){return t.forEach($,function(ce){t.has(W,ce.tokenTypeIdx)||(W[ce.tokenTypeIdx]=te),t.forEach(ce.categoryMatches,function(ae){t.has(W,ae)||(W[ae]=te)})}),W},[]);return function(){var W=this.LA(1);return Q[W.tokenTypeIdx]}}else return function(){for(var W=0;W<M;W++){var $=x[W],te=$.length;e:for(var ce=0;ce<te;ce++){for(var ae=$[ce],le=ae.length,ne=0;ne<le;ne++){var pe=this.LA(ne+1);if(P(pe,ae[ne])===!1)continue e}return W}}}}n.buildAlternativesLookAheadFunc=g;function p(x,B,P){var O=t.every(x,function($){return $.length===1}),M=x.length;if(O&&!P){var C=t.flatten(x);if(C.length===1&&t.isEmpty(C[0].categoryMatches)){var X=C[0],Q=X.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===Q}}else{var W=t.reduce(C,function($,te,ce){return $[te.tokenTypeIdx]=!0,t.forEach(te.categoryMatches,function(ae){$[ae]=!0}),$},[]);return function(){var $=this.LA(1);return W[$.tokenTypeIdx]===!0}}}else return function(){e:for(var $=0;$<M;$++){for(var te=x[$],ce=te.length,ae=0;ae<ce;ae++){var le=this.LA(ae+1);if(B(le,te[ae])===!1)continue e}return!0}return!1}}n.buildSingleAlternativeLookaheadFunction=p;var T=(function(x){e(B,x);function B(P,O,M){var C=x.call(this)||this;return C.topProd=P,C.targetOccurrence=O,C.targetProdType=M,C}return B.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},B.prototype.checkIsTarget=function(P,O,M,C){return P.idx===this.targetOccurrence&&this.targetProdType===O?(this.restDef=M.concat(C),!0):!1},B.prototype.walkOption=function(P,O,M){this.checkIsTarget(P,c.OPTION,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkAtLeastOne=function(P,O,M){this.checkIsTarget(P,c.REPETITION_MANDATORY,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkAtLeastOneSep=function(P,O,M){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkMany=function(P,O,M){this.checkIsTarget(P,c.REPETITION,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkManySep=function(P,O,M){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR,O,M)||x.prototype.walkOption.call(this,P,O,M)},B})(r.RestWalker),m=(function(x){e(B,x);function B(P,O,M){var C=x.call(this)||this;return C.targetOccurrence=P,C.targetProdType=O,C.targetRef=M,C.result=[],C}return B.prototype.checkIsTarget=function(P,O){P.idx===this.targetOccurrence&&this.targetProdType===O&&(this.targetRef===void 0||P===this.targetRef)&&(this.result=P.definition)},B.prototype.visitOption=function(P){this.checkIsTarget(P,c.OPTION)},B.prototype.visitRepetition=function(P){this.checkIsTarget(P,c.REPETITION)},B.prototype.visitRepetitionMandatory=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY)},B.prototype.visitRepetitionMandatoryWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR)},B.prototype.visitRepetitionWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR)},B.prototype.visitAlternation=function(P){this.checkIsTarget(P,c.ALTERNATION)},B})(u.GAstVisitor);function l(x){for(var B=new Array(x),P=0;P<x;P++)B[P]=[];return B}function d(x){for(var B=[""],P=0;P<x.length;P++){for(var O=x[P],M=[],C=0;C<B.length;C++){var X=B[C];M.push(X+"_"+O.tokenTypeIdx);for(var Q=0;Q<O.categoryMatches.length;Q++){var W="_"+O.categoryMatches[Q];M.push(X+W)}}B=M}return B}function y(x,B,P){for(var O=0;O<x.length;O++)if(O!==P)for(var M=x[O],C=0;C<B.length;C++){var X=B[C];if(M[X]===!0)return!1}return!0}function v(x,B){for(var P=t.map(x,function(te){return i.possiblePathsFrom([te],1)}),O=l(P.length),M=t.map(P,function(te){var ce={};return t.forEach(te,function(ae){var le=d(ae.partialPath);t.forEach(le,function(ne){ce[ne]=!0})}),ce}),C=P,X=1;X<=B;X++){var Q=C;C=l(Q.length);for(var W=function(te){for(var ce=Q[te],ae=0;ae<ce.length;ae++){var le=ce[ae].partialPath,ne=ce[ae].suffixDef,pe=d(le),U=y(M,pe,te);if(U||t.isEmpty(ne)||le.length===B){var G=O[te];if(I(G,le)===!1){G.push(le);for(var K=0;K<pe.length;K++){var q=pe[K];M[te][q]=!0}}}else{var J=i.possiblePathsFrom(ne,X+1,le);C[te]=C[te].concat(J),t.forEach(J,function(ie){var Te=d(ie.partialPath);t.forEach(Te,function(ye){M[te][ye]=!0})})}}},$=0;$<Q.length;$++)W($)}return O}n.lookAheadSequenceFromAlternatives=v;function E(x,B,P,O){var M=new m(x,c.ALTERNATION,O);return B.accept(M),v(M.result,P)}n.getLookaheadPathsForOr=E;function S(x,B,P,O){var M=new m(x,P);B.accept(M);var C=M.result,X=new T(B,x,P),Q=X.startWalking(),W=new o.Alternative({definition:C}),$=new o.Alternative({definition:Q});return v([W,$],O)}n.getLookaheadPathsForOptionalProd=S;function I(x,B){e:for(var P=0;P<x.length;P++){var O=x[P];if(O.length===B.length){for(var M=0;M<O.length;M++){var C=B[M],X=O[M],Q=C===X||X.categoryMatchesMap[C.tokenTypeIdx]!==void 0;if(Q===!1)continue e}return!0}}return!1}n.containsPath=I;function k(x,B){return x.length<B.length&&t.every(x,function(P,O){var M=B[O];return P===M||M.categoryMatchesMap[P.tokenTypeIdx]})}n.isStrictPrefixOfPath=k;function H(x){return t.every(x,function(B){return t.every(B,function(P){return t.every(P,function(O){return t.isEmpty(O.categoryMatches)})})})}n.areTokenCategoriesNotUsed=H}),Sn=ve(n=>{var e=n&&n.__extends||(function(){var O=function(M,C){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(X,Q){X.__proto__=Q}||function(X,Q){for(var W in Q)Object.prototype.hasOwnProperty.call(Q,W)&&(X[W]=Q[W])},O(M,C)};return function(M,C){if(typeof C!="function"&&C!==null)throw new TypeError("Class extends value "+String(C)+" is not a constructor or null");O(M,C);function X(){this.constructor=M}M.prototype=C===null?Object.create(C):(X.prototype=C.prototype,new X)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.checkPrefixAlternativesAmbiguities=n.validateSomeNonEmptyLookaheadPath=n.validateTooManyAlts=n.RepetionCollector=n.validateAmbiguousAlternationAlternatives=n.validateEmptyOrAlternative=n.getFirstNoneTerminal=n.validateNoLeftRecursion=n.validateRuleIsOverridden=n.validateRuleDoesNotAlreadyExist=n.OccurrenceValidationCollector=n.identifyProductionForDuplicates=n.validateGrammar=void 0;var t=xe(),i=xe(),r=Ye(),a=Tt(),o=Rt(),u=vt(),c=He(),s=ft();function f(O,M,C,X,Q){var W=t.map(O,function(U){return h(U,X)}),$=t.map(O,function(U){return d(U,U,X)}),te=[],ce=[],ae=[];i.every($,i.isEmpty)&&(te=i.map(O,function(U){return E(U,X)}),ce=i.map(O,function(U){return S(U,M,X)}),ae=H(O,M,X));var le=P(O,C,X),ne=i.map(O,function(U){return k(U,X)}),pe=i.map(O,function(U){return m(U,O,Q,X)});return t.flatten(W.concat(ae,$,te,ce,le,ne,pe))}n.validateGrammar=f;function h(O,M){var C=new T;O.accept(C);var X=C.allProductions,Q=t.groupBy(X,g),W=t.pick(Q,function(te){return te.length>1}),$=t.map(t.values(W),function(te){var ce=t.first(te),ae=M.buildDuplicateFoundError(O,te),le=a.getProductionDslName(ce),ne={message:ae,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:O.name,dslName:le,occurrence:ce.idx},pe=p(ce);return pe&&(ne.parameter=pe),ne});return $}function g(O){return a.getProductionDslName(O)+"_#_"+O.idx+"_#_"+p(O)}n.identifyProductionForDuplicates=g;function p(O){return O instanceof c.Terminal?O.terminalType.name:O instanceof c.NonTerminal?O.nonTerminalName:""}var T=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.allProductions=[],C}return M.prototype.visitNonTerminal=function(C){this.allProductions.push(C)},M.prototype.visitOption=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatory=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatoryWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetition=function(C){this.allProductions.push(C)},M.prototype.visitAlternation=function(C){this.allProductions.push(C)},M.prototype.visitTerminal=function(C){this.allProductions.push(C)},M})(s.GAstVisitor);n.OccurrenceValidationCollector=T;function m(O,M,C,X){var Q=[],W=i.reduce(M,function(te,ce){return ce.name===O.name?te+1:te},0);if(W>1){var $=X.buildDuplicateRuleNameError({topLevelRule:O,grammarName:C});Q.push({message:$,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:O.name})}return Q}n.validateRuleDoesNotAlreadyExist=m;function l(O,M,C){var X=[],Q;return t.contains(M,O)||(Q="Invalid rule override, rule: ->"+O+"<- cannot be overridden in the grammar: ->"+C+"<-as it is not defined in any of the super grammars ",X.push({message:Q,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:O})),X}n.validateRuleIsOverridden=l;function d(O,M,C,X){X===void 0&&(X=[]);var Q=[],W=y(M.definition);if(t.isEmpty(W))return[];var $=O.name,te=t.contains(W,O);te&&Q.push({message:C.buildLeftRecursionError({topLevelRule:O,leftRecursionPath:X}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:$});var ce=t.difference(W,X.concat([O])),ae=t.map(ce,function(le){var ne=t.cloneArr(X);return ne.push(le),d(O,le,C,ne)});return Q.concat(t.flatten(ae))}n.validateNoLeftRecursion=d;function y(O){var M=[];if(t.isEmpty(O))return M;var C=t.first(O);if(C instanceof c.NonTerminal)M.push(C.referencedRule);else if(C instanceof c.Alternative||C instanceof c.Option||C instanceof c.RepetitionMandatory||C instanceof c.RepetitionMandatoryWithSeparator||C instanceof c.RepetitionWithSeparator||C instanceof c.Repetition)M=M.concat(y(C.definition));else if(C instanceof c.Alternation)M=t.flatten(t.map(C.definition,function($){return y($.definition)}));else if(!(C instanceof c.Terminal))throw Error("non exhaustive match");var X=a.isOptionalProd(C),Q=O.length>1;if(X&&Q){var W=t.drop(O);return M.concat(y(W))}else return M}n.getFirstNoneTerminal=y;var v=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.alternations=[],C}return M.prototype.visitAlternation=function(C){this.alternations.push(C)},M})(s.GAstVisitor);function E(O,M){var C=new v;O.accept(C);var X=C.alternations,Q=t.reduce(X,function(W,$){var te=t.dropRight($.definition),ce=t.map(te,function(ae,le){var ne=u.nextPossibleTokensAfter([ae],[],null,1);return t.isEmpty(ne)?{message:M.buildEmptyAlternationError({topLevelRule:O,alternation:$,emptyChoiceIdx:le}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:O.name,occurrence:$.idx,alternative:le+1}:null});return W.concat(t.compact(ce))},[]);return Q}n.validateEmptyOrAlternative=E;function S(O,M,C){var X=new v;O.accept(X);var Q=X.alternations;Q=i.reject(Q,function($){return $.ignoreAmbiguities===!0});var W=t.reduce(Q,function($,te){var ce=te.idx,ae=te.maxLookahead||M,le=o.getLookaheadPathsForOr(ce,O,ae,te),ne=x(le,te,O,C),pe=B(le,te,O,C);return $.concat(ne,pe)},[]);return W}n.validateAmbiguousAlternationAlternatives=S;var I=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.allProductions=[],C}return M.prototype.visitRepetitionWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatory=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatoryWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetition=function(C){this.allProductions.push(C)},M})(s.GAstVisitor);n.RepetionCollector=I;function k(O,M){var C=new v;O.accept(C);var X=C.alternations,Q=t.reduce(X,function(W,$){return $.definition.length>255&&W.push({message:M.buildTooManyAlternativesError({topLevelRule:O,alternation:$}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:O.name,occurrence:$.idx}),W},[]);return Q}n.validateTooManyAlts=k;function H(O,M,C){var X=[];return i.forEach(O,function(Q){var W=new I;Q.accept(W);var $=W.allProductions;i.forEach($,function(te){var ce=o.getProdType(te),ae=te.maxLookahead||M,le=te.idx,ne=o.getLookaheadPathsForOptionalProd(le,Q,ce,ae),pe=ne[0];if(i.isEmpty(i.flatten(pe))){var U=C.buildEmptyRepetitionError({topLevelRule:Q,repetition:te});X.push({message:U,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:Q.name})}})}),X}n.validateSomeNonEmptyLookaheadPath=H;function x(O,M,C,X){var Q=[],W=i.reduce(O,function(te,ce,ae){return M.definition[ae].ignoreAmbiguities===!0||i.forEach(ce,function(le){var ne=[ae];i.forEach(O,function(pe,U){ae!==U&&o.containsPath(pe,le)&&M.definition[U].ignoreAmbiguities!==!0&&ne.push(U)}),ne.length>1&&!o.containsPath(Q,le)&&(Q.push(le),te.push({alts:ne,path:le}))}),te},[]),$=t.map(W,function(te){var ce=i.map(te.alts,function(le){return le+1}),ae=X.buildAlternationAmbiguityError({topLevelRule:C,alternation:M,ambiguityIndices:ce,prefixPath:te.path});return{message:ae,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:C.name,occurrence:M.idx,alternatives:[te.alts]}});return $}function B(O,M,C,X){var Q=[],W=i.reduce(O,function($,te,ce){var ae=i.map(te,function(le){return{idx:ce,path:le}});return $.concat(ae)},[]);return i.forEach(W,function($){var te=M.definition[$.idx];if(te.ignoreAmbiguities!==!0){var ce=$.idx,ae=$.path,le=i.findAll(W,function(pe){return M.definition[pe.idx].ignoreAmbiguities!==!0&&pe.idx<ce&&o.isStrictPrefixOfPath(pe.path,ae)}),ne=i.map(le,function(pe){var U=[pe.idx+1,ce+1],G=M.idx===0?"":M.idx,K=X.buildAlternationPrefixAmbiguityError({topLevelRule:C,alternation:M,ambiguityIndices:U,prefixPath:pe.path});return{message:K,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:C.name,occurrence:G,alternatives:U}});Q=Q.concat(ne)}}),Q}n.checkPrefixAlternativesAmbiguities=B;function P(O,M,C){var X=[],Q=i.map(M,function(W){return W.name});return i.forEach(O,function(W){var $=W.name;if(i.contains(Q,$)){var te=C.buildNamespaceConflictError(W);X.push({message:te,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:$})}}),X}}),oi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateGrammar=n.resolveGrammar=void 0;var e=xe(),t=ii(),i=Sn(),r=Et();function a(u){u=e.defaults(u,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var c={};return e.forEach(u.rules,function(s){c[s.name]=s}),t.resolveGrammar(c,u.errMsgProvider)}n.resolveGrammar=a;function o(u){return u=e.defaults(u,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),i.validateGrammar(u.rules,u.maxLookahead,u.tokenTypes,u.errMsgProvider,u.grammarName)}n.validateGrammar=o}),dt=ve(n=>{var e=n&&n.__extends||(function(){var T=function(m,l){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,y){d.__proto__=y}||function(d,y){for(var v in y)Object.prototype.hasOwnProperty.call(y,v)&&(d[v]=y[v])},T(m,l)};return function(m,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");T(m,l);function d(){this.constructor=m}m.prototype=l===null?Object.create(l):(d.prototype=l.prototype,new d)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.EarlyExitException=n.NotAllInputParsedException=n.NoViableAltException=n.MismatchedTokenException=n.isRecognitionException=void 0;var t=xe(),i="MismatchedTokenException",r="NoViableAltException",a="EarlyExitException",o="NotAllInputParsedException",u=[i,r,a,o];Object.freeze(u);function c(T){return t.contains(u,T.name)}n.isRecognitionException=c;var s=(function(T){e(m,T);function m(l,d){var y=this.constructor,v=T.call(this,l)||this;return v.token=d,v.resyncedTokens=[],Object.setPrototypeOf(v,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(v,v.constructor),v}return m})(Error),f=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=i,v}return m})(s);n.MismatchedTokenException=f;var h=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=r,v}return m})(s);n.NoViableAltException=h;var g=(function(T){e(m,T);function m(l,d){var y=T.call(this,l,d)||this;return y.name=o,y}return m})(s);n.NotAllInputParsedException=g;var p=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=a,v}return m})(s);n.EarlyExitException=p}),On=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.attemptInRepetitionRecovery=n.Recoverable=n.InRuleRecoveryException=n.IN_RULE_RECOVERY_EXCEPTION=n.EOF_FOLLOW_KEY=void 0;var e=nt(),t=xe(),i=dt(),r=Ln(),a=Ye();n.EOF_FOLLOW_KEY={},n.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(s){this.name=n.IN_RULE_RECOVERY_EXCEPTION,this.message=s}n.InRuleRecoveryException=o,o.prototype=Error.prototype;var u=(function(){function s(){}return s.prototype.initRecoverable=function(f){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(f,"recoveryEnabled")?f.recoveryEnabled:a.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},s.prototype.getTokenToInsert=function(f){var h=e.createTokenInstance(f,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},s.prototype.canTokenTypeBeInsertedInRecovery=function(f){return!0},s.prototype.tryInRepetitionRecovery=function(f,h,g,p){for(var T=this,m=this.findReSyncTokenType(),l=this.exportLexerState(),d=[],y=!1,v=this.LA(1),E=this.LA(1),S=function(){var I=T.LA(0),k=T.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:v,previous:I,ruleName:T.getCurrRuleFullName()}),H=new i.MismatchedTokenException(k,v,T.LA(0));H.resyncedTokens=t.dropRight(d),T.SAVE_ERROR(H)};!y;)if(this.tokenMatcher(E,p)){S();return}else if(g.call(this)){S(),f.apply(this,h);return}else this.tokenMatcher(E,m)?y=!0:(E=this.SKIP_TOKEN(),this.addToResyncTokens(E,d));this.importLexerState(l)},s.prototype.shouldInRepetitionRecoveryBeTried=function(f,h,g){return!(g===!1||f===void 0||h===void 0||this.tokenMatcher(this.LA(1),f)||this.isBackTracking()||this.canPerformInRuleRecovery(f,this.getFollowsForInRuleRecovery(f,h)))},s.prototype.getFollowsForInRuleRecovery=function(f,h){var g=this.getCurrentGrammarPath(f,h),p=this.getNextPossibleTokenTypes(g);return p},s.prototype.tryInRuleRecovery=function(f,h){if(this.canRecoverWithSingleTokenInsertion(f,h)){var g=this.getTokenToInsert(f);return g}if(this.canRecoverWithSingleTokenDeletion(f)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},s.prototype.canPerformInRuleRecovery=function(f,h){return this.canRecoverWithSingleTokenInsertion(f,h)||this.canRecoverWithSingleTokenDeletion(f)},s.prototype.canRecoverWithSingleTokenInsertion=function(f,h){var g=this;if(!this.canTokenTypeBeInsertedInRecovery(f)||t.isEmpty(h))return!1;var p=this.LA(1),T=t.find(h,function(m){return g.tokenMatcher(p,m)})!==void 0;return T},s.prototype.canRecoverWithSingleTokenDeletion=function(f){var h=this.tokenMatcher(this.LA(2),f);return h},s.prototype.isInCurrentRuleReSyncSet=function(f){var h=this.getCurrFollowKey(),g=this.getFollowSetFromFollowKey(h);return t.contains(g,f)},s.prototype.findReSyncTokenType=function(){for(var f=this.flattenFollowSet(),h=this.LA(1),g=2;;){var p=h.tokenType;if(t.contains(f,p))return p;h=this.LA(g),g++}},s.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return n.EOF_FOLLOW_KEY;var f=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),g=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(f),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(g)}},s.prototype.buildFullFollowKeyStack=function(){var f=this,h=this.RULE_STACK,g=this.RULE_OCCURRENCE_STACK;return t.map(h,function(p,T){return T===0?n.EOF_FOLLOW_KEY:{ruleName:f.shortRuleNameToFullName(p),idxInCallingRule:g[T],inRule:f.shortRuleNameToFullName(h[T-1])}})},s.prototype.flattenFollowSet=function(){var f=this,h=t.map(this.buildFullFollowKeyStack(),function(g){return f.getFollowSetFromFollowKey(g)});return t.flatten(h)},s.prototype.getFollowSetFromFollowKey=function(f){if(f===n.EOF_FOLLOW_KEY)return[e.EOF];var h=f.ruleName+f.idxInCallingRule+r.IN+f.inRule;return this.resyncFollows[h]},s.prototype.addToResyncTokens=function(f,h){return this.tokenMatcher(f,e.EOF)||h.push(f),h},s.prototype.reSyncTo=function(f){for(var h=[],g=this.LA(1);this.tokenMatcher(g,f)===!1;)g=this.SKIP_TOKEN(),this.addToResyncTokens(g,h);return t.dropRight(h)},s.prototype.attemptInRepetitionRecovery=function(f,h,g,p,T,m,l){},s.prototype.getCurrentGrammarPath=function(f,h){var g=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),T={ruleStack:g,occurrenceStack:p,lastTok:f,lastTokOccurrence:h};return T},s.prototype.getHumanReadableRuleStack=function(){var f=this;return t.map(this.RULE_STACK,function(h){return f.shortRuleNameToFullName(h)})},s})();n.Recoverable=u;function c(s,f,h,g,p,T,m){var l=this.getKeyForAutomaticLookahead(g,p),d=this.firstAfterRepMap[l];if(d===void 0){var y=this.getCurrRuleFullName(),v=this.getGAstProductions()[y],E=new T(v,p);d=E.startWalking(),this.firstAfterRepMap[l]=d}var S=d.token,I=d.occurrence,k=d.isEndOfRule;this.RULE_STACK.length===1&&k&&S===void 0&&(S=e.EOF,I=1),this.shouldInRepetitionRecoveryBeTried(S,I,m)&&this.tryInRepetitionRecovery(s,f,h,S)}n.attemptInRepetitionRecovery=c}),Gt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getKeyForAutomaticLookahead=n.AT_LEAST_ONE_SEP_IDX=n.MANY_SEP_IDX=n.AT_LEAST_ONE_IDX=n.MANY_IDX=n.OPTION_IDX=n.OR_IDX=n.BITS_FOR_ALT_IDX=n.BITS_FOR_RULE_IDX=n.BITS_FOR_OCCURRENCE_IDX=n.BITS_FOR_METHOD_TYPE=void 0,n.BITS_FOR_METHOD_TYPE=4,n.BITS_FOR_OCCURRENCE_IDX=8,n.BITS_FOR_RULE_IDX=12,n.BITS_FOR_ALT_IDX=8,n.OR_IDX=1<<n.BITS_FOR_OCCURRENCE_IDX,n.OPTION_IDX=2<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_IDX=3<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_IDX=4<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_SEP_IDX=5<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_SEP_IDX=6<<n.BITS_FOR_OCCURRENCE_IDX;function e(t,i,r){return r|i|t}n.getKeyForAutomaticLookahead=e,32-n.BITS_FOR_ALT_IDX}),si=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LooksAhead=void 0;var e=Rt(),t=xe(),i=Ye(),r=Gt(),a=Tt(),o=(function(){function u(){}return u.prototype.initLooksAhead=function(c){this.dynamicTokensEnabled=t.has(c,"dynamicTokensEnabled")?c.dynamicTokensEnabled:i.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(c,"maxLookahead")?c.maxLookahead:i.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},u.prototype.preComputeLookaheadFunctions=function(c){var s=this;t.forEach(c,function(f){s.TRACE_INIT(f.name+" Rule Lookahead",function(){var h=a.collectMethods(f),g=h.alternation,p=h.repetition,T=h.option,m=h.repetitionMandatory,l=h.repetitionMandatoryWithSeparator,d=h.repetitionWithSeparator;t.forEach(g,function(y){var v=y.idx===0?"":y.idx;s.TRACE_INIT(""+a.getProductionDslName(y)+v,function(){var E=e.buildLookaheadFuncForOr(y.idx,f,y.maxLookahead||s.maxLookahead,y.hasPredicates,s.dynamicTokensEnabled,s.lookAheadBuilderForAlternatives),S=r.getKeyForAutomaticLookahead(s.fullRuleNameToShort[f.name],r.OR_IDX,y.idx);s.setLaFuncCache(S,E)})}),t.forEach(p,function(y){s.computeLookaheadFunc(f,y.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(T,function(y){s.computeLookaheadFunc(f,y.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(m,function(y){s.computeLookaheadFunc(f,y.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(l,function(y){s.computeLookaheadFunc(f,y.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(d,function(y){s.computeLookaheadFunc(f,y.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))})})})},u.prototype.computeLookaheadFunc=function(c,s,f,h,g,p){var T=this;this.TRACE_INIT(""+p+(s===0?"":s),function(){var m=e.buildLookaheadFuncForOptionalProd(s,c,g||T.maxLookahead,T.dynamicTokensEnabled,h,T.lookAheadBuilderForOptional),l=r.getKeyForAutomaticLookahead(T.fullRuleNameToShort[c.name],f,s);T.setLaFuncCache(l,m)})},u.prototype.lookAheadBuilderForOptional=function(c,s,f){return e.buildSingleAlternativeLookaheadFunction(c,s,f)},u.prototype.lookAheadBuilderForAlternatives=function(c,s,f,h){return e.buildAlternativesLookAheadFunc(c,s,f,h)},u.prototype.getKeyForAutomaticLookahead=function(c,s){var f=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(f,c,s)},u.prototype.getLaFuncFromCache=function(c){},u.prototype.getLaFuncFromMap=function(c){return this.lookAheadFuncsCache.get(c)},u.prototype.getLaFuncFromObj=function(c){return this.lookAheadFuncsCache[c]},u.prototype.setLaFuncCache=function(c,s){},u.prototype.setLaFuncCacheUsingMap=function(c,s){this.lookAheadFuncsCache.set(c,s)},u.prototype.setLaFuncUsingObj=function(c,s){this.lookAheadFuncsCache[c]=s},u})();n.LooksAhead=o}),ai=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addNoneTerminalToCst=n.addTerminalToCst=n.setNodeLocationFull=n.setNodeLocationOnlyOffset=void 0;function e(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.endOffset=o.endOffset):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset)}n.setNodeLocationOnlyOffset=e;function t(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.startColumn=o.startColumn,a.startLine=o.startLine,a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine)}n.setNodeLocationFull=t;function i(a,o,u){a.children[u]===void 0?a.children[u]=[o]:a.children[u].push(o)}n.addTerminalToCst=i;function r(a,o,u){a.children[o]===void 0?a.children[o]=[u]:a.children[o].push(u)}n.addNoneTerminalToCst=r}),xn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defineNameProp=n.functionName=n.classNameFromInstance=void 0;var e=xe();function t(o){return r(o.constructor)}n.classNameFromInstance=t;var i="name";function r(o){var u=o.name;return u||"anonymous"}n.functionName=r;function a(o,u){var c=Object.getOwnPropertyDescriptor(o,i);return e.isUndefined(c)||c.configurable?(Object.defineProperty(o,i,{enumerable:!1,configurable:!0,writable:!1,value:u}),!0):!1}n.defineNameProp=a}),ci=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateRedundantMethods=n.validateMissingCstMethods=n.validateVisitor=n.CstVisitorDefinitionError=n.createBaseVisitorConstructorWithDefaults=n.createBaseSemanticVisitorConstructor=n.defaultVisit=void 0;var e=xe(),t=xn();function i(h,g){for(var p=e.keys(h),T=p.length,m=0;m<T;m++)for(var l=p[m],d=h[l],y=d.length,v=0;v<y;v++){var E=d[v];E.tokenTypeIdx===void 0&&this[E.name](E.children,g)}}n.defaultVisit=i;function r(h,g){var p=function(){};t.defineNameProp(p,h+"BaseSemantics");var T={visit:function(m,l){if(e.isArray(m)&&(m=m[0]),!e.isUndefined(m))return this[m.name](m.children,l)},validateVisitor:function(){var m=u(this,g);if(!e.isEmpty(m)){var l=e.map(m,function(d){return d.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
162
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return f},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var u;o.topLevelRule instanceof r.Rule?u=o.topLevelRule.name:u=o.topLevelRule;var c="Duplicate definition, rule: ->"+u+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return c}}}),ii=ve(n=>{var e=n&&n.__extends||(function(){var u=function(c,s){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,h){f.__proto__=h}||function(f,h){for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(f[g]=h[g])},u(c,s)};return function(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");u(c,s);function f(){this.constructor=c}c.prototype=s===null?Object.create(s):(f.prototype=s.prototype,new f)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.GastRefResolverVisitor=n.resolveGrammar=void 0;var t=Ye(),i=xe(),r=ft();function a(u,c){var s=new o(u,c);return s.resolveRefs(),s.errors}n.resolveGrammar=a;var o=(function(u){e(c,u);function c(s,f){var h=u.call(this)||this;return h.nameToTopRule=s,h.errMsgProvider=f,h.errors=[],h}return c.prototype.resolveRefs=function(){var s=this;i.forEach(i.values(this.nameToTopRule),function(f){s.currTopLevel=f,f.accept(s)})},c.prototype.visitNonTerminal=function(s){var f=this.nameToTopRule[s.nonTerminalName];if(f)s.referencedRule=f;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,s);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:s.nonTerminalName})}},c})(r.GAstVisitor);n.GastRefResolverVisitor=o}),vt=ve(n=>{var e=n&&n.__extends||(function(){var l=function(d,y){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,E){v.__proto__=E}||function(v,E){for(var S in E)Object.prototype.hasOwnProperty.call(E,S)&&(v[S]=E[S])},l(d,y)};return function(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Class extends value "+String(y)+" is not a constructor or null");l(d,y);function v(){this.constructor=d}d.prototype=y===null?Object.create(y):(v.prototype=y.prototype,new v)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.nextPossibleTokensAfter=n.possiblePathsFrom=n.NextTerminalAfterAtLeastOneSepWalker=n.NextTerminalAfterAtLeastOneWalker=n.NextTerminalAfterManySepWalker=n.NextTerminalAfterManyWalker=n.AbstractNextTerminalAfterProductionWalker=n.NextAfterTokenWalker=n.AbstractNextPossibleTokensWalker=void 0;var t=jt(),i=xe(),r=bn(),a=He(),o=(function(l){e(d,l);function d(y,v){var E=l.call(this)||this;return E.topProd=y,E.path=v,E.possibleTokTypes=[],E.nextProductionName="",E.nextProductionOccurrence=0,E.found=!1,E.isAtEndOfPath=!1,E}return d.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=i.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=i.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},d.prototype.walk=function(y,v){v===void 0&&(v=[]),this.found||l.prototype.walk.call(this,y,v)},d.prototype.walkProdRef=function(y,v,E){if(y.referencedRule.name===this.nextProductionName&&y.idx===this.nextProductionOccurrence){var S=v.concat(E);this.updateExpectedNext(),this.walk(y.referencedRule,S)}},d.prototype.updateExpectedNext=function(){i.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},d})(t.RestWalker);n.AbstractNextPossibleTokensWalker=o;var u=(function(l){e(d,l);function d(y,v){var E=l.call(this,y,v)||this;return E.path=v,E.nextTerminalName="",E.nextTerminalOccurrence=0,E.nextTerminalName=E.path.lastTok.name,E.nextTerminalOccurrence=E.path.lastTokOccurrence,E}return d.prototype.walkTerminal=function(y,v,E){if(this.isAtEndOfPath&&y.terminalType.name===this.nextTerminalName&&y.idx===this.nextTerminalOccurrence&&!this.found){var S=v.concat(E),I=new a.Alternative({definition:S});this.possibleTokTypes=r.first(I),this.found=!0}},d})(o);n.NextAfterTokenWalker=u;var c=(function(l){e(d,l);function d(y,v){var E=l.call(this)||this;return E.topRule=y,E.occurrence=v,E.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},E}return d.prototype.startWalking=function(){return this.walk(this.topRule),this.result},d})(t.RestWalker);n.AbstractNextTerminalAfterProductionWalker=c;var s=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkMany=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkMany.call(this,y,v,E)},d})(c);n.NextTerminalAfterManyWalker=s;var f=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkManySep=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkManySep.call(this,y,v,E)},d})(c);n.NextTerminalAfterManySepWalker=f;var h=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOne=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOne.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneWalker=h;var g=(function(l){e(d,l);function d(){return l!==null&&l.apply(this,arguments)||this}return d.prototype.walkAtLeastOneSep=function(y,v,E){if(y.idx===this.occurrence){var S=i.first(v.concat(E));this.result.isEndOfRule=S===void 0,S instanceof a.Terminal&&(this.result.token=S.terminalType,this.result.occurrence=S.idx)}else l.prototype.walkAtLeastOneSep.call(this,y,v,E)},d})(c);n.NextTerminalAfterAtLeastOneSepWalker=g;function p(l,d,y){y===void 0&&(y=[]),y=i.cloneArr(y);var v=[],E=0;function S(x){return x.concat(i.drop(l,E+1))}function I(x){var B=p(S(x),d,y);return v.concat(B)}for(;y.length<d&&E<l.length;){var k=l[E];if(k instanceof a.Alternative||k instanceof a.NonTerminal)return I(k.definition);if(k instanceof a.Option)v=I(k.definition);else if(k instanceof a.RepetitionMandatory){var H=k.definition.concat([new a.Repetition({definition:k.definition})]);return I(H)}else if(k instanceof a.RepetitionMandatoryWithSeparator){var H=[new a.Alternative({definition:k.definition}),new a.Repetition({definition:[new a.Terminal({terminalType:k.separator})].concat(k.definition)})];return I(H)}else if(k instanceof a.RepetitionWithSeparator){var H=k.definition.concat([new a.Repetition({definition:[new a.Terminal({terminalType:k.separator})].concat(k.definition)})]);v=I(H)}else if(k instanceof a.Repetition){var H=k.definition.concat([new a.Repetition({definition:k.definition})]);v=I(H)}else{if(k instanceof a.Alternation)return i.forEach(k.definition,function(x){i.isEmpty(x.definition)===!1&&(v=I(x.definition))}),v;if(k instanceof a.Terminal)y.push(k.terminalType);else throw Error("non exhaustive match")}E++}return v.push({partialPath:y,suffixDef:i.drop(l,E)}),v}n.possiblePathsFrom=p;function T(l,d,y,v){var E="EXIT_NONE_TERMINAL",S=[E],I="EXIT_ALTERNATIVE",k=!1,H=d.length,x=H-v-1,B=[],P=[];for(P.push({idx:-1,def:l,ruleStack:[],occurrenceStack:[]});!i.isEmpty(P);){var O=P.pop();if(O===I){k&&i.last(P).idx<=x&&P.pop();continue}var M=O.def,C=O.idx,X=O.ruleStack,Q=O.occurrenceStack;if(!i.isEmpty(M)){var W=M[0];if(W===E){var $={idx:C,def:i.drop(M),ruleStack:i.dropRight(X),occurrenceStack:i.dropRight(Q)};P.push($)}else if(W instanceof a.Terminal)if(C<H-1){var te=C+1,ce=d[te];if(y(ce,W.terminalType)){var $={idx:te,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push($)}}else if(C===H-1)B.push({nextTokenType:W.terminalType,nextTokenOccurrence:W.idx,ruleStack:X,occurrenceStack:Q}),k=!0;else throw Error("non exhaustive match");else if(W instanceof a.NonTerminal){var ae=i.cloneArr(X);ae.push(W.nonTerminalName);var le=i.cloneArr(Q);le.push(W.idx);var $={idx:C,def:W.definition.concat(S,i.drop(M)),ruleStack:ae,occurrenceStack:le};P.push($)}else if(W instanceof a.Option){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var pe={idx:C,def:W.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.RepetitionMandatory){var U=new a.Repetition({definition:W.definition,idx:W.idx}),G=W.definition.concat([U],i.drop(M)),$={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push($)}else if(W instanceof a.RepetitionMandatoryWithSeparator){var K=new a.Terminal({terminalType:W.separator}),U=new a.Repetition({definition:[K].concat(W.definition),idx:W.idx}),G=W.definition.concat([U],i.drop(M)),$={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push($)}else if(W instanceof a.RepetitionWithSeparator){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var K=new a.Terminal({terminalType:W.separator}),q=new a.Repetition({definition:[K].concat(W.definition),idx:W.idx}),G=W.definition.concat([q],i.drop(M)),pe={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.Repetition){var ne={idx:C,def:i.drop(M),ruleStack:X,occurrenceStack:Q};P.push(ne),P.push(I);var q=new a.Repetition({definition:W.definition,idx:W.idx}),G=W.definition.concat([q],i.drop(M)),pe={idx:C,def:G,ruleStack:X,occurrenceStack:Q};P.push(pe)}else if(W instanceof a.Alternation)for(var J=W.definition.length-1;J>=0;J--){var ie=W.definition[J],Te={idx:C,def:ie.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q};P.push(Te),P.push(I)}else if(W instanceof a.Alternative)P.push({idx:C,def:W.definition.concat(i.drop(M)),ruleStack:X,occurrenceStack:Q});else if(W instanceof a.Rule)P.push(m(W,C,X,Q));else throw Error("non exhaustive match")}}return B}n.nextPossibleTokensAfter=T;function m(l,d,y,v){var E=i.cloneArr(y);E.push(l.name);var S=i.cloneArr(v);return S.push(1),{idx:d,def:l.definition,ruleStack:E,occurrenceStack:S}}}),Rt=ve(n=>{var e=n&&n.__extends||(function(){var x=function(B,P){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var C in M)Object.prototype.hasOwnProperty.call(M,C)&&(O[C]=M[C])},x(B,P)};return function(B,P){if(typeof P!="function"&&P!==null)throw new TypeError("Class extends value "+String(P)+" is not a constructor or null");x(B,P);function O(){this.constructor=B}B.prototype=P===null?Object.create(P):(O.prototype=P.prototype,new O)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.areTokenCategoriesNotUsed=n.isStrictPrefixOfPath=n.containsPath=n.getLookaheadPathsForOptionalProd=n.getLookaheadPathsForOr=n.lookAheadSequenceFromAlternatives=n.buildSingleAlternativeLookaheadFunction=n.buildAlternativesLookAheadFunc=n.buildLookaheadFuncForOptionalProd=n.buildLookaheadFuncForOr=n.getProdType=n.PROD_TYPE=void 0;var t=xe(),i=vt(),r=jt(),a=ht(),o=He(),u=ft(),c;(function(x){x[x.OPTION=0]="OPTION",x[x.REPETITION=1]="REPETITION",x[x.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",x[x.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",x[x.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",x[x.ALTERNATION=5]="ALTERNATION"})(c=n.PROD_TYPE||(n.PROD_TYPE={}));function s(x){if(x instanceof o.Option)return c.OPTION;if(x instanceof o.Repetition)return c.REPETITION;if(x instanceof o.RepetitionMandatory)return c.REPETITION_MANDATORY;if(x instanceof o.RepetitionMandatoryWithSeparator)return c.REPETITION_MANDATORY_WITH_SEPARATOR;if(x instanceof o.RepetitionWithSeparator)return c.REPETITION_WITH_SEPARATOR;if(x instanceof o.Alternation)return c.ALTERNATION;throw Error("non exhaustive match")}n.getProdType=s;function f(x,B,P,O,M,C){var X=E(x,B,P),Q=H(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return C(X,O,Q,M)}n.buildLookaheadFuncForOr=f;function h(x,B,P,O,M,C){var X=S(x,B,M,P),Q=H(X)?a.tokenStructuredMatcherNoCategories:a.tokenStructuredMatcher;return C(X[0],Q,O)}n.buildLookaheadFuncForOptionalProd=h;function g(x,B,P,O){var M=x.length,C=t.every(x,function(W){return t.every(W,function($){return $.length===1})});if(B)return function(W){for(var $=t.map(W,function(q){return q.GATE}),te=0;te<M;te++){var ce=x[te],ae=ce.length,le=$[te];if(!(le!==void 0&&le.call(this)===!1))e:for(var ne=0;ne<ae;ne++){for(var pe=ce[ne],U=pe.length,G=0;G<U;G++){var K=this.LA(G+1);if(P(K,pe[G])===!1)continue e}return te}}};if(C&&!O){var X=t.map(x,function(W){return t.flatten(W)}),Q=t.reduce(X,function(W,$,te){return t.forEach($,function(ce){t.has(W,ce.tokenTypeIdx)||(W[ce.tokenTypeIdx]=te),t.forEach(ce.categoryMatches,function(ae){t.has(W,ae)||(W[ae]=te)})}),W},[]);return function(){var W=this.LA(1);return Q[W.tokenTypeIdx]}}else return function(){for(var W=0;W<M;W++){var $=x[W],te=$.length;e:for(var ce=0;ce<te;ce++){for(var ae=$[ce],le=ae.length,ne=0;ne<le;ne++){var pe=this.LA(ne+1);if(P(pe,ae[ne])===!1)continue e}return W}}}}n.buildAlternativesLookAheadFunc=g;function p(x,B,P){var O=t.every(x,function($){return $.length===1}),M=x.length;if(O&&!P){var C=t.flatten(x);if(C.length===1&&t.isEmpty(C[0].categoryMatches)){var X=C[0],Q=X.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===Q}}else{var W=t.reduce(C,function($,te,ce){return $[te.tokenTypeIdx]=!0,t.forEach(te.categoryMatches,function(ae){$[ae]=!0}),$},[]);return function(){var $=this.LA(1);return W[$.tokenTypeIdx]===!0}}}else return function(){e:for(var $=0;$<M;$++){for(var te=x[$],ce=te.length,ae=0;ae<ce;ae++){var le=this.LA(ae+1);if(B(le,te[ae])===!1)continue e}return!0}return!1}}n.buildSingleAlternativeLookaheadFunction=p;var T=(function(x){e(B,x);function B(P,O,M){var C=x.call(this)||this;return C.topProd=P,C.targetOccurrence=O,C.targetProdType=M,C}return B.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},B.prototype.checkIsTarget=function(P,O,M,C){return P.idx===this.targetOccurrence&&this.targetProdType===O?(this.restDef=M.concat(C),!0):!1},B.prototype.walkOption=function(P,O,M){this.checkIsTarget(P,c.OPTION,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkAtLeastOne=function(P,O,M){this.checkIsTarget(P,c.REPETITION_MANDATORY,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkAtLeastOneSep=function(P,O,M){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkMany=function(P,O,M){this.checkIsTarget(P,c.REPETITION,O,M)||x.prototype.walkOption.call(this,P,O,M)},B.prototype.walkManySep=function(P,O,M){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR,O,M)||x.prototype.walkOption.call(this,P,O,M)},B})(r.RestWalker),m=(function(x){e(B,x);function B(P,O,M){var C=x.call(this)||this;return C.targetOccurrence=P,C.targetProdType=O,C.targetRef=M,C.result=[],C}return B.prototype.checkIsTarget=function(P,O){P.idx===this.targetOccurrence&&this.targetProdType===O&&(this.targetRef===void 0||P===this.targetRef)&&(this.result=P.definition)},B.prototype.visitOption=function(P){this.checkIsTarget(P,c.OPTION)},B.prototype.visitRepetition=function(P){this.checkIsTarget(P,c.REPETITION)},B.prototype.visitRepetitionMandatory=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY)},B.prototype.visitRepetitionMandatoryWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR)},B.prototype.visitRepetitionWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR)},B.prototype.visitAlternation=function(P){this.checkIsTarget(P,c.ALTERNATION)},B})(u.GAstVisitor);function l(x){for(var B=new Array(x),P=0;P<x;P++)B[P]=[];return B}function d(x){for(var B=[""],P=0;P<x.length;P++){for(var O=x[P],M=[],C=0;C<B.length;C++){var X=B[C];M.push(X+"_"+O.tokenTypeIdx);for(var Q=0;Q<O.categoryMatches.length;Q++){var W="_"+O.categoryMatches[Q];M.push(X+W)}}B=M}return B}function y(x,B,P){for(var O=0;O<x.length;O++)if(O!==P)for(var M=x[O],C=0;C<B.length;C++){var X=B[C];if(M[X]===!0)return!1}return!0}function v(x,B){for(var P=t.map(x,function(te){return i.possiblePathsFrom([te],1)}),O=l(P.length),M=t.map(P,function(te){var ce={};return t.forEach(te,function(ae){var le=d(ae.partialPath);t.forEach(le,function(ne){ce[ne]=!0})}),ce}),C=P,X=1;X<=B;X++){var Q=C;C=l(Q.length);for(var W=function(te){for(var ce=Q[te],ae=0;ae<ce.length;ae++){var le=ce[ae].partialPath,ne=ce[ae].suffixDef,pe=d(le),U=y(M,pe,te);if(U||t.isEmpty(ne)||le.length===B){var G=O[te];if(I(G,le)===!1){G.push(le);for(var K=0;K<pe.length;K++){var q=pe[K];M[te][q]=!0}}}else{var J=i.possiblePathsFrom(ne,X+1,le);C[te]=C[te].concat(J),t.forEach(J,function(ie){var Te=d(ie.partialPath);t.forEach(Te,function(ye){M[te][ye]=!0})})}}},$=0;$<Q.length;$++)W($)}return O}n.lookAheadSequenceFromAlternatives=v;function E(x,B,P,O){var M=new m(x,c.ALTERNATION,O);return B.accept(M),v(M.result,P)}n.getLookaheadPathsForOr=E;function S(x,B,P,O){var M=new m(x,P);B.accept(M);var C=M.result,X=new T(B,x,P),Q=X.startWalking(),W=new o.Alternative({definition:C}),$=new o.Alternative({definition:Q});return v([W,$],O)}n.getLookaheadPathsForOptionalProd=S;function I(x,B){e:for(var P=0;P<x.length;P++){var O=x[P];if(O.length===B.length){for(var M=0;M<O.length;M++){var C=B[M],X=O[M],Q=C===X||X.categoryMatchesMap[C.tokenTypeIdx]!==void 0;if(Q===!1)continue e}return!0}}return!1}n.containsPath=I;function k(x,B){return x.length<B.length&&t.every(x,function(P,O){var M=B[O];return P===M||M.categoryMatchesMap[P.tokenTypeIdx]})}n.isStrictPrefixOfPath=k;function H(x){return t.every(x,function(B){return t.every(B,function(P){return t.every(P,function(O){return t.isEmpty(O.categoryMatches)})})})}n.areTokenCategoriesNotUsed=H}),Sn=ve(n=>{var e=n&&n.__extends||(function(){var O=function(M,C){return O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(X,Q){X.__proto__=Q}||function(X,Q){for(var W in Q)Object.prototype.hasOwnProperty.call(Q,W)&&(X[W]=Q[W])},O(M,C)};return function(M,C){if(typeof C!="function"&&C!==null)throw new TypeError("Class extends value "+String(C)+" is not a constructor or null");O(M,C);function X(){this.constructor=M}M.prototype=C===null?Object.create(C):(X.prototype=C.prototype,new X)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.checkPrefixAlternativesAmbiguities=n.validateSomeNonEmptyLookaheadPath=n.validateTooManyAlts=n.RepetionCollector=n.validateAmbiguousAlternationAlternatives=n.validateEmptyOrAlternative=n.getFirstNoneTerminal=n.validateNoLeftRecursion=n.validateRuleIsOverridden=n.validateRuleDoesNotAlreadyExist=n.OccurrenceValidationCollector=n.identifyProductionForDuplicates=n.validateGrammar=void 0;var t=xe(),i=xe(),r=Ye(),a=Tt(),o=Rt(),u=vt(),c=He(),s=ft();function f(O,M,C,X,Q){var W=t.map(O,function(U){return h(U,X)}),$=t.map(O,function(U){return d(U,U,X)}),te=[],ce=[],ae=[];i.every($,i.isEmpty)&&(te=i.map(O,function(U){return E(U,X)}),ce=i.map(O,function(U){return S(U,M,X)}),ae=H(O,M,X));var le=P(O,C,X),ne=i.map(O,function(U){return k(U,X)}),pe=i.map(O,function(U){return m(U,O,Q,X)});return t.flatten(W.concat(ae,$,te,ce,le,ne,pe))}n.validateGrammar=f;function h(O,M){var C=new T;O.accept(C);var X=C.allProductions,Q=t.groupBy(X,g),W=t.pick(Q,function(te){return te.length>1}),$=t.map(t.values(W),function(te){var ce=t.first(te),ae=M.buildDuplicateFoundError(O,te),le=a.getProductionDslName(ce),ne={message:ae,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:O.name,dslName:le,occurrence:ce.idx},pe=p(ce);return pe&&(ne.parameter=pe),ne});return $}function g(O){return a.getProductionDslName(O)+"_#_"+O.idx+"_#_"+p(O)}n.identifyProductionForDuplicates=g;function p(O){return O instanceof c.Terminal?O.terminalType.name:O instanceof c.NonTerminal?O.nonTerminalName:""}var T=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.allProductions=[],C}return M.prototype.visitNonTerminal=function(C){this.allProductions.push(C)},M.prototype.visitOption=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatory=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatoryWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetition=function(C){this.allProductions.push(C)},M.prototype.visitAlternation=function(C){this.allProductions.push(C)},M.prototype.visitTerminal=function(C){this.allProductions.push(C)},M})(s.GAstVisitor);n.OccurrenceValidationCollector=T;function m(O,M,C,X){var Q=[],W=i.reduce(M,function(te,ce){return ce.name===O.name?te+1:te},0);if(W>1){var $=X.buildDuplicateRuleNameError({topLevelRule:O,grammarName:C});Q.push({message:$,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:O.name})}return Q}n.validateRuleDoesNotAlreadyExist=m;function l(O,M,C){var X=[],Q;return t.contains(M,O)||(Q="Invalid rule override, rule: ->"+O+"<- cannot be overridden in the grammar: ->"+C+"<-as it is not defined in any of the super grammars ",X.push({message:Q,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:O})),X}n.validateRuleIsOverridden=l;function d(O,M,C,X){X===void 0&&(X=[]);var Q=[],W=y(M.definition);if(t.isEmpty(W))return[];var $=O.name,te=t.contains(W,O);te&&Q.push({message:C.buildLeftRecursionError({topLevelRule:O,leftRecursionPath:X}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:$});var ce=t.difference(W,X.concat([O])),ae=t.map(ce,function(le){var ne=t.cloneArr(X);return ne.push(le),d(O,le,C,ne)});return Q.concat(t.flatten(ae))}n.validateNoLeftRecursion=d;function y(O){var M=[];if(t.isEmpty(O))return M;var C=t.first(O);if(C instanceof c.NonTerminal)M.push(C.referencedRule);else if(C instanceof c.Alternative||C instanceof c.Option||C instanceof c.RepetitionMandatory||C instanceof c.RepetitionMandatoryWithSeparator||C instanceof c.RepetitionWithSeparator||C instanceof c.Repetition)M=M.concat(y(C.definition));else if(C instanceof c.Alternation)M=t.flatten(t.map(C.definition,function($){return y($.definition)}));else if(!(C instanceof c.Terminal))throw Error("non exhaustive match");var X=a.isOptionalProd(C),Q=O.length>1;if(X&&Q){var W=t.drop(O);return M.concat(y(W))}else return M}n.getFirstNoneTerminal=y;var v=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.alternations=[],C}return M.prototype.visitAlternation=function(C){this.alternations.push(C)},M})(s.GAstVisitor);function E(O,M){var C=new v;O.accept(C);var X=C.alternations,Q=t.reduce(X,function(W,$){var te=t.dropRight($.definition),ce=t.map(te,function(ae,le){var ne=u.nextPossibleTokensAfter([ae],[],null,1);return t.isEmpty(ne)?{message:M.buildEmptyAlternationError({topLevelRule:O,alternation:$,emptyChoiceIdx:le}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:O.name,occurrence:$.idx,alternative:le+1}:null});return W.concat(t.compact(ce))},[]);return Q}n.validateEmptyOrAlternative=E;function S(O,M,C){var X=new v;O.accept(X);var Q=X.alternations;Q=i.reject(Q,function($){return $.ignoreAmbiguities===!0});var W=t.reduce(Q,function($,te){var ce=te.idx,ae=te.maxLookahead||M,le=o.getLookaheadPathsForOr(ce,O,ae,te),ne=x(le,te,O,C),pe=B(le,te,O,C);return $.concat(ne,pe)},[]);return W}n.validateAmbiguousAlternationAlternatives=S;var I=(function(O){e(M,O);function M(){var C=O!==null&&O.apply(this,arguments)||this;return C.allProductions=[],C}return M.prototype.visitRepetitionWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatory=function(C){this.allProductions.push(C)},M.prototype.visitRepetitionMandatoryWithSeparator=function(C){this.allProductions.push(C)},M.prototype.visitRepetition=function(C){this.allProductions.push(C)},M})(s.GAstVisitor);n.RepetionCollector=I;function k(O,M){var C=new v;O.accept(C);var X=C.alternations,Q=t.reduce(X,function(W,$){return $.definition.length>255&&W.push({message:M.buildTooManyAlternativesError({topLevelRule:O,alternation:$}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:O.name,occurrence:$.idx}),W},[]);return Q}n.validateTooManyAlts=k;function H(O,M,C){var X=[];return i.forEach(O,function(Q){var W=new I;Q.accept(W);var $=W.allProductions;i.forEach($,function(te){var ce=o.getProdType(te),ae=te.maxLookahead||M,le=te.idx,ne=o.getLookaheadPathsForOptionalProd(le,Q,ce,ae),pe=ne[0];if(i.isEmpty(i.flatten(pe))){var U=C.buildEmptyRepetitionError({topLevelRule:Q,repetition:te});X.push({message:U,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:Q.name})}})}),X}n.validateSomeNonEmptyLookaheadPath=H;function x(O,M,C,X){var Q=[],W=i.reduce(O,function(te,ce,ae){return M.definition[ae].ignoreAmbiguities===!0||i.forEach(ce,function(le){var ne=[ae];i.forEach(O,function(pe,U){ae!==U&&o.containsPath(pe,le)&&M.definition[U].ignoreAmbiguities!==!0&&ne.push(U)}),ne.length>1&&!o.containsPath(Q,le)&&(Q.push(le),te.push({alts:ne,path:le}))}),te},[]),$=t.map(W,function(te){var ce=i.map(te.alts,function(le){return le+1}),ae=X.buildAlternationAmbiguityError({topLevelRule:C,alternation:M,ambiguityIndices:ce,prefixPath:te.path});return{message:ae,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:C.name,occurrence:M.idx,alternatives:[te.alts]}});return $}function B(O,M,C,X){var Q=[],W=i.reduce(O,function($,te,ce){var ae=i.map(te,function(le){return{idx:ce,path:le}});return $.concat(ae)},[]);return i.forEach(W,function($){var te=M.definition[$.idx];if(te.ignoreAmbiguities!==!0){var ce=$.idx,ae=$.path,le=i.findAll(W,function(pe){return M.definition[pe.idx].ignoreAmbiguities!==!0&&pe.idx<ce&&o.isStrictPrefixOfPath(pe.path,ae)}),ne=i.map(le,function(pe){var U=[pe.idx+1,ce+1],G=M.idx===0?"":M.idx,K=X.buildAlternationPrefixAmbiguityError({topLevelRule:C,alternation:M,ambiguityIndices:U,prefixPath:pe.path});return{message:K,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:C.name,occurrence:G,alternatives:U}});Q=Q.concat(ne)}}),Q}n.checkPrefixAlternativesAmbiguities=B;function P(O,M,C){var X=[],Q=i.map(M,function(W){return W.name});return i.forEach(O,function(W){var $=W.name;if(i.contains(Q,$)){var te=C.buildNamespaceConflictError(W);X.push({message:te,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:$})}}),X}}),oi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateGrammar=n.resolveGrammar=void 0;var e=xe(),t=ii(),i=Sn(),r=Et();function a(u){u=e.defaults(u,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var c={};return e.forEach(u.rules,function(s){c[s.name]=s}),t.resolveGrammar(c,u.errMsgProvider)}n.resolveGrammar=a;function o(u){return u=e.defaults(u,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),i.validateGrammar(u.rules,u.maxLookahead,u.tokenTypes,u.errMsgProvider,u.grammarName)}n.validateGrammar=o}),dt=ve(n=>{var e=n&&n.__extends||(function(){var T=function(m,l){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,y){d.__proto__=y}||function(d,y){for(var v in y)Object.prototype.hasOwnProperty.call(y,v)&&(d[v]=y[v])},T(m,l)};return function(m,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");T(m,l);function d(){this.constructor=m}m.prototype=l===null?Object.create(l):(d.prototype=l.prototype,new d)}})();Object.defineProperty(n,"__esModule",{value:!0}),n.EarlyExitException=n.NotAllInputParsedException=n.NoViableAltException=n.MismatchedTokenException=n.isRecognitionException=void 0;var t=xe(),i="MismatchedTokenException",r="NoViableAltException",a="EarlyExitException",o="NotAllInputParsedException",u=[i,r,a,o];Object.freeze(u);function c(T){return t.contains(u,T.name)}n.isRecognitionException=c;var s=(function(T){e(m,T);function m(l,d){var y=this.constructor,v=T.call(this,l)||this;return v.token=d,v.resyncedTokens=[],Object.setPrototypeOf(v,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(v,v.constructor),v}return m})(Error),f=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=i,v}return m})(s);n.MismatchedTokenException=f;var h=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=r,v}return m})(s);n.NoViableAltException=h;var g=(function(T){e(m,T);function m(l,d){var y=T.call(this,l,d)||this;return y.name=o,y}return m})(s);n.NotAllInputParsedException=g;var p=(function(T){e(m,T);function m(l,d,y){var v=T.call(this,l,d)||this;return v.previousToken=y,v.name=a,v}return m})(s);n.EarlyExitException=p}),On=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.attemptInRepetitionRecovery=n.Recoverable=n.InRuleRecoveryException=n.IN_RULE_RECOVERY_EXCEPTION=n.EOF_FOLLOW_KEY=void 0;var e=nt(),t=xe(),i=dt(),r=Ln(),a=Ye();n.EOF_FOLLOW_KEY={},n.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(s){this.name=n.IN_RULE_RECOVERY_EXCEPTION,this.message=s}n.InRuleRecoveryException=o,o.prototype=Error.prototype;var u=(function(){function s(){}return s.prototype.initRecoverable=function(f){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(f,"recoveryEnabled")?f.recoveryEnabled:a.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},s.prototype.getTokenToInsert=function(f){var h=e.createTokenInstance(f,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},s.prototype.canTokenTypeBeInsertedInRecovery=function(f){return!0},s.prototype.tryInRepetitionRecovery=function(f,h,g,p){for(var T=this,m=this.findReSyncTokenType(),l=this.exportLexerState(),d=[],y=!1,v=this.LA(1),E=this.LA(1),S=function(){var I=T.LA(0),k=T.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:v,previous:I,ruleName:T.getCurrRuleFullName()}),H=new i.MismatchedTokenException(k,v,T.LA(0));H.resyncedTokens=t.dropRight(d),T.SAVE_ERROR(H)};!y;)if(this.tokenMatcher(E,p)){S();return}else if(g.call(this)){S(),f.apply(this,h);return}else this.tokenMatcher(E,m)?y=!0:(E=this.SKIP_TOKEN(),this.addToResyncTokens(E,d));this.importLexerState(l)},s.prototype.shouldInRepetitionRecoveryBeTried=function(f,h,g){return!(g===!1||f===void 0||h===void 0||this.tokenMatcher(this.LA(1),f)||this.isBackTracking()||this.canPerformInRuleRecovery(f,this.getFollowsForInRuleRecovery(f,h)))},s.prototype.getFollowsForInRuleRecovery=function(f,h){var g=this.getCurrentGrammarPath(f,h),p=this.getNextPossibleTokenTypes(g);return p},s.prototype.tryInRuleRecovery=function(f,h){if(this.canRecoverWithSingleTokenInsertion(f,h)){var g=this.getTokenToInsert(f);return g}if(this.canRecoverWithSingleTokenDeletion(f)){var p=this.SKIP_TOKEN();return this.consumeToken(),p}throw new o("sad sad panda")},s.prototype.canPerformInRuleRecovery=function(f,h){return this.canRecoverWithSingleTokenInsertion(f,h)||this.canRecoverWithSingleTokenDeletion(f)},s.prototype.canRecoverWithSingleTokenInsertion=function(f,h){var g=this;if(!this.canTokenTypeBeInsertedInRecovery(f)||t.isEmpty(h))return!1;var p=this.LA(1),T=t.find(h,function(m){return g.tokenMatcher(p,m)})!==void 0;return T},s.prototype.canRecoverWithSingleTokenDeletion=function(f){var h=this.tokenMatcher(this.LA(2),f);return h},s.prototype.isInCurrentRuleReSyncSet=function(f){var h=this.getCurrFollowKey(),g=this.getFollowSetFromFollowKey(h);return t.contains(g,f)},s.prototype.findReSyncTokenType=function(){for(var f=this.flattenFollowSet(),h=this.LA(1),g=2;;){var p=h.tokenType;if(t.contains(f,p))return p;h=this.LA(g),g++}},s.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return n.EOF_FOLLOW_KEY;var f=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),g=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(f),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(g)}},s.prototype.buildFullFollowKeyStack=function(){var f=this,h=this.RULE_STACK,g=this.RULE_OCCURRENCE_STACK;return t.map(h,function(p,T){return T===0?n.EOF_FOLLOW_KEY:{ruleName:f.shortRuleNameToFullName(p),idxInCallingRule:g[T],inRule:f.shortRuleNameToFullName(h[T-1])}})},s.prototype.flattenFollowSet=function(){var f=this,h=t.map(this.buildFullFollowKeyStack(),function(g){return f.getFollowSetFromFollowKey(g)});return t.flatten(h)},s.prototype.getFollowSetFromFollowKey=function(f){if(f===n.EOF_FOLLOW_KEY)return[e.EOF];var h=f.ruleName+f.idxInCallingRule+r.IN+f.inRule;return this.resyncFollows[h]},s.prototype.addToResyncTokens=function(f,h){return this.tokenMatcher(f,e.EOF)||h.push(f),h},s.prototype.reSyncTo=function(f){for(var h=[],g=this.LA(1);this.tokenMatcher(g,f)===!1;)g=this.SKIP_TOKEN(),this.addToResyncTokens(g,h);return t.dropRight(h)},s.prototype.attemptInRepetitionRecovery=function(f,h,g,p,T,m,l){},s.prototype.getCurrentGrammarPath=function(f,h){var g=this.getHumanReadableRuleStack(),p=t.cloneArr(this.RULE_OCCURRENCE_STACK),T={ruleStack:g,occurrenceStack:p,lastTok:f,lastTokOccurrence:h};return T},s.prototype.getHumanReadableRuleStack=function(){var f=this;return t.map(this.RULE_STACK,function(h){return f.shortRuleNameToFullName(h)})},s})();n.Recoverable=u;function c(s,f,h,g,p,T,m){var l=this.getKeyForAutomaticLookahead(g,p),d=this.firstAfterRepMap[l];if(d===void 0){var y=this.getCurrRuleFullName(),v=this.getGAstProductions()[y],E=new T(v,p);d=E.startWalking(),this.firstAfterRepMap[l]=d}var S=d.token,I=d.occurrence,k=d.isEndOfRule;this.RULE_STACK.length===1&&k&&S===void 0&&(S=e.EOF,I=1),this.shouldInRepetitionRecoveryBeTried(S,I,m)&&this.tryInRepetitionRecovery(s,f,h,S)}n.attemptInRepetitionRecovery=c}),Bt=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getKeyForAutomaticLookahead=n.AT_LEAST_ONE_SEP_IDX=n.MANY_SEP_IDX=n.AT_LEAST_ONE_IDX=n.MANY_IDX=n.OPTION_IDX=n.OR_IDX=n.BITS_FOR_ALT_IDX=n.BITS_FOR_RULE_IDX=n.BITS_FOR_OCCURRENCE_IDX=n.BITS_FOR_METHOD_TYPE=void 0,n.BITS_FOR_METHOD_TYPE=4,n.BITS_FOR_OCCURRENCE_IDX=8,n.BITS_FOR_RULE_IDX=12,n.BITS_FOR_ALT_IDX=8,n.OR_IDX=1<<n.BITS_FOR_OCCURRENCE_IDX,n.OPTION_IDX=2<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_IDX=3<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_IDX=4<<n.BITS_FOR_OCCURRENCE_IDX,n.MANY_SEP_IDX=5<<n.BITS_FOR_OCCURRENCE_IDX,n.AT_LEAST_ONE_SEP_IDX=6<<n.BITS_FOR_OCCURRENCE_IDX;function e(t,i,r){return r|i|t}n.getKeyForAutomaticLookahead=e,32-n.BITS_FOR_ALT_IDX}),si=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LooksAhead=void 0;var e=Rt(),t=xe(),i=Ye(),r=Bt(),a=Tt(),o=(function(){function u(){}return u.prototype.initLooksAhead=function(c){this.dynamicTokensEnabled=t.has(c,"dynamicTokensEnabled")?c.dynamicTokensEnabled:i.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(c,"maxLookahead")?c.maxLookahead:i.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},u.prototype.preComputeLookaheadFunctions=function(c){var s=this;t.forEach(c,function(f){s.TRACE_INIT(f.name+" Rule Lookahead",function(){var h=a.collectMethods(f),g=h.alternation,p=h.repetition,T=h.option,m=h.repetitionMandatory,l=h.repetitionMandatoryWithSeparator,d=h.repetitionWithSeparator;t.forEach(g,function(y){var v=y.idx===0?"":y.idx;s.TRACE_INIT(""+a.getProductionDslName(y)+v,function(){var E=e.buildLookaheadFuncForOr(y.idx,f,y.maxLookahead||s.maxLookahead,y.hasPredicates,s.dynamicTokensEnabled,s.lookAheadBuilderForAlternatives),S=r.getKeyForAutomaticLookahead(s.fullRuleNameToShort[f.name],r.OR_IDX,y.idx);s.setLaFuncCache(S,E)})}),t.forEach(p,function(y){s.computeLookaheadFunc(f,y.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(T,function(y){s.computeLookaheadFunc(f,y.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(m,function(y){s.computeLookaheadFunc(f,y.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(l,function(y){s.computeLookaheadFunc(f,y.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))}),t.forEach(d,function(y){s.computeLookaheadFunc(f,y.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,y.maxLookahead,a.getProductionDslName(y))})})})},u.prototype.computeLookaheadFunc=function(c,s,f,h,g,p){var T=this;this.TRACE_INIT(""+p+(s===0?"":s),function(){var m=e.buildLookaheadFuncForOptionalProd(s,c,g||T.maxLookahead,T.dynamicTokensEnabled,h,T.lookAheadBuilderForOptional),l=r.getKeyForAutomaticLookahead(T.fullRuleNameToShort[c.name],f,s);T.setLaFuncCache(l,m)})},u.prototype.lookAheadBuilderForOptional=function(c,s,f){return e.buildSingleAlternativeLookaheadFunction(c,s,f)},u.prototype.lookAheadBuilderForAlternatives=function(c,s,f,h){return e.buildAlternativesLookAheadFunc(c,s,f,h)},u.prototype.getKeyForAutomaticLookahead=function(c,s){var f=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(f,c,s)},u.prototype.getLaFuncFromCache=function(c){},u.prototype.getLaFuncFromMap=function(c){return this.lookAheadFuncsCache.get(c)},u.prototype.getLaFuncFromObj=function(c){return this.lookAheadFuncsCache[c]},u.prototype.setLaFuncCache=function(c,s){},u.prototype.setLaFuncCacheUsingMap=function(c,s){this.lookAheadFuncsCache.set(c,s)},u.prototype.setLaFuncUsingObj=function(c,s){this.lookAheadFuncsCache[c]=s},u})();n.LooksAhead=o}),ai=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addNoneTerminalToCst=n.addTerminalToCst=n.setNodeLocationFull=n.setNodeLocationOnlyOffset=void 0;function e(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.endOffset=o.endOffset):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset)}n.setNodeLocationOnlyOffset=e;function t(a,o){isNaN(a.startOffset)===!0?(a.startOffset=o.startOffset,a.startColumn=o.startColumn,a.startLine=o.startLine,a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine):a.endOffset<o.endOffset&&(a.endOffset=o.endOffset,a.endColumn=o.endColumn,a.endLine=o.endLine)}n.setNodeLocationFull=t;function i(a,o,u){a.children[u]===void 0?a.children[u]=[o]:a.children[u].push(o)}n.addTerminalToCst=i;function r(a,o,u){a.children[o]===void 0?a.children[o]=[u]:a.children[o].push(u)}n.addNoneTerminalToCst=r}),xn=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.defineNameProp=n.functionName=n.classNameFromInstance=void 0;var e=xe();function t(o){return r(o.constructor)}n.classNameFromInstance=t;var i="name";function r(o){var u=o.name;return u||"anonymous"}n.functionName=r;function a(o,u){var c=Object.getOwnPropertyDescriptor(o,i);return e.isUndefined(c)||c.configurable?(Object.defineProperty(o,i,{enumerable:!1,configurable:!0,writable:!1,value:u}),!0):!1}n.defineNameProp=a}),ci=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.validateRedundantMethods=n.validateMissingCstMethods=n.validateVisitor=n.CstVisitorDefinitionError=n.createBaseVisitorConstructorWithDefaults=n.createBaseSemanticVisitorConstructor=n.defaultVisit=void 0;var e=xe(),t=xn();function i(h,g){for(var p=e.keys(h),T=p.length,m=0;m<T;m++)for(var l=p[m],d=h[l],y=d.length,v=0;v<y;v++){var E=d[v];E.tokenTypeIdx===void 0&&this[E.name](E.children,g)}}n.defaultVisit=i;function r(h,g){var p=function(){};t.defineNameProp(p,h+"BaseSemantics");var T={visit:function(m,l){if(e.isArray(m)&&(m=m[0]),!e.isUndefined(m))return this[m.name](m.children,l)},validateVisitor:function(){var m=u(this,g);if(!e.isEmpty(m)){var l=e.map(m,function(d){return d.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
163
163
  `+(""+l.join(`
164
164
 
165
165
  `).replace(/\n/g,`
166
166
  `)))}}};return p.prototype=T,p.prototype.constructor=p,p._RULE_NAMES=g,p}n.createBaseSemanticVisitorConstructor=r;function a(h,g,p){var T=function(){};t.defineNameProp(T,h+"BaseSemanticsWithDefaults");var m=Object.create(p.prototype);return e.forEach(g,function(l){m[l]=i}),T.prototype=m,T.prototype.constructor=T,T}n.createBaseVisitorConstructorWithDefaults=a;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=n.CstVisitorDefinitionError||(n.CstVisitorDefinitionError={}));function u(h,g){var p=c(h,g),T=f(h,g);return p.concat(T)}n.validateVisitor=u;function c(h,g){var p=e.map(g,function(T){if(!e.isFunction(h[T]))return{msg:"Missing visitor method: <"+T+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:T}});return e.compact(p)}n.validateMissingCstMethods=c;var s=["constructor","visit","validateVisitor"];function f(h,g){var p=[];for(var T in h)e.isFunction(h[T])&&!e.contains(s,T)&&!e.contains(g,T)&&p.push({msg:"Redundant visitor method: <"+T+"> on "+t.functionName(h.constructor)+` CST Visitor
167
167
  There is no Grammar Rule corresponding to this method's name.
168
- `,type:o.REDUNDANT_METHOD,methodName:T});return p}n.validateRedundantMethods=f}),li=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TreeBuilder=void 0;var e=ai(),t=xe(),i=ci(),r=Ye(),a=(function(){function o(){}return o.prototype.initTreeBuilder=function(u){if(this.CST_STACK=[],this.outputCst=u.outputCst,this.nodeLocationTracking=t.has(u,"nodeLocationTracking")?u.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+u.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(u){u.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(u){u.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(u){u.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(u){var c=this.LA(1);u.location={startOffset:c.startOffset,startLine:c.startLine,startColumn:c.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(u,c){var s={name:u,children:{}};this.setInitialNodeLocation(s),this.CST_STACK.push(s)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(u){var c=this.LA(0),s=u.location;s.startOffset<=c.startOffset?(s.endOffset=c.endOffset,s.endLine=c.endLine,s.endColumn=c.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(u){var c=this.LA(0),s=u.location;s.startOffset<=c.startOffset?s.endOffset=c.endOffset:s.startOffset=NaN},o.prototype.cstPostTerminal=function(u,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(s,c,u),this.setNodeLocationFromToken(s.location,c)},o.prototype.cstPostNonTerminal=function(u,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(s,c,u),this.setNodeLocationFromNode(s.location,u.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var u=i.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=u,u}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var u=i.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=u,u}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var u=this.RULE_OCCURRENCE_STACK;return u[u.length-1]},o})();n.TreeBuilder=a}),ui=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LexerAdapter=void 0;var e=Ye(),t=(function(){function i(){}return i.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(i.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),i.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},i.prototype.LA=function(r){var a=this.currIdx+r;return a<0||this.tokVectorLength<=a?e.END_OF_FILE:this.tokVector[a]},i.prototype.consumeToken=function(){this.currIdx++},i.prototype.exportLexerState=function(){return this.currIdx},i.prototype.importLexerState=function(r){this.currIdx=r},i.prototype.resetLexerState=function(){this.currIdx=-1},i.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},i.prototype.getLexerPosition=function(){return this.exportLexerState()},i})();n.LexerAdapter=t}),hi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerApi=void 0;var e=xe(),t=dt(),i=Ye(),r=Et(),a=Sn(),o=He(),u=(function(){function c(){}return c.prototype.ACTION=function(s){return s.call(this)},c.prototype.consume=function(s,f,h){return this.consumeInternal(f,s,h)},c.prototype.subrule=function(s,f,h){return this.subruleInternal(f,s,h)},c.prototype.option=function(s,f){return this.optionInternal(f,s)},c.prototype.or=function(s,f){return this.orInternal(f,s)},c.prototype.many=function(s,f){return this.manyInternal(s,f)},c.prototype.atLeastOne=function(s,f){return this.atLeastOneInternal(s,f)},c.prototype.CONSUME=function(s,f){return this.consumeInternal(s,0,f)},c.prototype.CONSUME1=function(s,f){return this.consumeInternal(s,1,f)},c.prototype.CONSUME2=function(s,f){return this.consumeInternal(s,2,f)},c.prototype.CONSUME3=function(s,f){return this.consumeInternal(s,3,f)},c.prototype.CONSUME4=function(s,f){return this.consumeInternal(s,4,f)},c.prototype.CONSUME5=function(s,f){return this.consumeInternal(s,5,f)},c.prototype.CONSUME6=function(s,f){return this.consumeInternal(s,6,f)},c.prototype.CONSUME7=function(s,f){return this.consumeInternal(s,7,f)},c.prototype.CONSUME8=function(s,f){return this.consumeInternal(s,8,f)},c.prototype.CONSUME9=function(s,f){return this.consumeInternal(s,9,f)},c.prototype.SUBRULE=function(s,f){return this.subruleInternal(s,0,f)},c.prototype.SUBRULE1=function(s,f){return this.subruleInternal(s,1,f)},c.prototype.SUBRULE2=function(s,f){return this.subruleInternal(s,2,f)},c.prototype.SUBRULE3=function(s,f){return this.subruleInternal(s,3,f)},c.prototype.SUBRULE4=function(s,f){return this.subruleInternal(s,4,f)},c.prototype.SUBRULE5=function(s,f){return this.subruleInternal(s,5,f)},c.prototype.SUBRULE6=function(s,f){return this.subruleInternal(s,6,f)},c.prototype.SUBRULE7=function(s,f){return this.subruleInternal(s,7,f)},c.prototype.SUBRULE8=function(s,f){return this.subruleInternal(s,8,f)},c.prototype.SUBRULE9=function(s,f){return this.subruleInternal(s,9,f)},c.prototype.OPTION=function(s){return this.optionInternal(s,0)},c.prototype.OPTION1=function(s){return this.optionInternal(s,1)},c.prototype.OPTION2=function(s){return this.optionInternal(s,2)},c.prototype.OPTION3=function(s){return this.optionInternal(s,3)},c.prototype.OPTION4=function(s){return this.optionInternal(s,4)},c.prototype.OPTION5=function(s){return this.optionInternal(s,5)},c.prototype.OPTION6=function(s){return this.optionInternal(s,6)},c.prototype.OPTION7=function(s){return this.optionInternal(s,7)},c.prototype.OPTION8=function(s){return this.optionInternal(s,8)},c.prototype.OPTION9=function(s){return this.optionInternal(s,9)},c.prototype.OR=function(s){return this.orInternal(s,0)},c.prototype.OR1=function(s){return this.orInternal(s,1)},c.prototype.OR2=function(s){return this.orInternal(s,2)},c.prototype.OR3=function(s){return this.orInternal(s,3)},c.prototype.OR4=function(s){return this.orInternal(s,4)},c.prototype.OR5=function(s){return this.orInternal(s,5)},c.prototype.OR6=function(s){return this.orInternal(s,6)},c.prototype.OR7=function(s){return this.orInternal(s,7)},c.prototype.OR8=function(s){return this.orInternal(s,8)},c.prototype.OR9=function(s){return this.orInternal(s,9)},c.prototype.MANY=function(s){this.manyInternal(0,s)},c.prototype.MANY1=function(s){this.manyInternal(1,s)},c.prototype.MANY2=function(s){this.manyInternal(2,s)},c.prototype.MANY3=function(s){this.manyInternal(3,s)},c.prototype.MANY4=function(s){this.manyInternal(4,s)},c.prototype.MANY5=function(s){this.manyInternal(5,s)},c.prototype.MANY6=function(s){this.manyInternal(6,s)},c.prototype.MANY7=function(s){this.manyInternal(7,s)},c.prototype.MANY8=function(s){this.manyInternal(8,s)},c.prototype.MANY9=function(s){this.manyInternal(9,s)},c.prototype.MANY_SEP=function(s){this.manySepFirstInternal(0,s)},c.prototype.MANY_SEP1=function(s){this.manySepFirstInternal(1,s)},c.prototype.MANY_SEP2=function(s){this.manySepFirstInternal(2,s)},c.prototype.MANY_SEP3=function(s){this.manySepFirstInternal(3,s)},c.prototype.MANY_SEP4=function(s){this.manySepFirstInternal(4,s)},c.prototype.MANY_SEP5=function(s){this.manySepFirstInternal(5,s)},c.prototype.MANY_SEP6=function(s){this.manySepFirstInternal(6,s)},c.prototype.MANY_SEP7=function(s){this.manySepFirstInternal(7,s)},c.prototype.MANY_SEP8=function(s){this.manySepFirstInternal(8,s)},c.prototype.MANY_SEP9=function(s){this.manySepFirstInternal(9,s)},c.prototype.AT_LEAST_ONE=function(s){this.atLeastOneInternal(0,s)},c.prototype.AT_LEAST_ONE1=function(s){return this.atLeastOneInternal(1,s)},c.prototype.AT_LEAST_ONE2=function(s){this.atLeastOneInternal(2,s)},c.prototype.AT_LEAST_ONE3=function(s){this.atLeastOneInternal(3,s)},c.prototype.AT_LEAST_ONE4=function(s){this.atLeastOneInternal(4,s)},c.prototype.AT_LEAST_ONE5=function(s){this.atLeastOneInternal(5,s)},c.prototype.AT_LEAST_ONE6=function(s){this.atLeastOneInternal(6,s)},c.prototype.AT_LEAST_ONE7=function(s){this.atLeastOneInternal(7,s)},c.prototype.AT_LEAST_ONE8=function(s){this.atLeastOneInternal(8,s)},c.prototype.AT_LEAST_ONE9=function(s){this.atLeastOneInternal(9,s)},c.prototype.AT_LEAST_ONE_SEP=function(s){this.atLeastOneSepFirstInternal(0,s)},c.prototype.AT_LEAST_ONE_SEP1=function(s){this.atLeastOneSepFirstInternal(1,s)},c.prototype.AT_LEAST_ONE_SEP2=function(s){this.atLeastOneSepFirstInternal(2,s)},c.prototype.AT_LEAST_ONE_SEP3=function(s){this.atLeastOneSepFirstInternal(3,s)},c.prototype.AT_LEAST_ONE_SEP4=function(s){this.atLeastOneSepFirstInternal(4,s)},c.prototype.AT_LEAST_ONE_SEP5=function(s){this.atLeastOneSepFirstInternal(5,s)},c.prototype.AT_LEAST_ONE_SEP6=function(s){this.atLeastOneSepFirstInternal(6,s)},c.prototype.AT_LEAST_ONE_SEP7=function(s){this.atLeastOneSepFirstInternal(7,s)},c.prototype.AT_LEAST_ONE_SEP8=function(s){this.atLeastOneSepFirstInternal(8,s)},c.prototype.AT_LEAST_ONE_SEP9=function(s){this.atLeastOneSepFirstInternal(9,s)},c.prototype.RULE=function(s,f,h){if(h===void 0&&(h=i.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,s)){var g=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:s,grammarName:this.className}),p={message:g,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:s};this.definitionErrors.push(p)}this.definedRulesNames.push(s);var T=this.defineRule(s,f,h);return this[s]=T,T},c.prototype.OVERRIDE_RULE=function(s,f,h){h===void 0&&(h=i.DEFAULT_RULE_CONFIG);var g=[];g=g.concat(a.validateRuleIsOverridden(s,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(g);var p=this.defineRule(s,f,h);return this[s]=p,p},c.prototype.BACKTRACK=function(s,f){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return s.apply(this,f),!0}catch(g){if(t.isRecognitionException(g))return!1;throw g}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},c.prototype.getGAstProductions=function(){return this.gastProductionsCache},c.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},c})();n.RecognizerApi=u}),fi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerEngine=void 0;var e=xe(),t=Gt(),i=dt(),r=Rt(),a=vt(),o=Ye(),u=On(),c=nt(),s=ht(),f=xn(),h=(function(){function g(){}return g.prototype.initRecognizerEngine=function(p,T){if(this.className=f.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=s.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(T,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
168
+ `,type:o.REDUNDANT_METHOD,methodName:T});return p}n.validateRedundantMethods=f}),li=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TreeBuilder=void 0;var e=ai(),t=xe(),i=ci(),r=Ye(),a=(function(){function o(){}return o.prototype.initTreeBuilder=function(u){if(this.CST_STACK=[],this.outputCst=u.outputCst,this.nodeLocationTracking=t.has(u,"nodeLocationTracking")?u.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+u.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(u){u.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(u){u.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(u){u.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(u){var c=this.LA(1);u.location={startOffset:c.startOffset,startLine:c.startLine,startColumn:c.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(u,c){var s={name:u,children:{}};this.setInitialNodeLocation(s),this.CST_STACK.push(s)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(u){var c=this.LA(0),s=u.location;s.startOffset<=c.startOffset?(s.endOffset=c.endOffset,s.endLine=c.endLine,s.endColumn=c.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(u){var c=this.LA(0),s=u.location;s.startOffset<=c.startOffset?s.endOffset=c.endOffset:s.startOffset=NaN},o.prototype.cstPostTerminal=function(u,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(s,c,u),this.setNodeLocationFromToken(s.location,c)},o.prototype.cstPostNonTerminal=function(u,c){var s=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(s,c,u),this.setNodeLocationFromNode(s.location,u.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var u=i.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=u,u}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var u=i.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=u,u}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var u=this.RULE_STACK;return u[u.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var u=this.RULE_OCCURRENCE_STACK;return u[u.length-1]},o})();n.TreeBuilder=a}),ui=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.LexerAdapter=void 0;var e=Ye(),t=(function(){function i(){}return i.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(i.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),i.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},i.prototype.LA=function(r){var a=this.currIdx+r;return a<0||this.tokVectorLength<=a?e.END_OF_FILE:this.tokVector[a]},i.prototype.consumeToken=function(){this.currIdx++},i.prototype.exportLexerState=function(){return this.currIdx},i.prototype.importLexerState=function(r){this.currIdx=r},i.prototype.resetLexerState=function(){this.currIdx=-1},i.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},i.prototype.getLexerPosition=function(){return this.exportLexerState()},i})();n.LexerAdapter=t}),hi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerApi=void 0;var e=xe(),t=dt(),i=Ye(),r=Et(),a=Sn(),o=He(),u=(function(){function c(){}return c.prototype.ACTION=function(s){return s.call(this)},c.prototype.consume=function(s,f,h){return this.consumeInternal(f,s,h)},c.prototype.subrule=function(s,f,h){return this.subruleInternal(f,s,h)},c.prototype.option=function(s,f){return this.optionInternal(f,s)},c.prototype.or=function(s,f){return this.orInternal(f,s)},c.prototype.many=function(s,f){return this.manyInternal(s,f)},c.prototype.atLeastOne=function(s,f){return this.atLeastOneInternal(s,f)},c.prototype.CONSUME=function(s,f){return this.consumeInternal(s,0,f)},c.prototype.CONSUME1=function(s,f){return this.consumeInternal(s,1,f)},c.prototype.CONSUME2=function(s,f){return this.consumeInternal(s,2,f)},c.prototype.CONSUME3=function(s,f){return this.consumeInternal(s,3,f)},c.prototype.CONSUME4=function(s,f){return this.consumeInternal(s,4,f)},c.prototype.CONSUME5=function(s,f){return this.consumeInternal(s,5,f)},c.prototype.CONSUME6=function(s,f){return this.consumeInternal(s,6,f)},c.prototype.CONSUME7=function(s,f){return this.consumeInternal(s,7,f)},c.prototype.CONSUME8=function(s,f){return this.consumeInternal(s,8,f)},c.prototype.CONSUME9=function(s,f){return this.consumeInternal(s,9,f)},c.prototype.SUBRULE=function(s,f){return this.subruleInternal(s,0,f)},c.prototype.SUBRULE1=function(s,f){return this.subruleInternal(s,1,f)},c.prototype.SUBRULE2=function(s,f){return this.subruleInternal(s,2,f)},c.prototype.SUBRULE3=function(s,f){return this.subruleInternal(s,3,f)},c.prototype.SUBRULE4=function(s,f){return this.subruleInternal(s,4,f)},c.prototype.SUBRULE5=function(s,f){return this.subruleInternal(s,5,f)},c.prototype.SUBRULE6=function(s,f){return this.subruleInternal(s,6,f)},c.prototype.SUBRULE7=function(s,f){return this.subruleInternal(s,7,f)},c.prototype.SUBRULE8=function(s,f){return this.subruleInternal(s,8,f)},c.prototype.SUBRULE9=function(s,f){return this.subruleInternal(s,9,f)},c.prototype.OPTION=function(s){return this.optionInternal(s,0)},c.prototype.OPTION1=function(s){return this.optionInternal(s,1)},c.prototype.OPTION2=function(s){return this.optionInternal(s,2)},c.prototype.OPTION3=function(s){return this.optionInternal(s,3)},c.prototype.OPTION4=function(s){return this.optionInternal(s,4)},c.prototype.OPTION5=function(s){return this.optionInternal(s,5)},c.prototype.OPTION6=function(s){return this.optionInternal(s,6)},c.prototype.OPTION7=function(s){return this.optionInternal(s,7)},c.prototype.OPTION8=function(s){return this.optionInternal(s,8)},c.prototype.OPTION9=function(s){return this.optionInternal(s,9)},c.prototype.OR=function(s){return this.orInternal(s,0)},c.prototype.OR1=function(s){return this.orInternal(s,1)},c.prototype.OR2=function(s){return this.orInternal(s,2)},c.prototype.OR3=function(s){return this.orInternal(s,3)},c.prototype.OR4=function(s){return this.orInternal(s,4)},c.prototype.OR5=function(s){return this.orInternal(s,5)},c.prototype.OR6=function(s){return this.orInternal(s,6)},c.prototype.OR7=function(s){return this.orInternal(s,7)},c.prototype.OR8=function(s){return this.orInternal(s,8)},c.prototype.OR9=function(s){return this.orInternal(s,9)},c.prototype.MANY=function(s){this.manyInternal(0,s)},c.prototype.MANY1=function(s){this.manyInternal(1,s)},c.prototype.MANY2=function(s){this.manyInternal(2,s)},c.prototype.MANY3=function(s){this.manyInternal(3,s)},c.prototype.MANY4=function(s){this.manyInternal(4,s)},c.prototype.MANY5=function(s){this.manyInternal(5,s)},c.prototype.MANY6=function(s){this.manyInternal(6,s)},c.prototype.MANY7=function(s){this.manyInternal(7,s)},c.prototype.MANY8=function(s){this.manyInternal(8,s)},c.prototype.MANY9=function(s){this.manyInternal(9,s)},c.prototype.MANY_SEP=function(s){this.manySepFirstInternal(0,s)},c.prototype.MANY_SEP1=function(s){this.manySepFirstInternal(1,s)},c.prototype.MANY_SEP2=function(s){this.manySepFirstInternal(2,s)},c.prototype.MANY_SEP3=function(s){this.manySepFirstInternal(3,s)},c.prototype.MANY_SEP4=function(s){this.manySepFirstInternal(4,s)},c.prototype.MANY_SEP5=function(s){this.manySepFirstInternal(5,s)},c.prototype.MANY_SEP6=function(s){this.manySepFirstInternal(6,s)},c.prototype.MANY_SEP7=function(s){this.manySepFirstInternal(7,s)},c.prototype.MANY_SEP8=function(s){this.manySepFirstInternal(8,s)},c.prototype.MANY_SEP9=function(s){this.manySepFirstInternal(9,s)},c.prototype.AT_LEAST_ONE=function(s){this.atLeastOneInternal(0,s)},c.prototype.AT_LEAST_ONE1=function(s){return this.atLeastOneInternal(1,s)},c.prototype.AT_LEAST_ONE2=function(s){this.atLeastOneInternal(2,s)},c.prototype.AT_LEAST_ONE3=function(s){this.atLeastOneInternal(3,s)},c.prototype.AT_LEAST_ONE4=function(s){this.atLeastOneInternal(4,s)},c.prototype.AT_LEAST_ONE5=function(s){this.atLeastOneInternal(5,s)},c.prototype.AT_LEAST_ONE6=function(s){this.atLeastOneInternal(6,s)},c.prototype.AT_LEAST_ONE7=function(s){this.atLeastOneInternal(7,s)},c.prototype.AT_LEAST_ONE8=function(s){this.atLeastOneInternal(8,s)},c.prototype.AT_LEAST_ONE9=function(s){this.atLeastOneInternal(9,s)},c.prototype.AT_LEAST_ONE_SEP=function(s){this.atLeastOneSepFirstInternal(0,s)},c.prototype.AT_LEAST_ONE_SEP1=function(s){this.atLeastOneSepFirstInternal(1,s)},c.prototype.AT_LEAST_ONE_SEP2=function(s){this.atLeastOneSepFirstInternal(2,s)},c.prototype.AT_LEAST_ONE_SEP3=function(s){this.atLeastOneSepFirstInternal(3,s)},c.prototype.AT_LEAST_ONE_SEP4=function(s){this.atLeastOneSepFirstInternal(4,s)},c.prototype.AT_LEAST_ONE_SEP5=function(s){this.atLeastOneSepFirstInternal(5,s)},c.prototype.AT_LEAST_ONE_SEP6=function(s){this.atLeastOneSepFirstInternal(6,s)},c.prototype.AT_LEAST_ONE_SEP7=function(s){this.atLeastOneSepFirstInternal(7,s)},c.prototype.AT_LEAST_ONE_SEP8=function(s){this.atLeastOneSepFirstInternal(8,s)},c.prototype.AT_LEAST_ONE_SEP9=function(s){this.atLeastOneSepFirstInternal(9,s)},c.prototype.RULE=function(s,f,h){if(h===void 0&&(h=i.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,s)){var g=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:s,grammarName:this.className}),p={message:g,type:i.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:s};this.definitionErrors.push(p)}this.definedRulesNames.push(s);var T=this.defineRule(s,f,h);return this[s]=T,T},c.prototype.OVERRIDE_RULE=function(s,f,h){h===void 0&&(h=i.DEFAULT_RULE_CONFIG);var g=[];g=g.concat(a.validateRuleIsOverridden(s,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(g);var p=this.defineRule(s,f,h);return this[s]=p,p},c.prototype.BACKTRACK=function(s,f){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return s.apply(this,f),!0}catch(g){if(t.isRecognitionException(g))return!1;throw g}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},c.prototype.getGAstProductions=function(){return this.gastProductionsCache},c.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},c})();n.RecognizerApi=u}),fi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RecognizerEngine=void 0;var e=xe(),t=Bt(),i=dt(),r=Rt(),a=vt(),o=Ye(),u=On(),c=nt(),s=ht(),f=xn(),h=(function(){function g(){}return g.prototype.initRecognizerEngine=function(p,T){if(this.className=f.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=s.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(T,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
169
169
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
170
170
  For Further details.`);if(e.isArray(p)){if(e.isEmpty(p))throw Error(`A Token Vocabulary cannot be empty.
171
171
  Note that the first argument for the parser constructor
172
172
  is no longer a Token vector (since v4.0).`);if(typeof p[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
173
173
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
174
174
  For Further details.`)}if(e.isArray(p))this.tokensMap=e.reduce(p,function(y,v){return y[v.name]=v,y},{});else if(e.has(p,"modes")&&e.every(e.flatten(e.values(p.modes)),s.isTokenType)){var m=e.flatten(e.values(p.modes)),l=e.uniq(m);this.tokensMap=e.reduce(l,function(y,v){return y[v.name]=v,y},{})}else if(e.isObject(p))this.tokensMap=e.cloneObj(p);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=c.EOF;var d=e.every(e.values(p),function(y){return e.isEmpty(y.categoryMatches)});this.tokenMatcher=d?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher,s.augmentTokenTypes(e.values(this.tokensMap))},g.prototype.defineRule=function(p,T,m){if(this.selfAnalysisDone)throw Error("Grammar rule <"+p+`> may not be defined after the 'performSelfAnalysis' method has been called'
175
- Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var l=e.has(m,"resyncEnabled")?m.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,d=e.has(m,"recoveryValueFunc")?m.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,y=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[y]=p,this.fullRuleNameToShort[p]=y;function v(I){try{if(this.outputCst===!0){T.apply(this,I);var k=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(k),k}else return T.apply(this,I)}catch(H){return this.invokeRuleCatch(H,l,d)}finally{this.ruleFinallyStateUpdate()}}var E=function(I,k){return I===void 0&&(I=0),this.ruleInvocationStateUpdate(y,p,I),v.call(this,k)},S="ruleName";return E[S]=p,E.originalGrammarAction=T,E},g.prototype.invokeRuleCatch=function(p,T,m){var l=this.RULE_STACK.length===1,d=T&&!this.isBackTracking()&&this.recoveryEnabled;if(i.isRecognitionException(p)){var y=p;if(d){var v=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(v))if(y.resyncedTokens=this.reSyncTo(v),this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];return E.recoveredNode=!0,E}else return m();else{if(this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];E.recoveredNode=!0,y.partialCstResult=E}throw y}}else{if(l)return this.moveToTerminatedState(),m();throw y}}else throw p},g.prototype.optionInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OPTION_IDX,T);return this.optionInternalLogic(p,T,m)},g.prototype.optionInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(p.DEF!==void 0){if(y=p.DEF,v=p.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=p;if(d.call(this)===!0)return y.call(this)},g.prototype.atLeastOneInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,T,m)},g.prototype.atLeastOneInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=T;if(d.call(this)===!0)for(var S=this.doSingleRepetition(y);d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(y);else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY,T.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,T],d,t.AT_LEAST_ONE_IDX,p,a.NextTerminalAfterAtLeastOneWalker)},g.prototype.atLeastOneSepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,T,m)},g.prototype.atLeastOneSepFirstInternalLogic=function(p,T,m){var l=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterAtLeastOneSepWalker],E,t.AT_LEAST_ONE_SEP_IDX,p,a.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,T.ERR_MSG)},g.prototype.manyInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,T,m)},g.prototype.manyInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=T;for(var S=!0;d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(y);this.attemptInRepetitionRecovery(this.manyInternal,[p,T],d,t.MANY_IDX,p,a.NextTerminalAfterManyWalker,S)},g.prototype.manySepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,T,m)},g.prototype.manySepFirstInternalLogic=function(p,T,m){var l=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterManySepWalker],E,t.MANY_SEP_IDX,p,a.NextTerminalAfterManySepWalker)}},g.prototype.repetitionSepSecondInternal=function(p,T,m,l,d){for(;m();)this.CONSUME(T),l.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,T,m,l,d],m,t.AT_LEAST_ONE_SEP_IDX,p,d)},g.prototype.doSingleRepetition=function(p){var T=this.getLexerPosition();p.call(this);var m=this.getLexerPosition();return m>T},g.prototype.orInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OR_IDX,T),l=e.isArray(p)?p:p.DEF,d=this.getLaFuncFromCache(m),y=d.call(this,l);if(y!==void 0){var v=l[y];return v.ALT.call(this)}this.raiseNoAltException(T,p.ERR_MSG)},g.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),T=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new i.NotAllInputParsedException(T,p))}},g.prototype.subruleInternal=function(p,T,m){var l;try{var d=m!==void 0?m.ARGS:void 0;return l=p.call(this,T,d),this.cstPostNonTerminal(l,m!==void 0&&m.LABEL!==void 0?m.LABEL:p.ruleName),l}catch(y){this.subruleInternalError(y,m,p.ruleName)}},g.prototype.subruleInternalError=function(p,T,m){throw i.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,T!==void 0&&T.LABEL!==void 0?T.LABEL:m),delete p.partialCstResult),p},g.prototype.consumeInternal=function(p,T,m){var l;try{var d=this.LA(1);this.tokenMatcher(d,p)===!0?(this.consumeToken(),l=d):this.consumeInternalError(p,d,m)}catch(y){l=this.consumeInternalRecovery(p,T,y)}return this.cstPostTerminal(m!==void 0&&m.LABEL!==void 0?m.LABEL:p.name,l),l},g.prototype.consumeInternalError=function(p,T,m){var l,d=this.LA(0);throw m!==void 0&&m.ERR_MSG?l=m.ERR_MSG:l=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:T,previous:d,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new i.MismatchedTokenException(l,T,d))},g.prototype.consumeInternalRecovery=function(p,T,m){if(this.recoveryEnabled&&m.name==="MismatchedTokenException"&&!this.isBackTracking()){var l=this.getFollowsForInRuleRecovery(p,T);try{return this.tryInRuleRecovery(p,l)}catch(d){throw d.name===u.IN_RULE_RECOVERY_EXCEPTION?m:d}}else throw m},g.prototype.saveRecogState=function(){var p=this.errors,T=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:T,CST_STACK:this.CST_STACK}},g.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},g.prototype.ruleInvocationStateUpdate=function(p,T,m){this.RULE_OCCURRENCE_STACK.push(m),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(T,p)},g.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},g.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},g.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},g.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},g.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},g})();n.RecognizerEngine=h}),di=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorHandler=void 0;var e=dt(),t=xe(),i=Rt(),r=Ye(),a=(function(){function o(){}return o.prototype.initErrorHandler=function(u){this._errors=[],this.errorMessageProvider=t.has(u,"errorMessageProvider")?u.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(u){if(e.isRecognitionException(u))return u.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(u),u;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(u){this._errors=u},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(u,c,s){for(var f=this.getCurrRuleFullName(),h=this.getGAstProductions()[f],g=i.getLookaheadPathsForOptionalProd(u,h,c,this.maxLookahead),p=g[0],T=[],m=1;m<=this.maxLookahead;m++)T.push(this.LA(m));var l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:T,previous:this.LA(0),customUserDescription:s,ruleName:f});throw this.SAVE_ERROR(new e.EarlyExitException(l,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(u,c){for(var s=this.getCurrRuleFullName(),f=this.getGAstProductions()[s],h=i.getLookaheadPathsForOr(u,f,this.maxLookahead),g=[],p=1;p<=this.maxLookahead;p++)g.push(this.LA(p));var T=this.LA(0),m=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:g,previous:T,customUserDescription:c,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(m,this.LA(1),T))},o})();n.ErrorHandler=a}),pi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ContentAssist=void 0;var e=vt(),t=xe(),i=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(a,o){var u=this.gastProductionsCache[a];if(t.isUndefined(u))throw Error("Rule ->"+a+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([u],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(a){var o=t.first(a.ruleStack),u=this.getGAstProductions(),c=u[o],s=new e.NextAfterTokenWalker(c,a).startWalking();return s},r})();n.ContentAssist=i}),mi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GastRecorder=void 0;var e=xe(),t=He(),i=gt(),r=ht(),a=nt(),o=Ye(),u=Gt(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var s=!0,f=Math.pow(2,u.BITS_FOR_OCCURRENCE_IDX)-1,h=a.createToken({name:"RECORDING_PHASE_TOKEN",pattern:i.Lexer.NA});r.augmentTokenTypes([h]);var g=a.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
175
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var l=e.has(m,"resyncEnabled")?m.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,d=e.has(m,"recoveryValueFunc")?m.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,y=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[y]=p,this.fullRuleNameToShort[p]=y;function v(I){try{if(this.outputCst===!0){T.apply(this,I);var k=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(k),k}else return T.apply(this,I)}catch(H){return this.invokeRuleCatch(H,l,d)}finally{this.ruleFinallyStateUpdate()}}var E=function(I,k){return I===void 0&&(I=0),this.ruleInvocationStateUpdate(y,p,I),v.call(this,k)},S="ruleName";return E[S]=p,E.originalGrammarAction=T,E},g.prototype.invokeRuleCatch=function(p,T,m){var l=this.RULE_STACK.length===1,d=T&&!this.isBackTracking()&&this.recoveryEnabled;if(i.isRecognitionException(p)){var y=p;if(d){var v=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(v))if(y.resyncedTokens=this.reSyncTo(v),this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];return E.recoveredNode=!0,E}else return m();else{if(this.outputCst){var E=this.CST_STACK[this.CST_STACK.length-1];E.recoveredNode=!0,y.partialCstResult=E}throw y}}else{if(l)return this.moveToTerminatedState(),m();throw y}}else throw p},g.prototype.optionInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OPTION_IDX,T);return this.optionInternalLogic(p,T,m)},g.prototype.optionInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(p.DEF!==void 0){if(y=p.DEF,v=p.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=p;if(d.call(this)===!0)return y.call(this)},g.prototype.atLeastOneInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,p);return this.atLeastOneInternalLogic(p,T,m)},g.prototype.atLeastOneInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=T;if(d.call(this)===!0)for(var S=this.doSingleRepetition(y);d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(y);else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY,T.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[p,T],d,t.AT_LEAST_ONE_IDX,p,a.NextTerminalAfterAtLeastOneWalker)},g.prototype.atLeastOneSepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,p);this.atLeastOneSepFirstInternalLogic(p,T,m)},g.prototype.atLeastOneSepFirstInternalLogic=function(p,T,m){var l=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterAtLeastOneSepWalker],E,t.AT_LEAST_ONE_SEP_IDX,p,a.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(p,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,T.ERR_MSG)},g.prototype.manyInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_IDX,p);return this.manyInternalLogic(p,T,m)},g.prototype.manyInternalLogic=function(p,T,m){var l=this,d=this.getLaFuncFromCache(m),y,v;if(T.DEF!==void 0){if(y=T.DEF,v=T.GATE,v!==void 0){var E=d;d=function(){return v.call(l)&&E.call(l)}}}else y=T;for(var S=!0;d.call(this)===!0&&S===!0;)S=this.doSingleRepetition(y);this.attemptInRepetitionRecovery(this.manyInternal,[p,T],d,t.MANY_IDX,p,a.NextTerminalAfterManyWalker,S)},g.prototype.manySepFirstInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,p);this.manySepFirstInternalLogic(p,T,m)},g.prototype.manySepFirstInternalLogic=function(p,T,m){var l=this,d=T.DEF,y=T.SEP,v=this.getLaFuncFromCache(m);if(v.call(this)===!0){d.call(this);for(var E=function(){return l.tokenMatcher(l.LA(1),y)};this.tokenMatcher(this.LA(1),y)===!0;)this.CONSUME(y),d.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,y,E,d,a.NextTerminalAfterManySepWalker],E,t.MANY_SEP_IDX,p,a.NextTerminalAfterManySepWalker)}},g.prototype.repetitionSepSecondInternal=function(p,T,m,l,d){for(;m();)this.CONSUME(T),l.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[p,T,m,l,d],m,t.AT_LEAST_ONE_SEP_IDX,p,d)},g.prototype.doSingleRepetition=function(p){var T=this.getLexerPosition();p.call(this);var m=this.getLexerPosition();return m>T},g.prototype.orInternal=function(p,T){var m=this.getKeyForAutomaticLookahead(t.OR_IDX,T),l=e.isArray(p)?p:p.DEF,d=this.getLaFuncFromCache(m),y=d.call(this,l);if(y!==void 0){var v=l[y];return v.ALT.call(this)}this.raiseNoAltException(T,p.ERR_MSG)},g.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var p=this.LA(1),T=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:p,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new i.NotAllInputParsedException(T,p))}},g.prototype.subruleInternal=function(p,T,m){var l;try{var d=m!==void 0?m.ARGS:void 0;return l=p.call(this,T,d),this.cstPostNonTerminal(l,m!==void 0&&m.LABEL!==void 0?m.LABEL:p.ruleName),l}catch(y){this.subruleInternalError(y,m,p.ruleName)}},g.prototype.subruleInternalError=function(p,T,m){throw i.isRecognitionException(p)&&p.partialCstResult!==void 0&&(this.cstPostNonTerminal(p.partialCstResult,T!==void 0&&T.LABEL!==void 0?T.LABEL:m),delete p.partialCstResult),p},g.prototype.consumeInternal=function(p,T,m){var l;try{var d=this.LA(1);this.tokenMatcher(d,p)===!0?(this.consumeToken(),l=d):this.consumeInternalError(p,d,m)}catch(y){l=this.consumeInternalRecovery(p,T,y)}return this.cstPostTerminal(m!==void 0&&m.LABEL!==void 0?m.LABEL:p.name,l),l},g.prototype.consumeInternalError=function(p,T,m){var l,d=this.LA(0);throw m!==void 0&&m.ERR_MSG?l=m.ERR_MSG:l=this.errorMessageProvider.buildMismatchTokenMessage({expected:p,actual:T,previous:d,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new i.MismatchedTokenException(l,T,d))},g.prototype.consumeInternalRecovery=function(p,T,m){if(this.recoveryEnabled&&m.name==="MismatchedTokenException"&&!this.isBackTracking()){var l=this.getFollowsForInRuleRecovery(p,T);try{return this.tryInRuleRecovery(p,l)}catch(d){throw d.name===u.IN_RULE_RECOVERY_EXCEPTION?m:d}}else throw m},g.prototype.saveRecogState=function(){var p=this.errors,T=e.cloneArr(this.RULE_STACK);return{errors:p,lexerState:this.exportLexerState(),RULE_STACK:T,CST_STACK:this.CST_STACK}},g.prototype.reloadRecogState=function(p){this.errors=p.errors,this.importLexerState(p.lexerState),this.RULE_STACK=p.RULE_STACK},g.prototype.ruleInvocationStateUpdate=function(p,T,m){this.RULE_OCCURRENCE_STACK.push(m),this.RULE_STACK.push(p),this.cstInvocationStateUpdate(T,p)},g.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},g.prototype.getCurrRuleFullName=function(){var p=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[p]},g.prototype.shortRuleNameToFullName=function(p){return this.shortRuleNameToFull[p]},g.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},g.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},g})();n.RecognizerEngine=h}),di=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorHandler=void 0;var e=dt(),t=xe(),i=Rt(),r=Ye(),a=(function(){function o(){}return o.prototype.initErrorHandler=function(u){this._errors=[],this.errorMessageProvider=t.has(u,"errorMessageProvider")?u.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(u){if(e.isRecognitionException(u))return u.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(u),u;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(u){this._errors=u},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(u,c,s){for(var f=this.getCurrRuleFullName(),h=this.getGAstProductions()[f],g=i.getLookaheadPathsForOptionalProd(u,h,c,this.maxLookahead),p=g[0],T=[],m=1;m<=this.maxLookahead;m++)T.push(this.LA(m));var l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:p,actual:T,previous:this.LA(0),customUserDescription:s,ruleName:f});throw this.SAVE_ERROR(new e.EarlyExitException(l,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(u,c){for(var s=this.getCurrRuleFullName(),f=this.getGAstProductions()[s],h=i.getLookaheadPathsForOr(u,f,this.maxLookahead),g=[],p=1;p<=this.maxLookahead;p++)g.push(this.LA(p));var T=this.LA(0),m=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:g,previous:T,customUserDescription:c,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(m,this.LA(1),T))},o})();n.ErrorHandler=a}),pi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ContentAssist=void 0;var e=vt(),t=xe(),i=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(a,o){var u=this.gastProductionsCache[a];if(t.isUndefined(u))throw Error("Rule ->"+a+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([u],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(a){var o=t.first(a.ruleStack),u=this.getGAstProductions(),c=u[o],s=new e.NextAfterTokenWalker(c,a).startWalking();return s},r})();n.ContentAssist=i}),mi=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.GastRecorder=void 0;var e=xe(),t=He(),i=gt(),r=ht(),a=nt(),o=Ye(),u=Bt(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var s=!0,f=Math.pow(2,u.BITS_FOR_OCCURRENCE_IDX)-1,h=a.createToken({name:"RECORDING_PHASE_TOKEN",pattern:i.Lexer.NA});r.augmentTokenTypes([h]);var g=a.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
176
176
  See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(g);var p={name:`This CSTNode indicates the Parser is in Recording Phase
177
177
  See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},T=(function(){function v(){}return v.prototype.initGastRecorder=function(E){this.recordingProdStack=[],this.RECORDING_PHASE=!1},v.prototype.enableRecording=function(){var E=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var S=function(k){var H=k>0?k:"";E["CONSUME"+H]=function(x,B){return this.consumeInternalRecord(x,k,B)},E["SUBRULE"+H]=function(x,B){return this.subruleInternalRecord(x,k,B)},E["OPTION"+H]=function(x){return this.optionInternalRecord(x,k)},E["OR"+H]=function(x){return this.orInternalRecord(x,k)},E["MANY"+H]=function(x){this.manyInternalRecord(k,x)},E["MANY_SEP"+H]=function(x){this.manySepFirstInternalRecord(k,x)},E["AT_LEAST_ONE"+H]=function(x){this.atLeastOneInternalRecord(k,x)},E["AT_LEAST_ONE_SEP"+H]=function(x){this.atLeastOneSepFirstInternalRecord(k,x)}},I=0;I<10;I++)S(I);E.consume=function(k,H,x){return this.consumeInternalRecord(H,k,x)},E.subrule=function(k,H,x){return this.subruleInternalRecord(H,k,x)},E.option=function(k,H){return this.optionInternalRecord(H,k)},E.or=function(k,H){return this.orInternalRecord(H,k)},E.many=function(k,H){this.manyInternalRecord(k,H)},E.atLeastOne=function(k,H){this.atLeastOneInternalRecord(k,H)},E.ACTION=E.ACTION_RECORD,E.BACKTRACK=E.BACKTRACK_RECORD,E.LA=E.LA_RECORD})},v.prototype.disableRecording=function(){var E=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var S=0;S<10;S++){var I=S>0?S:"";delete E["CONSUME"+I],delete E["SUBRULE"+I],delete E["OPTION"+I],delete E["OR"+I],delete E["MANY"+I],delete E["MANY_SEP"+I],delete E["AT_LEAST_ONE"+I],delete E["AT_LEAST_ONE_SEP"+I]}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})},v.prototype.ACTION_RECORD=function(E){},v.prototype.BACKTRACK_RECORD=function(E,S){return function(){return!0}},v.prototype.LA_RECORD=function(E){return o.END_OF_FILE},v.prototype.topLevelRuleRecord=function(E,S){try{var I=new t.Rule({definition:[],name:E});return I.name=E,this.recordingProdStack.push(I),S.call(this),this.recordingProdStack.pop(),I}catch(k){if(k.KNOWN_RECORDER_ERROR!==!0)try{k.message=k.message+`
178
178
  This error was thrown during the "grammar recording phase" For more info see:
@@ -216,5 +216,5 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
216
216
  `;return f+h+g+p+T+m}n.createSyntaxDiagramsCode=t}),Ei=ve(n=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Parser=n.createSyntaxDiagramsCode=n.clearCache=n.GAstVisitor=n.serializeProduction=n.serializeGrammar=n.Terminal=n.Rule=n.RepetitionWithSeparator=n.RepetitionMandatoryWithSeparator=n.RepetitionMandatory=n.Repetition=n.Option=n.NonTerminal=n.Alternative=n.Alternation=n.defaultLexerErrorProvider=n.NoViableAltException=n.NotAllInputParsedException=n.MismatchedTokenException=n.isRecognitionException=n.EarlyExitException=n.defaultParserErrorProvider=n.tokenName=n.tokenMatcher=n.tokenLabel=n.EOF=n.createTokenInstance=n.createToken=n.LexerDefinitionErrorType=n.Lexer=n.EMPTY_ALT=n.ParserDefinitionErrorType=n.EmbeddedActionsParser=n.CstParser=n.VERSION=void 0;var e=Rn();Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=Ye();Object.defineProperty(n,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(n,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(n,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(n,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var i=gt();Object.defineProperty(n,"Lexer",{enumerable:!0,get:function(){return i.Lexer}}),Object.defineProperty(n,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return i.LexerDefinitionErrorType}});var r=nt();Object.defineProperty(n,"createToken",{enumerable:!0,get:function(){return r.createToken}}),Object.defineProperty(n,"createTokenInstance",{enumerable:!0,get:function(){return r.createTokenInstance}}),Object.defineProperty(n,"EOF",{enumerable:!0,get:function(){return r.EOF}}),Object.defineProperty(n,"tokenLabel",{enumerable:!0,get:function(){return r.tokenLabel}}),Object.defineProperty(n,"tokenMatcher",{enumerable:!0,get:function(){return r.tokenMatcher}}),Object.defineProperty(n,"tokenName",{enumerable:!0,get:function(){return r.tokenName}});var a=Et();Object.defineProperty(n,"defaultParserErrorProvider",{enumerable:!0,get:function(){return a.defaultParserErrorProvider}});var o=dt();Object.defineProperty(n,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(n,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(n,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(n,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(n,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var u=_n();Object.defineProperty(n,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return u.defaultLexerErrorProvider}});var c=He();Object.defineProperty(n,"Alternation",{enumerable:!0,get:function(){return c.Alternation}}),Object.defineProperty(n,"Alternative",{enumerable:!0,get:function(){return c.Alternative}}),Object.defineProperty(n,"NonTerminal",{enumerable:!0,get:function(){return c.NonTerminal}}),Object.defineProperty(n,"Option",{enumerable:!0,get:function(){return c.Option}}),Object.defineProperty(n,"Repetition",{enumerable:!0,get:function(){return c.Repetition}}),Object.defineProperty(n,"RepetitionMandatory",{enumerable:!0,get:function(){return c.RepetitionMandatory}}),Object.defineProperty(n,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return c.RepetitionMandatoryWithSeparator}}),Object.defineProperty(n,"RepetitionWithSeparator",{enumerable:!0,get:function(){return c.RepetitionWithSeparator}}),Object.defineProperty(n,"Rule",{enumerable:!0,get:function(){return c.Rule}}),Object.defineProperty(n,"Terminal",{enumerable:!0,get:function(){return c.Terminal}});var s=He();Object.defineProperty(n,"serializeGrammar",{enumerable:!0,get:function(){return s.serializeGrammar}}),Object.defineProperty(n,"serializeProduction",{enumerable:!0,get:function(){return s.serializeProduction}});var f=ft();Object.defineProperty(n,"GAstVisitor",{enumerable:!0,get:function(){return f.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
217
217
  It performs no action other than printing this message.
218
218
  Please avoid using it as it will be completely removed in the future`)}n.clearCache=h;var g=Ti();Object.defineProperty(n,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return g.createSyntaxDiagramsCode}});var p=(function(){function T(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
219
- See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return T})();n.Parser=p});const at=Ei();class vi extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const a=this,o=a.path===""?R.LoaderUtils.extractUrlBase(e):a.path,u=new R.FileLoader(a.manager);u.setPath(a.path),u.setRequestHeader(a.requestHeader),u.setWithCredentials(a.withCredentials),u.load(e,function(c){try{t(a.parse(c,o))}catch(s){r?r(s):console.error(s),a.manager.itemError(e)}},i,r)}parse(e,t){const i={};function r(b){const A=a(),_=new Ri(A.tokens),N=new _i(A.tokenVocabulary),L=o(N.getBaseCstVisitorConstructor()),w=_.lex(b);N.input=w.tokens;const D=N.vrml();if(N.errors.length>0)throw console.error(N.errors),Error("THREE.VRMLLoader2: Parsing errors detected.");return L.visit(D)}function a(){const b=at.createToken,A=b({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]*/}),_=b({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\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:A}),N=["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"],L=b({name:"Version",pattern:/#VRML.*/,longer_alt:_}),w=b({name:"NodeName",pattern:new RegExp(N.join("|")),longer_alt:_}),D=b({name:"DEF",pattern:/DEF/,longer_alt:_}),j=b({name:"USE",pattern:/USE/,longer_alt:_}),V=b({name:"ROUTE",pattern:/ROUTE/,longer_alt:_}),Z=b({name:"TO",pattern:/TO/,longer_alt:_}),re=b({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),ge=b({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),Oe=b({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),Fe=b({name:"TrueLiteral",pattern:/TRUE/}),Ie=b({name:"FalseLiteral",pattern:/FALSE/}),Ee=b({name:"NullLiteral",pattern:/NULL/}),Re=b({name:"LSquare",pattern:/\[/}),Ne=b({name:"RSquare",pattern:/]/}),Me=b({name:"LCurly",pattern:/{/}),Se=b({name:"RCurly",pattern:/}/}),De=b({name:"Comment",pattern:/#.*/,group:at.Lexer.SKIPPED}),Ge=[b({name:"WhiteSpace",pattern:/[ ,\s]/,group:at.Lexer.SKIPPED}),w,D,j,V,Z,Fe,Ie,Ee,L,_,A,re,ge,Oe,Re,Ne,Me,Se,De],ze={};for(let Le=0,ue=Ge.length;Le<ue;Le++){const he=Ge[Le];ze[he.name]=he}return{tokens:Ge,tokenVocabulary:ze}}function o(b){class A extends b{constructor(){super(),this.validateVisitor()}vrml(L){const w={version:this.visit(L.version),nodes:[],routes:[]};for(let D=0,j=L.node.length;D<j;D++){const V=L.node[D];w.nodes.push(this.visit(V))}if(L.route)for(let D=0,j=L.route.length;D<j;D++){const V=L.route[D];w.routes.push(this.visit(V))}return w}version(L){return L.Version[0].image}node(L){const w={name:L.NodeName[0].image,fields:[]};if(L.field)for(let D=0,j=L.field.length;D<j;D++){const V=L.field[D];w.fields.push(this.visit(V))}return L.def&&(w.DEF=this.visit(L.def[0])),w}field(L){const w={name:L.Identifier[0].image,type:null,values:null};let D;return L.singleFieldValue&&(D=this.visit(L.singleFieldValue[0])),L.multiFieldValue&&(D=this.visit(L.multiFieldValue[0])),w.type=D.type,w.values=D.values,w}def(L){return(L.Identifier||L.NodeName)[0].image}use(L){return{USE:(L.Identifier||L.NodeName)[0].image}}singleFieldValue(L){return _(this,L)}multiFieldValue(L){return _(this,L)}route(L){return{FROM:L.RouteIdentifier[0].image,TO:L.RouteIdentifier[1].image}}}function _(N,L){const w={type:null,values:[]};if(L.node){w.type="node";for(let D=0,j=L.node.length;D<j;D++){const V=L.node[D];w.values.push(N.visit(V))}}if(L.use){w.type="use";for(let D=0,j=L.use.length;D<j;D++){const V=L.use[D];w.values.push(N.visit(V))}}if(L.StringLiteral){w.type="string";for(let D=0,j=L.StringLiteral.length;D<j;D++){const V=L.StringLiteral[D];w.values.push(V.image.replace(/'|"/g,""))}}if(L.NumberLiteral){w.type="number";for(let D=0,j=L.NumberLiteral.length;D<j;D++){const V=L.NumberLiteral[D];w.values.push(parseFloat(V.image))}}if(L.HexLiteral){w.type="hex";for(let D=0,j=L.HexLiteral.length;D<j;D++){const V=L.HexLiteral[D];w.values.push(V.image)}}if(L.TrueLiteral){w.type="boolean";for(let D=0,j=L.TrueLiteral.length;D<j;D++)L.TrueLiteral[D].image==="TRUE"&&w.values.push(!0)}if(L.FalseLiteral){w.type="boolean";for(let D=0,j=L.FalseLiteral.length;D<j;D++)L.FalseLiteral[D].image==="FALSE"&&w.values.push(!1)}return L.NullLiteral&&(w.type="null",L.NullLiteral.forEach(function(){w.values.push(null)})),w}return new A}function u(b){const A=b.nodes,_=new R.Scene;for(let N=0,L=A.length;N<L;N++){const w=A[N];c(w)}for(let N=0,L=A.length;N<L;N++){const w=A[N],D=s(w);D instanceof R.Object3D&&_.add(D),w.name==="WorldInfo"&&(_.userData.worldInfo=D)}return _}function c(b){b.DEF&&(i[b.DEF]=b);const A=b.fields;for(let _=0,N=A.length;_<N;_++){const L=A[_];if(L.type==="node"){const w=L.values;for(let D=0,j=w.length;D<j;D++)c(w[D])}}}function s(b){return b.USE?Q(b.USE):(b.build!==void 0||(b.build=f(b)),b.build)}function f(b){const A=b.name;let _;switch(A){case"Anchor":case"Group":case"Transform":case"Collision":_=h(b);break;case"Background":_=g(b);break;case"Shape":_=p(b);break;case"Appearance":_=T(b);break;case"Material":_=m(b);break;case"ImageTexture":_=v(b);break;case"PixelTexture":_=y(b);break;case"TextureTransform":_=E(b);break;case"IndexedFaceSet":_=k(b);break;case"IndexedLineSet":_=H(b);break;case"PointSet":_=x(b);break;case"Box":_=B(b);break;case"Cone":_=P(b);break;case"Cylinder":_=O(b);break;case"Sphere":_=M(b);break;case"ElevationGrid":_=C(b);break;case"Extrusion":_=X(b);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":_=S(b);break;case"WorldInfo":_=I(b);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.VRMLLoader2: Unknown node:",A);break}return _!==void 0&&b.DEF!==void 0&&_.hasOwnProperty("name")===!0&&(_.name=b.DEF),_}function h(b){const A=new R.Group,_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":W(j,A);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":const V=new R.Vector3(j[0],j[1],j[2]).normalize(),Z=j[3];A.quaternion.setFromAxisAngle(V,Z);break;case"scale":A.scale.set(j[0],j[1],j[2]);break;case"scaleOrientation":break;case"translation":A.position.set(j[0],j[1],j[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function g(b){const A=new R.Group;let _,N,L,w;const D=b.fields;for(let V=0,Z=D.length;V<Z;V++){const re=D[V],ge=re.name,Oe=re.values;switch(ge){case"groundAngle":_=Oe;break;case"groundColor":N=Oe;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":L=Oe;break;case"skyColor":w=Oe;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",ge);break}}const j=1e4;if(w){const V=new R.SphereGeometry(j,32,16),Z=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,depthWrite:!1,depthTest:!1});w.length>3?(z(V,j,L,F(w),!0),Z.vertexColors=!0):Z.color.setRGB(w[0],w[1],w[2],R.SRGBColorSpace);const re=new R.Mesh(V,Z);A.add(re)}if(N&&N.length>0){const V=new R.SphereGeometry(j,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),Z=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});z(V,j,_,F(N),!1);const re=new R.Mesh(V,Z);A.add(re)}return A.renderOrder=-1/0,A}function p(b){const A=b.fields;let _=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0}),N;for(let w=0,D=A.length;w<D;w++){const j=A[w],V=j.name,Z=j.values;switch(V){case"appearance":Z[0]!==null&&(_=s(Z[0]));break;case"geometry":Z[0]!==null&&(N=s(Z[0]));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}let L;if(N&&N.attributes.position){const w=N._type;if(w==="points"){const D=new R.PointsMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:_.opacity,transparent:_.transparent});N.attributes.color!==void 0?D.vertexColors=!0:_.isMeshPhongMaterial&&D.color.copy(_.emissive),L=new R.Points(N,D)}else if(w==="line"){const D=new R.LineBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:_.opacity,transparent:_.transparent});N.attributes.color!==void 0?D.vertexColors=!0:_.isMeshPhongMaterial&&D.color.copy(_.emissive),L=new R.LineSegments(N,D)}else N._solid!==void 0&&(_.side=N._solid?R.FrontSide:R.DoubleSide),N.attributes.color!==void 0&&(_.vertexColors=!0),L=new R.Mesh(N,_)}else L=new R.Object3D,L.visible=!1;return L}function T(b){let A=new R.MeshPhongMaterial,_;const N=b.fields;for(let L=0,w=N.length;L<w;L++){const D=N[L],j=D.name,V=D.values;switch(j){case"material":if(V[0]!==null){const re=s(V[0]);re.diffuseColor&&A.color.copy(re.diffuseColor),re.emissiveColor&&A.emissive.copy(re.emissiveColor),re.shininess&&(A.shininess=re.shininess),re.specularColor&&A.specular.copy(re.specularColor),re.transparency&&(A.opacity=1-re.transparency),re.transparency>0&&(A.transparent=!0)}else A=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":const Z=V[0];Z!==null&&(Z.name==="ImageTexture"||Z.name==="PixelTexture"||Z.USE)&&(A.map=s(Z));break;case"textureTransform":V[0]!==null&&(_=s(V[0]));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",j);break}}if(A.map){if(A.map.__type){switch(A.map.__type){case Xe.INTENSITY_ALPHA:A.opacity=1;break;case Xe.RGB:A.color.set(16777215);break;case Xe.RGBA:A.color.set(16777215),A.opacity=1;break}delete A.map.__type}_&&(A.map.center.copy(_.center),A.map.rotation=_.rotation,A.map.repeat.copy(_.scale),A.map.offset.copy(_.translation))}return A}function m(b){const A={},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"ambientIntensity":break;case"diffuseColor":A.diffuseColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"emissiveColor":A.emissiveColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"shininess":A.shininess=j[0];break;case"specularColor":A.specularColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"transparency":A.transparency=j[0];break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function l(b,A,_){let N;switch(A){case Xe.INTENSITY:N=parseInt(b),_.r=N,_.g=N,_.b=N,_.a=1;break;case Xe.INTENSITY_ALPHA:N=parseInt("0x"+b.substring(2,4)),_.r=N,_.g=N,_.b=N,_.a=parseInt("0x"+b.substring(4,6));break;case Xe.RGB:_.r=parseInt("0x"+b.substring(2,4)),_.g=parseInt("0x"+b.substring(4,6)),_.b=parseInt("0x"+b.substring(6,8)),_.a=1;break;case Xe.RGBA:_.r=parseInt("0x"+b.substring(2,4)),_.g=parseInt("0x"+b.substring(4,6)),_.b=parseInt("0x"+b.substring(6,8)),_.a=parseInt("0x"+b.substring(8,10));break}}function d(b){let A;switch(b){case 1:A=Xe.INTENSITY;break;case 2:A=Xe.INTENSITY_ALPHA;break;case 3:A=Xe.RGB;break;case 4:A=Xe.RGBA;break}return A}function y(b){let A,_=R.RepeatWrapping,N=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const j=L[w],V=j.name,Z=j.values;switch(V){case"image":const re=Z[0],ge=Z[1],Oe=Z[2],Fe=d(Oe),Ie=new Uint8Array(4*re*ge),Ee={r:0,g:0,b:0,a:0};for(let Re=3,Ne=0,Me=Z.length;Re<Me;Re++,Ne++){l(Z[Re],Fe,Ee);const Se=Ne*4;Ie[Se+0]=Ee.r,Ie[Se+1]=Ee.g,Ie[Se+2]=Ee.b,Ie[Se+3]=Ee.a}A=new R.DataTexture(Ie,re,ge),A.colorSpace=R.SRGBColorSpace,A.needsUpdate=!0,A.__type=Fe;break;case"repeatS":Z[0]===!1&&(_=R.ClampToEdgeWrapping);break;case"repeatT":Z[0]===!1&&(N=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return A&&(A.wrapS=_,A.wrapT=N),A}function v(b){let A,_=R.RepeatWrapping,N=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const j=L[w],V=j.name,Z=j.values;switch(V){case"url":const re=Z[0];re&&(A=ee.load(re));break;case"repeatS":Z[0]===!1&&(_=R.ClampToEdgeWrapping);break;case"repeatT":Z[0]===!1&&(N=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return A&&(A.wrapS=_,A.wrapT=N,A.colorSpace=R.SRGBColorSpace),A}function E(b){const A={center:new R.Vector2,rotation:new R.Vector2,scale:new R.Vector2,translation:new R.Vector2},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"center":A.center.set(j[0],j[1]);break;case"rotation":A.rotation=j[0];break;case"scale":A.scale.set(j[0],j[1]);break;case"translation":A.translation.set(j[0],j[1]);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function S(b){return b.fields[0].values}function I(b){const A={},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"title":A.title=j[0];break;case"info":A.info=j;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function k(b){let A,_,N,L,w=!0,D=!0,j=0,V,Z,re,ge,Oe=!0,Fe=!0;const Ie=b.fields;for(let Ce=0,Ge=Ie.length;Ce<Ge;Ce++){const ze=Ie[Ce],Le=ze.name,ue=ze.values;switch(Le){case"color":const he=ue[0];he!==null&&(A=s(he));break;case"coord":const oe=ue[0];oe!==null&&(_=s(oe));break;case"normal":const fe=ue[0];fe!==null&&(N=s(fe));break;case"texCoord":const me=ue[0];me!==null&&(L=s(me));break;case"ccw":w=ue[0];break;case"colorIndex":V=ue;break;case"colorPerVertex":Oe=ue[0];break;case"convex":break;case"coordIndex":Z=ue;break;case"creaseAngle":j=ue[0];break;case"normalIndex":re=ue;break;case"normalPerVertex":Fe=ue[0];break;case"solid":D=ue[0];break;case"texCoordIndex":ge=ue;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Le);break}}if(Z===void 0)return console.warn("THREE.VRMLLoader2: Missing coordIndex."),new R.BufferGeometry;const Ee=$(Z,w);let Re,Ne,Me;if(A){if(Oe===!0)if(V&&V.length>0){const Ce=$(V,w);Re=J(Ee,Ce,A,3)}else Re=ye(Ee,new R.Float32BufferAttribute(A,3));else if(V&&V.length>0){const Ce=ce(A,V),Ge=te(Ce,Z);Re=ie(Ee,Ge)}else{const Ce=te(A,Z);Re=ie(Ee,Ce)}Y(Re)}if(N)if(Fe===!0)if(re&&re.length>0){const Ce=$(re,w);Ne=J(Ee,Ce,N,3)}else Ne=ye(Ee,new R.Float32BufferAttribute(N,3));else if(re&&re.length>0){const Ce=ce(N,re),Ge=te(Ce,Z);Ne=ie(Ee,Ge)}else{const Ce=te(N,Z);Ne=ie(Ee,Ce)}else Ne=We(Ee,_,j);if(L)if(ge&&ge.length>0){const Ce=$(ge,w);Me=J(Ee,Ce,L,2)}else Me=ye(Ee,new R.Float32BufferAttribute(L,2));const Se=new R.BufferGeometry,De=ye(Ee,new R.Float32BufferAttribute(_,3));return Se.setAttribute("position",De),Se.setAttribute("normal",Ne),Re&&Se.setAttribute("color",Re),Me&&Se.setAttribute("uv",Me),Se._solid=D,Se._type="mesh",Se}function H(b){let A,_,N,L,w=!0;const D=b.fields;for(let ge=0,Oe=D.length;ge<Oe;ge++){const Fe=D[ge],Ie=Fe.name,Ee=Fe.values;switch(Ie){case"color":const Re=Ee[0];Re!==null&&(A=s(Re));break;case"coord":const Ne=Ee[0];Ne!==null&&(_=s(Ne));break;case"colorIndex":N=Ee;break;case"colorPerVertex":w=Ee[0];break;case"coordIndex":L=Ee;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Ie);break}}let j;const V=ae(L);if(A){if(w===!0)if(N.length>0){const ge=ae(N);j=J(V,ge,A,3)}else j=ye(V,new R.Float32BufferAttribute(A,3));else if(N.length>0){const ge=ce(A,N),Oe=le(ge,L);j=Te(V,Oe)}else{const ge=le(A,L);j=Te(V,ge)}Y(j)}const Z=new R.BufferGeometry,re=ye(V,new R.Float32BufferAttribute(_,3));return Z.setAttribute("position",re),j&&Z.setAttribute("color",j),Z._type="line",Z}function x(b){let A,_;const N=b.fields;for(let w=0,D=N.length;w<D;w++){const j=N[w],V=j.name,Z=j.values;switch(V){case"color":const re=Z[0];re!==null&&(A=s(re));break;case"coord":const ge=Z[0];ge!==null&&(_=s(ge));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}const L=new R.BufferGeometry;if(L.setAttribute("position",new R.Float32BufferAttribute(_,3)),A){const w=new R.Float32BufferAttribute(A,3);Y(w),L.setAttribute("color",w)}return L._type="points",L}function B(b){const A=new R.Vector3(2,2,2),_=b.fields;for(let L=0,w=_.length;L<w;L++){const D=_[L],j=D.name,V=D.values;j==="size"?(A.x=V[0],A.y=V[1],A.z=V[2]):console.warn("THREE.VRMLLoader2: Unknown field:",j)}return new R.BoxGeometry(A.x,A.y,A.z)}function P(b){let A=1,_=2,N=!1;const L=b.fields;for(let D=0,j=L.length;D<j;D++){const V=L[D],Z=V.name,re=V.values;switch(Z){case"bottom":N=!re[0];break;case"bottomRadius":A=re[0];break;case"height":_=re[0];break;case"side":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Z);break}}return new R.ConeGeometry(A,_,16,1,N)}function O(b){let A=1,_=2;const N=b.fields;for(let w=0,D=N.length;w<D;w++){const j=N[w],V=j.name,Z=j.values;switch(V){case"bottom":break;case"radius":A=Z[0];break;case"height":_=Z[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return new R.CylinderGeometry(A,A,_,16,1)}function M(b){let A=1;const _=b.fields;for(let L=0,w=_.length;L<w;L++){const D=_[L],j=D.name,V=D.values;j==="radius"?A=V[0]:console.warn("THREE.VRMLLoader2: Unknown field:",j)}return new R.SphereGeometry(A,16,16)}function C(b){let A,_,N,L,w=!0,D=!0,j=!0,V=!0,Z=0,re=2,ge=2,Oe=1,Fe=1;const Ie=b.fields;for(let ue=0,he=Ie.length;ue<he;ue++){const oe=Ie[ue],fe=oe.name,me=oe.values;switch(fe){case"color":const Pe=me[0];Pe!==null&&(A=s(Pe));break;case"normal":const Qe=me[0];Qe!==null&&(_=s(Qe));break;case"texCoord":const Ze=me[0];Ze!==null&&(N=s(Ze));break;case"height":L=me;break;case"ccw":V=me[0];break;case"colorPerVertex":w=me[0];break;case"creaseAngle":Z=me[0];break;case"normalPerVertex":D=me[0];break;case"solid":j=me[0];break;case"xDimension":re=me[0];break;case"xSpacing":Oe=me[0];break;case"zDimension":ge=me[0];break;case"zSpacing":Fe=me[0];break;default:console.warn("THREE.VRMLLoader2: Unknown field:",fe);break}}const Ee=[],Re=[],Ne=[],Me=[];for(let ue=0;ue<ge;ue++)for(let he=0;he<re;he++){const oe=ue*re+he,fe=Oe*ue,me=L[oe],Pe=Fe*he;if(Ee.push(fe,me,Pe),A&&w===!0){const Qe=A[oe*3+0],Ze=A[oe*3+1],At=A[oe*3+2];Ne.push(Qe,Ze,At)}if(_&&D===!0){const Qe=_[oe*3+0],Ze=_[oe*3+1],At=_[oe*3+2];Re.push(Qe,Ze,At)}if(N){const Qe=N[oe*2+0],Ze=N[oe*2+1];Me.push(Qe,Ze)}else Me.push(ue/(re-1),he/(ge-1))}const Se=[];for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*re,fe=ue+(he+1)*re,me=ue+1+(he+1)*re,Pe=ue+1+he*re;V===!0?(Se.push(oe,me,fe),Se.push(me,oe,Pe)):(Se.push(oe,fe,me),Se.push(me,Pe,oe))}const De=ye(Se,new R.Float32BufferAttribute(Ee,3)),Ce=ye(Se,new R.Float32BufferAttribute(Me,2));let Ge,ze;if(A){if(w===!1){for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*(re-1),fe=A[oe*3+0],me=A[oe*3+1],Pe=A[oe*3+2];Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe)}Ge=new R.Float32BufferAttribute(Ne,3)}else Ge=ye(Se,new R.Float32BufferAttribute(Ne,3));Y(Ge)}if(_)if(D===!1){for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*(re-1),fe=_[oe*3+0],me=_[oe*3+1],Pe=_[oe*3+2];Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe)}ze=new R.Float32BufferAttribute(Re,3)}else ze=ye(Se,new R.Float32BufferAttribute(Re,3));else ze=We(Se,Ee,Z);const Le=new R.BufferGeometry;return Le.setAttribute("position",De),Le.setAttribute("normal",ze),Le.setAttribute("uv",Ce),Ge&&Le.setAttribute("color",Ge),Le._solid=j,Le._type="mesh",Le}function X(b){let A=[1,1,1,-1,-1,-1,-1,1,1,1],_=[0,0,0,0,1,0],N,L,w=!0,D=!0,j=0,V=!0,Z=!0;const re=b.fields;for(let Le=0,ue=re.length;Le<ue;Le++){const he=re[Le],oe=he.name,fe=he.values;switch(oe){case"beginCap":w=fe[0];break;case"ccw":D=fe[0];break;case"convex":break;case"creaseAngle":j=fe[0];break;case"crossSection":A=fe;break;case"endCap":V=fe[0];break;case"orientation":L=fe;break;case"scale":N=fe;break;case"solid":Z=fe[0];break;case"spine":_=fe;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",oe);break}}const ge=A[0]===A[A.length-2]&&A[1]===A[A.length-1],Oe=[],Fe=new R.Vector3,Ie=new R.Vector3,Ee=new R.Vector3,Re=new R.Vector3,Ne=new R.Quaternion;for(let Le=0,ue=0,he=0,oe=_.length;Le<oe;Le+=3,ue+=2,he+=4){Fe.fromArray(_,Le),Ie.x=N?N[ue+0]:1,Ie.y=1,Ie.z=N?N[ue+1]:1,Ee.x=L?L[he+0]:0,Ee.y=L?L[he+1]:0,Ee.z=L?L[he+2]:1;const fe=L?L[he+3]:0;for(let me=0,Pe=A.length;me<Pe;me+=2)Re.x=A[me+0],Re.y=0,Re.z=A[me+1],Re.multiply(Ie),Ne.setFromAxisAngle(Ee,fe),Re.applyQuaternion(Ne),Re.add(Fe),Oe.push(Re.x,Re.y,Re.z)}const Me=[],Se=_.length/3,De=A.length/2;for(let Le=0;Le<Se-1;Le++)for(let ue=0;ue<De-1;ue++){const he=ue+Le*De;let oe=ue+1+Le*De;const fe=ue+(Le+1)*De;let me=ue+1+(Le+1)*De;ue===De-2&&ge===!0&&(oe=Le*De,me=(Le+1)*De),D===!0?(Me.push(he,oe,fe),Me.push(fe,oe,me)):(Me.push(he,fe,oe),Me.push(fe,me,oe))}if(w===!0||V===!0){const Le=[];for(let oe=0,fe=A.length;oe<fe;oe+=2)Le.push(new R.Vector2(A[oe],A[oe+1]));const ue=R.ShapeUtils.triangulateShape(Le,[]),he=[];for(let oe=0,fe=ue.length;oe<fe;oe++){const me=ue[oe];he.push(me[0],me[1],me[2])}if(w===!0)for(let oe=0,fe=he.length;oe<fe;oe+=3)D===!0?Me.push(he[oe+0],he[oe+1],he[oe+2]):Me.push(he[oe+0],he[oe+2],he[oe+1]);if(V===!0){const oe=De*(Se-1);for(let fe=0,me=he.length;fe<me;fe+=3)D===!0?Me.push(oe+he[fe+0],oe+he[fe+2],oe+he[fe+1]):Me.push(oe+he[fe+0],oe+he[fe+1],oe+he[fe+2])}}const Ce=ye(Me,new R.Float32BufferAttribute(Oe,3)),Ge=We(Me,Oe,j),ze=new R.BufferGeometry;return ze.setAttribute("position",Ce),ze.setAttribute("normal",Ge),ze._solid=Z,ze._type="mesh",ze}function Q(b){const A=i[b],_=s(A);return _.isObject3D||_.isMaterial?_.clone():_}function W(b,A){for(let _=0,N=b.length;_<N;_++){const L=s(b[_]);L instanceof R.Object3D&&A.add(L)}}function $(b,A){const _=[];let N=0;for(let L=0,w=b.length;L<w;L++){const D=b[N],j=b[L+(A?1:2)],V=b[L+(A?2:1)];_.push(D,j,V),(b[L+3]===-1||L+3>=w)&&(L+=3,N=L+1)}return _}function te(b,A){const _=[];let N=0;for(let L=0,w=A.length;L<w;L++){const D=N*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z),(A[L+3]===-1||L+3>=w)&&(L+=3,N++)}return _}function ce(b,A){const _=[];for(let N=0,L=A.length;N<L;N++){const D=A[N]*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z)}return _}function ae(b){const A=[];for(let _=0,N=b.length;_<N;_++){const L=b[_],w=b[_+1];A.push(L,w),(b[_+2]===-1||_+2>=N)&&(_+=2)}return A}function le(b,A){const _=[];let N=0;for(let L=0,w=A.length;L<w;L++){const D=N*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z),(A[L+2]===-1||L+2>=w)&&(L+=2,N++)}return _}const ne=new R.Vector3,pe=new R.Vector3,U=new R.Vector3,G=new R.Vector2,K=new R.Vector2,q=new R.Vector2;function J(b,A,_,N){const L=[];for(let w=0,D=b.length;w<D;w+=3){const j=A[w],V=A[w+1],Z=A[w+2];N===2?(G.fromArray(_,j*N),K.fromArray(_,V*N),q.fromArray(_,Z*N),L.push(G.x,G.y),L.push(K.x,K.y),L.push(q.x,q.y)):(ne.fromArray(_,j*N),pe.fromArray(_,V*N),U.fromArray(_,Z*N),L.push(ne.x,ne.y,ne.z),L.push(pe.x,pe.y,pe.z),L.push(U.x,U.y,U.z))}return new R.Float32BufferAttribute(L,N)}function ie(b,A){const _=[];for(let N=0,L=0,w=b.length;N<w;N+=3,L++)ne.fromArray(A,L*3),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(_,3)}function Te(b,A){const _=[];for(let N=0,L=0,w=b.length;N<w;N+=2,L++)ne.fromArray(A,L*3),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(_,3)}function ye(b,A){const _=A.array,N=A.itemSize,L=new _.constructor(b.length*N);let w=0,D=0;for(let j=0,V=b.length;j<V;j++){w=b[j]*N;for(let Z=0;Z<N;Z++)L[D++]=_[w++]}return new R.Float32BufferAttribute(L,N)}const we=new R.Vector3,Be=new R.Vector3;function We(b,A,_){const N=[],L={};for(let D=0,j=b.length;D<j;D+=3){const V=b[D],Z=b[D+1],re=b[D+2],ge=new bi(V,Z,re);ne.fromArray(A,V*3),pe.fromArray(A,Z*3),U.fromArray(A,re*3),Be.subVectors(U,pe),we.subVectors(ne,pe),Be.cross(we),Be.normalize(),ge.normal.copy(Be),L[V]===void 0&&(L[V]=[]),L[Z]===void 0&&(L[Z]=[]),L[re]===void 0&&(L[re]=[]),L[V].push(ge.normal),L[Z].push(ge.normal),L[re].push(ge.normal),N.push(ge)}const w=[];for(let D=0,j=N.length;D<j;D++){const V=N[D],Z=Ue(L[V.a],V.normal,_),re=Ue(L[V.b],V.normal,_),ge=Ue(L[V.c],V.normal,_);ne.fromArray(A,V.a*3),pe.fromArray(A,V.b*3),U.fromArray(A,V.c*3),w.push(Z.x,Z.y,Z.z),w.push(re.x,re.y,re.z),w.push(ge.x,ge.y,ge.z)}return new R.Float32BufferAttribute(w,3)}function Ue(b,A,_){const N=new R.Vector3;if(_===0)N.copy(A);else for(let L=0,w=b.length;L<w;L++)b[L].angleTo(A)<_&&N.add(b[L]);return N.normalize()}function F(b){const A=[];for(let _=0,N=b.length;_<N;_+=3)A.push(new R.Color(b[_],b[_+1],b[_+2]));return A}function Y(b){const A=new R.Color;for(let _=0;_<b.count;_++)A.fromBufferAttribute(b,_),R.ColorManagement.colorSpaceToWorking(A,R.SRGBColorSpace),b.setXYZ(_,A.r,A.g,A.b)}function z(b,A,_,N,L){const w=[],D=L===!0?0:Math.PI;for(let Oe=0,Fe=N.length;Oe<Fe;Oe++){let Ie=Oe===0?0:_[Oe-1];Ie=L===!0?Ie:D-Ie;const Ee=new R.Vector3;Ee.setFromSphericalCoords(A,Ie,0),w.push(Ee)}const j=b.index,V=b.attributes.position,Z=new R.BufferAttribute(new Float32Array(b.attributes.position.count*3),3),re=new R.Vector3,ge=new R.Color;for(let Oe=0;Oe<j.count;Oe++){const Fe=j.getX(Oe);re.fromBufferAttribute(V,Fe);let Ie,Ee,Re=1;for(let Se=1;Se<w.length;Se++){Ie=Se-1,Ee=Se;const De=w[Ie],Ce=w[Ee];if(L===!0){if(re.y<=De.y&&re.y>Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}else if(re.y>=De.y&&re.y<Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}const Ne=N[Ie],Me=N[Ee];ge.copy(Ne).lerp(Me,Re),R.ColorManagement.colorSpaceToWorking(ge,R.SRGBColorSpace),Z.setXYZ(Fe,ge.r,ge.g,ge.b)}b.setAttribute("color",Z)}const ee=new R.TextureLoader(this.manager);if(ee.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const de=r(e);return u(de)}}class Ri{constructor(e){this.lexer=new at.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 Ai=at.CstParser;class _i extends Ai{constructor(e){super(e);const t=this,i=e.Version,r=e.LCurly,a=e.RCurly,o=e.LSquare,u=e.RSquare,c=e.Identifier,s=e.RouteIdentifier,f=e.StringLiteral,h=e.HexLiteral,g=e.NumberLiteral,p=e.TrueLiteral,T=e.FalseLiteral,m=e.NullLiteral,l=e.DEF,d=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(i)}),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(a)}),t.RULE("field",function(){t.CONSUME(c),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(l),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("use",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(c)}},{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(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(T)}},{ALT:function(){t.CONSUME(m)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(m)}}])}),t.CONSUME(u)}),t.RULE("route",function(){t.CONSUME(y),t.CONSUME(s),t.CONSUME(v),t.CONSUME2(s)}),this.performSelfAnalysis()}}class bi{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.normal=new R.Vector3}}const Xe={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};class Li extends R.Loader{constructor(e){super(e),this.animateBonePositions=!0,this.animateBoneRotations=!0,this.animateBoneScales=!0}load(e,t,i,r){const a=this,o=new R.FileLoader(a.manager);o.setPath(a.path),o.setRequestHeader(a.requestHeader),o.setWithCredentials(a.withCredentials),o.load(e,function(u){try{t(a.parse(u))}catch(c){r?r(c):console.error(c),a.manager.itemError(e)}},i,r)}parse(e){function t(p){u(p)!=="HIERARCHY"&&console.error("THREE.BVHLoader2: HIERARCHY expected.");const T=[],m=r(p,u(p),T);u(p)!=="MOTION"&&console.error("THREE.BVHLoader2: MOTION expected.");let l=u(p).split(/[\s]+/);const d=parseInt(l[1]);isNaN(d)&&console.error("THREE.BVHLoader2: Failed to read number of frames."),l=u(p).split(/[\s]+/);const y=parseFloat(l[2]);isNaN(y)&&console.error("THREE.BVHLoader2: Failed to read frame time.");for(let v=0;v<d;v++)l=u(p).split(/[\s]+/),i(l,v*y,m);return T}function i(p,T,m){if(m.type==="ENDSITE")return;const l={time:T,position:new R.Vector3,rotation:new R.Quaternion,scale:new R.Vector3(1,1,1)};m.frames.push(l);const d=new R.Quaternion,y=new R.Vector3(1,0,0),v=new R.Vector3(0,1,0),E=new R.Vector3(0,0,1);for(let S=0;S<m.channels.length;S++)switch(m.channels[S]){case"Xposition":l.position.x=parseFloat(p.shift().trim());break;case"Yposition":l.position.y=parseFloat(p.shift().trim());break;case"Zposition":l.position.z=parseFloat(p.shift().trim());break;case"Xrotation":d.setFromAxisAngle(y,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Yrotation":d.setFromAxisAngle(v,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Zrotation":d.setFromAxisAngle(E,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Xscale":l.scale.x=parseFloat(p.shift().trim());break;case"Yscale":l.scale.y=parseFloat(p.shift().trim());break;case"Zscale":l.scale.z=parseFloat(p.shift().trim());break;default:console.warn("THREE.BVHLoader2: Invalid channel type.")}for(let S=0;S<m.children.length;S++)i(p,T,m.children[S])}function r(p,T,m){const l={name:"",type:"",frames:[]};m.push(l);let d=T.split(/[\s]+/);d[0].toUpperCase()==="END"&&d[1].toUpperCase()==="SITE"?(l.type="ENDSITE",l.name="ENDSITE"):(l.name=d[1],l.type=d[0].toUpperCase()),u(p)!=="{"&&console.error("THREE.BVHLoader2: Expected opening { after type & name"),d=u(p).split(/[\s]+/),d[0]!=="OFFSET"&&console.error("THREE.BVHLoader2: Expected OFFSET but got: "+d[0]),d.length!==4&&console.error("THREE.BVHLoader2: Invalid number of values for OFFSET.");const y=new R.Vector3(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]));if((isNaN(y.x)||isNaN(y.y)||isNaN(y.z))&&console.error("THREE.BVHLoader2: Invalid values of OFFSET."),l.offset=y,l.type!=="ENDSITE"){d=u(p).split(/[\s]+/),d[0]!=="CHANNELS"&&console.error("THREE.BVHLoader2: Expected CHANNELS definition.");const v=parseInt(d[1]);l.channels=d.splice(2,v),l.children=[]}for(;;){const v=u(p);if(v==="}")return l;l.children.push(r(p,v,m))}}function a(p,T){const m=new R.Bone;if(T.push(m),m.position.add(p.offset),m.name=p.name,p.type!=="ENDSITE")for(let l=0;l<p.children.length;l++)m.add(a(p.children[l],T));return m}function o(p){const T=[];for(let m=0;m<p.length;m++){const l=p[m];if(l.type==="ENDSITE")continue;const d=[],y=[],v=[],E=[];for(let S=0;S<l.frames.length;S++){const I=l.frames[S];d.push(I.time),y.push(I.position.x+l.offset.x),y.push(I.position.y+l.offset.y),y.push(I.position.z+l.offset.z),v.push(I.rotation.x),v.push(I.rotation.y),v.push(I.rotation.z),v.push(I.rotation.w),E.push(I.scale.x),E.push(I.scale.y),E.push(I.scale.z)}c.animateBonePositions&&T.push(new R.VectorKeyframeTrack(l.name+".position",d,y)),c.animateBoneRotations&&T.push(new R.QuaternionKeyframeTrack(l.name+".quaternion",d,v)),c.animateBoneScales&&T.push(new R.VectorKeyframeTrack(l.name+".scale",d,E))}return new R.AnimationClip("animation",-1,T)}function u(p){let T;for(;(T=p.shift().trim()).length===0;);return T}const c=this,s=e.split(/[\r\n]+/g),f=t(s),h=[];a(f[0],h);const g=o(f);return{skeleton:new R.Skeleton(h),clip:g}}}let pt;async function Si(n,e){return pt||(pt=new vi),pt.manager.setURLModifier(i=>(i.startsWith("./")&&(i=i.substring(2)),URL.createObjectURL(nr(n,i)))),await pt.loadAsync(e)}let Ot;async function Oi(n,e){Ot||(Ot=new Li);const t=Dt(n,e);return await Ot.parse(t)}function xi(n){const e=n.clip.clone(),t=n.skeleton.bones[0].clone(!0),i=[];t.traverse(a=>{a instanceof se.Bone&&i.push(a)});const r=new se.Skeleton(i);return r.calculateInverses(),{clip:e,skeleton:r}}class Ct{isDummy=!0;skeleton=new se.Skeleton([new se.Bone]);clip=new se.AnimationClip("dummy")}class st extends je{bvhs={};vrmls={};ready;viewActions;currentAction;comment=null;constructor(e){super(),this.viewActions={},this.currentAction={actionRoot:new se.Object3D,boneRoot:new se.Bone},this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}initMotion(){return new Mt(this)}async asyncInit(e){const t=await ln(e),i=new DOMParser,r=Dt(t,"CATALOG.XML"),a=i.parseFromString(r,"application/xml");if(a.querySelector("parsererror"))return console.error("Acerola3D.asyncInit(): CATALOG.XML parse error."),this;const o="http://acerola3d.sourceforge.jp/a3/catalog",u=a.getElementsByTagNameNS(o,"c");u[0]&&(this.comment=u[0].textContent);const c=a.getElementsByTagNameNS(o,"a"),s=[];for(const f of Array.from(c)){const h=f.getAttribute("an");if(h){const g=f.getAttribute("bvh");let p=null;if(g){const E=t.zipUrl+"!"+g;this.bvhs[E]?p=xi(this.bvhs[E]):(p=await Oi(t,g),this.bvhs[g]=p),p&&p.clip.tracks.forEach(S=>{S.setInterpolation(se.InterpolateDiscrete)})}else p=new Ct;const T=f.getAttribute("scale"),m=T?Number(T):1,l=f.getAttribute("offset"),d=new Ae;if(l){const E=l.split(" ");d.set(Number(E[0]),Number(E[1]),Number(E[2]))}const y={},v=f.getElementsByTagNameNS(o,"p");for(const E of Array.from(v)){const S=E.getAttribute("name"),I=E.getAttribute("wrl");if(S&&I){let k;const H=t.zipUrl+"!"+I;this.vrmls[H]?(k=this.vrmls[H].clone(!0),y[S]=k):(k=await Si(t,I),this.vrmls[H]=k,y[S]=k)}}s.push({name:h,bvh:p,scale:m,offset:d,parts:y})}}return this.generateViewActionsFromActionSeeds(s),this.motion instanceof Mt&&this.motion.myInitialize(s),this}generateViewActionsFromActionSeeds(e){this.viewActions={};for(const t of e){const i=new se.Object3D;if(i.position.set(t.offset.x,t.offset.y,t.offset.z),i.scale.set(t.scale,t.scale,t.scale),t.bvh instanceof Ct){for(const r of Object.values(t.parts))i.add(r);this.viewActions[t.name]={actionRoot:i,boneRoot:t.bvh.skeleton.bones[0].clone(!0)}}else{const r=t.bvh.skeleton.bones[0].clone(!0);i.add(r),In(r,t.parts),this.viewActions[t.name]={actionRoot:i,boneRoot:r}}i.traverse(r=>{r.userData.a3js={objectA3:this}})}}changeAction(e){this.object.remove(this.currentAction.actionRoot);const t=this.viewActions[e];this.object.add(t.actionRoot),this.currentAction=t}}function In(n,e){if(Hn(n)){const t=e[n.name];t&&n.add(t)}n.children&&n.children.forEach(t=>{In(t,e)})}class Mt extends tt{actionSeeds;motionActions;currentAction;isPaused;constructor(e){super(e),this.isPaused=!1,this.actionSeeds=[],this.motionActions={}}setObject(e){this.isPaused=!1,e instanceof st?(super.setObject(e),this.actionSeeds.length>0&&this.myInitialize([])):console.warn("Acerola3DMotion can set only Acerola3D object.")}myInitialize(e){if(!(this.objectA3 instanceof st))return;const t=[];for(const a of this.actionSeeds)t.push(a);for(const a of e)t.filter(o=>o.name===a.name).length===0&&t.push(a);this.objectA3.generateViewActionsFromActionSeeds(t),this.actionSeeds=t,this.motionActions={};for(const a of this.actionSeeds){if(a.bvh instanceof Ct){this.motionActions[a.name]={bvh:a.bvh};break}const o=this.objectA3.viewActions[a.name].boneRoot,u=new se.AnimationMixer(o),c=u.clipAction(a.bvh.clip),s={bvh:a.bvh,mixer:u,clipAction:c};this.motionActions[a.name]=s}const i=this.actionSeeds[0].name;this.objectA3.changeAction(i);const r=this.motionActions[i];r.clipAction?.play(),this.currentAction=r}detachObject(e){if(!(this.objectA3 instanceof st))return;const t=this.actionSeeds[0].name;for(const i of this.actionSeeds){const r=this.motionActions[i.name];r.mixer?.stopAllAction();const a=this.objectA3.viewActions[i.name].boneRoot;a&&r.mixer?.uncacheRoot(a),delete this.motionActions[i.name]}this.objectA3.changeAction(t),super.detachObject(e)}update(e){super.update(e),this.currentAction&&!this.isPaused&&this.currentAction.mixer&&this.currentAction.mixer?.update(e)}controlMotion(e){if(!(this.objectA3 instanceof st))return;const t=this.motionActions[e];t&&(this.currentAction&&this.currentAction.clipAction?.stop(),this.objectA3.changeAction(e),t.clipAction?.play(),this.currentAction=t)}setPause(e){this.isPaused=e}setTime(e){this.currentAction?.mixer?.setTime(e)}}class Ii extends je{constructor(e){super(e)}initObject(e){return e}}class Ni extends je{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new se.BoxGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new se.MeshStandardMaterial({color:a});return new se.Mesh(r,o)}}class wi extends je{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new se.SphereGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new se.MeshStandardMaterial({color:a});return new se.Mesh(r,o)}}class ki extends je{constructor(e){super(e)}initObject(e){return new un(e)}}exports.Acerola3D=st;exports.Acerola3DMotion=Mt;exports.Box=Ni;exports.Camera=sn;exports.Canvas=fn;exports.ControllerBase=an;exports.GLTF=En;exports.GLTFMotion=vn;exports.GeneralCamera=ut;exports.HTML=ki;exports.Motion=tt;exports.ObjectA3=je;exports.OrbitController=cn;exports.Quat=ke;exports.RapierPhysicsEngine=lt;exports.Scene=on;exports.Sound=$e;exports.Sphere=wi;exports.Test=ur;exports.Text3D=gr;exports.ThreeJS=Ii;exports.Vec3=Ae;exports.ViewBase=Ft;exports.Window=dn;exports.asyncSleep=tr;exports.deepMerge=yt;exports.getQuatOfLookAt=ct;exports.initFont=yr;exports.initPhysics=$n;exports.initSound=sr;exports.vec3EulerToQuat=rn;
219
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return T})();n.Parser=p});const at=Ei();class vi extends R.Loader{constructor(e){super(e)}load(e,t,i,r){const a=this,o=a.path===""?R.LoaderUtils.extractUrlBase(e):a.path,u=new R.FileLoader(a.manager);u.setPath(a.path),u.setRequestHeader(a.requestHeader),u.setWithCredentials(a.withCredentials),u.load(e,function(c){try{t(a.parse(c,o))}catch(s){r?r(s):console.error(s),a.manager.itemError(e)}},i,r)}parse(e,t){const i={};function r(b){const A=a(),_=new Ri(A.tokens),N=new _i(A.tokenVocabulary),L=o(N.getBaseCstVisitorConstructor()),w=_.lex(b);N.input=w.tokens;const D=N.vrml();if(N.errors.length>0)throw console.error(N.errors),Error("THREE.VRMLLoader2: Parsing errors detected.");return L.visit(D)}function a(){const b=at.createToken,A=b({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]*/}),_=b({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\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:A}),N=["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"],L=b({name:"Version",pattern:/#VRML.*/,longer_alt:_}),w=b({name:"NodeName",pattern:new RegExp(N.join("|")),longer_alt:_}),D=b({name:"DEF",pattern:/DEF/,longer_alt:_}),j=b({name:"USE",pattern:/USE/,longer_alt:_}),V=b({name:"ROUTE",pattern:/ROUTE/,longer_alt:_}),Z=b({name:"TO",pattern:/TO/,longer_alt:_}),re=b({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),ge=b({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),Oe=b({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),Fe=b({name:"TrueLiteral",pattern:/TRUE/}),Ie=b({name:"FalseLiteral",pattern:/FALSE/}),Ee=b({name:"NullLiteral",pattern:/NULL/}),Re=b({name:"LSquare",pattern:/\[/}),Ne=b({name:"RSquare",pattern:/]/}),Me=b({name:"LCurly",pattern:/{/}),Se=b({name:"RCurly",pattern:/}/}),De=b({name:"Comment",pattern:/#.*/,group:at.Lexer.SKIPPED}),Ge=[b({name:"WhiteSpace",pattern:/[ ,\s]/,group:at.Lexer.SKIPPED}),w,D,j,V,Z,Fe,Ie,Ee,L,_,A,re,ge,Oe,Re,Ne,Me,Se,De],ze={};for(let Le=0,ue=Ge.length;Le<ue;Le++){const he=Ge[Le];ze[he.name]=he}return{tokens:Ge,tokenVocabulary:ze}}function o(b){class A extends b{constructor(){super(),this.validateVisitor()}vrml(L){const w={version:this.visit(L.version),nodes:[],routes:[]};for(let D=0,j=L.node.length;D<j;D++){const V=L.node[D];w.nodes.push(this.visit(V))}if(L.route)for(let D=0,j=L.route.length;D<j;D++){const V=L.route[D];w.routes.push(this.visit(V))}return w}version(L){return L.Version[0].image}node(L){const w={name:L.NodeName[0].image,fields:[]};if(L.field)for(let D=0,j=L.field.length;D<j;D++){const V=L.field[D];w.fields.push(this.visit(V))}return L.def&&(w.DEF=this.visit(L.def[0])),w}field(L){const w={name:L.Identifier[0].image,type:null,values:null};let D;return L.singleFieldValue&&(D=this.visit(L.singleFieldValue[0])),L.multiFieldValue&&(D=this.visit(L.multiFieldValue[0])),w.type=D.type,w.values=D.values,w}def(L){return(L.Identifier||L.NodeName)[0].image}use(L){return{USE:(L.Identifier||L.NodeName)[0].image}}singleFieldValue(L){return _(this,L)}multiFieldValue(L){return _(this,L)}route(L){return{FROM:L.RouteIdentifier[0].image,TO:L.RouteIdentifier[1].image}}}function _(N,L){const w={type:null,values:[]};if(L.node){w.type="node";for(let D=0,j=L.node.length;D<j;D++){const V=L.node[D];w.values.push(N.visit(V))}}if(L.use){w.type="use";for(let D=0,j=L.use.length;D<j;D++){const V=L.use[D];w.values.push(N.visit(V))}}if(L.StringLiteral){w.type="string";for(let D=0,j=L.StringLiteral.length;D<j;D++){const V=L.StringLiteral[D];w.values.push(V.image.replace(/'|"/g,""))}}if(L.NumberLiteral){w.type="number";for(let D=0,j=L.NumberLiteral.length;D<j;D++){const V=L.NumberLiteral[D];w.values.push(parseFloat(V.image))}}if(L.HexLiteral){w.type="hex";for(let D=0,j=L.HexLiteral.length;D<j;D++){const V=L.HexLiteral[D];w.values.push(V.image)}}if(L.TrueLiteral){w.type="boolean";for(let D=0,j=L.TrueLiteral.length;D<j;D++)L.TrueLiteral[D].image==="TRUE"&&w.values.push(!0)}if(L.FalseLiteral){w.type="boolean";for(let D=0,j=L.FalseLiteral.length;D<j;D++)L.FalseLiteral[D].image==="FALSE"&&w.values.push(!1)}return L.NullLiteral&&(w.type="null",L.NullLiteral.forEach(function(){w.values.push(null)})),w}return new A}function u(b){const A=b.nodes,_=new R.Scene;for(let N=0,L=A.length;N<L;N++){const w=A[N];c(w)}for(let N=0,L=A.length;N<L;N++){const w=A[N],D=s(w);D instanceof R.Object3D&&_.add(D),w.name==="WorldInfo"&&(_.userData.worldInfo=D)}return _}function c(b){b.DEF&&(i[b.DEF]=b);const A=b.fields;for(let _=0,N=A.length;_<N;_++){const L=A[_];if(L.type==="node"){const w=L.values;for(let D=0,j=w.length;D<j;D++)c(w[D])}}}function s(b){return b.USE?Q(b.USE):(b.build!==void 0||(b.build=f(b)),b.build)}function f(b){const A=b.name;let _;switch(A){case"Anchor":case"Group":case"Transform":case"Collision":_=h(b);break;case"Background":_=g(b);break;case"Shape":_=p(b);break;case"Appearance":_=T(b);break;case"Material":_=m(b);break;case"ImageTexture":_=v(b);break;case"PixelTexture":_=y(b);break;case"TextureTransform":_=E(b);break;case"IndexedFaceSet":_=k(b);break;case"IndexedLineSet":_=H(b);break;case"PointSet":_=x(b);break;case"Box":_=B(b);break;case"Cone":_=P(b);break;case"Cylinder":_=O(b);break;case"Sphere":_=M(b);break;case"ElevationGrid":_=C(b);break;case"Extrusion":_=X(b);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":_=S(b);break;case"WorldInfo":_=I(b);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.VRMLLoader2: Unknown node:",A);break}return _!==void 0&&b.DEF!==void 0&&_.hasOwnProperty("name")===!0&&(_.name=b.DEF),_}function h(b){const A=new R.Group,_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":W(j,A);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":const V=new R.Vector3(j[0],j[1],j[2]).normalize(),Z=j[3];A.quaternion.setFromAxisAngle(V,Z);break;case"scale":A.scale.set(j[0],j[1],j[2]);break;case"scaleOrientation":break;case"translation":A.position.set(j[0],j[1],j[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function g(b){const A=new R.Group;let _,N,L,w;const D=b.fields;for(let V=0,Z=D.length;V<Z;V++){const re=D[V],ge=re.name,Oe=re.values;switch(ge){case"groundAngle":_=Oe;break;case"groundColor":N=Oe;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":L=Oe;break;case"skyColor":w=Oe;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",ge);break}}const j=1e4;if(w){const V=new R.SphereGeometry(j,32,16),Z=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,depthWrite:!1,depthTest:!1});w.length>3?(z(V,j,L,F(w),!0),Z.vertexColors=!0):Z.color.setRGB(w[0],w[1],w[2],R.SRGBColorSpace);const re=new R.Mesh(V,Z);A.add(re)}if(N&&N.length>0){const V=new R.SphereGeometry(j,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),Z=new R.MeshBasicMaterial({fog:!1,side:R.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});z(V,j,_,F(N),!1);const re=new R.Mesh(V,Z);A.add(re)}return A.renderOrder=-1/0,A}function p(b){const A=b.fields;let _=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0}),N;for(let w=0,D=A.length;w<D;w++){const j=A[w],V=j.name,Z=j.values;switch(V){case"appearance":Z[0]!==null&&(_=s(Z[0]));break;case"geometry":Z[0]!==null&&(N=s(Z[0]));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}let L;if(N&&N.attributes.position){const w=N._type;if(w==="points"){const D=new R.PointsMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:_.opacity,transparent:_.transparent});N.attributes.color!==void 0?D.vertexColors=!0:_.isMeshPhongMaterial&&D.color.copy(_.emissive),L=new R.Points(N,D)}else if(w==="line"){const D=new R.LineBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:16777215,opacity:_.opacity,transparent:_.transparent});N.attributes.color!==void 0?D.vertexColors=!0:_.isMeshPhongMaterial&&D.color.copy(_.emissive),L=new R.LineSegments(N,D)}else N._solid!==void 0&&(_.side=N._solid?R.FrontSide:R.DoubleSide),N.attributes.color!==void 0&&(_.vertexColors=!0),L=new R.Mesh(N,_)}else L=new R.Object3D,L.visible=!1;return L}function T(b){let A=new R.MeshPhongMaterial,_;const N=b.fields;for(let L=0,w=N.length;L<w;L++){const D=N[L],j=D.name,V=D.values;switch(j){case"material":if(V[0]!==null){const re=s(V[0]);re.diffuseColor&&A.color.copy(re.diffuseColor),re.emissiveColor&&A.emissive.copy(re.emissiveColor),re.shininess&&(A.shininess=re.shininess),re.specularColor&&A.specular.copy(re.specularColor),re.transparency&&(A.opacity=1-re.transparency),re.transparency>0&&(A.transparent=!0)}else A=new R.MeshBasicMaterial({name:R.Loader.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":const Z=V[0];Z!==null&&(Z.name==="ImageTexture"||Z.name==="PixelTexture"||Z.USE)&&(A.map=s(Z));break;case"textureTransform":V[0]!==null&&(_=s(V[0]));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",j);break}}if(A.map){if(A.map.__type){switch(A.map.__type){case Xe.INTENSITY_ALPHA:A.opacity=1;break;case Xe.RGB:A.color.set(16777215);break;case Xe.RGBA:A.color.set(16777215),A.opacity=1;break}delete A.map.__type}_&&(A.map.center.copy(_.center),A.map.rotation=_.rotation,A.map.repeat.copy(_.scale),A.map.offset.copy(_.translation))}return A}function m(b){const A={},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"ambientIntensity":break;case"diffuseColor":A.diffuseColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"emissiveColor":A.emissiveColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"shininess":A.shininess=j[0];break;case"specularColor":A.specularColor=new R.Color().setRGB(j[0],j[1],j[2],R.SRGBColorSpace);break;case"transparency":A.transparency=j[0];break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function l(b,A,_){let N;switch(A){case Xe.INTENSITY:N=parseInt(b),_.r=N,_.g=N,_.b=N,_.a=1;break;case Xe.INTENSITY_ALPHA:N=parseInt("0x"+b.substring(2,4)),_.r=N,_.g=N,_.b=N,_.a=parseInt("0x"+b.substring(4,6));break;case Xe.RGB:_.r=parseInt("0x"+b.substring(2,4)),_.g=parseInt("0x"+b.substring(4,6)),_.b=parseInt("0x"+b.substring(6,8)),_.a=1;break;case Xe.RGBA:_.r=parseInt("0x"+b.substring(2,4)),_.g=parseInt("0x"+b.substring(4,6)),_.b=parseInt("0x"+b.substring(6,8)),_.a=parseInt("0x"+b.substring(8,10));break}}function d(b){let A;switch(b){case 1:A=Xe.INTENSITY;break;case 2:A=Xe.INTENSITY_ALPHA;break;case 3:A=Xe.RGB;break;case 4:A=Xe.RGBA;break}return A}function y(b){let A,_=R.RepeatWrapping,N=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const j=L[w],V=j.name,Z=j.values;switch(V){case"image":const re=Z[0],ge=Z[1],Oe=Z[2],Fe=d(Oe),Ie=new Uint8Array(4*re*ge),Ee={r:0,g:0,b:0,a:0};for(let Re=3,Ne=0,Me=Z.length;Re<Me;Re++,Ne++){l(Z[Re],Fe,Ee);const Se=Ne*4;Ie[Se+0]=Ee.r,Ie[Se+1]=Ee.g,Ie[Se+2]=Ee.b,Ie[Se+3]=Ee.a}A=new R.DataTexture(Ie,re,ge),A.colorSpace=R.SRGBColorSpace,A.needsUpdate=!0,A.__type=Fe;break;case"repeatS":Z[0]===!1&&(_=R.ClampToEdgeWrapping);break;case"repeatT":Z[0]===!1&&(N=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return A&&(A.wrapS=_,A.wrapT=N),A}function v(b){let A,_=R.RepeatWrapping,N=R.RepeatWrapping;const L=b.fields;for(let w=0,D=L.length;w<D;w++){const j=L[w],V=j.name,Z=j.values;switch(V){case"url":const re=Z[0];re&&(A=ee.load(re));break;case"repeatS":Z[0]===!1&&(_=R.ClampToEdgeWrapping);break;case"repeatT":Z[0]===!1&&(N=R.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return A&&(A.wrapS=_,A.wrapT=N,A.colorSpace=R.SRGBColorSpace),A}function E(b){const A={center:new R.Vector2,rotation:new R.Vector2,scale:new R.Vector2,translation:new R.Vector2},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"center":A.center.set(j[0],j[1]);break;case"rotation":A.rotation=j[0];break;case"scale":A.scale.set(j[0],j[1]);break;case"translation":A.translation.set(j[0],j[1]);break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function S(b){return b.fields[0].values}function I(b){const A={},_=b.fields;for(let N=0,L=_.length;N<L;N++){const w=_[N],D=w.name,j=w.values;switch(D){case"title":A.title=j[0];break;case"info":A.info=j;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",D);break}}return A}function k(b){let A,_,N,L,w=!0,D=!0,j=0,V,Z,re,ge,Oe=!0,Fe=!0;const Ie=b.fields;for(let Ce=0,Ge=Ie.length;Ce<Ge;Ce++){const ze=Ie[Ce],Le=ze.name,ue=ze.values;switch(Le){case"color":const he=ue[0];he!==null&&(A=s(he));break;case"coord":const oe=ue[0];oe!==null&&(_=s(oe));break;case"normal":const fe=ue[0];fe!==null&&(N=s(fe));break;case"texCoord":const me=ue[0];me!==null&&(L=s(me));break;case"ccw":w=ue[0];break;case"colorIndex":V=ue;break;case"colorPerVertex":Oe=ue[0];break;case"convex":break;case"coordIndex":Z=ue;break;case"creaseAngle":j=ue[0];break;case"normalIndex":re=ue;break;case"normalPerVertex":Fe=ue[0];break;case"solid":D=ue[0];break;case"texCoordIndex":ge=ue;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Le);break}}if(Z===void 0)return console.warn("THREE.VRMLLoader2: Missing coordIndex."),new R.BufferGeometry;const Ee=$(Z,w);let Re,Ne,Me;if(A){if(Oe===!0)if(V&&V.length>0){const Ce=$(V,w);Re=J(Ee,Ce,A,3)}else Re=ye(Ee,new R.Float32BufferAttribute(A,3));else if(V&&V.length>0){const Ce=ce(A,V),Ge=te(Ce,Z);Re=ie(Ee,Ge)}else{const Ce=te(A,Z);Re=ie(Ee,Ce)}Y(Re)}if(N)if(Fe===!0)if(re&&re.length>0){const Ce=$(re,w);Ne=J(Ee,Ce,N,3)}else Ne=ye(Ee,new R.Float32BufferAttribute(N,3));else if(re&&re.length>0){const Ce=ce(N,re),Ge=te(Ce,Z);Ne=ie(Ee,Ge)}else{const Ce=te(N,Z);Ne=ie(Ee,Ce)}else Ne=We(Ee,_,j);if(L)if(ge&&ge.length>0){const Ce=$(ge,w);Me=J(Ee,Ce,L,2)}else Me=ye(Ee,new R.Float32BufferAttribute(L,2));const Se=new R.BufferGeometry,De=ye(Ee,new R.Float32BufferAttribute(_,3));return Se.setAttribute("position",De),Se.setAttribute("normal",Ne),Re&&Se.setAttribute("color",Re),Me&&Se.setAttribute("uv",Me),Se._solid=D,Se._type="mesh",Se}function H(b){let A,_,N,L,w=!0;const D=b.fields;for(let ge=0,Oe=D.length;ge<Oe;ge++){const Fe=D[ge],Ie=Fe.name,Ee=Fe.values;switch(Ie){case"color":const Re=Ee[0];Re!==null&&(A=s(Re));break;case"coord":const Ne=Ee[0];Ne!==null&&(_=s(Ne));break;case"colorIndex":N=Ee;break;case"colorPerVertex":w=Ee[0];break;case"coordIndex":L=Ee;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Ie);break}}let j;const V=ae(L);if(A){if(w===!0)if(N.length>0){const ge=ae(N);j=J(V,ge,A,3)}else j=ye(V,new R.Float32BufferAttribute(A,3));else if(N.length>0){const ge=ce(A,N),Oe=le(ge,L);j=Te(V,Oe)}else{const ge=le(A,L);j=Te(V,ge)}Y(j)}const Z=new R.BufferGeometry,re=ye(V,new R.Float32BufferAttribute(_,3));return Z.setAttribute("position",re),j&&Z.setAttribute("color",j),Z._type="line",Z}function x(b){let A,_;const N=b.fields;for(let w=0,D=N.length;w<D;w++){const j=N[w],V=j.name,Z=j.values;switch(V){case"color":const re=Z[0];re!==null&&(A=s(re));break;case"coord":const ge=Z[0];ge!==null&&(_=s(ge));break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}const L=new R.BufferGeometry;if(L.setAttribute("position",new R.Float32BufferAttribute(_,3)),A){const w=new R.Float32BufferAttribute(A,3);Y(w),L.setAttribute("color",w)}return L._type="points",L}function B(b){const A=new R.Vector3(2,2,2),_=b.fields;for(let L=0,w=_.length;L<w;L++){const D=_[L],j=D.name,V=D.values;j==="size"?(A.x=V[0],A.y=V[1],A.z=V[2]):console.warn("THREE.VRMLLoader2: Unknown field:",j)}return new R.BoxGeometry(A.x,A.y,A.z)}function P(b){let A=1,_=2,N=!1;const L=b.fields;for(let D=0,j=L.length;D<j;D++){const V=L[D],Z=V.name,re=V.values;switch(Z){case"bottom":N=!re[0];break;case"bottomRadius":A=re[0];break;case"height":_=re[0];break;case"side":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",Z);break}}return new R.ConeGeometry(A,_,16,1,N)}function O(b){let A=1,_=2;const N=b.fields;for(let w=0,D=N.length;w<D;w++){const j=N[w],V=j.name,Z=j.values;switch(V){case"bottom":break;case"radius":A=Z[0];break;case"height":_=Z[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader2: Unknown field:",V);break}}return new R.CylinderGeometry(A,A,_,16,1)}function M(b){let A=1;const _=b.fields;for(let L=0,w=_.length;L<w;L++){const D=_[L],j=D.name,V=D.values;j==="radius"?A=V[0]:console.warn("THREE.VRMLLoader2: Unknown field:",j)}return new R.SphereGeometry(A,16,16)}function C(b){let A,_,N,L,w=!0,D=!0,j=!0,V=!0,Z=0,re=2,ge=2,Oe=1,Fe=1;const Ie=b.fields;for(let ue=0,he=Ie.length;ue<he;ue++){const oe=Ie[ue],fe=oe.name,me=oe.values;switch(fe){case"color":const Pe=me[0];Pe!==null&&(A=s(Pe));break;case"normal":const Qe=me[0];Qe!==null&&(_=s(Qe));break;case"texCoord":const Ze=me[0];Ze!==null&&(N=s(Ze));break;case"height":L=me;break;case"ccw":V=me[0];break;case"colorPerVertex":w=me[0];break;case"creaseAngle":Z=me[0];break;case"normalPerVertex":D=me[0];break;case"solid":j=me[0];break;case"xDimension":re=me[0];break;case"xSpacing":Oe=me[0];break;case"zDimension":ge=me[0];break;case"zSpacing":Fe=me[0];break;default:console.warn("THREE.VRMLLoader2: Unknown field:",fe);break}}const Ee=[],Re=[],Ne=[],Me=[];for(let ue=0;ue<ge;ue++)for(let he=0;he<re;he++){const oe=ue*re+he,fe=Oe*ue,me=L[oe],Pe=Fe*he;if(Ee.push(fe,me,Pe),A&&w===!0){const Qe=A[oe*3+0],Ze=A[oe*3+1],At=A[oe*3+2];Ne.push(Qe,Ze,At)}if(_&&D===!0){const Qe=_[oe*3+0],Ze=_[oe*3+1],At=_[oe*3+2];Re.push(Qe,Ze,At)}if(N){const Qe=N[oe*2+0],Ze=N[oe*2+1];Me.push(Qe,Ze)}else Me.push(ue/(re-1),he/(ge-1))}const Se=[];for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*re,fe=ue+(he+1)*re,me=ue+1+(he+1)*re,Pe=ue+1+he*re;V===!0?(Se.push(oe,me,fe),Se.push(me,oe,Pe)):(Se.push(oe,fe,me),Se.push(me,Pe,oe))}const De=ye(Se,new R.Float32BufferAttribute(Ee,3)),Ce=ye(Se,new R.Float32BufferAttribute(Me,2));let Ge,ze;if(A){if(w===!1){for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*(re-1),fe=A[oe*3+0],me=A[oe*3+1],Pe=A[oe*3+2];Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe),Ne.push(fe,me,Pe)}Ge=new R.Float32BufferAttribute(Ne,3)}else Ge=ye(Se,new R.Float32BufferAttribute(Ne,3));Y(Ge)}if(_)if(D===!1){for(let ue=0;ue<re-1;ue++)for(let he=0;he<ge-1;he++){const oe=ue+he*(re-1),fe=_[oe*3+0],me=_[oe*3+1],Pe=_[oe*3+2];Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe),Re.push(fe,me,Pe)}ze=new R.Float32BufferAttribute(Re,3)}else ze=ye(Se,new R.Float32BufferAttribute(Re,3));else ze=We(Se,Ee,Z);const Le=new R.BufferGeometry;return Le.setAttribute("position",De),Le.setAttribute("normal",ze),Le.setAttribute("uv",Ce),Ge&&Le.setAttribute("color",Ge),Le._solid=j,Le._type="mesh",Le}function X(b){let A=[1,1,1,-1,-1,-1,-1,1,1,1],_=[0,0,0,0,1,0],N,L,w=!0,D=!0,j=0,V=!0,Z=!0;const re=b.fields;for(let Le=0,ue=re.length;Le<ue;Le++){const he=re[Le],oe=he.name,fe=he.values;switch(oe){case"beginCap":w=fe[0];break;case"ccw":D=fe[0];break;case"convex":break;case"creaseAngle":j=fe[0];break;case"crossSection":A=fe;break;case"endCap":V=fe[0];break;case"orientation":L=fe;break;case"scale":N=fe;break;case"solid":Z=fe[0];break;case"spine":_=fe;break;default:console.warn("THREE.VRMLLoader2: Unknown field:",oe);break}}const ge=A[0]===A[A.length-2]&&A[1]===A[A.length-1],Oe=[],Fe=new R.Vector3,Ie=new R.Vector3,Ee=new R.Vector3,Re=new R.Vector3,Ne=new R.Quaternion;for(let Le=0,ue=0,he=0,oe=_.length;Le<oe;Le+=3,ue+=2,he+=4){Fe.fromArray(_,Le),Ie.x=N?N[ue+0]:1,Ie.y=1,Ie.z=N?N[ue+1]:1,Ee.x=L?L[he+0]:0,Ee.y=L?L[he+1]:0,Ee.z=L?L[he+2]:1;const fe=L?L[he+3]:0;for(let me=0,Pe=A.length;me<Pe;me+=2)Re.x=A[me+0],Re.y=0,Re.z=A[me+1],Re.multiply(Ie),Ne.setFromAxisAngle(Ee,fe),Re.applyQuaternion(Ne),Re.add(Fe),Oe.push(Re.x,Re.y,Re.z)}const Me=[],Se=_.length/3,De=A.length/2;for(let Le=0;Le<Se-1;Le++)for(let ue=0;ue<De-1;ue++){const he=ue+Le*De;let oe=ue+1+Le*De;const fe=ue+(Le+1)*De;let me=ue+1+(Le+1)*De;ue===De-2&&ge===!0&&(oe=Le*De,me=(Le+1)*De),D===!0?(Me.push(he,oe,fe),Me.push(fe,oe,me)):(Me.push(he,fe,oe),Me.push(fe,me,oe))}if(w===!0||V===!0){const Le=[];for(let oe=0,fe=A.length;oe<fe;oe+=2)Le.push(new R.Vector2(A[oe],A[oe+1]));const ue=R.ShapeUtils.triangulateShape(Le,[]),he=[];for(let oe=0,fe=ue.length;oe<fe;oe++){const me=ue[oe];he.push(me[0],me[1],me[2])}if(w===!0)for(let oe=0,fe=he.length;oe<fe;oe+=3)D===!0?Me.push(he[oe+0],he[oe+1],he[oe+2]):Me.push(he[oe+0],he[oe+2],he[oe+1]);if(V===!0){const oe=De*(Se-1);for(let fe=0,me=he.length;fe<me;fe+=3)D===!0?Me.push(oe+he[fe+0],oe+he[fe+2],oe+he[fe+1]):Me.push(oe+he[fe+0],oe+he[fe+1],oe+he[fe+2])}}const Ce=ye(Me,new R.Float32BufferAttribute(Oe,3)),Ge=We(Me,Oe,j),ze=new R.BufferGeometry;return ze.setAttribute("position",Ce),ze.setAttribute("normal",Ge),ze._solid=Z,ze._type="mesh",ze}function Q(b){const A=i[b],_=s(A);return _.isObject3D||_.isMaterial?_.clone():_}function W(b,A){for(let _=0,N=b.length;_<N;_++){const L=s(b[_]);L instanceof R.Object3D&&A.add(L)}}function $(b,A){const _=[];let N=0;for(let L=0,w=b.length;L<w;L++){const D=b[N],j=b[L+(A?1:2)],V=b[L+(A?2:1)];_.push(D,j,V),(b[L+3]===-1||L+3>=w)&&(L+=3,N=L+1)}return _}function te(b,A){const _=[];let N=0;for(let L=0,w=A.length;L<w;L++){const D=N*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z),(A[L+3]===-1||L+3>=w)&&(L+=3,N++)}return _}function ce(b,A){const _=[];for(let N=0,L=A.length;N<L;N++){const D=A[N]*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z)}return _}function ae(b){const A=[];for(let _=0,N=b.length;_<N;_++){const L=b[_],w=b[_+1];A.push(L,w),(b[_+2]===-1||_+2>=N)&&(_+=2)}return A}function le(b,A){const _=[];let N=0;for(let L=0,w=A.length;L<w;L++){const D=N*3,j=b[D],V=b[D+1],Z=b[D+2];_.push(j,V,Z),(A[L+2]===-1||L+2>=w)&&(L+=2,N++)}return _}const ne=new R.Vector3,pe=new R.Vector3,U=new R.Vector3,G=new R.Vector2,K=new R.Vector2,q=new R.Vector2;function J(b,A,_,N){const L=[];for(let w=0,D=b.length;w<D;w+=3){const j=A[w],V=A[w+1],Z=A[w+2];N===2?(G.fromArray(_,j*N),K.fromArray(_,V*N),q.fromArray(_,Z*N),L.push(G.x,G.y),L.push(K.x,K.y),L.push(q.x,q.y)):(ne.fromArray(_,j*N),pe.fromArray(_,V*N),U.fromArray(_,Z*N),L.push(ne.x,ne.y,ne.z),L.push(pe.x,pe.y,pe.z),L.push(U.x,U.y,U.z))}return new R.Float32BufferAttribute(L,N)}function ie(b,A){const _=[];for(let N=0,L=0,w=b.length;N<w;N+=3,L++)ne.fromArray(A,L*3),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(_,3)}function Te(b,A){const _=[];for(let N=0,L=0,w=b.length;N<w;N+=2,L++)ne.fromArray(A,L*3),_.push(ne.x,ne.y,ne.z),_.push(ne.x,ne.y,ne.z);return new R.Float32BufferAttribute(_,3)}function ye(b,A){const _=A.array,N=A.itemSize,L=new _.constructor(b.length*N);let w=0,D=0;for(let j=0,V=b.length;j<V;j++){w=b[j]*N;for(let Z=0;Z<N;Z++)L[D++]=_[w++]}return new R.Float32BufferAttribute(L,N)}const we=new R.Vector3,Be=new R.Vector3;function We(b,A,_){const N=[],L={};for(let D=0,j=b.length;D<j;D+=3){const V=b[D],Z=b[D+1],re=b[D+2],ge=new bi(V,Z,re);ne.fromArray(A,V*3),pe.fromArray(A,Z*3),U.fromArray(A,re*3),Be.subVectors(U,pe),we.subVectors(ne,pe),Be.cross(we),Be.normalize(),ge.normal.copy(Be),L[V]===void 0&&(L[V]=[]),L[Z]===void 0&&(L[Z]=[]),L[re]===void 0&&(L[re]=[]),L[V].push(ge.normal),L[Z].push(ge.normal),L[re].push(ge.normal),N.push(ge)}const w=[];for(let D=0,j=N.length;D<j;D++){const V=N[D],Z=Ue(L[V.a],V.normal,_),re=Ue(L[V.b],V.normal,_),ge=Ue(L[V.c],V.normal,_);ne.fromArray(A,V.a*3),pe.fromArray(A,V.b*3),U.fromArray(A,V.c*3),w.push(Z.x,Z.y,Z.z),w.push(re.x,re.y,re.z),w.push(ge.x,ge.y,ge.z)}return new R.Float32BufferAttribute(w,3)}function Ue(b,A,_){const N=new R.Vector3;if(_===0)N.copy(A);else for(let L=0,w=b.length;L<w;L++)b[L].angleTo(A)<_&&N.add(b[L]);return N.normalize()}function F(b){const A=[];for(let _=0,N=b.length;_<N;_+=3)A.push(new R.Color(b[_],b[_+1],b[_+2]));return A}function Y(b){const A=new R.Color;for(let _=0;_<b.count;_++)A.fromBufferAttribute(b,_),R.ColorManagement.colorSpaceToWorking(A,R.SRGBColorSpace),b.setXYZ(_,A.r,A.g,A.b)}function z(b,A,_,N,L){const w=[],D=L===!0?0:Math.PI;for(let Oe=0,Fe=N.length;Oe<Fe;Oe++){let Ie=Oe===0?0:_[Oe-1];Ie=L===!0?Ie:D-Ie;const Ee=new R.Vector3;Ee.setFromSphericalCoords(A,Ie,0),w.push(Ee)}const j=b.index,V=b.attributes.position,Z=new R.BufferAttribute(new Float32Array(b.attributes.position.count*3),3),re=new R.Vector3,ge=new R.Color;for(let Oe=0;Oe<j.count;Oe++){const Fe=j.getX(Oe);re.fromBufferAttribute(V,Fe);let Ie,Ee,Re=1;for(let Se=1;Se<w.length;Se++){Ie=Se-1,Ee=Se;const De=w[Ie],Ce=w[Ee];if(L===!0){if(re.y<=De.y&&re.y>Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}else if(re.y>=De.y&&re.y<Ce.y){Re=Math.abs(De.y-re.y)/Math.abs(De.y-Ce.y);break}}const Ne=N[Ie],Me=N[Ee];ge.copy(Ne).lerp(Me,Re),R.ColorManagement.colorSpaceToWorking(ge,R.SRGBColorSpace),Z.setXYZ(Fe,ge.r,ge.g,ge.b)}b.setAttribute("color",Z)}const ee=new R.TextureLoader(this.manager);if(ee.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const de=r(e);return u(de)}}class Ri{constructor(e){this.lexer=new at.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 Ai=at.CstParser;class _i extends Ai{constructor(e){super(e);const t=this,i=e.Version,r=e.LCurly,a=e.RCurly,o=e.LSquare,u=e.RSquare,c=e.Identifier,s=e.RouteIdentifier,f=e.StringLiteral,h=e.HexLiteral,g=e.NumberLiteral,p=e.TrueLiteral,T=e.FalseLiteral,m=e.NullLiteral,l=e.DEF,d=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(i)}),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(a)}),t.RULE("field",function(){t.CONSUME(c),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(l),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(E)}}])}),t.RULE("use",function(){t.CONSUME(d),t.OR([{ALT:function(){t.CONSUME(c)}},{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(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(T)}},{ALT:function(){t.CONSUME(m)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(m)}}])}),t.CONSUME(u)}),t.RULE("route",function(){t.CONSUME(y),t.CONSUME(s),t.CONSUME(v),t.CONSUME2(s)}),this.performSelfAnalysis()}}class bi{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.normal=new R.Vector3}}const Xe={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};class Li extends R.Loader{constructor(e){super(e),this.animateBonePositions=!0,this.animateBoneRotations=!0,this.animateBoneScales=!0}load(e,t,i,r){const a=this,o=new R.FileLoader(a.manager);o.setPath(a.path),o.setRequestHeader(a.requestHeader),o.setWithCredentials(a.withCredentials),o.load(e,function(u){try{t(a.parse(u))}catch(c){r?r(c):console.error(c),a.manager.itemError(e)}},i,r)}parse(e){function t(p){u(p)!=="HIERARCHY"&&console.error("THREE.BVHLoader2: HIERARCHY expected.");const T=[],m=r(p,u(p),T);u(p)!=="MOTION"&&console.error("THREE.BVHLoader2: MOTION expected.");let l=u(p).split(/[\s]+/);const d=parseInt(l[1]);isNaN(d)&&console.error("THREE.BVHLoader2: Failed to read number of frames."),l=u(p).split(/[\s]+/);const y=parseFloat(l[2]);isNaN(y)&&console.error("THREE.BVHLoader2: Failed to read frame time.");for(let v=0;v<d;v++)l=u(p).split(/[\s]+/),i(l,v*y,m);return T}function i(p,T,m){if(m.type==="ENDSITE")return;const l={time:T,position:new R.Vector3,rotation:new R.Quaternion,scale:new R.Vector3(1,1,1)};m.frames.push(l);const d=new R.Quaternion,y=new R.Vector3(1,0,0),v=new R.Vector3(0,1,0),E=new R.Vector3(0,0,1);for(let S=0;S<m.channels.length;S++)switch(m.channels[S]){case"Xposition":l.position.x=parseFloat(p.shift().trim());break;case"Yposition":l.position.y=parseFloat(p.shift().trim());break;case"Zposition":l.position.z=parseFloat(p.shift().trim());break;case"Xrotation":d.setFromAxisAngle(y,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Yrotation":d.setFromAxisAngle(v,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Zrotation":d.setFromAxisAngle(E,parseFloat(p.shift().trim())*Math.PI/180),l.rotation.multiply(d);break;case"Xscale":l.scale.x=parseFloat(p.shift().trim());break;case"Yscale":l.scale.y=parseFloat(p.shift().trim());break;case"Zscale":l.scale.z=parseFloat(p.shift().trim());break;default:console.warn("THREE.BVHLoader2: Invalid channel type.")}for(let S=0;S<m.children.length;S++)i(p,T,m.children[S])}function r(p,T,m){const l={name:"",type:"",frames:[]};m.push(l);let d=T.split(/[\s]+/);d[0].toUpperCase()==="END"&&d[1].toUpperCase()==="SITE"?(l.type="ENDSITE",l.name="ENDSITE"):(l.name=d[1],l.type=d[0].toUpperCase()),u(p)!=="{"&&console.error("THREE.BVHLoader2: Expected opening { after type & name"),d=u(p).split(/[\s]+/),d[0]!=="OFFSET"&&console.error("THREE.BVHLoader2: Expected OFFSET but got: "+d[0]),d.length!==4&&console.error("THREE.BVHLoader2: Invalid number of values for OFFSET.");const y=new R.Vector3(parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]));if((isNaN(y.x)||isNaN(y.y)||isNaN(y.z))&&console.error("THREE.BVHLoader2: Invalid values of OFFSET."),l.offset=y,l.type!=="ENDSITE"){d=u(p).split(/[\s]+/),d[0]!=="CHANNELS"&&console.error("THREE.BVHLoader2: Expected CHANNELS definition.");const v=parseInt(d[1]);l.channels=d.splice(2,v),l.children=[]}for(;;){const v=u(p);if(v==="}")return l;l.children.push(r(p,v,m))}}function a(p,T){const m=new R.Bone;if(T.push(m),m.position.add(p.offset),m.name=p.name,p.type!=="ENDSITE")for(let l=0;l<p.children.length;l++)m.add(a(p.children[l],T));return m}function o(p){const T=[];for(let m=0;m<p.length;m++){const l=p[m];if(l.type==="ENDSITE")continue;const d=[],y=[],v=[],E=[];for(let S=0;S<l.frames.length;S++){const I=l.frames[S];d.push(I.time),y.push(I.position.x+l.offset.x),y.push(I.position.y+l.offset.y),y.push(I.position.z+l.offset.z),v.push(I.rotation.x),v.push(I.rotation.y),v.push(I.rotation.z),v.push(I.rotation.w),E.push(I.scale.x),E.push(I.scale.y),E.push(I.scale.z)}c.animateBonePositions&&T.push(new R.VectorKeyframeTrack(l.name+".position",d,y)),c.animateBoneRotations&&T.push(new R.QuaternionKeyframeTrack(l.name+".quaternion",d,v)),c.animateBoneScales&&T.push(new R.VectorKeyframeTrack(l.name+".scale",d,E))}return new R.AnimationClip("animation",-1,T)}function u(p){let T;for(;(T=p.shift().trim()).length===0;);return T}const c=this,s=e.split(/[\r\n]+/g),f=t(s),h=[];a(f[0],h);const g=o(f);return{skeleton:new R.Skeleton(h),clip:g}}}let pt;async function Si(n,e){return pt||(pt=new vi),pt.manager.setURLModifier(i=>(i.startsWith("./")&&(i=i.substring(2)),URL.createObjectURL(nr(n,i)))),await pt.loadAsync(e)}let Ot;async function Oi(n,e){Ot||(Ot=new Li);const t=Pt(n,e);return await Ot.parse(t)}function xi(n){const e=n.clip.clone(),t=n.skeleton.bones[0].clone(!0),i=[];t.traverse(a=>{a instanceof se.Bone&&i.push(a)});const r=new se.Skeleton(i);return r.calculateInverses(),{clip:e,skeleton:r}}class kt{isDummy=!0;skeleton=new se.Skeleton([new se.Bone]);clip=new se.AnimationClip("dummy")}class st extends je{bvhs={};vrmls={};ready;viewActions;currentAction;comment=null;constructor(e){super(),this.viewActions={},this.currentAction={actionRoot:new se.Object3D,boneRoot:new se.Bone},this.ready=this.asyncInit(e)}initObject(){return new se.Object3D}initMotion(){return new Ct(this)}async asyncInit(e){const t=await ln(e),i=new DOMParser,r=Pt(t,"CATALOG.XML"),a=i.parseFromString(r,"application/xml");if(a.querySelector("parsererror"))return console.error("Acerola3D.asyncInit(): CATALOG.XML parse error."),this;const o="http://acerola3d.sourceforge.jp/a3/catalog",u=a.getElementsByTagNameNS(o,"c");u[0]&&(this.comment=u[0].textContent);const c=a.getElementsByTagNameNS(o,"a"),s=[];for(const f of Array.from(c)){const h=f.getAttribute("an");if(h){const g=f.getAttribute("bvh");let p=null;if(g){const E=t.zipUrl+"!"+g;this.bvhs[E]?p=xi(this.bvhs[E]):(p=await Oi(t,g),this.bvhs[g]=p),p&&p.clip.tracks.forEach(S=>{S.setInterpolation(se.InterpolateDiscrete)})}else p=new kt;const T=f.getAttribute("scale"),m=T?Number(T):1,l=f.getAttribute("offset"),d=new Ae;if(l){const E=l.split(" ");d.set(Number(E[0]),Number(E[1]),Number(E[2]))}const y={},v=f.getElementsByTagNameNS(o,"p");for(const E of Array.from(v)){const S=E.getAttribute("name"),I=E.getAttribute("wrl");if(S&&I){let k;const H=t.zipUrl+"!"+I;this.vrmls[H]?(k=this.vrmls[H].clone(!0),y[S]=k):(k=await Si(t,I),this.vrmls[H]=k,y[S]=k)}}s.push({name:h,bvh:p,scale:m,offset:d,parts:y})}}return this.generateViewActionsFromActionSeeds(s),this.motion instanceof Ct&&this.motion.myInitialize(s),this}generateViewActionsFromActionSeeds(e){this.viewActions={};for(const t of e){const i=new se.Object3D;if(i.position.set(t.offset.x,t.offset.y,t.offset.z),i.scale.set(t.scale,t.scale,t.scale),t.bvh instanceof kt){for(const r of Object.values(t.parts))i.add(r);this.viewActions[t.name]={actionRoot:i,boneRoot:t.bvh.skeleton.bones[0].clone(!0)}}else{const r=t.bvh.skeleton.bones[0].clone(!0);i.add(r),In(r,t.parts),this.viewActions[t.name]={actionRoot:i,boneRoot:r}}i.traverse(r=>{r.userData.a3js={objectA3:this}})}}changeAction(e){this.object.remove(this.currentAction.actionRoot);const t=this.viewActions[e];this.object.add(t.actionRoot),this.currentAction=t}}function In(n,e){if(Hn(n)){const t=e[n.name];t&&n.add(t)}n.children&&n.children.forEach(t=>{In(t,e)})}class Ct extends tt{actionSeeds;motionActions;currentAction;isPaused;constructor(e){super(e),this.isPaused=!1,this.actionSeeds=[],this.motionActions={}}setObject(e){this.isPaused=!1,e instanceof st?(super.setObject(e),this.actionSeeds.length>0&&this.myInitialize([])):console.warn("Acerola3DMotion can set only Acerola3D object.")}myInitialize(e){if(!(this.objectA3 instanceof st))return;const t=[];for(const a of this.actionSeeds)t.push(a);for(const a of e)t.filter(o=>o.name===a.name).length===0&&t.push(a);this.objectA3.generateViewActionsFromActionSeeds(t),this.actionSeeds=t,this.motionActions={};for(const a of this.actionSeeds){if(a.bvh instanceof kt){this.motionActions[a.name]={bvh:a.bvh};break}const o=this.objectA3.viewActions[a.name].boneRoot,u=new se.AnimationMixer(o),c=u.clipAction(a.bvh.clip),s={bvh:a.bvh,mixer:u,clipAction:c};this.motionActions[a.name]=s}const i=this.actionSeeds[0].name;this.objectA3.changeAction(i);const r=this.motionActions[i];r.clipAction?.play(),this.currentAction=r}detachObject(e){if(!(this.objectA3 instanceof st))return;const t=this.actionSeeds[0].name;for(const i of this.actionSeeds){const r=this.motionActions[i.name];r.mixer?.stopAllAction();const a=this.objectA3.viewActions[i.name].boneRoot;a&&r.mixer?.uncacheRoot(a),delete this.motionActions[i.name]}this.objectA3.changeAction(t),super.detachObject(e)}update(e){super.update(e),this.currentAction&&!this.isPaused&&this.currentAction.mixer&&this.currentAction.mixer?.update(e)}controlMotion(e){if(!(this.objectA3 instanceof st))return;const t=this.motionActions[e];t&&(this.currentAction&&this.currentAction.clipAction?.stop(),this.objectA3.changeAction(e),t.clipAction?.play(),this.currentAction=t)}setPause(e){this.isPaused=e}setTime(e){this.currentAction?.mixer?.setTime(e)}}class Ii extends je{constructor(e){super(e)}initObject(e){return e}}class Ni extends je{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new se.BoxGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new se.MeshStandardMaterial({color:a});return new se.Mesh(r,o)}}class wi extends je{constructor(...e){super(e)}initObject(e){const t=e.filter(c=>typeof c=="number"),i=e.filter(c=>typeof c=="string"),r=new se.SphereGeometry(...t),a=i.length>0?i[0]:"rgb(128,128,128)",o=new se.MeshStandardMaterial({color:a});return new se.Mesh(r,o)}}class ki extends je{constructor(e){super(e)}initObject(e){return new un(e)}}exports.Acerola3D=st;exports.Acerola3DMotion=Ct;exports.Box=Ni;exports.Camera=sn;exports.Canvas=fn;exports.ControllerBase=an;exports.GLTF=En;exports.GLTFMotion=vn;exports.GeneralCamera=ut;exports.HTML=ki;exports.Motion=tt;exports.ObjectA3=je;exports.OrbitController=cn;exports.Quat=ke;exports.RapierPhysicsEngine=lt;exports.Scene=on;exports.Sound=$e;exports.Sphere=wi;exports.Test=ur;exports.Text3D=gr;exports.ThreeJS=Ii;exports.Vec3=Ae;exports.ViewBase=Dt;exports.Window=dn;exports.asyncSleep=tr;exports.deepMerge=yt;exports.getQuatOfLookAt=ct;exports.initFont=yr;exports.initPhysics=$n;exports.initSound=sr;exports.vec3EulerToQuat=tn;
220
220
  //# sourceMappingURL=a3js.cjs.js.map