@hatiolab/things-scene 10.1.85 → 10.1.87
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-types/components/data/evaluator.d.ts.map +1 -1
- package/dist-types/components/data/legend.d.ts +33 -0
- package/dist-types/components/data/legend.d.ts.map +1 -0
- package/dist-types/figure/figure-capability.d.ts.map +1 -1
- package/dist-types/figure/figure-data-reading.d.ts +64 -0
- package/dist-types/figure/figure-data-reading.d.ts.map +1 -0
- package/dist-types/figure/figure-inputs.d.ts +16 -15
- package/dist-types/figure/figure-inputs.d.ts.map +1 -1
- package/dist-types/figure/figure-instance.d.ts +3 -8
- package/dist-types/figure/figure-instance.d.ts.map +1 -1
- package/dist-types/figure/figure-real-object.d.ts +13 -0
- package/dist-types/figure/figure-real-object.d.ts.map +1 -1
- package/dist-types/figure/figure-registry.d.ts +5 -0
- package/dist-types/figure/figure-registry.d.ts.map +1 -1
- package/dist-types/figure/figure-rig.d.ts +15 -0
- package/dist-types/figure/figure-rig.d.ts.map +1 -1
- package/dist-types/figure/figure-status.d.ts +32 -0
- package/dist-types/figure/figure-status.d.ts.map +1 -0
- package/dist-types/figure/index.d.ts +2 -0
- package/dist-types/figure/index.d.ts.map +1 -1
- package/dist-types/items/items-data-binding.d.ts +12 -0
- package/dist-types/items/items-data-binding.d.ts.map +1 -1
- package/dist-types/things-scene/index.d.ts +1 -0
- package/dist-types/things-scene/index.d.ts.map +1 -1
- package/dist-types/transfer/index.d.ts +1 -0
- package/dist-types/transfer/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/things-scene-min.js +10 -10
- package/things-scene-min.js.map +1 -1
- package/things-scene-transfer.mjs +2 -2
- package/things-scene.mjs +3 -3
- package/things-scene.mjs.map +1 -1
|
@@ -3,5 +3,5 @@ function t(...t){return e=>{const n=Object.getPrototypeOf(e),r=Array.isArray(n?.
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2026 Three.js Authors
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/const g=2e3,m={};function b(...t){t=function(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function v(...t){const e=t.join(" ");e in m||(m[e]=!0,b(...t))}function x(t,e,n){return Math.max(e,Math.min(n,t))}class _{static{_.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class w{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,i,o,s){let a=n[r+0],c=n[r+1],u=n[r+2],h=n[r+3],l=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(h!==p||a!==l||c!==f||u!==d){let t=a*l+c*f+u*d+h*p;t<0&&(l=-l,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const n=Math.acos(t),r=Math.sin(n);e=Math.sin(e*n)/r,a=a*e+l*(s=Math.sin(s*n)/r),c=c*e+f*s,u=u*e+d*s,h=h*e+p*s}else{a=a*e+l*s,c=c*e+f*s,u=u*e+d*s,h=h*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+h*h);a*=t,c*=t,u*=t,h*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,i,o){const s=n[r],a=n[r+1],c=n[r+2],u=n[r+3],h=i[o],l=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*h+a*f-c*l,t[e+1]=a*d+u*l+c*h-s*f,t[e+2]=c*d+u*f+s*l-a*h,t[e+3]=u*d-s*h-a*l-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(n/2),u=s(r/2),h=s(i/2),l=a(n/2),f=a(r/2),d=a(i/2);switch(o){case"XYZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"YXZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"ZXY":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"ZYX":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"YZX":this._x=l*u*h+c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h-l*f*d;break;case"XZY":this._x=l*u*h-c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h+l*f*d;break;default:b("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],h=e[10],l=n+s+h;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-r)*t}else if(n>s&&n>h){const t=2*Math.sqrt(1+n-s-h);this._w=(u-a)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+c)/t}else if(s>h){const t=2*Math.sqrt(1+s-n-h);this._w=(i-c)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+h-n-s);this._w=(o-r)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(x(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=n*u+o*s+r*c-i*a,this._y=r*u+o*a+i*s-n*c,this._z=i*u+o*c+n*a-r*s,this._w=o*u-n*s-r*a-i*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,r=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(n=-n,r=-r,i=-i,o=-o,s=-s);let a=1-e;if(s<.9995){const t=Math.acos(s),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{static{k.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(S.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(S.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*r-s*n),u=2*(s*e-i*r),h=2*(i*n-o*e);return this.x=e+a*c+o*h-s*u,this.y=n+a*u+s*c-i*h,this.z=r+a*h+i*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=r*a-i*s,this.y=i*o-n*a,this.z=n*s-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const M=new k,S=new w;class z{static{z.prototype.isMatrix3=!0}constructor(t,e,n,r,i,o,s,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c)}set(t,e,n,r,i,o,s,a,c){const u=this.elements;return u[0]=t,u[1]=r,u[2]=s,u[3]=e,u[4]=i,u[5]=a,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[3],a=n[6],c=n[1],u=n[4],h=n[7],l=n[2],f=n[5],d=n[8],p=r[0],y=r[3],g=r[6],m=r[1],b=r[4],v=r[7],x=r[2],_=r[5],w=r[8];return i[0]=o*p+s*m+a*x,i[3]=o*y+s*b+a*_,i[6]=o*g+s*v+a*w,i[1]=c*p+u*m+h*x,i[4]=c*y+u*b+h*_,i[7]=c*g+u*v+h*w,i[2]=l*p+f*m+d*x,i[5]=l*y+f*b+d*_,i[8]=l*g+f*v+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8];return e*o*u-e*s*c-n*i*u+n*s*a+r*i*c-r*o*a}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=u*o-s*c,l=s*a-u*i,f=c*i-o*a,d=e*h+n*l+r*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return t[0]=h*p,t[1]=(r*c-u*n)*p,t[2]=(s*n-r*o)*p,t[3]=l*p,t[4]=(u*e-r*a)*p,t[5]=(r*i-s*e)*p,t[6]=f*p,t[7]=(n*a-c*e)*p,t[8]=(o*e-n*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,s){const a=Math.cos(i),c=Math.sin(i);return this.set(n*a,n*c,-n*(a*o+c*s)+o+t,-r*c,r*a,-r*(-c*o+a*s)+s+e,0,0,1),this}scale(t,e){return v("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(E.makeScale(t,e)),this}rotate(t){return v("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(E.makeRotation(-t)),this}translate(t,e){return v("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(E.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const E=new z;class A{static{A.prototype.isVector4=!0}constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,s=.1,a=t.elements,c=a[0],u=a[4],h=a[8],l=a[1],f=a[5],d=a[9],p=a[2],y=a[6],g=a[10];if(Math.abs(u-l)<o&&Math.abs(h-p)<o&&Math.abs(d-y)<o){if(Math.abs(u+l)<s&&Math.abs(h+p)<s&&Math.abs(d+y)<s&&Math.abs(c+f+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(f+1)/2,m=(g+1)/2,b=(u+l)/4,v=(h+p)/4,x=(d+y)/4;return t>a&&t>m?t<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(t),r=b/n,i=v/n):a>m?a<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(a),n=b/r,i=x/r):m<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(m),n=v/i,r=x/i),this.set(n,r,i,e),this}let m=Math.sqrt((y-d)*(y-d)+(h-p)*(h-p)+(l-u)*(l-u));return Math.abs(m)<.001&&(m=1),this.x=(y-d)/m,this.y=(h-p)/m,this.z=(l-u)/m,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this.w=x(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this.w=x(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class T{static{T.prototype.isMatrix4=!0}constructor(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y)}set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=s,g[13]=a,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=f,g[7]=d,g[11]=p,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new T).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,n=t.elements,r=1/O.setFromMatrixColumn(t,0).length(),i=1/O.setFromMatrixColumn(t,1).length(),o=1/O.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),s=Math.sin(n),a=Math.cos(r),c=Math.sin(r),u=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=-a*h,e[8]=c,e[1]=n+r*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=r+n*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t+i*s,e[4]=r*s-n,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-s,e[2]=n*s-r,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t-i*s,e[4]=-o*h,e[8]=r+n*s,e[1]=n+r*s,e[5]=o*u,e[9]=i-t*s,e[2]=-o*c,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=r*c-n,e[8]=t*c+i,e[1]=a*h,e[5]=i*c+t,e[9]=n*c-r,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=i-t*h,e[8]=r*h+n,e[1]=h,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=n*h+r,e[10]=t-i*h}else if("XZY"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=-h,e[8]=c*u,e[1]=t*h+i,e[5]=o*u,e[9]=n*h-r,e[2]=r*h-n,e[6]=s*u,e[10]=i*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(j,t,P)}lookAt(t,e,n){const r=this.elements;return F.subVectors(t,e),0===F.lengthSq()&&(F.z=1),F.normalize(),R.crossVectors(n,F),0===R.lengthSq()&&(1===Math.abs(n.z)?F.x+=1e-4:F.z+=1e-4,F.normalize(),R.crossVectors(n,F)),R.normalize(),C.crossVectors(F,R),r[0]=R.x,r[4]=C.x,r[8]=F.x,r[1]=R.y,r[5]=C.y,r[9]=F.y,r[2]=R.z,r[6]=C.z,r[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[4],a=n[8],c=n[12],u=n[1],h=n[5],l=n[9],f=n[13],d=n[2],p=n[6],y=n[10],g=n[14],m=n[3],b=n[7],v=n[11],x=n[15],_=r[0],w=r[4],k=r[8],M=r[12],S=r[1],z=r[5],E=r[9],A=r[13],T=r[2],O=r[6],I=r[10],j=r[14],P=r[3],R=r[7],C=r[11],F=r[15];return i[0]=o*_+s*S+a*T+c*P,i[4]=o*w+s*z+a*O+c*R,i[8]=o*k+s*E+a*I+c*C,i[12]=o*M+s*A+a*j+c*F,i[1]=u*_+h*S+l*T+f*P,i[5]=u*w+h*z+l*O+f*R,i[9]=u*k+h*E+l*I+f*C,i[13]=u*M+h*A+l*j+f*F,i[2]=d*_+p*S+y*T+g*P,i[6]=d*w+p*z+y*O+g*R,i[10]=d*k+p*E+y*I+g*C,i[14]=d*M+p*A+y*j+g*F,i[3]=m*_+b*S+v*T+x*P,i[7]=m*w+b*z+v*O+x*R,i[11]=m*k+b*E+v*I+x*C,i[15]=m*M+b*A+v*j+x*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],h=t[6],l=t[10],f=t[14],d=t[3],p=t[7],y=t[11],g=t[15],m=a*f-c*l,b=s*f-c*h,v=s*l-a*h,x=o*f-c*u,_=o*l-a*u,w=o*h-s*u;return e*(p*m-y*b+g*v)-n*(d*m-y*x+g*_)+r*(d*b-p*x+g*w)-i*(d*v-p*_+y*w)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[1],o=t[5],s=t[9],a=t[2],c=t[6],u=t[10];return e*(o*u-s*c)-n*(i*u-s*a)+r*(i*c-o*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=t[9],l=t[10],f=t[11],d=t[12],p=t[13],y=t[14],g=t[15],m=e*s-n*o,b=e*a-r*o,v=e*c-i*o,x=n*a-r*s,_=n*c-i*s,w=r*c-i*a,k=u*p-h*d,M=u*y-l*d,S=u*g-f*d,z=h*y-l*p,E=h*g-f*p,A=l*g-f*y,T=m*A-b*E+v*z+x*S-_*M+w*k;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/T;return t[0]=(s*A-a*E+c*z)*O,t[1]=(r*E-n*A-i*z)*O,t[2]=(p*w-y*_+g*x)*O,t[3]=(l*_-h*w-f*x)*O,t[4]=(a*S-o*A-c*M)*O,t[5]=(e*A-r*S+i*M)*O,t[6]=(y*v-d*w-g*b)*O,t[7]=(u*w-l*v+f*b)*O,t[8]=(o*E-s*S+c*k)*O,t[9]=(n*S-e*E-i*k)*O,t[10]=(d*_-p*v+g*m)*O,t[11]=(h*v-u*_-f*m)*O,t[12]=(s*M-o*z-a*k)*O,t[13]=(e*z-n*M+r*k)*O,t[14]=(p*b-d*x-y*m)*O,t[15]=(u*x-h*b+l*m)*O,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+n,c*s-r*a,c*a+r*s,0,c*s+r*a,u*s+n,u*a-r*o,0,c*a-r*s,u*a+r*o,i*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,h=s+s,l=i*c,f=i*u,d=i*h,p=o*u,y=o*h,g=s*h,m=a*c,b=a*u,v=a*h,x=n.x,_=n.y,w=n.z;return r[0]=(1-(p+g))*x,r[1]=(f+v)*x,r[2]=(d-b)*x,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(l+g))*_,r[6]=(y+m)*_,r[7]=0,r[8]=(d+b)*w,r[9]=(y-m)*w,r[10]=(1-(l+p))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;t.x=r[12],t.y=r[13],t.z=r[14];const i=this.determinantAffine();if(0===i)return n.set(1,1,1),e.identity(),this;let o=O.set(r[0],r[1],r[2]).length();const s=O.set(r[4],r[5],r[6]).length(),a=O.set(r[8],r[9],r[10]).length();i<0&&(o=-o),I.copy(this);const c=1/o,u=1/s,h=1/a;return I.elements[0]*=c,I.elements[1]*=c,I.elements[2]*=c,I.elements[4]*=u,I.elements[5]*=u,I.elements[6]*=u,I.elements[8]*=h,I.elements[9]*=h,I.elements[10]*=h,e.setFromRotationMatrix(I),n.x=o,n.y=s,n.z=a,this}makePerspective(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),h=2*i/(n-r),l=(e+t)/(e-t),f=(n+r)/(n-r);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===g)d=-(o+i)/(o-i),p=-2*o*i/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-i),p=-o*i/(o-i)}return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),h=2/(n-r),l=-(e+t)/(e-t),f=-(n+r)/(n-r);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===g)d=-2/(o-i),p=-(o+i)/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);d=-1/(o-i),p=-i/(o-i)}return c[0]=u,c[4]=0,c[8]=0,c[12]=l,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const O=new k,I=new T,j=new k(0,0,0),P=new k(1,1,1),R=new k,C=new k,F=new k,N=new T,D=new w;class L{constructor(t=0,e=0,n=0,r=L.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],s=r[8],a=r[1],c=r[5],u=r[9],h=r[2],l=r[6],f=r[10];switch(e){case"XYZ":this._y=Math.asin(x(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(l,c),this._z=0);break;case"YXZ":this._x=Math.asin(-x(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(x(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-x(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(l,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(l,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:b("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return N.makeRotationFromQuaternion(t),this.setFromRotationMatrix(N,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}L.DEFAULT_ORDER="XYZ";class ${static{$.prototype.isMatrix2=!0}constructor(t,e,n,r){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,r){const i=this.elements;return i[0]=t,i[2]=e,i[1]=n,i[3]=r,this}}function U(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?b("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const q=new L;function W(t,e){q.setFromQuaternion(new w(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=q.x,t.rotation=-q.y,t.rotationY=q.z}const Y="_transferSlotId";const B=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=B);const G=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,r=this._getResidents?.()??null;let i=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(i=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const o={fps:i,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...r??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}};function X(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const H=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return B.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const n=e?.component,r=n?.app??n?.root?.app;if(r&&"boolean"==typeof r.isViewMode&&!r.isViewMode)return()=>{};const i={id:this._nextId++,handler:t,description:e?.description??`<anonymous#${this._nextId-1}>`,componentRef:null!=e?.component&&"undefined"!=typeof WeakRef?new WeakRef(e.component):void 0,targetsGetter:e?.getTargets,metadata:e?.metadata,registeredAt:this._realTime,tickCount:0,totalDurationMs:0,lastDt:0,lastDurationMs:0};return this._subs.add(i),this.isRunning||this.start(),()=>{this._ticking?(i._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(i),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,G.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const n=B.tick(e),r=B.now;if(this._ticking=!0,G.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(n,r)}finally{const r=performance.now()-e;t.tickCount++,t.totalDurationMs+=r,t.lastDt=n,t.lastDurationMs=r}}else for(const t of this._subs)t._removed||t.handler(n,r);if(this._ticking=!1,this._hasPendingRemoval){this._hasPendingRemoval=!1;for(const t of this._subs)t._removed&&this._subs.delete(t);0===this._subs.size&&this.stop()}}start(){if(null!==this._rafId)return;if("undefined"==typeof requestAnimationFrame)return;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),n=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(n),null!==this._rafId&&(this._rafId=requestAnimationFrame(t))};this._rafId=requestAnimationFrame(t)}stop(){null!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._lastWallTime=null}registerExternalAnimation(t,e,n){const r={id:this._externalNextId++,description:t,source:e,metadata:n,registeredAt:this._realTime};return this._externals.add(r),{update:t=>{r.metadata={...r.metadata??{},...t}},unregister:()=>{this._externals.delete(r)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let n;const r=e.componentRef?.deref();let i;if(r&&(n=X(r)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(X(t));n.length>0&&(i=n)}}catch{}t.push({id:e.id,description:e.description,componentInfo:n,targetInfos:i,metadata:e.metadata,registeredAt:e.registeredAt,tickCount:e.tickCount,totalDurationMs:Math.round(100*e.totalDurationMs)/100,avgDurationMs:e.tickCount>0?Math.round(e.totalDurationMs/e.tickCount*100)/100:0,lastDt:Math.round(100*e.lastDt)/100,lastDurationMs:Math.round(100*e.lastDurationMs)/100})}const e=[];for(const t of this._externals)e.push({id:t.id,description:t.description,source:t.source,metadata:t.metadata,registeredAt:t.registeredAt,liveDurationMs:Math.round(this._realTime-t.registeredAt)});return{realTime:Math.round(this._realTime),simTime:Math.round(B.now),isRunning:this.isRunning,speed:B.speed,paused:B.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let V=null;const Z=[],Q=new Set;function J(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const K={beginContext(t){V=t},endContext(){V=null},current:()=>V,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??J(t.component),componentType:t.componentType??(n=t.component,n?.state?.type??n?.type),atSimMs:B.now,args:t.args,result:t.result,error:t.error};var n;V?V.pushTrace(e):(Z.push(e),Z.length>500&&Z.shift(),Q.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...Z],onStandalone:t=>(Q.add(t),()=>{Q.delete(t)}),clearStandalone(){Z.length=0}};function tt(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const n=String(e);return n.length>0?n:void 0}function et(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},n=t.sourceId??tt(t.source),r=t.targetId??tt(t.target),i=t.carrierId??tt(t.carrier);return void 0!==n&&(e.sourceId=n),void 0!==r&&(e.targetId=r),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let nt=1;class rt{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+nt++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:B.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??B.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return it.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=B.now;const t=this.target.canAccept?.(this.carrier);if(t&&t.ok)this._slot=t.slot;else{if(t&&!t.ok&&"no-slots-defined"!==t.reason)return this._rejectReason=t.reason,this._rollback();if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier))return this._rejectReason="cannot-receive",this._rollback();this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source}),this._reservation)?(this._timeline.planEndAt=B.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",it.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=B.now;const t=this._buildReceipt();return it.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){K.beginContext(this),K.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{return await this._executeImpl()}finally{K.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}executeSync(){K.beginContext(this),K.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{K.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",it.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:tt(this.source),targetId:tt(this.target),carrierId:tt(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const it=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??tt(t.source),n=t.targetId??tt(t.target);if("committed"===t.phase){if(e&&n){const t=e+">"+n;this._flows.set(t,(this._flows.get(t)??0)+1)}n&&this._targetCount.set(n,(this._targetCount.get(n)??0)+1),void 0!==t.timeline.committedAt&&(this._committedDurationSum+=t.timeline.committedAt-t.timeline.initiatedAt,this._committedCount++)}else if("rolled-back"===t.phase&&t.rejectReason){this._byRejectReason.set(t.rejectReason,(this._byRejectReason.get(t.rejectReason)??0)+1);try{t.source?._bumpRejected?.(t.carrier,t.rejectReason)}catch{}}this._listeners.forEach(e=>e(t))}flows(){return this._flows}targetCounts(){return this._targetCount}stats(){const t={};this._byPhase.forEach((e,n)=>{t[n]=e});const e=t["rolled-back"]??0;return{total:this._total,byPhase:t,committed:t.committed??0,rolledBack:e,rejectionRate:this._total>0?e/this._total:0,avgTransferDurationMs:this._committedCount>0?this._committedDurationSum/this._committedCount:0}}rejectReasonCounts(){return this._byRejectReason}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._flows.clear(),this._targetCount.clear(),this._byPhase.clear(),this._byRejectReason.clear(),this._total=0,this._committedDurationSum=0,this._committedCount=0}entries(){return[]}forCarrier(t){return[]}forCarrierId(t){return[]}forSourceId(t){return[]}forTargetId(t){return[]}forPhase(t){return[]}inTimeRange(t,e,n){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=it);let ot=1;function st(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const at={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class ct{constructor(t=at){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+ot++},n=(this._byResource.get(e.resource)??[]).filter(t=>st(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const r=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(r.every(t=>"b-yields"===t.decision)){const r=n.slice();for(const t of r)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:r}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:r}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>st(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let r=this._byReserver.get(t.reserverId);r||(r=[],this._byReserver.set(t.reserverId,r)),r.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const r=this._byReserver.get(t.reserverId);if(r){const e=r.findIndex(e=>e.id===t.id);e>=0&&r.splice(e,1),0===r.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const ut=new ct;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=ut);class ht{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const r of this.nodes.values()){const i=lt(r.position,t);i<n&&(n=i,e=r)}return e}}function lt(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}function ft(t,e){return Math.sqrt(lt(t,e))}function dt(t,e,n={}){const r=new ht,i=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,o=`${e.id}:end`;r.addNode({id:n,position:t[0],type:"lane-start"}),r.addNode({id:o,position:t[t.length-1],type:"lane-end"}),r.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=ft(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;r.addEdge({fromNode:n,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&r.addEdge({fromNode:o,toNode:n,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const i=r.laneEndpoints.get(n);if(!i)continue;const o=r.nodes.get(i.startNodeId).position,s=r.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===n)continue;const t=r.laneEndpoints.get(e);if(!t)continue;const i=r.nodes.get(t.startNodeId).position,h=r.nodes.get(t.endNodeId).position;a+=Math.min(lt(o,i),lt(o,h)),c+=Math.min(lt(s,i),lt(s,h)),u++}if(0===u)continue;const h=a<c?i.startNodeId:i.endNodeId;e.push({laneId:n,nodeId:h,pos:r.nodes.get(h).position})}for(let n=0;n<e.length;n++)for(let i=0;i<e.length;i++){if(n===i)continue;const o=e[n],s=e[i],a=ft(o.pos,s.pos);r.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return r}function pt(t,e,n,r={}){const i=t.nodes.get(e),o=t.nodes.get(n);if(!i||!o)return null;const s=r.speed?.max??100,a=e=>{const n=t.nodes.get(e);var r,i;return(r=n.position,i=o.position,Math.sqrt(function(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}(r,i)))/s*1e3},c=new Map,u=new Set,h=new Set,l={nodeId:e,gScore:0,fScore:a(e)};c.set(e,l),u.add(e);const f=r.startSimMs??0,d=r.deadlineSimMs;for(;u.size>0;){let e=null,r=null;for(const t of u){const n=c.get(t);(!r||n.fScore<r.fScore||n.fScore===r.fScore&&t<e)&&(r=n,e=t)}if(!r||!e)return null;if(e===n){const t=[];let e=r,n=0;for(;e&&e.cameFromEdge;){const r=e.cameFromEdge,i=f+(e.gScore-r.durationMs);t.unshift({resource:r.resource,timeWindow:{startSimMs:i,endSimMs:i+r.durationMs},fromPos:r.fromPos,toPos:r.toPos}),n+=r.distance,e=c.get(r.fromNodeId)}const i=r.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:n}}u.delete(e),h.add(e);for(const n of t.edgesFrom(e)){if(h.has(n.toNode))continue;const e=r.gScore+n.durationMs,i=c.get(n.toNode);if(!i||e<i.gScore){const r=t.nodes.get(n.fromNode),i=t.nodes.get(n.toNode),o={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:r.position,toPos:i.position}};c.set(n.toNode,o),u.add(n.toNode)}}}return null}function yt(t,e,n=0,r){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:r}))}const gt=.5;function mt(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function bt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o||!Number.isFinite(n)||Math.abs(n)<1e-9)return null;const s=Math.abs(n),a=(o*o+4*s*s)/(8*s),c=n>0?1:-1,u=a-s,h=(t.x+e.x)/2-c*(i/o)*u,l=(t.y+e.y)/2-c*-(r/o)*u;return{cx:h,cy:l,radius:a,startAngle:Math.atan2(t.y-l,t.x-h),endAngle:Math.atan2(e.y-l,e.x-h),clockwise:n<0}}function vt(t,e,n=0,r=16){const i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o);if(0===s)return null;const a=o/s,c=-(i/s),u=Number.isFinite(n)?n:0,h=Math.abs(u)>=1e-6?u:r;return{x:(t.x+e.x)/2+a*h,y:(t.y+e.y)/2+c*h,perpX:a,perpY:c}}function xt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o)return 0;const s=i/o,a=-(r/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let h=(n.x-c)*s+(n.y-u)*a;if(Math.abs(h)<.5)return 0;return h>o&&(h=o),h<-o&&(h=-o),h}function _t(t,e){const n=t.radius,r=Number.isFinite(e)?e:0;return null!=n&&Number.isFinite(n)?Math.max(0,n):Math.max(0,r)}function wt(t,e,n,r,i=16){const o=t.x-e.x,s=t.y-e.y,a=Math.sqrt(o*o+s*s);if(0===a)return null;const c=n.x-e.x,u=n.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h)return null;const l=o/a+c/h,f=s/a+u/h,d=Math.sqrt(l*l+f*f);if(d<1e-9)return null;const p=l/d,y=f/d,g=Math.max(r,i);return{x:e.x+p*g,y:e.y+y*g,bisectorX:p,bisectorY:y}}function kt(t,e,n,r){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=n.x-e.x,c=n.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const h=i/s+a/u,l=o/s+c/u,f=Math.sqrt(h*h+l*l);if(f<1e-9)return 0;const d=h/f,p=l/f,y=(r.x-e.x)*d+(r.y-e.y)*p,g=Math.min(s,u)/2;return Math.max(0,Math.min(y,g))}function Mt(t){if(0===t.length)return 0;let e;for(const n of t){const t=n.z??0;if(!Number.isFinite(t))return null;if(void 0===e)e=t;else if(Math.abs(t-e)>1e-9)return null}return e??0}const St={closed:!0,round:0,divisions:24};class zt{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const r=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(r*r+i*i))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const r=this.cumulative;let i=0,o=r.length-2;for(;i<o;){const t=i+o>>1;r[t+1]<=n?i=t+1:o=t}const s=r[i+1]-r[i],a=s>0?(n-r[i])/s:0,c=this.points[i],u=this.points[i+1],h=u.x-c.x,l=u.y-c.y;return{x:c.x+h*a,y:c.y+l*a,theta:0===h&&0===l?0:Math.atan2(l,h)}}}function Et(t,e={}){const n={...St,...e},r=t.length;if(0===r)return new zt([],n.closed);if(1===r)return new zt([{x:t[0].x,y:t[0].y}],n.closed);const i=[],o=(t,e)=>{if(i.length>0){const n=i[i.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}i.push({x:t,y:e})},s=(n.closed,r);for(let e=0;e<s;e++){const i=0===e?n.closed?r-1:-1:e-1,s=e===r-1?n.closed?0:-1:e+1,a=i>=0?t[i]:null,c=t[e],u=s>=0?t[s]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&u?_t(c,n.round):0;let l,f,d,p;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(h,t/2);l=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else l=c.x,f=c.y;if(u){const t=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2),e=0!==t?Math.atan2(u.x-c.x,u.y-c.y):0,n=Math.min(h,t/2);d=Math.sin(e)*n+c.x,p=Math.cos(e)*n+c.y}else d=c.x,p=c.y;if(o(l,f),h>0&&a&&u)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,r=1-e;o(r*r*l+2*r*e*c.x+e*e*d,r*r*f+2*r*e*c.y+e*e*p)}else l===d&&f===p||o(d,p);if(u&&mt(c)){const t=_t(u,n.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),r=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=bt({x:d,y:p},{x:Math.sin(r)*i+u.x,y:Math.cos(r)*i+u.y},c.bulge);if(s){let t=s.endAngle-s.startAngle;if(s.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const r=e/n.divisions,i=s.startAngle+t*r;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(n.closed&&i.length>0){const t=i[0],e=i[i.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&i.push({x:t.x,y:t.y})}return new zt(i,n.closed)}function At(t,e){return Et(t,e).length}function Tt(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function Ot(t){if(Tt(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class It{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function jt(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),r=e.onAvailable(()=>t.resumeEmit());return Ot(e).isFull&&t.pauseEmit(),()=>{n?.(),r?.()}}class Pt{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,r){const i=e.maxCount??1/0;if(t<0||t>=i)return null;const o=this.owner?.state?.width??0,s=this.owner?.state?.height??0,a=r?.state?.width??0,c=r?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(s-c)/2),z:0}:{x:Math.max(0,(o-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Rt(t,e,n,r,i,o,s){const a=n.w,c=n.h,u=r.w,h=r.h,l=r.d,f=[],d=u+i,p=h+i,y=Math.max(1,Math.floor((a+i)/d)),g=Math.max(1,Math.floor((c+i)/p)),m=y*g,b=o&&o>0?Math.floor(o):4;if("row"===t||"column"===t){const n=s?.advanceAlongX??!1,r=s?.reverse??!1,i=n?y:g,o=n?g:y,u=(t,e,r)=>((t,e,n)=>f.push({x:-a/2+(t+.5)*d,y:n*l+l/2,z:-c/2+(e+.5)*p}))(n?t:e,n?e:t,r);let h=0;for(let n=0;n<i&&h<e;n++){const s=r?i-1-n:n;if("column"===t)for(let t=0;t<o&&h<e;t++)for(let n=0;n<b&&h<e;n++)u(s,t,n),h++;else for(let t=0;t<b&&h<e;t++)for(let n=0;n<o&&h<e;n++)u(s,n,t),h++}return f}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,y-n),r=Math.max(1,g-n),i=e*r,s=Math.min(t,i);for(let t=0;t<s;t++){const i=t%e,o=Math.floor(t/e),s=-a/2+(i+(y-e)/2+.5)*d,u=-c/2+(o+(g-r)/2+.5)*p;f.push({x:s,y:n*l+l/2,z:u})}if(t-=s,n++,1===e&&1===r){for(let e=0;e<t;e++)f.push({x:0,y:(n+e)*l+l/2,z:0});break}if(o&&n>=o)break}return f}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/m),r=n%m,i=r%y,s=Math.floor(r/y),g=(t(2*n)-.5)*u*.2,b=(t(2*n+1)-.5)*h*.2,v=-a/2+(i+.5)*d+g,x=-c/2+(s+.5)*p+b;if(f.push({x:v,y:e*l+l/2,z:x}),o&&e>=o-1&&r===m-1)break}return f}for(let n=0;n<e;n++){const e=Math.floor(n/m);if(o&&e>=o)break;const r=n%m,i=r%y,s=Math.floor(r/y);let u=-a/2+(i+.5)*d;const h=-c/2+(s+.5)*p;"staggered"===t&&e%2==1&&(u+=d/2),f.push({x:u,y:e*l+l/2,z:h})}return f}class Ct{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,r={}){const i=r.gap??this.defaults.gap??0,o=r.heightLimit??this.defaults.heightLimit,s=r.fill??this.defaults.fill;return Rt(this.pattern,t,e,n,i,o,s).map(t=>({position:t}))}}class Ft{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,r={}){const i=Math.max(1,this.cols),o=Math.max(1,this.rows),s=i*o,a=r.gap??this.defaults.gap??0,c=n.w+a,u=n.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/s),r=e%s,a=r%i,l=Math.floor(r/i);h.push({position:{x:(a-(i-1)/2)*c,z:(l-(o-1)/2)*u,y:t*n.d+n.d/2}})}return h}}class Nt{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,r=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-r)/(e.h+r))),pitchX:e.w+n,pitchZ:e.h+r}}capacity(t,e,n){const{cols:r,rows:i}=this.grid(t,e);return r*i*Math.max(1,Math.floor(n))}layout(t,e,n,r={}){const{cols:i,rows:o,pitchX:s,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,u=null!=r.heightLimit?Math.max(1,Math.floor(r.heightLimit)):1/0,h=Number.isFinite(u),l=this.sliceFirst&&h,f=i*o,d=i*(h?u:1),p=i*o*(h?u:t),y=Math.min(t,p),g=[];for(let t=0;t<y;t++){let e,r,u;if(l){const n=Math.floor(t/d),o=t%d;e=o%i,u=Math.floor(o/i),r=n}else{u=Math.floor(t/f);const n=t%f;e=n%i,r=Math.floor(n/i)}this.fillFromFar&&(r=o-1-r),g.push({position:{x:(e-(i-1)/2)*s,z:(r-(o-1)/2)*a,y:u*c+n.d/2}})}return g}}function Dt(t,e,n,r=0){for(let i=0;i<e.length;i++){const o=e[i],s=n[i];o&&s&&(o.parent!==t&&t.attach(o),o.position.set(s.position.x,r+s.position.y,s.position.z),s.rotation?o.quaternion.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w):o.quaternion.identity())}}function Lt(t,e,n,r=.12){const i=e.left+e.width/2,o=e.top+e.height/2,s=Math.min(n.w,n.h)*r,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let r=a.get(t);r||(r={x:i+e.position.x-n.w/2+s,y:o+e.position.z-n.h/2+s,w:n.w-2*s,h:n.h-2*s,count:0},a.set(t,r)),r.count++}return[...a.values()]}function $t(t,e){return t===e||t!=t&&e!=e}function Ut(t,e){for(var n=t.length;n--;)if($t(t[n][0],e))return n;return-1}var qt=Array.prototype.splice;function Wt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Wt.prototype.clear=function(){this.__data__=[],this.size=0},Wt.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():qt.call(e,n,1),--this.size,!0)},Wt.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},Wt.prototype.has=function(t){return Ut(this.__data__,t)>-1},Wt.prototype.set=function(t,e){var n=this.__data__,r=Ut(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var Yt="object"==typeof global&&global&&global.Object===Object&&global,Bt="object"==typeof self&&self&&self.Object===Object&&self,Gt=Yt||Bt||Function("return this")(),Xt=Gt.Symbol,Ht=Object.prototype,Vt=Ht.hasOwnProperty,Zt=Ht.toString,Qt=Xt?Xt.toStringTag:void 0;var Jt=Object.prototype.toString;var Kt=Xt?Xt.toStringTag:void 0;function te(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Kt&&Kt in Object(t)?function(t){var e=Vt.call(t,Qt),n=t[Qt];try{t[Qt]=void 0;var r=!0}catch(t){}var i=Zt.call(t);return r&&(e?t[Qt]=n:delete t[Qt]),i}(t):function(t){return Jt.call(t)}(t)}function ee(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ne(t){if(!ee(t))return!1;var e=te(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var re,ie=Gt["__core-js_shared__"],oe=(re=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"";var se=Function.prototype.toString;function ae(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ce=/^\[object .+?Constructor\]$/,ue=Function.prototype,he=Object.prototype,le=ue.toString,fe=he.hasOwnProperty,de=RegExp("^"+le.call(fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pe(t){return!(!ee(t)||(e=t,oe&&oe in e))&&(ne(t)?de:ce).test(ae(t));var e}function ye(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return pe(n)?n:void 0}var ge=ye(Gt,"Map"),me=ye(Object,"create");var be=Object.prototype.hasOwnProperty;var ve=Object.prototype.hasOwnProperty;function xe(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _e(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function we(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}xe.prototype.clear=function(){this.__data__=me?me(null):{},this.size=0},xe.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},xe.prototype.get=function(t){var e=this.__data__;if(me){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return be.call(e,t)?e[t]:void 0},xe.prototype.has=function(t){var e=this.__data__;return me?void 0!==e[t]:ve.call(e,t)},xe.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=me&&void 0===e?"__lodash_hash_undefined__":e,this},we.prototype.clear=function(){this.size=0,this.__data__={hash:new xe,map:new(ge||Wt),string:new xe}},we.prototype.delete=function(t){var e=_e(this,t).delete(t);return this.size-=e?1:0,e},we.prototype.get=function(t){return _e(this,t).get(t)},we.prototype.has=function(t){return _e(this,t).has(t)},we.prototype.set=function(t,e){var n=_e(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function ke(t){var e=this.__data__=new Wt(t);this.size=e.size}ke.prototype.clear=function(){this.__data__=new Wt,this.size=0},ke.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ke.prototype.get=function(t){return this.__data__.get(t)},ke.prototype.has=function(t){return this.__data__.has(t)},ke.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Wt){var r=n.__data__;if(!ge||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new we(r)}return n.set(t,e),this.size=n.size,this};function Me(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new we;++e<n;)this.add(t[e])}function Se(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}Me.prototype.add=Me.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Me.prototype.has=function(t){return this.__data__.has(t)};function ze(t,e,n,r,i,o){var s=1&n,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),h=o.get(e);if(u&&h)return u==e&&h==t;var l=-1,f=!0,d=2&n?new Me:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var p=t[l],y=e[l];if(r)var g=s?r(y,p,l,e,t,o):r(p,y,l,t,e,o);if(void 0!==g){if(g)continue;f=!1;break}if(d){if(!Se(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,n,r,o)))return d.push(e);var s})){f=!1;break}}else if(p!==y&&!i(p,y,n,r,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var Ee=Gt.Uint8Array;function Ae(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function Te(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var Oe=Xt?Xt.prototype:void 0,Ie=Oe?Oe.valueOf:void 0;function je(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var Pe=Array.isArray;function Re(){return[]}var Ce=Object.prototype.propertyIsEnumerable,Fe=Object.getOwnPropertySymbols,Ne=Fe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}(Fe(t),function(e){return Ce.call(t,e)}))}:Re;function De(t){return null!=t&&"object"==typeof t}function Le(t){return De(t)&&"[object Arguments]"==te(t)}var $e=Object.prototype,Ue=$e.hasOwnProperty,qe=$e.propertyIsEnumerable,We=Le(function(){return arguments}())?Le:function(t){return De(t)&&Ue.call(t,"callee")&&!qe.call(t,"callee")};var Ye="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Ye&&"object"==typeof module&&module&&!module.nodeType&&module,Ge=Be&&Be.exports===Ye?Gt.Buffer:void 0,Xe=(Ge?Ge.isBuffer:void 0)||function(){return!1},He=/^(?:0|[1-9]\d*)$/;function Ve(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&He.test(t))&&t>-1&&t%1==0&&t<e}function Ze(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Qe={};function Je(t){return function(e){return t(e)}}Qe["[object Float32Array]"]=Qe["[object Float64Array]"]=Qe["[object Int8Array]"]=Qe["[object Int16Array]"]=Qe["[object Int32Array]"]=Qe["[object Uint8Array]"]=Qe["[object Uint8ClampedArray]"]=Qe["[object Uint16Array]"]=Qe["[object Uint32Array]"]=!0,Qe["[object Arguments]"]=Qe["[object Array]"]=Qe["[object ArrayBuffer]"]=Qe["[object Boolean]"]=Qe["[object DataView]"]=Qe["[object Date]"]=Qe["[object Error]"]=Qe["[object Function]"]=Qe["[object Map]"]=Qe["[object Number]"]=Qe["[object Object]"]=Qe["[object RegExp]"]=Qe["[object Set]"]=Qe["[object String]"]=Qe["[object WeakMap]"]=!1;var Ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,tn=Ke&&"object"==typeof module&&module&&!module.nodeType&&module,en=tn&&tn.exports===Ke&&Yt.process,nn=function(){try{var t=tn&&tn.require&&tn.require("util").types;return t||en&&en.binding&&en.binding("util")}catch(t){}}(),rn=nn&&nn.isTypedArray,on=rn?Je(rn):function(t){return De(t)&&Ze(t.length)&&!!Qe[te(t)]},sn=Object.prototype.hasOwnProperty;function an(t,e){var n=Pe(t),r=!n&&We(t),i=!n&&!r&&Xe(t),o=!n&&!r&&!i&&on(t),s=n||r||i||o,a=s?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=a.length;for(var u in t)!e&&!sn.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ve(u,c))||a.push(u);return a}var cn=Object.prototype;function un(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||cn)}function hn(t,e){return function(n){return t(e(n))}}var ln=hn(Object.keys,Object),fn=Object.prototype.hasOwnProperty;function dn(t){if(!un(t))return ln(t);var e=[];for(var n in Object(t))fn.call(t,n)&&"constructor"!=n&&e.push(n);return e}function pn(t){return null!=t&&Ze(t.length)&&!ne(t)}function yn(t){return pn(t)?an(t):dn(t)}function gn(t){return function(t,e,n){var r=e(t);return Pe(t)?r:je(r,n(t))}(t,yn,Ne)}var mn=Object.prototype.hasOwnProperty;var bn=ye(Gt,"DataView"),vn=ye(Gt,"Promise"),xn=ye(Gt,"Set"),_n=ye(Gt,"WeakMap"),wn="[object Map]",kn="[object Promise]",Mn="[object Set]",Sn="[object WeakMap]",zn="[object DataView]",En=ae(bn),An=ae(ge),Tn=ae(vn),On=ae(xn),In=ae(_n),jn=te;(bn&&jn(new bn(new ArrayBuffer(1)))!=zn||ge&&jn(new ge)!=wn||vn&&jn(vn.resolve())!=kn||xn&&jn(new xn)!=Mn||_n&&jn(new _n)!=Sn)&&(jn=function(t){var e=te(t),n="[object Object]"==e?t.constructor:void 0,r=n?ae(n):"";if(r)switch(r){case En:return zn;case An:return wn;case Tn:return kn;case On:return Mn;case In:return Sn}return e});var Pn="[object Arguments]",Rn="[object Array]",Cn="[object Object]",Fn=Object.prototype.hasOwnProperty;function Nn(t,e,n,r,i,o){var s=Pe(t),a=Pe(e),c=s?Rn:jn(t),u=a?Rn:jn(e),h=(c=c==Pn?Cn:c)==Cn,l=(u=u==Pn?Cn:u)==Cn,f=c==u;if(f&&Xe(t)){if(!Xe(e))return!1;s=!0,h=!1}if(f&&!h)return o||(o=new ke),s||on(t)?ze(t,e,n,r,i,o):function(t,e,n,r,i,o,s){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ee(t),new Ee(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return $t(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ae;case"[object Set]":var c=1&r;if(a||(a=Te),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var h=ze(a(t),a(e),r,i,o,s);return s.delete(t),h;case"[object Symbol]":if(Ie)return Ie.call(t)==Ie.call(e)}return!1}(t,e,c,n,r,i,o);if(!(1&n)){var d=h&&Fn.call(t,"__wrapped__"),p=l&&Fn.call(e,"__wrapped__");if(d||p){var y=d?t.value():t,g=p?e.value():e;return o||(o=new ke),i(y,g,n,r,o)}}return!!f&&(o||(o=new ke),function(t,e,n,r,i,o){var s=1&n,a=gn(t),c=a.length;if(c!=gn(e).length&&!s)return!1;for(var u=c;u--;){var h=a[u];if(!(s?h in e:mn.call(e,h)))return!1}var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var y=t[h=a[u]],g=e[h];if(r)var m=s?r(g,y,h,e,t,o):r(y,g,h,t,e,o);if(!(void 0===m?y===g||i(y,g,n,r,o):m)){d=!1;break}p||(p="constructor"==h)}if(d&&!p){var b=t.constructor,v=e.constructor;b==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof v&&v instanceof v||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,n,r,i,o))}function Dn(t,e,n,r,i){return t===e||(null==t||null==e||!De(t)&&!De(e)?t!=t&&e!=e:Nn(t,e,n,r,Dn,i))}function Ln(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}var $n=function(){try{var t=ye(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Un(t,e,n){"__proto__"==e&&$n?$n(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var qn=Object.prototype.hasOwnProperty;function Wn(t,e,n){var r=t[e];qn.call(t,e)&&$t(r,n)&&(void 0!==n||e in t)||Un(t,e,n)}function Yn(t,e,n,r){var i=!n;n||(n={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=r?r(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),i?Un(n,a,c):Wn(n,a,c)}return n}function Bn(t){return t}function Gn(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var Xn=Math.max;function Hn(t){return function(){return t}}var Vn=$n?function(t,e){return $n(t,"toString",{configurable:!0,enumerable:!1,value:Hn(e),writable:!0})}:Bn,Zn=Date.now;var Qn,Jn,Kn,tr=(Qn=Vn,Jn=0,Kn=0,function(){var t=Zn(),e=16-(t-Kn);if(Kn=t,e>0){if(++Jn>=800)return arguments[0]}else Jn=0;return Qn.apply(void 0,arguments)});function er(t,e){return tr(function(t,e,n){return e=Xn(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Xn(r.length-e,0),s=Array(o);++i<o;)s[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=n(s),Gn(t,this,a)}}(t,e,Bn),t+"")}function nr(t,e,n){if(!ee(n))return!1;var r=typeof e;return!!("number"==r?pn(n)&&Ve(e,n.length):"string"==r&&e in n)&&$t(n[e],t)}var rr,ir=(rr=function(t,e,n,r){Yn(e,yn(e),t,r)},er(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=rr.length>3&&"function"==typeof i?(r--,i):void 0,o&&nr(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var s=e[n];s&&rr(t,s,n,i)}return t})),or=hn(Object.getPrototypeOf,Object),sr=Function.prototype,ar=Object.prototype,cr=sr.toString,ur=ar.hasOwnProperty,hr=cr.call(Object);function lr(t){if(!De(t))return!1;var e=te(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!De(t)||"[object Object]"!=te(t))return!1;var e=or(t);if(null===e)return!0;var n=ur.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&cr.call(n)==hr}(t)}var fr=er(function(t,e){try{return Gn(t,void 0,e)}catch(t){return lr(t)?t:new Error(t)}});function dr(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var pr=Object.prototype,yr=pr.hasOwnProperty;function gr(t,e,n,r){return void 0===t||$t(t,pr[n])&&!yr.call(r,n)?e:t}var mr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function br(t){return"\\"+mr[t]}var vr=/<%=([\s\S]+?)%>/g;var xr,_r=(xr={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==xr?void 0:xr[t]});function wr(t){return"symbol"==typeof t||De(t)&&"[object Symbol]"==te(t)}var kr=Xt?Xt.prototype:void 0,Mr=kr?kr.toString:void 0;function Sr(t){if("string"==typeof t)return t;if(Pe(t))return dr(t,Sr)+"";if(wr(t))return Mr?Mr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function zr(t){return null==t?"":Sr(t)}var Er=/[&<>"']/g,Ar=RegExp(Er.source);var Tr={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vr,variable:"",imports:{_:{escape:function(t){return(t=zr(t))&&Ar.test(t)?t.replace(Er,_r):t}}}},Or=/\b__p \+= '';/g,Ir=/\b(__p \+=) '' \+/g,jr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pr=/[()=,{}\[\]\/\s]/,Rr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Cr=/($^)/,Fr=/['\n\r\u2028\u2029\\]/g,Nr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Lr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=un(t),n=[];for(var r in t)("constructor"!=r||!e&&Dr.call(t,r))&&n.push(r);return n}function $r(t,e){return t&&Yn(e,function(t){return pn(t)?an(t,!0):Lr(t)}(e),t)}var Ur="object"==typeof exports&&exports&&!exports.nodeType&&exports,qr=Ur&&"object"==typeof module&&module&&!module.nodeType&&module,Wr=qr&&qr.exports===Ur?Gt.Buffer:void 0,Yr=Wr?Wr.allocUnsafe:void 0;var Br=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)je(e,Ne(t)),t=or(t);return e}:Re;var Gr=Object.prototype.hasOwnProperty;var Xr=/\w*$/;var Hr=Xt?Xt.prototype:void 0,Vr=Hr?Hr.valueOf:void 0;function Zr(t,e,n){var r,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new Ee(a).set(new Ee(s)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return o=(i=t).buffer,new i.constructor(o,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Xr.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return r=t,Vr?Object(Vr.call(r)):{}}}var Qr=Object.create,Jr=function(){function t(){}return function(e){if(!ee(e))return{};if(Qr)return Qr(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var Kr=nn&&nn.isMap,ti=Kr?Je(Kr):function(t){return De(t)&&"[object Map]"==jn(t)};var ei=nn&&nn.isSet,ni=ei?Je(ei):function(t){return De(t)&&"[object Set]"==jn(t)},ri="[object Arguments]",ii="[object Function]",oi="[object Object]",si={};function ai(t,e,n,r,i,o){var s,a=2&e;if(void 0!==s)return s;if(!ee(t))return t;var c=Pe(t);if(c)return s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Gr.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,s);var u=jn(t),h=u==ii||"[object GeneratorFunction]"==u;if(Xe(t))return function(t){var e=t.length,n=Yr?Yr(e):new t.constructor(e);return t.copy(n),n}(t);if(u==oi||u==ri||h&&!i)return s=h?{}:function(t){return"function"!=typeof t.constructor||un(t)?{}:Jr(or(t))}(t),a?function(t,e){return Yn(t,Br(t),e)}(t,$r(s,t)):function(t,e){return Yn(t,Ne(t),e)}(t,function(t,e){return t&&Yn(e,yn(e),t)}(s,t));if(!si[u])return i?t:{};s=Zr(t,u),o||(o=new ke);var l=o.get(t);if(l)return l;o.set(t,s),ni(t)?t.forEach(function(r){s.add(ai(r,e,n,r,t,o))}):ti(t)&&t.forEach(function(r,i){s.set(i,ai(r,e,n,i,t,o))});var f=c?void 0:gn(t);return Ln(f||t,function(r,i){f&&(r=t[i=r]),Wn(s,i,ai(r,e,n,i,t,o))}),s}si[ri]=si["[object Array]"]=si["[object ArrayBuffer]"]=si["[object DataView]"]=si["[object Boolean]"]=si["[object Date]"]=si["[object Float32Array]"]=si["[object Float64Array]"]=si["[object Int8Array]"]=si["[object Int16Array]"]=si["[object Int32Array]"]=si["[object Map]"]=si["[object Number]"]=si[oi]=si["[object RegExp]"]=si["[object Set]"]=si["[object String]"]=si["[object Symbol]"]=si["[object Uint8Array]"]=si["[object Uint8ClampedArray]"]=si["[object Uint16Array]"]=si["[object Uint32Array]"]=!0,si["[object Error]"]=si[ii]=si["[object WeakMap]"]=!1;function ci(t){return ai(t,4)}var ui=/\s/;var hi=/^\s+/;function li(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ui.test(t.charAt(e)););return e}(t)+1).replace(hi,""):t}var fi=/^[-+]0x[0-9a-f]+$/i,di=/^0b[01]+$/i,pi=/^0o[0-7]+$/i,yi=parseInt;var gi=1/0;function mi(t){return t?(t=function(t){if("number"==typeof t)return t;if(wr(t))return NaN;if(ee(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ee(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=li(t);var n=di.test(t);return n||pi.test(t)?yi(t.slice(2),n?2:8):fi.test(t)?NaN:+t}(t))===gi||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function bi(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=mi(t),n=e%1;return e==e?n?e-n:e:0}(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var vi=Object.prototype.hasOwnProperty;function xi(t){if(null==t)return!0;if(pn(t)&&(Pe(t)||"string"==typeof t||"function"==typeof t.splice||Xe(t)||on(t)||We(t)))return!t.length;var e=jn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(un(t))return!dn(t).length;for(var n in t)if(vi.call(t,n))return!1;return!0}let _i=0;function wi(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function ki(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Mi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Si(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function zi(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Ei(t){if(this.__collection__)return this.__collection__[t]}function Ai(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Ti(t){return this.__collection__?this.__collection__.indexOf(t):-1}function Oi(){return this.__collection__?this.__collection__.length:0}function Ii(){this.__collection__=[]}function ji(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function Pi(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function Ri(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,r)}function Ci(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=n.concat(r,this.__collection__)}class Fi{constructor(){this.__collection__=[],this.insertAt=ki,this.append=Mi,this.prepend=Si,this.remove=zi,this.getAt=Ei,this.forEach=Ai,this.indexOf=Ti,this.size=Oi,this.clear=Ii,this.moveForward=ji,this.moveBackward=Pi,this.moveToHead=Ri,this.moveToTail=Ci}}const Ni=/\s+/;function Di(t,e,n,r){if(!n)return!0;if("object"==typeof n){for(const r in n){const i=n[r];t[e].apply(t,[r,i])}return!1}if(Ni.test(n)){return n.split(Ni).forEach(n=>t[e].apply(t,[n].concat(r))),!1}return!0}const Li=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],$i={withEvent(){Li.forEach(t=>this[t]=$i[t])},on(t,e,n){if(!Di(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!Di(this,"once",t,[e,n])||!e)return this;const r=this,i=function(t){return bi(2,t)}(function(){r.off(t,i,n),e.apply(r,arguments)});return i._callback=e,this.on(t,i,n),this},off(t,e,n){if(!this._listeners||!Di(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let r;r=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<r.length;t++){const i=r[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||n)for(let r=0;r<o.length;r++){const i=o[r];(e&&e!==i.callback&&e!==i.callback._callback||n&&n!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Fi),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&qi(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],r=this._listeners["(all)"];return n&&Ui(n,arguments),r&&Ui(r,arguments),this},trigger(t){G.enabled&&G.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&qi(this._delegators,e),!this._listeners)return this;if(!Di(this,"trigger",t,e))return this;const n=this._listeners[t],r=this._listeners["(all)"];return n&&Ui(n,e),r&&Ui(r,e),this},stopListening(t,e,n){let r=this._listeningTo;if(!r)return this;const i=!e&&!n;n||"object"!=typeof e||(n=this),t&&(r={},r[t._listenId]=t);for(const t in r){const o=r[t];o.off(e,n,this),(i||xi(o._events))&&delete this._listeningTo[t]}return this}};function Ui(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function qi(t,e){t.forEach(t=>$i.delegate.apply(t,e))}const Wi={listenTo:"on",listenToOnce:"once"};for(const t in Wi){const e=Wi[t];$i[t]=function(t,n,r){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++_i}`);return i[t._listenId]=t,r||"object"!=typeof n||(r=this),t[e](n,r,this),this}}const Yi=$i.on,Bi=$i.off,Gi=$i.once,Xi=$i.trigger,Hi=$i.delegate_on,Vi=$i.delegate_off;const Zi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Qi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ki(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var to,eo={exports:{}};var no=(to||(to=1,function(t){var e=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new O(r||[]);return i(s,"_invoke",{value:z(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f="suspendedStart",d="suspendedYield",p="executing",y="completed",g={};function m(){}function b(){}function v(){}var x={};u(x,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(I([])));w&&w!==n&&r.call(w,s)&&(x=w);var k=v.prototype=m.prototype=Object.create(x);function M(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function n(i,o,s,a){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,s,a)},function(t){n("throw",t,s,a)}):e.resolve(h).then(function(t){u.value=t,s(u)},function(t){return n("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e(function(e,i){n(t,r,e,i)})}return o=o?o.then(i,i):i()}})}function z(t,n,r){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:e,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var u=l(t,n,r);if("normal"===u.type){if(i=r.done?y:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=y,r.method="throw",r.arg=u.arg)}}}function E(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=l(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(t){if(null!=t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=v,i(k,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:b,configurable:!0}),b.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},M(S.prototype),u(S.prototype,a,function(){return this}),t.AsyncIterator=S,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var s=new S(h(e,n,r,i),o);return t.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},M(k),u(k,c,"Generator"),u(k,s,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=I,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return a.type="throw",a.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:I(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],r=0,i="",o=0,s=arguments.length;o!==s;++o){var a=+arguments[o];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?r=n.push(a):(a-=65536,r=n.push(55296+(a>>10),a%1024+56320)),r>=16383&&(i+=t.apply(null,n),n.length=0)}return i+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
|
|
7
|
-
/*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){if(!a&&Ki)return Ki(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,n,r)}return n[s].exports}for(var o=Ki,s=0;s<r.length;s++)i(r[s]);return i}return t}()({1:[function(t,e,n){var r=t("./utils"),i=function(){var t=r.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],i=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],o=["Thousand","Million","Billion","Trillion"];function s(t,r){var s=function(t,r,a){var c="";if(t<=19)c=(r?" and ":"")+(a?n[t]:e[t]);else if(t<100){var u=Math.floor(t/10),h=t%10;c=(r?" and ":"")+i[u-2],h>0?c+="-"+s(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(t<1e3){var l=Math.floor(t/100),f=t%100;c=(r?", ":"")+e[l]+" Hundred",f>0?c+=s(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(t)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),y=Math.floor(t/p),g=t-y*p;c=(r?", ":"")+s(y,!1,!1)+" "+o[d-1],g>0?c+=s(g,!0,a):a&&(c+="th")}return c};return s(t,!1,r)}var a=Object.create(null);function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];return e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)}),n.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,o.forEach(function(t,e){var n=t.toLowerCase(),r=Math.pow(10,3*(e+1));a[n]=r,a[n+"th"]=r});var u=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function l(t){for(var e=0;e<u.length;e++){var n=u[e];if(t>=n[0])return n[1]+l(t-n[0])}return""}function f(t){for(var e=0,n=1,r=t.length-1;r>=0;r--){var i=t[r],o=h[i];o<n?e-=o:(n=o,e+=o)}return e}function d(t,e){for(var n=[],r=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+r)),t=Math.floor((t-1)/26);return n.join("")}function p(t,e){for(var n=e.charCodeAt(0),r=0,i=0;i<t.length;i++)r+=(t.charCodeAt(t.length-i-1)-n+1)*Math.pow(26,i);return r}function y(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var g={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var r,i=e<0;switch(e=Math.abs(e),n.primary){case g.LETTERS:r=d(e,n.case===m.UPPER?"A":"a");break;case g.ROMAN:r=l(e),n.case===m.UPPER&&(r=r.toUpperCase());break;case g.WORDS:r=s(e,n.ordinal),n.case===m.UPPER?r=r.toUpperCase():n.case===m.LOWER&&(r=r.toLowerCase());break;case g.DECIMAL:r=""+e;var o=n.mandatoryDigits-r.length;if(o>0){var a=new Array(o+1).join("0");r=a+r}if(48!==n.zeroCode&&(r=t(r).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((r.length-1)/n.groupingSeparators.position);c>0;c--){var u=r.length-c*n.groupingSeparators.position;r=r.substr(0,u)+n.groupingSeparators.character+r.substr(u)}else n.groupingSeparators.reverse().forEach(function(t){var e=r.length-t.position;r=r.substr(0,e)+t.character+r.substr(e)});if(n.ordinal){var h={1:"st",2:"nd",3:"rd"}[r[r.length-1]];(!h||r.length>1&&"1"===r[r.length-2])&&(h="th"),r+=h}break;case g.SEQUENCE:throw{code:"D3130",value:n.token}}return i&&(r="-"+r),r}var v=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function x(e){var n,r={type:"integer",primary:g.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?n=e:(n=e.substring(0,i),"o"===e.substring(i+1)[0]&&(r.ordinal=!0)),n){case"A":r.case=m.UPPER;case"a":r.primary=g.LETTERS;break;case"I":r.case=m.UPPER;case"i":r.primary=g.ROMAN;break;case"W":r.case=m.UPPER,r.primary=g.WORDS;break;case"Ww":r.case=m.TITLE,r.primary=g.WORDS;break;case"w":r.primary=g.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(n).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,n=0;n<v.length;n++){var r=v[n];if(t>=r&&t<=r+9){if(e=!0,s++,u++,null===o)o=r;else if(r!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){r.primary=g.DECIMAL,r.zeroCode=o,r.mandatoryDigits=s,r.optionalDigits=a;var h=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var r=t.map(function(t){return t.position}),i=function(t,e){return 0===e?t:i(e,t%e)},o=r.reduce(i),s=1;s<=r.length;s++)if(-1===r.indexOf(s*o))return 0;return o}(c);h>0?(r.regular=!0,r.groupingSeparators={position:h,character:c[0].character}):(r.regular=!1,r.groupingSeparators=c)}else r.primary=g.SEQUENCE,r.token=n}return r}var _={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function w(t){for(var e=[],n={type:"datetime",parts:e},r=function(n,r){if(r>n){var i=t.substring(n,r);i=i.split("]]").join("]"),e.push({type:"literal",value:i})}},i=0,o=0;o<t.length;){if("["===t.charAt(o)){if("["===t.charAt(o+1)){r(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(r(i,o),i=o,-1===(o=t.indexOf("]",i)))throw{code:"D3135"};var s,a=t.substring(i+1,o),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},u=a.lastIndexOf(",");if(-1!==u){var h=a.substring(u+1),l=h.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===l?f=h:(f=h.substring(0,l),d=h.substring(l+1));var y={min:p(f),max:p(d)};c.width=y,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var g=s.charAt(s.length-1);-1!=="atco".indexOf(g)?(c.presentation2=g,"o"===g&&(c.ordinal=!0),c.presentation1=s.substring(0,s.length-1)):c.presentation1=s}else c.presentation1=_[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=m.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=m.TITLE:c.names=m.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=x(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var v=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;v>=2&&(c.n=v)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=x(c.presentation1)),e.push(c),i=o+1}o++}return r(i,o),n}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=864e5,z=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*S:e-(n-1)*S},E=function(t,e){return{year:t,month:e,nextMonth:function(){return 11===e?E(t+1,0):E(t,e+1)},previousMonth:function(){return 0===e?E(t-1,11):E(t,e-1)},nextYear:function(){return E(t+1,e)},previousYear:function(){return E(t-1,e)}}},A=function(t,e){return(e-t)/(7*S)+1},T=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/S+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var r=E(t.getUTCFullYear(),0),i=z(r),o=Date.UTC(r.year,t.getUTCMonth(),t.getUTCDate()),s=A(i,o);if(s>52)o>=z(r.nextYear())&&(s=1);else if(s<1){var a=z(r.previousYear());s=A(a,o)}n=Math.floor(s);break;case"w":var c=E(t.getUTCFullYear(),t.getUTCMonth()),u=z(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),l=A(u,h);if(l>4)h>=z(c.nextMonth())&&(l=1);else if(l<1){var f=z(c.previousMonth());l=A(f,h)}n=Math.floor(l);break;case"X":var d=E(t.getUTCFullYear(),0),p=z(d),y=z(d.nextYear()),g=t.getTime();n=g<p?d.year-1:g>=y?d.year+1:d.year;break;case"x":var m=E(t.getUTCFullYear(),t.getUTCMonth()),b=z(m),v=m.nextMonth(),x=z(v),_=t.getTime();n=_<b?m.previousMonth().month+1:_>=x?v.month+1:m.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},O=null;function I(t,e,n){var r=0,i=0;if(void 0!==n){var o=parseInt(n);r=Math.floor(o/100),i=o%100}var s,a=function(t,e){var n=T(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=M[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=k[n]}e.names===m.UPPER?n=n.toUpperCase():e.names===m.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*r+i;if(e.integerFormat.regular)n=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)n=b(r,e.integerFormat),0!==i&&(n+=":"+y(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};n=b(o,e.integerFormat)}}o>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===o&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===O&&(O=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),s=O):s=w(e);var c=new Date(t+60*(60*r+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function j(t){var e=Object.create(null);if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e=Object.create(null);if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var r=0,i=0;return n?(r=Number.parseInt(e.substring(0,e.indexOf(n.character))),i=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?r=Number.parseInt(e):(r=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*r+i}}else if("f"===t.component)e.regex="[0-9]+",e.parse=function(t){return 1e3*parseFloat("0."+t.substring(0,3))};else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var r=Object.create(null);if("M"===t.component||"x"===t.component)M.forEach(function(e,n){t.width&&t.width.max?r[e.substring(0,t.width.max)]=n+1:r[e]=n+1});else if("F"===t.component)k.forEach(function(e,n){n>0&&(t.width&&t.width.max?r[e.substring(0,t.width.max)]=n:r[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};r={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return r[t]}}return e.component=t.component,e});else{e.type="integer";var n,i=t.case===m.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case g.LETTERS:e.regex=i?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,i?"A":"a")};break;case g.ROMAN:e.regex=i?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(i?t:t.toUpperCase())};break;case g.WORDS:e.regex="(?:"+r.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case g.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case g.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function P(t,e){if(void 0!==t)return j(x(e)).parse(t)}function R(t,e){var n=j(w(e)),r="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(r,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,h=47,l=Object.create(null),f=1;f<i.length;f++){var d=n.parts[f-1];d.parse&&(l[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(l).length)return;var p=0,y=function(t){p<<=1,p+=t?1:0},g=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return y(l[t])});var m=!g(o)&&g(s),b=g(a),v=!b&&g(c);p=0,"PHhmsf".split("").forEach(function(t){return y(l[t])});var x=!g(u)&&g(h),_=(m?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),k=this.environment.timestamp,M=!1,S=!1;if(_.split("").forEach(function(t){if(void 0===l[t])M?(l[t]=-1!=="MDd".indexOf(t)?1:0,S=!0):l[t]=T(k,t);else if(M=!0,S)throw{code:"D3136"}}),l.M>0?l.M-=1:l.M=0,m){var z=Date.UTC(l.Y,0),E=1e3*(l.d-1)*60*60*24,A=new Date(z+E);l.M=A.getUTCMonth(),l.D=A.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(l.H=12===l.h?0:l.h,1===l.P&&(l.H+=12));var O=Date.UTC(l.Y,l.M,l.D,l.H,l.m,l.s,l.f);return(l.Z||l.z)&&(O-=60*(l.Z||l.z)*1e3),O}}var C=new RegExp("^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function F(t,e){if(void 0!==t){if(void 0===e){if(!C.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return R.call(this,t,e)}}function N(t,e,n){if(void 0!==t)return I.call(this,t,e,n)}return{formatInteger:y,parseInteger:P,fromMillis:N,toMillis:F}}();e.exports=i},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(s(t)+" is not iterable")}function c(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,h=Object.create(c.prototype);return u(h,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),h}var s={};function a(){}function h(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(u(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return h.prototype=l,u(d,"constructor",l),u(l,"constructor",h),h.displayName="GeneratorFunction",u(l,i,"GeneratorFunction"),u(d),u(d,i,"Generator"),u(d,r,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:o,m:p}})()}function u(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}u=function(t,e,n,r){function o(e,n){u(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},u(t,e,n,r)}var h=t("./utils"),l=function(){var t=c().m(W),e=c().m(Y),i=c().m(B),o=c().m(G),u=c().m(K),l=c().m(pt),f=c().m(yt),d=c().m(gt),p=c().m(bt),y=c().m(zt),g=c().m(Ot),m=c().m(Pt),b=h.isNumeric,v=h.isArrayOfStrings,x=h.isArrayOfNumbers,_=h.createSequence,w=h.isSequence,k=h.isFunction,M=h.isLambda,S=h.isIterable,z=h.getFunctionArity,E=h.isDeepEqual,A=h.stringToArray;function T(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function O(t){return void 0===t?0:t.length}function I(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function j(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function R(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(k(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var r=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&b(e)?Number(e.toPrecision(15)):e&&k(e)?"":e},r)}return n}}function C(t,e,n){if(void 0!==t){var r=A(t),i=r.length;if(i+e<0&&(e=0),void 0!==n){if(n<=0)return"";var o=e>=0?e+n:i+e+n;return r.slice(e,o).join("")}return r.slice(e).join("")}}function F(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function N(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function D(t){if(void 0!==t)return t.toLowerCase()}function L(t){if(void 0!==t)return t.toUpperCase()}function $(t){if(void 0!==t)return A(t).length}function U(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function q(t,e,n){if(void 0!==t){var r;void 0!==n&&0!==n.length||(n=" ");var i=Math.abs(e)-$(t);if(i>0){var o=new Array(i+1).join(n);n.length>1&&(o=C(o,0,i)),r=e>0?t+o:o+t}else r=t;return r}}function W(e,n){var r;return c().w(function(t){for(;;)switch(t.n){case 0:if(r=e.apply(this,[n]),!S(r)){t.n=2;break}return t.d(a(r),1);case 1:r=t.v;case 2:if(!r||"number"==typeof r.start||"number"===r.end||Array.isArray(r.groups)||k(r.next)){t.n=3;break}throw{code:"T1010",stack:(new Error).stack};case 3:return t.a(2,r)}},t,this)}function Y(t,n){var r,i;return c().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof n){e.n=2;break}r=-1!==t.indexOf(n),e.n=4;break;case 2:return e.d(a(W(n,t)),3);case 3:i=e.v,r=void 0!==i;case 4:return e.a(2,r)}},e)}function B(t,e,n){var r,o,s;return c().w(function(i){for(;;)switch(i.n){case 0:if(void 0!==t){i.n=1;break}return i.a(2,void 0);case 1:if(!(n<0)){i.n=2;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 2:if(r=_(),!(void 0===n||n>0)){i.n=6;break}return o=0,i.d(a(W(e,t)),3);case 3:if(void 0===(s=i.v)){i.n=6;break}case 4:if(void 0===s||!(void 0===n||o<n)){i.n=6;break}return r.push({match:s.match,index:s.start,groups:s.groups}),i.d(a(W(s.next)),5);case 5:s=i.v,o++,i.n=4;break;case 6:return i.a(2,r)}},i)}function G(t,e,n,r){var i,s,u,h,l,f,d,p;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:if(i=this,""!==e){o.n=2;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 2:if(!(r<0)){o.n=3;break}throw{code:"D3011",stack:(new Error).stack,value:r,index:4};case 3:if(s="string"==typeof n?function(t){for(var e="",r=0,i=n.indexOf("$",r);-1!==i&&r<n.length;){e+=n.substring(r,i),r=i+1;var o=n.charAt(r);if("$"===o)e+="$",r++;else if("0"===o)e+=t.match,r++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(n.substring(r,r+s),10),s>1&&i>t.groups.length&&(i=parseInt(n.substring(r,r+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}r+=i.toString().length}}i=n.indexOf("$",r)}return e+=n.substring(r)}:n,u="",h=0,!(void 0===r||r>0)){o.n=15;break}if(l=0,"string"!=typeof e){o.n=4;break}for(f=t.indexOf(e,h);-1!==f&&(void 0===r||l<r);)u+=t.substring(h,f),u+=n,h=f+e.length,l++,f=t.indexOf(e,h);u+=t.substring(h),o.n=14;break;case 4:return o.d(a(W(e,t)),5);case 5:if(void 0===(d=o.v)){o.n=13;break}case 6:if(void 0===d||!(void 0===r||l<r)){o.n=12;break}if(u+=t.substring(h,d.start),p=s.apply(i,[d]),!S(p)){o.n=8;break}return o.d(a(p),7);case 7:p=o.v;case 8:if("string"!=typeof p){o.n=9;break}u+=p,o.n=10;break;case 9:throw{code:"D3012",stack:(new Error).stack,value:p};case 10:return h=d.start+d.match.length,l++,o.d(a(W(d.next)),11);case 11:d=o.v,o.n=6;break;case 12:u+=t.substring(h),o.n=14;break;case 13:u=t;case 14:o.n=16;break;case 15:u=t;case 16:return o.a(2,u)}},o,this)}function X(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function H(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function V(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function Z(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function J(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function K(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!(n<0)){c.n=2;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 2:if(r=[],!(void 0===n||n>0)){c.n=9;break}if("string"!=typeof e){c.n=3;break}r=t.split(e,n),c.n=9;break;case 3:return i=0,c.d(a(W(e,t)),4);case 4:if(void 0===(o=c.v)){c.n=8;break}s=0;case 5:if(void 0===o||!(void 0===n||i<n)){c.n=7;break}return r.push(t.substring(s,o.start)),s=o.end,c.d(a(W(o.next)),6);case 6:o=c.v,i++,c.n=5;break;case 7:(void 0===n||i<n)&&r.push(t.substring(s)),c.n=9;break;case 8:r.push(t);case 9:return c.a(2,r)}},u)}function tt(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function et(t,e,n){if(void 0!==t){var r={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&h.keys(n).forEach(function(t){r[t]=n[t]});for(var i=[],o=r["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([r["decimal-separator"],r["exponent-separator"],r["grouping-separator"],r.digit,r["pattern-separator"]]),c=e.split(r["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,n,i,o,s=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(n+1)}(),u=t.substring(s.length,t.length-c.length),h=t.indexOf(r["exponent-separator"],s.length);-1===h||h>t.length-c.length?(e=u,n=void 0):(e=u.substring(0,h),n=u.substring(h+1));var l=e.indexOf(r["decimal-separator"]);return-1===l?(i=e,o=c):(i=e.substring(0,l),o=e.substring(l+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:n,integerPart:i,fractionalPart:o,subpicture:t}},l=function(t){var e,n,o=t.subpicture,s=o.indexOf(r["decimal-separator"]);s!==o.lastIndexOf(r["decimal-separator"])&&(e="D3081"),o.indexOf(r.percent)!==o.lastIndexOf(r.percent)&&(e="D3082"),o.indexOf(r["per-mille"])!==o.lastIndexOf(r["per-mille"])&&(e="D3083"),-1!==o.indexOf(r.percent)&&-1!==o.indexOf(r["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var u=t.mantissaPart.charAt(n);if(-1!==i.indexOf(u)||u===r.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==s?o.charAt(s-1)!==r["grouping-separator"]&&o.charAt(s+1)!==r["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===r["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(r["grouping-separator"]+r["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(r.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(r.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var l="string"==typeof t.exponentPart;if(l&&t.exponentPart.length>0&&(-1!==o.indexOf(r.percent)||-1!==o.indexOf(r["per-mille"]))&&(e="D3092"),l&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},f=function(t){var e=function(e,n){for(var o=[],s=e.indexOf(r["grouping-separator"]);-1!==s;){var a=(n?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length;o.push(a),s=t.integerPart.indexOf(r["grouping-separator"],s+1)}return o},n=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function(t,n){return 0===n?t:e(n,t%n)},n=t.reduce(e),r=1;r<=t.length;r++)if(-1===t.indexOf(r*n))return 0;return n}(n),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),h=u.filter(function(t){return-1!==i.indexOf(t)}).length,l=u.filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===l&&(f?(h=1,l=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(r.digit)&&(a=1),0===a&&0===h&&(h=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:l,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},d=c.map(u);d.forEach(l);var p,y,g,m,b=d.map(f),v=r["minus-sign"],x=r["zero-digit"],_=r["decimal-separator"],w=r["grouping-separator"];if(1===b.length&&(b.push(JSON.parse(JSON.stringify(b[0]))),b[1].prefix=v+b[1].prefix),y=-1!==(p=t>=0?b[0]:b[1]).picture.indexOf(r.percent)?100*t:-1!==p.picture.indexOf(r["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=y;else{var k=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(g=y,m=0;g<M;)g*=10,m-=1;for(;g>k;)g/=10,m+=1}var S=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==x&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),n},z=S(at(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=z.indexOf(".");for(-1===E?z+=_:z=z.replace(".",_);z.charAt(0)===x;)z=z.substring(1);for(;z.charAt(z.length-1)===x;)z=z.substring(0,z.length-1);E=z.indexOf(_);var A=p.minimumIntegerPartSize-E,T=p.minimumFactionalPartSize-(z.length-E-1);if(z=(A>0?new Array(A+1).join(x):"")+z,z+=T>0?new Array(T+1).join(x):"",E=z.indexOf(_),p.regularGrouping>0)for(var O=Math.floor((E-1)/p.regularGrouping),I=1;I<=O;I++)z=[z.slice(0,E-I*p.regularGrouping),w,z.slice(E-I*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){z=[z.slice(0,E-t),w,z.slice(E-t)].join(""),E++});if(E=z.indexOf(_),p.fractionalPartGroupingPositions.forEach(function(t){z=[z.slice(0,t+E+1),w,z.slice(t+E+1)].join("")}),E=z.indexOf(_),-1!==p.picture.indexOf(_)&&E!==z.length-1||(z=z.substring(0,z.length-1)),void 0!==m){var j=S(m,0);(A=p.minimumExponentSize-j.length)>0&&(j=new Array(A+1).join(x)+j),z=z+r["exponent-separator"]+(m<0?v:"")+j}return z=p.prefix+z+p.suffix}}function nt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function rt(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function it(t){if(void 0!==t)return Math.abs(t)}function ot(t){if(void 0!==t)return Math.floor(t)}function st(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var n;if(void 0!==t){if(e){var r=t.toString().split("e");t=+(r[0]+"e"+(r[1]?+r[1]+e:e))}var i=(n=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(n%2)&&(n-=1),e&&(r=n.toString().split("e"),n=+(r[0]+"e"+(r[1]?+r[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ct(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ut(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function ht(){return Math.random()}function lt(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=lt(t[0]):t.length>1&&(e=t.filter(function(t){return lt(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):b(t)?0!==t&&(e=!0):null!==t&&"object"===s(t)?h.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ft(t){if(void 0!==t)return!lt(t)}function dt(t,e,n,r){var i=[e],o=z(t);return o>=2&&i.push(n),o>=3&&i.push(r),i}function pt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=dt(e,t[r],r,t),s.d(a(e.apply(this,i)),3);case 3:void 0!==(o=s.v)&&n.push(o);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},l,this)}function yt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=t[r],o=dt(e,i,r,t),s.d(a(e.apply(this,o)),3);case 3:lt(s.v)&&n.push(i);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},f,this)}function gt(t,e){var n,r,i,o,s,u,h;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:n=!1,i=0;case 2:if(!(i<t.length)){c.n=7;break}if(o=t[i],s=!0,void 0===e){c.n=4;break}return u=dt(e,o,i,t),c.d(a(e.apply(this,u)),3);case 3:h=c.v,s=lt(h);case 4:if(!s){c.n=6;break}if(n){c.n=5;break}r=o,n=!0,c.n=6;break;case 5:throw{stack:(new Error).stack,code:"D3138",index:i};case 6:i++,c.n=2;break;case 7:if(n){c.n=8;break}throw{stack:(new Error).stack,code:"D3139"};case 8:return c.a(2,r)}},d,this)}function mt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),r=0;r<n;r++){var i=e.map(function(t){return t[r]});t.push(i)}return t}function bt(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!((i=z(e))<2)){c.n=2;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 2:void 0===n&&t.length>0?(r=t[0],o=1):(r=n,o=0);case 3:if(!(o<t.length)){c.n=5;break}return s=[r,t[o]],i>=3&&s.push(o),i>=4&&s.push(t),c.d(a(e.apply(this,s)),4);case 4:r=c.v,o++,c.n=3;break;case 5:return c.a(2,r)}},p,this)}function vt(t){var e=_();if(Array.isArray(t)){var n=Object.create(null);t.forEach(function(t){vt(t).forEach(function(t){n[t]=!0})}),e=vt(n)}else null===t||"object"!==s(t)||M(t)||h.keys(t).forEach(function(t){return e.push(t)});return e}function xt(t,e){var n;if(Array.isArray(t)){n=_();for(var r=0;r<t.length;r++){var i=xt(t[r],e);void 0!==i&&(Array.isArray(i)?i.forEach(function(t){return n.push(t)}):n.push(i))}}else null!==t&&"object"===s(t)&&Object.prototype.hasOwnProperty.call(t,e)&&!k(t)&&(n=t[e]);return n}function _t(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=_(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function wt(t){return void 0!==t}function kt(t){var e=_();if(Array.isArray(t))t.forEach(function(t){e=_t(e,kt(t))});else if(null===t||"object"!==s(t)||M(t))e=t;else{var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value,a=Object.create(null);a[o]=t[o],e.push(a)}}catch(t){i.e(t)}finally{i.f()}}return e}function Mt(t){if(void 0!==t){var e=Object.create(null);return t.forEach(function(t){var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;e[o]=t[o]}}catch(t){i.e(t)}finally{i.f()}}),e}}function St(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),r=0;r<e;r++)n[e-r-1]=t[r];return n}}function zt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=_(),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=dt(e,t[s],s,t),c.d(a(e.apply(this,u)),3);case 3:void 0!==(l=c.v)&&n.push(l);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return c.a(2,n)}},y,this,[[1,6,7,8]])}function Et(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function At(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function Tt(t){if(void 0!==t)return null===t?"null":b(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":k(t)?"function":"object"}function Ot(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:if(!(t.length<=1)){s.n=2;break}return s.a(2,t);case 2:if(void 0!==e){s.n=4;break}if(x(t)||v(t)){s.n=3;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 3:n=c().m(function t(e,n){return c().w(function(t){for(;;)if(0===t.n)return t.a(2,e>n)},t)}),s.n=5;break;case 4:n=e;case 5:return r=c().m(function t(e,r){var i,o;return c().w(function(t){for(;;)switch(t.n){case 0:return i=c().m(function t(e,r,o){return c().w(function(t){for(;;)switch(t.n){case 0:if(0!==r.length){t.n=1;break}Array.prototype.push.apply(e,o),t.n=6;break;case 1:if(0!==o.length){t.n=2;break}Array.prototype.push.apply(e,r),t.n=6;break;case 2:return t.d(a(n(r[0],o[0])),3);case 3:if(!t.v){t.n=5;break}return e.push(o[0]),t.d(a(i(e,r,o.slice(1))),4);case 4:t.n=6;break;case 5:return e.push(r[0]),t.d(a(i(e,r.slice(1),o)),6);case 6:return t.a(2)}},t)}),o=[],t.d(a(i(o,e,r)),1);case 1:return t.a(2,o)}},t)}),i=c().m(function t(e){var n,o,s;return c().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(e)&&!(e.length<=1)){t.n=1;break}return t.a(2,e);case 1:return n=Math.floor(e.length/2),o=e.slice(0,n),s=e.slice(n),t.d(a(i(o)),2);case 2:return o=t.v,t.d(a(i(s)),3);case 3:return s=t.v,t.d(a(r(o,s)),4);case 4:return t.a(2,t.v);case 5:return t.a(2)}},t)}),s.d(a(i(t)),6);case 6:return o=s.v,s.a(2,o)}},g)}function It(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var r=Math.floor(Math.random()*(n+1));n!==r&&(e[n]=e[r]),e[r]=t[n]}return e}}function jt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=w(t)?_():[],n=0;n<t.length;n++){for(var r=t[n],i=!1,o=0;o<e.length;o++)if(E(r,e[o])){i=!0;break}i||e.push(r)}return e}}function Pt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=Object.create(null),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=t[s],l=dt(e,u,s,t),c.d(a(e.apply(this,l)),3);case 3:lt(c.v)&&(n[s]=u);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return 0===h.keys(n).length&&(n=void 0),c.a(2,n)}},m,this,[[1,6,7,8]])}return{sum:T,count:O,max:I,min:j,average:P,string:R,substring:C,substringBefore:F,substringAfter:N,lowercase:D,uppercase:L,length:$,trim:U,pad:q,match:B,contains:Y,replace:G,split:K,join:tt,formatNumber:et,formatBase:nt,number:rt,floor:ot,ceil:st,round:at,abs:it,sqrt:ct,power:ut,random:ht,boolean:lt,not:ft,map:pt,zip:mt,filter:yt,single:gt,foldLeft:bt,sift:Pt,keys:vt,lookup:xt,append:_t,exists:wt,spread:kt,merge:Mt,reverse:St,each:zt,error:Et,assert:At,type:Tt,sort:Ot,shuffle:It,distinct:jt,base64encode:X,base64decode:H,encodeUrlComponent:V,encodeUrl:Z,decodeUrlComponent:Q,decodeUrl:J}}();e.exports=l}).call(this)}).call(this,void 0!==Qi?Qi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function r(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=s(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(i(t)+" is not iterable")}function u(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return h(u,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),u}var s={};function a(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(h(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,h(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,h(d,"constructor",l),h(l,"constructor",c),c.displayName="GeneratorFunction",h(l,i,"GeneratorFunction"),h(d),h(d,i,"Generator"),h(d,r,function(){return this}),h(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:o,m:p}})()}function h(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}h=function(t,e,n,r){function o(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},h(t,e,n,r)}var l=t("./datetime"),f=t("./functions"),d=t("./utils"),p=t("./parser"),y=t("./signature"),g=function(){var t=u().m(W),e=u().m(Y),n=u().m(G),s=u().m(X),a=u().m(H),h=u().m(V),g=u().m(Z),m=u().m(Q),b=u().m(ct),v=u().m(lt),x=u().m(pt),_=u().m(yt),w=u().m(gt),k=u().m(vt),M=u().m(wt),S=u().m(kt),z=u().m(Mt),E=u().m(St),A=u().m(Et),T=u().m(Tt),O=u().m(jt),I=u().m(Ct),j=d.isNumeric,P=d.isArrayOfStrings,R=d.isArrayOfNumbers,C=d.createSequence,F=d.isSequence,N=d.isFunction,D=d.isLambda,L=d.isIterable,$=d.getFunctionArity,U=d.isDeepEqual,q=Nt(null);function W(e,n,r){var i,o,s,a,h;return u().w(function(t){for(;;)switch(t.n){case 0:(o=r.lookup("__evaluate_entry"))&&o(e,n,r),h=e.type,t.n="path"===h?1:"binary"===h?3:"unary"===h?5:"name"===h?7:"string"===h||"number"===h||"value"===h?8:"wildcard"===h?9:"descendant"===h?10:"parent"===h?11:"condition"===h?12:"block"===h?14:"bind"===h?16:"regex"===h?18:"function"===h?19:"variable"===h?21:"lambda"===h?22:"partial"===h?23:"apply"===h?25:"transform"===h?27:28;break;case 1:return t.d(c(Y(e,n,r)),2);case 2:return i=t.v,t.a(3,28);case 3:return t.d(c(Z(e,n,r)),4);case 4:return i=t.v,t.a(3,28);case 5:return t.d(c(Q(e,n,r)),6);case 6:return i=t.v,t.a(3,28);case 7:return i=J(e,n),t.a(3,28);case 8:return i=K(e),t.a(3,28);case 9:return i=tt(e,n),t.a(3,28);case 10:return i=nt(e,n),t.a(3,28);case 11:return i=r.lookup(e.slot.label),t.a(3,28);case 12:return t.d(c(yt(e,n,r)),13);case 13:return i=t.v,t.a(3,28);case 14:return t.d(c(gt(e,n,r)),15);case 15:return i=t.v,t.a(3,28);case 16:return t.d(c(pt(e,n,r)),17);case 17:return i=t.v,t.a(3,28);case 18:return i=mt(e),t.a(3,28);case 19:return t.d(c(kt(e,n,r)),20);case 20:return i=t.v,t.a(3,28);case 21:return i=bt(e,n,r),t.a(3,28);case 22:return i=zt(e,n,r),t.a(3,28);case 23:return t.d(c(Et(e,n,r)),24);case 24:return i=t.v,t.a(3,28);case 25:return t.d(c(wt(e,n,r)),26);case 26:return i=t.v,t.a(3,28);case 27:return i=xt(e,n,r),t.a(3,28);case 28:if(!r.async||null!=i&&"function"==typeof i.then||(i=Promise.resolve(i)),!r.async||"function"!=typeof i.then||!e.nextFunction||"function"!=typeof i[e.nextFunction]){t.n=29;break}t.n=31;break;case 29:return t.n=30,i;case 30:i=t.v;case 31:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.n=35;break}s=0;case 32:if(!(s<e.predicate.length)){t.n=35;break}return t.d(c(V(e.predicate[s].expr,i,r)),33);case 33:i=t.v;case 34:s++,t.n=32;break;case 35:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.n=37;break}return t.d(c(lt(e.group,i,r)),36);case 36:i=t.v;case 37:return(a=r.lookup("__evaluate_exit"))&&a(e,n,r,i),i&&F(i)&&!i.tupleStream&&(e.keepArray&&(i.keepSingleton=!0),0===i.length?i=void 0:1===i.length&&(i=i.keepSingleton?i:i[0])),t.a(2,i)}},t)}function Y(t,n,r){var i,o,s,a,h,l;return u().w(function(e){for(;;)switch(e.n){case 0:i=Array.isArray(n)&&"variable"!==t.steps[0].type?n:C(n),s=!1,a=void 0,h=0;case 1:if(!(h<t.steps.length)){e.n=10;break}if((l=t.steps[h]).tuple&&(s=!0),0!==h||!l.consarray){e.n=3;break}return e.d(c(W(l,i,r)),2);case 2:o=e.v,e.n=7;break;case 3:if(!s){e.n=5;break}return e.d(c(H(l,i,a,r)),4);case 4:a=e.v,e.n=7;break;case 5:return e.d(c(G(l,i,r,h===t.steps.length-1)),6);case 6:o=e.v;case 7:if(s||void 0!==o&&0!==o.length){e.n=8;break}return e.a(3,10);case 8:void 0===l.focus&&(i=o);case 9:h++,e.n=1;break;case 10:if(s)if(t.tuple)o=a;else for(o=C(),h=0;h<a.length;h++)o.push(a[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=C(o)),o.keepSingleton=!0),!Object.prototype.hasOwnProperty.call(t,"group")){e.n=12;break}return e.d(c(lt(t.group,s?a:o,r)),11);case 11:o=e.v;case 12:return e.a(2,o)}},e)}function B(t,e){var n,r=Nt(t),i=o(d.keys(e));try{for(i.s();!(n=i.n()).done;){var s=n.value;r.bind(s,e[s])}}catch(t){i.e(t)}finally{i.f()}return r}function G(t,e,r,i){var o,s,a,h,l;return u().w(function(n){for(;;)switch(n.n){case 0:if("sort"!==t.type){n.n=4;break}return n.d(c(vt(t,e,r)),1);case 1:if(o=n.v,!t.stages){n.n=3;break}return n.d(c(X(t.stages,o,r)),2);case 2:o=n.v;case 3:return n.a(2,o);case 4:o=C(),s=0;case 5:if(!(s<e.length)){n.n=12;break}return n.d(c(W(t,e[s],r)),6);case 6:if(a=n.v,!t.stages){n.n=10;break}h=0;case 7:if(!(h<t.stages.length)){n.n=10;break}return n.d(c(V(t.stages[h].expr,a,r)),8);case 8:a=n.v;case 9:h++,n.n=7;break;case 10:void 0!==a&&o.push(a);case 11:s++,n.n=5;break;case 12:return l=C(),i&&1===o.length&&Array.isArray(o[0])&&!F(o[0])?l=o[0]:Array.prototype.forEach.call(o,function(t){!Array.isArray(t)||t.cons?l.push(t):Array.prototype.forEach.call(t,function(t){return l.push(t)})}),n.a(2,l)}},n)}function X(t,e,n){var r,i,o,a,h;return u().w(function(s){for(;;)switch(s.n){case 0:r=e,i=0;case 1:if(!(i<t.length)){s.n=6;break}o=t[i],h=o.type,s.n="filter"===h?2:"index"===h?4:5;break;case 2:return s.d(c(V(o.expr,r,n)),3);case 3:return r=s.v,s.a(3,5);case 4:for(a=0;a<r.length;a++)r[a][o.value]=a;return s.a(3,5);case 5:i++,s.n=1;break;case 6:return s.a(2,r)}},s)}function H(t,e,n,r){var i,o,s,h,l,f,d,p;return u().w(function(a){for(;;)switch(a.n){case 0:if("sort"!==t.type){a.n=7;break}if(!n){a.n=2;break}return a.d(c(vt(t,n,r)),1);case 1:i=a.v,a.n=4;break;case 2:return a.d(c(vt(t,e,r)),3);case 3:for(o=a.v,(i=C()).tupleStream=!0,s=0;s<o.length;s++)(h={"@":o[s]})[t.index]=s,i.push(h);case 4:if(!t.stages){a.n=6;break}return a.d(c(X(t.stages,i,r)),5);case 5:i=a.v;case 6:return a.a(2,i);case 7:(i=C()).tupleStream=!0,l=r,void 0===n&&(n=e.map(function(t){return{"@":t}})),f=0;case 8:if(!(f<n.length)){a.n=11;break}return l=B(r,n[f]),a.d(c(W(t,n[f]["@"],l)),9);case 9:if(void 0!==(d=a.v))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)h=Object.create(null),Object.assign(h,n[f]),d.tupleStream?Object.assign(h,d[p]):(t.focus?(h[t.focus]=d[p],h["@"]=n[f]["@"]):h["@"]=d[p],t.index&&(h[t.index]=p),t.ancestor&&(h[t.ancestor.label]=n[f]["@"])),i.push(h);case 10:f++,a.n=8;break;case 11:if(!t.stages){a.n=13;break}return a.d(c(X(t.stages,i,r)),12);case 12:i=a.v;case 13:return a.a(2,i)}},a)}function V(t,e,n){var r,i,o,s,a,l;return u().w(function(u){for(;;)switch(u.n){case 0:if(r=C(),e&&e.tupleStream&&(r.tupleStream=!0),Array.isArray(e)||(e=C(e)),"number"!==t.type){u.n=1;break}(i=Math.floor(t.value))<0&&(i=e.length+i),void 0!==(o=e[i])&&(Array.isArray(o)?r=o:r.push(o)),u.n=5;break;case 1:i=0;case 2:if(!(i<e.length)){u.n=5;break}return o=e[i],s=o,a=n,e.tupleStream&&(s=o["@"],a=B(n,o)),u.d(c(W(t,s,a)),3);case 3:l=u.v,j(l)&&(l=[l]),R(l)?Array.prototype.forEach.call(l,function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===i&&r.push(o)}):f.boolean(l)&&r.push(o);case 4:i++,u.n=2;break;case 5:return u.a(2,r)}},h)}function Z(t,e,n){var r,i,o,s,a,h,l,f;return u().w(function(d){for(;;)switch(d.p=d.n){case 0:return d.d(c(W(t.lhs,e,n)),1);case 1:if(i=d.v,o=t.value,s=u().m(function r(){return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(W(t.rhs,e,n)),1);case 1:return r.a(2,r.v)}},r)}),"and"!==o&&"or"!==o){d.n=5;break}return d.p=2,d.d(c(ct(i,s,o)),3);case 3:return d.a(2,d.v);case 4:throw d.p=4,(h=d.v).position=t.position,h.token=o,h;case 5:return d.d(c(s()),6);case 6:a=d.v,d.p=7,l=o,d.n="+"===l||"-"===l||"*"===l||"/"===l||"%"===l?8:"="===l||"!="===l?9:"<"===l||"<="===l||">"===l||">="===l?10:"&"===l?11:".."===l?12:"in"===l?13:14;break;case 8:return r=it(i,a,o),d.a(3,14);case 9:return r=ot(i,a,o),d.a(3,14);case 10:return r=st(i,a,o),d.a(3,14);case 11:return r=ht(i,a),d.a(3,14);case 12:return r=dt(i,a),d.a(3,14);case 13:return r=at(i,a),d.a(3,14);case 14:d.n=16;break;case 15:throw d.p=15,(f=d.v).position=t.position,f.token=o,f;case 16:return d.a(2,r)}},g,null,[[7,15],[2,4]])}function Q(t,e,n){var r,i,o,s,a;return u().w(function(u){for(;;)switch(u.n){case 0:a=t.value,u.n="-"===a?1:"["===a?6:"{"===a?11:13;break;case 1:return u.d(c(W(t.expression,e,n)),2);case 2:if(void 0!==(r=u.v)){u.n=3;break}r=void 0,u.n=5;break;case 3:if(!j(r)){u.n=4;break}r=-r,u.n=5;break;case 4:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:r};case 5:return u.a(3,13);case 6:r=[],i=0;case 7:if(!(i<t.expressions.length)){u.n=10;break}return o=t.expressions[i],u.d(c(W(o,e,n)),8);case 8:void 0!==(s=u.v)&&("["===o.value?r.push(s):r=f.append(r,s));case 9:i++,u.n=7;break;case 10:return t.consarray&&Object.defineProperty(r,"cons",{enumerable:!1,configurable:!1,value:!0}),u.a(3,13);case 11:return u.d(c(lt(t,e,n)),12);case 12:return r=u.v,u.a(3,13);case 13:return u.a(2,r)}},m)}function J(t,e,n){return f.lookup(e,t.value)}function K(t){return t.value}function tt(t,e){var n=C();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null===e||"object"!==i(e)||N(e)||d.keys(e).forEach(function(t){var r=e[t];Array.isArray(r)?(r=et(r),n=f.append(n,r)):n.push(r)}),n}function et(t,e){return void 0===e&&(e=[]),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){et(t,e)}):e.push(t),e}function nt(t,e){var n,r=C();return void 0!==e&&(rt(e,r),n=1===r.length?r[0]:r),n}function rt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){rt(t,e)}):null===t||"object"!==i(t)||N(t)||d.keys(t).forEach(function(n){rt(t[n],e)})}function it(t,e,n){var r;if(void 0!==t&&!j(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!j(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;switch(n){case"+":r=t+e;break;case"-":r=t-e;break;case"*":r=t*e;break;case"/":r=t/e;break;case"%":r=t%e}return r}function ot(t,e,n){var r,o=i(t),s=i(e);if("undefined"===o||"undefined"===s)return!1;switch(n){case"=":r=U(t,e);break;case"!=":r=!U(t,e)}return r}function st(t,e,n){var r,o=i(t),s=i(e);if("undefined"!==o&&"string"!==o&&"number"!==o||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==o&&"number"!==o?t:e};if("undefined"!==o&&"undefined"!==s){if(o!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":r=t<e;break;case"<=":r=t<=e;break;case">":r=t>e;break;case">=":r=t>=e}return r}}function at(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++)if(e[r]===t){n=!0;break}return n}function ct(t,e,n){var r,i,o,s,a,h,l;return u().w(function(u){for(;;)switch(u.n){case 0:i=ut(t),o=n,u.n="and"===o?1:"or"===o?4:7;break;case 1:if(!(s=i)){u.n=3;break}return a=ut,u.d(c(e()),2);case 2:s=a(u.v);case 3:return r=s,u.a(3,7);case 4:if(h=i){u.n=6;break}return l=ut,u.d(c(e()),5);case 5:h=l(u.v);case 6:return r=h,u.a(3,7);case 7:return u.a(2,r)}},b)}function ut(t){var e=f.boolean(t);return void 0!==e&&e}function ht(t,e){var n="",r="";return void 0!==t&&(n=f.string(t)),void 0!==e&&(r=f.string(e)),n.concat(r)}function lt(t,e,n){var i,o,s,a,h,l,d,p,y,g,m,b,x,_,w;return u().w(function(u){for(;;)switch(u.n){case 0:i=Object.create(null),o=Object.create(null),s=!(!e||!e.tupleStream),Array.isArray(e)||(e=C(e)),0===e.length&&e.push(void 0),a=0;case 1:if(!(a<e.length)){u.n=10;break}h=e[a],l=s?B(n,h):n,d=0;case 2:if(!(d<t.lhs.length)){u.n=9;break}return p=t.lhs[d],u.d(c(W(p[0],s?h["@"]:h,l)),3);case 3:if("string"==typeof(y=u.v)||void 0===y){u.n=4;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:y};case 4:if(void 0===y){u.n=8;break}if("_jsonata_lambda"!==y&&"_jsonata_function"!==y){u.n=5;break}throw{code:"D1013",stack:(new Error).stack,position:t.position,value:y};case 5:if(g={data:h,exprIndex:d},!Object.prototype.hasOwnProperty.call(o,y)){u.n=7;break}if(o[y].exprIndex===d){u.n=6;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:y};case 6:o[y].data=f.append(o[y].data,h),u.n=8;break;case 7:o[y]=g;case 8:d++,u.n=2;break;case 9:a++,u.n=1;break;case 10:_=r(o);case 11:if((w=_()).done){u.n=13;break}return y=w.value,g=o[y],m=g.data,l=n,s&&(b=ft(g.data),m=b["@"],delete b["@"],l=B(n,b)),u.d(c(W(t.lhs[g.exprIndex][1],m,l)),12);case 12:void 0!==(x=u.v)&&(i[y]=x),u.n=11;break;case 13:return u.a(2,i)}},v)}function ft(t){if(!Array.isArray(t))return t;var e=Object.create(null);Object.assign(e,t[0]);for(var n=1;n<t.length;n++){var r,i=o(d.keys(t[n]));try{for(i.s();!(r=i.n()).done;){var s=r.value;e[s]=f.append(e[s],t[n][s])}}catch(t){i.e(t)}finally{i.f()}}return e}function dt(t,e){var n;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;if(t>e)return n;var r=e-t+1;if(r>1e7)throw{code:"D2014",stack:(new Error).stack,value:r};n=new Array(r);for(var i=t,o=0;i<=e;i++,o++)n[o]=i;return n.sequence=!0,n}function pt(t,e,n){var r;return u().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(W(t.rhs,e,n)),1);case 1:return r=i.v,n.bind(t.lhs.value,r),i.a(2,r)}},x)}function yt(t,e,n){var r,i;return u().w(function(o){for(;;)switch(o.n){case 0:return o.d(c(W(t.condition,e,n)),1);case 1:if(i=o.v,!f.boolean(i)){o.n=3;break}return o.d(c(W(t.then,e,n)),2);case 2:r=o.v,o.n=5;break;case 3:if(void 0===t.else){o.n=5;break}return o.d(c(W(t.else,e,n)),4);case 4:r=o.v;case 5:return o.a(2,r)}},_)}function gt(t,e,n){var r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:i=Nt(n),o=0;case 1:if(!(o<t.expressions.length)){s.n=4;break}return s.d(c(W(t.expressions[o],e,i)),2);case 2:r=s.v;case 3:o++,s.n=1;break;case 4:return s.a(2,r)}},w)}function mt(t){var e=new $t.RegexEngine(t.value),n=function(r,i){var o;e.lastIndex=i||0;var s=e.exec(r);if(null!==s){if(o={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var a=1;a<s.length;a++)o.groups.push(s[a]);o.next=function(){if(!(e.lastIndex>=r.length)){var i=n(r,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return o};return n}function bt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function vt(t,e,n){var r,o,s,a,h;return u().w(function(l){for(;;)switch(l.n){case 0:return o=e,s=!!e.tupleStream,a=u().m(function e(r,o){var a,h,l,f,d,p,y,g,m;return u().w(function(e){for(;;)switch(e.n){case 0:a=0,h=0;case 1:if(!(0===a&&h<t.terms.length)){e.n=11;break}return l=t.terms[h],f=r,d=n,s&&(f=r["@"],d=B(n,r)),e.d(c(W(l.expression,f,d)),2);case 2:return p=e.v,f=o,d=n,s&&(f=o["@"],d=B(n,o)),e.d(c(W(l.expression,f,d)),3);case 3:if(y=e.v,g=i(p),m=i(y),"undefined"!==g){e.n=4;break}return a="undefined"===m?0:1,e.a(3,10);case 4:if("undefined"!==m){e.n=5;break}return a=-1,e.a(3,10);case 5:if(!("string"!==g&&"number"!==g||"string"!==m&&"number"!==m)){e.n=6;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?p:y};case 6:if(g===m){e.n=7;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:y};case 7:if(p!==y){e.n=8;break}return e.a(3,10);case 8:a=p<y?-1:1;case 9:!0===l.descending&&(a=-a);case 10:h++,e.n=1;break;case 11:return e.a(2,1===a)}},e)}),h={environment:n,input:e},l.d(c(f.sort.apply(h,[o,a])),1);case 1:return r=l.v,l.a(2,r)}},k)}function xt(t,e,n){return Rt(u().m(function e(r){var s,a,h,l,f,p,y,g,m,b,v,x,_;return u().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==r){e.n=1;break}return e.a(2,void 0);case 1:if(s=n.lookup("clone"),N(s)){e.n=2;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 2:return e.d(c(Mt(s,[r],null,n)),3);case 3:return a=e.v,e.d(c(W(t.pattern,a,n)),4);case 4:if(void 0===(h=e.v)){e.n=12;break}Array.isArray(h)||(h=[h]),l=0;case 5:if(!(l<h.length)){e.n=12;break}return f=h[l],e.d(c(W(t.update,f,n)),6);case 6:if(p=e.v,"undefined"===(y=i(p))){e.n=8;break}if("object"===y&&null!==p&&!Array.isArray(p)){e.n=7;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:p};case 7:g=o(d.keys(p));try{for(g.s();!(m=g.n()).done;)b=m.value,f[b]=p[b]}catch(t){g.e(t)}finally{g.f()}case 8:if(void 0===t.delete){e.n=11;break}return e.d(c(W(t.delete,f,n)),9);case 9:if(void 0===(v=e.v)){e.n=11;break}if(x=v,Array.isArray(v)||(v=[v]),P(v)){e.n=10;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:x};case 10:for(_=0;_<v.length;_++)"object"===i(f)&&null!==f&&delete f[v[_]];case 11:l++,e.n=5;break;case 12:return e.a(2,a)}},e)}),"<(oa):o>")}var _t=p("function($f, $g) { function($x){ $g($f($x)) } }");function wt(t,e,n){var r,i,o,s;return u().w(function(a){for(;;)switch(a.n){case 0:return a.d(c(W(t.lhs,e,n)),1);case 1:if(i=a.v,"function"!==t.rhs.type){a.n=3;break}return a.d(c(kt(t.rhs,e,n,{context:i})),2);case 2:r=a.v,a.n=10;break;case 3:return a.d(c(W(t.rhs,e,n)),4);case 4:if(o=a.v,N(o)){a.n=5;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 5:if(!N(i)){a.n=8;break}return a.d(c(W(_t,null,n)),6);case 6:return s=a.v,a.d(c(Mt(s,[i,o],null,n)),7);case 7:r=a.v,a.n=10;break;case 8:return a.d(c(Mt(o,[i],null,n)),9);case 9:r=a.v;case 10:return a.a(2,r)}},M)}function kt(t,e,n,r){var o,s,a,h,l,f,d;return u().w(function(p){for(;;)switch(p.p=p.n){case 0:return p.d(c(W(t.procedure,e,n)),1);case 1:if(void 0!==(s=p.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){p.n=2;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 2:a=[],void 0!==r&&a.push(r.context),h=u().m(function r(){var i,o;return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(W(t.arguments[l],e,n)),1);case 1:i=r.v,N(i)?(o=u().m(function t(){var e,r,o,s=arguments;return u().w(function(t){for(;;)switch(t.n){case 0:for(e=s.length,r=new Array(e),o=0;o<e;o++)r[o]=s[o];return t.d(c(Mt(i,r,null,n)),1);case 1:return t.a(2,t.v)}},t)}),o.arity=$(i),a.push(o)):a.push(i);case 2:return r.a(2)}},r)}),l=0;case 3:if(!(l<t.arguments.length)){p.n=5;break}return p.d(c(h()),4);case 4:l++,p.n=3;break;case 5:return f="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,p.p=6,"object"===i(s)&&(s.token=f,s.position=t.position),p.d(c(Mt(s,a,e,n)),7);case 7:o=p.v,p.n=9;break;case 8:throw p.p=8,(d=p.v).position||(d.position=t.position),d.token||(d.token=f),d;case 9:return p.a(2,o)}},S,null,[[6,8]])}function Mt(t,e,n,r){var i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:return u.d(c(St(t,e,n,r)),1);case 1:i=u.v;case 2:if(!D(i)||!0!==i.thunk){u.n=9;break}return u.d(c(W(i.body.procedure,i.input,i.environment)),3);case 3:o=u.v,"variable"===i.body.procedure.type&&(o.token=i.body.procedure.value),o.position=i.body.procedure.position,s=[],a=0;case 4:if(!(a<i.body.arguments.length)){u.n=7;break}return h=s,u.d(c(W(i.body.arguments[a],i.input,i.environment)),5);case 5:h.push.call(h,u.v);case 6:a++,u.n=4;break;case 7:return u.d(c(St(o,s,n,r)),8);case 8:i=u.v,u.n=2;break;case 9:return u.a(2,i)}},z)}function St(t,e,n,r){var i,o,s,a;return u().w(function(u){for(;;)switch(u.p=u.n){case 0:if(u.p=0,o=e,t&&(o=At(t.signature,e,n)),!D(t)){u.n=2;break}return u.d(c(Tt(t,o)),1);case 1:i=u.v,u.n=9;break;case 2:if(!t||!0!==t._jsonata_function){u.n=5;break}if(s={environment:r,input:n},i=t.implementation.apply(s,o),!L(i)){u.n=4;break}return u.d(c(i),3);case 3:i=u.v;case 4:u.n=9;break;case 5:if("function"!=typeof t){u.n=8;break}if(i=t.apply(n,o),!L(i)){u.n=7;break}return u.d(c(i),6);case 6:i=u.v;case 7:u.n=9;break;case 8:throw{code:"T1006",stack:(new Error).stack};case 9:u.n=11;break;case 10:throw u.p=10,a=u.v,t&&(void 0===a.token&&void 0!==t.token&&(a.token=t.token),a.position=t.position||a.position),a;case 11:return u.a(2,i)}},E,null,[[0,10]])}function zt(t,e,n){var r={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(r.thunk=!0),r.apply=u().m(function t(n,i){return u().w(function(t){for(;;)switch(t.n){case 0:return t.d(c(Mt(r,i,e,n.environment)),1);case 1:return t.a(2,t.v)}},t)}),r}function Et(t,e,n){var r,i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:i=[],o=0;case 1:if(!(o<t.arguments.length)){u.n=5;break}if("operator"!==(s=t.arguments[o]).type||"?"!==s.value){u.n=2;break}i.push(s),u.n=4;break;case 2:return h=i,u.d(c(W(s,e,n)),3);case 3:h.push.call(h,u.v);case 4:o++,u.n=1;break;case 5:return u.d(c(W(t.procedure,e,n)),6);case 6:if(void 0!==(a=u.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){u.n=7;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 7:if(!D(a)){u.n=8;break}r=Ot(a,i),u.n=11;break;case 8:if(!a||!0!==a._jsonata_function){u.n=9;break}r=It(a.implementation,i),u.n=11;break;case 9:if("function"!=typeof a){u.n=10;break}r=It(a,i),u.n=11;break;case 10:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 11:return u.a(2,r)}},A)}function At(t,e,n){return void 0===t?e:t.validate(e,n)}function Tt(t,e){var n,r;return u().w(function(i){for(;;)switch(i.n){case 0:if(r=Nt(t.environment),Array.prototype.forEach.call(t.arguments,function(t,n){r.bind(t.value,e[n])}),"function"!=typeof t.body){i.n=2;break}return i.d(c(jt(t.body,r)),1);case 1:n=i.v,i.n=4;break;case 2:return i.d(c(W(t.body,t.input,r)),3);case 3:n=i.v;case 4:return i.a(2,n)}},T)}function Ot(t,e){var n=Nt(t.environment),r=[];return Array.prototype.forEach.call(t.arguments,function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?r.push(t):n.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:r,body:t.body}}function It(t,e){var n=Pt(t),r="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=p(r);return i.body=t,Ot(i,e)}function jt(t,e){var n,r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:if(n=Pt(t),r=n.map(function(t){return e.lookup(t.trim())}),i={environment:e},o=t.apply(i,r),!L(o)){s.n=2;break}return s.d(c(o),1);case 1:o=s.v;case 2:return s.a(2,o)}},O)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Rt(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=y(e)),n}function Ct(t,e){var n,r,i,o,s;return u().w(function(a){for(;;)switch(a.p=a.n){case 0:if(void 0!==t){a.n=1;break}return a.a(2,void 0);case 1:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!F(n)&&((n=C(n)).outerWrapper=!0)),a.p=2,r=p(t,!1),a.n=4;break;case 3:throw a.p=3,Lt(o=a.v),{stack:(new Error).stack,code:"D3120",value:o.message,error:o};case 4:return a.p=4,a.d(c(W(r,n,this.environment)),5);case 5:i=a.v,a.n=7;break;case 6:throw a.p=6,Lt(s=a.v),{stack:(new Error).stack,code:"D3121",value:s.message,error:s};case 7:return a.a(2,i)}},I,this,[[4,6],[2,3]])}function Ft(t){if(void 0!==t)return JSON.parse(f.string(t))}function Nt(t){var e=Object.create(null);return{bind:function(t,n){e[t]=n},lookup:function(n){var r;return Object.prototype.hasOwnProperty.call(e,n)?r=e[n]:t&&(r=t.lookup(n)),r},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}q.bind("sum",Rt(f.sum,"<a<n>:n>")),q.bind("count",Rt(f.count,"<a:n>")),q.bind("max",Rt(f.max,"<a<n>:n>")),q.bind("min",Rt(f.min,"<a<n>:n>")),q.bind("average",Rt(f.average,"<a<n>:n>")),q.bind("string",Rt(f.string,"<x-b?:s>")),q.bind("substring",Rt(f.substring,"<s-nn?:s>")),q.bind("substringBefore",Rt(f.substringBefore,"<s-s:s>")),q.bind("substringAfter",Rt(f.substringAfter,"<s-s:s>")),q.bind("lowercase",Rt(f.lowercase,"<s-:s>")),q.bind("uppercase",Rt(f.uppercase,"<s-:s>")),q.bind("length",Rt(f.length,"<s-:n>")),q.bind("trim",Rt(f.trim,"<s-:s>")),q.bind("pad",Rt(f.pad,"<s-ns?:s>")),q.bind("match",Rt(f.match,"<s-f<s:o>n?:a<o>>")),q.bind("contains",Rt(f.contains,"<s-(sf):b>")),q.bind("replace",Rt(f.replace,"<s-(sf)(sf)n?:s>")),q.bind("split",Rt(f.split,"<s-(sf)n?:a<s>>")),q.bind("join",Rt(f.join,"<a<s>s?:s>")),q.bind("formatNumber",Rt(f.formatNumber,"<n-so?:s>")),q.bind("formatBase",Rt(f.formatBase,"<n-n?:s>")),q.bind("formatInteger",Rt(l.formatInteger,"<n-s:s>")),q.bind("parseInteger",Rt(l.parseInteger,"<s-s:n>")),q.bind("number",Rt(f.number,"<(nsb)-:n>")),q.bind("floor",Rt(f.floor,"<n-:n>")),q.bind("ceil",Rt(f.ceil,"<n-:n>")),q.bind("round",Rt(f.round,"<n-n?:n>")),q.bind("abs",Rt(f.abs,"<n-:n>")),q.bind("sqrt",Rt(f.sqrt,"<n-:n>")),q.bind("power",Rt(f.power,"<n-n:n>")),q.bind("random",Rt(f.random,"<:n>")),q.bind("boolean",Rt(f.boolean,"<x-:b>")),q.bind("not",Rt(f.not,"<x-:b>")),q.bind("map",Rt(f.map,"<af>")),q.bind("zip",Rt(f.zip,"<a+>")),q.bind("filter",Rt(f.filter,"<af>")),q.bind("single",Rt(f.single,"<af?>")),q.bind("reduce",Rt(f.foldLeft,"<afj?:j>")),q.bind("sift",Rt(f.sift,"<o-f?:o>")),q.bind("keys",Rt(f.keys,"<x-:a<s>>")),q.bind("lookup",Rt(f.lookup,"<x-s:x>")),q.bind("append",Rt(f.append,"<xx:a>")),q.bind("exists",Rt(f.exists,"<x:b>")),q.bind("spread",Rt(f.spread,"<x-:a<o>>")),q.bind("merge",Rt(f.merge,"<a<o>:o>")),q.bind("reverse",Rt(f.reverse,"<a:a>")),q.bind("each",Rt(f.each,"<o-f:a>")),q.bind("error",Rt(f.error,"<s?:x>")),q.bind("assert",Rt(f.assert,"<bs?:x>")),q.bind("type",Rt(f.type,"<x:s>")),q.bind("sort",Rt(f.sort,"<af?:a>")),q.bind("shuffle",Rt(f.shuffle,"<a:a>")),q.bind("distinct",Rt(f.distinct,"<x:x>")),q.bind("base64encode",Rt(f.base64encode,"<s-:s>")),q.bind("base64decode",Rt(f.base64decode,"<s-:s>")),q.bind("encodeUrlComponent",Rt(f.encodeUrlComponent,"<s-:s>")),q.bind("encodeUrl",Rt(f.encodeUrl,"<s-:s>")),q.bind("decodeUrlComponent",Rt(f.decodeUrlComponent,"<s-:s>")),q.bind("decodeUrl",Rt(f.decodeUrl,"<s-:s>")),q.bind("eval",Rt(Ct,"<sx?:x>")),q.bind("toMillis",Rt(l.toMillis,"<s-s?:n>")),q.bind("fromMillis",Rt(l.fromMillis,"<n-s?s?:s>")),q.bind("clone",Rt(Ft,"<(oa)-:o>"));var Dt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1013:"Object property names starting with _jsonata_ are reserved for internal use: {{value}}",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Lt(t){var e=Dt[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function $t(t,e){var n,r;try{n=p(t,e&&e.recover),r=n.errors,delete n.errors}catch(t){throw Lt(t),t}var i=Nt(q),s=new Date;return i.bind("now",Rt(function(t,e){return l.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Rt(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?$t.RegexEngine=e.RegexEngine:$t.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==r){var c={code:"S0500",position:0};throw Lt(c),c}if(void 0!==e){var u;u=Nt(i);var h,l=o(d.keys(e));try{for(l.s();!(h=l.n()).done;){var f=h.value;u.bind(f,e[f])}}catch(c){l.e(c)}finally{l.f()}}else u=i;var p,y;if(u.bind("$",t),s=new Date,u.timestamp=s,Array.isArray(t)&&!F(t)&&((t=C(t)).outerWrapper=!0),"function"==typeof a){u.async=!0;var g=function(t){Lt(t),a(t,null)},m=function(t){(p=y.next(t)).done?a(null,p.value):p.value.then(m).catch(g)};y=W(n,t,u),(p=y.next()).value.then(m).catch(g)}else try{for(y=W(n,t,u),p=y.next();!p.done;)p=y.next(p.value);return p.value}catch(c){throw Lt(c),c}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,n){var r=Rt(e,n);i.bind(t,r)},ast:function(){return n},errors:function(){return r}}}return $t.parser=p,$t}();e.exports=g},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var r=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},n=function(n){var r=0,i=n.length,o=function(t,e){return{type:t,value:e,position:r}},s=function(){for(var t,e,o=r,s=0;r<i;){var a=n.charAt(r);if("/"===a&&"\\"!==n.charAt(r-1)&&0===s){if(""===(t=n.substring(o,r)))throw{code:"S0301",stack:(new Error).stack,position:r};for(r++,a=n.charAt(r),o=r;"i"===a||"m"===a;)r++,a=n.charAt(r);return e=n.substring(o,r)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(r-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(r-1)||s--,r++}throw{code:"S0302",stack:(new Error).stack,position:r}},a=function(c){if(r>=i)return null;for(var u=n.charAt(r);r<i&&" \t\n\r\v".indexOf(u)>-1;)r++,u=n.charAt(r);if("/"===u&&"*"===n.charAt(r+1)){var h=r;for(r+=2,u=n.charAt(r);"*"!==u||"/"!==n.charAt(r+1);)if(u=n.charAt(++r),r>=i)throw{code:"S0106",stack:(new Error).stack,position:h};return r+=2,u=n.charAt(r),a(c)}if(!0!==c&&"/"===u)return r++,o("regex",s());if("."===u&&"."===n.charAt(r+1))return r+=2,o("operator","..");if(":"===u&&"="===n.charAt(r+1))return r+=2,o("operator",":=");if("!"===u&&"="===n.charAt(r+1))return r+=2,o("operator","!=");if(">"===u&&"="===n.charAt(r+1))return r+=2,o("operator",">=");if("<"===u&&"="===n.charAt(r+1))return r+=2,o("operator","<=");if("*"===u&&"*"===n.charAt(r+1))return r+=2,o("operator","**");if("~"===u&&">"===n.charAt(r+1))return r+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return r++,o("operator",u);if('"'===u||"'"===u){var l=u;r++;for(var f="";r<i;){if("\\"===(u=n.charAt(r)))if(r++,u=n.charAt(r),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:r,token:u};var d=n.substr(r+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:r};var p=parseInt(d,16);f+=String.fromCharCode(p),r+=4}else{if(u===l)return r++,o("string",f);f+=u}r++}throw{code:"S0101",stack:(new Error).stack,position:r}}var y,g=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(r));if(null!==g){var m=parseFloat(g[0]);if(!isNaN(m)&&isFinite(m))return r+=g[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:r,token:g[0]}}if("`"===u){r++;var b=n.indexOf("`",r);if(-1!==b)return y=n.substring(r,b),r=b+1,o("name",y);throw r=i,{code:"S0105",stack:(new Error).stack,position:r}}for(var v,x=r;;)if(v=n.charAt(x),x===i||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===n.charAt(r))return y=n.substring(r+1,x),r=x,o("variable",y);switch(y=n.substring(r,x),r=x,y){case"or":case"in":case"and":return o("operator",y);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return r===i&&""===y?null:o("name",y)}}else x++};return a},i=function(e,i){var o,s,a=Object.create(null),c=[],u=function(){var t=[];"(end)"!==o.id&&t.push({type:o.type,value:o.value,position:o.position});for(var e=s();null!==e;)t.push(e),e=s();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},l=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(h)).id=n.value=t,n.lbp=e,a[t]=n),n},f=function(t){if(i){t.remaining=u(),c.push(t);var e=a["(error)"];return(o=Object.create(e)).error=t,o.type="(error)",o}throw t.stack=(new Error).stack,t},d=function(t,n){if(t&&o.id!==t){var r={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(r)}var i=s(n);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,h=i.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(o=Object.create(c)).value=u,o.type=h,o.position=i.position,o},p=function(t){var e,n=o;for(d(null,!0),e=n.nud();t<o.lbp;)n=o,d(),e=n.led(e);return e},y=function(t){l(t,0).nud=function(){return this}},g=function(e,n,r){var i=n||t[e],o=l(e,i);return o.led=r||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,n){var r=l(t,e);return r.led=n,r},b=function(t,e){var n=l(t);return n.nud=e||function(){return this.expression=p(70),this.type="unary",this},n};y("(end)"),y("(name)"),y("(literal)"),y("(regex)"),l(":"),l(";"),l(","),l(")"),l("]"),l("}"),l(".."),g("."),g("+"),g("-"),g("*"),g("/"),g("%"),g("="),g("<"),g(">"),g("!="),g("<="),g(">="),g("&"),g("and"),g("or"),g("in"),y("and"),y("or"),y("in"),b("-"),g("~>"),m("(error)",10,function(t){return this.lhs=t,this.error=o.error,this.remaining=u(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),g("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==o.id)for(;"operator"===o.type&&"?"===o.id?(this.type="partial",this.arguments.push(o),d("?")):this.arguments.push(p(0)),","===o.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===o.id){for(var e=o.position,n=1,i="<";n>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?n--:"<"===s.id&&n++,i+=s.value}d(">");try{this.signature=r(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this}),b("(",function(){for(var t=[];")"!==o.id&&(t.push(p(0)),";"===o.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==o.id)for(;;){var e=p(0);if(".."===o.id){var n={type:"binary",value:"..",position:o.position,lhs:e};d(".."),n.rhs=p(0),e=n}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),g("[",t["["],function(e){if("]"===o.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),g("^",t["^"],function(t){d("(");for(var e=[];;){var n={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(n.descending=!0,d(">")),n.expression=p(0),e.push(n),","!==o.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var v=function(t){var e=[];if("}"!==o.id)for(;;){var n=p(0);d(":");var r=p(0);if(e.push([n,r]),","!==o.id)break;d(",")}return d("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};b("{",v),g("{",t["{"],v),m(":=",t[":="],function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)}),g("@",t["@"],function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),g("#",t["#"],function(e){return this.lhs=e,this.rhs=p(t["#"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),g("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=p(0),":"===o.id&&(d(":"),this.else=p(0)),this}),b("|",function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===o.id&&(d(","),this.delete=p(0)),d("|"),this});var x=function(t){var e;if("function"!==t.type||t.predicate)if("condition"===t.type)t.then=x(t.then),void 0!==t.else&&(t.else=x(t.else)),e=t;else if("block"===t.type){var n=t.expressions.length;n>0&&(t.expressions[n-1]=x(t.expressions[n-1])),e=t}else e=t;else{var r={type:"lambda",thunk:!0,arguments:[],position:t.position};r.body=t,e=r}return e},_=0,w=0,k=[],M=function(t,e){switch(t.type){case"name":case"wildcard":e.level--,0===e.level&&(void 0===t.ancestor||(k[e.index].slot.label=t.ancestor.label),t.ancestor=e,t.tuple=!0);break;case"parent":e.level++;break;case"block":t.expressions.length>0&&(t.tuple=!0,e=M(t.expressions[t.expressions.length-1],e));break;case"path":t.tuple=!0;var n=t.steps.length-1;for(e=M(t.steps[n--],e);e.level>0&&n>=0;)e=M(t.steps[n--],e);break;default:throw{code:"S0217",token:t.type,position:t.position}}return e},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},z=function(t){var e=t.steps.length-1,n=t.steps[e],r=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&r.push(n.slot);for(var i=0;i<r.length;i++){var o=r[i];for(e=t.steps.length-2;o.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[o]:t.seekingParent.push(o);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];o=M(s,o)}}},E=function(t){var e;switch(t.type){case"binary":switch(t.value){case".":var n=E(t.lhs);e="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(e.seekingParent=[n.slot]);var r=E(t.rhs);"function"===r.type&&"path"===r.procedure.type&&1===r.procedure.steps.length&&"name"===r.procedure.steps[0].type&&"function"===e.steps[e.steps.length-1].type&&(e.steps[e.steps.length-1].nextFunction=r.procedure.steps[0].value),"path"===r.type?Array.prototype.push.apply(e.steps,r.steps):(void 0!==r.predicate&&(r.stages=r.predicate,delete r.predicate),e.steps.push(r)),e.steps.filter(function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type}).forEach(function(t){t.type="name"}),e.steps.filter(function(t){return!0===t.keepArray}).length>0&&(e.keepSingletonArray=!0);var o=e.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var s=e.steps[e.steps.length-1];"unary"===s.type&&"["===s.value&&(s.consarray=!0),z(e);break;case"[":var a=e=E(t.lhs),u="predicate";if("path"===e.type&&(a=e.steps[e.steps.length-1],u="stages"),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:t.position};void 0===a[u]&&(a[u]=[]);var h=E(t.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach(function(t){1===t.level?M(a,t):t.level--}),S(a,h)),a[u].push({type:"filter",expr:h,position:t.position});break;case"{":if(void 0!==(e=E(t.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:t.position};e.group={lhs:t.rhs.map(function(t){return[E(t[0]),E(t[1])]}),position:t.position};break;case"^":"path"!==(e=E(t.lhs)).type&&(e={type:"path",steps:[e]});var l={type:"sort",position:t.position};l.terms=t.rhs.map(function(t){var e=E(t.expression);return S(l,e),{descending:t.descending,expression:e}}),e.steps.push(l),z(e);break;case":=":(e={type:"bind",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.rhs);break;case"@":if(e=E(t.lhs),a=e,"path"===e.type&&(a=e.steps[e.steps.length-1]),void 0!==a.stages||void 0!==a.predicate)throw{code:"S0215",stack:(new Error).stack,position:t.position};if("sort"===a.type)throw{code:"S0216",stack:(new Error).stack,position:t.position};t.keepArray&&(a.keepArray=!0),a.focus=t.rhs.value,a.tuple=!0;break;case"#":e=E(t.lhs),a=e,"path"===e.type?a=e.steps[e.steps.length-1]:(e={type:"path",steps:[e]},void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate)),void 0===a.stages?a.index=t.rhs.value:a.stages.push({type:"index",value:t.rhs.value,position:t.position}),a.tuple=!0;break;case"~>":(e={type:"apply",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs);break;default:(e={type:t.type,value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.lhs),S(e,e.rhs)}break;case"unary":e={type:t.type,value:t.value,position:t.position},"["===t.value?e.expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),n}):"{"===t.value?e.lhs=t.lhs.map(function(t){var n=E(t[0]);S(e,n);var r=E(t[1]);return S(e,r),[n,r]}):(e.expression=E(t.expression),"-"===t.value&&"number"===e.expression.type?(e=e.expression).value=-e.value:S(e,e.expression));break;case"function":case"partial":(e={type:t.type,name:t.name,value:t.value,position:t.position}).arguments=t.arguments.map(function(t){var n=E(t);return S(e,n),n}),e.procedure=E(t.procedure);break;case"lambda":e={type:t.type,arguments:t.arguments,signature:t.signature,position:t.position};var f=E(t.body);e.body=x(f);break;case"condition":(e={type:t.type,position:t.position}).condition=E(t.condition),S(e,e.condition),e.then=E(t.then),S(e,e.then),void 0!==t.else&&(e.else=E(t.else),S(e,e.else));break;case"transform":(e={type:t.type,position:t.position}).pattern=E(t.pattern),e.update=E(t.update),void 0!==t.delete&&(e.delete=E(t.delete));break;case"block":(e={type:t.type,position:t.position}).expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(e.consarray=!0),n});break;case"name":e={type:"path",steps:[t]},t.keepArray&&(e.keepSingletonArray=!0);break;case"parent":e={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(e);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":e=t;break;case"operator":if("and"===t.value||"or"===t.value||"in"===t.value)t.type="name",e=E(t);else{if("?"!==t.value)throw{code:"S0201",stack:(new Error).stack,position:t.position,token:t.value};e=t}break;case"error":e=t,t.lhs&&(e=E(t.lhs));break;default:var d="S0206";"(end)"===t.id&&(d="S0207");var p={code:d,position:t.position,token:t.value};if(i)return c.push(p),{type:"error",error:p};throw p.stack=(new Error).stack,p}return t.keepArray&&(e.keepArray=!0),e};s=n(e),d();var A=p(0);if("(end)"!==o.id){var T={code:"S0201",position:o.position,token:o.value};f(T)}if("parent"===(A=E(A)).type||void 0!==A.seekingParent)throw{code:"S0217",token:A.type,position:A.position};return c.length>0&&(A.errors=c),A};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,n){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=t("./utils"),o=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,o=[],s=Object.create(null),a=s;n<e.length;){var c=e.charAt(n);if(":"===c)break;var u=function(){o.push(s),a=s,s=Object.create(null)},h=function(t,e,n,r){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===r){if(0===--i)break}else c===n&&i++;return o};switch(c){case"s":case"n":case"b":case"l":case"o":s.regex="["+c+"m]",s.type=c,u();break;case"a":s.regex="[asnblfom]",s.type=c,s.array=!0,u();break;case"f":s.regex="f",s.type=c,u();break;case"j":s.regex="[asnblom]",s.type=c,u();break;case"x":s.regex="[asnblfom]",s.type=c,u();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var l=h(e,n,"(",")"),f=e.substring(n+1,l);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:n};s.regex="["+f+"m]",s.type="("+f+")",n=l,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var d=h(e,n,"<",">");a.subtype=e.substring(n+1,d),n=d}n++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",y=new RegExp(p),g=function(t){var e;if(i.isFunction(t))e="f";else switch(r(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},m=function(t,e){for(var n="^",r=0,i=0;i<o.length;i++){n+=o[i].regex;var s=e.match(n);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1};r=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1}};return{definition:e,validate:function(e,n){var r="";e.forEach(function(t){r+=g(t)});var i=y.exec(r);if(i){var s=[],a=0;return o.forEach(function(r,o){var c=e[a],u=i[o+1];if(""===u)if(r.context&&r.contextRegex){var h=g(n);if(!r.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};s.push(n)}else s.push(c),a++;else u.split("").forEach(function(n){if("a"===r.type){if("m"===n)c=void 0;else{c=e[a];var i=!0;if(void 0!==r.subtype)if("a"!==n&&u!==r.subtype)i=!1;else if("a"===n&&c.length>0){var o=g(c[0]);i=o===r.subtype.charAt(0)&&0===c.filter(function(t){return g(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[r.subtype]};"a"!==n&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,r)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,n){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}var a=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter(function(t){return"string"!=typeof t}).length),e}function n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function o(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function u(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function l(t){return"object"===s(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!f(t[n],e[n]))return!1;return!0}var r=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(r.length!==i.length)return!1;for(r=r.sort(),i=i.sort(),n=0;n<r.length;n++)if(r[n]!==i[n])return!1;for(n=0;n<r.length;n++){var o=r[n];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,n=[],i=r(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;n.push(o)}}catch(t){i.e(t)}finally{i.f()}return n}function p(t){return"object"===s(t)&&null!==t?Object.keys(t):[]}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:l,getFunctionArity:c,isDeepEqual:f,stringToArray:d,keys:p}}();e.exports=a},{}]},{},[3])(3)}(eo)),eo.exports),ro=Ji(no);const io=function(t){return t};function oo(t){if(!t)return io;try{const e=ro(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Zi(t),io}}function so(t){const e=wi(t);return null==e?"":String(e)}function ao(t){return Number(wi(t))}function co(t){return t}function uo(t){return so(t)}function ho(t){return ao(t)}function lo(t){if(this.param)return t=so(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function fo(t){const{param:e}=this;if(e){for(const n in e){let[r,i]=n.split("~");const o=!!r,s=!!i,a=parseFloat(r),c=parseFloat(i);if(t=ao(t),o&&!s&&t>=a)return e[n];if(!o&&s&&t<a)return e[n];if(t>=a&&t<c)return e[n]}return e.default}}function po(t){return ao(t)*Math.PI/180}function yo(){}const go=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const mo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],bo=new Array(mo.length).fill(void 0),vo=Object.getPrototypeOf(async function(){}).constructor;function xo(t,e){!function(t){for(const e of go)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const n=function(t){return/\bawait\b/.test(t)}(t),r=new(n?vo:Function)(...e,...mo,t);return function(t,...e){return r.call(t,...e,...bo)}}function _o(t,e,n,r,i){switch(n){case"value":return"text"===i||"string"===i?uo.bind(t):"number"===i?ho.bind(t):co.bind(e);case"map":return lo.bind(t);case"range":return fo.bind(t);case"radian":return po.bind(t);case"eval":return function(t){try{const e=xo(t,["value","targets","scene"]);return function(t,n){try{const r=e(this,t,n,globalThis.scene);return r&&"function"==typeof r.then?r.catch(t=>{Zi(t)}):r}catch(t){return void Zi(t)}}}catch(t){return Zi(t),yo}}(r).bind(e);default:return co.bind(e)}}class wo{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:r,param:i,accessor:o}=t;this._model=t,this.evaluator=_o(this,this.owner,r,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=oo(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=oo(t),this.partAccessor=oo(e)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function ko(t,e,n,r){const i=e.split(".");if(1===i.length)return void(t[e]=r?{...t[e],...n}:n);const o=i[0],s=void 0!==t[o]?t[o]:"function"==typeof t.get?t.get(o):void 0,a=s?{...s}:{};let c=a;for(let t=1;t<i.length-1;t++)c[i[t]]=c[i[t]]?{...c[i[t]]}:{},c=c[i[t]];const u=i[i.length-1];c[u]=r?{...c[u],...n}:n,t[o]=a}function Mo(t,e,n,r){t.forEach(t=>ko(t,e,n,r))}function So(t,e,n,r){t&&"function"==typeof t.then?t.then(t=>{void 0!==n&&void 0!==r&&n._dataGeneration!==r||e(t)}).catch(t=>Zi(t)):e(t)}function zo(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,n=this;this.mappings&&this.mappings.forEach(t=>{try{let r,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:h=!1,partial:l=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),r=this.root.findById(i)?.data||{}):r=this.data;const f=a(r);if("(root)"==o||"(key)"==o){if(null==f)return;const r=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();r.length>0&&r.forEach(r=>{So(t.evaluator(f[r.get("id")],[r]),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||ko(r,s,t,l)},n,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(r=>{const i=c(r);if(i){const o=this.root.findOrCreate(i);o&&So(t.evaluator(u(r),o),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(o,s,t,l)},n,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const r=c(f);if(r){const i=this.root.findOrCreate(r);i&&So(t.evaluator(u(f),i),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(i,s,t,l)},n,e)}}}}else{const r=this.root.findAll(o,this);r.length>0&&So(t.evaluator(f,r),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(r,s,t,l)},n,e)}}catch(e){Zi(e,this,t)}})}function Eo(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),zo.call(this,!0)}function Ao(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new wo({target:"(self)",rule:"value",...t},this))):(Zi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function To(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function Oo(t,e){this.disposeMappings(),zo.call(this)}function Io(t,e,n,r,i,o){e.complete?t.drawImage(e,n,r,i,o):e.addEventListener("load",()=>{this.invalidate()})}function jo(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Po="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),Ro={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Co=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";Ro.FONT_FAMILY=e||n};let Fo;function No(t,e,n,r,i){const{alpha:o=1}=r,s=i.fillStyle;if(t.globalAlpha*=o,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(n.x,n.y);let r,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,n="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,r=t.createLinearGradient(s*Math.cos(n+e),s*Math.sin(n+e),s*Math.cos(n),s*Math.sin(n))}else r=t.createLinearGradient((i-4)/2*Math.cos(n+e),(o-4)/2*Math.sin(n+e),(i-4)/2*Math.cos(n),(o-4)/2*Math.sin(n))}else if("radial"==s.gradientType){const e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));switch(s.center){case"center":default:r=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":r=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":r=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":r=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":r=t.createRadialGradient(i/2,o/2,0,i/2,o/2,2*e)}}(Array.isArray(s.colorStops)?s.colorStops:Array.isArray(s.gradientStops)?s.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{r.addColorStop(t.position,t.color)}catch(e){((...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))})("Invalid Color for colorstop : ",t.color),r.addColorStop(t.position,"#fff")}}),t.fillStyle=r,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==s.type&&s.image)if(s.guideOnly&&1!=i.app.mode)s.color&&(t.fillStyle=s.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);const n=i._pattern_image;if(!n||!n.width||!n.height)return;let r=0,o=0,a=0,c=0,u=e.left,h=e.top;if(!s.fitPattern){r=s.offsetX,o=s.offsetY;const t=s.width?s.width:n.width,i=s.height?s.height:n.height;switch(s.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=r+a,h+=o+c}t.translate(u,h),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-h)}}function Do(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const r=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return r._pattern_image=r._pattern_image_origin,void t(this);let e=n.width||this.width,i=n.height||this.height;n.fitPattern&&(e=r.bounds.width,i=r.bounds.height);const o=Fo(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),r._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(n.image)}catch(t){e(t)}}function Lo(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Zi(t)})}function $o(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function Uo(t,e,n){let{strokeStyle:r,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(r&&0!=o){if(s&&(t.lineCap=s),i){const e="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=e?[0,2*o]:[o,o];break;case"square-dot":i=e?[o,2*o]:[2*o,o];break;case"dash":i=e?[3*o,2.5*o]:[4*o,1.5*o];break;case"dash-dot":i=e?[3*o,3*o,0,3*o]:[4*o,2*o,o,2*o];break;case"long-dash":i=e?[5*o,4*o]:[6*o,3*o];break;case"long-dash-dot":i=e?[5*o,3*o,0,3*o]:[6*o,2*o,o,2*o];break;case"long-dash-dot-dot":i=e?[5*o,2*o,0,2*o,0,2*o]:[6*o,o,o,o,o,o]}Array.isArray(i)||(i=[]),t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=r,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function qo(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let r;for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function Wo(t,e,n,r=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const o=e.text.substring(0,i);if(!(t.measureText(o).width+(i-1)*r<n))break}return{...e,text:e.text.substring(0,i-1)}}function Yo(t,e,n,r,i,o=0){const s=String(e).split("\n");return r?[].concat(...s.map(e=>function(t,e,n,r=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-s,u=t.measureText(a).width+(a.length-1)*r;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const n=Wo(t,{...e,text:a},c,r);o.push(n),i.push(o),o=[],s=0,a=a.substring(n.text.length)}}}),o.length>0&&i.push(o),i}(t,i?qo(e):[{text:e,bold:!1,italic:!1}],n,o))):s.map(t=>i?qo(t):[{text:t,bold:!1,italic:!1}])}function Bo(t,e,n,r,i,o,s=0){if(!r)return[];t.save(),t.font=n;const a=Yo(t,r,e,!!i,o,s);return t.restore(),a}function Go(t){const{fontFamily:e=Ro.FONT_FAMILY,bold:n=Ro.BOLD,italic:r=Ro.ITALIC,fontSize:i=Ro.FONT_SIZE}=t,o=[];return n&&o.push("bold"),r&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Xo(t,e){const n=t.bold||e.bold,r=t.italic||e.italic;return Go({...t,bold:n,italic:r})}function Ho(t,e,n,r){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=Ro.FONT_COLOR,textAlign:c=Ro.TEXT_ALIGN,textBaseline:u=Ro.TEXT_BASELINE,textBackgroundStyle:h,fontSize:l,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:y=0}=r;i=void 0!==i?i:1,l||=Ro.FONT_SIZE,f||=1.2*l,t.save();const{left:g,top:m,width:b,height:v}=e;if(o&&s&&(t.translate(g+b/2,m+v/2),t.rotate(-o),t.translate(-(g+b/2),-(m+v/2))),t.beginPath(),t.font=Go(r),!d&&p){const e=function(t,e,n,r){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of n){const n=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=r-("ellipsis"===t?o:0))){const i=Vo(e,c,r-a-("ellipsis"===t?o:0),t);return n.push(i),s.push(n),s}n.push(c),a+=i}s.push(n),a=0}return s}(p,t,n,b);n=e}const x=n.length*f;let _;switch(u){case"top":_=m,t.textBaseline="top";break;case"bottom":_=m+v-x+f,t.textBaseline="bottom";break;default:_=m+v/2-x/2+f/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,n.forEach((e,i)=>{const o=_+i*f,s=function(t,e,n,r=0){return e.reduce((e,i)=>(t.font=Xo(n,i),e+t.measureText(i.text).width+r*(i.text.length-1)),0)}(t,e,r,y);let u=g;switch(c){case"left":case"justify":u=g;break;case"right":u=g+b-s;break;case"center":u=g+(b-s)/2}if(h&&(t.fillStyle=h,function(t,e,n,r,i,o=0,s=!1,a=!0){o="number"==typeof o?{tl:o,tr:o,br:o,bl:o}:{tl:0,tr:0,br:0,bl:0,...o},t.beginPath(),t.moveTo(e+o.tl,n),t.lineTo(e+r-o.tr,n),t.quadraticCurveTo(e+r,n,e+r,n+o.tr),t.lineTo(e+r,n+i-o.br),t.quadraticCurveTo(e+r,n+i,e+r-o.br,n+i),t.lineTo(e+o.bl,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o.bl),t.lineTo(e,n+o.tl),t.quadraticCurveTo(e,n,e+o.tl,n),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-l/2-4,s+8,l+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<n.length-1&&e.length>1){const n=b-s,i=e.length-1,a=n/i;e.forEach((e,n)=>{t.font=Xo(r,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(n<i?a:0)})}else e.forEach(e=>{t.font=Xo(r,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+y})})}),t.restore()}function Vo(t,e,n,r){let i="";for(let r=0;r<e.text.length;r++){const o=i+e.text[r];if(t.measureText(o).width>n)break;i=o}return{...e,text:i+("ellipsis"===r?"…":"")}}function Zo(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Co()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Co),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Co()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Co(),Fo="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Qo=[];function Jo(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-n.x)/i.x,e=(e-n.y)/i.y):(t-=n.x,e-=n.y),0!==r){const n=Math.cos(-r),i=Math.sin(-r),o=t*i+e*n;t=t*n-e*i,e=o}return{x:t+n.x,y:e+n.y}}function Ko(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(t-=n.x,e-=n.y,0!==r){const n=Math.cos(r),i=Math.sin(r),o=t*i+e*n;t=t*n-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+n.x,y:e*i.y+n.y}:{x:t+n.x,y:e+n.y}}function ts(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=Jo(t,e,n,r,i);return n&&(o.x-=n.x,o.y-=n.y),o}return Jo(t,e,n=n||this.rotatePoint,r,i)}function es(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=Ko(t,e,void 0,r+(this._delta?.theta??0),i);return n&&(o.x+=n.x,o.y+=n.y),o}n=n||this.rotatePoint;const{theta:o=0,tx:s=0,ty:a=0,sx:c=1,sy:u=1}=this._delta||{};if(0===o&&0===s&&0===a&&1===c&&1===u)return Ko(t,e,n,r,i);return Ko(t+s,e+a,{x:n.x+s,y:n.y+a},r+o,{x:i.x*c,y:i.y*u})}function ns(t,e,n){n=n||this.rootModel;const r=this.transcoordS2T(t,e,n);return Ko(r.x,r.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function rs(t,e,n){n=n||this.rootModel,Qo.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Qo.push(t);let r=this.transcoordS2P(t,e);for(let t=0;t<Qo.length;t++){const e=Qo[t],n=e.bounds;r.x+=n.left,r.y+=n.top,r=e.transcoordS2P(r.x,r.y)}return r}function is(t,e,n){n=n||this.rootModel,Qo.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Qo.push(t);let r={x:t,y:e};for(let t=Qo.length-1;t>=0;t--){const e=Qo[t];r=e.transcoordP2S(r.x,r.y);const n=e.bounds;r.x-=n.left,r.y-=n.top}return r}function os(t,e,n){const r=this.transcoordT2P(t,e,n);return this.transcoordP2S(r.x,r.y)}function ss(t,e,n){const r=this.rootModel,i=this.transcoordS2T(t,e,r);return n.transcoordT2S(i.x,i.y,r)}function as(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:r={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=n.model,s=Jo(t,e,r,o,i);return r&&(s.x-=r.x,s.y-=r.y),n===this?s:this.transcoordT2S(s.x,s.y,n)}function cs(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let r;if(r=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return r;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=n.model;return r=Ko(r.x,r.y,void 0,o+n._delta.theta,s),i&&(r.x+=i.x,r.y+=i.y),r}function us(t){const e=t.element,n=t.fillStyle,r=e.style;if(n)if("string"==typeof n)r.backgroundColor=n;else switch(n.type){case"pattern":if(r.backgroundImage="url("+n.image+")",r.backgroundColor="transparent",n.fitPattern?r.backgroundSize="100% 100%":n.width||n.height?r.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:r.backgroundSize="contain",n.fitPattern)r.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=n;if(i&&(r.backgroundRepeat="no-repeat"),s&&(r.backgroundColor=s),o)switch(o){case"center":r.backgroundPosition="center center";break;case"left-top":r.backgroundPosition="left top";break;case"left-bottom":r.backgroundPosition="left bottom";break;case"right-top":r.backgroundPosition="right top";break;case"right-bottom":r.backgroundPosition="right bottom";break;case"left":r.backgroundPosition="left center";break;case"right":r.backgroundPosition="right center";break;case"top":r.backgroundPosition="center top";break;case"bottom":r.backgroundPosition="center bottom"}else t||e?r.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete r.backgroundPosition}break;case"gradient":r.background=function(t,e){const n=e.colorStops,r=e.gradientType;if(n instanceof Array&&n.length>0)switch(r){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:r}=t.bounds;switch(e){case"center":return[n/2,r/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,r];default:return[n,r]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else r.background="transparent"}const hs={x:1,y:1},ls={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function fs(t,e){let n=this.bounds,r=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const r=t.call(e,n);r&&(n=r)}const{left:s,top:a,width:c,height:u}=n;let h=[{x:s,y:a},{x:s+c,y:a+u}];h=h.map(t=>Ko(t.x,t.y,r,i,o));let l=h[0],f=h[1];r={x:(l.x+f.x)/2,y:(l.y+f.y)/2},h=h.map(t=>Jo(t.x,t.y,r,i,o)),l=h[0],f=h[1],this.bounds={left:l.x,top:l.y,width:f.x-l.x,height:f.y-l.y}}function ds(t,e,n){let r=this.path,i=this.rotatePoint;t&&(r=t.call(n,r));let o=r.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(n,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,h;r=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=r[0].x,u=h=r[0].y;for(let t=1;t<r.length;t++){const e=r[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>h&&(h=e.y)}i={x:(a+c)/2,y:(u+h)/2},i=this.toParent(i.x,i.y,s),this.path=o.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const ps=new Map;let ys=null;function gs(){ys&&(ys(),ys=null)}function ms(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var bs=new class{add(t){var e;ms(t)&&!ps.has(t)&&(ps.set(t,0),e=t?.root,ys||(ys=H.subscribe(t=>{if(0===t)return;const e=[];for(const[n,r]of ps){if(!ms(n)){e.push(n);continue}const i=r+t;i>=n.retention?e.push(n):ps.set(n,i)}for(const t of e){ps.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Zi("RetentionManager removeSelf failed:",t)}}0===ps.size&&gs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ps.keys()),metadata:{get count(){return ps.size},get preview(){return Array.from(ps.entries()).slice(0,3).map(([t,e])=>({type:t?.state?.type,id:t?.state?.id??"-",retentionMs:t?.retention,remainingMs:Math.max(0,Math.round(t?.retention-e))}))}}})))}remove(t){ps.delete(t)&&0===ps.size&&gs()}touch(t){t&&ps.has(t)&&ps.set(t,0)}dispose(){gs(),ps.clear()}get length(){return ps.size}};const vs=function(t){return t};function xs(t){const e=t.indexOf("||");let n="",r="";-1!=e&&(n=t,r=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),o=i.slice(1);return{defaultValue:r,match:t,originText:n||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:vs}}function _s(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>xs(t))[0];if(n)return n.accessor(this.getState(n.target));const r=(e.match(/\${[^}]*}/)||[]).map(t=>xs(t))[0];if(r){const t=this.root.findById(r.target);return r.accessor(this.getState(t))}return t}function ws(t,e){if(!t)return;const n=String(t),r=e||wi,i=(n.match(/#{(\S*)}/gi)||[]).map(t=>xs(t)),o=(n.match(/\${[^}]*}/gi)||[]).map(t=>xs(t));if(0==i.length&&0==o.length)return n;let s=n;return i.forEach(t=>{const e=r(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)}),o.forEach(t=>{const e=this.root.findById(t.target),n=r(t.accessor(e&&e.data));s=s.replace(t.match,void 0===n?"":n)}),s}function ks(t,e,n){if(!t)return;const r=n||wi,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>xs(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>xs(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(n=>{const i=r(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===i?n.defaultValue||"":i)}),s.forEach(n=>{const i=e.root.findById(n.target),o=r(n.accessor(i&&i.data));t=t.replace(n.originText,void 0===o?n.defaultValue||"":o)}),t}:void 0}class Ms{constructor(){}static registerDecorator(t,e){Ms.constructors.set(t,e)}static create(t,e,n={},r){const i=Ms.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(r,e,n)}}function Ss(t,e){const n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r);if(!mt(t))return i;const o=bt(t,e,t.bulge);if(!o)return i;const s=Math.min(o.radius,i/2),a=2*Math.asin(s/o.radius);return o.radius*a}function zs(t,e){const n=t.path.slice();if(!n||!n.length)return void Zi("path should not be empty");let r=1;const i=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[r];)i.push(Ss(n[r-1],n[r])),r++;const o=i.reduce(function(t,e){return t+e},0);r=0;let s=0;do{s+=i[r++]}while(s/o<e);s-=i[--r];e=(e-s/o)*(o/i[r]);const a=n[r%n.length],c=n[(r+1)%n.length],{x:u,y:h}=function(t,e,n){if(mt(t)){const r=bt(t,e,t.bulge);if(r){let t=r.endAngle-r.startAngle;r.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=r.startAngle+n*t;return{x:r.cx+r.radius*Math.cos(e),y:r.cy+r.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*n),y:t.y+Math.round((e.y-t.y)*n)}}(a,c,e);return t.toScene(u,h)}function Es(t,e){return!1}function As({x:t,y:e},...n){const r=this.path,i=t,o=e;this.path=r.map(t=>({...t,x:t.x+i,y:t.y+o}))}function Ts(t){const e=t??this.center.x,{rotation:n}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-n),r&&"gradient"===r.type&&"linear"===r.gradientType){const t=ci(r);t.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({...t,x:2*e-t.x,y:t.y}))}function Os(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}function Is(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let r=t.width-e.width,i=t.height-e.height;r*n>i?i=r*n:r=i/n;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-r):0!=o?o=-r:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+r,height:e.height+i}}return t}function js(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function Ps(t){return zs(this,t||0)}function Rs(){const t=this.path;let e,n,r,i;e=n=t[0].x,r=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>n&&(n=s.x),s.y<r?r=s.y:s.y>i&&(i=s.y)}return{left:e,top:r,width:n-e,height:i-r}}function Cs(t){const e=this.bounds;if(Math.round(100*t.width)/100==Math.round(100*e.width)/100&&Math.round(100*t.height)/100==Math.round(100*e.height)/100&&Math.round(100*t.left)/100==Math.round(100*e.left)/100&&Math.round(100*t.top)/100==Math.round(100*e.top)/100)return;const n=0==e.width?1:t.width/e.width,r=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*n,y:t.top+(i.y-e.top)*r}))}function Fs(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ns(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const n=t.x-e.x,r=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+n,y:t.y+r}))}function Ds(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Ls(t){const{x:e,y:n,z:r}=t||{};this.center={x:e,y:n},isNaN(r)||this.setState("zPos",Number(r))}function $s(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function Us(t){const{x:e,y:n,z:r}=t;this.setState({rotationX:e,rotationY:n,rotation:-r})}function qs(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function Ws(t){const{width:e,height:n,depth:r}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:n},this.setState("depth",r)}function Ys(){return Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Bs(t){Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Gs(){return this.path}function Xs(){return this.center}function Hs(){return this.nature.mutable}function Vs(){return this.nature.resizable&&!this.stuck}function Zs(){return this.nature.rotatable&&!this.stuck}Ms.constructors=new Map;const Qs={x:1,y:1};function Js(t,e,n){const{offsetX:r,offsetY:i,blur:o,color:s}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??Qs;t.shadowOffsetX=r*a.x*Po,t.shadowOffsetY=i*a.y*Po,t.shadowBlur=o*a.x*Po,t.shadowColor=s}function Ks(t){t.save(),this.prerender(t);const e=this.app,n=!0===t.__inHiddenSubtree;e?.isEditMode&&((function(t){const e=t?.app;if(!e?.isEditMode)return!1;const n=e.focusFilter;return!!(t.hidden||n&&!n(t))}(this)||n)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=n,t.restore()}function ta(t){const e=this.rotatePoint,{scale:n,rotation:r,shadow:i,alpha:o}=this.state,s=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(r||0)+this._delta.theta,{tx:u=0,ty:h=0}=this._delta,l=(o||1)-this._delta.fade;(u||h)&&t.translate(u,h),(1!=s||1!=a||c)&&(t.translate(e.x,e.y),1==s&&1==a||t.scale(s,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),l&&(t.globalAlpha=l),i&&Js(t,i,this)}function ea(t){}function na(t){this.drawText(t)}function ra(t,e){t(this)}function ia(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Zi(t)})}function oa(t){!this.textHidden&&this.text&&this.hasTextProperty&&Ho(t,this.textBounds,this.textLines(t),this.state)}function sa(t,e){Uo(t,e?{...this.state,...e}:this.state)}function aa(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(No(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function ca(){return this.get("strokeStyle")}function ua(t){this.set("strokeStyle",t)}function ha(){return this.getState("fillStyle")}function la(t){this.setState("fillStyle",t)}function fa(){return this.get("fontColor")}function da(t){this.set("fontColor",String(wi(t)))}function pa(){return this.getState("rotation")}function ya(t){this.setState("rotation",Number(wi(t)))}function ga(){return this.app.isEditMode?["decotag","data-spread"]:[]}function ma(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function ba(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function va(t){this.setState("hidden",t)}function xa(){return this.state.tag}function _a(t){this.setState("tag",t)}function wa(){}function ka(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function Ma(){const t=this.getState("text");return null==t?"":String(t)}function Sa(t){const{textWrap:e,supportMarkdown:n}=this.state;return Bo(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function za(){return Go(this.model)}function Ea(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Aa(){return this._text_substitutor||(this._text_substitutor=ks(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Ta(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,r,i,o,s,a,c,u,h,l,f,d=t.length,p=t.search(/[0-9\-\+#]/),y=p>0?t.substring(0,p):"",g=t.split("").reverse().join(""),m=g.search(/[0-9\-\+#]/),b=d-m,v=t.substring(b,b+1),x=b+("."===v||","===v?1:0),_=m>0?t.substring(x,d):"";if(n=(e="-"===(t=t.substring(p,x)).charAt(0)?-e:+e)<0?e=-e:0,r=t.match(/[^\d\-\+#]/g),i=".",o=r&&r[1]&&r[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),u=e.split("."),(!u[1]||u[1]&&u[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(o),t[0]=h.join(""),s=t[0]&&t[0].indexOf("0"),s>-1)for(;u[0].length<t[0].length-s;)u[0]="0"+u[0];else 0===+u[0]&&(u[0]="");if((e=e.split("."))[0]=u[0],c=h[1]&&h[h.length-1].length,c){for(l=e[0],g="",b=l.length%c,d=l.length,x=0;x<d;x++)g+=l.charAt(x),!((x-b+1)%c)&&x<d-c&&(g+=o);e[0]=g}return e[1]=t[1]&&e[1]?"."+e[1]:"",r=e.join(""),"0"!==r&&""!==r||(n=!1),f="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",y+(f+r)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function Oa(t){delete this._text_substitutor;const e=wi(t);this.setState("text",null==e?"":String(e))}function Ia(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:r}=this.state;r||=0,t||=0,e||=0,n||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-n,0),height:Math.max(a-t-r,0)}}function ja(){return 0}function Pa(){return!!this._textHidden}function Ra(t){this._textHidden=!!t,this.invalidate()}function Ca(){return!0}function Fa(t){return t}function Na(t){return Math.pow(t,2)}function Da(t){return 1-Math.sin(Math.acos(t))}function La(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function $a(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function Ua(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var qa={linear:Fa,quad:Na,circ:Da,back:La,bounce:$a,elastic:Ua},Wa=Object.freeze({__proto__:null,back:La,bounce:$a,circ:Da,default:qa,elastic:Ua,linear:Fa,quad:Na});class Ya{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:r,ease:i}=this.config;let o;o="string"==typeof n?qa[n]:n,this.delta="out"===i?function(t,e){return function(n){return 1-t(1-n,e)}}(o,r):"inout"===i?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(o,r):o,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:r=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>H.simTime,u=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==s&&(s=c(),this.client?.touch?.());const h=c()-s,l=Math.max((h-e)%(t+r),0)/t,f=r<=0&&a>l;if(a=l,l>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(i),void(s=0);if(r>0)return this._unsub?.(),this._unsub=null,void(this._timeout=setTimeout(()=>{this._timeout=null,this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(()=>{this._timeout=null,this._started&&(this._unsub=H.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}}))},r/2)},r/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.()};this._unsub=H.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}})}stop(t){this._unsub&&(this._unsub(),this._unsub=null),this._timeout&&clearTimeout(this._timeout),this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const Ba={rotation:class extends Ya{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Ya{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let r=t*n;t<1/4?r*=-1:t<3/4?r-=2*e:r=n-r,this.client.delta?.("theta",r)}},heartbeat:class extends Ya{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let r;r=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:r,sy:r,sz:r})}},moving:class extends Ya{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends Ya{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let r={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(r=i);const{tx:o,ty:s}=r,a=n.outline(t),{x:c,y:u}=this.client.center,h=this.client.toScene(c,u);this.client.delta({tx:a.x-h.x+o,ty:a.y-h.y+s})}},fade:class extends Ya{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,r=Math.max(Math.min(e,n,1),0),i=2*(Math.min(Math.max(e,n,1),1)-r);let o;o=t<.5?i*t:(1-t)*i,this.client.delta?.("fade",o)}},waypoint:class extends Ya{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,r=t.center,{x:i,y:o}=e.toScene(n.x,n.y),{x:s,y:a}=t.toScene(r.x,r.y);this._startX=i,this._startY=o,this._endX=s,this._endY=a;const c=this.config.yawOffset??Math.PI/2,u=Math.atan2(a-o,s-i)+c;this.client.location={x:i,y:o},this.client.setState("rotation",u),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};const Ga={gradation:function(t,e,n){const{subType:r,from:i,to:o,colors:s}=n;let a;switch(r){case"linear":default:a=e.createLinearGradient(i.x,i.y,o.x,o.y);break;case"radial":a=e.createRadialGradient(i.x,i.y,i.r,o.x,o.y,o.r)}s&&(s.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:Js};function Xa(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:n,component:r,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:h}=t;let l;l="string"==typeof h?Wa[h]:h||Fa,"out"===n?l=function(t,e){return function(n){return 1-t(1-n,e)}}(l,c):"inout"===n&&(l=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(l,c));let f=!1,d=null;return{start:function(){if(f)return this;if(r?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const n=()=>H.simTime;return d=H.subscribe(()=>{if(!f)return;if(r?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=n());const o=(n()-t)/e,a=u?o%1:Math.min(o,1);i(l(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:r,metadata:{duration:e,repeat:u}}),this},stop:function(){return f=!1,d&&(d(),d=null),a&&a(),this}}}({component:this,...t}),this._animate}function Ha(t,e){return function(t,e,n){const r=Ga[n.type];r&&r(t,e,n)}(this,t,e)}const Va=100;function Za(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Va)/Va}return e}}function Qa(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*Va)/Va):delete t[e]:"object"==typeof n&&Qa(n)}return t}function Ja(...t){return JSON.stringify(this.hierarchy,Za,...t)}function Ka(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function tc(t){this.rootModel.closeScene(t)}function ec(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function nc(){this.parent&&this.parent.invalidate()}function rc(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function ic(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function oc(){return this.getState("data")}function sc(t){this.setState("data",t),this.touch()}function ac(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function cc(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function uc(){return Number(this.get("retention"))||0}function hc(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const n=e.type?Ba[e.type]:void 0;return n?new n(t,e):null}(this,t.oncreate))}return this._animation}}function lc(){return!!this.animation?.started}function fc(t){this.animation&&(this.animation.started=t)}function dc(){}function pc(t,e,n,r){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function yc(t,e,n,r){return t==e.get("type")}function gc(t,e,n,r,i,o){return t(e,n,r,i)&&o.push(n),n.components&&n.components.forEach(n=>{gc(t,e,n,r,i,o)}),o}function mc(t,e,n,r){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function bc(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let r;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":r=pc;break;case"(":r=mc;break;default:r=yc}return gc(r,t,e,n,e,[])}function vc(t,...e){if(t(this,...e))return this}function xc(t,...e){return"string"==typeof t?bc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function _c(t,e,n){if(!this.capturable||n?.(this))return!1;const r=this.fromParent(t,e);return this.contains(r.x,r.y)?this:void 0}function wc(t){return this.anchors.find(e=>e.name===t)}function kc(t){return!0}function Mc(t){return this._parent.getContext(t??this)}function Sc(){return this.isRoot()?this:this.parent&&this.parent.root}function zc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Ec(){return this._parent}function Ac(t){this._parent=t}function Tc(){return this.nature.anchors||[]}function Oc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Ic(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function jc(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function Pc(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Rc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Cc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Fc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Nc={},Dc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Lc=[],$c=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Uc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let qc=0;const Wc={};const Yc=new FinalizationRegistry(t=>{!function(t){qc--;let e=Wc[t];e||(e=Wc[t]={up:0,down:0}),e.down++}(t)});class Bc{static get nature(){return Dc}static register(t,e){if(!e)return Nc[t];Nc[t]=e}static types(){return Object.keys(Nc)}static get residents(){return Wc}static get residentsCount(){return qc}static registerDecorator(t,e){Ms.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},n=[];for(const r of Object.keys(t)){const i=e[r];if(!i)continue;const o=t[r];if(o&&"object"==typeof o){if("script"===o.action){const t="string"==typeof o.value?o.value:o.value&&"object"==typeof o.value?o.value.script:"";t&&n.push({trigger:i,action:"script",code:t,target:o.target});continue}n.push({trigger:i,action:o.action,target:o.target,value:o.value,options:{emphasize:o.emphasize,restore:o.restore,pressed:o.pressed,...o.options??{}}})}}return n}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=ci(Uc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??!0))&&(this.animation.started=!0),this.clearCache(),bs.add(this),function(t){qc++;let e=Wc[t];e||(e=Wc[t]={up:0,down:0}),e.up++}(this._model.type),Yc.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),bs.touch(this)}clearCache(...t){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=ci(Uc))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&bs.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&bs.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get refid(){return this.get("refid")}get hierarchy(){const t=ci(this._model);return this.volatile.forEach(e=>{delete t[e]}),Qa(t)}get volatile(){return Lc}_applyProps(t,e,n){const r={},i={};let o=!1;const s=ci(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=n.getBeforeVal(e),u=s[e];!n.sensitive&&function(t,e){return Dn(t,e)}(c,u)||(i[e]=c,r[e]=u,t[e]=u,n.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(r).some(t=>!$c.has(t))&&this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(r,i),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,i),n.afterFillStyle&&n.afterFillStyle(r,i),r.hasOwnProperty("data")&&this.onchangeData(r,i),this.onchange&&this.onchange(r,i),this.trigger("change",r,i)}return this}contains(t,e){return Es.call(this,t,e)}move(t,...e){As.call(this,t,...e)}symmetryX(t){Ts.call(this,t)}symmetryY(t){Os.call(this,t)}adjustResize(t,e,n){return Is.call(this,t,e,n)}adjustRotation(t,e){return js.call(this,t,e)}outline(t){return Ps.call(this,t)}get bounds(){return Rs.call(this)}set bounds(t){Cs.call(this,t)}get center(){return Fs.call(this)}set center(t){Ns.call(this,t)}get location(){return Ds.call(this)}set location(t){Ls.call(this,t)}get rotate(){return $s.call(this)}set rotate(t){Us.call(this,t)}get dimension(){return qs.call(this)}set dimension(t){Ws.call(this,t)}get path(){return Ys.call(this)}set path(t){Bs.call(this,t)}get drawPath(){return Gs.call(this)}get rotatePoint(){return Xs.call(this)}get mutable(){return Hs.call(this)}get resizable(){return Vs.call(this)}get rotatable(){return Zs.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Ks.call(this,t)}prerender(t){ta.call(this,t)}render(t){ea.call(this,t)}postrender(t){na.call(this,t)}prepare(t,e){ra.call(this,t,e)}prepareIf(t){ia.call(this,t)}drawText(t){oa.call(this,t)}drawStroke(t,e){sa.call(this,t,e)}drawFill(t,e){aa.call(this,t,e)}get strokeStyle(){return ca.call(this)}set strokeStyle(t){ua.call(this,t)}get fillStyle(){return ha.call(this)}set fillStyle(t){la.call(this,t)}get fontColor(){return fa.call(this)}set fontColor(t){da.call(this,t)}get rotation(){return pa.call(this)}set rotation(t){ya.call(this,t)}get decorators(){return ga.call(this)}get decotag(){return ma.call(this)}get hidden(){return ba.call(this)}set hidden(t){va.call(this,t)}get tag(){return xa.call(this)}set tag(t){_a.call(this,t)}get appendum(){return wa.call(this)}set appendum(t){ka.call(this,t)}defaultTextSubstitutor(){return Ma.call(this)}textLines(t){return Sa.call(this,t)}get font(){return za.call(this)}get lineHeight(){return Ea.call(this)}get textSubstitutor(){return Aa.call(this)}get text(){return Ta.call(this)}set text(t){Oa.call(this,t)}get textBounds(){return Ia.call(this)}get textRotation(){return ja.call(this)}get textHidden(){return Pa.call(this)}set textHidden(t){Ra.call(this,t)}get hasTextProperty(){return Ca.call(this)}animate(t){return Xa.call(this,t)}effect(t,e){return Ha.call(this,t,e)}serialize(...t){return Ja.call(this,...t)}trim(){Ka.call(this)}closeScene(t){tc.call(this,t)}delta(t,e){return ec.call(this,t,e)}invalidate(){nc.call(this)}get value(){return rc.call(this)}set value(t){ic.call(this,t)}get data(){return oc.call(this)}set data(t){sc.call(this,t)}set tap(t){ac.call(this,t)}get mappings(){return cc.call(this)}get retention(){return uc.call(this)}get animation(){return hc.call(this)}get started(){return lc.call(this)}set started(t){fc.call(this,t)}get controls(){return dc.call(this)}findFirst(t,...e){return vc.call(this,t,...e)}findAll(t,...e){return xc.call(this,t,...e)}capture(t,e,n){return _c.call(this,t,e,n)}findAnchor(t){return wc.call(this,t)}isDescendible(t){return kc.call(this,t)}getContext(t){return Mc.call(this,t)}get root(){return Sc.call(this)}get rootModel(){return zc.call(this)}get parent(){return Ec.call(this)}set parent(t){Ac.call(this,t)}get anchors(){return Tc.call(this)}get scalable(){return Oc.call(this)}get stuck(){return Ic.call(this)}get capturable(){return jc.call(this)}get position(){return Pc.call(this)}get origin(){return Rc.call(this)}get offset(){return Cc.call(this)}get app(){return Fc.call(this)}drawEffect(t){jo.call(this,t)}prepareFill(t,e){Do.call(this,t,e)}prepareFillIf(t){Lo.call(this,t)}onchangeFill(t,e){$o.call(this,t,e)}drawImage(t,e,n,r,i,o){Io.call(this,t,e,n,r,i,o)}mutateBounds(t,e){fs.call(this,t,e)}mutatePath(t,e,n){ds.call(this,t,e,n)}access(t){return _s.call(this,t)}substitute(t,e){return ws.call(this,t,e)}onchangeMappings(t,e){Oo.call(this,t,e)}onchangeData(t,e){Eo.call(this,t,e)}buildMappings(){Ao.call(this)}executeMappings(t){zo.call(this,t)}disposeMappings(){To.call(this)}ondropfile(t,e){Zo.call(this,t,e)}transcoordS2P(t,e,n){return es.call(this,t,e,n)}transcoordP2S(t,e,n){return ts.call(this,t,e,n)}transcoordS2T(t,e,n){return rs.call(this,t,e,n)}transcoordT2P(t,e,n){return is.call(this,t,e,n)}transcoordT2S(t,e,n){return os.call(this,t,e,n)}transcoordS2TR(t,e,n){return ns.call(this,t,e,n)}transcoordS2O(t,e,n){return ss.call(this,t,e,n)}transcoordC2S(t,e,n){return as.call(this,t,e,n)}transcoordS2C(t,e,n){return cs.call(this,t,e,n)}toParent(t,e,n){return es.call(this,t,e,n)}fromParent(t,e,n){return ts.call(this,t,e,n)}toScene(t,e,n){return rs.call(this,t,e,n)}fromScene(t,e,n){return os.call(this,t,e,n)}toLocal(t,e,n){return as.call(this,t,e,n)}toGlobal(t,e,n){return cs.call(this,t,e,n)}toOther(t,e,n){return ss.call(this,t,e,n)}on(t,e,n){return Yi.call(this,t,e,n)}off(t,e,n){return Bi.call(this,t,e,n)}once(t,e,n){return Gi.call(this,t,e,n)}trigger(t,...e){return Xi.call(this,t,...e)}delegate_on(t){return Hi.call(this,t)}delegate_off(t){return Vi.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get unitScale(){return 1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}Bc.capabilities=[],Bc.requires3d=!1,Bc.union=function(t){let e=0,n=0,r=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),n=Math.min(t.top,n),r=Math.max(t.left+t.width,r),i=Math.max(t.top+t.height,i)):(e=t.left,n=t.top,r=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:n,width:r-e,height:i-n}},Bc.transcoordR=Jo,Bc.transcoordRR=Ko,Bc.createCanvas=Fo,Bc.memoize=function(t,e,n){const r=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!r?.get)return void Zi(`${String(e)} is not defined in ${t.constructor.name}`);const i=r.get,o={get:n?function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};r.set&&(o.set=r.set),Object.defineProperty(t,e,o)},Bc.mixin=function t(e,n){if(n instanceof Array)n.forEach(n=>t(e,n));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(n)>=0)return e;if(e.mixingIn.indexOf(n)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(n),n.call(e),e.mixingIn.pop(),e.mixedIn.push(n)}return e},Bc.drawText=Ho,Bc.font=Go,Bc.textLines=Bo,Bc.drawStroke=Uo,Bc.drawFill=No,Bc.reposition=function(t){let{id:e,scale:n=hs,bold:r,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:h,paddingLeft:l,paddingRight:f,fontSize:d=Ro.FONT_SIZE,lineWidth:p=0,lineHeight:y,lineDash:g}=t.state;h||=0,u||=0,l||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:_}=t,{left:w,top:k,width:M,height:S}=t.bounds,z=t.element;if(z.hidden=!t.app?.isEditMode&&_,e&&(z.id=e),m&&(z.className=m),Object.assign(z.style,ls,{fontFamily:o,fontSize:d+"px",width:M+"px",height:S+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:h+"px",paddingLeft:l+"px",border:p+"px",borderColor:b,borderStyle:p>0?g||Ro.LINE_DASH:"",color:x,fontWeight:r?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===y?"":y+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),us(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,r=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${n}px ${r}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const E=t.delta(),A=(n&&n.x||1)*E.sx,T=(n&&n.y||1)*E.sy,O=(v||0)+E.theta,I=E.tx||0,j=E.ty||0;z.style.transform=`rotate(${O}rad) translate(${I}px, ${j}px) scale(${A}, ${T}) perspective(1px)`},Bc.RetentionManager=bs,Bc.template=function(t,e,n){var r=Tr.imports._.templateSettings||Tr;n&&nr(t,e,n)&&(e=void 0),t=zr(t),e=ir({},e,r,gr);var i=ir({},e.imports,r.imports,gr),o=yn(i),s=function(t,e){return dr(e,function(e){return t[e]})}(i,o);Ln(o,function(t){if(Pr.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,u=0,h=e.interpolate||Cr,l="__p += '",f=RegExp((e.escape||Cr).source+"|"+h.source+"|"+(h===vr?Rr:Cr).source+"|"+(e.evaluate||Cr).source+"|$","g"),d=Nr.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,n,r,i,o,s){return r||(r=i),l+=t.slice(u,s).replace(Fr,br),n&&(a=!0,l+="' +\n__e("+n+") +\n'"),o&&(c=!0,l+="';\n"+o+";\n__p += '"),r&&(l+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=s+e.length,e}),l+="';\n";var p=Nr.call(e,"variable")&&e.variable;if(p){if(Pr.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(c?l.replace(Or,""):l).replace(Ir,"$1").replace(jr,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=fr(function(){return Function(o,d+"return "+l).apply(void 0,s)});if(y.source=l,lr(y))throw y;return y},Bc.buildSubstitutor=ks,["rotatePoint","font","lineHeight","retention"].forEach(t=>Bc.memoize(Bc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Bc.memoize(Bc.prototype,t,!0));const Gc=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function Xc(t){return class extends t{async ready(){await super.ready();const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=t[Y];null!=e&&n.set(String(e),t)}for(const[t,r]of n)if(!e.has(t)){try{this.removeItem(r,!0)}catch{}try{r?.dispose?.()}catch{}}for(const[t,r]of e){if(n.has(t))continue;if(null==r.itemId)continue;const e=this._createItemFromRecord(r);if(e){e[Y]=t;try{this.handoverIn(e)}catch{}}}for(const[t,r]of e){const e=n.get(t);if(e&&(r.itemState&&"function"==typeof e.setState))try{e.setState(r.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,r=[];for(const t of this._items){const e=t[Y];null!=e?n.set(String(e),t):r.push(t)}for(const r of t){const t=n.get(r)??null;e.push(this._slotRecordOf(r,t))}for(const t of r)e.push(this._slotRecordOf("",t));for(const[r,i]of n)t.includes(r)||e.push(this._slotRecordOf(r,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const r of n)r in e&&void 0!==e[r]&&(t[r]=e[r]);return Object.keys(t).length>0?t:void 0}const r={};for(const t of Object.keys(e))Gc.has(t)||t.startsWith("_")||(r[t]=e[t]);return Object.keys(r).length>0?r:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=Bc.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}function Hc(t,e,n){return n?{code:t,path:e,params:n}:{code:t,path:e}}const Vc="holder",Zc=t=>"number"==typeof t&&Number.isFinite(t),Qc=t=>Zc(t)&&t>0,Jc=t=>Number.isSafeInteger(t)&&t>0;function Kc(t,e,n){const r=t?.allowed;if(r&&"object"==typeof r)for(const t of["width","depth","height"])Qc(r[t])||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else n.push(Hc("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Jc(t.stackLimit)||t.stackLimit===1/0||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Zc(t.rotation)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||n.push(Hc("ARRAY_REQUIRED",`${e}.accepts`))}function tu(t,e={}){const n=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Hc("TIERS_REQUIRED","tiers")];const r=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const o=`tiers[${e}]`;if(!t||"object"!=typeof t)return void n.push(Hc("OBJECT_REQUIRED",o));if(Jc(t.tierNo)?i.has(t.tierNo)?n.push(Hc("TIER_NUMBER_DUPLICATE",`${o}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?r&&!r.has(t.anchorId)&&n.push(Hc("ANCHOR_UNKNOWN",`${o}.anchorId`,{anchorId:t.anchorId})):n.push(Hc("ANCHOR_REQUIRED",`${o}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||n.push(Hc("MOUNT_INVALID",`${o}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Zc(t.position[e])||n.push(Hc("FINITE_NUMBER_REQUIRED",`${o}.position.${e}`));else n.push(Hc("OBJECT_REQUIRED",`${o}.position`));Zc(t.rotation)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${o}.rotation`));const s=t.layout;switch(s?.pattern){case"SINGLE":Kc(s.slot,`${o}.layout.slot`,n);break;case"ROW":Jc(s.count)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.count`)),Qc(s.pitch)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch`)),"X"!==s.axis&&"Z"!==s.axis&&n.push(Hc("AXIS_INVALID",`${o}.layout.axis`)),Kc(s.slot,`${o}.layout.slot`,n);break;case"GRID":Jc(s.rows)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.rows`)),Jc(s.cols)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.cols`)),Qc(s.pitch?.x)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.x`)),Qc(s.pitch?.z)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.z`)),Kc(s.slot,`${o}.layout.slot`,n);break;case"CUSTOM":{if(!Array.isArray(s.slots)){n.push(Hc("ARRAY_REQUIRED",`${o}.layout.slots`));break}s.slots.length||n.push(Hc("SLOTS_REQUIRED",`${o}.layout.slots`));const t=new Set;s.slots.forEach((e,r)=>{const i=`${o}.layout.slots[${r}]`;Jc(e?.slotNo)?t.has(e.slotNo)?n.push(Hc("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),Zc(e?.offset?.x)&&Zc(e?.offset?.z)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${i}.offset`)),Kc(e,i,n)});break}default:n.push(Hc("PATTERN_INVALID",`${o}.layout.pattern`))}}),n}function eu(t,e=""){const n=[],r=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,n)=>r(t,`${e}[${n}]`));else if(t&&"object"==typeof t)for(const[n,i]of Object.entries(t))r(i,e?`${e}.${n}`:n)}else n.push(Hc("NOT_PERSISTABLE",e,{value:String(t)}))};return r(t,e),n}function nu(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function ru(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:nu(t)},(t,e)=>e+1)}function iu(t,e,n,r,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(n-1)*e+r;case"COL_MAJOR":return(r-1)*t+n;case"SERPENTINE_ROW":return(n-1)*e+(n%2==1?r:e-r+1);case"SERPENTINE_COL":return(r-1)*t+(r%2==1?n:t-n+1)}}function ou(t,e,n,r="ROW_MAJOR"){const i=n-1;switch(r){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,n=i%e+1;return{r:t,c:t%2==1?n:e-n+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,n=i%t+1;return{r:e%2==1?n:t-n+1,c:e}}}}const su=(t,e)=>e&&0!==t?-t:t;function au(t,e,n={}){const r=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!r||!Jc(e.slot))return null;const i=r.layout;let o,s,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;o=i.slot,s={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=su((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);o=i.slot,s="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:n}=ou(i.rows,i.cols,e.slot,i.order),r=i.origin??{x:"MIN",z:"MIN"};o=i.slot,s={x:su((n-1-(i.cols-1)/2)*i.pitch.x,"MAX"===r.x),z:su((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===r.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;o=t,s={...t.offset},a=t.name;break}}return{tier:r.tierNo,slotNo:e.slot,name:a,anchorId:r.anchorId,mount:r.mount,tierPosition:{...r.position},tierRotation:r.rotation,offset:s,allowed:{...o.allowed},accepts:o.accepts?[...o.accepts]:void 0,stackLimit:o.stackLimit??n.defaultStackLimit??1,rotation:o.rotation??0}}function cu(t){return`t${t.tier}_s${t.slot}`}function uu(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*hu(t){for(const e of t?.tiers??[])for(const t of ru(e.layout))yield{tier:e.tierNo,slot:t}}function lu(t,e,n){if(!n)return{x:t,z:e};const r=n*Math.PI/180,i=Math.cos(r),o=Math.sin(r),s=t=>Math.round(1e9*t)/1e9;return{x:s(t*i+e*o),z:s(-t*o+e*i)}}function fu(t){const e=lu(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const du=.05,pu=t=>!!t&&Qc(t.width)&&Qc(t.depth)&&Qc(t.height);function yu(t,e){const n=e*Math.PI/180,r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),o=t=>Math.round(1e9*t)/1e9;return{width:o(t.width*r+t.depth*i),depth:o(t.width*i+t.depth*r)}}function gu(t,e,n=0,r=.05){if(!pu(t))return null;if(!Zc(n)||!Zc(r)||r<0||r>=1)return null;const i=yu(t,e.rotation),o=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-r)),s=t.height*o;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(n+s/2),z:0},rotation:0,scale:o}}function mu(t,e,n=0,r=.05){const i=gu(t,e,n,r);if(!i)return null;const o=fu(e);return{position:{x:o.position.x,y:o.position.y+i.position.y,z:o.position.z},rotation:o.rotation,scale:i.scale}}function bu(t,e,n=.05){let r=0;return t.map(t=>{const i=t?mu(t,e,r,n):null;return i&&(r+=t.height*i.scale),i})}const vu=1e-6;function xu(t,e){const n=fu(t),r=t.allowed.width/2,i=t.allowed.depth/2,o=[[-r,-i],[r,-i],[r,i],[-r,i]].map(([t,e])=>{const r=lu(t,e,n.rotation);return{x:n.position.x+r.x,z:n.position.z+r.z}}),s=lu(1,0,n.rotation),a=lu(0,1,n.rotation),c="HANG"===t.mount?-1:1,u=[n.position.y,n.position.y+c*t.allowed.height],h=o.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:o,axes:[s,a],y0:Math.min(...u),y1:Math.max(...u),minX:Math.min(...h),maxX:Math.max(...h)}}function _u(t,e){for(const n of[...t.axes,...e.axes]){const r=t.corners.map(t=>t.x*n.x+t.z*n.z),i=e.corners.map(t=>t.x*n.x+t.z*n.z);if(Math.min(Math.max(...r),Math.max(...i))-Math.max(Math.min(...r),Math.min(...i))<=vu)return!1}return!0}function wu(t,e={}){const n=[],r=new Map;t.tiers.forEach((e,n)=>{const i=r.get(e.anchorId)??[];r.set(e.anchorId,i);for(const r of ru(e.layout))i.push(xu(au(t,{tier:e.tierNo,slot:r}),n))});for(const[t,i]of r){const r=e.anchorFaces?.[t];if(r)for(const t of i)t.corners.some(t=>Math.abs(t.x)-r.width/2>vu||Math.abs(t.z)-r.depth/2>vu)&&n.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else n.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const o=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<o.length;t++){const e=o[t];for(let r=t+1;r<o.length&&o[r].minX<e.maxX-vu;r++){const t=o[r];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=vu)continue;if(!_u(e,t))continue;const[i,s]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];n.push({code:"SLOT_OVERLAP",path:`tiers[${s.tierIndex}]`,params:{tier:s.tier,slot:s.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return n}function ku(t,e,n=[],r={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=r.normalizeType??(t=>null==t?"":String(t)),o=[];let s=!1;if(t.accepts){const n=i(e.type);n?t.accepts.map(i).includes(n)||o.push("TYPE_NOT_ACCEPTED"):s=!0}if(n.length+1>t.stackLimit&&o.push("STACK_LIMIT_EXCEEDED"),pu(e.dims)){const r=yu(e.dims,t.rotation);if(r.width>t.allowed.width&&o.push("WIDTH_EXCEEDED"),r.depth>t.allowed.depth&&o.push("DEPTH_EXCEEDED"),n.every(t=>pu(t.dims))){n.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&o.push("HEIGHT_EXCEEDED")}else s=!0}else s=!0;return o.length?{verdict:"NG",reasons:s?[...o,"SPEC_UNKNOWN"]:o}:s?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}const Mu=[{id:"__default__",maxCount:1/0}];function Su(t){const e={id:cu({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function zu(t,e){const n=e?.state?.type??e?.type;return t.accepts?!!n&&t.accepts.includes(n):!t.allowedTypes?.length||!!n&&t.allowedTypes.includes(n)}function Eu(t){var e;return e=class extends t{get slotLayout(){}get slots(){const t=this.slotLayout;if(!t)return[];const e=[];for(const n of hu(t)){const r=au(t,n);r&&e.push(Su(r))}return e}slotById(t){const e=this.slotLayout;if(e){const n=uu(t),r=n?au(e,n):null;return r?Su(r):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,n=0,r){const i=this.slotLayout,o=i?uu(t):null,s=o?au(i,o):null,a=s?mu(e,s,n,r):null;return a?{...a,anchorId:s.anchorId}:null}get arrangementStrategy(){return p}canReceive(t,e){const n=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return K.log({role:"target",contract:"canReceive",component:this,args:{carrier:U(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:Mu;for(const n of e){if(!zu(n,t))continue;const e=n.maxCount??this.arrangementStrategy.capacity(n),r=this._countOccupied(n.id);if(!(r>=e))return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:{slotId:n.id,occupied:r,max:e}}),n}return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const n=this._realObject?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new w;n.getWorldQuaternion(r);const i=new w(e.x,e.y,e.z,e.w);return r.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,n=e?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new k;n.getWorldPosition(r);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new k(0,i,0);return n.localToWorld(t),{x:r.x,y:t.y,z:r.z}}return{x:r.x,y:r.y,z:r.z}}attachPointFor(t){const e=t?.[Y];if(!e)return null;const n=this.slots.find(t=>t.id===e);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,r=n?n.state??{}:t??{},i={width:Number(r.width)||0,height:Number(r.height)||0,depth:Number(r.depth)||0},o=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!o)return null;const s=e.index??this._countOccupied(o.id),a=e.occupantCount??s,c=this.arrangementStrategy.positionAt(s,o,a,n??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,h=Number(this.state?.height)||0,l=c.x+i.width/2-u/2,f=c.y+i.height/2-h/2,d=this._realObject,p=d?.placementMode??"floor",y="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,g=this._receivingSurfaceLocalY();let m;m=null!==g?g+y:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+y:y-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??i,o)??void 0;return b?{position:{x:l,y:m,z:f},rotation:b}:{position:{x:l,y:m,z:f}}}_zPosFromSeatY(t,e,n){const r=this._realObject,i=r?.receivingSurfaceY??0,o=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=r?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(r?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!zu(t,e))return null;const n=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<n?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[Y]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[Y]===t).length:0}},e.__hasCapacity=!0,e}function Au(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return[];const s="number"==typeof t.rotation?t.rotation:0,a=Math.cos(s),c=Math.sin(s),u=n+i/2,h=r+o/2,l="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/2,lz:0,odx:1,odz:0},{lx:0,lz:-o/2,odx:0,odz:-1},{lx:0,lz:o/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:u+e*a-n*c,z:h+e*c+n*a}),direction:{x:l*(t.odx*a-t.odz*c),z:l*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Tu(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return{inbounds:[],outbounds:[]};const s="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&i<o,u=n+i/2,h=r+o/2,l=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),y=Math.sin(s),g=(t,e)=>({x:u+t*p-e*y,z:h+t*y+e*p}),m=c?{lx:0,lz:-l}:{lx:-l,lz:0},b=c?{lx:0,lz:l}:{lx:l,lz:0},v=g(m.lx,m.lz),x=g(b.lx,b.lz),_={x:f*p-d*y,z:f*y+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},M={x:-k.x,z:-k.z},S=(c?i:o)/2;return a?{inbounds:[{worldPos:x,direction:M,halfSpan:S}],outbounds:[{worldPos:v,direction:M,halfSpan:S}]}:{inbounds:[{worldPos:v,direction:k,halfSpan:S}],outbounds:[{worldPos:x,direction:k,halfSpan:S}]}}function Ou(t){const e=t.left??0,n=t.top??0,r=t.width??0,i=t.height??0;if(r<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&r<i,a=e+r/2,c=n+i/2,u=s?i/2:r/2,h=Math.cos(o),l=Math.sin(o),f=(t,e)=>({x:a+t*h-e*l,z:c+t*l+e*h});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Iu(t){const e=t.cx??0,n=t.cy??0,r=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(r+r*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,h="reverse"===t.status;if(r<=0||i<=0)return{inbounds:[],outbounds:[]};const l={x:e+s*Math.sin(c),z:n-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:n-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return h?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:l,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:l,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function ju(t){const e=Tu(t),n=e.outbounds[0];if(!n)return{inbounds:Au(t,"inbound"),outbounds:[]};const r=Au(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,r=t.worldPos.z-n.worldPos.z;return Math.hypot(e,r)>1}),i=n.direction,o=[];for(const t of r){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+i.x,r=t.direction.z+i.z,s=Math.hypot(n,r)||1;o.push({worldPos:t.worldPos,direction:{x:n/s,z:r/s},halfSpan:t.halfSpan})}return{inbounds:[...r,...o],outbounds:e.outbounds}}function Pu(t,e,n={}){const r=n.distance??5,i=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<i)return!1;const o=t.worldPos.x-e.worldPos.x,s=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,i=t.direction.z;if(Math.abs(o*n+s*i)>r)return!1;const a=Math.abs(o*-i+s*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=r}function Ru(t,e,n,r=0){const i=n.width??0,o=n.height??0;if(i<=0||o<=0)return!1;const s=(n.left??0)+i/2,a=(n.top??0)+o/2,c="number"==typeof n.rotation?n.rotation:0,u=Math.cos(-c),h=Math.sin(-c),l=t-s,f=e-a,d=l*u-f*h,p=l*h+f*u;return Math.abs(d)<=i/2+r&&Math.abs(p)<=o/2+r}function Cu(t,e,n){const r=n.width??0,i=n.height??0;if(r<=0||i<=0)return 1/0;const o=(n.left??0)+r/2,s=(n.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,h=e.z;const l="number"==typeof n.rotation?n.rotation:0;if(0!==l){const t=Math.cos(-l),e=Math.sin(-l),n=a*e+c*t,r=u*e+h*t;a=a*t-c*e,c=n,u=u*t-h*e,h=r}const f=r/2,d=i/2;let p=-1/0,y=1/0;if(Math.abs(u)<1e-9){if(a<-f||a>f)return 1/0}else{const t=(-f-a)/u,e=(f-a)/u;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/h,e=(d-c)/h;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}return y<p?1/0:p>=0?p:y>=0?Math.min(-p,y):-y}function Fu(t,e,n,r=6){return!!Ru(t.worldPos.x,t.worldPos.z,e,r)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function Nu(t,e,n){return t.outbounds.map(t=>{const r=[];for(const i of e){let e=null;for(const r of i.topology.inbounds){if(!Pu(t,r,n))continue;const i=t.worldPos.x-r.worldPos.x,o=t.worldPos.z-r.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const r=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?n?.sinkMargin??30:6;if(Fu(t,i.bounds,r,o)){const n=Cu(t.worldPos,t.direction,i.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(i.bounds.left??0)+(i.bounds.width??0)/2,r=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-r)+1e3}}}null!==e&&r.push({id:i.id,dist:e})}return 0===r.length?null:(r.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),r[0].id)})}function Du(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const r=new Map,i=new Set;for(const n of t){const o=t.filter(t=>t.id!==n.id),s=Nu(n.topology,o,e);r.set(n.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const o=r.get(t)??[];o.includes(e)||(o.push(e),r.set(t,o),i.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])o(e.id,t);for(const t of e.links.upstream??[])o(t,e.id)}const s=new Set,a=new Set;for(const e of t){(r.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:n,out:r,sinks:s,sources:a}}function Lu(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const r=new Set([e]);for(const i of function(t,e,n){const r=n.get(e);if(r)return r;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const n of t.out.get(e)??[])null!=n&&(i.add(n),s.has(n)||(s.add(n),o.push(n)))}return n.set(e,i),i}(t,e,n))r.add(i);return r})}function $u(t,e,n,r){return e===n?0:function(t,e,n){const r=n.get(e);if(r)return r;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),n=i.get(e);for(const r of t.out.get(e)??[])null==r||i.has(r)||(i.set(r,n+1),o.push(r))}return n.set(e,i),i}(t,e,r).get(n)??1/0}function Uu(t,e,n){const r=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<r.length;e++){const s=r[e];if(null==s)continue;const a=s===n?0:$u(t,s,n,i);a!==1/0&&o.push({i:e,hops:1+a})}return o.sort((t,e)=>t.hops-e.hops||t.i-e.i),o.map(t=>t.i)}function qu(t,e,n){const r=Uu(t,e,n);return r.length?r[0]:-1}function Wu(t,e,n){return e===n||Uu(t,e,n).length>0}function Yu(t,e){const n=new Set;for(const r of Lu(t,e))for(const e of r)t.sinks.has(e)&&n.add(e);return n}function Bu(t,e,n){return Gu(t,e,n).map(t=>t.index)}function Gu(t,e,n){const r=n instanceof Set?n:new Set(n);if(0===r.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...r].sort(),a=[];for(let e=0;e<i.length;e++){const n=i[e];if(null==n)continue;let r=1/0,c="";for(const e of s){const i=1+(n===e?0:$u(t,n,e,o));i<r&&(r=i,c=e)}r!==1/0&&a.push({index:e,hops:r,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Xu(t,e={}){const n=[],r=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const r=t.nodes.get(e);if(!r||!r.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(i.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],n=[...t.nodes.keys()].sort(),r=new Set,i=[],o=new Set,s=n=>{r.add(n),i.push(n),o.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),n=i.slice(t),r=n.indexOf([...n].sort()[0]),o=[...n.slice(r),...n.slice(0,r)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else r.has(a)||s(a);i.pop(),o.delete(n)};for(const t of n)r.has(t)||s(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of o){t.some(t=>r.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const s=e.routingWeights;if(s)for(const[t,e]of[...s].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...i].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Hu(t,e){if(!t)return[];const n=[],r=new Set,i=t=>{if(!t||r.has(t))return;if(r.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,r=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=r?String(r):void 0;if(i)try{const e=t.getSegmentTopology(),r=t.state??{},o={left:r.left,top:r.top,width:r.width,height:r.height,rotation:r.rotation};e&&n.push({id:i,topology:e,bounds:o})}catch{}}const o=t?.components;if(Array.isArray(o))for(const t of o)i(t)};return i(t),n}function Vu(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const r=t.getSegmentTopology();if(!r||0===r.outbounds.length)return null;const i=Nu(r,Hu(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of i)if(t)return t;return null}function Zu(t){return!!t&&"function"==typeof t.routingConstraints}function Qu(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Ju(t,e=16){const n=[],r=t.parent??t.rootModel??t.root;if(!r)return n;const i=Vu(t);if(!i)return n;const o=eh(r,i);if(!o)return n;const s=[{segment:o,accumulated:{},pathIds:[i],visited:new Set([i])}];for(;s.length>0;){const t=s.shift();if(t.pathIds.length>e)continue;const i=Zu(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=Ku(t.accumulated,i);if(!o)continue;const a=th(t.segment,e.portId,r);a&&!t.visited.has(a.state?.id??"")?s.push({segment:a,accumulated:o,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Qu(t.segment)){const e=t.segment.acceptedCarrierData(),r=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:r});else for(const i of e){const e=Ku(t.accumulated,i);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:r})}continue}const e=Vu(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=eh(r,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function Ku(t,e){const n={...t};for(const[t,r]of Object.entries(e)){if(t in n&&n[t]!==r)return null;n[t]=r}return n}function th(t,e,n){if("straight"===e&&t.state?.downstreamRef)return eh(n,t.state.downstreamRef);const r=eh(n,e);if(r)return r;const i=Vu(t);return i?eh(n,i):null}function eh(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,r=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=r(t);if(e)return e}return null};return r(t)}function nh(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function rh(t,e,n=5,r=[],i=n){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,u=[],h=new Map,l=[],f=new Map;for(const t of r){const e=Array.isArray(t),n=e?t:t.positions,r=e?void 0:t.kind;if(!n.length)continue;const i=u.length;u.push({pos:n[0],members:[]});for(const t of n)l.push({pos:t,pt:i});r&&f.set(i,r)}const d=(t,e)=>{const r=c(t,e),i=h.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of l)nh(t.pos,r)<=n&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)nh(u[t].pos,r)<=n&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:r,members:[]})),u[s].members.push({seg:t,end:e}),h.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,y=new Set,g=new Set;{const t=t=>{let e=-1,n=1/0;for(let r=0;r<u.length;r++){const i=nh(u[r].pos,t);i<n&&(n=i,e=r)}for(const r of l){const i=nh(r.pos,t);i<n&&(n=i,e=r.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:r}=t(n.pos);e>=0&&r<=i&&(p.add(e),("source"===n.kind?y:g).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?y:g).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],v=(e,n)=>{if(void 0===s[e])return s[e]=n,void b.push(e);s[e]!==n&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const n=h.get(`${t}:${e}`);if(void 0===n)continue;const r=u[n];if(2!==r.members.length||p.has(n))continue;const i=r.members[0],o=i.seg===t&&i.end===e?r.members[1]:i;if(o.seg===t)continue;const a="end"===e!==s[t],c="end"===o.end!==!a;v(o.seg,c)}},_=()=>{for(;b.length;)x(b.shift())},w=t=>{let e=-1,n="start",r=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=nh(c(i,o),t.pos);s<r&&(r=s,e=i,n=o)}if(e<0||r>i)return;const s="source"===t.kind?"end"===n:"start"===n;v(e,s)};for(const t of e)"source"===t.kind&&w(t);_();for(const t of e)"sink"===t.kind&&w(t);_();let k=!0;for(;k;){k=!1;for(const t of u){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===s[t.seg]);if(1!==e.length)continue;let n=0,r=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?n++:r++);const i=e[0];let o;0===r&&n>0?o="end"===i.end:0===n&&r>0&&(o="start"===i.end),void 0!==o&&(s[i.seg]=o,b.push(i.seg),_(),k=!0)}}if(s.some(t=>void 0===t)&&y.size>0&&g.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),n=[];for(const r of t)e[r]=0,n.push(r);for(;n.length;){const t=n.shift();for(const r of u[t].members){const i=h.get(`${r.seg}:${"start"===r.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,n.push(i))}}return e},e=t(y),n=t(g);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const r=h.get(`${t}:start`),i=h.get(`${t}:end`);if(void 0===r||void 0===i)continue;if(u[r].members.length<2||u[i].members.length<2)continue;if(e[r]===1/0||e[i]===1/0||n[r]===1/0||n[i]===1/0)continue;let o;e[r]!==e[i]?o=e[r]<e[i]:n[r]!==n[i]&&(o=n[i]<n[r]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const M=new Map;for(let e=0;e<o;e++)M.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function ih(...t){}function oh(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function sh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*ah(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*ah(t)}function ch(t,e,n){const r=e.width??0,i=e.height??0;if(r<=0||i<=0)return!1;const o=(e.left??0)+r/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,h=Math.cos(-a),l=Math.sin(-a),f=c*h-u*l,d=c*l+u*h;return Math.abs(f)<=r/2+n&&Math.abs(d)<=i/2+n}function uh(t){const e=[],n=[],r=[],i=[];for(const o of ah(t)){const t=sh(o);if(!t)continue;if(o.flowOrientable){const n=Ou(o.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof o.openings){const t=o.state??{};(t.width??0)>0&&(t.height??0)>0&&i.push(t);continue}let s;try{s=o.getSegmentTopology()}catch{continue}if(!s)continue;const a=s.inbounds??[],c=s.outbounds??[],u="function"==typeof o.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||u))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&r.push({positions:t})}}for(const t of i){const i=[];for(const n of e)for(const e of[n.start,n.end])ch(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of n)ch(e.pos,t,16)&&("sink"===e.kind?o=!0:s=!0);const a=o&&!s?"sink":s&&!o?"source":void 0;(i.length>=2||a&&i.length>=1)&&r.push({positions:i,kind:a})}if(0===e.length||0===n.length)return e.length,n.length,new Map;const o=rh(e,n,8,r,60).directions;return e.length,n.length,r.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function hh(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:uh(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const r=sh(t),i=r?n.map.get(r):void 0;return"reverse"===i||"forward"!==i&&void 0}function lh(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function fh(t,e,n,r){if(!t||!e)return null;const i=[],o=t=>{if(!t||t===r)return;if(function(t,e){const n=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(n)&&n.includes(e)}(t,e)&&lh(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(n.x,n.y)})}const s=t.components;if(Array.isArray(s))for(const t of s)o(t)};return o(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function dh(t){return!!t&&"function"==typeof t.routingDestination}function ph(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*yh(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*yh(t)}function gh(t){const e=[],n=new Map,r=new Map,i=new Set,o=[];for(const s of yh(t)){"function"==typeof s?.registerWithHost&&o.push(s);const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks?s.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||dh(s)||c||lh(s)))continue;const u=ph(s);if(!u)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=s.getSegmentTopology()}catch{continue}if(!h)continue}const l=s.state??{},f={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation};if(e.push({id:u,topology:h,bounds:f,links:a}),r.set(u,s),dh(s)){i.add(u);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(u),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:r,routingTargetIds:i,stationClients:o}}function mh(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:r,components:i,routingTargetIds:o,stationClients:s}=gh(t),a=Du(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const r=[...e].sort((t,e)=>{const n=ph(t)??"",r=ph(e)??"";return n.localeCompare(r)});for(const e of r){const n=e.declaredHostRef?.();let r=null;if(n&&(r=t.findById?.(n)??null),!r){const n=e.hostCapability?.(),i=e.hostFacingPoint?.();n&&i&&(r=fh(t,n,i,e)?.component??null)}r&&"function"==typeof e.registerWithHost&&e.registerWithHost(r)}const i=e=>{if(!e)return;if(lh(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const r=t.findById?.(n);r&&e.registerDivertStation(n,r)}const n=e.components;if(Array.isArray(n))for(const t of n)i(t)};i(t)}(t,s);const c=new Set;for(const[t,e]of i){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const u=new Map;for(const t of o){const e=i.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&u.set(t,n)}}const h=Xu(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:r,components:i,issues:h},t.__flowGraph=e}return e}function bh(t){return mh(t)?.issues??[]}function vh(t){const e=mh(t);return e&&e.graph.nodes.size>0?e.graph:null}function xh(t,e){return mh(t)?.destToSinks.get(e)??[]}function _h(t,e){return mh(t)?.components.get(e)}function wh(t){const e=mh(t);return e?[...e.destToSinks.keys()]:[]}function kh(t){return ph(t)}function Mh(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function Sh(t,e,n,r,i){if(1===r.length)return r[0];switch(t){case"index":default:return r[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),r[t%r.length]}case"weight":{const t=r.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(i.get(t.target))),o=t.reduce((t,e)=>t+e,0);if(o<=0)return r[0];const s=n.counters.get(e)??0;n.counters.set(e,s+1);let a=s%o;for(let e=0;e<r.length;e++){if(a<t[e])return r[e];a-=t[e]}return r[r.length-1]}case"utilization":{let t=1/0,e=r[0];for(const n of r){const r=Mh(i.get(n.target));r<t&&(t=r,e=n)}return e}}}function zh(t,e,n){const r=t?.root;if(!r)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=mh(r);if(!o||0===o.graph.nodes.size)return null;const s=ph(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Gu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],h=c.filter(t=>{const n=u[t.index],r=n?o.components.get(n):null;return!r||"function"!=typeof r.canReceive||r.canReceive(e)});if(0===h.length)return u[c[0].index]??null;const l=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const r=e?.state?.routingBalancingPolicy;return r||"round-robin"}(t,r),f=Sh(l,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(r),h,o.components);return u[f.index]??null}n({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),n({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,vh(t)}catch{return null}}}catch{}function Eh(t,e,n){const r=zh(t,e,n);if(null==r)return null;const i=t?.root,o=_h(i,r)??i?.findById?.(r)??null;return o?{targetId:r,component:o,origin:"explicit"}:null}function Ah(t){const e=t?.root,n=vh(e),r=kh(t);if(!n||!r)return null;const i=(n.out.get(r)??[]).find(Boolean);if(!i)return null;const o=_h(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Th(t){const e=kh(t);return e?Oh(t?.root,e):[]}function Oh(t,e){if(!t||!e)return[];const n=vh(t);if(!n)return[];const r=new Set;for(const i of Yu(n,e)){const e=_h(t,i);if(dh(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&r.add(t)}}return[...r]}function Ih(t,e){if(!t||!e)return[];const n=vh(t);if(!n)return[];const r=new Map;for(const t of n.out.values())for(const e of t)null!=e&&r.set(e,(r.get(e)??0)+1);const i=new Map;for(const o of Yu(n,e)){const e=_h(t,o);if(!dh(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let s=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(s=t)}null===s&&(s=r.get(o)??0,0===s&&(s=1)),i.set(n,(i.get(n)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function jh(t){return vh(t)}function Ph(t){const e=vh(t);if(!e)return[];const n=new Set,r=new Set,i=t=>{if(!t)return;const o=kh(t);if(o&&e.nodes.has(o)){dh(t)&&n.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&r.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),Xu(e,{routingTargetIds:n,loopCapableIds:r})}function Rh(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let r=0;for(const e of t)if(r+=e.weight,n<r)return e.value;return t[t.length-1].value}const Ch={next:Eh,downstream:Ah,reachableDestinations:Th,reachableDestinationsFrom:Oh,reachableDestinationsWeightedFrom:Ih,pickWeightedDestination:Rh,graphFor:jh,validate:Ph};function Fh(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const r=t.prototype?.attachPointFor;return"function"==typeof r?r.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n&&(this._items.splice(n,1),t.parent=null,t._realObject?.setTransientDisplayScale?.(1),!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=t.parent;n&&("function"==typeof n.removeComponent&&-1!==n._components?.indexOf?.(t)&&n.removeComponent(t,!0),n!==this&&"function"==typeof n.removeItem&&-1!==n._items?.indexOf?.(t)&&n.removeItem(t,!0));const r=-1===this._items.indexOf(t);if(r&&this._items.push(t),t.parent=this,r&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}this.seatHeldItem(t,{toParent3D:e?.toParent3D,slotId:e?.slotId}),t.held?.(this),this._bumpReceived?.(t)}seatHeldItem(t,e={}){t.realObject;const n=t._realObject,r=n?.object3d;if(r){let i,o,s=e.toParent3D,a="world-preserve",c=1;if(!s){const n=this.attachPointFor?.(t,{slotId:e.slotId});n?.attach&&(s=n.attach,i=n.localPosition,o=n.localRotation,a=n.carryPolicy??"world-preserve",c=n.displayScale??1)}s&&r.parent!==s&&(s.updateWorldMatrix?.(!0,!1),r.updateWorldMatrix?.(!0,!1),s.attach(r),n.suppressTransform=!0),s&&(i&&r.position.set(i.x,i.y,i.z),"world-preserve"!==a?o?r.rotation.set(o.x,o.y,o.z):r.quaternion.identity():o&&r.rotation.set(o.x,o.y,o.z),n?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),n?.setTransientDisplayScale?.(c))}}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)try{e.dispose?.()}catch{}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,r,i){for(let o=this._items.length-1;o>=0;o--){const s=this._items[o],a="static"===s.position?s.capture?.(t,e,i):s.capture?.(n,r,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const r=e.bounds;!e.showOverflow&&r&&(t.beginPath(),t.rect(r.left,r.top,r.width,r.height),t.clip(),t.closePath());const{left:i=0,top:o=0}=e.state??{};t.translate(i,o),this._drawItems(t),t.translate(-i,-o),t.restore()}capture(t,e,n){const r=this,i=this._items;if(i&&i.length>0&&(!r.app||r.app.isEditMode||!r.hidden)){const i=r.fromParent?.(t,e);if(i&&r.contains?.(i.x,i.y)){const o=r.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,n);if(s)return s}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Nh(t){var e;const n=!!t.__hasCapacity,r=!!t.__hasTransferable,i=n?t:Eu(t),o=r?i:function(t){var e;return(e=class extends t{reserve(t,e){const n=this.findSlot(t);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){K.log({role:"target",contract:"receive:enter",component:this,args:{carrier:U(t),options:e}});const n=this.reserve(t,e);if(!n){K.log({role:"target",contract:"receive:reject",component:this,args:{carrier:U(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,e,n={}){const r=t.slot,i=this._countOccupied(r.id),o=this.arrangementStrategy.positionAt(i,r,i,e);K.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:r.id,occupantCount:i,carrier:U(e)},result:o}),e[Y]=r.id;const s=e._realObject;let a,c;s?.object3d&&(s.object3d.updateWorldMatrix(!0,!1),a=new k,c=new w,s.object3d.getWorldPosition(a),s.object3d.getWorldQuaternion(c));const{animated:u=!1,duration:h,ease:l}=n;"function"==typeof this.handoverIn?this.handoverIn(e,{slotId:r.id}):this.reparent?.(e,{animated:u,duration:h,ease:l}),!u&&e._realObject&&(e._realObject.suppressTransform=!1);{const t={},n=this.placementFor?.(e,{slot:r,index:i,occupantCount:i})??null;if(K.log({role:"target",contract:"placementFor",component:this,args:{carrier:U(e),slotId:r.id,index:i},result:n}),n){const i=e.state??{},o=this.state??{};t.left=n.position.x-(Number(i.width)||0)/2+(Number(o.width)||0)/2,t.top=n.position.z-(Number(i.height)||0)/2+(Number(o.height)||0)/2;const s=this._zPosFromSeatY(n.position.y,i.depth,r);null!==s&&(t.zPos=s),n.rotation&&W(t,n.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=r.localPosition.z+e}const n=this.acceptanceRotation?.(e,r);K.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:U(e),slotId:r.id},result:n}),n&&W(t,n)}const s=this.normalizePose?.(e,r);"function"==typeof this.normalizePose&&K.log({role:"target",contract:"normalizePose",component:this,args:{carrier:U(e),slotId:r.id},result:s}),s&&Object.assign(t,s),Object.keys(t).length&&(e.setState?.(t),K.log({role:"target",contract:"receive:setState",component:this,args:{carrier:U(e),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:r.id,preReceiveWorldPos:a,preReceiveWorldQuat:c}),K.log({role:"target",contract:"receive:done",component:this,args:{carrier:U(e),slotId:r.id}})}async dispatch(t,e,n={}){const r=new rt({source:this,target:e,carrier:t,options:n,physical:async()=>{delete t[Y]}}),i=await r.execute();"rolled-back"!==i.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:i.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const n=this.findSlot(t);if(!n){const n=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!n||t.allowedTypes.includes(n))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:n}})();return K.log({role:"target",contract:"canAccept",component:this,args:{carrier:U(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}(i),s=[...t.capabilities??[]];n||s.push("Capacity","PlacementSurface"),r||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Xc((e=class extends(Fh(o)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:u?"".concat(u," ",c):c}),e.capabilities=Object.freeze(s),e.isFlowNode=!0,e))}function Dh(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,n({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),n({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),n({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});export{gt as BULGE_EPSILON,Eu as Capacity,It as CapacityEventTracker,Pt as CenteringQueueStrategy,y as CenteringSlotStrategy,du as DEFAULT_SEAT_MARGIN,d as FixedSlotStrategy,Ch as FlowEngine,Nh as FlowNode,Ft as GridStacking,Vc as HOLDER_ANCHOR,Fh as Holdable,Xc as ItemsDataBinding,ht as NavGraph,Ct as PatternStacking,zt as PolygonPathPolyline,ct as ReservationTable,Y as TRANSFER_SLOT_KEY,rt as Transfer,Nt as VolumeStacking,uu as addressOfSlotId,wh as allDestinations,Pu as anchorsConnect,Sh as applyPolicy,W as applySeatingRotation,Dt as applyStackLayout,Iu as arcSegmentTopology,jt as autoWireBackPressure,Du as buildFlowGraph,dt as buildNavGraph,xt as bulgeFromDrag,vt as bulgeHandlePosition,Wu as canReach,t as capability,f as chooseNearestPickupFrame,Hu as collectAdjacentSegments,_h as componentForNode,bt as computeArcParams,uh as computeFlowMap,Rt as computeStackPositions,wt as cornerHandlePosition,kt as cornerRadiusFromDrag,Fu as deliversInto,Ah as downstream,_t as effectiveCornerRadius,Ju as enumerateDataScenarios,l as filterByToolType,fh as findNearestWithCapability,p as fixedSlotStrategy,Et as flattenPolygonPath,vh as flowGraphFor,bh as flowGraphIssues,hh as flowReverseFor,Lt as footprint2D,H as frameClock,oh as ftId,ih as ftrace,i as getAllCapabilityMeta,r as getCapabilityMeta,B as globalSimClock,jh as graphFor,ou as gridCellOf,iu as gridSlotNo,mt as hasArc,Tt as hasCapacity,Ot as inferCapacity,Vu as inferDownstreamId,rh as inferFlowDirections,Dh as isFlowNode,lh as isGeometricHost,dh as isRoutingTarget,ku as judgeItemFit,Hc as layoutIssue,Nu as matchOutbounds,Eh as next,qu as nextHop,Uu as nextHops,Bu as nextHopsToAny,Gu as nextHopsToAnyDetailed,kh as nodeIdOf,eu as persistenceIssues,Rh as pickWeightedDestination,pt as planPathAStar,yt as planToReservations,Ru as pointInRotatedRect,At as polygonPathLength,s as quatFromYaw,Cu as rayAbsDistanceToRect,Lu as reachableByOutbound,Th as reachableDestinations,Oh as reachableDestinationsFrom,Ih as reachableDestinationsWeightedFrom,Yu as reachableSinks,et as receiptToJSON,Au as rectFaceAnchors,u as rectangularFootprintFrames,n as registerCapabilityMeta,ut as reservationTable,zh as resolveNextHop,au as resolveSlot,yu as rotatedFootprint,gu as seatInSlot,mu as seatTransform,xh as sinksForDestination,hu as slotAddresses,nu as slotCount,fu as slotFrame,cu as slotIdOf,ru as slotNumbers,wu as slotSpaceWarnings,bu as stackSeatTransforms,at as standardYieldPolicy,Ou as straightSegmentEndpoints,ju as straightSegmentMultiInbound,Tu as straightSegmentTopology,h as topApproachFrame,it as transferLog,K as transferTracer,Mt as uniformZ,Ph as validate,Xu as validateFlowGraph,tu as validateSlotLayout};
|
|
6
|
+
*/const g=2e3,m={};function b(...t){t=function(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function v(...t){const e=t.join(" ");e in m||(m[e]=!0,b(...t))}function x(t,e,n){return Math.max(e,Math.min(n,t))}class _{static{_.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class w{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,i,o,s){let a=n[r+0],c=n[r+1],u=n[r+2],h=n[r+3],l=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(h!==p||a!==l||c!==f||u!==d){let t=a*l+c*f+u*d+h*p;t<0&&(l=-l,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const n=Math.acos(t),r=Math.sin(n);e=Math.sin(e*n)/r,a=a*e+l*(s=Math.sin(s*n)/r),c=c*e+f*s,u=u*e+d*s,h=h*e+p*s}else{a=a*e+l*s,c=c*e+f*s,u=u*e+d*s,h=h*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+h*h);a*=t,c*=t,u*=t,h*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,i,o){const s=n[r],a=n[r+1],c=n[r+2],u=n[r+3],h=i[o],l=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*h+a*f-c*l,t[e+1]=a*d+u*l+c*h-s*f,t[e+2]=c*d+u*f+s*l-a*h,t[e+3]=u*d-s*h-a*l-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(n/2),u=s(r/2),h=s(i/2),l=a(n/2),f=a(r/2),d=a(i/2);switch(o){case"XYZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"YXZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"ZXY":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"ZYX":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"YZX":this._x=l*u*h+c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h-l*f*d;break;case"XZY":this._x=l*u*h-c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h+l*f*d;break;default:b("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],h=e[10],l=n+s+h;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-r)*t}else if(n>s&&n>h){const t=2*Math.sqrt(1+n-s-h);this._w=(u-a)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+c)/t}else if(s>h){const t=2*Math.sqrt(1+s-n-h);this._w=(i-c)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+h-n-s);this._w=(o-r)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(x(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=n*u+o*s+r*c-i*a,this._y=r*u+o*a+i*s-n*c,this._z=i*u+o*c+n*a-r*s,this._w=o*u-n*s-r*a-i*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,r=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(n=-n,r=-r,i=-i,o=-o,s=-s);let a=1-e;if(s<.9995){const t=Math.acos(s),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{static{k.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(S.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(S.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*r-s*n),u=2*(s*e-i*r),h=2*(i*n-o*e);return this.x=e+a*c+o*h-s*u,this.y=n+a*u+s*c-i*h,this.z=r+a*h+i*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=r*a-i*s,this.y=i*o-n*a,this.z=n*s-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const M=new k,S=new w;class z{static{z.prototype.isMatrix3=!0}constructor(t,e,n,r,i,o,s,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c)}set(t,e,n,r,i,o,s,a,c){const u=this.elements;return u[0]=t,u[1]=r,u[2]=s,u[3]=e,u[4]=i,u[5]=a,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[3],a=n[6],c=n[1],u=n[4],h=n[7],l=n[2],f=n[5],d=n[8],p=r[0],y=r[3],g=r[6],m=r[1],b=r[4],v=r[7],x=r[2],_=r[5],w=r[8];return i[0]=o*p+s*m+a*x,i[3]=o*y+s*b+a*_,i[6]=o*g+s*v+a*w,i[1]=c*p+u*m+h*x,i[4]=c*y+u*b+h*_,i[7]=c*g+u*v+h*w,i[2]=l*p+f*m+d*x,i[5]=l*y+f*b+d*_,i[8]=l*g+f*v+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8];return e*o*u-e*s*c-n*i*u+n*s*a+r*i*c-r*o*a}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=u*o-s*c,l=s*a-u*i,f=c*i-o*a,d=e*h+n*l+r*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return t[0]=h*p,t[1]=(r*c-u*n)*p,t[2]=(s*n-r*o)*p,t[3]=l*p,t[4]=(u*e-r*a)*p,t[5]=(r*i-s*e)*p,t[6]=f*p,t[7]=(n*a-c*e)*p,t[8]=(o*e-n*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,s){const a=Math.cos(i),c=Math.sin(i);return this.set(n*a,n*c,-n*(a*o+c*s)+o+t,-r*c,r*a,-r*(-c*o+a*s)+s+e,0,0,1),this}scale(t,e){return v("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(E.makeScale(t,e)),this}rotate(t){return v("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(E.makeRotation(-t)),this}translate(t,e){return v("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(E.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const E=new z;class A{static{A.prototype.isVector4=!0}constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,s=.1,a=t.elements,c=a[0],u=a[4],h=a[8],l=a[1],f=a[5],d=a[9],p=a[2],y=a[6],g=a[10];if(Math.abs(u-l)<o&&Math.abs(h-p)<o&&Math.abs(d-y)<o){if(Math.abs(u+l)<s&&Math.abs(h+p)<s&&Math.abs(d+y)<s&&Math.abs(c+f+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(f+1)/2,m=(g+1)/2,b=(u+l)/4,v=(h+p)/4,x=(d+y)/4;return t>a&&t>m?t<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(t),r=b/n,i=v/n):a>m?a<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(a),n=b/r,i=x/r):m<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(m),n=v/i,r=x/i),this.set(n,r,i,e),this}let m=Math.sqrt((y-d)*(y-d)+(h-p)*(h-p)+(l-u)*(l-u));return Math.abs(m)<.001&&(m=1),this.x=(y-d)/m,this.y=(h-p)/m,this.z=(l-u)/m,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this.w=x(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this.w=x(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class O{static{O.prototype.isMatrix4=!0}constructor(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y)}set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=s,g[13]=a,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=f,g[7]=d,g[11]=p,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new O).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,n=t.elements,r=1/T.setFromMatrixColumn(t,0).length(),i=1/T.setFromMatrixColumn(t,1).length(),o=1/T.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),s=Math.sin(n),a=Math.cos(r),c=Math.sin(r),u=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=-a*h,e[8]=c,e[1]=n+r*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=r+n*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t+i*s,e[4]=r*s-n,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-s,e[2]=n*s-r,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t-i*s,e[4]=-o*h,e[8]=r+n*s,e[1]=n+r*s,e[5]=o*u,e[9]=i-t*s,e[2]=-o*c,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=r*c-n,e[8]=t*c+i,e[1]=a*h,e[5]=i*c+t,e[9]=n*c-r,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=i-t*h,e[8]=r*h+n,e[1]=h,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=n*h+r,e[10]=t-i*h}else if("XZY"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=-h,e[8]=c*u,e[1]=t*h+i,e[5]=o*u,e[9]=n*h-r,e[2]=r*h-n,e[6]=s*u,e[10]=i*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(j,t,P)}lookAt(t,e,n){const r=this.elements;return F.subVectors(t,e),0===F.lengthSq()&&(F.z=1),F.normalize(),R.crossVectors(n,F),0===R.lengthSq()&&(1===Math.abs(n.z)?F.x+=1e-4:F.z+=1e-4,F.normalize(),R.crossVectors(n,F)),R.normalize(),C.crossVectors(F,R),r[0]=R.x,r[4]=C.x,r[8]=F.x,r[1]=R.y,r[5]=C.y,r[9]=F.y,r[2]=R.z,r[6]=C.z,r[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[4],a=n[8],c=n[12],u=n[1],h=n[5],l=n[9],f=n[13],d=n[2],p=n[6],y=n[10],g=n[14],m=n[3],b=n[7],v=n[11],x=n[15],_=r[0],w=r[4],k=r[8],M=r[12],S=r[1],z=r[5],E=r[9],A=r[13],O=r[2],T=r[6],I=r[10],j=r[14],P=r[3],R=r[7],C=r[11],F=r[15];return i[0]=o*_+s*S+a*O+c*P,i[4]=o*w+s*z+a*T+c*R,i[8]=o*k+s*E+a*I+c*C,i[12]=o*M+s*A+a*j+c*F,i[1]=u*_+h*S+l*O+f*P,i[5]=u*w+h*z+l*T+f*R,i[9]=u*k+h*E+l*I+f*C,i[13]=u*M+h*A+l*j+f*F,i[2]=d*_+p*S+y*O+g*P,i[6]=d*w+p*z+y*T+g*R,i[10]=d*k+p*E+y*I+g*C,i[14]=d*M+p*A+y*j+g*F,i[3]=m*_+b*S+v*O+x*P,i[7]=m*w+b*z+v*T+x*R,i[11]=m*k+b*E+v*I+x*C,i[15]=m*M+b*A+v*j+x*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],h=t[6],l=t[10],f=t[14],d=t[3],p=t[7],y=t[11],g=t[15],m=a*f-c*l,b=s*f-c*h,v=s*l-a*h,x=o*f-c*u,_=o*l-a*u,w=o*h-s*u;return e*(p*m-y*b+g*v)-n*(d*m-y*x+g*_)+r*(d*b-p*x+g*w)-i*(d*v-p*_+y*w)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[1],o=t[5],s=t[9],a=t[2],c=t[6],u=t[10];return e*(o*u-s*c)-n*(i*u-s*a)+r*(i*c-o*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=t[9],l=t[10],f=t[11],d=t[12],p=t[13],y=t[14],g=t[15],m=e*s-n*o,b=e*a-r*o,v=e*c-i*o,x=n*a-r*s,_=n*c-i*s,w=r*c-i*a,k=u*p-h*d,M=u*y-l*d,S=u*g-f*d,z=h*y-l*p,E=h*g-f*p,A=l*g-f*y,O=m*A-b*E+v*z+x*S-_*M+w*k;if(0===O)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/O;return t[0]=(s*A-a*E+c*z)*T,t[1]=(r*E-n*A-i*z)*T,t[2]=(p*w-y*_+g*x)*T,t[3]=(l*_-h*w-f*x)*T,t[4]=(a*S-o*A-c*M)*T,t[5]=(e*A-r*S+i*M)*T,t[6]=(y*v-d*w-g*b)*T,t[7]=(u*w-l*v+f*b)*T,t[8]=(o*E-s*S+c*k)*T,t[9]=(n*S-e*E-i*k)*T,t[10]=(d*_-p*v+g*m)*T,t[11]=(h*v-u*_-f*m)*T,t[12]=(s*M-o*z-a*k)*T,t[13]=(e*z-n*M+r*k)*T,t[14]=(p*b-d*x-y*m)*T,t[15]=(u*x-h*b+l*m)*T,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+n,c*s-r*a,c*a+r*s,0,c*s+r*a,u*s+n,u*a-r*o,0,c*a-r*s,u*a+r*o,i*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,h=s+s,l=i*c,f=i*u,d=i*h,p=o*u,y=o*h,g=s*h,m=a*c,b=a*u,v=a*h,x=n.x,_=n.y,w=n.z;return r[0]=(1-(p+g))*x,r[1]=(f+v)*x,r[2]=(d-b)*x,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(l+g))*_,r[6]=(y+m)*_,r[7]=0,r[8]=(d+b)*w,r[9]=(y-m)*w,r[10]=(1-(l+p))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;t.x=r[12],t.y=r[13],t.z=r[14];const i=this.determinantAffine();if(0===i)return n.set(1,1,1),e.identity(),this;let o=T.set(r[0],r[1],r[2]).length();const s=T.set(r[4],r[5],r[6]).length(),a=T.set(r[8],r[9],r[10]).length();i<0&&(o=-o),I.copy(this);const c=1/o,u=1/s,h=1/a;return I.elements[0]*=c,I.elements[1]*=c,I.elements[2]*=c,I.elements[4]*=u,I.elements[5]*=u,I.elements[6]*=u,I.elements[8]*=h,I.elements[9]*=h,I.elements[10]*=h,e.setFromRotationMatrix(I),n.x=o,n.y=s,n.z=a,this}makePerspective(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),h=2*i/(n-r),l=(e+t)/(e-t),f=(n+r)/(n-r);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===g)d=-(o+i)/(o-i),p=-2*o*i/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-i),p=-o*i/(o-i)}return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),h=2/(n-r),l=-(e+t)/(e-t),f=-(n+r)/(n-r);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===g)d=-2/(o-i),p=-(o+i)/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);d=-1/(o-i),p=-i/(o-i)}return c[0]=u,c[4]=0,c[8]=0,c[12]=l,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const T=new k,I=new O,j=new k(0,0,0),P=new k(1,1,1),R=new k,C=new k,F=new k,N=new O,D=new w;class L{constructor(t=0,e=0,n=0,r=L.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],s=r[8],a=r[1],c=r[5],u=r[9],h=r[2],l=r[6],f=r[10];switch(e){case"XYZ":this._y=Math.asin(x(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(l,c),this._z=0);break;case"YXZ":this._x=Math.asin(-x(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(x(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-x(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(l,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(l,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:b("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return N.makeRotationFromQuaternion(t),this.setFromRotationMatrix(N,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}L.DEFAULT_ORDER="XYZ";class ${static{$.prototype.isMatrix2=!0}constructor(t,e,n,r){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,r){const i=this.elements;return i[0]=t,i[2]=e,i[1]=n,i[3]=r,this}}function U(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?b("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const W=new L;function q(t,e){W.setFromQuaternion(new w(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=W.x,t.rotation=-W.y,t.rotationY=W.z}const Y="_transferSlotId";const B=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=B);const G=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,r=this._getResidents?.()??null;let i=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(i=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const o={fps:i,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...r??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}};function H(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const X=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return B.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const n=e?.component,r=n?.app??n?.root?.app;if(r&&"boolean"==typeof r.isViewMode&&!r.isViewMode)return()=>{};const i={id:this._nextId++,handler:t,description:e?.description??`<anonymous#${this._nextId-1}>`,componentRef:null!=e?.component&&"undefined"!=typeof WeakRef?new WeakRef(e.component):void 0,targetsGetter:e?.getTargets,metadata:e?.metadata,registeredAt:this._realTime,tickCount:0,totalDurationMs:0,lastDt:0,lastDurationMs:0};return this._subs.add(i),this.isRunning||this.start(),()=>{this._ticking?(i._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(i),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,G.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const n=B.tick(e),r=B.now;if(this._ticking=!0,G.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(n,r)}finally{const r=performance.now()-e;t.tickCount++,t.totalDurationMs+=r,t.lastDt=n,t.lastDurationMs=r}}else for(const t of this._subs)t._removed||t.handler(n,r);if(this._ticking=!1,this._hasPendingRemoval){this._hasPendingRemoval=!1;for(const t of this._subs)t._removed&&this._subs.delete(t);0===this._subs.size&&this.stop()}}start(){if(null!==this._rafId)return;if("undefined"==typeof requestAnimationFrame)return;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),n=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(n),null!==this._rafId&&(this._rafId=requestAnimationFrame(t))};this._rafId=requestAnimationFrame(t)}stop(){null!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._lastWallTime=null}registerExternalAnimation(t,e,n){const r={id:this._externalNextId++,description:t,source:e,metadata:n,registeredAt:this._realTime};return this._externals.add(r),{update:t=>{r.metadata={...r.metadata??{},...t}},unregister:()=>{this._externals.delete(r)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let n;const r=e.componentRef?.deref();let i;if(r&&(n=H(r)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(H(t));n.length>0&&(i=n)}}catch{}t.push({id:e.id,description:e.description,componentInfo:n,targetInfos:i,metadata:e.metadata,registeredAt:e.registeredAt,tickCount:e.tickCount,totalDurationMs:Math.round(100*e.totalDurationMs)/100,avgDurationMs:e.tickCount>0?Math.round(e.totalDurationMs/e.tickCount*100)/100:0,lastDt:Math.round(100*e.lastDt)/100,lastDurationMs:Math.round(100*e.lastDurationMs)/100})}const e=[];for(const t of this._externals)e.push({id:t.id,description:t.description,source:t.source,metadata:t.metadata,registeredAt:t.registeredAt,liveDurationMs:Math.round(this._realTime-t.registeredAt)});return{realTime:Math.round(this._realTime),simTime:Math.round(B.now),isRunning:this.isRunning,speed:B.speed,paused:B.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let V=null;const Z=[],Q=new Set;function J(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const K={beginContext(t){V=t},endContext(){V=null},current:()=>V,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??J(t.component),componentType:t.componentType??(n=t.component,n?.state?.type??n?.type),atSimMs:B.now,args:t.args,result:t.result,error:t.error};var n;V?V.pushTrace(e):(Z.push(e),Z.length>500&&Z.shift(),Q.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...Z],onStandalone:t=>(Q.add(t),()=>{Q.delete(t)}),clearStandalone(){Z.length=0}};function tt(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const n=String(e);return n.length>0?n:void 0}function et(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},n=t.sourceId??tt(t.source),r=t.targetId??tt(t.target),i=t.carrierId??tt(t.carrier);return void 0!==n&&(e.sourceId=n),void 0!==r&&(e.targetId=r),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let nt=1;class rt{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+nt++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:B.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??B.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return it.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=B.now;const t=this.target.canAccept?.(this.carrier);if(t&&t.ok)this._slot=t.slot;else{if(t&&!t.ok&&"no-slots-defined"!==t.reason)return this._rejectReason=t.reason,this._rollback();if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier))return this._rejectReason="cannot-receive",this._rollback();this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source}),this._reservation)?(this._timeline.planEndAt=B.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",it.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=B.now;const t=this._buildReceipt();return it.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){K.beginContext(this),K.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{return await this._executeImpl()}finally{K.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}executeSync(){K.beginContext(this),K.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{K.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",it.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:tt(this.source),targetId:tt(this.target),carrierId:tt(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const it=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??tt(t.source),n=t.targetId??tt(t.target);if("committed"===t.phase){if(e&&n){const t=e+">"+n;this._flows.set(t,(this._flows.get(t)??0)+1)}n&&this._targetCount.set(n,(this._targetCount.get(n)??0)+1),void 0!==t.timeline.committedAt&&(this._committedDurationSum+=t.timeline.committedAt-t.timeline.initiatedAt,this._committedCount++)}else if("rolled-back"===t.phase&&t.rejectReason){this._byRejectReason.set(t.rejectReason,(this._byRejectReason.get(t.rejectReason)??0)+1);try{t.source?._bumpRejected?.(t.carrier,t.rejectReason)}catch{}}this._listeners.forEach(e=>e(t))}flows(){return this._flows}targetCounts(){return this._targetCount}stats(){const t={};this._byPhase.forEach((e,n)=>{t[n]=e});const e=t["rolled-back"]??0;return{total:this._total,byPhase:t,committed:t.committed??0,rolledBack:e,rejectionRate:this._total>0?e/this._total:0,avgTransferDurationMs:this._committedCount>0?this._committedDurationSum/this._committedCount:0}}rejectReasonCounts(){return this._byRejectReason}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._flows.clear(),this._targetCount.clear(),this._byPhase.clear(),this._byRejectReason.clear(),this._total=0,this._committedDurationSum=0,this._committedCount=0}entries(){return[]}forCarrier(t){return[]}forCarrierId(t){return[]}forSourceId(t){return[]}forTargetId(t){return[]}forPhase(t){return[]}inTimeRange(t,e,n){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=it);let ot=1;function st(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const at={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class ct{constructor(t=at){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+ot++},n=(this._byResource.get(e.resource)??[]).filter(t=>st(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const r=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(r.every(t=>"b-yields"===t.decision)){const r=n.slice();for(const t of r)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:r}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:r}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>st(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let r=this._byReserver.get(t.reserverId);r||(r=[],this._byReserver.set(t.reserverId,r)),r.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const r=this._byReserver.get(t.reserverId);if(r){const e=r.findIndex(e=>e.id===t.id);e>=0&&r.splice(e,1),0===r.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const ut=new ct;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=ut);class ht{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const r of this.nodes.values()){const i=lt(r.position,t);i<n&&(n=i,e=r)}return e}}function lt(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}function ft(t,e){return Math.sqrt(lt(t,e))}function dt(t,e,n={}){const r=new ht,i=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,o=`${e.id}:end`;r.addNode({id:n,position:t[0],type:"lane-start"}),r.addNode({id:o,position:t[t.length-1],type:"lane-end"}),r.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=ft(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;r.addEdge({fromNode:n,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&r.addEdge({fromNode:o,toNode:n,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const i=r.laneEndpoints.get(n);if(!i)continue;const o=r.nodes.get(i.startNodeId).position,s=r.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===n)continue;const t=r.laneEndpoints.get(e);if(!t)continue;const i=r.nodes.get(t.startNodeId).position,h=r.nodes.get(t.endNodeId).position;a+=Math.min(lt(o,i),lt(o,h)),c+=Math.min(lt(s,i),lt(s,h)),u++}if(0===u)continue;const h=a<c?i.startNodeId:i.endNodeId;e.push({laneId:n,nodeId:h,pos:r.nodes.get(h).position})}for(let n=0;n<e.length;n++)for(let i=0;i<e.length;i++){if(n===i)continue;const o=e[n],s=e[i],a=ft(o.pos,s.pos);r.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return r}function pt(t,e,n,r={}){const i=t.nodes.get(e),o=t.nodes.get(n);if(!i||!o)return null;const s=r.speed?.max??100,a=e=>{const n=t.nodes.get(e);var r,i;return(r=n.position,i=o.position,Math.sqrt(function(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}(r,i)))/s*1e3},c=new Map,u=new Set,h=new Set,l={nodeId:e,gScore:0,fScore:a(e)};c.set(e,l),u.add(e);const f=r.startSimMs??0,d=r.deadlineSimMs;for(;u.size>0;){let e=null,r=null;for(const t of u){const n=c.get(t);(!r||n.fScore<r.fScore||n.fScore===r.fScore&&t<e)&&(r=n,e=t)}if(!r||!e)return null;if(e===n){const t=[];let e=r,n=0;for(;e&&e.cameFromEdge;){const r=e.cameFromEdge,i=f+(e.gScore-r.durationMs);t.unshift({resource:r.resource,timeWindow:{startSimMs:i,endSimMs:i+r.durationMs},fromPos:r.fromPos,toPos:r.toPos}),n+=r.distance,e=c.get(r.fromNodeId)}const i=r.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:n}}u.delete(e),h.add(e);for(const n of t.edgesFrom(e)){if(h.has(n.toNode))continue;const e=r.gScore+n.durationMs,i=c.get(n.toNode);if(!i||e<i.gScore){const r=t.nodes.get(n.fromNode),i=t.nodes.get(n.toNode),o={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:r.position,toPos:i.position}};c.set(n.toNode,o),u.add(n.toNode)}}}return null}function yt(t,e,n=0,r){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:r}))}const gt=.5;function mt(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function bt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o||!Number.isFinite(n)||Math.abs(n)<1e-9)return null;const s=Math.abs(n),a=(o*o+4*s*s)/(8*s),c=n>0?1:-1,u=a-s,h=(t.x+e.x)/2-c*(i/o)*u,l=(t.y+e.y)/2-c*-(r/o)*u;return{cx:h,cy:l,radius:a,startAngle:Math.atan2(t.y-l,t.x-h),endAngle:Math.atan2(e.y-l,e.x-h),clockwise:n<0}}function vt(t,e,n=0,r=16){const i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o);if(0===s)return null;const a=o/s,c=-(i/s),u=Number.isFinite(n)?n:0,h=Math.abs(u)>=1e-6?u:r;return{x:(t.x+e.x)/2+a*h,y:(t.y+e.y)/2+c*h,perpX:a,perpY:c}}function xt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o)return 0;const s=i/o,a=-(r/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let h=(n.x-c)*s+(n.y-u)*a;if(Math.abs(h)<.5)return 0;return h>o&&(h=o),h<-o&&(h=-o),h}function _t(t,e){const n=t.radius,r=Number.isFinite(e)?e:0;return null!=n&&Number.isFinite(n)?Math.max(0,n):Math.max(0,r)}function wt(t,e,n,r,i=16){const o=t.x-e.x,s=t.y-e.y,a=Math.sqrt(o*o+s*s);if(0===a)return null;const c=n.x-e.x,u=n.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h)return null;const l=o/a+c/h,f=s/a+u/h,d=Math.sqrt(l*l+f*f);if(d<1e-9)return null;const p=l/d,y=f/d,g=Math.max(r,i);return{x:e.x+p*g,y:e.y+y*g,bisectorX:p,bisectorY:y}}function kt(t,e,n,r){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=n.x-e.x,c=n.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const h=i/s+a/u,l=o/s+c/u,f=Math.sqrt(h*h+l*l);if(f<1e-9)return 0;const d=h/f,p=l/f,y=(r.x-e.x)*d+(r.y-e.y)*p,g=Math.min(s,u)/2;return Math.max(0,Math.min(y,g))}function Mt(t){if(0===t.length)return 0;let e;for(const n of t){const t=n.z??0;if(!Number.isFinite(t))return null;if(void 0===e)e=t;else if(Math.abs(t-e)>1e-9)return null}return e??0}const St={closed:!0,round:0,divisions:24};class zt{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const r=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(r*r+i*i))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const r=this.cumulative;let i=0,o=r.length-2;for(;i<o;){const t=i+o>>1;r[t+1]<=n?i=t+1:o=t}const s=r[i+1]-r[i],a=s>0?(n-r[i])/s:0,c=this.points[i],u=this.points[i+1],h=u.x-c.x,l=u.y-c.y;return{x:c.x+h*a,y:c.y+l*a,theta:0===h&&0===l?0:Math.atan2(l,h)}}}function Et(t,e={}){const n={...St,...e},r=t.length;if(0===r)return new zt([],n.closed);if(1===r)return new zt([{x:t[0].x,y:t[0].y}],n.closed);const i=[],o=(t,e)=>{if(i.length>0){const n=i[i.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}i.push({x:t,y:e})},s=(n.closed,r);for(let e=0;e<s;e++){const i=0===e?n.closed?r-1:-1:e-1,s=e===r-1?n.closed?0:-1:e+1,a=i>=0?t[i]:null,c=t[e],u=s>=0?t[s]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&u?_t(c,n.round):0;let l,f,d,p;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(h,t/2);l=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else l=c.x,f=c.y;if(u){const t=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2),e=0!==t?Math.atan2(u.x-c.x,u.y-c.y):0,n=Math.min(h,t/2);d=Math.sin(e)*n+c.x,p=Math.cos(e)*n+c.y}else d=c.x,p=c.y;if(o(l,f),h>0&&a&&u)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,r=1-e;o(r*r*l+2*r*e*c.x+e*e*d,r*r*f+2*r*e*c.y+e*e*p)}else l===d&&f===p||o(d,p);if(u&&mt(c)){const t=_t(u,n.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),r=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=bt({x:d,y:p},{x:Math.sin(r)*i+u.x,y:Math.cos(r)*i+u.y},c.bulge);if(s){let t=s.endAngle-s.startAngle;if(s.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const r=e/n.divisions,i=s.startAngle+t*r;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(n.closed&&i.length>0){const t=i[0],e=i[i.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&i.push({x:t.x,y:t.y})}return new zt(i,n.closed)}function At(t,e){return Et(t,e).length}function Ot(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function Tt(t){if(Ot(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class It{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function jt(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),r=e.onAvailable(()=>t.resumeEmit());return Tt(e).isFull&&t.pauseEmit(),()=>{n?.(),r?.()}}class Pt{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,r){const i=e.maxCount??1/0;if(t<0||t>=i)return null;const o=this.owner?.state?.width??0,s=this.owner?.state?.height??0,a=r?.state?.width??0,c=r?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(s-c)/2),z:0}:{x:Math.max(0,(o-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Rt(t,e,n,r,i,o,s){const a=n.w,c=n.h,u=r.w,h=r.h,l=r.d,f=[],d=u+i,p=h+i,y=Math.max(1,Math.floor((a+i)/d)),g=Math.max(1,Math.floor((c+i)/p)),m=y*g,b=o&&o>0?Math.floor(o):4;if("row"===t||"column"===t){const n=s?.advanceAlongX??!1,r=s?.reverse??!1,i=n?y:g,o=n?g:y,u=(t,e,r)=>((t,e,n)=>f.push({x:-a/2+(t+.5)*d,y:n*l+l/2,z:-c/2+(e+.5)*p}))(n?t:e,n?e:t,r);let h=0;for(let n=0;n<i&&h<e;n++){const s=r?i-1-n:n;if("column"===t)for(let t=0;t<o&&h<e;t++)for(let n=0;n<b&&h<e;n++)u(s,t,n),h++;else for(let t=0;t<b&&h<e;t++)for(let n=0;n<o&&h<e;n++)u(s,n,t),h++}return f}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,y-n),r=Math.max(1,g-n),i=e*r,s=Math.min(t,i);for(let t=0;t<s;t++){const i=t%e,o=Math.floor(t/e),s=-a/2+(i+(y-e)/2+.5)*d,u=-c/2+(o+(g-r)/2+.5)*p;f.push({x:s,y:n*l+l/2,z:u})}if(t-=s,n++,1===e&&1===r){for(let e=0;e<t;e++)f.push({x:0,y:(n+e)*l+l/2,z:0});break}if(o&&n>=o)break}return f}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/m),r=n%m,i=r%y,s=Math.floor(r/y),g=(t(2*n)-.5)*u*.2,b=(t(2*n+1)-.5)*h*.2,v=-a/2+(i+.5)*d+g,x=-c/2+(s+.5)*p+b;if(f.push({x:v,y:e*l+l/2,z:x}),o&&e>=o-1&&r===m-1)break}return f}for(let n=0;n<e;n++){const e=Math.floor(n/m);if(o&&e>=o)break;const r=n%m,i=r%y,s=Math.floor(r/y);let u=-a/2+(i+.5)*d;const h=-c/2+(s+.5)*p;"staggered"===t&&e%2==1&&(u+=d/2),f.push({x:u,y:e*l+l/2,z:h})}return f}class Ct{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,r={}){const i=r.gap??this.defaults.gap??0,o=r.heightLimit??this.defaults.heightLimit,s=r.fill??this.defaults.fill;return Rt(this.pattern,t,e,n,i,o,s).map(t=>({position:t}))}}class Ft{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,r={}){const i=Math.max(1,this.cols),o=Math.max(1,this.rows),s=i*o,a=r.gap??this.defaults.gap??0,c=n.w+a,u=n.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/s),r=e%s,a=r%i,l=Math.floor(r/i);h.push({position:{x:(a-(i-1)/2)*c,z:(l-(o-1)/2)*u,y:t*n.d+n.d/2}})}return h}}class Nt{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,r=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-r)/(e.h+r))),pitchX:e.w+n,pitchZ:e.h+r}}capacity(t,e,n){const{cols:r,rows:i}=this.grid(t,e);return r*i*Math.max(1,Math.floor(n))}layout(t,e,n,r={}){const{cols:i,rows:o,pitchX:s,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,u=null!=r.heightLimit?Math.max(1,Math.floor(r.heightLimit)):1/0,h=Number.isFinite(u),l=this.sliceFirst&&h,f=i*o,d=i*(h?u:1),p=i*o*(h?u:t),y=Math.min(t,p),g=[];for(let t=0;t<y;t++){let e,r,u;if(l){const n=Math.floor(t/d),o=t%d;e=o%i,u=Math.floor(o/i),r=n}else{u=Math.floor(t/f);const n=t%f;e=n%i,r=Math.floor(n/i)}this.fillFromFar&&(r=o-1-r),g.push({position:{x:(e-(i-1)/2)*s,z:(r-(o-1)/2)*a,y:u*c+n.d/2}})}return g}}function Dt(t,e,n,r=0){for(let i=0;i<e.length;i++){const o=e[i],s=n[i];o&&s&&(o.parent!==t&&t.attach(o),o.position.set(s.position.x,r+s.position.y,s.position.z),s.rotation?o.quaternion.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w):o.quaternion.identity())}}function Lt(t,e,n,r=.12){const i=e.left+e.width/2,o=e.top+e.height/2,s=Math.min(n.w,n.h)*r,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let r=a.get(t);r||(r={x:i+e.position.x-n.w/2+s,y:o+e.position.z-n.h/2+s,w:n.w-2*s,h:n.h-2*s,count:0},a.set(t,r)),r.count++}return[...a.values()]}function $t(t,e){return t===e||t!=t&&e!=e}function Ut(t,e){for(var n=t.length;n--;)if($t(t[n][0],e))return n;return-1}var Wt=Array.prototype.splice;function qt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}qt.prototype.clear=function(){this.__data__=[],this.size=0},qt.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():Wt.call(e,n,1),--this.size,!0)},qt.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},qt.prototype.has=function(t){return Ut(this.__data__,t)>-1},qt.prototype.set=function(t,e){var n=this.__data__,r=Ut(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var Yt="object"==typeof global&&global&&global.Object===Object&&global,Bt="object"==typeof self&&self&&self.Object===Object&&self,Gt=Yt||Bt||Function("return this")(),Ht=Gt.Symbol,Xt=Object.prototype,Vt=Xt.hasOwnProperty,Zt=Xt.toString,Qt=Ht?Ht.toStringTag:void 0;var Jt=Object.prototype.toString;var Kt=Ht?Ht.toStringTag:void 0;function te(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Kt&&Kt in Object(t)?function(t){var e=Vt.call(t,Qt),n=t[Qt];try{t[Qt]=void 0;var r=!0}catch(t){}var i=Zt.call(t);return r&&(e?t[Qt]=n:delete t[Qt]),i}(t):function(t){return Jt.call(t)}(t)}function ee(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ne(t){if(!ee(t))return!1;var e=te(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var re,ie=Gt["__core-js_shared__"],oe=(re=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"";var se=Function.prototype.toString;function ae(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ce=/^\[object .+?Constructor\]$/,ue=Function.prototype,he=Object.prototype,le=ue.toString,fe=he.hasOwnProperty,de=RegExp("^"+le.call(fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pe(t){return!(!ee(t)||(e=t,oe&&oe in e))&&(ne(t)?de:ce).test(ae(t));var e}function ye(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return pe(n)?n:void 0}var ge=ye(Gt,"Map"),me=ye(Object,"create");var be=Object.prototype.hasOwnProperty;var ve=Object.prototype.hasOwnProperty;function xe(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _e(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function we(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}xe.prototype.clear=function(){this.__data__=me?me(null):{},this.size=0},xe.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},xe.prototype.get=function(t){var e=this.__data__;if(me){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return be.call(e,t)?e[t]:void 0},xe.prototype.has=function(t){var e=this.__data__;return me?void 0!==e[t]:ve.call(e,t)},xe.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=me&&void 0===e?"__lodash_hash_undefined__":e,this},we.prototype.clear=function(){this.size=0,this.__data__={hash:new xe,map:new(ge||qt),string:new xe}},we.prototype.delete=function(t){var e=_e(this,t).delete(t);return this.size-=e?1:0,e},we.prototype.get=function(t){return _e(this,t).get(t)},we.prototype.has=function(t){return _e(this,t).has(t)},we.prototype.set=function(t,e){var n=_e(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function ke(t){var e=this.__data__=new qt(t);this.size=e.size}ke.prototype.clear=function(){this.__data__=new qt,this.size=0},ke.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ke.prototype.get=function(t){return this.__data__.get(t)},ke.prototype.has=function(t){return this.__data__.has(t)},ke.prototype.set=function(t,e){var n=this.__data__;if(n instanceof qt){var r=n.__data__;if(!ge||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new we(r)}return n.set(t,e),this.size=n.size,this};function Me(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new we;++e<n;)this.add(t[e])}function Se(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}Me.prototype.add=Me.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Me.prototype.has=function(t){return this.__data__.has(t)};function ze(t,e,n,r,i,o){var s=1&n,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),h=o.get(e);if(u&&h)return u==e&&h==t;var l=-1,f=!0,d=2&n?new Me:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var p=t[l],y=e[l];if(r)var g=s?r(y,p,l,e,t,o):r(p,y,l,t,e,o);if(void 0!==g){if(g)continue;f=!1;break}if(d){if(!Se(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,n,r,o)))return d.push(e);var s})){f=!1;break}}else if(p!==y&&!i(p,y,n,r,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var Ee=Gt.Uint8Array;function Ae(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function Oe(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var Te=Ht?Ht.prototype:void 0,Ie=Te?Te.valueOf:void 0;function je(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var Pe=Array.isArray;function Re(){return[]}var Ce=Object.prototype.propertyIsEnumerable,Fe=Object.getOwnPropertySymbols,Ne=Fe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}(Fe(t),function(e){return Ce.call(t,e)}))}:Re;function De(t){return null!=t&&"object"==typeof t}function Le(t){return De(t)&&"[object Arguments]"==te(t)}var $e=Object.prototype,Ue=$e.hasOwnProperty,We=$e.propertyIsEnumerable,qe=Le(function(){return arguments}())?Le:function(t){return De(t)&&Ue.call(t,"callee")&&!We.call(t,"callee")};var Ye="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Ye&&"object"==typeof module&&module&&!module.nodeType&&module,Ge=Be&&Be.exports===Ye?Gt.Buffer:void 0,He=(Ge?Ge.isBuffer:void 0)||function(){return!1},Xe=/^(?:0|[1-9]\d*)$/;function Ve(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Xe.test(t))&&t>-1&&t%1==0&&t<e}function Ze(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Qe={};function Je(t){return function(e){return t(e)}}Qe["[object Float32Array]"]=Qe["[object Float64Array]"]=Qe["[object Int8Array]"]=Qe["[object Int16Array]"]=Qe["[object Int32Array]"]=Qe["[object Uint8Array]"]=Qe["[object Uint8ClampedArray]"]=Qe["[object Uint16Array]"]=Qe["[object Uint32Array]"]=!0,Qe["[object Arguments]"]=Qe["[object Array]"]=Qe["[object ArrayBuffer]"]=Qe["[object Boolean]"]=Qe["[object DataView]"]=Qe["[object Date]"]=Qe["[object Error]"]=Qe["[object Function]"]=Qe["[object Map]"]=Qe["[object Number]"]=Qe["[object Object]"]=Qe["[object RegExp]"]=Qe["[object Set]"]=Qe["[object String]"]=Qe["[object WeakMap]"]=!1;var Ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,tn=Ke&&"object"==typeof module&&module&&!module.nodeType&&module,en=tn&&tn.exports===Ke&&Yt.process,nn=function(){try{var t=tn&&tn.require&&tn.require("util").types;return t||en&&en.binding&&en.binding("util")}catch(t){}}(),rn=nn&&nn.isTypedArray,on=rn?Je(rn):function(t){return De(t)&&Ze(t.length)&&!!Qe[te(t)]},sn=Object.prototype.hasOwnProperty;function an(t,e){var n=Pe(t),r=!n&&qe(t),i=!n&&!r&&He(t),o=!n&&!r&&!i&&on(t),s=n||r||i||o,a=s?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=a.length;for(var u in t)!e&&!sn.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ve(u,c))||a.push(u);return a}var cn=Object.prototype;function un(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||cn)}function hn(t,e){return function(n){return t(e(n))}}var ln=hn(Object.keys,Object),fn=Object.prototype.hasOwnProperty;function dn(t){if(!un(t))return ln(t);var e=[];for(var n in Object(t))fn.call(t,n)&&"constructor"!=n&&e.push(n);return e}function pn(t){return null!=t&&Ze(t.length)&&!ne(t)}function yn(t){return pn(t)?an(t):dn(t)}function gn(t){return function(t,e,n){var r=e(t);return Pe(t)?r:je(r,n(t))}(t,yn,Ne)}var mn=Object.prototype.hasOwnProperty;var bn=ye(Gt,"DataView"),vn=ye(Gt,"Promise"),xn=ye(Gt,"Set"),_n=ye(Gt,"WeakMap"),wn="[object Map]",kn="[object Promise]",Mn="[object Set]",Sn="[object WeakMap]",zn="[object DataView]",En=ae(bn),An=ae(ge),On=ae(vn),Tn=ae(xn),In=ae(_n),jn=te;(bn&&jn(new bn(new ArrayBuffer(1)))!=zn||ge&&jn(new ge)!=wn||vn&&jn(vn.resolve())!=kn||xn&&jn(new xn)!=Mn||_n&&jn(new _n)!=Sn)&&(jn=function(t){var e=te(t),n="[object Object]"==e?t.constructor:void 0,r=n?ae(n):"";if(r)switch(r){case En:return zn;case An:return wn;case On:return kn;case Tn:return Mn;case In:return Sn}return e});var Pn="[object Arguments]",Rn="[object Array]",Cn="[object Object]",Fn=Object.prototype.hasOwnProperty;function Nn(t,e,n,r,i,o){var s=Pe(t),a=Pe(e),c=s?Rn:jn(t),u=a?Rn:jn(e),h=(c=c==Pn?Cn:c)==Cn,l=(u=u==Pn?Cn:u)==Cn,f=c==u;if(f&&He(t)){if(!He(e))return!1;s=!0,h=!1}if(f&&!h)return o||(o=new ke),s||on(t)?ze(t,e,n,r,i,o):function(t,e,n,r,i,o,s){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ee(t),new Ee(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return $t(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ae;case"[object Set]":var c=1&r;if(a||(a=Oe),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var h=ze(a(t),a(e),r,i,o,s);return s.delete(t),h;case"[object Symbol]":if(Ie)return Ie.call(t)==Ie.call(e)}return!1}(t,e,c,n,r,i,o);if(!(1&n)){var d=h&&Fn.call(t,"__wrapped__"),p=l&&Fn.call(e,"__wrapped__");if(d||p){var y=d?t.value():t,g=p?e.value():e;return o||(o=new ke),i(y,g,n,r,o)}}return!!f&&(o||(o=new ke),function(t,e,n,r,i,o){var s=1&n,a=gn(t),c=a.length;if(c!=gn(e).length&&!s)return!1;for(var u=c;u--;){var h=a[u];if(!(s?h in e:mn.call(e,h)))return!1}var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var y=t[h=a[u]],g=e[h];if(r)var m=s?r(g,y,h,e,t,o):r(y,g,h,t,e,o);if(!(void 0===m?y===g||i(y,g,n,r,o):m)){d=!1;break}p||(p="constructor"==h)}if(d&&!p){var b=t.constructor,v=e.constructor;b==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof v&&v instanceof v||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,n,r,i,o))}function Dn(t,e,n,r,i){return t===e||(null==t||null==e||!De(t)&&!De(e)?t!=t&&e!=e:Nn(t,e,n,r,Dn,i))}function Ln(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}var $n=function(){try{var t=ye(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Un(t,e,n){"__proto__"==e&&$n?$n(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Wn=Object.prototype.hasOwnProperty;function qn(t,e,n){var r=t[e];Wn.call(t,e)&&$t(r,n)&&(void 0!==n||e in t)||Un(t,e,n)}function Yn(t,e,n,r){var i=!n;n||(n={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=r?r(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),i?Un(n,a,c):qn(n,a,c)}return n}function Bn(t){return t}function Gn(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var Hn=Math.max;function Xn(t){return function(){return t}}var Vn=$n?function(t,e){return $n(t,"toString",{configurable:!0,enumerable:!1,value:Xn(e),writable:!0})}:Bn,Zn=Date.now;var Qn,Jn,Kn,tr=(Qn=Vn,Jn=0,Kn=0,function(){var t=Zn(),e=16-(t-Kn);if(Kn=t,e>0){if(++Jn>=800)return arguments[0]}else Jn=0;return Qn.apply(void 0,arguments)});function er(t,e){return tr(function(t,e,n){return e=Hn(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Hn(r.length-e,0),s=Array(o);++i<o;)s[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=n(s),Gn(t,this,a)}}(t,e,Bn),t+"")}function nr(t,e,n){if(!ee(n))return!1;var r=typeof e;return!!("number"==r?pn(n)&&Ve(e,n.length):"string"==r&&e in n)&&$t(n[e],t)}var rr,ir=(rr=function(t,e,n,r){Yn(e,yn(e),t,r)},er(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=rr.length>3&&"function"==typeof i?(r--,i):void 0,o&&nr(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var s=e[n];s&&rr(t,s,n,i)}return t})),or=hn(Object.getPrototypeOf,Object),sr=Function.prototype,ar=Object.prototype,cr=sr.toString,ur=ar.hasOwnProperty,hr=cr.call(Object);function lr(t){if(!De(t))return!1;var e=te(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!De(t)||"[object Object]"!=te(t))return!1;var e=or(t);if(null===e)return!0;var n=ur.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&cr.call(n)==hr}(t)}var fr=er(function(t,e){try{return Gn(t,void 0,e)}catch(t){return lr(t)?t:new Error(t)}});function dr(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var pr=Object.prototype,yr=pr.hasOwnProperty;function gr(t,e,n,r){return void 0===t||$t(t,pr[n])&&!yr.call(r,n)?e:t}var mr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function br(t){return"\\"+mr[t]}var vr=/<%=([\s\S]+?)%>/g;var xr,_r=(xr={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==xr?void 0:xr[t]});function wr(t){return"symbol"==typeof t||De(t)&&"[object Symbol]"==te(t)}var kr=Ht?Ht.prototype:void 0,Mr=kr?kr.toString:void 0;function Sr(t){if("string"==typeof t)return t;if(Pe(t))return dr(t,Sr)+"";if(wr(t))return Mr?Mr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function zr(t){return null==t?"":Sr(t)}var Er=/[&<>"']/g,Ar=RegExp(Er.source);var Or={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vr,variable:"",imports:{_:{escape:function(t){return(t=zr(t))&&Ar.test(t)?t.replace(Er,_r):t}}}},Tr=/\b__p \+= '';/g,Ir=/\b(__p \+=) '' \+/g,jr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pr=/[()=,{}\[\]\/\s]/,Rr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Cr=/($^)/,Fr=/['\n\r\u2028\u2029\\]/g,Nr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Lr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=un(t),n=[];for(var r in t)("constructor"!=r||!e&&Dr.call(t,r))&&n.push(r);return n}function $r(t,e){return t&&Yn(e,function(t){return pn(t)?an(t,!0):Lr(t)}(e),t)}var Ur="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wr=Ur&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Wr&&Wr.exports===Ur?Gt.Buffer:void 0,Yr=qr?qr.allocUnsafe:void 0;var Br=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)je(e,Ne(t)),t=or(t);return e}:Re;var Gr=Object.prototype.hasOwnProperty;var Hr=/\w*$/;var Xr=Ht?Ht.prototype:void 0,Vr=Xr?Xr.valueOf:void 0;function Zr(t,e,n){var r,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new Ee(a).set(new Ee(s)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return o=(i=t).buffer,new i.constructor(o,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Hr.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return r=t,Vr?Object(Vr.call(r)):{}}}var Qr=Object.create,Jr=function(){function t(){}return function(e){if(!ee(e))return{};if(Qr)return Qr(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var Kr=nn&&nn.isMap,ti=Kr?Je(Kr):function(t){return De(t)&&"[object Map]"==jn(t)};var ei=nn&&nn.isSet,ni=ei?Je(ei):function(t){return De(t)&&"[object Set]"==jn(t)},ri="[object Arguments]",ii="[object Function]",oi="[object Object]",si={};function ai(t,e,n,r,i,o){var s,a=2&e;if(void 0!==s)return s;if(!ee(t))return t;var c=Pe(t);if(c)return s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Gr.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,s);var u=jn(t),h=u==ii||"[object GeneratorFunction]"==u;if(He(t))return function(t){var e=t.length,n=Yr?Yr(e):new t.constructor(e);return t.copy(n),n}(t);if(u==oi||u==ri||h&&!i)return s=h?{}:function(t){return"function"!=typeof t.constructor||un(t)?{}:Jr(or(t))}(t),a?function(t,e){return Yn(t,Br(t),e)}(t,$r(s,t)):function(t,e){return Yn(t,Ne(t),e)}(t,function(t,e){return t&&Yn(e,yn(e),t)}(s,t));if(!si[u])return i?t:{};s=Zr(t,u),o||(o=new ke);var l=o.get(t);if(l)return l;o.set(t,s),ni(t)?t.forEach(function(r){s.add(ai(r,e,n,r,t,o))}):ti(t)&&t.forEach(function(r,i){s.set(i,ai(r,e,n,i,t,o))});var f=c?void 0:gn(t);return Ln(f||t,function(r,i){f&&(r=t[i=r]),qn(s,i,ai(r,e,n,i,t,o))}),s}si[ri]=si["[object Array]"]=si["[object ArrayBuffer]"]=si["[object DataView]"]=si["[object Boolean]"]=si["[object Date]"]=si["[object Float32Array]"]=si["[object Float64Array]"]=si["[object Int8Array]"]=si["[object Int16Array]"]=si["[object Int32Array]"]=si["[object Map]"]=si["[object Number]"]=si[oi]=si["[object RegExp]"]=si["[object Set]"]=si["[object String]"]=si["[object Symbol]"]=si["[object Uint8Array]"]=si["[object Uint8ClampedArray]"]=si["[object Uint16Array]"]=si["[object Uint32Array]"]=!0,si["[object Error]"]=si[ii]=si["[object WeakMap]"]=!1;function ci(t){return ai(t,4)}var ui=/\s/;var hi=/^\s+/;function li(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ui.test(t.charAt(e)););return e}(t)+1).replace(hi,""):t}var fi=/^[-+]0x[0-9a-f]+$/i,di=/^0b[01]+$/i,pi=/^0o[0-7]+$/i,yi=parseInt;var gi=1/0;function mi(t){return t?(t=function(t){if("number"==typeof t)return t;if(wr(t))return NaN;if(ee(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ee(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=li(t);var n=di.test(t);return n||pi.test(t)?yi(t.slice(2),n?2:8):fi.test(t)?NaN:+t}(t))===gi||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function bi(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=mi(t),n=e%1;return e==e?n?e-n:e:0}(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var vi=Object.prototype.hasOwnProperty;function xi(t){if(null==t)return!0;if(pn(t)&&(Pe(t)||"string"==typeof t||"function"==typeof t.splice||He(t)||on(t)||qe(t)))return!t.length;var e=jn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(un(t))return!dn(t).length;for(var n in t)if(vi.call(t,n))return!1;return!0}let _i=0;function wi(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function ki(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Mi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Si(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function zi(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Ei(t){if(this.__collection__)return this.__collection__[t]}function Ai(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Oi(t){return this.__collection__?this.__collection__.indexOf(t):-1}function Ti(){return this.__collection__?this.__collection__.length:0}function Ii(){this.__collection__=[]}function ji(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function Pi(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function Ri(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,r)}function Ci(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=n.concat(r,this.__collection__)}class Fi{constructor(){this.__collection__=[],this.insertAt=ki,this.append=Mi,this.prepend=Si,this.remove=zi,this.getAt=Ei,this.forEach=Ai,this.indexOf=Oi,this.size=Ti,this.clear=Ii,this.moveForward=ji,this.moveBackward=Pi,this.moveToHead=Ri,this.moveToTail=Ci}}const Ni=/\s+/;function Di(t,e,n,r){if(!n)return!0;if("object"==typeof n){for(const r in n){const i=n[r];t[e].apply(t,[r,i])}return!1}if(Ni.test(n)){return n.split(Ni).forEach(n=>t[e].apply(t,[n].concat(r))),!1}return!0}const Li=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],$i={withEvent(){Li.forEach(t=>this[t]=$i[t])},on(t,e,n){if(!Di(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!Di(this,"once",t,[e,n])||!e)return this;const r=this,i=function(t){return bi(2,t)}(function(){r.off(t,i,n),e.apply(r,arguments)});return i._callback=e,this.on(t,i,n),this},off(t,e,n){if(!this._listeners||!Di(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let r;r=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<r.length;t++){const i=r[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||n)for(let r=0;r<o.length;r++){const i=o[r];(e&&e!==i.callback&&e!==i.callback._callback||n&&n!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Fi),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&Wi(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],r=this._listeners["(all)"];return n&&Ui(n,arguments),r&&Ui(r,arguments),this},trigger(t){G.enabled&&G.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&Wi(this._delegators,e),!this._listeners)return this;if(!Di(this,"trigger",t,e))return this;const n=this._listeners[t],r=this._listeners["(all)"];return n&&Ui(n,e),r&&Ui(r,e),this},stopListening(t,e,n){let r=this._listeningTo;if(!r)return this;const i=!e&&!n;n||"object"!=typeof e||(n=this),t&&(r={},r[t._listenId]=t);for(const t in r){const o=r[t];o.off(e,n,this),(i||xi(o._events))&&delete this._listeningTo[t]}return this}};function Ui(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function Wi(t,e){t.forEach(t=>$i.delegate.apply(t,e))}const qi={listenTo:"on",listenToOnce:"once"};for(const t in qi){const e=qi[t];$i[t]=function(t,n,r){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++_i}`);return i[t._listenId]=t,r||"object"!=typeof n||(r=this),t[e](n,r,this),this}}const Yi=$i.on,Bi=$i.off,Gi=$i.once,Hi=$i.trigger,Xi=$i.delegate_on,Vi=$i.delegate_off;const Zi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Qi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ki(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var to,eo={exports:{}};var no=(to||(to=1,function(t){var e=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new T(r||[]);return i(s,"_invoke",{value:z(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f="suspendedStart",d="suspendedYield",p="executing",y="completed",g={};function m(){}function b(){}function v(){}var x={};u(x,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(I([])));w&&w!==n&&r.call(w,s)&&(x=w);var k=v.prototype=m.prototype=Object.create(x);function M(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function n(i,o,s,a){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,s,a)},function(t){n("throw",t,s,a)}):e.resolve(h).then(function(t){u.value=t,s(u)},function(t){return n("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e(function(e,i){n(t,r,e,i)})}return o=o?o.then(i,i):i()}})}function z(t,n,r){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:e,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var u=l(t,n,r);if("normal"===u.type){if(i=r.done?y:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=y,r.method="throw",r.arg=u.arg)}}}function E(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=l(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(t){if(null!=t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=v,i(k,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:b,configurable:!0}),b.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},M(S.prototype),u(S.prototype,a,function(){return this}),t.AsyncIterator=S,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var s=new S(h(e,n,r,i),o);return t.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},M(k),u(k,c,"Generator"),u(k,s,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=I,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return a.type="throw",a.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;O(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:I(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],r=0,i="",o=0,s=arguments.length;o!==s;++o){var a=+arguments[o];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?r=n.push(a):(a-=65536,r=n.push(55296+(a>>10),a%1024+56320)),r>=16383&&(i+=t.apply(null,n),n.length=0)}return i+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
|
|
7
|
+
/*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){if(!a&&Ki)return Ki(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,n,r)}return n[s].exports}for(var o=Ki,s=0;s<r.length;s++)i(r[s]);return i}return t}()({1:[function(t,e,n){var r=t("./utils"),i=function(){var t=r.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],i=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],o=["Thousand","Million","Billion","Trillion"];function s(t,r){var s=function(t,r,a){var c="";if(t<=19)c=(r?" and ":"")+(a?n[t]:e[t]);else if(t<100){var u=Math.floor(t/10),h=t%10;c=(r?" and ":"")+i[u-2],h>0?c+="-"+s(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(t<1e3){var l=Math.floor(t/100),f=t%100;c=(r?", ":"")+e[l]+" Hundred",f>0?c+=s(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(t)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),y=Math.floor(t/p),g=t-y*p;c=(r?", ":"")+s(y,!1,!1)+" "+o[d-1],g>0?c+=s(g,!0,a):a&&(c+="th")}return c};return s(t,!1,r)}var a=Object.create(null);function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];return e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)}),n.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,o.forEach(function(t,e){var n=t.toLowerCase(),r=Math.pow(10,3*(e+1));a[n]=r,a[n+"th"]=r});var u=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function l(t){for(var e=0;e<u.length;e++){var n=u[e];if(t>=n[0])return n[1]+l(t-n[0])}return""}function f(t){for(var e=0,n=1,r=t.length-1;r>=0;r--){var i=t[r],o=h[i];o<n?e-=o:(n=o,e+=o)}return e}function d(t,e){for(var n=[],r=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+r)),t=Math.floor((t-1)/26);return n.join("")}function p(t,e){for(var n=e.charCodeAt(0),r=0,i=0;i<t.length;i++)r+=(t.charCodeAt(t.length-i-1)-n+1)*Math.pow(26,i);return r}function y(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var g={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var r,i=e<0;switch(e=Math.abs(e),n.primary){case g.LETTERS:r=d(e,n.case===m.UPPER?"A":"a");break;case g.ROMAN:r=l(e),n.case===m.UPPER&&(r=r.toUpperCase());break;case g.WORDS:r=s(e,n.ordinal),n.case===m.UPPER?r=r.toUpperCase():n.case===m.LOWER&&(r=r.toLowerCase());break;case g.DECIMAL:r=""+e;var o=n.mandatoryDigits-r.length;if(o>0){var a=new Array(o+1).join("0");r=a+r}if(48!==n.zeroCode&&(r=t(r).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((r.length-1)/n.groupingSeparators.position);c>0;c--){var u=r.length-c*n.groupingSeparators.position;r=r.substr(0,u)+n.groupingSeparators.character+r.substr(u)}else n.groupingSeparators.reverse().forEach(function(t){var e=r.length-t.position;r=r.substr(0,e)+t.character+r.substr(e)});if(n.ordinal){var h={1:"st",2:"nd",3:"rd"}[r[r.length-1]];(!h||r.length>1&&"1"===r[r.length-2])&&(h="th"),r+=h}break;case g.SEQUENCE:throw{code:"D3130",value:n.token}}return i&&(r="-"+r),r}var v=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function x(e){var n,r={type:"integer",primary:g.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?n=e:(n=e.substring(0,i),"o"===e.substring(i+1)[0]&&(r.ordinal=!0)),n){case"A":r.case=m.UPPER;case"a":r.primary=g.LETTERS;break;case"I":r.case=m.UPPER;case"i":r.primary=g.ROMAN;break;case"W":r.case=m.UPPER,r.primary=g.WORDS;break;case"Ww":r.case=m.TITLE,r.primary=g.WORDS;break;case"w":r.primary=g.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(n).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,n=0;n<v.length;n++){var r=v[n];if(t>=r&&t<=r+9){if(e=!0,s++,u++,null===o)o=r;else if(r!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){r.primary=g.DECIMAL,r.zeroCode=o,r.mandatoryDigits=s,r.optionalDigits=a;var h=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var r=t.map(function(t){return t.position}),i=function(t,e){return 0===e?t:i(e,t%e)},o=r.reduce(i),s=1;s<=r.length;s++)if(-1===r.indexOf(s*o))return 0;return o}(c);h>0?(r.regular=!0,r.groupingSeparators={position:h,character:c[0].character}):(r.regular=!1,r.groupingSeparators=c)}else r.primary=g.SEQUENCE,r.token=n}return r}var _={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function w(t){for(var e=[],n={type:"datetime",parts:e},r=function(n,r){if(r>n){var i=t.substring(n,r);i=i.split("]]").join("]"),e.push({type:"literal",value:i})}},i=0,o=0;o<t.length;){if("["===t.charAt(o)){if("["===t.charAt(o+1)){r(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(r(i,o),i=o,-1===(o=t.indexOf("]",i)))throw{code:"D3135"};var s,a=t.substring(i+1,o),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},u=a.lastIndexOf(",");if(-1!==u){var h=a.substring(u+1),l=h.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===l?f=h:(f=h.substring(0,l),d=h.substring(l+1));var y={min:p(f),max:p(d)};c.width=y,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var g=s.charAt(s.length-1);-1!=="atco".indexOf(g)?(c.presentation2=g,"o"===g&&(c.ordinal=!0),c.presentation1=s.substring(0,s.length-1)):c.presentation1=s}else c.presentation1=_[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=m.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=m.TITLE:c.names=m.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=x(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var v=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;v>=2&&(c.n=v)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=x(c.presentation1)),e.push(c),i=o+1}o++}return r(i,o),n}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=864e5,z=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*S:e-(n-1)*S},E=function(t,e){return{year:t,month:e,nextMonth:function(){return 11===e?E(t+1,0):E(t,e+1)},previousMonth:function(){return 0===e?E(t-1,11):E(t,e-1)},nextYear:function(){return E(t+1,e)},previousYear:function(){return E(t-1,e)}}},A=function(t,e){return(e-t)/(7*S)+1},O=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/S+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var r=E(t.getUTCFullYear(),0),i=z(r),o=Date.UTC(r.year,t.getUTCMonth(),t.getUTCDate()),s=A(i,o);if(s>52)o>=z(r.nextYear())&&(s=1);else if(s<1){var a=z(r.previousYear());s=A(a,o)}n=Math.floor(s);break;case"w":var c=E(t.getUTCFullYear(),t.getUTCMonth()),u=z(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),l=A(u,h);if(l>4)h>=z(c.nextMonth())&&(l=1);else if(l<1){var f=z(c.previousMonth());l=A(f,h)}n=Math.floor(l);break;case"X":var d=E(t.getUTCFullYear(),0),p=z(d),y=z(d.nextYear()),g=t.getTime();n=g<p?d.year-1:g>=y?d.year+1:d.year;break;case"x":var m=E(t.getUTCFullYear(),t.getUTCMonth()),b=z(m),v=m.nextMonth(),x=z(v),_=t.getTime();n=_<b?m.previousMonth().month+1:_>=x?v.month+1:m.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},T=null;function I(t,e,n){var r=0,i=0;if(void 0!==n){var o=parseInt(n);r=Math.floor(o/100),i=o%100}var s,a=function(t,e){var n=O(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=M[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=k[n]}e.names===m.UPPER?n=n.toUpperCase():e.names===m.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*r+i;if(e.integerFormat.regular)n=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)n=b(r,e.integerFormat),0!==i&&(n+=":"+y(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};n=b(o,e.integerFormat)}}o>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===o&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===T&&(T=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),s=T):s=w(e);var c=new Date(t+60*(60*r+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function j(t){var e=Object.create(null);if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e=Object.create(null);if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var r=0,i=0;return n?(r=Number.parseInt(e.substring(0,e.indexOf(n.character))),i=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?r=Number.parseInt(e):(r=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*r+i}}else if("f"===t.component)e.regex="[0-9]+",e.parse=function(t){return 1e3*parseFloat("0."+t.substring(0,3))};else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var r=Object.create(null);if("M"===t.component||"x"===t.component)M.forEach(function(e,n){t.width&&t.width.max?r[e.substring(0,t.width.max)]=n+1:r[e]=n+1});else if("F"===t.component)k.forEach(function(e,n){n>0&&(t.width&&t.width.max?r[e.substring(0,t.width.max)]=n:r[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};r={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return r[t]}}return e.component=t.component,e});else{e.type="integer";var n,i=t.case===m.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case g.LETTERS:e.regex=i?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,i?"A":"a")};break;case g.ROMAN:e.regex=i?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(i?t:t.toUpperCase())};break;case g.WORDS:e.regex="(?:"+r.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case g.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case g.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function P(t,e){if(void 0!==t)return j(x(e)).parse(t)}function R(t,e){var n=j(w(e)),r="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(r,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,h=47,l=Object.create(null),f=1;f<i.length;f++){var d=n.parts[f-1];d.parse&&(l[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(l).length)return;var p=0,y=function(t){p<<=1,p+=t?1:0},g=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return y(l[t])});var m=!g(o)&&g(s),b=g(a),v=!b&&g(c);p=0,"PHhmsf".split("").forEach(function(t){return y(l[t])});var x=!g(u)&&g(h),_=(m?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),k=this.environment.timestamp,M=!1,S=!1;if(_.split("").forEach(function(t){if(void 0===l[t])M?(l[t]=-1!=="MDd".indexOf(t)?1:0,S=!0):l[t]=O(k,t);else if(M=!0,S)throw{code:"D3136"}}),l.M>0?l.M-=1:l.M=0,m){var z=Date.UTC(l.Y,0),E=1e3*(l.d-1)*60*60*24,A=new Date(z+E);l.M=A.getUTCMonth(),l.D=A.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(l.H=12===l.h?0:l.h,1===l.P&&(l.H+=12));var T=Date.UTC(l.Y,l.M,l.D,l.H,l.m,l.s,l.f);return(l.Z||l.z)&&(T-=60*(l.Z||l.z)*1e3),T}}var C=new RegExp("^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function F(t,e){if(void 0!==t){if(void 0===e){if(!C.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return R.call(this,t,e)}}function N(t,e,n){if(void 0!==t)return I.call(this,t,e,n)}return{formatInteger:y,parseInteger:P,fromMillis:N,toMillis:F}}();e.exports=i},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(s(t)+" is not iterable")}function c(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,h=Object.create(c.prototype);return u(h,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),h}var s={};function a(){}function h(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(u(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return h.prototype=l,u(d,"constructor",l),u(l,"constructor",h),h.displayName="GeneratorFunction",u(l,i,"GeneratorFunction"),u(d),u(d,i,"Generator"),u(d,r,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:o,m:p}})()}function u(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}u=function(t,e,n,r){function o(e,n){u(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},u(t,e,n,r)}var h=t("./utils"),l=function(){var t=c().m(q),e=c().m(Y),i=c().m(B),o=c().m(G),u=c().m(K),l=c().m(pt),f=c().m(yt),d=c().m(gt),p=c().m(bt),y=c().m(zt),g=c().m(Tt),m=c().m(Pt),b=h.isNumeric,v=h.isArrayOfStrings,x=h.isArrayOfNumbers,_=h.createSequence,w=h.isSequence,k=h.isFunction,M=h.isLambda,S=h.isIterable,z=h.getFunctionArity,E=h.isDeepEqual,A=h.stringToArray;function O(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function T(t){return void 0===t?0:t.length}function I(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function j(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function R(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(k(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var r=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&b(e)?Number(e.toPrecision(15)):e&&k(e)?"":e},r)}return n}}function C(t,e,n){if(void 0!==t){var r=A(t),i=r.length;if(i+e<0&&(e=0),void 0!==n){if(n<=0)return"";var o=e>=0?e+n:i+e+n;return r.slice(e,o).join("")}return r.slice(e).join("")}}function F(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function N(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function D(t){if(void 0!==t)return t.toLowerCase()}function L(t){if(void 0!==t)return t.toUpperCase()}function $(t){if(void 0!==t)return A(t).length}function U(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function W(t,e,n){if(void 0!==t){var r;void 0!==n&&0!==n.length||(n=" ");var i=Math.abs(e)-$(t);if(i>0){var o=new Array(i+1).join(n);n.length>1&&(o=C(o,0,i)),r=e>0?t+o:o+t}else r=t;return r}}function q(e,n){var r;return c().w(function(t){for(;;)switch(t.n){case 0:if(r=e.apply(this,[n]),!S(r)){t.n=2;break}return t.d(a(r),1);case 1:r=t.v;case 2:if(!r||"number"==typeof r.start||"number"===r.end||Array.isArray(r.groups)||k(r.next)){t.n=3;break}throw{code:"T1010",stack:(new Error).stack};case 3:return t.a(2,r)}},t,this)}function Y(t,n){var r,i;return c().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof n){e.n=2;break}r=-1!==t.indexOf(n),e.n=4;break;case 2:return e.d(a(q(n,t)),3);case 3:i=e.v,r=void 0!==i;case 4:return e.a(2,r)}},e)}function B(t,e,n){var r,o,s;return c().w(function(i){for(;;)switch(i.n){case 0:if(void 0!==t){i.n=1;break}return i.a(2,void 0);case 1:if(!(n<0)){i.n=2;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 2:if(r=_(),!(void 0===n||n>0)){i.n=6;break}return o=0,i.d(a(q(e,t)),3);case 3:if(void 0===(s=i.v)){i.n=6;break}case 4:if(void 0===s||!(void 0===n||o<n)){i.n=6;break}return r.push({match:s.match,index:s.start,groups:s.groups}),i.d(a(q(s.next)),5);case 5:s=i.v,o++,i.n=4;break;case 6:return i.a(2,r)}},i)}function G(t,e,n,r){var i,s,u,h,l,f,d,p;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:if(i=this,""!==e){o.n=2;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 2:if(!(r<0)){o.n=3;break}throw{code:"D3011",stack:(new Error).stack,value:r,index:4};case 3:if(s="string"==typeof n?function(t){for(var e="",r=0,i=n.indexOf("$",r);-1!==i&&r<n.length;){e+=n.substring(r,i),r=i+1;var o=n.charAt(r);if("$"===o)e+="$",r++;else if("0"===o)e+=t.match,r++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(n.substring(r,r+s),10),s>1&&i>t.groups.length&&(i=parseInt(n.substring(r,r+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}r+=i.toString().length}}i=n.indexOf("$",r)}return e+=n.substring(r)}:n,u="",h=0,!(void 0===r||r>0)){o.n=15;break}if(l=0,"string"!=typeof e){o.n=4;break}for(f=t.indexOf(e,h);-1!==f&&(void 0===r||l<r);)u+=t.substring(h,f),u+=n,h=f+e.length,l++,f=t.indexOf(e,h);u+=t.substring(h),o.n=14;break;case 4:return o.d(a(q(e,t)),5);case 5:if(void 0===(d=o.v)){o.n=13;break}case 6:if(void 0===d||!(void 0===r||l<r)){o.n=12;break}if(u+=t.substring(h,d.start),p=s.apply(i,[d]),!S(p)){o.n=8;break}return o.d(a(p),7);case 7:p=o.v;case 8:if("string"!=typeof p){o.n=9;break}u+=p,o.n=10;break;case 9:throw{code:"D3012",stack:(new Error).stack,value:p};case 10:return h=d.start+d.match.length,l++,o.d(a(q(d.next)),11);case 11:d=o.v,o.n=6;break;case 12:u+=t.substring(h),o.n=14;break;case 13:u=t;case 14:o.n=16;break;case 15:u=t;case 16:return o.a(2,u)}},o,this)}function H(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function X(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function V(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function Z(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function J(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function K(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!(n<0)){c.n=2;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 2:if(r=[],!(void 0===n||n>0)){c.n=9;break}if("string"!=typeof e){c.n=3;break}r=t.split(e,n),c.n=9;break;case 3:return i=0,c.d(a(q(e,t)),4);case 4:if(void 0===(o=c.v)){c.n=8;break}s=0;case 5:if(void 0===o||!(void 0===n||i<n)){c.n=7;break}return r.push(t.substring(s,o.start)),s=o.end,c.d(a(q(o.next)),6);case 6:o=c.v,i++,c.n=5;break;case 7:(void 0===n||i<n)&&r.push(t.substring(s)),c.n=9;break;case 8:r.push(t);case 9:return c.a(2,r)}},u)}function tt(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function et(t,e,n){if(void 0!==t){var r={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&h.keys(n).forEach(function(t){r[t]=n[t]});for(var i=[],o=r["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([r["decimal-separator"],r["exponent-separator"],r["grouping-separator"],r.digit,r["pattern-separator"]]),c=e.split(r["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,n,i,o,s=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(n+1)}(),u=t.substring(s.length,t.length-c.length),h=t.indexOf(r["exponent-separator"],s.length);-1===h||h>t.length-c.length?(e=u,n=void 0):(e=u.substring(0,h),n=u.substring(h+1));var l=e.indexOf(r["decimal-separator"]);return-1===l?(i=e,o=c):(i=e.substring(0,l),o=e.substring(l+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:n,integerPart:i,fractionalPart:o,subpicture:t}},l=function(t){var e,n,o=t.subpicture,s=o.indexOf(r["decimal-separator"]);s!==o.lastIndexOf(r["decimal-separator"])&&(e="D3081"),o.indexOf(r.percent)!==o.lastIndexOf(r.percent)&&(e="D3082"),o.indexOf(r["per-mille"])!==o.lastIndexOf(r["per-mille"])&&(e="D3083"),-1!==o.indexOf(r.percent)&&-1!==o.indexOf(r["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var u=t.mantissaPart.charAt(n);if(-1!==i.indexOf(u)||u===r.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==s?o.charAt(s-1)!==r["grouping-separator"]&&o.charAt(s+1)!==r["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===r["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(r["grouping-separator"]+r["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(r.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(r.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var l="string"==typeof t.exponentPart;if(l&&t.exponentPart.length>0&&(-1!==o.indexOf(r.percent)||-1!==o.indexOf(r["per-mille"]))&&(e="D3092"),l&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},f=function(t){var e=function(e,n){for(var o=[],s=e.indexOf(r["grouping-separator"]);-1!==s;){var a=(n?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length;o.push(a),s=t.integerPart.indexOf(r["grouping-separator"],s+1)}return o},n=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function(t,n){return 0===n?t:e(n,t%n)},n=t.reduce(e),r=1;r<=t.length;r++)if(-1===t.indexOf(r*n))return 0;return n}(n),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),h=u.filter(function(t){return-1!==i.indexOf(t)}).length,l=u.filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===l&&(f?(h=1,l=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(r.digit)&&(a=1),0===a&&0===h&&(h=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:l,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},d=c.map(u);d.forEach(l);var p,y,g,m,b=d.map(f),v=r["minus-sign"],x=r["zero-digit"],_=r["decimal-separator"],w=r["grouping-separator"];if(1===b.length&&(b.push(JSON.parse(JSON.stringify(b[0]))),b[1].prefix=v+b[1].prefix),y=-1!==(p=t>=0?b[0]:b[1]).picture.indexOf(r.percent)?100*t:-1!==p.picture.indexOf(r["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=y;else{var k=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(g=y,m=0;g<M;)g*=10,m-=1;for(;g>k;)g/=10,m+=1}var S=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==x&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),n},z=S(at(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=z.indexOf(".");for(-1===E?z+=_:z=z.replace(".",_);z.charAt(0)===x;)z=z.substring(1);for(;z.charAt(z.length-1)===x;)z=z.substring(0,z.length-1);E=z.indexOf(_);var A=p.minimumIntegerPartSize-E,O=p.minimumFactionalPartSize-(z.length-E-1);if(z=(A>0?new Array(A+1).join(x):"")+z,z+=O>0?new Array(O+1).join(x):"",E=z.indexOf(_),p.regularGrouping>0)for(var T=Math.floor((E-1)/p.regularGrouping),I=1;I<=T;I++)z=[z.slice(0,E-I*p.regularGrouping),w,z.slice(E-I*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){z=[z.slice(0,E-t),w,z.slice(E-t)].join(""),E++});if(E=z.indexOf(_),p.fractionalPartGroupingPositions.forEach(function(t){z=[z.slice(0,t+E+1),w,z.slice(t+E+1)].join("")}),E=z.indexOf(_),-1!==p.picture.indexOf(_)&&E!==z.length-1||(z=z.substring(0,z.length-1)),void 0!==m){var j=S(m,0);(A=p.minimumExponentSize-j.length)>0&&(j=new Array(A+1).join(x)+j),z=z+r["exponent-separator"]+(m<0?v:"")+j}return z=p.prefix+z+p.suffix}}function nt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function rt(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function it(t){if(void 0!==t)return Math.abs(t)}function ot(t){if(void 0!==t)return Math.floor(t)}function st(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var n;if(void 0!==t){if(e){var r=t.toString().split("e");t=+(r[0]+"e"+(r[1]?+r[1]+e:e))}var i=(n=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(n%2)&&(n-=1),e&&(r=n.toString().split("e"),n=+(r[0]+"e"+(r[1]?+r[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ct(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ut(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function ht(){return Math.random()}function lt(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=lt(t[0]):t.length>1&&(e=t.filter(function(t){return lt(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):b(t)?0!==t&&(e=!0):null!==t&&"object"===s(t)?h.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ft(t){if(void 0!==t)return!lt(t)}function dt(t,e,n,r){var i=[e],o=z(t);return o>=2&&i.push(n),o>=3&&i.push(r),i}function pt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=dt(e,t[r],r,t),s.d(a(e.apply(this,i)),3);case 3:void 0!==(o=s.v)&&n.push(o);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},l,this)}function yt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=t[r],o=dt(e,i,r,t),s.d(a(e.apply(this,o)),3);case 3:lt(s.v)&&n.push(i);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},f,this)}function gt(t,e){var n,r,i,o,s,u,h;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:n=!1,i=0;case 2:if(!(i<t.length)){c.n=7;break}if(o=t[i],s=!0,void 0===e){c.n=4;break}return u=dt(e,o,i,t),c.d(a(e.apply(this,u)),3);case 3:h=c.v,s=lt(h);case 4:if(!s){c.n=6;break}if(n){c.n=5;break}r=o,n=!0,c.n=6;break;case 5:throw{stack:(new Error).stack,code:"D3138",index:i};case 6:i++,c.n=2;break;case 7:if(n){c.n=8;break}throw{stack:(new Error).stack,code:"D3139"};case 8:return c.a(2,r)}},d,this)}function mt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),r=0;r<n;r++){var i=e.map(function(t){return t[r]});t.push(i)}return t}function bt(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!((i=z(e))<2)){c.n=2;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 2:void 0===n&&t.length>0?(r=t[0],o=1):(r=n,o=0);case 3:if(!(o<t.length)){c.n=5;break}return s=[r,t[o]],i>=3&&s.push(o),i>=4&&s.push(t),c.d(a(e.apply(this,s)),4);case 4:r=c.v,o++,c.n=3;break;case 5:return c.a(2,r)}},p,this)}function vt(t){var e=_();if(Array.isArray(t)){var n=Object.create(null);t.forEach(function(t){vt(t).forEach(function(t){n[t]=!0})}),e=vt(n)}else null===t||"object"!==s(t)||M(t)||h.keys(t).forEach(function(t){return e.push(t)});return e}function xt(t,e){var n;if(Array.isArray(t)){n=_();for(var r=0;r<t.length;r++){var i=xt(t[r],e);void 0!==i&&(Array.isArray(i)?i.forEach(function(t){return n.push(t)}):n.push(i))}}else null!==t&&"object"===s(t)&&Object.prototype.hasOwnProperty.call(t,e)&&!k(t)&&(n=t[e]);return n}function _t(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=_(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function wt(t){return void 0!==t}function kt(t){var e=_();if(Array.isArray(t))t.forEach(function(t){e=_t(e,kt(t))});else if(null===t||"object"!==s(t)||M(t))e=t;else{var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value,a=Object.create(null);a[o]=t[o],e.push(a)}}catch(t){i.e(t)}finally{i.f()}}return e}function Mt(t){if(void 0!==t){var e=Object.create(null);return t.forEach(function(t){var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;e[o]=t[o]}}catch(t){i.e(t)}finally{i.f()}}),e}}function St(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),r=0;r<e;r++)n[e-r-1]=t[r];return n}}function zt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=_(),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=dt(e,t[s],s,t),c.d(a(e.apply(this,u)),3);case 3:void 0!==(l=c.v)&&n.push(l);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return c.a(2,n)}},y,this,[[1,6,7,8]])}function Et(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function At(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function Ot(t){if(void 0!==t)return null===t?"null":b(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":k(t)?"function":"object"}function Tt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:if(!(t.length<=1)){s.n=2;break}return s.a(2,t);case 2:if(void 0!==e){s.n=4;break}if(x(t)||v(t)){s.n=3;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 3:n=c().m(function t(e,n){return c().w(function(t){for(;;)if(0===t.n)return t.a(2,e>n)},t)}),s.n=5;break;case 4:n=e;case 5:return r=c().m(function t(e,r){var i,o;return c().w(function(t){for(;;)switch(t.n){case 0:return i=c().m(function t(e,r,o){return c().w(function(t){for(;;)switch(t.n){case 0:if(0!==r.length){t.n=1;break}Array.prototype.push.apply(e,o),t.n=6;break;case 1:if(0!==o.length){t.n=2;break}Array.prototype.push.apply(e,r),t.n=6;break;case 2:return t.d(a(n(r[0],o[0])),3);case 3:if(!t.v){t.n=5;break}return e.push(o[0]),t.d(a(i(e,r,o.slice(1))),4);case 4:t.n=6;break;case 5:return e.push(r[0]),t.d(a(i(e,r.slice(1),o)),6);case 6:return t.a(2)}},t)}),o=[],t.d(a(i(o,e,r)),1);case 1:return t.a(2,o)}},t)}),i=c().m(function t(e){var n,o,s;return c().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(e)&&!(e.length<=1)){t.n=1;break}return t.a(2,e);case 1:return n=Math.floor(e.length/2),o=e.slice(0,n),s=e.slice(n),t.d(a(i(o)),2);case 2:return o=t.v,t.d(a(i(s)),3);case 3:return s=t.v,t.d(a(r(o,s)),4);case 4:return t.a(2,t.v);case 5:return t.a(2)}},t)}),s.d(a(i(t)),6);case 6:return o=s.v,s.a(2,o)}},g)}function It(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var r=Math.floor(Math.random()*(n+1));n!==r&&(e[n]=e[r]),e[r]=t[n]}return e}}function jt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=w(t)?_():[],n=0;n<t.length;n++){for(var r=t[n],i=!1,o=0;o<e.length;o++)if(E(r,e[o])){i=!0;break}i||e.push(r)}return e}}function Pt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=Object.create(null),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=t[s],l=dt(e,u,s,t),c.d(a(e.apply(this,l)),3);case 3:lt(c.v)&&(n[s]=u);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return 0===h.keys(n).length&&(n=void 0),c.a(2,n)}},m,this,[[1,6,7,8]])}return{sum:O,count:T,max:I,min:j,average:P,string:R,substring:C,substringBefore:F,substringAfter:N,lowercase:D,uppercase:L,length:$,trim:U,pad:W,match:B,contains:Y,replace:G,split:K,join:tt,formatNumber:et,formatBase:nt,number:rt,floor:ot,ceil:st,round:at,abs:it,sqrt:ct,power:ut,random:ht,boolean:lt,not:ft,map:pt,zip:mt,filter:yt,single:gt,foldLeft:bt,sift:Pt,keys:vt,lookup:xt,append:_t,exists:wt,spread:kt,merge:Mt,reverse:St,each:zt,error:Et,assert:At,type:Ot,sort:Tt,shuffle:It,distinct:jt,base64encode:H,base64decode:X,encodeUrlComponent:V,encodeUrl:Z,decodeUrlComponent:Q,decodeUrl:J}}();e.exports=l}).call(this)}).call(this,void 0!==Qi?Qi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function r(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=s(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(i(t)+" is not iterable")}function u(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return h(u,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),u}var s={};function a(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(h(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,h(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,h(d,"constructor",l),h(l,"constructor",c),c.displayName="GeneratorFunction",h(l,i,"GeneratorFunction"),h(d),h(d,i,"Generator"),h(d,r,function(){return this}),h(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:o,m:p}})()}function h(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}h=function(t,e,n,r){function o(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},h(t,e,n,r)}var l=t("./datetime"),f=t("./functions"),d=t("./utils"),p=t("./parser"),y=t("./signature"),g=function(){var t=u().m(q),e=u().m(Y),n=u().m(G),s=u().m(H),a=u().m(X),h=u().m(V),g=u().m(Z),m=u().m(Q),b=u().m(ct),v=u().m(lt),x=u().m(pt),_=u().m(yt),w=u().m(gt),k=u().m(vt),M=u().m(wt),S=u().m(kt),z=u().m(Mt),E=u().m(St),A=u().m(Et),O=u().m(Ot),T=u().m(jt),I=u().m(Ct),j=d.isNumeric,P=d.isArrayOfStrings,R=d.isArrayOfNumbers,C=d.createSequence,F=d.isSequence,N=d.isFunction,D=d.isLambda,L=d.isIterable,$=d.getFunctionArity,U=d.isDeepEqual,W=Nt(null);function q(e,n,r){var i,o,s,a,h;return u().w(function(t){for(;;)switch(t.n){case 0:(o=r.lookup("__evaluate_entry"))&&o(e,n,r),h=e.type,t.n="path"===h?1:"binary"===h?3:"unary"===h?5:"name"===h?7:"string"===h||"number"===h||"value"===h?8:"wildcard"===h?9:"descendant"===h?10:"parent"===h?11:"condition"===h?12:"block"===h?14:"bind"===h?16:"regex"===h?18:"function"===h?19:"variable"===h?21:"lambda"===h?22:"partial"===h?23:"apply"===h?25:"transform"===h?27:28;break;case 1:return t.d(c(Y(e,n,r)),2);case 2:return i=t.v,t.a(3,28);case 3:return t.d(c(Z(e,n,r)),4);case 4:return i=t.v,t.a(3,28);case 5:return t.d(c(Q(e,n,r)),6);case 6:return i=t.v,t.a(3,28);case 7:return i=J(e,n),t.a(3,28);case 8:return i=K(e),t.a(3,28);case 9:return i=tt(e,n),t.a(3,28);case 10:return i=nt(e,n),t.a(3,28);case 11:return i=r.lookup(e.slot.label),t.a(3,28);case 12:return t.d(c(yt(e,n,r)),13);case 13:return i=t.v,t.a(3,28);case 14:return t.d(c(gt(e,n,r)),15);case 15:return i=t.v,t.a(3,28);case 16:return t.d(c(pt(e,n,r)),17);case 17:return i=t.v,t.a(3,28);case 18:return i=mt(e),t.a(3,28);case 19:return t.d(c(kt(e,n,r)),20);case 20:return i=t.v,t.a(3,28);case 21:return i=bt(e,n,r),t.a(3,28);case 22:return i=zt(e,n,r),t.a(3,28);case 23:return t.d(c(Et(e,n,r)),24);case 24:return i=t.v,t.a(3,28);case 25:return t.d(c(wt(e,n,r)),26);case 26:return i=t.v,t.a(3,28);case 27:return i=xt(e,n,r),t.a(3,28);case 28:if(!r.async||null!=i&&"function"==typeof i.then||(i=Promise.resolve(i)),!r.async||"function"!=typeof i.then||!e.nextFunction||"function"!=typeof i[e.nextFunction]){t.n=29;break}t.n=31;break;case 29:return t.n=30,i;case 30:i=t.v;case 31:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.n=35;break}s=0;case 32:if(!(s<e.predicate.length)){t.n=35;break}return t.d(c(V(e.predicate[s].expr,i,r)),33);case 33:i=t.v;case 34:s++,t.n=32;break;case 35:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.n=37;break}return t.d(c(lt(e.group,i,r)),36);case 36:i=t.v;case 37:return(a=r.lookup("__evaluate_exit"))&&a(e,n,r,i),i&&F(i)&&!i.tupleStream&&(e.keepArray&&(i.keepSingleton=!0),0===i.length?i=void 0:1===i.length&&(i=i.keepSingleton?i:i[0])),t.a(2,i)}},t)}function Y(t,n,r){var i,o,s,a,h,l;return u().w(function(e){for(;;)switch(e.n){case 0:i=Array.isArray(n)&&"variable"!==t.steps[0].type?n:C(n),s=!1,a=void 0,h=0;case 1:if(!(h<t.steps.length)){e.n=10;break}if((l=t.steps[h]).tuple&&(s=!0),0!==h||!l.consarray){e.n=3;break}return e.d(c(q(l,i,r)),2);case 2:o=e.v,e.n=7;break;case 3:if(!s){e.n=5;break}return e.d(c(X(l,i,a,r)),4);case 4:a=e.v,e.n=7;break;case 5:return e.d(c(G(l,i,r,h===t.steps.length-1)),6);case 6:o=e.v;case 7:if(s||void 0!==o&&0!==o.length){e.n=8;break}return e.a(3,10);case 8:void 0===l.focus&&(i=o);case 9:h++,e.n=1;break;case 10:if(s)if(t.tuple)o=a;else for(o=C(),h=0;h<a.length;h++)o.push(a[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=C(o)),o.keepSingleton=!0),!Object.prototype.hasOwnProperty.call(t,"group")){e.n=12;break}return e.d(c(lt(t.group,s?a:o,r)),11);case 11:o=e.v;case 12:return e.a(2,o)}},e)}function B(t,e){var n,r=Nt(t),i=o(d.keys(e));try{for(i.s();!(n=i.n()).done;){var s=n.value;r.bind(s,e[s])}}catch(t){i.e(t)}finally{i.f()}return r}function G(t,e,r,i){var o,s,a,h,l;return u().w(function(n){for(;;)switch(n.n){case 0:if("sort"!==t.type){n.n=4;break}return n.d(c(vt(t,e,r)),1);case 1:if(o=n.v,!t.stages){n.n=3;break}return n.d(c(H(t.stages,o,r)),2);case 2:o=n.v;case 3:return n.a(2,o);case 4:o=C(),s=0;case 5:if(!(s<e.length)){n.n=12;break}return n.d(c(q(t,e[s],r)),6);case 6:if(a=n.v,!t.stages){n.n=10;break}h=0;case 7:if(!(h<t.stages.length)){n.n=10;break}return n.d(c(V(t.stages[h].expr,a,r)),8);case 8:a=n.v;case 9:h++,n.n=7;break;case 10:void 0!==a&&o.push(a);case 11:s++,n.n=5;break;case 12:return l=C(),i&&1===o.length&&Array.isArray(o[0])&&!F(o[0])?l=o[0]:Array.prototype.forEach.call(o,function(t){!Array.isArray(t)||t.cons?l.push(t):Array.prototype.forEach.call(t,function(t){return l.push(t)})}),n.a(2,l)}},n)}function H(t,e,n){var r,i,o,a,h;return u().w(function(s){for(;;)switch(s.n){case 0:r=e,i=0;case 1:if(!(i<t.length)){s.n=6;break}o=t[i],h=o.type,s.n="filter"===h?2:"index"===h?4:5;break;case 2:return s.d(c(V(o.expr,r,n)),3);case 3:return r=s.v,s.a(3,5);case 4:for(a=0;a<r.length;a++)r[a][o.value]=a;return s.a(3,5);case 5:i++,s.n=1;break;case 6:return s.a(2,r)}},s)}function X(t,e,n,r){var i,o,s,h,l,f,d,p;return u().w(function(a){for(;;)switch(a.n){case 0:if("sort"!==t.type){a.n=7;break}if(!n){a.n=2;break}return a.d(c(vt(t,n,r)),1);case 1:i=a.v,a.n=4;break;case 2:return a.d(c(vt(t,e,r)),3);case 3:for(o=a.v,(i=C()).tupleStream=!0,s=0;s<o.length;s++)(h={"@":o[s]})[t.index]=s,i.push(h);case 4:if(!t.stages){a.n=6;break}return a.d(c(H(t.stages,i,r)),5);case 5:i=a.v;case 6:return a.a(2,i);case 7:(i=C()).tupleStream=!0,l=r,void 0===n&&(n=e.map(function(t){return{"@":t}})),f=0;case 8:if(!(f<n.length)){a.n=11;break}return l=B(r,n[f]),a.d(c(q(t,n[f]["@"],l)),9);case 9:if(void 0!==(d=a.v))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)h=Object.create(null),Object.assign(h,n[f]),d.tupleStream?Object.assign(h,d[p]):(t.focus?(h[t.focus]=d[p],h["@"]=n[f]["@"]):h["@"]=d[p],t.index&&(h[t.index]=p),t.ancestor&&(h[t.ancestor.label]=n[f]["@"])),i.push(h);case 10:f++,a.n=8;break;case 11:if(!t.stages){a.n=13;break}return a.d(c(H(t.stages,i,r)),12);case 12:i=a.v;case 13:return a.a(2,i)}},a)}function V(t,e,n){var r,i,o,s,a,l;return u().w(function(u){for(;;)switch(u.n){case 0:if(r=C(),e&&e.tupleStream&&(r.tupleStream=!0),Array.isArray(e)||(e=C(e)),"number"!==t.type){u.n=1;break}(i=Math.floor(t.value))<0&&(i=e.length+i),void 0!==(o=e[i])&&(Array.isArray(o)?r=o:r.push(o)),u.n=5;break;case 1:i=0;case 2:if(!(i<e.length)){u.n=5;break}return o=e[i],s=o,a=n,e.tupleStream&&(s=o["@"],a=B(n,o)),u.d(c(q(t,s,a)),3);case 3:l=u.v,j(l)&&(l=[l]),R(l)?Array.prototype.forEach.call(l,function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===i&&r.push(o)}):f.boolean(l)&&r.push(o);case 4:i++,u.n=2;break;case 5:return u.a(2,r)}},h)}function Z(t,e,n){var r,i,o,s,a,h,l,f;return u().w(function(d){for(;;)switch(d.p=d.n){case 0:return d.d(c(q(t.lhs,e,n)),1);case 1:if(i=d.v,o=t.value,s=u().m(function r(){return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(q(t.rhs,e,n)),1);case 1:return r.a(2,r.v)}},r)}),"and"!==o&&"or"!==o){d.n=5;break}return d.p=2,d.d(c(ct(i,s,o)),3);case 3:return d.a(2,d.v);case 4:throw d.p=4,(h=d.v).position=t.position,h.token=o,h;case 5:return d.d(c(s()),6);case 6:a=d.v,d.p=7,l=o,d.n="+"===l||"-"===l||"*"===l||"/"===l||"%"===l?8:"="===l||"!="===l?9:"<"===l||"<="===l||">"===l||">="===l?10:"&"===l?11:".."===l?12:"in"===l?13:14;break;case 8:return r=it(i,a,o),d.a(3,14);case 9:return r=ot(i,a,o),d.a(3,14);case 10:return r=st(i,a,o),d.a(3,14);case 11:return r=ht(i,a),d.a(3,14);case 12:return r=dt(i,a),d.a(3,14);case 13:return r=at(i,a),d.a(3,14);case 14:d.n=16;break;case 15:throw d.p=15,(f=d.v).position=t.position,f.token=o,f;case 16:return d.a(2,r)}},g,null,[[7,15],[2,4]])}function Q(t,e,n){var r,i,o,s,a;return u().w(function(u){for(;;)switch(u.n){case 0:a=t.value,u.n="-"===a?1:"["===a?6:"{"===a?11:13;break;case 1:return u.d(c(q(t.expression,e,n)),2);case 2:if(void 0!==(r=u.v)){u.n=3;break}r=void 0,u.n=5;break;case 3:if(!j(r)){u.n=4;break}r=-r,u.n=5;break;case 4:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:r};case 5:return u.a(3,13);case 6:r=[],i=0;case 7:if(!(i<t.expressions.length)){u.n=10;break}return o=t.expressions[i],u.d(c(q(o,e,n)),8);case 8:void 0!==(s=u.v)&&("["===o.value?r.push(s):r=f.append(r,s));case 9:i++,u.n=7;break;case 10:return t.consarray&&Object.defineProperty(r,"cons",{enumerable:!1,configurable:!1,value:!0}),u.a(3,13);case 11:return u.d(c(lt(t,e,n)),12);case 12:return r=u.v,u.a(3,13);case 13:return u.a(2,r)}},m)}function J(t,e,n){return f.lookup(e,t.value)}function K(t){return t.value}function tt(t,e){var n=C();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null===e||"object"!==i(e)||N(e)||d.keys(e).forEach(function(t){var r=e[t];Array.isArray(r)?(r=et(r),n=f.append(n,r)):n.push(r)}),n}function et(t,e){return void 0===e&&(e=[]),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){et(t,e)}):e.push(t),e}function nt(t,e){var n,r=C();return void 0!==e&&(rt(e,r),n=1===r.length?r[0]:r),n}function rt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){rt(t,e)}):null===t||"object"!==i(t)||N(t)||d.keys(t).forEach(function(n){rt(t[n],e)})}function it(t,e,n){var r;if(void 0!==t&&!j(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!j(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;switch(n){case"+":r=t+e;break;case"-":r=t-e;break;case"*":r=t*e;break;case"/":r=t/e;break;case"%":r=t%e}return r}function ot(t,e,n){var r,o=i(t),s=i(e);if("undefined"===o||"undefined"===s)return!1;switch(n){case"=":r=U(t,e);break;case"!=":r=!U(t,e)}return r}function st(t,e,n){var r,o=i(t),s=i(e);if("undefined"!==o&&"string"!==o&&"number"!==o||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==o&&"number"!==o?t:e};if("undefined"!==o&&"undefined"!==s){if(o!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":r=t<e;break;case"<=":r=t<=e;break;case">":r=t>e;break;case">=":r=t>=e}return r}}function at(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++)if(e[r]===t){n=!0;break}return n}function ct(t,e,n){var r,i,o,s,a,h,l;return u().w(function(u){for(;;)switch(u.n){case 0:i=ut(t),o=n,u.n="and"===o?1:"or"===o?4:7;break;case 1:if(!(s=i)){u.n=3;break}return a=ut,u.d(c(e()),2);case 2:s=a(u.v);case 3:return r=s,u.a(3,7);case 4:if(h=i){u.n=6;break}return l=ut,u.d(c(e()),5);case 5:h=l(u.v);case 6:return r=h,u.a(3,7);case 7:return u.a(2,r)}},b)}function ut(t){var e=f.boolean(t);return void 0!==e&&e}function ht(t,e){var n="",r="";return void 0!==t&&(n=f.string(t)),void 0!==e&&(r=f.string(e)),n.concat(r)}function lt(t,e,n){var i,o,s,a,h,l,d,p,y,g,m,b,x,_,w;return u().w(function(u){for(;;)switch(u.n){case 0:i=Object.create(null),o=Object.create(null),s=!(!e||!e.tupleStream),Array.isArray(e)||(e=C(e)),0===e.length&&e.push(void 0),a=0;case 1:if(!(a<e.length)){u.n=10;break}h=e[a],l=s?B(n,h):n,d=0;case 2:if(!(d<t.lhs.length)){u.n=9;break}return p=t.lhs[d],u.d(c(q(p[0],s?h["@"]:h,l)),3);case 3:if("string"==typeof(y=u.v)||void 0===y){u.n=4;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:y};case 4:if(void 0===y){u.n=8;break}if("_jsonata_lambda"!==y&&"_jsonata_function"!==y){u.n=5;break}throw{code:"D1013",stack:(new Error).stack,position:t.position,value:y};case 5:if(g={data:h,exprIndex:d},!Object.prototype.hasOwnProperty.call(o,y)){u.n=7;break}if(o[y].exprIndex===d){u.n=6;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:y};case 6:o[y].data=f.append(o[y].data,h),u.n=8;break;case 7:o[y]=g;case 8:d++,u.n=2;break;case 9:a++,u.n=1;break;case 10:_=r(o);case 11:if((w=_()).done){u.n=13;break}return y=w.value,g=o[y],m=g.data,l=n,s&&(b=ft(g.data),m=b["@"],delete b["@"],l=B(n,b)),u.d(c(q(t.lhs[g.exprIndex][1],m,l)),12);case 12:void 0!==(x=u.v)&&(i[y]=x),u.n=11;break;case 13:return u.a(2,i)}},v)}function ft(t){if(!Array.isArray(t))return t;var e=Object.create(null);Object.assign(e,t[0]);for(var n=1;n<t.length;n++){var r,i=o(d.keys(t[n]));try{for(i.s();!(r=i.n()).done;){var s=r.value;e[s]=f.append(e[s],t[n][s])}}catch(t){i.e(t)}finally{i.f()}}return e}function dt(t,e){var n;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;if(t>e)return n;var r=e-t+1;if(r>1e7)throw{code:"D2014",stack:(new Error).stack,value:r};n=new Array(r);for(var i=t,o=0;i<=e;i++,o++)n[o]=i;return n.sequence=!0,n}function pt(t,e,n){var r;return u().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(q(t.rhs,e,n)),1);case 1:return r=i.v,n.bind(t.lhs.value,r),i.a(2,r)}},x)}function yt(t,e,n){var r,i;return u().w(function(o){for(;;)switch(o.n){case 0:return o.d(c(q(t.condition,e,n)),1);case 1:if(i=o.v,!f.boolean(i)){o.n=3;break}return o.d(c(q(t.then,e,n)),2);case 2:r=o.v,o.n=5;break;case 3:if(void 0===t.else){o.n=5;break}return o.d(c(q(t.else,e,n)),4);case 4:r=o.v;case 5:return o.a(2,r)}},_)}function gt(t,e,n){var r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:i=Nt(n),o=0;case 1:if(!(o<t.expressions.length)){s.n=4;break}return s.d(c(q(t.expressions[o],e,i)),2);case 2:r=s.v;case 3:o++,s.n=1;break;case 4:return s.a(2,r)}},w)}function mt(t){var e=new $t.RegexEngine(t.value),n=function(r,i){var o;e.lastIndex=i||0;var s=e.exec(r);if(null!==s){if(o={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var a=1;a<s.length;a++)o.groups.push(s[a]);o.next=function(){if(!(e.lastIndex>=r.length)){var i=n(r,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return o};return n}function bt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function vt(t,e,n){var r,o,s,a,h;return u().w(function(l){for(;;)switch(l.n){case 0:return o=e,s=!!e.tupleStream,a=u().m(function e(r,o){var a,h,l,f,d,p,y,g,m;return u().w(function(e){for(;;)switch(e.n){case 0:a=0,h=0;case 1:if(!(0===a&&h<t.terms.length)){e.n=11;break}return l=t.terms[h],f=r,d=n,s&&(f=r["@"],d=B(n,r)),e.d(c(q(l.expression,f,d)),2);case 2:return p=e.v,f=o,d=n,s&&(f=o["@"],d=B(n,o)),e.d(c(q(l.expression,f,d)),3);case 3:if(y=e.v,g=i(p),m=i(y),"undefined"!==g){e.n=4;break}return a="undefined"===m?0:1,e.a(3,10);case 4:if("undefined"!==m){e.n=5;break}return a=-1,e.a(3,10);case 5:if(!("string"!==g&&"number"!==g||"string"!==m&&"number"!==m)){e.n=6;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?p:y};case 6:if(g===m){e.n=7;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:y};case 7:if(p!==y){e.n=8;break}return e.a(3,10);case 8:a=p<y?-1:1;case 9:!0===l.descending&&(a=-a);case 10:h++,e.n=1;break;case 11:return e.a(2,1===a)}},e)}),h={environment:n,input:e},l.d(c(f.sort.apply(h,[o,a])),1);case 1:return r=l.v,l.a(2,r)}},k)}function xt(t,e,n){return Rt(u().m(function e(r){var s,a,h,l,f,p,y,g,m,b,v,x,_;return u().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==r){e.n=1;break}return e.a(2,void 0);case 1:if(s=n.lookup("clone"),N(s)){e.n=2;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 2:return e.d(c(Mt(s,[r],null,n)),3);case 3:return a=e.v,e.d(c(q(t.pattern,a,n)),4);case 4:if(void 0===(h=e.v)){e.n=12;break}Array.isArray(h)||(h=[h]),l=0;case 5:if(!(l<h.length)){e.n=12;break}return f=h[l],e.d(c(q(t.update,f,n)),6);case 6:if(p=e.v,"undefined"===(y=i(p))){e.n=8;break}if("object"===y&&null!==p&&!Array.isArray(p)){e.n=7;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:p};case 7:g=o(d.keys(p));try{for(g.s();!(m=g.n()).done;)b=m.value,f[b]=p[b]}catch(t){g.e(t)}finally{g.f()}case 8:if(void 0===t.delete){e.n=11;break}return e.d(c(q(t.delete,f,n)),9);case 9:if(void 0===(v=e.v)){e.n=11;break}if(x=v,Array.isArray(v)||(v=[v]),P(v)){e.n=10;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:x};case 10:for(_=0;_<v.length;_++)"object"===i(f)&&null!==f&&delete f[v[_]];case 11:l++,e.n=5;break;case 12:return e.a(2,a)}},e)}),"<(oa):o>")}var _t=p("function($f, $g) { function($x){ $g($f($x)) } }");function wt(t,e,n){var r,i,o,s;return u().w(function(a){for(;;)switch(a.n){case 0:return a.d(c(q(t.lhs,e,n)),1);case 1:if(i=a.v,"function"!==t.rhs.type){a.n=3;break}return a.d(c(kt(t.rhs,e,n,{context:i})),2);case 2:r=a.v,a.n=10;break;case 3:return a.d(c(q(t.rhs,e,n)),4);case 4:if(o=a.v,N(o)){a.n=5;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 5:if(!N(i)){a.n=8;break}return a.d(c(q(_t,null,n)),6);case 6:return s=a.v,a.d(c(Mt(s,[i,o],null,n)),7);case 7:r=a.v,a.n=10;break;case 8:return a.d(c(Mt(o,[i],null,n)),9);case 9:r=a.v;case 10:return a.a(2,r)}},M)}function kt(t,e,n,r){var o,s,a,h,l,f,d;return u().w(function(p){for(;;)switch(p.p=p.n){case 0:return p.d(c(q(t.procedure,e,n)),1);case 1:if(void 0!==(s=p.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){p.n=2;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 2:a=[],void 0!==r&&a.push(r.context),h=u().m(function r(){var i,o;return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(q(t.arguments[l],e,n)),1);case 1:i=r.v,N(i)?(o=u().m(function t(){var e,r,o,s=arguments;return u().w(function(t){for(;;)switch(t.n){case 0:for(e=s.length,r=new Array(e),o=0;o<e;o++)r[o]=s[o];return t.d(c(Mt(i,r,null,n)),1);case 1:return t.a(2,t.v)}},t)}),o.arity=$(i),a.push(o)):a.push(i);case 2:return r.a(2)}},r)}),l=0;case 3:if(!(l<t.arguments.length)){p.n=5;break}return p.d(c(h()),4);case 4:l++,p.n=3;break;case 5:return f="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,p.p=6,"object"===i(s)&&(s.token=f,s.position=t.position),p.d(c(Mt(s,a,e,n)),7);case 7:o=p.v,p.n=9;break;case 8:throw p.p=8,(d=p.v).position||(d.position=t.position),d.token||(d.token=f),d;case 9:return p.a(2,o)}},S,null,[[6,8]])}function Mt(t,e,n,r){var i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:return u.d(c(St(t,e,n,r)),1);case 1:i=u.v;case 2:if(!D(i)||!0!==i.thunk){u.n=9;break}return u.d(c(q(i.body.procedure,i.input,i.environment)),3);case 3:o=u.v,"variable"===i.body.procedure.type&&(o.token=i.body.procedure.value),o.position=i.body.procedure.position,s=[],a=0;case 4:if(!(a<i.body.arguments.length)){u.n=7;break}return h=s,u.d(c(q(i.body.arguments[a],i.input,i.environment)),5);case 5:h.push.call(h,u.v);case 6:a++,u.n=4;break;case 7:return u.d(c(St(o,s,n,r)),8);case 8:i=u.v,u.n=2;break;case 9:return u.a(2,i)}},z)}function St(t,e,n,r){var i,o,s,a;return u().w(function(u){for(;;)switch(u.p=u.n){case 0:if(u.p=0,o=e,t&&(o=At(t.signature,e,n)),!D(t)){u.n=2;break}return u.d(c(Ot(t,o)),1);case 1:i=u.v,u.n=9;break;case 2:if(!t||!0!==t._jsonata_function){u.n=5;break}if(s={environment:r,input:n},i=t.implementation.apply(s,o),!L(i)){u.n=4;break}return u.d(c(i),3);case 3:i=u.v;case 4:u.n=9;break;case 5:if("function"!=typeof t){u.n=8;break}if(i=t.apply(n,o),!L(i)){u.n=7;break}return u.d(c(i),6);case 6:i=u.v;case 7:u.n=9;break;case 8:throw{code:"T1006",stack:(new Error).stack};case 9:u.n=11;break;case 10:throw u.p=10,a=u.v,t&&(void 0===a.token&&void 0!==t.token&&(a.token=t.token),a.position=t.position||a.position),a;case 11:return u.a(2,i)}},E,null,[[0,10]])}function zt(t,e,n){var r={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(r.thunk=!0),r.apply=u().m(function t(n,i){return u().w(function(t){for(;;)switch(t.n){case 0:return t.d(c(Mt(r,i,e,n.environment)),1);case 1:return t.a(2,t.v)}},t)}),r}function Et(t,e,n){var r,i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:i=[],o=0;case 1:if(!(o<t.arguments.length)){u.n=5;break}if("operator"!==(s=t.arguments[o]).type||"?"!==s.value){u.n=2;break}i.push(s),u.n=4;break;case 2:return h=i,u.d(c(q(s,e,n)),3);case 3:h.push.call(h,u.v);case 4:o++,u.n=1;break;case 5:return u.d(c(q(t.procedure,e,n)),6);case 6:if(void 0!==(a=u.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){u.n=7;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 7:if(!D(a)){u.n=8;break}r=Tt(a,i),u.n=11;break;case 8:if(!a||!0!==a._jsonata_function){u.n=9;break}r=It(a.implementation,i),u.n=11;break;case 9:if("function"!=typeof a){u.n=10;break}r=It(a,i),u.n=11;break;case 10:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 11:return u.a(2,r)}},A)}function At(t,e,n){return void 0===t?e:t.validate(e,n)}function Ot(t,e){var n,r;return u().w(function(i){for(;;)switch(i.n){case 0:if(r=Nt(t.environment),Array.prototype.forEach.call(t.arguments,function(t,n){r.bind(t.value,e[n])}),"function"!=typeof t.body){i.n=2;break}return i.d(c(jt(t.body,r)),1);case 1:n=i.v,i.n=4;break;case 2:return i.d(c(q(t.body,t.input,r)),3);case 3:n=i.v;case 4:return i.a(2,n)}},O)}function Tt(t,e){var n=Nt(t.environment),r=[];return Array.prototype.forEach.call(t.arguments,function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?r.push(t):n.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:r,body:t.body}}function It(t,e){var n=Pt(t),r="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=p(r);return i.body=t,Tt(i,e)}function jt(t,e){var n,r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:if(n=Pt(t),r=n.map(function(t){return e.lookup(t.trim())}),i={environment:e},o=t.apply(i,r),!L(o)){s.n=2;break}return s.d(c(o),1);case 1:o=s.v;case 2:return s.a(2,o)}},T)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Rt(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=y(e)),n}function Ct(t,e){var n,r,i,o,s;return u().w(function(a){for(;;)switch(a.p=a.n){case 0:if(void 0!==t){a.n=1;break}return a.a(2,void 0);case 1:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!F(n)&&((n=C(n)).outerWrapper=!0)),a.p=2,r=p(t,!1),a.n=4;break;case 3:throw a.p=3,Lt(o=a.v),{stack:(new Error).stack,code:"D3120",value:o.message,error:o};case 4:return a.p=4,a.d(c(q(r,n,this.environment)),5);case 5:i=a.v,a.n=7;break;case 6:throw a.p=6,Lt(s=a.v),{stack:(new Error).stack,code:"D3121",value:s.message,error:s};case 7:return a.a(2,i)}},I,this,[[4,6],[2,3]])}function Ft(t){if(void 0!==t)return JSON.parse(f.string(t))}function Nt(t){var e=Object.create(null);return{bind:function(t,n){e[t]=n},lookup:function(n){var r;return Object.prototype.hasOwnProperty.call(e,n)?r=e[n]:t&&(r=t.lookup(n)),r},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}W.bind("sum",Rt(f.sum,"<a<n>:n>")),W.bind("count",Rt(f.count,"<a:n>")),W.bind("max",Rt(f.max,"<a<n>:n>")),W.bind("min",Rt(f.min,"<a<n>:n>")),W.bind("average",Rt(f.average,"<a<n>:n>")),W.bind("string",Rt(f.string,"<x-b?:s>")),W.bind("substring",Rt(f.substring,"<s-nn?:s>")),W.bind("substringBefore",Rt(f.substringBefore,"<s-s:s>")),W.bind("substringAfter",Rt(f.substringAfter,"<s-s:s>")),W.bind("lowercase",Rt(f.lowercase,"<s-:s>")),W.bind("uppercase",Rt(f.uppercase,"<s-:s>")),W.bind("length",Rt(f.length,"<s-:n>")),W.bind("trim",Rt(f.trim,"<s-:s>")),W.bind("pad",Rt(f.pad,"<s-ns?:s>")),W.bind("match",Rt(f.match,"<s-f<s:o>n?:a<o>>")),W.bind("contains",Rt(f.contains,"<s-(sf):b>")),W.bind("replace",Rt(f.replace,"<s-(sf)(sf)n?:s>")),W.bind("split",Rt(f.split,"<s-(sf)n?:a<s>>")),W.bind("join",Rt(f.join,"<a<s>s?:s>")),W.bind("formatNumber",Rt(f.formatNumber,"<n-so?:s>")),W.bind("formatBase",Rt(f.formatBase,"<n-n?:s>")),W.bind("formatInteger",Rt(l.formatInteger,"<n-s:s>")),W.bind("parseInteger",Rt(l.parseInteger,"<s-s:n>")),W.bind("number",Rt(f.number,"<(nsb)-:n>")),W.bind("floor",Rt(f.floor,"<n-:n>")),W.bind("ceil",Rt(f.ceil,"<n-:n>")),W.bind("round",Rt(f.round,"<n-n?:n>")),W.bind("abs",Rt(f.abs,"<n-:n>")),W.bind("sqrt",Rt(f.sqrt,"<n-:n>")),W.bind("power",Rt(f.power,"<n-n:n>")),W.bind("random",Rt(f.random,"<:n>")),W.bind("boolean",Rt(f.boolean,"<x-:b>")),W.bind("not",Rt(f.not,"<x-:b>")),W.bind("map",Rt(f.map,"<af>")),W.bind("zip",Rt(f.zip,"<a+>")),W.bind("filter",Rt(f.filter,"<af>")),W.bind("single",Rt(f.single,"<af?>")),W.bind("reduce",Rt(f.foldLeft,"<afj?:j>")),W.bind("sift",Rt(f.sift,"<o-f?:o>")),W.bind("keys",Rt(f.keys,"<x-:a<s>>")),W.bind("lookup",Rt(f.lookup,"<x-s:x>")),W.bind("append",Rt(f.append,"<xx:a>")),W.bind("exists",Rt(f.exists,"<x:b>")),W.bind("spread",Rt(f.spread,"<x-:a<o>>")),W.bind("merge",Rt(f.merge,"<a<o>:o>")),W.bind("reverse",Rt(f.reverse,"<a:a>")),W.bind("each",Rt(f.each,"<o-f:a>")),W.bind("error",Rt(f.error,"<s?:x>")),W.bind("assert",Rt(f.assert,"<bs?:x>")),W.bind("type",Rt(f.type,"<x:s>")),W.bind("sort",Rt(f.sort,"<af?:a>")),W.bind("shuffle",Rt(f.shuffle,"<a:a>")),W.bind("distinct",Rt(f.distinct,"<x:x>")),W.bind("base64encode",Rt(f.base64encode,"<s-:s>")),W.bind("base64decode",Rt(f.base64decode,"<s-:s>")),W.bind("encodeUrlComponent",Rt(f.encodeUrlComponent,"<s-:s>")),W.bind("encodeUrl",Rt(f.encodeUrl,"<s-:s>")),W.bind("decodeUrlComponent",Rt(f.decodeUrlComponent,"<s-:s>")),W.bind("decodeUrl",Rt(f.decodeUrl,"<s-:s>")),W.bind("eval",Rt(Ct,"<sx?:x>")),W.bind("toMillis",Rt(l.toMillis,"<s-s?:n>")),W.bind("fromMillis",Rt(l.fromMillis,"<n-s?s?:s>")),W.bind("clone",Rt(Ft,"<(oa)-:o>"));var Dt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1013:"Object property names starting with _jsonata_ are reserved for internal use: {{value}}",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Lt(t){var e=Dt[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function $t(t,e){var n,r;try{n=p(t,e&&e.recover),r=n.errors,delete n.errors}catch(t){throw Lt(t),t}var i=Nt(W),s=new Date;return i.bind("now",Rt(function(t,e){return l.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Rt(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?$t.RegexEngine=e.RegexEngine:$t.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==r){var c={code:"S0500",position:0};throw Lt(c),c}if(void 0!==e){var u;u=Nt(i);var h,l=o(d.keys(e));try{for(l.s();!(h=l.n()).done;){var f=h.value;u.bind(f,e[f])}}catch(c){l.e(c)}finally{l.f()}}else u=i;var p,y;if(u.bind("$",t),s=new Date,u.timestamp=s,Array.isArray(t)&&!F(t)&&((t=C(t)).outerWrapper=!0),"function"==typeof a){u.async=!0;var g=function(t){Lt(t),a(t,null)},m=function(t){(p=y.next(t)).done?a(null,p.value):p.value.then(m).catch(g)};y=q(n,t,u),(p=y.next()).value.then(m).catch(g)}else try{for(y=q(n,t,u),p=y.next();!p.done;)p=y.next(p.value);return p.value}catch(c){throw Lt(c),c}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,n){var r=Rt(e,n);i.bind(t,r)},ast:function(){return n},errors:function(){return r}}}return $t.parser=p,$t}();e.exports=g},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var r=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},n=function(n){var r=0,i=n.length,o=function(t,e){return{type:t,value:e,position:r}},s=function(){for(var t,e,o=r,s=0;r<i;){var a=n.charAt(r);if("/"===a&&"\\"!==n.charAt(r-1)&&0===s){if(""===(t=n.substring(o,r)))throw{code:"S0301",stack:(new Error).stack,position:r};for(r++,a=n.charAt(r),o=r;"i"===a||"m"===a;)r++,a=n.charAt(r);return e=n.substring(o,r)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(r-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(r-1)||s--,r++}throw{code:"S0302",stack:(new Error).stack,position:r}},a=function(c){if(r>=i)return null;for(var u=n.charAt(r);r<i&&" \t\n\r\v".indexOf(u)>-1;)r++,u=n.charAt(r);if("/"===u&&"*"===n.charAt(r+1)){var h=r;for(r+=2,u=n.charAt(r);"*"!==u||"/"!==n.charAt(r+1);)if(u=n.charAt(++r),r>=i)throw{code:"S0106",stack:(new Error).stack,position:h};return r+=2,u=n.charAt(r),a(c)}if(!0!==c&&"/"===u)return r++,o("regex",s());if("."===u&&"."===n.charAt(r+1))return r+=2,o("operator","..");if(":"===u&&"="===n.charAt(r+1))return r+=2,o("operator",":=");if("!"===u&&"="===n.charAt(r+1))return r+=2,o("operator","!=");if(">"===u&&"="===n.charAt(r+1))return r+=2,o("operator",">=");if("<"===u&&"="===n.charAt(r+1))return r+=2,o("operator","<=");if("*"===u&&"*"===n.charAt(r+1))return r+=2,o("operator","**");if("~"===u&&">"===n.charAt(r+1))return r+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return r++,o("operator",u);if('"'===u||"'"===u){var l=u;r++;for(var f="";r<i;){if("\\"===(u=n.charAt(r)))if(r++,u=n.charAt(r),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:r,token:u};var d=n.substr(r+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:r};var p=parseInt(d,16);f+=String.fromCharCode(p),r+=4}else{if(u===l)return r++,o("string",f);f+=u}r++}throw{code:"S0101",stack:(new Error).stack,position:r}}var y,g=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(r));if(null!==g){var m=parseFloat(g[0]);if(!isNaN(m)&&isFinite(m))return r+=g[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:r,token:g[0]}}if("`"===u){r++;var b=n.indexOf("`",r);if(-1!==b)return y=n.substring(r,b),r=b+1,o("name",y);throw r=i,{code:"S0105",stack:(new Error).stack,position:r}}for(var v,x=r;;)if(v=n.charAt(x),x===i||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===n.charAt(r))return y=n.substring(r+1,x),r=x,o("variable",y);switch(y=n.substring(r,x),r=x,y){case"or":case"in":case"and":return o("operator",y);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return r===i&&""===y?null:o("name",y)}}else x++};return a},i=function(e,i){var o,s,a=Object.create(null),c=[],u=function(){var t=[];"(end)"!==o.id&&t.push({type:o.type,value:o.value,position:o.position});for(var e=s();null!==e;)t.push(e),e=s();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},l=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(h)).id=n.value=t,n.lbp=e,a[t]=n),n},f=function(t){if(i){t.remaining=u(),c.push(t);var e=a["(error)"];return(o=Object.create(e)).error=t,o.type="(error)",o}throw t.stack=(new Error).stack,t},d=function(t,n){if(t&&o.id!==t){var r={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(r)}var i=s(n);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,h=i.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(o=Object.create(c)).value=u,o.type=h,o.position=i.position,o},p=function(t){var e,n=o;for(d(null,!0),e=n.nud();t<o.lbp;)n=o,d(),e=n.led(e);return e},y=function(t){l(t,0).nud=function(){return this}},g=function(e,n,r){var i=n||t[e],o=l(e,i);return o.led=r||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,n){var r=l(t,e);return r.led=n,r},b=function(t,e){var n=l(t);return n.nud=e||function(){return this.expression=p(70),this.type="unary",this},n};y("(end)"),y("(name)"),y("(literal)"),y("(regex)"),l(":"),l(";"),l(","),l(")"),l("]"),l("}"),l(".."),g("."),g("+"),g("-"),g("*"),g("/"),g("%"),g("="),g("<"),g(">"),g("!="),g("<="),g(">="),g("&"),g("and"),g("or"),g("in"),y("and"),y("or"),y("in"),b("-"),g("~>"),m("(error)",10,function(t){return this.lhs=t,this.error=o.error,this.remaining=u(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),g("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==o.id)for(;"operator"===o.type&&"?"===o.id?(this.type="partial",this.arguments.push(o),d("?")):this.arguments.push(p(0)),","===o.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===o.id){for(var e=o.position,n=1,i="<";n>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?n--:"<"===s.id&&n++,i+=s.value}d(">");try{this.signature=r(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this}),b("(",function(){for(var t=[];")"!==o.id&&(t.push(p(0)),";"===o.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==o.id)for(;;){var e=p(0);if(".."===o.id){var n={type:"binary",value:"..",position:o.position,lhs:e};d(".."),n.rhs=p(0),e=n}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),g("[",t["["],function(e){if("]"===o.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),g("^",t["^"],function(t){d("(");for(var e=[];;){var n={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(n.descending=!0,d(">")),n.expression=p(0),e.push(n),","!==o.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var v=function(t){var e=[];if("}"!==o.id)for(;;){var n=p(0);d(":");var r=p(0);if(e.push([n,r]),","!==o.id)break;d(",")}return d("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};b("{",v),g("{",t["{"],v),m(":=",t[":="],function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)}),g("@",t["@"],function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),g("#",t["#"],function(e){return this.lhs=e,this.rhs=p(t["#"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),g("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=p(0),":"===o.id&&(d(":"),this.else=p(0)),this}),b("|",function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===o.id&&(d(","),this.delete=p(0)),d("|"),this});var x=function(t){var e;if("function"!==t.type||t.predicate)if("condition"===t.type)t.then=x(t.then),void 0!==t.else&&(t.else=x(t.else)),e=t;else if("block"===t.type){var n=t.expressions.length;n>0&&(t.expressions[n-1]=x(t.expressions[n-1])),e=t}else e=t;else{var r={type:"lambda",thunk:!0,arguments:[],position:t.position};r.body=t,e=r}return e},_=0,w=0,k=[],M=function(t,e){switch(t.type){case"name":case"wildcard":e.level--,0===e.level&&(void 0===t.ancestor||(k[e.index].slot.label=t.ancestor.label),t.ancestor=e,t.tuple=!0);break;case"parent":e.level++;break;case"block":t.expressions.length>0&&(t.tuple=!0,e=M(t.expressions[t.expressions.length-1],e));break;case"path":t.tuple=!0;var n=t.steps.length-1;for(e=M(t.steps[n--],e);e.level>0&&n>=0;)e=M(t.steps[n--],e);break;default:throw{code:"S0217",token:t.type,position:t.position}}return e},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},z=function(t){var e=t.steps.length-1,n=t.steps[e],r=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&r.push(n.slot);for(var i=0;i<r.length;i++){var o=r[i];for(e=t.steps.length-2;o.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[o]:t.seekingParent.push(o);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];o=M(s,o)}}},E=function(t){var e;switch(t.type){case"binary":switch(t.value){case".":var n=E(t.lhs);e="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(e.seekingParent=[n.slot]);var r=E(t.rhs);"function"===r.type&&"path"===r.procedure.type&&1===r.procedure.steps.length&&"name"===r.procedure.steps[0].type&&"function"===e.steps[e.steps.length-1].type&&(e.steps[e.steps.length-1].nextFunction=r.procedure.steps[0].value),"path"===r.type?Array.prototype.push.apply(e.steps,r.steps):(void 0!==r.predicate&&(r.stages=r.predicate,delete r.predicate),e.steps.push(r)),e.steps.filter(function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type}).forEach(function(t){t.type="name"}),e.steps.filter(function(t){return!0===t.keepArray}).length>0&&(e.keepSingletonArray=!0);var o=e.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var s=e.steps[e.steps.length-1];"unary"===s.type&&"["===s.value&&(s.consarray=!0),z(e);break;case"[":var a=e=E(t.lhs),u="predicate";if("path"===e.type&&(a=e.steps[e.steps.length-1],u="stages"),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:t.position};void 0===a[u]&&(a[u]=[]);var h=E(t.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach(function(t){1===t.level?M(a,t):t.level--}),S(a,h)),a[u].push({type:"filter",expr:h,position:t.position});break;case"{":if(void 0!==(e=E(t.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:t.position};e.group={lhs:t.rhs.map(function(t){return[E(t[0]),E(t[1])]}),position:t.position};break;case"^":"path"!==(e=E(t.lhs)).type&&(e={type:"path",steps:[e]});var l={type:"sort",position:t.position};l.terms=t.rhs.map(function(t){var e=E(t.expression);return S(l,e),{descending:t.descending,expression:e}}),e.steps.push(l),z(e);break;case":=":(e={type:"bind",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.rhs);break;case"@":if(e=E(t.lhs),a=e,"path"===e.type&&(a=e.steps[e.steps.length-1]),void 0!==a.stages||void 0!==a.predicate)throw{code:"S0215",stack:(new Error).stack,position:t.position};if("sort"===a.type)throw{code:"S0216",stack:(new Error).stack,position:t.position};t.keepArray&&(a.keepArray=!0),a.focus=t.rhs.value,a.tuple=!0;break;case"#":e=E(t.lhs),a=e,"path"===e.type?a=e.steps[e.steps.length-1]:(e={type:"path",steps:[e]},void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate)),void 0===a.stages?a.index=t.rhs.value:a.stages.push({type:"index",value:t.rhs.value,position:t.position}),a.tuple=!0;break;case"~>":(e={type:"apply",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs);break;default:(e={type:t.type,value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.lhs),S(e,e.rhs)}break;case"unary":e={type:t.type,value:t.value,position:t.position},"["===t.value?e.expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),n}):"{"===t.value?e.lhs=t.lhs.map(function(t){var n=E(t[0]);S(e,n);var r=E(t[1]);return S(e,r),[n,r]}):(e.expression=E(t.expression),"-"===t.value&&"number"===e.expression.type?(e=e.expression).value=-e.value:S(e,e.expression));break;case"function":case"partial":(e={type:t.type,name:t.name,value:t.value,position:t.position}).arguments=t.arguments.map(function(t){var n=E(t);return S(e,n),n}),e.procedure=E(t.procedure);break;case"lambda":e={type:t.type,arguments:t.arguments,signature:t.signature,position:t.position};var f=E(t.body);e.body=x(f);break;case"condition":(e={type:t.type,position:t.position}).condition=E(t.condition),S(e,e.condition),e.then=E(t.then),S(e,e.then),void 0!==t.else&&(e.else=E(t.else),S(e,e.else));break;case"transform":(e={type:t.type,position:t.position}).pattern=E(t.pattern),e.update=E(t.update),void 0!==t.delete&&(e.delete=E(t.delete));break;case"block":(e={type:t.type,position:t.position}).expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(e.consarray=!0),n});break;case"name":e={type:"path",steps:[t]},t.keepArray&&(e.keepSingletonArray=!0);break;case"parent":e={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(e);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":e=t;break;case"operator":if("and"===t.value||"or"===t.value||"in"===t.value)t.type="name",e=E(t);else{if("?"!==t.value)throw{code:"S0201",stack:(new Error).stack,position:t.position,token:t.value};e=t}break;case"error":e=t,t.lhs&&(e=E(t.lhs));break;default:var d="S0206";"(end)"===t.id&&(d="S0207");var p={code:d,position:t.position,token:t.value};if(i)return c.push(p),{type:"error",error:p};throw p.stack=(new Error).stack,p}return t.keepArray&&(e.keepArray=!0),e};s=n(e),d();var A=p(0);if("(end)"!==o.id){var O={code:"S0201",position:o.position,token:o.value};f(O)}if("parent"===(A=E(A)).type||void 0!==A.seekingParent)throw{code:"S0217",token:A.type,position:A.position};return c.length>0&&(A.errors=c),A};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,n){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=t("./utils"),o=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,o=[],s=Object.create(null),a=s;n<e.length;){var c=e.charAt(n);if(":"===c)break;var u=function(){o.push(s),a=s,s=Object.create(null)},h=function(t,e,n,r){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===r){if(0===--i)break}else c===n&&i++;return o};switch(c){case"s":case"n":case"b":case"l":case"o":s.regex="["+c+"m]",s.type=c,u();break;case"a":s.regex="[asnblfom]",s.type=c,s.array=!0,u();break;case"f":s.regex="f",s.type=c,u();break;case"j":s.regex="[asnblom]",s.type=c,u();break;case"x":s.regex="[asnblfom]",s.type=c,u();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var l=h(e,n,"(",")"),f=e.substring(n+1,l);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:n};s.regex="["+f+"m]",s.type="("+f+")",n=l,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var d=h(e,n,"<",">");a.subtype=e.substring(n+1,d),n=d}n++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",y=new RegExp(p),g=function(t){var e;if(i.isFunction(t))e="f";else switch(r(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},m=function(t,e){for(var n="^",r=0,i=0;i<o.length;i++){n+=o[i].regex;var s=e.match(n);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1};r=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1}};return{definition:e,validate:function(e,n){var r="";e.forEach(function(t){r+=g(t)});var i=y.exec(r);if(i){var s=[],a=0;return o.forEach(function(r,o){var c=e[a],u=i[o+1];if(""===u)if(r.context&&r.contextRegex){var h=g(n);if(!r.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};s.push(n)}else s.push(c),a++;else u.split("").forEach(function(n){if("a"===r.type){if("m"===n)c=void 0;else{c=e[a];var i=!0;if(void 0!==r.subtype)if("a"!==n&&u!==r.subtype)i=!1;else if("a"===n&&c.length>0){var o=g(c[0]);i=o===r.subtype.charAt(0)&&0===c.filter(function(t){return g(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[r.subtype]};"a"!==n&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,r)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,n){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}var a=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter(function(t){return"string"!=typeof t}).length),e}function n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function o(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function u(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function l(t){return"object"===s(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!f(t[n],e[n]))return!1;return!0}var r=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(r.length!==i.length)return!1;for(r=r.sort(),i=i.sort(),n=0;n<r.length;n++)if(r[n]!==i[n])return!1;for(n=0;n<r.length;n++){var o=r[n];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,n=[],i=r(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;n.push(o)}}catch(t){i.e(t)}finally{i.f()}return n}function p(t){return"object"===s(t)&&null!==t?Object.keys(t):[]}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:l,getFunctionArity:c,isDeepEqual:f,stringToArray:d,keys:p}}();e.exports=a},{}]},{},[3])(3)}(eo)),eo.exports),ro=Ji(no);const io=function(t){return t};function oo(t){if(!t)return io;try{const e=ro(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Zi(t),io}}function so(t,e){if(!e)return;const n=wi(t),r=null==n?"":String(n);return Object.prototype.hasOwnProperty.call(e,r)?e[r]:e.default}const ao=t=>null==t||""===t?void 0:parseFloat(String(t));function co(t,e,n){for(const n of e)if(void 0!==n.value&&n.value===t)return n.result;const r=wi(t);if(null==r)return n;const i=Number(r);if(Number.isNaN(i))return n;for(const t of e){const e=ao(t.min),n=ao(t.max);if((void 0!==e||void 0!==n)&&(i>=(e??-1/0)&&i<(n??1/0)))return t.result}return n}function uo(t){return Number(wi(t))}function ho(t){return t}function lo(t){return function(t){const e=wi(t);return null==e?"":String(e)}(t)}function fo(t){return uo(t)}function po(t){return so(t,this.param)}function yo(t){const{param:e}=this;if(!e)return;return co(t,Object.keys(e).filter(t=>"default"!==t).map(t=>{const[n,r]=t.split("~");return{min:""===n?null:n,max:void 0===r||""===r?null:r,result:e[t]}}),e.default)}function go(t){const{param:e}=this;if(!e)return;const n=Number(e.scale??1),r=Number(e.offset??0);return uo(t)*n+r}function mo(t){return uo(t)*Math.PI/180}function bo(){}const vo=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const xo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],_o=new Array(xo.length).fill(void 0),wo=Object.getPrototypeOf(async function(){}).constructor;function ko(t,e){!function(t){for(const e of vo)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const n=function(t){return/\bawait\b/.test(t)}(t),r=new(n?wo:Function)(...e,...xo,t);return function(t,...e){return r.call(t,...e,..._o)}}function Mo(t,e,n,r,i){switch(n){case"value":return"text"===i||"string"===i?lo.bind(t):"number"===i?fo.bind(t):ho.bind(e);case"map":return po.bind(t);case"range":return yo.bind(t);case"scale":return go.bind(t);case"radian":return mo.bind(t);case"eval":return function(t){try{const e=ko(t,["value","targets","scene"]);return function(t,n){try{const r=e(this,t,n,globalThis.scene);return r&&"function"==typeof r.then?r.catch(t=>{Zi(t)}):r}catch(t){return void Zi(t)}}}catch(t){return Zi(t),bo}}(r).bind(e);default:return ho.bind(e)}}class So{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:r,param:i,accessor:o}=t;this._model=t,this.evaluator=Mo(this,this.owner,r,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=oo(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=oo(t),this.partAccessor=oo(e)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function zo(t,e,n,r){const i=e.split(".");if(1===i.length)return void(t[e]=r?{...t[e],...n}:n);const o=i[0],s=void 0!==t[o]?t[o]:"function"==typeof t.get?t.get(o):void 0,a=s?{...s}:{};let c=a;for(let t=1;t<i.length-1;t++)c[i[t]]=c[i[t]]?{...c[i[t]]}:{},c=c[i[t]];const u=i[i.length-1];c[u]=r?{...c[u],...n}:n,t[o]=a}function Eo(t,e,n,r){t.forEach(t=>zo(t,e,n,r))}function Ao(t,e,n,r){t&&"function"==typeof t.then?t.then(t=>{void 0!==n&&void 0!==r&&n._dataGeneration!==r||e(t)}).catch(t=>Zi(t)):e(t)}function Oo(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,n=this;this.mappings&&this.mappings.forEach(t=>{try{let r,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:h=!1,partial:l=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),r=this.root.findById(i)?.data||{}):r=this.data;const f=a(r);if("(root)"==o||"(key)"==o){if(null==f)return;const r=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();r.length>0&&r.forEach(r=>{Ao(t.evaluator(f[r.get("id")],[r]),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||zo(r,s,t,l)},n,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(r=>{const i=c(r);if(i){const o=this.root.findOrCreate(i);o&&Ao(t.evaluator(u(r),o),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(o,s,t,l)},n,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const r=c(f);if(r){const i=this.root.findOrCreate(r);i&&Ao(t.evaluator(u(f),i),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(i,s,t,l)},n,e)}}}}else{const r=this.root.findAll(o,this);r.length>0&&Ao(t.evaluator(f,r),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Eo(r,s,t,l)},n,e)}}catch(e){Zi(e,this,t)}})}function To(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),Oo.call(this,!0)}function Io(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new So({target:"(self)",rule:"value",...t},this))):(Zi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function jo(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function Po(t,e){this.disposeMappings(),Oo.call(this)}function Ro(t,e,n,r,i,o){e.complete?t.drawImage(e,n,r,i,o):e.addEventListener("load",()=>{this.invalidate()})}function Co(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Fo="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),No={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Do=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";No.FONT_FAMILY=e||n};let Lo;function $o(t,e,n,r,i){const{alpha:o=1}=r,s=i.fillStyle;if(t.globalAlpha*=o,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(n.x,n.y);let r,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,n="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,r=t.createLinearGradient(s*Math.cos(n+e),s*Math.sin(n+e),s*Math.cos(n),s*Math.sin(n))}else r=t.createLinearGradient((i-4)/2*Math.cos(n+e),(o-4)/2*Math.sin(n+e),(i-4)/2*Math.cos(n),(o-4)/2*Math.sin(n))}else if("radial"==s.gradientType){const e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));switch(s.center){case"center":default:r=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":r=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":r=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":r=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":r=t.createRadialGradient(i/2,o/2,0,i/2,o/2,2*e)}}(Array.isArray(s.colorStops)?s.colorStops:Array.isArray(s.gradientStops)?s.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{r.addColorStop(t.position,t.color)}catch(e){((...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))})("Invalid Color for colorstop : ",t.color),r.addColorStop(t.position,"#fff")}}),t.fillStyle=r,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==s.type&&s.image)if(s.guideOnly&&1!=i.app.mode)s.color&&(t.fillStyle=s.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);const n=i._pattern_image;if(!n||!n.width||!n.height)return;let r=0,o=0,a=0,c=0,u=e.left,h=e.top;if(!s.fitPattern){r=s.offsetX,o=s.offsetY;const t=s.width?s.width:n.width,i=s.height?s.height:n.height;switch(s.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=r+a,h+=o+c}t.translate(u,h),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-h)}}function Uo(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const r=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return r._pattern_image=r._pattern_image_origin,void t(this);let e=n.width||this.width,i=n.height||this.height;n.fitPattern&&(e=r.bounds.width,i=r.bounds.height);const o=Lo(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),r._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(n.image)}catch(t){e(t)}}function Wo(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Zi(t)})}function qo(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function Yo(t,e,n){let{strokeStyle:r,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(r&&0!=o){if(s&&(t.lineCap=s),i){const e="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=e?[0,2*o]:[o,o];break;case"square-dot":i=e?[o,2*o]:[2*o,o];break;case"dash":i=e?[3*o,2.5*o]:[4*o,1.5*o];break;case"dash-dot":i=e?[3*o,3*o,0,3*o]:[4*o,2*o,o,2*o];break;case"long-dash":i=e?[5*o,4*o]:[6*o,3*o];break;case"long-dash-dot":i=e?[5*o,3*o,0,3*o]:[6*o,2*o,o,2*o];break;case"long-dash-dot-dot":i=e?[5*o,2*o,0,2*o,0,2*o]:[6*o,o,o,o,o,o]}Array.isArray(i)||(i=[]),t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=r,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function Bo(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let r;for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function Go(t,e,n,r=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const o=e.text.substring(0,i);if(!(t.measureText(o).width+(i-1)*r<n))break}return{...e,text:e.text.substring(0,i-1)}}function Ho(t,e,n,r,i,o=0){const s=String(e).split("\n");return r?[].concat(...s.map(e=>function(t,e,n,r=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-s,u=t.measureText(a).width+(a.length-1)*r;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const n=Go(t,{...e,text:a},c,r);o.push(n),i.push(o),o=[],s=0,a=a.substring(n.text.length)}}}),o.length>0&&i.push(o),i}(t,i?Bo(e):[{text:e,bold:!1,italic:!1}],n,o))):s.map(t=>i?Bo(t):[{text:t,bold:!1,italic:!1}])}function Xo(t,e,n,r,i,o,s=0){if(!r)return[];t.save(),t.font=n;const a=Ho(t,r,e,!!i,o,s);return t.restore(),a}function Vo(t){const{fontFamily:e=No.FONT_FAMILY,bold:n=No.BOLD,italic:r=No.ITALIC,fontSize:i=No.FONT_SIZE}=t,o=[];return n&&o.push("bold"),r&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Zo(t,e){const n=t.bold||e.bold,r=t.italic||e.italic;return Vo({...t,bold:n,italic:r})}function Qo(t,e,n,r){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=No.FONT_COLOR,textAlign:c=No.TEXT_ALIGN,textBaseline:u=No.TEXT_BASELINE,textBackgroundStyle:h,fontSize:l,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:y=0}=r;i=void 0!==i?i:1,l||=No.FONT_SIZE,f||=1.2*l,t.save();const{left:g,top:m,width:b,height:v}=e;if(o&&s&&(t.translate(g+b/2,m+v/2),t.rotate(-o),t.translate(-(g+b/2),-(m+v/2))),t.beginPath(),t.font=Vo(r),!d&&p){const e=function(t,e,n,r){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of n){const n=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=r-("ellipsis"===t?o:0))){const i=Jo(e,c,r-a-("ellipsis"===t?o:0),t);return n.push(i),s.push(n),s}n.push(c),a+=i}s.push(n),a=0}return s}(p,t,n,b);n=e}const x=n.length*f;let _;switch(u){case"top":_=m,t.textBaseline="top";break;case"bottom":_=m+v-x+f,t.textBaseline="bottom";break;default:_=m+v/2-x/2+f/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,n.forEach((e,i)=>{const o=_+i*f,s=function(t,e,n,r=0){return e.reduce((e,i)=>(t.font=Zo(n,i),e+t.measureText(i.text).width+r*(i.text.length-1)),0)}(t,e,r,y);let u=g;switch(c){case"left":case"justify":u=g;break;case"right":u=g+b-s;break;case"center":u=g+(b-s)/2}if(h&&(t.fillStyle=h,function(t,e,n,r,i,o=0,s=!1,a=!0){o="number"==typeof o?{tl:o,tr:o,br:o,bl:o}:{tl:0,tr:0,br:0,bl:0,...o},t.beginPath(),t.moveTo(e+o.tl,n),t.lineTo(e+r-o.tr,n),t.quadraticCurveTo(e+r,n,e+r,n+o.tr),t.lineTo(e+r,n+i-o.br),t.quadraticCurveTo(e+r,n+i,e+r-o.br,n+i),t.lineTo(e+o.bl,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o.bl),t.lineTo(e,n+o.tl),t.quadraticCurveTo(e,n,e+o.tl,n),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-l/2-4,s+8,l+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<n.length-1&&e.length>1){const n=b-s,i=e.length-1,a=n/i;e.forEach((e,n)=>{t.font=Zo(r,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(n<i?a:0)})}else e.forEach(e=>{t.font=Zo(r,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+y})})}),t.restore()}function Jo(t,e,n,r){let i="";for(let r=0;r<e.text.length;r++){const o=i+e.text[r];if(t.measureText(o).width>n)break;i=o}return{...e,text:i+("ellipsis"===r?"…":"")}}function Ko(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Do()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Do),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Do()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Do(),Lo="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const ts=[];function es(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-n.x)/i.x,e=(e-n.y)/i.y):(t-=n.x,e-=n.y),0!==r){const n=Math.cos(-r),i=Math.sin(-r),o=t*i+e*n;t=t*n-e*i,e=o}return{x:t+n.x,y:e+n.y}}function ns(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(t-=n.x,e-=n.y,0!==r){const n=Math.cos(r),i=Math.sin(r),o=t*i+e*n;t=t*n-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+n.x,y:e*i.y+n.y}:{x:t+n.x,y:e+n.y}}function rs(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=es(t,e,n,r,i);return n&&(o.x-=n.x,o.y-=n.y),o}return es(t,e,n=n||this.rotatePoint,r,i)}function is(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=ns(t,e,void 0,r+(this._delta?.theta??0),i);return n&&(o.x+=n.x,o.y+=n.y),o}n=n||this.rotatePoint;const{theta:o=0,tx:s=0,ty:a=0,sx:c=1,sy:u=1}=this._delta||{};if(0===o&&0===s&&0===a&&1===c&&1===u)return ns(t,e,n,r,i);return ns(t+s,e+a,{x:n.x+s,y:n.y+a},r+o,{x:i.x*c,y:i.y*u})}function os(t,e,n){n=n||this.rootModel;const r=this.transcoordS2T(t,e,n);return ns(r.x,r.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function ss(t,e,n){n=n||this.rootModel,ts.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)ts.push(t);let r=this.transcoordS2P(t,e);for(let t=0;t<ts.length;t++){const e=ts[t],n=e.bounds;r.x+=n.left,r.y+=n.top,r=e.transcoordS2P(r.x,r.y)}return r}function as(t,e,n){n=n||this.rootModel,ts.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)ts.push(t);let r={x:t,y:e};for(let t=ts.length-1;t>=0;t--){const e=ts[t];r=e.transcoordP2S(r.x,r.y);const n=e.bounds;r.x-=n.left,r.y-=n.top}return r}function cs(t,e,n){const r=this.transcoordT2P(t,e,n);return this.transcoordP2S(r.x,r.y)}function us(t,e,n){const r=this.rootModel,i=this.transcoordS2T(t,e,r);return n.transcoordT2S(i.x,i.y,r)}function hs(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:r={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=n.model,s=es(t,e,r,o,i);return r&&(s.x-=r.x,s.y-=r.y),n===this?s:this.transcoordT2S(s.x,s.y,n)}function ls(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let r;if(r=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return r;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=n.model;return r=ns(r.x,r.y,void 0,o+n._delta.theta,s),i&&(r.x+=i.x,r.y+=i.y),r}function fs(t){const e=t.element,n=t.fillStyle,r=e.style;if(n)if("string"==typeof n)r.backgroundColor=n;else switch(n.type){case"pattern":if(r.backgroundImage="url("+n.image+")",r.backgroundColor="transparent",n.fitPattern?r.backgroundSize="100% 100%":n.width||n.height?r.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:r.backgroundSize="contain",n.fitPattern)r.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=n;if(i&&(r.backgroundRepeat="no-repeat"),s&&(r.backgroundColor=s),o)switch(o){case"center":r.backgroundPosition="center center";break;case"left-top":r.backgroundPosition="left top";break;case"left-bottom":r.backgroundPosition="left bottom";break;case"right-top":r.backgroundPosition="right top";break;case"right-bottom":r.backgroundPosition="right bottom";break;case"left":r.backgroundPosition="left center";break;case"right":r.backgroundPosition="right center";break;case"top":r.backgroundPosition="center top";break;case"bottom":r.backgroundPosition="center bottom"}else t||e?r.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete r.backgroundPosition}break;case"gradient":r.background=function(t,e){const n=e.colorStops,r=e.gradientType;if(n instanceof Array&&n.length>0)switch(r){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:r}=t.bounds;switch(e){case"center":return[n/2,r/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,r];default:return[n,r]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else r.background="transparent"}const ds={x:1,y:1},ps={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function ys(t,e){let n=this.bounds,r=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const r=t.call(e,n);r&&(n=r)}const{left:s,top:a,width:c,height:u}=n;let h=[{x:s,y:a},{x:s+c,y:a+u}];h=h.map(t=>ns(t.x,t.y,r,i,o));let l=h[0],f=h[1];r={x:(l.x+f.x)/2,y:(l.y+f.y)/2},h=h.map(t=>es(t.x,t.y,r,i,o)),l=h[0],f=h[1],this.bounds={left:l.x,top:l.y,width:f.x-l.x,height:f.y-l.y}}function gs(t,e,n){let r=this.path,i=this.rotatePoint;t&&(r=t.call(n,r));let o=r.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(n,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,h;r=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=r[0].x,u=h=r[0].y;for(let t=1;t<r.length;t++){const e=r[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>h&&(h=e.y)}i={x:(a+c)/2,y:(u+h)/2},i=this.toParent(i.x,i.y,s),this.path=o.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const ms=new Map;let bs=null;function vs(){bs&&(bs(),bs=null)}function xs(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var _s=new class{add(t){var e;xs(t)&&!ms.has(t)&&(ms.set(t,0),e=t?.root,bs||(bs=X.subscribe(t=>{if(0===t)return;const e=[];for(const[n,r]of ms){if(!xs(n)){e.push(n);continue}const i=r+t;i>=n.retention?e.push(n):ms.set(n,i)}for(const t of e){ms.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Zi("RetentionManager removeSelf failed:",t)}}0===ms.size&&vs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ms.keys()),metadata:{get count(){return ms.size},get preview(){return Array.from(ms.entries()).slice(0,3).map(([t,e])=>({type:t?.state?.type,id:t?.state?.id??"-",retentionMs:t?.retention,remainingMs:Math.max(0,Math.round(t?.retention-e))}))}}})))}remove(t){ms.delete(t)&&0===ms.size&&vs()}touch(t){t&&ms.has(t)&&ms.set(t,0)}dispose(){vs(),ms.clear()}get length(){return ms.size}};const ws=function(t){return t};function ks(t){const e=t.indexOf("||");let n="",r="";-1!=e&&(n=t,r=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),o=i.slice(1);return{defaultValue:r,match:t,originText:n||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:ws}}function Ms(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>ks(t))[0];if(n)return n.accessor(this.getState(n.target));const r=(e.match(/\${[^}]*}/)||[]).map(t=>ks(t))[0];if(r){const t=this.root.findById(r.target);return r.accessor(this.getState(t))}return t}function Ss(t,e){if(!t)return;const n=String(t),r=e||wi,i=(n.match(/#{(\S*)}/gi)||[]).map(t=>ks(t)),o=(n.match(/\${[^}]*}/gi)||[]).map(t=>ks(t));if(0==i.length&&0==o.length)return n;let s=n;return i.forEach(t=>{const e=r(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)}),o.forEach(t=>{const e=this.root.findById(t.target),n=r(t.accessor(e&&e.data));s=s.replace(t.match,void 0===n?"":n)}),s}function zs(t,e,n){if(!t)return;const r=n||wi,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>ks(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>ks(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(n=>{const i=r(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===i?n.defaultValue||"":i)}),s.forEach(n=>{const i=e.root.findById(n.target),o=r(n.accessor(i&&i.data));t=t.replace(n.originText,void 0===o?n.defaultValue||"":o)}),t}:void 0}class Es{constructor(){}static registerDecorator(t,e){Es.constructors.set(t,e)}static create(t,e,n={},r){const i=Es.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(r,e,n)}}function As(t,e){const n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r);if(!mt(t))return i;const o=bt(t,e,t.bulge);if(!o)return i;const s=Math.min(o.radius,i/2),a=2*Math.asin(s/o.radius);return o.radius*a}function Os(t,e){const n=t.path.slice();if(!n||!n.length)return void Zi("path should not be empty");let r=1;const i=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[r];)i.push(As(n[r-1],n[r])),r++;const o=i.reduce(function(t,e){return t+e},0);r=0;let s=0;do{s+=i[r++]}while(s/o<e);s-=i[--r];e=(e-s/o)*(o/i[r]);const a=n[r%n.length],c=n[(r+1)%n.length],{x:u,y:h}=function(t,e,n){if(mt(t)){const r=bt(t,e,t.bulge);if(r){let t=r.endAngle-r.startAngle;r.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=r.startAngle+n*t;return{x:r.cx+r.radius*Math.cos(e),y:r.cy+r.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*n),y:t.y+Math.round((e.y-t.y)*n)}}(a,c,e);return t.toScene(u,h)}function Ts(t,e){return!1}function Is({x:t,y:e},...n){const r=this.path,i=t,o=e;this.path=r.map(t=>({...t,x:t.x+i,y:t.y+o}))}function js(t){const e=t??this.center.x,{rotation:n}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-n),r&&"gradient"===r.type&&"linear"===r.gradientType){const t=ci(r);t.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({...t,x:2*e-t.x,y:t.y}))}function Ps(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}function Rs(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let r=t.width-e.width,i=t.height-e.height;r*n>i?i=r*n:r=i/n;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-r):0!=o?o=-r:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+r,height:e.height+i}}return t}function Cs(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function Fs(t){return Os(this,t||0)}function Ns(){const t=this.path;let e,n,r,i;e=n=t[0].x,r=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>n&&(n=s.x),s.y<r?r=s.y:s.y>i&&(i=s.y)}return{left:e,top:r,width:n-e,height:i-r}}function Ds(t){const e=this.bounds;if(Math.round(100*t.width)/100==Math.round(100*e.width)/100&&Math.round(100*t.height)/100==Math.round(100*e.height)/100&&Math.round(100*t.left)/100==Math.round(100*e.left)/100&&Math.round(100*t.top)/100==Math.round(100*e.top)/100)return;const n=0==e.width?1:t.width/e.width,r=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*n,y:t.top+(i.y-e.top)*r}))}function Ls(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function $s(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const n=t.x-e.x,r=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+n,y:t.y+r}))}function Us(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Ws(t){const{x:e,y:n,z:r}=t||{};this.center={x:e,y:n},isNaN(r)||this.setState("zPos",Number(r))}function qs(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function Ys(t){const{x:e,y:n,z:r}=t;this.setState({rotationX:e,rotationY:n,rotation:-r})}function Bs(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function Gs(t){const{width:e,height:n,depth:r}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:n},this.setState("depth",r)}function Hs(){return Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Xs(t){Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Vs(){return this.path}function Zs(){return this.center}function Qs(){return this.nature.mutable}function Js(){return this.nature.resizable&&!this.stuck}function Ks(){return this.nature.rotatable&&!this.stuck}Es.constructors=new Map;const ta={x:1,y:1};function ea(t,e,n){const{offsetX:r,offsetY:i,blur:o,color:s}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??ta;t.shadowOffsetX=r*a.x*Fo,t.shadowOffsetY=i*a.y*Fo,t.shadowBlur=o*a.x*Fo,t.shadowColor=s}function na(t){t.save(),this.prerender(t);const e=this.app,n=!0===t.__inHiddenSubtree;e?.isEditMode&&((function(t){const e=t?.app;if(!e?.isEditMode)return!1;const n=e.focusFilter;return!!(t.hidden||n&&!n(t))}(this)||n)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=n,t.restore()}function ra(t){const e=this.rotatePoint,{scale:n,rotation:r,shadow:i,alpha:o}=this.state,s=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(r||0)+this._delta.theta,{tx:u=0,ty:h=0}=this._delta,l=(o||1)-this._delta.fade;(u||h)&&t.translate(u,h),(1!=s||1!=a||c)&&(t.translate(e.x,e.y),1==s&&1==a||t.scale(s,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),l&&(t.globalAlpha=l),i&&ea(t,i,this)}function ia(t){}function oa(t){this.drawText(t)}function sa(t,e){t(this)}function aa(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Zi(t)})}function ca(t){!this.textHidden&&this.text&&this.hasTextProperty&&Qo(t,this.textBounds,this.textLines(t),this.state)}function ua(t,e){Yo(t,e?{...this.state,...e}:this.state)}function ha(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&($o(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function la(){return this.get("strokeStyle")}function fa(t){this.set("strokeStyle",t)}function da(){return this.getState("fillStyle")}function pa(t){this.setState("fillStyle",t)}function ya(){return this.get("fontColor")}function ga(t){this.set("fontColor",String(wi(t)))}function ma(){return this.getState("rotation")}function ba(t){this.setState("rotation",Number(wi(t)))}function va(){return this.app.isEditMode?["decotag","data-spread"]:[]}function xa(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function _a(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function wa(t){this.setState("hidden",t)}function ka(){return this.state.tag}function Ma(t){this.setState("tag",t)}function Sa(){}function za(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function Ea(){const t=this.getState("text");return null==t?"":String(t)}function Aa(t){const{textWrap:e,supportMarkdown:n}=this.state;return Xo(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function Oa(){return Vo(this.model)}function Ta(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Ia(){return this._text_substitutor||(this._text_substitutor=zs(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function ja(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,r,i,o,s,a,c,u,h,l,f,d=t.length,p=t.search(/[0-9\-\+#]/),y=p>0?t.substring(0,p):"",g=t.split("").reverse().join(""),m=g.search(/[0-9\-\+#]/),b=d-m,v=t.substring(b,b+1),x=b+("."===v||","===v?1:0),_=m>0?t.substring(x,d):"";if(n=(e="-"===(t=t.substring(p,x)).charAt(0)?-e:+e)<0?e=-e:0,r=t.match(/[^\d\-\+#]/g),i=".",o=r&&r[1]&&r[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),u=e.split("."),(!u[1]||u[1]&&u[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(o),t[0]=h.join(""),s=t[0]&&t[0].indexOf("0"),s>-1)for(;u[0].length<t[0].length-s;)u[0]="0"+u[0];else 0===+u[0]&&(u[0]="");if((e=e.split("."))[0]=u[0],c=h[1]&&h[h.length-1].length,c){for(l=e[0],g="",b=l.length%c,d=l.length,x=0;x<d;x++)g+=l.charAt(x),!((x-b+1)%c)&&x<d-c&&(g+=o);e[0]=g}return e[1]=t[1]&&e[1]?"."+e[1]:"",r=e.join(""),"0"!==r&&""!==r||(n=!1),f="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",y+(f+r)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function Pa(t){delete this._text_substitutor;const e=wi(t);this.setState("text",null==e?"":String(e))}function Ra(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:r}=this.state;r||=0,t||=0,e||=0,n||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-n,0),height:Math.max(a-t-r,0)}}function Ca(){return 0}function Fa(){return!!this._textHidden}function Na(t){this._textHidden=!!t,this.invalidate()}function Da(){return!0}function La(t){return t}function $a(t){return Math.pow(t,2)}function Ua(t){return 1-Math.sin(Math.acos(t))}function Wa(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function qa(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function Ya(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var Ba={linear:La,quad:$a,circ:Ua,back:Wa,bounce:qa,elastic:Ya},Ga=Object.freeze({__proto__:null,back:Wa,bounce:qa,circ:Ua,default:Ba,elastic:Ya,linear:La,quad:$a});class Ha{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:r,ease:i}=this.config;let o;o="string"==typeof n?Ba[n]:n,this.delta="out"===i?function(t,e){return function(n){return 1-t(1-n,e)}}(o,r):"inout"===i?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(o,r):o,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:r=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>X.simTime,u=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==s&&(s=c(),this.client?.touch?.());const h=c()-s,l=Math.max((h-e)%(t+r),0)/t,f=r<=0&&a>l;if(a=l,l>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(i),void(s=0);if(r>0)return this._unsub?.(),this._unsub=null,void(this._timeout=setTimeout(()=>{this._timeout=null,this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(()=>{this._timeout=null,this._started&&(this._unsub=X.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}}))},r/2)},r/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.()};this._unsub=X.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}})}stop(t){this._unsub&&(this._unsub(),this._unsub=null),this._timeout&&clearTimeout(this._timeout),this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const Xa={rotation:class extends Ha{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Ha{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let r=t*n;t<1/4?r*=-1:t<3/4?r-=2*e:r=n-r,this.client.delta?.("theta",r)}},heartbeat:class extends Ha{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let r;r=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:r,sy:r,sz:r})}},moving:class extends Ha{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends Ha{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let r={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(r=i);const{tx:o,ty:s}=r,a=n.outline(t),{x:c,y:u}=this.client.center,h=this.client.toScene(c,u);this.client.delta({tx:a.x-h.x+o,ty:a.y-h.y+s})}},fade:class extends Ha{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,r=Math.max(Math.min(e,n,1),0),i=2*(Math.min(Math.max(e,n,1),1)-r);let o;o=t<.5?i*t:(1-t)*i,this.client.delta?.("fade",o)}},waypoint:class extends Ha{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,r=t.center,{x:i,y:o}=e.toScene(n.x,n.y),{x:s,y:a}=t.toScene(r.x,r.y);this._startX=i,this._startY=o,this._endX=s,this._endY=a;const c=this.config.yawOffset??Math.PI/2,u=Math.atan2(a-o,s-i)+c;this.client.location={x:i,y:o},this.client.setState("rotation",u),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};const Va={gradation:function(t,e,n){const{subType:r,from:i,to:o,colors:s}=n;let a;switch(r){case"linear":default:a=e.createLinearGradient(i.x,i.y,o.x,o.y);break;case"radial":a=e.createRadialGradient(i.x,i.y,i.r,o.x,o.y,o.r)}s&&(s.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:ea};function Za(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:n,component:r,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:h}=t;let l;l="string"==typeof h?Ga[h]:h||La,"out"===n?l=function(t,e){return function(n){return 1-t(1-n,e)}}(l,c):"inout"===n&&(l=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(l,c));let f=!1,d=null;return{start:function(){if(f)return this;if(r?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const n=()=>X.simTime;return d=X.subscribe(()=>{if(!f)return;if(r?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=n());const o=(n()-t)/e,a=u?o%1:Math.min(o,1);i(l(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:r,metadata:{duration:e,repeat:u}}),this},stop:function(){return f=!1,d&&(d(),d=null),a&&a(),this}}}({component:this,...t}),this._animate}function Qa(t,e){return function(t,e,n){const r=Va[n.type];r&&r(t,e,n)}(this,t,e)}const Ja=100;function Ka(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Ja)/Ja}return e}}function tc(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*Ja)/Ja):delete t[e]:"object"==typeof n&&tc(n)}return t}function ec(...t){return JSON.stringify(this.hierarchy,Ka,...t)}function nc(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function rc(t){this.rootModel.closeScene(t)}function ic(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function oc(){this.parent&&this.parent.invalidate()}function sc(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function ac(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function cc(){return this.getState("data")}function uc(t){this.setState("data",t),this.touch()}function hc(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function lc(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function fc(){return Number(this.get("retention"))||0}function dc(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const n=e.type?Xa[e.type]:void 0;return n?new n(t,e):null}(this,t.oncreate))}return this._animation}}function pc(){return!!this.animation?.started}function yc(t){this.animation&&(this.animation.started=t)}function gc(){}function mc(t,e,n,r){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function bc(t,e,n,r){return t==e.get("type")}function vc(t,e,n,r,i,o){return t(e,n,r,i)&&o.push(n),n.components&&n.components.forEach(n=>{vc(t,e,n,r,i,o)}),o}function xc(t,e,n,r){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function _c(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let r;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":r=mc;break;case"(":r=xc;break;default:r=bc}return vc(r,t,e,n,e,[])}function wc(t,...e){if(t(this,...e))return this}function kc(t,...e){return"string"==typeof t?_c(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function Mc(t,e,n){if(!this.capturable||n?.(this))return!1;const r=this.fromParent(t,e);return this.contains(r.x,r.y)?this:void 0}function Sc(t){return this.anchors.find(e=>e.name===t)}function zc(t){return!0}function Ec(t){return this._parent.getContext(t??this)}function Ac(){return this.isRoot()?this:this.parent&&this.parent.root}function Oc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Tc(){return this._parent}function Ic(t){this._parent=t}function jc(){return this.nature.anchors||[]}function Pc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Rc(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function Cc(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function Fc(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Nc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Dc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Lc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const $c={},Uc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Wc=[],qc=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Yc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let Bc=0;const Gc={};const Hc=new FinalizationRegistry(t=>{!function(t){Bc--;let e=Gc[t];e||(e=Gc[t]={up:0,down:0}),e.down++}(t)});class Xc{static get nature(){return Uc}static register(t,e){if(!e)return $c[t];$c[t]=e}static types(){return Object.keys($c)}static get residents(){return Gc}static get residentsCount(){return Bc}static registerDecorator(t,e){Es.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},n=[];for(const r of Object.keys(t)){const i=e[r];if(!i)continue;const o=t[r];if(o&&"object"==typeof o){if("script"===o.action){const t="string"==typeof o.value?o.value:o.value&&"object"==typeof o.value?o.value.script:"";t&&n.push({trigger:i,action:"script",code:t,target:o.target});continue}n.push({trigger:i,action:o.action,target:o.target,value:o.value,options:{emphasize:o.emphasize,restore:o.restore,pressed:o.pressed,...o.options??{}}})}}return n}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=ci(Yc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??!0))&&(this.animation.started=!0),this.clearCache(),_s.add(this),function(t){Bc++;let e=Gc[t];e||(e=Gc[t]={up:0,down:0}),e.up++}(this._model.type),Hc.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),_s.touch(this)}clearCache(...t){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=ci(Yc))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&_s.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&_s.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get refid(){return this.get("refid")}get hierarchy(){const t=ci(this._model);return this.volatile.forEach(e=>{delete t[e]}),tc(t)}get volatile(){return Wc}_applyProps(t,e,n){const r={},i={};let o=!1;const s=ci(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=n.getBeforeVal(e),u=s[e];!n.sensitive&&function(t,e){return Dn(t,e)}(c,u)||(i[e]=c,r[e]=u,t[e]=u,n.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(r).some(t=>!qc.has(t))&&this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(r,i),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,i),n.afterFillStyle&&n.afterFillStyle(r,i),r.hasOwnProperty("data")&&this.onchangeData(r,i),this.onchange&&this.onchange(r,i),this.trigger("change",r,i)}return this}contains(t,e){return Ts.call(this,t,e)}move(t,...e){Is.call(this,t,...e)}symmetryX(t){js.call(this,t)}symmetryY(t){Ps.call(this,t)}adjustResize(t,e,n){return Rs.call(this,t,e,n)}adjustRotation(t,e){return Cs.call(this,t,e)}outline(t){return Fs.call(this,t)}get bounds(){return Ns.call(this)}set bounds(t){Ds.call(this,t)}get center(){return Ls.call(this)}set center(t){$s.call(this,t)}get location(){return Us.call(this)}set location(t){Ws.call(this,t)}get rotate(){return qs.call(this)}set rotate(t){Ys.call(this,t)}get dimension(){return Bs.call(this)}set dimension(t){Gs.call(this,t)}get path(){return Hs.call(this)}set path(t){Xs.call(this,t)}get drawPath(){return Vs.call(this)}get rotatePoint(){return Zs.call(this)}get mutable(){return Qs.call(this)}get resizable(){return Js.call(this)}get rotatable(){return Ks.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&na.call(this,t)}prerender(t){ra.call(this,t)}render(t){ia.call(this,t)}postrender(t){oa.call(this,t)}prepare(t,e){sa.call(this,t,e)}prepareIf(t){aa.call(this,t)}drawText(t){ca.call(this,t)}drawStroke(t,e){ua.call(this,t,e)}drawFill(t,e){ha.call(this,t,e)}get strokeStyle(){return la.call(this)}set strokeStyle(t){fa.call(this,t)}get fillStyle(){return da.call(this)}set fillStyle(t){pa.call(this,t)}get fontColor(){return ya.call(this)}set fontColor(t){ga.call(this,t)}get rotation(){return ma.call(this)}set rotation(t){ba.call(this,t)}get decorators(){return va.call(this)}get decotag(){return xa.call(this)}get hidden(){return _a.call(this)}set hidden(t){wa.call(this,t)}get tag(){return ka.call(this)}set tag(t){Ma.call(this,t)}get appendum(){return Sa.call(this)}set appendum(t){za.call(this,t)}defaultTextSubstitutor(){return Ea.call(this)}textLines(t){return Aa.call(this,t)}get font(){return Oa.call(this)}get lineHeight(){return Ta.call(this)}get textSubstitutor(){return Ia.call(this)}get text(){return ja.call(this)}set text(t){Pa.call(this,t)}get textBounds(){return Ra.call(this)}get textRotation(){return Ca.call(this)}get textHidden(){return Fa.call(this)}set textHidden(t){Na.call(this,t)}get hasTextProperty(){return Da.call(this)}animate(t){return Za.call(this,t)}effect(t,e){return Qa.call(this,t,e)}serialize(...t){return ec.call(this,...t)}trim(){nc.call(this)}closeScene(t){rc.call(this,t)}delta(t,e){return ic.call(this,t,e)}invalidate(){oc.call(this)}get value(){return sc.call(this)}set value(t){ac.call(this,t)}get data(){return cc.call(this)}set data(t){uc.call(this,t)}set tap(t){hc.call(this,t)}get mappings(){return lc.call(this)}get retention(){return fc.call(this)}get animation(){return dc.call(this)}get started(){return pc.call(this)}set started(t){yc.call(this,t)}get controls(){return gc.call(this)}findFirst(t,...e){return wc.call(this,t,...e)}findAll(t,...e){return kc.call(this,t,...e)}capture(t,e,n){return Mc.call(this,t,e,n)}findAnchor(t){return Sc.call(this,t)}isDescendible(t){return zc.call(this,t)}getContext(t){return Ec.call(this,t)}get root(){return Ac.call(this)}get rootModel(){return Oc.call(this)}get parent(){return Tc.call(this)}set parent(t){Ic.call(this,t)}get anchors(){return jc.call(this)}get scalable(){return Pc.call(this)}get stuck(){return Rc.call(this)}get capturable(){return Cc.call(this)}get position(){return Fc.call(this)}get origin(){return Nc.call(this)}get offset(){return Dc.call(this)}get app(){return Lc.call(this)}drawEffect(t){Co.call(this,t)}prepareFill(t,e){Uo.call(this,t,e)}prepareFillIf(t){Wo.call(this,t)}onchangeFill(t,e){qo.call(this,t,e)}drawImage(t,e,n,r,i,o){Ro.call(this,t,e,n,r,i,o)}mutateBounds(t,e){ys.call(this,t,e)}mutatePath(t,e,n){gs.call(this,t,e,n)}access(t){return Ms.call(this,t)}substitute(t,e){return Ss.call(this,t,e)}onchangeMappings(t,e){Po.call(this,t,e)}onchangeData(t,e){To.call(this,t,e)}buildMappings(){Io.call(this)}executeMappings(t){Oo.call(this,t)}disposeMappings(){jo.call(this)}ondropfile(t,e){Ko.call(this,t,e)}transcoordS2P(t,e,n){return is.call(this,t,e,n)}transcoordP2S(t,e,n){return rs.call(this,t,e,n)}transcoordS2T(t,e,n){return ss.call(this,t,e,n)}transcoordT2P(t,e,n){return as.call(this,t,e,n)}transcoordT2S(t,e,n){return cs.call(this,t,e,n)}transcoordS2TR(t,e,n){return os.call(this,t,e,n)}transcoordS2O(t,e,n){return us.call(this,t,e,n)}transcoordC2S(t,e,n){return hs.call(this,t,e,n)}transcoordS2C(t,e,n){return ls.call(this,t,e,n)}toParent(t,e,n){return is.call(this,t,e,n)}fromParent(t,e,n){return rs.call(this,t,e,n)}toScene(t,e,n){return ss.call(this,t,e,n)}fromScene(t,e,n){return cs.call(this,t,e,n)}toLocal(t,e,n){return hs.call(this,t,e,n)}toGlobal(t,e,n){return ls.call(this,t,e,n)}toOther(t,e,n){return us.call(this,t,e,n)}on(t,e,n){return Yi.call(this,t,e,n)}off(t,e,n){return Bi.call(this,t,e,n)}once(t,e,n){return Gi.call(this,t,e,n)}trigger(t,...e){return Hi.call(this,t,...e)}delegate_on(t){return Xi.call(this,t)}delegate_off(t){return Vi.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get unitScale(){return 1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}Xc.capabilities=[],Xc.requires3d=!1,Xc.union=function(t){let e=0,n=0,r=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),n=Math.min(t.top,n),r=Math.max(t.left+t.width,r),i=Math.max(t.top+t.height,i)):(e=t.left,n=t.top,r=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:n,width:r-e,height:i-n}},Xc.transcoordR=es,Xc.transcoordRR=ns,Xc.createCanvas=Lo,Xc.memoize=function(t,e,n){const r=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!r?.get)return void Zi(`${String(e)} is not defined in ${t.constructor.name}`);const i=r.get,o={get:n?function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};r.set&&(o.set=r.set),Object.defineProperty(t,e,o)},Xc.mixin=function t(e,n){if(n instanceof Array)n.forEach(n=>t(e,n));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(n)>=0)return e;if(e.mixingIn.indexOf(n)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(n),n.call(e),e.mixingIn.pop(),e.mixedIn.push(n)}return e},Xc.drawText=Qo,Xc.font=Vo,Xc.textLines=Xo,Xc.drawStroke=Yo,Xc.drawFill=$o,Xc.reposition=function(t){let{id:e,scale:n=ds,bold:r,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:h,paddingLeft:l,paddingRight:f,fontSize:d=No.FONT_SIZE,lineWidth:p=0,lineHeight:y,lineDash:g}=t.state;h||=0,u||=0,l||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:_}=t,{left:w,top:k,width:M,height:S}=t.bounds,z=t.element;if(z.hidden=!t.app?.isEditMode&&_,e&&(z.id=e),m&&(z.className=m),Object.assign(z.style,ps,{fontFamily:o,fontSize:d+"px",width:M+"px",height:S+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:h+"px",paddingLeft:l+"px",border:p+"px",borderColor:b,borderStyle:p>0?g||No.LINE_DASH:"",color:x,fontWeight:r?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===y?"":y+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),fs(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,r=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${n}px ${r}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const E=t.delta(),A=(n&&n.x||1)*E.sx,O=(n&&n.y||1)*E.sy,T=(v||0)+E.theta,I=E.tx||0,j=E.ty||0;z.style.transform=`rotate(${T}rad) translate(${I}px, ${j}px) scale(${A}, ${O}) perspective(1px)`},Xc.RetentionManager=_s,Xc.template=function(t,e,n){var r=Or.imports._.templateSettings||Or;n&&nr(t,e,n)&&(e=void 0),t=zr(t),e=ir({},e,r,gr);var i=ir({},e.imports,r.imports,gr),o=yn(i),s=function(t,e){return dr(e,function(e){return t[e]})}(i,o);Ln(o,function(t){if(Pr.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,u=0,h=e.interpolate||Cr,l="__p += '",f=RegExp((e.escape||Cr).source+"|"+h.source+"|"+(h===vr?Rr:Cr).source+"|"+(e.evaluate||Cr).source+"|$","g"),d=Nr.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,n,r,i,o,s){return r||(r=i),l+=t.slice(u,s).replace(Fr,br),n&&(a=!0,l+="' +\n__e("+n+") +\n'"),o&&(c=!0,l+="';\n"+o+";\n__p += '"),r&&(l+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=s+e.length,e}),l+="';\n";var p=Nr.call(e,"variable")&&e.variable;if(p){if(Pr.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(c?l.replace(Tr,""):l).replace(Ir,"$1").replace(jr,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=fr(function(){return Function(o,d+"return "+l).apply(void 0,s)});if(y.source=l,lr(y))throw y;return y},Xc.buildSubstitutor=zs,["rotatePoint","font","lineHeight","retention"].forEach(t=>Xc.memoize(Xc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Xc.memoize(Xc.prototype,t,!0));const Vc=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]),Zc={},Qc=new WeakMap;function Jc(t){return class extends t{_itemsFromData(){return!0}_currentKeyOf(t){const e=t?.[Y];return null!=e?String(e):null}_keyedById(){return!1}async ready(){if(await super.ready(),!this._itemsFromData())return;const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)&&this._itemsFromData()){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(!this._itemsFromData())return this.state?.data;if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=this._keyedById(),n=new Map;for(const e of t){const t=this._recordKey(e);t&&n.set(t,e)}const r=new Map;for(const t of this._items){const e=this._currentKeyOf(t);null!=e&&r.set(e,t)}const i=e?(t=>{const e=t?.root??Zc;let n=Qc.get(e);return n||Qc.set(e,n=new Map),n})(this):null;for(const[t,o]of r)if(!n.has(t))if(e)setTimeout(()=>{if(o.parent===this){try{this.removeItem(o,!0)}catch{}try{o?.dispose?.()}catch{}i.get(t)?.carrier===o&&i.delete(t)}},0);else{try{this.removeItem(o,!0)}catch{}try{o?.dispose?.()}catch{}}for(const[t,e]of n){if(r.has(t))continue;if(null==e.itemId)continue;const n=i?.get(t),o=n&&n.holder!==this&&n.carrier?.parent===n.holder?n.carrier:this._createItemFromRecord(e);if(o){o[Y]=e.slotId;try{this.handoverIn(o,e.slotId?{slotId:e.slotId}:void 0)}catch{}i?.set(t,{holder:this,carrier:o})}}for(const[t,i]of n){const n=r.get(t);if(n){if(i.itemState&&"function"==typeof n.setState)try{n.setState(i.itemState)}catch{}if(e&&n[Y]!==i.slotId){n[Y]=i.slotId;try{this.handoverIn(n,i.slotId?{slotId:i.slotId}:void 0)}catch{}}}}e&&this._orderItemsAs([...n.keys()])}_orderItemsAs(t){const e=new Map(t.map((t,e)=>[t,e])),n=this._items.filter(t=>e.has(this._currentKeyOf(t)??"")),r=[...n].sort((t,n)=>e.get(this._currentKeyOf(t))-e.get(this._currentKeyOf(n)));if(r.every((t,e)=>t===n[e]))return;let i=0;for(let t=0;t<this._items.length;t++)e.has(this._currentKeyOf(this._items[t])??"")&&(this._items[t]=r[i++]);const o=this.seatHeldItem;if("function"==typeof o)for(const t of r)o.call(this,t,{slotId:t[Y]})}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,r=[];for(const t of this._items){const e=t[Y];null!=e?n.set(String(e),t):r.push(t)}for(const r of t){const t=n.get(r)??null;e.push(this._slotRecordOf(r,t))}for(const t of r)e.push(this._slotRecordOf("",t));for(const[r,i]of n)t.includes(r)||e.push(this._slotRecordOf(r,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const r of n)r in e&&void 0!==e[r]&&(t[r]=e[r]);return Object.keys(t).length>0?t:void 0}const r={};for(const t of Object.keys(e))Vc.has(t)||t.startsWith("_")||(r[t]=e[t]);return Object.keys(r).length>0?r:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=Xc.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}function Kc(t,e,n){return n?{code:t,path:e,params:n}:{code:t,path:e}}const tu="holder",eu=t=>"number"==typeof t&&Number.isFinite(t),nu=t=>eu(t)&&t>0,ru=t=>Number.isSafeInteger(t)&&t>0;function iu(t,e,n){const r=t?.allowed;if(r&&"object"==typeof r)for(const t of["width","depth","height"])nu(r[t])||n.push(Kc("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else n.push(Kc("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||ru(t.stackLimit)||t.stackLimit===1/0||n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||eu(t.rotation)||n.push(Kc("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||n.push(Kc("ARRAY_REQUIRED",`${e}.accepts`))}function ou(t,e={}){const n=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Kc("TIERS_REQUIRED","tiers")];const r=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const o=`tiers[${e}]`;if(!t||"object"!=typeof t)return void n.push(Kc("OBJECT_REQUIRED",o));if(ru(t.tierNo)?i.has(t.tierNo)?n.push(Kc("TIER_NUMBER_DUPLICATE",`${o}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${o}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?r&&!r.has(t.anchorId)&&n.push(Kc("ANCHOR_UNKNOWN",`${o}.anchorId`,{anchorId:t.anchorId})):n.push(Kc("ANCHOR_REQUIRED",`${o}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||n.push(Kc("MOUNT_INVALID",`${o}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])eu(t.position[e])||n.push(Kc("FINITE_NUMBER_REQUIRED",`${o}.position.${e}`));else n.push(Kc("OBJECT_REQUIRED",`${o}.position`));eu(t.rotation)||n.push(Kc("FINITE_NUMBER_REQUIRED",`${o}.rotation`));const s=t.layout;switch(s?.pattern){case"SINGLE":iu(s.slot,`${o}.layout.slot`,n);break;case"ROW":ru(s.count)||n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.count`)),nu(s.pitch)||n.push(Kc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch`)),"X"!==s.axis&&"Z"!==s.axis&&n.push(Kc("AXIS_INVALID",`${o}.layout.axis`)),iu(s.slot,`${o}.layout.slot`,n);break;case"GRID":ru(s.rows)||n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.rows`)),ru(s.cols)||n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.cols`)),nu(s.pitch?.x)||n.push(Kc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.x`)),nu(s.pitch?.z)||n.push(Kc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.z`)),iu(s.slot,`${o}.layout.slot`,n);break;case"CUSTOM":{if(!Array.isArray(s.slots)){n.push(Kc("ARRAY_REQUIRED",`${o}.layout.slots`));break}s.slots.length||n.push(Kc("SLOTS_REQUIRED",`${o}.layout.slots`));const t=new Set;s.slots.forEach((e,r)=>{const i=`${o}.layout.slots[${r}]`;ru(e?.slotNo)?t.has(e.slotNo)?n.push(Kc("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):n.push(Kc("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),eu(e?.offset?.x)&&eu(e?.offset?.z)||n.push(Kc("FINITE_NUMBER_REQUIRED",`${i}.offset`)),iu(e,i,n)});break}default:n.push(Kc("PATTERN_INVALID",`${o}.layout.pattern`))}}),n}function su(t,e=""){const n=[],r=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,n)=>r(t,`${e}[${n}]`));else if(t&&"object"==typeof t)for(const[n,i]of Object.entries(t))r(i,e?`${e}.${n}`:n)}else n.push(Kc("NOT_PERSISTABLE",e,{value:String(t)}))};return r(t,e),n}function au(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function cu(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:au(t)},(t,e)=>e+1)}function uu(t,e,n,r,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(n-1)*e+r;case"COL_MAJOR":return(r-1)*t+n;case"SERPENTINE_ROW":return(n-1)*e+(n%2==1?r:e-r+1);case"SERPENTINE_COL":return(r-1)*t+(r%2==1?n:t-n+1)}}function hu(t,e,n,r="ROW_MAJOR"){const i=n-1;switch(r){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,n=i%e+1;return{r:t,c:t%2==1?n:e-n+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,n=i%t+1;return{r:e%2==1?n:t-n+1,c:e}}}}const lu=(t,e)=>e&&0!==t?-t:t;function fu(t,e,n={}){const r=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!r||!ru(e.slot))return null;const i=r.layout;let o,s,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;o=i.slot,s={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=lu((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);o=i.slot,s="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:n}=hu(i.rows,i.cols,e.slot,i.order),r=i.origin??{x:"MIN",z:"MIN"};o=i.slot,s={x:lu((n-1-(i.cols-1)/2)*i.pitch.x,"MAX"===r.x),z:lu((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===r.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;o=t,s={...t.offset},a=t.name;break}}return{tier:r.tierNo,slotNo:e.slot,name:a,anchorId:r.anchorId,mount:r.mount,tierPosition:{...r.position},tierRotation:r.rotation,offset:s,allowed:{...o.allowed},accepts:o.accepts?[...o.accepts]:void 0,stackLimit:o.stackLimit??n.defaultStackLimit??1,rotation:o.rotation??0}}function du(t){return`t${t.tier}_s${t.slot}`}function pu(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*yu(t){for(const e of t?.tiers??[])for(const t of cu(e.layout))yield{tier:e.tierNo,slot:t}}function gu(t,e,n){if(!n)return{x:t,z:e};const r=n*Math.PI/180,i=Math.cos(r),o=Math.sin(r),s=t=>Math.round(1e9*t)/1e9;return{x:s(t*i+e*o),z:s(-t*o+e*i)}}function mu(t){const e=gu(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const bu=.05,vu=t=>!!t&&nu(t.width)&&nu(t.depth)&&nu(t.height);function xu(t,e){const n=e*Math.PI/180,r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),o=t=>Math.round(1e9*t)/1e9;return{width:o(t.width*r+t.depth*i),depth:o(t.width*i+t.depth*r)}}function _u(t,e,n=0,r=.05){if(!vu(t))return null;if(!eu(n)||!eu(r)||r<0||r>=1)return null;const i=xu(t,e.rotation),o=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-r)),s=t.height*o;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(n+s/2),z:0},rotation:0,scale:o}}function wu(t,e,n=0,r=.05){const i=_u(t,e,n,r);if(!i)return null;const o=mu(e);return{position:{x:o.position.x,y:o.position.y+i.position.y,z:o.position.z},rotation:o.rotation,scale:i.scale}}function ku(t,e,n=.05){let r=0;return t.map(t=>{const i=t?wu(t,e,r,n):null;return i&&(r+=t.height*i.scale),i})}const Mu=1e-6;function Su(t,e){const n=mu(t),r=t.allowed.width/2,i=t.allowed.depth/2,o=[[-r,-i],[r,-i],[r,i],[-r,i]].map(([t,e])=>{const r=gu(t,e,n.rotation);return{x:n.position.x+r.x,z:n.position.z+r.z}}),s=gu(1,0,n.rotation),a=gu(0,1,n.rotation),c="HANG"===t.mount?-1:1,u=[n.position.y,n.position.y+c*t.allowed.height],h=o.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:o,axes:[s,a],y0:Math.min(...u),y1:Math.max(...u),minX:Math.min(...h),maxX:Math.max(...h)}}function zu(t,e){for(const n of[...t.axes,...e.axes]){const r=t.corners.map(t=>t.x*n.x+t.z*n.z),i=e.corners.map(t=>t.x*n.x+t.z*n.z);if(Math.min(Math.max(...r),Math.max(...i))-Math.max(Math.min(...r),Math.min(...i))<=Mu)return!1}return!0}function Eu(t,e={}){const n=[],r=new Map;t.tiers.forEach((e,n)=>{const i=r.get(e.anchorId)??[];r.set(e.anchorId,i);for(const r of cu(e.layout))i.push(Su(fu(t,{tier:e.tierNo,slot:r}),n))});for(const[t,i]of r){const r=e.anchorFaces?.[t];if(r)for(const t of i)t.corners.some(t=>Math.abs(t.x)-r.width/2>Mu||Math.abs(t.z)-r.depth/2>Mu)&&n.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else n.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const o=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<o.length;t++){const e=o[t];for(let r=t+1;r<o.length&&o[r].minX<e.maxX-Mu;r++){const t=o[r];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=Mu)continue;if(!zu(e,t))continue;const[i,s]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];n.push({code:"SLOT_OVERLAP",path:`tiers[${s.tierIndex}]`,params:{tier:s.tier,slot:s.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return n}function Au(t,e,n=[],r={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=r.normalizeType??(t=>null==t?"":String(t)),o=[];let s=!1;if(t.accepts){const n=i(e.type);n?t.accepts.map(i).includes(n)||o.push("TYPE_NOT_ACCEPTED"):s=!0}if(n.length+1>t.stackLimit&&o.push("STACK_LIMIT_EXCEEDED"),vu(e.dims)){const r=xu(e.dims,t.rotation);if(r.width>t.allowed.width&&o.push("WIDTH_EXCEEDED"),r.depth>t.allowed.depth&&o.push("DEPTH_EXCEEDED"),n.every(t=>vu(t.dims))){n.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&o.push("HEIGHT_EXCEEDED")}else s=!0}else s=!0;return o.length?{verdict:"NG",reasons:s?[...o,"SPEC_UNKNOWN"]:o}:s?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}const Ou=[{id:"__default__",maxCount:1/0}];function Tu(t){const e={id:du({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function Iu(t,e){const n=e?.state?.type??e?.type;return t.accepts?!!n&&t.accepts.includes(n):!t.allowedTypes?.length||!!n&&t.allowedTypes.includes(n)}function ju(t){var e;return e=class extends t{get slotLayout(){}get slots(){const t=this.slotLayout;if(!t)return[];const e=[];for(const n of yu(t)){const r=fu(t,n);r&&e.push(Tu(r))}return e}slotById(t){const e=this.slotLayout;if(e){const n=pu(t),r=n?fu(e,n):null;return r?Tu(r):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,n=0,r){const i=this.slotLayout,o=i?pu(t):null,s=o?fu(i,o):null,a=s?wu(e,s,n,r):null;return a?{...a,anchorId:s.anchorId}:null}get arrangementStrategy(){return p}canReceive(t,e){const n=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return K.log({role:"target",contract:"canReceive",component:this,args:{carrier:U(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:Ou;for(const n of e){if(!Iu(n,t))continue;const e=n.maxCount??this.arrangementStrategy.capacity(n),r=this._countOccupied(n.id);if(!(r>=e))return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:{slotId:n.id,occupied:r,max:e}}),n}return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const n=this._realObject?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new w;n.getWorldQuaternion(r);const i=new w(e.x,e.y,e.z,e.w);return r.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,n=e?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new k;n.getWorldPosition(r);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new k(0,i,0);return n.localToWorld(t),{x:r.x,y:t.y,z:r.z}}return{x:r.x,y:r.y,z:r.z}}attachPointFor(t){const e=t?.[Y];if(!e)return null;const n=this.slots.find(t=>t.id===e);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,r=n?n.state??{}:t??{},i={width:Number(r.width)||0,height:Number(r.height)||0,depth:Number(r.depth)||0},o=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!o)return null;const s=e.index??this._countOccupied(o.id),a=e.occupantCount??s,c=this.arrangementStrategy.positionAt(s,o,a,n??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,h=Number(this.state?.height)||0,l=c.x+i.width/2-u/2,f=c.y+i.height/2-h/2,d=this._realObject,p=d?.placementMode??"floor",y="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,g=this._receivingSurfaceLocalY();let m;m=null!==g?g+y:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+y:y-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??i,o)??void 0;return b?{position:{x:l,y:m,z:f},rotation:b}:{position:{x:l,y:m,z:f}}}_zPosFromSeatY(t,e,n){const r=this._realObject,i=r?.receivingSurfaceY??0,o=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=r?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(r?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!Iu(t,e))return null;const n=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<n?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[Y]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[Y]===t).length:0}},e.__hasCapacity=!0,e}function Pu(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return[];const s="number"==typeof t.rotation?t.rotation:0,a=Math.cos(s),c=Math.sin(s),u=n+i/2,h=r+o/2,l="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/2,lz:0,odx:1,odz:0},{lx:0,lz:-o/2,odx:0,odz:-1},{lx:0,lz:o/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:u+e*a-n*c,z:h+e*c+n*a}),direction:{x:l*(t.odx*a-t.odz*c),z:l*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Ru(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return{inbounds:[],outbounds:[]};const s="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&i<o,u=n+i/2,h=r+o/2,l=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),y=Math.sin(s),g=(t,e)=>({x:u+t*p-e*y,z:h+t*y+e*p}),m=c?{lx:0,lz:-l}:{lx:-l,lz:0},b=c?{lx:0,lz:l}:{lx:l,lz:0},v=g(m.lx,m.lz),x=g(b.lx,b.lz),_={x:f*p-d*y,z:f*y+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},M={x:-k.x,z:-k.z},S=(c?i:o)/2;return a?{inbounds:[{worldPos:x,direction:M,halfSpan:S}],outbounds:[{worldPos:v,direction:M,halfSpan:S}]}:{inbounds:[{worldPos:v,direction:k,halfSpan:S}],outbounds:[{worldPos:x,direction:k,halfSpan:S}]}}function Cu(t){const e=t.left??0,n=t.top??0,r=t.width??0,i=t.height??0;if(r<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&r<i,a=e+r/2,c=n+i/2,u=s?i/2:r/2,h=Math.cos(o),l=Math.sin(o),f=(t,e)=>({x:a+t*h-e*l,z:c+t*l+e*h});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Fu(t){const e=t.cx??0,n=t.cy??0,r=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(r+r*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,h="reverse"===t.status;if(r<=0||i<=0)return{inbounds:[],outbounds:[]};const l={x:e+s*Math.sin(c),z:n-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:n-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return h?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:l,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:l,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function Nu(t){const e=Ru(t),n=e.outbounds[0];if(!n)return{inbounds:Pu(t,"inbound"),outbounds:[]};const r=Pu(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,r=t.worldPos.z-n.worldPos.z;return Math.hypot(e,r)>1}),i=n.direction,o=[];for(const t of r){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+i.x,r=t.direction.z+i.z,s=Math.hypot(n,r)||1;o.push({worldPos:t.worldPos,direction:{x:n/s,z:r/s},halfSpan:t.halfSpan})}return{inbounds:[...r,...o],outbounds:e.outbounds}}function Du(t,e,n={}){const r=n.distance??5,i=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<i)return!1;const o=t.worldPos.x-e.worldPos.x,s=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,i=t.direction.z;if(Math.abs(o*n+s*i)>r)return!1;const a=Math.abs(o*-i+s*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=r}function Lu(t,e,n,r=0){const i=n.width??0,o=n.height??0;if(i<=0||o<=0)return!1;const s=(n.left??0)+i/2,a=(n.top??0)+o/2,c="number"==typeof n.rotation?n.rotation:0,u=Math.cos(-c),h=Math.sin(-c),l=t-s,f=e-a,d=l*u-f*h,p=l*h+f*u;return Math.abs(d)<=i/2+r&&Math.abs(p)<=o/2+r}function $u(t,e,n){const r=n.width??0,i=n.height??0;if(r<=0||i<=0)return 1/0;const o=(n.left??0)+r/2,s=(n.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,h=e.z;const l="number"==typeof n.rotation?n.rotation:0;if(0!==l){const t=Math.cos(-l),e=Math.sin(-l),n=a*e+c*t,r=u*e+h*t;a=a*t-c*e,c=n,u=u*t-h*e,h=r}const f=r/2,d=i/2;let p=-1/0,y=1/0;if(Math.abs(u)<1e-9){if(a<-f||a>f)return 1/0}else{const t=(-f-a)/u,e=(f-a)/u;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/h,e=(d-c)/h;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}return y<p?1/0:p>=0?p:y>=0?Math.min(-p,y):-y}function Uu(t,e,n,r=6){return!!Lu(t.worldPos.x,t.worldPos.z,e,r)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function Wu(t,e,n){return t.outbounds.map(t=>{const r=[];for(const i of e){let e=null;for(const r of i.topology.inbounds){if(!Du(t,r,n))continue;const i=t.worldPos.x-r.worldPos.x,o=t.worldPos.z-r.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const r=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?n?.sinkMargin??30:6;if(Uu(t,i.bounds,r,o)){const n=$u(t.worldPos,t.direction,i.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(i.bounds.left??0)+(i.bounds.width??0)/2,r=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-r)+1e3}}}null!==e&&r.push({id:i.id,dist:e})}return 0===r.length?null:(r.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),r[0].id)})}function qu(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const r=new Map,i=new Set;for(const n of t){const o=t.filter(t=>t.id!==n.id),s=Wu(n.topology,o,e);r.set(n.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const o=r.get(t)??[];o.includes(e)||(o.push(e),r.set(t,o),i.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])o(e.id,t);for(const t of e.links.upstream??[])o(t,e.id)}const s=new Set,a=new Set;for(const e of t){(r.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:n,out:r,sinks:s,sources:a}}function Yu(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const r=new Set([e]);for(const i of function(t,e,n){const r=n.get(e);if(r)return r;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const n of t.out.get(e)??[])null!=n&&(i.add(n),s.has(n)||(s.add(n),o.push(n)))}return n.set(e,i),i}(t,e,n))r.add(i);return r})}function Bu(t,e,n,r){return e===n?0:function(t,e,n){const r=n.get(e);if(r)return r;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),n=i.get(e);for(const r of t.out.get(e)??[])null==r||i.has(r)||(i.set(r,n+1),o.push(r))}return n.set(e,i),i}(t,e,r).get(n)??1/0}function Gu(t,e,n){const r=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<r.length;e++){const s=r[e];if(null==s)continue;const a=s===n?0:Bu(t,s,n,i);a!==1/0&&o.push({i:e,hops:1+a})}return o.sort((t,e)=>t.hops-e.hops||t.i-e.i),o.map(t=>t.i)}function Hu(t,e,n){const r=Gu(t,e,n);return r.length?r[0]:-1}function Xu(t,e,n){return e===n||Gu(t,e,n).length>0}function Vu(t,e){const n=new Set;for(const r of Yu(t,e))for(const e of r)t.sinks.has(e)&&n.add(e);return n}function Zu(t,e,n){return Qu(t,e,n).map(t=>t.index)}function Qu(t,e,n){const r=n instanceof Set?n:new Set(n);if(0===r.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...r].sort(),a=[];for(let e=0;e<i.length;e++){const n=i[e];if(null==n)continue;let r=1/0,c="";for(const e of s){const i=1+(n===e?0:Bu(t,n,e,o));i<r&&(r=i,c=e)}r!==1/0&&a.push({index:e,hops:r,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Ju(t,e={}){const n=[],r=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const r=t.nodes.get(e);if(!r||!r.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(i.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],n=[...t.nodes.keys()].sort(),r=new Set,i=[],o=new Set,s=n=>{r.add(n),i.push(n),o.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),n=i.slice(t),r=n.indexOf([...n].sort()[0]),o=[...n.slice(r),...n.slice(0,r)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else r.has(a)||s(a);i.pop(),o.delete(n)};for(const t of n)r.has(t)||s(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of o){t.some(t=>r.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const s=e.routingWeights;if(s)for(const[t,e]of[...s].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...i].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Ku(t,e){if(!t)return[];const n=[],r=new Set,i=t=>{if(!t||r.has(t))return;if(r.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,r=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=r?String(r):void 0;if(i)try{const e=t.getSegmentTopology(),r=t.state??{},o={left:r.left,top:r.top,width:r.width,height:r.height,rotation:r.rotation};e&&n.push({id:i,topology:e,bounds:o})}catch{}}const o=t?.components;if(Array.isArray(o))for(const t of o)i(t)};return i(t),n}function th(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const r=t.getSegmentTopology();if(!r||0===r.outbounds.length)return null;const i=Wu(r,Ku(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of i)if(t)return t;return null}function eh(t){return!!t&&"function"==typeof t.routingConstraints}function nh(t){return!!t&&"function"==typeof t.acceptedCarrierData}function rh(t,e=16){const n=[],r=t.parent??t.rootModel??t.root;if(!r)return n;const i=th(t);if(!i)return n;const o=sh(r,i);if(!o)return n;const s=[{segment:o,accumulated:{},pathIds:[i],visited:new Set([i])}];for(;s.length>0;){const t=s.shift();if(t.pathIds.length>e)continue;const i=eh(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=ih(t.accumulated,i);if(!o)continue;const a=oh(t.segment,e.portId,r);a&&!t.visited.has(a.state?.id??"")?s.push({segment:a,accumulated:o,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(nh(t.segment)){const e=t.segment.acceptedCarrierData(),r=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:r});else for(const i of e){const e=ih(t.accumulated,i);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:r})}continue}const e=th(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=sh(r,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function ih(t,e){const n={...t};for(const[t,r]of Object.entries(e)){if(t in n&&n[t]!==r)return null;n[t]=r}return n}function oh(t,e,n){if("straight"===e&&t.state?.downstreamRef)return sh(n,t.state.downstreamRef);const r=sh(n,e);if(r)return r;const i=th(t);return i?sh(n,i):null}function sh(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,r=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=r(t);if(e)return e}return null};return r(t)}function ah(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function ch(t,e,n=5,r=[],i=n){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,u=[],h=new Map,l=[],f=new Map;for(const t of r){const e=Array.isArray(t),n=e?t:t.positions,r=e?void 0:t.kind;if(!n.length)continue;const i=u.length;u.push({pos:n[0],members:[]});for(const t of n)l.push({pos:t,pt:i});r&&f.set(i,r)}const d=(t,e)=>{const r=c(t,e),i=h.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of l)ah(t.pos,r)<=n&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)ah(u[t].pos,r)<=n&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:r,members:[]})),u[s].members.push({seg:t,end:e}),h.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,y=new Set,g=new Set;{const t=t=>{let e=-1,n=1/0;for(let r=0;r<u.length;r++){const i=ah(u[r].pos,t);i<n&&(n=i,e=r)}for(const r of l){const i=ah(r.pos,t);i<n&&(n=i,e=r.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:r}=t(n.pos);e>=0&&r<=i&&(p.add(e),("source"===n.kind?y:g).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?y:g).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],v=(e,n)=>{if(void 0===s[e])return s[e]=n,void b.push(e);s[e]!==n&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const n=h.get(`${t}:${e}`);if(void 0===n)continue;const r=u[n];if(2!==r.members.length||p.has(n))continue;const i=r.members[0],o=i.seg===t&&i.end===e?r.members[1]:i;if(o.seg===t)continue;const a="end"===e!==s[t],c="end"===o.end!==!a;v(o.seg,c)}},_=()=>{for(;b.length;)x(b.shift())},w=t=>{let e=-1,n="start",r=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=ah(c(i,o),t.pos);s<r&&(r=s,e=i,n=o)}if(e<0||r>i)return;const s="source"===t.kind?"end"===n:"start"===n;v(e,s)};for(const t of e)"source"===t.kind&&w(t);_();for(const t of e)"sink"===t.kind&&w(t);_();let k=!0;for(;k;){k=!1;for(const t of u){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===s[t.seg]);if(1!==e.length)continue;let n=0,r=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?n++:r++);const i=e[0];let o;0===r&&n>0?o="end"===i.end:0===n&&r>0&&(o="start"===i.end),void 0!==o&&(s[i.seg]=o,b.push(i.seg),_(),k=!0)}}if(s.some(t=>void 0===t)&&y.size>0&&g.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),n=[];for(const r of t)e[r]=0,n.push(r);for(;n.length;){const t=n.shift();for(const r of u[t].members){const i=h.get(`${r.seg}:${"start"===r.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,n.push(i))}}return e},e=t(y),n=t(g);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const r=h.get(`${t}:start`),i=h.get(`${t}:end`);if(void 0===r||void 0===i)continue;if(u[r].members.length<2||u[i].members.length<2)continue;if(e[r]===1/0||e[i]===1/0||n[r]===1/0||n[i]===1/0)continue;let o;e[r]!==e[i]?o=e[r]<e[i]:n[r]!==n[i]&&(o=n[i]<n[r]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const M=new Map;for(let e=0;e<o;e++)M.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function uh(...t){}function hh(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function lh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*fh(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*fh(t)}function dh(t,e,n){const r=e.width??0,i=e.height??0;if(r<=0||i<=0)return!1;const o=(e.left??0)+r/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,h=Math.cos(-a),l=Math.sin(-a),f=c*h-u*l,d=c*l+u*h;return Math.abs(f)<=r/2+n&&Math.abs(d)<=i/2+n}function ph(t){const e=[],n=[],r=[],i=[];for(const o of fh(t)){const t=lh(o);if(!t)continue;if(o.flowOrientable){const n=Cu(o.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof o.openings){const t=o.state??{};(t.width??0)>0&&(t.height??0)>0&&i.push(t);continue}let s;try{s=o.getSegmentTopology()}catch{continue}if(!s)continue;const a=s.inbounds??[],c=s.outbounds??[],u="function"==typeof o.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||u))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&r.push({positions:t})}}for(const t of i){const i=[];for(const n of e)for(const e of[n.start,n.end])dh(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of n)dh(e.pos,t,16)&&("sink"===e.kind?o=!0:s=!0);const a=o&&!s?"sink":s&&!o?"source":void 0;(i.length>=2||a&&i.length>=1)&&r.push({positions:i,kind:a})}if(0===e.length||0===n.length)return e.length,n.length,new Map;const o=ch(e,n,8,r,60).directions;return e.length,n.length,r.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function yh(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:ph(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const r=lh(t),i=r?n.map.get(r):void 0;return"reverse"===i||"forward"!==i&&void 0}function gh(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function mh(t,e,n,r){if(!t||!e)return null;const i=[],o=t=>{if(!t||t===r)return;if(function(t,e){const n=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(n)&&n.includes(e)}(t,e)&&gh(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(n.x,n.y)})}const s=t.components;if(Array.isArray(s))for(const t of s)o(t)};return o(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function bh(t){return!!t&&"function"==typeof t.routingDestination}function vh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*xh(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*xh(t)}function _h(t){const e=[],n=new Map,r=new Map,i=new Set,o=[];for(const s of xh(t)){"function"==typeof s?.registerWithHost&&o.push(s);const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks?s.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||bh(s)||c||gh(s)))continue;const u=vh(s);if(!u)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=s.getSegmentTopology()}catch{continue}if(!h)continue}const l=s.state??{},f={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation};if(e.push({id:u,topology:h,bounds:f,links:a}),r.set(u,s),bh(s)){i.add(u);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(u),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:r,routingTargetIds:i,stationClients:o}}function wh(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:r,components:i,routingTargetIds:o,stationClients:s}=_h(t),a=qu(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const r=[...e].sort((t,e)=>{const n=vh(t)??"",r=vh(e)??"";return n.localeCompare(r)});for(const e of r){const n=e.declaredHostRef?.();let r=null;if(n&&(r=t.findById?.(n)??null),!r){const n=e.hostCapability?.(),i=e.hostFacingPoint?.();n&&i&&(r=mh(t,n,i,e)?.component??null)}r&&"function"==typeof e.registerWithHost&&e.registerWithHost(r)}const i=e=>{if(!e)return;if(gh(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const r=t.findById?.(n);r&&e.registerDivertStation(n,r)}const n=e.components;if(Array.isArray(n))for(const t of n)i(t)};i(t)}(t,s);const c=new Set;for(const[t,e]of i){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const u=new Map;for(const t of o){const e=i.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&u.set(t,n)}}const h=Ju(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:r,components:i,issues:h},t.__flowGraph=e}return e}function kh(t){return wh(t)?.issues??[]}function Mh(t){const e=wh(t);return e&&e.graph.nodes.size>0?e.graph:null}function Sh(t,e){return wh(t)?.destToSinks.get(e)??[]}function zh(t,e){return wh(t)?.components.get(e)}function Eh(t){const e=wh(t);return e?[...e.destToSinks.keys()]:[]}function Ah(t){return vh(t)}function Oh(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function Th(t,e,n,r,i){if(1===r.length)return r[0];switch(t){case"index":default:return r[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),r[t%r.length]}case"weight":{const t=r.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(i.get(t.target))),o=t.reduce((t,e)=>t+e,0);if(o<=0)return r[0];const s=n.counters.get(e)??0;n.counters.set(e,s+1);let a=s%o;for(let e=0;e<r.length;e++){if(a<t[e])return r[e];a-=t[e]}return r[r.length-1]}case"utilization":{let t=1/0,e=r[0];for(const n of r){const r=Oh(i.get(n.target));r<t&&(t=r,e=n)}return e}}}function Ih(t,e,n){const r=t?.root;if(!r)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=wh(r);if(!o||0===o.graph.nodes.size)return null;const s=vh(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Qu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],h=c.filter(t=>{const n=u[t.index],r=n?o.components.get(n):null;return!r||"function"!=typeof r.canReceive||r.canReceive(e)});if(0===h.length)return u[c[0].index]??null;const l=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const r=e?.state?.routingBalancingPolicy;return r||"round-robin"}(t,r),f=Th(l,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(r),h,o.components);return u[f.index]??null}n({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),n({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,Mh(t)}catch{return null}}}catch{}function jh(t,e,n){const r=Ih(t,e,n);if(null==r)return null;const i=t?.root,o=zh(i,r)??i?.findById?.(r)??null;return o?{targetId:r,component:o,origin:"explicit"}:null}function Ph(t){const e=t?.root,n=Mh(e),r=Ah(t);if(!n||!r)return null;const i=(n.out.get(r)??[]).find(Boolean);if(!i)return null;const o=zh(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Rh(t){const e=Ah(t);return e?Ch(t?.root,e):[]}function Ch(t,e){if(!t||!e)return[];const n=Mh(t);if(!n)return[];const r=new Set;for(const i of Vu(n,e)){const e=zh(t,i);if(bh(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&r.add(t)}}return[...r]}function Fh(t,e){if(!t||!e)return[];const n=Mh(t);if(!n)return[];const r=new Map;for(const t of n.out.values())for(const e of t)null!=e&&r.set(e,(r.get(e)??0)+1);const i=new Map;for(const o of Vu(n,e)){const e=zh(t,o);if(!bh(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let s=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(s=t)}null===s&&(s=r.get(o)??0,0===s&&(s=1)),i.set(n,(i.get(n)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function Nh(t){return Mh(t)}function Dh(t){const e=Mh(t);if(!e)return[];const n=new Set,r=new Set,i=t=>{if(!t)return;const o=Ah(t);if(o&&e.nodes.has(o)){bh(t)&&n.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&r.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),Ju(e,{routingTargetIds:n,loopCapableIds:r})}function Lh(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let r=0;for(const e of t)if(r+=e.weight,n<r)return e.value;return t[t.length-1].value}const $h={next:jh,downstream:Ph,reachableDestinations:Rh,reachableDestinationsFrom:Ch,reachableDestinationsWeightedFrom:Fh,pickWeightedDestination:Lh,graphFor:Nh,validate:Dh};function Uh(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const r=t.prototype?.attachPointFor;return"function"==typeof r?r.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n&&(this._items.splice(n,1),t.parent=null,t._realObject?.setTransientDisplayScale?.(1),!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=t.parent;n&&("function"==typeof n.removeComponent&&-1!==n._components?.indexOf?.(t)&&n.removeComponent(t,!0),n!==this&&"function"==typeof n.removeItem&&-1!==n._items?.indexOf?.(t)&&n.removeItem(t,!0));const r=-1===this._items.indexOf(t);if(r&&this._items.push(t),t.parent=this,r&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}this.seatHeldItem(t,{toParent3D:e?.toParent3D,slotId:e?.slotId}),t.held?.(this),this._bumpReceived?.(t)}seatHeldItem(t,e={}){t.realObject;const n=t._realObject,r=n?.object3d;if(r){let i,o,s=e.toParent3D,a="world-preserve",c=1;if(!s){const n=this.attachPointFor?.(t,{slotId:e.slotId});n?.attach&&(s=n.attach,i=n.localPosition,o=n.localRotation,a=n.carryPolicy??"world-preserve",c=n.displayScale??1)}s&&r.parent!==s&&(s.updateWorldMatrix?.(!0,!1),r.updateWorldMatrix?.(!0,!1),s.attach(r),n.suppressTransform=!0),s&&(i&&r.position.set(i.x,i.y,i.z),"world-preserve"!==a?o?r.rotation.set(o.x,o.y,o.z):r.quaternion.identity():o&&r.rotation.set(o.x,o.y,o.z),n?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),n?.setTransientDisplayScale?.(c))}}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)try{e.dispose?.()}catch{}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,r,i){for(let o=this._items.length-1;o>=0;o--){const s=this._items[o],a="static"===s.position?s.capture?.(t,e,i):s.capture?.(n,r,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const r=e.bounds;!e.showOverflow&&r&&(t.beginPath(),t.rect(r.left,r.top,r.width,r.height),t.clip(),t.closePath());const{left:i=0,top:o=0}=e.state??{};t.translate(i,o),this._drawItems(t),t.translate(-i,-o),t.restore()}capture(t,e,n){const r=this,i=this._items;if(i&&i.length>0&&(!r.app||r.app.isEditMode||!r.hidden)){const i=r.fromParent?.(t,e);if(i&&r.contains?.(i.x,i.y)){const o=r.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,n);if(s)return s}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Wh(t){var e;const n=!!t.__hasCapacity,r=!!t.__hasTransferable,i=n?t:ju(t),o=r?i:function(t){var e;return(e=class extends t{reserve(t,e){const n=this.findSlot(t);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){K.log({role:"target",contract:"receive:enter",component:this,args:{carrier:U(t),options:e}});const n=this.reserve(t,e);if(!n){K.log({role:"target",contract:"receive:reject",component:this,args:{carrier:U(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,e,n={}){const r=t.slot,i=this._countOccupied(r.id),o=this.arrangementStrategy.positionAt(i,r,i,e);K.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:r.id,occupantCount:i,carrier:U(e)},result:o}),e[Y]=r.id;const s=e._realObject;let a,c;s?.object3d&&(s.object3d.updateWorldMatrix(!0,!1),a=new k,c=new w,s.object3d.getWorldPosition(a),s.object3d.getWorldQuaternion(c));const{animated:u=!1,duration:h,ease:l}=n;"function"==typeof this.handoverIn?this.handoverIn(e,{slotId:r.id}):this.reparent?.(e,{animated:u,duration:h,ease:l}),!u&&e._realObject&&(e._realObject.suppressTransform=!1);{const t={},n=this.placementFor?.(e,{slot:r,index:i,occupantCount:i})??null;if(K.log({role:"target",contract:"placementFor",component:this,args:{carrier:U(e),slotId:r.id,index:i},result:n}),n){const i=e.state??{},o=this.state??{};t.left=n.position.x-(Number(i.width)||0)/2+(Number(o.width)||0)/2,t.top=n.position.z-(Number(i.height)||0)/2+(Number(o.height)||0)/2;const s=this._zPosFromSeatY(n.position.y,i.depth,r);null!==s&&(t.zPos=s),n.rotation&&q(t,n.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=r.localPosition.z+e}const n=this.acceptanceRotation?.(e,r);K.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:U(e),slotId:r.id},result:n}),n&&q(t,n)}const s=this.normalizePose?.(e,r);"function"==typeof this.normalizePose&&K.log({role:"target",contract:"normalizePose",component:this,args:{carrier:U(e),slotId:r.id},result:s}),s&&Object.assign(t,s),Object.keys(t).length&&(e.setState?.(t),K.log({role:"target",contract:"receive:setState",component:this,args:{carrier:U(e),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:r.id,preReceiveWorldPos:a,preReceiveWorldQuat:c}),K.log({role:"target",contract:"receive:done",component:this,args:{carrier:U(e),slotId:r.id}})}async dispatch(t,e,n={}){const r=new rt({source:this,target:e,carrier:t,options:n,physical:async()=>{delete t[Y]}}),i=await r.execute();"rolled-back"!==i.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:i.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const n=this.findSlot(t);if(!n){const n=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!n||t.allowedTypes.includes(n))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:n}})();return K.log({role:"target",contract:"canAccept",component:this,args:{carrier:U(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}(i),s=[...t.capabilities??[]];n||s.push("Capacity","PlacementSurface"),r||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Jc((e=class extends(Uh(o)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:u?"".concat(u," ",c):c}),e.capabilities=Object.freeze(s),e.isFlowNode=!0,e))}function qh(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,n({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),n({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),n({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});export{gt as BULGE_EPSILON,ju as Capacity,It as CapacityEventTracker,Pt as CenteringQueueStrategy,y as CenteringSlotStrategy,bu as DEFAULT_SEAT_MARGIN,d as FixedSlotStrategy,$h as FlowEngine,Wh as FlowNode,Ft as GridStacking,tu as HOLDER_ANCHOR,Uh as Holdable,Jc as ItemsDataBinding,ht as NavGraph,Ct as PatternStacking,zt as PolygonPathPolyline,ct as ReservationTable,Y as TRANSFER_SLOT_KEY,rt as Transfer,Nt as VolumeStacking,pu as addressOfSlotId,Eh as allDestinations,Du as anchorsConnect,Th as applyPolicy,q as applySeatingRotation,Dt as applyStackLayout,Fu as arcSegmentTopology,jt as autoWireBackPressure,qu as buildFlowGraph,dt as buildNavGraph,xt as bulgeFromDrag,vt as bulgeHandlePosition,Xu as canReach,t as capability,f as chooseNearestPickupFrame,Ku as collectAdjacentSegments,zh as componentForNode,bt as computeArcParams,ph as computeFlowMap,Rt as computeStackPositions,wt as cornerHandlePosition,kt as cornerRadiusFromDrag,Uu as deliversInto,Ph as downstream,_t as effectiveCornerRadius,rh as enumerateDataScenarios,l as filterByToolType,mh as findNearestWithCapability,p as fixedSlotStrategy,Et as flattenPolygonPath,Mh as flowGraphFor,kh as flowGraphIssues,yh as flowReverseFor,Lt as footprint2D,X as frameClock,hh as ftId,uh as ftrace,i as getAllCapabilityMeta,r as getCapabilityMeta,B as globalSimClock,Nh as graphFor,hu as gridCellOf,uu as gridSlotNo,mt as hasArc,Ot as hasCapacity,Tt as inferCapacity,th as inferDownstreamId,ch as inferFlowDirections,qh as isFlowNode,gh as isGeometricHost,bh as isRoutingTarget,Au as judgeItemFit,Kc as layoutIssue,Wu as matchOutbounds,jh as next,Hu as nextHop,Gu as nextHops,Zu as nextHopsToAny,Qu as nextHopsToAnyDetailed,Ah as nodeIdOf,su as persistenceIssues,Lh as pickWeightedDestination,pt as planPathAStar,yt as planToReservations,Lu as pointInRotatedRect,At as polygonPathLength,s as quatFromYaw,$u as rayAbsDistanceToRect,Yu as reachableByOutbound,Rh as reachableDestinations,Ch as reachableDestinationsFrom,Fh as reachableDestinationsWeightedFrom,Vu as reachableSinks,et as receiptToJSON,Pu as rectFaceAnchors,u as rectangularFootprintFrames,n as registerCapabilityMeta,ut as reservationTable,so as resolveLegend,co as resolveLegendEntries,Ih as resolveNextHop,fu as resolveSlot,xu as rotatedFootprint,_u as seatInSlot,wu as seatTransform,Sh as sinksForDestination,yu as slotAddresses,au as slotCount,mu as slotFrame,du as slotIdOf,cu as slotNumbers,Eu as slotSpaceWarnings,ku as stackSeatTransforms,at as standardYieldPolicy,Cu as straightSegmentEndpoints,Nu as straightSegmentMultiInbound,Ru as straightSegmentTopology,h as topApproachFrame,it as transferLog,K as transferTracer,Mt as uniformZ,Dh as validate,Ju as validateFlowGraph,ou as validateSlotLayout};
|