UNPKG

@itwin/core-frontend

Version:
1 lines • 1.07 MB
(()=>{"use strict";function t(t,e){return t-e}function e(t,e){return t!==e?t<e?-1:1:0}function i(t,e){return t===e?0:t<e?-1:1}function n(t,e,i){return void 0===e?void 0===i?0:-1:void 0===i?1:t(e,i)}function s(t,i){return n(e,t,i)}function r(t){const e=parseInt(t,16);return Number.isNaN(e)?0:e}function o(t,e,i=!0){const n=t.charCodeAt(e);return n>=(i?48:49)&&n<=57||n>=97&&n<=102}function a(t,e,i){if(0===i)return!1;if(!o(t,e,!1))return!1;for(let n=1;n<i;n++)if(!o(t,e+n))return!1;return!0}var c,l,h,d,u,f,g,p,m,_,x,y,v,P,I,S,b,A,C,T,w,E,k,F,R,M,D,O,B,N,X,z,L,Y;function V(t){return t}function U(t,e,i){return q(e,(e=>i(t,e)))}function q(t,e){let i=0,n=t.length;for(;i<n;){const s=Math.floor((i+n)/2),r=e(t[s]);if(0===r)return{index:s,equal:!0};r<0?n=s:i=s+1}return{index:i,equal:!1}}!function(t){t.getLocalId=function(t){if(g(t))return 0;const e=t.length,i=e>12?e-10:2;return r(t.slice(i))},t.getBriefcaseId=function(t){if(g(t))return 0;const e=t.length;return e<=12?0:r(t.slice(2,e-10))},t.fromJSON=function(e){return"string"==typeof e?t.fromString(e):t.invalid},t.fromString=function(e){if("string"!=typeof e)return t.invalid;if(t.isId64(e))return e;const n=(e=e.toLowerCase().trim()).length;if(n<2||"0"!==e[0]||"x"!==e[1])return t.invalid;let s=0,o=0,a=2;return n>12&&(a=n-10,o=r(e.slice(2,a))),s=r(e.slice(a)),i(s,o)};const e=["0000000000","000000000","00000000","0000000","000000","00000","0000","000","00","0",""];function i(i,n){if("number"!=typeof i||"number"!=typeof n)return t.invalid;if(0===(i=Math.floor(i)))return t.invalid;n=Math.floor(n);const s=i.toString(16);return`0x${0===n?s:n.toString(16)+(e[s.length]+s)}`}t.fromLocalAndBriefcaseIds=i;const n=[48,120,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48];function s(t){return t+(t<10?48:87)}function o(t,e,i){let n=0;for(let r=e;r<i;r++)n=(n|(s=t.charCodeAt(r))-(s>=87?87:48)<<(i-r-1<<2))>>>0;var s;return n}function c(e,i){if(0==(e>>>0)+4294967296*(255&i))return t.invalid;const r=n;let o=2;for(let t=7;t>=0;t--){const e=t<<2,n=(i&15<<e)>>>e;(o>2||0!==n)&&(r[o++]=s(n))}for(let t=7;t>=0;t--){const i=t<<2,n=(e&15<<i)>>>i;(o>2||0!==n)&&(r[o++]=s(n))}return r.length!==o&&(r.length=o),String.fromCharCode(...n)}function l(t){if(g(t))return 0;const e=t.length;return o(t,e>10?e-8:2,e)}function h(t){const e=t.length;return e<=10||g(t)?0:o(t,2,e-8)}function*d(t){if("string"==typeof t)yield t;else for(const e of t)yield e}function u(t){return 18===t.length&&t.startsWith("0xffffff")}function f(e){return t.invalid!==e&&t.isId64(e)}function g(e){return t.invalid===e}t.fromUint32Pair=c,t.fromUint32PairObject=function(t){return c(t.lower,t.upper)},t.isValidUint32Pair=function(t,e){return 0!==t||!!(255&e)},t.getUint32Pair=function(t,e){return e||(e={lower:0,upper:0}),e.lower=l(t),e.upper=h(t),e},t.getLowerUint32=l,t.getUpperUint32=h,t.toIdSet=function(t,e=!1){if(t instanceof Set)return e?new Set(t):t;const i=new Set;return"string"==typeof t?i.add(t):Array.isArray(t)&&t.forEach((t=>{"string"==typeof t&&i.add(t)})),i},t.iterator=d,t.iterable=function(t){return{[Symbol.iterator]:()=>d(t)}},t.getFirst=function(e){return"string"==typeof e?e:(Array.isArray(e)?e[0]:e.values().next().value)??t.invalid},t.sizeOf=function(t){return"string"==typeof t?1:Array.isArray(t)?t.length:t.size},t.has=function(t,e){return"string"==typeof t?t===e:Array.isArray(t)?-1!==t.indexOf(e):t.has(e)},t.invalid="0",t.isTransient=u,t.isTransientId64=function(t){return f(t)&&u(t)},t.isId64=function(t){const e=t.length;if(0===e||18<e)return!1;if("0"!==t[0])return!1;if(1===e)return!0;if(2===e||"x"!==t[1])return!1;let i=2;if(e>12){if(i=e-10,!a(t,2,i-2))return!1;for(let n=i;n<e&&48===t.charCodeAt(n);n++)i++;if(i>=e)return!1}return a(t,i,e-i)},t.isValid=function(e){return t.invalid!==e},t.isValidId64=f,t.isInvalid=g,t.Uint32Set=class{_map=new Map;constructor(t){void 0!==t&&this.addIds(t)}equals(t){if(this===t)return!0;if(this.size!==t.size)return!1;for(const[e,i]of this._map){const n=t._map.get(e);if(!n||i.size!==n.size)return!1;for(const t of i)if(!n.has(t))return!1}return!0}clear(){this._map.clear()}addId(e){this.add(t.getLowerUint32(e),t.getUpperUint32(e))}addIds(e){for(const i of t.iterable(e))this.addId(i)}hasId(e){return this.has(t.getLowerUint32(e),t.getUpperUint32(e))}add(t,e){let i=this._map.get(e);void 0===i&&(i=new Set,this._map.set(e,i)),i.add(t)}deleteId(e){this.delete(t.getLowerUint32(e),t.getUpperUint32(e))}deleteIds(e){for(const i of t.iterable(e))this.deleteId(i)}delete(t,e){const i=this._map.get(e);void 0!==i&&(i.delete(t),0===i.size&&this._map.delete(e))}has(t,e){const i=this._map.get(e);return void 0!==i&&i.has(t)}hasPair(t){return this.has(t.lower,t.upper)}get isEmpty(){return 0===this._map.size}get size(){let t=0;for(const e of this._map)t+=e[1].size;return t}toId64Array(){const e=[];for(const i of this._map)for(const n of i[1])e.push(t.fromUint32Pair(n,i[0]));return e}toId64Set(){const e=new Set;for(const i of this._map)for(const n of i[1])e.add(t.fromUint32Pair(n,i[0]));return e}forEach(t){for(const e of this._map)for(const i of e[1])t(i,e[0])}},t.Uint32Map=class{_map=new Map;clear(){this._map.clear()}getById(e){return this.get(t.getLowerUint32(e),t.getUpperUint32(e))}setById(e,i){this.set(t.getLowerUint32(e),t.getUpperUint32(e),i)}set(t,e,i){let n=this._map.get(e);void 0===n&&(n=new Map,this._map.set(e,n)),n.set(t,i)}get(t,e){const i=this._map.get(e);return void 0!==i?i.get(t):void 0}get isEmpty(){return 0===this._map.size}get size(){let t=0;for(const e of this._map)t+=e[1].size;return t}forEach(t){for(const e of this._map)for(const i of e[1])t(i[0],e[0],i[1])}}}(c||(c={})),function(t){const e=new RegExp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");function i(t){return e.test(t)}t.empty="00000000-0000-0000-0000-000000000000",t.isGuid=i,t.isV4Guid=function(t){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/.test(t)},t.createValue=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},t.normalize=function(t){const e=t.toLowerCase().trim();if(i(e))return e;const n=e.replace(/-/g,""),s=/^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/;return s.test(n)?n.replace(s,((t,e,i,n,s,r)=>`${e}-${i}-${n}-${s}-${r}`)):t}}(l||(l={})),function(t){function e(t,e){return t.length!==e.length?t.length<e.length?-1:1:t!==e?t<e?-1:1:0}function*i(t){const e=t[Symbol.iterator]();let i,n=e.next();for(;!n.done;){const t=n.value;n=e.next(),t!==i&&(i=t,yield t)}}function*n(t,i){const n=t[Symbol.iterator](),s=i[Symbol.iterator]();let r,o=n.next(),a=s.next();for(;!o.done||!a.done;){const t=o.done?void 0:o.value,i=a.done?void 0:a.value;if(void 0===t&&void 0===i)break;let c;if(void 0===t)c=i,a=s.next();else if(void 0===i)c=t,o=n.next();else{const r=e(t,i);r<=0?(c=t,o=n.next(),0===r&&(a=s.next())):(c=i,a=s.next())}r!==c&&(r=c,yield c)}}function*s(t,i){const n=t[Symbol.iterator](),s=i[Symbol.iterator]();let r,o=n.next(),a=s.next();for(;!o.done&&!a.done;){const t=o.value;if(o=n.next(),t===r)continue;r=t;let i=a.value,c=e(t,i);for(;c>0;){if(a=s.next(),a.done)return;i=a.value,c=e(t,i)}0===c&&(yield t)}}function*r(t,i){const n=t[Symbol.iterator](),s=i[Symbol.iterator]();let r,o=n.next(),a=s.next();for(;!o.done;){const t=o.value;if(o=n.next(),t===r)continue;if(a.done){yield r=t;continue}let i=a.value,c=e(t,i);for(;c>0&&!a.done;)a=s.next(),a.done?yield r=t:(i=a.value,c=e(t,i));c<0&&(yield r=t)}}t.compare=e,t.sortArray=function(t){return t.sort(((t,i)=>e(t,i))),t},t.areEqualSets=function(t,n){const s=i(t),r=i(n);let o=s.next(),a=r.next();for(;!o.done&&!a.done;){if(0!==e(o.value,a.value))return!1;o=s.next(),a=r.next()}return!(!o.done||!a.done)},t.isEmptySet=function(t){return"string"==typeof t?""===t:!0===t[Symbol.iterator]().next().done},t.unique=function(t){return{[Symbol.iterator]:()=>i(t)}},t.uniqueIterator=i,t.union=function(t,e){return{[Symbol.iterator]:()=>n(t,e)}},t.intersection=function(t,e){return{[Symbol.iterator]:()=>s(t,e)}},t.difference=function(t,e){return{[Symbol.iterator]:()=>r(t,e)}},t.unionIterator=n,t.intersectionIterator=s,t.differenceIterator=r}(h||(h={})),function(t){t[t.Allow=0]="Allow",t[t.Retain=1]="Retain",t[t.Replace=2]="Replace"}(d||(d={}));class Z{_array=[];_compare;_clone;_duplicatePolicy;constructor(t,e=!1,i=V){this._compare=t,this._clone=i,"boolean"==typeof e&&(e=e?d.Allow:d.Retain),this._duplicatePolicy=e}get length(){return this._array.length}get isEmpty(){return 0===this.length}[Symbol.iterator](){return this._array[Symbol.iterator]()}indexOf(t){const e=this.lowerBound(t);return e.equal?e.index:-1}contains(t){return-1!==this.indexOf(t)}findEqual(t){const e=this.indexOf(t);return-1!==e?this._array[e]:void 0}findEquivalent(t){const e=this.indexOfEquivalent(t);return-1!==e?this._array[e]:void 0}indexOfEquivalent(t){const e=q(this._array,(e=>0-t(e)));return e.equal?e.index:-1}get(t){return t<this.length?this._array[t]:void 0}forEach(t){for(let e=0;e<this.length;e++)t(this._array[e])}slice(t,e){const i=new Z(this._compare,this._duplicatePolicy,this._clone);return i._array=this._array.slice(t,e),i}lowerBound(t){return U(t,this._array,this._compare)}_clear(){this._array.length=0}_extractArray(){const t=this._array;return this._array=[],t}_insert(t,e){const i=this.lowerBound(t);if(i.equal)switch(this._duplicatePolicy){case d.Retain:return i.index;case d.Replace:return this._array[i.index]=this._clone(t),e&&e(t),i.index}return this._array.splice(i.index,0,this._clone(t)),void 0!==e&&e(t),i.index}_remove(t){const e=this.lowerBound(t);return e.equal?(this._array.splice(e.index,1),e.index):-1}}class W extends Z{constructor(t,e=!1,i=V){super(t,e,i)}clear(){this._clear()}extractArray(){return this._extractArray()}insert(t,e){return this._insert(t,e)}remove(t){return this._remove(t)}slice(t,e){const i=new W(this._compare,this._duplicatePolicy,this._clone);return i._array=this._array.slice(t,e),i}}!function(t){function e(t){return t>=48&&t<=57||t>=65&&t<=70}function i(t,e){const i=`+${t.toString()}`;return e<=1?i:`${i}*${e.toString(16).toUpperCase()}`}function n(t){const e="string"==typeof t?[t]:Array.from(t);return h.sortArray(e),s(e)}function s(t){return r(t)}function r(t){if("string"==typeof t)return t;let e="";const n=new o,s=new o;let r=0;const a=new o,l=new o;for(const o of t){if(!c.isValidId64(o))continue;a.setFromId(o),l.setFromDifference(a,n);const t=n.compare(a);if(0!==t){if(t>0)throw new Error("CompressedId64Set.compressArray requires a sorted array as input");n.copyFrom(a),0===r?(s.copyFrom(l),r=1):l.equals(s)?++r:(e+=i(s,r),s.copyFrom(l),r=1)}}return 0<r&&(e+=i(s,r)),e}t.compressSet=function(t){return n(t)},t.sortAndCompress=n,t.compressArray=s,t.compressIds=r;class o{lower;upper;static _base=4294967296;static assertUint32(t){o._base,Math.floor(t)}assertConstraints(){o.assertUint32(this.lower),o.assertUint32(this.upper)}constructor(t=0,e=0){this.lower=t,this.upper=e,this.assertConstraints()}compare(t){const e=this.upper-t.upper;return 0===e?this.lower-t.lower:e}equals(t){return 0===this.compare(t)}isLessThan(t){return this.compare(t)<0}isGreaterThan(t){return this.compare(t)>0}get isZero(){return 0===this.lower&&0===this.upper}setFromDifference(t,e){e.isGreaterThan(t),this.lower=t.lower-e.lower,this.upper=t.upper-e.upper,this.lower<0&&(this.lower+=o._base,this.upper-=1)}add(t){let e=t.lower,i=t.upper;e+this.lower>=o._base&&(e-=o._base,i+=1),this.lower+=e,this.upper+=i,this.assertConstraints()}setFromId(t){c.getUint32Pair(t,this)}copyFrom(t){this.lower=t.lower,this.upper=t.upper}toString(){if(0===this.upper)return this.lower.toString(16).toUpperCase();const t=this.upper.toString(16),e=this.lower.toString(16).padStart(8,"0");return e.length,`${t}${e}`.toUpperCase()}toId64String(){return c.fromUint32Pair(this.lower,this.upper)}}function*a(t){if(0===t.length)return;if("+"!==t[0])throw new Error("Invalid CompressedId64Set");let i=1;const n=new o;function s(){let n=0,s=0;for(;i<t.length&&s<8;){++s;const r=t.charCodeAt(i);if(!e(r))break;n<<=4,n|=r>=65?r-65+10:r-48,n>>>=0,++i}return n}function r(n){let r=0,o=0;const a=i,c=s();if(8===i-a&&i+1<t.length&&e(t.charCodeAt(i+1))){const t=i,e=s(),n=i-t,a=8-n;o=c>>>4*a,r=(e|c-(o<<4*a>>>0)<<4*n>>>0)>>>0}else r=c;n.lower=r,n.upper=o}const a=new o;for(;i<t.length;){let e=1;if(r(a),a.isZero)throw new Error("Invalid CompressedId64Set");if(i<t.length)switch(t[i++]){case"*":if(e=s(),0===e)throw new Error("Invalid CompressedId64Set");if(i!==t.length&&"+"!==t[i++])return;break;case"+":break;default:throw new Error("Invalid CompressedId64Set")}for(let t=0;t<e;t++)n.add(a),yield n.toId64String()}}function l(t){return{[Symbol.iterator]:()=>a(t)}}t.iterator=a,t.iterable=l,t.decompressSet=function(t,e){const i=e??new Set;for(const e of l(t))i.add(e);return i},t.decompressArray=function(t,e){const i=e??[];for(const e of l(t))i.push(e);return i}}(u||(u={})),Symbol.iterator;class G{static piOver12Radians=.26179938779914946;static piOver4Radians=.7853981633974483;static piOver2Radians=1.5707963267948966;static piRadians=3.141592653589793;static pi3Over2Radians=4.71238898038469;static pi2Radians=6.283185307179586;static degreesPerRadian=45/G.piOver4Radians;static radiansPerDegree=G.piOver4Radians/45;_radians;_degrees;constructor(t=0,e){this._radians=t,this._degrees=e}clone(){return new G(this._radians,this._degrees)}freeze(){return Object.freeze(this)}static createDegrees(t){return new G(G.degreesToRadians(t),t)}static createRadians(t){return new G(t)}static createSmallAngle(){return new G(J.smallAngleRadians)}static createInterpolate(t,e,i){return new G(J.interpolate(t.radians,e,i.radians))}cloneScaled(t){return new G(this.radians*t)}setRadians(t){this._radians=t,this._degrees=void 0}setDegrees(t){this._radians=G.degreesToRadians(t),this._degrees=t}static create360(){return new G(2*Math.PI,360)}static createAtan2(t,e){return new G(Math.atan2(t,e))}setFrom(t){this._radians=t._radians,this._degrees=t._degrees}setFromJSON(t,e){this._radians=e||0,t&&("number"==typeof t?this.setDegrees(t):"number"==typeof t.degrees?this.setDegrees(t.degrees):"number"==typeof t._degrees?this.setDegrees(t._degrees):"number"==typeof t.radians?this.setRadians(t.radians):"number"==typeof t._radians&&this.setRadians(t._radians))}static fromJSON(t,e){const i=new G;return i.setFromJSON(t,e),i}toJSON(){return this.degrees}toJSONRadians(){return{radians:this.radians}}get radians(){return this._radians}get degrees(){return void 0!==this._degrees?this._degrees:G.radiansToDegrees(this._radians)}static degreesToRadians(t){return t*Math.PI/180}static radiansToDegrees(t){if(t<0)return-G.radiansToDegrees(-t);const e=Math.PI;return t<=.25*e?180/e*t:t<.75*e?90+(t-.5*e)/e*180:t<=1.25*e?180+(t-e)/e*180:t<=1.75*e?270+(t-1.5*e)/e*180:360+(t-2*e)/e*180}cos(){return Math.cos(this._radians)}sin(){return Math.sin(this._radians)}tan(){return Math.tan(this._radians)}static isFullCircleRadians(t){return Math.abs(t)>=J.fullCircleRadiansMinusSmallAngle}static isHalfCircleRadians(t){return Math.abs(Math.abs(t)-Math.PI)<=J.smallAngleRadians}get isFullCircle(){return G.isFullCircleRadians(this._radians)}get isHalfCircle(){return G.isHalfCircleRadians(this._radians)}static adjustDegrees0To360(t){if(t>=0){const e=360;return t<e?t:t-Math.floor(t/e)*e}return t<0?360-G.adjustDegrees0To360(-t):0}static adjustDegreesSigned180(t){if(Math.abs(t)<=180)return t;if(t>=0){const e=360;return t-(1+Math.floor((t-180)/e))*e}return t<0?-G.adjustDegreesSigned180(-t):0}static adjustRadians0To2Pi(t){if(t>=0){const e=2*Math.PI;return t<e?t:t-Math.floor(t/e)*e}return t<0?2*Math.PI-G.adjustRadians0To2Pi(-t):0}static adjustRadians0ToLessThan2Pi(t){return G.isAlmostEqualRadiansAllowPeriodShift(t,0)&&(t=0),this.adjustRadians0To2Pi(t)}static adjustRadiansMinusPiPlusPi(t){if(Math.abs(t)<=Math.PI)return t;if(t>=0){const e=2*Math.PI;return t-(1+Math.floor((t-Math.PI)/e))*e}return t<0?-G.adjustRadiansMinusPiPlusPi(-t):0}static zero(){return new G(0)}get isExactZero(){return 0===this.radians}get isAlmostZero(){return Math.abs(this.radians)<J.smallAngleRadians}get isAlmostNorthOrSouthPole(){return G.isHalfCircleRadians(2*this.radians)}static createDegreesAdjustPositive(t){return G.createDegrees(G.adjustDegrees0To360(t))}static createDegreesAdjustSigned180(t){return G.createDegrees(G.adjustDegreesSigned180(t))}static isAlmostEqualRadiansAllowPeriodShift(t,e,i=J.smallAngleRadians){const n=Math.abs(t-e);if(n<=i)return!0;const s=2*Math.PI;if(Math.abs(n-s)<=i)return!0;const r=n-Math.round(n/s)*s;return Math.abs(r)<=i}isMagnitudeLessThanOrEqual(t){return Math.abs(this.radians)<=Math.abs(t.radians)}isAlmostEqualAllowPeriodShift(t,e=J.smallAngleRadians){return G.isAlmostEqualRadiansAllowPeriodShift(this._radians,t._radians,e)}static isAlmostEqualRadiansNoPeriodShift(t,e,i=J.smallAngleRadians){return Math.abs(t-e)<i}isAlmostEqualNoPeriodShift(t,e=J.smallAngleRadians){return G.isAlmostEqualRadiansNoPeriodShift(this._radians,t._radians,e)}isAlmostEqual(t,e=J.smallAngleRadians){return this.isAlmostEqualNoPeriodShift(t,e)}static isPerpendicularDotSet(t,e,i){return t>J.smallMetricDistanceSquared&&e>J.smallMetricDistanceSquared&&i*i<=J.smallAngleRadiansSquared*t*e}static trigValuesToHalfAngleTrigValues(t,e){const i=J.hypotenuseXY(t,e);if(i<J.smallMetricDistance)return{c:1,s:0,radians:0};{let n,s=0;const r=t/i,o=e/i;return r>=0?(n=Math.sqrt(.5*(1+r)),s=o/(2*n)):(s=o>0?Math.sqrt(.5*(1-r)):-Math.sqrt(.5*(1-r)),n=o/(2*s)),{c:n,s,radians:Math.atan2(s,n)}}}static cleanupTrigValue(t,e=J.smallFloatingPoint){const i=Math.abs(t);if(i<=e)return 0;let n=Math.abs(i-.5);return n<=e?t<0?-.5:.5:(n=Math.abs(i-1),n<=e?t<0?-1:1:t)}static dotProductsToHalfAngleTrigValues(t,e,i,n=!0){const s=t-e,r=2*i;return n&&Math.abs(r)<J.smallAngleRadians*(Math.abs(t)+Math.abs(e))?{c:1,s:0,radians:0}:G.trigValuesToHalfAngleTrigValues(s,r)}static radiansBetweenVectorsXYZ(t,e,i,n,s,r){const o=t*n+e*s+i*r;return Math.atan2(J.crossProductMagnitude(t,e,i,n,s,r),o)}static orientedRadiansBetweenVectorsXYZ(t,e,i,n,s,r,o,a,c,l=!1){const h=t*n+e*s+i*r,d=e*r-i*s,u=i*n-t*r,f=t*s-e*n,g=o*d+a*u+c*f,p=J.hypotenuseXYZ(d,u,f);return g<0?l?Math.PI+Math.atan2(p,-h):-Math.atan2(p,h):Math.atan2(p,h)}addMultipleOf2PiInPlace(t){void 0!==this._degrees?(this._degrees+=360*t,this._radians=G.degreesToRadians(this._degrees)):this._radians+=t*G.pi2Radians}}class Q{x;y;set(t=0,e=0){this.x=t,this.y=e}setZero(){this.x=0,this.y=0}constructor(t=0,e=0){this.x=t,this.y=e}setFrom(t){t?(this.x=t.x,this.y=t.y):(this.x=0,this.y=0)}freeze(){return Object.freeze(this)}isAlmostEqual(t,e){return J.isSameCoordinate(this.x,t.x,e)&&J.isSameCoordinate(this.y,t.y,e)}isAlmostEqualXY(t,e,i){return J.isSameCoordinate(this.x,t,i)&&J.isSameCoordinate(this.y,e,i)}toJSON(){return[this.x,this.y]}toJSONXY(){return{x:this.x,y:this.y}}setFromJSON(t){Array.isArray(t)?this.set(t[0]||0,t[1]||0):t?this.set(t.x||0,t.y||0):this.set(0,0)}distance(t){const e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)}distanceSquared(t){const e=t.x-this.x,i=t.y-this.y;return e*e+i*i}maxDiff(t){return Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y))}at(t){return t<.5?this.x:this.y}setAt(t,e){t<.5?this.x=e:this.y=e}indexOfMaxAbs(){let t=0;const e=Math.abs(this.x);return Math.abs(this.y)>e&&(t=1),t}get isAlmostZero(){return J.isSmallMetricDistance(this.x)&&J.isSmallMetricDistance(this.y)}get isZero(){return 0===this.x&&0===this.y}maxAbs(){return Math.max(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitudeSquared(){return this.x*this.x+this.y*this.y}isExactEqual(t){return this.x===t.x&&this.y===t.y}isAlmostEqualMetric(t,e=J.smallMetricDistance){return this.maxDiff(t)<=e}vectorTo(t,e){return j.create(t.x-this.x,t.y-this.y,e)}unitVectorTo(t,e){return this.vectorTo(t,e).normalize(e)}static crossProductToPoints(t,e,i){return J.crossProductXYXY(e.x-t.x,e.y-t.y,i.x-t.x,i.y-t.y)}}class H extends Q{constructor(t=0,e=0){super(t,e)}clone(t){return H.create(this.x,this.y,t)}static create(t=0,e=0,i){return i?(i.x=t,i.y=e,i):new H(t,e)}static fromJSON(t){const e=new H;return e.setFromJSON(t),e}static createFrom(t,e){return t?H.create(t.x,t.y,e):H.create(0,0,e)}static createZero(t){return H.create(0,0,t)}addForwardLeft(t,e,i,n){const s=i.x,r=i.y;return H.create(this.x+t*s-e*r,this.y+t*r+e*s,n)}forwardLeftInterpolate(t,e,i){const n=i.x-this.x,s=i.y-this.y;return H.create(this.x+t*n-e*s,this.y+t*s+e*n)}interpolate(t,e,i){if(t<=.5)return H.create(this.x+t*(e.x-this.x),this.y+t*(e.y-this.y),i);const n=t-1;return H.create(e.x+n*(e.x-this.x),e.y+n*(e.y-this.y),i)}interpolateXY(t,e,i,n){return H.create(J.interpolate(this.x,t,i.x),J.interpolate(this.y,e,i.y),n)}minus(t,e){return H.create(this.x-t.x,this.y-t.y,e)}plus(t,e){return H.create(this.x+t.x,this.y+t.y,e)}plusXY(t=0,e=0,i){return H.create(this.x+t,this.y+e,i)}plusScaled(t,e,i){return H.create(this.x+t.x*e,this.y+t.y*e,i)}plus2Scaled(t,e,i,n,s){return H.create(this.x+t.x*e+i.x*n,this.y+t.y*e+i.y*n,s)}plus3Scaled(t,e,i,n,s,r,o){return H.create(this.x+t.x*e+i.x*n+s.x*r,this.y+t.y*e+i.y*n+s.y*r,o)}scaleInPlace(t){this.x*=t,this.y*=t}dotVectorsToTargets(t,e){return(t.x-this.x)*(e.x-this.x)+(t.y-this.y)*(e.y-this.y)}crossProductToPoints(t,e){const i=t.x-this.x,n=t.y-this.y,s=e.x-this.x;return i*(e.y-this.y)-n*s}fractionOfProjectionToLine(t,e,i=0){const n=t.distanceSquared(e);return n<J.smallMetricDistanceSquared?i:t.dotVectorsToTargets(e,this)/n}}class j extends Q{constructor(t=0,e=0){super(t,e)}clone(t){return j.create(this.x,this.y,t)}static create(t=0,e=0,i){return i?(i.x=t,i.y=e,i):new j(t,e)}static unitX(t=1){return new j(t,0)}static unitY(t=1){return new j(0,t)}static createZero(t){return j.create(0,0,t)}static createFrom(t,e){return t instanceof Float64Array?t.length>=2?j.create(t[0],t[1]):t.length>=1?j.create(t[0],0):j.create(0,0):j.create(t.x,t.y,e)}static fromJSON(t){const e=new j;return e.setFromJSON(t),e}static createPolar(t,e){return j.create(t*e.cos(),t*e.sin())}static createStartEnd(t,e,i){return j.create(e.x-t.x,e.y-t.y,i)}static createOffsetBisector(t,e,i){let n=t.plus(e);if(n=n.normalize(),n){const e=n.dotProduct(t);return n.scale(i,n),n.safeDivideOrNull(e)}}safeDivideOrNull(t,e){if(0!==t)return this.scale(1/t,e)}normalize(t){const e=J.correctSmallFraction(this.magnitude());return t=t||new j,this.safeDivideOrNull(e,t)}fractionOfProjectionToVector(t,e){const i=t.magnitudeSquared();return i<J.smallMetricDistanceSquared?e||0:this.dotProduct(t)/i}negate(t){return(t=t||new j).x=-this.x,t.y=-this.y,t}rotate90CCWXY(t){t=t||new j;const e=this.x,i=this.y;return t.x=-i,t.y=e,t}rotate90CWXY(t){t=t||new j;const e=this.x,i=this.y;return t.x=i,t.y=-e,t}unitPerpendicularXY(t){t=t||new j;const e=this.x,i=this.y;t.x=-i,t.y=e;const n=e*e+i*i;if(0!==n){const e=1/Math.sqrt(n);t.x*=e,t.y*=e}return t}rotateXY(t,e){const i=t.sin(),n=t.cos(),s=this.x,r=this.y;return(e=e||new j).x=s*n-r*i,e.y=s*i+r*n,e}interpolate(t,e,i){if(i=i||new j,t<=.5)i.x=this.x+t*(e.x-this.x),i.y=this.y+t*(e.y-this.y);else{const n=t-1;i.x=e.x+n*(e.x-this.x),i.y=e.y+n*(e.y-this.y)}return i}plus(t,e){return(e=e||new j).x=this.x+t.x,e.y=this.y+t.y,e}minus(t,e){return(e=e||new j).x=this.x-t.x,e.y=this.y-t.y,e}plusScaled(t,e,i){return(i=i||new j).x=this.x+t.x*e,i.y=this.y+t.y*e,i}plus2Scaled(t,e,i,n,s){return(s=s||new j).x=this.x+t.x*e+i.x*n,s.y=this.y+t.y*e+i.y*n,s}plus3Scaled(t,e,i,n,s,r,o){return(o=o||new j).x=this.x+t.x*e+i.x*n+s.x*r,o.y=this.y+t.y*e+i.y*n+s.y*r,o}scale(t,e){return(e=e||new j).x=this.x*t,e.y=this.y*t,e}scaleToLength(t,e){const i=J.correctSmallFraction(this.magnitude());if(0!==i)return this.scale(t/i,e)}dotProduct(t){return this.x*t.x+this.y*t.y}dotProductStartEnd(t,e){return this.x*(e.x-t.x)+this.y*(e.y-t.y)}crossProduct(t){return this.x*t.y-this.y*t.x}radiansTo(t){return Math.atan2(this.crossProduct(t),this.dotProduct(t))}angleTo(t){return G.createRadians(this.radiansTo(t))}isParallelTo(t,e=!1,i=!1,n){const s=n?.radianSquaredTol??J.smallAngleRadiansSquared,r=n?.distanceSquaredTol??J.smallMetricDistanceSquared,o=this.magnitudeSquared(),a=t.magnitudeSquared();if(o<r||a<r)return i;if(this.dotProduct(t)<0&&!e)return!1;const c=this.crossProduct(t);return c*c<=s*o*a}isPerpendicularTo(t,e=!1,i){const n=i?.radianSquaredTol??J.smallAngleRadiansSquared,s=i?.distanceSquaredTol??J.smallMetricDistanceSquared,r=this.magnitudeSquared(),o=t.magnitudeSquared();if(r<s||o<s)return e;const a=this.dotProduct(t);return a*a<=n*r*o}}!function(t){t[t.XYZ=0]="XYZ",t[t.YZX=1]="YZX",t[t.ZXY=2]="ZXY",t[t.XZY=4]="XZY",t[t.YXZ=5]="YXZ",t[t.ZYX=6]="ZYX"}(f||(f={})),function(t){t[t.X=0]="X",t[t.Y=1]="Y",t[t.Z=2]="Z"}(g||(g={})),function(t){t[t.Top=1]="Top",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t[t.Right=4]="Right",t[t.Front=5]="Front",t[t.Back=6]="Back",t[t.Iso=7]="Iso",t[t.RightIso=8]="RightIso"}(p||(p={})),function(t){t[t.Unit=0]="Unit",t[t.LongestRangeDirection=1]="LongestRangeDirection",t[t.NonUniformRangeContainment=2]="NonUniformRangeContainment"}(m||(m={})),function(t){t[t.Unknown=0]="Unknown",t[t.OnPolygonVertex=1]="OnPolygonVertex",t[t.OnPolygonEdgeInterior=2]="OnPolygonEdgeInterior",t[t.InsidePolygon=3]="InsidePolygon",t[t.InsidePolygonProjectsToVertex=4]="InsidePolygonProjectsToVertex",t[t.InsidePolygonProjectsToEdgeInterior=5]="InsidePolygonProjectsToEdgeInterior",t[t.OutsidePolygon=6]="OutsidePolygon",t[t.OutsidePolygonProjectsToVertex=7]="OutsidePolygonProjectsToVertex",t[t.OutsidePolygonProjectsToEdgeInterior=8]="OutsidePolygonProjectsToEdgeInterior"}(_||(_={}));class J{static smallMetricDistance=1e-6;static smallMetricDistanceSquared=1e-12;static smallAngleRadians=1e-12;static smallAngleRadiansSquared=1e-24;static smallAngleDegrees=57e-12;static smallAngleSeconds=2e-7;static smallFraction=1e-10;static smallFloatingPoint=1e-15;static fullCircleRadiansMinusSmallAngle=2*Math.PI-J.smallAngleRadians;static largeFractionResult=1e10;static largeCoordinateResult=1e13;static hugeCoordinate=1e12;static isLargeCoordinateResult(t){return t>=this.largeCoordinateResult||t<=-this.largeCoordinateResult}static isHugeCoordinate(t){return J.isLargeCoordinateResult(t)}static isOdd(t){return!(1&~t)}static correctSmallMetricDistance(t,e=0){return void 0===t||Math.abs(t)<=J.smallMetricDistance?e:t}static correctSmallFraction(t,e=0){return void 0===t||Math.abs(t)<=J.smallFraction?e:t}static inverseMetricDistance(t){return Math.abs(t)<=J.smallMetricDistance?void 0:1/t}static inverseMetricDistanceSquared(t){return Math.abs(t)<=J.smallMetricDistanceSquared?void 0:1/t}static isSameCoordinate(t,e,i=J.smallMetricDistance){let n=t-e;return n<0&&(n=-n),n<=i}static isSameCoordinateWithToleranceFactor(t,e,i){return J.isSameCoordinate(t,e,i*J.smallMetricDistance)}static isSameCoordinateXY(t,e,i,n,s=J.smallMetricDistance){let r=i-t;return r<0&&(r=-r),!(r>s)&&(r=n-e,r<0&&(r=-r),r<=s)}static isSameCoordinateSquared(t,e,i=J.smallMetricDistance){return Math.abs(Math.sqrt(t)-Math.sqrt(e))<=i}static isSamePoint3d(t,e,i=J.smallMetricDistance){return t.distance(e)<=i}static isSameXYZ(t,e,i=J.smallMetricDistance){return t.distance(e)<=i}static isSamePoint3dXY(t,e,i=J.smallMetricDistance){return t.distanceXY(e)<=i}static isSameVector3d(t,e,i=J.smallMetricDistance){return t.distance(e)<=i}static isSamePoint2d(t,e,i=J.smallMetricDistance){return t.distance(e)<=i}static isSameVector2d(t,e,i=J.smallMetricDistance){return t.distance(e)<=i}static lexicalXYLessThan(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}static lexicalYXLessThan(t,e){return t.y<e.y?-1:t.y>e.y?1:t.x<e.x?-1:t.x>e.x?1:0}static lexicalXYZLessThan(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:t.z<e.z?-1:t.z>e.z?1:0}static isSmallRelative(t){return Math.abs(t)<=J.smallFraction}static isSmallAngleRadians(t){return Math.abs(t)<=J.smallAngleRadians}static isSmallAngleRadiansSquared(t){return Math.abs(t)<=J.smallAngleRadiansSquared}static isAlmostEqualOptional(t,e,i){if(void 0!==t&&void 0!==e){if(Math.abs(t-e)>i)return!1}else if(void 0!==t||void 0!==e)return!1;return!0}static isAlmostEqualNumber(t,e,i=J.smallAngleRadians){const n=1+Math.abs(t)+Math.abs(e);return Math.abs(t-e)<=i*n}static isAlmostEqualEitherNumber(t,e,i,n=J.smallAngleRadians){return this.isAlmostEqualNumber(t,e,n)||this.isAlmostEqualNumber(t,i,n)}static isAlmostEqualAnyNumber(t,e,i=J.smallAngleRadians){const n=Array.isArray(e)?t=>e[t]:e.iter;for(let s=0;s<e.length;s++)if(this.isAlmostEqualNumber(t,n(s),i))return!0;return!1}static isAlmostEqualXAndY(t,e,i=J.smallAngleRadians){const n=i*(1+Math.abs(t.x)+Math.abs(e.x)+Math.abs(t.y)+Math.abs(e.y));return Math.abs(t.x-e.x)<=n&&Math.abs(t.y-e.y)<=n}static isDistanceWithinTol(t,e=J.smallMetricDistance){return Math.abs(t)<=e}static isSmallMetricDistance(t){return Math.abs(t)<=J.smallMetricDistance}static isSmallMetricDistanceSquared(t){return Math.abs(t)<=J.smallMetricDistanceSquared}static cyclic3dAxis(t){if(t>=0)return t<3?t:t<6?t-3:t%3;const e=t+3;return e>=0?e:2-(-t-1)%3}static axisIndexToRightHandedAxisOrder(t){return 0===t?f.XYZ:1===t?f.YZX:2===t?f.ZXY:J.axisIndexToRightHandedAxisOrder(J.cyclic3dAxis(t))}static maxXYZ(t,e,i){let n=t;return e>n&&(n=e),i>n&&(n=i),n}static minXYZ(t,e,i){let n=t;return e<n&&(n=e),i<n&&(n=i),n}static maxXY(t,e){let i=t;return e>i&&(i=e),i}static minXY(t,e){let i=t;return e<i&&(i=e),i}static maxAbsXYZ(t,e,i){return J.maxXYZ(Math.abs(t),Math.abs(e),Math.abs(i))}static maxAbsXY(t,e){return J.maxXY(Math.abs(t),Math.abs(e))}static maxAbsDiff(t,e,i){return Math.max(Math.abs(t-e),Math.abs(t-i))}static split3WaySign(t,e,i,n){return t<0?e:t>0?n:i}static split3Way01(t,e=J.smallMetricDistance){return t>e?1:t<-e?-1:0}static square(t){return t*t}static hypotenuseXY(t,e){return Math.sqrt(t*t+e*e)}static hypotenuseSquaredXY(t,e){return t*t+e*e}static hypotenuseXYZ(t,e,i){return Math.sqrt(t*t+e*e+i*i)}static hypotenuseSquaredXYZ(t,e,i){return t*t+e*e+i*i}static hypotenuseXYZW(t,e,i,n){return Math.sqrt(t*t+e*e+i*i+n*n)}static hypotenuseSquaredXYZW(t,e,i,n){return t*t+e*e+i*i+n*n}static distanceXYXY(t,e,i,n){return J.hypotenuseXY(i-t,n-e)}static distanceSquaredXYXY(t,e,i,n){return J.hypotenuseSquaredXY(i-t,n-e)}static distanceXYZXYZ(t,e,i,n,s,r){return J.hypotenuseXYZ(n-t,s-e,r-i)}static tripleProduct(t,e,i,n,s,r,o,a,c){return t*(s*c-r*a)+e*(r*o-n*c)+i*(n*a-s*o)}static determinant4x4(t,e,i,n,s,r,o,a,c,l,h,d,u,f,g,p){return t*this.tripleProduct(r,o,a,l,h,d,f,g,p)-s*this.tripleProduct(e,i,n,l,h,d,f,g,p)+c*this.tripleProduct(e,i,n,r,o,a,f,g,p)-u*this.tripleProduct(e,i,n,r,o,a,l,h,d)}static tripleProductXYW(t,e,i,n,s,r){return J.tripleProduct(t.x,i.x,s.x,t.y,i.y,s.y,e,n,r)}static tripleProductPoint4dXYW(t,e,i){return J.tripleProduct(t.x,e.x,i.x,t.y,e.y,i.y,t.w,e.w,i.w)}static crossProductXYXY(t,e,i,n){return t*n-e*i}static crossProductXYZXYZ(t,e,i,n,s,r,o){return tt.create(e*r-i*s,i*n-t*r,t*s-e*n,o)}static crossProductMagnitude(t,e,i,n,s,r){return J.hypotenuseXYZ(e*r-i*s,i*n-t*r,t*s-e*n)}static dotProductXYXY(t,e,i,n){return t*i+e*n}static dotProductXYZXYZ(t,e,i,n,s,r){return t*n+e*s+i*r}static meanCurvatureOfRadii(t,e){return.5*(this.safeDivideFraction(1,t,0)+this.safeDivideFraction(1,e,0))}static curvatureMagnitude(t,e,i,n,s,r){let o=e*r-i*s,a=o*o;o=i*n-t*r,a+=o*o,o=t*s-e*n,a+=o*o;const c=Math.sqrt(a),l=Math.sqrt(t*t+e*e+i*i),h=l*l*l;return h>J.smallAngleRadians*c?c/h:0}static clampToStartEnd(t,e,i){return e>i?J.clampToStartEnd(t,i,e):t<e?e:i<t?i:t}static clamp(t,e,i){return Math.max(e,Math.min(i,t))}static resolveNumber(t,e=0){return void 0!==t?t:e}static resolveValue(t,e){return void 0!==t?t:e}static resolveToUndefined(t,e){return t===e?void 0:t}static interpolate(t,e,i){return e<=.5?t+e*(i-t):i-(1-e)*(i-t)}static interpolateByte(t,e,i,n){return t=t>>>n&255,i=i>>>n&255,(255&Math.floor(t+e*(i-t)))<<n}static interpolateColor(t,e,i){return e=J.clamp(e,0,1),this.interpolateByte(t,e,i,0)|this.interpolateByte(t,e,i,8)|this.interpolateByte(t,e,i,16)|this.interpolateByte(t,e,i,24)}static axisOrderToAxis(t,e){const i=t<=f.ZXY?t+e:t-f.XZY-e;return J.cyclic3dAxis(i)}static modulo(t,e){if(e<=0)return 0===e?t:-J.modulo(-t,-e);if(t>=0){if(t<e)return t;if(t<2*e)return t-e}else if((t+=e)>0)return t;return t-Math.floor(t/e)*e}static defined01(t){return void 0===t?0:1}static conditionalDivideFraction(t,e){if(0!==e)return Math.abs(e)*J.largeFractionResult>=Math.abs(t)?t/e:void 0}static safeDivideFraction(t,e,i){const n=J.conditionalDivideFraction(t,e);return void 0!==n?n:i}static conditionalDivideCoordinate(t,e,i=J.largeCoordinateResult){if(0!==e)return Math.abs(e*i)>=Math.abs(t)?t/e:void 0}static solveTrigForm(t,e,i){const n=e*e+i*i;let s;if(n>0){const r=1/n,o=1-t*t*r;if(o<-J.smallMetricDistanceSquared)return s;const a=-t*r,c=a*e,l=a*i;if(o<=J.smallMetricDistanceSquared)s=[j.create(c,l)];else{const t=Math.sqrt(o*r);s=[j.create(c-t*i,l+t*e),j.create(c+t*i,l-t*e)]}}return s}static inverseInterpolate(t,e,i,n,s=0,r){const o=J.conditionalDivideFraction(s-e,n-e);return void 0!==o?J.interpolate(t,o,i):r}static inverseInterpolate01(t,e,i=0){return J.conditionalDivideFraction(i-t,e-t)}static isNumberArray(t,e=0){if(Array.isArray(t)&&t.length>=e){let e;for(e of t)if(!Number.isFinite(e))return!1;return!0}return!1}static isArrayOfNumberArray(t,e,i=0){if(Array.isArray(t)&&t.length>=e){let e;for(e of t)if(!J.isNumberArray(e,i))return!1;return!0}return!1}static stepCount(t,e,i=1,n=101){if(t<=0)return i;if(t>=(e=Math.abs(e)))return i;const s=Math.floor((e+.999999*t)/t);return s<i?i:s>n?n:s}static isIn01(t,e=!0){return!e||t>=0&&t<=1}static isIn01WithTolerance(t,e){return t+(e=Math.abs(e))>=0&&t-e<=1}static restrictToInterval(t,e,i){return e<=i?t<e?e:t>i?i:t:t<i?i:t>e?e:t}static equalStringNoCase(t,e){return t.toUpperCase()===e.toUpperCase()}static exactEqualNumberArrays(t,e){if(Array.isArray(t)&&0===t.length&&(t=void 0),Array.isArray(e)&&0===e.length&&(e=void 0),void 0===t&&void 0===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}return!1}static almostEqualArrays(t,e,i){if(Array.isArray(t)&&0===t.length&&(t=void 0),Array.isArray(e)&&0===e.length&&(e=void 0),void 0===t&&void 0===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}return!1}static almostEqualNumberArrays(t,e,i){if(Array.isArray(t)&&0===t.length&&(t=void 0),Array.isArray(e)&&0===e.length&&(e=void 0),void 0===t&&void 0===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}return!1}static areEqualAllowUndefined(t,e,i=!0){return void 0===t&&void 0===e?i:void 0!==t&&void 0!==e&&t===e}static cloneMembers(t){if(void 0===t)return;const e=[];for(const i of t)e.push(i.clone());return e}static cloneArray(t){if(void 0===t)return;const e=[];for(const i of t)e.push(i.clone());return e}}!function(t){t.almostEqual=function(t,e,i){return J.isSameCoordinate(t.x,e.x,i)&&J.isSameCoordinate(t.y,e.y,i)&&J.isSameCoordinate(t.z,e.z,i)}}(x||(x={}));class K{x;y;z;set(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}setZero(){this.x=0,this.y=0,this.z=0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}static isXAndY(t){return void 0!==t.x&&void 0!==t.y}static hasZ(t){return void 0!==t.z}static isXYAndZ(t){return this.isXAndY(t)&&this.hasZ(t)}static isAnyImmediatePointType(t){return $.isXAndY(t)||J.isNumberArray(t,2)}static accessX(t,e){return void 0!==t.x?t.x:Array.isArray(t)&&t.length>0&&Number.isFinite(t[0])?t[0]:e}static accessY(t,e){return void 0!==t.y?t.y:Array.isArray(t)&&t.length>1&&Number.isFinite(t[1])?t[1]:e}static accessZ(t,e){return void 0!==t.z?t.z:Array.isArray(t)&&t.length>2&&Number.isFinite(t[2])?t[2]:e}setFrom(t){void 0===t?this.setZero():K.isXAndY(t)?(this.x=t.x,this.y=t.y,this.z=K.hasZ(t)?t.z:0):(this.x=t[0],this.y=t[1],this.z=t[2])}setFromPoint3d(t){t?(this.x=t.x,this.y=t.y,this.z=t.z):this.setZero()}setFromVector3d(t){t?(this.x=t.x,this.y=t.y,this.z=t.z):this.setZero()}isAlmostEqual(t,e){return x.almostEqual(this,t,e)}isAlmostEqualXYZ(t,e,i,n){return J.isSameCoordinate(this.x,t,n)&&J.isSameCoordinate(this.y,e,n)&&J.isSameCoordinate(this.z,i,n)}isAlmostEqualPointPlusScaledVector(t,e,i,n){return J.isSameCoordinate(this.x,t.x+e.x*i,n)&&J.isSameCoordinate(this.y,t.y+e.y*i,n)&&J.isSameCoordinate(this.z,t.z+e.z*i,n)}isAlmostEqualXY(t,e){return J.isSameCoordinate(this.x,t.x,e)&&J.isSameCoordinate(this.y,t.y,e)}toJSON(){return this.toArray()}toArray(){return[this.x,this.y,this.z]}toJSONXYZ(){return{x:this.x,y:this.y,z:this.z}}toFloat64Array(){return Float64Array.of(this.x,this.y,this.z)}setFromJSON(t){Array.isArray(t)?this.set(t[0]||0,t[1]||0,t[2]||0):t?this.set(t.x||0,t.y||0,t.z||0):this.set(0,0,0)}distance(t){const e=t.x-this.x,i=t.y-this.y,n=t.z-this.z;return Math.sqrt(e*e+i*i+n*n)}distanceSquared(t){const e=t.x-this.x,i=t.y-this.y,n=t.z-this.z;return e*e+i*i+n*n}distanceXY(t){const e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)}distanceSquaredXY(t){const e=t.x-this.x,i=t.y-this.y;return e*e+i*i}maxDiff(t){return Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y),Math.abs(this.z-t.z))}at(t){return t<.5?this.x:t>1.5?this.z:this.y}setAt(t,e){t<.5?this.x=e:t>1.5?this.z=e:this.y=e}indexOfMaxAbs(){let t=0,e=Math.abs(this.x),i=Math.abs(this.y);return i>e&&(t=1,e=i),i=Math.abs(this.z),i>e&&(t=2),t}get isAlmostZero(){return J.isSmallMetricDistance(this.x)&&J.isSmallMetricDistance(this.y)&&J.isSmallMetricDistance(this.z)}get isZero(){return 0===this.x&&0===this.y&&0===this.z}maxAbs(){return Math.max(Math.abs(this.x),Math.abs(this.y),Math.abs(this.z))}magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}magnitudeSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}magnitudeXY(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitudeSquaredXY(){return this.x*this.x+this.y*this.y}isExactEqual(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}isAlmostEqualMetric(t){return this.maxDiff(t)<=J.smallMetricDistance}addInPlace(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}subtractInPlace(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}addScaledInPlace(t,e){this.x+=e*t.x,this.y+=e*t.y,this.z+=e*t.z}scaleInPlace(t){this.x*=t,this.y*=t,this.z*=t}addXYZInPlace(t=0,e=0,i=0){this.x+=t,this.y+=e,this.z+=i}cloneAsPoint3d(){return $.create(this.x,this.y,this.z)}vectorTo(t,e){return tt.create(t.x-this.x,t.y-this.y,t.z-this.z,e)}scaledVectorTo(t,e,i){return tt.create(e*(t.x-this.x),e*(t.y-this.y),e*(t.z-this.z),i)}unitVectorTo(t,e){return this.vectorTo(t,e).normalize(e)}freeze(){return Object.freeze(this)}static x(t,e=0){return void 0===t?e:Array.isArray(t)?t[0]:void 0!==t.x?t.x:e}static y(t,e=0){return void 0===t?e:Array.isArray(t)?t[1]:void 0!==t.y?t.y:e}static z(t,e=0){return void 0===t?e:Array.isArray(t)?t[2]:void 0!==t.z?t.z:e}}class $ extends K{constructor(t=0,e=0,i=0){super(t,e,i)}static fromJSON(t){const e=new $;return e.setFromJSON(t),e}clone(t){return $.create(this.x,this.y,this.z,t)}static create(t=0,e=0,i=0,n){return n?(n.x=t,n.y=e,n.z=i,n):new $(t,e,i)}static createFrom(t,e){if(t instanceof Float64Array){let i=0,n=0,s=0;return t.length>0&&(i=t[0]),t.length>1&&(n=t[1]),t.length>2&&(s=t[2]),$.create(i,n,s,e)}return $.create(t.x,t.y,K.hasZ(t)?t.z:0,e)}static createFromPacked(t,e,i){const n=3*e;if(n>=0&&n+2<t.length)return $.create(t[n],t[n+1],t[n+2],i)}static createFromPackedXYZW(t,e,i){const n=4*e;if(n>=0&&n+3<t.length){const e=t[n+3];if(!J.isSmallMetricDistance(e)){const s=1/e;return $.create(s*t[n],s*t[n+1],s*t[n+2],i)}}}static createArrayFromPackedXYZ(t){const e=[];for(let i=0;i+2<t.length;i+=3)e.push(new $(t[i],t[i+1],t[i+2]));return e}static createZero(t){return $.create(0,0,0,t)}crossProductToPoints(t,e,i){return tt.createCrossProduct(t.x-this.x,t.y-this.y,t.z-this.z,e.x-this.x,e.y-this.y,e.z-this.z,i)}crossProductToPointsMagnitude(t,e){return J.crossProductMagnitude(t.x-this.x,t.y-this.y,t.z-this.z,e.x-this.x,e.y-this.y,e.z-this.z)}tripleProductToPoints(t,e,i){return J.tripleProduct(t.x-this.x,t.y-this.y,t.z-this.z,e.x-this.x,e.y-this.y,e.z-this.z,i.x-this.x,i.y-this.y,i.z-this.z)}crossProductToPointsXY(t,e){return J.crossProductXYXY(t.x-this.x,t.y-this.y,e.x-this.x,e.y-this.y)}interpolate(t,e,i){if(t<=.5)return $.create(this.x+t*(e.x-this.x),this.y+t*(e.y-this.y),this.z+t*(e.z-this.z),i);const n=t-1;return $.create(e.x+n*(e.x-this.x),e.y+n*(e.y-this.y),e.z+n*(e.z-this.z),i)}interpolateXYZ(t,e,i,n,s){return $.create(J.interpolate(this.x,t,n.x),J.interpolate(this.y,e,n.y),J.interpolate(this.z,i,n.z),s)}interpolatePerpendicularXY(t,e,i,n){n=n||new $;const s=e.minus(this);return this.interpolate(t,e,n),n.x-=i*s.y,n.y+=i*s.x,n}minus(t,e){return $.create(this.x-t.x,this.y-t.y,this.z-t.z,e)}plus(t,e){return $.create(this.x+t.x,this.y+t.y,this.z+t.z,e)}plusXYZ(t=0,e=0,i=0,n){return $.create(this.x+t,this.y+e,this.z+i,n)}plusScaled(t,e,i){return $.create(this.x+t.x*e,this.y+t.y*e,this.z+t.z*e,i)}plus2Scaled(t,e,i,n,s){return $.create(this.x+t.x*e+i.x*n,this.y+t.y*e+i.y*n,this.z+t.z*e+i.z*n,s)}plus3Scaled(t,e,i,n,s,r,o){return $.create(this.x+t.x*e+i.x*n+s.x*r,this.y+t.y*e+i.y*n+s.y*r,this.z+t.z*e+i.z*n+s.z*r,o)}static createScale(t,e,i){return $.create(t.x*e,t.y*e,t.z*e,i)}static createAdd2Scaled(t,e,i,n,s){return $.create(t.x*e+i.x*n,t.y*e+i.y*n,t.z*e+i.z*n,s)}static createAdd3Scaled(t,e,i,n,s,r,o){return $.create(t.x*e+i.x*n+s.x*r,t.y*e+i.y*n+s.y*r,t.z*e+i.z*n+s.z*r,o)}dotVectorsToTargets(t,e){return(t.x-this.x)*(e.x-this.x)+(t.y-this.y)*(e.y-this.y)+(t.z-this.z)*(e.z-this.z)}fractionOfProjectionToLine(t,e,i=0){const n=t.distanceSquared(e);return n<J.smallMetricDistanceSquared?i:t.dotVectorsToTargets(e,this)/n}}class tt extends K{constructor(t=0,e=0,i=0){super(t,e,i)}static createArrayFromPackedXYZ(t){const e=[];for(let i=0;i+2<t.length;i+=3)e.push(new tt(t[i],t[i+1],t[i+2]));return e}clone(t){return tt.create(this.x,this.y,this.z,t)}static create(t=0,e=0,i=0,n){return n?(n.x=t,n.y=e,n.z=i,n):new tt(t,e,i)}static createCrossProduct(t,e,i,n,s,r,o){return tt.create(e*r-i*s,i*n-t*r,t*s-e*n,o)}addCrossProductToTargetsInPlace(t,e,i,n,s,r,o,a,c){const l=n-t,h=s-e,d=r-i,u=o-t,f=a-e,g=c-i;this.x+=h*g-d*f,this.y+=d*u-l*g,this.z+=l*f-h*u}static createCrossProductToPoints(t,e,i,n){return tt.createCrossProduct(e.x-t.x,e.y-t.y,e.z-t.z,i.x-t.x,i.y-t.y,i.z-t.z,n)}static createUnitCrossProductToPoints(t,e,i,n){return tt.createCrossProduct(e.x-t.x,e.y-t.y,e.z-t.z,i.x-t.x,i.y-t.y,i.z-t.z,n).normalize()}static createPolar(t,e,i){return tt.create(t*e.cos(),t*e.sin(),i)}static createSpherical(t,e,i){const n=i.cos();return tt.create(n*t*e.cos(),n*t*e.sin(),t*i.sin())}static fromJSON(t){const e=new tt;return e.setFromJSON(t),e}static createFrom(t,e){if(t instanceof Float64Array){let i=0,n=0,s=0;return t.length>0&&(i=t[0]),t.length>1&&(n=t[1]),t.length>2&&(s=t[2]),tt.create(i,n,s,e)}return Array.isArray(t)?tt.create(t[0],t[1],t.length>2?t[2]:0):tt.create(t.x,t.y,K.hasZ(t)?t.z:0,e)}static createStartEnd(t,e,i){const n=K.accessZ(t,0),s=K.accessZ(e,0)-n;return i?(i.set(e.x-t.x,e.y-t.y,s),i):new tt(e.x-t.x,e.y-t.y,s)}static createStartEndXYZXYZ(t,e,i,n,s,r,o){return this.create(n-t,s-e,r-i,o)}static createRotateVectorAroundVector(t,e,i){const n=e.normalize();if(n){const e=n.crossProduct(t);let s,r;return i?(s=i.cos(),r=i.sin()):(s=0,r=1),tt.createAdd3Scaled(t,s,e,r,n,n.dotProduct(t)*(1-s))}}setStartEnd(t,e){this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z}static createZero(t){return tt.create(0,0,0,t)}static unitX(t=1){return new tt(t,0,0)}static unitY(t=1){return new tt(0,t,0)}static unitZ(t=1){return new tt(0,0,t)}safeDivideOrNull(t,e){if(0!==t)return this.scale(1/t,e)}normalizeWithLength(t){const e=this.magnitude(),i=J.correctSmallFraction(e);return t=t||new tt,{v:this.safeDivideOrNull(i,t),mag:e}}normalize(t){return this.normalizeWithLength(t).v}normalizeInPlace(){return void 0!==this.normalizeWithLength(this).v}static createNormalized(t=0,e=0,i=0,n){if(void 0===n?n=tt.create(t,e,i):n.set(t,e,i),n.normalizeInPlace())return n}static createNormalizedStartEnd(t,e,i){if((i=tt.createStartEnd(t,e,i)).normalizeInPlace())return i}fractionOfProjectionToVector(t,e=0){const i=t.magnitudeSquared();return i<J.smallMetricDistanceSquared?e:this.dotProduct(t)/i}negate(t){return(t=t||new tt).x=-this.x,t.y=-this.y,t.z=-this.z,t}rotate90CCWXY(t){t=t||new tt;const e=this.x,i=this.y;return t.x=-i,t.y=e,t.z=this.z,t}rotate90CWXY(t){t=t||new tt;const e=this.x,i=this.y;return t.x=i,t.y=-e,t.z=this.z,t}unitPerpendicularXY(t){t=t||new tt;const e=this.x,i=this.y;t.x=-i,t.y=e,t.z=0;const n=e*e+i*i;if(0!==n){const e=1/Math.sqrt(n);t.x*=e,t.y*=e}return t}rotateXY(t,e){const i=t.sin(),n=t.cos(),s=this.x,r=this.y;return(e=e||new tt).x=s*n-r*i,e.y=s*i+r*n,e.z=this.z,e}rotate90Towards(t,e){const i=this.crossProduct(t).normalize();return i?i.crossProduct(this,e):void 0}rotate90Around(t,e){const i=t.normalize();return i?i.crossProduct(this).plusScaled(i,i.dotProduct(this),e):void 0}interpolate(t,e,i){if(i=i||new tt,t<=.5)i.x=this.x+t*(e.x-this.x),i.y=this.y+t*(e.y-this.y),i.z=this.z+t*(e.z-this.z);else{const n=t-1;i.x=e.x+n*(e.x-this.x),i.y=e.y+n*(e.y-this.y),i.z=e.z+n*(e.z-this.z)}return i}plus(t,e){return(e=e||new tt).x=this.x+t.x,e.y=this.y+t.y,e.z=this.z+t.z,e}minus(t,e){return(e=e||new tt).x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z,e}plusScaled(t,e,i){return(i=i||new tt).x=this.x+t.x*e,i.y=this.y+t.y*e,i.z=this.z+t.z*e,i}plus2Scaled(t,e,i,n,s){return(s=s||new tt).x=this.x+t.x*e+i.x*n,s.y=this.y+t.y*e+i.y*n,s.z=this.z+t.z*e+i.z*n,s}plus3Scaled(t,e,i,n,s,r,o){return(o=o||new tt).x=this.x+t.x*e+i.x*n+s.x*r,o.y=this.y+t.y*e+i.y*n+s.y*r,o.z=this.z+t.z*e+i.z*n+s.z*r,o}static createAdd2Scaled(t,e,i,n,s){return tt.create(t.x*e+i.x*n,t.y*e+i.y*n,t.z*e+i.z*n,s)}static createAdd2ScaledXYZ(t,e,i,n,s,r,o,a,c){return tt.create(t*n+s*a,e*n+r*a,i*n+o*a,c)}static createAdd3Scaled(t,e,i,n,s,r,o){return tt.create(t.x*e+i.x*n+s.x*r,t.y*e+i.y*n+s.y*r,t.z*e+i.z*n+s.z*r,o)}scale(t,e){return(e=e||new tt).x=this.x*t,e.y=this.y*t,e.z=this.z*t,e}scaleToLength(t,e){const i=J.correctSmallFraction(this.magnitude());if(0!==i)return this.scale(t/i,e)}unitCrossProduct(t,e){return this.crossProduct(t,e).normalize(e)}unitCrossProductWithDefault(t,e,i,n,s){const r=this.crossProduct(t,s).normalize(s);return void 0===r?tt.create(e,i,n,s):r}normalizeWithDefault(t,e,i,n){return this.normalize(n)||((n=tt.create(t,e,i,n)).normalizeInPlace()?n:tt.create(1,0,0,n))}tryNormalizeInPlace(t=J.smallFraction){const e=this.magnitude();return!(e<t||0===e||(this.scaleInPlace(1/e),0))}sizedCrossProduct(t,e,i){if((i=this.crossProduct(t,i)).tryNormalizeInPlace())return i.scaleInPlace(e),i}crossProductMagnitudeSquared(t){const e=this.y*t.z-this.z*t.y,i=this.z*t.x-this.x*t.z,n=this.x*t.y-this.y*t.x;return e*e+i*i+n*n}crossProductMagnitude(t){return Math.sqrt(this.crossProductMagnitudeSquared(t))}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}static dotProductAsXYAndZ(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}dotProductStartEnd(t,e){return this.x*(e.x-t.x)+this.y*(e.y-t.y)+this.z*(e.z-t.z)}dotProductStart3dEnd4d(t,e){const i=e.w;return this.x*(e.x-t.x*i)+this.y*(e.y-t.y*i)+this.z*(e.z-t.z*i)}crossProductStartEnd(t,e,i){return tt.createCrossProduct(this.x,this.y,this.z,e.x-t.x,e.y-t.y,e.z-t.z,i)}crossProductStartEndXY(t,e){return J.crossProductXYXY(this.x,this.y,e.x-t.x,e.y-t.y)}dotProductStartEndXYZ(t,e,i,n){return this.x*(e-t.x)+this.y*(i-t.y)+this.z*(n-t.z)}dotProductStartEndXY(t,e){return this.x*(e.x-t.x)+this.y*(e.y-t.y)}dotProductStartEndXYZW(t,e,i,n,s){if(J.isSmallMetricDistance(s))return 0;const r=1/s;return this.x*(r*e-t.x)+this.y*(r*i-t.y)+this.z*(r*n-t.z)}dotProductXY(t){return this.x*t.x+this.y*t.y}dotProductXYZ(t,e,i=0){return this.x*t+this.y*e+this.z*i}tripleProduct(t,e){return J.tripleProduct(this.x,this.y,this.z,t.x,t.y,t.z,e.x,e.y,e.z)}crossProductXY(t){return this.x*t.y-this.y*t.x}crossProduct(t,e){return tt.createCrossProduct(this.x,this.y,this.z,t.x,t.y,t.z,e)}crossProductXYZ(t,e,i,n){return tt.createCrossProduct(this.x,this.y,this.z,t,e,i,n)}radiansTo(t){return Math.atan2(this.crossProductMagnitude(t),this.dotProduct(t))}angleTo(t){return G.createRadians(this.radiansTo(t))}angleFromPerpendicular(t){return G.createAtan2(this.dotProduct(t),this.crossProductMagnitude(t))}radiansFromPerpendicular(t){return Math.atan2(this.dotProduct(t),this.crossProductMagnitude(t))}angleToXY(t){return G.createAtan2(this.crossProductXY(t),this.dotProductXY(t))}signedRadiansTo(t,e){const i=this.crossProduct(t),n=Math.atan2(i.magnitude(),this.dotProduct(t));return e.dotProduct(i)<0?-n:n}signedAngleTo(t,e){return G.createRadians(this.signedRadiansTo(t,e))}planarRadiansTo(t,e){const i=e.dotProduct(e);if(0===i)return 0;const n=1/i,s=this.plusScaled(e,-this.dotProduct(e)*n),r=t.plusScaled(e,-t.dotProduct(e)*n);return s.signedRadiansTo(r,e)}planarAngleTo(t,e){return G.createRadians(this.planarRadiansTo(t,e))}smallerUnorientedRadiansTo(t){const e=this.dotProduct(t),i=this.crossProductMagnitude(t);return Math.atan2(Math.abs(i),Math.abs(e))}smallerUnorientedAngleTo(t){return G.createRadians(this.smallerUnorientedRadiansTo(t))}isParallelTo(t,e=!1,i=!1,n){const s=n?.radianSquaredTol??J.smallAngleRadiansSquared,r=n?.distanceSquaredTol??J.smallMetricDistanceSquared,o=this.magnitudeSquared(),a=t.magnitudeSquared();return o<r||a<r?i:!(this.dotProduct(t)<0&&!e)&&this.crossProductMagnitudeSquared(t)<=s*o*a}isPerpendicularTo(t,e=!1,i){const n=i?.radianSquaredTol??J.smallAngleRadiansSquared,s=i?.distanceSquaredTol??J.smallMetricDistanceSquared,r=this.magnitudeSquared(),o=t.magnitudeSquared();if(r<s||o<s)return e;const a=this.dotProduct(t);return a*a<=n*r*o}}class et{isPointInPlane(t,e=J.smallMetricDistance){return Math.abs(this.altitude(t))<=e}classifyAltitude(t,e=J.smallMetricDistance){return J.split3Way01(this.altitude(t),e)}classifyAltitudeXYZ(t,e,i,n=J.smallMetricDistance){return J.split3Way01(this.altitudeXYZ(t,e,i),n)}getUnitNormal(t){return tt.createNormalized(this.normalX(),this.normalY(),this.normalZ(),t)}getAnyPointOnPlane(t){return this.projectXYZToPlane(0,0,0,t)}projectXYZToPlane(t,