@hatiolab/things-scene 10.0.0-beta.127 → 10.0.0-beta.129
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/command/command-migrate.d.ts.map +1 -1
- package/dist-types/components/mixins/holdable.d.ts.map +1 -1
- package/dist-types/diagnostics/data-lag-tracker.d.ts.map +1 -1
- package/dist-types/diagnostics/loading-overlay.d.ts +18 -1
- package/dist-types/diagnostics/loading-overlay.d.ts.map +1 -1
- package/dist-types/flow/flow-node.d.ts.map +1 -1
- package/dist-types/items/capacity-mixin.d.ts +1 -0
- package/dist-types/items/capacity-mixin.d.ts.map +1 -1
- package/dist-types/layer/modeling-layer.d.ts +9 -0
- package/dist-types/layer/modeling-layer.d.ts.map +1 -1
- package/dist-types/things-scene/index.d.ts +1 -1
- package/dist-types/things-scene/index.d.ts.map +1 -1
- package/dist-types/threed/factories/floor-plate.d.ts.map +1 -1
- package/dist-types/threed/real-object.d.ts +22 -0
- package/dist-types/threed/real-object.d.ts.map +1 -1
- package/dist-types/threed/three-capability.d.ts.map +1 -1
- package/dist-types/transfer/container-capacity-helpers.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/dist-types/transfer/transfer.d.ts.map +1 -1
- package/dist-types/transfer/transferable-mixin.d.ts +1 -0
- package/dist-types/transfer/transferable-mixin.d.ts.map +1 -1
- package/package.json +1 -1
- package/things-scene-min.js +11 -11
- 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 r=Object.getPrototypeOf(e),n=Array.isArray(r?.
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2026 Three.js Authors
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/const y=2e3;function m(...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 r=t[0];r&&r.isStackTrace?console.warn(r.getError(e)):console.warn(e,...t)}}function b(t,e,r){return Math.max(e,Math.min(r,t))}class v{constructor(t=0,e=0,r=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=n}static slerpFlat(t,e,r,n,i,o,s){let a=r[n+0],c=r[n+1],u=r[n+2],l=r[n+3],h=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(l!==p||a!==h||c!==f||u!==d){let t=a*h+c*f+u*d+l*p;t<0&&(h=-h,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const r=Math.acos(t),n=Math.sin(r);e=Math.sin(e*r)/n,a=a*e+h*(s=Math.sin(s*r)/n),c=c*e+f*s,u=u*e+d*s,l=l*e+p*s}else{a=a*e+h*s,c=c*e+f*s,u=u*e+d*s,l=l*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+l*l);a*=t,c*=t,u*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=l}static multiplyQuaternionsFlat(t,e,r,n,i,o){const s=r[n],a=r[n+1],c=r[n+2],u=r[n+3],l=i[o],h=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*l+a*f-c*h,t[e+1]=a*d+u*h+c*l-s*f,t[e+2]=c*d+u*f+s*h-a*l,t[e+3]=u*d-s*l-a*h-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,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,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 r=t._x,n=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(r/2),u=s(n/2),l=s(i/2),h=a(r/2),f=a(n/2),d=a(i/2);switch(o){case"XYZ":this._x=h*u*l+c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l-h*f*d;break;case"YXZ":this._x=h*u*l+c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l+h*f*d;break;case"ZXY":this._x=h*u*l-c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l-h*f*d;break;case"ZYX":this._x=h*u*l-c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l+h*f*d;break;case"YZX":this._x=h*u*l+c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l-h*f*d;break;case"XZY":this._x=h*u*l-c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l+h*f*d;break;default:m("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],l=e[10],h=r+s+l;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-n)*t}else if(r>s&&r>l){const t=2*Math.sqrt(1+r-s-l);this._w=(u-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(i+c)/t}else if(s>l){const t=2*Math.sqrt(1+s-r-l);this._w=(i-c)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+l-r-s);this._w=(o-n)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(b(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),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 r=t._x,n=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=r*u+o*s+n*c-i*a,this._y=n*u+o*a+i*s-r*c,this._z=i*u+o*c+r*a-n*s,this._w=o*u-r*s-n*a-i*c,this._onChangeCallback(),this}slerp(t,e){let r=t._x,n=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(r=-r,n=-n,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+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),n=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(n*Math.sin(t),n*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 x{constructor(t=0,e=0,r=0){x.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,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("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,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(w.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(w.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*n-s*r),u=2*(s*e-i*n),l=2*(i*r-o*e);return this.x=e+a*c+o*l-s*u,this.y=r+a*u+s*c-i*l,this.z=n+a*l+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,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,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=b(this.x,t.x,e.x),this.y=b(this.y,t.y,e.y),this.z=b(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=b(this.x,t,e),this.y=b(this.y,t,e),this.z=b(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(b(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=n*a-i*s,this.y=i*o-r*a,this.z=r*s-n*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return _.copy(this).projectOnVector(t),this.sub(_)}reflect(t){return this.sub(_.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 r=this.dot(t)/e;return Math.acos(b(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}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,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,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(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,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,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _=new x,w=new v;class k{constructor(t,e,r,n,i,o,s,a,c,u,l,h,f,d,p,g){k.prototype.isMatrix4=!0,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,r,n,i,o,s,a,c,u,l,h,f,d,p,g)}set(t,e,r,n,i,o,s,a,c,u,l,h,f,d,p,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=n,y[1]=i,y[5]=o,y[9]=s,y[13]=a,y[2]=c,y[6]=u,y[10]=l,y[14]=h,y[3]=f,y[7]=d,y[11]=p,y[15]=g,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 k).fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[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,r){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,r=t.elements,n=1/S.setFromMatrixColumn(t,0).length(),i=1/S.setFromMatrixColumn(t,1).length(),o=1/S.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),s=Math.sin(r),a=Math.cos(n),c=Math.sin(n),u=Math.cos(i),l=Math.sin(i);if("XYZ"===t.order){const t=o*u,r=o*l,n=s*u,i=s*l;e[0]=a*u,e[4]=-a*l,e[8]=c,e[1]=r+n*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=n+r*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,r=a*l,n=c*u,i=c*l;e[0]=t+i*s,e[4]=n*s-r,e[8]=o*c,e[1]=o*l,e[5]=o*u,e[9]=-s,e[2]=r*s-n,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,r=a*l,n=c*u,i=c*l;e[0]=t-i*s,e[4]=-o*l,e[8]=n+r*s,e[1]=r+n*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,r=o*l,n=s*u,i=s*l;e[0]=a*u,e[4]=n*c-r,e[8]=t*c+i,e[1]=a*l,e[5]=i*c+t,e[9]=r*c-n,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=i-t*l,e[8]=n*l+r,e[1]=l,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=r*l+n,e[10]=t-i*l}else if("XZY"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=-l,e[8]=c*u,e[1]=t*l+i,e[5]=o*u,e[9]=r*l-n,e[2]=n*l-r,e[6]=s*u,e[10]=i*l+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(z,t,A)}lookAt(t,e,r){const n=this.elements;return O.subVectors(t,e),0===O.lengthSq()&&(O.z=1),O.normalize(),j.crossVectors(r,O),0===j.lengthSq()&&(1===Math.abs(r.z)?O.x+=1e-4:O.z+=1e-4,O.normalize(),j.crossVectors(r,O)),j.normalize(),E.crossVectors(O,j),n[0]=j.x,n[4]=E.x,n[8]=O.x,n[1]=j.y,n[5]=E.y,n[9]=O.y,n[2]=j.z,n[6]=E.z,n[10]=O.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,o=r[0],s=r[4],a=r[8],c=r[12],u=r[1],l=r[5],h=r[9],f=r[13],d=r[2],p=r[6],g=r[10],y=r[14],m=r[3],b=r[7],v=r[11],x=r[15],_=n[0],w=n[4],k=n[8],S=n[12],M=n[1],z=n[5],A=n[9],j=n[13],E=n[2],O=n[6],T=n[10],P=n[14],C=n[3],I=n[7],F=n[11],R=n[15];return i[0]=o*_+s*M+a*E+c*C,i[4]=o*w+s*z+a*O+c*I,i[8]=o*k+s*A+a*T+c*F,i[12]=o*S+s*j+a*P+c*R,i[1]=u*_+l*M+h*E+f*C,i[5]=u*w+l*z+h*O+f*I,i[9]=u*k+l*A+h*T+f*F,i[13]=u*S+l*j+h*P+f*R,i[2]=d*_+p*M+g*E+y*C,i[6]=d*w+p*z+g*O+y*I,i[10]=d*k+p*A+g*T+y*F,i[14]=d*S+p*j+g*P+y*R,i[3]=m*_+b*M+v*E+x*C,i[7]=m*w+b*z+v*O+x*I,i[11]=m*k+b*A+v*T+x*F,i[15]=m*S+b*j+v*P+x*R,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],r=t[4],n=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],l=t[6],h=t[10],f=t[14],d=t[3],p=t[7],g=t[11],y=t[15],m=a*f-c*h,b=s*f-c*l,v=s*h-a*l,x=o*f-c*u,_=o*h-a*u,w=o*l-s*u;return e*(p*m-g*b+y*v)-r*(d*m-g*x+y*_)+n*(d*b-p*x+y*w)-i*(d*v-p*_+g*w)}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,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],l=t[9],h=t[10],f=t[11],d=t[12],p=t[13],g=t[14],y=t[15],m=e*s-r*o,b=e*a-n*o,v=e*c-i*o,x=r*a-n*s,_=r*c-i*s,w=n*c-i*a,k=u*p-l*d,S=u*g-h*d,M=u*y-f*d,z=l*g-h*p,A=l*y-f*p,j=h*y-f*g,E=m*j-b*A+v*z+x*M-_*S+w*k;if(0===E)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/E;return t[0]=(s*j-a*A+c*z)*O,t[1]=(n*A-r*j-i*z)*O,t[2]=(p*w-g*_+y*x)*O,t[3]=(h*_-l*w-f*x)*O,t[4]=(a*M-o*j-c*S)*O,t[5]=(e*j-n*M+i*S)*O,t[6]=(g*v-d*w-y*b)*O,t[7]=(u*w-h*v+f*b)*O,t[8]=(o*A-s*M+c*k)*O,t[9]=(r*M-e*A-i*k)*O,t[10]=(d*_-p*v+y*m)*O,t[11]=(l*v-u*_-f*m)*O,t[12]=(s*S-o*z-a*k)*O,t[13]=(e*z-r*S+n*k)*O,t[14]=(p*b-d*x-g*m)*O,t[15]=(u*x-l*b+h*m)*O,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+r,c*s-n*a,c*a+n*s,0,c*s+n*a,u*s+r,u*a-n*o,0,c*a-n*s,u*a+n*o,i*a*a+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,o){return this.set(1,r,i,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,l=s+s,h=i*c,f=i*u,d=i*l,p=o*u,g=o*l,y=s*l,m=a*c,b=a*u,v=a*l,x=r.x,_=r.y,w=r.z;return n[0]=(1-(p+y))*x,n[1]=(f+v)*x,n[2]=(d-b)*x,n[3]=0,n[4]=(f-v)*_,n[5]=(1-(h+y))*_,n[6]=(g+m)*_,n[7]=0,n[8]=(d+b)*w,n[9]=(g-m)*w,n[10]=(1-(h+p))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const i=this.determinant();if(0===i)return r.set(1,1,1),e.identity(),this;let o=S.set(n[0],n[1],n[2]).length();const s=S.set(n[4],n[5],n[6]).length(),a=S.set(n[8],n[9],n[10]).length();i<0&&(o=-o),M.copy(this);const c=1/o,u=1/s,l=1/a;return M.elements[0]*=c,M.elements[1]*=c,M.elements[2]*=c,M.elements[4]*=u,M.elements[5]*=u,M.elements[6]*=u,M.elements[8]*=l,M.elements[9]*=l,M.elements[10]*=l,e.setFromRotationMatrix(M),r.x=o,r.y=s,r.z=a,this}makePerspective(t,e,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),l=2*i/(r-n),h=(e+t)/(e-t),f=(r+n)/(r-n);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===y)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]=h,c[12]=0,c[1]=0,c[5]=l,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,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),l=2/(r-n),h=-(e+t)/(e-t),f=-(r+n)/(r-n);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===y)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]=h,c[1]=0,c[5]=l,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,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const S=new x,M=new k,z=new x(0,0,0),A=new x(1,1,1),j=new x,E=new x,O=new x,T=new k,P=new v;class C{constructor(t=0,e=0,r=0,n=C.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}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,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,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,r=!0){const n=t.elements,i=n[0],o=n[4],s=n[8],a=n[1],c=n[5],u=n[9],l=n[2],h=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(b(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-b(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(b(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-l,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-b(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(b(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-b(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:m("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return T.makeRotationFromQuaternion(t),this.setFromRotationMatrix(T,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return P.setFromEuler(this),this.setFromQuaternion(P,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}}C.DEFAULT_ORDER="XYZ","undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"183"}})),"undefined"!=typeof window&&(window.__THREE__?m("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="183");const I=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__=I);let F=null;const R=[],D=new Set;function N(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const L={beginContext(t){F=t},endContext(){F=null},current:()=>F,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??N(t.component),componentType:t.componentType??(r=t.component,r?.state?.type??r?.type),atSimMs:I.now,args:t.args,result:t.result,error:t.error};var r;F?F.pushTrace(e):(R.push(e),R.length>500&&R.shift(),D.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...R],onStandalone:t=>(D.add(t),()=>{D.delete(t)}),clearStandalone(){R.length=0}};function Y(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}const $=new C;function U(t,e){$.setFromQuaternion(new v(e.x,e.y,e.z,e.w),"XYZ"),t.rotationX=$.x,t.rotation=-$.y,t.rotationY=$.z}const W="_transferSlotId";function q(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const r=String(e);return r.length>0?r:void 0}function G(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},r=t.sourceId??q(t.source),n=t.targetId??q(t.target),i=t.carrierId??q(t.carrier);return void 0!==r&&(e.sourceId=r),void 0!==n&&(e.targetId=n),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let B=1;class H{constructor(t){this._phase="pending",this._slot=null,this._traceEvents=[],this.meta={},this.id="xfer-"+B++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:I.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??I.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}async execute(){L.beginContext(this),L.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:q(this.source),target:q(this.target),carrier:q(this.carrier)}});try{return await this._executeImpl()}finally{L.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),L.endContext()}}executeSync(){L.beginContext(this),L.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:q(this.source),target:q(this.target),carrier:q(this.carrier)}});try{this._phase="planning",this._timeline.planStartAt=I.now;const t=this.target.canAccept?.(this.carrier);if(t){if(!t.ok){this._rejectReason=t.reason,this._phase="rolled-back";const e=this._buildReceipt();return X.append(e),e}this._slot=t.slot}else if("function"==typeof this.target.canReceive){if(!this.target.canReceive(this.carrier)){this._rejectReason="cannot-receive",this._phase="rolled-back";const t=this._buildReceipt();return X.append(t),t}this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}else this._slot=null;if(this._timeline.planEndAt=I.now,this.physical){this._phase="physical",this._timeline.physicalStartAt=I.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();return X.append(e),e}this._timeline.physicalEndAt=I.now}this._phase="handoff",this._timeline.handoffAt=I.now;const e=this.target.accept??this.target.receive;if("function"==typeof e)try{const t=e.call(this.target,this.carrier,this.options);t instanceof Promise&&t.catch(()=>{})}catch(t){this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();throw X.append(e),t}else L.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}});this._phase="committed",this._timeline.committedAt=I.now;const r=this._buildReceipt();return X.append(r),r}finally{L.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),L.endContext()}}async _executeImpl(){this._phase="planning",this._timeline.planStartAt=I.now;const t=this.target.canAccept?.(this.carrier);if(t){if(!t.ok){this._rejectReason=t.reason,this._phase="rolled-back";const e=this._buildReceipt();return X.append(e),e}this._slot=t.slot}else if("function"==typeof this.target.canReceive){if(!this.target.canReceive(this.carrier)){this._rejectReason="cannot-receive",this._phase="rolled-back";const t=this._buildReceipt();return X.append(t),t}this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}else this._slot=null;if(this._timeline.planEndAt=I.now,this.physical){this._phase="physical",this._timeline.physicalStartAt=I.now;try{await this.physical()}catch(t){this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();return X.append(e),e}this._timeline.physicalEndAt=I.now}this._phase="handoff",this._timeline.handoffAt=I.now;const e=this.target.accept??this.target.receive;if("function"==typeof e)try{await e.call(this.target,this.carrier,this.options)}catch(t){this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();throw X.append(e),t}else L.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method (physical phase handled handoff)"}});this._phase="committed",this._timeline.committedAt=I.now;const r=this._buildReceipt();return X.append(r),r}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",X.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:q(this.source),targetId:q(this.target),carrierId:q(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 X=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??q(t.source),r=t.targetId??q(t.target);if("committed"===t.phase){if(e&&r){const t=e+">"+r;this._flows.set(t,(this._flows.get(t)??0)+1)}r&&this._targetCount.set(r,(this._targetCount.get(r)??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,r)=>{t[r]=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,r){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};function V(t){const e=function(t){return class extends t{async receive(t,e={}){L.log({role:"target",contract:"receive:enter",component:this,args:{carrier:Y(t),options:e}});const r=this.findSlot(t);if(!r){L.log({role:"target",contract:"receive:reject",component:this,args:{carrier:Y(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}const n=this._countOccupied(r.id),i=this.arrangementStrategy.positionAt(n,r,n,t);L.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:n,slotId:r.id,occupantCount:n,carrier:Y(t)},result:i}),t[W]=r.id;const o=t._realObject;let s,a;o?.object3d&&(o.object3d.updateWorldMatrix(!0,!1),s=new x,a=new v,o.object3d.getWorldPosition(s),o.object3d.getWorldQuaternion(a));const{animated:c=!1,duration:u,ease:l}=e;"function"==typeof this.handoverIn?this.handoverIn(t):this.reparent?.(t,{animated:c,duration:u,ease:l}),!c&&t._realObject&&(t._realObject.suppressTransform=!1);{const e={},o=this.placementFor?.(t,{slot:r,index:n,occupantCount:n})??null;if(L.log({role:"target",contract:"placementFor",component:this,args:{carrier:Y(t),slotId:r.id,index:n},result:o}),o){const n=t.state??{},i=this.state??{};e.left=o.position.x-(Number(n.width)||0)/2+(Number(i.width)||0)/2,e.top=o.position.z-(Number(n.height)||0)/2+(Number(i.height)||0)/2;const s=this._zPosFromSeatY(o.position.y,n.depth,r);null!==s&&(e.zPos=s),o.rotation&&U(e,o.rotation)}else{if(i&&(e.left=i.x,e.top=i.y),0!==(this._realObject?.receivingSurfaceY??0))e.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const t=this._realObject?.geometricOffsetY??0;e.zPos=r.localPosition.z+t}const n=this.acceptanceRotation?.(t,r);L.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:Y(t),slotId:r.id},result:n}),n&&U(e,n)}const s=this.normalizePose?.(t,r);"function"==typeof this.normalizePose&&L.log({role:"target",contract:"normalizePose",component:this,args:{carrier:Y(t),slotId:r.id},result:s}),s&&Object.assign(e,s),Object.keys(e).length&&(t.setState?.(e),L.log({role:"target",contract:"receive:setState",component:this,args:{carrier:Y(t),keys:Object.keys(e)}}))}this.trigger("transfer-received",{type:"transfer-received",component:t,container:this,slotId:r.id,preReceiveWorldPos:s,preReceiveWorldQuat:a}),L.log({role:"target",contract:"receive:done",component:this,args:{carrier:Y(t),slotId:r.id}})}async dispatch(t,e,r={}){const n=new H({source:this,target:e,carrier:t,options:r,physical:async()=>{delete t[W]}}),i=await n.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 r=this.findSlot(t);if(!r){const r=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!r||t.allowedTypes.includes(r))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:r}})();return L.log({role:"target",contract:"canAccept",component:this,args:{carrier:Y(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}}(function(t){return class extends t{get slots(){return[]}get arrangementStrategy(){return p}canReceive(t){const e=null!==this.findSlot(t);return L.log({role:"target",contract:"canReceive",component:this,args:{carrier:Y(t)},result:e}),e}findSlot(t){const e=this.slots;if(!e.length)return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:null}),null;for(const r of e){if(r.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!r.allowedTypes.includes(e))continue}const e=r.maxCount??this.arrangementStrategy.capacity(r),n=this._countOccupied(r.id);if(!(n>=e))return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:{slotId:r.id,occupied:n,max:e}}),r}return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const r=this._realObject?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new v;r.getWorldQuaternion(n);const i=new v(e.x,e.y,e.z,e.w);return n.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,r=e?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new x;r.getWorldPosition(n);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new x(0,i,0);return r.localToWorld(t),{x:n.x,y:t.y,z:n.z}}return{x:n.x,y:n.y,z:n.z}}attachPointFor(t){const e=t?.[W];if(!e)return null;const r=this.slots.find(t=>t.id===e);return r?{position:r.localPosition??{x:0,y:0,z:0},rotation:r.localRotation??{x:0,y:0,z:0},slotId:r.id}:null}placementFor(t,e={}){const r=t&&"object"==typeof t&&"state"in t?t:void 0,n=r?r.state??{}:t??{},i={width:Number(n.width)||0,height:Number(n.height)||0,depth:Number(n.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,r??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,l=Number(this.state?.height)||0,h=c.x+i.width/2-u/2,f=c.y+i.height/2-l/2,d=this._realObject,p=d?.placementMode??"floor",g="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,y=this._receivingSurfaceLocalY();let m;m=null!==y?y+g:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+g:g-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(r??i,o)??void 0;return b?{position:{x:h,y:m,z:f},rotation:b}:{position:{x:h,y:m,z:f}}}_zPosFromSeatY(t,e,r){const n=this._realObject,i=n?.receivingSurfaceY??0,o=!(!r.localPosition||!Number.isFinite(r.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=n?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(n?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_countOccupied(t){const e=this.components;return e?e.filter(e=>e.parent===this&&e[W]===t).length:0}}}(t));return e.capabilities=[...t.capabilities??[],"ContainerCapacity","PlacementSurface"],e}function Z(t){if(!t||"object"!=typeof t)return!1;const e=t;return"function"==typeof e.canReserveAtJoinPoint&&"function"==typeof e.reserveAtJoinPoint&&"function"==typeof e.commitReservation&&"function"==typeof e.releaseReservation&&e.carrierMap instanceof Map}"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=X),r({name:"ContainerCapacity",description:"Carrier slot topology + reservation / commit / release 의 default 구현을 Mixin 으로 제공. 컨테이너 (chute, induct, dock 등) 가 Transferable contract 의 standard impl 을 1줄 Mixin 으로 획득. subclass 는 *slots* 만 override.",methods:["get slots","reserveSlot","commitReservation","releaseReservation","isSlotAvailable","occupancyAt"],stateFields:["capacity","maxCapacity","slotArrangement"],sourceFile:"src/transfer/container-capacity.ts"}),r({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 구현은 ContainerCapacity 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/transfer/container-capacity.ts"}),r({name:"CarrierLine",description:"carrier slot 들을 연속 경로 위에서 운영하는 컴포넌트의 추상 contract. cross-belt-line, loop-sorter, monorail, AGV-fleet 등 각각 다른 concrete class 들이 같은 capability 를 노출 — source (induct, station 등) 는 concrete class 모르고 capability 만 사용.",methods:["canReserveAtJoinPoint","reserveAtJoinPoint","commitReservation","releaseReservation"],models:["CarrierReservation","CarrierSlotState","JoinPoint"],stateFields:["speed","carrierPitch","direction","orientation"],sourceFile:"src/transfer/carrier-line-capability.ts"});let Q=1;function J(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const K={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class tt{constructor(t=K){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-"+Q++},r=(this._byResource.get(e.resource)??[]).filter(t=>J(t.timeWindow,e.timeWindow));if(0===r.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const n=r.map(t=>{const r=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:r}});if(n.every(t=>"b-yields"===t.decision)){const n=r.slice();for(const t of n)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:n,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:n}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r.slice(),outcome:"rejected"}),{ok:!1,conflicts:n}}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=>J(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 r=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);r<0?e.push(t):e.splice(r,0,t);let n=this._byReserver.get(t.reserverId);n||(n=[],this._byReserver.set(t.reserverId,n)),n.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const r=e.findIndex(e=>e.id===t.id);if(r<0)return!1;e.splice(r,1),0===e.length&&this._byResource.delete(t.resource);const n=this._byReserver.get(t.reserverId);if(n){const e=n.findIndex(e=>e.id===t.id);e>=0&&n.splice(e,1),0===n.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const et=new tt;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=et);class rt{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,r=1/0;for(const n of this.nodes.values()){const i=nt(n.position,t);i<r&&(r=i,e=n)}return e}}function nt(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}function it(t,e){return Math.sqrt(nt(t,e))}function ot(t,e,r={}){const n=new rt,i=r.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const r=`${e.id}:start`,o=`${e.id}:end`;n.addNode({id:r,position:t[0],type:"lane-start"}),n.addNode({id:o,position:t[t.length-1],type:"lane-end"}),n.laneEndpoints.set(e.id,{startNodeId:r,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=it(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;n.addEdge({fromNode:r,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&n.addEdge({fromNode:o,toNode:r,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const r of t.lanes){const i=n.laneEndpoints.get(r);if(!i)continue;const o=n.nodes.get(i.startNodeId).position,s=n.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===r)continue;const t=n.laneEndpoints.get(e);if(!t)continue;const i=n.nodes.get(t.startNodeId).position,l=n.nodes.get(t.endNodeId).position;a+=Math.min(nt(o,i),nt(o,l)),c+=Math.min(nt(s,i),nt(s,l)),u++}if(0===u)continue;const l=a<c?i.startNodeId:i.endNodeId;e.push({laneId:r,nodeId:l,pos:n.nodes.get(l).position})}for(let r=0;r<e.length;r++)for(let i=0;i<e.length;i++){if(r===i)continue;const o=e[r],s=e[i],a=it(o.pos,s.pos);n.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return n}function st(t,e,r,n={}){const i=t.nodes.get(e),o=t.nodes.get(r);if(!i||!o)return null;const s=n.speed?.max??100,a=e=>{const r=t.nodes.get(e);var n,i;return(n=r.position,i=o.position,Math.sqrt(function(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}(n,i)))/s*1e3},c=new Map,u=new Set,l=new Set,h={nodeId:e,gScore:0,fScore:a(e)};c.set(e,h),u.add(e);const f=n.startSimMs??0,d=n.deadlineSimMs;for(;u.size>0;){let e=null,n=null;for(const t of u){const r=c.get(t);(!n||r.fScore<n.fScore||r.fScore===n.fScore&&t<e)&&(n=r,e=t)}if(!n||!e)return null;if(e===r){const t=[];let e=n,r=0;for(;e&&e.cameFromEdge;){const n=e.cameFromEdge,i=f+(e.gScore-n.durationMs);t.unshift({resource:n.resource,timeWindow:{startSimMs:i,endSimMs:i+n.durationMs},fromPos:n.fromPos,toPos:n.toPos}),r+=n.distance,e=c.get(n.fromNodeId)}const i=n.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:r}}u.delete(e),l.add(e);for(const r of t.edgesFrom(e)){if(l.has(r.toNode))continue;const e=n.gScore+r.durationMs,i=c.get(r.toNode);if(!i||e<i.gScore){const n=t.nodes.get(r.fromNode),i=t.nodes.get(r.toNode),o={nodeId:r.toNode,gScore:e,fScore:e+a(r.toNode),cameFromEdge:{fromNodeId:r.fromNode,resource:r.resource,distance:r.distance,durationMs:r.durationMs,fromPos:n.position,toPos:i.position}};c.set(r.toNode,o),u.add(r.toNode)}}}return null}function at(t,e,r=0,n){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:r,metadata:n}))}const ct=.5;function ut(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function lt(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o||!Number.isFinite(r)||Math.abs(r)<1e-9)return null;const s=Math.abs(r),a=(o*o+4*s*s)/(8*s),c=r>0?1:-1,u=a-s,l=(t.x+e.x)/2-c*(i/o)*u,h=(t.y+e.y)/2-c*-(n/o)*u;return{cx:l,cy:h,radius:a,startAngle:Math.atan2(t.y-h,t.x-l),endAngle:Math.atan2(e.y-h,e.x-l),clockwise:r<0}}function ht(t,e,r=0,n=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(r)?r:0,l=Math.abs(u)>=1e-6?u:n;return{x:(t.x+e.x)/2+a*l,y:(t.y+e.y)/2+c*l,perpX:a,perpY:c}}function ft(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o)return 0;const s=i/o,a=-(n/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let l=(r.x-c)*s+(r.y-u)*a;if(Math.abs(l)<.5)return 0;return l>o&&(l=o),l<-o&&(l=-o),l}function dt(t,e){const r=t.radius,n=Number.isFinite(e)?e:0;return null!=r&&Number.isFinite(r)?Math.max(0,r):Math.max(0,n)}function pt(t,e,r,n,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=r.x-e.x,u=r.y-e.y,l=Math.sqrt(c*c+u*u);if(0===l)return null;const h=o/a+c/l,f=s/a+u/l,d=Math.sqrt(h*h+f*f);if(d<1e-9)return null;const p=h/d,g=f/d,y=Math.max(n,i);return{x:e.x+p*y,y:e.y+g*y,bisectorX:p,bisectorY:g}}function gt(t,e,r,n){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=r.x-e.x,c=r.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const l=i/s+a/u,h=o/s+c/u,f=Math.sqrt(l*l+h*h);if(f<1e-9)return 0;const d=l/f,p=h/f,g=(n.x-e.x)*d+(n.y-e.y)*p,y=Math.min(s,u)/2;return Math.max(0,Math.min(g,y))}function yt(t){if(0===t.length)return 0;let e;for(const r of t){const t=r.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 mt={closed:!0,round:0,divisions:24};class bt{constructor(t,e){this.points=t,this.closed=e;const r=[0];for(let e=1;e<t.length;e++){const n=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;r.push(r[e-1]+Math.sqrt(n*n+i*i))}this.cumulative=r,this.length=r[r.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 r=t;this.closed?r=(t%e+e)%e:r<0?r=0:r>e&&(r=e);const n=this.cumulative;let i=0,o=n.length-2;for(;i<o;){const t=i+o>>1;n[t+1]<=r?i=t+1:o=t}const s=n[i+1]-n[i],a=s>0?(r-n[i])/s:0,c=this.points[i],u=this.points[i+1],l=u.x-c.x,h=u.y-c.y;return{x:c.x+l*a,y:c.y+h*a,theta:0===l&&0===h?0:Math.atan2(h,l)}}}function vt(t,e={}){const r={...mt,...e},n=t.length;if(0===n)return new bt([],r.closed);if(1===n)return new bt([{x:t[0].x,y:t[0].y}],r.closed);const i=[],o=(t,e)=>{if(i.length>0){const r=i[i.length-1];if(Math.abs(r.x-t)<1e-9&&Math.abs(r.y-e)<1e-9)return}i.push({x:t,y:e})},s=(r.closed,n);for(let e=0;e<s;e++){const i=0===e?r.closed?n-1:-1:e-1,s=e===n-1?r.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 l=a&&u?dt(c,r.round):0;let h,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,r=Math.min(l,t/2);h=Math.sin(e)*r+c.x,f=Math.cos(e)*r+c.y}else h=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,r=Math.min(l,t/2);d=Math.sin(e)*r+c.x,p=Math.cos(e)*r+c.y}else d=c.x,p=c.y;if(o(h,f),l>0&&a&&u)for(let t=1;t<=r.divisions;t++){const e=t/r.divisions,n=1-e;o(n*n*h+2*n*e*c.x+e*e*d,n*n*f+2*n*e*c.y+e*e*p)}else h===d&&f===p||o(d,p);if(u&&ut(c)){const t=dt(u,r.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),n=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=lt({x:d,y:p},{x:Math.sin(n)*i+u.x,y:Math.cos(n)*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<=r.divisions;e++){const n=e/r.divisions,i=s.startAngle+t*n;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(r.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 bt(i,r.closed)}function xt(t,e){return vt(t,e).length}function _t(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function wt(t){if(_t(t)){const e=t.capacity(),r=t.available();return{capacity:e,available:r,isFull:0===r}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,r="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:r,isFull:0===r}}const e=t?.state?.capacity,r=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-r);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class kt{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 St(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 r=e.onFull(()=>t.pauseEmit()),n=e.onAvailable(()=>t.resumeEmit());return wt(e).isFull&&t.pauseEmit(),()=>{r?.(),n?.()}}class Mt{constructor(t=1){this.itemSpacing=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y+t*this.itemSpacing,z:i.z}}capacity(t){return t.maxCount??1/0}}class zt{constructor(t=1){this.itemSpacing=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y,z:i.z+t*this.itemSpacing}}capacity(t){return t.maxCount??1/0}}class At{constructor(t,e=1,r="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=r}positionAt(t,e,r,n){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=n?.state?.width??0,c=n?.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}}class jt{constructor(t=1,e=1){this.colSpacing=t,this.rowSpacing=e}positionAt(t,e,r){const n=e.gridShape?.cols??1,i=n*(e.gridShape?.rows??1);if(t<0||t>=i)return null;if(t>=(e.maxCount??i))return null;const o=t%n,s=Math.floor(t/n),a=e.localPosition??{x:0,y:0,z:0};return{x:a.x+o*this.colSpacing,y:a.y,z:a.z+s*this.rowSpacing}}capacity(t){const e=t.gridShape?.cols??1,r=t.gridShape?.rows??1;return Math.min(t.maxCount??1/0,e*r)}}class Et{constructor(t=1,e=1){this.itemWidth=t,this.shelfHeight=e}positionAt(t,e,r){const n=e.gridShape?.cols??1,i=n*(e.gridShape?.rows??1);if(t<0||t>=i)return null;if(t>=(e.maxCount??i))return null;const o=t%n,s=Math.floor(t/n),a=e.localPosition??{x:0,y:0,z:0};return{x:a.x+o*this.itemWidth,y:a.y+s*this.shelfHeight,z:a.z}}capacity(t){const e=t.gridShape?.cols??1,r=t.gridShape?.rows??1;return Math.min(t.maxCount??1/0,e*r)}}class Ot{constructor(t=1){this.itemHeight=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y+t*this.itemHeight,z:i.z}}capacity(t){return t.maxCount??1/0}}function Tt(t,e){return t===e||t!=t&&e!=e}function Pt(t,e){for(var r=t.length;r--;)if(Tt(t[r][0],e))return r;return-1}var Ct=Array.prototype.splice;function It(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}It.prototype.clear=function(){this.__data__=[],this.size=0},It.prototype.delete=function(t){var e=this.__data__,r=Pt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ct.call(e,r,1),--this.size,!0)},It.prototype.get=function(t){var e=this.__data__,r=Pt(e,t);return r<0?void 0:e[r][1]},It.prototype.has=function(t){return Pt(this.__data__,t)>-1},It.prototype.set=function(t,e){var r=this.__data__,n=Pt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ft="object"==typeof global&&global&&global.Object===Object&&global,Rt="object"==typeof self&&self&&self.Object===Object&&self,Dt=Ft||Rt||Function("return this")(),Nt=Dt.Symbol,Lt=Object.prototype,Yt=Lt.hasOwnProperty,$t=Lt.toString,Ut=Nt?Nt.toStringTag:void 0;var Wt=Object.prototype.toString;var qt=Nt?Nt.toStringTag:void 0;function Gt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":qt&&qt in Object(t)?function(t){var e=Yt.call(t,Ut),r=t[Ut];try{t[Ut]=void 0;var n=!0}catch(t){}var i=$t.call(t);return n&&(e?t[Ut]=r:delete t[Ut]),i}(t):function(t){return Wt.call(t)}(t)}function Bt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ht(t){if(!Bt(t))return!1;var e=Gt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var Xt,Vt=Dt["__core-js_shared__"],Zt=(Xt=/[^.]+$/.exec(Vt&&Vt.keys&&Vt.keys.IE_PROTO||""))?"Symbol(src)_1."+Xt:"";var Qt=Function.prototype.toString;function Jt(t){if(null!=t){try{return Qt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Kt=/^\[object .+?Constructor\]$/,te=Function.prototype,ee=Object.prototype,re=te.toString,ne=ee.hasOwnProperty,ie=RegExp("^"+re.call(ne).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oe(t){return!(!Bt(t)||(e=t,Zt&&Zt in e))&&(Ht(t)?ie:Kt).test(Jt(t));var e}function se(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return oe(r)?r:void 0}var ae=se(Dt,"Map"),ce=se(Object,"create");var ue=Object.prototype.hasOwnProperty;var le=Object.prototype.hasOwnProperty;function he(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function fe(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function de(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}he.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},he.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},he.prototype.get=function(t){var e=this.__data__;if(ce){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return ue.call(e,t)?e[t]:void 0},he.prototype.has=function(t){var e=this.__data__;return ce?void 0!==e[t]:le.call(e,t)},he.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ce&&void 0===e?"__lodash_hash_undefined__":e,this},de.prototype.clear=function(){this.size=0,this.__data__={hash:new he,map:new(ae||It),string:new he}},de.prototype.delete=function(t){var e=fe(this,t).delete(t);return this.size-=e?1:0,e},de.prototype.get=function(t){return fe(this,t).get(t)},de.prototype.has=function(t){return fe(this,t).has(t)},de.prototype.set=function(t,e){var r=fe(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function pe(t){var e=this.__data__=new It(t);this.size=e.size}pe.prototype.clear=function(){this.__data__=new It,this.size=0},pe.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},pe.prototype.get=function(t){return this.__data__.get(t)},pe.prototype.has=function(t){return this.__data__.has(t)},pe.prototype.set=function(t,e){var r=this.__data__;if(r instanceof It){var n=r.__data__;if(!ae||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new de(n)}return r.set(t,e),this.size=r.size,this};function ge(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new de;++e<r;)this.add(t[e])}function ye(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}ge.prototype.add=ge.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ge.prototype.has=function(t){return this.__data__.has(t)};function me(t,e,r,n,i,o){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),l=o.get(e);if(u&&l)return u==e&&l==t;var h=-1,f=!0,d=2&r?new ge:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var p=t[h],g=e[h];if(n)var y=s?n(g,p,h,e,t,o):n(p,g,h,t,e,o);if(void 0!==y){if(y)continue;f=!1;break}if(d){if(!ye(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,r,n,o)))return d.push(e);var s})){f=!1;break}}else if(p!==g&&!i(p,g,r,n,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var be=Dt.Uint8Array;function ve(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xe(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var _e=Nt?Nt.prototype:void 0,we=_e?_e.valueOf:void 0;function ke(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var Se=Array.isArray;function Me(){return[]}var ze=Object.prototype.propertyIsEnumerable,Ae=Object.getOwnPropertySymbols,je=Ae?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var s=t[r];e(s,r,t)&&(o[i++]=s)}return o}(Ae(t),function(e){return ze.call(t,e)}))}:Me;function Ee(t){return null!=t&&"object"==typeof t}function Oe(t){return Ee(t)&&"[object Arguments]"==Gt(t)}var Te=Object.prototype,Pe=Te.hasOwnProperty,Ce=Te.propertyIsEnumerable,Ie=Oe(function(){return arguments}())?Oe:function(t){return Ee(t)&&Pe.call(t,"callee")&&!Ce.call(t,"callee")};var Fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Re=Fe&&"object"==typeof module&&module&&!module.nodeType&&module,De=Re&&Re.exports===Fe?Dt.Buffer:void 0,Ne=(De?De.isBuffer:void 0)||function(){return!1},Le=/^(?:0|[1-9]\d*)$/;function Ye(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Le.test(t))&&t>-1&&t%1==0&&t<e}function $e(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Ue={};function We(t){return function(e){return t(e)}}Ue["[object Float32Array]"]=Ue["[object Float64Array]"]=Ue["[object Int8Array]"]=Ue["[object Int16Array]"]=Ue["[object Int32Array]"]=Ue["[object Uint8Array]"]=Ue["[object Uint8ClampedArray]"]=Ue["[object Uint16Array]"]=Ue["[object Uint32Array]"]=!0,Ue["[object Arguments]"]=Ue["[object Array]"]=Ue["[object ArrayBuffer]"]=Ue["[object Boolean]"]=Ue["[object DataView]"]=Ue["[object Date]"]=Ue["[object Error]"]=Ue["[object Function]"]=Ue["[object Map]"]=Ue["[object Number]"]=Ue["[object Object]"]=Ue["[object RegExp]"]=Ue["[object Set]"]=Ue["[object String]"]=Ue["[object WeakMap]"]=!1;var qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ge=qe&&"object"==typeof module&&module&&!module.nodeType&&module,Be=Ge&&Ge.exports===qe&&Ft.process,He=function(){try{var t=Ge&&Ge.require&&Ge.require("util").types;return t||Be&&Be.binding&&Be.binding("util")}catch(t){}}(),Xe=He&&He.isTypedArray,Ve=Xe?We(Xe):function(t){return Ee(t)&&$e(t.length)&&!!Ue[Gt(t)]},Ze=Object.prototype.hasOwnProperty;function Qe(t,e){var r=Se(t),n=!r&&Ie(t),i=!r&&!n&&Ne(t),o=!r&&!n&&!i&&Ve(t),s=r||n||i||o,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!Ze.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ye(u,c))||a.push(u);return a}var Je=Object.prototype;function Ke(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Je)}function tr(t,e){return function(r){return t(e(r))}}var er=tr(Object.keys,Object),rr=Object.prototype.hasOwnProperty;function nr(t){if(!Ke(t))return er(t);var e=[];for(var r in Object(t))rr.call(t,r)&&"constructor"!=r&&e.push(r);return e}function ir(t){return null!=t&&$e(t.length)&&!Ht(t)}function or(t){return ir(t)?Qe(t):nr(t)}function sr(t){return function(t,e,r){var n=e(t);return Se(t)?n:ke(n,r(t))}(t,or,je)}var ar=Object.prototype.hasOwnProperty;var cr=se(Dt,"DataView"),ur=se(Dt,"Promise"),lr=se(Dt,"Set"),hr=se(Dt,"WeakMap"),fr="[object Map]",dr="[object Promise]",pr="[object Set]",gr="[object WeakMap]",yr="[object DataView]",mr=Jt(cr),br=Jt(ae),vr=Jt(ur),xr=Jt(lr),_r=Jt(hr),wr=Gt;(cr&&wr(new cr(new ArrayBuffer(1)))!=yr||ae&&wr(new ae)!=fr||ur&&wr(ur.resolve())!=dr||lr&&wr(new lr)!=pr||hr&&wr(new hr)!=gr)&&(wr=function(t){var e=Gt(t),r="[object Object]"==e?t.constructor:void 0,n=r?Jt(r):"";if(n)switch(n){case mr:return yr;case br:return fr;case vr:return dr;case xr:return pr;case _r:return gr}return e});var kr="[object Arguments]",Sr="[object Array]",Mr="[object Object]",zr=Object.prototype.hasOwnProperty;function Ar(t,e,r,n,i,o){var s=Se(t),a=Se(e),c=s?Sr:wr(t),u=a?Sr:wr(e),l=(c=c==kr?Mr:c)==Mr,h=(u=u==kr?Mr:u)==Mr,f=c==u;if(f&&Ne(t)){if(!Ne(e))return!1;s=!0,l=!1}if(f&&!l)return o||(o=new pe),s||Ve(t)?me(t,e,r,n,i,o):function(t,e,r,n,i,o,s){switch(r){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 be(t),new be(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Tt(+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=ve;case"[object Set]":var c=1&n;if(a||(a=xe),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var l=me(a(t),a(e),n,i,o,s);return s.delete(t),l;case"[object Symbol]":if(we)return we.call(t)==we.call(e)}return!1}(t,e,c,r,n,i,o);if(!(1&r)){var d=l&&zr.call(t,"__wrapped__"),p=h&&zr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,y=p?e.value():e;return o||(o=new pe),i(g,y,r,n,o)}}return!!f&&(o||(o=new pe),function(t,e,r,n,i,o){var s=1&r,a=sr(t),c=a.length;if(c!=sr(e).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in e:ar.call(e,l)))return!1}var h=o.get(t),f=o.get(e);if(h&&f)return h==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var g=t[l=a[u]],y=e[l];if(n)var m=s?n(y,g,l,e,t,o):n(g,y,l,t,e,o);if(!(void 0===m?g===y||i(g,y,r,n,o):m)){d=!1;break}p||(p="constructor"==l)}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,r,n,i,o))}function jr(t,e,r,n,i){return t===e||(null==t||null==e||!Ee(t)&&!Ee(e)?t!=t&&e!=e:Ar(t,e,r,n,jr,i))}function Er(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var Or=function(){try{var t=se(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Tr(t,e,r){"__proto__"==e&&Or?Or(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Pr=Object.prototype.hasOwnProperty;function Cr(t,e,r){var n=t[e];Pr.call(t,e)&&Tt(n,r)&&(void 0!==r||e in t)||Tr(t,e,r)}function Ir(t,e,r,n){var i=!r;r||(r={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),i?Tr(r,a,c):Cr(r,a,c)}return r}function Fr(t){return t}function Rr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Dr=Math.max;function Nr(t){return function(){return t}}var Lr=Or?function(t,e){return Or(t,"toString",{configurable:!0,enumerable:!1,value:Nr(e),writable:!0})}:Fr,Yr=Date.now;var $r,Ur,Wr,qr=($r=Lr,Ur=0,Wr=0,function(){var t=Yr(),e=16-(t-Wr);if(Wr=t,e>0){if(++Ur>=800)return arguments[0]}else Ur=0;return $r.apply(void 0,arguments)});function Gr(t,e){return qr(function(t,e,r){return e=Dr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=Dr(n.length-e,0),s=Array(o);++i<o;)s[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=r(s),Rr(t,this,a)}}(t,e,Fr),t+"")}function Br(t,e,r){if(!Bt(r))return!1;var n=typeof e;return!!("number"==n?ir(r)&&Ye(e,r.length):"string"==n&&e in r)&&Tt(r[e],t)}var Hr,Xr=(Hr=function(t,e,r,n){Ir(e,or(e),t,n)},Gr(function(t,e){var r=-1,n=e.length,i=n>1?e[n-1]:void 0,o=n>2?e[2]:void 0;for(i=Hr.length>3&&"function"==typeof i?(n--,i):void 0,o&&Br(e[0],e[1],o)&&(i=n<3?void 0:i,n=1),t=Object(t);++r<n;){var s=e[r];s&&Hr(t,s,r,i)}return t})),Vr=tr(Object.getPrototypeOf,Object),Zr=Function.prototype,Qr=Object.prototype,Jr=Zr.toString,Kr=Qr.hasOwnProperty,tn=Jr.call(Object);function en(t){if(!Ee(t))return!1;var e=Gt(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!Ee(t)||"[object Object]"!=Gt(t))return!1;var e=Vr(t);if(null===e)return!0;var r=Kr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Jr.call(r)==tn}(t)}var rn=Gr(function(t,e){try{return Rr(t,void 0,e)}catch(t){return en(t)?t:new Error(t)}});function nn(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var on=Object.prototype,sn=on.hasOwnProperty;function an(t,e,r,n){return void 0===t||Tt(t,on[r])&&!sn.call(n,r)?e:t}var cn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function un(t){return"\\"+cn[t]}var ln=/<%=([\s\S]+?)%>/g;var hn,fn=(hn={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==hn?void 0:hn[t]});function dn(t){return"symbol"==typeof t||Ee(t)&&"[object Symbol]"==Gt(t)}var pn=Nt?Nt.prototype:void 0,gn=pn?pn.toString:void 0;function yn(t){if("string"==typeof t)return t;if(Se(t))return nn(t,yn)+"";if(dn(t))return gn?gn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function mn(t){return null==t?"":yn(t)}var bn=/[&<>"']/g,vn=RegExp(bn.source);var xn={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ln,variable:"",imports:{_:{escape:function(t){return(t=mn(t))&&vn.test(t)?t.replace(bn,fn):t}}}},_n=/\b__p \+= '';/g,wn=/\b(__p \+=) '' \+/g,kn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Sn=/[()=,{}\[\]\/\s]/,Mn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zn=/($^)/,An=/['\n\r\u2028\u2029\\]/g,jn=Object.prototype.hasOwnProperty;var En=Object.prototype.hasOwnProperty;function On(t){if(!Bt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Ke(t),r=[];for(var n in t)("constructor"!=n||!e&&En.call(t,n))&&r.push(n);return r}function Tn(t,e){return t&&Ir(e,function(t){return ir(t)?Qe(t,!0):On(t)}(e),t)}var Pn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Cn=Pn&&"object"==typeof module&&module&&!module.nodeType&&module,In=Cn&&Cn.exports===Pn?Dt.Buffer:void 0,Fn=In?In.allocUnsafe:void 0;var Rn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ke(e,je(t)),t=Vr(t);return e}:Me;var Dn=Object.prototype.hasOwnProperty;var Nn=/\w*$/;var Ln=Nt?Nt.prototype:void 0,Yn=Ln?Ln.valueOf:void 0;function $n(t,e,r){var n,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new be(a).set(new be(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,Nn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Yn?Object(Yn.call(n)):{}}}var Un=Object.create,Wn=function(){function t(){}return function(e){if(!Bt(e))return{};if(Un)return Un(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var qn=He&&He.isMap,Gn=qn?We(qn):function(t){return Ee(t)&&"[object Map]"==wr(t)};var Bn=He&&He.isSet,Hn=Bn?We(Bn):function(t){return Ee(t)&&"[object Set]"==wr(t)},Xn="[object Arguments]",Vn="[object Function]",Zn="[object Object]",Qn={};function Jn(t,e,r,n,i,o){var s,a=2&e;if(void 0!==s)return s;if(!Bt(t))return t;var c=Se(t);if(c)return s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Dn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,s);var u=wr(t),l=u==Vn||"[object GeneratorFunction]"==u;if(Ne(t))return function(t){var e=t.length,r=Fn?Fn(e):new t.constructor(e);return t.copy(r),r}(t);if(u==Zn||u==Xn||l&&!i)return s=l?{}:function(t){return"function"!=typeof t.constructor||Ke(t)?{}:Wn(Vr(t))}(t),a?function(t,e){return Ir(t,Rn(t),e)}(t,Tn(s,t)):function(t,e){return Ir(t,je(t),e)}(t,function(t,e){return t&&Ir(e,or(e),t)}(s,t));if(!Qn[u])return i?t:{};s=$n(t,u),o||(o=new pe);var h=o.get(t);if(h)return h;o.set(t,s),Hn(t)?t.forEach(function(n){s.add(Jn(n,e,r,n,t,o))}):Gn(t)&&t.forEach(function(n,i){s.set(i,Jn(n,e,r,i,t,o))});var f=c?void 0:sr(t);return Er(f||t,function(n,i){f&&(n=t[i=n]),Cr(s,i,Jn(n,e,r,i,t,o))}),s}Qn[Xn]=Qn["[object Array]"]=Qn["[object ArrayBuffer]"]=Qn["[object DataView]"]=Qn["[object Boolean]"]=Qn["[object Date]"]=Qn["[object Float32Array]"]=Qn["[object Float64Array]"]=Qn["[object Int8Array]"]=Qn["[object Int16Array]"]=Qn["[object Int32Array]"]=Qn["[object Map]"]=Qn["[object Number]"]=Qn[Zn]=Qn["[object RegExp]"]=Qn["[object Set]"]=Qn["[object String]"]=Qn["[object Symbol]"]=Qn["[object Uint8Array]"]=Qn["[object Uint8ClampedArray]"]=Qn["[object Uint16Array]"]=Qn["[object Uint32Array]"]=!0,Qn["[object Error]"]=Qn[Vn]=Qn["[object WeakMap]"]=!1;function Kn(t){return Jn(t,4)}var ti=/\s/;var ei=/^\s+/;function ri(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ti.test(t.charAt(e)););return e}(t)+1).replace(ei,""):t}var ni=/^[-+]0x[0-9a-f]+$/i,ii=/^0b[01]+$/i,oi=/^0o[0-7]+$/i,si=parseInt;var ai=1/0;function ci(t){return t?(t=function(t){if("number"==typeof t)return t;if(dn(t))return NaN;if(Bt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Bt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ri(t);var r=ii.test(t);return r||oi.test(t)?si(t.slice(2),r?2:8):ni.test(t)?NaN:+t}(t))===ai||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function ui(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=ci(t),r=e%1;return e==e?r?e-r:e:0}(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=void 0),r}}var li=Object.prototype.hasOwnProperty;function hi(t){if(null==t)return!0;if(ir(t)&&(Se(t)||"string"==typeof t||"function"==typeof t.splice||Ne(t)||Ve(t)||Ie(t)))return!t.length;var e=wr(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Ke(t))return!nr(t).length;for(var r in t)if(li.call(t,r))return!1;return!0}let fi=0;function di(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 pi(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function gi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function yi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function mi(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function bi(t){if(this.__collection__)return this.__collection__[t]}function vi(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function xi(t){return this.__collection__?this.__collection__.indexOf(t):-1}function _i(){return this.__collection__?this.__collection__.length:0}function wi(){this.__collection__=[]}function ki(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function Si(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 Mi(t){const e=this.indexOf(t);if(-1==e||0==e)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(r,n)}function zi(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=r.concat(n,this.__collection__)}class Ai{constructor(){this.__collection__=[],this.insertAt=pi,this.append=gi,this.prepend=yi,this.remove=mi,this.getAt=bi,this.forEach=vi,this.indexOf=xi,this.size=_i,this.clear=wi,this.moveForward=ki,this.moveBackward=Si,this.moveToHead=Mi,this.moveToTail=zi}}const ji=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,r=this.cacheHit+this.cacheMiss,n=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:r>0?Math.round(this.cacheHit/r*1e3)/10:0,...n??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}},Ei=/\s+/;function Oi(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(const n in r){const i=r[n];t[e].apply(t,[n,i])}return!1}if(Ei.test(r)){return r.split(Ei).forEach(r=>t[e].apply(t,[r].concat(n))),!1}return!0}const Ti=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],Pi={withEvent(){Ti.forEach(t=>this[t]=Pi[t])},on(t,e,r){if(!Oi(this,"on",t,[e,r])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:r,ctx:r||this}),this},once(t,e,r){if(!Oi(this,"once",t,[e,r])||!e)return this;const n=this,i=function(t){return ui(2,t)}(function(){n.off(t,i,r),e.apply(n,arguments)});return i._callback=e,this.on(t,i,r),this},off(t,e,r){if(!this._listeners||!Oi(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._listeners=void 0,this;let n;n=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<n.length;t++){const i=n[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||r)for(let n=0;n<o.length;n++){const i=o[n];(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Ai),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&&Ii(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 r=this._listeners[e.name],n=this._listeners["(all)"];return r&&Ci(r,arguments),n&&Ci(n,arguments),this},trigger(t){ji.enabled&&ji.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&Ii(this._delegators,e),!this._listeners)return this;if(!Oi(this,"trigger",t,e))return this;const r=this._listeners[t],n=this._listeners["(all)"];return r&&Ci(r,e),n&&Ci(n,e),this},stopListening(t,e,r){let n=this._listeningTo;if(!n)return this;const i=!e&&!r;r||"object"!=typeof e||(r=this),t&&(n={},n[t._listenId]=t);for(const t in n){const o=n[t];o.off(e,r,this),(i||hi(o._events))&&delete this._listeningTo[t]}return this}};function Ci(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function Ii(t,e){t.forEach(t=>Pi.delegate.apply(t,e))}const Fi={listenTo:"on",listenToOnce:"once"};for(const t in Fi){const e=Fi[t];Pi[t]=function(t,r,n){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++fi}`);return i[t._listenId]=t,n||"object"!=typeof r||(n=this),t[e](r,n,this),this}}const Ri=Pi.on,Di=Pi.off,Ni=Pi.once,Li=Pi.trigger,Yi=Pi.delegate_on,$i=Pi.delegate_off;const Ui=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Wi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function qi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Gi(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 Bi,Hi={exports:{}};var Xi=(Bi||(Bi=1,function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new O(n||[]);return i(s,"_invoke",{value:z(t,r,a)}),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f="suspendedStart",d="suspendedYield",p="executing",g="completed",y={};function m(){}function b(){}function v(){}var x={};u(x,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(T([])));w&&w!==r&&n.call(w,s)&&(x=w);var k=v.prototype=m.prototype=Object.create(x);function S(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function M(t,e){function r(i,o,s,a){var c=h(t[i],t,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,s,a)},function(t){r("throw",t,s,a)}):e.resolve(l).then(function(t){u.value=t,s(u)},function(t){return r("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e(function(e,i){r(t,n,e,i)})}return o=o?o.then(i,i):i()}})}function z(t,r,n){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===g){if("throw"===o)throw s;return{value:e,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=A(a,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=h(t,r,n);if("normal"===u.type){if(i=n.done?g:d,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=g,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=h(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var s=o.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function T(t){if(null!=t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};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}},S(M.prototype),u(M.prototype,a,function(){return this}),t.AsyncIterator=M,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new M(l(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},S(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),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=T,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(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.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=n.call(s,"catchLoc"),u=n.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 r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,y):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),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:T(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},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 r=[],n=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?n=r.push(a):(a-=65536,n=r.push(55296+(a>>10),a%1024+56320)),n>=16383&&(i+=t.apply(null,r),r.length=0)}return i+t.apply(null,r)};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,r=e(t,t,t)&&e}catch(t){}return r}(),e=function(t){if(null==this)throw TypeError();var e=String(this),r=e.length,n=t?Number(t):0;if(n!=n&&(n=0),!(n<0||n>=r)){var i,o=e.charCodeAt(n);return o>=55296&&o<=56319&&r>n+1&&(i=e.charCodeAt(n+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,r,n){function i(s,a){if(!r[s]){if(!e[s]){if(!a&&Gi)return Gi(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,r,n)}return r[s].exports}for(var o=Gi,s=0;s<n.length;s++)i(n[s]);return i}return t}()({1:[function(t,e,r){var n=t("./utils"),i=function(){var t=n.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],r=["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,n){var s=function t(n,s,a){var c="";if(n<=19)c=(s?" and ":"")+(a?r[n]:e[n]);else if(n<100){var u=Math.floor(n/10),l=n%10;c=(s?" and ":"")+i[u-2],l>0?c+="-"+t(l,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(n<1e3){var h=Math.floor(n/100),f=n%100;c=(s?", ":"")+e[h]+" Hundred",f>0?c+=t(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(n)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),g=Math.floor(n/p),y=n-g*p;c=(s?", ":"")+t(g,!1,!1)+" "+o[d-1],y>0?c+=t(y,!0,a):a&&(c+="th")}return c};return s(t,!1,n)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),r=[0];return e.forEach(function(t){if(t<100){var e=r.pop();e>=1e3&&(r.push(e),e=0),r.push(e+t)}else r.push(r.pop()*t)}),r.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var r=t.toLowerCase();a[r]=10*(e+2),a[r.substring(0,t.length-1)+"ieth"]=a[r]}),a.hundredth=100,o.forEach(function(t,e){var r=t.toLowerCase(),n=Math.pow(10,3*(e+1));a[r]=n,a[r+"th"]=n});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"]],l={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function h(t){for(var e=0;e<u.length;e++){var r=u[e];if(t>=r[0])return r[1]+h(t-r[0])}return""}function f(t){for(var e=0,r=1,n=t.length-1;n>=0;n--){var i=t[n],o=l[i];o<r?e-=o:(r=o,e+=o)}return e}function d(t,e){for(var r=[],n=e.charCodeAt(0);t>0;)r.unshift(String.fromCharCode((t-1)%26+n)),t=Math.floor((t-1)/26);return r.join("")}function p(t,e){for(var r=e.charCodeAt(0),n=0,i=0;i<t.length;i++)n+=(t.charCodeAt(t.length-i-1)-r+1)*Math.pow(26,i);return n}function g(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var y={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,r){var n,i=e<0;switch(e=Math.abs(e),r.primary){case y.LETTERS:n=d(e,r.case===m.UPPER?"A":"a");break;case y.ROMAN:n=h(e),r.case===m.UPPER&&(n=n.toUpperCase());break;case y.WORDS:n=s(e,r.ordinal),r.case===m.UPPER?n=n.toUpperCase():r.case===m.LOWER&&(n=n.toLowerCase());break;case y.DECIMAL:n=""+e;var o=r.mandatoryDigits-n.length;if(o>0){var a=new Array(o+1).join("0");n=a+n}if(48!==r.zeroCode&&(n=t(n).map(function(t){return String.fromCodePoint(t.codePointAt(0)+r.zeroCode-48)}).join("")),r.regular)for(var c=Math.floor((n.length-1)/r.groupingSeparators.position);c>0;c--){var u=n.length-c*r.groupingSeparators.position;n=n.substr(0,u)+r.groupingSeparators.character+n.substr(u)}else r.groupingSeparators.reverse().forEach(function(t){var e=n.length-t.position;n=n.substr(0,e)+t.character+n.substr(e)});if(r.ordinal){var l={1:"st",2:"nd",3:"rd"}[n[n.length-1]];(!l||n.length>1&&"1"===n[n.length-2])&&(l="th"),n+=l}break;case y.SEQUENCE:throw{code:"D3130",value:r.token}}return i&&(n="-"+n),n}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 r,n={type:"integer",primary:y.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?r=e:(r=e.substring(0,i),"o"===e.substring(i+1)[0]&&(n.ordinal=!0)),r){case"A":n.case=m.UPPER;case"a":n.primary=y.LETTERS;break;case"I":n.case=m.UPPER;case"i":n.primary=y.ROMAN;break;case"W":n.case=m.UPPER,n.primary=y.WORDS;break;case"Ww":n.case=m.TITLE,n.primary=y.WORDS;break;case"w":n.primary=y.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(r).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,r=0;r<v.length;r++){var n=v[r];if(t>=n&&t<=n+9){if(e=!0,s++,u++,null===o)o=n;else if(n!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){n.primary=y.DECIMAL,n.zeroCode=o,n.mandatoryDigits=s,n.optionalDigits=a;var l=function(t){if(0===t.length)return 0;for(var e=t[0].character,r=1;r<t.length;r++)if(t[r].character!==e)return 0;for(var n=t.map(function(t){return t.position}),i=function t(e,r){return 0===r?e:t(r,e%r)},o=n.reduce(i),s=1;s<=n.length;s++)if(-1===n.indexOf(s*o))return 0;return o}(c);l>0?(n.regular=!0,n.groupingSeparators={position:l,character:c[0].character}):(n.regular=!1,n.groupingSeparators=c)}else n.primary=y.SEQUENCE,n.token=r}return n}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=[],r={type:"datetime",parts:e},n=function(r,n){if(n>r){var i=t.substring(r,n);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)){n(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(n(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 l=a.substring(u+1),h=l.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===h?f=l:(f=l.substring(0,h),d=l.substring(h+1));var g={min:p(f),max:p(d)};c.width=g,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var y=s.charAt(s.length-1);-1!=="atco".indexOf(y)?(c.presentation2=y,"o"===y&&(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 n(i,o),r}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],M=864e5,z=function(t){var e=Date.UTC(t.year,t.month),r=new Date(e).getUTCDay();return 0===r&&(r=7),r>4?e+(8-r)*M:e-(r-1)*M},A=function t(e,r){return{year:e,month:r,nextMonth:function(){return 11===r?t(e+1,0):t(e,r+1)},previousMonth:function(){return 0===r?t(e-1,11):t(e,r-1)},nextYear:function(){return t(e+1,r)},previousYear:function(){return t(e-1,r)}}},j=function(t,e){return(e-t)/(7*M)+1},E=function(t,e){var r;switch(e){case"Y":r=t.getUTCFullYear();break;case"M":r=t.getUTCMonth()+1;break;case"D":r=t.getUTCDate();break;case"d":r=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/M+1;break;case"F":0===(r=t.getUTCDay())&&(r=7);break;case"W":var n=A(t.getUTCFullYear(),0),i=z(n),o=Date.UTC(n.year,t.getUTCMonth(),t.getUTCDate()),s=j(i,o);if(s>52)o>=z(n.nextYear())&&(s=1);else if(s<1){var a=z(n.previousYear());s=j(a,o)}r=Math.floor(s);break;case"w":var c=A(t.getUTCFullYear(),t.getUTCMonth()),u=z(c),l=Date.UTC(c.year,c.month,t.getUTCDate()),h=j(u,l);if(h>4)l>=z(c.nextMonth())&&(h=1);else if(h<1){var f=z(c.previousMonth());h=j(f,l)}r=Math.floor(h);break;case"X":var d=A(t.getUTCFullYear(),0),p=z(d),g=z(d.nextYear()),y=t.getTime();r=y<p?d.year-1:y>=g?d.year+1:d.year;break;case"x":var m=A(t.getUTCFullYear(),t.getUTCMonth()),b=z(m),v=m.nextMonth(),x=z(v),_=t.getTime();r=_<b?m.previousMonth().month+1:_>=x?v.month+1:m.month+1;break;case"H":r=t.getUTCHours();break;case"h":r=t.getUTCHours(),0==(r%=12)&&(r=12);break;case"P":r=t.getUTCHours()>=12?"pm":"am";break;case"m":r=t.getUTCMinutes();break;case"s":r=t.getUTCSeconds();break;case"f":r=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":r="ISO"}return r},O=null;function T(t,e,r){var n=0,i=0;if(void 0!==r){var o=parseInt(r);n=Math.floor(o/100),i=o%100}var s,a=function(t,e){var r=E(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(r%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)r=S[r-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};r=k[r]}e.names===m.UPPER?r=r.toUpperCase():e.names===m.LOWER&&(r=r.toLowerCase()),e.width&&r.length>e.width.max&&(r=r.substring(0,e.width.max))}else r=b(r,e.integerFormat);else if("f"===e.component)r=b(r,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*n+i;if(e.integerFormat.regular)r=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)r=b(n,e.integerFormat),0!==i&&(r+=":"+g(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};r=b(o,e.integerFormat)}}o>=0&&(r="+"+r),"z"===e.component&&(r="GMT"+r),0===o&&"t"===e.presentation2&&(r="Z")}return r};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*n+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function P(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var r;Array.isArray(t.integerFormat.groupingSeparators)||(r=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",r&&(e.regex+=r.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var n=0,i=0;return r?(n=Number.parseInt(e.substring(0,e.indexOf(r.character))),i=Number.parseInt(e.substring(e.indexOf(r.character)+1))):e.length-1<=2?n=Number.parseInt(e):(n=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*n+i}}else if(t.integerFormat)t.integerFormat.n=t.n,e=P(t.integerFormat);else{e.regex="[a-zA-Z]+";var n={};if("M"===t.component||"x"===t.component)S.forEach(function(e,r){t.width&&t.width.max?n[e.substring(0,t.width.max)]=r+1:n[e]=r+1});else if("F"===t.component)k.forEach(function(e,r){r>0&&(t.width&&t.width.max?n[e.substring(0,t.width.max)]=r:n[e]=r)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};n={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return n[t]}}return e.component=t.component,e});else{e.type="integer";var r,n=t.case===m.UPPER;switch(r=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case y.LETTERS:e.regex=n?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,n?"A":"a")};break;case y.ROMAN:e.regex=n?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(n?t:t.toUpperCase())};break;case y.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case y.DECIMAL:e.regex="[0-9]".concat(r),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var r=e;return t.ordinal&&(r=e.substring(0,e.length-2)),t.regular?r=r.split(",").join(""):t.groupingSeparators.forEach(function(t){r=r.split(t.character).join("")}),48!==t.zeroCode&&(r=r.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(r)};break;case y.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function C(t,e){if(void 0!==t)return P(x(e)).parse(t)}function I(t,e){var r=P(w(e)),n="^"+r.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(n,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,l=47,h={},f=1;f<i.length;f++){var d=r.parts[f-1];d.parse&&(h[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(h).length)return;var p=0,g=function(t){p<<=1,p+=t?1:0},y=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return g(h[t])});var m=!y(o)&&y(s),b=y(a),v=!b&&y(c);p=0,"PHhmsf".split("").forEach(function(t){return g(h[t])});var x=!y(u)&&y(l),_=(m?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),k=this.environment.timestamp,S=!1,M=!1;if(_.split("").forEach(function(t){if(void 0===h[t])S?(h[t]=-1!=="MDd".indexOf(t)?1:0,M=!0):h[t]=E(k,t);else if(S=!0,M)throw{code:"D3136"}}),h.M>0?h.M-=1:h.M=0,m){var z=Date.UTC(h.Y,0),A=1e3*(h.d-1)*60*60*24,j=new Date(z+A);h.M=j.getUTCMonth(),h.D=j.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(h.H=12===h.h?0:h.h,1===h.P&&(h.H+=12));var O=Date.UTC(h.Y,h.M,h.D,h.H,h.m,h.s,h.f);return(h.Z||h.z)&&(O-=60*(h.Z||h.z)*1e3),O}}var F=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 R(t,e){if(void 0!==t){if(void 0===e){if(!F.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return I.call(this,t,e)}}function D(t,e,r){if(void 0!==t)return T.call(this,t,e,r)}return{formatInteger:g,parseInteger:C,fromMillis:D,toMillis:R}}();e.exports=i},{"./utils":6}],2:[function(t,e,r){(function(r){(function(){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new P(n||[]);return s(o,"_invoke",{value:j(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function v(){}function x(){}function _(){}var w={};h(w,c,function(){return this});var k=Object.getPrototypeOf,S=k&&k(k(C([])));S&&S!==r&&o.call(S,c)&&(w=S);var M=_.prototype=v.prototype=Object.create(w);function z(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&o.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(h).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function j(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function C(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=_,s(M,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:x,configurable:!0}),x.displayName=h(_,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,h(t,l,"GeneratorFunction")),t.prototype=Object.create(M),t},e.awrap=function(t){return{__await:t}},z(A.prototype),h(A.prototype,u,function(){return this}),e.AsyncIterator=A,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new A(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},z(M),h(M,l,"Generator"),h(M,c,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:C(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./utils"),s=function(){var t=i().mark($),e=i().mark(U),s=i().mark(W),a=i().mark(q),c=i().mark(Q),u=i().mark(ft),l=i().mark(dt),h=i().mark(pt),f=i().mark(yt),d=i().mark(St),p=i().mark(jt),g=i().mark(Tt),y=o.isNumeric,m=o.isArrayOfStrings,b=o.isArrayOfNumbers,v=o.createSequence,x=o.isSequence,_=o.isFunction,w=o.isLambda,k=o.isIterable,S=o.getFunctionArity,M=o.isDeepEqual,z=o.stringToArray;function A(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function j(t){return void 0===t?0:t.length}function E(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function O(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function T(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function P(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(_(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&y(e)?Number(e.toPrecision(15)):e&&_(e)?"":e},n)}return r}}function C(t,e,r){if(void 0!==t){var n=z(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var o=e>=0?e+r:i+e+r;return n.slice(e,o).join("")}return n.slice(e).join("")}}function I(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function F(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function R(t){if(void 0!==t)return t.toLowerCase()}function D(t){if(void 0!==t)return t.toUpperCase()}function N(t){if(void 0!==t)return z(t).length}function L(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 Y(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-N(t);if(i>0){var o=new Array(i+1).join(r);r.length>1&&(o=C(o,0,i)),n=e>0?t+o:o+t}else n=t;return n}}function $(e,r){var n;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.apply(this,[r]),!k(n)){t.next=4;break}return t.delegateYield(n,"t0",3);case 3:n=t.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||_(n.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}},t,this)}function U(t,r){var n,o;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof r){e.next=6;break}n=-1!==t.indexOf(r),e.next=9;break;case 6:return e.delegateYield($(r,t),"t0",7);case 7:o=e.t0,n=void 0!==o;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e)}function W(t,e,r){var n,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=v(),!(void 0===r||r>0)){i.next=17;break}return o=0,i.delegateYield($(e,t),"t0",8);case 8:if(void 0===(a=i.t0)){i.next=17;break}case 10:if(void 0===a||!(void 0===r||o<r)){i.next=17;break}return n.push({match:a.match,index:a.start,groups:a.groups}),i.delegateYield($(a.next),"t1",13);case 13:a=i.t1,o++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}},s)}function q(t,e,r,n){var o,s,c,u,l,h,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(o=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(s="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var o=r.charAt(n);if("$"===o)e+="$",n++;else if("0"===o)e+=t.match,n++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+s),10),s>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,c="",u=0,!(void 0===n||n>0)){i.next=44;break}if(l=0,"string"!=typeof e){i.next=18;break}for(h=t.indexOf(e,u);-1!==h&&(void 0===n||l<n);)c+=t.substring(u,h),c+=r,u=h+e.length,l++,h=t.indexOf(e,u);c+=t.substring(u),i.next=42;break;case 18:return i.delegateYield($(e,t),"t0",19);case 19:if(void 0===(f=i.t0)){i.next=41;break}case 21:if(void 0===f||!(void 0===n||l<n)){i.next=38;break}if(c+=t.substring(u,f.start),d=s.apply(o,[f]),!k(d)){i.next=27;break}return i.delegateYield(d,"t1",26);case 26:d=i.t1;case 27:if("string"!=typeof d){i.next=31;break}c+=d,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:d};case 32:return u=f.start+f.match.length,l++,i.delegateYield($(f.next),"t2",35);case 35:f=i.t2,i.next=21;break;case 38:c+=t.substring(u),i.next=42;break;case 41:c=t;case 42:i.next=45;break;case 44:c=t;case 45:return i.abrupt("return",c);case 46:case"end":return i.stop()}},a,this)}function G(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new r.Buffer.from(t,"binary").toString("base64")};return e(t)}}function B(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new r.Buffer.from(t,"base64").toString("binary")};return e(t)}}function H(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 X(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 V(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 Z(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 Q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return o=0,i.delegateYield($(e,t),"t0",12);case 12:if(void 0===(s=i.t0)){i.next=26;break}a=0;case 15:if(void 0===s||!(void 0===r||o<r)){i.next=23;break}return n.push(t.substring(a,s.start)),a=s.end,i.delegateYield($(s.next),"t1",19);case 19:s=i.t1,o++,i.next=15;break;case 23:(void 0===r||o<r)&&n.push(t.substring(a)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}},c)}function J(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function K(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach(function(t){n[t]=r[t]});for(var i=[],o=n["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),c=e.split(n["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,r,i,o,s=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),c=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),u=t.substring(s.length,t.length-c.length),l=t.indexOf(n["exponent-separator"],s.length);-1===l||l>t.length-c.length?(e=u,r=void 0):(e=u.substring(0,l),r=u.substring(l+1));var h=e.indexOf(n["decimal-separator"]);return-1===h?(i=e,o=c):(i=e.substring(0,h),o=e.substring(h+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:o,subpicture:t}},l=function(t){var e,r,o=t.subpicture,s=o.indexOf(n["decimal-separator"]);s!==o.lastIndexOf(n["decimal-separator"])&&(e="D3081"),o.indexOf(n.percent)!==o.lastIndexOf(n.percent)&&(e="D3082"),o.indexOf(n["per-mille"])!==o.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==o.indexOf(n.percent)&&-1!==o.indexOf(n["per-mille"])&&(e="D3084");var c=!1;for(r=0;r<t.mantissaPart.length;r++){var u=t.mantissaPart.charAt(r);if(-1!==i.indexOf(u)||u===n.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)!==n["grouping-separator"]&&o.charAt(s+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(n.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var h="string"==typeof t.exponentPart;if(h&&t.exponentPart.length>0&&(-1!==o.indexOf(n.percent)||-1!==o.indexOf(n["per-mille"]))&&(e="D3092"),h&&(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}},h=function(t){var e=function(e,r){for(var o=[],s=e.indexOf(n["grouping-separator"]);-1!==s;){var a=(r?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length;o.push(a),s=t.integerPart.indexOf(n["grouping-separator"],s+1)}return o},r=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r}(r),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),l=u.filter(function(t){return-1!==i.indexOf(t)}).length,h=u.filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===h&&(f?(l=1,h=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(n.digit)&&(a=1),0===a&&0===l&&(l=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:r,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:l,maximumFactionalPartSize:h,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},f=c.map(u);f.forEach(l);var d,p,g,y,m=f.map(h),b=n["minus-sign"],v=n["zero-digit"],x=n["decimal-separator"],_=n["grouping-separator"];if(1===m.length&&(m.push(JSON.parse(JSON.stringify(m[0]))),m[1].prefix=b+m[1].prefix),p=-1!==(d=t>=0?m[0]:m[1]).picture.indexOf(n.percent)?100*t:-1!==d.picture.indexOf(n["per-mille"])?1e3*t:t,0===d.minimumExponentSize)g=p;else{var w=Math.pow(10,d.scalingFactor),k=Math.pow(10,d.scalingFactor-1);for(g=p,y=0;g<k;)g*=10,y-=1;for(;g>w;)g/=10,y+=1}var S=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==v&&(r=r.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),r},M=S(ot(g,d.maximumFactionalPartSize),d.maximumFactionalPartSize),z=M.indexOf(".");for(-1===z?M+=x:M=M.replace(".",x);M.charAt(0)===v;)M=M.substring(1);for(;M.charAt(M.length-1)===v;)M=M.substring(0,M.length-1);z=M.indexOf(x);var A=d.minimumIntegerPartSize-z,j=d.minimumFactionalPartSize-(M.length-z-1);if(M=(A>0?new Array(A+1).join(v):"")+M,M+=j>0?new Array(j+1).join(v):"",z=M.indexOf(x),d.regularGrouping>0)for(var E=Math.floor((z-1)/d.regularGrouping),O=1;O<=E;O++)M=[M.slice(0,z-O*d.regularGrouping),_,M.slice(z-O*d.regularGrouping)].join("");else d.integerPartGroupingPositions.forEach(function(t){M=[M.slice(0,z-t),_,M.slice(z-t)].join(""),z++});if(z=M.indexOf(x),d.fractionalPartGroupingPositions.forEach(function(t){M=[M.slice(0,t+z+1),_,M.slice(t+z+1)].join("")}),z=M.indexOf(x),-1!==d.picture.indexOf(x)&&z!==M.length-1||(M=M.substring(0,M.length-1)),void 0!==y){var T=S(y,0);(A=d.minimumExponentSize-T.length)>0&&(T=new Array(A+1).join(v)+T),M=M+n["exponent-separator"]+(y<0?b:"")+T}return M=d.prefix+M+d.suffix}}function tt(t,e){if(void 0!==t){if(t=ot(t),(e=void 0===e?10:ot(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(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 rt(t){if(void 0!==t)return Math.abs(t)}function nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function ot(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function st(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function ct(){return Math.random()}function ut(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ut(t[0]):t.length>1&&(e=t.filter(function(t){return ut(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):y(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function lt(t){if(void 0!==t)return!ut(t)}function ht(t,e,r,n){var i=[e],o=S(t);return o>=2&&i.push(r),o>=3&&i.push(n),i}function ft(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=v(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return o=ht(e,t[n],n,t),i.delegateYield(e.apply(this,o),"t0",7);case 7:void 0!==(s=i.t0)&&r.push(s);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}},u,this)}function dt(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=v(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return o=t[n],s=ht(e,o,n,t),i.delegateYield(e.apply(this,s),"t0",8);case 8:ut(i.t0)&&r.push(o);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}},l,this)}function pt(t,e){var r,n,o,s,a,c,u;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,o=0;case 4:if(!(o<t.length)){i.next=22;break}if(s=t[o],a=!0,void 0===e){i.next=12;break}return c=ht(e,s,o,t),i.delegateYield(e.apply(this,c),"t0",10);case 10:u=i.t0,a=ut(u);case 12:if(!a){i.next=19;break}if(r){i.next=18;break}n=s,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:o};case 19:o++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}},h,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),n=0;n<r;n++){var i=e.map(function(t){return t[n]});t.push(i)}return t}function yt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((o=S(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],s=1):(n=r,s=0);case 6:if(!(s<t.length)){i.next=15;break}return a=[n,t[s]],o>=3&&a.push(s),o>=4&&a.push(t),i.delegateYield(e.apply(this,a),"t0",11);case 11:n=i.t0,s++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},f,this)}function mt(t){var e=v();if(Array.isArray(t)){var r={};t.forEach(function(t){mt(t).forEach(function(t){r[t]=!0})}),e=mt(r)}else null===t||"object"!==n(t)||w(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var r;if(Array.isArray(t)){r=v();for(var i=0;i<t.length;i++){var o=bt(t[i],e);void 0!==o&&(Array.isArray(o)?o.forEach(function(t){return r.push(t)}):r.push(o))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function vt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=v(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function xt(t){return void 0!==t}function _t(t){var e=v();if(Array.isArray(t))t.forEach(function(t){e=vt(e,_t(t))});else if(null===t||"object"!==n(t)||w(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function wt(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var r in t)e[r]=t[r]}),e}}function kt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function St(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r=v(),a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return n=a.t1.value,o=ht(e,t[n],n,t),a.delegateYield(e.apply(this,o),"t2",6);case 6:void 0!==(s=a.t2)&&r.push(s),a.next=2;break;case 10:return a.abrupt("return",r);case 11:case"end":return a.stop()}},d,this)}function Mt(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function zt(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function At(t){if(void 0!==t)return null===t?"null":y(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":_(t)?"function":"object"}function jt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||m(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark(function t(e,r){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:r=e;case 11:return n=i().mark(function t(e,n){var o,s;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=i().mark(function t(e,n,o){return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,o),i.next=16;break;case 4:if(0!==o.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],o[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(o[0]),i.delegateYield(t(e,n,o.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),o),"t2",16);case 16:case"end":return i.stop()}},t)}),s=[],t.delegateYield(o(s,e,n),"t0",3);case 3:return t.abrupt("return",s);case 4:case"end":return t.stop()}},t)}),o=i().mark(function t(e){var r,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),o=e.slice(0,r),s=e.slice(r),i.delegateYield(t(o),"t0",8);case 8:return o=i.t0,i.delegateYield(t(s),"t1",10);case 10:return s=i.t1,i.delegateYield(n(o,s),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}},t)}),a.delegateYield(o(t),"t0",14);case 14:return s=a.t0,a.abrupt("return",s);case 16:case"end":return a.stop()}},p)}function Et(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Ot(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=x(t)?v():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,o=0;o<e.length;o++)if(M(n,e[o])){i=!0;break}i||e.push(n)}return e}}function Tt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r={},a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return n=a.t1.value,o=t[n],s=ht(e,o,n,t),a.delegateYield(e.apply(this,s),"t2",7);case 7:ut(a.t2)&&(r[n]=o),a.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),a.abrupt("return",r);case 13:case"end":return a.stop()}},g,this)}return{sum:A,count:j,max:E,min:O,average:T,string:P,substring:C,substringBefore:I,substringAfter:F,lowercase:R,uppercase:D,length:N,trim:L,pad:Y,match:W,contains:U,replace:q,split:Q,join:J,formatNumber:K,formatBase:tt,number:et,floor:nt,ceil:it,round:ot,abs:rt,sqrt:st,power:at,random:ct,boolean:ut,not:lt,map:ft,zip:gt,filter:dt,single:pt,foldLeft:yt,sift:Tt,keys:mt,lookup:bt,append:vt,exists:xt,spread:_t,merge:wt,reverse:kt,each:St,error:Mt,assert:zt,type:At,sort:jt,shuffle:Et,distinct:Ot,base64encode:G,base64decode:B,encodeUrlComponent:H,encodeUrl:X,decodeUrlComponent:V,decodeUrl:Z}}();e.exports=s}).call(this)}).call(this,void 0!==Wi?Wi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new P(n||[]);return s(o,"_invoke",{value:j(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function v(){}function x(){}function _(){}var w={};h(w,c,function(){return this});var k=Object.getPrototypeOf,S=k&&k(k(C([])));S&&S!==r&&o.call(S,c)&&(w=S);var M=_.prototype=v.prototype=Object.create(w);function z(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&o.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(h).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function j(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function C(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=_,s(M,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:x,configurable:!0}),x.displayName=h(_,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,h(t,l,"GeneratorFunction")),t.prototype=Object.create(M),t},e.awrap=function(t){return{__await:t}},z(A.prototype),h(A.prototype,u,function(){return this}),e.AsyncIterator=A,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new A(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},z(M),h(M,l,"Generator"),h(M,c,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:C(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./datetime"),s=t("./functions"),a=t("./utils"),c=t("./parser"),u=t("./signature"),l=function(){var t=i().mark(Y),e=i().mark($),r=i().mark(W),l=i().mark(q),h=i().mark(G),f=i().mark(B),d=i().mark(H),p=i().mark(X),g=i().mark(ot),y=i().mark(ct),m=i().mark(ht),b=i().mark(ft),v=i().mark(dt),x=i().mark(yt),_=i().mark(vt),w=i().mark(xt),k=i().mark(_t),S=i().mark(wt),M=i().mark(St),z=i().mark(zt),A=i().mark(Et),j=i().mark(Pt),E=a.isNumeric,O=a.isArrayOfStrings,T=a.isArrayOfNumbers,P=a.createSequence,C=a.isSequence,I=a.isFunction,F=a.isLambda,R=a.isIterable,D=a.getFunctionArity,N=a.isDeepEqual,L=It(null);function Y(e,r,n){var o,s,a,c;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield($(e,r,n),"t1",6);case 6:return o=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(H(e,r,n),"t2",9);case 9:return o=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return o=t.t3,t.abrupt("break",50);case 14:return o=V(e,r),t.abrupt("break",50);case 16:return o=Z(e),t.abrupt("break",50);case 18:return o=Q(e,r),t.abrupt("break",50);case 20:return o=K(e,r),t.abrupt("break",50);case 22:return o=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ft(e,r,n),"t4",25);case 25:return o=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(dt(e,r,n),"t5",28);case 28:return o=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ht(e,r,n),"t6",31);case 31:return o=t.t6,t.abrupt("break",50);case 33:return o=pt(e),t.abrupt("break",50);case 35:return t.delegateYield(xt(e,r,n),"t7",36);case 36:return o=t.t7,t.abrupt("break",50);case 38:return o=gt(e,r,n),t.abrupt("break",50);case 40:return o=kt(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(St(e,r,n),"t8",43);case 43:return o=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(vt(e,r,n),"t9",46);case 46:return o=t.t9,t.abrupt("break",50);case 48:return o=mt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=o&&"function"==typeof o.then||(o=Promise.resolve(o)),!n.async||"function"!=typeof o.then||!e.nextFunction||"function"!=typeof o[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,o;case 56:o=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield(B(e.predicate[a].expr,o,n),"t10",61);case 61:o=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,o,n),"t11",67);case 67:o=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,o),o&&C(o)&&!o.tupleStream&&(e.keepArray&&(o.keepSingleton=!0),0===o.length?o=void 0:1===o.length&&(o=o.keepSingleton?o:o[0])),t.abrupt("return",o);case 72:case"end":return t.stop()}},t)}function $(t,r,n){var o,s,a,c,u,l;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=Array.isArray(r)&&"variable"!==t.steps[0].type?r:P(r),a=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((l=t.steps[u]).tuple&&(a=!0),0!==u||!l.consarray){e.next=12;break}return e.delegateYield(Y(l,o,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(G(l,o,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(W(l,o,n,u===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(a||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===l.focus&&(o=s);case 22:u++,e.next=4;break;case 25:if(a)if(t.tuple)s=c;else for(s=P(),u=0;u<c.length;u++)s.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=P(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}},e)}function U(t,e){var r=It(t);for(var n in e)r.bind(n,e[n]);return r}function W(t,e,n,o){var s,a,c,u,l;return i().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(yt(t,e,n),"t0",2);case 2:if(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(q(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=P(),a=0;case 9:if(!(a<e.length)){r.next=24;break}return r.delegateYield(Y(t,e[a],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}u=0;case 14:if(!(u<t.stages.length)){r.next=20;break}return r.delegateYield(B(t.stages[u].expr,c,n),"t3",16);case 16:c=r.t3;case 17:u++,r.next=14;break;case 20:void 0!==c&&s.push(c);case 21:a++,r.next=9;break;case 24:return l=P(),o&&1===s.length&&Array.isArray(s[0])&&!C(s[0])?l=s[0]:s.forEach(function(t){!Array.isArray(t)||t.cons?l.push(t):t.forEach(function(t){return l.push(t)})}),r.abrupt("return",l);case 27:case"end":return r.stop()}},r)}function q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:n=e,o=0;case 2:if(!(o<t.length)){i.next=15;break}s=t[o],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(B(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(a=0;a<n.length;a++)n[a][s.value]=a;return i.abrupt("break",12);case 12:o++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},l)}function G(t,e,r,n){var o,s,a,c,u,l,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(yt(t,r,n),"t0",3);case 3:o=i.t0,i.next=11;break;case 6:return i.delegateYield(yt(t,e,n),"t1",7);case 7:for(s=i.t1,(o=P()).tupleStream=!0,a=0;a<s.length;a++)(c={"@":s[a]})[t.index]=a,o.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(q(t.stages,o,n),"t2",13);case 13:o=i.t2;case 14:return i.abrupt("return",o);case 15:(o=P()).tupleStream=!0,u=n,void 0===r&&(r=e.map(function(t){return{"@":t}})),l=0;case 20:if(!(l<r.length)){i.next=28;break}return u=U(n,r[l]),i.delegateYield(Y(t,r[l]["@"],u),"t3",23);case 23:if(void 0!==(f=i.t3))for(Array.isArray(f)||(f=[f]),d=0;d<f.length;d++)c={},Object.assign(c,r[l]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[l]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[l]["@"])),o.push(c);case 25:l++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(q(t.stages,o,n),"t4",30);case 30:o=i.t4;case 31:return i.abrupt("return",o);case 32:case"end":return i.stop()}},h)}function B(t,e,r){var n,o,a,c,u,l;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=P(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=P(e)),"number"!==t.type){i.next=10;break}(o=Math.floor(t.value))<0&&(o=e.length+o),void 0!==(a=e[o])&&(Array.isArray(a)?n=a:n.push(a)),i.next=23;break;case 10:o=0;case 11:if(!(o<e.length)){i.next=23;break}return a=e[o],c=a,u=r,e.tupleStream&&(c=a["@"],u=U(r,a)),i.delegateYield(Y(t,c,u),"t0",17);case 17:l=i.t0,E(l)&&(l=[l]),T(l)?l.forEach(function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===o&&n.push(a)}):s.boolean(l)&&n.push(a);case 20:o++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}},f)}function H(t,e,r){var n,o,s,a,c;return i().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=u.t0,s=t.value,a=i().mark(function n(){return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}},n)}),"and"!==s&&"or"!==s){u.next=15;break}return u.prev=5,u.delegateYield(ot(o,a,s),"t1",7);case 7:return u.abrupt("return",u.t1);case 10:throw u.prev=10,u.t2=u.catch(5),u.t2.position=t.position,u.t2.token=s,u.t2;case 15:return u.delegateYield(a(),"t3",16);case 16:c=u.t3,u.prev=17,u.t4=s,u.next="+"===u.t4||"-"===u.t4||"*"===u.t4||"/"===u.t4||"%"===u.t4?21:"="===u.t4||"!="===u.t4?23:"<"===u.t4||"<="===u.t4||">"===u.t4||">="===u.t4?25:"&"===u.t4?27:".."===u.t4?29:"in"===u.t4?31:33;break;case 21:return n=et(o,c,s),u.abrupt("break",33);case 23:return n=rt(o,c,s),u.abrupt("break",33);case 25:return n=nt(o,c,s),u.abrupt("break",33);case 27:return n=at(o,c),u.abrupt("break",33);case 29:return n=lt(o,c),u.abrupt("break",33);case 31:return n=it(o,c),u.abrupt("break",33);case 33:u.next=40;break;case 35:throw u.prev=35,u.t5=u.catch(17),u.t5.position=t.position,u.t5.token=s,u.t5;case 40:return u.abrupt("return",n);case 41:case"end":return u.stop()}},d,null,[[5,10],[17,35]])}function X(t,e,r){var n,o,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(Y(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!E(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],o=0;case 17:if(!(o<t.expressions.length)){i.next=25;break}return a=t.expressions[o],i.delegateYield(Y(a,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===a.value?n.push(c):n=s.append(n,c));case 22:o++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}},p)}function V(t,e,r){return s.lookup(e,t.value)}function Z(t){return t.value}function Q(t,e){var r=P();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach(function(t){var n=e[t];Array.isArray(n)?(n=J(n),r=s.append(r,n)):r.push(n)}),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){J(t,e)}):e.push(t),e}function K(t,e){var r,n=P();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===n(t)&&Object.keys(t).forEach(function(r){tt(t[r],e)})}function et(t,e,r){var n;if(void 0!==t&&!E(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!E(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,o=n(t),s=n(e);if("undefined"===o||"undefined"===s)return!1;switch(r){case"=":i=N(t,e);break;case"!=":i=!N(t,e)}return i}function nt(t,e,r){var i,o=n(t),s=n(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(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function ot(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=st(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=o,!i.t1){i.next=10;break}return i.t2=st,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=o,i.t5){i.next=18;break}return i.t6=st,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},g)}function st(t){var e=s.boolean(t);return void 0!==e&&e}function at(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function ct(t,e,r){var n,o,a,c,u,l,h,f,d,p,g,m,b;return i().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:n={},o={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=P(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){y.next=31;break}u=e[c],l=a?U(r,u):r,h=0;case 10:if(!(h<t.lhs.length)){y.next=28;break}return f=t.lhs[h],y.delegateYield(Y(f[0],a?u["@"]:u,l),"t0",13);case 13:if("string"==typeof(d=y.t0)||void 0===d){y.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:d};case 16:if(void 0===d){y.next=25;break}if(p={data:u,exprIndex:h},!o.hasOwnProperty(d)){y.next=24;break}if(o[d].exprIndex===h){y.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:d};case 21:o[d].data=s.append(o[d].data,u),y.next=25;break;case 24:o[d]=p;case 25:h++,y.next=10;break;case 28:c++,y.next=6;break;case 31:y.t1=i().keys(o);case 32:if((y.t2=y.t1()).done){y.next=43;break}return d=y.t2.value,p=o[d],g=p.data,l=r,a&&(m=ut(p.data),g=m["@"],delete m["@"],l=U(r,m)),y.delegateYield(Y(t.lhs[p.exprIndex][1],g,l),"t3",39);case 39:void 0!==(b=y.t3)&&(n[d]=b),y.next=32;break;case 43:return y.abrupt("return",n);case 44:case"end":return y.stop()}},y)}function ut(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=s.append(e[n],t[r][n]);return e}function lt(t,e){var r;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 r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,o=0;i<=e;i++,o++)r[o]=i;return r.sequence=!0,r}function ht(t,e,r){var n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}},m)}function ft(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.condition,e,r),"t0",1);case 1:if(o=i.t0,!s.boolean(o)){i.next=7;break}return i.delegateYield(Y(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(Y(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}},b)}function dt(t,e,r){var n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=It(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(Y(t.expressions[s],e,o),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}},v)}function pt(t){var e=new Dt.RegexEngine(t.value),r=function r(n,i){var o;e.lastIndex=i||0;var s=e.exec(n);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>=n.length)){var i=r(n,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 r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function yt(t,e,r){var o,a,c,u,l;return i().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return a=e,c=!!e.tupleStream,u=i().mark(function e(o,s){var a,u,l,h,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,u=0;case 2:if(!(0===a&&u<t.terms.length)){e.next=35;break}return l=t.terms[u],h=o,f=r,c&&(h=o["@"],f=U(r,o)),e.delegateYield(Y(l.expression,h,f),"t0",8);case 8:return d=e.t0,h=s,f=r,c&&(h=s["@"],f=U(r,s)),e.delegateYield(Y(l.expression,h,f),"t1",13);case 13:if(p=e.t1,g=n(d),y=n(p),"undefined"!==g){e.next=19;break}return a="undefined"===y?0:1,e.abrupt("continue",32);case 19:if("undefined"!==y){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==y&&"number"!==y)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?d:p};case 24:if(g===y){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:d,value2:p};case 26:if(d!==p){e.next=30;break}return e.abrupt("continue",32);case 30:a=d<p?-1:1;case 31:!0===l.descending&&(a=-a);case 32:u++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),l={environment:r,input:e},h.delegateYield(s.sort.apply(l,[a,u]),"t0",5);case 5:return o=h.t0,h.abrupt("return",o);case 7:case"end":return h.stop()}},x)}function mt(t,e,r){return Tt(i().mark(function e(o){var s,a,c,u,l,h,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==o){e.next=2;break}return e.abrupt("return",void 0);case 2:if(s=r.lookup("clone"),I(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(_t(s,[o],null,r),"t0",6);case 6:return a=e.t0,e.delegateYield(Y(t.pattern,a,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),u=0;case 12:if(!(u<c.length)){e.next=35;break}if(!(l=c[u])||!(l.isPrototypeOf(a)||l instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(Y(t.update,l,r),"t2",17);case 17:if(h=e.t2,"undefined"===(f=n(h))){e.next=23;break}if("object"===f&&null!==h&&!Array.isArray(h)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:h};case 22:for(d in h)l[d]=h[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(Y(t.delete,l,r),"t3",25);case 25:if(void 0===(p=e.t3)){e.next=32;break}if(g=p,Array.isArray(p)||(p=[p]),O(p)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(y=0;y<p.length;y++)"object"===n(l)&&null!==l&&delete l[p[y]];case 32:u++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)}),"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function vt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(xt(t.rhs,e,r,{context:o}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(Y(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,I(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!I(o)){i.next=18;break}return i.delegateYield(Y(bt,null,r),"t3",13);case 13:return a=i.t3,i.delegateYield(_t(a,[o,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(_t(s,[o],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},_)}function xt(t,e,r,o){var s,a,c,u,l,h;return i().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.delegateYield(Y(t.procedure,e,r),"t0",1);case 1:if(void 0!==(a=f.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){f.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==o&&c.push(o.context),u=i().mark(function n(){var o,s;return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.arguments[l],e,r),"t0",1);case 1:o=n.t0,I(o)?(s=i().mark(function t(){var e,n,s,a=arguments;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,n=new Array(e),s=0;s<e;s++)n[s]=a[s];return t.delegateYield(_t(o,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),s.arity=D(o),c.push(s)):c.push(o);case 3:case"end":return n.stop()}},n)}),l=0;case 8:if(!(l<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:l++,f.next=8;break;case 13:return h="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(a)&&(a.token=h,a.position=t.position),f.delegateYield(_t(a,c,e,r),"t2",17);case 17:s=f.t2,f.next=25;break;case 20:throw f.prev=20,f.t3=f.catch(14),f.t3.position||(f.t3.position=t.position),f.t3.token||(f.t3.token=h),f.t3;case 25:return f.abrupt("return",s);case 26:case"end":return f.stop()}},w,null,[[14,20]])}function _t(t,e,r,n){var o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(wt(t,e,r,n),"t0",1);case 1:o=i.t0;case 2:if(!F(o)||!0!==o.thunk){i.next=21;break}return i.delegateYield(Y(o.body.procedure,o.input,o.environment),"t1",4);case 4:s=i.t1,"variable"===o.body.procedure.type&&(s.token=o.body.procedure.value),s.position=o.body.procedure.position,a=[],c=0;case 9:if(!(c<o.body.arguments.length)){i.next=17;break}return i.t2=a,i.delegateYield(Y(o.body.arguments[c],o.input,o.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(wt(s,a,r,n),"t5",18);case 18:o=i.t5,i.next=2;break;case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},k)}function wt(t,e,r,n){var o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=Mt(t.signature,e,r)),!F(t)){i.next=8;break}return i.delegateYield(zt(t,s),"t0",5);case 5:o=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(a={environment:n,input:r},o=t.implementation.apply(a,s),!R(o)){i.next=14;break}return i.delegateYield(o,"t1",13);case 13:o=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(o=t.apply(r,s),!R(o)){i.next=21;break}return i.delegateYield(o,"t2",20);case 20:o=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",o);case 31:case"end":return i.stop()}},S,null,[[0,26]])}function kt(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark(function t(r,o){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_t(n,o,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),n}function St(t,e,r){var n,o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(a=t.arguments[s]).type||"?"!==a.value){i.next=8;break}o.push(a),i.next=12;break;case 8:return i.t0=o,i.delegateYield(Y(a,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(Y(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!F(c)){i.next=23;break}n=At(c,o),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=jt(c.implementation,o),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=jt(c,o),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}},M)}function Mt(t,e,r){return void 0===t?e:t.validate(e,r)}function zt(t,e){var r,n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=It(t.environment),t.arguments.forEach(function(t,r){n.bind(t.value,e[r])}),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Et(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(Y(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}},z)}function At(t,e){var r=It(t.environment),n=[];return t.arguments.forEach(function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?n.push(t):r.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function jt(t,e){var r=Ot(t),n="function("+(r=r.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=c(n);return i.body=t,At(i,e)}function Et(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map(function(t){return e.lookup(t.trim())}),o={environment:e},s=t.apply(o,n),!R(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}},A)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Tt(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function Pt(t,e){var r,n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!C(r)&&((r=P(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Rt(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(Y(n,r,this.environment),"t1",14);case 14:o=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Rt(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},j,this,[[4,8],[12,17]])}function Ct(t){if(void 0!==t)return JSON.parse(s.string(t))}function It(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}L.bind("sum",Tt(s.sum,"<a<n>:n>")),L.bind("count",Tt(s.count,"<a:n>")),L.bind("max",Tt(s.max,"<a<n>:n>")),L.bind("min",Tt(s.min,"<a<n>:n>")),L.bind("average",Tt(s.average,"<a<n>:n>")),L.bind("string",Tt(s.string,"<x-b?:s>")),L.bind("substring",Tt(s.substring,"<s-nn?:s>")),L.bind("substringBefore",Tt(s.substringBefore,"<s-s:s>")),L.bind("substringAfter",Tt(s.substringAfter,"<s-s:s>")),L.bind("lowercase",Tt(s.lowercase,"<s-:s>")),L.bind("uppercase",Tt(s.uppercase,"<s-:s>")),L.bind("length",Tt(s.length,"<s-:n>")),L.bind("trim",Tt(s.trim,"<s-:s>")),L.bind("pad",Tt(s.pad,"<s-ns?:s>")),L.bind("match",Tt(s.match,"<s-f<s:o>n?:a<o>>")),L.bind("contains",Tt(s.contains,"<s-(sf):b>")),L.bind("replace",Tt(s.replace,"<s-(sf)(sf)n?:s>")),L.bind("split",Tt(s.split,"<s-(sf)n?:a<s>>")),L.bind("join",Tt(s.join,"<a<s>s?:s>")),L.bind("formatNumber",Tt(s.formatNumber,"<n-so?:s>")),L.bind("formatBase",Tt(s.formatBase,"<n-n?:s>")),L.bind("formatInteger",Tt(o.formatInteger,"<n-s:s>")),L.bind("parseInteger",Tt(o.parseInteger,"<s-s:n>")),L.bind("number",Tt(s.number,"<(nsb)-:n>")),L.bind("floor",Tt(s.floor,"<n-:n>")),L.bind("ceil",Tt(s.ceil,"<n-:n>")),L.bind("round",Tt(s.round,"<n-n?:n>")),L.bind("abs",Tt(s.abs,"<n-:n>")),L.bind("sqrt",Tt(s.sqrt,"<n-:n>")),L.bind("power",Tt(s.power,"<n-n:n>")),L.bind("random",Tt(s.random,"<:n>")),L.bind("boolean",Tt(s.boolean,"<x-:b>")),L.bind("not",Tt(s.not,"<x-:b>")),L.bind("map",Tt(s.map,"<af>")),L.bind("zip",Tt(s.zip,"<a+>")),L.bind("filter",Tt(s.filter,"<af>")),L.bind("single",Tt(s.single,"<af?>")),L.bind("reduce",Tt(s.foldLeft,"<afj?:j>")),L.bind("sift",Tt(s.sift,"<o-f?:o>")),L.bind("keys",Tt(s.keys,"<x-:a<s>>")),L.bind("lookup",Tt(s.lookup,"<x-s:x>")),L.bind("append",Tt(s.append,"<xx:a>")),L.bind("exists",Tt(s.exists,"<x:b>")),L.bind("spread",Tt(s.spread,"<x-:a<o>>")),L.bind("merge",Tt(s.merge,"<a<o>:o>")),L.bind("reverse",Tt(s.reverse,"<a:a>")),L.bind("each",Tt(s.each,"<o-f:a>")),L.bind("error",Tt(s.error,"<s?:x>")),L.bind("assert",Tt(s.assert,"<bs?:x>")),L.bind("type",Tt(s.type,"<x:s>")),L.bind("sort",Tt(s.sort,"<af?:a>")),L.bind("shuffle",Tt(s.shuffle,"<a:a>")),L.bind("distinct",Tt(s.distinct,"<x:x>")),L.bind("base64encode",Tt(s.base64encode,"<s-:s>")),L.bind("base64decode",Tt(s.base64decode,"<s-:s>")),L.bind("encodeUrlComponent",Tt(s.encodeUrlComponent,"<s-:s>")),L.bind("encodeUrl",Tt(s.encodeUrl,"<s-:s>")),L.bind("decodeUrlComponent",Tt(s.decodeUrlComponent,"<s-:s>")),L.bind("decodeUrl",Tt(s.decodeUrl,"<s-:s>")),L.bind("eval",Tt(Pt,"<sx?:x>")),L.bind("toMillis",Tt(o.toMillis,"<s-s?:n>")),L.bind("fromMillis",Tt(o.fromMillis,"<n-s?s?:s>")),L.bind("clone",Tt(Ct,"<(oa)-:o>"));var Ft={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}}",D1010:"Attempted to access the Javascript object prototype",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 Rt(t){var e=Ft[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});r=r.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=r}}function Dt(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Rt(t),t}var i=It(L),s=new Date;return i.bind("now",Tt(function(t,e){return o.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Tt(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?Dt.RegexEngine=e.RegexEngine:Dt.RegexEngine=RegExp,{evaluate:function(t,e,o){if(void 0!==n){var a={code:"S0500",position:0};throw Rt(a),a}var c,u,l;if(void 0!==e)for(var h in c=It(i),e)c.bind(h,e[h]);else c=i;if(c.bind("$",t),s=new Date,c.timestamp=s,Array.isArray(t)&&!C(t)&&((t=P(t)).outerWrapper=!0),"function"==typeof o){c.async=!0;var f=function(t){Rt(t),o(t,null)},d=function t(e){(u=l.next(e)).done?o(null,u.value):u.value.then(t).catch(f)};l=Y(r,t,c),(u=l.next()).value.then(d).catch(f)}else try{for(l=Y(r,t,c),u=l.next();!u.done;)u=l.next(u.value);return u.value}catch(a){throw Rt(a),a}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=Tt(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Dt.parser=c,Dt}();e.exports=l},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=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"},r=function(r){var n=0,i=r.length,o=function(t,e){return{type:t,value:e,position:n}},s=function(){for(var t,e,o=n,s=0;n<i;){var a=r.charAt(n);if("/"===a&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(o,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,a=r.charAt(n),o=n;"i"===a||"m"===a;)n++,a=r.charAt(n);return e=r.substring(o,n)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===r.charAt(n-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}};return function a(c){if(n>=i)return null;for(var u=r.charAt(n);n<i&&" \t\n\r\v".indexOf(u)>-1;)n++,u=r.charAt(n);if("/"===u&&"*"===r.charAt(n+1)){var l=n;for(n+=2,u=r.charAt(n);"*"!==u||"/"!==r.charAt(n+1);)if(u=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:l};return n+=2,u=r.charAt(n),a(c)}if(!0!==c&&"/"===u)return n++,o("regex",s());if("."===u&&"."===r.charAt(n+1))return n+=2,o("operator","..");if(":"===u&&"="===r.charAt(n+1))return n+=2,o("operator",":=");if("!"===u&&"="===r.charAt(n+1))return n+=2,o("operator","!=");if(">"===u&&"="===r.charAt(n+1))return n+=2,o("operator",">=");if("<"===u&&"="===r.charAt(n+1))return n+=2,o("operator","<=");if("*"===u&&"*"===r.charAt(n+1))return n+=2,o("operator","**");if("~"===u&&">"===r.charAt(n+1))return n+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return n++,o("operator",u);if('"'===u||"'"===u){var h=u;n++;for(var f="";n<i;){if("\\"===(u=r.charAt(n)))if(n++,u=r.charAt(n),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:n,token:u};var d=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:n};var p=parseInt(d,16);f+=String.fromCharCode(p),n+=4}else{if(u===h)return n++,o("string",f);f+=u}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,y=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==y){var m=parseFloat(y[0]);if(!isNaN(m)&&isFinite(m))return n+=y[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:y[0]}}if("`"===u){n++;var b=r.indexOf("`",n);if(-1!==b)return g=r.substring(n,b),n=b+1,o("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var v,x=n;;)if(v=r.charAt(x),x===i||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===r.charAt(n))return g=r.substring(n+1,x),n=x,o("variable",g);switch(g=r.substring(n,x),n=x,g){case"or":case"in":case"and":return o("operator",g);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return n===i&&""===g?null:o("name",g)}}else x++}},i=function(e,i){var o,s,a={},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},l={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}},h=function(t,e){var r=a[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(l)).id=r.value=t,r.lbp=e,a[t]=r),r},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,r){if(t&&o.id!==t){var n={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(n)}var i=s(r);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,l=i.type;switch(l){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":l="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=l,o.position=i.position,o},p=function(t){var e,r=o;for(d(null,!0),e=r.nud();t<o.lbp;)r=o,d(),e=r.led(e);return e},g=function(t){h(t,0).nud=function(){return this}},y=function(e,r,n){var i=r||t[e],o=h(e,i);return o.led=n||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,r){var n=h(t,e);return n.led=r,n},b=function(t,e){var r=h(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),h(":"),h(";"),h(","),h(")"),h("]"),h("}"),h(".."),y("."),y("+"),y("-"),y("*"),y("/"),y("%"),y("="),y("<"),y(">"),y("!="),y("<="),y(">="),y("&"),y("and"),y("or"),y("in"),g("and"),g("or"),g("in"),b("-"),y("~>"),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}),y("(",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,r=1,i="<";r>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}d(">");try{this.signature=n(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 r={type:"binary",value:"..",position:o.position,lhs:e};d(".."),r.rhs=p(0),e=r}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),y("[",t["["],function(e){if("]"===o.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),y("^",t["^"],function(t){d("(");for(var e=[];;){var r={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(r.descending=!0,d(">")),r.expression=p(0),e.push(r),","!==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 r=p(0);d(":");var n=p(0);if(e.push([r,n]),","!==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),y("{",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)}),y("@",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)}),y("#",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)}),y("?",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(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},_=0,w=0,k=[],S=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(k[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},M=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},z=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var o=n[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=S(s,o)}}},A=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var o=t(e.rhs);"function"===o.type&&"path"===o.procedure.type&&1===o.procedure.steps.length&&"name"===o.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=o.procedure.steps[0].value),"path"===o.type?Array.prototype.push.apply(r.steps,o.steps):(void 0!==o.predicate&&(o.stages=o.predicate,delete o.predicate),r.steps.push(o)),r.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"}),r.steps.filter(function(t){return!0===t.keepArray}).length>0&&(r.keepSingletonArray=!0);var s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var a=r.steps[r.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),z(r);break;case"[":var u=r=t(e.lhs),l="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],l="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[l]&&(u[l]=[]);var h=t(e.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach(function(t){1===t.level?S(u,t):t.level--}),M(u,h)),u[l].push({type:"filter",expr:h,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var f={type:"sort",position:e.position};f.terms=e.rhs.map(function(e){var r=t(e.expression);return M(f,r),{descending:e.descending,expression:r}}),r.steps.push(f),z(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),M(r,r.rhs);break;case"@":if(r=t(e.lhs),u=r,"path"===r.type&&(u=r.steps[r.steps.length-1]),void 0!==u.stages||void 0!==u.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===u.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(u.keepArray=!0),u.focus=e.rhs.value,u.tuple=!0;break;case"#":r=t(e.lhs),u=r,"path"===r.type?u=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==u.predicate&&(u.stages=u.predicate,delete u.predicate)),void 0===u.stages?u.index=e.rhs.value:u.stages.push({type:"index",value:e.rhs.value,position:e.position}),u.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),M(r,r.lhs),M(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map(function(e){var n=t(e);return M(r,n),n}):"{"===e.value?r.lhs=e.lhs.map(function(e){var n=t(e[0]);M(r,n);var i=t(e[1]);return M(r,i),[n,i]}):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:M(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var n=t(e);return M(r,n),n}),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var d=t(e.body);r.body=x(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),M(r,r.condition),r.then=t(e.then),M(r,r.then),void 0!==e.else&&(r.else=t(e.else),M(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var n=t(e);return M(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n});break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var p="S0206";"(end)"===e.id&&(p="S0207");var g={code:p,position:e.position,token:e.value};if(i)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),d();var j=p(0);if("(end)"!==o.id){var E={code:"S0201",position:o.position,token:o.value};f(E)}if("parent"===(j=A(j)).type||void 0!==j.seekingParent)throw{code:"S0217",token:j.type,position:j.position};return c.length>0&&(j.errors=c),j};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(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 r=1,o=[],s={},a=s;r<e.length;){var c=e.charAt(r);if(":"===c)break;var u=function(){o.push(s),a=s,s={}},l=function(t,e,r,n){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===n){if(0===--i)break}else c===r&&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 h=l(e,r,"(",")"),f=e.substring(r+1,h);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};s.regex="["+f+"m]",s.type="("+f+")",r=h,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:r};var d=l(e,r,"<",">");a.subtype=e.substring(r+1,d),r=d}r++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",g=new RegExp(p),y=function(t){var e;if(i.isFunction(t))e="f";else switch(n(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 r="^",n=0,i=0;i<o.length;i++){r+=o[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(t){n+=y(t)});var i=g.exec(n);if(i){var s=[],a=0;return o.forEach(function(n,o){var c=e[a],u=i[o+1];if(""===u)if(n.context&&n.contextRegex){var l=y(r);if(!n.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:r,index:a+1};s.push(r)}else s.push(c),a++;else u.split("").forEach(function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[a];var i=!0;if(void 0!==n.subtype)if("a"!==r&&u!==n.subtype)i=!1;else if("a"===r&&c.length>0){var o=y(c[0]);i=o===n.subtype.charAt(0)&&0===c.filter(function(t){return y(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[n.subtype]};"a"!==r&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,n)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}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 r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return!t(e)}).length),r}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 l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function h(t){return"object"===s(t)&&null!==t&&l 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 r=0;r<t.length;r++)if(!f(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var o=n[r];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;r.push(o)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:h,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=a},{}]},{},[3])(3)}(Hi)),Hi.exports),Vi=qi(Xi);const Zi=function(t){return t};function Qi(t){if(!t)return Zi;try{const e=Vi(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Ui(t),Zi}}function Ji(t){const e=di(t);return null==e?"":String(e)}function Ki(t){return Number(di(t))}function to(t){return t}function eo(t){return Ji(t)}function ro(t){return Ki(t)}function no(t){if(this.param)return t=Ji(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function io(t){const{param:e}=this;if(e){for(const r in e){let[n,i]=r.split("~");const o=!!n,s=!!i,a=parseFloat(n),c=parseFloat(i);if(t=Ki(t),o&&!s&&t>=a)return e[r];if(!o&&s&&t<a)return e[r];if(t>=a&&t<c)return e[r]}return e.default}}function oo(t){return Ki(t)*Math.PI/180}function so(){}const ao=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const co=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],uo=new Array(co.length).fill(void 0),lo=Object.getPrototypeOf(async function(){}).constructor;function ho(t,e){!function(t){for(const e of ao)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const r=function(t){return/\bawait\b/.test(t)}(t),n=new(r?lo:Function)(...e,...co,t);return function(t,...e){return n.call(t,...e,...uo)}}function fo(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?eo.bind(t):"number"===i?ro.bind(t):to.bind(e);case"map":return no.bind(t);case"range":return io.bind(t);case"radian":return oo.bind(t);case"eval":return function(t){try{const e=ho(t,["value","targets","scene"]);return function(t,r){try{const n=e(this,t,r,globalThis.scene);return n&&"function"==typeof n.then?n.catch(t=>{Ui(t)}):n}catch(t){return void Ui(t)}}}catch(t){return Ui(t),so}}(n).bind(e);default:return to.bind(e)}}class po{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:r,rule:n,param:i,accessor:o}=t;this._model=t,this.evaluator=fo(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=Qi(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=Qi(t),this.partAccessor=Qi(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 go(t,e,r,n){const i=e.split(".");if(1===i.length)return void(t[e]=n?{...t[e],...r}:r);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]=n?{...c[u],...r}:r,t[o]=a}function yo(t,e,r,n){t.forEach(t=>go(t,e,r,n))}function mo(t,e,r,n){t&&"function"==typeof t.then?t.then(t=>{void 0!==r&&void 0!==n&&r._dataGeneration!==n||e(t)}).catch(t=>Ui(t)):e(t)}function bo(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,r=this;this.mappings&&this.mappings.forEach(t=>{try{let n,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:l=!1,partial:h=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),n=this.root.findById(i)?.data||{}):n=this.data;const f=a(n);if("(root)"==o||"(key)"==o){if(null==f)return;const n=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();n.length>0&&n.forEach(n=>{mo(t.evaluator(f[n.get("id")],[n]),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||go(n,s,t,h)},r,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(n=>{const i=c(n);if(i){const o=this.root.findOrCreate(i);o&&mo(t.evaluator(u(n),o),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||yo(o,s,t,h)},r,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const n=c(f);if(n){const i=this.root.findOrCreate(n);i&&mo(t.evaluator(u(f),i),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||yo(i,s,t,h)},r,e)}}}}else{const n=this.root.findAll(o,this);n.length>0&&mo(t.evaluator(f,n),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||yo(n,s,t,h)},r,e)}}catch(e){Ui(e,this,t)}})}function vo(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),bo.call(this,!0)}function xo(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new po({target:"(self)",rule:"value",...t},this))):(Ui("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function _o(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function wo(t,e){this.disposeMappings(),bo.call(this)}function ko(t,e,r,n,i,o){e.complete?t.drawImage(e,r,n,i,o):e.addEventListener("load",()=>{this.invalidate()})}function So(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Mo="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),zo={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Ao=()=>{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(),r=t.fontFamily||"sans-serif";zo.FONT_FAMILY=e||r};let jo;function Eo(t,e,r,n,i){const{alpha:o=1}=n,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(r.x,r.y);let n,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,r="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(o-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(o-4)/2*Math.sin(r))}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:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":n=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{n.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),n.addColorStop(t.position,"#fff")}}),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.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 r=i._pattern_image;if(!r||!r.width||!r.height)return;let n=0,o=0,a=0,c=0,u=e.left,l=e.top;if(!s.fitPattern){n=s.offsetX,o=s.offsetY;const t=s.width?s.width:r.width,i=s.height?s.height:r.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+=n+a,l+=o+c}t.translate(u,l),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((r.width-e.width)*(r.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(r,"no-repeat"):t.fillStyle=t.createPattern(r,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-l)}}function Oo(t,e){const r=this.fillStyle;if(!r||"pattern"!=r.type||!r.image)return void t(this);if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);const o=jo(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.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(r.image)}catch(t){e(t)}}function To(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Ui(t)})}function Po(t,e){const r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)}function Co(t,e,r){let{strokeStyle:n,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(n&&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=n,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function Io(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,r=[];let n;for(;null!==(n=e.exec(t));)n[1]?r.push({text:n[2],bold:!0,italic:!1}):n[3]?r.push({text:n[4],bold:!1,italic:!0}):n[5]&&r.push({text:n[5],bold:!1,italic:!1});return r}function Fo(t,e,r,n=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)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function Ro(t,e,r,n,i,o=0){const s=String(e).split("\n");return n?[].concat(...s.map(e=>function(t,e,r,n=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=r-s,u=t.measureText(a).width+(a.length-1)*n;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const r=Fo(t,{...e,text:a},c,n);o.push(r),i.push(o),o=[],s=0,a=a.substring(r.text.length)}}}),o.length>0&&i.push(o),i}(t,i?Io(e):[{text:e,bold:!1,italic:!1}],r,o))):s.map(t=>i?Io(t):[{text:t,bold:!1,italic:!1}])}function Do(t,e,r,n,i,o,s=0){if(!n)return[];t.save(),t.font=r;const a=Ro(t,n,e,!!i,o,s);return t.restore(),a}function No(t){const{fontFamily:e=zo.FONT_FAMILY,bold:r=zo.BOLD,italic:n=zo.ITALIC,fontSize:i=zo.FONT_SIZE}=t,o=[];return r&&o.push("bold"),n&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Lo(t,e){const r=t.bold||e.bold,n=t.italic||e.italic;return No({...t,bold:r,italic:n})}function Yo(t,e,r,n){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=zo.FONT_COLOR,textAlign:c=zo.TEXT_ALIGN,textBaseline:u=zo.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:g=0}=n;i=void 0!==i?i:1,h||=zo.FONT_SIZE,f||=1.2*h,t.save();const{left:y,top:m,width:b,height:v}=e;if(o&&s&&(t.translate(y+b/2,m+v/2),t.rotate(-o),t.translate(-(y+b/2),-(m+v/2))),t.beginPath(),t.font=No(n),!d&&p){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of r){const r=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=n-("ellipsis"===t?o:0))){const i=$o(e,c,n-a-("ellipsis"===t?o:0),t);return r.push(i),s.push(r),s}r.push(c),a+=i}s.push(r),a=0}return s}(p,t,r,b);r=e}const x=r.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,r.forEach((e,i)=>{const o=_+i*f,s=function(t,e,r,n=0){return e.reduce((e,i)=>(t.font=Lo(r,i),e+t.measureText(i.text).width+n*(i.text.length-1)),0)}(t,e,n,g);let u=y;switch(c){case"left":case"justify":u=y;break;case"right":u=y+b-s;break;case"center":u=y+(b-s)/2}if(l&&(t.fillStyle=l,function(t,e,r,n,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,r),t.lineTo(e+n-o.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+o.tr),t.lineTo(e+n,r+i-o.br),t.quadraticCurveTo(e+n,r+i,e+n-o.br,r+i),t.lineTo(e+o.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-o.bl),t.lineTo(e,r+o.tl),t.quadraticCurveTo(e,r,e+o.tl,r),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-h/2-4,s+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<r.length-1&&e.length>1){const r=b-s,i=e.length-1,a=r/i;e.forEach((e,r)=>{t.font=Lo(n,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(r<i?a:0)})}else e.forEach(e=>{t.font=Lo(n,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+g})})}),t.restore()}function $o(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){const o=i+e.text[n];if(t.measureText(o).width>r)break;i=o}return{...e,text:i+("ellipsis"===n?"…":"")}}function Uo(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Ao()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Ao),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Ao()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Ao(),jo="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const r=document.createElement("canvas");return r.width=t,r.height=e,r};const Wo=[];function qo(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-r.x)/i.x,e=(e-r.y)/i.y):(t-=r.x,e-=r.y),0!==n){const r=Math.cos(-n),i=Math.sin(-n),o=t*i+e*r;t=t*r-e*i,e=o}return{x:t+r.x,y:e+r.y}}function Go(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(t-=r.x,e-=r.y,0!==n){const r=Math.cos(n),i=Math.sin(n),o=t*i+e*r;t=t*r-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+r.x,y:e*i.y+r.y}:{x:t+r.x,y:e+r.y}}function Bo(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=qo(t,e,r,n,i);return r&&(o.x-=r.x,o.y-=r.y),o}return qo(t,e,r=r||this.rotatePoint,n,i)}function Ho(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=Go(t,e,void 0,n+(this._delta?.theta??0),i);return r&&(o.x+=r.x,o.y+=r.y),o}r=r||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 Go(t,e,r,n,i);return Go(t+s,e+a,{x:r.x+s,y:r.y+a},n+o,{x:i.x*c,y:i.y*u})}function Xo(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Go(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)}function Vo(t,e,r){r=r||this.rootModel,Wo.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Wo.push(t);let n=this.transcoordS2P(t,e);for(let t=0;t<Wo.length;t++){const e=Wo[t],r=e.bounds;n.x+=r.left,n.y+=r.top,n=e.transcoordS2P(n.x,n.y)}return n}function Zo(t,e,r){r=r||this.rootModel,Wo.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Wo.push(t);let n={x:t,y:e};for(let t=Wo.length-1;t>=0;t--){const e=Wo[t];n=e.transcoordP2S(n.x,n.y);const r=e.bounds;n.x-=r.left,n.y-=r.top}return n}function Qo(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)}function Jo(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)}function Ko(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=r.model,s=qo(t,e,n,o,i);return n&&(s.x-=n.x,s.y-=n.y),r===this?s:this.transcoordT2S(s.x,s.y,r)}function ts(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;if(n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e},!this.scalable)return n;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=r.model;return n=Go(n.x,n.y,void 0,o+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}function es(t){const e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),o)switch(o){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){const r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,r)}else n.background="transparent"}const rs={x:1,y:1},ns={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function is(t,e){let r=this.bounds,n=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const n=t.call(e,r);n&&(r=n)}const{left:s,top:a,width:c,height:u}=r;let l=[{x:s,y:a},{x:s+c,y:a+u}];l=l.map(t=>Go(t.x,t.y,n,i,o));let h=l[0],f=l[1];n={x:(h.x+f.x)/2,y:(h.y+f.y)/2},l=l.map(t=>qo(t.x,t.y,n,i,o)),h=l[0],f=l[1],this.bounds={left:h.x,top:h.y,width:f.x-h.x,height:f.y-h.y}}function os(t,e,r){let n=this.path,i=this.rotatePoint;t&&(n=t.call(r,n));let o=n.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(r,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,l;n=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=n[0].x,u=l=n[0].y;for(let t=1;t<n.length;t++){const e=n[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>l&&(l=e.y)}i={x:(a+c)/2,y:(u+l)/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}})}function ss(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const as=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 I.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const r=e?.component,n=r?.root?.app;if(n&&"boolean"==typeof n.isViewMode&&!n.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,ji.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const r=I.tick(e),n=I.now;if(this._ticking=!0,ji.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(r,n)}finally{const n=performance.now()-e;t.tickCount++,t.totalDurationMs+=n,t.lastDt=r,t.lastDurationMs=n}}else for(const t of this._subs)t._removed||t.handler(r,n);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;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),r=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(r),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,r){const n={id:this._externalNextId++,description:t,source:e,metadata:r,registeredAt:this._realTime};return this._externals.add(n),{update:t=>{n.metadata={...n.metadata??{},...t}},unregister:()=>{this._externals.delete(n)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let r;const n=e.componentRef?.deref();let i;if(n&&(r=ss(n)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],r=[];for(const t of e)null!=t&&r.push(ss(t));r.length>0&&(i=r)}}catch{}t.push({id:e.id,description:e.description,componentInfo:r,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(I.now),isRunning:this.isRunning,speed:I.speed,paused:I.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}},cs=new Map;let us=null;function ls(){us&&(us(),us=null)}function hs(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var fs=new class{add(t){var e;hs(t)&&!cs.has(t)&&(cs.set(t,0),e=t?.root,us||(us=as.subscribe(t=>{if(0===t)return;const e=[];for(const[r,n]of cs){if(!hs(r)){e.push(r);continue}const i=n+t;i>=r.retention?e.push(r):cs.set(r,i)}for(const t of e){cs.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Ui("RetentionManager removeSelf failed:",t)}}0===cs.size&&ls()},{description:"retention timer",component:e,getTargets:()=>Array.from(cs.keys()),metadata:{get count(){return cs.size},get preview(){return Array.from(cs.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){cs.delete(t)&&0===cs.size&&ls()}touch(t){t&&cs.has(t)&&cs.set(t,0)}dispose(){ls(),cs.clear()}get length(){return cs.size}};const ds=function(t){return t};function ps(t){const e=t.indexOf("||");let r="",n="";-1!=e&&(r=t,n=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:n,match:t,originText:r||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:ds}}function gs(t){if(!t)return;const e=String(t),r=(e.match(/#{(\S*)}/)||[]).map(t=>ps(t))[0];if(r)return r.accessor(this.getState(r.target));const n=(e.match(/\${[^}]*}/)||[]).map(t=>ps(t))[0];if(n){const t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}function ys(t,e){if(!t)return;const r=String(t),n=e||di,i=(r.match(/#{(\S*)}/gi)||[]).map(t=>ps(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>ps(t));if(0==i.length&&0==o.length)return r;let s=r;return i.forEach(t=>{const e=n(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),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)}),s}function ms(t,e,r){if(!t)return;const n=r||di,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>ps(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>ps(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(r=>{const i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)}),s.forEach(r=>{const i=e.root.findById(r.target),o=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===o?r.defaultValue||"":o)}),t}:void 0}class bs{constructor(){}static registerDecorator(t,e){bs.constructors.set(t,e)}static create(t,e,r={},n){const i=bs.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(n,e,r)}}function vs(t,e){const r=e.x-t.x,n=e.y-t.y,i=Math.sqrt(r*r+n*n);if(!ut(t))return i;const o=lt(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 xs(t,e){const r=t.path.slice();if(!r||!r.length)return void Ui("path should not be empty");let n=1;const i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.toScene(r[0].x,r[0].y);if(e>=1)return t.toScene(r[r.length-1].x,r[r.length-1].y);for(;r[n];)i.push(vs(r[n-1],r[n])),n++;const o=i.reduce(function(t,e){return t+e},0);n=0;let s=0;do{s+=i[n++]}while(s/o<e);s-=i[--n];e=(e-s/o)*(o/i[n]);const a=r[n%r.length],c=r[(n+1)%r.length],{x:u,y:l}=function(t,e,r){if(ut(t)){const n=lt(t,e,t.bulge);if(n){let t=n.endAngle-n.startAngle;n.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=n.startAngle+r*t;return{x:n.cx+n.radius*Math.cos(e),y:n.cy+n.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*r),y:t.y+Math.round((e.y-t.y)*r)}}(a,c,e);return t.toScene(u,l)}function _s(t,e){return!1}function ws({x:t,y:e},...r){const n=this.path,i=t,o=e;this.path=n.map(t=>({...t,x:t.x+i,y:t.y+o}))}function ks(t){const e=t??this.center.x,{rotation:r}=this.state,n=this.fillStyle;if(this.set("rotation",2*Math.PI-r),n&&"gradient"===n.type&&"linear"===n.gradientType){const t=Kn(n);t.rotation=(Math.PI-parseFloat(n.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 Ss(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 Ms(t,e,r){if(r){const e=this.bounds,r=e.height/e.width;let n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-n):0!=o?o=-n:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+n,height:e.height+i}}return t}function zs(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function As(t){return xs(this,t||0)}function js(){const t=this.path;let e,r,n,i;e=r=t[0].x,n=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>r&&(r=s.x),s.y<n?n=s.y:s.y>i&&(i=s.y)}return{left:e,top:n,width:r-e,height:i-n}}function Es(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 r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))}function Os(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ts(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 r=t.x-e.x,n=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+r,y:t.y+n}))}function Ps(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Cs(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}function Is(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}function Fs(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}function Rs(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}function Ds(t){const{width:e,height:r,depth:n}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:r},this.setState("depth",n)}function Ns(){return Ui("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Ls(t){Ui("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Ys(){return this.path}function $s(){return this.center}function Us(){return this.nature.mutable}function Ws(){return this.nature.resizable&&!this.stuck}function qs(){return this.nature.rotatable&&!this.stuck}bs.constructors=new Map;const Gs={x:1,y:1};function Bs(t,e,r){const{offsetX:n,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=r.rootModel.get("scale")??Gs;t.shadowOffsetX=n*a.x*Mo,t.shadowOffsetY=i*a.y*Mo,t.shadowBlur=o*a.x*Mo,t.shadowColor=s}function Hs(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}function Xs(t){const e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:o}=this.state,s=(r&&r.x||1)*this._delta.sx,a=(r&&r.y||1)*this._delta.sy,c=(n||0)+this._delta.theta,{tx:u=0,ty:l=0}=this._delta,h=(o||1)-this._delta.fade;(u||l)&&t.translate(u,l),(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)),h&&(t.globalAlpha=h),i&&Bs(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}function Vs(t){}function Zs(t){this.drawText(t)}function Qs(t,e){t(this)}function Js(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Ui(t)})}function Ks(t){!this.textHidden&&this.text&&this.hasTextProperty&&Yo(t,this.textBounds,this.textLines(t),this.state)}function ta(t,e){Co(t,e?{...this.state,...e}:this.state)}function ea(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(Eo(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function ra(){return this.get("strokeStyle")}function na(t){this.set("strokeStyle",t)}function ia(){return this.getState("fillStyle")}function oa(t){this.setState("fillStyle",t)}function sa(){return this.get("fontColor")}function aa(t){this.set("fontColor",String(di(t)))}function ca(){return this.getState("rotation")}function ua(t){this.setState("rotation",Number(di(t)))}function la(){return this.app.isEditMode?["decotag","data-spread"]:[]}function ha(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function fa(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function da(t){this.setState("hidden",t)}function pa(){return this.state.tag}function ga(t){this.setState("tag",t)}function ya(){}function ma(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function ba(){const t=this.getState("text");return null==t?"":String(t)}function va(t){const{textWrap:e,supportMarkdown:r}=this.state;return Do(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}function xa(){return No(this.model)}function _a(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function wa(){return this._text_substitutor||(this._text_substitutor=ms(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function ka(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let r,n,i,o,s,a,c,u,l,h,f,d=t.length,p=t.search(/[0-9\-\+#]/),g=p>0?t.substring(0,p):"",y=t.split("").reverse().join(""),m=y.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(r=(e="-"===(t=t.substring(p,x)).charAt(0)?-e:+e)<0?e=-e:0,n=t.match(/[^\d\-\+#]/g),i=".",o=n&&n[1]&&n[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)),l=t[0].split(o),t[0]=l.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=l[1]&&l[l.length-1].length,c){for(h=e[0],y="",b=h.length%c,d=h.length,x=0;x<d;x++)y+=h.charAt(x),!((x-b+1)%c)&&x<d-c&&(y+=o);e[0]=y}return e[1]=t[1]&&e[1]?"."+e[1]:"",n=e.join(""),"0"!==n&&""!==n||(r=!1),f="+"==t[0].substring(0,1)?r?"-":"+":r?"-":"",g+(f+n)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function Sa(t){delete this._text_substitutor;const e=di(t);this.setState("text",null==e?"":String(e))}function Ma(){let{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-r,0),height:Math.max(a-t-n,0)}}function za(){return 0}function Aa(){return!!this._textHidden}function ja(t){this._textHidden=!!t,this.invalidate()}function Ea(){return!0}function Oa(t){return t}function Ta(t){return Math.pow(t,2)}function Pa(t){return 1-Math.sin(Math.acos(t))}function Ca(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function Ia(t){for(let e=0,r=1;;e+=r,r/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(r,2)}function Fa(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var Ra={linear:Oa,quad:Ta,circ:Pa,back:Ca,bounce:Ia,elastic:Fa},Da=Object.freeze({__proto__:null,back:Ca,bounce:Ia,circ:Pa,default:Ra,elastic:Fa,linear:Oa,quad:Ta});class Na{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:r="linear",options:n,ease:i}=this.config;let o;o="string"==typeof r?Ra[r]:r,this.delta="out"===i?function(t,e){return function(r){return 1-t(1-r,e)}}(o,n):"inout"===i?function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(o,n):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:r=!1,interval:n=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>as.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 l=c()-s,h=Math.max((l-e)%(t+n),0)/t,f=n<=0&&a>h;if(a=h,h>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!r||!this._started)return this.stop(i),void(s=0);if(n>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=as.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}}))},n/2)},n/2))}else this.step(this.delta(h)),this.client&&this.client.invalidate?.()};this._unsub=as.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}})}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 La={rotation:class extends Na{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Na{step(t){const{theta:e=.2617993877991494}=this.config,r=4*e;let n=t*r;t<1/4?n*=-1:t<3/4?n-=2*e:n=r-n,this.client.delta?.("theta",n)}},heartbeat:class extends Na{step(t){const{scale:e=1.3}=this.config,r=2*(e-1);let n;n=t<.5?1+r*t:1+(1-t)*r,this.client.delta?.({sx:n,sy:n,sz:n})}},moving:class extends Na{step(t){const{x:e=0,y:r=0}=this.config;this.client.delta?.({tx:t*e,ty:t*r})}},outline:class extends Na{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const r=this.client.root.findById(e);if(!r)return;let n={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(n=i);const{tx:o,ty:s}=n,a=r.outline(t),{x:c,y:u}=this.client.center,l=this.client.toScene(c,u);this.client.delta({tx:a.x-l.x+o,ty:a.y-l.y+s})}},fade:class extends Na{step(t){const{startAlpha:e=1,endAlpha:r=0}=this.config,n=Math.max(Math.min(e,r,1),0),i=2*(Math.min(Math.max(e,r,1),1)-n);let o;o=t<.5?i*t:(1-t)*i,this.client.delta?.("fade",o)}},waypoint:class extends Na{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 r=e.center,n=t.center,{x:i,y:o}=e.toScene(r.x,r.y),{x:s,y:a}=t.toScene(n.x,n.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:r="snap"}=this.config;if(super.stop(t),"snap"===r&&e){const t=e.center,r=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=r}}step(t){const e=(this._endX-this._startX)*t,r=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+r}}}};const Ya={gradation:function(t,e,r){const{subType:n,from:i,to:o,colors:s}=r;let a;switch(n){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:Bs};function $a(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:r,component:n,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:l}=t;let h;h="string"==typeof l?Da[l]:l||Oa,"out"===r?h=function(t,e){return function(r){return 1-t(1-r,e)}}(h,c):"inout"===r&&(h=function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(h,c));let f=!1,d=null;return{start:function(){if(f)return this;if(n?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const r=()=>as.simTime;return d=as.subscribe(()=>{if(!f)return;if(n?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=r());const o=(r()-t)/e,a=u?o%1:Math.min(o,1);i(h(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:n,metadata:{duration:e,repeat:u}}),this},stop:function(){return f=!1,d&&(d(),d=null),a&&a(),this}}}({component:this,...t}),this._animate}function Ua(t,e){return function(t,e,r){const n=Ya[r.type];n&&n(t,e,r)}(this,t,e)}const Wa=100;function qa(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Wa)/Wa}return e}}function Ga(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const r=t[e];null===r?delete t[e]:"number"==typeof r?Number.isFinite(r)?Number.isInteger(r)||(t[e]=Math.round(r*Wa)/Wa):delete t[e]:"object"==typeof r&&Ga(r)}return t}function Ba(...t){return JSON.stringify(this.hierarchy,qa,...t)}function Ha(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Xa(t){this.rootModel.closeScene(t)}function Va(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 Za(){this.parent&&this.parent.invalidate()}function Qa(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function Ja(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function Ka(){return this.getState("data")}function tc(t){this.setState("data",t),this.touch()}function ec(t){const e=this.model.event?.tap;if(e){const{x:t,y:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:r}))}}function rc(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function nc(){return Number(this.get("retention"))||0}function ic(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const r=e.type?La[e.type]:void 0;return r?new r(t,e):null}(this,t.oncreate))}return this._animation}}function oc(){return!!this.animation?.started}function sc(t){this.animation&&(this.animation.started=t)}function ac(){}function cc(t,e,r,n){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function uc(t,e,r,n){return t==e.get("type")}function lc(t,e,r,n,i,o){return t(e,r,n,i)&&o.push(r),r.components&&r.components.forEach(r=>{lc(t,e,r,n,i,o)}),o}function hc(t,e,r,n){switch(t){case"(all)":return!0;case"(parent)":return r&&r.parent===e;case"(child)":case"(children)":return r&&r===e.parent;case"(sibling)":case"(siblings)":return r&&r.parent===e.parent&&r!==e;default:return!1}}function fc(t,e,r){if("(root)"==t)return[e];if("(self)"==t)return r?[r]:[];let n;switch(t.charAt(0)){case"#":const r=e.root.findAllById?.(t.substring(1));return r||[];case".":n=cc;break;case"(":n=hc;break;default:n=uc}return lc(n,t,e,r,e,[])}function dc(t,...e){if(t(this,...e))return this}function pc(t,...e){return"string"==typeof t?fc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function gc(t,e,r){if(!this.capturable||r?.(this))return!1;const n=this.fromParent(t,e);return this.contains(n.x,n.y)?this:void 0}function yc(t){return this.anchors.find(e=>e.name===t)}function mc(t){return!0}function bc(t){return this._parent.getContext(t??this)}function vc(){return this.isRoot()?this:this.parent&&this.parent.root}function xc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function _c(){return this._parent}function wc(t){this._parent=t}function kc(){return this.nature.anchors||[]}function Sc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Mc(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}function zc(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}function Ac(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function jc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Ec(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Oc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Tc={},Pc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Cc=[],Ic=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"]),Fc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let Rc=0;const Dc={};const Nc=new FinalizationRegistry(t=>{!function(t){Rc--;let e=Dc[t];e||(e=Dc[t]={up:0,down:0}),e.down++}(t)});class Lc{static get nature(){return Pc}static register(t,e){if(!e)return Tc[t];Tc[t]=e}static types(){return Object.keys(Tc)}static get residents(){return Dc}static get residentsCount(){return Rc}static registerDecorator(t,e){bs.registerDecorator(t,e)}constructor(t,e){if(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"},r=[];for(const n of Object.keys(t)){const i=e[n];if(!i)continue;const o=t[n];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&&r.push({trigger:i,action:"script",code:t,target:o.target});continue}r.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 r}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=Kn(Fc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),fs.add(this),function(t){Rc++;let e=Dc[t];e||(e=Dc[t]={up:0,down:0}),e.up++}(this._model.type),Nc.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))}}touch(){this.updatedAt=performance.now(),fs.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=Kn(Fc))}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&&fs.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 r=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return r._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&fs.add(r)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&r.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 r=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return r.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=Kn(this._model);return this.volatile.forEach(e=>{delete t[e]}),Ga(t)}get volatile(){return Cc}_applyProps(t,e,r){const n={},i={};let o=!1;const s=Kn(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=r.getBeforeVal(e),u=s[e];!r.sensitive&&function(t,e){return jr(t,e)}(c,u)||(i[e]=c,n[e]=u,t[e]=u,r.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(n).some(t=>!Ic.has(t))&&this.clearCache(),n.hasOwnProperty("text")&&delete this._text_substitutor,r.beforeFillStyle&&r.beforeFillStyle(n,i),n.hasOwnProperty("fillStyle")&&this.onchangeFill(n,i),r.afterFillStyle&&r.afterFillStyle(n,i),n.hasOwnProperty("data")&&this.onchangeData(n,i),this.onchange&&this.onchange(n,i),this.trigger("change",n,i)}return this}contains(t,e){return _s.call(this,t,e)}move(t,...e){ws.call(this,t,...e)}symmetryX(t){ks.call(this,t)}symmetryY(t){Ss.call(this,t)}adjustResize(t,e,r){return Ms.call(this,t,e,r)}adjustRotation(t,e){return zs.call(this,t,e)}outline(t){return As.call(this,t)}get bounds(){return js.call(this)}set bounds(t){Es.call(this,t)}get center(){return Os.call(this)}set center(t){Ts.call(this,t)}get location(){return Ps.call(this)}set location(t){Cs.call(this,t)}get rotate(){return Is.call(this)}set rotate(t){Fs.call(this,t)}get dimension(){return Rs.call(this)}set dimension(t){Ds.call(this,t)}get path(){return Ns.call(this)}set path(t){Ls.call(this,t)}get drawPath(){return Ys.call(this)}get rotatePoint(){return $s.call(this)}get mutable(){return Us.call(this)}get resizable(){return Ws.call(this)}get rotatable(){return qs.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&&Hs.call(this,t)}prerender(t){Xs.call(this,t)}render(t){Vs.call(this,t)}postrender(t){Zs.call(this,t)}prepare(t,e){Qs.call(this,t,e)}prepareIf(t){Js.call(this,t)}drawText(t){Ks.call(this,t)}drawStroke(t,e){ta.call(this,t,e)}drawFill(t,e){ea.call(this,t,e)}get strokeStyle(){return ra.call(this)}set strokeStyle(t){na.call(this,t)}get fillStyle(){return ia.call(this)}set fillStyle(t){oa.call(this,t)}get fontColor(){return sa.call(this)}set fontColor(t){aa.call(this,t)}get rotation(){return ca.call(this)}set rotation(t){ua.call(this,t)}get decorators(){return la.call(this)}get decotag(){return ha.call(this)}get hidden(){return fa.call(this)}set hidden(t){da.call(this,t)}get tag(){return pa.call(this)}set tag(t){ga.call(this,t)}get appendum(){return ya.call(this)}set appendum(t){ma.call(this,t)}defaultTextSubstitutor(){return ba.call(this)}textLines(t){return va.call(this,t)}get font(){return xa.call(this)}get lineHeight(){return _a.call(this)}get textSubstitutor(){return wa.call(this)}get text(){return ka.call(this)}set text(t){Sa.call(this,t)}get textBounds(){return Ma.call(this)}get textRotation(){return za.call(this)}get textHidden(){return Aa.call(this)}set textHidden(t){ja.call(this,t)}get hasTextProperty(){return Ea.call(this)}animate(t){return $a.call(this,t)}effect(t,e){return Ua.call(this,t,e)}serialize(...t){return Ba.call(this,...t)}trim(){Ha.call(this)}closeScene(t){Xa.call(this,t)}delta(t,e){return Va.call(this,t,e)}invalidate(){Za.call(this)}get value(){return Qa.call(this)}set value(t){Ja.call(this,t)}get data(){return Ka.call(this)}set data(t){tc.call(this,t)}set tap(t){ec.call(this,t)}get mappings(){return rc.call(this)}get retention(){return nc.call(this)}get animation(){return ic.call(this)}get started(){return oc.call(this)}set started(t){sc.call(this,t)}get controls(){return ac.call(this)}findFirst(t,...e){return dc.call(this,t,...e)}findAll(t,...e){return pc.call(this,t,...e)}capture(t,e,r){return gc.call(this,t,e,r)}findAnchor(t){return yc.call(this,t)}isDescendible(t){return mc.call(this,t)}getContext(t){return bc.call(this,t)}get root(){return vc.call(this)}get rootModel(){return xc.call(this)}get parent(){return _c.call(this)}set parent(t){wc.call(this,t)}get anchors(){return kc.call(this)}get scalable(){return Sc.call(this)}get stuck(){return Mc.call(this)}get capturable(){return zc.call(this)}get position(){return Ac.call(this)}get origin(){return jc.call(this)}get offset(){return Ec.call(this)}get app(){return Oc.call(this)}drawEffect(t){So.call(this,t)}prepareFill(t,e){Oo.call(this,t,e)}prepareFillIf(t){To.call(this,t)}onchangeFill(t,e){Po.call(this,t,e)}drawImage(t,e,r,n,i,o){ko.call(this,t,e,r,n,i,o)}mutateBounds(t,e){is.call(this,t,e)}mutatePath(t,e,r){os.call(this,t,e,r)}access(t){return gs.call(this,t)}substitute(t,e){return ys.call(this,t,e)}onchangeMappings(t,e){wo.call(this,t,e)}onchangeData(t,e){vo.call(this,t,e)}buildMappings(){xo.call(this)}executeMappings(t){bo.call(this,t)}disposeMappings(){_o.call(this)}ondropfile(t,e){Uo.call(this,t,e)}transcoordS2P(t,e,r){return Ho.call(this,t,e,r)}transcoordP2S(t,e,r){return Bo.call(this,t,e,r)}transcoordS2T(t,e,r){return Vo.call(this,t,e,r)}transcoordT2P(t,e,r){return Zo.call(this,t,e,r)}transcoordT2S(t,e,r){return Qo.call(this,t,e,r)}transcoordS2TR(t,e,r){return Xo.call(this,t,e,r)}transcoordS2O(t,e,r){return Jo.call(this,t,e,r)}transcoordC2S(t,e,r){return Ko.call(this,t,e,r)}transcoordS2C(t,e,r){return ts.call(this,t,e,r)}toParent(t,e,r){return Ho.call(this,t,e,r)}fromParent(t,e,r){return Bo.call(this,t,e,r)}toScene(t,e,r){return Vo.call(this,t,e,r)}fromScene(t,e,r){return Qo.call(this,t,e,r)}toLocal(t,e,r){return Ko.call(this,t,e,r)}toGlobal(t,e,r){return ts.call(this,t,e,r)}toOther(t,e,r){return Jo.call(this,t,e,r)}on(t,e,r){return Ri.call(this,t,e,r)}off(t,e,r){return Di.call(this,t,e,r)}once(t,e,r){return Ni.call(this,t,e,r)}trigger(t,...e){return Li.call(this,t,...e)}delegate_on(t){return Yi.call(this,t)}delegate_off(t){return $i.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,r){}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){}}Lc.capabilities=[],Lc.union=function(t){let e=0,r=0,n=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i)):(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:r,width:n-e,height:i-r}},Lc.transcoordR=qo,Lc.transcoordRR=Go,Lc.createCanvas=jo,Lc.memoize=function(t,e,r){const n=function(t,e){let r=t;for(;r;){const t=Object.getOwnPropertyDescriptor(r,e);if(t?.get)return t;r=Object.getPrototypeOf(r)}}(t,e);if(!n?.get)return void Ui(`${String(e)} is not defined in ${t.constructor.name}`);const i=n.get,o={get:r?function(){return e in this.__cache__?ji.enabled&&ji.cacheHit++:(ji.enabled&&ji.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?ji.enabled&&ji.cacheHit++:(ji.enabled&&ji.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};n.set&&(o.set=n.set),Object.defineProperty(t,e,o)},Lc.mixin=function t(e,r){if(r instanceof Array)r.forEach(r=>t(e,r));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(r)>=0)return e;if(e.mixingIn.indexOf(r)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(r),r.call(e),e.mixingIn.pop(),e.mixedIn.push(r)}return e},Lc.drawText=Yo,Lc.font=No,Lc.textLines=Do,Lc.drawStroke=Co,Lc.drawFill=Eo,Lc.reposition=function(t){let{id:e,scale:r=rs,bold:n,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:l,paddingLeft:h,paddingRight:f,fontSize:d=zo.FONT_SIZE,lineWidth:p=0,lineHeight:g,lineDash:y}=t.state;l||=0,u||=0,h||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:_}=t,{left:w,top:k,width:S,height:M}=t.bounds,z=t.element;if(z.hidden=_,e&&(z.id=e),m&&(z.className=m),Object.assign(z.style,ns,{fontFamily:o,fontSize:d+"px",width:S+"px",height:M+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:l+"px",paddingLeft:h+"px",border:p+"px",borderColor:b,borderStyle:p>0?y||zo.LINE_DASH:"",color:x,fontWeight:n?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===g?"":g+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),es(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,r=e.offsetX??e.left??0,n=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${r}px ${n}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const A=t.delta(),j=(r&&r.x||1)*A.sx,E=(r&&r.y||1)*A.sy,O=(v||0)+A.theta,T=A.tx||0,P=A.ty||0;z.style.transform=`rotate(${O}rad) translate(${T}px, ${P}px) scale(${j}, ${E}) perspective(1px)`},Lc.RetentionManager=fs,Lc.template=function(t,e,r){var n=xn.imports._.templateSettings||xn;r&&Br(t,e,r)&&(e=void 0),t=mn(t),e=Xr({},e,n,an);var i=Xr({},e.imports,n.imports,an),o=or(i),s=function(t,e){return nn(e,function(e){return t[e]})}(i,o);Er(o,function(t){if(Sn.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,u=0,l=e.interpolate||zn,h="__p += '",f=RegExp((e.escape||zn).source+"|"+l.source+"|"+(l===ln?Mn:zn).source+"|"+(e.evaluate||zn).source+"|$","g"),d=jn.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,r,n,i,o,s){return n||(n=i),h+=t.slice(u,s).replace(An,un),r&&(a=!0,h+="' +\n__e("+r+") +\n'"),o&&(c=!0,h+="';\n"+o+";\n__p += '"),n&&(h+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=s+e.length,e}),h+="';\n";var p=jn.call(e,"variable")&&e.variable;if(p){if(Sn.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(c?h.replace(_n,""):h).replace(wn,"$1").replace(kn,"$1;"),h="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")+h+"return __p\n}";var g=rn(function(){return Function(o,d+"return "+h).apply(void 0,s)});if(g.source=h,en(g))throw g;return g},Lc.buildSubstitutor=ms,["rotatePoint","font","lineHeight","retention"].forEach(t=>Lc.memoize(Lc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Lc.memoize(Lc.prototype,t,!0));const Yc=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 $c(t){return class extends 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)}}get data(){return this.isRecordStorage?this.state?.data??[]:this._exportSlotRecords()}_reconcileItems(t){const e=new Map;for(const r of t){const t=this._recordKey(r);t&&e.set(t,r)}const r=new Map;for(const t of this._items){const e=t[W];null!=e&&r.set(String(e),t)}for(const[t,n]of r)if(!e.has(t)){try{this.removeItem(n,!0)}catch{}try{n?.dispose?.()}catch{}}for(const[t,n]of e){if(r.has(t))continue;if(null==n.itemId)continue;const e=this._createItemFromRecord(n);if(e){e[W]=t;try{this.handoverIn(e)}catch{}}}for(const[t,n]of e){const e=r.get(t);if(e&&(n.itemState&&"function"==typeof e.setState))try{e.setState(n.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],r=new Map,n=[];for(const t of this._items){const e=t[W];null!=e?r.set(String(e),t):n.push(t)}for(const n of t){const t=r.get(n)??null;e.push(this._slotRecordOf(n,t))}for(const t of n)e.push(this._slotRecordOf("",t));for(const[n,i]of r)t.includes(n)||e.push(this._slotRecordOf(n,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const r=e?.state?.id;return{slotId:t,itemId:null!=r?String(r):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const r=this._businessFields?.();if(Array.isArray(r)){if(0===r.length)return;const t={};for(const n of r)n in e&&void 0!==e[n]&&(t[n]=e[n]);return Object.keys(t).length>0?t:void 0}const n={};for(const t of Object.keys(e))Yc.has(t)||t.startsWith("_")||(n[t]=e[t]);return Object.keys(n).length>0?n:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const r=Lc.register?.(e);if(r&&"function"==typeof r){return new r({type:e,...t.itemState??{}})}}catch{}return null}}}function Uc(t,e){const r=t.left??0,n=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=r+i/2,l=n+o/2,h="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,r;return{worldPos:(e=t.lx,r=t.lz,{x:u+e*a-r*c,z:l+e*c+r*a}),direction:{x:h*(t.odx*a-t.odz*c),z:h*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Wc(t,e){const r=t.left??0,n=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=r+i/2,l=n+o/2,h=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),g=Math.sin(s),y=(t,e)=>({x:u+t*p-e*g,z:l+t*g+e*p}),m=c?{lx:0,lz:-h}:{lx:-h,lz:0},b=c?{lx:0,lz:h}:{lx:h,lz:0},v=y(m.lx,m.lz),x=y(b.lx,b.lz),_={x:f*p-d*g,z:f*g+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},S={x:-k.x,z:-k.z},M=(c?i:o)/2;return a?{inbounds:[{worldPos:x,direction:S,halfSpan:M}],outbounds:[{worldPos:v,direction:S,halfSpan:M}]}:{inbounds:[{worldPos:v,direction:k,halfSpan:M}],outbounds:[{worldPos:x,direction:k,halfSpan:M}]}}function qc(t){const e=t.left??0,r=t.top??0,n=t.width??0,i=t.height??0;if(n<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&n<i,a=e+n/2,c=r+i/2,u=s?i/2:n/2,l=Math.cos(o),h=Math.sin(o),f=(t,e)=>({x:a+t*l-e*h,z:c+t*h+e*l});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Gc(t){const e=t.cx??0,r=t.cy??0,n=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(n+n*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,l="reverse"===t.status;if(n<=0||i<=0)return{inbounds:[],outbounds:[]};const h={x:e+s*Math.sin(c),z:r-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:r-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return l?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:h,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:h,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function Bc(t){const e=Wc(t),r=e.outbounds[0];if(!r)return{inbounds:Uc(t,"inbound"),outbounds:[]};const n=Uc(t,"inbound").filter(t=>{const e=t.worldPos.x-r.worldPos.x,n=t.worldPos.z-r.worldPos.z;return Math.hypot(e,n)>1}),i=r.direction,o=[];for(const t of n){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const r=t.direction.x+i.x,n=t.direction.z+i.z,s=Math.hypot(r,n)||1;o.push({worldPos:t.worldPos,direction:{x:r/s,z:n/s},halfSpan:t.halfSpan})}return{inbounds:[...n,...o],outbounds:e.outbounds}}function Hc(t,e,r={}){const n=r.distance??5,i=r.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 r=t.direction.x,i=t.direction.z;if(Math.abs(o*r+s*i)>n)return!1;const a=Math.abs(o*-i+s*r);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=n}function Xc(t,e,r,n=0){const i=r.width??0,o=r.height??0;if(i<=0||o<=0)return!1;const s=(r.left??0)+i/2,a=(r.top??0)+o/2,c="number"==typeof r.rotation?r.rotation:0,u=Math.cos(-c),l=Math.sin(-c),h=t-s,f=e-a,d=h*u-f*l,p=h*l+f*u;return Math.abs(d)<=i/2+n&&Math.abs(p)<=o/2+n}function Vc(t,e,r){const n=r.width??0,i=r.height??0;if(n<=0||i<=0)return 1/0;const o=(r.left??0)+n/2,s=(r.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,l=e.z;const h="number"==typeof r.rotation?r.rotation:0;if(0!==h){const t=Math.cos(-h),e=Math.sin(-h),r=a*e+c*t,n=u*e+l*t;a=a*t-c*e,c=r,u=u*t-l*e,l=n}const f=n/2,d=i/2;let p=-1/0,g=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)),g=Math.min(g,Math.max(t,e))}if(Math.abs(l)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/l,e=(d-c)/l;p=Math.max(p,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<p?1/0:p>=0?p:g>=0?Math.min(-p,g):-g}function Zc(t,e,r,n=6){return!!Xc(t.worldPos.x,t.worldPos.z,e,n)&&(!r||t.direction.x*r.x+t.direction.z*r.z>=0)}function Qc(t,e,r){return t.outbounds.map(t=>{const n=[];for(const i of e){let e=null;for(const n of i.topology.inbounds){if(!Hc(t,n,r))continue;const i=t.worldPos.x-n.worldPos.x,o=t.worldPos.z-n.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const n=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?r?.sinkMargin??30:6;if(Zc(t,i.bounds,n,o)){const r=Vc(t.worldPos,t.direction,i.bounds);if(Number.isFinite(r))e=r+1e3;else{const r=(i.bounds.left??0)+(i.bounds.width??0)/2,n=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-r,t.worldPos.z-n)+1e3}}}null!==e&&n.push({id:i.id,dist:e})}return 0===n.length?null:(n.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),n[0].id)})}function Jc(t,e){const r=new Map;for(const e of t)r.set(e.id,e);const n=new Map,i=new Set;for(const r of t){const o=t.filter(t=>t.id!==r.id),s=Qc(r.topology,o,e);n.set(r.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!r.has(t)||!r.has(e)||t===e)return;const o=n.get(t)??[];o.includes(e)||(o.push(e),n.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){(n.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:r,out:n,sinks:s,sources:a}}function Kc(t,e){const r=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const n=new Set([e]);for(const i of function(t,e,r){const n=r.get(e);if(n)return n;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const r of t.out.get(e)??[])null!=r&&(i.add(r),s.has(r)||(s.add(r),o.push(r)))}return r.set(e,i),i}(t,e,r))n.add(i);return n})}function tu(t,e,r,n){return e===r?0:function(t,e,r){const n=r.get(e);if(n)return n;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),r=i.get(e);for(const n of t.out.get(e)??[])null==n||i.has(n)||(i.set(n,r+1),o.push(n))}return r.set(e,i),i}(t,e,n).get(r)??1/0}function eu(t,e,r){const n=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<n.length;e++){const s=n[e];if(null==s)continue;const a=s===r?0:tu(t,s,r,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 ru(t,e,r){const n=eu(t,e,r);return n.length?n[0]:-1}function nu(t,e,r){return e===r||eu(t,e,r).length>0}function iu(t,e){const r=new Set;for(const n of Kc(t,e))for(const e of n)t.sinks.has(e)&&r.add(e);return r}function ou(t,e,r){return su(t,e,r).map(t=>t.index)}function su(t,e,r){const n=r instanceof Set?r:new Set(r);if(0===n.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...n].sort(),a=[];for(let e=0;e<i.length;e++){const r=i[e];if(null==r)continue;let n=1/0,c="";for(const e of s){const i=1+(r===e?0:tu(t,r,e,o));i<n&&(n=i,c=e)}n!==1/0&&a.push({index:e,hops:n,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function au(t,e={}){const r=[],n=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const n=t.nodes.get(e);if(!n||!n.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||r.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)||r.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],r=[...t.nodes.keys()].sort(),n=new Set,i=[],o=new Set,s=r=>{n.add(r),i.push(r),o.add(r);for(const a of t.out.get(r)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),r=i.slice(t),n=r.indexOf([...r].sort()[0]),o=[...r.slice(n),...r.slice(0,n)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else n.has(a)||s(a);i.pop(),o.delete(r)};for(const t of r)n.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=>n.has(t))||r.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)&&r.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)||r.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return r.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),r}function cu(t,e){if(!t)return[];const r=[],n=new Set,i=t=>{if(!t||n.has(t))return;if(n.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,n=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=n?String(n):void 0;if(i)try{const e=t.getSegmentTopology(),n=t.state??{},o={left:n.left,top:n.top,width:n.width,height:n.height,rotation:n.rotation};e&&r.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),r}function uu(t,e){const r=t.state?.targetRef??t.state?.outputRef;if("string"==typeof r&&r.length>0)return r;if("function"!=typeof t.getSegmentTopology)return null;const n=t.getSegmentTopology();if(!n||0===n.outbounds.length)return null;const i=Qc(n,cu(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 lu(t){return!!t&&"function"==typeof t.routingConstraints}function hu(t){return!!t&&"function"==typeof t.acceptedCarrierData}function fu(t,e=16){const r=[],n=t.parent??t.rootModel??t.root;if(!n)return r;const i=uu(t);if(!i)return r;const o=gu(n,i);if(!o)return r;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=lu(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=du(t.accumulated,i);if(!o)continue;const a=pu(t.segment,e.portId,n);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??""])}):r.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(hu(t.segment)){const e=t.segment.acceptedCarrierData(),n=t.segment.state?.id;if(0===e.length)r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:n});else for(const i of e){const e=du(t.accumulated,i);e&&r.push({data:e,weight:1,pathIds:t.pathIds,destination:n})}continue}const e=uu(t.segment);if(!e||t.visited.has(e)){r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=gu(n,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return r}function du(t,e){const r={...t};for(const[t,n]of Object.entries(e)){if(t in r&&r[t]!==n)return null;r[t]=n}return r}function pu(t,e,r){if("straight"===e&&t.state?.outputRef)return gu(r,t.state.outputRef);const n=gu(r,e);if(n)return n;const i=uu(t);return i?gu(r,i):null}function gu(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const r=new Set,n=t=>{if(!t||r.has(t))return null;if(r.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=n(t);if(e)return e}return null};return n(t)}function yu(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function mu(t,e,r=5,n=[],i=r){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,r)=>"start"===r?t[e].start:t[e].end,u=[],l=new Map,h=[],f=new Map;for(const t of n){const e=Array.isArray(t),r=e?t:t.positions,n=e?void 0:t.kind;if(!r.length)continue;const i=u.length;u.push({pos:r[0],members:[]});for(const t of r)h.push({pos:t,pt:i});n&&f.set(i,n)}const d=(t,e)=>{const n=c(t,e),i=l.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of h)yu(t.pos,n)<=r&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)yu(u[t].pos,n)<=r&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:n,members:[]})),u[s].members.push({seg:t,end:e}),l.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,g=new Set,y=new Set;{const t=t=>{let e=-1,r=1/0;for(let n=0;n<u.length;n++){const i=yu(u[n].pos,t);i<r&&(r=i,e=n)}for(const n of h){const i=yu(n.pos,t);i<r&&(r=i,e=n.pt)}return{pt:e,d:r}};for(const r of e){const{pt:e,d:n}=t(r.pos);e>=0&&n<=i&&(p.add(e),("source"===r.kind?g:y).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?g:y).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],v=(e,r)=>{if(void 0===s[e])return s[e]=r,void b.push(e);s[e]!==r&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const r=l.get(`${t}:${e}`);if(void 0===r)continue;const n=u[r];if(2!==n.members.length||p.has(r))continue;const i=n.members[0],o=i.seg===t&&i.end===e?n.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,r="start",n=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=yu(c(i,o),t.pos);s<n&&(n=s,e=i,r=o)}if(e<0||n>i)return;const s="source"===t.kind?"end"===r:"start"===r;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 r=0,n=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?r++:n++);const i=e[0];let o;0===n&&r>0?o="end"===i.end:0===r&&n>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)&&g.size>0&&y.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),r=[];for(const n of t)e[n]=0,r.push(n);for(;r.length;){const t=r.shift();for(const n of u[t].members){const i=l.get(`${n.seg}:${"start"===n.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,r.push(i))}}return e},e=t(g),r=t(y);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const n=l.get(`${t}:start`),i=l.get(`${t}:end`);if(void 0===n||void 0===i)continue;if(u[n].members.length<2||u[i].members.length<2)continue;if(e[n]===1/0||e[i]===1/0||r[n]===1/0||r[i]===1/0)continue;let o;e[n]!==e[i]?o=e[n]<e[i]:r[n]!==r[i]&&(o=r[i]<r[n]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const S=new Map;for(let e=0;e<o;e++)S.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:S,conflicts:[...a]}}function bu(...t){}function vu(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function xu(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*_u(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*_u(t)}function wu(t,e,r){const n=e.width??0,i=e.height??0;if(n<=0||i<=0)return!1;const o=(e.left??0)+n/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,l=Math.cos(-a),h=Math.sin(-a),f=c*l-u*h,d=c*h+u*l;return Math.abs(f)<=n/2+r&&Math.abs(d)<=i/2+r}function ku(t){const e=[],r=[],n=[],i=[];for(const o of _u(t)){const t=xu(o);if(!t)continue;if(o.flowOrientable){const r=qc(o.state??{});r&&e.push({id:t,start:r.start,end:r.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)r.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)r.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&&n.push({positions:t})}}for(const t of i){const i=[];for(const r of e)for(const e of[r.start,r.end])wu(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of r)wu(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)&&n.push({positions:i,kind:a})}if(0===e.length||0===r.length)return e.length,r.length,new Map;const o=mu(e,r,8,n,60).directions;return e.length,r.length,n.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function Su(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let r=e.__flowOrientation;if(!r){e.__flowComputing=!0;try{r={map:ku(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=r}const n=xu(t),i=n?r.map.get(n):void 0;return"reverse"===i||"forward"!==i&&void 0}function Mu(t){return!!t&&"function"==typeof t.distanceToBoardPoint&&"function"==typeof t.routingLinks&&("function"==typeof t.registerDivertStation||"function"==typeof t.registerInductStation)}function zu(t,e,r){if(!e)return null;const n=[],i=e=>{if(!e||e===r)return;if(Mu(e)){const r=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}(e);if(r){const i=e.distanceToBoardPoint(t.x,t.y);n.push({id:r,component:e,distance:i})}}const o=e.components;if(Array.isArray(o))for(const t of o)i(t)};return i(e),0===n.length?null:(n.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),n[0])}function Au(t){return!!t&&"function"==typeof t.routingDestination}function ju(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*Eu(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*Eu(t)}function Ou(t){const e=[],r=new Map,n=new Map,i=new Set,o=[];for(const s of Eu(t)){const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks;if(!t&&!Au(s)&&!a)continue;const c=ju(s);if(!c)continue;let u={inbounds:[],outbounds:[]};if(t){try{u=s.getSegmentTopology()}catch{continue}if(!u)continue}const l=s.state??{},h={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation},f="function"==typeof s.routingLinks?s.routingLinks():void 0;if(e.push({id:c,topology:u,bounds:h,links:f}),n.set(c,s),"function"==typeof s?.registerWithStationHost&&o.push(s),Au(s)){i.add(c);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=r.get(t)??[];e.push(c),r.set(t,e)}}}return{nodes:e,destToSinks:r,components:n,routingTargetIds:i,stationClients:o}}function Tu(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:r,destToSinks:n,components:i,routingTargetIds:o,stationClients:s}=Ou(t),a=Jc(r);!function(t,e){if(!t)return;const r=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)r(t)};if(r(t),0===e.length)return;const n=[...e].sort((t,e)=>{const r=ju(t)??"",n=ju(e)??"";return r.localeCompare(n)});for(const e of n){const r=e.state?.sorterRef;let n=null;if(r&&(n=t.findById?.(r)??null),!n){const r=e.sorterFacingPoint?.()??e._sorterFacingPoint?.();r&&(n=zu(r,t,e)?.component??null)}n&&"function"==typeof e.registerWithStationHost&&e.registerWithStationHost(n)}}(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 r=e.routingWeight();"number"==typeof r&&(!Number.isFinite(r)||r<=0)&&u.set(t,r)}}const l=au(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(l.length>0&&"undefined"!=typeof console){const t=l.filter(t=>"error"===t.severity),e=l.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,l):console.info(`[FlowGraph] ${e.length} warning(s):`,l)}e={graph:a,destToSinks:n,components:i,issues:l},t.__flowGraph=e}return e}function Pu(t){return Tu(t)?.issues??[]}function Cu(t){const e=Tu(t);return e&&e.graph.nodes.size>0?e.graph:null}function Iu(t,e){return Tu(t)?.destToSinks.get(e)??[]}function Fu(t,e){return Tu(t)?.components.get(e)}function Ru(t){const e=Tu(t);return e?[...e.destToSinks.keys()]:[]}function Du(t){return ju(t)}function Nu(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,r=t?.state?.capacity;return"number"==typeof r&&r>0?e/r:e}function Lu(t,e,r,n,i){if(1===n.length)return n[0];switch(t){case"index":default:return n[0];case"round-robin":{const t=r.counters.get(e)??0;return r.counters.set(e,t+1),n[t%n.length]}case"weight":{const t=n.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 n[0];const s=r.counters.get(e)??0;r.counters.set(e,s+1);let a=s%o;for(let e=0;e<n.length;e++){if(a<t[e])return n[e];a-=t[e]}return n[n.length-1]}case"utilization":{let t=1/0,e=n[0];for(const r of n){const n=Nu(i.get(r.target));n<t&&(t=n,e=r)}return e}}}function Yu(t,e,r){const n=t?.root;if(!n)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=Tu(n);if(!o||0===o.graph.nodes.size)return null;const s=ju(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=su(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],l=c.filter(t=>{const r=u[t.index],n=r?o.components.get(r):null;return!n||"function"!=typeof n.canReceive||n.canReceive(e)});if(0===l.length)return u[c[0].index]??null;const h=r?.policy??function(t,e){const r=t?.state?.balancingPolicy;if(r)return r;const n=e?.state?.routingBalancingPolicy;return n||"round-robin"}(t,n),f=Lu(h,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(n),l,o.components);return u[f.index]??null}try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,Cu(t)}catch{return null}}}catch{}function $u(t,e,r){const n=Yu(t,e,r);if(null==n)return null;const i=t?.root,o=Fu(i,n)??i?.findById?.(n)??null;return o?{targetId:n,component:o,origin:"explicit"}:null}function Uu(t){const e=t?.root,r=Cu(e),n=Du(t);if(!r||!n)return null;const i=(r.out.get(n)??[]).find(Boolean);if(!i)return null;const o=Fu(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Wu(t){const e=Du(t);return e?qu(t?.root,e):[]}function qu(t,e){if(!t||!e)return[];const r=Cu(t);if(!r)return[];const n=new Set;for(const i of iu(r,e)){const e=Fu(t,i);if(Au(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&n.add(t)}}return[...n]}function Gu(t,e){if(!t||!e)return[];const r=Cu(t);if(!r)return[];const n=new Map;for(const t of r.out.values())for(const e of t)null!=e&&n.set(e,(n.get(e)??0)+1);const i=new Map;for(const o of iu(r,e)){const e=Fu(t,o);if(!Au(e))continue;const r=e.routingDestination();if("string"!=typeof r||0===r.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=n.get(o)??0,0===s&&(s=1)),i.set(r,(i.get(r)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function Bu(t){return Cu(t)}function Hu(t){const e=Cu(t);if(!e)return[];const r=new Set,n=new Set,i=t=>{if(!t)return;const o=Du(t);if(o&&e.nodes.has(o)){Au(t)&&r.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&n.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),au(e,{routingTargetIds:r,loopCapableIds:n})}function Xu(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 r=Math.random()*e;let n=0;for(const e of t)if(n+=e.weight,r<n)return e.value;return t[t.length-1].value}const Vu={next:$u,downstream:Uu,reachableDestinations:Wu,reachableDestinationsFrom:qu,reachableDestinationsWeightedFrom:Gu,pickWeightedDestination:Xu,graphFor:Bu,validate:Hu};function Zu(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(t,e){const r=this._realObject?.object3d;return r?{attach:r}:null}addItem(t,e){if(!t||this.containsItem(t))return;const r=t.parent;if(r&&"function"==typeof r.removeItem&&r!==this&&r.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 r=this._items.indexOf(t);if(-1!==r&&(this._items.splice(r,1),t.parent=null,!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,r)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const r=t.parent;r&&("function"==typeof r.removeComponent&&-1!==r._components?.indexOf?.(t)&&r.removeComponent(t,!0),r!==this&&"function"==typeof r.removeItem&&-1!==r._items?.indexOf?.(t)&&r.removeItem(t,!0));const n=-1===this._items.indexOf(t);if(n&&this._items.push(t),t.parent=this,n&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.realObject;const i=t._realObject,o=i?.object3d;if(o){let r,n,s=e?.toParent3D,a="world-preserve";if(!s&&!0===this.isCarrierHolder&&"function"==typeof this.attachPointFor){const e=this.attachPointFor(t);e?.attach&&(s=e.attach,r=e.localPosition,n=e.localRotation,a=e.carryPolicy??"world-preserve")}s&&o.parent!==s&&(s.updateWorldMatrix?.(!0,!1),o.updateWorldMatrix?.(!0,!1),s.attach(o),i.suppressTransform=!0),s&&(r&&o.position.set(r.x,r.y,r.z),"world-preserve"!==a?n?o.rotation.set(n.x,n.y,n.z):o.quaternion.identity():n&&o.rotation.set(n.x,n.y,n.z),i?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}))}t.held?.(this),this._bumpReceived?.(t)}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,r,n,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?.(r,n,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const r=this._items;if(!r||0===r.length)return;t.save();const n=e.bounds;!e.showOverflow&&n&&(t.beginPath(),t.rect(n.left,n.top,n.width,n.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,r){const n=this,i=this._items;if(i&&i.length>0&&(!n.app||n.app.isEditMode||!n.hidden)){const i=n.fromParent?.(t,e);if(i&&n.contains?.(i.x,i.y)){const o=n.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,r);if(s)return s}}return super.capture?.(t,e,r)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Qu(t){var e;var r,n,i;return $c((e=class extends(Zu(t)){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 r=this.state?.rejected??0;this.setState?.({rejected:r+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}},r=e,"symbol"==typeof(n="FlowNodeMixed")&&(n=n.description?"[".concat(n.description,"]"):""),Object.defineProperty(r,"name",{configurable:!0,value:i?"".concat(i," ",n):n}),e.capabilities=Object.freeze([...t.capabilities??[],"Holdable","FlowNode"]),e.isFlowNode=!0,e))}function Ju(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,r({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"}),r({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{ct as BULGE_EPSILON,kt as CapacityEventTracker,At as CenteringQueueStrategy,g as CenteringSlotStrategy,V as ContainerCapacity,d as FixedSlotStrategy,Vu as FlowEngine,Qu as FlowNode,Ot as GravityStrategy,jt as GridStrategy,Zu as Holdable,$c as ItemsDataBinding,rt as NavGraph,bt as PolygonPathPolyline,zt as QueueStrategy,tt as ReservationTable,Et as ShelfStrategy,Mt as StackStrategy,W as TRANSFER_SLOT_KEY,H as Transfer,Ru as allDestinations,Hc as anchorsConnect,Lu as applyPolicy,Gc as arcSegmentTopology,St as autoWireBackPressure,Jc as buildFlowGraph,ot as buildNavGraph,ft as bulgeFromDrag,ht as bulgeHandlePosition,nu as canReach,t as capability,f as chooseNearestPickupFrame,cu as collectAdjacentSegments,Fu as componentForNode,lt as computeArcParams,ku as computeFlowMap,pt as cornerHandlePosition,gt as cornerRadiusFromDrag,Zc as deliversInto,Uu as downstream,dt as effectiveCornerRadius,fu as enumerateDataScenarios,h as filterByToolType,zu as findNearestStationHost,p as fixedSlotStrategy,vt as flattenPolygonPath,Cu as flowGraphFor,Pu as flowGraphIssues,Su as flowReverseFor,vu as ftId,bu as ftrace,i as getAllCapabilityMeta,n as getCapabilityMeta,I as globalSimClock,Bu as graphFor,ut as hasArc,_t as hasCapacity,wt as inferCapacity,uu as inferDownstreamId,mu as inferFlowDirections,Z as isCarrierLine,Ju as isFlowNode,Au as isRoutingTarget,Mu as isStationHost,Qc as matchOutbounds,$u as next,ru as nextHop,eu as nextHops,ou as nextHopsToAny,su as nextHopsToAnyDetailed,Du as nodeIdOf,Xu as pickWeightedDestination,st as planPathAStar,at as planToReservations,Xc as pointInRotatedRect,xt as polygonPathLength,s as quatFromYaw,Vc as rayAbsDistanceToRect,Kc as reachableByOutbound,Wu as reachableDestinations,qu as reachableDestinationsFrom,Gu as reachableDestinationsWeightedFrom,iu as reachableSinks,G as receiptToJSON,Uc as rectFaceAnchors,u as rectangularFootprintFrames,r as registerCapabilityMeta,et as reservationTable,Yu as resolveNextHop,Iu as sinksForDestination,K as standardYieldPolicy,qc as straightSegmentEndpoints,Bc as straightSegmentMultiInbound,Wc as straightSegmentTopology,l as topApproachFrame,X as transferLog,L as transferTracer,yt as uniformZ,Hu as validate,au as validateFlowGraph};
|
|
6
|
+
*/const y=2e3;function m(...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 r=t[0];r&&r.isStackTrace?console.warn(r.getError(e)):console.warn(e,...t)}}function b(t,e,r){return Math.max(e,Math.min(r,t))}class v{constructor(t=0,e=0,r=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=n}static slerpFlat(t,e,r,n,i,o,s){let a=r[n+0],c=r[n+1],u=r[n+2],l=r[n+3],h=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(l!==p||a!==h||c!==f||u!==d){let t=a*h+c*f+u*d+l*p;t<0&&(h=-h,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const r=Math.acos(t),n=Math.sin(r);e=Math.sin(e*r)/n,a=a*e+h*(s=Math.sin(s*r)/n),c=c*e+f*s,u=u*e+d*s,l=l*e+p*s}else{a=a*e+h*s,c=c*e+f*s,u=u*e+d*s,l=l*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+l*l);a*=t,c*=t,u*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=l}static multiplyQuaternionsFlat(t,e,r,n,i,o){const s=r[n],a=r[n+1],c=r[n+2],u=r[n+3],l=i[o],h=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*l+a*f-c*h,t[e+1]=a*d+u*h+c*l-s*f,t[e+2]=c*d+u*f+s*h-a*l,t[e+3]=u*d-s*l-a*h-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,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,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 r=t._x,n=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(r/2),u=s(n/2),l=s(i/2),h=a(r/2),f=a(n/2),d=a(i/2);switch(o){case"XYZ":this._x=h*u*l+c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l-h*f*d;break;case"YXZ":this._x=h*u*l+c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l+h*f*d;break;case"ZXY":this._x=h*u*l-c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l-h*f*d;break;case"ZYX":this._x=h*u*l-c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l+h*f*d;break;case"YZX":this._x=h*u*l+c*f*d,this._y=c*f*l+h*u*d,this._z=c*u*d-h*f*l,this._w=c*u*l-h*f*d;break;case"XZY":this._x=h*u*l-c*f*d,this._y=c*f*l-h*u*d,this._z=c*u*d+h*f*l,this._w=c*u*l+h*f*d;break;default:m("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],n=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],l=e[10],h=r+s+l;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-n)*t}else if(r>s&&r>l){const t=2*Math.sqrt(1+r-s-l);this._w=(u-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(i+c)/t}else if(s>l){const t=2*Math.sqrt(1+s-r-l);this._w=(i-c)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+l-r-s);this._w=(o-n)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(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=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(b(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(0===r)return this;const n=Math.min(1,e/r);return this.slerp(t,n),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 r=t._x,n=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=r*u+o*s+n*c-i*a,this._y=n*u+o*a+i*s-r*c,this._z=i*u+o*c+r*a-n*s,this._w=o*u-r*s-n*a-i*c,this._onChangeCallback(),this}slerp(t,e){let r=t._x,n=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(r=-r,n=-n,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+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+r*e,this._y=this._y*a+n*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),n=Math.sqrt(1-r),i=Math.sqrt(r);return this.set(n*Math.sin(t),n*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 x{constructor(t=0,e=0,r=0){x.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return void 0===r&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,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("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,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(w.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(w.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*n-s*r),u=2*(s*e-i*n),l=2*(i*r-o*e);return this.x=e+a*c+o*l-s*u,this.y=r+a*u+s*c-i*l,this.z=n+a*l+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,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,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=b(this.x,t.x,e.x),this.y=b(this.y,t.y,e.y),this.z=b(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=b(this.x,t,e),this.y=b(this.y,t,e),this.z=b(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(b(r,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,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,n=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=n*a-i*s,this.y=i*o-r*a,this.z=r*s-n*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return _.copy(this).projectOnVector(t),this.sub(_)}reflect(t){return this.sub(_.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 r=this.dot(t)/e;return Math.acos(b(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}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,r){const n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,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(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,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,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _=new x,w=new v;class k{constructor(t,e,r,n,i,o,s,a,c,u,l,h,f,d,p,g){k.prototype.isMatrix4=!0,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,r,n,i,o,s,a,c,u,l,h,f,d,p,g)}set(t,e,r,n,i,o,s,a,c,u,l,h,f,d,p,g){const y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=n,y[1]=i,y[5]=o,y[9]=s,y[13]=a,y[2]=c,y[6]=u,y[10]=l,y[14]=h,y[3]=f,y[7]=d,y[11]=p,y[15]=g,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 k).fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[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,r){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),r.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,r=t.elements,n=1/S.setFromMatrixColumn(t,0).length(),i=1/S.setFromMatrixColumn(t,1).length(),o=1/S.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),s=Math.sin(r),a=Math.cos(n),c=Math.sin(n),u=Math.cos(i),l=Math.sin(i);if("XYZ"===t.order){const t=o*u,r=o*l,n=s*u,i=s*l;e[0]=a*u,e[4]=-a*l,e[8]=c,e[1]=r+n*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=n+r*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,r=a*l,n=c*u,i=c*l;e[0]=t+i*s,e[4]=n*s-r,e[8]=o*c,e[1]=o*l,e[5]=o*u,e[9]=-s,e[2]=r*s-n,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,r=a*l,n=c*u,i=c*l;e[0]=t-i*s,e[4]=-o*l,e[8]=n+r*s,e[1]=r+n*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,r=o*l,n=s*u,i=s*l;e[0]=a*u,e[4]=n*c-r,e[8]=t*c+i,e[1]=a*l,e[5]=i*c+t,e[9]=r*c-n,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=i-t*l,e[8]=n*l+r,e[1]=l,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=r*l+n,e[10]=t-i*l}else if("XZY"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=-l,e[8]=c*u,e[1]=t*l+i,e[5]=o*u,e[9]=r*l-n,e[2]=n*l-r,e[6]=s*u,e[10]=i*l+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(z,t,A)}lookAt(t,e,r){const n=this.elements;return O.subVectors(t,e),0===O.lengthSq()&&(O.z=1),O.normalize(),j.crossVectors(r,O),0===j.lengthSq()&&(1===Math.abs(r.z)?O.x+=1e-4:O.z+=1e-4,O.normalize(),j.crossVectors(r,O)),j.normalize(),E.crossVectors(O,j),n[0]=j.x,n[4]=E.x,n[8]=O.x,n[1]=j.y,n[5]=E.y,n[9]=O.y,n[2]=j.z,n[6]=E.z,n[10]=O.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,o=r[0],s=r[4],a=r[8],c=r[12],u=r[1],l=r[5],h=r[9],f=r[13],d=r[2],p=r[6],g=r[10],y=r[14],m=r[3],b=r[7],v=r[11],x=r[15],_=n[0],w=n[4],k=n[8],S=n[12],M=n[1],z=n[5],A=n[9],j=n[13],E=n[2],O=n[6],T=n[10],P=n[14],C=n[3],I=n[7],F=n[11],R=n[15];return i[0]=o*_+s*M+a*E+c*C,i[4]=o*w+s*z+a*O+c*I,i[8]=o*k+s*A+a*T+c*F,i[12]=o*S+s*j+a*P+c*R,i[1]=u*_+l*M+h*E+f*C,i[5]=u*w+l*z+h*O+f*I,i[9]=u*k+l*A+h*T+f*F,i[13]=u*S+l*j+h*P+f*R,i[2]=d*_+p*M+g*E+y*C,i[6]=d*w+p*z+g*O+y*I,i[10]=d*k+p*A+g*T+y*F,i[14]=d*S+p*j+g*P+y*R,i[3]=m*_+b*M+v*E+x*C,i[7]=m*w+b*z+v*O+x*I,i[11]=m*k+b*A+v*T+x*F,i[15]=m*S+b*j+v*P+x*R,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],r=t[4],n=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],l=t[6],h=t[10],f=t[14],d=t[3],p=t[7],g=t[11],y=t[15],m=a*f-c*h,b=s*f-c*l,v=s*h-a*l,x=o*f-c*u,_=o*h-a*u,w=o*l-s*u;return e*(p*m-g*b+y*v)-r*(d*m-g*x+y*_)+n*(d*b-p*x+y*w)-i*(d*v-p*_+g*w)}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,r){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],l=t[9],h=t[10],f=t[11],d=t[12],p=t[13],g=t[14],y=t[15],m=e*s-r*o,b=e*a-n*o,v=e*c-i*o,x=r*a-n*s,_=r*c-i*s,w=n*c-i*a,k=u*p-l*d,S=u*g-h*d,M=u*y-f*d,z=l*g-h*p,A=l*y-f*p,j=h*y-f*g,E=m*j-b*A+v*z+x*M-_*S+w*k;if(0===E)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/E;return t[0]=(s*j-a*A+c*z)*O,t[1]=(n*A-r*j-i*z)*O,t[2]=(p*w-g*_+y*x)*O,t[3]=(h*_-l*w-f*x)*O,t[4]=(a*M-o*j-c*S)*O,t[5]=(e*j-n*M+i*S)*O,t[6]=(g*v-d*w-y*b)*O,t[7]=(u*w-h*v+f*b)*O,t[8]=(o*A-s*M+c*k)*O,t[9]=(r*M-e*A-i*k)*O,t[10]=(d*_-p*v+y*m)*O,t[11]=(l*v-u*_-f*m)*O,t[12]=(s*S-o*z-a*k)*O,t[13]=(e*z-r*S+n*k)*O,t[14]=(p*b-d*x-g*m)*O,t[15]=(u*x-l*b+h*m)*O,this}scale(t){const e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),n=Math.sin(e),i=1-r,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+r,c*s-n*a,c*a+n*s,0,c*s+n*a,u*s+r,u*a-n*o,0,c*a-n*s,u*a+n*o,i*a*a+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,i,o){return this.set(1,r,i,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){const n=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,l=s+s,h=i*c,f=i*u,d=i*l,p=o*u,g=o*l,y=s*l,m=a*c,b=a*u,v=a*l,x=r.x,_=r.y,w=r.z;return n[0]=(1-(p+y))*x,n[1]=(f+v)*x,n[2]=(d-b)*x,n[3]=0,n[4]=(f-v)*_,n[5]=(1-(h+y))*_,n[6]=(g+m)*_,n[7]=0,n[8]=(d+b)*w,n[9]=(g-m)*w,n[10]=(1-(h+p))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const i=this.determinant();if(0===i)return r.set(1,1,1),e.identity(),this;let o=S.set(n[0],n[1],n[2]).length();const s=S.set(n[4],n[5],n[6]).length(),a=S.set(n[8],n[9],n[10]).length();i<0&&(o=-o),M.copy(this);const c=1/o,u=1/s,l=1/a;return M.elements[0]*=c,M.elements[1]*=c,M.elements[2]*=c,M.elements[4]*=u,M.elements[5]*=u,M.elements[6]*=u,M.elements[8]*=l,M.elements[9]*=l,M.elements[10]*=l,e.setFromRotationMatrix(M),r.x=o,r.y=s,r.z=a,this}makePerspective(t,e,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),l=2*i/(r-n),h=(e+t)/(e-t),f=(r+n)/(r-n);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===y)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]=h,c[12]=0,c[1]=0,c[5]=l,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,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),l=2/(r-n),h=-(e+t)/(e-t),f=-(r+n)/(r-n);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===y)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]=h,c[1]=0,c[5]=l,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,r=t.elements;for(let t=0;t<16;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const S=new x,M=new k,z=new x(0,0,0),A=new x(1,1,1),j=new x,E=new x,O=new x,T=new k,P=new v;class C{constructor(t=0,e=0,r=0,n=C.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}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,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,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,r=!0){const n=t.elements,i=n[0],o=n[4],s=n[8],a=n[1],c=n[5],u=n[9],l=n[2],h=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(b(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-b(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(b(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-l,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-b(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(b(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-b(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:m("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return T.makeRotationFromQuaternion(t),this.setFromRotationMatrix(T,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return P.setFromEuler(this),this.setFromQuaternion(P,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}}C.DEFAULT_ORDER="XYZ","undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"183"}})),"undefined"!=typeof window&&(window.__THREE__?m("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="183");const I=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__=I);let F=null;const R=[],D=new Set;function N(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const L={beginContext(t){F=t},endContext(){F=null},current:()=>F,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??N(t.component),componentType:t.componentType??(r=t.component,r?.state?.type??r?.type),atSimMs:I.now,args:t.args,result:t.result,error:t.error};var r;F?F.pushTrace(e):(R.push(e),R.length>500&&R.shift(),D.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...R],onStandalone:t=>(D.add(t),()=>{D.delete(t)}),clearStandalone(){R.length=0}};function Y(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}const $=new C;function U(t,e){$.setFromQuaternion(new v(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=$.x,t.rotation=-$.y,t.rotationY=$.z}const W="_transferSlotId";function q(t){var e;return(e=class extends t{get slots(){return[]}get arrangementStrategy(){return p}canReceive(t){const e=null!==this.findSlot(t);return L.log({role:"target",contract:"canReceive",component:this,args:{carrier:Y(t)},result:e}),e}findSlot(t){const e=this.slots;if(!e.length)return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:null}),null;for(const r of e){if(r.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!r.allowedTypes.includes(e))continue}const e=r.maxCount??this.arrangementStrategy.capacity(r),n=this._countOccupied(r.id);if(!(n>=e))return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:{slotId:r.id,occupied:n,max:e}}),r}return L.log({role:"target",contract:"findSlot",component:this,args:{carrier:Y(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const r=this._realObject?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new v;r.getWorldQuaternion(n);const i=new v(e.x,e.y,e.z,e.w);return n.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,r=e?.object3d;if(!r)return;r.updateWorldMatrix(!0,!1);const n=new x;r.getWorldPosition(n);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new x(0,i,0);return r.localToWorld(t),{x:n.x,y:t.y,z:n.z}}return{x:n.x,y:n.y,z:n.z}}attachPointFor(t){const e=t?.[W];if(!e)return null;const r=this.slots.find(t=>t.id===e);return r?{position:r.localPosition??{x:0,y:0,z:0},rotation:r.localRotation??{x:0,y:0,z:0},slotId:r.id}:null}placementFor(t,e={}){const r=t&&"object"==typeof t&&"state"in t?t:void 0,n=r?r.state??{}:t??{},i={width:Number(n.width)||0,height:Number(n.height)||0,depth:Number(n.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,r??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,l=Number(this.state?.height)||0,h=c.x+i.width/2-u/2,f=c.y+i.height/2-l/2,d=this._realObject,p=d?.placementMode??"floor",g="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,y=this._receivingSurfaceLocalY();let m;m=null!==y?y+g:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+g:g-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(r??i,o)??void 0;return b?{position:{x:h,y:m,z:f},rotation:b}:{position:{x:h,y:m,z:f}}}_zPosFromSeatY(t,e,r){const n=this._realObject,i=n?.receivingSurfaceY??0,o=!(!r.localPosition||!Number.isFinite(r.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=n?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(n?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_countOccupied(t){const e=this.components;return e?e.filter(e=>e.parent===this&&e[W]===t).length:0}}).__hasCapacity=!0,e}function G(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const r=String(e);return r.length>0?r:void 0}function B(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},r=t.sourceId??G(t.source),n=t.targetId??G(t.target),i=t.carrierId??G(t.carrier);return void 0!==r&&(e.sourceId=r),void 0!==n&&(e.targetId=n),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let H=1;class X{constructor(t){this._phase="pending",this._slot=null,this._traceEvents=[],this.meta={},this.id="xfer-"+H++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:I.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??I.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}async execute(){L.beginContext(this),L.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:G(this.source),target:G(this.target),carrier:G(this.carrier)}});try{return await this._executeImpl()}finally{L.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),L.endContext()}}executeSync(){L.beginContext(this),L.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:G(this.source),target:G(this.target),carrier:G(this.carrier)}});try{this._phase="planning",this._timeline.planStartAt=I.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){this._rejectReason=t.reason,this._phase="rolled-back";const e=this._buildReceipt();return V.append(e),e}if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier)){this._rejectReason="cannot-receive",this._phase="rolled-back";const t=this._buildReceipt();return V.append(t),t}this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}if(this._timeline.planEndAt=I.now,this.physical){this._phase="physical",this._timeline.physicalStartAt=I.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();return V.append(e),e}this._timeline.physicalEndAt=I.now}this._phase="handoff",this._timeline.handoffAt=I.now;const e=this.target.accept??this.target.receive;if("function"==typeof e)try{const t=e.call(this.target,this.carrier,this.options);t instanceof Promise&&t.catch(()=>{})}catch(t){this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();throw V.append(e),t}else L.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}});this._phase="committed",this._timeline.committedAt=I.now;const r=this._buildReceipt();return V.append(r),r}finally{L.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),L.endContext()}}async _executeImpl(){this._phase="planning",this._timeline.planStartAt=I.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){this._rejectReason=t.reason,this._phase="rolled-back";const e=this._buildReceipt();return V.append(e),e}if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier)){this._rejectReason="cannot-receive",this._phase="rolled-back";const t=this._buildReceipt();return V.append(t),t}this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}if(this._timeline.planEndAt=I.now,this.physical){this._phase="physical",this._timeline.physicalStartAt=I.now;try{await this.physical()}catch(t){this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();return V.append(e),e}this._timeline.physicalEndAt=I.now}this._phase="handoff",this._timeline.handoffAt=I.now;const e=this.target.accept??this.target.receive;if("function"==typeof e)try{await e.call(this.target,this.carrier,this.options)}catch(t){this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();throw V.append(e),t}else L.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method (physical phase handled handoff)"}});this._phase="committed",this._timeline.committedAt=I.now;const r=this._buildReceipt();return V.append(r),r}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",V.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:G(this.source),targetId:G(this.target),carrierId:G(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 V=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??G(t.source),r=t.targetId??G(t.target);if("committed"===t.phase){if(e&&r){const t=e+">"+r;this._flows.set(t,(this._flows.get(t)??0)+1)}r&&this._targetCount.set(r,(this._targetCount.get(r)??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,r)=>{t[r]=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,r){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};function Z(t){var e;return(e=class extends t{async receive(t,e={}){L.log({role:"target",contract:"receive:enter",component:this,args:{carrier:Y(t),options:e}});const r=this.findSlot(t);if(!r){L.log({role:"target",contract:"receive:reject",component:this,args:{carrier:Y(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}const n=this._countOccupied(r.id),i=this.arrangementStrategy.positionAt(n,r,n,t);L.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:n,slotId:r.id,occupantCount:n,carrier:Y(t)},result:i}),t[W]=r.id;const o=t._realObject;let s,a;o?.object3d&&(o.object3d.updateWorldMatrix(!0,!1),s=new x,a=new v,o.object3d.getWorldPosition(s),o.object3d.getWorldQuaternion(a));const{animated:c=!1,duration:u,ease:l}=e;"function"==typeof this.handoverIn?this.handoverIn(t,{slotId:r.id}):this.reparent?.(t,{animated:c,duration:u,ease:l}),!c&&t._realObject&&(t._realObject.suppressTransform=!1);{const e={},o=this.placementFor?.(t,{slot:r,index:n,occupantCount:n})??null;if(L.log({role:"target",contract:"placementFor",component:this,args:{carrier:Y(t),slotId:r.id,index:n},result:o}),o){const n=t.state??{},i=this.state??{};e.left=o.position.x-(Number(n.width)||0)/2+(Number(i.width)||0)/2,e.top=o.position.z-(Number(n.height)||0)/2+(Number(i.height)||0)/2;const s=this._zPosFromSeatY(o.position.y,n.depth,r);null!==s&&(e.zPos=s),o.rotation&&U(e,o.rotation)}else{i&&(e.left=i.x,e.top=i.y);if(0!==(this._realObject?.receivingSurfaceY??0))e.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const t=this._realObject?.geometricOffsetY??0;e.zPos=r.localPosition.z+t}const n=this.acceptanceRotation?.(t,r);L.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:Y(t),slotId:r.id},result:n}),n&&U(e,n)}const s=this.normalizePose?.(t,r);"function"==typeof this.normalizePose&&L.log({role:"target",contract:"normalizePose",component:this,args:{carrier:Y(t),slotId:r.id},result:s}),s&&Object.assign(e,s),Object.keys(e).length&&(t.setState?.(e),L.log({role:"target",contract:"receive:setState",component:this,args:{carrier:Y(t),keys:Object.keys(e)}}))}this.trigger("transfer-received",{type:"transfer-received",component:t,container:this,slotId:r.id,preReceiveWorldPos:s,preReceiveWorldQuat:a}),L.log({role:"target",contract:"receive:done",component:this,args:{carrier:Y(t),slotId:r.id}})}async dispatch(t,e,r={}){const n=new X({source:this,target:e,carrier:t,options:r,physical:async()=>{delete t[W]}}),i=await n.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 r=this.findSlot(t);if(!r){const r=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!r||t.allowedTypes.includes(r))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:r}})();return L.log({role:"target",contract:"canAccept",component:this,args:{carrier:Y(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}function Q(t){const e=Z(q(t));return e.capabilities=[...t.capabilities??[],"ContainerCapacity","PlacementSurface"],e}function J(t){if(!t||"object"!=typeof t)return!1;const e=t;return"function"==typeof e.canReserveAtJoinPoint&&"function"==typeof e.reserveAtJoinPoint&&"function"==typeof e.commitReservation&&"function"==typeof e.releaseReservation&&e.carrierMap instanceof Map}"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=V),r({name:"ContainerCapacity",description:"Carrier slot topology + reservation / commit / release 의 default 구현을 Mixin 으로 제공. 컨테이너 (chute, induct, dock 등) 가 Transferable contract 의 standard impl 을 1줄 Mixin 으로 획득. subclass 는 *slots* 만 override.",methods:["get slots","reserveSlot","commitReservation","releaseReservation","isSlotAvailable","occupancyAt"],stateFields:["capacity","maxCapacity","slotArrangement"],sourceFile:"src/transfer/container-capacity.ts"}),r({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 구현은 ContainerCapacity 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/transfer/container-capacity.ts"}),r({name:"CarrierLine",description:"carrier slot 들을 연속 경로 위에서 운영하는 컴포넌트의 추상 contract. cross-belt-line, loop-sorter, monorail, AGV-fleet 등 각각 다른 concrete class 들이 같은 capability 를 노출 — source (induct, station 등) 는 concrete class 모르고 capability 만 사용.",methods:["canReserveAtJoinPoint","reserveAtJoinPoint","commitReservation","releaseReservation"],models:["CarrierReservation","CarrierSlotState","JoinPoint"],stateFields:["speed","carrierPitch","direction","orientation"],sourceFile:"src/transfer/carrier-line-capability.ts"});let K=1;function tt(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const et={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class rt{constructor(t=et){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-"+K++},r=(this._byResource.get(e.resource)??[]).filter(t=>tt(t.timeWindow,e.timeWindow));if(0===r.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const n=r.map(t=>{const r=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:r}});if(n.every(t=>"b-yields"===t.decision)){const n=r.slice();for(const t of n)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:n,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:n}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r.slice(),outcome:"rejected"}),{ok:!1,conflicts:n}}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=>tt(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 r=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);r<0?e.push(t):e.splice(r,0,t);let n=this._byReserver.get(t.reserverId);n||(n=[],this._byReserver.set(t.reserverId,n)),n.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const r=e.findIndex(e=>e.id===t.id);if(r<0)return!1;e.splice(r,1),0===e.length&&this._byResource.delete(t.resource);const n=this._byReserver.get(t.reserverId);if(n){const e=n.findIndex(e=>e.id===t.id);e>=0&&n.splice(e,1),0===n.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const nt=new rt;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=nt);class it{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,r=1/0;for(const n of this.nodes.values()){const i=ot(n.position,t);i<r&&(r=i,e=n)}return e}}function ot(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}function st(t,e){return Math.sqrt(ot(t,e))}function at(t,e,r={}){const n=new it,i=r.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const r=`${e.id}:start`,o=`${e.id}:end`;n.addNode({id:r,position:t[0],type:"lane-start"}),n.addNode({id:o,position:t[t.length-1],type:"lane-end"}),n.laneEndpoints.set(e.id,{startNodeId:r,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=st(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;n.addEdge({fromNode:r,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&n.addEdge({fromNode:o,toNode:r,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const r of t.lanes){const i=n.laneEndpoints.get(r);if(!i)continue;const o=n.nodes.get(i.startNodeId).position,s=n.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===r)continue;const t=n.laneEndpoints.get(e);if(!t)continue;const i=n.nodes.get(t.startNodeId).position,l=n.nodes.get(t.endNodeId).position;a+=Math.min(ot(o,i),ot(o,l)),c+=Math.min(ot(s,i),ot(s,l)),u++}if(0===u)continue;const l=a<c?i.startNodeId:i.endNodeId;e.push({laneId:r,nodeId:l,pos:n.nodes.get(l).position})}for(let r=0;r<e.length;r++)for(let i=0;i<e.length;i++){if(r===i)continue;const o=e[r],s=e[i],a=st(o.pos,s.pos);n.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return n}function ct(t,e,r,n={}){const i=t.nodes.get(e),o=t.nodes.get(r);if(!i||!o)return null;const s=n.speed?.max??100,a=e=>{const r=t.nodes.get(e);var n,i;return(n=r.position,i=o.position,Math.sqrt(function(t,e){const r=t.x-e.x,n=t.y-e.y,i=t.z-e.z;return r*r+n*n+i*i}(n,i)))/s*1e3},c=new Map,u=new Set,l=new Set,h={nodeId:e,gScore:0,fScore:a(e)};c.set(e,h),u.add(e);const f=n.startSimMs??0,d=n.deadlineSimMs;for(;u.size>0;){let e=null,n=null;for(const t of u){const r=c.get(t);(!n||r.fScore<n.fScore||r.fScore===n.fScore&&t<e)&&(n=r,e=t)}if(!n||!e)return null;if(e===r){const t=[];let e=n,r=0;for(;e&&e.cameFromEdge;){const n=e.cameFromEdge,i=f+(e.gScore-n.durationMs);t.unshift({resource:n.resource,timeWindow:{startSimMs:i,endSimMs:i+n.durationMs},fromPos:n.fromPos,toPos:n.toPos}),r+=n.distance,e=c.get(n.fromNodeId)}const i=n.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:r}}u.delete(e),l.add(e);for(const r of t.edgesFrom(e)){if(l.has(r.toNode))continue;const e=n.gScore+r.durationMs,i=c.get(r.toNode);if(!i||e<i.gScore){const n=t.nodes.get(r.fromNode),i=t.nodes.get(r.toNode),o={nodeId:r.toNode,gScore:e,fScore:e+a(r.toNode),cameFromEdge:{fromNodeId:r.fromNode,resource:r.resource,distance:r.distance,durationMs:r.durationMs,fromPos:n.position,toPos:i.position}};c.set(r.toNode,o),u.add(r.toNode)}}}return null}function ut(t,e,r=0,n){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:r,metadata:n}))}const lt=.5;function ht(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function ft(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o||!Number.isFinite(r)||Math.abs(r)<1e-9)return null;const s=Math.abs(r),a=(o*o+4*s*s)/(8*s),c=r>0?1:-1,u=a-s,l=(t.x+e.x)/2-c*(i/o)*u,h=(t.y+e.y)/2-c*-(n/o)*u;return{cx:l,cy:h,radius:a,startAngle:Math.atan2(t.y-h,t.x-l),endAngle:Math.atan2(e.y-h,e.x-l),clockwise:r<0}}function dt(t,e,r=0,n=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(r)?r:0,l=Math.abs(u)>=1e-6?u:n;return{x:(t.x+e.x)/2+a*l,y:(t.y+e.y)/2+c*l,perpX:a,perpY:c}}function pt(t,e,r){const n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i);if(0===o)return 0;const s=i/o,a=-(n/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let l=(r.x-c)*s+(r.y-u)*a;if(Math.abs(l)<.5)return 0;return l>o&&(l=o),l<-o&&(l=-o),l}function gt(t,e){const r=t.radius,n=Number.isFinite(e)?e:0;return null!=r&&Number.isFinite(r)?Math.max(0,r):Math.max(0,n)}function yt(t,e,r,n,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=r.x-e.x,u=r.y-e.y,l=Math.sqrt(c*c+u*u);if(0===l)return null;const h=o/a+c/l,f=s/a+u/l,d=Math.sqrt(h*h+f*f);if(d<1e-9)return null;const p=h/d,g=f/d,y=Math.max(n,i);return{x:e.x+p*y,y:e.y+g*y,bisectorX:p,bisectorY:g}}function mt(t,e,r,n){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=r.x-e.x,c=r.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const l=i/s+a/u,h=o/s+c/u,f=Math.sqrt(l*l+h*h);if(f<1e-9)return 0;const d=l/f,p=h/f,g=(n.x-e.x)*d+(n.y-e.y)*p,y=Math.min(s,u)/2;return Math.max(0,Math.min(g,y))}function bt(t){if(0===t.length)return 0;let e;for(const r of t){const t=r.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 vt={closed:!0,round:0,divisions:24};class xt{constructor(t,e){this.points=t,this.closed=e;const r=[0];for(let e=1;e<t.length;e++){const n=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;r.push(r[e-1]+Math.sqrt(n*n+i*i))}this.cumulative=r,this.length=r[r.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 r=t;this.closed?r=(t%e+e)%e:r<0?r=0:r>e&&(r=e);const n=this.cumulative;let i=0,o=n.length-2;for(;i<o;){const t=i+o>>1;n[t+1]<=r?i=t+1:o=t}const s=n[i+1]-n[i],a=s>0?(r-n[i])/s:0,c=this.points[i],u=this.points[i+1],l=u.x-c.x,h=u.y-c.y;return{x:c.x+l*a,y:c.y+h*a,theta:0===l&&0===h?0:Math.atan2(h,l)}}}function _t(t,e={}){const r={...vt,...e},n=t.length;if(0===n)return new xt([],r.closed);if(1===n)return new xt([{x:t[0].x,y:t[0].y}],r.closed);const i=[],o=(t,e)=>{if(i.length>0){const r=i[i.length-1];if(Math.abs(r.x-t)<1e-9&&Math.abs(r.y-e)<1e-9)return}i.push({x:t,y:e})},s=(r.closed,n);for(let e=0;e<s;e++){const i=0===e?r.closed?n-1:-1:e-1,s=e===n-1?r.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 l=a&&u?gt(c,r.round):0;let h,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,r=Math.min(l,t/2);h=Math.sin(e)*r+c.x,f=Math.cos(e)*r+c.y}else h=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,r=Math.min(l,t/2);d=Math.sin(e)*r+c.x,p=Math.cos(e)*r+c.y}else d=c.x,p=c.y;if(o(h,f),l>0&&a&&u)for(let t=1;t<=r.divisions;t++){const e=t/r.divisions,n=1-e;o(n*n*h+2*n*e*c.x+e*e*d,n*n*f+2*n*e*c.y+e*e*p)}else h===d&&f===p||o(d,p);if(u&&ht(c)){const t=gt(u,r.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),n=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=ft({x:d,y:p},{x:Math.sin(n)*i+u.x,y:Math.cos(n)*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<=r.divisions;e++){const n=e/r.divisions,i=s.startAngle+t*n;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(r.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 xt(i,r.closed)}function wt(t,e){return _t(t,e).length}function kt(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function St(t){if(kt(t)){const e=t.capacity(),r=t.available();return{capacity:e,available:r,isFull:0===r}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,r="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:r,isFull:0===r}}const e=t?.state?.capacity,r=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-r);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class Mt{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 zt(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 r=e.onFull(()=>t.pauseEmit()),n=e.onAvailable(()=>t.resumeEmit());return St(e).isFull&&t.pauseEmit(),()=>{r?.(),n?.()}}class At{constructor(t=1){this.itemSpacing=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y+t*this.itemSpacing,z:i.z}}capacity(t){return t.maxCount??1/0}}class jt{constructor(t=1){this.itemSpacing=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y,z:i.z+t*this.itemSpacing}}capacity(t){return t.maxCount??1/0}}class Et{constructor(t,e=1,r="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=r}positionAt(t,e,r,n){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=n?.state?.width??0,c=n?.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}}class Ot{constructor(t=1,e=1){this.colSpacing=t,this.rowSpacing=e}positionAt(t,e,r){const n=e.gridShape?.cols??1,i=n*(e.gridShape?.rows??1);if(t<0||t>=i)return null;if(t>=(e.maxCount??i))return null;const o=t%n,s=Math.floor(t/n),a=e.localPosition??{x:0,y:0,z:0};return{x:a.x+o*this.colSpacing,y:a.y,z:a.z+s*this.rowSpacing}}capacity(t){const e=t.gridShape?.cols??1,r=t.gridShape?.rows??1;return Math.min(t.maxCount??1/0,e*r)}}class Tt{constructor(t=1,e=1){this.itemWidth=t,this.shelfHeight=e}positionAt(t,e,r){const n=e.gridShape?.cols??1,i=n*(e.gridShape?.rows??1);if(t<0||t>=i)return null;if(t>=(e.maxCount??i))return null;const o=t%n,s=Math.floor(t/n),a=e.localPosition??{x:0,y:0,z:0};return{x:a.x+o*this.itemWidth,y:a.y+s*this.shelfHeight,z:a.z}}capacity(t){const e=t.gridShape?.cols??1,r=t.gridShape?.rows??1;return Math.min(t.maxCount??1/0,e*r)}}class Pt{constructor(t=1){this.itemHeight=t}positionAt(t,e,r){const n=e.maxCount??1/0;if(t<0||t>=n)return null;const i=e.localPosition??{x:0,y:0,z:0};return{x:i.x,y:i.y+t*this.itemHeight,z:i.z}}capacity(t){return t.maxCount??1/0}}function Ct(t,e){return t===e||t!=t&&e!=e}function It(t,e){for(var r=t.length;r--;)if(Ct(t[r][0],e))return r;return-1}var Ft=Array.prototype.splice;function Rt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Rt.prototype.clear=function(){this.__data__=[],this.size=0},Rt.prototype.delete=function(t){var e=this.__data__,r=It(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ft.call(e,r,1),--this.size,!0)},Rt.prototype.get=function(t){var e=this.__data__,r=It(e,t);return r<0?void 0:e[r][1]},Rt.prototype.has=function(t){return It(this.__data__,t)>-1},Rt.prototype.set=function(t,e){var r=this.__data__,n=It(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Dt="object"==typeof global&&global&&global.Object===Object&&global,Nt="object"==typeof self&&self&&self.Object===Object&&self,Lt=Dt||Nt||Function("return this")(),Yt=Lt.Symbol,$t=Object.prototype,Ut=$t.hasOwnProperty,Wt=$t.toString,qt=Yt?Yt.toStringTag:void 0;var Gt=Object.prototype.toString;var Bt=Yt?Yt.toStringTag:void 0;function Ht(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Bt&&Bt in Object(t)?function(t){var e=Ut.call(t,qt),r=t[qt];try{t[qt]=void 0;var n=!0}catch(t){}var i=Wt.call(t);return n&&(e?t[qt]=r:delete t[qt]),i}(t):function(t){return Gt.call(t)}(t)}function Xt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Vt(t){if(!Xt(t))return!1;var e=Ht(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var Zt,Qt=Lt["__core-js_shared__"],Jt=(Zt=/[^.]+$/.exec(Qt&&Qt.keys&&Qt.keys.IE_PROTO||""))?"Symbol(src)_1."+Zt:"";var Kt=Function.prototype.toString;function te(t){if(null!=t){try{return Kt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ee=/^\[object .+?Constructor\]$/,re=Function.prototype,ne=Object.prototype,ie=re.toString,oe=ne.hasOwnProperty,se=RegExp("^"+ie.call(oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ae(t){return!(!Xt(t)||(e=t,Jt&&Jt in e))&&(Vt(t)?se:ee).test(te(t));var e}function ce(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ae(r)?r:void 0}var ue=ce(Lt,"Map"),le=ce(Object,"create");var he=Object.prototype.hasOwnProperty;var fe=Object.prototype.hasOwnProperty;function de(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function pe(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function ge(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}de.prototype.clear=function(){this.__data__=le?le(null):{},this.size=0},de.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},de.prototype.get=function(t){var e=this.__data__;if(le){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return he.call(e,t)?e[t]:void 0},de.prototype.has=function(t){var e=this.__data__;return le?void 0!==e[t]:fe.call(e,t)},de.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=le&&void 0===e?"__lodash_hash_undefined__":e,this},ge.prototype.clear=function(){this.size=0,this.__data__={hash:new de,map:new(ue||Rt),string:new de}},ge.prototype.delete=function(t){var e=pe(this,t).delete(t);return this.size-=e?1:0,e},ge.prototype.get=function(t){return pe(this,t).get(t)},ge.prototype.has=function(t){return pe(this,t).has(t)},ge.prototype.set=function(t,e){var r=pe(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function ye(t){var e=this.__data__=new Rt(t);this.size=e.size}ye.prototype.clear=function(){this.__data__=new Rt,this.size=0},ye.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ye.prototype.get=function(t){return this.__data__.get(t)},ye.prototype.has=function(t){return this.__data__.has(t)},ye.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Rt){var n=r.__data__;if(!ue||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new ge(n)}return r.set(t,e),this.size=r.size,this};function me(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new ge;++e<r;)this.add(t[e])}function be(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,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 ve(t,e,r,n,i,o){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),l=o.get(e);if(u&&l)return u==e&&l==t;var h=-1,f=!0,d=2&r?new me:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var p=t[h],g=e[h];if(n)var y=s?n(g,p,h,e,t,o):n(p,g,h,t,e,o);if(void 0!==y){if(y)continue;f=!1;break}if(d){if(!be(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,r,n,o)))return d.push(e);var s})){f=!1;break}}else if(p!==g&&!i(p,g,r,n,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var xe=Lt.Uint8Array;function _e(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function we(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var ke=Yt?Yt.prototype:void 0,Se=ke?ke.valueOf:void 0;function Me(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var ze=Array.isArray;function Ae(){return[]}var je=Object.prototype.propertyIsEnumerable,Ee=Object.getOwnPropertySymbols,Oe=Ee?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var s=t[r];e(s,r,t)&&(o[i++]=s)}return o}(Ee(t),function(e){return je.call(t,e)}))}:Ae;function Te(t){return null!=t&&"object"==typeof t}function Pe(t){return Te(t)&&"[object Arguments]"==Ht(t)}var Ce=Object.prototype,Ie=Ce.hasOwnProperty,Fe=Ce.propertyIsEnumerable,Re=Pe(function(){return arguments}())?Pe:function(t){return Te(t)&&Ie.call(t,"callee")&&!Fe.call(t,"callee")};var De="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ne=De&&"object"==typeof module&&module&&!module.nodeType&&module,Le=Ne&&Ne.exports===De?Lt.Buffer:void 0,Ye=(Le?Le.isBuffer:void 0)||function(){return!1},$e=/^(?:0|[1-9]\d*)$/;function Ue(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&$e.test(t))&&t>-1&&t%1==0&&t<e}function We(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var qe={};function Ge(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 Be="object"==typeof exports&&exports&&!exports.nodeType&&exports,He=Be&&"object"==typeof module&&module&&!module.nodeType&&module,Xe=He&&He.exports===Be&&Dt.process,Ve=function(){try{var t=He&&He.require&&He.require("util").types;return t||Xe&&Xe.binding&&Xe.binding("util")}catch(t){}}(),Ze=Ve&&Ve.isTypedArray,Qe=Ze?Ge(Ze):function(t){return Te(t)&&We(t.length)&&!!qe[Ht(t)]},Je=Object.prototype.hasOwnProperty;function Ke(t,e){var r=ze(t),n=!r&&Re(t),i=!r&&!n&&Ye(t),o=!r&&!n&&!i&&Qe(t),s=r||n||i||o,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!Je.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ue(u,c))||a.push(u);return a}var tr=Object.prototype;function er(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||tr)}function rr(t,e){return function(r){return t(e(r))}}var nr=rr(Object.keys,Object),ir=Object.prototype.hasOwnProperty;function or(t){if(!er(t))return nr(t);var e=[];for(var r in Object(t))ir.call(t,r)&&"constructor"!=r&&e.push(r);return e}function sr(t){return null!=t&&We(t.length)&&!Vt(t)}function ar(t){return sr(t)?Ke(t):or(t)}function cr(t){return function(t,e,r){var n=e(t);return ze(t)?n:Me(n,r(t))}(t,ar,Oe)}var ur=Object.prototype.hasOwnProperty;var lr=ce(Lt,"DataView"),hr=ce(Lt,"Promise"),fr=ce(Lt,"Set"),dr=ce(Lt,"WeakMap"),pr="[object Map]",gr="[object Promise]",yr="[object Set]",mr="[object WeakMap]",br="[object DataView]",vr=te(lr),xr=te(ue),_r=te(hr),wr=te(fr),kr=te(dr),Sr=Ht;(lr&&Sr(new lr(new ArrayBuffer(1)))!=br||ue&&Sr(new ue)!=pr||hr&&Sr(hr.resolve())!=gr||fr&&Sr(new fr)!=yr||dr&&Sr(new dr)!=mr)&&(Sr=function(t){var e=Ht(t),r="[object Object]"==e?t.constructor:void 0,n=r?te(r):"";if(n)switch(n){case vr:return br;case xr:return pr;case _r:return gr;case wr:return yr;case kr:return mr}return e});var Mr="[object Arguments]",zr="[object Array]",Ar="[object Object]",jr=Object.prototype.hasOwnProperty;function Er(t,e,r,n,i,o){var s=ze(t),a=ze(e),c=s?zr:Sr(t),u=a?zr:Sr(e),l=(c=c==Mr?Ar:c)==Ar,h=(u=u==Mr?Ar:u)==Ar,f=c==u;if(f&&Ye(t)){if(!Ye(e))return!1;s=!0,l=!1}if(f&&!l)return o||(o=new ye),s||Qe(t)?ve(t,e,r,n,i,o):function(t,e,r,n,i,o,s){switch(r){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 xe(t),new xe(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Ct(+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=_e;case"[object Set]":var c=1&n;if(a||(a=we),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var l=ve(a(t),a(e),n,i,o,s);return s.delete(t),l;case"[object Symbol]":if(Se)return Se.call(t)==Se.call(e)}return!1}(t,e,c,r,n,i,o);if(!(1&r)){var d=l&&jr.call(t,"__wrapped__"),p=h&&jr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,y=p?e.value():e;return o||(o=new ye),i(g,y,r,n,o)}}return!!f&&(o||(o=new ye),function(t,e,r,n,i,o){var s=1&r,a=cr(t),c=a.length;if(c!=cr(e).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in e:ur.call(e,l)))return!1}var h=o.get(t),f=o.get(e);if(h&&f)return h==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var g=t[l=a[u]],y=e[l];if(n)var m=s?n(y,g,l,e,t,o):n(g,y,l,t,e,o);if(!(void 0===m?g===y||i(g,y,r,n,o):m)){d=!1;break}p||(p="constructor"==l)}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,r,n,i,o))}function Or(t,e,r,n,i){return t===e||(null==t||null==e||!Te(t)&&!Te(e)?t!=t&&e!=e:Er(t,e,r,n,Or,i))}function Tr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var Pr=function(){try{var t=ce(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&Pr?Pr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Ir=Object.prototype.hasOwnProperty;function Fr(t,e,r){var n=t[e];Ir.call(t,e)&&Ct(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}function Rr(t,e,r,n){var i=!r;r||(r={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),i?Cr(r,a,c):Fr(r,a,c)}return r}function Dr(t){return t}function Nr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Lr=Math.max;function Yr(t){return function(){return t}}var $r=Pr?function(t,e){return Pr(t,"toString",{configurable:!0,enumerable:!1,value:Yr(e),writable:!0})}:Dr,Ur=Date.now;var Wr,qr,Gr,Br=(Wr=$r,qr=0,Gr=0,function(){var t=Ur(),e=16-(t-Gr);if(Gr=t,e>0){if(++qr>=800)return arguments[0]}else qr=0;return Wr.apply(void 0,arguments)});function Hr(t,e){return Br(function(t,e,r){return e=Lr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=Lr(n.length-e,0),s=Array(o);++i<o;)s[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=r(s),Nr(t,this,a)}}(t,e,Dr),t+"")}function Xr(t,e,r){if(!Xt(r))return!1;var n=typeof e;return!!("number"==n?sr(r)&&Ue(e,r.length):"string"==n&&e in r)&&Ct(r[e],t)}var Vr,Zr=(Vr=function(t,e,r,n){Rr(e,ar(e),t,n)},Hr(function(t,e){var r=-1,n=e.length,i=n>1?e[n-1]:void 0,o=n>2?e[2]:void 0;for(i=Vr.length>3&&"function"==typeof i?(n--,i):void 0,o&&Xr(e[0],e[1],o)&&(i=n<3?void 0:i,n=1),t=Object(t);++r<n;){var s=e[r];s&&Vr(t,s,r,i)}return t})),Qr=rr(Object.getPrototypeOf,Object),Jr=Function.prototype,Kr=Object.prototype,tn=Jr.toString,en=Kr.hasOwnProperty,rn=tn.call(Object);function nn(t){if(!Te(t))return!1;var e=Ht(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!Te(t)||"[object Object]"!=Ht(t))return!1;var e=Qr(t);if(null===e)return!0;var r=en.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&tn.call(r)==rn}(t)}var on=Hr(function(t,e){try{return Nr(t,void 0,e)}catch(t){return nn(t)?t:new Error(t)}});function sn(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var an=Object.prototype,cn=an.hasOwnProperty;function un(t,e,r,n){return void 0===t||Ct(t,an[r])&&!cn.call(n,r)?e:t}var ln={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function hn(t){return"\\"+ln[t]}var fn=/<%=([\s\S]+?)%>/g;var dn,pn=(dn={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==dn?void 0:dn[t]});function gn(t){return"symbol"==typeof t||Te(t)&&"[object Symbol]"==Ht(t)}var yn=Yt?Yt.prototype:void 0,mn=yn?yn.toString:void 0;function bn(t){if("string"==typeof t)return t;if(ze(t))return sn(t,bn)+"";if(gn(t))return mn?mn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function vn(t){return null==t?"":bn(t)}var xn=/[&<>"']/g,_n=RegExp(xn.source);var wn={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:fn,variable:"",imports:{_:{escape:function(t){return(t=vn(t))&&_n.test(t)?t.replace(xn,pn):t}}}},kn=/\b__p \+= '';/g,Sn=/\b(__p \+=) '' \+/g,Mn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,zn=/[()=,{}\[\]\/\s]/,An=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,jn=/($^)/,En=/['\n\r\u2028\u2029\\]/g,On=Object.prototype.hasOwnProperty;var Tn=Object.prototype.hasOwnProperty;function Pn(t){if(!Xt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=er(t),r=[];for(var n in t)("constructor"!=n||!e&&Tn.call(t,n))&&r.push(n);return r}function Cn(t,e){return t&&Rr(e,function(t){return sr(t)?Ke(t,!0):Pn(t)}(e),t)}var In="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fn=In&&"object"==typeof module&&module&&!module.nodeType&&module,Rn=Fn&&Fn.exports===In?Lt.Buffer:void 0,Dn=Rn?Rn.allocUnsafe:void 0;var Nn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Me(e,Oe(t)),t=Qr(t);return e}:Ae;var Ln=Object.prototype.hasOwnProperty;var Yn=/\w*$/;var $n=Yt?Yt.prototype:void 0,Un=$n?$n.valueOf:void 0;function Wn(t,e,r){var n,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new xe(a).set(new xe(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,Yn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Un?Object(Un.call(n)):{}}}var qn=Object.create,Gn=function(){function t(){}return function(e){if(!Xt(e))return{};if(qn)return qn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var Bn=Ve&&Ve.isMap,Hn=Bn?Ge(Bn):function(t){return Te(t)&&"[object Map]"==Sr(t)};var Xn=Ve&&Ve.isSet,Vn=Xn?Ge(Xn):function(t){return Te(t)&&"[object Set]"==Sr(t)},Zn="[object Arguments]",Qn="[object Function]",Jn="[object Object]",Kn={};function ti(t,e,r,n,i,o){var s,a=2&e;if(void 0!==s)return s;if(!Xt(t))return t;var c=ze(t);if(c)return s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Ln.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,s);var u=Sr(t),l=u==Qn||"[object GeneratorFunction]"==u;if(Ye(t))return function(t){var e=t.length,r=Dn?Dn(e):new t.constructor(e);return t.copy(r),r}(t);if(u==Jn||u==Zn||l&&!i)return s=l?{}:function(t){return"function"!=typeof t.constructor||er(t)?{}:Gn(Qr(t))}(t),a?function(t,e){return Rr(t,Nn(t),e)}(t,Cn(s,t)):function(t,e){return Rr(t,Oe(t),e)}(t,function(t,e){return t&&Rr(e,ar(e),t)}(s,t));if(!Kn[u])return i?t:{};s=Wn(t,u),o||(o=new ye);var h=o.get(t);if(h)return h;o.set(t,s),Vn(t)?t.forEach(function(n){s.add(ti(n,e,r,n,t,o))}):Hn(t)&&t.forEach(function(n,i){s.set(i,ti(n,e,r,i,t,o))});var f=c?void 0:cr(t);return Tr(f||t,function(n,i){f&&(n=t[i=n]),Fr(s,i,ti(n,e,r,i,t,o))}),s}Kn[Zn]=Kn["[object Array]"]=Kn["[object ArrayBuffer]"]=Kn["[object DataView]"]=Kn["[object Boolean]"]=Kn["[object Date]"]=Kn["[object Float32Array]"]=Kn["[object Float64Array]"]=Kn["[object Int8Array]"]=Kn["[object Int16Array]"]=Kn["[object Int32Array]"]=Kn["[object Map]"]=Kn["[object Number]"]=Kn[Jn]=Kn["[object RegExp]"]=Kn["[object Set]"]=Kn["[object String]"]=Kn["[object Symbol]"]=Kn["[object Uint8Array]"]=Kn["[object Uint8ClampedArray]"]=Kn["[object Uint16Array]"]=Kn["[object Uint32Array]"]=!0,Kn["[object Error]"]=Kn[Qn]=Kn["[object WeakMap]"]=!1;function ei(t){return ti(t,4)}var ri=/\s/;var ni=/^\s+/;function ii(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ri.test(t.charAt(e)););return e}(t)+1).replace(ni,""):t}var oi=/^[-+]0x[0-9a-f]+$/i,si=/^0b[01]+$/i,ai=/^0o[0-7]+$/i,ci=parseInt;var ui=1/0;function li(t){return t?(t=function(t){if("number"==typeof t)return t;if(gn(t))return NaN;if(Xt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Xt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ii(t);var r=si.test(t);return r||ai.test(t)?ci(t.slice(2),r?2:8):oi.test(t)?NaN:+t}(t))===ui||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function hi(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=li(t),r=e%1;return e==e?r?e-r:e:0}(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=void 0),r}}var fi=Object.prototype.hasOwnProperty;function di(t){if(null==t)return!0;if(sr(t)&&(ze(t)||"string"==typeof t||"function"==typeof t.splice||Ye(t)||Qe(t)||Re(t)))return!t.length;var e=Sr(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(er(t))return!or(t).length;for(var r in t)if(fi.call(t,r))return!1;return!0}let pi=0;function gi(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 yi(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 bi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function vi(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function xi(t){if(this.__collection__)return this.__collection__[t]}function _i(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function wi(t){return this.__collection__?this.__collection__.indexOf(t):-1}function ki(){return this.__collection__?this.__collection__.length:0}function Si(){this.__collection__=[]}function Mi(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function zi(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 Ai(t){const e=this.indexOf(t);if(-1==e||0==e)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(r,n)}function ji(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const r=this.__collection__.splice(0,e),n=this.__collection__.splice(1);this.__collection__=r.concat(n,this.__collection__)}class Ei{constructor(){this.__collection__=[],this.insertAt=yi,this.append=mi,this.prepend=bi,this.remove=vi,this.getAt=xi,this.forEach=_i,this.indexOf=wi,this.size=ki,this.clear=Si,this.moveForward=Mi,this.moveBackward=zi,this.moveToHead=Ai,this.moveToTail=ji}}const Oi=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,r=this.cacheHit+this.cacheMiss,n=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:r>0?Math.round(this.cacheHit/r*1e3)/10:0,...n??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}},Ti=/\s+/;function Pi(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(const n in r){const i=r[n];t[e].apply(t,[n,i])}return!1}if(Ti.test(r)){return r.split(Ti).forEach(r=>t[e].apply(t,[r].concat(n))),!1}return!0}const Ci=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],Ii={withEvent(){Ci.forEach(t=>this[t]=Ii[t])},on(t,e,r){if(!Pi(this,"on",t,[e,r])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:r,ctx:r||this}),this},once(t,e,r){if(!Pi(this,"once",t,[e,r])||!e)return this;const n=this,i=function(t){return hi(2,t)}(function(){n.off(t,i,r),e.apply(n,arguments)});return i._callback=e,this.on(t,i,r),this},off(t,e,r){if(!this._listeners||!Pi(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._listeners=void 0,this;let n;n=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<n.length;t++){const i=n[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||r)for(let n=0;n<o.length;n++){const i=o[n];(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Ei),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&&Ri(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 r=this._listeners[e.name],n=this._listeners["(all)"];return r&&Fi(r,arguments),n&&Fi(n,arguments),this},trigger(t){Oi.enabled&&Oi.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&Ri(this._delegators,e),!this._listeners)return this;if(!Pi(this,"trigger",t,e))return this;const r=this._listeners[t],n=this._listeners["(all)"];return r&&Fi(r,e),n&&Fi(n,e),this},stopListening(t,e,r){let n=this._listeningTo;if(!n)return this;const i=!e&&!r;r||"object"!=typeof e||(r=this),t&&(n={},n[t._listenId]=t);for(const t in n){const o=n[t];o.off(e,r,this),(i||di(o._events))&&delete this._listeningTo[t]}return this}};function Fi(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function Ri(t,e){t.forEach(t=>Ii.delegate.apply(t,e))}const Di={listenTo:"on",listenToOnce:"once"};for(const t in Di){const e=Di[t];Ii[t]=function(t,r,n){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++pi}`);return i[t._listenId]=t,n||"object"!=typeof r||(n=this),t[e](r,n,this),this}}const Ni=Ii.on,Li=Ii.off,Yi=Ii.once,$i=Ii.trigger,Ui=Ii.delegate_on,Wi=Ii.delegate_off;const qi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Gi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Bi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Hi(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 Xi,Vi={exports:{}};var Zi=(Xi||(Xi=1,function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new O(n||[]);return i(s,"_invoke",{value:z(t,r,a)}),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f="suspendedStart",d="suspendedYield",p="executing",g="completed",y={};function m(){}function b(){}function v(){}var x={};u(x,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(T([])));w&&w!==r&&n.call(w,s)&&(x=w);var k=v.prototype=m.prototype=Object.create(x);function S(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function M(t,e){function r(i,o,s,a){var c=h(t[i],t,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,s,a)},function(t){r("throw",t,s,a)}):e.resolve(l).then(function(t){u.value=t,s(u)},function(t){return r("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e(function(e,i){r(t,n,e,i)})}return o=o?o.then(i,i):i()}})}function z(t,r,n){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===g){if("throw"===o)throw s;return{value:e,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=A(a,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=h(t,r,n);if("normal"===u.type){if(i=n.done?g:d,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=g,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=h(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var s=o.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function T(t){if(null!=t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};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}},S(M.prototype),u(M.prototype,a,function(){return this}),t.AsyncIterator=M,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new M(l(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},S(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),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=T,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(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.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=n.call(s,"catchLoc"),u=n.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 r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,y):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),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:T(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},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 r=[],n=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?n=r.push(a):(a-=65536,n=r.push(55296+(a>>10),a%1024+56320)),n>=16383&&(i+=t.apply(null,r),r.length=0)}return i+t.apply(null,r)};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,r=e(t,t,t)&&e}catch(t){}return r}(),e=function(t){if(null==this)throw TypeError();var e=String(this),r=e.length,n=t?Number(t):0;if(n!=n&&(n=0),!(n<0||n>=r)){var i,o=e.charCodeAt(n);return o>=55296&&o<=56319&&r>n+1&&(i=e.charCodeAt(n+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,r,n){function i(s,a){if(!r[s]){if(!e[s]){if(!a&&Hi)return Hi(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,r,n)}return r[s].exports}for(var o=Hi,s=0;s<n.length;s++)i(n[s]);return i}return t}()({1:[function(t,e,r){var n=t("./utils"),i=function(){var t=n.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],r=["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,n){var s=function t(n,s,a){var c="";if(n<=19)c=(s?" and ":"")+(a?r[n]:e[n]);else if(n<100){var u=Math.floor(n/10),l=n%10;c=(s?" and ":"")+i[u-2],l>0?c+="-"+t(l,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(n<1e3){var h=Math.floor(n/100),f=n%100;c=(s?", ":"")+e[h]+" Hundred",f>0?c+=t(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(n)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),g=Math.floor(n/p),y=n-g*p;c=(s?", ":"")+t(g,!1,!1)+" "+o[d-1],y>0?c+=t(y,!0,a):a&&(c+="th")}return c};return s(t,!1,n)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),r=[0];return e.forEach(function(t){if(t<100){var e=r.pop();e>=1e3&&(r.push(e),e=0),r.push(e+t)}else r.push(r.pop()*t)}),r.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var r=t.toLowerCase();a[r]=10*(e+2),a[r.substring(0,t.length-1)+"ieth"]=a[r]}),a.hundredth=100,o.forEach(function(t,e){var r=t.toLowerCase(),n=Math.pow(10,3*(e+1));a[r]=n,a[r+"th"]=n});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"]],l={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function h(t){for(var e=0;e<u.length;e++){var r=u[e];if(t>=r[0])return r[1]+h(t-r[0])}return""}function f(t){for(var e=0,r=1,n=t.length-1;n>=0;n--){var i=t[n],o=l[i];o<r?e-=o:(r=o,e+=o)}return e}function d(t,e){for(var r=[],n=e.charCodeAt(0);t>0;)r.unshift(String.fromCharCode((t-1)%26+n)),t=Math.floor((t-1)/26);return r.join("")}function p(t,e){for(var r=e.charCodeAt(0),n=0,i=0;i<t.length;i++)n+=(t.charCodeAt(t.length-i-1)-r+1)*Math.pow(26,i);return n}function g(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var y={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,r){var n,i=e<0;switch(e=Math.abs(e),r.primary){case y.LETTERS:n=d(e,r.case===m.UPPER?"A":"a");break;case y.ROMAN:n=h(e),r.case===m.UPPER&&(n=n.toUpperCase());break;case y.WORDS:n=s(e,r.ordinal),r.case===m.UPPER?n=n.toUpperCase():r.case===m.LOWER&&(n=n.toLowerCase());break;case y.DECIMAL:n=""+e;var o=r.mandatoryDigits-n.length;if(o>0){var a=new Array(o+1).join("0");n=a+n}if(48!==r.zeroCode&&(n=t(n).map(function(t){return String.fromCodePoint(t.codePointAt(0)+r.zeroCode-48)}).join("")),r.regular)for(var c=Math.floor((n.length-1)/r.groupingSeparators.position);c>0;c--){var u=n.length-c*r.groupingSeparators.position;n=n.substr(0,u)+r.groupingSeparators.character+n.substr(u)}else r.groupingSeparators.reverse().forEach(function(t){var e=n.length-t.position;n=n.substr(0,e)+t.character+n.substr(e)});if(r.ordinal){var l={1:"st",2:"nd",3:"rd"}[n[n.length-1]];(!l||n.length>1&&"1"===n[n.length-2])&&(l="th"),n+=l}break;case y.SEQUENCE:throw{code:"D3130",value:r.token}}return i&&(n="-"+n),n}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 r,n={type:"integer",primary:y.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?r=e:(r=e.substring(0,i),"o"===e.substring(i+1)[0]&&(n.ordinal=!0)),r){case"A":n.case=m.UPPER;case"a":n.primary=y.LETTERS;break;case"I":n.case=m.UPPER;case"i":n.primary=y.ROMAN;break;case"W":n.case=m.UPPER,n.primary=y.WORDS;break;case"Ww":n.case=m.TITLE,n.primary=y.WORDS;break;case"w":n.primary=y.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(r).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,r=0;r<v.length;r++){var n=v[r];if(t>=n&&t<=n+9){if(e=!0,s++,u++,null===o)o=n;else if(n!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){n.primary=y.DECIMAL,n.zeroCode=o,n.mandatoryDigits=s,n.optionalDigits=a;var l=function(t){if(0===t.length)return 0;for(var e=t[0].character,r=1;r<t.length;r++)if(t[r].character!==e)return 0;for(var n=t.map(function(t){return t.position}),i=function t(e,r){return 0===r?e:t(r,e%r)},o=n.reduce(i),s=1;s<=n.length;s++)if(-1===n.indexOf(s*o))return 0;return o}(c);l>0?(n.regular=!0,n.groupingSeparators={position:l,character:c[0].character}):(n.regular=!1,n.groupingSeparators=c)}else n.primary=y.SEQUENCE,n.token=r}return n}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=[],r={type:"datetime",parts:e},n=function(r,n){if(n>r){var i=t.substring(r,n);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)){n(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(n(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 l=a.substring(u+1),h=l.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===h?f=l:(f=l.substring(0,h),d=l.substring(h+1));var g={min:p(f),max:p(d)};c.width=g,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var y=s.charAt(s.length-1);-1!=="atco".indexOf(y)?(c.presentation2=y,"o"===y&&(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 n(i,o),r}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],M=864e5,z=function(t){var e=Date.UTC(t.year,t.month),r=new Date(e).getUTCDay();return 0===r&&(r=7),r>4?e+(8-r)*M:e-(r-1)*M},A=function t(e,r){return{year:e,month:r,nextMonth:function(){return 11===r?t(e+1,0):t(e,r+1)},previousMonth:function(){return 0===r?t(e-1,11):t(e,r-1)},nextYear:function(){return t(e+1,r)},previousYear:function(){return t(e-1,r)}}},j=function(t,e){return(e-t)/(7*M)+1},E=function(t,e){var r;switch(e){case"Y":r=t.getUTCFullYear();break;case"M":r=t.getUTCMonth()+1;break;case"D":r=t.getUTCDate();break;case"d":r=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/M+1;break;case"F":0===(r=t.getUTCDay())&&(r=7);break;case"W":var n=A(t.getUTCFullYear(),0),i=z(n),o=Date.UTC(n.year,t.getUTCMonth(),t.getUTCDate()),s=j(i,o);if(s>52)o>=z(n.nextYear())&&(s=1);else if(s<1){var a=z(n.previousYear());s=j(a,o)}r=Math.floor(s);break;case"w":var c=A(t.getUTCFullYear(),t.getUTCMonth()),u=z(c),l=Date.UTC(c.year,c.month,t.getUTCDate()),h=j(u,l);if(h>4)l>=z(c.nextMonth())&&(h=1);else if(h<1){var f=z(c.previousMonth());h=j(f,l)}r=Math.floor(h);break;case"X":var d=A(t.getUTCFullYear(),0),p=z(d),g=z(d.nextYear()),y=t.getTime();r=y<p?d.year-1:y>=g?d.year+1:d.year;break;case"x":var m=A(t.getUTCFullYear(),t.getUTCMonth()),b=z(m),v=m.nextMonth(),x=z(v),_=t.getTime();r=_<b?m.previousMonth().month+1:_>=x?v.month+1:m.month+1;break;case"H":r=t.getUTCHours();break;case"h":r=t.getUTCHours(),0==(r%=12)&&(r=12);break;case"P":r=t.getUTCHours()>=12?"pm":"am";break;case"m":r=t.getUTCMinutes();break;case"s":r=t.getUTCSeconds();break;case"f":r=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":r="ISO"}return r},O=null;function T(t,e,r){var n=0,i=0;if(void 0!==r){var o=parseInt(r);n=Math.floor(o/100),i=o%100}var s,a=function(t,e){var r=E(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(r%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)r=S[r-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};r=k[r]}e.names===m.UPPER?r=r.toUpperCase():e.names===m.LOWER&&(r=r.toLowerCase()),e.width&&r.length>e.width.max&&(r=r.substring(0,e.width.max))}else r=b(r,e.integerFormat);else if("f"===e.component)r=b(r,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*n+i;if(e.integerFormat.regular)r=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)r=b(n,e.integerFormat),0!==i&&(r+=":"+g(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};r=b(o,e.integerFormat)}}o>=0&&(r="+"+r),"z"===e.component&&(r="GMT"+r),0===o&&"t"===e.presentation2&&(r="Z")}return r};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*n+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function P(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var r;Array.isArray(t.integerFormat.groupingSeparators)||(r=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",r&&(e.regex+=r.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var n=0,i=0;return r?(n=Number.parseInt(e.substring(0,e.indexOf(r.character))),i=Number.parseInt(e.substring(e.indexOf(r.character)+1))):e.length-1<=2?n=Number.parseInt(e):(n=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*n+i}}else if(t.integerFormat)t.integerFormat.n=t.n,e=P(t.integerFormat);else{e.regex="[a-zA-Z]+";var n={};if("M"===t.component||"x"===t.component)S.forEach(function(e,r){t.width&&t.width.max?n[e.substring(0,t.width.max)]=r+1:n[e]=r+1});else if("F"===t.component)k.forEach(function(e,r){r>0&&(t.width&&t.width.max?n[e.substring(0,t.width.max)]=r:n[e]=r)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};n={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return n[t]}}return e.component=t.component,e});else{e.type="integer";var r,n=t.case===m.UPPER;switch(r=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case y.LETTERS:e.regex=n?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,n?"A":"a")};break;case y.ROMAN:e.regex=n?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(n?t:t.toUpperCase())};break;case y.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case y.DECIMAL:e.regex="[0-9]".concat(r),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var r=e;return t.ordinal&&(r=e.substring(0,e.length-2)),t.regular?r=r.split(",").join(""):t.groupingSeparators.forEach(function(t){r=r.split(t.character).join("")}),48!==t.zeroCode&&(r=r.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(r)};break;case y.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function C(t,e){if(void 0!==t)return P(x(e)).parse(t)}function I(t,e){var r=P(w(e)),n="^"+r.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(n,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,l=47,h={},f=1;f<i.length;f++){var d=r.parts[f-1];d.parse&&(h[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(h).length)return;var p=0,g=function(t){p<<=1,p+=t?1:0},y=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return g(h[t])});var m=!y(o)&&y(s),b=y(a),v=!b&&y(c);p=0,"PHhmsf".split("").forEach(function(t){return g(h[t])});var x=!y(u)&&y(l),_=(m?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),k=this.environment.timestamp,S=!1,M=!1;if(_.split("").forEach(function(t){if(void 0===h[t])S?(h[t]=-1!=="MDd".indexOf(t)?1:0,M=!0):h[t]=E(k,t);else if(S=!0,M)throw{code:"D3136"}}),h.M>0?h.M-=1:h.M=0,m){var z=Date.UTC(h.Y,0),A=1e3*(h.d-1)*60*60*24,j=new Date(z+A);h.M=j.getUTCMonth(),h.D=j.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(h.H=12===h.h?0:h.h,1===h.P&&(h.H+=12));var O=Date.UTC(h.Y,h.M,h.D,h.H,h.m,h.s,h.f);return(h.Z||h.z)&&(O-=60*(h.Z||h.z)*1e3),O}}var F=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 R(t,e){if(void 0!==t){if(void 0===e){if(!F.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return I.call(this,t,e)}}function D(t,e,r){if(void 0!==t)return T.call(this,t,e,r)}return{formatInteger:g,parseInteger:C,fromMillis:D,toMillis:R}}();e.exports=i},{"./utils":6}],2:[function(t,e,r){(function(r){(function(){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new P(n||[]);return s(o,"_invoke",{value:j(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function v(){}function x(){}function _(){}var w={};h(w,c,function(){return this});var k=Object.getPrototypeOf,S=k&&k(k(C([])));S&&S!==r&&o.call(S,c)&&(w=S);var M=_.prototype=v.prototype=Object.create(w);function z(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&o.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(h).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function j(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function C(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=_,s(M,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:x,configurable:!0}),x.displayName=h(_,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,h(t,l,"GeneratorFunction")),t.prototype=Object.create(M),t},e.awrap=function(t){return{__await:t}},z(A.prototype),h(A.prototype,u,function(){return this}),e.AsyncIterator=A,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new A(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},z(M),h(M,l,"Generator"),h(M,c,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:C(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./utils"),s=function(){var t=i().mark($),e=i().mark(U),s=i().mark(W),a=i().mark(q),c=i().mark(Q),u=i().mark(ft),l=i().mark(dt),h=i().mark(pt),f=i().mark(yt),d=i().mark(St),p=i().mark(jt),g=i().mark(Tt),y=o.isNumeric,m=o.isArrayOfStrings,b=o.isArrayOfNumbers,v=o.createSequence,x=o.isSequence,_=o.isFunction,w=o.isLambda,k=o.isIterable,S=o.getFunctionArity,M=o.isDeepEqual,z=o.stringToArray;function A(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function j(t){return void 0===t?0:t.length}function E(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function O(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function T(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function P(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(_(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&y(e)?Number(e.toPrecision(15)):e&&_(e)?"":e},n)}return r}}function C(t,e,r){if(void 0!==t){var n=z(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var o=e>=0?e+r:i+e+r;return n.slice(e,o).join("")}return n.slice(e).join("")}}function I(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function F(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function R(t){if(void 0!==t)return t.toLowerCase()}function D(t){if(void 0!==t)return t.toUpperCase()}function N(t){if(void 0!==t)return z(t).length}function L(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 Y(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-N(t);if(i>0){var o=new Array(i+1).join(r);r.length>1&&(o=C(o,0,i)),n=e>0?t+o:o+t}else n=t;return n}}function $(e,r){var n;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.apply(this,[r]),!k(n)){t.next=4;break}return t.delegateYield(n,"t0",3);case 3:n=t.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||_(n.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}},t,this)}function U(t,r){var n,o;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof r){e.next=6;break}n=-1!==t.indexOf(r),e.next=9;break;case 6:return e.delegateYield($(r,t),"t0",7);case 7:o=e.t0,n=void 0!==o;case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e)}function W(t,e,r){var n,o,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=v(),!(void 0===r||r>0)){i.next=17;break}return o=0,i.delegateYield($(e,t),"t0",8);case 8:if(void 0===(a=i.t0)){i.next=17;break}case 10:if(void 0===a||!(void 0===r||o<r)){i.next=17;break}return n.push({match:a.match,index:a.start,groups:a.groups}),i.delegateYield($(a.next),"t1",13);case 13:a=i.t1,o++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}},s)}function q(t,e,r,n){var o,s,c,u,l,h,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(o=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(s="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var o=r.charAt(n);if("$"===o)e+="$",n++;else if("0"===o)e+=t.match,n++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+s),10),s>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,c="",u=0,!(void 0===n||n>0)){i.next=44;break}if(l=0,"string"!=typeof e){i.next=18;break}for(h=t.indexOf(e,u);-1!==h&&(void 0===n||l<n);)c+=t.substring(u,h),c+=r,u=h+e.length,l++,h=t.indexOf(e,u);c+=t.substring(u),i.next=42;break;case 18:return i.delegateYield($(e,t),"t0",19);case 19:if(void 0===(f=i.t0)){i.next=41;break}case 21:if(void 0===f||!(void 0===n||l<n)){i.next=38;break}if(c+=t.substring(u,f.start),d=s.apply(o,[f]),!k(d)){i.next=27;break}return i.delegateYield(d,"t1",26);case 26:d=i.t1;case 27:if("string"!=typeof d){i.next=31;break}c+=d,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:d};case 32:return u=f.start+f.match.length,l++,i.delegateYield($(f.next),"t2",35);case 35:f=i.t2,i.next=21;break;case 38:c+=t.substring(u),i.next=42;break;case 41:c=t;case 42:i.next=45;break;case 44:c=t;case 45:return i.abrupt("return",c);case 46:case"end":return i.stop()}},a,this)}function G(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new r.Buffer.from(t,"binary").toString("base64")};return e(t)}}function B(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new r.Buffer.from(t,"base64").toString("binary")};return e(t)}}function H(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 X(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 V(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 Z(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 Q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return o=0,i.delegateYield($(e,t),"t0",12);case 12:if(void 0===(s=i.t0)){i.next=26;break}a=0;case 15:if(void 0===s||!(void 0===r||o<r)){i.next=23;break}return n.push(t.substring(a,s.start)),a=s.end,i.delegateYield($(s.next),"t1",19);case 19:s=i.t1,o++,i.next=15;break;case 23:(void 0===r||o<r)&&n.push(t.substring(a)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}},c)}function J(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function K(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach(function(t){n[t]=r[t]});for(var i=[],o=n["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),c=e.split(n["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,r,i,o,s=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),c=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==a.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),u=t.substring(s.length,t.length-c.length),l=t.indexOf(n["exponent-separator"],s.length);-1===l||l>t.length-c.length?(e=u,r=void 0):(e=u.substring(0,l),r=u.substring(l+1));var h=e.indexOf(n["decimal-separator"]);return-1===h?(i=e,o=c):(i=e.substring(0,h),o=e.substring(h+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:o,subpicture:t}},l=function(t){var e,r,o=t.subpicture,s=o.indexOf(n["decimal-separator"]);s!==o.lastIndexOf(n["decimal-separator"])&&(e="D3081"),o.indexOf(n.percent)!==o.lastIndexOf(n.percent)&&(e="D3082"),o.indexOf(n["per-mille"])!==o.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==o.indexOf(n.percent)&&-1!==o.indexOf(n["per-mille"])&&(e="D3084");var c=!1;for(r=0;r<t.mantissaPart.length;r++){var u=t.mantissaPart.charAt(r);if(-1!==i.indexOf(u)||u===n.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)!==n["grouping-separator"]&&o.charAt(s+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(n.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(l).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var h="string"==typeof t.exponentPart;if(h&&t.exponentPart.length>0&&(-1!==o.indexOf(n.percent)||-1!==o.indexOf(n["per-mille"]))&&(e="D3092"),h&&(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}},h=function(t){var e=function(e,r){for(var o=[],s=e.indexOf(n["grouping-separator"]);-1!==s;){var a=(r?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length;o.push(a),s=t.integerPart.indexOf(n["grouping-separator"],s+1)}return o},r=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r}(r),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),l=u.filter(function(t){return-1!==i.indexOf(t)}).length,h=u.filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===h&&(f?(l=1,h=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(n.digit)&&(a=1),0===a&&0===l&&(l=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:r,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:l,maximumFactionalPartSize:h,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},f=c.map(u);f.forEach(l);var d,p,g,y,m=f.map(h),b=n["minus-sign"],v=n["zero-digit"],x=n["decimal-separator"],_=n["grouping-separator"];if(1===m.length&&(m.push(JSON.parse(JSON.stringify(m[0]))),m[1].prefix=b+m[1].prefix),p=-1!==(d=t>=0?m[0]:m[1]).picture.indexOf(n.percent)?100*t:-1!==d.picture.indexOf(n["per-mille"])?1e3*t:t,0===d.minimumExponentSize)g=p;else{var w=Math.pow(10,d.scalingFactor),k=Math.pow(10,d.scalingFactor-1);for(g=p,y=0;g<k;)g*=10,y-=1;for(;g>w;)g/=10,y+=1}var S=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==v&&(r=r.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),r},M=S(ot(g,d.maximumFactionalPartSize),d.maximumFactionalPartSize),z=M.indexOf(".");for(-1===z?M+=x:M=M.replace(".",x);M.charAt(0)===v;)M=M.substring(1);for(;M.charAt(M.length-1)===v;)M=M.substring(0,M.length-1);z=M.indexOf(x);var A=d.minimumIntegerPartSize-z,j=d.minimumFactionalPartSize-(M.length-z-1);if(M=(A>0?new Array(A+1).join(v):"")+M,M+=j>0?new Array(j+1).join(v):"",z=M.indexOf(x),d.regularGrouping>0)for(var E=Math.floor((z-1)/d.regularGrouping),O=1;O<=E;O++)M=[M.slice(0,z-O*d.regularGrouping),_,M.slice(z-O*d.regularGrouping)].join("");else d.integerPartGroupingPositions.forEach(function(t){M=[M.slice(0,z-t),_,M.slice(z-t)].join(""),z++});if(z=M.indexOf(x),d.fractionalPartGroupingPositions.forEach(function(t){M=[M.slice(0,t+z+1),_,M.slice(t+z+1)].join("")}),z=M.indexOf(x),-1!==d.picture.indexOf(x)&&z!==M.length-1||(M=M.substring(0,M.length-1)),void 0!==y){var T=S(y,0);(A=d.minimumExponentSize-T.length)>0&&(T=new Array(A+1).join(v)+T),M=M+n["exponent-separator"]+(y<0?b:"")+T}return M=d.prefix+M+d.suffix}}function tt(t,e){if(void 0!==t){if(t=ot(t),(e=void 0===e?10:ot(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(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 rt(t){if(void 0!==t)return Math.abs(t)}function nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function ot(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function st(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function ct(){return Math.random()}function ut(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ut(t[0]):t.length>1&&(e=t.filter(function(t){return ut(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):y(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function lt(t){if(void 0!==t)return!ut(t)}function ht(t,e,r,n){var i=[e],o=S(t);return o>=2&&i.push(r),o>=3&&i.push(n),i}function ft(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=v(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return o=ht(e,t[n],n,t),i.delegateYield(e.apply(this,o),"t0",7);case 7:void 0!==(s=i.t0)&&r.push(s);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}},u,this)}function dt(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=v(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return o=t[n],s=ht(e,o,n,t),i.delegateYield(e.apply(this,s),"t0",8);case 8:ut(i.t0)&&r.push(o);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}},l,this)}function pt(t,e){var r,n,o,s,a,c,u;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,o=0;case 4:if(!(o<t.length)){i.next=22;break}if(s=t[o],a=!0,void 0===e){i.next=12;break}return c=ht(e,s,o,t),i.delegateYield(e.apply(this,c),"t0",10);case 10:u=i.t0,a=ut(u);case 12:if(!a){i.next=19;break}if(r){i.next=18;break}n=s,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:o};case 19:o++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}},h,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),n=0;n<r;n++){var i=e.map(function(t){return t[n]});t.push(i)}return t}function yt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((o=S(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],s=1):(n=r,s=0);case 6:if(!(s<t.length)){i.next=15;break}return a=[n,t[s]],o>=3&&a.push(s),o>=4&&a.push(t),i.delegateYield(e.apply(this,a),"t0",11);case 11:n=i.t0,s++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},f,this)}function mt(t){var e=v();if(Array.isArray(t)){var r={};t.forEach(function(t){mt(t).forEach(function(t){r[t]=!0})}),e=mt(r)}else null===t||"object"!==n(t)||w(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var r;if(Array.isArray(t)){r=v();for(var i=0;i<t.length;i++){var o=bt(t[i],e);void 0!==o&&(Array.isArray(o)?o.forEach(function(t){return r.push(t)}):r.push(o))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function vt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=v(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function xt(t){return void 0!==t}function _t(t){var e=v();if(Array.isArray(t))t.forEach(function(t){e=vt(e,_t(t))});else if(null===t||"object"!==n(t)||w(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function wt(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var r in t)e[r]=t[r]}),e}}function kt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function St(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r=v(),a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return n=a.t1.value,o=ht(e,t[n],n,t),a.delegateYield(e.apply(this,o),"t2",6);case 6:void 0!==(s=a.t2)&&r.push(s),a.next=2;break;case 10:return a.abrupt("return",r);case 11:case"end":return a.stop()}},d,this)}function Mt(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function zt(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function At(t){if(void 0!==t)return null===t?"null":y(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":_(t)?"function":"object"}function jt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||m(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark(function t(e,r){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:r=e;case 11:return n=i().mark(function t(e,n){var o,s;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=i().mark(function t(e,n,o){return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,o),i.next=16;break;case 4:if(0!==o.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],o[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(o[0]),i.delegateYield(t(e,n,o.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),o),"t2",16);case 16:case"end":return i.stop()}},t)}),s=[],t.delegateYield(o(s,e,n),"t0",3);case 3:return t.abrupt("return",s);case 4:case"end":return t.stop()}},t)}),o=i().mark(function t(e){var r,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),o=e.slice(0,r),s=e.slice(r),i.delegateYield(t(o),"t0",8);case 8:return o=i.t0,i.delegateYield(t(s),"t1",10);case 10:return s=i.t1,i.delegateYield(n(o,s),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}},t)}),a.delegateYield(o(t),"t0",14);case 14:return s=a.t0,a.abrupt("return",s);case 16:case"end":return a.stop()}},p)}function Et(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Ot(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=x(t)?v():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,o=0;o<e.length;o++)if(M(n,e[o])){i=!0;break}i||e.push(n)}return e}}function Tt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r={},a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return n=a.t1.value,o=t[n],s=ht(e,o,n,t),a.delegateYield(e.apply(this,s),"t2",7);case 7:ut(a.t2)&&(r[n]=o),a.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),a.abrupt("return",r);case 13:case"end":return a.stop()}},g,this)}return{sum:A,count:j,max:E,min:O,average:T,string:P,substring:C,substringBefore:I,substringAfter:F,lowercase:R,uppercase:D,length:N,trim:L,pad:Y,match:W,contains:U,replace:q,split:Q,join:J,formatNumber:K,formatBase:tt,number:et,floor:nt,ceil:it,round:ot,abs:rt,sqrt:st,power:at,random:ct,boolean:ut,not:lt,map:ft,zip:gt,filter:dt,single:pt,foldLeft:yt,sift:Tt,keys:mt,lookup:bt,append:vt,exists:xt,spread:_t,merge:wt,reverse:kt,each:St,error:Mt,assert:zt,type:At,sort:jt,shuffle:Et,distinct:Ot,base64encode:G,base64decode:B,encodeUrlComponent:H,encodeUrl:X,decodeUrlComponent:V,decodeUrl:Z}}();e.exports=s}).call(this)}).call(this,void 0!==Gi?Gi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="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},n(t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new P(n||[]);return s(o,"_invoke",{value:j(t,r,a)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",y="executing",m="completed",b={};function v(){}function x(){}function _(){}var w={};h(w,c,function(){return this});var k=Object.getPrototypeOf,S=k&&k(k(C([])));S&&S!==r&&o.call(S,c)&&(w=S);var M=_.prototype=v.prototype=Object.create(w);function z(t){["next","throw","return"].forEach(function(e){h(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&o.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(h).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,c)})}c(u.arg)}var i;s(this,"_invoke",{value:function(t,n){function o(){return new e(function(e,i){r(t,n,e,i)})}return i=i?i.then(o,o):o()}})}function j(e,r,n){var i=p;return function(o,s){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?m:g,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function O(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function C(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=_,s(M,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:x,configurable:!0}),x.displayName=h(_,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,h(t,l,"GeneratorFunction")),t.prototype=Object.create(M),t},e.awrap=function(t){return{__await:t}},z(A.prototype),h(A.prototype,u,function(){return this}),e.AsyncIterator=A,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new A(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},z(M),h(M,l,"Generator"),h(M,c,function(){return this}),h(M,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=C,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):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),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:C(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}var o=t("./datetime"),s=t("./functions"),a=t("./utils"),c=t("./parser"),u=t("./signature"),l=function(){var t=i().mark(Y),e=i().mark($),r=i().mark(W),l=i().mark(q),h=i().mark(G),f=i().mark(B),d=i().mark(H),p=i().mark(X),g=i().mark(ot),y=i().mark(ct),m=i().mark(ht),b=i().mark(ft),v=i().mark(dt),x=i().mark(yt),_=i().mark(vt),w=i().mark(xt),k=i().mark(_t),S=i().mark(wt),M=i().mark(St),z=i().mark(zt),A=i().mark(Et),j=i().mark(Pt),E=a.isNumeric,O=a.isArrayOfStrings,T=a.isArrayOfNumbers,P=a.createSequence,C=a.isSequence,I=a.isFunction,F=a.isLambda,R=a.isIterable,D=a.getFunctionArity,N=a.isDeepEqual,L=It(null);function Y(e,r,n){var o,s,a,c;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield($(e,r,n),"t1",6);case 6:return o=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(H(e,r,n),"t2",9);case 9:return o=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return o=t.t3,t.abrupt("break",50);case 14:return o=V(e,r),t.abrupt("break",50);case 16:return o=Z(e),t.abrupt("break",50);case 18:return o=Q(e,r),t.abrupt("break",50);case 20:return o=K(e,r),t.abrupt("break",50);case 22:return o=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ft(e,r,n),"t4",25);case 25:return o=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(dt(e,r,n),"t5",28);case 28:return o=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ht(e,r,n),"t6",31);case 31:return o=t.t6,t.abrupt("break",50);case 33:return o=pt(e),t.abrupt("break",50);case 35:return t.delegateYield(xt(e,r,n),"t7",36);case 36:return o=t.t7,t.abrupt("break",50);case 38:return o=gt(e,r,n),t.abrupt("break",50);case 40:return o=kt(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(St(e,r,n),"t8",43);case 43:return o=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(vt(e,r,n),"t9",46);case 46:return o=t.t9,t.abrupt("break",50);case 48:return o=mt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=o&&"function"==typeof o.then||(o=Promise.resolve(o)),!n.async||"function"!=typeof o.then||!e.nextFunction||"function"!=typeof o[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,o;case 56:o=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield(B(e.predicate[a].expr,o,n),"t10",61);case 61:o=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,o,n),"t11",67);case 67:o=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,o),o&&C(o)&&!o.tupleStream&&(e.keepArray&&(o.keepSingleton=!0),0===o.length?o=void 0:1===o.length&&(o=o.keepSingleton?o:o[0])),t.abrupt("return",o);case 72:case"end":return t.stop()}},t)}function $(t,r,n){var o,s,a,c,u,l;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=Array.isArray(r)&&"variable"!==t.steps[0].type?r:P(r),a=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((l=t.steps[u]).tuple&&(a=!0),0!==u||!l.consarray){e.next=12;break}return e.delegateYield(Y(l,o,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(G(l,o,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(W(l,o,n,u===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(a||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===l.focus&&(o=s);case 22:u++,e.next=4;break;case 25:if(a)if(t.tuple)s=c;else for(s=P(),u=0;u<c.length;u++)s.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=P(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}},e)}function U(t,e){var r=It(t);for(var n in e)r.bind(n,e[n]);return r}function W(t,e,n,o){var s,a,c,u,l;return i().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(yt(t,e,n),"t0",2);case 2:if(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(q(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=P(),a=0;case 9:if(!(a<e.length)){r.next=24;break}return r.delegateYield(Y(t,e[a],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}u=0;case 14:if(!(u<t.stages.length)){r.next=20;break}return r.delegateYield(B(t.stages[u].expr,c,n),"t3",16);case 16:c=r.t3;case 17:u++,r.next=14;break;case 20:void 0!==c&&s.push(c);case 21:a++,r.next=9;break;case 24:return l=P(),o&&1===s.length&&Array.isArray(s[0])&&!C(s[0])?l=s[0]:s.forEach(function(t){!Array.isArray(t)||t.cons?l.push(t):t.forEach(function(t){return l.push(t)})}),r.abrupt("return",l);case 27:case"end":return r.stop()}},r)}function q(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:n=e,o=0;case 2:if(!(o<t.length)){i.next=15;break}s=t[o],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(B(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(a=0;a<n.length;a++)n[a][s.value]=a;return i.abrupt("break",12);case 12:o++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}},l)}function G(t,e,r,n){var o,s,a,c,u,l,f,d;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(yt(t,r,n),"t0",3);case 3:o=i.t0,i.next=11;break;case 6:return i.delegateYield(yt(t,e,n),"t1",7);case 7:for(s=i.t1,(o=P()).tupleStream=!0,a=0;a<s.length;a++)(c={"@":s[a]})[t.index]=a,o.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(q(t.stages,o,n),"t2",13);case 13:o=i.t2;case 14:return i.abrupt("return",o);case 15:(o=P()).tupleStream=!0,u=n,void 0===r&&(r=e.map(function(t){return{"@":t}})),l=0;case 20:if(!(l<r.length)){i.next=28;break}return u=U(n,r[l]),i.delegateYield(Y(t,r[l]["@"],u),"t3",23);case 23:if(void 0!==(f=i.t3))for(Array.isArray(f)||(f=[f]),d=0;d<f.length;d++)c={},Object.assign(c,r[l]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[l]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[l]["@"])),o.push(c);case 25:l++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(q(t.stages,o,n),"t4",30);case 30:o=i.t4;case 31:return i.abrupt("return",o);case 32:case"end":return i.stop()}},h)}function B(t,e,r){var n,o,a,c,u,l;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=P(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=P(e)),"number"!==t.type){i.next=10;break}(o=Math.floor(t.value))<0&&(o=e.length+o),void 0!==(a=e[o])&&(Array.isArray(a)?n=a:n.push(a)),i.next=23;break;case 10:o=0;case 11:if(!(o<e.length)){i.next=23;break}return a=e[o],c=a,u=r,e.tupleStream&&(c=a["@"],u=U(r,a)),i.delegateYield(Y(t,c,u),"t0",17);case 17:l=i.t0,E(l)&&(l=[l]),T(l)?l.forEach(function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===o&&n.push(a)}):s.boolean(l)&&n.push(a);case 20:o++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}},f)}function H(t,e,r){var n,o,s,a,c;return i().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=u.t0,s=t.value,a=i().mark(function n(){return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}},n)}),"and"!==s&&"or"!==s){u.next=15;break}return u.prev=5,u.delegateYield(ot(o,a,s),"t1",7);case 7:return u.abrupt("return",u.t1);case 10:throw u.prev=10,u.t2=u.catch(5),u.t2.position=t.position,u.t2.token=s,u.t2;case 15:return u.delegateYield(a(),"t3",16);case 16:c=u.t3,u.prev=17,u.t4=s,u.next="+"===u.t4||"-"===u.t4||"*"===u.t4||"/"===u.t4||"%"===u.t4?21:"="===u.t4||"!="===u.t4?23:"<"===u.t4||"<="===u.t4||">"===u.t4||">="===u.t4?25:"&"===u.t4?27:".."===u.t4?29:"in"===u.t4?31:33;break;case 21:return n=et(o,c,s),u.abrupt("break",33);case 23:return n=rt(o,c,s),u.abrupt("break",33);case 25:return n=nt(o,c,s),u.abrupt("break",33);case 27:return n=at(o,c),u.abrupt("break",33);case 29:return n=lt(o,c),u.abrupt("break",33);case 31:return n=it(o,c),u.abrupt("break",33);case 33:u.next=40;break;case 35:throw u.prev=35,u.t5=u.catch(17),u.t5.position=t.position,u.t5.token=s,u.t5;case 40:return u.abrupt("return",n);case 41:case"end":return u.stop()}},d,null,[[5,10],[17,35]])}function X(t,e,r){var n,o,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(Y(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!E(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],o=0;case 17:if(!(o<t.expressions.length)){i.next=25;break}return a=t.expressions[o],i.delegateYield(Y(a,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===a.value?n.push(c):n=s.append(n,c));case 22:o++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}},p)}function V(t,e,r){return s.lookup(e,t.value)}function Z(t){return t.value}function Q(t,e){var r=P();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach(function(t){var n=e[t];Array.isArray(n)?(n=J(n),r=s.append(r,n)):r.push(n)}),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){J(t,e)}):e.push(t),e}function K(t,e){var r,n=P();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===n(t)&&Object.keys(t).forEach(function(r){tt(t[r],e)})}function et(t,e,r){var n;if(void 0!==t&&!E(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!E(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,o=n(t),s=n(e);if("undefined"===o||"undefined"===s)return!1;switch(r){case"=":i=N(t,e);break;case"!=":i=!N(t,e)}return i}function nt(t,e,r){var i,o=n(t),s=n(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(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function ot(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=st(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=o,!i.t1){i.next=10;break}return i.t2=st,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=o,i.t5){i.next=18;break}return i.t6=st,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},g)}function st(t){var e=s.boolean(t);return void 0!==e&&e}function at(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function ct(t,e,r){var n,o,a,c,u,l,h,f,d,p,g,m,b;return i().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:n={},o={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=P(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){y.next=31;break}u=e[c],l=a?U(r,u):r,h=0;case 10:if(!(h<t.lhs.length)){y.next=28;break}return f=t.lhs[h],y.delegateYield(Y(f[0],a?u["@"]:u,l),"t0",13);case 13:if("string"==typeof(d=y.t0)||void 0===d){y.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:d};case 16:if(void 0===d){y.next=25;break}if(p={data:u,exprIndex:h},!o.hasOwnProperty(d)){y.next=24;break}if(o[d].exprIndex===h){y.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:d};case 21:o[d].data=s.append(o[d].data,u),y.next=25;break;case 24:o[d]=p;case 25:h++,y.next=10;break;case 28:c++,y.next=6;break;case 31:y.t1=i().keys(o);case 32:if((y.t2=y.t1()).done){y.next=43;break}return d=y.t2.value,p=o[d],g=p.data,l=r,a&&(m=ut(p.data),g=m["@"],delete m["@"],l=U(r,m)),y.delegateYield(Y(t.lhs[p.exprIndex][1],g,l),"t3",39);case 39:void 0!==(b=y.t3)&&(n[d]=b),y.next=32;break;case 43:return y.abrupt("return",n);case 44:case"end":return y.stop()}},y)}function ut(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=s.append(e[n],t[r][n]);return e}function lt(t,e){var r;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 r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,o=0;i<=e;i++,o++)r[o]=i;return r.sequence=!0,r}function ht(t,e,r){var n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}},m)}function ft(t,e,r){var n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.condition,e,r),"t0",1);case 1:if(o=i.t0,!s.boolean(o)){i.next=7;break}return i.delegateYield(Y(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(Y(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}},b)}function dt(t,e,r){var n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=It(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(Y(t.expressions[s],e,o),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}},v)}function pt(t){var e=new Dt.RegexEngine(t.value),r=function r(n,i){var o;e.lastIndex=i||0;var s=e.exec(n);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>=n.length)){var i=r(n,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 r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function yt(t,e,r){var o,a,c,u,l;return i().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return a=e,c=!!e.tupleStream,u=i().mark(function e(o,s){var a,u,l,h,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,u=0;case 2:if(!(0===a&&u<t.terms.length)){e.next=35;break}return l=t.terms[u],h=o,f=r,c&&(h=o["@"],f=U(r,o)),e.delegateYield(Y(l.expression,h,f),"t0",8);case 8:return d=e.t0,h=s,f=r,c&&(h=s["@"],f=U(r,s)),e.delegateYield(Y(l.expression,h,f),"t1",13);case 13:if(p=e.t1,g=n(d),y=n(p),"undefined"!==g){e.next=19;break}return a="undefined"===y?0:1,e.abrupt("continue",32);case 19:if("undefined"!==y){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==y&&"number"!==y)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?d:p};case 24:if(g===y){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:d,value2:p};case 26:if(d!==p){e.next=30;break}return e.abrupt("continue",32);case 30:a=d<p?-1:1;case 31:!0===l.descending&&(a=-a);case 32:u++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),l={environment:r,input:e},h.delegateYield(s.sort.apply(l,[a,u]),"t0",5);case 5:return o=h.t0,h.abrupt("return",o);case 7:case"end":return h.stop()}},x)}function mt(t,e,r){return Tt(i().mark(function e(o){var s,a,c,u,l,h,f,d,p,g,y;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==o){e.next=2;break}return e.abrupt("return",void 0);case 2:if(s=r.lookup("clone"),I(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(_t(s,[o],null,r),"t0",6);case 6:return a=e.t0,e.delegateYield(Y(t.pattern,a,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),u=0;case 12:if(!(u<c.length)){e.next=35;break}if(!(l=c[u])||!(l.isPrototypeOf(a)||l instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(Y(t.update,l,r),"t2",17);case 17:if(h=e.t2,"undefined"===(f=n(h))){e.next=23;break}if("object"===f&&null!==h&&!Array.isArray(h)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:h};case 22:for(d in h)l[d]=h[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(Y(t.delete,l,r),"t3",25);case 25:if(void 0===(p=e.t3)){e.next=32;break}if(g=p,Array.isArray(p)||(p=[p]),O(p)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(y=0;y<p.length;y++)"object"===n(l)&&null!==l&&delete l[p[y]];case 32:u++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)}),"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function vt(t,e,r){var n,o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Y(t.lhs,e,r),"t0",1);case 1:if(o=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(xt(t.rhs,e,r,{context:o}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(Y(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,I(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!I(o)){i.next=18;break}return i.delegateYield(Y(bt,null,r),"t3",13);case 13:return a=i.t3,i.delegateYield(_t(a,[o,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(_t(s,[o],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}},_)}function xt(t,e,r,o){var s,a,c,u,l,h;return i().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.delegateYield(Y(t.procedure,e,r),"t0",1);case 1:if(void 0!==(a=f.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){f.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==o&&c.push(o.context),u=i().mark(function n(){var o,s;return i().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(Y(t.arguments[l],e,r),"t0",1);case 1:o=n.t0,I(o)?(s=i().mark(function t(){var e,n,s,a=arguments;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,n=new Array(e),s=0;s<e;s++)n[s]=a[s];return t.delegateYield(_t(o,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),s.arity=D(o),c.push(s)):c.push(o);case 3:case"end":return n.stop()}},n)}),l=0;case 8:if(!(l<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:l++,f.next=8;break;case 13:return h="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(a)&&(a.token=h,a.position=t.position),f.delegateYield(_t(a,c,e,r),"t2",17);case 17:s=f.t2,f.next=25;break;case 20:throw f.prev=20,f.t3=f.catch(14),f.t3.position||(f.t3.position=t.position),f.t3.token||(f.t3.token=h),f.t3;case 25:return f.abrupt("return",s);case 26:case"end":return f.stop()}},w,null,[[14,20]])}function _t(t,e,r,n){var o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(wt(t,e,r,n),"t0",1);case 1:o=i.t0;case 2:if(!F(o)||!0!==o.thunk){i.next=21;break}return i.delegateYield(Y(o.body.procedure,o.input,o.environment),"t1",4);case 4:s=i.t1,"variable"===o.body.procedure.type&&(s.token=o.body.procedure.value),s.position=o.body.procedure.position,a=[],c=0;case 9:if(!(c<o.body.arguments.length)){i.next=17;break}return i.t2=a,i.delegateYield(Y(o.body.arguments[c],o.input,o.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(wt(s,a,r,n),"t5",18);case 18:o=i.t5,i.next=2;break;case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},k)}function wt(t,e,r,n){var o,s,a;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=Mt(t.signature,e,r)),!F(t)){i.next=8;break}return i.delegateYield(zt(t,s),"t0",5);case 5:o=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(a={environment:n,input:r},o=t.implementation.apply(a,s),!R(o)){i.next=14;break}return i.delegateYield(o,"t1",13);case 13:o=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(o=t.apply(r,s),!R(o)){i.next=21;break}return i.delegateYield(o,"t2",20);case 20:o=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",o);case 31:case"end":return i.stop()}},S,null,[[0,26]])}function kt(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark(function t(r,o){return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_t(n,o,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),n}function St(t,e,r){var n,o,s,a,c;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(a=t.arguments[s]).type||"?"!==a.value){i.next=8;break}o.push(a),i.next=12;break;case 8:return i.t0=o,i.delegateYield(Y(a,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(Y(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!F(c)){i.next=23;break}n=At(c,o),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=jt(c.implementation,o),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=jt(c,o),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}},M)}function Mt(t,e,r){return void 0===t?e:t.validate(e,r)}function zt(t,e){var r,n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=It(t.environment),t.arguments.forEach(function(t,r){n.bind(t.value,e[r])}),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Et(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(Y(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}},z)}function At(t,e){var r=It(t.environment),n=[];return t.arguments.forEach(function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?n.push(t):r.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function jt(t,e){var r=Ot(t),n="function("+(r=r.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=c(n);return i.body=t,At(i,e)}function Et(t,e){var r,n,o,s;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map(function(t){return e.lookup(t.trim())}),o={environment:e},s=t.apply(o,n),!R(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}},A)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Tt(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function Pt(t,e){var r,n,o;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!C(r)&&((r=P(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Rt(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(Y(n,r,this.environment),"t1",14);case 14:o=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Rt(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",o);case 22:case"end":return i.stop()}},j,this,[[4,8],[12,17]])}function Ct(t){if(void 0!==t)return JSON.parse(s.string(t))}function It(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}L.bind("sum",Tt(s.sum,"<a<n>:n>")),L.bind("count",Tt(s.count,"<a:n>")),L.bind("max",Tt(s.max,"<a<n>:n>")),L.bind("min",Tt(s.min,"<a<n>:n>")),L.bind("average",Tt(s.average,"<a<n>:n>")),L.bind("string",Tt(s.string,"<x-b?:s>")),L.bind("substring",Tt(s.substring,"<s-nn?:s>")),L.bind("substringBefore",Tt(s.substringBefore,"<s-s:s>")),L.bind("substringAfter",Tt(s.substringAfter,"<s-s:s>")),L.bind("lowercase",Tt(s.lowercase,"<s-:s>")),L.bind("uppercase",Tt(s.uppercase,"<s-:s>")),L.bind("length",Tt(s.length,"<s-:n>")),L.bind("trim",Tt(s.trim,"<s-:s>")),L.bind("pad",Tt(s.pad,"<s-ns?:s>")),L.bind("match",Tt(s.match,"<s-f<s:o>n?:a<o>>")),L.bind("contains",Tt(s.contains,"<s-(sf):b>")),L.bind("replace",Tt(s.replace,"<s-(sf)(sf)n?:s>")),L.bind("split",Tt(s.split,"<s-(sf)n?:a<s>>")),L.bind("join",Tt(s.join,"<a<s>s?:s>")),L.bind("formatNumber",Tt(s.formatNumber,"<n-so?:s>")),L.bind("formatBase",Tt(s.formatBase,"<n-n?:s>")),L.bind("formatInteger",Tt(o.formatInteger,"<n-s:s>")),L.bind("parseInteger",Tt(o.parseInteger,"<s-s:n>")),L.bind("number",Tt(s.number,"<(nsb)-:n>")),L.bind("floor",Tt(s.floor,"<n-:n>")),L.bind("ceil",Tt(s.ceil,"<n-:n>")),L.bind("round",Tt(s.round,"<n-n?:n>")),L.bind("abs",Tt(s.abs,"<n-:n>")),L.bind("sqrt",Tt(s.sqrt,"<n-:n>")),L.bind("power",Tt(s.power,"<n-n:n>")),L.bind("random",Tt(s.random,"<:n>")),L.bind("boolean",Tt(s.boolean,"<x-:b>")),L.bind("not",Tt(s.not,"<x-:b>")),L.bind("map",Tt(s.map,"<af>")),L.bind("zip",Tt(s.zip,"<a+>")),L.bind("filter",Tt(s.filter,"<af>")),L.bind("single",Tt(s.single,"<af?>")),L.bind("reduce",Tt(s.foldLeft,"<afj?:j>")),L.bind("sift",Tt(s.sift,"<o-f?:o>")),L.bind("keys",Tt(s.keys,"<x-:a<s>>")),L.bind("lookup",Tt(s.lookup,"<x-s:x>")),L.bind("append",Tt(s.append,"<xx:a>")),L.bind("exists",Tt(s.exists,"<x:b>")),L.bind("spread",Tt(s.spread,"<x-:a<o>>")),L.bind("merge",Tt(s.merge,"<a<o>:o>")),L.bind("reverse",Tt(s.reverse,"<a:a>")),L.bind("each",Tt(s.each,"<o-f:a>")),L.bind("error",Tt(s.error,"<s?:x>")),L.bind("assert",Tt(s.assert,"<bs?:x>")),L.bind("type",Tt(s.type,"<x:s>")),L.bind("sort",Tt(s.sort,"<af?:a>")),L.bind("shuffle",Tt(s.shuffle,"<a:a>")),L.bind("distinct",Tt(s.distinct,"<x:x>")),L.bind("base64encode",Tt(s.base64encode,"<s-:s>")),L.bind("base64decode",Tt(s.base64decode,"<s-:s>")),L.bind("encodeUrlComponent",Tt(s.encodeUrlComponent,"<s-:s>")),L.bind("encodeUrl",Tt(s.encodeUrl,"<s-:s>")),L.bind("decodeUrlComponent",Tt(s.decodeUrlComponent,"<s-:s>")),L.bind("decodeUrl",Tt(s.decodeUrl,"<s-:s>")),L.bind("eval",Tt(Pt,"<sx?:x>")),L.bind("toMillis",Tt(o.toMillis,"<s-s?:n>")),L.bind("fromMillis",Tt(o.fromMillis,"<n-s?s?:s>")),L.bind("clone",Tt(Ct,"<(oa)-:o>"));var Ft={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}}",D1010:"Attempted to access the Javascript object prototype",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 Rt(t){var e=Ft[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});r=r.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=r}}function Dt(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Rt(t),t}var i=It(L),s=new Date;return i.bind("now",Tt(function(t,e){return o.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Tt(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?Dt.RegexEngine=e.RegexEngine:Dt.RegexEngine=RegExp,{evaluate:function(t,e,o){if(void 0!==n){var a={code:"S0500",position:0};throw Rt(a),a}var c,u,l;if(void 0!==e)for(var h in c=It(i),e)c.bind(h,e[h]);else c=i;if(c.bind("$",t),s=new Date,c.timestamp=s,Array.isArray(t)&&!C(t)&&((t=P(t)).outerWrapper=!0),"function"==typeof o){c.async=!0;var f=function(t){Rt(t),o(t,null)},d=function t(e){(u=l.next(e)).done?o(null,u.value):u.value.then(t).catch(f)};l=Y(r,t,c),(u=l.next()).value.then(d).catch(f)}else try{for(l=Y(r,t,c),u=l.next();!u.done;)u=l.next(u.value);return u.value}catch(a){throw Rt(a),a}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=Tt(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Dt.parser=c,Dt}();e.exports=l},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=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"},r=function(r){var n=0,i=r.length,o=function(t,e){return{type:t,value:e,position:n}},s=function(){for(var t,e,o=n,s=0;n<i;){var a=r.charAt(n);if("/"===a&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(o,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,a=r.charAt(n),o=n;"i"===a||"m"===a;)n++,a=r.charAt(n);return e=r.substring(o,n)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===r.charAt(n-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}};return function a(c){if(n>=i)return null;for(var u=r.charAt(n);n<i&&" \t\n\r\v".indexOf(u)>-1;)n++,u=r.charAt(n);if("/"===u&&"*"===r.charAt(n+1)){var l=n;for(n+=2,u=r.charAt(n);"*"!==u||"/"!==r.charAt(n+1);)if(u=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:l};return n+=2,u=r.charAt(n),a(c)}if(!0!==c&&"/"===u)return n++,o("regex",s());if("."===u&&"."===r.charAt(n+1))return n+=2,o("operator","..");if(":"===u&&"="===r.charAt(n+1))return n+=2,o("operator",":=");if("!"===u&&"="===r.charAt(n+1))return n+=2,o("operator","!=");if(">"===u&&"="===r.charAt(n+1))return n+=2,o("operator",">=");if("<"===u&&"="===r.charAt(n+1))return n+=2,o("operator","<=");if("*"===u&&"*"===r.charAt(n+1))return n+=2,o("operator","**");if("~"===u&&">"===r.charAt(n+1))return n+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return n++,o("operator",u);if('"'===u||"'"===u){var h=u;n++;for(var f="";n<i;){if("\\"===(u=r.charAt(n)))if(n++,u=r.charAt(n),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:n,token:u};var d=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:n};var p=parseInt(d,16);f+=String.fromCharCode(p),n+=4}else{if(u===h)return n++,o("string",f);f+=u}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,y=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==y){var m=parseFloat(y[0]);if(!isNaN(m)&&isFinite(m))return n+=y[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:y[0]}}if("`"===u){n++;var b=r.indexOf("`",n);if(-1!==b)return g=r.substring(n,b),n=b+1,o("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var v,x=n;;)if(v=r.charAt(x),x===i||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===r.charAt(n))return g=r.substring(n+1,x),n=x,o("variable",g);switch(g=r.substring(n,x),n=x,g){case"or":case"in":case"and":return o("operator",g);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return n===i&&""===g?null:o("name",g)}}else x++}},i=function(e,i){var o,s,a={},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},l={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}},h=function(t,e){var r=a[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(l)).id=r.value=t,r.lbp=e,a[t]=r),r},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,r){if(t&&o.id!==t){var n={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(n)}var i=s(r);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,l=i.type;switch(l){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":l="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=l,o.position=i.position,o},p=function(t){var e,r=o;for(d(null,!0),e=r.nud();t<o.lbp;)r=o,d(),e=r.led(e);return e},g=function(t){h(t,0).nud=function(){return this}},y=function(e,r,n){var i=r||t[e],o=h(e,i);return o.led=n||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,r){var n=h(t,e);return n.led=r,n},b=function(t,e){var r=h(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),h(":"),h(";"),h(","),h(")"),h("]"),h("}"),h(".."),y("."),y("+"),y("-"),y("*"),y("/"),y("%"),y("="),y("<"),y(">"),y("!="),y("<="),y(">="),y("&"),y("and"),y("or"),y("in"),g("and"),g("or"),g("in"),b("-"),y("~>"),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}),y("(",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,r=1,i="<";r>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}d(">");try{this.signature=n(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 r={type:"binary",value:"..",position:o.position,lhs:e};d(".."),r.rhs=p(0),e=r}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),y("[",t["["],function(e){if("]"===o.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),y("^",t["^"],function(t){d("(");for(var e=[];;){var r={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(r.descending=!0,d(">")),r.expression=p(0),e.push(r),","!==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 r=p(0);d(":");var n=p(0);if(e.push([r,n]),","!==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),y("{",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)}),y("@",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)}),y("#",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)}),y("?",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(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},_=0,w=0,k=[],S=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(k[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},M=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},z=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var o=n[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=S(s,o)}}},A=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var o=t(e.rhs);"function"===o.type&&"path"===o.procedure.type&&1===o.procedure.steps.length&&"name"===o.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=o.procedure.steps[0].value),"path"===o.type?Array.prototype.push.apply(r.steps,o.steps):(void 0!==o.predicate&&(o.stages=o.predicate,delete o.predicate),r.steps.push(o)),r.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"}),r.steps.filter(function(t){return!0===t.keepArray}).length>0&&(r.keepSingletonArray=!0);var s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var a=r.steps[r.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),z(r);break;case"[":var u=r=t(e.lhs),l="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],l="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[l]&&(u[l]=[]);var h=t(e.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach(function(t){1===t.level?S(u,t):t.level--}),M(u,h)),u[l].push({type:"filter",expr:h,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var f={type:"sort",position:e.position};f.terms=e.rhs.map(function(e){var r=t(e.expression);return M(f,r),{descending:e.descending,expression:r}}),r.steps.push(f),z(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),M(r,r.rhs);break;case"@":if(r=t(e.lhs),u=r,"path"===r.type&&(u=r.steps[r.steps.length-1]),void 0!==u.stages||void 0!==u.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===u.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(u.keepArray=!0),u.focus=e.rhs.value,u.tuple=!0;break;case"#":r=t(e.lhs),u=r,"path"===r.type?u=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==u.predicate&&(u.stages=u.predicate,delete u.predicate)),void 0===u.stages?u.index=e.rhs.value:u.stages.push({type:"index",value:e.rhs.value,position:e.position}),u.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),M(r,r.lhs),M(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map(function(e){var n=t(e);return M(r,n),n}):"{"===e.value?r.lhs=e.lhs.map(function(e){var n=t(e[0]);M(r,n);var i=t(e[1]);return M(r,i),[n,i]}):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:M(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var n=t(e);return M(r,n),n}),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var d=t(e.body);r.body=x(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),M(r,r.condition),r.then=t(e.then),M(r,r.then),void 0!==e.else&&(r.else=t(e.else),M(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var n=t(e);return M(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n});break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var p="S0206";"(end)"===e.id&&(p="S0207");var g={code:p,position:e.position,token:e.value};if(i)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),d();var j=p(0);if("(end)"!==o.id){var E={code:"S0201",position:o.position,token:o.value};f(E)}if("parent"===(j=A(j)).type||void 0!==j.seekingParent)throw{code:"S0217",token:j.type,position:j.position};return c.length>0&&(j.errors=c),j};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="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},n(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 r=1,o=[],s={},a=s;r<e.length;){var c=e.charAt(r);if(":"===c)break;var u=function(){o.push(s),a=s,s={}},l=function(t,e,r,n){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===n){if(0===--i)break}else c===r&&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 h=l(e,r,"(",")"),f=e.substring(r+1,h);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};s.regex="["+f+"m]",s.type="("+f+")",r=h,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:r};var d=l(e,r,"<",">");a.subtype=e.substring(r+1,d),r=d}r++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",g=new RegExp(p),y=function(t){var e;if(i.isFunction(t))e="f";else switch(n(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 r="^",n=0,i=0;i<o.length;i++){r+=o[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(t){n+=y(t)});var i=g.exec(n);if(i){var s=[],a=0;return o.forEach(function(n,o){var c=e[a],u=i[o+1];if(""===u)if(n.context&&n.contextRegex){var l=y(r);if(!n.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:r,index:a+1};s.push(r)}else s.push(c),a++;else u.split("").forEach(function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[a];var i=!0;if(void 0!==n.subtype)if("a"!==r&&u!==n.subtype)i=!1;else if("a"===r&&c.length>0){var o=y(c[0]);i=o===n.subtype.charAt(0)&&0===c.filter(function(t){return y(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[n.subtype]};"a"!==r&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,n)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}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 r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return!t(e)}).length),r}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 l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function h(t){return"object"===s(t)&&null!==t&&l 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 r=0;r<t.length;r++)if(!f(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var o=n[r];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;r.push(o)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:h,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=a},{}]},{},[3])(3)}(Vi)),Vi.exports),Qi=Bi(Zi);const Ji=function(t){return t};function Ki(t){if(!t)return Ji;try{const e=Qi(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return qi(t),Ji}}function to(t){const e=gi(t);return null==e?"":String(e)}function eo(t){return Number(gi(t))}function ro(t){return t}function no(t){return to(t)}function io(t){return eo(t)}function oo(t){if(this.param)return t=to(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function so(t){const{param:e}=this;if(e){for(const r in e){let[n,i]=r.split("~");const o=!!n,s=!!i,a=parseFloat(n),c=parseFloat(i);if(t=eo(t),o&&!s&&t>=a)return e[r];if(!o&&s&&t<a)return e[r];if(t>=a&&t<c)return e[r]}return e.default}}function ao(t){return eo(t)*Math.PI/180}function co(){}const uo=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const lo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],ho=new Array(lo.length).fill(void 0),fo=Object.getPrototypeOf(async function(){}).constructor;function po(t,e){!function(t){for(const e of uo)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const r=function(t){return/\bawait\b/.test(t)}(t),n=new(r?fo:Function)(...e,...lo,t);return function(t,...e){return n.call(t,...e,...ho)}}function go(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?no.bind(t):"number"===i?io.bind(t):ro.bind(e);case"map":return oo.bind(t);case"range":return so.bind(t);case"radian":return ao.bind(t);case"eval":return function(t){try{const e=po(t,["value","targets","scene"]);return function(t,r){try{const n=e(this,t,r,globalThis.scene);return n&&"function"==typeof n.then?n.catch(t=>{qi(t)}):n}catch(t){return void qi(t)}}}catch(t){return qi(t),co}}(n).bind(e);default:return ro.bind(e)}}class yo{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:r,rule:n,param:i,accessor:o}=t;this._model=t,this.evaluator=go(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=Ki(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=Ki(t),this.partAccessor=Ki(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 mo(t,e,r,n){const i=e.split(".");if(1===i.length)return void(t[e]=n?{...t[e],...r}:r);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]=n?{...c[u],...r}:r,t[o]=a}function bo(t,e,r,n){t.forEach(t=>mo(t,e,r,n))}function vo(t,e,r,n){t&&"function"==typeof t.then?t.then(t=>{void 0!==r&&void 0!==n&&r._dataGeneration!==n||e(t)}).catch(t=>qi(t)):e(t)}function xo(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,r=this;this.mappings&&this.mappings.forEach(t=>{try{let n,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:l=!1,partial:h=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),n=this.root.findById(i)?.data||{}):n=this.data;const f=a(n);if("(root)"==o||"(key)"==o){if(null==f)return;const n=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();n.length>0&&n.forEach(n=>{vo(t.evaluator(f[n.get("id")],[n]),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||mo(n,s,t,h)},r,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(n=>{const i=c(n);if(i){const o=this.root.findOrCreate(i);o&&vo(t.evaluator(u(n),o),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||bo(o,s,t,h)},r,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const n=c(f);if(n){const i=this.root.findOrCreate(n);i&&vo(t.evaluator(u(f),i),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||bo(i,s,t,h)},r,e)}}}}else{const n=this.root.findAll(o,this);n.length>0&&vo(t.evaluator(f,n),t=>{!s||"(action)"===s||l&&!t&&0!==t&&!1!==t||bo(n,s,t,h)},r,e)}}catch(e){qi(e,this,t)}})}function _o(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),xo.call(this,!0)}function wo(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new yo({target:"(self)",rule:"value",...t},this))):(qi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function ko(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function So(t,e){this.disposeMappings(),xo.call(this)}function Mo(t,e,r,n,i,o){e.complete?t.drawImage(e,r,n,i,o):e.addEventListener("load",()=>{this.invalidate()})}function zo(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Ao="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),jo={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Eo=()=>{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(),r=t.fontFamily||"sans-serif";jo.FONT_FAMILY=e||r};let Oo;function To(t,e,r,n,i){const{alpha:o=1}=n,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(r.x,r.y);let n,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,r="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(o-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(o-4)/2*Math.sin(r))}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:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":n=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{n.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),n.addColorStop(t.position,"#fff")}}),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.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 r=i._pattern_image;if(!r||!r.width||!r.height)return;let n=0,o=0,a=0,c=0,u=e.left,l=e.top;if(!s.fitPattern){n=s.offsetX,o=s.offsetY;const t=s.width?s.width:r.width,i=s.height?s.height:r.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+=n+a,l+=o+c}t.translate(u,l),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((r.width-e.width)*(r.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(r,"no-repeat"):t.fillStyle=t.createPattern(r,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-l)}}function Po(t,e){const r=this.fillStyle;if(!r||"pattern"!=r.type||!r.image)return void t(this);if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);const o=Oo(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.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(r.image)}catch(t){e(t)}}function Co(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{qi(t)})}function Io(t,e){const r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)}function Fo(t,e,r){let{strokeStyle:n,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(n&&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=n,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function Ro(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,r=[];let n;for(;null!==(n=e.exec(t));)n[1]?r.push({text:n[2],bold:!0,italic:!1}):n[3]?r.push({text:n[4],bold:!1,italic:!0}):n[5]&&r.push({text:n[5],bold:!1,italic:!1});return r}function Do(t,e,r,n=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)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function No(t,e,r,n,i,o=0){const s=String(e).split("\n");return n?[].concat(...s.map(e=>function(t,e,r,n=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=r-s,u=t.measureText(a).width+(a.length-1)*n;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const r=Do(t,{...e,text:a},c,n);o.push(r),i.push(o),o=[],s=0,a=a.substring(r.text.length)}}}),o.length>0&&i.push(o),i}(t,i?Ro(e):[{text:e,bold:!1,italic:!1}],r,o))):s.map(t=>i?Ro(t):[{text:t,bold:!1,italic:!1}])}function Lo(t,e,r,n,i,o,s=0){if(!n)return[];t.save(),t.font=r;const a=No(t,n,e,!!i,o,s);return t.restore(),a}function Yo(t){const{fontFamily:e=jo.FONT_FAMILY,bold:r=jo.BOLD,italic:n=jo.ITALIC,fontSize:i=jo.FONT_SIZE}=t,o=[];return r&&o.push("bold"),n&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function $o(t,e){const r=t.bold||e.bold,n=t.italic||e.italic;return Yo({...t,bold:r,italic:n})}function Uo(t,e,r,n){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=jo.FONT_COLOR,textAlign:c=jo.TEXT_ALIGN,textBaseline:u=jo.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:g=0}=n;i=void 0!==i?i:1,h||=jo.FONT_SIZE,f||=1.2*h,t.save();const{left:y,top:m,width:b,height:v}=e;if(o&&s&&(t.translate(y+b/2,m+v/2),t.rotate(-o),t.translate(-(y+b/2),-(m+v/2))),t.beginPath(),t.font=Yo(n),!d&&p){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of r){const r=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=n-("ellipsis"===t?o:0))){const i=Wo(e,c,n-a-("ellipsis"===t?o:0),t);return r.push(i),s.push(r),s}r.push(c),a+=i}s.push(r),a=0}return s}(p,t,r,b);r=e}const x=r.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,r.forEach((e,i)=>{const o=_+i*f,s=function(t,e,r,n=0){return e.reduce((e,i)=>(t.font=$o(r,i),e+t.measureText(i.text).width+n*(i.text.length-1)),0)}(t,e,n,g);let u=y;switch(c){case"left":case"justify":u=y;break;case"right":u=y+b-s;break;case"center":u=y+(b-s)/2}if(l&&(t.fillStyle=l,function(t,e,r,n,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,r),t.lineTo(e+n-o.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+o.tr),t.lineTo(e+n,r+i-o.br),t.quadraticCurveTo(e+n,r+i,e+n-o.br,r+i),t.lineTo(e+o.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-o.bl),t.lineTo(e,r+o.tl),t.quadraticCurveTo(e,r,e+o.tl,r),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-h/2-4,s+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<r.length-1&&e.length>1){const r=b-s,i=e.length-1,a=r/i;e.forEach((e,r)=>{t.font=$o(n,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(r<i?a:0)})}else e.forEach(e=>{t.font=$o(n,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+g})})}),t.restore()}function Wo(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){const o=i+e.text[n];if(t.measureText(o).width>r)break;i=o}return{...e,text:i+("ellipsis"===n?"…":"")}}function qo(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Eo()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Eo),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Eo()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Eo(),Oo="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const r=document.createElement("canvas");return r.width=t,r.height=e,r};const Go=[];function Bo(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-r.x)/i.x,e=(e-r.y)/i.y):(t-=r.x,e-=r.y),0!==n){const r=Math.cos(-n),i=Math.sin(-n),o=t*i+e*r;t=t*r-e*i,e=o}return{x:t+r.x,y:e+r.y}}function Ho(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){if(t-=r.x,e-=r.y,0!==n){const r=Math.cos(n),i=Math.sin(n),o=t*i+e*r;t=t*r-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+r.x,y:e*i.y+r.y}:{x:t+r.x,y:e+r.y}}function Xo(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=Bo(t,e,r,n,i);return r&&(o.x-=r.x,o.y-=r.y),o}return Bo(t,e,r=r||this.rotatePoint,n,i)}function Vo(t,e,r){if(!this.parent)return{x:t,y:e};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate,o=Ho(t,e,void 0,n+(this._delta?.theta??0),i);return r&&(o.x+=r.x,o.y+=r.y),o}r=r||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 Ho(t,e,r,n,i);return Ho(t+s,e+a,{x:r.x+s,y:r.y+a},n+o,{x:i.x*c,y:i.y*u})}function Zo(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Ho(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)}function Qo(t,e,r){r=r||this.rootModel,Go.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Go.push(t);let n=this.transcoordS2P(t,e);for(let t=0;t<Go.length;t++){const e=Go[t],r=e.bounds;n.x+=r.left,n.y+=r.top,n=e.transcoordS2P(n.x,n.y)}return n}function Jo(t,e,r){r=r||this.rootModel,Go.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Go.push(t);let n={x:t,y:e};for(let t=Go.length-1;t>=0;t--){const e=Go[t];n=e.transcoordP2S(n.x,n.y);const r=e.bounds;n.x-=r.left,n.y-=r.top}return n}function Ko(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)}function ts(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)}function es(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=r.model,s=Bo(t,e,n,o,i);return n&&(s.x-=n.x,s.y-=n.y),r===this?s:this.transcoordT2S(s.x,s.y,r)}function rs(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;if(n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e},!this.scalable)return n;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=r.model;return n=Ho(n.x,n.y,void 0,o+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}function ns(t){const e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),o)switch(o){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){const r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,r)}else n.background="transparent"}const is={x:1,y:1},os={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function ss(t,e){let r=this.bounds,n=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const n=t.call(e,r);n&&(r=n)}const{left:s,top:a,width:c,height:u}=r;let l=[{x:s,y:a},{x:s+c,y:a+u}];l=l.map(t=>Ho(t.x,t.y,n,i,o));let h=l[0],f=l[1];n={x:(h.x+f.x)/2,y:(h.y+f.y)/2},l=l.map(t=>Bo(t.x,t.y,n,i,o)),h=l[0],f=l[1],this.bounds={left:h.x,top:h.y,width:f.x-h.x,height:f.y-h.y}}function as(t,e,r){let n=this.path,i=this.rotatePoint;t&&(n=t.call(r,n));let o=n.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(r,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,l;n=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=n[0].x,u=l=n[0].y;for(let t=1;t<n.length;t++){const e=n[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>l&&(l=e.y)}i={x:(a+c)/2,y:(u+l)/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}})}function cs(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const us=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 I.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const r=e?.component,n=r?.root?.app;if(n&&"boolean"==typeof n.isViewMode&&!n.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,Oi.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const r=I.tick(e),n=I.now;if(this._ticking=!0,Oi.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(r,n)}finally{const n=performance.now()-e;t.tickCount++,t.totalDurationMs+=n,t.lastDt=r,t.lastDurationMs=n}}else for(const t of this._subs)t._removed||t.handler(r,n);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;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),r=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(r),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,r){const n={id:this._externalNextId++,description:t,source:e,metadata:r,registeredAt:this._realTime};return this._externals.add(n),{update:t=>{n.metadata={...n.metadata??{},...t}},unregister:()=>{this._externals.delete(n)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let r;const n=e.componentRef?.deref();let i;if(n&&(r=cs(n)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],r=[];for(const t of e)null!=t&&r.push(cs(t));r.length>0&&(i=r)}}catch{}t.push({id:e.id,description:e.description,componentInfo:r,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(I.now),isRunning:this.isRunning,speed:I.speed,paused:I.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}},ls=new Map;let hs=null;function fs(){hs&&(hs(),hs=null)}function ds(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ps=new class{add(t){var e;ds(t)&&!ls.has(t)&&(ls.set(t,0),e=t?.root,hs||(hs=us.subscribe(t=>{if(0===t)return;const e=[];for(const[r,n]of ls){if(!ds(r)){e.push(r);continue}const i=n+t;i>=r.retention?e.push(r):ls.set(r,i)}for(const t of e){ls.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){qi("RetentionManager removeSelf failed:",t)}}0===ls.size&&fs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ls.keys()),metadata:{get count(){return ls.size},get preview(){return Array.from(ls.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){ls.delete(t)&&0===ls.size&&fs()}touch(t){t&&ls.has(t)&&ls.set(t,0)}dispose(){fs(),ls.clear()}get length(){return ls.size}};const gs=function(t){return t};function ys(t){const e=t.indexOf("||");let r="",n="";-1!=e&&(r=t,n=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:n,match:t,originText:r||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:gs}}function ms(t){if(!t)return;const e=String(t),r=(e.match(/#{(\S*)}/)||[]).map(t=>ys(t))[0];if(r)return r.accessor(this.getState(r.target));const n=(e.match(/\${[^}]*}/)||[]).map(t=>ys(t))[0];if(n){const t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}function bs(t,e){if(!t)return;const r=String(t),n=e||gi,i=(r.match(/#{(\S*)}/gi)||[]).map(t=>ys(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>ys(t));if(0==i.length&&0==o.length)return r;let s=r;return i.forEach(t=>{const e=n(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),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)}),s}function vs(t,e,r){if(!t)return;const n=r||gi,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>ys(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>ys(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(r=>{const i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)}),s.forEach(r=>{const i=e.root.findById(r.target),o=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===o?r.defaultValue||"":o)}),t}:void 0}class xs{constructor(){}static registerDecorator(t,e){xs.constructors.set(t,e)}static create(t,e,r={},n){const i=xs.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(n,e,r)}}function _s(t,e){const r=e.x-t.x,n=e.y-t.y,i=Math.sqrt(r*r+n*n);if(!ht(t))return i;const o=ft(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 ws(t,e){const r=t.path.slice();if(!r||!r.length)return void qi("path should not be empty");let n=1;const i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.toScene(r[0].x,r[0].y);if(e>=1)return t.toScene(r[r.length-1].x,r[r.length-1].y);for(;r[n];)i.push(_s(r[n-1],r[n])),n++;const o=i.reduce(function(t,e){return t+e},0);n=0;let s=0;do{s+=i[n++]}while(s/o<e);s-=i[--n];e=(e-s/o)*(o/i[n]);const a=r[n%r.length],c=r[(n+1)%r.length],{x:u,y:l}=function(t,e,r){if(ht(t)){const n=ft(t,e,t.bulge);if(n){let t=n.endAngle-n.startAngle;n.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=n.startAngle+r*t;return{x:n.cx+n.radius*Math.cos(e),y:n.cy+n.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*r),y:t.y+Math.round((e.y-t.y)*r)}}(a,c,e);return t.toScene(u,l)}function ks(t,e){return!1}function Ss({x:t,y:e},...r){const n=this.path,i=t,o=e;this.path=n.map(t=>({...t,x:t.x+i,y:t.y+o}))}function Ms(t){const e=t??this.center.x,{rotation:r}=this.state,n=this.fillStyle;if(this.set("rotation",2*Math.PI-r),n&&"gradient"===n.type&&"linear"===n.gradientType){const t=ei(n);t.rotation=(Math.PI-parseFloat(n.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 zs(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 As(t,e,r){if(r){const e=this.bounds,r=e.height/e.width;let n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-n):0!=o?o=-n:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+n,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 Es(t){return ws(this,t||0)}function Os(){const t=this.path;let e,r,n,i;e=r=t[0].x,n=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>r&&(r=s.x),s.y<n?n=s.y:s.y>i&&(i=s.y)}return{left:e,top:n,width:r-e,height:i-n}}function Ts(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 r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))}function Ps(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Cs(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 r=t.x-e.x,n=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+r,y:t.y+n}))}function Is(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Fs(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}function Rs(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}function Ds(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}function Ns(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}function Ls(t){const{width:e,height:r,depth:n}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:r},this.setState("depth",n)}function Ys(){return qi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function $s(t){qi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Us(){return this.path}function Ws(){return this.center}function qs(){return this.nature.mutable}function Gs(){return this.nature.resizable&&!this.stuck}function Bs(){return this.nature.rotatable&&!this.stuck}xs.constructors=new Map;const Hs={x:1,y:1};function Xs(t,e,r){const{offsetX:n,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=r.rootModel.get("scale")??Hs;t.shadowOffsetX=n*a.x*Ao,t.shadowOffsetY=i*a.y*Ao,t.shadowBlur=o*a.x*Ao,t.shadowColor=s}function Vs(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}function Zs(t){const e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:o}=this.state,s=(r&&r.x||1)*this._delta.sx,a=(r&&r.y||1)*this._delta.sy,c=(n||0)+this._delta.theta,{tx:u=0,ty:l=0}=this._delta,h=(o||1)-this._delta.fade;(u||l)&&t.translate(u,l),(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)),h&&(t.globalAlpha=h),i&&Xs(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}function Qs(t){}function Js(t){this.drawText(t)}function Ks(t,e){t(this)}function ta(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{qi(t)})}function ea(t){!this.textHidden&&this.text&&this.hasTextProperty&&Uo(t,this.textBounds,this.textLines(t),this.state)}function ra(t,e){Fo(t,e?{...this.state,...e}:this.state)}function na(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(To(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function ia(){return this.get("strokeStyle")}function oa(t){this.set("strokeStyle",t)}function sa(){return this.getState("fillStyle")}function aa(t){this.setState("fillStyle",t)}function ca(){return this.get("fontColor")}function ua(t){this.set("fontColor",String(gi(t)))}function la(){return this.getState("rotation")}function ha(t){this.setState("rotation",Number(gi(t)))}function fa(){return this.app.isEditMode?["decotag","data-spread"]:[]}function da(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function pa(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function ga(t){this.setState("hidden",t)}function ya(){return this.state.tag}function ma(t){this.setState("tag",t)}function ba(){}function va(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function xa(){const t=this.getState("text");return null==t?"":String(t)}function _a(t){const{textWrap:e,supportMarkdown:r}=this.state;return Lo(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}function wa(){return Yo(this.model)}function ka(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Sa(){return this._text_substitutor||(this._text_substitutor=vs(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Ma(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let r,n,i,o,s,a,c,u,l,h,f,d=t.length,p=t.search(/[0-9\-\+#]/),g=p>0?t.substring(0,p):"",y=t.split("").reverse().join(""),m=y.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(r=(e="-"===(t=t.substring(p,x)).charAt(0)?-e:+e)<0?e=-e:0,n=t.match(/[^\d\-\+#]/g),i=".",o=n&&n[1]&&n[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)),l=t[0].split(o),t[0]=l.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=l[1]&&l[l.length-1].length,c){for(h=e[0],y="",b=h.length%c,d=h.length,x=0;x<d;x++)y+=h.charAt(x),!((x-b+1)%c)&&x<d-c&&(y+=o);e[0]=y}return e[1]=t[1]&&e[1]?"."+e[1]:"",n=e.join(""),"0"!==n&&""!==n||(r=!1),f="+"==t[0].substring(0,1)?r?"-":"+":r?"-":"",g+(f+n)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function za(t){delete this._text_substitutor;const e=gi(t);this.setState("text",null==e?"":String(e))}function Aa(){let{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-r,0),height:Math.max(a-t-n,0)}}function ja(){return 0}function Ea(){return!!this._textHidden}function Oa(t){this._textHidden=!!t,this.invalidate()}function Ta(){return!0}function Pa(t){return t}function Ca(t){return Math.pow(t,2)}function Ia(t){return 1-Math.sin(Math.acos(t))}function Fa(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function Ra(t){for(let e=0,r=1;;e+=r,r/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(r,2)}function Da(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var Na={linear:Pa,quad:Ca,circ:Ia,back:Fa,bounce:Ra,elastic:Da},La=Object.freeze({__proto__:null,back:Fa,bounce:Ra,circ:Ia,default:Na,elastic:Da,linear:Pa,quad:Ca});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:r="linear",options:n,ease:i}=this.config;let o;o="string"==typeof r?Na[r]:r,this.delta="out"===i?function(t,e){return function(r){return 1-t(1-r,e)}}(o,n):"inout"===i?function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(o,n):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:r=!1,interval:n=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>us.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 l=c()-s,h=Math.max((l-e)%(t+n),0)/t,f=n<=0&&a>h;if(a=h,h>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!r||!this._started)return this.stop(i),void(s=0);if(n>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=us.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}}))},n/2)},n/2))}else this.step(this.delta(h)),this.client&&this.client.invalidate?.()};this._unsub=us.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:r,interval:n}})}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 $a={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,r=4*e;let n=t*r;t<1/4?n*=-1:t<3/4?n-=2*e:n=r-n,this.client.delta?.("theta",n)}},heartbeat:class extends Ya{step(t){const{scale:e=1.3}=this.config,r=2*(e-1);let n;n=t<.5?1+r*t:1+(1-t)*r,this.client.delta?.({sx:n,sy:n,sz:n})}},moving:class extends Ya{step(t){const{x:e=0,y:r=0}=this.config;this.client.delta?.({tx:t*e,ty:t*r})}},outline:class extends Ya{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const r=this.client.root.findById(e);if(!r)return;let n={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(n=i);const{tx:o,ty:s}=n,a=r.outline(t),{x:c,y:u}=this.client.center,l=this.client.toScene(c,u);this.client.delta({tx:a.x-l.x+o,ty:a.y-l.y+s})}},fade:class extends Ya{step(t){const{startAlpha:e=1,endAlpha:r=0}=this.config,n=Math.max(Math.min(e,r,1),0),i=2*(Math.min(Math.max(e,r,1),1)-n);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 r=e.center,n=t.center,{x:i,y:o}=e.toScene(r.x,r.y),{x:s,y:a}=t.toScene(n.x,n.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:r="snap"}=this.config;if(super.stop(t),"snap"===r&&e){const t=e.center,r=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=r}}step(t){const e=(this._endX-this._startX)*t,r=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+r}}}};const Ua={gradation:function(t,e,r){const{subType:n,from:i,to:o,colors:s}=r;let a;switch(n){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:Xs};function Wa(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:r,component:n,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:l}=t;let h;h="string"==typeof l?La[l]:l||Pa,"out"===r?h=function(t,e){return function(r){return 1-t(1-r,e)}}(h,c):"inout"===r&&(h=function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(h,c));let f=!1,d=null;return{start:function(){if(f)return this;if(n?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const r=()=>us.simTime;return d=us.subscribe(()=>{if(!f)return;if(n?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=r());const o=(r()-t)/e,a=u?o%1:Math.min(o,1);i(h(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:n,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,r){const n=Ua[r.type];n&&n(t,e,r)}(this,t,e)}const Ga=100;function Ba(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Ga)/Ga}return e}}function Ha(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const r=t[e];null===r?delete t[e]:"number"==typeof r?Number.isFinite(r)?Number.isInteger(r)||(t[e]=Math.round(r*Ga)/Ga):delete t[e]:"object"==typeof r&&Ha(r)}return t}function Xa(...t){return JSON.stringify(this.hierarchy,Ba,...t)}function Va(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Za(t){this.rootModel.closeScene(t)}function Qa(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 Ja(){this.parent&&this.parent.invalidate()}function Ka(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function tc(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function ec(){return this.getState("data")}function rc(t){this.setState("data",t),this.touch()}function nc(t){const e=this.model.event?.tap;if(e){const{x:t,y:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:r}))}}function ic(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function oc(){return Number(this.get("retention"))||0}function sc(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const r=e.type?$a[e.type]:void 0;return r?new r(t,e):null}(this,t.oncreate))}return this._animation}}function ac(){return!!this.animation?.started}function cc(t){this.animation&&(this.animation.started=t)}function uc(){}function lc(t,e,r,n){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function hc(t,e,r,n){return t==e.get("type")}function fc(t,e,r,n,i,o){return t(e,r,n,i)&&o.push(r),r.components&&r.components.forEach(r=>{fc(t,e,r,n,i,o)}),o}function dc(t,e,r,n){switch(t){case"(all)":return!0;case"(parent)":return r&&r.parent===e;case"(child)":case"(children)":return r&&r===e.parent;case"(sibling)":case"(siblings)":return r&&r.parent===e.parent&&r!==e;default:return!1}}function pc(t,e,r){if("(root)"==t)return[e];if("(self)"==t)return r?[r]:[];let n;switch(t.charAt(0)){case"#":const r=e.root.findAllById?.(t.substring(1));return r||[];case".":n=lc;break;case"(":n=dc;break;default:n=hc}return fc(n,t,e,r,e,[])}function gc(t,...e){if(t(this,...e))return this}function yc(t,...e){return"string"==typeof t?pc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function mc(t,e,r){if(!this.capturable||r?.(this))return!1;const n=this.fromParent(t,e);return this.contains(n.x,n.y)?this:void 0}function bc(t){return this.anchors.find(e=>e.name===t)}function vc(t){return!0}function xc(t){return this._parent.getContext(t??this)}function _c(){return this.isRoot()?this:this.parent&&this.parent.root}function wc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function kc(){return this._parent}function Sc(t){this._parent=t}function Mc(){return this.nature.anchors||[]}function zc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Ac(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}function jc(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}function Ec(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Oc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Tc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Pc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Cc={},Ic={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Fc=[],Rc=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"]),Dc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let Nc=0;const Lc={};const Yc=new FinalizationRegistry(t=>{!function(t){Nc--;let e=Lc[t];e||(e=Lc[t]={up:0,down:0}),e.down++}(t)});class $c{static get nature(){return Ic}static register(t,e){if(!e)return Cc[t];Cc[t]=e}static types(){return Object.keys(Cc)}static get residents(){return Lc}static get residentsCount(){return Nc}static registerDecorator(t,e){xs.registerDecorator(t,e)}constructor(t,e){if(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"},r=[];for(const n of Object.keys(t)){const i=e[n];if(!i)continue;const o=t[n];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&&r.push({trigger:i,action:"script",code:t,target:o.target});continue}r.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 r}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=ei(Dc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),ps.add(this),function(t){Nc++;let e=Lc[t];e||(e=Lc[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))}}touch(){this.updatedAt=performance.now(),ps.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=ei(Dc))}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&&ps.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 r=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return r._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&ps.add(r)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&r.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 r=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return r.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=ei(this._model);return this.volatile.forEach(e=>{delete t[e]}),Ha(t)}get volatile(){return Fc}_applyProps(t,e,r){const n={},i={};let o=!1;const s=ei(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=r.getBeforeVal(e),u=s[e];!r.sensitive&&function(t,e){return Or(t,e)}(c,u)||(i[e]=c,n[e]=u,t[e]=u,r.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(n).some(t=>!Rc.has(t))&&this.clearCache(),n.hasOwnProperty("text")&&delete this._text_substitutor,r.beforeFillStyle&&r.beforeFillStyle(n,i),n.hasOwnProperty("fillStyle")&&this.onchangeFill(n,i),r.afterFillStyle&&r.afterFillStyle(n,i),n.hasOwnProperty("data")&&this.onchangeData(n,i),this.onchange&&this.onchange(n,i),this.trigger("change",n,i)}return this}contains(t,e){return ks.call(this,t,e)}move(t,...e){Ss.call(this,t,...e)}symmetryX(t){Ms.call(this,t)}symmetryY(t){zs.call(this,t)}adjustResize(t,e,r){return As.call(this,t,e,r)}adjustRotation(t,e){return js.call(this,t,e)}outline(t){return Es.call(this,t)}get bounds(){return Os.call(this)}set bounds(t){Ts.call(this,t)}get center(){return Ps.call(this)}set center(t){Cs.call(this,t)}get location(){return Is.call(this)}set location(t){Fs.call(this,t)}get rotate(){return Rs.call(this)}set rotate(t){Ds.call(this,t)}get dimension(){return Ns.call(this)}set dimension(t){Ls.call(this,t)}get path(){return Ys.call(this)}set path(t){$s.call(this,t)}get drawPath(){return Us.call(this)}get rotatePoint(){return Ws.call(this)}get mutable(){return qs.call(this)}get resizable(){return Gs.call(this)}get rotatable(){return Bs.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&&Vs.call(this,t)}prerender(t){Zs.call(this,t)}render(t){Qs.call(this,t)}postrender(t){Js.call(this,t)}prepare(t,e){Ks.call(this,t,e)}prepareIf(t){ta.call(this,t)}drawText(t){ea.call(this,t)}drawStroke(t,e){ra.call(this,t,e)}drawFill(t,e){na.call(this,t,e)}get strokeStyle(){return ia.call(this)}set strokeStyle(t){oa.call(this,t)}get fillStyle(){return sa.call(this)}set fillStyle(t){aa.call(this,t)}get fontColor(){return ca.call(this)}set fontColor(t){ua.call(this,t)}get rotation(){return la.call(this)}set rotation(t){ha.call(this,t)}get decorators(){return fa.call(this)}get decotag(){return da.call(this)}get hidden(){return pa.call(this)}set hidden(t){ga.call(this,t)}get tag(){return ya.call(this)}set tag(t){ma.call(this,t)}get appendum(){return ba.call(this)}set appendum(t){va.call(this,t)}defaultTextSubstitutor(){return xa.call(this)}textLines(t){return _a.call(this,t)}get font(){return wa.call(this)}get lineHeight(){return ka.call(this)}get textSubstitutor(){return Sa.call(this)}get text(){return Ma.call(this)}set text(t){za.call(this,t)}get textBounds(){return Aa.call(this)}get textRotation(){return ja.call(this)}get textHidden(){return Ea.call(this)}set textHidden(t){Oa.call(this,t)}get hasTextProperty(){return Ta.call(this)}animate(t){return Wa.call(this,t)}effect(t,e){return qa.call(this,t,e)}serialize(...t){return Xa.call(this,...t)}trim(){Va.call(this)}closeScene(t){Za.call(this,t)}delta(t,e){return Qa.call(this,t,e)}invalidate(){Ja.call(this)}get value(){return Ka.call(this)}set value(t){tc.call(this,t)}get data(){return ec.call(this)}set data(t){rc.call(this,t)}set tap(t){nc.call(this,t)}get mappings(){return ic.call(this)}get retention(){return oc.call(this)}get animation(){return sc.call(this)}get started(){return ac.call(this)}set started(t){cc.call(this,t)}get controls(){return uc.call(this)}findFirst(t,...e){return gc.call(this,t,...e)}findAll(t,...e){return yc.call(this,t,...e)}capture(t,e,r){return mc.call(this,t,e,r)}findAnchor(t){return bc.call(this,t)}isDescendible(t){return vc.call(this,t)}getContext(t){return xc.call(this,t)}get root(){return _c.call(this)}get rootModel(){return wc.call(this)}get parent(){return kc.call(this)}set parent(t){Sc.call(this,t)}get anchors(){return Mc.call(this)}get scalable(){return zc.call(this)}get stuck(){return Ac.call(this)}get capturable(){return jc.call(this)}get position(){return Ec.call(this)}get origin(){return Oc.call(this)}get offset(){return Tc.call(this)}get app(){return Pc.call(this)}drawEffect(t){zo.call(this,t)}prepareFill(t,e){Po.call(this,t,e)}prepareFillIf(t){Co.call(this,t)}onchangeFill(t,e){Io.call(this,t,e)}drawImage(t,e,r,n,i,o){Mo.call(this,t,e,r,n,i,o)}mutateBounds(t,e){ss.call(this,t,e)}mutatePath(t,e,r){as.call(this,t,e,r)}access(t){return ms.call(this,t)}substitute(t,e){return bs.call(this,t,e)}onchangeMappings(t,e){So.call(this,t,e)}onchangeData(t,e){_o.call(this,t,e)}buildMappings(){wo.call(this)}executeMappings(t){xo.call(this,t)}disposeMappings(){ko.call(this)}ondropfile(t,e){qo.call(this,t,e)}transcoordS2P(t,e,r){return Vo.call(this,t,e,r)}transcoordP2S(t,e,r){return Xo.call(this,t,e,r)}transcoordS2T(t,e,r){return Qo.call(this,t,e,r)}transcoordT2P(t,e,r){return Jo.call(this,t,e,r)}transcoordT2S(t,e,r){return Ko.call(this,t,e,r)}transcoordS2TR(t,e,r){return Zo.call(this,t,e,r)}transcoordS2O(t,e,r){return ts.call(this,t,e,r)}transcoordC2S(t,e,r){return es.call(this,t,e,r)}transcoordS2C(t,e,r){return rs.call(this,t,e,r)}toParent(t,e,r){return Vo.call(this,t,e,r)}fromParent(t,e,r){return Xo.call(this,t,e,r)}toScene(t,e,r){return Qo.call(this,t,e,r)}fromScene(t,e,r){return Ko.call(this,t,e,r)}toLocal(t,e,r){return es.call(this,t,e,r)}toGlobal(t,e,r){return rs.call(this,t,e,r)}toOther(t,e,r){return ts.call(this,t,e,r)}on(t,e,r){return Ni.call(this,t,e,r)}off(t,e,r){return Li.call(this,t,e,r)}once(t,e,r){return Yi.call(this,t,e,r)}trigger(t,...e){return $i.call(this,t,...e)}delegate_on(t){return Ui.call(this,t)}delegate_off(t){return Wi.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,r){}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){}}$c.capabilities=[],$c.union=function(t){let e=0,r=0,n=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i)):(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:r,width:n-e,height:i-r}},$c.transcoordR=Bo,$c.transcoordRR=Ho,$c.createCanvas=Oo,$c.memoize=function(t,e,r){const n=function(t,e){let r=t;for(;r;){const t=Object.getOwnPropertyDescriptor(r,e);if(t?.get)return t;r=Object.getPrototypeOf(r)}}(t,e);if(!n?.get)return void qi(`${String(e)} is not defined in ${t.constructor.name}`);const i=n.get,o={get:r?function(){return e in this.__cache__?Oi.enabled&&Oi.cacheHit++:(Oi.enabled&&Oi.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?Oi.enabled&&Oi.cacheHit++:(Oi.enabled&&Oi.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};n.set&&(o.set=n.set),Object.defineProperty(t,e,o)},$c.mixin=function t(e,r){if(r instanceof Array)r.forEach(r=>t(e,r));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(r)>=0)return e;if(e.mixingIn.indexOf(r)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(r),r.call(e),e.mixingIn.pop(),e.mixedIn.push(r)}return e},$c.drawText=Uo,$c.font=Yo,$c.textLines=Lo,$c.drawStroke=Fo,$c.drawFill=To,$c.reposition=function(t){let{id:e,scale:r=is,bold:n,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:l,paddingLeft:h,paddingRight:f,fontSize:d=jo.FONT_SIZE,lineWidth:p=0,lineHeight:g,lineDash:y}=t.state;l||=0,u||=0,h||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:_}=t,{left:w,top:k,width:S,height:M}=t.bounds,z=t.element;if(z.hidden=_,e&&(z.id=e),m&&(z.className=m),Object.assign(z.style,os,{fontFamily:o,fontSize:d+"px",width:S+"px",height:M+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:l+"px",paddingLeft:h+"px",border:p+"px",borderColor:b,borderStyle:p>0?y||jo.LINE_DASH:"",color:x,fontWeight:n?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===g?"":g+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),ns(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,r=e.offsetX??e.left??0,n=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${r}px ${n}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const A=t.delta(),j=(r&&r.x||1)*A.sx,E=(r&&r.y||1)*A.sy,O=(v||0)+A.theta,T=A.tx||0,P=A.ty||0;z.style.transform=`rotate(${O}rad) translate(${T}px, ${P}px) scale(${j}, ${E}) perspective(1px)`},$c.RetentionManager=ps,$c.template=function(t,e,r){var n=wn.imports._.templateSettings||wn;r&&Xr(t,e,r)&&(e=void 0),t=vn(t),e=Zr({},e,n,un);var i=Zr({},e.imports,n.imports,un),o=ar(i),s=function(t,e){return sn(e,function(e){return t[e]})}(i,o);Tr(o,function(t){if(zn.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,u=0,l=e.interpolate||jn,h="__p += '",f=RegExp((e.escape||jn).source+"|"+l.source+"|"+(l===fn?An:jn).source+"|"+(e.evaluate||jn).source+"|$","g"),d=On.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,r,n,i,o,s){return n||(n=i),h+=t.slice(u,s).replace(En,hn),r&&(a=!0,h+="' +\n__e("+r+") +\n'"),o&&(c=!0,h+="';\n"+o+";\n__p += '"),n&&(h+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=s+e.length,e}),h+="';\n";var p=On.call(e,"variable")&&e.variable;if(p){if(zn.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(c?h.replace(kn,""):h).replace(Sn,"$1").replace(Mn,"$1;"),h="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")+h+"return __p\n}";var g=on(function(){return Function(o,d+"return "+h).apply(void 0,s)});if(g.source=h,nn(g))throw g;return g},$c.buildSubstitutor=vs,["rotatePoint","font","lineHeight","retention"].forEach(t=>$c.memoize($c.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>$c.memoize($c.prototype,t,!0));const Uc=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 Wc(t){return class extends 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)}}get data(){return this.isRecordStorage?this.state?.data??[]:this._exportSlotRecords()}_reconcileItems(t){const e=new Map;for(const r of t){const t=this._recordKey(r);t&&e.set(t,r)}const r=new Map;for(const t of this._items){const e=t[W];null!=e&&r.set(String(e),t)}for(const[t,n]of r)if(!e.has(t)){try{this.removeItem(n,!0)}catch{}try{n?.dispose?.()}catch{}}for(const[t,n]of e){if(r.has(t))continue;if(null==n.itemId)continue;const e=this._createItemFromRecord(n);if(e){e[W]=t;try{this.handoverIn(e)}catch{}}}for(const[t,n]of e){const e=r.get(t);if(e&&(n.itemState&&"function"==typeof e.setState))try{e.setState(n.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],r=new Map,n=[];for(const t of this._items){const e=t[W];null!=e?r.set(String(e),t):n.push(t)}for(const n of t){const t=r.get(n)??null;e.push(this._slotRecordOf(n,t))}for(const t of n)e.push(this._slotRecordOf("",t));for(const[n,i]of r)t.includes(n)||e.push(this._slotRecordOf(n,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const r=e?.state?.id;return{slotId:t,itemId:null!=r?String(r):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const r=this._businessFields?.();if(Array.isArray(r)){if(0===r.length)return;const t={};for(const n of r)n in e&&void 0!==e[n]&&(t[n]=e[n]);return Object.keys(t).length>0?t:void 0}const n={};for(const t of Object.keys(e))Uc.has(t)||t.startsWith("_")||(n[t]=e[t]);return Object.keys(n).length>0?n:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const r=$c.register?.(e);if(r&&"function"==typeof r){return new r({type:e,...t.itemState??{}})}}catch{}return null}}}function qc(t,e){const r=t.left??0,n=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=r+i/2,l=n+o/2,h="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,r;return{worldPos:(e=t.lx,r=t.lz,{x:u+e*a-r*c,z:l+e*c+r*a}),direction:{x:h*(t.odx*a-t.odz*c),z:h*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Gc(t,e){const r=t.left??0,n=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=r+i/2,l=n+o/2,h=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),g=Math.sin(s),y=(t,e)=>({x:u+t*p-e*g,z:l+t*g+e*p}),m=c?{lx:0,lz:-h}:{lx:-h,lz:0},b=c?{lx:0,lz:h}:{lx:h,lz:0},v=y(m.lx,m.lz),x=y(b.lx,b.lz),_={x:f*p-d*g,z:f*g+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},S={x:-k.x,z:-k.z},M=(c?i:o)/2;return a?{inbounds:[{worldPos:x,direction:S,halfSpan:M}],outbounds:[{worldPos:v,direction:S,halfSpan:M}]}:{inbounds:[{worldPos:v,direction:k,halfSpan:M}],outbounds:[{worldPos:x,direction:k,halfSpan:M}]}}function Bc(t){const e=t.left??0,r=t.top??0,n=t.width??0,i=t.height??0;if(n<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&n<i,a=e+n/2,c=r+i/2,u=s?i/2:n/2,l=Math.cos(o),h=Math.sin(o),f=(t,e)=>({x:a+t*l-e*h,z:c+t*h+e*l});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Hc(t){const e=t.cx??0,r=t.cy??0,n=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(n+n*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,l="reverse"===t.status;if(n<=0||i<=0)return{inbounds:[],outbounds:[]};const h={x:e+s*Math.sin(c),z:r-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:r-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return l?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:h,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:h,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function Xc(t){const e=Gc(t),r=e.outbounds[0];if(!r)return{inbounds:qc(t,"inbound"),outbounds:[]};const n=qc(t,"inbound").filter(t=>{const e=t.worldPos.x-r.worldPos.x,n=t.worldPos.z-r.worldPos.z;return Math.hypot(e,n)>1}),i=r.direction,o=[];for(const t of n){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const r=t.direction.x+i.x,n=t.direction.z+i.z,s=Math.hypot(r,n)||1;o.push({worldPos:t.worldPos,direction:{x:r/s,z:n/s},halfSpan:t.halfSpan})}return{inbounds:[...n,...o],outbounds:e.outbounds}}function Vc(t,e,r={}){const n=r.distance??5,i=r.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 r=t.direction.x,i=t.direction.z;if(Math.abs(o*r+s*i)>n)return!1;const a=Math.abs(o*-i+s*r);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=n}function Zc(t,e,r,n=0){const i=r.width??0,o=r.height??0;if(i<=0||o<=0)return!1;const s=(r.left??0)+i/2,a=(r.top??0)+o/2,c="number"==typeof r.rotation?r.rotation:0,u=Math.cos(-c),l=Math.sin(-c),h=t-s,f=e-a,d=h*u-f*l,p=h*l+f*u;return Math.abs(d)<=i/2+n&&Math.abs(p)<=o/2+n}function Qc(t,e,r){const n=r.width??0,i=r.height??0;if(n<=0||i<=0)return 1/0;const o=(r.left??0)+n/2,s=(r.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,l=e.z;const h="number"==typeof r.rotation?r.rotation:0;if(0!==h){const t=Math.cos(-h),e=Math.sin(-h),r=a*e+c*t,n=u*e+l*t;a=a*t-c*e,c=r,u=u*t-l*e,l=n}const f=n/2,d=i/2;let p=-1/0,g=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)),g=Math.min(g,Math.max(t,e))}if(Math.abs(l)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/l,e=(d-c)/l;p=Math.max(p,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<p?1/0:p>=0?p:g>=0?Math.min(-p,g):-g}function Jc(t,e,r,n=6){return!!Zc(t.worldPos.x,t.worldPos.z,e,n)&&(!r||t.direction.x*r.x+t.direction.z*r.z>=0)}function Kc(t,e,r){return t.outbounds.map(t=>{const n=[];for(const i of e){let e=null;for(const n of i.topology.inbounds){if(!Vc(t,n,r))continue;const i=t.worldPos.x-n.worldPos.x,o=t.worldPos.z-n.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const n=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?r?.sinkMargin??30:6;if(Jc(t,i.bounds,n,o)){const r=Qc(t.worldPos,t.direction,i.bounds);if(Number.isFinite(r))e=r+1e3;else{const r=(i.bounds.left??0)+(i.bounds.width??0)/2,n=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-r,t.worldPos.z-n)+1e3}}}null!==e&&n.push({id:i.id,dist:e})}return 0===n.length?null:(n.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),n[0].id)})}function tu(t,e){const r=new Map;for(const e of t)r.set(e.id,e);const n=new Map,i=new Set;for(const r of t){const o=t.filter(t=>t.id!==r.id),s=Kc(r.topology,o,e);n.set(r.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!r.has(t)||!r.has(e)||t===e)return;const o=n.get(t)??[];o.includes(e)||(o.push(e),n.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){(n.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:r,out:n,sinks:s,sources:a}}function eu(t,e){const r=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const n=new Set([e]);for(const i of function(t,e,r){const n=r.get(e);if(n)return n;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const r of t.out.get(e)??[])null!=r&&(i.add(r),s.has(r)||(s.add(r),o.push(r)))}return r.set(e,i),i}(t,e,r))n.add(i);return n})}function ru(t,e,r,n){return e===r?0:function(t,e,r){const n=r.get(e);if(n)return n;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),r=i.get(e);for(const n of t.out.get(e)??[])null==n||i.has(n)||(i.set(n,r+1),o.push(n))}return r.set(e,i),i}(t,e,n).get(r)??1/0}function nu(t,e,r){const n=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<n.length;e++){const s=n[e];if(null==s)continue;const a=s===r?0:ru(t,s,r,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 iu(t,e,r){const n=nu(t,e,r);return n.length?n[0]:-1}function ou(t,e,r){return e===r||nu(t,e,r).length>0}function su(t,e){const r=new Set;for(const n of eu(t,e))for(const e of n)t.sinks.has(e)&&r.add(e);return r}function au(t,e,r){return cu(t,e,r).map(t=>t.index)}function cu(t,e,r){const n=r instanceof Set?r:new Set(r);if(0===n.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...n].sort(),a=[];for(let e=0;e<i.length;e++){const r=i[e];if(null==r)continue;let n=1/0,c="";for(const e of s){const i=1+(r===e?0:ru(t,r,e,o));i<n&&(n=i,c=e)}n!==1/0&&a.push({index:e,hops:n,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function uu(t,e={}){const r=[],n=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const n=t.nodes.get(e);if(!n||!n.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||r.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)||r.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],r=[...t.nodes.keys()].sort(),n=new Set,i=[],o=new Set,s=r=>{n.add(r),i.push(r),o.add(r);for(const a of t.out.get(r)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),r=i.slice(t),n=r.indexOf([...r].sort()[0]),o=[...r.slice(n),...r.slice(0,n)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else n.has(a)||s(a);i.pop(),o.delete(r)};for(const t of r)n.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=>n.has(t))||r.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)&&r.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)||r.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return r.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),r}function lu(t,e){if(!t)return[];const r=[],n=new Set,i=t=>{if(!t||n.has(t))return;if(n.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,n=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=n?String(n):void 0;if(i)try{const e=t.getSegmentTopology(),n=t.state??{},o={left:n.left,top:n.top,width:n.width,height:n.height,rotation:n.rotation};e&&r.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),r}function hu(t,e){const r=t.state?.targetRef??t.state?.outputRef;if("string"==typeof r&&r.length>0)return r;if("function"!=typeof t.getSegmentTopology)return null;const n=t.getSegmentTopology();if(!n||0===n.outbounds.length)return null;const i=Kc(n,lu(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 fu(t){return!!t&&"function"==typeof t.routingConstraints}function du(t){return!!t&&"function"==typeof t.acceptedCarrierData}function pu(t,e=16){const r=[],n=t.parent??t.rootModel??t.root;if(!n)return r;const i=hu(t);if(!i)return r;const o=mu(n,i);if(!o)return r;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=fu(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=gu(t.accumulated,i);if(!o)continue;const a=yu(t.segment,e.portId,n);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??""])}):r.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(du(t.segment)){const e=t.segment.acceptedCarrierData(),n=t.segment.state?.id;if(0===e.length)r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:n});else for(const i of e){const e=gu(t.accumulated,i);e&&r.push({data:e,weight:1,pathIds:t.pathIds,destination:n})}continue}const e=hu(t.segment);if(!e||t.visited.has(e)){r.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=mu(n,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return r}function gu(t,e){const r={...t};for(const[t,n]of Object.entries(e)){if(t in r&&r[t]!==n)return null;r[t]=n}return r}function yu(t,e,r){if("straight"===e&&t.state?.outputRef)return mu(r,t.state.outputRef);const n=mu(r,e);if(n)return n;const i=hu(t);return i?mu(r,i):null}function mu(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const r=new Set,n=t=>{if(!t||r.has(t))return null;if(r.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=n(t);if(e)return e}return null};return n(t)}function bu(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function vu(t,e,r=5,n=[],i=r){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,r)=>"start"===r?t[e].start:t[e].end,u=[],l=new Map,h=[],f=new Map;for(const t of n){const e=Array.isArray(t),r=e?t:t.positions,n=e?void 0:t.kind;if(!r.length)continue;const i=u.length;u.push({pos:r[0],members:[]});for(const t of r)h.push({pos:t,pt:i});n&&f.set(i,n)}const d=(t,e)=>{const n=c(t,e),i=l.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of h)bu(t.pos,n)<=r&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)bu(u[t].pos,n)<=r&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:n,members:[]})),u[s].members.push({seg:t,end:e}),l.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,g=new Set,y=new Set;{const t=t=>{let e=-1,r=1/0;for(let n=0;n<u.length;n++){const i=bu(u[n].pos,t);i<r&&(r=i,e=n)}for(const n of h){const i=bu(n.pos,t);i<r&&(r=i,e=n.pt)}return{pt:e,d:r}};for(const r of e){const{pt:e,d:n}=t(r.pos);e>=0&&n<=i&&(p.add(e),("source"===r.kind?g:y).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?g:y).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],v=(e,r)=>{if(void 0===s[e])return s[e]=r,void b.push(e);s[e]!==r&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const r=l.get(`${t}:${e}`);if(void 0===r)continue;const n=u[r];if(2!==n.members.length||p.has(r))continue;const i=n.members[0],o=i.seg===t&&i.end===e?n.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,r="start",n=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=bu(c(i,o),t.pos);s<n&&(n=s,e=i,r=o)}if(e<0||n>i)return;const s="source"===t.kind?"end"===r:"start"===r;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 r=0,n=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?r++:n++);const i=e[0];let o;0===n&&r>0?o="end"===i.end:0===r&&n>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)&&g.size>0&&y.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),r=[];for(const n of t)e[n]=0,r.push(n);for(;r.length;){const t=r.shift();for(const n of u[t].members){const i=l.get(`${n.seg}:${"start"===n.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,r.push(i))}}return e},e=t(g),r=t(y);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const n=l.get(`${t}:start`),i=l.get(`${t}:end`);if(void 0===n||void 0===i)continue;if(u[n].members.length<2||u[i].members.length<2)continue;if(e[n]===1/0||e[i]===1/0||r[n]===1/0||r[i]===1/0)continue;let o;e[n]!==e[i]?o=e[n]<e[i]:r[n]!==r[i]&&(o=r[i]<r[n]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const S=new Map;for(let e=0;e<o;e++)S.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:S,conflicts:[...a]}}function xu(...t){}function _u(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function wu(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*ku(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*ku(t)}function Su(t,e,r){const n=e.width??0,i=e.height??0;if(n<=0||i<=0)return!1;const o=(e.left??0)+n/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,l=Math.cos(-a),h=Math.sin(-a),f=c*l-u*h,d=c*h+u*l;return Math.abs(f)<=n/2+r&&Math.abs(d)<=i/2+r}function Mu(t){const e=[],r=[],n=[],i=[];for(const o of ku(t)){const t=wu(o);if(!t)continue;if(o.flowOrientable){const r=Bc(o.state??{});r&&e.push({id:t,start:r.start,end:r.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)r.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)r.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&&n.push({positions:t})}}for(const t of i){const i=[];for(const r of e)for(const e of[r.start,r.end])Su(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of r)Su(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)&&n.push({positions:i,kind:a})}if(0===e.length||0===r.length)return e.length,r.length,new Map;const o=vu(e,r,8,n,60).directions;return e.length,r.length,n.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function zu(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let r=e.__flowOrientation;if(!r){e.__flowComputing=!0;try{r={map:Mu(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=r}const n=wu(t),i=n?r.map.get(n):void 0;return"reverse"===i||"forward"!==i&&void 0}function Au(t){return!!t&&"function"==typeof t.distanceToBoardPoint&&"function"==typeof t.routingLinks&&("function"==typeof t.registerDivertStation||"function"==typeof t.registerInductStation)}function ju(t,e,r){if(!e)return null;const n=[],i=e=>{if(!e||e===r)return;if(Au(e)){const r=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}(e);if(r){const i=e.distanceToBoardPoint(t.x,t.y);n.push({id:r,component:e,distance:i})}}const o=e.components;if(Array.isArray(o))for(const t of o)i(t)};return i(e),0===n.length?null:(n.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),n[0])}function Eu(t){return!!t&&"function"==typeof t.routingDestination}function Ou(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const r=t?.refid??t?.state?.refid;return null!=r?String(r):void 0}function*Tu(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*Tu(t)}function Pu(t){const e=[],r=new Map,n=new Map,i=new Set,o=[];for(const s of Tu(t)){const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks;if(!t&&!Eu(s)&&!a)continue;const c=Ou(s);if(!c)continue;let u={inbounds:[],outbounds:[]};if(t){try{u=s.getSegmentTopology()}catch{continue}if(!u)continue}const l=s.state??{},h={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation},f="function"==typeof s.routingLinks?s.routingLinks():void 0;if(e.push({id:c,topology:u,bounds:h,links:f}),n.set(c,s),"function"==typeof s?.registerWithStationHost&&o.push(s),Eu(s)){i.add(c);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=r.get(t)??[];e.push(c),r.set(t,e)}}}return{nodes:e,destToSinks:r,components:n,routingTargetIds:i,stationClients:o}}function Cu(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:r,destToSinks:n,components:i,routingTargetIds:o,stationClients:s}=Pu(t),a=tu(r);!function(t,e){if(!t)return;const r=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)r(t)};if(r(t),0===e.length)return;const n=[...e].sort((t,e)=>{const r=Ou(t)??"",n=Ou(e)??"";return r.localeCompare(n)});for(const e of n){const r=e.state?.sorterRef;let n=null;if(r&&(n=t.findById?.(r)??null),!n){const r=e.sorterFacingPoint?.()??e._sorterFacingPoint?.();r&&(n=ju(r,t,e)?.component??null)}n&&"function"==typeof e.registerWithStationHost&&e.registerWithStationHost(n)}}(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 r=e.routingWeight();"number"==typeof r&&(!Number.isFinite(r)||r<=0)&&u.set(t,r)}}const l=uu(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(l.length>0&&"undefined"!=typeof console){const t=l.filter(t=>"error"===t.severity),e=l.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,l):console.info(`[FlowGraph] ${e.length} warning(s):`,l)}e={graph:a,destToSinks:n,components:i,issues:l},t.__flowGraph=e}return e}function Iu(t){return Cu(t)?.issues??[]}function Fu(t){const e=Cu(t);return e&&e.graph.nodes.size>0?e.graph:null}function Ru(t,e){return Cu(t)?.destToSinks.get(e)??[]}function Du(t,e){return Cu(t)?.components.get(e)}function Nu(t){const e=Cu(t);return e?[...e.destToSinks.keys()]:[]}function Lu(t){return Ou(t)}function Yu(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,r=t?.state?.capacity;return"number"==typeof r&&r>0?e/r:e}function $u(t,e,r,n,i){if(1===n.length)return n[0];switch(t){case"index":default:return n[0];case"round-robin":{const t=r.counters.get(e)??0;return r.counters.set(e,t+1),n[t%n.length]}case"weight":{const t=n.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 n[0];const s=r.counters.get(e)??0;r.counters.set(e,s+1);let a=s%o;for(let e=0;e<n.length;e++){if(a<t[e])return n[e];a-=t[e]}return n[n.length-1]}case"utilization":{let t=1/0,e=n[0];for(const r of n){const n=Yu(i.get(r.target));n<t&&(t=n,e=r)}return e}}}function Uu(t,e,r){const n=t?.root;if(!n)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=Cu(n);if(!o||0===o.graph.nodes.size)return null;const s=Ou(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=cu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],l=c.filter(t=>{const r=u[t.index],n=r?o.components.get(r):null;return!n||"function"!=typeof n.canReceive||n.canReceive(e)});if(0===l.length)return u[c[0].index]??null;const h=r?.policy??function(t,e){const r=t?.state?.balancingPolicy;if(r)return r;const n=e?.state?.routingBalancingPolicy;return n||"round-robin"}(t,n),f=$u(h,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(n),l,o.components);return u[f.index]??null}try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,Fu(t)}catch{return null}}}catch{}function Wu(t,e,r){const n=Uu(t,e,r);if(null==n)return null;const i=t?.root,o=Du(i,n)??i?.findById?.(n)??null;return o?{targetId:n,component:o,origin:"explicit"}:null}function qu(t){const e=t?.root,r=Fu(e),n=Lu(t);if(!r||!n)return null;const i=(r.out.get(n)??[]).find(Boolean);if(!i)return null;const o=Du(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Gu(t){const e=Lu(t);return e?Bu(t?.root,e):[]}function Bu(t,e){if(!t||!e)return[];const r=Fu(t);if(!r)return[];const n=new Set;for(const i of su(r,e)){const e=Du(t,i);if(Eu(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&n.add(t)}}return[...n]}function Hu(t,e){if(!t||!e)return[];const r=Fu(t);if(!r)return[];const n=new Map;for(const t of r.out.values())for(const e of t)null!=e&&n.set(e,(n.get(e)??0)+1);const i=new Map;for(const o of su(r,e)){const e=Du(t,o);if(!Eu(e))continue;const r=e.routingDestination();if("string"!=typeof r||0===r.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=n.get(o)??0,0===s&&(s=1)),i.set(r,(i.get(r)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function Xu(t){return Fu(t)}function Vu(t){const e=Fu(t);if(!e)return[];const r=new Set,n=new Set,i=t=>{if(!t)return;const o=Lu(t);if(o&&e.nodes.has(o)){Eu(t)&&r.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&n.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),uu(e,{routingTargetIds:r,loopCapableIds:n})}function Zu(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 r=Math.random()*e;let n=0;for(const e of t)if(n+=e.weight,r<n)return e.value;return t[t.length-1].value}const Qu={next:Wu,downstream:qu,reachableDestinations:Gu,reachableDestinationsFrom:Bu,reachableDestinationsWeightedFrom:Hu,pickWeightedDestination:Zu,graphFor:Xu,validate:Vu};function Ju(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,r){const n=t.prototype?.attachPointFor;return"function"==typeof n?n.call(this,e,r):null}addItem(t,e){if(!t||this.containsItem(t))return;const r=t.parent;if(r&&"function"==typeof r.removeItem&&r!==this&&r.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 r=this._items.indexOf(t);if(-1!==r&&(this._items.splice(r,1),t.parent=null,!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,r)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const r=t.parent;r&&("function"==typeof r.removeComponent&&-1!==r._components?.indexOf?.(t)&&r.removeComponent(t,!0),r!==this&&"function"==typeof r.removeItem&&-1!==r._items?.indexOf?.(t)&&r.removeItem(t,!0));const n=-1===this._items.indexOf(t);if(n&&this._items.push(t),t.parent=this,n&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.realObject;const i=t._realObject,o=i?.object3d;if(o){let r,n,s=e?.toParent3D,a="world-preserve";if(!s){const i=this.attachPointFor?.(t,{slotId:e?.slotId});i?.attach&&(s=i.attach,r=i.localPosition,n=i.localRotation,a=i.carryPolicy??"world-preserve")}s&&o.parent!==s&&(s.updateWorldMatrix?.(!0,!1),o.updateWorldMatrix?.(!0,!1),s.attach(o),i.suppressTransform=!0),s&&(r&&o.position.set(r.x,r.y,r.z),"world-preserve"!==a?n?o.rotation.set(n.x,n.y,n.z):o.quaternion.identity():n&&o.rotation.set(n.x,n.y,n.z),i?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}))}t.held?.(this),this._bumpReceived?.(t)}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,r,n,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?.(r,n,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const r=this._items;if(!r||0===r.length)return;t.save();const n=e.bounds;!e.showOverflow&&n&&(t.beginPath(),t.rect(n.left,n.top,n.width,n.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,r){const n=this,i=this._items;if(i&&i.length>0&&(!n.app||n.app.isEditMode||!n.hidden)){const i=n.fromParent?.(t,e);if(i&&n.contains?.(i.x,i.y)){const o=n.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,r);if(s)return s}}return super.capture?.(t,e,r)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Ku(t){var e;const r=!!t.__hasCapacity,n=!!t.__hasTransferable,i=r?t:q(t),o=n?i:Z(i),s=[...t.capabilities??[]];r||s.push("Capacity","PlacementSurface"),n||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Wc((e=class extends(Ju(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 r=this.state?.rejected??0;this.setState?.({rejected:r+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}},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 tl(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,r({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"}),r({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{lt as BULGE_EPSILON,Mt as CapacityEventTracker,Et as CenteringQueueStrategy,g as CenteringSlotStrategy,Q as ContainerCapacity,d as FixedSlotStrategy,Qu as FlowEngine,Ku as FlowNode,Pt as GravityStrategy,Ot as GridStrategy,Ju as Holdable,Wc as ItemsDataBinding,it as NavGraph,xt as PolygonPathPolyline,jt as QueueStrategy,rt as ReservationTable,Tt as ShelfStrategy,At as StackStrategy,W as TRANSFER_SLOT_KEY,X as Transfer,Nu as allDestinations,Vc as anchorsConnect,$u as applyPolicy,U as applySeatingRotation,Hc as arcSegmentTopology,zt as autoWireBackPressure,tu as buildFlowGraph,at as buildNavGraph,pt as bulgeFromDrag,dt as bulgeHandlePosition,ou as canReach,t as capability,f as chooseNearestPickupFrame,lu as collectAdjacentSegments,Du as componentForNode,ft as computeArcParams,Mu as computeFlowMap,yt as cornerHandlePosition,mt as cornerRadiusFromDrag,Jc as deliversInto,qu as downstream,gt as effectiveCornerRadius,pu as enumerateDataScenarios,h as filterByToolType,ju as findNearestStationHost,p as fixedSlotStrategy,_t as flattenPolygonPath,Fu as flowGraphFor,Iu as flowGraphIssues,zu as flowReverseFor,_u as ftId,xu as ftrace,i as getAllCapabilityMeta,n as getCapabilityMeta,I as globalSimClock,Xu as graphFor,ht as hasArc,kt as hasCapacity,St as inferCapacity,hu as inferDownstreamId,vu as inferFlowDirections,J as isCarrierLine,tl as isFlowNode,Eu as isRoutingTarget,Au as isStationHost,Kc as matchOutbounds,Wu as next,iu as nextHop,nu as nextHops,au as nextHopsToAny,cu as nextHopsToAnyDetailed,Lu as nodeIdOf,Zu as pickWeightedDestination,ct as planPathAStar,ut as planToReservations,Zc as pointInRotatedRect,wt as polygonPathLength,s as quatFromYaw,Qc as rayAbsDistanceToRect,eu as reachableByOutbound,Gu as reachableDestinations,Bu as reachableDestinationsFrom,Hu as reachableDestinationsWeightedFrom,su as reachableSinks,B as receiptToJSON,qc as rectFaceAnchors,u as rectangularFootprintFrames,r as registerCapabilityMeta,nt as reservationTable,Uu as resolveNextHop,Ru as sinksForDestination,et as standardYieldPolicy,Bc as straightSegmentEndpoints,Xc as straightSegmentMultiInbound,Gc as straightSegmentTopology,l as topApproachFrame,V as transferLog,L as transferTracer,bt as uniformZ,Vu as validate,uu as validateFlowGraph};
|