@mappedin/mappedin-js 5.48.0 → 5.49.0

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 +1 @@
1
- var g,tn=Object.create,le=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,nn=Object.getOwnPropertyNames,an=Object.getPrototypeOf,un=Object.prototype.hasOwnProperty,on=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,a=(e,t)=>le(e,"name",{value:t,configurable:!0}),sn=(e,t)=>()=>(e&&(t=e(e=0)),t),m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ln=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of nn(t))!un.call(e,a)&&a!==r&&le(e,a,{get:()=>t[a],enumerable:!(n=rn(t,a))||n.enumerable});return e},dn=(e,t,r)=>(r=null!=e?tn(an(e)):{},ln(!t&&e&&e.__esModule?r:le(r,"default",{value:e,enumerable:!0}),e)),D=(e,t,r)=>(on(e,"symbol"!=typeof t?t+"":t,r),r),s=sn((()=>{g={env:{NODE_ENV:"production",npm_package_version:"5.48.0"}}})),T=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.areaConversion=e.timeConversion=e.distanceConversion=e.altitudeKeys=e.latitudeKeys=e.longitudeKeys=e.MAXLON=e.MINLON=e.MAXLAT=e.MINLAT=e.earthRadius=e.sexagesimalPattern=void 0;e.sexagesimalPattern=/^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}(\.([0-9]{1,}))?)["″]\s*)?([NEOSW]?)$/;e.earthRadius=6378137;e.MINLAT=-90;e.MAXLAT=90;e.MINLON=-180;e.MAXLON=180;e.longitudeKeys=["lng","lon","longitude",0];e.latitudeKeys=["lat","latitude",1];e.altitudeKeys=["alt","altitude","elevation","elev",2];e.distanceConversion={m:1,km:.001,cm:100,mm:1e3,mi:1/1609.344,sm:1/1852.216,ft:100/30.48,in:100/2.54,yd:1/.9144};e.timeConversion={m:60,h:3600,d:86400};var t={m2:1,km2:1e-6,ha:1e-4,a:.01,ft2:10.763911,yd2:1.19599,in2:1550.0031};e.areaConversion=t,t.sqm=t.m2,t.sqkm=t.km2,t.sqft=t.ft2,t.sqyd=t.yd2,t.sqin=t.in2})),re=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e,t){return t.reduce((function(t,r){if(typeof e>"u"||null===e)throw new Error("'".concat(e,"' is no valid coordinate."));return Object.prototype.hasOwnProperty.call(e,r)&&typeof r<"u"&&typeof t>"u"?(t=r,r):t}),void 0)}),"getCoordinateKey");e.default=t})),ne=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){var t=e.toString().trim();return!isNaN(parseFloat(t))&&parseFloat(t)===Number(t)}),"isDecimal");e.default=t})),ae=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){return t.sexagesimalPattern.test(e.toString().trim())}),"isSexagesimal");e.default=r})),ie=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=new RegExp(t.sexagesimalPattern).exec(e);if(typeof r>"u"||null===r)throw new Error("Given value is not in sexagesimal format");var n=Number(r[2])/60||0,a=Number(r[4])/3600||0,i=parseFloat(r[1])+n+a;return["S","W"].includes(r[7])?-i:i}),"sexagesimalToDecimal");e.default=r})),he=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=n(re());function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(n,"_interopRequireDefault"),a(i,"ownKeys"),a(u,"_objectSpread"),a(o,"_defineProperty");var l=a((function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{longitude:t.longitudeKeys,latitude:t.latitudeKeys,altitude:t.altitudeKeys},a=(0,r.default)(e,n.longitude),i=(0,r.default)(e,n.latitude),o=(0,r.default)(e,n.altitude);return u({latitude:i,longitude:a},o?{altitude:o}:{})}),"getCoordinateKeys");e.default=l})),ht=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(ne()),r=u(ae()),n=u(ie()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function e(a){return(0,t.default)(a)?!(parseFloat(a)>i.MAXLAT||a<i.MINLAT):!!(0,r.default)(a)&&e((0,n.default)(a))}),"isValidLatitude");e.default=o})),pt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(ne()),r=u(ae()),n=u(ie()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function e(a){return(0,t.default)(a)?!(parseFloat(a)>i.MAXLON||a<i.MINLON):!!(0,r.default)(a)&&e((0,n.default)(a))}),"isValidLongitude");e.default=o})),yt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=i(he()),r=i(ht()),n=i(pt());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e){var a=(0,t.default)(e),i=a.latitude,u=a.longitude;if(Array.isArray(e)&&e.length>=2)return(0,n.default)(e[0])&&(0,r.default)(e[1]);if(typeof i>"u"||typeof u>"u")return!1;var o=e[u],l=e[i];return!(typeof l>"u"||typeof o>"u"||!1===(0,r.default)(l)||!1===(0,n.default)(o))}),"isValidCoordinate");e.default=u})),Me=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(ne()),r=o(ae()),n=o(ie()),i=o(yt()),u=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(o,"_interopRequireDefault"),a(l,"ownKeys"),a(d,"_objectSpread"),a(f,"_defineProperty");var c=a((function e(a){if((0,t.default)(a))return Number(a);if((0,r.default)(a))return(0,n.default)(a);if((0,i.default)(a)){var o=(0,u.default)(a);return Array.isArray(a)?a.map((function(t,r){return[0,1].includes(r)?e(t):t})):d(d(d({},a),o.latitude&&f({},o.latitude,e(a[o.latitude]))),o.longitude&&f({},o.longitude,e(a[o.longitude])))}return Array.isArray(a)?a.map((function(t){return(0,i.default)(t)?e(t):t})):a}),"toDecimal");e.default=c})),S=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=i(re()),n=i(Me());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e,a){var i=(0,r.default)(e,t.latitudeKeys);if(!(typeof i>"u"||null===i)){var u=e[i];return!0===a?u:(0,n.default)(u)}}),"getLatitude");e.default=u})),w=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=i(re()),n=i(Me());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e,a){var i=(0,r.default)(e,t.longitudeKeys);if(!(typeof i>"u"||null===i)){var u=e[i];return!0===a?u:(0,n.default)(u)}}),"getLongitude");e.default=u})),W=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return e*Math.PI/180}),"toRad");e.default=t})),Y=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return 180*e/Math.PI}),"toDeg");e.default=t})),nr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Y()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a,o){var l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6371e3,s=(0,t.default)(e),d=(0,r.default)(e),f=a/l,c=(0,n.default)(o),g=(0,n.default)(s),h=(0,n.default)(d),p=Math.asin(Math.sin(g)*Math.cos(f)+Math.cos(g)*Math.sin(f)*Math.cos(c)),y=h+Math.atan2(Math.sin(c)*Math.sin(f)*Math.cos(g),Math.cos(f)-Math.sin(g)*Math.sin(p)),v=(0,i.default)(y);return(v<u.MINLON||v>u.MAXLON)&&(y=(y+3*Math.PI)%(2*Math.PI)-Math.PI,v=(0,i.default)(y)),{latitude:(0,i.default)(p),longitude:v}}),"computeDestinationPoint");e.default=l})),ar=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"m",n=t.areaConversion[r];if(n)return e*n;throw new Error("Invalid unit used for area conversion.")}),"convertArea");e.default=r})),ir=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"m",n=t.distanceConversion[r];if(n)return e*n;throw new Error("Invalid unit used for distance conversion.")}),"convertDistance");e.default=r})),ur=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kmh";switch(r){case"kmh":return e*t.timeConversion.h*t.distanceConversion.km;case"mph":return e*t.timeConversion.h*t.distanceConversion.mi;default:return e}}),"convertSpeed");e.default=r})),lr=m((e=>{"use strict";function t(e,t){return o(e)||u(e,t)||n(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(typeof Symbol>"u")&&Symbol.iterator in Object(e)){var r=[],n=!0,a=!1,i=void 0;try{for(var u,o=e[Symbol.iterator]();!(n=(u=o.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&null!=o.return&&o.return()}finally{if(a)throw i}}return r}}function o(e){if(Array.isArray(e))return e}s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a(t,"_slicedToArray"),a(r,"_nonIterableRest"),a(n,"_unsupportedIterableToArray"),a(i,"_arrayLikeToArray"),a(u,"_iterableToArrayLimit"),a(o,"_arrayWithHoles");var l=a((function(e){var t=Math.pow(10,12);return Math.round(e*t)/t}),"imprecise"),d=a((function(e){var r=t(e.toString().split("."),2),n=r[0],a=r[1],i=Math.abs(Number(n)),u=l(60*+("0."+(a||0))),o=Math.floor(u),s=l(60*(u%o||0));return i+"° "+Number(o.toFixed(6)).toString().split(".").map((function(e,t){return 0===t?e.padStart(2,"0"):e})).join(".")+"' "+Number(s.toFixed(4)).toString().split(".").map((function(e,t){return 0===t?e.padStart(2,"0"):e})).join(".")+'"'}),"decimal2sexagesimal");e.default=d})),Ot=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return e>1?1:e<-1?-1:e}),"robustAcos");e.default=t})),$=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Ot()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;o=typeof o<"u"&&!isNaN(o)?o:1;var l=(0,t.default)(e),s=(0,r.default)(e),d=(0,t.default)(a),f=(0,r.default)(a),c=Math.acos((0,i.default)(Math.sin((0,n.default)(d))*Math.sin((0,n.default)(l))+Math.cos((0,n.default)(d))*Math.cos((0,n.default)(l))*Math.cos((0,n.default)(s)-(0,n.default)(f))))*u.earthRadius;return Math.round(c/o)*o}),"getDistance");e.default=l})),Lt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default;return n="function"==typeof n?n:t.default,r.slice().sort((function(t,r){return n(e,t)-n(e,r)}))}),"orderByDistance");e.default=n})),gr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(Lt());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){return(0,t.default)(e,r)[0]}),"findNearest");e.default=n})),mr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(W()),r=u(S()),n=u(w()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e){var a=0;if(e.length>2){for(var u,o,l,s=0;s<e.length;s++){s===e.length-2?(u=e.length-2,o=e.length-1,l=0):s===e.length-1?(u=e.length-1,o=0,l=1):(u=s,o=s+1,l=s+2);var d=(0,n.default)(e[u]),f=(0,r.default)(e[o]),c=(0,n.default)(e[l]);a+=((0,t.default)(c)-(0,t.default)(d))*Math.sin((0,t.default)(f))}a=a*i.earthRadius*i.earthRadius/2}return Math.abs(a)}),"getAreaOfPolygon");e.default=o})),qt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(S()),r=n(w());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e){if(!1===Array.isArray(e)||0===e.length)throw new Error("No points were given.");return e.reduce((function(e,n){var a=(0,t.default)(n),i=(0,r.default)(n);return{maxLat:Math.max(a,e.maxLat),minLat:Math.min(a,e.minLat),maxLng:Math.max(i,e.maxLng),minLng:Math.min(i,e.minLng)}}),{maxLat:-1/0,minLat:1/0,maxLng:-1/0,minLng:1/0})}),"getBounds");e.default=i})),_r=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Y()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a){var o,l,s=(0,t.default)(e),d=(0,r.default)(e),f=(0,n.default)(s),c=(0,n.default)(d),g=a/u.earthRadius,h=f-g,p=f+g,y=(0,n.default)(u.MAXLAT),v=(0,n.default)(u.MINLAT),m=(0,n.default)(u.MAXLON),b=(0,n.default)(u.MINLON);if(h>v&&p<y){var M=Math.asin(Math.sin(g)/Math.cos(f));(o=c-M)<b&&(o+=2*Math.PI),(l=c+M)>m&&(l-=2*Math.PI)}else h=Math.max(h,v),p=Math.min(p,y),o=b,l=m;return[{latitude:(0,i.default)(h),longitude:(0,i.default)(o)},{latitude:(0,i.default)(p),longitude:(0,i.default)(l)}]}),"getBoundsOfDistance");e.default=l})),Ir=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e){if(!1===Array.isArray(e)||0===e.length)return!1;var a=e.length,u=e.reduce((function(e,a){var i=(0,n.default)((0,t.default)(a)),u=(0,n.default)((0,r.default)(a));return{X:e.X+Math.cos(i)*Math.cos(u),Y:e.Y+Math.cos(i)*Math.sin(u),Z:e.Z+Math.sin(i)}}),{X:0,Y:0,Z:0}),o=u.X/a,l=u.Y/a,s=u.Z/a;return{longitude:(0,i.default)(Math.atan2(l,o)),latitude:(0,i.default)(Math.atan2(s,Math.sqrt(o*o+l*l)))}}),"getCenter");e.default=o})),br=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(qt());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e){var r=(0,t.default)(e),n=r.minLat+(r.maxLat-r.minLat)/2,a=r.minLng+(r.maxLng-r.minLng)/2;return{latitude:parseFloat(n.toFixed(6)),longitude:parseFloat(a.toFixed(6))}}),"getCenterOfBounds");e.default=n})),Et=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=(0,n.default)((0,r.default)(a))-(0,n.default)((0,r.default)(e)),o=Math.log(Math.tan((0,n.default)((0,t.default)(a))/2+Math.PI/4)/Math.tan((0,n.default)((0,t.default)(e))/2+Math.PI/4));return Math.abs(u)>Math.PI&&(u=u>0?-1*(2*Math.PI-u):2*Math.PI+u),((0,i.default)(Math.atan2(u,o))+360)%360}),"getRhumbLineBearing");e.default=o})),Dr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(Et());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default,a="function"==typeof n?n(e,r):(0,t.default)(e,r);if(isNaN(a))throw new Error("Could not calculate bearing for given points. Check your bearing function");switch(Math.round(a/22.5)){case 1:return"NNE";case 2:return"NE";case 3:return"ENE";case 4:return"E";case 5:return"ESE";case 6:return"SE";case 7:return"SSE";case 8:return"S";case 9:return"SSW";case 10:return"SW";case 11:return"WSW";case 12:return"W";case 13:return"WNW";case 14:return"NW";case 15:return"NNW";default:return"N"}}),"getCompassDirection");e.default=n})),At=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n($()),r=n(Ot());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e,n,a){var i=(0,t.default)(n,e),u=(0,t.default)(e,a),o=(0,t.default)(n,a),l=Math.acos((0,r.default)((i*i+o*o-u*u)/(2*i*o))),s=Math.acos((0,r.default)((u*u+o*o-i*i)/(2*u*o)));return l>Math.PI/2?i:s>Math.PI/2?u:Math.sin(l)*i}),"getDistanceFromLine");e.default=i})),Ar=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=(0,t.default)(a),o=(0,r.default)(a),l=(0,t.default)(e),s=(0,r.default)(e);return((0,i.default)(Math.atan2(Math.sin((0,n.default)(o)-(0,n.default)(s))*Math.cos((0,n.default)(u)),Math.cos((0,n.default)(l))*Math.sin((0,n.default)(u))-Math.sin((0,n.default)(l))*Math.cos((0,n.default)(u))*Math.cos((0,n.default)(o)-(0,n.default)(s))))+360)%360}),"getGreatCircleBearing");e.default=o})),xr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?a((function(e){return typeof e}),"_typeof"):a((function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}),"_typeof"))(e)}a(r,"_interopRequireDefault"),a(n,"_typeof");var i=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.default;return e.reduce((function(e,t){return"object"===n(e)&&null!==e.last&&(e.distance+=r(t,e.last)),e.last=t,e}),{last:null,distance:0}).distance}),"getPathLength");e.default=i})),Cr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;u=typeof u<"u"&&!isNaN(u)?u:1;var o,l,s,d,f,c,g,h=(0,t.default)(e),p=(0,r.default)(e),y=(0,t.default)(a),v=(0,r.default)(a),m=6356752.314245,b=1/298.257223563,M=(0,n.default)(v-p),_=Math.atan((1-b)*Math.tan((0,n.default)(parseFloat(h)))),O=Math.atan((1-b)*Math.tan((0,n.default)(parseFloat(y)))),P=Math.sin(_),j=Math.cos(_),I=Math.sin(O),D=Math.cos(O),x=M,S=100;do{var L=Math.sin(x),w=Math.cos(x);if(0===(c=Math.sqrt(D*L*(D*L)+(j*I-P*D*w)*(j*I-P*D*w))))return 0;o=P*I+j*D*w,l=Math.atan2(c,o),f=o-2*P*I/(d=1-(s=j*D*L/c)*s),isNaN(f)&&(f=0);var N=b/16*d*(4+b*(4-3*d));g=x,x=M+(1-N)*b*s*(l+N*c*(f+N*o*(2*f*f-1)))}while(Math.abs(x-g)>1e-12&&--S>0);if(0===S)return NaN;var E=d*(i.earthRadius*i.earthRadius-m*m)/(m*m),A=1+E/16384*(4096+E*(E*(320-175*E)-768)),R=E/1024*(256+E*(E*(74-47*E)-128)),T=R*c*(f+R/4*(o*(2*f*f-1)-R/6*f*(4*c*c-3)*(4*f*f-3))),B=m*A*(l-T);return Math.round(B/u)*u}),"getDistance");e.default=o})),Br=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return/^NNE|NE|NNW|N$/.test(e)?"N":/^ENE|E|ESE|SE$/.test(e)?"E":/^SSE|S|SSW|SW$/.test(e)?"S":/^WSW|W|WNW|NW$/.test(e)?"W":void 0}),"getRoughCompassDirection");e.default=t})),Vr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default,a=n(e,r),i=Number(r.time)-Number(e.time),u=a/i*1e3;return u}),"getSpeed");e.default=n})),Kr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n){return(0,t.default)(r,e)+(0,t.default)(e,n)===(0,t.default)(r,n)}),"isPointInLine");e.default=n})),Fr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(S()),r=n(w());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e,n){for(var a=!1,i=n.length,u=-1,o=i-1;++u<i;o=u)((0,r.default)(n[u])<=(0,r.default)(e)&&(0,r.default)(e)<(0,r.default)(n[o])||(0,r.default)(n[o])<=(0,r.default)(e)&&(0,r.default)(e)<(0,r.default)(n[u]))&&(0,t.default)(e)<((0,t.default)(n[o])-(0,t.default)(n[u]))*((0,r.default)(e)-(0,r.default)(n[u]))/((0,r.default)(n[o])-(0,r.default)(n[u]))+(0,t.default)(n[u])&&(a=!a);return a}),"isPointInPolygon");e.default=i})),Gr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(At());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n,a){return(0,t.default)(e,r,n)<a}),"isPointNearLine");e.default=n})),Xr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n){return(0,t.default)(e,r)<n}),"isPointWithinRadius");e.default=n})),$r=m((e=>{"use strict";function t(e,t){return o(e)||u(e,t)||n(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(typeof Symbol>"u")&&Symbol.iterator in Object(e)){var r=[],n=!0,a=!1,i=void 0;try{for(var u,o=e[Symbol.iterator]();!(n=(u=o.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&null!=o.return&&o.return()}finally{if(a)throw i}}return r}}function o(e){if(Array.isArray(e))return e}s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a(t,"_slicedToArray"),a(r,"_nonIterableRest"),a(n,"_unsupportedIterableToArray"),a(i,"_arrayLikeToArray"),a(u,"_iterableToArrayLimit"),a(o,"_arrayWithHoles");var l=a((function(e){if(!e.startsWith("POLYGON"))throw new Error("Invalid wkt.");return e.slice(e.indexOf("(")+2,e.indexOf(")")).split(", ").map((function(e){var r=t(e.split(" "),2),n=r[0],a=r[1];return{longitude:parseFloat(n),latitude:parseFloat(a)}}))}),"wktToPolygon");e.default=l})),jr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0});var t={computeDestinationPoint:!0,convertArea:!0,convertDistance:!0,convertSpeed:!0,decimalToSexagesimal:!0,findNearest:!0,getAreaOfPolygon:!0,getBounds:!0,getBoundsOfDistance:!0,getCenter:!0,getCenterOfBounds:!0,getCompassDirection:!0,getCoordinateKey:!0,getCoordinateKeys:!0,getDistance:!0,getDistanceFromLine:!0,getGreatCircleBearing:!0,getLatitude:!0,getLongitude:!0,getPathLength:!0,getPreciseDistance:!0,getRhumbLineBearing:!0,getRoughCompassDirection:!0,getSpeed:!0,isDecimal:!0,isPointInLine:!0,isPointInPolygon:!0,isPointNearLine:!0,isPointWithinRadius:!0,isSexagesimal:!0,isValidCoordinate:!0,isValidLatitude:!0,isValidLongitude:!0,orderByDistance:!0,sexagesimalToDecimal:!0,toDecimal:!0,toRad:!0,toDeg:!0,wktToPolygon:!0};Object.defineProperty(e,"computeDestinationPoint",{enumerable:!0,get:a((function(){return r.default}),"get")}),Object.defineProperty(e,"convertArea",{enumerable:!0,get:a((function(){return n.default}),"get")}),Object.defineProperty(e,"convertDistance",{enumerable:!0,get:a((function(){return i.default}),"get")}),Object.defineProperty(e,"convertSpeed",{enumerable:!0,get:a((function(){return u.default}),"get")}),Object.defineProperty(e,"decimalToSexagesimal",{enumerable:!0,get:a((function(){return o.default}),"get")}),Object.defineProperty(e,"findNearest",{enumerable:!0,get:a((function(){return l.default}),"get")}),Object.defineProperty(e,"getAreaOfPolygon",{enumerable:!0,get:a((function(){return d.default}),"get")}),Object.defineProperty(e,"getBounds",{enumerable:!0,get:a((function(){return f.default}),"get")}),Object.defineProperty(e,"getBoundsOfDistance",{enumerable:!0,get:a((function(){return c.default}),"get")}),Object.defineProperty(e,"getCenter",{enumerable:!0,get:a((function(){return g.default}),"get")}),Object.defineProperty(e,"getCenterOfBounds",{enumerable:!0,get:a((function(){return h.default}),"get")}),Object.defineProperty(e,"getCompassDirection",{enumerable:!0,get:a((function(){return p.default}),"get")}),Object.defineProperty(e,"getCoordinateKey",{enumerable:!0,get:a((function(){return y.default}),"get")}),Object.defineProperty(e,"getCoordinateKeys",{enumerable:!0,get:a((function(){return v.default}),"get")}),Object.defineProperty(e,"getDistance",{enumerable:!0,get:a((function(){return m.default}),"get")}),Object.defineProperty(e,"getDistanceFromLine",{enumerable:!0,get:a((function(){return b.default}),"get")}),Object.defineProperty(e,"getGreatCircleBearing",{enumerable:!0,get:a((function(){return M.default}),"get")}),Object.defineProperty(e,"getLatitude",{enumerable:!0,get:a((function(){return _.default}),"get")}),Object.defineProperty(e,"getLongitude",{enumerable:!0,get:a((function(){return O.default}),"get")}),Object.defineProperty(e,"getPathLength",{enumerable:!0,get:a((function(){return P.default}),"get")}),Object.defineProperty(e,"getPreciseDistance",{enumerable:!0,get:a((function(){return j.default}),"get")}),Object.defineProperty(e,"getRhumbLineBearing",{enumerable:!0,get:a((function(){return I.default}),"get")}),Object.defineProperty(e,"getRoughCompassDirection",{enumerable:!0,get:a((function(){return D.default}),"get")}),Object.defineProperty(e,"getSpeed",{enumerable:!0,get:a((function(){return x.default}),"get")}),Object.defineProperty(e,"isDecimal",{enumerable:!0,get:a((function(){return L.default}),"get")}),Object.defineProperty(e,"isPointInLine",{enumerable:!0,get:a((function(){return N.default}),"get")}),Object.defineProperty(e,"isPointInPolygon",{enumerable:!0,get:a((function(){return E.default}),"get")}),Object.defineProperty(e,"isPointNearLine",{enumerable:!0,get:a((function(){return A.default}),"get")}),Object.defineProperty(e,"isPointWithinRadius",{enumerable:!0,get:a((function(){return R.default}),"get")}),Object.defineProperty(e,"isSexagesimal",{enumerable:!0,get:a((function(){return B.default}),"get")}),Object.defineProperty(e,"isValidCoordinate",{enumerable:!0,get:a((function(){return C.default}),"get")}),Object.defineProperty(e,"isValidLatitude",{enumerable:!0,get:a((function(){return q.default}),"get")}),Object.defineProperty(e,"isValidLongitude",{enumerable:!0,get:a((function(){return V.default}),"get")}),Object.defineProperty(e,"orderByDistance",{enumerable:!0,get:a((function(){return k.default}),"get")}),Object.defineProperty(e,"sexagesimalToDecimal",{enumerable:!0,get:a((function(){return F.default}),"get")}),Object.defineProperty(e,"toDecimal",{enumerable:!0,get:a((function(){return K.default}),"get")}),Object.defineProperty(e,"toRad",{enumerable:!0,get:a((function(){return X.default}),"get")}),Object.defineProperty(e,"toDeg",{enumerable:!0,get:a((function(){return G.default}),"get")}),Object.defineProperty(e,"wktToPolygon",{enumerable:!0,get:a((function(){return H.default}),"get")});var r=Z(nr()),n=Z(ar()),i=Z(ir()),u=Z(ur()),o=Z(lr()),l=Z(gr()),d=Z(mr()),f=Z(qt()),c=Z(_r()),g=Z(Ir()),h=Z(br()),p=Z(Dr()),y=Z(re()),v=Z(he()),m=Z($()),b=Z(At()),M=Z(Ar()),_=Z(S()),O=Z(w()),P=Z(xr()),j=Z(Cr()),I=Z(Et()),D=Z(Br()),x=Z(Vr()),L=Z(ne()),N=Z(Kr()),E=Z(Fr()),A=Z(Gr()),R=Z(Xr()),B=Z(ae()),C=Z(yt()),q=Z(ht()),V=Z(pt()),k=Z(Lt()),F=Z(ie()),K=Z(Me()),X=Z(W()),G=Z(Y()),H=Z($r()),U=T();function Z(e){return e&&e.__esModule?e:{default:e}}Object.keys(U).forEach((function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(e,r,{enumerable:!0,get:a((function(){return U[r]}),"get")})})),a(Z,"_interopRequireDefault")}));s(),s();var Jr=dn(jr());s();var Ct=class{constructor({origin:e,destination:t,vortex:r,elevationDelta:n=0,distance:a=0,angle:i=0,pathWeight:u=0}){let o,l;if(D(this,"origin"),D(this,"destination"),D(this,"vortex"),D(this,"distance"),D(this,"angle"),D(this,"weight"),this.origin=e,this.destination=t,this.vortex=r,this.distance=a,this.angle=i,r)this.distance=0,this.angle=0,o=void 0!==r.weight&&r.weight>0?r.weight:"elevator"===r.type?2e3:1e3,l=r.multiplier&&r.multiplier>=1?r.multiplier:1,this.weight=n*l+o;else{let e=u||t.weight;o=e&&e>=0?e:0,l=t.multiplier&&t.multiplier>=1?t.multiplier:1,this.weight=this.distance*l+o}if(isNaN(this.angle))throw new Error("nan angle")}};a(Ct,"Edge");var wt=Ct,k=wt;s();var Yr=(e=>(e[e.LOG=0]="LOG",e[e.WARN=1]="WARN",e[e.ERROR=2]="ERROR",e[e.SILENT=3]="SILENT",e))(Yr||{});function Xu(e){0<=e&&e<=3&&(kr.logState=e)}a(Xu,"setLoggerLevel");var kr={logState:"test"===g.env.NODE_ENV?3:0,log(...e){this.logState<=0&&console.log("[MappedInJS]",...e)},warn(...e){this.logState<=1&&console.warn("[MappedInJS]",...e)},error(...e){this.logState<=2&&console.error("[MappedInJS]",...e)},assert(...e){console.assert(...e)},time(e){console.time(e)},timeEnd(e){console.timeEnd(e)}},Zr=kr;function Uu(e){if(e.scale||e.x_scale)return 1/(e.scale||e.x_scale||1);try{if(!e.georeference)throw new Error("map ".concat(e.name||e.shortName||e.id," does not have a georeference field"));if(e.georeference.length<3)throw new Error("map ".concat(e.name||e.shortName||e.id," has less than 3 georeference points, we require at least 3 for proper map scaling"));let t=e.georeference[0],r=e.georeference[2],n=(0,Jr.getDistance)({latitude:t.target.x,longitude:t.target.y},{latitude:r.target.x,longitude:r.target.y}),a=t.control.x-r.control.x,i=t.control.y-r.control.y;return Math.sqrt(a*a+i*i)/n}catch(e){return Zr.error(e),1}}function lt(e,t){let r=e.x-t.x,n=e.y-t.y;return(Math.atan2(n,r)+2.5*Math.PI)%(2*Math.PI)}a(Uu,"getMapScale"),a(lt,"getAngle");var Kt=class{constructor({nodes:e,vortexes:t,maps:r,showVortexNames:n=!1}){D(this,"edges"),D(this,"nodesById"),D(this,"mapsById"),this.edges={},this.mapsById=r.map((e=>({...e,_scale:Uu(e)}))).reduce(((e,t)=>(e[t.id]=t,e)),{});let a=e.filter((e=>!!this.mapsById[e.map])).map((e=>({...e,paths:e.paths?e.paths.filter((({map:t})=>t===e.map)):[]})));this.nodesById=a.reduce(((e,t)=>(e[t.id]=t,e)),{});for(let e in this.nodesById)this.nodesById.hasOwnProperty(e)&&(this.nodesById[e].paths=this.nodesById[e].paths.filter((({node:e})=>!!this.nodesById[e])));let i=t.map((e=>({...e,name:n?e.name:e.type,nodes:e.nodes?e.nodes.filter((e=>!!this.nodesById[e])):[]})));a.forEach((e=>{this.edges[e.id]=e.paths.map((({node:t,weight:r})=>{let n=this.nodesById[t];return new k({angle:lt(e,n),destination:n,distance:this.getDistance(e,n),origin:e,pathWeight:r})}))})),i.forEach((e=>{if(null==e.nodes||0===e.nodes.length)return;let t=0;for(;t<e.nodes.length-1;){let r=this.nodesById[e.nodes[t]];if(t++,null==r)continue;let n=t;for(;n<e.nodes.length;){let t=this.nodesById[e.nodes[n]];if(n++,null==t)continue;let a=this.mapsById[r.map].elevation||0,i=this.mapsById[t.map].elevation||0,u=Math.abs(a-i);this.edges[r.id].push(new k({destination:t,elevationDelta:u,origin:r,vortex:e})),this.edges[t.id].push(new k({destination:r,elevationDelta:u,origin:t,vortex:e}))}}}))}aStar({originIds:e,destinationNodeIds:t,accessible:r,includedVortexIds:n,excludedVortexIds:a,excludedNodeIds:i}){let u=e.map((e=>this.nodesById[e])).filter((e=>e&&(!i||!i.has(e.id)))),o=t.map((e=>this.nodesById[e])).filter((e=>e&&(!i||!i.has(e.id))));if(0===u.length||0===o.length)return[];let l=[],s={},d={};for(u.forEach((e=>{let t=this.getShortestEuclideanDistance(e,o);l.push({origin:e,priority:t}),s[e.id]=null,d[e.id]=0})),l.sort(((e,t)=>e.priority-t.priority));l.length>0;){let e=l[0];if(o.includes(e.origin)){let t=[],r=s[e.origin.id];for(;null!=r;){t.push(r);let e=s[r.origin.id];r=null!=e?e:null}return t.reverse()}for(let t of this.edges[e.origin.id]){let u=t.vortex&&!1===t.vortex.accessible||!1===t.origin.accessible||!1===t.destination.accessible,f=t.vortex&&(n&&!n.has(t.vortex.id)||a&&a.has(t.vortex.id)),c=i&&i.has(t.destination.id);if(r&&u||f||c)continue;let g=d[e.origin.id]+t.weight;if(null==d[t.destination.id]||g<d[t.destination.id]){d[t.destination.id]=g;let e=g+this.getShortestEuclideanDistance(t.destination,o);l.push({origin:t.destination,priority:e}),s[t.destination.id]=t}}l.splice(0,1),l.sort(((e,t)=>e.priority-t.priority))}return[]}getDistance(e,t){let r,n=e.x-t.x,a=e.y-t.y,i=n*n+a*a;return r=null==this.mapsById[e.map]?1:this.mapsById[e.map]._scale,Math.sqrt(i)/r}getShortestEuclideanDistance(e,t){return t.reduce(((t,r)=>{let n=this.getDistance(e,r);return Math.min(t,n)}),Number.MAX_VALUE)}};a(Kt,"NavigationGraph");var Bt=Kt,Vt=Bt;s(),s();var Ft=(e=>(e.DEPARTURE="Departure",e.TAKEVORTEX="TakeVortex",e.EXITVORTEX="ExitVortex",e.TURN="Turn",e.ARRIVAL="Arrival",e))(Ft||{}),Gt=(e=>(e.STRAIGHT="Straight",e.RIGHT="Right",e.SLIGHTRIGHT="SlightRight",e.LEFT="Left",e.SLIGHTLEFT="SlightLeft",e))(Gt||{});function $u(e){switch(e){case"down":case"up":return"".concat(e," ");default:return""}}a($u,"vortexDirectionTest");var Xt=class{constructor({origin:e,action:t,distance:r,atLocation:n,instruction:a}){D(this,"node"),D(this,"instruction"),D(this,"action"),D(this,"atLocation"),D(this,"type"),D(this,"distance",0),this.node=e,this.action=t,this.distance=r||0,this.atLocation=n,this.instruction="",a?this.instruction=a:(null!=t&&"Departure"===t.type?this.instruction=null!=n?"Depart from ".concat(n.name):"Depart from current location":null!=t&&"Arrival"===t.type?this.instruction=null!=n?"Arrive at ".concat(n.name):"Arrive at destination":null!=t&&"TakeVortex"===t.type?this.instruction="Take ".concat(n&&n.name," ").concat($u(t.direction),"to ").concat(t.toMap.name):null!=t&&"ExitVortex"===t.type?this.instruction="Exit ".concat(n&&n.name," at ").concat(t.toMap.name):null!=t&&"bearing"in t&&"Right"===t.bearing?this.instruction="Turn right":null!=t&&"bearing"in t&&"SlightRight"===t.bearing?this.instruction="Turn slightly right":null!=t&&"bearing"in t&&"Straight"===t.bearing?this.instruction="Head straight":null!=t&&"bearing"in t&&"SlightLeft"===t.bearing?this.instruction="Turn slightly left":null!=t&&"bearing"in t&&"Left"===t.bearing&&(this.instruction="Turn left"),null!=t&&"Turn"===t.type&&n&&(this.instruction+=" at ".concat(n.name)))}};a(Xt,"Directive");var Wt=Xt,H=Wt;function Ut(e,t,r,n){if(!(e&&t&&r&&n))return null;let a=e.x,i=e.y,u=t.x,o=t.y,l=r.x,s=r.y,d=n.x,f=n.y;if(a===u&&i===o||l===d&&s===f)return null;let c=(f-s)*(u-a)-(d-l)*(o-i);if(0===c)return null;let g=((d-l)*(i-s)-(f-s)*(a-l))/c,h=((u-a)*(i-s)-(o-i)*(a-l))/c;return g<0||g>1||h<0||h>1?null:{x:a+g*(u-a),y:i+g*(o-i)}}function zr(e,t,r){if(e.x===t.x)return[{x:e.x+r,y:e.y},{x:t.x+r,y:t.y}];if(e.y===t.y)return[{x:e.x,y:e.y+r},{x:t.x,y:t.y+r}];let n=-1/((t.y-e.y)/(t.x-e.x)),a=r*Math.sqrt(1/(1+n*n)),i=n*a;return[{x:e.x+a,y:e.y+i},{x:t.x+a,y:t.y+i}]}function Qr(e,t,r=[],n=0){let a=!0;return r.forEach((r=>{if(n>0){let i=zr(e,t,-n),u=zr(e,t,n);if(Ut(i[0],i[1],r[0],r[1])||Ut(u[0],u[1],r[0],r[1]))return void(a=!1)}else if(Ut(e,t,r[0],r[1]))return void(a=!1)})),a}s(),a(Ut,"getLineIntersection"),a(zr,"getOffsetLine"),a(Qr,"hasLineOfSight");var en=(e=>(e.NO_VALID_PATH="No Valid Path Available",e))(en||{}),dt=.1*Math.PI;function ft(e,t){return((t-e+Math.PI)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)-Math.PI}a(ft,"differenceBetweenAngles");var Ht=class{constructor({locations:e,nodes:t,vortexes:r,maps:n,polygons:a,showVortexNames:i}){D(this,"graph"),D(this,"locationsByNodeId"),D(this,"geometryEdgesByMapId",new Map),this.graph=new Vt({maps:n,nodes:t,showVortexNames:i,vortexes:r}),this.locationsByNodeId=e.reduce(((e,t)=>(t.nodes&&t.nodes.forEach((r=>{e[r.node]=t})),t.polygons&&t.polygons.forEach((r=>{r.entrances&&r.entrances.forEach((r=>{e[r]=t}))})),e)),{}),a&&a.forEach((e=>{if(this.geometryEdgesByMapId.has(e.map)||this.geometryEdgesByMapId.set(e.map,[]),!0===e.isLineStringSegment)for(let t of e.vertexes)for(let r=0;r<t.length;r++)t[r+1]&&this.geometryEdgesByMapId.get(e.map).push([t[r],t[r+1]]);else e.vertexes.forEach(((t,r)=>{e.vertexes[r+1]?this.geometryEdgesByMapId.get(e.map).push([t,e.vertexes[r+1]]):this.geometryEdgesByMapId.get(e.map).push([t,e.vertexes[0]])}))}))}getClosestLocationInRay(e,t=.5*Math.PI,r=10){let n=0,a=0,i=e;for(;Math.abs(n)<t&&a<r;){let e=this.graph.edges[i.destination.id],u=null,o=0;for(let t of e)if(t.distance>0)if(null!=u){let e=-ft(i.angle,t.angle);Math.abs(e)<Math.abs(o)&&(u=t,o=e)}else u=t,o=-ft(i.angle,t.angle);if(null==u)return null;{if(Math.abs(o)>=t||(n+=o,a+=u.distance,Math.abs(n)>=t||a>r))return null;let e=this.locationsByNodeId[u.destination.id];if(null!=e)return e;i=u}}return null}getDirections({originIds:e,destinationNodeIds:t,accessible:r,departFrom:n,arriveAt:a,includedVortexIds:i,excludedVortexIds:u,excludedNodeIds:o,simplify:l}){var s,d,f;let c=this.graph.aStar({originIds:e,destinationNodeIds:t,accessible:r,includedVortexIds:i,excludedVortexIds:u,excludedNodeIds:o});if(0===c.length)return{distance:0,instructions:[new H({distance:0,instruction:"No Valid Path Available"})],path:[]};let g=0,h=[],p=[];if(null!=l&&l.enabled){let e=null!=(s=null==l?void 0:l.bufferRadius)?s:1.8,t=[c[0]];for(let r=1;r<c.length;r++){if(c[r].origin.map!==c[r-1].origin.map){let n=null!=(d=this.geometryEdgesByMapId.get(c[r-1].origin.map))?d:[];p.push(...this.simplifySteps(t,n,e)),t=[c[r]]}t.push(c[r])}let r=c[c.length-1],n=null!=(f=this.geometryEdgesByMapId.get(r.origin.map))?f:[];p.push(...this.simplifySteps(t,n,e)),c=p}for(let e=0;e<c.length;e++)h.push(c[e].origin);h.push(c[c.length-1].destination);let y=[],v=null,m=null,b=0,M=0;for(let e=0;e<c.length;e++){let t=c[e],r=t.origin,i=t.destination;if(g+=t.distance,b+=(null==m?void 0:m.distance)||0,0===e&&y.push(new H({action:{type:"Departure"},atLocation:n,distance:0,origin:r})),null!=t.vortex){let e=this.graph.mapsById[r.map],n=this.graph.mapsById[i.map],a="none";if(null!=e.elevation&&null!=n.elevation){let t=e.elevation-n.elevation;t>0?a="down":t<0&&(a="up")}y.push(new H({action:{direction:a,fromMap:e,toMap:n,type:"TakeVortex"},atLocation:t.vortex,distance:b,origin:r})),M+=b,b=0}else if(null!=v&&null!=m)if(null!=m.vortex){let e=this.graph.mapsById[v.map],t=this.graph.mapsById[m.destination.map];y.push(new H({action:{fromMap:e,toMap:t,type:"ExitVortex"},atLocation:m.vortex,distance:b,origin:r})),M+=b,b=0}else{let e=this.graph.edges[r.id].filter((e=>e.destination!==v&&e.destination!==t.destination));if(e.length>0){let n=-ft(m.angle,t.angle),a=e.reduce(((e,r)=>{let n=-ft(t.angle,r.angle);return Math.min(e,Math.abs(n))}),Math.PI);if(Math.abs(n)>=dt||Math.abs(a)<=dt){let e;e=n<=-Math.PI/4?"Right":n<=-dt?"SlightRight":n<=dt?"Straight":n<=Math.PI/4?"SlightLeft":"Left";let t=this.locationsByNodeId[r.id];if(t||(t=this.getClosestLocationInRay(m,.5*Math.PI,10)),null!=t){let n=new H({action:{bearing:e,referencePosition:"At",type:"Turn"},atLocation:t,distance:b,origin:r});n.type=e,y.push(n)}else y.push(new H({action:{bearing:e,referencePosition:"At",type:"Turn"},distance:b,origin:r}));M+=b,b=0}}}e===c.length-1&&(y.push(new H({action:{type:"Arrival"},atLocation:a,distance:g-M<0?0:g-M,origin:t.destination})),M+=b,b=0),v=r,m=t}let _=[],O=null;for(let e=y.length-1;e>=0;e--){let t=y[e],{action:r}=t;r&&"TakeVortex"===r.type?(O=t.node,_.unshift(t)):r&&"Turn"===r.type&&null!=O?this.graph.getDistance(t.node,O)>5?_.unshift(t):_[0].distance+=t.distance:_.unshift(t)}return{distance:g,instructions:_,path:h}}simplifySteps(e,t,r){if(e.length<3)return e;let n=[e[0]],a=1;for(let i=a+2;i<e.length;i++)if(!Qr(e[a].origin,e[i].origin,t,r)){let t=i-1;n.push(new k({...e[a],destination:e[t].origin,distance:this.graph.getDistance(e[a].origin,e[t].origin),angle:lt(e[a].origin,e[t].origin)})),a=t}return n.push(new k({...e[a],destination:e[e.length-1].origin,distance:this.graph.getDistance(e[a].origin,e[e.length-1].origin),angle:lt(e[a].origin,e[e.length-1].origin)}),e[e.length-1]),n}};a(Ht,"Navigator");var $t=Ht,Hu=$t;export{Ft as ACTION_TYPE,Gt as BEARING_TYPE,en as E_MESSAGES,Yr as E_SDK_LOG_LEVEL,Vt as NavigationGraph,Hu as Navigator,Xu as setLoggerLevel};
1
+ var g,tn=Object.create,le=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,nn=Object.getOwnPropertyNames,an=Object.getPrototypeOf,un=Object.prototype.hasOwnProperty,on=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,a=(e,t)=>le(e,"name",{value:t,configurable:!0}),sn=(e,t)=>()=>(e&&(t=e(e=0)),t),m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ln=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of nn(t))!un.call(e,a)&&a!==r&&le(e,a,{get:()=>t[a],enumerable:!(n=rn(t,a))||n.enumerable});return e},dn=(e,t,r)=>(r=null!=e?tn(an(e)):{},ln(!t&&e&&e.__esModule?r:le(r,"default",{value:e,enumerable:!0}),e)),D=(e,t,r)=>(on(e,"symbol"!=typeof t?t+"":t,r),r),s=sn((()=>{g={env:{NODE_ENV:"production",npm_package_version:"5.49.0"}}})),T=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.areaConversion=e.timeConversion=e.distanceConversion=e.altitudeKeys=e.latitudeKeys=e.longitudeKeys=e.MAXLON=e.MINLON=e.MAXLAT=e.MINLAT=e.earthRadius=e.sexagesimalPattern=void 0;e.sexagesimalPattern=/^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}(\.([0-9]{1,}))?)["″]\s*)?([NEOSW]?)$/;e.earthRadius=6378137;e.MINLAT=-90;e.MAXLAT=90;e.MINLON=-180;e.MAXLON=180;e.longitudeKeys=["lng","lon","longitude",0];e.latitudeKeys=["lat","latitude",1];e.altitudeKeys=["alt","altitude","elevation","elev",2];e.distanceConversion={m:1,km:.001,cm:100,mm:1e3,mi:1/1609.344,sm:1/1852.216,ft:100/30.48,in:100/2.54,yd:1/.9144};e.timeConversion={m:60,h:3600,d:86400};var t={m2:1,km2:1e-6,ha:1e-4,a:.01,ft2:10.763911,yd2:1.19599,in2:1550.0031};e.areaConversion=t,t.sqm=t.m2,t.sqkm=t.km2,t.sqft=t.ft2,t.sqyd=t.yd2,t.sqin=t.in2})),re=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e,t){return t.reduce((function(t,r){if(typeof e>"u"||null===e)throw new Error("'".concat(e,"' is no valid coordinate."));return Object.prototype.hasOwnProperty.call(e,r)&&typeof r<"u"&&typeof t>"u"?(t=r,r):t}),void 0)}),"getCoordinateKey");e.default=t})),ne=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){var t=e.toString().trim();return!isNaN(parseFloat(t))&&parseFloat(t)===Number(t)}),"isDecimal");e.default=t})),ae=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){return t.sexagesimalPattern.test(e.toString().trim())}),"isSexagesimal");e.default=r})),ie=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=new RegExp(t.sexagesimalPattern).exec(e);if(typeof r>"u"||null===r)throw new Error("Given value is not in sexagesimal format");var n=Number(r[2])/60||0,a=Number(r[4])/3600||0,i=parseFloat(r[1])+n+a;return["S","W"].includes(r[7])?-i:i}),"sexagesimalToDecimal");e.default=r})),he=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=n(re());function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(n,"_interopRequireDefault"),a(i,"ownKeys"),a(u,"_objectSpread"),a(o,"_defineProperty");var l=a((function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{longitude:t.longitudeKeys,latitude:t.latitudeKeys,altitude:t.altitudeKeys},a=(0,r.default)(e,n.longitude),i=(0,r.default)(e,n.latitude),o=(0,r.default)(e,n.altitude);return u({latitude:i,longitude:a},o?{altitude:o}:{})}),"getCoordinateKeys");e.default=l})),ht=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(ne()),r=u(ae()),n=u(ie()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function e(a){return(0,t.default)(a)?!(parseFloat(a)>i.MAXLAT||a<i.MINLAT):!!(0,r.default)(a)&&e((0,n.default)(a))}),"isValidLatitude");e.default=o})),pt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(ne()),r=u(ae()),n=u(ie()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function e(a){return(0,t.default)(a)?!(parseFloat(a)>i.MAXLON||a<i.MINLON):!!(0,r.default)(a)&&e((0,n.default)(a))}),"isValidLongitude");e.default=o})),yt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=i(he()),r=i(ht()),n=i(pt());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e){var a=(0,t.default)(e),i=a.latitude,u=a.longitude;if(Array.isArray(e)&&e.length>=2)return(0,n.default)(e[0])&&(0,r.default)(e[1]);if(typeof i>"u"||typeof u>"u")return!1;var o=e[u],l=e[i];return!(typeof l>"u"||typeof o>"u"||!1===(0,r.default)(l)||!1===(0,n.default)(o))}),"isValidCoordinate");e.default=u})),Me=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(ne()),r=o(ae()),n=o(ie()),i=o(yt()),u=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(o,"_interopRequireDefault"),a(l,"ownKeys"),a(d,"_objectSpread"),a(f,"_defineProperty");var c=a((function e(a){if((0,t.default)(a))return Number(a);if((0,r.default)(a))return(0,n.default)(a);if((0,i.default)(a)){var o=(0,u.default)(a);return Array.isArray(a)?a.map((function(t,r){return[0,1].includes(r)?e(t):t})):d(d(d({},a),o.latitude&&f({},o.latitude,e(a[o.latitude]))),o.longitude&&f({},o.longitude,e(a[o.longitude])))}return Array.isArray(a)?a.map((function(t){return(0,i.default)(t)?e(t):t})):a}),"toDecimal");e.default=c})),S=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=i(re()),n=i(Me());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e,a){var i=(0,r.default)(e,t.latitudeKeys);if(!(typeof i>"u"||null===i)){var u=e[i];return!0===a?u:(0,n.default)(u)}}),"getLatitude");e.default=u})),w=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=i(re()),n=i(Me());function i(e){return e&&e.__esModule?e:{default:e}}a(i,"_interopRequireDefault");var u=a((function(e,a){var i=(0,r.default)(e,t.longitudeKeys);if(!(typeof i>"u"||null===i)){var u=e[i];return!0===a?u:(0,n.default)(u)}}),"getLongitude");e.default=u})),W=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return e*Math.PI/180}),"toRad");e.default=t})),Y=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return 180*e/Math.PI}),"toDeg");e.default=t})),nr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Y()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a,o){var l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6371e3,s=(0,t.default)(e),d=(0,r.default)(e),f=a/l,c=(0,n.default)(o),g=(0,n.default)(s),h=(0,n.default)(d),p=Math.asin(Math.sin(g)*Math.cos(f)+Math.cos(g)*Math.sin(f)*Math.cos(c)),y=h+Math.atan2(Math.sin(c)*Math.sin(f)*Math.cos(g),Math.cos(f)-Math.sin(g)*Math.sin(p)),v=(0,i.default)(y);return(v<u.MINLON||v>u.MAXLON)&&(y=(y+3*Math.PI)%(2*Math.PI)-Math.PI,v=(0,i.default)(y)),{latitude:(0,i.default)(p),longitude:v}}),"computeDestinationPoint");e.default=l})),ar=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"m",n=t.areaConversion[r];if(n)return e*n;throw new Error("Invalid unit used for area conversion.")}),"convertArea");e.default=r})),ir=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"m",n=t.distanceConversion[r];if(n)return e*n;throw new Error("Invalid unit used for distance conversion.")}),"convertDistance");e.default=r})),ur=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=T(),r=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kmh";switch(r){case"kmh":return e*t.timeConversion.h*t.distanceConversion.km;case"mph":return e*t.timeConversion.h*t.distanceConversion.mi;default:return e}}),"convertSpeed");e.default=r})),lr=m((e=>{"use strict";function t(e,t){return o(e)||u(e,t)||n(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(typeof Symbol>"u")&&Symbol.iterator in Object(e)){var r=[],n=!0,a=!1,i=void 0;try{for(var u,o=e[Symbol.iterator]();!(n=(u=o.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&null!=o.return&&o.return()}finally{if(a)throw i}}return r}}function o(e){if(Array.isArray(e))return e}s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a(t,"_slicedToArray"),a(r,"_nonIterableRest"),a(n,"_unsupportedIterableToArray"),a(i,"_arrayLikeToArray"),a(u,"_iterableToArrayLimit"),a(o,"_arrayWithHoles");var l=a((function(e){var t=Math.pow(10,12);return Math.round(e*t)/t}),"imprecise"),d=a((function(e){var r=t(e.toString().split("."),2),n=r[0],a=r[1],i=Math.abs(Number(n)),u=l(60*+("0."+(a||0))),o=Math.floor(u),s=l(60*(u%o||0));return i+"° "+Number(o.toFixed(6)).toString().split(".").map((function(e,t){return 0===t?e.padStart(2,"0"):e})).join(".")+"' "+Number(s.toFixed(4)).toString().split(".").map((function(e,t){return 0===t?e.padStart(2,"0"):e})).join(".")+'"'}),"decimal2sexagesimal");e.default=d})),Ot=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return e>1?1:e<-1?-1:e}),"robustAcos");e.default=t})),$=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Ot()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;o=typeof o<"u"&&!isNaN(o)?o:1;var l=(0,t.default)(e),s=(0,r.default)(e),d=(0,t.default)(a),f=(0,r.default)(a),c=Math.acos((0,i.default)(Math.sin((0,n.default)(d))*Math.sin((0,n.default)(l))+Math.cos((0,n.default)(d))*Math.cos((0,n.default)(l))*Math.cos((0,n.default)(s)-(0,n.default)(f))))*u.earthRadius;return Math.round(c/o)*o}),"getDistance");e.default=l})),Lt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default;return n="function"==typeof n?n:t.default,r.slice().sort((function(t,r){return n(e,t)-n(e,r)}))}),"orderByDistance");e.default=n})),gr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(Lt());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){return(0,t.default)(e,r)[0]}),"findNearest");e.default=n})),mr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(W()),r=u(S()),n=u(w()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e){var a=0;if(e.length>2){for(var u,o,l,s=0;s<e.length;s++){s===e.length-2?(u=e.length-2,o=e.length-1,l=0):s===e.length-1?(u=e.length-1,o=0,l=1):(u=s,o=s+1,l=s+2);var d=(0,n.default)(e[u]),f=(0,r.default)(e[o]),c=(0,n.default)(e[l]);a+=((0,t.default)(c)-(0,t.default)(d))*Math.sin((0,t.default)(f))}a=a*i.earthRadius*i.earthRadius/2}return Math.abs(a)}),"getAreaOfPolygon");e.default=o})),qt=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(S()),r=n(w());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e){if(!1===Array.isArray(e)||0===e.length)throw new Error("No points were given.");return e.reduce((function(e,n){var a=(0,t.default)(n),i=(0,r.default)(n);return{maxLat:Math.max(a,e.maxLat),minLat:Math.min(a,e.minLat),maxLng:Math.max(i,e.maxLng),minLng:Math.min(i,e.minLng)}}),{maxLat:-1/0,minLat:1/0,maxLng:-1/0,minLng:1/0})}),"getBounds");e.default=i})),_r=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(S()),r=o(w()),n=o(W()),i=o(Y()),u=T();function o(e){return e&&e.__esModule?e:{default:e}}a(o,"_interopRequireDefault");var l=a((function(e,a){var o,l,s=(0,t.default)(e),d=(0,r.default)(e),f=(0,n.default)(s),c=(0,n.default)(d),g=a/u.earthRadius,h=f-g,p=f+g,y=(0,n.default)(u.MAXLAT),v=(0,n.default)(u.MINLAT),m=(0,n.default)(u.MAXLON),b=(0,n.default)(u.MINLON);if(h>v&&p<y){var M=Math.asin(Math.sin(g)/Math.cos(f));(o=c-M)<b&&(o+=2*Math.PI),(l=c+M)>m&&(l-=2*Math.PI)}else h=Math.max(h,v),p=Math.min(p,y),o=b,l=m;return[{latitude:(0,i.default)(h),longitude:(0,i.default)(o)},{latitude:(0,i.default)(p),longitude:(0,i.default)(l)}]}),"getBoundsOfDistance");e.default=l})),Ir=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e){if(!1===Array.isArray(e)||0===e.length)return!1;var a=e.length,u=e.reduce((function(e,a){var i=(0,n.default)((0,t.default)(a)),u=(0,n.default)((0,r.default)(a));return{X:e.X+Math.cos(i)*Math.cos(u),Y:e.Y+Math.cos(i)*Math.sin(u),Z:e.Z+Math.sin(i)}}),{X:0,Y:0,Z:0}),o=u.X/a,l=u.Y/a,s=u.Z/a;return{longitude:(0,i.default)(Math.atan2(l,o)),latitude:(0,i.default)(Math.atan2(s,Math.sqrt(o*o+l*l)))}}),"getCenter");e.default=o})),br=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(qt());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e){var r=(0,t.default)(e),n=r.minLat+(r.maxLat-r.minLat)/2,a=r.minLng+(r.maxLng-r.minLng)/2;return{latitude:parseFloat(n.toFixed(6)),longitude:parseFloat(a.toFixed(6))}}),"getCenterOfBounds");e.default=n})),Et=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=(0,n.default)((0,r.default)(a))-(0,n.default)((0,r.default)(e)),o=Math.log(Math.tan((0,n.default)((0,t.default)(a))/2+Math.PI/4)/Math.tan((0,n.default)((0,t.default)(e))/2+Math.PI/4));return Math.abs(u)>Math.PI&&(u=u>0?-1*(2*Math.PI-u):2*Math.PI+u),((0,i.default)(Math.atan2(u,o))+360)%360}),"getRhumbLineBearing");e.default=o})),Dr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(Et());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default,a="function"==typeof n?n(e,r):(0,t.default)(e,r);if(isNaN(a))throw new Error("Could not calculate bearing for given points. Check your bearing function");switch(Math.round(a/22.5)){case 1:return"NNE";case 2:return"NE";case 3:return"ENE";case 4:return"E";case 5:return"ESE";case 6:return"SE";case 7:return"SSE";case 8:return"S";case 9:return"SSW";case 10:return"SW";case 11:return"WSW";case 12:return"W";case 13:return"WNW";case 14:return"NW";case 15:return"NNW";default:return"N"}}),"getCompassDirection");e.default=n})),At=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n($()),r=n(Ot());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e,n,a){var i=(0,t.default)(n,e),u=(0,t.default)(e,a),o=(0,t.default)(n,a),l=Math.acos((0,r.default)((i*i+o*o-u*u)/(2*i*o))),s=Math.acos((0,r.default)((u*u+o*o-i*i)/(2*u*o)));return l>Math.PI/2?i:s>Math.PI/2?u:Math.sin(l)*i}),"getDistanceFromLine");e.default=i})),Ar=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=u(Y());function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=(0,t.default)(a),o=(0,r.default)(a),l=(0,t.default)(e),s=(0,r.default)(e);return((0,i.default)(Math.atan2(Math.sin((0,n.default)(o)-(0,n.default)(s))*Math.cos((0,n.default)(u)),Math.cos((0,n.default)(l))*Math.sin((0,n.default)(u))-Math.sin((0,n.default)(l))*Math.cos((0,n.default)(u))*Math.cos((0,n.default)(o)-(0,n.default)(s))))+360)%360}),"getGreatCircleBearing");e.default=o})),xr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?a((function(e){return typeof e}),"_typeof"):a((function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}),"_typeof"))(e)}a(r,"_interopRequireDefault"),a(n,"_typeof");var i=a((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.default;return e.reduce((function(e,t){return"object"===n(e)&&null!==e.last&&(e.distance+=r(t,e.last)),e.last=t,e}),{last:null,distance:0}).distance}),"getPathLength");e.default=i})),Cr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=u(S()),r=u(w()),n=u(W()),i=T();function u(e){return e&&e.__esModule?e:{default:e}}a(u,"_interopRequireDefault");var o=a((function(e,a){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;u=typeof u<"u"&&!isNaN(u)?u:1;var o,l,s,d,f,c,g,h=(0,t.default)(e),p=(0,r.default)(e),y=(0,t.default)(a),v=(0,r.default)(a),m=6356752.314245,b=1/298.257223563,M=(0,n.default)(v-p),_=Math.atan((1-b)*Math.tan((0,n.default)(parseFloat(h)))),O=Math.atan((1-b)*Math.tan((0,n.default)(parseFloat(y)))),P=Math.sin(_),j=Math.cos(_),I=Math.sin(O),D=Math.cos(O),x=M,S=100;do{var L=Math.sin(x),w=Math.cos(x);if(0===(c=Math.sqrt(D*L*(D*L)+(j*I-P*D*w)*(j*I-P*D*w))))return 0;o=P*I+j*D*w,l=Math.atan2(c,o),f=o-2*P*I/(d=1-(s=j*D*L/c)*s),isNaN(f)&&(f=0);var N=b/16*d*(4+b*(4-3*d));g=x,x=M+(1-N)*b*s*(l+N*c*(f+N*o*(2*f*f-1)))}while(Math.abs(x-g)>1e-12&&--S>0);if(0===S)return NaN;var E=d*(i.earthRadius*i.earthRadius-m*m)/(m*m),A=1+E/16384*(4096+E*(E*(320-175*E)-768)),R=E/1024*(256+E*(E*(74-47*E)-128)),T=R*c*(f+R/4*(o*(2*f*f-1)-R/6*f*(4*c*c-3)*(4*f*f-3))),B=m*A*(l-T);return Math.round(B/u)*u}),"getDistance");e.default=o})),Br=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a((function(e){return/^NNE|NE|NNW|N$/.test(e)?"N":/^ENE|E|ESE|SE$/.test(e)?"E":/^SSE|S|SSW|SW$/.test(e)?"S":/^WSW|W|WNW|NW$/.test(e)?"W":void 0}),"getRoughCompassDirection");e.default=t})),Vr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.default,a=n(e,r),i=Number(r.time)-Number(e.time),u=a/i*1e3;return u}),"getSpeed");e.default=n})),Kr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n){return(0,t.default)(r,e)+(0,t.default)(e,n)===(0,t.default)(r,n)}),"isPointInLine");e.default=n})),Fr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(S()),r=n(w());function n(e){return e&&e.__esModule?e:{default:e}}a(n,"_interopRequireDefault");var i=a((function(e,n){for(var a=!1,i=n.length,u=-1,o=i-1;++u<i;o=u)((0,r.default)(n[u])<=(0,r.default)(e)&&(0,r.default)(e)<(0,r.default)(n[o])||(0,r.default)(n[o])<=(0,r.default)(e)&&(0,r.default)(e)<(0,r.default)(n[u]))&&(0,t.default)(e)<((0,t.default)(n[o])-(0,t.default)(n[u]))*((0,r.default)(e)-(0,r.default)(n[u]))/((0,r.default)(n[o])-(0,r.default)(n[u]))+(0,t.default)(n[u])&&(a=!a);return a}),"isPointInPolygon");e.default=i})),Gr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r(At());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n,a){return(0,t.default)(e,r,n)<a}),"isPointNearLine");e.default=n})),Xr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=r($());function r(e){return e&&e.__esModule?e:{default:e}}a(r,"_interopRequireDefault");var n=a((function(e,r,n){return(0,t.default)(e,r)<n}),"isPointWithinRadius");e.default=n})),$r=m((e=>{"use strict";function t(e,t){return o(e)||u(e,t)||n(e,t)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(typeof Symbol>"u")&&Symbol.iterator in Object(e)){var r=[],n=!0,a=!1,i=void 0;try{for(var u,o=e[Symbol.iterator]();!(n=(u=o.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&null!=o.return&&o.return()}finally{if(a)throw i}}return r}}function o(e){if(Array.isArray(e))return e}s(),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a(t,"_slicedToArray"),a(r,"_nonIterableRest"),a(n,"_unsupportedIterableToArray"),a(i,"_arrayLikeToArray"),a(u,"_iterableToArrayLimit"),a(o,"_arrayWithHoles");var l=a((function(e){if(!e.startsWith("POLYGON"))throw new Error("Invalid wkt.");return e.slice(e.indexOf("(")+2,e.indexOf(")")).split(", ").map((function(e){var r=t(e.split(" "),2),n=r[0],a=r[1];return{longitude:parseFloat(n),latitude:parseFloat(a)}}))}),"wktToPolygon");e.default=l})),jr=m((e=>{"use strict";s(),Object.defineProperty(e,"__esModule",{value:!0});var t={computeDestinationPoint:!0,convertArea:!0,convertDistance:!0,convertSpeed:!0,decimalToSexagesimal:!0,findNearest:!0,getAreaOfPolygon:!0,getBounds:!0,getBoundsOfDistance:!0,getCenter:!0,getCenterOfBounds:!0,getCompassDirection:!0,getCoordinateKey:!0,getCoordinateKeys:!0,getDistance:!0,getDistanceFromLine:!0,getGreatCircleBearing:!0,getLatitude:!0,getLongitude:!0,getPathLength:!0,getPreciseDistance:!0,getRhumbLineBearing:!0,getRoughCompassDirection:!0,getSpeed:!0,isDecimal:!0,isPointInLine:!0,isPointInPolygon:!0,isPointNearLine:!0,isPointWithinRadius:!0,isSexagesimal:!0,isValidCoordinate:!0,isValidLatitude:!0,isValidLongitude:!0,orderByDistance:!0,sexagesimalToDecimal:!0,toDecimal:!0,toRad:!0,toDeg:!0,wktToPolygon:!0};Object.defineProperty(e,"computeDestinationPoint",{enumerable:!0,get:a((function(){return r.default}),"get")}),Object.defineProperty(e,"convertArea",{enumerable:!0,get:a((function(){return n.default}),"get")}),Object.defineProperty(e,"convertDistance",{enumerable:!0,get:a((function(){return i.default}),"get")}),Object.defineProperty(e,"convertSpeed",{enumerable:!0,get:a((function(){return u.default}),"get")}),Object.defineProperty(e,"decimalToSexagesimal",{enumerable:!0,get:a((function(){return o.default}),"get")}),Object.defineProperty(e,"findNearest",{enumerable:!0,get:a((function(){return l.default}),"get")}),Object.defineProperty(e,"getAreaOfPolygon",{enumerable:!0,get:a((function(){return d.default}),"get")}),Object.defineProperty(e,"getBounds",{enumerable:!0,get:a((function(){return f.default}),"get")}),Object.defineProperty(e,"getBoundsOfDistance",{enumerable:!0,get:a((function(){return c.default}),"get")}),Object.defineProperty(e,"getCenter",{enumerable:!0,get:a((function(){return g.default}),"get")}),Object.defineProperty(e,"getCenterOfBounds",{enumerable:!0,get:a((function(){return h.default}),"get")}),Object.defineProperty(e,"getCompassDirection",{enumerable:!0,get:a((function(){return p.default}),"get")}),Object.defineProperty(e,"getCoordinateKey",{enumerable:!0,get:a((function(){return y.default}),"get")}),Object.defineProperty(e,"getCoordinateKeys",{enumerable:!0,get:a((function(){return v.default}),"get")}),Object.defineProperty(e,"getDistance",{enumerable:!0,get:a((function(){return m.default}),"get")}),Object.defineProperty(e,"getDistanceFromLine",{enumerable:!0,get:a((function(){return b.default}),"get")}),Object.defineProperty(e,"getGreatCircleBearing",{enumerable:!0,get:a((function(){return M.default}),"get")}),Object.defineProperty(e,"getLatitude",{enumerable:!0,get:a((function(){return _.default}),"get")}),Object.defineProperty(e,"getLongitude",{enumerable:!0,get:a((function(){return O.default}),"get")}),Object.defineProperty(e,"getPathLength",{enumerable:!0,get:a((function(){return P.default}),"get")}),Object.defineProperty(e,"getPreciseDistance",{enumerable:!0,get:a((function(){return j.default}),"get")}),Object.defineProperty(e,"getRhumbLineBearing",{enumerable:!0,get:a((function(){return I.default}),"get")}),Object.defineProperty(e,"getRoughCompassDirection",{enumerable:!0,get:a((function(){return D.default}),"get")}),Object.defineProperty(e,"getSpeed",{enumerable:!0,get:a((function(){return x.default}),"get")}),Object.defineProperty(e,"isDecimal",{enumerable:!0,get:a((function(){return L.default}),"get")}),Object.defineProperty(e,"isPointInLine",{enumerable:!0,get:a((function(){return N.default}),"get")}),Object.defineProperty(e,"isPointInPolygon",{enumerable:!0,get:a((function(){return E.default}),"get")}),Object.defineProperty(e,"isPointNearLine",{enumerable:!0,get:a((function(){return A.default}),"get")}),Object.defineProperty(e,"isPointWithinRadius",{enumerable:!0,get:a((function(){return R.default}),"get")}),Object.defineProperty(e,"isSexagesimal",{enumerable:!0,get:a((function(){return B.default}),"get")}),Object.defineProperty(e,"isValidCoordinate",{enumerable:!0,get:a((function(){return C.default}),"get")}),Object.defineProperty(e,"isValidLatitude",{enumerable:!0,get:a((function(){return q.default}),"get")}),Object.defineProperty(e,"isValidLongitude",{enumerable:!0,get:a((function(){return V.default}),"get")}),Object.defineProperty(e,"orderByDistance",{enumerable:!0,get:a((function(){return k.default}),"get")}),Object.defineProperty(e,"sexagesimalToDecimal",{enumerable:!0,get:a((function(){return F.default}),"get")}),Object.defineProperty(e,"toDecimal",{enumerable:!0,get:a((function(){return K.default}),"get")}),Object.defineProperty(e,"toRad",{enumerable:!0,get:a((function(){return X.default}),"get")}),Object.defineProperty(e,"toDeg",{enumerable:!0,get:a((function(){return G.default}),"get")}),Object.defineProperty(e,"wktToPolygon",{enumerable:!0,get:a((function(){return H.default}),"get")});var r=Z(nr()),n=Z(ar()),i=Z(ir()),u=Z(ur()),o=Z(lr()),l=Z(gr()),d=Z(mr()),f=Z(qt()),c=Z(_r()),g=Z(Ir()),h=Z(br()),p=Z(Dr()),y=Z(re()),v=Z(he()),m=Z($()),b=Z(At()),M=Z(Ar()),_=Z(S()),O=Z(w()),P=Z(xr()),j=Z(Cr()),I=Z(Et()),D=Z(Br()),x=Z(Vr()),L=Z(ne()),N=Z(Kr()),E=Z(Fr()),A=Z(Gr()),R=Z(Xr()),B=Z(ae()),C=Z(yt()),q=Z(ht()),V=Z(pt()),k=Z(Lt()),F=Z(ie()),K=Z(Me()),X=Z(W()),G=Z(Y()),H=Z($r()),U=T();function Z(e){return e&&e.__esModule?e:{default:e}}Object.keys(U).forEach((function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(e,r,{enumerable:!0,get:a((function(){return U[r]}),"get")})})),a(Z,"_interopRequireDefault")}));s(),s();var Jr=dn(jr());s();var Ct=class{constructor({origin:e,destination:t,vortex:r,elevationDelta:n=0,distance:a=0,angle:i=0,pathWeight:u=0}){let o,l;if(D(this,"origin"),D(this,"destination"),D(this,"vortex"),D(this,"distance"),D(this,"angle"),D(this,"weight"),this.origin=e,this.destination=t,this.vortex=r,this.distance=a,this.angle=i,r)this.distance=0,this.angle=0,o=void 0!==r.weight&&r.weight>0?r.weight:"elevator"===r.type?2e3:1e3,l=r.multiplier&&r.multiplier>=1?r.multiplier:1,this.weight=n*l+o;else{let e=u||t.weight;o=e&&e>=0?e:0,l=t.multiplier&&t.multiplier>=1?t.multiplier:1,this.weight=this.distance*l+o}if(isNaN(this.angle))throw new Error("nan angle")}};a(Ct,"Edge");var wt=Ct,k=wt;s();var Yr=(e=>(e[e.LOG=0]="LOG",e[e.WARN=1]="WARN",e[e.ERROR=2]="ERROR",e[e.SILENT=3]="SILENT",e))(Yr||{});function Xu(e){0<=e&&e<=3&&(kr.logState=e)}a(Xu,"setLoggerLevel");var kr={logState:"test"===g.env.NODE_ENV?3:0,log(...e){this.logState<=0&&console.log("[MappedInJS]",...e)},warn(...e){this.logState<=1&&console.warn("[MappedInJS]",...e)},error(...e){this.logState<=2&&console.error("[MappedInJS]",...e)},assert(...e){console.assert(...e)},time(e){console.time(e)},timeEnd(e){console.timeEnd(e)}},Zr=kr;function Uu(e){if(e.scale||e.x_scale)return 1/(e.scale||e.x_scale||1);try{if(!e.georeference)throw new Error("map ".concat(e.name||e.shortName||e.id," does not have a georeference field"));if(e.georeference.length<3)throw new Error("map ".concat(e.name||e.shortName||e.id," has less than 3 georeference points, we require at least 3 for proper map scaling"));let t=e.georeference[0],r=e.georeference[2],n=(0,Jr.getDistance)({latitude:t.target.x,longitude:t.target.y},{latitude:r.target.x,longitude:r.target.y}),a=t.control.x-r.control.x,i=t.control.y-r.control.y;return Math.sqrt(a*a+i*i)/n}catch(e){return Zr.error(e),1}}function lt(e,t){let r=e.x-t.x,n=e.y-t.y;return(Math.atan2(n,r)+2.5*Math.PI)%(2*Math.PI)}a(Uu,"getMapScale"),a(lt,"getAngle");var Kt=class{constructor({nodes:e,vortexes:t,maps:r,showVortexNames:n=!1}){D(this,"edges"),D(this,"nodesById"),D(this,"mapsById"),this.edges={},this.mapsById=r.map((e=>({...e,_scale:Uu(e)}))).reduce(((e,t)=>(e[t.id]=t,e)),{});let a=e.filter((e=>!!this.mapsById[e.map])).map((e=>({...e,paths:e.paths?e.paths.filter((({map:t})=>t===e.map)):[]})));this.nodesById=a.reduce(((e,t)=>(e[t.id]=t,e)),{});for(let e in this.nodesById)this.nodesById.hasOwnProperty(e)&&(this.nodesById[e].paths=this.nodesById[e].paths.filter((({node:e})=>!!this.nodesById[e])));let i=t.map((e=>({...e,name:n?e.name:e.type,nodes:e.nodes?e.nodes.filter((e=>!!this.nodesById[e])):[]})));a.forEach((e=>{this.edges[e.id]=e.paths.map((({node:t,weight:r})=>{let n=this.nodesById[t];return new k({angle:lt(e,n),destination:n,distance:this.getDistance(e,n),origin:e,pathWeight:r})}))})),i.forEach((e=>{if(null==e.nodes||0===e.nodes.length)return;let t=0;for(;t<e.nodes.length-1;){let r=this.nodesById[e.nodes[t]];if(t++,null==r)continue;let n=t;for(;n<e.nodes.length;){let t=this.nodesById[e.nodes[n]];if(n++,null==t)continue;let a=this.mapsById[r.map].elevation||0,i=this.mapsById[t.map].elevation||0,u=Math.abs(a-i);this.edges[r.id].push(new k({destination:t,elevationDelta:u,origin:r,vortex:e})),this.edges[t.id].push(new k({destination:r,elevationDelta:u,origin:t,vortex:e}))}}}))}aStar({originIds:e,destinationNodeIds:t,accessible:r,includedVortexIds:n,excludedVortexIds:a,excludedNodeIds:i}){let u=e.map((e=>this.nodesById[e])).filter((e=>e&&(!i||!i.has(e.id)))),o=t.map((e=>this.nodesById[e])).filter((e=>e&&(!i||!i.has(e.id))));if(0===u.length||0===o.length)return[];let l=[],s={},d={};for(u.forEach((e=>{let t=this.getShortestEuclideanDistance(e,o);l.push({origin:e,priority:t}),s[e.id]=null,d[e.id]=0})),l.sort(((e,t)=>e.priority-t.priority));l.length>0;){let e=l[0];if(o.includes(e.origin)){let t=[],r=s[e.origin.id];for(;null!=r;){t.push(r);let e=s[r.origin.id];r=null!=e?e:null}return t.reverse()}for(let t of this.edges[e.origin.id]){let u=t.vortex&&!1===t.vortex.accessible||!1===t.origin.accessible||!1===t.destination.accessible,f=t.vortex&&(n&&!n.has(t.vortex.id)||a&&a.has(t.vortex.id)),c=i&&i.has(t.destination.id);if(r&&u||f||c)continue;let g=d[e.origin.id]+t.weight;if(null==d[t.destination.id]||g<d[t.destination.id]){d[t.destination.id]=g;let e=g+this.getShortestEuclideanDistance(t.destination,o);l.push({origin:t.destination,priority:e}),s[t.destination.id]=t}}l.splice(0,1),l.sort(((e,t)=>e.priority-t.priority))}return[]}getDistance(e,t){let r,n=e.x-t.x,a=e.y-t.y,i=n*n+a*a;return r=null==this.mapsById[e.map]?1:this.mapsById[e.map]._scale,Math.sqrt(i)/r}getShortestEuclideanDistance(e,t){return t.reduce(((t,r)=>{let n=this.getDistance(e,r);return Math.min(t,n)}),Number.MAX_VALUE)}};a(Kt,"NavigationGraph");var Bt=Kt,Vt=Bt;s(),s();var Ft=(e=>(e.DEPARTURE="Departure",e.TAKEVORTEX="TakeVortex",e.EXITVORTEX="ExitVortex",e.TURN="Turn",e.ARRIVAL="Arrival",e))(Ft||{}),Gt=(e=>(e.STRAIGHT="Straight",e.RIGHT="Right",e.SLIGHTRIGHT="SlightRight",e.LEFT="Left",e.SLIGHTLEFT="SlightLeft",e))(Gt||{});function $u(e){switch(e){case"down":case"up":return"".concat(e," ");default:return""}}a($u,"vortexDirectionTest");var Xt=class{constructor({origin:e,action:t,distance:r,atLocation:n,instruction:a}){D(this,"node"),D(this,"instruction"),D(this,"action"),D(this,"atLocation"),D(this,"type"),D(this,"distance",0),this.node=e,this.action=t,this.distance=r||0,this.atLocation=n,this.instruction="",a?this.instruction=a:(null!=t&&"Departure"===t.type?this.instruction=null!=n?"Depart from ".concat(n.name):"Depart from current location":null!=t&&"Arrival"===t.type?this.instruction=null!=n?"Arrive at ".concat(n.name):"Arrive at destination":null!=t&&"TakeVortex"===t.type?this.instruction="Take ".concat(n&&n.name," ").concat($u(t.direction),"to ").concat(t.toMap.name):null!=t&&"ExitVortex"===t.type?this.instruction="Exit ".concat(n&&n.name," at ").concat(t.toMap.name):null!=t&&"bearing"in t&&"Right"===t.bearing?this.instruction="Turn right":null!=t&&"bearing"in t&&"SlightRight"===t.bearing?this.instruction="Turn slightly right":null!=t&&"bearing"in t&&"Straight"===t.bearing?this.instruction="Head straight":null!=t&&"bearing"in t&&"SlightLeft"===t.bearing?this.instruction="Turn slightly left":null!=t&&"bearing"in t&&"Left"===t.bearing&&(this.instruction="Turn left"),null!=t&&"Turn"===t.type&&n&&(this.instruction+=" at ".concat(n.name)))}};a(Xt,"Directive");var Wt=Xt,H=Wt;function Ut(e,t,r,n){if(!(e&&t&&r&&n))return null;let a=e.x,i=e.y,u=t.x,o=t.y,l=r.x,s=r.y,d=n.x,f=n.y;if(a===u&&i===o||l===d&&s===f)return null;let c=(f-s)*(u-a)-(d-l)*(o-i);if(0===c)return null;let g=((d-l)*(i-s)-(f-s)*(a-l))/c,h=((u-a)*(i-s)-(o-i)*(a-l))/c;return g<0||g>1||h<0||h>1?null:{x:a+g*(u-a),y:i+g*(o-i)}}function zr(e,t,r){if(e.x===t.x)return[{x:e.x+r,y:e.y},{x:t.x+r,y:t.y}];if(e.y===t.y)return[{x:e.x,y:e.y+r},{x:t.x,y:t.y+r}];let n=-1/((t.y-e.y)/(t.x-e.x)),a=r*Math.sqrt(1/(1+n*n)),i=n*a;return[{x:e.x+a,y:e.y+i},{x:t.x+a,y:t.y+i}]}function Qr(e,t,r=[],n=0){let a=!0;return r.forEach((r=>{if(n>0){let i=zr(e,t,-n),u=zr(e,t,n);if(Ut(i[0],i[1],r[0],r[1])||Ut(u[0],u[1],r[0],r[1]))return void(a=!1)}else if(Ut(e,t,r[0],r[1]))return void(a=!1)})),a}s(),a(Ut,"getLineIntersection"),a(zr,"getOffsetLine"),a(Qr,"hasLineOfSight");var en=(e=>(e.NO_VALID_PATH="No Valid Path Available",e))(en||{}),dt=.1*Math.PI;function ft(e,t){return((t-e+Math.PI)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)-Math.PI}a(ft,"differenceBetweenAngles");var Ht=class{constructor({locations:e,nodes:t,vortexes:r,maps:n,polygons:a,showVortexNames:i}){D(this,"graph"),D(this,"locationsByNodeId"),D(this,"geometryEdgesByMapId",new Map),this.graph=new Vt({maps:n,nodes:t,showVortexNames:i,vortexes:r}),this.locationsByNodeId=e.reduce(((e,t)=>(t.nodes&&t.nodes.forEach((r=>{e[r.node]=t})),t.polygons&&t.polygons.forEach((r=>{r.entrances&&r.entrances.forEach((r=>{e[r]=t}))})),e)),{}),a&&a.forEach((e=>{if(this.geometryEdgesByMapId.has(e.map)||this.geometryEdgesByMapId.set(e.map,[]),!0===e.isLineStringSegment)for(let t of e.vertexes)for(let r=0;r<t.length;r++)t[r+1]&&this.geometryEdgesByMapId.get(e.map).push([t[r],t[r+1]]);else e.vertexes.forEach(((t,r)=>{e.vertexes[r+1]?this.geometryEdgesByMapId.get(e.map).push([t,e.vertexes[r+1]]):this.geometryEdgesByMapId.get(e.map).push([t,e.vertexes[0]])}))}))}getClosestLocationInRay(e,t=.5*Math.PI,r=10){let n=0,a=0,i=e;for(;Math.abs(n)<t&&a<r;){let e=this.graph.edges[i.destination.id],u=null,o=0;for(let t of e)if(t.distance>0)if(null!=u){let e=-ft(i.angle,t.angle);Math.abs(e)<Math.abs(o)&&(u=t,o=e)}else u=t,o=-ft(i.angle,t.angle);if(null==u)return null;{if(Math.abs(o)>=t||(n+=o,a+=u.distance,Math.abs(n)>=t||a>r))return null;let e=this.locationsByNodeId[u.destination.id];if(null!=e)return e;i=u}}return null}getDirections({originIds:e,destinationNodeIds:t,accessible:r,departFrom:n,arriveAt:a,includedVortexIds:i,excludedVortexIds:u,excludedNodeIds:o,simplify:l}){var s,d,f;let c=this.graph.aStar({originIds:e,destinationNodeIds:t,accessible:r,includedVortexIds:i,excludedVortexIds:u,excludedNodeIds:o});if(0===c.length)return{distance:0,instructions:[new H({distance:0,instruction:"No Valid Path Available"})],path:[]};let g=0,h=[],p=[];if(null!=l&&l.enabled){let e=null!=(s=null==l?void 0:l.bufferRadius)?s:1.8,t=[c[0]];for(let r=1;r<c.length;r++){if(c[r].origin.map!==c[r-1].origin.map){let n=null!=(d=this.geometryEdgesByMapId.get(c[r-1].origin.map))?d:[];p.push(...this.simplifySteps(t,n,e)),t=[c[r]]}t.push(c[r])}let r=c[c.length-1],n=null!=(f=this.geometryEdgesByMapId.get(r.origin.map))?f:[];p.push(...this.simplifySteps(t,n,e)),c=p}for(let e=0;e<c.length;e++)h.push(c[e].origin);h.push(c[c.length-1].destination);let y=[],v=null,m=null,b=0,M=0;for(let e=0;e<c.length;e++){let t=c[e],r=t.origin,i=t.destination;if(g+=t.distance,b+=(null==m?void 0:m.distance)||0,0===e&&y.push(new H({action:{type:"Departure"},atLocation:n,distance:0,origin:r})),null!=t.vortex){let e=this.graph.mapsById[r.map],n=this.graph.mapsById[i.map],a="none";if(null!=e.elevation&&null!=n.elevation){let t=e.elevation-n.elevation;t>0?a="down":t<0&&(a="up")}y.push(new H({action:{direction:a,fromMap:e,toMap:n,type:"TakeVortex"},atLocation:t.vortex,distance:b,origin:r})),M+=b,b=0}else if(null!=v&&null!=m)if(null!=m.vortex){let e=this.graph.mapsById[v.map],t=this.graph.mapsById[m.destination.map];y.push(new H({action:{fromMap:e,toMap:t,type:"ExitVortex"},atLocation:m.vortex,distance:b,origin:r})),M+=b,b=0}else{let e=this.graph.edges[r.id].filter((e=>e.destination!==v&&e.destination!==t.destination));if(e.length>0){let n=-ft(m.angle,t.angle),a=e.reduce(((e,r)=>{let n=-ft(t.angle,r.angle);return Math.min(e,Math.abs(n))}),Math.PI);if(Math.abs(n)>=dt||Math.abs(a)<=dt){let e;e=n<=-Math.PI/4?"Right":n<=-dt?"SlightRight":n<=dt?"Straight":n<=Math.PI/4?"SlightLeft":"Left";let t=this.locationsByNodeId[r.id];if(t||(t=this.getClosestLocationInRay(m,.5*Math.PI,10)),null!=t){let n=new H({action:{bearing:e,referencePosition:"At",type:"Turn"},atLocation:t,distance:b,origin:r});n.type=e,y.push(n)}else y.push(new H({action:{bearing:e,referencePosition:"At",type:"Turn"},distance:b,origin:r}));M+=b,b=0}}}e===c.length-1&&(y.push(new H({action:{type:"Arrival"},atLocation:a,distance:g-M<0?0:g-M,origin:t.destination})),M+=b,b=0),v=r,m=t}let _=[],O=null;for(let e=y.length-1;e>=0;e--){let t=y[e],{action:r}=t;r&&"TakeVortex"===r.type?(O=t.node,_.unshift(t)):r&&"Turn"===r.type&&null!=O?this.graph.getDistance(t.node,O)>5?_.unshift(t):_[0].distance+=t.distance:_.unshift(t)}return{distance:g,instructions:_,path:h}}simplifySteps(e,t,r){if(e.length<3)return e;let n=[e[0]],a=1;for(let i=a+2;i<e.length;i++)if(!Qr(e[a].origin,e[i].origin,t,r)){let t=i-1;n.push(new k({...e[a],destination:e[t].origin,distance:this.graph.getDistance(e[a].origin,e[t].origin),angle:lt(e[a].origin,e[t].origin)})),a=t}return n.push(new k({...e[a],destination:e[e.length-1].origin,distance:this.graph.getDistance(e[a].origin,e[e.length-1].origin),angle:lt(e[a].origin,e[e.length-1].origin)}),e[e.length-1]),n}};a(Ht,"Navigator");var $t=Ht,Hu=$t;export{Ft as ACTION_TYPE,Gt as BEARING_TYPE,en as E_MESSAGES,Yr as E_SDK_LOG_LEVEL,Vt as NavigationGraph,Hu as Navigator,Xu as setLoggerLevel};
@@ -1 +1 @@
1
- import{$ as _,A as He,D as Ve,E as V,L as G,Ma as z,N as Ge,Na as Ze,R as Ye,S as D,V as W,Y as Ke,ba as je,da as qe,e as _e,fa as Xe,ha as We,i as Ce,j as Ue,k as ve,l as Le,m as Oe,ma as Je,n as De,o as Pe,oa as P,p as ze,q as Be,ta as Y,ua as Qe,w as Fe,z as ke}from"./chunk-TUEPC7VC.js";import{a as H}from"./chunk-JIMJW33G.js";import{a as T}from"./chunk-ZRT45YCM.js";var B,J,U,K;function j(e,t=1/0,s=null){J||(J=new We(2,2,1,1)),U||(U=new qe({uniforms:{blitTexture:new Ze(e)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),U.uniforms.blitTexture.value=e,U.defines.IS_SRGB=e.colorSpace==V,U.needsUpdate=!0,K||((K=new je(J,U)).frustrumCulled=!1);let r=new Xe,n=new P;n.add(K),null===s&&(s=B=new Je({antialias:!1}));let i=Math.min(e.image.width,t),a=Math.min(e.image.height,t);s.setSize(i,a),s.clear(),s.render(n,r);let o=document.createElement("canvas"),l=o.getContext("2d");o.width=i,o.height=a,l.drawImage(s.domElement,0,0,i,a);let c=new Qe(o);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,B&&(B.forceContextLoss(),B.dispose(),B=null),c}H(),H(),T(j,"decompress");var $e={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},pe=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new ee(e)})),this.register((function(e){return new se(e)})),this.register((function(e){return new re(e)})),this.register((function(e){return new ie(e)})),this.register((function(e){return new oe(e)})),this.register((function(e){return new ae(e)})),this.register((function(e){return new te(e)})),this.register((function(e){return new ne(e)})),this.register((function(e){return new ce(e)})),this.register((function(e){return new ue(e)})),this.register((function(e){return new le(e)})),this.register((function(e){return new fe(e)})),this.register((function(e){return new he(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n=new $,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](n));n.setPlugins(i),n.write(e,t,r).catch(s)}parseAsync(e,t){let s=this;return new Promise((function(r,n){s.parse(e,r,n,t)}))}};T(pe,"GLTFExporter");var q=pe,x={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Q="KHR_mesh_quantization",b={};b[Le]=x.NEAREST,b[Oe]=x.NEAREST_MIPMAP_NEAREST,b[De]=x.NEAREST_MIPMAP_LINEAR,b[Pe]=x.LINEAR,b[ze]=x.LINEAR_MIPMAP_NEAREST,b[Be]=x.LINEAR_MIPMAP_LINEAR,b[Ue]=x.CLAMP_TO_EDGE,b[Ce]=x.REPEAT,b[ve]=x.MIRRORED_REPEAT;var es={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},cs=new Ke,ss=12,us=1179937895,ls=2,ts=8,fs=1313821514,hs=5130562;function F(e,t){return e.length===t.length&&e.every((function(e,s){return e===t[s]}))}function ps(e){return(new TextEncoder).encode(e).buffer}function ds(e){return F(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function gs(e,t,s){let r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=t;n<t+s;n++)for(let t=0;t<e.itemSize;t++){let s;e.itemSize>4?s=e.array[n*e.itemSize+t]:(0===t?s=e.getX(n):1===t?s=e.getY(n):2===t?s=e.getZ(n):3===t&&(s=e.getW(n)),!0===e.normalized&&(s=G.normalize(s,e.array))),r.min[t]=Math.min(r.min[t],s),r.max[t]=Math.max(r.max[t],s)}return r}function is(e){return 4*Math.ceil(e/4)}function Z(e,t=0){let s=is(e.byteLength);if(s!==e.byteLength){let r=new Uint8Array(s);if(r.set(new Uint8Array(e)),0!==t)for(let n=e.byteLength;n<s;n++)r[n]=t;return r.buffer}return e}function ns(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function rs(e,t){if(void 0!==e.toBlob)return new Promise((s=>e.toBlob(s,t)));let s;return"image/jpeg"===t?s=.92:"image/webp"===t&&(s=.8),e.convertToBlob({type:t,quality:s})}T(F,"equalArray"),T(ps,"stringToArrayBuffer"),T(ds,"isIdentityMatrix"),T(gs,"getMinMax"),T(is,"getPaddedBufferSize"),T(Z,"getPaddedArrayBuffer"),T(ns,"getCanvas"),T(rs,"getToBlobPromise");var de=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,s={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let r=this,n=r.buffers,i=r.json;s=r.options;let a=r.extensionsUsed,o=r.extensionsRequired,l=new Blob(n,{type:"application/octet-stream"}),c=Object.keys(a),u=Object.keys(o);if(c.length>0&&(i.extensionsUsed=c),u.length>0&&(i.extensionsRequired=u),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=l.size),!0===s.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let s=Z(e.result),r=new DataView(new ArrayBuffer(ts));r.setUint32(0,s.byteLength,!0),r.setUint32(4,hs,!0);let n=Z(ps(JSON.stringify(i)),32),a=new DataView(new ArrayBuffer(ts));a.setUint32(0,n.byteLength,!0),a.setUint32(4,fs,!0);let o=new ArrayBuffer(ss),l=new DataView(o);l.setUint32(0,us,!0),l.setUint32(4,ls,!0);let c=ss+a.byteLength+n.byteLength+r.byteLength+s.byteLength;l.setUint32(8,c,!0);let u=new Blob([o,a,n,r,s],{type:"application/octet-stream"}),h=new FileReader;h.readAsArrayBuffer(u),h.onloadend=function(){t(h.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let s=e.result;i.buffers[0].uri=s,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let s=this.options,r=this.extensionsUsed;try{let n=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&n.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in n.gltfExtensions)t.extensions[e]=n.gltfExtensions[e],r[e]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new D;for(let s=0,r=e.count;s<r;s++)if(Math.abs(t.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let s=e.clone(),r=new D;for(let e=0,t=s.count;e<t;e++)r.fromBufferAttribute(s,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),s.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1,r={};(0!==t.offset.x||0!==t.offset.y)&&(r.offset=t.offset.toArray(),s=!0),0!==t.rotation&&(r.rotation=t.rotation,s=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(r.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function s(e){return e.colorSpace===V?T((function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}),"SRGBToLinear"):T((function(e){return e}),"LinearToLinear")}T(s,"getEncodingConversion"),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof Y&&(e=j(e)),t instanceof Y&&(t=j(t));let r=e?e.image:null,n=t?t.image:null,i=Math.max(r?r.width:0,n?n.width:0),a=Math.max(r?r.height:0,n?n.height:0),o=ns();o.width=i,o.height=a;let l=o.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,i,a);let c=l.getImageData(0,0,i,a);if(r){l.drawImage(r,0,0,i,a);let t=s(e),n=l.getImageData(0,0,i,a).data;for(let e=2;e<n.length;e+=4)c.data[e]=256*t(n[e]/256)}if(n){l.drawImage(n,0,0,i,a);let e=s(t),r=l.getImageData(0,0,i,a).data;for(let t=1;t<r.length;t+=4)c.data[t]=256*e(r[t]/256)}l.putImageData(c,0,0);let u=(e||t).clone();return u.source=new Ge(o),u.colorSpace=Ve,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),u}processBuffer(e){let t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,r,n){let i,a=this.json;switch(a.bufferViews||(a.bufferViews=[]),t){case x.BYTE:case x.UNSIGNED_BYTE:i=1;break;case x.SHORT:case x.UNSIGNED_SHORT:i=2;break;default:i=4}let o=is(r*e.itemSize*i),l=new DataView(new ArrayBuffer(o)),c=0;for(let n=s;n<s+r;n++)for(let s=0;s<e.itemSize;s++){let r;e.itemSize>4?r=e.array[n*e.itemSize+s]:(0===s?r=e.getX(n):1===s?r=e.getY(n):2===s?r=e.getZ(n):3===s&&(r=e.getW(n)),!0===e.normalized&&(r=G.normalize(r,e.array))),t===x.FLOAT?l.setFloat32(c,r,!0):t===x.INT?l.setInt32(c,r,!0):t===x.UNSIGNED_INT?l.setUint32(c,r,!0):t===x.SHORT?l.setInt16(c,r,!0):t===x.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===x.BYTE?l.setInt8(c,r):t===x.UNSIGNED_BYTE&&l.setUint8(c,r),c+=i}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==n&&(u.target=n),n===x.ARRAY_BUFFER&&(u.byteStride=e.itemSize*i),this.byteOffset+=o,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise((function(r){let n=new FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){let e=Z(n.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(s.bufferViews.push(i)-1)}}))}processAccessor(e,t,s,r){let n,i=this.json;if(e.array.constructor===Float32Array)n=x.FLOAT;else if(e.array.constructor===Int32Array)n=x.INT;else if(e.array.constructor===Uint32Array)n=x.UNSIGNED_INT;else if(e.array.constructor===Int16Array)n=x.SHORT;else if(e.array.constructor===Uint16Array)n=x.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)n=x.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);n=x.UNSIGNED_BYTE}if(void 0===s&&(s=0),(void 0===r||r===1/0)&&(r=e.count),0===r)return null;let a,o=gs(e,s,r);void 0!==t&&(a=e===t.index?x.ELEMENT_ARRAY_BUFFER:x.ARRAY_BUFFER);let l=this.processBufferView(e,n,s,r,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:n,count:r,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(c)-1}processImage(e,t,s,r="image/png"){if(null!==e){let n=this,i=n.cache,a=n.json,o=n.options,l=n.pending;i.images.has(e)||i.images.set(e,{});let c=i.images.get(e),u=r+":flipY/"+s.toString();if(void 0!==c[u])return c[u];a.images||(a.images=[]);let h={mimeType:r},p=ns();p.width=Math.min(e.width,o.maxTextureSize),p.height=Math.min(e.height,o.maxTextureSize);let m=p.getContext("2d");if(!0===s&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==Fe&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let s=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<s.length;t+=4)s[t+0]=e.data[t+0],s[t+1]=e.data[t+1],s[t+2]=e.data[t+2],s[t+3]=e.data[t+3];m.putImageData(new ImageData(s,e.width,e.height),0,0)}else{if(!(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement or ImageBitmap.");m.drawImage(e,0,0,p.width,p.height)}!0===o.binary?l.push(rs(p,r).then((e=>n.processBufferViewImage(e))).then((e=>{h.bufferView=e}))):void 0!==p.toDataURL?h.uri=p.toDataURL(r):l.push(rs(p,r).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{h.uri=e})));let f=a.images.push(h)-1;return c[u]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let s={magFilter:b[e.magFilter],minFilter:b[e.minFilter],wrapS:b[e.wrapS],wrapT:b[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){let t=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof Y&&(e=j(e,t.maxTextureSize));let n=e.userData.mimeType;"image/webp"===n&&(n="image/png");let i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,n)};e.name&&(i.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,i)}));let a=r.textures.push(i)-1;return s.textures.set(e,a),a}processMaterial(e){let t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let n=e.color.toArray().concat([e.opacity]);if(F(n,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),s={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(s,t),r.pbrMetallicRoughness.metallicRoughnessTexture=s}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===_e&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,r)}));let i=s.materials.push(r)-1;return t.materials.set(e,i),i}processMesh(e){let t=this.cache,s=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,s=e.material.length;t<s;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let n=r.join(":");if(t.meshes.has(n))return t.meshes.get(n);let i,a=e.geometry;i=e.isLineSegments?x.LINES:e.isLineLoop?x.LINE_LOOP:e.isLine?x.LINE_STRIP:e.isPoints?x.POINTS:e.material.wireframe?x.LINES:x.TRIANGLES;let o={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=a.getAttribute("normal");void 0!==p&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let m=null;for(let e in a.attributes){if("morph"===e.slice(0,5))continue;let s=a.attributes[e];if(e=h[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(s))){l[e]=t.attributes.get(this.getUID(s));continue}m=null;let r=s.array;"JOINTS_0"===e&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new _(new Uint16Array(r),s.itemSize,s.normalized));let n=this.processAccessor(m||s,a);null!==n&&(e.startsWith("_")||this.detectMeshQuantization(e,s),l[e]=n,t.attributes.set(this.getUID(s),n))}if(void 0!==p&&a.setAttribute("normal",p),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){let s=[],r=[],n={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let i=0;i<e.morphTargetInfluences.length;++i){let o={},l=!1;for(let e in a.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}let s=a.morphAttributes[e][i],r=e.toUpperCase(),n=a.attributes[e];if(t.attributes.has(this.getUID(s,!0))){o[r]=t.attributes.get(this.getUID(s,!0));continue}let c=s.clone();if(!a.morphTargetsRelative)for(let e=0,t=s.count;e<t;e++)for(let t=0;t<s.itemSize;t++)0===t&&c.setX(e,s.getX(e)-n.getX(e)),1===t&&c.setY(e,s.getY(e)-n.getY(e)),2===t&&c.setZ(e,s.getZ(e)-n.getZ(e)),3===t&&c.setW(e,s.getW(e)-n.getW(e));o[r]=this.processAccessor(c,a),t.attributes.set(this.getUID(n,!0),o[r])}u.push(o),s.push(e.morphTargetInfluences[i]),void 0!==e.morphTargetDictionary&&r.push(n[i])}o.weights=s,r.length>0&&(o.extras={},o.extras.targetNames=r)}let f=Array.isArray(e.material);if(f&&0===a.groups.length)return null;let g=!1;if(f&&null===a.index){let e=[];for(let t=0,s=a.attributes.position.count;t<s;t++)e[t]=t;a.setIndex(e),g=!0}let d=f?e.material:[e.material],T=f?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,s=T.length;e<s;e++){let s={mode:i,attributes:l};if(this.serializeUserData(a,s),u.length>0&&(s.targets=u),null!==a.index){let r=this.getUID(a.index);(void 0!==T[e].start||void 0!==T[e].count)&&(r+=":"+T[e].start+":"+T[e].count),t.attributes.has(r)?s.indices=t.attributes.get(r):(s.indices=this.processAccessor(a.index,a,T[e].start,T[e].count),t.attributes.set(r,s.indices)),null===s.indices&&delete s.indices}let r=this.processMaterial(d[T[e].materialIndex]);null!==r&&(s.material=r),c.push(s)}!0===g&&a.setIndex(null),o.primitives=c,s.meshes||(s.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let y=s.meshes.push(o)-1;return t.meshes.set(n,y),y}detectMeshQuantization(e,t){if(this.extensionsUsed[Q])return;let s;switch(t.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}t.normalized&&(s+=" normalized");let r=e.split("_",1)[0];$e[r]&&$e[r].includes(s)&&(this.extensionsUsed[Q]=!0,this.extensionsRequired[Q]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let s=e.isOrthographicCamera,r={type:s?"orthographic":"perspective"};return s?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:G.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let s=this.json,r=this.nodeMap;s.animations||(s.animations=[]);let n=(e=q.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,i=[],a=[];for(let e=0;e<n.length;++e){let s=n[e],o=z.parseTrackName(s.name),l=z.findNode(t,o.nodeName),c=es[o.propertyName];if("bones"===o.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(o.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',s.name),null;let u,h=1,p=s.values.length/s.times.length;c===es.morphTargetInfluences&&(p/=l.morphTargetInfluences.length),!0===s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",p/=3):u=s.getInterpolation()===ke?"STEP":"LINEAR",a.push({input:this.processAccessor(new _(s.times,h)),output:this.processAccessor(new _(s.values,p)),interpolation:u}),i.push({sampler:a.length-1,target:{node:r.get(l),path:c}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:i}),s.animations.length-1}processSkin(e){let t=this.json,s=this.nodeMap,r=t.nodes[s.get(e)],n=e.skeleton;if(void 0===n)return null;let i=e.skeleton.bones[0];if(void 0===i)return null;let a=[],o=new Float32Array(16*n.bones.length),l=new W;for(let t=0;t<n.bones.length;++t)a.push(s.get(n.bones[t])),l.copy(n.boneInverses[t]),l.multiply(e.bindMatrix).toArray(o,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new _(o,16)),joints:a,skeleton:s.get(i)}),r.skin=t.skins.length-1}processNode(e){let t=this.json,s=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);let n={};if(s.trs){let t=e.quaternion.toArray(),s=e.position.toArray(),r=e.scale.toArray();F(t,[0,0,0,1])||(n.rotation=t),F(s,[0,0,0])||(n.translation=s),F(r,[1,1,1])||(n.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===ds(e.matrix)&&(n.matrix=e.matrix.elements);if(""!==e.name&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);null!==t&&(n.mesh=t)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,n=e.children.length;r<n;r++){let n=e.children[r];if(n.visible||!1===s.onlyVisible){let e=this.processNode(n);null!==e&&t.push(e)}}t.length>0&&(n.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,n)}));let i=t.nodes.push(n)-1;return r.set(e,i),i}processScene(e){let t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let n=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||!1===s.onlyVisible){let e=this.processNode(r);null!==e&&n.push(e)}}n.length>0&&(r.nodes=n),this.serializeUserData(e,r)}processObjects(e){let t=new P;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));let s=[];for(let t=0;t<e.length;t++)e[t]instanceof P?this.processScene(e[t]):s.push(e[t]);s.length>0&&this.processObjects(s);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}};T(de,"GLTFWriter");var $=de,ge=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);let s=this.writer,r=s.json,n=s.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(1-e.penumbra)*e.angle,i.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},n[this.name]=!0);let a=r.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}};T(ge,"GLTFLightExtension");var ee=ge,xe=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}};T(xe,"GLTFMaterialsUnlitExtension");var se=xe,me=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:s.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};s.applyTextureTransform(t,e.clearcoatMap),n.clearcoatTexture=t}if(n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:s.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};s.applyTextureTransform(t,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:s.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};s.applyTextureTransform(t,e.clearcoatNormalMap),n.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(me,"GLTFMaterialsClearcoatExtension");var te=me,Te=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:s.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};s.applyTextureTransform(t,e.iridescenceMap),n.iridescenceTexture=t}if(n.iridescenceIor=e.iridescenceIOR,n.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],n.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:s.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};s.applyTextureTransform(t,e.iridescenceThicknessMap),n.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Te,"GLTFMaterialsIridescenceExtension");var ne=Te,ye=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.transmissionFactor=e.transmission,e.transmissionMap){let t={index:s.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};s.applyTextureTransform(t,e.transmissionMap),n.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(ye,"GLTFMaterialsTransmissionExtension");var re=ye,we=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.thicknessFactor=e.thickness,e.thicknessMap){let t={index:s.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};s.applyTextureTransform(t,e.thicknessMap),n.thicknessTexture=t}n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(we,"GLTFMaterialsVolumeExtension");var ie=we,Me=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(Me,"GLTFMaterialsIorExtension");var oe=Me,Ie=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(cs)&&!e.specularIntensityMap&&!e.specularColorMap)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.specularIntensityMap){let t={index:s.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};s.applyTextureTransform(t,e.specularIntensityMap),n.specularTexture=t}if(e.specularColorMap){let t={index:s.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};s.applyTextureTransform(t,e.specularColorMap),n.specularColorTexture=t}n.specularFactor=e.specularIntensity,n.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Ie,"GLTFMaterialsSpecularExtension");var ae=Ie,Ae=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.sheenRoughnessMap){let t={index:s.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};s.applyTextureTransform(t,e.sheenRoughnessMap),n.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:s.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};s.applyTextureTransform(t,e.sheenColorMap),n.sheenColorTexture=t}n.sheenRoughnessFactor=e.sheenRoughness,n.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Ae,"GLTFMaterialsSheenExtension");var ce=Ae,Re=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.anisotropyMap){let t={index:s.processTexture(e.anisotropyMap)};s.applyTextureTransform(t,e.anisotropyMap),n.anisotropyTexture=t}n.anisotropyStrength=e.anisotropy,n.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Re,"GLTFMaterialsAnisotropyExtension");var ue=Re,Ee=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(Ee,"GLTFMaterialsEmissiveStrengthExtension");var le=Ee,be=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.bumpMap){let t={index:s.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};s.applyTextureTransform(t,e.bumpMap),n.bumpTexture=t}n.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(be,"GLTFMaterialsBumpExtension");var fe=be,Ne=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let s=this.writer,r=e,n=new Float32Array(3*r.count),i=new Float32Array(4*r.count),a=new Float32Array(3*r.count),o=new W,l=new D,c=new Ye,u=new D;for(let e=0;e<r.count;e++)r.getMatrixAt(e,o),o.decompose(l,c,u),l.toArray(n,3*e),c.toArray(i,4*e),u.toArray(a,3*e);let h={TRANSLATION:s.processAccessor(new _(n,3)),ROTATION:s.processAccessor(new _(i,4)),SCALE:s.processAccessor(new _(a,3))};r.instanceColor&&(h._COLOR_0=s.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:h},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}};T(Ne,"GLTFMeshGpuInstancing");var he=Ne;q.Utils={insertKeyframe:function(e,t){let s,r=e.getValueSize(),n=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+r),a=e.createInterpolant(new e.ValueBufferType(r));if(0===e.times.length){n[0]=t;for(let e=0;e<r;e++)i[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;n[0]=t,n.set(e.times,1),i.set(a.evaluate(t),0),i.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;n[n.length-1]=t,n.set(e.times,0),i.set(e.values,0),i.set(a.evaluate(t),e.values.length),s=n.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){n.set(e.times.slice(0,o+1),0),n[o+1]=t,n.set(e.times.slice(o+1),o+2),i.set(e.values.slice(0,(o+1)*r),0),i.set(a.evaluate(t),(o+1)*r),i.set(e.values.slice((o+1)*r),(o+2)*r),s=o+1;break}}return e.times=n,e.values=i,s},mergeMorphTargetTracks:function(e,t){let s=[],r={},n=e.tracks;for(let e=0;e<n.length;++e){let i=n[e],a=z.parseTrackName(i.name),o=z.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){s.push(i);continue}if(i.createInterpolant!==i.InterpolantFactoryMethodDiscrete&&i.createInterpolant!==i.InterpolantFactoryMethodLinear){if(i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),i=i.clone(),i.setInterpolation(He)}let l,c=o.morphTargetInfluences.length,u=o.morphTargetDictionary[a.propertyIndex];if(void 0===u)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);if(void 0===r[o.uuid]){l=i.clone();let e=new l.ValueBufferType(c*l.times.length);for(let t=0;t<l.times.length;t++)e[t*c+u]=l.values[t];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=e,r[o.uuid]=l,s.push(l);continue}let h=i.createInterpolant(new i.ValueBufferType(1));l=r[o.uuid];for(let e=0;e<l.times.length;e++)l.values[e*c+u]=h.evaluate(l.times[e]);for(let e=0;e<i.times.length;e++){let t=this.insertKeyframe(l,i.times[e]);l.values[t*c+u]=i.values[e]}}return e.tracks=s,e}};export{q as GLTFExporter};
1
+ import{$ as _,A as He,D as Ve,E as V,L as G,Ma as z,N as Ge,Na as Ze,R as Ye,S as D,V as W,Y as Ke,ba as je,da as qe,e as _e,fa as Xe,ha as We,i as Ce,j as Ue,k as ve,l as Le,m as Oe,ma as Je,n as De,o as Pe,oa as P,p as ze,q as Be,ta as Y,ua as Qe,w as Fe,z as ke}from"./chunk-I76QBIBM.js";import{a as H}from"./chunk-ARDLMWG5.js";import{a as T}from"./chunk-ZRT45YCM.js";var B,J,U,K;function j(e,t=1/0,s=null){J||(J=new We(2,2,1,1)),U||(U=new qe({uniforms:{blitTexture:new Ze(e)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),U.uniforms.blitTexture.value=e,U.defines.IS_SRGB=e.colorSpace==V,U.needsUpdate=!0,K||((K=new je(J,U)).frustrumCulled=!1);let r=new Xe,n=new P;n.add(K),null===s&&(s=B=new Je({antialias:!1}));let i=Math.min(e.image.width,t),a=Math.min(e.image.height,t);s.setSize(i,a),s.clear(),s.render(n,r);let o=document.createElement("canvas"),l=o.getContext("2d");o.width=i,o.height=a,l.drawImage(s.domElement,0,0,i,a);let c=new Qe(o);return c.minFilter=e.minFilter,c.magFilter=e.magFilter,c.wrapS=e.wrapS,c.wrapT=e.wrapT,c.name=e.name,B&&(B.forceContextLoss(),B.dispose(),B=null),c}H(),H(),T(j,"decompress");var $e={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},pe=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new ee(e)})),this.register((function(e){return new se(e)})),this.register((function(e){return new re(e)})),this.register((function(e){return new ie(e)})),this.register((function(e){return new oe(e)})),this.register((function(e){return new ae(e)})),this.register((function(e){return new te(e)})),this.register((function(e){return new ne(e)})),this.register((function(e){return new ce(e)})),this.register((function(e){return new ue(e)})),this.register((function(e){return new le(e)})),this.register((function(e){return new fe(e)})),this.register((function(e){return new he(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n=new $,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](n));n.setPlugins(i),n.write(e,t,r).catch(s)}parseAsync(e,t){let s=this;return new Promise((function(r,n){s.parse(e,r,n,t)}))}};T(pe,"GLTFExporter");var q=pe,x={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Q="KHR_mesh_quantization",b={};b[Le]=x.NEAREST,b[Oe]=x.NEAREST_MIPMAP_NEAREST,b[De]=x.NEAREST_MIPMAP_LINEAR,b[Pe]=x.LINEAR,b[ze]=x.LINEAR_MIPMAP_NEAREST,b[Be]=x.LINEAR_MIPMAP_LINEAR,b[Ue]=x.CLAMP_TO_EDGE,b[Ce]=x.REPEAT,b[ve]=x.MIRRORED_REPEAT;var es={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},cs=new Ke,ss=12,us=1179937895,ls=2,ts=8,fs=1313821514,hs=5130562;function F(e,t){return e.length===t.length&&e.every((function(e,s){return e===t[s]}))}function ps(e){return(new TextEncoder).encode(e).buffer}function ds(e){return F(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function gs(e,t,s){let r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=t;n<t+s;n++)for(let t=0;t<e.itemSize;t++){let s;e.itemSize>4?s=e.array[n*e.itemSize+t]:(0===t?s=e.getX(n):1===t?s=e.getY(n):2===t?s=e.getZ(n):3===t&&(s=e.getW(n)),!0===e.normalized&&(s=G.normalize(s,e.array))),r.min[t]=Math.min(r.min[t],s),r.max[t]=Math.max(r.max[t],s)}return r}function is(e){return 4*Math.ceil(e/4)}function Z(e,t=0){let s=is(e.byteLength);if(s!==e.byteLength){let r=new Uint8Array(s);if(r.set(new Uint8Array(e)),0!==t)for(let n=e.byteLength;n<s;n++)r[n]=t;return r.buffer}return e}function ns(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function rs(e,t){if(void 0!==e.toBlob)return new Promise((s=>e.toBlob(s,t)));let s;return"image/jpeg"===t?s=.92:"image/webp"===t&&(s=.8),e.convertToBlob({type:t,quality:s})}T(F,"equalArray"),T(ps,"stringToArrayBuffer"),T(ds,"isIdentityMatrix"),T(gs,"getMinMax"),T(is,"getPaddedBufferSize"),T(Z,"getPaddedArrayBuffer"),T(ns,"getCanvas"),T(rs,"getToBlobPromise");var de=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,s={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let r=this,n=r.buffers,i=r.json;s=r.options;let a=r.extensionsUsed,o=r.extensionsRequired,l=new Blob(n,{type:"application/octet-stream"}),c=Object.keys(a),u=Object.keys(o);if(c.length>0&&(i.extensionsUsed=c),u.length>0&&(i.extensionsRequired=u),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=l.size),!0===s.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let s=Z(e.result),r=new DataView(new ArrayBuffer(ts));r.setUint32(0,s.byteLength,!0),r.setUint32(4,hs,!0);let n=Z(ps(JSON.stringify(i)),32),a=new DataView(new ArrayBuffer(ts));a.setUint32(0,n.byteLength,!0),a.setUint32(4,fs,!0);let o=new ArrayBuffer(ss),l=new DataView(o);l.setUint32(0,us,!0),l.setUint32(4,ls,!0);let c=ss+a.byteLength+n.byteLength+r.byteLength+s.byteLength;l.setUint32(8,c,!0);let u=new Blob([o,a,n,r,s],{type:"application/octet-stream"}),h=new FileReader;h.readAsArrayBuffer(u),h.onloadend=function(){t(h.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let s=e.result;i.buffers[0].uri=s,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let s=this.options,r=this.extensionsUsed;try{let n=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&n.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in n.gltfExtensions)t.extensions[e]=n.gltfExtensions[e],r[e]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new D;for(let s=0,r=e.count;s<r;s++)if(Math.abs(t.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let s=e.clone(),r=new D;for(let e=0,t=s.count;e<t;e++)r.fromBufferAttribute(s,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),s.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1,r={};(0!==t.offset.x||0!==t.offset.y)&&(r.offset=t.offset.toArray(),s=!0),0!==t.rotation&&(r.rotation=t.rotation,s=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(r.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function s(e){return e.colorSpace===V?T((function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}),"SRGBToLinear"):T((function(e){return e}),"LinearToLinear")}T(s,"getEncodingConversion"),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof Y&&(e=j(e)),t instanceof Y&&(t=j(t));let r=e?e.image:null,n=t?t.image:null,i=Math.max(r?r.width:0,n?n.width:0),a=Math.max(r?r.height:0,n?n.height:0),o=ns();o.width=i,o.height=a;let l=o.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,i,a);let c=l.getImageData(0,0,i,a);if(r){l.drawImage(r,0,0,i,a);let t=s(e),n=l.getImageData(0,0,i,a).data;for(let e=2;e<n.length;e+=4)c.data[e]=256*t(n[e]/256)}if(n){l.drawImage(n,0,0,i,a);let e=s(t),r=l.getImageData(0,0,i,a).data;for(let t=1;t<r.length;t+=4)c.data[t]=256*e(r[t]/256)}l.putImageData(c,0,0);let u=(e||t).clone();return u.source=new Ge(o),u.colorSpace=Ve,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),u}processBuffer(e){let t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,r,n){let i,a=this.json;switch(a.bufferViews||(a.bufferViews=[]),t){case x.BYTE:case x.UNSIGNED_BYTE:i=1;break;case x.SHORT:case x.UNSIGNED_SHORT:i=2;break;default:i=4}let o=is(r*e.itemSize*i),l=new DataView(new ArrayBuffer(o)),c=0;for(let n=s;n<s+r;n++)for(let s=0;s<e.itemSize;s++){let r;e.itemSize>4?r=e.array[n*e.itemSize+s]:(0===s?r=e.getX(n):1===s?r=e.getY(n):2===s?r=e.getZ(n):3===s&&(r=e.getW(n)),!0===e.normalized&&(r=G.normalize(r,e.array))),t===x.FLOAT?l.setFloat32(c,r,!0):t===x.INT?l.setInt32(c,r,!0):t===x.UNSIGNED_INT?l.setUint32(c,r,!0):t===x.SHORT?l.setInt16(c,r,!0):t===x.UNSIGNED_SHORT?l.setUint16(c,r,!0):t===x.BYTE?l.setInt8(c,r):t===x.UNSIGNED_BYTE&&l.setUint8(c,r),c+=i}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==n&&(u.target=n),n===x.ARRAY_BUFFER&&(u.byteStride=e.itemSize*i),this.byteOffset+=o,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise((function(r){let n=new FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){let e=Z(n.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(s.bufferViews.push(i)-1)}}))}processAccessor(e,t,s,r){let n,i=this.json;if(e.array.constructor===Float32Array)n=x.FLOAT;else if(e.array.constructor===Int32Array)n=x.INT;else if(e.array.constructor===Uint32Array)n=x.UNSIGNED_INT;else if(e.array.constructor===Int16Array)n=x.SHORT;else if(e.array.constructor===Uint16Array)n=x.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)n=x.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);n=x.UNSIGNED_BYTE}if(void 0===s&&(s=0),(void 0===r||r===1/0)&&(r=e.count),0===r)return null;let a,o=gs(e,s,r);void 0!==t&&(a=e===t.index?x.ELEMENT_ARRAY_BUFFER:x.ARRAY_BUFFER);let l=this.processBufferView(e,n,s,r,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:n,count:r,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(c)-1}processImage(e,t,s,r="image/png"){if(null!==e){let n=this,i=n.cache,a=n.json,o=n.options,l=n.pending;i.images.has(e)||i.images.set(e,{});let c=i.images.get(e),u=r+":flipY/"+s.toString();if(void 0!==c[u])return c[u];a.images||(a.images=[]);let h={mimeType:r},p=ns();p.width=Math.min(e.width,o.maxTextureSize),p.height=Math.min(e.height,o.maxTextureSize);let m=p.getContext("2d");if(!0===s&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==Fe&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let s=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<s.length;t+=4)s[t+0]=e.data[t+0],s[t+1]=e.data[t+1],s[t+2]=e.data[t+2],s[t+3]=e.data[t+3];m.putImageData(new ImageData(s,e.width,e.height),0,0)}else{if(!(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement or ImageBitmap.");m.drawImage(e,0,0,p.width,p.height)}!0===o.binary?l.push(rs(p,r).then((e=>n.processBufferViewImage(e))).then((e=>{h.bufferView=e}))):void 0!==p.toDataURL?h.uri=p.toDataURL(r):l.push(rs(p,r).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{h.uri=e})));let f=a.images.push(h)-1;return c[u]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let s={magFilter:b[e.magFilter],minFilter:b[e.minFilter],wrapS:b[e.wrapS],wrapT:b[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){let t=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof Y&&(e=j(e,t.maxTextureSize));let n=e.userData.mimeType;"image/webp"===n&&(n="image/png");let i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,n)};e.name&&(i.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,i)}));let a=r.textures.push(i)-1;return s.textures.set(e,a),a}processMaterial(e){let t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);let r={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let n=e.color.toArray().concat([e.opacity]);if(F(n,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),s={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(s,t),r.pbrMetallicRoughness.metallicRoughnessTexture=s}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===_e&&(r.doubleSided=!0),""!==e.name&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,r)}));let i=s.materials.push(r)-1;return t.materials.set(e,i),i}processMesh(e){let t=this.cache,s=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,s=e.material.length;t<s;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let n=r.join(":");if(t.meshes.has(n))return t.meshes.get(n);let i,a=e.geometry;i=e.isLineSegments?x.LINES:e.isLineLoop?x.LINE_LOOP:e.isLine?x.LINE_STRIP:e.isPoints?x.POINTS:e.material.wireframe?x.LINES:x.TRIANGLES;let o={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=a.getAttribute("normal");void 0!==p&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let m=null;for(let e in a.attributes){if("morph"===e.slice(0,5))continue;let s=a.attributes[e];if(e=h[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(s))){l[e]=t.attributes.get(this.getUID(s));continue}m=null;let r=s.array;"JOINTS_0"===e&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new _(new Uint16Array(r),s.itemSize,s.normalized));let n=this.processAccessor(m||s,a);null!==n&&(e.startsWith("_")||this.detectMeshQuantization(e,s),l[e]=n,t.attributes.set(this.getUID(s),n))}if(void 0!==p&&a.setAttribute("normal",p),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){let s=[],r=[],n={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let i=0;i<e.morphTargetInfluences.length;++i){let o={},l=!1;for(let e in a.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}let s=a.morphAttributes[e][i],r=e.toUpperCase(),n=a.attributes[e];if(t.attributes.has(this.getUID(s,!0))){o[r]=t.attributes.get(this.getUID(s,!0));continue}let c=s.clone();if(!a.morphTargetsRelative)for(let e=0,t=s.count;e<t;e++)for(let t=0;t<s.itemSize;t++)0===t&&c.setX(e,s.getX(e)-n.getX(e)),1===t&&c.setY(e,s.getY(e)-n.getY(e)),2===t&&c.setZ(e,s.getZ(e)-n.getZ(e)),3===t&&c.setW(e,s.getW(e)-n.getW(e));o[r]=this.processAccessor(c,a),t.attributes.set(this.getUID(n,!0),o[r])}u.push(o),s.push(e.morphTargetInfluences[i]),void 0!==e.morphTargetDictionary&&r.push(n[i])}o.weights=s,r.length>0&&(o.extras={},o.extras.targetNames=r)}let f=Array.isArray(e.material);if(f&&0===a.groups.length)return null;let g=!1;if(f&&null===a.index){let e=[];for(let t=0,s=a.attributes.position.count;t<s;t++)e[t]=t;a.setIndex(e),g=!0}let d=f?e.material:[e.material],T=f?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,s=T.length;e<s;e++){let s={mode:i,attributes:l};if(this.serializeUserData(a,s),u.length>0&&(s.targets=u),null!==a.index){let r=this.getUID(a.index);(void 0!==T[e].start||void 0!==T[e].count)&&(r+=":"+T[e].start+":"+T[e].count),t.attributes.has(r)?s.indices=t.attributes.get(r):(s.indices=this.processAccessor(a.index,a,T[e].start,T[e].count),t.attributes.set(r,s.indices)),null===s.indices&&delete s.indices}let r=this.processMaterial(d[T[e].materialIndex]);null!==r&&(s.material=r),c.push(s)}!0===g&&a.setIndex(null),o.primitives=c,s.meshes||(s.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let y=s.meshes.push(o)-1;return t.meshes.set(n,y),y}detectMeshQuantization(e,t){if(this.extensionsUsed[Q])return;let s;switch(t.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}t.normalized&&(s+=" normalized");let r=e.split("_",1)[0];$e[r]&&$e[r].includes(s)&&(this.extensionsUsed[Q]=!0,this.extensionsRequired[Q]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let s=e.isOrthographicCamera,r={type:s?"orthographic":"perspective"};return s?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:G.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let s=this.json,r=this.nodeMap;s.animations||(s.animations=[]);let n=(e=q.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,i=[],a=[];for(let e=0;e<n.length;++e){let s=n[e],o=z.parseTrackName(s.name),l=z.findNode(t,o.nodeName),c=es[o.propertyName];if("bones"===o.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(o.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',s.name),null;let u,h=1,p=s.values.length/s.times.length;c===es.morphTargetInfluences&&(p/=l.morphTargetInfluences.length),!0===s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",p/=3):u=s.getInterpolation()===ke?"STEP":"LINEAR",a.push({input:this.processAccessor(new _(s.times,h)),output:this.processAccessor(new _(s.values,p)),interpolation:u}),i.push({sampler:a.length-1,target:{node:r.get(l),path:c}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:i}),s.animations.length-1}processSkin(e){let t=this.json,s=this.nodeMap,r=t.nodes[s.get(e)],n=e.skeleton;if(void 0===n)return null;let i=e.skeleton.bones[0];if(void 0===i)return null;let a=[],o=new Float32Array(16*n.bones.length),l=new W;for(let t=0;t<n.bones.length;++t)a.push(s.get(n.bones[t])),l.copy(n.boneInverses[t]),l.multiply(e.bindMatrix).toArray(o,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new _(o,16)),joints:a,skeleton:s.get(i)}),r.skin=t.skins.length-1}processNode(e){let t=this.json,s=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);let n={};if(s.trs){let t=e.quaternion.toArray(),s=e.position.toArray(),r=e.scale.toArray();F(t,[0,0,0,1])||(n.rotation=t),F(s,[0,0,0])||(n.translation=s),F(r,[1,1,1])||(n.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===ds(e.matrix)&&(n.matrix=e.matrix.elements);if(""!==e.name&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);null!==t&&(n.mesh=t)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,n=e.children.length;r<n;r++){let n=e.children[r];if(n.visible||!1===s.onlyVisible){let e=this.processNode(n);null!==e&&t.push(e)}}t.length>0&&(n.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,n)}));let i=t.nodes.push(n)-1;return r.set(e,i),i}processScene(e){let t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let n=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||!1===s.onlyVisible){let e=this.processNode(r);null!==e&&n.push(e)}}n.length>0&&(r.nodes=n),this.serializeUserData(e,r)}processObjects(e){let t=new P;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));let s=[];for(let t=0;t<e.length;t++)e[t]instanceof P?this.processScene(e[t]):s.push(e[t]);s.length>0&&this.processObjects(s);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}};T(de,"GLTFWriter");var $=de,ge=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);let s=this.writer,r=s.json,n=s.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(1-e.penumbra)*e.angle,i.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},n[this.name]=!0);let a=r.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}};T(ge,"GLTFLightExtension");var ee=ge,xe=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}};T(xe,"GLTFMaterialsUnlitExtension");var se=xe,me=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:s.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};s.applyTextureTransform(t,e.clearcoatMap),n.clearcoatTexture=t}if(n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:s.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};s.applyTextureTransform(t,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:s.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};s.applyTextureTransform(t,e.clearcoatNormalMap),n.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(me,"GLTFMaterialsClearcoatExtension");var te=me,Te=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:s.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};s.applyTextureTransform(t,e.iridescenceMap),n.iridescenceTexture=t}if(n.iridescenceIor=e.iridescenceIOR,n.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],n.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:s.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};s.applyTextureTransform(t,e.iridescenceThicknessMap),n.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Te,"GLTFMaterialsIridescenceExtension");var ne=Te,ye=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.transmissionFactor=e.transmission,e.transmissionMap){let t={index:s.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};s.applyTextureTransform(t,e.transmissionMap),n.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(ye,"GLTFMaterialsTransmissionExtension");var re=ye,we=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let s=this.writer,r=s.extensionsUsed,n={};if(n.thicknessFactor=e.thickness,e.thicknessMap){let t={index:s.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};s.applyTextureTransform(t,e.thicknessMap),n.thicknessTexture=t}n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(we,"GLTFMaterialsVolumeExtension");var ie=we,Me=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(Me,"GLTFMaterialsIorExtension");var oe=Me,Ie=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(cs)&&!e.specularIntensityMap&&!e.specularColorMap)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.specularIntensityMap){let t={index:s.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};s.applyTextureTransform(t,e.specularIntensityMap),n.specularTexture=t}if(e.specularColorMap){let t={index:s.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};s.applyTextureTransform(t,e.specularColorMap),n.specularColorTexture=t}n.specularFactor=e.specularIntensity,n.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Ie,"GLTFMaterialsSpecularExtension");var ae=Ie,Ae=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.sheenRoughnessMap){let t={index:s.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};s.applyTextureTransform(t,e.sheenRoughnessMap),n.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:s.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};s.applyTextureTransform(t,e.sheenColorMap),n.sheenColorTexture=t}n.sheenRoughnessFactor=e.sheenRoughness,n.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Ae,"GLTFMaterialsSheenExtension");var ce=Ae,Re=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.anisotropyMap){let t={index:s.processTexture(e.anisotropyMap)};s.applyTextureTransform(t,e.anisotropyMap),n.anisotropyTexture=t}n.anisotropyStrength=e.anisotropy,n.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(Re,"GLTFMaterialsAnisotropyExtension");var ue=Re,Ee=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};T(Ee,"GLTFMaterialsEmissiveStrengthExtension");var le=Ee,be=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let s=this.writer,r=s.extensionsUsed,n={};if(e.bumpMap){let t={index:s.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};s.applyTextureTransform(t,e.bumpMap),n.bumpTexture=t}n.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=n,r[this.name]=!0}};T(be,"GLTFMaterialsBumpExtension");var fe=be,Ne=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let s=this.writer,r=e,n=new Float32Array(3*r.count),i=new Float32Array(4*r.count),a=new Float32Array(3*r.count),o=new W,l=new D,c=new Ye,u=new D;for(let e=0;e<r.count;e++)r.getMatrixAt(e,o),o.decompose(l,c,u),l.toArray(n,3*e),c.toArray(i,4*e),u.toArray(a,3*e);let h={TRANSLATION:s.processAccessor(new _(n,3)),ROTATION:s.processAccessor(new _(i,4)),SCALE:s.processAccessor(new _(a,3))};r.instanceColor&&(h._COLOR_0=s.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:h},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}};T(Ne,"GLTFMeshGpuInstancing");var he=Ne;q.Utils={insertKeyframe:function(e,t){let s,r=e.getValueSize(),n=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+r),a=e.createInterpolant(new e.ValueBufferType(r));if(0===e.times.length){n[0]=t;for(let e=0;e<r;e++)i[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;n[0]=t,n.set(e.times,1),i.set(a.evaluate(t),0),i.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;n[n.length-1]=t,n.set(e.times,0),i.set(e.values,0),i.set(a.evaluate(t),e.values.length),s=n.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){n.set(e.times.slice(0,o+1),0),n[o+1]=t,n.set(e.times.slice(o+1),o+2),i.set(e.values.slice(0,(o+1)*r),0),i.set(a.evaluate(t),(o+1)*r),i.set(e.values.slice((o+1)*r),(o+2)*r),s=o+1;break}}return e.times=n,e.values=i,s},mergeMorphTargetTracks:function(e,t){let s=[],r={},n=e.tracks;for(let e=0;e<n.length;++e){let i=n[e],a=z.parseTrackName(i.name),o=z.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){s.push(i);continue}if(i.createInterpolant!==i.InterpolantFactoryMethodDiscrete&&i.createInterpolant!==i.InterpolantFactoryMethodLinear){if(i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),i=i.clone(),i.setInterpolation(He)}let l,c=o.morphTargetInfluences.length,u=o.morphTargetDictionary[a.propertyIndex];if(void 0===u)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);if(void 0===r[o.uuid]){l=i.clone();let e=new l.ValueBufferType(c*l.times.length);for(let t=0;t<l.times.length;t++)e[t*c+u]=l.values[t];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=e,r[o.uuid]=l,s.push(l);continue}let h=i.createInterpolant(new i.ValueBufferType(1));l=r[o.uuid];for(let e=0;e<l.times.length;e++)l.values[e*c+u]=h.evaluate(l.times[e]);for(let e=0;e<i.times.length;e++){let t=this.insertKeyframe(l,i.times[e]);l.values[t*c+u]=i.values[e]}}return e.tracks=s,e}};export{q as GLTFExporter};
@@ -1 +1 @@
1
- import{L as C}from"./chunk-TUEPC7VC.js";import{a as S}from"./chunk-JIMJW33G.js";import{a as o,f as e}from"./chunk-ZRT45YCM.js";S();var F,y,P=class{constructor(t){e(this,"_currentStats",{fps:0,ms:0,mb:0}),e(this,"view"),e(this,"timer"),e(this,"counter"),e(this,"onFPSChangeArray"),e(this,"onFPSChangeIndex"),e(this,"lastFPS",0),e(this,"SECONDS_TO_DECIDE",3),e(this,"MIN_FPS",38),e(this,"CRITICAL_FPS",24),e(this,"MAX_FPS",120),e(this,"MAX_MS",200),e(this,"MAX_MB",((null==(y=null==(F=window.performance)?void 0:F.memory)?void 0:y.jsHeapSizeLimit)||1/0)/1048576),e(this,"updateMappedinDevtools",o((()=>{let t="__MAPPEDIN_DEVTOOLS__";window[t]=window[t]||{};let e=window[t];e.showPerformancePanelArray=e.showPerformancePanelArray||[],e.hidePerformancePanelArray=e.hidePerformancePanelArray||[],e.showPerformancePanelArray.push((()=>this.showPerformancePanel())),e.hidePerformancePanelArray.push((()=>this.hidePerformancePanel()))}),"updateMappedinDevtools"));let{MAX_FPS:i,MAX_MS:s,MAX_MB:n}=this,a={fps:i,ms:s,mb:n};this.view=new d(t.debug,t.container,a),this.timer=new c,this.counter=new u,this.onFPSChangeArray=t.onFPSChangeArray,this.onFPSChangeIndex=t.dynamicPerformance?t.onFPSChangeArray.length:-1,this.updateMappedinDevtools()}static getDefaultOnFPSChangeArray(t){let{effectComposer:e}=t.renderer.implementation;return[()=>{null==e||e.setAntialiasConfiguration({antialias:!1}),t.paths.pathSegments.forEach((({arrowAnimationTween:t})=>{t.stop()}));for(let e in t.polygonMeshesById){let{material:i}=t.polygonMeshesById[e];i.map&&(i.map.anisotropy=1,i.needsUpdate=!0)}t.tryRendering()},()=>{null==e||e.setAmbientOcclusionConfiguration({aoEnabled:!1}),t.tryRendering()}]}updateStats(t){var e,i;let s=(null==(i=null==(e=window.performance)?void 0:e.memory)?void 0:i.usedJSHeapSize)||0;this._currentStats.fps=Math.min(t,this.MAX_FPS),this._currentStats.ms=Math.min(1e3/t,this.MAX_MS),this._currentStats.mb=Math.min(s/1048576,this.MAX_MB),this.view.updatePanels(this._currentStats)}isFPSSpiked(t){return Math.abs(this.lastFPS-t)/this.lastFPS>.1}updateOnFPSChangeIndex(t,e){let i=this.onFPSChangeIndex;return e&&i>0?i=0:t&&(i-=1),this.onFPSChangeIndex=C.clamp(i,-1,this.onFPSChangeArray.length),this.onFPSChangeIndex}handleFPSChange(t,e){let i=this.onFPSChangeIndex,s=this.updateOnFPSChangeIndex(t,e),n=this.onFPSChangeArray[s];!n||s===i||n(this.currentStats)}update(){let{fps:t,duration:e}=this.timer.update();if(e>=1e3){if(!this.isFPSSpiked(t)){let{lowFPS:e,criticalFPS:i}=this.counter.update(t,this.MIN_FPS,this.CRITICAL_FPS,this.SECONDS_TO_DECIDE);this.updateStats(t),this.handleFPSChange(e,i)}this.lastFPS=t,this.timer.reset()}}get currentStats(){return{...this._currentStats}}get dom(){return this.view.dom}hidePerformancePanel(){this.view.hidePerformancePanel()}showPerformancePanel(){this.view.showPerformancePanel()}};o(P,"PerformanceController");var b=P,m=class{constructor(){e(this,"beginTime",performance.now()),e(this,"frames",0),e(this,"duration",0)}reset(){this.duration=0,this.frames=0}update(){let t=performance.now(),e=t-this.beginTime;return this.frames++,this.duration+=e,this.beginTime=t,{duration:this.duration,fps:this.frames/(this.duration/1e3)}}};o(m,"PerformanceTimer");var c=m,f=class{constructor(){e(this,"criticalFpsCounter",0),e(this,"lowFpsCounter",0),e(this,"highFpsCounter",0)}update(t,e,i,s){let n=t<e,a=t<i;return this.criticalFpsCounter=a?this.criticalFpsCounter+1:0,this.lowFpsCounter=n?this.lowFpsCounter+1:0,this.highFpsCounter=n?0:this.highFpsCounter+1,this.lowFpsCounter===s?(this.lowFpsCounter=0,this.criticalFpsCounter===s?(this.criticalFpsCounter=0,{lowFPS:!0,highFPS:!1,criticalFPS:!0}):{lowFPS:!0,highFPS:!1,criticalFPS:!1}):this.highFpsCounter===s?(this.highFpsCounter=0,{lowFPS:!1,highFPS:!0,criticalFPS:!1}):(n?this.highFpsCounter=0:(this.lowFpsCounter=0,this.criticalFpsCounter=0),{lowFPS:!1,highFPS:!1,criticalFPS:!1})}};o(f,"PerformanceCounter");var u=f,g=class{constructor(t,i,s){var n;e(this,"mode",-1),e(this,"panels",[]),e(this,"appContainer"),e(this,"maxValues"),e(this,"debug"),e(this,"stats"),e(this,"container"),this.debug=t,this.appContainer=i,this.maxValues=s,this.container=this.createContainer(),this.addPanel(new l({name:"FPS",foregroundColor:"#0ff",backgroundColor:"#002"})),this.addPanel(new l({name:"MS",foregroundColor:"#0f0",backgroundColor:"#020"})),null!=(n=window.performance)&&n.memory&&this.addPanel(new l({name:"MB",foregroundColor:"#f08",backgroundColor:"#201"})),this.debug&&this.showPerformancePanel()}createContainer(){let t=document.createElement("div");return t.style.cssText="position:absolute;top:0;right:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(t=>{t.preventDefault(),this.showPanel(++this.mode%this.panels.length)})),t}addPanel(t){this.panels.push(t),this.container.appendChild(t.dom)}showPanel(t){this.panels.forEach(((e,i)=>{e.dom.style.display=i===t?"block":"none"})),this.mode=t}hidePerformancePanel(){this.container.parentNode&&(this.debug=!1,this.appContainer.removeChild(this.container))}showPerformancePanel(){this.container.parentNode||(this.debug=!0,this.stats&&this.updatePanels(this.stats),this.appContainer.appendChild(this.container))}updatePanels(t){this.stats=t,this.debug&&this.panels.forEach(((e,i)=>{0===i?e.update(t.fps,this.maxValues.fps):1===i?e.update(t.ms,this.maxValues.ms):2===i&&e.update(t.mb,this.maxValues.mb)}))}get dom(){return this.container}};o(g,"PerformanceView");var d=g,v=class{constructor(t){this.config=t,e(this,"min",1/0),e(this,"max",0),e(this,"canvas"),e(this,"context"),e(this,"PR",Math.round(window.devicePixelRatio||1)),e(this,"WIDTH",80*this.PR),e(this,"HEIGHT",48*this.PR),e(this,"TEXT_X",3*this.PR),e(this,"TEXT_Y",2*this.PR),e(this,"GRAPH_X",3*this.PR),e(this,"GRAPH_Y",15*this.PR),e(this,"GRAPH_WIDTH",74*this.PR),e(this,"GRAPH_HEIGHT",30*this.PR),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.setupCanvas()}setupCanvas(){this.canvas.dataset.name=this.config.name,this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="".concat(this.WIDTH/this.PR,"px"),this.canvas.style.height="".concat(this.HEIGHT/this.PR,"px"),this.context.font="bold ".concat(9*this.PR,"px Helvetica,Arial,sans-serif"),this.context.textBaseline="top",this.context.fillStyle=this.config.backgroundColor,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.config.foregroundColor,this.context.fillText(this.config.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.config.backgroundColor,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT)}get dom(){return this.canvas}update(t,e){this.min=Math.min(this.min,t),this.max=Math.max(this.max,t);let{context:i,WIDTH:s,GRAPH_Y:n,GRAPH_WIDTH:a,GRAPH_HEIGHT:h,PR:o}=this;i.fillStyle=this.config.backgroundColor,i.globalAlpha=1,i.fillRect(0,0,s,n),i.fillStyle=this.config.foregroundColor,i.fillText("".concat(Math.round(t)," ").concat(this.config.name," (").concat(Math.round(this.min),"-").concat(Math.round(this.max),")"),this.TEXT_X,this.TEXT_Y),i.drawImage(this.canvas,this.GRAPH_X+o,this.GRAPH_Y,a-o,h,this.GRAPH_X,this.GRAPH_Y,a-o,h),i.fillRect(this.GRAPH_X+a-o,this.GRAPH_Y,o,h),i.fillStyle=this.config.backgroundColor,i.globalAlpha=.9,i.fillRect(this.GRAPH_X+a-o,this.GRAPH_Y,o,Math.round((1-t/e)*h))}};o(v,"Panel");var l=v;export{b as PerformanceController,d as PerformanceView};
1
+ import{L as C}from"./chunk-I76QBIBM.js";import{a as S}from"./chunk-ARDLMWG5.js";import{a as o,f as e}from"./chunk-ZRT45YCM.js";S();var F,y,P=class{constructor(t){e(this,"_currentStats",{fps:0,ms:0,mb:0}),e(this,"view"),e(this,"timer"),e(this,"counter"),e(this,"onFPSChangeArray"),e(this,"onFPSChangeIndex"),e(this,"lastFPS",0),e(this,"SECONDS_TO_DECIDE",3),e(this,"MIN_FPS",38),e(this,"CRITICAL_FPS",24),e(this,"MAX_FPS",120),e(this,"MAX_MS",200),e(this,"MAX_MB",((null==(y=null==(F=window.performance)?void 0:F.memory)?void 0:y.jsHeapSizeLimit)||1/0)/1048576),e(this,"updateMappedinDevtools",o((()=>{let t="__MAPPEDIN_DEVTOOLS__";window[t]=window[t]||{};let e=window[t];e.showPerformancePanelArray=e.showPerformancePanelArray||[],e.hidePerformancePanelArray=e.hidePerformancePanelArray||[],e.showPerformancePanelArray.push((()=>this.showPerformancePanel())),e.hidePerformancePanelArray.push((()=>this.hidePerformancePanel()))}),"updateMappedinDevtools"));let{MAX_FPS:i,MAX_MS:s,MAX_MB:n}=this,a={fps:i,ms:s,mb:n};this.view=new d(t.debug,t.container,a),this.timer=new c,this.counter=new u,this.onFPSChangeArray=t.onFPSChangeArray,this.onFPSChangeIndex=t.dynamicPerformance?t.onFPSChangeArray.length:-1,this.updateMappedinDevtools()}static getDefaultOnFPSChangeArray(t){let{effectComposer:e}=t.renderer.implementation;return[()=>{null==e||e.setAntialiasConfiguration({antialias:!1}),t.paths.pathSegments.forEach((({arrowAnimationTween:t})=>{t.stop()}));for(let e in t.polygonMeshesById){let{material:i}=t.polygonMeshesById[e];i.map&&(i.map.anisotropy=1,i.needsUpdate=!0)}t.tryRendering()},()=>{null==e||e.setAmbientOcclusionConfiguration({aoEnabled:!1}),t.tryRendering()}]}updateStats(t){var e,i;let s=(null==(i=null==(e=window.performance)?void 0:e.memory)?void 0:i.usedJSHeapSize)||0;this._currentStats.fps=Math.min(t,this.MAX_FPS),this._currentStats.ms=Math.min(1e3/t,this.MAX_MS),this._currentStats.mb=Math.min(s/1048576,this.MAX_MB),this.view.updatePanels(this._currentStats)}isFPSSpiked(t){return Math.abs(this.lastFPS-t)/this.lastFPS>.1}updateOnFPSChangeIndex(t,e){let i=this.onFPSChangeIndex;return e&&i>0?i=0:t&&(i-=1),this.onFPSChangeIndex=C.clamp(i,-1,this.onFPSChangeArray.length),this.onFPSChangeIndex}handleFPSChange(t,e){let i=this.onFPSChangeIndex,s=this.updateOnFPSChangeIndex(t,e),n=this.onFPSChangeArray[s];!n||s===i||n(this.currentStats)}update(){let{fps:t,duration:e}=this.timer.update();if(e>=1e3){if(!this.isFPSSpiked(t)){let{lowFPS:e,criticalFPS:i}=this.counter.update(t,this.MIN_FPS,this.CRITICAL_FPS,this.SECONDS_TO_DECIDE);this.updateStats(t),this.handleFPSChange(e,i)}this.lastFPS=t,this.timer.reset()}}get currentStats(){return{...this._currentStats}}get dom(){return this.view.dom}hidePerformancePanel(){this.view.hidePerformancePanel()}showPerformancePanel(){this.view.showPerformancePanel()}};o(P,"PerformanceController");var b=P,m=class{constructor(){e(this,"beginTime",performance.now()),e(this,"frames",0),e(this,"duration",0)}reset(){this.duration=0,this.frames=0}update(){let t=performance.now(),e=t-this.beginTime;return this.frames++,this.duration+=e,this.beginTime=t,{duration:this.duration,fps:this.frames/(this.duration/1e3)}}};o(m,"PerformanceTimer");var c=m,f=class{constructor(){e(this,"criticalFpsCounter",0),e(this,"lowFpsCounter",0),e(this,"highFpsCounter",0)}update(t,e,i,s){let n=t<e,a=t<i;return this.criticalFpsCounter=a?this.criticalFpsCounter+1:0,this.lowFpsCounter=n?this.lowFpsCounter+1:0,this.highFpsCounter=n?0:this.highFpsCounter+1,this.lowFpsCounter===s?(this.lowFpsCounter=0,this.criticalFpsCounter===s?(this.criticalFpsCounter=0,{lowFPS:!0,highFPS:!1,criticalFPS:!0}):{lowFPS:!0,highFPS:!1,criticalFPS:!1}):this.highFpsCounter===s?(this.highFpsCounter=0,{lowFPS:!1,highFPS:!0,criticalFPS:!1}):(n?this.highFpsCounter=0:(this.lowFpsCounter=0,this.criticalFpsCounter=0),{lowFPS:!1,highFPS:!1,criticalFPS:!1})}};o(f,"PerformanceCounter");var u=f,g=class{constructor(t,i,s){var n;e(this,"mode",-1),e(this,"panels",[]),e(this,"appContainer"),e(this,"maxValues"),e(this,"debug"),e(this,"stats"),e(this,"container"),this.debug=t,this.appContainer=i,this.maxValues=s,this.container=this.createContainer(),this.addPanel(new l({name:"FPS",foregroundColor:"#0ff",backgroundColor:"#002"})),this.addPanel(new l({name:"MS",foregroundColor:"#0f0",backgroundColor:"#020"})),null!=(n=window.performance)&&n.memory&&this.addPanel(new l({name:"MB",foregroundColor:"#f08",backgroundColor:"#201"})),this.debug&&this.showPerformancePanel()}createContainer(){let t=document.createElement("div");return t.style.cssText="position:absolute;top:0;right:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(t=>{t.preventDefault(),this.showPanel(++this.mode%this.panels.length)})),t}addPanel(t){this.panels.push(t),this.container.appendChild(t.dom)}showPanel(t){this.panels.forEach(((e,i)=>{e.dom.style.display=i===t?"block":"none"})),this.mode=t}hidePerformancePanel(){this.container.parentNode&&(this.debug=!1,this.appContainer.removeChild(this.container))}showPerformancePanel(){this.container.parentNode||(this.debug=!0,this.stats&&this.updatePanels(this.stats),this.appContainer.appendChild(this.container))}updatePanels(t){this.stats=t,this.debug&&this.panels.forEach(((e,i)=>{0===i?e.update(t.fps,this.maxValues.fps):1===i?e.update(t.ms,this.maxValues.ms):2===i&&e.update(t.mb,this.maxValues.mb)}))}get dom(){return this.container}};o(g,"PerformanceView");var d=g,v=class{constructor(t){this.config=t,e(this,"min",1/0),e(this,"max",0),e(this,"canvas"),e(this,"context"),e(this,"PR",Math.round(window.devicePixelRatio||1)),e(this,"WIDTH",80*this.PR),e(this,"HEIGHT",48*this.PR),e(this,"TEXT_X",3*this.PR),e(this,"TEXT_Y",2*this.PR),e(this,"GRAPH_X",3*this.PR),e(this,"GRAPH_Y",15*this.PR),e(this,"GRAPH_WIDTH",74*this.PR),e(this,"GRAPH_HEIGHT",30*this.PR),this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.setupCanvas()}setupCanvas(){this.canvas.dataset.name=this.config.name,this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="".concat(this.WIDTH/this.PR,"px"),this.canvas.style.height="".concat(this.HEIGHT/this.PR,"px"),this.context.font="bold ".concat(9*this.PR,"px Helvetica,Arial,sans-serif"),this.context.textBaseline="top",this.context.fillStyle=this.config.backgroundColor,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.config.foregroundColor,this.context.fillText(this.config.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.config.backgroundColor,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT)}get dom(){return this.canvas}update(t,e){this.min=Math.min(this.min,t),this.max=Math.max(this.max,t);let{context:i,WIDTH:s,GRAPH_Y:n,GRAPH_WIDTH:a,GRAPH_HEIGHT:h,PR:o}=this;i.fillStyle=this.config.backgroundColor,i.globalAlpha=1,i.fillRect(0,0,s,n),i.fillStyle=this.config.foregroundColor,i.fillText("".concat(Math.round(t)," ").concat(this.config.name," (").concat(Math.round(this.min),"-").concat(Math.round(this.max),")"),this.TEXT_X,this.TEXT_Y),i.drawImage(this.canvas,this.GRAPH_X+o,this.GRAPH_Y,a-o,h,this.GRAPH_X,this.GRAPH_Y,a-o,h),i.fillRect(this.GRAPH_X+a-o,this.GRAPH_Y,o,h),i.fillStyle=this.config.backgroundColor,i.globalAlpha=.9,i.fillRect(this.GRAPH_X+a-o,this.GRAPH_Y,o,Math.round((1-t/e)*h))}};o(v,"Panel");var l=v;export{b as PerformanceController,d as PerformanceView};