@hatiolab/things-scene 10.1.83 → 10.1.85

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.
@@ -1,7 +1,7 @@
1
- function t(...t){return e=>{const r=Object.getPrototypeOf(e),n=Array.isArray(r?.capabilities)?r.capabilities:[],i=new Set([...n,...t]);return Object.defineProperty(e,"capabilities",{value:Object.freeze([...i]),writable:!1,configurable:!0}),e}}const e=new Map;function r(t){e.set(t.name,t)}function n(t){return e.get(t)}function i(){return[...e.values()]}const o={x:0,y:0,z:0,w:1};function s(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function a(t,e){const r=t.rotation,n=e.rotation,i=e.position,o=r.w*i.x+r.y*i.z-r.z*i.y,s=r.w*i.y+r.z*i.x-r.x*i.z,a=r.w*i.z+r.x*i.y-r.y*i.x,c=-r.x*i.x-r.y*i.y-r.z*i.z,u=o*r.w+c*-r.x+s*-r.z-a*-r.y,h=s*r.w+c*-r.y+a*-r.x-o*-r.z,l=a*r.w+c*-r.z+o*-r.y-s*-r.x,f={x:r.w*n.x+r.x*n.w+r.y*n.z-r.z*n.y,y:r.w*n.y-r.x*n.z+r.y*n.w+r.z*n.x,z:r.w*n.z+r.x*n.y-r.y*n.x+r.z*n.w,w:r.w*n.w-r.x*n.x-r.y*n.y-r.z*n.z};return{position:{x:t.position.x+u,y:t.position.y+h,z:t.position.z+l},rotation:f}}const c={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function u(t){const{carrierWorld:e,width:r,depth:n,entryHeight:i,mountLocalY:u,approachDistance:h,sides:l,toolType:f,tolerance:d,priority:p}=t,g="number"==typeof u?{position:{x:0,y:u,z:0},rotation:{...o}}:void 0,y=r/2,m=n/2;return l.map(t=>{const r=c[t],n="string"==typeof f?f:f[t]??"unknown",o={position:{x:r.axis.x*("east"===t||"west"===t?y:0),y:i,z:r.axis.z*("north"===t||"south"===t?m:0)},rotation:s(r.yaw)},u={position:{x:o.position.x+r.axis.x*h,y:i,z:o.position.z+r.axis.z*h},rotation:s(r.yaw)};return{id:`entry-${r.idSuffix}`,toolType:n,approach:a(e,u),engage:a(e,o),...g?{mount:g}:{},tolerance:d,priority:p}})}function h(t){const{carrierWorld:e,topY:r,approachDistance:n,toolType:i,mountLocalY:s,tolerance:c,priority:u,id:h}=t,l={position:{x:0,y:r,z:0},rotation:{...o}};return{id:h??"top",toolType:i,approach:a(e,{position:{x:0,y:r+n,z:0},rotation:{...o}}),engage:a(e,l),..."number"==typeof s?{mount:{position:{x:0,y:s,z:0},rotation:{...o}}}:{},tolerance:c,priority:u}}function l(t,e){return t.filter(t=>t.toolType===e.toolType)}function f(t,e){if(0===t.length)return null;const r=t.map(t=>{const r=t.approach.position.x-e.x,n=t.approach.position.y-e.y,i=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(r*r+n*n+i*i)}});return r.sort((t,e)=>{const r=t.f.priority??0,n=e.f.priority??0;return r!==n?r-n:t.dist-e.dist}),r[0].f}class d{positionAt(t,e,r){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const p=new d;class g{constructor(t){this.owner=t}positionAt(t,e,r,n){if(0!==t)return null;const i=this.owner?.state?.width??0,o=this.owner?.state?.height??0,s=n?.state?.width??0,a=n?.state?.height??0;return{x:Math.max(0,(i-s)/2),y:Math.max(0,(o-a)/2),z:0}}capacity(t){return t.maxCount??1}}
1
+ function t(...t){return e=>{const n=Object.getPrototypeOf(e),r=Array.isArray(n?.capabilities)?n.capabilities:[],i=new Set([...r,...t]);return Object.defineProperty(e,"capabilities",{value:Object.freeze([...i]),writable:!1,configurable:!0}),e}}const e=new Map;function n(t){e.set(t.name,t)}function r(t){return e.get(t)}function i(){return[...e.values()]}const o={x:0,y:0,z:0,w:1};function s(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function a(t,e){const n=t.rotation,r=e.rotation,i=e.position,o=n.w*i.x+n.y*i.z-n.z*i.y,s=n.w*i.y+n.z*i.x-n.x*i.z,a=n.w*i.z+n.x*i.y-n.y*i.x,c=-n.x*i.x-n.y*i.y-n.z*i.z,u=o*n.w+c*-n.x+s*-n.z-a*-n.y,h=s*n.w+c*-n.y+a*-n.x-o*-n.z,l=a*n.w+c*-n.z+o*-n.y-s*-n.x,f={x:n.w*r.x+n.x*r.w+n.y*r.z-n.z*r.y,y:n.w*r.y-n.x*r.z+n.y*r.w+n.z*r.x,z:n.w*r.z+n.x*r.y-n.y*r.x+n.z*r.w,w:n.w*r.w-n.x*r.x-n.y*r.y-n.z*r.z};return{position:{x:t.position.x+u,y:t.position.y+h,z:t.position.z+l},rotation:f}}const c={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function u(t){const{carrierWorld:e,width:n,depth:r,entryHeight:i,mountLocalY:u,approachDistance:h,sides:l,toolType:f,tolerance:d,priority:p}=t,y="number"==typeof u?{position:{x:0,y:u,z:0},rotation:{...o}}:void 0,g=n/2,m=r/2;return l.map(t=>{const n=c[t],r="string"==typeof f?f:f[t]??"unknown",o={position:{x:n.axis.x*("east"===t||"west"===t?g:0),y:i,z:n.axis.z*("north"===t||"south"===t?m:0)},rotation:s(n.yaw)},u={position:{x:o.position.x+n.axis.x*h,y:i,z:o.position.z+n.axis.z*h},rotation:s(n.yaw)};return{id:`entry-${n.idSuffix}`,toolType:r,approach:a(e,u),engage:a(e,o),...y?{mount:y}:{},tolerance:d,priority:p}})}function h(t){const{carrierWorld:e,topY:n,approachDistance:r,toolType:i,mountLocalY:s,tolerance:c,priority:u,id:h}=t,l={position:{x:0,y:n,z:0},rotation:{...o}};return{id:h??"top",toolType:i,approach:a(e,{position:{x:0,y:n+r,z:0},rotation:{...o}}),engage:a(e,l),..."number"==typeof s?{mount:{position:{x:0,y:s,z:0},rotation:{...o}}}:{},tolerance:c,priority:u}}function l(t,e){return t.filter(t=>t.toolType===e.toolType)}function f(t,e){if(0===t.length)return null;const n=t.map(t=>{const n=t.approach.position.x-e.x,r=t.approach.position.y-e.y,i=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(n*n+r*r+i*i)}});return n.sort((t,e)=>{const n=t.f.priority??0,r=e.f.priority??0;return n!==r?n-r:t.dist-e.dist}),n[0].f}class d{positionAt(t,e,n){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const p=new d;class y{constructor(t){this.owner=t}positionAt(t,e,n,r){if(0!==t)return null;const i=this.owner?.state?.width??0,o=this.owner?.state?.height??0,s=r?.state?.width??0,a=r?.state?.height??0;return{x:Math.max(0,(i-s)/2),y:Math.max(0,(o-a)/2),z:0}}capacity(t){return t.maxCount??1}}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2026 Three.js Authors
5
5
  * SPDX-License-Identifier: MIT
6
- */const y=2e3,m={};function b(...t){t=function(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);const e="THREE."+t.shift();{const r=t[0];r&&r.isStackTrace?console.warn(r.getError(e)):console.warn(e,...t)}}function x(...t){const e=t.join(" ");e in m||(m[e]=!0,b(...t))}function v(t,e,r){return Math.max(e,Math.min(r,t))}class _{static{_.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(v(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*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}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class w{constructor(t=0,e=0,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],h=r[n+3],l=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(h!==p||a!==l||c!==f||u!==d){let t=a*l+c*f+u*d+h*p;t<0&&(l=-l,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const r=Math.acos(t),n=Math.sin(r);e=Math.sin(e*r)/n,a=a*e+l*(s=Math.sin(s*r)/n),c=c*e+f*s,u=u*e+d*s,h=h*e+p*s}else{a=a*e+l*s,c=c*e+f*s,u=u*e+d*s,h=h*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+h*h);a*=t,c*=t,u*=t,h*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,n,i,o){const s=r[n],a=r[n+1],c=r[n+2],u=r[n+3],h=i[o],l=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*h+a*f-c*l,t[e+1]=a*d+u*l+c*h-s*f,t[e+2]=c*d+u*f+s*l-a*h,t[e+3]=u*d-s*h-a*l-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,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),h=s(i/2),l=a(r/2),f=a(n/2),d=a(i/2);switch(o){case"XYZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"YXZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"ZXY":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"ZYX":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"YZX":this._x=l*u*h+c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h-l*f*d;break;case"XZY":this._x=l*u*h-c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h+l*f*d;break;default:b("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const 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],h=e[10],l=r+s+h;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-n)*t}else if(r>s&&r>h){const t=2*Math.sqrt(1+r-s-h);this._w=(u-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(i+c)/t}else if(s>h){const t=2*Math.sqrt(1+s-r-h);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+h-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(v(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 k{static{k.prototype.isVector3=!0}constructor(t=0,e=0,r=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("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(S.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(S.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,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),h=2*(i*r-o*e);return this.x=e+a*c+o*h-s*u,this.y=r+a*u+s*c-i*h,this.z=n+a*h+i*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,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=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this.z=v(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this.z=v(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(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 M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(v(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 M=new k,S=new w;class E{static{E.prototype.isMatrix3=!0}constructor(t,e,r,n,i,o,s,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,r,n,i,o,s,a,c)}set(t,e,r,n,i,o,s,a,c){const u=this.elements;return u[0]=t,u[1]=n,u[2]=s,u[3]=e,u[4]=i,u[5]=a,u[6]=r,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,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],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,n=e.elements,i=this.elements,o=r[0],s=r[3],a=r[6],c=r[1],u=r[4],h=r[7],l=r[2],f=r[5],d=r[8],p=n[0],g=n[3],y=n[6],m=n[1],b=n[4],x=n[7],v=n[2],_=n[5],w=n[8];return i[0]=o*p+s*m+a*v,i[3]=o*g+s*b+a*_,i[6]=o*y+s*x+a*w,i[1]=c*p+u*m+h*v,i[4]=c*g+u*b+h*_,i[7]=c*y+u*x+h*w,i[2]=l*p+f*m+d*v,i[5]=l*g+f*b+d*_,i[8]=l*y+f*x+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8];return e*o*u-e*s*c-r*i*u+r*s*a+n*i*c-n*o*a}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],h=u*o-s*c,l=s*a-u*i,f=c*i-o*a,d=e*h+r*l+n*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return t[0]=h*p,t[1]=(n*c-u*r)*p,t[2]=(s*r-n*o)*p,t[3]=l*p,t[4]=(u*e-n*a)*p,t[5]=(n*i-s*e)*p,t[6]=f*p,t[7]=(r*a-c*e)*p,t[8]=(o*e-r*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,n,i,o,s){const a=Math.cos(i),c=Math.sin(i);return this.set(r*a,r*c,-r*(a*o+c*s)+o+t,-n*c,n*a,-n*(-c*o+a*s)+s+e,0,0,1),this}scale(t,e){return x("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(z.makeScale(t,e)),this}rotate(t){return x("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(z.makeRotation(-t)),this}translate(t,e){return x("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(z.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,r=t.elements;for(let t=0;t<9;t++)if(e[t]!==r[t])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;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}clone(){return(new this.constructor).fromArray(this.elements)}}const z=new E;class A{static{A.prototype.isVector4=!0}constructor(t=0,e=0,r=0,n=1){this.x=t,this.y=e,this.z=r,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,n,i;const o=.01,s=.1,a=t.elements,c=a[0],u=a[4],h=a[8],l=a[1],f=a[5],d=a[9],p=a[2],g=a[6],y=a[10];if(Math.abs(u-l)<o&&Math.abs(h-p)<o&&Math.abs(d-g)<o){if(Math.abs(u+l)<s&&Math.abs(h+p)<s&&Math.abs(d+g)<s&&Math.abs(c+f+y-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(f+1)/2,m=(y+1)/2,b=(u+l)/4,x=(h+p)/4,v=(d+g)/4;return t>a&&t>m?t<o?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(t),n=b/r,i=x/r):a>m?a<o?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(a),r=b/n,i=v/n):m<o?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(m),r=x/i,n=v/i),this.set(r,n,i,e),this}let m=Math.sqrt((g-d)*(g-d)+(h-p)*(h-p)+(l-u)*(l-u));return Math.abs(m)<.001&&(m=1),this.x=(g-d)/m,this.y=(h-p)/m,this.z=(l-u)/m,this.w=Math.acos((c+f+y-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=v(this.x,t.x,e.x),this.y=v(this.y,t.y,e.y),this.z=v(this.z,t.z,e.z),this.w=v(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=v(this.x,t,e),this.y=v(this.y,t,e),this.z=v(this.z,t,e),this.w=v(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(v(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,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.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class T{static{T.prototype.isMatrix4=!0}constructor(t,e,r,n,i,o,s,a,c,u,h,l,f,d,p,g){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,h,l,f,d,p,g)}set(t,e,r,n,i,o,s,a,c,u,h,l,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]=h,y[14]=l,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 T).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.determinantAffine()?(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.determinantAffine())return this.identity();const e=this.elements,r=t.elements,n=1/O.setFromMatrixColumn(t,0).length(),i=1/O.setFromMatrixColumn(t,1).length(),o=1/O.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),h=Math.sin(i);if("XYZ"===t.order){const t=o*u,r=o*h,n=s*u,i=s*h;e[0]=a*u,e[4]=-a*h,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*h,n=c*u,i=c*h;e[0]=t+i*s,e[4]=n*s-r,e[8]=o*c,e[1]=o*h,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*h,n=c*u,i=c*h;e[0]=t-i*s,e[4]=-o*h,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*h,n=s*u,i=s*h;e[0]=a*u,e[4]=n*c-r,e[8]=t*c+i,e[1]=a*h,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*h,e[8]=n*h+r,e[1]=h,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=r*h+n,e[10]=t-i*h}else if("XZY"===t.order){const t=o*a,r=o*c,n=s*a,i=s*c;e[0]=a*u,e[4]=-h,e[8]=c*u,e[1]=t*h+i,e[5]=o*u,e[9]=r*h-n,e[2]=n*h-r,e[6]=s*u,e[10]=i*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(j,t,P)}lookAt(t,e,r){const n=this.elements;return N.subVectors(t,e),0===N.lengthSq()&&(N.z=1),N.normalize(),R.crossVectors(r,N),0===R.lengthSq()&&(1===Math.abs(r.z)?N.x+=1e-4:N.z+=1e-4,N.normalize(),R.crossVectors(r,N)),R.normalize(),C.crossVectors(N,R),n[0]=R.x,n[4]=C.x,n[8]=N.x,n[1]=R.y,n[5]=C.y,n[9]=N.y,n[2]=R.z,n[6]=C.z,n[10]=N.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],h=r[5],l=r[9],f=r[13],d=r[2],p=r[6],g=r[10],y=r[14],m=r[3],b=r[7],x=r[11],v=r[15],_=n[0],w=n[4],k=n[8],M=n[12],S=n[1],E=n[5],z=n[9],A=n[13],T=n[2],O=n[6],I=n[10],j=n[14],P=n[3],R=n[7],C=n[11],N=n[15];return i[0]=o*_+s*S+a*T+c*P,i[4]=o*w+s*E+a*O+c*R,i[8]=o*k+s*z+a*I+c*C,i[12]=o*M+s*A+a*j+c*N,i[1]=u*_+h*S+l*T+f*P,i[5]=u*w+h*E+l*O+f*R,i[9]=u*k+h*z+l*I+f*C,i[13]=u*M+h*A+l*j+f*N,i[2]=d*_+p*S+g*T+y*P,i[6]=d*w+p*E+g*O+y*R,i[10]=d*k+p*z+g*I+y*C,i[14]=d*M+p*A+g*j+y*N,i[3]=m*_+b*S+x*T+v*P,i[7]=m*w+b*E+x*O+v*R,i[11]=m*k+b*z+x*I+v*C,i[15]=m*M+b*A+x*j+v*N,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],h=t[6],l=t[10],f=t[14],d=t[3],p=t[7],g=t[11],y=t[15],m=a*f-c*l,b=s*f-c*h,x=s*l-a*h,v=o*f-c*u,_=o*l-a*u,w=o*h-s*u;return e*(p*m-g*b+y*x)-r*(d*m-g*v+y*_)+n*(d*b-p*v+y*w)-i*(d*x-p*_+g*w)}determinantAffine(){const t=this.elements,e=t[0],r=t[4],n=t[8],i=t[1],o=t[5],s=t[9],a=t[2],c=t[6],u=t[10];return e*(o*u-s*c)-r*(i*u-s*a)+n*(i*c-o*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,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],h=t[9],l=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,x=e*c-i*o,v=r*a-n*s,_=r*c-i*s,w=n*c-i*a,k=u*p-h*d,M=u*g-l*d,S=u*y-f*d,E=h*g-l*p,z=h*y-f*p,A=l*y-f*g,T=m*A-b*z+x*E+v*S-_*M+w*k;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/T;return t[0]=(s*A-a*z+c*E)*O,t[1]=(n*z-r*A-i*E)*O,t[2]=(p*w-g*_+y*v)*O,t[3]=(l*_-h*w-f*v)*O,t[4]=(a*S-o*A-c*M)*O,t[5]=(e*A-n*S+i*M)*O,t[6]=(g*x-d*w-y*b)*O,t[7]=(u*w-l*x+f*b)*O,t[8]=(o*z-s*S+c*k)*O,t[9]=(r*S-e*z-i*k)*O,t[10]=(d*_-p*x+y*m)*O,t[11]=(h*x-u*_-f*m)*O,t[12]=(s*M-o*E-a*k)*O,t[13]=(e*E-r*M+n*k)*O,t[14]=(p*b-d*v-g*m)*O,t[15]=(u*v-h*b+l*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,h=s+s,l=i*c,f=i*u,d=i*h,p=o*u,g=o*h,y=s*h,m=a*c,b=a*u,x=a*h,v=r.x,_=r.y,w=r.z;return n[0]=(1-(p+y))*v,n[1]=(f+x)*v,n[2]=(d-b)*v,n[3]=0,n[4]=(f-x)*_,n[5]=(1-(l+y))*_,n[6]=(g+m)*_,n[7]=0,n[8]=(d+b)*w,n[9]=(g-m)*w,n[10]=(1-(l+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.determinantAffine();if(0===i)return r.set(1,1,1),e.identity(),this;let o=O.set(n[0],n[1],n[2]).length();const s=O.set(n[4],n[5],n[6]).length(),a=O.set(n[8],n[9],n[10]).length();i<0&&(o=-o),I.copy(this);const c=1/o,u=1/s,h=1/a;return I.elements[0]*=c,I.elements[1]*=c,I.elements[2]*=c,I.elements[4]*=u,I.elements[5]*=u,I.elements[6]*=u,I.elements[8]*=h,I.elements[9]*=h,I.elements[10]*=h,e.setFromRotationMatrix(I),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),h=2*i/(r-n),l=(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]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,n,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),h=2/(r-n),l=-(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]=l,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,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 O=new k,I=new T,j=new k(0,0,0),P=new k(1,1,1),R=new k,C=new k,N=new k,F=new T,D=new w;class L{constructor(t=0,e=0,r=0,n=L.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],h=n[2],l=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(v(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(l,c),this._z=0);break;case"YXZ":this._x=Math.asin(-v(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(v(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-v(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(l,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(v(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-v(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(l,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:b("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===r&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return F.makeRotationFromQuaternion(t),this.setFromRotationMatrix(F,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}L.DEFAULT_ORDER="XYZ";class Y{static{Y.prototype.isMatrix2=!0}constructor(t,e,r,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,r,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let r=0;r<4;r++)this.elements[r]=t[r+e];return this}set(t,e,r,n){const i=this.elements;return i[0]=t,i[2]=e,i[1]=r,i[3]=n,this}}function $(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?b("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const U=new L;function q(t,e){U.setFromQuaternion(new w(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=U.x,t.rotation=-U.y,t.rotationY=U.z}const W="_transferSlotId";const B=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=B);const G=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,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}};function X(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const H=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return B.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const r=e?.component,n=r?.app??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,G.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const r=B.tick(e),n=B.now;if(this._ticking=!0,G.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(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;if("undefined"==typeof requestAnimationFrame)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=X(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(X(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(B.now),isRunning:this.isRunning,speed:B.speed,paused:B.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let V=null;const Z=[],Q=new Set;function J(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const K={beginContext(t){V=t},endContext(){V=null},current:()=>V,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??J(t.component),componentType:t.componentType??(r=t.component,r?.state?.type??r?.type),atSimMs:B.now,args:t.args,result:t.result,error:t.error};var r;V?V.pushTrace(e):(Z.push(e),Z.length>500&&Z.shift(),Q.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...Z],onStandalone:t=>(Q.add(t),()=>{Q.delete(t)}),clearStandalone(){Z.length=0}};function tt(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const r=String(e);return r.length>0?r:void 0}function et(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},r=t.sourceId??tt(t.source),n=t.targetId??tt(t.target),i=t.carrierId??tt(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 rt=1;class nt{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+rt++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:B.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??B.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return it.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=B.now;const t=this.target.canAccept?.(this.carrier);if(t&&t.ok)this._slot=t.slot;else{if(t&&!t.ok&&"no-slots-defined"!==t.reason)return this._rejectReason=t.reason,this._rollback();if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier))return this._rejectReason="cannot-receive",this._rollback();this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source}),this._reservation)?(this._timeline.planEndAt=B.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",it.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=B.now;const t=this._buildReceipt();return it.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){K.beginContext(this),K.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{return await this._executeImpl()}finally{K.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}executeSync(){K.beginContext(this),K.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{K.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",it.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:tt(this.source),targetId:tt(this.target),carrierId:tt(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const it=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??tt(t.source),r=t.targetId??tt(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){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=it);let ot=1;function st(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const at={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class ct{constructor(t=at){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+ot++},r=(this._byResource.get(e.resource)??[]).filter(t=>st(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=>st(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const 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 ut=new ct;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=ut);class ht{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,r=1/0;for(const n of this.nodes.values()){const i=lt(n.position,t);i<r&&(r=i,e=n)}return e}}function lt(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 ft(t,e){return Math.sqrt(lt(t,e))}function dt(t,e,r={}){const n=new ht,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+=ft(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,h=n.nodes.get(t.endNodeId).position;a+=Math.min(lt(o,i),lt(o,h)),c+=Math.min(lt(s,i),lt(s,h)),u++}if(0===u)continue;const h=a<c?i.startNodeId:i.endNodeId;e.push({laneId:r,nodeId:h,pos:n.nodes.get(h).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=ft(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 pt(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,h=new Set,l={nodeId:e,gScore:0,fScore:a(e)};c.set(e,l),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),h.add(e);for(const r of t.edgesFrom(e)){if(h.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 gt(t,e,r=0,n){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:r,metadata:n}))}const yt=.5;function mt(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function bt(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,h=(t.x+e.x)/2-c*(i/o)*u,l=(t.y+e.y)/2-c*-(n/o)*u;return{cx:h,cy:l,radius:a,startAngle:Math.atan2(t.y-l,t.x-h),endAngle:Math.atan2(e.y-l,e.x-h),clockwise:r<0}}function xt(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,h=Math.abs(u)>=1e-6?u:n;return{x:(t.x+e.x)/2+a*h,y:(t.y+e.y)/2+c*h,perpX:a,perpY:c}}function vt(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 h=(r.x-c)*s+(r.y-u)*a;if(Math.abs(h)<.5)return 0;return h>o&&(h=o),h<-o&&(h=-o),h}function _t(t,e){const r=t.radius,n=Number.isFinite(e)?e:0;return null!=r&&Number.isFinite(r)?Math.max(0,r):Math.max(0,n)}function wt(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,h=Math.sqrt(c*c+u*u);if(0===h)return null;const l=o/a+c/h,f=s/a+u/h,d=Math.sqrt(l*l+f*f);if(d<1e-9)return null;const p=l/d,g=f/d,y=Math.max(n,i);return{x:e.x+p*y,y:e.y+g*y,bisectorX:p,bisectorY:g}}function kt(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 h=i/s+a/u,l=o/s+c/u,f=Math.sqrt(h*h+l*l);if(f<1e-9)return 0;const d=h/f,p=l/f,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 Mt(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 St={closed:!0,round:0,divisions:24};class Et{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],h=u.x-c.x,l=u.y-c.y;return{x:c.x+h*a,y:c.y+l*a,theta:0===h&&0===l?0:Math.atan2(l,h)}}}function zt(t,e={}){const r={...St,...e},n=t.length;if(0===n)return new Et([],r.closed);if(1===n)return new Et([{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 h=a&&u?_t(c,r.round):0;let l,f,d,p;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,r=Math.min(h,t/2);l=Math.sin(e)*r+c.x,f=Math.cos(e)*r+c.y}else l=c.x,f=c.y;if(u){const t=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2),e=0!==t?Math.atan2(u.x-c.x,u.y-c.y):0,r=Math.min(h,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(l,f),h>0&&a&&u)for(let t=1;t<=r.divisions;t++){const e=t/r.divisions,n=1-e;o(n*n*l+2*n*e*c.x+e*e*d,n*n*f+2*n*e*c.y+e*e*p)}else l===d&&f===p||o(d,p);if(u&&mt(c)){const t=_t(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=bt({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 Et(i,r.closed)}function At(t,e){return zt(t,e).length}function Tt(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function Ot(t){if(Tt(t)){const e=t.capacity(),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 It{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function jt(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const r=e.onFull(()=>t.pauseEmit()),n=e.onAvailable(()=>t.resumeEmit());return Ot(e).isFull&&t.pauseEmit(),()=>{r?.(),n?.()}}class Pt{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}}function Rt(t,e,r,n,i,o,s){const a=r.w,c=r.h,u=n.w,h=n.h,l=n.d,f=[],d=u+i,p=h+i,g=Math.max(1,Math.floor((a+i)/d)),y=Math.max(1,Math.floor((c+i)/p)),m=g*y,b=o&&o>0?Math.floor(o):4;if("row"===t||"column"===t){const r=s?.advanceAlongX??!1,n=s?.reverse??!1,i=r?g:y,o=r?y:g,u=(t,e,n)=>((t,e,r)=>f.push({x:-a/2+(t+.5)*d,y:r*l+l/2,z:-c/2+(e+.5)*p}))(r?t:e,r?e:t,n);let h=0;for(let r=0;r<i&&h<e;r++){const s=n?i-1-r:r;if("column"===t)for(let t=0;t<o&&h<e;t++)for(let r=0;r<b&&h<e;r++)u(s,t,r),h++;else for(let t=0;t<b&&h<e;t++)for(let r=0;r<o&&h<e;r++)u(s,r,t),h++}return f}if("pyramid"===t){let t=e,r=0;for(;t>0;){const e=Math.max(1,g-r),n=Math.max(1,y-r),i=e*n,s=Math.min(t,i);for(let t=0;t<s;t++){const i=t%e,o=Math.floor(t/e),s=-a/2+(i+(g-e)/2+.5)*d,u=-c/2+(o+(y-n)/2+.5)*p;f.push({x:s,y:r*l+l/2,z:u})}if(t-=s,r++,1===e&&1===n){for(let e=0;e<t;e++)f.push({x:0,y:(r+e)*l+l/2,z:0});break}if(o&&r>=o)break}return f}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let r=0;r<e;r++){const e=Math.floor(r/m),n=r%m,i=n%g,s=Math.floor(n/g),y=(t(2*r)-.5)*u*.2,b=(t(2*r+1)-.5)*h*.2,x=-a/2+(i+.5)*d+y,v=-c/2+(s+.5)*p+b;if(f.push({x:x,y:e*l+l/2,z:v}),o&&e>=o-1&&n===m-1)break}return f}for(let r=0;r<e;r++){const e=Math.floor(r/m);if(o&&e>=o)break;const n=r%m,i=n%g,s=Math.floor(n/g);let u=-a/2+(i+.5)*d;const h=-c/2+(s+.5)*p;"staggered"===t&&e%2==1&&(u+=d/2),f.push({x:u,y:e*l+l/2,z:h})}return f}class Ct{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,r,n={}){const i=n.gap??this.defaults.gap??0,o=n.heightLimit??this.defaults.heightLimit,s=n.fill??this.defaults.fill;return Rt(this.pattern,t,e,r,i,o,s).map(t=>({position:t}))}}class Nt{constructor(t,e,r={}){this.cols=t,this.rows=e,this.defaults=r}layout(t,e,r,n={}){const i=Math.max(1,this.cols),o=Math.max(1,this.rows),s=i*o,a=n.gap??this.defaults.gap??0,c=r.w+a,u=r.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/s),n=e%s,a=n%i,l=Math.floor(n/i);h.push({position:{x:(a-(i-1)/2)*c,z:(l-(o-1)/2)*u,y:t*r.d+r.d/2}})}return h}}class Ft{constructor(t=.1,e=!1,r=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=r}grid(t,e){const r=e.w*this.gapRatio,n=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-r)/(e.w+r))),rows:Math.max(1,Math.floor((t.h-n)/(e.h+n))),pitchX:e.w+r,pitchZ:e.h+n}}capacity(t,e,r){const{cols:n,rows:i}=this.grid(t,e);return n*i*Math.max(1,Math.floor(r))}layout(t,e,r,n={}){const{cols:i,rows:o,pitchX:s,pitchZ:a}=this.grid(e,r),c=r.d+r.d*this.gapRatio,u=null!=n.heightLimit?Math.max(1,Math.floor(n.heightLimit)):1/0,h=Number.isFinite(u),l=this.sliceFirst&&h,f=i*o,d=i*(h?u:1),p=i*o*(h?u:t),g=Math.min(t,p),y=[];for(let t=0;t<g;t++){let e,n,u;if(l){const r=Math.floor(t/d),o=t%d;e=o%i,u=Math.floor(o/i),n=r}else{u=Math.floor(t/f);const r=t%f;e=r%i,n=Math.floor(r/i)}this.fillFromFar&&(n=o-1-n),y.push({position:{x:(e-(i-1)/2)*s,z:(n-(o-1)/2)*a,y:u*c+r.d/2}})}return y}}function Dt(t,e,r,n=0){for(let i=0;i<e.length;i++){const o=e[i],s=r[i];o&&s&&(o.parent!==t&&t.attach(o),o.position.set(s.position.x,n+s.position.y,s.position.z),s.rotation?o.quaternion.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w):o.quaternion.identity())}}function Lt(t,e,r,n=.12){const i=e.left+e.width/2,o=e.top+e.height/2,s=Math.min(r.w,r.h)*n,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let n=a.get(t);n||(n={x:i+e.position.x-r.w/2+s,y:o+e.position.z-r.h/2+s,w:r.w-2*s,h:r.h-2*s,count:0},a.set(t,n)),n.count++}return[...a.values()]}function Yt(t,e){return t===e||t!=t&&e!=e}function $t(t,e){for(var r=t.length;r--;)if(Yt(t[r][0],e))return r;return-1}var Ut=Array.prototype.splice;function qt(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])}}qt.prototype.clear=function(){this.__data__=[],this.size=0},qt.prototype.delete=function(t){var e=this.__data__,r=$t(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ut.call(e,r,1),--this.size,!0)},qt.prototype.get=function(t){var e=this.__data__,r=$t(e,t);return r<0?void 0:e[r][1]},qt.prototype.has=function(t){return $t(this.__data__,t)>-1},qt.prototype.set=function(t,e){var r=this.__data__,n=$t(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Wt="object"==typeof global&&global&&global.Object===Object&&global,Bt="object"==typeof self&&self&&self.Object===Object&&self,Gt=Wt||Bt||Function("return this")(),Xt=Gt.Symbol,Ht=Object.prototype,Vt=Ht.hasOwnProperty,Zt=Ht.toString,Qt=Xt?Xt.toStringTag:void 0;var Jt=Object.prototype.toString;var Kt=Xt?Xt.toStringTag:void 0;function te(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Kt&&Kt in Object(t)?function(t){var e=Vt.call(t,Qt),r=t[Qt];try{t[Qt]=void 0;var n=!0}catch(t){}var i=Zt.call(t);return n&&(e?t[Qt]=r:delete t[Qt]),i}(t):function(t){return Jt.call(t)}(t)}function ee(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function re(t){if(!ee(t))return!1;var e=te(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var ne,ie=Gt["__core-js_shared__"],oe=(ne=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"";var se=Function.prototype.toString;function ae(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ce=/^\[object .+?Constructor\]$/,ue=Function.prototype,he=Object.prototype,le=ue.toString,fe=he.hasOwnProperty,de=RegExp("^"+le.call(fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pe(t){return!(!ee(t)||(e=t,oe&&oe in e))&&(re(t)?de:ce).test(ae(t));var e}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return pe(r)?r:void 0}var ye=ge(Gt,"Map"),me=ge(Object,"create");var be=Object.prototype.hasOwnProperty;var xe=Object.prototype.hasOwnProperty;function ve(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 _e(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 we(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])}}ve.prototype.clear=function(){this.__data__=me?me(null):{},this.size=0},ve.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ve.prototype.get=function(t){var e=this.__data__;if(me){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return be.call(e,t)?e[t]:void 0},ve.prototype.has=function(t){var e=this.__data__;return me?void 0!==e[t]:xe.call(e,t)},ve.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=me&&void 0===e?"__lodash_hash_undefined__":e,this},we.prototype.clear=function(){this.size=0,this.__data__={hash:new ve,map:new(ye||qt),string:new ve}},we.prototype.delete=function(t){var e=_e(this,t).delete(t);return this.size-=e?1:0,e},we.prototype.get=function(t){return _e(this,t).get(t)},we.prototype.has=function(t){return _e(this,t).has(t)},we.prototype.set=function(t,e){var r=_e(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function ke(t){var e=this.__data__=new qt(t);this.size=e.size}ke.prototype.clear=function(){this.__data__=new qt,this.size=0},ke.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ke.prototype.get=function(t){return this.__data__.get(t)},ke.prototype.has=function(t){return this.__data__.has(t)},ke.prototype.set=function(t,e){var r=this.__data__;if(r instanceof qt){var n=r.__data__;if(!ye||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new we(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 we;++e<r;)this.add(t[e])}function Se(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 Ee(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),h=o.get(e);if(u&&h)return u==e&&h==t;var l=-1,f=!0,d=2&r?new Me:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var p=t[l],g=e[l];if(n)var y=s?n(g,p,l,e,t,o):n(p,g,l,t,e,o);if(void 0!==y){if(y)continue;f=!1;break}if(d){if(!Se(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 ze=Gt.Uint8Array;function Ae(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Te(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Oe=Xt?Xt.prototype:void 0,Ie=Oe?Oe.valueOf:void 0;function je(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}var Pe=Array.isArray;function Re(){return[]}var Ce=Object.prototype.propertyIsEnumerable,Ne=Object.getOwnPropertySymbols,Fe=Ne?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}(Ne(t),function(e){return Ce.call(t,e)}))}:Re;function De(t){return null!=t&&"object"==typeof t}function Le(t){return De(t)&&"[object Arguments]"==te(t)}var Ye=Object.prototype,$e=Ye.hasOwnProperty,Ue=Ye.propertyIsEnumerable,qe=Le(function(){return arguments}())?Le:function(t){return De(t)&&$e.call(t,"callee")&&!Ue.call(t,"callee")};var We="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=We&&"object"==typeof module&&module&&!module.nodeType&&module,Ge=Be&&Be.exports===We?Gt.Buffer:void 0,Xe=(Ge?Ge.isBuffer:void 0)||function(){return!1},He=/^(?:0|[1-9]\d*)$/;function Ve(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&He.test(t))&&t>-1&&t%1==0&&t<e}function Ze(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Qe={};function Je(t){return function(e){return t(e)}}Qe["[object Float32Array]"]=Qe["[object Float64Array]"]=Qe["[object Int8Array]"]=Qe["[object Int16Array]"]=Qe["[object Int32Array]"]=Qe["[object Uint8Array]"]=Qe["[object Uint8ClampedArray]"]=Qe["[object Uint16Array]"]=Qe["[object Uint32Array]"]=!0,Qe["[object Arguments]"]=Qe["[object Array]"]=Qe["[object ArrayBuffer]"]=Qe["[object Boolean]"]=Qe["[object DataView]"]=Qe["[object Date]"]=Qe["[object Error]"]=Qe["[object Function]"]=Qe["[object Map]"]=Qe["[object Number]"]=Qe["[object Object]"]=Qe["[object RegExp]"]=Qe["[object Set]"]=Qe["[object String]"]=Qe["[object WeakMap]"]=!1;var Ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,tr=Ke&&"object"==typeof module&&module&&!module.nodeType&&module,er=tr&&tr.exports===Ke&&Wt.process,rr=function(){try{var t=tr&&tr.require&&tr.require("util").types;return t||er&&er.binding&&er.binding("util")}catch(t){}}(),nr=rr&&rr.isTypedArray,ir=nr?Je(nr):function(t){return De(t)&&Ze(t.length)&&!!Qe[te(t)]},or=Object.prototype.hasOwnProperty;function sr(t,e){var r=Pe(t),n=!r&&qe(t),i=!r&&!n&&Xe(t),o=!r&&!n&&!i&&ir(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&&!or.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ve(u,c))||a.push(u);return a}var ar=Object.prototype;function cr(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ar)}function ur(t,e){return function(r){return t(e(r))}}var hr=ur(Object.keys,Object),lr=Object.prototype.hasOwnProperty;function fr(t){if(!cr(t))return hr(t);var e=[];for(var r in Object(t))lr.call(t,r)&&"constructor"!=r&&e.push(r);return e}function dr(t){return null!=t&&Ze(t.length)&&!re(t)}function pr(t){return dr(t)?sr(t):fr(t)}function gr(t){return function(t,e,r){var n=e(t);return Pe(t)?n:je(n,r(t))}(t,pr,Fe)}var yr=Object.prototype.hasOwnProperty;var mr=ge(Gt,"DataView"),br=ge(Gt,"Promise"),xr=ge(Gt,"Set"),vr=ge(Gt,"WeakMap"),_r="[object Map]",wr="[object Promise]",kr="[object Set]",Mr="[object WeakMap]",Sr="[object DataView]",Er=ae(mr),zr=ae(ye),Ar=ae(br),Tr=ae(xr),Or=ae(vr),Ir=te;(mr&&Ir(new mr(new ArrayBuffer(1)))!=Sr||ye&&Ir(new ye)!=_r||br&&Ir(br.resolve())!=wr||xr&&Ir(new xr)!=kr||vr&&Ir(new vr)!=Mr)&&(Ir=function(t){var e=te(t),r="[object Object]"==e?t.constructor:void 0,n=r?ae(r):"";if(n)switch(n){case Er:return Sr;case zr:return _r;case Ar:return wr;case Tr:return kr;case Or:return Mr}return e});var jr="[object Arguments]",Pr="[object Array]",Rr="[object Object]",Cr=Object.prototype.hasOwnProperty;function Nr(t,e,r,n,i,o){var s=Pe(t),a=Pe(e),c=s?Pr:Ir(t),u=a?Pr:Ir(e),h=(c=c==jr?Rr:c)==Rr,l=(u=u==jr?Rr:u)==Rr,f=c==u;if(f&&Xe(t)){if(!Xe(e))return!1;s=!0,h=!1}if(f&&!h)return o||(o=new ke),s||ir(t)?Ee(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 ze(t),new ze(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Yt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ae;case"[object Set]":var c=1&n;if(a||(a=Te),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var h=Ee(a(t),a(e),n,i,o,s);return s.delete(t),h;case"[object Symbol]":if(Ie)return Ie.call(t)==Ie.call(e)}return!1}(t,e,c,r,n,i,o);if(!(1&r)){var d=h&&Cr.call(t,"__wrapped__"),p=l&&Cr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,y=p?e.value():e;return o||(o=new ke),i(g,y,r,n,o)}}return!!f&&(o||(o=new ke),function(t,e,r,n,i,o){var s=1&r,a=gr(t),c=a.length;if(c!=gr(e).length&&!s)return!1;for(var u=c;u--;){var h=a[u];if(!(s?h in e:yr.call(e,h)))return!1}var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var g=t[h=a[u]],y=e[h];if(n)var m=s?n(y,g,h,e,t,o):n(g,y,h,t,e,o);if(!(void 0===m?g===y||i(g,y,r,n,o):m)){d=!1;break}p||(p="constructor"==h)}if(d&&!p){var b=t.constructor,x=e.constructor;b==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof x&&x instanceof x||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,r,n,i,o))}function Fr(t,e,r,n,i){return t===e||(null==t||null==e||!De(t)&&!De(e)?t!=t&&e!=e:Nr(t,e,r,n,Fr,i))}var Dr=function(){try{var t=ge(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Lr(t,e,r){"__proto__"==e&&Dr?Dr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Yr=Object.prototype.hasOwnProperty;function $r(t,e,r){var n=t[e];Yr.call(t,e)&&Yt(n,r)&&(void 0!==r||e in t)||Lr(t,e,r)}function Ur(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?Lr(r,a,c):$r(r,a,c)}return r}function qr(t){return t}function Wr(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 Br=Math.max;function Gr(t){return function(){return t}}var Xr=Dr?function(t,e){return Dr(t,"toString",{configurable:!0,enumerable:!1,value:Gr(e),writable:!0})}:qr,Hr=Date.now;var Vr,Zr,Qr,Jr=(Vr=Xr,Zr=0,Qr=0,function(){var t=Hr(),e=16-(t-Qr);if(Qr=t,e>0){if(++Zr>=800)return arguments[0]}else Zr=0;return Vr.apply(void 0,arguments)});function Kr(t,e){return Jr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=Br(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),Wr(t,this,a)}}(t,e,qr),t+"")}function tn(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?dr(r)&&Ve(e,r.length):"string"==n&&e in r)&&Yt(r[e],t)}var en=Object.prototype.hasOwnProperty;function rn(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=cr(t),r=[];for(var n in t)("constructor"!=n||!e&&en.call(t,n))&&r.push(n);return r}function nn(t){return dr(t)?sr(t,!0):rn(t)}var on,sn=(on=function(t,e,r,n){Ur(e,nn(e),t,n)},Kr(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=on.length>3&&"function"==typeof i?(n--,i):void 0,o&&tn(e[0],e[1],o)&&(i=n<3?void 0:i,n=1),t=Object(t);++r<n;){var s=e[r];s&&on(t,s,r,i)}return t})),an=ur(Object.getPrototypeOf,Object),cn=Function.prototype,un=Object.prototype,hn=cn.toString,ln=un.hasOwnProperty,fn=hn.call(Object);function dn(t){if(!De(t))return!1;var e=te(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!De(t)||"[object Object]"!=te(t))return!1;var e=an(t);if(null===e)return!0;var r=ln.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&hn.call(r)==fn}(t)}var pn=Kr(function(t,e){try{return Wr(t,void 0,e)}catch(t){return dn(t)?t:new Error(t)}});function gn(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 yn=Object.prototype,mn=yn.hasOwnProperty;function bn(t,e,r,n){return void 0===t||Yt(t,yn[r])&&!mn.call(n,r)?e:t}var xn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function vn(t){return"\\"+xn[t]}var _n=/<%=([\s\S]+?)%>/g;var wn,kn=(wn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},function(t){return null==wn?void 0:wn[t]});function Mn(t){return"symbol"==typeof t||De(t)&&"[object Symbol]"==te(t)}var Sn=Xt?Xt.prototype:void 0,En=Sn?Sn.toString:void 0;function zn(t){if("string"==typeof t)return t;if(Pe(t))return gn(t,zn)+"";if(Mn(t))return En?En.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function An(t){return null==t?"":zn(t)}var Tn=/[&<>"']/g,On=RegExp(Tn.source);var In={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:_n,variable:"",imports:{_:{escape:function(t){return(t=An(t))&&On.test(t)?t.replace(Tn,kn):t}}}},jn=/\b__p \+= '';/g,Pn=/\b(__p \+=) '' \+/g,Rn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Cn=/[()=,{}\[\]\/\s]/,Nn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fn=/($^)/,Dn=/['\n\r\u2028\u2029\\]/g,Ln=Object.prototype.hasOwnProperty;var Yn="object"==typeof exports&&exports&&!exports.nodeType&&exports,$n=Yn&&"object"==typeof module&&module&&!module.nodeType&&module,Un=$n&&$n.exports===Yn?Gt.Buffer:void 0,qn=Un?Un.allocUnsafe:void 0;var Wn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)je(e,Fe(t)),t=an(t);return e}:Re;var Bn=Object.prototype.hasOwnProperty;var Gn=/\w*$/;var Xn=Xt?Xt.prototype:void 0,Hn=Xn?Xn.valueOf:void 0;function Vn(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 ze(a).set(new ze(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,Gn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Hn?Object(Hn.call(n)):{}}}var Zn=Object.create,Qn=function(){function t(){}return function(e){if(!ee(e))return{};if(Zn)return Zn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();var Jn=rr&&rr.isMap,Kn=Jn?Je(Jn):function(t){return De(t)&&"[object Map]"==Ir(t)};var ti=rr&&rr.isSet,ei=ti?Je(ti):function(t){return De(t)&&"[object Set]"==Ir(t)},ri="[object Arguments]",ni="[object Function]",ii="[object Object]",oi={};function si(t,e,r,n,i,o){var s,a=2&e;if(void 0!==s)return s;if(!ee(t))return t;var c=Pe(t);if(c)return s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Bn.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=Ir(t),h=u==ni||"[object GeneratorFunction]"==u;if(Xe(t))return function(t){var e=t.length,r=qn?qn(e):new t.constructor(e);return t.copy(r),r}(t);if(u==ii||u==ri||h&&!i)return s=h?{}:function(t){return"function"!=typeof t.constructor||cr(t)?{}:Qn(an(t))}(t),a?function(t,e){return Ur(t,Wn(t),e)}(t,function(t,e){return t&&Ur(e,nn(e),t)}(s,t)):function(t,e){return Ur(t,Fe(t),e)}(t,function(t,e){return t&&Ur(e,pr(e),t)}(s,t));if(!oi[u])return i?t:{};s=Vn(t,u),o||(o=new ke);var l=o.get(t);if(l)return l;o.set(t,s),ei(t)?t.forEach(function(n){s.add(si(n,e,r,n,t,o))}):Kn(t)&&t.forEach(function(n,i){s.set(i,si(n,e,r,i,t,o))});var f=c?void 0:gr(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(f||t,function(n,i){f&&(n=t[i=n]),$r(s,i,si(n,e,r,i,t,o))}),s}oi[ri]=oi["[object Array]"]=oi["[object ArrayBuffer]"]=oi["[object DataView]"]=oi["[object Boolean]"]=oi["[object Date]"]=oi["[object Float32Array]"]=oi["[object Float64Array]"]=oi["[object Int8Array]"]=oi["[object Int16Array]"]=oi["[object Int32Array]"]=oi["[object Map]"]=oi["[object Number]"]=oi[ii]=oi["[object RegExp]"]=oi["[object Set]"]=oi["[object String]"]=oi["[object Symbol]"]=oi["[object Uint8Array]"]=oi["[object Uint8ClampedArray]"]=oi["[object Uint16Array]"]=oi["[object Uint32Array]"]=!0,oi["[object Error]"]=oi[ni]=oi["[object WeakMap]"]=!1;function ai(t){return si(t,4)}var ci=/\s/;var ui=/^\s+/;function hi(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ci.test(t.charAt(e)););return e}(t)+1).replace(ui,""):t}var li=/^[-+]0x[0-9a-f]+$/i,fi=/^0b[01]+$/i,di=/^0o[0-7]+$/i,pi=parseInt;var gi=1/0;function yi(t){return t?(t=function(t){if("number"==typeof t)return t;if(Mn(t))return NaN;if(ee(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ee(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=hi(t);var r=fi.test(t);return r||di.test(t)?pi(t.slice(2),r?2:8):li.test(t)?NaN:+t}(t))===gi||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function mi(t,e){var r;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=yi(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 bi=Object.prototype.hasOwnProperty;function xi(t){if(null==t)return!0;if(dr(t)&&(Pe(t)||"string"==typeof t||"function"==typeof t.splice||Xe(t)||ir(t)||qe(t)))return!t.length;var e=Ir(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(cr(t))return!fr(t).length;for(var r in t)if(bi.call(t,r))return!1;return!0}let vi=0;function _i(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 wi(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function ki(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Mi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function Si(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Ei(t){if(this.__collection__)return this.__collection__[t]}function zi(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Ai(t){return this.__collection__?this.__collection__.indexOf(t):-1}function Ti(){return this.__collection__?this.__collection__.length:0}function Oi(){this.__collection__=[]}function Ii(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function ji(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 Pi(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 Ri(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 Ci{constructor(){this.__collection__=[],this.insertAt=wi,this.append=ki,this.prepend=Mi,this.remove=Si,this.getAt=Ei,this.forEach=zi,this.indexOf=Ai,this.size=Ti,this.clear=Oi,this.moveForward=Ii,this.moveBackward=ji,this.moveToHead=Pi,this.moveToTail=Ri}}const Ni=/\s+/;function Fi(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(Ni.test(r)){return r.split(Ni).forEach(r=>t[e].apply(t,[r].concat(n))),!1}return!0}const Di=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],Li={withEvent(){Di.forEach(t=>this[t]=Li[t])},on(t,e,r){if(!Fi(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(!Fi(this,"once",t,[e,r])||!e)return this;const n=this,i=function(t){return mi(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||!Fi(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 Ci),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&&$i(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&&Yi(r,arguments),n&&Yi(n,arguments),this},trigger(t){G.enabled&&G.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&$i(this._delegators,e),!this._listeners)return this;if(!Fi(this,"trigger",t,e))return this;const r=this._listeners[t],n=this._listeners["(all)"];return r&&Yi(r,e),n&&Yi(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||xi(o._events))&&delete this._listeningTo[t]}return this}};function Yi(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function $i(t,e){t.forEach(t=>Li.delegate.apply(t,e))}const Ui={listenTo:"on",listenToOnce:"once"};for(const t in Ui){const e=Ui[t];Li[t]=function(t,r,n){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++vi}`);return i[t._listenId]=t,n||"object"!=typeof r||(n=this),t[e](r,n,this),this}}const qi=Li.on,Wi=Li.off,Bi=Li.once,Gi=Li.trigger,Xi=Li.delegate_on,Hi=Li.delegate_off;const Vi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Zi="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 Ji(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 Ki,to={exports:{}};var eo=(Ki||(Ki=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 h(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:E(t,r,a)}),s}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f="suspendedStart",d="suspendedYield",p="executing",g="completed",y={};function m(){}function b(){}function x(){}var v={};u(v,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(I([])));w&&w!==r&&n.call(w,s)&&(v=w);var k=x.prototype=m.prototype=Object.create(v);function M(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function r(i,o,s,a){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){r("next",t,s,a)},function(t){r("throw",t,s,a)}):e.resolve(h).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 E(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=z(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=l(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 z(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,z(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=l(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 A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(t){if(null!=t){var 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=x,i(k,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=u(x,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,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},M(S.prototype),u(S.prototype,a,function(){return this}),t.AsyncIterator=S,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new S(h(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},M(k),u(k,c,"Generator"),u(k,s,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),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=I,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var 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),T(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;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(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&&Ji)return Ji(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=Ji,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),h=n%10;c=(s?" and ":"")+i[u-2],h>0?c+="-"+t(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(n<1e3){var l=Math.floor(n/100),f=n%100;c=(s?", ":"")+e[l]+" 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"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function l(t){for(var e=0;e<u.length;e++){var r=u[e];if(t>=r[0])return r[1]+l(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=h[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),v(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=l(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 h={1:"st",2:"nd",3:"rd"}[n[n.length-1]];(!h||n.length>1&&"1"===n[n.length-2])&&(h="th"),n+=h}break;case y.SEQUENCE:throw{code:"D3130",value:r.token}}return i&&(n="-"+n),n}var x=[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 v(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<x.length;r++){var n=x[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 h=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);h>0?(n.regular=!0,n.groupingSeparators={position:h,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 h=a.substring(u+1),l=h.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===l?f=h:(f=h.substring(0,l),d=h.substring(l+1));var 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=v(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 x=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;x>=2&&(c.n=x)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=v(c.presentation1)),e.push(c),i=o+1}o++}return n(i,o),r}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=864e5,E=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)*S:e-(r-1)*S},z=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)}}},A=function(t,e){return(e-t)/(7*S)+1},T=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))/S+1;break;case"F":0===(r=t.getUTCDay())&&(r=7);break;case"W":var n=z(t.getUTCFullYear(),0),i=E(n),o=Date.UTC(n.year,t.getUTCMonth(),t.getUTCDate()),s=A(i,o);if(s>52)o>=E(n.nextYear())&&(s=1);else if(s<1){var a=E(n.previousYear());s=A(a,o)}r=Math.floor(s);break;case"w":var c=z(t.getUTCFullYear(),t.getUTCMonth()),u=E(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),l=A(u,h);if(l>4)h>=E(c.nextMonth())&&(l=1);else if(l<1){var f=E(c.previousMonth());l=A(f,h)}r=Math.floor(l);break;case"X":var d=z(t.getUTCFullYear(),0),p=E(d),g=E(d.nextYear()),y=t.getTime();r=y<p?d.year-1:y>=g?d.year+1:d.year;break;case"x":var m=z(t.getUTCFullYear(),t.getUTCMonth()),b=E(m),x=m.nextMonth(),v=E(x),_=t.getTime();r=_<b?m.previousMonth().month+1:_>=v?x.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 I(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=T(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=M[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 j(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=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var n={};if("M"===t.component||"x"===t.component)M.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 P(t,e){if(void 0!==t)return j(v(e)).parse(t)}function R(t,e){var r=j(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,h=47,l={},f=1;f<i.length;f++){var d=r.parts[f-1];d.parse&&(l[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(l).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(l[t])});var m=!y(o)&&y(s),b=y(a),x=!b&&y(c);p=0,"PHhmsf".split("").forEach(function(t){return g(l[t])});var v=!y(u)&&y(h),_=(m?"YD":b?"XxwF":x?"XWF":"YMD")+(v?"Phmsf":"Hmsf"),k=this.environment.timestamp,M=!1,S=!1;if(_.split("").forEach(function(t){if(void 0===l[t])M?(l[t]=-1!=="MDd".indexOf(t)?1:0,S=!0):l[t]=T(k,t);else if(M=!0,S)throw{code:"D3136"}}),l.M>0?l.M-=1:l.M=0,m){var E=Date.UTC(l.Y,0),z=1e3*(l.d-1)*60*60*24,A=new Date(E+z);l.M=A.getUTCMonth(),l.D=A.getUTCDate()}if(b)throw{code:"D3136"};if(x)throw{code:"D3136"};v&&(l.H=12===l.h?0:l.h,1===l.P&&(l.H+=12));var O=Date.UTC(l.Y,l.M,l.D,l.H,l.m,l.s,l.f);return(l.Z||l.z)&&(O-=60*(l.Z||l.z)*1e3),O}}var C=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function N(t,e){if(void 0!==t){if(void 0===e){if(!C.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return R.call(this,t,e)}}function F(t,e,r){if(void 0!==t)return I.call(this,t,e,r)}return{formatInteger:g,parseInteger:P,fromMillis:F,toMillis:N}}();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",h=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,o=Object.create(i.prototype),a=new j(n||[]);return s(o,"_invoke",{value:A(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 x(){}function v(){}function _(){}var w={};l(w,c,function(){return this});var k=Object.getPrototypeOf,M=k&&k(k(P([])));M&&M!==r&&o.call(M,c)&&(w=M);var S=_.prototype=x.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==n(l)&&o.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(l).then(function(t){h.value=t,a(h)},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 A(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=T(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 T(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,T(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 I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(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 v.prototype=_,s(S,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,h,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(z.prototype),l(z.prototype,u,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new z(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},E(S),l(S,h,"Generator"),l(S,c,function(){return this}),l(S,"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=P,j.prototype={constructor:j,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(I),!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),I(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;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(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(q),a=i().mark(W),c=i().mark(Q),u=i().mark(ft),h=i().mark(dt),l=i().mark(pt),f=i().mark(yt),d=i().mark(Mt),p=i().mark(At),g=i().mark(It),y=o.isNumeric,m=o.isArrayOfStrings,b=o.isArrayOfNumbers,x=o.createSequence,v=o.isSequence,_=o.isFunction,w=o.isLambda,k=o.isIterable,M=o.getFunctionArity,S=o.isDeepEqual,E=o.stringToArray;function z(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function A(t){return void 0===t?0:t.length}function T(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 I(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function j(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 P(t,e,r){if(void 0!==t){var n=E(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 R(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function C(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function N(t){if(void 0!==t)return t.toLowerCase()}function F(t){if(void 0!==t)return t.toUpperCase()}function D(t){if(void 0!==t)return E(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)-D(t);if(i>0){var o=new Array(i+1).join(r);r.length>1&&(o=P(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 q(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=x(),!(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 W(t,e,r,n){var o,s,c,u,h,l,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(h=0,"string"!=typeof e){i.next=18;break}for(l=t.indexOf(e,u);-1!==l&&(void 0===n||h<n);)c+=t.substring(u,l),c+=r,u=l+e.length,h++,l=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||h<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,h++,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 B(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 G(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 X(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 H(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),h=t.indexOf(n["exponent-separator"],s.length);-1===h||h>t.length-c.length?(e=u,r=void 0):(e=u.substring(0,h),r=u.substring(h+1));var l=e.indexOf(n["decimal-separator"]);return-1===l?(i=e,o=c):(i=e.substring(0,l),o=e.substring(l+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:o,subpicture:t}},h=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 h=t.integerPart.indexOf(n.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var l="string"==typeof t.exponentPart;if(l&&t.exponentPart.length>0&&(-1!==o.indexOf(n.percent)||-1!==o.indexOf(n["per-mille"]))&&(e="D3092"),l&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},l=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(""),h=u.filter(function(t){return-1!==i.indexOf(t)}).length,l=u.filter(function(t){return-1!==i.indexOf(t)||t===n.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===l&&(f?(h=1,l=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(n.digit)&&(a=1),0===a&&0===h&&(h=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:r,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:l,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},f=c.map(u);f.forEach(h);var d,p,g,y,m=f.map(l),b=n["minus-sign"],x=n["zero-digit"],v=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 M=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==x&&(r=r.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),r},S=M(ot(g,d.maximumFactionalPartSize),d.maximumFactionalPartSize),E=S.indexOf(".");for(-1===E?S+=v:S=S.replace(".",v);S.charAt(0)===x;)S=S.substring(1);for(;S.charAt(S.length-1)===x;)S=S.substring(0,S.length-1);E=S.indexOf(v);var z=d.minimumIntegerPartSize-E,A=d.minimumFactionalPartSize-(S.length-E-1);if(S=(z>0?new Array(z+1).join(x):"")+S,S+=A>0?new Array(A+1).join(x):"",E=S.indexOf(v),d.regularGrouping>0)for(var T=Math.floor((E-1)/d.regularGrouping),O=1;O<=T;O++)S=[S.slice(0,E-O*d.regularGrouping),_,S.slice(E-O*d.regularGrouping)].join("");else d.integerPartGroupingPositions.forEach(function(t){S=[S.slice(0,E-t),_,S.slice(E-t)].join(""),E++});if(E=S.indexOf(v),d.fractionalPartGroupingPositions.forEach(function(t){S=[S.slice(0,t+E+1),_,S.slice(t+E+1)].join("")}),E=S.indexOf(v),-1!==d.picture.indexOf(v)&&E!==S.length-1||(S=S.substring(0,S.length-1)),void 0!==y){var I=M(y,0);(z=d.minimumExponentSize-I.length)>0&&(I=new Array(z+1).join(x)+I),S=S+n["exponent-separator"]+(y<0?b:"")+I}return S=d.prefix+S+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 ht(t){if(void 0!==t)return!ut(t)}function lt(t,e,r,n){var i=[e],o=M(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=x(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return o=lt(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=x(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return o=t[n],s=lt(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()}},h,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=lt(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()}},l,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=M(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=x();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=x();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 xt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=x(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function vt(t){return void 0!==t}function _t(t){var e=x();if(Array.isArray(t))t.forEach(function(t){e=xt(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 Mt(t,e){var r,n,o,s;return i().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:r=x(),a.t0=i().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return n=a.t1.value,o=lt(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 St(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Et(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function zt(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 At(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 Tt(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=v(t)?x():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,o=0;o<e.length;o++)if(S(n,e[o])){i=!0;break}i||e.push(n)}return e}}function It(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=lt(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:z,count:A,max:T,min:O,average:I,string:j,substring:P,substringBefore:R,substringAfter:C,lowercase:N,uppercase:F,length:D,trim:L,pad:Y,match:q,contains:U,replace:W,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:ht,map:ft,zip:gt,filter:dt,single:pt,foldLeft:yt,sift:It,keys:mt,lookup:bt,append:xt,exists:vt,spread:_t,merge:wt,reverse:kt,each:Mt,error:St,assert:Et,type:zt,sort:At,shuffle:Tt,distinct:Ot,base64encode:B,base64decode:G,encodeUrlComponent:X,encodeUrl:H,decodeUrlComponent:V,decodeUrl:Z}}();e.exports=s}).call(this)}).call(this,void 0!==Zi?Zi:"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",h=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,o=Object.create(i.prototype),a=new j(n||[]);return s(o,"_invoke",{value:A(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 x(){}function v(){}function _(){}var w={};l(w,c,function(){return this});var k=Object.getPrototypeOf,M=k&&k(k(P([])));M&&M!==r&&o.call(M,c)&&(w=M);var S=_.prototype=x.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function z(t,e){function r(i,s,a,c){var u=d(t[i],t,s);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==n(l)&&o.call(l,"__await")?e.resolve(l.__await).then(function(t){r("next",t,a,c)},function(t){r("throw",t,a,c)}):e.resolve(l).then(function(t){h.value=t,a(h)},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 A(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=T(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 T(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,T(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 I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(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 v.prototype=_,s(S,"constructor",{value:_,configurable:!0}),s(_,"constructor",{value:v,configurable:!0}),v.displayName=l(_,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,h,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(z.prototype),l(z.prototype,u,function(){return this}),e.AsyncIterator=z,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new z(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then(function(t){return t.done?t.value:s.next()})},E(S),l(S,h,"Generator"),l(S,c,function(){return this}),l(S,"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=P,j.prototype={constructor:j,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(I),!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),I(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;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(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"),h=function(){var t=i().mark(Y),e=i().mark($),r=i().mark(q),h=i().mark(W),l=i().mark(B),f=i().mark(G),d=i().mark(X),p=i().mark(H),g=i().mark(ot),y=i().mark(ct),m=i().mark(lt),b=i().mark(ft),x=i().mark(dt),v=i().mark(yt),_=i().mark(xt),w=i().mark(vt),k=i().mark(_t),M=i().mark(wt),S=i().mark(Mt),E=i().mark(Et),z=i().mark(Tt),A=i().mark(jt),T=a.isNumeric,O=a.isArrayOfStrings,I=a.isArrayOfNumbers,j=a.createSequence,P=a.isSequence,R=a.isFunction,C=a.isLambda,N=a.isIterable,F=a.getFunctionArity,D=a.isDeepEqual,L=Rt(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(X(e,r,n),"t2",9);case 9:return o=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(H(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(lt(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(vt(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(Mt(e,r,n),"t8",43);case 43:return o=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(xt(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(G(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&&P(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,h;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=Array.isArray(r)&&"variable"!==t.steps[0].type?r:j(r),a=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((h=t.steps[u]).tuple&&(a=!0),0!==u||!h.consarray){e.next=12;break}return e.delegateYield(Y(h,o,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(B(h,o,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(q(h,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===h.focus&&(o=s);case 22:u++,e.next=4;break;case 25:if(a)if(t.tuple)s=c;else for(s=j(),u=0;u<c.length;u++)s.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=j(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=Rt(t);for(var n in e)r.bind(n,e[n]);return r}function q(t,e,n,o){var s,a,c,u,h;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(W(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=j(),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(G(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 h=j(),o&&1===s.length&&Array.isArray(s[0])&&!P(s[0])?h=s[0]:s.forEach(function(t){!Array.isArray(t)||t.cons?h.push(t):t.forEach(function(t){return h.push(t)})}),r.abrupt("return",h);case 27:case"end":return r.stop()}},r)}function W(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(G(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()}},h)}function B(t,e,r,n){var o,s,a,c,u,h,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=j()).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(W(t.stages,o,n),"t2",13);case 13:o=i.t2;case 14:return i.abrupt("return",o);case 15:(o=j()).tupleStream=!0,u=n,void 0===r&&(r=e.map(function(t){return{"@":t}})),h=0;case 20:if(!(h<r.length)){i.next=28;break}return u=U(n,r[h]),i.delegateYield(Y(t,r[h]["@"],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[h]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[h]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[h]["@"])),o.push(c);case 25:h++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(W(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()}},l)}function G(t,e,r){var n,o,a,c,u,h;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=j(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=j(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:h=i.t0,T(h)&&(h=[h]),I(h)?h.forEach(function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===o&&n.push(a)}):s.boolean(h)&&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 X(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=ht(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 H(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(!T(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=j();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=j();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&&!T(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!T(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=D(t,e);break;case"!=":i=!D(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,h,l,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=j(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){y.next=31;break}u=e[c],h=a?U(r,u):r,l=0;case 10:if(!(l<t.lhs.length)){y.next=28;break}return f=t.lhs[l],y.delegateYield(Y(f[0],a?u["@"]:u,h),"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:l},!o.hasOwnProperty(d)){y.next=24;break}if(o[d].exprIndex===l){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:l++,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,h=r,a&&(m=ut(p.data),g=m["@"],delete m["@"],h=U(r,m)),y.delegateYield(Y(t.lhs[p.exprIndex][1],g,h),"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 ht(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 lt(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=Rt(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()}},x)}function pt(t){var e=new Ft.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,h;return i().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return a=e,c=!!e.tupleStream,u=i().mark(function e(o,s){var a,u,h,l,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 h=t.terms[u],l=o,f=r,c&&(l=o["@"],f=U(r,o)),e.delegateYield(Y(h.expression,l,f),"t0",8);case 8:return d=e.t0,l=s,f=r,c&&(l=s["@"],f=U(r,s)),e.delegateYield(Y(h.expression,l,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===h.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)}),h={environment:r,input:e},l.delegateYield(s.sort.apply(h,[a,u]),"t0",5);case 5:return o=l.t0,l.abrupt("return",o);case 7:case"end":return l.stop()}},v)}function mt(t,e,r){return It(i().mark(function e(o){var s,a,c,u,h,l,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"),R(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(!(h=c[u])||!(h.isPrototypeOf(a)||h 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,h,r),"t2",17);case 17:if(l=e.t2,"undefined"===(f=n(l))){e.next=23;break}if("object"===f&&null!==l&&!Array.isArray(l)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:l};case 22:for(d in l)h[d]=l[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(Y(t.delete,h,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(h)&&null!==h&&delete h[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 xt(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(vt(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,R(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!R(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 vt(t,e,r,o){var s,a,c,u,h,l;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[h],e,r),"t0",1);case 1:o=n.t0,R(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=F(o),c.push(s)):c.push(o);case 3:case"end":return n.stop()}},n)}),h=0;case 8:if(!(h<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:h++,f.next=8;break;case 13:return l="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(a)&&(a.token=l,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=l),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(!C(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=St(t.signature,e,r)),!C(t)){i.next=8;break}return i.delegateYield(Et(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),!N(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),!N(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()}},M,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 Mt(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(!C(c)){i.next=23;break}n=zt(c,o),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=At(c.implementation,o),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=At(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()}},S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Rt(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(Tt(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()}},E)}function zt(t,e){var r=Rt(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 At(t,e){var r=Ot(t),n="function("+(r=r.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=c(n);return i.body=t,zt(i,e)}function Tt(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),!N(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()}},z)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function jt(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)&&!P(r)&&((r=j(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),Nt(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),Nt(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()}},A,this,[[4,8],[12,17]])}function Pt(t){if(void 0!==t)return JSON.parse(s.string(t))}function Rt(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",It(s.sum,"<a<n>:n>")),L.bind("count",It(s.count,"<a:n>")),L.bind("max",It(s.max,"<a<n>:n>")),L.bind("min",It(s.min,"<a<n>:n>")),L.bind("average",It(s.average,"<a<n>:n>")),L.bind("string",It(s.string,"<x-b?:s>")),L.bind("substring",It(s.substring,"<s-nn?:s>")),L.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),L.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),L.bind("lowercase",It(s.lowercase,"<s-:s>")),L.bind("uppercase",It(s.uppercase,"<s-:s>")),L.bind("length",It(s.length,"<s-:n>")),L.bind("trim",It(s.trim,"<s-:s>")),L.bind("pad",It(s.pad,"<s-ns?:s>")),L.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),L.bind("contains",It(s.contains,"<s-(sf):b>")),L.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),L.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),L.bind("join",It(s.join,"<a<s>s?:s>")),L.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),L.bind("formatBase",It(s.formatBase,"<n-n?:s>")),L.bind("formatInteger",It(o.formatInteger,"<n-s:s>")),L.bind("parseInteger",It(o.parseInteger,"<s-s:n>")),L.bind("number",It(s.number,"<(nsb)-:n>")),L.bind("floor",It(s.floor,"<n-:n>")),L.bind("ceil",It(s.ceil,"<n-:n>")),L.bind("round",It(s.round,"<n-n?:n>")),L.bind("abs",It(s.abs,"<n-:n>")),L.bind("sqrt",It(s.sqrt,"<n-:n>")),L.bind("power",It(s.power,"<n-n:n>")),L.bind("random",It(s.random,"<:n>")),L.bind("boolean",It(s.boolean,"<x-:b>")),L.bind("not",It(s.not,"<x-:b>")),L.bind("map",It(s.map,"<af>")),L.bind("zip",It(s.zip,"<a+>")),L.bind("filter",It(s.filter,"<af>")),L.bind("single",It(s.single,"<af?>")),L.bind("reduce",It(s.foldLeft,"<afj?:j>")),L.bind("sift",It(s.sift,"<o-f?:o>")),L.bind("keys",It(s.keys,"<x-:a<s>>")),L.bind("lookup",It(s.lookup,"<x-s:x>")),L.bind("append",It(s.append,"<xx:a>")),L.bind("exists",It(s.exists,"<x:b>")),L.bind("spread",It(s.spread,"<x-:a<o>>")),L.bind("merge",It(s.merge,"<a<o>:o>")),L.bind("reverse",It(s.reverse,"<a:a>")),L.bind("each",It(s.each,"<o-f:a>")),L.bind("error",It(s.error,"<s?:x>")),L.bind("assert",It(s.assert,"<bs?:x>")),L.bind("type",It(s.type,"<x:s>")),L.bind("sort",It(s.sort,"<af?:a>")),L.bind("shuffle",It(s.shuffle,"<a:a>")),L.bind("distinct",It(s.distinct,"<x:x>")),L.bind("base64encode",It(s.base64encode,"<s-:s>")),L.bind("base64decode",It(s.base64decode,"<s-:s>")),L.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),L.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),L.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),L.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),L.bind("eval",It(jt,"<sx?:x>")),L.bind("toMillis",It(o.toMillis,"<s-s?:n>")),L.bind("fromMillis",It(o.fromMillis,"<n-s?s?:s>")),L.bind("clone",It(Pt,"<(oa)-:o>"));var Ct={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 Nt(t){var e=Ct[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 Ft(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Nt(t),t}var i=Rt(L),s=new Date;return i.bind("now",It(function(t,e){return o.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",It(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?Ft.RegexEngine=e.RegexEngine:Ft.RegexEngine=RegExp,{evaluate:function(t,e,o){if(void 0!==n){var a={code:"S0500",position:0};throw Nt(a),a}var c,u,h;if(void 0!==e)for(var l in c=Rt(i),e)c.bind(l,e[l]);else c=i;if(c.bind("$",t),s=new Date,c.timestamp=s,Array.isArray(t)&&!P(t)&&((t=j(t)).outerWrapper=!0),"function"==typeof o){c.async=!0;var f=function(t){Nt(t),o(t,null)},d=function t(e){(u=h.next(e)).done?o(null,u.value):u.value.then(t).catch(f)};h=Y(r,t,c),(u=h.next()).value.then(d).catch(f)}else try{for(h=Y(r,t,c),u=h.next();!u.done;)u=h.next(u.value);return u.value}catch(a){throw Nt(a),a}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return Ft.parser=c,Ft}();e.exports=h},{"./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 h=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:h};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 l=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===l)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 x,v=n;;)if(x=r.charAt(v),v===i||" \t\n\r\v".indexOf(x)>-1||Object.prototype.hasOwnProperty.call(t,x)){if("$"===r.charAt(n))return g=r.substring(n+1,v),n=v,o("variable",g);switch(g=r.substring(n,v),n=v,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 v++}},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},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},l=function(t,e){var r=a[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(h)).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,h=i.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(o=Object.create(c)).value=u,o.type=h,o.position=i.position,o},p=function(t){var e,r=o;for(d(null,!0),e=r.nud();t<o.lbp;)r=o,d(),e=r.led(e);return e},g=function(t){l(t,0).nud=function(){return this}},y=function(e,r,n){var i=r||t[e],o=l(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=l(t,e);return n.led=r,n},b=function(t,e){var r=l(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),l(":"),l(";"),l(","),l(")"),l("]"),l("}"),l(".."),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 x=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("{",x),y("{",t["{"],x),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 v=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=[],M=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},S=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)}},E=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=M(s,o)}}},z=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),E(r);break;case"[":var u=r=t(e.lhs),h="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],h="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[h]&&(u[h]=[]);var l=t(e.rhs);void 0!==l.seekingParent&&(l.seekingParent.forEach(function(t){1===t.level?M(u,t):t.level--}),S(u,l)),u[h].push({type:"filter",expr:l,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 S(f,r),{descending:e.descending,expression:r}}),r.steps.push(f),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(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),S(r,r.lhs),S(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 S(r,n),n}):"{"===e.value?r.lhs=e.lhs.map(function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]}):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(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 S(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=v(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(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 S(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 A=p(0);if("(end)"!==o.id){var T={code:"S0201",position:o.position,token:o.value};f(T)}if("parent"===(A=z(A)).type||void 0!==A.seekingParent)throw{code:"S0217",token:A.type,position:A.position};return c.length>0&&(A.errors=c),A};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,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={}},h=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 l=h(e,r,"(",")"),f=e.substring(r+1,l);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};s.regex="["+f+"m]",s.type="("+f+")",r=l,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:r};var d=h(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 h=y(r);if(!n.contextRegex.test(h))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 h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function l(t){return"object"===s(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var 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:l,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=a},{}]},{},[3])(3)}(to)),to.exports),ro=Qi(eo);const no=function(t){return t};function io(t){if(!t)return no;try{const e=ro(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Vi(t),no}}function oo(t){const e=_i(t);return null==e?"":String(e)}function so(t){return Number(_i(t))}function ao(t){return t}function co(t){return oo(t)}function uo(t){return so(t)}function ho(t){if(this.param)return t=oo(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function lo(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=so(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 fo(t){return so(t)*Math.PI/180}function po(){}const go=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const yo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],mo=new Array(yo.length).fill(void 0),bo=Object.getPrototypeOf(async function(){}).constructor;function xo(t,e){!function(t){for(const e of go)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const r=function(t){return/\bawait\b/.test(t)}(t),n=new(r?bo:Function)(...e,...yo,t);return function(t,...e){return n.call(t,...e,...mo)}}function vo(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?co.bind(t):"number"===i?uo.bind(t):ao.bind(e);case"map":return ho.bind(t);case"range":return lo.bind(t);case"radian":return fo.bind(t);case"eval":return function(t){try{const e=xo(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=>{Vi(t)}):n}catch(t){return void Vi(t)}}}catch(t){return Vi(t),po}}(n).bind(e);default:return ao.bind(e)}}class _o{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=vo(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=io(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=io(t),this.partAccessor=io(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 wo(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 ko(t,e,r,n){t.forEach(t=>wo(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=>Vi(t)):e(t)}function So(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:h=!1,partial:l=!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||h&&!t&&0!==t&&!1!==t||wo(n,s,t,l)},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||h&&!t&&0!==t&&!1!==t||ko(o,s,t,l)},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||h&&!t&&0!==t&&!1!==t||ko(i,s,t,l)},r,e)}}}}else{const n=this.root.findAll(o,this);n.length>0&&Mo(t.evaluator(f,n),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||ko(n,s,t,l)},r,e)}}catch(e){Vi(e,this,t)}})}function Eo(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),So.call(this,!0)}function zo(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new _o({target:"(self)",rule:"value",...t},this))):(Vi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function Ao(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function To(t,e){this.disposeMappings(),So.call(this)}function Oo(t,e,r,n,i,o){e.complete?t.drawImage(e,r,n,i,o):e.addEventListener("load",()=>{this.invalidate()})}function Io(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const jo="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),Po={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Ro=()=>{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";Po.FONT_FAMILY=e||r};let Co;function No(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,h=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,h+=o+c}t.translate(u,h),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,-h)}}function Fo(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=Co(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 Do(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Vi(t)})}function Lo(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 Yo(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 $o(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 Uo(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 qo(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=Uo(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?$o(e):[{text:e,bold:!1,italic:!1}],r,o))):s.map(t=>i?$o(t):[{text:t,bold:!1,italic:!1}])}function Wo(t,e,r,n,i,o,s=0){if(!n)return[];t.save(),t.font=r;const a=qo(t,n,e,!!i,o,s);return t.restore(),a}function Bo(t){const{fontFamily:e=Po.FONT_FAMILY,bold:r=Po.BOLD,italic:n=Po.ITALIC,fontSize:i=Po.FONT_SIZE}=t,o=[];return r&&o.push("bold"),n&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Go(t,e){const r=t.bold||e.bold,n=t.italic||e.italic;return Bo({...t,bold:r,italic:n})}function Xo(t,e,r,n){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=Po.FONT_COLOR,textAlign:c=Po.TEXT_ALIGN,textBaseline:u=Po.TEXT_BASELINE,textBackgroundStyle:h,fontSize:l,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:g=0}=n;i=void 0!==i?i:1,l||=Po.FONT_SIZE,f||=1.2*l,t.save();const{left:y,top:m,width:b,height:x}=e;if(o&&s&&(t.translate(y+b/2,m+x/2),t.rotate(-o),t.translate(-(y+b/2),-(m+x/2))),t.beginPath(),t.font=Bo(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=Ho(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 v=r.length*f;let _;switch(u){case"top":_=m,t.textBaseline="top";break;case"bottom":_=m+x-v+f,t.textBaseline="bottom";break;default:_=m+x/2-v/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=Go(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(h&&(t.fillStyle=h,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-l/2-4,s+8,l+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=Go(n,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(r<i?a:0)})}else e.forEach(e=>{t.font=Go(n,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+g})})}),t.restore()}function Ho(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 Vo(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",()=>{Ro()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Ro),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Ro()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Ro(),Co="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 Zo=[];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 Jo(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 Ko(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 ts(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=Jo(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 Jo(t,e,r,n,i);return Jo(t+s,e+a,{x:r.x+s,y:r.y+a},n+o,{x:i.x*c,y:i.y*u})}function es(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Jo(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)}function rs(t,e,r){r=r||this.rootModel,Zo.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Zo.push(t);let n=this.transcoordS2P(t,e);for(let t=0;t<Zo.length;t++){const e=Zo[t],r=e.bounds;n.x+=r.left,n.y+=r.top,n=e.transcoordS2P(n.x,n.y)}return n}function ns(t,e,r){r=r||this.rootModel,Zo.length=0;for(let t=this.parent;t&&t!==r;t=t.parent)Zo.push(t);let n={x:t,y:e};for(let t=Zo.length-1;t>=0;t--){const e=Zo[t];n=e.transcoordP2S(n.x,n.y);const r=e.bounds;n.x-=r.left,n.y-=r.top}return n}function is(t,e,r){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)}function os(t,e,r){const n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)}function ss(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 as(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=Jo(n.x,n.y,void 0,o+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}function cs(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 us={x:1,y:1},hs={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function ls(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 h=[{x:s,y:a},{x:s+c,y:a+u}];h=h.map(t=>Jo(t.x,t.y,n,i,o));let l=h[0],f=h[1];n={x:(l.x+f.x)/2,y:(l.y+f.y)/2},h=h.map(t=>Qo(t.x,t.y,n,i,o)),l=h[0],f=h[1],this.bounds={left:l.x,top:l.y,width:f.x-l.x,height:f.y-l.y}}function fs(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,h;n=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=n[0].x,u=h=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>h&&(h=e.y)}i={x:(a+c)/2,y:(u+h)/2},i=this.toParent(i.x,i.y,s),this.path=o.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const ds=new Map;let ps=null;function gs(){ps&&(ps(),ps=null)}function ys(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ms=new class{add(t){var e;ys(t)&&!ds.has(t)&&(ds.set(t,0),e=t?.root,ps||(ps=H.subscribe(t=>{if(0===t)return;const e=[];for(const[r,n]of ds){if(!ys(r)){e.push(r);continue}const i=n+t;i>=r.retention?e.push(r):ds.set(r,i)}for(const t of e){ds.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Vi("RetentionManager removeSelf failed:",t)}}0===ds.size&&gs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ds.keys()),metadata:{get count(){return ds.size},get preview(){return Array.from(ds.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){ds.delete(t)&&0===ds.size&&gs()}touch(t){t&&ds.has(t)&&ds.set(t,0)}dispose(){gs(),ds.clear()}get length(){return ds.size}};const bs=function(t){return t};function xs(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)}:bs}}function vs(t){if(!t)return;const e=String(t),r=(e.match(/#{(\S*)}/)||[]).map(t=>xs(t))[0];if(r)return r.accessor(this.getState(r.target));const n=(e.match(/\${[^}]*}/)||[]).map(t=>xs(t))[0];if(n){const t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}function _s(t,e){if(!t)return;const r=String(t),n=e||_i,i=(r.match(/#{(\S*)}/gi)||[]).map(t=>xs(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>xs(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 ws(t,e,r){if(!t)return;const n=r||_i,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>xs(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>xs(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(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 ks{constructor(){}static registerDecorator(t,e){ks.constructors.set(t,e)}static create(t,e,r={},n){const i=ks.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(n,e,r)}}function Ms(t,e){const r=e.x-t.x,n=e.y-t.y,i=Math.sqrt(r*r+n*n);if(!mt(t))return i;const o=bt(t,e,t.bulge);if(!o)return i;const s=Math.min(o.radius,i/2),a=2*Math.asin(s/o.radius);return o.radius*a}function Ss(t,e){const r=t.path.slice();if(!r||!r.length)return void Vi("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(Ms(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:h}=function(t,e,r){if(mt(t)){const n=bt(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,h)}function Es(t,e){return!1}function zs({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 As(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=ai(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 Ts(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 Os(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 Is(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function js(t){return Ss(this,t||0)}function Ps(){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 Rs(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 Cs(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ns(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const 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 Fs(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Ds(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}function Ls(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}function Ys(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}function $s(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}function Us(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 qs(){return Vi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Ws(t){Vi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Bs(){return this.path}function Gs(){return this.center}function Xs(){return this.nature.mutable}function Hs(){return this.nature.resizable&&!this.stuck}function Vs(){return this.nature.rotatable&&!this.stuck}ks.constructors=new Map;const Zs={x:1,y:1};function Qs(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")??Zs;t.shadowOffsetX=n*a.x*jo,t.shadowOffsetY=i*a.y*jo,t.shadowBlur=o*a.x*jo,t.shadowColor=s}function Js(t){t.save(),this.prerender(t);const e=this.app,r=!0===t.__inHiddenSubtree;e?.isEditMode&&((function(t){const e=t?.app;if(!e?.isEditMode)return!1;const r=e.focusFilter;return!!(t.hidden||r&&!r(t))}(this)||r)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=r,t.restore()}function Ks(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:h=0}=this._delta,l=(o||1)-this._delta.fade;(u||h)&&t.translate(u,h),(1!=s||1!=a||c)&&(t.translate(e.x,e.y),1==s&&1==a||t.scale(s,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),l&&(t.globalAlpha=l),i&&Qs(t,i,this)}function ta(t){}function ea(t){this.drawText(t)}function ra(t,e){t(this)}function na(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Vi(t)})}function ia(t){!this.textHidden&&this.text&&this.hasTextProperty&&Xo(t,this.textBounds,this.textLines(t),this.state)}function oa(t,e){Yo(t,e?{...this.state,...e}:this.state)}function sa(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(No(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function aa(){return this.get("strokeStyle")}function ca(t){this.set("strokeStyle",t)}function ua(){return this.getState("fillStyle")}function ha(t){this.setState("fillStyle",t)}function la(){return this.get("fontColor")}function fa(t){this.set("fontColor",String(_i(t)))}function da(){return this.getState("rotation")}function pa(t){this.setState("rotation",Number(_i(t)))}function ga(){return this.app.isEditMode?["decotag","data-spread"]:[]}function ya(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function ma(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function ba(t){this.setState("hidden",t)}function xa(){return this.state.tag}function va(t){this.setState("tag",t)}function _a(){}function wa(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function ka(){const t=this.getState("text");return null==t?"":String(t)}function Ma(t){const{textWrap:e,supportMarkdown:r}=this.state;return Wo(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}function Sa(){return Bo(this.model)}function Ea(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function za(){return this._text_substitutor||(this._text_substitutor=ws(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Aa(){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,h,l,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,x=t.substring(b,b+1),v=b+("."===x||","===x?1:0),_=m>0?t.substring(v,d):"";if(r=(e="-"===(t=t.substring(p,v)).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)),h=t[0].split(o),t[0]=h.join(""),s=t[0]&&t[0].indexOf("0"),s>-1)for(;u[0].length<t[0].length-s;)u[0]="0"+u[0];else 0===+u[0]&&(u[0]="");if((e=e.split("."))[0]=u[0],c=h[1]&&h[h.length-1].length,c){for(l=e[0],y="",b=l.length%c,d=l.length,v=0;v<d;v++)y+=l.charAt(v),!((v-b+1)%c)&&v<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 Ta(t){delete this._text_substitutor;const e=_i(t);this.setState("text",null==e?"":String(e))}function Oa(){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 Ia(){return 0}function ja(){return!!this._textHidden}function Pa(t){this._textHidden=!!t,this.invalidate()}function Ra(){return!0}function Ca(t){return t}function Na(t){return Math.pow(t,2)}function Fa(t){return 1-Math.sin(Math.acos(t))}function Da(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function La(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 Ya(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var $a={linear:Ca,quad:Na,circ:Fa,back:Da,bounce:La,elastic:Ya},Ua=Object.freeze({__proto__:null,back:Da,bounce:La,circ:Fa,default:$a,elastic:Ya,linear:Ca,quad:Na});class qa{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?$a[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=()=>H.simTime,u=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==s&&(s=c(),this.client?.touch?.());const h=c()-s,l=Math.max((h-e)%(t+n),0)/t,f=n<=0&&a>l;if(a=l,l>=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=H.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(l)),this.client&&this.client.invalidate?.()};this._unsub=H.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 Wa={rotation:class extends qa{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends qa{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 qa{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 qa{step(t){const{x:e=0,y:r=0}=this.config;this.client.delta?.({tx:t*e,ty:t*r})}},outline:class extends qa{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,h=this.client.toScene(c,u);this.client.delta({tx:a.x-h.x+o,ty:a.y-h.y+s})}},fade:class extends qa{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 qa{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 Ba={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:Qs};function Ga(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:h}=t;let l;l="string"==typeof h?Ua[h]:h||Ca,"out"===r?l=function(t,e){return function(r){return 1-t(1-r,e)}}(l,c):"inout"===r&&(l=function(t,e){return function(r){return r<.5?t(2*r,e)/2:(2-t(2*(1-r),e))/2}}(l,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=()=>H.simTime;return d=H.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(l(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 Xa(t,e){return function(t,e,r){const n=Ba[r.type];n&&n(t,e,r)}(this,t,e)}const Ha=100;function Va(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Ha)/Ha}return e}}function Za(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*Ha)/Ha):delete t[e]:"object"==typeof r&&Za(r)}return t}function Qa(...t){return JSON.stringify(this.hierarchy,Va,...t)}function Ja(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Ka(t){this.rootModel.closeScene(t)}function tc(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 ec(){this.parent&&this.parent.invalidate()}function rc(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function nc(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function ic(){return this.getState("data")}function oc(t){this.setState("data",t),this.touch()}function sc(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 ac(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function cc(){return Number(this.get("retention"))||0}function uc(){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?Wa[e.type]:void 0;return r?new r(t,e):null}(this,t.oncreate))}return this._animation}}function hc(){return!!this.animation?.started}function lc(t){this.animation&&(this.animation.started=t)}function fc(){}function dc(t,e,r,n){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function pc(t,e,r,n){return t==e.get("type")}function gc(t,e,r,n,i,o){return t(e,r,n,i)&&o.push(r),r.components&&r.components.forEach(r=>{gc(t,e,r,n,i,o)}),o}function yc(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 mc(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=dc;break;case"(":n=yc;break;default:n=pc}return gc(n,t,e,r,e,[])}function bc(t,...e){if(t(this,...e))return this}function xc(t,...e){return"string"==typeof t?mc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function vc(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 _c(t){return this.anchors.find(e=>e.name===t)}function wc(t){return!0}function kc(t){return this._parent.getContext(t??this)}function Mc(){return this.isRoot()?this:this.parent&&this.parent.root}function Sc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Ec(){return this._parent}function zc(t){this._parent=t}function Ac(){return this.nature.anchors||[]}function Tc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Oc(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function Ic(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function jc(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Pc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Rc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Cc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Nc={},Fc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Dc=[],Lc=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Yc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let $c=0;const Uc={};const qc=new FinalizationRegistry(t=>{!function(t){$c--;let e=Uc[t];e||(e=Uc[t]={up:0,down:0}),e.down++}(t)});class Wc{static get nature(){return Fc}static register(t,e){if(!e)return Nc[t];Nc[t]=e}static types(){return Object.keys(Nc)}static get residents(){return Uc}static get residentsCount(){return $c}static registerDecorator(t,e){ks.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},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=ai(Yc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),ms.add(this),function(t){$c++;let e=Uc[t];e||(e=Uc[t]={up:0,down:0}),e.up++}(this._model.type),qc.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),ms.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=ai(Yc))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&ms.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")&&ms.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=ai(this._model);return this.volatile.forEach(e=>{delete t[e]}),Za(t)}get volatile(){return Dc}_applyProps(t,e,r){const n={},i={};let o=!1;const s=ai(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=r.getBeforeVal(e),u=s[e];!r.sensitive&&function(t,e){return Fr(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=>!Lc.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 Es.call(this,t,e)}move(t,...e){zs.call(this,t,...e)}symmetryX(t){As.call(this,t)}symmetryY(t){Ts.call(this,t)}adjustResize(t,e,r){return Os.call(this,t,e,r)}adjustRotation(t,e){return Is.call(this,t,e)}outline(t){return js.call(this,t)}get bounds(){return Ps.call(this)}set bounds(t){Rs.call(this,t)}get center(){return Cs.call(this)}set center(t){Ns.call(this,t)}get location(){return Fs.call(this)}set location(t){Ds.call(this,t)}get rotate(){return Ls.call(this)}set rotate(t){Ys.call(this,t)}get dimension(){return $s.call(this)}set dimension(t){Us.call(this,t)}get path(){return qs.call(this)}set path(t){Ws.call(this,t)}get drawPath(){return Bs.call(this)}get rotatePoint(){return Gs.call(this)}get mutable(){return Xs.call(this)}get resizable(){return Hs.call(this)}get rotatable(){return Vs.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&&Js.call(this,t)}prerender(t){Ks.call(this,t)}render(t){ta.call(this,t)}postrender(t){ea.call(this,t)}prepare(t,e){ra.call(this,t,e)}prepareIf(t){na.call(this,t)}drawText(t){ia.call(this,t)}drawStroke(t,e){oa.call(this,t,e)}drawFill(t,e){sa.call(this,t,e)}get strokeStyle(){return aa.call(this)}set strokeStyle(t){ca.call(this,t)}get fillStyle(){return ua.call(this)}set fillStyle(t){ha.call(this,t)}get fontColor(){return la.call(this)}set fontColor(t){fa.call(this,t)}get rotation(){return da.call(this)}set rotation(t){pa.call(this,t)}get decorators(){return ga.call(this)}get decotag(){return ya.call(this)}get hidden(){return ma.call(this)}set hidden(t){ba.call(this,t)}get tag(){return xa.call(this)}set tag(t){va.call(this,t)}get appendum(){return _a.call(this)}set appendum(t){wa.call(this,t)}defaultTextSubstitutor(){return ka.call(this)}textLines(t){return Ma.call(this,t)}get font(){return Sa.call(this)}get lineHeight(){return Ea.call(this)}get textSubstitutor(){return za.call(this)}get text(){return Aa.call(this)}set text(t){Ta.call(this,t)}get textBounds(){return Oa.call(this)}get textRotation(){return Ia.call(this)}get textHidden(){return ja.call(this)}set textHidden(t){Pa.call(this,t)}get hasTextProperty(){return Ra.call(this)}animate(t){return Ga.call(this,t)}effect(t,e){return Xa.call(this,t,e)}serialize(...t){return Qa.call(this,...t)}trim(){Ja.call(this)}closeScene(t){Ka.call(this,t)}delta(t,e){return tc.call(this,t,e)}invalidate(){ec.call(this)}get value(){return rc.call(this)}set value(t){nc.call(this,t)}get data(){return ic.call(this)}set data(t){oc.call(this,t)}set tap(t){sc.call(this,t)}get mappings(){return ac.call(this)}get retention(){return cc.call(this)}get animation(){return uc.call(this)}get started(){return hc.call(this)}set started(t){lc.call(this,t)}get controls(){return fc.call(this)}findFirst(t,...e){return bc.call(this,t,...e)}findAll(t,...e){return xc.call(this,t,...e)}capture(t,e,r){return vc.call(this,t,e,r)}findAnchor(t){return _c.call(this,t)}isDescendible(t){return wc.call(this,t)}getContext(t){return kc.call(this,t)}get root(){return Mc.call(this)}get rootModel(){return Sc.call(this)}get parent(){return Ec.call(this)}set parent(t){zc.call(this,t)}get anchors(){return Ac.call(this)}get scalable(){return Tc.call(this)}get stuck(){return Oc.call(this)}get capturable(){return Ic.call(this)}get position(){return jc.call(this)}get origin(){return Pc.call(this)}get offset(){return Rc.call(this)}get app(){return Cc.call(this)}drawEffect(t){Io.call(this,t)}prepareFill(t,e){Fo.call(this,t,e)}prepareFillIf(t){Do.call(this,t)}onchangeFill(t,e){Lo.call(this,t,e)}drawImage(t,e,r,n,i,o){Oo.call(this,t,e,r,n,i,o)}mutateBounds(t,e){ls.call(this,t,e)}mutatePath(t,e,r){fs.call(this,t,e,r)}access(t){return vs.call(this,t)}substitute(t,e){return _s.call(this,t,e)}onchangeMappings(t,e){To.call(this,t,e)}onchangeData(t,e){Eo.call(this,t,e)}buildMappings(){zo.call(this)}executeMappings(t){So.call(this,t)}disposeMappings(){Ao.call(this)}ondropfile(t,e){Vo.call(this,t,e)}transcoordS2P(t,e,r){return ts.call(this,t,e,r)}transcoordP2S(t,e,r){return Ko.call(this,t,e,r)}transcoordS2T(t,e,r){return rs.call(this,t,e,r)}transcoordT2P(t,e,r){return ns.call(this,t,e,r)}transcoordT2S(t,e,r){return is.call(this,t,e,r)}transcoordS2TR(t,e,r){return es.call(this,t,e,r)}transcoordS2O(t,e,r){return os.call(this,t,e,r)}transcoordC2S(t,e,r){return ss.call(this,t,e,r)}transcoordS2C(t,e,r){return as.call(this,t,e,r)}toParent(t,e,r){return ts.call(this,t,e,r)}fromParent(t,e,r){return Ko.call(this,t,e,r)}toScene(t,e,r){return rs.call(this,t,e,r)}fromScene(t,e,r){return is.call(this,t,e,r)}toLocal(t,e,r){return ss.call(this,t,e,r)}toGlobal(t,e,r){return as.call(this,t,e,r)}toOther(t,e,r){return os.call(this,t,e,r)}on(t,e,r){return qi.call(this,t,e,r)}off(t,e,r){return Wi.call(this,t,e,r)}once(t,e,r){return Bi.call(this,t,e,r)}trigger(t,...e){return Gi.call(this,t,...e)}delegate_on(t){return Xi.call(this,t)}delegate_off(t){return Hi.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){}}Wc.capabilities=[],Wc.requires3d=!1,Wc.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}},Wc.transcoordR=Qo,Wc.transcoordRR=Jo,Wc.createCanvas=Co,Wc.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 Vi(`${String(e)} is not defined in ${t.constructor.name}`);const i=n.get,o={get:r?function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};n.set&&(o.set=n.set),Object.defineProperty(t,e,o)},Wc.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},Wc.drawText=Xo,Wc.font=Bo,Wc.textLines=Wo,Wc.drawStroke=Yo,Wc.drawFill=No,Wc.reposition=function(t){let{id:e,scale:r=us,bold:n,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:h,paddingLeft:l,paddingRight:f,fontSize:d=Po.FONT_SIZE,lineWidth:p=0,lineHeight:g,lineDash:y}=t.state;h||=0,u||=0,l||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:x=0,fontColor:v,hidden:_}=t,{left:w,top:k,width:M,height:S}=t.bounds,E=t.element;if(E.hidden=!t.app?.isEditMode&&_,e&&(E.id=e),m&&(E.className=m),Object.assign(E.style,hs,{fontFamily:o,fontSize:d+"px",width:M+"px",height:S+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:h+"px",paddingLeft:l+"px",border:p+"px",borderColor:b,borderStyle:p>0?y||Po.LINE_DASH:"",color:v,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"}),cs(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 z=t.delta(),A=(r&&r.x||1)*z.sx,T=(r&&r.y||1)*z.sy,O=(x||0)+z.theta,I=z.tx||0,j=z.ty||0;E.style.transform=`rotate(${O}rad) translate(${I}px, ${j}px) scale(${A}, ${T}) perspective(1px)`},Wc.RetentionManager=ms,Wc.template=function(t,e,r){var n=In.imports._.templateSettings||In;r&&tn(t,e,r)&&(e=void 0),t=An(t),e=sn({},e,n,bn);var i,o,s=sn({},e.imports,n.imports,bn),a=pr(s),c=function(t,e){return gn(e,function(e){return t[e]})}(s,a),u=0,h=e.interpolate||Fn,l="__p += '",f=RegExp((e.escape||Fn).source+"|"+h.source+"|"+(h===_n?Nn:Fn).source+"|"+(e.evaluate||Fn).source+"|$","g"),d=Ln.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,r,n,s,a,c){return n||(n=s),l+=t.slice(u,c).replace(Dn,vn),r&&(i=!0,l+="' +\n__e("+r+") +\n'"),a&&(o=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+e.length,e}),l+="';\n";var p=Ln.call(e,"variable")&&e.variable;if(p){if(Cn.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(o?l.replace(jn,""):l).replace(Pn,"$1").replace(Rn,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var g=pn(function(){return Function(a,d+"return "+l).apply(void 0,c)});if(g.source=l,dn(g))throw g;return g},Wc.buildSubstitutor=ws,["rotatePoint","font","lineHeight","retention"].forEach(t=>Wc.memoize(Wc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Wc.memoize(Wc.prototype,t,!0));const Bc=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 Gc(t){return class extends t{async ready(){await super.ready();const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=new Map;for(const 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))Bc.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=Wc.register?.(e);if(r&&"function"==typeof r){return new r({type:e,...t.itemState??{}})}}catch{}return null}}}function Xc(t,e,r){return r?{code:t,path:e,params:r}:{code:t,path:e}}const Hc="holder",Vc=t=>"number"==typeof t&&Number.isFinite(t),Zc=t=>Vc(t)&&t>0,Qc=t=>Number.isSafeInteger(t)&&t>0;function Jc(t,e,r){const n=t?.allowed;if(n&&"object"==typeof n)for(const t of["width","depth","height"])Zc(n[t])||r.push(Xc("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else r.push(Xc("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Qc(t.stackLimit)||t.stackLimit===1/0||r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Vc(t.rotation)||r.push(Xc("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||r.push(Xc("ARRAY_REQUIRED",`${e}.accepts`))}function Kc(t,e={}){const r=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Xc("TIERS_REQUIRED","tiers")];const n=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const o=`tiers[${e}]`;if(!t||"object"!=typeof t)return void r.push(Xc("OBJECT_REQUIRED",o));if(Qc(t.tierNo)?i.has(t.tierNo)?r.push(Xc("TIER_NUMBER_DUPLICATE",`${o}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${o}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?n&&!n.has(t.anchorId)&&r.push(Xc("ANCHOR_UNKNOWN",`${o}.anchorId`,{anchorId:t.anchorId})):r.push(Xc("ANCHOR_REQUIRED",`${o}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||r.push(Xc("MOUNT_INVALID",`${o}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Vc(t.position[e])||r.push(Xc("FINITE_NUMBER_REQUIRED",`${o}.position.${e}`));else r.push(Xc("OBJECT_REQUIRED",`${o}.position`));Vc(t.rotation)||r.push(Xc("FINITE_NUMBER_REQUIRED",`${o}.rotation`));const s=t.layout;switch(s?.pattern){case"SINGLE":Jc(s.slot,`${o}.layout.slot`,r);break;case"ROW":Qc(s.count)||r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.count`)),Zc(s.pitch)||r.push(Xc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch`)),"X"!==s.axis&&"Z"!==s.axis&&r.push(Xc("AXIS_INVALID",`${o}.layout.axis`)),Jc(s.slot,`${o}.layout.slot`,r);break;case"GRID":Qc(s.rows)||r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.rows`)),Qc(s.cols)||r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.cols`)),Zc(s.pitch?.x)||r.push(Xc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.x`)),Zc(s.pitch?.z)||r.push(Xc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.z`)),Jc(s.slot,`${o}.layout.slot`,r);break;case"CUSTOM":{if(!Array.isArray(s.slots)){r.push(Xc("ARRAY_REQUIRED",`${o}.layout.slots`));break}s.slots.length||r.push(Xc("SLOTS_REQUIRED",`${o}.layout.slots`));const t=new Set;s.slots.forEach((e,n)=>{const i=`${o}.layout.slots[${n}]`;Qc(e?.slotNo)?t.has(e.slotNo)?r.push(Xc("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):r.push(Xc("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),Vc(e?.offset?.x)&&Vc(e?.offset?.z)||r.push(Xc("FINITE_NUMBER_REQUIRED",`${i}.offset`)),Jc(e,i,r)});break}default:r.push(Xc("PATTERN_INVALID",`${o}.layout.pattern`))}}),r}function tu(t,e=""){const r=[],n=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,r)=>n(t,`${e}[${r}]`));else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))n(i,e?`${e}.${r}`:r)}else r.push(Xc("NOT_PERSISTABLE",e,{value:String(t)}))};return n(t,e),r}function eu(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function ru(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:eu(t)},(t,e)=>e+1)}function nu(t,e,r,n,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(r-1)*e+n;case"COL_MAJOR":return(n-1)*t+r;case"SERPENTINE_ROW":return(r-1)*e+(r%2==1?n:e-n+1);case"SERPENTINE_COL":return(n-1)*t+(n%2==1?r:t-r+1)}}function iu(t,e,r,n="ROW_MAJOR"){const i=r-1;switch(n){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,r=i%e+1;return{r:t,c:t%2==1?r:e-r+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,r=i%t+1;return{r:e%2==1?r:t-r+1,c:e}}}}const ou=(t,e)=>e&&0!==t?-t:t;function su(t,e,r={}){const n=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!n||!Qc(e.slot))return null;const i=n.layout;let o,s,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;o=i.slot,s={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=ou((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);o=i.slot,s="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:r}=iu(i.rows,i.cols,e.slot,i.order),n=i.origin??{x:"MIN",z:"MIN"};o=i.slot,s={x:ou((r-1-(i.cols-1)/2)*i.pitch.x,"MAX"===n.x),z:ou((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===n.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;o=t,s={...t.offset},a=t.name;break}}return{tier:n.tierNo,slotNo:e.slot,name:a,anchorId:n.anchorId,mount:n.mount,tierPosition:{...n.position},tierRotation:n.rotation,offset:s,allowed:{...o.allowed},accepts:o.accepts?[...o.accepts]:void 0,stackLimit:o.stackLimit??r.defaultStackLimit??1,rotation:o.rotation??0}}function au(t){return`t${t.tier}_s${t.slot}`}function cu(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*uu(t){for(const e of t?.tiers??[])for(const t of ru(e.layout))yield{tier:e.tierNo,slot:t}}function hu(t,e,r){if(!r)return{x:t,z:e};const n=r*Math.PI/180,i=Math.cos(n),o=Math.sin(n),s=t=>Math.round(1e9*t)/1e9;return{x:s(t*i+e*o),z:s(-t*o+e*i)}}function lu(t){const e=hu(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const fu=.05,du=t=>!!t&&Zc(t.width)&&Zc(t.depth)&&Zc(t.height);function pu(t,e){const r=e*Math.PI/180,n=Math.abs(Math.cos(r)),i=Math.abs(Math.sin(r)),o=t=>Math.round(1e9*t)/1e9;return{width:o(t.width*n+t.depth*i),depth:o(t.width*i+t.depth*n)}}function gu(t,e,r=0,n=.05){if(!du(t))return null;if(!Vc(r)||!Vc(n)||n<0||n>=1)return null;const i=pu(t,e.rotation),o=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-n)),s=t.height*o;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(r+s/2),z:0},rotation:0,scale:o}}function yu(t,e,r=0,n=.05){const i=gu(t,e,r,n);if(!i)return null;const o=lu(e);return{position:{x:o.position.x,y:o.position.y+i.position.y,z:o.position.z},rotation:o.rotation,scale:i.scale}}function mu(t,e,r=.05){let n=0;return t.map(t=>{const i=t?yu(t,e,n,r):null;return i&&(n+=t.height*i.scale),i})}const bu=1e-6;function xu(t,e){const r=lu(t),n=t.allowed.width/2,i=t.allowed.depth/2,o=[[-n,-i],[n,-i],[n,i],[-n,i]].map(([t,e])=>{const n=hu(t,e,r.rotation);return{x:r.position.x+n.x,z:r.position.z+n.z}}),s=hu(1,0,r.rotation),a=hu(0,1,r.rotation),c="HANG"===t.mount?-1:1,u=[r.position.y,r.position.y+c*t.allowed.height],h=o.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:o,axes:[s,a],y0:Math.min(...u),y1:Math.max(...u),minX:Math.min(...h),maxX:Math.max(...h)}}function vu(t,e){for(const r of[...t.axes,...e.axes]){const n=t.corners.map(t=>t.x*r.x+t.z*r.z),i=e.corners.map(t=>t.x*r.x+t.z*r.z);if(Math.min(Math.max(...n),Math.max(...i))-Math.max(Math.min(...n),Math.min(...i))<=bu)return!1}return!0}function _u(t,e={}){const r=[],n=new Map;t.tiers.forEach((e,r)=>{const i=n.get(e.anchorId)??[];n.set(e.anchorId,i);for(const n of ru(e.layout))i.push(xu(su(t,{tier:e.tierNo,slot:n}),r))});for(const[t,i]of n){const n=e.anchorFaces?.[t];if(n)for(const t of i)t.corners.some(t=>Math.abs(t.x)-n.width/2>bu||Math.abs(t.z)-n.depth/2>bu)&&r.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else r.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const o=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<o.length;t++){const e=o[t];for(let n=t+1;n<o.length&&o[n].minX<e.maxX-bu;n++){const t=o[n];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=bu)continue;if(!vu(e,t))continue;const[i,s]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];r.push({code:"SLOT_OVERLAP",path:`tiers[${s.tierIndex}]`,params:{tier:s.tier,slot:s.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return r}function wu(t,e,r=[],n={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=n.normalizeType??(t=>null==t?"":String(t)),o=[];let s=!1;if(t.accepts){const r=i(e.type);r?t.accepts.map(i).includes(r)||o.push("TYPE_NOT_ACCEPTED"):s=!0}if(r.length+1>t.stackLimit&&o.push("STACK_LIMIT_EXCEEDED"),du(e.dims)){const n=pu(e.dims,t.rotation);if(n.width>t.allowed.width&&o.push("WIDTH_EXCEEDED"),n.depth>t.allowed.depth&&o.push("DEPTH_EXCEEDED"),r.every(t=>du(t.dims))){r.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&o.push("HEIGHT_EXCEEDED")}else s=!0}else s=!0;return o.length?{verdict:"NG",reasons:s?[...o,"SPEC_UNKNOWN"]:o}:s?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}const ku=[{id:"__default__",maxCount:1/0}];function Mu(t){const e={id:au({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function Su(t,e){const r=e?.state?.type??e?.type;return t.accepts?!!r&&t.accepts.includes(r):!t.allowedTypes?.length||!!r&&t.allowedTypes.includes(r)}function Eu(t){var e;return e=class extends t{get slotLayout(){}get slots(){const t=this.slotLayout;if(!t)return[];const e=[];for(const r of uu(t)){const n=su(t,r);n&&e.push(Mu(n))}return e}slotById(t){const e=this.slotLayout;if(e){const r=cu(t),n=r?su(e,r):null;return n?Mu(n):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,r=0,n){const i=this.slotLayout,o=i?cu(t):null,s=o?su(i,o):null,a=s?yu(e,s,r,n):null;return a?{...a,anchorId:s.anchorId}:null}get arrangementStrategy(){return p}canReceive(t,e){const r=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return K.log({role:"target",contract:"canReceive",component:this,args:{carrier:$(t)},result:r}),r}findSlot(t){const e=this.slots.length?this.slots:ku;for(const r of e){if(!Su(r,t))continue;const e=r.maxCount??this.arrangementStrategy.capacity(r),n=this._countOccupied(r.id);if(!(n>=e))return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:$(t)},result:{slotId:r.id,occupied:n,max:e}}),r}return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:$(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 w;r.getWorldQuaternion(n);const i=new w(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 k;r.getWorldPosition(n);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new k(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,h=Number(this.state?.height)||0,l=c.x+i.width/2-u/2,f=c.y+i.height/2-h/2,d=this._realObject,p=d?.placementMode??"floor",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:l,y:m,z:f},rotation:b}:{position:{x:l,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)}_slotIfAvailable(t,e){if(!t||!Su(t,e))return null;const r=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<r?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[W]===t).length;const r=this.components;return r?r.filter(e=>e.parent===this&&e[W]===t).length:0}},e.__hasCapacity=!0,e}function zu(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,h=n+o/2,l="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/2,lz:0,odx:1,odz:0},{lx:0,lz:-o/2,odx:0,odz:-1},{lx:0,lz:o/2,odx:0,odz:1}].map(t=>{var e,r;return{worldPos:(e=t.lx,r=t.lz,{x:u+e*a-r*c,z:h+e*c+r*a}),direction:{x:l*(t.odx*a-t.odz*c),z:l*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Au(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,h=n+o/2,l=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:h+t*g+e*p}),m=c?{lx:0,lz:-l}:{lx:-l,lz:0},b=c?{lx:0,lz:l}:{lx:l,lz:0},x=y(m.lx,m.lz),v=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},M={x:-k.x,z:-k.z},S=(c?i:o)/2;return a?{inbounds:[{worldPos:v,direction:M,halfSpan:S}],outbounds:[{worldPos:x,direction:M,halfSpan:S}]}:{inbounds:[{worldPos:x,direction:k,halfSpan:S}],outbounds:[{worldPos:v,direction:k,halfSpan:S}]}}function Tu(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,h=Math.cos(o),l=Math.sin(o),f=(t,e)=>({x:a+t*h-e*l,z:c+t*l+e*h});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Ou(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,h="reverse"===t.status;if(n<=0||i<=0)return{inbounds:[],outbounds:[]};const l={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 h?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:l,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:l,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function Iu(t){const e=Au(t),r=e.outbounds[0];if(!r)return{inbounds:zu(t,"inbound"),outbounds:[]};const n=zu(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 ju(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 Pu(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),h=Math.sin(-c),l=t-s,f=e-a,d=l*u-f*h,p=l*h+f*u;return Math.abs(d)<=i/2+n&&Math.abs(p)<=o/2+n}function Ru(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,h=e.z;const l="number"==typeof r.rotation?r.rotation:0;if(0!==l){const t=Math.cos(-l),e=Math.sin(-l),r=a*e+c*t,n=u*e+h*t;a=a*t-c*e,c=r,u=u*t-h*e,h=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(h)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/h,e=(d-c)/h;p=Math.max(p,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<p?1/0:p>=0?p:g>=0?Math.min(-p,g):-g}function Cu(t,e,r,n=6){return!!Pu(t.worldPos.x,t.worldPos.z,e,n)&&(!r||t.direction.x*r.x+t.direction.z*r.z>=0)}function Nu(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(!ju(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(Cu(t,i.bounds,n,o)){const r=Ru(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 Fu(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=Nu(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 Du(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 Lu(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 Yu(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:Lu(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 $u(t,e,r){const n=Yu(t,e,r);return n.length?n[0]:-1}function Uu(t,e,r){return e===r||Yu(t,e,r).length>0}function qu(t,e){const r=new Set;for(const n of Du(t,e))for(const e of n)t.sinks.has(e)&&r.add(e);return r}function Wu(t,e,r){return Bu(t,e,r).map(t=>t.index)}function Bu(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:Lu(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 Gu(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 Xu(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?.downstreamRef;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=Nu(n,Xu(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 Vu(t){return!!t&&"function"==typeof t.routingConstraints}function Zu(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Qu(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=th(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=Vu(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=Ju(t.accumulated,i);if(!o)continue;const a=Ku(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(Zu(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=Ju(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=th(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 Ju(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 Ku(t,e,r){if("straight"===e&&t.state?.downstreamRef)return th(r,t.state.downstreamRef);const n=th(r,e);if(n)return n;const i=Hu(t);return i?th(r,i):null}function th(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 eh(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function rh(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=[],h=new Map,l=[],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)l.push({pos:t,pt:i});n&&f.set(i,n)}const d=(t,e)=>{const n=c(t,e),i=h.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of l)eh(t.pos,n)<=r&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)eh(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}),h.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=eh(u[n].pos,t);i<r&&(r=i,e=n)}for(const n of l){const i=eh(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=[],x=(e,r)=>{if(void 0===s[e])return s[e]=r,void b.push(e);s[e]!==r&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const r=h.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;x(o.seg,c)}},_=()=>{for(;b.length;)v(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=eh(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;x(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=h.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=h.get(`${t}:start`),i=h.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 M=new Map;for(let e=0;e<o;e++)M.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function nh(...t){}function ih(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function oh(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*sh(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*sh(t)}function ah(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,h=Math.cos(-a),l=Math.sin(-a),f=c*h-u*l,d=c*l+u*h;return Math.abs(f)<=n/2+r&&Math.abs(d)<=i/2+r}function ch(t){const e=[],r=[],n=[],i=[];for(const o of sh(t)){const t=oh(o);if(!t)continue;if(o.flowOrientable){const r=Tu(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])ah(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of r)ah(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=rh(e,r,8,n,60).directions;return e.length,r.length,n.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function uh(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let r=e.__flowOrientation;if(!r){e.__flowComputing=!0;try{r={map:ch(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=r}const n=oh(t),i=n?r.map.get(n):void 0;return"reverse"===i||"forward"!==i&&void 0}function hh(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function lh(t,e,r,n){if(!t||!e)return null;const i=[],o=t=>{if(!t||t===n)return;if(function(t,e){const r=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(r)&&r.includes(e)}(t,e)&&hh(t)){const e=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}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(r.x,r.y)})}const s=t.components;if(Array.isArray(s))for(const t of s)o(t)};return o(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function fh(t){return!!t&&"function"==typeof t.routingDestination}function dh(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*ph(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*ph(t)}function gh(t){const e=[],r=new Map,n=new Map,i=new Set,o=[];for(const s of ph(t)){"function"==typeof s?.registerWithHost&&o.push(s);const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks?s.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||fh(s)||c||hh(s)))continue;const u=dh(s);if(!u)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=s.getSegmentTopology()}catch{continue}if(!h)continue}const l=s.state??{},f={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation};if(e.push({id:u,topology:h,bounds:f,links:a}),n.set(u,s),fh(s)){i.add(u);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=r.get(t)??[];e.push(u),r.set(t,e)}}}return{nodes:e,destToSinks:r,components:n,routingTargetIds:i,stationClients:o}}function yh(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:r,destToSinks:n,components:i,routingTargetIds:o,stationClients:s}=gh(t),a=Fu(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)};r(t);const n=[...e].sort((t,e)=>{const r=dh(t)??"",n=dh(e)??"";return r.localeCompare(n)});for(const e of n){const r=e.declaredHostRef?.();let n=null;if(r&&(n=t.findById?.(r)??null),!n){const r=e.hostCapability?.(),i=e.hostFacingPoint?.();r&&i&&(n=lh(t,r,i,e)?.component??null)}n&&"function"==typeof e.registerWithHost&&e.registerWithHost(n)}const i=e=>{if(!e)return;if(hh(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const r of e.resolveDownstream()){const n=t.findById?.(r);n&&e.registerDivertStation(r,n)}const r=e.components;if(Array.isArray(r))for(const t of r)i(t)};i(t)}(t,s);const c=new Set;for(const[t,e]of i){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const u=new Map;for(const t of o){const e=i.get(t);if("function"==typeof e?.routingWeight){const r=e.routingWeight();"number"==typeof r&&(!Number.isFinite(r)||r<=0)&&u.set(t,r)}}const h=Gu(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:n,components:i,issues:h},t.__flowGraph=e}return e}function mh(t){return yh(t)?.issues??[]}function bh(t){const e=yh(t);return e&&e.graph.nodes.size>0?e.graph:null}function xh(t,e){return yh(t)?.destToSinks.get(e)??[]}function vh(t,e){return yh(t)?.components.get(e)}function _h(t){const e=yh(t);return e?[...e.destToSinks.keys()]:[]}function wh(t){return dh(t)}function kh(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 Mh(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=kh(i.get(r.target));n<t&&(t=n,e=r)}return e}}}function Sh(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=yh(n);if(!o||0===o.graph.nodes.size)return null;const s=dh(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Bu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],h=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===h.length)return u[c[0].index]??null;const l=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=Mh(l,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(n),h,o.components);return u[f.index]??null}r({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),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 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,bh(t)}catch{return null}}}catch{}function Eh(t,e,r){const n=Sh(t,e,r);if(null==n)return null;const i=t?.root,o=vh(i,n)??i?.findById?.(n)??null;return o?{targetId:n,component:o,origin:"explicit"}:null}function zh(t){const e=t?.root,r=bh(e),n=wh(t);if(!r||!n)return null;const i=(r.out.get(n)??[]).find(Boolean);if(!i)return null;const o=vh(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Ah(t){const e=wh(t);return e?Th(t?.root,e):[]}function Th(t,e){if(!t||!e)return[];const r=bh(t);if(!r)return[];const n=new Set;for(const i of qu(r,e)){const e=vh(t,i);if(fh(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&n.add(t)}}return[...n]}function Oh(t,e){if(!t||!e)return[];const r=bh(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 qu(r,e)){const e=vh(t,o);if(!fh(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 Ih(t){return bh(t)}function jh(t){const e=bh(t);if(!e)return[];const r=new Set,n=new Set,i=t=>{if(!t)return;const o=wh(t);if(o&&e.nodes.has(o)){fh(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),Gu(e,{routingTargetIds:r,loopCapableIds:n})}function Ph(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 Rh={next:Eh,downstream:zh,reachableDestinations:Ah,reachableDestinationsFrom:Th,reachableDestinationsWeightedFrom:Oh,pickWeightedDestination:Ph,graphFor:Ih,validate:jh};function Ch(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 Nh(t){var e;const r=!!t.__hasCapacity,n=!!t.__hasTransferable,i=r?t:Eu(t),o=n?i:function(t){var e;return(e=class extends t{reserve(t,e){const r=this.findSlot(t);return r?{slot:r,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){K.log({role:"target",contract:"receive:enter",component:this,args:{carrier:$(t),options:e}});const r=this.reserve(t,e);if(!r){K.log({role:"target",contract:"receive:reject",component:this,args:{carrier:$(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(r,t,e)}commit(t,e,r={}){const n=t.slot,i=this._countOccupied(n.id),o=this.arrangementStrategy.positionAt(i,n,i,e);K.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:n.id,occupantCount:i,carrier:$(e)},result:o}),e[W]=n.id;const s=e._realObject;let a,c;s?.object3d&&(s.object3d.updateWorldMatrix(!0,!1),a=new k,c=new w,s.object3d.getWorldPosition(a),s.object3d.getWorldQuaternion(c));const{animated:u=!1,duration:h,ease:l}=r;"function"==typeof this.handoverIn?this.handoverIn(e,{slotId:n.id}):this.reparent?.(e,{animated:u,duration:h,ease:l}),!u&&e._realObject&&(e._realObject.suppressTransform=!1);{const t={},r=this.placementFor?.(e,{slot:n,index:i,occupantCount:i})??null;if(K.log({role:"target",contract:"placementFor",component:this,args:{carrier:$(e),slotId:n.id,index:i},result:r}),r){const i=e.state??{},o=this.state??{};t.left=r.position.x-(Number(i.width)||0)/2+(Number(o.width)||0)/2,t.top=r.position.z-(Number(i.height)||0)/2+(Number(o.height)||0)/2;const s=this._zPosFromSeatY(r.position.y,i.depth,n);null!==s&&(t.zPos=s),r.rotation&&q(t,r.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(n.localPosition&&Number.isFinite(n.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=n.localPosition.z+e}const r=this.acceptanceRotation?.(e,n);K.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:$(e),slotId:n.id},result:r}),r&&q(t,r)}const s=this.normalizePose?.(e,n);"function"==typeof this.normalizePose&&K.log({role:"target",contract:"normalizePose",component:this,args:{carrier:$(e),slotId:n.id},result:s}),s&&Object.assign(t,s),Object.keys(t).length&&(e.setState?.(t),K.log({role:"target",contract:"receive:setState",component:this,args:{carrier:$(e),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:n.id,preReceiveWorldPos:a,preReceiveWorldQuat:c}),K.log({role:"target",contract:"receive:done",component:this,args:{carrier:$(e),slotId:n.id}})}async dispatch(t,e,r={}){const n=new nt({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 K.log({role:"target",contract:"canAccept",component:this,args:{carrier:$(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}(i),s=[...t.capabilities??[]];r||s.push("Capacity","PlacementSurface"),n||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Gc((e=class extends(Ch(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){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:u?"".concat(u," ",c):c}),e.capabilities=Object.freeze(s),e.isFlowNode=!0,e))}function Fh(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:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),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{yt as BULGE_EPSILON,Eu as Capacity,It as CapacityEventTracker,Pt as CenteringQueueStrategy,g as CenteringSlotStrategy,fu as DEFAULT_SEAT_MARGIN,d as FixedSlotStrategy,Rh as FlowEngine,Nh as FlowNode,Nt as GridStacking,Hc as HOLDER_ANCHOR,Ch as Holdable,Gc as ItemsDataBinding,ht as NavGraph,Ct as PatternStacking,Et as PolygonPathPolyline,ct as ReservationTable,W as TRANSFER_SLOT_KEY,nt as Transfer,Ft as VolumeStacking,cu as addressOfSlotId,_h as allDestinations,ju as anchorsConnect,Mh as applyPolicy,q as applySeatingRotation,Dt as applyStackLayout,Ou as arcSegmentTopology,jt as autoWireBackPressure,Fu as buildFlowGraph,dt as buildNavGraph,vt as bulgeFromDrag,xt as bulgeHandlePosition,Uu as canReach,t as capability,f as chooseNearestPickupFrame,Xu as collectAdjacentSegments,vh as componentForNode,bt as computeArcParams,ch as computeFlowMap,Rt as computeStackPositions,wt as cornerHandlePosition,kt as cornerRadiusFromDrag,Cu as deliversInto,zh as downstream,_t as effectiveCornerRadius,Qu as enumerateDataScenarios,l as filterByToolType,lh as findNearestWithCapability,p as fixedSlotStrategy,zt as flattenPolygonPath,bh as flowGraphFor,mh as flowGraphIssues,uh as flowReverseFor,Lt as footprint2D,H as frameClock,ih as ftId,nh as ftrace,i as getAllCapabilityMeta,n as getCapabilityMeta,B as globalSimClock,Ih as graphFor,iu as gridCellOf,nu as gridSlotNo,mt as hasArc,Tt as hasCapacity,Ot as inferCapacity,Hu as inferDownstreamId,rh as inferFlowDirections,Fh as isFlowNode,hh as isGeometricHost,fh as isRoutingTarget,wu as judgeItemFit,Xc as layoutIssue,Nu as matchOutbounds,Eh as next,$u as nextHop,Yu as nextHops,Wu as nextHopsToAny,Bu as nextHopsToAnyDetailed,wh as nodeIdOf,tu as persistenceIssues,Ph as pickWeightedDestination,pt as planPathAStar,gt as planToReservations,Pu as pointInRotatedRect,At as polygonPathLength,s as quatFromYaw,Ru as rayAbsDistanceToRect,Du as reachableByOutbound,Ah as reachableDestinations,Th as reachableDestinationsFrom,Oh as reachableDestinationsWeightedFrom,qu as reachableSinks,et as receiptToJSON,zu as rectFaceAnchors,u as rectangularFootprintFrames,r as registerCapabilityMeta,ut as reservationTable,Sh as resolveNextHop,su as resolveSlot,pu as rotatedFootprint,gu as seatInSlot,yu as seatTransform,xh as sinksForDestination,uu as slotAddresses,eu as slotCount,lu as slotFrame,au as slotIdOf,ru as slotNumbers,_u as slotSpaceWarnings,mu as stackSeatTransforms,at as standardYieldPolicy,Tu as straightSegmentEndpoints,Iu as straightSegmentMultiInbound,Au as straightSegmentTopology,h as topApproachFrame,it as transferLog,K as transferTracer,Mt as uniformZ,jh as validate,Gu as validateFlowGraph,Kc as validateSlotLayout};
6
+ */const g=2e3,m={};function b(...t){t=function(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function v(...t){const e=t.join(" ");e in m||(m[e]=!0,b(...t))}function x(t,e,n){return Math.max(e,Math.min(n,t))}class _{static{_.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class w{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,i,o,s){let a=n[r+0],c=n[r+1],u=n[r+2],h=n[r+3],l=i[o+0],f=i[o+1],d=i[o+2],p=i[o+3];if(h!==p||a!==l||c!==f||u!==d){let t=a*l+c*f+u*d+h*p;t<0&&(l=-l,f=-f,d=-d,p=-p,t=-t);let e=1-s;if(t<.9995){const n=Math.acos(t),r=Math.sin(n);e=Math.sin(e*n)/r,a=a*e+l*(s=Math.sin(s*n)/r),c=c*e+f*s,u=u*e+d*s,h=h*e+p*s}else{a=a*e+l*s,c=c*e+f*s,u=u*e+d*s,h=h*e+p*s;const t=1/Math.sqrt(a*a+c*c+u*u+h*h);a*=t,c*=t,u*=t,h*=t}}t[e]=a,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,i,o){const s=n[r],a=n[r+1],c=n[r+2],u=n[r+3],h=i[o],l=i[o+1],f=i[o+2],d=i[o+3];return t[e]=s*d+u*h+a*f-c*l,t[e+1]=a*d+u*l+c*h-s*f,t[e+2]=c*d+u*f+s*l-a*h,t[e+3]=u*d-s*h-a*l-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,i=t._z,o=t._order,s=Math.cos,a=Math.sin,c=s(n/2),u=s(r/2),h=s(i/2),l=a(n/2),f=a(r/2),d=a(i/2);switch(o){case"XYZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"YXZ":this._x=l*u*h+c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"ZXY":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h-l*f*d;break;case"ZYX":this._x=l*u*h-c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h+l*f*d;break;case"YZX":this._x=l*u*h+c*f*d,this._y=c*f*h+l*u*d,this._z=c*u*d-l*f*h,this._w=c*u*h-l*f*d;break;case"XZY":this._x=l*u*h-c*f*d,this._y=c*f*h-l*u*d,this._z=c*u*d+l*f*h,this._w=c*u*h+l*f*d;break;default:b("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],s=e[5],a=e[9],c=e[2],u=e[6],h=e[10],l=n+s+h;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-a)*t,this._y=(i-c)*t,this._z=(o-r)*t}else if(n>s&&n>h){const t=2*Math.sqrt(1+n-s-h);this._w=(u-a)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+c)/t}else if(s>h){const t=2*Math.sqrt(1+s-n-h);this._w=(i-c)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+h-n-s);this._w=(o-r)/t,this._x=(i+c)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(x(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,s=e._x,a=e._y,c=e._z,u=e._w;return this._x=n*u+o*s+r*c-i*a,this._y=r*u+o*a+i*s-n*c,this._z=i*u+o*c+n*a-r*s,this._w=o*u-n*s-r*a-i*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,r=t._y,i=t._z,o=t._w,s=this.dot(t);s<0&&(n=-n,r=-r,i=-i,o=-o,s=-s);let a=1-e;if(s<.9995){const t=Math.acos(s),c=Math.sin(t);a=Math.sin(a*t)/c,e=Math.sin(e*t)/c,this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+r*e,this._z=this._z*a+i*e,this._w=this._w*a+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{static{k.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(S.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(S.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,s=t.z,a=t.w,c=2*(o*r-s*n),u=2*(s*e-i*r),h=2*(i*n-o*e);return this.x=e+a*c+o*h-s*u,this.y=n+a*u+s*c-i*h,this.z=r+a*h+i*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,s=e.y,a=e.z;return this.x=r*a-i*s,this.y=i*o-n*a,this.z=n*s-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(x(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const M=new k,S=new w;class z{static{z.prototype.isMatrix3=!0}constructor(t,e,n,r,i,o,s,a,c){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c)}set(t,e,n,r,i,o,s,a,c){const u=this.elements;return u[0]=t,u[1]=r,u[2]=s,u[3]=e,u[4]=i,u[5]=a,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[3],a=n[6],c=n[1],u=n[4],h=n[7],l=n[2],f=n[5],d=n[8],p=r[0],y=r[3],g=r[6],m=r[1],b=r[4],v=r[7],x=r[2],_=r[5],w=r[8];return i[0]=o*p+s*m+a*x,i[3]=o*y+s*b+a*_,i[6]=o*g+s*v+a*w,i[1]=c*p+u*m+h*x,i[4]=c*y+u*b+h*_,i[7]=c*g+u*v+h*w,i[2]=l*p+f*m+d*x,i[5]=l*y+f*b+d*_,i[8]=l*g+f*v+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8];return e*o*u-e*s*c-n*i*u+n*s*a+r*i*c-r*o*a}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=u*o-s*c,l=s*a-u*i,f=c*i-o*a,d=e*h+n*l+r*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const p=1/d;return t[0]=h*p,t[1]=(r*c-u*n)*p,t[2]=(s*n-r*o)*p,t[3]=l*p,t[4]=(u*e-r*a)*p,t[5]=(r*i-s*e)*p,t[6]=f*p,t[7]=(n*a-c*e)*p,t[8]=(o*e-n*i)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,s){const a=Math.cos(i),c=Math.sin(i);return this.set(n*a,n*c,-n*(a*o+c*s)+o+t,-r*c,r*a,-r*(-c*o+a*s)+s+e,0,0,1),this}scale(t,e){return v("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(E.makeScale(t,e)),this}rotate(t){return v("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(E.makeRotation(-t)),this}translate(t,e){return v("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(E.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const E=new z;class A{static{A.prototype.isVector4=!0}constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,s=.1,a=t.elements,c=a[0],u=a[4],h=a[8],l=a[1],f=a[5],d=a[9],p=a[2],y=a[6],g=a[10];if(Math.abs(u-l)<o&&Math.abs(h-p)<o&&Math.abs(d-y)<o){if(Math.abs(u+l)<s&&Math.abs(h+p)<s&&Math.abs(d+y)<s&&Math.abs(c+f+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(f+1)/2,m=(g+1)/2,b=(u+l)/4,v=(h+p)/4,x=(d+y)/4;return t>a&&t>m?t<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(t),r=b/n,i=v/n):a>m?a<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(a),n=b/r,i=x/r):m<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(m),n=v/i,r=x/i),this.set(n,r,i,e),this}let m=Math.sqrt((y-d)*(y-d)+(h-p)*(h-p)+(l-u)*(l-u));return Math.abs(m)<.001&&(m=1),this.x=(y-d)/m,this.y=(h-p)/m,this.z=(l-u)/m,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=x(this.x,t.x,e.x),this.y=x(this.y,t.y,e.y),this.z=x(this.z,t.z,e.z),this.w=x(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=x(this.x,t,e),this.y=x(this.y,t,e),this.z=x(this.z,t,e),this.w=x(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(x(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class T{static{T.prototype.isMatrix4=!0}constructor(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y)}set(t,e,n,r,i,o,s,a,c,u,h,l,f,d,p,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=s,g[13]=a,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=f,g[7]=d,g[11]=p,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new T).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,n=t.elements,r=1/O.setFromMatrixColumn(t,0).length(),i=1/O.setFromMatrixColumn(t,1).length(),o=1/O.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),s=Math.sin(n),a=Math.cos(r),c=Math.sin(r),u=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=-a*h,e[8]=c,e[1]=n+r*c,e[5]=t-i*c,e[9]=-s*a,e[2]=i-t*c,e[6]=r+n*c,e[10]=o*a}else if("YXZ"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t+i*s,e[4]=r*s-n,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-s,e[2]=n*s-r,e[6]=i+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*u,n=a*h,r=c*u,i=c*h;e[0]=t-i*s,e[4]=-o*h,e[8]=r+n*s,e[1]=n+r*s,e[5]=o*u,e[9]=i-t*s,e[2]=-o*c,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*u,n=o*h,r=s*u,i=s*h;e[0]=a*u,e[4]=r*c-n,e[8]=t*c+i,e[1]=a*h,e[5]=i*c+t,e[9]=n*c-r,e[2]=-c,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=i-t*h,e[8]=r*h+n,e[1]=h,e[5]=o*u,e[9]=-s*u,e[2]=-c*u,e[6]=n*h+r,e[10]=t-i*h}else if("XZY"===t.order){const t=o*a,n=o*c,r=s*a,i=s*c;e[0]=a*u,e[4]=-h,e[8]=c*u,e[1]=t*h+i,e[5]=o*u,e[9]=n*h-r,e[2]=r*h-n,e[6]=s*u,e[10]=i*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(j,t,P)}lookAt(t,e,n){const r=this.elements;return F.subVectors(t,e),0===F.lengthSq()&&(F.z=1),F.normalize(),R.crossVectors(n,F),0===R.lengthSq()&&(1===Math.abs(n.z)?F.x+=1e-4:F.z+=1e-4,F.normalize(),R.crossVectors(n,F)),R.normalize(),C.crossVectors(F,R),r[0]=R.x,r[4]=C.x,r[8]=F.x,r[1]=R.y,r[5]=C.y,r[9]=F.y,r[2]=R.z,r[6]=C.z,r[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],s=n[4],a=n[8],c=n[12],u=n[1],h=n[5],l=n[9],f=n[13],d=n[2],p=n[6],y=n[10],g=n[14],m=n[3],b=n[7],v=n[11],x=n[15],_=r[0],w=r[4],k=r[8],M=r[12],S=r[1],z=r[5],E=r[9],A=r[13],T=r[2],O=r[6],I=r[10],j=r[14],P=r[3],R=r[7],C=r[11],F=r[15];return i[0]=o*_+s*S+a*T+c*P,i[4]=o*w+s*z+a*O+c*R,i[8]=o*k+s*E+a*I+c*C,i[12]=o*M+s*A+a*j+c*F,i[1]=u*_+h*S+l*T+f*P,i[5]=u*w+h*z+l*O+f*R,i[9]=u*k+h*E+l*I+f*C,i[13]=u*M+h*A+l*j+f*F,i[2]=d*_+p*S+y*T+g*P,i[6]=d*w+p*z+y*O+g*R,i[10]=d*k+p*E+y*I+g*C,i[14]=d*M+p*A+y*j+g*F,i[3]=m*_+b*S+v*T+x*P,i[7]=m*w+b*z+v*O+x*R,i[11]=m*k+b*E+v*I+x*C,i[15]=m*M+b*A+v*j+x*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],s=t[5],a=t[9],c=t[13],u=t[2],h=t[6],l=t[10],f=t[14],d=t[3],p=t[7],y=t[11],g=t[15],m=a*f-c*l,b=s*f-c*h,v=s*l-a*h,x=o*f-c*u,_=o*l-a*u,w=o*h-s*u;return e*(p*m-y*b+g*v)-n*(d*m-y*x+g*_)+r*(d*b-p*x+g*w)-i*(d*v-p*_+y*w)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[1],o=t[5],s=t[9],a=t[2],c=t[6],u=t[10];return e*(o*u-s*c)-n*(i*u-s*a)+r*(i*c-o*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],u=t[8],h=t[9],l=t[10],f=t[11],d=t[12],p=t[13],y=t[14],g=t[15],m=e*s-n*o,b=e*a-r*o,v=e*c-i*o,x=n*a-r*s,_=n*c-i*s,w=r*c-i*a,k=u*p-h*d,M=u*y-l*d,S=u*g-f*d,z=h*y-l*p,E=h*g-f*p,A=l*g-f*y,T=m*A-b*E+v*z+x*S-_*M+w*k;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/T;return t[0]=(s*A-a*E+c*z)*O,t[1]=(r*E-n*A-i*z)*O,t[2]=(p*w-y*_+g*x)*O,t[3]=(l*_-h*w-f*x)*O,t[4]=(a*S-o*A-c*M)*O,t[5]=(e*A-r*S+i*M)*O,t[6]=(y*v-d*w-g*b)*O,t[7]=(u*w-l*v+f*b)*O,t[8]=(o*E-s*S+c*k)*O,t[9]=(n*S-e*E-i*k)*O,t[10]=(d*_-p*v+g*m)*O,t[11]=(h*v-u*_-f*m)*O,t[12]=(s*M-o*z-a*k)*O,t[13]=(e*z-n*M+r*k)*O,t[14]=(p*b-d*x-y*m)*O,t[15]=(u*x-h*b+l*m)*O,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,s=t.y,a=t.z,c=i*o,u=i*s;return this.set(c*o+n,c*s-r*a,c*a+r*s,0,c*s+r*a,u*s+n,u*a-r*o,0,c*a-r*s,u*a+r*o,i*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,s=e._z,a=e._w,c=i+i,u=o+o,h=s+s,l=i*c,f=i*u,d=i*h,p=o*u,y=o*h,g=s*h,m=a*c,b=a*u,v=a*h,x=n.x,_=n.y,w=n.z;return r[0]=(1-(p+g))*x,r[1]=(f+v)*x,r[2]=(d-b)*x,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(l+g))*_,r[6]=(y+m)*_,r[7]=0,r[8]=(d+b)*w,r[9]=(y-m)*w,r[10]=(1-(l+p))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;t.x=r[12],t.y=r[13],t.z=r[14];const i=this.determinantAffine();if(0===i)return n.set(1,1,1),e.identity(),this;let o=O.set(r[0],r[1],r[2]).length();const s=O.set(r[4],r[5],r[6]).length(),a=O.set(r[8],r[9],r[10]).length();i<0&&(o=-o),I.copy(this);const c=1/o,u=1/s,h=1/a;return I.elements[0]*=c,I.elements[1]*=c,I.elements[2]*=c,I.elements[4]*=u,I.elements[5]*=u,I.elements[6]*=u,I.elements[8]*=h,I.elements[9]*=h,I.elements[10]*=h,e.setFromRotationMatrix(I),n.x=o,n.y=s,n.z=a,this}makePerspective(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2*i/(e-t),h=2*i/(n-r),l=(e+t)/(e-t),f=(n+r)/(n-r);let d,p;if(a)d=i/(o-i),p=o*i/(o-i);else if(s===g)d=-(o+i)/(o-i),p=-2*o*i/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-i),p=-o*i/(o-i)}return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,i,o,s=2e3,a=!1){const c=this.elements,u=2/(e-t),h=2/(n-r),l=-(e+t)/(e-t),f=-(n+r)/(n-r);let d,p;if(a)d=1/(o-i),p=o/(o-i);else if(s===g)d=-2/(o-i),p=-(o+i)/(o-i);else{if(2001!==s)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);d=-1/(o-i),p=-i/(o-i)}return c[0]=u,c[4]=0,c[8]=0,c[12]=l,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const O=new k,I=new T,j=new k(0,0,0),P=new k(1,1,1),R=new k,C=new k,F=new k,N=new T,D=new w;class L{constructor(t=0,e=0,n=0,r=L.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],s=r[8],a=r[1],c=r[5],u=r[9],h=r[2],l=r[6],f=r[10];switch(e){case"XYZ":this._y=Math.asin(x(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(l,c),this._z=0);break;case"YXZ":this._x=Math.asin(-x(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,f),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(x(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-x(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(l,f),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,f));break;case"XZY":this._z=Math.asin(-x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(l,c),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-u,f),this._y=0);break;default:b("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return N.makeRotationFromQuaternion(t),this.setFromRotationMatrix(N,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}L.DEFAULT_ORDER="XYZ";class ${static{$.prototype.isMatrix2=!0}constructor(t,e,n,r){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,r){const i=this.elements;return i[0]=t,i[2]=e,i[1]=n,i[3]=r,this}}function U(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?b("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");const q=new L;function W(t,e){q.setFromQuaternion(new w(e.x,e.y,e.z,e.w),"YXZ"),t.rotationX=q.x,t.rotation=-q.y,t.rotationY=q.z}const Y="_transferSlotId";const B=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=B);const G=new class{constructor(){this.enabled=!1,this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}enable(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._frameCount=0,this._lastSnapshotTime=0,this.enabled=!0}disable(){this.enabled=!1}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){this.enabled||this.enable();const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,r=this._getResidents?.()??null;let i=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(i=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const o={fps:i,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...r??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,o}};function X(t){const e=t?.state;return{type:e?.type??t?.constructor?.name,id:e?.id,refid:e?.refid,className:t?.constructor?.name}}const H=new class{constructor(){this._realTime=0,this._totalTicks=0,this._subs=new Set,this._nextId=1,this._externals=new Set,this._externalNextId=1,this._rafId=null,this._lastWallTime=null,this._emaDt=16.67,this._ticking=!1,this._hasPendingRemoval=!1}get realTime(){return this._realTime}get simTime(){return B.now}get isRunning(){return null!==this._rafId}subscribe(t,e){const n=e?.component,r=n?.app??n?.root?.app;if(r&&"boolean"==typeof r.isViewMode&&!r.isViewMode)return()=>{};const i={id:this._nextId++,handler:t,description:e?.description??`<anonymous#${this._nextId-1}>`,componentRef:null!=e?.component&&"undefined"!=typeof WeakRef?new WeakRef(e.component):void 0,targetsGetter:e?.getTargets,metadata:e?.metadata,registeredAt:this._realTime,tickCount:0,totalDurationMs:0,lastDt:0,lastDurationMs:0};return this._subs.add(i),this.isRunning||this.start(),()=>{this._ticking?(i._removed=!0,this._hasPendingRemoval=!0):(this._subs.delete(i),0===this._subs.size&&this.stop())}}tick(t){const e=Math.min(Math.max(t,0),200);this._realTime+=e,G.enabled&&(this._totalTicks++,e>0&&(this._emaDt=.9*this._emaDt+.1*e));const n=B.tick(e),r=B.now;if(this._ticking=!0,G.enabled)for(const t of this._subs){if(t._removed)continue;const e=performance.now();try{t.handler(n,r)}finally{const r=performance.now()-e;t.tickCount++,t.totalDurationMs+=r,t.lastDt=n,t.lastDurationMs=r}}else for(const t of this._subs)t._removed||t.handler(n,r);if(this._ticking=!1,this._hasPendingRemoval){this._hasPendingRemoval=!1;for(const t of this._subs)t._removed&&this._subs.delete(t);0===this._subs.size&&this.stop()}}start(){if(null!==this._rafId)return;if("undefined"==typeof requestAnimationFrame)return;this._lastWallTime=null;const t=()=>{if(null===this._rafId)return;const e=performance.now(),n=null===this._lastWallTime?0:e-this._lastWallTime;this._lastWallTime=e,this.tick(n),null!==this._rafId&&(this._rafId=requestAnimationFrame(t))};this._rafId=requestAnimationFrame(t)}stop(){null!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._lastWallTime=null}registerExternalAnimation(t,e,n){const r={id:this._externalNextId++,description:t,source:e,metadata:n,registeredAt:this._realTime};return this._externals.add(r),{update:t=>{r.metadata={...r.metadata??{},...t}},unregister:()=>{this._externals.delete(r)}}}snapshot(){const t=[];for(const e of this._subs){if(e._removed)continue;let n;const r=e.componentRef?.deref();let i;if(r&&(n=X(r)),e.targetsGetter)try{const t=e.targetsGetter();if(null!=t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(X(t));n.length>0&&(i=n)}}catch{}t.push({id:e.id,description:e.description,componentInfo:n,targetInfos:i,metadata:e.metadata,registeredAt:e.registeredAt,tickCount:e.tickCount,totalDurationMs:Math.round(100*e.totalDurationMs)/100,avgDurationMs:e.tickCount>0?Math.round(e.totalDurationMs/e.tickCount*100)/100:0,lastDt:Math.round(100*e.lastDt)/100,lastDurationMs:Math.round(100*e.lastDurationMs)/100})}const e=[];for(const t of this._externals)e.push({id:t.id,description:t.description,source:t.source,metadata:t.metadata,registeredAt:t.registeredAt,liveDurationMs:Math.round(this._realTime-t.registeredAt)});return{realTime:Math.round(this._realTime),simTime:Math.round(B.now),isRunning:this.isRunning,speed:B.speed,paused:B.isPaused,totalTicks:this._totalTicks,ticksPerSecond:this._emaDt>0?Math.round(1e3/this._emaDt):0,totalSubs:t.length,subscriptions:t,externalAnimations:e}}};let V=null;const Z=[],Q=new Set;function J(t){if(!t)return;const e=t?.state?.id??t?.id??t?.refid;return void 0!==e?String(e):void 0}const K={beginContext(t){V=t},endContext(){V=null},current:()=>V,log(t){const e={role:t.role,contract:t.contract,componentId:t.componentId??J(t.component),componentType:t.componentType??(n=t.component,n?.state?.type??n?.type),atSimMs:B.now,args:t.args,result:t.result,error:t.error};var n;V?V.pushTrace(e):(Z.push(e),Z.length>500&&Z.shift(),Q.forEach(t=>{try{t(e)}catch{}}))},standaloneEvents:()=>[...Z],onStandalone:t=>(Q.add(t),()=>{Q.delete(t)}),clearStandalone(){Z.length=0}};function tt(t){if(!t)return;const e=t?.state?.refid??t?.refid;if(null==e)return;const n=String(e);return n.length>0?n:void 0}function et(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},n=t.sourceId??tt(t.source),r=t.targetId??tt(t.target),i=t.carrierId??tt(t.carrier);return void 0!==n&&(e.sourceId=n),void 0!==r&&(e.targetId=r),void 0!==i&&(e.carrierId=i),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}let nt=1;class rt{constructor(t){this._phase="pending",this._slot=null,this._reservation=null,this._traceEvents=[],this.meta={},this.id="xfer-"+nt++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:B.now}}pushTrace(t){this._traceEvents.push({atSimMs:t.atSimMs??B.now,...t})}get phase(){return this._phase}get timeline(){return this._timeline}_rollback(){this._phase="rolled-back";const t=this._buildReceipt();return it.append(t),t}_planAndReserve(){this._phase="planning",this._timeline.planStartAt=B.now;const t=this.target.canAccept?.(this.carrier);if(t&&t.ok)this._slot=t.slot;else{if(t&&!t.ok&&"no-slots-defined"!==t.reason)return this._rejectReason=t.reason,this._rollback();if(t||"function"!=typeof this.target.canReceive)this._slot=null;else{if(!this.target.canReceive(this.carrier))return this._rejectReason="cannot-receive",this._rollback();this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}}return null===this._slot||"function"!=typeof this.target.reserve||"function"!=typeof this.target.commit||(this._reservation=this.target.reserve(this.carrier,{source:this.source}),this._reservation)?(this._timeline.planEndAt=B.now,null):(this._rejectReason="cannot-reserve",this._rollback())}_physicalFailed(t){return this._reservation&&this.target.release?.(this._reservation),this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._rollback()}_handoffFailed(t){throw this._rejectReason=`handoff-failed: ${t.message??"unknown"}`,this._phase="rolled-back",it.append(this._buildReceipt()),t}_commitReserved(){if(this._reservation&&"function"==typeof this.target.commit){try{this.target.commit(this._reservation,this.carrier,this.options)}catch(t){this.target.release?.(this._reservation),this._handoffFailed(t)}return!0}return!1}_finishCommitted(){this._phase="committed",this._timeline.committedAt=B.now;const t=this._buildReceipt();return it.append(t),t}_runPhysicalSync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{const t=this.physical();t instanceof Promise&&t.catch(()=>{})}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}async _runPhysicalAsync(){if(!this.physical)return null;this._phase="physical",this._timeline.physicalStartAt=B.now;try{await this.physical()}catch(t){return this._physicalFailed(t)}return this._timeline.physicalEndAt=B.now,null}_runReceiveSync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{const e=t.call(this.target,this.carrier,this.options);e instanceof Promise&&e.catch(()=>{})}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async _runReceiveAsync(){const t=this.target.accept??this.target.receive;if("function"==typeof t)try{await t.call(this.target,this.carrier,this.options)}catch(t){this._handoffFailed(t)}else K.log({role:"target",contract:"handoff:noop",component:this.target,args:{reason:"no-accept-method"}})}async execute(){K.beginContext(this),K.log({role:"transfer",contract:"execute:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{return await this._executeImpl()}finally{K.log({role:"transfer",contract:"execute:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}executeSync(){K.beginContext(this),K.log({role:"transfer",contract:"executeSync:begin",args:{transferId:this.id,source:tt(this.source),target:tt(this.target),carrier:tt(this.carrier)}});try{const t=this._planAndReserve();if(t)return t;const e=this._runPhysicalSync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||this._runReceiveSync(),this._finishCommitted())}finally{K.log({role:"transfer",contract:"executeSync:end",args:{transferId:this.id,phase:this._phase}}),K.endContext()}}async _executeImpl(){const t=this._planAndReserve();if(t)return t;const e=await this._runPhysicalAsync();return e||(this._phase="handoff",this._timeline.handoffAt=B.now,this._commitReserved()||await this._runReceiveAsync(),this._finishCommitted())}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",it.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:tt(this.source),targetId:tt(this.target),carrierId:tt(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason,traceEvents:[...this._traceEvents],meta:Object.keys(this.meta).length>0?{...this.meta}:void 0}}}const it=new class{constructor(){this._flows=new Map,this._targetCount=new Map,this._byPhase=new Map,this._byRejectReason=new Map,this._total=0,this._committedDurationSum=0,this._committedCount=0,this._listeners=new Set}append(t){this._total++,this._byPhase.set(t.phase,(this._byPhase.get(t.phase)??0)+1);const e=t.sourceId??tt(t.source),n=t.targetId??tt(t.target);if("committed"===t.phase){if(e&&n){const t=e+">"+n;this._flows.set(t,(this._flows.get(t)??0)+1)}n&&this._targetCount.set(n,(this._targetCount.get(n)??0)+1),void 0!==t.timeline.committedAt&&(this._committedDurationSum+=t.timeline.committedAt-t.timeline.initiatedAt,this._committedCount++)}else if("rolled-back"===t.phase&&t.rejectReason){this._byRejectReason.set(t.rejectReason,(this._byRejectReason.get(t.rejectReason)??0)+1);try{t.source?._bumpRejected?.(t.carrier,t.rejectReason)}catch{}}this._listeners.forEach(e=>e(t))}flows(){return this._flows}targetCounts(){return this._targetCount}stats(){const t={};this._byPhase.forEach((e,n)=>{t[n]=e});const e=t["rolled-back"]??0;return{total:this._total,byPhase:t,committed:t.committed??0,rolledBack:e,rejectionRate:this._total>0?e/this._total:0,avgTransferDurationMs:this._committedCount>0?this._committedDurationSum/this._committedCount:0}}rejectReasonCounts(){return this._byRejectReason}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._flows.clear(),this._targetCount.clear(),this._byPhase.clear(),this._byRejectReason.clear(),this._total=0,this._committedDurationSum=0,this._committedCount=0}entries(){return[]}forCarrier(t){return[]}forCarrierId(t){return[]}forSourceId(t){return[]}forTargetId(t){return[]}forPhase(t){return[]}inTimeRange(t,e,n){return[]}groupByRejectReason(){return new Map}toJSON(){return[]}fromJSON(t){}replayTo(t){}setMaxEntries(t){}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=it);let ot=1;function st(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const at={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class ct{constructor(t=at){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+ot++},n=(this._byResource.get(e.resource)??[]).filter(t=>st(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const r=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(r.every(t=>"b-yields"===t.decision)){const r=n.slice();for(const t of r)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:r,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:r}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:r}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>st(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let r=this._byReserver.get(t.reserverId);r||(r=[],this._byReserver.set(t.reserverId,r)),r.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const r=this._byReserver.get(t.reserverId);if(r){const e=r.findIndex(e=>e.id===t.id);e>=0&&r.splice(e,1),0===r.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const ut=new ct;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=ut);class ht{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const r of this.nodes.values()){const i=lt(r.position,t);i<n&&(n=i,e=r)}return e}}function lt(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}function ft(t,e){return Math.sqrt(lt(t,e))}function dt(t,e,n={}){const r=new ht,i=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,o=`${e.id}:end`;r.addNode({id:n,position:t[0],type:"lane-start"}),r.addNode({id:o,position:t[t.length-1],type:"lane-end"}),r.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:o});let s=0;for(let e=1;e<t.length;e++)s+=ft(t[e-1],t[e]);const a=s/(e.speedLimit??i)*1e3;r.addEdge({fromNode:n,toNode:o,resource:e.id,distance:s,durationMs:a,forward:!0}),"twoway"===e.direction&&r.addEdge({fromNode:o,toNode:n,resource:e.id,distance:s,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const i=r.laneEndpoints.get(n);if(!i)continue;const o=r.nodes.get(i.startNodeId).position,s=r.nodes.get(i.endNodeId).position;let a=0,c=0,u=0;for(const e of t.lanes){if(e===n)continue;const t=r.laneEndpoints.get(e);if(!t)continue;const i=r.nodes.get(t.startNodeId).position,h=r.nodes.get(t.endNodeId).position;a+=Math.min(lt(o,i),lt(o,h)),c+=Math.min(lt(s,i),lt(s,h)),u++}if(0===u)continue;const h=a<c?i.startNodeId:i.endNodeId;e.push({laneId:n,nodeId:h,pos:r.nodes.get(h).position})}for(let n=0;n<e.length;n++)for(let i=0;i<e.length;i++){if(n===i)continue;const o=e[n],s=e[i],a=ft(o.pos,s.pos);r.addEdge({fromNode:o.nodeId,toNode:s.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return r}function pt(t,e,n,r={}){const i=t.nodes.get(e),o=t.nodes.get(n);if(!i||!o)return null;const s=r.speed?.max??100,a=e=>{const n=t.nodes.get(e);var r,i;return(r=n.position,i=o.position,Math.sqrt(function(t,e){const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return n*n+r*r+i*i}(r,i)))/s*1e3},c=new Map,u=new Set,h=new Set,l={nodeId:e,gScore:0,fScore:a(e)};c.set(e,l),u.add(e);const f=r.startSimMs??0,d=r.deadlineSimMs;for(;u.size>0;){let e=null,r=null;for(const t of u){const n=c.get(t);(!r||n.fScore<r.fScore||n.fScore===r.fScore&&t<e)&&(r=n,e=t)}if(!r||!e)return null;if(e===n){const t=[];let e=r,n=0;for(;e&&e.cameFromEdge;){const r=e.cameFromEdge,i=f+(e.gScore-r.durationMs);t.unshift({resource:r.resource,timeWindow:{startSimMs:i,endSimMs:i+r.durationMs},fromPos:r.fromPos,toPos:r.toPos}),n+=r.distance,e=c.get(r.fromNodeId)}const i=r.gScore;return void 0!==d&&f+i>d?null:{segments:t,totalDurationMs:i,totalDistance:n}}u.delete(e),h.add(e);for(const n of t.edgesFrom(e)){if(h.has(n.toNode))continue;const e=r.gScore+n.durationMs,i=c.get(n.toNode);if(!i||e<i.gScore){const r=t.nodes.get(n.fromNode),i=t.nodes.get(n.toNode),o={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:r.position,toPos:i.position}};c.set(n.toNode,o),u.add(n.toNode)}}}return null}function yt(t,e,n=0,r){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:r}))}const gt=.5;function mt(t){const e=t.bulge;return null!=e&&Number.isFinite(e)&&Math.abs(e)>=.5}function bt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o||!Number.isFinite(n)||Math.abs(n)<1e-9)return null;const s=Math.abs(n),a=(o*o+4*s*s)/(8*s),c=n>0?1:-1,u=a-s,h=(t.x+e.x)/2-c*(i/o)*u,l=(t.y+e.y)/2-c*-(r/o)*u;return{cx:h,cy:l,radius:a,startAngle:Math.atan2(t.y-l,t.x-h),endAngle:Math.atan2(e.y-l,e.x-h),clockwise:n<0}}function vt(t,e,n=0,r=16){const i=e.x-t.x,o=e.y-t.y,s=Math.sqrt(i*i+o*o);if(0===s)return null;const a=o/s,c=-(i/s),u=Number.isFinite(n)?n:0,h=Math.abs(u)>=1e-6?u:r;return{x:(t.x+e.x)/2+a*h,y:(t.y+e.y)/2+c*h,perpX:a,perpY:c}}function xt(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o)return 0;const s=i/o,a=-(r/o),c=(t.x+e.x)/2,u=(t.y+e.y)/2;let h=(n.x-c)*s+(n.y-u)*a;if(Math.abs(h)<.5)return 0;return h>o&&(h=o),h<-o&&(h=-o),h}function _t(t,e){const n=t.radius,r=Number.isFinite(e)?e:0;return null!=n&&Number.isFinite(n)?Math.max(0,n):Math.max(0,r)}function wt(t,e,n,r,i=16){const o=t.x-e.x,s=t.y-e.y,a=Math.sqrt(o*o+s*s);if(0===a)return null;const c=n.x-e.x,u=n.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h)return null;const l=o/a+c/h,f=s/a+u/h,d=Math.sqrt(l*l+f*f);if(d<1e-9)return null;const p=l/d,y=f/d,g=Math.max(r,i);return{x:e.x+p*g,y:e.y+y*g,bisectorX:p,bisectorY:y}}function kt(t,e,n,r){const i=t.x-e.x,o=t.y-e.y,s=Math.sqrt(i*i+o*o),a=n.x-e.x,c=n.y-e.y,u=Math.sqrt(a*a+c*c);if(0===s||0===u)return 0;const h=i/s+a/u,l=o/s+c/u,f=Math.sqrt(h*h+l*l);if(f<1e-9)return 0;const d=h/f,p=l/f,y=(r.x-e.x)*d+(r.y-e.y)*p,g=Math.min(s,u)/2;return Math.max(0,Math.min(y,g))}function Mt(t){if(0===t.length)return 0;let e;for(const n of t){const t=n.z??0;if(!Number.isFinite(t))return null;if(void 0===e)e=t;else if(Math.abs(t-e)>1e-9)return null}return e??0}const St={closed:!0,round:0,divisions:24};class zt{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const r=t[e].x-t[e-1].x,i=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(r*r+i*i))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const r=this.cumulative;let i=0,o=r.length-2;for(;i<o;){const t=i+o>>1;r[t+1]<=n?i=t+1:o=t}const s=r[i+1]-r[i],a=s>0?(n-r[i])/s:0,c=this.points[i],u=this.points[i+1],h=u.x-c.x,l=u.y-c.y;return{x:c.x+h*a,y:c.y+l*a,theta:0===h&&0===l?0:Math.atan2(l,h)}}}function Et(t,e={}){const n={...St,...e},r=t.length;if(0===r)return new zt([],n.closed);if(1===r)return new zt([{x:t[0].x,y:t[0].y}],n.closed);const i=[],o=(t,e)=>{if(i.length>0){const n=i[i.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}i.push({x:t,y:e})},s=(n.closed,r);for(let e=0;e<s;e++){const i=0===e?n.closed?r-1:-1:e-1,s=e===r-1?n.closed?0:-1:e+1,a=i>=0?t[i]:null,c=t[e],u=s>=0?t[s]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&u?_t(c,n.round):0;let l,f,d,p;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(h,t/2);l=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else l=c.x,f=c.y;if(u){const t=Math.sqrt((u.x-c.x)**2+(u.y-c.y)**2),e=0!==t?Math.atan2(u.x-c.x,u.y-c.y):0,n=Math.min(h,t/2);d=Math.sin(e)*n+c.x,p=Math.cos(e)*n+c.y}else d=c.x,p=c.y;if(o(l,f),h>0&&a&&u)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,r=1-e;o(r*r*l+2*r*e*c.x+e*e*d,r*r*f+2*r*e*c.y+e*e*p)}else l===d&&f===p||o(d,p);if(u&&mt(c)){const t=_t(u,n.round),e=Math.sqrt((c.x-u.x)**2+(c.y-u.y)**2),r=0!==e?Math.atan2(c.x-u.x,c.y-u.y):0,i=Math.min(t,e/2),s=bt({x:d,y:p},{x:Math.sin(r)*i+u.x,y:Math.cos(r)*i+u.y},c.bulge);if(s){let t=s.endAngle-s.startAngle;if(s.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const r=e/n.divisions,i=s.startAngle+t*r;o(s.cx+s.radius*Math.cos(i),s.cy+s.radius*Math.sin(i))}}}}if(n.closed&&i.length>0){const t=i[0],e=i[i.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&i.push({x:t.x,y:t.y})}return new zt(i,n.closed)}function At(t,e){return Et(t,e).length}function Tt(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function Ot(t){if(Tt(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class It{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function jt(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),r=e.onAvailable(()=>t.resumeEmit());return Ot(e).isFull&&t.pauseEmit(),()=>{n?.(),r?.()}}class Pt{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,r){const i=e.maxCount??1/0;if(t<0||t>=i)return null;const o=this.owner?.state?.width??0,s=this.owner?.state?.height??0,a=r?.state?.width??0,c=r?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(s-c)/2),z:0}:{x:Math.max(0,(o-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Rt(t,e,n,r,i,o,s){const a=n.w,c=n.h,u=r.w,h=r.h,l=r.d,f=[],d=u+i,p=h+i,y=Math.max(1,Math.floor((a+i)/d)),g=Math.max(1,Math.floor((c+i)/p)),m=y*g,b=o&&o>0?Math.floor(o):4;if("row"===t||"column"===t){const n=s?.advanceAlongX??!1,r=s?.reverse??!1,i=n?y:g,o=n?g:y,u=(t,e,r)=>((t,e,n)=>f.push({x:-a/2+(t+.5)*d,y:n*l+l/2,z:-c/2+(e+.5)*p}))(n?t:e,n?e:t,r);let h=0;for(let n=0;n<i&&h<e;n++){const s=r?i-1-n:n;if("column"===t)for(let t=0;t<o&&h<e;t++)for(let n=0;n<b&&h<e;n++)u(s,t,n),h++;else for(let t=0;t<b&&h<e;t++)for(let n=0;n<o&&h<e;n++)u(s,n,t),h++}return f}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,y-n),r=Math.max(1,g-n),i=e*r,s=Math.min(t,i);for(let t=0;t<s;t++){const i=t%e,o=Math.floor(t/e),s=-a/2+(i+(y-e)/2+.5)*d,u=-c/2+(o+(g-r)/2+.5)*p;f.push({x:s,y:n*l+l/2,z:u})}if(t-=s,n++,1===e&&1===r){for(let e=0;e<t;e++)f.push({x:0,y:(n+e)*l+l/2,z:0});break}if(o&&n>=o)break}return f}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/m),r=n%m,i=r%y,s=Math.floor(r/y),g=(t(2*n)-.5)*u*.2,b=(t(2*n+1)-.5)*h*.2,v=-a/2+(i+.5)*d+g,x=-c/2+(s+.5)*p+b;if(f.push({x:v,y:e*l+l/2,z:x}),o&&e>=o-1&&r===m-1)break}return f}for(let n=0;n<e;n++){const e=Math.floor(n/m);if(o&&e>=o)break;const r=n%m,i=r%y,s=Math.floor(r/y);let u=-a/2+(i+.5)*d;const h=-c/2+(s+.5)*p;"staggered"===t&&e%2==1&&(u+=d/2),f.push({x:u,y:e*l+l/2,z:h})}return f}class Ct{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,r={}){const i=r.gap??this.defaults.gap??0,o=r.heightLimit??this.defaults.heightLimit,s=r.fill??this.defaults.fill;return Rt(this.pattern,t,e,n,i,o,s).map(t=>({position:t}))}}class Ft{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,r={}){const i=Math.max(1,this.cols),o=Math.max(1,this.rows),s=i*o,a=r.gap??this.defaults.gap??0,c=n.w+a,u=n.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/s),r=e%s,a=r%i,l=Math.floor(r/i);h.push({position:{x:(a-(i-1)/2)*c,z:(l-(o-1)/2)*u,y:t*n.d+n.d/2}})}return h}}class Nt{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,r=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-r)/(e.h+r))),pitchX:e.w+n,pitchZ:e.h+r}}capacity(t,e,n){const{cols:r,rows:i}=this.grid(t,e);return r*i*Math.max(1,Math.floor(n))}layout(t,e,n,r={}){const{cols:i,rows:o,pitchX:s,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,u=null!=r.heightLimit?Math.max(1,Math.floor(r.heightLimit)):1/0,h=Number.isFinite(u),l=this.sliceFirst&&h,f=i*o,d=i*(h?u:1),p=i*o*(h?u:t),y=Math.min(t,p),g=[];for(let t=0;t<y;t++){let e,r,u;if(l){const n=Math.floor(t/d),o=t%d;e=o%i,u=Math.floor(o/i),r=n}else{u=Math.floor(t/f);const n=t%f;e=n%i,r=Math.floor(n/i)}this.fillFromFar&&(r=o-1-r),g.push({position:{x:(e-(i-1)/2)*s,z:(r-(o-1)/2)*a,y:u*c+n.d/2}})}return g}}function Dt(t,e,n,r=0){for(let i=0;i<e.length;i++){const o=e[i],s=n[i];o&&s&&(o.parent!==t&&t.attach(o),o.position.set(s.position.x,r+s.position.y,s.position.z),s.rotation?o.quaternion.set(s.rotation.x,s.rotation.y,s.rotation.z,s.rotation.w):o.quaternion.identity())}}function Lt(t,e,n,r=.12){const i=e.left+e.width/2,o=e.top+e.height/2,s=Math.min(n.w,n.h)*r,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let r=a.get(t);r||(r={x:i+e.position.x-n.w/2+s,y:o+e.position.z-n.h/2+s,w:n.w-2*s,h:n.h-2*s,count:0},a.set(t,r)),r.count++}return[...a.values()]}function $t(t,e){return t===e||t!=t&&e!=e}function Ut(t,e){for(var n=t.length;n--;)if($t(t[n][0],e))return n;return-1}var qt=Array.prototype.splice;function Wt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Wt.prototype.clear=function(){this.__data__=[],this.size=0},Wt.prototype.delete=function(t){var e=this.__data__,n=Ut(e,t);return!(n<0)&&(n==e.length-1?e.pop():qt.call(e,n,1),--this.size,!0)},Wt.prototype.get=function(t){var e=this.__data__,n=Ut(e,t);return n<0?void 0:e[n][1]},Wt.prototype.has=function(t){return Ut(this.__data__,t)>-1},Wt.prototype.set=function(t,e){var n=this.__data__,r=Ut(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var Yt="object"==typeof global&&global&&global.Object===Object&&global,Bt="object"==typeof self&&self&&self.Object===Object&&self,Gt=Yt||Bt||Function("return this")(),Xt=Gt.Symbol,Ht=Object.prototype,Vt=Ht.hasOwnProperty,Zt=Ht.toString,Qt=Xt?Xt.toStringTag:void 0;var Jt=Object.prototype.toString;var Kt=Xt?Xt.toStringTag:void 0;function te(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Kt&&Kt in Object(t)?function(t){var e=Vt.call(t,Qt),n=t[Qt];try{t[Qt]=void 0;var r=!0}catch(t){}var i=Zt.call(t);return r&&(e?t[Qt]=n:delete t[Qt]),i}(t):function(t){return Jt.call(t)}(t)}function ee(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ne(t){if(!ee(t))return!1;var e=te(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var re,ie=Gt["__core-js_shared__"],oe=(re=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"";var se=Function.prototype.toString;function ae(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ce=/^\[object .+?Constructor\]$/,ue=Function.prototype,he=Object.prototype,le=ue.toString,fe=he.hasOwnProperty,de=RegExp("^"+le.call(fe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pe(t){return!(!ee(t)||(e=t,oe&&oe in e))&&(ne(t)?de:ce).test(ae(t));var e}function ye(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return pe(n)?n:void 0}var ge=ye(Gt,"Map"),me=ye(Object,"create");var be=Object.prototype.hasOwnProperty;var ve=Object.prototype.hasOwnProperty;function xe(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _e(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function we(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}xe.prototype.clear=function(){this.__data__=me?me(null):{},this.size=0},xe.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},xe.prototype.get=function(t){var e=this.__data__;if(me){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return be.call(e,t)?e[t]:void 0},xe.prototype.has=function(t){var e=this.__data__;return me?void 0!==e[t]:ve.call(e,t)},xe.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=me&&void 0===e?"__lodash_hash_undefined__":e,this},we.prototype.clear=function(){this.size=0,this.__data__={hash:new xe,map:new(ge||Wt),string:new xe}},we.prototype.delete=function(t){var e=_e(this,t).delete(t);return this.size-=e?1:0,e},we.prototype.get=function(t){return _e(this,t).get(t)},we.prototype.has=function(t){return _e(this,t).has(t)},we.prototype.set=function(t,e){var n=_e(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function ke(t){var e=this.__data__=new Wt(t);this.size=e.size}ke.prototype.clear=function(){this.__data__=new Wt,this.size=0},ke.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ke.prototype.get=function(t){return this.__data__.get(t)},ke.prototype.has=function(t){return this.__data__.has(t)},ke.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Wt){var r=n.__data__;if(!ge||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new we(r)}return n.set(t,e),this.size=n.size,this};function Me(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new we;++e<n;)this.add(t[e])}function Se(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}Me.prototype.add=Me.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Me.prototype.has=function(t){return this.__data__.has(t)};function ze(t,e,n,r,i,o){var s=1&n,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),h=o.get(e);if(u&&h)return u==e&&h==t;var l=-1,f=!0,d=2&n?new Me:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var p=t[l],y=e[l];if(r)var g=s?r(y,p,l,e,t,o):r(p,y,l,t,e,o);if(void 0!==g){if(g)continue;f=!1;break}if(d){if(!Se(e,function(t,e){if(s=e,!d.has(s)&&(p===t||i(p,t,n,r,o)))return d.push(e);var s})){f=!1;break}}else if(p!==y&&!i(p,y,n,r,o)){f=!1;break}}return o.delete(t),o.delete(e),f}var Ee=Gt.Uint8Array;function Ae(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function Te(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var Oe=Xt?Xt.prototype:void 0,Ie=Oe?Oe.valueOf:void 0;function je(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var Pe=Array.isArray;function Re(){return[]}var Ce=Object.prototype.propertyIsEnumerable,Fe=Object.getOwnPropertySymbols,Ne=Fe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}(Fe(t),function(e){return Ce.call(t,e)}))}:Re;function De(t){return null!=t&&"object"==typeof t}function Le(t){return De(t)&&"[object Arguments]"==te(t)}var $e=Object.prototype,Ue=$e.hasOwnProperty,qe=$e.propertyIsEnumerable,We=Le(function(){return arguments}())?Le:function(t){return De(t)&&Ue.call(t,"callee")&&!qe.call(t,"callee")};var Ye="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Ye&&"object"==typeof module&&module&&!module.nodeType&&module,Ge=Be&&Be.exports===Ye?Gt.Buffer:void 0,Xe=(Ge?Ge.isBuffer:void 0)||function(){return!1},He=/^(?:0|[1-9]\d*)$/;function Ve(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&He.test(t))&&t>-1&&t%1==0&&t<e}function Ze(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Qe={};function Je(t){return function(e){return t(e)}}Qe["[object Float32Array]"]=Qe["[object Float64Array]"]=Qe["[object Int8Array]"]=Qe["[object Int16Array]"]=Qe["[object Int32Array]"]=Qe["[object Uint8Array]"]=Qe["[object Uint8ClampedArray]"]=Qe["[object Uint16Array]"]=Qe["[object Uint32Array]"]=!0,Qe["[object Arguments]"]=Qe["[object Array]"]=Qe["[object ArrayBuffer]"]=Qe["[object Boolean]"]=Qe["[object DataView]"]=Qe["[object Date]"]=Qe["[object Error]"]=Qe["[object Function]"]=Qe["[object Map]"]=Qe["[object Number]"]=Qe["[object Object]"]=Qe["[object RegExp]"]=Qe["[object Set]"]=Qe["[object String]"]=Qe["[object WeakMap]"]=!1;var Ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,tn=Ke&&"object"==typeof module&&module&&!module.nodeType&&module,en=tn&&tn.exports===Ke&&Yt.process,nn=function(){try{var t=tn&&tn.require&&tn.require("util").types;return t||en&&en.binding&&en.binding("util")}catch(t){}}(),rn=nn&&nn.isTypedArray,on=rn?Je(rn):function(t){return De(t)&&Ze(t.length)&&!!Qe[te(t)]},sn=Object.prototype.hasOwnProperty;function an(t,e){var n=Pe(t),r=!n&&We(t),i=!n&&!r&&Xe(t),o=!n&&!r&&!i&&on(t),s=n||r||i||o,a=s?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=a.length;for(var u in t)!e&&!sn.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ve(u,c))||a.push(u);return a}var cn=Object.prototype;function un(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||cn)}function hn(t,e){return function(n){return t(e(n))}}var ln=hn(Object.keys,Object),fn=Object.prototype.hasOwnProperty;function dn(t){if(!un(t))return ln(t);var e=[];for(var n in Object(t))fn.call(t,n)&&"constructor"!=n&&e.push(n);return e}function pn(t){return null!=t&&Ze(t.length)&&!ne(t)}function yn(t){return pn(t)?an(t):dn(t)}function gn(t){return function(t,e,n){var r=e(t);return Pe(t)?r:je(r,n(t))}(t,yn,Ne)}var mn=Object.prototype.hasOwnProperty;var bn=ye(Gt,"DataView"),vn=ye(Gt,"Promise"),xn=ye(Gt,"Set"),_n=ye(Gt,"WeakMap"),wn="[object Map]",kn="[object Promise]",Mn="[object Set]",Sn="[object WeakMap]",zn="[object DataView]",En=ae(bn),An=ae(ge),Tn=ae(vn),On=ae(xn),In=ae(_n),jn=te;(bn&&jn(new bn(new ArrayBuffer(1)))!=zn||ge&&jn(new ge)!=wn||vn&&jn(vn.resolve())!=kn||xn&&jn(new xn)!=Mn||_n&&jn(new _n)!=Sn)&&(jn=function(t){var e=te(t),n="[object Object]"==e?t.constructor:void 0,r=n?ae(n):"";if(r)switch(r){case En:return zn;case An:return wn;case Tn:return kn;case On:return Mn;case In:return Sn}return e});var Pn="[object Arguments]",Rn="[object Array]",Cn="[object Object]",Fn=Object.prototype.hasOwnProperty;function Nn(t,e,n,r,i,o){var s=Pe(t),a=Pe(e),c=s?Rn:jn(t),u=a?Rn:jn(e),h=(c=c==Pn?Cn:c)==Cn,l=(u=u==Pn?Cn:u)==Cn,f=c==u;if(f&&Xe(t)){if(!Xe(e))return!1;s=!0,h=!1}if(f&&!h)return o||(o=new ke),s||on(t)?ze(t,e,n,r,i,o):function(t,e,n,r,i,o,s){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ee(t),new Ee(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return $t(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ae;case"[object Set]":var c=1&r;if(a||(a=Te),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var h=ze(a(t),a(e),r,i,o,s);return s.delete(t),h;case"[object Symbol]":if(Ie)return Ie.call(t)==Ie.call(e)}return!1}(t,e,c,n,r,i,o);if(!(1&n)){var d=h&&Fn.call(t,"__wrapped__"),p=l&&Fn.call(e,"__wrapped__");if(d||p){var y=d?t.value():t,g=p?e.value():e;return o||(o=new ke),i(y,g,n,r,o)}}return!!f&&(o||(o=new ke),function(t,e,n,r,i,o){var s=1&n,a=gn(t),c=a.length;if(c!=gn(e).length&&!s)return!1;for(var u=c;u--;){var h=a[u];if(!(s?h in e:mn.call(e,h)))return!1}var l=o.get(t),f=o.get(e);if(l&&f)return l==e&&f==t;var d=!0;o.set(t,e),o.set(e,t);for(var p=s;++u<c;){var y=t[h=a[u]],g=e[h];if(r)var m=s?r(g,y,h,e,t,o):r(y,g,h,t,e,o);if(!(void 0===m?y===g||i(y,g,n,r,o):m)){d=!1;break}p||(p="constructor"==h)}if(d&&!p){var b=t.constructor,v=e.constructor;b==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof v&&v instanceof v||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,n,r,i,o))}function Dn(t,e,n,r,i){return t===e||(null==t||null==e||!De(t)&&!De(e)?t!=t&&e!=e:Nn(t,e,n,r,Dn,i))}function Ln(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}var $n=function(){try{var t=ye(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Un(t,e,n){"__proto__"==e&&$n?$n(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var qn=Object.prototype.hasOwnProperty;function Wn(t,e,n){var r=t[e];qn.call(t,e)&&$t(r,n)&&(void 0!==n||e in t)||Un(t,e,n)}function Yn(t,e,n,r){var i=!n;n||(n={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=r?r(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),i?Un(n,a,c):Wn(n,a,c)}return n}function Bn(t){return t}function Gn(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var Xn=Math.max;function Hn(t){return function(){return t}}var Vn=$n?function(t,e){return $n(t,"toString",{configurable:!0,enumerable:!1,value:Hn(e),writable:!0})}:Bn,Zn=Date.now;var Qn,Jn,Kn,tr=(Qn=Vn,Jn=0,Kn=0,function(){var t=Zn(),e=16-(t-Kn);if(Kn=t,e>0){if(++Jn>=800)return arguments[0]}else Jn=0;return Qn.apply(void 0,arguments)});function er(t,e){return tr(function(t,e,n){return e=Xn(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Xn(r.length-e,0),s=Array(o);++i<o;)s[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=n(s),Gn(t,this,a)}}(t,e,Bn),t+"")}function nr(t,e,n){if(!ee(n))return!1;var r=typeof e;return!!("number"==r?pn(n)&&Ve(e,n.length):"string"==r&&e in n)&&$t(n[e],t)}var rr,ir=(rr=function(t,e,n,r){Yn(e,yn(e),t,r)},er(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=rr.length>3&&"function"==typeof i?(r--,i):void 0,o&&nr(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var s=e[n];s&&rr(t,s,n,i)}return t})),or=hn(Object.getPrototypeOf,Object),sr=Function.prototype,ar=Object.prototype,cr=sr.toString,ur=ar.hasOwnProperty,hr=cr.call(Object);function lr(t){if(!De(t))return!1;var e=te(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!De(t)||"[object Object]"!=te(t))return!1;var e=or(t);if(null===e)return!0;var n=ur.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&cr.call(n)==hr}(t)}var fr=er(function(t,e){try{return Gn(t,void 0,e)}catch(t){return lr(t)?t:new Error(t)}});function dr(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var pr=Object.prototype,yr=pr.hasOwnProperty;function gr(t,e,n,r){return void 0===t||$t(t,pr[n])&&!yr.call(r,n)?e:t}var mr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function br(t){return"\\"+mr[t]}var vr=/<%=([\s\S]+?)%>/g;var xr,_r=(xr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},function(t){return null==xr?void 0:xr[t]});function wr(t){return"symbol"==typeof t||De(t)&&"[object Symbol]"==te(t)}var kr=Xt?Xt.prototype:void 0,Mr=kr?kr.toString:void 0;function Sr(t){if("string"==typeof t)return t;if(Pe(t))return dr(t,Sr)+"";if(wr(t))return Mr?Mr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function zr(t){return null==t?"":Sr(t)}var Er=/[&<>"']/g,Ar=RegExp(Er.source);var Tr={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vr,variable:"",imports:{_:{escape:function(t){return(t=zr(t))&&Ar.test(t)?t.replace(Er,_r):t}}}},Or=/\b__p \+= '';/g,Ir=/\b(__p \+=) '' \+/g,jr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pr=/[()=,{}\[\]\/\s]/,Rr=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Cr=/($^)/,Fr=/['\n\r\u2028\u2029\\]/g,Nr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Lr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=un(t),n=[];for(var r in t)("constructor"!=r||!e&&Dr.call(t,r))&&n.push(r);return n}function $r(t,e){return t&&Yn(e,function(t){return pn(t)?an(t,!0):Lr(t)}(e),t)}var Ur="object"==typeof exports&&exports&&!exports.nodeType&&exports,qr=Ur&&"object"==typeof module&&module&&!module.nodeType&&module,Wr=qr&&qr.exports===Ur?Gt.Buffer:void 0,Yr=Wr?Wr.allocUnsafe:void 0;var Br=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)je(e,Ne(t)),t=or(t);return e}:Re;var Gr=Object.prototype.hasOwnProperty;var Xr=/\w*$/;var Hr=Xt?Xt.prototype:void 0,Vr=Hr?Hr.valueOf:void 0;function Zr(t,e,n){var r,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new Ee(a).set(new Ee(s)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return o=(i=t).buffer,new i.constructor(o,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Xr.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return r=t,Vr?Object(Vr.call(r)):{}}}var Qr=Object.create,Jr=function(){function t(){}return function(e){if(!ee(e))return{};if(Qr)return Qr(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var Kr=nn&&nn.isMap,ti=Kr?Je(Kr):function(t){return De(t)&&"[object Map]"==jn(t)};var ei=nn&&nn.isSet,ni=ei?Je(ei):function(t){return De(t)&&"[object Set]"==jn(t)},ri="[object Arguments]",ii="[object Function]",oi="[object Object]",si={};function ai(t,e,n,r,i,o){var s,a=2&e;if(void 0!==s)return s;if(!ee(t))return t;var c=Pe(t);if(c)return s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Gr.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,s);var u=jn(t),h=u==ii||"[object GeneratorFunction]"==u;if(Xe(t))return function(t){var e=t.length,n=Yr?Yr(e):new t.constructor(e);return t.copy(n),n}(t);if(u==oi||u==ri||h&&!i)return s=h?{}:function(t){return"function"!=typeof t.constructor||un(t)?{}:Jr(or(t))}(t),a?function(t,e){return Yn(t,Br(t),e)}(t,$r(s,t)):function(t,e){return Yn(t,Ne(t),e)}(t,function(t,e){return t&&Yn(e,yn(e),t)}(s,t));if(!si[u])return i?t:{};s=Zr(t,u),o||(o=new ke);var l=o.get(t);if(l)return l;o.set(t,s),ni(t)?t.forEach(function(r){s.add(ai(r,e,n,r,t,o))}):ti(t)&&t.forEach(function(r,i){s.set(i,ai(r,e,n,i,t,o))});var f=c?void 0:gn(t);return Ln(f||t,function(r,i){f&&(r=t[i=r]),Wn(s,i,ai(r,e,n,i,t,o))}),s}si[ri]=si["[object Array]"]=si["[object ArrayBuffer]"]=si["[object DataView]"]=si["[object Boolean]"]=si["[object Date]"]=si["[object Float32Array]"]=si["[object Float64Array]"]=si["[object Int8Array]"]=si["[object Int16Array]"]=si["[object Int32Array]"]=si["[object Map]"]=si["[object Number]"]=si[oi]=si["[object RegExp]"]=si["[object Set]"]=si["[object String]"]=si["[object Symbol]"]=si["[object Uint8Array]"]=si["[object Uint8ClampedArray]"]=si["[object Uint16Array]"]=si["[object Uint32Array]"]=!0,si["[object Error]"]=si[ii]=si["[object WeakMap]"]=!1;function ci(t){return ai(t,4)}var ui=/\s/;var hi=/^\s+/;function li(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ui.test(t.charAt(e)););return e}(t)+1).replace(hi,""):t}var fi=/^[-+]0x[0-9a-f]+$/i,di=/^0b[01]+$/i,pi=/^0o[0-7]+$/i,yi=parseInt;var gi=1/0;function mi(t){return t?(t=function(t){if("number"==typeof t)return t;if(wr(t))return NaN;if(ee(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ee(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=li(t);var n=di.test(t);return n||pi.test(t)?yi(t.slice(2),n?2:8):fi.test(t)?NaN:+t}(t))===gi||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function bi(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=function(t){var e=mi(t),n=e%1;return e==e?n?e-n:e:0}(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var vi=Object.prototype.hasOwnProperty;function xi(t){if(null==t)return!0;if(pn(t)&&(Pe(t)||"string"==typeof t||"function"==typeof t.splice||Xe(t)||on(t)||We(t)))return!t.length;var e=jn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(un(t))return!dn(t).length;for(var n in t)if(vi.call(t,n))return!1;return!0}let _i=0;function wi(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function ki(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function Mi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function Si(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function zi(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function Ei(t){if(this.__collection__)return this.__collection__[t]}function Ai(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function Ti(t){return this.__collection__?this.__collection__.indexOf(t):-1}function Oi(){return this.__collection__?this.__collection__.length:0}function Ii(){this.__collection__=[]}function ji(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function Pi(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function Ri(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,r)}function Ci(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),r=this.__collection__.splice(1);this.__collection__=n.concat(r,this.__collection__)}class Fi{constructor(){this.__collection__=[],this.insertAt=ki,this.append=Mi,this.prepend=Si,this.remove=zi,this.getAt=Ei,this.forEach=Ai,this.indexOf=Ti,this.size=Oi,this.clear=Ii,this.moveForward=ji,this.moveBackward=Pi,this.moveToHead=Ri,this.moveToTail=Ci}}const Ni=/\s+/;function Di(t,e,n,r){if(!n)return!0;if("object"==typeof n){for(const r in n){const i=n[r];t[e].apply(t,[r,i])}return!1}if(Ni.test(n)){return n.split(Ni).forEach(n=>t[e].apply(t,[n].concat(r))),!1}return!0}const Li=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],$i={withEvent(){Li.forEach(t=>this[t]=$i[t])},on(t,e,n){if(!Di(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!Di(this,"once",t,[e,n])||!e)return this;const r=this,i=function(t){return bi(2,t)}(function(){r.off(t,i,n),e.apply(r,arguments)});return i._callback=e,this.on(t,i,n),this},off(t,e,n){if(!this._listeners||!Di(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let r;r=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<r.length;t++){const i=r[t],o=this._listeners?.[i];if(o){const t=[];if(this._listeners[i]=t,e||n)for(let r=0;r<o.length;r++){const i=o[r];(e&&e!==i.callback&&e!==i.callback._callback||n&&n!==i.context)&&t.push(i)}t.length||delete this._listeners[i]}}return this},delegate_on(t){return this._delegators||(this._delegators=new Fi),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&qi(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],r=this._listeners["(all)"];return n&&Ui(n,arguments),r&&Ui(r,arguments),this},trigger(t){G.enabled&&G.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&qi(this._delegators,e),!this._listeners)return this;if(!Di(this,"trigger",t,e))return this;const n=this._listeners[t],r=this._listeners["(all)"];return n&&Ui(n,e),r&&Ui(r,e),this},stopListening(t,e,n){let r=this._listeningTo;if(!r)return this;const i=!e&&!n;n||"object"!=typeof e||(n=this),t&&(r={},r[t._listenId]=t);for(const t in r){const o=r[t];o.off(e,n,this),(i||xi(o._events))&&delete this._listeningTo[t]}return this}};function Ui(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function qi(t,e){t.forEach(t=>$i.delegate.apply(t,e))}const Wi={listenTo:"on",listenToOnce:"once"};for(const t in Wi){const e=Wi[t];$i[t]=function(t,n,r){this._listeningTo||(this._listeningTo={});const i=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++_i}`);return i[t._listenId]=t,r||"object"!=typeof n||(r=this),t[e](n,r,this),this}}const Yi=$i.on,Bi=$i.off,Gi=$i.once,Xi=$i.trigger,Hi=$i.delegate_on,Vi=$i.delegate_off;const Zi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))};var Qi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ki(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var to,eo={exports:{}};var no=(to||(to=1,function(t){var e=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,s=Object.create(o.prototype),a=new O(r||[]);return i(s,"_invoke",{value:z(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f="suspendedStart",d="suspendedYield",p="executing",y="completed",g={};function m(){}function b(){}function v(){}var x={};u(x,s,function(){return this});var _=Object.getPrototypeOf,w=_&&_(_(I([])));w&&w!==n&&r.call(w,s)&&(x=w);var k=v.prototype=m.prototype=Object.create(x);function M(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function n(i,o,s,a){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,s,a)},function(t){n("throw",t,s,a)}):e.resolve(h).then(function(t){u.value=t,s(u)},function(t){return n("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e(function(e,i){n(t,r,e,i)})}return o=o?o.then(i,i):i()}})}function z(t,n,r){var i=f;return function(o,s){if(i===p)throw new Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:e,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var u=l(t,n,r);if("normal"===u.type){if(i=r.done?y:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=y,r.method="throw",r.arg=u.arg)}}}function E(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=l(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(t){if(null!=t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=v,i(k,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:b,configurable:!0}),b.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},M(S.prototype),u(S.prototype,a,function(){return this}),t.AsyncIterator=S,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var s=new S(h(e,n,r,i),o);return t.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},M(k),u(k,c,"Generator"),u(k,s,function(){return this}),u(k,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=I,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return a.type="throw",a.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:I(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],r=0,i="",o=0,s=arguments.length;o!==s;++o){var a=+arguments[o];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?r=n.push(a):(a-=65536,r=n.push(55296+(a>>10),a%1024+56320)),r>=16383&&(i+=t.apply(null,n),n.length=0)}return i+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
7
+ /*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){if(!a&&Ki)return Ki(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};e[s][0].call(u.exports,function(t){return i(e[s][1][t]||t)},u,u.exports,t,e,n,r)}return n[s].exports}for(var o=Ki,s=0;s<r.length;s++)i(r[s]);return i}return t}()({1:[function(t,e,n){var r=t("./utils"),i=function(){var t=r.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],i=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],o=["Thousand","Million","Billion","Trillion"];function s(t,r){var s=function(t,r,a){var c="";if(t<=19)c=(r?" and ":"")+(a?n[t]:e[t]);else if(t<100){var u=Math.floor(t/10),h=t%10;c=(r?" and ":"")+i[u-2],h>0?c+="-"+s(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(t<1e3){var l=Math.floor(t/100),f=t%100;c=(r?", ":"")+e[l]+" Hundred",f>0?c+=s(f,!0,a):a&&(c+="th")}else{var d=Math.floor(Math.log10(t)/3);d>o.length&&(d=o.length);var p=Math.pow(10,3*d),y=Math.floor(t/p),g=t-y*p;c=(r?", ":"")+s(y,!1,!1)+" "+o[d-1],g>0?c+=s(g,!0,a):a&&(c+="th")}return c};return s(t,!1,r)}var a=Object.create(null);function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];return e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)}),n.reduce(function(t,e){return t+e},0)}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),i.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,o.forEach(function(t,e){var n=t.toLowerCase(),r=Math.pow(10,3*(e+1));a[n]=r,a[n+"th"]=r});var u=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function l(t){for(var e=0;e<u.length;e++){var n=u[e];if(t>=n[0])return n[1]+l(t-n[0])}return""}function f(t){for(var e=0,n=1,r=t.length-1;r>=0;r--){var i=t[r],o=h[i];o<n?e-=o:(n=o,e+=o)}return e}function d(t,e){for(var n=[],r=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+r)),t=Math.floor((t-1)/26);return n.join("")}function p(t,e){for(var n=e.charCodeAt(0),r=0,i=0;i<t.length;i++)r+=(t.charCodeAt(t.length-i-1)-n+1)*Math.pow(26,i);return r}function y(t,e){if(void 0!==t)return b(t=Math.floor(t),x(e))}var g={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},m={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var r,i=e<0;switch(e=Math.abs(e),n.primary){case g.LETTERS:r=d(e,n.case===m.UPPER?"A":"a");break;case g.ROMAN:r=l(e),n.case===m.UPPER&&(r=r.toUpperCase());break;case g.WORDS:r=s(e,n.ordinal),n.case===m.UPPER?r=r.toUpperCase():n.case===m.LOWER&&(r=r.toLowerCase());break;case g.DECIMAL:r=""+e;var o=n.mandatoryDigits-r.length;if(o>0){var a=new Array(o+1).join("0");r=a+r}if(48!==n.zeroCode&&(r=t(r).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((r.length-1)/n.groupingSeparators.position);c>0;c--){var u=r.length-c*n.groupingSeparators.position;r=r.substr(0,u)+n.groupingSeparators.character+r.substr(u)}else n.groupingSeparators.reverse().forEach(function(t){var e=r.length-t.position;r=r.substr(0,e)+t.character+r.substr(e)});if(n.ordinal){var h={1:"st",2:"nd",3:"rd"}[r[r.length-1]];(!h||r.length>1&&"1"===r[r.length-2])&&(h="th"),r+=h}break;case g.SEQUENCE:throw{code:"D3130",value:n.token}}return i&&(r="-"+r),r}var v=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function x(e){var n,r={type:"integer",primary:g.DECIMAL,case:m.LOWER,ordinal:!1},i=e.lastIndexOf(";");switch(-1===i?n=e:(n=e.substring(0,i),"o"===e.substring(i+1)[0]&&(r.ordinal=!0)),n){case"A":r.case=m.UPPER;case"a":r.primary=g.LETTERS;break;case"I":r.case=m.UPPER;case"i":r.primary=g.ROMAN;break;case"W":r.case=m.UPPER,r.primary=g.WORDS;break;case"Ww":r.case=m.TITLE,r.primary=g.WORDS;break;case"w":r.primary=g.WORDS;break;default:var o=null,s=0,a=0,c=[],u=0;if(t(n).map(function(t){return t.codePointAt(0)}).reverse().forEach(function(t){for(var e=!1,n=0;n<v.length;n++){var r=v[n];if(t>=r&&t<=r+9){if(e=!0,s++,u++,null===o)o=r;else if(r!==o)throw{code:"D3131"};break}}e||(35===t?(u++,a++):c.push({position:u,character:String.fromCodePoint(t)}))}),s>0){r.primary=g.DECIMAL,r.zeroCode=o,r.mandatoryDigits=s,r.optionalDigits=a;var h=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var r=t.map(function(t){return t.position}),i=function(t,e){return 0===e?t:i(e,t%e)},o=r.reduce(i),s=1;s<=r.length;s++)if(-1===r.indexOf(s*o))return 0;return o}(c);h>0?(r.regular=!0,r.groupingSeparators={position:h,character:c[0].character}):(r.regular=!1,r.groupingSeparators=c)}else r.primary=g.SEQUENCE,r.token=n}return r}var _={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function w(t){for(var e=[],n={type:"datetime",parts:e},r=function(n,r){if(r>n){var i=t.substring(n,r);i=i.split("]]").join("]"),e.push({type:"literal",value:i})}},i=0,o=0;o<t.length;){if("["===t.charAt(o)){if("["===t.charAt(o+1)){r(i,o),e.push({type:"literal",value:"["}),i=o+=2;continue}if(r(i,o),i=o,-1===(o=t.indexOf("]",i)))throw{code:"D3135"};var s,a=t.substring(i+1,o),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},u=a.lastIndexOf(",");if(-1!==u){var h=a.substring(u+1),l=h.indexOf("-"),f=void 0,d=void 0,p=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===l?f=h:(f=h.substring(0,l),d=h.substring(l+1));var y={min:p(f),max:p(d)};c.width=y,s=a.substring(1,u)}else s=a.substring(1);if(1===s.length)c.presentation1=s;else if(s.length>1){var g=s.charAt(s.length-1);-1!=="atco".indexOf(g)?(c.presentation2=g,"o"===g&&(c.ordinal=!0),c.presentation1=s.substring(0,s.length-1)):c.presentation1=s}else c.presentation1=_[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=m.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=m.TITLE:c.names=m.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=x(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var v=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;v>=2&&(c.n=v)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=x(c.presentation1)),e.push(c),i=o+1}o++}return r(i,o),n}var k=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=864e5,z=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*S:e-(n-1)*S},E=function(t,e){return{year:t,month:e,nextMonth:function(){return 11===e?E(t+1,0):E(t,e+1)},previousMonth:function(){return 0===e?E(t-1,11):E(t,e-1)},nextYear:function(){return E(t+1,e)},previousYear:function(){return E(t-1,e)}}},A=function(t,e){return(e-t)/(7*S)+1},T=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/S+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var r=E(t.getUTCFullYear(),0),i=z(r),o=Date.UTC(r.year,t.getUTCMonth(),t.getUTCDate()),s=A(i,o);if(s>52)o>=z(r.nextYear())&&(s=1);else if(s<1){var a=z(r.previousYear());s=A(a,o)}n=Math.floor(s);break;case"w":var c=E(t.getUTCFullYear(),t.getUTCMonth()),u=z(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),l=A(u,h);if(l>4)h>=z(c.nextMonth())&&(l=1);else if(l<1){var f=z(c.previousMonth());l=A(f,h)}n=Math.floor(l);break;case"X":var d=E(t.getUTCFullYear(),0),p=z(d),y=z(d.nextYear()),g=t.getTime();n=g<p?d.year-1:g>=y?d.year+1:d.year;break;case"x":var m=E(t.getUTCFullYear(),t.getUTCMonth()),b=z(m),v=m.nextMonth(),x=z(v),_=t.getTime();n=_<b?m.previousMonth().month+1:_>=x?v.month+1:m.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},O=null;function I(t,e,n){var r=0,i=0;if(void 0!==n){var o=parseInt(n);r=Math.floor(o/100),i=o%100}var s,a=function(t,e){var n=T(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=M[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=k[n]}e.names===m.UPPER?n=n.toUpperCase():e.names===m.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var o=100*r+i;if(e.integerFormat.regular)n=b(o,e.integerFormat);else{var s=e.integerFormat.mandatoryDigits;if(1===s||2===s)n=b(r,e.integerFormat),0!==i&&(n+=":"+y(i,"00"));else{if(3!==s&&4!==s)throw{code:"D3134",value:s};n=b(o,e.integerFormat)}}o>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===o&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===O&&(O=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),s=O):s=w(e);var c=new Date(t+60*(60*r+i)*1e3),u="";return s.parts.forEach(function(t){"literal"===t.type?u+=t.value:u+=a(c,t)}),u}function j(t){var e=Object.create(null);if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e=Object.create(null);if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var r=0,i=0;return n?(r=Number.parseInt(e.substring(0,e.indexOf(n.character))),i=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?r=Number.parseInt(e):(r=Number.parseInt(e.substring(0,3)),i=Number.parseInt(e.substring(3))),60*r+i}}else if("f"===t.component)e.regex="[0-9]+",e.parse=function(t){return 1e3*parseFloat("0."+t.substring(0,3))};else if(t.integerFormat)t.integerFormat.n=t.n,e=j(t.integerFormat);else{e.regex="[a-zA-Z]+";var r=Object.create(null);if("M"===t.component||"x"===t.component)M.forEach(function(e,n){t.width&&t.width.max?r[e.substring(0,t.width.max)]=n+1:r[e]=n+1});else if("F"===t.component)k.forEach(function(e,n){n>0&&(t.width&&t.width.max?r[e.substring(0,t.width.max)]=n:r[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};r={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return r[t]}}return e.component=t.component,e});else{e.type="integer";var n,i=t.case===m.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case g.LETTERS:e.regex=i?"[A-Z]+":"[a-z]+",e.parse=function(t){return p(t,i?"A":"a")};break;case g.ROMAN:e.regex=i?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return f(i?t:t.toUpperCase())};break;case g.WORDS:e.regex="(?:"+r.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case g.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case g.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function P(t,e){if(void 0!==t)return j(x(e)).parse(t)}function R(t,e){var n=j(w(e)),r="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",i=new RegExp(r,"i").exec(t);if(null!==i){for(var o=161,s=130,a=84,c=72,u=23,h=47,l=Object.create(null),f=1;f<i.length;f++){var d=n.parts[f-1];d.parse&&(l[d.component]=d.parse(i[f]))}if(0===Object.getOwnPropertyNames(l).length)return;var p=0,y=function(t){p<<=1,p+=t?1:0},g=function(t){return!(~t&p||!(t&p))};"YXMxWwdD".split("").forEach(function(t){return y(l[t])});var m=!g(o)&&g(s),b=g(a),v=!b&&g(c);p=0,"PHhmsf".split("").forEach(function(t){return y(l[t])});var x=!g(u)&&g(h),_=(m?"YD":b?"XxwF":v?"XWF":"YMD")+(x?"Phmsf":"Hmsf"),k=this.environment.timestamp,M=!1,S=!1;if(_.split("").forEach(function(t){if(void 0===l[t])M?(l[t]=-1!=="MDd".indexOf(t)?1:0,S=!0):l[t]=T(k,t);else if(M=!0,S)throw{code:"D3136"}}),l.M>0?l.M-=1:l.M=0,m){var z=Date.UTC(l.Y,0),E=1e3*(l.d-1)*60*60*24,A=new Date(z+E);l.M=A.getUTCMonth(),l.D=A.getUTCDate()}if(b)throw{code:"D3136"};if(v)throw{code:"D3136"};x&&(l.H=12===l.h?0:l.h,1===l.P&&(l.H+=12));var O=Date.UTC(l.Y,l.M,l.D,l.H,l.m,l.s,l.f);return(l.Z||l.z)&&(O-=60*(l.Z||l.z)*1e3),O}}var C=new RegExp("^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function F(t,e){if(void 0!==t){if(void 0===e){if(!C.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return R.call(this,t,e)}}function N(t,e,n){if(void 0!==t)return I.call(this,t,e,n)}return{formatInteger:y,parseInteger:P,fromMillis:N,toMillis:F}}();e.exports=i},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(s(t)+" is not iterable")}function c(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,h=Object.create(c.prototype);return u(h,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),h}var s={};function a(){}function h(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(u(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return h.prototype=l,u(d,"constructor",l),u(l,"constructor",h),h.displayName="GeneratorFunction",u(l,i,"GeneratorFunction"),u(d),u(d,i,"Generator"),u(d,r,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:o,m:p}})()}function u(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}u=function(t,e,n,r){function o(e,n){u(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},u(t,e,n,r)}var h=t("./utils"),l=function(){var t=c().m(W),e=c().m(Y),i=c().m(B),o=c().m(G),u=c().m(K),l=c().m(pt),f=c().m(yt),d=c().m(gt),p=c().m(bt),y=c().m(zt),g=c().m(Ot),m=c().m(Pt),b=h.isNumeric,v=h.isArrayOfStrings,x=h.isArrayOfNumbers,_=h.createSequence,w=h.isSequence,k=h.isFunction,M=h.isLambda,S=h.isIterable,z=h.getFunctionArity,E=h.isDeepEqual,A=h.stringToArray;function T(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function O(t){return void 0===t?0:t.length}function I(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function j(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function P(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function R(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(k(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var r=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&b(e)?Number(e.toPrecision(15)):e&&k(e)?"":e},r)}return n}}function C(t,e,n){if(void 0!==t){var r=A(t),i=r.length;if(i+e<0&&(e=0),void 0!==n){if(n<=0)return"";var o=e>=0?e+n:i+e+n;return r.slice(e,o).join("")}return r.slice(e).join("")}}function F(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function N(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function D(t){if(void 0!==t)return t.toLowerCase()}function L(t){if(void 0!==t)return t.toUpperCase()}function $(t){if(void 0!==t)return A(t).length}function U(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function q(t,e,n){if(void 0!==t){var r;void 0!==n&&0!==n.length||(n=" ");var i=Math.abs(e)-$(t);if(i>0){var o=new Array(i+1).join(n);n.length>1&&(o=C(o,0,i)),r=e>0?t+o:o+t}else r=t;return r}}function W(e,n){var r;return c().w(function(t){for(;;)switch(t.n){case 0:if(r=e.apply(this,[n]),!S(r)){t.n=2;break}return t.d(a(r),1);case 1:r=t.v;case 2:if(!r||"number"==typeof r.start||"number"===r.end||Array.isArray(r.groups)||k(r.next)){t.n=3;break}throw{code:"T1010",stack:(new Error).stack};case 3:return t.a(2,r)}},t,this)}function Y(t,n){var r,i;return c().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==t){e.n=1;break}return e.a(2,void 0);case 1:if("string"!=typeof n){e.n=2;break}r=-1!==t.indexOf(n),e.n=4;break;case 2:return e.d(a(W(n,t)),3);case 3:i=e.v,r=void 0!==i;case 4:return e.a(2,r)}},e)}function B(t,e,n){var r,o,s;return c().w(function(i){for(;;)switch(i.n){case 0:if(void 0!==t){i.n=1;break}return i.a(2,void 0);case 1:if(!(n<0)){i.n=2;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 2:if(r=_(),!(void 0===n||n>0)){i.n=6;break}return o=0,i.d(a(W(e,t)),3);case 3:if(void 0===(s=i.v)){i.n=6;break}case 4:if(void 0===s||!(void 0===n||o<n)){i.n=6;break}return r.push({match:s.match,index:s.start,groups:s.groups}),i.d(a(W(s.next)),5);case 5:s=i.v,o++,i.n=4;break;case 6:return i.a(2,r)}},i)}function G(t,e,n,r){var i,s,u,h,l,f,d,p;return c().w(function(o){for(;;)switch(o.n){case 0:if(void 0!==t){o.n=1;break}return o.a(2,void 0);case 1:if(i=this,""!==e){o.n=2;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 2:if(!(r<0)){o.n=3;break}throw{code:"D3011",stack:(new Error).stack,value:r,index:4};case 3:if(s="string"==typeof n?function(t){for(var e="",r=0,i=n.indexOf("$",r);-1!==i&&r<n.length;){e+=n.substring(r,i),r=i+1;var o=n.charAt(r);if("$"===o)e+="$",r++;else if("0"===o)e+=t.match,r++;else{var s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(n.substring(r,r+s),10),s>1&&i>t.groups.length&&(i=parseInt(n.substring(r,r+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var a=t.groups[i-1];void 0!==a&&(e+=a)}r+=i.toString().length}}i=n.indexOf("$",r)}return e+=n.substring(r)}:n,u="",h=0,!(void 0===r||r>0)){o.n=15;break}if(l=0,"string"!=typeof e){o.n=4;break}for(f=t.indexOf(e,h);-1!==f&&(void 0===r||l<r);)u+=t.substring(h,f),u+=n,h=f+e.length,l++,f=t.indexOf(e,h);u+=t.substring(h),o.n=14;break;case 4:return o.d(a(W(e,t)),5);case 5:if(void 0===(d=o.v)){o.n=13;break}case 6:if(void 0===d||!(void 0===r||l<r)){o.n=12;break}if(u+=t.substring(h,d.start),p=s.apply(i,[d]),!S(p)){o.n=8;break}return o.d(a(p),7);case 7:p=o.v;case 8:if("string"!=typeof p){o.n=9;break}u+=p,o.n=10;break;case 9:throw{code:"D3012",stack:(new Error).stack,value:p};case 10:return h=d.start+d.match.length,l++,o.d(a(W(d.next)),11);case 11:d=o.v,o.n=6;break;case 12:u+=t.substring(h),o.n=14;break;case 13:u=t;case 14:o.n=16;break;case 15:u=t;case 16:return o.a(2,u)}},o,this)}function X(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function H(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function V(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function Z(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function J(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function K(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!(n<0)){c.n=2;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 2:if(r=[],!(void 0===n||n>0)){c.n=9;break}if("string"!=typeof e){c.n=3;break}r=t.split(e,n),c.n=9;break;case 3:return i=0,c.d(a(W(e,t)),4);case 4:if(void 0===(o=c.v)){c.n=8;break}s=0;case 5:if(void 0===o||!(void 0===n||i<n)){c.n=7;break}return r.push(t.substring(s,o.start)),s=o.end,c.d(a(W(o.next)),6);case 6:o=c.v,i++,c.n=5;break;case 7:(void 0===n||i<n)&&r.push(t.substring(s)),c.n=9;break;case 8:r.push(t);case 9:return c.a(2,r)}},u)}function tt(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function et(t,e,n){if(void 0!==t){var r={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&h.keys(n).forEach(function(t){r[t]=n[t]});for(var i=[],o=r["zero-digit"].charCodeAt(0),s=o;s<o+10;s++)i.push(String.fromCharCode(s));var a=i.concat([r["decimal-separator"],r["exponent-separator"],r["grouping-separator"],r.digit,r["pattern-separator"]]),c=e.split(r["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,n,i,o,s=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==r["exponent-separator"])return t.substring(n+1)}(),u=t.substring(s.length,t.length-c.length),h=t.indexOf(r["exponent-separator"],s.length);-1===h||h>t.length-c.length?(e=u,n=void 0):(e=u.substring(0,h),n=u.substring(h+1));var l=e.indexOf(r["decimal-separator"]);return-1===l?(i=e,o=c):(i=e.substring(0,l),o=e.substring(l+1)),{prefix:s,suffix:c,activePart:u,mantissaPart:e,exponentPart:n,integerPart:i,fractionalPart:o,subpicture:t}},l=function(t){var e,n,o=t.subpicture,s=o.indexOf(r["decimal-separator"]);s!==o.lastIndexOf(r["decimal-separator"])&&(e="D3081"),o.indexOf(r.percent)!==o.lastIndexOf(r.percent)&&(e="D3082"),o.indexOf(r["per-mille"])!==o.lastIndexOf(r["per-mille"])&&(e="D3083"),-1!==o.indexOf(r.percent)&&-1!==o.indexOf(r["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var u=t.mantissaPart.charAt(n);if(-1!==i.indexOf(u)||u===r.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==s?o.charAt(s-1)!==r["grouping-separator"]&&o.charAt(s+1)!==r["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===r["grouping-separator"]&&(e="D3088"),-1!==o.indexOf(r["grouping-separator"]+r["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(r.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(r.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return i.indexOf(t)>-1}).length>0&&(e="D3091");var l="string"==typeof t.exponentPart;if(l&&t.exponentPart.length>0&&(-1!==o.indexOf(r.percent)||-1!==o.indexOf(r["per-mille"]))&&(e="D3092"),l&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===i.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},f=function(t){var e=function(e,n){for(var o=[],s=e.indexOf(r["grouping-separator"]);-1!==s;){var a=(n?e.substring(0,s):e.substring(s)).split("").filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length;o.push(a),s=t.integerPart.indexOf(r["grouping-separator"],s+1)}return o},n=e(t.integerPart),o=function(t){if(0===t.length)return 0;for(var e=function(t,n){return 0===n?t:e(n,t%n)},n=t.reduce(e),r=1;r<=t.length;r++)if(-1===t.indexOf(r*n))return 0;return n}(n),s=e(t.fractionalPart,!0),a=t.integerPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length,c=a,u=t.fractionalPart.split(""),h=u.filter(function(t){return-1!==i.indexOf(t)}).length,l=u.filter(function(t){return-1!==i.indexOf(t)||t===r.digit}).length,f="string"==typeof t.exponentPart;0===a&&0===l&&(f?(h=1,l=1):a=1),f&&0===a&&-1!==t.integerPart.indexOf(r.digit)&&(a=1),0===a&&0===h&&(h=1);var d=0;return f&&(d=t.exponentPart.split("").filter(function(t){return-1!==i.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:o,minimumIntegerPartSize:a,scalingFactor:c,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:l,minimumExponentSize:d,suffix:t.suffix,picture:t.subpicture}},d=c.map(u);d.forEach(l);var p,y,g,m,b=d.map(f),v=r["minus-sign"],x=r["zero-digit"],_=r["decimal-separator"],w=r["grouping-separator"];if(1===b.length&&(b.push(JSON.parse(JSON.stringify(b[0]))),b[1].prefix=v+b[1].prefix),y=-1!==(p=t>=0?b[0]:b[1]).picture.indexOf(r.percent)?100*t:-1!==p.picture.indexOf(r["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=y;else{var k=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(g=y,m=0;g<M;)g*=10,m-=1;for(;g>k;)g/=10,m+=1}var S=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==x&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t}).join("")),n},z=S(at(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=z.indexOf(".");for(-1===E?z+=_:z=z.replace(".",_);z.charAt(0)===x;)z=z.substring(1);for(;z.charAt(z.length-1)===x;)z=z.substring(0,z.length-1);E=z.indexOf(_);var A=p.minimumIntegerPartSize-E,T=p.minimumFactionalPartSize-(z.length-E-1);if(z=(A>0?new Array(A+1).join(x):"")+z,z+=T>0?new Array(T+1).join(x):"",E=z.indexOf(_),p.regularGrouping>0)for(var O=Math.floor((E-1)/p.regularGrouping),I=1;I<=O;I++)z=[z.slice(0,E-I*p.regularGrouping),w,z.slice(E-I*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){z=[z.slice(0,E-t),w,z.slice(E-t)].join(""),E++});if(E=z.indexOf(_),p.fractionalPartGroupingPositions.forEach(function(t){z=[z.slice(0,t+E+1),w,z.slice(t+E+1)].join("")}),E=z.indexOf(_),-1!==p.picture.indexOf(_)&&E!==z.length-1||(z=z.substring(0,z.length-1)),void 0!==m){var j=S(m,0);(A=p.minimumExponentSize-j.length)>0&&(j=new Array(A+1).join(x)+j),z=z+r["exponent-separator"]+(m<0?v:"")+j}return z=p.prefix+z+p.suffix}}function nt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function rt(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function it(t){if(void 0!==t)return Math.abs(t)}function ot(t){if(void 0!==t)return Math.floor(t)}function st(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var n;if(void 0!==t){if(e){var r=t.toString().split("e");t=+(r[0]+"e"+(r[1]?+r[1]+e:e))}var i=(n=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(n%2)&&(n-=1),e&&(r=n.toString().split("e"),n=+(r[0]+"e"+(r[1]?+r[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ct(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ut(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function ht(){return Math.random()}function lt(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=lt(t[0]):t.length>1&&(e=t.filter(function(t){return lt(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):b(t)?0!==t&&(e=!0):null!==t&&"object"===s(t)?h.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ft(t){if(void 0!==t)return!lt(t)}function dt(t,e,n,r){var i=[e],o=z(t);return o>=2&&i.push(n),o>=3&&i.push(r),i}function pt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=dt(e,t[r],r,t),s.d(a(e.apply(this,i)),3);case 3:void 0!==(o=s.v)&&n.push(o);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},l,this)}function yt(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:n=_(),r=0;case 2:if(!(r<t.length)){s.n=5;break}return i=t[r],o=dt(e,i,r,t),s.d(a(e.apply(this,o)),3);case 3:lt(s.v)&&n.push(i);case 4:r++,s.n=2;break;case 5:return s.a(2,n)}},f,this)}function gt(t,e){var n,r,i,o,s,u,h;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:n=!1,i=0;case 2:if(!(i<t.length)){c.n=7;break}if(o=t[i],s=!0,void 0===e){c.n=4;break}return u=dt(e,o,i,t),c.d(a(e.apply(this,u)),3);case 3:h=c.v,s=lt(h);case 4:if(!s){c.n=6;break}if(n){c.n=5;break}r=o,n=!0,c.n=6;break;case 5:throw{stack:(new Error).stack,code:"D3138",index:i};case 6:i++,c.n=2;break;case 7:if(n){c.n=8;break}throw{stack:(new Error).stack,code:"D3139"};case 8:return c.a(2,r)}},d,this)}function mt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),r=0;r<n;r++){var i=e.map(function(t){return t[r]});t.push(i)}return t}function bt(t,e,n){var r,i,o,s;return c().w(function(c){for(;;)switch(c.n){case 0:if(void 0!==t){c.n=1;break}return c.a(2,void 0);case 1:if(!((i=z(e))<2)){c.n=2;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 2:void 0===n&&t.length>0?(r=t[0],o=1):(r=n,o=0);case 3:if(!(o<t.length)){c.n=5;break}return s=[r,t[o]],i>=3&&s.push(o),i>=4&&s.push(t),c.d(a(e.apply(this,s)),4);case 4:r=c.v,o++,c.n=3;break;case 5:return c.a(2,r)}},p,this)}function vt(t){var e=_();if(Array.isArray(t)){var n=Object.create(null);t.forEach(function(t){vt(t).forEach(function(t){n[t]=!0})}),e=vt(n)}else null===t||"object"!==s(t)||M(t)||h.keys(t).forEach(function(t){return e.push(t)});return e}function xt(t,e){var n;if(Array.isArray(t)){n=_();for(var r=0;r<t.length;r++){var i=xt(t[r],e);void 0!==i&&(Array.isArray(i)?i.forEach(function(t){return n.push(t)}):n.push(i))}}else null!==t&&"object"===s(t)&&Object.prototype.hasOwnProperty.call(t,e)&&!k(t)&&(n=t[e]);return n}function _t(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=_(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function wt(t){return void 0!==t}function kt(t){var e=_();if(Array.isArray(t))t.forEach(function(t){e=_t(e,kt(t))});else if(null===t||"object"!==s(t)||M(t))e=t;else{var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value,a=Object.create(null);a[o]=t[o],e.push(a)}}catch(t){i.e(t)}finally{i.f()}}return e}function Mt(t){if(void 0!==t){var e=Object.create(null);return t.forEach(function(t){var n,i=r(h.keys(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;e[o]=t[o]}}catch(t){i.e(t)}finally{i.f()}}),e}}function St(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),r=0;r<e;r++)n[e-r-1]=t[r];return n}}function zt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=_(),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=dt(e,t[s],s,t),c.d(a(e.apply(this,u)),3);case 3:void 0!==(l=c.v)&&n.push(l);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return c.a(2,n)}},y,this,[[1,6,7,8]])}function Et(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function At(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function Tt(t){if(void 0!==t)return null===t?"null":b(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":k(t)?"function":"object"}function Ot(t,e){var n,r,i,o;return c().w(function(s){for(;;)switch(s.n){case 0:if(void 0!==t){s.n=1;break}return s.a(2,void 0);case 1:if(!(t.length<=1)){s.n=2;break}return s.a(2,t);case 2:if(void 0!==e){s.n=4;break}if(x(t)||v(t)){s.n=3;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 3:n=c().m(function t(e,n){return c().w(function(t){for(;;)if(0===t.n)return t.a(2,e>n)},t)}),s.n=5;break;case 4:n=e;case 5:return r=c().m(function t(e,r){var i,o;return c().w(function(t){for(;;)switch(t.n){case 0:return i=c().m(function t(e,r,o){return c().w(function(t){for(;;)switch(t.n){case 0:if(0!==r.length){t.n=1;break}Array.prototype.push.apply(e,o),t.n=6;break;case 1:if(0!==o.length){t.n=2;break}Array.prototype.push.apply(e,r),t.n=6;break;case 2:return t.d(a(n(r[0],o[0])),3);case 3:if(!t.v){t.n=5;break}return e.push(o[0]),t.d(a(i(e,r,o.slice(1))),4);case 4:t.n=6;break;case 5:return e.push(r[0]),t.d(a(i(e,r.slice(1),o)),6);case 6:return t.a(2)}},t)}),o=[],t.d(a(i(o,e,r)),1);case 1:return t.a(2,o)}},t)}),i=c().m(function t(e){var n,o,s;return c().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(e)&&!(e.length<=1)){t.n=1;break}return t.a(2,e);case 1:return n=Math.floor(e.length/2),o=e.slice(0,n),s=e.slice(n),t.d(a(i(o)),2);case 2:return o=t.v,t.d(a(i(s)),3);case 3:return s=t.v,t.d(a(r(o,s)),4);case 4:return t.a(2,t.v);case 5:return t.a(2)}},t)}),s.d(a(i(t)),6);case 6:return o=s.v,s.a(2,o)}},g)}function It(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var r=Math.floor(Math.random()*(n+1));n!==r&&(e[n]=e[r]),e[r]=t[n]}return e}}function jt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=w(t)?_():[],n=0;n<t.length;n++){for(var r=t[n],i=!1,o=0;o<e.length;o++)if(E(r,e[o])){i=!0;break}i||e.push(r)}return e}}function Pt(t,e){var n,i,o,s,u,l,f;return c().w(function(c){for(;;)switch(c.p=c.n){case 0:n=Object.create(null),i=r(h.keys(t)),c.p=1,i.s();case 2:if((o=i.n()).done){c.n=5;break}return s=o.value,u=t[s],l=dt(e,u,s,t),c.d(a(e.apply(this,l)),3);case 3:lt(c.v)&&(n[s]=u);case 4:c.n=2;break;case 5:c.n=7;break;case 6:c.p=6,f=c.v,i.e(f);case 7:return c.p=7,i.f(),c.f(7);case 8:return 0===h.keys(n).length&&(n=void 0),c.a(2,n)}},m,this,[[1,6,7,8]])}return{sum:T,count:O,max:I,min:j,average:P,string:R,substring:C,substringBefore:F,substringAfter:N,lowercase:D,uppercase:L,length:$,trim:U,pad:q,match:B,contains:Y,replace:G,split:K,join:tt,formatNumber:et,formatBase:nt,number:rt,floor:ot,ceil:st,round:at,abs:it,sqrt:ct,power:ut,random:ht,boolean:lt,not:ft,map:pt,zip:mt,filter:yt,single:gt,foldLeft:bt,sift:Pt,keys:vt,lookup:xt,append:_t,exists:wt,spread:kt,merge:Mt,reverse:St,each:zt,error:Et,assert:At,type:Tt,sort:Ot,shuffle:It,distinct:jt,base64encode:X,base64decode:H,encodeUrlComponent:V,encodeUrl:Z,decodeUrlComponent:Q,decodeUrl:J}}();e.exports=l}).call(this)}).call(this,void 0!==Qi?Qi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function r(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=s(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(i(t)+" is not iterable")}function u(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return h(u,"_invoke",function(n,r,i){var o,a,c,u=0,h=i||[],l=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!l&&u&&!i&&e<h.length;e++){var i,o=h[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw l=!0,r}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(l&&1===h&&d(h,p),a=h,c=p;(e=a<2?t:c)||!l;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(l=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{u=1}}return{value:e,done:l}}}(n,i,o),!0),u}var s={};function a(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][r]?e(e([][r]())):(h(e={},r,function(){return this}),e),d=l.prototype=a.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,h(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=l,h(d,"constructor",l),h(l,"constructor",c),c.displayName="GeneratorFunction",h(l,i,"GeneratorFunction"),h(d),h(d,i,"Generator"),h(d,r,function(){return this}),h(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:o,m:p}})()}function h(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}h=function(t,e,n,r){function o(e,n){h(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},h(t,e,n,r)}var l=t("./datetime"),f=t("./functions"),d=t("./utils"),p=t("./parser"),y=t("./signature"),g=function(){var t=u().m(W),e=u().m(Y),n=u().m(G),s=u().m(X),a=u().m(H),h=u().m(V),g=u().m(Z),m=u().m(Q),b=u().m(ct),v=u().m(lt),x=u().m(pt),_=u().m(yt),w=u().m(gt),k=u().m(vt),M=u().m(wt),S=u().m(kt),z=u().m(Mt),E=u().m(St),A=u().m(Et),T=u().m(Tt),O=u().m(jt),I=u().m(Ct),j=d.isNumeric,P=d.isArrayOfStrings,R=d.isArrayOfNumbers,C=d.createSequence,F=d.isSequence,N=d.isFunction,D=d.isLambda,L=d.isIterable,$=d.getFunctionArity,U=d.isDeepEqual,q=Nt(null);function W(e,n,r){var i,o,s,a,h;return u().w(function(t){for(;;)switch(t.n){case 0:(o=r.lookup("__evaluate_entry"))&&o(e,n,r),h=e.type,t.n="path"===h?1:"binary"===h?3:"unary"===h?5:"name"===h?7:"string"===h||"number"===h||"value"===h?8:"wildcard"===h?9:"descendant"===h?10:"parent"===h?11:"condition"===h?12:"block"===h?14:"bind"===h?16:"regex"===h?18:"function"===h?19:"variable"===h?21:"lambda"===h?22:"partial"===h?23:"apply"===h?25:"transform"===h?27:28;break;case 1:return t.d(c(Y(e,n,r)),2);case 2:return i=t.v,t.a(3,28);case 3:return t.d(c(Z(e,n,r)),4);case 4:return i=t.v,t.a(3,28);case 5:return t.d(c(Q(e,n,r)),6);case 6:return i=t.v,t.a(3,28);case 7:return i=J(e,n),t.a(3,28);case 8:return i=K(e),t.a(3,28);case 9:return i=tt(e,n),t.a(3,28);case 10:return i=nt(e,n),t.a(3,28);case 11:return i=r.lookup(e.slot.label),t.a(3,28);case 12:return t.d(c(yt(e,n,r)),13);case 13:return i=t.v,t.a(3,28);case 14:return t.d(c(gt(e,n,r)),15);case 15:return i=t.v,t.a(3,28);case 16:return t.d(c(pt(e,n,r)),17);case 17:return i=t.v,t.a(3,28);case 18:return i=mt(e),t.a(3,28);case 19:return t.d(c(kt(e,n,r)),20);case 20:return i=t.v,t.a(3,28);case 21:return i=bt(e,n,r),t.a(3,28);case 22:return i=zt(e,n,r),t.a(3,28);case 23:return t.d(c(Et(e,n,r)),24);case 24:return i=t.v,t.a(3,28);case 25:return t.d(c(wt(e,n,r)),26);case 26:return i=t.v,t.a(3,28);case 27:return i=xt(e,n,r),t.a(3,28);case 28:if(!r.async||null!=i&&"function"==typeof i.then||(i=Promise.resolve(i)),!r.async||"function"!=typeof i.then||!e.nextFunction||"function"!=typeof i[e.nextFunction]){t.n=29;break}t.n=31;break;case 29:return t.n=30,i;case 30:i=t.v;case 31:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.n=35;break}s=0;case 32:if(!(s<e.predicate.length)){t.n=35;break}return t.d(c(V(e.predicate[s].expr,i,r)),33);case 33:i=t.v;case 34:s++,t.n=32;break;case 35:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.n=37;break}return t.d(c(lt(e.group,i,r)),36);case 36:i=t.v;case 37:return(a=r.lookup("__evaluate_exit"))&&a(e,n,r,i),i&&F(i)&&!i.tupleStream&&(e.keepArray&&(i.keepSingleton=!0),0===i.length?i=void 0:1===i.length&&(i=i.keepSingleton?i:i[0])),t.a(2,i)}},t)}function Y(t,n,r){var i,o,s,a,h,l;return u().w(function(e){for(;;)switch(e.n){case 0:i=Array.isArray(n)&&"variable"!==t.steps[0].type?n:C(n),s=!1,a=void 0,h=0;case 1:if(!(h<t.steps.length)){e.n=10;break}if((l=t.steps[h]).tuple&&(s=!0),0!==h||!l.consarray){e.n=3;break}return e.d(c(W(l,i,r)),2);case 2:o=e.v,e.n=7;break;case 3:if(!s){e.n=5;break}return e.d(c(H(l,i,a,r)),4);case 4:a=e.v,e.n=7;break;case 5:return e.d(c(G(l,i,r,h===t.steps.length-1)),6);case 6:o=e.v;case 7:if(s||void 0!==o&&0!==o.length){e.n=8;break}return e.a(3,10);case 8:void 0===l.focus&&(i=o);case 9:h++,e.n=1;break;case 10:if(s)if(t.tuple)o=a;else for(o=C(),h=0;h<a.length;h++)o.push(a[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=C(o)),o.keepSingleton=!0),!Object.prototype.hasOwnProperty.call(t,"group")){e.n=12;break}return e.d(c(lt(t.group,s?a:o,r)),11);case 11:o=e.v;case 12:return e.a(2,o)}},e)}function B(t,e){var n,r=Nt(t),i=o(d.keys(e));try{for(i.s();!(n=i.n()).done;){var s=n.value;r.bind(s,e[s])}}catch(t){i.e(t)}finally{i.f()}return r}function G(t,e,r,i){var o,s,a,h,l;return u().w(function(n){for(;;)switch(n.n){case 0:if("sort"!==t.type){n.n=4;break}return n.d(c(vt(t,e,r)),1);case 1:if(o=n.v,!t.stages){n.n=3;break}return n.d(c(X(t.stages,o,r)),2);case 2:o=n.v;case 3:return n.a(2,o);case 4:o=C(),s=0;case 5:if(!(s<e.length)){n.n=12;break}return n.d(c(W(t,e[s],r)),6);case 6:if(a=n.v,!t.stages){n.n=10;break}h=0;case 7:if(!(h<t.stages.length)){n.n=10;break}return n.d(c(V(t.stages[h].expr,a,r)),8);case 8:a=n.v;case 9:h++,n.n=7;break;case 10:void 0!==a&&o.push(a);case 11:s++,n.n=5;break;case 12:return l=C(),i&&1===o.length&&Array.isArray(o[0])&&!F(o[0])?l=o[0]:Array.prototype.forEach.call(o,function(t){!Array.isArray(t)||t.cons?l.push(t):Array.prototype.forEach.call(t,function(t){return l.push(t)})}),n.a(2,l)}},n)}function X(t,e,n){var r,i,o,a,h;return u().w(function(s){for(;;)switch(s.n){case 0:r=e,i=0;case 1:if(!(i<t.length)){s.n=6;break}o=t[i],h=o.type,s.n="filter"===h?2:"index"===h?4:5;break;case 2:return s.d(c(V(o.expr,r,n)),3);case 3:return r=s.v,s.a(3,5);case 4:for(a=0;a<r.length;a++)r[a][o.value]=a;return s.a(3,5);case 5:i++,s.n=1;break;case 6:return s.a(2,r)}},s)}function H(t,e,n,r){var i,o,s,h,l,f,d,p;return u().w(function(a){for(;;)switch(a.n){case 0:if("sort"!==t.type){a.n=7;break}if(!n){a.n=2;break}return a.d(c(vt(t,n,r)),1);case 1:i=a.v,a.n=4;break;case 2:return a.d(c(vt(t,e,r)),3);case 3:for(o=a.v,(i=C()).tupleStream=!0,s=0;s<o.length;s++)(h={"@":o[s]})[t.index]=s,i.push(h);case 4:if(!t.stages){a.n=6;break}return a.d(c(X(t.stages,i,r)),5);case 5:i=a.v;case 6:return a.a(2,i);case 7:(i=C()).tupleStream=!0,l=r,void 0===n&&(n=e.map(function(t){return{"@":t}})),f=0;case 8:if(!(f<n.length)){a.n=11;break}return l=B(r,n[f]),a.d(c(W(t,n[f]["@"],l)),9);case 9:if(void 0!==(d=a.v))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)h=Object.create(null),Object.assign(h,n[f]),d.tupleStream?Object.assign(h,d[p]):(t.focus?(h[t.focus]=d[p],h["@"]=n[f]["@"]):h["@"]=d[p],t.index&&(h[t.index]=p),t.ancestor&&(h[t.ancestor.label]=n[f]["@"])),i.push(h);case 10:f++,a.n=8;break;case 11:if(!t.stages){a.n=13;break}return a.d(c(X(t.stages,i,r)),12);case 12:i=a.v;case 13:return a.a(2,i)}},a)}function V(t,e,n){var r,i,o,s,a,l;return u().w(function(u){for(;;)switch(u.n){case 0:if(r=C(),e&&e.tupleStream&&(r.tupleStream=!0),Array.isArray(e)||(e=C(e)),"number"!==t.type){u.n=1;break}(i=Math.floor(t.value))<0&&(i=e.length+i),void 0!==(o=e[i])&&(Array.isArray(o)?r=o:r.push(o)),u.n=5;break;case 1:i=0;case 2:if(!(i<e.length)){u.n=5;break}return o=e[i],s=o,a=n,e.tupleStream&&(s=o["@"],a=B(n,o)),u.d(c(W(t,s,a)),3);case 3:l=u.v,j(l)&&(l=[l]),R(l)?Array.prototype.forEach.call(l,function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===i&&r.push(o)}):f.boolean(l)&&r.push(o);case 4:i++,u.n=2;break;case 5:return u.a(2,r)}},h)}function Z(t,e,n){var r,i,o,s,a,h,l,f;return u().w(function(d){for(;;)switch(d.p=d.n){case 0:return d.d(c(W(t.lhs,e,n)),1);case 1:if(i=d.v,o=t.value,s=u().m(function r(){return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(W(t.rhs,e,n)),1);case 1:return r.a(2,r.v)}},r)}),"and"!==o&&"or"!==o){d.n=5;break}return d.p=2,d.d(c(ct(i,s,o)),3);case 3:return d.a(2,d.v);case 4:throw d.p=4,(h=d.v).position=t.position,h.token=o,h;case 5:return d.d(c(s()),6);case 6:a=d.v,d.p=7,l=o,d.n="+"===l||"-"===l||"*"===l||"/"===l||"%"===l?8:"="===l||"!="===l?9:"<"===l||"<="===l||">"===l||">="===l?10:"&"===l?11:".."===l?12:"in"===l?13:14;break;case 8:return r=it(i,a,o),d.a(3,14);case 9:return r=ot(i,a,o),d.a(3,14);case 10:return r=st(i,a,o),d.a(3,14);case 11:return r=ht(i,a),d.a(3,14);case 12:return r=dt(i,a),d.a(3,14);case 13:return r=at(i,a),d.a(3,14);case 14:d.n=16;break;case 15:throw d.p=15,(f=d.v).position=t.position,f.token=o,f;case 16:return d.a(2,r)}},g,null,[[7,15],[2,4]])}function Q(t,e,n){var r,i,o,s,a;return u().w(function(u){for(;;)switch(u.n){case 0:a=t.value,u.n="-"===a?1:"["===a?6:"{"===a?11:13;break;case 1:return u.d(c(W(t.expression,e,n)),2);case 2:if(void 0!==(r=u.v)){u.n=3;break}r=void 0,u.n=5;break;case 3:if(!j(r)){u.n=4;break}r=-r,u.n=5;break;case 4:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:r};case 5:return u.a(3,13);case 6:r=[],i=0;case 7:if(!(i<t.expressions.length)){u.n=10;break}return o=t.expressions[i],u.d(c(W(o,e,n)),8);case 8:void 0!==(s=u.v)&&("["===o.value?r.push(s):r=f.append(r,s));case 9:i++,u.n=7;break;case 10:return t.consarray&&Object.defineProperty(r,"cons",{enumerable:!1,configurable:!1,value:!0}),u.a(3,13);case 11:return u.d(c(lt(t,e,n)),12);case 12:return r=u.v,u.a(3,13);case 13:return u.a(2,r)}},m)}function J(t,e,n){return f.lookup(e,t.value)}function K(t){return t.value}function tt(t,e){var n=C();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null===e||"object"!==i(e)||N(e)||d.keys(e).forEach(function(t){var r=e[t];Array.isArray(r)?(r=et(r),n=f.append(n,r)):n.push(r)}),n}function et(t,e){return void 0===e&&(e=[]),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){et(t,e)}):e.push(t),e}function nt(t,e){var n,r=C();return void 0!==e&&(rt(e,r),n=1===r.length?r[0]:r),n}function rt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?Array.prototype.forEach.call(t,function(t){rt(t,e)}):null===t||"object"!==i(t)||N(t)||d.keys(t).forEach(function(n){rt(t[n],e)})}function it(t,e,n){var r;if(void 0!==t&&!j(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!j(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;switch(n){case"+":r=t+e;break;case"-":r=t-e;break;case"*":r=t*e;break;case"/":r=t/e;break;case"%":r=t%e}return r}function ot(t,e,n){var r,o=i(t),s=i(e);if("undefined"===o||"undefined"===s)return!1;switch(n){case"=":r=U(t,e);break;case"!=":r=!U(t,e)}return r}function st(t,e,n){var r,o=i(t),s=i(e);if("undefined"!==o&&"string"!==o&&"number"!==o||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==o&&"number"!==o?t:e};if("undefined"!==o&&"undefined"!==s){if(o!==s)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":r=t<e;break;case"<=":r=t<=e;break;case">":r=t>e;break;case">=":r=t>=e}return r}}function at(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++)if(e[r]===t){n=!0;break}return n}function ct(t,e,n){var r,i,o,s,a,h,l;return u().w(function(u){for(;;)switch(u.n){case 0:i=ut(t),o=n,u.n="and"===o?1:"or"===o?4:7;break;case 1:if(!(s=i)){u.n=3;break}return a=ut,u.d(c(e()),2);case 2:s=a(u.v);case 3:return r=s,u.a(3,7);case 4:if(h=i){u.n=6;break}return l=ut,u.d(c(e()),5);case 5:h=l(u.v);case 6:return r=h,u.a(3,7);case 7:return u.a(2,r)}},b)}function ut(t){var e=f.boolean(t);return void 0!==e&&e}function ht(t,e){var n="",r="";return void 0!==t&&(n=f.string(t)),void 0!==e&&(r=f.string(e)),n.concat(r)}function lt(t,e,n){var i,o,s,a,h,l,d,p,y,g,m,b,x,_,w;return u().w(function(u){for(;;)switch(u.n){case 0:i=Object.create(null),o=Object.create(null),s=!(!e||!e.tupleStream),Array.isArray(e)||(e=C(e)),0===e.length&&e.push(void 0),a=0;case 1:if(!(a<e.length)){u.n=10;break}h=e[a],l=s?B(n,h):n,d=0;case 2:if(!(d<t.lhs.length)){u.n=9;break}return p=t.lhs[d],u.d(c(W(p[0],s?h["@"]:h,l)),3);case 3:if("string"==typeof(y=u.v)||void 0===y){u.n=4;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:y};case 4:if(void 0===y){u.n=8;break}if("_jsonata_lambda"!==y&&"_jsonata_function"!==y){u.n=5;break}throw{code:"D1013",stack:(new Error).stack,position:t.position,value:y};case 5:if(g={data:h,exprIndex:d},!Object.prototype.hasOwnProperty.call(o,y)){u.n=7;break}if(o[y].exprIndex===d){u.n=6;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:y};case 6:o[y].data=f.append(o[y].data,h),u.n=8;break;case 7:o[y]=g;case 8:d++,u.n=2;break;case 9:a++,u.n=1;break;case 10:_=r(o);case 11:if((w=_()).done){u.n=13;break}return y=w.value,g=o[y],m=g.data,l=n,s&&(b=ft(g.data),m=b["@"],delete b["@"],l=B(n,b)),u.d(c(W(t.lhs[g.exprIndex][1],m,l)),12);case 12:void 0!==(x=u.v)&&(i[y]=x),u.n=11;break;case 13:return u.a(2,i)}},v)}function ft(t){if(!Array.isArray(t))return t;var e=Object.create(null);Object.assign(e,t[0]);for(var n=1;n<t.length;n++){var r,i=o(d.keys(t[n]));try{for(i.s();!(r=i.n()).done;){var s=r.value;e[s]=f.append(e[s],t[n][s])}}catch(t){i.e(t)}finally{i.f()}}return e}function dt(t,e){var n;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;if(t>e)return n;var r=e-t+1;if(r>1e7)throw{code:"D2014",stack:(new Error).stack,value:r};n=new Array(r);for(var i=t,o=0;i<=e;i++,o++)n[o]=i;return n.sequence=!0,n}function pt(t,e,n){var r;return u().w(function(i){for(;;)switch(i.n){case 0:return i.d(c(W(t.rhs,e,n)),1);case 1:return r=i.v,n.bind(t.lhs.value,r),i.a(2,r)}},x)}function yt(t,e,n){var r,i;return u().w(function(o){for(;;)switch(o.n){case 0:return o.d(c(W(t.condition,e,n)),1);case 1:if(i=o.v,!f.boolean(i)){o.n=3;break}return o.d(c(W(t.then,e,n)),2);case 2:r=o.v,o.n=5;break;case 3:if(void 0===t.else){o.n=5;break}return o.d(c(W(t.else,e,n)),4);case 4:r=o.v;case 5:return o.a(2,r)}},_)}function gt(t,e,n){var r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:i=Nt(n),o=0;case 1:if(!(o<t.expressions.length)){s.n=4;break}return s.d(c(W(t.expressions[o],e,i)),2);case 2:r=s.v;case 3:o++,s.n=1;break;case 4:return s.a(2,r)}},w)}function mt(t){var e=new $t.RegexEngine(t.value),n=function(r,i){var o;e.lastIndex=i||0;var s=e.exec(r);if(null!==s){if(o={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var a=1;a<s.length;a++)o.groups.push(s[a]);o.next=function(){if(!(e.lastIndex>=r.length)){var i=n(r,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return o};return n}function bt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function vt(t,e,n){var r,o,s,a,h;return u().w(function(l){for(;;)switch(l.n){case 0:return o=e,s=!!e.tupleStream,a=u().m(function e(r,o){var a,h,l,f,d,p,y,g,m;return u().w(function(e){for(;;)switch(e.n){case 0:a=0,h=0;case 1:if(!(0===a&&h<t.terms.length)){e.n=11;break}return l=t.terms[h],f=r,d=n,s&&(f=r["@"],d=B(n,r)),e.d(c(W(l.expression,f,d)),2);case 2:return p=e.v,f=o,d=n,s&&(f=o["@"],d=B(n,o)),e.d(c(W(l.expression,f,d)),3);case 3:if(y=e.v,g=i(p),m=i(y),"undefined"!==g){e.n=4;break}return a="undefined"===m?0:1,e.a(3,10);case 4:if("undefined"!==m){e.n=5;break}return a=-1,e.a(3,10);case 5:if(!("string"!==g&&"number"!==g||"string"!==m&&"number"!==m)){e.n=6;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?p:y};case 6:if(g===m){e.n=7;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:y};case 7:if(p!==y){e.n=8;break}return e.a(3,10);case 8:a=p<y?-1:1;case 9:!0===l.descending&&(a=-a);case 10:h++,e.n=1;break;case 11:return e.a(2,1===a)}},e)}),h={environment:n,input:e},l.d(c(f.sort.apply(h,[o,a])),1);case 1:return r=l.v,l.a(2,r)}},k)}function xt(t,e,n){return Rt(u().m(function e(r){var s,a,h,l,f,p,y,g,m,b,v,x,_;return u().w(function(e){for(;;)switch(e.n){case 0:if(void 0!==r){e.n=1;break}return e.a(2,void 0);case 1:if(s=n.lookup("clone"),N(s)){e.n=2;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 2:return e.d(c(Mt(s,[r],null,n)),3);case 3:return a=e.v,e.d(c(W(t.pattern,a,n)),4);case 4:if(void 0===(h=e.v)){e.n=12;break}Array.isArray(h)||(h=[h]),l=0;case 5:if(!(l<h.length)){e.n=12;break}return f=h[l],e.d(c(W(t.update,f,n)),6);case 6:if(p=e.v,"undefined"===(y=i(p))){e.n=8;break}if("object"===y&&null!==p&&!Array.isArray(p)){e.n=7;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:p};case 7:g=o(d.keys(p));try{for(g.s();!(m=g.n()).done;)b=m.value,f[b]=p[b]}catch(t){g.e(t)}finally{g.f()}case 8:if(void 0===t.delete){e.n=11;break}return e.d(c(W(t.delete,f,n)),9);case 9:if(void 0===(v=e.v)){e.n=11;break}if(x=v,Array.isArray(v)||(v=[v]),P(v)){e.n=10;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:x};case 10:for(_=0;_<v.length;_++)"object"===i(f)&&null!==f&&delete f[v[_]];case 11:l++,e.n=5;break;case 12:return e.a(2,a)}},e)}),"<(oa):o>")}var _t=p("function($f, $g) { function($x){ $g($f($x)) } }");function wt(t,e,n){var r,i,o,s;return u().w(function(a){for(;;)switch(a.n){case 0:return a.d(c(W(t.lhs,e,n)),1);case 1:if(i=a.v,"function"!==t.rhs.type){a.n=3;break}return a.d(c(kt(t.rhs,e,n,{context:i})),2);case 2:r=a.v,a.n=10;break;case 3:return a.d(c(W(t.rhs,e,n)),4);case 4:if(o=a.v,N(o)){a.n=5;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 5:if(!N(i)){a.n=8;break}return a.d(c(W(_t,null,n)),6);case 6:return s=a.v,a.d(c(Mt(s,[i,o],null,n)),7);case 7:r=a.v,a.n=10;break;case 8:return a.d(c(Mt(o,[i],null,n)),9);case 9:r=a.v;case 10:return a.a(2,r)}},M)}function kt(t,e,n,r){var o,s,a,h,l,f,d;return u().w(function(p){for(;;)switch(p.p=p.n){case 0:return p.d(c(W(t.procedure,e,n)),1);case 1:if(void 0!==(s=p.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){p.n=2;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 2:a=[],void 0!==r&&a.push(r.context),h=u().m(function r(){var i,o;return u().w(function(r){for(;;)switch(r.n){case 0:return r.d(c(W(t.arguments[l],e,n)),1);case 1:i=r.v,N(i)?(o=u().m(function t(){var e,r,o,s=arguments;return u().w(function(t){for(;;)switch(t.n){case 0:for(e=s.length,r=new Array(e),o=0;o<e;o++)r[o]=s[o];return t.d(c(Mt(i,r,null,n)),1);case 1:return t.a(2,t.v)}},t)}),o.arity=$(i),a.push(o)):a.push(i);case 2:return r.a(2)}},r)}),l=0;case 3:if(!(l<t.arguments.length)){p.n=5;break}return p.d(c(h()),4);case 4:l++,p.n=3;break;case 5:return f="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,p.p=6,"object"===i(s)&&(s.token=f,s.position=t.position),p.d(c(Mt(s,a,e,n)),7);case 7:o=p.v,p.n=9;break;case 8:throw p.p=8,(d=p.v).position||(d.position=t.position),d.token||(d.token=f),d;case 9:return p.a(2,o)}},S,null,[[6,8]])}function Mt(t,e,n,r){var i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:return u.d(c(St(t,e,n,r)),1);case 1:i=u.v;case 2:if(!D(i)||!0!==i.thunk){u.n=9;break}return u.d(c(W(i.body.procedure,i.input,i.environment)),3);case 3:o=u.v,"variable"===i.body.procedure.type&&(o.token=i.body.procedure.value),o.position=i.body.procedure.position,s=[],a=0;case 4:if(!(a<i.body.arguments.length)){u.n=7;break}return h=s,u.d(c(W(i.body.arguments[a],i.input,i.environment)),5);case 5:h.push.call(h,u.v);case 6:a++,u.n=4;break;case 7:return u.d(c(St(o,s,n,r)),8);case 8:i=u.v,u.n=2;break;case 9:return u.a(2,i)}},z)}function St(t,e,n,r){var i,o,s,a;return u().w(function(u){for(;;)switch(u.p=u.n){case 0:if(u.p=0,o=e,t&&(o=At(t.signature,e,n)),!D(t)){u.n=2;break}return u.d(c(Tt(t,o)),1);case 1:i=u.v,u.n=9;break;case 2:if(!t||!0!==t._jsonata_function){u.n=5;break}if(s={environment:r,input:n},i=t.implementation.apply(s,o),!L(i)){u.n=4;break}return u.d(c(i),3);case 3:i=u.v;case 4:u.n=9;break;case 5:if("function"!=typeof t){u.n=8;break}if(i=t.apply(n,o),!L(i)){u.n=7;break}return u.d(c(i),6);case 6:i=u.v;case 7:u.n=9;break;case 8:throw{code:"T1006",stack:(new Error).stack};case 9:u.n=11;break;case 10:throw u.p=10,a=u.v,t&&(void 0===a.token&&void 0!==t.token&&(a.token=t.token),a.position=t.position||a.position),a;case 11:return u.a(2,i)}},E,null,[[0,10]])}function zt(t,e,n){var r={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(r.thunk=!0),r.apply=u().m(function t(n,i){return u().w(function(t){for(;;)switch(t.n){case 0:return t.d(c(Mt(r,i,e,n.environment)),1);case 1:return t.a(2,t.v)}},t)}),r}function Et(t,e,n){var r,i,o,s,a,h;return u().w(function(u){for(;;)switch(u.n){case 0:i=[],o=0;case 1:if(!(o<t.arguments.length)){u.n=5;break}if("operator"!==(s=t.arguments[o]).type||"?"!==s.value){u.n=2;break}i.push(s),u.n=4;break;case 2:return h=i,u.d(c(W(s,e,n)),3);case 3:h.push.call(h,u.v);case 4:o++,u.n=1;break;case 5:return u.d(c(W(t.procedure,e,n)),6);case 6:if(void 0!==(a=u.v)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){u.n=7;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 7:if(!D(a)){u.n=8;break}r=Ot(a,i),u.n=11;break;case 8:if(!a||!0!==a._jsonata_function){u.n=9;break}r=It(a.implementation,i),u.n=11;break;case 9:if("function"!=typeof a){u.n=10;break}r=It(a,i),u.n=11;break;case 10:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 11:return u.a(2,r)}},A)}function At(t,e,n){return void 0===t?e:t.validate(e,n)}function Tt(t,e){var n,r;return u().w(function(i){for(;;)switch(i.n){case 0:if(r=Nt(t.environment),Array.prototype.forEach.call(t.arguments,function(t,n){r.bind(t.value,e[n])}),"function"!=typeof t.body){i.n=2;break}return i.d(c(jt(t.body,r)),1);case 1:n=i.v,i.n=4;break;case 2:return i.d(c(W(t.body,t.input,r)),3);case 3:n=i.v;case 4:return i.a(2,n)}},T)}function Ot(t,e){var n=Nt(t.environment),r=[];return Array.prototype.forEach.call(t.arguments,function(t,i){var o=e[i];o&&"operator"===o.type&&"?"===o.value?r.push(t):n.bind(t.value,o)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:r,body:t.body}}function It(t,e){var n=Pt(t),r="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",i=p(r);return i.body=t,Ot(i,e)}function jt(t,e){var n,r,i,o;return u().w(function(s){for(;;)switch(s.n){case 0:if(n=Pt(t),r=n.map(function(t){return e.lookup(t.trim())}),i={environment:e},o=t.apply(i,r),!L(o)){s.n=2;break}return s.d(c(o),1);case 1:o=s.v;case 2:return s.a(2,o)}},O)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Rt(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=y(e)),n}function Ct(t,e){var n,r,i,o,s;return u().w(function(a){for(;;)switch(a.p=a.n){case 0:if(void 0!==t){a.n=1;break}return a.a(2,void 0);case 1:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!F(n)&&((n=C(n)).outerWrapper=!0)),a.p=2,r=p(t,!1),a.n=4;break;case 3:throw a.p=3,Lt(o=a.v),{stack:(new Error).stack,code:"D3120",value:o.message,error:o};case 4:return a.p=4,a.d(c(W(r,n,this.environment)),5);case 5:i=a.v,a.n=7;break;case 6:throw a.p=6,Lt(s=a.v),{stack:(new Error).stack,code:"D3121",value:s.message,error:s};case 7:return a.a(2,i)}},I,this,[[4,6],[2,3]])}function Ft(t){if(void 0!==t)return JSON.parse(f.string(t))}function Nt(t){var e=Object.create(null);return{bind:function(t,n){e[t]=n},lookup:function(n){var r;return Object.prototype.hasOwnProperty.call(e,n)?r=e[n]:t&&(r=t.lookup(n)),r},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}q.bind("sum",Rt(f.sum,"<a<n>:n>")),q.bind("count",Rt(f.count,"<a:n>")),q.bind("max",Rt(f.max,"<a<n>:n>")),q.bind("min",Rt(f.min,"<a<n>:n>")),q.bind("average",Rt(f.average,"<a<n>:n>")),q.bind("string",Rt(f.string,"<x-b?:s>")),q.bind("substring",Rt(f.substring,"<s-nn?:s>")),q.bind("substringBefore",Rt(f.substringBefore,"<s-s:s>")),q.bind("substringAfter",Rt(f.substringAfter,"<s-s:s>")),q.bind("lowercase",Rt(f.lowercase,"<s-:s>")),q.bind("uppercase",Rt(f.uppercase,"<s-:s>")),q.bind("length",Rt(f.length,"<s-:n>")),q.bind("trim",Rt(f.trim,"<s-:s>")),q.bind("pad",Rt(f.pad,"<s-ns?:s>")),q.bind("match",Rt(f.match,"<s-f<s:o>n?:a<o>>")),q.bind("contains",Rt(f.contains,"<s-(sf):b>")),q.bind("replace",Rt(f.replace,"<s-(sf)(sf)n?:s>")),q.bind("split",Rt(f.split,"<s-(sf)n?:a<s>>")),q.bind("join",Rt(f.join,"<a<s>s?:s>")),q.bind("formatNumber",Rt(f.formatNumber,"<n-so?:s>")),q.bind("formatBase",Rt(f.formatBase,"<n-n?:s>")),q.bind("formatInteger",Rt(l.formatInteger,"<n-s:s>")),q.bind("parseInteger",Rt(l.parseInteger,"<s-s:n>")),q.bind("number",Rt(f.number,"<(nsb)-:n>")),q.bind("floor",Rt(f.floor,"<n-:n>")),q.bind("ceil",Rt(f.ceil,"<n-:n>")),q.bind("round",Rt(f.round,"<n-n?:n>")),q.bind("abs",Rt(f.abs,"<n-:n>")),q.bind("sqrt",Rt(f.sqrt,"<n-:n>")),q.bind("power",Rt(f.power,"<n-n:n>")),q.bind("random",Rt(f.random,"<:n>")),q.bind("boolean",Rt(f.boolean,"<x-:b>")),q.bind("not",Rt(f.not,"<x-:b>")),q.bind("map",Rt(f.map,"<af>")),q.bind("zip",Rt(f.zip,"<a+>")),q.bind("filter",Rt(f.filter,"<af>")),q.bind("single",Rt(f.single,"<af?>")),q.bind("reduce",Rt(f.foldLeft,"<afj?:j>")),q.bind("sift",Rt(f.sift,"<o-f?:o>")),q.bind("keys",Rt(f.keys,"<x-:a<s>>")),q.bind("lookup",Rt(f.lookup,"<x-s:x>")),q.bind("append",Rt(f.append,"<xx:a>")),q.bind("exists",Rt(f.exists,"<x:b>")),q.bind("spread",Rt(f.spread,"<x-:a<o>>")),q.bind("merge",Rt(f.merge,"<a<o>:o>")),q.bind("reverse",Rt(f.reverse,"<a:a>")),q.bind("each",Rt(f.each,"<o-f:a>")),q.bind("error",Rt(f.error,"<s?:x>")),q.bind("assert",Rt(f.assert,"<bs?:x>")),q.bind("type",Rt(f.type,"<x:s>")),q.bind("sort",Rt(f.sort,"<af?:a>")),q.bind("shuffle",Rt(f.shuffle,"<a:a>")),q.bind("distinct",Rt(f.distinct,"<x:x>")),q.bind("base64encode",Rt(f.base64encode,"<s-:s>")),q.bind("base64decode",Rt(f.base64decode,"<s-:s>")),q.bind("encodeUrlComponent",Rt(f.encodeUrlComponent,"<s-:s>")),q.bind("encodeUrl",Rt(f.encodeUrl,"<s-:s>")),q.bind("decodeUrlComponent",Rt(f.decodeUrlComponent,"<s-:s>")),q.bind("decodeUrl",Rt(f.decodeUrl,"<s-:s>")),q.bind("eval",Rt(Ct,"<sx?:x>")),q.bind("toMillis",Rt(l.toMillis,"<s-s?:n>")),q.bind("fromMillis",Rt(l.fromMillis,"<n-s?s?:s>")),q.bind("clone",Rt(Ft,"<(oa)-:o>"));var Dt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1013:"Object property names starting with _jsonata_ are reserved for internal use: {{value}}",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Lt(t){var e=Dt[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function $t(t,e){var n,r;try{n=p(t,e&&e.recover),r=n.errors,delete n.errors}catch(t){throw Lt(t),t}var i=Nt(q),s=new Date;return i.bind("now",Rt(function(t,e){return l.fromMillis(s.getTime(),t,e)},"<s?s?:s>")),i.bind("millis",Rt(function(){return s.getTime()},"<:n>")),e&&e.RegexEngine?$t.RegexEngine=e.RegexEngine:$t.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==r){var c={code:"S0500",position:0};throw Lt(c),c}if(void 0!==e){var u;u=Nt(i);var h,l=o(d.keys(e));try{for(l.s();!(h=l.n()).done;){var f=h.value;u.bind(f,e[f])}}catch(c){l.e(c)}finally{l.f()}}else u=i;var p,y;if(u.bind("$",t),s=new Date,u.timestamp=s,Array.isArray(t)&&!F(t)&&((t=C(t)).outerWrapper=!0),"function"==typeof a){u.async=!0;var g=function(t){Lt(t),a(t,null)},m=function(t){(p=y.next(t)).done?a(null,p.value):p.value.then(m).catch(g)};y=W(n,t,u),(p=y.next()).value.then(m).catch(g)}else try{for(y=W(n,t,u),p=y.next();!p.done;)p=y.next(p.value);return p.value}catch(c){throw Lt(c),c}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,n){var r=Rt(e,n);i.bind(t,r)},ast:function(){return n},errors:function(){return r}}}return $t.parser=p,$t}();e.exports=g},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var r=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},n=function(n){var r=0,i=n.length,o=function(t,e){return{type:t,value:e,position:r}},s=function(){for(var t,e,o=r,s=0;r<i;){var a=n.charAt(r);if("/"===a&&"\\"!==n.charAt(r-1)&&0===s){if(""===(t=n.substring(o,r)))throw{code:"S0301",stack:(new Error).stack,position:r};for(r++,a=n.charAt(r),o=r;"i"===a||"m"===a;)r++,a=n.charAt(r);return e=n.substring(o,r)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(r-1)||s++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(r-1)||s--,r++}throw{code:"S0302",stack:(new Error).stack,position:r}},a=function(c){if(r>=i)return null;for(var u=n.charAt(r);r<i&&" \t\n\r\v".indexOf(u)>-1;)r++,u=n.charAt(r);if("/"===u&&"*"===n.charAt(r+1)){var h=r;for(r+=2,u=n.charAt(r);"*"!==u||"/"!==n.charAt(r+1);)if(u=n.charAt(++r),r>=i)throw{code:"S0106",stack:(new Error).stack,position:h};return r+=2,u=n.charAt(r),a(c)}if(!0!==c&&"/"===u)return r++,o("regex",s());if("."===u&&"."===n.charAt(r+1))return r+=2,o("operator","..");if(":"===u&&"="===n.charAt(r+1))return r+=2,o("operator",":=");if("!"===u&&"="===n.charAt(r+1))return r+=2,o("operator","!=");if(">"===u&&"="===n.charAt(r+1))return r+=2,o("operator",">=");if("<"===u&&"="===n.charAt(r+1))return r+=2,o("operator","<=");if("*"===u&&"*"===n.charAt(r+1))return r+=2,o("operator","**");if("~"===u&&">"===n.charAt(r+1))return r+=2,o("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return r++,o("operator",u);if('"'===u||"'"===u){var l=u;r++;for(var f="";r<i;){if("\\"===(u=n.charAt(r)))if(r++,u=n.charAt(r),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:r,token:u};var d=n.substr(r+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:r};var p=parseInt(d,16);f+=String.fromCharCode(p),r+=4}else{if(u===l)return r++,o("string",f);f+=u}r++}throw{code:"S0101",stack:(new Error).stack,position:r}}var y,g=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(r));if(null!==g){var m=parseFloat(g[0]);if(!isNaN(m)&&isFinite(m))return r+=g[0].length,o("number",m);throw{code:"S0102",stack:(new Error).stack,position:r,token:g[0]}}if("`"===u){r++;var b=n.indexOf("`",r);if(-1!==b)return y=n.substring(r,b),r=b+1,o("name",y);throw r=i,{code:"S0105",stack:(new Error).stack,position:r}}for(var v,x=r;;)if(v=n.charAt(x),x===i||" \t\n\r\v".indexOf(v)>-1||Object.prototype.hasOwnProperty.call(t,v)){if("$"===n.charAt(r))return y=n.substring(r+1,x),r=x,o("variable",y);switch(y=n.substring(r,x),r=x,y){case"or":case"in":case"and":return o("operator",y);case"true":return o("value",!0);case"false":return o("value",!1);case"null":return o("value",null);default:return r===i&&""===y?null:o("name",y)}}else x++};return a},i=function(e,i){var o,s,a=Object.create(null),c=[],u=function(){var t=[];"(end)"!==o.id&&t.push({type:o.type,value:o.value,position:o.position});for(var e=s();null!==e;)t.push(e),e=s();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},l=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(h)).id=n.value=t,n.lbp=e,a[t]=n),n},f=function(t){if(i){t.remaining=u(),c.push(t);var e=a["(error)"];return(o=Object.create(e)).error=t,o.type="(error)",o}throw t.stack=(new Error).stack,t},d=function(t,n){if(t&&o.id!==t){var r={code:"(end)"===o.id?"S0203":"S0202",position:o.position,token:o.value,value:t};return f(r)}var i=s(n);if(null===i)return(o=a["(end)"]).position=e.length,o;var c,u=i.value,h=i.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(o=Object.create(c)).value=u,o.type=h,o.position=i.position,o},p=function(t){var e,n=o;for(d(null,!0),e=n.nud();t<o.lbp;)n=o,d(),e=n.led(e);return e},y=function(t){l(t,0).nud=function(){return this}},g=function(e,n,r){var i=n||t[e],o=l(e,i);return o.led=r||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},o},m=function(t,e,n){var r=l(t,e);return r.led=n,r},b=function(t,e){var n=l(t);return n.nud=e||function(){return this.expression=p(70),this.type="unary",this},n};y("(end)"),y("(name)"),y("(literal)"),y("(regex)"),l(":"),l(";"),l(","),l(")"),l("]"),l("}"),l(".."),g("."),g("+"),g("-"),g("*"),g("/"),g("%"),g("="),g("<"),g(">"),g("!="),g("<="),g(">="),g("&"),g("and"),g("or"),g("in"),y("and"),y("or"),y("in"),b("-"),g("~>"),m("(error)",10,function(t){return this.lhs=t,this.error=o.error,this.remaining=u(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),g("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==o.id)for(;"operator"===o.type&&"?"===o.id?(this.type="partial",this.arguments.push(o),d("?")):this.arguments.push(p(0)),","===o.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach(function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===o.id){for(var e=o.position,n=1,i="<";n>0&&"{"!==o.id&&"(end)"!==o.id;){var s=d();">"===s.id?n--:"<"===s.id&&n++,i+=s.value}d(">");try{this.signature=r(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this}),b("(",function(){for(var t=[];")"!==o.id&&(t.push(p(0)),";"===o.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==o.id)for(;;){var e=p(0);if(".."===o.id){var n={type:"binary",value:"..",position:o.position,lhs:e};d(".."),n.rhs=p(0),e=n}if(t.push(e),","!==o.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this}),g("[",t["["],function(e){if("]"===o.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this}),g("^",t["^"],function(t){d("(");for(var e=[];;){var n={descending:!1};if("<"===o.id?d("<"):">"===o.id&&(n.descending=!0,d(">")),n.expression=p(0),e.push(n),","!==o.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var v=function(t){var e=[];if("}"!==o.id)for(;;){var n=p(0);d(":");var r=p(0);if(e.push([n,r]),","!==o.id)break;d(",")}return d("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};b("{",v),g("{",t["{"],v),m(":=",t[":="],function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)}),g("@",t["@"],function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),g("#",t["#"],function(e){return this.lhs=e,this.rhs=p(t["#"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),g("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=p(0),":"===o.id&&(d(":"),this.else=p(0)),this}),b("|",function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===o.id&&(d(","),this.delete=p(0)),d("|"),this});var x=function(t){var e;if("function"!==t.type||t.predicate)if("condition"===t.type)t.then=x(t.then),void 0!==t.else&&(t.else=x(t.else)),e=t;else if("block"===t.type){var n=t.expressions.length;n>0&&(t.expressions[n-1]=x(t.expressions[n-1])),e=t}else e=t;else{var r={type:"lambda",thunk:!0,arguments:[],position:t.position};r.body=t,e=r}return e},_=0,w=0,k=[],M=function(t,e){switch(t.type){case"name":case"wildcard":e.level--,0===e.level&&(void 0===t.ancestor||(k[e.index].slot.label=t.ancestor.label),t.ancestor=e,t.tuple=!0);break;case"parent":e.level++;break;case"block":t.expressions.length>0&&(t.tuple=!0,e=M(t.expressions[t.expressions.length-1],e));break;case"path":t.tuple=!0;var n=t.steps.length-1;for(e=M(t.steps[n--],e);e.level>0&&n>=0;)e=M(t.steps[n--],e);break;default:throw{code:"S0217",token:t.type,position:t.position}}return e},S=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},z=function(t){var e=t.steps.length-1,n=t.steps[e],r=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&r.push(n.slot);for(var i=0;i<r.length;i++){var o=r[i];for(e=t.steps.length-2;o.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[o]:t.seekingParent.push(o);break}for(var s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];o=M(s,o)}}},E=function(t){var e;switch(t.type){case"binary":switch(t.value){case".":var n=E(t.lhs);e="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(e.seekingParent=[n.slot]);var r=E(t.rhs);"function"===r.type&&"path"===r.procedure.type&&1===r.procedure.steps.length&&"name"===r.procedure.steps[0].type&&"function"===e.steps[e.steps.length-1].type&&(e.steps[e.steps.length-1].nextFunction=r.procedure.steps[0].value),"path"===r.type?Array.prototype.push.apply(e.steps,r.steps):(void 0!==r.predicate&&(r.stages=r.predicate,delete r.predicate),e.steps.push(r)),e.steps.filter(function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type}).forEach(function(t){t.type="name"}),e.steps.filter(function(t){return!0===t.keepArray}).length>0&&(e.keepSingletonArray=!0);var o=e.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var s=e.steps[e.steps.length-1];"unary"===s.type&&"["===s.value&&(s.consarray=!0),z(e);break;case"[":var a=e=E(t.lhs),u="predicate";if("path"===e.type&&(a=e.steps[e.steps.length-1],u="stages"),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:t.position};void 0===a[u]&&(a[u]=[]);var h=E(t.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach(function(t){1===t.level?M(a,t):t.level--}),S(a,h)),a[u].push({type:"filter",expr:h,position:t.position});break;case"{":if(void 0!==(e=E(t.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:t.position};e.group={lhs:t.rhs.map(function(t){return[E(t[0]),E(t[1])]}),position:t.position};break;case"^":"path"!==(e=E(t.lhs)).type&&(e={type:"path",steps:[e]});var l={type:"sort",position:t.position};l.terms=t.rhs.map(function(t){var e=E(t.expression);return S(l,e),{descending:t.descending,expression:e}}),e.steps.push(l),z(e);break;case":=":(e={type:"bind",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.rhs);break;case"@":if(e=E(t.lhs),a=e,"path"===e.type&&(a=e.steps[e.steps.length-1]),void 0!==a.stages||void 0!==a.predicate)throw{code:"S0215",stack:(new Error).stack,position:t.position};if("sort"===a.type)throw{code:"S0216",stack:(new Error).stack,position:t.position};t.keepArray&&(a.keepArray=!0),a.focus=t.rhs.value,a.tuple=!0;break;case"#":e=E(t.lhs),a=e,"path"===e.type?a=e.steps[e.steps.length-1]:(e={type:"path",steps:[e]},void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate)),void 0===a.stages?a.index=t.rhs.value:a.stages.push({type:"index",value:t.rhs.value,position:t.position}),a.tuple=!0;break;case"~>":(e={type:"apply",value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs);break;default:(e={type:t.type,value:t.value,position:t.position}).lhs=E(t.lhs),e.rhs=E(t.rhs),S(e,e.lhs),S(e,e.rhs)}break;case"unary":e={type:t.type,value:t.value,position:t.position},"["===t.value?e.expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),n}):"{"===t.value?e.lhs=t.lhs.map(function(t){var n=E(t[0]);S(e,n);var r=E(t[1]);return S(e,r),[n,r]}):(e.expression=E(t.expression),"-"===t.value&&"number"===e.expression.type?(e=e.expression).value=-e.value:S(e,e.expression));break;case"function":case"partial":(e={type:t.type,name:t.name,value:t.value,position:t.position}).arguments=t.arguments.map(function(t){var n=E(t);return S(e,n),n}),e.procedure=E(t.procedure);break;case"lambda":e={type:t.type,arguments:t.arguments,signature:t.signature,position:t.position};var f=E(t.body);e.body=x(f);break;case"condition":(e={type:t.type,position:t.position}).condition=E(t.condition),S(e,e.condition),e.then=E(t.then),S(e,e.then),void 0!==t.else&&(e.else=E(t.else),S(e,e.else));break;case"transform":(e={type:t.type,position:t.position}).pattern=E(t.pattern),e.update=E(t.update),void 0!==t.delete&&(e.delete=E(t.delete));break;case"block":(e={type:t.type,position:t.position}).expressions=t.expressions.map(function(t){var n=E(t);return S(e,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(e.consarray=!0),n});break;case"name":e={type:"path",steps:[t]},t.keepArray&&(e.keepSingletonArray=!0);break;case"parent":e={type:"parent",slot:{label:"!"+_++,level:1,index:w++}},k.push(e);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":e=t;break;case"operator":if("and"===t.value||"or"===t.value||"in"===t.value)t.type="name",e=E(t);else{if("?"!==t.value)throw{code:"S0201",stack:(new Error).stack,position:t.position,token:t.value};e=t}break;case"error":e=t,t.lhs&&(e=E(t.lhs));break;default:var d="S0206";"(end)"===t.id&&(d="S0207");var p={code:d,position:t.position,token:t.value};if(i)return c.push(p),{type:"error",error:p};throw p.stack=(new Error).stack,p}return t.keepArray&&(e.keepArray=!0),e};s=n(e),d();var A=p(0);if("(end)"!==o.id){var T={code:"S0201",position:o.position,token:o.value};f(T)}if("parent"===(A=E(A)).type||void 0!==A.seekingParent)throw{code:"S0217",token:A.type,position:A.position};return c.length>0&&(A.errors=c),A};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,n){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=t("./utils"),o=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,o=[],s=Object.create(null),a=s;n<e.length;){var c=e.charAt(n);if(":"===c)break;var u=function(){o.push(s),a=s,s=Object.create(null)},h=function(t,e,n,r){for(var i=1,o=e;o<t.length;)if(o++,(c=t.charAt(o))===r){if(0===--i)break}else c===n&&i++;return o};switch(c){case"s":case"n":case"b":case"l":case"o":s.regex="["+c+"m]",s.type=c,u();break;case"a":s.regex="[asnblfom]",s.type=c,s.array=!0,u();break;case"f":s.regex="f",s.type=c,u();break;case"j":s.regex="[asnblom]",s.type=c,u();break;case"x":s.regex="[asnblfom]",s.type=c,u();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var l=h(e,n,"(",")"),f=e.substring(n+1,l);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:n};s.regex="["+f+"m]",s.type="("+f+")",n=l,u();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var d=h(e,n,"<",">");a.subtype=e.substring(n+1,d),n=d}n++}var p="^"+o.map(function(t){return"("+t.regex+")"}).join("")+"$",y=new RegExp(p),g=function(t){var e;if(i.isFunction(t))e="f";else switch(r(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},m=function(t,e){for(var n="^",r=0,i=0;i<o.length;i++){n+=o[i].regex;var s=e.match(n);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1};r=s[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[r],index:r+1}};return{definition:e,validate:function(e,n){var r="";e.forEach(function(t){r+=g(t)});var i=y.exec(r);if(i){var s=[],a=0;return o.forEach(function(r,o){var c=e[a],u=i[o+1];if(""===u)if(r.context&&r.contextRegex){var h=g(n);if(!r.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};s.push(n)}else s.push(c),a++;else u.split("").forEach(function(n){if("a"===r.type){if("m"===n)c=void 0;else{c=e[a];var i=!0;if(void 0!==r.subtype)if("a"!==n&&u!==r.subtype)i=!1;else if("a"===n&&c.length>0){var o=g(c[0]);i=o===r.subtype.charAt(0)&&0===c.filter(function(t){return g(t)!==o}).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[r.subtype]};"a"!==n&&(c=[c])}s.push(c),a++}else s.push(c),a++})}),s}m(e,r)}}}return e}();e.exports=o},{"./utils":6}],6:[function(t,e,n){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}var a=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter(function(t){return"string"!=typeof t}).length),e}function n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function o(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function u(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function l(t){return"object"===s(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!f(t[n],e[n]))return!1;return!0}var r=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(r.length!==i.length)return!1;for(r=r.sort(),i=i.sort(),n=0;n<r.length;n++)if(r[n]!==i[n])return!1;for(n=0;n<r.length;n++){var o=r[n];if(!f(t[o],e[o]))return!1}return!0}return!1}function d(t){var e,n=[],i=r(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;n.push(o)}}catch(t){i.e(t)}finally{i.f()}return n}function p(t){return"object"===s(t)&&null!==t?Object.keys(t):[]}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:i,isSequence:o,isFunction:a,isLambda:u,isIterable:l,getFunctionArity:c,isDeepEqual:f,stringToArray:d,keys:p}}();e.exports=a},{}]},{},[3])(3)}(eo)),eo.exports),ro=Ji(no);const io=function(t){return t};function oo(t){if(!t)return io;try{const e=ro(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Zi(t),io}}function so(t){const e=wi(t);return null==e?"":String(e)}function ao(t){return Number(wi(t))}function co(t){return t}function uo(t){return so(t)}function ho(t){return ao(t)}function lo(t){if(this.param)return t=so(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function fo(t){const{param:e}=this;if(e){for(const n in e){let[r,i]=n.split("~");const o=!!r,s=!!i,a=parseFloat(r),c=parseFloat(i);if(t=ao(t),o&&!s&&t>=a)return e[n];if(!o&&s&&t<a)return e[n];if(t>=a&&t<c)return e[n]}return e.default}}function po(t){return ao(t)*Math.PI/180}function yo(){}const go=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const mo=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],bo=new Array(mo.length).fill(void 0),vo=Object.getPrototypeOf(async function(){}).constructor;function xo(t,e){!function(t){for(const e of go)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const n=function(t){return/\bawait\b/.test(t)}(t),r=new(n?vo:Function)(...e,...mo,t);return function(t,...e){return r.call(t,...e,...bo)}}function _o(t,e,n,r,i){switch(n){case"value":return"text"===i||"string"===i?uo.bind(t):"number"===i?ho.bind(t):co.bind(e);case"map":return lo.bind(t);case"range":return fo.bind(t);case"radian":return po.bind(t);case"eval":return function(t){try{const e=xo(t,["value","targets","scene"]);return function(t,n){try{const r=e(this,t,n,globalThis.scene);return r&&"function"==typeof r.then?r.catch(t=>{Zi(t)}):r}catch(t){return void Zi(t)}}}catch(t){return Zi(t),yo}}(r).bind(e);default:return co.bind(e)}}class wo{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:r,param:i,accessor:o}=t;this._model=t,this.evaluator=_o(this,this.owner,r,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=oo(o);const s=e.match(/\[(.*?)\]/);if(s){const[t,e]=s[1].split(":");this.propAccessor=oo(t),this.partAccessor=oo(e)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function ko(t,e,n,r){const i=e.split(".");if(1===i.length)return void(t[e]=r?{...t[e],...n}:n);const o=i[0],s=void 0!==t[o]?t[o]:"function"==typeof t.get?t.get(o):void 0,a=s?{...s}:{};let c=a;for(let t=1;t<i.length-1;t++)c[i[t]]=c[i[t]]?{...c[i[t]]}:{},c=c[i[t]];const u=i[i.length-1];c[u]=r?{...c[u],...n}:n,t[o]=a}function Mo(t,e,n,r){t.forEach(t=>ko(t,e,n,r))}function So(t,e,n,r){t&&"function"==typeof t.then?t.then(t=>{void 0!==n&&void 0!==r&&n._dataGeneration!==r||e(t)}).catch(t=>Zi(t)):e(t)}function zo(t=!1){if(!t&&void 0===this.data)return;this._dataGeneration=(this._dataGeneration??0)+1;const e=this._dataGeneration,n=this;this.mappings&&this.mappings.forEach(t=>{try{let r,{source:i,target:o,property:s,accessor:a,propAccessor:c,partAccessor:u,ndnsp:h=!1,partial:l=!1}=t;o=(o||"(self)").trim(),t.rule||(t.rule="value"),i&&"(self)"!=i?(i.startsWith("#")&&(i=i.substring(1)),r=this.root.findById(i)?.data||{}):r=this.data;const f=a(r);if("(root)"==o||"(key)"==o){if(null==f)return;const r=Object.keys(f||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();r.length>0&&r.forEach(r=>{So(t.evaluator(f[r.get("id")],[r]),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||ko(r,s,t,l)},n,e)})}else if(o.startsWith("[")){if(null==f)return;if(f instanceof Array)f.forEach(r=>{const i=c(r);if(i){const o=this.root.findOrCreate(i);o&&So(t.evaluator(u(r),o),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(o,s,t,l)},n,e)}});else{if(!(f instanceof Object))throw String("mapping data should be an object to target property-id.("+f+")");{const r=c(f);if(r){const i=this.root.findOrCreate(r);i&&So(t.evaluator(u(f),i),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(i,s,t,l)},n,e)}}}}else{const r=this.root.findAll(o,this);r.length>0&&So(t.evaluator(f,r),t=>{!s||"(action)"===s||h&&!t&&0!==t&&!1!==t||Mo(r,s,t,l)},n,e)}}catch(e){Zi(e,this,t)}})}function Eo(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),zo.call(this,!0)}function Ao(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new wo({target:"(self)",rule:"value",...t},this))):(Zi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function To(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function Oo(t,e){this.disposeMappings(),zo.call(this)}function Io(t,e,n,r,i,o){e.complete?t.drawImage(e,n,r,i,o):e.addEventListener("load",()=>{this.invalidate()})}function jo(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const Po="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),Ro={FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",BOLD:!1,ITALIC:!1,LINE_DASH:"solid"},Co=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";Ro.FONT_FAMILY=e||n};let Fo;function No(t,e,n,r,i){const{alpha:o=1}=r,s=i.fillStyle;if(t.globalAlpha*=o,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(n.x,n.y);let r,{width:i,height:o}=e;if("linear"==s.gradientType){const e=3.141592653589793,n="number"==typeof s.rotation&&Number.isFinite(s.rotation)?s.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));s-=s-(i+o)/3,r=t.createLinearGradient(s*Math.cos(n+e),s*Math.sin(n+e),s*Math.cos(n),s*Math.sin(n))}else r=t.createLinearGradient((i-4)/2*Math.cos(n+e),(o-4)/2*Math.sin(n+e),(i-4)/2*Math.cos(n),(o-4)/2*Math.sin(n))}else if("radial"==s.gradientType){const e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((o-4)/2,2));switch(s.center){case"center":default:r=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":r=t.createRadialGradient(-i/2,-o/2,0,-i/2,-o/2,2*e);break;case"right-top":r=t.createRadialGradient(i/2,-o/2,0,i/2,-o/2,2*e);break;case"left-bottom":r=t.createRadialGradient(-i/2,o/2,0,-i/2,o/2,2*e);break;case"right-bottom":r=t.createRadialGradient(i/2,o/2,0,i/2,o/2,2*e)}}(Array.isArray(s.colorStops)?s.colorStops:Array.isArray(s.gradientStops)?s.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{r.addColorStop(t.position,t.color)}catch(e){((...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))})("Invalid Color for colorstop : ",t.color),r.addColorStop(t.position,"#fff")}}),t.fillStyle=r,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==s.type&&s.image)if(s.guideOnly&&1!=i.app.mode)s.color&&(t.fillStyle=s.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);const n=i._pattern_image;if(!n||!n.width||!n.height)return;let r=0,o=0,a=0,c=0,u=e.left,h=e.top;if(!s.fitPattern){r=s.offsetX,o=s.offsetY;const t=s.width?s.width:n.width,i=s.height?s.height:n.height;switch(s.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=r+a,h+=o+c}t.translate(u,h),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-h)}}function Do(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const r=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return r._pattern_image=r._pattern_image_origin,void t(this);let e=n.width||this.width,i=n.height||this.height;n.fitPattern&&(e=r.bounds.width,i=r.bounds.height);const o=Fo(e,i);o.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),r._pattern_image=o,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(n.image)}catch(t){e(t)}}function Lo(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Zi(t)})}function $o(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function Uo(t,e,n){let{strokeStyle:r,lineDash:i,lineWidth:o,lineCap:s,lineJoin:a,alpha:c}=e;if(r&&0!=o){if(s&&(t.lineCap=s),i){const e="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=e?[0,2*o]:[o,o];break;case"square-dot":i=e?[o,2*o]:[2*o,o];break;case"dash":i=e?[3*o,2.5*o]:[4*o,1.5*o];break;case"dash-dot":i=e?[3*o,3*o,0,3*o]:[4*o,2*o,o,2*o];break;case"long-dash":i=e?[5*o,4*o]:[6*o,3*o];break;case"long-dash-dot":i=e?[5*o,3*o,0,3*o]:[6*o,2*o,o,2*o];break;case"long-dash-dot-dot":i=e?[5*o,2*o,0,2*o,0,2*o]:[6*o,o,o,o,o,o]}Array.isArray(i)||(i=[]),t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=r,t.lineWidth=o,t.lineJoin=a,t.stroke()}}function qo(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let r;for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function Wo(t,e,n,r=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const o=e.text.substring(0,i);if(!(t.measureText(o).width+(i-1)*r<n))break}return{...e,text:e.text.substring(0,i-1)}}function Yo(t,e,n,r,i,o=0){const s=String(e).split("\n");return r?[].concat(...s.map(e=>function(t,e,n,r=0){const i=[];let o=[],s=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-s,u=t.measureText(a).width+(a.length-1)*r;if(u<=c)o.push({...e,text:a}),s+=u,a="";else{const n=Wo(t,{...e,text:a},c,r);o.push(n),i.push(o),o=[],s=0,a=a.substring(n.text.length)}}}),o.length>0&&i.push(o),i}(t,i?qo(e):[{text:e,bold:!1,italic:!1}],n,o))):s.map(t=>i?qo(t):[{text:t,bold:!1,italic:!1}])}function Bo(t,e,n,r,i,o,s=0){if(!r)return[];t.save(),t.font=n;const a=Yo(t,r,e,!!i,o,s);return t.restore(),a}function Go(t){const{fontFamily:e=Ro.FONT_FAMILY,bold:n=Ro.BOLD,italic:r=Ro.ITALIC,fontSize:i=Ro.FONT_SIZE}=t,o=[];return n&&o.push("bold"),r&&o.push("italic"),o.push(i+"px"),o.push(e),o.join(" ")}function Xo(t,e){const n=t.bold||e.bold,r=t.italic||e.italic;return Go({...t,bold:n,italic:r})}function Ho(t,e,n,r){let{alpha:i,rotation:o,keepTextAngle:s=!1,fontColor:a=Ro.FONT_COLOR,textAlign:c=Ro.TEXT_ALIGN,textBaseline:u=Ro.TEXT_BASELINE,textBackgroundStyle:h,fontSize:l,lineHeight:f,textWrap:d,textOverflow:p,letterSpacing:y=0}=r;i=void 0!==i?i:1,l||=Ro.FONT_SIZE,f||=1.2*l,t.save();const{left:g,top:m,width:b,height:v}=e;if(o&&s&&(t.translate(g+b/2,m+v/2),t.rotate(-o),t.translate(-(g+b/2),-(m+v/2))),t.beginPath(),t.font=Go(r),!d&&p){const e=function(t,e,n,r){const i="ellipsis"===t?"…":"",o=e.measureText(i).width,s=[];let a=0;for(const i of n){const n=[];for(const c of i){const i=e.measureText(c.text).width;if(!(a+i<=r-("ellipsis"===t?o:0))){const i=Vo(e,c,r-a-("ellipsis"===t?o:0),t);return n.push(i),s.push(n),s}n.push(c),a+=i}s.push(n),a=0}return s}(p,t,n,b);n=e}const x=n.length*f;let _;switch(u){case"top":_=m,t.textBaseline="top";break;case"bottom":_=m+v-x+f,t.textBaseline="bottom";break;default:_=m+v/2-x/2+f/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,n.forEach((e,i)=>{const o=_+i*f,s=function(t,e,n,r=0){return e.reduce((e,i)=>(t.font=Xo(n,i),e+t.measureText(i.text).width+r*(i.text.length-1)),0)}(t,e,r,y);let u=g;switch(c){case"left":case"justify":u=g;break;case"right":u=g+b-s;break;case"center":u=g+(b-s)/2}if(h&&(t.fillStyle=h,function(t,e,n,r,i,o=0,s=!1,a=!0){o="number"==typeof o?{tl:o,tr:o,br:o,bl:o}:{tl:0,tr:0,br:0,bl:0,...o},t.beginPath(),t.moveTo(e+o.tl,n),t.lineTo(e+r-o.tr,n),t.quadraticCurveTo(e+r,n,e+r,n+o.tr),t.lineTo(e+r,n+i-o.br),t.quadraticCurveTo(e+r,n+i,e+r-o.br,n+i),t.lineTo(e+o.bl,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o.bl),t.lineTo(e,n+o.tl),t.quadraticCurveTo(e,n,e+o.tl,n),t.closePath(),s&&t.fill(),a&&t.stroke()}(t,u-4,o-l/2-4,s+8,l+8,4,!0,!1),t.fillStyle=a),"justify"===c&&i<n.length-1&&e.length>1){const n=b-s,i=e.length-1,a=n/i;e.forEach((e,n)=>{t.font=Xo(r,e),t.fillText(e.text,u,o),u+=t.measureText(e.text).width+(n<i?a:0)})}else e.forEach(e=>{t.font=Xo(r,e),[...e.text].forEach(e=>{t.fillText(e,u,o),u+=t.measureText(e).width+y})})}),t.restore()}function Vo(t,e,n,r){let i="";for(let r=0;r<e.text.length;r++){const o=i+e.text[r];if(t.measureText(o).width>n)break;i=o}return{...e,text:i+("ellipsis"===r?"…":"")}}function Zo(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}(()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Co()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Co),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Co()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}})(),Co(),Fo="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Qo=[];function Jo(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(1!==i.x||1!==i.y?(t=(t-n.x)/i.x,e=(e-n.y)/i.y):(t-=n.x,e-=n.y),0!==r){const n=Math.cos(-r),i=Math.sin(-r),o=t*i+e*n;t=t*n-e*i,e=o}return{x:t+n.x,y:e+n.y}}function Ko(t,e,n={x:0,y:0},r=0,i={x:1,y:1}){if(t-=n.x,e-=n.y,0!==r){const n=Math.cos(r),i=Math.sin(r),o=t*i+e*n;t=t*n-e*i,e=o}return 1!==i.x||1!==i.y?{x:t*i.x+n.x,y:e*i.y+n.y}:{x:t+n.x,y:e+n.y}}function ts(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=Jo(t,e,n,r,i);return n&&(o.x-=n.x,o.y-=n.y),o}return Jo(t,e,n=n||this.rotatePoint,r,i)}function es(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:r=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,o=Ko(t,e,void 0,r+(this._delta?.theta??0),i);return n&&(o.x+=n.x,o.y+=n.y),o}n=n||this.rotatePoint;const{theta:o=0,tx:s=0,ty:a=0,sx:c=1,sy:u=1}=this._delta||{};if(0===o&&0===s&&0===a&&1===c&&1===u)return Ko(t,e,n,r,i);return Ko(t+s,e+a,{x:n.x+s,y:n.y+a},r+o,{x:i.x*c,y:i.y*u})}function ns(t,e,n){n=n||this.rootModel;const r=this.transcoordS2T(t,e,n);return Ko(r.x,r.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function rs(t,e,n){n=n||this.rootModel,Qo.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Qo.push(t);let r=this.transcoordS2P(t,e);for(let t=0;t<Qo.length;t++){const e=Qo[t],n=e.bounds;r.x+=n.left,r.y+=n.top,r=e.transcoordS2P(r.x,r.y)}return r}function is(t,e,n){n=n||this.rootModel,Qo.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Qo.push(t);let r={x:t,y:e};for(let t=Qo.length-1;t>=0;t--){const e=Qo[t];r=e.transcoordP2S(r.x,r.y);const n=e.bounds;r.x-=n.left,r.y-=n.top}return r}function os(t,e,n){const r=this.transcoordT2P(t,e,n);return this.transcoordP2S(r.x,r.y)}function ss(t,e,n){const r=this.rootModel,i=this.transcoordS2T(t,e,r);return n.transcoordT2S(i.x,i.y,r)}function as(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:r={x:0,y:0},scale:i={x:1,y:1},rotation:o=0}=n.model,s=Jo(t,e,r,o,i);return r&&(s.x-=r.x,s.y-=r.y),n===this?s:this.transcoordT2S(s.x,s.y,n)}function cs(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let r;if(r=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return r;const{translate:i={x:0,y:0},rotation:o=0,scale:s={x:1,y:1}}=n.model;return r=Ko(r.x,r.y,void 0,o+n._delta.theta,s),i&&(r.x+=i.x,r.y+=i.y),r}function us(t){const e=t.element,n=t.fillStyle,r=e.style;if(n)if("string"==typeof n)r.backgroundColor=n;else switch(n.type){case"pattern":if(r.backgroundImage="url("+n.image+")",r.backgroundColor="transparent",n.fitPattern?r.backgroundSize="100% 100%":n.width||n.height?r.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:r.backgroundSize="contain",n.fitPattern)r.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:o,color:s}=n;if(i&&(r.backgroundRepeat="no-repeat"),s&&(r.backgroundColor=s),o)switch(o){case"center":r.backgroundPosition="center center";break;case"left-top":r.backgroundPosition="left top";break;case"left-bottom":r.backgroundPosition="left bottom";break;case"right-top":r.backgroundPosition="right top";break;case"right-bottom":r.backgroundPosition="right bottom";break;case"left":r.backgroundPosition="left center";break;case"right":r.backgroundPosition="right center";break;case"top":r.backgroundPosition="center top";break;case"bottom":r.backgroundPosition="center bottom"}else t||e?r.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete r.backgroundPosition}break;case"gradient":r.background=function(t,e){const n=e.colorStops,r=e.gradientType;if(n instanceof Array&&n.length>0)switch(r){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:r}=t.bounds;switch(e){case"center":return[n/2,r/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,r];default:return[n,r]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else r.background="transparent"}const hs={x:1,y:1},ls={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function fs(t,e){let n=this.bounds,r=this.rotatePoint;const i=this.get("rotation"),o=this.get("scale");if(t){const r=t.call(e,n);r&&(n=r)}const{left:s,top:a,width:c,height:u}=n;let h=[{x:s,y:a},{x:s+c,y:a+u}];h=h.map(t=>Ko(t.x,t.y,r,i,o));let l=h[0],f=h[1];r={x:(l.x+f.x)/2,y:(l.y+f.y)/2},h=h.map(t=>Jo(t.x,t.y,r,i,o)),l=h[0],f=h[1],this.bounds={left:l.x,top:l.y,width:f.x-l.x,height:f.y-l.y}}function ds(t,e,n){let r=this.path,i=this.rotatePoint;t&&(r=t.call(n,r));let o=r.map(t=>{const e=this.toParent(t.x,t.y);return{...t,x:e.x,y:e.y}});if(e){const t=e.call(n,o);t&&(o=t)}const s={x:0,y:0};let a,c,u,h;r=o.map(t=>this.fromParent(t.x,t.y,s)),a=c=r[0].x,u=h=r[0].y;for(let t=1;t<r.length;t++){const e=r[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<u?u=e.y:e.y>h&&(h=e.y)}i={x:(a+c)/2,y:(u+h)/2},i=this.toParent(i.x,i.y,s),this.path=o.map(t=>{const e=this.fromParent(t.x,t.y,i);return{...t,x:e.x,y:e.y}})}const ps=new Map;let ys=null;function gs(){ys&&(ys(),ys=null)}function ms(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var bs=new class{add(t){var e;ms(t)&&!ps.has(t)&&(ps.set(t,0),e=t?.root,ys||(ys=H.subscribe(t=>{if(0===t)return;const e=[];for(const[n,r]of ps){if(!ms(n)){e.push(n);continue}const i=r+t;i>=n.retention?e.push(n):ps.set(n,i)}for(const t of e){ps.delete(t);try{t.disposed||t.removeSelf?.(!0)}catch(t){Zi("RetentionManager removeSelf failed:",t)}}0===ps.size&&gs()},{description:"retention timer",component:e,getTargets:()=>Array.from(ps.keys()),metadata:{get count(){return ps.size},get preview(){return Array.from(ps.entries()).slice(0,3).map(([t,e])=>({type:t?.state?.type,id:t?.state?.id??"-",retentionMs:t?.retention,remainingMs:Math.max(0,Math.round(t?.retention-e))}))}}})))}remove(t){ps.delete(t)&&0===ps.size&&gs()}touch(t){t&&ps.has(t)&&ps.set(t,0)}dispose(){gs(),ps.clear()}get length(){return ps.size}};const vs=function(t){return t};function xs(t){const e=t.indexOf("||");let n="",r="";-1!=e&&(n=t,r=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),o=i.slice(1);return{defaultValue:r,match:t,originText:n||t,target:i[0],accessor:o.length>0?function(t){return o.reduce((t,e)=>t?t[e]:void 0,t)}:vs}}function _s(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>xs(t))[0];if(n)return n.accessor(this.getState(n.target));const r=(e.match(/\${[^}]*}/)||[]).map(t=>xs(t))[0];if(r){const t=this.root.findById(r.target);return r.accessor(this.getState(t))}return t}function ws(t,e){if(!t)return;const n=String(t),r=e||wi,i=(n.match(/#{(\S*)}/gi)||[]).map(t=>xs(t)),o=(n.match(/\${[^}]*}/gi)||[]).map(t=>xs(t));if(0==i.length&&0==o.length)return n;let s=n;return i.forEach(t=>{const e=r(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)}),o.forEach(t=>{const e=this.root.findById(t.target),n=r(t.accessor(e&&e.data));s=s.replace(t.match,void 0===n?"":n)}),s}function ks(t,e,n){if(!t)return;const r=n||wi,i=String(t),o=(i.match(/#{[^}]*}/gi)||[]).map(t=>xs(t)),s=(i.match(/\${[^}]*}/gi)||[]).map(t=>xs(t));return 0!=o.length||0!=s.length?function(){let t=i;return o.forEach(n=>{const i=r(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===i?n.defaultValue||"":i)}),s.forEach(n=>{const i=e.root.findById(n.target),o=r(n.accessor(i&&i.data));t=t.replace(n.originText,void 0===o?n.defaultValue||"":o)}),t}:void 0}class Ms{constructor(){}static registerDecorator(t,e){Ms.constructors.set(t,e)}static create(t,e,n={},r){const i=Ms.constructors.get(t);if(!i)throw new Error(`unknown decorator type: ${t}`);return new i(r,e,n)}}function Ss(t,e){const n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r);if(!mt(t))return i;const o=bt(t,e,t.bulge);if(!o)return i;const s=Math.min(o.radius,i/2),a=2*Math.asin(s/o.radius);return o.radius*a}function zs(t,e){const n=t.path.slice();if(!n||!n.length)return void Zi("path should not be empty");let r=1;const i=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[r];)i.push(Ss(n[r-1],n[r])),r++;const o=i.reduce(function(t,e){return t+e},0);r=0;let s=0;do{s+=i[r++]}while(s/o<e);s-=i[--r];e=(e-s/o)*(o/i[r]);const a=n[r%n.length],c=n[(r+1)%n.length],{x:u,y:h}=function(t,e,n){if(mt(t)){const r=bt(t,e,t.bulge);if(r){let t=r.endAngle-r.startAngle;r.clockwise?t>0&&(t-=2*Math.PI):t<0&&(t+=2*Math.PI);const e=r.startAngle+n*t;return{x:r.cx+r.radius*Math.cos(e),y:r.cy+r.radius*Math.sin(e)}}}return{x:t.x+Math.round((e.x-t.x)*n),y:t.y+Math.round((e.y-t.y)*n)}}(a,c,e);return t.toScene(u,h)}function Es(t,e){return!1}function As({x:t,y:e},...n){const r=this.path,i=t,o=e;this.path=r.map(t=>({...t,x:t.x+i,y:t.y+o}))}function Ts(t){const e=t??this.center.x,{rotation:n}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-n),r&&"gradient"===r.type&&"linear"===r.gradientType){const t=ci(r);t.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({...t,x:2*e-t.x,y:t.y}))}function Os(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}function Is(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let r=t.width-e.width,i=t.height-e.height;r*n>i?i=r*n:r=i/n;let o=t.left-e.left,s=t.top-e.top;return 0!=o&&0!=s?(s=-i,o=-r):0!=o?o=-r:0!=s&&(s=-i),{left:e.left+o,top:e.top+s,width:e.width+r,height:e.height+i}}return t}function js(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function Ps(t){return zs(this,t||0)}function Rs(){const t=this.path;let e,n,r,i;e=n=t[0].x,r=i=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<e?e=s.x:s.x>n&&(n=s.x),s.y<r?r=s.y:s.y>i&&(i=s.y)}return{left:e,top:r,width:n-e,height:i-r}}function Cs(t){const e=this.bounds;if(Math.round(100*t.width)/100==Math.round(100*e.width)/100&&Math.round(100*t.height)/100==Math.round(100*e.height)/100&&Math.round(100*t.left)/100==Math.round(100*e.left)/100&&Math.round(100*t.top)/100==Math.round(100*e.top)/100)return;const n=0==e.width?1:t.width/e.width,r=0==e.height?1:t.height/e.height;this.path=this.path.map(i=>({...i,x:t.left+(i.x-e.left)*n,y:t.top+(i.y-e.top)*r}))}function Fs(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ns(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const e=this.center;if(Math.round(100*t.x)/100==Math.round(100*e.x)/100&&Math.round(100*t.y)/100==Math.round(100*e.y)/100)return;const n=t.x-e.x,r=t.y-e.y;this.path=this.path.map(t=>({...t,x:t.x+n,y:t.y+r}))}function Ds(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Ls(t){const{x:e,y:n,z:r}=t||{};this.center={x:e,y:n},isNaN(r)||this.setState("zPos",Number(r))}function $s(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function Us(t){const{x:e,y:n,z:r}=t;this.setState({rotationX:e,rotationY:n,rotation:-r})}function qs(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function Ws(t){const{width:e,height:n,depth:r}=t,{top:i,left:o}=this.bounds;this.bounds={top:i,left:o,width:e,height:n},this.setState("depth",r)}function Ys(){return Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Bs(t){Zi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Gs(){return this.path}function Xs(){return this.center}function Hs(){return this.nature.mutable}function Vs(){return this.nature.resizable&&!this.stuck}function Zs(){return this.nature.rotatable&&!this.stuck}Ms.constructors=new Map;const Qs={x:1,y:1};function Js(t,e,n){const{offsetX:r,offsetY:i,blur:o,color:s}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??Qs;t.shadowOffsetX=r*a.x*Po,t.shadowOffsetY=i*a.y*Po,t.shadowBlur=o*a.x*Po,t.shadowColor=s}function Ks(t){t.save(),this.prerender(t);const e=this.app,n=!0===t.__inHiddenSubtree;e?.isEditMode&&((function(t){const e=t?.app;if(!e?.isEditMode)return!1;const n=e.focusFilter;return!!(t.hidden||n&&!n(t))}(this)||n)&&(t.globalAlpha*=.5),this.hidden&&(t.__inHiddenSubtree=!0)),this.render(t),this.postrender(t),t.__inHiddenSubtree=n,t.restore()}function ta(t){const e=this.rotatePoint,{scale:n,rotation:r,shadow:i,alpha:o}=this.state,s=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(r||0)+this._delta.theta,{tx:u=0,ty:h=0}=this._delta,l=(o||1)-this._delta.fade;(u||h)&&t.translate(u,h),(1!=s||1!=a||c)&&(t.translate(e.x,e.y),1==s&&1==a||t.scale(s,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),l&&(t.globalAlpha=l),i&&Js(t,i,this)}function ea(t){}function na(t){this.drawText(t)}function ra(t,e){t(this)}function ia(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Zi(t)})}function oa(t){!this.textHidden&&this.text&&this.hasTextProperty&&Ho(t,this.textBounds,this.textLines(t),this.state)}function sa(t,e){Uo(t,e?{...this.state,...e}:this.state)}function aa(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(No(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function ca(){return this.get("strokeStyle")}function ua(t){this.set("strokeStyle",t)}function ha(){return this.getState("fillStyle")}function la(t){this.setState("fillStyle",t)}function fa(){return this.get("fontColor")}function da(t){this.set("fontColor",String(wi(t)))}function pa(){return this.getState("rotation")}function ya(t){this.setState("rotation",Number(wi(t)))}function ga(){return this.app.isEditMode?["decotag","data-spread"]:[]}function ma(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function ba(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function va(t){this.setState("hidden",t)}function xa(){return this.state.tag}function _a(t){this.setState("tag",t)}function wa(){}function ka(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function Ma(){const t=this.getState("text");return null==t?"":String(t)}function Sa(t){const{textWrap:e,supportMarkdown:n}=this.state;return Bo(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function za(){return Go(this.model)}function Ea(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Aa(){return this._text_substitutor||(this._text_substitutor=ks(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Ta(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,r,i,o,s,a,c,u,h,l,f,d=t.length,p=t.search(/[0-9\-\+#]/),y=p>0?t.substring(0,p):"",g=t.split("").reverse().join(""),m=g.search(/[0-9\-\+#]/),b=d-m,v=t.substring(b,b+1),x=b+("."===v||","===v?1:0),_=m>0?t.substring(x,d):"";if(n=(e="-"===(t=t.substring(p,x)).charAt(0)?-e:+e)<0?e=-e:0,r=t.match(/[^\d\-\+#]/g),i=".",o=r&&r[1]&&r[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),u=e.split("."),(!u[1]||u[1]&&u[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(o),t[0]=h.join(""),s=t[0]&&t[0].indexOf("0"),s>-1)for(;u[0].length<t[0].length-s;)u[0]="0"+u[0];else 0===+u[0]&&(u[0]="");if((e=e.split("."))[0]=u[0],c=h[1]&&h[h.length-1].length,c){for(l=e[0],g="",b=l.length%c,d=l.length,x=0;x<d;x++)g+=l.charAt(x),!((x-b+1)%c)&&x<d-c&&(g+=o);e[0]=g}return e[1]=t[1]&&e[1]?"."+e[1]:"",r=e.join(""),"0"!==r&&""!==r||(n=!1),f="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",y+(f+r)+_}(t,this.textSubstitutor()):this.textSubstitutor()}function Oa(t){delete this._text_substitutor;const e=wi(t);this.setState("text",null==e?"":String(e))}function Ia(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:r}=this.state;r||=0,t||=0,e||=0,n||=0;const{left:i,top:o,width:s,height:a}=this.bounds;return{left:i+e,top:o+t,width:Math.max(s-e-n,0),height:Math.max(a-t-r,0)}}function ja(){return 0}function Pa(){return!!this._textHidden}function Ra(t){this._textHidden=!!t,this.invalidate()}function Ca(){return!0}function Fa(t){return t}function Na(t){return Math.pow(t,2)}function Da(t){return 1-Math.sin(Math.acos(t))}function La(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function $a(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function Ua(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var qa={linear:Fa,quad:Na,circ:Da,back:La,bounce:$a,elastic:Ua},Wa=Object.freeze({__proto__:null,back:La,bounce:$a,circ:Da,default:qa,elastic:Ua,linear:Fa,quad:Na});class Ya{constructor(t,e){this._started=!1,this._unsub=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:r,ease:i}=this.config;let o;o="string"==typeof n?qa[n]:n,this.delta="out"===i?function(t,e){return function(n){return 1-t(1-n,e)}}(o,r):"inout"===i?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(o,r):o,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:r=0,onComplete:i}=this.config;this._started=!0;const o=this.config?.type??"animation";let s=0,a=0;const c=()=>H.simTime,u=()=>{if(!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(i);0==s&&(s=c(),this.client?.touch?.());const h=c()-s,l=Math.max((h-e)%(t+r),0)/t,f=r<=0&&a>l;if(a=l,l>=1||f){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(i),void(s=0);if(r>0)return this._unsub?.(),this._unsub=null,void(this._timeout=setTimeout(()=>{this._timeout=null,this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(()=>{this._timeout=null,this._started&&(this._unsub=H.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}}))},r/2)},r/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.()};this._unsub=H.subscribe(u,{description:`animation: ${o}`,component:this.client,metadata:{duration:t,delay:e,repeat:n,interval:r}})}stop(t){this._unsub&&(this._unsub(),this._unsub=null),this._timeout&&clearTimeout(this._timeout),this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const Ba={rotation:class extends Ya{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Ya{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let r=t*n;t<1/4?r*=-1:t<3/4?r-=2*e:r=n-r,this.client.delta?.("theta",r)}},heartbeat:class extends Ya{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let r;r=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:r,sy:r,sz:r})}},moving:class extends Ya{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends Ya{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let r={tx:0,ty:0};const i=this.client.delta("");i&&"object"==typeof i&&"tx"in i&&"ty"in i&&(r=i);const{tx:o,ty:s}=r,a=n.outline(t),{x:c,y:u}=this.client.center,h=this.client.toScene(c,u);this.client.delta({tx:a.x-h.x+o,ty:a.y-h.y+s})}},fade:class extends Ya{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,r=Math.max(Math.min(e,n,1),0),i=2*(Math.min(Math.max(e,n,1),1)-r);let o;o=t<.5?i*t:(1-t)*i,this.client.delta?.("fade",o)}},waypoint:class extends Ya{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,r=t.center,{x:i,y:o}=e.toScene(n.x,n.y),{x:s,y:a}=t.toScene(r.x,r.y);this._startX=i,this._startY=o,this._endX=s,this._endY=a;const c=this.config.yawOffset??Math.PI/2,u=Math.atan2(a-o,s-i)+c;this.client.location={x:i,y:o},this.client.setState("rotation",u),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};const Ga={gradation:function(t,e,n){const{subType:r,from:i,to:o,colors:s}=n;let a;switch(r){case"linear":default:a=e.createLinearGradient(i.x,i.y,o.x,o.y);break;case"radial":a=e.createRadialGradient(i.x,i.y,i.r,o.x,o.y,o.r)}s&&(s.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:Js};function Xa(t){return this._animate&&this._animate.stop(),this._animate=function(t){const{duration:e=1e3,easing:n,component:r,step:i=()=>{},onStart:o,onProgress:s,onComplete:a,options:c,repeat:u=!1,delta:h}=t;let l;l="string"==typeof h?Wa[h]:h||Fa,"out"===n?l=function(t,e){return function(n){return 1-t(1-n,e)}}(l,c):"inout"===n&&(l=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(l,c));let f=!1,d=null;return{start:function(){if(f)return this;if(r?.root?.app?.suppressAnimations)return this;f=!0,o&&o();let t=0;const n=()=>H.simTime;return d=H.subscribe(()=>{if(!f)return;if(r?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=n());const o=(n()-t)/e,a=u?o%1:Math.min(o,1);i(l(a,c)),s&&s(a),!(o>=1)||u&&f||(this.stop(),t=0)},{description:"animate()",component:r,metadata:{duration:e,repeat:u}}),this},stop:function(){return f=!1,d&&(d(),d=null),a&&a(),this}}}({component:this,...t}),this._animate}function Ha(t,e){return function(t,e,n){const r=Ga[n.type];r&&r(t,e,n)}(this,t,e)}const Va=100;function Za(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Va)/Va}return e}}function Qa(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*Va)/Va):delete t[e]:"object"==typeof n&&Qa(n)}return t}function Ja(...t){return JSON.stringify(this.hierarchy,Za,...t)}function Ka(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function tc(t){this.rootModel.closeScene(t)}function ec(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function nc(){this.parent&&this.parent.invalidate()}function rc(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function ic(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function oc(){return this.getState("data")}function sc(t){this.setState("data",t),this.touch()}function ac(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function cc(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function uc(){return Number(this.get("retention"))||0}function hc(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=function(t,e){const n=e.type?Ba[e.type]:void 0;return n?new n(t,e):null}(this,t.oncreate))}return this._animation}}function lc(){return!!this.animation?.started}function fc(t){this.animation&&(this.animation.started=t)}function dc(){}function pc(t,e,n,r){const i=e.get("class");if(!i)return!1;return(i.split(" ")||[]).indexOf(t.substr(1))>=0}function yc(t,e,n,r){return t==e.get("type")}function gc(t,e,n,r,i,o){return t(e,n,r,i)&&o.push(n),n.components&&n.components.forEach(n=>{gc(t,e,n,r,i,o)}),o}function mc(t,e,n,r){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function bc(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let r;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":r=pc;break;case"(":r=mc;break;default:r=yc}return gc(r,t,e,n,e,[])}function vc(t,...e){if(t(this,...e))return this}function xc(t,...e){return"string"==typeof t?bc(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function _c(t,e,n){if(!this.capturable||n?.(this))return!1;const r=this.fromParent(t,e);return this.contains(r.x,r.y)?this:void 0}function wc(t){return this.anchors.find(e=>e.name===t)}function kc(t){return!0}function Mc(t){return this._parent.getContext(t??this)}function Sc(){return this.isRoot()?this:this.parent&&this.parent.root}function zc(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Ec(){return this._parent}function Ac(t){this._parent=t}function Tc(){return this.nature.anchors||[]}function Oc(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Ic(){if(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))return!0;const t=this.app?.focusFilter;return!(!this.app?.isEditMode||!t||t(this))}function jc(){if(!1===this.get("capturable"))return!1;const t=this.app?.isEditMode;if(!t&&this.hidden)return!1;if(t){if(this.get("locked"))return!1;const t=this.app.focusFilter;if(t&&!t(this))return!1}return!0}function Pc(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Rc(){return this.app&&this.app.isViewMode&&this.state.origin||""}function Cc(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Fc(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Nc={},Dc={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Lc=[],$c=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Uc={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let qc=0;const Wc={};const Yc=new FinalizationRegistry(t=>{!function(t){qc--;let e=Wc[t];e||(e=Wc[t]={up:0,down:0}),e.down++}(t)});class Bc{static get nature(){return Dc}static register(t,e){if(!e)return Nc[t];Nc[t]=e}static types(){return Object.keys(Nc)}static get residents(){return Wc}static get residentsCount(){return qc}static registerDecorator(t,e){Ms.registerDecorator(t,e)}constructor(t,e){if(this._readyInvoked=!1,this._app=e,this._model=t||{},this._model.event&&"object"==typeof this._model.event&&!Array.isArray(this._model.event)&&!Array.isArray(this._model.eventHandlers)){const t=function(t){if(!t||"object"!=typeof t||Array.isArray(t))return[];const e={tap:"click",hover:"mouseenter",dblclick:"dblclick",longpress:"longpress"},n=[];for(const r of Object.keys(t)){const i=e[r];if(!i)continue;const o=t[r];if(o&&"object"==typeof o){if("script"===o.action){const t="string"==typeof o.value?o.value:o.value&&"object"==typeof o.value?o.value.script:"";t&&n.push({trigger:i,action:"script",code:t,target:o.target});continue}n.push({trigger:i,action:o.action,target:o.target,value:o.value,options:{emphasize:o.emphasize,restore:o.restore,pressed:o.pressed,...o.options??{}}})}}return n}(this._model.event);t.length>0&&(this._model.eventHandlers=t)}this._state={},this._delta=ci(Uc),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??!0))&&(this.animation.started=!0),this.clearCache(),bs.add(this),function(t){qc++;let e=Wc[t];e||(e=Wc[t]={up:0,down:0}),e.up++}(this._model.type),Yc.register(this,this._model.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}invokeReady(){if(!this._readyInvoked)return this._readyInvoked=!0,this.ready()}touch(){this.updatedAt=performance.now(),bs.touch(this)}clearCache(...t){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=ci(Uc))}dispose(){this.resetAnimation(),this.disposeMappings();const t=this.parent;t&&"function"==typeof t.removeItem&&-1!==t._items?.indexOf?.(this)&&t.removeItem(this),t?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&bs.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&bs.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get refid(){return this.get("refid")}get hierarchy(){const t=ci(this._model);return this.volatile.forEach(e=>{delete t[e]}),Qa(t)}get volatile(){return Lc}_applyProps(t,e,n){const r={},i={};let o=!1;const s=ci(e),a=this;if(Object.getOwnPropertyNames(s).forEach(function(e){const c=n.getBeforeVal(e),u=s[e];!n.sensitive&&function(t,e){return Dn(t,e)}(c,u)||(i[e]=c,r[e]=u,t[e]=u,n.clearState&&delete a._state[e],o=!0)}),o){this._cachedState=null;Object.keys(r).some(t=>!$c.has(t))&&this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(r,i),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,i),n.afterFillStyle&&n.afterFillStyle(r,i),r.hasOwnProperty("data")&&this.onchangeData(r,i),this.onchange&&this.onchange(r,i),this.trigger("change",r,i)}return this}contains(t,e){return Es.call(this,t,e)}move(t,...e){As.call(this,t,...e)}symmetryX(t){Ts.call(this,t)}symmetryY(t){Os.call(this,t)}adjustResize(t,e,n){return Is.call(this,t,e,n)}adjustRotation(t,e){return js.call(this,t,e)}outline(t){return Ps.call(this,t)}get bounds(){return Rs.call(this)}set bounds(t){Cs.call(this,t)}get center(){return Fs.call(this)}set center(t){Ns.call(this,t)}get location(){return Ds.call(this)}set location(t){Ls.call(this,t)}get rotate(){return $s.call(this)}set rotate(t){Us.call(this,t)}get dimension(){return qs.call(this)}set dimension(t){Ws.call(this,t)}get path(){return Ys.call(this)}set path(t){Bs.call(this,t)}get drawPath(){return Gs.call(this)}get rotatePoint(){return Xs.call(this)}get mutable(){return Hs.call(this)}get resizable(){return Vs.call(this)}get rotatable(){return Zs.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Ks.call(this,t)}prerender(t){ta.call(this,t)}render(t){ea.call(this,t)}postrender(t){na.call(this,t)}prepare(t,e){ra.call(this,t,e)}prepareIf(t){ia.call(this,t)}drawText(t){oa.call(this,t)}drawStroke(t,e){sa.call(this,t,e)}drawFill(t,e){aa.call(this,t,e)}get strokeStyle(){return ca.call(this)}set strokeStyle(t){ua.call(this,t)}get fillStyle(){return ha.call(this)}set fillStyle(t){la.call(this,t)}get fontColor(){return fa.call(this)}set fontColor(t){da.call(this,t)}get rotation(){return pa.call(this)}set rotation(t){ya.call(this,t)}get decorators(){return ga.call(this)}get decotag(){return ma.call(this)}get hidden(){return ba.call(this)}set hidden(t){va.call(this,t)}get tag(){return xa.call(this)}set tag(t){_a.call(this,t)}get appendum(){return wa.call(this)}set appendum(t){ka.call(this,t)}defaultTextSubstitutor(){return Ma.call(this)}textLines(t){return Sa.call(this,t)}get font(){return za.call(this)}get lineHeight(){return Ea.call(this)}get textSubstitutor(){return Aa.call(this)}get text(){return Ta.call(this)}set text(t){Oa.call(this,t)}get textBounds(){return Ia.call(this)}get textRotation(){return ja.call(this)}get textHidden(){return Pa.call(this)}set textHidden(t){Ra.call(this,t)}get hasTextProperty(){return Ca.call(this)}animate(t){return Xa.call(this,t)}effect(t,e){return Ha.call(this,t,e)}serialize(...t){return Ja.call(this,...t)}trim(){Ka.call(this)}closeScene(t){tc.call(this,t)}delta(t,e){return ec.call(this,t,e)}invalidate(){nc.call(this)}get value(){return rc.call(this)}set value(t){ic.call(this,t)}get data(){return oc.call(this)}set data(t){sc.call(this,t)}set tap(t){ac.call(this,t)}get mappings(){return cc.call(this)}get retention(){return uc.call(this)}get animation(){return hc.call(this)}get started(){return lc.call(this)}set started(t){fc.call(this,t)}get controls(){return dc.call(this)}findFirst(t,...e){return vc.call(this,t,...e)}findAll(t,...e){return xc.call(this,t,...e)}capture(t,e,n){return _c.call(this,t,e,n)}findAnchor(t){return wc.call(this,t)}isDescendible(t){return kc.call(this,t)}getContext(t){return Mc.call(this,t)}get root(){return Sc.call(this)}get rootModel(){return zc.call(this)}get parent(){return Ec.call(this)}set parent(t){Ac.call(this,t)}get anchors(){return Tc.call(this)}get scalable(){return Oc.call(this)}get stuck(){return Ic.call(this)}get capturable(){return jc.call(this)}get position(){return Pc.call(this)}get origin(){return Rc.call(this)}get offset(){return Cc.call(this)}get app(){return Fc.call(this)}drawEffect(t){jo.call(this,t)}prepareFill(t,e){Do.call(this,t,e)}prepareFillIf(t){Lo.call(this,t)}onchangeFill(t,e){$o.call(this,t,e)}drawImage(t,e,n,r,i,o){Io.call(this,t,e,n,r,i,o)}mutateBounds(t,e){fs.call(this,t,e)}mutatePath(t,e,n){ds.call(this,t,e,n)}access(t){return _s.call(this,t)}substitute(t,e){return ws.call(this,t,e)}onchangeMappings(t,e){Oo.call(this,t,e)}onchangeData(t,e){Eo.call(this,t,e)}buildMappings(){Ao.call(this)}executeMappings(t){zo.call(this,t)}disposeMappings(){To.call(this)}ondropfile(t,e){Zo.call(this,t,e)}transcoordS2P(t,e,n){return es.call(this,t,e,n)}transcoordP2S(t,e,n){return ts.call(this,t,e,n)}transcoordS2T(t,e,n){return rs.call(this,t,e,n)}transcoordT2P(t,e,n){return is.call(this,t,e,n)}transcoordT2S(t,e,n){return os.call(this,t,e,n)}transcoordS2TR(t,e,n){return ns.call(this,t,e,n)}transcoordS2O(t,e,n){return ss.call(this,t,e,n)}transcoordC2S(t,e,n){return as.call(this,t,e,n)}transcoordS2C(t,e,n){return cs.call(this,t,e,n)}toParent(t,e,n){return es.call(this,t,e,n)}fromParent(t,e,n){return ts.call(this,t,e,n)}toScene(t,e,n){return rs.call(this,t,e,n)}fromScene(t,e,n){return os.call(this,t,e,n)}toLocal(t,e,n){return as.call(this,t,e,n)}toGlobal(t,e,n){return cs.call(this,t,e,n)}toOther(t,e,n){return ss.call(this,t,e,n)}on(t,e,n){return Yi.call(this,t,e,n)}off(t,e,n){return Bi.call(this,t,e,n)}once(t,e,n){return Gi.call(this,t,e,n)}trigger(t,...e){return Xi.call(this,t,...e)}delegate_on(t){return Hi.call(this,t)}delegate_off(t){return Vi.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get unitScale(){return 1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}Bc.capabilities=[],Bc.requires3d=!1,Bc.union=function(t){let e=0,n=0,r=0,i=0,o=!1;return t.forEach(t=>{o?(e=Math.min(t.left,e),n=Math.min(t.top,n),r=Math.max(t.left+t.width,r),i=Math.max(t.top+t.height,i)):(e=t.left,n=t.top,r=t.left+t.width,i=t.top+t.height,o=!0)}),{left:e,top:n,width:r-e,height:i-n}},Bc.transcoordR=Jo,Bc.transcoordRR=Ko,Bc.createCanvas=Fo,Bc.memoize=function(t,e,n){const r=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!r?.get)return void Zi(`${String(e)} is not defined in ${t.constructor.name}`);const i=r.get,o={get:n?function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=Object.freeze(i.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?G.enabled&&G.cacheHit++:(G.enabled&&G.cacheMiss++,this.__cache__[e]=i.call(this)),this.__cache__[e]},configurable:!0};r.set&&(o.set=r.set),Object.defineProperty(t,e,o)},Bc.mixin=function t(e,n){if(n instanceof Array)n.forEach(n=>t(e,n));else{if(e.mixedIn=e.hasOwnProperty("mixedIn")?e.mixedIn:[],e.mixingIn=e.hasOwnProperty("mixingIn")?e.mixingIn:[],e.mixedIn.indexOf(n)>=0)return e;if(e.mixingIn.indexOf(n)>=0)throw new Error(`found cyclic dependencies between ${e.mixingIn}`);e.mixingIn.push(n),n.call(e),e.mixingIn.pop(),e.mixedIn.push(n)}return e},Bc.drawText=Ho,Bc.font=Go,Bc.textLines=Bo,Bc.drawStroke=Uo,Bc.drawFill=No,Bc.reposition=function(t){let{id:e,scale:n=hs,bold:r,italic:i,fontFamily:o="",textAlign:s,textBaseline:a,textOverflow:c,paddingTop:u,paddingBottom:h,paddingLeft:l,paddingRight:f,fontSize:d=Ro.FONT_SIZE,lineWidth:p=0,lineHeight:y,lineDash:g}=t.state;h||=0,u||=0,l||=0,f||=0;const m=t.state.class,{strokeStyle:b,rotation:v=0,fontColor:x,hidden:_}=t,{left:w,top:k,width:M,height:S}=t.bounds,z=t.element;if(z.hidden=!t.app?.isEditMode&&_,e&&(z.id=e),m&&(z.className=m),Object.assign(z.style,ls,{fontFamily:o,fontSize:d+"px",width:M+"px",height:S+"px",paddingTop:u+"px",paddingRight:f+"px",paddingBottom:h+"px",paddingLeft:l+"px",border:p+"px",borderColor:b,borderStyle:p>0?g||Ro.LINE_DASH:"",color:x,fontWeight:r?"bold":"",fontStyle:i?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:a,lineHeight:void 0===y?"":y+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:k+"px"}),us(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,r=e.offsetY??e.top??0,i=e.blur??e.blurSize??0,o=e.color??"transparent";t.element.style.boxShadow=`${n}px ${r}px ${i}px ${o}`}(t),t.isIn3DSpace())return;const E=t.delta(),A=(n&&n.x||1)*E.sx,T=(n&&n.y||1)*E.sy,O=(v||0)+E.theta,I=E.tx||0,j=E.ty||0;z.style.transform=`rotate(${O}rad) translate(${I}px, ${j}px) scale(${A}, ${T}) perspective(1px)`},Bc.RetentionManager=bs,Bc.template=function(t,e,n){var r=Tr.imports._.templateSettings||Tr;n&&nr(t,e,n)&&(e=void 0),t=zr(t),e=ir({},e,r,gr);var i=ir({},e.imports,r.imports,gr),o=yn(i),s=function(t,e){return dr(e,function(e){return t[e]})}(i,o);Ln(o,function(t){if(Pr.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,u=0,h=e.interpolate||Cr,l="__p += '",f=RegExp((e.escape||Cr).source+"|"+h.source+"|"+(h===vr?Rr:Cr).source+"|"+(e.evaluate||Cr).source+"|$","g"),d=Nr.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,function(e,n,r,i,o,s){return r||(r=i),l+=t.slice(u,s).replace(Fr,br),n&&(a=!0,l+="' +\n__e("+n+") +\n'"),o&&(c=!0,l+="';\n"+o+";\n__p += '"),r&&(l+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=s+e.length,e}),l+="';\n";var p=Nr.call(e,"variable")&&e.variable;if(p){if(Pr.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(c?l.replace(Or,""):l).replace(Ir,"$1").replace(jr,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=fr(function(){return Function(o,d+"return "+l).apply(void 0,s)});if(y.source=l,lr(y))throw y;return y},Bc.buildSubstitutor=ks,["rotatePoint","font","lineHeight","retention"].forEach(t=>Bc.memoize(Bc.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Bc.memoize(Bc.prototype,t,!0));const Gc=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function Xc(t){return class extends t{async ready(){await super.ready();const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=t[Y];null!=e&&n.set(String(e),t)}for(const[t,r]of n)if(!e.has(t)){try{this.removeItem(r,!0)}catch{}try{r?.dispose?.()}catch{}}for(const[t,r]of e){if(n.has(t))continue;if(null==r.itemId)continue;const e=this._createItemFromRecord(r);if(e){e[Y]=t;try{this.handoverIn(e)}catch{}}}for(const[t,r]of e){const e=n.get(t);if(e&&(r.itemState&&"function"==typeof e.setState))try{e.setState(r.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,r=[];for(const t of this._items){const e=t[Y];null!=e?n.set(String(e),t):r.push(t)}for(const r of t){const t=n.get(r)??null;e.push(this._slotRecordOf(r,t))}for(const t of r)e.push(this._slotRecordOf("",t));for(const[r,i]of n)t.includes(r)||e.push(this._slotRecordOf(r,i));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const r of n)r in e&&void 0!==e[r]&&(t[r]=e[r]);return Object.keys(t).length>0?t:void 0}const r={};for(const t of Object.keys(e))Gc.has(t)||t.startsWith("_")||(r[t]=e[t]);return Object.keys(r).length>0?r:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=Bc.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}function Hc(t,e,n){return n?{code:t,path:e,params:n}:{code:t,path:e}}const Vc="holder",Zc=t=>"number"==typeof t&&Number.isFinite(t),Qc=t=>Zc(t)&&t>0,Jc=t=>Number.isSafeInteger(t)&&t>0;function Kc(t,e,n){const r=t?.allowed;if(r&&"object"==typeof r)for(const t of["width","depth","height"])Qc(r[t])||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${e}.allowed.${t}`));else n.push(Hc("OBJECT_REQUIRED",`${e}.allowed`));void 0===t?.stackLimit||Jc(t.stackLimit)||t.stackLimit===1/0||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${e}.stackLimit`)),void 0===t?.rotation||Zc(t.rotation)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${e}.rotation`)),void 0===t?.accepts||Array.isArray(t.accepts)||n.push(Hc("ARRAY_REQUIRED",`${e}.accepts`))}function tu(t,e={}){const n=[];if(!t||!Array.isArray(t.tiers)||0===t.tiers.length)return[Hc("TIERS_REQUIRED","tiers")];const r=e.anchors?new Set(e.anchors):null,i=new Set;return t.tiers.forEach((t,e)=>{const o=`tiers[${e}]`;if(!t||"object"!=typeof t)return void n.push(Hc("OBJECT_REQUIRED",o));if(Jc(t.tierNo)?i.has(t.tierNo)?n.push(Hc("TIER_NUMBER_DUPLICATE",`${o}.tierNo`,{tierNo:t.tierNo})):i.add(t.tierNo):n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.tierNo`)),"string"==typeof t.anchorId&&t.anchorId.trim()?r&&!r.has(t.anchorId)&&n.push(Hc("ANCHOR_UNKNOWN",`${o}.anchorId`,{anchorId:t.anchorId})):n.push(Hc("ANCHOR_REQUIRED",`${o}.anchorId`)),["ON","IN","HANG"].includes(t.mount)||n.push(Hc("MOUNT_INVALID",`${o}.mount`)),t.position&&"object"==typeof t.position)for(const e of["x","y","z"])Zc(t.position[e])||n.push(Hc("FINITE_NUMBER_REQUIRED",`${o}.position.${e}`));else n.push(Hc("OBJECT_REQUIRED",`${o}.position`));Zc(t.rotation)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${o}.rotation`));const s=t.layout;switch(s?.pattern){case"SINGLE":Kc(s.slot,`${o}.layout.slot`,n);break;case"ROW":Jc(s.count)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.count`)),Qc(s.pitch)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch`)),"X"!==s.axis&&"Z"!==s.axis&&n.push(Hc("AXIS_INVALID",`${o}.layout.axis`)),Kc(s.slot,`${o}.layout.slot`,n);break;case"GRID":Jc(s.rows)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.rows`)),Jc(s.cols)||n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${o}.layout.cols`)),Qc(s.pitch?.x)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.x`)),Qc(s.pitch?.z)||n.push(Hc("POSITIVE_NUMBER_REQUIRED",`${o}.layout.pitch.z`)),Kc(s.slot,`${o}.layout.slot`,n);break;case"CUSTOM":{if(!Array.isArray(s.slots)){n.push(Hc("ARRAY_REQUIRED",`${o}.layout.slots`));break}s.slots.length||n.push(Hc("SLOTS_REQUIRED",`${o}.layout.slots`));const t=new Set;s.slots.forEach((e,r)=>{const i=`${o}.layout.slots[${r}]`;Jc(e?.slotNo)?t.has(e.slotNo)?n.push(Hc("SLOT_NUMBER_DUPLICATE",`${i}.slotNo`,{slotNo:e.slotNo})):t.add(e.slotNo):n.push(Hc("POSITIVE_INTEGER_REQUIRED",`${i}.slotNo`)),Zc(e?.offset?.x)&&Zc(e?.offset?.z)||n.push(Hc("FINITE_NUMBER_REQUIRED",`${i}.offset`)),Kc(e,i,n)});break}default:n.push(Hc("PATTERN_INVALID",`${o}.layout.pattern`))}}),n}function eu(t,e=""){const n=[],r=(t,e)=>{if("number"!=typeof t||Number.isFinite(t)){if(Array.isArray(t))t.forEach((t,n)=>r(t,`${e}[${n}]`));else if(t&&"object"==typeof t)for(const[n,i]of Object.entries(t))r(i,e?`${e}.${n}`:n)}else n.push(Hc("NOT_PERSISTABLE",e,{value:String(t)}))};return r(t,e),n}function nu(t){switch(t.pattern){case"SINGLE":return 1;case"ROW":return t.count;case"GRID":return t.rows*t.cols;case"CUSTOM":return t.slots.length}}function ru(t){return"CUSTOM"===t.pattern?t.slots.map(t=>t.slotNo).sort((t,e)=>t-e):Array.from({length:nu(t)},(t,e)=>e+1)}function iu(t,e,n,r,i="ROW_MAJOR"){switch(i){case"ROW_MAJOR":return(n-1)*e+r;case"COL_MAJOR":return(r-1)*t+n;case"SERPENTINE_ROW":return(n-1)*e+(n%2==1?r:e-r+1);case"SERPENTINE_COL":return(r-1)*t+(r%2==1?n:t-n+1)}}function ou(t,e,n,r="ROW_MAJOR"){const i=n-1;switch(r){case"ROW_MAJOR":return{r:Math.floor(i/e)+1,c:i%e+1};case"COL_MAJOR":return{r:i%t+1,c:Math.floor(i/t)+1};case"SERPENTINE_ROW":{const t=Math.floor(i/e)+1,n=i%e+1;return{r:t,c:t%2==1?n:e-n+1}}case"SERPENTINE_COL":{const e=Math.floor(i/t)+1,n=i%t+1;return{r:e%2==1?n:t-n+1,c:e}}}}const su=(t,e)=>e&&0!==t?-t:t;function au(t,e,n={}){const r=t?.tiers?.find(t=>t?.tierNo===e?.tier);if(!r||!Jc(e.slot))return null;const i=r.layout;let o,s,a;switch(i.pattern){case"SINGLE":if(1!==e.slot)return null;o=i.slot,s={x:0,z:0};break;case"ROW":{if(e.slot>i.count)return null;const t=su((e.slot-1-(i.count-1)/2)*i.pitch,"MAX"===i.origin);o=i.slot,s="X"===i.axis?{x:t,z:0}:{x:0,z:t};break}case"GRID":{if(e.slot>i.rows*i.cols)return null;const{r:t,c:n}=ou(i.rows,i.cols,e.slot,i.order),r=i.origin??{x:"MIN",z:"MIN"};o=i.slot,s={x:su((n-1-(i.cols-1)/2)*i.pitch.x,"MAX"===r.x),z:su((t-1-(i.rows-1)/2)*i.pitch.z,"MAX"===r.z)};break}case"CUSTOM":{const t=i.slots.find(t=>t.slotNo===e.slot);if(!t)return null;o=t,s={...t.offset},a=t.name;break}}return{tier:r.tierNo,slotNo:e.slot,name:a,anchorId:r.anchorId,mount:r.mount,tierPosition:{...r.position},tierRotation:r.rotation,offset:s,allowed:{...o.allowed},accepts:o.accepts?[...o.accepts]:void 0,stackLimit:o.stackLimit??n.defaultStackLimit??1,rotation:o.rotation??0}}function cu(t){return`t${t.tier}_s${t.slot}`}function uu(t){const e="string"==typeof t?/^t(\d+)_s(\d+)$/.exec(t):null;return e?{tier:Number(e[1]),slot:Number(e[2])}:null}function*hu(t){for(const e of t?.tiers??[])for(const t of ru(e.layout))yield{tier:e.tierNo,slot:t}}function lu(t,e,n){if(!n)return{x:t,z:e};const r=n*Math.PI/180,i=Math.cos(r),o=Math.sin(r),s=t=>Math.round(1e9*t)/1e9;return{x:s(t*i+e*o),z:s(-t*o+e*i)}}function fu(t){const e=lu(t.offset.x,t.offset.z,t.tierRotation);return{position:{x:t.tierPosition.x+e.x,y:t.tierPosition.y,z:t.tierPosition.z+e.z},rotation:t.tierRotation+t.rotation}}const du=.05,pu=t=>!!t&&Qc(t.width)&&Qc(t.depth)&&Qc(t.height);function yu(t,e){const n=e*Math.PI/180,r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),o=t=>Math.round(1e9*t)/1e9;return{width:o(t.width*r+t.depth*i),depth:o(t.width*i+t.depth*r)}}function gu(t,e,n=0,r=.05){if(!pu(t))return null;if(!Zc(n)||!Zc(r)||r<0||r>=1)return null;const i=yu(t,e.rotation),o=Math.min(1,Math.min(e.allowed.width/i.width,e.allowed.depth/i.depth)*(1-r)),s=t.height*o;return{position:{x:0,y:("HANG"===e.mount?-1:1)*(n+s/2),z:0},rotation:0,scale:o}}function mu(t,e,n=0,r=.05){const i=gu(t,e,n,r);if(!i)return null;const o=fu(e);return{position:{x:o.position.x,y:o.position.y+i.position.y,z:o.position.z},rotation:o.rotation,scale:i.scale}}function bu(t,e,n=.05){let r=0;return t.map(t=>{const i=t?mu(t,e,r,n):null;return i&&(r+=t.height*i.scale),i})}const vu=1e-6;function xu(t,e){const n=fu(t),r=t.allowed.width/2,i=t.allowed.depth/2,o=[[-r,-i],[r,-i],[r,i],[-r,i]].map(([t,e])=>{const r=lu(t,e,n.rotation);return{x:n.position.x+r.x,z:n.position.z+r.z}}),s=lu(1,0,n.rotation),a=lu(0,1,n.rotation),c="HANG"===t.mount?-1:1,u=[n.position.y,n.position.y+c*t.allowed.height],h=o.map(t=>t.x);return{tierIndex:e,tier:t.tier,slot:t.slotNo,corners:o,axes:[s,a],y0:Math.min(...u),y1:Math.max(...u),minX:Math.min(...h),maxX:Math.max(...h)}}function _u(t,e){for(const n of[...t.axes,...e.axes]){const r=t.corners.map(t=>t.x*n.x+t.z*n.z),i=e.corners.map(t=>t.x*n.x+t.z*n.z);if(Math.min(Math.max(...r),Math.max(...i))-Math.max(Math.min(...r),Math.min(...i))<=vu)return!1}return!0}function wu(t,e={}){const n=[],r=new Map;t.tiers.forEach((e,n)=>{const i=r.get(e.anchorId)??[];r.set(e.anchorId,i);for(const r of ru(e.layout))i.push(xu(au(t,{tier:e.tierNo,slot:r}),n))});for(const[t,i]of r){const r=e.anchorFaces?.[t];if(r)for(const t of i)t.corners.some(t=>Math.abs(t.x)-r.width/2>vu||Math.abs(t.z)-r.depth/2>vu)&&n.push({code:"SLOT_OUTSIDE_ANCHOR",path:`tiers[${t.tierIndex}]`,params:{tier:t.tier,slot:t.slot}});else n.push({code:"ANCHOR_SPACE_UNKNOWN",path:"tiers",params:{anchorId:t}});const o=[...i].sort((t,e)=>t.minX-e.minX);for(let t=0;t<o.length;t++){const e=o[t];for(let r=t+1;r<o.length&&o[r].minX<e.maxX-vu;r++){const t=o[r];if(Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)<=vu)continue;if(!_u(e,t))continue;const[i,s]=e.tierIndex<t.tierIndex||e.tierIndex===t.tierIndex&&e.slot<t.slot?[e,t]:[t,e];n.push({code:"SLOT_OVERLAP",path:`tiers[${s.tierIndex}]`,params:{tier:s.tier,slot:s.slot,otherTier:i.tier,otherSlot:i.slot}})}}}return n}function ku(t,e,n=[],r={}){if(!t)return{verdict:"NG",reasons:["SLOT_NOT_FOUND"]};const i=r.normalizeType??(t=>null==t?"":String(t)),o=[];let s=!1;if(t.accepts){const n=i(e.type);n?t.accepts.map(i).includes(n)||o.push("TYPE_NOT_ACCEPTED"):s=!0}if(n.length+1>t.stackLimit&&o.push("STACK_LIMIT_EXCEEDED"),pu(e.dims)){const r=yu(e.dims,t.rotation);if(r.width>t.allowed.width&&o.push("WIDTH_EXCEEDED"),r.depth>t.allowed.depth&&o.push("DEPTH_EXCEEDED"),n.every(t=>pu(t.dims))){n.reduce((t,e)=>t+e.dims.height,e.dims.height)>t.allowed.height&&o.push("HEIGHT_EXCEEDED")}else s=!0}else s=!0;return o.length?{verdict:"NG",reasons:s?[...o,"SPEC_UNKNOWN"]:o}:s?{verdict:"UNKNOWN",reasons:["SPEC_UNKNOWN"]}:{verdict:"OK",reasons:[]}}const Mu=[{id:"__default__",maxCount:1/0}];function Su(t){const e={id:cu({tier:t.tier,slot:t.slotNo}),maxCount:t.stackLimit};return t.accepts&&(e.accepts=[...t.accepts]),e}function zu(t,e){const n=e?.state?.type??e?.type;return t.accepts?!!n&&t.accepts.includes(n):!t.allowedTypes?.length||!!n&&t.allowedTypes.includes(n)}function Eu(t){var e;return e=class extends t{get slotLayout(){}get slots(){const t=this.slotLayout;if(!t)return[];const e=[];for(const n of hu(t)){const r=au(t,n);r&&e.push(Su(r))}return e}slotById(t){const e=this.slotLayout;if(e){const n=uu(t),r=n?au(e,n):null;return r?Su(r):null}return this.slots.find(e=>e.id===t)??null}slotSeatTransform(t,e,n=0,r){const i=this.slotLayout,o=i?uu(t):null,s=o?au(i,o):null,a=s?mu(e,s,n,r):null;return a?{...a,anchorId:s.anchorId}:null}get arrangementStrategy(){return p}canReceive(t,e){const n=null!==(void 0!==e?.slotId?this._slotIfAvailable(this.slotById(e.slotId),t):this.findSlot(t));return K.log({role:"target",contract:"canReceive",component:this,args:{carrier:U(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:Mu;for(const n of e){if(!zu(n,t))continue;const e=n.maxCount??this.arrangementStrategy.capacity(n),r=this._countOccupied(n.id);if(!(r>=e))return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:{slotId:n.id,occupied:r,max:e}}),n}return K.log({role:"target",contract:"findSlot",component:this,args:{carrier:U(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const n=this._realObject?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new w;n.getWorldQuaternion(r);const i=new w(e.x,e.y,e.z,e.w);return r.clone().multiply(i)}deliveryWorldPosition(t){const e=this._realObject,n=e?.object3d;if(!n)return;n.updateWorldMatrix(!0,!1);const r=new k;n.getWorldPosition(r);const i=this._receivingSurfaceLocalY();if(null!==i){const t=new k(0,i,0);return n.localToWorld(t),{x:r.x,y:t.y,z:r.z}}return{x:r.x,y:r.y,z:r.z}}attachPointFor(t){const e=t?.[Y];if(!e)return null;const n=this.slots.find(t=>t.id===e);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,r=n?n.state??{}:t??{},i={width:Number(r.width)||0,height:Number(r.height)||0,depth:Number(r.depth)||0},o=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!o)return null;const s=e.index??this._countOccupied(o.id),a=e.occupantCount??s,c=this.arrangementStrategy.positionAt(s,o,a,n??{state:{...i}});if(!c)return null;const u=Number(this.state?.width)||0,h=Number(this.state?.height)||0,l=c.x+i.width/2-u/2,f=c.y+i.height/2-h/2,d=this._realObject,p=d?.placementMode??"floor",y="space"===p?0:"inverted"===p?-i.depth/2:i.depth/2,g=this._receivingSurfaceLocalY();let m;m=null!==g?g+y:o.localPosition&&Number.isFinite(o.localPosition.z)?o.localPosition.z+y:y-(d?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??i,o)??void 0;return b?{position:{x:l,y:m,z:f},rotation:b}:{position:{x:l,y:m,z:f}}}_zPosFromSeatY(t,e,n){const r=this._realObject,i=r?.receivingSurfaceY??0,o=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===i&&!o)return null;const s=Number(e)||0,a=r?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-s/2:s/2)+(r?.geometricOffsetY??0)-i}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_slotIfAvailable(t,e){if(!t||!zu(t,e))return null;const n=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<n?t:null}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[Y]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[Y]===t).length:0}},e.__hasCapacity=!0,e}function Au(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return[];const s="number"==typeof t.rotation?t.rotation:0,a=Math.cos(s),c=Math.sin(s),u=n+i/2,h=r+o/2,l="inbound"===e?-1:1;return[{lx:-i/2,lz:0,odx:-1,odz:0},{lx:i/2,lz:0,odx:1,odz:0},{lx:0,lz:-o/2,odx:0,odz:-1},{lx:0,lz:o/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:u+e*a-n*c,z:h+e*c+n*a}),direction:{x:l*(t.odx*a-t.odz*c),z:l*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?o/2:i/2}})}function Tu(t,e){const n=t.left??0,r=t.top??0,i=t.width??0,o=t.height??0;if(i<=0||o<=0)return{inbounds:[],outbounds:[]};const s="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&i<o,u=n+i/2,h=r+o/2,l=c?o/2:i/2,f=c?0:1,d=c?1:0,p=Math.cos(s),y=Math.sin(s),g=(t,e)=>({x:u+t*p-e*y,z:h+t*y+e*p}),m=c?{lx:0,lz:-l}:{lx:-l,lz:0},b=c?{lx:0,lz:l}:{lx:l,lz:0},v=g(m.lx,m.lz),x=g(b.lx,b.lz),_={x:f*p-d*y,z:f*y+d*p},w=Math.hypot(_.x,_.z)||1,k={x:_.x/w,z:_.z/w},M={x:-k.x,z:-k.z},S=(c?i:o)/2;return a?{inbounds:[{worldPos:x,direction:M,halfSpan:S}],outbounds:[{worldPos:v,direction:M,halfSpan:S}]}:{inbounds:[{worldPos:v,direction:k,halfSpan:S}],outbounds:[{worldPos:x,direction:k,halfSpan:S}]}}function Ou(t){const e=t.left??0,n=t.top??0,r=t.width??0,i=t.height??0;if(r<=0||i<=0)return null;const o="number"==typeof t.rotation?t.rotation:0,s="vertical"===t.orientation||"horizontal"!==t.orientation&&r<i,a=e+r/2,c=n+i/2,u=s?i/2:r/2,h=Math.cos(o),l=Math.sin(o),f=(t,e)=>({x:a+t*h-e*l,z:c+t*l+e*h});return{start:s?f(0,-u):f(-u,0),end:s?f(0,u):f(u,0)}}function Iu(t){const e=t.cx??0,n=t.cy??0,r=Math.abs(t.rx??100),i=Math.abs(t.ry??100),o=t.ratio??50,s=(r+r*o/100)/2,a=(i+i*o/100)/2,c=t.startAngle??0,u=t.endAngle??Math.PI/2,h="reverse"===t.status;if(r<=0||i<=0)return{inbounds:[],outbounds:[]};const l={x:e+s*Math.sin(c),z:n-a*Math.cos(c)},f={x:e+s*Math.sin(u),z:n-a*Math.cos(u)},d={x:Math.cos(c),z:Math.sin(c)},p={x:Math.cos(u),z:Math.sin(u)};return h?{inbounds:[{worldPos:f,direction:{x:-p.x,z:-p.z}}],outbounds:[{worldPos:l,direction:{x:-d.x,z:-d.z}}]}:{inbounds:[{worldPos:l,direction:d}],outbounds:[{worldPos:f,direction:p}]}}function ju(t){const e=Tu(t),n=e.outbounds[0];if(!n)return{inbounds:Au(t,"inbound"),outbounds:[]};const r=Au(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,r=t.worldPos.z-n.worldPos.z;return Math.hypot(e,r)>1}),i=n.direction,o=[];for(const t of r){const e=t.direction.x*i.x+t.direction.z*i.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+i.x,r=t.direction.z+i.z,s=Math.hypot(n,r)||1;o.push({worldPos:t.worldPos,direction:{x:n/s,z:r/s},halfSpan:t.halfSpan})}return{inbounds:[...r,...o],outbounds:e.outbounds}}function Pu(t,e,n={}){const r=n.distance??5,i=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<i)return!1;const o=t.worldPos.x-e.worldPos.x,s=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,i=t.direction.z;if(Math.abs(o*n+s*i)>r)return!1;const a=Math.abs(o*-i+s*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(o,s)<=r}function Ru(t,e,n,r=0){const i=n.width??0,o=n.height??0;if(i<=0||o<=0)return!1;const s=(n.left??0)+i/2,a=(n.top??0)+o/2,c="number"==typeof n.rotation?n.rotation:0,u=Math.cos(-c),h=Math.sin(-c),l=t-s,f=e-a,d=l*u-f*h,p=l*h+f*u;return Math.abs(d)<=i/2+r&&Math.abs(p)<=o/2+r}function Cu(t,e,n){const r=n.width??0,i=n.height??0;if(r<=0||i<=0)return 1/0;const o=(n.left??0)+r/2,s=(n.top??0)+i/2;let a=t.x-o,c=t.z-s,u=e.x,h=e.z;const l="number"==typeof n.rotation?n.rotation:0;if(0!==l){const t=Math.cos(-l),e=Math.sin(-l),n=a*e+c*t,r=u*e+h*t;a=a*t-c*e,c=n,u=u*t-h*e,h=r}const f=r/2,d=i/2;let p=-1/0,y=1/0;if(Math.abs(u)<1e-9){if(a<-f||a>f)return 1/0}else{const t=(-f-a)/u,e=(f-a)/u;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-d||c>d)return 1/0}else{const t=(-d-c)/h,e=(d-c)/h;p=Math.max(p,Math.min(t,e)),y=Math.min(y,Math.max(t,e))}return y<p?1/0:p>=0?p:y>=0?Math.min(-p,y):-y}function Fu(t,e,n,r=6){return!!Ru(t.worldPos.x,t.worldPos.z,e,r)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function Nu(t,e,n){return t.outbounds.map(t=>{const r=[];for(const i of e){let e=null;for(const r of i.topology.inbounds){if(!Pu(t,r,n))continue;const i=t.worldPos.x-r.worldPos.x,o=t.worldPos.z-r.worldPos.z,s=Math.hypot(i,o);(null===e||s<e)&&(e=s)}if(null===e&&i.bounds){const r=i.topology.outbounds[0]?.direction,o=!(i.topology.outbounds&&i.topology.outbounds.length)?n?.sinkMargin??30:6;if(Fu(t,i.bounds,r,o)){const n=Cu(t.worldPos,t.direction,i.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(i.bounds.left??0)+(i.bounds.width??0)/2,r=(i.bounds.top??0)+(i.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-r)+1e3}}}null!==e&&r.push({id:i.id,dist:e})}return 0===r.length?null:(r.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),r[0].id)})}function Du(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const r=new Map,i=new Set;for(const n of t){const o=t.filter(t=>t.id!==n.id),s=Nu(n.topology,o,e);r.set(n.id,s);for(const t of s)null!=t&&i.add(t)}const o=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const o=r.get(t)??[];o.includes(e)||(o.push(e),r.set(t,o),i.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])o(e.id,t);for(const t of e.links.upstream??[])o(t,e.id)}const s=new Set,a=new Set;for(const e of t){(r.get(e.id)??[]).some(t=>null!=t)||s.add(e.id),i.has(e.id)||a.add(e.id)}return{nodes:n,out:r,sinks:s,sources:a}}function Lu(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const r=new Set([e]);for(const i of function(t,e,n){const r=n.get(e);if(r)return r;const i=new Set,o=[e],s=new Set([e]);for(;o.length;){const e=o.shift();for(const n of t.out.get(e)??[])null!=n&&(i.add(n),s.has(n)||(s.add(n),o.push(n)))}return n.set(e,i),i}(t,e,n))r.add(i);return r})}function $u(t,e,n,r){return e===n?0:function(t,e,n){const r=n.get(e);if(r)return r;const i=new Map([[e,0]]),o=[e];for(;o.length;){const e=o.shift(),n=i.get(e);for(const r of t.out.get(e)??[])null==r||i.has(r)||(i.set(r,n+1),o.push(r))}return n.set(e,i),i}(t,e,r).get(n)??1/0}function Uu(t,e,n){const r=t.out.get(e)??[],i=new Map,o=[];for(let e=0;e<r.length;e++){const s=r[e];if(null==s)continue;const a=s===n?0:$u(t,s,n,i);a!==1/0&&o.push({i:e,hops:1+a})}return o.sort((t,e)=>t.hops-e.hops||t.i-e.i),o.map(t=>t.i)}function qu(t,e,n){const r=Uu(t,e,n);return r.length?r[0]:-1}function Wu(t,e,n){return e===n||Uu(t,e,n).length>0}function Yu(t,e){const n=new Set;for(const r of Lu(t,e))for(const e of r)t.sinks.has(e)&&n.add(e);return n}function Bu(t,e,n){return Gu(t,e,n).map(t=>t.index)}function Gu(t,e,n){const r=n instanceof Set?n:new Set(n);if(0===r.size)return[];const i=t.out.get(e)??[],o=new Map,s=[...r].sort(),a=[];for(let e=0;e<i.length;e++){const n=i[e];if(null==n)continue;let r=1/0,c="";for(const e of s){const i=1+(n===e?0:$u(t,n,e,o));i<r&&(r=i,c=e)}r!==1/0&&a.push({index:e,hops:r,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Xu(t,e={}){const n=[],r=e.loopCapableIds??new Set,i=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const r=t.nodes.get(e);if(!r||!r.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(i.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const o=function(t){const e=[],n=[...t.nodes.keys()].sort(),r=new Set,i=[],o=new Set,s=n=>{r.add(n),i.push(n),o.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(o.has(a)){const t=i.indexOf(a),n=i.slice(t),r=n.indexOf([...n].sort()[0]),o=[...n.slice(r),...n.slice(0,r)],s=o.join("→");e.some(t=>t.join("→")===s)||e.push(o)}else r.has(a)||s(a);i.pop(),o.delete(n)};for(const t of n)r.has(t)||s(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of o){t.some(t=>r.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const s=e.routingWeights;if(s)for(const[t,e]of[...s].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...i].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Hu(t,e){if(!t)return[];const n=[],r=new Set,i=t=>{if(!t||r.has(t))return;if(r.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,r=t.refid??t.state?.refid,i="string"==typeof e&&e.length>0?e:null!=r?String(r):void 0;if(i)try{const e=t.getSegmentTopology(),r=t.state??{},o={left:r.left,top:r.top,width:r.width,height:r.height,rotation:r.rotation};e&&n.push({id:i,topology:e,bounds:o})}catch{}}const o=t?.components;if(Array.isArray(o))for(const t of o)i(t)};return i(t),n}function Vu(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const r=t.getSegmentTopology();if(!r||0===r.outbounds.length)return null;const i=Nu(r,Hu(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of i)if(t)return t;return null}function Zu(t){return!!t&&"function"==typeof t.routingConstraints}function Qu(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Ju(t,e=16){const n=[],r=t.parent??t.rootModel??t.root;if(!r)return n;const i=Vu(t);if(!i)return n;const o=eh(r,i);if(!o)return n;const s=[{segment:o,accumulated:{},pathIds:[i],visited:new Set([i])}];for(;s.length>0;){const t=s.shift();if(t.pathIds.length>e)continue;const i=Zu(t.segment)?t.segment.routingConstraints():null;if(i&&i.length>0)for(const e of i)for(const i of e.candidates){const o=Ku(t.accumulated,i);if(!o)continue;const a=th(t.segment,e.portId,r);a&&!t.visited.has(a.state?.id??"")?s.push({segment:a,accumulated:o,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:o,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Qu(t.segment)){const e=t.segment.acceptedCarrierData(),r=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:r});else for(const i of e){const e=Ku(t.accumulated,i);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:r})}continue}const e=Vu(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const i=eh(r,e);if(!i)continue;s.push({segment:i,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function Ku(t,e){const n={...t};for(const[t,r]of Object.entries(e)){if(t in n&&n[t]!==r)return null;n[t]=r}return n}function th(t,e,n){if("straight"===e&&t.state?.downstreamRef)return eh(n,t.state.downstreamRef);const r=eh(n,e);if(r)return r;const i=Vu(t);return i?eh(n,i):null}function eh(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,r=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const i=t.components;if(Array.isArray(i))for(const t of i){const e=r(t);if(e)return e}return null};return r(t)}function nh(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function rh(t,e,n=5,r=[],i=n){const o=t.length,s=new Array(o).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,u=[],h=new Map,l=[],f=new Map;for(const t of r){const e=Array.isArray(t),n=e?t:t.positions,r=e?void 0:t.kind;if(!n.length)continue;const i=u.length;u.push({pos:n[0],members:[]});for(const t of n)l.push({pos:t,pt:i});r&&f.set(i,r)}const d=(t,e)=>{const r=c(t,e),i=h.get(`${t}:${"end"===e?"start":"end"}`),o=[];for(const t of l)nh(t.pos,r)<=n&&!o.includes(t.pt)&&o.push(t.pt);for(let t=0;t<u.length;t++)nh(u[t].pos,r)<=n&&!o.includes(t)&&o.push(t);let s=o.find(t=>t!==i)??-1;s<0&&(s=u.length,u.push({pos:r,members:[]})),u[s].members.push({seg:t,end:e}),h.set(`${t}:${e}`,s)};for(let t=0;t<o;t++)d(t,"start"),d(t,"end");const p=new Set,y=new Set,g=new Set;{const t=t=>{let e=-1,n=1/0;for(let r=0;r<u.length;r++){const i=nh(u[r].pos,t);i<n&&(n=i,e=r)}for(const r of l){const i=nh(r.pos,t);i<n&&(n=i,e=r.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:r}=t(n.pos);e>=0&&r<=i&&(p.add(e),("source"===n.kind?y:g).add(e))}}for(const[t,e]of f)p.add(t),("source"===e?y:g).add(t);const m=(t,e)=>"end"===e!==s[t],b=[],v=(e,n)=>{if(void 0===s[e])return s[e]=n,void b.push(e);s[e]!==n&&a.add(t[e].id)},x=t=>{for(const e of["start","end"]){const n=h.get(`${t}:${e}`);if(void 0===n)continue;const r=u[n];if(2!==r.members.length||p.has(n))continue;const i=r.members[0],o=i.seg===t&&i.end===e?r.members[1]:i;if(o.seg===t)continue;const a="end"===e!==s[t],c="end"===o.end!==!a;v(o.seg,c)}},_=()=>{for(;b.length;)x(b.shift())},w=t=>{let e=-1,n="start",r=1/0;for(let i=0;i<o;i++)for(const o of["start","end"]){const s=nh(c(i,o),t.pos);s<r&&(r=s,e=i,n=o)}if(e<0||r>i)return;const s="source"===t.kind?"end"===n:"start"===n;v(e,s)};for(const t of e)"source"===t.kind&&w(t);_();for(const t of e)"sink"===t.kind&&w(t);_();let k=!0;for(;k;){k=!1;for(const t of u){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===s[t.seg]);if(1!==e.length)continue;let n=0,r=0;for(const e of t.members)void 0!==s[e.seg]&&(m(e.seg,e.end)?n++:r++);const i=e[0];let o;0===r&&n>0?o="end"===i.end:0===n&&r>0&&(o="start"===i.end),void 0!==o&&(s[i.seg]=o,b.push(i.seg),_(),k=!0)}}if(s.some(t=>void 0===t)&&y.size>0&&g.size>0){const t=t=>{const e=new Array(u.length).fill(1/0),n=[];for(const r of t)e[r]=0,n.push(r);for(;n.length;){const t=n.shift();for(const r of u[t].members){const i=h.get(`${r.seg}:${"start"===r.end?"end":"start"}`);void 0!==i&&e[i]>e[t]+1&&(e[i]=e[t]+1,n.push(i))}}return e},e=t(y),n=t(g);for(let t=0;t<o;t++){if(void 0!==s[t])continue;const r=h.get(`${t}:start`),i=h.get(`${t}:end`);if(void 0===r||void 0===i)continue;if(u[r].members.length<2||u[i].members.length<2)continue;if(e[r]===1/0||e[i]===1/0||n[r]===1/0||n[i]===1/0)continue;let o;e[r]!==e[i]?o=e[r]<e[i]:n[r]!==n[i]&&(o=n[i]<n[r]),void 0!==o&&(s[t]=!o,b.push(t))}_()}const M=new Map;for(let e=0;e<o;e++)M.set(t[e].id,void 0===s[e]?"unknown":s[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function ih(...t){}function oh(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function sh(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*ah(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*ah(t)}function ch(t,e,n){const r=e.width??0,i=e.height??0;if(r<=0||i<=0)return!1;const o=(e.left??0)+r/2,s=(e.top??0)+i/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-o,u=t.z-s,h=Math.cos(-a),l=Math.sin(-a),f=c*h-u*l,d=c*l+u*h;return Math.abs(f)<=r/2+n&&Math.abs(d)<=i/2+n}function uh(t){const e=[],n=[],r=[],i=[];for(const o of ah(t)){const t=sh(o);if(!t)continue;if(o.flowOrientable){const n=Ou(o.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof o.openings){const t=o.state??{};(t.width??0)>0&&(t.height??0)>0&&i.push(t);continue}let s;try{s=o.getSegmentTopology()}catch{continue}if(!s)continue;const a=s.inbounds??[],c=s.outbounds??[],u="function"==typeof o.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||u))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&r.push({positions:t})}}for(const t of i){const i=[];for(const n of e)for(const e of[n.start,n.end])ch(e,t,16)&&i.push(e);let o=!1,s=!1;for(const e of n)ch(e.pos,t,16)&&("sink"===e.kind?o=!0:s=!0);const a=o&&!s?"sink":s&&!o?"source":void 0;(i.length>=2||a&&i.length>=1)&&r.push({positions:i,kind:a})}if(0===e.length||0===n.length)return e.length,n.length,new Map;const o=rh(e,n,8,r,60).directions;return e.length,n.length,r.length,[...o].map(([t,e])=>`#${t}:${e}`).join(" "),o}function hh(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:uh(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const r=sh(t),i=r?n.map.get(r):void 0;return"reverse"===i||"forward"!==i&&void 0}function lh(t){return!!t&&"function"==typeof t.distanceToBoardPoint}function fh(t,e,n,r){if(!t||!e)return null;const i=[],o=t=>{if(!t||t===r)return;if(function(t,e){const n=t?.capabilities??t?.constructor?.capabilities;return Array.isArray(n)&&n.includes(e)}(t,e)&&lh(t)){const e=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(t);e&&i.push({id:e,component:t,distance:t.distanceToBoardPoint(n.x,n.y)})}const s=t.components;if(Array.isArray(s))for(const t of s)o(t)};return o(t),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function dh(t){return!!t&&"function"==typeof t.routingDestination}function ph(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*yh(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*yh(t)}function gh(t){const e=[],n=new Map,r=new Map,i=new Set,o=[];for(const s of yh(t)){"function"==typeof s?.registerWithHost&&o.push(s);const t="function"==typeof s?.getSegmentTopology,a="function"==typeof s?.routingLinks?s.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||dh(s)||c||lh(s)))continue;const u=ph(s);if(!u)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=s.getSegmentTopology()}catch{continue}if(!h)continue}const l=s.state??{},f={left:l.left,top:l.top,width:l.width,height:l.height,rotation:l.rotation};if(e.push({id:u,topology:h,bounds:f,links:a}),r.set(u,s),dh(s)){i.add(u);const t=s.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(u),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:r,routingTargetIds:i,stationClients:o}}function mh(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:r,components:i,routingTargetIds:o,stationClients:s}=gh(t),a=Du(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const r=[...e].sort((t,e)=>{const n=ph(t)??"",r=ph(e)??"";return n.localeCompare(r)});for(const e of r){const n=e.declaredHostRef?.();let r=null;if(n&&(r=t.findById?.(n)??null),!r){const n=e.hostCapability?.(),i=e.hostFacingPoint?.();n&&i&&(r=fh(t,n,i,e)?.component??null)}r&&"function"==typeof e.registerWithHost&&e.registerWithHost(r)}const i=e=>{if(!e)return;if(lh(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const r=t.findById?.(n);r&&e.registerDivertStation(n,r)}const n=e.components;if(Array.isArray(n))for(const t of n)i(t)};i(t)}(t,s);const c=new Set;for(const[t,e]of i){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const u=new Map;for(const t of o){const e=i.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&u.set(t,n)}}const h=Xu(a,{routingTargetIds:o,loopCapableIds:c,routingWeights:u});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:r,components:i,issues:h},t.__flowGraph=e}return e}function bh(t){return mh(t)?.issues??[]}function vh(t){const e=mh(t);return e&&e.graph.nodes.size>0?e.graph:null}function xh(t,e){return mh(t)?.destToSinks.get(e)??[]}function _h(t,e){return mh(t)?.components.get(e)}function wh(t){const e=mh(t);return e?[...e.destToSinks.keys()]:[]}function kh(t){return ph(t)}function Mh(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function Sh(t,e,n,r,i){if(1===r.length)return r[0];switch(t){case"index":default:return r[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),r[t%r.length]}case"weight":{const t=r.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(i.get(t.target))),o=t.reduce((t,e)=>t+e,0);if(o<=0)return r[0];const s=n.counters.get(e)??0;n.counters.set(e,s+1);let a=s%o;for(let e=0;e<r.length;e++){if(a<t[e])return r[e];a-=t[e]}return r[r.length-1]}case"utilization":{let t=1/0,e=r[0];for(const n of r){const r=Mh(i.get(n.target));r<t&&(t=r,e=n)}return e}}}function zh(t,e,n){const r=t?.root;if(!r)return null;const i=e?.state?.meta?.destination;if("string"!=typeof i||0===i.length)return null;const o=mh(r);if(!o||0===o.graph.nodes.size)return null;const s=ph(t);if(!s)return null;let a=o.destToSinks.get(i)??[];0===a.length&&(a=[i]);const c=Gu(o.graph,s,a);if(0===c.length)return null;const u=o.graph.out.get(s)??[],h=c.filter(t=>{const n=u[t.index],r=n?o.components.get(n):null;return!r||"function"!=typeof r.canReceive||r.canReceive(e)});if(0===h.length)return u[c[0].index]??null;const l=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const r=e?.state?.routingBalancingPolicy;return r||"round-robin"}(t,r),f=Sh(l,s,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(r),h,o.components);return u[f.index]??null}n({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slotLayout","get slots","slotById","slotSeatTransform","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),n({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,vh(t)}catch{return null}}}catch{}function Eh(t,e,n){const r=zh(t,e,n);if(null==r)return null;const i=t?.root,o=_h(i,r)??i?.findById?.(r)??null;return o?{targetId:r,component:o,origin:"explicit"}:null}function Ah(t){const e=t?.root,n=vh(e),r=kh(t);if(!n||!r)return null;const i=(n.out.get(r)??[]).find(Boolean);if(!i)return null;const o=_h(e,i)??e?.findById?.(i)??null;return o?{id:i,component:o}:null}function Th(t){const e=kh(t);return e?Oh(t?.root,e):[]}function Oh(t,e){if(!t||!e)return[];const n=vh(t);if(!n)return[];const r=new Set;for(const i of Yu(n,e)){const e=_h(t,i);if(dh(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&r.add(t)}}return[...r]}function Ih(t,e){if(!t||!e)return[];const n=vh(t);if(!n)return[];const r=new Map;for(const t of n.out.values())for(const e of t)null!=e&&r.set(e,(r.get(e)??0)+1);const i=new Map;for(const o of Yu(n,e)){const e=_h(t,o);if(!dh(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let s=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(s=t)}null===s&&(s=r.get(o)??0,0===s&&(s=1)),i.set(n,(i.get(n)??0)+s)}return[...i].map(([t,e])=>({value:t,weight:e}))}function jh(t){return vh(t)}function Ph(t){const e=vh(t);if(!e)return[];const n=new Set,r=new Set,i=t=>{if(!t)return;const o=kh(t);if(o&&e.nodes.has(o)){dh(t)&&n.add(o);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&r.add(o)}const s=t.components;if(Array.isArray(s))for(const t of s)i(t)};return i(t),Xu(e,{routingTargetIds:n,loopCapableIds:r})}function Rh(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let r=0;for(const e of t)if(r+=e.weight,n<r)return e.value;return t[t.length-1].value}const Ch={next:Eh,downstream:Ah,reachableDestinations:Th,reachableDestinationsFrom:Oh,reachableDestinationsWeightedFrom:Ih,pickWeightedDestination:Rh,graphFor:jh,validate:Ph};function Fh(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const r=t.prototype?.attachPointFor;return"function"==typeof r?r.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n&&(this._items.splice(n,1),t.parent=null,t._realObject?.setTransientDisplayScale?.(1),!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=t.parent;n&&("function"==typeof n.removeComponent&&-1!==n._components?.indexOf?.(t)&&n.removeComponent(t,!0),n!==this&&"function"==typeof n.removeItem&&-1!==n._items?.indexOf?.(t)&&n.removeItem(t,!0));const r=-1===this._items.indexOf(t);if(r&&this._items.push(t),t.parent=this,r&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}this.seatHeldItem(t,{toParent3D:e?.toParent3D,slotId:e?.slotId}),t.held?.(this),this._bumpReceived?.(t)}seatHeldItem(t,e={}){t.realObject;const n=t._realObject,r=n?.object3d;if(r){let i,o,s=e.toParent3D,a="world-preserve",c=1;if(!s){const n=this.attachPointFor?.(t,{slotId:e.slotId});n?.attach&&(s=n.attach,i=n.localPosition,o=n.localRotation,a=n.carryPolicy??"world-preserve",c=n.displayScale??1)}s&&r.parent!==s&&(s.updateWorldMatrix?.(!0,!1),r.updateWorldMatrix?.(!0,!1),s.attach(r),n.suppressTransform=!0),s&&(i&&r.position.set(i.x,i.y,i.z),"world-preserve"!==a?o?r.rotation.set(o.x,o.y,o.z):r.quaternion.identity():o&&r.rotation.set(o.x,o.y,o.z),n?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}),n?.setTransientDisplayScale?.(c))}}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)try{e.dispose?.()}catch{}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,r,i){for(let o=this._items.length-1;o>=0;o--){const s=this._items[o],a="static"===s.position?s.capture?.(t,e,i):s.capture?.(n,r,i);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const r=e.bounds;!e.showOverflow&&r&&(t.beginPath(),t.rect(r.left,r.top,r.width,r.height),t.clip(),t.closePath());const{left:i=0,top:o=0}=e.state??{};t.translate(i,o),this._drawItems(t),t.translate(-i,-o),t.restore()}capture(t,e,n){const r=this,i=this._items;if(i&&i.length>0&&(!r.app||r.app.isEditMode||!r.hidden)){const i=r.fromParent?.(t,e);if(i&&r.contains?.(i.x,i.y)){const o=r.bounds,s=this._captureItems(i.x-o.left,i.y-o.top,t,e,n);if(s)return s}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Nh(t){var e;const n=!!t.__hasCapacity,r=!!t.__hasTransferable,i=n?t:Eu(t),o=r?i:function(t){var e;return(e=class extends t{reserve(t,e){const n=this.findSlot(t);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){K.log({role:"target",contract:"receive:enter",component:this,args:{carrier:U(t),options:e}});const n=this.reserve(t,e);if(!n){K.log({role:"target",contract:"receive:reject",component:this,args:{carrier:U(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,e,n={}){const r=t.slot,i=this._countOccupied(r.id),o=this.arrangementStrategy.positionAt(i,r,i,e);K.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:i,slotId:r.id,occupantCount:i,carrier:U(e)},result:o}),e[Y]=r.id;const s=e._realObject;let a,c;s?.object3d&&(s.object3d.updateWorldMatrix(!0,!1),a=new k,c=new w,s.object3d.getWorldPosition(a),s.object3d.getWorldQuaternion(c));const{animated:u=!1,duration:h,ease:l}=n;"function"==typeof this.handoverIn?this.handoverIn(e,{slotId:r.id}):this.reparent?.(e,{animated:u,duration:h,ease:l}),!u&&e._realObject&&(e._realObject.suppressTransform=!1);{const t={},n=this.placementFor?.(e,{slot:r,index:i,occupantCount:i})??null;if(K.log({role:"target",contract:"placementFor",component:this,args:{carrier:U(e),slotId:r.id,index:i},result:n}),n){const i=e.state??{},o=this.state??{};t.left=n.position.x-(Number(i.width)||0)/2+(Number(o.width)||0)/2,t.top=n.position.z-(Number(i.height)||0)/2+(Number(o.height)||0)/2;const s=this._zPosFromSeatY(n.position.y,i.depth,r);null!==s&&(t.zPos=s),n.rotation&&W(t,n.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=r.localPosition.z+e}const n=this.acceptanceRotation?.(e,r);K.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:U(e),slotId:r.id},result:n}),n&&W(t,n)}const s=this.normalizePose?.(e,r);"function"==typeof this.normalizePose&&K.log({role:"target",contract:"normalizePose",component:this,args:{carrier:U(e),slotId:r.id},result:s}),s&&Object.assign(t,s),Object.keys(t).length&&(e.setState?.(t),K.log({role:"target",contract:"receive:setState",component:this,args:{carrier:U(e),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:e,container:this,slotId:r.id,preReceiveWorldPos:a,preReceiveWorldQuat:c}),K.log({role:"target",contract:"receive:done",component:this,args:{carrier:U(e),slotId:r.id}})}async dispatch(t,e,n={}){const r=new rt({source:this,target:e,carrier:t,options:n,physical:async()=>{delete t[Y]}}),i=await r.execute();"rolled-back"!==i.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:i.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const n=this.findSlot(t);if(!n){const n=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!n||t.allowedTypes.includes(n))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:n}})();return K.log({role:"target",contract:"canAccept",component:this,args:{carrier:U(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,e}(i),s=[...t.capabilities??[]];n||s.push("Capacity","PlacementSurface"),r||s.push("Transferable"),s.push("Holdable","FlowNode");var a,c,u;return Xc((e=class extends(Fh(o)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},a=e,"symbol"==typeof(c="FlowNodeMixed")&&(c=c.description?"[".concat(c.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:u?"".concat(u," ",c):c}),e.capabilities=Object.freeze(s),e.isFlowNode=!0,e))}function Dh(t){return!!t&&!0===t.isFlowNode}"function"==typeof SuppressedError&&SuppressedError,n({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),n({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),n({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});export{gt as BULGE_EPSILON,Eu as Capacity,It as CapacityEventTracker,Pt as CenteringQueueStrategy,y as CenteringSlotStrategy,du as DEFAULT_SEAT_MARGIN,d as FixedSlotStrategy,Ch as FlowEngine,Nh as FlowNode,Ft as GridStacking,Vc as HOLDER_ANCHOR,Fh as Holdable,Xc as ItemsDataBinding,ht as NavGraph,Ct as PatternStacking,zt as PolygonPathPolyline,ct as ReservationTable,Y as TRANSFER_SLOT_KEY,rt as Transfer,Nt as VolumeStacking,uu as addressOfSlotId,wh as allDestinations,Pu as anchorsConnect,Sh as applyPolicy,W as applySeatingRotation,Dt as applyStackLayout,Iu as arcSegmentTopology,jt as autoWireBackPressure,Du as buildFlowGraph,dt as buildNavGraph,xt as bulgeFromDrag,vt as bulgeHandlePosition,Wu as canReach,t as capability,f as chooseNearestPickupFrame,Hu as collectAdjacentSegments,_h as componentForNode,bt as computeArcParams,uh as computeFlowMap,Rt as computeStackPositions,wt as cornerHandlePosition,kt as cornerRadiusFromDrag,Fu as deliversInto,Ah as downstream,_t as effectiveCornerRadius,Ju as enumerateDataScenarios,l as filterByToolType,fh as findNearestWithCapability,p as fixedSlotStrategy,Et as flattenPolygonPath,vh as flowGraphFor,bh as flowGraphIssues,hh as flowReverseFor,Lt as footprint2D,H as frameClock,oh as ftId,ih as ftrace,i as getAllCapabilityMeta,r as getCapabilityMeta,B as globalSimClock,jh as graphFor,ou as gridCellOf,iu as gridSlotNo,mt as hasArc,Tt as hasCapacity,Ot as inferCapacity,Vu as inferDownstreamId,rh as inferFlowDirections,Dh as isFlowNode,lh as isGeometricHost,dh as isRoutingTarget,ku as judgeItemFit,Hc as layoutIssue,Nu as matchOutbounds,Eh as next,qu as nextHop,Uu as nextHops,Bu as nextHopsToAny,Gu as nextHopsToAnyDetailed,kh as nodeIdOf,eu as persistenceIssues,Rh as pickWeightedDestination,pt as planPathAStar,yt as planToReservations,Ru as pointInRotatedRect,At as polygonPathLength,s as quatFromYaw,Cu as rayAbsDistanceToRect,Lu as reachableByOutbound,Th as reachableDestinations,Oh as reachableDestinationsFrom,Ih as reachableDestinationsWeightedFrom,Yu as reachableSinks,et as receiptToJSON,Au as rectFaceAnchors,u as rectangularFootprintFrames,n as registerCapabilityMeta,ut as reservationTable,zh as resolveNextHop,au as resolveSlot,yu as rotatedFootprint,gu as seatInSlot,mu as seatTransform,xh as sinksForDestination,hu as slotAddresses,nu as slotCount,fu as slotFrame,cu as slotIdOf,ru as slotNumbers,wu as slotSpaceWarnings,bu as stackSeatTransforms,at as standardYieldPolicy,Ou as straightSegmentEndpoints,ju as straightSegmentMultiInbound,Tu as straightSegmentTopology,h as topApproachFrame,it as transferLog,K as transferTracer,Mt as uniformZ,Ph as validate,Xu as validateFlowGraph,tu as validateSlotLayout};