Files
torebki-fabiola.pl/wp-content/plugins/mapster-wp-maps/includes/acf-mapster-map/assets/dist/acf-mapster-map-pro.js
2026-03-05 13:07:40 +01:00

9 lines
2.3 MiB
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).turf={})}(this,(function(t){"use strict";var e=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},r={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e,yards:1.0936133},i={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function o(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function a(t,e,n){switch(t){case"Point":return s(e).geometry;case"LineString":return h(e).geometry;case"Polygon":return u(e).geometry;case"MultiPoint":return m(e).geometry;case"MultiLineString":return d(e).geometry;case"MultiPolygon":return g(e).geometry;default:throw new Error(t+" is invalid")}}function s(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!C(t[0])||!C(t[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:t},e,n)}function l(t,e,n){return void 0===n&&(n={}),f(t.map((function(t){return s(t,e)})),n)}function u(t,e,n){void 0===n&&(n={});for(var r=0,i=t;r<i.length;r++){var a=i[r];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return o({type:"Polygon",coordinates:t},e,n)}function c(t,e,n){return void 0===n&&(n={}),f(t.map((function(t){return u(t,e)})),n)}function h(t,e,n){if(void 0===n&&(n={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return o({type:"LineString",coordinates:t},e,n)}function p(t,e,n){return void 0===n&&(n={}),f(t.map((function(t){return h(t,e)})),n)}function f(t,e){void 0===e&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function d(t,e,n){return void 0===n&&(n={}),o({type:"MultiLineString",coordinates:t},e,n)}function m(t,e,n){return void 0===n&&(n={}),o({type:"MultiPoint",coordinates:t},e,n)}function g(t,e,n){return void 0===n&&(n={}),o({type:"MultiPolygon",coordinates:t},e,n)}function y(t,e,n){return void 0===n&&(n={}),o({type:"GeometryCollection",geometries:t},e,n)}function v(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function _(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t*r}function x(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t/r}function b(t,e){return E(x(t,e))}function w(t){var e=t%360;return e<0&&(e+=360),e}function E(t){return t%(2*Math.PI)*180/Math.PI}function S(t){return t%360*Math.PI/180}function M(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return _(x(t,e),n)}function T(t,e,n){if(void 0===e&&(e="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var r=i[e];if(!r)throw new Error("invalid original units");var o=i[n];if(!o)throw new Error("invalid final units");return t/r*o}function C(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function I(t){return!!t&&t.constructor===Object}function A(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!C(t))throw new Error("bbox must only contain numbers")}))}function L(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}var P=Object.freeze({__proto__:null,earthRadius:e,factors:n,unitsFactors:r,areaFactors:i,feature:o,geometry:a,point:s,points:l,polygon:u,polygons:c,lineString:h,lineStrings:p,featureCollection:f,multiLineString:d,multiPoint:m,multiPolygon:g,geometryCollection:y,round:v,radiansToLength:_,lengthToRadians:x,lengthToDegrees:b,bearingToAzimuth:w,radiansToDegrees:E,degreesToRadians:S,convertLength:M,convertArea:T,isNumber:C,isObject:I,validateBBox:A,validateId:L});function R(t,e,n){if(null!==t)for(var r,i,o,a,s,l,u,c,h=0,p=0,f=t.type,d="FeatureCollection"===f,m="Feature"===f,g=d?t.features.length:1,y=0;y<g;y++){s=(c=!!(u=d?t.features[y].geometry:m?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<s;v++){var _=0,x=0;if(null!==(a=c?u.geometries[v]:u)){l=a.coordinates;var b=a.type;switch(h=!n||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,p,y,_,x))return!1;p++,_++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],p,y,_,x))return!1;p++,"MultiPoint"===b&&_++}"LineString"===b&&_++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(i=0;i<l[r].length-h;i++){if(!1===e(l[r][i],p,y,_,x))return!1;p++}"MultiLineString"===b&&_++,"Polygon"===b&&x++}"Polygon"===b&&_++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(x=0,i=0;i<l[r].length;i++){for(o=0;o<l[r][i].length-h;o++){if(!1===e(l[r][i][o],p,y,_,x))return!1;p++}x++}_++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===R(a.geometries[r],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function D(t,e,n,r){var i=n;return R(t,(function(t,r,o,a,s){i=0===r&&void 0===n?t:e(i,t,r,o,a,s)}),r),i}function N(t,e){var n;switch(t.type){case"FeatureCollection":for(n=0;n<t.features.length&&!1!==e(t.features[n].properties,n);n++);break;case"Feature":e(t.properties,0)}}function O(t,e,n){var r=n;return N(t,(function(t,i){r=0===i&&void 0===n?t:e(r,t,i)})),r}function k(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function z(t,e,n){var r=n;return k(t,(function(t,i){r=0===i&&void 0===n?t:e(r,t,i)})),r}function F(t){var e=[];return R(t,(function(t){e.push(t)})),e}function B(t,e){var n,r,i,o,a,s,l,u,c,h,p=0,f="FeatureCollection"===t.type,d="Feature"===t.type,m=f?t.features.length:1;for(n=0;n<m;n++){for(s=f?t.features[n].geometry:d?t.geometry:t,u=f?t.features[n].properties:d?t.properties:{},c=f?t.features[n].bbox:d?t.bbox:void 0,h=f?t.features[n].id:d?t.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,p,u,c,h))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],p,u,c,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,u,c,h))return!1;p++}}function U(t,e,n){var r=n;return B(t,(function(t,i,o,a,s){r=0===i&&void 0===n?t:e(r,t,i,o,a,s)})),r}function V(t,e){B(t,(function(t,n,r,i,a){var s,l=null===t?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==e(o(t,r,{bbox:i,id:a}),n,0)&&void 0}switch(l){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var u=0;u<t.coordinates.length;u++){var c=t.coordinates[u];if(!1===e(o({type:s,coordinates:c},r),n,u))return!1}}))}function G(t,e,n){var r=n;return V(t,(function(t,i,o){r=0===i&&0===o&&void 0===n?t:e(r,t,i,o)})),r}function j(t,e){V(t,(function(t,n,r){var i=0;if(t.geometry){var o=t.geometry.type;if("Point"!==o&&"MultiPoint"!==o){var a,s=0,l=0,u=0;return!1!==R(t,(function(o,c,p,f,d){if(void 0===a||n>s||f>l||d>u)return a=o,s=n,l=f,u=d,void(i=0);var m=h([a,o],t.properties);if(!1===e(m,n,r,d,i))return!1;i++,a=o}))&&void 0}}}))}function H(t,e,n){var r=n,i=!1;return j(t,(function(t,o,a,s,l){r=!1===i&&void 0===n?t:e(r,t,o,a,s,l),i=!0})),r}function q(t,e){if(!t)throw new Error("geojson is required");V(t,(function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var a=0;a<o.length;a++)if(!1===e(h(o[a],t.properties),n,r,a))return!1}}}))}function W(t,e,n){var r=n;return q(t,(function(t,i,o,a){r=0===i&&void 0===n?t:e(r,t,i,o,a)})),r}function X(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n,r=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.segmentIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":r<0&&(r=t.features.length+r),s=s||t.features[r].properties,n=t.features[r].geometry;break;case"Feature":s=s||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var l=n.coordinates;switch(n.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=l.length+a-1),h([l[a],l[a+1]],s,e);case"Polygon":return o<0&&(o=l.length+o),a<0&&(a=l[o].length+a-1),h([l[o][a],l[o][a+1]],s,e);case"MultiLineString":return i<0&&(i=l.length+i),a<0&&(a=l[i].length+a-1),h([l[i][a],l[i][a+1]],s,e);case"MultiPolygon":return i<0&&(i=l.length+i),o<0&&(o=l[i].length+o),a<0&&(a=l[i][o].length-a-1),h([l[i][o][a],l[i][o][a+1]],s,e)}throw new Error("geojson is invalid")}function Z(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n,r=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.coordIndex||0,l=e.properties;switch(t.type){case"FeatureCollection":r<0&&(r=t.features.length+r),l=l||t.features[r].properties,n=t.features[r].geometry;break;case"Feature":l=l||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var u=n.coordinates;switch(n.type){case"Point":return s(u,l,e);case"MultiPoint":return i<0&&(i=u.length+i),s(u[i],l,e);case"LineString":return a<0&&(a=u.length+a),s(u[a],l,e);case"Polygon":return o<0&&(o=u.length+o),a<0&&(a=u[o].length+a),s(u[o][a],l,e);case"MultiLineString":return i<0&&(i=u.length+i),a<0&&(a=u[i].length+a),s(u[i][a],l,e);case"MultiPolygon":return i<0&&(i=u.length+i),o<0&&(o=u[i].length+o),a<0&&(a=u[i][o].length-a),s(u[i][o][a],l,e)}throw new Error("geojson is invalid")}var Y=Object.freeze({__proto__:null,coordAll:F,coordEach:R,coordReduce:D,featureEach:k,featureReduce:z,findPoint:Z,findSegment:X,flattenEach:V,flattenReduce:G,geomEach:B,geomReduce:U,lineEach:q,lineReduce:W,propEach:N,propReduce:O,segmentEach:j,segmentReduce:H});function J(t){var e=[1/0,1/0,-1/0,-1/0];return R(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])})),e}function K(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Q(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function $(t){if(t.length>1&&C(t[0])&&C(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return $(t[0]);throw new Error("coordinates must only contain numbers")}function tt(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function et(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function nt(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0,i=t.features;r<i.length;r++){var o=i[r];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!o.geometry||o.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+o.geometry.type)}}function rt(t){return"Feature"===t.type?t.geometry:t}function it(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}J.default=J;var ot=Object.freeze({__proto__:null,getCoord:K,getCoords:Q,containsNumber:$,geojsonType:tt,featureOf:et,collectionOf:nt,getGeom:rt,getType:it}),at=Object.getOwnPropertySymbols,st=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var ut=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var n,r,i=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),o=1;o<arguments.length;o++){for(var a in n=Object(arguments[o]))st.call(n,a)&&(i[a]=n[a]);if(at){r=at(n);for(var s=0;s<r.length;s++)lt.call(n,r[s])&&(i[r[s]]=n[r[s]])}}return i},ct={successCallback:null,verbose:!1},ht={};function pt(t,e,n){n=n||{};for(var r=Object.keys(ct),i=0;i<r.length;i++){var o=r[i],a=n[o];a=null!=a?a:ct[o],ht[o]=a}ht.verbose&&console.log("MarchingSquaresJS-isoContours: computing isocontour for "+e);var s=function(t){var e=[],n=0;return t.cells.forEach((function(r,i){r.forEach((function(r,o){if(void 0!==r&&5!==(p=r).cval&&10!==p.cval&&!dt(r)){var a=function(t,e,n){var r,i,o=t.length,a=[],s=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],l=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],u=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],c=t[e][n],h=c.cval,p=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"][h],f=gt(c,p);a.push([n+f[0],e+f[1]]),f=gt(c,p=u[h]),a.push([n+f[0],e+f[1]]),mt(c);for(var d=n+s[h],m=e+l[h],g=h;d>=0&&m>=0&&m<o&&(d!=n||m!=e)&&void 0!==(c=t[m][d]);){if(0===(h=c.cval)||15===h)return{path:a,info:"mergeable"};p=u[h],r=s[h],i=l[h],5!==h&&10!==h||(5===h?c.flipped?-1===l[g]?(p="left",r=-1,i=0):(p="right",r=1,i=0):-1===s[g]&&(p="bottom",r=0,i=-1):10===h&&(c.flipped?-1===s[g]?(p="top",r=0,i=1):(p="bottom",r=0,i=-1):1===l[g]&&(p="left",r=-1,i=0))),f=gt(c,p),a.push([d+f[0],m+f[1]]),mt(c),d+=r,m+=i,g=h}return{path:a,info:"closed"}}(t.cells,i,o),s=!1;if("mergeable"===a.info)for(var l=a.path[a.path.length-1][0],u=a.path[a.path.length-1][1],c=n-1;c>=0;c--)if(Math.abs(e[c][0][0]-l)<=1e-7&&Math.abs(e[c][0][1]-u)<=1e-7){for(var h=a.path.length-2;h>=0;--h)e[c].unshift(a.path[h]);s=!0;break}s||(e[n++]=a.path)}var p}))})),e}(function(t,e){for(var n=t.length-1,r=t[0].length-1,i={rows:n,cols:r,cells:[]},o=0;o<n;++o){i.cells[o]=[];for(var a=0;a<r;++a){var s=0,l=t[o+1][a],u=t[o+1][a+1],c=t[o][a+1],h=t[o][a];if(!(isNaN(l)||isNaN(u)||isNaN(c)||isNaN(h))){s|=l>=e?8:0,s|=u>=e?4:0,s|=c>=e?2:0;var p,f,d,m,g=!1;if(5==(s|=h>=e?1:0)||10===s){var y=(l+u+c+h)/4;5===s&&y<e?(s=10,g=!0):10===s&&y<e&&(s=5,g=!0)}0!==s&&15!==s&&(p=f=d=m=.5,1===s?(d=1-ft(e,l,h),f=1-ft(e,c,h)):2===s?(f=ft(e,h,c),m=1-ft(e,u,c)):3===s?(d=1-ft(e,l,h),m=1-ft(e,u,c)):4===s?(p=ft(e,l,u),m=ft(e,c,u)):5===s?(p=ft(e,l,u),m=ft(e,c,u),f=1-ft(e,c,h),d=1-ft(e,l,h)):6===s?(f=ft(e,h,c),p=ft(e,l,u)):7===s?(d=1-ft(e,l,h),p=ft(e,l,u)):8===s?(d=ft(e,h,l),p=1-ft(e,u,l)):9===s?(f=1-ft(e,c,h),p=1-ft(e,u,l)):10===s?(p=1-ft(e,u,l),m=1-ft(e,u,c),f=ft(e,h,c),d=ft(e,h,l)):11===s?(p=1-ft(e,u,l),m=1-ft(e,u,c)):12===s?(d=ft(e,h,l),m=ft(e,c,u)):13===s?(f=1-ft(e,c,h),m=ft(e,c,u)):14===s?(d=ft(e,h,l),f=ft(e,h,c)):console.log("MarchingSquaresJS-isoContours: Illegal cval detected: "+s),i.cells[o][a]={cval:s,flipped:g,top:p,right:m,bottom:f,left:d})}}}return i}(t,e));return"function"==typeof ht.successCallback&&ht.successCallback(s),s}function ft(t,e,n){return(t-e)/(n-e)}function dt(t){return 0===t.cval||15===t.cval}function mt(t){dt(t)||5===t.cval||10===t.cval||(t.cval=15)}function gt(t,e){return"top"===e?[t.top,1]:"bottom"===e?[t.bottom,0]:"right"===e?[1,t.right]:"left"===e?[0,t.left]:void 0}var yt=_t,vt=_t;function _t(t,e,n,r,i){xt(t,e,n||0,r||t.length-1,i||wt)}function xt(t,e,n,r,i){for(;r>n;){if(r-n>600){var o=r-n+1,a=e-n+1,s=Math.log(o),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);xt(t,e,Math.max(n,Math.floor(e-a*l/o+u)),Math.min(r,Math.floor(e+(o-a)*l/o+u)),i)}var c=t[e],h=n,p=r;for(bt(t,n,e),i(t[r],c)>0&&bt(t,n,r);h<p;){for(bt(t,h,p),h++,p--;i(t[h],c)<0;)h++;for(;i(t[p],c)>0;)p--}0===i(t[n],c)?bt(t,n,p):bt(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1)}}function bt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function wt(t,e){return t<e?-1:t>e?1:0}yt.default=vt;var Et=Mt,St=Mt;function Mt(t,e){if(!(this instanceof Mt))return new Mt(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function Tt(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function Ct(t,e){It(t,0,t.children.length,e,t)}function It(t,e,n,r,i){i||(i=kt(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o,a=e;a<n;a++)o=t.children[a],At(i,t.leaf?r(o):o);return i}function At(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Lt(t,e){return t.minX-e.minX}function Pt(t,e){return t.minY-e.minY}function Rt(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Dt(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Nt(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Ot(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function kt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function zt(t,e,n,r,i){for(var o,a=[e,n];a.length;)(n=a.pop())-(e=a.pop())<=r||(o=e+Math.ceil((n-e)/r/2)*r,yt(t,o,e,n,i),a.push(e,o,o,n))}function Ft(t){var e={exports:{}};return t(e,e.exports),e.exports}Mt.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],r=this.toBBox;if(!Ot(t,e))return n;for(var i,o,a,s,l=[];e;){for(i=0,o=e.children.length;i<o;i++)a=e.children[i],Ot(t,s=e.leaf?r(a):a)&&(e.leaf?n.push(a):Nt(t,s)?this._all(a,n):l.push(a));e=l.pop()}return n},collides:function(t){var e=this.data,n=this.toBBox;if(!Ot(t,e))return!1;for(var r,i,o,a,s=[];e;){for(r=0,i=e.children.length;r<i;r++)if(o=e.children[r],Ot(t,a=e.leaf?n(o):o)){if(e.leaf||Nt(t,a))return!0;s.push(o)}e=s.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,n=t.length;e<n;e++)this.insert(t[e]);return this}var r=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var i=this.data;this.data=r,r=i}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},insert:function(t){return t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=kt([]),this},remove:function(t,e){if(!t)return this;for(var n,r,i,o,a=this.data,s=this.toBBox(t),l=[],u=[];a||l.length;){if(a||(a=l.pop(),r=l[l.length-1],n=u.pop(),o=!0),a.leaf&&-1!==(i=Tt(t,a.children,e)))return a.children.splice(i,1),l.push(a),this._condense(l),this;o||a.leaf||!Nt(a,s)?r?(n++,a=r.children[n],o=!1):a=null:(l.push(a),u.push(n),n=0,r=a,a=a.children[0])}return this},toBBox:function(t){return t},compareMinX:Lt,compareMinY:Pt,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},_build:function(t,e,n,r){var i,o=n-e+1,a=this._maxEntries;if(o<=a)return Ct(i=kt(t.slice(e,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(a)),a=Math.ceil(o/Math.pow(a,r-1))),(i=kt([])).leaf=!1,i.height=r;var s,l,u,c,h=Math.ceil(o/a),p=h*Math.ceil(Math.sqrt(a));for(zt(t,e,n,p,this.compareMinX),s=e;s<=n;s+=p)for(zt(t,s,u=Math.min(s+p-1,n),h,this.compareMinY),l=s;l<=u;l+=h)c=Math.min(l+h-1,u),i.children.push(this._build(t,l,c,r-1));return Ct(i,this.toBBox),i},_chooseSubtree:function(t,e,n,r){for(var i,o,a,s,l,u,c,h,p,f;r.push(e),!e.leaf&&r.length-1!==n;){for(c=h=1/0,i=0,o=e.children.length;i<o;i++)l=Rt(a=e.children[i]),p=t,f=a,(u=(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.minY))-l)<h?(h=u,c=l<c?l:c,s=a):u===h&&l<c&&(c=l,s=a);e=s||e.children[0]}return e},_insert:function(t,e,n){var r=this.toBBox,i=n?t:r(t),o=[],a=this._chooseSubtree(i,this.data,e,o);for(a.children.push(t),At(a,i);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(i,o,e)},_split:function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),a=kt(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,Ct(n,this.toBBox),Ct(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},_splitRoot:function(t,e){this.data=kt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ct(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var r,i,o,a,s,l,u,c,h,p,f,d,m,g;for(l=u=1/0,r=e;r<=n-e;r++)h=i=It(t,0,r,this.toBBox),p=o=It(t,r,n,this.toBBox),void 0,void 0,void 0,void 0,f=Math.max(h.minX,p.minX),d=Math.max(h.minY,p.minY),m=Math.min(h.maxX,p.maxX),g=Math.min(h.maxY,p.maxY),a=Math.max(0,m-f)*Math.max(0,g-d),s=Rt(i)+Rt(o),a<l?(l=a,c=r,u=s<u?s:u):a===l&&s<u&&(u=s,c=r);return c},_chooseSplitAxis:function(t,e,n){var r=t.leaf?this.compareMinX:Lt,i=t.leaf?this.compareMinY:Pt;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)},_allDistMargin:function(t,e,n,r){t.children.sort(r);var i,o,a=this.toBBox,s=It(t,0,e,a),l=It(t,n-e,n,a),u=Dt(s)+Dt(l);for(i=e;i<n-e;i++)o=t.children[i],At(s,t.leaf?a(o):o),u+=Dt(s);for(i=n-e-1;i>=e;i--)o=t.children[i],At(l,t.leaf?a(o):o),u+=Dt(l);return u},_adjustParentBBoxes:function(t,e,n){for(var r=n;r>=0;r--)At(e[r],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():Ct(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},Et.default=St;var Bt=function(t,e,n){var r=t*e,i=Ut*t,o=i-(i-t),a=t-o,s=Ut*e,l=s-(s-e),u=e-l,c=a*u-(r-o*l-a*l-o*u);return n?(n[0]=c,n[1]=r,n):[c,r]},Ut=+(Math.pow(2,27)+1),Vt=function(t,e){var n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){var n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);var i,o,a=new Array(n+r),s=0,l=0,u=0,c=Math.abs,h=t[l],p=c(h),f=e[u],d=c(f);p<d?(o=h,(l+=1)<n&&(p=c(h=t[l]))):(o=f,(u+=1)<r&&(d=c(f=e[u])));l<n&&p<d||u>=r?(i=h,(l+=1)<n&&(p=c(h=t[l]))):(i=f,(u+=1)<r&&(d=c(f=e[u])));for(var m,g,y=i+o,v=y-i,_=o-v,x=_,b=y;l<n&&u<r;)p<d?(i=h,(l+=1)<n&&(p=c(h=t[l]))):(i=f,(u+=1)<r&&(d=c(f=e[u]))),(_=(o=x)-(v=(y=i+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m;for(;l<n;)(_=(o=x)-(v=(y=(i=h)+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m,(l+=1)<n&&(h=t[l]);for(;u<r;)(_=(o=x)-(v=(y=(i=f)+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m,(u+=1)<r&&(f=e[u]);x&&(a[s++]=x);b&&(a[s++]=b);s||(a[s++]=0);return a.length=s,a},Gt=function(t,e,n){var r=t+e,i=r-t,o=e-i,a=t-(r-i);return n?(n[0]=a+o,n[1]=r,n):[a+o,r]},jt=function(t,e){var n=t.length;if(1===n){var r=Bt(t[0],e);return r[0]?r:[r[1]]}var i=new Array(2*n),o=[.1,.1],a=[.1,.1],s=0;Bt(t[0],e,o),o[0]&&(i[s++]=o[0]);for(var l=1;l<n;++l){Bt(t[l],e,a);var u=o[1];Gt(u,a[0],o),o[0]&&(i[s++]=o[0]);var c=a[1],h=o[1],p=c+h,f=h-(p-c);o[1]=p,f&&(i[s++]=f)}o[1]&&(i[s++]=o[1]);0===s&&(i[s++]=0);return i.length=s,i},Ht=function(t,e){var n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){var n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],-e[0]);var i,o,a=new Array(n+r),s=0,l=0,u=0,c=Math.abs,h=t[l],p=c(h),f=-e[u],d=c(f);p<d?(o=h,(l+=1)<n&&(p=c(h=t[l]))):(o=f,(u+=1)<r&&(d=c(f=-e[u])));l<n&&p<d||u>=r?(i=h,(l+=1)<n&&(p=c(h=t[l]))):(i=f,(u+=1)<r&&(d=c(f=-e[u])));for(var m,g,y=i+o,v=y-i,_=o-v,x=_,b=y;l<n&&u<r;)p<d?(i=h,(l+=1)<n&&(p=c(h=t[l]))):(i=f,(u+=1)<r&&(d=c(f=-e[u]))),(_=(o=x)-(v=(y=i+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m;for(;l<n;)(_=(o=x)-(v=(y=(i=h)+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m,(l+=1)<n&&(h=t[l]);for(;u<r;)(_=(o=x)-(v=(y=(i=f)+o)-i))&&(a[s++]=_),x=b-((m=b+y)-(g=m-b))+(y-g),b=m,(u+=1)<r&&(f=-e[u]);x&&(a[s++]=x);b&&(a[s++]=b);s||(a[s++]=0);return a.length=s,a},qt=Ft((function(t){function e(t,e){for(var n=new Array(t.length-1),r=1;r<t.length;++r)for(var i=n[r-1]=new Array(t.length-1),o=0,a=0;o<t.length;++o)o!==e&&(i[a++]=t[r][o]);return n}function n(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",n(t.slice(0,e)),",",n(t.slice(e)),")"].join("")}function r(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var i=[],o=0;o<t.length;++o)i.push(["scale(",n(r(e(t,o))),",",(a=o,1&a?"-":""),t[0][o],")"].join(""));return i;var a}function i(t){for(var i=[],o=[],a=function(t){for(var e=new Array(t),n=0;n<t;++n){e[n]=new Array(t);for(var r=0;r<t;++r)e[n][r]=["m",r,"[",t-n-1,"]"].join("")}return e}(t),s=[],l=0;l<t;++l)0==(1&l)?i.push.apply(i,r(e(a,l))):o.push.apply(o,r(e(a,l))),s.push("m"+l);var u=n(i),c=n(o),h="orientation"+t+"Exact",p=["function ",h,"(",s.join(),"){var p=",u,",n=",c,",d=sub(p,n);return d[d.length-1];};return ",h].join("");return new Function("sum","prod","scale","sub",p)(Vt,Bt,jt,Ht)}var o=i(3),a=i(4),s=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){var r,i=(t[1]-n[1])*(e[0]-n[0]),a=(t[0]-n[0])*(e[1]-n[1]),s=i-a;if(i>0){if(a<=0)return s;r=i+a}else{if(!(i<0))return s;if(a>=0)return s;r=-(i+a)}var l=33306690738754716e-32*r;return s>=l||s<=-l?s:o(t,e,n)},function(t,e,n,r){var i=t[0]-r[0],o=e[0]-r[0],s=n[0]-r[0],l=t[1]-r[1],u=e[1]-r[1],c=n[1]-r[1],h=t[2]-r[2],p=e[2]-r[2],f=n[2]-r[2],d=o*c,m=s*u,g=s*l,y=i*c,v=i*u,_=o*l,x=h*(d-m)+p*(g-y)+f*(v-_),b=7771561172376103e-31*((Math.abs(d)+Math.abs(m))*Math.abs(h)+(Math.abs(g)+Math.abs(y))*Math.abs(p)+(Math.abs(v)+Math.abs(_))*Math.abs(f));return x>b||-x>b?x:a(t,e,n,r)}];function l(t){var e=s[t.length];return e||(e=s[t.length]=i(t.length)),e.apply(void 0,t)}!function(){for(;s.length<=5;)s.push(i(s.length));for(var e=[],n=["slow"],r=0;r<=5;++r)e.push("a"+r),n.push("o"+r);var o=["function getOrientation(",e.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=5;++r)o.push("case ",r,":return o",r,"(",e.slice(0,r).join(),");");o.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation"),n.push(o.join(""));var a=Function.apply(void 0,n);for(t.exports=a.apply(void 0,[l].concat(s)),r=0;r<=5;++r)t.exports[r]=s[r]}()})),Wt=qt[3],Xt=Yt,Zt=Yt;function Yt(t,e){if(!(this instanceof Yt))return new Yt(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||Jt,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function Jt(t,e){return t<e?-1:t>e?1:0}Yt.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},_down:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t<r;){var o=1+(t<<1),a=o+1,s=e[o];if(a<this.length&&n(e[a],s)<0&&(o=a,s=e[a]),n(s,i)>=0)break;e[t]=s,t=o}e[t]=i}},Xt.default=Zt;var Kt=function(t,e){for(var n=t[0],r=t[1],i=!1,o=0,a=e.length-1;o<e.length;a=o++){var s=e[o][0],l=e[o][1],u=e[a][0],c=e[a][1];l>r!=c>r&&n<(u-s)*(r-l)/(c-l)+s&&(i=!i)}return i},Qt=qt[3],$t=ee,te=ee;function ee(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;for(var r,i=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;o<t.length;o++){var a=t[o];a[0]<e[0]&&(e=a),a[0]>r[0]&&(r=a),a[1]<n[1]&&(n=a),a[1]>i[1]&&(i=a)}var s=[e,n,r,i],l=s.slice();for(o=0;o<t.length;o++)Kt(t[o],s)||l.push(t[o]);var u=function(t){var e=t.length;if(e<3){for(var n=new Array(e),r=0;r<e;++r)n[r]=r;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}var i=new Array(e);for(r=0;r<e;++r)i[r]=r;i.sort((function(e,n){return t[e][0]-t[n][0]||t[e][1]-t[n][1]}));var o=[i[0],i[1]],a=[i[0],i[1]];for(r=2;r<e;++r){for(var s=i[r],l=t[s],u=o.length;u>1&&Wt(t[o[u-2]],t[o[u-1]],l)<=0;)u-=1,o.pop();for(o.push(s),u=a.length;u>1&&Wt(t[a[u-2]],t[a[u-1]],l)>=0;)u-=1,a.pop();a.push(s)}n=new Array(a.length+o.length-2);for(var c=0,h=(r=0,o.length);r<h;++r)n[c++]=o[r];for(var p=a.length-2;p>0;--p)n[c++]=a[p];return n}(l),c=[];for(o=0;o<u.length;o++)c.push(l[u[o]]);return c}(t),o=Et(16,["[0]","[1]","[0]","[1]"]).load(t),a=[],s=0;s<i.length;s++){var l=i[s];o.remove(l),r=le(l,r),a.push(r)}var u=Et(16);for(s=0;s<a.length;s++)u.insert(se(a[s]));for(var c=e*e,h=n*n;a.length;){var p=a.shift(),f=p.p,d=p.next.p,m=ue(f,d);if(!(m<h)){var g=m/c;(l=ne(o,p.prev.p,f,d,p.next.next.p,g,u))&&Math.min(ue(l,f),ue(l,d))<=g&&(a.push(p),a.push(le(l,p)),o.remove(l),u.remove(p),u.insert(se(p)),u.insert(se(p.next)))}}p=r;var y=[];do{y.push(p.p),p=p.next}while(p!==r);return y.push(p.p),y}function ne(t,e,n,r,i,o,a){for(var s=new Xt(null,re),l=t.data;l;){for(var u=0;u<l.children.length;u++){var c=l.children[u],h=l.leaf?ce(c,n,r):ie(n,r,c);h>o||s.push({node:c,dist:h})}for(;s.length&&!s.peek().node.children;){var p=s.pop(),f=p.node,d=ce(f,e,n),m=ce(f,r,i);if(p.dist<d&&p.dist<m&&ae(n,f,a)&&ae(r,f,a))return f}(l=s.pop())&&(l=l.node)}return null}function re(t,e){return t.dist-e.dist}function ie(t,e,n){if(oe(t,n)||oe(e,n))return 0;var r=he(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===r)return 0;var i=he(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===i)return 0;var o=he(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var a=he(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===a?0:Math.min(r,i,o,a)}function oe(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function ae(t,e,n){for(var r,i,o,a,s=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),u=Math.max(t[0],e[0]),c=Math.max(t[1],e[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),p=0;p<h.length;p++)if(r=h[p].p,i=h[p].next.p,o=t,r!==(a=e)&&i!==o&&Qt(r,i,o)>0!=Qt(r,i,a)>0&&Qt(o,a,r)>0!=Qt(o,a,i)>0)return!1;return!0}function se(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function le(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function ue(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function ce(t,e,n){var r=e[0],i=e[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((t[0]-r)*o+(t[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=t[0]-r)*o+(a=t[1]-i)*a}function he(t,e,n,r,i,o,a,s){var l,u,c,h,p=n-t,f=r-e,d=a-i,m=s-o,g=t-i,y=e-o,v=p*p+f*f,_=p*d+f*m,x=d*d+m*m,b=p*g+f*y,w=d*g+m*y,E=v*x-_*_,S=E,M=E;0===E?(u=0,S=1,h=w,M=x):(h=v*w-_*b,(u=_*w-x*b)<0?(u=0,h=w,M=x):u>S&&(u=S,h=w+_,M=x)),h<0?(h=0,-b<0?u=0:-b>v?u=S:(u=-b,S=v)):h>M&&(h=M,-b+_<0?u=0:-b+_>v?u=S:(u=-b+_,S=v));var T=(1-(c=0===h?0:h/M))*i+c*a-((1-(l=0===u?0:u/S))*t+l*n),C=(1-c)*o+c*s-((1-l)*e+l*r);return T*T+C*C}function pe(t,e){void 0===e&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(R(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var r=$t(n,e.concavity);return r.length>3?u([r]):null}function fe(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=K(t),i=rt(e),o=i.type,a=e.bbox,s=i.coordinates;if(a&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(r,a))return!1;"Polygon"===o&&(s=[s]);for(var l=!1,u=0;u<s.length&&!l;u++)if(de(r,s[u][0],n.ignoreBoundary)){for(var c=!1,h=1;h<s[u].length&&!c;)de(r,s[u][h],!n.ignoreBoundary)&&(c=!0),h++;c||(l=!0)}return l}function de(t,e,n){var r=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var i=0,o=e.length-1;i<e.length;o=i++){var a=e[i][0],s=e[i][1],l=e[o][0],u=e[o][1];if(t[1]*(a-l)+s*(l-t[0])+u*(t[0]-a)==0&&(a-t[0])*(l-t[0])<=0&&(s-t[1])*(u-t[1])<=0)return!n;s>t[1]!=u>t[1]&&t[0]<(l-a)*(t[1]-s)/(u-s)+a&&(r=!r)}return r}function me(t,e){var n=[];return k(t,(function(t){var r=!1;if("Point"===t.geometry.type)B(e,(function(e){fe(t,e)&&(r=!0)})),r&&n.push(t);else{if("MultiPoint"!==t.geometry.type)throw new Error("Input geometry must be a Point or MultiPoint");var i=[];B(e,(function(e){R(t,(function(t){fe(t,e)&&(r=!0,i.push(t))}))})),r&&n.push(m(i))}})),f(n)}function ge(t,e,n){void 0===n&&(n={});var r=K(t),i=K(e),o=S(i[1]-r[1]),a=S(i[0]-r[0]),s=S(r[1]),l=S(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(l);return _(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}function ye(t,e){var n=!1;return f(function(t){if(t.length<3)return[];t.sort(_e);for(var e,n,r,i,o,a,s=t.length-1,l=t[s].x,u=t[0].x,c=t[s].y,h=c;s--;)t[s].y<c&&(c=t[s].y),t[s].y>h&&(h=t[s].y);var p,f=u-l,d=h-c,m=f>d?f:d,g=.5*(u+l),y=.5*(h+c),v=[new ve({__sentinel:!0,x:g-20*m,y:y-m},{__sentinel:!0,x:g,y:y+20*m},{__sentinel:!0,x:g+20*m,y:y-m})],_=[],x=[];s=t.length;for(;s--;){for(x.length=0,p=v.length;p--;)(f=t[s].x-v[p].x)>0&&f*f>v[p].r?(_.push(v[p]),v.splice(p,1)):f*f+(d=t[s].y-v[p].y)*d>v[p].r||(x.push(v[p].a,v[p].b,v[p].b,v[p].c,v[p].c,v[p].a),v.splice(p,1));for(xe(x),p=x.length;p;)n=x[--p],e=x[--p],r=t[s],i=n.x-e.x,o=n.y-e.y,a=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(a)>1e-12&&v.push(new ve(e,n,r))}Array.prototype.push.apply(_,v),s=_.length;for(;s--;)(_[s].a.__sentinel||_[s].b.__sentinel||_[s].c.__sentinel)&&_.splice(s,1);return _}(t.features.map((function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r}))).map((function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},u([[e,r,i,e]],o)})))}$t.default=te;var ve=function(t,e,n){this.a=t,this.b=e,this.c=n;var r,i,o=e.x-t.x,a=e.y-t.y,s=n.x-t.x,l=n.y-t.y,u=o*(t.x+e.x)+a*(t.y+e.y),c=s*(t.x+n.x)+l*(t.y+n.y),h=2*(o*(n.y-e.y)-a*(n.x-e.x));this.x=(l*u-a*c)/h,this.y=(o*c-s*u)/h,r=this.x-t.x,i=this.y-t.y,this.r=r*r+i*i};function _e(t,e){return e.x-t.x}function xe(t){var e,n,r,i,o,a=t.length;t:for(;a;)for(n=t[--a],e=t[--a],r=a;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(a,2),t.splice(r,2),a-=2;continue t}}function be(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return we(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach((function(n){switch(n){case"type":case"features":return;default:e[n]=t[n]}})),e.features=t.features.map((function(t){return we(t)})),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Se(t);default:throw new Error("unknown GeoJSON type")}}function we(t){var e={type:"Feature"};return Object.keys(t).forEach((function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}})),e.properties=Ee(t.properties),e.geometry=Se(t.geometry),e}function Ee(t){var e={};return t?(Object.keys(t).forEach((function(n){var r=t[n];"object"==typeof r?null===r?e[n]=null:Array.isArray(r)?e[n]=r.map((function(t){return t})):e[n]=Ee(r):e[n]=r})),e):e}function Se(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map((function(t){return Se(t)})),e):(e.coordinates=Me(t.coordinates),e)}function Me(t){var e=t;return"object"!=typeof e[0]?e.slice():e.map((function(t){return Me(t)}))}function Te(t){return t[0].toString()+","+t[1].toString()}function Ce(t){return t}function Ie(t,e){var n=function(t){if(null==t)return Ce;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],a=t.translate[1];return function(t,s){s||(e=n=0);var l=2,u=t.length,c=new Array(u);for(c[0]=(e+=t[0])*r+o,c[1]=(n+=t[1])*i+a;l<u;)c[l]=t[l],++l;return c}}(t.transform),r=t.arcs;function i(t,e){e.length&&e.pop();for(var i=r[t<0?~t:t],o=0,a=i.length;o<a;++o)e.push(n(i[o],o));t<0&&function(t,e){for(var n,r=t.length,i=r-e;i<--r;)n=t[i],t[i++]=t[r],t[r]=n}(e,a)}function o(t){return n(t)}function a(t){for(var e=[],n=0,r=t.length;n<r;++n)i(t[n],e);return e.length<2&&e.push(e[0]),e}function s(t){for(var e=a(t);e.length<4;)e.push(e[0]);return e}function l(t){return t.map(s)}return function t(e){var n,r=e.type;switch(r){case"GeometryCollection":return{type:r,geometries:e.geometries.map(t)};case"Point":n=o(e.coordinates);break;case"MultiPoint":n=e.coordinates.map(o);break;case"LineString":n=a(e.arcs);break;case"MultiLineString":n=e.arcs.map(a);break;case"Polygon":n=l(e.arcs);break;case"MultiPolygon":n=e.arcs.map(l);break;default:return null}return{type:r,coordinates:n}}(e)}function Ae(t,e){var n={},r=[],i=[];function o(t){t.forEach((function(e){e.forEach((function(e){(n[e=e<0?~e:e]||(n[e]=[])).push(t)}))})),r.push(t)}function a(e){return function(t){for(var e,n=-1,r=t.length,i=t[r-1],o=0;++n<r;)e=i,i=t[n],o+=e[0]*i[1]-e[1]*i[0];return Math.abs(o)}(Ie(t,{type:"Polygon",arcs:[e]}).coordinates[0])}return e.forEach((function t(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"Polygon":o(e.arcs);break;case"MultiPolygon":e.arcs.forEach(o)}})),r.forEach((function(t){if(!t._){var e=[],r=[t];for(t._=1,i.push(e);t=r.pop();)e.push(t),t.forEach((function(t){t.forEach((function(t){n[t<0?~t:t].forEach((function(t){t._||(t._=1,r.push(t))}))}))}))}})),r.forEach((function(t){delete t._})),{type:"MultiPolygon",arcs:i.map((function(e){var r,i=[];if(e.forEach((function(t){t.forEach((function(t){t.forEach((function(t){n[t<0?~t:t].length<2&&i.push(t)}))}))})),(r=(i=function(t,e){var n={},r={},i={},o=[],a=-1;function s(t,e){for(var r in t){var i=t[r];delete e[i.start],delete i.start,delete i.end,i.forEach((function(t){n[t<0?~t:t]=1})),o.push(i)}}return e.forEach((function(n,r){var i,o=t.arcs[n<0?~n:n];o.length<3&&!o[1][0]&&!o[1][1]&&(i=e[++a],e[a]=n,e[r]=i)})),e.forEach((function(e){var n,o,a=function(e){var n,r=t.arcs[e<0?~e:e],i=r[0];t.transform?(n=[0,0],r.forEach((function(t){n[0]+=t[0],n[1]+=t[1]}))):n=r[r.length-1];return e<0?[n,i]:[i,n]}(e),s=a[0],l=a[1];if(n=i[s])if(delete i[n.end],n.push(e),n.end=l,o=r[l]){delete r[o.start];var u=o===n?n:n.concat(o);r[u.start=n.start]=i[u.end=o.end]=u}else r[n.start]=i[n.end]=n;else if(n=r[l])if(delete r[n.start],n.unshift(e),n.start=s,o=i[s]){delete i[o.end];var c=o===n?n:o.concat(n);r[c.start=o.start]=i[c.end=n.end]=c}else r[n.start]=i[n.end]=n;else r[(n=[e]).start=s]=i[n.end=l]=n})),s(i,r),s(r,i),e.forEach((function(t){n[t<0?~t:t]||o.push([t])})),o}(t,i)).length)>1)for(var o,s,l=1,u=a(i[0]);l<r;++l)(o=a(i[l]))>u&&(s=i[0],i[0]=i[l],i[l]=s,u=o);return i})).filter((function(t){return t.length>0}))}}var Le=Object.prototype.hasOwnProperty;function Pe(t,e,n,r,i,o){3===arguments.length&&(r=o=Array,i=null);for(var a=new r(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),s=new o(t),l=t-1,u=0;u<t;++u)a[u]=i;return{set:function(r,o){for(var u=e(r)&l,c=a[u],h=0;c!=i;){if(n(c,r))return s[u]=o;if(++h>=t)throw new Error("full hashmap");c=a[u=u+1&l]}return a[u]=r,s[u]=o,o},maybeSet:function(r,o){for(var u=e(r)&l,c=a[u],h=0;c!=i;){if(n(c,r))return s[u];if(++h>=t)throw new Error("full hashmap");c=a[u=u+1&l]}return a[u]=r,s[u]=o,o},get:function(r,o){for(var u=e(r)&l,c=a[u],h=0;c!=i;){if(n(c,r))return s[u];if(++h>=t)break;c=a[u=u+1&l]}return o},keys:function(){for(var t=[],e=0,n=a.length;e<n;++e){var r=a[e];r!=i&&t.push(r)}return t}}}function Re(t,e){return t[0]===e[0]&&t[1]===e[1]}var De=new ArrayBuffer(16),Ne=new Float64Array(De),Oe=new Uint32Array(De);function ke(t){Ne[0]=t[0],Ne[1]=t[1];var e=Oe[0]^Oe[1];return 2147483647&(e<<5^e>>7^Oe[2]^Oe[3])}function ze(t,e,n,r){Fe(t,e,n),Fe(t,e,e+r),Fe(t,e+r,n)}function Fe(t,e,n){for(var r,i=e+(n---e>>1);e<i;++e,--n)r=t[e],t[e]=t[n],t[n]=r}function Be(t){var e={type:"GeometryCollection",geometries:t.features.map(Ue)};return null!=t.bbox&&(e.bbox=t.bbox),e}function Ue(t){var e,n=Ve(t.geometry);for(e in null!=t.id&&(n.id=t.id),null!=t.bbox&&(n.bbox=t.bbox),t.properties){n.properties=t.properties;break}return n}function Ve(t){if(null==t)return{type:null};var e="GeometryCollection"===t.type?{type:"GeometryCollection",geometries:t.geometries.map(Ve)}:"Point"===t.type||"MultiPoint"===t.type?{type:t.type,coordinates:t.coordinates}:{type:t.type,arcs:t.coordinates};return null!=t.bbox&&(e.bbox=t.bbox),e}function Ge(t,e){var n=function(t){var e=1/0,n=1/0,r=-1/0,i=-1/0;function o(t){null!=t&&Le.call(a,t.type)&&a[t.type](t)}var a={GeometryCollection:function(t){t.geometries.forEach(o)},Point:function(t){s(t.coordinates)},MultiPoint:function(t){t.coordinates.forEach(s)},LineString:function(t){l(t.arcs)},MultiLineString:function(t){t.arcs.forEach(l)},Polygon:function(t){t.arcs.forEach(l)},MultiPolygon:function(t){t.arcs.forEach(u)}};function s(t){var o=t[0],a=t[1];o<e&&(e=o),o>r&&(r=o),a<n&&(n=a),a>i&&(i=a)}function l(t){t.forEach(s)}function u(t){t.forEach(l)}for(var c in t)o(t[c]);return r>=e&&i>=n?[e,n,r,i]:void 0}(t=function(t){var e,n,r={};for(e in t)r[e]=null==(n=t[e])?{type:null}:("FeatureCollection"===n.type?Be:"Feature"===n.type?Ue:Ve)(n);return r}(t)),r=e>0&&n&&function(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=o-r?(n-1)/(o-r):1,l=a-i?(n-1)/(a-i):1;function u(t){return[Math.round((t[0]-r)*s),Math.round((t[1]-i)*l)]}function c(t,e){for(var n,o,a,u,c,h=-1,p=0,f=t.length,d=new Array(f);++h<f;)n=t[h],u=Math.round((n[0]-r)*s),c=Math.round((n[1]-i)*l),u===o&&c===a||(d[p++]=[o=u,a=c]);for(d.length=p;p<e;)p=d.push([d[0][0],d[0][1]]);return d}function h(t){return c(t,2)}function p(t){return c(t,4)}function f(t){return t.map(p)}function d(t){null!=t&&Le.call(m,t.type)&&m[t.type](t)}var m={GeometryCollection:function(t){t.geometries.forEach(d)},Point:function(t){t.coordinates=u(t.coordinates)},MultiPoint:function(t){t.coordinates=t.coordinates.map(u)},LineString:function(t){t.arcs=h(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(h)},Polygon:function(t){t.arcs=f(t.arcs)},MultiPolygon:function(t){t.arcs=t.arcs.map(f)}};for(var g in t)d(t[g]);return{scale:[1/s,1/l],translate:[r,i]}}(t,n,e),i=function(t){var e,n,r,i,o=t.coordinates,a=t.lines,s=t.rings,l=a.length+s.length;for(delete t.lines,delete t.rings,r=0,i=a.length;r<i;++r)for(e=a[r];e=e.next;)++l;for(r=0,i=s.length;r<i;++r)for(n=s[r];n=n.next;)++l;var u=Pe(2*l*1.4,ke,Re),c=t.arcs=[];for(r=0,i=a.length;r<i;++r){e=a[r];do{h(e)}while(e=e.next)}for(r=0,i=s.length;r<i;++r)if((n=s[r]).next)do{h(n)}while(n=n.next);else p(n);function h(t){var e,n,r,i,a,s,l,h;if(r=u.get(e=o[t[0]]))for(l=0,h=r.length;l<h;++l)if(f(i=r[l],t))return t[0]=i[0],void(t[1]=i[1]);if(a=u.get(n=o[t[1]]))for(l=0,h=a.length;l<h;++l)if(d(s=a[l],t))return t[1]=s[0],void(t[0]=s[1]);r?r.push(t):u.set(e,[t]),a?a.push(t):u.set(n,[t]),c.push(t)}function p(t){var e,n,r,i,a;if(n=u.get(o[t[0]]))for(i=0,a=n.length;i<a;++i){if(m(r=n[i],t))return t[0]=r[0],void(t[1]=r[1]);if(g(r,t))return t[0]=r[1],void(t[1]=r[0])}if(n=u.get(e=o[t[0]+y(t)]))for(i=0,a=n.length;i<a;++i){if(m(r=n[i],t))return t[0]=r[0],void(t[1]=r[1]);if(g(r,t))return t[0]=r[1],void(t[1]=r[0])}n?n.push(t):u.set(e,[t]),c.push(t)}function f(t,e){var n=t[0],r=e[0],i=t[1];if(n-i!=r-e[1])return!1;for(;n<=i;++n,++r)if(!Re(o[n],o[r]))return!1;return!0}function d(t,e){var n=t[0],r=e[0],i=t[1],a=e[1];if(n-i!=r-a)return!1;for(;n<=i;++n,--a)if(!Re(o[n],o[a]))return!1;return!0}function m(t,e){var n=t[0],r=e[0],i=t[1]-n;if(i!==e[1]-r)return!1;for(var a=y(t),s=y(e),l=0;l<i;++l)if(!Re(o[n+(l+a)%i],o[r+(l+s)%i]))return!1;return!0}function g(t,e){var n=t[0],r=e[0],i=t[1],a=e[1],s=i-n;if(s!==a-r)return!1;for(var l=y(t),u=s-y(e),c=0;c<s;++c)if(!Re(o[n+(c+l)%s],o[a-(c+u)%s]))return!1;return!0}function y(t){for(var e=t[0],n=t[1],r=e,i=r,a=o[r];++r<n;){var s=o[r];(s[0]<a[0]||s[0]===a[0]&&s[1]<a[1])&&(i=r,a=s)}return i-e}return t}(function(t){var e,n,r,i=function(t){var e,n,r,i,o=t.coordinates,a=t.lines,s=t.rings,l=function(){for(var t=Pe(1.4*o.length,b,w,Int32Array,-1,Int32Array),e=new Int32Array(o.length),n=0,r=o.length;n<r;++n)e[n]=t.maybeSet(n,n);return e}(),u=new Int32Array(o.length),c=new Int32Array(o.length),h=new Int32Array(o.length),p=new Int8Array(o.length),f=0;for(e=0,n=o.length;e<n;++e)u[e]=c[e]=h[e]=-1;for(e=0,n=a.length;e<n;++e){var d=a[e],m=d[0],g=d[1];for(r=l[m],i=l[++m],++f,p[r]=1;++m<=g;)x(e,r,r=i,i=l[m]);++f,p[i]=1}for(e=0,n=o.length;e<n;++e)u[e]=-1;for(e=0,n=s.length;e<n;++e){var y=s[e],v=y[0]+1,_=y[1];for(x(e,l[_-1],r=l[v-1],i=l[v]);++v<=_;)x(e,r,r=i,i=l[v])}function x(t,e,n,r){if(u[n]!==t){u[n]=t;var i=c[n];if(i>=0){var o=h[n];i===e&&o===r||i===r&&o===e||(++f,p[n]=1)}else c[n]=e,h[n]=r}}function b(t){return ke(o[t])}function w(t,e){return Re(o[t],o[e])}u=c=h=null;var E,S=function(t,e,n,r,i){3===arguments.length&&(r=Array,i=null);for(var o=new r(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),a=t-1,s=0;s<t;++s)o[s]=i;return{add:function(r){for(var s=e(r)&a,l=o[s],u=0;l!=i;){if(n(l,r))return!0;if(++u>=t)throw new Error("full hashset");l=o[s=s+1&a]}return o[s]=r,!0},has:function(r){for(var s=e(r)&a,l=o[s],u=0;l!=i;){if(n(l,r))return!0;if(++u>=t)break;l=o[s=s+1&a]}return!1},values:function(){for(var t=[],e=0,n=o.length;e<n;++e){var r=o[e];r!=i&&t.push(r)}return t}}}(1.4*f,ke,Re);for(e=0,n=o.length;e<n;++e)p[E=l[e]]&&S.add(o[E]);return S}(t),o=t.coordinates,a=t.lines,s=t.rings;for(n=0,r=a.length;n<r;++n)for(var l=a[n],u=l[0],c=l[1];++u<c;)i.has(o[u])&&(e={0:u,1:l[1]},l[1]=u,l=l.next=e);for(n=0,r=s.length;n<r;++n)for(var h=s[n],p=h[0],f=p,d=h[1],m=i.has(o[p]);++f<d;)i.has(o[f])&&(m?(e={0:f,1:h[1]},h[1]=f,h=h.next=e):(ze(o,p,d,d-f),o[d]=o[p],m=!0,f=p));return t}(function(t){var e=-1,n=[],r=[],i=[];function o(t){t&&Le.call(a,t.type)&&a[t.type](t)}var a={GeometryCollection:function(t){t.geometries.forEach(o)},LineString:function(t){t.arcs=s(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(s)},Polygon:function(t){t.arcs=t.arcs.map(l)},MultiPolygon:function(t){t.arcs=t.arcs.map(u)}};function s(t){for(var r=0,o=t.length;r<o;++r)i[++e]=t[r];var a={0:e-o+1,1:e};return n.push(a),a}function l(t){for(var n=0,o=t.length;n<o;++n)i[++e]=t[n];var a={0:e-o+1,1:e};return r.push(a),a}function u(t){return t.map(l)}for(var c in t)o(t[c]);return{type:"Topology",coordinates:i,lines:n,rings:r,objects:t}}(t))),o=i.coordinates,a=Pe(1.4*i.arcs.length,je,He);function s(t){t&&Le.call(l,t.type)&&l[t.type](t)}t=i.objects,i.bbox=n,i.arcs=i.arcs.map((function(t,e){return a.set(t,e),o.slice(t[0],t[1]+1)})),delete i.coordinates,o=null;var l={GeometryCollection:function(t){t.geometries.forEach(s)},LineString:function(t){t.arcs=u(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(u)},Polygon:function(t){t.arcs=t.arcs.map(u)},MultiPolygon:function(t){t.arcs=t.arcs.map(c)}};function u(t){var e=[];do{var n=a.get(t);e.push(t[0]<t[1]?n:~n)}while(t=t.next);return e}function c(t){return t.map(u)}for(var h in t)s(t[h]);return r&&(i.transform=r,i.arcs=function(t){for(var e=-1,n=t.length;++e<n;){for(var r,i,o=t[e],a=0,s=1,l=o.length,u=o[0],c=u[0],h=u[1];++a<l;)r=(u=o[a])[0],i=u[1],r===c&&i===h||(o[s++]=[r-c,i-h],c=r,h=i);1===s&&(o[s++]=[0,0]),o.length=s}return t}(i.arcs)),i}function je(t){var e,n=t[0],r=t[1];return r<n&&(e=n,n=r,r=e),n+31*r}function He(t,e){var n,r=t[0],i=t[1],o=e[0],a=e[1];return i<r&&(n=r,r=i,i=n),a<o&&(n=o,o=a,a=n),r===o&&i===a}function qe(t,e){if(void 0===e&&(e={}),"FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==e.mutate&&void 0!==e.mutate||(t=be(t));var n=[];V(t,(function(t){n.push(t.geometry)}));var r=Ge({geoms:y(n).geometry});return function(t){return Ie(t,Ae.apply(this,arguments))}(r,r.objects.geoms.geometries)}function We(t,e){if(void 0===e&&(e={}),!I(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==n&&void 0!==n||(t=be(t));var r=function(t){var e={};V(t,(function(t){e[t.geometry.type]=!0}));var n=Object.keys(e);return 1===n.length?n[0]:null}(t);if(!r)throw new Error("geojson must be homogenous");var i=t;switch(r){case"LineString":return function(t,e){if(void 0===e&&(e={}),!I(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==n&&void 0!==n||(t=be(t));var r=[],i=W(t,(function(t,e){var n=function(t,e){var n,r=t.geometry.coordinates,i=e.geometry.coordinates,o=Te(r[0]),a=Te(r[r.length-1]),s=Te(i[0]),l=Te(i[i.length-1]);if(o===l)n=i.concat(r.slice(1));else if(s===a)n=r.concat(i.slice(1));else if(o===s)n=r.slice(1).reverse().concat(i);else{if(a!==l)return null;n=r.concat(i.reverse().slice(1))}return h(n)}(t,e);return n||(r.push(t),e)}));return i&&r.push(i),r.length?1===r.length?r[0]:d(r.map((function(t){return t.coordinates}))):null}(i,e);case"Polygon":return qe(i,e);default:throw new Error(r+" is not supported")}}function Xe(t,e){void 0===e&&(e={});var n="object"==typeof e?e.mutate:e;if(!t)throw new Error("geojson is required");var r=it(t),i=[];switch(r){case"LineString":i=Ze(t);break;case"MultiLineString":case"Polygon":Q(t).forEach((function(t){i.push(Ze(t))}));break;case"MultiPolygon":Q(t).forEach((function(t){var e=[];t.forEach((function(t){e.push(Ze(t))})),i.push(e)}));break;case"Point":return t;case"MultiPoint":var a={};Q(t).forEach((function(t){var e=t.join("-");Object.prototype.hasOwnProperty.call(a,e)||(i.push(t),a[e]=!0)}));break;default:throw new Error(r+" geometry not supported")}return t.coordinates?!0===n?(t.coordinates=i,t):{type:r,coordinates:i}:!0===n?(t.geometry.coordinates=i,t):o({type:r,coordinates:i},t.properties,{bbox:t.bbox,id:t.id})}function Ze(t){var e=Q(t);if(2===e.length&&!Ye(e[0],e[1]))return e;var n=[],r=e.length-1,i=n.length;n.push(e[0]);for(var o=1;o<r;o++){var a=n[n.length-1];e[o][0]===a[0]&&e[o][1]===a[1]||(n.push(e[o]),(i=n.length)>2&&Je(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1))}if(n.push(e[e.length-1]),i=n.length,Ye(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return Je(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1),n}function Ye(t,e){return t[0]===e[0]&&t[1]===e[1]}function Je(t,e,n){var r=n[0],i=n[1],o=t[0],a=t[1],s=e[0],l=e[1],u=s-o,c=l-a;return 0==(r-o)*c-(i-a)*u&&(Math.abs(u)>=Math.abs(c)?u>0?o<=r&&r<=s:s<=r&&r<=o:c>0?a<=i&&i<=l:l<=i&&i<=a)}function Ke(t,e,n){var r=e.x,i=e.y,o=n.x-r,a=n.y-i;if(0!==o||0!==a){var s=((t.x-r)*o+(t.y-i)*a)/(o*o+a*a);s>1?(r=n.x,i=n.y):s>0&&(r+=o*s,i+=a*s)}return(o=t.x-r)*o+(a=t.y-i)*a}function Qe(t,e,n,r,i){for(var o,a=r,s=e+1;s<n;s++){var l=Ke(t[s],t[e],t[n]);l>a&&(o=s,a=l)}a>r&&(o-e>1&&Qe(t,e,o,r,i),i.push(t[o]),n-o>1&&Qe(t,o,n,r,i))}function $e(t,e){var n=t.length-1,r=[t[0]];return Qe(t,0,n,e,r),r.push(t[n]),r}function tn(t,e,n){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return $e(t=n?t:function(t,e){for(var n,r,i,o,a,s=t[0],l=[s],u=1,c=t.length;u<c;u++)i=s,void 0,void 0,(o=(r=n=t[u]).x-i.x)*o+(a=r.y-i.y)*a>e&&(l.push(n),s=n);return s!==n&&l.push(n),l}(t,r),r)}function en(t,e,n){return tn(t.map((function(t){return{x:t[0],y:t[1],z:t[2]}})),e,n).map((function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y]}))}function nn(t,e,n){return t.map((function(t){var r=t.map((function(t){return{x:t[0],y:t[1]}}));if(r.length<4)throw new Error("invalid polygon");for(var i=tn(r,e,n).map((function(t){return[t.x,t.y]}));!rn(i);)i=tn(r,e-=.01*e,n).map((function(t){return[t.x,t.y]}));return i[i.length-1][0]===i[0][0]&&i[i.length-1][1]===i[0][1]||i.push(i[0]),i}))}function rn(t){return!(t.length<3||3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}var on=function(){function t(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(e=0;e<this.length-1;e++){var n=this.points[e],r=this.points[e+1];this.centers.push({x:(n.x+r.x)/2,y:(n.y+r.y)/2,z:(n.z+r.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(e=0;e<this.centers.length-1;e++){var i=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,o=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,a=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+i),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+o),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+a)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+i),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+o),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+a)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return t.prototype.cacheSteps=function(t){var e=[],n=this.pos(0);e.push(0);for(var r=0;r<this.duration;r+=10){var i=this.pos(r);Math.sqrt((i.x-n.x)*(i.x-n.x)+(i.y-n.y)*(i.y-n.y)+(i.z-n.z)*(i.z-n.z))>t&&(e.push(r),n=i)}return e},t.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}},t.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*n);return function(t,e,n,r,i){var o=function(t){var e=t*t;return[e*t,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:i.x*o[0]+r.x*o[1]+n.x*o[2]+e.x*o[3],y:i.y*o[0]+r.y*o[1]+n.y*o[2]+e.y*o[3],z:i.z*o[0]+r.z*o[1]+n.z*o[2]+e.z*o[3]}}((this.length-1)*n-r,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1])},t}();function an(t,e){void 0===e&&(e={});for(var n=e.resolution||1e4,r=e.sharpness||.85,i=[],o=rt(t).coordinates.map((function(t){return{x:t[0],y:t[1]}})),a=new on({duration:n,points:o,sharpness:r}),s=function(t){var e=a.pos(t);Math.floor(t/100)%2==0&&i.push([e.x,e.y])},l=0;l<a.duration;l+=10)s(l);return s(a.duration),h(i,e.properties)}function sn(t,e){void 0===e&&(e={});var n=Number(t[0]),r=Number(t[1]),i=Number(t[2]),o=Number(t[3]);if(6===t.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var a=[n,r];return u([[a,[i,r],[i,o],[n,o],a]],e.properties,{bbox:t,id:e.id})}function ln(t){return sn(J(t))}function un(t){var e=t[0],n=t[1],r=t[2],i=t[3];if(ge(t.slice(0,2),[r,n])>=ge(t.slice(0,2),[e,i])){var o=(n+i)/2;return[e,o-(r-e)/2,r,o+(r-e)/2]}var a=(e+r)/2;return[a-(i-n)/2,n,a+(i-n)/2,i]}function cn(t,e,n,r){void 0===r&&(r={});var i=K(t),o=S(i[0]),a=S(i[1]),l=S(n),u=x(e,r.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(l));return s([E(o+Math.atan2(Math.sin(l)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),E(c)],r.properties)}function hn(t,e,n){void 0===n&&(n={});for(var r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],a=0;a<r;a++)o.push(cn(t,e,-360*a/r,n).geometry.coordinates);return o.push(o[0]),u([o],i)}function pn(t,e,n){if(void 0===n&&(n={}),!0===n.final)return function(t,e){var n=pn(e,t);return(n+180)%360}(t,e);var r=K(t),i=K(e),o=S(r[0]),a=S(i[0]),s=S(r[1]),l=S(i[1]),u=Math.sin(a-o)*Math.cos(l),c=Math.cos(s)*Math.sin(l)-Math.sin(s)*Math.cos(l)*Math.cos(a-o);return E(Math.atan2(u,c))}function fn(t,e){void 0===e&&(e={});var n=J(t);return s([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}function dn(t,e){void 0===e&&(e={});var n=0,r=0,i=0;return R(t,(function(t){n+=t[0],r+=t[1],i++}),!0),s([n/i,r/i],e.properties)}function mn(t){var e=[];return"FeatureCollection"===t.type?k(t,(function(t){R(t,(function(n){e.push(s(n,t.properties))}))})):R(t,(function(n){e.push(s(n,t.properties))})),f(e)}var gn=vn,yn=vn;function vn(t,e,n){n=n||2;var r,i,o,a,s,l,u,c=e&&e.length,h=c?e[0]*n:t.length,p=_n(t,0,h,n,!0),f=[];if(!p)return f;if(c&&(p=function(t,e,n,r){var i,o,a,s=[];for(i=0,o=e.length;i<o;i++)(a=_n(t,e[i]*r,i<o-1?e[i+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),s.push(An(a));for(s.sort(Tn),i=0;i<s.length;i++)Cn(s[i],n),n=xn(n,n.next);return n}(t,e,p,n)),t.length>80*n){r=o=t[0],i=a=t[1];for(var d=n;d<h;d+=n)(s=t[d])<r&&(r=s),(l=t[d+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return bn(p,f,n,r,i,u),f}function _n(t,e,n,r,i){var o,a;if(i===Un(t,e,n,r)>0)for(o=e;o<n;o+=r)a=zn(o,t[o],t[o+1],a);else for(o=n-r;o>=e;o-=r)a=zn(o,t[o],t[o+1],a);return a&&Dn(a,a.next)&&(Fn(a),a=a.next),a}function xn(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Dn(r,r.next)&&0!==Rn(r.prev,r,r.next))r=r.next;else{if(Fn(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function bn(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=In(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e<u&&(s++,r=r.nextZ);e++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?En(t,r,i,o):wn(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Fn(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?bn(t=Sn(t,e,n),e,n,r,i,o,2):2===a&&Mn(t,e,n,r,i,o):bn(xn(t),e,n,r,i,o,1);break}}}function wn(t){var e=t.prev,n=t,r=t.next;if(Rn(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Ln(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Rn(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function En(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Rn(i,o,a)>=0)return!1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=In(s,l,e,n,r),p=In(u,c,e,n,r),f=t.prevZ,d=t.nextZ;f&&f.z>=h&&d&&d.z<=p;){if(f!==t.prev&&f!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Rn(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==t.prev&&d!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Rn(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Rn(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Rn(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Sn(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Dn(i,o)&&Nn(i,r,r.next,o)&&On(i,o)&&On(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Fn(r),Fn(r.next),r=t=o),r=r.next}while(r!==t);return r}function Mn(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Pn(a,s)){var l=kn(a,s);return a=xn(a,a.next),l=xn(l,l.next),bn(a,e,n,r,i,o),void bn(l,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function Tn(t,e){return t.x-e.x}function Cn(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!n)return null;if(i===a)return n.prev;var l,u=n,c=n.x,h=n.y,p=1/0;r=n.next;for(;r!==u;)i>=r.x&&r.x>=c&&i!==r.x&&Ln(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&((l=Math.abs(o-r.y)/(i-r.x))<p||l===p&&r.x>n.x)&&On(r,t)&&(n=r,p=l),r=r.next;return n}(t,e)){var n=kn(e,t);xn(n,n.next)}}function In(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function An(t){var e=t,n=t;do{e.x<n.x&&(n=e),e=e.next}while(e!==t);return n}function Ln(t,e,n,r,i,o,a,s){return(i-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Pn(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Nn(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&On(t,e)&&On(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Rn(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Dn(t,e){return t.x===e.x&&t.y===e.y}function Nn(t,e,n,r){return!!(Dn(t,e)&&Dn(n,r)||Dn(t,r)&&Dn(n,e))||Rn(t,e,n)>0!=Rn(t,e,r)>0&&Rn(n,r,t)>0!=Rn(n,r,e)>0}function On(t,e){return Rn(t.prev,t,t.next)<0?Rn(t,e,t.next)>=0&&Rn(t,t.prev,e)>=0:Rn(t,e,t.prev)<0||Rn(t,t.next,e)<0}function kn(t,e){var n=new Bn(t.i,t.x,t.y),r=new Bn(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function zn(t,e,n,r){var i=new Bn(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Fn(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Bn(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Un(t,e,n,r){for(var i=0,o=e,a=n-r;o<n;o+=r)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}function Vn(t){var e=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<e;a++)n.vertices.push(t[i][o][a]);i>0&&(r+=t[i-1].length,n.holes.push(r))}return n}(t),n=gn(e.vertices,e.holes,2),r=[],i=[];n.forEach((function(t,r){var o=n[r];i.push([e.vertices[2*o],e.vertices[2*o+1]])}));for(var o=0;o<i.length;o+=3){var a=i.slice(o,o+3);a.push(i[o]),r.push(u([a]))}return r}function Gn(t,e){if(!t)throw new Error("targetPoint is required");if(!e)throw new Error("points is required");var n,r=1/0,i=0;return k(e,(function(e,n){var o=ge(t,e);o<r&&(i=n,r=o)})),(n=be(e.features[i])).properties.featureIndex=i,n.properties.distanceToPoint=r,n}function jn(t){if(!t)throw new Error("geojson is required");var e=[];return V(t,(function(t){!function(t,e){var n=[],r=t.geometry;if(null!==r){switch(r.type){case"Polygon":n=Q(r);break;case"LineString":n=[Q(r)]}n.forEach((function(n){(function(t,e){var n=[];return t.reduce((function(t,r){var i=h([t,r],e);return i.bbox=function(t,e){var n=t[0],r=t[1],i=e[0],o=e[1];return[n<i?n:i,r<o?r:o,n>i?n:i,r>o?r:o]}(t,r),n.push(i),r})),n})(n,t.properties).forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),f(e)}vn.deviation=function(t,e,n,r){var i=e&&e.length,o=i?e[0]*n:t.length,a=Math.abs(Un(t,0,o,n));if(i)for(var s=0,l=e.length;s<l;s++){var u=e[s]*n,c=s<l-1?e[s+1]*n:t.length;a-=Math.abs(Un(t,u,c,n))}var h=0;for(s=0;s<r.length;s+=3){var p=r[s]*n,f=r[s+1]*n,d=r[s+2]*n;h+=Math.abs((t[p]-t[d])*(t[f+1]-t[p+1])-(t[p]-t[f])*(t[d+1]-t[p+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},vn.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<e;a++)n.vertices.push(t[i][o][a]);i>0&&(r+=t[i-1].length,n.holes.push(r))}return n},gn.default=yn;var Hn=Ft((function(t,e){function n(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function r(t,e,r){if(void 0===r&&(r={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:t},e,r)}function i(t,e,r){void 0===r&&(r={});for(var i=0,o=t;i<o.length;i++){var a=o[i];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:t},e,r)}function o(t,e,r){if(void 0===r&&(r={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:t},e,r)}function a(t,e){void 0===e&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function s(t,e,r){return void 0===r&&(r={}),n({type:"MultiLineString",coordinates:t},e,r)}function l(t,e,r){return void 0===r&&(r={}),n({type:"MultiPoint",coordinates:t},e,r)}function u(t,e,r){return void 0===r&&(r={}),n({type:"MultiPolygon",coordinates:t},e,r)}function c(t,n){void 0===n&&(n="kilometers");var r=e.factors[n];if(!r)throw new Error(n+" units is invalid");return t*r}function h(t,n){void 0===n&&(n="kilometers");var r=e.factors[n];if(!r)throw new Error(n+" units is invalid");return t/r}function p(t){return t%(2*Math.PI)*180/Math.PI}function f(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.earthRadius=6371008.8,e.factors={centimeters:100*e.earthRadius,centimetres:100*e.earthRadius,degrees:e.earthRadius/111325,feet:3.28084*e.earthRadius,inches:39.37*e.earthRadius,kilometers:e.earthRadius/1e3,kilometres:e.earthRadius/1e3,meters:e.earthRadius,metres:e.earthRadius,miles:e.earthRadius/1609.344,millimeters:1e3*e.earthRadius,millimetres:1e3*e.earthRadius,nauticalmiles:e.earthRadius/1852,radians:1,yards:1.0936*e.earthRadius},e.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e.earthRadius,yards:1.0936133},e.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},e.feature=n,e.geometry=function(t,e,n){switch(t){case"Point":return r(e).geometry;case"LineString":return o(e).geometry;case"Polygon":return i(e).geometry;case"MultiPoint":return l(e).geometry;case"MultiLineString":return s(e).geometry;case"MultiPolygon":return u(e).geometry;default:throw new Error(t+" is invalid")}},e.point=r,e.points=function(t,e,n){return void 0===n&&(n={}),a(t.map((function(t){return r(t,e)})),n)},e.polygon=i,e.polygons=function(t,e,n){return void 0===n&&(n={}),a(t.map((function(t){return i(t,e)})),n)},e.lineString=o,e.lineStrings=function(t,e,n){return void 0===n&&(n={}),a(t.map((function(t){return o(t,e)})),n)},e.featureCollection=a,e.multiLineString=s,e.multiPoint=l,e.multiPolygon=u,e.geometryCollection=function(t,e,r){return void 0===r&&(r={}),n({type:"GeometryCollection",geometries:t},e,r)},e.round=function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n},e.radiansToLength=c,e.lengthToRadians=h,e.lengthToDegrees=function(t,e){return p(h(t,e))},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},e.radiansToDegrees=p,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(h(t,e),n)},e.convertArea=function(t,n,r){if(void 0===n&&(n="meters"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[n];if(!i)throw new Error("invalid original units");var o=e.areaFactors[r];if(!o)throw new Error("invalid final units");return t/i*o},e.isNumber=f,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!f(t))throw new Error("bbox must only contain numbers")}))},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}}));function qn(t,e,n){if(null!==t)for(var r,i,o,a,s,l,u,c,h=0,p=0,f=t.type,d="FeatureCollection"===f,m="Feature"===f,g=d?t.features.length:1,y=0;y<g;y++){s=(c=!!(u=d?t.features[y].geometry:m?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<s;v++){var _=0,x=0;if(null!==(a=c?u.geometries[v]:u)){l=a.coordinates;var b=a.type;switch(h=!n||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,p,y,_,x))return!1;p++,_++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],p,y,_,x))return!1;p++,"MultiPoint"===b&&_++}"LineString"===b&&_++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(i=0;i<l[r].length-h;i++){if(!1===e(l[r][i],p,y,_,x))return!1;p++}"MultiLineString"===b&&_++,"Polygon"===b&&x++}"Polygon"===b&&_++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(x=0,i=0;i<l[r].length;i++){for(o=0;o<l[r][i].length-h;o++){if(!1===e(l[r][i][o],p,y,_,x))return!1;p++}x++}_++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===qn(a.geometries[r],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Wn(t,e){var n;switch(t.type){case"FeatureCollection":for(n=0;n<t.features.length&&!1!==e(t.features[n].properties,n);n++);break;case"Feature":e(t.properties,0)}}function Xn(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length&&!1!==e(t.features[n],n);n++);}function Zn(t,e){var n,r,i,o,a,s,l,u,c,h,p=0,f="FeatureCollection"===t.type,d="Feature"===t.type,m=f?t.features.length:1;for(n=0;n<m;n++){for(s=f?t.features[n].geometry:d?t.geometry:t,u=f?t.features[n].properties:d?t.properties:{},c=f?t.features[n].bbox:d?t.bbox:void 0,h=f?t.features[n].id:d?t.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,p,u,c,h))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],p,u,c,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,u,c,h))return!1;p++}}function Yn(t,e){Zn(t,(function(t,n,r,i,o){var a,s=null===t?null:t.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==e(Hn.feature(t,r,{bbox:i,id:o}),n,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var l=0;l<t.coordinates.length;l++){var u={type:a,coordinates:t.coordinates[l]};if(!1===e(Hn.feature(u,r),n,l))return!1}}))}function Jn(t,e){Yn(t,(function(t,n,r){var i=0;if(t.geometry){var o=t.geometry.type;if("Point"!==o&&"MultiPoint"!==o){var a,s=0,l=0,u=0;return!1!==qn(t,(function(o,c,h,p,f){if(void 0===a||n>s||p>l||f>u)return a=o,s=n,l=p,u=f,void(i=0);var d=Hn.lineString([a,o],t.properties);if(!1===e(d,n,r,f,i))return!1;i++,a=o}))&&void 0}}}))}function Kn(t,e){if(!t)throw new Error("geojson is required");Yn(t,(function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var a=0;a<o.length;a++)if(!1===e(Hn.lineString(o[a],t.properties),n,r,a))return!1}}}))}var Qn=qn,$n=Xn,tr=Yn,er=Zn,nr=Kn,rr=Wn,ir=Jn,or=Object.defineProperty({coordAll:function(t){var e=[];return qn(t,(function(t){e.push(t)})),e},coordEach:Qn,coordReduce:function(t,e,n,r){var i=n;return qn(t,(function(t,r,o,a,s){i=0===r&&void 0===n?t:e(i,t,r,o,a,s)}),r),i},featureEach:$n,featureReduce:function(t,e,n){var r=n;return Xn(t,(function(t,i){r=0===i&&void 0===n?t:e(r,t,i)})),r},findPoint:function(t,e){if(e=e||{},!Hn.isObject(e))throw new Error("options is invalid");var n,r=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.coordIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":r<0&&(r=t.features.length+r),s=s||t.features[r].properties,n=t.features[r].geometry;break;case"Feature":s=s||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var l=n.coordinates;switch(n.type){case"Point":return Hn.point(l,s,e);case"MultiPoint":return i<0&&(i=l.length+i),Hn.point(l[i],s,e);case"LineString":return a<0&&(a=l.length+a),Hn.point(l[a],s,e);case"Polygon":return o<0&&(o=l.length+o),a<0&&(a=l[o].length+a),Hn.point(l[o][a],s,e);case"MultiLineString":return i<0&&(i=l.length+i),a<0&&(a=l[i].length+a),Hn.point(l[i][a],s,e);case"MultiPolygon":return i<0&&(i=l.length+i),o<0&&(o=l[i].length+o),a<0&&(a=l[i][o].length-a),Hn.point(l[i][o][a],s,e)}throw new Error("geojson is invalid")},findSegment:function(t,e){if(e=e||{},!Hn.isObject(e))throw new Error("options is invalid");var n,r=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.segmentIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":r<0&&(r=t.features.length+r),s=s||t.features[r].properties,n=t.features[r].geometry;break;case"Feature":s=s||t.properties,n=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":n=t;break;default:throw new Error("geojson is invalid")}if(null===n)return null;var l=n.coordinates;switch(n.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=l.length+a-1),Hn.lineString([l[a],l[a+1]],s,e);case"Polygon":return o<0&&(o=l.length+o),a<0&&(a=l[o].length+a-1),Hn.lineString([l[o][a],l[o][a+1]],s,e);case"MultiLineString":return i<0&&(i=l.length+i),a<0&&(a=l[i].length+a-1),Hn.lineString([l[i][a],l[i][a+1]],s,e);case"MultiPolygon":return i<0&&(i=l.length+i),o<0&&(o=l[i].length+o),a<0&&(a=l[i][o].length-a-1),Hn.lineString([l[i][o][a],l[i][o][a+1]],s,e)}throw new Error("geojson is invalid")},flattenEach:tr,flattenReduce:function(t,e,n){var r=n;return Yn(t,(function(t,i,o){r=0===i&&0===o&&void 0===n?t:e(r,t,i,o)})),r},geomEach:er,geomReduce:function(t,e,n){var r=n;return Zn(t,(function(t,i,o,a,s){r=0===i&&void 0===n?t:e(r,t,i,o,a,s)})),r},lineEach:nr,lineReduce:function(t,e,n){var r=n;return Kn(t,(function(t,i,o,a){r=0===i&&void 0===n?t:e(r,t,i,o,a)})),r},propEach:rr,propReduce:function(t,e,n){var r=n;return Wn(t,(function(t,i){r=0===i&&void 0===n?t:e(r,t,i)})),r},segmentEach:ir,segmentReduce:function(t,e,n){var r=n,i=!1;return Jn(t,(function(t,o,a,s,l){r=!1===i&&void 0===n?t:e(r,t,o,a,s,l),i=!0})),r}},"__esModule",{value:!0});function ar(t){var e=[1/0,1/0,-1/0,-1/0];return or.coordEach(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])})),e}ar.default=ar;var sr=ar,lr=Object.defineProperty({default:sr},"__esModule",{value:!0}).default,ur=or.featureEach,cr=(or.coordEach,Hn.polygon,Hn.featureCollection);function hr(t){var e=Et(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:lr(t),Et.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach((function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:lr(t),e.push(t)})):ur(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:lr(t),e.push(t)})),Et.prototype.load.call(this,e)},e.remove=function(t,e){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:lr(t),Et.prototype.remove.call(this,t,e)},e.clear=function(){return Et.prototype.clear.call(this)},e.search=function(t){var e=Et.prototype.search.call(this,this.toBBox(t));return cr(e)},e.collides=function(t){return Et.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=Et.prototype.all.call(this);return cr(t)},e.toJSON=function(){return Et.prototype.toJSON.call(this)},e.fromJSON=function(t){return Et.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;if(t.bbox)e=t.bbox;else if(Array.isArray(t)&&4===t.length)e=t;else if(Array.isArray(t)&&6===t.length)e=[t[0],t[1],t[3],t[4]];else if("Feature"===t.type)e=lr(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=lr(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}var pr=hr,fr=hr;function dr(t,e){var n={},r=[];if("LineString"===t.type&&(t=o(t)),"LineString"===e.type&&(e=o(e)),"Feature"===t.type&&"Feature"===e.type&&null!==t.geometry&&null!==e.geometry&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var i=mr(t,e);return i&&r.push(i),f(r)}var a=pr();return a.load(jn(e)),k(jn(t),(function(t){k(a.search(t),(function(e){var i=mr(t,e);if(i){var o=Q(i).join(",");n[o]||(n[o]=!0,r.push(i))}}))})),f(r)}function mr(t,e){var n=Q(t),r=Q(e);if(2!==n.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==r.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],a=n[1][0],l=n[1][1],u=r[0][0],c=r[0][1],h=r[1][0],p=r[1][1],f=(p-c)*(a-i)-(h-u)*(l-o);if(0===f)return null;var d=((h-u)*(o-c)-(p-c)*(i-u))/f,m=((a-i)*(o-c)-(l-o)*(i-u))/f;return d>=0&&d<=1&&m>=0&&m<=1?s([i+d*(a-i),o+d*(l-o)]):null}function gr(t,e,n){void 0===n&&(n={});var r=s([1/0,1/0],{dist:1/0}),i=0;return V(t,(function(t){for(var o=Q(t),a=0;a<o.length-1;a++){var l=s(o[a]);l.properties.dist=ge(e,l,n);var u=s(o[a+1]);u.properties.dist=ge(e,u,n);var c=ge(l,u,n),p=Math.max(l.properties.dist,u.properties.dist),f=pn(l,u),d=cn(e,p,f+90,n),m=cn(e,p,f-90,n),g=dr(h([d.geometry.coordinates,m.geometry.coordinates]),h([l.geometry.coordinates,u.geometry.coordinates])),y=null;g.features.length>0&&((y=g.features[0]).properties.dist=ge(e,y,n),y.properties.location=i+ge(l,y,n)),l.properties.dist<r.properties.dist&&((r=l).properties.index=a,r.properties.location=i),u.properties.dist<r.properties.dist&&((r=u).properties.index=a+1,r.properties.location=i+c),y&&y.properties.dist<r.properties.dist&&((r=y).properties.index=a),i+=c}})),r}function yr(t,n,r){void 0===r&&(r={});var i=K(t),o=K(n);return o[0]+=o[0]-i[0]>180?-360:i[0]-o[0]>180?360:0,M(function(t,n,r){var i=r=void 0===r?e:Number(r),o=t[1]*Math.PI/180,a=n[1]*Math.PI/180,s=a-o,l=Math.abs(n[0]-t[0])*Math.PI/180;l>Math.PI&&(l-=2*Math.PI);var u=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),c=Math.abs(u)>1e-11?s/u:Math.cos(o);return Math.sqrt(s*s+c*c*l*l)*i}(i,o),"meters",r.units)}function vr(t,e,n){if(void 0===n&&(n={}),n.method||(n.method="geodesic"),n.units||(n.units="kilometers"),!t)throw new Error("pt is required");if(Array.isArray(t)?t=s(t):"Point"===t.type?t=o(t):et(t,"Point","point"),!e)throw new Error("line is required");Array.isArray(e)?e=h(e):"LineString"===e.type?e=o(e):et(e,"LineString","line");var r=1/0,i=t.geometry.coordinates;return j(e,(function(t){var e=t.geometry.coordinates[0],o=t.geometry.coordinates[1],a=function(t,e,n,r){var i=[n[0]-e[0],n[1]-e[1]],o=_r([t[0]-e[0],t[1]-e[1]],i);if(o<=0)return xr(t,e,{method:r.method,units:"degrees"});var a=_r(i,i);if(a<=o)return xr(t,n,{method:r.method,units:"degrees"});var s=o/a;return xr(t,[e[0]+s*i[0],e[1]+s*i[1]],{method:r.method,units:"degrees"})}(i,e,o,n);a<r&&(r=a)})),M(r,"degrees",n.units)}function _r(t,e){return t[0]*e[0]+t[1]*e[1]}function xr(t,e,n){return"planar"===n.method?yr(t,e,n):ge(t,e,n)}function br(t,e,n,r,i,o,a,s){var l,u,c,h,p={x:null,y:null,onLine1:!1,onLine2:!1};return 0==(l=(s-o)*(n-t)-(a-i)*(r-e))?null!==p.x&&null!==p.y&&p:(h=(n-t)*(u=e-o)-(r-e)*(c=t-i),u=((a-i)*u-(s-o)*c)/l,c=h/l,p.x=t+u*(n-t),p.y=e+u*(r-e),u>=0&&u<=1&&(p.onLine1=!0),c>=0&&c<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y])}function wr(t){for(var e=function(t){return"FeatureCollection"!==t.type?"Feature"!==t.type?f([o(t)]):f([t]):t}(t),n=fn(e),r=!1,i=0;!r&&i<e.features.length;){var a,l=e.features[i].geometry,u=!1;if("Point"===l.type)n.geometry.coordinates[0]===l.coordinates[0]&&n.geometry.coordinates[1]===l.coordinates[1]&&(r=!0);else if("MultiPoint"===l.type){var c=!1;for(a=0;!c&&a<l.coordinates.length;)n.geometry.coordinates[0]===l.coordinates[a][0]&&n.geometry.coordinates[1]===l.coordinates[a][1]&&(r=!0,c=!0),a++}else if("LineString"===l.type)for(a=0;!u&&a<l.coordinates.length-1;)Er(n.geometry.coordinates[0],n.geometry.coordinates[1],l.coordinates[a][0],l.coordinates[a][1],l.coordinates[a+1][0],l.coordinates[a+1][1])&&(u=!0,r=!0),a++;else if("MultiLineString"===l.type)for(var h=0;h<l.coordinates.length;){u=!1,a=0;for(var p=l.coordinates[h];!u&&a<p.length-1;)Er(n.geometry.coordinates[0],n.geometry.coordinates[1],p[a][0],p[a][1],p[a+1][0],p[a+1][1])&&(u=!0,r=!0),a++;h++}else"Polygon"!==l.type&&"MultiPolygon"!==l.type||fe(n,l)&&(r=!0);i++}if(r)return n;var d=f([]);for(i=0;i<e.features.length;i++)d.features=d.features.concat(mn(e.features[i]).features);return s(Gn(n,d).geometry.coordinates)}function Er(t,e,n,r,i,o){return Math.sqrt((i-n)*(i-n)+(o-r)*(o-r))===Math.sqrt((t-n)*(t-n)+(e-r)*(e-r))+Math.sqrt((i-t)*(i-t)+(o-e)*(o-e))}pr.default=fr;var Sr=6378137;function Mr(t){return U(t,(function(t,e){return t+function(t){var e,n=0;switch(t.type){case"Polygon":return Tr(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)n+=Tr(t.coordinates[e]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),0)}function Tr(t){var e=0;if(t&&t.length>0){e+=Math.abs(Cr(t[0]));for(var n=1;n<t.length;n++)e-=Math.abs(Cr(t[n]))}return e}function Cr(t){var e,n,r,i,o,a,s=0,l=t.length;if(l>2){for(a=0;a<l;a++)a===l-2?(r=l-2,i=l-1,o=0):a===l-1?(r=l-1,i=0,o=1):(r=a,i=a+1,o=a+2),e=t[r],n=t[i],s+=(Ir(t[o][0])-Ir(e[0]))*Math.sin(Ir(n[1]));s=s*Sr*Sr/2}return s}function Ir(t){return t*Math.PI/180}function Ar(t,e){return void 0===e&&(e={}),H(t,(function(t,n){var r=n.geometry.coordinates;return t+ge(r[0],r[1],e)}),0)}function Lr(t,e,n,r){if(!I(r=r||{}))throw new Error("options is invalid");var i,o=[];if("Feature"===t.type)i=t.geometry.coordinates;else{if("LineString"!==t.type)throw new Error("input must be a LineString Feature or Geometry");i=t.coordinates}for(var a,s,l,u=i.length,c=0,p=0;p<i.length&&!(e>=c&&p===i.length-1);p++){if(c>e&&0===o.length){if(!(a=e-c))return o.push(i[p]),h(o);s=pn(i[p],i[p-1])-180,l=cn(i[p],a,s,r),o.push(l.geometry.coordinates)}if(c>=n)return(a=n-c)?(s=pn(i[p],i[p-1])-180,l=cn(i[p],a,s,r),o.push(l.geometry.coordinates),h(o)):(o.push(i[p]),h(o));if(c>=e&&o.push(i[p]),p===i.length-1)return h(o);c+=ge(i[p],i[p+1],r)}if(c<e&&i.length===u)throw new Error("Start position is beyond line");var f=i[i.length-1];return h([f,f])}function Pr(t,e,n){void 0===n&&(n={});for(var r=K(t),i=Q(e),o=0;o<i.length-1;o++){var a=!1;if(n.ignoreEndVertices&&(0===o&&(a="start"),o===i.length-2&&(a="end"),0===o&&o+1===i.length-1&&(a="both")),Rr(i[o],i[o+1],r,a,void 0===n.epsilon?null:n.epsilon))return!0}return!1}function Rr(t,e,n,r,i){var o=n[0],a=n[1],s=t[0],l=t[1],u=e[0],c=e[1],h=u-s,p=c-l,f=(n[0]-s)*p-(n[1]-l)*h;if(null!==i){if(Math.abs(f)>i)return!1}else if(0!==f)return!1;return r?"start"===r?Math.abs(h)>=Math.abs(p)?h>0?s<o&&o<=u:u<=o&&o<s:p>0?l<a&&a<=c:c<=a&&a<l:"end"===r?Math.abs(h)>=Math.abs(p)?h>0?s<=o&&o<u:u<o&&o<=s:p>0?l<=a&&a<c:c<a&&a<=l:"both"===r&&(Math.abs(h)>=Math.abs(p)?h>0?s<o&&o<u:u<o&&o<s:p>0?l<a&&a<c:c<a&&a<l):Math.abs(h)>=Math.abs(p)?h>0?s<=o&&o<=u:u<=o&&o<=s:p>0?l<=a&&a<=c:c<=a&&a<=l}function Dr(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;switch(i){case"Point":switch(o){case"MultiPoint":return function(t,e){var n,r=!1;for(n=0;n<e.coordinates.length;n++)if(Or(e.coordinates[n],t.coordinates)){r=!0;break}return r}(n,r);case"LineString":return Pr(n,r,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return fe(n,r,{ignoreBoundary:!0});default:throw new Error("feature2 "+o+" geometry not supported")}case"MultiPoint":switch(o){case"MultiPoint":return function(t,e){for(var n=0;n<t.coordinates.length;n++){for(var r=!1,i=0;i<e.coordinates.length;i++)Or(t.coordinates[n],e.coordinates[i])&&(r=!0);if(!r)return!1}return!0}(n,r);case"LineString":return function(t,e){for(var n=!1,r=0;r<t.coordinates.length;r++){if(!Pr(t.coordinates[r],e))return!1;n||(n=Pr(t.coordinates[r],e,{ignoreEndVertices:!0}))}return n}(n,r);case"Polygon":case"MultiPolygon":return function(t,e){for(var n=!0,r=!1,i=0;i<t.coordinates.length;i++){if(!(r=fe(t.coordinates[1],e))){n=!1;break}r=fe(t.coordinates[1],e,{ignoreBoundary:!0})}return n&&r}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"LineString":return function(t,e){for(var n=0;n<t.coordinates.length;n++)if(!Pr(t.coordinates[n],e))return!1;return!0}(n,r);case"Polygon":case"MultiPolygon":return function(t,e){if(!Nr(J(e),J(t)))return!1;for(var n=!1,r=0;r<t.coordinates.length-1;r++){if(!fe(t.coordinates[r],e))return!1;(n||(n=fe(t.coordinates[r],e,{ignoreBoundary:!0})),n)||(n=fe(kr(t.coordinates[r],t.coordinates[r+1]),e,{ignoreBoundary:!0}))}return n}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"Polygon":switch(o){case"Polygon":case"MultiPolygon":return function(t,e){var n=J(t);if(!Nr(J(e),n))return!1;for(var r=0;r<t.coordinates[0].length;r++)if(!fe(t.coordinates[0][r],e))return!1;return!0}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}default:throw new Error("feature1 "+i+" geometry not supported")}}function Nr(t,e){return!(t[0]>e[0]||t[2]<e[2]||t[1]>e[1]||t[3]<e[3])}function Or(t,e){return t[0]===e[0]&&t[1]===e[1]}function kr(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}function zr(t,e,n){void 0===n&&(n={}),n.mask&&!n.units&&(n.units="kilometers");for(var r=[],i=t[0],o=t[1],a=t[2],l=t[3],u=e/ge([i,o],[a,o],n)*(a-i),c=e/ge([i,o],[i,l],n)*(l-o),h=a-i,p=l-o,d=Math.floor(h/u),m=(p-Math.floor(p/c)*c)/2,g=i+(h-d*u)/2;g<=a;){for(var y=o+m;y<=l;){var v=s([g,y],n.properties);n.mask?Dr(v,n.mask)&&r.push(v):r.push(v),y+=c}g+=u}return f(r)}function Fr(t,e){void 0===e&&(e={});var n=e.precision,r=e.coordinates,i=e.mutate;if(n=null==n||isNaN(n)?6:n,r=null==r||isNaN(r)?3:r,!t)throw new Error("<geojson> is required");if("number"!=typeof n)throw new Error("<precision> must be a number");if("number"!=typeof r)throw new Error("<coordinates> must be a number");!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return R(t,(function(t){!function(t,e,n){t.length>n&&t.splice(n,t.length);for(var r=0;r<t.length;r++)t[r]=Math.round(t[r]*e)/e}(t,o,r)})),t}function Br(t){if(!t)throw new Error("geojson is required");var e=[];return V(t,(function(t){e.push(t)})),f(e)}function Ur(t,e){if(!t||!e)return!1;if(t.length!==e.length)return!1;for(var n=0,r=t.length;n<r;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!Ur(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0}function Vr(t){if("Feature"!=t.type)throw new Error("The input must a geojson object of type Feature");if(void 0===t.geometry||null==t.geometry)throw new Error("The input must a geojson object with a non-empty geometry");if("Polygon"!=t.geometry.type)throw new Error("The input must be a geojson Polygon");for(var e=t.geometry.coordinates.length,n=[],r=0;r<e;r++){var i=t.geometry.coordinates[r];Wr(i[0],i[i.length-1])||i.push(i[0]),n.push.apply(n,i.slice(0,i.length-1))}if(!function(t){for(var e={},n=1,r=0,i=t.length;r<i;++r){if(Object.prototype.hasOwnProperty.call(e,t[r])){n=0;break}e[t[r]]=1}return n}(n))throw new Error("The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)");var o=n.length,a=function(t,e,n){if("Polygon"!==t.geometry.type)throw new Error("The input feature must be a Polygon");void 0===n&&(n=1);var r=t.geometry.coordinates,i=[],o={};if(n){for(var a=[],s=0;s<r.length;s++)for(var l=0;l<r[s].length-1;l++)a.push(m(s,l));var u=Et();u.load(a)}for(var c=0;c<r.length;c++)for(var h=0;h<r[c].length-1;h++)if(n)u.search(m(c,h)).forEach((function(t){var e=t.ring,n=t.edge;d(c,h,e,n)}));else for(var p=0;p<r.length;p++)for(var f=0;f<r[p].length-1;f++)d(c,h,p,f);return e||(i={type:"Feature",geometry:{type:"MultiPoint",coordinates:i}}),i;function d(t,n,a,s){var l,u,c=r[t][n],h=r[t][n+1],p=r[a][s],f=r[a][s+1],d=function(t,e,n,r){if(Ur(t,n)||Ur(t,r)||Ur(e,n)||Ur(r,n))return null;var i=t[0],o=t[1],a=e[0],s=e[1],l=n[0],u=n[1],c=r[0],h=r[1],p=(i-a)*(u-h)-(o-s)*(l-c);return 0===p?null:[((i*s-o*a)*(l-c)-(i-a)*(l*h-u*c))/p,((i*s-o*a)*(u-h)-(o-s)*(l*h-u*c))/p]}(c,h,p,f);if(null!==d&&(l=h[0]!==c[0]?(d[0]-c[0])/(h[0]-c[0]):(d[1]-c[1])/(h[1]-c[1]),u=f[0]!==p[0]?(d[0]-p[0])/(f[0]-p[0]):(d[1]-p[1])/(f[1]-p[1]),!(l>=1||l<=0||u>=1||u<=0))){var m=d,g=!o[m];g&&(o[m]=!0),e?i.push(e(d,t,n,c,h,l,a,s,p,f,u,g)):i.push(d)}}function m(t,e){var n,i,o,a,s=r[t][e],l=r[t][e+1];return s[0]<l[0]?(n=s[0],i=l[0]):(n=l[0],i=s[0]),s[1]<l[1]?(o=s[1],a=l[1]):(o=l[1],a=s[1]),{minX:n,minY:o,maxX:i,maxY:a,ring:t,edge:e}}}(t,(function(t,e,n,r,i,o,a,s,l,u,c,h){return[t,e,n,r,i,o,a,s,l,u,c,h]})),s=a.length;if(0==s){var l=[];for(r=0;r<e;r++)l.push(u([t.geometry.coordinates[r]],{parent:-1,winding:qr(t.geometry.coordinates[r])}));var c=f(l);return F(),B(),c}var h=[],p=[];for(r=0;r<e;r++){h.push([]);for(var d=0;d<t.geometry.coordinates[r].length-1;d++)h[r].push([new Gr(t.geometry.coordinates[r][Xr(d+1,t.geometry.coordinates[r].length-1)],1,[r,d],[r,Xr(d+1,t.geometry.coordinates[r].length-1)],void 0)]),p.push(new jr(t.geometry.coordinates[r][d],[r,Xr(d-1,t.geometry.coordinates[r].length-1)],[r,d],void 0,void 0,!1,!0))}for(r=0;r<s;r++)h[a[r][1]][a[r][2]].push(new Gr(a[r][0],a[r][5],[a[r][1],a[r][2]],[a[r][6],a[r][7]],void 0)),a[r][11]&&p.push(new jr(a[r][0],[a[r][1],a[r][2]],[a[r][6],a[r][7]],void 0,void 0,!0,!0));var m=p.length;for(r=0;r<h.length;r++)for(d=0;d<h[r].length;d++)h[r][d].sort((function(t,e){return t.param<e.param?-1:1}));var g=[];for(r=0;r<m;r++)g.push({minX:p[r].coord[0],minY:p[r].coord[1],maxX:p[r].coord[0],maxY:p[r].coord[1],index:r});var y=Et();y.load(g);for(r=0;r<h.length;r++)for(d=0;d<h[r].length;d++)for(var v=0;v<h[r][d].length;v++){x=v==h[r][d].length-1?h[r][Xr(d+1,t.geometry.coordinates[r].length-1)][0].coord:h[r][d][v+1].coord;var _=y.search({minX:x[0],minY:x[1],maxX:x[0],maxY:x[1]})[0];h[r][d][v].nxtIsectAlongEdgeIn=_.index}for(r=0;r<h.length;r++)for(d=0;d<h[r].length;d++)for(v=0;v<h[r][d].length;v++){var x=h[r][d][v].coord,b=(_=y.search({minX:x[0],minY:x[1],maxX:x[0],maxY:x[1]})[0]).index;b<o?p[b].nxtIsectAlongRingAndEdge2=h[r][d][v].nxtIsectAlongEdgeIn:Wr(p[b].ringAndEdge1,h[r][d][v].ringAndEdgeIn)?p[b].nxtIsectAlongRingAndEdge1=h[r][d][v].nxtIsectAlongEdgeIn:p[b].nxtIsectAlongRingAndEdge2=h[r][d][v].nxtIsectAlongEdgeIn}var w=[];for(r=0,d=0;d<e;d++){var E=r;for(v=0;v<t.geometry.coordinates[d].length-1;v++)p[r].coord[0]<p[E].coord[0]&&(E=r),r++;var S=p[E].nxtIsectAlongRingAndEdge2;for(v=0;v<p.length;v++)if(p[v].nxtIsectAlongRingAndEdge1==E||p[v].nxtIsectAlongRingAndEdge2==E){var M=v;break}var T=Hr([p[M].coord,p[E].coord,p[S].coord],!0)?1:-1;w.push({isect:E,parent:-1,winding:T})}w.sort((function(t,e){return p[t.isect].coord>p[e.isect].coord?-1:1}));for(l=[];w.length>0;){var C=w.pop(),I=C.isect,A=C.parent,L=C.winding,P=l.length,R=[p[I].coord],D=I;if(p[I].ringAndEdge1Walkable)var N=p[I].ringAndEdge1,O=p[I].nxtIsectAlongRingAndEdge1;else N=p[I].ringAndEdge2,O=p[I].nxtIsectAlongRingAndEdge2;for(;!Wr(p[I].coord,p[O].coord);){R.push(p[O].coord);var k=void 0;for(r=0;r<w.length;r++)if(w[r].isect==O){k=r;break}if(null!=k&&w.splice(k,1),Wr(N,p[O].ringAndEdge1)){if(N=p[O].ringAndEdge2,p[O].ringAndEdge2Walkable=!1,p[O].ringAndEdge1Walkable){var z={isect:O};Hr([p[D].coord,p[O].coord,p[p[O].nxtIsectAlongRingAndEdge2].coord],1==L)?(z.parent=A,z.winding=-L):(z.parent=P,z.winding=L),w.push(z)}D=O,O=p[O].nxtIsectAlongRingAndEdge2}else{if(N=p[O].ringAndEdge1,p[O].ringAndEdge1Walkable=!1,p[O].ringAndEdge2Walkable){z={isect:O};Hr([p[D].coord,p[O].coord,p[p[O].nxtIsectAlongRingAndEdge1].coord],1==L)?(z.parent=A,z.winding=-L):(z.parent=P,z.winding=L),w.push(z)}D=O,O=p[O].nxtIsectAlongRingAndEdge1}}R.push(p[O].coord),l.push(u([R],{index:P,parent:A,winding:L,netWinding:void 0}))}c=f(l);function F(){for(var t=[],e=0;e<c.features.length;e++)-1==c.features[e].properties.parent&&t.push(e);if(t.length>1)for(e=0;e<t.length;e++){for(var n=-1,r=0;r<c.features.length;r++)t[e]!=r&&fe(c.features[t[e]].geometry.coordinates[0][0],c.features[r],{ignoreBoundary:!0})&&Mr(c.features[r])<1/0&&(n=r);c.features[t[e]].properties.parent=n}}function B(){for(var t=0;t<c.features.length;t++)if(-1==c.features[t].properties.parent){var e=c.features[t].properties.winding;c.features[t].properties.netWinding=e,U(t,e)}}function U(t,e){for(var n=0;n<c.features.length;n++)if(c.features[n].properties.parent==t){var r=e+c.features[n].properties.winding;c.features[n].properties.netWinding=r,U(n,r)}}return F(),B(),c}var Gr=function(t,e,n,r,i){this.coord=t,this.param=e,this.ringAndEdgeIn=n,this.ringAndEdgeOut=r,this.nxtIsectAlongEdgeIn=i},jr=function(t,e,n,r,i,o,a){this.coord=t,this.ringAndEdge1=e,this.ringAndEdge2=n,this.nxtIsectAlongRingAndEdge1=r,this.nxtIsectAlongRingAndEdge2=i,this.ringAndEdge1Walkable=o,this.ringAndEdge2Walkable=a};function Hr(t,e){if(void 0===e&&(e=!0),3!=t.length)throw new Error("This function requires an array of three points [x,y]");return(t[1][0]-t[0][0])*(t[2][1]-t[0][1])-(t[1][1]-t[0][1])*(t[2][0]-t[0][0])>=0==e}function qr(t){for(var e=0,n=0;n<t.length-1;n++)t[n][0]<t[e][0]&&(e=n);if(Hr([t[Xr(e-1,t.length-1)],t[e],t[Xr(e+1,t.length-1)]],!0))var r=1;else r=-1;return r}function Wr(t,e){if(!t||!e)return!1;if(t.length!=e.length)return!1;for(var n=0,r=t.length;n<r;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!Wr(t[n],e[n]))return!1}else if(t[n]!=e[n])return!1;return!0}function Xr(t,e){return(t%e+e)%e}var Zr=Math.PI/180,Yr=180/Math.PI,Jr=function(t,e){this.lon=t,this.lat=e,this.x=Zr*t,this.y=Zr*e};Jr.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)},Jr.prototype.antipode=function(){var t=-1*this.lat,e=this.lon<0?180+this.lon:-1*(180-this.lon);return new Jr(e,t)};var Kr=function(){this.coords=[],this.length=0};Kr.prototype.move_to=function(t){this.length++,this.coords.push(t)};var Qr=function(t){this.properties=t||{},this.geometries=[]};Qr.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(1===this.geometries.length)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var t=[],e=0;e<this.geometries.length;e++)t.push(this.geometries[e].coords);return{geometry:{type:"MultiLineString",coordinates:t},type:"Feature",properties:this.properties}},Qr.prototype.wkt=function(){for(var t="",e="LINESTRING(",n=function(t){e+=t[0]+" "+t[1]+","},r=0;r<this.geometries.length;r++){if(0===this.geometries[r].coords.length)return"LINESTRING(empty)";this.geometries[r].coords.forEach(n),t+=e.substring(0,e.length-1)+")"}return t};var $r=function(t,e,n){if(!t||void 0===t.x||void 0===t.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||void 0===e.x||void 0===e.y)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new Jr(t.x,t.y),this.end=new Jr(e.x,e.y),this.properties=n||{};var r=this.start.x-this.end.x,i=this.start.y-this.end.y,o=Math.pow(Math.sin(i/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(r/2),2);if(this.g=2*Math.asin(Math.sqrt(o)),this.g===Math.PI)throw new Error("it appears "+t.view()+" and "+e.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)};function ti(t,e){var n=[],r=pr();return V(e,(function(e){if(n.forEach((function(t,e){t.id=e})),n.length){var i=r.search(e);if(i.features.length){var o=ni(e,i);n=n.filter((function(t){return t.id!==o.id})),r.remove(o),k(ei(o,e),(function(t){n.push(t),r.insert(t)}))}}else(n=ei(t,e).features).forEach((function(t){t.bbox||(t.bbox=un(J(t)))})),r.load(f(n))})),f(n)}function ei(t,e){var n=[],r=Q(t)[0],i=Q(t)[t.geometry.coordinates.length-1];if(ri(r,K(e))||ri(i,K(e)))return f([t]);var o=pr(),a=jn(t);o.load(a);var s=o.search(e);if(!s.features.length)return f([t]);var l=ni(e,s),u=z(a,(function(t,r,i){var o=Q(r)[1],a=K(e);return i===l.id?(t.push(a),n.push(h(t)),ri(a,o)?[a]:[a,o]):(t.push(o),t)}),[r]);return u.length>1&&n.push(h(u)),f(n)}function ni(t,e){if(!e.features.length)throw new Error("lines must contain features");if(1===e.features.length)return e.features[0];var n,r=1/0;return k(e,(function(e){var i=gr(e,t).properties.dist;i<r&&(n=e,r=i)})),n}function ri(t,e){return t[0]===e[0]&&t[1]===e[1]}function ii(t,e,n,r,i){void 0===i&&(i={});var o=i.steps||64,a=oi(n),s=oi(r),l=Array.isArray(t)||"Feature"!==t.type?{}:t.properties;if(a===s)return h(hn(t,e,i).geometry.coordinates[0],l);for(var u=a,c=a<s?s:s+360,p=u,f=[],d=0;p<c;)f.push(cn(t,e,p,i).geometry.coordinates),p=u+360*++d/o;return p>c&&f.push(cn(t,e,c,i).geometry.coordinates),h(f,l)}function oi(t){var e=t%360;return e<0&&(e+=360),e}function ai(t,e){void 0===e&&(e={});var n=rt(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return si(n,e);case"MultiPolygon":return function(t,e){void 0===e&&(e={});var n=rt(t).coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{},i=[];return n.forEach((function(t){i.push(li(t,r))})),f(i)}(n,e);default:throw new Error("invalid poly")}}function si(t,e){return void 0===e&&(e={}),li(rt(t).coordinates,e.properties?e.properties:"Feature"===t.type?t.properties:{})}function li(t,e){return t.length>1?d(t,e):h(t[0],e)}function ui(t,e){var n,r,i;void 0===e&&(e={});var o=e.properties,a=null===(n=e.autoComplete)||void 0===n||n,s=null===(r=e.orderCoords)||void 0===r||r;if("FeatureCollection"===(null!==(i=e.mutate)&&void 0!==i&&i||(t=be(t)),t.type)){var l=[];return t.features.forEach((function(t){l.push(Q(ci(t,{},a,s)))})),g(l,o)}return ci(t,o,a,s)}function ci(t,e,n,r){e=e||("Feature"===t.type?t.properties:{});var i=rt(t),o=i.coordinates,a=i.type;if(!o.length)throw new Error("line must contain coordinates");switch(a){case"LineString":return n&&(o=hi(o)),u([o],e);case"MultiLineString":var s=[],l=0;return o.forEach((function(t){if(n&&(t=hi(t)),r){var e=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.abs(e-r)*Math.abs(n-i)}(J(h(t)));e>l?(s.unshift(t),l=e):s.push(t)}else s.push(t)})),u(s,e);default:throw new Error("geometry type "+a+" is not supported")}}function hi(t){var e=t[0],n=e[0],r=e[1],i=t[t.length-1],o=i[0],a=i[1];return n===o&&r===a||t.push(e),t}function pi(t,e){var n,r,i,o,a,s,l;for(r=1;r<=8;r*=2){for(n=[],o=!(di(i=t[t.length-1],e)&r),a=0;a<t.length;a++)(l=!(di(s=t[a],e)&r))!==o&&n.push(fi(i,s,r,e)),l&&n.push(s),i=s,o=l;if(!(t=n).length)break}return n}function fi(t,e,n,r){return 8&n?[t[0]+(e[0]-t[0])*(r[3]-t[1])/(e[1]-t[1]),r[3]]:4&n?[t[0]+(e[0]-t[0])*(r[1]-t[1])/(e[1]-t[1]),r[1]]:2&n?[r[2],t[1]+(e[1]-t[1])*(r[2]-t[0])/(e[0]-t[0])]:1&n?[r[0],t[1]+(e[1]-t[1])*(r[0]-t[0])/(e[0]-t[0])]:null}function di(t,e){var n=0;return t[0]<e[0]?n|=1:t[0]>e[2]&&(n|=2),t[1]<e[1]?n|=4:t[1]>e[3]&&(n|=8),n}function mi(t,e){for(var n=[],r=0,i=t;r<i.length;r++){var o=pi(i[r],e);o.length>0&&(o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]||o.push(o[0]),o.length>=4&&n.push(o))}return n}$r.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),n=Math.sin(t*this.g)/Math.sin(this.g),r=e*Math.cos(this.start.y)*Math.cos(this.start.x)+n*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+n*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+n*Math.sin(this.end.y),a=Yr*Math.atan2(o,Math.sqrt(Math.pow(r,2)+Math.pow(i,2)));return[Yr*Math.atan2(i,r),a]},$r.prototype.Arc=function(t,e){var n=[];if(!t||t<=2)n.push([this.start.lon,this.start.lat]),n.push([this.end.lon,this.end.lat]);else for(var r=1/(t-1),i=0;i<t;++i){var o=r*i,a=this.interpolate(o);n.push(a)}for(var s=!1,l=0,u=e&&e.offset?e.offset:10,c=180-u,h=-180+u,p=360-u,f=1;f<n.length;++f){var d=n[f-1][0],m=n[f][0],g=Math.abs(m-d);g>p&&(m>c&&d<h||d>c&&m<h)?s=!0:g>l&&(l=g)}var y=[];if(s&&l<u){var v=[];y.push(v);for(var _=0;_<n.length;++_){var x=parseFloat(n[_][0]);if(_>0&&Math.abs(x-n[_-1][0])>p){var b=parseFloat(n[_-1][0]),w=parseFloat(n[_-1][1]),E=parseFloat(n[_][0]),S=parseFloat(n[_][1]);if(b>-180&&b<h&&180===E&&_+1<n.length&&n[_-1][0]>-180&&n[_-1][0]<h){v.push([-180,n[_][1]]),_++,v.push([n[_][0],n[_][1]]);continue}if(b>c&&b<180&&-180===E&&_+1<n.length&&n[_-1][0]>c&&n[_-1][0]<180){v.push([180,n[_][1]]),_++,v.push([n[_][0],n[_][1]]);continue}if(b<h&&E>c){var M=b;b=E,E=M;var T=w;w=S,S=T}if(b>c&&E<h&&(E+=360),b<=180&&E>=180&&b<E){var C=(180-b)/(E-b),I=C*S+(1-C)*w;v.push([n[_-1][0]>c?180:-180,I]),(v=[]).push([n[_-1][0]>c?-180:180,I]),y.push(v)}else v=[],y.push(v);v.push([x,n[_][1]])}else v.push([n[_][0],n[_][1]])}}else{var A=[];y.push(A);for(var L=0;L<n.length;++L)A.push([n[L][0],n[L][1]])}for(var P=new Qr(this.properties),R=0;R<y.length;++R){var D=new Kr;P.geometries.push(D);for(var N=y[R],O=0;O<N.length;++O)D.move_to(N[O])}return P};var gi=Ft((function(t,e){function n(t){var e=[];for(var n in t)e.push(n);return e}(t.exports="function"==typeof Object.keys?Object.keys:n).shim=n})),yi=Ft((function(t,e){var n="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();function r(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function i(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}(e=t.exports=n?r:i).supported=r,e.unsupported=i})),vi=Ft((function(t){var e=Array.prototype.slice,n=t.exports=function(t,o,a){return a||(a={}),t===o||(t instanceof Date&&o instanceof Date?t.getTime()===o.getTime():!t||!o||"object"!=typeof t&&"object"!=typeof o?a.strict?t===o:t==o:function(t,o,a){var s,l;if(r(t)||r(o))return!1;if(t.prototype!==o.prototype)return!1;if(yi(t))return!!yi(o)&&(t=e.call(t),o=e.call(o),n(t,o,a));if(i(t)){if(!i(o))return!1;if(t.length!==o.length)return!1;for(s=0;s<t.length;s++)if(t[s]!==o[s])return!1;return!0}try{var u=gi(t),c=gi(o)}catch(t){return!1}if(u.length!=c.length)return!1;for(u.sort(),c.sort(),s=u.length-1;s>=0;s--)if(u[s]!=c[s])return!1;for(s=u.length-1;s>=0;s--)if(l=u[s],!n(t[l],o[l],a))return!1;return typeof t==typeof o}(t,o,a))};function r(t){return null==t}function i(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length||"function"!=typeof t.copy||"function"!=typeof t.slice||t.length>0&&"number"!=typeof t[0])}}));function _i(t,e,n){if(void 0===n&&(n={}),!I(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],a=pr(),s=jn(t);return a.load(s),j(e,(function(t){var e=!1;t&&(k(a.search(t),(function(n){if(!1===e){var o=Q(t).sort(),a=Q(n).sort();vi(o,a)||(0===i?Pr(o[0],n)&&Pr(o[1],n):gr(n,o[0]).properties.dist<=i&&gr(n,o[1]).properties.dist<=i)?(e=!0,r=r?xi(r,t):t):(0===i?Pr(a[0],t)&&Pr(a[1],t):gr(t,a[0]).properties.dist<=i&&gr(t,a[1]).properties.dist<=i)&&(r=r?xi(r,n):n)}})),!1===e&&r&&(o.push(r),r=void 0))})),r&&o.push(r),f(o)}function xi(t,e){var n=Q(e),r=Q(t),i=r[0],o=r[r.length-1],a=t.geometry.coordinates;return vi(n[0],i)?a.unshift(n[1]):vi(n[0],o)?a.push(n[1]):vi(n[1],i)?a.unshift(n[0]):vi(n[1],o)&&a.push(n[0]),t}function bi(t){var e=t%360;return e<0&&(e+=360),e}function wi(t,e,n){var r;return void 0===n&&(n={}),(r=n.final?Ei(K(e),K(t)):Ei(K(t),K(e)))>180?-(360-r):r}function Ei(t,e){var n=S(t[1]),r=S(e[1]),i=S(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(E(Math.atan2(i,o))+360)%360}function Si(t,n,r,i){void 0===i&&(i={});var o=n<0,a=M(Math.abs(n),i.units,"meters");o&&(a=-Math.abs(a));var l=K(t),u=function(t,n,r,i){var o=n/(i=void 0===i?e:Number(i)),a=t[0]*Math.PI/180,s=S(t[1]),l=S(r),u=o*Math.cos(l),c=s+u;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),p=Math.abs(h)>1e-11?u/h:Math.cos(s);return[(180*(a+o*Math.sin(l)/p)/Math.PI+540)%360-180,180*c/Math.PI]}(l,a,r);return u[0]+=u[0]-l[0]>180?-360:l[0]-u[0]>180?360:0,s(u,i.properties)}function Mi(t,e,n,r,i,o){for(var a=0;a<t.length;a++){var s=t[a],l=t[a+1];a===t.length-1&&(l=t[0]),r=Ci(s,l,e),n<=0&&r>0?Ci(e,s,i)<0||(i=s):n>0&&r<=0&&(Ti(e,s,o)||(o=s)),n=r}return[i,o]}function Ti(t,e,n){return Ci(t,e,n)>0}function Ci(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function Ii(t){for(var e,n,r=Q(t),i=0,o=1;o<r.length;)e=n||r[0],i+=((n=r[o])[0]-e[0])*(n[1]+e[1]),o++;return i>0}function Ai(t,e){switch("Feature"===t.type?t.geometry.type:t.type){case"GeometryCollection":return B(t,(function(t){Ai(t,e)})),t;case"LineString":return Li(Q(t),e),t;case"Polygon":return Pi(Q(t),e),t;case"MultiLineString":return Q(t).forEach((function(t){Li(t,e)})),t;case"MultiPolygon":return Q(t).forEach((function(t){Pi(t,e)})),t;case"Point":case"MultiPoint":return t}}function Li(t,e){Ii(t)===e&&t.reverse()}function Pi(t,e){Ii(t[0])!==e&&t[0].reverse();for(var n=1;n<t.length;n++)Ii(t[n])===e&&t[n].reverse()}var Ri={successCallback:null,verbose:!1,polygons:!1},Di={};function Ni(t,e,n,r){r=r||{};for(var i=Object.keys(Ri),o=0;o<i.length;o++){var a=i[o],s=r[a];s=null!=s?s:Ri[a],Di[a]=s}Di.verbose&&console.log("MarchingSquaresJS-isoBands: computing isobands for ["+e+":"+(e+n)+"]");var l,u=function(t,e,n){for(var r=t.length-1,i=t[0].length-1,o={rows:r,cols:i,cells:[]},a=e+Math.abs(n),s=0;s<r;++s){o.cells[s]=[];for(var l=0;l<i;++l){var u=0,c=t[s+1][l],h=t[s+1][l+1],p=t[s][l+1],f=t[s][l];if(!(isNaN(c)||isNaN(h)||isNaN(p)||isNaN(f))){u|=c<e?0:c>a?128:64,u|=h<e?0:h>a?32:16,u|=p<e?0:p>a?8:4;var d=+(u|=f<e?0:f>a?2:1),m=0;if(17===u||18===u||33===u||34===u||38===u||68===u||72===u||98===u||102===u||132===u||136===u||137===u||152===u||153===u){var g=(c+h+p+f)/4;m=g>a?2:g<e?0:1,34===u?1===m?u=35:0===m&&(u=136):136===u?1===m?(u=35,m=4):0===m&&(u=34):17===u?1===m?(u=155,m=4):0===m&&(u=153):68===u?1===m?(u=103,m=4):0===m&&(u=102):153===u?1===m&&(u=155):102===u?1===m&&(u=103):152===u?m<2&&(u=156,m=1):137===u?m<2&&(u=139,m=1):98===u?m<2&&(u=99,m=1):38===u?m<2&&(u=39,m=1):18===u?m>0?(u=156,m=4):u=152:33===u?m>0?(u=139,m=4):u=137:72===u?m>0?(u=99,m=4):u=98:132===u&&(m>0?(u=39,m=4):u=38)}if(0!=u&&170!=u){var y,v,_,x,b,w,E,S;y=v=_=x=b=w=E=S=.5;var M=[];1===u?(_=1-Mo(e,p,f),S=1-Mo(e,c,f),M.push(_o[u])):169===u?(_=Mo(a,f,p),S=Mo(a,f,c),M.push(_o[u])):4===u?(w=1-Mo(e,h,p),x=Mo(e,f,p),M.push(yo[u])):166===u?(w=Mo(a,p,h),x=1-Mo(a,p,f),M.push(yo[u])):16===u?(b=Mo(e,p,h),v=Mo(e,c,h),M.push(go[u])):154===u?(b=1-Mo(a,h,p),v=1-Mo(a,h,c),M.push(go[u])):64===u?(E=Mo(e,f,c),y=1-Mo(e,h,c),M.push(bo[u])):106===u?(E=1-Mo(a,c,f),y=Mo(a,c,h),M.push(bo[u])):168===u?(x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),M.push(vo[u]),M.push(_o[u])):2===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(vo[u]),M.push(_o[u])):162===u?(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),M.push(vo[u]),M.push(_o[u])):8===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),M.push(go[u]),M.push(yo[u])):138===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):32===u?(b=Mo(a,p,h),w=Mo(e,p,h),y=Mo(e,c,h),v=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):42===u?(S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(xo[u]),M.push(bo[u])):128===u&&(S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(xo[u]),M.push(bo[u])),5===u?(w=1-Mo(e,h,p),S=1-Mo(e,c,f),M.push(yo[u])):165===u?(w=Mo(a,p,h),S=Mo(a,f,c),M.push(yo[u])):20===u?(x=Mo(e,f,p),v=Mo(e,c,h),M.push(vo[u])):150===u?(x=1-Mo(a,p,f),v=1-Mo(a,h,c),M.push(vo[u])):80===u?(b=Mo(e,p,h),E=Mo(e,f,c),M.push(go[u])):90===u?(b=1-Mo(a,h,p),E=1-Mo(a,c,f),M.push(go[u])):65===u?(_=1-Mo(e,p,f),y=1-Mo(e,h,c),M.push(_o[u])):105===u?(_=Mo(a,f,p),y=Mo(a,c,h),M.push(_o[u])):160===u?(b=Mo(a,p,h),w=Mo(e,p,h),S=Mo(e,f,c),E=Mo(a,f,c),M.push(go[u]),M.push(yo[u])):10===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(go[u]),M.push(yo[u])):130===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(vo[u]),M.push(_o[u])):40===u?(x=Mo(a,f,p),_=Mo(e,f,p),y=Mo(e,c,h),v=Mo(a,c,h),M.push(vo[u]),M.push(_o[u])):101===u?(w=Mo(a,p,h),y=Mo(a,c,h),M.push(yo[u])):69===u?(w=1-Mo(e,h,p),y=1-Mo(e,h,c),M.push(yo[u])):149===u?(S=Mo(a,f,c),v=1-Mo(a,h,c),M.push(xo[u])):21===u?(S=1-Mo(e,c,f),v=Mo(e,c,h),M.push(xo[u])):86===u?(x=1-Mo(a,p,f),E=1-Mo(a,c,f),M.push(vo[u])):84===u?(x=Mo(e,f,p),E=Mo(e,f,c),M.push(vo[u])):89===u?(b=1-Mo(a,h,p),_=Mo(a,f,p),M.push(_o[u])):81===u?(b=Mo(e,p,h),_=1-Mo(e,p,f),M.push(_o[u])):96===u?(b=Mo(a,p,h),w=Mo(e,p,h),E=Mo(e,f,c),y=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):74===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):24===u?(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),v=Mo(e,c,h),M.push(go[u]),M.push(_o[u])):146===u?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),v=1-Mo(a,h,c),M.push(go[u]),M.push(_o[u])):6===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(yo[u]),M.push(vo[u])):164===u?(w=Mo(a,p,h),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),M.push(yo[u]),M.push(vo[u])):129===u?(_=1-Mo(e,p,f),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(_o[u]),M.push(xo[u])):41===u?(_=Mo(a,f,p),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(_o[u]),M.push(xo[u])):66===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(vo[u]),M.push(_o[u])):104===u?(x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=Mo(a,c,h),M.push(_o[u]),M.push(wo[u])):144===u?(b=Mo(e,p,h),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c),M.push(go[u]),M.push(bo[u])):26===u?(b=1-Mo(a,h,p),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h),M.push(go[u]),M.push(bo[u])):36===u?(w=Mo(a,p,h),x=Mo(e,f,p),y=Mo(e,c,h),v=Mo(a,c,h),M.push(yo[u]),M.push(vo[u])):134===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(yo[u]),M.push(vo[u])):9===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=1-Mo(e,c,f),M.push(go[u]),M.push(yo[u])):161===u?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=Mo(a,f,c),M.push(go[u]),M.push(yo[u])):37===u?(w=Mo(a,p,h),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(yo[u]),M.push(xo[u])):133===u?(w=1-Mo(e,h,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(yo[u]),M.push(xo[u])):148===u?(x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c),M.push(vo[u]),M.push(bo[u])):22===u?(x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h),M.push(vo[u]),M.push(bo[u])):82===u?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),M.push(go[u]),M.push(_o[u])):88===u?(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),M.push(go[u]),M.push(_o[u])):73===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),y=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):97===u?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),y=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):145===u?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=Mo(a,f,c),v=1-Mo(a,h,c),M.push(go[u]),M.push(xo[u])):25===u?(b=1-Mo(a,h,p),_=Mo(a,f,p),S=1-Mo(e,c,f),v=Mo(e,c,h),M.push(go[u]),M.push(xo[u])):70===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(yo[u]),M.push(vo[u])):100===u?(w=Mo(a,p,h),x=Mo(e,f,p),E=Mo(e,f,c),y=Mo(a,c,h),M.push(yo[u]),M.push(vo[u])):34===u?(0===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):35===u?(4===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(_o[u]),M.push(bo[u])):136===u?(0===m?(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):153===u?(0===m?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(_o[u])):102===u?(0===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(yo[u]),M.push(bo[u])):155===u?(4===m?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(xo[u])):103===u?(4===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(yo[u]),M.push(vo[u])):152===u?(0===m?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(vo[u]),M.push(_o[u])):156===u?(4===m?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(_o[u]),M.push(bo[u])):137===u?(0===m?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(_o[u])):139===u?(4===m?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(xo[u])):98===u?(0===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(bo[u])):99===u?(4===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(_o[u])):38===u?(0===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):39===u?(4===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(yo[u]),M.push(vo[u]),M.push(bo[u])):85===u&&(b=1,w=0,x=1,_=0,S=0,E=1,y=0,v=1),(y<0||y>1||v<0||v>1||b<0||b>1||x<0||x>1||S<0||S>1||E<0||E>1)&&console.log("MarchingSquaresJS-isoBands: "+u+" "+d+" "+c+","+h+","+p+","+f+" "+m+" "+y+" "+v+" "+b+" "+w+" "+x+" "+_+" "+S+" "+E),o.cells[s][l]={cval:u,cval_real:d,flipped:m,topleft:y,topright:v,righttop:b,rightbottom:w,bottomright:x,bottomleft:_,leftbottom:S,lefttop:E,edges:M}}}}}return o}(t,e,n);return Di.polygons?(Di.verbose&&console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"),l=function(t){var e=[],n=0;return t.cells.forEach((function(t,r){t.forEach((function(t,i){if(void 0!==t){var o=So[t.cval](t);"object"==typeof o&&To(o)?"object"==typeof o[0]&&To(o[0])?"object"==typeof o[0][0]&&To(o[0][0])?o.forEach((function(t){t.forEach((function(t){t[0]+=i,t[1]+=r})),e[n++]=t})):(o.forEach((function(t){t[0]+=i,t[1]+=r})),e[n++]=o):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates")}}))})),e}(u)):(Di.verbose&&console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),l=function(t){for(var e=[],n=t.rows,r=t.cols,i=[],o=0;o<n;o++)for(var a=0;a<r;a++)if(void 0!==t.cells[o][a]&&t.cells[o][a].edges.length>0){var s=Io(t.cells[o][a]),l=null,u=a,c=o;null!==s&&i.push([s.p[0]+u,s.p[1]+c]);do{if(null===(l=Ao(t.cells[c][u],s.x,s.y,s.o)))break;if(i.push([l.p[0]+u,l.p[1]+c]),u+=l.x,s=l,(c+=l.y)<0||c>=n||u<0||u>=r||void 0===t.cells[c][u]){var h=Co(t,u-=l.x,c-=l.y,l.x,l.y,l.o);if(null===h)break;h.path.forEach((function(t){i.push(t)})),u=h.i,c=h.j,s=h}}while(void 0!==t.cells[c][u]&&t.cells[c][u].edges.length>0);e.push(i),i=[],t.cells[o][a].edges.length>0&&a--}return e}(u)),"function"==typeof Di.successCallback&&Di.successCallback(l),l}var Oi=64,ki=16,zi=[],Fi=[],Bi=[],Ui=[],Vi=[],Gi=[],ji=[],Hi=[],qi=[],Wi=[],Xi=[],Zi=[],Yi=[],Ji=[],Ki=[],Qi=[],$i=[],to=[],eo=[],no=[],ro=[],io=[],oo=[],ao=[];ji[85]=Wi[85]=-1,Hi[85]=Xi[85]=0,qi[85]=Zi[85]=1,eo[85]=io[85]=1,no[85]=oo[85]=0,ro[85]=ao[85]=1,zi[85]=Ui[85]=0,Fi[85]=Vi[85]=-1,Bi[85]=Ki[85]=0,Qi[85]=Yi[85]=0,$i[85]=Ji[85]=1,Gi[85]=to[85]=1,io[1]=io[169]=0,oo[1]=oo[169]=-1,ao[1]=ao[169]=0,Yi[1]=Yi[169]=-1,Ji[1]=Ji[169]=0,Ki[1]=Ki[169]=0,Wi[4]=Wi[166]=0,Xi[4]=Xi[166]=-1,Zi[4]=Zi[166]=1,Qi[4]=Qi[166]=1,$i[4]=$i[166]=0,to[4]=to[166]=0,ji[16]=ji[154]=0,Hi[16]=Hi[154]=1,qi[16]=qi[154]=1,Ui[16]=Ui[154]=1,Vi[16]=Vi[154]=0,Gi[16]=Gi[154]=1,eo[64]=eo[106]=0,no[64]=no[106]=1,ro[64]=ro[106]=0,zi[64]=zi[106]=-1,Fi[64]=Fi[106]=0,Bi[64]=Bi[106]=1,eo[2]=eo[168]=0,no[2]=no[168]=-1,ro[2]=ro[168]=1,io[2]=io[168]=0,oo[2]=oo[168]=-1,ao[2]=ao[168]=0,Yi[2]=Yi[168]=-1,Ji[2]=Ji[168]=0,Ki[2]=Ki[168]=0,Qi[2]=Qi[168]=-1,$i[2]=$i[168]=0,to[2]=to[168]=1,ji[8]=ji[162]=0,Hi[8]=Hi[162]=-1,qi[8]=qi[162]=0,Wi[8]=Wi[162]=0,Xi[8]=Xi[162]=-1,Zi[8]=Zi[162]=1,Yi[8]=Yi[162]=1,Ji[8]=Ji[162]=0,Ki[8]=Ki[162]=1,Qi[8]=Qi[162]=1,$i[8]=$i[162]=0,to[8]=to[162]=0,ji[32]=ji[138]=0,Hi[32]=Hi[138]=1,qi[32]=qi[138]=1,Wi[32]=Wi[138]=0,Xi[32]=Xi[138]=1,Zi[32]=Zi[138]=0,zi[32]=zi[138]=1,Fi[32]=Fi[138]=0,Bi[32]=Bi[138]=0,Ui[32]=Ui[138]=1,Vi[32]=Vi[138]=0,Gi[32]=Gi[138]=1,io[128]=io[42]=0,oo[128]=oo[42]=1,ao[128]=ao[42]=1,eo[128]=eo[42]=0,no[128]=no[42]=1,ro[128]=ro[42]=0,zi[128]=zi[42]=-1,Fi[128]=Fi[42]=0,Bi[128]=Bi[42]=1,Ui[128]=Ui[42]=-1,Vi[128]=Vi[42]=0,Gi[128]=Gi[42]=0,Wi[5]=Wi[165]=-1,Xi[5]=Xi[165]=0,Zi[5]=Zi[165]=0,io[5]=io[165]=1,oo[5]=oo[165]=0,ao[5]=ao[165]=0,Qi[20]=Qi[150]=0,$i[20]=$i[150]=1,to[20]=to[150]=1,Ui[20]=Ui[150]=0,Vi[20]=Vi[150]=-1,Gi[20]=Gi[150]=1,ji[80]=ji[90]=-1,Hi[80]=Hi[90]=0,qi[80]=qi[90]=1,eo[80]=eo[90]=1,no[80]=no[90]=0,ro[80]=ro[90]=1,Yi[65]=Yi[105]=0,Ji[65]=Ji[105]=1,Ki[65]=Ki[105]=0,zi[65]=zi[105]=0,Fi[65]=Fi[105]=-1,Bi[65]=Bi[105]=0,ji[160]=ji[10]=-1,Hi[160]=Hi[10]=0,qi[160]=qi[10]=1,Wi[160]=Wi[10]=-1,Xi[160]=Xi[10]=0,Zi[160]=Zi[10]=0,io[160]=io[10]=1,oo[160]=oo[10]=0,ao[160]=ao[10]=0,eo[160]=eo[10]=1,no[160]=no[10]=0,ro[160]=ro[10]=1,Qi[130]=Qi[40]=0,$i[130]=$i[40]=1,to[130]=to[40]=1,Yi[130]=Yi[40]=0,Ji[130]=Ji[40]=1,Ki[130]=Ki[40]=0,zi[130]=zi[40]=0,Fi[130]=Fi[40]=-1,Bi[130]=Bi[40]=0,Ui[130]=Ui[40]=0,Vi[130]=Vi[40]=-1,Gi[130]=Gi[40]=1,Wi[37]=Wi[133]=0,Xi[37]=Xi[133]=1,Zi[37]=Zi[133]=1,io[37]=io[133]=0,oo[37]=oo[133]=1,ao[37]=ao[133]=0,zi[37]=zi[133]=-1,Fi[37]=Fi[133]=0,Bi[37]=Bi[133]=0,Ui[37]=Ui[133]=1,Vi[37]=Vi[133]=0,Gi[37]=Gi[133]=0,Qi[148]=Qi[22]=-1,$i[148]=$i[22]=0,to[148]=to[22]=0,io[148]=io[22]=0,oo[148]=oo[22]=-1,ao[148]=ao[22]=1,eo[148]=eo[22]=0,no[148]=no[22]=1,ro[148]=ro[22]=1,Ui[148]=Ui[22]=-1,Vi[148]=Vi[22]=0,Gi[148]=Gi[22]=1,ji[82]=ji[88]=0,Hi[82]=Hi[88]=-1,qi[82]=qi[88]=1,Qi[82]=Qi[88]=1,$i[82]=$i[88]=0,to[82]=to[88]=1,Yi[82]=Yi[88]=-1,Ji[82]=Ji[88]=0,Ki[82]=Ki[88]=1,eo[82]=eo[88]=0,no[82]=no[88]=-1,ro[82]=ro[88]=0,ji[73]=ji[97]=0,Hi[73]=Hi[97]=1,qi[73]=qi[97]=0,Wi[73]=Wi[97]=0,Xi[73]=Xi[97]=-1,Zi[73]=Zi[97]=0,Yi[73]=Yi[97]=1,Ji[73]=Ji[97]=0,Ki[73]=Ki[97]=0,zi[73]=zi[97]=1,Fi[73]=Fi[97]=0,Bi[73]=Bi[97]=1,ji[145]=ji[25]=0,Hi[145]=Hi[25]=-1,qi[145]=qi[25]=0,Yi[145]=Yi[25]=1,Ji[145]=Ji[25]=0,Ki[145]=Ki[25]=1,io[145]=io[25]=0,oo[145]=oo[25]=1,ao[145]=ao[25]=1,Ui[145]=Ui[25]=-1,Vi[145]=Vi[25]=0,Gi[145]=Gi[25]=0,Wi[70]=Wi[100]=0,Xi[70]=Xi[100]=1,Zi[70]=Zi[100]=0,Qi[70]=Qi[100]=-1,$i[70]=$i[100]=0,to[70]=to[100]=1,eo[70]=eo[100]=0,no[70]=no[100]=-1,ro[70]=ro[100]=1,zi[70]=zi[100]=1,Fi[70]=Fi[100]=0,Bi[70]=Bi[100]=0,Wi[101]=Wi[69]=0,Xi[101]=Xi[69]=1,Zi[101]=Zi[69]=0,zi[101]=zi[69]=1,Fi[101]=Fi[69]=0,Bi[101]=Bi[69]=0,io[149]=io[21]=0,oo[149]=oo[21]=1,ao[149]=ao[21]=1,Ui[149]=Ui[21]=-1,Vi[149]=Vi[21]=0,Gi[149]=Gi[21]=0,Qi[86]=Qi[84]=-1,$i[86]=$i[84]=0,to[86]=to[84]=1,eo[86]=eo[84]=0,no[86]=no[84]=-1,ro[86]=ro[84]=1,ji[89]=ji[81]=0,Hi[89]=Hi[81]=-1,qi[89]=qi[81]=0,Yi[89]=Yi[81]=1,Ji[89]=Ji[81]=0,Ki[89]=Ki[81]=1,ji[96]=ji[74]=0,Hi[96]=Hi[74]=1,qi[96]=qi[74]=0,Wi[96]=Wi[74]=-1,Xi[96]=Xi[74]=0,Zi[96]=Zi[74]=1,eo[96]=eo[74]=1,no[96]=no[74]=0,ro[96]=ro[74]=0,zi[96]=zi[74]=1,Fi[96]=Fi[74]=0,Bi[96]=Bi[74]=1,ji[24]=ji[146]=0,Hi[24]=Hi[146]=-1,qi[24]=qi[146]=1,Qi[24]=Qi[146]=1,$i[24]=$i[146]=0,to[24]=to[146]=1,Yi[24]=Yi[146]=0,Ji[24]=Ji[146]=1,Ki[24]=Ki[146]=1,Ui[24]=Ui[146]=0,Vi[24]=Vi[146]=-1,Gi[24]=Gi[146]=0,Wi[6]=Wi[164]=-1,Xi[6]=Xi[164]=0,Zi[6]=Zi[164]=1,Qi[6]=Qi[164]=-1,$i[6]=$i[164]=0,to[6]=to[164]=0,io[6]=io[164]=0,oo[6]=oo[164]=-1,ao[6]=ao[164]=1,eo[6]=eo[164]=1,no[6]=no[164]=0,ro[6]=ro[164]=0,Yi[129]=Yi[41]=0,Ji[129]=Ji[41]=1,Ki[129]=Ki[41]=1,io[129]=io[41]=0,oo[129]=oo[41]=1,ao[129]=ao[41]=0,zi[129]=zi[41]=-1,Fi[129]=Fi[41]=0,Bi[129]=Bi[41]=0,Ui[129]=Ui[41]=0,Vi[129]=Vi[41]=-1,Gi[129]=Gi[41]=0,Qi[66]=Qi[104]=0,$i[66]=$i[104]=1,to[66]=to[104]=0,Yi[66]=Yi[104]=-1,Ji[66]=Ji[104]=0,Ki[66]=Ki[104]=1,eo[66]=eo[104]=0,no[66]=no[104]=-1,ro[66]=ro[104]=0,zi[66]=zi[104]=0,Fi[66]=Fi[104]=-1,Bi[66]=Bi[104]=1,ji[144]=ji[26]=-1,Hi[144]=Hi[26]=0,qi[144]=qi[26]=0,io[144]=io[26]=1,oo[144]=oo[26]=0,ao[144]=ao[26]=1,eo[144]=eo[26]=0,no[144]=no[26]=1,ro[144]=ro[26]=1,Ui[144]=Ui[26]=-1,Vi[144]=Vi[26]=0,Gi[144]=Gi[26]=1,Wi[36]=Wi[134]=0,Xi[36]=Xi[134]=1,Zi[36]=Zi[134]=1,Qi[36]=Qi[134]=0,$i[36]=$i[134]=1,to[36]=to[134]=0,zi[36]=zi[134]=0,Fi[36]=Fi[134]=-1,Bi[36]=Bi[134]=1,Ui[36]=Ui[134]=1,Vi[36]=Vi[134]=0,Gi[36]=Gi[134]=0,ji[9]=ji[161]=-1,Hi[9]=Hi[161]=0,qi[9]=qi[161]=0,Wi[9]=Wi[161]=0,Xi[9]=Xi[161]=-1,Zi[9]=Zi[161]=0,Yi[9]=Yi[161]=1,Ji[9]=Ji[161]=0,Ki[9]=Ki[161]=0,io[9]=io[161]=1,oo[9]=oo[161]=0,ao[9]=ao[161]=1,ji[136]=0,Hi[136]=1,qi[136]=1,Wi[136]=0,Xi[136]=1,Zi[136]=0,Qi[136]=-1,$i[136]=0,to[136]=1,Yi[136]=-1,Ji[136]=0,Ki[136]=0,io[136]=0,oo[136]=-1,ao[136]=0,eo[136]=0,no[136]=-1,ro[136]=1,zi[136]=1,Fi[136]=0,Bi[136]=0,Ui[136]=1,Vi[136]=0,Gi[136]=1,ji[34]=0,Hi[34]=-1,qi[34]=0,Wi[34]=0,Xi[34]=-1,Zi[34]=1,Qi[34]=1,$i[34]=0,to[34]=0,Yi[34]=1,Ji[34]=0,Ki[34]=1,io[34]=0,oo[34]=1,ao[34]=1,eo[34]=0,no[34]=1,ro[34]=0,zi[34]=-1,Fi[34]=0,Bi[34]=1,Ui[34]=-1,Vi[34]=0,Gi[34]=0,ji[35]=0,Hi[35]=1,qi[35]=1,Wi[35]=0,Xi[35]=-1,Zi[35]=1,Qi[35]=1,$i[35]=0,to[35]=0,Yi[35]=-1,Ji[35]=0,Ki[35]=0,io[35]=0,oo[35]=-1,ao[35]=0,eo[35]=0,no[35]=1,ro[35]=0,zi[35]=-1,Fi[35]=0,Bi[35]=1,Ui[35]=1,Vi[35]=0,Gi[35]=1,ji[153]=0,Hi[153]=1,qi[153]=1,Yi[153]=-1,Ji[153]=0,Ki[153]=0,io[153]=0,oo[153]=-1,ao[153]=0,Ui[153]=1,Vi[153]=0,Gi[153]=1,Wi[102]=0,Xi[102]=-1,Zi[102]=1,Qi[102]=1,$i[102]=0,to[102]=0,eo[102]=0,no[102]=1,ro[102]=0,zi[102]=-1,Fi[102]=0,Bi[102]=1,ji[155]=0,Hi[155]=-1,qi[155]=0,Yi[155]=1,Ji[155]=0,Ki[155]=1,io[155]=0,oo[155]=1,ao[155]=1,Ui[155]=-1,Vi[155]=0,Gi[155]=0,Wi[103]=0,Xi[103]=1,Zi[103]=0,Qi[103]=-1,$i[103]=0,to[103]=1,eo[103]=0,no[103]=-1,ro[103]=1,zi[103]=1,Fi[103]=0,Bi[103]=0,ji[152]=0,Hi[152]=1,qi[152]=1,Qi[152]=-1,$i[152]=0,to[152]=1,Yi[152]=-1,Ji[152]=0,Ki[152]=0,io[152]=0,oo[152]=-1,ao[152]=0,eo[152]=0,no[152]=-1,ro[152]=1,Ui[152]=1,Vi[152]=0,Gi[152]=1,ji[156]=0,Hi[156]=-1,qi[156]=1,Qi[156]=1,$i[156]=0,to[156]=1,Yi[156]=-1,Ji[156]=0,Ki[156]=0,io[156]=0,oo[156]=-1,ao[156]=0,eo[156]=0,no[156]=1,ro[156]=1,Ui[156]=-1,Vi[156]=0,Gi[156]=1,ji[137]=0,Hi[137]=1,qi[137]=1,Wi[137]=0,Xi[137]=1,Zi[137]=0,Yi[137]=-1,Ji[137]=0,Ki[137]=0,io[137]=0,oo[137]=-1,ao[137]=0,zi[137]=1,Fi[137]=0,Bi[137]=0,Ui[137]=1,Vi[137]=0,Gi[137]=1,ji[139]=0,Hi[139]=1,qi[139]=1,Wi[139]=0,Xi[139]=-1,Zi[139]=0,Yi[139]=1,Ji[139]=0,Ki[139]=0,io[139]=0,oo[139]=1,ao[139]=0,zi[139]=-1,Fi[139]=0,Bi[139]=0,Ui[139]=1,Vi[139]=0,Gi[139]=1,ji[98]=0,Hi[98]=-1,qi[98]=0,Wi[98]=0,Xi[98]=-1,Zi[98]=1,Qi[98]=1,$i[98]=0,to[98]=0,Yi[98]=1,Ji[98]=0,Ki[98]=1,eo[98]=0,no[98]=1,ro[98]=0,zi[98]=-1,Fi[98]=0,Bi[98]=1,ji[99]=0,Hi[99]=1,qi[99]=0,Wi[99]=0,Xi[99]=-1,Zi[99]=1,Qi[99]=1,$i[99]=0,to[99]=0,Yi[99]=-1,Ji[99]=0,Ki[99]=1,eo[99]=0,no[99]=-1,ro[99]=0,zi[99]=1,Fi[99]=0,Bi[99]=1,Wi[38]=0,Xi[38]=-1,Zi[38]=1,Qi[38]=1,$i[38]=0,to[38]=0,io[38]=0,oo[38]=1,ao[38]=1,eo[38]=0,no[38]=1,ro[38]=0,zi[38]=-1,Fi[38]=0,Bi[38]=1,Ui[38]=-1,Vi[38]=0,Gi[38]=0,Wi[39]=0,Xi[39]=1,Zi[39]=1,Qi[39]=-1,$i[39]=0,to[39]=0,io[39]=0,oo[39]=-1,ao[39]=1,eo[39]=0,no[39]=1,ro[39]=0,zi[39]=-1,Fi[39]=0,Bi[39]=1,Ui[39]=1,Vi[39]=0,Gi[39]=0;var so=function(t){return[[t.bottomleft,0],[0,0],[0,t.leftbottom]]},lo=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0]]},uo=function(t){return[[t.topright,1],[1,1],[1,t.righttop]]},co=function(t){return[[0,t.lefttop],[0,1],[t.topleft,1]]},ho=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop]]},po=function(t){return[[t.bottomright,0],[t.bottomleft,0],[1,t.righttop],[1,t.rightbottom]]},fo=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.topleft,1],[t.topright,1]]},mo=function(t){return[[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},go=[],yo=[],vo=[],_o=[],xo=[],bo=[],wo=[],Eo=[];_o[1]=xo[1]=18,_o[169]=xo[169]=18,vo[4]=yo[4]=12,vo[166]=yo[166]=12,go[16]=Eo[16]=4,go[154]=Eo[154]=4,bo[64]=wo[64]=22,bo[106]=wo[106]=22,vo[2]=bo[2]=17,_o[2]=xo[2]=18,vo[168]=bo[168]=17,_o[168]=xo[168]=18,go[8]=_o[8]=9,yo[8]=vo[8]=12,go[162]=_o[162]=9,yo[162]=vo[162]=12,go[32]=Eo[32]=4,yo[32]=wo[32]=1,go[138]=Eo[138]=4,yo[138]=wo[138]=1,xo[128]=Eo[128]=21,bo[128]=wo[128]=22,xo[42]=Eo[42]=21,bo[42]=wo[42]=22,yo[5]=xo[5]=14,yo[165]=xo[165]=14,vo[20]=Eo[20]=6,vo[150]=Eo[150]=6,go[80]=bo[80]=11,go[90]=bo[90]=11,_o[65]=wo[65]=3,_o[105]=wo[105]=3,go[160]=bo[160]=11,yo[160]=xo[160]=14,go[10]=bo[10]=11,yo[10]=xo[10]=14,vo[130]=Eo[130]=6,_o[130]=wo[130]=3,vo[40]=Eo[40]=6,_o[40]=wo[40]=3,yo[101]=wo[101]=1,yo[69]=wo[69]=1,xo[149]=Eo[149]=21,xo[21]=Eo[21]=21,vo[86]=bo[86]=17,vo[84]=bo[84]=17,go[89]=_o[89]=9,go[81]=_o[81]=9,go[96]=wo[96]=0,yo[96]=bo[96]=15,go[74]=wo[74]=0,yo[74]=bo[74]=15,go[24]=vo[24]=8,_o[24]=Eo[24]=7,go[146]=vo[146]=8,_o[146]=Eo[146]=7,yo[6]=bo[6]=15,vo[6]=xo[6]=16,yo[164]=bo[164]=15,vo[164]=xo[164]=16,_o[129]=Eo[129]=7,xo[129]=wo[129]=20,_o[41]=Eo[41]=7,xo[41]=wo[41]=20,vo[66]=wo[66]=2,_o[66]=bo[66]=19,vo[104]=wo[104]=2,_o[104]=bo[104]=19,go[144]=xo[144]=10,bo[144]=Eo[144]=23,go[26]=xo[26]=10,bo[26]=Eo[26]=23,yo[36]=Eo[36]=5,vo[36]=wo[36]=2,yo[134]=Eo[134]=5,vo[134]=wo[134]=2,go[9]=xo[9]=10,yo[9]=_o[9]=13,go[161]=xo[161]=10,yo[161]=_o[161]=13,yo[37]=Eo[37]=5,xo[37]=wo[37]=20,yo[133]=Eo[133]=5,xo[133]=wo[133]=20,vo[148]=xo[148]=16,bo[148]=Eo[148]=23,vo[22]=xo[22]=16,bo[22]=Eo[22]=23,go[82]=vo[82]=8,_o[82]=bo[82]=19,go[88]=vo[88]=8,_o[88]=bo[88]=19,go[73]=wo[73]=0,yo[73]=_o[73]=13,go[97]=wo[97]=0,yo[97]=_o[97]=13,go[145]=_o[145]=9,xo[145]=Eo[145]=21,go[25]=_o[25]=9,xo[25]=Eo[25]=21,yo[70]=wo[70]=1,vo[70]=bo[70]=17,yo[100]=wo[100]=1,vo[100]=bo[100]=17,go[34]=_o[34]=9,yo[34]=vo[34]=12,xo[34]=Eo[34]=21,bo[34]=wo[34]=22,go[136]=Eo[136]=4,yo[136]=wo[136]=1,vo[136]=bo[136]=17,_o[136]=xo[136]=18,go[35]=Eo[35]=4,yo[35]=vo[35]=12,_o[35]=xo[35]=18,bo[35]=wo[35]=22,go[153]=Eo[153]=4,_o[153]=xo[153]=18,yo[102]=vo[102]=12,bo[102]=wo[102]=22,go[155]=_o[155]=9,xo[155]=Eo[155]=23,yo[103]=wo[103]=1,vo[103]=bo[103]=17,go[152]=Eo[152]=4,vo[152]=bo[152]=17,_o[152]=xo[152]=18,go[156]=vo[156]=8,_o[156]=xo[156]=18,bo[156]=Eo[156]=23,go[137]=Eo[137]=4,yo[137]=wo[137]=1,_o[137]=xo[137]=18,go[139]=Eo[139]=4,yo[139]=_o[139]=13,xo[139]=wo[139]=20,go[98]=_o[98]=9,yo[98]=vo[98]=12,bo[98]=wo[98]=22,go[99]=wo[99]=0,yo[99]=vo[99]=12,_o[99]=bo[99]=19,yo[38]=vo[38]=12,xo[38]=Eo[38]=21,bo[38]=wo[38]=22,yo[39]=Eo[39]=5,vo[39]=xo[39]=16,bo[39]=wo[39]=22;var So=[];function Mo(t,e,n){return(t-e)/(n-e)}function To(t){return t.constructor.toString().indexOf("Array")>-1}function Co(t,e,n,r,i,o){for(var a=t.cells[n][e],s=a.cval_real,l=e+r,u=n+i,c=[],h=!1;!h;){if(void 0===t.cells[u]||void 0===t.cells[u][l])if(u-=i,l-=r,s=(a=t.cells[u][l]).cval_real,-1===i)if(0===o)if(1&s)c.push([l,u]),r=-1,i=0,o=0;else{if(!(4&s)){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l+1,u]),r=1,i=0,o=0}else{if(!(1&s)){if(4&s){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l+a.bottomleft,u]),r=0,i=1,o=0,h=!0;break}c.push([l,u]),r=-1,i=0,o=0}else if(1===i)if(0===o){if(!(s&ki)){if(s&Oi){c.push([l+a.topleft,u+1]),r=0,i=-1,o=0,h=!0;break}c.push([l+a.topright,u+1]),r=0,i=-1,o=1,h=!0;break}c.push([l+1,u+1]),r=1,i=0,o=1}else c.push([l+1,u+1]),r=1,i=0,o=1;else if(-1===r)if(0===o){if(!(s&Oi)){if(1&s){c.push([l,u+a.leftbottom]),r=1,i=0,o=0,h=!0;break}c.push([l,u+a.lefttop]),r=1,i=0,o=1,h=!0;break}c.push([l,u+1]),r=0,i=1,o=0}else{if(!(s&Oi)){console.log("MarchingSquaresJS-isoBands: wtf");break}c.push([l,u+1]),r=0,i=1,o=0}else{if(1!==r){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break}if(0===o){if(!(4&s)){c.push([l+1,u+a.rightbottom]),r=-1,i=0,o=0,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}else{if(!(4&s)){if(s&ki){c.push([l+1,u+a.righttop]),r=-1,i=0,o=1;break}c.push([l+1,u+a.rightbottom]),r=-1,i=0,o=0,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}}else if(s=(a=t.cells[u][l]).cval_real,-1===r)if(0===o)if(void 0!==t.cells[u-1]&&void 0!==t.cells[u-1][l])r=0,i=-1,o=1;else{if(!(1&s)){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l,u])}else{if(!(s&Oi)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+l+","+u);break}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!")}else if(1===r){if(0===o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u+1]&&void 0!==t.cells[u+1][l])r=0,i=1,o=0;else{if(!(s&ki)){c.push([l+a.topleft,u+1]),r=0,i=-1,o=0,h=!0;break}c.push([l+1,u+1]),r=1,i=0,o=1}}else if(-1===i){if(1!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u][l+1])r=1,i=0,o=1;else{if(!(4&s)){c.push([l+1,u+a.righttop]),r=-1,i=0,o=1,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}}else{if(1!==i){console.log("MarchingSquaresJS-isoBands: where did we came from???");break}if(0!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u][l-1])r=-1,i=0,o=0;else{if(!(s&Oi)){c.push([l,u+a.leftbottom]),r=1,i=0,o=0,h=!0;break}c.push([l,u+1]),r=0,i=1,o=0}}if(u+=i,(l+=r)===e&&u===n)break}return{path:c,i:l,j:u,x:r,y:i,o:o}}function Io(t){if(t.edges.length>0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&ki?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return 4&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return 1&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&ki?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return 4&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return 1&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return 1&n?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&Oi?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return 1&n?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&Oi?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&Oi?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&Oi?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&Oi?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&ki?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&Oi?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&ki?{p:[0,t.lefttop],x:1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};default:console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t)}}return null}function Ao(t,e,n,r){var i,o,a,s,l,u=t.cval;switch(e){case-1:if(0===r)i=yo[u],a=Wi[u],s=Xi[u],l=Zi[u];else i=go[u],a=ji[u],s=Hi[u],l=qi[u];break;case 1:if(0===r)i=xo[u],a=io[u],s=oo[u],l=ao[u];else i=bo[u],a=eo[u],s=no[u],l=ro[u];break;default:switch(n){case-1:if(0===r)i=wo[u],a=zi[u],s=Fi[u],l=Bi[u];else i=Eo[u],a=Ui[u],s=Vi[u],l=Gi[u];break;case 1:if(0===r)i=_o[u],a=Yi[u],s=Ji[u],l=Ki[u];else i=vo[u],a=Qi[u],s=$i[u],l=to[u]}}if(o=t.edges.indexOf(i),void 0===t.edges[o])return null;switch(function(t,e){delete t.edges[e];for(var n=e+1;n<t.edges.length;n++)t.edges[n-1]=t.edges[n];t.edges.pop()}(t,o),u=t.cval_real,i){case 0:u&ki?(e=t.topleft,n=1):(e=1,n=t.righttop);break;case 1:4&u?(e=1,n=t.rightbottom):(e=t.topleft,n=1);break;case 2:4&u?(e=t.topleft,n=1):(e=t.bottomright,n=0);break;case 3:1&u?(e=t.bottomleft,n=0):(e=t.topleft,n=1);break;case 4:u&ki?(e=t.topright,n=1):(e=1,n=t.righttop);break;case 5:4&u?(e=1,n=t.rightbottom):(e=t.topright,n=1);break;case 6:4&u?(e=t.topright,n=1):(e=t.bottomright,n=0);break;case 7:1&u?(e=t.bottomleft,n=0):(e=t.topright,n=1);break;case 8:4&u?(e=1,n=t.righttop):(e=t.bottomright,n=0);break;case 9:1&u?(e=t.bottomleft,n=0):(e=1,n=t.righttop);break;case 10:1&u?(e=1,n=t.righttop):(e=0,n=t.leftbottom);break;case 11:u&Oi?(e=0,n=t.lefttop):(e=1,n=t.righttop);break;case 12:4&u?(e=1,n=t.rightbottom):(e=t.bottomright,n=0);break;case 13:1&u?(e=t.bottomleft,n=0):(e=1,n=t.rightbottom);break;case 14:1&u?(e=1,n=t.rightbottom):(e=0,n=t.leftbottom);break;case 15:u&Oi?(e=0,n=t.lefttop):(e=1,n=t.rightbottom);break;case 16:4&u?(e=0,n=t.leftbottom):(e=t.bottomright,n=0);break;case 17:u&Oi?(e=0,n=t.lefttop):(e=t.bottomright,n=0);break;case 18:1&u?(e=t.bottomleft,n=0):(e=0,n=t.leftbottom);break;case 19:u&Oi?(e=0,n=t.lefttop):(e=t.bottomleft,n=0);break;case 20:u&Oi?(e=0,n=t.leftbottom):(e=t.topleft,n=1);break;case 21:u&ki?(e=t.topright,n=1):(e=0,n=t.leftbottom);break;case 22:u&Oi?(e=0,n=t.lefttop):(e=t.topleft,n=1);break;case 23:u&ki?(e=t.topright,n=1):(e=0,n=t.lefttop);break;default:return console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t),null}return void 0!==e&&void 0!==n&&void 0!==a&&void 0!==s&&void 0!==l||(console.log("MarchingSquaresJS-isoBands: undefined value!"),console.log(t),console.log(e+" "+n+" "+a+" "+s+" "+l)),{p:[e,n],x:a,y:s,o:l}}function Lo(t){var e=[],n=[];t.forEach((function(t){var r=Mr(u([t]));n.push(r),e.push({ring:t,area:r})})),n.sort((function(t,e){return e-t}));var r=[];return n.forEach((function(t){for(var n=0;n<e.length;n++)if(e[n].area===t){r.push(e[n].ring),e.splice(n,1);break}})),r}function Po(t){for(var e=t.map((function(t){return{lrCoordinates:t,grouped:!1}})),n=[];!Do(e);)for(var r=0;r<e.length;r++)if(!e[r].grouped){var i=[];i.push(e[r].lrCoordinates),e[r].grouped=!0;for(var o=u([e[r].lrCoordinates]),a=r+1;a<e.length;a++)e[a].grouped||Ro(u([e[a].lrCoordinates]),o)&&(i.push(e[a].lrCoordinates),e[a].grouped=!0);n.push(i)}return n}function Ro(t,e){for(var n=mn(t),r=0;r<n.features.length;r++)if(!fe(n.features[r],e))return!1;return!0}function Do(t){for(var e=0;e<t.length;e++)if(!1===t[e].grouped)return!1;return!0}function No(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.pivot,i=n.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("angle is required");return 0===e||(r||(r=dn(t)),!1!==i&&void 0!==i||(t=be(t)),R(t,(function(t){var n=wi(r,t)+e,i=yr(r,t),o=Q(Si(r,i,n));t[0]=o[0],t[1]=o[1]}))),t}function Oo(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.origin,i=n.mutate;if(!t)throw new Error("geojson required");if("number"!=typeof e||0===e)throw new Error("invalid factor");var o=Array.isArray(r)||"object"==typeof r;return!0!==i&&(t=be(t)),"FeatureCollection"!==t.type||o?ko(t,e,r):(k(t,(function(n,i){t.features[i]=ko(n,e,r)})),t)}function ko(t,e,n){var r="Point"===it(t);return n=function(t,e){null==e&&(e="centroid");if(Array.isArray(e)||"object"==typeof e)return K(e);var n=t.bbox?t.bbox:J(t),r=n[0],i=n[1],o=n[2],a=n[3];switch(e){case"sw":case"southwest":case"westsouth":case"bottomleft":return s([r,i]);case"se":case"southeast":case"eastsouth":case"bottomright":return s([o,i]);case"nw":case"northwest":case"westnorth":case"topleft":return s([r,a]);case"ne":case"northeast":case"eastnorth":case"topright":return s([o,a]);case"center":return fn(t);case void 0:case null:case"centroid":return dn(t);default:throw new Error("invalid origin")}}(t,n),1===e||r||R(t,(function(t){var r=yr(n,t),i=wi(n,t),o=Q(Si(n,r*e,i));t[0]=o[0],t[1]=o[1],3===t.length&&(t[2]*=e)})),t}function zo(t){var e=t[0],n=t[1];return[n[0]-e[0],n[1]-e[1]]}function Fo(t,e){return t[0]*e[1]-e[0]*t[1]}function Bo(t,e,n){var r=[],i=b(e,n),o=Q(t),a=[];return o.forEach((function(t,e){if(e!==o.length-1){var n=(u=t,c=o[e+1],h=i,p=Math.sqrt((u[0]-c[0])*(u[0]-c[0])+(u[1]-c[1])*(u[1]-c[1])),f=u[0]+h*(c[1]-u[1])/p,d=c[0]+h*(c[1]-u[1])/p,[[f,u[1]+h*(u[0]-c[0])/p],[d,c[1]+h*(u[0]-c[0])/p]]);if(r.push(n),e>0){var s=r[e-1],l=function(t,e){return!function(t,e){return 0===Fo(zo(t),zo(e))}(t,e)&&function(t,e){var n,r,i=t[0],o=zo(t),a=e[0],s=zo(e),l=Fo(o,s);return function(t,e){return[t[0]+e[0],t[1]+e[1]]}(i,function(t,e){return[t*e[0],t*e[1]]}(Fo((r=i,[(n=a)[0]-r[0],n[1]-r[1]]),s)/l,o))}(t,e)}(n,s);!1!==l&&(s[1]=l,n[0]=l),a.push(s[0]),e===o.length-2&&(a.push(n[0]),a.push(n[1]))}2===o.length&&(a.push(n[0]),a.push(n[1]))}var u,c,h,p,f,d})),h(a,t.properties)}function Uo(t,e,n){var r=e[0]-t[0],i=e[1]-t[1],o=n[0]-e[0];return function(t){return(t>0)-(t<0)||+t}(r*(n[1]-e[1])-o*i)}function Vo(t,e){return e.geometry.coordinates[0].every((function(e){return fe(s(e),t)}))}So[1]=So[169]=so,So[4]=So[166]=lo,So[16]=So[154]=uo,So[64]=So[106]=co,So[168]=So[2]=ho,So[162]=So[8]=po,So[138]=So[32]=fo,So[42]=So[128]=mo,So[5]=So[165]=function(t){return[[0,0],[0,t.leftbottom],[1,t.rightbottom],[1,0]]},So[20]=So[150]=function(t){return[[1,0],[t.bottomright,0],[t.topright,1],[1,1]]},So[80]=So[90]=function(t){return[[1,1],[1,t.righttop],[0,t.lefttop],[0,1]]},So[65]=So[105]=function(t){return[[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},So[160]=So[10]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.leftbottom],[0,t.lefttop]]},So[130]=So[40]=function(t){return[[t.topleft,1],[t.topright,1],[t.bottomright,0],[t.bottomleft,0]]},So[85]=function(){return[[0,0],[0,1],[1,1],[1,0]]},So[101]=So[69]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,1],[t.topleft,1]]},So[149]=So[21]=function(t){return[[t.topright,1],[1,1],[1,0],[0,0],[0,t.leftbottom]]},So[86]=So[84]=function(t){return[[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[1,1]]},So[89]=So[81]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,1]]},So[96]=So[74]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.lefttop],[0,1],[t.topleft,1]]},So[24]=So[146]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[t.topright,1]]},So[6]=So[164]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop]]},So[129]=So[41]=function(t){return[[t.topright,1],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1]]},So[66]=So[104]=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[144]=So[26]=function(t){return[[1,1],[1,t.righttop],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[36]=So[134]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[t.topleft,1],[t.topright,1]]},So[9]=So[161]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom]]},So[37]=So[133]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},So[148]=So[22]=function(t){return[[1,1],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[82]=So[88]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1]]},So[73]=So[97]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},So[145]=So[25]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},So[70]=So[100]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[34]=function(t){return[mo(t),po(t)]},So[35]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},So[136]=function(t){return[fo(t),ho(t)]},So[153]=function(t){return[uo(t),so(t)]},So[102]=function(t){return[lo(t),co(t)]},So[155]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},So[103]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[152]=function(t){return[uo(t),ho(t)]},So[156]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[137]=function(t){return[fo(t),so(t)]},So[139]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},So[98]=function(t){return[po(t),co(t)]},So[99]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[38]=function(t){return[lo(t),mo(t)]},So[39]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]};var Go=function(){function t(e){this.id=t.buildId(e),this.coordinates=e,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return t.buildId=function(t){return t.join(",")},t.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter((function(e){return e.from.id!==t.from.id}))},t.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter((function(e){return e.to.id!==t.to.id}))},t.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},t.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort((function(e,n){var r=e.to,i=n.to;if(r.coordinates[0]-t.coordinates[0]>=0&&i.coordinates[0]-t.coordinates[0]<0)return 1;if(r.coordinates[0]-t.coordinates[0]<0&&i.coordinates[0]-t.coordinates[0]>=0)return-1;if(r.coordinates[0]-t.coordinates[0]==0&&i.coordinates[0]-t.coordinates[0]==0)return r.coordinates[1]-t.coordinates[1]>=0||i.coordinates[1]-t.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];var o=Uo(t.coordinates,r.coordinates,i.coordinates);return o<0?1:o>0?-1:Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2)-(Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2))})),this.outerEdgesSorted=!0)},t.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},t.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},t.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},t}(),jo=function(){function t(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return t.prototype.getSymetric=function(){return this.symetric||(this.symetric=new t(this.to,this.from),this.symetric.symetric=this),this.symetric},t.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},t.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},t.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},t.prototype.toLineString=function(){return h([this.from.coordinates,this.to.coordinates])},t.prototype.compareTo=function(t){return Uo(t.from.coordinates,t.to.coordinates,this.to.coordinates)},t}(),Ho=function(){function t(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return t.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},t.prototype.get=function(t){return this.edges[t]},Object.defineProperty(t.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t){this.edges.forEach(t)},t.prototype.map=function(t){return this.edges.map(t)},t.prototype.some=function(t){return this.edges.some(t)},t.prototype.isValid=function(){return!0},t.prototype.isHole=function(){var t=this,e=this.edges.reduce((function(e,n,r){return n.from.coordinates[1]>t.edges[e].from.coordinates[1]&&(e=r),e}),0),n=(0===e?this.length:e)-1,r=(e+1)%this.length,i=Uo(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[r].from.coordinates);return 0===i?this.edges[n].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0},t.prototype.toMultiPoint=function(){return m(this.edges.map((function(t){return t.from.coordinates})))},t.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map((function(t){return t.from.coordinates}));return t.push(this.edges[0].from.coordinates),this.polygon=u([t])},t.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=ln(this.toPolygon())},t.findEdgeRingContaining=function(t,e){var n,r,i=t.getEnvelope();return e.forEach((function(e){var o,a,l,u,c,h,p=e.getEnvelope();if((r&&(n=r.getEnvelope()),a=i,l=(o=p).geometry.coordinates[0].map((function(t){return t[0]})),u=o.geometry.coordinates[0].map((function(t){return t[1]})),c=a.geometry.coordinates[0].map((function(t){return t[0]})),h=a.geometry.coordinates[0].map((function(t){return t[1]})),Math.max.apply(null,l)!==Math.max.apply(null,c)||Math.max.apply(null,u)!==Math.max.apply(null,h)||Math.min.apply(null,l)!==Math.min.apply(null,c)||Math.min.apply(null,u)!==Math.min.apply(null,h))&&Vo(p,i)){for(var f=t.map((function(t){return t.from.coordinates})),d=void 0,m=function(t){e.some((function(e){return n=t,r=e.from.coordinates,n[0]===r[0]&&n[1]===r[1];var n,r}))||(d=t)},g=0,y=f;g<y.length;g++)m(y[g]);d&&e.inside(s(d))&&(r&&!Vo(n,p)||(r=e))}})),r},t.prototype.inside=function(t){return fe(t,this.toPolygon())},t}(),qo=function(){function t(){this.edges=[],this.nodes={}}return t.fromGeoJson=function(e){!function(t){if(!t)throw new Error("No geojson passed");if("FeatureCollection"!==t.type&&"GeometryCollection"!==t.type&&"MultiLineString"!==t.type&&"LineString"!==t.type&&"Feature"!==t.type)throw new Error("Invalid input type '"+t.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}(e);var n=new t;return V(e,(function(t){et(t,"LineString","Graph::fromGeoJson"),D(t,(function(t,e){if(t){var r=n.getNode(t),i=n.getNode(e);n.addEdge(r,i)}return e}))})),n},t.prototype.getNode=function(t){var e=Go.buildId(t),n=this.nodes[e];return n||(n=this.nodes[e]=new Go(t)),n},t.prototype.addEdge=function(t,e){var n=new jo(t,e),r=n.getSymetric();this.edges.push(n),this.edges.push(r)},t.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map((function(e){return t.nodes[e]})).forEach((function(e){return t._removeIfDangle(e)}))},t.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var n=t.getOuterEdges().map((function(t){return t.to}));this.removeNode(t),n.forEach((function(t){return e._removeIfDangle(t)}))}},t.prototype.deleteCutEdges=function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach((function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))}))},t.prototype._computeNextCWEdges=function(t){var e=this;void 0===t?Object.keys(this.nodes).forEach((function(t){return e._computeNextCWEdges(e.nodes[t])})):t.getOuterEdges().forEach((function(e,n){t.getOuterEdge((0===n?t.getOuterEdges().length:n)-1).symetric.next=e}))},t.prototype._computeNextCCWEdges=function(t,e){for(var n,r,i=t.getOuterEdges(),o=i.length-1;o>=0;--o){var a=i[o],s=a.symetric,l=void 0,u=void 0;a.label===e&&(l=a),s.label===e&&(u=s),l&&u&&(u&&(r=u),l&&(r&&(r.next=l,r=void 0),n||(n=l)))}r&&(r.next=n)},t.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach((function(n){if(!(n.label>=0)){t.push(n);var r=n;do{r.label=e,r=r.next}while(!n.isEqual(r));e++}})),t},t.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach((function(t){t.label=void 0})),this._findLabeledEdgeRings().forEach((function(e){t._findIntersectionNodes(e).forEach((function(n){t._computeNextCCWEdges(n,e.label)}))}));var e=[];return this.edges.forEach((function(n){n.ring||e.push(t._findEdgeRing(n))})),e},t.prototype._findIntersectionNodes=function(t){var e=[],n=t,r=function(){var r=0;n.from.getOuterEdges().forEach((function(e){e.label===t.label&&++r})),r>1&&e.push(n.from),n=n.next};do{r()}while(!t.isEqual(n));return e},t.prototype._findEdgeRing=function(t){var e=t,n=new Ho;do{n.push(e),e.ring=n,e=e.next}while(!t.isEqual(e));return n},t.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach((function(t){return e.removeEdge(t)})),t.innerEdges.forEach((function(t){return e.removeEdge(t)})),delete this.nodes[t.id]},t.prototype.removeEdge=function(t){this.edges=this.edges.filter((function(e){return!e.isEqual(t)})),t.deleteEdge()},t}();function Wo(t,e){var n=!0;return V(t,(function(t){V(e,(function(e){if(!1===n)return!1;n=function(t,e){switch(t.type){case"Point":switch(e.type){case"Point":return n=t.coordinates,r=e.coordinates,!(n[0]===r[0]&&n[1]===r[1]);case"LineString":return!Xo(e,t);case"Polygon":return!fe(t,e)}break;case"LineString":switch(e.type){case"Point":return!Xo(t,e);case"LineString":return!function(t,e){return dr(t,e).features.length>0}(t,e);case"Polygon":return!Zo(e,t)}break;case"Polygon":switch(e.type){case"Point":return!fe(e,t);case"LineString":return!Zo(t,e);case"Polygon":return!function(t,e){for(var n=0,r=t.coordinates[0];n<r.length;n++)if(fe(r[n],e))return!0;for(var i=0,o=e.coordinates[0];i<o.length;i++)if(fe(o[i],t))return!0;return dr(ai(t),ai(e)).features.length>0}(e,t)}}var n,r;return!1}(t.geometry,e.geometry)}))})),n}function Xo(t,e){for(var n=0;n<t.coordinates.length-1;n++)if(Yo(t.coordinates[n],t.coordinates[n+1],e.coordinates))return!0;return!1}function Zo(t,e){for(var n=0,r=e.coordinates;n<r.length;n++)if(fe(r[n],t))return!0;return dr(e,ai(t)).features.length>0}function Yo(t,e,n){var r=n[0]-t[0],i=n[1]-t[1],o=e[0]-t[0],a=e[1]-t[1];return 0==r*a-i*o&&(Math.abs(o)>=Math.abs(a)?o>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:a>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1])}function Jo(t,e){return!(t[0]>e[0]||t[2]<e[2]||t[1]>e[1]||t[3]<e[3])}function Ko(t,e){return t[0]===e[0]&&t[1]===e[1]}function Qo(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}function $o(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o<i&&!n&&!r;){for(var a=0;a<e.coordinates.length-1;a++){var s=!0;0!==a&&a!==e.coordinates.length-2||(s=!1),na(e.coordinates[a],e.coordinates[a+1],t.coordinates[o],s)?n=!0:r=!0}o++}return n&&r}function ta(t,e){return dr(t,si(e)).features.length>0}function ea(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o<i&&(!n||!r);o++)fe(s(t.coordinates[o]),e)?n=!0:r=!0;return r&&n}function na(t,e,n,r){var i=n[0]-t[0],o=n[1]-t[1],a=e[0]-t[0],s=e[1]-t[1];return 0==i*s-o*a&&(r?Math.abs(a)>=Math.abs(s)?a>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:s>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]:Math.abs(a)>=Math.abs(s)?a>0?t[0]<n[0]&&n[0]<e[0]:e[0]<n[0]&&n[0]<t[0]:s>0?t[1]<n[1]&&n[1]<e[1]:e[1]<n[1]&&n[1]<t[1])}var ra=function(t){this.precision=t&&t.precision?t.precision:17,this.direction=!(!t||!t.direction)&&t.direction,this.pseudoNode=!(!t||!t.pseudoNode)&&t.pseudoNode,this.objectComparator=t&&t.objectComparator?t.objectComparator:aa};function ia(t){return t.coordinates.map((function(e){return{type:t.type.replace("Multi",""),coordinates:e}}))}function oa(t,e){return t.hasOwnProperty("coordinates")?t.coordinates.length===e.coordinates.length:t.length===e.length}function aa(t,e){return vi(t,e,{strict:!0})}ra.prototype.compare=function(t,e){if(t.type!==e.type||!oa(t,e))return!1;switch(t.type){case"Point":return this.compareCoord(t.coordinates,e.coordinates);case"LineString":return this.compareLine(t.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(t,e);case"Feature":return this.compareFeature(t,e);default:if(0===t.type.indexOf("Multi")){var n=this,r=ia(t),i=ia(e);return r.every((function(t){return this.some((function(e){return n.compare(t,e)}))}),i)}}return!1},ra.prototype.compareCoord=function(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n].toFixed(this.precision)!==e[n].toFixed(this.precision))return!1;return!0},ra.prototype.compareLine=function(t,e,n,r){if(!oa(t,e))return!1;var i=this.pseudoNode?t:this.removePseudo(t),o=this.pseudoNode?e:this.removePseudo(e);if(!r||this.compareCoord(i[0],o[0])||(o=this.fixStartIndex(o,i))){var a=this.compareCoord(i[n],o[n]);return this.direction||a?this.comparePath(i,o):!!this.compareCoord(i[n],o[o.length-(1+n)])&&this.comparePath(i.slice().reverse(),o)}},ra.prototype.fixStartIndex=function(t,e){for(var n,r=-1,i=0;i<t.length;i++)if(this.compareCoord(t[i],e[0])){r=i;break}return r>=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n},ra.prototype.comparePath=function(t,e){var n=this;return t.every((function(t,e){return n.compareCoord(t,this[e])}),e)},ra.prototype.comparePolygon=function(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var n=t.coordinates.slice(1,t.coordinates.length),r=e.coordinates.slice(1,e.coordinates.length),i=this;return n.every((function(t){return this.some((function(e){return i.compareLine(t,e,1,!0)}))}),r)}return!1},ra.prototype.compareFeature=function(t,e){return!(t.id!==e.id||!this.objectComparator(t.properties,e.properties)||!this.compareBBox(t,e))&&this.compare(t.geometry,e.geometry)},ra.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox))},ra.prototype.removePseudo=function(t){return t};var sa=ra;function la(t,e){var n=!1;return V(t,(function(t){V(e,(function(e){if(!0===n)return!0;n=!Wo(t.geometry,e.geometry)}))})),n}var ua=Ft((function(t){function e(t,e,n,r){this.dataset=[],this.epsilon=1,this.minPts=2,this.distance=this._euclideanDistance,this.clusters=[],this.noise=[],this._visited=[],this._assigned=[],this._datasetLength=0,this._init(t,e,n,r)}e.prototype.run=function(t,e,n,r){this._init(t,e,n,r);for(var i=0;i<this._datasetLength;i++)if(1!==this._visited[i]){this._visited[i]=1;var o=this._regionQuery(i);if(o.length<this.minPts)this.noise.push(i);else{var a=this.clusters.length;this.clusters.push([]),this._addToCluster(i,a),this._expandCluster(a,o)}}return this.clusters},e.prototype._init=function(t,e,n,r){if(t){if(!(t instanceof Array))throw Error("Dataset must be of type array, "+typeof t+" given");this.dataset=t,this.clusters=[],this.noise=[],this._datasetLength=t.length,this._visited=new Array(this._datasetLength),this._assigned=new Array(this._datasetLength)}e&&(this.epsilon=e),n&&(this.minPts=n),r&&(this.distance=r)},e.prototype._expandCluster=function(t,e){for(var n=0;n<e.length;n++){var r=e[n];if(1!==this._visited[r]){this._visited[r]=1;var i=this._regionQuery(r);i.length>=this.minPts&&(e=this._mergeArrays(e,i))}1!==this._assigned[r]&&this._addToCluster(r,t)}},e.prototype._addToCluster=function(t,e){this.clusters[e].push(t),this._assigned[t]=1},e.prototype._regionQuery=function(t){for(var e=[],n=0;n<this._datasetLength;n++)this.distance(this.dataset[t],this.dataset[n])<this.epsilon&&e.push(n);return e},e.prototype._mergeArrays=function(t,e){for(var n=e.length,r=0;r<n;r++){var i=e[r];t.indexOf(i)<0&&t.push(i)}return t},e.prototype._euclideanDistance=function(t,e){for(var n=0,r=Math.min(t.length,e.length);r--;)n+=(t[r]-e[r])*(t[r]-e[r]);return Math.sqrt(n)},t.exports&&(t.exports=e)})),ca=Ft((function(t){function e(t,e,n){this.k=3,this.dataset=[],this.assignments=[],this.centroids=[],this.init(t,e,n)}e.prototype.init=function(t,e,n){this.assignments=[],this.centroids=[],void 0!==t&&(this.dataset=t),void 0!==e&&(this.k=e),void 0!==n&&(this.distance=n)},e.prototype.run=function(t,e){this.init(t,e);for(var n=this.dataset.length,r=0;r<this.k;r++)this.centroids[r]=this.randomCentroid();for(var i=!0;i;){i=this.assign();for(var o=0;o<this.k;o++){for(var a=new Array(c),s=0,l=0;l<c;l++)a[l]=0;for(var u=0;u<n;u++){var c=this.dataset[u].length;if(o===this.assignments[u]){for(l=0;l<c;l++)a[l]+=this.dataset[u][l];s++}}if(s>0){for(l=0;l<c;l++)a[l]/=s;this.centroids[o]=a}else this.centroids[o]=this.randomCentroid(),i=!0}}return this.getClusters()},e.prototype.randomCentroid=function(){var t,e,n=this.dataset.length-1;do{e=Math.round(Math.random()*n),t=this.dataset[e]}while(this.centroids.indexOf(t)>=0);return t},e.prototype.assign=function(){for(var t,e=!1,n=this.dataset.length,r=0;r<n;r++)(t=this.argmin(this.dataset[r],this.centroids,this.distance))!=this.assignments[r]&&(this.assignments[r]=t,e=!0);return e},e.prototype.getClusters=function(){for(var t,e=new Array(this.k),n=0;n<this.assignments.length;n++)void 0===e[t=this.assignments[n]]&&(e[t]=[]),e[t].push(n);return e},e.prototype.argmin=function(t,e,n){for(var r,i=Number.MAX_VALUE,o=0,a=e.length,s=0;s<a;s++)(r=n(t,e[s]))<i&&(i=r,o=s);return o},e.prototype.distance=function(t,e){for(var n=0,r=Math.min(t.length,e.length);r--;){var i=t[r]-e[r];n+=i*i}return Math.sqrt(n)},t.exports&&(t.exports=e)})),ha=Ft((function(t){function e(t,e,n){this._queue=[],this._priorities=[],this._sorting="desc",this._init(t,e,n)}e.prototype.insert=function(t,e){for(var n=this._queue.length,r=n;r--;){var i=this._priorities[r];"desc"===this._sorting?e>i&&(n=r):e<i&&(n=r)}this._insertAt(t,e,n)},e.prototype.remove=function(t){for(var e=this._queue.length;e--;)if(t===this._queue[e]){this._queue.splice(e,1),this._priorities.splice(e,1);break}},e.prototype.forEach=function(t){this._queue.forEach(t)},e.prototype.getElements=function(){return this._queue},e.prototype.getElementPriority=function(t){return this._priorities[t]},e.prototype.getPriorities=function(){return this._priorities},e.prototype.getElementsWithPriorities=function(){for(var t=[],e=0,n=this._queue.length;e<n;e++)t.push([this._queue[e],this._priorities[e]]);return t},e.prototype._init=function(t,e,n){if(t&&e){if(this._queue=[],this._priorities=[],t.length!==e.length)throw new Error("Arrays must have the same length");for(var r=0;r<t.length;r++)this.insert(t[r],e[r])}n&&(this._sorting=n)},e.prototype._insertAt=function(t,e,n){this._queue.length===n?(this._queue.push(t),this._priorities.push(e)):(this._queue.splice(n,0,t),this._priorities.splice(n,0,e))},t.exports&&(t.exports=e)})),pa=Ft((function(t){if(t.exports)var e=ha;function n(t,e,n,r){this.epsilon=1,this.minPts=1,this.distance=this._euclideanDistance,this._reachability=[],this._processed=[],this._coreDistance=0,this._orderedList=[],this._init(t,e,n,r)}n.prototype.run=function(t,n,r,i){this._init(t,n,r,i);for(var o=0,a=this.dataset.length;o<a;o++)if(1!==this._processed[o]){this._processed[o]=1,this.clusters.push([o]);var s=this.clusters.length-1;this._orderedList.push(o);var l=new e(null,null,"asc"),u=this._regionQuery(o);void 0!==this._distanceToCore(o)&&(this._updateQueue(o,u,l),this._expandCluster(s,l))}return this.clusters},n.prototype.getReachabilityPlot=function(){for(var t=[],e=0,n=this._orderedList.length;e<n;e++){var r=this._orderedList[e],i=this._reachability[r];t.push([r,i])}return t},n.prototype._init=function(t,e,n,r){if(t){if(!(t instanceof Array))throw Error("Dataset must be of type array, "+typeof t+" given");this.dataset=t,this.clusters=[],this._reachability=new Array(this.dataset.length),this._processed=new Array(this.dataset.length),this._coreDistance=0,this._orderedList=[]}e&&(this.epsilon=e),n&&(this.minPts=n),r&&(this.distance=r)},n.prototype._updateQueue=function(t,e,n){var r=this;this._coreDistance=this._distanceToCore(t),e.forEach((function(e){if(void 0===r._processed[e]){var i=r.distance(r.dataset[t],r.dataset[e]),o=Math.max(r._coreDistance,i);void 0===r._reachability[e]?(r._reachability[e]=o,n.insert(e,o)):o<r._reachability[e]&&(r._reachability[e]=o,n.remove(e),n.insert(e,o))}}))},n.prototype._expandCluster=function(t,e){for(var n=e.getElements(),r=0,i=n.length;r<i;r++){var o=n[r];if(void 0===this._processed[o]){var a=this._regionQuery(o);this._processed[o]=1,this.clusters[t].push(o),this._orderedList.push(o),void 0!==this._distanceToCore(o)&&(this._updateQueue(o,a,e),this._expandCluster(t,e))}}},n.prototype._distanceToCore=function(t){for(var e=this.epsilon,n=0;n<e;n++)if(this._regionQuery(t,n).length>=this.minPts)return n},n.prototype._regionQuery=function(t,e){e=e||this.epsilon;for(var n=[],r=0,i=this.dataset.length;r<i;r++)this.distance(this.dataset[t],this.dataset[r])<e&&n.push(r);return n},n.prototype._euclideanDistance=function(t,e){for(var n=0,r=Math.min(t.length,e.length);r--;)n+=(t[r]-e[r])*(t[r]-e[r]);return Math.sqrt(n)},t.exports&&(t.exports=n)})),fa=Ft((function(t){t.exports&&(t.exports={DBSCAN:ua,KMEANS:ca,OPTICS:pa,PriorityQueue:ha})})),da=function(t,e,n){for(var r=t.length,i=0,o=0;o<r;o++){var a=(t[o]||0)-(e[o]||0);i+=a*a}return n?Math.sqrt(i):i},ma=da,ga=function(t,e,n){var r=Math.abs(t-e);return n?r:r*r},ya=da;function va(t,e,n){n=n||[];for(var r=0;r<t;r++)n[r]=e;return n}var _a=function(t,e,n,r){var i=[],o=[],a=[],s=[],l=!1,u=r||1e4,c=t.length,h=t[0].length,p=h>0,f=[];if(n)i="kmrand"==n?function(t,e){for(var n={},r=[],i=e<<2,o=t.length,a=t[0].length>0;r.length<e&&i-- >0;){var s=t[Math.floor(Math.random()*o)],l=a?s.join("_"):""+s;n[l]||(n[l]=!0,r.push(s))}if(r.length<e)throw new Error("Error initializating clusters");return r}(t,e):"kmpp"==n?function(t,e){var n=t[0].length?ma:ga,r=[],i=t.length,o=t[0].length>0,a=t[Math.floor(Math.random()*i)];o&&a.join("_");for(r.push(a);r.length<e;){for(var s=[],l=r.length,u=0,c=[],h=0;h<i;h++){for(var p=1/0,f=0;f<l;f++){var d=n(t[h],r[f]);d<=p&&(p=d)}s[h]=p}for(var m=0;m<i;m++)u+=s[m];for(var g=0;g<i;g++)c[g]={i:g,v:t[g],pr:s[g]/u,cs:0};c.sort((function(t,e){return t.pr-e.pr})),c[0].cs=c[0].pr;for(var y=1;y<i;y++)c[y].cs=c[y-1].cs+c[y].pr;for(var v=Math.random(),_=0;_<i-1&&c[_++].cs<v;);r.push(c[_-1].v)}return r}(t,e):n;else for(var d={};i.length<e;){var m=Math.floor(Math.random()*c);d[m]||(d[m]=!0,i.push(t[m]))}do{va(e,0,f);for(var g=0;g<c;g++){for(var y=1/0,v=0,_=0;_<e;_++)(s=p?ya(t[g],i[_]):Math.abs(t[g]-i[_]))<=y&&(y=s,v=_);a[g]=v,f[v]++}for(var x=[],b=(o=[],0);b<e;b++)x[b]=p?va(h,0,x[b]):0,o[b]=i[b];if(p){for(var w=0;w<e;w++)i[w]=[];for(var E=0;E<c;E++)for(var S=x[a[E]],M=t[E],T=0;T<h;T++)S[T]+=M[T];l=!0;for(var C=0;C<e;C++){for(var I=i[C],A=x[C],L=o[C],P=f[C],R=0;R<h;R++)I[R]=A[R]/P||0;if(l)for(var D=0;D<h;D++)if(L[D]!=I[D]){l=!1;break}}}else{for(var N=0;N<c;N++)x[a[N]]+=t[N];for(var O=0;O<e;O++)i[O]=x[O]/f[O]||0;l=!0;for(var k=0;k<e;k++)if(o[k]!=i[k]){l=!1;break}}l=l||--u<=0}while(!l);return{it:1e4-u,k:e,idxs:a,centroids:i}};function xa(t,e){return w(wi(t[0],t[1]))===w(wi(e[0],e[1]))}function ba(t,e){if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error("Invalid GeoJSON object for "+e)}function wa(t){for(var e=t,n=[];e.parent;)n.unshift(e),e=e.parent;return n}var Ea={search:function(t,e,n,r){t.cleanDirty();var i=(r=r||{}).heuristic||Ea.heuristics.manhattan,o=r.closest||!1,a=new Ta((function(t){return t.f})),s=e;for(e.h=i(e,n),a.push(e);a.size()>0;){var l=a.pop();if(l===n)return wa(l);l.closed=!0;for(var u=t.neighbors(l),c=0,h=u.length;c<h;++c){var p=u[c];if(!p.closed&&!p.isWall()){var f=l.g+p.getCost(l),d=p.visited;(!d||f<p.g)&&(p.visited=!0,p.parent=l,p.h=p.h||i(p,n),p.g=f,p.f=p.g+p.h,t.markDirty(p),o&&(p.h<s.h||p.h===s.h&&p.g<s.g)&&(s=p),d?a.rescoreElement(p):a.push(p))}}}return o?wa(s):[]},heuristics:{manhattan:function(t,e){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)},diagonal:function(t,e){var n=Math.sqrt(2),r=Math.abs(e.x-t.x),i=Math.abs(e.y-t.y);return 1*(r+i)+(n-2)*Math.min(r,i)}},cleanNode:function(t){t.f=0,t.g=0,t.h=0,t.visited=!1,t.closed=!1,t.parent=null}};function Sa(t,e){e=e||{},this.nodes=[],this.diagonal=!!e.diagonal,this.grid=[];for(var n=0;n<t.length;n++){this.grid[n]=[];for(var r=0,i=t[n];r<i.length;r++){var o=new Ma(n,r,i[r]);this.grid[n][r]=o,this.nodes.push(o)}}this.init()}function Ma(t,e,n){this.x=t,this.y=e,this.weight=n}function Ta(t){this.content=[],this.scoreFunction=t}function Ca(t,e){for(var n=0;n<e.features.length;n++)if(fe(t,e.features[n]))return!0;return!1}function Ia(t){return function(){return t}}function Aa(t){return t[0]}function La(t){return t[1]}function Pa(){this._=null}function Ra(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function Da(t,e){var n=e,r=e.R,i=n.U;i?i.L===n?i.L=r:i.R=r:t._=r,r.U=i,n.U=r,n.R=r.L,n.R&&(n.R.U=n),r.L=n}function Na(t,e){var n=e,r=e.L,i=n.U;i?i.L===n?i.L=r:i.R=r:t._=r,r.U=i,n.U=r,n.L=r.R,n.L&&(n.L.U=n),r.R=n}function Oa(t){for(;t.L;)t=t.L;return t}function ka(t,e,n,r){var i=[null,null],o=as.push(i)-1;return i.left=t,i.right=e,n&&Fa(i,t,e,n),r&&Fa(i,e,t,r),is[t.index].halfedges.push(o),is[e.index].halfedges.push(o),i}function za(t,e,n){var r=[e,n];return r.left=t,r}function Fa(t,e,n,r){t[0]||t[1]?t.left===n?t[1]=r:t[0]=r:(t[0]=r,t.left=e,t.right=n)}function Ba(t,e,n,r,i){var o,a=t[0],s=t[1],l=a[0],u=a[1],c=0,h=1,p=s[0]-l,f=s[1]-u;if(o=e-l,p||!(o>0)){if(o/=p,p<0){if(o<c)return;o<h&&(h=o)}else if(p>0){if(o>h)return;o>c&&(c=o)}if(o=r-l,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>c&&(c=o)}else if(p>0){if(o<c)return;o<h&&(h=o)}if(o=n-u,f||!(o>0)){if(o/=f,f<0){if(o<c)return;o<h&&(h=o)}else if(f>0){if(o>h)return;o>c&&(c=o)}if(o=i-u,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(o<c)return;o<h&&(h=o)}return!(c>0||h<1)||(c>0&&(t[0]=[l+c*p,u+c*f]),h<1&&(t[1]=[l+h*p,u+h*f]),!0)}}}}}function Ua(t,e,n,r,i){var o=t[1];if(o)return!0;var a,s,l=t[0],u=t.left,c=t.right,h=u[0],p=u[1],f=c[0],d=c[1],m=(h+f)/2,g=(p+d)/2;if(d===p){if(m<e||m>=r)return;if(h>f){if(l){if(l[1]>=i)return}else l=[m,n];o=[m,i]}else{if(l){if(l[1]<n)return}else l=[m,i];o=[m,n]}}else if(s=g-(a=(h-f)/(d-p))*m,a<-1||a>1)if(h>f){if(l){if(l[1]>=i)return}else l=[(n-s)/a,n];o=[(i-s)/a,i]}else{if(l){if(l[1]<n)return}else l=[(i-s)/a,i];o=[(n-s)/a,n]}else if(p<d){if(l){if(l[0]>=r)return}else l=[e,a*e+s];o=[r,a*r+s]}else{if(l){if(l[0]<e)return}else l=[r,a*r+s];o=[e,a*e+s]}return t[0]=l,t[1]=o,!0}function Va(t,e){var n=t.site,r=e.left,i=e.right;return n===i&&(i=r,r=n),i?Math.atan2(i[1]-r[1],i[0]-r[0]):(n===r?(r=e[1],i=e[0]):(r=e[0],i=e[1]),Math.atan2(r[0]-i[0],i[1]-r[1]))}function Ga(t,e){return e[+(e.left!==t.site)]}function ja(t,e){return e[+(e.left===t.site)]}Sa.prototype.init=function(){this.dirtyNodes=[];for(var t=0;t<this.nodes.length;t++)Ea.cleanNode(this.nodes[t])},Sa.prototype.cleanDirty=function(){for(var t=0;t<this.dirtyNodes.length;t++)Ea.cleanNode(this.dirtyNodes[t]);this.dirtyNodes=[]},Sa.prototype.markDirty=function(t){this.dirtyNodes.push(t)},Sa.prototype.neighbors=function(t){var e=[],n=t.x,r=t.y,i=this.grid;return i[n-1]&&i[n-1][r]&&e.push(i[n-1][r]),i[n+1]&&i[n+1][r]&&e.push(i[n+1][r]),i[n]&&i[n][r-1]&&e.push(i[n][r-1]),i[n]&&i[n][r+1]&&e.push(i[n][r+1]),this.diagonal&&(i[n-1]&&i[n-1][r-1]&&e.push(i[n-1][r-1]),i[n+1]&&i[n+1][r-1]&&e.push(i[n+1][r-1]),i[n-1]&&i[n-1][r+1]&&e.push(i[n-1][r+1]),i[n+1]&&i[n+1][r+1]&&e.push(i[n+1][r+1])),e},Sa.prototype.toString=function(){for(var t,e,n,r,i=[],o=this.grid,a=0,s=o.length;a<s;a++){for(t=[],n=0,r=(e=o[a]).length;n<r;n++)t.push(e[n].weight);i.push(t.join(" "))}return i.join("\n")},Ma.prototype.toString=function(){return"["+this.x+" "+this.y+"]"},Ma.prototype.getCost=function(t){return t&&t.x!==this.x&&t.y!==this.y?1.41421*this.weight:this.weight},Ma.prototype.isWall=function(){return 0===this.weight},Ta.prototype={push:function(t){this.content.push(t),this.sinkDown(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.bubbleUp(0)),t},remove:function(t){var e=this.content.indexOf(t),n=this.content.pop();e!==this.content.length-1&&(this.content[e]=n,this.scoreFunction(n)<this.scoreFunction(t)?this.sinkDown(e):this.bubbleUp(e))},size:function(){return this.content.length},rescoreElement:function(t){this.sinkDown(this.content.indexOf(t))},sinkDown:function(t){for(var e=this.content[t];t>0;){var n=(t+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(e)<this.scoreFunction(r)))break;this.content[n]=e,this.content[t]=r,t=n}},bubbleUp:function(t){for(var e=this.content.length,n=this.content[t],r=this.scoreFunction(n);;){var i,o=t+1<<1,a=o-1,s=null;if(a<e){var l=this.content[a];(i=this.scoreFunction(l))<r&&(s=a)}if(o<e){var u=this.content[o];this.scoreFunction(u)<(null===s?r:i)&&(s=o)}if(null===s)break;this.content[t]=this.content[s],this.content[s]=n,t=s}}},Pa.prototype={constructor:Pa,insert:function(t,e){var n,r,i;if(t){if(e.P=t,e.N=t.N,t.N&&(t.N.P=e),t.N=e,t.R){for(t=t.R;t.L;)t=t.L;t.L=e}else t.R=e;n=t}else this._?(t=Oa(this._),e.P=null,e.N=t,t.P=t.L=e,n=t):(e.P=e.N=null,this._=e,n=null);for(e.L=e.R=null,e.U=n,e.C=!0,t=e;n&&n.C;)n===(r=n.U).L?(i=r.R)&&i.C?(n.C=i.C=!1,r.C=!0,t=r):(t===n.R&&(Da(this,n),n=(t=n).U),n.C=!1,r.C=!0,Na(this,r)):(i=r.L)&&i.C?(n.C=i.C=!1,r.C=!0,t=r):(t===n.L&&(Na(this,n),n=(t=n).U),n.C=!1,r.C=!0,Da(this,r)),n=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var e,n,r,i=t.U,o=t.L,a=t.R;if(n=o?a?Oa(a):o:a,i?i.L===t?i.L=n:i.R=n:this._=n,o&&a?(r=n.C,n.C=t.C,n.L=o,o.U=n,n!==a?(i=n.U,n.U=t.U,t=n.R,i.L=t,n.R=a,a.U=n):(n.U=i,i=n,t=n.R)):(r=t.C,t=n),t&&(t.U=i),!r)if(t&&t.C)t.C=!1;else{do{if(t===this._)break;if(t===i.L){if((e=i.R).C&&(e.C=!1,i.C=!0,Da(this,i),e=i.R),e.L&&e.L.C||e.R&&e.R.C){e.R&&e.R.C||(e.L.C=!1,e.C=!0,Na(this,e),e=i.R),e.C=i.C,i.C=e.R.C=!1,Da(this,i),t=this._;break}}else if((e=i.L).C&&(e.C=!1,i.C=!0,Na(this,i),e=i.L),e.L&&e.L.C||e.R&&e.R.C){e.L&&e.L.C||(e.R.C=!1,e.C=!0,Da(this,e),e=i.L),e.C=i.C,i.C=e.L.C=!1,Na(this,i),t=this._;break}e.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var Ha,qa=[];function Wa(){Ra(this),this.x=this.y=this.arc=this.site=this.cy=null}function Xa(t){var e=t.P,n=t.N;if(e&&n){var r=e.site,i=t.site,o=n.site;if(r!==o){var a=i[0],s=i[1],l=r[0]-a,u=r[1]-s,c=o[0]-a,h=o[1]-s,p=2*(l*h-u*c);if(!(p>=-ls)){var f=l*l+u*u,d=c*c+h*h,m=(h*f-u*d)/p,g=(l*d-c*f)/p,y=qa.pop()||new Wa;y.arc=t,y.site=i,y.x=m+a,y.y=(y.cy=g+s)+Math.sqrt(m*m+g*g),t.circle=y;for(var v=null,_=os._;_;)if(y.y<_.y||y.y===_.y&&y.x<=_.x){if(!_.L){v=_.P;break}_=_.L}else{if(!_.R){v=_;break}_=_.R}os.insert(v,y),v||(Ha=y)}}}}function Za(t){var e=t.circle;e&&(e.P||(Ha=e.N),os.remove(e),qa.push(e),Ra(e),t.circle=null)}var Ya=[];function Ja(){Ra(this),this.edge=this.site=this.circle=null}function Ka(t){var e=Ya.pop()||new Ja;return e.site=t,e}function Qa(t){Za(t),rs.remove(t),Ya.push(t),Ra(t)}function $a(t){var e=t.circle,n=e.x,r=e.cy,i=[n,r],o=t.P,a=t.N,s=[t];Qa(t);for(var l=o;l.circle&&Math.abs(n-l.circle.x)<ss&&Math.abs(r-l.circle.cy)<ss;)o=l.P,s.unshift(l),Qa(l),l=o;s.unshift(l),Za(l);for(var u=a;u.circle&&Math.abs(n-u.circle.x)<ss&&Math.abs(r-u.circle.cy)<ss;)a=u.N,s.push(u),Qa(u),u=a;s.push(u),Za(u);var c,h=s.length;for(c=1;c<h;++c)u=s[c],l=s[c-1],Fa(u.edge,l.site,u.site,i);l=s[0],(u=s[h-1]).edge=ka(l.site,u.site,null,i),Xa(l),Xa(u)}function ts(t){for(var e,n,r,i,o=t[0],a=t[1],s=rs._;s;)if((r=es(s,a)-o)>ss)s=s.L;else{if(!((i=o-ns(s,a))>ss)){r>-ss?(e=s.P,n=s):i>-ss?(e=s,n=s.N):e=n=s;break}if(!s.R){e=s;break}s=s.R}!function(t){is[t.index]={site:t,halfedges:[]}}(t);var l=Ka(t);if(rs.insert(e,l),e||n){if(e===n)return Za(e),n=Ka(e.site),rs.insert(l,n),l.edge=n.edge=ka(e.site,l.site),Xa(e),void Xa(n);if(n){Za(e),Za(n);var u=e.site,c=u[0],h=u[1],p=t[0]-c,f=t[1]-h,d=n.site,m=d[0]-c,g=d[1]-h,y=2*(p*g-f*m),v=p*p+f*f,_=m*m+g*g,x=[(g*v-f*_)/y+c,(p*_-m*v)/y+h];Fa(n.edge,u,d,x),l.edge=ka(u,t,null,x),n.edge=ka(t,d,null,x),Xa(e),Xa(n)}else l.edge=ka(e.site,l.site)}}function es(t,e){var n=t.site,r=n[0],i=n[1],o=i-e;if(!o)return r;var a=t.P;if(!a)return-1/0;var s=(n=a.site)[0],l=n[1],u=l-e;if(!u)return s;var c=s-r,h=1/o-1/u,p=c/u;return h?(-p+Math.sqrt(p*p-2*h*(c*c/(-2*u)-l+u/2+i-o/2)))/h+r:(r+s)/2}function ns(t,e){var n=t.N;if(n)return es(n,e);var r=t.site;return r[1]===e?r[0]:1/0}var rs,is,os,as,ss=1e-6,ls=1e-12;function us(t,e){return e[1]-t[1]||e[0]-t[0]}function cs(t,e){var n,r,i,o=t.sort(us).pop();for(as=[],is=new Array(t.length),rs=new Pa,os=new Pa;;)if(i=Ha,o&&(!i||o[1]<i.y||o[1]===i.y&&o[0]<i.x))o[0]===n&&o[1]===r||(ts(o),n=o[0],r=o[1]),o=t.pop();else{if(!i)break;$a(i.arc)}if(function(){for(var t,e,n,r,i=0,o=is.length;i<o;++i)if((t=is[i])&&(r=(e=t.halfedges).length)){var a=new Array(r),s=new Array(r);for(n=0;n<r;++n)a[n]=n,s[n]=Va(t,as[e[n]]);for(a.sort((function(t,e){return s[e]-s[t]})),n=0;n<r;++n)s[n]=e[a[n]];for(n=0;n<r;++n)e[n]=s[n]}}(),e){var a=+e[0][0],s=+e[0][1],l=+e[1][0],u=+e[1][1];!function(t,e,n,r){for(var i,o=as.length;o--;)Ua(i=as[o],t,e,n,r)&&Ba(i,t,e,n,r)&&(Math.abs(i[0][0]-i[1][0])>ss||Math.abs(i[0][1]-i[1][1])>ss)||delete as[o]}(a,s,l,u),function(t,e,n,r){var i,o,a,s,l,u,c,h,p,f,d,m,g=is.length,y=!0;for(i=0;i<g;++i)if(o=is[i]){for(a=o.site,s=(l=o.halfedges).length;s--;)as[l[s]]||l.splice(s,1);for(s=0,u=l.length;s<u;)d=(f=ja(o,as[l[s]]))[0],m=f[1],h=(c=Ga(o,as[l[++s%u]]))[0],p=c[1],(Math.abs(d-h)>ss||Math.abs(m-p)>ss)&&(l.splice(s,0,as.push(za(a,f,Math.abs(d-t)<ss&&r-m>ss?[t,Math.abs(h-t)<ss?p:r]:Math.abs(m-r)<ss&&n-d>ss?[Math.abs(p-r)<ss?h:n,r]:Math.abs(d-n)<ss&&m-e>ss?[n,Math.abs(h-n)<ss?p:e]:Math.abs(m-e)<ss&&d-t>ss?[Math.abs(p-e)<ss?h:t,e]:null))-1),++u);u&&(y=!1)}if(y){var v,_,x,b=1/0;for(i=0,y=null;i<g;++i)(o=is[i])&&(x=(v=(a=o.site)[0]-t)*v+(_=a[1]-e)*_)<b&&(b=x,y=o);if(y){var w=[t,e],E=[t,r],S=[n,r],M=[n,e];y.halfedges.push(as.push(za(a=y.site,w,E))-1,as.push(za(a,E,S))-1,as.push(za(a,S,M))-1,as.push(za(a,M,w))-1)}}for(i=0;i<g;++i)(o=is[i])&&(o.halfedges.length||delete is[i])}(a,s,l,u)}this.edges=as,this.cells=is,rs=os=as=is=null}function hs(t){return(t=t.slice()).push(t[0]),u([t])}function ps(t,e,n,r){var i=(r=r||{}).steps||64,o=r.units||"kilometers",a=r.angle||0,s=r.pivot||t,l=r.properties||t.properties||{};if(!t)throw new Error("center is required");if(!e)throw new Error("xSemiAxis is required");if(!n)throw new Error("ySemiAxis is required");if(!I(r))throw new Error("options must be an object");if(!C(i))throw new Error("steps must be a number");if(!C(a))throw new Error("angle must be a number");var c=K(t);if("degrees"===o)var h=S(a);else e=Si(t,e,90,{units:o}),n=Si(t,n,0,{units:o}),e=K(e)[0]-c[0],n=K(n)[1]-c[1];for(var p=[],f=0;f<i;f+=1){var d=-360*f/i,m=e*n/Math.sqrt(Math.pow(n,2)+Math.pow(e,2)*Math.pow(fs(d),2)),g=e*n/Math.sqrt(Math.pow(e,2)+Math.pow(n,2)/Math.pow(fs(d),2));if(d<-90&&d>=-270&&(m=-m),d<-180&&d>=-360&&(g=-g),"degrees"===o){var y=m*Math.cos(h)+g*Math.sin(h),v=g*Math.cos(h)-m*Math.sin(h);m=y,g=v}p.push([m+c[0],g+c[1]])}return p.push(p[0]),"degrees"===o?u([p],l):No(u([p],l),a,{pivot:s})}function fs(t){var e=t*Math.PI/180;return Math.tan(e)}function ds(t,e){void 0===e&&(e={});var n=0,r=0,i=0;return B(t,(function(t,o,a){var s=e.weight?null==a?void 0:a[e.weight]:void 0;if(!C(s=null==s?1:s))throw new Error("weight value must be a number for feature index "+o);(s=Number(s))>0&&R(t,(function(t){n+=t[0]*s,r+=t[1]*s,i+=s}))})),s([n/i,r/i],e.properties,e)}function ms(t,e,n,r,i){var o=r.tolerance||.001,a=0,l=0,u=0,c=0;if(k(n,(function(e){var n,r=null===(n=e.properties)||void 0===n?void 0:n.weight,i=null==r?1:r;if(!C(i=Number(i)))throw new Error("weight value must be a number");if(i>0){c+=1;var o=i*ge(e,t);0===o&&(o=1);var s=i/o;a+=e.geometry.coordinates[0]*s,l+=e.geometry.coordinates[1]*s,u+=s}})),c<1)throw new Error("no features to measure");var h=a/u,p=l/u;return 1===c||0===i||Math.abs(h-e[0])<o&&Math.abs(p-e[1])<o?s([h,p],{medianCandidates:r.medianCandidates}):(r.medianCandidates.push([h,p]),ms([h,p],t,n,r,i-1))}function gs(t,e){return{x:t[0]-e[0],y:t[1]-e[1]}}function ys(t,e){var n=0,r=0;R(t,(function(i,o,a,s,l){l>n&&(n=l,r=o,e.push([]));var u=o-r,c=t.coordinates[l][u+1],h=i[0],p=i[1],f=c[0],d=c[1];e[l].push([.75*h+.25*f,.75*p+.25*d]),e[l].push([.25*h+.75*f,.25*p+.75*d])}),!0),e.forEach((function(t){t.push(t[0])}))}function vs(t,e){var n=0,r=0,i=0;R(t,(function(o,a,s,l,u){l>i&&(i=l,r=a,e.push([[]])),u>n&&(n=u,r=a,e[l].push([]));var c=a-r,h=t.coordinates[l][u][c+1],p=o[0],f=o[1],d=h[0],m=h[1];e[l][u].push([.75*p+.25*d,.75*f+.25*m]),e[l][u].push([.25*p+.75*d,.25*f+.75*m])}),!0),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function _s(t,e,n){void 0===n&&(n=2);var r=K(t),i=K(e),o=r[0]-i[0],a=r[1]-i[1];return 1===n?Math.abs(o)+Math.abs(a):Math.pow(Math.pow(o,n)+Math.pow(a,n),1/n)}function xs(t,e){var n=(e=e||{}).threshold||1e4,r=e.p||2,i=e.binary||!1,o=e.alpha||-1,a=e.standardization||!1,s=[];k(t,(function(t){s.push(dn(t))}));for(var l=[],u=0;u<s.length;u++)l[u]=[];for(u=0;u<s.length;u++)for(var c=u;c<s.length;c++){u===c&&(l[u][c]=0);var h=_s(s[u],s[c],r);l[u][c]=h,l[c][u]=h}for(u=0;u<s.length;u++)for(c=0;c<s.length;c++)0!==(h=l[u][c])&&(l[u][c]=i?h<=n?1:0:h<=n?Math.pow(h,o):0);if(a)for(u=0;u<s.length;u++){var p=l[u].reduce((function(t,e){return t+e}),0);for(c=0;c<s.length;c++)l[u][c]=l[u][c]/p}return l}function bs(t){for(var e=0,n=0,r=t;n<r.length;n++)e+=r[n];return e/t.length}function ws(t,e){return void 0===e&&(e={}),Ss(t,"mercator",e)}function Es(t,e){return void 0===e&&(e={}),Ss(t,"wgs84",e)}function Ss(t,e,n){void 0===n&&(n={});var r=(n=n||{}).mutate;if(!t)throw new Error("geojson is required");return Array.isArray(t)&&C(t[0])?t="mercator"===e?Ms(t):Ts(t):(!0!==r&&(t=be(t)),R(t,(function(t){var n="mercator"===e?Ms(t):Ts(t);t[0]=n[0],t[1]=n[1]}))),t}function Ms(t){var e=Math.PI/180,n=6378137,r=20037508.342789244,i=[n*(Math.abs(t[0])<=180?t[0]:t[0]-360*function(t){return t<0?-1:t>0?1:0}(t[0]))*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i}function Ts(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e]}cs.prototype={constructor:cs,polygons:function(){var t=this.edges;return this.cells.map((function(e){var n=e.halfedges.map((function(n){return Ga(e,t[n])}));return n.data=e.site.data,n}))},triangles:function(){var t=[],e=this.edges;return this.cells.forEach((function(n,r){if(o=(i=n.halfedges).length)for(var i,o,a,s,l,u,c=n.site,h=-1,p=e[i[o-1]],f=p.left===c?p.right:p.left;++h<o;)a=f,f=(p=e[i[h]]).left===c?p.right:p.left,a&&f&&r<a.index&&r<f.index&&(l=a,u=f,((s=c)[0]-u[0])*(l[1]-s[1])-(s[0]-l[0])*(u[1]-s[1])<0)&&t.push([c.data,a.data,f.data])})),t},links:function(){return this.edges.filter((function(t){return t.right})).map((function(t){return{source:t.left.data,target:t.right.data}}))},find:function(t,e,n){for(var r,i,o=this,a=o._found||0,s=o.cells.length;!(i=o.cells[a]);)if(++a>=s)return null;var l=t-i.site[0],u=e-i.site[1],c=l*l+u*u;do{i=o.cells[r=a],a=null,i.halfedges.forEach((function(n){var r=o.edges[n],s=r.left;if(s!==i.site&&s||(s=r.right)){var l=t-s[0],u=e-s[1],h=l*l+u*u;h<c&&(c=h,a=s.index)}}))}while(null!==a);return o._found=r,null==n||c<=n*n?i.site:null}};var Cs=Object.freeze({__proto__:null,toMercator:ws,toWgs84:Es});function Is(t){return Array.isArray(t)?Ds(t):t&&t.bbox?Ds(t.bbox):[360*Rs(),180*Rs()]}function As(t,e){void 0===e&&(e={}),null==t&&(t=1);for(var n=[],r=0;r<t;r++)n.push(s(Is(e.bbox)));return f(n)}function Ls(t,e){void 0===e&&(e={}),null==t&&(t=1),C(e.num_vertices)&&void 0!==e.num_vertices||(e.num_vertices=10),C(e.max_radial_length)&&void 0!==e.max_radial_length||(e.max_radial_length=10);for(var n=[],r=function(t){var r,i=[],o=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(Array(e.num_vertices+1)).map(Math.random);o.forEach((function(t,e,n){n[e]=e>0?t+n[e-1]:t})),o.forEach((function(t){t=2*t*Math.PI/o[o.length-1];var n=Math.random();i.push([n*(e.max_radial_length||10)*Math.sin(t),n*(e.max_radial_length||10)*Math.cos(t)])})),i[i.length-1]=i[0],i=i.map((r=Is(e.bbox),function(t){return[t[0]+r[0],t[1]+r[1]]})),n.push(u([i]))},i=0;i<t;i++)r();return f(n)}function Ps(t,e){if(void 0===e&&(e={}),!I(e=e||{}))throw new Error("options is invalid");var n=e.bbox,r=e.num_vertices,i=e.max_length,o=e.max_rotation;null==t&&(t=1),(!C(r)||void 0===r||r<2)&&(r=10),C(i)&&void 0!==i||(i=1e-4),C(o)&&void 0!==o||(o=Math.PI/8);for(var a=[],s=0;s<t;s++){for(var l=[Is(n)],u=0;u<r-1;u++){var c=(0===u?2*Math.random()*Math.PI:Math.tan((l[u][1]-l[u-1][1])/(l[u][0]-l[u-1][0])))+(Math.random()-.5)*o*2,p=Math.random()*i;l.push([l[u][0]+p*Math.cos(c),l[u][1]+p*Math.sin(c)])}a.push(h(l))}return f(a)}function Rs(){return Math.random()-.5}function Ds(t){return[Math.random()*(t[2]-t[0])+t[0],Math.random()*(t[3]-t[1])+t[1]]}var Ns=Object.freeze({__proto__:null,randomPosition:Is,randomPoint:As,randomPolygon:Ls,randomLineString:Ps});function Os(t,e){if(!t)throw new Error("geojson is required");if("FeatureCollection"!==t.type)throw new Error("geojson must be a FeatureCollection");if(null==e)throw new Error("filter is required");var n=[];return k(t,(function(t){Bs(t.properties,e)&&n.push(t)})),f(n)}function ks(t,e,n){if(!t)throw new Error("geojson is required");if("FeatureCollection"!==t.type)throw new Error("geojson must be a FeatureCollection");if(null==e)throw new Error("property is required");for(var r=Fs(t,e),i=Object.keys(r),o=0;o<i.length;o++){for(var a=i[o],s=r[a],l=[],u=0;u<s.length;u++)l.push(t.features[s[u]]);n(f(l),a,o)}}function zs(t,e,n,r){var i=r;return ks(t,e,(function(t,e,o){i=0===o&&void 0===r?t:n(i,t,e,o)})),i}function Fs(t,e){var n={};return k(t,(function(t,r){var i=t.properties||{};if(Object.prototype.hasOwnProperty.call(i,String(e))){var o=i[e];Object.prototype.hasOwnProperty.call(n,o)?n[o].push(r):n[o]=[r]}})),n}function Bs(t,e){if(void 0===t)return!1;var n=typeof e;if("number"===n||"string"===n)return Object.prototype.hasOwnProperty.call(t,e);if(Array.isArray(e)){for(var r=0;r<e.length;r++)if(!Bs(t,e[r]))return!1;return!0}return Us(t,e)}function Us(t,e){for(var n=Object.keys(e),r=0;r<n.length;r++){var i=n[r];if(t[i]!==e[i])return!1}return!0}function Vs(t,e){if(!e)return{};if(!e.length)return{};for(var n={},r=0;r<e.length;r++){var i=e[r];Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n}var Gs=Object.freeze({__proto__:null,getCluster:Os,clusterEach:ks,clusterReduce:zs,createBins:Fs,applyFilter:Bs,propertiesContainsFilter:Us,filterProperties:Vs}),js=function(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null};function Hs(t,e){return t>e?1:t<e?-1:0}function qs(t,e,n){for(var r=new js(null,null),i=r,o=r;;){var a=n(t,e.key);if(a<0){if(null===e.left)break;if(n(t,e.left.key)<0){var s=e.left;if(e.left=s.right,s.right=e,null===(e=s).left)break}o.left=e,o=e,e=e.left}else{if(!(a>0))break;if(null===e.right)break;if(n(t,e.right.key)>0){s=e.right;if(e.right=s.left,s.left=e,null===(e=s).right)break}i.right=e,i=e,e=e.right}}return i.right=e.left,o.left=e.right,e.left=r.right,e.right=r.left,e}function Ws(t,e,n,r){var i=new js(t,e);if(null===n)return i.left=i.right=null,i;var o=r(t,(n=qs(t,n,r)).key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function Xs(t,e,n){var r=null,i=null;if(e){var o=n((e=qs(t,e,n)).key,t);0===o?(r=e.left,i=e.right):o<0?(i=e.right,e.right=null,r=e):(r=e.left,e.left=null,i=e)}return{left:r,right:i}}function Zs(t,e,n,r,i){if(t){r(e+(n?"└── ":"├── ")+i(t)+"\n");var o=e+(n?" ":"│ ");t.left&&Zs(t.left,o,!1,r,i),t.right&&Zs(t.right,o,!0,r,i)}}var Ys=function(){function t(t){void 0===t&&(t=Hs),this._root=null,this._size=0,this._comparator=t}return t.prototype.insert=function(t,e){return this._size++,this._root=Ws(t,e,this._root,this._comparator)},t.prototype.add=function(t,e){var n=new js(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,i=qs(t,this._root,r),o=r(t,i.key);return 0===o?this._root=i:(o<0?(n.left=i.left,n.right=i,i.left=null):o>0&&(n.right=i.right,n.left=i,i.right=null),this._size++,this._root=n),this._root},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},t.prototype._remove=function(t,e,n){var r;return null===e?null:0===n(t,(e=qs(t,e,n)).key)?(null===e.left?r=e.right:(r=qs(t,e.left,n)).right=e.right,this._size--,r):e},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=qs(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},t.prototype.findStatic=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return e;e=r<0?e.left:e.right}return null},t.prototype.find=function(t){return this._root&&(this._root=qs(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root},t.prototype.contains=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return!0;e=r<0?e.left:e.right}return!1},t.prototype.forEach=function(t,e){for(var n=this._root,r=[],i=!1;!i;)null!==n?(r.push(n),n=n.left):0!==r.length?(n=r.pop(),t.call(e,n),n=n.right):i=!0;return this},t.prototype.range=function(t,e,n,r){for(var i=[],o=this._comparator,a=this._root;0!==i.length||a;)if(a)i.push(a),a=a.left;else{if(o((a=i.pop()).key,e)>0)break;if(o(a.key,t)>=0&&n.call(r,a))return this;a=a.right}return this},t.prototype.keys=function(){var t=[];return this.forEach((function(e){var n=e.key;return t.push(n)})),t},t.prototype.values=function(){var t=[];return this.forEach((function(e){var n=e.data;return t.push(n)})),t},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},t.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t},t.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t},t.prototype.at=function(t){for(var e=this._root,n=!1,r=0,i=[];!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right}else n=!0;return null},t.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?(n=e,e=e.left):e=e.right}return n},t.prototype.prev=function(t){var e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?e=e.left:(n=e,e=e.right)}return n},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return function(t){for(var e=t,n=[],r=!1,i=new js(null,null),o=i;!r;)e?(n.push(e),e=e.left):n.length>0?e=(e=o=o.next=n.pop()).right:r=!0;return o.next=null,i.next}(this._root)},t.prototype.load=function(t,e,n){void 0===e&&(e=[]),void 0===n&&(n=!1);var r=t.length,i=this._comparator;if(n&&Qs(t,e,0,r-1,i),null===this._root)this._root=Js(t,e,0,r),this._size=r;else{var o=function(t,e,n){for(var r=new js(null,null),i=r,o=t,a=e;null!==o&&null!==a;)n(o.key,a.key)<0?(i.next=o,o=o.next):(i.next=a,a=a.next),i=i.next;null!==o?i.next=o:null!==a&&(i.next=a);return r.next}(this.toList(),function(t,e){for(var n=new js(null,null),r=n,i=0;i<t.length;i++)r=r.next=new js(t[i],e[i]);return r.next=null,n.next}(t,e),i);r=this._size+r,this._root=Ks({head:o},0,r)}return this},t.prototype.isEmpty=function(){return null===this._root},Object.defineProperty(t.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),t.prototype.toString=function(t){void 0===t&&(t=function(t){return String(t.key)});var e=[];return Zs(this._root,"",!0,(function(t){return e.push(t)}),t),e.join("")},t.prototype.update=function(t,e,n){var r=this._comparator,i=Xs(t,this._root,r),o=i.left,a=i.right;r(t,e)<0?a=Ws(e,n,a,r):o=Ws(e,n,o,r),this._root=function(t,e,n){return null===e?t:(null===t||((e=qs(t.key,e,n)).left=t),e)}(o,a,r)},t.prototype.split=function(t){return Xs(t,this._root,this._comparator)},t}();function Js(t,e,n,r){var i=r-n;if(i>0){var o=n+Math.floor(i/2),a=t[o],s=e[o],l=new js(a,s);return l.left=Js(t,e,n,o),l.right=Js(t,e,o+1,r),l}return null}function Ks(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=Ks(t,e,i),a=t.head;return a.left=o,t.head=t.head.next,a.right=Ks(t,i+1,n),a}return null}function Qs(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],a=n-1,s=r+1;;){do{a++}while(i(t[a],o)<0);do{s--}while(i(t[s],o)>0);if(a>=s)break;var l=t[a];t[a]=t[s],t[s]=l,l=e[a],e[a]=e[s],e[s]=l}Qs(t,e,n,s,i),Qs(t,e,s+1,r,i)}}function $s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function el(t,e,n){return e&&tl(t.prototype,e),n&&tl(t,n),t}var nl=function(t,e){return t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y},rl=function(t,e){if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;var n=t.ll.x<e.ll.x?e.ll.x:t.ll.x,r=t.ur.x<e.ur.x?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y<e.ll.y?e.ll.y:t.ll.y},ur:{x:r,y:t.ur.y<e.ur.y?t.ur.y:e.ur.y}}},il=Number.EPSILON;void 0===il&&(il=Math.pow(2,-52));var ol=il*il,al=function(t,e){if(-il<t&&t<il&&-il<e&&e<il)return 0;var n=t-e;return n*n<ol*t*e?0:t<e?-1:1},sl=function(){function t(){$s(this,t),this.reset()}return el(t,[{key:"reset",value:function(){this.xRounder=new ll,this.yRounder=new ll}},{key:"round",value:function(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}}]),t}(),ll=function(){function t(){$s(this,t),this.tree=new Ys,this.round(0)}return el(t,[{key:"round",value:function(t){var e=this.tree.add(t),n=this.tree.prev(e);if(null!==n&&0===al(e.key,n.key))return this.tree.remove(t),n.key;var r=this.tree.next(e);return null!==r&&0===al(e.key,r.key)?(this.tree.remove(t),r.key):t}}]),t}(),ul=new sl,cl=function(t,e){return t.x*e.y-t.y*e.x},hl=function(t,e){return t.x*e.x+t.y*e.y},pl=function(t,e,n){var r={x:e.x-t.x,y:e.y-t.y},i={x:n.x-t.x,y:n.y-t.y},o=cl(r,i);return al(o,0)},fl=function(t){return Math.sqrt(hl(t,t))},dl=function(t,e,n){var r={x:e.x-t.x,y:e.y-t.y},i={x:n.x-t.x,y:n.y-t.y};return hl(i,r)/fl(i)/fl(r)},ml=function(t,e,n){return 0===e.y?null:{x:t.x+e.x/e.y*(n-t.y),y:n}},gl=function(t,e,n){return 0===e.x?null:{x:n,y:t.y+e.y/e.x*(n-t.x)}},yl=function(){function t(e,n){$s(this,t),void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return el(t,null,[{key:"compare",value:function(e,n){var r=t.comparePoints(e.point,n.point);return 0!==r?r:(e.point!==n.point&&e.link(n),e.isLeft!==n.isLeft?e.isLeft?1:-1:_l.compare(e.segment,n.segment))}},{key:"comparePoints",value:function(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}}]),el(t,[{key:"link",value:function(t){if(t.point===this.point)throw new Error("Tried to link already linked events");for(var e=t.point.events,n=0,r=e.length;n<r;n++){var i=e[n];this.point.events.push(i),i.point=this.point}this.checkForConsuming()}},{key:"checkForConsuming",value:function(){for(var t=this.point.events.length,e=0;e<t;e++){var n=this.point.events[e];if(void 0===n.segment.consumedBy)for(var r=e+1;r<t;r++){var i=this.point.events[r];void 0===i.consumedBy&&n.otherSE.point.events===i.otherSE.point.events&&n.segment.consume(i.segment)}}}},{key:"getAvailableLinkedEvents",value:function(){for(var t=[],e=0,n=this.point.events.length;e<n;e++){var r=this.point.events[e];r!==this&&!r.segment.ringOut&&r.segment.isInResult()&&t.push(r)}return t}},{key:"getLeftmostComparator",value:function(t){var e=this,n=new Map,r=function(r){var i,o,a,s,l,u=r.otherSE;n.set(r,{sine:(i=e.point,o=t.point,a=u.point,s={x:o.x-i.x,y:o.y-i.y},l={x:a.x-i.x,y:a.y-i.y},cl(l,s)/fl(l)/fl(s)),cosine:dl(e.point,t.point,u.point)})};return function(t,e){n.has(t)||r(t),n.has(e)||r(e);var i=n.get(t),o=i.sine,a=i.cosine,s=n.get(e),l=s.sine,u=s.cosine;return o>=0&&l>=0?a<u?1:a>u?-1:0:o<0&&l<0?a<u?-1:a>u?1:0:l<o?-1:l>o?1:0}}}]),t}(),vl=0,_l=function(){function t(e,n,r,i){$s(this,t),this.id=++vl,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=r,this.windings=i}return el(t,null,[{key:"compare",value:function(t,e){var n=t.leftSE.point.x,r=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(o<n)return 1;if(i<r)return-1;var a=t.leftSE.point.y,s=e.leftSE.point.y,l=t.rightSE.point.y,u=e.rightSE.point.y;if(n<r){if(s<a&&s<l)return 1;if(s>a&&s>l)return-1;var c=t.comparePoint(e.leftSE.point);if(c<0)return 1;if(c>0)return-1;var h=e.comparePoint(t.rightSE.point);return 0!==h?h:-1}if(n>r){if(a<s&&a<u)return-1;if(a>s&&a>u)return 1;var p=e.comparePoint(t.leftSE.point);if(0!==p)return p;var f=t.comparePoint(e.rightSE.point);return f<0?1:f>0?-1:1}if(a<s)return-1;if(a>s)return 1;if(i<o){var d=e.comparePoint(t.rightSE.point);if(0!==d)return d}if(i>o){var m=t.comparePoint(e.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(i!==o){var g=l-a,y=i-n,v=u-s,_=o-r;if(g>y&&v<_)return 1;if(g<y&&v>_)return-1}return i>o?1:i<o||l<u?-1:l>u?1:t.id<e.id?-1:t.id>e.id?1:0}}]),el(t,[{key:"replaceRightSE",value:function(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t<e?t:e},ur:{x:this.rightSE.point.x,y:t>e?t:e}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}},{key:"comparePoint",value:function(t){if(this.isAnEndpoint(t))return 0;var e=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x<e.x?1:-1;var i=(t.y-e.y)/r.y,o=e.x+i*r.x;if(t.x===o)return 0;var a=(t.x-e.x)/r.x,s=e.y+a*r.y;return t.y===s?0:t.y<s?-1:1}},{key:"getIntersection",value:function(t){var e=this.bbox(),n=t.bbox(),r=rl(e,n);if(null===r)return null;var i=this.leftSE.point,o=this.rightSE.point,a=t.leftSE.point,s=t.rightSE.point,l=nl(e,a)&&0===this.comparePoint(a),u=nl(n,i)&&0===t.comparePoint(i),c=nl(e,s)&&0===this.comparePoint(s),h=nl(n,o)&&0===t.comparePoint(o);if(u&&l)return h&&!c?o:!h&&c?s:null;if(u)return c&&i.x===s.x&&i.y===s.y?null:i;if(l)return h&&o.x===a.x&&o.y===a.y?null:a;if(h&&c)return null;if(h)return o;if(c)return s;var p=function(t,e,n,r){if(0===e.x)return gl(n,r,t.x);if(0===r.x)return gl(t,e,n.x);if(0===e.y)return ml(n,r,t.y);if(0===r.y)return ml(t,e,n.y);var i=cl(e,r);if(0==i)return null;var o={x:n.x-t.x,y:n.y-t.y},a=cl(o,e)/i,s=cl(o,r)/i;return{x:(t.x+s*e.x+(n.x+a*r.x))/2,y:(t.y+s*e.y+(n.y+a*r.y))/2}}(i,this.vector(),a,t.vector());return null===p?null:nl(r,p)?ul.round(p.x,p.y):null}},{key:"split",value:function(e){var n=[],r=void 0!==e.events,i=new yl(e,!0),o=new yl(e,!1),a=this.rightSE;this.replaceRightSE(o),n.push(o),n.push(i);var s=new t(i,a,this.rings.slice(),this.windings.slice());return yl.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),yl.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}},{key:"swapEvents",value:function(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,n=this.windings.length;e<n;e++)this.windings[e]*=-1}},{key:"consume",value:function(e){for(var n=this,r=e;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;var i=t.compare(n,r);if(0!==i){if(i>0){var o=n;n=r,r=o}if(n.prev===r){var a=n;n=r,r=a}for(var s=0,l=r.rings.length;s<l;s++){var u=r.rings[s],c=r.windings[s],h=n.rings.indexOf(u);-1===h?(n.rings.push(u),n.windings.push(c)):n.windings[h]+=c}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}},{key:"prevInResult",value:function(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}},{key:"beforeState",value:function(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){var t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}},{key:"afterState",value:function(){if(void 0!==this._afterState)return this._afterState;var t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};for(var e=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys,i=0,o=this.rings.length;i<o;i++){var a=this.rings[i],s=this.windings[i],l=e.indexOf(a);-1===l?(e.push(a),n.push(s)):n[l]+=s}for(var u=[],c=[],h=0,p=e.length;h<p;h++)if(0!==n[h]){var f=e[h],d=f.poly;if(-1===c.indexOf(d))if(f.isExterior)u.push(d);else{-1===c.indexOf(d)&&c.push(d);var m=u.indexOf(f.poly);-1!==m&&u.splice(m,1)}}for(var g=0,y=u.length;g<y;g++){var v=u[g].multiPoly;-1===r.indexOf(v)&&r.push(v)}return this._afterState}},{key:"isInResult",value:function(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;var t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(Al.type){case"union":var n=0===t.length,r=0===e.length;this._isInResult=n!==r;break;case"intersection":var i,o;t.length<e.length?(i=t.length,o=e.length):(i=e.length,o=t.length),this._isInResult=o===Al.numMultiPolys&&i<o;break;case"xor":var a=Math.abs(t.length-e.length);this._isInResult=a%2==1;break;case"difference":var s=function(t){return 1===t.length&&t[0].isSubject};this._isInResult=s(t)!==s(e);break;default:throw new Error("Unrecognized operation type found ".concat(Al.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,n,r){var i,o,a,s=yl.comparePoints(e,n);if(s<0)i=e,o=n,a=1;else{if(!(s>0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));i=n,o=e,a=-1}return new t(new yl(i,!0),new yl(o,!1),[r],[a])}}]),t}(),xl=function(){function t(e,n,r){if($s(this,t),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=ul.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,a=1,s=e.length;a<s;a++){if("number"!=typeof e[a][0]||"number"!=typeof e[a][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var l=ul.round(e[a][0],e[a][1]);l.x===o.x&&l.y===o.y||(this.segments.push(_l.fromRing(o,l,this)),l.x<this.bbox.ll.x&&(this.bbox.ll.x=l.x),l.y<this.bbox.ll.y&&(this.bbox.ll.y=l.y),l.x>this.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}i.x===o.x&&i.y===o.y||this.segments.push(_l.fromRing(o,i,this))}return el(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.segments.length;e<n;e++){var r=this.segments[e];t.push(r.leftSE),t.push(r.rightSE)}return t}}]),t}(),bl=function(){function t(e,n){if($s(this,t),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new xl(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(var r=1,i=e.length;r<i;r++){var o=new xl(e[r],this,!1);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return el(t,[{key:"getSweepEvents",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,n=this.interiorRings.length;e<n;e++)for(var r=this.interiorRings[e].getSweepEvents(),i=0,o=r.length;i<o;i++)t.push(r[i]);return t}}]),t}(),wl=function(){function t(e,n){if($s(this,t),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch(t){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(var r=0,i=e.length;r<i;r++){var o=new bl(e[r],this);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return el(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.polys.length;e<n;e++)for(var r=this.polys[e].getSweepEvents(),i=0,o=r.length;i<o;i++)t.push(r[i]);return t}}]),t}(),El=function(){function t(e){$s(this,t),this.events=e;for(var n=0,r=e.length;n<r;n++)e[n].segment.ringOut=this;this.poly=null}return el(t,null,[{key:"factory",value:function(e){for(var n=[],r=0,i=e.length;r<i;r++){var o=e[r];if(o.isInResult()&&!o.ringOut){for(var a=null,s=o.leftSE,l=o.rightSE,u=[s],c=s.point,h=[];a=s,s=l,u.push(s),s.point!==c;)for(;;){var p=s.getAvailableLinkedEvents();if(0===p.length){var f=u[0].point,d=u[u.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(f.x,",")+" ".concat(f.y,"]. Last matching segment found ends at")+" [".concat(d.x,", ").concat(d.y,"]."))}if(1===p.length){l=p[0].otherSE;break}for(var m=null,g=0,y=h.length;g<y;g++)if(h[g].point===s.point){m=g;break}if(null===m){h.push({index:u.length,point:s.point});var v=s.getLeftmostComparator(a);l=p.sort(v)[0].otherSE;break}var _=h.splice(m)[0],x=u.splice(_.index);x.unshift(x[0].otherSE),n.push(new t(x.reverse()))}n.push(new t(u))}}return n}}]),el(t,[{key:"getGeom",value:function(){for(var t=this.events[0].point,e=[t],n=1,r=this.events.length-1;n<r;n++){var i=this.events[n].point,o=this.events[n+1].point;0!==pl(i,t,o)&&(e.push(i),t=i)}if(1===e.length)return null;var a=e[0],s=e[1];0===pl(a,t,s)&&e.shift(),e.push(e[0]);for(var l=this.isExteriorRing()?1:-1,u=this.isExteriorRing()?0:e.length-1,c=this.isExteriorRing()?e.length:-1,h=[],p=u;p!=c;p+=l)h.push([e[p].x,e[p].y]);return h}},{key:"isExteriorRing",value:function(){if(void 0===this._isExteriorRing){var t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var t=this.events[0],e=1,n=this.events.length;e<n;e++){var r=this.events[e];yl.compare(t,r)>0&&(t=r)}for(var i=t.segment.prevInResult(),o=i?i.prevInResult():null;;){if(!i)return null;if(!o)return i.ringOut;if(o.ringOut!==i.ringOut)return o.ringOut.enclosingRing()!==i.ringOut?i.ringOut:i.ringOut.enclosingRing();i=o.prevInResult(),o=i?i.prevInResult():null}}}]),t}(),Sl=function(){function t(e){$s(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return el(t,[{key:"addInterior",value:function(t){this.interiorRings.push(t),t.poly=this}},{key:"getGeom",value:function(){var t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(var e=0,n=this.interiorRings.length;e<n;e++){var r=this.interiorRings[e].getGeom();null!==r&&t.push(r)}return t}}]),t}(),Ml=function(){function t(e){$s(this,t),this.rings=e,this.polys=this._composePolys(e)}return el(t,[{key:"getGeom",value:function(){for(var t=[],e=0,n=this.polys.length;e<n;e++){var r=this.polys[e].getGeom();null!==r&&t.push(r)}return t}},{key:"_composePolys",value:function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];if(!i.poly)if(i.isExteriorRing())e.push(new Sl(i));else{var o=i.enclosingRing();o.poly||e.push(new Sl(o)),o.poly.addInterior(i)}}return e}}]),t}(),Tl=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_l.compare;$s(this,t),this.queue=e,this.tree=new Ys(n),this.segments=[]}return el(t,[{key:"process",value:function(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;var r=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!r)throw new Error("Unable to find segment #".concat(e.id," ")+"[".concat(e.leftSE.point.x,", ").concat(e.leftSE.point.y,"] -> ")+"[".concat(e.rightSE.point.x,", ").concat(e.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var i=r,o=r,a=void 0,s=void 0;void 0===a;)null===(i=this.tree.prev(i))?a=null:void 0===i.key.consumedBy&&(a=i.key);for(;void 0===s;)null===(o=this.tree.next(o))?s=null:void 0===o.key.consumedBy&&(s=o.key);if(t.isLeft){var l=null;if(a){var u=a.getIntersection(e);if(null!==u&&(e.isAnEndpoint(u)||(l=u),!a.isAnEndpoint(u)))for(var c=this._splitSafely(a,u),h=0,p=c.length;h<p;h++)n.push(c[h])}var f=null;if(s){var d=s.getIntersection(e);if(null!==d&&(e.isAnEndpoint(d)||(f=d),!s.isAnEndpoint(d)))for(var m=this._splitSafely(s,d),g=0,y=m.length;g<y;g++)n.push(m[g])}if(null!==l||null!==f){var v=null;v=null===l?f:null===f||yl.comparePoints(l,f)<=0?l:f;this.queue.remove(e.rightSE),n.push(e.rightSE);for(var _=e.split(v),x=0,b=_.length;x<b;x++)n.push(_[x])}n.length>0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=a)}else{if(a&&s){var w=a.getIntersection(s);if(null!==w){if(!a.isAnEndpoint(w))for(var E=this._splitSafely(a,w),S=0,M=E.length;S<M;S++)n.push(E[S]);if(!s.isAnEndpoint(w))for(var T=this._splitSafely(s,w),C=0,I=T.length;C<I;C++)n.push(T[C])}}this.tree.remove(e)}return n}},{key:"_splitSafely",value:function(t,e){this.tree.remove(t);var n=t.rightSE;this.queue.remove(n);var r=t.split(e);return r.push(n),void 0===t.consumedBy&&this.tree.insert(t),r}}]),t}(),Cl="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,Il="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6,Al=new(function(){function t(){$s(this,t)}return el(t,[{key:"run",value:function(t,e,n){Al.type=t,ul.reset();for(var r=[new wl(e,!0)],i=0,o=n.length;i<o;i++)r.push(new wl(n[i],!1));if(Al.numMultiPolys=r.length,"difference"===Al.type)for(var a=r[0],s=1;s<r.length;)null!==rl(r[s].bbox,a.bbox)?s++:r.splice(s,1);if("intersection"===Al.type)for(var l=0,u=r.length;l<u;l++)for(var c=r[l],h=l+1,p=r.length;h<p;h++)if(null===rl(c.bbox,r[h].bbox))return[];for(var f=new Ys(yl.compare),d=0,m=r.length;d<m;d++)for(var g=r[d].getSweepEvents(),y=0,v=g.length;y<v;y++)if(f.insert(g[y]),f.size>Cl)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var _=new Tl(f),x=f.size,b=f.pop();b;){var w=b.key;if(f.size===x){var E=w.segment;throw new Error("Unable to pop() ".concat(w.isLeft?"left":"right"," SweepEvent ")+"[".concat(w.point.x,", ").concat(w.point.y,"] from segment #").concat(E.id," ")+"[".concat(E.leftSE.point.x,", ").concat(E.leftSE.point.y,"] -> ")+"[".concat(E.rightSE.point.x,", ").concat(E.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(f.size>Cl)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(_.segments.length>Il)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var S=_.process(w),M=0,T=S.length;M<T;M++){var C=S[M];void 0===C.consumedBy&&f.insert(C)}x=f.size,b=f.pop()}ul.reset();var I=El.factory(_.segments);return new Ml(I).getGeom()}}]),t}()),Ll={union:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Al.run("union",t,n)},intersection:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Al.run("intersection",t,n)},xor:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Al.run("xor",t,n)},difference:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Al.run("difference",t,n)}};"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(t){if(null==this)throw new TypeError(this+" is not an object");var e=Object(this),n=Math.max(Math.min(e.length,9007199254740991),0)||0,r=1 in arguments&&parseInt(Number(arguments[1]),10)||0;r=r<0?Math.max(n+r,0):Math.min(r,n);var i=2 in arguments&&void 0!==arguments[2]?parseInt(Number(arguments[2]),10)||0:n;for(i=i<0?Math.max(n+arguments[2],0):Math.min(i,n);r<i;)e[r]=t,++r;return e},writable:!0}),Number.isFinite=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},Number.parseFloat=Number.parseFloat||parseFloat,Number.isNaN=Number.isNaN||function(t){return t!=t},Math.trunc=Math.trunc||function(t){return t<0?Math.ceil(t):Math.floor(t)};var Pl=function(){};Pl.prototype.interfaces_=function(){return[]},Pl.prototype.getClass=function(){return Pl},Pl.prototype.equalsWithTolerance=function(t,e,n){return Math.abs(t-e)<=n};var Rl=function(t){function e(e){t.call(this,e),this.name="IllegalArgumentException",this.message=e,this.stack=(new t).stack}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),Dl=function(){},Nl={MAX_VALUE:{configurable:!0}};Dl.isNaN=function(t){return Number.isNaN(t)},Dl.doubleToLongBits=function(t){return t},Dl.longBitsToDouble=function(t){return t},Dl.isInfinite=function(t){return!Number.isFinite(t)},Nl.MAX_VALUE.get=function(){return Number.MAX_VALUE},Object.defineProperties(Dl,Nl);var Ol=function(){},kl=function(){},zl=function(){};function Fl(){}var Bl=function t(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)this.x=0,this.y=0,this.z=t.NULL_ORDINATE;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.z=e.z}else 2===arguments.length?(this.x=arguments[0],this.y=arguments[1],this.z=t.NULL_ORDINATE):3===arguments.length&&(this.x=arguments[0],this.y=arguments[1],this.z=arguments[2])},Ul={DimensionalComparator:{configurable:!0},serialVersionUID:{configurable:!0},NULL_ORDINATE:{configurable:!0},X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0}};Bl.prototype.setOrdinate=function(t,e){switch(t){case Bl.X:this.x=e;break;case Bl.Y:this.y=e;break;case Bl.Z:this.z=e;break;default:throw new Rl("Invalid ordinate index: "+t)}},Bl.prototype.equals2D=function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!Pl.equalsWithTolerance(this.x,e.x,n)&&!!Pl.equalsWithTolerance(this.y,e.y,n)}},Bl.prototype.getOrdinate=function(t){switch(t){case Bl.X:return this.x;case Bl.Y:return this.y;case Bl.Z:return this.z}throw new Rl("Invalid ordinate index: "+t)},Bl.prototype.equals3D=function(t){return this.x===t.x&&this.y===t.y&&(this.z===t.z||Dl.isNaN(this.z))&&Dl.isNaN(t.z)},Bl.prototype.equals=function(t){return t instanceof Bl&&this.equals2D(t)},Bl.prototype.equalInZ=function(t,e){return Pl.equalsWithTolerance(this.z,t.z,e)},Bl.prototype.compareTo=function(t){var e=t;return this.x<e.x?-1:this.x>e.x?1:this.y<e.y?-1:this.y>e.y?1:0},Bl.prototype.clone=function(){},Bl.prototype.copy=function(){return new Bl(this)},Bl.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},Bl.prototype.distance3D=function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return Math.sqrt(e*e+n*n+r*r)},Bl.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},Bl.prototype.hashCode=function(){var t=17;return 37*(t=37*t+Bl.hashCode(this.x))+Bl.hashCode(this.y)},Bl.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},Bl.prototype.interfaces_=function(){return[Ol,kl,Fl]},Bl.prototype.getClass=function(){return Bl},Bl.hashCode=function(){if(1===arguments.length){var t=Dl.doubleToLongBits(arguments[0]);return Math.trunc((t^t)>>>32)}},Ul.DimensionalComparator.get=function(){return Vl},Ul.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},Ul.NULL_ORDINATE.get=function(){return Dl.NaN},Ul.X.get=function(){return 0},Ul.Y.get=function(){return 1},Ul.Z.get=function(){return 2},Object.defineProperties(Bl,Ul);var Vl=function(t){if(this._dimensionsToTest=2,0===arguments.length);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new Rl("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}};Vl.prototype.compare=function(t,e){var n=t,r=e,i=Vl.compare(n.x,r.x);if(0!==i)return i;var o=Vl.compare(n.y,r.y);return 0!==o?o:this._dimensionsToTest<=2?0:Vl.compare(n.z,r.z)},Vl.prototype.interfaces_=function(){return[zl]},Vl.prototype.getClass=function(){return Vl},Vl.compare=function(t,e){return t<e?-1:t>e?1:Dl.isNaN(t)?Dl.isNaN(e)?0:-1:Dl.isNaN(e)?1:0};var Gl=function(){};Gl.prototype.create=function(){},Gl.prototype.interfaces_=function(){return[]},Gl.prototype.getClass=function(){return Gl};var jl=function(){},Hl={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};jl.prototype.interfaces_=function(){return[]},jl.prototype.getClass=function(){return jl},jl.toLocationSymbol=function(t){switch(t){case jl.EXTERIOR:return"e";case jl.BOUNDARY:return"b";case jl.INTERIOR:return"i";case jl.NONE:return"-"}throw new Rl("Unknown location value: "+t)},Hl.INTERIOR.get=function(){return 0},Hl.BOUNDARY.get=function(){return 1},Hl.EXTERIOR.get=function(){return 2},Hl.NONE.get=function(){return-1},Object.defineProperties(jl,Hl);var ql=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},Wl=function(){},Xl={LOG_10:{configurable:!0}};Wl.prototype.interfaces_=function(){return[]},Wl.prototype.getClass=function(){return Wl},Wl.log10=function(t){var e=Math.log(t);return Dl.isInfinite(e)||Dl.isNaN(e)?e:e/Wl.LOG_10},Wl.min=function(t,e,n,r){var i=t;return e<i&&(i=e),n<i&&(i=n),r<i&&(i=r),i},Wl.clamp=function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1],n=arguments[2];return t<e?e:t>n?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return r<i?i:r>o?o:r}},Wl.wrap=function(t,e){return t<0?e- -t%e:t%e},Wl.max=function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var r=arguments[1],i=arguments[2],o=arguments[3],a=arguments[0];return r>a&&(a=r),i>a&&(a=i),o>a&&(a=o),a}},Wl.average=function(t,e){return(t+e)/2},Xl.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Wl,Xl);var Zl=function(t){this.str=t};Zl.prototype.append=function(t){this.str+=t},Zl.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},Zl.prototype.toString=function(t){return this.str};var Yl=function(t){this.value=t};Yl.prototype.intValue=function(){return this.value},Yl.prototype.compareTo=function(t){return this.value<t?-1:this.value>t?1:0},Yl.isNaN=function(t){return Number.isNaN(t)};var Jl=function(){};Jl.isWhitespace=function(t){return t<=32&&t>=0||127===t},Jl.toUpperCase=function(t){return t.toUpperCase()};var Kl=function t(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){t.call(this,t.parse(arguments[0]))}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r,i)}},Ql={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};Kl.prototype.le=function(t){return(this._hi<t._hi||this._hi===t._hi)&&this._lo<=t._lo},Kl.prototype.extractSignificantDigits=function(t,e){var n=this.abs(),r=Kl.magnitude(n._hi),i=Kl.TEN.pow(r);(n=n.divide(i)).gt(Kl.TEN)?(n=n.divide(Kl.TEN),r+=1):n.lt(Kl.ONE)&&(n=n.multiply(Kl.TEN),r-=1);for(var o=r+1,a=new Zl,s=Kl.MAX_PRINT_DIGITS-1,l=0;l<=s;l++){t&&l===o&&a.append(".");var u=Math.trunc(n._hi);if(u<0)break;var c=!1,h=0;u>9?(c=!0,h="9"):h="0"+u,a.append(h),n=n.subtract(Kl.valueOf(u)).multiply(Kl.TEN),c&&n.selfAdd(Kl.TEN);var p=!0,f=Kl.magnitude(n._hi);if(f<0&&Math.abs(f)>=s-l&&(p=!1),!p)break}return e[0]=r,a.toString()},Kl.prototype.sqr=function(){return this.multiply(this)},Kl.prototype.doubleValue=function(){return this._hi+this._lo},Kl.prototype.subtract=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},Kl.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},Kl.prototype.isZero=function(){return 0===this._hi&&0===this._lo},Kl.prototype.selfSubtract=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},Kl.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},Kl.prototype.min=function(t){return this.le(t)?this:t},Kl.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){var n,r,i,o,a=arguments[0],s=arguments[1],l=null,u=null,c=null,h=null;return i=this._hi/a,h=(l=(c=Kl.SPLIT*i)-(l=c-i))*(u=(h=Kl.SPLIT*a)-(u=h-a))-(o=i*a)+l*(r=a-u)+(n=i-l)*u+n*r,h=i+(c=(this._hi-o-h+this._lo-i*s)/a),this._hi=h,this._lo=i-h+c,this}},Kl.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},Kl.prototype.divide=function(){if(arguments[0]instanceof Kl){var t,e,n,r,i=arguments[0],o=null,a=null,s=null,l=null;t=(n=this._hi/i._hi)-(o=(s=Kl.SPLIT*n)-(o=s-n)),l=o*(a=(l=Kl.SPLIT*i._hi)-(a=l-i._hi))-(r=n*i._hi)+o*(e=i._hi-a)+t*a+t*e;var u=l=n+(s=(this._hi-r-l+this._lo-n*i._lo)/i._hi);return new Kl(u,n-l+s)}if("number"==typeof arguments[0]){var c=arguments[0];return Dl.isNaN(c)?Kl.createNaN():Kl.copy(this).selfDivide(c,0)}},Kl.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},Kl.prototype.pow=function(t){if(0===t)return Kl.valueOf(1);var e=new Kl(this),n=Kl.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&n.selfMultiply(e),(r/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},Kl.prototype.ceil=function(){if(this.isNaN())return Kl.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new Kl(t,e)},Kl.prototype.compareTo=function(t){var e=t;return this._hi<e._hi?-1:this._hi>e._hi?1:this._lo<e._lo?-1:this._lo>e._lo?1:0},Kl.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},Kl.prototype.setValue=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},Kl.prototype.max=function(t){return this.ge(t)?this:t},Kl.prototype.sqrt=function(){if(this.isZero())return Kl.valueOf(0);if(this.isNegative())return Kl.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,n=Kl.valueOf(e),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r)},Kl.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var e,n,r,i,o,a=arguments[0],s=null;return s=(r=this._hi+a)-(i=r-this._hi),n=(o=(s=a-i+(this._hi-s))+this._lo)+(r-(e=r+o)),this._hi=e+n,this._lo=n+(e-this._hi),this}}else if(2===arguments.length){var l,u,c,h,p=arguments[0],f=arguments[1],d=null,m=null,g=null;c=this._hi+p,u=this._lo+f,m=c-(g=c-this._hi),d=u-(h=u-this._lo);var y=(l=c+(g=(m=p-g+(this._hi-m))+u))+(g=(d=f-h+(this._lo-d))+(g+(c-l))),v=g+(l-y);return this._hi=y,this._lo=v,this}},Kl.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){var n,r,i=arguments[0],o=arguments[1],a=null,s=null,l=null,u=null;a=(l=Kl.SPLIT*this._hi)-this._hi,u=Kl.SPLIT*i,a=l-a,n=this._hi-a,s=u-i;var c=(l=this._hi*i)+(u=a*(s=u-s)-l+a*(r=i-s)+n*s+n*r+(this._hi*o+this._lo*i)),h=u+(a=l-c);return this._hi=c,this._lo=h,this}},Kl.prototype.selfSqr=function(){return this.selfMultiply(this)},Kl.prototype.floor=function(){if(this.isNaN())return Kl.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new Kl(t,e)},Kl.prototype.negate=function(){return this.isNaN()?this:new Kl(-this._hi,-this._lo)},Kl.prototype.clone=function(){},Kl.prototype.multiply=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return t.isNaN()?Kl.createNaN():Kl.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return Dl.isNaN(e)?Kl.createNaN():Kl.copy(this).selfMultiply(e,0)}},Kl.prototype.isNaN=function(){return Dl.isNaN(this._hi)},Kl.prototype.intValue=function(){return Math.trunc(this._hi)},Kl.prototype.toString=function(){var t=Kl.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},Kl.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),r=e[0]+1,i=n;if("."===n.charAt(0))i="0"+n;else if(r<0)i="0."+Kl.stringOfChar("0",-r)+n;else if(-1===n.indexOf(".")){var o=r-n.length;i=n+Kl.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+i:i},Kl.prototype.reciprocal=function(){var t,e,n,r,i=null,o=null,a=null,s=null;t=(n=1/this._hi)-(i=(a=Kl.SPLIT*n)-(i=a-n)),o=(s=Kl.SPLIT*this._hi)-this._hi;var l=n+(a=(1-(r=n*this._hi)-(s=i*(o=s-o)-r+i*(e=this._hi-o)+t*o+t*e)-n*this._lo)/this._hi);return new Kl(l,n-l+a)},Kl.prototype.toSciNotation=function(){if(this.isZero())return Kl.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),r=Kl.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new Error("Found leading zero: "+n);var i="";n.length>1&&(i=n.substring(1));var o=n.charAt(0)+"."+i;return this.isNegative()?"-"+o+r:o+r},Kl.prototype.abs=function(){return this.isNaN()?Kl.NaN:this.isNegative()?this.negate():new Kl(this)},Kl.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0},Kl.prototype.lt=function(t){return(this._hi<t._hi||this._hi===t._hi)&&this._lo<t._lo},Kl.prototype.add=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return Kl.copy(this).selfAdd(t)}if("number"==typeof arguments[0]){var e=arguments[0];return Kl.copy(this).selfAdd(e)}},Kl.prototype.init=function(){if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this._hi=t,this._lo=0}else if(arguments[0]instanceof Kl){var e=arguments[0];this._hi=e._hi,this._lo=e._lo}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this._hi=n,this._lo=r}},Kl.prototype.gt=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>t._lo},Kl.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0},Kl.prototype.trunc=function(){return this.isNaN()?Kl.NaN:this.isPositive()?this.floor():this.ceil()},Kl.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},Kl.prototype.interfaces_=function(){return[Fl,Ol,kl]},Kl.prototype.getClass=function(){return Kl},Kl.sqr=function(t){return Kl.valueOf(t).selfMultiply(t)},Kl.valueOf=function(){if("string"==typeof arguments[0]){return Kl.parse(arguments[0])}if("number"==typeof arguments[0]){return new Kl(arguments[0])}},Kl.sqrt=function(t){return Kl.valueOf(t).sqrt()},Kl.parse=function(t){for(var e=0,n=t.length;Jl.isWhitespace(t.charAt(e));)e++;var r=!1;if(e<n){var i=t.charAt(e);"-"!==i&&"+"!==i||(e++,"-"===i&&(r=!0))}for(var o=new Kl,a=0,s=0,l=0;!(e>=n);){var u=t.charAt(e);if(e++,Jl.isDigit(u)){var c=u-"0";o.selfMultiply(Kl.TEN),o.selfAdd(c),a++}else{if("."!==u){if("e"===u||"E"===u){var h=t.substring(e);try{l=Yl.parseInt(h)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+h+" in string "+t):e}break}throw new Error("Unexpected character '"+u+"' at position "+e+" in string "+t)}s=a}}var p=o,f=a-s-l;if(0===f)p=o;else if(f>0){var d=Kl.TEN.pow(f);p=o.divide(d)}else if(f<0){var m=Kl.TEN.pow(-f);p=o.multiply(m)}return r?p.negate():p},Kl.createNaN=function(){return new Kl(Dl.NaN,Dl.NaN)},Kl.copy=function(t){return new Kl(t)},Kl.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r},Kl.stringOfChar=function(t,e){for(var n=new Zl,r=0;r<e;r++)n.append(t);return n.toString()},Ql.PI.get=function(){return new Kl(3.141592653589793,12246467991473532e-32)},Ql.TWO_PI.get=function(){return new Kl(6.283185307179586,24492935982947064e-32)},Ql.PI_2.get=function(){return new Kl(1.5707963267948966,6123233995736766e-32)},Ql.E.get=function(){return new Kl(2.718281828459045,14456468917292502e-32)},Ql.NaN.get=function(){return new Kl(Dl.NaN,Dl.NaN)},Ql.EPS.get=function(){return 123259516440783e-46},Ql.SPLIT.get=function(){return 134217729},Ql.MAX_PRINT_DIGITS.get=function(){return 32},Ql.TEN.get=function(){return Kl.valueOf(10)},Ql.ONE.get=function(){return Kl.valueOf(1)},Ql.SCI_NOT_EXPONENT_CHAR.get=function(){return"E"},Ql.SCI_NOT_ZERO.get=function(){return"0.0E0"},Object.defineProperties(Kl,Ql);var $l=function(){},tu={DP_SAFE_EPSILON:{configurable:!0}};$l.prototype.interfaces_=function(){return[]},$l.prototype.getClass=function(){return $l},$l.orientationIndex=function(t,e,n){var r=$l.orientationIndexFilter(t,e,n);if(r<=1)return r;var i=Kl.valueOf(e.x).selfAdd(-t.x),o=Kl.valueOf(e.y).selfAdd(-t.y),a=Kl.valueOf(n.x).selfAdd(-e.x),s=Kl.valueOf(n.y).selfAdd(-e.y);return i.selfMultiply(s).selfSubtract(o.selfMultiply(a)).signum()},$l.signOfDet2x2=function(t,e,n,r){return t.multiply(r).selfSubtract(e.multiply(n)).signum()},$l.intersection=function(t,e,n,r){var i=Kl.valueOf(r.y).selfSubtract(n.y).selfMultiply(Kl.valueOf(e.x).selfSubtract(t.x)),o=Kl.valueOf(r.x).selfSubtract(n.x).selfMultiply(Kl.valueOf(e.y).selfSubtract(t.y)),a=i.subtract(o),s=Kl.valueOf(r.x).selfSubtract(n.x).selfMultiply(Kl.valueOf(t.y).selfSubtract(n.y)),l=Kl.valueOf(r.y).selfSubtract(n.y).selfMultiply(Kl.valueOf(t.x).selfSubtract(n.x)),u=s.subtract(l).selfDivide(a).doubleValue(),c=Kl.valueOf(t.x).selfAdd(Kl.valueOf(e.x).selfSubtract(t.x).selfMultiply(u)).doubleValue(),h=Kl.valueOf(e.x).selfSubtract(t.x).selfMultiply(Kl.valueOf(t.y).selfSubtract(n.y)),p=Kl.valueOf(e.y).selfSubtract(t.y).selfMultiply(Kl.valueOf(t.x).selfSubtract(n.x)),f=h.subtract(p).selfDivide(a).doubleValue(),d=Kl.valueOf(n.y).selfAdd(Kl.valueOf(r.y).selfSubtract(n.y).selfMultiply(f)).doubleValue();return new Bl(c,d)},$l.orientationIndexFilter=function(t,e,n){var r=null,i=(t.x-n.x)*(e.y-n.y),o=(t.y-n.y)*(e.x-n.x),a=i-o;if(i>0){if(o<=0)return $l.signum(a);r=i+o}else{if(!(i<0))return $l.signum(a);if(o>=0)return $l.signum(a);r=-i-o}var s=$l.DP_SAFE_EPSILON*r;return a>=s||-a>=s?$l.signum(a):2},$l.signum=function(t){return t>0?1:t<0?-1:0},tu.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties($l,tu);var eu=function(){},nu={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};nu.X.get=function(){return 0},nu.Y.get=function(){return 1},nu.Z.get=function(){return 2},nu.M.get=function(){return 3},eu.prototype.setOrdinate=function(t,e,n){},eu.prototype.size=function(){},eu.prototype.getOrdinate=function(t,e){},eu.prototype.getCoordinate=function(){},eu.prototype.getCoordinateCopy=function(t){},eu.prototype.getDimension=function(){},eu.prototype.getX=function(t){},eu.prototype.clone=function(){},eu.prototype.expandEnvelope=function(t){},eu.prototype.copy=function(){},eu.prototype.getY=function(t){},eu.prototype.toCoordinateArray=function(){},eu.prototype.interfaces_=function(){return[kl]},eu.prototype.getClass=function(){return eu},Object.defineProperties(eu,nu);var ru=function(){},iu=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ru),ou=function(){};ou.arraycopy=function(t,e,n,r,i){for(var o=0,a=e;a<e+i;a++)n[r+o]=t[a],o++},ou.getProperty=function(t){return{"line.separator":"\n"}[t]};var au=function t(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1];this.x=n,this.y=r,this.w=1}else if(arguments[0]instanceof t&&arguments[1]instanceof t){var i=arguments[0],o=arguments[1];this.x=i.y*o.w-o.y*i.w,this.y=o.x*i.w-i.x*o.w,this.w=i.x*o.y-o.x*i.y}else if(arguments[0]instanceof Bl&&arguments[1]instanceof Bl){var a=arguments[0],s=arguments[1];this.x=a.y-s.y,this.y=s.x-a.x,this.w=a.x*s.y-s.x*a.y}}else if(3===arguments.length){var l=arguments[0],u=arguments[1],c=arguments[2];this.x=l,this.y=u,this.w=c}else if(4===arguments.length){var h=arguments[0],p=arguments[1],f=arguments[2],d=arguments[3],m=h.y-p.y,g=p.x-h.x,y=h.x*p.y-p.x*h.y,v=f.y-d.y,_=d.x-f.x,x=f.x*d.y-d.x*f.y;this.x=g*x-_*y,this.y=v*y-m*x,this.w=m*_-v*g}};au.prototype.getY=function(){var t=this.y/this.w;if(Dl.isNaN(t)||Dl.isInfinite(t))throw new iu;return t},au.prototype.getX=function(){var t=this.x/this.w;if(Dl.isNaN(t)||Dl.isInfinite(t))throw new iu;return t},au.prototype.getCoordinate=function(){var t=new Bl;return t.x=this.getX(),t.y=this.getY(),t},au.prototype.interfaces_=function(){return[]},au.prototype.getClass=function(){return au},au.intersection=function(t,e,n,r){var i=t.y-e.y,o=e.x-t.x,a=t.x*e.y-e.x*t.y,s=n.y-r.y,l=r.x-n.x,u=n.x*r.y-r.x*n.y,c=i*l-s*o,h=(o*u-l*a)/c,p=(s*a-i*u)/c;if(Dl.isNaN(h)||Dl.isInfinite(h)||Dl.isNaN(p)||Dl.isInfinite(p))throw new iu;return new Bl(h,p)};var su=function t(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof Bl){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r.x,i.x,r.y,i.y)}else if(4===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2],l=arguments[3];this.init(o,a,s,l)}},lu={serialVersionUID:{configurable:!0}};su.prototype.getArea=function(){return this.getWidth()*this.getHeight()},su.prototype.equals=function(t){if(!(t instanceof su))return!1;var e=t;return this.isNull()?e.isNull():this._maxx===e.getMaxX()&&this._maxy===e.getMaxY()&&this._minx===e.getMinX()&&this._miny===e.getMinY()},su.prototype.intersection=function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new su;var e=this._minx>t._minx?this._minx:t._minx,n=this._miny>t._miny?this._miny:t._miny,r=this._maxx<t._maxx?this._maxx:t._maxx,i=this._maxy<t._maxy?this._maxy:t._maxy;return new su(e,r,n,i)},su.prototype.isNull=function(){return this._maxx<this._minx},su.prototype.getMaxX=function(){return this._maxx},su.prototype.covers=function(){if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];return this.covers(t.x,t.y)}if(arguments[0]instanceof su){var e=arguments[0];return!this.isNull()&&!e.isNull()&&e.getMinX()>=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy}},su.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof su){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny)}if(arguments[0]instanceof Bl){var e=arguments[0];return this.intersects(e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&!(n>this._maxx||n<this._minx||r>this._maxy||r<this._miny)}},su.prototype.getMinY=function(){return this._miny},su.prototype.getMinX=function(){return this._minx},su.prototype.expandToInclude=function(){if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];this.expandToInclude(t.x,t.y)}else if(arguments[0]instanceof su){var e=arguments[0];if(e.isNull())return null;this.isNull()?(this._minx=e.getMinX(),this._maxx=e.getMaxX(),this._miny=e.getMinY(),this._maxy=e.getMaxY()):(e._minx<this._minx&&(this._minx=e._minx),e._maxx>this._maxx&&(this._maxx=e._maxx),e._miny<this._miny&&(this._miny=e._miny),e._maxy>this._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=r,this._maxy=r):(n<this._minx&&(this._minx=n),n>this._maxx&&(this._maxx=n),r<this._miny&&(this._miny=r),r>this._maxy&&(this._maxy=r))}},su.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t<e?t:e},su.prototype.getWidth=function(){return this.isNull()?0:this._maxx-this._minx},su.prototype.compareTo=function(t){var e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this._minx<e._minx?-1:this._minx>e._minx?1:this._miny<e._miny?-1:this._miny>e._miny?1:this._maxx<e._maxx?-1:this._maxx>e._maxx?1:this._maxy<e._maxy?-1:this._maxy>e._maxy?1:0},su.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},su.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},su.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},su.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},su.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},su.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}},su.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof su){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof Bl){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.covers(n,r)}},su.prototype.centre=function(){return this.isNull()?null:new Bl((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},su.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof su){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];i<o?(this._minx=i,this._maxx=o):(this._minx=o,this._maxx=i),a<s?(this._miny=a,this._maxy=s):(this._miny=s,this._maxy=a)}},su.prototype.getMaxY=function(){return this._maxy},su.prototype.distance=function(t){if(this.intersects(t))return 0;var e=0;this._maxx<t._minx?e=t._minx-this._maxx:this._minx>t._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxy<t._miny?n=t._miny-this._maxy:this._miny>t._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},su.prototype.hashCode=function(){var t=17;return 37*(t=37*(t=37*(t=37*t+Bl.hashCode(this._minx))+Bl.hashCode(this._maxx))+Bl.hashCode(this._miny))+Bl.hashCode(this._maxy)},su.prototype.interfaces_=function(){return[Ol,Fl]},su.prototype.getClass=function(){return su},su.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.x<e.x?t.x:e.x)&&n.x<=(t.x>e.x?t.x:e.x)&&n.y>=(t.y<e.y?t.y:e.y)&&n.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],a=arguments[3],s=Math.min(o.x,a.x),l=Math.max(o.x,a.x),u=Math.min(r.x,i.x),c=Math.max(r.x,i.x);return!(u>l||c<s||(s=Math.min(o.y,a.y),l=Math.max(o.y,a.y),u=Math.min(r.y,i.y),c=Math.max(r.y,i.y),u>l||c<s))}},lu.serialVersionUID.get=function(){return 0x51845cd552189800},Object.defineProperties(su,lu);var uu={typeStr:/^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,emptyTypeStr:/^\s*(\w+)\s*EMPTY\s*$/,spaces:/\s+/,parenComma:/\)\s*,\s*\(/,doubleParenComma:/\)\s*\)\s*,\s*\(\s*\(/,trimParens:/^\s*\(?(.*?)\)?\s*$/},cu=function(t){this.geometryFactory=t||new Yc};cu.prototype.read=function(t){var e,n,r;t=t.replace(/[\n\r]/g," ");var i=uu.typeStr.exec(t);if(-1!==t.search("EMPTY")&&((i=uu.emptyTypeStr.exec(t))[2]=void 0),i&&(n=i[1].toLowerCase(),r=i[2],pu[n]&&(e=pu[n].apply(this,[r]))),void 0===e)throw new Error("Could not parse WKT "+t);return e},cu.prototype.write=function(t){return this.extractGeometry(t)},cu.prototype.extractGeometry=function(t){var e=t.getGeometryType().toLowerCase();if(!hu[e])return null;var n=e.toUpperCase();return t.isEmpty()?n+" EMPTY":n+"("+hu[e].apply(this,[t])+")"};var hu={coordinate:function(t){return t.x+" "+t.y},point:function(t){return hu.coordinate.call(this,t._coordinates._coordinates[0])},multipoint:function(t){for(var e=[],n=0,r=t._geometries.length;n<r;++n)e.push("("+hu.point.apply(this,[t._geometries[n]])+")");return e.join(",")},linestring:function(t){for(var e=[],n=0,r=t._points._coordinates.length;n<r;++n)e.push(hu.coordinate.apply(this,[t._points._coordinates[n]]));return e.join(",")},linearring:function(t){for(var e=[],n=0,r=t._points._coordinates.length;n<r;++n)e.push(hu.coordinate.apply(this,[t._points._coordinates[n]]));return e.join(",")},multilinestring:function(t){for(var e=[],n=0,r=t._geometries.length;n<r;++n)e.push("("+hu.linestring.apply(this,[t._geometries[n]])+")");return e.join(",")},polygon:function(t){var e=[];e.push("("+hu.linestring.apply(this,[t._shell])+")");for(var n=0,r=t._holes.length;n<r;++n)e.push("("+hu.linestring.apply(this,[t._holes[n]])+")");return e.join(",")},multipolygon:function(t){for(var e=[],n=0,r=t._geometries.length;n<r;++n)e.push("("+hu.polygon.apply(this,[t._geometries[n]])+")");return e.join(",")},geometrycollection:function(t){for(var e=[],n=0,r=t._geometries.length;n<r;++n)e.push(this.extractGeometry(t._geometries[n]));return e.join(",")}},pu={point:function(t){if(void 0===t)return this.geometryFactory.createPoint();var e=t.trim().split(uu.spaces);return this.geometryFactory.createPoint(new Bl(Number.parseFloat(e[0]),Number.parseFloat(e[1])))},multipoint:function(t){var e;if(void 0===t)return this.geometryFactory.createMultiPoint();for(var n=t.trim().split(","),r=[],i=0,o=n.length;i<o;++i)e=n[i].replace(uu.trimParens,"$1"),r.push(pu.point.apply(this,[e]));return this.geometryFactory.createMultiPoint(r)},linestring:function(t){if(void 0===t)return this.geometryFactory.createLineString();for(var e,n=t.trim().split(","),r=[],i=0,o=n.length;i<o;++i)e=n[i].trim().split(uu.spaces),r.push(new Bl(Number.parseFloat(e[0]),Number.parseFloat(e[1])));return this.geometryFactory.createLineString(r)},linearring:function(t){if(void 0===t)return this.geometryFactory.createLinearRing();for(var e,n=t.trim().split(","),r=[],i=0,o=n.length;i<o;++i)e=n[i].trim().split(uu.spaces),r.push(new Bl(Number.parseFloat(e[0]),Number.parseFloat(e[1])));return this.geometryFactory.createLinearRing(r)},multilinestring:function(t){var e;if(void 0===t)return this.geometryFactory.createMultiLineString();for(var n=t.trim().split(uu.parenComma),r=[],i=0,o=n.length;i<o;++i)e=n[i].replace(uu.trimParens,"$1"),r.push(pu.linestring.apply(this,[e]));return this.geometryFactory.createMultiLineString(r)},polygon:function(t){var e,n,r;if(void 0===t)return this.geometryFactory.createPolygon();for(var i,o=t.trim().split(uu.parenComma),a=[],s=0,l=o.length;s<l;++s)e=o[s].replace(uu.trimParens,"$1"),n=pu.linestring.apply(this,[e]),r=this.geometryFactory.createLinearRing(n._points),0===s?i=r:a.push(r);return this.geometryFactory.createPolygon(i,a)},multipolygon:function(t){var e;if(void 0===t)return this.geometryFactory.createMultiPolygon();for(var n=t.trim().split(uu.doubleParenComma),r=[],i=0,o=n.length;i<o;++i)e=n[i].replace(uu.trimParens,"$1"),r.push(pu.polygon.apply(this,[e]));return this.geometryFactory.createMultiPolygon(r)},geometrycollection:function(t){if(void 0===t)return this.geometryFactory.createGeometryCollection();for(var e=(t=t.replace(/,\s*([A-Za-z])/g,"|$1")).trim().split("|"),n=[],r=0,i=e.length;r<i;++r)n.push(this.read(e[r]));return this.geometryFactory.createGeometryCollection(n)}},fu=function(t){this.parser=new cu(t)};fu.prototype.write=function(t){return this.parser.write(t)},fu.toLineString=function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"};var du=function(t){function e(e){t.call(this,e),this.name="RuntimeException",this.message=e,this.stack=(new t).stack}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),mu=function(t){function e(){if(t.call(this),0===arguments.length)t.call(this);else if(1===arguments.length){var e=arguments[0];t.call(this,e)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(du),gu=function(){};gu.prototype.interfaces_=function(){return[]},gu.prototype.getClass=function(){return gu},gu.shouldNeverReachHere=function(){if(0===arguments.length)gu.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new mu("Should never reach here"+(null!==t?": "+t:""))}},gu.isTrue=function(){var t;if(1===arguments.length)gu.isTrue(arguments[0],null);else if(2===arguments.length&&(t=arguments[1],!arguments[0]))throw null===t?new mu:new mu(t)},gu.equals=function(){var t,e,n;if(2===arguments.length)gu.equals(t=arguments[0],e=arguments[1],null);else if(3===arguments.length&&(t=arguments[0],n=arguments[2],!(e=arguments[1]).equals(t)))throw new mu("Expected "+t+" but encountered "+e+(null!==n?": "+n:""))};var yu=function(){this._result=null,this._inputLines=Array(2).fill().map((function(){return Array(2)})),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new Bl,this._intPt[1]=new Bl,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0},vu={DONT_INTERSECT:{configurable:!0},DO_INTERSECT:{configurable:!0},COLLINEAR:{configurable:!0},NO_INTERSECTION:{configurable:!0},POINT_INTERSECTION:{configurable:!0},COLLINEAR_INTERSECTION:{configurable:!0}};yu.prototype.getIndexAlongSegment=function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]},yu.prototype.getTopologySummary=function(){var t=new Zl;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()},yu.prototype.computeIntersection=function(t,e,n,r){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=r,this._result=this.computeIntersect(t,e,n,r)},yu.prototype.getIntersectionNum=function(){return this._result},yu.prototype.computeIntLineIndex=function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},yu.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},yu.prototype.setPrecisionModel=function(t){this._precisionModel=t},yu.prototype.isInteriorIntersection=function(){var t=this;if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var e=arguments[0],n=0;n<this._result;n++)if(!t._intPt[n].equals2D(t._inputLines[e][0])&&!t._intPt[n].equals2D(t._inputLines[e][1]))return!0;return!1}},yu.prototype.getIntersection=function(t){return this._intPt[t]},yu.prototype.isEndPoint=function(){return this.hasIntersection()&&!this._isProper},yu.prototype.hasIntersection=function(){return this._result!==yu.NO_INTERSECTION},yu.prototype.getEdgeDistance=function(t,e){return yu.computeEdgeDistance(this._intPt[e],this._inputLines[t][0],this._inputLines[t][1])},yu.prototype.isCollinear=function(){return this._result===yu.COLLINEAR_INTERSECTION},yu.prototype.toString=function(){return fu.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+fu.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()},yu.prototype.getEndpoint=function(t,e){return this._inputLines[t][e]},yu.prototype.isIntersection=function(t){for(var e=0;e<this._result;e++)if(this._intPt[e].equals2D(t))return!0;return!1},yu.prototype.getIntersectionAlongSegment=function(t,e){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[t][e]]},yu.prototype.interfaces_=function(){return[]},yu.prototype.getClass=function(){return yu},yu.computeEdgeDistance=function(t,e,n){var r=Math.abs(n.x-e.x),i=Math.abs(n.y-e.y),o=-1;if(t.equals(e))o=0;else if(t.equals(n))o=r>i?r:i;else{var a=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);0!==(o=r>i?a:s)||t.equals(e)||(o=Math.max(a,s))}return gu.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},yu.nonRobustComputeEdgeDistance=function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return gu.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},vu.DONT_INTERSECT.get=function(){return 0},vu.DO_INTERSECT.get=function(){return 1},vu.COLLINEAR.get=function(){return 2},vu.NO_INTERSECTION.get=function(){return 0},vu.POINT_INTERSECTION.get=function(){return 1},vu.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(yu,vu);var _u=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isInSegmentEnvelopes=function(t){var e=new su(this._inputLines[0][0],this._inputLines[0][1]),n=new su(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2];if(this._isProper=!1,su.intersects(n,r,e)&&0===wu.orientationIndex(n,r,e)&&0===wu.orientationIndex(r,n,e))return this._isProper=!0,(e.equals(n)||e.equals(r))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(t,e,n,r,i){i.x=this.smallestInAbsValue(t.x,e.x,n.x,r.x),i.y=this.smallestInAbsValue(t.y,e.y,n.y,r.y),t.x-=i.x,t.y-=i.y,e.x-=i.x,e.y-=i.y,n.x-=i.x,n.y-=i.y,r.x-=i.x,r.y-=i.y},e.prototype.safeHCoordinateIntersection=function(t,n,r,i){var o=null;try{o=au.intersection(t,n,r,i)}catch(a){if(!(a instanceof iu))throw a;o=e.nearestEndpoint(t,n,r,i)}return o},e.prototype.intersection=function(t,n,r,i){var o=this.intersectionWithNormalization(t,n,r,i);return this.isInSegmentEnvelopes(o)||(o=new Bl(e.nearestEndpoint(t,n,r,i))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o},e.prototype.smallestInAbsValue=function(t,e,n,r){var i=t,o=Math.abs(i);return Math.abs(e)<o&&(i=e,o=Math.abs(e)),Math.abs(n)<o&&(i=n,o=Math.abs(n)),Math.abs(r)<o&&(i=r),i},e.prototype.checkDD=function(t,e,n,r,i){var o=$l.intersection(t,e,n,r),a=this.isInSegmentEnvelopes(o);ou.out.println("DD in env = "+a+" --------------------- "+o),i.distance(o)>1e-4&&ou.out.println("Distance = "+i.distance(o))},e.prototype.intersectionWithNormalization=function(t,e,n,r){var i=new Bl(t),o=new Bl(e),a=new Bl(n),s=new Bl(r),l=new Bl;this.normalizeToEnvCentre(i,o,a,s,l);var u=this.safeHCoordinateIntersection(i,o,a,s);return u.x+=l.x,u.y+=l.y,u},e.prototype.computeCollinearIntersection=function(e,n,r,i){var o=su.intersects(e,n,r),a=su.intersects(e,n,i),s=su.intersects(r,i,e),l=su.intersects(r,i,n);return o&&a?(this._intPt[0]=r,this._intPt[1]=i,t.COLLINEAR_INTERSECTION):s&&l?(this._intPt[0]=e,this._intPt[1]=n,t.COLLINEAR_INTERSECTION):o&&s?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||a||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&l?(this._intPt[0]=r,this._intPt[1]=n,!r.equals(n)||a||s?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&s?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||o||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&l?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||o||s?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(t,e,n,r,i){var o=t.x<e.x?t.x:e.x,a=t.y<e.y?t.y:e.y,s=t.x>e.x?t.x:e.x,l=t.y>e.y?t.y:e.y,u=n.x<r.x?n.x:r.x,c=n.y<r.y?n.y:r.y,h=n.x>r.x?n.x:r.x,p=n.y>r.y?n.y:r.y,f=((o>u?o:u)+(s<h?s:h))/2,d=((a>c?a:c)+(l<p?l:p))/2;i.x=f,i.y=d,t.x-=i.x,t.y-=i.y,e.x-=i.x,e.y-=i.y,n.x-=i.x,n.y-=i.y,r.x-=i.x,r.y-=i.y},e.prototype.computeIntersect=function(e,n,r,i){if(this._isProper=!1,!su.intersects(e,n,r,i))return t.NO_INTERSECTION;var o=wu.orientationIndex(e,n,r),a=wu.orientationIndex(e,n,i);if(o>0&&a>0||o<0&&a<0)return t.NO_INTERSECTION;var s=wu.orientationIndex(r,i,e),l=wu.orientationIndex(r,i,n);return s>0&&l>0||s<0&&l<0?t.NO_INTERSECTION:0===o&&0===a&&0===s&&0===l?this.computeCollinearIntersection(e,n,r,i):(0===o||0===a||0===s||0===l?(this._isProper=!1,e.equals2D(r)||e.equals2D(i)?this._intPt[0]=e:n.equals2D(r)||n.equals2D(i)?this._intPt[0]=n:0===o?this._intPt[0]=new Bl(r):0===a?this._intPt[0]=new Bl(i):0===s?this._intPt[0]=new Bl(e):0===l&&(this._intPt[0]=new Bl(n))):(this._isProper=!0,this._intPt[0]=this.intersection(e,n,r,i)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(t,e,n,r){var i=t,o=wu.distancePointLine(t,n,r),a=wu.distancePointLine(e,n,r);return a<o&&(o=a,i=e),(a=wu.distancePointLine(n,t,e))<o&&(o=a,i=n),(a=wu.distancePointLine(r,t,e))<o&&(o=a,i=r),i},e}(yu),xu=function(){};xu.prototype.interfaces_=function(){return[]},xu.prototype.getClass=function(){return xu},xu.orientationIndex=function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=n.x-e.x,a=n.y-e.y;return xu.signOfDet2x2(r,i,o,a)},xu.signOfDet2x2=function(t,e,n,r){var i=null,o=null,a=null;if(i=1,0===t||0===r)return 0===e||0===n?0:e>0?n>0?-i:i:n>0?i:-i;if(0===e||0===n)return r>0?t>0?i:-i:t>0?-i:i;if(e>0?r>0?e<=r||(i=-i,o=t,t=n,n=o,o=e,e=r,r=o):e<=-r?(i=-i,n=-n,r=-r):(o=t,t=-n,n=o,o=e,e=-r,r=o):r>0?-e<=r?(i=-i,t=-t,e=-e):(o=-t,t=n,n=o,o=-e,e=r,r=o):e>=r?(t=-t,e=-e,n=-n,r=-r):(i=-i,o=-t,t=-n,n=o,o=-e,e=-r,r=o),t>0){if(!(n>0))return i;if(!(t<=n))return i}else{if(n>0)return-i;if(!(t>=n))return-i;i=-i,t=-t,n=-n}for(;;){if((r-=(a=Math.floor(n/t))*e)<0)return-i;if(r>e)return i;if(t>(n-=a*t)+n){if(e<r+r)return i}else{if(e>r+r)return-i;n=t-n,r=e-r,i=-i}if(0===r)return 0===n?0:-i;if(0===n)return i;if((e-=(a=Math.floor(t/n))*r)<0)return i;if(e>r)return-i;if(n>(t-=a*n)+t){if(r<e+e)return-i}else{if(r>e+e)return i;t=n-t,e=r-e,i=-i}if(0===e)return 0===t?0:i;if(0===t)return-i}};var bu=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t};bu.prototype.countSegment=function(t,e){if(t.x<this._p.x&&e.x<this._p.x)return null;if(this._p.x===e.x&&this._p.y===e.y)return this._isPointOnSegment=!0,null;if(t.y===this._p.y&&e.y===this._p.y){var n=t.x,r=e.x;return n>r&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=t.x-this._p.x,o=t.y-this._p.y,a=e.x-this._p.x,s=e.y-this._p.y,l=xu.signOfDet2x2(i,o,a,s);if(0===l)return this._isPointOnSegment=!0,null;s<o&&(l=-l),l>0&&this._crossingCount++}},bu.prototype.isPointInPolygon=function(){return this.getLocation()!==jl.EXTERIOR},bu.prototype.getLocation=function(){return this._isPointOnSegment?jl.BOUNDARY:this._crossingCount%2==1?jl.INTERIOR:jl.EXTERIOR},bu.prototype.isOnSegment=function(){return this._isPointOnSegment},bu.prototype.interfaces_=function(){return[]},bu.prototype.getClass=function(){return bu},bu.locatePointInRing=function(){if(arguments[0]instanceof Bl&&ql(arguments[1],eu)){for(var t=arguments[1],e=new bu(arguments[0]),n=new Bl,r=new Bl,i=1;i<t.size();i++)if(t.getCoordinate(i,n),t.getCoordinate(i-1,r),e.countSegment(n,r),e.isOnSegment())return e.getLocation();return e.getLocation()}if(arguments[0]instanceof Bl&&arguments[1]instanceof Array){for(var o=arguments[1],a=new bu(arguments[0]),s=1;s<o.length;s++){var l=o[s],u=o[s-1];if(a.countSegment(l,u),a.isOnSegment())return a.getLocation()}return a.getLocation()}};var wu=function(){},Eu={CLOCKWISE:{configurable:!0},RIGHT:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},LEFT:{configurable:!0},COLLINEAR:{configurable:!0},STRAIGHT:{configurable:!0}};wu.prototype.interfaces_=function(){return[]},wu.prototype.getClass=function(){return wu},wu.orientationIndex=function(t,e,n){return $l.orientationIndex(t,e,n)},wu.signedArea=function(){if(arguments[0]instanceof Array){var t=arguments[0];if(t.length<3)return 0;for(var e=0,n=t[0].x,r=1;r<t.length-1;r++){var i=t[r].x-n,o=t[r+1].y;e+=i*(t[r-1].y-o)}return e/2}if(ql(arguments[0],eu)){var a=arguments[0],s=a.size();if(s<3)return 0;var l=new Bl,u=new Bl,c=new Bl;a.getCoordinate(0,u),a.getCoordinate(1,c);var h=u.x;c.x-=h;for(var p=0,f=1;f<s-1;f++)l.y=u.y,u.x=c.x,u.y=c.y,a.getCoordinate(f+1,c),c.x-=h,p+=u.x*(l.y-c.y);return p/2}},wu.distanceLineLine=function(t,e,n,r){if(t.equals(e))return wu.distancePointLine(t,n,r);if(n.equals(r))return wu.distancePointLine(r,t,e);var i=!1;if(su.intersects(t,e,n,r)){var o=(e.x-t.x)*(r.y-n.y)-(e.y-t.y)*(r.x-n.x);if(0===o)i=!0;else{var a=(t.y-n.y)*(r.x-n.x)-(t.x-n.x)*(r.y-n.y),s=((t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y))/o,l=a/o;(l<0||l>1||s<0||s>1)&&(i=!0)}}else i=!0;return i?Wl.min(wu.distancePointLine(t,n,r),wu.distancePointLine(e,n,r),wu.distancePointLine(n,t,e),wu.distancePointLine(r,t,e)):0},wu.isPointInRing=function(t,e){return wu.locatePointInRing(t,e)!==jl.EXTERIOR},wu.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,r=new Bl;t.getCoordinate(0,r);for(var i=r.x,o=r.y,a=1;a<e;a++){t.getCoordinate(a,r);var s=r.x,l=r.y,u=s-i,c=l-o;n+=Math.sqrt(u*u+c*c),i=s,o=l}return n},wu.isCCW=function(t){var e=t.length-1;if(e<3)throw new Rl("Ring has fewer than 4 points, so orientation cannot be determined");for(var n=t[0],r=0,i=1;i<=e;i++){var o=t[i];o.y>n.y&&(n=o,r=i)}var a=r;do{(a-=1)<0&&(a=e)}while(t[a].equals2D(n)&&a!==r);var s=r;do{s=(s+1)%e}while(t[s].equals2D(n)&&s!==r);var l=t[a],u=t[s];if(l.equals2D(n)||u.equals2D(n)||l.equals2D(u))return!1;var c=wu.computeOrientation(l,n,u);return 0===c?l.x>u.x:c>0},wu.locatePointInRing=function(t,e){return bu.locatePointInRing(t,e)},wu.distancePointLinePerpendicular=function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r)},wu.computeOrientation=function(t,e,n){return wu.orientationIndex(t,e,n)},wu.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new Rl("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r<e.length-1;r++){var i=wu.distancePointLine(t,e[r],e[r+1]);i<n&&(n=i)}return n}if(3===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2];if(a.x===s.x&&a.y===s.y)return o.distance(a);var l=(s.x-a.x)*(s.x-a.x)+(s.y-a.y)*(s.y-a.y),u=((o.x-a.x)*(s.x-a.x)+(o.y-a.y)*(s.y-a.y))/l;if(u<=0)return o.distance(a);if(u>=1)return o.distance(s);var c=((a.y-o.y)*(s.x-a.x)-(a.x-o.x)*(s.y-a.y))/l;return Math.abs(c)*Math.sqrt(l)}},wu.isOnLine=function(t,e){for(var n=new _u,r=1;r<e.length;r++){var i=e[r-1],o=e[r];if(n.computeIntersection(t,i,o),n.hasIntersection())return!0}return!1},Eu.CLOCKWISE.get=function(){return-1},Eu.RIGHT.get=function(){return wu.CLOCKWISE},Eu.COUNTERCLOCKWISE.get=function(){return 1},Eu.LEFT.get=function(){return wu.COUNTERCLOCKWISE},Eu.COLLINEAR.get=function(){return 0},Eu.STRAIGHT.get=function(){return wu.COLLINEAR},Object.defineProperties(wu,Eu);var Su=function(){};Su.prototype.filter=function(t){},Su.prototype.interfaces_=function(){return[]},Su.prototype.getClass=function(){return Su};var Mu=function(){var t=arguments[0];this._envelope=null,this._factory=null,this._SRID=null,this._userData=null,this._factory=t,this._SRID=t.getSRID()},Tu={serialVersionUID:{configurable:!0},SORTINDEX_POINT:{configurable:!0},SORTINDEX_MULTIPOINT:{configurable:!0},SORTINDEX_LINESTRING:{configurable:!0},SORTINDEX_LINEARRING:{configurable:!0},SORTINDEX_MULTILINESTRING:{configurable:!0},SORTINDEX_POLYGON:{configurable:!0},SORTINDEX_MULTIPOLYGON:{configurable:!0},SORTINDEX_GEOMETRYCOLLECTION:{configurable:!0},geometryChangedFilter:{configurable:!0}};Mu.prototype.isGeometryCollection=function(){return this.getSortIndex()===Mu.SORTINDEX_GEOMETRYCOLLECTION},Mu.prototype.getFactory=function(){return this._factory},Mu.prototype.getGeometryN=function(t){return this},Mu.prototype.getArea=function(){return 0},Mu.prototype.isRectangle=function(){return!1},Mu.prototype.equals=function(){if(arguments[0]instanceof Mu){var t=arguments[0];return null!==t&&this.equalsTopo(t)}if(arguments[0]instanceof Object){var e=arguments[0];if(!(e instanceof Mu))return!1;var n=e;return this.equalsExact(n)}},Mu.prototype.equalsExact=function(t){return this===t||this.equalsExact(t,0)},Mu.prototype.geometryChanged=function(){this.apply(Mu.geometryChangedFilter)},Mu.prototype.geometryChangedAction=function(){this._envelope=null},Mu.prototype.equalsNorm=function(t){return null!==t&&this.norm().equalsExact(t.norm())},Mu.prototype.getLength=function(){return 0},Mu.prototype.getNumGeometries=function(){return 1},Mu.prototype.compareTo=function(){if(1===arguments.length){var t=arguments[0],e=t;return this.getSortIndex()!==e.getSortIndex()?this.getSortIndex()-e.getSortIndex():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t)}if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.getSortIndex()!==n.getSortIndex()?this.getSortIndex()-n.getSortIndex():this.isEmpty()&&n.isEmpty()?0:this.isEmpty()?-1:n.isEmpty()?1:this.compareToSameClass(n,r)}},Mu.prototype.getUserData=function(){return this._userData},Mu.prototype.getSRID=function(){return this._SRID},Mu.prototype.getEnvelope=function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())},Mu.prototype.checkNotGeometryCollection=function(t){if(t.getSortIndex()===Mu.SORTINDEX_GEOMETRYCOLLECTION)throw new Rl("This method does not support GeometryCollection arguments")},Mu.prototype.equal=function(t,e,n){return 0===n?t.equals(e):t.distance(e)<=n},Mu.prototype.norm=function(){var t=this.copy();return t.normalize(),t},Mu.prototype.getPrecisionModel=function(){return this._factory.getPrecisionModel()},Mu.prototype.getEnvelopeInternal=function(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new su(this._envelope)},Mu.prototype.setSRID=function(t){this._SRID=t},Mu.prototype.setUserData=function(t){this._userData=t},Mu.prototype.compare=function(t,e){for(var n=t.iterator(),r=e.iterator();n.hasNext()&&r.hasNext();){var i=n.next(),o=r.next(),a=i.compareTo(o);if(0!==a)return a}return n.hasNext()?1:r.hasNext()?-1:0},Mu.prototype.hashCode=function(){return this.getEnvelopeInternal().hashCode()},Mu.prototype.isGeometryCollectionOrDerived=function(){return this.getSortIndex()===Mu.SORTINDEX_GEOMETRYCOLLECTION||this.getSortIndex()===Mu.SORTINDEX_MULTIPOINT||this.getSortIndex()===Mu.SORTINDEX_MULTILINESTRING||this.getSortIndex()===Mu.SORTINDEX_MULTIPOLYGON},Mu.prototype.interfaces_=function(){return[kl,Ol,Fl]},Mu.prototype.getClass=function(){return Mu},Mu.hasNonEmptyElements=function(t){for(var e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1},Mu.hasNullElements=function(t){for(var e=0;e<t.length;e++)if(null===t[e])return!0;return!1},Tu.serialVersionUID.get=function(){return 0x799ea46522854c00},Tu.SORTINDEX_POINT.get=function(){return 0},Tu.SORTINDEX_MULTIPOINT.get=function(){return 1},Tu.SORTINDEX_LINESTRING.get=function(){return 2},Tu.SORTINDEX_LINEARRING.get=function(){return 3},Tu.SORTINDEX_MULTILINESTRING.get=function(){return 4},Tu.SORTINDEX_POLYGON.get=function(){return 5},Tu.SORTINDEX_MULTIPOLYGON.get=function(){return 6},Tu.SORTINDEX_GEOMETRYCOLLECTION.get=function(){return 7},Tu.geometryChangedFilter.get=function(){return Cu},Object.defineProperties(Mu,Tu);var Cu=function(){};Cu.interfaces_=function(){return[Su]},Cu.filter=function(t){t.geometryChangedAction()};var Iu=function(){};Iu.prototype.filter=function(t){},Iu.prototype.interfaces_=function(){return[]},Iu.prototype.getClass=function(){return Iu};var Au=function(){},Lu={Mod2BoundaryNodeRule:{configurable:!0},EndPointBoundaryNodeRule:{configurable:!0},MultiValentEndPointBoundaryNodeRule:{configurable:!0},MonoValentEndPointBoundaryNodeRule:{configurable:!0},MOD2_BOUNDARY_RULE:{configurable:!0},ENDPOINT_BOUNDARY_RULE:{configurable:!0},MULTIVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},MONOVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},OGC_SFS_BOUNDARY_RULE:{configurable:!0}};Au.prototype.isInBoundary=function(t){},Au.prototype.interfaces_=function(){return[]},Au.prototype.getClass=function(){return Au},Lu.Mod2BoundaryNodeRule.get=function(){return Pu},Lu.EndPointBoundaryNodeRule.get=function(){return Ru},Lu.MultiValentEndPointBoundaryNodeRule.get=function(){return Du},Lu.MonoValentEndPointBoundaryNodeRule.get=function(){return Nu},Lu.MOD2_BOUNDARY_RULE.get=function(){return new Pu},Lu.ENDPOINT_BOUNDARY_RULE.get=function(){return new Ru},Lu.MULTIVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new Du},Lu.MONOVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new Nu},Lu.OGC_SFS_BOUNDARY_RULE.get=function(){return Au.MOD2_BOUNDARY_RULE},Object.defineProperties(Au,Lu);var Pu=function(){};Pu.prototype.isInBoundary=function(t){return t%2==1},Pu.prototype.interfaces_=function(){return[Au]},Pu.prototype.getClass=function(){return Pu};var Ru=function(){};Ru.prototype.isInBoundary=function(t){return t>0},Ru.prototype.interfaces_=function(){return[Au]},Ru.prototype.getClass=function(){return Ru};var Du=function(){};Du.prototype.isInBoundary=function(t){return t>1},Du.prototype.interfaces_=function(){return[Au]},Du.prototype.getClass=function(){return Du};var Nu=function(){};Nu.prototype.isInBoundary=function(t){return 1===t},Nu.prototype.interfaces_=function(){return[Au]},Nu.prototype.getClass=function(){return Nu};var Ou=function(){};function ku(t){this.message=t||""}Ou.prototype.add=function(){},Ou.prototype.addAll=function(){},Ou.prototype.isEmpty=function(){},Ou.prototype.iterator=function(){},Ou.prototype.size=function(){},Ou.prototype.toArray=function(){},Ou.prototype.remove=function(){},ku.prototype=new Error,ku.prototype.name="IndexOutOfBoundsException";var zu=function(){};zu.prototype.hasNext=function(){},zu.prototype.next=function(){},zu.prototype.remove=function(){};var Fu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e}(Ou);function Bu(t){this.message=t||""}Bu.prototype=new Error,Bu.prototype.name="NoSuchElementException";var Uu=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Ou&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,Ou]},e.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},e.prototype.clear=function(){this.array_=[]},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},e.prototype.iterator=function(){return new Vu(this)},e.prototype.get=function(t){if(t<0||t>=this.size())throw new ku;return this.array_[t]},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.size=function(){return this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},e.prototype.remove=function(t){for(var e=!1,n=0,r=this.array_.length;n<r;n++)if(this.array_[n]===t){this.array_.splice(n,1),e=!0;break}return e},e}(Fu),Vu=function(t){function e(e){t.call(this),this.arrayList_=e,this.position_=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.next=function(){if(this.position_===this.arrayList_.size())throw new Bu;return this.arrayList_.get(this.position_++)},e.prototype.hasNext=function(){return this.position_<this.arrayList_.size()},e.prototype.set=function(t){return this.arrayList_.set(this.position_-1,t)},e.prototype.remove=function(){this.arrayList_.remove(this.arrayList_.get(this.position_))},e}(zu),Gu=function(t){function e(){if(t.call(this),0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.ensureCapacity(e.length),this.add(e,!0)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.ensureCapacity(n.length),this.add(n,r)}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={coordArrayType:{configurable:!0}};return n.coordArrayType.get=function(){return new Array(0).fill(null)},e.prototype.getCoordinate=function(t){return this.get(t)},e.prototype.addAll=function(){if(2===arguments.length){for(var e=arguments[1],n=!1,r=arguments[0].iterator();r.hasNext();)this.add(r.next(),e),n=!0;return n}return t.prototype.addAll.apply(this,arguments)},e.prototype.clone=function(){for(var e=t.prototype.clone.call(this),n=0;n<this.size();n++)e.add(n,this.get(n).copy());return e},e.prototype.toCoordinateArray=function(){return this.toArray(e.coordArrayType)},e.prototype.add=function(){var e=this;if(1===arguments.length){var n=arguments[0];t.prototype.add.call(this,n)}else if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var r=arguments[0],i=arguments[1];return this.add(r,i,!0),!0}if(arguments[0]instanceof Bl&&"boolean"==typeof arguments[1]){var o=arguments[0];if(!arguments[1]&&this.size()>=1){if(this.get(this.size()-1).equals2D(o))return null}t.prototype.add.call(this,o)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var a=arguments[0],s=arguments[1];return this.add(a,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var l=arguments[0],u=arguments[1];if(arguments[2])for(var c=0;c<l.length;c++)e.add(l[c],u);else for(var h=l.length-1;h>=0;h--)e.add(l[h],u);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof Bl){var p=arguments[0],f=arguments[1];if(!arguments[2]){var d=this.size();if(d>0){if(p>0){if(this.get(p-1).equals2D(f))return null}if(p<d){if(this.get(p).equals2D(f))return null}}}t.prototype.add.call(this,p,f)}}else if(4===arguments.length){var m=arguments[0],g=arguments[1],y=arguments[2],v=arguments[3],_=1;y>v&&(_=-1);for(var x=y;x!==v;x+=_)e.add(m[x],g);return!0}},e.prototype.closeRing=function(){this.size()>0&&this.add(new Bl(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,n),e}(Uu),ju=function(){},Hu={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Hu.ForwardComparator.get=function(){return qu},Hu.BidirectionalComparator.get=function(){return Wu},Hu.coordArrayType.get=function(){return new Array(0).fill(null)},ju.prototype.interfaces_=function(){return[]},ju.prototype.getClass=function(){return ju},ju.isRing=function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))},ju.ptNotInList=function(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(ju.indexOf(r,e)<0)return r}return null},ju.scroll=function(t,e){var n=ju.indexOf(e,t);if(n<0)return null;var r=new Array(t.length).fill(null);ou.arraycopy(t,n,r,0,t.length-n),ou.arraycopy(t,0,r,t.length-n,n),ou.arraycopy(r,0,t,0,t.length)},ju.equals=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].equals(e[n]))return!1;return!0}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];if(r===i)return!0;if(null===r||null===i)return!1;if(r.length!==i.length)return!1;for(var a=0;a<r.length;a++)if(0!==o.compare(r[a],i[a]))return!1;return!0}},ju.intersection=function(t,e){for(var n=new Gu,r=0;r<t.length;r++)e.intersects(t[r])&&n.add(t[r],!0);return n.toCoordinateArray()},ju.hasRepeatedPoints=function(t){for(var e=1;e<t.length;e++)if(t[e-1].equals(t[e]))return!0;return!1},ju.removeRepeatedPoints=function(t){return ju.hasRepeatedPoints(t)?new Gu(t,!1).toCoordinateArray():t},ju.reverse=function(t){for(var e=t.length-1,n=Math.trunc(e/2),r=0;r<=n;r++){var i=t[r];t[r]=t[e-r],t[e-r]=i}},ju.removeNull=function(t){for(var e=0,n=0;n<t.length;n++)null!==t[n]&&e++;var r=new Array(e).fill(null);if(0===e)return r;for(var i=0,o=0;o<t.length;o++)null!==t[o]&&(r[i++]=t[o]);return r},ju.copyDeep=function(){if(1===arguments.length){for(var t=arguments[0],e=new Array(t.length).fill(null),n=0;n<t.length;n++)e[n]=new Bl(t[n]);return e}if(5===arguments.length)for(var r=arguments[0],i=arguments[1],o=arguments[2],a=arguments[3],s=arguments[4],l=0;l<s;l++)o[a+l]=new Bl(r[i+l])},ju.isEqualReversed=function(t,e){for(var n=0;n<t.length;n++){var r=t[n],i=e[t.length-n-1];if(0!==r.compareTo(i))return!1}return!0},ju.envelope=function(t){for(var e=new su,n=0;n<t.length;n++)e.expandToInclude(t[n]);return e},ju.toCoordinateArray=function(t){return t.toArray(ju.coordArrayType)},ju.atLeastNCoordinatesOrNothing=function(t,e){return e.length>=t?e:[]},ju.indexOf=function(t,e){for(var n=0;n<e.length;n++)if(t.equals(e[n]))return n;return-1},ju.increasingDirection=function(t){for(var e=0;e<Math.trunc(t.length/2);e++){var n=t.length-1-e,r=t[e].compareTo(t[n]);if(0!==r)return r}return 1},ju.compare=function(t,e){for(var n=0;n<t.length&&n<e.length;){var r=t[n].compareTo(e[n]);if(0!==r)return r;n++}return n<e.length?-1:n<t.length?1:0},ju.minCoordinate=function(t){for(var e=null,n=0;n<t.length;n++)(null===e||e.compareTo(t[n])>0)&&(e=t[n]);return e},ju.extract=function(t,e,n){e=Wl.clamp(e,0,t.length);var r=(n=Wl.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),n<e&&(r=0);var i=new Array(r).fill(null);if(0===r)return i;for(var o=0,a=e;a<=n;a++)i[o++]=t[a];return i},Object.defineProperties(ju,Hu);var qu=function(){};qu.prototype.compare=function(t,e){return ju.compare(t,e)},qu.prototype.interfaces_=function(){return[zl]},qu.prototype.getClass=function(){return qu};var Wu=function(){};Wu.prototype.compare=function(t,e){var n=t,r=e;if(n.length<r.length)return-1;if(n.length>r.length)return 1;if(0===n.length)return 0;var i=ju.compare(n,r);return ju.isEqualReversed(n,r)?0:i},Wu.prototype.OLDcompare=function(t,e){var n=t,r=e;if(n.length<r.length)return-1;if(n.length>r.length)return 1;if(0===n.length)return 0;for(var i=ju.increasingDirection(n),o=ju.increasingDirection(r),a=i>0?0:n.length-1,s=o>0?0:n.length-1,l=0;l<n.length;l++){var u=n[a].compareTo(r[s]);if(0!==u)return u;a+=i,s+=o}return 0},Wu.prototype.interfaces_=function(){return[zl]},Wu.prototype.getClass=function(){return Wu};var Xu=function(){};Xu.prototype.get=function(){},Xu.prototype.put=function(){},Xu.prototype.size=function(){},Xu.prototype.values=function(){},Xu.prototype.entrySet=function(){};var Zu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Xu);function Yu(t){this.message=t||""}function Ju(){}Yu.prototype=new Error,Yu.prototype.name="OperationNotSupported",Ju.prototype=new Ou,Ju.prototype.contains=function(){};var Ku=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Ou&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.contains=function(t){for(var e=0,n=this.array_.length;e<n;e++)if(this.array_[e]===t)return!0;return!1},e.prototype.add=function(t){return!this.contains(t)&&(this.array_.push(t),!0)},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.remove=function(t){throw new Error},e.prototype.size=function(){return this.array_.length},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},e.prototype.iterator=function(){return new Qu(this)},e}(Ju),Qu=function(t){function e(e){t.call(this),this.hashSet_=e,this.position_=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.next=function(){if(this.position_===this.hashSet_.size())throw new Bu;return this.hashSet_.array_[this.position_++]},e.prototype.hasNext=function(){return this.position_<this.hashSet_.size()},e.prototype.remove=function(){throw new Yu},e}(zu);function $u(t){return null===t?0:t.color}function tc(t){return null===t?null:t.parent}function ec(t,e){null!==t&&(t.color=e)}function nc(t){return null===t?null:t.left}function rc(t){return null===t?null:t.right}function ic(){this.root_=null,this.size_=0}ic.prototype=new Zu,ic.prototype.get=function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null},ic.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,r,i=this.root_;do{if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o}i=i.right}}while(null!==i);var a={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return r<0?n.left=a:n.right=a,this.fixAfterInsertion(a),this.size_++,null},ic.prototype.fixAfterInsertion=function(t){var e=this;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(tc(t)===nc(tc(tc(t)))){var n=rc(tc(tc(t)));1===$u(n)?(ec(tc(t),0),ec(n,0),ec(tc(tc(t)),1),t=tc(tc(t))):(t===rc(tc(t))&&(t=tc(t),e.rotateLeft(t)),ec(tc(t),0),ec(tc(tc(t)),1),e.rotateRight(tc(tc(t))))}else{var r=nc(tc(tc(t)));1===$u(r)?(ec(tc(t),0),ec(r,0),ec(tc(tc(t)),1),t=tc(tc(t))):(t===nc(tc(t))&&(t=tc(t),e.rotateRight(t)),ec(tc(t),0),ec(tc(tc(t)),1),e.rotateLeft(tc(tc(t))))}this.root_.color=0},ic.prototype.values=function(){var t=new Uu,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=ic.successor(e));)t.add(e.value);return t},ic.prototype.entrySet=function(){var t=new Ku,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=ic.successor(e));)t.add(e);return t},ic.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},ic.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},ic.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},ic.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var n=t.parent,r=t;null!==n&&r===n.right;)r=n,n=n.parent;return n},ic.prototype.size=function(){return this.size_};var oc=function(){};function ac(){}function sc(){this.array_=[],arguments[0]instanceof Ou&&this.addAll(arguments[0])}oc.prototype.interfaces_=function(){return[]},oc.prototype.getClass=function(){return oc},ac.prototype=new Ju,sc.prototype=new ac,sc.prototype.contains=function(t){for(var e=0,n=this.array_.length;e<n;e++)if(0===this.array_[e].compareTo(t))return!0;return!1},sc.prototype.add=function(t){if(this.contains(t))return!1;for(var e=0,n=this.array_.length;e<n;e++)if(1===this.array_[e].compareTo(t))return this.array_.splice(e,0,t),!0;return this.array_.push(t),!0},sc.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},sc.prototype.remove=function(t){throw new Yu},sc.prototype.size=function(){return this.array_.length},sc.prototype.isEmpty=function(){return 0===this.array_.length},sc.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t},sc.prototype.iterator=function(){return new lc(this)};var lc=function(t){this.treeSet_=t,this.position_=0};lc.prototype.next=function(){if(this.position_===this.treeSet_.size())throw new Bu;return this.treeSet_.array_[this.position_++]},lc.prototype.hasNext=function(){return this.position_<this.treeSet_.size()},lc.prototype.remove=function(){throw new Yu};var uc=function(){};uc.sort=function(){var t,e,n,r,i=arguments[0];if(1===arguments.length)r=function(t,e){return t.compareTo(e)},i.sort(r);else if(2===arguments.length)n=arguments[1],r=function(t,e){return n.compare(t,e)},i.sort(r);else if(3===arguments.length){(e=i.slice(arguments[1],arguments[2])).sort();var o=i.slice(0,arguments[1]).concat(e,i.slice(arguments[2],i.length));for(i.splice(0,i.length),t=0;t<o.length;t++)i.push(o[t])}else if(4===arguments.length)for(e=i.slice(arguments[1],arguments[2]),n=arguments[3],r=function(t,e){return n.compare(t,e)},e.sort(r),o=i.slice(0,arguments[1]).concat(e,i.slice(arguments[2],i.length)),i.splice(0,i.length),t=0;t<o.length;t++)i.push(o[t])},uc.asList=function(t){for(var e=new Uu,n=0,r=t.length;n<r;n++)e.add(t[n]);return e};var cc=function(){},hc={P:{configurable:!0},L:{configurable:!0},A:{configurable:!0},FALSE:{configurable:!0},TRUE:{configurable:!0},DONTCARE:{configurable:!0},SYM_FALSE:{configurable:!0},SYM_TRUE:{configurable:!0},SYM_DONTCARE:{configurable:!0},SYM_P:{configurable:!0},SYM_L:{configurable:!0},SYM_A:{configurable:!0}};hc.P.get=function(){return 0},hc.L.get=function(){return 1},hc.A.get=function(){return 2},hc.FALSE.get=function(){return-1},hc.TRUE.get=function(){return-2},hc.DONTCARE.get=function(){return-3},hc.SYM_FALSE.get=function(){return"F"},hc.SYM_TRUE.get=function(){return"T"},hc.SYM_DONTCARE.get=function(){return"*"},hc.SYM_P.get=function(){return"0"},hc.SYM_L.get=function(){return"1"},hc.SYM_A.get=function(){return"2"},cc.prototype.interfaces_=function(){return[]},cc.prototype.getClass=function(){return cc},cc.toDimensionSymbol=function(t){switch(t){case cc.FALSE:return cc.SYM_FALSE;case cc.TRUE:return cc.SYM_TRUE;case cc.DONTCARE:return cc.SYM_DONTCARE;case cc.P:return cc.SYM_P;case cc.L:return cc.SYM_L;case cc.A:return cc.SYM_A}throw new Rl("Unknown dimension value: "+t)},cc.toDimensionValue=function(t){switch(Jl.toUpperCase(t)){case cc.SYM_FALSE:return cc.FALSE;case cc.SYM_TRUE:return cc.TRUE;case cc.SYM_DONTCARE:return cc.DONTCARE;case cc.SYM_P:return cc.P;case cc.SYM_L:return cc.L;case cc.SYM_A:return cc.A}throw new Rl("Unknown dimension symbol: "+t)},Object.defineProperties(cc,hc);var pc=function(){};pc.prototype.filter=function(t){},pc.prototype.interfaces_=function(){return[]},pc.prototype.getClass=function(){return pc};var fc=function(){};fc.prototype.filter=function(t,e){},fc.prototype.isDone=function(){},fc.prototype.isGeometryChanged=function(){},fc.prototype.interfaces_=function(){return[]},fc.prototype.getClass=function(){return fc};var dc=function(t){function e(e,n){if(t.call(this,n),this._geometries=e||[],t.hasNullElements(this._geometries))throw new Rl("geometries must not contain null elements")}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){for(var t=new su,e=0;e<this._geometries.length;e++)t.expandToInclude(this._geometries[e].getEnvelopeInternal());return t},e.prototype.getGeometryN=function(t){return this._geometries[t]},e.prototype.getSortIndex=function(){return t.SORTINDEX_GEOMETRYCOLLECTION},e.prototype.getCoordinates=function(){for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=0;n<this._geometries.length;n++)for(var r=this._geometries[n].getCoordinates(),i=0;i<r.length;i++)t[++e]=r[i];return t},e.prototype.getArea=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getArea();return t},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var r=e;if(this._geometries.length!==r._geometries.length)return!1;for(var i=0;i<this._geometries.length;i++)if(!this._geometries[i].equalsExact(r._geometries[i],n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){for(var t=0;t<this._geometries.length;t++)this._geometries[t].normalize();uc.sort(this._geometries)},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()},e.prototype.getBoundaryDimension=function(){for(var t=cc.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getBoundaryDimension());return t},e.prototype.getDimension=function(){for(var t=cc.FALSE,e=0;e<this._geometries.length;e++)t=Math.max(t,this._geometries[e].getDimension());return t},e.prototype.getLength=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getLength();return t},e.prototype.getNumPoints=function(){for(var t=0,e=0;e<this._geometries.length;e++)t+=this._geometries[e].getNumPoints();return t},e.prototype.getNumGeometries=function(){return this._geometries.length},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n<this._geometries.length;n++)e[n]=this._geometries[n].reverse();return this.getFactory().createGeometryCollection(e)},e.prototype.compareToSameClass=function(){if(1===arguments.length){var t=arguments[0],e=new sc(uc.asList(this._geometries)),n=new sc(uc.asList(t._geometries));return this.compare(e,n)}if(2===arguments.length){for(var r=arguments[1],i=arguments[0],o=this.getNumGeometries(),a=i.getNumGeometries(),s=0;s<o&&s<a;){var l=this.getGeometryN(s),u=i.getGeometryN(s),c=l.compareToSameClass(u,r);if(0!==c)return c;s++}return s<o?1:s<a?-1:0}},e.prototype.apply=function(){var t=this;if(ql(arguments[0],Iu))for(var e=arguments[0],n=0;n<this._geometries.length;n++)t._geometries[n].apply(e);else if(ql(arguments[0],fc)){var r=arguments[0];if(0===this._geometries.length)return null;for(var i=0;i<this._geometries.length&&(t._geometries[i].apply(r),!r.isDone());i++);r.isGeometryChanged()&&this.geometryChanged()}else if(ql(arguments[0],pc)){var o=arguments[0];o.filter(this);for(var a=0;a<this._geometries.length;a++)t._geometries[a].apply(o)}else if(ql(arguments[0],Su)){var s=arguments[0];s.filter(this);for(var l=0;l<this._geometries.length;l++)t._geometries[l].apply(s)}},e.prototype.getBoundary=function(){return this.checkNotGeometryCollection(this),gu.shouldNeverReachHere(),null},e.prototype.clone=function(){var e=t.prototype.clone.call(this);e._geometries=new Array(this._geometries.length).fill(null);for(var n=0;n<this._geometries.length;n++)e._geometries[n]=this._geometries[n].clone();return e},e.prototype.getGeometryType=function(){return"GeometryCollection"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.isEmpty=function(){for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isEmpty())return!1;return!0},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x4f07bcb1f857d800},Object.defineProperties(e,n),e}(Mu),mc=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Mu.SORTINDEX_MULTILINESTRING},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?cc.FALSE:0},e.prototype.isClosed=function(){if(this.isEmpty())return!1;for(var t=0;t<this._geometries.length;t++)if(!this._geometries[t].isClosed())return!1;return!0},e.prototype.getDimension=function(){return 1},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n<this._geometries.length;n++)e[t-1-n]=this._geometries[n].reverse();return this.getFactory().createMultiLineString(e)},e.prototype.getBoundary=function(){return new gc(this).getBoundary()},e.prototype.getGeometryType=function(){return"MultiLineString"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[oc]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x7155d2ab4afa8000},Object.defineProperties(e,n),e}(dc),gc=function(){if(this._geom=null,this._geomFact=null,this._bnRule=null,this._endpointMap=null,1===arguments.length){var t=arguments[0],e=Au.MOD2_BOUNDARY_RULE;this._geom=t,this._geomFact=t.getFactory(),this._bnRule=e}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this._geom=n,this._geomFact=n.getFactory(),this._bnRule=r}};gc.prototype.boundaryMultiLineString=function(t){if(this._geom.isEmpty())return this.getEmptyMultiPoint();var e=this.computeBoundaryCoordinates(t);return 1===e.length?this._geomFact.createPoint(e[0]):this._geomFact.createMultiPointFromCoords(e)},gc.prototype.getBoundary=function(){return this._geom instanceof Cc?this.boundaryLineString(this._geom):this._geom instanceof mc?this.boundaryMultiLineString(this._geom):this._geom.getBoundary()},gc.prototype.boundaryLineString=function(t){return this._geom.isEmpty()?this.getEmptyMultiPoint():t.isClosed()?this._bnRule.isInBoundary(2)?t.getStartPoint():this._geomFact.createMultiPoint():this._geomFact.createMultiPoint([t.getStartPoint(),t.getEndPoint()])},gc.prototype.getEmptyMultiPoint=function(){return this._geomFact.createMultiPoint()},gc.prototype.computeBoundaryCoordinates=function(t){var e=this,n=new Uu;this._endpointMap=new ic;for(var r=0;r<t.getNumGeometries();r++){var i=t.getGeometryN(r);0!==i.getNumPoints()&&(e.addEndpoint(i.getCoordinateN(0)),e.addEndpoint(i.getCoordinateN(i.getNumPoints()-1)))}for(var o=this._endpointMap.entrySet().iterator();o.hasNext();){var a=o.next(),s=a.getValue().count;e._bnRule.isInBoundary(s)&&n.add(a.getKey())}return ju.toCoordinateArray(n)},gc.prototype.addEndpoint=function(t){var e=this._endpointMap.get(t);null===e&&(e=new yc,this._endpointMap.put(t,e)),e.count++},gc.prototype.interfaces_=function(){return[]},gc.prototype.getClass=function(){return gc},gc.getBoundary=function(){if(1===arguments.length){return new gc(arguments[0]).getBoundary()}if(2===arguments.length){return new gc(arguments[0],arguments[1]).getBoundary()}};var yc=function(){this.count=null};function vc(){}function _c(){}yc.prototype.interfaces_=function(){return[]},yc.prototype.getClass=function(){return yc};var xc=function(){};function bc(){}function wc(){}function Ec(){}var Sc=function(){},Mc={NEWLINE:{configurable:!0},SIMPLE_ORDINATE_FORMAT:{configurable:!0}};Sc.prototype.interfaces_=function(){return[]},Sc.prototype.getClass=function(){return Sc},Sc.chars=function(t,e){for(var n=new Array(e).fill(null),r=0;r<e;r++)n[r]=t;return String(n)},Sc.getStackTrace=function(){if(1===arguments.length){var t=arguments[0],e=new bc,n=new vc(e);return t.printStackTrace(n),e.toString()}if(2===arguments.length){for(var r=arguments[1],i="",o=new Ec(new _c(Sc.getStackTrace(arguments[0]))),a=0;a<r;a++)try{i+=o.readLine()+Sc.NEWLINE}catch(t){if(!(t instanceof wc))throw t;gu.shouldNeverReachHere()}return i}},Sc.split=function(t,e){for(var n=e.length,r=new Uu,i=""+t,o=i.indexOf(e);o>=0;){var a=i.substring(0,o);r.add(a),o=(i=i.substring(o+n)).indexOf(e)}i.length>0&&r.add(i);for(var s=new Array(r.size()).fill(null),l=0;l<s.length;l++)s[l]=r.get(l);return s},Sc.toString=function(){if(1===arguments.length){var t=arguments[0];return Sc.SIMPLE_ORDINATE_FORMAT.format(t)}},Sc.spaces=function(t){return Sc.chars(" ",t)},Mc.NEWLINE.get=function(){return ou.getProperty("line.separator")},Mc.SIMPLE_ORDINATE_FORMAT.get=function(){return new xc("0.#")},Object.defineProperties(Sc,Mc);var Tc=function(){};Tc.prototype.interfaces_=function(){return[]},Tc.prototype.getClass=function(){return Tc},Tc.copyCoord=function(t,e,n,r){for(var i=Math.min(t.getDimension(),n.getDimension()),o=0;o<i;o++)n.setOrdinate(r,o,t.getOrdinate(e,o))},Tc.isRing=function(t){var e=t.size();return 0===e||!(e<=3)&&t.getOrdinate(0,eu.X)===t.getOrdinate(e-1,eu.X)&&t.getOrdinate(0,eu.Y)===t.getOrdinate(e-1,eu.Y)},Tc.isEqual=function(t,e){var n=t.size();if(n!==e.size())return!1;for(var r=Math.min(t.getDimension(),e.getDimension()),i=0;i<n;i++)for(var o=0;o<r;o++){var a=t.getOrdinate(i,o),s=e.getOrdinate(i,o);if(!(t.getOrdinate(i,o)===e.getOrdinate(i,o)||Dl.isNaN(a)&&Dl.isNaN(s)))return!1}return!0},Tc.extend=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();if(Tc.copy(e,0,r,0,i),i>0)for(var o=i;o<n;o++)Tc.copy(e,i-1,r,o,1);return r},Tc.reverse=function(t){for(var e=t.size()-1,n=Math.trunc(e/2),r=0;r<=n;r++)Tc.swap(t,r,e-r)},Tc.swap=function(t,e,n){if(e===n)return null;for(var r=0;r<t.getDimension();r++){var i=t.getOrdinate(e,r);t.setOrdinate(e,r,t.getOrdinate(n,r)),t.setOrdinate(n,r,i)}},Tc.copy=function(t,e,n,r,i){for(var o=0;o<i;o++)Tc.copyCoord(t,e+o,n,r+o)},Tc.toString=function(){if(1===arguments.length){var t=arguments[0],e=t.size();if(0===e)return"()";var n=t.getDimension(),r=new Zl;r.append("(");for(var i=0;i<e;i++){i>0&&r.append(" ");for(var o=0;o<n;o++)o>0&&r.append(","),r.append(Sc.toString(t.getOrdinate(i,o)))}return r.append(")"),r.toString()}},Tc.ensureValidRing=function(t,e){var n=e.size();return 0===n?e:n<=3?Tc.createClosedRing(t,e,4):e.getOrdinate(0,eu.X)===e.getOrdinate(n-1,eu.X)&&e.getOrdinate(0,eu.Y)===e.getOrdinate(n-1,eu.Y)?e:Tc.createClosedRing(t,e,n+1)},Tc.createClosedRing=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();Tc.copy(e,0,r,0,i);for(var o=i;o<n;o++)Tc.copy(e,0,r,o,1);return r};var Cc=function(t){function e(e,n){t.call(this,n),this._points=null,this.init(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){return this.isEmpty()?new su:this._points.expandEnvelope(new su)},e.prototype.isRing=function(){return this.isClosed()&&this.isSimple()},e.prototype.getSortIndex=function(){return t.SORTINDEX_LINESTRING},e.prototype.getCoordinates=function(){return this._points.toCoordinateArray()},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var r=e;if(this._points.size()!==r._points.size())return!1;for(var i=0;i<this._points.size();i++)if(!this.equal(this._points.getCoordinate(i),r._points.getCoordinate(i),n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){for(var t=this,e=0;e<Math.trunc(this._points.size()/2);e++){var n=t._points.size()-1-e;if(!t._points.getCoordinate(e).equals(t._points.getCoordinate(n)))return t._points.getCoordinate(e).compareTo(t._points.getCoordinate(n))>0&&Tc.reverse(t._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?cc.FALSE:0},e.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},e.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},e.prototype.getDimension=function(){return 1},e.prototype.getLength=function(){return wu.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var t=this._points.copy();return Tc.reverse(t),this.getFactory().createLineString(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e<this._points.size()&&n<t._points.size();){var r=this._points.getCoordinate(e).compareTo(t._points.getCoordinate(n));if(0!==r)return r;e++,n++}return e<this._points.size()?1:n<t._points.size()?-1:0}if(2===arguments.length){var i=arguments[0];return arguments[1].compare(this._points,i._points)}},e.prototype.apply=function(){if(ql(arguments[0],Iu))for(var t=arguments[0],e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e));else if(ql(arguments[0],fc)){var n=arguments[0];if(0===this._points.size())return null;for(var r=0;r<this._points.size()&&(n.filter(this._points,r),!n.isDone());r++);n.isGeometryChanged()&&this.geometryChanged()}else if(ql(arguments[0],pc)){arguments[0].filter(this)}else if(ql(arguments[0],Su)){arguments[0].filter(this)}},e.prototype.getBoundary=function(){return new gc(this).getBoundary()},e.prototype.isEquivalentClass=function(t){return t instanceof e},e.prototype.clone=function(){var e=t.prototype.clone.call(this);return e._points=this._points.clone(),e},e.prototype.getCoordinateN=function(t){return this._points.getCoordinate(t)},e.prototype.getGeometryType=function(){return"LineString"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.getCoordinateSequence=function(){return this._points},e.prototype.isEmpty=function(){return 0===this._points.size()},e.prototype.init=function(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new Rl("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this._points=t},e.prototype.isCoordinate=function(t){for(var e=0;e<this._points.size();e++)if(this._points.getCoordinate(e).equals(t))return!0;return!1},e.prototype.getStartPoint=function(){return this.isEmpty()?null:this.getPointN(0)},e.prototype.getPointN=function(t){return this.getFactory().createPoint(this._points.getCoordinate(t))},e.prototype.interfaces_=function(){return[oc]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x2b2b51ba435c8e00},Object.defineProperties(e,n),e}(Mu),Ic=function(){};Ic.prototype.interfaces_=function(){return[]},Ic.prototype.getClass=function(){return Ic};var Ac=function(t){function e(e,n){t.call(this,n),this._coordinates=e||null,this.init(this._coordinates)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){if(this.isEmpty())return new su;var t=new su;return t.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),t},e.prototype.getSortIndex=function(){return t.SORTINDEX_POINT},e.prototype.getCoordinates=function(){return this.isEmpty()?[]:[this.getCoordinate()]},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&(!(!this.isEmpty()||!e.isEmpty())||this.isEmpty()===e.isEmpty()&&this.equal(e.getCoordinate(),this.getCoordinate(),n))}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){},e.prototype.getCoordinate=function(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null},e.prototype.getBoundaryDimension=function(){return cc.FALSE},e.prototype.getDimension=function(){return 0},e.prototype.getNumPoints=function(){return this.isEmpty()?0:1},e.prototype.reverse=function(){return this.copy()},e.prototype.getX=function(){if(null===this.getCoordinate())throw new Error("getX called on empty Point");return this.getCoordinate().x},e.prototype.compareToSameClass=function(){if(1===arguments.length){var t=arguments[0];return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length){var e=arguments[0];return arguments[1].compare(this._coordinates,e._coordinates)}},e.prototype.apply=function(){if(ql(arguments[0],Iu)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(ql(arguments[0],fc)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else if(ql(arguments[0],pc)){arguments[0].filter(this)}else if(ql(arguments[0],Su)){arguments[0].filter(this)}},e.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},e.prototype.clone=function(){var e=t.prototype.clone.call(this);return e._coordinates=this._coordinates.clone(),e},e.prototype.getGeometryType=function(){return"Point"},e.prototype.copy=function(){return new e(this._coordinates.copy(),this._factory)},e.prototype.getCoordinateSequence=function(){return this._coordinates},e.prototype.getY=function(){if(null===this.getCoordinate())throw new Error("getY called on empty Point");return this.getCoordinate().y},e.prototype.isEmpty=function(){return 0===this._coordinates.size()},e.prototype.init=function(t){null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),gu.isTrue(t.size()<=1),this._coordinates=t},e.prototype.isSimple=function(){return!0},e.prototype.interfaces_=function(){return[Ic]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return 0x44077bad161cbc00},Object.defineProperties(e,n),e}(Mu),Lc=function(){};Lc.prototype.interfaces_=function(){return[]},Lc.prototype.getClass=function(){return Lc};var Pc=function(t){function e(e,n,r){if(t.call(this,r),this._shell=null,this._holes=null,null===e&&(e=this.getFactory().createLinearRing()),null===n&&(n=[]),t.hasNullElements(n))throw new Rl("holes must not contain null elements");if(e.isEmpty()&&t.hasNonEmptyElements(n))throw new Rl("shell is empty but holes are not");this._shell=e,this._holes=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.computeEnvelopeInternal=function(){return this._shell.getEnvelopeInternal()},e.prototype.getSortIndex=function(){return t.SORTINDEX_POLYGON},e.prototype.getCoordinates=function(){if(this.isEmpty())return[];for(var t=new Array(this.getNumPoints()).fill(null),e=-1,n=this._shell.getCoordinates(),r=0;r<n.length;r++)t[++e]=n[r];for(var i=0;i<this._holes.length;i++)for(var o=this._holes[i].getCoordinates(),a=0;a<o.length;a++)t[++e]=o[a];return t},e.prototype.getArea=function(){var t=0;t+=Math.abs(wu.signedArea(this._shell.getCoordinateSequence()));for(var e=0;e<this._holes.length;e++)t-=Math.abs(wu.signedArea(this._holes[e].getCoordinateSequence()));return t},e.prototype.isRectangle=function(){if(0!==this.getNumInteriorRing())return!1;if(null===this._shell)return!1;if(5!==this._shell.getNumPoints())return!1;for(var t=this._shell.getCoordinateSequence(),e=this.getEnvelopeInternal(),n=0;n<5;n++){var r=t.getX(n);if(r!==e.getMinX()&&r!==e.getMaxX())return!1;var i=t.getY(n);if(i!==e.getMinY()&&i!==e.getMaxY())return!1}for(var o=t.getX(0),a=t.getY(0),s=1;s<=4;s++){var l=t.getX(s),u=t.getY(s);if(l!==o==(u!==a))return!1;o=l,a=u}return!0},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];if(!this.isEquivalentClass(e))return!1;var r=e,i=this._shell,o=r._shell;if(!i.equalsExact(o,n))return!1;if(this._holes.length!==r._holes.length)return!1;for(var a=0;a<this._holes.length;a++)if(!this._holes[a].equalsExact(r._holes[a],n))return!1;return!0}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.normalize=function(){if(0===arguments.length){this.normalize(this._shell,!0);for(var t=0;t<this._holes.length;t++)this.normalize(this._holes[t],!1);uc.sort(this._holes)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(e.isEmpty())return null;var r=new Array(e.getCoordinates().length-1).fill(null);ou.arraycopy(e.getCoordinates(),0,r,0,r.length);var i=ju.minCoordinate(e.getCoordinates());ju.scroll(r,i),ou.arraycopy(r,0,e.getCoordinates(),0,r.length),e.getCoordinates()[r.length]=r[0],wu.isCCW(e.getCoordinates())===n&&ju.reverse(e.getCoordinates())}},e.prototype.getCoordinate=function(){return this._shell.getCoordinate()},e.prototype.getNumInteriorRing=function(){return this._holes.length},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.getLength=function(){var t=0;t+=this._shell.getLength();for(var e=0;e<this._holes.length;e++)t+=this._holes[e].getLength();return t},e.prototype.getNumPoints=function(){for(var t=this._shell.getNumPoints(),e=0;e<this._holes.length;e++)t+=this._holes[e].getNumPoints();return t},e.prototype.reverse=function(){var t=this.copy();t._shell=this._shell.copy().reverse(),t._holes=new Array(this._holes.length).fill(null);for(var e=0;e<this._holes.length;e++)t._holes[e]=this._holes[e].copy().reverse();return t},e.prototype.convexHull=function(){return this.getExteriorRing().convexHull()},e.prototype.compareToSameClass=function(){if(1===arguments.length){var t=arguments[0],e=this._shell,n=t._shell;return e.compareToSameClass(n)}if(2===arguments.length){var r=arguments[1],i=arguments[0],o=this._shell,a=i._shell,s=o.compareToSameClass(a,r);if(0!==s)return s;for(var l=this.getNumInteriorRing(),u=i.getNumInteriorRing(),c=0;c<l&&c<u;){var h=this.getInteriorRingN(c),p=i.getInteriorRingN(c),f=h.compareToSameClass(p,r);if(0!==f)return f;c++}return c<l?1:c<u?-1:0}},e.prototype.apply=function(t){var e=this;if(ql(t,Iu)){this._shell.apply(t);for(var n=0;n<this._holes.length;n++)e._holes[n].apply(t)}else if(ql(t,fc)){if(this._shell.apply(t),!t.isDone())for(var r=0;r<this._holes.length&&(e._holes[r].apply(t),!t.isDone());r++);t.isGeometryChanged()&&this.geometryChanged()}else if(ql(t,pc))t.filter(this);else if(ql(t,Su)){t.filter(this),this._shell.apply(t);for(var i=0;i<this._holes.length;i++)e._holes[i].apply(t)}},e.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var t=new Array(this._holes.length+1).fill(null);t[0]=this._shell;for(var e=0;e<this._holes.length;e++)t[e+1]=this._holes[e];return t.length<=1?this.getFactory().createLinearRing(t[0].getCoordinateSequence()):this.getFactory().createMultiLineString(t)},e.prototype.clone=function(){var e=t.prototype.clone.call(this);e._shell=this._shell.clone(),e._holes=new Array(this._holes.length).fill(null);for(var n=0;n<this._holes.length;n++)e._holes[n]=this._holes[n].clone();return e},e.prototype.getGeometryType=function(){return"Polygon"},e.prototype.copy=function(){for(var t=this._shell.copy(),n=new Array(this._holes.length).fill(null),r=0;r<n.length;r++)n[r]=this._holes[r].copy();return new e(t,n,this._factory)},e.prototype.getExteriorRing=function(){return this._shell},e.prototype.isEmpty=function(){return this._shell.isEmpty()},e.prototype.getInteriorRingN=function(t){return this._holes[t]},e.prototype.interfaces_=function(){return[Lc]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x307ffefd8dc97200},Object.defineProperties(e,n),e}(Mu),Rc=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Mu.SORTINDEX_MULTIPOINT},e.prototype.isValid=function(){return!0},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getCoordinate=function(){if(1===arguments.length){var e=arguments[0];return this._geometries[e].getCoordinate()}return t.prototype.getCoordinate.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return cc.FALSE},e.prototype.getDimension=function(){return 0},e.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},e.prototype.getGeometryType=function(){return"MultiPoint"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[Ic]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x6fb1ed4162e0fc00},Object.defineProperties(e,n),e}(dc),Dc=function(t){function e(e,n){e instanceof Bl&&n instanceof Yc&&(e=n.getCoordinateSequenceFactory().create(e)),t.call(this,e,n),this.validateConstruction()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={MINIMUM_VALID_SIZE:{configurable:!0},serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Mu.SORTINDEX_LINEARRING},e.prototype.getBoundaryDimension=function(){return cc.FALSE},e.prototype.isClosed=function(){return!!this.isEmpty()||t.prototype.isClosed.call(this)},e.prototype.reverse=function(){var t=this._points.copy();return Tc.reverse(t),this.getFactory().createLinearRing(t)},e.prototype.validateConstruction=function(){if(!this.isEmpty()&&!t.prototype.isClosed.call(this))throw new Rl("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<e.MINIMUM_VALID_SIZE)throw new Rl("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")},e.prototype.getGeometryType=function(){return"LinearRing"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.MINIMUM_VALID_SIZE.get=function(){return 4},n.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(e,n),e}(Cc),Nc=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Mu.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n<this._geometries.length;n++)e[n]=this._geometries[n].reverse();return this.getFactory().createMultiPolygon(e)},e.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var t=new Uu,e=0;e<this._geometries.length;e++)for(var n=this._geometries[e].getBoundary(),r=0;r<n.getNumGeometries();r++)t.add(n.getGeometryN(r));var i=new Array(t.size()).fill(null);return this.getFactory().createMultiLineString(t.toArray(i))},e.prototype.getGeometryType=function(){return"MultiPolygon"},e.prototype.copy=function(){for(var t=new Array(this._geometries.length).fill(null),n=0;n<t.length;n++)t[n]=this._geometries[n].copy();return new e(t,this._factory)},e.prototype.interfaces_=function(){return[Lc]},e.prototype.getClass=function(){return e},n.serialVersionUID.get=function(){return-0x7a5aa1369171980},Object.defineProperties(e,n),e}(dc),Oc=function(t){this._factory=t||null,this._isUserDataCopied=!1},kc={NoOpGeometryOperation:{configurable:!0},CoordinateOperation:{configurable:!0},CoordinateSequenceOperation:{configurable:!0}};Oc.prototype.setCopyUserData=function(t){this._isUserDataCopied=t},Oc.prototype.edit=function(t,e){if(null===t)return null;var n=this.editInternal(t,e);return this._isUserDataCopied&&n.setUserData(t.getUserData()),n},Oc.prototype.editInternal=function(t,e){return null===this._factory&&(this._factory=t.getFactory()),t instanceof dc?this.editGeometryCollection(t,e):t instanceof Pc?this.editPolygon(t,e):t instanceof Ac||t instanceof Cc?e.edit(t,this._factory):(gu.shouldNeverReachHere("Unsupported Geometry class: "+t.getClass().getName()),null)},Oc.prototype.editGeometryCollection=function(t,e){for(var n=e.edit(t,this._factory),r=new Uu,i=0;i<n.getNumGeometries();i++){var o=this.edit(n.getGeometryN(i),e);null===o||o.isEmpty()||r.add(o)}return n.getClass()===Rc?this._factory.createMultiPoint(r.toArray([])):n.getClass()===mc?this._factory.createMultiLineString(r.toArray([])):n.getClass()===Nc?this._factory.createMultiPolygon(r.toArray([])):this._factory.createGeometryCollection(r.toArray([]))},Oc.prototype.editPolygon=function(t,e){var n=e.edit(t,this._factory);if(null===n&&(n=this._factory.createPolygon(null)),n.isEmpty())return n;var r=this.edit(n.getExteriorRing(),e);if(null===r||r.isEmpty())return this._factory.createPolygon();for(var i=new Uu,o=0;o<n.getNumInteriorRing();o++){var a=this.edit(n.getInteriorRingN(o),e);null===a||a.isEmpty()||i.add(a)}return this._factory.createPolygon(r,i.toArray([]))},Oc.prototype.interfaces_=function(){return[]},Oc.prototype.getClass=function(){return Oc},Oc.GeometryEditorOperation=function(){},kc.NoOpGeometryOperation.get=function(){return zc},kc.CoordinateOperation.get=function(){return Fc},kc.CoordinateSequenceOperation.get=function(){return Bc},Object.defineProperties(Oc,kc);var zc=function(){};zc.prototype.edit=function(t,e){return t},zc.prototype.interfaces_=function(){return[Oc.GeometryEditorOperation]},zc.prototype.getClass=function(){return zc};var Fc=function(){};Fc.prototype.edit=function(t,e){var n=this.editCoordinates(t.getCoordinates(),t);return null===n?t:t instanceof Dc?e.createLinearRing(n):t instanceof Cc?e.createLineString(n):t instanceof Ac?n.length>0?e.createPoint(n[0]):e.createPoint():t},Fc.prototype.interfaces_=function(){return[Oc.GeometryEditorOperation]},Fc.prototype.getClass=function(){return Fc};var Bc=function(){};Bc.prototype.edit=function(t,e){return t instanceof Dc?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Cc?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof Ac?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},Bc.prototype.interfaces_=function(){return[Oc.GeometryEditorOperation]},Bc.prototype.getClass=function(){return Bc};var Uc=function(){var t=this;if(this._dimension=3,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var e=arguments[0];this._coordinates=new Array(e).fill(null);for(var n=0;n<e;n++)t._coordinates[n]=new Bl}else if(ql(arguments[0],eu)){var r=arguments[0];if(null===r)return this._coordinates=new Array(0).fill(null),null;this._dimension=r.getDimension(),this._coordinates=new Array(r.size()).fill(null);for(var i=0;i<this._coordinates.length;i++)t._coordinates[i]=r.getCoordinateCopy(i)}}else if(2===arguments.length)if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var o=arguments[0],a=arguments[1];this._coordinates=o,this._dimension=a,null===o&&(this._coordinates=new Array(0).fill(null))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var s=arguments[0],l=arguments[1];this._coordinates=new Array(s).fill(null),this._dimension=l;for(var u=0;u<s;u++)t._coordinates[u]=new Bl}},Vc={serialVersionUID:{configurable:!0}};Uc.prototype.setOrdinate=function(t,e,n){switch(e){case eu.X:this._coordinates[t].x=n;break;case eu.Y:this._coordinates[t].y=n;break;case eu.Z:this._coordinates[t].z=n;break;default:throw new Rl("invalid ordinateIndex")}},Uc.prototype.size=function(){return this._coordinates.length},Uc.prototype.getOrdinate=function(t,e){switch(e){case eu.X:return this._coordinates[t].x;case eu.Y:return this._coordinates[t].y;case eu.Z:return this._coordinates[t].z}return Dl.NaN},Uc.prototype.getCoordinate=function(){if(1===arguments.length){var t=arguments[0];return this._coordinates[t]}if(2===arguments.length){var e=arguments[0],n=arguments[1];n.x=this._coordinates[e].x,n.y=this._coordinates[e].y,n.z=this._coordinates[e].z}},Uc.prototype.getCoordinateCopy=function(t){return new Bl(this._coordinates[t])},Uc.prototype.getDimension=function(){return this._dimension},Uc.prototype.getX=function(t){return this._coordinates[t].x},Uc.prototype.clone=function(){for(var t=new Array(this.size()).fill(null),e=0;e<this._coordinates.length;e++)t[e]=this._coordinates[e].clone();return new Uc(t,this._dimension)},Uc.prototype.expandEnvelope=function(t){for(var e=0;e<this._coordinates.length;e++)t.expandToInclude(this._coordinates[e]);return t},Uc.prototype.copy=function(){for(var t=new Array(this.size()).fill(null),e=0;e<this._coordinates.length;e++)t[e]=this._coordinates[e].copy();return new Uc(t,this._dimension)},Uc.prototype.toString=function(){if(this._coordinates.length>0){var t=new Zl(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e<this._coordinates.length;e++)t.append(", "),t.append(this._coordinates[e]);return t.append(")"),t.toString()}return"()"},Uc.prototype.getY=function(t){return this._coordinates[t].y},Uc.prototype.toCoordinateArray=function(){return this._coordinates},Uc.prototype.interfaces_=function(){return[eu,Fl]},Uc.prototype.getClass=function(){return Uc},Vc.serialVersionUID.get=function(){return-0xcb44a778db18e00},Object.defineProperties(Uc,Vc);var Gc=function(){},jc={serialVersionUID:{configurable:!0},instanceObject:{configurable:!0}};Gc.prototype.readResolve=function(){return Gc.instance()},Gc.prototype.create=function(){if(1===arguments.length){if(arguments[0]instanceof Array){return new Uc(arguments[0])}if(ql(arguments[0],eu)){return new Uc(arguments[0])}}else if(2===arguments.length){var t=arguments[0],e=arguments[1];return e>3&&(e=3),e<2?new Uc(t):new Uc(t,e)}},Gc.prototype.interfaces_=function(){return[Gl,Fl]},Gc.prototype.getClass=function(){return Gc},Gc.instance=function(){return Gc.instanceObject},jc.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},jc.instanceObject.get=function(){return new Gc},Object.defineProperties(Gc,jc);var Hc=function(t){function e(){t.call(this),this.map_=new Map}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return this.map_.get(t)||null},e.prototype.put=function(t,e){return this.map_.set(t,e),e},e.prototype.values=function(){for(var t=new Uu,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},e.prototype.entrySet=function(){var t=new Ku;return this.map_.entries().forEach((function(e){return t.add(e)})),t},e.prototype.size=function(){return this.map_.size()},e}(Xu),qc=function t(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Xc){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var r=arguments[0];this._modelType=r._modelType,this._scale=r._scale}},Wc={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};qc.prototype.equals=function(t){if(!(t instanceof qc))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale},qc.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),r=e.getMaximumSignificantDigits();return new Yl(n).compareTo(new Yl(r))},qc.prototype.getScale=function(){return this._scale},qc.prototype.isFloating=function(){return this._modelType===qc.FLOATING||this._modelType===qc.FLOATING_SINGLE},qc.prototype.getType=function(){return this._modelType},qc.prototype.toString=function(){var t="UNKNOWN";return this._modelType===qc.FLOATING?t="Floating":this._modelType===qc.FLOATING_SINGLE?t="Floating-Single":this._modelType===qc.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},qc.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];return Dl.isNaN(t)||this._modelType===qc.FLOATING_SINGLE?t:this._modelType===qc.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof Bl){var e=arguments[0];if(this._modelType===qc.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},qc.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===qc.FLOATING?t=16:this._modelType===qc.FLOATING_SINGLE?t=6:this._modelType===qc.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},qc.prototype.setScale=function(t){this._scale=Math.abs(t)},qc.prototype.interfaces_=function(){return[Fl,Ol]},qc.prototype.getClass=function(){return qc},qc.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},Wc.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},Wc.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(qc,Wc);var Xc=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},Zc={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};Xc.prototype.readResolve=function(){return Xc.nameToTypeMap.get(this._name)},Xc.prototype.toString=function(){return this._name},Xc.prototype.interfaces_=function(){return[Fl]},Xc.prototype.getClass=function(){return Xc},Zc.serialVersionUID.get=function(){return-552860263173159e4},Zc.nameToTypeMap.get=function(){return new Hc},Object.defineProperties(Xc,Zc),qc.Type=Xc,qc.FIXED=new Xc("FIXED"),qc.FLOATING=new Xc("FLOATING"),qc.FLOATING_SINGLE=new Xc("FLOATING SINGLE");var Yc=function t(){this._precisionModel=new qc,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?ql(arguments[0],Gl)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof qc&&(this._precisionModel=arguments[0]):2===arguments.length?(this._precisionModel=arguments[0],this._SRID=arguments[1]):3===arguments.length&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]))},Jc={serialVersionUID:{configurable:!0}};Yc.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new Bl(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new Bl(t.getMinX(),t.getMinY()),new Bl(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new Bl(t.getMinX(),t.getMinY()),new Bl(t.getMinX(),t.getMaxY()),new Bl(t.getMaxX(),t.getMaxY()),new Bl(t.getMaxX(),t.getMinY()),new Bl(t.getMinX(),t.getMinY())]),null)},Yc.prototype.createLineString=function(t){return t?t instanceof Array?new Cc(this.getCoordinateSequenceFactory().create(t),this):ql(t,eu)?new Cc(t,this):void 0:new Cc(this.getCoordinateSequenceFactory().create([]),this)},Yc.prototype.createMultiLineString=function(){if(0===arguments.length)return new mc(null,this);if(1===arguments.length){return new mc(arguments[0],this)}},Yc.prototype.buildGeometry=function(t){for(var e=null,n=!1,r=!1,i=t.iterator();i.hasNext();){var o=i.next(),a=o.getClass();null===e&&(e=a),a!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(r=!0)}if(null===e)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(Yc.toGeometryArray(t));var s=t.iterator().next();if(t.size()>1){if(s instanceof Pc)return this.createMultiPolygon(Yc.toPolygonArray(t));if(s instanceof Cc)return this.createMultiLineString(Yc.toLineStringArray(t));if(s instanceof Ac)return this.createMultiPoint(Yc.toPointArray(t));gu.shouldNeverReachHere("Unhandled class: "+s.getClass().getName())}return s},Yc.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},Yc.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(ql(arguments[0],eu)){return new Ac(arguments[0],this)}}},Yc.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},Yc.prototype.createPolygon=function(){if(0===arguments.length)return new Pc(null,null,this);if(1===arguments.length){if(ql(arguments[0],eu)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Dc){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){return new Pc(arguments[0],arguments[1],this)}},Yc.prototype.getSRID=function(){return this._SRID},Yc.prototype.createGeometryCollection=function(){if(0===arguments.length)return new dc(null,this);if(1===arguments.length){return new dc(arguments[0],this)}},Yc.prototype.createGeometry=function(t){return new Oc(this).edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return this._coordinateSequenceFactory.create(t)}}})},Yc.prototype.getPrecisionModel=function(){return this._precisionModel},Yc.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(ql(arguments[0],eu)){return new Dc(arguments[0],this)}}},Yc.prototype.createMultiPolygon=function(){if(0===arguments.length)return new Nc(null,this);if(1===arguments.length){return new Nc(arguments[0],this)}},Yc.prototype.createMultiPoint=function(){if(0===arguments.length)return new Rc(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new Rc(arguments[0],this)}if(arguments[0]instanceof Array){var t=arguments[0];return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(ql(arguments[0],eu)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var n=new Array(e.size()).fill(null),r=0;r<e.size();r++){var i=this.getCoordinateSequenceFactory().create(1,e.getDimension());Tc.copy(e,r,i,0,1),n[r]=this.createPoint(i)}return this.createMultiPoint(n)}}},Yc.prototype.interfaces_=function(){return[Fl]},Yc.prototype.getClass=function(){return Yc},Yc.toMultiPolygonArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toGeometryArray=function(t){if(null===t)return null;var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.getDefaultCoordinateSequenceFactory=function(){return Gc.instance()},Yc.toMultiLineStringArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toLineStringArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toMultiPointArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toLinearRingArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toPointArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.toPolygonArray=function(t){var e=new Array(t.size()).fill(null);return t.toArray(e)},Yc.createPointFromInternalCoord=function(t,e){return e.getPrecisionModel().makePrecise(t),e.getFactory().createPoint(t)},Jc.serialVersionUID.get=function(){return-0x5ea75f2051eeb400},Object.defineProperties(Yc,Jc);var Kc=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],Qc=function(t){this.geometryFactory=t||new Yc};Qc.prototype.read=function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!$c[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==Kc.indexOf(n)?$c[n].apply(this,[e.coordinates]):"GeometryCollection"===n?$c[n].apply(this,[e.geometries]):$c[n].apply(this,[e])},Qc.prototype.write=function(t){var e=t.getGeometryType();if(!th[e])throw new Error("Geometry is not supported");return th[e].apply(this,[t])};var $c={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var r=t.geometry.type;if(!$c[r])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=$c.bbox.apply(this,[t.bbox])),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n<t.features.length;++n)e.features.push(this.read(t.features[n]))}return t.bbox&&(e.bbox=this.parse.bbox.apply(this,[t.bbox])),e},coordinates:function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n];e.push(new Bl(r[0],r[1]))}return e},bbox:function(t){return this.geometryFactory.createLinearRing([new Bl(t[0],t[1]),new Bl(t[2],t[1]),new Bl(t[2],t[3]),new Bl(t[0],t[3]),new Bl(t[0],t[1])])},Point:function(t){var e=new Bl(t[0],t[1]);return this.geometryFactory.createPoint(e)},MultiPoint:function(t){for(var e=[],n=0;n<t.length;++n)e.push($c.Point.apply(this,[t[n]]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=$c.coordinates.apply(this,[t]);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push($c.LineString.apply(this,[t[n]]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=$c.coordinates.apply(this,[t[0]]),n=this.geometryFactory.createLinearRing(e),r=[],i=1;i<t.length;++i){var o=t[i],a=$c.coordinates.apply(this,[o]),s=this.geometryFactory.createLinearRing(a);r.push(s)}return this.geometryFactory.createPolygon(n,r)},MultiPolygon:function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n];e.push($c.Polygon.apply(this,[r]))}return this.geometryFactory.createMultiPolygon(e)},GeometryCollection:function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n];e.push(this.read(r))}return this.geometryFactory.createGeometryCollection(e)}},th={coordinate:function(t){return[t.x,t.y]},Point:function(t){return{type:"Point",coordinates:th.coordinate.apply(this,[t.getCoordinate()])}},MultiPoint:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var r=t._geometries[n],i=th.Point.apply(this,[r]);e.push(i.coordinates)}return{type:"MultiPoint",coordinates:e}},LineString:function(t){for(var e=[],n=t.getCoordinates(),r=0;r<n.length;++r){var i=n[r];e.push(th.coordinate.apply(this,[i]))}return{type:"LineString",coordinates:e}},MultiLineString:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var r=t._geometries[n],i=th.LineString.apply(this,[r]);e.push(i.coordinates)}return{type:"MultiLineString",coordinates:e}},Polygon:function(t){var e=[],n=th.LineString.apply(this,[t._shell]);e.push(n.coordinates);for(var r=0;r<t._holes.length;++r){var i=t._holes[r],o=th.LineString.apply(this,[i]);e.push(o.coordinates)}return{type:"Polygon",coordinates:e}},MultiPolygon:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var r=t._geometries[n],i=th.Polygon.apply(this,[r]);e.push(i.coordinates)}return{type:"MultiPolygon",coordinates:e}},GeometryCollection:function(t){for(var e=[],n=0;n<t._geometries.length;++n){var r=t._geometries[n],i=r.getGeometryType();e.push(th[i].apply(this,[r]))}return{type:"GeometryCollection",geometries:e}}},eh=function(t){this.geometryFactory=t||new Yc,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new Qc(this.geometryFactory)};eh.prototype.read=function(t){var e=this.parser.read(t);return this.precisionModel.getType()===qc.FIXED&&this.reducePrecision(e),e},eh.prototype.reducePrecision=function(t){var e,n;if(t.coordinate)this.precisionModel.makePrecise(t.coordinate);else if(t.points)for(e=0,n=t.points.length;e<n;e++)this.precisionModel.makePrecise(t.points[e]);else if(t.geometries)for(e=0,n=t.geometries.length;e<n;e++)this.reducePrecision(t.geometries[e])};var nh=function(){this.parser=new Qc(this.geometryFactory)};nh.prototype.write=function(t){return this.parser.write(t)};var rh=function(){},ih={ON:{configurable:!0},LEFT:{configurable:!0},RIGHT:{configurable:!0}};function oh(t){this.message=t||""}function ah(){this.array_=[]}rh.prototype.interfaces_=function(){return[]},rh.prototype.getClass=function(){return rh},rh.opposite=function(t){return t===rh.LEFT?rh.RIGHT:t===rh.RIGHT?rh.LEFT:t},ih.ON.get=function(){return 0},ih.LEFT.get=function(){return 1},ih.RIGHT.get=function(){return 2},Object.defineProperties(rh,ih),oh.prototype=new Error,oh.prototype.name="EmptyStackException",ah.prototype=new Fu,ah.prototype.add=function(t){return this.array_.push(t),!0},ah.prototype.get=function(t){if(t<0||t>=this.size())throw new Error;return this.array_[t]},ah.prototype.push=function(t){return this.array_.push(t),t},ah.prototype.pop=function(t){if(0===this.array_.length)throw new oh;return this.array_.pop()},ah.prototype.peek=function(){if(0===this.array_.length)throw new oh;return this.array_[this.array_.length-1]},ah.prototype.empty=function(){return 0===this.array_.length},ah.prototype.isEmpty=function(){return this.empty()},ah.prototype.search=function(t){return this.array_.indexOf(t)},ah.prototype.size=function(){return this.array_.length},ah.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e<n;e++)t.push(this.array_[e]);return t};var sh=function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null};sh.prototype.getCoordinate=function(){return this._minCoord},sh.prototype.getRightmostSide=function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n},sh.prototype.findRightmostEdgeAtVertex=function(){var t=this._minDe.getEdge().getCoordinates();gu.isTrue(this._minIndex>0&&this._minIndex<t.length,"rightmost point expected to be interior vertex of edge");var e=t[this._minIndex-1],n=t[this._minIndex+1],r=wu.computeOrientation(this._minCoord,n,e),i=!1;(e.y<this._minCoord.y&&n.y<this._minCoord.y&&r===wu.COUNTERCLOCKWISE||e.y>this._minCoord.y&&n.y>this._minCoord.y&&r===wu.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1)},sh.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var r=rh.LEFT;return n[e].y<n[e+1].y&&(r=rh.RIGHT),r},sh.prototype.getEdge=function(){return this._orientedDe},sh.prototype.checkForRightmostCoordinate=function(t){for(var e=this,n=t.getEdge().getCoordinates(),r=0;r<n.length-1;r++)(null===e._minCoord||n[r].x>e._minCoord.x)&&(e._minDe=t,e._minIndex=r,e._minCoord=n[r])},sh.prototype.findRightmostEdgeAtNode=function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)},sh.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}gu.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===rh.LEFT&&(this._orientedDe=this._minDe.getSym())},sh.prototype.interfaces_=function(){return[]},sh.prototype.getClass=function(){return sh};var lh=function(t){function e(n,r){t.call(this,e.msgWithCoord(n,r)),this.pt=r?new Bl(r):null,this.name="TopologyException"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCoordinate=function(){return this.pt},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.msgWithCoord=function(t,e){return e?t:t+" [ "+e+" ]"},e}(du),uh=function(){this.array_=[]};uh.prototype.addLast=function(t){this.array_.push(t)},uh.prototype.removeFirst=function(){return this.array_.shift()},uh.prototype.isEmpty=function(){return 0===this.array_.length};var ch=function(){this._finder=null,this._dirEdgeList=new Uu,this._nodes=new Uu,this._rightMostCoord=null,this._env=null,this._finder=new sh};ch.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)},ch.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},ch.prototype.computeNodeDepth=function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var r=n.next();if(r.isVisited()||r.getSym().isVisited()){e=r;break}}if(null===e)throw new lh("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var i=t.getEdges().iterator();i.hasNext();){var o=i.next();o.setVisited(!0),this.copySymDepths(o)}},ch.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(rh.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},ch.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},ch.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(rh.RIGHT)>=1&&e.getDepth(rh.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},ch.prototype.computeDepths=function(t){var e=new Ku,n=new uh,r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var a=o.next().getSym();if(!a.isVisited()){var s=a.getNode();e.contains(s)||(n.addLast(s),e.add(s))}}}},ch.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.x<e._rightMostCoord.x?-1:this._rightMostCoord.x>e._rightMostCoord.x?1:0},ch.prototype.getEnvelope=function(){if(null===this._env){for(var t=new su,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;r<n.length-1;r++)t.expandToInclude(n[r]);this._env=t}return this._env},ch.prototype.addReachable=function(t){var e=new ah;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}},ch.prototype.copySymDepths=function(t){var e=t.getSym();e.setDepth(rh.LEFT,t.getDepth(rh.RIGHT)),e.setDepth(rh.RIGHT,t.getDepth(rh.LEFT))},ch.prototype.add=function(t,e){t.setVisited(!0),this._nodes.add(t);for(var n=t.getEdges().iterator();n.hasNext();){var r=n.next();this._dirEdgeList.add(r);var i=r.getSym().getNode();i.isVisited()||e.push(i)}},ch.prototype.getNodes=function(){return this._nodes},ch.prototype.getDirectedEdges=function(){return this._dirEdgeList},ch.prototype.interfaces_=function(){return[Ol]},ch.prototype.getClass=function(){return ch};var hh=function t(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];this.init(e.length)}else if(Number.isInteger(arguments[0])){var n=arguments[0];this.init(1),this.location[rh.ON]=n}else if(arguments[0]instanceof t){var r=arguments[0];if(this.init(r.location.length),null!==r)for(var i=0;i<this.location.length;i++)this.location[i]=r.location[i]}}else if(3===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2];this.init(3),this.location[rh.ON]=o,this.location[rh.LEFT]=a,this.location[rh.RIGHT]=s}};hh.prototype.setAllLocations=function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t},hh.prototype.isNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==jl.NONE)return!1;return!0},hh.prototype.setAllLocationsIfNull=function(t){for(var e=0;e<this.location.length;e++)this.location[e]===jl.NONE&&(this.location[e]=t)},hh.prototype.isLine=function(){return 1===this.location.length},hh.prototype.merge=function(t){if(t.location.length>this.location.length){var e=new Array(3).fill(null);e[rh.ON]=this.location[rh.ON],e[rh.LEFT]=jl.NONE,e[rh.RIGHT]=jl.NONE,this.location=e}for(var n=0;n<this.location.length;n++)this.location[n]===jl.NONE&&n<t.location.length&&(this.location[n]=t.location[n])},hh.prototype.getLocations=function(){return this.location},hh.prototype.flip=function(){if(this.location.length<=1)return null;var t=this.location[rh.LEFT];this.location[rh.LEFT]=this.location[rh.RIGHT],this.location[rh.RIGHT]=t},hh.prototype.toString=function(){var t=new Zl;return this.location.length>1&&t.append(jl.toLocationSymbol(this.location[rh.LEFT])),t.append(jl.toLocationSymbol(this.location[rh.ON])),this.location.length>1&&t.append(jl.toLocationSymbol(this.location[rh.RIGHT])),t.toString()},hh.prototype.setLocations=function(t,e,n){this.location[rh.ON]=t,this.location[rh.LEFT]=e,this.location[rh.RIGHT]=n},hh.prototype.get=function(t){return t<this.location.length?this.location[t]:jl.NONE},hh.prototype.isArea=function(){return this.location.length>1},hh.prototype.isAnyNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===jl.NONE)return!0;return!1},hh.prototype.setLocation=function(){if(1===arguments.length){var t=arguments[0];this.setLocation(rh.ON,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.location[e]=n}},hh.prototype.init=function(t){this.location=new Array(t).fill(null),this.setAllLocations(jl.NONE)},hh.prototype.isEqualOnSide=function(t,e){return this.location[e]===t.location[e]},hh.prototype.allPositionsEqual=function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0},hh.prototype.interfaces_=function(){return[]},hh.prototype.getClass=function(){return hh};var ph=function t(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var e=arguments[0];this.elt[0]=new hh(e),this.elt[1]=new hh(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.elt[0]=new hh(n.elt[0]),this.elt[1]=new hh(n.elt[1])}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.elt[0]=new hh(jl.NONE),this.elt[1]=new hh(jl.NONE),this.elt[r].setLocation(i)}else if(3===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2];this.elt[0]=new hh(o,a,s),this.elt[1]=new hh(o,a,s)}else if(4===arguments.length){var l=arguments[0],u=arguments[1],c=arguments[2],h=arguments[3];this.elt[0]=new hh(jl.NONE,jl.NONE,jl.NONE),this.elt[1]=new hh(jl.NONE,jl.NONE,jl.NONE),this.elt[l].setLocations(u,c,h)}};ph.prototype.getGeometryCount=function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t},ph.prototype.setAllLocations=function(t,e){this.elt[t].setAllLocations(e)},ph.prototype.isNull=function(t){return this.elt[t].isNull()},ph.prototype.setAllLocationsIfNull=function(){if(1===arguments.length){var t=arguments[0];this.setAllLocationsIfNull(0,t),this.setAllLocationsIfNull(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.elt[e].setAllLocationsIfNull(n)}},ph.prototype.isLine=function(t){return this.elt[t].isLine()},ph.prototype.merge=function(t){for(var e=this,n=0;n<2;n++)null===e.elt[n]&&null!==t.elt[n]?e.elt[n]=new hh(t.elt[n]):e.elt[n].merge(t.elt[n])},ph.prototype.flip=function(){this.elt[0].flip(),this.elt[1].flip()},ph.prototype.getLocation=function(){if(1===arguments.length){var t=arguments[0];return this.elt[t].get(rh.ON)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.elt[e].get(n)}},ph.prototype.toString=function(){var t=new Zl;return null!==this.elt[0]&&(t.append("A:"),t.append(this.elt[0].toString())),null!==this.elt[1]&&(t.append(" B:"),t.append(this.elt[1].toString())),t.toString()},ph.prototype.isArea=function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var t=arguments[0];return this.elt[t].isArea()}},ph.prototype.isAnyNull=function(t){return this.elt[t].isAnyNull()},ph.prototype.setLocation=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.elt[t].setLocation(rh.ON,e)}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this.elt[n].setLocation(r,i)}},ph.prototype.isEqualOnSide=function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)},ph.prototype.allPositionsEqual=function(t,e){return this.elt[t].allPositionsEqual(e)},ph.prototype.toLine=function(t){this.elt[t].isArea()&&(this.elt[t]=new hh(this.elt[t].location[0]))},ph.prototype.interfaces_=function(){return[]},ph.prototype.getClass=function(){return ph},ph.toLineLabel=function(t){for(var e=new ph(jl.NONE),n=0;n<2;n++)e.setLocation(n,t.getLocation(n));return e};var fh=function(){this._startDe=null,this._maxNodeDegree=-1,this._edges=new Uu,this._pts=new Uu,this._label=new ph(jl.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new Uu,this._geometryFactory=null;var t=arguments[0],e=arguments[1];this._geometryFactory=e,this.computePoints(t),this.computeRing()};fh.prototype.computeRing=function(){if(null!==this._ring)return null;for(var t=new Array(this._pts.size()).fill(null),e=0;e<this._pts.size();e++)t[e]=this._pts.get(e);this._ring=this._geometryFactory.createLinearRing(t),this._isHole=wu.isCCW(this._ring.getCoordinates())},fh.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},fh.prototype.computePoints=function(t){var e=this;this._startDe=t;var n=t,r=!0;do{if(null===n)throw new lh("Found null DirectedEdge");if(n.getEdgeRing()===e)throw new lh("Directed Edge visited twice during ring-building at "+n.getCoordinate());e._edges.add(n);var i=n.getLabel();gu.isTrue(i.isArea()),e.mergeLabel(i),e.addPoints(n.getEdge(),n.isForward(),r),r=!1,e.setEdgeRing(n,e),n=e.getNext(n)}while(n!==this._startDe)},fh.prototype.getLinearRing=function(){return this._ring},fh.prototype.getCoordinate=function(t){return this._pts.get(t)},fh.prototype.computeMaxNodeDegree=function(){var t=this;this._maxNodeDegree=0;var e=this._startDe;do{var n=e.getNode().getEdges().getOutgoingDegree(t);n>t._maxNodeDegree&&(t._maxNodeDegree=n),e=t.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2},fh.prototype.addPoints=function(t,e,n){var r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o<r.length;o++)this._pts.add(r[o])}else{var a=r.length-2;n&&(a=r.length-1);for(var s=a;s>=0;s--)this._pts.add(r[s])}},fh.prototype.isHole=function(){return this._isHole},fh.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},fh.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!wu.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0},fh.prototype.addHole=function(t){this._holes.add(t)},fh.prototype.isShell=function(){return null===this._shell},fh.prototype.getLabel=function(){return this._label},fh.prototype.getEdges=function(){return this._edges},fh.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},fh.prototype.getShell=function(){return this._shell},fh.prototype.mergeLabel=function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,rh.RIGHT);if(n===jl.NONE)return null;if(this._label.getLocation(e)===jl.NONE)return this._label.setLocation(e,n),null}},fh.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},fh.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n<this._holes.size();n++)e[n]=this._holes.get(n).getLinearRing();return t.createPolygon(this.getLinearRing(),e)},fh.prototype.interfaces_=function(){return[]},fh.prototype.getClass=function(){return fh};var dh=function(t){function e(){var e=arguments[0],n=arguments[1];t.call(this,e,n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setEdgeRing=function(t,e){t.setMinEdgeRing(e)},e.prototype.getNext=function(t){return t.getNextMin()},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(fh),mh=function(t){function e(){var e=arguments[0],n=arguments[1];t.call(this,e,n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildMinimalRings=function(){var t=new Uu,e=this._startDe;do{if(null===e.getMinEdgeRing()){var n=new dh(e,this._geometryFactory);t.add(n)}e=e.getNext()}while(e!==this._startDe);return t},e.prototype.setEdgeRing=function(t,e){t.setEdgeRing(e)},e.prototype.linkDirectedEdgesForMinimalEdgeRings=function(){var t=this._startDe;do{t.getNode().getEdges().linkMinimalDirectedEdges(this),t=t.getNext()}while(t!==this._startDe)},e.prototype.getNext=function(t){return t.getNext()},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(fh),gh=function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._label=t}};gh.prototype.setVisited=function(t){this._isVisited=t},gh.prototype.setInResult=function(t){this._isInResult=t},gh.prototype.isCovered=function(){return this._isCovered},gh.prototype.isCoveredSet=function(){return this._isCoveredSet},gh.prototype.setLabel=function(t){this._label=t},gh.prototype.getLabel=function(){return this._label},gh.prototype.setCovered=function(t){this._isCovered=t,this._isCoveredSet=!0},gh.prototype.updateIM=function(t){gu.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(t)},gh.prototype.isInResult=function(){return this._isInResult},gh.prototype.isVisited=function(){return this._isVisited},gh.prototype.interfaces_=function(){return[]},gh.prototype.getClass=function(){return gh};var yh=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[0],n=arguments[1];this._coord=e,this._edges=n,this._label=new ph(0,jl.NONE)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1},e.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},e.prototype.getCoordinate=function(){return this._coord},e.prototype.print=function(t){t.println("node "+this._coord+" lbl: "+this._label)},e.prototype.computeIM=function(t){},e.prototype.computeMergedLocation=function(t,e){var n=jl.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==jl.BOUNDARY&&(n=r)}return n},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],n=arguments[1];null===this._label?this._label=new ph(e,n):this._label.setLocation(e,n)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){var t=this;if(arguments[0]instanceof e){var n=arguments[0];this.mergeLabel(n._label)}else if(arguments[0]instanceof ph)for(var r=arguments[0],i=0;i<2;i++){var o=t.computeMergedLocation(r,i);t._label.getLocation(i)===jl.NONE&&t._label.setLocation(i,o)}},e.prototype.add=function(t){this._edges.insert(t),t.setNode(this)},e.prototype.setLabelBoundary=function(t){if(null===this._label)return null;var e=jl.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;if(e===jl.BOUNDARY)n=jl.INTERIOR;else n=jl.BOUNDARY;this._label.setLocation(t,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(gh),vh=function(){this.nodeMap=new ic,this.nodeFact=null;var t=arguments[0];this.nodeFact=t};vh.prototype.find=function(t){return this.nodeMap.get(t)},vh.prototype.addNode=function(){if(arguments[0]instanceof Bl){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof yh){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}},vh.prototype.print=function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)},vh.prototype.iterator=function(){return this.nodeMap.values().iterator()},vh.prototype.values=function(){return this.nodeMap.values()},vh.prototype.getBoundaryNodes=function(t){for(var e=new Uu,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===jl.BOUNDARY&&e.add(r)}return e},vh.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},vh.prototype.interfaces_=function(){return[]},vh.prototype.getClass=function(){return vh};var _h=function(){},xh={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};_h.prototype.interfaces_=function(){return[]},_h.prototype.getClass=function(){return _h},_h.isNorthern=function(t){return t===_h.NE||t===_h.NW},_h.isOpposite=function(t,e){return t!==e&&2==(t-e+4)%4},_h.commonHalfPlane=function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=t<e?t:e;return 0===n&&3===(t>e?t:e)?3:n},_h.isInHalfPlane=function(t,e){return e===_h.SE?t===_h.SE||t===_h.SW:t===e||t===e+1},_h.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new Rl("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?_h.NE:_h.SE:e>=0?_h.NW:_h.SW}if(arguments[0]instanceof Bl&&arguments[1]instanceof Bl){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new Rl("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?_h.NE:_h.SE:r.y>=n.y?_h.NW:_h.SW}},xh.NE.get=function(){return 0},xh.NW.get=function(){return 1},xh.SW.get=function(){return 2},xh.SE.get=function(){return 3},Object.defineProperties(_h,xh);var bh=function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var t=arguments[0];this._edge=t}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];this._edge=e,this.init(n,r),this._label=null}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];this._edge=i,this.init(o,a),this._label=s}};bh.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant<t._quadrant?-1:wu.computeOrientation(t._p0,t._p1,this._p1)},bh.prototype.getDy=function(){return this._dy},bh.prototype.getCoordinate=function(){return this._p0},bh.prototype.setNode=function(t){this._node=t},bh.prototype.print=function(t){var e=Math.atan2(this._dy,this._dx),n=this.getClass().getName(),r=n.lastIndexOf("."),i=n.substring(r+1);t.print(" "+i+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+e+" "+this._label)},bh.prototype.compareTo=function(t){var e=t;return this.compareDirection(e)},bh.prototype.getDirectedCoordinate=function(){return this._p1},bh.prototype.getDx=function(){return this._dx},bh.prototype.getLabel=function(){return this._label},bh.prototype.getEdge=function(){return this._edge},bh.prototype.getQuadrant=function(){return this._quadrant},bh.prototype.getNode=function(){return this._node},bh.prototype.toString=function(){var t=Math.atan2(this._dy,this._dx),e=this.getClass().getName(),n=e.lastIndexOf(".");return" "+e.substring(n+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+t+" "+this._label},bh.prototype.computeLabel=function(t){},bh.prototype.init=function(t,e){this._p0=t,this._p1=e,this._dx=e.x-t.x,this._dy=e.y-t.y,this._quadrant=_h.quadrant(this._dx,this._dy),gu.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")},bh.prototype.interfaces_=function(){return[Ol]},bh.prototype.getClass=function(){return bh};var wh=function(t){function e(){var e=arguments[0],n=arguments[1];if(t.call(this,e),this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999],this._isForward=n,n)this.init(e.getCoordinate(0),e.getCoordinate(1));else{var r=e.getNumPoints()-1;this.init(e.getCoordinate(r),e.getCoordinate(r-1))}this.computeDirectedLabel()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getNextMin=function(){return this._nextMin},e.prototype.getDepth=function(t){return this._depth[t]},e.prototype.setVisited=function(t){this._isVisited=t},e.prototype.computeDirectedLabel=function(){this._label=new ph(this._edge.getLabel()),this._isForward||this._label.flip()},e.prototype.getNext=function(){return this._next},e.prototype.setDepth=function(t,e){if(-999!==this._depth[t]&&this._depth[t]!==e)throw new lh("assigned depths do not match",this.getCoordinate());this._depth[t]=e},e.prototype.isInteriorAreaEdge=function(){for(var t=this,e=!0,n=0;n<2;n++)t._label.isArea(n)&&t._label.getLocation(n,rh.LEFT)===jl.INTERIOR&&t._label.getLocation(n,rh.RIGHT)===jl.INTERIOR||(e=!1);return e},e.prototype.setNextMin=function(t){this._nextMin=t},e.prototype.print=function(e){t.prototype.print.call(this,e),e.print(" "+this._depth[rh.LEFT]+"/"+this._depth[rh.RIGHT]),e.print(" ("+this.getDepthDelta()+")"),this._isInResult&&e.print(" inResult")},e.prototype.setMinEdgeRing=function(t){this._minEdgeRing=t},e.prototype.isLineEdge=function(){var t=this._label.isLine(0)||this._label.isLine(1),e=!this._label.isArea(0)||this._label.allPositionsEqual(0,jl.EXTERIOR),n=!this._label.isArea(1)||this._label.allPositionsEqual(1,jl.EXTERIOR);return t&&e&&n},e.prototype.setEdgeRing=function(t){this._edgeRing=t},e.prototype.getMinEdgeRing=function(){return this._minEdgeRing},e.prototype.getDepthDelta=function(){var t=this._edge.getDepthDelta();return this._isForward||(t=-t),t},e.prototype.setInResult=function(t){this._isInResult=t},e.prototype.getSym=function(){return this._sym},e.prototype.isForward=function(){return this._isForward},e.prototype.getEdge=function(){return this._edge},e.prototype.printEdge=function(t){this.print(t),t.print(" "),this._isForward?this._edge.print(t):this._edge.printReverse(t)},e.prototype.setSym=function(t){this._sym=t},e.prototype.setVisitedEdge=function(t){this.setVisited(t),this._sym.setVisited(t)},e.prototype.setEdgeDepths=function(t,e){var n=this.getEdge().getDepthDelta();this._isForward||(n=-n);var r=1;t===rh.LEFT&&(r=-1);var i=rh.opposite(t),o=e+n*r;this.setDepth(t,e),this.setDepth(i,o)},e.prototype.getEdgeRing=function(){return this._edgeRing},e.prototype.isInResult=function(){return this._isInResult},e.prototype.setNext=function(t){this._next=t},e.prototype.isVisited=function(){return this._isVisited},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.depthFactor=function(t,e){return t===jl.EXTERIOR&&e===jl.INTERIOR?1:t===jl.INTERIOR&&e===jl.EXTERIOR?-1:0},e}(bh),Eh=function(){};Eh.prototype.createNode=function(t){return new yh(t,null)},Eh.prototype.interfaces_=function(){return[]},Eh.prototype.getClass=function(){return Eh};var Sh=function(){if(this._edges=new Uu,this._nodes=null,this._edgeEndList=new Uu,0===arguments.length)this._nodes=new vh(new Eh);else if(1===arguments.length){var t=arguments[0];this._nodes=new vh(t)}};Sh.prototype.printEdges=function(t){t.println("Edges:");for(var e=0;e<this._edges.size();e++){t.println("edge "+e+":");var n=this._edges.get(e);n.print(t),n.eiList.print(t)}},Sh.prototype.find=function(t){return this._nodes.find(t)},Sh.prototype.addNode=function(){if(arguments[0]instanceof yh){var t=arguments[0];return this._nodes.addNode(t)}if(arguments[0]instanceof Bl){var e=arguments[0];return this._nodes.addNode(e)}},Sh.prototype.getNodeIterator=function(){return this._nodes.iterator()},Sh.prototype.linkResultDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()},Sh.prototype.debugPrintln=function(t){ou.out.println(t)},Sh.prototype.isBoundaryNode=function(t,e){var n=this._nodes.find(e);if(null===n)return!1;var r=n.getLabel();return null!==r&&r.getLocation(t)===jl.BOUNDARY},Sh.prototype.linkAllDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()},Sh.prototype.matchInSameDirection=function(t,e,n,r){return!!t.equals(n)&&wu.computeOrientation(t,e,r)===wu.COLLINEAR&&_h.quadrant(t,e)===_h.quadrant(n,r)},Sh.prototype.getEdgeEnds=function(){return this._edgeEndList},Sh.prototype.debugPrint=function(t){ou.out.print(t)},Sh.prototype.getEdgeIterator=function(){return this._edges.iterator()},Sh.prototype.findEdgeInSameDirection=function(t,e){for(var n=this,r=0;r<this._edges.size();r++){var i=n._edges.get(r),o=i.getCoordinates();if(n.matchInSameDirection(t,e,o[0],o[1]))return i;if(n.matchInSameDirection(t,e,o[o.length-1],o[o.length-2]))return i}return null},Sh.prototype.insertEdge=function(t){this._edges.add(t)},Sh.prototype.findEdgeEnd=function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null},Sh.prototype.addEdges=function(t){for(var e=this,n=t.iterator();n.hasNext();){var r=n.next();e._edges.add(r);var i=new wh(r,!0),o=new wh(r,!1);i.setSym(o),o.setSym(i),e.add(i),e.add(o)}},Sh.prototype.add=function(t){this._nodes.add(t),this._edgeEndList.add(t)},Sh.prototype.getNodes=function(){return this._nodes.values()},Sh.prototype.findEdge=function(t,e){for(var n=0;n<this._edges.size();n++){var r=this._edges.get(n),i=r.getCoordinates();if(t.equals(i[0])&&e.equals(i[1]))return r}return null},Sh.prototype.interfaces_=function(){return[]},Sh.prototype.getClass=function(){return Sh},Sh.linkResultDirectedEdges=function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()};var Mh=function(){this._geometryFactory=null,this._shellList=new Uu;var t=arguments[0];this._geometryFactory=t};Mh.prototype.sortShellsAndHoles=function(t,e,n){for(var r=t.iterator();r.hasNext();){var i=r.next();i.isHole()?n.add(i):e.add(i)}},Mh.prototype.computePolygons=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next().toPolygon(this._geometryFactory);e.add(r)}return e},Mh.prototype.placeFreeHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();if(null===r.getShell()){var i=this.findEdgeRingContaining(r,t);if(null===i)throw new lh("unable to assign hole to a shell",r.getCoordinate(0));r.setShell(i)}}},Mh.prototype.buildMinimalEdgeRings=function(t,e,n){for(var r=new Uu,i=t.iterator();i.hasNext();){var o=i.next();if(o.getMaxNodeDegree()>2){o.linkDirectedEdgesForMinimalEdgeRings();var a=o.buildMinimalRings(),s=this.findShell(a);null!==s?(this.placePolygonHoles(s,a),e.add(s)):n.addAll(a)}else r.add(o)}return r},Mh.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();)if(e.next().containsPoint(t))return!0;return!1},Mh.prototype.buildMaximalEdgeRings=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new mh(r,this._geometryFactory);e.add(i),i.setInResult()}}return e},Mh.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}},Mh.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Mh.prototype.findEdgeRingContaining=function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,a=null,s=e.iterator();s.hasNext();){var l=s.next(),u=l.getLinearRing(),c=u.getEnvelopeInternal();null!==o&&(a=o.getLinearRing().getEnvelopeInternal());var h=!1;c.contains(r)&&wu.isPointInRing(i,u.getCoordinates())&&(h=!0),h&&(null===o||a.contains(c))&&(o=l)}return o},Mh.prototype.findShell=function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++)}return gu.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},Mh.prototype.add=function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0];Sh.linkResultDirectedEdges(arguments[1]);var n=this.buildMaximalEdgeRings(e),r=new Uu,i=this.buildMinimalEdgeRings(n,this._shellList,r);this.sortShellsAndHoles(i,this._shellList,r),this.placeFreeHoles(this._shellList,r)}},Mh.prototype.interfaces_=function(){return[]},Mh.prototype.getClass=function(){return Mh};var Th=function(){};Th.prototype.getBounds=function(){},Th.prototype.interfaces_=function(){return[]},Th.prototype.getClass=function(){return Th};var Ch=function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e};Ch.prototype.getItem=function(){return this._item},Ch.prototype.getBounds=function(){return this._bounds},Ch.prototype.interfaces_=function(){return[Th,Fl]},Ch.prototype.getClass=function(){return Ch};var Ih=function(){this._size=null,this._items=null,this._size=0,this._items=new Uu,this._items.add(null)};Ih.prototype.poll=function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t},Ih.prototype.size=function(){return this._size},Ih.prototype.reorder=function(t){for(var e=this,n=null,r=this._items.get(t);2*t<=this._size&&((n=2*t)!==e._size&&e._items.get(n+1).compareTo(e._items.get(n))<0&&n++,e._items.get(n).compareTo(r)<0);t=n)e._items.set(t,e._items.get(n));this._items.set(t,r)},Ih.prototype.clear=function(){this._size=0,this._items.clear()},Ih.prototype.isEmpty=function(){return 0===this._size},Ih.prototype.add=function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)},Ih.prototype.interfaces_=function(){return[]},Ih.prototype.getClass=function(){return Ih};var Ah=function(){};Ah.prototype.visitItem=function(t){},Ah.prototype.interfaces_=function(){return[]},Ah.prototype.getClass=function(){return Ah};var Lh=function(){};Lh.prototype.insert=function(t,e){},Lh.prototype.remove=function(t,e){},Lh.prototype.query=function(){},Lh.prototype.interfaces_=function(){return[]},Lh.prototype.getClass=function(){return Lh};var Ph=function(){if(this._childBoundables=new Uu,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}},Rh={serialVersionUID:{configurable:!0}};Ph.prototype.getLevel=function(){return this._level},Ph.prototype.size=function(){return this._childBoundables.size()},Ph.prototype.getChildBoundables=function(){return this._childBoundables},Ph.prototype.addChildBoundable=function(t){gu.isTrue(null===this._bounds),this._childBoundables.add(t)},Ph.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},Ph.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},Ph.prototype.interfaces_=function(){return[Th,Fl]},Ph.prototype.getClass=function(){return Ph},Rh.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties(Ph,Rh);var Dh=function(){};Dh.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},Dh.min=function(t){return Dh.sort(t),t.get(0)},Dh.sort=function(t,e){var n=t.toArray();e?uc.sort(n,e):uc.sort(n);for(var r=t.iterator(),i=0,o=n.length;i<o;i++)r.next(),r.set(n[i])},Dh.singletonList=function(t){var e=new Uu;return e.add(t),e};var Nh=function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var t=arguments[0],e=arguments[1],n=arguments[2];this._boundable1=t,this._boundable2=e,this._itemDistance=n,this._distance=this.distance()};Nh.prototype.expandToQueue=function(t,e){var n=Nh.isComposite(this._boundable1),r=Nh.isComposite(this._boundable2);if(n&&r)return Nh.area(this._boundable1)>Nh.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,t,e),null;if(r)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new Rl("neither boundable is composite")},Nh.prototype.isLeaves=function(){return!(Nh.isComposite(this._boundable1)||Nh.isComposite(this._boundable2))},Nh.prototype.compareTo=function(t){var e=t;return this._distance<e._distance?-1:this._distance>e._distance?1:0},Nh.prototype.expand=function(t,e,n,r){for(var i=t.getChildBoundables().iterator();i.hasNext();){var o=i.next(),a=new Nh(o,e,this._itemDistance);a.getDistance()<r&&n.add(a)}},Nh.prototype.getBoundable=function(t){return 0===t?this._boundable1:this._boundable2},Nh.prototype.getDistance=function(){return this._distance},Nh.prototype.distance=function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())},Nh.prototype.interfaces_=function(){return[Ol]},Nh.prototype.getClass=function(){return Nh},Nh.area=function(t){return t.getBounds().getArea()},Nh.isComposite=function(t){return t instanceof Ph};var Oh=function t(){if(this._root=null,this._built=!1,this._itemBoundables=new Uu,this._nodeCapacity=null,0===arguments.length){var e=t.DEFAULT_NODE_CAPACITY;this._nodeCapacity=e}else if(1===arguments.length){var n=arguments[0];gu.isTrue(n>1,"Node capacity must be greater than 1"),this._nodeCapacity=n}},kh={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};Oh.prototype.getNodeCapacity=function(){return this._nodeCapacity},Oh.prototype.lastNode=function(t){return t.get(t.size()-1)},Oh.prototype.size=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof Ph?t+=this.size(n):n instanceof Ch&&(t+=1)}return t}},Oh.prototype.removeItem=function(t,e){for(var n=null,r=t.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Ch&&i.getItem()===e&&(n=i)}return null!==n&&(t.getChildBoundables().remove(n),!0)},Oh.prototype.itemsTree=function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new Uu:t}if(1===arguments.length){for(var e=arguments[0],n=new Uu,r=e.getChildBoundables().iterator();r.hasNext();){var i=r.next();if(i instanceof Ph){var o=this.itemsTree(i);null!==o&&n.add(o)}else i instanceof Ch?n.add(i.getItem()):gu.shouldNeverReachHere()}return n.size()<=0?null:n}},Oh.prototype.insert=function(t,e){gu.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Ch(t,e))},Oh.prototype.boundablesAtLevel=function(){if(1===arguments.length){var t=arguments[0],e=new Uu;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];if(gu.isTrue(n>-2),r.getLevel()===n)return i.add(r),null;for(var o=r.getChildBoundables().iterator();o.hasNext();){var a=o.next();a instanceof Ph?this.boundablesAtLevel(n,a,i):(gu.isTrue(a instanceof Ch),-1===n&&i.add(a))}return null}},Oh.prototype.query=function(){var t=this;if(1===arguments.length){var e=arguments[0];this.build();var n=new Uu;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.query(e,this._root,n),n}if(2===arguments.length){var r=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),r)&&this.query(r,this._root,i)}else if(3===arguments.length)if(ql(arguments[2],Ah)&&arguments[0]instanceof Object&&arguments[1]instanceof Ph)for(var o=arguments[0],a=arguments[2],s=arguments[1].getChildBoundables(),l=0;l<s.size();l++){var u=s.get(l);t.getIntersectsOp().intersects(u.getBounds(),o)&&(u instanceof Ph?t.query(o,u,a):u instanceof Ch?a.visitItem(u.getItem()):gu.shouldNeverReachHere())}else if(ql(arguments[2],Fu)&&arguments[0]instanceof Object&&arguments[1]instanceof Ph)for(var c=arguments[0],h=arguments[2],p=arguments[1].getChildBoundables(),f=0;f<p.size();f++){var d=p.get(f);t.getIntersectsOp().intersects(d.getBounds(),c)&&(d instanceof Ph?t.query(c,d,h):d instanceof Ch?h.add(d.getItem()):gu.shouldNeverReachHere())}},Oh.prototype.build=function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0},Oh.prototype.getRoot=function(){return this.build(),this._root},Oh.prototype.remove=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],o=this.removeItem(r,i);if(o)return!0;for(var a=null,s=r.getChildBoundables().iterator();s.hasNext();){var l=s.next();if(this.getIntersectsOp().intersects(l.getBounds(),n)&&l instanceof Ph&&(o=this.remove(n,l,i))){a=l;break}}return null!==a&&a.getChildBoundables().isEmpty()&&r.getChildBoundables().remove(a),o}},Oh.prototype.createHigherLevels=function(t,e){gu.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)},Oh.prototype.depth=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof Ph){var r=this.depth(n);r>t&&(t=r)}}return t+1}},Oh.prototype.createParentBoundables=function(t,e){var n=this;gu.isTrue(!t.isEmpty());var r=new Uu;r.add(this.createNode(e));var i=new Uu(t);Dh.sort(i,this.getComparator());for(var o=i.iterator();o.hasNext();){var a=o.next();n.lastNode(r).getChildBoundables().size()===n.getNodeCapacity()&&r.add(n.createNode(e)),n.lastNode(r).addChildBoundable(a)}return r},Oh.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},Oh.prototype.interfaces_=function(){return[Fl]},Oh.prototype.getClass=function(){return Oh},Oh.compareDoubles=function(t,e){return t>e?1:t<e?-1:0},kh.IntersectsOp.get=function(){return zh},kh.serialVersionUID.get=function(){return-0x35ef64c82d4c5400},kh.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(Oh,kh);var zh=function(){},Fh=function(){};Fh.prototype.distance=function(t,e){},Fh.prototype.interfaces_=function(){return[]},Fh.prototype.getClass=function(){return Fh};var Bh=function(t){function e(n){n=n||e.DEFAULT_NODE_CAPACITY,t.call(this,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={STRtreeNode:{configurable:!0},serialVersionUID:{configurable:!0},xComparator:{configurable:!0},yComparator:{configurable:!0},intersectsOp:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};return e.prototype.createParentBoundablesFromVerticalSlices=function(t,e){gu.isTrue(t.length>0);for(var n=new Uu,r=0;r<t.length;r++)n.addAll(this.createParentBoundablesFromVerticalSlice(t[r],e));return n},e.prototype.createNode=function(t){return new Uh(t)},e.prototype.size=function(){return 0===arguments.length?t.prototype.size.call(this):t.prototype.size.apply(this,arguments)},e.prototype.insert=function(){if(2!==arguments.length)return t.prototype.insert.apply(this,arguments);var e=arguments[0],n=arguments[1];if(e.isNull())return null;t.prototype.insert.call(this,e,n)},e.prototype.getIntersectsOp=function(){return e.intersectsOp},e.prototype.verticalSlices=function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),r=new Array(e).fill(null),i=t.iterator(),o=0;o<e;o++){r[o]=new Uu;for(var a=0;i.hasNext()&&a<n;){var s=i.next();r[o].add(s),a++}}return r},e.prototype.query=function(){if(1===arguments.length){var e=arguments[0];return t.prototype.query.call(this,e)}if(2===arguments.length){var n=arguments[0],r=arguments[1];t.prototype.query.call(this,n,r)}else if(3===arguments.length)if(ql(arguments[2],Ah)&&arguments[0]instanceof Object&&arguments[1]instanceof Ph){var i=arguments[0],o=arguments[1],a=arguments[2];t.prototype.query.call(this,i,o,a)}else if(ql(arguments[2],Fu)&&arguments[0]instanceof Object&&arguments[1]instanceof Ph){var s=arguments[0],l=arguments[1],u=arguments[2];t.prototype.query.call(this,s,l,u)}},e.prototype.getComparator=function(){return e.yComparator},e.prototype.createParentBoundablesFromVerticalSlice=function(e,n){return t.prototype.createParentBoundables.call(this,e,n)},e.prototype.remove=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return t.prototype.remove.call(this,e,n)}return t.prototype.remove.apply(this,arguments)},e.prototype.depth=function(){return 0===arguments.length?t.prototype.depth.call(this):t.prototype.depth.apply(this,arguments)},e.prototype.createParentBoundables=function(t,n){gu.isTrue(!t.isEmpty());var r=Math.trunc(Math.ceil(t.size()/this.getNodeCapacity())),i=new Uu(t);Dh.sort(i,e.xComparator);var o=this.verticalSlices(i,Math.trunc(Math.ceil(Math.sqrt(r))));return this.createParentBoundablesFromVerticalSlices(o,n)},e.prototype.nearestNeighbour=function(){if(1===arguments.length){if(ql(arguments[0],Fh)){var t=arguments[0],n=new Nh(this.getRoot(),this.getRoot(),t);return this.nearestNeighbour(n)}if(arguments[0]instanceof Nh){var r=arguments[0];return this.nearestNeighbour(r,Dl.POSITIVE_INFINITY)}}else if(2===arguments.length){if(arguments[0]instanceof e&&ql(arguments[1],Fh)){var i=arguments[0],o=arguments[1],a=new Nh(this.getRoot(),i.getRoot(),o);return this.nearestNeighbour(a)}if(arguments[0]instanceof Nh&&"number"==typeof arguments[1]){var s=arguments[0],l=arguments[1],u=null,c=new Ih;for(c.add(s);!c.isEmpty()&&l>0;){var h=c.poll(),p=h.getDistance();if(p>=l)break;h.isLeaves()?(l=p,u=h):h.expandToQueue(c,l)}return[u.getBoundable(0).getItem(),u.getBoundable(1).getItem()]}}else if(3===arguments.length){var f=arguments[2],d=new Ch(arguments[0],arguments[1]),m=new Nh(this.getRoot(),d,f);return this.nearestNeighbour(m)[0]}},e.prototype.interfaces_=function(){return[Lh,Fl]},e.prototype.getClass=function(){return e},e.centreX=function(t){return e.avg(t.getMinX(),t.getMaxX())},e.avg=function(t,e){return(t+e)/2},e.centreY=function(t){return e.avg(t.getMinY(),t.getMaxY())},n.STRtreeNode.get=function(){return Uh},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0},n.xComparator.get=function(){return{interfaces_:function(){return[zl]},compare:function(n,r){return t.compareDoubles(e.centreX(n.getBounds()),e.centreX(r.getBounds()))}}},n.yComparator.get=function(){return{interfaces_:function(){return[zl]},compare:function(n,r){return t.compareDoubles(e.centreY(n.getBounds()),e.centreY(r.getBounds()))}}},n.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(t,e){return t.intersects(e)}}},n.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(e,n),e}(Oh),Uh=function(t){function e(){var e=arguments[0];t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new su(n.getBounds()):t.expandToInclude(n.getBounds())}return t},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ph),Vh=function(){};Vh.prototype.interfaces_=function(){return[]},Vh.prototype.getClass=function(){return Vh},Vh.relativeSign=function(t,e){return t<e?-1:t>e?1:0},Vh.compare=function(t,e,n){if(e.equals2D(n))return 0;var r=Vh.relativeSign(e.x,n.x),i=Vh.relativeSign(e.y,n.y);switch(t){case 0:return Vh.compareValue(r,i);case 1:return Vh.compareValue(i,r);case 2:return Vh.compareValue(i,-r);case 3:return Vh.compareValue(-r,i);case 4:return Vh.compareValue(-r,-i);case 5:return Vh.compareValue(-i,-r);case 6:return Vh.compareValue(-i,r);case 7:return Vh.compareValue(r,-i)}return gu.shouldNeverReachHere("invalid octant value"),0},Vh.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var Gh=function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._segString=t,this.coord=new Bl(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))};Gh.prototype.getCoordinate=function(){return this.coord},Gh.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},Gh.prototype.compareTo=function(t){var e=t;return this.segmentIndex<e.segmentIndex?-1:this.segmentIndex>e.segmentIndex?1:this.coord.equals2D(e.coord)?0:Vh.compare(this._segmentOctant,this.coord,e.coord)},Gh.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},Gh.prototype.isInterior=function(){return this._isInterior},Gh.prototype.interfaces_=function(){return[Ol]},Gh.prototype.getClass=function(){return Gh};var jh=function(){this._nodeMap=new ic,this._edge=null;var t=arguments[0];this._edge=t};jh.prototype.getSplitCoordinates=function(){var t=new Gu;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r}return t.toCoordinateArray()},jh.prototype.addCollapsedNodes=function(){var t=new Uu;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}},jh.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},jh.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e<this._edge.size()-2;e++){var n=this._edge.getCoordinate(e),r=this._edge.getCoordinate(e+2);n.equals2D(r)&&t.add(new Yl(e+1))}},jh.prototype.addEdgeCoordinates=function(t,e,n){var r=this._edge.getCoordinate(e.segmentIndex),i=e.isInterior()||!e.coord.equals2D(r);n.add(new Bl(t.coord),!1);for(var o=t.segmentIndex+1;o<=e.segmentIndex;o++)n.add(this._edge.getCoordinate(o));i&&n.add(new Bl(e.coord))},jh.prototype.iterator=function(){return this._nodeMap.values().iterator()},jh.prototype.addSplitEdges=function(t){this.addEndpoints(),this.addCollapsedNodes();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next(),i=this.createSplitEdge(n,r);t.add(i),n=r}},jh.prototype.findCollapseIndex=function(t,e,n){if(!t.coord.equals2D(e.coord))return!1;var r=e.segmentIndex-t.segmentIndex;return e.isInterior()||r--,1===r&&(n[0]=t.segmentIndex+1,!0)},jh.prototype.findCollapsesFromInsertedNodes=function(t){for(var e=new Array(1).fill(null),n=this.iterator(),r=n.next();n.hasNext();){var i=n.next();this.findCollapseIndex(r,i,e)&&t.add(new Yl(e[0])),r=i}},jh.prototype.getEdge=function(){return this._edge},jh.prototype.addEndpoints=function(){var t=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(t),t)},jh.prototype.createSplitEdge=function(t,e){var n=e.segmentIndex-t.segmentIndex+2,r=this._edge.getCoordinate(e.segmentIndex),i=e.isInterior()||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),a=0;o[a++]=new Bl(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)o[a++]=this._edge.getCoordinate(s);return i&&(o[a]=new Bl(e.coord)),new Xh(o,this._edge.getData())},jh.prototype.add=function(t,e){var n=new Gh(this._edge,t,e,this._edge.getSegmentOctant(e)),r=this._nodeMap.get(n);return null!==r?(gu.isTrue(r.coord.equals2D(t),"Found equal nodes with different coordinates"),r):(this._nodeMap.put(n,n),n)},jh.prototype.checkSplitEdgesCorrectness=function(t){var e=this._edge.getCoordinates(),n=t.get(0).getCoordinate(0);if(!n.equals2D(e[0]))throw new du("bad split edge start point at "+n);var r=t.get(t.size()-1).getCoordinates(),i=r[r.length-1];if(!i.equals2D(e[e.length-1]))throw new du("bad split edge end point at "+i)},jh.prototype.interfaces_=function(){return[]},jh.prototype.getClass=function(){return jh};var Hh=function(){};Hh.prototype.interfaces_=function(){return[]},Hh.prototype.getClass=function(){return Hh},Hh.octant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new Rl("Cannot compute the octant for point ( "+t+", "+e+" )");var n=Math.abs(t),r=Math.abs(e);return t>=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof Bl&&arguments[1]instanceof Bl){var i=arguments[0],o=arguments[1],a=o.x-i.x,s=o.y-i.y;if(0===a&&0===s)throw new Rl("Cannot compute the octant for two identical points "+i);return Hh.octant(a,s)}};var qh=function(){};qh.prototype.getCoordinates=function(){},qh.prototype.size=function(){},qh.prototype.getCoordinate=function(t){},qh.prototype.isClosed=function(){},qh.prototype.setData=function(t){},qh.prototype.getData=function(){},qh.prototype.interfaces_=function(){return[]},qh.prototype.getClass=function(){return qh};var Wh=function(){};Wh.prototype.addIntersection=function(t,e){},Wh.prototype.interfaces_=function(){return[qh]},Wh.prototype.getClass=function(){return Wh};var Xh=function(){this._nodeList=new jh(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};Xh.prototype.getCoordinates=function(){return this._pts},Xh.prototype.size=function(){return this._pts.length},Xh.prototype.getCoordinate=function(t){return this._pts[t]},Xh.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},Xh.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},Xh.prototype.setData=function(t){this._data=t},Xh.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:Hh.octant(t,e)},Xh.prototype.getData=function(){return this._data},Xh.prototype.addIntersection=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],r=arguments[3],i=new Bl(arguments[0].getIntersection(r));this.addIntersection(i,n)}},Xh.prototype.toString=function(){return fu.toLineString(new Uc(this._pts))},Xh.prototype.getNodeList=function(){return this._nodeList},Xh.prototype.addIntersectionNode=function(t,e){var n=e,r=n+1;if(r<this._pts.length){var i=this._pts[r];t.equals2D(i)&&(n=r)}return this._nodeList.add(t,n)},Xh.prototype.addIntersections=function(t,e,n){for(var r=0;r<t.getIntersectionNum();r++)this.addIntersection(t,e,n,r)},Xh.prototype.interfaces_=function(){return[Wh]},Xh.prototype.getClass=function(){return Xh},Xh.getNodedSubstrings=function(){if(1===arguments.length){var t=arguments[0],e=new Uu;return Xh.getNodedSubstrings(t,e),e}if(2===arguments.length)for(var n=arguments[1],r=arguments[0].iterator();r.hasNext();){r.next().getNodeList().addSplitEdges(n)}};var Zh=function(){if(this.p0=null,this.p1=null,0===arguments.length)this.p0=new Bl,this.p1=new Bl;else if(1===arguments.length){var t=arguments[0];this.p0=new Bl(t.p0),this.p1=new Bl(t.p1)}else if(2===arguments.length)this.p0=arguments[0],this.p1=arguments[1];else if(4===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=arguments[3];this.p0=new Bl(e,n),this.p1=new Bl(r,i)}},Yh={serialVersionUID:{configurable:!0}};Zh.prototype.minX=function(){return Math.min(this.p0.x,this.p1.x)},Zh.prototype.orientationIndex=function(){if(arguments[0]instanceof Zh){var t=arguments[0],e=wu.orientationIndex(this.p0,this.p1,t.p0),n=wu.orientationIndex(this.p0,this.p1,t.p1);return e>=0&&n>=0||e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof Bl){var r=arguments[0];return wu.orientationIndex(this.p0,this.p1,r)}},Zh.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},Zh.prototype.isVertical=function(){return this.p0.x===this.p1.x},Zh.prototype.equals=function(t){if(!(t instanceof Zh))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},Zh.prototype.intersection=function(t){var e=new _u;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},Zh.prototype.project=function(){if(arguments[0]instanceof Bl){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new Bl(t);var e=this.projectionFactor(t),n=new Bl;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof Zh){var r=arguments[0],i=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(i>=1&&o>=1)return null;if(i<=0&&o<=0)return null;var a=this.project(r.p0);i<0&&(a=this.p0),i>1&&(a=this.p1);var s=this.project(r.p1);return o<0&&(s=this.p0),o>1&&(s=this.p1),new Zh(a,s)}},Zh.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},Zh.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},Zh.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1},Zh.prototype.distancePerpendicular=function(t){return wu.distancePointLinePerpendicular(t,this.p0,this.p1)},Zh.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},Zh.prototype.midPoint=function(){return Zh.midPoint(this.p0,this.p1)},Zh.prototype.projectionFactor=function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,r=e*e+n*n;return r<=0?Dl.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r},Zh.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=Dl.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var a=this.closestPoint(t.p1);(i=a.distance(t.p1))<r&&(r=i,n[0]=a,n[1]=t.p1);var s=t.closestPoint(this.p0);(i=s.distance(this.p0))<r&&(r=i,n[0]=this.p0,n[1]=s);var l=t.closestPoint(this.p1);return(i=l.distance(this.p1))<r&&(r=i,n[0]=this.p1,n[1]=l),n},Zh.prototype.closestPoint=function(t){var e=this.projectionFactor(t);return e>0&&e<1?this.project(t):this.p0.distance(t)<this.p1.distance(t)?this.p0:this.p1},Zh.prototype.maxX=function(){return Math.max(this.p0.x,this.p1.x)},Zh.prototype.getLength=function(){return this.p0.distance(this.p1)},Zh.prototype.compareTo=function(t){var e=t,n=this.p0.compareTo(e.p0);return 0!==n?n:this.p1.compareTo(e.p1)},Zh.prototype.reverse=function(){var t=this.p0;this.p0=this.p1,this.p1=t},Zh.prototype.equalsTopo=function(t){return this.p0.equals(t.p0)&&(this.p1.equals(t.p1)||this.p0.equals(t.p1))&&this.p1.equals(t.p0)},Zh.prototype.lineIntersection=function(t){try{return au.intersection(this.p0,this.p1,t.p0,t.p1)}catch(t){if(!(t instanceof iu))throw t}return null},Zh.prototype.maxY=function(){return Math.max(this.p0.y,this.p1.y)},Zh.prototype.pointAlongOffset=function(t,e){var n=this.p0.x+t*(this.p1.x-this.p0.x),r=this.p0.y+t*(this.p1.y-this.p0.y),i=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y,a=Math.sqrt(i*i+o*o),s=0,l=0;if(0!==e){if(a<=0)throw new Error("Cannot compute offset from zero-length line segment");s=e*i/a,l=e*o/a}return new Bl(n-l,r+s)},Zh.prototype.setCoordinates=function(){if(1===arguments.length){var t=arguments[0];this.setCoordinates(t.p0,t.p1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p0.x=e.x,this.p0.y=e.y,this.p1.x=n.x,this.p1.y=n.y}},Zh.prototype.segmentFraction=function(t){var e=this.projectionFactor(t);return e<0?e=0:(e>1||Dl.isNaN(e))&&(e=1),e},Zh.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},Zh.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},Zh.prototype.distance=function(){if(arguments[0]instanceof Zh){var t=arguments[0];return wu.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof Bl){var e=arguments[0];return wu.distancePointLine(e,this.p0,this.p1)}},Zh.prototype.pointAlong=function(t){var e=new Bl;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},Zh.prototype.hashCode=function(){var t=Dl.doubleToLongBits(this.p0.x);t^=31*Dl.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=Dl.doubleToLongBits(this.p1.x);return n^=31*Dl.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)},Zh.prototype.interfaces_=function(){return[Ol,Fl]},Zh.prototype.getClass=function(){return Zh},Zh.midPoint=function(t,e){return new Bl((t.x+e.x)/2,(t.y+e.y)/2)},Yh.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(Zh,Yh);var Jh=function(){this.tempEnv1=new su,this.tempEnv2=new su,this._overlapSeg1=new Zh,this._overlapSeg2=new Zh};Jh.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}},Jh.prototype.interfaces_=function(){return[]},Jh.prototype.getClass=function(){return Jh};var Kh=function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=r};Kh.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},Kh.prototype.computeSelect=function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(r.tempEnv1.init(i,o),n-e==1)return r.select(this,e),null;if(!t.intersects(r.tempEnv1))return null;var a=Math.trunc((e+n)/2);e<a&&this.computeSelect(t,e,a,r),a<n&&this.computeSelect(t,a,n,r)},Kh.prototype.getCoordinates=function(){for(var t=new Array(this._end-this._start+1).fill(null),e=0,n=this._start;n<=this._end;n++)t[e++]=this._pts[n];return t},Kh.prototype.computeOverlaps=function(t,e){this.computeOverlapsInternal(this._start,this._end,t,t._start,t._end,e)},Kh.prototype.setId=function(t){this._id=t},Kh.prototype.select=function(t,e){this.computeSelect(t,this._start,this._end,e)},Kh.prototype.getEnvelope=function(){if(null===this._env){var t=this._pts[this._start],e=this._pts[this._end];this._env=new su(t,e)}return this._env},Kh.prototype.getEndIndex=function(){return this._end},Kh.prototype.getStartIndex=function(){return this._start},Kh.prototype.getContext=function(){return this._context},Kh.prototype.getId=function(){return this._id},Kh.prototype.computeOverlapsInternal=function(t,e,n,r,i,o){var a=this._pts[t],s=this._pts[e],l=n._pts[r],u=n._pts[i];if(e-t==1&&i-r==1)return o.overlap(this,t,n,r),null;if(o.tempEnv1.init(a,s),o.tempEnv2.init(l,u),!o.tempEnv1.intersects(o.tempEnv2))return null;var c=Math.trunc((t+e)/2),h=Math.trunc((r+i)/2);t<c&&(r<h&&this.computeOverlapsInternal(t,c,n,r,h,o),h<i&&this.computeOverlapsInternal(t,c,n,h,i,o)),c<e&&(r<h&&this.computeOverlapsInternal(c,e,n,r,h,o),h<i&&this.computeOverlapsInternal(c,e,n,h,i,o))},Kh.prototype.interfaces_=function(){return[]},Kh.prototype.getClass=function(){return Kh};var Qh=function(){};Qh.prototype.interfaces_=function(){return[]},Qh.prototype.getClass=function(){return Qh},Qh.getChainStartIndices=function(t){var e=0,n=new Uu;n.add(new Yl(e));do{var r=Qh.findChainEnd(t,e);n.add(new Yl(r)),e=r}while(e<t.length-1);return Qh.toIntArray(n)},Qh.findChainEnd=function(t,e){for(var n=e;n<t.length-1&&t[n].equals2D(t[n+1]);)n++;if(n>=t.length-1)return t.length-1;for(var r=_h.quadrant(t[n],t[n+1]),i=e+1;i<t.length&&(t[i-1].equals2D(t[i])||_h.quadrant(t[i-1],t[i])===r);)i++;return i-1},Qh.getChains=function(){if(1===arguments.length){return Qh.getChains(arguments[0],null)}if(2===arguments.length){for(var t=arguments[0],e=arguments[1],n=new Uu,r=Qh.getChainStartIndices(t),i=0;i<r.length-1;i++){var o=new Kh(t,r[i],r[i+1],e);n.add(o)}return n}},Qh.toIntArray=function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e};var $h=function(){};$h.prototype.computeNodes=function(t){},$h.prototype.getNodedSubstrings=function(){},$h.prototype.interfaces_=function(){return[]},$h.prototype.getClass=function(){return $h};var tp=function(){if(this._segInt=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}};tp.prototype.setSegmentIntersector=function(t){this._segInt=t},tp.prototype.interfaces_=function(){return[$h]},tp.prototype.getClass=function(){return tp};var ep=function(t){function e(e){e?t.call(this,e):t.call(this),this._monoChains=new Uu,this._index=new Bh,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={SegmentOverlapAction:{configurable:!0}};return e.prototype.getMonotoneChains=function(){return this._monoChains},e.prototype.getNodedSubstrings=function(){return Xh.getNodedSubstrings(this._nodedSegStrings)},e.prototype.getIndex=function(){return this._index},e.prototype.add=function(t){for(var e=this,n=Qh.getChains(t.getCoordinates(),t).iterator();n.hasNext();){var r=n.next();r.setId(e._idCounter++),e._index.insert(r.getEnvelope(),r),e._monoChains.add(r)}},e.prototype.computeNodes=function(t){this._nodedSegStrings=t;for(var e=t.iterator();e.hasNext();)this.add(e.next());this.intersectChains()},e.prototype.intersectChains=function(){for(var t=this,e=new np(this._segInt),n=this._monoChains.iterator();n.hasNext();)for(var r=n.next(),i=t._index.query(r.getEnvelope()).iterator();i.hasNext();){var o=i.next();if(o.getId()>r.getId()&&(r.computeOverlaps(o,e),t._nOverlaps++),t._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.SegmentOverlapAction.get=function(){return np},Object.defineProperties(e,n),e}(tp),np=function(t){function e(){t.call(this),this._si=null;var e=arguments[0];this._si=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(4!==arguments.length)return t.prototype.overlap.apply(this,arguments);var e=arguments[1],n=arguments[2],r=arguments[3],i=arguments[0].getContext(),o=n.getContext();this._si.processIntersections(i,e,o,r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Jh),rp=function t(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(a),this.setMitreLimit(s)}},ip={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};rp.prototype.getEndCapStyle=function(){return this._endCapStyle},rp.prototype.isSingleSided=function(){return this._isSingleSided},rp.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=rp.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=rp.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==rp.JOIN_ROUND&&(this._quadrantSegments=rp.DEFAULT_QUADRANT_SEGMENTS)},rp.prototype.getJoinStyle=function(){return this._joinStyle},rp.prototype.setJoinStyle=function(t){this._joinStyle=t},rp.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},rp.prototype.getSimplifyFactor=function(){return this._simplifyFactor},rp.prototype.getQuadrantSegments=function(){return this._quadrantSegments},rp.prototype.setEndCapStyle=function(t){this._endCapStyle=t},rp.prototype.getMitreLimit=function(){return this._mitreLimit},rp.prototype.setMitreLimit=function(t){this._mitreLimit=t},rp.prototype.setSingleSided=function(t){this._isSingleSided=t},rp.prototype.interfaces_=function(){return[]},rp.prototype.getClass=function(){return rp},rp.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},ip.CAP_ROUND.get=function(){return 1},ip.CAP_FLAT.get=function(){return 2},ip.CAP_SQUARE.get=function(){return 3},ip.JOIN_ROUND.get=function(){return 1},ip.JOIN_MITRE.get=function(){return 2},ip.JOIN_BEVEL.get=function(){return 3},ip.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},ip.DEFAULT_MITRE_LIMIT.get=function(){return 5},ip.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(rp,ip);var op=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=wu.COUNTERCLOCKWISE,this._inputLine=t||null},ap={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};op.prototype.isDeletable=function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],a=this._inputLine[n];return!!this.isConcave(i,o,a)&&!!this.isShallow(i,o,a,r)&&this.isShallowSampled(i,o,t,n,r)},op.prototype.deleteShallowConcavities=function(){for(var t=this,e=1,n=this.findNextNonDeletedIndex(e),r=this.findNextNonDeletedIndex(n),i=!1;r<this._inputLine.length;){var o=!1;t.isDeletable(e,n,r,t._distanceTol)&&(t._isDeleted[n]=op.DELETE,o=!0,i=!0),e=o?r:n,n=t.findNextNonDeletedIndex(e),r=t.findNextNonDeletedIndex(n)}return i},op.prototype.isShallowConcavity=function(t,e,n,r){return wu.computeOrientation(t,e,n)===this._angleOrientation&&wu.distancePointLine(e,t,n)<r},op.prototype.isShallowSampled=function(t,e,n,r,i){var o=Math.trunc((r-n)/op.NUM_PTS_TO_CHECK);o<=0&&(o=1);for(var a=n;a<r;a+=o)if(!this.isShallow(t,e,this._inputLine[a],i))return!1;return!0},op.prototype.isConcave=function(t,e,n){return wu.computeOrientation(t,e,n)===this._angleOrientation},op.prototype.simplify=function(t){this._distanceTol=Math.abs(t),t<0&&(this._angleOrientation=wu.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var e=!1;do{e=this.deleteShallowConcavities()}while(e);return this.collapseLine()},op.prototype.findNextNonDeletedIndex=function(t){for(var e=t+1;e<this._inputLine.length&&this._isDeleted[e]===op.DELETE;)e++;return e},op.prototype.isShallow=function(t,e,n,r){return wu.distancePointLine(e,t,n)<r},op.prototype.collapseLine=function(){for(var t=new Gu,e=0;e<this._inputLine.length;e++)this._isDeleted[e]!==op.DELETE&&t.add(this._inputLine[e]);return t.toCoordinateArray()},op.prototype.interfaces_=function(){return[]},op.prototype.getClass=function(){return op},op.simplify=function(t,e){return new op(t).simplify(e)},ap.INIT.get=function(){return 0},ap.DELETE.get=function(){return 1},ap.KEEP.get=function(){return 1},ap.NUM_PTS_TO_CHECK.get=function(){return 10},Object.defineProperties(op,ap);var sp=function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new Uu},lp={COORDINATE_ARRAY_TYPE:{configurable:!0}};sp.prototype.getCoordinates=function(){return this._ptList.toArray(sp.COORDINATE_ARRAY_TYPE)},sp.prototype.setPrecisionModel=function(t){this._precisionModel=t},sp.prototype.addPt=function(t){var e=new Bl(t);if(this._precisionModel.makePrecise(e),this.isRedundant(e))return null;this._ptList.add(e)},sp.prototype.revere=function(){},sp.prototype.addPts=function(t,e){if(e)for(var n=0;n<t.length;n++)this.addPt(t[n]);else for(var r=t.length-1;r>=0;r--)this.addPt(t[r])},sp.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)<this._minimimVertexDistance},sp.prototype.toString=function(){return(new Yc).createLineString(this.getCoordinates()).toString()},sp.prototype.closeRing=function(){if(this._ptList.size()<1)return null;var t=new Bl(this._ptList.get(0)),e=this._ptList.get(this._ptList.size()-1);if(t.equals(e))return null;this._ptList.add(t)},sp.prototype.setMinimumVertexDistance=function(t){this._minimimVertexDistance=t},sp.prototype.interfaces_=function(){return[]},sp.prototype.getClass=function(){return sp},lp.COORDINATE_ARRAY_TYPE.get=function(){return new Array(0).fill(null)},Object.defineProperties(sp,lp);var up=function(){},cp={PI_TIMES_2:{configurable:!0},PI_OVER_2:{configurable:!0},PI_OVER_4:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},CLOCKWISE:{configurable:!0},NONE:{configurable:!0}};up.prototype.interfaces_=function(){return[]},up.prototype.getClass=function(){return up},up.toDegrees=function(t){return 180*t/Math.PI},up.normalize=function(t){for(;t>Math.PI;)t-=up.PI_TIMES_2;for(;t<=-Math.PI;)t+=up.PI_TIMES_2;return t},up.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}},up.isAcute=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0},up.isObtuse=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0},up.interiorAngle=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n);return Math.abs(i-r)},up.normalizePositive=function(t){if(t<0){for(;t<0;)t+=up.PI_TIMES_2;t>=up.PI_TIMES_2&&(t=0)}else{for(;t>=up.PI_TIMES_2;)t-=up.PI_TIMES_2;t<0&&(t=0)}return t},up.angleBetween=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n);return up.diff(r,i)},up.diff=function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},up.toRadians=function(t){return t*Math.PI/180},up.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?up.COUNTERCLOCKWISE:n<0?up.CLOCKWISE:up.NONE},up.angleBetweenOriented=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n)-r;return i<=-Math.PI?i+up.PI_TIMES_2:i>Math.PI?i-up.PI_TIMES_2:i},cp.PI_TIMES_2.get=function(){return 2*Math.PI},cp.PI_OVER_2.get=function(){return Math.PI/2},cp.PI_OVER_4.get=function(){return Math.PI/4},cp.COUNTERCLOCKWISE.get=function(){return wu.COUNTERCLOCKWISE},cp.CLOCKWISE.get=function(){return wu.CLOCKWISE},cp.NONE.get=function(){return wu.COLLINEAR},Object.defineProperties(up,cp);var hp=function t(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new Zh,this._seg1=new Zh,this._offset0=new Zh,this._offset1=new Zh,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new _u,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===rp.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)},pp={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};hp.prototype.addNextSegment=function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=wu.computeOrientation(this._s0,this._s1,this._s2),r=n===wu.CLOCKWISE&&this._side===rh.LEFT||n===wu.COUNTERCLOCKWISE&&this._side===rh.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},hp.prototype.addLineEndCap=function(t,e){var n=new Zh(t,e),r=new Zh;this.computeOffsetSegment(n,rh.LEFT,this._distance,r);var i=new Zh;this.computeOffsetSegment(n,rh.RIGHT,this._distance,i);var o=e.x-t.x,a=e.y-t.y,s=Math.atan2(a,o);switch(this._bufParams.getEndCapStyle()){case rp.CAP_ROUND:this._segList.addPt(r.p1),this.addFilletArc(e,s+Math.PI/2,s-Math.PI/2,wu.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case rp.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case rp.CAP_SQUARE:var l=new Bl;l.x=Math.abs(this._distance)*Math.cos(s),l.y=Math.abs(this._distance)*Math.sin(s);var u=new Bl(r.p1.x+l.x,r.p1.y+l.y),c=new Bl(i.p1.x+l.x,i.p1.y+l.y);this._segList.addPt(u),this._segList.addPt(c)}},hp.prototype.getCoordinates=function(){return this._segList.getCoordinates()},hp.prototype.addMitreJoin=function(t,e,n,r){var i=!0,o=null;try{o=au.intersection(e.p0,e.p1,n.p0,n.p1),(r<=0?1:o.distance(t)/Math.abs(r))>this._bufParams.getMitreLimit()&&(i=!1)}catch(t){if(!(t instanceof iu))throw t;o=new Bl(0,0),i=!1}i?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())},hp.prototype.addFilletCorner=function(t,e,n,r,i){var o=e.x-t.x,a=e.y-t.y,s=Math.atan2(a,o),l=n.x-t.x,u=n.y-t.y,c=Math.atan2(u,l);r===wu.CLOCKWISE?s<=c&&(s+=2*Math.PI):s>=c&&(s-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,s,c,r,i),this._segList.addPt(n)},hp.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*hp.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===rp.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===rp.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(e&&this._segList.addPt(this._offset0.p1),this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,t,this._distance),this._segList.addPt(this._offset1.p0))},hp.prototype.createSquare=function(t){this._segList.addPt(new Bl(t.x+this._distance,t.y+this._distance)),this._segList.addPt(new Bl(t.x+this._distance,t.y-this._distance)),this._segList.addPt(new Bl(t.x-this._distance,t.y-this._distance)),this._segList.addPt(new Bl(t.x-this._distance,t.y+this._distance)),this._segList.closeRing()},hp.prototype.addSegments=function(t,e){this._segList.addPts(t,e)},hp.prototype.addFirstSegment=function(){this._segList.addPt(this._offset1.p0)},hp.prototype.addLastSegment=function(){this._segList.addPt(this._offset1.p1)},hp.prototype.initSideSegments=function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)},hp.prototype.addLimitedMitreJoin=function(t,e,n,r){var i=this._seg0.p1,o=up.angle(i,this._seg0.p0),a=up.angleBetweenOriented(this._seg0.p0,i,this._seg1.p1)/2,s=up.normalize(o+a),l=up.normalize(s+Math.PI),u=r*n,c=n-u*Math.abs(Math.sin(a)),h=i.x+u*Math.cos(l),p=i.y+u*Math.sin(l),f=new Bl(h,p),d=new Zh(i,f),m=d.pointAlongOffset(1,c),g=d.pointAlongOffset(1,-c);this._side===rh.LEFT?(this._segList.addPt(m),this._segList.addPt(g)):(this._segList.addPt(g),this._segList.addPt(m))},hp.prototype.computeOffsetSegment=function(t,e,n,r){var i=e===rh.LEFT?1:-1,o=t.p1.x-t.p0.x,a=t.p1.y-t.p0.y,s=Math.sqrt(o*o+a*a),l=i*n*o/s,u=i*n*a/s;r.p0.x=t.p0.x-u,r.p0.y=t.p0.y+l,r.p1.x=t.p1.x-u,r.p1.y=t.p1.y+l},hp.prototype.addFilletArc=function(t,e,n,r,i){var o=r===wu.CLOCKWISE?-1:1,a=Math.abs(e-n),s=Math.trunc(a/this._filletAngleQuantum+.5);if(s<1)return null;for(var l=a/s,u=0,c=new Bl;u<a;){var h=e+o*u;c.x=t.x+i*Math.cos(h),c.y=t.y+i*Math.sin(h),this._segList.addPt(c),u+=l}},hp.prototype.addInsideTurn=function(t,e){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*hp.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var n=new Bl((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var r=new Bl((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}},hp.prototype.createCircle=function(t){var e=new Bl(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},hp.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},hp.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new sp,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*hp.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},hp.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===rp.JOIN_BEVEL||this._bufParams.getJoinStyle()===rp.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,wu.CLOCKWISE,this._distance))},hp.prototype.closeRing=function(){this._segList.closeRing()},hp.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},hp.prototype.interfaces_=function(){return[]},hp.prototype.getClass=function(){return hp},pp.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},pp.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},pp.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},pp.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(hp,pp);var fp=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e};fp.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&ju.reverse(o),o},fp.prototype.computeSingleSidedBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=op.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],rh.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{n.addSegments(t,!1);var s=op.simplify(t,r),l=s.length-1;n.initSideSegments(s[0],s[1],rh.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(s[u],!0)}n.addLastSegment(),n.closeRing()},fp.prototype.computeRingBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);e===rh.RIGHT&&(r=-r);var i=op.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var a=1;a<=o;a++){var s=1!==a;n.addNextSegment(i[a],s)}n.closeRing()},fp.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),r=op.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],rh.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var a=op.simplify(t,-n),s=a.length-1;e.initSideSegments(a[s],a[s-1],rh.LEFT);for(var l=s-2;l>=0;l--)e.addNextSegment(a[l],!0);e.addLastSegment(),e.addLineEndCap(a[1],a[0]),e.closeRing()},fp.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case rp.CAP_ROUND:e.createCircle(t);break;case rp.CAP_SQUARE:e.createSquare(t)}},fp.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r)}else this.computeLineBufferCurve(t,r);return r.getCoordinates()},fp.prototype.getBufferParameters=function(){return this._bufParams},fp.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},fp.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return fp.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,e,r),r.getCoordinates()},fp.prototype.computeOffsetCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=op.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],rh.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{var s=op.simplify(t,r),l=s.length-1;n.initSideSegments(s[0],s[1],rh.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(s[u],!0)}n.addLastSegment()},fp.prototype.getSegGen=function(t){return new hp(this._precisionModel,this._bufParams,t)},fp.prototype.interfaces_=function(){return[]},fp.prototype.getClass=function(){return fp},fp.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;n<e.length;n++)e[n]=new Bl(t[n]);return e};var dp=function(){this._subgraphs=null,this._seg=new Zh,this._cga=new wu;var t=arguments[0];this._subgraphs=t},mp={DepthSegment:{configurable:!0}};dp.prototype.findStabbedSegments=function(){var t=this;if(1===arguments.length){for(var e=arguments[0],n=new Uu,r=this._subgraphs.iterator();r.hasNext();){var i=r.next(),o=i.getEnvelope();e.y<o.getMinY()||e.y>o.getMaxY()||t.findStabbedSegments(e,i.getDirectedEdges(),n)}return n}if(3===arguments.length)if(ql(arguments[2],Fu)&&arguments[0]instanceof Bl&&arguments[1]instanceof wh)for(var a=arguments[0],s=arguments[1],l=arguments[2],u=s.getEdge().getCoordinates(),c=0;c<u.length-1;c++){t._seg.p0=u[c],t._seg.p1=u[c+1],t._seg.p0.y>t._seg.p1.y&&t._seg.reverse();if(!(Math.max(t._seg.p0.x,t._seg.p1.x)<a.x||t._seg.isHorizontal()||a.y<t._seg.p0.y||a.y>t._seg.p1.y||wu.computeOrientation(t._seg.p0,t._seg.p1,a)===wu.RIGHT)){var h=s.getDepth(rh.LEFT);t._seg.p0.equals(u[c])||(h=s.getDepth(rh.RIGHT));var p=new gp(t._seg,h);l.add(p)}}else if(ql(arguments[2],Fu)&&arguments[0]instanceof Bl&&ql(arguments[1],Fu))for(var f=arguments[0],d=arguments[2],m=arguments[1].iterator();m.hasNext();){var g=m.next();g.isForward()&&t.findStabbedSegments(f,g,d)}},dp.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:Dh.min(e)._leftDepth},dp.prototype.interfaces_=function(){return[]},dp.prototype.getClass=function(){return dp},mp.DepthSegment.get=function(){return gp},Object.defineProperties(dp,mp);var gp=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new Zh(t),this._leftDepth=e};gp.prototype.compareTo=function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)},gp.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},gp.prototype.toString=function(){return this._upwardSeg.toString()},gp.prototype.interfaces_=function(){return[Ol]},gp.prototype.getClass=function(){return gp};var yp=function(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null};yp.prototype.area=function(){return yp.area(this.p0,this.p1,this.p2)},yp.prototype.signedArea=function(){return yp.signedArea(this.p0,this.p1,this.p2)},yp.prototype.interpolateZ=function(t){if(null===t)throw new Rl("Supplied point is null.");return yp.interpolateZ(t,this.p0,this.p1,this.p2)},yp.prototype.longestSideLength=function(){return yp.longestSideLength(this.p0,this.p1,this.p2)},yp.prototype.isAcute=function(){return yp.isAcute(this.p0,this.p1,this.p2)},yp.prototype.circumcentre=function(){return yp.circumcentre(this.p0,this.p1,this.p2)},yp.prototype.area3D=function(){return yp.area3D(this.p0,this.p1,this.p2)},yp.prototype.centroid=function(){return yp.centroid(this.p0,this.p1,this.p2)},yp.prototype.inCentre=function(){return yp.inCentre(this.p0,this.p1,this.p2)},yp.prototype.interfaces_=function(){return[]},yp.prototype.getClass=function(){return yp},yp.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},yp.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},yp.det=function(t,e,n,r){return t*r-e*n},yp.interpolateZ=function(t,e,n,r){var i=e.x,o=e.y,a=n.x-i,s=r.x-i,l=n.y-o,u=r.y-o,c=a*u-s*l,h=t.x-i,p=t.y-o,f=(u*h-s*p)/c,d=(-l*h+a*p)/c;return e.z+f*(n.z-e.z)+d*(r.z-e.z)},yp.longestSideLength=function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),a=r;return i>a&&(a=i),o>a&&(a=o),a},yp.isAcute=function(t,e,n){return!!up.isAcute(t,e,n)&&!!up.isAcute(e,n,t)&&!!up.isAcute(n,t,e)},yp.circumcentre=function(t,e,n){var r=n.x,i=n.y,o=t.x-r,a=t.y-i,s=e.x-r,l=e.y-i,u=2*yp.det(o,a,s,l),c=yp.det(a,o*o+a*a,l,s*s+l*l),h=yp.det(o,o*o+a*a,s,s*s+l*l);return new Bl(r-c/u,i+h/u)},yp.perpendicularBisector=function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new au(t.x+n/2,t.y+r/2,1),o=new au(t.x-r+n/2,t.y+n+r/2,1);return new au(i,o)},yp.angleBisector=function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,a=n.y-t.y;return new Bl(t.x+i*o,t.y+i*a)},yp.area3D=function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.z-t.z,a=n.x-t.x,s=n.y-t.y,l=n.z-t.z,u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,p=u*u+c*c+h*h;return Math.sqrt(p)/2},yp.centroid=function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new Bl(r,i)},yp.inCentre=function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),a=r+i+o,s=(r*t.x+i*e.x+o*n.x)/a,l=(r*t.y+i*e.y+o*n.y)/a;return new Bl(s,l)};var vp=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new Uu;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n};vp.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,jl.EXTERIOR,jl.INTERIOR)},vp.prototype.addPolygon=function(t){var e=this,n=this._distance,r=rh.LEFT;this._distance<0&&(n=-this._distance,r=rh.RIGHT);var i=t.getExteriorRing(),o=ju.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&o.length<3)return null;this.addPolygonRing(o,n,r,jl.EXTERIOR,jl.INTERIOR);for(var a=0;a<t.getNumInteriorRing();a++){var s=t.getInteriorRingN(a),l=ju.removeRepeatedPoints(s.getCoordinates());e._distance>0&&e.isErodedCompletely(s,-e._distance)||e.addPolygonRing(l,n,rh.opposite(r),jl.INTERIOR,jl.EXTERIOR)}},vp.prototype.isTriangleErodedCompletely=function(t,e){var n=new yp(t[0],t[1],t[2]),r=n.inCentre();return wu.distancePointLine(r,n.p0,n.p1)<Math.abs(e)},vp.prototype.addLineString=function(t){if(this._distance<=0&&!this._curveBuilder.getBufferParameters().isSingleSided())return null;var e=ju.removeRepeatedPoints(t.getCoordinates()),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,jl.EXTERIOR,jl.INTERIOR)},vp.prototype.addCurve=function(t,e,n){if(null===t||t.length<2)return null;var r=new Xh(t,new ph(0,jl.BOUNDARY,e,n));this._curveList.add(r)},vp.prototype.getCurves=function(){return this.add(this._inputGeom),this._curveList},vp.prototype.addPolygonRing=function(t,e,n,r,i){if(0===e&&t.length<Dc.MINIMUM_VALID_SIZE)return null;var o=r,a=i;t.length>=Dc.MINIMUM_VALID_SIZE&&wu.isCCW(t)&&(o=i,a=r,n=rh.opposite(n));var s=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(s,o,a)},vp.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Pc?this.addPolygon(t):t instanceof Cc?this.addLineString(t):t instanceof Ac?this.addPoint(t):(t instanceof Rc||t instanceof mc||t instanceof Nc||t instanceof dc)&&this.addCollection(t)},vp.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var r=t.getEnvelopeInternal(),i=Math.min(r.getHeight(),r.getWidth());return e<0&&2*Math.abs(e)>i},vp.prototype.addCollection=function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}},vp.prototype.interfaces_=function(){return[]},vp.prototype.getClass=function(){return vp};var _p=function(){};_p.prototype.locate=function(t){},_p.prototype.interfaces_=function(){return[]},_p.prototype.getClass=function(){return _p};var xp=function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()};xp.prototype.next=function(){if(this._atStart)return this._atStart=!1,xp.isAtomic(this._parent)&&this._index++,this._parent;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new Bu;var t=this._parent.getGeometryN(this._index++);return t instanceof dc?(this._subcollectionIterator=new xp(t),this._subcollectionIterator.next()):t},xp.prototype.remove=function(){throw new Error(this.getClass().getName())},xp.prototype.hasNext=function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)},xp.prototype.interfaces_=function(){return[zu]},xp.prototype.getClass=function(){return xp},xp.isAtomic=function(t){return!(t instanceof dc)};var bp=function(){this._geom=null;var t=arguments[0];this._geom=t};bp.prototype.locate=function(t){return bp.locate(t,this._geom)},bp.prototype.interfaces_=function(){return[_p]},bp.prototype.getClass=function(){return bp},bp.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&wu.isPointInRing(t,e.getCoordinates())},bp.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!bp.isPointInRing(t,n))return!1;for(var r=0;r<e.getNumInteriorRing();r++){var i=e.getInteriorRingN(r);if(bp.isPointInRing(t,i))return!1}return!0},bp.containsPoint=function(t,e){if(e instanceof Pc)return bp.containsPointInPolygon(t,e);if(e instanceof dc)for(var n=new xp(e);n.hasNext();){var r=n.next();if(r!==e&&bp.containsPoint(t,r))return!0}return!1},bp.locate=function(t,e){return e.isEmpty()?jl.EXTERIOR:bp.containsPoint(t,e)?jl.INTERIOR:jl.EXTERIOR};var wp=function(){this._edgeMap=new ic,this._edgeList=null,this._ptInAreaLocation=[jl.NONE,jl.NONE]};wp.prototype.getNextCW=function(t){this.getEdges();var e=this._edgeList.indexOf(t),n=e-1;return 0===e&&(n=this._edgeList.size()-1),this._edgeList.get(n)},wp.prototype.propagateSideLabels=function(t){for(var e=jl.NONE,n=this.iterator();n.hasNext();){var r=n.next().getLabel();r.isArea(t)&&r.getLocation(t,rh.LEFT)!==jl.NONE&&(e=r.getLocation(t,rh.LEFT))}if(e===jl.NONE)return null;for(var i=e,o=this.iterator();o.hasNext();){var a=o.next(),s=a.getLabel();if(s.getLocation(t,rh.ON)===jl.NONE&&s.setLocation(t,rh.ON,i),s.isArea(t)){var l=s.getLocation(t,rh.LEFT),u=s.getLocation(t,rh.RIGHT);if(u!==jl.NONE){if(u!==i)throw new lh("side location conflict",a.getCoordinate());l===jl.NONE&&gu.shouldNeverReachHere("found single null side (at "+a.getCoordinate()+")"),i=l}else gu.isTrue(s.getLocation(t,rh.LEFT)===jl.NONE,"found single null side"),s.setLocation(t,rh.RIGHT,i),s.setLocation(t,rh.LEFT,i)}}},wp.prototype.getCoordinate=function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null},wp.prototype.print=function(t){ou.out.println("EdgeEndStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)},wp.prototype.isAreaLabelsConsistent=function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)},wp.prototype.checkAreaLabelsConsistent=function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,r=e.get(n).getLabel().getLocation(t,rh.LEFT);gu.isTrue(r!==jl.NONE,"Found unlabelled area edge");for(var i=r,o=this.iterator();o.hasNext();){var a=o.next().getLabel();gu.isTrue(a.isArea(t),"Found non-area edge");var s=a.getLocation(t,rh.LEFT),l=a.getLocation(t,rh.RIGHT);if(s===l)return!1;if(l!==i)return!1;i=s}return!0},wp.prototype.findIndex=function(t){this.iterator();for(var e=0;e<this._edgeList.size();e++)if(this._edgeList.get(e)===t)return e;return-1},wp.prototype.iterator=function(){return this.getEdges().iterator()},wp.prototype.getEdges=function(){return null===this._edgeList&&(this._edgeList=new Uu(this._edgeMap.values())),this._edgeList},wp.prototype.getLocation=function(t,e,n){return this._ptInAreaLocation[t]===jl.NONE&&(this._ptInAreaLocation[t]=bp.locate(e,n[t].getGeometry())),this._ptInAreaLocation[t]},wp.prototype.toString=function(){var t=new Zl;t.append("EdgeEndStar: "+this.getCoordinate()),t.append("\n");for(var e=this.iterator();e.hasNext();){var n=e.next();t.append(n),t.append("\n")}return t.toString()},wp.prototype.computeEdgeEndLabels=function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)},wp.prototype.computeLabelling=function(t){this.computeEdgeEndLabels(t[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var e=[!1,!1],n=this.iterator();n.hasNext();)for(var r=n.next().getLabel(),i=0;i<2;i++)r.isLine(i)&&r.getLocation(i)===jl.BOUNDARY&&(e[i]=!0);for(var o=this.iterator();o.hasNext();)for(var a=o.next(),s=a.getLabel(),l=0;l<2;l++)if(s.isAnyNull(l)){var u=jl.NONE;if(e[l])u=jl.EXTERIOR;else{var c=a.getCoordinate();u=this.getLocation(l,c,t)}s.setAllLocationsIfNull(l,u)}},wp.prototype.getDegree=function(){return this._edgeMap.size()},wp.prototype.insertEdgeEnd=function(t,e){this._edgeMap.put(t,e),this._edgeList=null},wp.prototype.interfaces_=function(){return[]},wp.prototype.getClass=function(){return wp};var Ep=function(t){function e(){t.call(this),this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.linkResultDirectedEdges=function(){var t=this;this.getResultAreaEdges();for(var e=null,n=null,r=this._SCANNING_FOR_INCOMING,i=0;i<this._resultAreaEdgeList.size();i++){var o=t._resultAreaEdgeList.get(i),a=o.getSym();if(o.getLabel().isArea())switch(null===e&&o.isInResult()&&(e=o),r){case t._SCANNING_FOR_INCOMING:if(!a.isInResult())continue;n=a,r=t._LINKING_TO_OUTGOING;break;case t._LINKING_TO_OUTGOING:if(!o.isInResult())continue;n.setNext(o),r=t._SCANNING_FOR_INCOMING}}if(r===this._LINKING_TO_OUTGOING){if(null===e)throw new lh("no outgoing dirEdge found",this.getCoordinate());gu.isTrue(e.isInResult(),"unable to link last incoming dirEdge"),n.setNext(e)}},e.prototype.insert=function(t){var e=t;this.insertEdgeEnd(e,e)},e.prototype.getRightmostEdge=function(){var t=this.getEdges(),e=t.size();if(e<1)return null;var n=t.get(0);if(1===e)return n;var r=t.get(e-1),i=n.getQuadrant(),o=r.getQuadrant();return _h.isNorthern(i)&&_h.isNorthern(o)?n:_h.isNorthern(i)||_h.isNorthern(o)?0!==n.getDy()?n:0!==r.getDy()?r:(gu.shouldNeverReachHere("found two horizontal edges incident on node"),null):r},e.prototype.print=function(t){ou.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();){var n=e.next();t.print("out "),n.print(t),t.println(),t.print("in "),n.getSym().print(t),t.println()}},e.prototype.getResultAreaEdges=function(){if(null!==this._resultAreaEdgeList)return this._resultAreaEdgeList;this._resultAreaEdgeList=new Uu;for(var t=this.iterator();t.hasNext();){var e=t.next();(e.isInResult()||e.getSym().isInResult())&&this._resultAreaEdgeList.add(e)}return this._resultAreaEdgeList},e.prototype.updateLabelling=function(t){for(var e=this.iterator();e.hasNext();){var n=e.next().getLabel();n.setAllLocationsIfNull(0,t.getLocation(0)),n.setAllLocationsIfNull(1,t.getLocation(1))}},e.prototype.linkAllDirectedEdges=function(){this.getEdges();for(var t=null,e=null,n=this._edgeList.size()-1;n>=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r}e.setNext(t)},e.prototype.computeDepths=function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(rh.LEFT),r=t.getDepth(rh.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,i)!==r)throw new lh("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],a=arguments[2],s=arguments[0];s<o;s++){var l=this._edgeList.get(s);l.setEdgeDepths(rh.RIGHT,a),a=l.getDepth(rh.LEFT)}return a}},e.prototype.mergeSymLabels=function(){for(var t=this.iterator();t.hasNext();){var e=t.next();e.getLabel().merge(e.getSym().getLabel())}},e.prototype.linkMinimalDirectedEdges=function(t){for(var e=this,n=null,r=null,i=this._SCANNING_FOR_INCOMING,o=this._resultAreaEdgeList.size()-1;o>=0;o--){var a=e._resultAreaEdgeList.get(o),s=a.getSym();switch(null===n&&a.getEdgeRing()===t&&(n=a),i){case e._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;r=s,i=e._LINKING_TO_OUTGOING;break;case e._LINKING_TO_OUTGOING:if(a.getEdgeRing()!==t)continue;r.setNextMin(a),i=e._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(gu.isTrue(null!==n,"found null for first outgoing dirEdge"),gu.isTrue(n.getEdgeRing()===t,"unable to link last incoming dirEdge"),r.setNextMin(n))},e.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){e.next().isInResult()&&t++}return t}if(1===arguments.length){for(var n=arguments[0],r=0,i=this.iterator();i.hasNext();){i.next().getEdgeRing()===n&&r++}return r}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var t=jl.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=jl.INTERIOR;break}if(r.isInResult()){t=jl.EXTERIOR;break}}}if(t===jl.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var a=o.next(),s=a.getSym();a.isLineEdge()?a.getEdge().setCovered(i===jl.INTERIOR):(a.isInResult()&&(i=jl.EXTERIOR),s.isInResult()&&(i=jl.INTERIOR))}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new ph(jl.NONE);for(var n=this.iterator();n.hasNext();)for(var r=n.next().getEdge().getLabel(),i=0;i<2;i++){var o=r.getLocation(i);o!==jl.INTERIOR&&o!==jl.BOUNDARY||this._label.setLocation(i,jl.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(wp),Sp=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(t){return new yh(t,new Ep)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Eh),Mp=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};Mp.prototype.compareTo=function(t){var e=t;return Mp.compareOriented(this._pts,this._orientation,e._pts,e._orientation)},Mp.prototype.interfaces_=function(){return[Ol]},Mp.prototype.getClass=function(){return Mp},Mp.orientation=function(t){return 1===ju.increasingDirection(t)},Mp.compareOriented=function(t,e,n,r){for(var i=e?1:-1,o=r?1:-1,a=e?t.length:-1,s=r?n.length:-1,l=e?0:t.length-1,u=r?0:n.length-1;;){var c=t[l].compareTo(n[u]);if(0!==c)return c;var h=(l+=i)===a,p=(u+=o)===s;if(h&&!p)return-1;if(!h&&p)return 1;if(h&&p)return 0}};var Tp=function(){this._edges=new Uu,this._ocaMap=new ic};Tp.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e<this._edges.size();e++){var n=this._edges.get(e);e>0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i<r.length;i++)i>0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")")}t.print(") ")},Tp.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Tp.prototype.findEdgeIndex=function(t){for(var e=0;e<this._edges.size();e++)if(this._edges.get(e).equals(t))return e;return-1},Tp.prototype.iterator=function(){return this._edges.iterator()},Tp.prototype.getEdges=function(){return this._edges},Tp.prototype.get=function(t){return this._edges.get(t)},Tp.prototype.findEqualEdge=function(t){var e=new Mp(t.getCoordinates());return this._ocaMap.get(e)},Tp.prototype.add=function(t){this._edges.add(t);var e=new Mp(t.getCoordinates());this._ocaMap.put(e,t)},Tp.prototype.interfaces_=function(){return[]},Tp.prototype.getClass=function(){return Tp};var Cp=function(){};Cp.prototype.processIntersections=function(t,e,n,r){},Cp.prototype.isDone=function(){},Cp.prototype.interfaces_=function(){return[]},Cp.prototype.getClass=function(){return Cp};var Ip=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this._li=t};Ip.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(Ip.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.size()-1;if(0===e&&r===i||0===r&&e===i)return!0}}return!1},Ip.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Ip.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Ip.prototype.getLineIntersector=function(){return this._li},Ip.prototype.hasProperIntersection=function(){return this._hasProper},Ip.prototype.processIntersections=function(t,e,n,r){if(t===n&&e===r)return null;this.numTests++;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(t,e,n,r)||(this._hasIntersection=!0,t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))},Ip.prototype.hasIntersection=function(){return this._hasIntersection},Ip.prototype.isDone=function(){return!1},Ip.prototype.hasInteriorIntersection=function(){return this._hasInterior},Ip.prototype.interfaces_=function(){return[Cp]},Ip.prototype.getClass=function(){return Ip},Ip.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var Ap=function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new Bl(t),this.segmentIndex=e,this.dist=n};Ap.prototype.getSegmentIndex=function(){return this.segmentIndex},Ap.prototype.getCoordinate=function(){return this.coord},Ap.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex),t.println(" dist = "+this.dist)},Ap.prototype.compareTo=function(t){var e=t;return this.compare(e.segmentIndex,e.dist)},Ap.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===t},Ap.prototype.toString=function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist},Ap.prototype.getDistance=function(){return this.dist},Ap.prototype.compare=function(t,e){return this.segmentIndex<t?-1:this.segmentIndex>t?1:this.dist<e?-1:this.dist>e?1:0},Ap.prototype.interfaces_=function(){return[Ol]},Ap.prototype.getClass=function(){return Ap};var Lp=function(){this._nodeMap=new ic,this.edge=null;var t=arguments[0];this.edge=t};Lp.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},Lp.prototype.iterator=function(){return this._nodeMap.values().iterator()},Lp.prototype.addSplitEdges=function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next(),i=this.createSplitEdge(n,r);t.add(i),n=r}},Lp.prototype.addEndpoints=function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)},Lp.prototype.createSplitEdge=function(t,e){var n=e.segmentIndex-t.segmentIndex+2,r=this.edge.pts[e.segmentIndex],i=e.dist>0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),a=0;o[a++]=new Bl(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)o[a++]=this.edge.pts[s];return i&&(o[a]=e.coord),new Op(o,new ph(this.edge._label))},Lp.prototype.add=function(t,e,n){var r=new Ap(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r)},Lp.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1},Lp.prototype.interfaces_=function(){return[]},Lp.prototype.getClass=function(){return Lp};var Pp=function(){};Pp.prototype.getChainStartIndices=function(t){var e=0,n=new Uu;n.add(new Yl(e));do{var r=this.findChainEnd(t,e);n.add(new Yl(r)),e=r}while(e<t.length-1);return Pp.toIntArray(n)},Pp.prototype.findChainEnd=function(t,e){for(var n=_h.quadrant(t[e],t[e+1]),r=e+1;r<t.length&&_h.quadrant(t[r-1],t[r])===n;)r++;return r-1},Pp.prototype.interfaces_=function(){return[]},Pp.prototype.getClass=function(){return Pp},Pp.toIntArray=function(t){for(var e=new Array(t.size()).fill(null),n=0;n<e.length;n++)e[n]=t.get(n).intValue();return e};var Rp=function(){this.e=null,this.pts=null,this.startIndex=null,this.env1=new su,this.env2=new su;var t=arguments[0];this.e=t,this.pts=t.getCoordinates();var e=new Pp;this.startIndex=e.getChainStartIndices(this.pts)};Rp.prototype.getCoordinates=function(){return this.pts},Rp.prototype.getMaxX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e>n?e:n},Rp.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return e<n?e:n},Rp.prototype.computeIntersectsForChain=function(){if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this.computeIntersectsForChain(this.startIndex[t],this.startIndex[t+1],e,e.startIndex[n],e.startIndex[n+1],r)}else if(6===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3],l=arguments[4],u=arguments[5],c=this.pts[i],h=this.pts[o],p=a.pts[s],f=a.pts[l];if(o-i==1&&l-s==1)return u.addIntersections(this.e,i,a.e,s),null;if(this.env1.init(c,h),this.env2.init(p,f),!this.env1.intersects(this.env2))return null;var d=Math.trunc((i+o)/2),m=Math.trunc((s+l)/2);i<d&&(s<m&&this.computeIntersectsForChain(i,d,a,s,m,u),m<l&&this.computeIntersectsForChain(i,d,a,m,l,u)),d<o&&(s<m&&this.computeIntersectsForChain(d,o,a,s,m,u),m<l&&this.computeIntersectsForChain(d,o,a,m,l,u))}},Rp.prototype.getStartIndexes=function(){return this.startIndex},Rp.prototype.computeIntersects=function(t,e){for(var n=0;n<this.startIndex.length-1;n++)for(var r=0;r<t.startIndex.length-1;r++)this.computeIntersectsForChain(n,t,r,e)},Rp.prototype.interfaces_=function(){return[]},Rp.prototype.getClass=function(){return Rp};var Dp=function t(){this._depth=Array(2).fill().map((function(){return Array(3)}));for(var e=0;e<2;e++)for(var n=0;n<3;n++)this._depth[e][n]=t.NULL_VALUE},Np={NULL_VALUE:{configurable:!0}};Dp.prototype.getDepth=function(t,e){return this._depth[t][e]},Dp.prototype.setDepth=function(t,e,n){this._depth[t][e]=n},Dp.prototype.isNull=function(){if(0===arguments.length){for(var t=0;t<2;t++)for(var e=0;e<3;e++)if(this._depth[t][e]!==Dp.NULL_VALUE)return!1;return!0}if(1===arguments.length){var n=arguments[0];return this._depth[n][1]===Dp.NULL_VALUE}if(2===arguments.length){var r=arguments[0],i=arguments[1];return this._depth[r][i]===Dp.NULL_VALUE}},Dp.prototype.normalize=function(){for(var t=this,e=0;e<2;e++)if(!t.isNull(e)){var n=t._depth[e][1];t._depth[e][2]<n&&(n=t._depth[e][2]),n<0&&(n=0);for(var r=1;r<3;r++){var i=0;t._depth[e][r]>n&&(i=1),t._depth[e][r]=i}}},Dp.prototype.getDelta=function(t){return this._depth[t][rh.RIGHT]-this._depth[t][rh.LEFT]},Dp.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?jl.EXTERIOR:jl.INTERIOR},Dp.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},Dp.prototype.add=function(){var t=this;if(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=e.getLocation(n,r);i!==jl.EXTERIOR&&i!==jl.INTERIOR||(t.isNull(n,r)?t._depth[n][r]=Dp.depthAtLocation(i):t._depth[n][r]+=Dp.depthAtLocation(i))}else if(3===arguments.length){var o=arguments[0],a=arguments[1];arguments[2]===jl.INTERIOR&&this._depth[o][a]++}},Dp.prototype.interfaces_=function(){return[]},Dp.prototype.getClass=function(){return Dp},Dp.depthAtLocation=function(t){return t===jl.EXTERIOR?0:t===jl.INTERIOR?1:Dp.NULL_VALUE},Np.NULL_VALUE.get=function(){return-1},Object.defineProperties(Dp,Np);var Op=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Lp(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Dp,this._depthDelta=0,1===arguments.length){var n=arguments[0];e.call(this,n,null)}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.pts=r,this._label=i}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getDepth=function(){return this._depth},e.prototype.getCollapsedEdge=function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new e(t,ph.toLineLabel(this._label))},e.prototype.isIsolated=function(){return this._isIsolated},e.prototype.getCoordinates=function(){return this.pts},e.prototype.setIsolated=function(t){this._isIsolated=t},e.prototype.setName=function(t){this._name=t},e.prototype.equals=function(t){if(!(t instanceof e))return!1;var n=t;if(this.pts.length!==n.pts.length)return!1;for(var r=!0,i=!0,o=this.pts.length,a=0;a<this.pts.length;a++)if(this.pts[a].equals2D(n.pts[a])||(r=!1),this.pts[a].equals2D(n.pts[--o])||(i=!1),!r&&!i)return!1;return!0},e.prototype.getCoordinate=function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}},e.prototype.print=function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)},e.prototype.computeIM=function(t){e.updateIM(this._label,t)},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},e.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])},e.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1},e.prototype.getDepthDelta=function(){return this._depthDelta},e.prototype.getNumPoints=function(){return this.pts.length},e.prototype.printReverse=function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},e.prototype.getMonotoneChainEdge=function(){return null===this._mce&&(this._mce=new Rp(this)),this._mce},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new su;for(var t=0;t<this.pts.length;t++)this._env.expandToInclude(this.pts[t])}return this._env},e.prototype.addIntersection=function(t,e,n,r){var i=new Bl(t.getIntersection(r)),o=e,a=t.getEdgeDistance(n,r),s=o+1;if(s<this.pts.length){var l=this.pts[s];i.equals2D(l)&&(o=s,a=0)}this.eiList.add(i,o,a)},e.prototype.toString=function(){var t=new Zl;t.append("edge "+this._name+": "),t.append("LINESTRING (");for(var e=0;e<this.pts.length;e++)e>0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()},e.prototype.isPointwiseEqual=function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e<this.pts.length;e++)if(!this.pts[e].equals2D(t.pts[e]))return!1;return!0},e.prototype.setDepthDelta=function(t){this._depthDelta=t},e.prototype.getEdgeIntersectionList=function(){return this.eiList},e.prototype.addIntersections=function(t,e,n){for(var r=0;r<t.getIntersectionNum();r++)this.addIntersection(t,e,n,r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.updateIM=function(){if(2!==arguments.length)return t.prototype.updateIM.apply(this,arguments);var e=arguments[0],n=arguments[1];n.setAtLeastIfValid(e.getLocation(0,rh.ON),e.getLocation(1,rh.ON),1),e.isArea()&&(n.setAtLeastIfValid(e.getLocation(0,rh.LEFT),e.getLocation(1,rh.LEFT),2),n.setAtLeastIfValid(e.getLocation(0,rh.RIGHT),e.getLocation(1,rh.RIGHT),2))},e}(gh),kp=function(t){this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Tp,this._bufParams=t||null};kp.prototype.setWorkingPrecisionModel=function(t){this._workingPrecisionModel=t},kp.prototype.insertUniqueEdge=function(t){var e=this._edgeList.findEqualEdge(t);if(null!==e){var n=e.getLabel(),r=t.getLabel();e.isPointwiseEqual(t)||(r=new ph(t.getLabel())).flip(),n.merge(r);var i=kp.depthDelta(r),o=e.getDepthDelta()+i;e.setDepthDelta(o)}else this._edgeList.add(t),t.setDepthDelta(kp.depthDelta(t.getLabel()))},kp.prototype.buildSubgraphs=function(t,e){for(var n=new Uu,r=t.iterator();r.hasNext();){var i=r.next(),o=i.getRightmostCoordinate(),a=new dp(n).getDepth(o);i.computeDepth(a),i.findResultEdges(),n.add(i),e.add(i.getDirectedEdges(),i.getNodes())}},kp.prototype.createSubgraphs=function(t){for(var e=new Uu,n=t.getNodes().iterator();n.hasNext();){var r=n.next();if(!r.isVisited()){var i=new ch;i.create(r),e.add(i)}}return Dh.sort(e,Dh.reverseOrder()),e},kp.prototype.createEmptyResultGeometry=function(){return this._geomFact.createPolygon()},kp.prototype.getNoder=function(t){if(null!==this._workingNoder)return this._workingNoder;var e=new ep,n=new _u;return n.setPrecisionModel(t),e.setSegmentIntersector(new Ip(n)),e},kp.prototype.buffer=function(t,e){var n=this._workingPrecisionModel;null===n&&(n=t.getPrecisionModel()),this._geomFact=t.getFactory();var r=new fp(n,this._bufParams),i=new vp(t,e,r).getCurves();if(i.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(i,n),this._graph=new Sh(new Sp),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),a=new Mh(this._geomFact);this.buildSubgraphs(o,a);var s=a.getPolygons();return s.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(s)},kp.prototype.computeNodedEdges=function(t,e){var n=this.getNoder(e);n.computeNodes(t);for(var r=n.getNodedSubstrings().iterator();r.hasNext();){var i=r.next(),o=i.getCoordinates();if(2!==o.length||!o[0].equals2D(o[1])){var a=i.getData(),s=new Op(i.getCoordinates(),new ph(a));this.insertUniqueEdge(s)}}},kp.prototype.setNoder=function(t){this._workingNoder=t},kp.prototype.interfaces_=function(){return[]},kp.prototype.getClass=function(){return kp},kp.depthDelta=function(t){var e=t.getLocation(0,rh.LEFT),n=t.getLocation(0,rh.RIGHT);return e===jl.INTERIOR&&n===jl.EXTERIOR?1:e===jl.EXTERIOR&&n===jl.INTERIOR?-1:0},kp.convertSegStrings=function(t){for(var e=new Yc,n=new Uu;t.hasNext();){var r=t.next(),i=e.createLineString(r.getCoordinates());n.add(i)}return e.buildGeometry(n)};var zp=function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){var t=arguments[0],e=arguments[1];this._noder=t,this._scaleFactor=e,this._offsetX=0,this._offsetY=0,this._isScaled=!this.isIntegerPrecision()}else if(4===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],o=arguments[3];this._noder=n,this._scaleFactor=r,this._offsetX=i,this._offsetY=o,this._isScaled=!this.isIntegerPrecision()}};zp.prototype.rescale=function(){var t=this;if(ql(arguments[0],Ou))for(var e=arguments[0].iterator();e.hasNext();){var n=e.next();t.rescale(n.getCoordinates())}else if(arguments[0]instanceof Array){for(var r=arguments[0],i=0;i<r.length;i++)r[i].x=r[i].x/t._scaleFactor+t._offsetX,r[i].y=r[i].y/t._scaleFactor+t._offsetY;2===r.length&&r[0].equals2D(r[1])&&ou.out.println(r)}},zp.prototype.scale=function(){var t=this;if(ql(arguments[0],Ou)){for(var e=arguments[0],n=new Uu,r=e.iterator();r.hasNext();){var i=r.next();n.add(new Xh(t.scale(i.getCoordinates()),i.getData()))}return n}if(arguments[0]instanceof Array){for(var o=arguments[0],a=new Array(o.length).fill(null),s=0;s<o.length;s++)a[s]=new Bl(Math.round((o[s].x-t._offsetX)*t._scaleFactor),Math.round((o[s].y-t._offsetY)*t._scaleFactor),o[s].z);return ju.removeRepeatedPoints(a)}},zp.prototype.isIntegerPrecision=function(){return 1===this._scaleFactor},zp.prototype.getNodedSubstrings=function(){var t=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(t),t},zp.prototype.computeNodes=function(t){var e=t;this._isScaled&&(e=this.scale(t)),this._noder.computeNodes(e)},zp.prototype.interfaces_=function(){return[$h]},zp.prototype.getClass=function(){return zp};var Fp=function(){this._li=new _u,this._segStrings=null;var t=arguments[0];this._segStrings=t},Bp={fact:{configurable:!0}};Fp.prototype.checkEndPtVertexIntersections=function(){var t=this;if(0===arguments.length)for(var e=this._segStrings.iterator();e.hasNext();){var n=e.next().getCoordinates();t.checkEndPtVertexIntersections(n[0],t._segStrings),t.checkEndPtVertexIntersections(n[n.length-1],t._segStrings)}else if(2===arguments.length)for(var r=arguments[0],i=arguments[1].iterator();i.hasNext();)for(var o=i.next().getCoordinates(),a=1;a<o.length-1;a++)if(o[a].equals(r))throw new du("found endpt/interior pt intersection at index "+a+" :pt "+r)},Fp.prototype.checkInteriorIntersections=function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();)for(var e=t.next(),n=this._segStrings.iterator();n.hasNext();){var r=n.next();this.checkInteriorIntersections(e,r)}else if(2===arguments.length)for(var i=arguments[0],o=arguments[1],a=i.getCoordinates(),s=o.getCoordinates(),l=0;l<a.length-1;l++)for(var u=0;u<s.length-1;u++)this.checkInteriorIntersections(i,l,o,u);else if(4===arguments.length){var c=arguments[0],h=arguments[1],p=arguments[2],f=arguments[3];if(c===p&&h===f)return null;var d=c.getCoordinates()[h],m=c.getCoordinates()[h+1],g=p.getCoordinates()[f],y=p.getCoordinates()[f+1];if(this._li.computeIntersection(d,m,g,y),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,d,m)||this.hasInteriorIntersection(this._li,g,y)))throw new du("found non-noded intersection at "+d+"-"+m+" and "+g+"-"+y)}},Fp.prototype.checkValid=function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()},Fp.prototype.checkCollapses=function(){if(0===arguments.length)for(var t=this._segStrings.iterator();t.hasNext();){var e=t.next();this.checkCollapses(e)}else if(1===arguments.length)for(var n=arguments[0].getCoordinates(),r=0;r<n.length-2;r++)this.checkCollapse(n[r],n[r+1],n[r+2])},Fp.prototype.hasInteriorIntersection=function(t,e,n){for(var r=0;r<t.getIntersectionNum();r++){var i=t.getIntersection(r);if(!i.equals(e)&&!i.equals(n))return!0}return!1},Fp.prototype.checkCollapse=function(t,e,n){if(t.equals(n))throw new du("found non-noded collapse at "+Fp.fact.createLineString([t,e,n]))},Fp.prototype.interfaces_=function(){return[]},Fp.prototype.getClass=function(){return Fp},Bp.fact.get=function(){return new Yc},Object.defineProperties(Fp,Bp);var Up=function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new Rl("Scale factor must be non-zero");1!==e&&(this._pt=new Bl(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new Bl,this._p1Scaled=new Bl),this.initCorners(this._pt)},Vp={SAFE_ENV_EXPANSION_FACTOR:{configurable:!0}};Up.prototype.intersectsScaled=function(t,e){var n=Math.min(t.x,e.x),r=Math.max(t.x,e.x),i=Math.min(t.y,e.y),o=Math.max(t.y,e.y),a=this._maxx<n||this._minx>r||this._maxy<i||this._miny>o;if(a)return!1;var s=this.intersectsToleranceSquare(t,e);return gu.isTrue(!(a&&s),"Found bad envelope test"),s},Up.prototype.initCorners=function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new Bl(this._maxx,this._maxy),this._corner[1]=new Bl(this._minx,this._maxy),this._corner[2]=new Bl(this._minx,this._miny),this._corner[3]=new Bl(this._maxx,this._miny)},Up.prototype.intersects=function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))},Up.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},Up.prototype.getCoordinate=function(){return this._originalPt},Up.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},Up.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=Up.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new su(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},Up.prototype.intersectsPixelClosure=function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))},Up.prototype.intersectsToleranceSquare=function(t,e){var n=!1,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&r||t.equals(this._pt)||e.equals(this._pt)))))},Up.prototype.addSnappedNode=function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(t.addIntersection(this.getCoordinate(),e),!0)},Up.prototype.interfaces_=function(){return[]},Up.prototype.getClass=function(){return Up},Vp.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(Up,Vp);var Gp=function(){this.tempEnv1=new su,this.selectedSegment=new Zh};Gp.prototype.select=function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}},Gp.prototype.interfaces_=function(){return[]},Gp.prototype.getClass=function(){return Gp};var jp=function(){this._index=null;var t=arguments[0];this._index=t},Hp={HotPixelSnapAction:{configurable:!0}};jp.prototype.snap=function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=e.getSafeEnvelope(),o=new qp(e,n,r);return this._index.query(i,{interfaces_:function(){return[Ah]},visitItem:function(t){t.select(i,o)}}),o.isNodeAdded()}},jp.prototype.interfaces_=function(){return[]},jp.prototype.getClass=function(){return jp},Hp.HotPixelSnapAction.get=function(){return qp},Object.defineProperties(jp,Hp);var qp=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._hotPixel=e,this._parentEdge=n,this._hotPixelVertexIndex=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isNodeAdded=function(){return this._isNodeAdded},e.prototype.select=function(){if(2!==arguments.length)return t.prototype.select.apply(this,arguments);var e=arguments[1],n=arguments[0].getContext();if(null!==this._parentEdge&&n===this._parentEdge&&e===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(n,e)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Gp),Wp=function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new Uu};Wp.prototype.processIntersections=function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l<this._li.getIntersectionNum();l++)this._interiorIntersections.add(this._li.getIntersection(l));t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1)}},Wp.prototype.isDone=function(){return!1},Wp.prototype.getInteriorIntersections=function(){return this._interiorIntersections},Wp.prototype.interfaces_=function(){return[Cp]},Wp.prototype.getClass=function(){return Wp};var Xp=function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var t=arguments[0];this._pm=t,this._li=new _u,this._li.setPrecisionModel(t),this._scaleFactor=t.getScale()};Xp.prototype.checkCorrectness=function(t){var e=Xh.getNodedSubstrings(t),n=new Fp(e);try{n.checkValid()}catch(t){if(!(t instanceof ru))throw t;t.printStackTrace()}},Xp.prototype.getNodedSubstrings=function(){return Xh.getNodedSubstrings(this._nodedSegStrings)},Xp.prototype.snapRound=function(t,e){var n=this.findInteriorIntersections(t,e);this.computeIntersectionSnaps(n),this.computeVertexSnaps(t)},Xp.prototype.findInteriorIntersections=function(t,e){var n=new Wp(e);return this._noder.setSegmentIntersector(n),this._noder.computeNodes(t),n.getInteriorIntersections()},Xp.prototype.computeVertexSnaps=function(){var t=this;if(ql(arguments[0],Ou))for(var e=arguments[0].iterator();e.hasNext();){var n=e.next();t.computeVertexSnaps(n)}else if(arguments[0]instanceof Xh)for(var r=arguments[0],i=r.getCoordinates(),o=0;o<i.length;o++){var a=new Up(i[o],t._scaleFactor,t._li);t._pointSnapper.snap(a,r,o)&&r.addIntersection(i[o],o)}},Xp.prototype.computeNodes=function(t){this._nodedSegStrings=t,this._noder=new ep,this._pointSnapper=new jp(this._noder.getIndex()),this.snapRound(t,this._li)},Xp.prototype.computeIntersectionSnaps=function(t){for(var e=this,n=t.iterator();n.hasNext();){var r=n.next(),i=new Up(r,e._scaleFactor,e._li);e._pointSnapper.snap(i)}},Xp.prototype.interfaces_=function(){return[$h]},Xp.prototype.getClass=function(){return Xp};var Zp=function(){if(this._argGeom=null,this._distance=null,this._bufParams=new rp,this._resultGeometry=null,this._saveException=null,1===arguments.length){var t=arguments[0];this._argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._argGeom=e,this._bufParams=n}},Yp={CAP_ROUND:{configurable:!0},CAP_BUTT:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},MAX_PRECISION_DIGITS:{configurable:!0}};Zp.prototype.bufferFixedPrecision=function(t){var e=new zp(new Xp(new qc(1)),t.getScale()),n=new kp(this._bufParams);n.setWorkingPrecisionModel(t),n.setNoder(e),this._resultGeometry=n.buffer(this._argGeom,this._distance)},Zp.prototype.bufferReducedPrecision=function(){var t=this;if(0===arguments.length){for(var e=Zp.MAX_PRECISION_DIGITS;e>=0;e--){try{t.bufferReducedPrecision(e)}catch(e){if(!(e instanceof lh))throw e;t._saveException=e}if(null!==t._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],r=Zp.precisionScaleFactor(this._argGeom,this._distance,n),i=new qc(r);this.bufferFixedPrecision(i)}},Zp.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===qc.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},Zp.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},Zp.prototype.bufferOriginalPrecision=function(){try{var t=new kp(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof du))throw t;this._saveException=t}},Zp.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},Zp.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},Zp.prototype.interfaces_=function(){return[]},Zp.prototype.getClass=function(){return Zp},Zp.bufferOp=function(){if(2===arguments.length){var t=arguments[1];return new Zp(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Mu&&"number"==typeof arguments[1]){var e=arguments[1],n=arguments[2],r=new Zp(arguments[0]);r.setQuadrantSegments(n);return r.getResultGeometry(e)}if(arguments[2]instanceof rp&&arguments[0]instanceof Mu&&"number"==typeof arguments[1]){var i=arguments[1];return new Zp(arguments[0],arguments[2]).getResultGeometry(i)}}else if(4===arguments.length){var o=arguments[1],a=arguments[2],s=arguments[3],l=new Zp(arguments[0]);l.setQuadrantSegments(a),l.setEndCapStyle(s);return l.getResultGeometry(o)}},Zp.precisionScaleFactor=function(t,e,n){var r=t.getEnvelopeInternal(),i=Wl.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o)},Yp.CAP_ROUND.get=function(){return rp.CAP_ROUND},Yp.CAP_BUTT.get=function(){return rp.CAP_FLAT},Yp.CAP_FLAT.get=function(){return rp.CAP_FLAT},Yp.CAP_SQUARE.get=function(){return rp.CAP_SQUARE},Yp.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(Zp,Yp);var Jp=function(){this._pt=[new Bl,new Bl],this._distance=Dl.NaN,this._isNull=!0};Jp.prototype.getCoordinates=function(){return this._pt},Jp.prototype.getCoordinate=function(t){return this._pt[t]},Jp.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);r<this._distance&&this.initialize(e,n,r)}},Jp.prototype.initialize=function(){if(0===arguments.length)this._isNull=!0;else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._pt[0].setCoordinate(t),this._pt[1].setCoordinate(e),this._distance=t.distance(e),this._isNull=!1}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this._pt[0].setCoordinate(n),this._pt[1].setCoordinate(r),this._distance=i,this._isNull=!1}},Jp.prototype.getDistance=function(){return this._distance},Jp.prototype.setMaximum=function(){if(1===arguments.length){var t=arguments[0];this.setMaximum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);r>this._distance&&this.initialize(e,n,r)}},Jp.prototype.interfaces_=function(){return[]},Jp.prototype.getClass=function(){return Jp};var Kp=function(){};Kp.prototype.interfaces_=function(){return[]},Kp.prototype.getClass=function(){return Kp},Kp.computeDistance=function(){if(arguments[2]instanceof Jp&&arguments[0]instanceof Cc&&arguments[1]instanceof Bl)for(var t=arguments[1],e=arguments[2],n=arguments[0].getCoordinates(),r=new Zh,i=0;i<n.length-1;i++){r.setCoordinates(n[i],n[i+1]);var o=r.closestPoint(t);e.setMinimum(o,t)}else if(arguments[2]instanceof Jp&&arguments[0]instanceof Pc&&arguments[1]instanceof Bl){var a=arguments[0],s=arguments[1],l=arguments[2];Kp.computeDistance(a.getExteriorRing(),s,l);for(var u=0;u<a.getNumInteriorRing();u++)Kp.computeDistance(a.getInteriorRingN(u),s,l)}else if(arguments[2]instanceof Jp&&arguments[0]instanceof Mu&&arguments[1]instanceof Bl){var c=arguments[0],h=arguments[1],p=arguments[2];if(c instanceof Cc)Kp.computeDistance(c,h,p);else if(c instanceof Pc)Kp.computeDistance(c,h,p);else if(c instanceof dc)for(var f=c,d=0;d<f.getNumGeometries();d++){var m=f.getGeometryN(d);Kp.computeDistance(m,h,p)}else p.setMinimum(c.getCoordinate(),h)}else if(arguments[2]instanceof Jp&&arguments[0]instanceof Zh&&arguments[1]instanceof Bl){var g=arguments[1],y=arguments[2],v=arguments[0].closestPoint(g);y.setMinimum(v,g)}};var Qp=function(t){this._maxPtDist=new Jp,this._inputGeom=t||null},$p={MaxPointDistanceFilter:{configurable:!0},MaxMidpointDistanceFilter:{configurable:!0}};Qp.prototype.computeMaxMidpointDistance=function(t){var e=new ef(this._inputGeom);t.apply(e),this._maxPtDist.setMaximum(e.getMaxPointDistance())},Qp.prototype.computeMaxVertexDistance=function(t){var e=new tf(this._inputGeom);t.apply(e),this._maxPtDist.setMaximum(e.getMaxPointDistance())},Qp.prototype.findDistance=function(t){return this.computeMaxVertexDistance(t),this.computeMaxMidpointDistance(t),this._maxPtDist.getDistance()},Qp.prototype.getDistancePoints=function(){return this._maxPtDist},Qp.prototype.interfaces_=function(){return[]},Qp.prototype.getClass=function(){return Qp},$p.MaxPointDistanceFilter.get=function(){return tf},$p.MaxMidpointDistanceFilter.get=function(){return ef},Object.defineProperties(Qp,$p);var tf=function(t){this._maxPtDist=new Jp,this._minPtDist=new Jp,this._geom=t||null};tf.prototype.filter=function(t){this._minPtDist.initialize(),Kp.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},tf.prototype.getMaxPointDistance=function(){return this._maxPtDist},tf.prototype.interfaces_=function(){return[Iu]},tf.prototype.getClass=function(){return tf};var ef=function(t){this._maxPtDist=new Jp,this._minPtDist=new Jp,this._geom=t||null};ef.prototype.filter=function(t,e){if(0===e)return null;var n=t.getCoordinate(e-1),r=t.getCoordinate(e),i=new Bl((n.x+r.x)/2,(n.y+r.y)/2);this._minPtDist.initialize(),Kp.computeDistance(this._geom,i,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},ef.prototype.isDone=function(){return!1},ef.prototype.isGeometryChanged=function(){return!1},ef.prototype.getMaxPointDistance=function(){return this._maxPtDist},ef.prototype.interfaces_=function(){return[fc]},ef.prototype.getClass=function(){return ef};var nf=function(t){this._comps=t||null};nf.prototype.filter=function(t){t instanceof Pc&&this._comps.add(t)},nf.prototype.interfaces_=function(){return[pc]},nf.prototype.getClass=function(){return nf},nf.getPolygons=function(){if(1===arguments.length){return nf.getPolygons(arguments[0],new Uu)}if(2===arguments.length){var t=arguments[0],e=arguments[1];return t instanceof Pc?e.add(t):t instanceof dc&&t.apply(new nf(e)),e}};var rf=function(){if(this._lines=null,this._isForcedToLineString=!1,1===arguments.length){var t=arguments[0];this._lines=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._lines=e,this._isForcedToLineString=n}};rf.prototype.filter=function(t){if(this._isForcedToLineString&&t instanceof Dc){var e=t.getFactory().createLineString(t.getCoordinateSequence());return this._lines.add(e),null}t instanceof Cc&&this._lines.add(t)},rf.prototype.setForceToLineString=function(t){this._isForcedToLineString=t},rf.prototype.interfaces_=function(){return[Su]},rf.prototype.getClass=function(){return rf},rf.getGeometry=function(){if(1===arguments.length){var t=arguments[0];return t.getFactory().buildGeometry(rf.getLines(t))}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e.getFactory().buildGeometry(rf.getLines(e,n))}},rf.getLines=function(){if(1===arguments.length){return rf.getLines(arguments[0],!1)}if(2===arguments.length){if(ql(arguments[0],Ou)&&ql(arguments[1],Ou)){for(var t=arguments[1],e=arguments[0].iterator();e.hasNext();){var n=e.next();rf.getLines(n,t)}return t}if(arguments[0]instanceof Mu&&"boolean"==typeof arguments[1]){var r=arguments[0],i=arguments[1],o=new Uu;return r.apply(new rf(o,i)),o}if(arguments[0]instanceof Mu&&ql(arguments[1],Ou)){var a=arguments[0],s=arguments[1];return a instanceof Cc?s.add(a):a.apply(new rf(s)),s}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&ql(arguments[0],Ou)&&ql(arguments[1],Ou)){for(var l=arguments[1],u=arguments[2],c=arguments[0].iterator();c.hasNext();){var h=c.next();rf.getLines(h,l,u)}return l}if("boolean"==typeof arguments[2]&&arguments[0]instanceof Mu&&ql(arguments[1],Ou)){var p=arguments[1],f=arguments[2];return arguments[0].apply(new rf(p,f)),p}}};var of=function(){if(this._boundaryRule=Au.OGC_SFS_BOUNDARY_RULE,this._isIn=null,this._numBoundaries=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];if(null===t)throw new Rl("Rule must be non-null");this._boundaryRule=t}};of.prototype.locateInternal=function(){if(arguments[0]instanceof Bl&&arguments[1]instanceof Pc){var t=arguments[0],e=arguments[1];if(e.isEmpty())return jl.EXTERIOR;var n=e.getExteriorRing(),r=this.locateInPolygonRing(t,n);if(r===jl.EXTERIOR)return jl.EXTERIOR;if(r===jl.BOUNDARY)return jl.BOUNDARY;for(var i=0;i<e.getNumInteriorRing();i++){var o=e.getInteriorRingN(i),a=this.locateInPolygonRing(t,o);if(a===jl.INTERIOR)return jl.EXTERIOR;if(a===jl.BOUNDARY)return jl.BOUNDARY}return jl.INTERIOR}if(arguments[0]instanceof Bl&&arguments[1]instanceof Cc){var s=arguments[0],l=arguments[1];if(!l.getEnvelopeInternal().intersects(s))return jl.EXTERIOR;var u=l.getCoordinates();return l.isClosed()||!s.equals(u[0])&&!s.equals(u[u.length-1])?wu.isOnLine(s,u)?jl.INTERIOR:jl.EXTERIOR:jl.BOUNDARY}if(arguments[0]instanceof Bl&&arguments[1]instanceof Ac){var c=arguments[0];return arguments[1].getCoordinate().equals2D(c)?jl.INTERIOR:jl.EXTERIOR}},of.prototype.locateInPolygonRing=function(t,e){return e.getEnvelopeInternal().intersects(t)?wu.locatePointInRing(t,e.getCoordinates()):jl.EXTERIOR},of.prototype.intersects=function(t,e){return this.locate(t,e)!==jl.EXTERIOR},of.prototype.updateLocationInfo=function(t){t===jl.INTERIOR&&(this._isIn=!0),t===jl.BOUNDARY&&this._numBoundaries++},of.prototype.computeLocation=function(t,e){var n=this;if(e instanceof Ac&&this.updateLocationInfo(this.locateInternal(t,e)),e instanceof Cc)this.updateLocationInfo(this.locateInternal(t,e));else if(e instanceof Pc)this.updateLocationInfo(this.locateInternal(t,e));else if(e instanceof mc)for(var r=e,i=0;i<r.getNumGeometries();i++){var o=r.getGeometryN(i);n.updateLocationInfo(n.locateInternal(t,o))}else if(e instanceof Nc)for(var a=e,s=0;s<a.getNumGeometries();s++){var l=a.getGeometryN(s);n.updateLocationInfo(n.locateInternal(t,l))}else if(e instanceof dc)for(var u=new xp(e);u.hasNext();){var c=u.next();c!==e&&n.computeLocation(t,c)}},of.prototype.locate=function(t,e){return e.isEmpty()?jl.EXTERIOR:e instanceof Cc||e instanceof Pc?this.locateInternal(t,e):(this._isIn=!1,this._numBoundaries=0,this.computeLocation(t,e),this._boundaryRule.isInBoundary(this._numBoundaries)?jl.BOUNDARY:this._numBoundaries>0||this._isIn?jl.INTERIOR:jl.EXTERIOR)},of.prototype.interfaces_=function(){return[]},of.prototype.getClass=function(){return of};var af=function t(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length){t.call(this,arguments[0],t.INSIDE_AREA,arguments[1])}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];this._component=e,this._segIndex=n,this._pt=r}},sf={INSIDE_AREA:{configurable:!0}};af.prototype.isInsideArea=function(){return this._segIndex===af.INSIDE_AREA},af.prototype.getCoordinate=function(){return this._pt},af.prototype.getGeometryComponent=function(){return this._component},af.prototype.getSegmentIndex=function(){return this._segIndex},af.prototype.interfaces_=function(){return[]},af.prototype.getClass=function(){return af},sf.INSIDE_AREA.get=function(){return-1},Object.defineProperties(af,sf);var lf=function(t){this._pts=t||null};lf.prototype.filter=function(t){t instanceof Ac&&this._pts.add(t)},lf.prototype.interfaces_=function(){return[pc]},lf.prototype.getClass=function(){return lf},lf.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof Ac?Dh.singletonList(t):lf.getPoints(t,new Uu)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Ac?n.add(e):e instanceof dc&&e.apply(new lf(n)),n}};var uf=function(){this._locations=null;var t=arguments[0];this._locations=t};uf.prototype.filter=function(t){(t instanceof Ac||t instanceof Cc||t instanceof Pc)&&this._locations.add(new af(t,0,t.getCoordinate()))},uf.prototype.interfaces_=function(){return[pc]},uf.prototype.getClass=function(){return uf},uf.getLocations=function(t){var e=new Uu;return t.apply(new uf(e)),e};var cf=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new of,this._minDistanceLocation=null,this._minDistance=Dl.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];this._geom=[t,e],this._terminateDistance=0}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=n,this._geom[1]=r,this._terminateDistance=i}};cf.prototype.computeContainmentDistance=function(){var t=this;if(0===arguments.length){var e=new Array(2).fill(null);if(this.computeContainmentDistance(0,e),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,e)}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=1-n,o=nf.getPolygons(this._geom[n]);if(o.size()>0){var a=uf.getLocations(this._geom[i]);if(this.computeContainmentDistance(a,o,r),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[i]=r[0],this._minDistanceLocation[n]=r[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&ql(arguments[0],Fu)&&ql(arguments[1],Fu)){for(var s=arguments[0],l=arguments[1],u=arguments[2],c=0;c<s.size();c++)for(var h=s.get(c),p=0;p<l.size();p++)if(t.computeContainmentDistance(h,l.get(p),u),t._minDistance<=t._terminateDistance)return null}else if(arguments[2]instanceof Array&&arguments[0]instanceof af&&arguments[1]instanceof Pc){var f=arguments[0],d=arguments[1],m=arguments[2],g=f.getCoordinate();if(jl.EXTERIOR!==this._ptLocator.locate(g,d))return this._minDistance=0,m[0]=f,m[1]=new af(d,g),null}},cf.prototype.computeMinDistanceLinesPoints=function(t,e,n){for(var r=this,i=0;i<t.size();i++)for(var o=t.get(i),a=0;a<e.size();a++){var s=e.get(a);if(r.computeMinDistance(o,s,n),r._minDistance<=r._terminateDistance)return null}},cf.prototype.computeFacetDistance=function(){var t=new Array(2).fill(null),e=rf.getLines(this._geom[0]),n=rf.getLines(this._geom[1]),r=lf.getPoints(this._geom[0]),i=lf.getPoints(this._geom[1]);return this.computeMinDistanceLines(e,n,t),this.updateMinDistance(t,!1),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistanceLinesPoints(e,i,t),this.updateMinDistance(t,!1),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistanceLinesPoints(n,r,t),this.updateMinDistance(t,!0),this._minDistance<=this._terminateDistance?null:(t[0]=null,t[1]=null,this.computeMinDistancePoints(r,i,t),void this.updateMinDistance(t,!1))))},cf.prototype.nearestLocations=function(){return this.computeMinDistance(),this._minDistanceLocation},cf.prototype.updateMinDistance=function(t,e){if(null===t[0])return null;e?(this._minDistanceLocation[0]=t[1],this._minDistanceLocation[1]=t[0]):(this._minDistanceLocation[0]=t[0],this._minDistanceLocation[1]=t[1])},cf.prototype.nearestPoints=function(){return this.computeMinDistance(),[this._minDistanceLocation[0].getCoordinate(),this._minDistanceLocation[1].getCoordinate()]},cf.prototype.computeMinDistance=function(){var t=this;if(0===arguments.length){if(null!==this._minDistanceLocation)return null;if(this._minDistanceLocation=new Array(2).fill(null),this.computeContainmentDistance(),this._minDistance<=this._terminateDistance)return null;this.computeFacetDistance()}else if(3===arguments.length)if(arguments[2]instanceof Array&&arguments[0]instanceof Cc&&arguments[1]instanceof Ac){var e=arguments[0],n=arguments[1],r=arguments[2];if(e.getEnvelopeInternal().distance(n.getEnvelopeInternal())>this._minDistance)return null;for(var i=e.getCoordinates(),o=n.getCoordinate(),a=0;a<i.length-1;a++){var s=wu.distancePointLine(o,i[a],i[a+1]);if(s<t._minDistance){t._minDistance=s;var l=new Zh(i[a],i[a+1]).closestPoint(o);r[0]=new af(e,a,l),r[1]=new af(n,0,o)}if(t._minDistance<=t._terminateDistance)return null}}else if(arguments[2]instanceof Array&&arguments[0]instanceof Cc&&arguments[1]instanceof Cc){var u=arguments[0],c=arguments[1],h=arguments[2];if(u.getEnvelopeInternal().distance(c.getEnvelopeInternal())>this._minDistance)return null;for(var p=u.getCoordinates(),f=c.getCoordinates(),d=0;d<p.length-1;d++)for(var m=0;m<f.length-1;m++){var g=wu.distanceLineLine(p[d],p[d+1],f[m],f[m+1]);if(g<t._minDistance){t._minDistance=g;var y=new Zh(p[d],p[d+1]),v=new Zh(f[m],f[m+1]),_=y.closestPoints(v);h[0]=new af(u,d,_[0]),h[1]=new af(c,m,_[1])}if(t._minDistance<=t._terminateDistance)return null}}},cf.prototype.computeMinDistancePoints=function(t,e,n){for(var r=this,i=0;i<t.size();i++)for(var o=t.get(i),a=0;a<e.size();a++){var s=e.get(a),l=o.getCoordinate().distance(s.getCoordinate());if(l<r._minDistance&&(r._minDistance=l,n[0]=new af(o,0,o.getCoordinate()),n[1]=new af(s,0,s.getCoordinate())),r._minDistance<=r._terminateDistance)return null}},cf.prototype.distance=function(){if(null===this._geom[0]||null===this._geom[1])throw new Rl("null geometries are not supported");return this._geom[0].isEmpty()||this._geom[1].isEmpty()?0:(this.computeMinDistance(),this._minDistance)},cf.prototype.computeMinDistanceLines=function(t,e,n){for(var r=this,i=0;i<t.size();i++)for(var o=t.get(i),a=0;a<e.size();a++){var s=e.get(a);if(r.computeMinDistance(o,s,n),r._minDistance<=r._terminateDistance)return null}},cf.prototype.interfaces_=function(){return[]},cf.prototype.getClass=function(){return cf},cf.distance=function(t,e){return new cf(t,e).distance()},cf.isWithinDistance=function(t,e,n){return new cf(t,e,n).distance()<=n},cf.nearestPoints=function(t,e){return new cf(t,e).nearestPoints()};var hf=function(){this._pt=[new Bl,new Bl],this._distance=Dl.NaN,this._isNull=!0};hf.prototype.getCoordinates=function(){return this._pt},hf.prototype.getCoordinate=function(t){return this._pt[t]},hf.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);r<this._distance&&this.initialize(e,n,r)}},hf.prototype.initialize=function(){if(0===arguments.length)this._isNull=!0;else if(2===arguments.length){var t=arguments[0],e=arguments[1];this._pt[0].setCoordinate(t),this._pt[1].setCoordinate(e),this._distance=t.distance(e),this._isNull=!1}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this._pt[0].setCoordinate(n),this._pt[1].setCoordinate(r),this._distance=i,this._isNull=!1}},hf.prototype.toString=function(){return fu.toLineString(this._pt[0],this._pt[1])},hf.prototype.getDistance=function(){return this._distance},hf.prototype.setMaximum=function(){if(1===arguments.length){var t=arguments[0];this.setMaximum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);r>this._distance&&this.initialize(e,n,r)}},hf.prototype.interfaces_=function(){return[]},hf.prototype.getClass=function(){return hf};var pf=function(){};pf.prototype.interfaces_=function(){return[]},pf.prototype.getClass=function(){return pf},pf.computeDistance=function(){if(arguments[2]instanceof hf&&arguments[0]instanceof Cc&&arguments[1]instanceof Bl)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=new Zh,i=t.getCoordinates(),o=0;o<i.length-1;o++){r.setCoordinates(i[o],i[o+1]);var a=r.closestPoint(e);n.setMinimum(a,e)}else if(arguments[2]instanceof hf&&arguments[0]instanceof Pc&&arguments[1]instanceof Bl){var s=arguments[0],l=arguments[1],u=arguments[2];pf.computeDistance(s.getExteriorRing(),l,u);for(var c=0;c<s.getNumInteriorRing();c++)pf.computeDistance(s.getInteriorRingN(c),l,u)}else if(arguments[2]instanceof hf&&arguments[0]instanceof Mu&&arguments[1]instanceof Bl){var h=arguments[0],p=arguments[1],f=arguments[2];if(h instanceof Cc)pf.computeDistance(h,p,f);else if(h instanceof Pc)pf.computeDistance(h,p,f);else if(h instanceof dc)for(var d=h,m=0;m<d.getNumGeometries();m++){var g=d.getGeometryN(m);pf.computeDistance(g,p,f)}else f.setMinimum(h.getCoordinate(),p)}else if(arguments[2]instanceof hf&&arguments[0]instanceof Zh&&arguments[1]instanceof Bl){var y=arguments[1],v=arguments[2],_=arguments[0].closestPoint(y);v.setMinimum(_,y)}};var ff=function(){this._g0=null,this._g1=null,this._ptDist=new hf,this._densifyFrac=0;var t=arguments[0],e=arguments[1];this._g0=t,this._g1=e},df={MaxPointDistanceFilter:{configurable:!0},MaxDensifiedByFractionDistanceFilter:{configurable:!0}};ff.prototype.getCoordinates=function(){return this._ptDist.getCoordinates()},ff.prototype.setDensifyFraction=function(t){if(t>1||t<=0)throw new Rl("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},ff.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},ff.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},ff.prototype.computeOrientedDistance=function(t,e,n){var r=new mf(e);if(t.apply(r),n.setMaximum(r.getMaxPointDistance()),this._densifyFrac>0){var i=new gf(e,this._densifyFrac);t.apply(i),n.setMaximum(i.getMaxPointDistance())}},ff.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},ff.prototype.interfaces_=function(){return[]},ff.prototype.getClass=function(){return ff},ff.distance=function(){if(2===arguments.length){return new ff(arguments[0],arguments[1]).distance()}if(3===arguments.length){var t=arguments[2],e=new ff(arguments[0],arguments[1]);return e.setDensifyFraction(t),e.distance()}},df.MaxPointDistanceFilter.get=function(){return mf},df.MaxDensifiedByFractionDistanceFilter.get=function(){return gf},Object.defineProperties(ff,df);var mf=function(){this._maxPtDist=new hf,this._minPtDist=new hf,this._euclideanDist=new pf,this._geom=null;var t=arguments[0];this._geom=t};mf.prototype.filter=function(t){this._minPtDist.initialize(),pf.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},mf.prototype.getMaxPointDistance=function(){return this._maxPtDist},mf.prototype.interfaces_=function(){return[Iu]},mf.prototype.getClass=function(){return mf};var gf=function(){this._maxPtDist=new hf,this._minPtDist=new hf,this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))};gf.prototype.filter=function(t,e){var n=this;if(0===e)return null;for(var r=t.getCoordinate(e-1),i=t.getCoordinate(e),o=(i.x-r.x)/this._numSubSegs,a=(i.y-r.y)/this._numSubSegs,s=0;s<this._numSubSegs;s++){var l=r.x+s*o,u=r.y+s*a,c=new Bl(l,u);n._minPtDist.initialize(),pf.computeDistance(n._geom,c,n._minPtDist),n._maxPtDist.setMaximum(n._minPtDist)}},gf.prototype.isDone=function(){return!1},gf.prototype.isGeometryChanged=function(){return!1},gf.prototype.getMaxPointDistance=function(){return this._maxPtDist},gf.prototype.interfaces_=function(){return[fc]},gf.prototype.getClass=function(){return gf};var yf=function(t,e,n){this._minValidDistance=null,this._maxValidDistance=null,this._minDistanceFound=null,this._maxDistanceFound=null,this._isValid=!0,this._errMsg=null,this._errorLocation=null,this._errorIndicator=null,this._input=t||null,this._bufDistance=e||null,this._result=n||null},vf={VERBOSE:{configurable:!0},MAX_DISTANCE_DIFF_FRAC:{configurable:!0}};yf.prototype.checkMaximumDistance=function(t,e,n){var r=new ff(e,t);if(r.setDensifyFraction(.25),this._maxDistanceFound=r.orientedDistance(),this._maxDistanceFound>n){this._isValid=!1;var i=r.getCoordinates();this._errorLocation=i[1],this._errorIndicator=t.getFactory().createLineString(i),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+fu.toLineString(i[0],i[1])+")"}},yf.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=yf.MAX_DISTANCE_DIFF_FRAC*t;return this._minValidDistance=t-e,this._maxValidDistance=t+e,!(!this._input.isEmpty()&&!this._result.isEmpty())||(this._bufDistance>0?this.checkPositiveValid():this.checkNegativeValid(),yf.VERBOSE&&ou.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},yf.prototype.checkNegativeValid=function(){if(!(this._input instanceof Pc||this._input instanceof Nc||this._input instanceof dc))return null;var t=this.getPolygonLines(this._input);if(this.checkMinimumDistance(t,this._result,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(t,this._result,this._maxValidDistance)},yf.prototype.getErrorIndicator=function(){return this._errorIndicator},yf.prototype.checkMinimumDistance=function(t,e,n){var r=new cf(t,e,n);if(this._minDistanceFound=r.distance(),this._minDistanceFound<n){this._isValid=!1;var i=r.nearestPoints();this._errorLocation=r.nearestPoints()[1],this._errorIndicator=t.getFactory().createLineString(i),this._errMsg="Distance between buffer curve and input is too small ("+this._minDistanceFound+" at "+fu.toLineString(i[0],i[1])+" )"}},yf.prototype.checkPositiveValid=function(){var t=this._result.getBoundary();if(this.checkMinimumDistance(this._input,t,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(this._input,t,this._maxValidDistance)},yf.prototype.getErrorLocation=function(){return this._errorLocation},yf.prototype.getPolygonLines=function(t){for(var e=new Uu,n=new rf(e),r=nf.getPolygons(t).iterator();r.hasNext();)r.next().apply(n);return t.getFactory().buildGeometry(e)},yf.prototype.getErrorMessage=function(){return this._errMsg},yf.prototype.interfaces_=function(){return[]},yf.prototype.getClass=function(){return yf},vf.VERBOSE.get=function(){return!1},vf.MAX_DISTANCE_DIFF_FRAC.get=function(){return.012},Object.defineProperties(yf,vf);var _f=function(t,e,n){this._isValid=!0,this._errorMsg=null,this._errorLocation=null,this._errorIndicator=null,this._input=t||null,this._distance=e||null,this._result=n||null},xf={VERBOSE:{configurable:!0},MAX_ENV_DIFF_FRAC:{configurable:!0}};_f.prototype.isValid=function(){return this.checkPolygonal(),this._isValid?(this.checkExpectedEmpty(),this._isValid?(this.checkEnvelope(),this._isValid?(this.checkArea(),this._isValid?(this.checkDistance(),this._isValid):this._isValid):this._isValid):this._isValid):this._isValid},_f.prototype.checkEnvelope=function(){if(this._distance<0)return null;var t=this._distance*_f.MAX_ENV_DIFF_FRAC;0===t&&(t=.001);var e=new su(this._input.getEnvelopeInternal());e.expandBy(this._distance);var n=new su(this._result.getEnvelopeInternal());n.expandBy(t),n.contains(e)||(this._isValid=!1,this._errorMsg="Buffer envelope is incorrect",this._errorIndicator=this._input.getFactory().toGeometry(n)),this.report("Envelope")},_f.prototype.checkDistance=function(){var t=new yf(this._input,this._distance,this._result);t.isValid()||(this._isValid=!1,this._errorMsg=t.getErrorMessage(),this._errorLocation=t.getErrorLocation(),this._errorIndicator=t.getErrorIndicator()),this.report("Distance")},_f.prototype.checkArea=function(){var t=this._input.getArea(),e=this._result.getArea();this._distance>0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t<e&&(this._isValid=!1,this._errorMsg="Area of negative buffer is larger than input",this._errorIndicator=this._result),this.report("Area")},_f.prototype.checkPolygonal=function(){this._result instanceof Pc||this._result instanceof Nc||(this._isValid=!1),this._errorMsg="Result is not polygonal",this._errorIndicator=this._result,this.report("Polygonal")},_f.prototype.getErrorIndicator=function(){return this._errorIndicator},_f.prototype.getErrorLocation=function(){return this._errorLocation},_f.prototype.checkExpectedEmpty=function(){return this._input.getDimension()>=2||this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"))},_f.prototype.report=function(t){if(!_f.VERBOSE)return null;ou.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},_f.prototype.getErrorMessage=function(){return this._errorMsg},_f.prototype.interfaces_=function(){return[]},_f.prototype.getClass=function(){return _f},_f.isValidMsg=function(t,e,n){var r=new _f(t,e,n);return r.isValid()?null:r.getErrorMessage()},_f.isValid=function(t,e,n){return!!new _f(t,e,n).isValid()},xf.VERBOSE.get=function(){return!1},xf.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(_f,xf);var bf=function(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};bf.prototype.getCoordinates=function(){return this._pts},bf.prototype.size=function(){return this._pts.length},bf.prototype.getCoordinate=function(t){return this._pts[t]},bf.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},bf.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:Hh.octant(this.getCoordinate(t),this.getCoordinate(t+1))},bf.prototype.setData=function(t){this._data=t},bf.prototype.getData=function(){return this._data},bf.prototype.toString=function(){return fu.toLineString(new Uc(this._pts))},bf.prototype.interfaces_=function(){return[qh]},bf.prototype.getClass=function(){return bf};var wf=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new Uu,this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null};wf.prototype.getInteriorIntersection=function(){return this._interiorIntersection},wf.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},wf.prototype.getIntersectionSegments=function(){return this._intSegments},wf.prototype.count=function(){return this._intersectionCount},wf.prototype.getIntersections=function(){return this._intersections},wf.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},wf.prototype.setKeepIntersections=function(t){this._keepIntersections=t},wf.prototype.processIntersections=function(t,e,n,r){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===r)return null;if(this._isCheckEndSegmentsOnly&&!this.isEndSegment(t,e)&&!this.isEndSegment(n,r))return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=i,this._intSegments[1]=o,this._intSegments[2]=a,this._intSegments[3]=s,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)},wf.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2},wf.prototype.hasIntersection=function(){return null!==this._interiorIntersection},wf.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection},wf.prototype.interfaces_=function(){return[Cp]},wf.prototype.getClass=function(){return wf},wf.createAllIntersectionsFinder=function(t){var e=new wf(t);return e.setFindAllIntersections(!0),e},wf.createAnyIntersectionFinder=function(t){return new wf(t)},wf.createIntersectionCounter=function(t){var e=new wf(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var Ef=function(){this._li=new _u,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t};Ef.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},Ef.prototype.getIntersections=function(){return this._segInt.getIntersections()},Ef.prototype.isValid=function(){return this.execute(),this._isValid},Ef.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Ef.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new wf(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new ep;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},Ef.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new lh(this.getErrorMessage(),this._segInt.getInteriorIntersection())},Ef.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+fu.toLineString(t[0],t[1])+" and "+fu.toLineString(t[2],t[3])},Ef.prototype.interfaces_=function(){return[]},Ef.prototype.getClass=function(){return Ef},Ef.computeIntersections=function(t){var e=new Ef(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Sf=function t(){this._nv=null;var e=arguments[0];this._nv=new Ef(t.toSegmentStrings(e))};Sf.prototype.checkValid=function(){this._nv.checkValid()},Sf.prototype.interfaces_=function(){return[]},Sf.prototype.getClass=function(){return Sf},Sf.toSegmentStrings=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next();e.add(new bf(r.getCoordinates(),r))}return e},Sf.checkValid=function(t){new Sf(t).checkValid()};var Mf=function(t){this._mapOp=t};Mf.prototype.map=function(t){for(var e=new Uu,n=0;n<t.getNumGeometries();n++){var r=this._mapOp.map(t.getGeometryN(n));r.isEmpty()||e.add(r)}return t.getFactory().createGeometryCollection(Yc.toGeometryArray(e))},Mf.prototype.interfaces_=function(){return[]},Mf.prototype.getClass=function(){return Mf},Mf.map=function(t,e){return new Mf(e).map(t)};var Tf=function(){this._op=null,this._geometryFactory=null,this._ptLocator=null,this._lineEdgesList=new Uu,this._resultLineList=new Uu;var t=arguments[0],e=arguments[1],n=arguments[2];this._op=t,this._geometryFactory=e,this._ptLocator=n};Tf.prototype.collectLines=function(t){for(var e=this,n=this._op.getGraph().getEdgeEnds().iterator();n.hasNext();){var r=n.next();e.collectLineEdge(r,t,e._lineEdgesList),e.collectBoundaryTouchEdge(r,t,e._lineEdgesList)}},Tf.prototype.labelIsolatedLine=function(t,e){var n=this._ptLocator.locate(t.getCoordinate(),this._op.getArgGeometry(e));t.getLabel().setLocation(e,n)},Tf.prototype.build=function(t){return this.findCoveredLineEdges(),this.collectLines(t),this.buildLines(t),this._resultLineList},Tf.prototype.collectLineEdge=function(t,e,n){var r=t.getLabel(),i=t.getEdge();t.isLineEdge()&&(t.isVisited()||!ad.isResultOfOp(r,e)||i.isCovered()||(n.add(i),t.setVisitedEdge(!0)))},Tf.prototype.findCoveredLineEdges=function(){for(var t=this._op.getGraph().getNodes().iterator();t.hasNext();)t.next().getEdges().findCoveredLineEdges();for(var e=this._op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next(),r=n.getEdge();if(n.isLineEdge()&&!r.isCoveredSet()){var i=this._op.isCoveredByA(n.getCoordinate());r.setCovered(i)}}},Tf.prototype.labelIsolatedLines=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),r=n.getLabel();n.isIsolated()&&(r.isNull(0)?this.labelIsolatedLine(n,0):this.labelIsolatedLine(n,1))}},Tf.prototype.buildLines=function(t){for(var e=this._lineEdgesList.iterator();e.hasNext();){var n=e.next(),r=this._geometryFactory.createLineString(n.getCoordinates());this._resultLineList.add(r),n.setInResult(!0)}},Tf.prototype.collectBoundaryTouchEdge=function(t,e,n){var r=t.getLabel();return t.isLineEdge()||t.isVisited()||t.isInteriorAreaEdge()||t.getEdge().isInResult()?null:(gu.isTrue(!(t.isInResult()||t.getSym().isInResult())||!t.getEdge().isInResult()),void(ad.isResultOfOp(r,e)&&e===ad.INTERSECTION&&(n.add(t.getEdge()),t.setVisitedEdge(!0))))},Tf.prototype.interfaces_=function(){return[]},Tf.prototype.getClass=function(){return Tf};var Cf=function(){this._op=null,this._geometryFactory=null,this._resultPointList=new Uu;var t=arguments[0],e=arguments[1];this._op=t,this._geometryFactory=e};Cf.prototype.filterCoveredNodeToPoint=function(t){var e=t.getCoordinate();if(!this._op.isCoveredByLA(e)){var n=this._geometryFactory.createPoint(e);this._resultPointList.add(n)}},Cf.prototype.extractNonCoveredResultNodes=function(t){for(var e=this._op.getGraph().getNodes().iterator();e.hasNext();){var n=e.next();if(!(n.isInResult()||n.isIncidentEdgeInResult()||0!==n.getEdges().getDegree()&&t!==ad.INTERSECTION)){var r=n.getLabel();ad.isResultOfOp(r,t)&&this.filterCoveredNodeToPoint(n)}}},Cf.prototype.build=function(t){return this.extractNonCoveredResultNodes(t),this._resultPointList},Cf.prototype.interfaces_=function(){return[]},Cf.prototype.getClass=function(){return Cf};var If=function(){this._inputGeom=null,this._factory=null,this._pruneEmptyGeometry=!0,this._preserveGeometryCollectionType=!0,this._preserveCollections=!1,this._preserveType=!1};If.prototype.transformPoint=function(t,e){return this._factory.createPoint(this.transformCoordinates(t.getCoordinateSequence(),t))},If.prototype.transformPolygon=function(t,e){var n=!0,r=this.transformLinearRing(t.getExteriorRing(),t);null!==r&&r instanceof Dc&&!r.isEmpty()||(n=!1);for(var i=new Uu,o=0;o<t.getNumInteriorRing();o++){var a=this.transformLinearRing(t.getInteriorRingN(o),t);null===a||a.isEmpty()||(a instanceof Dc||(n=!1),i.add(a))}if(n)return this._factory.createPolygon(r,i.toArray([]));var s=new Uu;return null!==r&&s.add(r),s.addAll(i),this._factory.buildGeometry(s)},If.prototype.createCoordinateSequence=function(t){return this._factory.getCoordinateSequenceFactory().create(t)},If.prototype.getInputGeometry=function(){return this._inputGeom},If.prototype.transformMultiLineString=function(t,e){for(var n=new Uu,r=0;r<t.getNumGeometries();r++){var i=this.transformLineString(t.getGeometryN(r),t);null!==i&&(i.isEmpty()||n.add(i))}return this._factory.buildGeometry(n)},If.prototype.transformCoordinates=function(t,e){return this.copy(t)},If.prototype.transformLineString=function(t,e){return this._factory.createLineString(this.transformCoordinates(t.getCoordinateSequence(),t))},If.prototype.transformMultiPoint=function(t,e){for(var n=new Uu,r=0;r<t.getNumGeometries();r++){var i=this.transformPoint(t.getGeometryN(r),t);null!==i&&(i.isEmpty()||n.add(i))}return this._factory.buildGeometry(n)},If.prototype.transformMultiPolygon=function(t,e){for(var n=new Uu,r=0;r<t.getNumGeometries();r++){var i=this.transformPolygon(t.getGeometryN(r),t);null!==i&&(i.isEmpty()||n.add(i))}return this._factory.buildGeometry(n)},If.prototype.copy=function(t){return t.copy()},If.prototype.transformGeometryCollection=function(t,e){for(var n=new Uu,r=0;r<t.getNumGeometries();r++){var i=this.transform(t.getGeometryN(r));null!==i&&(this._pruneEmptyGeometry&&i.isEmpty()||n.add(i))}return this._preserveGeometryCollectionType?this._factory.createGeometryCollection(Yc.toGeometryArray(n)):this._factory.buildGeometry(n)},If.prototype.transform=function(t){if(this._inputGeom=t,this._factory=t.getFactory(),t instanceof Ac)return this.transformPoint(t,null);if(t instanceof Rc)return this.transformMultiPoint(t,null);if(t instanceof Dc)return this.transformLinearRing(t,null);if(t instanceof Cc)return this.transformLineString(t,null);if(t instanceof mc)return this.transformMultiLineString(t,null);if(t instanceof Pc)return this.transformPolygon(t,null);if(t instanceof Nc)return this.transformMultiPolygon(t,null);if(t instanceof dc)return this.transformGeometryCollection(t,null);throw new Rl("Unknown Geometry subtype: "+t.getClass().getName())},If.prototype.transformLinearRing=function(t,e){var n=this.transformCoordinates(t.getCoordinateSequence(),t);if(null===n)return this._factory.createLinearRing(null);var r=n.size();return r>0&&r<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)},If.prototype.interfaces_=function(){return[]},If.prototype.getClass=function(){return If};var Af=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new Zh,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Cc&&"number"==typeof arguments[1]){var e=arguments[1];t.call(this,arguments[0].getCoordinates(),e)}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1];this._srcPts=n,this._isClosed=t.isClosed(n),this._snapTolerance=r}};Af.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),r=0;r<n;r++){var i=t.get(r),o=this.findSnapForVertex(i,e);null!==o&&(t.set(r,new Bl(o)),0===r&&this._isClosed&&t.set(t.size()-1,new Bl(o)))}},Af.prototype.findSnapForVertex=function(t,e){for(var n=0;n<e.length;n++){if(t.equals2D(e[n]))return null;if(t.distance(e[n])<this._snapTolerance)return e[n]}return null},Af.prototype.snapTo=function(t){var e=new Gu(this._srcPts);return this.snapVertices(e,t),this.snapSegments(e,t),e.toCoordinateArray()},Af.prototype.snapSegments=function(t,e){if(0===e.length)return null;var n=e.length;e[0].equals2D(e[e.length-1])&&(n=e.length-1);for(var r=0;r<n;r++){var i=e[r],o=this.findSegmentIndexToSnap(i,t);o>=0&&t.add(o+1,new Bl(i),!1)}},Af.prototype.findSegmentIndexToSnap=function(t,e){for(var n=this,r=Dl.MAX_VALUE,i=-1,o=0;o<e.size()-1;o++){if(n._seg.p0=e.get(o),n._seg.p1=e.get(o+1),n._seg.p0.equals2D(t)||n._seg.p1.equals2D(t)){if(n._allowSnappingToSourceVertices)continue;return-1}var a=n._seg.distance(t);a<n._snapTolerance&&a<r&&(r=a,i=o)}return i},Af.prototype.setAllowSnappingToSourceVertices=function(t){this._allowSnappingToSourceVertices=t},Af.prototype.interfaces_=function(){return[]},Af.prototype.getClass=function(){return Af},Af.isClosed=function(t){return!(t.length<=1)&&t[0].equals2D(t[t.length-1])};var Lf=function(t){this._srcGeom=t||null},Pf={SNAP_PRECISION_FACTOR:{configurable:!0}};Lf.prototype.snapTo=function(t,e){var n=this.extractTargetCoordinates(t);return new Rf(e,n).transform(this._srcGeom)},Lf.prototype.snapToSelf=function(t,e){var n=this.extractTargetCoordinates(this._srcGeom),r=new Rf(t,n,!0).transform(this._srcGeom),i=r;return e&&ql(i,Lc)&&(i=r.buffer(0)),i},Lf.prototype.computeSnapTolerance=function(t){return this.computeMinimumSegmentLength(t)/10},Lf.prototype.extractTargetCoordinates=function(t){for(var e=new sc,n=t.getCoordinates(),r=0;r<n.length;r++)e.add(n[r]);return e.toArray(new Array(0).fill(null))},Lf.prototype.computeMinimumSegmentLength=function(t){for(var e=Dl.MAX_VALUE,n=0;n<t.length-1;n++){var r=t[n].distance(t[n+1]);r<e&&(e=r)}return e},Lf.prototype.interfaces_=function(){return[]},Lf.prototype.getClass=function(){return Lf},Lf.snap=function(t,e,n){var r=new Array(2).fill(null),i=new Lf(t);r[0]=i.snapTo(e,n);var o=new Lf(e);return r[1]=o.snapTo(r[0],n),r},Lf.computeOverlaySnapTolerance=function(){if(1===arguments.length){var t=arguments[0],e=Lf.computeSizeBasedSnapTolerance(t),n=t.getPrecisionModel();if(n.getType()===qc.FIXED){var r=1/n.getScale()*2/1.415;r>e&&(e=r)}return e}if(2===arguments.length){var i=arguments[0],o=arguments[1];return Math.min(Lf.computeOverlaySnapTolerance(i),Lf.computeOverlaySnapTolerance(o))}},Lf.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*Lf.SNAP_PRECISION_FACTOR},Lf.snapToSelf=function(t,e,n){return new Lf(t).snapToSelf(e,n)},Pf.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Lf,Pf);var Rf=function(t){function e(e,n,r){t.call(this),this._snapTolerance=e||null,this._snapPts=n||null,this._isSelfSnap=void 0!==r&&r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var n=new Af(t,this._snapTolerance);return n.setAllowSnappingToSourceVertices(this._isSelfSnap),n.snapTo(e)},e.prototype.transformCoordinates=function(t,e){var n=t.toCoordinateArray(),r=this.snapLine(n,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(If),Df=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};Df.prototype.getCommon=function(){return Dl.longBitsToDouble(this._commonBits)},Df.prototype.add=function(t){var e=Dl.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=Df.signExpBits(this._commonBits),this._isFirst=!1,null):Df.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=Df.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=Df.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))))},Df.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=Dl.longBitsToDouble(t),n="0000000000000000000000000000000000000000000000000000000000000000"+Dl.toBinaryString(t),r=n.substring(n.length-64);return r.substring(0,1)+" "+r.substring(1,12)+"(exp) "+r.substring(12)+" [ "+e+" ]"}},Df.prototype.interfaces_=function(){return[]},Df.prototype.getClass=function(){return Df},Df.getBit=function(t,e){return 0!=(t&1<<e)?1:0},Df.signExpBits=function(t){return t>>52},Df.zeroLowerBits=function(t,e){return t&~((1<<e)-1)},Df.numCommonMostSigMantissaBits=function(t,e){for(var n=0,r=52;r>=0;r--){if(Df.getBit(t,r)!==Df.getBit(e,r))return n;n++}return 52};var Nf=function(){this._commonCoord=null,this._ccFilter=new kf},Of={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};Nf.prototype.addCommonBits=function(t){var e=new zf(this._commonCoord);t.apply(e),t.geometryChanged()},Nf.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new Bl(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new zf(e);return t.apply(n),t.geometryChanged(),t},Nf.prototype.getCommonCoordinate=function(){return this._commonCoord},Nf.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},Nf.prototype.interfaces_=function(){return[]},Nf.prototype.getClass=function(){return Nf},Of.CommonCoordinateFilter.get=function(){return kf},Of.Translater.get=function(){return zf},Object.defineProperties(Nf,Of);var kf=function(){this._commonBitsX=new Df,this._commonBitsY=new Df};kf.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},kf.prototype.getCommonCoordinate=function(){return new Bl(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},kf.prototype.interfaces_=function(){return[Iu]},kf.prototype.getClass=function(){return kf};var zf=function(){this.trans=null;var t=arguments[0];this.trans=t};zf.prototype.filter=function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,r=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,r)},zf.prototype.isDone=function(){return!1},zf.prototype.isGeometryChanged=function(){return!0},zf.prototype.interfaces_=function(){return[fc]},zf.prototype.getClass=function(){return zf};var Ff=function(t,e){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null,this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance()};Ff.prototype.selfSnap=function(t){return new Lf(t).snapTo(t,this._snapTolerance)},Ff.prototype.removeCommonBits=function(t){this._cbr=new Nf,this._cbr.add(t[0]),this._cbr.add(t[1]);var e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e},Ff.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},Ff.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=ad.overlayOp(e[0],e[1],t);return this.prepareResult(n)},Ff.prototype.checkValid=function(t){t.isValid()||ou.out.println("Snapped geometry is invalid")},Ff.prototype.computeSnapTolerance=function(){this._snapTolerance=Lf.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},Ff.prototype.snap=function(t){var e=this.removeCommonBits(t);return Lf.snap(e[0],e[1],this._snapTolerance)},Ff.prototype.interfaces_=function(){return[]},Ff.prototype.getClass=function(){return Ff},Ff.overlayOp=function(t,e,n){return new Ff(t,e).getResultGeometry(n)},Ff.union=function(t,e){return Ff.overlayOp(t,e,ad.UNION)},Ff.intersection=function(t,e){return Ff.overlayOp(t,e,ad.INTERSECTION)},Ff.symDifference=function(t,e){return Ff.overlayOp(t,e,ad.SYMDIFFERENCE)},Ff.difference=function(t,e){return Ff.overlayOp(t,e,ad.DIFFERENCE)};var Bf=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};Bf.prototype.getResultGeometry=function(t){var e=null,n=!1,r=null;try{e=ad.overlayOp(this._geom[0],this._geom[1],t);n=!0}catch(t){if(!(t instanceof du))throw t;r=t}if(!n)try{e=Ff.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof du?r:t}return e},Bf.prototype.interfaces_=function(){return[]},Bf.prototype.getClass=function(){return Bf},Bf.overlayOp=function(t,e,n){return new Bf(t,e).getResultGeometry(n)},Bf.union=function(t,e){return Bf.overlayOp(t,e,ad.UNION)},Bf.intersection=function(t,e){return Bf.overlayOp(t,e,ad.INTERSECTION)},Bf.symDifference=function(t,e){return Bf.overlayOp(t,e,ad.SYMDIFFERENCE)},Bf.difference=function(t,e){return Bf.overlayOp(t,e,ad.DIFFERENCE)};var Uf=function(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e};Uf.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},Uf.prototype.interfaces_=function(){return[]},Uf.prototype.getClass=function(){return Uf};var Vf=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=r,this._xValue=i,this._obj=o}},Gf={INSERT:{configurable:!0},DELETE:{configurable:!0}};Vf.prototype.isDelete=function(){return this._eventType===Vf.DELETE},Vf.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},Vf.prototype.getObject=function(){return this._obj},Vf.prototype.compareTo=function(t){var e=t;return this._xValue<e._xValue?-1:this._xValue>e._xValue?1:this._eventType<e._eventType?-1:this._eventType>e._eventType?1:0},Vf.prototype.getInsertEvent=function(){return this._insertEvent},Vf.prototype.isInsert=function(){return this._eventType===Vf.INSERT},Vf.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label},Vf.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},Vf.prototype.interfaces_=function(){return[Ol]},Vf.prototype.getClass=function(){return Vf},Gf.INSERT.get=function(){return 1},Gf.DELETE.get=function(){return 2},Object.defineProperties(Vf,Gf);var jf=function(){};jf.prototype.interfaces_=function(){return[]},jf.prototype.getClass=function(){return jf};var Hf=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=n};Hf.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(Hf.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.getNumPoints()-1;if(0===e&&r===i||0===r&&e===i)return!0}}return!1},Hf.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Hf.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},Hf.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Hf.prototype.isBoundaryPointInternal=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next().getCoordinate();if(t.isIntersection(r))return!0}return!1},Hf.prototype.hasProperIntersection=function(){return this._hasProper},Hf.prototype.hasIntersection=function(){return this._hasIntersection},Hf.prototype.isDone=function(){return this._isDone},Hf.prototype.isBoundaryPoint=function(t,e){return!(null===e||!this.isBoundaryPointInternal(t,e[0])&&!this.isBoundaryPointInternal(t,e[1]))},Hf.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},Hf.prototype.addIntersections=function(t,e,n,r){if(t===n&&e===r)return null;this.numTests++;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,n,r)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))))},Hf.prototype.interfaces_=function(){return[]},Hf.prototype.getClass=function(){return Hf},Hf.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var qf=function(t){function e(){t.call(this),this.events=new Uu,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){Dh.sort(this.events);for(var t=0;t<this.events.size();t++){var e=this.events.get(t);e.isDelete()&&e.getInsertEvent().setDeleteEventIndex(t)}},e.prototype.computeIntersections=function(){if(1===arguments.length){var t=arguments[0];this.nOverlaps=0,this.prepareEvents();for(var e=0;e<this.events.size();e++){var n=this.events.get(e);if(n.isInsert()&&this.processOverlaps(e,n.getDeleteEventIndex(),n,t),t.isDone())break}}else if(3===arguments.length)if(arguments[2]instanceof Hf&&ql(arguments[0],Fu)&&ql(arguments[1],Fu)){var r=arguments[0],i=arguments[1],o=arguments[2];this.addEdges(r,r),this.addEdges(i,i),this.computeIntersections(o)}else if("boolean"==typeof arguments[2]&&ql(arguments[0],Fu)&&arguments[1]instanceof Hf){var a=arguments[0],s=arguments[1];arguments[2]?this.addEdges(a,null):this.addEdges(a),this.computeIntersections(s)}},e.prototype.addEdge=function(t,e){for(var n=t.getMonotoneChainEdge(),r=n.getStartIndexes(),i=0;i<r.length-1;i++){var o=new Uf(n,i),a=new Vf(e,n.getMinX(i),o);this.events.add(a),this.events.add(new Vf(n.getMaxX(i),a))}},e.prototype.processOverlaps=function(t,e,n,r){for(var i=n.getObject(),o=t;o<e;o++){var a=this.events.get(o);if(a.isInsert()){var s=a.getObject();n.isSameLabel(a)||(i.computeIntersections(s,r),this.nOverlaps++)}}},e.prototype.addEdges=function(){if(1===arguments.length)for(var t=arguments[0].iterator();t.hasNext();){var e=t.next();this.addEdge(e,e)}else if(2===arguments.length)for(var n=arguments[1],r=arguments[0].iterator();r.hasNext();){var i=r.next();this.addEdge(i,n)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(jf),Wf=function(){this._min=Dl.POSITIVE_INFINITY,this._max=Dl.NEGATIVE_INFINITY},Xf={NodeComparator:{configurable:!0}};Wf.prototype.getMin=function(){return this._min},Wf.prototype.intersects=function(t,e){return!(this._min>e||this._max<t)},Wf.prototype.getMax=function(){return this._max},Wf.prototype.toString=function(){return fu.toLineString(new Bl(this._min,0),new Bl(this._max,0))},Wf.prototype.interfaces_=function(){return[]},Wf.prototype.getClass=function(){return Wf},Xf.NodeComparator.get=function(){return Zf},Object.defineProperties(Wf,Xf);var Zf=function(){};Zf.prototype.compare=function(t,e){var n=t,r=e,i=(n._min+n._max)/2,o=(r._min+r._max)/2;return i<o?-1:i>o?1:0},Zf.prototype.interfaces_=function(){return[zl]},Zf.prototype.getClass=function(){return Zf};var Yf=function(t){function e(){t.call(this),this._item=null;var e=arguments[0],n=arguments[1],r=arguments[2];this._min=e,this._max=n,this._item=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;n.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Wf),Jf=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[0],n=arguments[1];this._node1=e,this._node2=n,this.buildExtent(this._node1,this._node2)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildExtent=function(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max)},e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,n),null!==this._node2&&this._node2.query(t,e,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Wf),Kf=function(){this._leaves=new Uu,this._root=null,this._level=0};Kf.prototype.buildTree=function(){Dh.sort(this._leaves,new Wf.NodeComparator);for(var t=this._leaves,e=null,n=new Uu;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},Kf.prototype.insert=function(t,e,n){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new Yf(t,e,n))},Kf.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n)},Kf.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree()},Kf.prototype.printNode=function(t){ou.out.println(fu.toLineString(new Bl(t._min,this._level),new Bl(t._max,this._level)))},Kf.prototype.init=function(){if(null!==this._root)return null;this.buildRoot()},Kf.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n<t.size();n+=2){var r=t.get(n);if(null===(n+1<t.size()?t.get(n):null))e.add(r);else{var i=new Jf(t.get(n),t.get(n+1));e.add(i)}}},Kf.prototype.interfaces_=function(){return[]},Kf.prototype.getClass=function(){return Kf};var Qf=function(){this._items=new Uu};Qf.prototype.visitItem=function(t){this._items.add(t)},Qf.prototype.getItems=function(){return this._items},Qf.prototype.interfaces_=function(){return[Ah]},Qf.prototype.getClass=function(){return Qf};var $f=function(){this._index=null;var t=arguments[0];if(!ql(t,Lc))throw new Rl("Argument must be Polygonal");this._index=new nd(t)},td={SegmentVisitor:{configurable:!0},IntervalIndexedGeometry:{configurable:!0}};$f.prototype.locate=function(t){var e=new bu(t),n=new ed(e);return this._index.query(t.y,t.y,n),e.getLocation()},$f.prototype.interfaces_=function(){return[_p]},$f.prototype.getClass=function(){return $f},td.SegmentVisitor.get=function(){return ed},td.IntervalIndexedGeometry.get=function(){return nd},Object.defineProperties($f,td);var ed=function(){this._counter=null;var t=arguments[0];this._counter=t};ed.prototype.visitItem=function(t){var e=t;this._counter.countSegment(e.getCoordinate(0),e.getCoordinate(1))},ed.prototype.interfaces_=function(){return[Ah]},ed.prototype.getClass=function(){return ed};var nd=function(){this._index=new Kf;var t=arguments[0];this.init(t)};nd.prototype.init=function(t){for(var e=rf.getLines(t).iterator();e.hasNext();){var n=e.next().getCoordinates();this.addLine(n)}},nd.prototype.addLine=function(t){for(var e=1;e<t.length;e++){var n=new Zh(t[e-1],t[e]),r=Math.min(n.p0.y,n.p1.y),i=Math.max(n.p0.y,n.p1.y);this._index.insert(r,i,n)}},nd.prototype.query=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new Qf;return this._index.query(t,e,n),n.getItems()}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._index.query(r,i,o)}},nd.prototype.interfaces_=function(){return[]},nd.prototype.getClass=function(){return nd};var rd=function(t){function e(){if(t.call(this),this._parentGeom=null,this._lineEdgeMap=new Hc,this._boundaryNodeRule=null,this._useBoundaryDeterminationRule=!0,this._argIndex=null,this._boundaryNodes=null,this._hasTooFewPoints=!1,this._invalidPoint=null,this._areaPtLocator=null,this._ptLocator=new of,2===arguments.length){var e=arguments[0],n=arguments[1],r=Au.OGC_SFS_BOUNDARY_RULE;this._argIndex=e,this._parentGeom=n,this._boundaryNodeRule=r,null!==n&&this.add(n)}else if(3===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2];this._argIndex=i,this._parentGeom=o,this._boundaryNodeRule=a,null!==o&&this.add(o)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.insertBoundaryPoint=function(t,n){var r=this._nodes.addNode(n).getLabel(),i=1;r.getLocation(t,rh.ON)===jl.BOUNDARY&&i++;var o=e.determineBoundary(this._boundaryNodeRule,i);r.setLocation(t,o)},e.prototype.computeSelfNodes=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.computeSelfNodes(t,e,!1)}if(3===arguments.length){var n=arguments[1],r=arguments[2],i=new Hf(arguments[0],!0,!1);i.setIsDoneIfProperInt(r);var o=this.createEdgeSetIntersector(),a=this._parentGeom instanceof Dc||this._parentGeom instanceof Pc||this._parentGeom instanceof Nc,s=n||!a;return o.computeIntersections(this._edges,i,s),this.addSelfIntersectionNodes(this._argIndex),i}},e.prototype.computeSplitEdges=function(t){for(var e=this._edges.iterator();e.hasNext();)e.next().eiList.addSplitEdges(t)},e.prototype.computeEdgeIntersections=function(t,e,n){var r=new Hf(e,n,!0);return r.setBoundaryNodes(this.getBoundaryNodes(),t.getBoundaryNodes()),this.createEdgeSetIntersector().computeIntersections(this._edges,t._edges,r),r},e.prototype.getGeometry=function(){return this._parentGeom},e.prototype.getBoundaryNodeRule=function(){return this._boundaryNodeRule},e.prototype.hasTooFewPoints=function(){return this._hasTooFewPoints},e.prototype.addPoint=function(){if(arguments[0]instanceof Ac){var t=arguments[0].getCoordinate();this.insertPoint(this._argIndex,t,jl.INTERIOR)}else if(arguments[0]instanceof Bl){var e=arguments[0];this.insertPoint(this._argIndex,e,jl.INTERIOR)}},e.prototype.addPolygon=function(t){this.addPolygonRing(t.getExteriorRing(),jl.EXTERIOR,jl.INTERIOR);for(var e=0;e<t.getNumInteriorRing();e++){var n=t.getInteriorRingN(e);this.addPolygonRing(n,jl.INTERIOR,jl.EXTERIOR)}},e.prototype.addEdge=function(t){this.insertEdge(t);var e=t.getCoordinates();this.insertPoint(this._argIndex,e[0],jl.BOUNDARY),this.insertPoint(this._argIndex,e[e.length-1],jl.BOUNDARY)},e.prototype.addLineString=function(t){var e=ju.removeRepeatedPoints(t.getCoordinates());if(e.length<2)return this._hasTooFewPoints=!0,this._invalidPoint=e[0],null;var n=new Op(e,new ph(this._argIndex,jl.INTERIOR));this._lineEdgeMap.put(t,n),this.insertEdge(n),gu.isTrue(e.length>=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1])},e.prototype.getInvalidPoint=function(){return this._invalidPoint},e.prototype.getBoundaryPoints=function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,r=t.iterator();r.hasNext();){var i=r.next();e[n++]=i.getCoordinate().copy()}return e},e.prototype.getBoundaryNodes=function(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes},e.prototype.addSelfIntersectionNode=function(t,e,n){if(this.isBoundaryNode(t,e))return null;n===jl.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n)},e.prototype.addPolygonRing=function(t,e,n){if(t.isEmpty())return null;var r=ju.removeRepeatedPoints(t.getCoordinates());if(r.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=r[0],null;var i=e,o=n;wu.isCCW(r)&&(i=n,o=e);var a=new Op(r,new ph(this._argIndex,jl.BOUNDARY,i,o));this._lineEdgeMap.put(t,a),this.insertEdge(a),this.insertPoint(this._argIndex,r[0],jl.BOUNDARY)},e.prototype.insertPoint=function(t,e,n){var r=this._nodes.addNode(e),i=r.getLabel();null===i?r._label=new ph(t,n):i.setLocation(t,n)},e.prototype.createEdgeSetIntersector=function(){return new qf},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var n=e.next(),r=n.getLabel().getLocation(t),i=n.eiList.iterator();i.hasNext();){var o=i.next();this.addSelfIntersectionNode(t,o.coord,r)}},e.prototype.add=function(){if(1!==arguments.length)return t.prototype.add.apply(this,arguments);var e=arguments[0];if(e.isEmpty())return null;if(e instanceof Nc&&(this._useBoundaryDeterminationRule=!1),e instanceof Pc)this.addPolygon(e);else if(e instanceof Cc)this.addLineString(e);else if(e instanceof Ac)this.addPoint(e);else if(e instanceof Rc)this.addCollection(e);else if(e instanceof mc)this.addCollection(e);else if(e instanceof Nc)this.addCollection(e);else{if(!(e instanceof dc))throw new Error(e.getClass().getName());this.addCollection(e)}},e.prototype.addCollection=function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}},e.prototype.locate=function(t){return ql(this._parentGeom,Lc)&&this._parentGeom.getNumGeometries()>50?(null===this._areaPtLocator&&(this._areaPtLocator=new $f(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom)},e.prototype.findEdge=function(){if(1===arguments.length){var e=arguments[0];return this._lineEdgeMap.get(e)}return t.prototype.findEdge.apply(this,arguments)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.determineBoundary=function(t,e){return t.isInBoundary(e)?jl.BOUNDARY:jl.INTERIOR},e}(Sh),id=function(){if(this._li=new _u,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new rd(0,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=Au.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new rd(0,e,r),this._arg[1]=new rd(1,n,r)}else if(3===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2];i.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new rd(0,i,a),this._arg[1]=new rd(1,o,a)}};id.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},id.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},id.prototype.interfaces_=function(){return[]},id.prototype.getClass=function(){return id};var od=function(){};od.prototype.interfaces_=function(){return[]},od.prototype.getClass=function(){return od},od.map=function(){if(arguments[0]instanceof Mu&&ql(arguments[1],od.MapOp)){for(var t=arguments[0],e=arguments[1],n=new Uu,r=0;r<t.getNumGeometries();r++){var i=e.map(t.getGeometryN(r));null!==i&&n.add(i)}return t.getFactory().buildGeometry(n)}if(ql(arguments[0],Ou)&&ql(arguments[1],od.MapOp)){for(var o=arguments[0],a=arguments[1],s=new Uu,l=o.iterator();l.hasNext();){var u=l.next(),c=a.map(u);null!==c&&s.add(c)}return s}},od.MapOp=function(){};var ad=function(t){function e(){var e=arguments[0],n=arguments[1];t.call(this,e,n),this._ptLocator=new of,this._geomFact=null,this._resultGeom=null,this._graph=null,this._edgeList=new Tp,this._resultPolyList=new Uu,this._resultLineList=new Uu,this._resultPointList=new Uu,this._graph=new Sh(new Sp),this._geomFact=e.getFactory()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.insertUniqueEdge=function(t){var e=this._edgeList.findEqualEdge(t);if(null!==e){var n=e.getLabel(),r=t.getLabel();e.isPointwiseEqual(t)||(r=new ph(t.getLabel())).flip();var i=e.getDepth();i.isNull()&&i.add(n),i.add(r),n.merge(r)}else this._edgeList.add(t)},e.prototype.getGraph=function(){return this._graph},e.prototype.cancelDuplicateResultEdges=function(){for(var t=this._graph.getEdgeEnds().iterator();t.hasNext();){var e=t.next(),n=e.getSym();e.isInResult()&&n.isInResult()&&(e.setInResult(!1),n.setInResult(!1))}},e.prototype.isCoveredByLA=function(t){return!!this.isCovered(t,this._resultLineList)||!!this.isCovered(t,this._resultPolyList)},e.prototype.computeGeometry=function(t,n,r,i){var o=new Uu;return o.addAll(t),o.addAll(n),o.addAll(r),o.isEmpty()?e.createEmptyResult(i,this._arg[0].getGeometry(),this._arg[1].getGeometry(),this._geomFact):this._geomFact.buildGeometry(o)},e.prototype.mergeSymLabels=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();)t.next().getEdges().mergeSymLabels()},e.prototype.isCovered=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();if(this._ptLocator.locate(t,r)!==jl.EXTERIOR)return!0}return!1},e.prototype.replaceCollapsedEdges=function(){for(var t=new Uu,e=this._edgeList.iterator();e.hasNext();){var n=e.next();n.isCollapsed()&&(e.remove(),t.add(n.getCollapsedEdge()))}this._edgeList.addAll(t)},e.prototype.updateNodeLabelling=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();){var e=t.next(),n=e.getEdges().getLabel();e.getLabel().merge(n)}},e.prototype.getResultGeometry=function(t){return this.computeOverlay(t),this._resultGeom},e.prototype.insertUniqueEdges=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.insertUniqueEdge(n)}},e.prototype.computeOverlay=function(t){this.copyPoints(0),this.copyPoints(1),this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1),this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!0);var e=new Uu;this._arg[0].computeSplitEdges(e),this._arg[1].computeSplitEdges(e),this.insertUniqueEdges(e),this.computeLabelsFromDepths(),this.replaceCollapsedEdges(),Sf.checkValid(this._edgeList.getEdges()),this._graph.addEdges(this._edgeList.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(t),this.cancelDuplicateResultEdges();var n=new Mh(this._geomFact);n.add(this._graph),this._resultPolyList=n.getPolygons();var r=new Tf(this,this._geomFact,this._ptLocator);this._resultLineList=r.build(t);var i=new Cf(this,this._geomFact,this._ptLocator);this._resultPointList=i.build(t),this._resultGeom=this.computeGeometry(this._resultPointList,this._resultLineList,this._resultPolyList,t)},e.prototype.labelIncompleteNode=function(t,e){var n=this._ptLocator.locate(t.getCoordinate(),this._arg[e].getGeometry());t.getLabel().setLocation(e,n)},e.prototype.copyPoints=function(t){for(var e=this._arg[t].getNodeIterator();e.hasNext();){var n=e.next();this._graph.addNode(n.getCoordinate()).setLabel(t,n.getLabel().getLocation(t))}},e.prototype.findResultAreaEdges=function(t){for(var n=this._graph.getEdgeEnds().iterator();n.hasNext();){var r=n.next(),i=r.getLabel();i.isArea()&&!r.isInteriorAreaEdge()&&e.isResultOfOp(i.getLocation(0,rh.RIGHT),i.getLocation(1,rh.RIGHT),t)&&r.setInResult(!0)}},e.prototype.computeLabelsFromDepths=function(){for(var t=this._edgeList.iterator();t.hasNext();){var e=t.next(),n=e.getLabel(),r=e.getDepth();if(!r.isNull()){r.normalize();for(var i=0;i<2;i++)n.isNull(i)||!n.isArea()||r.isNull(i)||(0===r.getDelta(i)?n.toLine(i):(gu.isTrue(!r.isNull(i,rh.LEFT),"depth of LEFT side has not been initialized"),n.setLocation(i,rh.LEFT,r.getLocation(i,rh.LEFT)),gu.isTrue(!r.isNull(i,rh.RIGHT),"depth of RIGHT side has not been initialized"),n.setLocation(i,rh.RIGHT,r.getLocation(i,rh.RIGHT))))}}},e.prototype.computeLabelling=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();)t.next().getEdges().computeLabelling(this._arg);this.mergeSymLabels(),this.updateNodeLabelling()},e.prototype.labelIncompleteNodes=function(){for(var t=this._graph.getNodes().iterator();t.hasNext();){var e=t.next(),n=e.getLabel();e.isIsolated()&&(n.isNull(0)?this.labelIncompleteNode(e,0):this.labelIncompleteNode(e,1)),e.getEdges().updateLabelling(n)}},e.prototype.isCoveredByA=function(t){return!!this.isCovered(t,this._resultPolyList)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(id);ad.overlayOp=function(t,e,n){return new ad(t,e).getResultGeometry(n)},ad.intersection=function(t,e){if(t.isEmpty()||e.isEmpty())return ad.createEmptyResult(ad.INTERSECTION,t,e,t.getFactory());if(t.isGeometryCollection()){var n=e;return Mf.map(t,{interfaces_:function(){return[od.MapOp]},map:function(t){return t.intersection(n)}})}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Bf.overlayOp(t,e,ad.INTERSECTION)},ad.symDifference=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return ad.createEmptyResult(ad.SYMDIFFERENCE,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Bf.overlayOp(t,e,ad.SYMDIFFERENCE)},ad.resultDimension=function(t,e,n){var r=e.getDimension(),i=n.getDimension(),o=-1;switch(t){case ad.INTERSECTION:o=Math.min(r,i);break;case ad.UNION:o=Math.max(r,i);break;case ad.DIFFERENCE:o=r;break;case ad.SYMDIFFERENCE:o=Math.max(r,i)}return o},ad.createEmptyResult=function(t,e,n,r){var i=null;switch(ad.resultDimension(t,e,n)){case-1:i=r.createGeometryCollection(new Array(0).fill(null));break;case 0:i=r.createPoint();break;case 1:i=r.createLineString();break;case 2:i=r.createPolygon()}return i},ad.difference=function(t,e){return t.isEmpty()?ad.createEmptyResult(ad.DIFFERENCE,t,e,t.getFactory()):e.isEmpty()?t.copy():(t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Bf.overlayOp(t,e,ad.DIFFERENCE))},ad.isResultOfOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=t.getLocation(0),r=t.getLocation(1);return ad.isResultOfOp(n,r,e)}if(3===arguments.length){var i=arguments[0],o=arguments[1];switch(i===jl.BOUNDARY&&(i=jl.INTERIOR),o===jl.BOUNDARY&&(o=jl.INTERIOR),arguments[2]){case ad.INTERSECTION:return i===jl.INTERIOR&&o===jl.INTERIOR;case ad.UNION:return i===jl.INTERIOR||o===jl.INTERIOR;case ad.DIFFERENCE:return i===jl.INTERIOR&&o!==jl.INTERIOR;case ad.SYMDIFFERENCE:return i===jl.INTERIOR&&o!==jl.INTERIOR||i!==jl.INTERIOR&&o===jl.INTERIOR}return!1}},ad.INTERSECTION=1,ad.UNION=2,ad.DIFFERENCE=3,ad.SYMDIFFERENCE=4;var sd=function(){this._g=null,this._boundaryDistanceTolerance=null,this._linework=null,this._ptLocator=new of,this._seg=new Zh;var t=arguments[0],e=arguments[1];this._g=t,this._boundaryDistanceTolerance=e,this._linework=this.extractLinework(t)};sd.prototype.isWithinToleranceOfBoundary=function(t){for(var e=this,n=0;n<this._linework.getNumGeometries();n++)for(var r=e._linework.getGeometryN(n).getCoordinateSequence(),i=0;i<r.size()-1;i++)if(r.getCoordinate(i,e._seg.p0),r.getCoordinate(i+1,e._seg.p1),e._seg.distance(t)<=e._boundaryDistanceTolerance)return!0;return!1},sd.prototype.getLocation=function(t){return this.isWithinToleranceOfBoundary(t)?jl.BOUNDARY:this._ptLocator.locate(t,this._g)},sd.prototype.extractLinework=function(t){var e=new ld;t.apply(e);var n=e.getLinework(),r=Yc.toLineStringArray(n);return t.getFactory().createMultiLineString(r)},sd.prototype.interfaces_=function(){return[]},sd.prototype.getClass=function(){return sd};var ld=function(){this._linework=null,this._linework=new Uu};ld.prototype.getLinework=function(){return this._linework},ld.prototype.filter=function(t){if(t instanceof Pc){var e=t;this._linework.add(e.getExteriorRing());for(var n=0;n<e.getNumInteriorRing();n++)this._linework.add(e.getInteriorRingN(n))}},ld.prototype.interfaces_=function(){return[pc]},ld.prototype.getClass=function(){return ld};var ud=function(){this._g=null,this._doLeft=!0,this._doRight=!0;var t=arguments[0];this._g=t};ud.prototype.extractPoints=function(t,e,n){for(var r=t.getCoordinates(),i=0;i<r.length-1;i++)this.computeOffsetPoints(r[i],r[i+1],e,n)},ud.prototype.setSidesToGenerate=function(t,e){this._doLeft=t,this._doRight=e},ud.prototype.getPoints=function(t){for(var e=new Uu,n=rf.getLines(this._g).iterator();n.hasNext();){var r=n.next();this.extractPoints(r,t,e)}return e},ud.prototype.computeOffsetPoints=function(t,e,n,r){var i=e.x-t.x,o=e.y-t.y,a=Math.sqrt(i*i+o*o),s=n*i/a,l=n*o/a,u=(e.x+t.x)/2,c=(e.y+t.y)/2;if(this._doLeft){var h=new Bl(u-l,c+s);r.add(h)}if(this._doRight){var p=new Bl(u+l,c-s);r.add(p)}},ud.prototype.interfaces_=function(){return[]},ud.prototype.getClass=function(){return ud};var cd=function t(){this._geom=null,this._locFinder=null,this._location=new Array(3).fill(null),this._invalidLocation=null,this._boundaryDistanceTolerance=t.TOLERANCE,this._testCoords=new Uu;var e=arguments[0],n=arguments[1],r=arguments[2];this._boundaryDistanceTolerance=t.computeBoundaryDistanceTolerance(e,n),this._geom=[e,n,r],this._locFinder=[new sd(this._geom[0],this._boundaryDistanceTolerance),new sd(this._geom[1],this._boundaryDistanceTolerance),new sd(this._geom[2],this._boundaryDistanceTolerance)]},hd={TOLERANCE:{configurable:!0}};cd.prototype.reportResult=function(t,e,n){ou.out.println("Overlay result invalid - A:"+jl.toLocationSymbol(e[0])+" B:"+jl.toLocationSymbol(e[1])+" expected:"+(n?"i":"e")+" actual:"+jl.toLocationSymbol(e[2]))},cd.prototype.isValid=function(t){this.addTestPts(this._geom[0]),this.addTestPts(this._geom[1]);return this.checkValid(t)},cd.prototype.checkValid=function(){var t=this;if(1===arguments.length){for(var e=arguments[0],n=0;n<this._testCoords.size();n++){var r=t._testCoords.get(n);if(!t.checkValid(e,r))return t._invalidLocation=r,!1}return!0}if(2===arguments.length){var i=arguments[0],o=arguments[1];return this._location[0]=this._locFinder[0].getLocation(o),this._location[1]=this._locFinder[1].getLocation(o),this._location[2]=this._locFinder[2].getLocation(o),!!cd.hasLocation(this._location,jl.BOUNDARY)||this.isValidResult(i,this._location)}},cd.prototype.addTestPts=function(t){var e=new ud(t);this._testCoords.addAll(e.getPoints(5*this._boundaryDistanceTolerance))},cd.prototype.isValidResult=function(t,e){var n=ad.isResultOfOp(e[0],e[1],t),r=!(n^e[2]===jl.INTERIOR);return r||this.reportResult(t,e,n),r},cd.prototype.getInvalidLocation=function(){return this._invalidLocation},cd.prototype.interfaces_=function(){return[]},cd.prototype.getClass=function(){return cd},cd.hasLocation=function(t,e){for(var n=0;n<3;n++)if(t[n]===e)return!0;return!1},cd.computeBoundaryDistanceTolerance=function(t,e){return Math.min(Lf.computeSizeBasedSnapTolerance(t),Lf.computeSizeBasedSnapTolerance(e))},cd.isValid=function(t,e,n,r){return new cd(t,e,r).isValid(n)},hd.TOLERANCE.get=function(){return 1e-6},Object.defineProperties(cd,hd);var pd=function t(e){this._geomFactory=null,this._skipEmpty=!1,this._inputGeoms=null,this._geomFactory=t.extractFactory(e),this._inputGeoms=e};pd.prototype.extractElements=function(t,e){if(null===t)return null;for(var n=0;n<t.getNumGeometries();n++){var r=t.getGeometryN(n);this._skipEmpty&&r.isEmpty()||e.add(r)}},pd.prototype.combine=function(){for(var t=new Uu,e=this._inputGeoms.iterator();e.hasNext();){var n=e.next();this.extractElements(n,t)}return 0===t.size()?null!==this._geomFactory?this._geomFactory.createGeometryCollection(null):null:this._geomFactory.buildGeometry(t)},pd.prototype.interfaces_=function(){return[]},pd.prototype.getClass=function(){return pd},pd.combine=function(){if(1===arguments.length){return new pd(arguments[0]).combine()}if(2===arguments.length){return new pd(pd.createList(arguments[0],arguments[1])).combine()}if(3===arguments.length){return new pd(pd.createList(arguments[0],arguments[1],arguments[2])).combine()}},pd.extractFactory=function(t){return t.isEmpty()?null:t.iterator().next().getFactory()},pd.createList=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new Uu;return n.add(t),n.add(e),n}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],a=new Uu;return a.add(r),a.add(i),a.add(o),a}};var fd=function(){this._inputPolys=null,this._geomFactory=null;var t=arguments[0];this._inputPolys=t,null===this._inputPolys&&(this._inputPolys=new Uu)},dd={STRTREE_NODE_CAPACITY:{configurable:!0}};fd.prototype.reduceToGeometries=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next(),i=null;ql(r,Fu)?i=this.unionTree(r):r instanceof Mu&&(i=r),e.add(i)}return e},fd.prototype.extractByEnvelope=function(t,e,n){for(var r=new Uu,i=0;i<e.getNumGeometries();i++){var o=e.getGeometryN(i);o.getEnvelopeInternal().intersects(t)?r.add(o):n.add(o)}return this._geomFactory.buildGeometry(r)},fd.prototype.unionOptimized=function(t,e){var n=t.getEnvelopeInternal(),r=e.getEnvelopeInternal();if(!n.intersects(r))return pd.combine(t,e);if(t.getNumGeometries()<=1&&e.getNumGeometries()<=1)return this.unionActual(t,e);var i=n.intersection(r);return this.unionUsingEnvelopeIntersection(t,e,i)},fd.prototype.union=function(){if(null===this._inputPolys)throw new Error("union() method cannot be called twice");if(this._inputPolys.isEmpty())return null;this._geomFactory=this._inputPolys.iterator().next().getFactory();for(var t=new Bh(fd.STRTREE_NODE_CAPACITY),e=this._inputPolys.iterator();e.hasNext();){var n=e.next();t.insert(n.getEnvelopeInternal(),n)}this._inputPolys=null;var r=t.itemsTree();return this.unionTree(r)},fd.prototype.binaryUnion=function(){if(1===arguments.length){var t=arguments[0];return this.binaryUnion(t,0,t.size())}if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];if(r-n<=1){var i=fd.getGeometry(e,n);return this.unionSafe(i,null)}if(r-n==2)return this.unionSafe(fd.getGeometry(e,n),fd.getGeometry(e,n+1));var o=Math.trunc((r+n)/2),a=this.binaryUnion(e,n,o),s=this.binaryUnion(e,o,r);return this.unionSafe(a,s)}},fd.prototype.repeatedUnion=function(t){for(var e=null,n=t.iterator();n.hasNext();){var r=n.next();e=null===e?r.copy():e.union(r)}return e},fd.prototype.unionSafe=function(t,e){return null===t&&null===e?null:null===t?e.copy():null===e?t.copy():this.unionOptimized(t,e)},fd.prototype.unionActual=function(t,e){return fd.restrictToPolygons(t.union(e))},fd.prototype.unionTree=function(t){var e=this.reduceToGeometries(t);return this.binaryUnion(e)},fd.prototype.unionUsingEnvelopeIntersection=function(t,e,n){var r=new Uu,i=this.extractByEnvelope(n,t,r),o=this.extractByEnvelope(n,e,r),a=this.unionActual(i,o);return r.add(a),pd.combine(r)},fd.prototype.bufferUnion=function(){if(1===arguments.length){var t=arguments[0];return t.get(0).getFactory().buildGeometry(t).buffer(0)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e.getFactory().createGeometryCollection([e,n]).buffer(0)}},fd.prototype.interfaces_=function(){return[]},fd.prototype.getClass=function(){return fd},fd.restrictToPolygons=function(t){if(ql(t,Lc))return t;var e=nf.getPolygons(t);return 1===e.size()?e.get(0):t.getFactory().createMultiPolygon(Yc.toPolygonArray(e))},fd.getGeometry=function(t,e){return e>=t.size()?null:t.get(e)},fd.union=function(t){return new fd(t).union()},dd.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(fd,dd);var md=function(){};function gd(){return new yd}function yd(){this.reset()}md.prototype.interfaces_=function(){return[]},md.prototype.getClass=function(){return md},md.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return ad.createEmptyResult(ad.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Bf.overlayOp(t,e,ad.UNION)},yd.prototype={constructor:yd,reset:function(){this.s=this.t=0},add:function(t){_d(vd,t,this.t),_d(this,vd.s,this.s),this.s?this.t+=vd.t:this.s=vd.t},valueOf:function(){return this.s}};var vd=new yd;function _d(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i)}var xd=1e-6,bd=Math.PI,wd=bd/2,Ed=bd/4,Sd=2*bd,Md=180/bd,Td=bd/180,Cd=Math.abs,Id=Math.atan,Ad=Math.atan2,Ld=Math.cos,Pd=Math.sin,Rd=Math.sqrt;function Dd(t){return t>1?0:t<-1?bd:Math.acos(t)}function Nd(t){return t>1?wd:t<-1?-wd:Math.asin(t)}function Od(){}function kd(t,e){t&&Ud.hasOwnProperty(t.type)&&Ud[t.type](t,e)}var zd,Fd,Bd={Feature:function(t,e){kd(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)kd(n[r].geometry,e)}},Ud={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)t=n[r],e.point(t[0],t[1],t[2])},LineString:function(t,e){Vd(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Vd(n[r],e,0)},Polygon:function(t,e){Gd(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Gd(n[r],e)},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)kd(n[r],e)}};function Vd(t,e,n){var r,i=-1,o=t.length-n;for(e.lineStart();++i<o;)r=t[i],e.point(r[0],r[1],r[2]);e.lineEnd()}function Gd(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;)Vd(t[n],e,1);e.polygonEnd()}gd(),gd();function jd(t){return[Ad(t[1],t[0]),Nd(t[2])]}function Hd(t){var e=t[0],n=t[1],r=Ld(n);return[r*Ld(e),r*Pd(e),Pd(n)]}function qd(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Wd(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Xd(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Zd(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Yd(t){var e=Rd(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}gd();function Jd(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,r){return(n=e.invert(n,r))&&t.invert(n[0],n[1])}),n}function Kd(t,e){return[t>bd?t-Sd:t<-bd?t+Sd:t,e]}function Qd(t){return function(e,n){return[(e+=t)>bd?e-Sd:e<-bd?e+Sd:e,n]}}function $d(t){var e=Qd(t);return e.invert=Qd(-t),e}function tm(t,e){var n=Ld(t),r=Pd(t),i=Ld(e),o=Pd(e);function a(t,e){var a=Ld(e),s=Ld(t)*a,l=Pd(t)*a,u=Pd(e),c=u*n+s*r;return[Ad(l*i-c*o,s*n-u*r),Nd(c*i+l*o)]}return a.invert=function(t,e){var a=Ld(e),s=Ld(t)*a,l=Pd(t)*a,u=Pd(e),c=u*i-l*o;return[Ad(l*i+u*o,s*n+c*r),Nd(c*n-s*r)]},a}function em(t,e){(e=Hd(e))[0]-=t,Yd(e);var n=Dd(-e[1]);return((-e[2]<0?-n:n)+Sd-xd)%Sd}function nm(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:Od,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function rm(t,e){return Cd(t[0]-e[0])<xd&&Cd(t[1]-e[1])<xd}function im(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function om(t,e,n,r,i){var o,a,s=[],l=[];if(t.forEach((function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],a=t[e];if(rm(r,a)){for(i.lineStart(),o=0;o<e;++o)i.point((r=t[o])[0],r[1]);i.lineEnd()}else s.push(n=new im(r,t,null,!0)),l.push(n.o=new im(r,null,n,!1)),s.push(n=new im(a,t,null,!1)),l.push(n.o=new im(a,null,n,!0))}})),s.length){for(l.sort(e),am(s),am(l),o=0,a=l.length;o<a;++o)l[o].e=n=!n;for(var u,c,h=s[0];;){for(var p=h,f=!0;p.v;)if((p=p.n)===h)return;u=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(f)for(o=0,a=u.length;o<a;++o)i.point((c=u[o])[0],c[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(f)for(u=p.p.z,o=u.length-1;o>=0;--o)i.point((c=u[o])[0],c[1]);else r(p.x,p.p.x,-1,i);p=p.p}u=(p=p.o).z,f=!f}while(!p.v);i.lineEnd()}}}function am(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;)i.n=n=t[r],n.p=i,i=n;i.n=n=t[0],n.p=i}}function sm(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}Kd.invert=Kd;1===(zd=sm).length&&(Fd=zd,zd=function(t,e){return sm(Fd(t),e)});function lm(t){for(var e,n,r,i=t.length,o=-1,a=0;++o<i;)a+=t[o].length;for(n=new Array(a);--i>=0;)for(e=(r=t[i]).length;--e>=0;)n[--a]=r[e];return n}var um=1e9,cm=-um;var hm=gd();gd();function pm(t){return t}gd(),gd();var fm=1/0,dm=fm,mm=-fm,gm=mm,ym={point:function(t,e){t<fm&&(fm=t);t>mm&&(mm=t);e<dm&&(dm=e);e>gm&&(gm=e)},lineStart:Od,lineEnd:Od,polygonStart:Od,polygonEnd:Od,result:function(){var t=[[fm,dm],[mm,gm]];return mm=gm=-(dm=fm=1/0),t}};gd();function vm(t,e,n,r){return function(i,o){var a,s,l,u=e(o),c=i.invert(r[0],r[1]),h=nm(),p=e(h),f=!1,d={point:m,lineStart:y,lineEnd:v,polygonStart:function(){d.point=_,d.lineStart=x,d.lineEnd=b,s=[],a=[]},polygonEnd:function(){d.point=m,d.lineStart=y,d.lineEnd=v,s=lm(s);var t=function(t,e){var n=e[0],r=e[1],i=[Pd(n),-Ld(n),0],o=0,a=0;hm.reset();for(var s=0,l=t.length;s<l;++s)if(c=(u=t[s]).length)for(var u,c,h=u[c-1],p=h[0],f=h[1]/2+Ed,d=Pd(f),m=Ld(f),g=0;g<c;++g,p=v,d=x,m=b,h=y){var y=u[g],v=y[0],_=y[1]/2+Ed,x=Pd(_),b=Ld(_),w=v-p,E=w>=0?1:-1,S=E*w,M=S>bd,T=d*x;if(hm.add(Ad(T*E*Pd(S),m*b+T*Ld(S))),o+=M?w+E*Sd:w,M^p>=n^v>=n){var C=Wd(Hd(h),Hd(y));Yd(C);var I=Wd(i,C);Yd(I);var A=(M^w>=0?-1:1)*Nd(I[2]);(r>A||r===A&&(C[0]||C[1]))&&(a+=M^w>=0?1:-1)}}return(o<-1e-6||o<xd&&hm<-1e-6)^1&a}(a,c);s.length?(f||(o.polygonStart(),f=!0),om(s,xm,t,n,o)):t&&(f||(o.polygonStart(),f=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),f&&(o.polygonEnd(),f=!1),s=a=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function m(e,n){var r=i(e,n);t(e=r[0],n=r[1])&&o.point(e,n)}function g(t,e){var n=i(t,e);u.point(n[0],n[1])}function y(){d.point=g,u.lineStart()}function v(){d.point=m,u.lineEnd()}function _(t,e){l.push([t,e]);var n=i(t,e);p.point(n[0],n[1])}function x(){p.lineStart(),l=[]}function b(){_(l[0][0],l[0][1]),p.lineEnd();var t,e,n,r,i=p.clean(),u=h.result(),c=u.length;if(l.pop(),a.push(l),l=null,c)if(1&i){if((e=(n=u[0]).length-1)>0){for(f||(o.polygonStart(),f=!0),o.lineStart(),t=0;t<e;++t)o.point((r=n[t])[0],r[1]);o.lineEnd()}}else c>1&&2&i&&u.push(u.pop().concat(u.shift())),s.push(u.filter(_m))}return d}}function _m(t){return t.length>1}function xm(t,e){return((t=t.x)[0]<0?t[1]-wd-xd:wd-t[1])-((e=e.x)[0]<0?e[1]-wd-xd:wd-e[1])}var bm=vm((function(){return!0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,a){var s=o>0?bd:-bd,l=Cd(o-n);Cd(l-bd)<xd?(t.point(n,r=(r+a)/2>0?wd:-wd),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),e=0):i!==s&&l>=bd&&(Cd(n-i)<xd&&(n-=i*xd),Cd(o-s)<xd&&(o-=s*xd),r=function(t,e,n,r){var i,o,a=Pd(t-n);return Cd(a)>xd?Id((Pd(e)*(o=Ld(r))*Pd(n)-Pd(r)*(i=Ld(e))*Pd(t))/(i*o*a)):(e+r)/2}(n,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=o,r=a),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*wd,r.point(-bd,i),r.point(0,i),r.point(bd,i),r.point(bd,0),r.point(bd,-i),r.point(0,-i),r.point(-bd,-i),r.point(-bd,0),r.point(-bd,i);else if(Cd(t[0]-e[0])>xd){var o=t[0]<e[0]?bd:-bd;i=n*o/2,r.point(-o,i),r.point(0,i),r.point(o,i)}else r.point(e[0],e[1])}),[-bd,-wd]);function wm(t){return function(e){var n=new Em;for(var r in t)n[r]=t[r];return n.stream=e,n}}function Em(){}function Sm(t,e,n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),null!=o&&t.clipExtent(null),function(t,e){t&&Bd.hasOwnProperty(t.type)?Bd[t.type](t,e):kd(t,e)}(n,t.stream(ym));var a=ym.result(),s=Math.min(r/(a[1][0]-a[0][0]),i/(a[1][1]-a[0][1])),l=+e[0][0]+(r-s*(a[1][0]+a[0][0]))/2,u=+e[0][1]+(i-s*(a[1][1]+a[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*s).translate([l,u])}Em.prototype={constructor:Em,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Mm=Ld(30*Td);function Tm(t,e){return+e?function(t,e){function n(r,i,o,a,s,l,u,c,h,p,f,d,m,g){var y=u-r,v=c-i,_=y*y+v*v;if(_>4*e&&m--){var x=a+p,b=s+f,w=l+d,E=Rd(x*x+b*b+w*w),S=Nd(w/=E),M=Cd(Cd(w)-1)<xd||Cd(o-h)<xd?(o+h)/2:Ad(b,x),T=t(M,S),C=T[0],I=T[1],A=C-r,L=I-i,P=v*A-y*L;(P*P/_>e||Cd((y*A+v*L)/_-.5)>.3||a*p+s*f+l*d<Mm)&&(n(r,i,o,a,s,l,C,I,M,x/=E,b/=E,w,m,g),g.point(C,I),n(C,I,M,x,b,w,u,c,h,p,f,d,m,g))}}return function(e){var r,i,o,a,s,l,u,c,h,p,f,d,m={point:g,lineStart:y,lineEnd:_,polygonStart:function(){e.polygonStart(),m.lineStart=x},polygonEnd:function(){e.polygonEnd(),m.lineStart=y}};function g(n,r){n=t(n,r),e.point(n[0],n[1])}function y(){c=NaN,m.point=v,e.lineStart()}function v(r,i){var o=Hd([r,i]),a=t(r,i);n(c,h,u,p,f,d,c=a[0],h=a[1],u=r,p=o[0],f=o[1],d=o[2],16,e),e.point(c,h)}function _(){m.point=g,e.lineEnd()}function x(){y(),m.point=b,m.lineEnd=w}function b(t,e){v(r=t,e),i=c,o=h,a=p,s=f,l=d,m.point=v}function w(){n(c,h,u,p,f,d,i,o,r,a,s,l,16,e),m.lineEnd=_,_()}return m}}(t,e):function(t){return wm({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var Cm=wm({point:function(t,e){this.stream.point(t*Td,e*Td)}});function Im(t){return function(t){var e,n,r,i,o,a,s,l,u,c,h=150,p=480,f=250,d=0,m=0,g=0,y=0,v=0,_=null,x=bm,b=null,w=pm,E=.5,S=Tm(C,E);function M(t){return[(t=o(t[0]*Td,t[1]*Td))[0]*h+n,r-t[1]*h]}function T(t){return(t=o.invert((t[0]-n)/h,(r-t[1])/h))&&[t[0]*Md,t[1]*Md]}function C(t,i){return[(t=e(t,i))[0]*h+n,r-t[1]*h]}function I(){o=Jd(i=function(t,e,n){return(t%=Sd)?e||n?Jd($d(t),tm(e,n)):$d(t):e||n?tm(e,n):Kd}(g,y,v),e);var t=e(d,m);return n=p-t[0]*h,r=f+t[1]*h,A()}function A(){return u=c=null,M}return M.stream=function(t){return u&&c===t?u:u=Cm(x(i,S(w(c=t))))},M.clipAngle=function(t){return arguments.length?(x=+t?function(t,e){var n=Ld(t),r=n>0,i=Cd(n)>xd;function o(t,e){return Ld(t)*Ld(e)>n}function a(t,e,r){var i=[1,0,0],o=Wd(Hd(t),Hd(e)),a=qd(o,o),s=o[0],l=a-s*s;if(!l)return!r&&t;var u=n*a/l,c=-n*s/l,h=Wd(i,o),p=Zd(i,u);Xd(p,Zd(o,c));var f=h,d=qd(p,f),m=qd(f,f),g=d*d-m*(qd(p,p)-1);if(!(g<0)){var y=Rd(g),v=Zd(f,(-d-y)/m);if(Xd(v,p),v=jd(v),!r)return v;var _,x=t[0],b=e[0],w=t[1],E=e[1];b<x&&(_=x,x=b,b=_);var S=b-x,M=Cd(S-bd)<xd;if(!M&&E<w&&(_=w,w=E,E=_),M||S<xd?M?w+E>0^v[1]<(Cd(v[0]-x)<xd?w:E):w<=v[1]&&v[1]<=E:S>bd^(x<=v[0]&&v[0]<=b)){var T=Zd(f,(-d+y)/m);return Xd(T,p),[v,jd(T)]}}}function s(e,n){var i=r?t:bd-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return vm(o,(function(t){var e,n,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(h,p){var f,d=[h,p],m=o(h,p),g=r?m?0:s(h,p):m?s(h+(h<0?bd:-bd),p):0;if(!e&&(u=l=m)&&t.lineStart(),m!==l&&(!(f=a(e,d))||rm(e,f)||rm(d,f))&&(d[0]+=xd,d[1]+=xd,m=o(d[0],d[1])),m!==l)c=0,m?(t.lineStart(),f=a(d,e),t.point(f[0],f[1])):(f=a(e,d),t.point(f[0],f[1]),t.lineEnd()),e=f;else if(i&&e&&r^m){var y;g&n||!(y=a(d,e,!0))||(c=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!m||e&&rm(e,d)||t.point(d[0],d[1]),e=d,l=m,n=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}}),(function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var a=Ld(e),s=Pd(e),l=r*n;null==i?(i=e+r*Sd,o=e-l/2):(i=em(a,i),o=em(a,o),(r>0?i<o:i>o)&&(i+=r*Sd));for(var u,c=i;r>0?c>o:c<o;c-=l)u=jd([a,-s*Ld(c),-s*Pd(c)]),t.point(u[0],u[1])}}(o,t,e,i,n,r)}),r?[0,-t]:[-bd,t-bd])}(_=t*Td,6*Td):(_=null,bm),A()):_*Md},M.clipExtent=function(t){return arguments.length?(w=null==t?(b=a=s=l=null,pm):function(t,e,n,r){function i(i,o){return t<=i&&i<=n&&e<=o&&o<=r}function o(i,o,s,u){var c=0,h=0;if(null==i||(c=a(i,s))!==(h=a(o,s))||l(i,o)<0^s>0)do{u.point(0===c||3===c?t:n,c>1?r:e)}while((c=(c+s+4)%4)!==h);else u.point(o[0],o[1])}function a(r,i){return Cd(r[0]-t)<xd?i>0?0:3:Cd(r[0]-n)<xd?i>0?2:1:Cd(r[1]-e)<xd?i>0?1:0:i>0?3:2}function s(t,e){return l(t.x,e.x)}function l(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(a){var l,u,c,h,p,f,d,m,g,y,v,_=a,x=nm(),b={point:w,lineStart:function(){b.point=E,u&&u.push(c=[]);y=!0,g=!1,d=m=NaN},lineEnd:function(){l&&(E(h,p),f&&g&&x.rejoin(),l.push(x.result()));b.point=w,g&&_.lineEnd()},polygonStart:function(){_=x,l=[],u=[],v=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=u.length;n<i;++n)for(var o,a,s=u[n],l=1,c=s.length,h=s[0],p=h[0],f=h[1];l<c;++l)o=p,a=f,p=(h=s[l])[0],f=h[1],a<=r?f>r&&(p-o)*(r-a)>(f-a)*(t-o)&&++e:f<=r&&(p-o)*(r-a)<(f-a)*(t-o)&&--e;return e}(),n=v&&e,i=(l=lm(l)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&om(l,s,e,o,a),a.polygonEnd());_=a,l=u=c=null}};function w(t,e){i(t,e)&&_.point(t,e)}function E(o,a){var s=i(o,a);if(u&&c.push([o,a]),y)h=o,p=a,f=s,y=!1,s&&(_.lineStart(),_.point(o,a));else if(s&&g)_.point(o,a);else{var l=[d=Math.max(cm,Math.min(um,d)),m=Math.max(cm,Math.min(um,m))],x=[o=Math.max(cm,Math.min(um,o)),a=Math.max(cm,Math.min(um,a))];!function(t,e,n,r,i,o){var a,s=t[0],l=t[1],u=0,c=1,h=e[0]-s,p=e[1]-l;if(a=n-s,h||!(a>0)){if(a/=h,h<0){if(a<u)return;a<c&&(c=a)}else if(h>0){if(a>c)return;a>u&&(u=a)}if(a=i-s,h||!(a<0)){if(a/=h,h<0){if(a>c)return;a>u&&(u=a)}else if(h>0){if(a<u)return;a<c&&(c=a)}if(a=r-l,p||!(a>0)){if(a/=p,p<0){if(a<u)return;a<c&&(c=a)}else if(p>0){if(a>c)return;a>u&&(u=a)}if(a=o-l,p||!(a<0)){if(a/=p,p<0){if(a>c)return;a>u&&(u=a)}else if(p>0){if(a<u)return;a<c&&(c=a)}return u>0&&(t[0]=s+u*h,t[1]=l+u*p),c<1&&(e[0]=s+c*h,e[1]=l+c*p),!0}}}}}(l,x,t,e,n,r)?s&&(_.lineStart(),_.point(o,a),v=!1):(g||(_.lineStart(),_.point(l[0],l[1])),_.point(x[0],x[1]),s||_.lineEnd(),v=!1)}d=o,m=a,g=s}return b}}(b=+t[0][0],a=+t[0][1],s=+t[1][0],l=+t[1][1]),A()):null==b?null:[[b,a],[s,l]]},M.scale=function(t){return arguments.length?(h=+t,I()):h},M.translate=function(t){return arguments.length?(p=+t[0],f=+t[1],I()):[p,f]},M.center=function(t){return arguments.length?(d=t[0]%360*Td,m=t[1]%360*Td,I()):[d*Md,m*Md]},M.rotate=function(t){return arguments.length?(g=t[0]%360*Td,y=t[1]%360*Td,v=t.length>2?t[2]%360*Td:0,I()):[g*Md,y*Md,v*Md]},M.precision=function(t){return arguments.length?(S=Tm(C,E=t*t),A()):Rd(E)},M.fitExtent=function(t,e){return Sm(M,t,e)},M.fitSize=function(t,e){return function(t,e,n){return Sm(t,[[0,0],e],n)}(M,t,e)},function(){return e=t.apply(this,arguments),M.invert=e.invert&&T,I()}}((function(){return t}))()}var Am=function(t,e){var n=Ld(t),r=Ld(e),i=function(t){return(t=Dd(t))&&t/Pd(t)}(n*r);return[i*r*Pd(t),i*Pd(e)]};function Lm(t,n,r,i){var a=t.properties||{},s="Feature"===t.type?t.geometry:t;if("GeometryCollection"===s.type){var l=[];return B(t,(function(t){var e=Lm(t,n,r,i);e&&l.push(e)})),f(l)}var u=function(t){var n=fn(t).geometry.coordinates,r=[-n[0],-n[1]];return Im(Am).scale(79.4188).clipAngle(179.999).rotate(r).scale(e)}(s),c={type:s.type,coordinates:Rm(s.coordinates,u)},h=(new eh).read(c),p=_(x(n,r),"meters"),d=Zp.bufferOp(h,p,i);if(!Pm((d=(new nh).write(d)).coordinates))return o({type:d.type,coordinates:Dm(d.coordinates,u)},a)}function Pm(t){return Array.isArray(t[0])?Pm(t[0]):isNaN(t[0])}function Rm(t,e){return"object"!=typeof t[0]?e(t):t.map((function(t){return Rm(t,e)}))}function Dm(t,e){return"object"!=typeof t[0]?e.invert(t):t.map((function(t){return Dm(t,e)}))}function Nm(t,e,n){void 0===n&&(n={});var r=rt(t),i=rt(e),o=Ll.intersection(r.coordinates,i.coordinates);return 0===o.length?null:1===o.length?u(o[0],n.properties):g(o,n.properties)}function Om(t,e,n){void 0===n&&(n={});var r=JSON.stringify(n.properties||{}),i=t[0],o=t[1],a=t[2],s=t[3],l=(o+s)/2,u=(i+a)/2,c=2*e/ge([i,l],[a,l],n)*(a-i),h=2*e/ge([u,o],[u,s],n)*(s-o),p=c/2,d=2*p,m=Math.sqrt(3)/2*h,g=a-i,y=s-o,v=3/4*d,_=m,x=(g-d)/(d-p/2),b=Math.floor(x),w=(b*v-p/2-g)/2-p/2+v/2,E=Math.floor((y-m)/m),S=(y-E*m)/2,M=E*m-y>m/2;M&&(S-=m/4);for(var T=[],C=[],I=0;I<6;I++){var A=2*Math.PI/6*I;T.push(Math.cos(A)),C.push(Math.sin(A))}for(var L=[],P=0;P<=b;P++)for(var R=0;R<=E;R++){var D=P%2==1;if(!(0===R&&D||0===R&&M)){var N=P*v+i-w,O=R*_+o+S;if(D&&(O-=m/2),!0===n.triangles)zm([N,O],c/2,h/2,JSON.parse(r),T,C).forEach((function(t){n.mask?Nm(n.mask,t)&&L.push(t):L.push(t)}));else{var k=km([N,O],c/2,h/2,JSON.parse(r),T,C);n.mask?Nm(n.mask,k)&&L.push(k):L.push(k)}}}return f(L)}function km(t,e,n,r,i,o){for(var a=[],s=0;s<6;s++){var l=t[0]+e*i[s],c=t[1]+n*o[s];a.push([l,c])}return a.push(a[0].slice()),u([a],r)}function zm(t,e,n,r,i,o){for(var a=[],s=0;s<6;s++){var l=[];l.push(t),l.push([t[0]+e*i[s],t[1]+n*o[s]]),l.push([t[0]+e*i[(s+1)%6],t[1]+n*o[(s+1)%6]]),l.push(t),a.push(u([l],r))}return a}function Fm(t){return g(t)}function Bm(t,e,n){return void 0===n&&(n={}),function(t,e,n,r){void 0===r&&(r={});for(var i=[],o=t[0],a=t[1],s=t[2],l=t[3],c=e/ge([o,a],[s,a],r)*(s-o),h=n/ge([o,a],[o,l],r)*(l-a),p=s-o,d=l-a,m=Math.floor(p/c),g=Math.floor(d/h),y=(d-g*h)/2,v=o+(p-m*c)/2,_=0;_<m;_++){for(var x=a+y,b=0;b<g;b++){var w=u([[[v,x],[v,x+h],[v+c,x+h],[v+c,x],[v,x]]],r.properties);r.mask?la(r.mask,w)&&i.push(w):i.push(w),x+=h}v+=c}return f(i)}(t,e,e,n)}function Um(t,e,n){void 0===n&&(n={});for(var r=[],i=e/ge([t[0],t[1]],[t[2],t[1]],n)*(t[2]-t[0]),o=e/ge([t[0],t[1]],[t[0],t[3]],n)*(t[3]-t[1]),a=0,s=t[0];s<=t[2];){for(var l=0,c=t[1];c<=t[3];){var h=null,p=null;a%2==0&&l%2==0?(h=u([[[s,c],[s,c+o],[s+i,c],[s,c]]],n.properties),p=u([[[s,c+o],[s+i,c+o],[s+i,c],[s,c+o]]],n.properties)):a%2==0&&l%2==1?(h=u([[[s,c],[s+i,c+o],[s+i,c],[s,c]]],n.properties),p=u([[[s,c],[s,c+o],[s+i,c+o],[s,c]]],n.properties)):l%2==0&&a%2==1?(h=u([[[s,c],[s,c+o],[s+i,c+o],[s,c]]],n.properties),p=u([[[s,c],[s+i,c+o],[s+i,c],[s,c]]],n.properties)):l%2==1&&a%2==1&&(h=u([[[s,c],[s,c+o],[s+i,c],[s,c]]],n.properties),p=u([[[s,c+o],[s+i,c+o],[s+i,c],[s,c+o]]],n.properties)),n.mask?(Nm(n.mask,h)&&r.push(h),Nm(n.mask,p)&&r.push(p)):(r.push(h),r.push(p)),c+=o,l++}a++,s+=i}return f(r)}Am.invert=function(t,e){var n=Rd(t*t+e*e),r=n,i=Pd(r),o=Ld(r);return[Ad(t*i,n*o),Nd(n&&e*i/n)]},t.along=function(t,e,n){void 0===n&&(n={});for(var r=rt(t).coordinates,i=0,o=0;o<r.length&&!(e>=i&&o===r.length-1);o++){if(i>=e){var a=e-i;if(a){var l=pn(r[o],r[o-1])-180;return cn(r[o],a,l,n)}return s(r[o])}i+=ge(r[o],r[o+1],n)}return s(r[r.length-1])},t.angle=function(t,e,n,r){if(void 0===r&&(r={}),!I(r))throw new Error("options is invalid");if(!t)throw new Error("startPoint is required");if(!e)throw new Error("midPoint is required");if(!n)throw new Error("endPoint is required");var i=t,o=e,a=n,s=w(!0!==r.mercator?pn(i,o):wi(i,o)),l=w(!0!==r.mercator?pn(a,o):wi(a,o)),u=Math.abs(s-l);return!0===r.explementary?360-u:u},t.applyFilter=Bs,t.area=Mr,t.areaFactors=i,t.bbox=J,t.bboxClip=function(t,e){var n=rt(t),r=n.type,i="Feature"===t.type?t.properties:{},o=n.coordinates;switch(r){case"LineString":case"MultiLineString":var a=[];return"LineString"===r&&(o=[o]),o.forEach((function(t){!function(t,e,n){var r,i,o,a,s,l=t.length,u=di(t[0],e),c=[];for(n||(n=[]),r=1;r<l;r++){for(a=t[r-1],i=o=di(s=t[r],e);;){if(!(u|i)){c.push(a),i!==o?(c.push(s),r<l-1&&(n.push(c),c=[])):r===l-1&&c.push(s);break}if(u&i)break;u?u=di(a=fi(a,s,u,e),e):i=di(s=fi(a,s,i,e),e)}u=o}c.length&&n.push(c)}(t,e,a)})),1===a.length?h(a[0],i):d(a,i);case"Polygon":return u(mi(o,e),i);case"MultiPolygon":return g(o.map((function(t){return mi(t,e)})),i);default:throw new Error("geometry "+r+" not supported")}},t.bboxPolygon=sn,t.bearing=pn,t.bearingToAngle=w,t.bearingToAzimuth=w,t.bezier=an,t.bezierSpline=an,t.booleanClockwise=Ii,t.booleanContains=function(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type,a=n.coordinates,s=r.coordinates;switch(i){case"Point":if("Point"===o)return Ko(a,s);throw new Error("feature2 "+o+" geometry not supported");case"MultiPoint":switch(o){case"Point":return function(t,e){var n,r=!1;for(n=0;n<t.coordinates.length;n++)if(Ko(t.coordinates[n],e.coordinates)){r=!0;break}return r}(n,r);case"MultiPoint":return function(t,e){for(var n=0,r=e.coordinates;n<r.length;n++){for(var i=r[n],o=!1,a=0,s=t.coordinates;a<s.length;a++)if(Ko(i,s[a])){o=!0;break}if(!o)return!1}return!0}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"Point":return Pr(r,n,{ignoreEndVertices:!0});case"LineString":return function(t,e){for(var n=!1,r=0,i=e.coordinates;r<i.length;r++){var o=i[r];if(Pr({type:"Point",coordinates:o},t,{ignoreEndVertices:!0})&&(n=!0),!Pr({type:"Point",coordinates:o},t,{ignoreEndVertices:!1}))return!1}return n}(n,r);case"MultiPoint":return function(t,e){for(var n=!1,r=0,i=e.coordinates;r<i.length;r++){var o=i[r];if(Pr(o,t,{ignoreEndVertices:!0})&&(n=!0),!Pr(o,t))return!1}return!!n}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"Polygon":switch(o){case"Point":return fe(r,n,{ignoreBoundary:!0});case"LineString":return function(t,e){var n=!1,r=0;if(!Jo(J(t),J(e)))return!1;for(;r<e.coordinates.length-1;r++)if(fe({type:"Point",coordinates:Qo(e.coordinates[r],e.coordinates[r+1])},t,{ignoreBoundary:!0})){n=!0;break}return n}(n,r);case"Polygon":return function(t,e){if("Feature"===t.type&&null===t.geometry)return!1;if("Feature"===e.type&&null===e.geometry)return!1;if(!Jo(J(t),J(e)))return!1;for(var n=0,r=rt(e).coordinates;n<r.length;n++)for(var i=0,o=r[n];i<o.length;i++)if(!fe(o[i],t))return!1;return!0}(n,r);case"MultiPoint":return function(t,e){for(var n=0,r=e.coordinates;n<r.length;n++)if(!fe(r[n],t,{ignoreBoundary:!0}))return!1;return!0}(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}default:throw new Error("feature1 "+i+" geometry not supported")}},t.booleanCrosses=function(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;switch(i){case"MultiPoint":switch(o){case"LineString":return $o(n,r);case"Polygon":return ea(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"MultiPoint":return $o(r,n);case"LineString":return function(t,e){if(dr(t,e).features.length>0)for(var n=0;n<t.coordinates.length-1;n++)for(var r=0;r<e.coordinates.length-1;r++){var i=!0;if(0!==r&&r!==e.coordinates.length-2||(i=!1),na(t.coordinates[n],t.coordinates[n+1],e.coordinates[r],i))return!0}return!1}(n,r);case"Polygon":return ta(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"Polygon":switch(o){case"MultiPoint":return ea(r,n);case"LineString":return ta(r,n);default:throw new Error("feature2 "+o+" geometry not supported")}default:throw new Error("feature1 "+i+" geometry not supported")}},t.booleanDisjoint=Wo,t.booleanEqual=function(t,e){return rt(t).type===rt(e).type&&new sa({precision:6}).compare(Xe(t),Xe(e))},t.booleanIntersects=la,t.booleanOverlap=function(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;if("MultiPoint"===i&&"MultiPoint"!==o||("LineString"===i||"MultiLineString"===i)&&"LineString"!==o&&"MultiLineString"!==o||("Polygon"===i||"MultiPolygon"===i)&&"Polygon"!==o&&"MultiPolygon"!==o)throw new Error("features must be of the same type");if("Point"===i)throw new Error("Point geometry not supported");if(new sa({precision:6}).compare(t,e))return!1;var a=0;switch(i){case"MultiPoint":for(var s=0;s<n.coordinates.length;s++)for(var l=0;l<r.coordinates.length;l++){var u=n.coordinates[s],c=r.coordinates[l];if(u[0]===c[0]&&u[1]===c[1])return!0}return!1;case"LineString":case"MultiLineString":j(t,(function(t){j(e,(function(e){_i(t,e).features.length&&a++}))}));break;case"Polygon":case"MultiPolygon":j(t,(function(t){j(e,(function(e){dr(t,e).features.length&&a++}))}))}return a>0},t.booleanParallel=function(t,e){if(!t)throw new Error("line1 is required");if(!e)throw new Error("line2 is required");if("LineString"!==ba(t,"line1"))throw new Error("line1 must be a LineString");if("LineString"!==ba(e,"line2"))throw new Error("line2 must be a LineString");for(var n=jn(Xe(t)).features,r=jn(Xe(e)).features,i=0;i<n.length;i++){var o=n[i].geometry.coordinates;if(!r[i])break;if(!xa(o,r[i].geometry.coordinates))return!1}return!0},t.booleanPointInPolygon=fe,t.booleanPointOnLine=Pr,t.booleanWithin=Dr,t.buffer=function(t,e,n){var r=(n=n||{}).units||"kilometers",i=n.steps||8;if(!t)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof i)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(i<=0)throw new Error("steps must be greater than 0");var o=[];switch(t.type){case"GeometryCollection":return B(t,(function(t){var n=Lm(t,e,r,i);n&&o.push(n)})),f(o);case"FeatureCollection":return k(t,(function(t){var n=Lm(t,e,r,i);n&&k(n,(function(t){t&&o.push(t)}))})),f(o)}return Lm(t,e,r,i)},t.center=fn,t.centerMean=ds,t.centerMedian=function(t,e){if(void 0===e&&(e={}),!I(e=e||{}))throw new Error("options is invalid");var n=e.counter||10;if(!C(n))throw new Error("counter must be a number");var r=e.weight,i=ds(t,{weight:e.weight}),o=f([]);k(t,(function(t){var e;o.features.push(dn(t,{properties:{weight:null===(e=t.properties)||void 0===e?void 0:e[r]}}))}));var a={tolerance:e.tolerance,medianCandidates:[]};return ms(i.geometry.coordinates,[0,0],o,a,n)},t.centerOfMass=function t(e,n){switch(void 0===n&&(n={}),it(e)){case"Point":return s(K(e),n.properties);case"Polygon":var r=[];R(e,(function(t){r.push(t)}));var i,o,a,l,u,c,h,p,f=dn(e,{properties:n.properties}),d=f.geometry.coordinates,m=0,g=0,y=0,v=r.map((function(t){return[t[0]-d[0],t[1]-d[1]]}));for(i=0;i<r.length-1;i++)l=(o=v[i])[0],c=o[1],u=(a=v[i+1])[0],y+=p=l*(h=a[1])-u*c,m+=(l+u)*p,g+=(c+h)*p;if(0===y)return f;var _=1/(.5*y*6);return s([d[0]+_*m,d[1]+_*g],n.properties);default:var x=pe(e);return x?t(x,{properties:n.properties}):dn(e,{properties:n.properties})}},t.centroid=dn,t.circle=hn,t.cleanCoords=Xe,t.clone=be,t.clusterEach=ks,t.clusterReduce=zs,t.clusters=Gs,t.clustersDbscan=function(t,e,n){void 0===n&&(n={}),!0!==n.mutate&&(t=be(t)),n.minPoints=n.minPoints||3;var r=new fa.DBSCAN,i=r.run(F(t),M(e,n.units),n.minPoints,ge),o=-1;return i.forEach((function(e){o++,e.forEach((function(e){var n=t.features[e];n.properties||(n.properties={}),n.properties.cluster=o,n.properties.dbscan="core"}))})),r.noise.forEach((function(e){var n=t.features[e];n.properties||(n.properties={}),n.properties.cluster?n.properties.dbscan="edge":n.properties.dbscan="noise"})),t},t.clustersKmeans=function(t,e){void 0===e&&(e={});var n=t.features.length;e.numberOfClusters=e.numberOfClusters||Math.round(Math.sqrt(n/2)),e.numberOfClusters>n&&(e.numberOfClusters=n),!0!==e.mutate&&(t=be(t));var r=F(t),i=r.slice(0,e.numberOfClusters),o=_a(r,e.numberOfClusters,i),a={};return o.centroids.forEach((function(t,e){a[e]=t})),k(t,(function(t,e){var n=o.idxs[e];t.properties.cluster=n,t.properties.centroid=a[n]})),t},t.collect=function(t,e,n,r){var i=Et(6),o=e.features.map((function(t){var e;return{minX:t.geometry.coordinates[0],minY:t.geometry.coordinates[1],maxX:t.geometry.coordinates[0],maxY:t.geometry.coordinates[1],property:null===(e=t.properties)||void 0===e?void 0:e[n]}}));return i.load(o),t.features.forEach((function(t){t.properties||(t.properties={});var e=J(t),n=i.search({minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}),o=[];n.forEach((function(e){fe([e.minX,e.minY],t)&&o.push(e.property)})),t.properties[r]=o})),t},t.collectionOf=nt,t.combine=function(t){var e={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return k(t,(function(t){var n,r,i,o;switch(null===(o=t.geometry)||void 0===o?void 0:o.type){case"Point":e.MultiPoint.coordinates.push(t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"MultiPoint":(n=e.MultiPoint.coordinates).push.apply(n,t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"LineString":e.MultiLineString.coordinates.push(t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"MultiLineString":(r=e.MultiLineString.coordinates).push.apply(r,t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"Polygon":e.MultiPolygon.coordinates.push(t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties);break;case"MultiPolygon":(i=e.MultiPolygon.coordinates).push.apply(i,t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties)}})),f(Object.keys(e).filter((function(t){return e[t].coordinates.length})).sort().map((function(t){return o({type:t,coordinates:e[t].coordinates},{collectedProperties:e[t].properties})})))},t.concave=function(t,e){void 0===e&&(e={});var n=e.maxEdge||1/0,r=ye(function(t){var e=[],n={};return k(t,(function(t){if(t.geometry){var r=t.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(n,r)||(e.push(t),n[r]=!0)}})),f(e)}(t));if(r.features=r.features.filter((function(t){var r=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],a=ge(r,i,e),s=ge(i,o,e),l=ge(r,o,e);return a<=n&&s<=n&&l<=n})),r.features.length<1)return null;var i=We(r);return 1===i.coordinates.length&&(i.coordinates=i.coordinates[0],i.type="Polygon"),o(i)},t.containsNumber=$,t.convertArea=T,t.convertDistance=M,t.convertLength=M,t.convex=pe,t.coordAll=F,t.coordEach=R,t.coordReduce=D,t.createBins=Fs,t.degrees2radians=S,t.degreesToRadians=S,t.destination=cn,t.difference=function(t,e){var n=rt(t),r=rt(e),i=t.properties||{},o=Ll.difference(n.coordinates,r.coordinates);return 0===o.length?null:1===o.length?u(o[0],i):g(o,i)},t.dissolve=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.propertyName;nt(t,"Polygon","dissolve");var r=[];if(!e.propertyName)return Br(g(Ll.union.apply(null,t.features.map((function(t){return t.geometry.coordinates})))));var i={};k(t,(function(t){Object.prototype.hasOwnProperty.call(i,t.properties[n])||(i[t.properties[n]]=[]),i[t.properties[n]].push(t)}));for(var o=Object.keys(i),a=0;a<o.length;a++){var s=g(Ll.union.apply(null,i[o[a]].map((function(t){return t.geometry.coordinates}))));s.properties[n]=o[a],r.push(s)}return Br(f(r))},t.distance=ge,t.distanceToDegrees=b,t.distanceToRadians=x,t.distanceWeight=xs,t.earthRadius=e,t.ellipse=ps,t.envelope=ln,t.explode=mn,t.factors=n,t.feature=o,t.featureCollection=f,t.featureEach=k,t.featureOf=et,t.featureReduce=z,t.filterProperties=Vs,t.findPoint=Z,t.findSegment=X,t.flatten=Br,t.flattenEach=V,t.flattenReduce=G,t.flip=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if(!t)throw new Error("geojson is required");return!1!==n&&void 0!==n||(t=be(t)),R(t,(function(t){var e=t[0],n=t[1];t[0]=n,t[1]=e})),t},t.geojsonType=tt,t.geomEach=B,t.geomReduce=U,t.geometry=a,t.geometryCollection=y,t.getCluster=Os,t.getCoord=K,t.getCoords=Q,t.getGeom=rt,t.getType=it,t.greatCircle=function(t,e,n){if("object"!=typeof(n=n||{}))throw new Error("options is invalid");var r=n.properties,i=n.npoints,o=n.offset;return t=K(t),e=K(e),r=r||{},i=i||100,o=o||10,new $r({x:t[0],y:t[1]},{x:e[0],y:e[1]},r).Arc(i,{offset:o}).json()},t.helpers=P,t.hexGrid=Om,t.inside=fe,t.interpolate=function(t,e,n){if("object"!=typeof(n=n||{}))throw new Error("options is invalid");var r=n.gridType,i=n.property,o=n.weight;if(!t)throw new Error("points is required");if(nt(t,"Point","input must contain Points"),!e)throw new Error("cellSize is required");if(void 0!==o&&"number"!=typeof o)throw new Error("weight must be a number");i=i||"elevation",r=r||"square",o=o||1;var a,s=J(t);switch(r){case"point":case"points":a=zr(s,e,n);break;case"square":case"squares":a=Bm(s,e,n);break;case"hex":case"hexes":a=Om(s,e,n);break;case"triangle":case"triangles":a=Um(s,e,n);break;default:throw new Error("invalid gridType")}var l=[];return k(a,(function(e){var a=0,s=0;k(t,(function(t){var l,u=ge("point"===r?e:dn(e),t,n);if(void 0!==i&&(l=t.properties[i]),void 0===l&&(l=t.geometry.coordinates[2]),void 0===l)throw new Error("zValue is missing");0===u&&(a=l);var c=1/Math.pow(u,o);s+=c,a+=c*l}));var u=be(e);u.properties[i]=a/s,l.push(u)})),f(l)},t.intersect=Nm,t.invariant=ot,t.isNumber=C,t.isObject=I,t.isobands=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.zProperty||"elevation",i=n.commonProperties||{},o=n.breaksProperties||[];if(nt(t,"Point","Input must contain Points"),!e)throw new Error("breaks is required");if(!Array.isArray(e))throw new Error("breaks is not an Array");if(!I(i))throw new Error("commonProperties is not an Object");if(!Array.isArray(o))throw new Error("breaksProperties is not an Array");var a=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.zProperty||"elevation",r=e.flip,i=e.flags;nt(t,"Point","input must contain Points");for(var o=function(t,e){var n={};return k(t,(function(t){var e=Q(t)[1];n[e]||(n[e]=[]),n[e].push(t)})),Object.keys(n).map((function(t){return n[t].sort((function(t,e){return Q(t)[0]-Q(e)[0]}))})).sort((function(t,n){return e?Q(t[0])[1]-Q(n[0])[1]:Q(n[0])[1]-Q(t[0])[1]}))}(t,r),a=[],s=0;s<o.length;s++){for(var l=o[s],u=[],c=0;c<l.length;c++){var h=l[c];h.properties[n]?u.push(h.properties[n]):u.push(0),!0===i&&(h.properties.matrixPosition=[s,c])}a.push(u)}return a}(t,{zProperty:r,flip:!0}),s=function(t,e,n){for(var r=[],i=1;i<e.length;i++){var o=+e[i-1],a=+e[i],s=Po(Lo(Ni(t,o,a-o))),l={};l.groupedRings=s,l[n]=o+"-"+a,r.push(l)}return r}(a,e,r);return f((s=function(t,e,n){var r=J(n),i=r[2]-r[0],o=r[3]-r[1],a=r[0],s=r[1],l=e[0].length-1,u=e.length-1,c=i/l,h=o/u,p=function(t){t[0]=t[0]*c+a,t[1]=t[1]*h+s};return t.forEach((function(t){t.groupedRings.forEach((function(t){t.forEach((function(t){t.forEach(p)}))}))})),t}(s,a,t)).map((function(t,e){if(o[e]&&!I(o[e]))throw new Error("Each mappedProperty is required to be an Object");var n=ut({},i,o[e]);return n[r]=t[r],g(t.groupedRings,n)})))},t.isolines=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.zProperty||"elevation",i=n.commonProperties||{},o=n.breaksProperties||[];if(nt(t,"Point","Input must contain Points"),!e)throw new Error("breaks is required");if(!Array.isArray(e))throw new Error("breaks must be an Array");if(!I(i))throw new Error("commonProperties must be an Object");if(!Array.isArray(o))throw new Error("breaksProperties must be an Array");var a=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.zProperty||"elevation",r=e.flip,i=e.flags;nt(t,"Point","input must contain Points");for(var o=function(t,e){var n={};return k(t,(function(t){var e=Q(t)[1];n[e]||(n[e]=[]),n[e].push(t)})),Object.keys(n).map((function(t){return n[t].sort((function(t,e){return Q(t)[0]-Q(e)[0]}))})).sort((function(t,n){return e?Q(t[0])[1]-Q(n[0])[1]:Q(n[0])[1]-Q(t[0])[1]}))}(t,r),a=[],s=0;s<o.length;s++){for(var l=o[s],u=[],c=0;c<l.length;c++){var h=l[c];h.properties[n]?u.push(h.properties[n]):u.push(0),!0===i&&(h.properties.matrixPosition=[s,c])}a.push(u)}return a}(t,{zProperty:r,flip:!0});return f(function(t,e,n){var r=J(n),i=r[2]-r[0],o=r[3]-r[1],a=r[0],s=r[1],l=e[0].length-1,u=e.length-1,c=i/l,h=o/u,p=function(t){t[0]=t[0]*c+a,t[1]=t[1]*h+s};return t.forEach((function(t){R(t,p)})),t}(function(t,e,n,r,i){for(var o=[],a=1;a<e.length;a++){var s=+e[a],l=ut({},r,i[a]);l[n]=s;var u=d(pt(t,s),l);o.push(u)}return o}(a,e,r,i,o),a,t))},t.kinks=function(t){var e,n,r={type:"FeatureCollection",features:[]};if("LineString"===(n="Feature"===t.type?t.geometry:t).type)e=[n.coordinates];else if("MultiLineString"===n.type)e=n.coordinates;else if("MultiPolygon"===n.type)e=[].concat.apply([],n.coordinates);else{if("Polygon"!==n.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=n.coordinates}return e.forEach((function(t){e.forEach((function(e){for(var n=0;n<t.length-1;n++)for(var i=n;i<e.length-1;i++){if(t===e){if(1===Math.abs(n-i))continue;if(0===n&&i===t.length-2&&t[n][0]===t[t.length-1][0]&&t[n][1]===t[t.length-1][1])continue}var o=br(t[n][0],t[n][1],t[n+1][0],t[n+1][1],e[i][0],e[i][1],e[i+1][0],e[i+1][1]);o&&r.features.push(s([o[0],o[1]]))}}))})),r},t.length=Ar,t.lengthToDegrees=b,t.lengthToRadians=x,t.lineArc=ii,t.lineChunk=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.units,i=n.reverse;if(!t)throw new Error("geojson is required");if(e<=0)throw new Error("segmentLength must be greater than 0");var o=[];return V(t,(function(t){i&&(t.geometry.coordinates=t.geometry.coordinates.reverse()),function(t,e,n,r){var i=Ar(t,{units:n});if(i<=e)return r(t);var o=i/e;Number.isInteger(o)||(o=Math.floor(o)+1);for(var a=0;a<o;a++)r(Lr(t,e*a,e*(a+1),{units:n}))}(t,e,r,(function(t){o.push(t)}))})),f(o)},t.lineDistance=Ar,t.lineEach=q,t.lineIntersect=dr,t.lineOffset=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.units;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("distance is required");var i=it(t),o=t.properties;switch(i){case"LineString":return Bo(t,e,r);case"MultiLineString":var a=[];return V(t,(function(t){a.push(Bo(t,e,r).geometry.coordinates)})),d(a,o);default:throw new Error("geometry "+i+" is not supported")}},t.lineOverlap=_i,t.lineReduce=W,t.lineSegment=jn,t.lineSlice=function(t,e,n){var r=Q(n);if("LineString"!==it(n))throw new Error("line must be a LineString");for(var i,o=gr(n,t),a=gr(n,e),s=[(i=o.properties.index<=a.properties.index?[o,a]:[a,o])[0].geometry.coordinates],l=i[0].properties.index+1;l<i[1].properties.index+1;l++)s.push(r[l]);return s.push(i[1].geometry.coordinates),h(s,n.properties)},t.lineSliceAlong=Lr,t.lineSplit=function(t,e){if(!t)throw new Error("line is required");if(!e)throw new Error("splitter is required");var n=it(t),r=it(e);if("LineString"!==n)throw new Error("line must be LineString");if("FeatureCollection"===r)throw new Error("splitter cannot be a FeatureCollection");if("GeometryCollection"===r)throw new Error("splitter cannot be a GeometryCollection");var i=Fr(e,{precision:7});switch(r){case"Point":return ei(t,i);case"MultiPoint":return ti(t,i);case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":return ti(t,dr(t,i))}},t.lineString=h,t.lineStringToPolygon=ui,t.lineStrings=p,t.lineToPolygon=ui,t.mask=function(t,e){var n,r=function(t){return u(t&&t.geometry.coordinates||[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]])}(e);return("FeatureCollection"===t.type?Fm(2===(n=t).features.length?Ll.union(n.features[0].geometry.coordinates,n.features[1].geometry.coordinates):Ll.union.apply(Ll,n.features.map((function(t){return t.geometry.coordinates})))):Fm(Ll.union(t.geometry.coordinates))).geometry.coordinates.forEach((function(t){r.geometry.coordinates.push(t[0])})),r},t.meta=Y,t.midpoint=function(t,e){return cn(t,ge(t,e)/2,pn(t,e))},t.moranIndex=function(t,e){var n=e.inputField,r=e.threshold||1e5,i=e.p||2,o=e.binary||!1,a=xs(t,{alpha:e.alpha||-1,binary:o,p:i,standardization:e.standardization||!0,threshold:r}),s=[];k(t,(function(t){var e=t.properties||{};s.push(e[n])}));for(var l=bs(s),u=function(t){for(var e=bs(t),n=0,r=0,i=t;r<i.length;r++){var o=i[r];n+=Math.pow(o-e,2)}return n/t.length}(s),c=0,h=0,p=0,f=0,d=a.length,m=0;m<d;m++){for(var g=0,y=0;y<d;y++)c+=a[m][y]*(s[m]-l)*(s[y]-l),h+=a[m][y],p+=Math.pow(a[m][y]+a[y][m],2),g+=a[m][y]+a[y][m];f+=Math.pow(g,2)}var v=c/h/u,_=-1/(d-1),x=(d*d*(p*=.5)-d*f+h*h*3)/((d-1)*(d+1)*(h*h))-_*_,b=Math.sqrt(x);return{expectedMoranIndex:_,moranIndex:v,stdNorm:b,zNorm:(v-_)/b}},t.multiLineString=d,t.multiPoint=m,t.multiPolygon=g,t.nearest=Gn,t.nearestPoint=Gn,t.nearestPointOnLine=gr,t.nearestPointToLine=function(t,e,n){void 0===n&&(n={});var r=n.units,i=n.properties||{},o=function(t){var e=[];switch(t.geometry?t.geometry.type:t.type){case"GeometryCollection":return B(t,(function(t){"Point"===t.type&&e.push({type:"Feature",properties:{},geometry:t})})),{type:"FeatureCollection",features:e};case"FeatureCollection":return t.features=t.features.filter((function(t){return"Point"===t.geometry.type})),t;default:throw new Error("points must be a Point Collection")}}(t);if(!o.features.length)throw new Error("points must contain features");if(!e)throw new Error("line is required");if("LineString"!==it(e))throw new Error("line must be a LineString");var a=1/0,s=null;return k(o,(function(t){var n=vr(t,e,{units:r});n<a&&(a=n,s=t)})),s&&(s.properties=ut({dist:a},s.properties,i)),s},t.planepoint=function(t,e){var n=K(t),r=rt(e).coordinates[0];if(r.length<4)throw new Error("OuterRing of a Polygon must have 4 or more Positions.");var i=e.properties||{},o=i.a,a=i.b,s=i.c,l=n[0],u=n[1],c=r[0][0],h=r[0][1],p=void 0!==o?o:r[0][2],f=r[1][0],d=r[1][1],m=void 0!==a?a:r[1][2],g=r[2][0],y=r[2][1],v=void 0!==s?s:r[2][2];return(v*(l-c)*(u-d)+p*(l-f)*(u-y)+m*(l-g)*(u-h)-m*(l-c)*(u-y)-v*(l-f)*(u-h)-p*(l-g)*(u-d))/((l-c)*(u-d)+(l-f)*(u-y)+(l-g)*(u-h)-(l-c)*(u-y)-(l-f)*(u-h)-(l-g)*(u-d))},t.point=s,t.pointGrid=zr,t.pointOnFeature=wr,t.pointOnLine=gr,t.pointOnSurface=wr,t.pointToLineDistance=vr,t.points=l,t.pointsWithinPolygon=me,t.polygon=u,t.polygonSmooth=function(t,e){var n=[],r=e.iterations||1;if(!t)throw new Error("inputPolys is required");return B(t,(function(t,e,i){var o,a,s;switch(t.type){case"Polygon":o=[[]];for(var l=0;l<r;l++)s=[[]],a=t,l>0&&(a=u(o).geometry),ys(a,s),o=s.slice(0);n.push(u(o,i));break;case"MultiPolygon":o=[[[]]];for(var c=0;c<r;c++)s=[[[]]],a=t,c>0&&(a=g(o).geometry),vs(a,s),o=s.slice(0);n.push(g(o,i));break;default:throw new Error("geometry is invalid, must be Polygon or MultiPolygon")}})),f(n)},t.polygonTangents=function(t,e){var n,r,i,o,a=Q(t),l=Q(e),u=J(e),c=0,h=null;switch(a[0]>u[0]&&a[0]<u[2]&&a[1]>u[1]&&a[1]<u[3]&&(c=(h=Gn(t,mn(e))).properties.featureIndex),it(e)){case"Polygon":n=l[0][c],r=l[0][0],null!==h&&h.geometry.coordinates[1]<a[1]&&(r=l[0][c]),o=Ci(l[0][0],l[0][l[0].length-1],a);var p=Mi(l[0],a,o,i,n,r);n=p[0],r=p[1];break;case"MultiPolygon":for(var d=0,m=0,g=0,y=0;y<l[0].length;y++){d=y;for(var v=!1,_=0;_<l[0][y].length;_++){if(m=_,g===c){v=!0;break}g++}if(v)break}n=l[0][d][m],r=l[0][d][m],o=Ci(l[0][0][0],l[0][0][l[0][0].length-1],a),l.forEach((function(t){var e=Mi(t[0],a,o,i,n,r);n=e[0],r=e[1]}))}return f([s(n),s(r)])},t.polygonToLine=ai,t.polygonToLineString=ai,t.polygonize=function(t){var e=qo.fromGeoJson(t);e.deleteDangles(),e.deleteCutEdges();var n=[],r=[];return e.getEdgeRings().filter((function(t){return t.isValid()})).forEach((function(t){t.isHole()?n.push(t):r.push(t)})),n.forEach((function(t){Ho.findEdgeRingContaining(t,r)&&r.push(t)})),f(r.map((function(t){return t.toPolygon()})))},t.polygons=c,t.projection=Cs,t.propEach=N,t.propReduce=O,t.propertiesContainsFilter=Us,t.radians2degrees=E,t.radiansToDegrees=E,t.radiansToDistance=_,t.radiansToLength=_,t.random=Ns,t.randomLineString=Ps,t.randomPoint=As,t.randomPolygon=Ls,t.randomPosition=Is,t.rewind=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.reverse||!1,r=e.mutate||!1;if(!t)throw new Error("<geojson> is required");if("boolean"!=typeof n)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof r)throw new Error("<mutate> must be a boolean");!1===r&&(t=be(t));var i=[];switch(t.type){case"GeometryCollection":return B(t,(function(t){Ai(t,n)})),t;case"FeatureCollection":return k(t,(function(t){k(Ai(t,n),(function(t){i.push(t)}))})),f(i)}return Ai(t,n)},t.rhumbBearing=wi,t.rhumbDestination=Si,t.rhumbDistance=yr,t.round=v,t.sample=function(t,e){if(!t)throw new Error("featurecollection is required");if(null==e)throw new Error("num is required");if("number"!=typeof e)throw new Error("num must be a number");return f(function(t,e){for(var n,r,i=t.slice(0),o=t.length,a=o-e;o-- >a;)n=i[r=Math.floor((o+1)*Math.random())],i[r]=i[o],i[o]=n;return i.slice(a)}(t.features,e))},t.sector=function(t,e,n,r,i){if(!I(i=i||{}))throw new Error("options is invalid");var o=i.properties;if(!t)throw new Error("center is required");if(null==n)throw new Error("bearing1 is required");if(null==r)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if("object"!=typeof i)throw new Error("options must be an object");if(bi(n)===bi(r))return hn(t,e,i);var a=Q(t),s=ii(t,e,n,r,i),l=[[a]];return R(s,(function(t){l[0].push(t)})),l[0].push(a),u(l,o)},t.segmentEach=j,t.segmentReduce=H,t.shortestPath=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.resolution,i=n.minDistance,a=n.obstacles||f([]);if(!t)throw new Error("start is required");if(!e)throw new Error("end is required");if(r&&!C(r)||r<=0)throw new Error("options.resolution must be a number, greater than 0");if(i)throw new Error("options.minDistance is not yet implemented");var l=K(t),u=K(e);switch(t=s(l),e=s(u),it(a)){case"FeatureCollection":if(0===a.features.length)return h([l,u]);break;case"Polygon":a=f([o(rt(a))]);break;default:throw new Error("invalid obstacles")}var c=a;c.features.push(t),c.features.push(e);var p=J(Oo(sn(J(c)),1.15));r||(r=ge([p[0],p[1]],[p[2],p[1]],n)/100),c.features.pop(),c.features.pop();for(var d=p[0],m=p[1],g=p[2],y=p[3],v=r/ge([d,m],[g,m],n)*(g-d),_=r/ge([d,m],[d,y],n)*(y-m),x=g-d,b=y-m,w=Math.floor(x/v),E=Math.floor(b/_),S=(x-w*v)/2,M=[],T=[],A=[],L=[],P=1/0,R=1/0,D=y-(b-E*_)/2,N=0;D>=m;){for(var O=[],k=[],z=d+S,F=0;z<=g;){var B=s([z,D]),U=Ca(B,a);O.push(U?0:1),k.push(z+"|"+D);var V=ge(B,t);!U&&V<P&&(P=V,A={x:F,y:N});var G=ge(B,e);!U&&G<R&&(R=G,L={x:F,y:N}),z+=v,F++}T.push(O),M.push(k),D-=_,N++}var j=new Sa(T,{diagonal:!0}),H=j.grid[A.y][A.x],q=j.grid[L.y][L.x],W=Ea.search(j,H,q),X=[l];return W.forEach((function(t){var e=M[t.x][t.y].split("|");X.push([+e[0],+e[1]])})),X.push(u),Xe(h(X))},t.simplify=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=void 0!==e.tolerance?e.tolerance:1,r=e.highQuality||!1,i=e.mutate||!1;if(!t)throw new Error("geojson is required");if(n&&n<0)throw new Error("invalid tolerance");return!0!==i&&(t=be(t)),B(t,(function(t){!function(t,e,n){var r=t.type;if("Point"===r||"MultiPoint"===r)return t;Xe(t,!0);var i=t.coordinates;switch(r){case"LineString":t.coordinates=en(i,e,n);break;case"MultiLineString":t.coordinates=i.map((function(t){return en(t,e,n)}));break;case"Polygon":t.coordinates=nn(i,e,n);break;case"MultiPolygon":t.coordinates=i.map((function(t){return nn(t,e,n)}))}}(t,n,r)})),t},t.square=un,t.squareGrid=Bm,t.standardDeviationalEllipse=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.steps||64,r=e.weight,i=e.properties||{};if(!C(n))throw new Error("steps must be a number");if(!I(i))throw new Error("properties must be a number");var o=F(t).length,a=ds(t,{weight:r}),s=0,l=0,u=0;k(t,(function(t){var e=t.properties[r]||1,n=gs(Q(t),Q(a));s+=Math.pow(n.x,2)*e,l+=Math.pow(n.y,2)*e,u+=n.x*n.y*e}));var c=s-l,h=Math.sqrt(Math.pow(c,2)+4*Math.pow(u,2)),p=2*u,d=Math.atan((c+h)/p),m=180*d/Math.PI,g=0,y=0,v=0;k(t,(function(t){var e=t.properties[r]||1,n=gs(Q(t),Q(a));g+=Math.pow(n.x*Math.cos(d)-n.y*Math.sin(d),2)*e,y+=Math.pow(n.x*Math.sin(d)+n.y*Math.cos(d),2)*e,v+=e}));var _=Math.sqrt(2*g/v),x=Math.sqrt(2*y/v),b=ps(a,_,x,{units:"degrees",angle:m,steps:n,properties:i}),w=me(t,f([b])),E={meanCenterCoordinates:Q(a),semiMajorAxis:_,semiMinorAxis:x,numberOfFeatures:o,angle:m,percentageWithinEllipse:100*F(w).length/o};return b.properties.standardDeviationalEllipse=E,b},t.tag=function(t,e,n,r){return t=be(t),e=be(e),k(t,(function(t){t.properties||(t.properties={}),k(e,(function(e){void 0===t.properties[r]&&fe(t,e)&&(t.properties[r]=e.properties[n])}))})),t},t.tesselate=function(t){if(!t.geometry||"Polygon"!==t.geometry.type&&"MultiPolygon"!==t.geometry.type)throw new Error("input must be a Polygon or MultiPolygon");var e={type:"FeatureCollection",features:[]};return"Polygon"===t.geometry.type?e.features=Vn(t.geometry.coordinates):t.geometry.coordinates.forEach((function(t){e.features=e.features.concat(Vn(t))})),e},t.tin=ye,t.toMercator=ws,t.toWgs84=Es,t.transformRotate=No,t.transformScale=Oo,t.transformTranslate=function(t,e,n,r){if(!I(r=r||{}))throw new Error("options is invalid");var i=r.units,o=r.zTranslation,a=r.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("distance is required");if(o&&"number"!=typeof o&&isNaN(o))throw new Error("zTranslation is not a number");if(o=void 0!==o?o:0,0===e&&0===o)return t;if(null==n||isNaN(n))throw new Error("direction is required");return e<0&&(e=-e,n+=180),!1!==a&&void 0!==a||(t=be(t)),R(t,(function(t){var r=Q(Si(t,e,n,{units:i}));t[0]=r[0],t[1]=r[1],o&&3===t.length&&(t[2]+=o)})),t},t.triangleGrid=Um,t.truncate=Fr,t.union=function(t,e,n){void 0===n&&(n={});var r=rt(t),i=rt(e),o=Ll.union(r.coordinates,i.coordinates);return 0===o.length?null:1===o.length?u(o[0],n.properties):g(o,n.properties)},t.unitsFactors=r,t.unkinkPolygon=function(t){var e=[];return V(t,(function(t){"Polygon"===t.geometry.type&&k(Vr(t),(function(n){e.push(u(n.geometry.coordinates,t.properties))}))})),f(e)},t.validateBBox=A,t.validateId=L,t.voronoi=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.bbox||[-180,-85,180,85];if(!t)throw new Error("points is required");if(!Array.isArray(n))throw new Error("bbox is invalid");return nt(t,"Point","points"),f(function(){var t=Aa,e=La,n=null;function r(r){return new cs(r.map((function(n,i){var o=[Math.round(t(n,i,r)/ss)*ss,Math.round(e(n,i,r)/ss)*ss];return o.index=i,o.data=n,o})),n)}return r.polygons=function(t){return r(t).polygons()},r.links=function(t){return r(t).links()},r.triangles=function(t){return r(t).triangles()},r.x=function(e){return arguments.length?(t="function"==typeof e?e:Ia(+e),r):t},r.y=function(t){return arguments.length?(e="function"==typeof t?t:Ia(+t),r):e},r.extent=function(t){return arguments.length?(n=null==t?null:[[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]],r):n&&[[n[0][0],n[0][1]],[n[1][0],n[1][1]]]},r.size=function(t){return arguments.length?(n=null==t?null:[[0,0],[+t[0],+t[1]]],r):n&&[n[1][0]-n[0][0],n[1][1]-n[0][1]]},r}().x((function(t){return t.geometry.coordinates[0]})).y((function(t){return t.geometry.coordinates[1]})).extent([[n[0],n[1]],[n[2],n[3]]]).polygons(t.features).map(hs))},t.within=me,Object.defineProperty(t,"__esModule",{value:!0})}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).maplibregl=e()}(this,(function(){"use strict";var t,e,n;function r(r,i){if(t)if(e){var o="var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk);",a={};t(a);n=i(a);"undefined"!=typeof window&&(n.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=i;else t=i}r(0,(function(t){function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=r;function r(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=n,this.p2y=r}r.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},r.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},r.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},r.prototype.solveCurveX=function(t,e){var n,r,i,o,a;for(void 0===e&&(e=1e-6),i=t,a=0;a<8;a++){if(o=this.sampleCurveX(i)-t,Math.abs(o)<e)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=o/s}if((i=t)<(n=0))return n;if(i>(r=1))return r;for(;n<r;){if(o=this.sampleCurveX(i),Math.abs(o-t)<e)return i;t>o?n=i:r=i,i=.5*(r-n)+n}return i},r.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var i=o;function o(t,e){this.x=t,this.y=e}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=r,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-r*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(t){return t instanceof o?t:Array.isArray(t)?new o(t[0],t[1]):t};var a="undefined"!=typeof self?self:{},s=Math.pow(2,53)-1;function l(t,e,r,i){var o=new n(t,e,r,i);return function(t){return o.solve(t)}}var u=l(.25,.1,.25,1);function c(t,e,n){return Math.min(n,Math.max(e,t))}function h(t,e,n){var r=n-e,i=((t-e)%r+r)%r+e;return i===e?n:i}function p(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r<i.length;r+=1){var o=i[r];for(var a in o)t[a]=o[a]}return t}var f=1;function d(){return f++}function m(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function g(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function y(t,e){t.forEach((function(t){e[t]&&(e[t]=e[t].bind(e))}))}function v(t,e){return-1!==t.indexOf(e,t.length-e.length)}function _(t,e,n){var r={};for(var i in t)r[i]=e.call(n||this,t[i],i,t);return r}function x(t,e,n){var r={};for(var i in t)e.call(n||this,t[i],i,t)&&(r[i]=t[i]);return r}function b(t){return Array.isArray(t)?t.map(b):"object"==typeof t&&t?_(t,b):t}var w={};function E(t){w[t]||("undefined"!=typeof console&&console.warn(t),w[t]=!0)}function S(t,e,n){return(n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function M(t){for(var e=0,n=0,r=t.length,i=r-1,o=void 0,a=void 0;n<r;i=n++)e+=((a=t[i]).x-(o=t[n]).x)*(o.y+a.y);return e}function T(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function C(t){var e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(t,n,r,i){var o=r||i;return e[n]=!o||o.toLowerCase(),""})),e["max-age"]){var n=parseInt(e["max-age"],10);isNaN(n)?delete e["max-age"]:e["max-age"]=n}return e}var I=null;function A(t){if(null==I){var e=t.navigator?t.navigator.userAgent:null;I=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return I}function L(t){try{var e=a[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}var P,R,D,N,O=a.performance&&a.performance.now?a.performance.now.bind(a.performance):Date.now.bind(Date),k=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame,z=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame,F={now:O,frame:function(t){var e=k(t);return{cancel:function(){return z(e)}}},getImageData:function(t,e){void 0===e&&(e=0);var n=a.document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return n.width=t.width,n.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:function(t){return P||(P=a.document.createElement("a")),P.href=t,P.href},hardwareConcurrency:a.navigator&&a.navigator.hardwareConcurrency||4,get devicePixelRatio(){return a.devicePixelRatio},get prefersReducedMotion(){return!!a.matchMedia&&(null==R&&(R=a.matchMedia("(prefers-reduced-motion: reduce)")),R.matches)}},B={API_URL:"https://api.mapbox.com",get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},FEEDBACK_URL:"https://apps.mapbox.com/feedback",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},U={supported:!1,testSupport:function(t){!V&&N&&(G?j(t):D=t)}},V=!1,G=!1;function j(t){var e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,N),t.isContextLost())return;U.supported=!0}catch(t){}t.deleteTexture(e),V=!0}a.document&&((N=a.document.createElement("img")).onload=function(){D&&j(D),D=null,G=!0},N.onerror=function(){V=!0,D=null},N.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var H="01",q=function(t,e){this._transformRequestFn=t,this._customAccessToken=e,this._createSkuToken()};function W(t){return 0===t.indexOf("mapbox:")}q.prototype._createSkuToken=function(){var t=function(){for(var t="",e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",H,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt},q.prototype._isSkuTokenExpired=function(){return Date.now()>this._skuTokenExpiresAt},q.prototype.transformRequest=function(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}},q.prototype.normalizeStyleURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeGlyphsURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeSourceURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/v4/"+n.authority+".json",n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeSpriteURL=function(t,e,n,r){var i=J(t);return W(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+n,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=""+e+n,K(i))},q.prototype.normalizeTileURL=function(t,e){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!W(t))return t;var n=J(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,(F.devicePixelRatio>=2||512===e?"@2x":"")+(U.supported?".webp":"$1")),n.path=n.path.replace(/^.+\/v4\//,"/"),n.path="/v4"+n.path;var r=this._customAccessToken||function(t){for(var e=0,n=t;e<n.length;e+=1){var r=n[e].match(/^access_token=(.*)$/);if(r)return r[1]}return null}(n.params)||B.ACCESS_TOKEN;return B.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&n.params.push("sku="+this._skuToken),this._makeAPIURL(n,r)},q.prototype.canonicalizeTileURL=function(t,e){var n=J(t);if(!n.path.match(/(^\/v4\/)/)||!n.path.match(/\.[\w]+$/))return t;var r="mapbox://tiles/";r+=n.path.replace("/v4/","");var i=n.params;return e&&(i=i.filter((function(t){return!t.match(/^access_token=/)}))),i.length&&(r+="?"+i.join("&")),r},q.prototype.canonicalizeTileset=function(t,e){for(var n=!!e&&W(e),r=[],i=0,o=t.tiles||[];i<o.length;i+=1){var a=o[i];Z(a)?r.push(this.canonicalizeTileURL(a,n)):r.push(a)}return r},q.prototype._makeAPIURL=function(t,e){var n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=J(B.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){var i=t.params.indexOf("secure");i>=0&&t.params.splice(i,1)}if("/"!==r.path&&(t.path=""+r.path+t.path),!B.REQUIRE_ACCESS_TOKEN)return K(t);if(!(e=e||B.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n);return t.params=t.params.filter((function(t){return-1===t.indexOf("access_token")})),t.params.push("access_token="+e),K(t)},q.prototype.setTransformRequest=function(t){this._transformRequestFn=t};var X=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;function Z(t){return X.test(t)}var Y=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function J(t){var e=t.match(Y);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function K(t){var e=t.params.length?"?"+t.params.join("&"):"";return t.protocol+"://"+t.authority+t.path+e}function Q(t){if(!t)return null;var e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(a.atob(e[1]).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return null}}var $=function(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null};$.prototype.getStorageKey=function(t){var e,n=Q(B.ACCESS_TOKEN);return e=n&&n.u?a.btoa(encodeURIComponent(n.u).replace(/%([0-9A-F]{2})/g,(function(t,e){return String.fromCharCode(Number("0x"+e))}))):B.ACCESS_TOKEN||"",t?"mapbox.eventData."+t+":"+e:"mapbox.eventData:"+e},$.prototype.fetchEventData=function(){var t=L("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{var r=a.localStorage.getItem(e);r&&(this.eventData=JSON.parse(r));var i=a.localStorage.getItem(n);i&&(this.anonId=i)}catch(t){E("Unable to read from LocalStorage")}},$.prototype.saveEventData=function(){var t=L("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{a.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&a.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){E("Unable to write to LocalStorage")}},$.prototype.processRequests=function(t){},$.prototype.postEvent=function(t,e,n,r){var i=this;if(B.EVENTS_URL){var o=J(B.EVENTS_URL);o.params.push("access_token="+(r||B.ACCESS_TOKEN||""));var a={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:"1.15.2",skuId:H,userId:this.anonId},s=e?p(a,e):a,l={url:K(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=wt(l,(function(t){i.pendingRequest=null,n(t),i.saveEventData(),i.processRequests(r)}))}},$.prototype.queueRequest=function(t,e){this.queue.push(t),this.processRequests(e)};var tt,et,nt=function(t){function e(){t.call(this,"map.load"),this.success={},this.skuToken=""}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postMapLoadEvent=function(t,e,n,r){this.skuToken=n,(B.EVENTS_URL&&r||B.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return W(t)||Z(t)})))&&this.queueRequest({id:e,timestamp:Date.now()},r)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){var n=this.queue.shift(),r=n.id,i=n.timestamp;r&&this.success[r]||(this.anonId||this.fetchEventData(),g(this.anonId)||(this.anonId=m()),this.postEvent(i,{skuToken:this.skuToken},(function(t){t||r&&(e.success[r]=!0)}),t))}},e}($),rt=new(function(t){function e(e){t.call(this,"appUserTurnstile"),this._customAccessToken=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postTurnstileEvent=function(t,e){B.EVENTS_URL&&B.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return W(t)||Z(t)}))&&this.queueRequest(Date.now(),e)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var n=Q(B.ACCESS_TOKEN),r=n?n.u:B.ACCESS_TOKEN,i=r!==this.eventData.tokenU;g(this.anonId)||(this.anonId=m(),i=!0);var o=this.queue.shift();if(this.eventData.lastSuccess){var a=new Date(this.eventData.lastSuccess),s=new Date(o),l=(o-this.eventData.lastSuccess)/864e5;i=i||l>=1||l<-1||a.getDate()!==s.getDate()}else i=!0;if(!i)return this.processRequests();this.postEvent(o,{"enabled.telemetry":!1},(function(t){t||(e.eventData.lastSuccess=o,e.eventData.tokenU=r)}),t)}},e}($)),it=rt.postTurnstileEvent.bind(rt),ot=new nt,at=ot.postMapLoadEvent.bind(ot),st=500,lt=50;function ut(){a.caches&&!tt&&(tt=a.caches.open("mapbox-tiles"))}function ct(t){var e=t.indexOf("?");return e<0?t:t.slice(0,e)}var ht,pt=1/0;function ft(){return null==ht&&(ht=a.OffscreenCanvas&&new a.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.createImageBitmap),ht}var dt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(dt);var mt=function(t){function e(e,n,r){401===n&&Z(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),t.call(this,e),this.status=n,this.url=r,this.name=this.constructor.name,this.message=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.toString=function(){return this.name+": "+this.message+" ("+this.status+"): "+this.url},e}(Error),gt=T()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===a.location.protocol?a.parent:a).location.href};function yt(t,e){var n,r=new a.AbortController,i=new a.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:gt(),signal:r.signal}),o=!1,s=!1,l=(n=i.url).indexOf("sku=")>0&&Z(n);"json"===t.type&&i.headers.set("Accept","application/json");var u=function(n,r,o){if(!s){if(n&&"SecurityError"!==n.message&&E(n),r&&o)return c(r);var u=Date.now();a.fetch(i).then((function(n){if(n.ok){var r=l?n.clone():null;return c(n,r,u)}return e(new mt(n.statusText,n.status,t.url))})).catch((function(t){20!==t.code&&e(new Error(t.message))}))}},c=function(n,r,l){("arrayBuffer"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text()).then((function(t){s||(r&&l&&function(t,e,n){if(ut(),tt){var r={status:e.status,statusText:e.statusText,headers:new a.Headers};e.headers.forEach((function(t,e){return r.headers.set(e,t)}));var i=C(e.headers.get("Cache-Control")||"");i["no-store"]||(i["max-age"]&&r.headers.set("Expires",new Date(n+1e3*i["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-n<42e4||function(t,e){if(void 0===et)try{new Response(new ReadableStream),et=!0}catch(t){et=!1}et?e(t.body):t.blob().then(e)}(e,(function(e){var n=new a.Response(e,r);ut(),tt&&tt.then((function(e){return e.put(ct(t.url),n)})).catch((function(t){return E(t.message)}))})))}}(i,r,l),o=!0,e(null,t,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((function(t){s||e(new Error(t.message))}))};return l?function(t,e){if(ut(),!tt)return e(null);var n=ct(t.url);tt.then((function(t){t.match(n).then((function(r){var i=function(t){if(!t)return!1;var e=new Date(t.headers.get("Expires")||0),n=C(t.headers.get("Cache-Control")||"");return e>Date.now()&&!n["no-cache"]}(r);t.delete(n),i&&t.put(n,r.clone()),e(null,r,i)})).catch(e)})).catch(e)}(i,u):u(null,null),{cancel:function(){s=!0,o||r.abort()}}}var vt,_t,xt=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!T()){var n=t.url.substring(0,t.url.indexOf("://"));return(B.REGISTERED_PROTOCOLS[n]||yt)(t,e)}}if(!(/^file:/.test(r=t.url)||/^file:/.test(gt())&&!/^\w+:/.test(r))){if(a.fetch&&a.Request&&a.AbortController&&a.Request.prototype.hasOwnProperty("signal"))return yt(t,e);if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){var n=new a.XMLHttpRequest;for(var r in n.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(n.responseType="arraybuffer"),t.headers)n.setRequestHeader(r,t.headers[r]);return"json"===t.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=function(){e(new Error(n.statusText))},n.onload=function(){if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){var r=n.response;if("json"===t.type)try{r=JSON.parse(n.response)}catch(t){return e(t)}e(null,r,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else e(new mt(n.statusText,n.status,t.url))},n.send(t.body),{cancel:function(){return n.abort()}}}(t,e)},bt=function(t,e){return xt(p(t,{type:"arrayBuffer"}),e)},wt=function(t,e){return xt(p(t,{method:"POST"}),e)},Et="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";vt=[],_t=0;var St=function(t,e){if(U.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),_t>=B.MAX_PARALLEL_IMAGE_REQUESTS){var n={requestParameters:t,callback:e,cancelled:!1,cancel:function(){this.cancelled=!0}};return vt.push(n),n}_t++;var r=!1,i=function(){if(!r)for(r=!0,_t--;vt.length&&_t<B.MAX_PARALLEL_IMAGE_REQUESTS;){var t=vt.shift();t.cancelled||(t.cancel=St(t.requestParameters,t.callback).cancel)}},o=bt(t,(function(t,n,r,o){i(),t?e(t):n&&(ft()?function(t,e){var n=new a.Blob([new Uint8Array(t)],{type:"image/png"});a.createImageBitmap(n).then((function(t){e(null,t)})).catch((function(t){e(new Error("Could not load image because of "+t.message+". Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))}))}(n,e):function(t,e,n,r){var i=new a.Image,o=a.URL;i.onload=function(){e(null,i),o.revokeObjectURL(i.src),i.onload=null,a.requestAnimationFrame((function(){i.src=Et}))},i.onerror=function(){return e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))};var s=new a.Blob([new Uint8Array(t)],{type:"image/png"});i.cacheControl=n,i.expires=r,i.src=t.byteLength?o.createObjectURL(s):Et}(n,e,r,o))}));return{cancel:function(){o.cancel(),i()}}};function Mt(t,e,n){n[t]&&-1!==n[t].indexOf(e)||(n[t]=n[t]||[],n[t].push(e))}function Tt(t,e,n){if(n&&n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}var Ct=function(t,e){void 0===e&&(e={}),p(this,e),this.type=t},It=function(t){function e(e,n){void 0===n&&(n={}),t.call(this,"error",p({error:e},n))}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Ct),At=function(){};At.prototype.on=function(t,e){return this._listeners=this._listeners||{},Mt(t,e,this._listeners),this},At.prototype.off=function(t,e){return Tt(t,e,this._listeners),Tt(t,e,this._oneTimeListeners),this},At.prototype.once=function(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},Mt(t,e,this._oneTimeListeners),this},At.prototype.fire=function(t,e){"string"==typeof t&&(t=new Ct(t,e||{}));var n=t.type;if(this.listens(n)){t.target=this;for(var r=0,i=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];r<i.length;r+=1)i[r].call(this,t);for(var o=0,a=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];o<a.length;o+=1){var s=a[o];Tt(n,s,this._oneTimeListeners),s.call(this,t)}var l=this._eventedParent;l&&(p(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),l.fire(t))}else t instanceof It&&console.error(t.error);return this},At.prototype.listens=function(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},At.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var Lt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}},Pt=function(t,e,n,r){this.message=(t?t+": ":"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)};function Rt(t){var e=t.value;return e?[new Pt(t.key,e,"constants have been deprecated as of v8")]:[]}function Dt(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r<i.length;r+=1){var o=i[r];for(var a in o)t[a]=o[a]}return t}function Nt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ot(t){if(Array.isArray(t))return t.map(Ot);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){var e={};for(var n in t)e[n]=Ot(t[n]);return e}return Nt(t)}var kt=function(t){function e(e,n){t.call(this,n),this.message=n,this.key=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),zt=function(t,e){void 0===e&&(e=[]),this.parent=t,this.bindings={};for(var n=0,r=e;n<r.length;n+=1){var i=r[n];this.bindings[i[0]]=i[1]}};zt.prototype.concat=function(t){return new zt(this,t)},zt.prototype.get=function(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(t+" not found in scope.")},zt.prototype.has=function(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)};var Ft={kind:"null"},Bt={kind:"number"},Ut={kind:"string"},Vt={kind:"boolean"},Gt={kind:"color"},jt={kind:"object"},Ht={kind:"value"},qt={kind:"collator"},Wt={kind:"formatted"},Xt={kind:"resolvedImage"};function Zt(t,e){return{kind:"array",itemType:t,N:e}}function Yt(t){if("array"===t.kind){var e=Yt(t.itemType);return"number"==typeof t.N?"array<"+e+", "+t.N+">":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var Jt=[Ft,Bt,Ut,Vt,Gt,Wt,jt,Zt(Ht),Xt];function Kt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Kt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var n=0,r=Jt;n<r.length;n+=1)if(!Kt(r[n],e))return null}return"Expected "+Yt(t)+" but found "+Yt(e)+" instead."}function Qt(t,e){return e.some((function(e){return e.kind===t.kind}))}function $t(t,e){return e.some((function(e){return"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t}))}var te=e((function(t,e){var n={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function r(t){return(t=Math.round(t))<0?0:t>255?255:t}function i(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function a(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{e.parseCSSColor=function(t){var e,s=t.replace(/ /g,"").toLowerCase();if(s in n)return n[s].slice();if("#"===s[0])return 4===s.length?(e=parseInt(s.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===s.length&&(e=parseInt(s.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[i(h[0]),i(h[1]),i(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,d=o(h[1]),m=o(h[2]),g=m<=.5?m*(d+1):m+d-m*d,y=2*m-g;return[r(255*a(y,g,f+1/3)),r(255*a(y,g,f)),r(255*a(y,g,f-1/3)),p];default:return null}}return null}}catch(t){}})).parseCSSColor,ee=function(t,e,n,r){void 0===r&&(r=1),this.r=t,this.g=e,this.b=n,this.a=r};ee.parse=function(t){if(t){if(t instanceof ee)return t;if("string"==typeof t){var e=te(t);if(e)return new ee(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},ee.prototype.toString=function(){var t=this.toArray(),e=t[1],n=t[2],r=t[3];return"rgba("+Math.round(t[0])+","+Math.round(e)+","+Math.round(n)+","+r+")"},ee.prototype.toArray=function(){var t=this.a;return 0===t?[0,0,0,0]:[255*this.r/t,255*this.g/t,255*this.b/t,t]},ee.black=new ee(0,0,0,1),ee.white=new ee(1,1,1,1),ee.transparent=new ee(0,0,0,0),ee.red=new ee(1,0,0,1);var ne=function(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};ne.prototype.compare=function(t,e){return this.collator.compare(t,e)},ne.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var re=function(t,e,n,r,i){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i},ie=function(t){this.sections=t};ie.fromString=function(t){return new ie([new re(t,null,null,null,null)])},ie.prototype.isEmpty=function(){return 0===this.sections.length||!this.sections.some((function(t){return 0!==t.text.length||t.image&&0!==t.image.name.length}))},ie.factory=function(t){return t instanceof ie?t:ie.fromString(t)},ie.prototype.toString=function(){return 0===this.sections.length?"":this.sections.map((function(t){return t.text})).join("")},ie.prototype.serialize=function(){for(var t=["format"],e=0,n=this.sections;e<n.length;e+=1){var r=n[e];if(r.image)t.push(["image",r.image.name]);else{t.push(r.text);var i={};r.fontStack&&(i["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(i["font-scale"]=r.scale),r.textColor&&(i["text-color"]=["rgba"].concat(r.textColor.toArray())),t.push(i)}}return t};var oe=function(t){this.name=t.name,this.available=t.available};function ae(t,e,n,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value ["+[t,e,n,r].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function se(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ee)return!0;if(t instanceof ne)return!0;if(t instanceof ie)return!0;if(t instanceof oe)return!0;if(Array.isArray(t)){for(var e=0,n=t;e<n.length;e+=1)if(!se(n[e]))return!1;return!0}if("object"==typeof t){for(var r in t)if(!se(t[r]))return!1;return!0}return!1}function le(t){if(null===t)return Ft;if("string"==typeof t)return Ut;if("boolean"==typeof t)return Vt;if("number"==typeof t)return Bt;if(t instanceof ee)return Gt;if(t instanceof ne)return qt;if(t instanceof ie)return Wt;if(t instanceof oe)return Xt;if(Array.isArray(t)){for(var e,n=t.length,r=0,i=t;r<i.length;r+=1){var o=le(i[r]);if(e){if(e===o)continue;e=Ht;break}e=o}return Zt(e||Ht,n)}return jt}function ue(t){var e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ee||t instanceof ie||t instanceof oe?t.toString():JSON.stringify(t)}oe.prototype.toString=function(){return this.name},oe.fromString=function(t){return t?new oe({name:t,available:!1}):null},oe.prototype.serialize=function(){return["image",this.name]};var ce=function(t,e){this.type=t,this.value=e};ce.parse=function(t,e){if(2!==t.length)return e.error("'literal' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(!se(t[1]))return e.error("invalid value");var n=t[1],r=le(n),i=e.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new ce(r,n)},ce.prototype.evaluate=function(){return this.value},ce.prototype.eachChild=function(){},ce.prototype.outputDefined=function(){return!0},ce.prototype.serialize=function(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ee?["rgba"].concat(this.value.toArray()):this.value instanceof ie?this.value.serialize():this.value};var he=function(t){this.name="ExpressionEvaluationError",this.message=t};he.prototype.toJSON=function(){return this.message};var pe={string:Ut,number:Bt,boolean:Vt,object:jt},fe=function(t,e){this.type=t,this.args=e};fe.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n,r=1,i=t[0];if("array"===i){var o,a;if(t.length>2){var s=t[1];if("string"!=typeof s||!(s in pe)||"object"===s)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=pe[s],r++}else o=Ht;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],r++}n=Zt(o,a)}else n=pe[i];for(var l=[];r<t.length;r++){var u=e.parse(t[r],r,Ht);if(!u)return null;l.push(u)}return new fe(n,l)},fe.prototype.evaluate=function(t){for(var e=0;e<this.args.length;e++){var n=this.args[e].evaluate(t);if(!Kt(this.type,le(n)))return n;if(e===this.args.length-1)throw new he("Expected value to be of type "+Yt(this.type)+", but found "+Yt(le(n))+" instead.")}return null},fe.prototype.eachChild=function(t){this.args.forEach(t)},fe.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},fe.prototype.serialize=function(){var t=this.type,e=[t.kind];if("array"===t.kind){var n=t.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){e.push(n.kind);var r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((function(t){return t.serialize()})))};var de=function(t){this.type=Wt,this.sections=t};de.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");for(var r=[],i=!1,o=1;o<=t.length-1;++o){var a=t[o];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;var s=null;if(a["font-scale"]&&!(s=e.parse(a["font-scale"],1,Bt)))return null;var l=null;if(a["text-font"]&&!(l=e.parse(a["text-font"],1,Zt(Ut))))return null;var u=null;if(a["text-color"]&&!(u=e.parse(a["text-color"],1,Gt)))return null;var c=r[r.length-1];c.scale=s,c.font=l,c.textColor=u}else{var h=e.parse(t[o],1,Ht);if(!h)return null;var p=h.type.kind;if("string"!==p&&"value"!==p&&"null"!==p&&"resolvedImage"!==p)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:h,scale:null,font:null,textColor:null})}}return new de(r)},de.prototype.evaluate=function(t){return new ie(this.sections.map((function(e){var n=e.content.evaluate(t);return le(n)===Xt?new re("",n,null,null,null):new re(ue(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))},de.prototype.eachChild=function(t){for(var e=0,n=this.sections;e<n.length;e+=1){var r=n[e];t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}},de.prototype.outputDefined=function(){return!1},de.prototype.serialize=function(){for(var t=["format"],e=0,n=this.sections;e<n.length;e+=1){var r=n[e];t.push(r.content.serialize());var i={};r.scale&&(i["font-scale"]=r.scale.serialize()),r.font&&(i["text-font"]=r.font.serialize()),r.textColor&&(i["text-color"]=r.textColor.serialize()),t.push(i)}return t};var me=function(t){this.type=Xt,this.input=t};me.parse=function(t,e){if(2!==t.length)return e.error("Expected two arguments.");var n=e.parse(t[1],1,Ut);return n?new me(n):e.error("No image name provided.")},me.prototype.evaluate=function(t){var e=this.input.evaluate(t),n=oe.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n},me.prototype.eachChild=function(t){t(this.input)},me.prototype.outputDefined=function(){return!1},me.prototype.serialize=function(){return["image",this.input.serialize()]};var ge={"to-boolean":Vt,"to-color":Gt,"to-number":Bt,"to-string":Ut},ye=function(t,e){this.type=t,this.args=e};ye.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[0];if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");for(var r=ge[n],i=[],o=1;o<t.length;o++){var a=e.parse(t[o],o,Ht);if(!a)return null;i.push(a)}return new ye(r,i)},ye.prototype.evaluate=function(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){for(var e,n,r=0,i=this.args;r<i.length;r+=1){if(n=null,(e=i[r].evaluate(t))instanceof ee)return e;if("string"==typeof e){var o=t.parseColor(e);if(o)return o}else if(Array.isArray(e)&&!(n=e.length<3||e.length>4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":ae(e[0],e[1],e[2],e[3])))return new ee(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new he(n||"Could not parse color from value '"+("string"==typeof e?e:String(JSON.stringify(e)))+"'")}if("number"===this.type.kind){for(var a=null,s=0,l=this.args;s<l.length;s+=1){if(null===(a=l[s].evaluate(t)))return 0;var u=Number(a);if(!isNaN(u))return u}throw new he("Could not convert "+JSON.stringify(a)+" to number.")}return"formatted"===this.type.kind?ie.fromString(ue(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?oe.fromString(ue(this.args[0].evaluate(t))):ue(this.args[0].evaluate(t))},ye.prototype.eachChild=function(t){this.args.forEach(t)},ye.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},ye.prototype.serialize=function(){if("formatted"===this.type.kind)return new de([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new me(this.args[0]).serialize();var t=["to-"+this.type.kind];return this.eachChild((function(e){t.push(e.serialize())})),t};var ve=["Unknown","Point","LineString","Polygon"],_e=function(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null};_e.prototype.id=function(){return this.feature&&"id"in this.feature?this.feature.id:null},_e.prototype.geometryType=function(){return this.feature?"number"==typeof this.feature.type?ve[this.feature.type]:this.feature.type:null},_e.prototype.geometry=function(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null},_e.prototype.canonicalID=function(){return this.canonical},_e.prototype.properties=function(){return this.feature&&this.feature.properties||{}},_e.prototype.parseColor=function(t){var e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ee.parse(t)),e};var xe=function(t,e,n,r){this.name=t,this.type=e,this._evaluate=n,this.args=r};xe.prototype.evaluate=function(t){return this._evaluate(t,this.args)},xe.prototype.eachChild=function(t){this.args.forEach(t)},xe.prototype.outputDefined=function(){return!1},xe.prototype.serialize=function(){return[this.name].concat(this.args.map((function(t){return t.serialize()})))},xe.parse=function(t,e){var n,r=t[0],i=xe.definitions[r];if(!i)return e.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0);for(var o=Array.isArray(i)?i[0]:i.type,a=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=a.filter((function(e){var n=e[0];return!Array.isArray(n)||n.length===t.length-1})),l=null,u=0,c=s;u<c.length;u+=1){var h=c[u],p=h[0],f=h[1];l=new Ge(e.registry,e.path,null,e.scope);for(var d=[],m=!1,g=1;g<t.length;g++){var y=t[g],v=Array.isArray(p)?p[g-1]:p.type,_=l.parse(y,1+d.length,v);if(!_){m=!0;break}d.push(_)}if(!m)if(Array.isArray(p)&&p.length!==d.length)l.error("Expected "+p.length+" arguments, but found "+d.length+" instead.");else{for(var x=0;x<d.length;x++){var b=Array.isArray(p)?p[x]:p.type,w=d[x];l.concat(x+1).checkSubtype(b,w.type)}if(0===l.errors.length)return new xe(r,o,f,d)}}if(1===s.length)(n=e.errors).push.apply(n,l.errors);else{for(var E=(s.length?s:a).map((function(t){var e;return e=t[0],Array.isArray(e)?"("+e.map(Yt).join(", ")+")":"("+Yt(e.type)+"...)"})).join(" | "),S=[],M=1;M<t.length;M++){var T=e.parse(t[M],1+S.length);if(!T)return null;S.push(Yt(T.type))}e.error("Expected arguments of type "+E+", but found ("+S.join(", ")+") instead.")}return null},xe.register=function(t,e){for(var n in xe.definitions=e,e)t[n]=xe};var be=function(t,e,n){this.type=qt,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e};function we(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Ee(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Se(t,e){var n=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(n*i*8192),Math.round(r*i*8192)]}function Me(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function Te(t,e){for(var n,r,i,o,a,s,l,u=!1,c=0,h=e.length;c<h;c++)for(var p=e[c],f=0,d=p.length;f<d-1;f++){if((o=(n=t)[0]-(r=p[f])[0])*(l=n[1]-(i=p[f+1])[1])-(s=n[0]-i[0])*(a=n[1]-r[1])==0&&o*s<=0&&a*l<=0)return!1;Me(t,p[f],p[f+1])&&(u=!u)}return u}function Ce(t,e){for(var n=0;n<e.length;n++)if(Te(t,e[n]))return!0;return!1}function Ie(t,e,n,r){var i=r[0]-n[0],o=r[1]-n[1],a=(t[0]-n[0])*o-i*(t[1]-n[1]),s=(e[0]-n[0])*o-i*(e[1]-n[1]);return a>0&&s<0||a<0&&s>0}function Ae(t,e,n){for(var r=0,i=n;r<i.length;r+=1)for(var o=i[r],a=0;a<o.length-1;++a)if(0!=(h=[(c=o[a+1])[0]-(u=o[a])[0],c[1]-u[1]])[0]*(p=[(l=e)[0]-(s=t)[0],l[1]-s[1]])[1]-h[1]*p[0]&&Ie(s,l,u,c)&&Ie(u,c,s,l))return!0;var s,l,u,c,h,p;return!1}function Le(t,e){for(var n=0;n<t.length;++n)if(!Te(t[n],e))return!1;for(var r=0;r<t.length-1;++r)if(Ae(t[r],t[r+1],e))return!1;return!0}function Pe(t,e){for(var n=0;n<e.length;n++)if(Le(t,e[n]))return!0;return!1}function Re(t,e,n){for(var r=[],i=0;i<t.length;i++){for(var o=[],a=0;a<t[i].length;a++){var s=Se(t[i][a],n);we(e,s),o.push(s)}r.push(o)}return r}function De(t,e,n){for(var r=[],i=0;i<t.length;i++){var o=Re(t[i],e,n);r.push(o)}return r}function Ne(t,e,n,r){if(t[0]<n[0]||t[0]>n[2]){var i=.5*r,o=t[0]-n[0]>i?-r:n[0]-t[0]>i?r:0;0===o&&(o=t[0]-n[2]>i?-r:n[2]-t[0]>i?r:0),t[0]+=o}we(e,t)}function Oe(t,e,n,r){for(var i=8192*Math.pow(2,r.z),o=[8192*r.x,8192*r.y],a=[],s=0,l=t;s<l.length;s+=1)for(var u=0,c=l[s];u<c.length;u+=1){var h=c[u],p=[h.x+o[0],h.y+o[1]];Ne(p,e,n,i),a.push(p)}return a}function ke(t,e,n,r){for(var i,o=8192*Math.pow(2,r.z),a=[8192*r.x,8192*r.y],s=[],l=0,u=t;l<u.length;l+=1){for(var c=[],h=0,p=u[l];h<p.length;h+=1){var f=p[h],d=[f.x+a[0],f.y+a[1]];we(e,d),c.push(d)}s.push(c)}if(e[2]-e[0]<=o/2){(i=e)[0]=i[1]=1/0,i[2]=i[3]=-1/0;for(var m=0,g=s;m<g.length;m+=1)for(var y=0,v=g[m];y<v.length;y+=1)Ne(v[y],e,n,o)}return s}be.parse=function(t,e){if(2!==t.length)return e.error("Expected one argument.");var n=t[1];if("object"!=typeof n||Array.isArray(n))return e.error("Collator options argument must be an object.");var r=e.parse(void 0!==n["case-sensitive"]&&n["case-sensitive"],1,Vt);if(!r)return null;var i=e.parse(void 0!==n["diacritic-sensitive"]&&n["diacritic-sensitive"],1,Vt);if(!i)return null;var o=null;return n.locale&&!(o=e.parse(n.locale,1,Ut))?null:new be(r,i,o)},be.prototype.evaluate=function(t){return new ne(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)},be.prototype.eachChild=function(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)},be.prototype.outputDefined=function(){return!1},be.prototype.serialize=function(){var t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]};var ze=function(t,e){this.type=Vt,this.geojson=t,this.geometries=e};function Fe(t){if(t instanceof xe){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof ze)return!1;var e=!0;return t.eachChild((function(t){e&&!Fe(t)&&(e=!1)})),e}function Be(t){if(t instanceof xe&&"feature-state"===t.name)return!1;var e=!0;return t.eachChild((function(t){e&&!Be(t)&&(e=!1)})),e}function Ue(t,e){if(t instanceof xe&&e.indexOf(t.name)>=0)return!1;var n=!0;return t.eachChild((function(t){n&&!Ue(t,e)&&(n=!1)})),n}ze.parse=function(t,e){if(2!==t.length)return e.error("'within' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(se(t[1])){var n=t[1];if("FeatureCollection"===n.type)for(var r=0;r<n.features.length;++r){var i=n.features[r].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new ze(n,n.features[r].geometry)}else if("Feature"===n.type){var o=n.geometry.type;if("Polygon"===o||"MultiPolygon"===o)return new ze(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new ze(n,n)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")},ze.prototype.evaluate=function(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){var n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){var o=Re(e.coordinates,r,i),a=Oe(t.geometry(),n,r,i);if(!Ee(n,r))return!1;for(var s=0,l=a;s<l.length;s+=1)if(!Te(l[s],o))return!1}if("MultiPolygon"===e.type){var u=De(e.coordinates,r,i),c=Oe(t.geometry(),n,r,i);if(!Ee(n,r))return!1;for(var h=0,p=c;h<p.length;h+=1)if(!Ce(p[h],u))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){var n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){var o=Re(e.coordinates,r,i),a=ke(t.geometry(),n,r,i);if(!Ee(n,r))return!1;for(var s=0,l=a;s<l.length;s+=1)if(!Le(l[s],o))return!1}if("MultiPolygon"===e.type){var u=De(e.coordinates,r,i),c=ke(t.geometry(),n,r,i);if(!Ee(n,r))return!1;for(var h=0,p=c;h<p.length;h+=1)if(!Pe(p[h],u))return!1}return!0}(t,this.geometries)}return!1},ze.prototype.eachChild=function(){},ze.prototype.outputDefined=function(){return!0},ze.prototype.serialize=function(){return["within",this.geojson]};var Ve=function(t,e){this.type=e.type,this.name=t,this.boundExpression=e};Ve.parse=function(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");var n=t[1];return e.scope.has(n)?new Ve(n,e.scope.get(n)):e.error('Unknown variable "'+n+'". Make sure "'+n+'" has been bound in an enclosing "let" expression before using it.',1)},Ve.prototype.evaluate=function(t){return this.boundExpression.evaluate(t)},Ve.prototype.eachChild=function(){},Ve.prototype.outputDefined=function(){return!1},Ve.prototype.serialize=function(){return["var",this.name]};var Ge=function(t,e,n,r,i){void 0===e&&(e=[]),void 0===r&&(r=new zt),void 0===i&&(i=[]),this.registry=t,this.path=e,this.key=e.map((function(t){return"["+t+"]"})).join(""),this.scope=r,this.errors=i,this.expectedType=n};function je(t,e){for(var n,r=t.length-1,i=0,o=r,a=0;i<=o;)if((n=t[a=Math.floor((i+o)/2)])<=e){if(a===r||e<t[a+1])return a;i=a+1}else{if(!(n>e))throw new he("Input is not a number.");o=a-1}return 0}Ge.prototype.parse=function(t,e,n,r,i){return void 0===i&&(i={}),e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)},Ge.prototype._parse=function(t,e){function n(t,e,n){return"assert"===n?new fe(e,[t]):"coerce"===n?new ye(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var r=t[0];if("string"!=typeof r)return this.error("Expression name must be a string, but found "+typeof r+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var i=this.registry[r];if(i){var o=i.parse(t,this);if(!o)return null;if(this.expectedType){var a=this.expectedType,s=o.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==s.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(a,s))return null}else o=n(o,a,e.typeAnnotation||"coerce");else o=n(o,a,e.typeAnnotation||"assert")}if(!(o instanceof ce)&&"resolvedImage"!==o.type.kind&&function t(e){if(e instanceof Ve)return t(e.boundExpression);if(e instanceof xe&&"error"===e.name)return!1;if(e instanceof be)return!1;if(e instanceof ze)return!1;var n=e instanceof ye||e instanceof fe,r=!0;return e.eachChild((function(e){r=n?r&&t(e):r&&e instanceof ce})),!!r&&Fe(e)&&Ue(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}(o)){var l=new _e;try{o=new ce(o.type,o.evaluate(l))}catch(t){return this.error(t.message),null}}return o}return this.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':"Expected an array, but found "+typeof t+" instead.")},Ge.prototype.concat=function(t,e,n){var r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new Ge(this.registry,r,e||null,i,this.errors)},Ge.prototype.error=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=""+this.key+e.map((function(t){return"["+t+"]"})).join("");this.errors.push(new kt(r,t))},Ge.prototype.checkSubtype=function(t,e){var n=Kt(t,e);return n&&this.error(n),n};var He=function(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var r=0,i=n;r<i.length;r+=1){var o=i[r],a=o[1];this.labels.push(o[0]),this.outputs.push(a)}};function qe(t,e,n){return t*(1-n)+e*n}He.parse=function(t,e){if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");var n=e.parse(t[1],1,Bt);if(!n)return null;var r=[],i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(var o=1;o<t.length;o+=2){var a=1===o?-1/0:t[o],s=t[o+1],l=o,u=o+1;if("number"!=typeof a)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',l);if(r.length&&r[r.length-1][0]>=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);var c=e.parse(s,u,i);if(!c)return null;i=i||c.type,r.push([a,c])}return new He(i,n,r)},He.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[je(e,r)].evaluate(t)},He.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e<n.length;e+=1)t(n[e])},He.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))},He.prototype.serialize=function(){for(var t=["step",this.input.serialize()],e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var We=Object.freeze({__proto__:null,number:qe,color:function(t,e,n){return new ee(qe(t.r,e.r,n),qe(t.g,e.g,n),qe(t.b,e.b,n),qe(t.a,e.a,n))},array:function(t,e,n){return t.map((function(t,r){return qe(t,e[r],n)}))}}),Xe=6/29*3*(6/29),Ze=Math.PI/180,Ye=180/Math.PI;function Je(t){return t>.008856451679035631?Math.pow(t,1/3):t/Xe+4/29}function Ke(t){return t>6/29?t*t*t:Xe*(t-4/29)}function Qe(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function $e(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function tn(t){var e=$e(t.r),n=$e(t.g),r=$e(t.b),i=Je((.4124564*e+.3575761*n+.1804375*r)/.95047),o=Je((.2126729*e+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Je((.0193339*e+.119192*n+.9503041*r)/1.08883)),alpha:t.a}}function en(t){var e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ke(e),n=.95047*Ke(n),r=1.08883*Ke(r),new ee(Qe(3.2404542*n-1.5371385*e-.4985314*r),Qe(-.969266*n+1.8760108*e+.041556*r),Qe(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}function nn(t,e,n){var r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}var rn={forward:tn,reverse:en,interpolate:function(t,e,n){return{l:qe(t.l,e.l,n),a:qe(t.a,e.a,n),b:qe(t.b,e.b,n),alpha:qe(t.alpha,e.alpha,n)}}},on={forward:function(t){var e=tn(t),n=e.l,r=e.a,i=e.b,o=Math.atan2(i,r)*Ye;return{h:o<0?o+360:o,c:Math.sqrt(r*r+i*i),l:n,alpha:t.a}},reverse:function(t){var e=t.h*Ze,n=t.c;return en({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:nn(t.h,e.h,n),c:qe(t.c,e.c,n),l:qe(t.l,e.l,n),alpha:qe(t.alpha,e.alpha,n)}}},an=Object.freeze({__proto__:null,lab:rn,hcl:on}),sn=function(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(var o=0,a=i;o<a.length;o+=1){var s=a[o],l=s[1];this.labels.push(s[0]),this.outputs.push(l)}};function ln(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}sn.interpolationFactor=function(t,e,r,i){var o=0;if("exponential"===t.name)o=ln(e,t.base,r,i);else if("linear"===t.name)o=ln(e,1,r,i);else if("cubic-bezier"===t.name){var a=t.controlPoints;o=new n(a[0],a[1],a[2],a[3]).solve(ln(e,1,r,i))}return o},sn.parse=function(t,e){var n=t[0],r=t[1],i=t[2],o=t.slice(3);if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){var a=r[1];if("number"!=typeof a)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:a}}else{if("cubic-bezier"!==r[0])return e.error("Unknown interpolation type "+String(r[0]),1,0);var s=r.slice(1);if(4!==s.length||s.some((function(t){return"number"!=typeof t||t<0||t>1})))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:s}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(i=e.parse(i,2,Bt)))return null;var l=[],u=null;"interpolate-hcl"===n||"interpolate-lab"===n?u=Gt:e.expectedType&&"value"!==e.expectedType.kind&&(u=e.expectedType);for(var c=0;c<o.length;c+=2){var h=o[c],p=o[c+1],f=c+3,d=c+4;if("number"!=typeof h)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',f);if(l.length&&l[l.length-1][0]>=h)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',f);var m=e.parse(p,d,u);if(!m)return null;u=u||m.type,l.push([h,m])}return"number"===u.kind||"color"===u.kind||"array"===u.kind&&"number"===u.itemType.kind&&"number"==typeof u.N?new sn(u,n,r,i,l):e.error("Type "+Yt(u)+" is not interpolatable.")},sn.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);var o=je(e,r),a=sn.interpolationFactor(this.interpolation,r,e[o],e[o+1]),s=n[o].evaluate(t),l=n[o+1].evaluate(t);return"interpolate"===this.operator?We[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?on.reverse(on.interpolate(on.forward(s),on.forward(l),a)):rn.reverse(rn.interpolate(rn.forward(s),rn.forward(l),a))},sn.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e<n.length;e+=1)t(n[e])},sn.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))},sn.prototype.serialize=function(){var t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);for(var e=[this.operator,t,this.input.serialize()],n=0;n<this.labels.length;n++)e.push(this.labels[n],this.outputs[n].serialize());return e};var un=function(t,e){this.type=t,this.args=e};un.parse=function(t,e){if(t.length<2)return e.error("Expectected at least one argument.");var n=null,r=e.expectedType;r&&"value"!==r.kind&&(n=r);for(var i=[],o=0,a=t.slice(1);o<a.length;o+=1){var s=e.parse(a[o],1+i.length,n,void 0,{typeAnnotation:"omit"});if(!s)return null;n=n||s.type,i.push(s)}var l=r&&i.some((function(t){return Kt(r,t.type)}));return new un(l?Ht:n,i)},un.prototype.evaluate=function(t){for(var e,n=null,r=0,i=0,o=this.args;i<o.length&&(r++,(n=o[i].evaluate(t))&&n instanceof oe&&!n.available&&(e||(e=n.name),n=null,r===this.args.length&&(n=e)),null===n);i+=1);return n},un.prototype.eachChild=function(t){this.args.forEach(t)},un.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},un.prototype.serialize=function(){var t=["coalesce"];return this.eachChild((function(e){t.push(e.serialize())})),t};var cn=function(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e};cn.prototype.evaluate=function(t){return this.result.evaluate(t)},cn.prototype.eachChild=function(t){for(var e=0,n=this.bindings;e<n.length;e+=1)t(n[e][1]);t(this.result)},cn.parse=function(t,e){if(t.length<4)return e.error("Expected at least 3 arguments, but found "+(t.length-1)+" instead.");for(var n=[],r=1;r<t.length-1;r+=2){var i=t[r];if("string"!=typeof i)return e.error("Expected string, but found "+typeof i+" instead.",r);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);var o=e.parse(t[r+1],r+1);if(!o)return null;n.push([i,o])}var a=e.parse(t[t.length-1],t.length-1,e.expectedType,n);return a?new cn(n,a):null},cn.prototype.outputDefined=function(){return this.result.outputDefined()},cn.prototype.serialize=function(){for(var t=["let"],e=0,n=this.bindings;e<n.length;e+=1){var r=n[e];t.push(r[0],r[1].serialize())}return t.push(this.result.serialize()),t};var hn=function(t,e,n){this.type=t,this.index=e,this.input=n};hn.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Bt),r=e.parse(t[2],2,Zt(e.expectedType||Ht));return n&&r?new hn(r.type.itemType,n,r):null},hn.prototype.evaluate=function(t){var e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new he("Array index out of bounds: "+e+" < 0.");if(e>=n.length)throw new he("Array index out of bounds: "+e+" > "+(n.length-1)+".");if(e!==Math.floor(e))throw new he("Array index must be an integer, but found "+e+" instead.");return n[e]},hn.prototype.eachChild=function(t){t(this.index),t(this.input)},hn.prototype.outputDefined=function(){return!1},hn.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var pn=function(t,e){this.type=Vt,this.needle=t,this.haystack=e};pn.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);return n&&r?Qt(n.type,[Vt,Ut,Bt,Ft,Ht])?new pn(n,r):e.error("Expected first argument to be of type boolean, string, number or null, but found "+Yt(n.type)+" instead"):null},pn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!$t(e,["boolean","string","number","null"]))throw new he("Expected first argument to be of type boolean, string, number or null, but found "+Yt(le(e))+" instead.");if(!$t(n,["string","array"]))throw new he("Expected second argument to be of type array or string, but found "+Yt(le(n))+" instead.");return n.indexOf(e)>=0},pn.prototype.eachChild=function(t){t(this.needle),t(this.haystack)},pn.prototype.outputDefined=function(){return!0},pn.prototype.serialize=function(){return["in",this.needle.serialize(),this.haystack.serialize()]};var fn=function(t,e,n){this.type=Bt,this.needle=t,this.haystack=e,this.fromIndex=n};fn.parse=function(t,e){if(t.length<=2||t.length>=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);if(!n||!r)return null;if(!Qt(n.type,[Vt,Ut,Bt,Ft,Ht]))return e.error("Expected first argument to be of type boolean, string, number or null, but found "+Yt(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Bt);return i?new fn(n,r,i):null}return new fn(n,r)},fn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!$t(e,["boolean","string","number","null"]))throw new he("Expected first argument to be of type boolean, string, number or null, but found "+Yt(le(e))+" instead.");if(!$t(n,["string","array"]))throw new he("Expected second argument to be of type array or string, but found "+Yt(le(n))+" instead.");if(this.fromIndex){var r=this.fromIndex.evaluate(t);return n.indexOf(e,r)}return n.indexOf(e)},fn.prototype.eachChild=function(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)},fn.prototype.outputDefined=function(){return!1},fn.prototype.serialize=function(){if(null!=this.fromIndex&&void 0!==this.fromIndex){var t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]};var dn=function(t,e,n,r,i,o){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o};dn.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(var i={},o=[],a=2;a<t.length-1;a+=2){var s=t[a],l=t[a+1];Array.isArray(s)||(s=[s]);var u=e.concat(a);if(0===s.length)return u.error("Expected at least one branch label.");for(var c=0,h=s;c<h.length;c+=1){var p=h[c];if("number"!=typeof p&&"string"!=typeof p)return u.error("Branch labels must be numbers or strings.");if("number"==typeof p&&Math.abs(p)>Number.MAX_SAFE_INTEGER)return u.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof p&&Math.floor(p)!==p)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,le(p)))return null}else n=le(p);if(void 0!==i[String(p)])return u.error("Branch labels must be unique.");i[String(p)]=o.length}var f=e.parse(l,a,r);if(!f)return null;r=r||f.type,o.push(f)}var d=e.parse(t[1],1,Ht);if(!d)return null;var m=e.parse(t[t.length-1],t.length-1,r);return m?"value"!==d.type.kind&&e.concat(1).checkSubtype(n,d.type)?null:new dn(n,r,d,i,o,m):null},dn.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(le(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},dn.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},dn.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))&&this.otherwise.outputDefined()},dn.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],n=[],r={},i=0,o=Object.keys(this.cases).sort();i<o.length;i+=1){var a=o[i];void 0===(h=r[this.cases[a]])?(r[this.cases[a]]=n.length,n.push([this.cases[a],[a]])):n[h][1].push(a)}for(var s=function(e){return"number"===t.inputType.kind?Number(e):e},l=0,u=n;l<u.length;l+=1){var c=u[l],h=c[0],p=c[1];e.push(1===p.length?s(p[0]):p.map(s)),e.push(this.outputs[outputIndex$1].serialize())}return e.push(this.otherwise.serialize()),e};var mn=function(t,e,n){this.type=t,this.branches=e,this.otherwise=n};mn.parse=function(t,e){if(t.length<4)return e.error("Expected at least 3 arguments, but found only "+(t.length-1)+".");if(t.length%2!=0)return e.error("Expected an odd number of arguments.");var n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(var r=[],i=1;i<t.length-1;i+=2){var o=e.parse(t[i],i,Vt);if(!o)return null;var a=e.parse(t[i+1],i+1,n);if(!a)return null;r.push([o,a]),n=n||a.type}var s=e.parse(t[t.length-1],t.length-1,n);return s?new mn(n,r,s):null},mn.prototype.evaluate=function(t){for(var e=0,n=this.branches;e<n.length;e+=1){var r=n[e],i=r[1];if(r[0].evaluate(t))return i.evaluate(t)}return this.otherwise.evaluate(t)},mn.prototype.eachChild=function(t){for(var e=0,n=this.branches;e<n.length;e+=1){var r=n[e],i=r[1];t(r[0]),t(i)}t(this.otherwise)},mn.prototype.outputDefined=function(){return this.branches.every((function(t){return t[1].outputDefined()}))&&this.otherwise.outputDefined()},mn.prototype.serialize=function(){var t=["case"];return this.eachChild((function(e){t.push(e.serialize())})),t};var gn=function(t,e,n,r){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=r};function yn(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function vn(t,e,n,r){return 0===r.compare(e,n)}function _n(t,e,n){var r="=="!==t&&"!="!==t;return function(){function i(t,e,n){this.type=Vt,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}return i.parse=function(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");var n=t[0],o=e.parse(t[1],1,Ht);if(!o)return null;if(!yn(n,o.type))return e.concat(1).error('"'+n+"\" comparisons are not supported for type '"+Yt(o.type)+"'.");var a=e.parse(t[2],2,Ht);if(!a)return null;if(!yn(n,a.type))return e.concat(2).error('"'+n+"\" comparisons are not supported for type '"+Yt(a.type)+"'.");if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return e.error("Cannot compare types '"+Yt(o.type)+"' and '"+Yt(a.type)+"'.");r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new fe(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new fe(o.type,[a])));var s=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(!(s=e.parse(t[3],3,qt)))return null}return new i(o,a,s)},i.prototype.evaluate=function(i){var o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){var s=le(o),l=le(a);if(s.kind!==l.kind||"string"!==s.kind&&"number"!==s.kind)throw new he('Expected arguments for "'+t+'" to be (string, string) or (number, number), but found ('+s.kind+", "+l.kind+") instead.")}if(this.collator&&!r&&this.hasUntypedArgument){var u=le(o),c=le(a);if("string"!==u.kind||"string"!==c.kind)return e(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):e(i,o,a)},i.prototype.eachChild=function(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)},i.prototype.outputDefined=function(){return!0},i.prototype.serialize=function(){var e=[t];return this.eachChild((function(t){e.push(t.serialize())})),e},i}()}gn.parse=function(t,e){if(t.length<=2||t.length>=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Bt);if(!n||!r)return null;if(!Qt(n.type,[Zt(Ht),Ut,Ht]))return e.error("Expected first argument to be of type array or string, but found "+Yt(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Bt);return i?new gn(n.type,n,r,i):null}return new gn(n.type,n,r)},gn.prototype.evaluate=function(t){var e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);if(!$t(e,["string","array"]))throw new he("Expected first argument to be of type array or string, but found "+Yt(le(e))+" instead.");if(this.endIndex){var r=this.endIndex.evaluate(t);return e.slice(n,r)}return e.slice(n)},gn.prototype.eachChild=function(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)},gn.prototype.outputDefined=function(){return!1},gn.prototype.serialize=function(){if(null!=this.endIndex&&void 0!==this.endIndex){var t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]};var xn=_n("==",(function(t,e,n){return e===n}),vn),bn=_n("!=",(function(t,e,n){return e!==n}),(function(t,e,n,r){return!vn(0,e,n,r)})),wn=_n("<",(function(t,e,n){return e<n}),(function(t,e,n,r){return r.compare(e,n)<0})),En=_n(">",(function(t,e,n){return e>n}),(function(t,e,n,r){return r.compare(e,n)>0})),Sn=_n("<=",(function(t,e,n){return e<=n}),(function(t,e,n,r){return r.compare(e,n)<=0})),Mn=_n(">=",(function(t,e,n){return e>=n}),(function(t,e,n,r){return r.compare(e,n)>=0})),Tn=function(t,e,n,r,i){this.type=Ut,this.number=t,this.locale=e,this.currency=n,this.minFractionDigits=r,this.maxFractionDigits=i};Tn.parse=function(t,e){if(3!==t.length)return e.error("Expected two arguments.");var n=e.parse(t[1],1,Bt);if(!n)return null;var r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");var i=null;if(r.locale&&!(i=e.parse(r.locale,1,Ut)))return null;var o=null;if(r.currency&&!(o=e.parse(r.currency,1,Ut)))return null;var a=null;if(r["min-fraction-digits"]&&!(a=e.parse(r["min-fraction-digits"],1,Bt)))return null;var s=null;return r["max-fraction-digits"]&&!(s=e.parse(r["max-fraction-digits"],1,Bt))?null:new Tn(n,i,o,a,s)},Tn.prototype.evaluate=function(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))},Tn.prototype.eachChild=function(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)},Tn.prototype.outputDefined=function(){return!1},Tn.prototype.serialize=function(){var t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]};var Cn=function(t){this.type=Bt,this.input=t};Cn.parse=function(t,e){if(2!==t.length)return e.error("Expected 1 argument, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error("Expected argument of type string or array, but found "+Yt(n.type)+" instead."):new Cn(n):null},Cn.prototype.evaluate=function(t){var e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new he("Expected value to be of type string or array, but found "+Yt(le(e))+" instead.")},Cn.prototype.eachChild=function(t){t(this.input)},Cn.prototype.outputDefined=function(){return!1},Cn.prototype.serialize=function(){var t=["length"];return this.eachChild((function(e){t.push(e.serialize())})),t};var In={"==":xn,"!=":bn,">":En,"<":wn,">=":Mn,"<=":Sn,array:fe,at:hn,boolean:fe,case:mn,coalesce:un,collator:be,format:de,image:me,in:pn,"index-of":fn,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:Cn,let:cn,literal:ce,match:dn,number:fe,"number-format":Tn,object:fe,slice:gn,step:He,string:fe,"to-boolean":ye,"to-color":ye,"to-number":ye,"to-string":ye,var:Ve,within:ze};function An(t,e){var n=e[0],r=e[1],i=e[2],o=e[3];n=n.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);var a=o?o.evaluate(t):1,s=ae(n,r,i,a);if(s)throw new he(s);return new ee(n/255*a,r/255*a,i/255*a,a)}function Ln(t,e){return t in e}function Pn(t,e){var n=e[t];return void 0===n?null:n}function Rn(t){return{type:t}}function Dn(t){return{result:"success",value:t}}function Nn(t){return{result:"error",value:t}}function On(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function kn(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function zn(t){return!!t.expression&&t.expression.interpolated}function Fn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Bn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Un(t){return t}function Vn(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function Gn(t,e,n,r,i){return Vn(typeof n===i?r[n]:void 0,t.default,e.default)}function jn(t,e,n){if("number"!==Fn(n))return Vn(t.default,e.default);var r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];var i=je(t.stops.map((function(t){return t[0]})),n);return t.stops[i][1]}function Hn(t,e,n){var r=void 0!==t.base?t.base:1;if("number"!==Fn(n))return Vn(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];var o=je(t.stops.map((function(t){return t[0]})),n),a=function(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[o][0],t.stops[o+1][0]),s=t.stops[o][1],l=t.stops[o+1][1],u=We[e.type]||Un;if(t.colorSpace&&"rgb"!==t.colorSpace){var c=an[t.colorSpace];u=function(t,e){return c.reverse(c.interpolate(c.forward(t),c.forward(e),a))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==r)return u(n,r,a)}}:u(s,l,a)}function qn(t,e,n){return"color"===e.type?n=ee.parse(n):"formatted"===e.type?n=ie.fromString(n.toString()):"resolvedImage"===e.type?n=oe.fromString(n.toString()):Fn(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),Vn(n,t.default,e.default)}xe.register(In,{error:[{kind:"error"},[Ut],function(t,e){throw new he(e[0].evaluate(t))}],typeof:[Ut,[Ht],function(t,e){return Yt(le(e[0].evaluate(t)))}],"to-rgba":[Zt(Bt,4),[Gt],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Gt,[Bt,Bt,Bt],An],rgba:[Gt,[Bt,Bt,Bt,Bt],An],has:{type:Vt,overloads:[[[Ut],function(t,e){return Ln(e[0].evaluate(t),t.properties())}],[[Ut,jt],function(t,e){var n=e[1];return Ln(e[0].evaluate(t),n.evaluate(t))}]]},get:{type:Ht,overloads:[[[Ut],function(t,e){return Pn(e[0].evaluate(t),t.properties())}],[[Ut,jt],function(t,e){var n=e[1];return Pn(e[0].evaluate(t),n.evaluate(t))}]]},"feature-state":[Ht,[Ut],function(t,e){return Pn(e[0].evaluate(t),t.featureState||{})}],properties:[jt,[],function(t){return t.properties()}],"geometry-type":[Ut,[],function(t){return t.geometryType()}],id:[Ht,[],function(t){return t.id()}],zoom:[Bt,[],function(t){return t.globals.zoom}],"heatmap-density":[Bt,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[Bt,[],function(t){return t.globals.lineProgress||0}],accumulated:[Ht,[],function(t){return void 0===t.globals.accumulated?null:t.globals.accumulated}],"+":[Bt,Rn(Bt),function(t,e){for(var n=0,r=0,i=e;r<i.length;r+=1)n+=i[r].evaluate(t);return n}],"*":[Bt,Rn(Bt),function(t,e){for(var n=1,r=0,i=e;r<i.length;r+=1)n*=i[r].evaluate(t);return n}],"-":{type:Bt,overloads:[[[Bt,Bt],function(t,e){var n=e[1];return e[0].evaluate(t)-n.evaluate(t)}],[[Bt],function(t,e){return-e[0].evaluate(t)}]]},"/":[Bt,[Bt,Bt],function(t,e){var n=e[1];return e[0].evaluate(t)/n.evaluate(t)}],"%":[Bt,[Bt,Bt],function(t,e){var n=e[1];return e[0].evaluate(t)%n.evaluate(t)}],ln2:[Bt,[],function(){return Math.LN2}],pi:[Bt,[],function(){return Math.PI}],e:[Bt,[],function(){return Math.E}],"^":[Bt,[Bt,Bt],function(t,e){var n=e[1];return Math.pow(e[0].evaluate(t),n.evaluate(t))}],sqrt:[Bt,[Bt],function(t,e){return Math.sqrt(e[0].evaluate(t))}],log10:[Bt,[Bt],function(t,e){return Math.log(e[0].evaluate(t))/Math.LN10}],ln:[Bt,[Bt],function(t,e){return Math.log(e[0].evaluate(t))}],log2:[Bt,[Bt],function(t,e){return Math.log(e[0].evaluate(t))/Math.LN2}],sin:[Bt,[Bt],function(t,e){return Math.sin(e[0].evaluate(t))}],cos:[Bt,[Bt],function(t,e){return Math.cos(e[0].evaluate(t))}],tan:[Bt,[Bt],function(t,e){return Math.tan(e[0].evaluate(t))}],asin:[Bt,[Bt],function(t,e){return Math.asin(e[0].evaluate(t))}],acos:[Bt,[Bt],function(t,e){return Math.acos(e[0].evaluate(t))}],atan:[Bt,[Bt],function(t,e){return Math.atan(e[0].evaluate(t))}],min:[Bt,Rn(Bt),function(t,e){return Math.min.apply(Math,e.map((function(e){return e.evaluate(t)})))}],max:[Bt,Rn(Bt),function(t,e){return Math.max.apply(Math,e.map((function(e){return e.evaluate(t)})))}],abs:[Bt,[Bt],function(t,e){return Math.abs(e[0].evaluate(t))}],round:[Bt,[Bt],function(t,e){var n=e[0].evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[Bt,[Bt],function(t,e){return Math.floor(e[0].evaluate(t))}],ceil:[Bt,[Bt],function(t,e){return Math.ceil(e[0].evaluate(t))}],"filter-==":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1];return t.properties()[n.value]===r.value}],"filter-id-==":[Vt,[Ht],function(t,e){var n=e[0];return t.id()===n.value}],"filter-type-==":[Vt,[Ut],function(t,e){var n=e[0];return t.geometryType()===n.value}],"filter-<":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i<o}],"filter-id-<":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<i}],"filter->":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[Vt,[Ht],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[Vt,[],function(t){return null!==t.id()&&void 0!==t.id()}],"filter-type-in":[Vt,[Zt(Ut)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[Vt,[Zt(Ht)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[Vt,[Ut,Zt(Ht)],function(t,e){var n=e[0];return e[1].value.indexOf(t.properties()[n.value])>=0}],"filter-in-large":[Vt,[Ut,Zt(Ht)],function(t,e){var n=e[0],r=e[1];return function(t,e,n,r){for(;n<=r;){var i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[n.value],r.value,0,r.value.length-1)}],all:{type:Vt,overloads:[[[Vt,Vt],function(t,e){var n=e[1];return e[0].evaluate(t)&&n.evaluate(t)}],[Rn(Vt),function(t,e){for(var n=0,r=e;n<r.length;n+=1)if(!r[n].evaluate(t))return!1;return!0}]]},any:{type:Vt,overloads:[[[Vt,Vt],function(t,e){var n=e[1];return e[0].evaluate(t)||n.evaluate(t)}],[Rn(Vt),function(t,e){for(var n=0,r=e;n<r.length;n+=1)if(r[n].evaluate(t))return!0;return!1}]]},"!":[Vt,[Vt],function(t,e){return!e[0].evaluate(t)}],"is-supported-script":[Vt,[Ut],function(t,e){var n=t.globals&&t.globals.isSupportedScript;return!n||n(e[0].evaluate(t))}],upcase:[Ut,[Ut],function(t,e){return e[0].evaluate(t).toUpperCase()}],downcase:[Ut,[Ut],function(t,e){return e[0].evaluate(t).toLowerCase()}],concat:[Ut,Rn(Ht),function(t,e){return e.map((function(e){return ue(e.evaluate(t))})).join("")}],"resolved-locale":[Ut,[qt],function(t,e){return e[0].evaluate(t).resolvedLocale()}]});var Wn=function(t,e){this.expression=t,this._warningHistory={},this._evaluator=new _e,this._defaultValue=e?function(t){return"color"===t.type&&Bn(t.default)?new ee(0,0,0,0):"color"===t.type?ee.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null};function Xn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in In}function Zn(t,e){var n=new Ge(In,[],e?function(t){var e={color:Gt,string:Ut,number:Bt,enum:Ut,boolean:Vt,formatted:Wt,resolvedImage:Xt};return"array"===t.type?Zt(e[t.value]||Ht,t.length):e[t.type]}(e):void 0),r=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Dn(new Wn(r,e)):Nn(n.errors)}Wn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)},Wn.prototype.evaluate=function(t,e,n,r,i,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null;try{var a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new he("Expected value to be one of "+Object.keys(this._enumValues).map((function(t){return JSON.stringify(t)})).join(", ")+", but found "+JSON.stringify(a)+" instead.");return a}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var Yn=function(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Be(e.expression)};Yn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,o)},Yn.prototype.evaluate=function(t,e,n,r,i,o){return this._styleExpression.evaluate(t,e,n,r,i,o)};var Jn=function(t,e,n,r){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Be(e.expression),this.interpolationType=r};function Kn(t,e){if("error"===(t=Zn(t,e)).result)return t;var n=t.value.expression,r=Fe(n);if(!r&&!On(e))return Nn([new kt("","data expressions not supported")]);var i=Ue(n,["zoom"]);if(!i&&!kn(e))return Nn([new kt("","zoom expressions not supported")]);var o=function t(e){var n=null;if(e instanceof cn)n=t(e.result);else if(e instanceof un)for(var r=0,i=e.args;r<i.length&&!(n=t(i[r]));r+=1);else(e instanceof He||e instanceof sn)&&e.input instanceof xe&&"zoom"===e.input.name&&(n=e);return n instanceof kt||e.eachChild((function(e){var r=t(e);r instanceof kt?n=r:!n&&r?n=new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new kt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),n}(n);return o||i?o instanceof kt?Nn([o]):o instanceof sn&&!zn(e)?Nn([new kt("",'"interpolate" expressions cannot be used with this property')]):Dn(o?new Jn(r?"camera":"composite",t.value,o.labels,o instanceof sn?o.interpolation:void 0):new Yn(r?"constant":"source",t.value)):Nn([new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}Jn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,o)},Jn.prototype.evaluate=function(t,e,n,r,i,o){return this._styleExpression.evaluate(t,e,n,r,i,o)},Jn.prototype.interpolationFactor=function(t,e,n){return this.interpolationType?sn.interpolationFactor(this.interpolationType,t,e,n):0};var Qn=function(t,e){this._parameters=t,this._specification=e,Dt(this,function t(e,n){var r,i,o,a="color"===n.type,s=e.stops&&"object"==typeof e.stops[0][0],l=s||!(s||void 0!==e.property),u=e.type||(zn(n)?"exponential":"interval");if(a&&((e=Dt({},e)).stops&&(e.stops=e.stops.map((function(t){return[t[0],ee.parse(t[1])]}))),e.default=ee.parse(e.default?e.default:n.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!an[e.colorSpace])throw new Error("Unknown color space: "+e.colorSpace);if("exponential"===u)r=Hn;else if("interval"===u)r=jn;else if("categorical"===u){r=Gn,i=Object.create(null);for(var c=0,h=e.stops;c<h.length;c+=1){var p=h[c];i[p[0]]=p[1]}o=typeof e.stops[0][0]}else{if("identity"!==u)throw new Error('Unknown function type "'+u+'"');r=qn}if(s){for(var f={},d=[],m=0;m<e.stops.length;m++){var g=e.stops[m],y=g[0].zoom;void 0===f[y]&&(f[y]={zoom:y,type:e.type,property:e.property,default:e.default,stops:[]},d.push(y)),f[y].stops.push([g[0].value,g[1]])}for(var v=[],_=0,x=d;_<x.length;_+=1){var b=x[_];v.push([f[b].zoom,t(f[b],n)])}var w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:sn.interpolationFactor.bind(void 0,w),zoomStops:v.map((function(t){return t[0]})),evaluate:function(t,r){var i=t.zoom;return Hn({stops:v,base:e.base},n,i).evaluate(i,r)}}}if(l){var E="exponential"===u?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:E,interpolationFactor:sn.interpolationFactor.bind(void 0,E),zoomStops:e.stops.map((function(t){return t[0]})),evaluate:function(t){return r(e,n,t.zoom,i,o)}}}return{kind:"source",evaluate:function(t,a){var s=a&&a.properties?a.properties[e.property]:void 0;return void 0===s?Vn(e.default,n.default):r(e,n,s,i,o)}}}(this._parameters,this._specification))};function $n(t){var e=t.key,n=t.value,r=t.valueSpec||{},i=t.objectElementValidators||{},o=t.style,a=t.styleSpec,s=[],l=Fn(n);if("object"!==l)return[new Pt(e,n,"object expected, "+l+" found")];for(var u in n){var c=u.split(".")[0],h=r[c]||r["*"],p=void 0;if(i[c])p=i[c];else if(r[c])p=Sr;else if(i["*"])p=i["*"];else{if(!r["*"]){s.push(new Pt(e,n[u],'unknown property "'+u+'"'));continue}p=Sr}s=s.concat(p({key:(e?e+".":e)+u,value:n[u],valueSpec:h,style:o,styleSpec:a,object:n,objectKey:u},n))}for(var f in r)i[f]||r[f].required&&void 0===r[f].default&&void 0===n[f]&&s.push(new Pt(e,n,'missing required property "'+f+'"'));return s}function tr(t){var e=t.value,n=t.valueSpec,r=t.style,i=t.styleSpec,o=t.key,a=t.arrayElementValidator||Sr;if("array"!==Fn(e))return[new Pt(o,e,"array expected, "+Fn(e)+" found")];if(n.length&&e.length!==n.length)return[new Pt(o,e,"array length "+n.length+" expected, length "+e.length+" found")];if(n["min-length"]&&e.length<n["min-length"])return[new Pt(o,e,"array length at least "+n["min-length"]+" expected, length "+e.length+" found")];var s={type:n.value,values:n.values};i.$version<7&&(s.function=n.function),"object"===Fn(n.value)&&(s=n.value);for(var l=[],u=0;u<e.length;u++)l=l.concat(a({array:e,arrayIndex:u,value:e[u],valueSpec:s,style:r,styleSpec:i,key:o+"["+u+"]"}));return l}function er(t){var e=t.key,n=t.value,r=t.valueSpec,i=Fn(n);return"number"===i&&n!=n&&(i="NaN"),"number"!==i?[new Pt(e,n,"number expected, "+i+" found")]:"minimum"in r&&n<r.minimum?[new Pt(e,n,n+" is less than the minimum value "+r.minimum)]:"maximum"in r&&n>r.maximum?[new Pt(e,n,n+" is greater than the maximum value "+r.maximum)]:[]}function nr(t){var e,n,r,i=t.valueSpec,o=Nt(t.value.type),a={},s="categorical"!==o&&void 0===t.value.property,l=!s,u="array"===Fn(t.value.stops)&&"array"===Fn(t.value.stops[0])&&"object"===Fn(t.value.stops[0][0]),c=$n({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new Pt(t.key,t.value,'identity function may not have a "stops" property')];var e=[],n=t.value;return e=e.concat(tr({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Fn(n)&&0===n.length&&e.push(new Pt(t.key,n,"array must have at least one stop")),e},default:function(t){return Sr({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===o&&s&&c.push(new Pt(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||c.push(new Pt(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!zn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!On(t.valueSpec)?c.push(new Pt(t.key,t.value,"property functions not supported")):s&&!kn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!u||void 0!==t.value.property||c.push(new Pt(t.key,t.value,'"property" property is required')),c;function h(t){var e=[],o=t.value,s=t.key;if("array"!==Fn(o))return[new Pt(s,o,"array expected, "+Fn(o)+" found")];if(2!==o.length)return[new Pt(s,o,"array length 2 expected, length "+o.length+" found")];if(u){if("object"!==Fn(o[0]))return[new Pt(s,o,"object expected, "+Fn(o[0])+" found")];if(void 0===o[0].zoom)return[new Pt(s,o,"object stop key must have zoom")];if(void 0===o[0].value)return[new Pt(s,o,"object stop key must have value")];if(r&&r>Nt(o[0].zoom))return[new Pt(s,o[0].zoom,"stop zoom values must appear in ascending order")];Nt(o[0].zoom)!==r&&(r=Nt(o[0].zoom),n=void 0,a={}),e=e.concat($n({key:s+"[0]",value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:er,value:p}}))}else e=e.concat(p({key:s+"[0]",value:o[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},o));return Xn(Ot(o[1]))?e.concat([new Pt(s+"[1]",o[1],"expressions are not allowed in function stops.")]):e.concat(Sr({key:s+"[1]",value:o[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,r){var s=Fn(t.value),l=Nt(t.value),u=null!==t.value?t.value:r;if(e){if(s!==e)return[new Pt(t.key,u,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new Pt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==o){var c="number expected, "+s+" found";return On(i)&&void 0===o&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pt(t.key,u,c)]}return"categorical"!==o||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===s&&void 0!==n&&l<n?[new Pt(t.key,u,"stop domain values must appear in ascending order")]:(n=l,"categorical"===o&&l in a?[new Pt(t.key,u,"stop domain values must be unique")]:(a[l]=!0,[])):[new Pt(t.key,u,"integer expected, found "+l)]}}function rr(t){var e=("property"===t.expressionContext?Kn:Zn)(Ot(t.value),t.valueSpec);if("error"===e.result)return e.value.map((function(e){return new Pt(""+t.key+e.key,t.value,e.message)}));var n=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new Pt(t.key,t.value,'Invalid data expression for "'+t.propertyKey+'". Output values must be contained as literals within the expression.')];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Be(n))return[new Pt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Be(n))return[new Pt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ue(n,["zoom","feature-state"]))return[new Pt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Fe(n))return[new Pt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ir(t){var e=t.key,n=t.value,r=t.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(Nt(n))&&i.push(new Pt(e,n,"expected one of ["+r.values.join(", ")+"], "+JSON.stringify(n)+" found")):-1===Object.keys(r.values).indexOf(Nt(n))&&i.push(new Pt(e,n,"expected one of ["+Object.keys(r.values).join(", ")+"], "+JSON.stringify(n)+" found")),i}function or(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(var e=0,n=t.slice(1);e<n.length;e+=1){var r=n[e];if(!or(r)&&"boolean"!=typeof r)return!1}return!0;default:return!0}}Qn.deserialize=function(t){return new Qn(t._parameters,t._specification)},Qn.serialize=function(t){return{_parameters:t._parameters,_specification:t._specification}};var ar={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function sr(t){if(null==t)return{filter:function(){return!0},needGeometry:!1};or(t)||(t=ur(t));var e=Zn(t,ar);if("error"===e.result)throw new Error(e.value.map((function(t){return t.key+": "+t.message})).join(", "));return{filter:function(t,n,r){return e.value.evaluate(t,n,{},r)},needGeometry:function t(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(var n=1;n<e.length;n++)if(t(e[n]))return!0;return!1}(t)}}function lr(t,e){return t<e?-1:t>e?1:0}function ur(t){if(!t)return!0;var e,n=t[0];return t.length<=1?"any"!==n:"=="===n?cr(t[1],t[2],"=="):"!="===n?fr(cr(t[1],t[2],"==")):"<"===n||">"===n||"<="===n||">="===n?cr(t[1],t[2],n):"any"===n?(e=t.slice(1),["any"].concat(e.map(ur))):"all"===n?["all"].concat(t.slice(1).map(ur)):"none"===n?["all"].concat(t.slice(1).map(ur).map(fr)):"in"===n?hr(t[1],t.slice(2)):"!in"===n?fr(hr(t[1],t.slice(2))):"has"===n?pr(t[1]):"!has"===n?fr(pr(t[1])):"within"!==n||t}function cr(t,e,n){switch(t){case"$type":return["filter-type-"+n,e];case"$id":return["filter-id-"+n,e];default:return["filter-"+n,t,e]}}function hr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((function(t){return typeof t!=typeof e[0]}))?["filter-in-large",t,["literal",e.sort(lr)]]:["filter-in-small",t,["literal",e]]}}function pr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function fr(t){return["!",t]}function dr(t){return or(Ot(t.value))?rr(Dt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var n=e.value,r=e.key;if("array"!==Fn(n))return[new Pt(r,n,"array expected, "+Fn(n)+" found")];var i,o=e.styleSpec,a=[];if(n.length<1)return[new Pt(r,n,"filter array must have at least 1 element")];switch(a=a.concat(ir({key:r+"[0]",value:n[0],valueSpec:o.filter_operator,style:e.style,styleSpec:e.styleSpec})),Nt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===Nt(n[1])&&a.push(new Pt(r,n,'"$type" cannot be use with operator "'+n[0]+'"'));case"==":case"!=":3!==n.length&&a.push(new Pt(r,n,'filter array for operator "'+n[0]+'" must have 3 elements'));case"in":case"!in":n.length>=2&&"string"!==(i=Fn(n[1]))&&a.push(new Pt(r+"[1]",n[1],"string expected, "+i+" found"));for(var s=2;s<n.length;s++)i=Fn(n[s]),"$type"===Nt(n[1])?a=a.concat(ir({key:r+"["+s+"]",value:n[s],valueSpec:o.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==i&&"number"!==i&&"boolean"!==i&&a.push(new Pt(r+"["+s+"]",n[s],"string, number, or boolean expected, "+i+" found"));break;case"any":case"all":case"none":for(var l=1;l<n.length;l++)a=a.concat(t({key:r+"["+l+"]",value:n[l],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":i=Fn(n[1]),2!==n.length?a.push(new Pt(r,n,'filter array for "'+n[0]+'" operator must have 2 elements')):"string"!==i&&a.push(new Pt(r+"[1]",n[1],"string expected, "+i+" found"));break;case"within":i=Fn(n[1]),2!==n.length?a.push(new Pt(r,n,'filter array for "'+n[0]+'" operator must have 2 elements')):"object"!==i&&a.push(new Pt(r+"[1]",n[1],"object expected, "+i+" found"))}return a}(t)}function mr(t,e){var n=t.key,r=t.style,i=t.styleSpec,o=t.value,a=t.objectKey,s=i[e+"_"+t.layerType];if(!s)return[];var l=a.match(/^(.*)-transition$/);if("paint"===e&&l&&s[l[1]]&&s[l[1]].transition)return Sr({key:n,value:o,valueSpec:i.transition,style:r,styleSpec:i});var u,c=t.valueSpec||s[a];if(!c)return[new Pt(n,o,'unknown property "'+a+'"')];if("string"===Fn(o)&&On(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new Pt(n,o,'"'+a+'" does not support interpolation syntax\nUse an identity property function instead: `{ "type": "identity", "property": '+JSON.stringify(u[1])+" }`.")];var h=[];return"symbol"===t.layerType&&("text-field"===a&&r&&!r.glyphs&&h.push(new Pt(n,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Bn(Ot(o))&&"identity"===Nt(o.type)&&h.push(new Pt(n,o,'"text-font" does not support identity functions'))),h.concat(Sr({key:t.key,value:o,valueSpec:c,style:r,styleSpec:i,expressionContext:"property",propertyType:e,propertyKey:a}))}function gr(t){return mr(t,"paint")}function yr(t){return mr(t,"layout")}function vr(t){var e=[],n=t.value,r=t.key,i=t.style,o=t.styleSpec;n.type||n.ref||e.push(new Pt(r,n,'either "type" or "ref" is required'));var a,s=Nt(n.type),l=Nt(n.ref);if(n.id)for(var u=Nt(n.id),c=0;c<t.arrayIndex;c++){var h=i.layers[c];Nt(h.id)===u&&e.push(new Pt(r,n.id,'duplicate layer id "'+n.id+'", previously used at line '+h.id.__line__))}if("ref"in n)["type","source","source-layer","filter","layout"].forEach((function(t){t in n&&e.push(new Pt(r,n[t],'"'+t+'" is prohibited for ref layers'))})),i.layers.forEach((function(t){Nt(t.id)===l&&(a=t)})),a?a.ref?e.push(new Pt(r,n.ref,"ref cannot reference another ref layer")):s=Nt(a.type):e.push(new Pt(r,n.ref,'ref layer "'+l+'" not found'));else if("background"!==s)if(n.source){var p=i.sources&&i.sources[n.source],f=p&&Nt(p.type);p?"vector"===f&&"raster"===s?e.push(new Pt(r,n.source,'layer "'+n.id+'" requires a raster source')):"raster"===f&&"raster"!==s?e.push(new Pt(r,n.source,'layer "'+n.id+'" requires a vector source')):"vector"!==f||n["source-layer"]?"raster-dem"===f&&"hillshade"!==s?e.push(new Pt(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!n.paint||!n.paint["line-gradient"]||"geojson"===f&&p.lineMetrics||e.push(new Pt(r,n,'layer "'+n.id+'" specifies a line-gradient, which requires a GeoJSON source with `lineMetrics` enabled.')):e.push(new Pt(r,n,'layer "'+n.id+'" must specify a "source-layer"')):e.push(new Pt(r,n.source,'source "'+n.source+'" not found'))}else e.push(new Pt(r,n,'missing required property "source"'));return e=e.concat($n({key:r,value:n,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":function(){return[]},type:function(){return Sr({key:r+".type",value:n.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"})},filter:dr,layout:function(t){return $n({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":function(t){return yr(Dt({layerType:s},t))}}})},paint:function(t){return $n({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":function(t){return gr(Dt({layerType:s},t))}}})}}}))}function _r(t){var e=t.value,n=t.key,r=Fn(e);return"string"!==r?[new Pt(n,e,"string expected, "+r+" found")]:[]}var xr={promoteId:function(t){var e=t.key,n=t.value;if("string"===Fn(n))return _r({key:e,value:n});var r=[];for(var i in n)r.push.apply(r,_r({key:e+"."+i,value:n[i]}));return r}};function br(t){var e=t.value,n=t.key,r=t.styleSpec,i=t.style;if(!e.type)return[new Pt(n,e,'"type" is required')];var o,a=Nt(e.type);switch(a){case"vector":case"raster":case"raster-dem":return $n({key:n,value:e,valueSpec:r["source_"+a.replace("-","_")],style:t.style,styleSpec:r,objectElementValidators:xr});case"geojson":if(o=$n({key:n,value:e,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:xr}),e.cluster)for(var s in e.clusterProperties){var l=e.clusterProperties[s],u=l[0],c="string"==typeof u?[u,["accumulated"],["get",s]]:u;o.push.apply(o,rr({key:n+"."+s+".map",value:l[1],expressionContext:"cluster-map"})),o.push.apply(o,rr({key:n+"."+s+".reduce",value:c,expressionContext:"cluster-reduce"}))}return o;case"video":return $n({key:n,value:e,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return $n({key:n,value:e,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new Pt(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ir({key:n+".type",value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,styleSpec:r})}}function wr(t){var e=t.value,n=t.styleSpec,r=n.light,i=t.style,o=[],a=Fn(e);if(void 0===e)return o;if("object"!==a)return o.concat([new Pt("light",e,"object expected, "+a+" found")]);for(var s in e){var l=s.match(/^(.*)-transition$/);o=o.concat(l&&r[l[1]]&&r[l[1]].transition?Sr({key:s,value:e[s],valueSpec:n.transition,style:i,styleSpec:n}):r[s]?Sr({key:s,value:e[s],valueSpec:r[s],style:i,styleSpec:n}):[new Pt(s,e[s],'unknown property "'+s+'"')])}return o}var Er={"*":function(){return[]},array:tr,boolean:function(t){var e=t.value,n=t.key,r=Fn(e);return"boolean"!==r?[new Pt(n,e,"boolean expected, "+r+" found")]:[]},number:er,color:function(t){var e=t.key,n=t.value,r=Fn(n);return"string"!==r?[new Pt(e,n,"color expected, "+r+" found")]:null===te(n)?[new Pt(e,n,'color expected, "'+n+'" found')]:[]},constants:Rt,enum:ir,filter:dr,function:nr,layer:vr,object:$n,source:br,light:wr,string:_r,formatted:function(t){return 0===_r(t).length?[]:rr(t)},resolvedImage:function(t){return 0===_r(t).length?[]:rr(t)}};function Sr(t){var e=t.value,n=t.valueSpec,r=t.styleSpec;return n.expression&&Bn(Nt(e))?nr(t):n.expression&&Xn(Ot(e))?rr(t):n.type&&Er[n.type]?Er[n.type](t):$n(Dt({},t,{valueSpec:n.type?r[n.type]:n}))}function Mr(t){var e=t.value,n=t.key,r=_r(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Pt(n,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Pt(n,e,'"glyphs" url must include a "{range}" token'))),r}function Tr(t,e){void 0===e&&(e=Lt);var n=[];return n=n.concat(Sr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Mr,"*":function(){return[]}}})),t.constants&&(n=n.concat(Rt({key:"constants",value:t.constants,style:t,styleSpec:e}))),Cr(n)}function Cr(t){return[].concat(t).sort((function(t,e){return t.line-e.line}))}function Ir(t){return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return Cr(t.apply(this,e))}}Tr.source=Ir(br),Tr.light=Ir(wr),Tr.layer=Ir(vr),Tr.filter=Ir(dr),Tr.paintProperty=Ir(gr),Tr.layoutProperty=Ir(yr);var Ar=Tr,Lr=Ar.light,Pr=Ar.paintProperty,Rr=Ar.layoutProperty;function Dr(t,e){var n=!1;if(e&&e.length)for(var r=0,i=e;r<i.length;r+=1)t.fire(new It(new Error(i[r].message))),n=!0;return n}var Nr=Or;function Or(t,e,n){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(n=i[2]);for(var o=0;o<this.d*this.d;o++){var a=i[3+o],s=i[3+o+1];r.push(a===s?null:i.subarray(a,s))}var l=i[3+r.length+1];this.keys=i.subarray(i[3+r.length],l),this.bboxes=i.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*n;for(var u=0;u<this.d*this.d;u++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=n,this.scale=e/t,this.uid=0;var c=n/e*t;this.min=-c,this.max=t+c}Or.prototype.insert=function(t,e,n,r,i){this._forEachCell(e,n,r,i,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)},Or.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Or.prototype._insertCell=function(t,e,n,r,i,o){this.cells[i].push(o)},Or.prototype.query=function(t,e,n,r,i){var o=this.min,a=this.max;if(t<=o&&e<=o&&a<=n&&a<=r&&!i)return Array.prototype.slice.call(this.keys);var s=[];return this._forEachCell(t,e,n,r,this._queryCell,s,{},i),s},Or.prototype._queryCell=function(t,e,n,r,i,o,a,s){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===a[p]){var f=4*p;(s?s(c[f+0],c[f+1],c[f+2],c[f+3]):t<=c[f+2]&&e<=c[f+3]&&n>=c[f+0]&&r>=c[f+1])?(a[p]=!0,o.push(u[p])):a[p]=!1}}},Or.prototype._forEachCell=function(t,e,n,r,i,o,a,s){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!s||s(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,n,r,d,o,a,s))return}},Or.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Or.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Or.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,n=0,r=0;r<this.cells.length;r++)n+=this.cells[r].length;var i=new Int32Array(e+n+this.keys.length+this.bboxes.length);i[0]=this.extent,i[1]=this.n,i[2]=this.padding;for(var o=e,a=0;a<t.length;a++){var s=t[a];i[3+a]=o,i.set(s,o),o+=s.length}return i[3+t.length]=o,i.set(this.keys,o),i[3+t.length+1]=o+=this.keys.length,i.set(this.bboxes,o),o+=this.bboxes.length,i.buffer};var kr=a.ImageData,zr=a.ImageBitmap,Fr={};function Br(t,e,n){void 0===n&&(n={}),Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Fr[t]={klass:e,omit:n.omit||[],shallow:n.shallow||[]}}for(var Ur in Br("Object",Object),Nr.serialize=function(t,e){var n=t.toArrayBuffer();return e&&e.push(n),{buffer:n}},Nr.deserialize=function(t){return new Nr(t.buffer)},Br("Grid",Nr),Br("Color",ee),Br("Error",Error),Br("ResolvedImage",oe),Br("StylePropertyFunction",Qn),Br("StyleExpression",Wn,{omit:["_evaluator"]}),Br("ZoomDependentExpression",Jn),Br("ZoomConstantExpression",Yn),Br("CompoundExpression",xe,{omit:["_evaluate"]}),In)In[Ur]._classRegistryKey||Br("Expression_"+Ur,In[Ur]);function Vr(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Gr(t){return zr&&t instanceof zr}function jr(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Vr(t)||Gr(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){var n=t;return e&&e.push(n.buffer),n}if(t instanceof kr)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){for(var r=[],i=0,o=t;i<o.length;i+=1)r.push(jr(o[i],e));return r}if("object"==typeof t){var a=t.constructor,s=a._classRegistryKey;if(!s)throw new Error("can't serialize object of unregistered class");var l=a.serialize?a.serialize(t,e):{};if(!a.serialize){for(var u in t)if(t.hasOwnProperty(u)&&!(Fr[s].omit.indexOf(u)>=0)){var c=t[u];l[u]=Fr[s].shallow.indexOf(u)>=0?c:jr(c,e)}t instanceof Error&&(l.message=t.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==s&&(l.$name=s),l}throw new Error("can't serialize object of type "+typeof t)}function Hr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Vr(t)||Gr(t)||ArrayBuffer.isView(t)||t instanceof kr)return t;if(Array.isArray(t))return t.map(Hr);if("object"==typeof t){var e=t.$name||"Object",n=Fr[e].klass;if(!n)throw new Error("can't deserialize unregistered class "+e);if(n.deserialize)return n.deserialize(t);for(var r=Object.create(n.prototype),i=0,o=Object.keys(t);i<o.length;i+=1){var a=o[i];if("$name"!==a){var s=t[a];r[a]=Fr[e].shallow.indexOf(a)>=0?s:Hr(s)}}return r}throw new Error("can't deserialize object of type "+typeof t)}var qr=function(){this.first=!0};qr.prototype.update=function(t,e){var n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=n,!0))};var Wr={"Latin-1 Supplement":function(t){return t>=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function Xr(t){for(var e=0,n=t;e<n.length;e+=1)if(Zr(n[e].charCodeAt(0)))return!0;return!1}function Zr(t){return!(746!==t&&747!==t&&(t<4352||!(Wr["Bopomofo Extended"](t)||Wr.Bopomofo(t)||Wr["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Wr["CJK Compatibility Ideographs"](t)||Wr["CJK Compatibility"](t)||Wr["CJK Radicals Supplement"](t)||Wr["CJK Strokes"](t)||!(!Wr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Wr["CJK Unified Ideographs Extension A"](t)||Wr["CJK Unified Ideographs"](t)||Wr["Enclosed CJK Letters and Months"](t)||Wr["Hangul Compatibility Jamo"](t)||Wr["Hangul Jamo Extended-A"](t)||Wr["Hangul Jamo Extended-B"](t)||Wr["Hangul Jamo"](t)||Wr["Hangul Syllables"](t)||Wr.Hiragana(t)||Wr["Ideographic Description Characters"](t)||Wr.Kanbun(t)||Wr["Kangxi Radicals"](t)||Wr["Katakana Phonetic Extensions"](t)||Wr.Katakana(t)&&12540!==t||!(!Wr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Wr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Wr["Unified Canadian Aboriginal Syllabics"](t)||Wr["Unified Canadian Aboriginal Syllabics Extended"](t)||Wr["Vertical Forms"](t)||Wr["Yijing Hexagram Symbols"](t)||Wr["Yi Syllables"](t)||Wr["Yi Radicals"](t))))}function Yr(t){return!(Zr(t)||function(t){return!!(Wr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Wr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Wr["Letterlike Symbols"](t)||Wr["Number Forms"](t)||Wr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Wr["Control Pictures"](t)&&9251!==t||Wr["Optical Character Recognition"](t)||Wr["Enclosed Alphanumerics"](t)||Wr["Geometric Shapes"](t)||Wr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Wr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Wr["CJK Symbols and Punctuation"](t)||Wr.Katakana(t)||Wr["Private Use Area"](t)||Wr["CJK Compatibility Forms"](t)||Wr["Small Form Variants"](t)||Wr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Jr(t){return t>=1424&&t<=2303||Wr["Arabic Presentation Forms-A"](t)||Wr["Arabic Presentation Forms-B"](t)}function Kr(t,e){return!(!e&&Jr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Wr.Khmer(t))}function Qr(t){for(var e=0,n=t;e<n.length;e+=1)if(Jr(n[e].charCodeAt(0)))return!0;return!1}var $r=null,ti="unavailable",ei=null,ni=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(ti="error"),$r&&$r(t)};function ri(){ii.fire(new Ct("pluginStateChange",{pluginStatus:ti,pluginURL:ei}))}var ii=new At,oi=function(){return ti},ai=function(){if("deferred"!==ti||!ei)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ti="loading",ri(),ei&&bt({url:ei},(function(t){t?ni(t):(ti="loaded",ri())}))},si={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return"loaded"===ti||null!=si.applyArabicShaping},isLoading:function(){return"loading"===ti},setState:function(t){ti=t.pluginStatus,ei=t.pluginURL},isParsed:function(){return null!=si.applyArabicShaping&&null!=si.processBidirectionalText&&null!=si.processStyledBidirectionalText},getPluginURL:function(){return ei}},li=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new qr,this.transition={})};li.prototype.isSupportedScript=function(t){return function(t,e){for(var n=0,r=t;n<r.length;n+=1)if(!Kr(r[n].charCodeAt(0),e))return!1;return!0}(t,si.isLoaded())},li.prototype.crossFadingFactor=function(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)},li.prototype.getCrossfadeParameters=function(){var t=this.zoom,e=t-Math.floor(t),n=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*e}};var ui=function(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Bn(t))return new Qn(t,e);if(Xn(t)){var n=Kn(t,e);if("error"===n.result)throw new Error(n.value.map((function(t){return t.key+": "+t.message})).join(", "));return n.value}var r=t;return"string"==typeof t&&"color"===e.type&&(r=ee.parse(t)),{kind:"constant",evaluate:function(){return r}}}(void 0===e?t.specification.default:e,t.specification)};ui.prototype.isDataDriven=function(){return"source"===this.expression.kind||"composite"===this.expression.kind},ui.prototype.possiblyEvaluate=function(t,e,n){return this.property.possiblyEvaluate(this,t,e,n)};var ci=function(t){this.property=t,this.value=new ui(t,void 0)};ci.prototype.transitioned=function(t,e){return new pi(this.property,this.value,e,p({},t.transition,this.transition),t.now)},ci.prototype.untransitioned=function(){return new pi(this.property,this.value,null,{},0)};var hi=function(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)};hi.prototype.getValue=function(t){return b(this._values[t].value.value)},hi.prototype.setValue=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].value=new ui(this._values[t].property,null===e?void 0:b(e))},hi.prototype.getTransition=function(t){return b(this._values[t].transition)},hi.prototype.setTransition=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].transition=b(e)||void 0},hi.prototype.serialize=function(){for(var t={},e=0,n=Object.keys(this._values);e<n.length;e+=1){var r=n[e],i=this.getValue(r);void 0!==i&&(t[r]=i);var o=this.getTransition(r);void 0!==o&&(t[r+"-transition"]=o)}return t},hi.prototype.transitioned=function(t,e){for(var n=new fi(this._properties),r=0,i=Object.keys(this._values);r<i.length;r+=1){var o=i[r];n._values[o]=this._values[o].transitioned(t,e._values[o])}return n},hi.prototype.untransitioned=function(){for(var t=new fi(this._properties),e=0,n=Object.keys(this._values);e<n.length;e+=1){var r=n[e];t._values[r]=this._values[r].untransitioned()}return t};var pi=function(t,e,n,r,i){this.property=t,this.value=e,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=n)};pi.prototype.possiblyEvaluate=function(t,e,n){var r=t.now||0,i=this.value.possiblyEvaluate(t,e,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(r<this.begin)return o.possiblyEvaluate(t,e,n);var a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,n),i,function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}(a))}return i};var fi=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};fi.prototype.possiblyEvaluate=function(t,e,n){for(var r=new gi(this._properties),i=0,o=Object.keys(this._values);i<o.length;i+=1){var a=o[i];r._values[a]=this._values[a].possiblyEvaluate(t,e,n)}return r},fi.prototype.hasTransition=function(){for(var t=0,e=Object.keys(this._values);t<e.length;t+=1)if(this._values[e[t]].prior)return!0;return!1};var di=function(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)};di.prototype.getValue=function(t){return b(this._values[t].value)},di.prototype.setValue=function(t,e){this._values[t]=new ui(this._values[t].property,null===e?void 0:b(e))},di.prototype.serialize=function(){for(var t={},e=0,n=Object.keys(this._values);e<n.length;e+=1){var r=n[e],i=this.getValue(r);void 0!==i&&(t[r]=i)}return t},di.prototype.possiblyEvaluate=function(t,e,n){for(var r=new gi(this._properties),i=0,o=Object.keys(this._values);i<o.length;i+=1){var a=o[i];r._values[a]=this._values[a].possiblyEvaluate(t,e,n)}return r};var mi=function(t,e,n){this.property=t,this.value=e,this.parameters=n};mi.prototype.isConstant=function(){return"constant"===this.value.kind},mi.prototype.constantOr=function(t){return"constant"===this.value.kind?this.value.value:t},mi.prototype.evaluate=function(t,e,n,r){return this.property.evaluate(this.value,this.parameters,t,e,n,r)};var gi=function(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)};gi.prototype.get=function(t){return this._values[t]};var yi=function(t){this.specification=t};yi.prototype.possiblyEvaluate=function(t,e){return t.expression.evaluate(e)},yi.prototype.interpolate=function(t,e,n){var r=We[this.specification.type];return r?r(t,e,n):t};var vi=function(t,e){this.specification=t,this.overrides=e};vi.prototype.possiblyEvaluate=function(t,e,n,r){return new mi(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},n,r)}:t.expression,e)},vi.prototype.interpolate=function(t,e,n){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new mi(this,{kind:"constant",value:void 0},t.parameters);var r=We[this.specification.type];return r?new mi(this,{kind:"constant",value:r(t.value.value,e.value.value,n)},t.parameters):t},vi.prototype.evaluate=function(t,e,n,r,i,o){return"constant"===t.kind?t.value:t.evaluate(e,n,r,i,o)};var _i=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.possiblyEvaluate=function(t,e,n,r){if(void 0===t.value)return new mi(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){var i=t.expression.evaluate(e,null,{},n,r),o="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,a=this._calculate(o,o,o,e);return new mi(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){var s=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new mi(this,{kind:"constant",value:s},e)}return new mi(this,t.expression,e)},e.prototype.evaluate=function(t,e,n,r,i,o){if("source"===t.kind){var a=t.evaluate(e,n,r,i,o);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},n,r),t.evaluate({zoom:Math.floor(e.zoom)},n,r),t.evaluate({zoom:Math.floor(e.zoom)+1},n,r),e):t.value},e.prototype._calculate=function(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},e.prototype.interpolate=function(t){return t},e}(vi),xi=function(t){this.specification=t};xi.prototype.possiblyEvaluate=function(t,e,n,r){if(void 0!==t.value){if("constant"===t.expression.kind){var i=t.expression.evaluate(e,null,{},n,r);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new li(Math.floor(e.zoom-1),e)),t.expression.evaluate(new li(Math.floor(e.zoom),e)),t.expression.evaluate(new li(Math.floor(e.zoom+1),e)),e)}},xi.prototype._calculate=function(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},xi.prototype.interpolate=function(t){return t};var bi=function(t){this.specification=t};bi.prototype.possiblyEvaluate=function(t,e,n,r){return!!t.expression.evaluate(e,null,{},n,r)},bi.prototype.interpolate=function(){return!1};var wi=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],t){var n=t[e];n.specification.overridable&&this.overridableProperties.push(e);var r=this.defaultPropertyValues[e]=new ui(n,void 0),i=this.defaultTransitionablePropertyValues[e]=new ci(n);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}};Br("DataDrivenProperty",vi),Br("DataConstantProperty",yi),Br("CrossFadedDataDrivenProperty",_i),Br("CrossFadedProperty",xi),Br("ColorRampProperty",bi);var Ei=function(t){function e(e,n){if(t.call(this),this.id=e.id,this.type=e.type,this._featureFilter={filter:function(){return!0},needGeometry:!1},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),n.layout&&(this._unevaluatedLayout=new di(n.layout)),n.paint)){for(var r in this._transitionablePaint=new hi(n.paint),e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new gi(n.paint)}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getCrossfadeParameters=function(){return this._crossfadeParameters},e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,n){void 0===n&&(n={}),null!=e&&this._validate(Rr,"layers."+this.id+".layout."+t,t,e,n)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,n){if(void 0===n&&(n={}),null!=e&&this._validate(Pr,"layers."+this.id+".paint."+t,t,e,n))return!1;if(v(t,"-transition"))return this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0),!1;var r=this._transitionablePaint._values[t],i="cross-faded-data-driven"===r.property.specification["property-type"],o=r.value.isDataDriven(),a=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);var s=this._transitionablePaint._values[t].value;return s.isDataDriven()||o||i||this._handleOverridablePaintPropertyUpdate(t,a,s)},e.prototype._handleSpecialPaintPropertyUpdate=function(t){},e.prototype._handleOverridablePaintPropertyUpdate=function(t,e,n){return!1},e.prototype.isHidden=function(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),x(t,(function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)}))},e.prototype._validate=function(t,e,n,r,i){return void 0===i&&(i={}),(!i||!1!==i.validate)&&Dr(this,t.call(Ar,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:Lt,style:{glyphs:!0,sprite:!0}}))},e.prototype.is3D=function(){return!1},e.prototype.isTileClipped=function(){return!1},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e.prototype.isStateDependent=function(){for(var t in this.paint._values){var e=this.paint.get(t);if(e instanceof mi&&On(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1},e}(At),Si={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Mi=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Ti=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Ci(t,e){void 0===e&&(e=1);var n=0,r=0;return{members:t.map((function(t){var i=Si[t.type].BYTES_PER_ELEMENT,o=n=Ii(n,Math.max(e,i)),a=t.components||1;return r=Math.max(r,i),n+=i*a,{name:t.name,type:t.type,components:a,offset:o}})),size:Ii(n,Math.max(r,e)),alignment:e}}function Ii(t,e){return Math.ceil(t/e)*e}Ti.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Ti.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Ti.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Ti.prototype.clear=function(){this.length=0},Ti.prototype.resize=function(t){this.reserve(t),this.length=t},Ti.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Ti.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Ai=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.int16[r+0]=e,this.int16[r+1]=n,t},e}(Ti);Ai.prototype.bytesPerElement=4,Br("StructArrayLayout2i4",Ai);var Li=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.int16[o+0]=e,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,t},e}(Ti);Li.prototype.bytesPerElement=8,Br("StructArrayLayout4i8",Li);var Pi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ti);Pi.prototype.bytesPerElement=12,Br("StructArrayLayout2i4i12",Pi);var Ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.uint8[l+4]=r,this.uint8[l+5]=i,this.uint8[l+6]=o,this.uint8[l+7]=a,t},e}(Ti);Ri.prototype.bytesPerElement=8,Br("StructArrayLayout2i4ub8",Ri);var Di=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.float32[r+0]=e,this.float32[r+1]=n,t},e}(Ti);Di.prototype.bytesPerElement=8,Br("StructArrayLayout2f8",Di);var Ni=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u){var c=this.length;return this.resize(c+1),this.emplace(c,t,e,n,r,i,o,a,s,l,u)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c){var h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=n,this.uint16[h+2]=r,this.uint16[h+3]=i,this.uint16[h+4]=o,this.uint16[h+5]=a,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t},e}(Ti);Ni.prototype.bytesPerElement=20,Br("StructArrayLayout10ui20",Ni);var Oi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h){var p=this.length;return this.resize(p+1),this.emplace(p,t,e,n,r,i,o,a,s,l,u,c,h)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p){var f=12*t;return this.int16[f+0]=e,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t},e}(Ti);Oi.prototype.bytesPerElement=24,Br("StructArrayLayout4i4ui4i24",Oi);var ki=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.float32[i+0]=e,this.float32[i+1]=n,this.float32[i+2]=r,t},e}(Ti);ki.prototype.bytesPerElement=12,Br("StructArrayLayout3f12",ki);var zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint32[1*t+0]=e,t},e}(Ti);zi.prototype.bytesPerElement=4,Br("StructArrayLayout1ul4",zi);var Fi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l){var u=this.length;return this.resize(u+1),this.emplace(u,t,e,n,r,i,o,a,s,l)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u){var c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=n,this.int16[c+2]=r,this.int16[c+3]=i,this.int16[c+4]=o,this.int16[c+5]=a,this.uint32[h+3]=s,this.uint16[c+8]=l,this.uint16[c+9]=u,t},e}(Ti);Fi.prototype.bytesPerElement=20,Br("StructArrayLayout6i1ul2ui20",Fi);var Bi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ti);Bi.prototype.bytesPerElement=12,Br("StructArrayLayout2i2i2i12",Bi);var Ui=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i)},e.prototype.emplace=function(t,e,n,r,i,o){var a=4*t,s=8*t;return this.float32[a+0]=e,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,t},e}(Ti);Ui.prototype.bytesPerElement=16,Br("StructArrayLayout2f1f2i16",Ui);var Vi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=12*t,a=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,t},e}(Ti);Vi.prototype.bytesPerElement=12,Br("StructArrayLayout2ub2f12",Vi);var Gi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=n,this.uint16[i+2]=r,t},e}(Ti);Gi.prototype.bytesPerElement=6,Br("StructArrayLayout3ui6",Gi);var ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g){var y=this.length;return this.resize(y+1),this.emplace(y,t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y){var v=24*t,_=12*t,x=48*t;return this.int16[v+0]=e,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[_+2]=o,this.uint32[_+3]=a,this.uint32[_+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=u,this.uint16[v+12]=c,this.float32[_+7]=h,this.float32[_+8]=p,this.uint8[x+36]=f,this.uint8[x+37]=d,this.uint8[x+38]=m,this.uint32[_+10]=g,this.int16[v+22]=y,t},e}(Ti);ji.prototype.bytesPerElement=48,Br("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ji);var Hi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C){var I=this.length;return this.resize(I+1),this.emplace(I,t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C,I){var A=34*t,L=17*t;return this.int16[A+0]=e,this.int16[A+1]=n,this.int16[A+2]=r,this.int16[A+3]=i,this.int16[A+4]=o,this.int16[A+5]=a,this.int16[A+6]=s,this.int16[A+7]=l,this.uint16[A+8]=u,this.uint16[A+9]=c,this.uint16[A+10]=h,this.uint16[A+11]=p,this.uint16[A+12]=f,this.uint16[A+13]=d,this.uint16[A+14]=m,this.uint16[A+15]=g,this.uint16[A+16]=y,this.uint16[A+17]=v,this.uint16[A+18]=_,this.uint16[A+19]=x,this.uint16[A+20]=b,this.uint16[A+21]=w,this.uint16[A+22]=E,this.uint32[L+12]=S,this.float32[L+13]=M,this.float32[L+14]=T,this.float32[L+15]=C,this.float32[L+16]=I,t},e}(Ti);Hi.prototype.bytesPerElement=68,Br("StructArrayLayout8i15ui1ul4f68",Hi);var qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.float32[1*t+0]=e,t},e}(Ti);qi.prototype.bytesPerElement=4,Br("StructArrayLayout1f4",qi);var Wi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.int16[i+0]=e,this.int16[i+1]=n,this.int16[i+2]=r,t},e}(Ti);Wi.prototype.bytesPerElement=6,Br("StructArrayLayout3i6",Wi);var Xi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=n,this.uint16[i+3]=r,t},e}(Ti);Xi.prototype.bytesPerElement=8,Br("StructArrayLayout1ul2ui8",Xi);var Zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=n,t},e}(Ti);Zi.prototype.bytesPerElement=4,Br("StructArrayLayout2ui4",Zi);var Yi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint16[1*t+0]=e,t},e}(Ti);Yi.prototype.bytesPerElement=2,Br("StructArrayLayout1ui2",Yi);var Ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.float32[o+0]=e,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,t},e}(Ti);Ji.prototype.bytesPerElement=16,Br("StructArrayLayout4f16",Ji);var Ki=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},anchorPoint:{configurable:!0}};return n.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},n.x1.get=function(){return this._structArray.int16[this._pos2+2]},n.y1.get=function(){return this._structArray.int16[this._pos2+3]},n.x2.get=function(){return this._structArray.int16[this._pos2+4]},n.y2.get=function(){return this._structArray.int16[this._pos2+5]},n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.anchorPoint.get=function(){return new i(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,n),e}(Mi);Ki.prototype.size=20;var Qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new Ki(this,t)},e}(Fi);Br("CollisionBoxArray",Qi);var $i=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},placedOrientation:{configurable:!0},hidden:{configurable:!0},crossTileID:{configurable:!0},associatedIconIndex:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},n.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},n.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},n.segment.get=function(){return this._structArray.uint16[this._pos2+10]},n.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},n.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},n.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},n.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},n.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},n.placedOrientation.get=function(){return this._structArray.uint8[this._pos1+37]},n.placedOrientation.set=function(t){this._structArray.uint8[this._pos1+37]=t},n.hidden.get=function(){return this._structArray.uint8[this._pos1+38]},n.hidden.set=function(t){this._structArray.uint8[this._pos1+38]=t},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+10]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+10]=t},n.associatedIconIndex.get=function(){return this._structArray.int16[this._pos2+22]},Object.defineProperties(e.prototype,n),e}(Mi);$i.prototype.size=48;var to=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new $i(this,t)},e}(ji);Br("PlacedSymbolArray",to);var eo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},rightJustifiedTextSymbolIndex:{configurable:!0},centerJustifiedTextSymbolIndex:{configurable:!0},leftJustifiedTextSymbolIndex:{configurable:!0},verticalPlacedTextSymbolIndex:{configurable:!0},placedIconSymbolIndex:{configurable:!0},verticalPlacedIconSymbolIndex:{configurable:!0},key:{configurable:!0},textBoxStartIndex:{configurable:!0},textBoxEndIndex:{configurable:!0},verticalTextBoxStartIndex:{configurable:!0},verticalTextBoxEndIndex:{configurable:!0},iconBoxStartIndex:{configurable:!0},iconBoxEndIndex:{configurable:!0},verticalIconBoxStartIndex:{configurable:!0},verticalIconBoxEndIndex:{configurable:!0},featureIndex:{configurable:!0},numHorizontalGlyphVertices:{configurable:!0},numVerticalGlyphVertices:{configurable:!0},numIconVertices:{configurable:!0},numVerticalIconVertices:{configurable:!0},useRuntimeCollisionCircles:{configurable:!0},crossTileID:{configurable:!0},textBoxScale:{configurable:!0},textOffset0:{configurable:!0},textOffset1:{configurable:!0},collisionCircleDiameter:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.rightJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+2]},n.centerJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+3]},n.leftJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+4]},n.verticalPlacedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+5]},n.placedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+6]},n.verticalPlacedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+7]},n.key.get=function(){return this._structArray.uint16[this._pos2+8]},n.textBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.textBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+10]},n.verticalTextBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+11]},n.verticalTextBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+12]},n.iconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+13]},n.iconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+14]},n.verticalIconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+15]},n.verticalIconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+16]},n.featureIndex.get=function(){return this._structArray.uint16[this._pos2+17]},n.numHorizontalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+18]},n.numVerticalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+19]},n.numIconVertices.get=function(){return this._structArray.uint16[this._pos2+20]},n.numVerticalIconVertices.get=function(){return this._structArray.uint16[this._pos2+21]},n.useRuntimeCollisionCircles.get=function(){return this._structArray.uint16[this._pos2+22]},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+12]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+12]=t},n.textBoxScale.get=function(){return this._structArray.float32[this._pos4+13]},n.textOffset0.get=function(){return this._structArray.float32[this._pos4+14]},n.textOffset1.get=function(){return this._structArray.float32[this._pos4+15]},n.collisionCircleDiameter.get=function(){return this._structArray.float32[this._pos4+16]},Object.defineProperties(e.prototype,n),e}(Mi);eo.prototype.size=68;var no=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new eo(this,t)},e}(Hi);Br("SymbolInstanceArray",no);var ro=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e}(qi);Br("GlyphOffsetArray",ro);var io=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e}(Wi);Br("SymbolLineVertexArray",io);var oo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},Object.defineProperties(e.prototype,n),e}(Mi);oo.prototype.size=8;var ao=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new oo(this,t)},e}(Xi);Br("FeatureIndexArray",ao);var so=Ci([{name:"a_pos",components:2,type:"Int16"}],4).members,lo=function(t){void 0===t&&(t=[]),this.segments=t};function uo(t,e){return 256*(t=c(Math.floor(t),0,255))+c(Math.floor(e),0,255)}lo.prototype.prepareSegment=function(t,e,n,r){var i=this.segments[this.segments.length-1];return t>lo.MAX_VERTEX_ARRAY_LENGTH&&E("Max vertices per segment is "+lo.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!i||i.vertexLength+t>lo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i},lo.prototype.get=function(){return this.segments},lo.prototype.destroy=function(){for(var t=0,e=this.segments;t<e.length;t+=1){var n=e[t];for(var r in n.vaos)n.vaos[r].destroy()}},lo.simpleSegment=function(t,e,n,r){return new lo([{vertexOffset:t,primitiveOffset:e,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])},lo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Br("SegmentVector",lo);var co=Ci([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ho=e((function(t){t.exports=function(t,e){var n,r,i,o,a,s,l,u;for(r=t.length-(n=3&t.length),i=e,a=3432918353,s=461845907,u=0;u<r;)l=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,i=27492+(65535&(o=5*(65535&(i=(i^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}})),po=e((function(t){t.exports=function(t,e){for(var n,r=t.length,i=e^r,o=0;r>=4;)n=1540483477*(65535&(n=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}})),fo=ho,mo=po;fo.murmur3=ho,fo.murmur2=mo;var go=function(){this.ids=[],this.positions=[],this.indexed=!1};go.prototype.add=function(t,e,n,r){this.ids.push(vo(t)),this.positions.push(e,n,r)},go.prototype.getPositions=function(t){for(var e=vo(t),n=0,r=this.ids.length-1;n<r;){var i=n+r>>1;this.ids[i]>=e?r=i:n=i+1}for(var o=[];this.ids[n]===e;)o.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return o},go.serialize=function(t,e){var n=new Float64Array(t.ids),r=new Uint32Array(t.positions);return function t(e,n,r,i){for(;r<i;){for(var o=e[r+i>>1],a=r-1,s=i+1;;){do{a++}while(e[a]<o);do{s--}while(e[s]>o);if(a>=s)break;_o(e,a,s),_o(n,3*a,3*s),_o(n,3*a+1,3*s+1),_o(n,3*a+2,3*s+2)}s-r<i-s?(t(e,n,r,s),r=s+1):(t(e,n,s+1,i),i=s)}}(n,r,0,n.length-1),e&&e.push(n.buffer,r.buffer),{ids:n,positions:r}},go.deserialize=function(t){var e=new go;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e};var yo=Math.pow(2,53)-1;function vo(t){var e=+t;return!isNaN(e)&&e<=yo?e:fo(String(t))}function _o(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}Br("FeaturePositionMap",go);var xo=function(t,e){this.gl=t.gl,this.location=e},bo=function(t){function e(e,n){t.call(this,e,n),this.current=0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))},e}(xo),wo=function(t){function e(e,n){t.call(this,e,n),this.current=0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))},e}(xo),Eo=function(t){function e(e,n){t.call(this,e,n),this.current=[0,0]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))},e}(xo),So=function(t){function e(e,n){t.call(this,e,n),this.current=[0,0,0]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))},e}(xo),Mo=function(t){function e(e,n){t.call(this,e,n),this.current=[0,0,0,0]}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))},e}(xo),To=function(t){function e(e,n){t.call(this,e,n),this.current=ee.transparent}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))},e}(xo),Co=new Float32Array(16),Io=function(t){function e(e,n){t.call(this,e,n),this.current=Co}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(var e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}},e}(xo);function Ao(t){return[uo(255*t.r,255*t.g),uo(255*t.b,255*t.a)]}var Lo=function(t,e,n){this.value=t,this.uniformNames=e.map((function(t){return"u_"+t})),this.type=n};Lo.prototype.setUniform=function(t,e,n){t.set(n.constantOr(this.value))},Lo.prototype.getBinding=function(t,e,n){return"color"===this.type?new To(t,e):new wo(t,e)};var Po=function(t,e){this.uniformNames=e.map((function(t){return"u_"+t})),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1};Po.prototype.setConstantPatternPositions=function(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr},Po.prototype.setUniform=function(t,e,n,r){var i="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;i&&t.set(i)},Po.prototype.getBinding=function(t,e,n){return"u_pattern"===n.substr(0,9)?new Mo(t,e):new wo(t,e)};var Ro=function(t,e,n,r){this.expression=t,this.type=n,this.maxValue=0,this.paintVertexAttributes=e.map((function(t){return{name:"a_"+t,type:"Float32",components:"color"===n?2:1,offset:0}})),this.paintVertexArray=new r};Ro.prototype.populatePaintArray=function(t,e,n,r,i){var o=this.paintVertexArray.length,a=this.expression.evaluate(new li(0),e,{},r,[],i);this.paintVertexArray.resize(t),this._setPaintValue(o,t,a)},Ro.prototype.updatePaintArray=function(t,e,n,r){var i=this.expression.evaluate({zoom:0},n,r);this._setPaintValue(t,e,i)},Ro.prototype._setPaintValue=function(t,e,n){if("color"===this.type)for(var r=Ao(n),i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1]);else{for(var o=t;o<e;o++)this.paintVertexArray.emplace(o,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}},Ro.prototype.upload=function(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))},Ro.prototype.destroy=function(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()};var Do=function(t,e,n,r,i,o){this.expression=t,this.uniformNames=e.map((function(t){return"u_"+t+"_t"})),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((function(t){return{name:"a_"+t,type:"Float32",components:"color"===n?4:2,offset:0}})),this.paintVertexArray=new o};Do.prototype.populatePaintArray=function(t,e,n,r,i){var o=this.expression.evaluate(new li(this.zoom),e,{},r,[],i),a=this.expression.evaluate(new li(this.zoom+1),e,{},r,[],i),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,o,a)},Do.prototype.updatePaintArray=function(t,e,n,r){var i=this.expression.evaluate({zoom:this.zoom},n,r),o=this.expression.evaluate({zoom:this.zoom+1},n,r);this._setPaintValue(t,e,i,o)},Do.prototype._setPaintValue=function(t,e,n,r){if("color"===this.type)for(var i=Ao(n),o=Ao(r),a=t;a<e;a++)this.paintVertexArray.emplace(a,i[0],i[1],o[0],o[1]);else{for(var s=t;s<e;s++)this.paintVertexArray.emplace(s,n,r);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(r))}},Do.prototype.upload=function(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))},Do.prototype.destroy=function(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()},Do.prototype.setUniform=function(t,e){var n=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=c(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);t.set(r)},Do.prototype.getBinding=function(t,e,n){return new wo(t,e)};var No=function(t,e,n,r,i,o){this.expression=t,this.type=e,this.useIntegerZoom=n,this.zoom=r,this.layerId=o,this.zoomInPaintVertexArray=new i,this.zoomOutPaintVertexArray=new i};No.prototype.populatePaintArray=function(t,e,n){var r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],n)},No.prototype.updatePaintArray=function(t,e,n,r,i){this._setPaintValues(t,e,n.patterns&&n.patterns[this.layerId],i)},No.prototype._setPaintValues=function(t,e,n,r){if(r&&n){var i=r[n.min],o=r[n.mid],a=r[n.max];if(i&&o&&a)for(var s=t;s<e;s++)this.zoomInPaintVertexArray.emplace(s,o.tl[0],o.tl[1],o.br[0],o.br[1],i.tl[0],i.tl[1],i.br[0],i.br[1],o.pixelRatio,i.pixelRatio),this.zoomOutPaintVertexArray.emplace(s,o.tl[0],o.tl[1],o.br[0],o.br[1],a.tl[0],a.tl[1],a.br[0],a.br[1],o.pixelRatio,a.pixelRatio)}},No.prototype.upload=function(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,co.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,co.members,this.expression.isStateDependent))},No.prototype.destroy=function(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()};var Oo=function(t,e,n){this.binders={},this._buffers=[];var r=[];for(var i in t.paint._values)if(n(i)){var o=t.paint.get(i);if(o instanceof mi&&On(o.property.specification)){var a=zo(i,t.type),s=o.value,l=o.property.specification.type,u=o.property.useIntegerZoom,c=o.property.specification["property-type"],h="cross-faded"===c||"cross-faded-data-driven"===c;if("constant"===s.kind)this.binders[i]=h?new Po(s.value,a):new Lo(s.value,a,l),r.push("/u_"+i);else if("source"===s.kind||h){var p=Fo(i,l,"source");this.binders[i]=h?new No(s,l,u,e,p,t.id):new Ro(s,a,l,p),r.push("/a_"+i)}else{var f=Fo(i,l,"composite");this.binders[i]=new Do(s,a,l,u,e,f),r.push("/z_"+i)}}}this.cacheKey=r.sort().join("")};Oo.prototype.getMaxValue=function(t){var e=this.binders[t];return e instanceof Ro||e instanceof Do?e.maxValue:0},Oo.prototype.populatePaintArrays=function(t,e,n,r,i){for(var o in this.binders){var a=this.binders[o];(a instanceof Ro||a instanceof Do||a instanceof No)&&a.populatePaintArray(t,e,n,r,i)}},Oo.prototype.setConstantPatternPositions=function(t,e){for(var n in this.binders){var r=this.binders[n];r instanceof Po&&r.setConstantPatternPositions(t,e)}},Oo.prototype.updatePaintArrays=function(t,e,n,r,i){var o=!1;for(var a in t)for(var s=0,l=e.getPositions(a);s<l.length;s+=1){var u=l[s],c=n.feature(u.index);for(var h in this.binders){var p=this.binders[h];if((p instanceof Ro||p instanceof Do||p instanceof No)&&!0===p.expression.isStateDependent){var f=r.paint.get(h);p.expression=f.value,p.updatePaintArray(u.start,u.end,c,t[a],i),o=!0}}}return o},Oo.prototype.defines=function(){var t=[];for(var e in this.binders){var n=this.binders[e];(n instanceof Lo||n instanceof Po)&&t.push.apply(t,n.uniformNames.map((function(t){return"#define HAS_UNIFORM_"+t})))}return t},Oo.prototype.getBinderAttributes=function(){var t=[];for(var e in this.binders){var n=this.binders[e];if(n instanceof Ro||n instanceof Do)for(var r=0;r<n.paintVertexAttributes.length;r++)t.push(n.paintVertexAttributes[r].name);else if(n instanceof No)for(var i=0;i<co.members.length;i++)t.push(co.members[i].name)}return t},Oo.prototype.getBinderUniforms=function(){var t=[];for(var e in this.binders){var n=this.binders[e];if(n instanceof Lo||n instanceof Po||n instanceof Do)for(var r=0,i=n.uniformNames;r<i.length;r+=1)t.push(i[r])}return t},Oo.prototype.getPaintVertexBuffers=function(){return this._buffers},Oo.prototype.getUniforms=function(t,e){var n=[];for(var r in this.binders){var i=this.binders[r];if(i instanceof Lo||i instanceof Po||i instanceof Do)for(var o=0,a=i.uniformNames;o<a.length;o+=1){var s=a[o];if(e[s]){var l=i.getBinding(t,e[s],s);n.push({name:s,property:r,binding:l})}}}return n},Oo.prototype.setUniforms=function(t,e,n,r){for(var i=0,o=e;i<o.length;i+=1){var a=o[i],s=a.name,l=a.property;this.binders[l].setUniform(a.binding,r,n.get(l),s)}},Oo.prototype.updatePaintBuffers=function(t){for(var e in this._buffers=[],this.binders){var n=this.binders[e];if(t&&n instanceof No){var r=2===t.fromScale?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;r&&this._buffers.push(r)}else(n instanceof Ro||n instanceof Do)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}},Oo.prototype.upload=function(t){for(var e in this.binders){var n=this.binders[e];(n instanceof Ro||n instanceof Do||n instanceof No)&&n.upload(t)}this.updatePaintBuffers()},Oo.prototype.destroy=function(){for(var t in this.binders){var e=this.binders[t];(e instanceof Ro||e instanceof Do||e instanceof No)&&e.destroy()}};var ko=function(t,e,n){void 0===n&&(n=function(){return!0}),this.programConfigurations={};for(var r=0,i=t;r<i.length;r+=1){var o=i[r];this.programConfigurations[o.id]=new Oo(o,e,n)}this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0};function zo(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(e+"-","").replace(/-/g,"_")]}function Fo(t,e,n){var r={color:{source:Di,composite:Ji},number:{source:qi,composite:Di}},i=function(t){return{"line-pattern":{source:Ni,composite:Ni},"fill-pattern":{source:Ni,composite:Ni},"fill-extrusion-pattern":{source:Ni,composite:Ni}}[t]}(t);return i&&i[n]||r[e][n]}ko.prototype.populatePaintArrays=function(t,e,n,r,i,o){for(var a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(t,e,r,i,o);void 0!==e.id&&this._featureMap.add(e.id,n,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0},ko.prototype.updatePaintArrays=function(t,e,n,r){for(var i=0,o=n;i<o.length;i+=1){var a=o[i];this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(t,this._featureMap,e,a,r)||this.needsUpload}},ko.prototype.get=function(t){return this.programConfigurations[t]},ko.prototype.upload=function(t){if(this.needsUpload){for(var e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}},ko.prototype.destroy=function(){for(var t in this.programConfigurations)this.programConfigurations[t].destroy()},Br("ConstantBinder",Lo),Br("CrossFadedConstantBinder",Po),Br("SourceExpressionBinder",Ro),Br("CrossFadedCompositeBinder",No),Br("CompositeExpressionBinder",Do),Br("ProgramConfiguration",Oo,{omit:["_buffers"]}),Br("ProgramConfigurationSet",ko);var Bo=Math.pow(2,14)-1,Uo=-Bo-1;function Vo(t){for(var e=8192/t.extent,n=t.loadGeometry(),r=0;r<n.length;r++)for(var i=n[r],o=0;o<i.length;o++){var a=i[o],s=Math.round(a.x*e),l=Math.round(a.y*e);a.x=c(s,Uo,Bo),a.y=c(l,Uo,Bo),(s<a.x||s>a.x+1||l<a.y||l>a.y+1)&&E("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return n}function Go(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Vo(t):[]}}function jo(t,e,n,r,i){t.emplaceBack(2*e+(r+1)/2,2*n+(i+1)/2)}var Ho=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ai,this.indexArray=new Gi,this.segments=new lo,this.programConfigurations=new ko(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function qo(t,e){for(var n=0;n<t.length;n++)if(ta(e,t[n]))return!0;for(var r=0;r<e.length;r++)if(ta(t,e[r]))return!0;return!!Yo(t,e)}function Wo(t,e,n){return!!ta(t,e)||!!Ko(e,t,n)}function Xo(t,e){if(1===t.length)return $o(e,t[0]);for(var n=0;n<e.length;n++)for(var r=e[n],i=0;i<r.length;i++)if(ta(t,r[i]))return!0;for(var o=0;o<t.length;o++)if($o(e,t[o]))return!0;for(var a=0;a<e.length;a++)if(Yo(t,e[a]))return!0;return!1}function Zo(t,e,n){if(t.length>1){if(Yo(t,e))return!0;for(var r=0;r<e.length;r++)if(Ko(e[r],t,n))return!0}for(var i=0;i<t.length;i++)if(Ko(t[i],e,n))return!0;return!1}function Yo(t,e){if(0===t.length||0===e.length)return!1;for(var n=0;n<t.length-1;n++)for(var r=t[n],i=t[n+1],o=0;o<e.length-1;o++)if(Jo(r,i,e[o],e[o+1]))return!0;return!1}function Jo(t,e,n,r){return S(t,n,r)!==S(e,n,r)&&S(t,e,n)!==S(t,e,r)}function Ko(t,e,n){var r=n*n;if(1===e.length)return t.distSqr(e[0])<r;for(var i=1;i<e.length;i++)if(Qo(t,e[i-1],e[i])<r)return!0;return!1}function Qo(t,e,n){var r=e.distSqr(n);if(0===r)return t.distSqr(e);var i=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;return t.distSqr(i<0?e:i>1?n:n.sub(e)._mult(i)._add(e))}function $o(t,e){for(var n,r,i,o=!1,a=0;a<t.length;a++)for(var s=0,l=(n=t[a]).length-1;s<n.length;l=s++)(r=n[s]).y>e.y!=(i=n[l]).y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(o=!o);return o}function ta(t,e){for(var n=!1,r=0,i=t.length-1;r<t.length;i=r++){var o=t[r],a=t[i];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function ea(t,e,n){var r=n[0],i=n[2];if(t.x<r.x&&e.x<r.x||t.x>i.x&&e.x>i.x||t.y<r.y&&e.y<r.y||t.y>i.y&&e.y>i.y)return!1;var o=S(t,e,n[0]);return o!==S(t,e,n[1])||o!==S(t,e,n[2])||o!==S(t,e,n[3])}function na(t,e,n){var r=e.paint.get(t).value;return"constant"===r.kind?r.value:n.programConfigurations.get(e.id).getMaxValue(t)}function ra(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ia(t,e,n,r,o){if(!e[0]&&!e[1])return t;var a=i.convert(e)._mult(o);"viewport"===n&&a._rotate(-r);for(var s=[],l=0;l<t.length;l++)s.push(t[l].sub(a));return s}Ho.prototype.populate=function(t,e,n){var r=this.layers[0],i=[],o=null,a=!1;"circle"===r.type&&(a=!(o=r.layout.get("circle-sort-key")).isConstant());for(var s=0,l=t;s<l.length;s+=1){var u=l[s],c=u.feature,h=u.id,p=u.index,f=u.sourceLayerIndex,d=this.layers[0]._featureFilter.needGeometry,m=Go(c,d);if(this.layers[0]._featureFilter.filter(new li(this.zoom),m,n)){var g=a?o.evaluate(m,{},n):void 0,y={id:h,properties:c.properties,type:c.type,sourceLayerIndex:f,index:p,geometry:d?m.geometry:Vo(c),patterns:{},sortKey:g};i.push(y)}}a&&i.sort((function(t,e){return t.sortKey-e.sortKey}));for(var v=0,_=i;v<_.length;v+=1){var x=_[v],b=x.geometry,w=x.index,E=x.sourceLayerIndex,S=t[w].feature;this.addFeature(x,b,w,n),e.featureIndex.insert(S,b,w,E,this.index)}},Ho.prototype.update=function(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n)},Ho.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},Ho.prototype.uploadPending=function(){return!this.uploaded||this.programConfigurations.needsUpload},Ho.prototype.upload=function(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,so),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0},Ho.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())},Ho.prototype.addFeature=function(t,e,n,r){for(var i=0,o=e;i<o.length;i+=1)for(var a=0,s=o[i];a<s.length;a+=1){var l=s[a],u=l.x,c=l.y;if(!(u<0||u>=8192||c<0||c>=8192)){var h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),p=h.vertexLength;jo(this.layoutVertexArray,u,c,-1,-1),jo(this.layoutVertexArray,u,c,1,-1),jo(this.layoutVertexArray,u,c,1,1),jo(this.layoutVertexArray,u,c,-1,1),this.indexArray.emplaceBack(p,p+1,p+2),this.indexArray.emplaceBack(p,p+3,p+2),h.vertexLength+=4,h.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{},r)},Br("CircleBucket",Ho,{omit:["layers"]});var oa=new wi({"circle-sort-key":new vi(Lt.layout_circle["circle-sort-key"])}),aa={paint:new wi({"circle-radius":new vi(Lt.paint_circle["circle-radius"]),"circle-color":new vi(Lt.paint_circle["circle-color"]),"circle-blur":new vi(Lt.paint_circle["circle-blur"]),"circle-opacity":new vi(Lt.paint_circle["circle-opacity"]),"circle-translate":new yi(Lt.paint_circle["circle-translate"]),"circle-translate-anchor":new yi(Lt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new yi(Lt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new yi(Lt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new vi(Lt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new vi(Lt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new vi(Lt.paint_circle["circle-stroke-opacity"])}),layout:oa},sa="undefined"!=typeof Float32Array?Float32Array:Array;function la(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ua(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=n[0],x=n[1],b=n[2],w=n[3];return t[0]=_*r+x*s+b*h+w*m,t[1]=_*i+x*l+b*p+w*g,t[2]=_*o+x*u+b*f+w*y,t[3]=_*a+x*c+b*d+w*v,t[4]=(_=n[4])*r+(x=n[5])*s+(b=n[6])*h+(w=n[7])*m,t[5]=_*i+x*l+b*p+w*g,t[6]=_*o+x*u+b*f+w*y,t[7]=_*a+x*c+b*d+w*v,t[8]=(_=n[8])*r+(x=n[9])*s+(b=n[10])*h+(w=n[11])*m,t[9]=_*i+x*l+b*p+w*g,t[10]=_*o+x*u+b*f+w*y,t[11]=_*a+x*c+b*d+w*v,t[12]=(_=n[12])*r+(x=n[13])*s+(b=n[14])*h+(w=n[15])*m,t[13]=_*i+x*l+b*p+w*g,t[14]=_*o+x*u+b*f+w*y,t[15]=_*a+x*c+b*d+w*v,t}Math.hypot||(Math.hypot=function(){for(var t=arguments,e=0,n=arguments.length;n--;)e+=t[n]*t[n];return Math.sqrt(e)});var ca,ha=ua;function pa(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}ca=new sa(3),sa!=Float32Array&&(ca[0]=0,ca[1]=0,ca[2]=0),function(){var t=new sa(4);sa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var fa=(function(){var t=new sa(2);sa!=Float32Array&&(t[0]=0,t[1]=0)}(),function(t){function e(e){t.call(this,e,aa)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.createBucket=function(t){return new Ho(t)},e.prototype.queryRadius=function(t){var e=t;return na("circle-radius",this,e)+na("circle-stroke-width",this,e)+ra(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,o,a,s){for(var l=ia(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,a),u=this.paint.get("circle-radius").evaluate(e,n)+this.paint.get("circle-stroke-width").evaluate(e,n),c="map"===this.paint.get("circle-pitch-alignment"),h=c?l:function(t,e){return t.map((function(t){return da(t,e)}))}(l,s),p=c?u*a:u,f=0,d=r;f<d.length;f+=1)for(var m=0,g=d[f];m<g.length;m+=1){var y=g[m],v=c?y:da(y,s),_=p,x=pa([],[y.x,y.y,0,1],s);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?_*=x[3]/o.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(_*=o.cameraToCenterDistance/x[3]),Wo(h,v,_))return!0}return!1},e}(Ei));function da(t,e){var n=pa([],[t.x,t.y,0,1],e);return new i(n[0]/n[3],n[1]/n[3])}var ma=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Ho);function ga(t,e,n,r){var i=e.width,o=e.height;if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==i*o*n)throw new RangeError("mismatched image size")}else r=new Uint8Array(i*o*n);return t.width=i,t.height=o,t.data=r,t}function ya(t,e,n){var r=e.width,i=e.height;if(r!==t.width||i!==t.height){var o=ga({},{width:r,height:i},n);va(t,o,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,r),height:Math.min(t.height,i)},n),t.width=r,t.height=i,t.data=o.data}}function va(t,e,n,r,i,o){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=t.data,s=e.data,l=0;l<i.height;l++)for(var u=((n.y+l)*t.width+n.x)*o,c=((r.y+l)*e.width+r.x)*o,h=0;h<i.width*o;h++)s[c+h]=a[u+h];return e}Br("HeatmapBucket",ma,{omit:["layers"]});var _a=function(t,e){ga(this,t,1,e)};_a.prototype.resize=function(t){ya(this,t,1)},_a.prototype.clone=function(){return new _a({width:this.width,height:this.height},new Uint8Array(this.data))},_a.copy=function(t,e,n,r,i){va(t,e,n,r,i,1)};var xa=function(t,e){ga(this,t,4,e)};xa.prototype.resize=function(t){ya(this,t,4)},xa.prototype.replace=function(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t},xa.prototype.clone=function(){return new xa({width:this.width,height:this.height},new Uint8Array(this.data))},xa.copy=function(t,e,n,r,i){va(t,e,n,r,i,4)},Br("AlphaImage",_a),Br("RGBAImage",xa);var ba={paint:new wi({"heatmap-radius":new vi(Lt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new vi(Lt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new yi(Lt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new bi(Lt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new yi(Lt.paint_heatmap["heatmap-opacity"])})};function wa(t){var e={},n=t.resolution||256,r=t.clips?t.clips.length:1,i=t.image||new xa({width:n,height:r}),o=function(n,r,o){e[t.evaluationKey]=o;var a=t.expression.evaluate(e);i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a)};if(t.clips)for(var a=0,s=0;a<r;++a,s+=4*n)for(var l=0,u=0;l<n;l++,u+=4){var c=l/(n-1),h=t.clips[a];o(s,u,h.start*(1-c)+h.end*c)}else for(var p=0,f=0;p<n;p++,f+=4)o(0,f,p/(n-1));return i}var Ea=function(t){function e(e){t.call(this,e,ba),this._updateColorRamp()}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.createBucket=function(t){return new ma(t)},e.prototype._handleSpecialPaintPropertyUpdate=function(t){"heatmap-color"===t&&this._updateColorRamp()},e.prototype._updateColorRamp=function(){this.colorRamp=wa({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null},e.prototype.resize=function(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)},e.prototype.queryRadius=function(){return 0},e.prototype.queryIntersectsFeature=function(){return!1},e.prototype.hasOffscreenPass=function(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility},e}(Ei),Sa={paint:new wi({"hillshade-illumination-direction":new yi(Lt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new yi(Lt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new yi(Lt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new yi(Lt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new yi(Lt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new yi(Lt.paint_hillshade["hillshade-accent-color"])})},Ma=function(t){function e(e){t.call(this,e,Sa)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.hasOffscreenPass=function(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility},e}(Ei),Ta=Ci([{name:"a_pos",components:2,type:"Int16"}],4).members,Ca=Aa,Ia=Aa;function Aa(t,e,n){n=n||2;var r,i,o,a,s,l,u,c=e&&e.length,h=c?e[0]*n:t.length,p=La(t,0,h,n,!0),f=[];if(!p||p.next===p.prev)return f;if(c&&(p=function(t,e,n,r){var i,o,a,s=[];for(i=0,o=e.length;i<o;i++)(a=La(t,e[i]*r,i<o-1?e[i+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),s.push(Va(a));for(s.sort(za),i=0;i<s.length;i++)Fa(s[i],n),n=Pa(n,n.next);return n}(t,e,p,n)),t.length>80*n){r=o=t[0],i=a=t[1];for(var d=n;d<h;d+=n)(s=t[d])<r&&(r=s),(l=t[d+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return Ra(p,f,n,r,i,u),f}function La(t,e,n,r,i){var o,a;if(i===ts(t,e,n,r)>0)for(o=e;o<n;o+=r)a=Ka(o,t[o],t[o+1],a);else for(o=n-r;o>=e;o-=r)a=Ka(o,t[o],t[o+1],a);return a&&qa(a,a.next)&&(Qa(a),a=a.next),a}function Pa(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!qa(r,r.next)&&0!==Ha(r.prev,r,r.next))r=r.next;else{if(Qa(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Ra(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Ua(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e<u&&(s++,r=r.nextZ);e++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Na(t,r,i,o):Da(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qa(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?Ra(t=Oa(Pa(t),e,n),e,n,r,i,o,2):2===a&&ka(t,e,n,r,i,o):Ra(Pa(t),e,n,r,i,o,1);break}}}function Da(t){var e=t.prev,n=t,r=t.next;if(Ha(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Ga(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Ha(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Na(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Ha(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=Ua(i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,e,n,r),c=Ua(s,l,e,n,r),h=t.prevZ,p=t.nextZ;h&&h.z>=u&&p&&p.z<=c;){if(h!==t.prev&&h!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==t.prev&&p!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=u;){if(h!==t.prev&&h!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=c;){if(p!==t.prev&&p!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Oa(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!qa(i,o)&&Wa(i,r,r.next,o)&&Ya(i,o)&&Ya(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qa(r),Qa(r.next),r=t=o),r=r.next}while(r!==t);return Pa(r)}function ka(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&ja(a,s)){var l=Ja(a,s);return a=Pa(a,a.next),l=Pa(l,l.next),Ra(a,e,n,r,i,o),void Ra(l,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function za(t,e){return t.x-e.x}function Fa(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!n)return null;if(i===a)return n;var l,u=n,c=n.x,h=n.y,p=1/0;r=n;do{i>=r.x&&r.x>=c&&i!==r.x&&Ga(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(i-r.x),Ya(r,t)&&(l<p||l===p&&(r.x>n.x||r.x===n.x&&Ba(n,r)))&&(n=r,p=l)),r=r.next}while(r!==u);return n}(t,e)){var n=Ja(e,t);Pa(e,e.next),Pa(n,n.next)}}function Ba(t,e){return Ha(t.prev,t,e.prev)<0&&Ha(e.next,t,t.next)<0}function Ua(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Va(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Ga(t,e,n,r,i,o,a,s){return(i-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function ja(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Wa(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Ya(t,e)&&Ya(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Ha(t.prev,t,e.prev)||Ha(t,e.prev,e))||qa(t,e)&&Ha(t.prev,t,t.next)>0&&Ha(e.prev,e,e.next)>0)}function Ha(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qa(t,e){return t.x===e.x&&t.y===e.y}function Wa(t,e,n,r){var i=Za(Ha(t,e,n)),o=Za(Ha(t,e,r)),a=Za(Ha(n,r,t)),s=Za(Ha(n,r,e));return i!==o&&a!==s||!(0!==i||!Xa(t,n,e))||!(0!==o||!Xa(t,r,e))||!(0!==a||!Xa(n,t,r))||!(0!==s||!Xa(n,e,r))}function Xa(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Za(t){return t>0?1:t<0?-1:0}function Ya(t,e){return Ha(t.prev,t,t.next)<0?Ha(t,e,t.next)>=0&&Ha(t,t.prev,e)>=0:Ha(t,e,t.prev)<0||Ha(t,t.next,e)<0}function Ja(t,e){var n=new $a(t.i,t.x,t.y),r=new $a(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ka(t,e,n,r){var i=new $a(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qa(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function $a(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ts(t,e,n,r){for(var i=0,o=e,a=n-r;o<n;o+=r)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}function es(t,e,n,r,i){!function t(e,n,r,i,o){for(;i>r;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=e[n],p=r,f=i;for(ns(e,r,n),o(e[i],h)>0&&ns(e,r,i);p<f;){for(ns(e,p,f),p++,f--;o(e[p],h)<0;)p++;for(;o(e[f],h)>0;)f--}0===o(e[r],h)?ns(e,r,f):ns(e,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(t,e,n||0,r||t.length-1,i||rs)}function ns(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function rs(t,e){return t<e?-1:t>e?1:0}function is(t,e){var n=t.length;if(n<=1)return[t];for(var r,i,o=[],a=0;a<n;a++){var s=M(t[a]);0!==s&&(t[a].area=Math.abs(s),void 0===i&&(i=s<0),i===s<0?(r&&o.push(r),r=[t[a]]):r.push(t[a]))}if(r&&o.push(r),e>1)for(var l=0;l<o.length;l++)o[l].length<=e||(es(o[l],e,1,o[l].length-1,os),o[l]=o[l].slice(0,e));return o}function os(t,e){return e.area-t.area}function as(t,e,n){for(var r=n.patternDependencies,i=!1,o=0,a=e;o<a.length;o+=1){var s=a[o].paint.get(t+"-pattern");s.isConstant()||(i=!0);var l=s.constantOr(null);l&&(i=!0,r[l.to]=!0,r[l.from]=!0)}return i}function ss(t,e,n,r,i){for(var o=i.patternDependencies,a=0,s=e;a<s.length;a+=1){var l=s[a],u=l.paint.get(t+"-pattern").value;if("constant"!==u.kind){var c=u.evaluate({zoom:r-1},n,{},i.availableImages),h=u.evaluate({zoom:r},n,{},i.availableImages),p=u.evaluate({zoom:r+1},n,{},i.availableImages);h=h&&h.name?h.name:h,p=p&&p.name?p.name:p,o[c=c&&c.name?c.name:c]=!0,o[h]=!0,o[p]=!0,n.patterns[l.id]={min:c,mid:h,max:p}}}return n}Aa.deviation=function(t,e,n,r){var i=e&&e.length,o=Math.abs(ts(t,0,i?e[0]*n:t.length,n));if(i)for(var a=0,s=e.length;a<s;a++)o-=Math.abs(ts(t,e[a]*n,a<s-1?e[a+1]*n:t.length,n));var l=0;for(a=0;a<r.length;a+=3){var u=r[a]*n,c=r[a+1]*n,h=r[a+2]*n;l+=Math.abs((t[u]-t[h])*(t[c+1]-t[u+1])-(t[u]-t[c])*(t[h+1]-t[u+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Aa.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<e;a++)n.vertices.push(t[i][o][a]);i>0&&n.holes.push(r+=t[i-1].length)}return n},Ca.default=Ia;var ls=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ai,this.indexArray=new Gi,this.indexArray2=new Zi,this.programConfigurations=new ko(t.layers,t.zoom),this.segments=new lo,this.segments2=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};ls.prototype.populate=function(t,e,n){this.hasPattern=as("fill",this.layers,e);for(var r=this.layers[0].layout.get("fill-sort-key"),i=!r.isConstant(),o=[],a=0,s=t;a<s.length;a+=1){var l=s[a],u=l.feature,c=l.id,h=l.index,p=l.sourceLayerIndex,f=this.layers[0]._featureFilter.needGeometry,d=Go(u,f);if(this.layers[0]._featureFilter.filter(new li(this.zoom),d,n)){var m=i?r.evaluate(d,{},n,e.availableImages):void 0,g={id:c,properties:u.properties,type:u.type,sourceLayerIndex:p,index:h,geometry:f?d.geometry:Vo(u),patterns:{},sortKey:m};o.push(g)}}i&&o.sort((function(t,e){return t.sortKey-e.sortKey}));for(var y=0,v=o;y<v.length;y+=1){var _=v[y],x=_.geometry,b=_.index,w=_.sourceLayerIndex;if(this.hasPattern){var E=ss("fill",this.layers,_,this.zoom,e);this.patternFeatures.push(E)}else this.addFeature(_,x,b,n,{});e.featureIndex.insert(t[b].feature,x,b,w,this.index)}},ls.prototype.update=function(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n)},ls.prototype.addFeatures=function(t,e,n){for(var r=0,i=this.patternFeatures;r<i.length;r+=1){var o=i[r];this.addFeature(o,o.geometry,o.index,e,n)}},ls.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},ls.prototype.uploadPending=function(){return!this.uploaded||this.programConfigurations.needsUpload},ls.prototype.upload=function(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ta),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0},ls.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())},ls.prototype.addFeature=function(t,e,n,r,i){for(var o=0,a=is(e,500);o<a.length;o+=1){for(var s=a[o],l=0,u=0,c=s;u<c.length;u+=1)l+=c[u].length;for(var h=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray),p=h.vertexLength,f=[],d=[],m=0,g=s;m<g.length;m+=1){var y=g[m];if(0!==y.length){y!==s[0]&&d.push(f.length/2);var v=this.segments2.prepareSegment(y.length,this.layoutVertexArray,this.indexArray2),_=v.vertexLength;this.layoutVertexArray.emplaceBack(y[0].x,y[0].y),this.indexArray2.emplaceBack(_+y.length-1,_),f.push(y[0].x),f.push(y[0].y);for(var x=1;x<y.length;x++)this.layoutVertexArray.emplaceBack(y[x].x,y[x].y),this.indexArray2.emplaceBack(_+x-1,_+x),f.push(y[x].x),f.push(y[x].y);v.vertexLength+=y.length,v.primitiveLength+=y.length}}for(var b=Ca(f,d),w=0;w<b.length;w+=3)this.indexArray.emplaceBack(p+b[w],p+b[w+1],p+b[w+2]);h.vertexLength+=l,h.primitiveLength+=b.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,i,r)},Br("FillBucket",ls,{omit:["layers","patternFeatures"]});var us=new wi({"fill-sort-key":new vi(Lt.layout_fill["fill-sort-key"])}),cs={paint:new wi({"fill-antialias":new yi(Lt.paint_fill["fill-antialias"]),"fill-opacity":new vi(Lt.paint_fill["fill-opacity"]),"fill-color":new vi(Lt.paint_fill["fill-color"]),"fill-outline-color":new vi(Lt.paint_fill["fill-outline-color"]),"fill-translate":new yi(Lt.paint_fill["fill-translate"]),"fill-translate-anchor":new yi(Lt.paint_fill["fill-translate-anchor"]),"fill-pattern":new _i(Lt.paint_fill["fill-pattern"])}),layout:us},hs=function(t){function e(e){t.call(this,e,cs)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.recalculate=function(e,n){t.prototype.recalculate.call(this,e,n);var r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])},e.prototype.createBucket=function(t){return new ls(t)},e.prototype.queryRadius=function(){return ra(this.paint.get("fill-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,o,a){return Xo(ia(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,a),r)},e.prototype.isTileClipped=function(){return!0},e}(Ei),ps=Ci([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4).members,fs=ds;function ds(t,e,n,r,i){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=i,t.readFields(ms,this,e)}function ms(t,e,n){1==t?e.id=n.readVarint():2==t?function(t,e){for(var n=t.readVarint()+t.pos;t.pos<n;){var r=e._keys[t.readVarint()],i=e._values[t.readVarint()];e.properties[r]=i}}(n,e):3==t?e.type=n.readVarint():4==t&&(e._geometry=n.pos)}function gs(t){for(var e,n,r=0,i=0,o=t.length,a=o-1;i<o;a=i++)r+=((n=t[a]).x-(e=t[i]).x)*(e.y+n.y);return r}ds.types=["Unknown","Point","LineString","Polygon"],ds.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,n=t.readVarint()+t.pos,r=1,o=0,a=0,s=0,l=[];t.pos<n;){if(o<=0){var u=t.readVarint();r=7&u,o=u>>3}if(o--,1===r||2===r)a+=t.readSVarint(),s+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new i(a,s));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},ds.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;t.pos<e;){if(r<=0){var c=t.readVarint();n=7&c,r=c>>3}if(r--,1===n||2===n)(i+=t.readSVarint())<a&&(a=i),i>s&&(s=i),(o+=t.readSVarint())<l&&(l=o),o>u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},ds.prototype.toGeoJSON=function(t,e,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*t,s=this.extent*e,l=this.loadGeometry(),u=ds.types[this.type];function c(t){for(var e=0;e<t.length;e++){var n=t[e];t[e]=[360*(n.x+a)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(n.y+s)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(r=0;r<l.length;r++)h[r]=l[r][0];c(l=h);break;case 2:for(r=0;r<l.length;r++)c(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var n,r,i=[],o=0;o<e;o++){var a=gs(t[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(n&&i.push(n),n=[t[o]]):n.push(t[o]))}return n&&i.push(n),i}(l),r=0;r<l.length;r++)for(i=0;i<l[r].length;i++)c(l[r][i])}1===l.length?l=l[0]:u="Multi"+u;var p={type:"Feature",geometry:{type:u,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var ys=vs;function vs(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(_s,this,e),this.length=this._features.length}function _s(t,e,n){15===t?e.version=n.readVarint():1===t?e.name=n.readString():5===t?e.extent=n.readVarint():2===t?e._features.push(n.pos):3===t?e._keys.push(n.readString()):4===t&&e._values.push(function(t){for(var e=null,n=t.readVarint()+t.pos;t.pos<n;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}function xs(t,e,n){if(3===t){var r=new ys(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}vs.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new fs(this._pbf,e,this.extent,this._keys,this._values)};var bs={VectorTile:function(t,e){this.layers=t.readFields(xs,{},e)},VectorTileFeature:fs,VectorTileLayer:ys},ws=bs.VectorTileFeature.types,Es=Math.pow(2,13);function Ss(t,e,n,r,i,o,a,s){t.emplaceBack(e,n,2*Math.floor(r*Es)+a,i*Es*2,o*Es*2,Math.round(s))}var Ms=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Pi,this.indexArray=new Gi,this.programConfigurations=new ko(t.layers,t.zoom),this.segments=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function Ts(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}Ms.prototype.populate=function(t,e,n){this.features=[],this.hasPattern=as("fill-extrusion",this.layers,e);for(var r=0,i=t;r<i.length;r+=1){var o=i[r],a=o.feature,s=o.id,l=o.index,u=o.sourceLayerIndex,c=this.layers[0]._featureFilter.needGeometry,h=Go(a,c);if(this.layers[0]._featureFilter.filter(new li(this.zoom),h,n)){var p={id:s,sourceLayerIndex:u,index:l,geometry:c?h.geometry:Vo(a),properties:a.properties,type:a.type,patterns:{}};this.hasPattern?this.features.push(ss("fill-extrusion",this.layers,p,this.zoom,e)):this.addFeature(p,p.geometry,l,n,{}),e.featureIndex.insert(a,p.geometry,l,u,this.index,!0)}}},Ms.prototype.addFeatures=function(t,e,n){for(var r=0,i=this.features;r<i.length;r+=1){var o=i[r];this.addFeature(o,o.geometry,o.index,e,n)}},Ms.prototype.update=function(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n)},Ms.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},Ms.prototype.uploadPending=function(){return!this.uploaded||this.programConfigurations.needsUpload},Ms.prototype.upload=function(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ps),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0},Ms.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())},Ms.prototype.addFeature=function(t,e,n,r,i){for(var o=0,a=is(e,500);o<a.length;o+=1){for(var s=a[o],l=0,u=0,c=s;u<c.length;u+=1)l+=c[u].length;for(var h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray),p=0,f=s;p<f.length;p+=1){var d=f[p];if(0!==d.length&&!((R=d).every((function(t){return t.x<0}))||R.every((function(t){return t.x>8192}))||R.every((function(t){return t.y<0}))||R.every((function(t){return t.y>8192}))))for(var m=0,g=0;g<d.length;g++){var y=d[g];if(g>=1){var v=d[g-1];if(!Ts(y,v)){h.vertexLength+4>lo.MAX_VERTEX_ARRAY_LENGTH&&(h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var _=y.sub(v)._perp()._unit(),x=v.dist(y);m+x>32768&&(m=0),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,0,m),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,1,m),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,0,m+=x),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,1,m);var b=h.vertexLength;this.indexArray.emplaceBack(b,b+2,b+1),this.indexArray.emplaceBack(b+1,b+2,b+3),h.vertexLength+=4,h.primitiveLength+=2}}}}if(h.vertexLength+l>lo.MAX_VERTEX_ARRAY_LENGTH&&(h=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray)),"Polygon"===ws[t.type]){for(var w=[],E=[],S=h.vertexLength,M=0,T=s;M<T.length;M+=1){var C=T[M];if(0!==C.length){C!==s[0]&&E.push(w.length/2);for(var I=0;I<C.length;I++){var A=C[I];Ss(this.layoutVertexArray,A.x,A.y,0,0,1,1,0),w.push(A.x),w.push(A.y)}}}for(var L=Ca(w,E),P=0;P<L.length;P+=3)this.indexArray.emplaceBack(S+L[P],S+L[P+2],S+L[P+1]);h.primitiveLength+=L.length/3,h.vertexLength+=l}}var R;this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,i,r)},Br("FillExtrusionBucket",Ms,{omit:["layers","features"]});var Cs={paint:new wi({"fill-extrusion-opacity":new yi(Lt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new vi(Lt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new yi(Lt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new yi(Lt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new _i(Lt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new vi(Lt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new vi(Lt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new yi(Lt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})},Is=function(t){function e(e){t.call(this,e,Cs)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.createBucket=function(t){return new Ms(t)},e.prototype.queryRadius=function(){return ra(this.paint.get("fill-extrusion-translate"))},e.prototype.is3D=function(){return!0},e.prototype.queryIntersectsFeature=function(t,e,n,r,o,a,s,l){var u=ia(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,s),c=this.paint.get("fill-extrusion-height").evaluate(e,n),h=this.paint.get("fill-extrusion-base").evaluate(e,n),p=function(t,e,n,r){for(var o=[],a=0,s=t;a<s.length;a+=1){var l=s[a],u=[l.x,l.y,0,1];pa(u,u,e),o.push(new i(u[0]/u[3],u[1]/u[3]))}return o}(u,l),f=function(t,e,n,r){for(var o=[],a=[],s=r[8]*e,l=r[9]*e,u=r[10]*e,c=r[11]*e,h=r[8]*n,p=r[9]*n,f=r[10]*n,d=r[11]*n,m=0,g=t;m<g.length;m+=1){for(var y=[],v=[],_=0,x=g[m];_<x.length;_+=1){var b=x[_],w=b.x,E=b.y,S=r[0]*w+r[4]*E+r[12],M=r[1]*w+r[5]*E+r[13],T=r[2]*w+r[6]*E+r[14],C=r[3]*w+r[7]*E+r[15],I=T+u,A=C+c,L=S+h,P=M+p,R=T+f,D=C+d,N=new i((S+s)/A,(M+l)/A);N.z=I/A,y.push(N);var O=new i(L/D,P/D);O.z=R/D,v.push(O)}o.push(y),a.push(v)}return[o,a]}(r,h,c,l);return function(t,e,n){var r=1/0;Xo(n,e)&&(r=Ls(n,e[0]));for(var i=0;i<e.length;i++)for(var o=e[i],a=t[i],s=0;s<o.length-1;s++){var l=o[s],u=[l,o[s+1],a[s+1],a[s],l];qo(n,u)&&(r=Math.min(r,Ls(n,u)))}return r!==1/0&&r}(f[0],f[1],p)},e}(Ei);function As(t,e){return t.x*e.x+t.y*e.y}function Ls(t,e){if(1===t.length){for(var n,r=0,i=e[r++];!n||i.equals(n);)if(!(n=e[r++]))return 1/0;for(;r<e.length;r++){var o=e[r],a=t[0],s=n.sub(i),l=o.sub(i),u=a.sub(i),c=As(s,s),h=As(s,l),p=As(l,l),f=As(u,s),d=As(u,l),m=c*p-h*h,g=(p*f-h*d)/m,y=(c*d-h*f)/m,v=i.z*(1-g-y)+n.z*g+o.z*y;if(isFinite(v))return v}return 1/0}for(var _=1/0,x=0,b=e;x<b.length;x+=1)_=Math.min(_,b[x].z);return _}var Ps=Ci([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4).members,Rs=Ci([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]).members,Ds=bs.VectorTileFeature.types,Ns=Math.cos(Math.PI/180*37.5),Os=Math.pow(2,14)/.5,ks=function(t){var e=this;this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((function(t){e.gradients[t.id]={}})),this.layoutVertexArray=new Ri,this.layoutVertexArray2=new Di,this.indexArray=new Gi,this.programConfigurations=new ko(t.layers,t.zoom),this.segments=new lo,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};ks.prototype.populate=function(t,e,n){this.hasPattern=as("line",this.layers,e);for(var r=this.layers[0].layout.get("line-sort-key"),i=!r.isConstant(),o=[],a=0,s=t;a<s.length;a+=1){var l=s[a],u=l.feature,c=l.id,h=l.index,p=l.sourceLayerIndex,f=this.layers[0]._featureFilter.needGeometry,d=Go(u,f);if(this.layers[0]._featureFilter.filter(new li(this.zoom),d,n)){var m=i?r.evaluate(d,{},n):void 0,g={id:c,properties:u.properties,type:u.type,sourceLayerIndex:p,index:h,geometry:f?d.geometry:Vo(u),patterns:{},sortKey:m};o.push(g)}}i&&o.sort((function(t,e){return t.sortKey-e.sortKey}));for(var y=0,v=o;y<v.length;y+=1){var _=v[y],x=_.geometry,b=_.index,w=_.sourceLayerIndex;if(this.hasPattern){var E=ss("line",this.layers,_,this.zoom,e);this.patternFeatures.push(E)}else this.addFeature(_,x,b,n,{});e.featureIndex.insert(t[b].feature,x,b,w,this.index)}},ks.prototype.update=function(t,e,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n)},ks.prototype.addFeatures=function(t,e,n){for(var r=0,i=this.patternFeatures;r<i.length;r+=1){var o=i[r];this.addFeature(o,o.geometry,o.index,e,n)}},ks.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length},ks.prototype.uploadPending=function(){return!this.uploaded||this.programConfigurations.needsUpload},ks.prototype.upload=function(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Rs)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ps),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0},ks.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())},ks.prototype.lineFeatureClips=function(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}},ks.prototype.addFeature=function(t,e,n,r,i){var o=this.layers[0].layout,a=o.get("line-join").evaluate(t,{}),s=o.get("line-cap"),l=o.get("line-miter-limit"),u=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(var c=0,h=e;c<h.length;c+=1)this.addLine(h[c],t,a,s,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,i,r)},ks.prototype.addLine=function(t,e,n,r,i,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(var a=0;a<t.length-1;a++)this.totalDistance+=t[a].dist(t[a+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}for(var s="Polygon"===Ds[e.type],l=t.length;l>=2&&t[l-1].equals(t[l-2]);)l--;for(var u=0;u<l-1&&t[u].equals(t[u+1]);)u++;if(!(l<(s?3:2))){"bevel"===n&&(i=1.05);var c,h=this.overscaling<=16?122880/(512*this.overscaling):0,p=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray),f=void 0,d=void 0,m=void 0,g=void 0;this.e1=this.e2=-1,s&&(g=t[u].sub(c=t[l-2])._unit()._perp());for(var y=u;y<l;y++)if(!(d=y===l-1?s?t[u+1]:void 0:t[y+1])||!t[y].equals(d)){g&&(m=g),c&&(f=c),c=t[y],g=d?d.sub(c)._unit()._perp():m;var v=(m=m||g).add(g);0===v.x&&0===v.y||v._unit();var _=m.x*g.x+m.y*g.y,x=v.x*g.x+v.y*g.y,b=0!==x?1/x:1/0,w=2*Math.sqrt(2-2*x),E=x<Ns&&f&&d,S=m.x*g.y-m.y*g.x>0;if(E&&y>u){var M=c.dist(f);if(M>2*h){var T=c.sub(c.sub(f)._mult(h/M)._round());this.updateDistance(f,T),this.addCurrentVertex(T,m,0,0,p),f=T}}var C=f&&d,I=C?n:s?"butt":r;if(C&&"round"===I&&(b<o?I="miter":b<=2&&(I="fakeround")),"miter"===I&&b>i&&(I="bevel"),"bevel"===I&&(b>2&&(I="flipbevel"),b<i&&(I="miter")),f&&this.updateDistance(f,c),"miter"===I)v._mult(b),this.addCurrentVertex(c,v,0,0,p);else if("flipbevel"===I){if(b>100)v=g.mult(-1);else{var A=b*m.add(g).mag()/m.sub(g).mag();v._perp()._mult(A*(S?-1:1))}this.addCurrentVertex(c,v,0,0,p),this.addCurrentVertex(c,v.mult(-1),0,0,p)}else if("bevel"===I||"fakeround"===I){var L=-Math.sqrt(b*b-1),P=S?L:0,R=S?0:L;if(f&&this.addCurrentVertex(c,m,P,R,p),"fakeround"===I)for(var D=Math.round(180*w/Math.PI/20),N=1;N<D;N++){var O=N/D;if(.5!==O){var k=O-.5;O+=O*k*(O-1)*((1.0904+_*(_*(3.55645-1.43519*_)-3.2452))*k*k+(.848013+_*(.215638*_-1.06021)))}var z=g.sub(m)._mult(O)._add(m)._unit()._mult(S?-1:1);this.addHalfVertex(c,z.x,z.y,!1,S,0,p)}d&&this.addCurrentVertex(c,g,-P,-R,p)}else if("butt"===I)this.addCurrentVertex(c,v,0,0,p);else if("square"===I){var F=f?1:-1;this.addCurrentVertex(c,v,F,F,p)}else"round"===I&&(f&&(this.addCurrentVertex(c,m,0,0,p),this.addCurrentVertex(c,m,1,1,p,!0)),d&&(this.addCurrentVertex(c,g,-1,-1,p,!0),this.addCurrentVertex(c,g,0,0,p)));if(E&&y<l-1){var B=c.dist(d);if(B>2*h){var U=c.add(d.sub(c)._mult(h/B)._round());this.updateDistance(c,U),this.addCurrentVertex(U,g,0,0,p),c=U}}}}},ks.prototype.addCurrentVertex=function(t,e,n,r,i,o){void 0===o&&(o=!1);var a=e.y*r-e.x,s=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*n,e.y-e.x*n,o,!1,n,i),this.addHalfVertex(t,a,s,o,!0,-r,i),this.distance>Os/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,n,r,i,o))},ks.prototype.addHalfVertex=function(t,e,n,r,i,o,a){var s=.5*(this.lineClips?this.scaledDistance*(Os-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t.x<<1)+(r?1:0),(t.y<<1)+(i?1:0),Math.round(63*e)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&s)<<2,s>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);var l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),i?this.e2=l:this.e1=l},ks.prototype.updateScaledDistance=function(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance},ks.prototype.updateDistance=function(t,e){this.distance+=t.dist(e),this.updateScaledDistance()},Br("LineBucket",ks,{omit:["layers","patternFeatures"]});var zs=new wi({"line-cap":new yi(Lt.layout_line["line-cap"]),"line-join":new vi(Lt.layout_line["line-join"]),"line-miter-limit":new yi(Lt.layout_line["line-miter-limit"]),"line-round-limit":new yi(Lt.layout_line["line-round-limit"]),"line-sort-key":new vi(Lt.layout_line["line-sort-key"])}),Fs={paint:new wi({"line-opacity":new vi(Lt.paint_line["line-opacity"]),"line-color":new vi(Lt.paint_line["line-color"]),"line-translate":new yi(Lt.paint_line["line-translate"]),"line-translate-anchor":new yi(Lt.paint_line["line-translate-anchor"]),"line-width":new vi(Lt.paint_line["line-width"]),"line-gap-width":new vi(Lt.paint_line["line-gap-width"]),"line-offset":new vi(Lt.paint_line["line-offset"]),"line-blur":new vi(Lt.paint_line["line-blur"]),"line-dasharray":new xi(Lt.paint_line["line-dasharray"]),"line-pattern":new _i(Lt.paint_line["line-pattern"]),"line-gradient":new bi(Lt.paint_line["line-gradient"])}),layout:zs},Bs=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.possiblyEvaluate=function(e,n){return n=new li(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),t.prototype.possiblyEvaluate.call(this,e,n)},e.prototype.evaluate=function(e,n,r,i){return n=p({},n,{zoom:Math.floor(n.zoom)}),t.prototype.evaluate.call(this,e,n,r,i)},e}(vi))(Fs.paint.properties["line-width"].specification);Bs.useIntegerZoom=!0;var Us=function(t){function e(e){t.call(this,e,Fs),this.gradientVersion=0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._handleSpecialPaintPropertyUpdate=function(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof He,this.gradientVersion=(this.gradientVersion+1)%s)},e.prototype.gradientExpression=function(){return this._transitionablePaint._values["line-gradient"].value.expression},e.prototype.recalculate=function(e,n){t.prototype.recalculate.call(this,e,n),this.paint._values["line-floorwidth"]=Bs.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new ks(t)},e.prototype.queryRadius=function(t){var e=t,n=Vs(na("line-width",this,e),na("line-gap-width",this,e)),r=na("line-offset",this,e);return n/2+Math.abs(r)+ra(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,o,a,s){var l=ia(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,s),u=s/2*Vs(this.paint.get("line-width").evaluate(e,n),this.paint.get("line-gap-width").evaluate(e,n)),c=this.paint.get("line-offset").evaluate(e,n);return c&&(r=function(t,e){for(var n=[],r=new i(0,0),o=0;o<t.length;o++){for(var a=t[o],s=[],l=0;l<a.length;l++){var u=a[l],c=a[l+1],h=0===l?r:u.sub(a[l-1])._unit()._perp(),p=l===a.length-1?r:c.sub(u)._unit()._perp(),f=h._add(p)._unit();f._mult(1/(f.x*p.x+f.y*p.y)),s.push(f._mult(e)._add(u))}n.push(s)}return n}(r,c*s)),function(t,e,n){for(var r=0;r<e.length;r++){var i=e[r];if(t.length>=3)for(var o=0;o<i.length;o++)if(ta(t,i[o]))return!0;if(Zo(t,i,n))return!0}return!1}(l,r,u)},e.prototype.isTileClipped=function(){return!0},e}(Ei);function Vs(t,e){return e>0?e+2*t:t}var Gs=Ci([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),js=Ci([{name:"a_projected_pos",components:3,type:"Float32"}],4),Hs=(Ci([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Ci([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}])),qs=(Ci([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]),Ci([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Ws=Ci([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Xs(t,e,n){return t.sections.forEach((function(t){t.text=function(t,e,n){var r=e.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),si.applyArabicShaping&&(t=si.applyArabicShaping(t)),t}(t.text,e,n)})),t}Ci([{name:"triangle",components:3,type:"Uint16"}]),Ci([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Ci([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ci([{type:"Float32",name:"offsetX"}]),Ci([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Zs={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Ys=function(t,e,n,r,i){var o,a,s=8*i-r-1,l=(1<<s)-1,u=l>>1,c=-7,h=n?i-1:0,p=n?-1:1,f=t[e+h];for(h+=p,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+t[e+h],h+=p,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},Js=function(t,e,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,d=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(e*l-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+f]=255&s,f+=d,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[n+f]=255&a,f+=d,a/=256,u-=8);t[n+f-d]|=128*m},Ks=Qs;function Qs(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Qs.Varint=0,Qs.Fixed64=1,Qs.Bytes=2,Qs.Fixed32=5;var $s="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function tl(t){return t.type===Qs.Bytes?t.readVarint()+t.pos:t.pos+1}function el(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function nl(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function rl(t,e){for(var n=0;n<t.length;n++)e.writeVarint(t[n])}function il(t,e){for(var n=0;n<t.length;n++)e.writeSVarint(t[n])}function ol(t,e){for(var n=0;n<t.length;n++)e.writeFloat(t[n])}function al(t,e){for(var n=0;n<t.length;n++)e.writeDouble(t[n])}function sl(t,e){for(var n=0;n<t.length;n++)e.writeBoolean(t[n])}function ll(t,e){for(var n=0;n<t.length;n++)e.writeFixed32(t[n])}function ul(t,e){for(var n=0;n<t.length;n++)e.writeSFixed32(t[n])}function cl(t,e){for(var n=0;n<t.length;n++)e.writeFixed64(t[n])}function hl(t,e){for(var n=0;n<t.length;n++)e.writeSFixed64(t[n])}function pl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function fl(t,e,n){t[n]=e,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function dl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function ml(t,e,n){1===t&&n.readMessage(gl,e)}function gl(t,e,n){if(3===t){var r=n.readMessage(yl,{}),i=r.width,o=r.height,a=r.left,s=r.top,l=r.advance;e.push({id:r.id,bitmap:new _a({width:i+6,height:o+6},r.bitmap),metrics:{width:i,height:o,left:a,top:s,advance:l}})}}function yl(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}function vl(t){for(var e=0,n=0,r=0,i=t;r<i.length;r+=1){var o=i[r];e+=o.w*o.h,n=Math.max(n,o.w)}t.sort((function(t,e){return e.h-t.h}));for(var a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),n),h:1/0}],s=0,l=0,u=0,c=t;u<c.length;u+=1)for(var h=c[u],p=a.length-1;p>=0;p--){var f=a[p];if(!(h.w>f.w||h.h>f.h)){if(h.x=f.x,h.y=f.y,l=Math.max(l,h.y+h.h),s=Math.max(s,h.x+h.w),h.w===f.w&&h.h===f.h){var d=a.pop();p<a.length&&(a[p]=d)}else h.h===f.h?(f.x+=h.w,f.w-=h.w):h.w===f.w?(f.y+=h.h,f.h-=h.h):(a.push({x:f.x+h.w,y:f.y,w:f.w-h.w,h:h.h}),f.y+=h.h,f.h-=h.h);break}}return{w:s,h:l,fill:e/(s*l)||0}}Qs.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=7&r,t(i,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=pl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=dl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=pl(this.buf,this.pos)+4294967296*pl(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=pl(this.buf,this.pos)+4294967296*dl(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=Ys(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Ys(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return el(t,r,e);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return el(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&$s?function(t,e,n){return $s.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){for(var r="",i=e;i<n;){var o,a,s,l=t[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(o=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],s=t[i+3],128==(192&(o=t[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Qs.Bytes)return t.push(this.readVarint(e));var n=tl(this);for(t=t||[];this.pos<n;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Qs.Bytes)return t.push(this.readSVarint());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Qs.Bytes)return t.push(this.readBoolean());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Qs.Bytes)return t.push(this.readFloat());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Qs.Bytes)return t.push(this.readDouble());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Qs.Bytes)return t.push(this.readFixed32());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Qs.Bytes)return t.push(this.readSFixed32());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Qs.Bytes)return t.push(this.readFixed64());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Qs.Bytes)return t.push(this.readSFixed64());var e=tl(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Qs.Varint)for(;this.buf[this.pos++]>127;);else if(e===Qs.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Qs.Fixed32)this.pos+=4;else{if(e!==Qs.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),fl(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),fl(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),fl(this.buf,-1&t,this.pos),fl(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),fl(this.buf,-1&t,this.pos),fl(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,n.buf[n.pos]=127&(t>>>=7)}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){r>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&nl(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),Js(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Js(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n<e;n++)this.buf[this.pos++]=t[n]},writeRawMessage:function(t,e){this.pos++;var n=this.pos;t(e,this);var r=this.pos-n;r>=128&&nl(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,Qs.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,rl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,il,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,sl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ol,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,al,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ll,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ul,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,cl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,hl,e)},writeBytesField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var _l=function(t,e){var n=e.pixelRatio,r=e.version,i=e.stretchX,o=e.stretchY,a=e.content;this.paddedRect=t,this.pixelRatio=n,this.stretchX=i,this.stretchY=o,this.content=a,this.version=r},xl={tl:{configurable:!0},br:{configurable:!0},tlbr:{configurable:!0},displaySize:{configurable:!0}};xl.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},xl.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},xl.tlbr.get=function(){return this.tl.concat(this.br)},xl.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(_l.prototype,xl);var bl=function(t,e){var n={},r={};this.haveRenderCallbacks=[];var i=[];this.addImages(t,n,i),this.addImages(e,r,i);var o=vl(i),a=new xa({width:o.w||1,height:o.h||1});for(var s in t){var l=t[s],u=n[s].paddedRect;xa.copy(l.data,a,{x:0,y:0},{x:u.x+1,y:u.y+1},l.data)}for(var c in e){var h=e[c],p=r[c].paddedRect,f=p.x+1,d=p.y+1,m=h.data.width,g=h.data.height;xa.copy(h.data,a,{x:0,y:0},{x:f,y:d},h.data),xa.copy(h.data,a,{x:0,y:g-1},{x:f,y:d-1},{width:m,height:1}),xa.copy(h.data,a,{x:0,y:0},{x:f,y:d+g},{width:m,height:1}),xa.copy(h.data,a,{x:m-1,y:0},{x:f-1,y:d},{width:1,height:g}),xa.copy(h.data,a,{x:0,y:0},{x:f+m,y:d},{width:1,height:g})}this.image=a,this.iconPositions=n,this.patternPositions=r};bl.prototype.addImages=function(t,e,n){for(var r in t){var i=t[r],o={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(o),e[r]=new _l(o,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}},bl.prototype.patchUpdatedImages=function(t,e){for(var n in t.dispatchRenderCallbacks(this.haveRenderCallbacks),t.updatedImages)this.patchUpdatedImage(this.iconPositions[n],t.getImage(n),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n),e)},bl.prototype.patchUpdatedImage=function(t,e,n){if(t&&e&&t.version!==e.version){t.version=e.version;var r=t.tl;n.update(e.data,void 0,{x:r[0],y:r[1]})}},Br("ImagePosition",_l),Br("ImageAtlas",bl);var wl={horizontal:1,vertical:2,horizontalOnly:3},El=function(){this.scale=1,this.fontStack="",this.imageName=null};El.forText=function(t,e){var n=new El;return n.scale=t||1,n.fontStack=e,n},El.forImage=function(t){var e=new El;return e.imageName=t,e};var Sl=function(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null};function Ml(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){var g,y=Sl.fromFeature(t,i);h===wl.vertical&&y.verticalizePunctuation();var v=si.processBidirectionalText,_=si.processStyledBidirectionalText;if(v&&1===y.sections.length){g=[];for(var x=0,b=v(y.toString(),Rl(y,u,o,e,r,f,d));x<b.length;x+=1){var w=b[x],E=new Sl;E.text=w,E.sections=y.sections;for(var S=0;S<w.length;S++)E.sectionIndex.push(0);g.push(E)}}else if(_){g=[];for(var M=0,T=_(y.text,y.sectionIndex,Rl(y,u,o,e,r,f,d));M<T.length;M+=1){var C=T[M],I=new Sl;I.text=C[0],I.sectionIndex=C[1],I.sections=y.sections,g.push(I)}}else g=function(t,e){for(var n=[],r=t.text,i=0,o=0,a=e;o<a.length;o+=1){var s=a[o];n.push(t.substring(i,s)),i=s}return i<r.length&&n.push(t.substring(i,r.length)),n}(y,Rl(y,u,o,e,r,f,d));var A=[],L={positionedLines:A,text:y.toString(),top:c[1],bottom:c[1],left:c[0],right:c[0],writingMode:h,iconsInText:!1,verticalizable:!1};return function(t,e,n,r,i,o,a,s,l,u,c,h){for(var p=0,f=-17,d=0,m=0,g="right"===s?1:"left"===s?0:.5,y=0,v=0,_=i;v<_.length;v+=1){var x=_[v];x.trim();var b=x.getMaxScale(),w=24*(b-1),E={positionedGlyphs:[],lineOffset:0};t.positionedLines[y]=E;var S=E.positionedGlyphs,M=0;if(x.length()){for(var T=0;T<x.length();T++){var C=x.getSection(T),I=x.getSectionIndex(T),A=x.getCharCode(T),L=0,P=null,R=null,D=null,N=24,O=!(l===wl.horizontal||!c&&!Zr(A)||c&&(Tl[A]||(H=A,Wr.Arabic(H)||Wr["Arabic Supplement"](H)||Wr["Arabic Extended-A"](H)||Wr["Arabic Presentation Forms-A"](H)||Wr["Arabic Presentation Forms-B"](H))));if(C.imageName){var k=r[C.imageName];if(!k)continue;D=C.imageName,t.iconsInText=t.iconsInText||!0,R=k.paddedRect;var z=k.displaySize;C.scale=24*C.scale/h,L=w+(24-z[1]*C.scale),N=(P={width:z[0],height:z[1],left:1,top:-3,advance:O?z[1]:z[0]}).advance;var F=O?z[0]*C.scale-24*b:z[1]*C.scale-24*b;F>0&&F>M&&(M=F)}else{var B=n[C.fontStack],U=B&&B[A];if(U&&U.rect)R=U.rect,P=U.metrics;else{var V=e[C.fontStack],G=V&&V[A];if(!G)continue;P=G.metrics}L=24*(b-C.scale)}O?(t.verticalizable=!0,S.push({glyph:A,imageName:D,x:p,y:f+L,vertical:O,scale:C.scale,fontStack:C.fontStack,sectionIndex:I,metrics:P,rect:R}),p+=N*C.scale+u):(S.push({glyph:A,imageName:D,x:p,y:f+L,vertical:O,scale:C.scale,fontStack:C.fontStack,sectionIndex:I,metrics:P,rect:R}),p+=P.advance*C.scale+u)}0!==S.length&&(d=Math.max(p-u,d),Nl(S,0,S.length-1,g,M)),p=0;var j=o*b+M;E.lineOffset=Math.max(M,w),f+=j,m=Math.max(j,m),++y}else f+=o,++y}var H,q=f- -17,W=Dl(a),X=W.horizontalAlign,Z=W.verticalAlign;(function(t,e,n,r,i,o,a,s,l){var u,c=(e-n)*i;u=o!==a?-s*r- -17:(-r*l+.5)*a;for(var h=0,p=t;h<p.length;h+=1)for(var f=0,d=p[h].positionedGlyphs;f<d.length;f+=1){var m=d[f];m.x+=c,m.y+=u}})(t.positionedLines,g,X,Z,d,m,o,q,i.length),t.top+=-Z*q,t.bottom=t.top+q,t.left+=-X*d,t.right=t.left+d}(L,e,n,r,g,a,s,l,h,u,p,m),!function(t){for(var e=0,n=t;e<n.length;e+=1)if(0!==n[e].positionedGlyphs.length)return!1;return!0}(A)&&L}Sl.fromFeature=function(t,e){for(var n=new Sl,r=0;r<t.sections.length;r++){var i=t.sections[r];i.image?n.addImageSection(i):n.addTextSection(i,e)}return n},Sl.prototype.length=function(){return this.text.length},Sl.prototype.getSection=function(t){return this.sections[this.sectionIndex[t]]},Sl.prototype.getSectionIndex=function(t){return this.sectionIndex[t]},Sl.prototype.getCharCode=function(t){return this.text.charCodeAt(t)},Sl.prototype.verticalizePunctuation=function(){this.text=function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n+1)||null,i=t.charCodeAt(n-1)||null;e+=r&&Yr(r)&&!Zs[t[n+1]]||i&&Yr(i)&&!Zs[t[n-1]]||!Zs[t[n]]?t[n]:Zs[t[n]]}return e}(this.text)},Sl.prototype.trim=function(){for(var t=0,e=0;e<this.text.length&&Tl[this.text.charCodeAt(e)];e++)t++;for(var n=this.text.length,r=this.text.length-1;r>=0&&r>=t&&Tl[this.text.charCodeAt(r)];r--)n--;this.text=this.text.substring(t,n),this.sectionIndex=this.sectionIndex.slice(t,n)},Sl.prototype.substring=function(t,e){var n=new Sl;return n.text=this.text.substring(t,e),n.sectionIndex=this.sectionIndex.slice(t,e),n.sections=this.sections,n},Sl.prototype.toString=function(){return this.text},Sl.prototype.getMaxScale=function(){var t=this;return this.sectionIndex.reduce((function(e,n){return Math.max(e,t.sections[n].scale)}),0)},Sl.prototype.addTextSection=function(t,e){this.text+=t.text,this.sections.push(El.forText(t.scale,t.fontStack||e));for(var n=this.sections.length-1,r=0;r<t.text.length;++r)this.sectionIndex.push(n)},Sl.prototype.addImageSection=function(t){var e=t.image?t.image.name:"";if(0!==e.length){var n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(El.forImage(e)),this.sectionIndex.push(this.sections.length-1)):E("Reached maximum number of images 6401")}else E("Can't add FormattedSection with an empty image.")},Sl.prototype.getNextImageSectionCharCode=function(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)};var Tl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Cl={};function Il(t,e,n,r,i,o){if(e.imageName){var a=r[e.imageName];return a?a.displaySize[0]*e.scale*24/o+i:0}var s=n[e.fontStack],l=s&&s[t];return l?l.metrics.advance*e.scale+i:0}function Al(t,e,n,r){var i=Math.pow(t-e,2);return r?t<e?i/2:2*i:i+Math.abs(n)*n}function Ll(t,e,n){var r=0;return 10===t&&(r-=1e4),n&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function Pl(t,e,n,r,i,o){for(var a=null,s=Al(e,n,i,o),l=0,u=r;l<u.length;l+=1){var c=u[l],h=Al(e-c.x,n,i,o)+c.badness;h<=s&&(a=c,s=h)}return{index:t,x:e,priorBreak:a,badness:s}}function Rl(t,e,n,r,i,o,a){if("point"!==o)return[];if(!t)return[];for(var s,l=[],u=function(t,e,n,r,i,o){for(var a=0,s=0;s<t.length();s++){var l=t.getSection(s);a+=Il(t.getCharCode(s),l,r,i,e,o)}return a/Math.max(1,Math.ceil(a/n))}(t,e,n,r,i,a),c=t.text.indexOf("")>=0,h=0,p=0;p<t.length();p++){var f=t.getSection(p),d=t.getCharCode(p);if(Tl[d]||(h+=Il(d,f,r,i,e,a)),p<t.length()-1){var m=!((s=d)<11904||!(Wr["Bopomofo Extended"](s)||Wr.Bopomofo(s)||Wr["CJK Compatibility Forms"](s)||Wr["CJK Compatibility Ideographs"](s)||Wr["CJK Compatibility"](s)||Wr["CJK Radicals Supplement"](s)||Wr["CJK Strokes"](s)||Wr["CJK Symbols and Punctuation"](s)||Wr["CJK Unified Ideographs Extension A"](s)||Wr["CJK Unified Ideographs"](s)||Wr["Enclosed CJK Letters and Months"](s)||Wr["Halfwidth and Fullwidth Forms"](s)||Wr.Hiragana(s)||Wr["Ideographic Description Characters"](s)||Wr["Kangxi Radicals"](s)||Wr["Katakana Phonetic Extensions"](s)||Wr.Katakana(s)||Wr["Vertical Forms"](s)||Wr["Yi Radicals"](s)||Wr["Yi Syllables"](s)));(Cl[d]||m||f.imageName)&&l.push(Pl(p+1,h,u,l,Ll(d,t.getCharCode(p+1),m&&c),!1))}}return function t(e){return e?t(e.priorBreak).concat(e.index):[]}(Pl(t.length(),h,u,l,0,!0))}function Dl(t){var e=.5,n=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":n=1;break;case"top":case"top-right":case"top-left":n=0}return{horizontalAlign:e,verticalAlign:n}}function Nl(t,e,n,r,i){if(r||i)for(var o=t[n],a=(t[n].x+o.metrics.advance*o.scale)*r,s=e;s<=n;s++)t[s].x-=a,t[s].y+=i}function Ol(t,e,n,r,i,o){var a,s=t.image;if(s.content){var l=s.content,u=s.pixelRatio||1;a=[l[0]/u,l[1]/u,s.displaySize[0]-l[2]/u,s.displaySize[1]-l[3]/u]}var c,h,p,f,d=e.left*o,m=e.right*o;"width"===n||"both"===n?(f=i[0]+d-r[3],h=i[0]+m+r[1]):h=(f=i[0]+(d+m-s.displaySize[0])/2)+s.displaySize[0];var g=e.top*o,y=e.bottom*o;return"height"===n||"both"===n?(c=i[1]+g-r[0],p=i[1]+y+r[2]):p=(c=i[1]+(g+y-s.displaySize[1])/2)+s.displaySize[1],{image:s,top:c,right:h,bottom:p,left:f,collisionPadding:a}}Cl[10]=!0,Cl[32]=!0,Cl[38]=!0,Cl[40]=!0,Cl[41]=!0,Cl[43]=!0,Cl[45]=!0,Cl[47]=!0,Cl[173]=!0,Cl[183]=!0,Cl[8203]=!0,Cl[8208]=!0,Cl[8211]=!0,Cl[8231]=!0;var kl=function(t){function e(e,n,r,i){t.call(this,e,n),this.angle=r,void 0!==i&&(this.segment=i)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.clone=function(){return new e(this.x,this.y,this.angle,this.segment)},e}(i);function zl(t,e){var n=e.expression;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new li(t+1))};if("source"===n.kind)return{kind:"source"};for(var r=n.zoomStops,i=n.interpolationType,o=0;o<r.length&&r[o]<=t;)o++;for(var a=o=Math.max(0,o-1);a<r.length&&r[a]<t+1;)a++;a=Math.min(r.length-1,a);var s=r[o],l=r[a];return"composite"===n.kind?{kind:"composite",minZoom:s,maxZoom:l,interpolationType:i}:{kind:"camera",minZoom:s,maxZoom:l,minSize:n.evaluate(new li(s)),maxSize:n.evaluate(new li(l)),interpolationType:i}}function Fl(t,e,n){var r=e.uSize,i=n.lowerSize;return"source"===t.kind?i/128:"composite"===t.kind?qe(i/128,n.upperSize/128,e.uSizeT):r}function Bl(t,e){var n=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){var i=t.interpolationType,o=i?c(sn.interpolationFactor(i,e,t.minZoom,t.maxZoom),0,1):0;"camera"===t.kind?r=qe(t.minSize,t.maxSize,o):n=o}return{uSizeT:n,uSize:r}}Br("Anchor",kl);var Ul=Object.freeze({__proto__:null,getSizeData:zl,evaluateSizeForFeature:Fl,evaluateSizeForZoom:Bl,SIZE_PACK_FACTOR:128});function Vl(t,e,n,r,i){if(void 0===e.segment)return!0;for(var o=e,a=e.segment+1,s=0;s>-n/2;){if(--a<0)return!1;s-=t[a].dist(o),o=t[a]}s+=t[a].dist(t[a+1]),a++;for(var l=[],u=0;s<n/2;){var c=t[a],h=t[a+1];if(!h)return!1;var p=t[a-1].angleTo(c)-c.angleTo(h);for(p=Math.abs((p+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:s,angleDelta:p}),u+=p;s-l[0].distance>r;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=c.dist(h)}return!0}function Gl(t){for(var e=0,n=0;n<t.length-1;n++)e+=t[n].dist(t[n+1]);return e}function jl(t,e,n){return t?.6*e*n:0}function Hl(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function ql(t,e,n,r,i,o){for(var a=jl(n,i,o),s=Hl(n,r)*o,l=0,u=Gl(t)/2,c=0;c<t.length-1;c++){var h=t[c],p=t[c+1],f=h.dist(p);if(l+f>u){var d=(u-l)/f,m=qe(h.x,p.x,d),g=qe(h.y,p.y,d),y=new kl(m,g,p.angleTo(h),c);return y._round(),!a||Vl(t,y,s,a,e)?y:void 0}l+=f}}function Wl(t,e,n,r,i,o,a,s,l){var u=jl(r,o,a),c=Hl(r,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),function t(e,n,r,i,o,a,s,l,u){for(var c=a/2,h=Gl(e),p=0,f=n-r,d=[],m=0;m<e.length-1;m++){for(var g=e[m],y=e[m+1],v=g.dist(y),_=y.angleTo(g);f+r<p+v;){var x=((f+=r)-p)/v,b=qe(g.x,y.x,x),w=qe(g.y,y.y,x);if(b>=0&&b<u&&w>=0&&w<u&&f-c>=0&&f+c<=h){var E=new kl(b,w,_,m);E._round(),i&&!Vl(e,E,a,i,o)||d.push(E)}}p+=v}return l||d.length||s||(d=t(e,p/2,r,i,o,a,s,!0,u)),d}(t,p?e/2*s%e:(c/2+2*o)*a*s%e,e,u,n,h,p,!1,l)}function Xl(t,e,n,r,o){for(var a=[],s=0;s<t.length;s++)for(var l=t[s],u=void 0,c=0;c<l.length-1;c++){var h=l[c],p=l[c+1];h.x<e&&p.x<e||(h.x<e?h=new i(e,h.y+(e-h.x)/(p.x-h.x)*(p.y-h.y))._round():p.x<e&&(p=new i(e,h.y+(e-h.x)/(p.x-h.x)*(p.y-h.y))._round()),h.y<n&&p.y<n||(h.y<n?h=new i(h.x+(n-h.y)/(p.y-h.y)*(p.x-h.x),n)._round():p.y<n&&(p=new i(h.x+(n-h.y)/(p.y-h.y)*(p.x-h.x),n)._round()),h.x>=r&&p.x>=r||(h.x>=r?h=new i(r,h.y+(r-h.x)/(p.x-h.x)*(p.y-h.y))._round():p.x>=r&&(p=new i(r,h.y+(r-h.x)/(p.x-h.x)*(p.y-h.y))._round()),h.y>=o&&p.y>=o||(h.y>=o?h=new i(h.x+(o-h.y)/(p.y-h.y)*(p.x-h.x),o)._round():p.y>=o&&(p=new i(h.x+(o-h.y)/(p.y-h.y)*(p.x-h.x),o)._round()),u&&h.equals(u[u.length-1])||a.push(u=[h]),u.push(p)))))}return a}function Zl(t,e,n,r){var o=[],a=t.image,s=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=t.right-t.left,h=t.bottom-t.top,p=a.stretchX||[[0,l]],f=a.stretchY||[[0,u]],d=function(t,e){return t+e[1]-e[0]},m=p.reduce(d,0),g=f.reduce(d,0),y=l-m,v=u-g,_=0,x=m,b=0,w=g,E=0,S=y,M=0,T=v;if(a.content&&r){var C=a.content;_=Yl(p,0,C[0]),b=Yl(f,0,C[1]),x=Yl(p,C[0],C[2]),w=Yl(f,C[1],C[3]),E=C[0]-_,M=C[1]-b,S=C[2]-C[0]-x,T=C[3]-C[1]-w}var I=function(r,o,l,u){var p=Kl(r.stretch-_,x,c,t.left),f=Ql(r.fixed-E,S,r.stretch,m),d=Kl(o.stretch-b,w,h,t.top),y=Ql(o.fixed-M,T,o.stretch,g),v=Kl(l.stretch-_,x,c,t.left),C=Ql(l.fixed-E,S,l.stretch,m),I=Kl(u.stretch-b,w,h,t.top),A=Ql(u.fixed-M,T,u.stretch,g),L=new i(p,d),P=new i(v,d),R=new i(v,I),D=new i(p,I),N=new i(f/s,y/s),O=new i(C/s,A/s),k=e*Math.PI/180;if(k){var z=Math.sin(k),F=Math.cos(k),B=[F,-z,z,F];L._matMult(B),P._matMult(B),D._matMult(B),R._matMult(B)}var U=r.stretch+r.fixed,V=o.stretch+o.fixed;return{tl:L,tr:P,bl:D,br:R,tex:{x:a.paddedRect.x+1+U,y:a.paddedRect.y+1+V,w:l.stretch+l.fixed-U,h:u.stretch+u.fixed-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:S/s/c,minFontScaleY:T/s/h,isSDF:n}};if(r&&(a.stretchX||a.stretchY))for(var A=Jl(p,y,m),L=Jl(f,v,g),P=0;P<A.length-1;P++)for(var R=A[P],D=A[P+1],N=0;N<L.length-1;N++)o.push(I(R,L[N],D,L[N+1]));else o.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return o}function Yl(t,e,n){for(var r=0,i=0,o=t;i<o.length;i+=1){var a=o[i];r+=Math.max(e,Math.min(n,a[1]))-Math.max(e,Math.min(n,a[0]))}return r}function Jl(t,e,n){for(var r=[{fixed:-1,stretch:0}],i=0,o=t;i<o.length;i+=1){var a=o[i],s=a[0],l=a[1],u=r[r.length-1];r.push({fixed:s-u.stretch,stretch:u.stretch}),r.push({fixed:s-u.stretch,stretch:u.stretch+(l-s)})}return r.push({fixed:e+1,stretch:n}),r}function Kl(t,e,n,r){return t/e*n+r}function Ql(t,e,n,r){return t-e*n/r}var $l=function(t,e,n,r,o,a,s,l,u,c){if(this.boxStartIndex=t.length,u){var h=a.top,p=a.bottom,f=a.collisionPadding;f&&(h-=f[1],p+=f[3]);var d=p-h;d>0&&(d=Math.max(10,d),this.circleDiameter=d)}else{var m=a.top*s-l,g=a.bottom*s+l,y=a.left*s-l,v=a.right*s+l,_=a.collisionPadding;if(_&&(y-=_[0]*s,m-=_[1]*s,v+=_[2]*s,g+=_[3]*s),c){var x=new i(y,m),b=new i(v,m),w=new i(y,g),E=new i(v,g),S=c*Math.PI/180;x._rotate(S),b._rotate(S),w._rotate(S),E._rotate(S),y=Math.min(x.x,b.x,w.x,E.x),v=Math.max(x.x,b.x,w.x,E.x),m=Math.min(x.y,b.y,w.y,E.y),g=Math.max(x.y,b.y,w.y,E.y)}t.emplaceBack(e.x,e.y,y,m,v,g,n,r,o)}this.boxEndIndex=t.length},tu=function(t,e){if(void 0===t&&(t=[]),void 0===e&&(e=eu),this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)};function eu(t,e){return t<e?-1:t>e?1:0}function nu(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=1/0,o=1/0,a=-1/0,s=-1/0,l=t[0],u=0;u<l.length;u++){var c=l[u];(!u||c.x<r)&&(r=c.x),(!u||c.y<o)&&(o=c.y),(!u||c.x>a)&&(a=c.x),(!u||c.y>s)&&(s=c.y)}var h=Math.min(a-r,s-o),p=h/2,f=new tu([],ru);if(0===h)return new i(r,o);for(var d=r;d<a;d+=h)for(var m=o;m<s;m+=h)f.push(new iu(d+p,m+p,p,t));for(var g=function(t){for(var e=0,n=0,r=0,i=t[0],o=0,a=i.length,s=a-1;o<a;s=o++){var l=i[o],u=i[s],c=l.x*u.y-u.x*l.y;n+=(l.x+u.x)*c,r+=(l.y+u.y)*c,e+=3*c}return new iu(n/e,r/e,0,t)}(t),y=f.length;f.length;){var v=f.pop();(v.d>g.d||!g.d)&&(g=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,y)),v.max-g.d<=e||(f.push(new iu(v.p.x-(p=v.h/2),v.p.y-p,p,t)),f.push(new iu(v.p.x+p,v.p.y-p,p,t)),f.push(new iu(v.p.x-p,v.p.y+p,p,t)),f.push(new iu(v.p.x+p,v.p.y+p,p,t)),y+=4)}return n&&(console.log("num probes: "+y),console.log("best distance: "+g.d)),g.p}function ru(t,e){return e.max-t.max}function iu(t,e,n,r){this.p=new i(t,e),this.h=n,this.d=function(t,e){for(var n=!1,r=1/0,i=0;i<e.length;i++)for(var o=e[i],a=0,s=o.length,l=s-1;a<s;l=a++){var u=o[a],c=o[l];u.y>t.y!=c.y>t.y&&t.x<(c.x-u.x)*(t.y-u.y)/(c.y-u.y)+u.x&&(n=!n),r=Math.min(r,Qo(t,u,c))}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}tu.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},tu.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},tu.prototype.peek=function(){return this.data[0]},tu.prototype._up=function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},tu.prototype._down=function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t<r;){var o=1+(t<<1),a=e[o],s=o+1;if(s<this.length&&n(e[s],a)<0&&(o=s,a=e[s]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i};var ou=Number.POSITIVE_INFINITY;function au(t,e){return e[1]!==ou?function(t,e,n){var r=0,i=0;switch(e=Math.abs(e),n=Math.abs(n),t){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,i]}(t,e[0],e[1]):function(t,e){var n=0,r=0;e<0&&(e=0);var i=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=e;break;case"right":n=-e}return[n,r]}(t,e[0])}function su(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lu(t,e,n,r,o,a,s,l,u,c,h,p,f,d,m){var g=function(t,e,n,r,o,a,s,l){for(var u=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=[],h=0,p=e.positionedLines;h<p.length;h+=1)for(var f=p[h],d=0,m=f.positionedGlyphs;d<m.length;d+=1){var g=m[d];if(g.rect){var y=g.rect||{},v=4,_=!0,x=1,b=0,w=(o||l)&&g.vertical,E=g.metrics.advance*g.scale/2;if(l&&e.verticalizable&&(b=f.lineOffset/2-(g.imageName?-(24-g.metrics.width*g.scale)/2:24*(g.scale-1))),g.imageName){var S=s[g.imageName];_=S.sdf,v=1/(x=S.pixelRatio)}var M=o?[g.x+E,g.y]:[0,0],T=o?[0,0]:[g.x+E+n[0],g.y+n[1]-b],C=[0,0];w&&(C=T,T=[0,0]);var I=(g.metrics.left-v)*g.scale-E+T[0],A=(-g.metrics.top-v)*g.scale+T[1],L=I+y.w*g.scale/x,P=A+y.h*g.scale/x,R=new i(I,A),D=new i(L,A),N=new i(I,P),O=new i(L,P);if(w){var k=new i(-E,E- -17),z=-Math.PI/2,F=12-E,B=new i(22-F,-(g.imageName?F:0)),U=new(Function.prototype.bind.apply(i,[null].concat(C)));R._rotateAround(z,k)._add(B)._add(U),D._rotateAround(z,k)._add(B)._add(U),N._rotateAround(z,k)._add(B)._add(U),O._rotateAround(z,k)._add(B)._add(U)}if(u){var V=Math.sin(u),G=Math.cos(u),j=[G,-V,V,G];R._matMult(j),D._matMult(j),N._matMult(j),O._matMult(j)}var H=new i(0,0),q=new i(0,0);c.push({tl:R,tr:D,bl:N,br:O,tex:y,writingMode:e.writingMode,glyphOffset:M,sectionIndex:g.sectionIndex,isSDF:_,pixelOffsetTL:H,pixelOffsetBR:q,minFontScaleX:0,minFontScaleY:0})}}return c}(0,n,l,o,a,s,r,t.allowVerticalPlacement),y=t.textSizeData,v=null;"source"===y.kind?(v=[128*o.layout.get("text-size").evaluate(s,{})])[0]>32640&&E(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'):"composite"===y.kind&&((v=[128*d.compositeTextSizes[0].evaluate(s,{},m),128*d.compositeTextSizes[1].evaluate(s,{},m)])[0]>32640||v[1]>32640)&&E(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'),t.addSymbols(t.text,g,v,l,a,s,c,e,u.lineStartIndex,u.lineLength,f,m);for(var _=0,x=h;_<x.length;_+=1)p[x[_]]=t.text.placedSymbolArray.length-1;return 4*g.length}function uu(t){for(var e in t)return t[e];return null}function cu(t,e,n,r){var i=t.compareText;if(e in i){for(var o=i[e],a=o.length-1;a>=0;a--)if(r.dist(o[a])<n)return!0}else i[e]=[];return i[e].push(r),!1}var hu=bs.VectorTileFeature.types,pu=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function fu(t,e,n,r,i,o,a,s,l,u,c,h,p){var f=s?Math.min(32640,Math.round(s[0])):0,d=s?Math.min(32640,Math.round(s[1])):0;t.emplaceBack(e,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p)}function du(t,e,n){t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n),t.emplaceBack(e.x,e.y,n)}function mu(t){for(var e=0,n=t.sections;e<n.length;e+=1)if(Qr(n[e].text))return!0;return!1}var gu=function(t){this.layoutVertexArray=new Oi,this.indexArray=new Gi,this.programConfigurations=t,this.segments=new lo,this.dynamicLayoutVertexArray=new ki,this.opacityVertexArray=new zi,this.placedSymbolArray=new to};gu.prototype.isEmpty=function(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length},gu.prototype.upload=function(t,e,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Gs.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,js.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,pu,!0),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(t))},gu.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())},Br("SymbolBuffers",gu);var yu=function(t,e,n){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new n,this.segments=new lo,this.collisionVertexArray=new Vi};yu.prototype.upload=function(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Hs.members,!0)},yu.prototype.destroy=function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())},Br("CollisionBuffers",yu);var vu=function(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=la([]),this.placementViewportMatrix=la([]);var e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=zl(this.zoom,e["text-size"]),this.iconSizeData=zl(this.zoom,e["icon-size"]);var n=this.layers[0].layout,r=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((function(t){return wl[t]}))),this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id})),this.sourceID=t.sourceID};vu.prototype.createArrays=function(){this.text=new gu(new ko(this.layers,this.zoom,(function(t){return/^text/.test(t)}))),this.icon=new gu(new ko(this.layers,this.zoom,(function(t){return/^icon/.test(t)}))),this.glyphOffsetArray=new ro,this.lineVertexArray=new io,this.symbolInstances=new no},vu.prototype.calculateGlyphDependencies=function(t,e,n,r,i){for(var o=0;o<t.length;o++)if(e[t.charCodeAt(o)]=!0,(n||r)&&i){var a=Zs[t.charAt(o)];a&&(e[a.charCodeAt(0)]=!0)}},vu.prototype.populate=function(t,e,n){var r=this.layers[0],i=r.layout,o=i.get("text-font"),a=i.get("text-field"),s=i.get("icon-image"),l=("constant"!==a.value.kind||a.value.value instanceof ie&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),u="constant"!==s.value.kind||!!s.value.value||Object.keys(s.parameters).length>0,c=i.get("symbol-sort-key");if(this.features=[],l||u){for(var h=e.iconDependencies,p=e.glyphDependencies,f=e.availableImages,d=new li(this.zoom),m=0,g=t;m<g.length;m+=1){var y=g[m],v=y.feature,_=y.id,x=y.index,b=y.sourceLayerIndex,w=r._featureFilter.needGeometry,E=Go(v,w);if(r._featureFilter.filter(d,E,n)){w||(E.geometry=Vo(v));var S=void 0;if(l){var M=r.getValueAndResolveTokens("text-field",E,n,f),T=ie.factory(M);mu(T)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===oi()||this.hasRTLText&&si.isParsed())&&(S=Xs(T,r,E))}var C=void 0;if(u){var I=r.getValueAndResolveTokens("icon-image",E,n,f);C=I instanceof oe?I:oe.fromString(I)}if(S||C){var A=this.sortFeaturesByKey?c.evaluate(E,{},n):void 0;if(this.features.push({id:_,text:S,icon:C,index:x,sourceLayerIndex:b,geometry:E.geometry,properties:v.properties,type:hu[v.type],sortKey:A}),C&&(h[C.name]=!0),S){var L=o.evaluate(E,{},n).join(","),P="map"===i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(wl.vertical)>=0;for(var R=0,D=S.sections;R<D.length;R+=1){var N=D[R];if(N.image)h[N.image.name]=!0;else{var O=Xr(S.toString()),k=N.fontStack||L,z=p[k]=p[k]||{};this.calculateGlyphDependencies(N.text,z,P,this.allowVerticalPlacement,O)}}}}}}"line"===i.get("symbol-placement")&&(this.features=function(t){var e={},n={},r=[],i=0;function o(e){r.push(t[e]),i++}function a(t,e,i){var o=n[t];return delete n[t],n[e]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(t,n,i){var o=e[n];return delete e[n],e[t]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(t,e,n){var r=n?e[0][e[0].length-1]:e[0][0];return t+":"+r.x+":"+r.y}for(var u=0;u<t.length;u++){var c=t[u],h=c.geometry,p=c.text?c.text.toString():null;if(p){var f=l(p,h),d=l(p,h,!0);if(f in n&&d in e&&n[f]!==e[d]){var m=s(f,d,h),g=a(f,d,r[m].geometry);delete e[f],delete n[d],n[l(p,r[g].geometry,!0)]=g,r[m].geometry=null}else f in n?a(f,d,h):d in e?s(f,d,h):(o(u),e[f]=i-1,n[d]=i-1)}else o(u)}return r.filter((function(t){return t.geometry}))}(this.features)),this.sortFeaturesByKey&&this.features.sort((function(t,e){return t.sortKey-e.sortKey}))}},vu.prototype.update=function(t,e,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,n),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,n))},vu.prototype.isEmpty=function(){return 0===this.symbolInstances.length&&!this.hasRTLText},vu.prototype.uploadPending=function(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload},vu.prototype.upload=function(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0},vu.prototype.destroyDebugData=function(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()},vu.prototype.destroy=function(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()},vu.prototype.addToLineVertexArray=function(t,e){var n=this.lineVertexArray.length;if(void 0!==t.segment){for(var r=t.dist(e[t.segment+1]),i=t.dist(e[t.segment]),o={},a=t.segment+1;a<e.length;a++)o[a]={x:e[a].x,y:e[a].y,tileUnitDistanceFromAnchor:r},a<e.length-1&&(r+=e[a+1].dist(e[a]));for(var s=t.segment||0;s>=0;s--)o[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l<e.length;l++){var u=o[l];this.lineVertexArray.emplaceBack(u.x,u.y,u.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}},vu.prototype.addSymbols=function(t,e,n,r,i,o,a,s,l,u,c,h){for(var p=t.indexArray,f=t.layoutVertexArray,d=t.segments.prepareSegment(4*e.length,f,p,this.canOverlap?o.sortKey:void 0),m=this.glyphOffsetArray.length,g=d.vertexLength,y=this.allowVerticalPlacement&&a===wl.vertical?Math.PI/2:0,v=o.text&&o.text.sections,_=0;_<e.length;_++){var x=e[_],b=x.tl,w=x.tr,E=x.bl,S=x.br,M=x.tex,T=x.pixelOffsetTL,C=x.pixelOffsetBR,I=x.minFontScaleX,A=x.minFontScaleY,L=x.glyphOffset,P=x.isSDF,R=x.sectionIndex,D=d.vertexLength,N=L[1];fu(f,s.x,s.y,b.x,N+b.y,M.x,M.y,n,P,T.x,T.y,I,A),fu(f,s.x,s.y,w.x,N+w.y,M.x+M.w,M.y,n,P,C.x,T.y,I,A),fu(f,s.x,s.y,E.x,N+E.y,M.x,M.y+M.h,n,P,T.x,C.y,I,A),fu(f,s.x,s.y,S.x,N+S.y,M.x+M.w,M.y+M.h,n,P,C.x,C.y,I,A),du(t.dynamicLayoutVertexArray,s,y),p.emplaceBack(D,D+1,D+2),p.emplaceBack(D+1,D+2,D+3),d.vertexLength+=4,d.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(L[0]),_!==e.length-1&&R===e[_+1].sectionIndex||t.programConfigurations.populatePaintArrays(f.length,o,o.index,{},h,v&&v[R])}t.placedSymbolArray.emplaceBack(s.x,s.y,m,this.glyphOffsetArray.length-m,g,l,u,s.segment,n?n[0]:0,n?n[1]:0,r[0],r[1],a,0,!1,0,c)},vu.prototype._addCollisionDebugVertex=function(t,e,n,r,i,o){return e.emplaceBack(0,0),t.emplaceBack(n.x,n.y,r,i,Math.round(o.x),Math.round(o.y))},vu.prototype.addCollisionDebugVertices=function(t,e,n,r,o,a,s){var l=o.segments.prepareSegment(4,o.layoutVertexArray,o.indexArray),u=l.vertexLength,c=o.layoutVertexArray,h=o.collisionVertexArray,p=s.anchorX,f=s.anchorY;this._addCollisionDebugVertex(c,h,a,p,f,new i(t,e)),this._addCollisionDebugVertex(c,h,a,p,f,new i(n,e)),this._addCollisionDebugVertex(c,h,a,p,f,new i(n,r)),this._addCollisionDebugVertex(c,h,a,p,f,new i(t,r)),l.vertexLength+=4;var d=o.indexArray;d.emplaceBack(u,u+1),d.emplaceBack(u+1,u+2),d.emplaceBack(u+2,u+3),d.emplaceBack(u+3,u),l.primitiveLength+=4},vu.prototype.addDebugCollisionBoxes=function(t,e,n,r){for(var i=t;i<e;i++){var o=this.collisionBoxArray.get(i);this.addCollisionDebugVertices(o.x1,o.y1,o.x2,o.y2,r?this.textCollisionBox:this.iconCollisionBox,o.anchorPoint,n)}},vu.prototype.generateCollisionDebugBuffers=function(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new yu(Bi,qs.members,Zi),this.iconCollisionBox=new yu(Bi,qs.members,Zi);for(var t=0;t<this.symbolInstances.length;t++){var e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}},vu.prototype._deserializeCollisionBoxesForSymbol=function(t,e,n,r,i,o,a,s,l){for(var u={},c=e;c<n;c++){var h=t.get(c);u.textBox={x1:h.x1,y1:h.y1,x2:h.x2,y2:h.y2,anchorPointX:h.anchorPointX,anchorPointY:h.anchorPointY},u.textFeatureIndex=h.featureIndex;break}for(var p=r;p<i;p++){var f=t.get(p);u.verticalTextBox={x1:f.x1,y1:f.y1,x2:f.x2,y2:f.y2,anchorPointX:f.anchorPointX,anchorPointY:f.anchorPointY},u.verticalTextFeatureIndex=f.featureIndex;break}for(var d=o;d<a;d++){var m=t.get(d);u.iconBox={x1:m.x1,y1:m.y1,x2:m.x2,y2:m.y2,anchorPointX:m.anchorPointX,anchorPointY:m.anchorPointY},u.iconFeatureIndex=m.featureIndex;break}for(var g=s;g<l;g++){var y=t.get(g);u.verticalIconBox={x1:y.x1,y1:y.y1,x2:y.x2,y2:y.y2,anchorPointX:y.anchorPointX,anchorPointY:y.anchorPointY},u.verticalIconFeatureIndex=y.featureIndex;break}return u},vu.prototype.deserializeCollisionBoxes=function(t){this.collisionArrays=[];for(var e=0;e<this.symbolInstances.length;e++){var n=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}},vu.prototype.hasTextData=function(){return this.text.segments.get().length>0},vu.prototype.hasIconData=function(){return this.icon.segments.get().length>0},vu.prototype.hasDebugData=function(){return this.textCollisionBox&&this.iconCollisionBox},vu.prototype.hasTextCollisionBoxData=function(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0},vu.prototype.hasIconCollisionBoxData=function(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0},vu.prototype.addIndicesForPlacedSymbol=function(t,e){for(var n=t.placedSymbolArray.get(e),r=n.vertexStartIndex+4*n.numGlyphs,i=n.vertexStartIndex;i<r;i+=4)t.indexArray.emplaceBack(i,i+1,i+2),t.indexArray.emplaceBack(i+1,i+2,i+3)},vu.prototype.getSortedSymbolIndexes=function(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;for(var e=Math.sin(t),n=Math.cos(t),r=[],i=[],o=[],a=0;a<this.symbolInstances.length;++a){o.push(a);var s=this.symbolInstances.get(a);r.push(0|Math.round(e*s.anchorX+n*s.anchorY)),i.push(s.featureIndex)}return o.sort((function(t,e){return r[t]-r[e]||i[e]-i[t]})),o},vu.prototype.addToSortKeyRanges=function(t,e){var n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===e?n.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})},vu.prototype.sortFeatures=function(t){var e=this;if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(var n=0,r=this.symbolInstanceIndexes;n<r.length;n+=1){var i=this.symbolInstances.get(r[n]);this.featureSortOrder.push(i.featureIndex),[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach((function(t,n,r){t>=0&&r.indexOf(t)===n&&e.addIndicesForPlacedSymbol(e.text,t)})),i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}},Br("SymbolBucket",vu,{omit:["layers","collisionBoxArray","features","compareText"]}),vu.MAX_GLYPHS=65535,vu.addDynamicAttributes=du;var _u=new wi({"symbol-placement":new yi(Lt.layout_symbol["symbol-placement"]),"symbol-spacing":new yi(Lt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new yi(Lt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new vi(Lt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new yi(Lt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new yi(Lt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new yi(Lt.layout_symbol["icon-ignore-placement"]),"icon-optional":new yi(Lt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new yi(Lt.layout_symbol["icon-rotation-alignment"]),"icon-size":new vi(Lt.layout_symbol["icon-size"]),"icon-text-fit":new yi(Lt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new yi(Lt.layout_symbol["icon-text-fit-padding"]),"icon-image":new vi(Lt.layout_symbol["icon-image"]),"icon-rotate":new vi(Lt.layout_symbol["icon-rotate"]),"icon-padding":new yi(Lt.layout_symbol["icon-padding"]),"icon-keep-upright":new yi(Lt.layout_symbol["icon-keep-upright"]),"icon-offset":new vi(Lt.layout_symbol["icon-offset"]),"icon-anchor":new vi(Lt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new yi(Lt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new yi(Lt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new yi(Lt.layout_symbol["text-rotation-alignment"]),"text-field":new vi(Lt.layout_symbol["text-field"]),"text-font":new vi(Lt.layout_symbol["text-font"]),"text-size":new vi(Lt.layout_symbol["text-size"]),"text-max-width":new vi(Lt.layout_symbol["text-max-width"]),"text-line-height":new yi(Lt.layout_symbol["text-line-height"]),"text-letter-spacing":new vi(Lt.layout_symbol["text-letter-spacing"]),"text-justify":new vi(Lt.layout_symbol["text-justify"]),"text-radial-offset":new vi(Lt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new yi(Lt.layout_symbol["text-variable-anchor"]),"text-anchor":new vi(Lt.layout_symbol["text-anchor"]),"text-max-angle":new yi(Lt.layout_symbol["text-max-angle"]),"text-writing-mode":new yi(Lt.layout_symbol["text-writing-mode"]),"text-rotate":new vi(Lt.layout_symbol["text-rotate"]),"text-padding":new yi(Lt.layout_symbol["text-padding"]),"text-keep-upright":new yi(Lt.layout_symbol["text-keep-upright"]),"text-transform":new vi(Lt.layout_symbol["text-transform"]),"text-offset":new vi(Lt.layout_symbol["text-offset"]),"text-allow-overlap":new yi(Lt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new yi(Lt.layout_symbol["text-ignore-placement"]),"text-optional":new yi(Lt.layout_symbol["text-optional"])}),xu={paint:new wi({"icon-opacity":new vi(Lt.paint_symbol["icon-opacity"]),"icon-color":new vi(Lt.paint_symbol["icon-color"]),"icon-halo-color":new vi(Lt.paint_symbol["icon-halo-color"]),"icon-halo-width":new vi(Lt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new vi(Lt.paint_symbol["icon-halo-blur"]),"icon-translate":new yi(Lt.paint_symbol["icon-translate"]),"icon-translate-anchor":new yi(Lt.paint_symbol["icon-translate-anchor"]),"text-opacity":new vi(Lt.paint_symbol["text-opacity"]),"text-color":new vi(Lt.paint_symbol["text-color"],{runtimeType:Gt,getOverride:function(t){return t.textColor},hasOverride:function(t){return!!t.textColor}}),"text-halo-color":new vi(Lt.paint_symbol["text-halo-color"]),"text-halo-width":new vi(Lt.paint_symbol["text-halo-width"]),"text-halo-blur":new vi(Lt.paint_symbol["text-halo-blur"]),"text-translate":new yi(Lt.paint_symbol["text-translate"]),"text-translate-anchor":new yi(Lt.paint_symbol["text-translate-anchor"])}),layout:_u},bu=function(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Ft,this.defaultValue=t};bu.prototype.evaluate=function(t){if(t.formattedSection){var e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default},bu.prototype.eachChild=function(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)},bu.prototype.outputDefined=function(){return!1},bu.prototype.serialize=function(){return null},Br("FormatSectionOverride",bu,{omit:["defaultValue"]});var wu=function(t){function e(e){t.call(this,e,xu)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.recalculate=function(e,n){if(t.prototype.recalculate.call(this,e,n),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){var r=this.layout.get("text-writing-mode");if(r){for(var i=[],o=0,a=r;o<a.length;o+=1){var s=a[o];i.indexOf(s)<0&&i.push(s)}this.layout._values["text-writing-mode"]=i}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()},e.prototype.getValueAndResolveTokens=function(t,e,n,r){var i=this.layout.get(t).evaluate(e,{},n,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||Xn(o.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,(function(e,n){return n in t?String(t[n]):""}))}(e.properties,i)},e.prototype.createBucket=function(t){return new vu(t)},e.prototype.queryRadius=function(){return 0},e.prototype.queryIntersectsFeature=function(){return!1},e.prototype._setPaintOverrides=function(){for(var t=0,n=xu.paint.overridableProperties;t<n.length;t+=1){var r=n[t];if(e.hasPaintOverride(this.layout,r)){var i,o=this.paint.get(r),a=new bu(o),s=new Wn(a,o.property.specification);i="constant"===o.value.kind||"source"===o.value.kind?new Yn("source",s):new Jn("composite",s,o.value.zoomStops,o.value._interpolationType),this.paint._values[r]=new mi(o.property,i,o.parameters)}}},e.prototype._handleOverridablePaintPropertyUpdate=function(t,n,r){return!(!this.layout||n.isDataDriven()||r.isDataDriven())&&e.hasPaintOverride(this.layout,t)},e.hasPaintOverride=function(t,e){var n=t.get("text-field"),r=xu.paint.properties[e],i=!1,o=function(t){for(var e=0,n=t;e<n.length;e+=1)if(r.overrides&&r.overrides.hasOverride(n[e]))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof ie)o(n.value.value.sections);else if("source"===n.value.kind){var a=function(t){i||(t instanceof ce&&le(t.value)===Wt?o(t.value.sections):t instanceof de?o(t.sections):t.eachChild(a))},s=n.value;s._styleExpression&&a(s._styleExpression.expression)}return i},e}(Ei),Eu={paint:new wi({"background-color":new yi(Lt.paint_background["background-color"]),"background-pattern":new xi(Lt.paint_background["background-pattern"]),"background-opacity":new yi(Lt.paint_background["background-opacity"])})},Su=function(t){function e(e){t.call(this,e,Eu)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Ei),Mu={paint:new wi({"raster-opacity":new yi(Lt.paint_raster["raster-opacity"]),"raster-hue-rotate":new yi(Lt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new yi(Lt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new yi(Lt.paint_raster["raster-brightness-max"]),"raster-saturation":new yi(Lt.paint_raster["raster-saturation"]),"raster-contrast":new yi(Lt.paint_raster["raster-contrast"]),"raster-resampling":new yi(Lt.paint_raster["raster-resampling"]),"raster-fade-duration":new yi(Lt.paint_raster["raster-fade-duration"])})},Tu=function(t){function e(e){t.call(this,e,Mu)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Ei),Cu=function(t){function e(e){t.call(this,e,{}),this.implementation=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.is3D=function(){return"3d"===this.implementation.renderingMode},e.prototype.hasOffscreenPass=function(){return void 0!==this.implementation.prerender},e.prototype.recalculate=function(){},e.prototype.updateTransitions=function(){},e.prototype.hasTransition=function(){},e.prototype.serialize=function(){},e.prototype.onAdd=function(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},e.prototype.onRemove=function(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},e}(Ei),Iu={circle:fa,heatmap:Ea,hillshade:Ma,fill:hs,"fill-extrusion":Is,line:Us,symbol:wu,background:Su,raster:Tu},Au=a.HTMLImageElement,Lu=a.HTMLCanvasElement,Pu=a.HTMLVideoElement,Ru=a.ImageData,Du=a.ImageBitmap,Nu=function(t,e,n,r){this.context=t,this.format=n,this.texture=t.gl.createTexture(),this.update(e,r)};Nu.prototype.update=function(t,e,n){var r=t.width,i=t.height,o=!(this.size&&this.size[0]===r&&this.size[1]===i||n),a=this.context,s=a.gl;if(this.useMipmap=Boolean(e&&e.useMipmap),s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),o)this.size=[r,i],t instanceof Au||t instanceof Lu||t instanceof Pu||t instanceof Ru||Du&&t instanceof Du?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,t):s.texImage2D(s.TEXTURE_2D,0,this.format,r,i,0,this.format,s.UNSIGNED_BYTE,t.data);else{var l=n||{x:0,y:0},u=l.x,c=l.y;t instanceof Au||t instanceof Lu||t instanceof Pu||t instanceof Ru||Du&&t instanceof Du?s.texSubImage2D(s.TEXTURE_2D,0,u,c,s.RGBA,s.UNSIGNED_BYTE,t):s.texSubImage2D(s.TEXTURE_2D,0,u,c,r,i,s.RGBA,s.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&s.generateMipmap(s.TEXTURE_2D)},Nu.prototype.bind=function(t,e,n){var r=this.context.gl;r.bindTexture(r.TEXTURE_2D,this.texture),n!==r.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=r.LINEAR),t!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,n||t),this.filter=t),e!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrap=e)},Nu.prototype.isSizePowerOfTwo=function(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0},Nu.prototype.destroy=function(){this.context.gl.deleteTexture(this.texture),this.texture=null};var Ou=function(t){var e=this;this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=function(){e._triggered=!1,e._callback()})};Ou.prototype.trigger=function(){var t=this;this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((function(){t._triggered=!1,t._callback()}),0))},Ou.prototype.remove=function(){delete this._channel,this._callback=function(){}};var ku=function(t,e,n){this.target=t,this.parent=e,this.mapId=n,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},y(["receive","process"],this),this.invoker=new Ou(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=T()?t:a};function zu(t,e,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}ku.prototype.send=function(t,e,n,r,i){var o=this;void 0===i&&(i=!1);var a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(this.callbacks[a]=n);var s=A(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:jr(e,s)},s),{cancel:function(){n&&delete o.callbacks[a],o.target.postMessage({id:a,type:"<cancel>",targetMapId:r,sourceMapId:o.mapId})}}},ku.prototype.receive=function(t){var e=t.data,n=e.id;if(n&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){delete this.tasks[n];var r=this.cancelCallbacks[n];delete this.cancelCallbacks[n],r&&r()}else T()||e.mustQueue?(this.tasks[n]=e,this.taskQueue.push(n),this.invoker.trigger()):this.processTask(n,e)},ku.prototype.process=function(){if(this.taskQueue.length){var t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}},ku.prototype.processTask=function(t,e){var n=this;if("<response>"===e.type){var r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Hr(e.error)):r(null,Hr(e.data)))}else{var i=!1,o=A(this.globalScope)?void 0:[],a=e.hasCallback?function(e,r){i=!0,delete n.cancelCallbacks[t],n.target.postMessage({id:t,type:"<response>",sourceMapId:n.mapId,error:e?jr(e):null,data:jr(r,o)},o)}:function(t){i=!0},s=null,l=Hr(e.data);if(this.parent[e.type])s=this.parent[e.type](e.sourceMapId,l,a);else if(this.parent.getWorkerSource){var u=e.type.split(".");s=this.parent.getWorkerSource(e.sourceMapId,u[0],l.source)[u[1]](l,a)}else a(new Error("Could not find function "+e.type));!i&&s&&s.cancel&&(this.cancelCallbacks[t]=s.cancel)}},ku.prototype.remove=function(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)};var Fu=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};Fu.prototype.setNorthEast=function(t){return this._ne=t instanceof Bu?new Bu(t.lng,t.lat):Bu.convert(t),this},Fu.prototype.setSouthWest=function(t){return this._sw=t instanceof Bu?new Bu(t.lng,t.lat):Bu.convert(t),this},Fu.prototype.extend=function(t){var e,n,r=this._sw,i=this._ne;if(t instanceof Bu)e=t,n=t;else{if(!(t instanceof Fu))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Fu.convert(t)):this.extend(Bu.convert(t)):this;if(n=t._ne,!(e=t._sw)||!n)return this}return r||i?(r.lng=Math.min(e.lng,r.lng),r.lat=Math.min(e.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Bu(e.lng,e.lat),this._ne=new Bu(n.lng,n.lat)),this},Fu.prototype.getCenter=function(){return new Bu((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},Fu.prototype.getSouthWest=function(){return this._sw},Fu.prototype.getNorthEast=function(){return this._ne},Fu.prototype.getNorthWest=function(){return new Bu(this.getWest(),this.getNorth())},Fu.prototype.getSouthEast=function(){return new Bu(this.getEast(),this.getSouth())},Fu.prototype.getWest=function(){return this._sw.lng},Fu.prototype.getSouth=function(){return this._sw.lat},Fu.prototype.getEast=function(){return this._ne.lng},Fu.prototype.getNorth=function(){return this._ne.lat},Fu.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},Fu.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},Fu.prototype.isEmpty=function(){return!(this._sw&&this._ne)},Fu.prototype.contains=function(t){var e=Bu.convert(t),n=e.lng,r=e.lat,i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i},Fu.convert=function(t){return!t||t instanceof Fu?t:new Fu(t)};var Bu=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};Bu.prototype.wrap=function(){return new Bu(h(this.lng,-180,180),this.lat)},Bu.prototype.toArray=function(){return[this.lng,this.lat]},Bu.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},Bu.prototype.distanceTo=function(t){var e=Math.PI/180,n=this.lat*e,r=t.lat*e,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return 6371008.8*Math.acos(Math.min(i,1))},Bu.prototype.toBounds=function(t){void 0===t&&(t=0);var e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new Fu(new Bu(this.lng-n,this.lat-e),new Bu(this.lng+n,this.lat+e))},Bu.convert=function(t){if(t instanceof Bu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Bu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Bu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")};var Uu=2*Math.PI*6371008.8;function Vu(t){return Uu*Math.cos(t*Math.PI/180)}function Gu(t){return(180+t)/360}function ju(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Hu(t,e){return t/Vu(e)}function qu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}var Wu=function(t,e,n){void 0===n&&(n=0),this.x=+t,this.y=+e,this.z=+n};Wu.fromLngLat=function(t,e){void 0===e&&(e=0);var n=Bu.convert(t);return new Wu(Gu(n.lng),ju(n.lat),Hu(e,n.lat))},Wu.prototype.toLngLat=function(){return new Bu(360*this.x-180,qu(this.y))},Wu.prototype.toAltitude=function(){return this.z*Vu(qu(this.y))},Wu.prototype.meterInMercatorCoordinateUnits=function(){return 1/Uu*(t=qu(this.y),1/Math.cos(t*Math.PI/180));var t};var Xu=function(t,e,n){this.z=t,this.x=e,this.y=n,this.key=Ju(0,t,t,e,n)};Xu.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Xu.prototype.url=function(t,e){var n,r,i,o,a,s=(r=this.y,i=this.z,o=zu(256*(n=this.x),256*(r=Math.pow(2,i)-r-1),i),a=zu(256*(n+1),256*(r+1),i),o[0]+","+o[1]+","+a[0]+","+a[1]),l=function(t,e,n){for(var r,i="",o=t;o>0;o--)i+=(e&(r=1<<o-1)?1:0)+(n&r?2:0);return i}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String("tms"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",l).replace("{bbox-epsg-3857}",s)},Xu.prototype.getTilePoint=function(t){var e=Math.pow(2,this.z);return new i(8192*(t.x*e-this.x),8192*(t.y*e-this.y))},Xu.prototype.toString=function(){return this.z+"/"+this.x+"/"+this.y};var Zu=function(t,e){this.wrap=t,this.canonical=e,this.key=Ju(t,e.z,e.z,e.x,e.y)},Yu=function(t,e,n,r,i){this.overscaledZ=t,this.wrap=e,this.canonical=new Xu(n,+r,+i),this.key=Ju(e,t,n,r,i)};function Ju(t,e,n,r,i){(t*=2)<0&&(t=-1*t-1);var o=1<<n;return(o*o*t+o*i+r).toString(36)+n.toString(36)+e.toString(36)}Yu.prototype.equals=function(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)},Yu.prototype.scaledTo=function(t){var e=this.canonical.z-t;return t>this.canonical.z?new Yu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Yu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},Yu.prototype.calculateScaledKey=function(t,e){var n=this.canonical.z-t;return t>this.canonical.z?Ju(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ju(this.wrap*+e,t,t,this.canonical.x>>n,this.canonical.y>>n)},Yu.prototype.isChildOf=function(t){if(t.wrap!==this.wrap)return!1;var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e},Yu.prototype.children=function(t){if(this.overscaledZ>=t)return[new Yu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Yu(e,this.wrap,e,n,r),new Yu(e,this.wrap,e,n+1,r),new Yu(e,this.wrap,e,n,r+1),new Yu(e,this.wrap,e,n+1,r+1)]},Yu.prototype.isLessThan=function(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))},Yu.prototype.wrapped=function(){return new Yu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)},Yu.prototype.unwrapTo=function(t){return new Yu(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)},Yu.prototype.overscaleFactor=function(){return Math.pow(2,this.overscaledZ-this.canonical.z)},Yu.prototype.toUnwrapped=function(){return new Zu(this.wrap,this.canonical)},Yu.prototype.toString=function(){return this.overscaledZ+"/"+this.canonical.x+"/"+this.canonical.y},Yu.prototype.getTilePoint=function(t){return this.canonical.getTilePoint(new Wu(t.x-this.wrap,t.y))},Br("CanonicalTileID",Xu),Br("OverscaledTileID",Yu,{omit:["posMatrix"]});var Ku=function(t,e,n){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(n&&"mapbox"!==n&&"terrarium"!==n)return E('"'+n+'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".');this.stride=e.height;var r=this.dim=e.height-2;this.data=new Uint32Array(e.data.buffer),this.encoding=n||"mapbox";for(var i=0;i<r;i++)this.data[this._idx(-1,i)]=this.data[this._idx(0,i)],this.data[this._idx(r,i)]=this.data[this._idx(r-1,i)],this.data[this._idx(i,-1)]=this.data[this._idx(i,0)],this.data[this._idx(i,r)]=this.data[this._idx(i,r-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(r,-1)]=this.data[this._idx(r-1,0)],this.data[this._idx(-1,r)]=this.data[this._idx(0,r-1)],this.data[this._idx(r,r)]=this.data[this._idx(r-1,r-1)]};Ku.prototype.get=function(t,e){var n=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(n[r],n[r+1],n[r+2])},Ku.prototype.getUnpackVector=function(){return"terrarium"===this.encoding?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]},Ku.prototype._idx=function(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)},Ku.prototype._unpackMapbox=function(t,e,n){return(256*t*256+256*e+n)/10-1e4},Ku.prototype._unpackTerrarium=function(t,e,n){return 256*t+e+n/256-32768},Ku.prototype.getPixels=function(){return new xa({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))},Ku.prototype.backfillBorder=function(t,e,n){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");var r=e*this.dim,i=e*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(e){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}for(var s=-e*this.dim,l=-n*this.dim,u=o;u<a;u++)for(var c=r;c<i;c++)this.data[this._idx(c,u)]=t.data[this._idx(c+s,u+l)]},Br("DEMData",Ku);var Qu=function(t){this._stringToNumber={},this._numberToString=[];for(var e=0;e<t.length;e++){var n=t[e];this._stringToNumber[n]=e,this._numberToString[e]=n}};Qu.prototype.encode=function(t){return this._stringToNumber[t]},Qu.prototype.decode=function(t){return this._numberToString[t]};var $u=function(t,e,n,r,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=n,t._y=r,this.properties=t.properties,this.id=i},tc={geometry:{configurable:!0}};tc.geometry.get=function(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry},tc.geometry.set=function(t){this._geometry=t},$u.prototype.toJSON=function(){var t={geometry:this.geometry};for(var e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t},Object.defineProperties($u.prototype,tc);var ec=function(){this.state={},this.stateChanges={},this.deletedStates={}};ec.prototype.updateState=function(t,e,n){var r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},p(this.stateChanges[t][r],n),null===this.deletedStates[t])for(var i in this.deletedStates[t]={},this.state[t])i!==r&&(this.deletedStates[t][i]=null);else if(this.deletedStates[t]&&null===this.deletedStates[t][r])for(var o in this.deletedStates[t][r]={},this.state[t][r])n[o]||(this.deletedStates[t][r][o]=null);else for(var a in n)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][a]&&delete this.deletedStates[t][r][a]},ec.prototype.removeFeatureState=function(t,e,n){if(null!==this.deletedStates[t]){var r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},n&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][n]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(n in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][n]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}},ec.prototype.getState=function(t,e){var n=String(e),r=p({},(this.state[t]||{})[n],(this.stateChanges[t]||{})[n]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){var i=this.deletedStates[t][e];if(null===i)return{};for(var o in i)delete r[o]}return r},ec.prototype.initializeTileState=function(t,e){t.setFeatureState(this.state,e)},ec.prototype.coalesceChanges=function(t,e){var n={};for(var r in this.stateChanges){this.state[r]=this.state[r]||{};var i={};for(var o in this.stateChanges[r])this.state[r][o]||(this.state[r][o]={}),p(this.state[r][o],this.stateChanges[r][o]),i[o]=this.state[r][o];n[r]=i}for(var a in this.deletedStates){this.state[a]=this.state[a]||{};var s={};if(null===this.deletedStates[a])for(var l in this.state[a])s[l]={},this.state[a][l]={};else for(var u in this.deletedStates[a]){if(null===this.deletedStates[a][u])this.state[a][u]={};else for(var c=0,h=Object.keys(this.deletedStates[a][u]);c<h.length;c+=1)delete this.state[a][u][h[c]];s[u]=this.state[a][u]}n[a]=n[a]||{},p(n[a],s)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(var f in t)t[f].setFeatureState(n,e)};var nc=function(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Nr(8192,16,0),this.grid3D=new Nr(8192,16,0),this.featureIndexArray=new ao,this.promoteId=e};function rc(t,e,n,r,i){return _(t,(function(t,o){var a=e instanceof gi?e.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a}))}function ic(t){for(var e=1/0,n=1/0,r=-1/0,i=-1/0,o=0,a=t;o<a.length;o+=1){var s=a[o];e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y)}return{minX:e,minY:n,maxX:r,maxY:i}}function oc(t,e){return e-t}nc.prototype.insert=function(t,e,n,r,i,o){var a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);for(var s=o?this.grid3D:this.grid,l=0;l<e.length;l++){for(var u=e[l],c=[1/0,1/0,-1/0,-1/0],h=0;h<u.length;h++){var p=u[h];c[0]=Math.min(c[0],p.x),c[1]=Math.min(c[1],p.y),c[2]=Math.max(c[2],p.x),c[3]=Math.max(c[3],p.y)}c[0]<8192&&c[1]<8192&&c[2]>=0&&c[3]>=0&&s.insert(a,c[0],c[1],c[2],c[3])}},nc.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new bs.VectorTile(new Ks(this.rawTileData)).layers,this.sourceLayerCoder=new Qu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},nc.prototype.query=function(t,e,n,r){var o=this;this.loadVTLayers();for(var a=t.params||{},s=8192/t.tileSize/t.scale,l=sr(a.filter),u=t.queryGeometry,c=t.queryPadding*s,h=ic(u),p=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),f=ic(t.cameraQueryGeometry),d=this.grid3D.query(f.minX-c,f.minY-c,f.maxX+c,f.maxY+c,(function(e,n,r,o){return function(t,e,n,r,o){for(var a=0,s=t;a<s.length;a+=1){var l=s[a];if(e<=l.x&&n<=l.y&&r>=l.x&&o>=l.y)return!0}var u=[new i(e,n),new i(e,o),new i(r,o),new i(r,n)];if(t.length>2)for(var c=0,h=u;c<h.length;c+=1)if(ta(t,h[c]))return!0;for(var p=0;p<t.length-1;p++)if(ea(t[p],t[p+1],u))return!0;return!1}(t.cameraQueryGeometry,e-c,n-c,r+c,o+c)})),m=0,g=d;m<g.length;m+=1)p.push(g[m]);p.sort(oc);for(var y,v={},_=function(i){var c=p[i];if(c!==y){y=c;var h=o.featureIndexArray.get(c),f=null;o.loadMatchingFeature(v,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,l,a.layers,a.availableImages,e,n,r,(function(e,n,r){return f||(f=Vo(e)),n.queryIntersectsFeature(u,e,r,f,o.z,t.transform,s,t.pixelPosMatrix)}))}},x=0;x<p.length;x++)_(x);return v},nc.prototype.loadMatchingFeature=function(t,e,n,r,i,o,a,s,l,u,c){var h=this.bucketLayerIDs[e];if(!o||function(t,e){for(var n=0;n<t.length;n++)if(e.indexOf(t[n])>=0)return!0;return!1}(o,h)){var f=this.sourceLayerCoder.decode(n),d=this.vtLayers[f].feature(r);if(i.needGeometry){var m=Go(d,!0);if(!i.filter(new li(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!i.filter(new li(this.tileID.overscaledZ),d))return;for(var g=this.getId(d,f),y=0;y<h.length;y++){var v=h[y];if(!(o&&o.indexOf(v)<0)){var _=s[v];if(_){var x={};void 0!==g&&u&&(x=u.getState(_.sourceLayer||"_geojsonTileLayer",g));var b=p({},l[v]);b.paint=rc(b.paint,_.paint,d,x,a),b.layout=rc(b.layout,_.layout,d,x,a);var w=!c||c(d,_,x);if(w){var E=new $u(d,this.z,this.x,this.y,g);E.layer=b;var S=t[v];void 0===S&&(S=t[v]=[]),S.push({featureIndex:r,feature:E,intersectionZ:w})}}}}}},nc.prototype.lookupSymbolFeatures=function(t,e,n,r,i,o,a,s){var l={};this.loadVTLayers();for(var u=sr(i),c=0,h=t;c<h.length;c+=1)this.loadMatchingFeature(l,n,r,h[c],u,o,a,s,e);return l},nc.prototype.hasLayer=function(t){for(var e=0,n=this.bucketLayerIDs;e<n.length;e+=1)for(var r=0,i=n[e];r<i.length;r+=1)if(t===i[r])return!0;return!1},nc.prototype.getId=function(t,e){var n=t.id;return this.promoteId&&"boolean"==typeof(n=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]])&&(n=Number(n)),n},Br("FeatureIndex",nc,{omit:["rawTileData","sourceLayerCoder"]});var ac=function(t,e){this.tileID=t,this.uid=d(),this.uses=0,this.tileSize=e,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.expiredRequestCount=0,this.state="loading"};ac.prototype.registerFadeDuration=function(t){var e=t+this.timeAdded;e<F.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)},ac.prototype.wasRequested=function(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state},ac.prototype.loadVectorData=function(t,e,n){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){for(var r in t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){var n={};if(!e)return n;for(var r=function(){var t=o[i],r=t.layerIds.map((function(t){return e.getLayer(t)})).filter(Boolean);if(0!==r.length){t.layers=r,t.stateDependentLayerIds&&(t.stateDependentLayers=t.stateDependentLayerIds.map((function(t){return r.filter((function(e){return e.id===t}))[0]})));for(var a=0,s=r;a<s.length;a+=1)n[s[a].id]=t}},i=0,o=t;i<o.length;i+=1)r();return n}(t.buckets,e.style),this.hasSymbolBuckets=!1,this.buckets){var i=this.buckets[r];if(i instanceof vu){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(var o in this.buckets){var a=this.buckets[o];if(a instanceof vu&&a.hasRTLText){this.hasRTLText=!0,si.isLoading()||si.isLoaded()||"deferred"!==oi()||ai();break}}for(var s in this.queryPadding=0,this.buckets){var l=this.buckets[s];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(s).queryRadius(l))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new Qi},ac.prototype.unloadVectorData=function(){for(var t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"},ac.prototype.getBucket=function(t){return this.buckets[t.id]},ac.prototype.upload=function(t){for(var e in this.buckets){var n=this.buckets[e];n.uploadPending()&&n.upload(t)}var r=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Nu(t,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Nu(t,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null)},ac.prototype.prepare=function(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)},ac.prototype.queryRenderedFeatures=function(t,e,n,r,i,o,a,s,l,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:i,scale:o,tileSize:this.tileSize,pixelPosMatrix:u,transform:s,params:a,queryPadding:this.queryPadding*l},t,e,n):{}},ac.prototype.querySourceFeatures=function(t,e){var n=this.latestFeatureIndex;if(n&&n.rawTileData){var r=n.loadVTLayers(),i=e?e.sourceLayer:"",o=r._geojsonTileLayer||r[i];if(o)for(var a=sr(e&&e.filter),s=this.tileID.canonical,l=s.z,u=s.x,c=s.y,h={z:l,x:u,y:c},p=0;p<o.length;p++){var f=o.feature(p);if(a.needGeometry){var d=Go(f,!0);if(!a.filter(new li(this.tileID.overscaledZ),d,this.tileID.canonical))continue}else if(!a.filter(new li(this.tileID.overscaledZ),f))continue;var m=n.getId(f,i),g=new $u(f,l,u,c,m);g.tile=h,t.push(g)}}},ac.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},ac.prototype.patternsLoaded=function(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length},ac.prototype.setExpiryData=function(t){var e=this.expirationTime;if(t.cacheControl){var n=C(t.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){var r=Date.now(),i=!1;if(this.expirationTime>r)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{var o=this.expirationTime-e;o?this.expirationTime=r+Math.max(o,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}},ac.prototype.getExpiryTimeout=function(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)},ac.prototype.setFeatureState=function(t,e){if(this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&0!==Object.keys(t).length){var n=this.latestFeatureIndex.loadVTLayers();for(var r in this.buckets)if(e.style.hasLayer(r)){var i=this.buckets[r],o=i.layers[0].sourceLayer||"_geojsonTileLayer",a=n[o],s=t[o];if(a&&s&&0!==Object.keys(s).length){i.update(s,a,this.imageAtlas&&this.imageAtlas.patternPositions||{});var l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(i)))}}}},ac.prototype.holdingForFade=function(){return void 0!==this.symbolFadeHoldUntil},ac.prototype.symbolFadeFinished=function(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<F.now()},ac.prototype.clearFadeHold=function(){this.symbolFadeHoldUntil=void 0},ac.prototype.setHoldDuration=function(t){this.symbolFadeHoldUntil=F.now()+t},ac.prototype.setDependencies=function(t,e){for(var n={},r=0,i=e;r<i.length;r+=1)n[i[r]]=!0;this.dependencies[t]=n},ac.prototype.hasDependency=function(t,e){for(var n=0,r=t;n<r.length;n+=1){var i=this.dependencies[r[n]];if(i)for(var o=0,a=e;o<a.length;o+=1)if(i[a[o]])return!0}return!1};var sc=a.performance,lc=function(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},sc.mark(this._marks.start)};lc.prototype.finish=function(){sc.mark(this._marks.end);var t=sc.getEntriesByName(this._marks.measure);return 0===t.length&&(sc.measure(this._marks.measure,this._marks.start,this._marks.end),t=sc.getEntriesByName(this._marks.measure),sc.clearMarks(this._marks.start),sc.clearMarks(this._marks.end),sc.clearMeasures(this._marks.measure)),t},t.Actor=ku,t.AlphaImage=_a,t.CanonicalTileID=Xu,t.CollisionBoxArray=Qi,t.Color=ee,t.DEMData=Ku,t.DataConstantProperty=yi,t.DictionaryCoder=Qu,t.EXTENT=8192,t.ErrorEvent=It,t.EvaluationParameters=li,t.Event=Ct,t.Evented=At,t.FeatureIndex=nc,t.FillBucket=ls,t.FillExtrusionBucket=Ms,t.ImageAtlas=bl,t.ImagePosition=_l,t.LineBucket=ks,t.LngLat=Bu,t.LngLatBounds=Fu,t.MercatorCoordinate=Wu,t.ONE_EM=24,t.OverscaledTileID=Yu,t.Point=i,t.Point$1=i,t.Properties=wi,t.Protobuf=Ks,t.RGBAImage=xa,t.RequestManager=q,t.RequestPerformance=lc,t.ResourceType=dt,t.SegmentVector=lo,t.SourceFeatureState=ec,t.StructArrayLayout1ui2=Yi,t.StructArrayLayout2f1f2i16=Ui,t.StructArrayLayout2i4=Ai,t.StructArrayLayout3ui6=Gi,t.StructArrayLayout4i8=Li,t.SymbolBucket=vu,t.Texture=Nu,t.Tile=ac,t.Transitionable=hi,t.Uniform1f=wo,t.Uniform1i=bo,t.Uniform2f=Eo,t.Uniform3f=So,t.Uniform4f=Mo,t.UniformColor=To,t.UniformMatrix4f=Io,t.UnwrappedTileID=Zu,t.ValidationError=Pt,t.WritingMode=wl,t.ZoomHistory=qr,t.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t},t.addDynamicAttributes=du,t.asyncAll=function(t,e,n){if(!t.length)return n(null,[]);var r=t.length,i=new Array(t.length),o=null;t.forEach((function(t,a){e(t,(function(t,e){t&&(o=t),i[a]=e,0==--r&&n(o,i)}))}))},t.bezier=l,t.bindAll=y,t.browser=F,t.cacheEntryPossiblyAdded=function(t){++pt>lt&&(t.getActor().send("enforceCacheSizeLimit",st),pt=0)},t.clamp=c,t.clearTileCache=function(t){var e=a.caches.delete("mapbox-tiles");t&&e.catch(t).then((function(){return t()}))},t.clipLine=Xl,t.clone=function(t){var e=new sa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=b,t.clone$2=function(t){var e=new sa(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.collisionCircleLayout=Ws,t.config=B,t.create=function(){var t=new sa(16);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=function(){var t=new sa(9);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},t.create$2=function(){var t=new sa(4);return sa!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},t.createCommonjsModule=e,t.createExpression=Zn,t.createLayout=Ci,t.createStyleLayer=function(t){return"custom"===t.type?new Cu(t):new Iu[t.type](t)},t.cross=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],l=n[2];return t[0]=i*l-o*s,t[1]=o*a-r*l,t[2]=r*s-i*a,t},t.deepEqual=function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==n){if("object"!=typeof n)return!1;if(Object.keys(e).length!==Object.keys(n).length)return!1;for(var i in e)if(!t(e[i],n[i]))return!1;return!0}return e===n},t.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.dot$1=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.ease=u,t.emitValidationErrors=Dr,t.endsWith=v,t.enforceCacheSizeLimit=function(t){ut(),tt&&tt.then((function(e){e.keys().then((function(n){for(var r=0;r<n.length-t;r++)e.delete(n[r])}))}))},t.evaluateSizeForFeature=Fl,t.evaluateSizeForZoom=Bl,t.evaluateVariableOffset=au,t.evented=ii,t.extend=p,t.featureFilter=sr,t.filterObject=x,t.fromRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.getAnchorAlignment=Dl,t.getAnchorJustification=su,t.getArrayBuffer=bt,t.getImage=St,t.getJSON=function(t,e){return xt(p(t,{type:"json"}),e)},t.getRTLTextPluginStatus=oi,t.getReferrer=gt,t.getVideo=function(t,e){var n,r,i=a.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(var o=0;o<t.length;o++){var s=a.document.createElement("source");n=t[o],r=void 0,(r=a.document.createElement("a")).href=n,(r.protocol!==a.document.location.protocol||r.host!==a.document.location.host)&&(i.crossOrigin="Anonymous"),s.src=t[o],i.appendChild(s)}return{cancel:function(){}}},t.identity=la,t.invert=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],g=e[14],y=e[15],v=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,E=i*u-o*l,S=c*m-h*d,M=c*g-p*d,T=c*y-f*d,C=h*g-p*m,I=h*y-f*m,A=p*y-f*g,L=v*A-_*I+x*C+b*T-w*M+E*S;return L?(t[0]=(s*A-l*I+u*C)*(L=1/L),t[1]=(i*I-r*A-o*C)*L,t[2]=(m*E-g*w+y*b)*L,t[3]=(p*w-h*E-f*b)*L,t[4]=(l*T-a*A-u*M)*L,t[5]=(n*A-i*T+o*M)*L,t[6]=(g*x-d*E-y*_)*L,t[7]=(c*E-p*x+f*_)*L,t[8]=(a*I-s*T+u*S)*L,t[9]=(r*T-n*I-o*S)*L,t[10]=(d*w-m*x+y*v)*L,t[11]=(h*x-c*w-f*v)*L,t[12]=(s*M-a*C-l*S)*L,t[13]=(n*C-r*M+i*S)*L,t[14]=(m*_-d*b-g*v)*L,t[15]=(c*b-h*_+p*v)*L,t):null},t.isChar=Wr,t.isMapboxURL=W,t.keysDifference=function(t,e){var n=[];for(var r in t)r in e||n.push(r);return n},t.makeRequest=xt,t.mapObject=_,t.mercatorXfromLng=Gu,t.mercatorYfromLat=ju,t.mercatorZfromAltitude=Hu,t.mul=ha,t.multiply=ua,t.mvt=bs,t.nextPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.normalize=function(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},t.number=qe,t.offscreenCanvasSupported=ft,t.ortho=function(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(a+o)*u,t[15]=1,t},t.parseGlyphPBF=function(t){return new Ks(t).readFields(ml,[])},t.pbf=Ks,t.performSymbolLayout=function(t,e,n,r,i,o,a){t.createArrays(),t.tilePixelRatio=8192/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;var s=t.layers[0].layout,l=t.layers[0]._unevaluatedLayout._values,u={};if("composite"===t.textSizeData.kind){var c=t.textSizeData,h=c.maxZoom;u.compositeTextSizes=[l["text-size"].possiblyEvaluate(new li(c.minZoom),a),l["text-size"].possiblyEvaluate(new li(h),a)]}if("composite"===t.iconSizeData.kind){var p=t.iconSizeData,f=p.maxZoom;u.compositeIconSizes=[l["icon-size"].possiblyEvaluate(new li(p.minZoom),a),l["icon-size"].possiblyEvaluate(new li(f),a)]}u.layoutTextSize=l["text-size"].possiblyEvaluate(new li(t.zoom+1),a),u.layoutIconSize=l["icon-size"].possiblyEvaluate(new li(t.zoom+1),a),u.textMaxSize=l["text-size"].possiblyEvaluate(new li(18));for(var d=24*s.get("text-line-height"),m="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement"),g=s.get("text-keep-upright"),y=s.get("text-size"),v=function(){var o=x[_],l=s.get("text-font").evaluate(o,{},a).join(","),c=y.evaluate(o,{},a),h=u.layoutTextSize.evaluate(o,{},a),p=u.layoutIconSize.evaluate(o,{},a),f={horizontal:{},vertical:void 0},v=o.text,b=[0,0];if(v){var w=v.toString(),S=24*s.get("text-letter-spacing").evaluate(o,{},a),M=function(t){for(var e=0,n=t;e<n.length;e+=1)if(r=n[e].charCodeAt(0),Wr.Arabic(r)||Wr["Arabic Supplement"](r)||Wr["Arabic Extended-A"](r)||Wr["Arabic Presentation Forms-A"](r)||Wr["Arabic Presentation Forms-B"](r))return!1;var r;return!0}(w)?S:0,T=s.get("text-anchor").evaluate(o,{},a),C=s.get("text-variable-anchor");if(!C){var I=s.get("text-radial-offset").evaluate(o,{},a);b=I?au(T,[24*I,ou]):s.get("text-offset").evaluate(o,{},a).map((function(t){return 24*t}))}var A=m?"center":s.get("text-justify").evaluate(o,{},a),L=s.get("symbol-placement"),P="point"===L?24*s.get("text-max-width").evaluate(o,{},a):0,R=function(){t.allowVerticalPlacement&&Xr(w)&&(f.vertical=Ml(v,e,n,i,l,P,d,T,"left",M,b,wl.vertical,!0,L,h,c))};if(!m&&C){for(var D="auto"===A?C.map((function(t){return su(t)})):[A],N=!1,O=0;O<D.length;O++){var k=D[O];if(!f.horizontal[k])if(N)f.horizontal[k]=f.horizontal[0];else{var z=Ml(v,e,n,i,l,P,d,"center",k,M,b,wl.horizontal,!1,L,h,c);z&&(f.horizontal[k]=z,N=1===z.positionedLines.length)}}R()}else{"auto"===A&&(A=su(T));var F=Ml(v,e,n,i,l,P,d,T,A,M,b,wl.horizontal,!1,L,h,c);F&&(f.horizontal[A]=F),R(),Xr(w)&&m&&g&&(f.vertical=Ml(v,e,n,i,l,P,d,T,A,M,b,wl.vertical,!1,L,h,c))}}var B=void 0,U=!1;if(o.icon&&o.icon.name){var V=r[o.icon.name];V&&(B=function(t,e,n){var r=Dl(n),i=e[0]-t.displaySize[0]*r.horizontalAlign,o=e[1]-t.displaySize[1]*r.verticalAlign;return{image:t,top:o,bottom:o+t.displaySize[1],left:i,right:i+t.displaySize[0]}}(i[o.icon.name],s.get("icon-offset").evaluate(o,{},a),s.get("icon-anchor").evaluate(o,{},a)),U=V.sdf,void 0===t.sdfIcons?t.sdfIcons=V.sdf:t.sdfIcons!==V.sdf&&E("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(V.pixelRatio!==t.pixelRatio||0!==s.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}var G=uu(f.horizontal)||f.vertical;t.iconsInText=!!G&&G.iconsInText,(G||B)&&function(t,e,n,r,i,o,a,s,l,u,c){var h=o.textMaxSize.evaluate(e,{});void 0===h&&(h=a);var p,f=t.layers[0].layout,d=f.get("icon-offset").evaluate(e,{},c),m=uu(n.horizontal),g=a/24,y=t.tilePixelRatio*g,v=t.tilePixelRatio*h/24,_=t.tilePixelRatio*s,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=f.get("icon-padding")*t.tilePixelRatio,S=f.get("text-max-angle")/180*Math.PI,M="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),T="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),C=f.get("symbol-placement"),I=x/2,A=f.get("icon-text-fit");r&&"none"!==A&&(t.allowVerticalPlacement&&n.vertical&&(p=Ol(r,n.vertical,A,f.get("icon-text-fit-padding"),d,g)),m&&(r=Ol(r,m,A,f.get("icon-text-fit-padding"),d,g)));var L=function(s,h){h.x<0||h.x>=8192||h.y<0||h.y>=8192||function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,S,M){var T,C,I,A,L,P=t.addToLineVertexArray(e,n),R=0,D=0,N=0,O=0,k=-1,z=-1,F={},B=fo(""),U=0,V=0;if(void 0===s._unevaluatedLayout.getValue("text-radial-offset")?(U=(T=s.layout.get("text-offset").evaluate(x,{},S).map((function(t){return 24*t})))[0],V=T[1]):(U=24*s.layout.get("text-radial-offset").evaluate(x,{},S),V=ou),t.allowVerticalPlacement&&r.vertical){var G=s.layout.get("text-rotate").evaluate(x,{},S)+90;A=new $l(l,e,u,c,h,r.vertical,p,f,d,G),a&&(L=new $l(l,e,u,c,h,a,g,y,d,G))}if(i){var j=s.layout.get("icon-rotate").evaluate(x,{}),H="none"!==s.layout.get("icon-text-fit"),q=Zl(i,j,w,H),W=a?Zl(a,j,w,H):void 0;I=new $l(l,e,u,c,h,i,g,y,!1,j),R=4*q.length;var X=t.iconSizeData,Z=null;"source"===X.kind?(Z=[128*s.layout.get("icon-size").evaluate(x,{})])[0]>32640&&E(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'):"composite"===X.kind&&((Z=[128*b.compositeIconSizes[0].evaluate(x,{},S),128*b.compositeIconSizes[1].evaluate(x,{},S)])[0]>32640||Z[1]>32640)&&E(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'),t.addSymbols(t.icon,q,Z,_,v,x,!1,e,P.lineStartIndex,P.lineLength,-1,S),k=t.icon.placedSymbolArray.length-1,W&&(D=4*W.length,t.addSymbols(t.icon,W,Z,_,v,x,wl.vertical,e,P.lineStartIndex,P.lineLength,-1,S),z=t.icon.placedSymbolArray.length-1)}for(var Y in r.horizontal){var J=r.horizontal[Y];if(!C){B=fo(J.text);var K=s.layout.get("text-rotate").evaluate(x,{},S);C=new $l(l,e,u,c,h,J,p,f,d,K)}var Q=1===J.positionedLines.length;if(N+=lu(t,e,J,o,s,d,x,m,P,r.vertical?wl.horizontal:wl.horizontalOnly,Q?Object.keys(r.horizontal):[Y],F,k,b,S),Q)break}r.vertical&&(O+=lu(t,e,r.vertical,o,s,d,x,m,P,wl.vertical,["vertical"],F,z,b,S));var $=C?C.boxStartIndex:t.collisionBoxArray.length,tt=C?C.boxEndIndex:t.collisionBoxArray.length,et=A?A.boxStartIndex:t.collisionBoxArray.length,nt=A?A.boxEndIndex:t.collisionBoxArray.length,rt=I?I.boxStartIndex:t.collisionBoxArray.length,it=I?I.boxEndIndex:t.collisionBoxArray.length,ot=L?L.boxStartIndex:t.collisionBoxArray.length,at=L?L.boxEndIndex:t.collisionBoxArray.length,st=-1,lt=function(t,e){return t&&t.circleDiameter?Math.max(t.circleDiameter,e):e};st=lt(C,st),st=lt(A,st),st=lt(I,st);var ut=(st=lt(L,st))>-1?1:0;ut&&(st*=M/24),t.glyphOffsetArray.length>=vu.MAX_GLYPHS&&E("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,F.right>=0?F.right:-1,F.center>=0?F.center:-1,F.left>=0?F.left:-1,F.vertical||-1,k,z,B,$,tt,et,nt,rt,it,ot,at,u,N,O,R,D,ut,0,p,U,V,st)}(t,h,s,n,r,i,p,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,b,M,l,_,w,T,d,e,o,u,c,a)};if("line"===C)for(var P=0,R=Xl(e.geometry,0,0,8192,8192);P<R.length;P+=1)for(var D=R[P],N=0,O=Wl(D,x,S,n.vertical||m,r,24,v,t.overscaling,8192);N<O.length;N+=1){var k=O[N];m&&cu(t,m.text,I,k)||L(D,k)}else if("line-center"===C)for(var z=0,F=e.geometry;z<F.length;z+=1){var B=F[z];if(B.length>1){var U=ql(B,S,n.vertical||m,r,24,v);U&&L(B,U)}}else if("Polygon"===e.type)for(var V=0,G=is(e.geometry,0);V<G.length;V+=1){var j=G[V],H=nu(j,16);L(j[0],new kl(H.x,H.y,0))}else if("LineString"===e.type)for(var q=0,W=e.geometry;q<W.length;q+=1){var X=W[q];L(X,new kl(X[0].x,X[0].y,0))}else if("Point"===e.type)for(var Z=0,Y=e.geometry;Z<Y.length;Z+=1)for(var J=0,K=Y[Z];J<K.length;J+=1){var Q=K[J];L([Q],new kl(Q.x,Q.y,0))}}(t,o,f,B,r,u,h,p,b,U,a)},_=0,x=t.features;_<x.length;_+=1)v();o&&t.generateCollisionDebugBuffers()},t.perspective=function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+r)*(o=1/(r-i)),t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){for(var n={},r=0;r<e.length;r++){var i=e[r];i in t&&(n[i]=t[i])}return n},t.plugin=si,t.polygonIntersectsPolygon=qo,t.postMapLoadEvent=at,t.postTurnstileEvent=it,t.potpack=vl,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.register=Br,t.registerForPluginStateChange=function(t){return t({pluginStatus:ti,pluginURL:ei}),ii.on("pluginStateChange",t),t},t.renderColorRamp=wa,t.rotate=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=Math.sin(n),l=Math.cos(n);return t[0]=r*l+o*s,t[1]=i*l+a*s,t[2]=r*-s+o*l,t[3]=i*-s+a*l,t},t.rotateX=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*r,t[5]=a*i+c*r,t[6]=s*i+h*r,t[7]=l*i+p*r,t[8]=u*i-o*r,t[9]=c*i-a*r,t[10]=h*i-s*r,t[11]=p*i-l*r,t},t.rotateZ=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*r,t[1]=a*i+c*r,t[2]=s*i+h*r,t[3]=l*i+p*r,t[4]=u*i-o*r,t[5]=c*i-a*r,t[6]=h*i-s*r,t[7]=p*i-l*r,t},t.scale=function(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.scale$1=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},t.scale$2=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t},t.setCacheLimits=function(t,e){st=t,lt=e},t.setRTLTextPlugin=function(t,e,n){if(void 0===n&&(n=!1),"deferred"===ti||"loading"===ti||"loaded"===ti)throw new Error("setRTLTextPlugin cannot be called multiple times.");ei=F.resolveURL(t),ti="deferred",$r=e,ri(),n||ai()},t.sphericalToCartesian=function(t){var e=t[0],n=t[1],r=t[2];return n+=90,n*=Math.PI/180,r*=Math.PI/180,{x:e*Math.cos(n)*Math.sin(r),y:e*Math.sin(n)*Math.sin(r),z:e*Math.cos(r)}},t.sqrLen=function(t){var e=t[0],n=t[1];return e*e+n*n},t.styleSpec=Lt,t.sub=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},t.symbolSize=Ul,t.transformMat3=function(t,e,n){var r=e[0],i=e[1],o=e[2];return t[0]=r*n[0]+i*n[3]+o*n[6],t[1]=r*n[1]+i*n[4]+o*n[7],t[2]=r*n[2]+i*n[5]+o*n[8],t},t.transformMat4=pa,t.translate=function(t,e,n){var r,i,o,a,s,l,u,c,h,p,f,d,m=n[0],g=n[1],y=n[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r=e[0],t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*m+s*g+h*y+e[12],t[13]=i*m+l*g+p*y+e[13],t[14]=o*m+u*g+f*y+e[14],t[15]=a*m+c*g+d*y+e[15]),t},t.triggerPluginCompletionEvent=ni,t.uniqueId=d,t.validateCustomStyleLayer=function(t){var e=[],n=t.id;return void 0===n&&e.push({message:"layers."+n+': missing required property "id"'}),void 0===t.render&&e.push({message:"layers."+n+': missing required method "render"'}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:"layers."+n+': property "renderingMode" must be either "2d" or "3d"'}),e},t.validateLight=Lr,t.validateStyle=Ar,t.values=function(t){var e=[];for(var n in t)e.push(t[n]);return e},t.vectorTile=bs,t.version="1.15.2",t.warnOnce=E,t.webpSupported=U,t.window=a,t.wrap=h}));r(0,(function(t){function e(t){var n=typeof t;if("number"===n||"boolean"===n||"string"===n||null==t)return JSON.stringify(t);if(Array.isArray(t)){for(var r="[",i=0,o=t;i<o.length;i+=1)r+=e(o[i])+",";return r+"]"}for(var a=Object.keys(t).sort(),s="{",l=0;l<a.length;l++)s+=JSON.stringify(a[l])+":"+e(t[a[l]])+",";return s+"}"}function n(n){for(var r="",i=0,o=t.refProperties;i<o.length;i+=1)r+="/"+e(n[o[i]]);return r}var r=function(t){this.keyCache={},t&&this.replace(t)};r.prototype.replace=function(t){this._layerConfigs={},this._layers={},this.update(t,[])},r.prototype.update=function(e,r){for(var i=this,o=0,a=e;o<a.length;o+=1){var s=a[o];this._layerConfigs[s.id]=s;var l=this._layers[s.id]=t.createStyleLayer(s);l._featureFilter=t.featureFilter(l.filter),this.keyCache[s.id]&&delete this.keyCache[s.id]}for(var u=0,c=r;u<c.length;u+=1){var h=c[u];delete this.keyCache[h],delete this._layerConfigs[h],delete this._layers[h]}this.familiesBySource={};for(var p=0,f=function(t,e){for(var r={},i=0;i<t.length;i++){var o=e&&e[t[i].id]||n(t[i]);e&&(e[t[i].id]=o);var a=r[o];a||(a=r[o]=[]),a.push(t[i])}var s=[];for(var l in r)s.push(r[l]);return s}(t.values(this._layerConfigs),this.keyCache);p<f.length;p+=1){var d=f[p].map((function(t){return i._layers[t.id]})),m=d[0];if("none"!==m.visibility){var g=m.source||"",y=this.familiesBySource[g];y||(y=this.familiesBySource[g]={});var v=m.sourceLayer||"_geojsonTileLayer",_=y[v];_||(_=y[v]=[]),_.push(d)}}};var i=function(e){var n={},r=[];for(var i in e){var o=e[i],a=n[i]={};for(var s in o){var l=o[+s];if(l&&0!==l.bitmap.width&&0!==l.bitmap.height){var u={x:0,y:0,w:l.bitmap.width+2,h:l.bitmap.height+2};r.push(u),a[s]={rect:u,metrics:l.metrics}}}}var c=t.potpack(r),h=new t.AlphaImage({width:c.w||1,height:c.h||1});for(var p in e){var f=e[p];for(var d in f){var m=f[+d];if(m&&0!==m.bitmap.width&&0!==m.bitmap.height){var g=n[p][d].rect;t.AlphaImage.copy(m.bitmap,h,{x:0,y:0},{x:g.x+1,y:g.y+1},m.bitmap)}}}this.image=h,this.positions=n};t.register("GlyphAtlas",i);var o=function(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId};function a(e,n,r){for(var i=new t.EvaluationParameters(n),o=0,a=e;o<a.length;o+=1)a[o].recalculate(i,r)}function s(e,n){var r=t.getArrayBuffer(e.request,(function(e,r,i,o){e?n(e):r&&n(null,{vectorTile:new t.vectorTile.VectorTile(new t.pbf(r)),rawData:r,cacheControl:i,expires:o})}));return function(){r.cancel(),n()}}o.prototype.parse=function(e,n,r,o,s){var l=this;this.status="parsing",this.data=e,this.collisionBoxArray=new t.CollisionBoxArray;var u=new t.DictionaryCoder(Object.keys(e.layers).sort()),c=new t.FeatureIndex(this.tileID,this.promoteId);c.bucketLayerIDs=[];var h,p,f,d,m={},g={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:r},y=n.familiesBySource[this.source];for(var v in y){var _=e.layers[v];if(_){1===_.version&&t.warnOnce('Vector tile source "'+this.source+'" layer "'+v+'" does not use vector tile spec v2 and therefore may have some rendering errors.');for(var x=u.encode(v),b=[],w=0;w<_.length;w++){var E=_.feature(w),S=c.getId(E,v);b.push({feature:E,id:S,index:w,sourceLayerIndex:x})}for(var M=0,T=y[v];M<T.length;M+=1){var C=T[M],I=C[0];I.minzoom&&this.zoom<Math.floor(I.minzoom)||I.maxzoom&&this.zoom>=I.maxzoom||"none"!==I.visibility&&(a(C,this.zoom,r),(m[I.id]=I.createBucket({index:c.bucketLayerIDs.length,layers:C,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source})).populate(b,g,this.tileID.canonical),c.bucketLayerIDs.push(C.map((function(t){return t.id}))))}}}var A=t.mapObject(g.glyphDependencies,(function(t){return Object.keys(t).map(Number)}));Object.keys(A).length?o.send("getGlyphs",{uid:this.uid,stacks:A},(function(t,e){h||(h=t,p=e,R.call(l))})):p={};var L=Object.keys(g.iconDependencies);L.length?o.send("getImages",{icons:L,source:this.source,tileID:this.tileID,type:"icons"},(function(t,e){h||(h=t,f=e,R.call(l))})):f={};var P=Object.keys(g.patternDependencies);function R(){if(h)return s(h);if(p&&f&&d){var e=new i(p),n=new t.ImageAtlas(f,d);for(var o in m){var l=m[o];l instanceof t.SymbolBucket?(a(l.layers,this.zoom,r),t.performSymbolLayout(l,p,e.positions,f,n.iconPositions,this.showCollisionBoxes,this.tileID.canonical)):l.hasPattern&&(l instanceof t.LineBucket||l instanceof t.FillBucket||l instanceof t.FillExtrusionBucket)&&(a(l.layers,this.zoom,r),l.addFeatures(g,this.tileID.canonical,n.patternPositions))}this.status="done",s(null,{buckets:t.values(m).filter((function(t){return!t.isEmpty()})),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:n,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"patterns"},(function(t,e){h||(h=t,d=e,R.call(l))})):d={},R.call(this)};var l=function(t,e,n,r){this.actor=t,this.layerIndex=e,this.availableImages=n,this.loadVectorData=r||s,this.loading={},this.loaded={}};l.prototype.loadTile=function(e,n){var r=this,i=e.uid;this.loading||(this.loading={});var a=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request),s=this.loading[i]=new o(e);s.abort=this.loadVectorData(e,(function(e,o){if(delete r.loading[i],e||!o)return s.status="done",r.loaded[i]=s,n(e);var l=o.rawData,u={};o.expires&&(u.expires=o.expires),o.cacheControl&&(u.cacheControl=o.cacheControl);var c={};if(a){var h=a.finish();h&&(c.resourceTiming=JSON.parse(JSON.stringify(h)))}s.vectorTile=o.vectorTile,s.parse(o.vectorTile,r.layerIndex,r.availableImages,r.actor,(function(e,r){if(e||!r)return n(e);n(null,t.extend({rawTileData:l.slice(0)},r,u,c))})),r.loaded=r.loaded||{},r.loaded[i]=s}))},l.prototype.reloadTile=function(t,e){var n=this,r=this.loaded,i=t.uid,o=this;if(r&&r[i]){var a=r[i];a.showCollisionBoxes=t.showCollisionBoxes;var s=function(t,r){var i=a.reloadCallback;i&&(delete a.reloadCallback,a.parse(a.vectorTile,o.layerIndex,n.availableImages,o.actor,i)),e(t,r)};"parsing"===a.status?a.reloadCallback=s:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}},l.prototype.abortTile=function(t,e){var n=this.loading,r=t.uid;n&&n[r]&&n[r].abort&&(n[r].abort(),delete n[r]),e()},l.prototype.removeTile=function(t,e){var n=this.loaded,r=t.uid;n&&n[r]&&delete n[r],e()};var u=t.window.ImageBitmap,c=function(){this.loaded={}};function h(t,e){if(0!==t.length){p(t[0],e);for(var n=1;n<t.length;n++)p(t[n],!e)}}function p(t,e){for(var n=0,r=0,i=t.length,o=i-1;r<i;o=r++)n+=(t[r][0]-t[o][0])*(t[o][1]+t[r][1]);n>=0!=!!e&&t.reverse()}c.prototype.loadTile=function(e,n){var r=e.uid,i=e.encoding,o=e.rawImageData,a=u&&o instanceof u?this.getImageData(o):o,s=new t.DEMData(r,a,i);this.loaded=this.loaded||{},this.loaded[r]=s,n(null,s)},c.prototype.getImageData=function(e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);var n=this.offscreenCanvasContext.getImageData(-1,-1,e.width+2,e.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:n.width,height:n.height},n.data)},c.prototype.removeTile=function(t){var e=this.loaded,n=t.uid;e&&e[n]&&delete e[n]};var f=t.vectorTile.VectorTileFeature.prototype.toGeoJSON,d=function(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};d.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],n=0,r=this._feature.geometry;n<r.length;n+=1){var i=r[n];e.push([new t.Point$1(i[0],i[1])])}return e}for(var o=[],a=0,s=this._feature.geometry;a<s.length;a+=1){for(var l=[],u=0,c=s[a];u<c.length;u+=1){var h=c[u];l.push(new t.Point$1(h[0],h[1]))}o.push(l)}return o},d.prototype.toGeoJSON=function(t,e,n){return f.call(this,t,e,n)};var m=function(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e};m.prototype.feature=function(t){return new d(this._features[t])};var g=t.vectorTile.VectorTileFeature,y=v;function v(t,e){this.options=e||{},this.features=t,this.length=t.length}function _(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}v.prototype.feature=function(t){return new _(this.features[t],this.options.extent)},_.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var n=0;n<e.length;n++){for(var r=e[n],i=[],o=0;o<r.length;o++)i.push(new t.Point$1(r[o][0],r[o][1]));this.geometry.push(i)}return this.geometry},_.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,n=-1/0,r=1/0,i=-1/0,o=0;o<t.length;o++)for(var a=t[o],s=0;s<a.length;s++){var l=a[s];e=Math.min(e,l.x),n=Math.max(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.y)}return[e,r,n,i]},_.prototype.toGeoJSON=g.prototype.toGeoJSON;var x=w,b=y;function w(e){var n=new t.pbf;return function(t,e){for(var n in t.layers)e.writeMessage(3,E,t.layers[n])}(e,n),n.finish()}function E(t,e){var n;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(n=0;n<t.length;n++)r.feature=t.feature(n),e.writeMessage(2,S,r);var i=r.keys;for(n=0;n<i.length;n++)e.writeStringField(3,i[n]);var o=r.values;for(n=0;n<o.length;n++)e.writeMessage(4,A,o[n])}function S(t,e){var n=t.feature;void 0!==n.id&&e.writeVarintField(1,n.id),e.writeMessage(2,M,t),e.writeVarintField(3,n.type),e.writeMessage(4,I,n)}function M(t,e){var n=t.feature,r=t.keys,i=t.values,o=t.keycache,a=t.valuecache;for(var s in n.properties){var l=o[s];void 0===l&&(r.push(s),o[s]=l=r.length-1),e.writeVarint(l);var u=n.properties[s],c=typeof u;"string"!==c&&"boolean"!==c&&"number"!==c&&(u=JSON.stringify(u));var h=c+":"+u,p=a[h];void 0===p&&(i.push(u),a[h]=p=i.length-1),e.writeVarint(p)}}function T(t,e){return(e<<3)+(7&t)}function C(t){return t<<1^t>>31}function I(t,e){for(var n=t.loadGeometry(),r=t.type,i=0,o=0,a=n.length,s=0;s<a;s++){var l=n[s],u=1;1===r&&(u=l.length),e.writeVarint(T(1,u));for(var c=3===r?l.length-1:l.length,h=0;h<c;h++){1===h&&1!==r&&e.writeVarint(T(2,c-1));var p=l[h].x-i,f=l[h].y-o;e.writeVarint(C(p)),e.writeVarint(C(f)),i+=p,o+=f}3===r&&e.writeVarint(T(7,1))}}function A(t,e){var n=typeof t;"string"===n?e.writeStringField(1,t):"boolean"===n?e.writeBooleanField(7,t):"number"===n&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}function L(t,e,n,r){P(t,n,r),P(e,2*n,2*r),P(e,2*n+1,2*r+1)}function P(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function R(t,e,n,r){var i=t-n,o=e-r;return i*i+o*o}x.fromVectorTileJs=w,x.fromGeojsonVt=function(t,e){e=e||{};var n={};for(var r in t)n[r]=new y(t[r].features,e),n[r].name=r,n[r].version=e.version,n[r].extent=e.extent;return w({layers:n})},x.GeoJSONWrapper=b;var D=function(t){return t[0]},N=function(t){return t[1]},O=function(t,e,n,r,i){void 0===e&&(e=D),void 0===n&&(n=N),void 0===r&&(r=64),void 0===i&&(i=Float64Array),this.nodeSize=r,this.points=t;for(var o=t.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(t.length),s=this.coords=new i(2*t.length),l=0;l<t.length;l++)a[l]=l,s[2*l]=e(t[l]),s[2*l+1]=n(t[l]);!function t(e,n,r,i,o,a){if(!(o-i<=r)){var s=i+o>>1;!function t(e,n,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);t(e,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}var p=n[2*r+a],f=i,d=o;for(L(e,n,i,r),n[2*o+a]>p&&L(e,n,i,o);f<d;){for(L(e,n,f,d),f++,d--;n[2*f+a]<p;)f++;for(;n[2*d+a]>p;)d--}n[2*i+a]===p?L(e,n,i,d):L(e,n,++d,o),d<=r&&(i=d+1),r<=d&&(o=d-1)}}(e,n,s,i,o,a%2),t(e,n,r,i,s-1,a+1),t(e,n,r,s+1,o,a+1)}}(a,s,r,0,a.length-1,0)};O.prototype.range=function(t,e,n,r){return function(t,e,n,r,i,o,a){for(var s,l,u=[0,t.length-1,0],c=[];u.length;){var h=u.pop(),p=u.pop(),f=u.pop();if(p-f<=a)for(var d=f;d<=p;d++)l=e[2*d+1],(s=e[2*d])>=n&&s<=i&&l>=r&&l<=o&&c.push(t[d]);else{var m=Math.floor((f+p)/2);l=e[2*m+1],(s=e[2*m])>=n&&s<=i&&l>=r&&l<=o&&c.push(t[m]);var g=(h+1)%2;(0===h?n<=s:r<=l)&&(u.push(f),u.push(m-1),u.push(g)),(0===h?i>=s:o>=l)&&(u.push(m+1),u.push(p),u.push(g))}}return c}(this.ids,this.coords,t,e,n,r,this.nodeSize)},O.prototype.within=function(t,e,n){return function(t,e,n,r,i,o){for(var a=[0,t.length-1,0],s=[],l=i*i;a.length;){var u=a.pop(),c=a.pop(),h=a.pop();if(c-h<=o)for(var p=h;p<=c;p++)R(e[2*p],e[2*p+1],n,r)<=l&&s.push(t[p]);else{var f=Math.floor((h+c)/2),d=e[2*f],m=e[2*f+1];R(d,m,n,r)<=l&&s.push(t[f]);var g=(u+1)%2;(0===u?n-i<=d:r-i<=m)&&(a.push(h),a.push(f-1),a.push(g)),(0===u?n+i>=d:r+i>=m)&&(a.push(f+1),a.push(c),a.push(g))}}return s}(this.ids,this.coords,t,e,n,this.nodeSize)};var k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:function(t){return t}},z=function(t){this.options=H(Object.create(k),t),this.trees=new Array(this.options.maxZoom+1)};function F(t,e,n,r,i){return{x:t,y:e,zoom:1/0,id:n,parentId:-1,numPoints:r,properties:i}}function B(t,e){var n=t.geometry.coordinates,r=n[1];return{x:G(n[0]),y:j(r),zoom:1/0,index:e,parentId:-1}}function U(t){return{type:"Feature",id:t.id,properties:V(t),geometry:{type:"Point",coordinates:[(r=t.x,360*(r-.5)),(e=t.y,n=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(n))/Math.PI-90)]}};var e,n,r}function V(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return H(H({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function G(t){return t/360+.5}function j(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function H(t,e){for(var n in e)t[n]=e[n];return t}function q(t){return t.x}function W(t){return t.y}function X(t,e,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((t-n)*a+(e-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=t-n)*a+(s=e-r)*s}function Z(t,e,n,r){var i={id:void 0===t?null:t,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Y(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r<e.length;r++)Y(t,e[r]);else if("MultiPolygon"===n)for(r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++)Y(t,e[r][i])}(i),i}function Y(t,e){for(var n=0;n<e.length;n+=3)t.minX=Math.min(t.minX,e[n]),t.minY=Math.min(t.minY,e[n+1]),t.maxX=Math.max(t.maxX,e[n]),t.maxY=Math.max(t.maxY,e[n+1])}function J(t,e,n,r){if(e.geometry){var i=e.geometry.coordinates,o=e.geometry.type,a=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),s=[],l=e.id;if(n.promoteId?l=e.properties[n.promoteId]:n.generateId&&(l=r||0),"Point"===o)K(i,s);else if("MultiPoint"===o)for(var u=0;u<i.length;u++)K(i[u],s);else if("LineString"===o)Q(i,s,a,!1);else if("MultiLineString"===o){if(n.lineMetrics){for(u=0;u<i.length;u++)Q(i[u],s=[],a,!1),t.push(Z(l,"LineString",s,e.properties));return}$(i,s,a,!1)}else if("Polygon"===o)$(i,s,a,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(u=0;u<e.geometry.geometries.length;u++)J(t,{id:l,geometry:e.geometry.geometries[u],properties:e.properties},n,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(u=0;u<i.length;u++){var c=[];$(i[u],c,a,!0),s.push(c)}}t.push(Z(l,o,s,e.properties))}}function K(t,e){e.push(tt(t[0])),e.push(et(t[1])),e.push(0)}function Q(t,e,n,r){for(var i,o,a=0,s=0;s<t.length;s++){var l=tt(t[s][0]),u=et(t[s][1]);e.push(l),e.push(u),e.push(0),s>0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=e.length-3;e[2]=1,function t(e,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=e[n],c=e[n+1],h=e[r],p=e[r+1],f=n+3;f<r;f+=3){var d=X(e[f],e[f+1],u,c,h,p);if(d>a)o=f,a=d;else if(d===a){var m=Math.abs(f-s);m<l&&(o=f,l=m)}}a>i&&(o-n>3&&t(e,n,o,i),e[o+2]=a,r-o>3&&t(e,o,r,i))}(e,0,c,n),e[c+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function $(t,e,n,r){for(var i=0;i<t.length;i++){var o=[];Q(t[i],o,n,r),e.push(o)}}function tt(t){return t/360+.5}function et(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function nt(t,e,n,r,i,o,a,s){if(r/=e,o>=(n/=e)&&a<r)return t;if(a<n||o>=r)return null;for(var l=[],u=0;u<t.length;u++){var c=t[u],h=c.geometry,p=c.type,f=0===i?c.minX:c.minY,d=0===i?c.maxX:c.maxY;if(f>=n&&d<r)l.push(c);else if(!(d<n||f>=r)){var m=[];if("Point"===p||"MultiPoint"===p)rt(h,m,n,r,i);else if("LineString"===p)it(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===p)at(h,m,n,r,i,!1);else if("Polygon"===p)at(h,m,n,r,i,!0);else if("MultiPolygon"===p)for(var g=0;g<h.length;g++){var y=[];at(h[g],y,n,r,i,!0),y.length&&m.push(y)}if(m.length){if(s.lineMetrics&&"LineString"===p){for(g=0;g<m.length;g++)l.push(Z(c.id,p,m[g],c.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===m.length?(p="LineString",m=m[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===m.length?"Point":"MultiPoint"),l.push(Z(c.id,p,m,c.tags))}}}return l.length?l:null}function rt(t,e,n,r,i){for(var o=0;o<t.length;o+=3){var a=t[o+i];a>=n&&a<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function it(t,e,n,r,i,o,a){for(var s,l,u=ot(t),c=0===i?lt:ut,h=t.start,p=0;p<t.length-3;p+=3){var f=t[p],d=t[p+1],m=t[p+2],g=t[p+3],y=t[p+4],v=0===i?f:d,_=0===i?g:y,x=!1;a&&(s=Math.sqrt(Math.pow(f-g,2)+Math.pow(d-y,2))),v<n?_>n&&(l=c(u,f,d,g,y,n),a&&(u.start=h+s*l)):v>r?_<r&&(l=c(u,f,d,g,y,r),a&&(u.start=h+s*l)):st(u,f,d,m),_<n&&v>=n&&(l=c(u,f,d,g,y,n),x=!0),_>r&&v<=r&&(l=c(u,f,d,g,y,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),e.push(u),u=ot(t)),a&&(h+=s)}var b=t.length-3;f=t[b],d=t[b+1],m=t[b+2],(v=0===i?f:d)>=n&&v<=r&&st(u,f,d,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&st(u,u[0],u[1],u[2]),u.length&&e.push(u)}function ot(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,n,r,i,o){for(var a=0;a<t.length;a++)it(t[a],e,n,r,i,o,!1)}function st(t,e,n,r){t.push(e),t.push(n),t.push(r)}function lt(t,e,n,r,i,o){var a=(o-e)/(r-e);return t.push(o),t.push(n+(i-n)*a),t.push(1),a}function ut(t,e,n,r,i,o){var a=(o-n)/(i-n);return t.push(e+(r-e)*a),t.push(o),t.push(1),a}function ct(t,e){for(var n=[],r=0;r<t.length;r++){var i,o=t[r],a=o.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)i=ht(o.geometry,e);else if("MultiLineString"===a||"Polygon"===a){i=[];for(var s=0;s<o.geometry.length;s++)i.push(ht(o.geometry[s],e))}else if("MultiPolygon"===a)for(i=[],s=0;s<o.geometry.length;s++){for(var l=[],u=0;u<o.geometry[s].length;u++)l.push(ht(o.geometry[s][u],e));i.push(l)}n.push(Z(o.id,a,i,o.tags))}return n}function ht(t,e){var n=[];n.size=t.size,void 0!==t.start&&(n.start=t.start,n.end=t.end);for(var r=0;r<t.length;r+=3)n.push(t[r]+e,t[r+1],t[r+2]);return n}function pt(t,e){if(t.transformed)return t;var n,r,i,o=1<<t.z,a=t.x,s=t.y;for(n=0;n<t.features.length;n++){var l=t.features[n],u=l.geometry,c=l.type;if(l.geometry=[],1===c)for(r=0;r<u.length;r+=2)l.geometry.push(ft(u[r],u[r+1],e,o,a,s));else for(r=0;r<u.length;r++){var h=[];for(i=0;i<u[r].length;i+=2)h.push(ft(u[r][i],u[r][i+1],e,o,a,s));l.geometry.push(h)}}return t.transformed=!0,t}function ft(t,e,n,r,i,o){return[Math.round(n*(t*r-i)),Math.round(n*(e*r-o))]}function dt(t,e,n,r,i){for(var o=e===i.maxZoom?0:i.tolerance/((1<<e)*i.extent),a={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:n,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},s=0;s<t.length;s++){a.numFeatures++,mt(a,t[s],o,i);var l=t[s].minX,u=t[s].minY,c=t[s].maxX,h=t[s].maxY;l<a.minX&&(a.minX=l),u<a.minY&&(a.minY=u),c>a.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function mt(t,e,n,r){var i=e.geometry,o=e.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s<i.length;s+=3)a.push(i[s]),a.push(i[s+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)gt(a,i,t,n,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(s=0;s<i.length;s++)gt(a,i[s],t,n,"Polygon"===o,0===s);else if("MultiPolygon"===o)for(var l=0;l<i.length;l++){var u=i[l];for(s=0;s<u.length;s++)gt(a,u[s],t,n,!0,0===s)}if(a.length){var c=e.tags||null;if("LineString"===o&&r.lineMetrics){for(var h in c={},e.tags)c[h]=e.tags[h];c.mapbox_clip_start=i.start/i.size,c.mapbox_clip_end=i.end/i.size}var p={geometry:a,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:c};null!==e.id&&(p.id=e.id),t.features.push(p)}}function gt(t,e,n,r,i,o){var a=r*r;if(r>0&&e.size<(i?a:r))n.numPoints+=e.length/3;else{for(var s=[],l=0;l<e.length;l+=3)(0===r||e[l+2]>a)&&(n.numSimplified++,s.push(e[l]),s.push(e[l+1])),n.numPoints++;i&&function(t,e){for(var n=0,r=0,i=t.length,o=i-2;r<i;o=r,r+=2)n+=(t[r]-t[o])*(t[r+1]+t[o+1]);if(n>0===e)for(r=0,i=t.length;r<i/2;r+=2){var a=t[r],s=t[r+1];t[r]=t[i-2-r],t[r+1]=t[i-1-r],t[i-2-r]=a,t[i-1-r]=s}}(s,o),t.push(s)}}function yt(t,e){var n=(e=this.options=function(t,e){for(var n in e)t[n]=e[n];return t}(Object.create(this.options),e)).debug;if(n&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)J(n,t.features[r],e,r);else J(n,"Feature"===t.type?t:{geometry:t},e);return n}(t,e);this.tiles={},this.tileCoords=[],n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(r=function(t,e){var n=e.buffer/e.extent,r=t,i=nt(t,1,-1-n,n,0,-1,2,e),o=nt(t,1,1-n,2+n,0,-1,2,e);return(i||o)&&(r=nt(t,1,-n,1+n,0,-1,2,e)||[],i&&(r=ct(i,1).concat(r)),o&&(r=r.concat(ct(o,-1)))),r}(r,e)).length&&this.splitTile(r,0,0,0),n&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function vt(t,e,n){return 32*((1<<t)*n+e)+t}function _t(t,e){var n=t.tileID.canonical;if(!this._geoJSONIndex)return e(null,null);var r=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!r)return e(null,null);var i=new m(r.features),o=x(i);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),e(null,{vectorTile:i,rawData:o.buffer})}z.prototype.load=function(t){var e=this.options,n=e.log,r=e.minZoom,i=e.maxZoom,o=e.nodeSize;n&&console.time("total time");var a="prepare "+t.length+" points";n&&console.time(a),this.points=t;for(var s=[],l=0;l<t.length;l++)t[l].geometry&&s.push(B(t[l],l));this.trees[i+1]=new O(s,q,W,o,Float32Array),n&&console.timeEnd(a);for(var u=i;u>=r;u--){var c=+Date.now();s=this._cluster(s,u),this.trees[u]=new O(s,q,W,o,Float32Array),n&&console.log("z%d: %d clusters in %dms",u,s.length,+Date.now()-c)}return n&&console.timeEnd("total time"),this},z.prototype.getClusters=function(t,e){var n=((t[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,t[1])),i=180===t[2]?180:((t[2]+180)%360+360)%360-180,o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,i=180;else if(n>i){var a=this.getClusters([n,r,180,o],e),s=this.getClusters([-180,r,i,o],e);return a.concat(s)}for(var l=this.trees[this._limitZoom(e)],u=[],c=0,h=l.range(G(n),j(o),G(i),j(r));c<h.length;c+=1){var p=l.points[h[c]];u.push(p.numPoints?U(p):this.points[p.index])}return u},z.prototype.getChildren=function(t){var e=this._getOriginId(t),n=this._getOriginZoom(t),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);var o=i.points[e];if(!o)throw new Error(r);for(var a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=[],l=0,u=i.within(o.x,o.y,a);l<u.length;l+=1){var c=i.points[u[l]];c.parentId===t&&s.push(c.numPoints?U(c):this.points[c.index])}if(0===s.length)throw new Error(r);return s},z.prototype.getLeaves=function(t,e,n){var r=[];return this._appendLeaves(r,t,e=e||10,n=n||0,0),r},z.prototype.getTile=function(t,e,n){var r=this.trees[this._limitZoom(t)],i=Math.pow(2,t),o=this.options,a=o.radius/o.extent,s=(n-a)/i,l=(n+1+a)/i,u={features:[]};return this._addTileFeatures(r.range((e-a)/i,s,(e+1+a)/i,l),r.points,e,n,i,u),0===e&&this._addTileFeatures(r.range(1-a/i,s,1,l),r.points,i,n,i,u),e===i-1&&this._addTileFeatures(r.range(0,s,a/i,l),r.points,-1,n,i,u),u.features.length?u:null},z.prototype.getClusterExpansionZoom=function(t){for(var e=this._getOriginZoom(t)-1;e<=this.options.maxZoom;){var n=this.getChildren(t);if(e++,1!==n.length)break;t=n[0].properties.cluster_id}return e},z.prototype._appendLeaves=function(t,e,n,r,i){for(var o=0,a=this.getChildren(e);o<a.length;o+=1){var s=a[o],l=s.properties;if(l&&l.cluster?i+l.point_count<=r?i+=l.point_count:i=this._appendLeaves(t,l.cluster_id,n,r,i):i<r?i++:t.push(s),t.length===n)break}return i},z.prototype._addTileFeatures=function(t,e,n,r,i,o){for(var a=0,s=t;a<s.length;a+=1){var l=e[s[a]],u=l.numPoints,c={type:1,geometry:[[Math.round(this.options.extent*(l.x*i-n)),Math.round(this.options.extent*(l.y*i-r))]],tags:u?V(l):this.points[l.index].properties},h=void 0;u?h=l.id:this.options.generateId?h=l.index:this.points[l.index].id&&(h=this.points[l.index].id),void 0!==h&&(c.id=h),o.features.push(c)}},z.prototype._limitZoom=function(t){return Math.max(this.options.minZoom,Math.min(+t,this.options.maxZoom+1))},z.prototype._cluster=function(t,e){for(var n=[],r=this.options,i=r.reduce,o=r.minPoints,a=r.radius/(r.extent*Math.pow(2,e)),s=0;s<t.length;s++){var l=t[s];if(!(l.zoom<=e)){l.zoom=e;for(var u=this.trees[e+1],c=u.within(l.x,l.y,a),h=l.numPoints||1,p=h,f=0,d=c;f<d.length;f+=1){var m=u.points[d[f]];m.zoom>e&&(p+=m.numPoints||1)}if(p>=o){for(var g=l.x*h,y=l.y*h,v=i&&h>1?this._map(l,!0):null,_=(s<<5)+(e+1)+this.points.length,x=0,b=c;x<b.length;x+=1){var w=u.points[b[x]];if(!(w.zoom<=e)){w.zoom=e;var E=w.numPoints||1;g+=w.x*E,y+=w.y*E,w.parentId=_,i&&(v||(v=this._map(l,!0)),i(v,this._map(w)))}}l.parentId=_,n.push(F(g/p,y/p,_,p,v))}else if(n.push(l),p>1)for(var S=0,M=c;S<M.length;S+=1){var T=u.points[M[S]];T.zoom<=e||(T.zoom=e,n.push(T))}}}return n},z.prototype._getOriginId=function(t){return t-this.points.length>>5},z.prototype._getOriginZoom=function(t){return(t-this.points.length)%32},z.prototype._map=function(t,e){if(t.numPoints)return e?H({},t.properties):t.properties;var n=this.points[t.index].properties,r=this.options.map(n);return e&&r===n?H({},r):r},yt.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},yt.prototype.splitTile=function(t,e,n,r,i,o,a){for(var s=[t,e,n,r],l=this.options,u=l.debug;s.length;){r=s.pop(),n=s.pop(),e=s.pop(),t=s.pop();var c=1<<e,h=vt(e,n,r),p=this.tiles[h];if(!p&&(u>1&&console.time("creation"),p=this.tiles[h]=dt(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+e;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<<i-e;if(n!==Math.floor(o/d)||r!==Math.floor(a/d))continue}else if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==t.length){u>1&&console.time("clipping");var m,g,y,v,_,x,b=.5*l.buffer/l.extent,w=.5-b,E=.5+b,S=1+b;m=g=y=v=null,_=nt(t,c,n-b,n+E,0,p.minX,p.maxX,l),x=nt(t,c,n+w,n+S,0,p.minX,p.maxX,l),t=null,_&&(m=nt(_,c,r-b,r+E,1,p.minY,p.maxY,l),g=nt(_,c,r+w,r+S,1,p.minY,p.maxY,l),_=null),x&&(y=nt(x,c,r-b,r+E,1,p.minY,p.maxY,l),v=nt(x,c,r+w,r+S,1,p.minY,p.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],e+1,2*n,2*r),s.push(g||[],e+1,2*n,2*r+1),s.push(y||[],e+1,2*n+1,2*r),s.push(v||[],e+1,2*n+1,2*r+1)}}},yt.prototype.getTile=function(t,e,n){var r=this.options,i=r.extent,o=r.debug;if(t<0||t>24)return null;var a=1<<t,s=vt(t,e=(e%a+a)%a,n);if(this.tiles[s])return pt(this.tiles[s],i);o>1&&console.log("drilling down to z%d-%d-%d",t,e,n);for(var l,u=t,c=e,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[vt(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,t,e,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?pt(this.tiles[s],i):null):null};var xt=function(e){function n(t,n,r,i){e.call(this,t,n,r,_t),i&&(this.loadGeoJSON=i)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},n.prototype._loadData=function(){var e=this;if(this._pendingCallback&&this._pendingLoadDataParams){var n=this._pendingCallback,r=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams;var i=!!(r&&r.request&&r.request.collectResourceTiming)&&new t.RequestPerformance(r.request);this.loadGeoJSON(r,(function(o,a){if(o||!a)return n(o);if("object"!=typeof a)return n(new Error("Input data given to '"+r.source+"' is not a valid GeoJSON object."));!function t(e,n){var r,i=e&&e.type;if("FeatureCollection"===i)for(r=0;r<e.features.length;r++)t(e.features[r],n);else if("GeometryCollection"===i)for(r=0;r<e.geometries.length;r++)t(e.geometries[r],n);else if("Feature"===i)t(e.geometry,n);else if("Polygon"===i)h(e.coordinates,n);else if("MultiPolygon"===i)for(r=0;r<e.coordinates.length;r++)h(e.coordinates[r],n);return e}(a,!0);try{if(r.filter){var s=t.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===s.result)throw new Error(s.value.map((function(t){return t.key+": "+t.message})).join(", "));var l=a.features.filter((function(t){return s.value.evaluate({zoom:0},t)}));a={type:"FeatureCollection",features:l}}e._geoJSONIndex=r.cluster?new z(function(e){var n=e.superclusterOptions,r=e.clusterProperties;if(!r||!n)return n;for(var i={},o={},a={accumulated:null,zoom:0},s={properties:null},l=Object.keys(r),u=0,c=l;u<c.length;u+=1){var h=c[u],p=r[h],f=p[0],d=t.createExpression(p[1]),m=t.createExpression("string"==typeof f?[f,["accumulated"],["get",h]]:f);i[h]=d.value,o[h]=m.value}return n.map=function(t){s.properties=t;for(var e={},n=0,r=l;n<r.length;n+=1){var o=r[n];e[o]=i[o].evaluate(a,s)}return e},n.reduce=function(t,e){s.properties=e;for(var n=0,r=l;n<r.length;n+=1){var i=r[n];a.accumulated=t[i],t[i]=o[i].evaluate(a,s)}},n}(r)).load(a.features):function(t,e){return new yt(t,e)}(a,r.geojsonVtOptions)}catch(o){return n(o)}e.loaded={};var u={};if(i){var c=i.finish();c&&(u.resourceTiming={},u.resourceTiming[r.source]=JSON.parse(JSON.stringify(c)))}n(null,u)}))}},n.prototype.coalesce=function(){"Coalescing"===this._state?this._state="Idle":"NeedsLoadData"===this._state&&(this._state="Coalescing",this._loadData())},n.prototype.reloadTile=function(t,n){var r=this.loaded;return r&&r[t.uid]?e.prototype.reloadTile.call(this,t,n):this.loadTile(t,n)},n.prototype.loadGeoJSON=function(e,n){if(e.request)t.getJSON(e.request,n);else{if("string"!=typeof e.data)return n(new Error("Input data given to '"+e.source+"' is not a valid GeoJSON object."));try{return n(null,JSON.parse(e.data))}catch(t){return n(new Error("Input data given to '"+e.source+"' is not a valid GeoJSON object."))}}},n.prototype.removeSource=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()},n.prototype.getClusterExpansionZoom=function(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}},n.prototype.getClusterChildren=function(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}},n.prototype.getClusterLeaves=function(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}},n}(l),bt=function(e){var n=this;this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:l,geojson:xt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=function(t,e){if(n.workerSourceTypes[t])throw new Error('Worker source with name "'+t+'" already registered.');n.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=function(e){if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}};return bt.prototype.setReferrer=function(t,e){this.referrer=e},bt.prototype.setImages=function(t,e,n){for(var r in this.availableImages[t]=e,this.workerSources[t]){var i=this.workerSources[t][r];for(var o in i)i[o].availableImages=e}n()},bt.prototype.setLayers=function(t,e,n){this.getLayerIndex(t).replace(e),n()},bt.prototype.updateLayers=function(t,e,n){this.getLayerIndex(t).update(e.layers,e.removedIds),n()},bt.prototype.loadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).loadTile(e,n)},bt.prototype.loadDEMTile=function(t,e,n){this.getDEMWorkerSource(t,e.source).loadTile(e,n)},bt.prototype.reloadTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).reloadTile(e,n)},bt.prototype.abortTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).abortTile(e,n)},bt.prototype.removeTile=function(t,e,n){this.getWorkerSource(t,e.type,e.source).removeTile(e,n)},bt.prototype.removeDEMTile=function(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)},bt.prototype.removeSource=function(t,e,n){if(this.workerSources[t]&&this.workerSources[t][e.type]&&this.workerSources[t][e.type][e.source]){var r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,n):n()}},bt.prototype.loadWorkerSource=function(t,e,n){try{this.self.importScripts(e.url),n()}catch(t){n(t.toString())}},bt.prototype.syncRTLPluginState=function(e,n,r){try{t.plugin.setState(n);var i=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=i){this.self.importScripts(i);var o=t.plugin.isParsed();r(o?void 0:new Error("RTL Text Plugin failed to import scripts from "+i),o)}}catch(t){r(t.toString())}},bt.prototype.getAvailableImages=function(t){var e=this.availableImages[t];return e||(e=[]),e},bt.prototype.getLayerIndex=function(t){var e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e},bt.prototype.getWorkerSource=function(t,e,n){var r=this;return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][n]||(this.workerSources[t][e][n]=new this.workerSourceTypes[e]({send:function(e,n,i){r.actor.send(e,n,i,t)}},this.getLayerIndex(t),this.getAvailableImages(t))),this.workerSources[t][e][n]},bt.prototype.getDEMWorkerSource=function(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new c),this.demWorkerSources[t][e]},bt.prototype.enforceCacheSizeLimit=function(e,n){t.enforceCacheSizeLimit(n)},"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new bt(self)),bt}));r(0,(function(t){var e=t.createCommonjsModule((function(t){function e(t){return!n(t)}function n(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,n=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(n);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var n=e.getImageData(0,0,1,1);return n&&n.width===t.width}()?(void 0===r[n=t&&t.failIfMajorPerformanceCaveat]&&(r[n]=function(t){var n=function(t){var n=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,n.probablySupportsContext?n.probablySupportsContext("webgl",r)||n.probablySupportsContext("experimental-webgl",r):n.supportsContext?n.supportsContext("webgl",r)||n.supportsContext("experimental-webgl",r):n.getContext("webgl",r)||n.getContext("experimental-webgl",r)}(t);if(!n)return!1;var r=n.createShader(n.VERTEX_SHADER);return!(!r||n.isContextLost())&&(n.shaderSource(r,"void main() {}"),n.compileShader(r),!0===n.getShaderParameter(r,n.COMPILE_STATUS))}(n)),r[n]?void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var n}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e,window.mapboxgl.notSupportedReason=n);var r={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0}})),n={create:function(e,n,r){var i=t.window.document.createElement(e);return void 0!==n&&(i.className=n),r&&r.appendChild(i),i},createNS:function(e,n){return t.window.document.createElementNS(e,n)}},r=t.window.document&&t.window.document.documentElement.style;function i(t){if(!r)return t[0];for(var e=0;e<t.length;e++)if(t[e]in r)return t[e];return t[0]}var o,a=i(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]);n.disableDrag=function(){r&&a&&(o=r[a],r[a]="none")},n.enableDrag=function(){r&&a&&(r[a]=o)};var s=i(["transform","WebkitTransform"]);n.setTransform=function(t,e){t.style[s]=e};var l=!1;try{var u=Object.defineProperty({},"passive",{get:function(){l=!0}});t.window.addEventListener("test",u,u),t.window.removeEventListener("test",u,u)}catch(t){l=!1}n.addEventListener=function(t,e,n,r){void 0===r&&(r={}),t.addEventListener(e,n,"passive"in r&&l?r:r.capture)},n.removeEventListener=function(t,e,n,r){void 0===r&&(r={}),t.removeEventListener(e,n,"passive"in r&&l?r:r.capture)};var c=function(e){e.preventDefault(),e.stopPropagation(),t.window.removeEventListener("click",c,!0)};function h(t){var e=t.userImage;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}n.suppressClick=function(){t.window.addEventListener("click",c,!0),t.window.setTimeout((function(){t.window.removeEventListener("click",c,!0)}),0)},n.mousePos=function(e,n){var r=e.getBoundingClientRect();return new t.Point(n.clientX-r.left-e.clientLeft,n.clientY-r.top-e.clientTop)},n.touchPos=function(e,n){for(var r=e.getBoundingClientRect(),i=[],o=0;o<n.length;o++)i.push(new t.Point(n[o].clientX-r.left-e.clientLeft,n[o].clientY-r.top-e.clientTop));return i},n.mouseButton=function(e){return void 0!==t.window.InstallTrigger&&2===e.button&&e.ctrlKey&&t.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button},n.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var p=function(e){function n(){e.call(this),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.isLoaded=function(){return this.loaded},n.prototype.setLoaded=function(t){if(this.loaded!==t&&(this.loaded=t,t)){for(var e=0,n=this.requestors;e<n.length;e+=1){var r=n[e];this._notify(r.ids,r.callback)}this.requestors=[]}},n.prototype.getImage=function(t){return this.images[t]},n.prototype.addImage=function(t,e){this._validate(t,e)&&(this.images[t]=e)},n.prototype._validate=function(e,n){var r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new t.ErrorEvent(new Error('Image "'+e+'" has invalid "stretchX" value'))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new t.ErrorEvent(new Error('Image "'+e+'" has invalid "stretchY" value'))),r=!1),this._validateContent(n.content,n)||(this.fire(new t.ErrorEvent(new Error('Image "'+e+'" has invalid "content" value'))),r=!1),r},n.prototype._validateStretch=function(t,e){if(!t)return!0;for(var n=0,r=0,i=t;r<i.length;r+=1){var o=i[r];if(o[0]<n||o[1]<o[0]||e<o[1])return!1;n=o[1]}return!0},n.prototype._validateContent=function(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))},n.prototype.updateImage=function(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0},n.prototype.removeImage=function(t){var e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()},n.prototype.listImages=function(){return Object.keys(this.images)},n.prototype.getImages=function(t,e){var n=!0;if(!this.isLoaded())for(var r=0,i=t;r<i.length;r+=1)this.images[i[r]]||(n=!1);this.isLoaded()||n?this._notify(t,e):this.requestors.push({ids:t,callback:e})},n.prototype._notify=function(e,n){for(var r={},i=0,o=e;i<o.length;i+=1){var a=o[i];this.images[a]||this.fire(new t.Event("styleimagemissing",{id:a}));var s=this.images[a];s?r[a]={data:s.data.clone(),pixelRatio:s.pixelRatio,sdf:s.sdf,version:s.version,stretchX:s.stretchX,stretchY:s.stretchY,content:s.content,hasRenderCallback:Boolean(s.userImage&&s.userImage.render)}:t.warnOnce('Image "'+a+'" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.')}n(null,r)},n.prototype.getPixelSize=function(){var t=this.atlasImage;return{width:t.width,height:t.height}},n.prototype.getPattern=function(e){var n=this.patterns[e],r=this.getImage(e);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{var i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.ImagePosition(i,r);this.patterns[e]={bin:i,position:o}}return this._updatePatternAtlas(),this.patterns[e].position},n.prototype.bind=function(e){var n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.Texture(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)},n.prototype._updatePatternAtlas=function(){var e=[];for(var n in this.patterns)e.push(this.patterns[n].bin);var r=t.potpack(e),i=r.w,o=r.h,a=this.atlasImage;for(var s in a.resize({width:i||1,height:o||1}),this.patterns){var l=this.patterns[s].bin,u=l.x+1,c=l.y+1,h=this.images[s].data,p=h.width,f=h.height;t.RGBAImage.copy(h,a,{x:0,y:0},{x:u,y:c},{width:p,height:f}),t.RGBAImage.copy(h,a,{x:0,y:f-1},{x:u,y:c-1},{width:p,height:1}),t.RGBAImage.copy(h,a,{x:0,y:0},{x:u,y:c+f},{width:p,height:1}),t.RGBAImage.copy(h,a,{x:p-1,y:0},{x:u-1,y:c},{width:1,height:f}),t.RGBAImage.copy(h,a,{x:0,y:0},{x:u+p,y:c},{width:1,height:f})}this.dirty=!0},n.prototype.beginFrame=function(){this.callbackDispatchedThisFrame={}},n.prototype.dispatchRenderCallbacks=function(t){for(var e=0,n=t;e<n.length;e+=1){var r=n[e];if(!this.callbackDispatchedThisFrame[r]){this.callbackDispatchedThisFrame[r]=!0;var i=this.images[r];h(i)&&this.updateImage(r,i)}}},n}(t.Evented),f=g,d=g,m=1e20;function g(t,e,n,r,i,o){this.fontSize=t||24,this.buffer=void 0===e?3:e,this.cutoff=r||.25,this.fontFamily=i||"sans-serif",this.fontWeight=o||"normal",this.radius=n||8;var a=this.size=this.fontSize+2*this.buffer;this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=a,this.ctx=this.canvas.getContext("2d"),this.ctx.font=this.fontWeight+" "+this.fontSize+"px "+this.fontFamily,this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.d=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Int16Array(a),this.middle=Math.round(a/2*(navigator.userAgent.indexOf("Gecko/")>=0?1.2:1))}function y(t,e,n,r,i,o,a){for(var s=0;s<e;s++){for(var l=0;l<n;l++)r[l]=t[l*e+s];for(v(r,i,o,a,n),l=0;l<n;l++)t[l*e+s]=i[l]}for(l=0;l<n;l++){for(s=0;s<e;s++)r[s]=t[l*e+s];for(v(r,i,o,a,e),s=0;s<e;s++)t[l*e+s]=Math.sqrt(i[s])}}function v(t,e,n,r,i){n[0]=0,r[0]=-m,r[1]=+m;for(var o=1,a=0;o<i;o++){for(var s=(t[o]+o*o-(t[n[a]]+n[a]*n[a]))/(2*o-2*n[a]);s<=r[a];)a--,s=(t[o]+o*o-(t[n[a]]+n[a]*n[a]))/(2*o-2*n[a]);n[++a]=o,r[a]=s,r[a+1]=+m}for(o=0,a=0;o<i;o++){for(;r[a+1]<o;)a++;e[o]=(o-n[a])*(o-n[a])+t[n[a]]}}g.prototype.draw=function(t){this.ctx.clearRect(0,0,this.size,this.size),this.ctx.fillText(t,this.buffer,this.middle);for(var e=this.ctx.getImageData(0,0,this.size,this.size),n=new Uint8ClampedArray(this.size*this.size),r=0;r<this.size*this.size;r++){var i=e.data[4*r+3]/255;this.gridOuter[r]=1===i?0:0===i?m:Math.pow(Math.max(0,.5-i),2),this.gridInner[r]=1===i?m:0===i?0:Math.pow(Math.max(0,i-.5),2)}for(y(this.gridOuter,this.size,this.size,this.f,this.d,this.v,this.z),y(this.gridInner,this.size,this.size,this.f,this.d,this.v,this.z),r=0;r<this.size*this.size;r++)n[r]=Math.max(0,Math.min(255,Math.round(255-255*((this.gridOuter[r]-this.gridInner[r])/this.radius+this.cutoff))));return n},f.default=d;var _=function(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}};_.prototype.setURL=function(t){this.url=t},_.prototype.getGlyphs=function(e,n){var r=this,i=[];for(var o in e)for(var a=0,s=e[o];a<s.length;a+=1)i.push({stack:o,id:s[a]});t.asyncAll(i,(function(t,e){var n=t.stack,i=t.id,o=r.entries[n];o||(o=r.entries[n]={glyphs:{},requests:{},ranges:{}});var a=o.glyphs[i];if(void 0===a){if(a=r._tinySDF(o,n,i))return o.glyphs[i]=a,void e(null,{stack:n,id:i,glyph:a});var s=Math.floor(i/256);if(256*s>65535)e(new Error("glyphs > 65535 not supported"));else if(o.ranges[s])e(null,{stack:n,id:i,glyph:a});else{var l=o.requests[s];l||(l=o.requests[s]=[],_.loadGlyphRange(n,s,r.url,r.requestManager,(function(t,e){if(e){for(var n in e)r._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=e[+n]);o.ranges[s]=!0}for(var i=0,a=l;i<a.length;i+=1)(0,a[i])(t,e);delete o.requests[s]}))),l.push((function(t,r){t?e(t):r&&e(null,{stack:n,id:i,glyph:r[i]||null})}))}}else e(null,{stack:n,id:i,glyph:a})}),(function(t,e){if(t)n(t);else if(e){for(var r={},i=0,o=e;i<o.length;i+=1){var a=o[i],s=a.stack,l=a.id,u=a.glyph;(r[s]||(r[s]={}))[l]=u&&{id:u.id,bitmap:u.bitmap.clone(),metrics:u.metrics}}n(null,r)}}))},_.prototype._doesCharSupportLocalGlyph=function(e){return!!this.localIdeographFontFamily&&(t.isChar["CJK Unified Ideographs"](e)||t.isChar["Hangul Syllables"](e)||t.isChar.Hiragana(e)||t.isChar.Katakana(e))},_.prototype._tinySDF=function(e,n,r){var i=this.localIdeographFontFamily;if(i&&this._doesCharSupportLocalGlyph(r)){var o=e.tinySDF;if(!o){var a="400";/bold/i.test(n)?a="900":/medium/i.test(n)?a="500":/light/i.test(n)&&(a="200"),o=e.tinySDF=new _.TinySDF(24,3,8,.25,i,a)}return{id:r,bitmap:new t.AlphaImage({width:30,height:30},o.draw(String.fromCharCode(r))),metrics:{width:24,height:24,left:0,top:-8,advance:24}}}},_.loadGlyphRange=function(e,n,r,i,o){var a=256*n,s=a+255,l=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",a+"-"+s),t.ResourceType.Glyphs);t.getArrayBuffer(l,(function(e,n){if(e)o(e);else if(n){for(var r={},i=0,a=t.parseGlyphPBF(n);i<a.length;i+=1){var s=a[i];r[s.id]=s}o(null,r)}}))},_.TinySDF=f;var x=function(){this.specification=t.styleSpec.light.position};x.prototype.possiblyEvaluate=function(e,n){return t.sphericalToCartesian(e.expression.evaluate(n))},x.prototype.interpolate=function(e,n,r){return{x:t.number(e.x,n.x,r),y:t.number(e.y,n.y,r),z:t.number(e.z,n.z,r)}};var b=new t.Properties({anchor:new t.DataConstantProperty(t.styleSpec.light.anchor),position:new x,color:new t.DataConstantProperty(t.styleSpec.light.color),intensity:new t.DataConstantProperty(t.styleSpec.light.intensity)}),w=function(e){function n(n){e.call(this),this._transitionable=new t.Transitionable(b),this.setLight(n),this._transitioning=this._transitionable.untransitioned()}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.getLight=function(){return this._transitionable.serialize()},n.prototype.setLight=function(e,n){if(void 0===n&&(n={}),!this._validate(t.validateLight,e,n))for(var r in e){var i=e[r];t.endsWith(r,"-transition")?this._transitionable.setTransition(r.slice(0,-"-transition".length),i):this._transitionable.setValue(r,i)}},n.prototype.updateTransitions=function(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)},n.prototype.hasTransition=function(){return this._transitioning.hasTransition()},n.prototype.recalculate=function(t){this.properties=this._transitioning.possiblyEvaluate(t)},n.prototype._validate=function(e,n,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.styleSpec})))},n}(t.Evented),E=function(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}};E.prototype.getDash=function(t,e){var n=t.join(",")+String(e);return this.dashEntry[n]||(this.dashEntry[n]=this.addDash(t,e)),this.dashEntry[n]},E.prototype.getDashRanges=function(t,e,n){var r=[],i=t.length%2==1?-t[t.length-1]*n:0,o=t[0]*n,a=!0;r.push({left:i,right:o,isDash:a,zeroLength:0===t[0]});for(var s=t[0],l=1;l<t.length;l++){var u=t[l];r.push({left:i=s*n,right:o=(s+=u)*n,isDash:a=!a,zeroLength:0===u})}return r},E.prototype.addRoundDash=function(t,e,n){for(var r=e/2,i=-n;i<=n;i++)for(var o=this.width*(this.nextRow+n+i),a=0,s=t[a],l=0;l<this.width;l++){l/s.right>1&&(s=t[++a]);var u=Math.abs(l-s.left),c=Math.abs(l-s.right),h=Math.min(u,c),p=void 0,f=i/n*(r+1);if(s.isDash){var d=r-Math.abs(f);p=Math.sqrt(h*h+d*d)}else p=r-Math.sqrt(h*h+f*f);this.data[o+l]=Math.max(0,Math.min(255,p+128))}},E.prototype.addRegularDash=function(t){for(var e=t.length-1;e>=0;--e){var n=t[e],r=t[e+1];n.zeroLength?t.splice(e,1):r&&r.isDash===n.isDash&&(r.left=n.left,t.splice(e,1))}var i=t[0],o=t[t.length-1];i.isDash===o.isDash&&(i.left=o.left-this.width,o.right=i.right+this.width);for(var a=this.width*this.nextRow,s=0,l=t[s],u=0;u<this.width;u++){u/l.right>1&&(l=t[++s]);var c=Math.abs(u-l.left),h=Math.abs(u-l.right),p=Math.min(c,h);this.data[a+u]=Math.max(0,Math.min(255,(l.isDash?p:-p)+128))}},E.prototype.addDash=function(e,n){var r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.warnOnce("LineAtlas out of space"),null;for(var o=0,a=0;a<e.length;a++)o+=e[a];if(0!==o){var s=this.width/o,l=this.getDashRanges(e,this.width,s);n?this.addRoundDash(l,s,r):this.addRegularDash(l)}var u={y:(this.nextRow+r+.5)/this.height,height:2*r/this.height,width:o};return this.nextRow+=i,this.dirty=!0,u},E.prototype.bind=function(t){var e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))};var S=function e(n,r){this.workerPool=n,this.actors=[],this.currentActor=0,this.id=t.uniqueId();for(var i=this.workerPool.acquire(this.id),o=0;o<i.length;o++){var a=new e.Actor(i[o],r,this.id);a.name="Worker "+o,this.actors.push(a)}};function M(e,n,r){var i=function(i,o){if(i)return r(i);if(o){var a=t.pick(t.extend(o,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(a.vectorLayers=o.vector_layers,a.vectorLayerIds=a.vectorLayers.map((function(t){return t.id}))),a.tiles=n.canonicalizeTileset(a,e.url),r(null,a)}};return e.url?t.getJSON(n.transformRequest(n.normalizeSourceURL(e.url),t.ResourceType.Source),i):t.browser.frame((function(){return i(null,e)}))}S.prototype.broadcast=function(e,n,r){t.asyncAll(this.actors,(function(t,r){t.send(e,n,r)}),r=r||function(){})},S.prototype.getActor=function(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]},S.prototype.remove=function(){this.actors.forEach((function(t){t.remove()})),this.actors=[],this.workerPool.release(this.id)},S.Actor=t.Actor;var T=function(e,n,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=r||24};T.prototype.validateBounds=function(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]},T.prototype.contains=function(e){var n=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*n);return e.x>=r&&e.x<o&&e.y>=i&&e.y<a};var C=function(e){function n(n,r,i,o){if(e.call(this),this.id=n,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(r,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},r),this._collectResourceTiming=r.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){var e=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=M(this._options,this.map._requestManager,(function(n,r){e._tileJSONRequest=null,e._loaded=!0,n?e.fire(new t.ErrorEvent(n)):r&&(t.extend(e,r),r.bounds&&(e.tileBounds=new T(r.bounds,e.minzoom,e.maxzoom)),t.postTurnstileEvent(r.tiles,e.map._requestManager._customAccessToken),t.postMapLoadEvent(r.tiles,e.map._getMapId(),e.map._requestManager._skuToken,e.map._requestManager._customAccessToken),e.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),e.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))},n.prototype.loaded=function(){return this._loaded},n.prototype.hasTile=function(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setSourceProperty=function(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.map.style.sourceCaches[this.id].clearTiles(),this.load()},n.prototype.setTiles=function(t){var e=this;return this.setSourceProperty((function(){e._options.tiles=t})),this},n.prototype.setUrl=function(t){var e=this;return this.setSourceProperty((function(){e.url=t,e._options.url=t})),this},n.prototype.onRemove=function(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)},n.prototype.serialize=function(){return t.extend({},this._options)},n.prototype.loadTile=function(e,n){var r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.browser.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function o(r,i){return delete e.request,e.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(e.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&e.setExpiryData(i),e.loadVectorData(i,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}i.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state?"loading"===e.state?e.reloadCallback=n:e.request=e.actor.send("reloadTile",i,o.bind(this)):(e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",i,o.bind(this)))},n.prototype.abortTile=function(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)},n.prototype.unloadTile=function(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)},n.prototype.hasTransition=function(){return!1},n}(t.Evented),I=function(e){function n(n,r,i,o){e.call(this),this.id=n,this.dispatcher=i,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},r),t.extend(this,t.pick(r,["url","scheme","tileSize"]))}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){var e=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=M(this._options,this.map._requestManager,(function(n,r){e._tileJSONRequest=null,e._loaded=!0,n?e.fire(new t.ErrorEvent(n)):r&&(t.extend(e,r),r.bounds&&(e.tileBounds=new T(r.bounds,e.minzoom,e.maxzoom)),t.postTurnstileEvent(r.tiles),t.postMapLoadEvent(r.tiles,e.map._getMapId(),e.map._requestManager._skuToken),e.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),e.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))},n.prototype.loaded=function(){return this._loaded},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.onRemove=function(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)},n.prototype.serialize=function(){return t.extend({},this._options)},n.prototype.hasTile=function(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)},n.prototype.loadTile=function(e,n){var r=this,i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(i,t.ResourceType.Tile),(function(i,o){if(delete e.request,e.aborted)e.state="unloaded",n(null);else if(i)e.state="errored",n(i);else if(o){r.map._refreshExpiredTiles&&e.setExpiryData(o),delete o.cacheControl,delete o.expires;var a=r.map.painter.context,s=a.gl;e.texture=r.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.Texture(a,o,s.RGBA,{useMipmap:!0}),e.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST),a.extTextureFilterAnisotropic&&s.texParameterf(s.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax)),e.state="loaded",t.cacheEntryPossiblyAdded(r.dispatcher),n(null)}}))},n.prototype.abortTile=function(t,e){t.request&&(t.request.cancel(),delete t.request),e()},n.prototype.unloadTile=function(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()},n.prototype.hasTransition=function(){return!1},n}(t.Evented),A=function(e){function n(n,r,i,o){e.call(this,n,r,i,o),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.serialize=function(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}},n.prototype.loadTile=function(e,n){var r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),this.tileSize);function i(t,r){t&&(e.state="errored",n(t)),r&&(e.dem=r,e.needsHillshadePrepare=!0,e.state="loaded",n(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,o){if(delete e.request,e.aborted)e.state="unloaded",n(null);else if(r)e.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData(o),delete o.cacheControl,delete o.expires;var a=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap&&t.offscreenCanvasSupported()?o:t.browser.getImageData(o,1),s={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:a,encoding:this.encoding};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",s,i.bind(this)))}}.bind(this)),e.neighboringTiles=this._getNeighboringTiles(e.tileID)},n.prototype._getNeighboringTiles=function(e){var n=e.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?e.wrap-1:e.wrap,a=(n.x+1+r)%r,s=n.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1<r&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,i,n.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,a,n.y+1).key]={backfilled:!1}),l},n.prototype.unloadTile=function(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})},n}(I),L=function(e){function n(n,r,i,o){e.call(this),this.id=n,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(o),this._data=r.data,this._options=t.extend({},r),this._collectResourceTiming=r.collectResourceTiming,this._resourceTiming=[],void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;var a=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*a,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*a,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?Math.min(r.clusterMaxZoom,this.maxzoom-1):this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:t.EXTENT,radius:(r.clusterRadius||50)*a,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){var e=this;this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData((function(n){if(n)e.fire(new t.ErrorEvent(n));else{var r={dataType:"source",sourceDataType:"metadata"};e._collectResourceTiming&&e._resourceTiming&&e._resourceTiming.length>0&&(r.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",r))}}))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setData=function(e){var n=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData((function(e){if(e)n.fire(new t.ErrorEvent(e));else{var r={dataType:"source",sourceDataType:"content"};n._collectResourceTiming&&n._resourceTiming&&n._resourceTiming.length>0&&(r.resourceTiming=n._resourceTiming,n._resourceTiming=[]),n.fire(new t.Event("data",r))}})),this},n.prototype.getClusterExpansionZoom=function(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this},n.prototype.getClusterChildren=function(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this},n.prototype.getClusterLeaves=function(t,e,n,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:n},r),this},n.prototype._updateWorkerData=function(e){var n=this;this._loaded=!1;var r=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(r.request=this.map._requestManager.transformRequest(t.browser.resolveURL(i),t.ResourceType.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(i),this.actor.send(this.type+".loadData",r,(function(t,i){n._removed||i&&i.abandoned||(n._loaded=!0,i&&i.resourceTiming&&i.resourceTiming[n.id]&&(n._resourceTiming=i.resourceTiming[n.id].slice(0)),n.actor.send(n.type+".coalesce",{source:r.source},null),e(t))}))},n.prototype.loaded=function(){return this._loaded},n.prototype.loadTile=function(e,n){var r=this,i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.browser.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(function(t,o){return delete e.request,e.unloadVectorData(),e.aborted?n(null):t?n(t):(e.loadVectorData(o,r.map.painter,"reloadTile"===i),n(null))}))},n.prototype.abortTile=function(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0},n.prototype.unloadTile=function(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})},n.prototype.onRemove=function(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})},n.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},n.prototype.hasTransition=function(){return!1},n}(t.Evented),P=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),R=function(e){function n(t,n,r,i){e.call(this),this.id=t,this.dispatcher=r,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=n}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(e,n){var r=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),(function(i,o){r._loaded=!0,i?r.fire(new t.ErrorEvent(i)):o&&(r.image=o,e&&(r.coordinates=e),n&&n(),r._finishLoading())}))},n.prototype.loaded=function(){return this._loaded},n.prototype.updateImage=function(t){var e=this;return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(function(){e.texture=null})),this):this},n.prototype._finishLoading=function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setCoordinates=function(e){var n=this;this.coordinates=e;var r=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){for(var n=1/0,r=1/0,i=-1/0,o=-1/0,a=0,s=e;a<s.length;a+=1){var l=s[a];n=Math.min(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.x),o=Math.max(o,l.y)}var u=Math.max(i-n,o-r),c=Math.max(0,Math.floor(-Math.log(u)/Math.LN2)),h=Math.pow(2,c);return new t.CanonicalTileID(c,Math.floor((n+i)/2*h),Math.floor((r+o)/2*h))}(r),this.minzoom=this.maxzoom=this.tileID.z;var i=r.map((function(t){return n.tileID.getTilePoint(t)._round()}));return this._boundsArray=new t.StructArrayLayout4i8,this._boundsArray.emplaceBack(i[0].x,i[0].y,0,0),this._boundsArray.emplaceBack(i[1].x,i[1].y,t.EXTENT,0),this._boundsArray.emplaceBack(i[3].x,i[3].y,0,t.EXTENT),this._boundsArray.emplaceBack(i[2].x,i[2].y,t.EXTENT,t.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this},n.prototype.prepare=function(){if(0!==Object.keys(this.tiles).length&&this.image){var e=this.map.painter.context,n=e.gl;for(var r in this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,P.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new t.Texture(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}}},n.prototype.loadTile=function(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))},n.prototype.serialize=function(){return{type:"image",url:this.options.url,coordinates:this.coordinates}},n.prototype.hasTransition=function(){return!1},n}(t.Evented),D=function(e){function n(t,n,r,i){e.call(this,t,n,r,i),this.roundZoom=!0,this.type="video",this.options=n}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){var e=this;this._loaded=!1;var n=this.options;this.urls=[];for(var r=0,i=n.urls;r<i.length;r+=1)this.urls.push(this.map._requestManager.transformRequest(i[r],t.ResourceType.Source).url);t.getVideo(this.urls,(function(n,r){e._loaded=!0,n?e.fire(new t.ErrorEvent(n)):r&&(e.video=r,e.video.loop=!0,e.video.addEventListener("playing",(function(){e.map.triggerRepaint()})),e.map&&e.video.play(),e._finishLoading())}))},n.prototype.pause=function(){this.video&&this.video.pause()},n.prototype.play=function(){this.video&&this.video.play()},n.prototype.seek=function(e){if(this.video){var n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError("sources."+this.id,null,"Playback for this video can be set only between the "+n.start(0)+" and "+n.end(0)+"-second mark."))):this.video.currentTime=e}},n.prototype.getVideo=function(){return this.video},n.prototype.onAdd=function(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))},n.prototype.prepare=function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var e=this.map.painter.context,n=e.gl;for(var r in this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,P.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this.video&&!this.video.paused},n}(R),N=function(e){function n(n,r,i,o){e.call(this,n,r,i,o),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((function(t){return!Array.isArray(t)||2!==t.length||t.some((function(t){return"number"!=typeof t}))}))||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},n.prototype.getCanvas=function(){return this.canvas},n.prototype.onAdd=function(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()},n.prototype.onRemove=function(){this.pause()},n.prototype.prepare=function(){var e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),!this._hasInvalidDimensions()&&0!==Object.keys(this.tiles).length){var n=this.map.painter.context,r=n.gl;for(var i in this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,P.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(n,this.canvas,r.RGBA,{premultiply:!0}),this.tiles){var o=this.tiles[i];"loaded"!==o.state&&(o.state="loaded",o.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"canvas",coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this._playing},n.prototype._hasInvalidDimensions=function(){for(var t=0,e=[this.canvas.width,this.canvas.height];t<e.length;t+=1){var n=e[t];if(isNaN(n)||n<=0)return!0}return!1},n}(R),O={vector:C,raster:I,"raster-dem":A,geojson:L,video:D,image:R,canvas:N};function k(e,n){var r=t.identity([]);return t.translate(r,r,[1,1,0]),t.scale(r,r,[.5*e.width,.5*e.height,1]),t.multiply(r,r,e.calculatePosMatrix(n.toUnwrapped()))}function z(t,e,n,r,i,o){var a=function(t,e,n){if(t)for(var r=0,i=t;r<i.length;r+=1){var o=e[i[r]];if(o&&o.source===n&&"fill-extrusion"===o.type)return!0}else for(var a in e){var s=e[a];if(s.source===n&&"fill-extrusion"===s.type)return!0}return!1}(i&&i.layers,e,t.id),s=o.maxPitchScaleFactor(),l=t.tilesIn(r,s,a);l.sort(F);for(var u=[],c=0,h=l;c<h.length;c+=1){var p=h[c];u.push({wrappedTileID:p.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(e,n,t._state,p.queryGeometry,p.cameraQueryGeometry,p.scale,i,o,s,k(t.transform,p.tileID))})}var f=function(t){for(var e={},n={},r=0,i=t;r<i.length;r+=1){var o=i[r],a=o.queryResults,s=o.wrappedTileID,l=n[s]=n[s]||{};for(var u in a)for(var c=a[u],h=l[u]=l[u]||{},p=e[u]=e[u]||[],f=0,d=c;f<d.length;f+=1){var m=d[f];h[m.featureIndex]||(h[m.featureIndex]=!0,p.push(m))}}return e}(u);for(var d in f)f[d].forEach((function(e){var n=e.feature,r=t.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=r}));return f}function F(t,e){var n=t.tileID,r=e.tileID;return n.overscaledZ-r.overscaledZ||n.canonical.y-r.canonical.y||n.wrap-r.wrap||n.canonical.x-r.canonical.x}var B=function(t,e){this.max=t,this.onRemove=e,this.reset()};B.prototype.reset=function(){for(var t in this.data)for(var e=0,n=this.data[t];e<n.length;e+=1){var r=n[e];r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value)}return this.data={},this.order=[],this},B.prototype.add=function(t,e,n){var r=this,i=t.wrapped().key;void 0===this.data[i]&&(this.data[i]=[]);var o={value:e,timeout:void 0};if(void 0!==n&&(o.timeout=setTimeout((function(){r.remove(t,o)}),n)),this.data[i].push(o),this.order.push(i),this.order.length>this.max){var a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this},B.prototype.has=function(t){return t.wrapped().key in this.data},B.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},B.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},B.prototype.getByKey=function(t){var e=this.data[t];return e?e[0].value:null},B.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},B.prototype.remove=function(t,e){if(!this.has(t))return this;var n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this},B.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this},B.prototype.filter=function(t){var e=[];for(var n in this.data)for(var r=0,i=this.data[n];r<i.length;r+=1){var o=i[r];t(o.value)||e.push(o)}for(var a=0,s=e;a<s.length;a+=1){var l=s[a];this.remove(l.value.tileID,l)}};var U=function(t,e,n){this.context=t;var r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};U.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},U.prototype.updateData=function(t){var e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},U.prototype.destroy=function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)};var V={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},G=function(t,e,n,r){this.length=e.length,this.attributes=n,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};G.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},G.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},G.prototype.enableAttributes=function(t,e){for(var n=0;n<this.attributes.length;n++){var r=e.attributes[this.attributes[n].name];void 0!==r&&t.enableVertexAttribArray(r)}},G.prototype.setVertexAttribPointers=function(t,e,n){for(var r=0;r<this.attributes.length;r++){var i=this.attributes[r],o=e.attributes[i.name];void 0!==o&&t.vertexAttribPointer(o,i.components,t[V[i.type]],!1,this.itemSize,i.offset+this.itemSize*(n||0))}},G.prototype.destroy=function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)};var j=function(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1};j.prototype.get=function(){return this.current},j.prototype.set=function(t){},j.prototype.getDefault=function(){return this.default},j.prototype.setDefault=function(){this.set(this.default)};var H=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.getDefault=function(){return t.Color.transparent},n.prototype.set=function(t){var e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)},n}(j),q=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return 1},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)},e}(j),W=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return 0},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)},e}(j),X=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return[!0,!0,!0,!0]},e.prototype.set=function(t){var e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)},e}(j),Z=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!0},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)},e}(j),Y=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return 255},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)},e}(j),J=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return{func:this.gl.ALWAYS,ref:0,mask:255}},e.prototype.set=function(t){var e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)},e}(j),K=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){var t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]},e.prototype.set=function(t){var e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)},e}(j),Q=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}},e}(j),$=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return[0,1]},e.prototype.set=function(t){var e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)},e}(j),tt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}},e}(j),et=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return this.gl.LESS},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)},e}(j),nt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}},e}(j),rt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){var t=this.gl;return[t.ONE,t.ZERO]},e.prototype.set=function(t){var e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)},e}(j),it=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.getDefault=function(){return t.Color.transparent},n.prototype.set=function(t){var e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)},n}(j),ot=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return this.gl.FUNC_ADD},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)},e}(j),at=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}},e}(j),st=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return this.gl.BACK},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)},e}(j),lt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return this.gl.CCW},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)},e}(j),ut=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)},e}(j),ct=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return this.gl.TEXTURE0},e.prototype.set=function(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)},e}(j),ht=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){var t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]},e.prototype.set=function(t){var e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)},e}(j),pt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},e}(j),ft=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},e}(j),dt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}},e}(j),mt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},e}(j),gt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){var e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1},e}(j),yt=function(t){function e(e){t.call(this,e),this.vao=e.extVertexArrayObject}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e.prototype.set=function(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)},e}(j),vt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return 4},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},e}(j),_t=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},e}(j),xt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return!1},e.prototype.set=function(t){if(t!==this.current||this.dirty){var e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},e}(j),bt=function(t){function e(e,n){t.call(this,e),this.context=e,this.parent=n}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getDefault=function(){return null},e}(j),wt=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.setDirty=function(){this.dirty=!0},e.prototype.set=function(t){if(t!==this.current||this.dirty){this.context.bindFramebuffer.set(this.parent);var e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},e}(bt),Et=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.set=function(t){if(t!==this.current||this.dirty){this.context.bindFramebuffer.set(this.parent);var e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},e}(bt),St=function(t,e,n,r){this.context=t,this.width=e,this.height=n;var i=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new wt(t,i),r&&(this.depthAttachment=new Et(t,i))};St.prototype.destroy=function(){var t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){var n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)};var Mt=function(t,e,n){this.func=t,this.mask=e,this.range=n};Mt.ReadOnly=!1,Mt.ReadWrite=!0,Mt.disabled=new Mt(519,Mt.ReadOnly,[0,1]);var Tt=function(t,e,n,r,i,o){this.test=t,this.ref=e,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o};Tt.disabled=new Tt({func:519,mask:0},0,0,7680,7680,7680);var Ct=function(t,e,n){this.blendFunction=t,this.blendColor=e,this.mask=n};Ct.disabled=new Ct(Ct.Replace=[1,0],t.Color.transparent,[!1,!1,!1,!1]),Ct.unblended=new Ct(Ct.Replace,t.Color.transparent,[!0,!0,!0,!0]),Ct.alphaBlended=new Ct([1,771],t.Color.transparent,[!0,!0,!0,!0]);var It=function(t,e,n){this.enable=t,this.mode=e,this.frontFace=n};It.disabled=new It(!1,1029,2305),It.backCCW=new It(!0,1029,2305);var At=function(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new H(this),this.clearDepth=new q(this),this.clearStencil=new W(this),this.colorMask=new X(this),this.depthMask=new Z(this),this.stencilMask=new Y(this),this.stencilFunc=new J(this),this.stencilOp=new K(this),this.stencilTest=new Q(this),this.depthRange=new $(this),this.depthTest=new tt(this),this.depthFunc=new et(this),this.blend=new nt(this),this.blendFunc=new rt(this),this.blendColor=new it(this),this.blendEquation=new ot(this),this.cullFace=new at(this),this.cullFaceSide=new st(this),this.frontFace=new lt(this),this.program=new ut(this),this.activeTexture=new ct(this),this.viewport=new ht(this),this.bindFramebuffer=new pt(this),this.bindRenderbuffer=new ft(this),this.bindTexture=new dt(this),this.bindVertexBuffer=new mt(this),this.bindElementBuffer=new gt(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new yt(this),this.pixelStoreUnpack=new vt(this),this.pixelStoreUnpackPremultiplyAlpha=new _t(this),this.pixelStoreUnpackFlipY=new xt(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)};At.prototype.setDefault=function(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()},At.prototype.setDirty=function(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0},At.prototype.createIndexBuffer=function(t,e){return new U(this,t,e)},At.prototype.createVertexBuffer=function(t,e,n){return new G(this,t,e,n)},At.prototype.createRenderbuffer=function(t,e,n){var r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,t,e,n),this.bindRenderbuffer.set(null),i},At.prototype.createFramebuffer=function(t,e,n){return new St(this,t,e,n)},At.prototype.clear=function(t){var e=t.color,n=t.depth,r=this.gl,i=0;e&&(i|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==n&&(i|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),r.clear(i)},At.prototype.setCullFace=function(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))},At.prototype.setDepthMode=function(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)},At.prototype.setStencilMode=function(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)},At.prototype.setColorMode=function(e){t.deepEqual(e.blendFunction,Ct.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)},At.prototype.unbindVAO=function(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)};var Lt=function(e){function n(n,r,i){var o=this;e.call(this),this.id=n,this.dispatcher=i,this.on("data",(function(t){"source"===t.dataType&&"metadata"===t.sourceDataType&&(o._sourceLoaded=!0),o._sourceLoaded&&!o._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(o.reload(),o.transform&&o.update(o.transform))})),this.on("error",(function(){o._sourceErrored=!0})),this._source=function(e,n,r,i){var o=new O[n.type](e,n,r,i);if(o.id!==e)throw new Error("Expected Source id to be "+e+" instead of "+o.id);return t.bindAll(["load","abort","unload","serialize","prepare"],o),o}(n,r,i,this),this._tiles={},this._cache=new B(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new t.SourceFeatureState}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.onAdd=function(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(t)},n.prototype.onRemove=function(t){this._source&&this._source.onRemove&&this._source.onRemove(t)},n.prototype.loaded=function(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(var t in this._tiles){var e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0},n.prototype.getSource=function(){return this._source},n.prototype.pause=function(){this._paused=!0},n.prototype.resume=function(){if(this._paused){var t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}},n.prototype._loadTile=function(t,e){return this._source.loadTile(t,e)},n.prototype._unloadTile=function(t){if(this._source.unloadTile)return this._source.unloadTile(t,(function(){}))},n.prototype._abortTile=function(t){if(this._source.abortTile)return this._source.abortTile(t,(function(){}))},n.prototype.serialize=function(){return this._source.serialize()},n.prototype.prepare=function(t){for(var e in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){var n=this._tiles[e];n.upload(t),n.prepare(this.map.style.imageManager)}},n.prototype.getIds=function(){return t.values(this._tiles).map((function(t){return t.tileID})).sort(Pt).map((function(t){return t.key}))},n.prototype.getRenderableIds=function(e){var n=this,r=[];for(var i in this._tiles)this._isIdRenderable(i,e)&&r.push(this._tiles[i]);return e?r.sort((function(e,r){var i=e.tileID,o=r.tileID,a=new t.Point(i.canonical.x,i.canonical.y)._rotate(n.transform.angle),s=new t.Point(o.canonical.x,o.canonical.y)._rotate(n.transform.angle);return i.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((function(t){return t.tileID.key})):r.map((function(t){return t.tileID})).sort(Pt).map((function(t){return t.key}))},n.prototype.hasRenderableParent=function(t){var e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)},n.prototype._isIdRenderable=function(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())},n.prototype.reload=function(){if(this._paused)this._shouldReloadOnResume=!0;else for(var t in this._cache.reset(),this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")},n.prototype._reloadTile=function(t,e){var n=this._tiles[t];n&&("loading"!==n.state&&(n.state=e),this._loadTile(n,this._tileLoaded.bind(this,n,t,e)))},n.prototype._tileLoaded=function(e,n,r,i){if(i)return e.state="errored",void(404!==i.status?this._source.fire(new t.ErrorEvent(i,{tile:e})):this.update(this.transform));e.timeAdded=t.browser.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new t.Event("data",{dataType:"source",tile:e,coord:e.tileID}))},n.prototype._backfillDEM=function(t){for(var e=this.getRenderableIds(),n=0;n<e.length;n++){var r=e[n];if(t.neighboringTiles&&t.neighboringTiles[r]){var i=this.getTileByID(r);o(t,i),o(i,t)}}function o(t,e){t.needsHillshadePrepare=!0;var n=e.tileID.canonical.x-t.tileID.canonical.x,r=e.tileID.canonical.y-t.tileID.canonical.y,i=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===n&&0===r||Math.abs(r)>1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}},n.prototype.getTile=function(t){return this.getTileByID(t.key)},n.prototype.getTileByID=function(t){return this._tiles[t]},n.prototype._retainLoadedChildren=function(t,e,n,r){for(var i in this._tiles){var o=this._tiles[i];if(!(r[i]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>n)){for(var a=o.tileID;o&&o.tileID.overscaledZ>e+1;){var s=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[s.key])&&o.hasData()&&(a=s)}for(var l=a;l.overscaledZ>e;)if(t[(l=l.scaledTo(l.overscaledZ-1)).key]){r[a.key]=a;break}}}},n.prototype.findLoadedParent=function(t,e){if(t.key in this._loadedParentTiles){var n=this._loadedParentTiles[t.key];return n&&n.tileID.overscaledZ>=e?n:null}for(var r=t.overscaledZ-1;r>=e;r--){var i=t.scaledTo(r),o=this._getLoadedTile(i);if(o)return o}},n.prototype._getLoadedTile=function(t){var e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)},n.prototype.updateCacheSize=function(t){var e=Math.ceil(t.width/this._source.tileSize)+1,n=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*n*5),i="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(i)},n.prototype.handleWrapJump=function(t){var e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){var n={};for(var r in this._tiles){var i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),n[i.tileID.key]=i}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}},n.prototype.update=function(e){var r=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)})):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter((function(t){return r._source.hasTile(t)})))):i=[];var o=e.coveringZoomLevel(this._source),a=Math.max(o-n.maxOverzooming,this._source.minzoom),s=Math.max(o+n.maxUnderzooming,this._source.minzoom),l=this._updateRetainedTiles(i,o);if(Rt(this._source.type)){for(var u={},c={},h=0,p=Object.keys(l);h<p.length;h+=1){var f=p[h],d=l[f],m=this._tiles[f];if(m&&!(m.fadeEndTime&&m.fadeEndTime<=t.browser.now())){var g=this.findLoadedParent(d,a);g&&(this._addTile(g.tileID),u[g.tileID.key]=g.tileID),c[f]=d}}for(var y in this._retainLoadedChildren(c,o,s,l),u)l[y]||(this._coveredTiles[y]=!0,l[y]=u[y])}for(var v in l)this._tiles[v].clearFadeHold();for(var _=0,x=t.keysDifference(this._tiles,l);_<x.length;_+=1){var b=x[_],w=this._tiles[b];w.hasSymbolBuckets&&!w.holdingForFade()?w.setHoldDuration(this.map._fadeDuration):w.hasSymbolBuckets&&!w.symbolFadeFinished()||this._removeTile(b)}this._updateLoadedParentTileCache()}},n.prototype.releaseSymbolFadeTiles=function(){for(var t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)},n.prototype._updateRetainedTiles=function(t,e){for(var r={},i={},o=Math.max(e-n.maxOverzooming,this._source.minzoom),a=Math.max(e+n.maxUnderzooming,this._source.minzoom),s={},l=0,u=t;l<u.length;l+=1){var c=u[l],h=this._addTile(c);r[c.key]=c,h.hasData()||e<this._source.maxzoom&&(s[c.key]=c)}this._retainLoadedChildren(s,e,a,r);for(var p=0,f=t;p<f.length;p+=1){var d=f[p],m=this._tiles[d.key];if(!m.hasData()){if(e+1>this._source.maxzoom){var g=d.children(this._source.maxzoom)[0],y=this.getTile(g);if(y&&y.hasData()){r[g.key]=g;continue}}else{var v=d.children(this._source.maxzoom);if(r[v[0].key]&&r[v[1].key]&&r[v[2].key]&&r[v[3].key])continue}for(var _=m.wasRequested(),x=d.overscaledZ-1;x>=o;--x){var b=d.scaledTo(x);if(i[b.key])break;if(i[b.key]=!0,!(m=this.getTile(b))&&_&&(m=this._addTile(b)),m&&(r[b.key]=b,_=m.wasRequested(),m.hasData()))break}}}return r},n.prototype._updateLoadedParentTileCache=function(){for(var t in this._loadedParentTiles={},this._tiles){for(var e=[],n=void 0,r=this._tiles[t].tileID;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}e.push(r.key);var i=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(i))break;r=i}for(var o=0,a=e;o<a.length;o+=1)this._loadedParentTiles[a[o]]=n}},n.prototype._addTile=function(e){var n=this._tiles[e.key];if(n)return n;(n=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));var r=Boolean(n);return r||(n=new t.Tile(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,e.key,n.state))),n?(n.uses++,this._tiles[e.key]=n,r||this._source.fire(new t.Event("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n):null},n.prototype._setTileReloadTimer=function(t,e){var n=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((function(){n._reloadTile(t,"expired"),delete n._timers[t]}),r))},n.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},n.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},n.prototype.tilesIn=function(e,n,r){var i=this,o=[],a=this.transform;if(!a)return o;for(var s=r?a.getCameraQueryGeometry(e):e,l=e.map((function(t){return a.pointCoordinate(t)})),u=s.map((function(t){return a.pointCoordinate(t)})),c=this.getIds(),h=1/0,p=1/0,f=-1/0,d=-1/0,m=0,g=u;m<g.length;m+=1){var y=g[m];h=Math.min(h,y.x),p=Math.min(p,y.y),f=Math.max(f,y.x),d=Math.max(d,y.y)}for(var v=function(e){var r=i._tiles[c[e]];if(!r.holdingForFade()){var s=r.tileID,m=Math.pow(2,a.zoom-r.tileID.overscaledZ),g=n*r.queryPadding*t.EXTENT/r.tileSize/m,y=[s.getTilePoint(new t.MercatorCoordinate(h,p)),s.getTilePoint(new t.MercatorCoordinate(f,d))];if(y[0].x-g<t.EXTENT&&y[0].y-g<t.EXTENT&&y[1].x+g>=0&&y[1].y+g>=0){var v=l.map((function(t){return s.getTilePoint(t)})),_=u.map((function(t){return s.getTilePoint(t)}));o.push({tile:r,tileID:s,queryGeometry:v,cameraQueryGeometry:_,scale:m})}}},_=0;_<c.length;_++)v(_);return o},n.prototype.getVisibleCoordinates=function(t){for(var e=this,n=this.getRenderableIds(t).map((function(t){return e._tiles[t].tileID})),r=0,i=n;r<i.length;r+=1){var o=i[r];o.posMatrix=this.transform.calculatePosMatrix(o.toUnwrapped())}return n},n.prototype.hasTransition=function(){if(this._source.hasTransition())return!0;if(Rt(this._source.type))for(var e in this._tiles){var n=this._tiles[e];if(void 0!==n.fadeEndTime&&n.fadeEndTime>=t.browser.now())return!0}return!1},n.prototype.setFeatureState=function(t,e,n){this._state.updateState(t=t||"_geojsonTileLayer",e,n)},n.prototype.removeFeatureState=function(t,e,n){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,n)},n.prototype.getFeatureState=function(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)},n.prototype.setDependencies=function(t,e,n){var r=this._tiles[t];r&&r.setDependencies(e,n)},n.prototype.reloadTilesForDependencies=function(t,e){for(var n in this._tiles)this._tiles[n].hasDependency(t,e)&&this._reloadTile(n,"reloading");this._cache.filter((function(n){return!n.hasDependency(t,e)}))},n}(t.Evented);function Pt(t,e){var n=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-n||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Rt(t){return"raster"===t||"image"===t||"video"===t}function Dt(){return new t.window.Worker(Yi.workerUrl)}Lt.maxOverzooming=10,Lt.maxUnderzooming=3;var Nt="mapboxgl_preloaded_worker_pool",Ot=function(){this.active={}};Ot.prototype.acquire=function(t){if(!this.workers)for(this.workers=[];this.workers.length<Ot.workerCount;)this.workers.push(new Dt);return this.active[t]=!0,this.workers.slice()},Ot.prototype.release=function(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((function(t){t.terminate()})),this.workers=null)},Ot.prototype.isPreloaded=function(){return!!this.active[Nt]},Ot.prototype.numActive=function(){return Object.keys(this.active).length};var kt,zt=Math.floor(t.browser.hardwareConcurrency/2);function Ft(){return kt||(kt=new Ot),kt}function Bt(e,n){var r={};for(var i in e)"ref"!==i&&(r[i]=e[i]);return t.refProperties.forEach((function(t){t in n&&(r[t]=n[t])})),r}function Ut(t){t=t.slice();for(var e=Object.create(null),n=0;n<t.length;n++)e[t[n].id]=t[n];for(var r=0;r<t.length;r++)"ref"in t[r]&&(t[r]=Bt(t[r],e[t[r].ref]));return t}Ot.workerCount=Math.max(Math.min(zt,6),1);var Vt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function Gt(t,e,n){n.push({command:Vt.addSource,args:[t,e[t]]})}function jt(t,e,n){e.push({command:Vt.removeSource,args:[t]}),n[t]=!0}function Ht(t,e,n,r){jt(t,n,r),Gt(t,e,n)}function qt(e,n,r){var i;for(i in e[r])if(e[r].hasOwnProperty(i)&&"data"!==i&&!t.deepEqual(e[r][i],n[r][i]))return!1;for(i in n[r])if(n[r].hasOwnProperty(i)&&"data"!==i&&!t.deepEqual(e[r][i],n[r][i]))return!1;return!0}function Wt(e,n,r,i,o,a){var s;for(s in n=n||{},e=e||{})e.hasOwnProperty(s)&&(t.deepEqual(e[s],n[s])||r.push({command:a,args:[i,s,n[s],o]}));for(s in n)n.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(t.deepEqual(e[s],n[s])||r.push({command:a,args:[i,s,n[s],o]}))}function Xt(t){return t.id}function Zt(t,e){return t[e.id]=e,t}var Yt=function(t,e){this.reset(t,e)};Yt.prototype.reset=function(t,e){this.points=t||[],this._distances=[0];for(var n=1;n<this.points.length;n++)this._distances[n]=this._distances[n-1]+this.points[n].dist(this.points[n-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding},Yt.prototype.lerp=function(e){if(1===this.points.length)return this.points[0];e=t.clamp(e,0,1);for(var n=1,r=this._distances[n],i=e*this.paddedLength+this.padding;r<i&&n<this._distances.length;)r=this._distances[++n];var o=n-1,a=this._distances[o],s=r-a,l=s>0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))};var Jt=function(t,e,n){var r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(t/n),this.yCellCount=Math.ceil(e/n);for(var o=0;o<this.xCellCount*this.yCellCount;o++)r.push([]),i.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0};function Kt(e,n,r,i,o){var a=t.create();return n?(t.scale(a,a,[1/o,1/o,1]),r||t.rotateZ(a,a,i.angle)):t.multiply(a,i.labelPlaneMatrix,e),a}function Qt(e,n,r,i,o){if(n){var a=t.clone(e);return t.scale(a,a,[o,o,1]),r||t.rotateZ(a,a,-i.angle),a}return i.glCoordMatrix}function $t(e,n){var r=[e.x,e.y,0,1];ce(r,r,n);var i=r[3];return{point:new t.Point(r[0]/i,r[1]/i),signedDistanceFromCamera:i}}function te(t,e){return.5+t/e*.5}function ee(t,e){var n=t[0]/t[3],r=t[1]/t[3];return n>=-e[0]&&n<=e[0]&&r>=-e[1]&&r<=e[1]}function ne(e,n,r,i,o,a,s,l){var u=i?e.textSizeData:e.iconSizeData,c=t.evaluateSizeForZoom(u,r.transform.zoom),h=[256/r.width*2+1,256/r.height*2+1],p=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;p.clear();for(var f=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,m=r.transform.width/r.transform.height,g=!1,y=0;y<d.length;y++){var v=d.get(y);if(v.hidden||v.writingMode===t.WritingMode.vertical&&!g)ue(v.numGlyphs,p);else{g=!1;var _=[v.anchorX,v.anchorY,0,1];if(t.transformMat4(_,_,n),ee(_,h)){var x=te(r.transform.cameraToCenterDistance,_[3]),b=t.evaluateSizeForFeature(u,c,v),w=s?b/x:b*x,E=new t.Point(v.anchorX,v.anchorY),S=$t(E,o).point,M={},T=oe(v,w,!1,l,n,o,a,e.glyphOffsetArray,f,p,S,E,M,m);g=T.useVertical,(T.notEnoughRoom||g||T.needsFlipping&&oe(v,w,!0,l,n,o,a,e.glyphOffsetArray,f,p,S,E,M,m).notEnoughRoom)&&ue(v.numGlyphs,p)}else ue(v.numGlyphs,p)}}i?e.text.dynamicLayoutVertexBuffer.updateData(p):e.icon.dynamicLayoutVertexBuffer.updateData(p)}function re(t,e,n,r,i,o,a,s,l,u,c){var h=s.glyphStartIndex+s.numGlyphs,p=s.lineStartIndex,f=s.lineStartIndex+s.lineLength,d=e.getoffsetX(s.glyphStartIndex),m=e.getoffsetX(h-1),g=se(t*d,n,r,i,o,a,s.segment,p,f,l,u,c);if(!g)return null;var y=se(t*m,n,r,i,o,a,s.segment,p,f,l,u,c);return y?{first:g,last:y}:null}function ie(e,n,r,i){return e===t.WritingMode.horizontal&&Math.abs(r.y-n.y)>Math.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?n.y<r.y:n.x>r.x)?{needsFlipping:!0}:null}function oe(e,n,r,i,o,a,s,l,u,c,h,p,f,d){var m,g=n/24,y=e.lineOffsetX*g,v=e.lineOffsetY*g;if(e.numGlyphs>1){var _=e.glyphStartIndex+e.numGlyphs,x=e.lineStartIndex,b=e.lineStartIndex+e.lineLength,w=re(g,l,y,v,r,h,p,e,u,a,f);if(!w)return{notEnoughRoom:!0};var E=$t(w.first.point,s).point,S=$t(w.last.point,s).point;if(i&&!r){var M=ie(e.writingMode,E,S,d);if(M)return M}m=[w.first];for(var T=e.glyphStartIndex+1;T<_-1;T++)m.push(se(g*l.getoffsetX(T),y,v,r,h,p,e.segment,x,b,u,a,f));m.push(w.last)}else{if(i&&!r){var C=$t(p,o).point,I=e.lineStartIndex+e.segment+1,A=new t.Point(u.getx(I),u.gety(I)),L=$t(A,o),P=L.signedDistanceFromCamera>0?L.point:ae(p,A,C,1,o),R=ie(e.writingMode,C,P,d);if(R)return R}var D=se(g*l.getoffsetX(e.glyphStartIndex),y,v,r,h,p,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,u,a,f);if(!D)return{notEnoughRoom:!0};m=[D]}for(var N=0,O=m;N<O.length;N+=1){var k=O[N];t.addDynamicAttributes(c,k.point,k.angle)}return{}}function ae(t,e,n,r,i){var o=$t(t.add(t.sub(e)._unit()),i).point,a=n.sub(o);return n.add(a._mult(r/a.mag()))}function se(e,n,r,i,o,a,s,l,u,c,h,p){var f=i?e-n:e+n,d=f>0?1:-1,m=0;i&&(d*=-1,m=Math.PI),d<0&&(m+=Math.PI);for(var g=d>0?l+s:l+s+1,y=o,v=o,_=0,x=0,b=Math.abs(f),w=[];_+x<=b;){if((g+=d)<l||g>=u)return null;if(v=y,w.push(y),void 0===(y=p[g])){var E=new t.Point(c.getx(g),c.gety(g)),S=$t(E,h);if(S.signedDistanceFromCamera>0)y=p[g]=S.point;else{var M=g-d;y=ae(0===_?a:new t.Point(c.getx(M),c.gety(M)),E,v,b-_+1,h)}}_+=x,x=v.dist(y)}var T=(b-_)/x,C=y.sub(v),I=C.mult(T)._add(v);I._add(C._unit()._perp()._mult(r*d));var A=m+Math.atan2(y.y-v.y,y.x-v.x);return w.push(I),{point:I,angle:A,path:w}}Jt.prototype.keysLength=function(){return this.boxKeys.length+this.circleKeys.length},Jt.prototype.insert=function(t,e,n,r,i){this._forEachCell(e,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)},Jt.prototype.insertCircle=function(t,e,n,r){this._forEachCell(e-r,n-r,e+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(n),this.circles.push(r)},Jt.prototype._insertBoxCell=function(t,e,n,r,i,o){this.boxCells[i].push(o)},Jt.prototype._insertCircleCell=function(t,e,n,r,i,o){this.circleCells[i].push(o)},Jt.prototype._query=function(t,e,n,r,i,o){if(n<0||t>this.width||r<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(var s=0;s<this.boxKeys.length;s++)a.push({key:this.boxKeys[s],x1:this.bboxes[4*s],y1:this.bboxes[4*s+1],x2:this.bboxes[4*s+2],y2:this.bboxes[4*s+3]});for(var l=0;l<this.circleKeys.length;l++){var u=this.circles[3*l],c=this.circles[3*l+1],h=this.circles[3*l+2];a.push({key:this.circleKeys[l],x1:u-h,y1:c-h,x2:u+h,y2:c+h})}return o?a.filter(o):a}return this._forEachCell(t,e,n,r,this._queryCell,a,{hitTest:i,seenUids:{box:{},circle:{}}},o),i?a.length>0:a},Jt.prototype._queryCircle=function(t,e,n,r,i){var o=t-n,a=t+n,s=e-n,l=e+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];var u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u},Jt.prototype.query=function(t,e,n,r,i){return this._query(t,e,n,r,!1,i)},Jt.prototype.hitTest=function(t,e,n,r,i){return this._query(t,e,n,r,!0,i)},Jt.prototype.hitTestCircle=function(t,e,n,r){return this._queryCircle(t,e,n,!0,r)},Jt.prototype._queryCell=function(t,e,n,r,i,o,a,s){var l=a.seenUids,u=this.boxCells[i];if(null!==u)for(var c=this.bboxes,h=0,p=u;h<p.length;h+=1){var f=p[h];if(!l.box[f]){l.box[f]=!0;var d=4*f;if(t<=c[d+2]&&e<=c[d+3]&&n>=c[d+0]&&r>=c[d+1]&&(!s||s(this.boxKeys[f]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[f],x1:c[d],y1:c[d+1],x2:c[d+2],y2:c[d+3]})}}}var m=this.circleCells[i];if(null!==m)for(var g=this.circles,y=0,v=m;y<v.length;y+=1){var _=v[y];if(!l.circle[_]){l.circle[_]=!0;var x=3*_;if(this._circleAndRectCollide(g[x],g[x+1],g[x+2],t,e,n,r)&&(!s||s(this.circleKeys[_]))){if(a.hitTest)return o.push(!0),!0;var b=g[x],w=g[x+1],E=g[x+2];o.push({key:this.circleKeys[_],x1:b-E,y1:w-E,x2:b+E,y2:w+E})}}}},Jt.prototype._queryCellCircle=function(t,e,n,r,i,o,a,s){var l=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c)for(var h=this.bboxes,p=0,f=c;p<f.length;p+=1){var d=f[p];if(!u.box[d]){u.box[d]=!0;var m=4*d;if(this._circleAndRectCollide(l.x,l.y,l.radius,h[m+0],h[m+1],h[m+2],h[m+3])&&(!s||s(this.boxKeys[d])))return o.push(!0),!0}}var g=this.circleCells[i];if(null!==g)for(var y=this.circles,v=0,_=g;v<_.length;v+=1){var x=_[v];if(!u.circle[x]){u.circle[x]=!0;var b=3*x;if(this._circlesCollide(y[b],y[b+1],y[b+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[x])))return o.push(!0),!0}}},Jt.prototype._forEachCell=function(t,e,n,r,i,o,a,s){for(var l=this._convertToXCellCoord(t),u=this._convertToYCellCoord(e),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r),p=l;p<=c;p++)for(var f=u;f<=h;f++)if(i.call(this,t,e,n,r,this.xCellCount*f+p,o,a,s))return},Jt.prototype._convertToXCellCoord=function(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))},Jt.prototype._convertToYCellCoord=function(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))},Jt.prototype._circlesCollide=function(t,e,n,r,i,o){var a=r-t,s=i-e,l=n+o;return l*l>a*a+s*s},Jt.prototype._circleAndRectCollide=function(t,e,n,r,i,o,a){var s=(o-r)/2,l=Math.abs(t-(r+s));if(l>s+n)return!1;var u=(a-i)/2,c=Math.abs(e-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;var h=l-s,p=c-u;return h*h+p*p<=n*n};var le=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ue(t,e){for(var n=0;n<t;n++){var r=e.length;e.resize(r+4),e.float32.set(le,3*r)}}function ce(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t[3]=n[3]*r+n[7]*i+n[15],t}var he=function(t,e,n){void 0===e&&(e=new Jt(t.width+200,t.height+200,25)),void 0===n&&(n=new Jt(t.width+200,t.height+200,25)),this.transform=t,this.grid=e,this.ignoredGrid=n,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200};function pe(e,n,r){return n*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}he.prototype.placeCollisionBox=function(t,e,n,r,i){var o=this.projectAndGetPerspectiveRatio(r,t.anchorPointX,t.anchorPointY),a=n*o.perspectiveRatio,s=t.x1*a+o.point.x,l=t.y1*a+o.point.y,u=t.x2*a+o.point.x,c=t.y2*a+o.point.y;return!this.isInsideGrid(s,l,u,c)||!e&&this.grid.hitTest(s,l,u,c,i)?{box:[],offscreen:!1}:{box:[s,l,u,c],offscreen:this.isOffscreen(s,l,u,c)}},he.prototype.placeCollisionCircles=function(e,n,r,i,o,a,s,l,u,c,h,p,f){var d=[],m=new t.Point(n.anchorX,n.anchorY),g=$t(m,a),y=te(this.transform.cameraToCenterDistance,g.signedDistanceFromCamera),v=(c?o/y:o*y)/t.ONE_EM,_=$t(m,s).point,x=re(v,i,n.lineOffsetX*v,n.lineOffsetY*v,!1,_,m,n,r,s,{}),b=!1,w=!1,E=!0;if(x){for(var S=.5*p*y+f,M=new t.Point(-100,-100),T=new t.Point(this.screenRightBoundary,this.screenBottomBoundary),C=new Yt,I=x.first,A=x.last,L=[],P=I.path.length-1;P>=1;P--)L.push(I.path[P]);for(var R=1;R<A.path.length;R++)L.push(A.path[R]);var D=2.5*S;if(l){var N=L.map((function(t){return $t(t,l)}));L=N.some((function(t){return t.signedDistanceFromCamera<=0}))?[]:N.map((function(t){return t.point}))}var O=[];if(L.length>0){for(var k=L[0].clone(),z=L[0].clone(),F=1;F<L.length;F++)k.x=Math.min(k.x,L[F].x),k.y=Math.min(k.y,L[F].y),z.x=Math.max(z.x,L[F].x),z.y=Math.max(z.y,L[F].y);O=k.x>=M.x&&z.x<=T.x&&k.y>=M.y&&z.y<=T.y?[L]:z.x<M.x||k.x>T.x||z.y<M.y||k.y>T.y?[]:t.clipLine([L],M.x,M.y,T.x,T.y)}for(var B=0,U=O;B<U.length;B+=1){var V;C.reset(U[B],.25*S),V=C.length<=.5*S?1:Math.ceil(C.paddedLength/D)+1;for(var G=0;G<V;G++){var j=G/Math.max(V-1,1),H=C.lerp(j),q=H.x+100,W=H.y+100;d.push(q,W,S,0);var X=q-S,Z=W-S,Y=q+S,J=W+S;if(E=E&&this.isOffscreen(X,Z,Y,J),w=w||this.isInsideGrid(X,Z,Y,J),!e&&this.grid.hitTestCircle(q,W,S,h)&&(b=!0,!u))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!u&&b||!w?[]:d,offscreen:E,collisionDetected:b}},he.prototype.queryRenderedSymbols=function(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};for(var n=[],r=1/0,i=1/0,o=-1/0,a=-1/0,s=0,l=e;s<l.length;s+=1){var u=l[s],c=new t.Point(u.x+100,u.y+100);r=Math.min(r,c.x),i=Math.min(i,c.y),o=Math.max(o,c.x),a=Math.max(a,c.y),n.push(c)}for(var h={},p={},f=0,d=this.grid.query(r,i,o,a).concat(this.ignoredGrid.query(r,i,o,a));f<d.length;f+=1){var m=d[f],g=m.key;if(void 0===h[g.bucketInstanceId]&&(h[g.bucketInstanceId]={}),!h[g.bucketInstanceId][g.featureIndex]){var y=[new t.Point(m.x1,m.y1),new t.Point(m.x2,m.y1),new t.Point(m.x2,m.y2),new t.Point(m.x1,m.y2)];t.polygonIntersectsPolygon(n,y)&&(h[g.bucketInstanceId][g.featureIndex]=!0,void 0===p[g.bucketInstanceId]&&(p[g.bucketInstanceId]=[]),p[g.bucketInstanceId].push(g.featureIndex))}}return p},he.prototype.insertCollisionBox=function(t,e,n,r,i){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:i},t[0],t[1],t[2],t[3])},he.prototype.insertCollisionCircles=function(t,e,n,r,i){for(var o=e?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:i},s=0;s<t.length;s+=4)o.insertCircle(a,t[s],t[s+1],t[s+2])},he.prototype.projectAndGetPerspectiveRatio=function(e,n,r){var i=[n,r,0,1];return ce(i,i,e),{point:new t.Point((i[0]/i[3]+1)/2*this.transform.width+100,(-i[1]/i[3]+1)/2*this.transform.height+100),perspectiveRatio:.5+this.transform.cameraToCenterDistance/i[3]*.5}},he.prototype.isOffscreen=function(t,e,n,r){return n<100||t>=this.screenRightBoundary||r<100||e>this.screenBottomBoundary},he.prototype.isInsideGrid=function(t,e,n,r){return n>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary},he.prototype.getViewportMatrix=function(){var e=t.identity([]);return t.translate(e,e,[-100,-100,0]),e};var fe=function(t,e,n,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&n?1:0,this.placed=n};fe.prototype.isHidden=function(){return 0===this.opacity&&!this.placed};var de=function(t,e,n,r,i){this.text=new fe(t?t.text:null,e,n,i),this.icon=new fe(t?t.icon:null,e,r,i)};de.prototype.isHidden=function(){return this.text.isHidden()&&this.icon.isHidden()};var me=function(t,e,n){this.text=t,this.icon=e,this.skipFade=n},ge=function(){this.invProjMatrix=t.create(),this.viewportMatrix=t.create(),this.circles=[]},ye=function(t,e,n,r,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i},ve=function(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}};function _e(e,n,r,i,o){var a=t.getAnchorAlignment(e),s=-(a.horizontalAlign-.5)*n,l=-(a.verticalAlign-.5)*r,u=t.evaluateVariableOffset(e,i);return new t.Point(s+u[0]*o,l+u[1]*o)}function xe(e,n,r,i,o,a){var s=e.x1,l=e.x2,u=e.y1,c=e.y2,h=e.anchorPointX,p=e.anchorPointY,f=new t.Point(n,r);return i&&f._rotate(o?a:-a),{x1:s+f.x,y1:u+f.y,x2:l+f.x,y2:c+f.y,anchorPointX:h,anchorPointY:p}}ve.prototype.get=function(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){var e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:function(t){return t.collisionGroupID===e}}}return this.collisionGroups[t]};var be=function(t,e,n,r){this.transform=t.clone(),this.collisionIndex=new he(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new ve(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}};function we(t,e,n,r,i){t.emplaceBack(e?1:0,n?1:0,r||0,i||0),t.emplaceBack(e?1:0,n?1:0,r||0,i||0),t.emplaceBack(e?1:0,n?1:0,r||0,i||0),t.emplaceBack(e?1:0,n?1:0,r||0,i||0)}be.prototype.getBucketParts=function(e,n,r,i){var o=r.getBucket(n),a=r.latestFeatureIndex;if(o&&a&&n.id===o.layerIds[0]){var s=r.collisionBoxArray,l=o.layers[0].layout,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/t.EXTENT,h=this.transform.calculatePosMatrix(r.tileID.toUnwrapped()),p="map"===l.get("text-pitch-alignment"),f="map"===l.get("text-rotation-alignment"),d=pe(r,1,this.transform.zoom),m=Kt(h,p,f,this.transform,d),g=null;if(p){var y=Qt(h,p,f,this.transform,d);g=t.multiply([],this.transform.labelPlaneMatrix,y)}this.retainedQueryData[o.bucketInstanceId]=new ye(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);var v={bucket:o,layout:l,posMatrix:h,textLabelPlaneMatrix:m,labelToScreenMatrix:g,scale:u,textPixelRatio:c,holdingForFade:r.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(var _=0,x=o.sortKeyRanges;_<x.length;_+=1){var b=x[_];e.push({sortKey:b.sortKey,symbolInstanceStart:b.symbolInstanceStart,symbolInstanceEnd:b.symbolInstanceEnd,parameters:v})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:v})}},be.prototype.attemptAnchorPlacement=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d){var m,g=[h.textOffset0,h.textOffset1],y=_e(t,n,r,g,i),v=this.collisionIndex.placeCollisionBox(xe(e,y.x,y.y,o,a,this.transform.angle),c,s,l,u.predicate);if(!d||0!==this.collisionIndex.placeCollisionBox(xe(d,y.x,y.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return v.box.length>0?(this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(m=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:g,width:n,height:r,anchor:t,textBoxScale:i,prevAnchor:m},this.markUsedJustification(p,t,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[h.crossTileID]=f),{shift:y,placedGlyphBoxes:v}):void 0},be.prototype.placeLayerBucketPart=function(e,n,r){var i=this,o=e.parameters,a=o.bucket,s=o.layout,l=o.posMatrix,u=o.textLabelPlaneMatrix,c=o.labelToScreenMatrix,h=o.textPixelRatio,p=o.holdingForFade,f=o.collisionBoxArray,d=o.partiallyEvaluatedTextSize,m=o.collisionGroup,g=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),_=s.get("icon-allow-overlap"),x="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),w="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order"),S=v&&(_||!a.hasIconData()||y),M=_&&(v||!a.hasTextData()||g);!a.collisionArrays&&f&&a.deserializeCollisionBoxes(f);var T=function(e,o){if(!n[e.crossTileID])if(p)i.placements[e.crossTileID]=new me(!1,!1,!1);else{var f,E=!1,T=!1,C=!0,I=null,A={box:null,offscreen:null},L={box:null,offscreen:null},P=null,R=null,D=0,N=0,O=0;o.textFeatureIndex?D=o.textFeatureIndex:e.useRuntimeCollisionCircles&&(D=e.featureIndex),o.verticalTextFeatureIndex&&(N=o.verticalTextFeatureIndex);var k=o.textBox;if(k){var z=function(n){var r=t.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&i.prevPlacement){var o=i.prevPlacement.placedOrientations[e.crossTileID];o&&(i.placedOrientations[e.crossTileID]=o,i.markUsedOrientation(a,r=o,e))}return r},F=function(n,r){if(a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&o.verticalTextBox)for(var i=0,s=a.writingModes;i<s.length&&(s[i]===t.WritingMode.vertical?(A=r(),L=A):A=n(),!(A&&A.box&&A.box.length));i+=1);else A=n()};if(s.get("text-variable-anchor")){var B=s.get("text-variable-anchor");if(i.prevPlacement&&i.prevPlacement.variableOffsets[e.crossTileID]){var U=i.prevPlacement.variableOffsets[e.crossTileID];B.indexOf(U.anchor)>0&&(B=B.filter((function(t){return t!==U.anchor}))).unshift(U.anchor)}var V=function(t,n,r){for(var o=t.x2-t.x1,s=t.y2-t.y1,u=e.textBoxScale,c=w&&!_?n:null,p={box:[],offscreen:!1},f=v?2*B.length:B.length,d=0;d<f;++d){var g=i.attemptAnchorPlacement(B[d%B.length],t,o,s,u,x,b,h,l,m,d>=B.length,e,a,r,c);if(g&&(p=g.placedGlyphBoxes)&&p.box&&p.box.length){E=!0,I=g.shift;break}}return p};F((function(){return V(k,o.iconBox,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&!(A&&A.box&&A.box.length)&&e.numVerticalGlyphVertices>0&&n?V(n,o.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),A&&(E=A.box,C=A.offscreen);var G=z(A&&A.box);if(!E&&i.prevPlacement){var j=i.prevPlacement.variableOffsets[e.crossTileID];j&&(i.variableOffsets[e.crossTileID]=j,i.markUsedJustification(a,j.anchor,e,G))}}else{var H=function(t,n){var r=i.collisionIndex.placeCollisionBox(t,v,h,l,m.predicate);return r&&r.box&&r.box.length&&(i.markUsedOrientation(a,n,e),i.placedOrientations[e.crossTileID]=n),r};F((function(){return H(k,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?H(n,t.WritingMode.vertical):{box:null,offscreen:null}})),z(A&&A.box&&A.box.length)}}if(E=(f=A)&&f.box&&f.box.length>0,C=f&&f.offscreen,e.useRuntimeCollisionCircles){var q=a.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),W=t.evaluateSizeForFeature(a.textSizeData,d,q),X=s.get("text-padding");P=i.collisionIndex.placeCollisionCircles(v,q,a.lineVertexArray,a.glyphOffsetArray,W,l,u,c,r,b,m.predicate,e.collisionCircleDiameter,X),E=v||P.circles.length>0&&!P.collisionDetected,C=C&&P.offscreen}if(o.iconFeatureIndex&&(O=o.iconFeatureIndex),o.iconBox){var Z=function(t){var e=w&&I?xe(t,I.x,I.y,x,b,i.transform.angle):t;return i.collisionIndex.placeCollisionBox(e,_,h,l,m.predicate)};T=L&&L.box&&L.box.length&&o.verticalIconBox?(R=Z(o.verticalIconBox)).box.length>0:(R=Z(o.iconBox)).box.length>0,C=C&&R.offscreen}var Y=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,J=y||0===e.numIconVertices;if(Y||J?J?Y||(T=T&&E):E=T&&E:T=E=T&&E,E&&f&&f.box&&i.collisionIndex.insertCollisionBox(f.box,s.get("text-ignore-placement"),a.bucketInstanceId,L&&L.box&&N?N:D,m.ID),T&&R&&i.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),a.bucketInstanceId,O,m.ID),P&&(E&&i.collisionIndex.insertCollisionCircles(P.circles,s.get("text-ignore-placement"),a.bucketInstanceId,D,m.ID),r)){var K=a.bucketInstanceId,Q=i.collisionCircleArrays[K];void 0===Q&&(Q=i.collisionCircleArrays[K]=new ge);for(var $=0;$<P.circles.length;$+=4)Q.circles.push(P.circles[$+0]),Q.circles.push(P.circles[$+1]),Q.circles.push(P.circles[$+2]),Q.circles.push(P.collisionDetected?1:0)}i.placements[e.crossTileID]=new me(E||S,T||M,C||a.justReloaded),n[e.crossTileID]=!0}};if(E)for(var C=a.getSortedSymbolIndexes(this.transform.angle),I=C.length-1;I>=0;--I){var A=C[I];T(a.symbolInstances.get(A),a.collisionArrays[A])}else for(var L=e.symbolInstanceStart;L<e.symbolInstanceEnd;L++)T(a.symbolInstances.get(L),a.collisionArrays[L]);if(r&&a.bucketInstanceId in this.collisionCircleArrays){var P=this.collisionCircleArrays[a.bucketInstanceId];t.invert(P.invProjMatrix,l),P.viewportMatrix=this.collisionIndex.getViewportMatrix()}a.justReloaded=!1},be.prototype.markUsedJustification=function(e,n,r,i){var o;o=i===t.WritingMode.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.getAnchorJustification(n)];for(var a=0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];a<s.length;a+=1){var l=s[a];l>=0&&(e.text.placedSymbolArray.get(l).crossTileID=o>=0&&l!==o?0:r.crossTileID)}},be.prototype.markUsedOrientation=function(e,n,r){for(var i=n===t.WritingMode.horizontal||n===t.WritingMode.horizontalOnly?n:0,o=n===t.WritingMode.vertical?n:0,a=0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];a<s.length;a+=1)e.text.placedSymbolArray.get(s[a]).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)},be.prototype.commit=function(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;var e=this.prevPlacement,n=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;var r=e?e.symbolFadeChange(t):1,i=e?e.opacities:{},o=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(var s in this.placements){var l=this.placements[s],u=i[s];u?(this.opacities[s]=new de(u,r,l.text,l.icon),n=n||l.text!==u.text.placed||l.icon!==u.icon.placed):(this.opacities[s]=new de(null,r,l.text,l.icon,l.skipFade),n=n||l.text||l.icon)}for(var c in i){var h=i[c];if(!this.opacities[c]){var p=new de(h,r,!1,!1);p.isHidden()||(this.opacities[c]=p,n=n||h.text.placed||h.icon.placed)}}for(var f in o)this.variableOffsets[f]||!this.opacities[f]||this.opacities[f].isHidden()||(this.variableOffsets[f]=o[f]);for(var d in a)this.placedOrientations[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.placedOrientations[d]=a[d]);n?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)},be.prototype.updateLayerOpacities=function(t,e){for(var n={},r=0,i=e;r<i.length;r+=1){var o=i[r],a=o.getBucket(t);a&&o.latestFeatureIndex&&t.id===a.layerIds[0]&&this.updateBucketOpacities(a,n,o.collisionBoxArray)}},be.prototype.updateBucketOpacities=function(e,n,r){var i=this;e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();var o=e.layers[0].layout,a=new de(null,0,!1,!1,!0),s=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),u=o.get("text-variable-anchor"),c="map"===o.get("text-rotation-alignment"),h="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),f=new de(null,0,s&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(s||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);for(var d=function(t,e,n){for(var r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(n)},m=function(r){var o=e.symbolInstances.get(r),s=o.numHorizontalGlyphVertices,l=o.numVerticalGlyphVertices,m=o.crossTileID,g=i.opacities[m];n[m]?g=a:g||(i.opacities[m]=g=f),n[m]=!0;var y=o.numIconVertices>0,v=i.placedOrientations[o.crossTileID],_=v===t.WritingMode.vertical,x=v===t.WritingMode.horizontal||v===t.WritingMode.horizontalOnly;if(s>0||l>0){var b=Le(g.text);d(e.text,s,_?Pe:b),d(e.text,l,x?Pe:b);var w=g.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((function(t){t>=0&&(e.text.placedSymbolArray.get(t).hidden=w||_?1:0)})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=w||x?1:0);var E=i.variableOffsets[o.crossTileID];E&&i.markUsedJustification(e,E.anchor,o,v);var S=i.placedOrientations[o.crossTileID];S&&(i.markUsedJustification(e,"left",o,S),i.markUsedOrientation(e,S,o))}if(y){var M=Le(g.icon),T=!(p&&o.verticalPlacedIconSymbolIndex&&_);o.placedIconSymbolIndex>=0&&(d(e.icon,o.numIconVertices,T?M:Pe),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=g.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(d(e.icon,o.numVerticalIconVertices,T?Pe:M),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){var C=e.collisionArrays[r];if(C){var I=new t.Point(0,0);if(C.textBox||C.verticalTextBox){var A=!0;if(u){var L=i.variableOffsets[m];L?(I=_e(L.anchor,L.width,L.height,L.textOffset,L.textBoxScale),c&&I._rotate(h?i.transform.angle:-i.transform.angle)):A=!1}C.textBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!A||_,I.x,I.y),C.verticalTextBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!A||x,I.x,I.y)}var P=Boolean(!x&&C.verticalIconBox);C.iconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,P,p?I.x:0,p?I.y:0),C.verticalIconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!P,p?I.x:0,p?I.y:0)}}},g=0;g<e.symbolInstances.length;g++)m(g);if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){var y=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=y.invProjMatrix,e.placementViewportMatrix=y.viewportMatrix,e.collisionCircleArray=y.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}},be.prototype.symbolFadeChange=function(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment},be.prototype.zoomAdjustment=function(t){return Math.max(0,(this.transform.zoom-t)/1.5)},be.prototype.hasTransitions=function(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration},be.prototype.stillRecent=function(t,e){var n=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*n>t},be.prototype.setStale=function(){this.stale=!0};var Ee=Math.pow(2,25),Se=Math.pow(2,24),Me=Math.pow(2,17),Te=Math.pow(2,16),Ce=Math.pow(2,9),Ie=Math.pow(2,8),Ae=Math.pow(2,1);function Le(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Ee+e*Se+n*Me+e*Te+n*Ce+e*Ie+n*Ae+e}var Pe=0,Re=function(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]};Re.prototype.continuePlacement=function(t,e,n,r,i){for(var o=this._bucketParts;this._currentTileIndex<t.length;)if(e.getBucketParts(o,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,i())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort((function(t,e){return t.sortKey-e.sortKey})));this._currentPartIndex<o.length;)if(e.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,n),this._currentPartIndex++,i())return!0;return!1};var De=function(t,e,n,r,i,o,a){this.placement=new be(t,i,o,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=n,this._showCollisionBoxes=r,this._done=!1};De.prototype.isDone=function(){return this._done},De.prototype.continuePlacement=function(e,n,r){for(var i=this,o=t.browser.now(),a=function(){var e=t.browser.now()-o;return!i._forceFullPlacement&&e>2};this._currentPlacementIndex>=0;){var s=n[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(this._inProgressLayer||(this._inProgressLayer=new Re(s)),this._inProgressLayer.continuePlacement(r[s.source],this.placement,this._showCollisionBoxes,s,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0},De.prototype.commit=function(t){return this.placement.commit(t),this.placement};var Ne=512/t.EXTENT/2,Oe=function(t,e,n){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(var r=0;r<e.length;r++){var i=e.get(r),o=i.key;this.indexedSymbolInstances[o]||(this.indexedSymbolInstances[o]=[]),this.indexedSymbolInstances[o].push({crossTileID:i.crossTileID,coord:this.getScaledCoordinates(i,t)})}};Oe.prototype.getScaledCoordinates=function(e,n){var r=Ne/Math.pow(2,n.canonical.z-this.tileID.canonical.z);return{x:Math.floor((n.canonical.x*t.EXTENT+e.anchorX)*r),y:Math.floor((n.canonical.y*t.EXTENT+e.anchorY)*r)}},Oe.prototype.findMatches=function(t,e,n){for(var r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z),i=0;i<t.length;i++){var o=t.get(i);if(!o.crossTileID){var a=this.indexedSymbolInstances[o.key];if(a)for(var s=this.getScaledCoordinates(o,e),l=0,u=a;l<u.length;l+=1){var c=u[l];if(Math.abs(c.coord.x-s.x)<=r&&Math.abs(c.coord.y-s.y)<=r&&!n[c.crossTileID]){n[c.crossTileID]=!0,o.crossTileID=c.crossTileID;break}}}}};var ke=function(){this.maxCrossTileID=0};ke.prototype.generate=function(){return++this.maxCrossTileID};var ze=function(){this.indexes={},this.usedCrossTileIDs={},this.lng=0};ze.prototype.handleWrapJump=function(t){var e=Math.round((t-this.lng)/360);if(0!==e)for(var n in this.indexes){var r=this.indexes[n],i={};for(var o in r){var a=r[o];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+e),i[a.tileID.key]=a}this.indexes[n]=i}this.lng=t},ze.prototype.addBucket=function(t,e,n){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(var r=0;r<e.symbolInstances.length;r++)e.symbolInstances.get(r).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});var i=this.usedCrossTileIDs[t.overscaledZ];for(var o in this.indexes){var a=this.indexes[o];if(Number(o)>t.overscaledZ)for(var s in a){var l=a[s];l.tileID.isChildOf(t)&&l.findMatches(e.symbolInstances,t,i)}else{var u=a[t.scaledTo(Number(o)).key];u&&u.findMatches(e.symbolInstances,t,i)}}for(var c=0;c<e.symbolInstances.length;c++){var h=e.symbolInstances.get(c);h.crossTileID||(h.crossTileID=n.generate(),i[h.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Oe(t,e.symbolInstances,e.bucketInstanceId),!0},ze.prototype.removeBucketCrossTileIDs=function(t,e){for(var n in e.indexedSymbolInstances)for(var r=0,i=e.indexedSymbolInstances[n];r<i.length;r+=1)delete this.usedCrossTileIDs[t][i[r].crossTileID]},ze.prototype.removeStaleBuckets=function(t){var e=!1;for(var n in this.indexes){var r=this.indexes[n];for(var i in r)t[r[i].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,r[i]),delete r[i],e=!0)}return e};var Fe=function(){this.layerIndexes={},this.crossTileIDs=new ke,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}};Fe.prototype.addLayer=function(t,e,n){var r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new ze);var i=!1,o={};r.handleWrapJump(n);for(var a=0,s=e;a<s.length;a+=1){var l=s[a],u=l.getBucket(t);u&&t.id===u.layerIds[0]&&(u.bucketInstanceId||(u.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(l.tileID,u,this.crossTileIDs)&&(i=!0),o[u.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(i=!0),i},Fe.prototype.pruneUnusedLayers=function(t){var e={};for(var n in t.forEach((function(t){e[t]=!0})),this.layerIndexes)e[n]||delete this.layerIndexes[n]};var Be=function(e,n){return t.emitValidationErrors(e,n&&n.filter((function(t){return"source.canvas"!==t.identifier})))},Ue=t.pick(Vt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),Ve=t.pick(Vt,["setCenter","setZoom","setBearing","setPitch"]),Ge=function(){var e={},n=t.styleSpec.$version;for(var r in t.styleSpec.$root){var i,o=t.styleSpec.$root[r];o.required&&null!=(i="version"===r?n:"array"===o.type?[]:{})&&(e[r]=i)}return e}(),je=function(e){function n(r,i){var o=this;void 0===i&&(i={}),e.call(this),this.map=r,this.dispatcher=new S(Ft(),this),this.imageManager=new p,this.imageManager.setEventedParent(this),this.glyphManager=new _(r._requestManager,i.localIdeographFontFamily),this.lineAtlas=new E(256,512),this.crossTileSymbolIndex=new Fe,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());var a=this;this._rtlTextPluginCallback=n.registerForPluginStateChange((function(e){a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},(function(e,n){if(t.triggerPluginCompletionEvent(e),n&&n.every((function(t){return t})))for(var r in a.sourceCaches)a.sourceCaches[r].reload()}))})),this.on("data",(function(t){if("source"===t.dataType&&"metadata"===t.sourceDataType){var e=o.sourceCaches[t.sourceId];if(e){var n=e.getSource();if(n&&n.vectorLayerIds)for(var r in o._layers){var i=o._layers[r];i.source===n.id&&o._validateLayer(i)}}}}))}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.loadURL=function(e,n){var r=this;void 0===n&&(n={}),this.fire(new t.Event("dataloading",{dataType:"style"}));var i="boolean"==typeof n.validate?n.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,n.accessToken);var o=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(o,(function(e,n){r._request=null,e?r.fire(new t.ErrorEvent(e)):n&&r._load(n,i)}))},n.prototype.loadJSON=function(e,n){var r=this;void 0===n&&(n={}),this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.browser.frame((function(){r._request=null,r._load(e,!1!==n.validate)}))},n.prototype.loadEmpty=function(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Ge,!1)},n.prototype._load=function(e,n){if(!n||!Be(this,t.validateStyle(e))){for(var r in this._loaded=!0,this.stylesheet=e,e.sources)this.addSource(r,e.sources[r],{validate:!1});e.sprite?this._loadSprite(e.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var i=Ut(this.stylesheet.layers);this._order=i.map((function(t){return t.id})),this._layers={},this._serializedLayers={};for(var o=0,a=i;o<a.length;o+=1){var s=a[o];(s=t.createStyleLayer(s)).setEventedParent(this,{layer:{id:s.id}}),this._layers[s.id]=s,this._serializedLayers[s.id]=s.serialize()}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new w(this.stylesheet.light),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}},n.prototype._loadSprite=function(e){var n=this;this._spriteRequest=function(e,n,r){var i,o,a,s=t.browser.devicePixelRatio>1?"@2x":"",l=t.getJSON(n.transformRequest(n.normalizeSpriteURL(e,s,".json"),t.ResourceType.SpriteJSON),(function(t,e){l=null,a||(a=t,i=e,c())})),u=t.getImage(n.transformRequest(n.normalizeSpriteURL(e,s,".png"),t.ResourceType.SpriteImage),(function(t,e){u=null,a||(a=t,o=e,c())}));function c(){if(a)r(a);else if(i&&o){var e=t.browser.getImageData(o),n={};for(var s in i){var l=i[s],u=l.width,c=l.height,h=l.x,p=l.y,f=l.sdf,d=l.pixelRatio,m=l.stretchX,g=l.stretchY,y=l.content,v=new t.RGBAImage({width:u,height:c});t.RGBAImage.copy(e,v,{x:h,y:p},{x:0,y:0},{width:u,height:c}),n[s]={data:v,pixelRatio:d,sdf:f,stretchX:m,stretchY:g,content:y}}r(null,n)}}return{cancel:function(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(e,this.map._requestManager,(function(e,r){if(n._spriteRequest=null,e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n._availableImages=n.imageManager.listImages(),n.dispatcher.broadcast("setImages",n._availableImages),n.fire(new t.Event("data",{dataType:"style"}))}))},n.prototype._validateLayer=function(e){var n=this.sourceCaches[e.source];if(n){var r=e.sourceLayer;if(r){var i=n.getSource();("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error('Source layer "'+r+'" does not exist on source "'+i.id+'" as specified by style layer "'+e.id+'"')))}}},n.prototype.loaded=function(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(var t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()},n.prototype._serializeLayers=function(t){for(var e=[],n=0,r=t;n<r.length;n+=1){var i=this._layers[r[n]];"custom"!==i.type&&e.push(i.serialize())}return e},n.prototype.hasTransitions=function(){if(this.light&&this.light.hasTransition())return!0;for(var t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(var e in this._layers)if(this._layers[e].hasTransition())return!0;return!1},n.prototype._checkLoaded=function(){if(!this._loaded)throw new Error("Style is not done loading")},n.prototype.update=function(e){if(this._loaded){var n=this._changed;if(this._changed){var r=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);for(var o in(r.length||i.length)&&this._updateWorkerLayers(r,i),this._updatedSources){var a=this._updatedSources[o];"reload"===a?this._reloadSource(o):"clear"===a&&this._clearSource(o)}for(var s in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[s].updateTransitions(e);this.light.updateTransitions(e),this._resetUpdates()}var l={};for(var u in this.sourceCaches){var c=this.sourceCaches[u];l[u]=c.used,c.used=!1}for(var h=0,p=this._order;h<p.length;h+=1){var f=this._layers[p[h]];f.recalculate(e,this._availableImages),!f.isHidden(e.zoom)&&f.source&&(this.sourceCaches[f.source].used=!0)}for(var d in l){var m=this.sourceCaches[d];l[d]!==m.used&&m.fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:d}))}this.light.recalculate(e),this.z=e.zoom,n&&this.fire(new t.Event("data",{dataType:"style"}))}},n.prototype._updateTilesForChangedImages=function(){var t=Object.keys(this._changedImages);if(t.length){for(var e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}},n.prototype._updateWorkerLayers=function(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})},n.prototype._resetUpdates=function(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}},n.prototype.setState=function(e){var n=this;if(this._checkLoaded(),Be(this,t.validateStyle(e)))return!1;(e=t.clone$1(e)).layers=Ut(e.layers);var r=function(e,n){if(!e)return[{command:Vt.setStyle,args:[n]}];var r=[];try{if(!t.deepEqual(e.version,n.version))return[{command:Vt.setStyle,args:[n]}];t.deepEqual(e.center,n.center)||r.push({command:Vt.setCenter,args:[n.center]}),t.deepEqual(e.zoom,n.zoom)||r.push({command:Vt.setZoom,args:[n.zoom]}),t.deepEqual(e.bearing,n.bearing)||r.push({command:Vt.setBearing,args:[n.bearing]}),t.deepEqual(e.pitch,n.pitch)||r.push({command:Vt.setPitch,args:[n.pitch]}),t.deepEqual(e.sprite,n.sprite)||r.push({command:Vt.setSprite,args:[n.sprite]}),t.deepEqual(e.glyphs,n.glyphs)||r.push({command:Vt.setGlyphs,args:[n.glyphs]}),t.deepEqual(e.transition,n.transition)||r.push({command:Vt.setTransition,args:[n.transition]}),t.deepEqual(e.light,n.light)||r.push({command:Vt.setLight,args:[n.light]});var i={},o=[];!function(e,n,r,i){var o;for(o in n=n||{},e=e||{})e.hasOwnProperty(o)&&(n.hasOwnProperty(o)||jt(o,r,i));for(o in n)n.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t.deepEqual(e[o],n[o])||("geojson"===e[o].type&&"geojson"===n[o].type&&qt(e,n,o)?r.push({command:Vt.setGeoJSONSourceData,args:[o,n[o].data]}):Ht(o,n,r,i)):Gt(o,n,r))}(e.sources,n.sources,o,i);var a=[];e.layers&&e.layers.forEach((function(t){i[t.source]?r.push({command:Vt.removeLayer,args:[t.id]}):a.push(t)})),r=r.concat(o),function(e,n,r){n=n||[];var i,o,a,s,l,u,c,h=(e=e||[]).map(Xt),p=n.map(Xt),f=e.reduce(Zt,{}),d=n.reduce(Zt,{}),m=h.slice(),g=Object.create(null);for(i=0,o=0;i<h.length;i++)d.hasOwnProperty(a=h[i])?o++:(r.push({command:Vt.removeLayer,args:[a]}),m.splice(m.indexOf(a,o),1));for(i=0,o=0;i<p.length;i++)m[m.length-1-i]!==(a=p[p.length-1-i])&&(f.hasOwnProperty(a)?(r.push({command:Vt.removeLayer,args:[a]}),m.splice(m.lastIndexOf(a,m.length-o),1)):o++,r.push({command:Vt.addLayer,args:[d[a],u=m[m.length-i]]}),m.splice(m.length-i,0,a),g[a]=!0);for(i=0;i<p.length;i++)if(s=f[a=p[i]],l=d[a],!g[a]&&!t.deepEqual(s,l))if(t.deepEqual(s.source,l.source)&&t.deepEqual(s["source-layer"],l["source-layer"])&&t.deepEqual(s.type,l.type)){for(c in Wt(s.layout,l.layout,r,a,null,Vt.setLayoutProperty),Wt(s.paint,l.paint,r,a,null,Vt.setPaintProperty),t.deepEqual(s.filter,l.filter)||r.push({command:Vt.setFilter,args:[a,l.filter]}),t.deepEqual(s.minzoom,l.minzoom)&&t.deepEqual(s.maxzoom,l.maxzoom)||r.push({command:Vt.setLayerZoomRange,args:[a,l.minzoom,l.maxzoom]}),s)s.hasOwnProperty(c)&&"layout"!==c&&"paint"!==c&&"filter"!==c&&"metadata"!==c&&"minzoom"!==c&&"maxzoom"!==c&&(0===c.indexOf("paint.")?Wt(s[c],l[c],r,a,c.slice(6),Vt.setPaintProperty):t.deepEqual(s[c],l[c])||r.push({command:Vt.setLayerProperty,args:[a,c,l[c]]}));for(c in l)l.hasOwnProperty(c)&&!s.hasOwnProperty(c)&&"layout"!==c&&"paint"!==c&&"filter"!==c&&"metadata"!==c&&"minzoom"!==c&&"maxzoom"!==c&&(0===c.indexOf("paint.")?Wt(s[c],l[c],r,a,c.slice(6),Vt.setPaintProperty):t.deepEqual(s[c],l[c])||r.push({command:Vt.setLayerProperty,args:[a,c,l[c]]}))}else r.push({command:Vt.removeLayer,args:[a]}),u=m[m.lastIndexOf(a)+1],r.push({command:Vt.addLayer,args:[l,u]})}(a,n.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:Vt.setStyle,args:[n]}]}return r}(this.serialize(),e).filter((function(t){return!(t.command in Ve)}));if(0===r.length)return!1;var i=r.filter((function(t){return!(t.command in Ue)}));if(i.length>0)throw new Error("Unimplemented: "+i.map((function(t){return t.command})).join(", ")+".");return r.forEach((function(t){"setTransition"!==t.command&&n[t.command].apply(n,t.args)})),this.stylesheet=e,!0},n.prototype.addImage=function(e,n){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,n),this._afterImageUpdated(e)},n.prototype.updateImage=function(t,e){this.imageManager.updateImage(t,e)},n.prototype.getImage=function(t){return this.imageManager.getImage(t)},n.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this._afterImageUpdated(e)},n.prototype._afterImageUpdated=function(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.listImages=function(){return this._checkLoaded(),this.imageManager.listImages()},n.prototype.addSource=function(e,n,r){var i=this;if(void 0===r&&(r={}),this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but only the following properties were given: "+Object.keys(n).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,n,null,r))){this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);var o=this.sourceCaches[e]=new Lt(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,(function(){return{isSourceLoaded:i.loaded(),source:o.serialize(),sourceId:e}})),o.onAdd(this.map),this._changed=!0}},n.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+n+'" is using it.')));var r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.clearTiles(),r.onRemove&&r.onRemove(this.map),this._changed=!0},n.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},n.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},n.prototype.addLayer=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else{var o;if("custom"===e.type){if(Be(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone$1(e),e=t.extend(e,{source:i})),this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize()}var a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.')));else{if(this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o,this._removedLayers[i]&&o.source&&"custom"!==o.type){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}},n.prototype.moveLayer=function(e,n){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==n){var r=this._order.indexOf(e);this._order.splice(r,1);var i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},n.prototype.removeLayer=function(e){this._checkLoaded();var n=this._layers[e];if(n){n.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},n.prototype.getLayer=function(t){return this._layers[t]},n.prototype.hasLayer=function(t){return t in this._layers},n.prototype.setLayerZoomRange=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},n.prototype.setFilter=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.deepEqual(i.filter,n))return null==n?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(t.validateStyle.filter,"layers."+i.id+".filter",n,null,r)||(i.filter=t.clone$1(n),this._updateLayer(i)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},n.prototype.getFilter=function(e){return t.clone$1(this.getLayer(e).filter)},n.prototype.setLayoutProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getLayoutProperty(n),r)||(o.setLayoutProperty(n,r,i),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getLayoutProperty=function(e,n){var r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style.")))},n.prototype.setPaintProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getPaintProperty(n),r)||(o.setPaintProperty(n,r,i)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},n.prototype.setFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=e.sourceLayer,o=this.sourceCaches[r];if(void 0!==o){var a=o.getSource().type;"geojson"===a&&i?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||i?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),o.setFeatureState(i,e.id,n)):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.removeFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=this.sourceCaches[r];if(void 0!==i){var o=i.getSource().type,a="vector"===o?e.sourceLayer:void 0;"vector"!==o||a?n&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(a,e.id,n):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.getFeatureState=function(e){this._checkLoaded();var n=e.source,r=e.sourceLayer,i=this.sourceCaches[n];if(void 0!==i){if("vector"!==i.getSource().type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+n+"' does not exist in the map's style.")))},n.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},n.prototype.serialize=function(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,(function(t){return t.serialize()})),layers:this._serializeLayers(this._order)},(function(t){return void 0!==t}))},n.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},n.prototype._flattenAndSortRenderedFeatures=function(t){for(var e=this,n=function(t){return"fill-extrusion"===e._layers[t].type},r={},i=[],o=this._order.length-1;o>=0;o--){var a=this._order[o];if(n(a)){r[a]=o;for(var s=0,l=t;s<l.length;s+=1){var u=l[s][a];if(u)for(var c=0,h=u;c<h.length;c+=1)i.push(h[c])}}}i.sort((function(t,e){return e.intersectionZ-t.intersectionZ}));for(var p=[],f=this._order.length-1;f>=0;f--){var d=this._order[f];if(n(d))for(var m=i.length-1;m>=0;m--){var g=i[m].feature;if(r[g.layer.id]<f)break;p.push(g),i.pop()}else for(var y=0,v=t;y<v.length;y+=1){var _=v[y][d];if(_)for(var x=0,b=_;x<b.length;x+=1)p.push(b[x].feature)}}return p},n.prototype.queryRenderedFeatures=function(e,n,r){n&&n.filter&&this._validate(t.validateStyle.filter,"queryRenderedFeatures.filter",n.filter,null,n);var i={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(var o=0,a=n.layers;o<a.length;o+=1){var s=a[o],l=this._layers[s];if(!l)return this.fire(new t.ErrorEvent(new Error("The layer '"+s+"' does not exist in the map's style and cannot be queried for features."))),[];i[l.source]=!0}}var u=[];for(var c in n.availableImages=this._availableImages,this.sourceCaches)n.layers&&!i[c]||u.push(z(this.sourceCaches[c],this._layers,this._serializedLayers,e,n,r));return this.placement&&u.push(function(t,e,n,r,i,o,a){for(var s={},l=o.queryRenderedSymbols(r),u=[],c=0,h=Object.keys(l).map(Number);c<h.length;c+=1)u.push(a[h[c]]);u.sort(F);for(var p=function(){var n=d[f],r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],e,n.bucketIndex,n.sourceLayerIndex,i.filter,i.layers,i.availableImages,t);for(var o in r){var a=s[o]=s[o]||[],u=r[o];u.sort((function(t,e){var r=n.featureSortOrder;if(r){var i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(var c=0,h=u;c<h.length;c+=1)a.push(h[c])}},f=0,d=u;f<d.length;f+=1)p();var m=function(e){s[e].forEach((function(r){var i=r.feature,o=n[t[e].source].getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o}))};for(var g in s)m(g);return s}(this._layers,this._serializedLayers,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)},n.prototype.querySourceFeatures=function(e,n){n&&n.filter&&this._validate(t.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);var r=this.sourceCaches[e];return r?function(t,e){for(var n=t.getRenderableIds().map((function(e){return t.getTileByID(e)})),r=[],i={},o=0;o<n.length;o++){var a=n[o],s=a.tileID.canonical.key;i[s]||(i[s]=!0,a.querySourceFeatures(r,e))}return r}(r,n):[]},n.prototype.addSourceType=function(t,e,r){return n.getSourceType(t)?r(new Error('A source type called "'+t+'" already exists.')):(n.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},r):r(null,null))},n.prototype.getLight=function(){return this.light.getLight()},n.prototype.setLight=function(e,n){void 0===n&&(n={}),this._checkLoaded();var r=this.light.getLight(),i=!1;for(var o in e)if(!t.deepEqual(e[o],r[o])){i=!0;break}if(i){var a={now:t.browser.now(),transition:t.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(a)}},n.prototype._validate=function(e,n,r,i,o){return void 0===o&&(o={}),(!o||!1!==o.validate)&&Be(this,e.call(t.validateStyle,t.extend({key:n,style:this.serialize(),value:r,styleSpec:t.styleSpec},i)))},n.prototype._remove=function(){for(var e in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[e].setEventedParent(null);for(var n in this.sourceCaches)this.sourceCaches[n].clearTiles(),this.sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()},n.prototype._clearSource=function(t){this.sourceCaches[t].clearTiles()},n.prototype._reloadSource=function(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()},n.prototype._updateSources=function(t){for(var e in this.sourceCaches)this.sourceCaches[e].update(t)},n.prototype._generateCollisionBoxes=function(){for(var t in this.sourceCaches)this._reloadSource(t)},n.prototype._updatePlacement=function(e,n,r,i,o){void 0===o&&(o=!1);for(var a=!1,s=!1,l={},u=0,c=this._order;u<c.length;u+=1){var h=this._layers[c[u]];if("symbol"===h.type){if(!l[h.source]){var p=this.sourceCaches[h.source];l[h.source]=p.getRenderableIds(!0).map((function(t){return p.getTileByID(t)})).sort((function(t,e){return e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)}))}var f=this.crossTileSymbolIndex.addLayer(h,l[h.source],e.center.lng);a=a||f}}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===r)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.browser.now(),e.zoom))&&(this.pauseablePlacement=new De(e,this._order,o,n,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.browser.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(var d=0,m=this._order;d<m.length;d+=1){var g=this._layers[m[d]];"symbol"===g.type&&this.placement.updateLayerOpacities(g,l[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.browser.now())},n.prototype._releaseSymbolFadeTiles=function(){for(var t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()},n.prototype.getImages=function(t,e,n){this.imageManager.getImages(e.icons,n),this._updateTilesForChangedImages();var r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)},n.prototype.getGlyphs=function(t,e,n){this.glyphManager.getGlyphs(e.stacks,n)},n.prototype.getResource=function(e,n,r){return t.makeRequest(n,r)},n}(t.Evented);je.getSourceType=function(t){return O[t]},je.setSourceType=function(t,e){O[t]=e},je.registerForPluginStateChange=t.registerForPluginStateChange;var He=t.createLayout([{name:"a_pos",type:"Int16",components:2}]),qe=vn("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}"),We=vn("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),Xe=vn("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),Ze=vn("varying vec3 v_data;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,0,1);} else {gl_Position=u_matrix*vec4(circle_center,0,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),Ye=vn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),Je=vn("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}"),Ke=vn("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),Qe=vn("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,0.0,1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),$e=vn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),tn=vn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,0,1);}"),en=vn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),nn=vn("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),rn=vn("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),on=vn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),an=vn("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),sn=vn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),ln=vn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),un=vn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),cn=vn("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),hn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),pn=vn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),fn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),dn=vn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),mn=vn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),0.0,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));}"),gn=vn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),0.0,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),yn=vn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),0.0,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}");function vn(t,e){var n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),i=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=o?o.concat(i):i,s={};return{fragmentSource:t=t.replace(n,(function(t,e,n,r,i){return s[i]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),vertexSource:e=e.replace(n,(function(t,e,n,r,i){var o="float"===r?"vec2":"vec4",a=i.match(/color/)?"color":o;return s[i]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),staticAttributes:r,staticUniforms:a}}var _n=Object.freeze({__proto__:null,prelude:qe,background:We,backgroundPattern:Xe,circle:Ze,clippingMask:Ye,heatmap:Je,heatmapTexture:Ke,collisionBox:Qe,collisionCircle:$e,debug:tn,fill:en,fillOutline:nn,fillOutlinePattern:rn,fillPattern:on,fillExtrusion:an,fillExtrusionPattern:sn,hillshadePrepare:ln,hillshade:un,line:cn,lineGradient:hn,linePattern:pn,lineSDF:fn,raster:dn,symbolIcon:mn,symbolSDF:gn,symbolTextAndIcon:yn}),xn=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};function bn(t){for(var e=[],n=0;n<t.length;n++)if(null!==t[n]){var r=t[n].split(" ");e.push(r.pop())}return e}xn.prototype.bind=function(t,e,n,r,i,o,a,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==r.length,u=0;!l&&u<r.length;u++)this.boundPaintVertexBuffers[u]!==r[u]&&(l=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===n&&!l&&this.boundIndexBuffer===i&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===a&&this.boundDynamicVertexBuffer2===s?(t.bindVertexArrayOES.set(this.vao),a&&a.bind(),i&&i.dynamicDraw&&i.bind(),s&&s.bind()):this.freshBind(e,n,r,i,o,a,s)},xn.prototype.freshBind=function(t,e,n,r,i,o,a){var s,l=t.numAttributes,u=this.context,c=u.gl;if(u.extVertexArrayObject)this.vao&&this.destroy(),this.vao=u.extVertexArrayObject.createVertexArrayOES(),u.bindVertexArrayOES.set(this.vao),s=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=r,this.boundVertexOffset=i,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=a;else{s=u.currentNumAttributes||0;for(var h=l;h<s;h++)c.disableVertexAttribArray(h)}e.enableAttributes(c,t);for(var p=0,f=n;p<f.length;p+=1)f[p].enableAttributes(c,t);o&&o.enableAttributes(c,t),a&&a.enableAttributes(c,t),e.bind(),e.setVertexAttribPointers(c,t,i);for(var d=0,m=n;d<m.length;d+=1){var g=m[d];g.bind(),g.setVertexAttribPointers(c,t,i)}o&&(o.bind(),o.setVertexAttribPointers(c,t,i)),r&&r.bind(),a&&(a.bind(),a.setVertexAttribPointers(c,t,i)),u.currentNumAttributes=l},xn.prototype.destroy=function(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)};var wn=function(t,e,n,r,i,o){var a=t.gl;this.program=a.createProgram();for(var s=bn(n.staticAttributes),l=r?r.getBinderAttributes():[],u=s.concat(l),c=n.staticUniforms?bn(n.staticUniforms):[],h=r?r.getBinderUniforms():[],p=[],f=0,d=c.concat(h);f<d.length;f+=1){var m=d[f];p.indexOf(m)<0&&p.push(m)}var g=r?r.defines():[];o&&g.push("#define OVERDRAW_INSPECTOR;");var y=g.concat(qe.fragmentSource,n.fragmentSource).join("\n"),v=g.concat(qe.vertexSource,n.vertexSource).join("\n"),_=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(_,y),a.compileShader(_),a.attachShader(this.program,_);var x=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(x,v),a.compileShader(x),a.attachShader(this.program,x),this.attributes={};var b={};this.numAttributes=u.length;for(var w=0;w<this.numAttributes;w++)u[w]&&(a.bindAttribLocation(this.program,w,u[w]),this.attributes[u[w]]=w);a.linkProgram(this.program),a.deleteShader(x),a.deleteShader(_);for(var E=0;E<p.length;E++){var S=p[E];if(S&&!b[S]){var M=a.getUniformLocation(this.program,S);M&&(b[S]=M)}}this.fixedUniforms=i(t,b),this.binderUniforms=r?r.getUniforms(t,b):[]}}};function En(t,e,n){var r=1/pe(n,1,e.transform.tileZoom),i=Math.pow(2,n.tileID.overscaledZ),o=n.tileSize*Math.pow(2,e.transform.tileZoom)/i,a=o*(n.tileID.canonical.x+n.tileID.wrap*i),s=o*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}wn.prototype.draw=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){var g,y=t.gl;if(!this.failedToCreate){for(var v in t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(r),t.setColorMode(i),t.setCullFace(o),this.fixedUniforms)this.fixedUniforms[v].set(a[v]);f&&f.setUniforms(t,this.binderUniforms,h,{zoom:p});for(var _=(g={},g[y.LINES]=2,g[y.TRIANGLES]=3,g[y.LINE_STRIP]=1,g)[e],x=0,b=c.get();x<b.length;x+=1){var w=b[x],E=w.vaos||(w.vaos={});(E[s]||(E[s]=new xn)).bind(t,this,l,f?f.getPaintVertexBuffers():[],u,w.vertexOffset,d,m),y.drawElements(e,w.primitiveLength*_,y.UNSIGNED_SHORT,w.primitiveOffset*_*2)}}};var Sn=function(e,n,r,i){var o=n.style.light,a=o.properties.get("position"),s=[a.x,a.y,a.z],l=t.create$1();"viewport"===o.properties.get("anchor")&&t.fromRotation(l,-n.transform.angle),t.transformMat3(s,s,l);var u=o.properties.get("color");return{u_matrix:e,u_lightpos:s,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+r,u_opacity:i}},Mn=function(e,n,r,i,o,a,s){return t.extend(Sn(e,n,r,i),En(a,n,s),{u_height_factor:-Math.pow(2,o.overscaledZ)/s.tileSize/8})},Tn=function(t){return{u_matrix:t}},Cn=function(e,n,r,i){return t.extend(Tn(e),En(r,n,i))},In=function(t,e){return{u_matrix:t,u_world:e}},An=function(e,n,r,i,o){return t.extend(Cn(e,n,r,i),{u_world:o})},Ln=function(e,n,r,i){var o,a,s=e.transform;if("map"===i.paint.get("circle-pitch-alignment")){var l=pe(r,1,s.zoom);o=!0,a=[l,l]}else o=!1,a=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_matrix:e.translatePosMatrix(n.posMatrix,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),u_pitch_with_map:+o,u_device_pixel_ratio:t.browser.devicePixelRatio,u_extrude_scale:a}},Pn=function(t,e,n){var r=pe(n,1,e.zoom),i=Math.pow(2,e.zoom-n.tileID.overscaledZ),o=n.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*i),e.pixelsToGLUnits[1]/(r*i)],u_overscale_factor:o}},Rn=function(t,e,n){return{u_matrix:t,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}},Dn=function(t,e,n){return void 0===n&&(n=1),{u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:n}},Nn=function(t){return{u_matrix:t}},On=function(t,e,n,r){return{u_matrix:t,u_extrude_scale:pe(e,1,n),u_intensity:r}},kn=function(e,n,r){var i=e.transform;return{u_matrix:Vn(e,n,r),u_ratio:1/pe(n,1,i.zoom),u_device_pixel_ratio:t.browser.devicePixelRatio,u_units_to_pixels:[1/i.pixelsToGLUnits[0],1/i.pixelsToGLUnits[1]]}},zn=function(e,n,r,i){return t.extend(kn(e,n,r),{u_image:0,u_image_height:i})},Fn=function(e,n,r,i){var o=e.transform,a=Un(n,o);return{u_matrix:Vn(e,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:1/pe(n,1,o.zoom),u_device_pixel_ratio:t.browser.devicePixelRatio,u_image:0,u_scale:[a,i.fromScale,i.toScale],u_fade:i.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Bn=function(e,n,r,i,o){var a=e.lineAtlas,s=Un(n,e.transform),l="round"===r.layout.get("line-cap"),u=a.getDash(i.from,l),c=a.getDash(i.to,l),h=u.width*o.fromScale,p=c.width*o.toScale;return t.extend(kn(e,n,r),{u_patternscale_a:[s/h,-u.height/2],u_patternscale_b:[s/p,-c.height/2],u_sdfgamma:a.width/(256*Math.min(h,p)*t.browser.devicePixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:c.y,u_mix:o.t})};function Un(t,e){return 1/pe(t,1,e.tileZoom)}function Vn(t,e,n){return t.translatePosMatrix(e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}var Gn=function(t,e,n,r,i){return{u_matrix:t,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(a=i.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(o=i.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:jn(i.paint.get("raster-hue-rotate"))};var o,a};function jn(t){t*=Math.PI/180;var e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}var Hn,qn=function(t,e,n,r,i,o,a,s,l,u){var c=i.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:c.width/c.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:u,u_texture:0}},Wn=function(e,n,r,i,o,a,s,l,u,c,h){var p=o.transform;return t.extend(qn(e,n,r,i,o,a,s,l,u,c),{u_gamma_scale:i?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:t.browser.devicePixelRatio,u_is_halo:+h})},Xn=function(e,n,r,i,o,a,s,l,u,c){return t.extend(Wn(e,n,r,i,o,a,s,l,!0,u,!0),{u_texsize_icon:c,u_texture_icon:1})},Zn=function(t,e,n){return{u_matrix:t,u_opacity:e,u_color:n}},Yn=function(e,n,r,i,o,a){return t.extend(function(t,e,n,r){var i=n.imageManager.getPattern(t.from.toString()),o=n.imageManager.getPattern(t.to.toString()),a=n.imageManager.getPixelSize(),s=a.width,l=a.height,u=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,n.transform.tileZoom)/u,h=c*(r.tileID.canonical.x+r.tileID.wrap*u),p=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,l],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/pe(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,p>>16],u_pixel_coord_lower:[65535&h,65535&p]}}(i,a,r,o),{u_matrix:e,u_opacity:n})},Jn={fillExtrusion:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fillExtrusionPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,n.u_height_factor),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fill:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},fillPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},fillOutline:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world)}},fillOutlinePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},circle:function(e,n){return{u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,n.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},collisionBox:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,n.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,n.u_overscale_factor)}},collisionCircle:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,n.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,n.u_viewport_size)}},debug:function(e,n){return{u_color:new t.UniformColor(e,n.u_color),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_overlay:new t.Uniform1i(e,n.u_overlay),u_overlay_scale:new t.Uniform1f(e,n.u_overlay_scale)}},clippingMask:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmap:function(e,n){return{u_extrude_scale:new t.Uniform1f(e,n.u_extrude_scale),u_intensity:new t.Uniform1f(e,n.u_intensity),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmapTexture:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_color_ramp:new t.Uniform1i(e,n.u_color_ramp),u_opacity:new t.Uniform1f(e,n.u_opacity)}},hillshade:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_latrange:new t.Uniform2f(e,n.u_latrange),u_light:new t.Uniform2f(e,n.u_light),u_shadow:new t.UniformColor(e,n.u_shadow),u_highlight:new t.UniformColor(e,n.u_highlight),u_accent:new t.UniformColor(e,n.u_accent)}},hillshadePrepare:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_dimension:new t.Uniform2f(e,n.u_dimension),u_zoom:new t.Uniform1f(e,n.u_zoom),u_unpack:new t.Uniform4f(e,n.u_unpack)}},line:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels)}},lineGradient:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_image:new t.Uniform1i(e,n.u_image),u_image_height:new t.Uniform1f(e,n.u_image_height)}},linePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_texsize:new t.Uniform2f(e,n.u_texsize),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_image:new t.Uniform1i(e,n.u_image),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},lineSDF:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,n.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,n.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,n.u_sdfgamma),u_image:new t.Uniform1i(e,n.u_image),u_tex_y_a:new t.Uniform1f(e,n.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,n.u_tex_y_b),u_mix:new t.Uniform1f(e,n.u_mix)}},raster:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_tl_parent:new t.Uniform2f(e,n.u_tl_parent),u_scale_parent:new t.Uniform1f(e,n.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,n.u_buffer_scale),u_fade_t:new t.Uniform1f(e,n.u_fade_t),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image0:new t.Uniform1i(e,n.u_image0),u_image1:new t.Uniform1i(e,n.u_image1),u_brightness_low:new t.Uniform1f(e,n.u_brightness_low),u_brightness_high:new t.Uniform1f(e,n.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,n.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,n.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,n.u_spin_weights)}},symbolIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture)}},symbolSDF:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},symbolTextAndIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texsize_icon:new t.Uniform2f(e,n.u_texsize_icon),u_texture:new t.Uniform1i(e,n.u_texture),u_texture_icon:new t.Uniform1i(e,n.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},background:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_color:new t.UniformColor(e,n.u_color)}},backgroundPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image:new t.Uniform1i(e,n.u_image),u_pattern_tl_a:new t.Uniform2f(e,n.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,n.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,n.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,n.u_pattern_br_b),u_texsize:new t.Uniform2f(e,n.u_texsize),u_mix:new t.Uniform1f(e,n.u_mix),u_pattern_size_a:new t.Uniform2f(e,n.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,n.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,n.u_scale_a),u_scale_b:new t.Uniform1f(e,n.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,n.u_tile_units_to_pixels)}}};function Kn(e,n,r,i,o,a,s){for(var l=e.context,u=l.gl,c=e.useProgram("collisionBox"),h=[],p=0,f=0,d=0;d<i.length;d++){var m=i[d],g=n.getTile(m),y=g.getBucket(r);if(y){var v=m.posMatrix;0===o[0]&&0===o[1]||(v=e.translatePosMatrix(m.posMatrix,g,o,a));var _=s?y.textCollisionBox:y.iconCollisionBox,x=y.collisionCircleArray;if(x.length>0){var b=t.create(),w=v;t.mul(b,y.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul(b,b,y.placementViewportMatrix),h.push({circleArray:x,circleOffset:f,transform:w,invTransform:b}),f=p+=x.length/4}_&&c.draw(l,u.LINES,Mt.disabled,Tt.disabled,e.colorModeForRenderPass(),It.disabled,Pn(v,e.transform,g),r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,null,e.transform.zoom,null,null,_.collisionVertexBuffer)}}if(s&&h.length){var E=e.useProgram("collisionCircle"),S=new t.StructArrayLayout2f1f2i16;S.resize(4*p),S._trim();for(var M=0,T=0,C=h;T<C.length;T+=1)for(var I=C[T],A=0;A<I.circleArray.length/4;A++){var L=4*A,P=I.circleArray[L+0],R=I.circleArray[L+1],D=I.circleArray[L+2],N=I.circleArray[L+3];S.emplace(M++,P,R,D,N,0),S.emplace(M++,P,R,D,N,1),S.emplace(M++,P,R,D,N,2),S.emplace(M++,P,R,D,N,3)}(!Hn||Hn.length<2*p)&&(Hn=function(e){var n=2*e,r=new t.StructArrayLayout3ui6;r.resize(n),r._trim();for(var i=0;i<n;i++){var o=6*i;r.uint16[o+0]=4*i+0,r.uint16[o+1]=4*i+1,r.uint16[o+2]=4*i+2,r.uint16[o+3]=4*i+2,r.uint16[o+4]=4*i+3,r.uint16[o+5]=4*i+0}return r}(p));for(var O=l.createIndexBuffer(Hn,!0),k=l.createVertexBuffer(S,t.collisionCircleLayout.members,!0),z=0,F=h;z<F.length;z+=1){var B=F[z],U=Rn(B.transform,B.invTransform,e.transform);E.draw(l,u.TRIANGLES,Mt.disabled,Tt.disabled,e.colorModeForRenderPass(),It.disabled,U,r.id,k,O,t.SegmentVector.simpleSegment(0,2*B.circleOffset,B.circleArray.length,B.circleArray.length/2),null,e.transform.zoom,null,null,null)}k.destroy(),O.destroy()}}var Qn=t.identity(new Float32Array(16));function $n(e,n,r,i,o,a){var s=t.getAnchorAlignment(e),l=-(s.horizontalAlign-.5)*n,u=-(s.verticalAlign-.5)*r,c=t.evaluateVariableOffset(e,i);return new t.Point((l/o+c[0])*a,(u/o+c[1])*a)}function tr(e,n,r,i,o,a,s,l,u,c,h){var p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,d=e.icon.dynamicLayoutVertexArray,m={};f.clear();for(var g=0;g<p.length;g++){var y=p.get(g),v=y.hidden||!y.crossTileID||e.allowVerticalPlacement&&!y.placedOrientation?null:i[y.crossTileID];if(v){var _=new t.Point(y.anchorX,y.anchorY),x=$t(_,r?l:s),b=te(a.cameraToCenterDistance,x.signedDistanceFromCamera),w=o.evaluateSizeForFeature(e.textSizeData,c,y)*b/t.ONE_EM;r&&(w*=e.tilePixelRatio/u);for(var E=$n(v.anchor,v.width,v.height,v.textOffset,v.textBoxScale,w),S=r?$t(_.add(E),s).point:x.point.add(n?E.rotate(-a.angle):E),M=e.allowVerticalPlacement&&y.placedOrientation===t.WritingMode.vertical?Math.PI/2:0,T=0;T<y.numGlyphs;T++)t.addDynamicAttributes(f,S,M);h&&y.associatedIconIndex>=0&&(m[y.associatedIconIndex]={shiftedAnchor:S,angle:M})}else ue(y.numGlyphs,f)}if(h){d.clear();for(var C=e.icon.placedSymbolArray,I=0;I<C.length;I++){var A=C.get(I);if(A.hidden)ue(A.numGlyphs,d);else{var L=m[I];if(L)for(var P=0;P<A.numGlyphs;P++)t.addDynamicAttributes(d,L.shiftedAnchor,L.angle);else ue(A.numGlyphs,d)}}e.icon.dynamicLayoutVertexBuffer.updateData(d)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function er(t,e,n){return n.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function nr(e,n,r,i,o,a,s,l,u,c,h,p){for(var f=e.context,d=f.gl,m=e.transform,g="map"===l,y="map"===u,v=g&&"point"!==r.layout.get("symbol-placement"),_=g&&!y&&!v,x=!r.layout.get("symbol-sort-key").isConstant(),b=!1,w=e.depthModeForSublayer(0,Mt.ReadOnly),E=r.layout.get("text-variable-anchor"),S=[],M=0,T=i;M<T.length;M+=1){var C=T[M],I=n.getTile(C),A=I.getBucket(r);if(A){var L=o?A.text:A.icon;if(L&&L.segments.get().length){var P=L.programConfigurations.get(r.id),R=o||A.sdfIcons,D=o?A.textSizeData:A.iconSizeData,N=y||0!==m.pitch,O=e.useProgram(er(R,o,A),P),k=t.evaluateSizeForZoom(D,m.zoom),z=void 0,F=[0,0],B=void 0,U=void 0,V=null,G=void 0;if(o)B=I.glyphAtlasTexture,U=d.LINEAR,z=I.glyphAtlasTexture.size,A.iconsInText&&(F=I.imageAtlasTexture.size,V=I.imageAtlasTexture,G=N||e.options.rotating||e.options.zooming||"composite"===D.kind||"camera"===D.kind?d.LINEAR:d.NEAREST);else{var j=1!==r.layout.get("icon-size").constantOr(0)||A.iconsNeedLinear;B=I.imageAtlasTexture,U=R||e.options.rotating||e.options.zooming||j||N?d.LINEAR:d.NEAREST,z=I.imageAtlasTexture.size}var H=pe(I,1,e.transform.zoom),q=Kt(C.posMatrix,y,g,e.transform,H),W=Qt(C.posMatrix,y,g,e.transform,H),X=E&&A.hasTextData(),Z="none"!==r.layout.get("icon-text-fit")&&X&&A.hasIconData();v&&ne(A,C.posMatrix,e,o,q,W,y,c);var Y=e.translatePosMatrix(C.posMatrix,I,a,s),J=v||o&&E||Z?Qn:q,K=e.translatePosMatrix(W,I,a,s,!0),Q=R&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1),$={program:O,buffers:L,uniformValues:R?A.iconsInText?Xn(D.kind,k,_,y,e,Y,J,K,z,F):Wn(D.kind,k,_,y,e,Y,J,K,o,z,!0):qn(D.kind,k,_,y,e,Y,J,K,o,z),atlasTexture:B,atlasTextureIcon:V,atlasInterpolation:U,atlasInterpolationIcon:G,isSDF:R,hasHalo:Q};if(x&&A.canOverlap){b=!0;for(var tt=0,et=L.segments.get();tt<et.length;tt+=1){var nt=et[tt];S.push({segments:new t.SegmentVector([nt]),sortKey:nt.sortKey,state:$})}}else S.push({segments:L.segments,sortKey:0,state:$})}}}b&&S.sort((function(t,e){return t.sortKey-e.sortKey}));for(var rt=0,it=S;rt<it.length;rt+=1){var ot=it[rt],at=ot.state;if(f.activeTexture.set(d.TEXTURE0),at.atlasTexture.bind(at.atlasInterpolation,d.CLAMP_TO_EDGE),at.atlasTextureIcon&&(f.activeTexture.set(d.TEXTURE1),at.atlasTextureIcon&&at.atlasTextureIcon.bind(at.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),at.isSDF){var st=at.uniformValues;at.hasHalo&&(st.u_is_halo=1,rr(at.buffers,ot.segments,r,e,at.program,w,h,p,st)),st.u_is_halo=0}rr(at.buffers,ot.segments,r,e,at.program,w,h,p,at.uniformValues)}}function rr(t,e,n,r,i,o,a,s,l){var u=r.context;i.draw(u,u.gl.TRIANGLES,o,a,s,It.disabled,l,n.id,t.layoutVertexBuffer,t.indexBuffer,e,n.paint,r.transform.zoom,t.programConfigurations.get(n.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ir(t,e,n,r,i,o,a){var s,l,u,c,h,p=t.context.gl,f=n.paint.get("fill-pattern"),d=f&&f.constantOr(1),m=n.getCrossfadeParameters();a?(l=d&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=p.LINES):(l=d?"fillPattern":"fill",s=p.TRIANGLES);for(var g=0,y=r;g<y.length;g+=1){var v=y[g],_=e.getTile(v);if(!d||_.patternsLoaded()){var x=_.getBucket(n);if(x){var b=x.programConfigurations.get(n.id),w=t.useProgram(l,b);d&&(t.context.activeTexture.set(p.TEXTURE0),_.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),b.updatePaintBuffers(m));var E=f.constantOr(null);if(E&&_.imageAtlas){var S=_.imageAtlas,M=S.patternPositions[E.to.toString()],T=S.patternPositions[E.from.toString()];M&&T&&b.setConstantPatternPositions(M,T)}var C=t.translatePosMatrix(v.posMatrix,_,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(a){c=x.indexBuffer2,h=x.segments2;var I=[p.drawingBufferWidth,p.drawingBufferHeight];u="fillOutlinePattern"===l&&d?An(C,t,m,_,I):In(C,I)}else c=x.indexBuffer,h=x.segments,u=d?Cn(C,t,m,_):Tn(C);w.draw(t.context,s,i,t.stencilModeForClipping(v),o,It.disabled,u,n.id,x.layoutVertexBuffer,c,h,n.paint,t.transform.zoom,b)}}}}function or(t,e,n,r,i,o,a){for(var s=t.context,l=s.gl,u=n.paint.get("fill-extrusion-pattern"),c=u.constantOr(1),h=n.getCrossfadeParameters(),p=n.paint.get("fill-extrusion-opacity"),f=0,d=r;f<d.length;f+=1){var m=d[f],g=e.getTile(m),y=g.getBucket(n);if(y){var v=y.programConfigurations.get(n.id),_=t.useProgram(c?"fillExtrusionPattern":"fillExtrusion",v);c&&(t.context.activeTexture.set(l.TEXTURE0),g.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));var x=u.constantOr(null);if(x&&g.imageAtlas){var b=g.imageAtlas,w=b.patternPositions[x.to.toString()],E=b.patternPositions[x.from.toString()];w&&E&&v.setConstantPatternPositions(w,E)}var S=t.translatePosMatrix(m.posMatrix,g,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),M=n.paint.get("fill-extrusion-vertical-gradient"),T=c?Mn(S,t,M,p,m,h,g):Sn(S,t,M,p);_.draw(s,s.gl.TRIANGLES,i,o,a,It.backCCW,T,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,t.transform.zoom,v)}}}function ar(e,n,r,i,o,a){var s=e.context,l=s.gl,u=n.fbo;if(u){var c=e.useProgram("hillshade");s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,u.colorAttachment.get());var h=function(e,n,r){var i=r.paint.get("hillshade-shadow-color"),o=r.paint.get("hillshade-highlight-color"),a=r.paint.get("hillshade-accent-color"),s=r.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===r.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);var l,u,c,h=!e.options.moving;return{u_matrix:e.transform.calculatePosMatrix(n.tileID.toUnwrapped(),h),u_image:0,u_latrange:(l=n.tileID,u=Math.pow(2,l.canonical.z),c=l.canonical.y,[new t.MercatorCoordinate(0,c/u).toLngLat().lat,new t.MercatorCoordinate(0,(c+1)/u).toLngLat().lat]),u_light:[r.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:o,u_accent:a}}(e,n,r);c.draw(s,l.TRIANGLES,i,o,a,It.disabled,h,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments)}}function sr(e,n,r,i,o,a){var s=e.context,l=s.gl,u=n.dem;if(u&&u.data){var c=u.dim,h=u.stride,p=u.getPixels();if(s.activeTexture.set(l.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||e.getTileTexture(h),n.demTexture){var f=n.demTexture;f.update(p,{premultiply:!1}),f.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else n.demTexture=new t.Texture(s,p,l.RGBA,{premultiply:!1}),n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);s.activeTexture.set(l.TEXTURE0);var d=n.fbo;if(!d){var m=new t.Texture(s,{width:c,height:c,data:null},l.RGBA);m.bind(l.LINEAR,l.CLAMP_TO_EDGE),(d=n.fbo=s.createFramebuffer(c,c,!0)).colorAttachment.set(m.texture)}s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,c,c]),e.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,i,o,a,It.disabled,function(e,n){var r=n.stride,i=t.create();return t.ortho(i,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(i,i,[0,-t.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:n.getUnpackVector()}}(n.tileID,u),r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),n.needsHillshadePrepare=!1}}function lr(e,n,r,i,o){var a=i.paint.get("raster-fade-duration");if(a>0){var s=t.browser.now(),l=(s-e.timeAdded)/a,u=n?(s-n.timeAdded)/a:-1,c=r.getSource(),h=o.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),p=!n||Math.abs(n.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),f=p&&e.refreshedUponExpiration?1:t.clamp(p?l:1-u,0,1);return e.refreshedUponExpiration&&l>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-f}:{opacity:f,mix:0}}return{opacity:1,mix:0}}var ur=new t.Color(1,0,0,1),cr=new t.Color(0,1,0,1),hr=new t.Color(0,0,1,1),pr=new t.Color(1,0,1,1),fr=new t.Color(0,1,1,1);function dr(t,e,n,r){gr(t,0,e+n/2,t.transform.width,n,r)}function mr(t,e,n,r){gr(t,e-n/2,0,n,t.transform.height,r)}function gr(e,n,r,i,o,a){var s=e.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*t.browser.devicePixelRatio,r*t.browser.devicePixelRatio,i*t.browser.devicePixelRatio,o*t.browser.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}function yr(e,n,r){var i=e.context,o=i.gl,a=r.posMatrix,s=e.useProgram("debug"),l=Mt.disabled,u=Tt.disabled,c=e.colorModeForRenderPass();i.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.draw(i,o.LINE_STRIP,l,u,c,It.disabled,Dn(a,t.Color.red),"$debug",e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);var h=n.getTileByID(r.key).latestRawTileData,p=Math.floor((h&&h.byteLength||0)/1024),f=n.getTile(r).tileSize,d=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5,m=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(m+=" => "+r.overscaledZ),function(t,e){t.initDebugOverlayCanvas();var n=t.debugOverlayCanvas,r=t.context.gl,i=t.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(e,5,5),i.strokeText(e,5,5),t.debugOverlayTexture.update(n),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,m+" "+p+"kb"),s.draw(i,o.TRIANGLES,l,u,Ct.alphaBlended,It.disabled,Dn(a,t.Color.transparent,d),"$debug",e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments)}var vr={symbol:function(e,n,r,i,o){if("translucent"===e.renderPass){var a=Tt.disabled,s=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,n,r,i,o,a,s){for(var l=n.transform,u="map"===o,c="map"===a,h=0,p=e;h<p.length;h+=1){var f=p[h],d=i.getTile(f),m=d.getBucket(r);if(m&&m.text&&m.text.segments.get().length){var g=t.evaluateSizeForZoom(m.textSizeData,l.zoom),y=pe(d,1,n.transform.zoom),v=Kt(f.posMatrix,c,u,n.transform,y),_="none"!==r.layout.get("icon-text-fit")&&m.hasIconData();if(g){var x=Math.pow(2,l.zoom-d.tileID.overscaledZ);tr(m,u,c,s,t.symbolSize,l,v,f.posMatrix,x,g,_)}}}}(i,e,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&nr(e,n,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&nr(e,n,r,i,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,s),n.map.showCollisionBoxes&&(Kn(e,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Kn(e,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))}},circle:function(e,n,r,i){if("translucent"===e.renderPass){var o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(0!==o.constantOr(1)||0!==a.constantOr(1)&&0!==s.constantOr(1)){for(var u=e.context,c=u.gl,h=e.depthModeForSublayer(0,Mt.ReadOnly),p=Tt.disabled,f=e.colorModeForRenderPass(),d=[],m=0;m<i.length;m++){var g=i[m],y=n.getTile(g),v=y.getBucket(r);if(v){var _=v.programConfigurations.get(r.id),x={programConfiguration:_,program:e.useProgram("circle",_),layoutVertexBuffer:v.layoutVertexBuffer,indexBuffer:v.indexBuffer,uniformValues:Ln(e,g,y,r)};if(l)for(var b=0,w=v.segments.get();b<w.length;b+=1){var E=w[b];d.push({segments:new t.SegmentVector([E]),sortKey:E.sortKey,state:x})}else d.push({segments:v.segments,sortKey:0,state:x})}}l&&d.sort((function(t,e){return t.sortKey-e.sortKey}));for(var S=0,M=d;S<M.length;S+=1){var T=M[S],C=T.state;C.program.draw(u,c.TRIANGLES,h,p,f,It.disabled,C.uniformValues,r.id,C.layoutVertexBuffer,C.indexBuffer,T.segments,r.paint,e.transform.zoom,C.programConfiguration)}}}},heatmap:function(e,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){var o=e.context,a=o.gl,s=Tt.disabled,l=new Ct([a.ONE,a.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,n){var r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);var i=n.heatmapFbo;if(i)r.bindTexture(r.TEXTURE_2D,i.colorAttachment.get()),t.bindFramebuffer.set(i.framebuffer);else{var o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),i=n.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,n,r){var i=t.gl;i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e.width/4,e.height/4,0,i.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:i.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(t,e,o,i)}}(o,e,r),o.clear({color:t.Color.transparent});for(var u=0;u<i.length;u++){var c=i[u];if(!n.hasRenderableParent(c)){var h=n.getTile(c),p=h.getBucket(r);if(p){var f=p.programConfigurations.get(r.id);e.useProgram("heatmap",f).draw(o,a.TRIANGLES,Mt.disabled,s,l,It.disabled,On(c.posMatrix,h,e.transform.zoom,r.paint.get("heatmap-intensity")),r.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,r.paint,e.transform.zoom,f)}}}o.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,n){var r=e.context,i=r.gl,o=n.heatmapFbo;if(o){r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1);var a=n.colorRampTexture;a||(a=n.colorRampTexture=new t.Texture(r,n.colorRamp,i.RGBA)),a.bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,i.TRIANGLES,Mt.disabled,Tt.disabled,e.colorModeForRenderPass(),It.disabled,function(e,n,r,i){var o=t.create();t.ortho(o,0,e.width,e.height,0,0,1);var a=e.context.gl;return{u_matrix:o,u_world:[a.drawingBufferWidth,a.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:n.paint.get("heatmap-opacity")}}(e,n),n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom)}}(e,r))},line:function(e,n,r,i){if("translucent"===e.renderPass){var o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0!==o.constantOr(1)&&0!==a.constantOr(1))for(var s=e.depthModeForSublayer(0,Mt.ReadOnly),l=e.colorModeForRenderPass(),u=r.paint.get("line-dasharray"),c=r.paint.get("line-pattern"),h=c.constantOr(1),p=r.paint.get("line-gradient"),f=r.getCrossfadeParameters(),d=h?"linePattern":u?"lineSDF":p?"lineGradient":"line",m=e.context,g=m.gl,y=!0,v=0,_=i;v<_.length;v+=1){var x=_[v],b=n.getTile(x);if(!h||b.patternsLoaded()){var w=b.getBucket(r);if(w){var E=w.programConfigurations.get(r.id),S=e.context.program.get(),M=e.useProgram(d,E),T=y||M.program!==S,C=c.constantOr(null);if(C&&b.imageAtlas){var I=b.imageAtlas,A=I.patternPositions[C.to.toString()],L=I.patternPositions[C.from.toString()];A&&L&&E.setConstantPatternPositions(A,L)}var P=h?Fn(e,b,r,f):u?Bn(e,b,r,u,f):p?zn(e,b,r,w.lineClipsArray.length):kn(e,b,r);if(h)m.activeTexture.set(g.TEXTURE0),b.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),E.updatePaintBuffers(f);else if(u&&(T||e.lineAtlas.dirty))m.activeTexture.set(g.TEXTURE0),e.lineAtlas.bind(m);else if(p){var R=w.gradients[r.id],D=R.texture;if(r.gradientVersion!==R.version){var N=256;if(r.stepInterpolant){var O=n.getSource().maxzoom,k=x.canonical.z===O?Math.ceil(1<<e.transform.maxZoom-x.canonical.z):1;N=t.clamp(t.nextPowerOfTwo(w.maxLineLength/t.EXTENT*1024*k),256,m.maxTextureSize)}R.gradient=t.renderColorRamp({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:N,image:R.gradient||void 0,clips:w.lineClipsArray}),R.texture?R.texture.update(R.gradient):R.texture=new t.Texture(m,R.gradient,g.RGBA),R.version=r.gradientVersion,D=R.texture}m.activeTexture.set(g.TEXTURE0),D.bind(r.stepInterpolant?g.NEAREST:g.LINEAR,g.CLAMP_TO_EDGE)}M.draw(m,g.TRIANGLES,s,e.stencilModeForClipping(x),l,It.disabled,P,r.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,r.paint,e.transform.zoom,E,w.layoutVertexBuffer2),y=!1}}}}},fill:function(e,n,r,i){var o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0!==a.constantOr(1)){var s=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(e.renderPass===u){var c=e.depthModeForSublayer(1,"opaque"===e.renderPass?Mt.ReadWrite:Mt.ReadOnly);ir(e,n,r,i,c,s,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){var h=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Mt.ReadOnly);ir(e,n,r,i,h,s,!0)}}},"fill-extrusion":function(t,e,n,r){var i=n.paint.get("fill-extrusion-opacity");if(0!==i&&"translucent"===t.renderPass){var o=new Mt(t.context.gl.LEQUAL,Mt.ReadWrite,t.depthRangeFor3D);if(1!==i||n.paint.get("fill-extrusion-pattern").constantOr(1))or(t,e,n,r,o,Tt.disabled,Ct.disabled),or(t,e,n,r,o,t.stencilModeFor3D(),t.colorModeForRenderPass());else{var a=t.colorModeForRenderPass();or(t,e,n,r,o,Tt.disabled,a)}}},hillshade:function(t,e,n,r){if("offscreen"===t.renderPass||"translucent"===t.renderPass){for(var i=t.context,o=t.depthModeForSublayer(0,Mt.ReadOnly),a=t.colorModeForRenderPass(),s="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r],l=s[0],u=0,c=s[1];u<c.length;u+=1){var h=c[u],p=e.getTile(h);p.needsHillshadePrepare&&"offscreen"===t.renderPass?sr(t,p,n,o,Tt.disabled,a):"translucent"===t.renderPass&&ar(t,p,n,o,l[h.overscaledZ],a)}i.viewport.set([0,0,t.width,t.height])}},raster:function(t,e,n,r){if("translucent"===t.renderPass&&0!==n.paint.get("raster-opacity")&&r.length)for(var i=t.context,o=i.gl,a=e.getSource(),s=t.useProgram("raster"),l=t.colorModeForRenderPass(),u=a instanceof R?[{},r]:t.stencilConfigForOverlap(r),c=u[0],h=u[1],p=h[h.length-1].overscaledZ,f=!t.options.moving,d=0,m=h;d<m.length;d+=1){var g=m[d],y=t.depthModeForSublayer(g.overscaledZ-p,1===n.paint.get("raster-opacity")?Mt.ReadWrite:Mt.ReadOnly,o.LESS),v=e.getTile(g),_=t.transform.calculatePosMatrix(g.toUnwrapped(),f);v.registerFadeDuration(n.paint.get("raster-fade-duration"));var x=e.findLoadedParent(g,0),b=lr(v,x,e,n,t.transform),w=void 0,E=void 0,S="nearest"===n.paint.get("raster-resampling")?o.NEAREST:o.LINEAR;i.activeTexture.set(o.TEXTURE0),v.texture.bind(S,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),i.activeTexture.set(o.TEXTURE1),x?(x.texture.bind(S,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),w=Math.pow(2,x.tileID.overscaledZ-v.tileID.overscaledZ),E=[v.tileID.canonical.x*w%1,v.tileID.canonical.y*w%1]):v.texture.bind(S,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);var M=Gn(_,E||[0,0],w||1,b,n);a instanceof R?s.draw(i,o.TRIANGLES,y,Tt.disabled,l,It.disabled,M,n.id,a.boundsBuffer,t.quadTriangleIndexBuffer,a.boundsSegments):s.draw(i,o.TRIANGLES,y,c[g.overscaledZ],l,It.disabled,M,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}},background:function(t,e,n){var r=n.paint.get("background-color"),i=n.paint.get("background-opacity");if(0!==i){var o=t.context,a=o.gl,s=t.transform,l=s.tileSize,u=n.paint.get("background-pattern");if(!t.isPatternMissing(u)){var c=!u&&1===r.a&&1===i&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass===c){var h=Tt.disabled,p=t.depthModeForSublayer(0,"opaque"===c?Mt.ReadWrite:Mt.ReadOnly),f=t.colorModeForRenderPass(),d=t.useProgram(u?"backgroundPattern":"background"),m=s.coveringTiles({tileSize:l});u&&(o.activeTexture.set(a.TEXTURE0),t.imageManager.bind(t.context));for(var g=n.getCrossfadeParameters(),y=0,v=m;y<v.length;y+=1){var _=v[y],x=t.transform.calculatePosMatrix(_.toUnwrapped()),b=u?Yn(x,i,t,u,{tileID:_,tileSize:l},g):Zn(x,i,r);d.draw(o,a.TRIANGLES,p,h,f,It.disabled,b,n.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}}}}},debug:function(t,e,n){for(var r=0;r<n.length;r++)yr(t,e,n[r])},custom:function(t,e,n){var r=t.context,i=n.implementation;if("offscreen"===t.renderPass){var o=i.prerender;o&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),o.call(i,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(Tt.disabled);var a="3d"===i.renderingMode?new Mt(t.context.gl.LEQUAL,Mt.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Mt.ReadOnly);r.setDepthMode(a),i.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}},_r=function(t,e){this.context=new At(t),this.transform=e,this._tileTextures={},this.setup(),this.numSublayers=Lt.maxUnderzooming+Lt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Fe,this.gpuTimers={}};_r.prototype.resize=function(e,n){if(this.width=e*t.browser.devicePixelRatio,this.height=n*t.browser.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var r=0,i=this.style._order;r<i.length;r+=1)this.style._layers[i[r]].resize()},_r.prototype.setup=function(){var e=this.context,n=new t.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(t.EXTENT,0),n.emplaceBack(0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(n,He.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);var r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,He.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);var i=new t.StructArrayLayout4i8;i.emplaceBack(0,0,0,0),i.emplaceBack(t.EXTENT,0,t.EXTENT,0),i.emplaceBack(0,t.EXTENT,0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.rasterBoundsBuffer=e.createVertexBuffer(i,P.members),this.rasterBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);var o=new t.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,He.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);var a=new t.StructArrayLayout1ui2;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);var s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new t.Texture(e,{width:1,height:1,data:new Uint8Array([0,0,0,0])},e.gl.RGBA);var l=this.context.gl;this.stencilClearMode=new Tt({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)},_r.prototype.clearStencil=function(){var e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;var r=t.create();t.ortho(r,0,this.width,this.height,0,0,1),t.scale(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,Mt.disabled,this.stencilClearMode,Ct.disabled,It.disabled,Nn(r),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)},_r.prototype._renderTileClippingMasks=function(t,e){if(this.currentStencilSource!==t.source&&t.isTileClipped()&&e&&e.length){this.currentStencilSource=t.source;var n=this.context,r=n.gl;this.nextStencilID+e.length>256&&this.clearStencil(),n.setColorMode(Ct.disabled),n.setDepthMode(Mt.disabled);var i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(var o=0,a=e;o<a.length;o+=1){var s=a[o],l=this._tileClippingMaskIDs[s.key]=this.nextStencilID++;i.draw(n,r.TRIANGLES,Mt.disabled,new Tt({func:r.ALWAYS,mask:0},l,255,r.KEEP,r.KEEP,r.REPLACE),Ct.disabled,It.disabled,Nn(s.posMatrix),"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}},_r.prototype.stencilModeFor3D=function(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();var t=this.nextStencilID++,e=this.context.gl;return new Tt({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilModeForClipping=function(t){var e=this.context.gl;return new Tt({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilConfigForOverlap=function(t){var e,n=this.context.gl,r=t.sort((function(t,e){return e.overscaledZ-t.overscaledZ})),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();for(var a={},s=0;s<o;s++)a[s+i]=new Tt({func:n.GEQUAL,mask:255},s+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=o,[a,r]}return[(e={},e[i]=Tt.disabled,e),r]},_r.prototype.colorModeForRenderPass=function(){var e=this.context.gl;return this._showOverdrawInspector?new Ct([e.CONSTANT_COLOR,e.ONE],new t.Color(1/8,1/8,1/8,0),[!0,!0,!0,!0]):"opaque"===this.renderPass?Ct.unblended:Ct.alphaBlended},_r.prototype.depthModeForSublayer=function(t,e,n){if(!this.opaquePassEnabledForLayer())return Mt.disabled;var r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Mt(n||this.context.gl.LEQUAL,e,[r,r])},_r.prototype.opaquePassEnabledForLayer=function(){return this.currentLayer<this.opaquePassCutoff},_r.prototype.render=function(e,n){var r=this;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(t.browser.now()),this.imageManager.beginFrame();var i=this.style._order,o=this.style.sourceCaches;for(var a in o){var s=o[a];s.used&&s.prepare(this.context)}var l,u,c={},h={},p={};for(var f in o){var d=o[f];c[f]=d.getVisibleCoordinates(),h[f]=c[f].slice().reverse(),p[f]=d.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(var m=0;m<i.length;m++)if(this.style._layers[i[m]].is3D()){this.opaquePassCutoff=m;break}this.renderPass="offscreen";for(var g=0,y=i;g<y.length;g+=1){var v=this.style._layers[y[g]];if(v.hasOffscreenPass()&&!v.isHidden(this.transform.zoom)){var _=h[v.source];("custom"===v.type||_.length)&&this.renderLayer(this,o[v.source],v,_)}}for(this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?t.Color.black:t.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],this.renderPass="opaque",this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){var x=this.style._layers[i[this.currentLayer]],b=o[x.source],w=c[x.source];this._renderTileClippingMasks(x,w),this.renderLayer(this,b,x,w)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){var E=this.style._layers[i[this.currentLayer]],S=o[E.source],M=("symbol"===E.type?p:h)[E.source];this._renderTileClippingMasks(E,c[E.source]),this.renderLayer(this,S,E,M)}this.options.showTileBoundaries&&(t.values(this.style._layers).forEach((function(t){t.source&&!t.isHidden(r.transform.zoom)&&(t.source!==(u&&u.id)&&(u=r.style.sourceCaches[t.source]),(!l||l.getSource().maxzoom<u.getSource().maxzoom)&&(l=u))})),l&&vr.debug(this,l,l.getVisibleCoordinates())),this.options.showPadding&&function(t){var e=t.transform.padding;dr(t,t.transform.height-(e.top||0),3,ur),dr(t,e.bottom||0,3,cr),mr(t,e.left||0,3,hr),mr(t,t.transform.width-(e.right||0),3,pr);var n=t.transform.centerPoint;!function(t,e,n,r){gr(t,e-1,n-10,2,20,r),gr(t,e-10,n-1,20,2,r)}(t,n.x,t.transform.height-n.y,fr)}(this),this.context.setDefault()},_r.prototype.renderLayer=function(t,e,n,r){n.isHidden(this.transform.zoom)||("background"===n.type||"custom"===n.type||r.length)&&(this.id=n.id,this.gpuTimingStart(n),vr[n.type](t,e,n,r,this.style.placement.variableOffsets),this.gpuTimingEnd())},_r.prototype.gpuTimingStart=function(t){if(this.options.gpuTiming){var e=this.context.extTimerQuery,n=this.gpuTimers[t.id];n||(n=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),n.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,n.query)}},_r.prototype.gpuTimingEnd=function(){if(this.options.gpuTiming){var t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}},_r.prototype.collectGpuTimers=function(){var t=this.gpuTimers;return this.gpuTimers={},t},_r.prototype.queryGpuTimers=function(t){var e={};for(var n in t){var r=t[n],i=this.context.extTimerQuery,o=i.getQueryObjectEXT(r.query,i.QUERY_RESULT_EXT)/1e6;i.deleteQueryEXT(r.query),e[n]=o}return e},_r.prototype.translatePosMatrix=function(e,n,r,i,o){if(!r[0]&&!r[1])return e;var a=o?"map"===i?this.transform.angle:0:"viewport"===i?-this.transform.angle:0;if(a){var s=Math.sin(a),l=Math.cos(a);r=[r[0]*l-r[1]*s,r[0]*s+r[1]*l]}var u=[o?r[0]:pe(n,r[0],this.transform.zoom),o?r[1]:pe(n,r[1],this.transform.zoom),0],c=new Float32Array(16);return t.translate(c,e,u),c},_r.prototype.saveTileTexture=function(t){var e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]},_r.prototype.getTileTexture=function(t){var e=this._tileTextures[t];return e&&e.length>0?e.pop():null},_r.prototype.isPatternMissing=function(t){if(!t)return!1;if(!t.from||!t.to)return!0;var e=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!e||!n},_r.prototype.useProgram=function(t,e){this.cache=this.cache||{};var n=""+t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[n]||(this.cache[n]=new wn(this.context,t,_n[t],e,Jn[t],this._showOverdrawInspector)),this.cache[n]},_r.prototype.setCustomLayerDefaults=function(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()},_r.prototype.setBaseState=function(){var t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)},_r.prototype.initDebugOverlayCanvas=function(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))},_r.prototype.destroy=function(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()};var xr=function(t,e){this.points=t,this.planes=e};xr.fromInvProjectionMatrix=function(e,n,r){var i=Math.pow(2,r),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((function(n){return t.transformMat4([],n,e)})).map((function(e){return t.scale$1([],e,1/e[3]/n*i)})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((function(e){var n=t.sub([],o[e[0]],o[e[1]]),r=t.sub([],o[e[2]],o[e[1]]),i=t.normalize([],t.cross([],n,r)),a=-t.dot(i,o[e[1]]);return i.concat(a)}));return new xr(o,a)};var br=function(e,n){this.min=e,this.max=n,this.center=t.scale$2([],t.add([],this.min,this.max),.5)};br.prototype.quadrant=function(e){for(var n=[e%2==0,e<2],r=t.clone$2(this.min),i=t.clone$2(this.max),o=0;o<n.length;o++)r[o]=n[o]?this.min[o]:this.center[o],i[o]=n[o]?this.center[o]:this.max[o];return i[2]=this.max[2],new br(r,i)},br.prototype.distanceX=function(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]},br.prototype.distanceY=function(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]},br.prototype.intersects=function(e){for(var n=[[this.min[0],this.min[1],0,1],[this.max[0],this.min[1],0,1],[this.max[0],this.max[1],0,1],[this.min[0],this.max[1],0,1]],r=!0,i=0;i<e.planes.length;i++){for(var o=e.planes[i],a=0,s=0;s<n.length;s++)a+=t.dot$1(o,n[s])>=0;if(0===a)return 0;a!==n.length&&(r=!1)}if(r)return 2;for(var l=0;l<3;l++){for(var u=Number.MAX_VALUE,c=-Number.MAX_VALUE,h=0;h<e.points.length;h++){var p=e.points[h][l]-this.min[l];u=Math.min(u,p),c=Math.max(c,p)}if(c<0||u>this.max[l]-this.min[l])return 0}return 1};var wr=function(t,e,n,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),isNaN(t)||t<0||isNaN(e)||e<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=n,this.right=r};wr.prototype.interpolate=function(e,n,r){return null!=n.top&&null!=e.top&&(this.top=t.number(e.top,n.top,r)),null!=n.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,n.bottom,r)),null!=n.left&&null!=e.left&&(this.left=t.number(e.left,n.left,r)),null!=n.right&&null!=e.right&&(this.right=t.number(e.right,n.right,r)),this},wr.prototype.getCenter=function(e,n){var r=t.clamp((this.left+e-this.right)/2,0,e),i=t.clamp((this.top+n-this.bottom)/2,0,n);return new t.Point(r,i)},wr.prototype.equals=function(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right},wr.prototype.clone=function(){return new wr(this.top,this.bottom,this.left,this.right)},wr.prototype.toJSON=function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}};var Er=function(e,n,r,i,o){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new wr,this._posMatrixCache={},this._alignedPosMatrixCache={}},Sr={minZoom:{configurable:!0},maxZoom:{configurable:!0},minPitch:{configurable:!0},maxPitch:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerOffset:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},padding:{configurable:!0},centerPoint:{configurable:!0},unmodified:{configurable:!0},point:{configurable:!0}};Er.prototype.clone=function(){var t=new Er(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t},Sr.minZoom.get=function(){return this._minZoom},Sr.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},Sr.maxZoom.get=function(){return this._maxZoom},Sr.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},Sr.minPitch.get=function(){return this._minPitch},Sr.minPitch.set=function(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))},Sr.maxPitch.get=function(){return this._maxPitch},Sr.maxPitch.set=function(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))},Sr.renderWorldCopies.get=function(){return this._renderWorldCopies},Sr.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},Sr.worldSize.get=function(){return this.tileSize*this.scale},Sr.centerOffset.get=function(){return this.centerPoint._sub(this.size._div(2))},Sr.size.get=function(){return new t.Point(this.width,this.height)},Sr.bearing.get=function(){return-this.angle/Math.PI*180},Sr.bearing.set=function(e){var n=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=t.create$2(),t.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},Sr.pitch.get=function(){return this._pitch/Math.PI*180},Sr.pitch.set=function(e){var n=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())},Sr.fov.get=function(){return this._fov/Math.PI*180},Sr.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},Sr.zoom.get=function(){return this._zoom},Sr.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},Sr.center.get=function(){return this._center},Sr.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Sr.padding.get=function(){return this._edgeInsets.toJSON()},Sr.padding.set=function(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())},Sr.centerPoint.get=function(){return this._edgeInsets.getCenter(this.width,this.height)},Er.prototype.isPaddingEqual=function(t){return this._edgeInsets.equals(t)},Er.prototype.interpolatePadding=function(t,e,n){this._unmodified=!1,this._edgeInsets.interpolate(t,e,n),this._constrain(),this._calcMatrices()},Er.prototype.coveringZoomLevel=function(t){var e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)},Er.prototype.getVisibleUnwrappedCoordinates=function(e){var n=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var r=this.pointCoordinate(new t.Point(0,0)),i=this.pointCoordinate(new t.Point(this.width,0)),o=this.pointCoordinate(new t.Point(this.width,this.height)),a=this.pointCoordinate(new t.Point(0,this.height)),s=Math.floor(Math.min(r.x,i.x,o.x,a.x)),l=Math.floor(Math.max(r.x,i.x,o.x,a.x)),u=s-1;u<=l+1;u++)0!==u&&n.push(new t.UnwrappedTileID(u,e));return n},Er.prototype.coveringTiles=function(e){var n=this.coveringZoomLevel(e),r=n;if(void 0!==e.minzoom&&n<e.minzoom)return[];void 0!==e.maxzoom&&n>e.maxzoom&&(n=e.maxzoom);var i=t.MercatorCoordinate.fromLngLat(this.center),o=Math.pow(2,n),a=[o*i.x,o*i.y,0],s=xr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n),l=e.minzoom||0;this.pitch<=60&&this._edgeInsets.top<.1&&(l=n);var u=function(t){return{aabb:new br([t*o,0,0],[(t+1)*o,o,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}},c=[],h=[],p=n,f=e.reparseOverscaled?r:n;if(this._renderWorldCopies)for(var d=1;d<=3;d++)c.push(u(-d)),c.push(u(d));for(c.push(u(0));c.length>0;){var m=c.pop(),g=m.x,y=m.y,v=m.fullyVisible;if(!v){var _=m.aabb.intersects(s);if(0===_)continue;v=2===_}var x=m.aabb.distanceX(a),b=m.aabb.distanceY(a),w=Math.max(Math.abs(x),Math.abs(b));if(m.zoom===p||w>3+(1<<p-m.zoom)-2&&m.zoom>=l)h.push({tileID:new t.OverscaledTileID(m.zoom===p?f:m.zoom,m.wrap,m.zoom,g,y),distanceSq:t.sqrLen([a[0]-.5-g,a[1]-.5-y])});else for(var E=0;E<4;E++){var S=(g<<1)+E%2,M=(y<<1)+(E>>1);c.push({aabb:m.aabb.quadrant(E),zoom:m.zoom+1,x:S,y:M,wrap:m.wrap,fullyVisible:v})}}return h.sort((function(t,e){return t.distanceSq-e.distanceSq})).map((function(t){return t.tileID}))},Er.prototype.resize=function(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()},Sr.unmodified.get=function(){return this._unmodified},Er.prototype.zoomScale=function(t){return Math.pow(2,t)},Er.prototype.scaleZoom=function(t){return Math.log(t)/Math.LN2},Er.prototype.project=function(e){var n=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.Point(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(n)*this.worldSize)},Er.prototype.unproject=function(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()},Sr.point.get=function(){return this.project(this.center)},Er.prototype.setLocationAtPoint=function(e,n){var r=this.pointCoordinate(n),i=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),a=new t.MercatorCoordinate(o.x-(r.x-i.x),o.y-(r.y-i.y));this.center=this.coordinateLocation(a),this._renderWorldCopies&&(this.center=this.center.wrap())},Er.prototype.locationPoint=function(t){return this.coordinatePoint(this.locationCoordinate(t))},Er.prototype.pointLocation=function(t){return this.coordinateLocation(this.pointCoordinate(t))},Er.prototype.locationCoordinate=function(e){return t.MercatorCoordinate.fromLngLat(e)},Er.prototype.coordinateLocation=function(t){return t.toLngLat()},Er.prototype.pointCoordinate=function(e){var n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.transformMat4(n,n,this.pixelMatrixInverse),t.transformMat4(r,r,this.pixelMatrixInverse);var i=n[3],o=r[3],a=n[1]/i,s=r[1]/o,l=n[2]/i,u=r[2]/o,c=l===u?0:(0-l)/(u-l);return new t.MercatorCoordinate(t.number(n[0]/i,r[0]/o,c)/this.worldSize,t.number(a,s,c)/this.worldSize)},Er.prototype.coordinatePoint=function(e){var n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix),new t.Point(n[0]/n[3],n[1]/n[3])},Er.prototype.getBounds=function(){return(new t.LngLatBounds).extend(this.pointLocation(new t.Point(0,0))).extend(this.pointLocation(new t.Point(this.width,0))).extend(this.pointLocation(new t.Point(this.width,this.height))).extend(this.pointLocation(new t.Point(0,this.height)))},Er.prototype.getMaxBounds=function(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new t.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null},Er.prototype.setMaxBounds=function(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])},Er.prototype.calculatePosMatrix=function(e,n){void 0===n&&(n=!1);var r=e.key,i=n?this._alignedPosMatrixCache:this._posMatrixCache;if(i[r])return i[r];var o=e.canonical,a=this.worldSize/this.zoomScale(o.z),s=o.x+Math.pow(2,o.z)*e.wrap,l=t.identity(new Float64Array(16));return t.translate(l,l,[s*a,o.y*a,0]),t.scale(l,l,[a/t.EXTENT,a/t.EXTENT,1]),t.multiply(l,n?this.alignedProjMatrix:this.projMatrix,l),i[r]=new Float32Array(l),i[r]},Er.prototype.customLayerMatrix=function(){return this.mercatorMatrix.slice()},Er.prototype._constrain=function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var e,n,r,i,o=-90,a=90,s=-180,l=180,u=this.size,c=this._unmodified;if(this.latRange){var h=this.latRange;o=t.mercatorYfromLat(h[1])*this.worldSize,e=(a=t.mercatorYfromLat(h[0])*this.worldSize)-o<u.y?u.y/(a-o):0}if(this.lngRange){var p=this.lngRange;s=t.mercatorXfromLng(p[0])*this.worldSize,n=(l=t.mercatorXfromLng(p[1])*this.worldSize)-s<u.x?u.x/(l-s):0}var f=this.point,d=Math.max(n||0,e||0);if(d)return this.center=this.unproject(new t.Point(n?(l+s)/2:f.x,e?(a+o)/2:f.y)),this.zoom+=this.scaleZoom(d),this._unmodified=c,void(this._constraining=!1);if(this.latRange){var m=f.y,g=u.y/2;m-g<o&&(i=o+g),m+g>a&&(i=a-g)}if(this.lngRange){var y=f.x,v=u.x/2;y-v<s&&(r=s+v),y+v>l&&(r=l-v)}void 0===r&&void 0===i||(this.center=this.unproject(new t.Point(void 0!==r?r:f.x,void 0!==i?i:f.y))),this._unmodified=c,this._constraining=!1}},Er.prototype._calcMatrices=function(){if(this.height){var e=this.centerOffset;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var n=Math.PI/2+this._pitch,r=this._fov*(.5+e.y/this.height),i=Math.sin(r)*this.cameraToCenterDistance/Math.sin(t.clamp(Math.PI-n-r,.01,Math.PI-.01)),o=this.point,a=o.x,s=o.y,l=1.01*(Math.cos(Math.PI/2-this._pitch)*i+this.cameraToCenterDistance),u=this.height/50,c=new Float64Array(16);t.perspective(c,this._fov,this.width/this.height,u,l),c[8]=2*-e.x/this.width,c[9]=2*e.y/this.height,t.scale(c,c,[1,-1,1]),t.translate(c,c,[0,0,-this.cameraToCenterDistance]),t.rotateX(c,c,this._pitch),t.rotateZ(c,c,this.angle),t.translate(c,c,[-a,-s,0]),this.mercatorMatrix=t.scale([],c,[this.worldSize,this.worldSize,this.worldSize]),t.scale(c,c,[1,1,t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,1]),this.projMatrix=c,this.invProjMatrix=t.invert([],this.projMatrix);var h=this.width%2/2,p=this.height%2/2,f=Math.cos(this.angle),d=Math.sin(this.angle),m=a-Math.round(a)+f*h+d*p,g=s-Math.round(s)+f*p+d*h,y=new Float64Array(c);if(t.translate(y,y,[m>.5?m-1:m,g>.5?g-1:g,0]),this.alignedProjMatrix=y,c=t.create(),t.scale(c,c,[this.width/2,-this.height/2,1]),t.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=t.create(),t.scale(c,c,[1,-1,1]),t.translate(c,c,[-1,-1,0]),t.scale(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),!(c=t.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Er.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.Point(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance},Er.prototype.getCameraPoint=function(){var e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,e))},Er.prototype.getCameraQueryGeometry=function(e){var n=this.getCameraPoint();if(1===e.length)return[e[0],n];for(var r=n.x,i=n.y,o=n.x,a=n.y,s=0,l=e;s<l.length;s+=1){var u=l[s];r=Math.min(r,u.x),i=Math.min(i,u.y),o=Math.max(o,u.x),a=Math.max(a,u.y)}return[new t.Point(r,i),new t.Point(o,i),new t.Point(o,a),new t.Point(r,a),new t.Point(r,i)]},Object.defineProperties(Er.prototype,Sr);var Mr=function(e){var n,r,i,o;this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=(n=this._updateHashUnthrottled.bind(this),r=!1,i=null,o=function(){i=null,r&&(n(),i=setTimeout(o,300),r=!1)},function(){return r=!0,i||o(),i})};Mr.prototype.addTo=function(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this},Mr.prototype.remove=function(){return t.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this},Mr.prototype.getHashString=function(e){var n=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=this._map.getBearing(),u=this._map.getPitch(),c="";if(c+=e?"/"+a+"/"+s+"/"+r:r+"/"+s+"/"+a,(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+="/"+Math.round(u)),this._hashName){var h=this._hashName,p=!1,f=t.window.location.hash.slice(1).split("&").map((function(t){var e=t.split("=")[0];return e===h?(p=!0,e+"="+c):t})).filter((function(t){return t}));return p||f.push(h+"="+c),"#"+f.join("&")}return"#"+c},Mr.prototype._getCurrentHash=function(){var e,n=this,r=t.window.location.hash.replace("#","");return this._hashName?(r.split("&").map((function(t){return t.split("=")})).forEach((function(t){t[0]===n._hashName&&(e=t)})),(e&&e[1]||"").split("/")):r.split("/")},Mr.prototype._onHashChange=function(){var t=this._getCurrentHash();if(t.length>=3&&!t.some((function(t){return isNaN(t)}))){var e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},Mr.prototype._updateHashUnthrottled=function(){var e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());try{t.window.history.replaceState(t.window.history.state,null,e)}catch(t){}};var Tr={linearity:.3,easing:t.bezier(0,0,.3,1)},Cr=t.extend({deceleration:2500,maxSpeed:1400},Tr),Ir=t.extend({deceleration:20,maxSpeed:1400},Tr),Ar=t.extend({deceleration:1e3,maxSpeed:360},Tr),Lr=t.extend({deceleration:1e3,maxSpeed:90},Tr),Pr=function(t){this._map=t,this.clear()};function Rr(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function Dr(e,n,r){var i=r.maxSpeed,o=r.linearity,a=r.deceleration,s=t.clamp(e*o/(n/1e3),-i,i),l=Math.abs(s)/(a*o);return{easing:r.easing,duration:1e3*l,amount:s*(l/2)}}Pr.prototype.clear=function(){this._inertiaBuffer=[]},Pr.prototype.record=function(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.browser.now(),settings:e})},Pr.prototype._drainInertiaBuffer=function(){for(var e=this._inertiaBuffer,n=t.browser.now();e.length>0&&n-e[0].time>160;)e.shift()},Pr.prototype._onMoveEnd=function(e){if(this._drainInertiaBuffer(),!(this._inertiaBuffer.length<2)){for(var n={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0},r=0,i=this._inertiaBuffer;r<i.length;r+=1){var o=i[r].settings;n.zoom+=o.zoomDelta||0,n.bearing+=o.bearingDelta||0,n.pitch+=o.pitchDelta||0,o.panDelta&&n.pan._add(o.panDelta),o.around&&(n.around=o.around),o.pinchAround&&(n.pinchAround=o.pinchAround)}var a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,s={};if(n.pan.mag()){var l=Dr(n.pan.mag(),a,t.extend({},Cr,e||{}));s.offset=n.pan.mult(l.amount/n.pan.mag()),s.center=this._map.transform.center,Rr(s,l)}if(n.zoom){var u=Dr(n.zoom,a,Ir);s.zoom=this._map.transform.zoom+u.amount,Rr(s,u)}if(n.bearing){var c=Dr(n.bearing,a,Ar);s.bearing=this._map.transform.bearing+t.clamp(c.amount,-179,179),Rr(s,c)}if(n.pitch){var h=Dr(n.pitch,a,Lr);s.pitch=this._map.transform.pitch+h.amount,Rr(s,h)}if(s.zoom||s.bearing){var p=void 0===n.pinchAround?n.around:n.pinchAround;s.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),t.extend(s,{noMoveStart:!0})}};var Nr=function(e){function r(r,i,o,a){void 0===a&&(a={});var s=n.mousePos(i.getCanvasContainer(),o),l=i.unproject(s);e.call(this,r,t.extend({point:s,lngLat:l,originalEvent:o},a)),this._defaultPrevented=!1,this.target=i}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},i.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,i),r}(t.Event),Or=function(e){function r(r,i,o){var a="touchend"===r?o.changedTouches:o.touches,s=n.touchPos(i.getCanvasContainer(),a),l=s.map((function(t){return i.unproject(t)})),u=s.reduce((function(t,e,n,r){return t.add(e.div(r.length))}),new t.Point(0,0)),c=i.unproject(u);e.call(this,r,{points:s,point:u,lngLats:l,lngLat:c,originalEvent:o}),this._defaultPrevented=!1}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={defaultPrevented:{configurable:!0}};return r.prototype.preventDefault=function(){this._defaultPrevented=!0},i.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(r.prototype,i),r}(t.Event),kr=function(t){function e(e,n,r){t.call(this,e,{originalEvent:r}),this._defaultPrevented=!1}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},n.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,n),e}(t.Event),zr=function(t,e){this._map=t,this._clickTolerance=e.clickTolerance};zr.prototype.reset=function(){delete this._mousedownPos},zr.prototype.wheel=function(t){return this._firePreventable(new kr(t.type,this._map,t))},zr.prototype.mousedown=function(t,e){return this._mousedownPos=e,this._firePreventable(new Nr(t.type,this._map,t))},zr.prototype.mouseup=function(t){this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.click=function(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.dblclick=function(t){return this._firePreventable(new Nr(t.type,this._map,t))},zr.prototype.mouseover=function(t){this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.mouseout=function(t){this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.touchstart=function(t){return this._firePreventable(new Or(t.type,this._map,t))},zr.prototype.touchmove=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype.touchend=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype.touchcancel=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype._firePreventable=function(t){if(this._map.fire(t),t.defaultPrevented)return{}},zr.prototype.isEnabled=function(){return!0},zr.prototype.isActive=function(){return!1},zr.prototype.enable=function(){},zr.prototype.disable=function(){};var Fr=function(t){this._map=t};Fr.prototype.reset=function(){this._delayContextMenu=!1,delete this._contextMenuEvent},Fr.prototype.mousemove=function(t){this._map.fire(new Nr(t.type,this._map,t))},Fr.prototype.mousedown=function(){this._delayContextMenu=!0},Fr.prototype.mouseup=function(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Nr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)},Fr.prototype.contextmenu=function(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new Nr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()},Fr.prototype.isEnabled=function(){return!0},Fr.prototype.isActive=function(){return!1},Fr.prototype.enable=function(){},Fr.prototype.disable=function(){};var Br=function(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1};function Ur(t,e){for(var n={},r=0;r<t.length;r++)n[t[r].identifier]=e[r];return n}Br.prototype.isEnabled=function(){return!!this._enabled},Br.prototype.isActive=function(){return!!this._active},Br.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Br.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Br.prototype.mousedown=function(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(n.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)},Br.prototype.mousemoveWindow=function(t,e){if(this._active){var r=e;if(!(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)<this._clickTolerance)){var i=this._startPos;this._lastPos=r,this._box||(this._box=n.create("div","maplibregl-boxzoom mapboxgl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair","mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));var o=Math.min(i.x,r.x),a=Math.max(i.x,r.x),s=Math.min(i.y,r.y),l=Math.max(i.y,r.y);n.setTransform(this._box,"translate("+o+"px,"+s+"px)"),this._box.style.width=a-o+"px",this._box.style.height=l-s+"px"}}},Br.prototype.mouseupWindow=function(e,r){var i=this;if(this._active&&0===e.button){var o=this._startPos,a=r;if(this.reset(),n.suppressClick(),o.x!==a.x||o.y!==a.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:function(t){return t.fitScreenCoordinates(o,a,i._map.getBearing(),{linear:!0})}};this._fireEvent("boxzoomcancel",e)}},Br.prototype.keydown=function(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))},Br.prototype.reset=function(){this._active=!1,this._container.classList.remove("maplibregl-crosshair","mapboxgl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos},Br.prototype._fireEvent=function(e,n){return this._map.fire(new t.Event(e,{originalEvent:n}))};var Vr=function(t){this.reset(),this.numTouches=t.numTouches};Vr.prototype.reset=function(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1},Vr.prototype.touchstart=function(e,n,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){for(var n=new t.Point(0,0),r=0,i=e;r<i.length;r+=1)n._add(i[r]);return n.div(e.length)}(n),this.touches=Ur(r,n)))},Vr.prototype.touchmove=function(t,e,n){if(!this.aborted&&this.centroid){var r=Ur(n,e);for(var i in this.touches){var o=r[i];(!o||o.dist(this.touches[i])>30)&&(this.aborted=!0)}}},Vr.prototype.touchend=function(t,e,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){var r=!this.aborted&&this.centroid;if(this.reset(),r)return r}};var Gr=function(t){this.singleTap=new Vr(t),this.numTaps=t.numTaps,this.reset()};Gr.prototype.reset=function(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()},Gr.prototype.touchstart=function(t,e,n){this.singleTap.touchstart(t,e,n)},Gr.prototype.touchmove=function(t,e,n){this.singleTap.touchmove(t,e,n)},Gr.prototype.touchend=function(t,e,n){var r=this.singleTap.touchend(t,e,n);if(r){var i=t.timeStamp-this.lastTime<500,o=!this.lastTap||this.lastTap.dist(r)<30;if(i&&o||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}};var jr=function(){this._zoomIn=new Gr({numTouches:1,numTaps:2}),this._zoomOut=new Gr({numTouches:2,numTaps:1}),this.reset()};jr.prototype.reset=function(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()},jr.prototype.touchstart=function(t,e,n){this._zoomIn.touchstart(t,e,n),this._zoomOut.touchstart(t,e,n)},jr.prototype.touchmove=function(t,e,n){this._zoomIn.touchmove(t,e,n),this._zoomOut.touchmove(t,e,n)},jr.prototype.touchend=function(t,e,n){var r=this,i=this._zoomIn.touchend(t,e,n),o=this._zoomOut.touchend(t,e,n);return i?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(i)},{originalEvent:t})}}):o?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(o)},{originalEvent:t})}}):void 0},jr.prototype.touchcancel=function(){this.reset()},jr.prototype.enable=function(){this._enabled=!0},jr.prototype.disable=function(){this._enabled=!1,this.reset()},jr.prototype.isEnabled=function(){return this._enabled},jr.prototype.isActive=function(){return this._active};var Hr={0:1,2:2},qr=function(t){this.reset(),this._clickTolerance=t.clickTolerance||1};qr.prototype.reset=function(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton},qr.prototype._correctButton=function(t,e){return!1},qr.prototype._move=function(t,e){return{}},qr.prototype.mousedown=function(t,e){if(!this._lastPoint){var r=n.mouseButton(t);this._correctButton(t,r)&&(this._lastPoint=e,this._eventButton=r)}},qr.prototype.mousemoveWindow=function(t,e){var n=this._lastPoint;if(n)if(t.preventDefault(),function(t,e){var n=Hr[e];return void 0===t.buttons||(t.buttons&n)!==n}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(n)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(n,e)},qr.prototype.mouseupWindow=function(t){this._lastPoint&&n.mouseButton(t)===this._eventButton&&(this._moved&&n.suppressClick(),this.reset())},qr.prototype.enable=function(){this._enabled=!0},qr.prototype.disable=function(){this._enabled=!1,this.reset()},qr.prototype.isEnabled=function(){return this._enabled},qr.prototype.isActive=function(){return this._active};var Wr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.mousedown=function(e,n){t.prototype.mousedown.call(this,e,n),this._lastPoint&&(this._active=!0)},e.prototype._correctButton=function(t,e){return 0===e&&!t.ctrlKey},e.prototype._move=function(t,e){return{around:e,panDelta:e.sub(t)}},e}(qr),Xr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._correctButton=function(t,e){return 0===e&&t.ctrlKey||2===e},e.prototype._move=function(t,e){var n=.8*(e.x-t.x);if(n)return this._active=!0,{bearingDelta:n}},e.prototype.contextmenu=function(t){t.preventDefault()},e}(qr),Zr=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._correctButton=function(t,e){return 0===e&&t.ctrlKey||2===e},e.prototype._move=function(t,e){var n=-.5*(e.y-t.y);if(n)return this._active=!0,{pitchDelta:n}},e.prototype.contextmenu=function(t){t.preventDefault()},e}(qr),Yr=function(t){this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset()};Yr.prototype.reset=function(){this._active=!1,this._touches={},this._sum=new t.Point(0,0)},Yr.prototype.touchstart=function(t,e,n){return this._calculateTransform(t,e,n)},Yr.prototype.touchmove=function(t,e,n){if(this._active&&!(n.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,e,n)},Yr.prototype.touchend=function(t,e,n){this._calculateTransform(t,e,n),this._active&&n.length<this._minTouches&&this.reset()},Yr.prototype.touchcancel=function(){this.reset()},Yr.prototype._calculateTransform=function(e,n,r){r.length>0&&(this._active=!0);var i=Ur(r,n),o=new t.Point(0,0),a=new t.Point(0,0),s=0;for(var l in i){var u=i[l],c=this._touches[l];c&&(o._add(u),a._add(u.sub(c)),s++,i[l]=u)}if(this._touches=i,!(s<this._minTouches)&&a.mag()){var h=a.div(s);if(this._sum._add(h),!(this._sum.mag()<this._clickTolerance))return{around:o.div(s),panDelta:h}}},Yr.prototype.enable=function(){this._enabled=!0},Yr.prototype.disable=function(){this._enabled=!1,this.reset()},Yr.prototype.isEnabled=function(){return this._enabled},Yr.prototype.isActive=function(){return this._active};var Jr=function(){this.reset()};function Kr(t,e,n){for(var r=0;r<t.length;r++)if(t[r].identifier===n)return e[r]}function Qr(t,e){return Math.log(t/e)/Math.LN2}Jr.prototype.reset=function(){this._active=!1,delete this._firstTwoTouches},Jr.prototype._start=function(t){},Jr.prototype._move=function(t,e,n){return{}},Jr.prototype.touchstart=function(t,e,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([e[0],e[1]]))},Jr.prototype.touchmove=function(t,e,n){if(this._firstTwoTouches){t.preventDefault();var r=this._firstTwoTouches,i=r[1],o=Kr(n,e,r[0]),a=Kr(n,e,i);if(o&&a){var s=this._aroundCenter?null:o.add(a).div(2);return this._move([o,a],s,t)}}},Jr.prototype.touchend=function(t,e,r){if(this._firstTwoTouches){var i=this._firstTwoTouches,o=i[1],a=Kr(r,e,i[0]),s=Kr(r,e,o);a&&s||(this._active&&n.suppressClick(),this.reset())}},Jr.prototype.touchcancel=function(){this.reset()},Jr.prototype.enable=function(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around},Jr.prototype.disable=function(){this._enabled=!1,this.reset()},Jr.prototype.isEnabled=function(){return this._enabled},Jr.prototype.isActive=function(){return this._active};var $r=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),delete this._distance,delete this._startDistance},e.prototype._start=function(t){this._startDistance=this._distance=t[0].dist(t[1])},e.prototype._move=function(t,e){var n=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Qr(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Qr(this._distance,n),pinchAround:e}},e}(Jr);function ti(t,e){return 180*t.angleWith(e)/Math.PI}var ei=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),delete this._minDiameter,delete this._startVector,delete this._vector},e.prototype._start=function(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])},e.prototype._move=function(t,e){var n=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ti(this._vector,n),pinchAround:e}},e.prototype._isBelowThreshold=function(t){this._minDiameter=Math.min(this._minDiameter,t.mag());var e=25/(Math.PI*this._minDiameter)*360,n=ti(t,this._startVector);return Math.abs(n)<e},e}(Jr);function ni(t){return Math.abs(t.y)>Math.abs(t.x)}var ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),this._valid=void 0,delete this._firstMove,delete this._lastPoints},e.prototype._start=function(t){this._lastPoints=t,ni(t[0].sub(t[1]))&&(this._valid=!1)},e.prototype._move=function(t,e,n){var r=t[0].sub(this._lastPoints[0]),i=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}},e.prototype.gestureBeginsVertically=function(t,e,n){if(void 0!==this._valid)return this._valid;var r=t.mag()>=2,i=e.mag()>=2;if(r||i){if(!r||!i)return void 0===this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;var o=t.y>0==e.y>0;return ni(t)&&ni(e)&&o}},e}(Jr),ii={panStep:100,bearingStep:15,pitchStep:10},oi=function(){var t=ii;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1};function ai(t){return t*(2-t)}oi.prototype.reset=function(){this._active=!1},oi.prototype.keydown=function(t){var e=this;if(!(t.altKey||t.ctrlKey||t.metaKey)){var n=0,r=0,i=0,o=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:function(s){var l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:ai,zoom:n?Math.round(l)+n*(t.shiftKey?2:1):l,bearing:s.getBearing()+r*e._bearingStep,pitch:s.getPitch()+i*e._pitchStep,offset:[-o*e._panStep,-a*e._panStep],center:s.getCenter()},{originalEvent:t})}}}},oi.prototype.enable=function(){this._enabled=!0},oi.prototype.disable=function(){this._enabled=!1,this.reset()},oi.prototype.isEnabled=function(){return this._enabled},oi.prototype.isActive=function(){return this._active},oi.prototype.disableRotation=function(){this._rotationDisabled=!0},oi.prototype.enableRotation=function(){this._rotationDisabled=!1};var si=function(e,n){this._map=e,this._el=e.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=1/450,t.bindAll(["_onTimeout"],this)};si.prototype.setZoomRate=function(t){this._defaultZoomRate=t},si.prototype.setWheelZoomRate=function(t){this._wheelZoomRate=t},si.prototype.isEnabled=function(){return!!this._enabled},si.prototype.isActive=function(){return!!this._active||void 0!==this._finishTimeout},si.prototype.isZooming=function(){return!!this._zooming},si.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},si.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},si.prototype.wheel=function(e){if(this.isEnabled()){var n=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=t.browser.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}},si.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},si.prototype._start=function(e){if(this._delta){this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);var r=n.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(r)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}},si.prototype.renderFrame=function(){var e=this;if(this._frameId&&(this._frameId=null,this.isActive())){var n=this._map.transform;if(0!==this._delta){var r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var a,s="number"==typeof this._targetZoom?this._targetZoom:n.zoom,l=this._startZoom,u=this._easing,c=!1;if("wheel"===this._type&&l&&u){var h=Math.min((t.browser.now()-this._lastWheelEventTime)/200,1),p=u(h);a=t.number(l,s,p),h<1?this._frameId||(this._frameId=!0):c=!0}else a=s,c=!0;return this._active=!0,c&&(this._active=!1,this._finishTimeout=setTimeout((function(){e._zooming=!1,e._handler._triggerRenderFrame(),delete e._targetZoom,delete e._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!c,zoomDelta:a-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}},si.prototype._smoothOutEasing=function(e){var n=t.ease;if(this._prevEase){var r=this._prevEase,i=(t.browser.now()-r.start)/r.duration,o=r.easing(i+.01)-r.easing(i),a=.27/Math.sqrt(o*o+1e-4)*.01,s=Math.sqrt(.0729-a*a);n=t.bezier(a,s,.25,1)}return this._prevEase={start:t.browser.now(),duration:e,easing:n},n},si.prototype.reset=function(){this._active=!1};var li=function(t,e){this._clickZoom=t,this._tapZoom=e};li.prototype.enable=function(){this._clickZoom.enable(),this._tapZoom.enable()},li.prototype.disable=function(){this._clickZoom.disable(),this._tapZoom.disable()},li.prototype.isEnabled=function(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()},li.prototype.isActive=function(){return this._clickZoom.isActive()||this._tapZoom.isActive()};var ui=function(){this.reset()};ui.prototype.reset=function(){this._active=!1},ui.prototype.dblclick=function(t,e){return t.preventDefault(),{cameraAnimation:function(n){n.easeTo({duration:300,zoom:n.getZoom()+(t.shiftKey?-1:1),around:n.unproject(e)},{originalEvent:t})}}},ui.prototype.enable=function(){this._enabled=!0},ui.prototype.disable=function(){this._enabled=!1,this.reset()},ui.prototype.isEnabled=function(){return this._enabled},ui.prototype.isActive=function(){return this._active};var ci=function(){this._tap=new Gr({numTouches:1,numTaps:1}),this.reset()};ci.prototype.reset=function(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()},ci.prototype.touchstart=function(t,e,n){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=e[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(t,e,n))},ci.prototype.touchmove=function(t,e,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;var r=e[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(t,e,n)},ci.prototype.touchend=function(t,e,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(t,e,n)&&(this._tapTime=t.timeStamp)},ci.prototype.touchcancel=function(){this.reset()},ci.prototype.enable=function(){this._enabled=!0},ci.prototype.disable=function(){this._enabled=!1,this.reset()},ci.prototype.isEnabled=function(){return this._enabled},ci.prototype.isActive=function(){return this._active};var hi=function(t,e,n){this._el=t,this._mousePan=e,this._touchPan=n};hi.prototype.enable=function(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},hi.prototype.disable=function(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},hi.prototype.isEnabled=function(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()},hi.prototype.isActive=function(){return this._mousePan.isActive()||this._touchPan.isActive()};var pi=function(t,e,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=n};pi.prototype.enable=function(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()},pi.prototype.disable=function(){this._mouseRotate.disable(),this._mousePitch.disable()},pi.prototype.isEnabled=function(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())},pi.prototype.isActive=function(){return this._mouseRotate.isActive()||this._mousePitch.isActive()};var fi=function(t,e,n,r){this._el=t,this._touchZoom=e,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0};fi.prototype.enable=function(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},fi.prototype.disable=function(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},fi.prototype.isEnabled=function(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()},fi.prototype.isActive=function(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()},fi.prototype.disableRotation=function(){this._rotationDisabled=!0,this._touchRotate.disable()},fi.prototype.enableRotation=function(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()};var di=function(t){return t.zoom||t.drag||t.pitch||t.rotate},mi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(t.Event);function gi(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}var yi=function(e,r){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pr(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r),t.bindAll(["handleEvent","handleWindowEvent"],this);var i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[t.window,"blur",void 0]];for(var o=0,a=this._listeners;o<a.length;o+=1){var s=a[o],l=s[0];n.addEventListener(l,s[1],l===t.window.document?this.handleWindowEvent:this.handleEvent,s[2])}};yi.prototype.destroy=function(){for(var e=0,r=this._listeners;e<r.length;e+=1){var i=r[e],o=i[0];n.removeEventListener(o,i[1],o===t.window.document?this.handleWindowEvent:this.handleEvent,i[2])}},yi.prototype._addDefaultHandlers=function(t){var e=this._map,n=e.getCanvasContainer();this._add("mapEvent",new zr(e,t));var r=e.boxZoom=new Br(e,t);this._add("boxZoom",r);var i=new jr,o=new ui;e.doubleClickZoom=new li(o,i),this._add("tapZoom",i),this._add("clickZoom",o);var a=new ci;this._add("tapDragZoom",a);var s=e.touchPitch=new ri;this._add("touchPitch",s);var l=new Xr(t),u=new Zr(t);e.dragRotate=new pi(t,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);var c=new Wr(t),h=new Yr(t);e.dragPan=new hi(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);var p=new ei,f=new $r;e.touchZoomRotate=new fi(n,f,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]);var d=e.scrollZoom=new si(e,this);this._add("scrollZoom",d,["mousePan"]);var m=e.keyboard=new oi;this._add("keyboard",m),this._add("blockableMapEvent",new Fr(e));for(var g=0,y=["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"];g<y.length;g+=1){var v=y[g];t.interactive&&t[v]&&e[v].enable(t[v])}},yi.prototype._add=function(t,e,n){this._handlers.push({handlerName:t,handler:e,allowed:n}),this._handlersById[t]=e},yi.prototype.stop=function(t){if(!this._updatingCamera){for(var e=0,n=this._handlers;e<n.length;e+=1)n[e].handler.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}},yi.prototype.isActive=function(){for(var t=0,e=this._handlers;t<e.length;t+=1)if(e[t].handler.isActive())return!0;return!1},yi.prototype.isZooming=function(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()},yi.prototype.isRotating=function(){return!!this._eventsInProgress.rotate},yi.prototype.isMoving=function(){return Boolean(di(this._eventsInProgress))||this.isZooming()},yi.prototype._blockedByActive=function(t,e,n){for(var r in t)if(r!==n&&(!e||e.indexOf(r)<0))return!0;return!1},yi.prototype.handleWindowEvent=function(t){this.handleEvent(t,t.type+"Window")},yi.prototype._getMapTouches=function(t){for(var e=[],n=0,r=t;n<r.length;n+=1){var i=r[n];this._el.contains(i.target)&&e.push(i)}return e},yi.prototype.handleEvent=function(t,e){if("blur"!==t.type){this._updatingCamera=!0;for(var r="renderFrame"===t.type?void 0:t,i={needsRenderFrame:!1},o={},a={},s=t.touches?this._getMapTouches(t.touches):void 0,l=s?n.touchPos(this._el,s):n.mousePos(this._el,t),u=0,c=this._handlers;u<c.length;u+=1){var h=c[u],p=h.handlerName,f=h.handler,d=h.allowed;if(f.isEnabled()){var m=void 0;this._blockedByActive(a,d,p)?f.reset():f[e||t.type]&&(m=f[e||t.type](t,l,s),this.mergeHandlerResult(i,o,m,p,r),m&&m.needsRenderFrame&&this._triggerRenderFrame()),(m||f.isActive())&&(a[p]=f)}}var g={};for(var y in this._previousActiveHandlers)a[y]||(g[y]=r);this._previousActiveHandlers=a,(Object.keys(g).length||gi(i))&&(this._changes.push([i,o,g]),this._triggerRenderFrame()),(Object.keys(a).length||gi(i))&&this._map._stop(!0),this._updatingCamera=!1;var v=i.cameraAnimation;v&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],v(this._map))}else this.stop(!0)},yi.prototype.mergeHandlerResult=function(e,n,r,i,o){if(r){t.extend(e,r);var a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}},yi.prototype._applyChanges=function(){for(var e={},n={},r={},i=0,o=this._changes;i<o.length;i+=1){var a=o[i],s=a[0],l=a[1],u=a[2];s.panDelta&&(e.panDelta=(e.panDelta||new t.Point(0,0))._add(s.panDelta)),s.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(e.around=s.around),void 0!==s.pinchAround&&(e.pinchAround=s.pinchAround),s.noInertia&&(e.noInertia=s.noInertia),t.extend(n,l),t.extend(r,u)}this._updateMapTransform(e,n,r),this._changes=[]},yi.prototype._updateMapTransform=function(t,e,n){var r=this._map,i=r.transform;if(!gi(t))return this._fireEvents(e,n,!0);var o=t.panDelta,a=t.zoomDelta,s=t.bearingDelta,l=t.pitchDelta,u=t.around,c=t.pinchAround;void 0!==c&&(u=c),r._stop(!0),u=u||r.transform.centerPoint;var h=i.pointLocation(o?u.sub(o):u);s&&(i.bearing+=s),l&&(i.pitch+=l),a&&(i.zoom+=a),i.setLocationAtPoint(h,u),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,n,!0)},yi.prototype._fireEvents=function(e,n,r){var i=this,o=di(this._eventsInProgress),a=di(e),s={};for(var l in e)this._eventsInProgress[l]||(s[l+"start"]=e[l].originalEvent),this._eventsInProgress[l]=e[l];for(var u in!o&&a&&this._fireEvent("movestart",a.originalEvent),s)this._fireEvent(u,s[u]);for(var c in a&&this._fireEvent("move",a.originalEvent),e)this._fireEvent(c,e[c].originalEvent);var h,p={};for(var f in this._eventsInProgress){var d=this._eventsInProgress[f],m=d.handlerName,g=d.originalEvent;this._handlersById[m].isActive()||(delete this._eventsInProgress[f],p[f+"end"]=h=n[m]||g)}for(var y in p)this._fireEvent(y,p[y]);var v=di(this._eventsInProgress);if(r&&(o||a)&&!v){this._updatingCamera=!0;var _=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),x=function(t){return 0!==t&&-i._bearingSnap<t&&t<i._bearingSnap};_?(x(_.bearing||this._map.getBearing())&&(_.bearing=0),this._map.easeTo(_,{originalEvent:h})):(this._map.fire(new t.Event("moveend",{originalEvent:h})),x(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}},yi.prototype._fireEvent=function(e,n){this._map.fire(new t.Event(e,n?{originalEvent:n}:{}))},yi.prototype._requestFrame=function(){var t=this;return this._map.triggerRepaint(),this._map._renderTaskQueue.add((function(e){delete t._frameId,t.handleEvent(new mi("renderFrame",{timeStamp:e})),t._applyChanges()}))},yi.prototype._triggerRenderFrame=function(){void 0===this._frameId&&(this._frameId=this._requestFrame())};var vi=function(e){function n(n,r){e.call(this),this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=r.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.getCenter=function(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)},n.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},n.prototype.panBy=function(e,n,r){return e=t.Point.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},n),r)},n.prototype.panTo=function(e,n,r){return this.easeTo(t.extend({center:e},n),r)},n.prototype.getZoom=function(){return this.transform.zoom},n.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},n.prototype.zoomTo=function(e,n,r){return this.easeTo(t.extend({zoom:e},n),r)},n.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},n.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},n.prototype.getBearing=function(){return this.transform.bearing},n.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},n.prototype.getPadding=function(){return this.transform.padding},n.prototype.setPadding=function(t,e){return this.jumpTo({padding:t},e),this},n.prototype.rotateTo=function(e,n,r){return this.easeTo(t.extend({bearing:e},n),r)},n.prototype.resetNorth=function(e,n){return this.rotateTo(0,t.extend({duration:1e3},e),n),this},n.prototype.resetNorthPitch=function(e,n){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),n),this},n.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this},n.prototype.getPitch=function(){return this.transform.pitch},n.prototype.setPitch=function(t,e){return this.jumpTo({pitch:t},e),this},n.prototype.cameraForBounds=function(e,n){e=t.LngLatBounds.convert(e);var r=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,n)},n.prototype._cameraForBoxAndBearing=function(e,n,r,i){var o={top:0,bottom:0,right:0,left:0};if("number"==typeof(i=t.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding){var a=i.padding;i.padding={top:a,bottom:a,right:a,left:a}}i.padding=t.extend(o,i.padding);var s=this.transform,l=s.padding,u=s.project(t.LngLat.convert(e)),c=s.project(t.LngLat.convert(n)),h=u.rotate(-r*Math.PI/180),p=c.rotate(-r*Math.PI/180),f=new t.Point(Math.max(h.x,p.x),Math.max(h.y,p.y)),d=new t.Point(Math.min(h.x,p.x),Math.min(h.y,p.y)),m=f.sub(d),g=(s.width-(l.left+l.right+i.padding.left+i.padding.right))/m.x,y=(s.height-(l.top+l.bottom+i.padding.top+i.padding.bottom))/m.y;if(!(y<0||g<0)){var v=Math.min(s.scaleZoom(s.scale*Math.min(g,y)),i.maxZoom),_="number"==typeof i.offset.x?new t.Point(i.offset.x,i.offset.y):t.Point.convert(i.offset),x=new t.Point((i.padding.left-i.padding.right)/2,(i.padding.top-i.padding.bottom)/2).rotate(r*Math.PI/180),b=_.add(x).mult(s.scale/s.zoomScale(v));return{center:s.unproject(u.add(c).div(2).sub(b)),zoom:v,bearing:r}}t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")},n.prototype.fitBounds=function(t,e,n){return this._fitInternal(this.cameraForBounds(t,e),e,n)},n.prototype.fitScreenCoordinates=function(e,n,r,i,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(t.Point.convert(e)),this.transform.pointLocation(t.Point.convert(n)),r,i),i,o)},n.prototype._fitInternal=function(e,n,r){return e?(delete(n=t.extend(e,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this},n.prototype.jumpTo=function(e,n){this.stop();var r=this.transform,i=!1,o=!1,a=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(i=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=t.LngLat.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(o=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(a=!0,r.pitch=+e.pitch),null==e.padding||r.isPaddingEqual(e.padding)||(r.padding=e.padding),this.fire(new t.Event("movestart",n)).fire(new t.Event("move",n)),i&&this.fire(new t.Event("zoomstart",n)).fire(new t.Event("zoom",n)).fire(new t.Event("zoomend",n)),o&&this.fire(new t.Event("rotatestart",n)).fire(new t.Event("rotate",n)).fire(new t.Event("rotateend",n)),a&&this.fire(new t.Event("pitchstart",n)).fire(new t.Event("pitch",n)).fire(new t.Event("pitchend",n)),this.fire(new t.Event("moveend",n))},n.prototype.easeTo=function(e,n){var r=this;this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||!e.essential&&t.browser.prefersReducedMotion)&&(e.duration=0);var i=this.transform,o=this.getZoom(),a=this.getBearing(),s=this.getPitch(),l=this.getPadding(),u="zoom"in e?+e.zoom:o,c="bearing"in e?this._normalizeBearing(e.bearing,a):a,h="pitch"in e?+e.pitch:s,p="padding"in e?e.padding:i.padding,f=t.Point.convert(e.offset),d=i.centerPoint.add(f),m=i.pointLocation(d),g=t.LngLat.convert(e.center||m);this._normalizeCenter(g);var y,v,_=i.project(m),x=i.project(g).sub(_),b=i.zoomScale(u-o);e.around&&(y=t.LngLat.convert(e.around),v=i.locationPoint(y));var w={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||u!==o,this._rotating=this._rotating||a!==c,this._pitching=this._pitching||h!==s,this._padding=!i.isPaddingEqual(p),this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,w),this._ease((function(e){if(r._zooming&&(i.zoom=t.number(o,u,e)),r._rotating&&(i.bearing=t.number(a,c,e)),r._pitching&&(i.pitch=t.number(s,h,e)),r._padding&&(i.interpolatePadding(l,p,e),d=i.centerPoint.add(f)),y)i.setLocationAtPoint(y,v);else{var m=i.zoomScale(i.zoom-o),g=u>o?Math.min(2,b):Math.max(.5,b),w=Math.pow(g,1-e),E=i.unproject(_.add(x.mult(e*w)).mult(m));i.setLocationAtPoint(i.renderWorldCopies?E.wrap():E,d)}r._fireMoveEvents(n)}),(function(t){r._afterEase(n,t)}),e),this},n.prototype._prepareEase=function(e,n,r){void 0===r&&(r={}),this._moving=!0,n||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))},n.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},n.prototype._afterEase=function(e,n){if(!this._easeId||!n||this._easeId!==n){delete this._easeId;var r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),i&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}},n.prototype.flyTo=function(e,n){var r=this;if(!e.essential&&t.browser.prefersReducedMotion){var i=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,n)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var o=this.transform,a=this.getZoom(),s=this.getBearing(),l=this.getPitch(),u=this.getPadding(),c="zoom"in e?t.clamp(+e.zoom,o.minZoom,o.maxZoom):a,h="bearing"in e?this._normalizeBearing(e.bearing,s):s,p="pitch"in e?+e.pitch:l,f="padding"in e?e.padding:o.padding,d=o.zoomScale(c-a),m=t.Point.convert(e.offset),g=o.centerPoint.add(m),y=o.pointLocation(g),v=t.LngLat.convert(e.center||y);this._normalizeCenter(v);var _=o.project(y),x=o.project(v).sub(_),b=e.curve,w=Math.max(o.width,o.height),E=w/d,S=x.mag();if("minZoom"in e){var M=t.clamp(Math.min(e.minZoom,a,c),o.minZoom,o.maxZoom),T=w/o.zoomScale(M-a);b=Math.sqrt(T/S*2)}var C=b*b;function I(t){var e=(E*E-w*w+(t?-1:1)*C*C*S*S)/(2*(t?E:w)*C*S);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function L(t){return(Math.exp(t)+Math.exp(-t))/2}var P=I(0),R=function(t){return L(P)/L(P+b*t)},D=function(t){return w*((L(P)*(A(e=P+b*t)/L(e))-A(P))/C)/S;var e},N=(I(1)-P)/b;if(Math.abs(S)<1e-6||!isFinite(N)){if(Math.abs(w-E)<1e-6)return this.easeTo(e,n);var O=E<w?-1:1;N=Math.abs(Math.log(E/w))/b,D=function(){return 0},R=function(t){return Math.exp(O*b*t)}}return e.duration="duration"in e?+e.duration:1e3*N/("screenSpeed"in e?+e.screenSpeed/b:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=s!==h,this._pitching=p!==l,this._padding=!o.isPaddingEqual(f),this._prepareEase(n,!1),this._ease((function(e){var i=e*N,d=1/R(i);o.zoom=1===e?c:a+o.scaleZoom(d),r._rotating&&(o.bearing=t.number(s,h,e)),r._pitching&&(o.pitch=t.number(l,p,e)),r._padding&&(o.interpolatePadding(u,f,e),g=o.centerPoint.add(m));var y=1===e?v:o.unproject(_.add(x.mult(D(i))).mult(d));o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,g),r._fireMoveEvents(n)}),(function(){return r._afterEase(n)}),e),this},n.prototype.isEasing=function(){return!!this._easeFrameId},n.prototype.stop=function(){return this._stop()},n.prototype._stop=function(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var n=this._onEaseEnd;delete this._onEaseEnd,n.call(this,e)}if(!t){var r=this.handlers;r&&r.stop(!1)}return this},n.prototype._ease=function(e,n,r){!1===r.animate||0===r.duration?(e(1),n()):(this._easeStart=t.browser.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},n.prototype._renderFrameCallback=function(){var e=Math.min((t.browser.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},n.prototype._normalizeBearing=function(e,n){e=t.wrap(e,-180,180);var r=Math.abs(e-n);return Math.abs(e-360-n)<r&&(e-=360),Math.abs(e+360-n)<r&&(e+=360),e},n.prototype._normalizeCenter=function(t){var e=this.transform;if(e.renderWorldCopies&&!e.lngRange){var n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}},n}(t.Evented),_i=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)};_i.prototype.getDefaultPosition=function(){return"bottom-right"},_i.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=n.create("button","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.type="button",this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("maplibregl-compact","mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},_i.prototype.onRemove=function(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0},_i.prototype._setElementTitle=function(t,e){var n=this._map._getUIString("AttributionControl."+e);t.title=n,t.setAttribute("aria-label",n)},_i.prototype._toggleAttribution=function(){this._container.classList.contains("maplibregl-compact-show")||this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","false")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","true"))},_i.prototype._updateEditLink=function(){var e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));var n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){var r=n.reduce((function(t,e,r){return e.value&&(t+=e.key+"="+e.value+(r<n.length-1?"&":"")),t}),"?");e.href=t.config.FEEDBACK_URL+"/"+r+(this._map._hash?this._map._hash.getHashString(!0):""),e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}},_i.prototype._updateData=function(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())},_i.prototype._updateAttributions=function(){if(this._map.style){var t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((function(t){return"string"!=typeof t?"":t}))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){var e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}var n=this._map.style.sourceCaches;for(var r in n){var i=n[r];if(i.used){var o=i.getSource();o.attribution&&t.indexOf(o.attribution)<0&&t.push(o.attribution)}}t.sort((function(t,e){return t.length-e.length}));var a=(t=t.filter((function(e,n){for(var r=n+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}))).join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._editLink=null)}},_i.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("maplibregl-compact","mapboxgl-compact"):this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show")};var xi=function(){t.bindAll(["_updateLogo"],this),t.bindAll(["_updateCompact"],this)};xi.prototype.onAdd=function(t){this._map=t,this._container=n.create("div","maplibregl-ctrl mapboxgl-ctrl");var e=n.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container},xi.prototype.onRemove=function(){n.remove(this._container),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)},xi.prototype.getDefaultPosition=function(){return"bottom-left"},xi.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},xi.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}},xi.prototype._updateCompact=function(){var t=this._container.children;if(t.length){var e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("maplibregl-compact","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}};var bi=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};bi.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},bi.prototype.remove=function(t){for(var e=this._currentlyRunning,n=0,r=e?this._queue.concat(e):this._queue;n<r.length;n+=1){var i=r[n];if(i.id===t)return void(i.cancelled=!0)}},bi.prototype.run=function(t){void 0===t&&(t=0);var e=this._currentlyRunning=this._queue;this._queue=[];for(var n=0,r=e;n<r.length;n+=1){var i=r[n];if(!i.cancelled&&(i.callback(t),this._cleared))break}this._cleared=!1,this._currentlyRunning=!1},bi.prototype.clear=function(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]};var wi={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm"},Ei=t.window.HTMLImageElement,Si=t.window.HTMLElement,Mi=t.window.ImageBitmap,Ti={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},Ci=function(r){function i(e){var n=this;if(null!=(e=t.extend({},Ti,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>60)throw new Error("maxPitch must be less than or equal to 60");var i=new Er(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies);if(r.call(this,i,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new bi,this._controls=[],this._mapId=t.uniqueId(),this._locale=t.extend({},wi,e.locale),this._clickTolerance=e.clickTolerance,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken),"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error("Container '"+e.container+"' not found.")}else{if(!(e.container instanceof Si))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(function(){return n._update(!1)})),this.on("moveend",(function(){return n._update(!1)})),this.on("zoom",(function(){return n._update(!0)})),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new yi(this,e),this._hash=e.hash&&new Mr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new _i({customAttribution:e.customAttribution})),this.addControl(new xi,e.logoPosition),this.on("style.load",(function(){n.transform.unmodified&&n.jumpTo(n.style.stylesheet)})),this.on("data",(function(e){n._update("style"===e.dataType),n.fire(new t.Event(e.dataType+"data",e))})),this.on("dataloading",(function(e){n.fire(new t.Event(e.dataType+"dataloading",e))}))}r&&(i.__proto__=r),(i.prototype=Object.create(r&&r.prototype)).constructor=i;var o={showTileBoundaries:{configurable:!0},showPadding:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0},version:{configurable:!0}};return i.prototype._getMapId=function(){return this._mapId},i.prototype.addControl=function(e,n){if(void 0===n&&(n=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));var r=e.onAdd(this);this._controls.push(e);var i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this},i.prototype.removeControl=function(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));var n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this},i.prototype.hasControl=function(t){return this._controls.indexOf(t)>-1},i.prototype.resize=function(e){var n=this._containerDimensions(),r=n[0],i=n[1];this._resizeCanvas(r,i),this.transform.resize(r,i),this.painter.resize(r,i);var o=!this._moving;return o&&(this.stop(),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e))),this.fire(new t.Event("resize",e)),o&&this.fire(new t.Event("moveend",e)),this},i.prototype.getBounds=function(){return this.transform.getBounds()},i.prototype.getMaxBounds=function(){return this.transform.getMaxBounds()},i.prototype.setMaxBounds=function(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()},i.prototype.setMinZoom=function(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")},i.prototype.getMinZoom=function(){return this.transform.minZoom},i.prototype.setMaxZoom=function(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},i.prototype.getMaxZoom=function(){return this.transform.maxZoom},i.prototype.setMinPitch=function(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")},i.prototype.getMinPitch=function(){return this.transform.minPitch},i.prototype.setMaxPitch=function(t){if((t=null==t?60:t)>60)throw new Error("maxPitch must be less than or equal to 60");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")},i.prototype.getMaxPitch=function(){return this.transform.maxPitch},i.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},i.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update()},i.prototype.project=function(e){return this.transform.locationPoint(t.LngLat.convert(e))},i.prototype.unproject=function(e){return this.transform.pointLocation(t.Point.convert(e))},i.prototype.isMoving=function(){return this._moving||this.handlers.isMoving()},i.prototype.isZooming=function(){return this._zooming||this.handlers.isZooming()},i.prototype.isRotating=function(){return this._rotating||this.handlers.isRotating()},i.prototype._createDelegatedListener=function(t,e,n){var r,i=this;if("mouseenter"===t||"mouseover"===t){var o=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){var a=i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[];a.length?o||(o=!0,n.call(i,new Nr(t,i,r.originalEvent,{features:a}))):o=!1},mouseout:function(){o=!1}}}}if("mouseleave"===t||"mouseout"===t){var a=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){(i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?a=!0:a&&(a=!1,n.call(i,new Nr(t,i,r.originalEvent)))},mouseout:function(e){a&&(a=!1,n.call(i,new Nr(t,i,e.originalEvent)))}}}}return{layer:e,listener:n,delegates:(r={},r[t]=function(t){var r=i.getLayer(e)?i.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,n.call(i,t),delete t.features)},r)}},i.prototype.on=function(t,e,n){if(void 0===n)return r.prototype.on.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(i),i.delegates)this.on(o,i.delegates[o]);return this},i.prototype.once=function(t,e,n){if(void 0===n)return r.prototype.once.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in i.delegates)this.once(o,i.delegates[o]);return this},i.prototype.off=function(t,e,n){var i=this;return void 0===n?r.prototype.off.call(this,t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&function(r){for(var o=r[t],a=0;a<o.length;a++){var s=o[a];if(s.layer===e&&s.listener===n){for(var l in s.delegates)i.off(l,s.delegates[l]);return o.splice(a,1),i}}}(this._delegatedListeners),this)},i.prototype.queryRenderedFeatures=function(e,n){if(!this.style)return[];var r;if(void 0!==n||void 0===e||e instanceof t.Point||Array.isArray(e)||(n=e,e=void 0),n=n||{},(e=e||[[0,0],[this.transform.width,this.transform.height]])instanceof t.Point||"number"==typeof e[0])r=[t.Point.convert(e)];else{var i=t.Point.convert(e[0]),o=t.Point.convert(e[1]);r=[i,new t.Point(o.x,i.y),o,new t.Point(i.x,o.y),i]}return this.style.queryRenderedFeatures(r,n,this.transform)},i.prototype.querySourceFeatures=function(t,e){return this.style.querySourceFeatures(t,e)},i.prototype.setStyle=function(e,n){return!1!==(n=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(e,n))},i.prototype.setTransformRequest=function(t){return this._requestManager.setTransformRequest(t),this},i.prototype._getUIString=function(t){var e=this._locale[t];if(null==e)throw new Error("Missing UI string '"+t+"'");return e},i.prototype._updateStyle=function(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove()),t?(this.style=new je(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t),this):(delete this.style,this)},i.prototype._lazyInitEmptyStyle=function(){this.style||(this.style=new je(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())},i.prototype._diffStyle=function(e,n){var r=this;if("string"==typeof e){var i=this._requestManager.normalizeStyleURL(e),o=this._requestManager.transformRequest(i,t.ResourceType.Style);t.getJSON(o,(function(e,i){e?r.fire(new t.ErrorEvent(e)):i&&r._updateDiff(i,n)}))}else"object"==typeof e&&this._updateDiff(e,n)},i.prototype._updateDiff=function(e,n){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce("Unable to perform style diff: "+(r.message||r.error||r)+". Rebuilding the style from scratch."),this._updateStyle(e,n)}},i.prototype.getStyle=function(){if(this.style)return this.style.serialize()},i.prototype.isStyleLoaded=function(){return this.style?this.style.loaded():t.warnOnce("There is no style added to the map.")},i.prototype.addSource=function(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)},i.prototype.isSourceLoaded=function(e){var n=this.style&&this.style.sourceCaches[e];if(void 0!==n)return n.loaded();this.fire(new t.ErrorEvent(new Error("There is no source with ID '"+e+"'")))},i.prototype.areTilesLoaded=function(){var t=this.style&&this.style.sourceCaches;for(var e in t){var n=t[e]._tiles;for(var r in n){var i=n[r];if("loaded"!==i.state&&"errored"!==i.state)return!1}}return!0},i.prototype.addSourceType=function(t,e,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,n)},i.prototype.removeSource=function(t){return this.style.removeSource(t),this._update(!0)},i.prototype.getSource=function(t){return this.style.getSource(t)},i.prototype.addImage=function(e,n,r){void 0===r&&(r={});var i=r.pixelRatio;void 0===i&&(i=1);var o=r.sdf;void 0===o&&(o=!1);var a=r.stretchX,s=r.stretchY,l=r.content;if(this._lazyInitEmptyStyle(),n instanceof Ei||Mi&&n instanceof Mi){var u=t.browser.getImageData(n);this.style.addImage(e,{data:new t.RGBAImage({width:u.width,height:u.height},u.data),pixelRatio:i,stretchX:a,stretchY:s,content:l,sdf:o,version:0})}else{if(void 0===n.width||void 0===n.height)return this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));var c=n;this.style.addImage(e,{data:new t.RGBAImage({width:n.width,height:n.height},new Uint8Array(n.data)),pixelRatio:i,stretchX:a,stretchY:s,content:l,sdf:o,version:0,userImage:c}),c.onAdd&&c.onAdd(this,e)}},i.prototype.updateImage=function(e,n){var r=this.style.getImage(e);if(!r)return this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));var i=n instanceof Ei||Mi&&n instanceof Mi?t.browser.getImageData(n):n,o=i.width,a=i.height,s=i.data;return void 0===o||void 0===a?this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))):o!==r.data.width||a!==r.data.height?this.fire(new t.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(r.data.replace(s,!(n instanceof Ei||Mi&&n instanceof Mi)),void this.style.updateImage(e,r))},i.prototype.hasImage=function(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)},i.prototype.removeImage=function(t){this.style.removeImage(t)},i.prototype.loadImage=function(e,n){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),n)},i.prototype.listImages=function(){return this.style.listImages()},i.prototype.addLayer=function(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)},i.prototype.moveLayer=function(t,e){return this.style.moveLayer(t,e),this._update(!0)},i.prototype.removeLayer=function(t){return this.style.removeLayer(t),this._update(!0)},i.prototype.getLayer=function(t){return this.style.getLayer(t)},i.prototype.setLayerZoomRange=function(t,e,n){return this.style.setLayerZoomRange(t,e,n),this._update(!0)},i.prototype.setFilter=function(t,e,n){return void 0===n&&(n={}),this.style.setFilter(t,e,n),this._update(!0)},i.prototype.getFilter=function(t){return this.style.getFilter(t)},i.prototype.setPaintProperty=function(t,e,n,r){return void 0===r&&(r={}),this.style.setPaintProperty(t,e,n,r),this._update(!0)},i.prototype.getPaintProperty=function(t,e){return this.style.getPaintProperty(t,e)},i.prototype.setLayoutProperty=function(t,e,n,r){return void 0===r&&(r={}),this.style.setLayoutProperty(t,e,n,r),this._update(!0)},i.prototype.getLayoutProperty=function(t,e){return this.style.getLayoutProperty(t,e)},i.prototype.setLight=function(t,e){return void 0===e&&(e={}),this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)},i.prototype.getLight=function(){return this.style.getLight()},i.prototype.setFeatureState=function(t,e){return this.style.setFeatureState(t,e),this._update()},i.prototype.removeFeatureState=function(t,e){return this.style.removeFeatureState(t,e),this._update()},i.prototype.getFeatureState=function(t){return this.style.getFeatureState(t)},i.prototype.getContainer=function(){return this._container},i.prototype.getCanvasContainer=function(){return this._canvasContainer},i.prototype.getCanvas=function(){return this._canvas},i.prototype._containerDimensions=function(){var t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]},i.prototype._setupContainer=function(){var t=this._container;t.classList.add("maplibregl-map","mapboxgl-map");var e=this._canvasContainer=n.create("div","maplibregl-canvas-container mapboxgl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");var r=this._containerDimensions();this._resizeCanvas(r[0],r[1]);var i=this._controlContainer=n.create("div","maplibregl-control-container mapboxgl-control-container",t),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((function(t){o[t]=n.create("div","maplibregl-ctrl-"+t+" mapboxgl-ctrl-"+t,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)},i.prototype._resizeCanvas=function(e,n){var r=t.browser.devicePixelRatio||1;this._canvas.width=r*e,this._canvas.height=r*n,this._canvas.style.width=e+"px",this._canvas.style.height=n+"px"},i.prototype._setupPainter=function(){var n=t.extend({},e.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",n)||this._canvas.getContext("experimental-webgl",n);r?(this.painter=new _r(r,this.transform),t.webpSupported.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))},i.prototype._contextLost=function(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))},i.prototype._contextRestored=function(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))},i.prototype._onMapScroll=function(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},i.prototype.loaded=function(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()},i.prototype._update=function(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this},i.prototype._requestRenderFrame=function(t){return this._update(),this._renderTaskQueue.add(t)},i.prototype._cancelRenderFrame=function(t){this._renderTaskQueue.remove(t)},i.prototype._render=function(e){var n,r=this,i=0,o=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(n=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,n),i=t.browser.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),!this._removed){var a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;var s=this.transform.zoom,l=t.browser.now();this.style.zoomHistory.update(s,l);var u=new t.EvaluationParameters(s,{now:l,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),c=u.crossFadingFactor();1===c&&c===this._crossFadingFactor||(a=!0,this._crossFadingFactor=c),this.style.update(u)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){var h=t.browser.now()-i;o.endQueryEXT(o.TIME_ELAPSED_EXT,n),setTimeout((function(){var e=o.getQueryObjectEXT(n,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(n),r.fire(new t.Event("gpu-timing-frame",{cpuTime:h,gpuTime:e}))}),50)}if(this.listens("gpu-timing-layer")){var p=this.painter.collectGpuTimers();setTimeout((function(){var e=r.painter.queryGpuTimers(p);r.fire(new t.Event("gpu-timing-layer",{layerTimes:e}))}),50)}var f=this._sourcesDirty||this._styleDirty||this._placementDirty;return f||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.Event("idle")),!this._loaded||this._fullyLoaded||f||(this._fullyLoaded=!0),this}},i.prototype.remove=function(){this._hash&&this._hash.remove();for(var e=0,n=this._controls;e<n.length;e+=1)n[e].onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),void 0!==t.window&&(t.window.removeEventListener("resize",this._onWindowResize,!1),t.window.removeEventListener("orientationchange",this._onWindowResize,!1),t.window.removeEventListener("online",this._onWindowOnline,!1));var r=this.painter.context.gl.getExtension("WEBGL_lose_context");r&&r.loseContext(),Ii(this._canvasContainer),Ii(this._controlContainer),this._container.classList.remove("maplibregl-map","mapboxgl-map"),this._removed=!0,this.fire(new t.Event("remove"))},i.prototype.triggerRepaint=function(){var e=this;this.style&&!this._frame&&(this._frame=t.browser.frame((function(t){e._frame=null,e._render(t)})))},i.prototype._onWindowOnline=function(){this._update()},i.prototype._onWindowResize=function(t){this._trackResize&&this.resize({originalEvent:t})._update()},o.showTileBoundaries.get=function(){return!!this._showTileBoundaries},o.showTileBoundaries.set=function(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())},o.showPadding.get=function(){return!!this._showPadding},o.showPadding.set=function(t){this._showPadding!==t&&(this._showPadding=t,this._update())},o.showCollisionBoxes.get=function(){return!!this._showCollisionBoxes},o.showCollisionBoxes.set=function(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())},o.showOverdrawInspector.get=function(){return!!this._showOverdrawInspector},o.showOverdrawInspector.set=function(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())},o.repaint.get=function(){return!!this._repaint},o.repaint.set=function(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())},o.vertices.get=function(){return!!this._vertices},o.vertices.set=function(t){this._vertices=t,this._update()},i.prototype._setCacheLimits=function(e,n){t.setCacheLimits(e,n)},o.version.get=function(){return t.version},Object.defineProperties(i.prototype,o),i}(vi);function Ii(t){t.parentNode&&t.parentNode.removeChild(t)}var Ai={showCompass:!0,showZoom:!0,visualizePitch:!1},Li=function(e){var r=this;this.options=t.extend({},Ai,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",(function(t){return r._map.zoomIn({},{originalEvent:t})})),n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",(function(t){return r._map.zoomOut({},{originalEvent:t})})),n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",(function(t){r.options.visualizePitch?r._map.resetNorthPitch({},{originalEvent:t}):r._map.resetNorth({},{originalEvent:t})})),this._compassIcon=n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))};Li.prototype._updateZoomButtons=function(){var t=this._map.getZoom(),e=t===this._map.getMaxZoom(),n=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())},Li.prototype._rotateCompassArrow=function(){var t=this.options.visualizePitch?"scale("+1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)+") rotateX("+this._map.transform.pitch+"deg) rotateZ("+this._map.transform.angle*(180/Math.PI)+"deg)":"rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassIcon.style.transform=t},Li.prototype.onAdd=function(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Pi(this._map,this._compass,this.options.visualizePitch)),this._container},Li.prototype.onRemove=function(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map},Li.prototype._createButton=function(t,e){var r=n.create("button",t,this._container);return r.type="button",r.addEventListener("click",e),r},Li.prototype._setButtonTitle=function(t,e){var n=this._map._getUIString("NavigationControl."+e);t.title=n,t.setAttribute("aria-label",n)};var Pi=function(e,r,i){void 0===i&&(i=!1),this._clickTolerance=10,this.element=r,this.mouseRotate=new Xr({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new Zr({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener(r,"mousedown",this.mousedown),n.addEventListener(r,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(r,"touchmove",this.touchmove),n.addEventListener(r,"touchend",this.touchend),n.addEventListener(r,"touchcancel",this.reset)};function Ri(e,n,r){if(e=new t.LngLat(e.lng,e.lat),n){var i=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),a=r.locationPoint(e).distSqr(n);r.locationPoint(i).distSqr(n)<a?e=i:r.locationPoint(o).distSqr(n)<a&&(e=o)}for(;Math.abs(e.lng-r.center.lng)>180;){var s=r.locationPoint(e);if(s.x>=0&&s.y>=0&&s.x<=r.width&&s.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}Pi.prototype.down=function(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),n.disableDrag()},Pi.prototype.move=function(t,e){var n=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&n.setBearing(n.getBearing()+r.bearingDelta),this.mousePitch){var i=this.mousePitch.mousemoveWindow(t,e);i&&i.pitchDelta&&n.setPitch(n.getPitch()+i.pitchDelta)}},Pi.prototype.off=function(){var t=this.element;n.removeEventListener(t,"mousedown",this.mousedown),n.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(t,"touchmove",this.touchmove),n.removeEventListener(t,"touchend",this.touchend),n.removeEventListener(t,"touchcancel",this.reset),this.offTemp()},Pi.prototype.offTemp=function(){n.enableDrag(),n.removeEventListener(t.window,"mousemove",this.mousemove),n.removeEventListener(t.window,"mouseup",this.mouseup)},Pi.prototype.mousedown=function(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:function(){return e.preventDefault()}}),n.mousePos(this.element,e)),n.addEventListener(t.window,"mousemove",this.mousemove),n.addEventListener(t.window,"mouseup",this.mouseup)},Pi.prototype.mousemove=function(t){this.move(t,n.mousePos(this.element,t))},Pi.prototype.mouseup=function(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()},Pi.prototype.touchstart=function(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:function(){return t.preventDefault()}},this._startPos))},Pi.prototype.touchmove=function(t){1!==t.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:function(){return t.preventDefault()}},this._lastPos))},Pi.prototype.touchend=function(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()},Pi.prototype.reset=function(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()};var Di={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ni(t,e,n){var r=t.classList;for(var i in Di)r.remove("maplibregl-"+n+"-anchor-"+i,"mapboxgl-"+n+"-anchor-"+i);r.add("maplibregl-"+n+"-anchor-"+e,"mapboxgl-"+n+"-anchor-"+e)}var Oi,ki=function(e){function r(r,i){if(e.call(this),(r instanceof t.window.HTMLElement||i)&&(r=t.extend({element:r},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&"auto"!==r.pitchAlignment?r.pitchAlignment:this._rotationAlignment,r&&r.element)this._element=r.element,this._offset=t.Point.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=n.create("div"),this._element.setAttribute("aria-label","Map marker");var o=n.createNS("http://www.w3.org/2000/svg","svg");o.setAttributeNS(null,"display","block"),o.setAttributeNS(null,"height","41px"),o.setAttributeNS(null,"width","27px"),o.setAttributeNS(null,"viewBox","0 0 27 41");var a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");var s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");var l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");for(var u=0,c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];u<c.length;u+=1){var h=c[u],p=n.createNS("http://www.w3.org/2000/svg","ellipse");p.setAttributeNS(null,"opacity","0.04"),p.setAttributeNS(null,"cx","10.5"),p.setAttributeNS(null,"cy","5.80029008"),p.setAttributeNS(null,"rx",h.rx),p.setAttributeNS(null,"ry",h.ry),l.appendChild(p)}var f=n.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill",this._color);var d=n.createNS("http://www.w3.org/2000/svg","path");d.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),f.appendChild(d);var m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"opacity","0.25"),m.setAttributeNS(null,"fill","#000000");var g=n.createNS("http://www.w3.org/2000/svg","path");g.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),m.appendChild(g);var y=n.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(6.0, 7.0)"),y.setAttributeNS(null,"fill","#FFFFFF");var v=n.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"transform","translate(8.0, 8.0)");var _=n.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#000000"),_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962");var x=n.createNS("http://www.w3.org/2000/svg","circle");x.setAttributeNS(null,"fill","#FFFFFF"),x.setAttributeNS(null,"cx","5.5"),x.setAttributeNS(null,"cy","5.5"),x.setAttributeNS(null,"r","5.4999962"),v.appendChild(_),v.appendChild(x),s.appendChild(l),s.appendChild(f),s.appendChild(m),s.appendChild(y),s.appendChild(v),o.appendChild(s),o.setAttributeNS(null,"height",41*this._scale+"px"),o.setAttributeNS(null,"width",27*this._scale+"px"),this._element.appendChild(o),this._offset=t.Point.convert(r&&r.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",(function(t){t.preventDefault()})),this._element.addEventListener("mousedown",(function(t){t.preventDefault()})),Ni(this._element,this._anchor,"marker"),this._popup=null}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.addTo=function(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this},r.prototype.remove=function(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this},r.prototype.getElement=function(){return this._element},r.prototype.setPopup=function(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){var e=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[e,-1*(24.6+e)],"bottom-right":[-e,-1*(24.6+e)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this},r.prototype._onKeyPress=function(t){var e=t.code,n=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==n&&13!==n||this.togglePopup()},r.prototype._onMapClick=function(t){var e=t.originalEvent.target,n=this._element;this._popup&&(e===n||n.contains(e))&&this.togglePopup()},r.prototype.getPopup=function(){return this._popup},r.prototype.togglePopup=function(){var t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this},r.prototype._update=function(t){if(this._map){this._map.transform.renderWorldCopies&&(this._lngLat=Ri(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);var e="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?e="rotateZ("+this._rotation+"deg)":"map"===this._rotationAlignment&&(e="rotateZ("+(this._rotation-this._map.getBearing())+"deg)");var r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r="rotateX("+this._map.getPitch()+"deg)"),t&&"moveend"!==t.type||(this._pos=this._pos.round()),n.setTransform(this._element,Di[this._anchor]+" translate("+this._pos.x+"px, "+this._pos.y+"px) "+r+" "+e)}},r.prototype.getOffset=function(){return this._offset},r.prototype.setOffset=function(e){return this._offset=t.Point.convert(e),this._update(),this},r.prototype._onMove=function(e){if(!this._isDragging){var n=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))},r.prototype._onUp=function(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"},r.prototype._addDragHandler=function(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},r.prototype.setDraggable=function(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this},r.prototype.isDraggable=function(){return this._draggable},r.prototype.setRotation=function(t){return this._rotation=t||0,this._update(),this},r.prototype.getRotation=function(){return this._rotation},r.prototype.setRotationAlignment=function(t){return this._rotationAlignment=t||"auto",this._update(),this},r.prototype.getRotationAlignment=function(){return this._rotationAlignment},r.prototype.setPitchAlignment=function(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this},r.prototype.getPitchAlignment=function(){return this._pitchAlignment},r}(t.Evented),zi={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Fi=0,Bi=!1,Ui=function(e){function r(n){e.call(this),this.options=t.extend({},zi,n),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.onAdd=function(e){var r;return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),r=this._setupUI,void 0!==Oi?r(Oi):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((function(t){r(Oi="denied"!==t.state)})):r(Oi=!!t.window.navigator.geolocation),this._container},r.prototype.onRemove=function(){void 0!==this._geolocationWatchID&&(t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Fi=0,Bi=!1},r.prototype._isOutOfMapMaxBounds=function(t){var e=this._map.getMaxBounds(),n=t.coords;return e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.latitude>e.getNorth())},r.prototype._setErrorState=function(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting")}},r.prototype._onSuccess=function(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}},r.prototype._updateCamera=function(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),o=t.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})},r.prototype._updateMarker=function(e){if(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},r.prototype._updateCircleRadius=function(){var t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),n=this._map.unproject([1,t]),r=e.distanceTo(n),i=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=i+"px",this._circleElement.style.height=i+"px"},r.prototype._onZoom=function(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},r.prototype._onError=function(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;var n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Bi)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}},r.prototype._finish=function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},r.prototype._setupUI=function(e){var r=this;if(this._container.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");var i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{var o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=o,this._geolocateButton.setAttribute("aria-label",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new ki(this._dotElement),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ki({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(function(e){e.geolocateSource||"ACTIVE_LOCK"!==r._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(r._watchState="BACKGROUND",r._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),r._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),r.fire(new t.Event("trackuserlocationend")))}))},r.prototype.trigger=function(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Fi--,Bi=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){var e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++Fi>1?(e={maximumAge:6e5,timeout:0},Bi=!0):(e=this.options.positionOptions,Bi=!1),this._geolocationWatchID=t.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else t.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0},r.prototype._clearWatch=function(){t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)},r}(t.Evented),Vi={maxWidth:100,unit:"metric"},Gi=function(e){this.options=t.extend({},Vi,e),t.bindAll(["_onMove","setUnit"],this)};function ji(t,e,n){var r=n&&n.maxWidth||100,i=t._container.clientHeight/2,o=t.unproject([0,i]),a=t.unproject([r,i]),s=o.distanceTo(a);if(n&&"imperial"===n.unit){var l=3.2808*s;l>5280?Hi(e,r,l/5280,t._getUIString("ScaleControl.Miles")):Hi(e,r,l,t._getUIString("ScaleControl.Feet"))}else n&&"nautical"===n.unit?Hi(e,r,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?Hi(e,r,s/1e3,t._getUIString("ScaleControl.Kilometers")):Hi(e,r,s,t._getUIString("ScaleControl.Meters"))}function Hi(t,e,n,r){var i,o,a,s=(i=n,(o=Math.pow(10,(""+Math.floor(i)).length-1))*(a=(a=i/o)>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(t){var e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(a)));t.style.width=e*(s/n)+"px",t.innerHTML=s+"&nbsp;"+r}Gi.prototype.getDefaultPosition=function(){return"bottom-left"},Gi.prototype._onMove=function(){ji(this._map,this._container,this.options)},Gi.prototype.onAdd=function(t){return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},Gi.prototype.onRemove=function(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},Gi.prototype.setUnit=function(t){this.options.unit=t,ji(this._map,this._container,this.options)};var qi=function(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.window.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.window.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.window.document&&(this._fullscreenchange="MSFullscreenChange")};qi.prototype.onAdd=function(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer},qi.prototype.onRemove=function(){n.remove(this._controlContainer),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)},qi.prototype._checkFullscreenSupport=function(){return!!(t.window.document.fullscreenEnabled||t.window.document.mozFullScreenEnabled||t.window.document.msFullscreenEnabled||t.window.document.webkitFullscreenEnabled)},qi.prototype._setupUI=function(){var e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",e).setAttribute("aria-hidden",!0),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)},qi.prototype._updateTitle=function(){var t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t},qi.prototype._getTitle=function(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")},qi.prototype._isFullscreen=function(){return this._fullscreen},qi.prototype._changeIcon=function(){(t.window.document.fullscreenElement||t.window.document.mozFullScreenElement||t.window.document.webkitFullscreenElement||t.window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())},qi.prototype._onClickFullscreen=function(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.mozCancelFullScreen?t.window.document.mozCancelFullScreen():t.window.document.msExitFullscreen?t.window.document.msExitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()};var Wi={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Xi=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),Zi=function(e){function r(n){e.call(this),this.options=t.extend(Object.create(Wi),n),t.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.addTo=function(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this},r.prototype.isOpen=function(){return!!this._map},r.prototype.remove=function(){return this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new t.Event("close")),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.trackPointer=function(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.getElement=function(){return this._container},r.prototype.setText=function(e){return this.setDOMContent(t.window.document.createTextNode(e))},r.prototype.setHTML=function(e){var n,r=t.window.document.createDocumentFragment(),i=t.window.document.createElement("body");for(i.innerHTML=e;n=i.firstChild;)r.appendChild(n);return this.setDOMContent(r)},r.prototype.getMaxWidth=function(){return this._container&&this._container.style.maxWidth},r.prototype.setMaxWidth=function(t){return this.options.maxWidth=t,this._update(),this},r.prototype.setDOMContent=function(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this},r.prototype.addClassName=function(t){this._container&&this._container.classList.add(t)},r.prototype.removeClassName=function(t){this._container&&this._container.classList.remove(t)},r.prototype.setOffset=function(t){return this.options.offset=t,this._update(),this},r.prototype.toggleClassName=function(t){if(this._container)return this._container.classList.toggle(t)},r.prototype._createCloseButton=function(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))},r.prototype._onMouseUp=function(t){this._update(t.point)},r.prototype._onMouseMove=function(t){this._update(t.point)},r.prototype._onDrag=function(t){this._update(t.point)},r.prototype._update=function(e){var r=this;if(this._map&&(this._lngLat||this._trackPointer)&&this._content&&(this._container||(this._container=n.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((function(t){return r._container.classList.add(t)})),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ri(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||e)){var i=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat),o=this.options.anchor,a=function e(n){if(n){if("number"==typeof n){var r=Math.round(Math.sqrt(.5*Math.pow(n,2)));return{center:new t.Point(0,0),top:new t.Point(0,n),"top-left":new t.Point(r,r),"top-right":new t.Point(-r,r),bottom:new t.Point(0,-n),"bottom-left":new t.Point(r,-r),"bottom-right":new t.Point(-r,-r),left:new t.Point(n,0),right:new t.Point(-n,0)}}if(n instanceof t.Point||Array.isArray(n)){var i=t.Point.convert(n);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.Point.convert(n.center||[0,0]),top:t.Point.convert(n.top||[0,0]),"top-left":t.Point.convert(n["top-left"]||[0,0]),"top-right":t.Point.convert(n["top-right"]||[0,0]),bottom:t.Point.convert(n.bottom||[0,0]),"bottom-left":t.Point.convert(n["bottom-left"]||[0,0]),"bottom-right":t.Point.convert(n["bottom-right"]||[0,0]),left:t.Point.convert(n.left||[0,0]),right:t.Point.convert(n.right||[0,0])}}return e(new t.Point(0,0))}(this.options.offset);if(!o){var s,l=this._container.offsetWidth,u=this._container.offsetHeight;s=i.y+a.bottom.y<u?["top"]:i.y>this._map.transform.height-u?["bottom"]:[],i.x<l/2?s.push("left"):i.x>this._map.transform.width-l/2&&s.push("right"),o=0===s.length?"bottom":s.join("-")}var c=i.add(a[o]).round();n.setTransform(this._container,Di[o]+" translate("+c.x+"px,"+c.y+"px)"),Ni(this._container,o,"popup")}},r.prototype._focusFirstElement=function(){if(this.options.focusAfterOpen&&this._container){var t=this._container.querySelector(Xi);t&&t.focus()}},r.prototype._onClose=function(){this.remove()},r}(t.Evented),Yi={version:t.version,supported:e,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:Ci,NavigationControl:Li,GeolocateControl:Ui,AttributionControl:_i,ScaleControl:Gi,FullscreenControl:qi,Popup:Zi,Marker:ki,Style:je,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,Evented:t.Evented,config:t.config,prewarm:function(){Ft().acquire(Nt)},clearPrewarmedResources:function(){var t=kt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Nt),kt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ot.workerCount},set workerCount(t){Ot.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage:function(e){t.clearTileCache(e)},workerUrl:"",addProtocol:function(e,n){t.config.REGISTERED_PROTOCOLS[e]=n},removeProtocol:function(e){delete t.config.REGISTERED_PROTOCOLS[e]}};return Yi}));return n}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MapboxDraw=e()}(this,(function(){"use strict";var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on:function(t,e,r){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:r})},render:function(t){e.store.featureChanged(t)}},i=function(t,i){for(var o=n[t],a=o.length;a--;){var s=o[a];if(s.selector(i)){s.fn.call(r,i)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(r),{render:t.render,stop:function(){t.stop&&t.stop()},trash:function(){t.trash&&(t.trash(),e.store.render())},combineFeatures:function(){t.combineFeatures&&t.combineFeatures()},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures()},drag:function(t){i("drag",t)},click:function(t){i("click",t)},mousemove:function(t){i("mousemove",t)},mousedown:function(t){i("mousedown",t)},mouseup:function(t){i("mouseup",t)},mouseout:function(t){i("mouseout",t)},keydown:function(t){i("keydown",t)},keyup:function(t){i("keyup",t)},touchstart:function(t){i("touchstart",t)},touchmove:function(t){i("touchmove",t)},touchend:function(t){i("touchend",t)},tap:function(t){i("tap",t)}}},e=6378137;function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(r(t[0]));for(var n=1;n<t.length;n++)e-=Math.abs(r(t[n]))}return e}function r(t){var n,r,o,a,s,l,u=0,c=t.length;if(c>2){for(l=0;l<c;l++)l===c-2?(o=c-2,a=c-1,s=0):l===c-1?(o=c-1,a=0,s=1):(o=l,a=l+1,s=l+2),n=t[o],r=t[a],u+=(i(t[s][0])-i(n[0]))*Math.sin(i(r[1]));u=u*e*e/2}return u}function i(t){return t*Math.PI/180}var o=function t(e){var r,i=0;switch(e.type){case"Polygon":return n(e.coordinates);case"MultiPolygon":for(r=0;r<e.coordinates.length;r++)i+=n(e.coordinates[r]);return i;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<e.geometries.length;r++)i+=t(e.geometries[r]);return i}},a="active",s="mapbox-gl-draw-hot",l="mapbox-gl-draw-cold",u="add",c="move",h="pointer",p="none",f={POLYGON:"polygon",LINE:"line_string",POINT:"point"},d="Feature",m="Polygon",g="LineString",y="Point",v="FeatureCollection",_="Multi",x={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"},b="draw.create",w="draw.delete",E="draw.update",S="draw.selectionchange",M="draw.render",T="feature",C="midpoint",I="vertex",A="true",L="false",P=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],R={Point:0,LineString:1,Polygon:2};function D(t,e){var n=R[t.geometry.type]-R[e.geometry.type];return 0===n&&t.geometry.type===m?t.area-e.area:n}function N(t){if(this._items={},this._nums={},this._length=t?t.length:0,t)for(var e=0,n=t.length;e<n;e++)this.add(t[e]),void 0!==t[e]&&("string"==typeof t[e]?this._items[t[e]]=e:this._nums[t[e]]=e)}N.prototype.add=function(t){return this.has(t)||(this._length++,"string"==typeof t?this._items[t]=this._length:this._nums[t]=this._length),this},N.prototype.delete=function(t){return!1===this.has(t)||(this._length--,delete this._items[t],delete this._nums[t]),this},N.prototype.has=function(t){return!("string"!=typeof t&&"number"!=typeof t||void 0===this._items[t]&&void 0===this._nums[t])},N.prototype.values=function(){var t=this,e=[];return Object.keys(this._items).forEach((function(n){e.push({k:n,v:t._items[n]})})),Object.keys(this._nums).forEach((function(n){e.push({k:JSON.parse(n),v:t._nums[n]})})),e.sort((function(t,e){return t.v-e.v})).map((function(t){return t.k}))},N.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};var O=[T,C,I],k={click:function(t,e,n){return z(t,e,n,n.options.clickBuffer)},touch:function(t,e,n){return z(t,e,n,n.options.touchBuffer)}};function z(t,e,n,r){if(null===n.map)return[];var i=t?function(t,e){return void 0===e&&(e=0),[[t.point.x-e,t.point.y-e],[t.point.x+e,t.point.y+e]]}(t,r):e,a={};n.options.styles&&(a.layers=n.options.styles.map((function(t){return t.id})));var s=n.map.queryRenderedFeatures(i,a).filter((function(t){return-1!==O.indexOf(t.properties.meta)})),l=new N,u=[];return s.forEach((function(t){var e=t.properties.id;l.has(e)||(l.add(e),u.push(t))})),function(t){return t.map((function(t){return t.geometry.type===m&&(t.area=o({type:d,property:{},geometry:t.geometry})),t})).sort(D).map((function(t){return delete t.area,t}))}(u)}function F(t,e){var n=k.click(t,null,e),r={mouse:p};return n[0]&&(r.mouse=n[0].properties.active===A?c:h,r.feature=n[0].properties.meta),-1!==e.events.currentModeName().indexOf("draw")&&(r.mouse=u),e.ui.queueMapClasses(r),e.ui.updateMapClasses(),n[0]}function B(t,e){var n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function U(t,e,n){void 0===n&&(n={});var r=null!=n.fineTolerance?n.fineTolerance:4,i=null!=n.grossTolerance?n.grossTolerance:12,o=null!=n.interval?n.interval:500;t.point=t.point||e.point,t.time=t.time||e.time;var a=B(t.point,e.point);return a<r||a<i&&e.time-t.time<o}function V(t,e,n){void 0===n&&(n={});var r=null!=n.tolerance?n.tolerance:25,i=null!=n.interval?n.interval:250;return t.point=t.point||e.point,t.time=t.time||e.time,B(t.point,e.point)<r&&e.time-t.time<i}function G(t,e){return t(e={exports:{}},e.exports),e.exports}var j=G((function(t){var e=t.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return"0";for(var r=Math.log(Math.pow(2,t))/Math.log(n),i=2;r===1/0;i*=2)r=Math.log(Math.pow(2,t/i))/Math.log(n)*i;var o=r-Math.floor(r),a="";for(i=0;i<Math.floor(r);i++)a=Math.floor(Math.random()*n).toString(n)+a;if(o){var s=Math.pow(n,o);a=Math.floor(Math.random()*s).toString(n)+a}var l=parseInt(a,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):a};e.rack=function(t,n,r){var i=function(i){var a=0;do{if(a++>10){if(!r)throw new Error("too many ID collisions, use more bits");t+=r}var s=e(t,n)}while(Object.hasOwnProperty.call(o,s));return o[s]=i,s},o=i.hats={};return i.get=function(t){return i.hats[t]},i.set=function(t,e){return i.hats[t]=e,i},i.bits=t||128,i.base=n||16,i}})),H=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||j(),this.type=e.geometry.type};H.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},H.prototype.incomingCoords=function(t){this.setCoordinates(t)},H.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},H.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},H.prototype.setProperty=function(t,e){this.properties[t]=e},H.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:d,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},H.prototype.internal=function(t){var e={id:this.id,meta:T,"meta:type":this.type,active:L,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return{type:d,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var q=function(t,e){H.call(this,t,e)};(q.prototype=Object.create(H.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},q.prototype.updateCoordinate=function(t,e,n){this.coordinates=3===arguments.length?[e,n]:[t,e],this.changed()},q.prototype.getCoordinate=function(){return this.getCoordinates()};var W=function(t,e){H.call(this,t,e)};(W.prototype=Object.create(H.prototype)).isValid=function(){return this.coordinates.length>1},W.prototype.addCoordinate=function(t,e,n){this.changed();var r=parseInt(t,10);this.coordinates.splice(r,0,[e,n])},W.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},W.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1)},W.prototype.updateCoordinate=function(t,e,n){var r=parseInt(t,10);this.coordinates[r]=[e,n],this.changed()};var X=function(t,e){H.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}))};(X.prototype=Object.create(H.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},X.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed()},X.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},X.prototype.addCoordinate=function(t,e,n){this.changed();var r=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[r[0]].splice(r[1],0,[e,n])},X.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1))},X.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},X.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},X.prototype.updateCoordinate=function(t,e,n){this.changed();var r=t.split("."),i=parseInt(r[0],10),o=parseInt(r[1],10);void 0===this.coordinates[i]&&(this.coordinates[i]=[]),this.coordinates[i][o]=[e,n]};var Z={MultiPoint:q,MultiLineString:W,MultiPolygon:X},Y=function(t,e,n,r,i){var o=n.split("."),a=parseInt(o[0],10),s=o[1]?o.slice(1).join("."):null;return t[a][e](s,r,i)},J=function(t,e){if(H.call(this,t,e),delete this.coordinates,this.model=Z[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates)};function K(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t}(J.prototype=Object.create(H.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:j(),type:d,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},J.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},J.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed()},J.prototype.getCoordinate=function(t){return Y(this.features,"getCoordinate",t)},J.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===m?t.getCoordinates():t.coordinates}))))},J.prototype.updateCoordinate=function(t,e,n){Y(this.features,"updateCoordinate",t,e,n),this.changed()},J.prototype.addCoordinate=function(t,e,n){Y(this.features,"addCoordinate",t,e,n),this.changed()},J.prototype.removeCoordinate=function(t){Y(this.features,"removeCoordinate",t),this.changed()},J.prototype.getFeatures=function(){return this.features},K.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},K.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{})},K.prototype.getSelected=function(){return this._ctx.store.getSelected()},K.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},K.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},K.prototype.getFeature=function(t){return this._ctx.store.get(t)},K.prototype.select=function(t){return this._ctx.store.select(t)},K.prototype.deselect=function(t){return this._ctx.store.deselect(t)},K.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},K.prototype.addFeature=function(t){return this._ctx.store.add(t)},K.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},K.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},K.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},K.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},K.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},K.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},K.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return k[n](t,e,this._ctx)},K.prototype.newFeature=function(t){var e=t.geometry.type;return e===y?new q(this._ctx,t):e===g?new W(this._ctx,t):e===m?new X(this._ctx,t):new J(this._ctx,t)},K.prototype.isInstanceOf=function(t,e){if(t===y)return e instanceof q;if(t===g)return e instanceof W;if(t===m)return e instanceof X;if("MultiFeature"===t)return e instanceof J;throw new Error("Unknown feature class: "+t)},K.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},K.prototype.onSetup=function(){},K.prototype.onDrag=function(){},K.prototype.onClick=function(){},K.prototype.onMouseMove=function(){},K.prototype.onMouseDown=function(){},K.prototype.onMouseUp=function(){},K.prototype.onMouseOut=function(){},K.prototype.onKeyUp=function(){},K.prototype.onKeyDown=function(){},K.prototype.onTouchStart=function(){},K.prototype.onTouchMove=function(){},K.prototype.onTouchEnd=function(){},K.prototype.onTap=function(){},K.prototype.onStop=function(){},K.prototype.onTrash=function(){},K.prototype.onCombineFeature=function(){},K.prototype.onUncombineFeature=function(){},K.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Q={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},$=Object.keys(Q);function tt(t){return[].concat(t).filter((function(t){return void 0!==t}))}function et(){var t=this;if(!t.ctx.map||void 0===t.ctx.map.getSource(s))return c();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],r=[];t.isDirty?r=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),r=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var i=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return-1===n.indexOf(e)}));var o=i!==t.sources.cold.length||r.length>0;function a(n,r){var i=t.get(n).internal(e);t.ctx.events.currentModeRender(i,(function(e){t.sources[r].push(e)}))}if(n.forEach((function(t){return a(t,"hot")})),r.forEach((function(t){return a(t,"cold")})),o&&t.ctx.map.getSource(l).setData({type:v,features:t.sources.cold}),t.ctx.map.getSource(s).setData({type:v,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(S,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return{type:d,properties:{},geometry:{type:y,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var u=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(w,{features:u})}function c(){t.isDirty=!1,t.clearChangedIds()}c(),t.ctx.map.fire(M,{})}function nt(t){var e,n=this;this._features={},this._featureIds=new N,this._selectedFeatureIds=new N,this._selectedCoordinates=[],this._changedFeatureIds=new N,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,et.call(n)})))},this.isDirty=!1}function rt(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n}nt.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++},function(){t.render=e,n>0&&t.render()}},nt.prototype.setDirty=function(){return this.isDirty=!0,this},nt.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},nt.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},nt.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},nt.prototype.getAllIds=function(){return this._featureIds.values()},nt.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},nt.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0)})),rt(this,e),this},nt.prototype.get=function(t){return this._features[t]},nt.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},nt.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),this},nt.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),rt(this,e),this},nt.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},nt.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=tt(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return-1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return!n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},nt.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},nt.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},nt.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},nt.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},nt.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return{coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},nt.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},nt.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t)},nt.prototype.storeMapConfig=function(){var t=this;P.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled())}))},nt.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable()}))},nt.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var it=function(){for(var t=arguments,e={},n=0;n<arguments.length;n++){var r=t[n];for(var i in r)ot.call(r,i)&&(e[i]=r[i])}return e},ot=Object.prototype.hasOwnProperty,at=["mode","feature","mouse"];function st(e){var n=null,r=null,i={onRemove:function(){return e.map.off("load",i.connect),clearInterval(r),i.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.map=null,e.container=null,e.store=null,n&&n.parentNode&&n.parentNode.removeChild(n),n=null,this},connect:function(){e.map.off("load",i.connect),clearInterval(r),i.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd:function(o){var s=o.fire;return o.fire=function(t,e){var n=arguments;return 1===s.length&&1!==arguments.length&&(n=[it({},{type:t},e)]),s.apply(o,n)},e.map=o,e.events=function(e){var n=Object.keys(e.options.modes).reduce((function(t,n){return t[n]=function(t){var e=Object.keys(t);return function(n,r){void 0===r&&(r={});var i={},o=e.reduce((function(e,n){return e[n]=t[n],e}),new K(n));return{start:function(){var e=this;i=o.onSetup(r),$.forEach((function(n){var r,a=Q[n],s=function(){return!1};t[a]&&(s=function(){return!0}),e.on(n,s,(r=a,function(t){return o[r](i,t)}))}))},stop:function(){o.onStop(i)},trash:function(){o.onTrash(i)},combineFeatures:function(){o.onCombineFeatures(i)},uncombineFeatures:function(){o.onUncombineFeatures(i)},render:function(t,e){o.toDisplayFeatures(i,t,e)}}}}(e.options.modes[n]),t}),{}),r={},i={},o={},a=null,s=null;o.drag=function(t,n){n({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:"drag"}),s.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(t){o.drag(t,(function(t){return!U(r,t)}))},o.touchdrag=function(t){o.drag(t,(function(t){return!V(i,t)}))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);var n=F(t,e);t.featureTarget=n,s.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};var n=F(t,e);t.featureTarget=n,s.mousedown(t)},o.mouseup=function(t){var n=F(t,e);t.featureTarget=n,U(r,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t)},o.mouseout=function(t){s.mouseout(t)},o.touchstart=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){i={time:(new Date).getTime(),point:t.point};var n=k.touch(t,null,e)[0];t.featureTarget=n,s.touchstart(t)}},o.touchmove=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled)return s.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){var n=k.touch(t,null,e)[0];t.featureTarget=n,V(i,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t)}};var l=function(t){return!(8===t||46===t||t>=48&&t<=57)};function u(r,i,o){void 0===o&&(o={}),s.stop();var l=n[r];if(void 0===l)throw new Error(r+" is not valid");a=r;var u=l(e,i);s=t(u,e),o.silent||e.map.fire("draw.modechange",{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){"mapboxgl-canvas"===(t.srcElement||t.target).classList[0]&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?l(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?u(x.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?u(x.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&u(x.DRAW_POLYGON):(t.preventDefault(),s.trash()))},o.keyup=function(t){l(t.keyCode)&&s.keyup(t)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){var n=e.setup,r=e.map,i=e.options,o=e.store;i.styles.some((function(t){return r.getLayer(t.id)}))||(n.addLayers(),o.setDirty(),o.render())}};var c={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){a=e.options.defaultMode,s=t(n[a](e),e)},changeMode:u,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(n=!0),c[e]=t[e]})),n&&e.map.fire("draw.actionable",{actions:c})},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){o[t]&&o[t](e)},addEventListeners:function(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners:function(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash:function(t){s.trash(t)},combineFeatures:function(){s.combineFeatures()},uncombineFeatures:function(){s.uncombineFeatures()},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,r={mode:null,feature:null,mouse:null},i={mode:null,feature:null,mouse:null};function o(t){i=it(i,t)}function s(){var e,n;if(t.container){var o=[],a=[];at.forEach((function(t){i[t]!==r[t]&&(o.push(t+"-"+r[t]),null!==i[t]&&a.push(t+"-"+i[t]))})),o.length>0&&(e=t.container.classList).remove.apply(e,o),a.length>0&&(n=t.container.classList).add.apply(n,a),r=it(r,i)}}function l(t,e){void 0===e&&(e={});var r=document.createElement("button");return r.className="mapbox-gl-draw_ctrl-draw-btn "+e.className,r.setAttribute("title",e.title),e.container.appendChild(r),r.addEventListener("click",(function(r){if(r.preventDefault(),r.stopPropagation(),r.target===n)return u(),void e.onDeactivate();c(t),e.onActivate()}),!0),r}function u(){n&&(n.classList.remove(a),n=null)}function c(t){u();var r=e[t];r&&r&&"trash"!==t&&(r.classList.add(a),n=r)}return{setActiveButton:c,queueMapClasses:o,updateMapClasses:s,clearMapClasses:function(){o({mode:null,feature:null,mouse:null}),s()},addButtons:function(){var n=t.options.controls,r=document.createElement("div");return r.className="mapboxgl-ctrl-group mapboxgl-ctrl",n?(n[f.LINE]&&(e[f.LINE]=l(f.LINE,{container:r,className:"mapbox-gl-draw_line",title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(x.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[f.POLYGON]&&(e[f.POLYGON]=l(f.POLYGON,{container:r,className:"mapbox-gl-draw_polygon",title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(x.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[f.POINT]&&(e[f.POINT]=l(f.POINT,{container:r,className:"mapbox-gl-draw_point",title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(x.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=l("trash",{container:r,className:"mapbox-gl-draw_trash",title:"Delete",onActivate:function(){t.events.trash()}})),n.combine_features&&(e.combine_features=l("combineFeatures",{container:r,className:"mapbox-gl-draw_combine",title:"Combine",onActivate:function(){t.events.combineFeatures()}})),n.uncombine_features&&(e.uncombine_features=l("uncombineFeatures",{container:r,className:"mapbox-gl-draw_uncombine",title:"Uncombine",onActivate:function(){t.events.uncombineFeatures()}})),r):r},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t]}))}}}(e),e.container=o.getContainer(),e.store=new nt(e),n=e.ui.addButtons(),e.options.boxSelect&&(o.boxZoom.disable(),o.dragPan.disable(),o.dragPan.enable()),o.loaded()?i.connect():(o.on("load",i.connect),r=setInterval((function(){o.loaded()&&i.connect()}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(l,{data:{type:v,features:[]},type:"geojson"}),e.map.addSource(s,{data:{type:v,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t)})),e.store.setDirty(!0),e.store.render()},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id)})),e.map.getSource(l)&&e.map.removeSource(l),e.map.getSource(s)&&e.map.removeSource(s)}};return e.setup=i,i}function lt(t){return function(e){var n=e.featureTarget;return!!n&&!!n.properties&&n.properties.meta===t}}function ut(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===A&&t.featureTarget.properties.meta===T}function ct(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===L&&t.featureTarget.properties.meta===T}function ht(t){return void 0===t.featureTarget}function pt(t){var e=t.featureTarget;return!!e&&!!e.properties&&e.properties.meta===I}function ft(t){return!!t.originalEvent&&!0===t.originalEvent.shiftKey}function dt(t){return 27===t.keyCode}function mt(t){return 13===t.keyCode}var gt=yt;function yt(t,e){this.x=t,this.y=e}function vt(t,e){var n=e.getBoundingClientRect();return new gt(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function _t(t,e,n,r){return{type:d,properties:{meta:I,parent:t,coord_path:n,active:r?A:L},geometry:{type:y,coordinates:e}}}function xt(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var r,i=t.geometry,o=i.type,a=i.coordinates,s=t.properties&&t.properties.id,l=[];function u(t,n){var r="",i=null;t.forEach((function(t,o){var a=null!=n?n+"."+o:String(o),u=_t(s,t,a,c(a));if(e.midpoints&&i){var h=function(t,e,n){var r=e.geometry.coordinates,i=n.geometry.coordinates;if(r[1]>85||r[1]<-85||i[1]>85||i[1]<-85)return null;var o={lng:(r[0]+i[0])/2,lat:(r[1]+i[1])/2};return{type:d,properties:{meta:C,parent:t,lng:o.lng,lat:o.lat,coord_path:n.properties.coord_path},geometry:{type:y,coordinates:[o.lng,o.lat]}}}(s,i,u);h&&l.push(h)}i=u;var p=JSON.stringify(t);r!==p&&l.push(u),0===o&&(r=p)}))}function c(t){return!!e.selectedPaths&&-1!==e.selectedPaths.indexOf(t)}return o===y?l.push(_t(s,a,n,c(n))):o===m?a.forEach((function(t,e){u(t,null!==n?n+"."+e:String(e))})):o===g?u(a,n):0===o.indexOf(_)&&(r=o.replace(_,""),a.forEach((function(n,i){var o={type:d,properties:t.properties,geometry:{type:r,coordinates:n}};l=l.concat(xt(o,e,i))}))),l}yt.prototype={clone:function(){return new yt(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),o=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=i,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},yt.convert=function(t){return t instanceof yt?t:Array.isArray(t)?new yt(t[0],t[1]):t};var bt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},wt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)},Et=function(t){if(!t||!t.type)return null;var e=St[t.type];return e?"geometry"===e?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===e?{type:"FeatureCollection",features:[t]}:"featurecollection"===e?t:void 0:null},St={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};function Mt(t){switch(t&&t.type||null){case"FeatureCollection":return t.features=t.features.reduce((function(t,e){return t.concat(Mt(e))}),[]),t;case"Feature":return t.geometry?Mt(t.geometry).map((function(e){var n={type:"Feature",properties:JSON.parse(JSON.stringify(t.properties)),geometry:e};return void 0!==t.id&&(n.id=t.id),n})):[t];case"MultiPoint":return t.coordinates.map((function(t){return{type:"Point",coordinates:t}}));case"MultiPolygon":return t.coordinates.map((function(t){return{type:"Polygon",coordinates:t}}));case"MultiLineString":return t.coordinates.map((function(t){return{type:"LineString",coordinates:t}}));case"GeometryCollection":return t.geometries.map(Mt).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return[t]}}var Tt=G((function(t){var e=t.exports=function(t){return new n(t)};function n(t){this.value=t}function r(t,e,n){var r=[],a=[],c=!0;return function t(h){var p=n?i(h):h,f={},d=!0,m={node:p,node_:h,path:[].concat(r),parent:a[a.length-1],parents:a,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(t,e){m.isRoot||(m.parent.node[m.key]=t),m.node=t,e&&(d=!1)},delete:function(t){delete m.parent.node[m.key],t&&(d=!1)},remove:function(t){s(m.parent.node)?m.parent.node.splice(m.key,1):delete m.parent.node[m.key],t&&(d=!1)},keys:null,before:function(t){f.before=t},after:function(t){f.after=t},pre:function(t){f.pre=t},post:function(t){f.post=t},stop:function(){c=!1},block:function(){d=!1}};if(!c)return m;function g(){if("object"==typeof m.node&&null!==m.node){m.keys&&m.node_===m.node||(m.keys=o(m.node)),m.isLeaf=0==m.keys.length;for(var t=0;t<a.length;t++)if(a[t].node_===h){m.circular=a[t];break}}else m.isLeaf=!0,m.keys=null;m.notLeaf=!m.isLeaf,m.notRoot=!m.isRoot}g();var y=e.call(m,m.node);return void 0!==y&&m.update&&m.update(y),f.before&&f.before.call(m,m.node),d?("object"!=typeof m.node||null===m.node||m.circular||(a.push(m),g(),l(m.keys,(function(e,i){r.push(e),f.pre&&f.pre.call(m,m.node[e],e);var o=t(m.node[e]);n&&u.call(m.node,e)&&(m.node[e]=o.node),o.isLast=i==m.keys.length-1,o.isFirst=0==i,f.post&&f.post.call(m,o),r.pop()})),a.pop()),f.after&&f.after.call(m,m.node),m):m}(t).node}function i(t){if("object"==typeof t&&null!==t){var e;if(s(t))e=[];else if("[object Date]"===a(t))e=new Date(t.getTime?t.getTime():t);else if(function(t){return"[object RegExp]"===a(t)}(t))e=new RegExp(t);else if(function(t){return"[object Error]"===a(t)}(t))e={message:t.message};else if(function(t){return"[object Boolean]"===a(t)}(t))e=new Boolean(t);else if(function(t){return"[object Number]"===a(t)}(t))e=new Number(t);else if(function(t){return"[object String]"===a(t)}(t))e=new String(t);else if(Object.create&&Object.getPrototypeOf)e=Object.create(Object.getPrototypeOf(t));else if(t.constructor===Object)e={};else{var n=t.constructor&&t.constructor.prototype||t.__proto__||{},r=function(){};r.prototype=n,e=new r}return l(o(t),(function(n){e[n]=t[n]})),e}return t}n.prototype.get=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!u.call(e,r)){e=void 0;break}e=e[r]}return e},n.prototype.has=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!u.call(e,r))return!1;e=e[r]}return!0},n.prototype.set=function(t,e){for(var n=this.value,r=0;r<t.length-1;r++){var i=t[r];u.call(n,i)||(n[i]={}),n=n[i]}return n[t[r]]=e,e},n.prototype.map=function(t){return r(this.value,t,!0)},n.prototype.forEach=function(t){return this.value=r(this.value,t,!1),this.value},n.prototype.reduce=function(t,e){var n=1===arguments.length,r=n?this.value:e;return this.forEach((function(e){this.isRoot&&n||(r=t.call(this,r,e))})),r},n.prototype.paths=function(){var t=[];return this.forEach((function(e){t.push(this.path)})),t},n.prototype.nodes=function(){var t=[];return this.forEach((function(e){t.push(this.node)})),t},n.prototype.clone=function(){var t=[],e=[];return function n(r){for(var a=0;a<t.length;a++)if(t[a]===r)return e[a];if("object"==typeof r&&null!==r){var s=i(r);return t.push(r),e.push(s),l(o(r),(function(t){s[t]=n(r[t])})),t.pop(),e.pop(),s}return r}(this.value)};var o=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function a(t){return Object.prototype.toString.call(t)}var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},l=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t)};l(o(n.prototype),(function(t){e[t]=function(e){var r=[].slice.call(arguments,1),i=new n(e);return i[t].apply(i,r)}}));var u=Object.hasOwnProperty||function(t,e){return e in t}})),Ct=It;function It(t){if(!(this instanceof It))return new It(t);this._bbox=t||[1/0,1/0,-1/0,-1/0],this._valid=!!t}It.prototype.include=function(t){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],t[0]),this._bbox[1]=Math.min(this._bbox[1],t[1]),this._bbox[2]=Math.max(this._bbox[2],t[0]),this._bbox[3]=Math.max(this._bbox[3],t[1]),this},It.prototype.equals=function(t){var e;return e=t instanceof It?t.bbox():t,this._bbox[0]==e[0]&&this._bbox[1]==e[1]&&this._bbox[2]==e[2]&&this._bbox[3]==e[3]},It.prototype.center=function(t){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},It.prototype.union=function(t){var e;return this._valid=!0,e=t instanceof It?t.bbox():t,this._bbox[0]=Math.min(this._bbox[0],e[0]),this._bbox[1]=Math.min(this._bbox[1],e[1]),this._bbox[2]=Math.max(this._bbox[2],e[2]),this._bbox[3]=Math.max(this._bbox[3],e[3]),this},It.prototype.bbox=function(){return this._valid?this._bbox:null},It.prototype.contains=function(t){if(!t)return this._fastContains();if(!this._valid)return null;var e=t[0],n=t[1];return this._bbox[0]<=e&&this._bbox[1]<=n&&this._bbox[2]>=e&&this._bbox[3]>=n},It.prototype.intersect=function(t){return this._valid?(e=t instanceof It?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]<e[0]||this._bbox[3]<e[1]||this._bbox[1]>e[3])):null;var e},It.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},It.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var At={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Lt=Object.keys(At),Pt=function(t){return Rt(t).bbox()};function Rt(t){for(var e=Ct(),n=function(t){if(!t)return[];var e=Mt(Et(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(function t(e){return Array.isArray(e)&&e.length&&"number"==typeof e[0]?[e]:e.reduce((function(e,n){return Array.isArray(n)&&Array.isArray(n[0])?e.concat(t(n)):(e.push(n),e)}),[])}(t.geometry.coordinates)))})),n}(t),r=0;r<n.length;r++)e.include(n[r]);return e}Pt.polygon=function(t){return Rt(t).polygon()},Pt.bboxify=function(t){return Tt(t).map((function(t){t&&Lt.some((function(e){return!!t[e]&&-1!==At[e].indexOf(t.type)}))&&(t.bbox=Rt(t).bbox(),this.update(t))}))};function Dt(t,e){var n=-90,r=90,i=-90,o=90,a=270,s=-270;t.forEach((function(t){var e=Pt(t),l=e[1],u=e[3],c=e[0],h=e[2];l>n&&(n=l),u<r&&(r=u),u>i&&(i=u),l<o&&(o=l),c<a&&(a=c),h>s&&(s=h)}));var l=e;return n+l.lat>85&&(l.lat=85-n),i+l.lat>90&&(l.lat=90-i),r+l.lat<-85&&(l.lat=-85-r),o+l.lat<-90&&(l.lat=-90-o),a+l.lng<=-270&&(l.lng+=360*Math.ceil(Math.abs(l.lng)/360)),s+l.lng>=270&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function Nt(t,e){var n=Dt(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,r=t.getCoordinates(),i=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return[e.lng,e.lat]},o=function(t){return t.map((function(t){return i(t)}))};t.type===y?e=i(r):t.type===g||"MultiPoint"===t.type?e=r.map(i):t.type===m||"MultiLineString"===t.type?e=r.map(o):"MultiPolygon"===t.type&&(e=r.map((function(t){return t.map((function(t){return o(t)}))}))),t.incomingCoords(e)}))}var Ot={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(E,{action:"move",features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),r=!1;if(e.length>1){r=!0;var i=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==i&&(r=!1)}))}var o=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:o,trash:a})},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new N).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1},onStop:function(){bt(this)},onMouseMove:function(t){return this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};Ot.onTap=Ot.onClick=function(t,e){return ht(e)?this.clickAnywhere(t,e):lt(I)(e)?this.clickOnVertex(t,e):function(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.meta===T}(e)?this.clickOnFeature(t,e):void 0},Ot.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),bt(this),this.stopExtendedInteractions(t)},Ot.clickOnVertex=function(t,e){this.changeMode(x.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:c})},Ot.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},Ot.clickOnFeature=function(t,e){var n=this;wt(this),this.stopExtendedInteractions(t);var r=ft(e),i=this.getSelectedIds(),o=e.featureTarget.properties.id,a=this.isSelected(o);if(!r&&a&&this.getFeature(o).type!==y)return this.changeMode(x.DIRECT_SELECT,{featureId:o});a&&r?(this.deselect(o),this.updateUIClasses({mouse:h}),1===i.length&&bt(this)):!a&&r?(this.select(o),this.updateUIClasses({mouse:c})):a||r||(i.forEach((function(t){return n.doRender(t)})),this.setSelected(o),this.updateUIClasses({mouse:c})),this.doRender(o)},Ot.onMouseDown=function(t,e){return ut(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&function(t){return!!t.originalEvent&&!!t.originalEvent.shiftKey&&0===t.originalEvent.button}(e)?this.startBoxSelect(t,e):void 0},Ot.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=vt(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0},Ot.onTouchStart=function(t,e){if(ut(e))return this.startOnActiveFeature(t,e)},Ot.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},Ot.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:u}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add("mapbox-gl-draw_boxselect"),this.map.getContainer().appendChild(t.boxSelectElement));var n=vt(e.originalEvent,this.map.getContainer()),r=Math.min(t.boxSelectStartLocation.x,n.x),i=Math.max(t.boxSelectStartLocation.x,n.x),o=Math.min(t.boxSelectStartLocation.y,n.y),a=Math.max(t.boxSelectStartLocation.y,n.y),s="translate("+r+"px, "+o+"px)";t.boxSelectElement.style.transform=s,t.boxSelectElement.style.WebkitTransform=s,t.boxSelectElement.style.width=i-r+"px",t.boxSelectElement.style.height=a-o+"px"},Ot.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};Nt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},Ot.onTouchEnd=Ot.onMouseUp=function(t,e){var n=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var r=[t.boxSelectStartLocation,vt(e.originalEvent,this.map.getContainer())],i=this.featuresAt(null,r,"click"),o=this.getUniqueIds(i).filter((function(t){return!n.isSelected(t)}));o.length&&(this.select(o),o.forEach((function(t){return n.doRender(t)})),this.updateUIClasses({mouse:c}))}this.stopExtendedInteractions(t)},Ot.toDisplayFeatures=function(t,e,n){e.properties.active=this.isSelected(e.properties.id)?A:L,n(e),this.fireActionable(),e.properties.active===A&&e.geometry.type!==y&&xt(e).forEach(n)},Ot.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Ot.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],n=[],r=t[0].type.replace("Multi",""),i=0;i<t.length;i++){var o=t[i];if(o.type.replace("Multi","")!==r)return;o.type.includes("Multi")?o.getCoordinates().forEach((function(t){e.push(t)})):e.push(o.getCoordinates()),n.push(o.toGeoJSON())}if(n.length>1){var a=this.newFeature({type:d,properties:n[0].properties,geometry:{type:"Multi"+r,coordinates:e}});this.addFeature(a),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([a.id]),this.map.fire("draw.combine",{createdFeatures:[a.toGeoJSON()],deletedFeatures:n})}this.fireActionable()}},Ot.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var n=[],r=[],i=function(i){var o=e[i];t.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach((function(e){t.addFeature(e),e.properties=o.properties,n.push(e.toGeoJSON()),t.select([e.id])})),t.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))},o=0;o<e.length;o++)i(o);n.length>1&&this.map.fire("draw.uncombine",{createdFeatures:n,deletedFeatures:r}),this.fireActionable()}};var kt=lt(I),zt=lt(C),Ft={fireUpdate:function(){this.map.fire(E,{action:"change_coordinates",features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(t){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:t.selectedCoordPaths.length>0})},startDragging:function(t,e){this.map.dragPan.disable(),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},stopDragging:function(t){this.map.dragPan.enable(),t.dragMoving=!1,t.canDragMove=!1,t.dragMoveLocation=null},onVertex:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties,r=t.selectedCoordPaths.indexOf(n.coord_path);ft(e)||-1!==r?ft(e)&&-1===r&&t.selectedCoordPaths.push(n.coord_path):t.selectedCoordPaths=[n.coord_path];var i=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(i)},onMidpoint:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties;t.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),t.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(t,e){return e.map((function(e){return{feature_id:t,coord_path:e}}))},onFeature:function(t,e){0===t.selectedCoordPaths.length?this.startDragging(t,e):this.stopDragging(t)},dragFeature:function(t,e,n){Nt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},dragVertex:function(t,e,n){for(var r=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),i=Dt(r.map((function(t){return{type:d,properties:{},geometry:{type:y,coordinates:t}}})),n),o=0;o<r.length;o++){var a=r[o];t.feature.updateCoordinate(t.selectedCoordPaths[o],a[0]+i.lng,a[1]+i.lat)}},clickNoTarget:function(){this.changeMode(x.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(x.SIMPLE_SELECT)},clickActiveFeature:function(t){t.selectedCoordPaths=[],this.clearSelectedCoordinates(),t.feature.changed()},onSetup:function(t){var e=t.featureId,n=this.getFeature(e);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===y)throw new TypeError("direct_select mode doesn't handle point features");var r={featureId:e,feature:n,dragMoveLocation:t.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:t.coordPath?[t.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(e,r.selectedCoordPaths)),this.setSelected(e),wt(this),this.setActionableState({trash:!0}),r},onStop:function(){bt(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(t,e,n){t.featureId===e.properties.id?(e.properties.active=A,n(e),xt(e,{map:this.map,midpoints:!0,selectedPaths:t.selectedCoordPaths}).forEach(n)):(e.properties.active=L,n(e)),this.fireActionable(t)},onTrash:function(t){t.selectedCoordPaths.sort((function(t,e){return e.localeCompare(t,"en",{numeric:!0})})).forEach((function(e){return t.feature.removeCoordinate(e)})),this.fireUpdate(),t.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(t),!1===t.feature.isValid()&&(this.deleteFeature([t.featureId]),this.changeMode(x.SIMPLE_SELECT,{}))},onMouseMove:function(t,e){var n=ut(e),r=kt(e),i=0===t.selectedCoordPaths.length;return n&&i||r&&!i?this.updateUIClasses({mouse:c}):this.updateUIClasses({mouse:p}),this.stopDragging(t),!0},onMouseOut:function(t){return t.dragMoving&&this.fireUpdate(),!0}};Ft.onTouchStart=Ft.onMouseDown=function(t,e){return kt(e)?this.onVertex(t,e):ut(e)?this.onFeature(t,e):zt(e)?this.onMidpoint(t,e):void 0},Ft.onDrag=function(t,e){if(!0===t.canDragMove){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};t.selectedCoordPaths.length>0?this.dragVertex(t,e,n):this.dragFeature(t,e,n),t.dragMoveLocation=e.lngLat}},Ft.onClick=function(t,e){return ht(e)?this.clickNoTarget(t,e):ut(e)?this.clickActiveFeature(t,e):ct(e)?this.clickInactive(t,e):void this.stopDragging(t)},Ft.onTap=function(t,e){return ht(e)?this.clickNoTarget(t,e):ut(e)?this.clickActiveFeature(t,e):ct(e)?this.clickInactive(t,e):void 0},Ft.onTouchEnd=Ft.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t)};var Bt={};function Ut(t,e){return!!t.lngLat&&t.lngLat.lng===e[0]&&t.lngLat.lat===e[1]}Bt.onSetup=function(){var t=this.newFeature({type:d,properties:{},geometry:{type:y,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:u}),this.activateUIButton(f.POINT),this.setActionableState({trash:!0}),{point:t}},Bt.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)},Bt.onTap=Bt.onClick=function(t,e){this.updateUIClasses({mouse:c}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(b,{features:[t.point.toGeoJSON()]}),this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.point.id]})},Bt.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0})},Bt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.point.id;if(e.properties.active=r?A:L,!r)return n(e)},Bt.onTrash=Bt.stopDrawingAndRemove,Bt.onKeyUp=function(t,e){if(dt(e)||mt(e))return this.stopDrawingAndRemove(t,e)};var Vt={onSetup:function(){var t=this.newFeature({type:d,properties:{},geometry:{type:m,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),wt(this),this.updateUIClasses({mouse:u}),this.activateUIButton(f.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Ut(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:u}),t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),pt(e)&&this.updateUIClasses({mouse:h})}};Vt.onTap=Vt.onClick=function(t,e){return pt(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},Vt.onKeyUp=function(t,e){dt(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)):mt(e)&&this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},Vt.onStop=function(t){this.updateUIClasses({mouse:p}),bt(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(b,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT,{},{silent:!0})))},Vt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.polygon.id;if(e.properties.active=r?A:L,!r)return n(e);if(0!==e.geometry.coordinates.length){var i=e.geometry.coordinates[0].length;if(!(i<3)){if(e.properties.meta=T,n(_t(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),i>3){var o=e.geometry.coordinates[0].length-3;n(_t(t.polygon.id,e.geometry.coordinates[0][o],"0."+o,!1))}if(i<=4){var a=[[e.geometry.coordinates[0][0][0],e.geometry.coordinates[0][0][1]],[e.geometry.coordinates[0][1][0],e.geometry.coordinates[0][1][1]]];if(n({type:d,properties:e.properties,geometry:{coordinates:a,type:g}}),3===i)return}return n(e)}}},Vt.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)};var Gt={onSetup:function(t){var e,n,r=(t=t||{}).featureId,i="forward";if(r){if(!(e=this.getFeature(r)))throw new Error("Could not find a feature with the provided featureId");var o=t.from;if(o&&"Feature"===o.type&&o.geometry&&"Point"===o.geometry.type&&(o=o.geometry),o&&"Point"===o.type&&o.coordinates&&2===o.coordinates.length&&(o=o.coordinates),!o||!Array.isArray(o))throw new Error("Please use the `from` property to indicate which point to continue the line from");var a=e.coordinates.length-1;if(e.coordinates[a][0]===o[0]&&e.coordinates[a][1]===o[1])n=a+1,e.addCoordinate.apply(e,[n].concat(e.coordinates[a]));else{if(e.coordinates[0][0]!==o[0]||e.coordinates[0][1]!==o[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");i="backwards",n=0,e.addCoordinate.apply(e,[n].concat(e.coordinates[0]))}}else e=this.newFeature({type:d,properties:{},geometry:{type:g,coordinates:[]}}),n=0,this.addFeature(e);return this.clearSelectedFeatures(),wt(this),this.updateUIClasses({mouse:u}),this.activateUIButton(f.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:n,direction:i}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Ut(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&Ut(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:u}),t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),"forward"===t.direction?(t.currentVertexPosition++,t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)):t.line.addCoordinate(0,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),pt(e)&&this.updateUIClasses({mouse:h})}};Gt.onTap=Gt.onClick=function(t,e){if(pt(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e)},Gt.onKeyUp=function(t,e){mt(e)?this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]}):dt(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT))},Gt.onStop=function(t){bt(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(b,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT,{},{silent:!0})))},Gt.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)},Gt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.line.id;if(e.properties.active=r?A:L,!r)return n(e);e.geometry.coordinates.length<2||(e.properties.meta=T,n(_t(t.line.id,e.geometry.coordinates["forward"===t.direction?e.geometry.coordinates.length-2:1],""+("forward"===t.direction?e.geometry.coordinates.length-2:1),!1)),n(e))};var jt={simple_select:Ot,direct_select:Ft,draw_point:Bt,draw_polygon:Vt,draw_line_string:Gt},Ht={defaultMode:x.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}],modes:jt,controls:{},userProperties:!1},qt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Wt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Xt(t,e){return t.map((function(t){return t.source?t:it(t,{id:t.id+"."+e,source:"hot"===e?s:l})}))}var Zt=G((function(t,e){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,l={};l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object Boolean]"]=l["[object DataView]"]=l["[object Date]"]=l["[object Error]"]=l["[object Function]"]=l[r]=l["[object Number]"]=l[i]=l["[object RegExp]"]=l[o]=l["[object String]"]=l["[object WeakMap]"]=!1;var u="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,h=u||c||Function("return this")(),p=e&&!e.nodeType&&e,f=p&&t&&!t.nodeType&&t,d=f&&f.exports===p,m=d&&u.process,g=function(){try{return m&&m.binding&&m.binding("util")}catch(t){}}(),y=g&&g.isTypedArray;function v(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function _(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function x(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var b,w,E,S=Array.prototype,M=Function.prototype,T=Object.prototype,C=h["__core-js_shared__"],I=M.toString,A=T.hasOwnProperty,L=(b=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"",P=T.toString,R=RegExp("^"+I.call(A).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D=d?h.Buffer:void 0,N=h.Symbol,O=h.Uint8Array,k=T.propertyIsEnumerable,z=S.splice,F=N?N.toStringTag:void 0,B=Object.getOwnPropertySymbols,U=D?D.isBuffer:void 0,V=(w=Object.keys,E=Object,function(t){return w(E(t))}),G=ft(h,"DataView"),j=ft(h,"Map"),H=ft(h,"Promise"),q=ft(h,"Set"),W=ft(h,"WeakMap"),X=ft(Object,"create"),Z=yt(G),Y=yt(j),J=yt(H),K=yt(q),Q=yt(W),$=N?N.prototype:void 0,tt=$?$.valueOf:void 0;function et(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function nt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function rt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new rt;++e<n;)this.add(t[e])}function ot(t){var e=this.__data__=new nt(t);this.size=e.size}function at(t,e){for(var n=t.length;n--;)if(vt(t[n][0],e))return n;return-1}function st(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":F&&F in Object(t)?function(t){var e=A.call(t,F),n=t[F];try{t[F]=void 0;var r=!0}catch(t){}var i=P.call(t);r&&(e?t[F]=n:delete t[F]);return i}(t):function(t){return P.call(t)}(t)}function lt(t){return Mt(t)&&st(t)==n}function ut(t,e,a,s,l){return t===e||(null==t||null==e||!Mt(t)&&!Mt(e)?t!=t&&e!=e:function(t,e,a,s,l,u){var c=xt(t),h=xt(e),p=c?"[object Array]":mt(t),f=h?"[object Array]":mt(e),d=(p=p==n?i:p)==i,m=(f=f==n?i:f)==i,g=p==f;if(g&&bt(t)){if(!bt(e))return!1;c=!0,d=!1}if(g&&!d)return u||(u=new ot),c||Tt(t)?ct(t,e,a,s,l,u):function(t,e,n,i,a,s,l){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new O(t),new O(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return vt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case r:var u=_;case o:var c=1&i;if(u||(u=x),t.size!=e.size&&!c)return!1;var h=l.get(t);if(h)return h==e;i|=2,l.set(t,e);var p=ct(u(t),u(e),i,a,s,l);return l.delete(t),p;case"[object Symbol]":if(tt)return tt.call(t)==tt.call(e)}return!1}(t,e,p,a,s,l,u);if(!(1&a)){var y=d&&A.call(t,"__wrapped__"),v=m&&A.call(e,"__wrapped__");if(y||v){var b=y?t.value():t,w=v?e.value():e;return u||(u=new ot),l(b,w,a,s,u)}}return!!g&&(u||(u=new ot),function(t,e,n,r,i,o){var a=1&n,s=ht(t),l=s.length;if(l!=ht(e).length&&!a)return!1;for(var u=l;u--;){var c=s[u];if(!(a?c in e:A.call(e,c)))return!1}var h=o.get(t);if(h&&o.get(e))return h==e;var p=!0;o.set(t,e),o.set(e,t);for(var f=a;++u<l;){var d=t[c=s[u]],m=e[c];if(r)var g=a?r(m,d,c,e,t,o):r(d,m,c,t,e,o);if(!(void 0===g?d===m||i(d,m,n,r,o):g)){p=!1;break}f||(f="constructor"==c)}if(p&&!f){var y=t.constructor,v=e.constructor;y==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(p=!1)}return o.delete(t),o.delete(e),p}(t,e,a,s,l,u))}(t,e,a,s,ut,l))}function ct(t,e,n,r,i,o){var a=1&n,s=t.length,l=e.length;if(s!=l&&!(a&&l>s))return!1;var u=o.get(t);if(u&&o.get(e))return u==e;var c=-1,h=!0,p=2&n?new it:void 0;for(o.set(t,e),o.set(e,t);++c<s;){var f=t[c],d=e[c];if(r)var m=a?r(d,f,c,e,t,o):r(f,d,c,t,e,o);if(void 0!==m){if(m)continue;h=!1;break}if(p){if(!v(e,(function(t,e){if(a=e,!p.has(a)&&(f===t||i(f,t,n,r,o)))return p.push(e);var a}))){h=!1;break}}else if(f!==d&&!i(f,d,n,r,o)){h=!1;break}}return o.delete(t),o.delete(e),h}function ht(t){return function(t,e,n){var r=e(t);return xt(t)?r:function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}(r,n(t))}(t,Ct,dt)}function pt(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function ft(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!St(t)||function(t){return!!L&&L in t}(t))&&(wt(t)?R:a).test(yt(t))}(n)?n:void 0}et.prototype.clear=function(){this.__data__=X?X(null):{},this.size=0},et.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},et.prototype.get=function(t){var e=this.__data__;if(X){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return A.call(e,t)?e[t]:void 0},et.prototype.has=function(t){var e=this.__data__;return X?void 0!==e[t]:A.call(e,t)},et.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=X&&void 0===e?"__lodash_hash_undefined__":e,this},nt.prototype.clear=function(){this.__data__=[],this.size=0},nt.prototype.delete=function(t){var e=this.__data__,n=at(e,t);return!(n<0||(n==e.length-1?e.pop():z.call(e,n,1),--this.size,0))},nt.prototype.get=function(t){var e=this.__data__,n=at(e,t);return n<0?void 0:e[n][1]},nt.prototype.has=function(t){return at(this.__data__,t)>-1},nt.prototype.set=function(t,e){var n=this.__data__,r=at(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},rt.prototype.clear=function(){this.size=0,this.__data__={hash:new et,map:new(j||nt),string:new et}},rt.prototype.delete=function(t){var e=pt(this,t).delete(t);return this.size-=e?1:0,e},rt.prototype.get=function(t){return pt(this,t).get(t)},rt.prototype.has=function(t){return pt(this,t).has(t)},rt.prototype.set=function(t,e){var n=pt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},it.prototype.add=it.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},it.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.clear=function(){this.__data__=new nt,this.size=0},ot.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ot.prototype.get=function(t){return this.__data__.get(t)},ot.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.set=function(t,e){var n=this.__data__;if(n instanceof nt){var r=n.__data__;if(!j||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new rt(r)}return n.set(t,e),this.size=n.size,this};var dt=B?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a)&&(o[i++]=a)}return o}(B(t),(function(e){return k.call(t,e)})))}:function(){return[]},mt=st;function gt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||s.test(t))&&t>-1&&t%1==0&&t<e}function yt(t){if(null!=t){try{return I.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function vt(t,e){return t===e||t!=t&&e!=e}(G&&"[object DataView]"!=mt(new G(new ArrayBuffer(1)))||j&&mt(new j)!=r||H&&"[object Promise]"!=mt(H.resolve())||q&&mt(new q)!=o||W&&"[object WeakMap]"!=mt(new W))&&(mt=function(t){var e=st(t),n=e==i?t.constructor:void 0,a=n?yt(n):"";if(a)switch(a){case Z:return"[object DataView]";case Y:return r;case J:return"[object Promise]";case K:return o;case Q:return"[object WeakMap]"}return e});var _t=lt(function(){return arguments}())?lt:function(t){return Mt(t)&&A.call(t,"callee")&&!k.call(t,"callee")},xt=Array.isArray,bt=U||function(){return!1};function wt(t){if(!St(t))return!1;var e=st(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Et(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function St(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Mt(t){return null!=t&&"object"==typeof t}var Tt=y?function(t){return function(e){return t(e)}}(y):function(t){return Mt(t)&&Et(t.length)&&!!l[st(t)]};function Ct(t){return null!=(e=t)&&Et(e.length)&&!wt(e)?function(t,e){var n=xt(t),r=!n&&_t(t),i=!n&&!r&&bt(t),o=!n&&!r&&!i&&Tt(t),a=n||r||i||o,s=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],l=s.length;for(var u in t)!e&&!A.call(t,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gt(u,l))||s.push(u);return s}(t):function(t){if(n=(e=t)&&e.constructor,e!==("function"==typeof n&&n.prototype||T))return V(t);var e,n,r=[];for(var i in Object(t))A.call(t,i)&&"constructor"!=i&&r.push(i);return r}(t);var e}t.exports=function(t,e){return ut(t,e)}})),Yt={Polygon:X,LineString:W,Point:q,MultiPolygon:J,MultiLineString:J,MultiPoint:J};var Jt=function(t,e){var n={options:t=function(t){void 0===t&&(t={});var e=it(t);return t.controls||(e.controls={}),!1===t.displayControlsDefault?e.controls=it(Wt,t.controls):e.controls=it(qt,t.controls),(e=it(Ht,e)).styles=Xt(e.styles,"cold").concat(Xt(e.styles,"hot")),e}(t)};e=function(t,e){return e.modes=x,e.getFeatureIdsAt=function(e){return k.click({point:e},null,t).map((function(t){return t.properties.id}))},e.getSelectedIds=function(){return t.store.getSelectedIds()},e.getSelected=function(){return{type:v,features:t.store.getSelectedIds().map((function(e){return t.store.get(e)})).map((function(t){return t.toGeoJSON()}))}},e.getSelectedPoints=function(){return{type:v,features:t.store.getSelectedCoordinates().map((function(t){return{type:d,properties:{},geometry:{type:y,coordinates:t.coordinates}}}))}},e.set=function(n){if(void 0===n.type||n.type!==v||!Array.isArray(n.features))throw new Error("Invalid FeatureCollection");var r=t.store.createRenderBatch(),i=t.store.getAllIds().slice(),o=e.add(n),a=new N(o);return(i=i.filter((function(t){return!a.has(t)}))).length&&e.delete(i),r(),o},e.add=function(e){var n=JSON.parse(JSON.stringify(Et(e))).features.map((function(e){if(e.id=e.id||j(),null===e.geometry)throw new Error("Invalid geometry: null");if(void 0===t.store.get(e.id)||t.store.get(e.id).type!==e.geometry.type){var n=Yt[e.geometry.type];if(void 0===n)throw new Error("Invalid geometry type: "+e.geometry.type+".");var r=new n(t,e);t.store.add(r)}else{var i=t.store.get(e.id);i.properties=e.properties,Zt(i.getCoordinates(),e.geometry.coordinates)||i.incomingCoords(e.geometry.coordinates)}return e.id}));return t.store.render(),n},e.get=function(e){var n=t.store.get(e);if(n)return n.toGeoJSON()},e.getAll=function(){return{type:v,features:t.store.getAll().map((function(t){return t.toGeoJSON()}))}},e.delete=function(n){return t.store.delete(n,{silent:!0}),e.getMode()!==x.DIRECT_SELECT||t.store.getSelectedIds().length?t.store.render():t.events.changeMode(x.SIMPLE_SELECT,void 0,{silent:!0}),e},e.deleteAll=function(){return t.store.delete(t.store.getAllIds(),{silent:!0}),e.getMode()===x.DIRECT_SELECT?t.events.changeMode(x.SIMPLE_SELECT,void 0,{silent:!0}):t.store.render(),e},e.changeMode=function(n,r){return void 0===r&&(r={}),n===x.SIMPLE_SELECT&&e.getMode()===x.SIMPLE_SELECT?(i=r.featureIds||[],o=t.store.getSelectedIds(),i.length===o.length&&JSON.stringify(i.map((function(t){return t})).sort())===JSON.stringify(o.map((function(t){return t})).sort())||(t.store.setSelected(r.featureIds,{silent:!0}),t.store.render()),e):(n===x.DIRECT_SELECT&&e.getMode()===x.DIRECT_SELECT&&r.featureId===t.store.getSelectedIds()[0]||t.events.changeMode(n,r,{silent:!0}),e);var i,o},e.getMode=function(){return t.events.getMode()},e.trash=function(){return t.events.trash({silent:!0}),e},e.combineFeatures=function(){return t.events.combineFeatures({silent:!0}),e},e.uncombineFeatures=function(){return t.events.uncombineFeatures({silent:!0}),e},e.setFeatureProperty=function(n,r,i){return t.store.setFeatureProperty(n,r,i),e},e}(n,e),n.api=e;var r=st(n);return e.onAdd=r.onAdd,e.onRemove=r.onRemove,e.types=f,e.options=t,e};function Kt(t){Jt(t,this)}return Kt.modes=jt,Kt}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t=t||self).GeoSearch={},t.L)}(this,(function(t,e){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e,n){return(o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function a(t,e,n,r){void 0===e&&(e=""),void 0===r&&(r={});var i=document.createElement(t);return e&&(i.className=e),Object.keys(r).forEach((function(t){if("function"==typeof r[t]){var e=0===t.indexOf("on")?t.substr(2).toLowerCase():t;i.addEventListener(e,r[t])}else"html"===t?i.innerHTML=r[t]:"text"===t?i.innerText=r[t]:i.setAttribute(t,r[t])})),n&&n.appendChild(i),i}function s(t){t.preventDefault(),t.stopPropagation()}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var l=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter(Boolean).join(" ").trim()};function u(t,e){t&&t.classList&&(Array.isArray(e)?e:[e]).forEach((function(e){t.classList.contains(e)||t.classList.add(e)}))}function c(t,e){t&&t.classList&&(Array.isArray(e)?e:[e]).forEach((function(e){t.classList.contains(e)&&t.classList.remove(e)}))}var h,p=13,f=40,d=38,m=[p,27,f,d,37,39],g=function(){function t(t){var e=this,n=t.handleSubmit,r=t.searchLabel,i=t.classNames,o=void 0===i?{}:i;this.hasError=!1,this.container=a("div",l("geosearch",o.container)),this.form=a("form",["",o.form].join(" "),this.container,{autocomplete:"none",onClick:s,onDblClick:s,touchStart:s,touchEnd:s}),this.input=a("input",["glass",o.input].join(" "),this.form,{type:"text",placeholder:r||"search",onInput:this.onInput,onKeyUp:function(t){return e.onKeyUp(t)},onKeyPress:function(t){return e.onKeyPress(t)},onFocus:this.onFocus,onBlur:this.onBlur,onClick:function(){e.input.focus(),e.input.dispatchEvent(new Event("focus"))}}),this.handleSubmit=n}var e=t.prototype;return e.onFocus=function(){u(this.form,"active")},e.onBlur=function(){c(this.form,"active")},e.onSubmit=function(t){try{var e=this;return s(t),c(n=e.container,"error"),u(n,"pending"),Promise.resolve(e.handleSubmit({query:e.input.value})).then((function(){c(e.container,"pending")}))}catch(t){return Promise.reject(t)}var n},e.onInput=function(){this.hasError&&(c(this.container,"error"),this.hasError=!1)},e.onKeyUp=function(t){27===t.keyCode&&(c(this.container,["pending","active"]),this.input.value="",document.body.focus(),document.body.blur())},e.onKeyPress=function(t){t.keyCode===p&&this.onSubmit(t)},e.setQuery=function(t){this.input.value=t},t}(),y=function(){function t(t){var e=this,n=t.handleClick,r=t.classNames,i=void 0===r?{}:r;this.selected=-1,this.results=[],this.onClick=function(t){if("function"==typeof e.handleClick){var n=t.target;if(n&&e.container.contains(n)&&n.hasAttribute("data-key")){var r=Number(n.getAttribute("data-key"));e.handleClick({result:e.results[r]})}}},this.handleClick=n,this.container=a("div",l("results",i.container)),this.container.addEventListener("click",this.onClick,!0),this.resultItem=a("div",l(i.item))}var e=t.prototype;return e.render=function(t){var e=this;void 0===t&&(t=[]),this.clear(),t.forEach((function(t,n){var r=e.resultItem.cloneNode(!0);r.setAttribute("data-key",""+n),r.innerHTML=t.label,e.container.appendChild(r)})),t.length>0&&(u(this.container.parentElement,"open"),u(this.container,"active")),this.results=t},e.select=function(t){return Array.from(this.container.children).forEach((function(e,n){return n===t?u(e,"active"):c(e,"active")})),this.selected=t,this.results[t]},e.count=function(){return this.results?this.results.length:0},e.clear=function(){for(this.selected=-1;this.container.lastChild;)this.container.removeChild(this.container.lastChild);c(this.container.parentElement,"open"),c(this.container,"active")},t}(),v={position:"topleft",style:"button",showMarker:!0,showPopup:!1,popupFormat:function(t){return""+t.result.label},marker:{icon:e&&e.Icon?new e.Icon.Default:void 0,draggable:!1},maxMarkers:1,maxSuggestions:5,retainZoomLevel:!1,animateZoom:!0,searchLabel:"Enter address",notFoundMessage:"Sorry, that address could not be found.",messageHideDelay:3e3,zoomLevel:18,classNames:{container:"leaflet-bar leaflet-control leaflet-control-geosearch",button:"leaflet-bar-part leaflet-bar-part-single",resetButton:"reset",msgbox:"leaflet-bar message",form:"",input:""},autoComplete:!0,autoCompleteDelay:250,autoClose:!1,keepResult:!1},_={},x=["dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard"],b="Leaflet must be loaded before instantiating the GeoSearch control",w={options:n({},v),classNames:n({},v.classNames),initialize:function(t){var r,i,o,l,u=this;if(!e)throw new Error(b);if(!t.provider)throw new Error("Provider is missing from options");this.options=n({},this.options,{},t),this.classNames=n({},this.classNames,{},t.classNames),this.markers=new e.FeatureGroup,this.classNames.container+=" leaflet-geosearch-"+this.options.style,this.searchElement=new g({searchLabel:this.options.searchLabel,classNames:{container:this.classNames.container,form:this.classNames.form,input:this.classNames.input},handleSubmit:function(t){return u.onSubmit(t)}}),this.button=a("a",this.classNames.button,this.searchElement.container,{title:this.options.searchLabel,href:"#",onClick:function(t){return u.onClick(t)},onDblClick:function(t){return s(t)}}),this.resetButton=a("a",this.classNames.resetButton,this.searchElement.form,{text:"×",href:"#",onClick:function(){return u.clearResults(null,!0)}}),this.options.autoComplete&&(this.resultList=new y({handleClick:function(t){var e=t.result;u.searchElement.input.value=e.label,u.onSubmit({query:e.label,data:e})}}),this.searchElement.form.appendChild(this.resultList.container),this.searchElement.input.addEventListener("keyup",(r=function(t){return u.autoSearch(t)},void 0===(i=this.options.autoCompleteDelay)&&(i=250),void 0===o&&(o=!1),function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];l&&clearTimeout(l),l=setTimeout((function(){l=null,o||r.apply(void 0,e)}),i),o&&!l&&r.apply(void 0,e)}),!0),this.searchElement.input.addEventListener("keydown",(function(t){return u.selectResult(t)}),!0),this.searchElement.input.addEventListener("keydown",(function(t){return u.clearResults(t,!0)}),!0)),this.searchElement.form.addEventListener("mouseenter",(function(t){u.disableHandlers(t)}),!0),this.searchElement.form.addEventListener("mouseleave",(function(){return u.restoreHandlers()}),!0),this.searchElement.form.addEventListener("click",(function(t){t.preventDefault()}),!1)},onAdd:function(t){var e=this.options,n=e.showMarker,r=e.style;if(this.map=t,n&&this.markers.addTo(t),"bar"===r){var i=t.getContainer().querySelector(".leaflet-control-container");this.container=a("div","leaflet-control-geosearch leaflet-geosearch-bar"),this.container.appendChild(this.searchElement.form),i.appendChild(this.container)}return this.searchElement.container},onRemove:function(){var t;return null==(t=this.container)||t.remove(),this},onClick:function(t){t.preventDefault(),t.stopPropagation();var e=this.searchElement,n=e.container,r=e.input;n.classList.contains("active")?(c(n,"active"),this.clearResults()):(u(n,"active"),r.focus())},disableHandlers:function(t){var e=this;this.searchElement.form.contains(t.target)&&x.forEach((function(t){var n,r;_[t]=null==(n=e.map[t])?void 0:n.enabled(),null==(r=e.map[t])||r.disable()}))},restoreHandlers:function(t){var e=this;t&&!this.searchElement.form.includes(t.target)||x.forEach((function(t){var n;_[t]&&(null==(n=e.map[t])||n.enable())}))},selectResult:function(t){if(-1!==[p,f,d].indexOf(t.keyCode))if(t.preventDefault(),t.keyCode!==p){var e=this.resultList.count()-1;if(!(e<0)){var n=this.resultList.selected,r=t.keyCode===f?n+1:n-1,i=this.resultList.select(r<0?e:r>e?0:r);this.searchElement.input.value=i.label}}else{var o=this.resultList.select(this.resultList.selected);this.onSubmit({query:this.searchElement.input.value,data:o})}},clearResults:function(t,e){if(void 0===e&&(e=!1),!t||27===t.keyCode){var n=this.options,r=n.autoComplete;!e&&n.keepResult||(this.searchElement.input.value="",this.markers.clearLayers()),r&&this.resultList.clear()}},autoSearch:function(t){try{var e=this;if(m.indexOf(t.keyCode)>-1)return Promise.resolve();var n=t.target.value,r=e.options.provider,i=function(){if(n.length)return Promise.resolve(r.search({query:n})).then((function(t){t=t.slice(0,e.options.maxSuggestions),e.resultList.render(t)}));e.resultList.clear()}();return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},onSubmit:function(t){try{var e=this;return Promise.resolve(e.options.provider.search(t)).then((function(n){n&&n.length>0&&e.showResult(n[0],t)}))}catch(t){return Promise.reject(t)}},showResult:function(t,e){var n=this.options.autoClose,r=Object.keys(this.markers._layers);r.length>=this.options.maxMarkers&&this.markers.removeLayer(r[0]);var i=this.addMarker(t,e);this.centerMap(t),this.map.fireEvent("geosearch/showlocation",{location:t,marker:i}),n&&this.closeResults()},closeResults:function(){var t=this.searchElement.container;t.classList.contains("active")&&c(t,"active"),this.restoreHandlers(),this.clearResults()},addMarker:function(t,n){var r=this,i=this.options,o=i.marker,a=i.showPopup,s=i.popupFormat,l=new e.Marker([t.y,t.x],o),u=t.label;return"function"==typeof s&&(u=s({query:n,result:t})),l.bindPopup(u),this.markers.addLayer(l),a&&l.openPopup(),o.draggable&&l.on("dragend",(function(t){r.map.fireEvent("geosearch/marker/dragend",{location:l.getLatLng(),event:t})})),l},centerMap:function(t){var n=this.options,r=n.retainZoomLevel,i=n.animateZoom,o=t.bounds?new e.LatLngBounds(t.bounds):new e.LatLng(t.y,t.x).toBounds(10),a=o.isValid()?o:this.markers.getBounds();!r&&o.isValid()?this.map.fitBounds(a,{animate:i}):this.map.setView(a.getCenter(),this.getZoom(),{animate:i})},getZoom:function(){var t=this.options,e=t.zoomLevel;return t.retainZoomLevel?this.map.getZoom():e}};function E(){if(!e)throw new Error(b);for(var t=e.Control.extend(w),n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return o(t,r)}!function(t){t[t.SEARCH=0]="SEARCH",t[t.REVERSE=1]="REVERSE"}(h||(h={}));var S=function(){function t(t){void 0===t&&(t={}),this.options=t}var e=t.prototype;return e.getParamString=function(t){void 0===t&&(t={});var e=n({},this.options.params,{},t);return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")},e.getUrl=function(t,e){return t+"?"+this.getParamString(e)},e.search=function(t){try{var e=this,n=e.endpoint({query:t.query,type:h.SEARCH});return Promise.resolve(fetch(n)).then((function(t){return Promise.resolve(t.json()).then((function(t){return e.parse({data:t})}))}))}catch(t){return Promise.reject(t)}},t}(),M=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.endpoint=function(){return"https://places-dsn.algolia.net/1/places/query"},i.findBestMatchLevelIndex=function(t){var e=t.find((function(t){return"full"===t.matchLevel}))||t.find((function(t){return"partial"===t.matchLevel}));return e?t.indexOf(e):0},i.getLabel=function(t){var e,n,r,i;return[null==(e=t.locale_names)?void 0:e.default[this.findBestMatchLevelIndex(t._highlightResult.locale_names.default)],null==(n=t.city)?void 0:n.default[this.findBestMatchLevelIndex(t._highlightResult.city.default)],t.administrative[this.findBestMatchLevelIndex(t._highlightResult.administrative)],null==(r=t.postcode)?void 0:r[this.findBestMatchLevelIndex(t._highlightResult.postcode)],null==(i=t.country)?void 0:i.default].filter(Boolean).join(", ")},i.parse=function(t){var e=this;return t.data.hits.map((function(t){return{x:t._geoloc.lng,y:t._geoloc.lat,label:e.getLabel(t),bounds:null,raw:t}}))},i.search=function(t){var e=t.query;try{var r=this,i="string"==typeof e?{query:e}:e;return Promise.resolve(fetch(r.endpoint(),{method:"POST",body:JSON.stringify(n({},r.options.params,{},i))})).then((function(t){return Promise.resolve(t.json()).then((function(t){return r.parse({data:t})}))}))}catch(t){return Promise.reject(t)}},e}(S),T=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).searchUrl="https://dev.virtualearth.net/REST/v1/Locations",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,n="string"==typeof e?{q:e}:e;return n.jsonp=t.jsonp,this.getUrl(this.searchUrl,n)},n.parse=function(t){return 0===t.data.resourceSets.length?[]:t.data.resourceSets[0].resources.map((function(t){return{x:t.point.coordinates[1],y:t.point.coordinates[0],label:t.address.formattedAddress,bounds:[[t.bbox[0],t.bbox[1]],[t.bbox[2],t.bbox[3]]],raw:t}}))},n.search=function(t){var e,n,r,i=t.query;try{var o=this,s="BING_JSONP_CB_"+Date.now();return Promise.resolve((e=o.endpoint({query:i,jsonp:s}),n=s,r=a("script",null,document.body),r.setAttribute("type","text/javascript"),new Promise((function(t){window[n]=function(e){r.remove(),delete window[n],t(e)},r.setAttribute("src",e)})))).then((function(t){return o.parse({data:t})}))}catch(t){return Promise.reject(t)}},e}(S),C=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).searchUrl="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,n="string"==typeof e?{text:e}:e;return n.f="json",this.getUrl(this.searchUrl,n)},n.parse=function(t){return t.data.locations.map((function(t){return{x:t.feature.geometry.x,y:t.feature.geometry.y,label:t.name,bounds:[[t.extent.ymin,t.extent.xmin],[t.extent.ymax,t.extent.xmax]],raw:t}}))},e}(S),I=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).searchUrl="https://maps.googleapis.com/maps/api/geocode/json",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return this.getUrl(this.searchUrl,"string"==typeof e?{address:e}:e)},n.parse=function(t){return t.data.results.map((function(t){return{x:t.geometry.location.lng,y:t.geometry.location.lat,label:t.formatted_address,bounds:[[t.geometry.viewport.southwest.lat,t.geometry.viewport.southwest.lng],[t.geometry.viewport.northeast.lat,t.geometry.viewport.northeast.lng]],raw:t}}))},e}(S),A=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).searchUrl="https://geocode.search.hereapi.com/v1/geocode",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return this.getUrl(this.searchUrl,"string"==typeof e?{q:e}:e)},n.parse=function(t){return t.data.items.map((function(t){return{x:t.position.lng,y:t.position.lat,label:t.address.label,bounds:null,raw:t}}))},e}(S),L=function(t){function e(e){var n;void 0===e&&(e={});var r="https://nominatim.openstreetmap.org";return(n=t.call(this,e)||this).searchUrl=e.searchUrl||r+"/search",n.reverseUrl=e.reverseUrl||r+"/reverse",n}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,n=t.type,r="string"==typeof e?{q:e}:e;return(r.format="json",n)===h.REVERSE?this.getUrl(this.reverseUrl,r):this.getUrl(this.searchUrl,r)},n.parse=function(t){return(Array.isArray(t.data)?t.data:[t.data]).map((function(t){return{x:Number(t.lon),y:Number(t.lat),label:t.display_name,bounds:[[parseFloat(t.boundingbox[0]),parseFloat(t.boundingbox[2])],[parseFloat(t.boundingbox[1]),parseFloat(t.boundingbox[3])]],raw:t}}))},e}(S),P=function(t){function e(e){return t.call(this,n({},e,{searchUrl:"https://locationiq.org/v1/search.php",reverseUrl:"https://locationiq.org/v1/reverse.php"}))||this}return r(e,t),e}(L),R=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).searchUrl="https://api.opencagedata.com/geocode/v1/json",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,n="string"==typeof e?{q:e}:e;return n.format="json",this.getUrl(this.searchUrl,n)},n.parse=function(t){return t.data.results.map((function(t){return{x:t.geometry.lng,y:t.geometry.lat,label:t.formatted,bounds:[[t.bounds.southwest.lat,t.bounds.southwest.lng],[t.bounds.northeast.lat,t.bounds.northeast.lng]],raw:t}}))},n.search=function(e){try{return Promise.resolve(e.query.length<2?[]:t.prototype.search.call(this,e))}catch(t){return Promise.reject(t)}},e}(S);t.AlgoliaProvider=M,t.BingProvider=T,t.EsriProvider=C,t.GeoSearchControl=E,t.GoogleProvider=I,t.HereProvider=A,t.JsonProvider=S,t.LocationIQProvider=P,t.OpenCageProvider=R,t.OpenStreetMapProvider=L,t.SearchControl=E,t.SearchElement=g}));!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).geojsonhint=t()}}((function(){return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};e[a][0].call(c.exports,(function(t){return i(e[a][1][t]||t)}),c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){var r=t("./rhr");e.exports.hint=function(t,e){var n=[],i=0,o=10,a=6;function s(t){e&&!1===e.noDuplicateMembers||!t.__duplicateProperties__||n.push({message:"An object contained duplicate members, making parsing ambigous: "+t.__duplicateProperties__.join(", "),line:t.__line__});if(!u(t,"type","string"))if(m[t.type])t&&m[t.type](t);else{var r=g[t.type.toLowerCase()];void 0!==r?n.push({message:"Expected "+r+" but got "+t.type+" (case sensitive)",line:t.__line__}):n.push({message:"The type "+t.type+" is unknown",line:t.__line__})}}function l(t,e){return t.every((function(t){return null!==t&&typeof t===e}))}function u(t,e,r){if(void 0===t[e])return n.push({message:'"'+e+'" member required',line:t.__line__});if("array"===r){if(!Array.isArray(t[e]))return n.push({message:'"'+e+'" member should be an array, but is an '+typeof t[e]+" instead",line:t.__line__})}else{if("object"===r&&t[e]&&t[e].constructor!==Object)return n.push({message:'"'+e+'" member should be '+r+", but is an "+t[e].constructor.name+" instead",line:t.__line__});if(r&&typeof t[e]!==r)return n.push({message:'"'+e+'" member should be '+r+", but is an "+typeof t[e]+" instead",line:t.__line__})}}function c(t,r){if(!Array.isArray(t))return n.push({message:"position should be an array, is a "+typeof t+" instead",line:t.__line__||r});if(t.length<2)return n.push({message:"position must have 2 or more elements",line:t.__line__||r});if(t.length>3)return n.push({message:"position should not have more than 3 elements",level:"message",line:t.__line__||r});if(!l(t,"number"))return n.push({message:"each element in a position must be a number",line:t.__line__||r});if(e&&e.precisionWarning){if(i===o){i+=1;return n.push({message:"truncated warnings: we've encountered coordinate precision warning "+o+" times, no more warnings will be reported",level:"message",line:t.__line__||r})}i<o&&t.forEach((function(e){var o=0,s=String(e).split(".")[1];void 0!==s&&(o=s.length);if(o>a){i+=1;return n.push({message:"precision of coordinates should be reduced",level:"message",line:t.__line__||r})}}))}}function h(t,e,r,i){void 0===i&&void 0!==t.__line__&&(i=t.__line__);if(0===r)return c(t,i);if(1===r&&e)if("LinearRing"===e){if(!Array.isArray(t[t.length-1])){n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:i});return!0}t.length<4&&n.push({message:"a LinearRing of coordinates needs to have four or more positions",line:i});if(t.length&&(t[t.length-1].length!==t[0].length||!t[t.length-1].every((function(e,n){return t[0][n]===e})))){n.push({message:"the first and last positions in a LinearRing of coordinates must be the same",line:i});return!0}}else if("Line"===e&&t.length<2)return n.push({message:"a line needs to have two or more coordinates to be valid",line:i});if(Array.isArray(t)){return t.map((function(t){return h(t,e,r-1,t.__line__||i)})).some((function(t){return t}))}n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:i})}function p(t){if(t.crs){"object"==typeof t.crs&&t.crs.properties&&"urn:ogc:def:crs:OGC:1.3:CRS84"===t.crs.properties.name?n.push({message:"old-style crs member is not recommended, this object is equivalent to the default and should be removed",line:t.__line__}):n.push({message:"old-style crs member is not recommended",line:t.__line__})}}function f(t){if(t.bbox){if(Array.isArray(t.bbox)){l(t.bbox,"number")||n.push({message:"each element in a bbox member must be a number",line:t.bbox.__line__});4!==t.bbox.length&&6!==t.bbox.length&&n.push({message:"bbox must contain 4 elements (for 2D) or 6 elements (for 3D)",line:t.bbox.__line__});return n.length}n.push({message:"bbox member must be an array of numbers, but is a "+typeof t.bbox,line:t.__line__})}}function d(t){p(t);f(t);void 0!==t.id&&"string"!=typeof t.id&&"number"!=typeof t.id&&n.push({message:'Feature "id" member must have a string or number value',line:t.__line__});void 0!==t.features&&n.push({message:'Feature object cannot contain a "features" member',line:t.__line__});void 0!==t.coordinates&&n.push({message:'Feature object cannot contain a "coordinates" member',line:t.__line__});"Feature"!==t.type&&n.push({message:"GeoJSON features must have a type=feature member",line:t.__line__});u(t,"properties","object");u(t,"geometry","object")||t.geometry&&s(t.geometry)}var m={Point:function(t){p(t);f(t);!function(t){void 0!==t.properties&&n.push({message:'geometry object cannot contain a "properties" member',line:t.__line__});void 0!==t.geometry&&n.push({message:'geometry object cannot contain a "geometry" member',line:t.__line__});void 0!==t.features&&n.push({message:'geometry object cannot contain a "features" member',line:t.__line__})}(t);u(t,"coordinates","array")||c(t.coordinates)},Feature:d,MultiPoint:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"",1)},LineString:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"Line",1)},MultiLineString:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"Line",2)},FeatureCollection:function(t){p(t);f(t);void 0!==t.properties&&n.push({message:'FeatureCollection object cannot contain a "properties" member',line:t.__line__});void 0!==t.coordinates&&n.push({message:'FeatureCollection object cannot contain a "coordinates" member',line:t.__line__});if(!u(t,"features","array")){if(!l(t.features,"object"))return n.push({message:"Every feature must be an object",line:t.__line__});t.features.forEach(d)}},GeometryCollection:function(t){p(t);f(t);if(!u(t,"geometries","array")){l(t.geometries,"object")||n.push({message:"The geometries array in a GeometryCollection must contain only geometry objects",line:t.__line__});1===t.geometries.length&&n.push({message:"GeometryCollection with a single geometry should be avoided in favor of single part or a single object of multi-part type",line:t.geometries.__line__});t.geometries.forEach((function(e){if(e){"GeometryCollection"===e.type&&n.push({message:"GeometryCollection should avoid nested geometry collections",line:t.geometries.__line__});s(e)}}))}},Polygon:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"LinearRing",2)||r(t,n)},MultiPolygon:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"LinearRing",3)||r(t,n)}},g=Object.keys(m).reduce((function(t,e){t[e.toLowerCase()]=e;return t}),{});if("object"!=typeof t||null==t){n.push({message:"The root of a GeoJSON object must be an object.",line:0});return n}s(t);n.forEach((function(t){({}).hasOwnProperty.call(t,"line")&&void 0===t.line&&delete t.line}));return n}},{"./rhr":2}],2:[function(t,e,n){function r(t){var e=0;if(t.length>2)for(var n,r,i=0;i<t.length-1;i++){n=t[i];e+=((r=t[i+1])[0]-n[0])*(r[1]+n[1])}return e>=0}function i(t){if(t&&t.length>0){if(r(t[0]))return!1;if(!t.slice(1,t.length).every(r))return!1}return!0}e.exports=function(t,e){(function(t){return"Polygon"===t.type?i(t.coordinates):"MultiPolygon"===t.type?t.coordinates.every(i):void 0})(t)||e.push({message:"Polygons and MultiPolygons should follow the right-hand rule",level:"message",line:t.__line__})}},{}],3:[function(t,e,n){},{}],4:[function(t,e,n){(function(r){(function(){var i=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,12],n=[1,13],r=[1,9],i=[1,10],o=[1,11],a=[1,14],s=[1,15],l=[14,18,22,24],u=[18,22],c=[22,24],h={trace:function(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function(t,e,n,r,i,o,a){var s=o.length-1;switch(i){case 1:this.$=t.replace(/\\(\\|")/g,"$1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\v/g,"\v").replace(/\\f/g,"\f").replace(/\\b/g,"\b");break;case 2:this.$=Number(t);break;case 3:this.$=null;break;case 4:this.$=!0;break;case 5:this.$=!1;break;case 6:return this.$=o[s-1];case 13:this.$={};Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 14:case 19:this.$=o[s-1];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 15:this.$=[o[s-2],o[s]];break;case 16:this.$={};this.$[o[s][0]]=o[s][1];break;case 17:this.$=o[s-2];if(void 0!==o[s-2][o[s][0]]){this.$.__duplicateProperties__||Object.defineProperty(this.$,"__duplicateProperties__",{value:[],enumerable:!1});this.$.__duplicateProperties__.push(o[s][0])}o[s-2][o[s][0]]=o[s][1];break;case 18:this.$=[];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 20:this.$=[o[s]];break;case 21:this.$=o[s-2];o[s-2].push(o[s])}},table:[{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,12:1,13:2,15:7,16:8,17:a,23:s},{1:[3]},{14:[1,16]},t(l,[2,7]),t(l,[2,8]),t(l,[2,9]),t(l,[2,10]),t(l,[2,11]),t(l,[2,12]),t(l,[2,3]),t(l,[2,4]),t(l,[2,5]),t([14,18,21,22,24],[2,1]),t(l,[2,2]),{3:20,4:e,18:[1,17],19:18,20:19},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:23,15:7,16:8,17:a,23:s,24:[1,21],25:22},{1:[2,6]},t(l,[2,13]),{18:[1,24],22:[1,25]},t(u,[2,16]),{21:[1,26]},t(l,[2,18]),{22:[1,28],24:[1,27]},t(c,[2,20]),t(l,[2,14]),{3:20,4:e,20:29},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:30,15:7,16:8,17:a,23:s},t(l,[2,19]),{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:31,15:7,16:8,17:a,23:s},t(u,[2,17]),t(u,[2,15]),t(c,[2,21])],defaultActions:{16:[2,6]},parseError:function(t,e){if(!e.recoverable){function n(t,e){this.message=t;this.hash=e}n.prototype=Error;throw new n(t,e)}this.trace(t)},parse:function(t){var e=this,n=[0],r=[null],i=[],o=this.table,a="",s=0,l=0,u=0,c=i.slice.call(arguments,1),h=Object.create(this.lexer),p={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(p.yy[f]=this.yy[f]);h.setInput(t,p.yy);p.yy.lexer=h;p.yy.parser=this;void 0===h.yylloc&&(h.yylloc={});var d=h.yylloc;i.push(d);var m=h.options&&h.options.ranges;"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,y,v,_,x,b,w,E,S,M=function(){var t;"number"!=typeof(t=h.lex()||1)&&(t=e.symbols_[t]||t);return t},T={};;){v=n[n.length-1];if(this.defaultActions[v])_=this.defaultActions[v];else{null==g&&(g=M());_=o[v]&&o[v][g]}if(void 0===_||!_.length||!_[0]){var C="";S=[];for(b in o[v])this.terminals_[b]&&b>2&&S.push("'"+this.terminals_[b]+"'");C=h.showPosition?"Parse error on line "+(s+1)+":\n"+h.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'");this.parseError(C,{text:h.match,token:this.terminals_[g]||g,line:h.yylineno,loc:d,expected:S})}if(_[0]instanceof Array&&_.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+g);switch(_[0]){case 1:n.push(g);r.push(h.yytext);i.push(h.yylloc);n.push(_[1]);g=null;if(y){g=y;y=null}else{l=h.yyleng;a=h.yytext;s=h.yylineno;d=h.yylloc;u>0&&u--}break;case 2:w=this.productions_[_[1]][1];T.$=r[r.length-w];T._$={first_line:i[i.length-(w||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(w||1)].first_column,last_column:i[i.length-1].last_column};m&&(T._$.range=[i[i.length-(w||1)].range[0],i[i.length-1].range[1]]);if(void 0!==(x=this.performAction.apply(T,[a,l,s,p.yy,_[1],r,i].concat(c))))return x;if(w){n=n.slice(0,-1*w*2);r=r.slice(0,-1*w);i=i.slice(0,-1*w)}n.push(this.productions_[_[1]][0]);r.push(T.$);i.push(T._$);E=o[n[n.length-2]][n[n.length-1]];n.push(E);break;case 3:return!0}}return!0}},p={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){this.yy=e||this.yy||{};this._input=t;this._more=this._backtrack=this.done=!1;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};this.options.ranges&&(this.yylloc.range=[0,0]);this.offset=0;return this},input:function(){var t=this._input[0];this.yytext+=t;this.yyleng++;this.offset++;this.match+=t;this.matched+=t;if(t.match(/(?:\r\n?|\n).*/g)){this.yylineno++;this.yylloc.last_line++}else this.yylloc.last_column++;this.options.ranges&&this.yylloc.range[1]++;this._input=this._input.slice(1);return t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-e);this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e};this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]);this.yyleng=this.yytext.length;return this},more:function(){this._more=!0;return this},reject:function(){if(!this.options.backtrack_lexer)return this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno});this._backtrack=!0;return this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;t.length<20&&(t+=this._input.substr(0,20-t.length));return(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer){i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done};this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))}(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length);this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length};this.yytext+=t[0];this.match+=t[0];this.matches=t;this.yyleng=this.yytext.length;this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]);this._more=!1;this._backtrack=!1;this._input=this._input.slice(t[0].length);this.matched+=t[0];n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]);this.done&&this._input&&(this.done=!1);if(n)return n;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,n,r;if(!this._more){this.yytext="";this.match=""}for(var i=this._currentRules(),o=0;o<i.length;o++)if((n=this._input.match(this.rules[i[o]]))&&(!e||n[0].length>e[0].length)){e=n;r=o;if(this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:break;case 1:return 6;case 2:e.yytext=e.yytext.substr(1,e.yyleng-2);return 4;case 3:return 17;case 4:return 18;case 5:return 23;case 6:return 24;case 7:return 22;case 8:return 21;case 9:return 10;case 10:return 11;case 11:return 8;case 12:return 14;case 13:return"INVALID"}},rules:[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt\/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};h.lexer=p;function f(){this.yy={}}f.prototype=h;h.Parser=f;return new f}();if(void 0!==t&&void 0!==n){n.parser=i;n.Parser=i.Parser;n.parse=function(){return i.parse.apply(i,arguments)};n.main=function(e){if(!e[1]){console.log("Usage: "+e[0]+" FILE");r.exit(1)}var i=t("fs").readFileSync(t("path").normalize(e[1]),"utf8");return n.parser.parse(i)};void 0!==e&&t.main===e&&n.main(r.argv.slice(1))}}).call(this)}).call(this,t("_process"))},{_process:6,fs:3,path:5}],5:[function(t,e,n){(function(t){(function(){function e(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];if("."===i)t.splice(r,1);else if(".."===i){t.splice(r,1);n++}else if(n){t.splice(r,1);n--}}if(e)for(;n--;n)t.unshift("..");return t}n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a=o>=0?arguments[o]:t.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");if(a){n=a+"/"+n;i="/"===a.charAt(0)}}return(i?"/":"")+(n=e(r(n.split("/"),(function(t){return!!t})),!i).join("/"))||"."};n.normalize=function(t){var o=n.isAbsolute(t),a="/"===i(t,-1);(t=e(r(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t=".");t&&a&&(t+="/");return(o?"/":"")+t};n.isAbsolute=function(t){return"/"===t.charAt(0)};n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))};n.relative=function(t,e){t=n.resolve(t).substr(1);e=n.resolve(e).substr(1);function r(t){for(var e=0;e<t.length&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l<a;l++)if(i[l]!==o[l]){s=l;break}var u=[];for(l=s;l<i.length;l++)u.push("..");return(u=u.concat(o.slice(s))).join("/")};n.sep="/";n.delimiter=":";n.dirname=function(t){"string"!=typeof t&&(t+="");if(0===t.length)return".";for(var e=t.charCodeAt(0),n=47===e,r=-1,i=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!i){r=o;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":t.slice(0,r)};n.basename=function(t,e){var n=function(t){"string"!=typeof t&&(t+="");var e,n=0,r=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){n=e+1;break}}else if(-1===r){i=!1;r=e+1}return-1===r?"":t.slice(n,r)}(t);e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length));return n};n.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,n=0,r=-1,i=!0,o=0,a=t.length-1;a>=0;--a){var s=t.charCodeAt(a);if(47!==s){if(-1===r){i=!1;r=a+1}46===s?-1===e?e=a:1!==o&&(o=1):-1!==e&&(o=-1)}else if(!i){n=a+1;break}}return-1===e||-1===r||0===o||1===o&&e===r-1&&e===n+1?"":t.slice(e,r)};function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r<t.length;r++)e(t[r],r,t)&&n.push(t[r]);return n}var i="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){e<0&&(e=t.length+e);return t.substr(e,n)}}).call(this)}).call(this,t("_process"))},{_process:6}],6:[function(t,e,n){var r,i,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(t){r=a}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();function l(t){if(r===setTimeout)return setTimeout(t,0);if((r===a||!r)&&setTimeout){r=setTimeout;return setTimeout(t,0)}try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}var u,c=[],h=!1,p=-1;function f(){if(h&&u){h=!1;u.length?c=u.concat(c):p=-1;c.length&&d()}}function d(){if(!h){var t=l(f);h=!0;for(var e=c.length;e;){u=c;c=[];for(;++p<e;)u&&u[p].run();p=-1;e=c.length}u=null;h=!1;!function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout){i=clearTimeout;return clearTimeout(t)}try{return i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new m(t,e));1!==c.length||h||l(d)};function m(t,e){this.fun=t;this.array=e}m.prototype.run=function(){this.fun.apply(null,this.array)};o.title="browser";o.browser=!0;o.env={};o.argv=[];o.version="";o.versions={};function g(){}o.on=g;o.addListener=g;o.once=g;o.off=g;o.removeListener=g;o.removeAllListeners=g;o.emit=g;o.prependListener=g;o.prependOnceListener=g;o.listeners=function(t){return[]};o.binding=function(t){throw new Error("process.binding is not supported")};o.cwd=function(){return"/"};o.chdir=function(t){throw new Error("process.chdir is not supported")};o.umask=function(){return 0}},{}],7:[function(t,e,n){var r=t("jsonlint-lines"),i=t("./object");e.exports.hint=function(t,e){var n,o=[];if("object"==typeof t)n=t;else{if("string"!=typeof t)return[{message:"Expected string or object as input",line:0}];try{n=r.parse(t)}catch(t){var a=t.message.match(/line (\d+)/);return[{line:parseInt(a[1],10)-1,message:t.message,error:t}]}}return o=o.concat(i.hint(n,e))}},{"./object":1,"jsonlint-lines":4}]},{},[7])(7)}));!function(){var t,e,n=function(t){var e;return function(n){return e||t(e={exports:{},parent:n},e.exports),e.exports}}((function(t,e){(function(t,n){(function(){var r=N.nextTick,i=(Function.prototype.apply,Array.prototype.slice),o={},a=0;function s(t,e){this._id=t,this._clearFn=e}s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(window,this._id)},e.setImmediate="function"==typeof t?t:function(t){var n=a++,s=!(arguments.length<2)&&i.call(arguments,1);return o[n]=!0,r((function(){o[n]&&(s?t.apply(null,s):t.call(null),e.clearImmediate(n))})),n},e.clearImmediate="function"==typeof n?n:function(t){delete o[t]}}).call(this)}).call(this,n({}).setImmediate,n({}).clearImmediate)})),r={exports:{}};t=this,e=function(t){"use strict";const e="132",n=100,r=300,i=301,o=302,a=303,s=304,l=306,u=307,c=1e3,h=1001,p=1002,f=1003,d=1004,m=1005,g=1006,y=1007,v=1008,_=1009,x=1012,b=1014,w=1015,E=1016,S=1020,M=1022,T=1023,C=1026,I=1027,A=33776,L=33777,P=33778,R=33779,D=35840,N=35841,O=35842,k=35843,z=37492,F=37496,B=2300,U=2301,V=2302,G=2400,j=2401,H=2402,q=2500,W=2501,X=3e3,Z=3001,Y=3007,J=3002,K=3004,Q=3005,$=3006,tt=35044,et=35048,nt="300 es";class rt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,r=n.length;e<r;e++)n[e].call(this,t);t.target=null}}}const it=[];for(let t=0;t<256;t++)it[t]=(t<16?"0":"")+t.toString(16);let ot=1234567;const at=Math.PI/180,st=180/Math.PI;function lt(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(it[255&t]+it[t>>8&255]+it[t>>16&255]+it[t>>24&255]+"-"+it[255&e]+it[e>>8&255]+"-"+it[e>>16&15|64]+it[e>>24&255]+"-"+it[63&n|128]+it[n>>8&255]+"-"+it[n>>16&255]+it[n>>24&255]+it[255&r]+it[r>>8&255]+it[r>>16&255]+it[r>>24&255]).toUpperCase()}function ut(t,e,n){return Math.max(e,Math.min(n,t))}function ct(t,e){return(t%e+e)%e}function ht(t,e,n){return(1-n)*t+n*e}function pt(t){return 0==(t&t-1)&&0!==t}function ft(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function dt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var mt=Object.freeze({__proto__:null,DEG2RAD:at,RAD2DEG:st,generateUUID:lt,clamp:ut,euclideanModulo:ct,mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:ht,damp:function(t,e,n,r){return ht(t,e,1-Math.exp(-n*r))},pingpong:function(t,e=1){return e-Math.abs(ct(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(ot=t%2147483647),((ot=16807*ot%2147483647)-1)/2147483646},degToRad:function(t){return t*at},radToDeg:function(t){return t*st},isPowerOfTwo:pt,ceilPowerOfTwo:ft,floorPowerOfTwo:dt,setQuaternionFromProperEuler:function(t,e,n,r,i){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),u=o((e+r)/2),c=a((e+r)/2),h=o((e-r)/2),p=a((e-r)/2),f=o((r-e)/2),d=a((r-e)/2);switch(i){case"XYX":t.set(s*c,l*h,l*p,s*u);break;case"YZY":t.set(l*p,s*c,l*h,s*u);break;case"ZXZ":t.set(l*h,l*p,s*c,s*u);break;case"XZX":t.set(s*c,l*d,l*f,s*u);break;case"YXY":t.set(l*f,s*c,l*d,s*u);break;case"ZYZ":t.set(l*d,l*f,s*c,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}});class gt{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}gt.prototype.isVector2=!0;class yt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,i,o,a,s,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=i,u[5]=s,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],u=n[4],c=n[7],h=n[2],p=n[5],f=n[8],d=r[0],m=r[3],g=r[6],y=r[1],v=r[4],_=r[7],x=r[2],b=r[5],w=r[8];return i[0]=o*d+a*y+s*x,i[3]=o*m+a*v+s*b,i[6]=o*g+a*_+s*w,i[1]=l*d+u*y+c*x,i[4]=l*m+u*v+c*b,i[7]=l*g+u*_+c*w,i[2]=h*d+p*y+f*x,i[5]=h*m+p*v+f*b,i[8]=h*g+p*_+f*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*i*u+n*a*s+r*i*l-r*o*s}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=u*o-a*l,h=a*s-u*i,p=l*i-o*s,f=e*c+n*h+r*p;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const d=1/f;return t[0]=c*d,t[1]=(r*l-u*n)*d,t[2]=(a*n-r*o)*d,t[3]=h*d,t[4]=(u*e-r*s)*d,t[5]=(r*i-a*e)*d,t[6]=p*d,t[7]=(n*s-l*e)*d,t[8]=(o*e-n*i)*d,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,a){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*o+l*a)+o+t,-r*l,r*s,-r*(-l*o+s*a)+a+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.elements,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7];return r[0]=e*i+n*s,r[3]=e*o+n*l,r[6]=e*a+n*u,r[1]=-n*i+e*s,r[4]=-n*o+e*l,r[7]=-n*a+e*u,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let vt;yt.prototype.isMatrix3=!0;class _t{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===vt&&(vt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),vt.width=t.width,vt.height=t.height;const n=vt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=vt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let xt=0;class bt extends rt{constructor(t=bt.DEFAULT_IMAGE,e=bt.DEFAULT_MAPPING,n=1001,r=1001,i=1006,o=1008,a=1023,s=1009,l=1,u=3e3){super(),Object.defineProperty(this,"id",{value:xt++}),this.uuid=lt(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new gt(0,0),this.repeat=new gt(1,1),this.center=new gt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const r=this.image;if(void 0===r.uuid&&(r.uuid=lt()),!e&&void 0===t.images[r.uuid]){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(wt(r[t].image)):e.push(wt(r[t]))}else e=wt(r);t.images[r.uuid]={uuid:r.uuid,url:e}}n.image=r.uuid}return e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==r)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case c:t.x=t.x-Math.floor(t.x);break;case h:t.x=t.x<0?0:1;break;case p:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case c:t.y=t.y-Math.floor(t.y);break;case h:t.y=t.y<0?0:1;break;case p:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function wt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_t.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}bt.DEFAULT_IMAGE=void 0,bt.DEFAULT_MAPPING=r,bt.prototype.isTexture=!0;class Et{constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,a=t.elements,s=a[0],l=a[4],u=a[8],c=a[1],h=a[5],p=a[9],f=a[2],d=a[6],m=a[10];if(Math.abs(l-c)<o&&Math.abs(u-f)<o&&Math.abs(p-d)<o){if(Math.abs(l+c)<.1&&Math.abs(u+f)<.1&&Math.abs(p+d)<.1&&Math.abs(s+h+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const t=(s+1)/2,a=(h+1)/2,g=(m+1)/2,y=(l+c)/4,v=(u+f)/4,_=(p+d)/4;return t>a&&t>g?t<o?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(t)),i=v/n):a>g?a<o?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(a)),i=_/r):g<o?(n=.707106781,r=.707106781,i=0):(n=v/(i=Math.sqrt(g)),r=_/i),this.set(n,r,i,e),this}let g=Math.sqrt((d-p)*(d-p)+(u-f)*(u-f)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(d-p)/g,this.y=(u-f)/g,this.z=(c-l)/g,this.w=Math.acos((s+h+m-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}Et.prototype.isVector4=!0;class St extends rt{constructor(t,e,n={}){super(),this.width=t,this.height=e,this.depth=1,this.scissor=new Et(0,0,t,e),this.scissorTest=!1,this.viewport=new Et(0,0,t,e),this.texture=new bt(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:t,height:e,depth:1},this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:g,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}setTexture(t){t.image={width:this.width,height:this.height,depth:this.depth},this.texture=t}setSize(t,e,n=1){this.width===t&&this.height===e&&this.depth===n||(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}St.prototype.isWebGLRenderTarget=!0;class Mt extends St{constructor(t,e,n){super(t,e);const r=this.texture;this.texture=[];for(let t=0;t<n;t++)this.texture[t]=r.clone()}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let r=0,i=this.texture.length;r<i;r++)this.texture[r].image.width=t,this.texture[r].image.height=e,this.texture[r].image.depth=n;this.dispose()}return this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e),this}copy(t){this.dispose(),this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this.texture.length=0;for(let e=0,n=t.texture.length;e<n;e++)this.texture[e]=t.texture[e].clone();return this}}Mt.prototype.isWebGLMultipleRenderTargets=!0;class Tt extends St{constructor(t,e,n){super(t,e,n),this.samples=4}copy(t){return super.copy.call(this,t),this.samples=t.samples,this}}Tt.prototype.isWebGLMultisampleRenderTarget=!0;class Ct{constructor(t=0,e=0,n=0,r=1){this._x=t,this._y=e,this._z=n,this._w=r}static slerp(t,e,n,r){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(t,e,r)}static slerpFlat(t,e,n,r,i,o,a){let s=n[r+0],l=n[r+1],u=n[r+2],c=n[r+3];const h=i[o+0],p=i[o+1],f=i[o+2],d=i[o+3];if(0===a)return t[e+0]=s,t[e+1]=l,t[e+2]=u,void(t[e+3]=c);if(1===a)return t[e+0]=h,t[e+1]=p,t[e+2]=f,void(t[e+3]=d);if(c!==d||s!==h||l!==p||u!==f){let t=1-a;const e=s*h+l*p+u*f+c*d,n=e>=0?1:-1,r=1-e*e;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,e*n);t=Math.sin(t*o)/i,a=Math.sin(a*o)/i}const i=a*n;if(s=s*t+h*i,l=l*t+p*i,u=u*t+f*i,c=c*t+d*i,t===1-a){const t=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=t,l*=t,u*=t,c*=t}}t[e]=s,t[e+1]=l,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,n,r,i,o){const a=n[r],s=n[r+1],l=n[r+2],u=n[r+3],c=i[o],h=i[o+1],p=i[o+2],f=i[o+3];return t[e]=a*f+u*c+s*p-l*h,t[e+1]=s*f+u*h+l*c-a*p,t[e+2]=l*f+u*p+a*h-s*c,t[e+3]=u*f-a*c-s*h-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,i=t._z,o=t._order,a=Math.cos,s=Math.sin,l=a(n/2),u=a(r/2),c=a(i/2),h=s(n/2),p=s(r/2),f=s(i/2);switch(o){case"XYZ":this._x=h*u*c+l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c-h*p*f;break;case"YXZ":this._x=h*u*c+l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c+h*p*f;break;case"ZXY":this._x=h*u*c-l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c-h*p*f;break;case"ZYX":this._x=h*u*c-l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c+h*p*f;break;case"YZX":this._x=h*u*c+l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c-h*p*f;break;case"XZY":this._x=h*u*c-l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c+h*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],a=e[5],s=e[9],l=e[2],u=e[6],c=e[10],h=n+a+c;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-s)*t,this._y=(i-l)*t,this._z=(o-r)*t}else if(n>a&&n>c){const t=2*Math.sqrt(1+n-a-c);this._w=(u-s)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-n-c);this._w=(i-l)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(s+u)/t}else{const t=2*Math.sqrt(1+c-n-a);this._w=(o-r)/t,this._x=(i+l)/t,this._y=(s+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ut(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+r*l-i*s,this._y=r*u+o*s+i*a-n*l,this._z=i*u+o*l+n*s-r*a,this._w=o*u-n*a-r*s-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,r=this._y,i=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const s=1-a*a;if(s<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*n+e*this._x,this._y=t*r+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),u=Math.atan2(l,a),c=Math.sin((1-e)*u)/l,h=Math.sin(e*u)/l;return this._w=o*c+this._w*h,this._x=n*c+this._x*h,this._y=r*c+this._y*h,this._z=i*c+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Ct.prototype.isQuaternion=!0;class It{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Lt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Lt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*r-a*n,u=s*n+a*e-i*r,c=s*r+i*n-o*e,h=-i*e-o*n-a*r;return this.x=l*s+h*-i+u*-a-c*-o,this.y=u*s+h*-o+c*-i-l*-a,this.z=c*s+h*-a+l*-o-u*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return At.copy(this).projectOnVector(t),this.sub(At)}reflect(t){return this.sub(At.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ut(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}It.prototype.isVector3=!0;const At=new It,Lt=new Ct;class Pt{constructor(t=new It(1/0,1/0,1/0),e=new It(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.length;s<l;s+=3){const l=t[s],u=t[s+1],c=t[s+2];l<e&&(e=l),u<n&&(n=u),c<r&&(r=c),l>i&&(i=l),u>o&&(o=u),c>a&&(a=c)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromBufferAttribute(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.count;s<l;s++){const l=t.getX(s),u=t.getY(s),c=t.getZ(s);l<e&&(e=l),u<n&&(n=u),c<r&&(r=c),l>i&&(i=l),u>o&&(o=u),c>a&&(a=c)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Dt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);const e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),Nt.copy(e.boundingBox),Nt.applyMatrix4(t.matrixWorld),this.union(Nt));const n=t.children;for(let t=0,e=n.length;t<e;t++)this.expandByObject(n[t]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Dt),Dt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Vt),Gt.subVectors(this.max,Vt),Ot.subVectors(t.a,Vt),kt.subVectors(t.b,Vt),zt.subVectors(t.c,Vt),Ft.subVectors(kt,Ot),Bt.subVectors(zt,kt),Ut.subVectors(Ot,zt);let e=[0,-Ft.z,Ft.y,0,-Bt.z,Bt.y,0,-Ut.z,Ut.y,Ft.z,0,-Ft.x,Bt.z,0,-Bt.x,Ut.z,0,-Ut.x,-Ft.y,Ft.x,0,-Bt.y,Bt.x,0,-Ut.y,Ut.x,0];return!!qt(e,Ot,kt,zt,Gt)&&!!qt(e=[1,0,0,0,1,0,0,0,1],Ot,kt,zt,Gt)&&(jt.crossVectors(Ft,Bt),qt(e=[jt.x,jt.y,jt.z],Ot,kt,zt,Gt))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Dt.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Dt).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Rt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Rt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Rt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Rt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Rt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Rt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Rt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Rt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Rt)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Pt.prototype.isBox3=!0;const Rt=[new It,new It,new It,new It,new It,new It,new It,new It],Dt=new It,Nt=new Pt,Ot=new It,kt=new It,zt=new It,Ft=new It,Bt=new It,Ut=new It,Vt=new It,Gt=new It,jt=new It,Ht=new It;function qt(t,e,n,r,i){for(let o=0,a=t.length-3;o<=a;o+=3){Ht.fromArray(t,o);const a=i.x*Math.abs(Ht.x)+i.y*Math.abs(Ht.y)+i.z*Math.abs(Ht.z),s=e.dot(Ht),l=n.dot(Ht),u=r.dot(Ht);if(Math.max(-Math.max(s,l,u),Math.min(s,l,u))>a)return!1}return!0}const Wt=new Pt,Xt=new It,Zt=new It,Yt=new It;class Jt{constructor(t=new It,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Wt.setFromPoints(t).getCenter(n);let r=0;for(let e=0,i=t.length;e<i;e++)r=Math.max(r,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Yt.subVectors(t,this.center);const e=Yt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(Yt.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return Zt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Xt.copy(t.center).add(Zt)),this.expandByPoint(Xt.copy(t.center).sub(Zt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Kt=new It,Qt=new It,$t=new It,te=new It,ee=new It,ne=new It,re=new It;class ie{constructor(t=new It,e=new It(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Kt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Kt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Kt.copy(this.direction).multiplyScalar(e).add(this.origin),Kt.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Qt.copy(t).add(e).multiplyScalar(.5),$t.copy(e).sub(t).normalize(),te.copy(this.origin).sub(Qt);const i=.5*t.distanceTo(e),o=-this.direction.dot($t),a=te.dot(this.direction),s=-te.dot($t),l=te.lengthSq(),u=Math.abs(1-o*o);let c,h,p,f;if(u>0)if(h=o*a-s,f=i*u,(c=o*s-a)>=0)if(h>=-f)if(h<=f){const t=1/u;p=(c*=t)*(c+o*(h*=t)+2*a)+h*(o*c+h+2*s)+l}else h=i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;else h=-i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;else h<=-f?p=-(c=Math.max(0,-(-o*i+a)))*c+(h=c>0?-i:Math.min(Math.max(-i,-s),i))*(h+2*s)+l:h<=f?(c=0,p=(h=Math.min(Math.max(-i,-s),i))*(h+2*s)+l):p=-(c=Math.max(0,-(o*i+a)))*c+(h=c>0?i:Math.min(Math.max(-i,-s),i))*(h+2*s)+l;else h=o>0?-i:i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(c).add(this.origin),r&&r.copy($t).multiplyScalar(h).add(Qt),p}intersectSphere(t,e){Kt.subVectors(t.center,this.origin);const n=Kt.dot(this.direction),r=Kt.dot(Kt)-n*n,i=t.radius*t.radius;if(r>i)return null;const o=Math.sqrt(i-r),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,i,o,a,s;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(t.min.x-h.x)*l,r=(t.max.x-h.x)*l):(n=(t.max.x-h.x)*l,r=(t.min.x-h.x)*l),u>=0?(i=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),c>=0?(a=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(a=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,e)))}intersectsBox(t){return null!==this.intersectBox(t,Kt)}intersectTriangle(t,e,n,r,i){ee.subVectors(e,t),ne.subVectors(n,t),re.crossVectors(ee,ne);let o,a=this.direction.dot(re);if(a>0){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}te.subVectors(this.origin,t);const s=o*this.direction.dot(ne.crossVectors(te,ne));if(s<0)return null;const l=o*this.direction.dot(ee.cross(te));if(l<0)return null;if(s+l>a)return null;const u=-o*te.dot(re);return u<0?null:this.at(u/a,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class oe{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new oe).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/ae.setFromMatrixColumn(t,0).length(),i=1/ae.setFromMatrixColumn(t,1).length(),o=1/ae.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),u=Math.cos(i),c=Math.sin(i);if("XYZ"===t.order){const t=o*u,n=o*c,r=a*u,i=a*c;e[0]=s*u,e[4]=-s*c,e[8]=l,e[1]=n+r*l,e[5]=t-i*l,e[9]=-a*s,e[2]=i-t*l,e[6]=r+n*l,e[10]=o*s}else if("YXZ"===t.order){const t=s*u,n=s*c,r=l*u,i=l*c;e[0]=t+i*a,e[4]=r*a-n,e[8]=o*l,e[1]=o*c,e[5]=o*u,e[9]=-a,e[2]=n*a-r,e[6]=i+t*a,e[10]=o*s}else if("ZXY"===t.order){const t=s*u,n=s*c,r=l*u,i=l*c;e[0]=t-i*a,e[4]=-o*c,e[8]=r+n*a,e[1]=n+r*a,e[5]=o*u,e[9]=i-t*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){const t=o*u,n=o*c,r=a*u,i=a*c;e[0]=s*u,e[4]=r*l-n,e[8]=t*l+i,e[1]=s*c,e[5]=i*l+t,e[9]=n*l-r,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*u,e[4]=i-t*c,e[8]=r*c+n,e[1]=c,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=n*c+r,e[10]=t-i*c}else if("XZY"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*u,e[4]=-c,e[8]=l*u,e[1]=t*c+i,e[5]=o*u,e[9]=n*c-r,e[2]=r*c-n,e[6]=a*u,e[10]=i*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(le,t,ue)}lookAt(t,e,n){const r=this.elements;return pe.subVectors(t,e),0===pe.lengthSq()&&(pe.z=1),pe.normalize(),ce.crossVectors(n,pe),0===ce.lengthSq()&&(1===Math.abs(n.z)?pe.x+=1e-4:pe.z+=1e-4,pe.normalize(),ce.crossVectors(n,pe)),ce.normalize(),he.crossVectors(pe,ce),r[0]=ce.x,r[4]=he.x,r[8]=pe.x,r[1]=ce.y,r[5]=he.y,r[9]=pe.y,r[2]=ce.z,r[6]=he.z,r[10]=pe.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],u=n[1],c=n[5],h=n[9],p=n[13],f=n[2],d=n[6],m=n[10],g=n[14],y=n[3],v=n[7],_=n[11],x=n[15],b=r[0],w=r[4],E=r[8],S=r[12],M=r[1],T=r[5],C=r[9],I=r[13],A=r[2],L=r[6],P=r[10],R=r[14],D=r[3],N=r[7],O=r[11],k=r[15];return i[0]=o*b+a*M+s*A+l*D,i[4]=o*w+a*T+s*L+l*N,i[8]=o*E+a*C+s*P+l*O,i[12]=o*S+a*I+s*R+l*k,i[1]=u*b+c*M+h*A+p*D,i[5]=u*w+c*T+h*L+p*N,i[9]=u*E+c*C+h*P+p*O,i[13]=u*S+c*I+h*R+p*k,i[2]=f*b+d*M+m*A+g*D,i[6]=f*w+d*T+m*L+g*N,i[10]=f*E+d*C+m*P+g*O,i[14]=f*S+d*I+m*R+g*k,i[3]=y*b+v*M+_*A+x*D,i[7]=y*w+v*T+_*L+x*N,i[11]=y*E+v*C+_*P+x*O,i[15]=y*S+v*I+_*R+x*k,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],a=t[5],s=t[9],l=t[13],u=t[2],c=t[6],h=t[10],p=t[14];return t[3]*(+i*s*c-r*l*c-i*a*h+n*l*h+r*a*p-n*s*p)+t[7]*(+e*s*p-e*l*h+i*o*h-r*o*p+r*l*u-i*s*u)+t[11]*(+e*l*c-e*a*p-i*o*c+n*o*p+i*a*u-n*l*u)+t[15]*(-r*a*u-e*s*c+e*a*h+r*o*c-n*o*h+n*s*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11],f=t[12],d=t[13],m=t[14],g=t[15],y=c*m*l-d*h*l+d*s*p-a*m*p-c*s*g+a*h*g,v=f*h*l-u*m*l-f*s*p+o*m*p+u*s*g-o*h*g,_=u*d*l-f*c*l+f*a*p-o*d*p-u*a*g+o*c*g,x=f*c*s-u*d*s-f*a*h+o*d*h+u*a*m-o*c*m,b=e*y+n*v+r*_+i*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return t[0]=y*w,t[1]=(d*h*i-c*m*i-d*r*p+n*m*p+c*r*g-n*h*g)*w,t[2]=(a*m*i-d*s*i+d*r*l-n*m*l-a*r*g+n*s*g)*w,t[3]=(c*s*i-a*h*i-c*r*l+n*h*l+a*r*p-n*s*p)*w,t[4]=v*w,t[5]=(u*m*i-f*h*i+f*r*p-e*m*p-u*r*g+e*h*g)*w,t[6]=(f*s*i-o*m*i-f*r*l+e*m*l+o*r*g-e*s*g)*w,t[7]=(o*h*i-u*s*i+u*r*l-e*h*l-o*r*p+e*s*p)*w,t[8]=_*w,t[9]=(f*c*i-u*d*i-f*n*p+e*d*p+u*n*g-e*c*g)*w,t[10]=(o*d*i-f*a*i+f*n*l-e*d*l-o*n*g+e*a*g)*w,t[11]=(u*a*i-o*c*i-u*n*l+e*c*l+o*n*p-e*a*p)*w,t[12]=x*w,t[13]=(u*d*r-f*c*r+f*n*h-e*d*h-u*n*m+e*c*m)*w,t[14]=(f*a*r-o*d*r-f*n*s+e*d*s+o*n*m-e*a*m)*w,t[15]=(o*c*r-u*a*r+u*n*s-e*c*s-o*n*h+e*a*h)*w,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,a=t.y,s=t.z,l=i*o,u=i*a;return this.set(l*o+n,l*a-r*s,l*s+r*a,0,l*a+r*s,u*a+n,u*s-r*o,0,l*s-r*a,u*s+r*o,i*s*s+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,a=e._z,s=e._w,l=i+i,u=o+o,c=a+a,h=i*l,p=i*u,f=i*c,d=o*u,m=o*c,g=a*c,y=s*l,v=s*u,_=s*c,x=n.x,b=n.y,w=n.z;return r[0]=(1-(d+g))*x,r[1]=(p+_)*x,r[2]=(f-v)*x,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(h+g))*b,r[6]=(m+y)*b,r[7]=0,r[8]=(f+v)*w,r[9]=(m-y)*w,r[10]=(1-(h+d))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let i=ae.set(r[0],r[1],r[2]).length();const o=ae.set(r[4],r[5],r[6]).length(),a=ae.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],se.copy(this);const s=1/i,l=1/o,u=1/a;return se.elements[0]*=s,se.elements[1]*=s,se.elements[2]*=s,se.elements[4]*=l,se.elements[5]*=l,se.elements[6]*=l,se.elements[8]*=u,se.elements[9]*=u,se.elements[10]*=u,e.setFromRotationMatrix(se),n.x=i,n.y=o,n.z=a,this}makePerspective(t,e,n,r,i,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,s=2*i/(e-t),l=2*i/(n-r),u=(e+t)/(e-t),c=(n+r)/(n-r),h=-(o+i)/(o-i),p=-2*o*i/(o-i);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=h,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,n,r,i,o){const a=this.elements,s=1/(e-t),l=1/(n-r),u=1/(o-i),c=(e+t)*s,h=(n+r)*l,p=(o+i)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-h,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}oe.prototype.isMatrix4=!0;const ae=new It,se=new oe,le=new It(0,0,0),ue=new It(1,1,1),ce=new It,he=new It,pe=new It,fe=new oe,de=new Ct;class me{constructor(t=0,e=0,n=0,r=me.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],u=r[9],c=r[2],h=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(ut(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ut(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(ut(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-ut(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ut(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-ut(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return fe.makeRotationFromQuaternion(t),this.setFromRotationMatrix(fe,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return de.setFromEuler(this),this.setFromQuaternion(de,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new It(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}me.prototype.isEuler=!0,me.DefaultOrder="XYZ",me.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ge{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}}let ye=0;const ve=new It,_e=new Ct,xe=new oe,be=new It,we=new It,Ee=new It,Se=new Ct,Me=new It(1,0,0),Te=new It(0,1,0),Ce=new It(0,0,1),Ie={type:"added"},Ae={type:"removed"};class Le extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:ye++}),this.uuid=lt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Le.DefaultUp.clone();const t=new It,e=new me,n=new Ct,r=new It(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new oe},normalMatrix:{value:new yt}}),this.matrix=new oe,this.matrixWorld=new oe,this.matrixAutoUpdate=Le.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new ge,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return _e.setFromAxisAngle(t,e),this.quaternion.multiply(_e),this}rotateOnWorldAxis(t,e){return _e.setFromAxisAngle(t,e),this.quaternion.premultiply(_e),this}rotateX(t){return this.rotateOnAxis(Me,t)}rotateY(t){return this.rotateOnAxis(Te,t)}rotateZ(t){return this.rotateOnAxis(Ce,t)}translateOnAxis(t,e){return ve.copy(t).applyQuaternion(this.quaternion),this.position.add(ve.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Me,t)}translateY(t){return this.translateOnAxis(Te,t)}translateZ(t){return this.translateOnAxis(Ce,t)}localToWorld(t){return t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return t.applyMatrix4(xe.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?be.copy(t):be.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),we.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xe.lookAt(we,be,this.up):xe.lookAt(be,we,this.up),this.quaternion.setFromRotationMatrix(xe),r&&(xe.extractRotation(r.matrixWorld),_e.setFromRotationMatrix(xe),this.quaternion.premultiply(_e.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Ie)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ae)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(Ae)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),xe.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),xe.multiply(t.parent.matrixWorld)),t.applyMatrix4(xe),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(t,e);if(void 0!==r)return r}}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,t,Ee),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,Se,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++)t[e].updateWorldMatrix(!1,!0)}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const r=n[e];i(t.shapes,r)}else i(t.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,r=this.material.length;n<r;n++)e.push(i(t.materials,this.material[n]));r.material=e}else r.material=i(t.materials,this.material);if(this.children.length>0){r.children=[];for(let e=0;e<this.children.length;e++)r.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];r.animations.push(i(t.animations,n))}}if(e){const e=o(t.geometries),r=o(t.materials),i=o(t.textures),a=o(t.images),s=o(t.shapes),l=o(t.skeletons),u=o(t.animations);e.length>0&&(n.geometries=e),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u)}return n.object=r,n;function o(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Le.DefaultUp=new It(0,1,0),Le.DefaultMatrixAutoUpdate=!0,Le.prototype.isObject3D=!0;const Pe=new It,Re=new It,De=new It,Ne=new It,Oe=new It,ke=new It,ze=new It,Fe=new It,Be=new It,Ue=new It;class Ve{constructor(t=new It,e=new It,n=new It){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Pe.subVectors(t,e),r.cross(Pe);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(t,e,n,r,i){Pe.subVectors(r,e),Re.subVectors(n,e),De.subVectors(t,e);const o=Pe.dot(Pe),a=Pe.dot(Re),s=Pe.dot(De),l=Re.dot(Re),u=Re.dot(De),c=o*l-a*a;if(0===c)return i.set(-2,-1,-1);const h=1/c,p=(l*s-a*u)*h,f=(o*u-a*s)*h;return i.set(1-p-f,f,p)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,Ne),Ne.x>=0&&Ne.y>=0&&Ne.x+Ne.y<=1}static getUV(t,e,n,r,i,o,a,s){return this.getBarycoord(t,e,n,r,Ne),s.set(0,0),s.addScaledVector(i,Ne.x),s.addScaledVector(o,Ne.y),s.addScaledVector(a,Ne.z),s}static isFrontFacing(t,e,n,r){return Pe.subVectors(n,e),Re.subVectors(t,e),Pe.cross(Re).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Pe.subVectors(this.c,this.b),Re.subVectors(this.a,this.b),.5*Pe.cross(Re).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,r,i){return Ve.getUV(t,this.a,this.b,this.c,e,n,r,i)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,i=this.c;let o,a;Oe.subVectors(r,n),ke.subVectors(i,n),Fe.subVectors(t,n);const s=Oe.dot(Fe),l=ke.dot(Fe);if(s<=0&&l<=0)return e.copy(n);Be.subVectors(t,r);const u=Oe.dot(Be),c=ke.dot(Be);if(u>=0&&c<=u)return e.copy(r);const h=s*c-u*l;if(h<=0&&s>=0&&u<=0)return o=s/(s-u),e.copy(n).addScaledVector(Oe,o);Ue.subVectors(t,i);const p=Oe.dot(Ue),f=ke.dot(Ue);if(f>=0&&p<=f)return e.copy(i);const d=p*l-s*f;if(d<=0&&l>=0&&f<=0)return a=l/(l-f),e.copy(n).addScaledVector(ke,a);const m=u*f-p*c;if(m<=0&&c-u>=0&&p-f>=0)return ze.subVectors(i,r),a=(c-u)/(c-u+(p-f)),e.copy(r).addScaledVector(ze,a);const g=1/(m+d+h);return o=d*g,a=h*g,e.copy(n).addScaledVector(Oe,o).addScaledVector(ke,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Ge=0;class je extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:Ge++}),this.uuid=lt(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=T,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(n.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(n.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(n.specularTintMap=this.specularTintMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(n.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.format!==T&&(n.format=this.format),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=r(t.textures),i=r(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let r=0;r!==t;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}je.prototype.isMaterial=!0;const He={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},qe={h:0,s:0,l:0},We={h:0,s:0,l:0};function Xe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function Ze(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Ye(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Je{constructor(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,n){return this.r=t,this.g=e,this.b=n,this}setHSL(t,e,n){if(t=ct(t,1),e=ut(e,0,1),n=ut(n,0,1),0===e)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Xe(i,r,t+1/3),this.g=Xe(i,r,t),this.b=Xe(i,r,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const r=n[1],i=n[2];switch(r){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const n=parseFloat(t[1])/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(n,r,i)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=He[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Ze(t.r),this.g=Ze(t.g),this.b=Ze(t.b),this}copyLinearToSRGB(t){return this.r=Ye(t.r),this.g=Ye(t.g),this.b=Ye(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){const e=this.r,n=this.g,r=this.b,i=Math.max(e,n,r),o=Math.min(e,n,r);let a,s;const l=(o+i)/2;if(o===i)a=0,s=0;else{const t=i-o;switch(s=l<=.5?t/(i+o):t/(2-i-o),i){case e:a=(n-r)/t+(n<r?6:0);break;case n:a=(r-e)/t+2;break;case r:a=(e-n)/t+4}a/=6}return t.h=a,t.s=s,t.l=l,t}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(t,e,n){return this.getHSL(qe),qe.h+=t,qe.s+=e,qe.l+=n,this.setHSL(qe.h,qe.s,qe.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(qe),t.getHSL(We);const n=ht(qe.h,We.h,e),r=ht(qe.s,We.s,e),i=ht(qe.l,We.l,e);return this.setHSL(n,r,i),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}Je.NAMES=He,Je.prototype.isColor=!0,Je.prototype.r=1,Je.prototype.g=1,Je.prototype.b=1;class Ke extends je{constructor(t){super(),this.type="MeshBasicMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Ke.prototype.isMeshBasicMaterial=!0;const Qe=new It,$e=new gt;class tn{constructor(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}copyColorsArray(t){const e=this.array;let n=0;for(let r=0,i=t.length;r<i;r++){let i=t[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new Je),e[n++]=i.r,e[n++]=i.g,e[n++]=i.b}return this}copyVector2sArray(t){const e=this.array;let n=0;for(let r=0,i=t.length;r<i;r++){let i=t[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new gt),e[n++]=i.x,e[n++]=i.y}return this}copyVector3sArray(t){const e=this.array;let n=0;for(let r=0,i=t.length;r<i;r++){let i=t[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new It),e[n++]=i.x,e[n++]=i.y,e[n++]=i.z}return this}copyVector4sArray(t){const e=this.array;let n=0;for(let r=0,i=t.length;r<i;r++){let i=t[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new Et),e[n++]=i.x,e[n++]=i.y,e[n++]=i.z,e[n++]=i.w}return this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)$e.fromBufferAttribute(this,e),$e.applyMatrix3(t),this.setXY(e,$e.x,$e.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)Qe.fromBufferAttribute(this,e),Qe.applyMatrix3(t),this.setXYZ(e,Qe.x,Qe.y,Qe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Qe.x=this.getX(e),Qe.y=this.getY(e),Qe.z=this.getZ(e),Qe.applyMatrix4(t),this.setXYZ(e,Qe.x,Qe.y,Qe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Qe.x=this.getX(e),Qe.y=this.getY(e),Qe.z=this.getZ(e),Qe.applyNormalMatrix(t),this.setXYZ(e,Qe.x,Qe.y,Qe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Qe.x=this.getX(e),Qe.y=this.getY(e),Qe.z=this.getZ(e),Qe.transformDirection(t),this.setXYZ(e,Qe.x,Qe.y,Qe.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){return this.array[t*this.itemSize]}setX(t,e){return this.array[t*this.itemSize]=e,this}getY(t){return this.array[t*this.itemSize+1]}setY(t,e){return this.array[t*this.itemSize+1]=e,this}getZ(t){return this.array[t*this.itemSize+2]}setZ(t,e){return this.array[t*this.itemSize+2]=e,this}getW(t){return this.array[t*this.itemSize+3]}setW(t,e){return this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=i,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==tt&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}}tn.prototype.isBufferAttribute=!0;class en extends tn{constructor(t,e,n){super(new Int8Array(t),e,n)}}class nn extends tn{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class rn extends tn{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class on extends tn{constructor(t,e,n){super(new Int16Array(t),e,n)}}class an extends tn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class sn extends tn{constructor(t,e,n){super(new Int32Array(t),e,n)}}class ln extends tn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class un extends tn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}un.prototype.isFloat16BufferAttribute=!0;class cn extends tn{constructor(t,e,n){super(new Float32Array(t),e,n)}}class hn extends tn{constructor(t,e,n){super(new Float64Array(t),e,n)}}function pn(t){if(0===t.length)return-1/0;let e=t[0];for(let n=1,r=t.length;n<r;++n)t[n]>e&&(e=t[n]);return e}const fn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function dn(t,e){return new fn[t](e)}let mn=0;const gn=new oe,yn=new Le,vn=new It,_n=new Pt,xn=new Pt,bn=new It;class wn extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:mn++}),this.uuid=lt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(pn(t)>65535?ln:an)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new yt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return gn.makeRotationFromQuaternion(t),this.applyMatrix4(gn),this}rotateX(t){return gn.makeRotationX(t),this.applyMatrix4(gn),this}rotateY(t){return gn.makeRotationY(t),this.applyMatrix4(gn),this}rotateZ(t){return gn.makeRotationZ(t),this.applyMatrix4(gn),this}translate(t,e,n){return gn.makeTranslation(t,e,n),this.applyMatrix4(gn),this}scale(t,e,n){return gn.makeScale(t,e,n),this.applyMatrix4(gn),this}lookAt(t){return yn.lookAt(t),yn.updateMatrix(),this.applyMatrix4(yn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vn).negate(),this.translate(vn.x,vn.y,vn.z),this}setFromPoints(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new cn(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new It(-1/0,-1/0,-1/0),new It(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];_n.setFromBufferAttribute(n),this.morphTargetsRelative?(bn.addVectors(this.boundingBox.min,_n.min),this.boundingBox.expandByPoint(bn),bn.addVectors(this.boundingBox.max,_n.max),this.boundingBox.expandByPoint(bn)):(this.boundingBox.expandByPoint(_n.min),this.boundingBox.expandByPoint(_n.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Jt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new It,1/0);if(t){const n=this.boundingSphere.center;if(_n.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];xn.setFromBufferAttribute(n),this.morphTargetsRelative?(bn.addVectors(_n.min,xn.min),_n.expandByPoint(bn),bn.addVectors(_n.max,xn.max),_n.expandByPoint(bn)):(_n.expandByPoint(xn.min),_n.expandByPoint(xn.max))}_n.getCenter(n);let r=0;for(let e=0,i=t.count;e<i;e++)bn.fromBufferAttribute(t,e),r=Math.max(r,n.distanceToSquared(bn));if(e)for(let i=0,o=e.length;i<o;i++){const o=e[i],a=this.morphTargetsRelative;for(let e=0,i=o.count;e<i;e++)bn.fromBufferAttribute(o,e),a&&(vn.fromBufferAttribute(t,e),bn.add(vn)),r=Math.max(r,n.distanceToSquared(bn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.array,r=e.position.array,i=e.normal.array,o=e.uv.array,a=r.length/3;void 0===e.tangent&&this.setAttribute("tangent",new tn(new Float32Array(4*a),4));const s=e.tangent.array,l=[],u=[];for(let t=0;t<a;t++)l[t]=new It,u[t]=new It;const c=new It,h=new It,p=new It,f=new gt,d=new gt,m=new gt,g=new It,y=new It;function v(t,e,n){c.fromArray(r,3*t),h.fromArray(r,3*e),p.fromArray(r,3*n),f.fromArray(o,2*t),d.fromArray(o,2*e),m.fromArray(o,2*n),h.sub(c),p.sub(c),d.sub(f),m.sub(f);const i=1/(d.x*m.y-m.x*d.y);isFinite(i)&&(g.copy(h).multiplyScalar(m.y).addScaledVector(p,-d.y).multiplyScalar(i),y.copy(p).multiplyScalar(d.x).addScaledVector(h,-m.x).multiplyScalar(i),l[t].add(g),l[e].add(g),l[n].add(g),u[t].add(y),u[e].add(y),u[n].add(y))}let _=this.groups;0===_.length&&(_=[{start:0,count:n.length}]);for(let t=0,e=_.length;t<e;++t){const e=_[t],r=e.start;for(let t=r,i=r+e.count;t<i;t+=3)v(n[t+0],n[t+1],n[t+2])}const x=new It,b=new It,w=new It,E=new It;function S(t){w.fromArray(i,3*t),E.copy(w);const e=l[t];x.copy(e),x.sub(w.multiplyScalar(w.dot(e))).normalize(),b.crossVectors(E,e);const n=b.dot(u[t])<0?-1:1;s[4*t]=x.x,s[4*t+1]=x.y,s[4*t+2]=x.z,s[4*t+3]=n}for(let t=0,e=_.length;t<e;++t){const e=_[t],r=e.start;for(let t=r,i=r+e.count;t<i;t+=3)S(n[t+0]),S(n[t+1]),S(n[t+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new tn(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const r=new It,i=new It,o=new It,a=new It,s=new It,l=new It,u=new It,c=new It;if(t)for(let h=0,p=t.count;h<p;h+=3){const p=t.getX(h+0),f=t.getX(h+1),d=t.getX(h+2);r.fromBufferAttribute(e,p),i.fromBufferAttribute(e,f),o.fromBufferAttribute(e,d),u.subVectors(o,i),c.subVectors(r,i),u.cross(c),a.fromBufferAttribute(n,p),s.fromBufferAttribute(n,f),l.fromBufferAttribute(n,d),a.add(u),s.add(u),l.add(u),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,s.x,s.y,s.z),n.setXYZ(d,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)r.fromBufferAttribute(e,t+0),i.fromBufferAttribute(e,t+1),o.fromBufferAttribute(e,t+2),u.subVectors(o,i),c.subVectors(r,i),u.cross(c),n.setXYZ(t+0,u.x,u.y,u.z),n.setXYZ(t+1,u.x,u.y,u.z),n.setXYZ(t+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const n=this.attributes;for(const r in n){if(void 0===t.attributes[r])continue;const i=n[r].array,o=t.attributes[r],a=o.array,s=o.itemSize*e,l=Math.min(a.length,i.length-s);for(let t=0,e=s;t<l;t++,e++)i[e]=a[t]}return this}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)bn.fromBufferAttribute(t,e),bn.normalize(),t.setXYZ(e,bn.x,bn.y,bn.z)}toNonIndexed(){function t(t,e){const n=t.array,r=t.itemSize,i=t.normalized,o=new n.constructor(e.length*r);let a=0,s=0;for(let i=0,l=e.length;i<l;i++){a=t.isInterleavedBufferAttribute?e[i]*t.data.stride+t.offset:e[i]*r;for(let t=0;t<r;t++)o[s++]=n[a++]}return new tn(o,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new wn,n=this.index.array,r=this.attributes;for(const i in r){const o=t(r[i],n);e.setAttribute(i,o)}const i=this.morphAttributes;for(const r in i){const o=[],a=i[r];for(let e=0,r=a.length;e<r;e++){const r=t(a[e],n);o.push(r)}e.morphAttributes[r]=o}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let t=0,n=o.length;t<n;t++){const n=o[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const r=n[e];t.data.attributes[e]=r.toJSON(t.data)}const r={};let i=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],o=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];o.push(r.toJSON(t.data))}o.length>0&&(r[e]=o,i=!0)}i&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new wn).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const r=t.attributes;for(const t in r){const n=r[t];this.setAttribute(t,n.clone(e))}const i=t.morphAttributes;for(const t in i){const n=[],r=i[t];for(let t=0,i=r.length;t<i;t++)n.push(r[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let t=0,e=o.length;t<e;t++){const e=o[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=t.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}wn.prototype.isBufferGeometry=!0;const En=new oe,Sn=new ie,Mn=new Jt,Tn=new It,Cn=new It,In=new It,An=new It,Ln=new It,Pn=new It,Rn=new It,Dn=new It,Nn=new It,On=new gt,kn=new gt,zn=new gt,Fn=new It,Bn=new It;class Un extends Le{constructor(t=new wn,e=new Ke){super(),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t){return super.copy(t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Mn.copy(n.boundingSphere),Mn.applyMatrix4(i),!1===t.ray.intersectsSphere(Mn))return;if(En.copy(i).invert(),Sn.copy(t.ray).applyMatrix4(En),null!==n.boundingBox&&!1===Sn.intersectsBox(n.boundingBox))return;let o;if(n.isBufferGeometry){const i=n.index,a=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,u=n.attributes.uv,c=n.attributes.uv2,h=n.groups,p=n.drawRange;if(null!==i)if(Array.isArray(r))for(let n=0,f=h.length;n<f;n++){const f=h[n],d=r[f.materialIndex];for(let n=Math.max(f.start,p.start),r=Math.min(f.start+f.count,p.start+p.count);n<r;n+=3){const r=i.getX(n),h=i.getX(n+1),p=i.getX(n+2);(o=Vn(this,d,t,Sn,a,s,l,u,c,r,h,p))&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=f.materialIndex,e.push(o))}}else for(let n=Math.max(0,p.start),h=Math.min(i.count,p.start+p.count);n<h;n+=3){const h=i.getX(n),p=i.getX(n+1),f=i.getX(n+2);(o=Vn(this,r,t,Sn,a,s,l,u,c,h,p,f))&&(o.faceIndex=Math.floor(n/3),e.push(o))}else if(void 0!==a)if(Array.isArray(r))for(let n=0,i=h.length;n<i;n++){const i=h[n],f=r[i.materialIndex];for(let n=Math.max(i.start,p.start),r=Math.min(i.start+i.count,p.start+p.count);n<r;n+=3)(o=Vn(this,f,t,Sn,a,s,l,u,c,n,n+1,n+2))&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,e.push(o))}else for(let n=Math.max(0,p.start),i=Math.min(a.count,p.start+p.count);n<i;n+=3)(o=Vn(this,r,t,Sn,a,s,l,u,c,n,n+1,n+2))&&(o.faceIndex=Math.floor(n/3),e.push(o))}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}function Vn(t,e,n,r,i,o,a,s,l,u,c,h){Tn.fromBufferAttribute(i,u),Cn.fromBufferAttribute(i,c),In.fromBufferAttribute(i,h);const p=t.morphTargetInfluences;if(o&&p){Rn.set(0,0,0),Dn.set(0,0,0),Nn.set(0,0,0);for(let t=0,e=o.length;t<e;t++){const e=p[t],n=o[t];0!==e&&(An.fromBufferAttribute(n,u),Ln.fromBufferAttribute(n,c),Pn.fromBufferAttribute(n,h),a?(Rn.addScaledVector(An,e),Dn.addScaledVector(Ln,e),Nn.addScaledVector(Pn,e)):(Rn.addScaledVector(An.sub(Tn),e),Dn.addScaledVector(Ln.sub(Cn),e),Nn.addScaledVector(Pn.sub(In),e)))}Tn.add(Rn),Cn.add(Dn),In.add(Nn)}t.isSkinnedMesh&&(t.boneTransform(u,Tn),t.boneTransform(c,Cn),t.boneTransform(h,In));const f=function(t,e,n,r,i,o,a,s){let l;if(null===(l=1===e.side?r.intersectTriangle(a,o,i,!0,s):r.intersectTriangle(i,o,a,2!==e.side,s)))return null;Bn.copy(s),Bn.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Bn);return u<n.near||u>n.far?null:{distance:u,point:Bn.clone(),object:t}}(t,e,n,r,Tn,Cn,In,Fn);if(f){s&&(On.fromBufferAttribute(s,u),kn.fromBufferAttribute(s,c),zn.fromBufferAttribute(s,h),f.uv=Ve.getUV(Fn,Tn,Cn,In,On,kn,zn,new gt)),l&&(On.fromBufferAttribute(l,u),kn.fromBufferAttribute(l,c),zn.fromBufferAttribute(l,h),f.uv2=Ve.getUV(Fn,Tn,Cn,In,On,kn,zn,new gt));const t={a:u,b:c,c:h,normal:new It,materialIndex:0};Ve.getNormal(Tn,Cn,In,t.normal),f.face=t}return f}Un.prototype.isMesh=!0;class Gn extends wn{constructor(t=1,e=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const a=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const s=[],l=[],u=[],c=[];let h=0,p=0;function f(t,e,n,r,i,o,f,d,m,g,y){const v=o/m,_=f/g,x=o/2,b=f/2,w=d/2,E=m+1,S=g+1;let M=0,T=0;const C=new It;for(let o=0;o<S;o++){const a=o*_-b;for(let s=0;s<E;s++){const h=s*v-x;C[t]=h*r,C[e]=a*i,C[n]=w,l.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[n]=d>0?1:-1,u.push(C.x,C.y,C.z),c.push(s/m),c.push(1-o/g),M+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const n=h+e+E*t,r=h+e+E*(t+1),i=h+(e+1)+E*(t+1),o=h+(e+1)+E*t;s.push(n,r,o),s.push(r,i,o),T+=6}a.addGroup(p,T,y),p+=T,h+=M}f("z","y","x",-1,-1,n,e,t,o,i,0),f("z","y","x",1,-1,n,e,-t,o,i,1),f("x","z","y",1,1,t,n,e,r,o,2),f("x","z","y",1,-1,t,n,-e,r,o,3),f("x","y","z",1,-1,t,e,n,r,i,4),f("x","y","z",-1,-1,t,e,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new cn(l,3)),this.setAttribute("normal",new cn(u,3)),this.setAttribute("uv",new cn(c,2))}static fromJSON(t){return new Gn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function jn(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Hn(t){const e={};for(let n=0;n<t.length;n++){const r=jn(t[n]);for(const t in r)e[t]=r[t]}return e}const qn={clone:jn,merge:Hn};class Wn extends je{constructor(t){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=jn(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?e.uniforms[n]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[n]={type:"m4",value:r.toArray()}:e.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}Wn.prototype.isShaderMaterial=!0;class Xn extends Le{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new oe,this.projectionMatrix=new oe,this.projectionMatrixInverse=new oe}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Xn.prototype.isCamera=!0;class Zn extends Xn{constructor(t=50,e=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*st*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*at*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*st*Math.atan(Math.tan(.5*at*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,r,i,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*at*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,a=o.fullHeight;i+=o.offsetX*r/t,e-=o.offsetY*n/a,r*=o.width/t,n*=o.height/a}const a=this.filmOffset;0!==a&&(i+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}Zn.prototype.isPerspectiveCamera=!0;class Yn extends Le{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const r=new Zn(90,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new It(1,0,0)),this.add(r);const i=new Zn(90,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new It(-1,0,0)),this.add(i);const o=new Zn(90,1,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new It(0,1,0)),this.add(o);const a=new Zn(90,1,t,e);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new It(0,-1,0)),this.add(a);const s=new Zn(90,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new It(0,0,1)),this.add(s);const l=new Zn(90,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new It(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,a,s,l]=this.children,u=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,i),t.setRenderTarget(n,2),t.render(e,o),t.setRenderTarget(n,3),t.render(e,a),t.setRenderTarget(n,4),t.render(e,s),n.texture.generateMipmaps=h,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(c),t.xr.enabled=u}}class Jn extends bt{constructor(t,e,n,r,o,a,s,l,u,c){super(t=void 0!==t?t:[],e=void 0!==e?e:i,n,r,o,a,s=void 0!==s?s:M,l,u,c),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Jn.prototype.isCubeTexture=!0;class Kn extends St{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new Jn(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=T,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n=new Gn(5,5,5),r=new Wn({name:"CubemapFromEquirect",uniforms:jn({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});r.uniforms.tEquirect.value=e;const i=new Un(n,r),o=e.minFilter;return e.minFilter===v&&(e.minFilter=g),new Yn(1,10,this).update(t,i),e.minFilter=o,i.geometry.dispose(),i.material.dispose(),this}clear(t,e,n,r){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,n,r);t.setRenderTarget(i)}}Kn.prototype.isWebGLCubeRenderTarget=!0;const Qn=new It,$n=new It,tr=new yt;class er{constructor(t=new It(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Qn.subVectors(n,e).cross($n.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const n=t.delta(Qn),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:e.copy(n).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||tr.getNormalMatrix(t),r=this.coplanarPoint(Qn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}er.prototype.isPlane=!0;const nr=new Jt,rr=new It;class ir{constructor(t=new er,e=new er,n=new er,r=new er,i=new er,o=new er){this.planes=[t,e,n,r,i,o]}set(t,e,n,r,i,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],p=n[9],f=n[10],d=n[11],m=n[12],g=n[13],y=n[14],v=n[15];return e[0].setComponents(a-r,c-s,d-h,v-m).normalize(),e[1].setComponents(a+r,c+s,d+h,v+m).normalize(),e[2].setComponents(a+i,c+l,d+p,v+g).normalize(),e[3].setComponents(a-i,c-l,d-p,v-g).normalize(),e[4].setComponents(a-o,c-u,d-f,v-y).normalize(),e[5].setComponents(a+o,c+u,d+f,v+y).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),nr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSprite(t){return nr.center.set(0,0,0),nr.radius=.7071067811865476,nr.applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(rr.x=r.normal.x>0?t.max.x:t.min.x,rr.y=r.normal.y>0?t.max.y:t.min.y,rr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(rr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function or(){let t=null,e=!1,n=null,r=null;function i(e,o){n(e,o),r=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function ar(t,e){const n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=r.get(e);n&&(t.deleteBuffer(n.buffer),r.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=r.get(e);return void((!t||t.version<e.version)&&r.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const o=r.get(e);void 0===o?r.set(e,function(e,r){const i=e.array,o=e.usage,a=t.createBuffer();t.bindBuffer(r,a),t.bufferData(r,i,o),e.onUploadCallback();let s=5126;return i instanceof Float32Array?s=5126:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?e.isFloat16BufferAttribute?n?s=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):s=5123:i instanceof Int16Array?s=5122:i instanceof Uint32Array?s=5125:i instanceof Int32Array?s=5124:i instanceof Int8Array?s=5120:(i instanceof Uint8Array||i instanceof Uint8ClampedArray)&&(s=5121),{buffer:a,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version}}(e,i)):o.version<e.version&&(function(e,r,i){const o=r.array,a=r.updateRange;t.bindBuffer(i,e),-1===a.count?t.bufferSubData(i,0,o):(n?t.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o,a.offset,a.count):t.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1)}(o.buffer,e,i),o.version=e.version)}}}class sr extends wn{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const i=t/2,o=e/2,a=Math.floor(n),s=Math.floor(r),l=a+1,u=s+1,c=t/a,h=e/s,p=[],f=[],d=[],m=[];for(let t=0;t<u;t++){const e=t*h-o;for(let n=0;n<l;n++){const r=n*c-i;f.push(r,-e,0),d.push(0,0,1),m.push(n/a),m.push(1-t/s)}}for(let t=0;t<s;t++)for(let e=0;e<a;e++){const n=e+l*t,r=e+l*(t+1),i=e+1+l*(t+1),o=e+1+l*t;p.push(n,r,o),p.push(r,i,o)}this.setIndex(p),this.setAttribute("position",new cn(f,3)),this.setAttribute("normal",new cn(d,3)),this.setAttribute("uv",new cn(m,2))}static fromJSON(t){return new sr(t.width,t.height,t.widthSegments,t.heightSegments)}}const lr={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotVH = saturate( dot( geometry.viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float NoH ) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float NoV, float NoL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( NoL + NoV - NoL * NoV ) ) );\n}\nvec3 BRDF_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in GeometricContext geometry ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenTint = sheenTint;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenTint;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( material.roughness, directLight.direction, geometry, material.sheenTint );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = transmission.a;\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},ur={common:{diffuse:{value:new Je(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new yt},uv2Transform:{value:new yt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new gt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Je(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new Je(16777215)},opacity:{value:1},center:{value:new gt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}}},cr={basic:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.fog]),vertexShader:lr.meshbasic_vert,fragmentShader:lr.meshbasic_frag},lambert:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.fog,ur.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshlambert_vert,fragmentShader:lr.meshlambert_frag},phong:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.fog,ur.lights,{emissive:{value:new Je(0)},specular:{value:new Je(1118481)},shininess:{value:30}}]),vertexShader:lr.meshphong_vert,fragmentShader:lr.meshphong_frag},standard:{uniforms:Hn([ur.common,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.roughnessmap,ur.metalnessmap,ur.fog,ur.lights,{emissive:{value:new Je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag},toon:{uniforms:Hn([ur.common,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.gradientmap,ur.fog,ur.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshtoon_vert,fragmentShader:lr.meshtoon_frag},matcap:{uniforms:Hn([ur.common,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.fog,{matcap:{value:null}}]),vertexShader:lr.meshmatcap_vert,fragmentShader:lr.meshmatcap_frag},points:{uniforms:Hn([ur.points,ur.fog]),vertexShader:lr.points_vert,fragmentShader:lr.points_frag},dashed:{uniforms:Hn([ur.common,ur.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lr.linedashed_vert,fragmentShader:lr.linedashed_frag},depth:{uniforms:Hn([ur.common,ur.displacementmap]),vertexShader:lr.depth_vert,fragmentShader:lr.depth_frag},normal:{uniforms:Hn([ur.common,ur.bumpmap,ur.normalmap,ur.displacementmap,{opacity:{value:1}}]),vertexShader:lr.meshnormal_vert,fragmentShader:lr.meshnormal_frag},sprite:{uniforms:Hn([ur.sprite,ur.fog]),vertexShader:lr.sprite_vert,fragmentShader:lr.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null}},vertexShader:lr.background_vert,fragmentShader:lr.background_frag},cube:{uniforms:Hn([ur.envmap,{opacity:{value:1}}]),vertexShader:lr.cube_vert,fragmentShader:lr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lr.equirect_vert,fragmentShader:lr.equirect_frag},distanceRGBA:{uniforms:Hn([ur.common,ur.displacementmap,{referencePosition:{value:new It},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lr.distanceRGBA_vert,fragmentShader:lr.distanceRGBA_frag},shadow:{uniforms:Hn([ur.lights,ur.fog,{color:{value:new Je(0)},opacity:{value:1}}]),vertexShader:lr.shadow_vert,fragmentShader:lr.shadow_frag}};function hr(t,e,n,r,i){const o=new Je(0);let a,s,u=0,c=null,h=0,p=null;function f(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),f(o,u=e)},getClearAlpha:function(){return u},setClearAlpha:function(t){f(o,u=t)},render:function(n,i){let d=!1,m=!0===i.isScene?i.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,y=g.getSession&&g.getSession();y&&"additive"===y.environmentBlendMode&&(m=null),null===m?f(o,u):m&&m.isColor&&(f(m,1),d=!0),(t.autoClear||d)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===s&&((s=new Un(new Gn(1,1,1),new Wn({name:"BackgroundCubeMaterial",uniforms:jn(cr.cube.uniforms),vertexShader:cr.cube.vertexShader,fragmentShader:cr.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(s)),s.material.uniforms.envMap.value=m,s.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,c===m&&h===m.version&&p===t.toneMapping||(s.material.needsUpdate=!0,c=m,h=m.version,p=t.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):m&&m.isTexture&&(void 0===a&&((a=new Un(new sr(2,2),new Wn({name:"BackgroundMaterial",uniforms:jn(cr.background.uniforms),vertexShader:cr.background.vertexShader,fragmentShader:cr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),c===m&&h===m.version&&p===t.toneMapping||(a.material.needsUpdate=!0,c=m,h=m.version,p=t.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null))}}}function pr(t,e,n,r){const i=t.getParameter(34921),o=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||null!==o,s={},l=p(null);let u=l;function c(e){return r.isWebGL2?t.bindVertexArray(e):o.bindVertexArrayOES(e)}function h(e){return r.isWebGL2?t.deleteVertexArray(e):o.deleteVertexArrayOES(e)}function p(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function f(){const t=u.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function d(t){m(t,0)}function m(n,i){const o=u.newAttributes,a=u.enabledAttributes,s=u.attributeDivisors;o[n]=1,0===a[n]&&(t.enableVertexAttribArray(n),a[n]=1),s[n]!==i&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i)}function g(){const e=u.newAttributes,n=u.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==e[r]&&(t.disableVertexAttribArray(r),n[r]=0)}function y(e,n,i,o,a,s){!0!==r.isWebGL2||5124!==i&&5125!==i?t.vertexAttribPointer(e,n,i,o,a,s):t.vertexAttribIPointer(e,n,i,a,s)}function v(){_(),u!==l&&c((u=l).object)}function _(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(i,l,h,v,_){let x=!1;if(a){const e=function(e,n,i){const a=!0===i.wireframe;let l=s[e.id];void 0===l&&(l={},s[e.id]=l);let u=l[n.id];void 0===u&&(u={},l[n.id]=u);let c=u[a];return void 0===c&&(c=p(r.isWebGL2?t.createVertexArray():o.createVertexArrayOES()),u[a]=c),c}(v,h,l);u!==e&&c((u=e).object),(x=function(t,e){const n=u.attributes,r=t.attributes;let i=0;for(const t in r){const e=n[t],o=r[t];if(void 0===e)return!0;if(e.attribute!==o)return!0;if(e.data!==o.data)return!0;i++}return u.attributesNum!==i||u.index!==e}(v,_))&&function(t,e){const n={},r=v.attributes;let i=0;for(const t in r){const e=r[t],o={};o.attribute=e,e.data&&(o.data=e.data),n[t]=o,i++}u.attributes=n,u.attributesNum=i,u.index=e}(0,_)}else{const t=!0===l.wireframe;u.geometry===v.id&&u.program===h.id&&u.wireframe===t||(u.geometry=v.id,u.program=h.id,u.wireframe=t,x=!0)}!0===i.isInstancedMesh&&(x=!0),null!==_&&n.update(_,34963),x&&(function(i,o,a,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;f();const l=s.attributes,u=a.getAttributes(),c=o.defaultAttributeValues;for(const e in u){const r=u[e];if(r.location>=0){let o=l[e];if(void 0===o&&("instanceMatrix"===e&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const e=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const u=l.buffer,c=l.type,h=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,p=o.offset;if(n&&n.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)m(r.location+t,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(34962,u);for(let t=0;t<r.locationSize;t++)y(r.location+t,a/r.locationSize,c,e,l*h,(p+a/r.locationSize*t)*h)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)m(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(34962,u);for(let t=0;t<r.locationSize;t++)y(r.location+t,a/r.locationSize,c,e,a*h,a/r.locationSize*t*h)}}else if(void 0!==c){const n=c[e];if(void 0!==n)switch(n.length){case 2:t.vertexAttrib2fv(r.location,n);break;case 3:t.vertexAttrib3fv(r.location,n);break;case 4:t.vertexAttrib4fv(r.location,n);break;default:t.vertexAttrib1fv(r.location,n)}}}}g()}(i,l,h,v),null!==_&&t.bindBuffer(34963,n.get(_).buffer))},reset:v,resetDefaultState:_,dispose:function(){v();for(const t in s){const e=s[t];for(const t in e){const n=e[t];for(const t in n)h(n[t].object),delete n[t];delete e[t]}delete s[t]}},releaseStatesOfGeometry:function(t){if(void 0===s[t.id])return;const e=s[t.id];for(const t in e){const n=e[t];for(const t in n)h(n[t].object),delete n[t];delete e[t]}delete s[t.id]},releaseStatesOfProgram:function(t){for(const e in s){const n=s[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)h(r[t].object),delete r[t];delete n[t.id]}},initAttributes:f,enableAttribute:d,disableUnusedAttributes:g}}function fr(t,e,n,r){const i=r.isWebGL2;let o;this.setMode=function(t){o=t},this.render=function(e,r){t.drawArrays(o,e,r),n.update(r,o,1)},this.renderInstances=function(r,a,s){if(0===s)return;let l,u;if(i)l=t,u="drawArraysInstanced";else if(u="drawArraysInstancedANGLE",null===(l=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](o,r,a,s),n.update(a,o,s)}}function dr(t,e,n){let r;function i(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||e.has("WEBGL_draw_buffers"),u=!0===n.logarithmicDepthBuffer,c=t.getParameter(34930),h=t.getParameter(35660),p=t.getParameter(3379),f=t.getParameter(34076),d=t.getParameter(34921),m=t.getParameter(36347),g=t.getParameter(36348),y=t.getParameter(36349),v=h>0,_=o||e.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:a,logarithmicDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:f,maxAttributes:d,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:o?t.getParameter(36183):0}}function mr(t){const e=this;let n=null,r=0,i=!1,o=!1;const a=new er,s=new yt,l={value:null,needsUpdate:!1};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function c(t,n,r,i){const o=null!==t?t.length:0;let u=null;if(0!==o){if(u=l.value,!0!==i||null===u){const e=r+4*o,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===u||u.length<e)&&(u=new Float32Array(e));for(let e=0,n=r;e!==o;++e,n+=4)a.copy(t[e]).applyMatrix4(i,s),a.normal.toArray(u,n),u[n+3]=a.constant}l.value=u,l.needsUpdate=!0}return e.numPlanes=o,e.numIntersection=0,u}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,o){const a=0!==t.length||e||0!==r||i;return i=e,n=c(t,o,0),r=t.length,a},this.beginShadows=function(){o=!0,c(null)},this.endShadows=function(){o=!1,u()},this.setState=function(e,a,s){const h=e.clippingPlanes,p=e.clipIntersection,f=e.clipShadows,d=t.get(e);if(!i||null===h||0===h.length||o&&!f)o?c(null):u();else{const t=o?0:r,e=4*t;let i=d.clippingState||null;l.value=i,i=c(h,a,e,s);for(let t=0;t!==e;++t)i[t]=n[t];d.clippingState=i,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=t}}}function gr(t){let e=new WeakMap;function n(t,e){return e===a?t.mapping=i:e===s&&(t.mapping=o),t}function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const o=i.mapping;if(o===a||o===s){if(e.has(i))return n(e.get(i).texture,i.mapping);{const o=i.image;if(o&&o.height>0){const a=t.getRenderTarget(),s=new Kn(o.height/2);return s.fromEquirectangularTexture(t,i),e.set(i,s),t.setRenderTarget(a),i.addEventListener("dispose",r),n(s.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}cr.physical={uniforms:Hn([cr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new gt(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Je(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new Je(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new Je(1,1,1)},specularTintMap:{value:null}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag};class yr extends Xn{constructor(t=-1,e=1,n=1,r=-1,i=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,i,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-t,o=n+t,a=r+e,s=r-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(i+=t*this.view.offsetX)+t*this.view.width,s=(a-=e*this.view.offsetY)-e*this.view.height}this.projectionMatrix.makeOrthographic(i,o,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}yr.prototype.isOrthographicCamera=!0;class vr extends Wn{constructor(t){super(t),this.type="RawShaderMaterial"}}vr.prototype.isRawShaderMaterial=!0;const _r=Math.pow(2,8),xr=[.125,.215,.35,.446,.526,.582],br=5+xr.length,wr={[X]:0,[Z]:1,[J]:2,[K]:3,[Q]:4,[$]:5,[Y]:6},Er=new yr,{_lodPlanes:Sr,_sizeLods:Mr,_sigmas:Tr}=function(){const t=[],e=[],n=[];let r=8;for(let i=0;i<br;i++){const o=Math.pow(2,r);e.push(o);let a=1/o;i>4?a=xr[i-8+4-1]:0==i&&(a=0),n.push(a);const s=1/(o-1),l=-s/2,u=1+s/2,c=[l,l,u,l,u,u,l,l,u,u,l,u],h=6,p=6,f=3,d=2,m=1,g=new Float32Array(f*p*h),y=new Float32Array(d*p*h),v=new Float32Array(m*p*h);for(let t=0;t<h;t++){const e=t%3*2/3-1,n=t>2?0:-1,r=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];g.set(r,f*p*t),y.set(c,d*p*t);const i=[t,t,t,t,t,t];v.set(i,m*p*t)}const _=new wn;_.setAttribute("position",new tn(g,f)),_.setAttribute("uv",new tn(y,d)),_.setAttribute("faceIndex",new tn(v,m)),t.push(_),r>4&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}(),Cr=new Je;let Ir=null;const Ar=(1+Math.sqrt(5))/2,Lr=1/Ar,Pr=[new It(1,1,1),new It(-1,1,1),new It(1,1,-1),new It(-1,1,-1),new It(0,Ar,Lr),new It(0,Ar,-Lr),new It(Lr,0,Ar),new It(-Lr,0,Ar),new It(Ar,Lr,0),new It(-Ar,Lr,0)];class Rr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(20),n=new It(0,1,0);return new vr({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){Ir=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(t,n,r,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=zr(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=kr(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t<Sr.length;t++)Sr[t].dispose()}_cleanup(t){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(Ir),t.scissorTest=!1,Or(t,0,0,t.width,t.height)}_fromTexture(t){Ir=this._renderer.getRenderTarget();const e=this._allocateTargets(t);return this._textureToCubeUV(t,e),this._applyPMREM(e),this._cleanup(e),e}_allocateTargets(t){const e={magFilter:f,minFilter:f,generateMipmaps:!1,type:_,format:1023,encoding:Dr(t)?t.encoding:J,depthBuffer:!1},n=Nr(e);return n.depthBuffer=!t,this._pingPongRenderTarget=Nr(e),n}_compileMaterial(t){const e=new Un(Sr[0],t);this._renderer.compile(e,Er)}_sceneToCubeUV(t,e,n,r){const i=new Zn(90,1,e,n),o=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,u=s.outputEncoding,c=s.toneMapping;s.getClearColor(Cr),s.toneMapping=0,s.outputEncoding=X,s.autoClear=!1;const h=new Ke({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),p=new Un(new Gn,h);let f=!1;const d=t.background;d?d.isColor&&(h.color.copy(d),t.background=null,f=!0):(h.color.copy(Cr),f=!0);for(let e=0;e<6;e++){const n=e%3;0==n?(i.up.set(0,o[e],0),i.lookAt(a[e],0,0)):1==n?(i.up.set(0,0,o[e]),i.lookAt(0,a[e],0)):(i.up.set(0,o[e],0),i.lookAt(0,0,a[e])),Or(r,n*_r,e>2?_r:0,_r,_r),s.setRenderTarget(r),f&&s.render(p,i),s.render(t,i)}p.geometry.dispose(),p.material.dispose(),s.toneMapping=c,s.outputEncoding=u,s.autoClear=l,t.background=d}_textureToCubeUV(t,e){const n=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=zr()):null==this._equirectShader&&(this._equirectShader=kr());const r=t.isCubeTexture?this._cubemapShader:this._equirectShader,i=new Un(Sr[0],r),o=r.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=wr[t.encoding],o.outputEncoding.value=wr[e.texture.encoding],Or(e,0,0,3*_r,2*_r),n.setRenderTarget(e),n.render(i,Er)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let e=1;e<br;e++){const n=Math.sqrt(Tr[e]*Tr[e]-Tr[e-1]*Tr[e-1]),r=Pr[(e-1)%Pr.length];this._blur(t,e-1,e,n,r)}e.autoClear=n}_blur(t,e,n,r,i){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,r,"latitudinal",i),this._halfBlur(o,t,n,n,r,"longitudinal",i)}_halfBlur(t,e,n,r,i,o,a){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const u=new Un(Sr[r],l),c=l.uniforms,h=Mr[n]-1,p=isFinite(i)?Math.PI/(2*h):2*Math.PI/39,f=i/p,d=isFinite(i)?1+Math.floor(3*f):20;d>20&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${d} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/f,n=Math.exp(-e*e/2);m.push(n),0==t?g+=n:t<d&&(g+=2*n)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=d,c.weights.value=m,c.latitudinal.value="latitudinal"===o,a&&(c.poleAxis.value=a),c.dTheta.value=p,c.mipInt.value=8-n,c.inputEncoding.value=wr[t.texture.encoding],c.outputEncoding.value=wr[t.texture.encoding];const y=Mr[r];Or(e,3*Math.max(0,_r-2*y),(0===r?0:2*_r)+2*y*(r>4?r-8+4:0),3*y,2*y),s.setRenderTarget(e),s.render(u,Er)}}function Dr(t){return void 0!==t&&t.type===_&&(t.encoding===X||t.encoding===Z||t.encoding===Y)}function Nr(t){const e=new St(3*_r,3*_r,t);return e.texture.mapping=l,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Or(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function kr(){const t=new gt(1,1);return new vr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function zr(){return new vr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Fr(t){let e=new WeakMap,n=null;function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const u=l.mapping,c=u===a||u===s,h=u===i||u===o;if(c||h){if(e.has(l))return e.get(l).texture;{const i=l.image;if(c&&i&&i.height>0||h&&i&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(i)){const i=t.getRenderTarget();null===n&&(n=new Rr(t));const o=c?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,o),t.setRenderTarget(i),l.addEventListener("dispose",r),o.texture}return null}}}return l},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Br(t){const e={};function n(n){if(void 0!==e[n])return e[n];let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r}return{has:function(t){return null!==n(t)},init:function(t){t.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ur(t,e,n,r){const i={},o=new WeakMap;function a(t){const s=t.target;null!==s.index&&e.remove(s.index);for(const t in s.attributes)e.remove(s.attributes[t]);s.removeEventListener("dispose",a),delete i[s.id];const l=o.get(s);l&&(e.remove(l),o.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(t){const n=[],r=t.index,i=t.attributes.position;let a=0;if(null!==r){const t=r.array;a=r.version;for(let e=0,r=t.length;e<r;e+=3){const r=t[e+0],i=t[e+1],o=t[e+2];n.push(r,i,i,o,o,r)}}else{const t=i.array;a=i.version;for(let e=0,r=t.length/3-1;e<r;e+=3){const t=e+0,r=e+1,i=e+2;n.push(t,r,r,i,i,t)}}const s=new(pn(n)>65535?ln:an)(n,1);s.version=a;const l=o.get(t);l&&e.remove(l),o.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",a),i[e.id]=!0,n.memory.geometries++),e},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const r=t.morphAttributes;for(const t in r){const n=r[t];for(let t=0,r=n.length;t<r;t++)e.update(n[t],34962)}},getWireframeAttribute:function(t){const e=o.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&s(t)}else s(t);return o.get(t)}}}function Vr(t,e,n,r){const i=r.isWebGL2;let o,a,s;this.setMode=function(t){o=t},this.setIndex=function(t){a=t.type,s=t.bytesPerElement},this.render=function(e,r){t.drawElements(o,r,a,e*s),n.update(r,o,1)},this.renderInstances=function(r,l,u){if(0===u)return;let c,h;if(i)c=t,h="drawElementsInstanced";else if(h="drawElementsInstancedANGLE",null===(c=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[h](o,l,a,r*s,u),n.update(l,o,u)}}function Gr(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,n,r){switch(e.calls++,n){case 4:e.triangles+=r*(t/3);break;case 1:e.lines+=r*(t/2);break;case 3:e.lines+=r*(t-1);break;case 2:e.lines+=r*t;break;case 0:e.points+=r*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function jr(t,e){return t[0]-e[0]}function Hr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function qr(t){const e={},n=new Float32Array(8),r=[];for(let t=0;t<8;t++)r[t]=[t,0];return{update:function(i,o,a,s){const l=i.morphTargetInfluences,u=void 0===l?0:l.length;let c=e[o.id];if(void 0===c||c.length!==u){c=[];for(let t=0;t<u;t++)c[t]=[t,0];e[o.id]=c}for(let t=0;t<u;t++){const e=c[t];e[0]=t,e[1]=l[t]}c.sort(Hr);for(let t=0;t<8;t++)t<u&&c[t][1]?(r[t][0]=c[t][0],r[t][1]=c[t][1]):(r[t][0]=Number.MAX_SAFE_INTEGER,r[t][1]=0);r.sort(jr);const h=o.morphAttributes.position,p=o.morphAttributes.normal;let f=0;for(let t=0;t<8;t++){const e=r[t],i=e[0],a=e[1];i!==Number.MAX_SAFE_INTEGER&&a?(h&&o.getAttribute("morphTarget"+t)!==h[i]&&o.setAttribute("morphTarget"+t,h[i]),p&&o.getAttribute("morphNormal"+t)!==p[i]&&o.setAttribute("morphNormal"+t,p[i]),n[t]=a,f+=a):(h&&!0===o.hasAttribute("morphTarget"+t)&&o.deleteAttribute("morphTarget"+t),p&&!0===o.hasAttribute("morphNormal"+t)&&o.deleteAttribute("morphNormal"+t),n[t]=0)}const d=o.morphTargetsRelative?1:1-f;s.getUniforms().setValue(t,"morphTargetBaseInfluence",d),s.getUniforms().setValue(t,"morphTargetInfluences",n)}}}function Wr(t,e,n,r){let i=new WeakMap;function o(t){const e=t.target;e.removeEventListener("dispose",o),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(t){const a=r.render.frame,s=t.geometry,l=e.get(t,s);return i.get(l)!==a&&(e.update(l),i.set(l,a)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",o)&&t.addEventListener("dispose",o),n.update(t.instanceMatrix,34962),null!==t.instanceColor&&n.update(t.instanceColor,34962)),l},dispose:function(){i=new WeakMap}}}class Xr extends bt{constructor(t=null,e=1,n=1,r=1){super(null),this.image={data:t,width:e,height:n,depth:r},this.magFilter=f,this.minFilter=f,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Xr.prototype.isDataTexture2DArray=!0;class Zr extends bt{constructor(t=null,e=1,n=1,r=1){super(null),this.image={data:t,width:e,height:n,depth:r},this.magFilter=f,this.minFilter=f,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Zr.prototype.isDataTexture3D=!0;const Yr=new bt,Jr=new Xr,Kr=new Zr,Qr=new Jn,$r=[],ti=[],ei=new Float32Array(16),ni=new Float32Array(9),ri=new Float32Array(4);function ii(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let o=$r[i];if(void 0===o&&(o=new Float32Array(i),$r[i]=o),0!==e){r.toArray(o,0);for(let r=1,i=0;r!==e;++r)i+=n,t[r].toArray(o,i)}return o}function oi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ai(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function si(t,e){let n=ti[e];void 0===n&&(n=new Int32Array(e),ti[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function li(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function ui(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(oi(n,e))return;t.uniform2fv(this.addr,e),ai(n,e)}}function ci(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(oi(n,e))return;t.uniform3fv(this.addr,e),ai(n,e)}}function hi(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(oi(n,e))return;t.uniform4fv(this.addr,e),ai(n,e)}}function pi(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ai(n,e)}else{if(oi(n,r))return;ri.set(r),t.uniformMatrix2fv(this.addr,!1,ri),ai(n,r)}}function fi(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ai(n,e)}else{if(oi(n,r))return;ni.set(r),t.uniformMatrix3fv(this.addr,!1,ni),ai(n,r)}}function di(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ai(n,e)}else{if(oi(n,r))return;ei.set(r),t.uniformMatrix4fv(this.addr,!1,ei),ai(n,r)}}function mi(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function gi(t,e){const n=this.cache;oi(n,e)||(t.uniform2iv(this.addr,e),ai(n,e))}function yi(t,e){const n=this.cache;oi(n,e)||(t.uniform3iv(this.addr,e),ai(n,e))}function vi(t,e){const n=this.cache;oi(n,e)||(t.uniform4iv(this.addr,e),ai(n,e))}function _i(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function xi(t,e){const n=this.cache;oi(n,e)||(t.uniform2uiv(this.addr,e),ai(n,e))}function bi(t,e){const n=this.cache;oi(n,e)||(t.uniform3uiv(this.addr,e),ai(n,e))}function wi(t,e){const n=this.cache;oi(n,e)||(t.uniform4uiv(this.addr,e),ai(n,e))}function Ei(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(e||Yr,i)}function Si(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||Kr,i)}function Mi(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(e||Qr,i)}function Ti(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||Jr,i)}function Ci(t,e){t.uniform1fv(this.addr,e)}function Ii(t,e){const n=ii(e,this.size,2);t.uniform2fv(this.addr,n)}function Ai(t,e){const n=ii(e,this.size,3);t.uniform3fv(this.addr,n)}function Li(t,e){const n=ii(e,this.size,4);t.uniform4fv(this.addr,n)}function Pi(t,e){const n=ii(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Ri(t,e){const n=ii(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Di(t,e){const n=ii(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Ni(t,e){t.uniform1iv(this.addr,e)}function Oi(t,e){t.uniform2iv(this.addr,e)}function ki(t,e){t.uniform3iv(this.addr,e)}function zi(t,e){t.uniform4iv(this.addr,e)}function Fi(t,e){t.uniform1uiv(this.addr,e)}function Bi(t,e){t.uniform2uiv(this.addr,e)}function Ui(t,e){t.uniform3uiv(this.addr,e)}function Vi(t,e){t.uniform4uiv(this.addr,e)}function Gi(t,e,n){const r=e.length,i=si(n,r);t.uniform1iv(this.addr,i);for(let t=0;t!==r;++t)n.safeSetTexture2D(e[t]||Yr,i[t])}function ji(t,e,n){const r=e.length,i=si(n,r);t.uniform1iv(this.addr,i);for(let t=0;t!==r;++t)n.safeSetTextureCube(e[t]||Qr,i[t])}function Hi(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=function(t){switch(e.type){case 5126:return li;case 35664:return ui;case 35665:return ci;case 35666:return hi;case 35674:return pi;case 35675:return fi;case 35676:return di;case 5124:case 35670:return mi;case 35667:case 35671:return gi;case 35668:case 35672:return yi;case 35669:case 35673:return vi;case 5125:return _i;case 36294:return xi;case 36295:return bi;case 36296:return wi;case 35678:case 36198:case 36298:case 36306:case 35682:return Ei;case 35679:case 36299:case 36307:return Si;case 35680:case 36300:case 36308:case 36293:return Mi;case 36289:case 36303:case 36311:case 36292:return Ti}}()}function qi(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=function(t){switch(e.type){case 5126:return Ci;case 35664:return Ii;case 35665:return Ai;case 35666:return Li;case 35674:return Pi;case 35675:return Ri;case 35676:return Di;case 5124:case 35670:return Ni;case 35667:case 35671:return Oi;case 35668:case 35672:return ki;case 35669:case 35673:return zi;case 5125:return Fi;case 36294:return Bi;case 36295:return Ui;case 36296:return Vi;case 35678:case 36198:case 36298:case 36306:case 35682:return Gi;case 35680:case 36300:case 36308:case 36293:return ji}}()}function Wi(t){this.id=t,this.seq=[],this.map={}}qi.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),ai(e,t)},Wi.prototype.setValue=function(t,e,n){const r=this.seq;for(let i=0,o=r.length;i!==o;++i){const o=r[i];o.setValue(t,e[o.id],n)}};const Xi=/(\w+)(\])?(\[|\.)?/g;function Zi(t,e){t.seq.push(e),t.map[e.id]=e}function Yi(t,e,n){const r=t.name,i=r.length;for(Xi.lastIndex=0;;){const o=Xi.exec(r),a=Xi.lastIndex;let s=o[1];const l="]"===o[2],u=o[3];if(l&&(s|=0),void 0===u||"["===u&&a+2===i){Zi(n,void 0===u?new Hi(s,t,e):new qi(s,t,e));break}{let t=n.map[s];void 0===t&&Zi(n,t=new Wi(s)),n=t}}}function Ji(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,35718);for(let r=0;r<n;++r){const n=t.getActiveUniform(e,r);Yi(n,t.getUniformLocation(e,n.name),this)}}function Ki(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}Ji.prototype.setValue=function(t,e,n,r){const i=this.map[e];void 0!==i&&i.setValue(t,n,r)},Ji.prototype.setOptional=function(t,e,n){const r=e[n];void 0!==r&&this.setValue(t,n,r)},Ji.upload=function(t,e,n,r){for(let i=0,o=e.length;i!==o;++i){const o=e[i],a=n[o.id];!1!==a.needsUpdate&&o.setValue(t,a.value,r)}},Ji.seqWithValue=function(t,e){const n=[];for(let r=0,i=t.length;r!==i;++r){const i=t[r];i.id in e&&n.push(i)}return n};let Qi=0;function $i(t){switch(t){case X:return["Linear","( value )"];case Z:return["sRGB","( value )"];case J:return["RGBE","( value )"];case K:return["RGBM","( value, 7.0 )"];case Q:return["RGBM","( value, 16.0 )"];case $:return["RGBD","( value, 256.0 )"];case Y:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function to(t,e,n){const r=t.getShaderParameter(e,35713),i=t.getShaderInfoLog(e).trim();return r&&""===i?"":n.toUpperCase()+"\n\n"+i+"\n\n"+function(t){const e=t.split("\n");for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(t.getShaderSource(e))}function eo(t,e){const n=$i(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function no(t,e){const n=$i(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function ro(t,e){let n;switch(e){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function io(t){return""!==t}function oo(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ao(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const so=/^[ \t]*#include +<([\w\d./]+)>/gm;function lo(t){return t.replace(so,uo)}function uo(t,e){const n=lr[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return lo(n)}const co=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ho=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function po(t){return t.replace(ho,mo).replace(co,fo)}function fo(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mo(t,e,n,r)}function mo(t,e,n,r){let i="";for(let t=parseInt(e);t<parseInt(n);t++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return i}function go(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function yo(t,e,n,r){const a=t.getContext(),s=n.defines;let c=n.vertexShader,h=n.fragmentShader;const p=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(n),f=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case i:case o:e="ENVMAP_TYPE_CUBE";break;case l:case u:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),d=function(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case o:case u:e="ENVMAP_MODE_REFRACTION"}return e}(n),m=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(n),g=t.gammaFactor>0?t.gammaFactor:1,y=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(io).join("\n")}(n),v=function(t){const e=[];for(const n in t){const r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(s),_=a.createProgram();let x,b,w=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((x=[v].filter(io).join("\n")).length>0&&(x+="\n"),(b=[y,v].filter(io).join("\n")).length>0&&(b+="\n")):(x=[go(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+p:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(io).join("\n"),b=[y,go(n),"#define SHADER_NAME "+n.shaderName,v,"#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.envMap?"#define "+d:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheenTint?"#define USE_SHEEN":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+p:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lr.tonemapping_pars_fragment:"",0!==n.toneMapping?ro("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===M?"#define OPAQUE":"",lr.encodings_pars_fragment,n.map?eo("mapTexelToLinear",n.mapEncoding):"",n.matcap?eo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?eo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?eo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularTintMap?eo("specularTintMapTexelToLinear",n.specularTintMapEncoding):"",n.lightMap?eo("lightMapTexelToLinear",n.lightMapEncoding):"",no("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(io).join("\n")),c=ao(c=oo(c=lo(c),n),n),h=ao(h=oo(h=lo(h),n),n),c=po(c),h=po(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",n.glslVersion===nt?"":"out highp vec4 pc_fragColor;",n.glslVersion===nt?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+b);const E=w+b+h,S=Ki(a,35633,w+x+c),T=Ki(a,35632,E);if(a.attachShader(_,S),a.attachShader(_,T),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_),t.debug.checkShaderErrors){const t=a.getProgramInfoLog(_).trim(),e=a.getShaderInfoLog(S).trim(),n=a.getShaderInfoLog(T).trim();let r=!0,i=!0;if(!1===a.getProgramParameter(_,35714)){r=!1;const e=to(a,S,"vertex"),n=to(a,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(_,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==n||(i=!1);i&&(this.diagnostics={runnable:r,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:n,prefix:b}})}let C,I;return a.deleteShader(S),a.deleteShader(T),this.getUniforms=function(){return void 0===C&&(C=new Ji(a,_)),C},this.getAttributes=function(){return void 0===I&&(I=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i<r;i++){const r=t.getActiveAttrib(e,i),o=r.name;let a=1;35674===r.type&&(a=2),35675===r.type&&(a=3),35676===r.type&&(a=4),n[o]={type:r.type,location:t.getAttribLocation(e,o),locationSize:a}}return n}(a,_)),I},this.destroy=function(){r.releaseStatesOfProgram(this),a.deleteProgram(_),this.program=void 0},this.name=n.shaderName,this.id=Qi++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=T,this}function vo(t,e,n,r,i,o,a){const s=[],c=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.floatVertexTextures,f=i.maxVertexUniforms,d=i.vertexTextures;let m=i.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},y=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","specularIntensityMap","specularTintMap","specularTintMapEncoding","roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","sheenTint","transmission","transmissionMap","thicknessMap"];function v(t){let e;return t&&t.isTexture?e=t.encoding:t&&t.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=X,e}return{getParameters:function(o,s,y,_,x){const b=_.fog,w=o.isMeshStandardMaterial?_.environment:null,E=(o.isMeshStandardMaterial?n:e).get(o.envMap||w),S=g[o.type],M=x.isSkinnedMesh?function(t){const e=x.skeleton.bones;if(p)return 1024;{const t=f,n=Math.floor((t-20)/4),r=Math.min(n,e.length);return r<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+r+"."),0):r}}():0;let T,C;if(null!==o.precision&&(m=i.getMaxPrecision(o.precision))!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",m,"instead."),S){const t=cr[S];T=t.vertexShader,C=t.fragmentShader}else T=o.vertexShader,C=o.fragmentShader;const I=t.getRenderTarget(),A=o.alphaTest>0,L=o.clearcoat>0;return{isWebGL2:c,shaderID:S,shaderName:o.type,vertexShader:T,fragmentShader:C,defines:o.defines,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:d,outputEncoding:null!==I?v(I.texture):t.outputEncoding,map:!!o.map,mapEncoding:v(o.map),matcap:!!o.matcap,matcapEncoding:v(o.matcap),envMap:!!E,envMapMode:E&&E.mapping,envMapEncoding:v(E),envMapCubeUV:!!E&&(E.mapping===l||E.mapping===u),lightMap:!!o.lightMap,lightMapEncoding:v(o.lightMap),aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,emissiveMapEncoding:v(o.emissiveMap),bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:1===o.normalMapType,tangentSpaceNormalMap:0===o.normalMapType,clearcoat:L,clearcoatMap:L&&!!o.clearcoatMap,clearcoatRoughnessMap:L&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:L&&!!o.clearcoatNormalMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularTintMap:!!o.specularTintMap,specularTintMapEncoding:v(o.specularTintMap),alphaMap:!!o.alphaMap,alphaTest:A,gradientMap:!!o.gradientMap,sheenTint:!!o.sheenTint&&(o.sheenTint.r>0||o.sheenTint.g>0||o.sheenTint.b>0),transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!x.geometry&&!!x.geometry.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!x.geometry&&!!x.geometry.attributes.color&&4===x.geometry.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap||!o.displacementMap),fog:!!b,useFog:o.fog,fogExp2:b&&b.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===x.isSkinnedMesh&&M>0,maxBones:M,useVertexTexture:p,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,format:o.format,dithering:o.dithering,shadowMapEnabled:t.shadowMap.enabled&&y.length>0,shadowMapType:t.shadowMap.type,toneMapping:o.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:2===o.side,flipSided:1===o.side,depthPacking:void 0!==o.depthPacking&&o.depthPacking,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t<y.length;t++)n.push(e[y[t]]);n.push(t.outputEncoding),n.push(t.gammaFactor)}return n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=g[t.type];let n;if(e){const t=cr[e];n=qn.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let r;for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e.cacheKey===n){++(r=e).usedTimes;break}}return void 0===r&&(r=new yo(t,n,e,o),s.push(r)),r},releaseProgram:function(t){if(0==--t.usedTimes){const e=s.indexOf(t);s[e]=s[s.length-1],s.pop(),t.destroy()}},programs:s}}function _o(){let t=new WeakMap;return{get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,r){t.get(e)[n]=r},dispose:function(){t=new WeakMap}}}function xo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function bo(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function wo(t){const e=[];let n=0;const r=[],i=[],o=[],a={id:-1};function s(r,i,o,s,l,u){let c=e[n];const h=t.get(o);return void 0===c?(c={id:r.id,object:r,geometry:i,material:o,program:h.program||a,groupOrder:s,renderOrder:r.renderOrder,z:l,group:u},e[n]=c):(c.id=r.id,c.object=r,c.geometry=i,c.material=o,c.program=h.program||a,c.groupOrder=s,c.renderOrder=r.renderOrder,c.z=l,c.group=u),n++,c}return{opaque:r,transmissive:i,transparent:o,init:function(){n=0,r.length=0,i.length=0,o.length=0},push:function(t,e,n,a,l,u){const c=s(t,e,n,a,l,u);n.transmission>0?i.push(c):!0===n.transparent?o.push(c):r.push(c)},unshift:function(t,e,n,a,l,u){const c=s(t,e,n,a,l,u);n.transmission>0?i.unshift(c):!0===n.transparent?o.unshift(c):r.unshift(c)},finish:function(){for(let t=n,r=e.length;t<r;t++){const n=e[t];if(null===n.id)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}},sort:function(t,e){r.length>1&&r.sort(t||xo),i.length>1&&i.sort(e||bo),o.length>1&&o.sort(e||bo)}}}function Eo(t){let e=new WeakMap;return{get:function(n,r){let i;return!1===e.has(n)?(i=new wo(t),e.set(n,[i])):r>=e.get(n).length?(i=new wo(t),e.get(n).push(i)):i=e.get(n)[r],i},dispose:function(){e=new WeakMap}}}function So(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new It,color:new Je};break;case"SpotLight":n={position:new It,direction:new It,color:new Je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new It,color:new Je,distance:0,decay:0};break;case"HemisphereLight":n={direction:new It,skyColor:new Je,groundColor:new Je};break;case"RectAreaLight":n={color:new Je,position:new It,halfWidth:new It,halfHeight:new It}}return t[e.id]=n,n}}}let Mo=0;function To(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Co(t,e){const n=new So,r=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)i.probe.push(new It);const o=new It,a=new oe,s=new oe;return{setup:function(o,a){let s=0,l=0,u=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let c=0,h=0,p=0,f=0,d=0,m=0,g=0,y=0;o.sort(To);const v=!0!==a?Math.PI:1;for(let t=0,e=o.length;t<e;t++){const e=o[t],a=e.color,_=e.intensity,x=e.distance,b=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)s+=a.r*_*v,l+=a.g*_*v,u+=a.b*_*v;else if(e.isLightProbe)for(let t=0;t<9;t++)i.probe[t].addScaledVector(e.sh.coefficients[t],_);else if(e.isDirectionalLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*v),e.castShadow){const t=e.shadow,n=r.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,i.directionalShadow[c]=n,i.directionalShadowMap[c]=b,i.directionalShadowMatrix[c]=e.shadow.matrix,m++}i.directional[c]=t,c++}else if(e.isSpotLight){const t=n.get(e);if(t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(a).multiplyScalar(_*v),t.distance=x,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,e.castShadow){const t=e.shadow,n=r.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,i.spotShadow[p]=n,i.spotShadowMap[p]=b,i.spotShadowMatrix[p]=e.shadow.matrix,y++}i.spot[p]=t,p++}else if(e.isRectAreaLight){const t=n.get(e);t.color.copy(a).multiplyScalar(_),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),i.rectArea[f]=t,f++}else if(e.isPointLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*v),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,n=r.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,n.shadowCameraNear=t.camera.near,n.shadowCameraFar=t.camera.far,i.pointShadow[h]=n,i.pointShadowMap[h]=b,i.pointShadowMatrix[h]=e.shadow.matrix,g++}i.point[h]=t,h++}else if(e.isHemisphereLight){const t=n.get(e);t.skyColor.copy(e.color).multiplyScalar(_*v),t.groundColor.copy(e.groundColor).multiplyScalar(_*v),i.hemi[d]=t,d++}}f>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=ur.LTC_FLOAT_1,i.rectAreaLTC2=ur.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=ur.LTC_HALF_1,i.rectAreaLTC2=ur.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=u;const _=i.hash;_.directionalLength===c&&_.pointLength===h&&_.spotLength===p&&_.rectAreaLength===f&&_.hemiLength===d&&_.numDirectionalShadows===m&&_.numPointShadows===g&&_.numSpotShadows===y||(i.directional.length=c,i.spot.length=p,i.rectArea.length=f,i.point.length=h,i.hemi.length=d,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=y,_.directionalLength=c,_.pointLength=h,_.spotLength=p,_.rectAreaLength=f,_.hemiLength=d,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=y,i.version=Mo++)},setupView:function(t,e){let n=0,r=0,l=0,u=0,c=0;const h=e.matrixWorldInverse;for(let e=0,p=t.length;e<p;e++){const p=t[e];if(p.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),t.direction.sub(o),t.direction.transformDirection(h),n++}else if(p.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(p.matrixWorld),t.position.applyMatrix4(h),t.direction.setFromMatrixPosition(p.matrixWorld),o.setFromMatrixPosition(p.target.matrixWorld),t.direction.sub(o),t.direction.transformDirection(h),l++}else if(p.isRectAreaLight){const t=i.rectArea[u];t.position.setFromMatrixPosition(p.matrixWorld),t.position.applyMatrix4(h),s.identity(),a.copy(p.matrixWorld),a.premultiply(h),s.extractRotation(a),t.halfWidth.set(.5*p.width,0,0),t.halfHeight.set(0,.5*p.height,0),t.halfWidth.applyMatrix4(s),t.halfHeight.applyMatrix4(s),u++}else if(p.isPointLight){const t=i.point[r];t.position.setFromMatrixPosition(p.matrixWorld),t.position.applyMatrix4(h),r++}else if(p.isHemisphereLight){const t=i.hemi[c];t.direction.setFromMatrixPosition(p.matrixWorld),t.direction.transformDirection(h),t.direction.normalize(),c++}}},state:i}}function Io(t,e){const n=new Co(t,e),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(t){n.setup(r,t)},setupLightsView:function(t){n.setupView(r,t)},pushLight:function(t){r.push(t)},pushShadow:function(t){i.push(t)}}}function Ao(t,e){let n=new WeakMap;return{get:function(r,i=0){let o;return!1===n.has(r)?(o=new Io(t,e),n.set(r,[o])):i>=n.get(r).length?(o=new Io(t,e),n.get(r).push(o)):o=n.get(r)[i],o},dispose:function(){n=new WeakMap}}}class Lo extends je{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Lo.prototype.isMeshDepthMaterial=!0;class Po extends je{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new It,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Ro(t,e,n){let r=new ir;const i=new gt,o=new gt,a=new Et,s=new Lo({depthPacking:3201}),l=new Po,u={},c=n.maxTextureSize,h={0:1,1:0,2:2},p=new Wn({uniforms:{shadow_pass:{value:null},resolution:{value:new gt},radius:{value:4},samples:{value:8}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),d=p.clone();d.defines.HORIZONTAL_PASS=1;const m=new wn;m.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Un(m,p),v=this;function _(n,r){const i=e.update(y);p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,p.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(r,null,i,p,y,null),d.uniforms.shadow_pass.value=n.mapPass.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,d.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(r,null,i,d,y,null)}function x(e,n,r,i,o,a,c){let p=null;const f=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(p=void 0!==f?f:!0===i.isPointLight?l:s,t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0){const t=p.uuid,e=r.uuid;let n=u[t];void 0===n&&(n={},u[t]=n);let i=n[e];void 0===i&&(i=p.clone(),n[e]=i),p=i}return p.visible=r.visible,p.wireframe=r.wireframe,p.side=3===c?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:h[r.side],p.alphaMap=r.alphaMap,p.alphaTest=r.alphaTest,p.clipShadows=r.clipShadows,p.clippingPlanes=r.clippingPlanes,p.clipIntersection=r.clipIntersection,p.displacementMap=r.displacementMap,p.displacementScale=r.displacementScale,p.displacementBias=r.displacementBias,p.wireframeLinewidth=r.wireframeLinewidth,p.linewidth=r.linewidth,!0===i.isPointLight&&!0===p.isMeshDistanceMaterial&&(p.referencePosition.setFromMatrixPosition(i.matrixWorld),p.nearDistance=o,p.farDistance=a),p}function b(n,i,o,a,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const r=e.update(n),i=n.material;if(Array.isArray(i)){const e=r.groups;for(let l=0,u=e.length;l<u;l++){const u=e[l],c=i[u.materialIndex];if(c&&c.visible){const e=x(n,0,c,a,o.near,o.far,s);t.renderBufferDirect(o,null,r,e,n,u)}}}else if(i.visible){const e=x(n,0,i,a,o.near,o.far,s);t.renderBufferDirect(o,null,r,e,n,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)b(l[t],i,o,a,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,n,s){if(!1===v.enabled)return;if(!1===v.autoUpdate&&!1===v.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),u=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),p=t.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(let l=0,u=e.length;l<u;l++){const u=e[l],h=u.shadow;if(void 0===h){console.warn("THREE.WebGLShadowMap:",u,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;i.copy(h.mapSize);const d=h.getFrameExtents();if(i.multiply(d),o.copy(h.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(o.x=Math.floor(c/d.x),i.x=o.x*d.x,h.mapSize.x=o.x),i.y>c&&(o.y=Math.floor(c/d.y),i.y=o.y*d.y,h.mapSize.y=o.y)),null===h.map&&!h.isPointLightShadow&&3===this.type){const t={minFilter:g,magFilter:g,format:T};h.map=new St(i.x,i.y,t),h.map.texture.name=u.name+".shadowMap",h.mapPass=new St(i.x,i.y,t),h.camera.updateProjectionMatrix()}if(null===h.map){const t={minFilter:f,magFilter:f,format:T};h.map=new St(i.x,i.y,t),h.map.texture.name=u.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const m=h.getViewportCount();for(let t=0;t<m;t++){const e=h.getViewport(t);a.set(o.x*e.x,o.y*e.y,o.x*e.z,o.y*e.w),p.viewport(a),h.updateMatrices(u,t),r=h.getFrustum(),b(n,s,h.camera,u,this.type)}h.isPointLightShadow||3!==this.type||_(h,s),h.needsUpdate=!1}v.needsUpdate=!1,t.setRenderTarget(l,u,h)}}function Do(t,e,r){const i=r.isWebGL2,o=new function(){let e=!1;const n=new Et;let r=null;const i=new Et(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),n.set(e,r,o,a),!1===i.equals(n)&&(t.clearColor(e,r,o,a),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){let e=!1,n=null,r=null,i=null;return{setTest:function(t){t?F(2929):B(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:default:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},s=new function(){let e=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,u=null;return{setTest:function(t){e||(t?F(2960):B(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,a){r===e&&i===n&&o===a||(t.stencilFunc(e,n,a),r=e,i=n,o=a)},setOp:function(e,n,r){a===e&&s===n&&l===r||(t.stencilOp(e,n,r),a=e,s=n,l=r)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,u=null}}};let l={},u=null,c={},h=null,p=!1,f=null,d=null,m=null,g=null,y=null,v=null,_=null,x=!1,b=null,w=null,E=null,S=null,M=null;const T=t.getParameter(35661);let C=!1,I=0;const A=t.getParameter(7938);-1!==A.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(A)[1]),C=I>=1):-1!==A.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),C=I>=2);let L=null,P={};const R=t.getParameter(3088),D=t.getParameter(2978),N=(new Et).fromArray(R),O=(new Et).fromArray(D);function k(e,n,r){const i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<r;e++)t.texImage2D(n+e,0,6408,1,1,0,6408,5121,i);return o}const z={};function F(e){!0!==l[e]&&(t.enable(e),l[e]=!0)}function B(e){!1!==l[e]&&(t.disable(e),l[e]=!1)}z[3553]=k(3553,3553,1),z[34067]=k(34067,34069,6),o.setClear(0,0,0,1),a.setClear(1),s.setClear(0),F(2929),a.setFunc(3),j(!1),H(1),F(2884),G(0);const U={[n]:32774,101:32778,102:32779};if(i)U[103]=32775,U[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(U[103]=t.MIN_EXT,U[104]=t.MAX_EXT)}const V={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function G(e,r,i,o,a,s,l,u){if(0!==e){if(!1===p&&(F(3042),p=!0),5===e)a=a||r,s=s||i,l=l||o,r===d&&a===y||(t.blendEquationSeparate(U[r],U[a]),d=r,y=a),i===m&&o===g&&s===v&&l===_||(t.blendFuncSeparate(V[i],V[o],V[s],V[l]),m=i,g=o,v=s,_=l),f=e,x=null;else if(e!==f||u!==x){if(d===n&&y===n||(t.blendEquation(32774),d=n,y=n),u)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}m=null,g=null,v=null,_=null,f=e,x=u}}else!0===p&&(B(3042),p=!1)}function j(e){b!==e&&(e?t.frontFace(2304):t.frontFace(2305),b=e)}function H(e){0!==e?(F(2884),e!==w&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):B(2884),w=e}function q(e,n,r){e?(F(32823),S===n&&M===r||(t.polygonOffset(n,r),S=n,M=r)):B(32823)}function W(e){void 0===e&&(e=33984+T-1),L!==e&&(t.activeTexture(e),L=e)}return{buffers:{color:o,depth:a,stencil:s},enable:F,disable:B,bindFramebuffer:function(e,n){return null===n&&null!==u&&(n=u),c[e]!==n&&(t.bindFramebuffer(e,n),c[e]=n,i&&(36009===e&&(c[36160]=n),36160===e&&(c[36009]=n)),!0)},bindXRFramebuffer:function(e){e!==u&&(t.bindFramebuffer(36160,e),u=e)},useProgram:function(e){return h!==e&&(t.useProgram(e),h=e,!0)},setBlending:G,setMaterial:function(t,e){2===t.side?B(2884):F(2884);let n=1===t.side;e&&(n=!n),j(n),1===t.blending&&!1===t.transparent?G(0):G(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),o.setMask(t.colorWrite);const r=t.stencilWrite;s.setTest(r),r&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?F(32926):B(32926)},setFlipSided:j,setCullFace:H,setLineWidth:function(e){e!==E&&(C&&t.lineWidth(e),E=e)},setPolygonOffset:q,setScissorTest:function(t){t?F(3089):B(3089)},activeTexture:W,bindTexture:function(e,n){null===L&&W();let r=P[L];void 0===r&&(r={type:void 0,texture:void 0},P[L]=r),r.type===e&&r.texture===n||(t.bindTexture(e,n||z[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=P[L];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===N.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),N.copy(e))},viewport:function(e){!1===O.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),O.copy(e))},reset:function(){t.disable(3042),t.disable(2884),t.disable(2929),t.disable(32823),t.disable(3089),t.disable(2960),t.disable(32926),t.blendEquation(32774),t.blendFunc(1,0),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(513),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(519,0,4294967295),t.stencilOp(7680,7680,7680),t.clearStencil(0),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.activeTexture(33984),t.bindFramebuffer(36160,null),!0===i&&(t.bindFramebuffer(36009,null),t.bindFramebuffer(36008,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),l={},L=null,P={},u=null,c={},h=null,p=!1,f=null,d=null,m=null,g=null,y=null,v=null,_=null,x=!1,b=null,w=null,E=null,S=null,M=null,N.set(0,0,t.canvas.width,t.canvas.height),O.set(0,0,t.canvas.width,t.canvas.height),o.reset(),a.reset(),s.reset()}}}function No(t,e,n,r,i,o,a){const s=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,_=i.maxTextureSize,A=i.maxSamples,L=new WeakMap;let P,R=!1;try{R="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function D(t,e){return R?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function N(t,e,n,r){let i=1;if((t.width>r||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const r=e?dt:Math.floor,o=r(i*t.width),a=r(i*t.height);void 0===P&&(P=D(o,a));const s=n?D(o,a):P;return s.width=o,s.height=a,s.getContext("2d").drawImage(t,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+a+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function O(t){return pt(t.width)&&pt(t.height)}function k(t,e){return t.generateMipmaps&&e&&t.minFilter!==f&&t.minFilter!==g}function z(e,n,i,o,a=1){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log2(Math.max(i,o,a))}function F(n,r,i){if(!1===s)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=r;return 6403===r&&(5126===i&&(o=33326),5131===i&&(o=33325),5121===i&&(o=33321)),6407===r&&(5126===i&&(o=34837),5131===i&&(o=34843),5121===i&&(o=32849)),6408===r&&(5126===i&&(o=34836),5131===i&&(o=34842),5121===i&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||e.get("EXT_color_buffer_float"),o}function B(t){return t===f||t===d||t===m?9728:9729}function U(e){const n=e.target;n.removeEventListener("dispose",U),function(e){const n=r.get(e);void 0!==n.__webglInit&&(t.deleteTexture(n.__webglTexture),r.remove(e))}(n),n.isVideoTexture&&L.delete(n),a.memory.textures--}function V(e){const n=e.target;n.removeEventListener("dispose",V),function(e){const n=e.texture,i=r.get(e),o=r.get(n);if(e){if(void 0!==o.__webglTexture&&(t.deleteTexture(o.__webglTexture),a.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,i=n.length;e<i;e++){const i=r.get(n[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),r.remove(n[e])}r.remove(n),r.remove(e)}}(n)}let G=0;function j(t,e){const i=r.get(t);if(t.isVideoTexture&&function(t){const e=a.render.frame;L.get(t)!==e&&(L.set(t,e),t.update())}(t),t.version>0&&i.__version!==t.version){const n=t.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void Y(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function H(e,i){const a=r.get(e);e.version>0&&a.__version!==e.version?function(e,r,i){if(6!==r.image.length)return;Z(e,r),n.activeTexture(33984+i),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const a=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),l=r.image[0]&&r.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=a||l?l?r.image[t].image:r.image[t]:N(r.image[t],!1,!0,u);const h=c[0],p=O(h)||s,f=o.convert(r.format),d=o.convert(r.type),m=F(r.internalFormat,f,d);let g;if(X(34067,r,p),a){for(let t=0;t<6;t++){g=c[t].mipmaps;for(let e=0;e<g.length;e++){const i=g[e];r.format!==T&&r.format!==M?null!==f?n.compressedTexImage2D(34069+t,e,m,i.width,i.height,0,i.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+t,e,m,i.width,i.height,0,f,d,i.data)}}e.__maxMipLevel=g.length-1}else{g=r.mipmaps;for(let t=0;t<6;t++)if(l){n.texImage2D(34069+t,0,m,c[t].width,c[t].height,0,f,d,c[t].data);for(let e=0;e<g.length;e++){const r=g[e].image[t].image;n.texImage2D(34069+t,e+1,m,r.width,r.height,0,f,d,r.data)}}else{n.texImage2D(34069+t,0,m,f,d,c[t]);for(let e=0;e<g.length;e++){const r=g[e];n.texImage2D(34069+t,e+1,m,f,d,r.image[t])}}e.__maxMipLevel=g.length}k(r,p)&&z(34067,r,h.width,h.height),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}(a,e,i):(n.activeTexture(33984+i),n.bindTexture(34067,a.__webglTexture))}const q={[c]:10497,[h]:33071,[p]:33648},W={[f]:9728,[d]:9984,[m]:9986,[g]:9729,[y]:9985,[v]:9987};function X(n,o,a){if(a?(t.texParameteri(n,10242,q[o.wrapS]),t.texParameteri(n,10243,q[o.wrapT]),32879!==n&&35866!==n||t.texParameteri(n,32882,q[o.wrapR]),t.texParameteri(n,10240,W[o.magFilter]),t.texParameteri(n,10241,W[o.minFilter])):(t.texParameteri(n,10242,33071),t.texParameteri(n,10243,33071),32879!==n&&35866!==n||t.texParameteri(n,32882,33071),o.wrapS===h&&o.wrapT===h||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(n,10240,B(o.magFilter)),t.texParameteri(n,10241,B(o.minFilter)),o.minFilter!==f&&o.minFilter!==g&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(o.type===w&&!1===e.has("OES_texture_float_linear"))return;if(!1===s&&o.type===E&&!1===e.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function Z(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",U),e.__webglTexture=t.createTexture(),a.memory.textures++)}function Y(e,r,i){let a=3553;r.isDataTexture2DArray&&(a=35866),r.isDataTexture3D&&(a=32879),Z(e,r),n.activeTexture(33984+i),n.bindTexture(a,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!s&&(t.wrapS!==h||t.wrapT!==h||t.minFilter!==f&&t.minFilter!==g)}(r)&&!1===O(r.image),u=N(r.image,l,!1,_),c=O(u)||s,p=o.convert(r.format);let d,m=o.convert(r.type),y=F(r.internalFormat,p,m);X(a,r,c);const v=r.mipmaps;if(r.isDepthTexture)y=6402,s?y=r.type===w?36012:r.type===b?33190:r.type===S?35056:33189:r.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===C&&6402===y&&r.type!==x&&r.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=x,m=o.convert(r.type)),r.format===I&&6402===y&&(y=34041,r.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=S,m=o.convert(r.type))),n.texImage2D(3553,0,y,u.width,u.height,0,p,m,null);else if(r.isDataTexture)if(v.length>0&&c){for(let t=0,e=v.length;t<e;t++)d=v[t],n.texImage2D(3553,t,y,d.width,d.height,0,p,m,d.data);r.generateMipmaps=!1,e.__maxMipLevel=v.length-1}else n.texImage2D(3553,0,y,u.width,u.height,0,p,m,u.data),e.__maxMipLevel=0;else if(r.isCompressedTexture){for(let t=0,e=v.length;t<e;t++)d=v[t],r.format!==T&&r.format!==M?null!==p?n.compressedTexImage2D(3553,t,y,d.width,d.height,0,d.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,t,y,d.width,d.height,0,p,m,d.data);e.__maxMipLevel=v.length-1}else if(r.isDataTexture2DArray)n.texImage3D(35866,0,y,u.width,u.height,u.depth,0,p,m,u.data),e.__maxMipLevel=0;else if(r.isDataTexture3D)n.texImage3D(32879,0,y,u.width,u.height,u.depth,0,p,m,u.data),e.__maxMipLevel=0;else if(v.length>0&&c){for(let t=0,e=v.length;t<e;t++)d=v[t],n.texImage2D(3553,t,y,p,m,d);r.generateMipmaps=!1,e.__maxMipLevel=v.length-1}else n.texImage2D(3553,0,y,p,m,u),e.__maxMipLevel=0;k(r,c)&&z(a,r,u.width,u.height),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}function J(e,i,a,s,l){const u=o.convert(a.format),c=o.convert(a.type),h=F(a.internalFormat,u,c);32879===l||35866===l?n.texImage3D(l,0,h,i.width,i.height,i.depth,0,u,c,null):n.texImage2D(l,0,h,i.width,i.height,0,u,c,null),n.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,s,l,r.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function K(e,n,r){if(t.bindRenderbuffer(36161,e),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r){const e=n.depthTexture;e&&e.isDepthTexture&&(e.type===w?i=36012:e.type===b&&(i=33190));const r=Q(n);t.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else t.renderbufferStorage(36161,i,n.width,n.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(n.depthBuffer&&n.stencilBuffer){if(r){const e=Q(n);t.renderbufferStorageMultisample(36161,e,35056,n.width,n.height)}else t.renderbufferStorage(36161,34041,n.width,n.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=!0===n.isWebGLMultipleRenderTargets?n.texture[0]:n.texture,i=o.convert(e.format),a=o.convert(e.type),s=F(e.internalFormat,i,a);if(r){const e=Q(n);t.renderbufferStorageMultisample(36161,e,s,n.width,n.height)}else t.renderbufferStorage(36161,s,n.width,n.height)}t.bindRenderbuffer(36161,null)}function Q(t){return s&&t.isWebGLMultisampleRenderTarget?Math.min(A,t.samples):0}let $=!1,tt=!1;this.allocateTextureUnit=function(){const t=G;return t>=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),G+=1,t},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?Y(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?Y(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(e){const l=e.texture,u=r.get(e),c=r.get(l);e.addEventListener("dispose",V),!0!==e.isWebGLMultipleRenderTargets&&(c.__webglTexture=t.createTexture(),c.__version=l.version,a.memory.textures++);const h=!0===e.isWebGLCubeRenderTarget,p=!0===e.isWebGLMultipleRenderTargets,f=!0===e.isWebGLMultisampleRenderTarget,d=l.isDataTexture3D||l.isDataTexture2DArray,m=O(e)||s;if(!s||l.format!==M||l.type!==w&&l.type!==E||(l.format=T,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){u.__webglFramebuffer=[];for(let e=0;e<6;e++)u.__webglFramebuffer[e]=t.createFramebuffer()}else if(u.__webglFramebuffer=t.createFramebuffer(),p)if(i.drawBuffers){const n=e.texture;for(let e=0,i=n.length;e<i;e++){const i=r.get(n[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(f)if(s){u.__webglMultisampledFramebuffer=t.createFramebuffer(),u.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,u.__webglColorRenderbuffer);const r=o.convert(l.format),i=o.convert(l.type),a=F(l.internalFormat,r,i),s=Q(e);t.renderbufferStorageMultisample(36161,s,a,e.width,e.height),n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,u.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(u.__webglDepthRenderbuffer=t.createRenderbuffer(),K(u.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h){n.bindTexture(34067,c.__webglTexture),X(34067,l,m);for(let t=0;t<6;t++)J(u.__webglFramebuffer[t],e,l,36064,34069+t);k(l,m)&&z(34067,l,e.width,e.height),n.unbindTexture()}else if(p){const t=e.texture;for(let i=0,o=t.length;i<o;i++){const o=t[i],a=r.get(o);n.bindTexture(3553,a.__webglTexture),X(3553,o,m),J(u.__webglFramebuffer,e,o,36064+i,3553),k(o,m)&&z(3553,o,e.width,e.height)}n.unbindTexture()}else{let t=3553;d&&(s?t=l.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),n.bindTexture(t,c.__webglTexture),X(t,l,m),J(u.__webglFramebuffer,e,l,36064,t),k(l,m)&&z(t,l,e.width,e.height,e.depth),n.unbindTexture()}e.depthBuffer&&function(e){const i=r.get(e),o=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),j(i.depthTexture,0);const o=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===C)t.framebufferTexture2D(36160,36096,3553,o,0);else{if(i.depthTexture.format!==I)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,o,0)}}(i.__webglFramebuffer,e)}else if(o){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=t.createRenderbuffer(),K(i.__webglDepthbuffer[r],e,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),K(i.__webglDepthbuffer,e,!1);n.bindFramebuffer(36160,null)}(e)},this.updateRenderTargetMipmap=function(t){const e=O(t)||s,i=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let o=0,a=i.length;o<a;o++){const a=i[o];if(k(a,e)){const e=t.isWebGLCubeRenderTarget?34067:3553,i=r.get(a).__webglTexture;n.bindTexture(e,i),z(e,a,t.width,t.height),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(s){const i=e.width,o=e.height;let a=16384;e.depthBuffer&&(a|=256),e.stencilBuffer&&(a|=1024);const s=r.get(e);n.bindFramebuffer(36008,s.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,s.__webglFramebuffer),t.blitFramebuffer(0,0,i,o,0,0,i,o,a,9728),n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,s.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$=!0),t=t.texture),j(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===tt&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),tt=!0),t=t.texture),H(t,e)}}function Oo(t,e,n){const r=n.isWebGL2;return{convert:function(t){let n;if(t===_)return 5121;if(1017===t)return 32819;if(1018===t)return 32820;if(1019===t)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(t===x)return 5123;if(1013===t)return 5124;if(t===b)return 5125;if(t===w)return 5126;if(t===E)return r?5131:null!==(n=e.get("OES_texture_half_float"))?n.HALF_FLOAT_OES:null;if(1021===t)return 6406;if(t===M)return 6407;if(t===T)return 6408;if(1024===t)return 6409;if(1025===t)return 6410;if(t===C)return 6402;if(t===I)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(t===A||t===L||t===P||t===R){if(null===(n=e.get("WEBGL_compressed_texture_s3tc")))return null;if(t===A)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===L)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===P)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===R)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===D||t===N||t===O||t===k){if(null===(n=e.get("WEBGL_compressed_texture_pvrtc")))return null;if(t===D)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===N)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===O)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===k)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===t)return null!==(n=e.get("WEBGL_compressed_texture_etc1"))?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((t===z||t===F)&&null!==(n=e.get("WEBGL_compressed_texture_etc"))){if(t===z)return n.COMPRESSED_RGB8_ETC2;if(t===F)return n.COMPRESSED_RGBA8_ETC2_EAC}return 37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t||37840===t||37841===t||37842===t||37843===t||37844===t||37845===t||37846===t||37847===t||37848===t||37849===t||37850===t||37851===t||37852===t||37853===t?null!==(n=e.get("WEBGL_compressed_texture_astc"))?t:null:36492===t?null!==(n=e.get("EXT_texture_compression_bptc"))?t:null:t===S?r?34042:null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}Po.prototype.isMeshDistanceMaterial=!0;class ko extends Zn{constructor(t=[]){super(),this.cameras=t}}ko.prototype.isArrayCamera=!0;class zo extends Le{constructor(){super(),this.type="Group"}}zo.prototype.isGroup=!0;const Fo={type:"move"};class Bo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new zo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new zo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new It,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new It),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new zo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new It,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new It),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let r=null,i=null,o=null;const a=this._targetRay,s=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState)if(null!==a&&null!==(r=e.getPose(t.targetRaySpace,n))&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Fo)),l&&t.hand){o=!0;for(const r of t.hand.values()){const t=e.getJointPose(r,n);if(void 0===l.joints[r.jointName]){const t=new zo;t.matrixAutoUpdate=!1,t.visible=!1,l.joints[r.jointName]=t,l.add(t)}const i=l.joints[r.jointName];null!==t&&(i.matrix.fromArray(t.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=t.radius),i.visible=null!==t}const r=l.joints["index-finger-tip"],i=l.joints["thumb-tip"],a=r.position.distanceTo(i.position),s=.02,u=.005;l.inputState.pinching&&a>s+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=s-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&null!==(i=e.getPose(t.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1);return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class Uo extends rt{constructor(t,e){super();const n=this,r=t.state;let i=null,o=1,a=null,s="local-floor",l=null,u=null,c=null,h=null,p=null,f=!1,d=null,m=null,g=null,y=null,v=null,_=null;const x=[],b=new Map,w=new Zn;w.layers.enable(1),w.viewport=new Et;const E=new Zn;E.layers.enable(2),E.viewport=new Et;const S=[w,E],M=new ko;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;function I(t){const e=b.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function A(){b.forEach((function(t,e){t.disconnect(e)})),b.clear(),T=null,C=null,r.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),c&&e.deleteFramebuffer(c),d&&e.deleteFramebuffer(d),m&&e.deleteRenderbuffer(m),g&&e.deleteRenderbuffer(g),c=null,d=null,m=null,g=null,p=null,h=null,u=null,i=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function L(t){const e=i.inputSources;for(let t=0;t<x.length;t++)b.set(e[t],x[t]);for(let e=0;e<t.removed.length;e++){const n=t.removed[e],r=b.get(n);r&&(r.dispatchEvent({type:"disconnected",data:n}),b.delete(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e],r=b.get(n);r&&r.dispatchEvent({type:"connected",data:n})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new Bo,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new Bo,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new Bo,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){o=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){s=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getBaseLayer=function(){return null!==h?h:p},this.getBinding=function(){return u},this.getFrame=function(){return y},this.getSession=function(){return i},this.setSession=async function(t){if(null!==(i=t)){i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",A),i.addEventListener("inputsourceschange",L);const t=e.getContextAttributes();if(!0!==t.xrCompatible&&await e.makeXRCompatible(),void 0===i.renderState.layers){const n={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:o};p=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:p})}else if(e instanceof WebGLRenderingContext){const n={antialias:!0,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:o};p=new XRWebGLLayer(i,e,n),i.updateRenderState({layers:[p]})}else{f=t.antialias;let n=null;t.depth&&(_=256,t.stencil&&(_|=1024),v=t.stencil?33306:36096,n=t.stencil?35056:33190);const a={colorFormat:t.alpha?32856:32849,depthFormat:n,scaleFactor:o};u=new XRWebGLBinding(i,e),h=u.createProjectionLayer(a),c=e.createFramebuffer(),i.updateRenderState({layers:[h]}),f&&(d=e.createFramebuffer(),m=e.createRenderbuffer(),e.bindRenderbuffer(36161,m),e.renderbufferStorageMultisample(36161,4,32856,h.textureWidth,h.textureHeight),r.bindFramebuffer(36160,d),e.framebufferRenderbuffer(36160,36064,36161,m),e.bindRenderbuffer(36161,null),null!==n&&(g=e.createRenderbuffer(),e.bindRenderbuffer(36161,g),e.renderbufferStorageMultisample(36161,4,n,h.textureWidth,h.textureHeight),e.framebufferRenderbuffer(36160,v,36161,g),e.bindRenderbuffer(36161,null)),r.bindFramebuffer(36160,null))}a=await i.requestReferenceSpace(s),O.setContext(i),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const P=new It,R=new It;function D(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;M.near=E.near=w.near=t.near,M.far=E.far=w.far=t.far,T===M.near&&C===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);const e=t.parent,n=M.cameras;D(M,e);for(let t=0;t<n.length;t++)D(n[t],e);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),t.position.copy(M.position),t.quaternion.copy(M.quaternion),t.scale.copy(M.scale),t.matrix.copy(M.matrix),t.matrixWorld.copy(M.matrixWorld);const r=t.children;for(let t=0,e=r.length;t<e;t++)r[t].updateMatrixWorld(!0);2===n.length?function(t,e,n){P.setFromMatrixPosition(e.matrixWorld),R.setFromMatrixPosition(n.matrixWorld);const r=P.distanceTo(R),i=e.projectionMatrix.elements,o=n.projectionMatrix.elements,a=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],u=(i[9]-1)/i[5],c=(i[8]-1)/i[0],h=(o[8]+1)/o[0],p=a*c,f=a*h,d=r/(-c+h),m=d*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(d),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=a+d,y=s+d,v=p-m,_=f+(r-m),x=l*s/y*g,b=u*s/y*g;t.projectionMatrix.makePerspective(v,_,x,b,g,y)}(M,w,E):M.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){return null!==h?h.fixedFoveation:null!==p?p.fixedFoveation:void 0},this.setFoveation=function(t){null!==h&&(h.fixedFoveation=t),null!==p&&void 0!==p.fixedFoveation&&(p.fixedFoveation=t)};let N=null;const O=new or;O.setAnimationLoop((function(t,n){if(l=n.getViewerPose(a),y=n,null!==l){const t=l.views;null!==p&&r.bindXRFramebuffer(p.framebuffer);let n=!1;t.length!==M.cameras.length&&(M.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const o=t[i];let a=null;if(null!==p)a=p.getViewport(o);else{const t=u.getViewSubImage(h,o);r.bindXRFramebuffer(c),void 0!==t.depthStencilTexture&&e.framebufferTexture2D(36160,v,3553,t.depthStencilTexture,0),e.framebufferTexture2D(36160,36064,3553,t.colorTexture,0),a=t.viewport}const s=S[i];s.matrix.fromArray(o.transform.matrix),s.projectionMatrix.fromArray(o.projectionMatrix),s.viewport.set(a.x,a.y,a.width,a.height),0===i&&M.matrix.copy(s.matrix),!0===n&&M.cameras.push(s)}f&&(r.bindXRFramebuffer(d),null!==_&&e.clear(_))}const o=i.inputSources;for(let t=0;t<x.length;t++){const e=x[t],r=o[t];e.update(r,n,a)}if(N&&N(t,n),f){const t=h.textureWidth,n=h.textureHeight;r.bindFramebuffer(36008,d),r.bindFramebuffer(36009,c),e.invalidateFramebuffer(36008,[v]),e.invalidateFramebuffer(36009,[v]),e.blitFramebuffer(0,0,t,n,0,0,t,n,16384,9728),e.invalidateFramebuffer(36008,[36064]),r.bindFramebuffer(36008,null),r.bindFramebuffer(36009,null),r.bindFramebuffer(36160,d)}y=null})),this.setAnimationLoop=function(t){N=t},this.dispose=function(){}}}function Vo(t){function e(e,n){e.opacity.value=n.opacity,n.color&&e.diffuse.value.copy(n.color),n.emissive&&e.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(e.map.value=n.map),n.alphaMap&&(e.alphaMap.value=n.alphaMap),n.specularMap&&(e.specularMap.value=n.specularMap),n.alphaTest>0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;if(r){e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.ior.value=n.ior,e.refractionRatio.value=n.refractionRatio;const i=t.get(r).__maxMipLevel;void 0!==i&&(e.maxMipLevel.value=i)}let i,o;n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?i=n.map:n.specularMap?i=n.specularMap:n.displacementMap?i=n.displacementMap:n.normalMap?i=n.normalMap:n.bumpMap?i=n.bumpMap:n.roughnessMap?i=n.roughnessMap:n.metalnessMap?i=n.metalnessMap:n.alphaMap?i=n.alphaMap:n.emissiveMap?i=n.emissiveMap:n.clearcoatMap?i=n.clearcoatMap:n.clearcoatNormalMap?i=n.clearcoatNormalMap:n.clearcoatRoughnessMap?i=n.clearcoatRoughnessMap:n.specularIntensityMap?i=n.specularIntensityMap:n.specularTintMap?i=n.specularTintMap:n.transmissionMap?i=n.transmissionMap:n.thicknessMap&&(i=n.thicknessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),n.aoMap?o=n.aoMap:n.lightMap&&(o=n.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uv2Transform.value.copy(o.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,i,o,a){r.isMeshBasicMaterial?e(t,r):r.isMeshLambertMaterial?(e(t,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,r)):r.isMeshToonMaterial?(e(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshPhongMaterial?(e(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshStandardMaterial?(e(t,r),r.isMeshPhysicalMaterial?function(t,e,r){n(t,e),t.ior.value=e.ior,e.sheenTint&&t.sheenTint.value.copy(e.sheenTint),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate())),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=r.texture,t.transmissionSamplerSize.value.set(r.width,r.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationTint.value.copy(e.attenuationTint)),t.specularIntensity.value=e.specularIntensity,t.specularTint.value.copy(e.specularTint),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap),e.specularTintMap&&(t.specularTintMap.value=e.specularTintMap)}(t,r,a):n(t,r)):r.isMeshMatcapMaterial?(e(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDepthMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDistanceMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?(e(t,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){let i;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?i=e.map:e.alphaMap&&(i=e.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,r,i,o):r.isSpriteMaterial?function(t,e){let n;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?n=e.map:e.alphaMap&&(n=e.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Go(t={}){const e=void 0!==t.canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,u=void 0!==t.powerPreference?t.powerPreference:"default",c=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let p=null,d=null;const m=[],g=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=X,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const y=this;let x=!1,b=0,S=0,M=null,C=-1,I=null;const A=new Et,L=new Et;let P=null,R=e.width,D=e.height,N=1,O=null,k=null;const z=new Et(0,0,R,D),F=new Et(0,0,R,D);let B=!1;const U=[],V=new ir;let G=!1,j=!1,H=null;const q=new oe,W=new It,Z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===M?N:1}let J,K,Q,$,tt,et,nt,rt,it,ot,at,st,lt,ut,ct,ht,pt,ft,dt,mt,gt,yt,vt,_t=n;function xt(t,n){for(let r=0;r<t.length;r++){const i=t[r],o=e.getContext(i,n);if(null!==o)return o}return null}try{const t={alpha:r,depth:i,stencil:o,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:c};if(e.addEventListener("webglcontextlost",Mt,!1),e.addEventListener("webglcontextrestored",Ct,!1),null===_t){const e=["webgl2","webgl","experimental-webgl"];if(!0===y.isWebGL1Renderer&&e.shift(),null===(_t=xt(e,t)))throw xt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===_t.getShaderPrecisionFormat&&(_t.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function bt(){J=new Br(_t),K=new dr(_t,J,t),J.init(K),yt=new Oo(_t,J,K),Q=new Do(_t,J,K),U[0]=1029,$=new Gr(_t),tt=new _o,et=new No(_t,J,Q,tt,K,yt,$),nt=new gr(y),rt=new Fr(y),it=new ar(_t,K),vt=new pr(_t,J,it,K),ot=new Ur(_t,it,$,vt),at=new Wr(_t,ot,it,$),dt=new qr(_t),ht=new mr(tt),st=new vo(y,nt,rt,J,K,vt,ht),lt=new Vo(tt),ut=new Eo(tt),ct=new Ao(J,K),ft=new hr(y,nt,Q,at,s),pt=new Ro(y,at,K),mt=new fr(_t,J,$,K),gt=new Vr(_t,J,$,K),$.programs=st.programs,y.capabilities=K,y.extensions=J,y.properties=tt,y.renderLists=ut,y.shadowMap=pt,y.state=Q,y.info=$}bt();const wt=new Uo(y,_t);function Mt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function Ct(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const t=$.autoReset,e=pt.enabled,n=pt.autoUpdate,r=pt.needsUpdate,i=pt.type;bt(),$.autoReset=t,pt.enabled=e,pt.autoUpdate=n,pt.needsUpdate=r,pt.type=i}function At(t){const e=t.target;e.removeEventListener("dispose",At),function(t){(function(t){const e=tt.get(t).programs;void 0!==e&&e.forEach((function(t){st.releaseProgram(t)}))})(t),tt.remove(t)}(e)}this.xr=wt,this.getContext=function(){return _t},this.getContextAttributes=function(){return _t.getContextAttributes()},this.forceContextLoss=function(){const t=J.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=J.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return N},this.setPixelRatio=function(t){void 0!==t&&(N=t,this.setSize(R,D,!1))},this.getSize=function(t){return t.set(R,D)},this.setSize=function(t,n,r){wt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=t,D=n,e.width=Math.floor(t*N),e.height=Math.floor(n*N),!1!==r&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(R*N,D*N).floor()},this.setDrawingBufferSize=function(t,n,r){R=t,D=n,N=r,e.width=Math.floor(t*r),e.height=Math.floor(n*r),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(z)},this.setViewport=function(t,e,n,r){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,n,r),Q.viewport(A.copy(z).multiplyScalar(N).floor())},this.getScissor=function(t){return t.copy(F)},this.setScissor=function(t,e,n,r){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,n,r),Q.scissor(L.copy(F).multiplyScalar(N).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){Q.setScissorTest(B=t)},this.setOpaqueSort=function(t){O=t},this.setTransparentSort=function(t){k=t},this.getClearColor=function(t){return t.copy(ft.getClearColor())},this.setClearColor=function(){ft.setClearColor.apply(ft,arguments)},this.getClearAlpha=function(){return ft.getClearAlpha()},this.setClearAlpha=function(){ft.setClearAlpha.apply(ft,arguments)},this.clear=function(t,e,n){let r=0;(void 0===t||t)&&(r|=16384),(void 0===e||e)&&(r|=256),(void 0===n||n)&&(r|=1024),_t.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Mt,!1),e.removeEventListener("webglcontextrestored",Ct,!1),ut.dispose(),ct.dispose(),tt.dispose(),nt.dispose(),rt.dispose(),at.dispose(),vt.dispose(),wt.dispose(),wt.removeEventListener("sessionstart",Pt),wt.removeEventListener("sessionend",Rt),H&&(H.dispose(),H=null),Dt.stop()},this.renderBufferImmediate=function(t,e){vt.initAttributes();const n=tt.get(t);t.hasPositions&&!n.position&&(n.position=_t.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=_t.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=_t.createBuffer()),t.hasColors&&!n.color&&(n.color=_t.createBuffer());const r=e.getAttributes();t.hasPositions&&(_t.bindBuffer(34962,n.position),_t.bufferData(34962,t.positionArray,35048),vt.enableAttribute(r.position.location),_t.vertexAttribPointer(r.position.location,3,5126,!1,0,0)),t.hasNormals&&(_t.bindBuffer(34962,n.normal),_t.bufferData(34962,t.normalArray,35048),vt.enableAttribute(r.normal.location),_t.vertexAttribPointer(r.normal.location,3,5126,!1,0,0)),t.hasUvs&&(_t.bindBuffer(34962,n.uv),_t.bufferData(34962,t.uvArray,35048),vt.enableAttribute(r.uv.location),_t.vertexAttribPointer(r.uv.location,2,5126,!1,0,0)),t.hasColors&&(_t.bindBuffer(34962,n.color),_t.bufferData(34962,t.colorArray,35048),vt.enableAttribute(r.color.location),_t.vertexAttribPointer(r.color.location,3,5126,!1,0,0)),vt.disableUnusedAttributes(),_t.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,n,r,i,o){null===e&&(e=Z);const a=i.isMesh&&i.matrixWorld.determinant()<0,s=Bt(t,e,r,i);Q.setMaterial(r,a);let l=n.index;const u=n.attributes.position;if(null===l){if(void 0===u||0===u.count)return}else if(0===l.count)return;let c,h=1;!0===r.wireframe&&(l=ot.getWireframeAttribute(n),h=2),void 0===n.morphAttributes.position&&void 0===n.morphAttributes.normal||dt.update(i,n,r,s),vt.setup(i,r,s,n,l);let p=mt;null!==l&&(c=it.get(l),(p=gt).setIndex(c));const f=null!==l?l.count:u.count,d=n.drawRange.start*h,m=n.drawRange.count*h,g=null!==o?o.start*h:0,y=null!==o?o.count*h:1/0,v=Math.max(d,g),_=Math.min(f,d+m,g+y)-1,x=Math.max(0,_-v+1);if(0!==x){if(i.isMesh)!0===r.wireframe?(Q.setLineWidth(r.wireframeLinewidth*Y()),p.setMode(1)):p.setMode(4);else if(i.isLine){let t=r.linewidth;void 0===t&&(t=1),Q.setLineWidth(t*Y()),i.isLineSegments?p.setMode(1):i.isLineLoop?p.setMode(2):p.setMode(3)}else i.isPoints?p.setMode(0):i.isSprite&&p.setMode(4);if(i.isInstancedMesh)p.renderInstances(v,x,i.count);else if(n.isInstancedBufferGeometry){const t=Math.min(n.instanceCount,n._maxInstanceCount);p.renderInstances(v,x,t)}else p.render(v,x)}},this.compile=function(t,e){(d=ct.get(t)).init(),g.push(d),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(y.physicallyCorrectLights),t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++)zt(n[r],t,e);else zt(n,t,e)})),g.pop(),d=null};let Lt=null;function Pt(){Dt.stop()}function Rt(){Dt.start()}const Dt=new or;function Nt(t,e,n,r){const i=t.opaque,o=t.transmissive,s=t.transparent;d.setupLightsView(n),o.length>0&&function(t,e,n){if(null===H){const t=!0===a&&!0===K.isWebGL2;H=new(t?Tt:St)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(E)?E:_,minFilter:v,magFilter:f,wrapS:h,wrapT:h})}const r=y.getRenderTarget();y.setRenderTarget(H),y.clear();const i=y.toneMapping;y.toneMapping=0,Ot(t,e,n),y.toneMapping=i,et.updateMultisampleRenderTarget(H),et.updateRenderTargetMipmap(H),y.setRenderTarget(r)}(i,e,n),r&&Q.viewport(A.copy(r)),i.length>0&&Ot(i,e,n),o.length>0&&Ot(o,e,n),s.length>0&&Ot(s,e,n)}function Ot(t,e,n){const r=!0===e.isScene?e.overrideMaterial:null;for(let i=0,o=t.length;i<o;i++){const o=t[i],a=o.object,s=o.geometry,l=null===r?o.material:r,u=o.group;a.layers.test(n.layers)&&kt(a,e,n,s,l,u)}}function kt(t,e,n,r,i,o){if(t.onBeforeRender(y,e,n,r,i,o),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){const r=Bt(n,e,i,t);Q.setMaterial(i),vt.reset(),function(t,e){t.render((function(t){y.renderBufferImmediate(t,e)}))}(t,r)}else!0===i.transparent&&2===i.side?(i.side=1,i.needsUpdate=!0,y.renderBufferDirect(n,e,r,i,t,o),i.side=0,i.needsUpdate=!0,y.renderBufferDirect(n,e,r,i,t,o),i.side=2):y.renderBufferDirect(n,e,r,i,t,o);t.onAfterRender(y,e,n,r,i,o)}function zt(t,e,n){!0!==e.isScene&&(e=Z);const r=tt.get(t),i=d.state.lights,o=d.state.shadowsArray,a=i.state.version,s=st.getParameters(t,i.state,o,e,n),l=st.getProgramCacheKey(s);let u=r.programs;r.environment=t.isMeshStandardMaterial?e.environment:null,r.fog=e.fog,r.envMap=(t.isMeshStandardMaterial?rt:nt).get(t.envMap||r.environment),void 0===u&&(t.addEventListener("dispose",At),u=new Map,r.programs=u);let c=u.get(l);if(void 0!==c){if(r.currentProgram===c&&r.lightsStateVersion===a)return Ft(t,s),c}else s.uniforms=st.getUniforms(t),t.onBuild(s,y),t.onBeforeCompile(s,y),c=st.acquireProgram(s,l),u.set(l,c),r.uniforms=s.uniforms;const h=r.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(h.clippingPlanes=ht.uniform),Ft(t,s),r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=a,r.needsLights&&(h.ambientLightColor.value=i.state.ambient,h.lightProbe.value=i.state.probe,h.directionalLights.value=i.state.directional,h.directionalLightShadows.value=i.state.directionalShadow,h.spotLights.value=i.state.spot,h.spotLightShadows.value=i.state.spotShadow,h.rectAreaLights.value=i.state.rectArea,h.ltc_1.value=i.state.rectAreaLTC1,h.ltc_2.value=i.state.rectAreaLTC2,h.pointLights.value=i.state.point,h.pointLightShadows.value=i.state.pointShadow,h.hemisphereLights.value=i.state.hemi,h.directionalShadowMap.value=i.state.directionalShadowMap,h.directionalShadowMatrix.value=i.state.directionalShadowMatrix,h.spotShadowMap.value=i.state.spotShadowMap,h.spotShadowMatrix.value=i.state.spotShadowMatrix,h.pointShadowMap.value=i.state.pointShadowMap,h.pointShadowMatrix.value=i.state.pointShadowMatrix);const p=c.getUniforms(),f=Ji.seqWithValue(p.seq,h);return r.currentProgram=c,r.uniformsList=f,c}function Ft(t,e){const n=tt.get(t);n.outputEncoding=e.outputEncoding,n.instancing=e.instancing,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents}function Bt(t,e,n,r){!0!==e.isScene&&(e=Z),et.resetTextureUnits();const i=e.fog,o=n.isMeshStandardMaterial?e.environment:null,a=null===M?y.outputEncoding:M.texture.encoding,s=(n.isMeshStandardMaterial?rt:nt).get(n.envMap||o),l=!0===n.vertexColors&&!!r.geometry&&!!r.geometry.attributes.color&&4===r.geometry.attributes.color.itemSize,u=!!r.geometry&&!!r.geometry.attributes.tangent,c=!!r.geometry&&!!r.geometry.morphAttributes.position,h=!!r.geometry&&!!r.geometry.morphAttributes.normal,p=tt.get(n),f=d.state.lights;if(!0===G&&(!0===j||t!==I)){const e=t===I&&n.id===C;ht.setState(n,t,e)}let m=!1;n.version===p.__version?p.needsLights&&p.lightsStateVersion!==f.state.version||p.outputEncoding!==a||r.isInstancedMesh&&!1===p.instancing?m=!0:r.isInstancedMesh||!0!==p.instancing?r.isSkinnedMesh&&!1===p.skinning?m=!0:r.isSkinnedMesh||!0!==p.skinning?p.envMap!==s||n.fog&&p.fog!==i?m=!0:void 0===p.numClippingPlanes||p.numClippingPlanes===ht.numPlanes&&p.numIntersection===ht.numIntersection?(p.vertexAlphas!==l||p.vertexTangents!==u||p.morphTargets!==c||p.morphNormals!==h)&&(m=!0):m=!0:m=!0:m=!0:(m=!0,p.__version=n.version);let g=p.currentProgram;!0===m&&(g=zt(n,e,r));let v=!1,_=!1,x=!1;const b=g.getUniforms(),w=p.uniforms;if(Q.useProgram(g.program)&&(v=!0,_=!0,x=!0),n.id!==C&&(C=n.id,_=!0),v||I!==t){if(b.setValue(_t,"projectionMatrix",t.projectionMatrix),K.logarithmicDepthBuffer&&b.setValue(_t,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),I!==t&&(I=t,_=!0,x=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const e=b.map.cameraPosition;void 0!==e&&e.setValue(_t,W.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&b.setValue(_t,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&b.setValue(_t,"viewMatrix",t.matrixWorldInverse)}if(r.isSkinnedMesh){b.setOptional(_t,r,"bindMatrix"),b.setOptional(_t,r,"bindMatrixInverse");const t=r.skeleton;t&&(K.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),b.setValue(_t,"boneTexture",t.boneTexture,et),b.setValue(_t,"boneTextureSize",t.boneTextureSize)):b.setOptional(_t,t,"boneMatrices"))}var E,S;return(_||p.receiveShadow!==r.receiveShadow)&&(p.receiveShadow=r.receiveShadow,b.setValue(_t,"receiveShadow",r.receiveShadow)),_&&(b.setValue(_t,"toneMappingExposure",y.toneMappingExposure),p.needsLights&&(S=x,(E=w).ambientLightColor.needsUpdate=S,E.lightProbe.needsUpdate=S,E.directionalLights.needsUpdate=S,E.directionalLightShadows.needsUpdate=S,E.pointLights.needsUpdate=S,E.pointLightShadows.needsUpdate=S,E.spotLights.needsUpdate=S,E.spotLightShadows.needsUpdate=S,E.rectAreaLights.needsUpdate=S,E.hemisphereLights.needsUpdate=S),i&&n.fog&&lt.refreshFogUniforms(w,i),lt.refreshMaterialUniforms(w,n,N,D,H),Ji.upload(_t,p.uniformsList,w,et)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ji.upload(_t,p.uniformsList,w,et),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&b.setValue(_t,"center",r.center),b.setValue(_t,"modelViewMatrix",r.modelViewMatrix),b.setValue(_t,"normalMatrix",r.normalMatrix),b.setValue(_t,"modelMatrix",r.matrixWorld),g}Dt.setAnimationLoop((function(t){Lt&&Lt(t)})),"undefined"!=typeof window&&Dt.setContext(window),this.setAnimationLoop=function(t){Lt=t,wt.setAnimationLoop(t),null===t?Dt.stop():Dt.start()},wt.addEventListener("sessionstart",Pt),wt.addEventListener("sessionend",Rt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===x)return;!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===wt.enabled&&!0===wt.isPresenting&&(!0===wt.cameraAutoUpdate&&wt.updateCamera(e),e=wt.getCamera()),!0===t.isScene&&t.onBeforeRender(y,t,e,M),(d=ct.get(t,g.length)).init(),g.push(d),q.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),V.setFromProjectionMatrix(q),j=this.localClippingEnabled,G=ht.init(this.clippingPlanes,j,e),(p=ut.get(t,m.length)).init(),m.push(p),function t(e,n,r,i){if(!1===e.visible)return;if(e.layers.test(n.layers))if(e.isGroup)r=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(n);else if(e.isLight)d.pushLight(e),e.castShadow&&d.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||V.intersectsSprite(e)){i&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(q);const t=at.update(e),n=e.material;n.visible&&p.push(e,t,n,r,W.z,null)}}else if(e.isImmediateRenderObject)i&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(q),p.push(e,null,e.material,r,W.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==$.render.frame&&(e.skeleton.update(),e.skeleton.frame=$.render.frame),!e.frustumCulled||V.intersectsObject(e))){i&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(q);const t=at.update(e),n=e.material;if(Array.isArray(n)){const i=t.groups;for(let o=0,a=i.length;o<a;o++){const a=i[o],s=n[a.materialIndex];s&&s.visible&&p.push(e,t,s,r,W.z,a)}}else n.visible&&p.push(e,t,n,r,W.z,null)}const o=e.children;for(let e=0,a=o.length;e<a;e++)t(o[e],n,r,i)}(t,e,0,y.sortObjects),p.finish(),!0===y.sortObjects&&p.sort(O,k),!0===G&&ht.beginShadows();const n=d.state.shadowsArray;if(pt.render(n,t,e),!0===G&&ht.endShadows(),!0===this.info.autoReset&&this.info.reset(),ft.render(p,t),d.setupLights(y.physicallyCorrectLights),e.isArrayCamera){const n=e.cameras;for(let e=0,r=n.length;e<r;e++){const r=n[e];Nt(p,t,r,r.viewport)}}else Nt(p,t,e);null!==M&&(et.updateMultisampleRenderTarget(M),et.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(y,t,e),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1),vt.resetDefaultState(),C=-1,I=null,g.pop(),d=g.length>0?g[g.length-1]:null,m.pop(),p=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTarget=function(t,e=0,n=0){M=t,b=e,S=n,t&&void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t);let r=null,i=!1,o=!1;if(t){const n=t.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const a=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=a[e],i=!0):r=t.isWebGLMultisampleRenderTarget?tt.get(t).__webglMultisampledFramebuffer:a,A.copy(t.viewport),L.copy(t.scissor),P=t.scissorTest}else A.copy(z).multiplyScalar(N).floor(),L.copy(F).multiplyScalar(N).floor(),P=B;if(Q.bindFramebuffer(36160,r)&&K.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const n=t.texture;if(U.length!==n.length||36064!==U[0]){for(let t=0,e=n.length;t<e;t++)U[t]=36064+t;U.length=n.length,e=!0}}else 1===U.length&&36064===U[0]||(U[0]=36064,U.length=1,e=!0);else 1===U.length&&1029===U[0]||(U[0]=1029,U.length=1,e=!0);e&&(K.isWebGL2?_t.drawBuffers(U):J.get("WEBGL_draw_buffers").drawBuffersWEBGL(U))}if(Q.viewport(A),Q.scissor(L),Q.setScissorTest(P),i){const r=tt.get(t.texture);_t.framebufferTexture2D(36160,36064,34069+e,r.__webglTexture,n)}else if(o){const r=tt.get(t.texture),i=e||0;_t.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}C=-1},this.readRenderTargetPixels=function(t,e,n,r,i,o,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=tt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){Q.bindFramebuffer(36160,s);try{const a=t.texture,s=a.format,l=a.type;if(s!==T&&yt.convert(s)!==_t.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const u=l===E&&(J.has("EXT_color_buffer_half_float")||K.isWebGL2&&J.has("EXT_color_buffer_float"));if(!(l===_||yt.convert(l)===_t.getParameter(35738)||l===w&&(K.isWebGL2||J.has("OES_texture_float")||J.has("WEBGL_color_buffer_float"))||u))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===_t.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&_t.readPixels(e,n,r,i,yt.convert(s),yt.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),o=Math.floor(e.image.height*r);let a=yt.convert(e.format);K.isWebGL2&&(6407===a&&(a=32849),6408===a&&(a=32856)),et.setTexture2D(e,0),_t.copyTexImage2D(3553,n,a,t.x,t.y,i,o,0),Q.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r=0){const i=e.image.width,o=e.image.height,a=yt.convert(n.format),s=yt.convert(n.type);et.setTexture2D(n,0),_t.pixelStorei(37440,n.flipY),_t.pixelStorei(37441,n.premultiplyAlpha),_t.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?_t.texSubImage2D(3553,r,t.x,t.y,i,o,a,s,e.image.data):e.isCompressedTexture?_t.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):_t.texSubImage2D(3553,r,t.x,t.y,a,s,e.image),0===r&&n.generateMipmaps&&_t.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,r,i=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,l=yt.convert(r.format),u=yt.convert(r.type);let c;if(r.isDataTexture3D)et.setTexture3D(r,0),c=32879;else{if(!r.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");et.setTexture2DArray(r,0),c=35866}_t.pixelStorei(37440,r.flipY),_t.pixelStorei(37441,r.premultiplyAlpha),_t.pixelStorei(3317,r.unpackAlignment);const h=_t.getParameter(3314),p=_t.getParameter(32878),f=_t.getParameter(3316),d=_t.getParameter(3315),m=_t.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;_t.pixelStorei(3314,g.width),_t.pixelStorei(32878,g.height),_t.pixelStorei(3316,t.min.x),_t.pixelStorei(3315,t.min.y),_t.pixelStorei(32877,t.min.z),n.isDataTexture||n.isDataTexture3D?_t.texSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,u,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_t.compressedTexSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,g.data)):_t.texSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,u,g),_t.pixelStorei(3314,h),_t.pixelStorei(32878,p),_t.pixelStorei(3316,f),_t.pixelStorei(3315,d),_t.pixelStorei(32877,m),0===i&&r.generateMipmaps&&_t.generateMipmap(c),Q.unbindTexture()},this.initTexture=function(t){et.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){b=0,S=0,M=null,Q.reset(),vt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class jo extends Go{}jo.prototype.isWebGL1Renderer=!0;class Ho{constructor(t,e=25e-5){this.name="",this.color=new Je(t),this.density=e}clone(){return new Ho(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ho.prototype.isFogExp2=!0;class qo{constructor(t,e=1,n=1e3){this.name="",this.color=new Je(t),this.near=e,this.far=n}clone(){return new qo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}qo.prototype.isFog=!0;class Wo extends Le{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Wo.prototype.isScene=!0;class Xo{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=lt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,i=this.stride;r<i;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=lt()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=lt()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}Xo.prototype.isInterleavedBuffer=!0;const Zo=new It;class Yo{constructor(t,e,n,r=!1){this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Zo.x=this.getX(e),Zo.y=this.getY(e),Zo.z=this.getZ(e),Zo.applyMatrix4(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Zo.x=this.getX(e),Zo.y=this.getY(e),Zo.z=this.getZ(e),Zo.applyNormalMatrix(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Zo.x=this.getX(e),Zo.y=this.getY(e),Zo.z=this.getZ(e),Zo.transformDirection(t),this.setXYZ(e,Zo.x,Zo.y,Zo.z);return this}setX(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){return this.data.array[t*this.data.stride+this.offset]}getY(t){return this.data.array[t*this.data.stride+this.offset+1]}getZ(t){return this.data.array[t*this.data.stride+this.offset+2]}getW(t){return this.data.array[t*this.data.stride+this.offset+3]}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=i,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new tn(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Yo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}Yo.prototype.isInterleavedBufferAttribute=!0;class Jo extends je{constructor(t){super(),this.type="SpriteMaterial",this.color=new Je(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this}}let Ko;Jo.prototype.isSpriteMaterial=!0;const Qo=new It,$o=new It,ta=new It,ea=new gt,na=new gt,ra=new oe,ia=new It,oa=new It,aa=new It,sa=new gt,la=new gt,ua=new gt;class ca extends Le{constructor(t){if(super(),this.type="Sprite",void 0===Ko){Ko=new wn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Xo(t,5);Ko.setIndex([0,1,2,0,2,3]),Ko.setAttribute("position",new Yo(e,3,0,!1)),Ko.setAttribute("uv",new Yo(e,2,3,!1))}this.geometry=Ko,this.material=void 0!==t?t:new Jo,this.center=new gt(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),$o.setFromMatrixScale(this.matrixWorld),ra.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ta.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&$o.multiplyScalar(-ta.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const o=this.center;ha(ia.set(-.5,-.5,0),ta,o,$o,r,i),ha(oa.set(.5,-.5,0),ta,o,$o,r,i),ha(aa.set(.5,.5,0),ta,o,$o,r,i),sa.set(0,0),la.set(1,0),ua.set(1,1);let a=t.ray.intersectTriangle(ia,oa,aa,!1,Qo);if(null===a&&(ha(oa.set(-.5,.5,0),ta,o,$o,r,i),la.set(0,1),null===(a=t.ray.intersectTriangle(ia,aa,oa,!1,Qo))))return;const s=t.ray.origin.distanceTo(Qo);s<t.near||s>t.far||e.push({distance:s,point:Qo.clone(),uv:Ve.getUV(Qo,ia,oa,aa,sa,la,ua,new gt),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function ha(t,e,n,r,i,o){ea.subVectors(t,n).addScalar(.5).multiply(r),void 0!==i?(na.x=o*ea.x-i*ea.y,na.y=i*ea.x+o*ea.y):na.copy(ea),t.copy(e),t.x+=na.x,t.y+=na.y,t.applyMatrix4(ra)}ca.prototype.isSprite=!0;const pa=new It,fa=new It;class da extends Le{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0){e=Math.abs(e);const n=this.levels;let r;for(r=0;r<n.length&&!(e<n[r].distance);r++);return n.splice(r,0,{distance:e,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,r;for(n=1,r=e.length;n<r&&!(t<e[n].distance);n++);return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){pa.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(pa);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){pa.setFromMatrixPosition(t.matrixWorld),fa.setFromMatrixPosition(this.matrixWorld);const n=pa.distanceTo(fa)/t.zoom;let r,i;for(e[0].object.visible=!0,r=1,i=e.length;r<i&&n>=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(this._currentLevel=r-1;r<i;r++)e[r].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,r=n.length;t<r;t++){const r=n[t];e.object.levels.push({object:r.object.uuid,distance:r.distance})}return e}}const ma=new It,ga=new Et,ya=new Et,va=new It,_a=new oe;class xa extends Un{constructor(t,e){super(t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new oe,this.bindMatrixInverse=new oe}copy(t){return super.copy(t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Et,e=this.geometry.attributes.skinWeight;for(let n=0,r=e.count;n<r;n++){t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.w=e.getW(n);const r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(t,e){const n=this.skeleton,r=this.geometry;ga.fromBufferAttribute(r.attributes.skinIndex,t),ya.fromBufferAttribute(r.attributes.skinWeight,t),ma.fromBufferAttribute(r.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const r=ya.getComponent(t);if(0!==r){const i=ga.getComponent(t);_a.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),e.addScaledVector(va.copy(ma).applyMatrix4(_a),r)}}return e.applyMatrix4(this.bindMatrixInverse)}}xa.prototype.isSkinnedMesh=!0;class ba extends Le{constructor(){super(),this.type="Bone"}}ba.prototype.isBone=!0;class wa extends bt{constructor(t=null,e=1,n=1,r,i,o,a,s,l=1003,u=1003,c,h){super(null,o,a,s,l,u,r,i,c,h),this.image={data:t,width:e,height:n},this.magFilter=l,this.minFilter=u,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}wa.prototype.isDataTexture=!0;const Ea=new oe,Sa=new oe;class Ma{constructor(t=[],e=[]){this.uuid=lt(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new oe)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new oe;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=t.length;r<i;r++){const i=t[r]?t[r].matrixWorld:Sa;Ea.multiplyMatrices(i,e[r]),Ea.toArray(n,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new Ma(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=ft(t),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new wa(e,t,t,T,w);return this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){const r=t.bones[n];let i=e[r];void 0===i&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),i=new ba),this.bones.push(i),this.boneInverses.push((new oe).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let r=0,i=e.length;r<i;r++){const i=e[r];t.bones.push(i.uuid);const o=n[r];t.boneInverses.push(o.toArray())}return t}}class Ta extends tn{constructor(t,e,n,r=1){"number"==typeof n&&(r=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(t,e,n),this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}Ta.prototype.isInstancedBufferAttribute=!0;const Ca=new oe,Ia=new oe,Aa=[],La=new Un;class Pa extends Un{constructor(t,e,n){super(t,e),this.instanceMatrix=new Ta(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(t){return super.copy(t),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}raycast(t,e){const n=this.matrixWorld,r=this.count;if(La.geometry=this.geometry,La.material=this.material,void 0!==La.material)for(let i=0;i<r;i++){this.getMatrixAt(i,Ca),Ia.multiplyMatrices(n,Ca),La.matrixWorld=Ia,La.raycast(t,Aa);for(let t=0,n=Aa.length;t<n;t++){const n=Aa[t];n.instanceId=i,n.object=this,e.push(n)}Aa.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Ta(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}Pa.prototype.isInstancedMesh=!0;class Ra extends je{constructor(t){super(),this.type="LineBasicMaterial",this.color=new Je(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this}}Ra.prototype.isLineBasicMaterial=!0;const Da=new It,Na=new It,Oa=new oe,ka=new ie,za=new Jt;class Fa extends Le{constructor(t=new wn,e=new Ra){super(),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t){return super.copy(t),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,r=e.count;t<r;t++)Da.fromBufferAttribute(e,t-1),Na.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Da.distanceTo(Na);t.setAttribute("lineDistance",new cn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(t,e){const n=this.geometry,r=this.matrixWorld,i=t.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),za.copy(n.boundingSphere),za.applyMatrix4(r),za.radius+=i,!1===t.ray.intersectsSphere(za))return;Oa.copy(r).invert(),ka.copy(t.ray).applyMatrix4(Oa);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new It,u=new It,c=new It,h=new It,p=this.isLineSegments?2:1;if(n.isBufferGeometry){const r=n.index,i=n.attributes.position;if(null!==r)for(let n=Math.max(0,o.start),a=Math.min(r.count,o.start+o.count)-1;n<a;n+=p){const o=r.getX(n),a=r.getX(n+1);if(l.fromBufferAttribute(i,o),u.fromBufferAttribute(i,a),ka.distanceSqToSegment(l,u,h,c)>s)continue;h.applyMatrix4(this.matrixWorld);const p=t.ray.origin.distanceTo(h);p<t.near||p>t.far||e.push({distance:p,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count)-1;n<r;n+=p){if(l.fromBufferAttribute(i,n),u.fromBufferAttribute(i,n+1),ka.distanceSqToSegment(l,u,h,c)>s)continue;h.applyMatrix4(this.matrixWorld);const r=t.ray.origin.distanceTo(h);r<t.near||r>t.far||e.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Fa.prototype.isLine=!0;const Ba=new It,Ua=new It;class Va extends Fa{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,r=e.count;t<r;t+=2)Ba.fromBufferAttribute(e,t),Ua.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Ba.distanceTo(Ua);t.setAttribute("lineDistance",new cn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}Va.prototype.isLineSegments=!0;class Ga extends Fa{constructor(t,e){super(t,e),this.type="LineLoop"}}Ga.prototype.isLineLoop=!0;class ja extends je{constructor(t){super(),this.type="PointsMaterial",this.color=new Je(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this}}ja.prototype.isPointsMaterial=!0;const Ha=new oe,qa=new ie,Wa=new Jt,Xa=new It;class Za extends Le{constructor(t=new wn,e=new ja){super(),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t){return super.copy(t),this.material=t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,r=this.matrixWorld,i=t.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Wa.copy(n.boundingSphere),Wa.applyMatrix4(r),Wa.radius+=i,!1===t.ray.intersectsSphere(Wa))return;Ha.copy(r).invert(),qa.copy(t.ray).applyMatrix4(Ha);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a;if(n.isBufferGeometry){const i=n.index,a=n.attributes.position;if(null!==i)for(let n=Math.max(0,o.start),l=Math.min(i.count,o.start+o.count);n<l;n++){const o=i.getX(n);Xa.fromBufferAttribute(a,o),Ya(Xa,o,s,r,t,e,this)}else for(let n=Math.max(0,o.start),i=Math.min(a.count,o.start+o.count);n<i;n++)Xa.fromBufferAttribute(a,n),Ya(Xa,n,s,r,t,e,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e<n;e++){const n=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Ya(t,e,n,r,i,o,a){const s=qa.distanceSqToPoint(t);if(s<n){const n=new It;qa.closestPointToPoint(t,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:e,face:null,object:a})}}Za.prototype.isPoints=!0;class Ja extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.format=void 0!==a?a:M,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==i?i:g,this.generateMipmaps=!1;const u=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){u.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;0=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Ja.prototype.isVideoTexture=!0;class Ka extends bt{constructor(t,e,n,r,i,o,a,s,l,u,c,h){super(null,o,a,s,l,u,r,i,c,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}Ka.prototype.isCompressedTexture=!0;class Qa extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.needsUpdate=!0}}Qa.prototype.isCanvasTexture=!0;class $a extends bt{constructor(t,e,n,r,i,o,a,s,l,u){if((u=void 0!==u?u:C)!==C&&u!==I)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===C&&(n=x),void 0===n&&u===I&&(n=S),super(null,r,i,o,a,s,u,n,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:f,this.minFilter=void 0!==s?s:f,this.flipY=!1,this.generateMipmaps=!1}}$a.prototype.isDepthTexture=!0;class ts extends wn{constructor(t=1,e=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const i=[],o=[],a=[],s=[],l=new It,u=new gt;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let i=0,c=3;i<=e;i++,c+=3){const h=n+i/e*r;l.x=t*Math.cos(h),l.y=t*Math.sin(h),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[c]/t+1)/2,u.y=(o[c+1]/t+1)/2,s.push(u.x,u.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new cn(o,3)),this.setAttribute("normal",new cn(a,3)),this.setAttribute("uv",new cn(s,2))}static fromJSON(t){return new ts(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class es extends wn{constructor(t=1,e=1,n=1,r=8,i=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s};const l=this;r=Math.floor(r),i=Math.floor(i);const u=[],c=[],h=[],p=[];let f=0;const d=[],m=n/2;let g=0;function y(n){const i=f,o=new gt,d=new It;let y=0;const v=!0===n?t:e,_=!0===n?1:-1;for(let t=1;t<=r;t++)c.push(0,m*_,0),h.push(0,_,0),p.push(.5,.5),f++;const x=f;for(let t=0;t<=r;t++){const e=t/r*s+a,n=Math.cos(e),i=Math.sin(e);d.x=v*i,d.y=m*_,d.z=v*n,c.push(d.x,d.y,d.z),h.push(0,_,0),o.x=.5*n+.5,o.y=.5*i*_+.5,p.push(o.x,o.y),f++}for(let t=0;t<r;t++){const e=i+t,r=x+t;!0===n?u.push(r,r+1,e):u.push(r+1,r,e),y+=3}l.addGroup(g,y,!0===n?1:2),g+=y}!function(){const o=new It,y=new It;let v=0;const _=(e-t)/n;for(let l=0;l<=i;l++){const u=[],g=l/i,v=g*(e-t)+t;for(let t=0;t<=r;t++){const e=t/r,i=e*s+a,l=Math.sin(i),d=Math.cos(i);y.x=v*l,y.y=-g*n+m,y.z=v*d,c.push(y.x,y.y,y.z),o.set(l,_,d).normalize(),h.push(o.x,o.y,o.z),p.push(e,1-g),u.push(f++)}d.push(u)}for(let t=0;t<r;t++)for(let e=0;e<i;e++){const n=d[e][t],r=d[e+1][t],i=d[e+1][t+1],o=d[e][t+1];u.push(n,r,o),u.push(r,i,o),v+=6}l.addGroup(g,v,0),g+=v}(),!1===o&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new cn(c,3)),this.setAttribute("normal",new cn(h,3)),this.setAttribute("uv",new cn(p,2))}static fromJSON(t){return new es(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ns extends es{constructor(t=1,e=1,n=8,r=1,i=!1,o=0,a=2*Math.PI){super(0,t,e,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}static fromJSON(t){return new ns(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rs extends wn{constructor(t,e,n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};const i=[],o=[];function a(t,e,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const a=t.clone().lerp(n,r/i),s=e.clone().lerp(n,r/i),l=i-r;for(let t=0;t<=l;t++)o[r][t]=0===t&&r===i?a:a.clone().lerp(s,t/l)}for(let t=0;t<i;t++)for(let e=0;e<2*(i-t)-1;e++){const n=Math.floor(e/2);e%2==0?(s(o[t][n+1]),s(o[t+1][n]),s(o[t][n])):(s(o[t][n+1]),s(o[t+1][n+1]),s(o[t+1][n]))}}function s(t){i.push(t.x,t.y,t.z)}function l(e,n){const r=3*e;n.x=t[r+0],n.y=t[r+1],n.z=t[r+2]}function u(t,e,n,r){r<0&&1===t.x&&(o[e]=t.x-1),0===n.x&&0===n.z&&(o[e]=r/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new It,r=new It,i=new It;for(let o=0;o<e.length;o+=3)l(e[o+0],n),l(e[o+1],r),l(e[o+2],i),a(n,r,i,t)}(r),function(t){const e=new It;for(let n=0;n<i.length;n+=3)e.x=i[n+0],e.y=i[n+1],e.z=i[n+2],e.normalize().multiplyScalar(t),i[n+0]=e.x,i[n+1]=e.y,i[n+2]=e.z}(n),function(){const t=new It;for(let n=0;n<i.length;n+=3){t.x=i[n+0],t.y=i[n+1],t.z=i[n+2];const r=c(t)/2/Math.PI+.5,a=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);o.push(r,1-a)}var e;(function(){const t=new It,e=new It,n=new It,r=new It,a=new gt,s=new gt,l=new gt;for(let h=0,p=0;h<i.length;h+=9,p+=6){t.set(i[h+0],i[h+1],i[h+2]),e.set(i[h+3],i[h+4],i[h+5]),n.set(i[h+6],i[h+7],i[h+8]),a.set(o[p+0],o[p+1]),s.set(o[p+2],o[p+3]),l.set(o[p+4],o[p+5]),r.copy(t).add(e).add(n).divideScalar(3);const f=c(r);u(a,p+0,t,f),u(s,p+2,e,f),u(l,p+4,n,f)}})(),function(){for(let t=0;t<o.length;t+=6){const e=o[t+0],n=o[t+2],r=o[t+4],i=Math.max(e,n,r),a=Math.min(e,n,r);i>.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new cn(i,3)),this.setAttribute("normal",new cn(i.slice(),3)),this.setAttribute("uv",new cn(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new rs(t.vertices,t.indices,t.radius,t.details)}}class is extends rs{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new is(t.radius,t.detail)}}const os=new It,as=new It,ss=new It,ls=new Ve;class us extends wn{constructor(t,e){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1,!0===t.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const n=Math.pow(10,4),r=Math.cos(at*e),i=t.getIndex(),o=t.getAttribute("position"),a=i?i.count:o.count,s=[0,0,0],l=["a","b","c"],u=new Array(3),c={},h=[];for(let t=0;t<a;t+=3){i?(s[0]=i.getX(t),s[1]=i.getX(t+1),s[2]=i.getX(t+2)):(s[0]=t,s[1]=t+1,s[2]=t+2);const{a:e,b:a,c:p}=ls;if(e.fromBufferAttribute(o,s[0]),a.fromBufferAttribute(o,s[1]),p.fromBufferAttribute(o,s[2]),ls.getNormal(ss),u[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,u[1]=`${Math.round(a.x*n)},${Math.round(a.y*n)},${Math.round(a.z*n)}`,u[2]=`${Math.round(p.x*n)},${Math.round(p.y*n)},${Math.round(p.z*n)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=u[t],i=u[e],o=ls[l[t]],a=ls[l[e]],p=`${n}_${i}`,f=`${i}_${n}`;f in c&&c[f]?(ss.dot(c[f].normal)<=r&&(h.push(o.x,o.y,o.z),h.push(a.x,a.y,a.z)),c[f]=null):p in c||(c[p]={index0:s[t],index1:s[e],normal:ss.clone()})}}for(const t in c)if(c[t]){const{index0:e,index1:n}=c[t];os.fromBufferAttribute(o,e),as.fromBufferAttribute(o,n),h.push(os.x,os.y,os.z),h.push(as.x,as.y,as.z)}this.setAttribute("position",new cn(h,3))}}class cs{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,r=this.getPoint(0),i=0;e.push(0);for(let o=1;o<=t;o++)i+=(n=this.getPoint(o/t)).distanceTo(r),e.push(i),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const i=n.length;let o;o=e||t*n[i-1];let a,s=0,l=i-1;for(;s<=l;)if((a=n[r=Math.floor(s+(l-s)/2)]-o)<0)s=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(n[r=l]===o)return r/(i-1);const u=n[r];return(r+(o-u)/(n[r+1]-u))/(i-1)}getTangent(t,e){let n=t-1e-4,r=t+1e-4;n<0&&(n=0),r>1&&(r=1);const i=this.getPoint(n),o=this.getPoint(r),a=e||(i.isVector2?new gt:new It);return a.copy(o).sub(i).normalize(),a}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new It,r=[],i=[],o=[],a=new It,s=new oe;for(let e=0;e<=t;e++){const n=e/t;r[e]=this.getTangentAt(n,new It),r[e].normalize()}i[0]=new It,o[0]=new It;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),c=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),o[0].crossVectors(r[0],i[0]);for(let e=1;e<=t;e++){if(i[e]=i[e-1].clone(),o[e]=o[e-1].clone(),a.crossVectors(r[e-1],r[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ut(r[e-1].dot(r[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(a,t))}o[e].crossVectors(r[e],i[e])}if(!0===e){let e=Math.acos(ut(i[0].dot(i[t]),-1,1));e/=t,r[0].dot(a.crossVectors(i[0],i[t]))>0&&(e=-e);for(let n=1;n<=t;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],e*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class hs extends cs{constructor(t=0,e=0,n=1,r=1,i=0,o=2*Math.PI,a=!1,s=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(t,e){const n=e||new gt,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=o?0:r),!0!==this.aClockwise||o||(i===r?i=-r:i-=r);const a=this.aStartAngle+t*i;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=s-this.aX,r=l-this.aY;s=n*t-r*e+this.aX,l=n*e+r*t+this.aY}return n.set(s,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}hs.prototype.isEllipseCurve=!0;class ps extends hs{constructor(t,e,n,r,i,o){super(t,e,n,n,r,i,o),this.type="ArcCurve"}}function fs(){let t=0,e=0,n=0,r=0;function i(i,o,a,s){t=i,e=a,n=-3*i+3*o-2*a-s,r=2*i-2*o+a+s}return{initCatmullRom:function(t,e,n,r,o){i(e,n,o*(n-t),o*(r-e))},initNonuniformCatmullRom:function(t,e,n,r,o,a,s){let l=(e-t)/o-(n-t)/(o+a)+(n-e)/a,u=(n-e)/a-(r-e)/(a+s)+(r-n)/s;i(e,n,l*=a,u*=a)},calc:function(i){const o=i*i;return t+e*i+n*o+r*(o*i)}}}ps.prototype.isArcCurve=!0;const ds=new It,ms=new fs,gs=new fs,ys=new fs;class vs extends cs{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new It){const n=e,r=this.points,i=r.length,o=(i-(this.closed?0:1))*t;let a,s,l=Math.floor(o),u=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===u&&l===i-1&&(l=i-2,u=1),this.closed||l>0?a=r[(l-1)%i]:(ds.subVectors(r[0],r[1]).add(r[0]),a=ds);const c=r[l%i],h=r[(l+1)%i];if(this.closed||l+2<i?s=r[(l+2)%i]:(ds.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=ds),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),n=Math.pow(c.distanceToSquared(h),t),r=Math.pow(h.distanceToSquared(s),t);n<1e-4&&(n=1),e<1e-4&&(e=n),r<1e-4&&(r=n),ms.initNonuniformCatmullRom(a.x,c.x,h.x,s.x,e,n,r),gs.initNonuniformCatmullRom(a.y,c.y,h.y,s.y,e,n,r),ys.initNonuniformCatmullRom(a.z,c.z,h.z,s.z,e,n,r)}else"catmullrom"===this.curveType&&(ms.initCatmullRom(a.x,c.x,h.x,s.x,this.tension),gs.initCatmullRom(a.y,c.y,h.y,s.y,this.tension),ys.initCatmullRom(a.z,c.z,h.z,s.z,this.tension));return n.set(ms.calc(u),gs.calc(u),ys.calc(u)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new It).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function _s(t,e,n,r,i){const o=.5*(r-e),a=.5*(i-n),s=t*t;return(2*n-2*r+o+a)*(t*s)+(-3*n+3*r-2*o-a)*s+o*t+n}function xs(t,e,n,r){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*n}(t)+function(t,e){return t*t*r}(t)}function bs(t,e,n,r,i){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*r}(t)+function(t,e){return t*t*t*i}(t)}vs.prototype.isCatmullRomCurve3=!0;class ws extends cs{constructor(t=new gt,e=new gt,n=new gt,r=new gt){super(),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new gt){const n=e,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(bs(t,r.x,i.x,o.x,a.x),bs(t,r.y,i.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}ws.prototype.isCubicBezierCurve=!0;class Es extends cs{constructor(t=new It,e=new It,n=new It,r=new It){super(),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new It){const n=e,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(bs(t,r.x,i.x,o.x,a.x),bs(t,r.y,i.y,o.y,a.y),bs(t,r.z,i.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}Es.prototype.isCubicBezierCurve3=!0;class Ss extends cs{constructor(t=new gt,e=new gt){super(),this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new gt){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){const n=e||new gt;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Ss.prototype.isLineCurve=!0;class Ms extends cs{constructor(t=new It,e=new It){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=t,this.v2=e}getPoint(t,e=new It){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Ts extends cs{constructor(t=new gt,e=new gt,n=new gt){super(),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new gt){const n=e,r=this.v0,i=this.v1,o=this.v2;return n.set(xs(t,r.x,i.x,o.x),xs(t,r.y,i.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Ts.prototype.isQuadraticBezierCurve=!0;class Cs extends cs{constructor(t=new It,e=new It,n=new It){super(),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new It){const n=e,r=this.v0,i=this.v1,o=this.v2;return n.set(xs(t,r.x,i.x,o.x),xs(t,r.y,i.y,o.y),xs(t,r.z,i.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Cs.prototype.isQuadraticBezierCurve3=!0;class Is extends cs{constructor(t=[]){super(),this.type="SplineCurve",this.points=t}getPoint(t,e=new gt){const n=e,r=this.points,i=(r.length-1)*t,o=Math.floor(i),a=i-o,s=r[0===o?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],c=r[o>r.length-3?r.length-1:o+2];return n.set(_s(a,s.x,l.x,u.x,c.x),_s(a,s.y,l.y,u.y,c.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new gt).fromArray(n))}return this}}Is.prototype.isSplineCurve=!0;var As=Object.freeze({__proto__:null,ArcCurve:ps,CatmullRomCurve3:vs,CubicBezierCurve:ws,CubicBezierCurve3:Es,EllipseCurve:hs,LineCurve:Ss,LineCurve3:Ms,QuadraticBezierCurve:Ts,QuadraticBezierCurve3:Cs,SplineCurve:Is});function Ls(t,e,n,r,i){let o,a;if(i===function(t,e,n,r){let i=0;for(let o=e,a=n-r;o<n;o+=r)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}(t,e,n,r)>0)for(o=e;o<n;o+=r)a=Ks(o,t[o],t[o+1],a);else for(o=n-r;o>=e;o-=r)a=Ks(o,t[o],t[o+1],a);return a&&qs(a,a.next)&&(Qs(a),a=a.next),a}function Ps(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!qs(r,r.next)&&0!==Hs(r.prev,r,r.next))r=r.next;else{if(Qs(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Rs(t,e,n,r,i,o,a){if(!t)return;!a&&o&&function(t,e,n,r){let i=t;do{null===i.z&&(i.z=Us(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e<u&&(s++,r=r.nextZ);e++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);let s,l,u=t;for(;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Ns(t,r,i,o):Ds(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qs(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?Rs(t=Os(Ps(t),e,n),e,n,r,i,o,2):2===a&&ks(t,e,n,r,i,o):Rs(Ps(t),e,n,r,i,o,1);break}}function Ds(t){const e=t.prev,n=t,r=t.next;if(Hs(e,n,r)>=0)return!1;let i=t.next.next;for(;i!==t.prev;){if(Gs(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Hs(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ns(t,e,n,r){const i=t.prev,o=t,a=t.next;if(Hs(i,o,a)>=0)return!1;const s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=Us(s,l,e,n,r),p=Us(u,c,e,n,r);let f=t.prevZ,d=t.nextZ;for(;f&&f.z>=h&&d&&d.z<=p;){if(f!==t.prev&&f!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==t.prev&&d!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Os(t,e,n){let r=t;do{const i=r.prev,o=r.next.next;!qs(i,o)&&Ws(i,r,r.next,o)&&Ys(i,o)&&Ys(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qs(r),Qs(r.next),r=t=o),r=r.next}while(r!==t);return Ps(r)}function ks(t,e,n,r,i,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&js(a,t)){let s=Js(a,t);return a=Ps(a,a.next),s=Ps(s,s.next),Rs(a,e,n,r,i,o),void Rs(s,e,n,r,i,o)}t=t.next}a=a.next}while(a!==t)}function zs(t,e){return t.x-e.x}function Fs(t,e){if(e=function(t,e){let n=e;const r=t.x,i=t.y;let o,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>a){if(a=t,t===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!o)return null;if(r===a)return o;const s=o,l=o.x,u=o.y;let c,h=1/0;n=o;do{r>=n.x&&n.x>=l&&r!==n.x&&Gs(i<u?r:a,i,l,u,i<u?a:r,i,n.x,n.y)&&(c=Math.abs(i-n.y)/(r-n.x),Ys(n,t)&&(c<h||c===h&&(n.x>o.x||n.x===o.x&&Bs(o,n)))&&(o=n,h=c)),n=n.next}while(n!==s);return o}(t,e)){const n=Js(e,t);Ps(e,e.next),Ps(n,n.next)}}function Bs(t,e){return Hs(t.prev,t,e.prev)<0&&Hs(e.next,t,t.next)<0}function Us(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Vs(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Gs(t,e,n,r,i,o,a,s){return(i-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function js(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Ws(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Ys(t,e)&&Ys(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Hs(t.prev,t,e.prev)||Hs(t,e.prev,e))||qs(t,e)&&Hs(t.prev,t,t.next)>0&&Hs(e.prev,e,e.next)>0)}function Hs(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qs(t,e){return t.x===e.x&&t.y===e.y}function Ws(t,e,n,r){const i=Zs(Hs(t,e,n)),o=Zs(Hs(t,e,r)),a=Zs(Hs(n,r,t)),s=Zs(Hs(n,r,e));return i!==o&&a!==s||!(0!==i||!Xs(t,n,e))||!(0!==o||!Xs(t,r,e))||!(0!==a||!Xs(n,t,r))||!(0!==s||!Xs(n,e,r))}function Xs(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Zs(t){return t>0?1:t<0?-1:0}function Ys(t,e){return Hs(t.prev,t,t.next)<0?Hs(t,e,t.next)>=0&&Hs(t,t.prev,e)>=0:Hs(t,e,t.prev)<0||Hs(t,t.next,e)<0}function Js(t,e){const n=new $s(t.i,t.x,t.y),r=new $s(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ks(t,e,n,r){const i=new $s(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qs(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function $s(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class tl{static area(t){const e=t.length;let n=0;for(let r=e-1,i=0;i<e;r=i++)n+=t[r].x*t[i].y-t[i].x*t[r].y;return.5*n}static isClockWise(t){return tl.area(t)<0}static triangulateShape(t,e){const n=[],r=[],i=[];el(t),nl(n,t);let o=t.length;e.forEach(el);for(let t=0;t<e.length;t++)r.push(o),o+=e[t].length,nl(n,e[t]);const a=function(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let o=Ls(t,0,i,n,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,u,c,h,p,f;if(r&&(o=function(t,e,n,r){const i=[];let o,a,s,l,u;for(o=0,a=e.length;o<a;o++)(u=Ls(t,s=e[o]*r,l=o<a-1?e[o+1]*r:t.length,r,!1))===u.next&&(u.steiner=!0),i.push(Vs(u));for(i.sort(zs),o=0;o<i.length;o++)Fs(i[o],n),n=Ps(n,n.next);return n}(t,e,o,n)),t.length>80*n){s=u=t[0],l=c=t[1];for(let e=n;e<i;e+=n)(h=t[e])<s&&(s=h),(p=t[e+1])<l&&(l=p),h>u&&(u=h),p>c&&(c=p);f=0!==(f=Math.max(u-s,c-l))?1/f:0}return Rs(o,a,n,s,l,f),a}(n,r);for(let t=0;t<a.length;t+=3)i.push(a.slice(t,t+3));return i}}function el(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function nl(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class rl extends wn{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,r=[],i=[];for(let e=0,n=t.length;e<n;e++)o(t[e]);function o(t){const o=[],a=void 0!==e.curveSegments?e.curveSegments:12,s=void 0!==e.steps?e.steps:1;let l=void 0!==e.depth?e.depth:100,u=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:6,h=void 0!==e.bevelSize?e.bevelSize:c-2,p=void 0!==e.bevelOffset?e.bevelOffset:0,f=void 0!==e.bevelSegments?e.bevelSegments:3;const d=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:il;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),l=e.amount);let g,y,v,_,x,b=!1;d&&(g=d.getSpacedPoints(s),b=!0,u=!1,y=d.computeFrenetFrames(s,!1),v=new It,_=new It,x=new It),u||(f=0,c=0,h=0,p=0);const w=t.extractPoints(a);let E=w.shape;const S=w.holes;if(!tl.isClockWise(E)){E=E.reverse();for(let t=0,e=S.length;t<e;t++){const e=S[t];tl.isClockWise(e)&&(S[t]=e.reverse())}}const M=tl.triangulateShape(E,S),T=E;for(let t=0,e=S.length;t<e;t++){const e=S[t];E=E.concat(e)}function C(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(n).add(t)}const I=E.length,A=M.length;function L(t,e,n){let r,i,o;const a=t.x-e.x,s=t.y-e.y,l=n.x-t.x,u=n.y-t.y,c=a*a+s*s,h=a*u-s*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(c),p=Math.sqrt(l*l+u*u),f=e.x-s/h,d=e.y+a/h,m=((n.x-u/p-f)*u-(n.y+l/p-d)*l)/(a*u-s*l),g=(r=f+a*m-t.x)*r+(i=d+s*m-t.y)*i;if(g<=2)return new gt(r,i);o=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(u)&&(t=!0),t?(r=-s,i=a,o=Math.sqrt(c)):(r=a,i=s,o=Math.sqrt(c/2))}return new gt(r/o,i/o)}const P=[];for(let t=0,e=T.length,n=e-1,r=t+1;t<e;t++,n++,r++)n===e&&(n=0),r===e&&(r=0),P[t]=L(T[t],T[n],T[r]);const R=[];let D,N=P.concat();for(let t=0,e=S.length;t<e;t++){const e=S[t];D=[];for(let t=0,n=e.length,r=n-1,i=t+1;t<n;t++,r++,i++)r===n&&(r=0),i===n&&(i=0),D[t]=L(e[t],e[r],e[i]);R.push(D),N=N.concat(D)}for(let t=0;t<f;t++){const e=t/f,n=c*Math.cos(e*Math.PI/2),r=h*Math.sin(e*Math.PI/2)+p;for(let t=0,e=T.length;t<e;t++){const e=C(T[t],P[t],r);z(e.x,e.y,-n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];D=R[t];for(let t=0,i=e.length;t<i;t++){const i=C(e[t],D[t],r);z(i.x,i.y,-n)}}}const O=h+p;for(let t=0;t<I;t++){const e=u?C(E[t],N[t],O):E[t];b?(_.copy(y.normals[0]).multiplyScalar(e.x),v.copy(y.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(_).add(v),z(x.x,x.y,x.z)):z(e.x,e.y,0)}for(let t=1;t<=s;t++)for(let e=0;e<I;e++){const n=u?C(E[e],N[e],O):E[e];b?(_.copy(y.normals[t]).multiplyScalar(n.x),v.copy(y.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(_).add(v),z(x.x,x.y,x.z)):z(n.x,n.y,l/s*t)}for(let t=f-1;t>=0;t--){const e=t/f,n=c*Math.cos(e*Math.PI/2),r=h*Math.sin(e*Math.PI/2)+p;for(let t=0,e=T.length;t<e;t++){const e=C(T[t],P[t],r);z(e.x,e.y,l+n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];D=R[t];for(let t=0,i=e.length;t<i;t++){const i=C(e[t],D[t],r);b?z(i.x,i.y+g[s-1].y,g[s-1].x+n):z(i.x,i.y,l+n)}}}function k(t,e){let n=t.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=t.length-1);for(let t=0,n=s+2*f;t<n;t++){const n=I*t,o=I*(t+1);B(e+r+n,e+i+n,e+i+o,e+r+o)}}}function z(t,e,n){o.push(t),o.push(e),o.push(n)}function F(t,e,i){U(t),U(e),U(i);const o=r.length/3,a=m.generateTopUV(n,r,o-3,o-2,o-1);V(a[0]),V(a[1]),V(a[2])}function B(t,e,i,o){U(t),U(e),U(o),U(e),U(i),U(o);const a=r.length/3,s=m.generateSideWallUV(n,r,a-6,a-3,a-2,a-1);V(s[0]),V(s[1]),V(s[3]),V(s[1]),V(s[2]),V(s[3])}function U(t){r.push(o[3*t+0]),r.push(o[3*t+1]),r.push(o[3*t+2])}function V(t){i.push(t.x),i.push(t.y)}!function(){const t=r.length/3;if(u){let t=0,e=I*t;for(let t=0;t<A;t++){const n=M[t];F(n[2]+e,n[1]+e,n[0]+e)}e=I*(t=s+2*f);for(let t=0;t<A;t++){const n=M[t];F(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<A;t++){const e=M[t];F(e[2],e[1],e[0])}for(let t=0;t<A;t++){const e=M[t];F(e[0]+I*s,e[1]+I*s,e[2]+I*s)}}n.addGroup(t,r.length/3-t,0)}(),function(){const t=r.length/3;let e=0;k(T,e),e+=T.length;for(let t=0,n=S.length;t<n;t++){const n=S[t];k(n,e),e+=n.length}n.addGroup(t,r.length/3-t,1)}()}this.setAttribute("position",new cn(r,3)),this.setAttribute("uv",new cn(i,2)),this.computeVertexNormals()}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,r=t.length;e<r;e++){const r=t[e];n.shapes.push(r.uuid)}else n.shapes.push(t.uuid);return void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON()),n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let r=0,i=t.shapes.length;r<i;r++){const i=e[t.shapes[r]];n.push(i)}const r=t.options.extrudePath;return void 0!==r&&(t.options.extrudePath=(new As[r.type]).fromJSON(r)),new rl(n,t.options)}}const il={generateTopUV:function(t,e,n,r,i){const o=e[3*n],a=e[3*n+1],s=e[3*r],l=e[3*r+1],u=e[3*i],c=e[3*i+1];return[new gt(o,a),new gt(s,l),new gt(u,c)]},generateSideWallUV:function(t,e,n,r,i,o){const a=e[3*n],s=e[3*n+1],l=e[3*n+2],u=e[3*r],c=e[3*r+1],h=e[3*r+2],p=e[3*i],f=e[3*i+1],d=e[3*i+2],m=e[3*o],g=e[3*o+1],y=e[3*o+2];return Math.abs(s-c)<Math.abs(a-u)?[new gt(a,1-l),new gt(u,1-h),new gt(p,1-d),new gt(m,1-y)]:[new gt(s,1-l),new gt(c,1-h),new gt(f,1-d),new gt(g,1-y)]}};class ol extends rs{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ol(t.radius,t.detail)}}class al extends wn{constructor(t,e=12,n=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=ut(r,0,2*Math.PI);const i=[],o=[],a=[],s=1/e,l=new It,u=new gt;for(let i=0;i<=e;i++){const c=n+i*s*r,h=Math.sin(c),p=Math.cos(c);for(let n=0;n<=t.length-1;n++)l.x=t[n].x*h,l.y=t[n].y,l.z=t[n].x*p,o.push(l.x,l.y,l.z),u.x=i/e,u.y=n/(t.length-1),a.push(u.x,u.y)}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const r=e+n*t.length,o=r,a=r+t.length,s=r+t.length+1,l=r+1;i.push(o,a,l),i.push(a,s,l)}if(this.setIndex(i),this.setAttribute("position",new cn(o,3)),this.setAttribute("uv",new cn(a,2)),this.computeVertexNormals(),r===2*Math.PI){const n=this.attributes.normal.array,r=new It,i=new It,o=new It,a=e*t.length*3;for(let e=0,s=0;e<t.length;e++,s+=3)r.x=n[s+0],r.y=n[s+1],r.z=n[s+2],i.x=n[a+s+0],i.y=n[a+s+1],i.z=n[a+s+2],o.addVectors(r,i).normalize(),n[s+0]=n[a+s+0]=o.x,n[s+1]=n[a+s+1]=o.y,n[s+2]=n[a+s+2]=o.z}}static fromJSON(t){return new al(t.points,t.segments,t.phiStart,t.phiLength)}}class sl extends rs{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new sl(t.radius,t.detail)}}class ll extends wn{constructor(t,e,n){super(),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n};const r=[],i=[],o=[],a=[],s=1e-5,l=new It,u=new It,c=new It,h=new It,p=new It;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const f=e+1;for(let r=0;r<=n;r++){const f=r/n;for(let n=0;n<=e;n++){const r=n/e;t(r,f,u),i.push(u.x,u.y,u.z),r-s>=0?(t(r-s,f,c),h.subVectors(u,c)):(t(r+s,f,c),h.subVectors(c,u)),f-s>=0?(t(r,f-s,c),p.subVectors(u,c)):(t(r,f+s,c),p.subVectors(c,u)),l.crossVectors(h,p).normalize(),o.push(l.x,l.y,l.z),a.push(r,f)}}for(let t=0;t<n;t++)for(let n=0;n<e;n++){const e=t*f+n,i=t*f+n+1,o=(t+1)*f+n+1,a=(t+1)*f+n;r.push(e,i,a),r.push(i,o,a)}this.setIndex(r),this.setAttribute("position",new cn(i,3)),this.setAttribute("normal",new cn(o,3)),this.setAttribute("uv",new cn(a,2))}}class ul extends wn{constructor(t=.5,e=1,n=8,r=1,i=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:o},n=Math.max(3,n);const a=[],s=[],l=[],u=[];let c=t;const h=(e-t)/(r=Math.max(1,r)),p=new It,f=new gt;for(let t=0;t<=r;t++){for(let t=0;t<=n;t++){const r=i+t/n*o;p.x=c*Math.cos(r),p.y=c*Math.sin(r),s.push(p.x,p.y,p.z),l.push(0,0,1),f.x=(p.x/e+1)/2,f.y=(p.y/e+1)/2,u.push(f.x,f.y)}c+=h}for(let t=0;t<r;t++){const e=t*(n+1);for(let t=0;t<n;t++){const r=t+e,i=r,o=r+n+1,s=r+n+2,l=r+1;a.push(i,o,l),a.push(o,s,l)}}this.setIndex(a),this.setAttribute("position",new cn(s,3)),this.setAttribute("normal",new cn(l,3)),this.setAttribute("uv",new cn(u,2))}static fromJSON(t){return new ul(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class cl extends wn{constructor(t,e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],r=[],i=[],o=[];let a=0,s=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(a,s,e),a+=s,s=0;function l(t){const a=r.length/3,l=t.extractPoints(e);let u=l.shape;const c=l.holes;!1===tl.isClockWise(u)&&(u=u.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===tl.isClockWise(e)&&(c[t]=e.reverse())}const h=tl.triangulateShape(u,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];u=u.concat(e)}for(let t=0,e=u.length;t<e;t++){const e=u[t];r.push(e.x,e.y,0),i.push(0,0,1),o.push(e.x,e.y)}for(let t=0,e=h.length;t<e;t++){const e=h[t],r=e[0]+a,i=e[1]+a,o=e[2]+a;n.push(r,i,o),s+=3}}this.setIndex(n),this.setAttribute("position",new cn(r,3)),this.setAttribute("normal",new cn(i,3)),this.setAttribute("uv",new cn(o,2))}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,r=t.length;n<r;n++){const r=t[n];e.shapes.push(r.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let r=0,i=t.shapes.length;r<i;r++){const i=e[t.shapes[r]];n.push(i)}return new cl(n,t.curveSegments)}}class hl extends wn{constructor(t=1,e=32,n=16,r=0,i=2*Math.PI,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:i,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const s=Math.min(o+a,Math.PI);let l=0;const u=[],c=new It,h=new It,p=[],f=[],d=[],m=[];for(let p=0;p<=n;p++){const g=[],y=p/n;let v=0;0==p&&0==o?v=.5/e:p==n&&s==Math.PI&&(v=-.5/e);for(let n=0;n<=e;n++){const s=n/e;c.x=-t*Math.cos(r+s*i)*Math.sin(o+y*a),c.y=t*Math.cos(o+y*a),c.z=t*Math.sin(r+s*i)*Math.sin(o+y*a),f.push(c.x,c.y,c.z),h.copy(c).normalize(),d.push(h.x,h.y,h.z),m.push(s+v,1-y),g.push(l++)}u.push(g)}for(let t=0;t<n;t++)for(let r=0;r<e;r++){const e=u[t][r+1],i=u[t][r],a=u[t+1][r],l=u[t+1][r+1];(0!==t||o>0)&&p.push(e,i,l),(t!==n-1||s<Math.PI)&&p.push(i,a,l)}this.setIndex(p),this.setAttribute("position",new cn(f,3)),this.setAttribute("normal",new cn(d,3)),this.setAttribute("uv",new cn(m,2))}static fromJSON(t){return new hl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class pl extends rs{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new pl(t.radius,t.detail)}}class fl extends rl{constructor(t,e={}){const n=e.font;if(!n||!n.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new wn;const r=n.generateShapes(t,e.size);e.depth=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),super(r,e),this.type="TextGeometry"}}class dl extends wn{constructor(t=1,e=.4,n=8,r=6,i=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:r,arc:i},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],s=[],l=[],u=new It,c=new It,h=new It;for(let o=0;o<=n;o++)for(let p=0;p<=r;p++){const f=p/r*i,d=o/n*Math.PI*2;c.x=(t+e*Math.cos(d))*Math.cos(f),c.y=(t+e*Math.cos(d))*Math.sin(f),c.z=e*Math.sin(d),a.push(c.x,c.y,c.z),u.x=t*Math.cos(f),u.y=t*Math.sin(f),h.subVectors(c,u).normalize(),s.push(h.x,h.y,h.z),l.push(p/r),l.push(o/n)}for(let t=1;t<=n;t++)for(let e=1;e<=r;e++){const n=(r+1)*t+e-1,i=(r+1)*(t-1)+e-1,a=(r+1)*(t-1)+e,s=(r+1)*t+e;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute("position",new cn(a,3)),this.setAttribute("normal",new cn(s,3)),this.setAttribute("uv",new cn(l,2))}static fromJSON(t){return new dl(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class ml extends wn{constructor(t=1,e=.4,n=64,r=8,i=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:i,q:o},n=Math.floor(n),r=Math.floor(r);const a=[],s=[],l=[],u=[],c=new It,h=new It,p=new It,f=new It,d=new It,m=new It,g=new It;for(let a=0;a<=n;++a){const v=a/n*i*Math.PI*2;y(v,i,o,t,p),y(v+.01,i,o,t,f),m.subVectors(f,p),g.addVectors(f,p),d.crossVectors(m,g),g.crossVectors(d,m),d.normalize(),g.normalize();for(let t=0;t<=r;++t){const i=t/r*Math.PI*2,o=-e*Math.cos(i),f=e*Math.sin(i);c.x=p.x+(o*g.x+f*d.x),c.y=p.y+(o*g.y+f*d.y),c.z=p.z+(o*g.z+f*d.z),s.push(c.x,c.y,c.z),h.subVectors(c,p).normalize(),l.push(h.x,h.y,h.z),u.push(a/n),u.push(t/r)}}for(let t=1;t<=n;t++)for(let e=1;e<=r;e++){const n=(r+1)*(t-1)+(e-1),i=(r+1)*t+(e-1),o=(r+1)*t+e,s=(r+1)*(t-1)+e;a.push(n,i,s),a.push(i,o,s)}function y(t,e,n,r,i){const o=Math.cos(t),a=Math.sin(t),s=n/e*t,l=Math.cos(s);i.x=r*(2+l)*.5*o,i.y=r*(2+l)*a*.5,i.z=r*Math.sin(s)*.5}this.setIndex(a),this.setAttribute("position",new cn(s,3)),this.setAttribute("normal",new cn(l,3)),this.setAttribute("uv",new cn(u,2))}static fromJSON(t){return new ml(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class gl extends wn{constructor(t,e=64,n=1,r=8,i=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i};const o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new It,s=new It,l=new gt;let u=new It;const c=[],h=[],p=[],f=[];function d(i){u=t.getPointAt(i/e,u);const l=o.normals[i],p=o.binormals[i];for(let t=0;t<=r;t++){const e=t/r*Math.PI*2,i=Math.sin(e),o=-Math.cos(e);s.x=o*l.x+i*p.x,s.y=o*l.y+i*p.y,s.z=o*l.z+i*p.z,s.normalize(),h.push(s.x,s.y,s.z),a.x=u.x+n*s.x,a.y=u.y+n*s.y,a.z=u.z+n*s.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)d(t);d(!1===i?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=r;n++)l.x=t/e,l.y=n/r,p.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=r;e++){const n=(r+1)*(t-1)+(e-1),i=(r+1)*t+(e-1),o=(r+1)*t+e,a=(r+1)*(t-1)+e;f.push(n,i,a),f.push(i,o,a)}}()}(),this.setIndex(f),this.setAttribute("position",new cn(c,3)),this.setAttribute("normal",new cn(h,3)),this.setAttribute("uv",new cn(p,2))}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new gl((new As[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class yl extends wn{constructor(t){if(super(),this.type="WireframeGeometry",!0===t.isGeometry)return void console.error("THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const e=[],n=new Set,r=new It,i=new It;if(null!==t.index){const o=t.attributes.position,a=t.index;let s=t.groups;0===s.length&&(s=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=s.length;t<l;++t){const l=s[t],u=l.start;for(let t=u,s=u+l.count;t<s;t+=3)for(let s=0;s<3;s++){const l=a.getX(t+s),u=a.getX(t+(s+1)%3);r.fromBufferAttribute(o,l),i.fromBufferAttribute(o,u),!0===vl(r,i,n)&&(e.push(r.x,r.y,r.z),e.push(i.x,i.y,i.z))}}}else{const o=t.attributes.position;for(let t=0,a=o.count/3;t<a;t++)for(let a=0;a<3;a++){const s=3*t+a,l=3*t+(a+1)%3;r.fromBufferAttribute(o,s),i.fromBufferAttribute(o,l),!0===vl(r,i,n)&&(e.push(r.x,r.y,r.z),e.push(i.x,i.y,i.z))}}this.setAttribute("position",new cn(e,3))}}function vl(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r,i),!0)}var _l=Object.freeze({__proto__:null,BoxGeometry:Gn,BoxBufferGeometry:Gn,CircleGeometry:ts,CircleBufferGeometry:ts,ConeGeometry:ns,ConeBufferGeometry:ns,CylinderGeometry:es,CylinderBufferGeometry:es,DodecahedronGeometry:is,DodecahedronBufferGeometry:is,EdgesGeometry:us,ExtrudeGeometry:rl,ExtrudeBufferGeometry:rl,IcosahedronGeometry:ol,IcosahedronBufferGeometry:ol,LatheGeometry:al,LatheBufferGeometry:al,OctahedronGeometry:sl,OctahedronBufferGeometry:sl,ParametricGeometry:ll,ParametricBufferGeometry:ll,PlaneGeometry:sr,PlaneBufferGeometry:sr,PolyhedronGeometry:rs,PolyhedronBufferGeometry:rs,RingGeometry:ul,RingBufferGeometry:ul,ShapeGeometry:cl,ShapeBufferGeometry:cl,SphereGeometry:hl,SphereBufferGeometry:hl,TetrahedronGeometry:pl,TetrahedronBufferGeometry:pl,TextGeometry:fl,TextBufferGeometry:fl,TorusGeometry:dl,TorusBufferGeometry:dl,TorusKnotGeometry:ml,TorusKnotBufferGeometry:ml,TubeGeometry:gl,TubeBufferGeometry:gl,WireframeGeometry:yl});class xl extends je{constructor(t){super(),this.type="ShadowMaterial",this.color=new Je(0),this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}}xl.prototype.isShadowMaterial=!0;class bl extends je{constructor(t){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Je(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}bl.prototype.isMeshStandardMaterial=!0;class wl extends bl{constructor(t){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new gt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ut(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.sheenTint=new Je(0),this.transmission=0,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationTint=new Je(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularTint=new Je(1,1,1),this.specularTintMap=null,this._clearcoat=0,this._transmission=0,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.sheenTint.copy(t.sheenTint),this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationTint.copy(t.attenuationTint),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularTint.copy(t.specularTint),this.specularTintMap=t.specularTintMap,this}}wl.prototype.isMeshPhysicalMaterial=!0;class El extends je{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new Je(16777215),this.specular=new Je(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}El.prototype.isMeshPhongMaterial=!0;class Sl extends je{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Je(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Sl.prototype.isMeshToonMaterial=!0;class Ml extends je{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}Ml.prototype.isMeshNormalMaterial=!0;class Tl extends je{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Tl.prototype.isMeshLambertMaterial=!0;class Cl extends je{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Je(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this}}Cl.prototype.isMeshMatcapMaterial=!0;class Il extends Ra{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}Il.prototype.isLineDashedMaterial=!0;var Al=Object.freeze({__proto__:null,ShadowMaterial:xl,SpriteMaterial:Jo,RawShaderMaterial:vr,ShaderMaterial:Wn,PointsMaterial:ja,MeshPhysicalMaterial:wl,MeshStandardMaterial:bl,MeshPhongMaterial:El,MeshToonMaterial:Sl,MeshNormalMaterial:Ml,MeshLambertMaterial:Tl,MeshDepthMaterial:Lo,MeshDistanceMaterial:Po,MeshBasicMaterial:Ke,MeshMatcapMaterial:Cl,LineDashedMaterial:Il,LineBasicMaterial:Ra,Material:je});const Ll={arraySlice:function(t,e,n){return Ll.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){const r=t.length,i=new t.constructor(r);for(let o=0,a=0;a!==r;++o){const r=n[o]*e;for(let n=0;n!==e;++n)i[a++]=t[r+n]}return i},flattenJSON:function(t,e,n,r){let i=1,o=t[0];for(;void 0!==o&&void 0===o[r];)o=t[i++];if(void 0===o)return;let a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(e.push(o.time),n.push.apply(n,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(e.push(o.time),a.toArray(n,n.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(e.push(o.time),n.push(a)),o=t[i++]}while(void 0!==o)},subclip:function(t,e,n,r,i=30){const o=t.clone();o.name=e;const a=[];for(let t=0;t<o.tracks.length;++t){const e=o.tracks[t],s=e.getValueSize(),l=[],u=[];for(let t=0;t<e.times.length;++t){const o=e.times[t]*i;if(!(o<n||o>=r)){l.push(e.times[t]);for(let n=0;n<s;++n)u.push(e.values[t*s+n])}}0!==l.length&&(e.times=Ll.convertArray(l,e.times.constructor),e.values=Ll.convertArray(u,e.values.constructor),a.push(e))}o.tracks=a;let s=1/0;for(let t=0;t<o.tracks.length;++t)s>o.tracks[t].times[0]&&(s=o.tracks[t].times[0]);for(let t=0;t<o.tracks.length;++t)o.tracks[t].shift(-1*s);return o.resetDuration(),o},makeClipAdditive:function(t,e=0,n=t,r=30){r<=0&&(r=30);const i=n.tracks.length,o=e/r;for(let e=0;e<i;++e){const r=n.tracks[e],i=r.ValueTypeName;if("bool"===i||"string"===i)continue;const a=t.tracks.find((function(t){return t.name===r.name&&t.ValueTypeName===i}));if(void 0===a)continue;let s=0;const l=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let u=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=c/3);const h=r.times.length-1;let p;if(o<=r.times[0]){const t=s,e=l-s;p=Ll.arraySlice(r.values,t,e)}else if(o>=r.times[h]){const t=h*l+s,e=t+l-s;p=Ll.arraySlice(r.values,t,e)}else{const t=r.createInterpolant(),e=s,n=l-s;t.evaluate(o),p=Ll.arraySlice(t.resultBuffer,e,n)}"quaternion"===i&&(new Ct).fromArray(p).normalize().conjugate().toArray(p);const f=a.times.length;for(let t=0;t<f;++t){const e=t*c+u;if("quaternion"===i)Ct.multiplyQuaternionsFlat(a.values,e,p,0,a.values,e);else{const t=c-2*u;for(let n=0;n<t;++n)a.values[e+n]-=p[n]}}}return t.blendMode=W,t}};class Pl{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,r=e[n],i=e[n-1];t:{e:{let o;n:{r:if(!(t<r)){for(let o=n+2;;){if(void 0===r){if(t<i)break r;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,i)}if(n===o)break;if(i=r,t<(r=e[++n]))break e}o=e.length;break n}if(t>=i)break t;{const a=e[1];t<a&&(n=2,i=a);for(let o=n-2;;){if(void 0===i)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(n===o)break;if(r=i,t>=(i=e[--n-1]))break e}o=n,n=0}}for(;n<o;){const r=n+o>>>1;t<e[r]?o=r:n=r+1}if(r=e[n],void 0===(i=e[n-1]))return this._cachedIndex=0,this.beforeStart_(0,t,r);if(void 0===r)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,i,t)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r;for(let t=0;t!==r;++t)e[t]=n[i+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}Pl.prototype.beforeStart_=Pl.prototype.copySampleValue_,Pl.prototype.afterEnd_=Pl.prototype.copySampleValue_;class Rl extends Pl{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:G,endingEnd:G}}intervalChanged_(t,e,n){const r=this.parameterPositions;let i=t-2,o=t+1,a=r[i],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case j:i=t,a=2*e-n;break;case H:a=e+r[i=r.length-2]-r[i+1];break;default:i=t,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case j:o=t,s=2*n-e;break;case H:o=1,s=n+r[1]-r[0];break;default:o=t-1,s=e}const l=.5*(n-e),u=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(s-n),this._offsetPrev=i*u,this._offsetNext=o*u}interpolate_(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=s-a,u=this._offsetPrev,c=this._offsetNext,h=this._weightPrev,p=this._weightNext,f=(n-e)/(r-e),d=f*f,m=d*f,g=-h*m+2*h*d-h*f,y=(1+h)*m+(-1.5-2*h)*d+(-.5+h)*f+1,v=(-1-p)*m+(1.5+p)*d+.5*f,_=p*m-p*d;for(let t=0;t!==a;++t)i[t]=g*o[u+t]+y*o[l+t]+v*o[s+t]+_*o[c+t];return i}}class Dl extends Pl{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=s-a,u=(n-e)/(r-e),c=1-u;for(let t=0;t!==a;++t)i[t]=o[l+t]*c+o[s+t]*u;return i}}class Nl extends Pl{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}}class Ol{constructor(t,e,n,r){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ll.convertArray(e,this.TimeBufferType),this.values=Ll.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Ll.convertArray(t.times,Array),values:Ll.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Nl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Dl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Rl(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case B:e=this.InterpolantFactoryMethodDiscrete;break;case U:e=this.InterpolantFactoryMethodLinear;break;case V:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return B;case this.InterpolantFactoryMethodLinear:return U;case this.InterpolantFactoryMethodSmooth:return V}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){const n=this.times,r=n.length;let i=0,o=r-1;for(;i!==r&&n[i]<t;)++i;for(;-1!==o&&n[o]>e;)--o;if(++o,0!==i||o!==r){i>=o&&(i=(o=Math.max(o,1))-1);const t=this.getValueSize();this.times=Ll.arraySlice(n,i,o),this.values=Ll.arraySlice(this.values,i*t,o*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let e=0;e!==i;e++){const r=n[e];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,r),t=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,r,o),t=!1;break}o=r}if(void 0!==r&&Ll.isTypedArray(r))for(let e=0,n=r.length;e!==n;++e){const n=r[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=Ll.arraySlice(this.times),e=Ll.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===V,i=t.length-1;let o=1;for(let a=1;a<i;++a){let i=!1;const s=t[a];if(s!==t[a+1]&&(1!==a||s!==t[0]))if(r)i=!0;else{const t=a*n,r=t-n,o=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[r+a]||n!==e[o+a]){i=!0;break}}}if(i){if(a!==o){t[o]=t[a];const r=a*n,i=o*n;for(let t=0;t!==n;++t)e[i+t]=e[r+t]}++o}}if(i>0){t[o]=t[i];for(let t=i*n,r=o*n,a=0;a!==n;++a)e[r+a]=e[t+a];++o}return o!==t.length?(this.times=Ll.arraySlice(t,0,o),this.values=Ll.arraySlice(e,0,o*n)):(this.times=t,this.values=e),this}clone(){const t=Ll.arraySlice(this.times,0),e=Ll.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Ol.prototype.TimeBufferType=Float32Array,Ol.prototype.ValueBufferType=Float32Array,Ol.prototype.DefaultInterpolation=U;class kl extends Ol{}kl.prototype.ValueTypeName="bool",kl.prototype.ValueBufferType=Array,kl.prototype.DefaultInterpolation=B,kl.prototype.InterpolantFactoryMethodLinear=void 0,kl.prototype.InterpolantFactoryMethodSmooth=void 0;class zl extends Ol{}zl.prototype.ValueTypeName="color";class Fl extends Ol{}Fl.prototype.ValueTypeName="number";class Bl extends Pl{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-e)/(r-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Ct.slerpFlat(i,0,o,l-a,o,l,s);return i}}class Ul extends Ol{InterpolantFactoryMethodLinear(t){return new Bl(this.times,this.values,this.getValueSize(),t)}}Ul.prototype.ValueTypeName="quaternion",Ul.prototype.DefaultInterpolation=U,Ul.prototype.InterpolantFactoryMethodSmooth=void 0;class Vl extends Ol{}Vl.prototype.ValueTypeName="string",Vl.prototype.ValueBufferType=Array,Vl.prototype.DefaultInterpolation=B,Vl.prototype.InterpolantFactoryMethodLinear=void 0,Vl.prototype.InterpolantFactoryMethodSmooth=void 0;class Gl extends Ol{}Gl.prototype.ValueTypeName="vector";class jl{constructor(t,e=-1,n,r=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=lt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,r=1/(t.fps||1);for(let t=0,i=n.length;t!==i;++t)e.push(Hl(n[t]).scale(r));const i=new this(t.name,t.duration,e,t.blendMode);return i.uuid=t.uuid,i}static toJSON(t){const e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,r=n.length;t!==r;++t)e.push(Ol.toJSON(n[t]));return r}static CreateFromMorphTargetSequence(t,e,n,r){const i=e.length,o=[];for(let t=0;t<i;t++){let a=[],s=[];a.push((t+i-1)%i,t,(t+1)%i),s.push(0,1,0);const l=Ll.getKeyframeOrder(a);a=Ll.sortedArray(a,1,l),s=Ll.sortedArray(s,1,l),r||0!==a[0]||(a.push(i),s.push(s[0])),o.push(new Fl(".morphTargetInfluences["+e[t].name+"]",a,s).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],o=n.name.match(i);if(o&&o.length>1){const t=o[1];let e=r[t];e||(r[t]=e=[]),e.push(n)}}const o=[];for(const t in r)o.push(this.CreateFromMorphTargetSequence(t,r[t],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,r,i){if(0!==n.length){const o=[],a=[];Ll.flattenJSON(n,o,a,r),0!==o.length&&i.push(new t(e,o,a))}},r=[],i=t.name||"default",o=t.fps||30,a=t.blendMode;let s=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const i=l[t].keys;if(i&&0!==i.length)if(i[0].morphTargets){const t={};let e;for(e=0;e<i.length;e++)if(i[e].morphTargets)for(let n=0;n<i[e].morphTargets.length;n++)t[i[e].morphTargets[n]]=-1;for(const n in t){const t=[],o=[];for(let r=0;r!==i[e].morphTargets.length;++r){const r=i[e];t.push(r.time),o.push(r.morphTarget===n?1:0)}r.push(new Fl(".morphTargetInfluence["+n+"]",t,o))}s=t.length*(o||1)}else{const o=".bones["+e[t].name+"]";n(Gl,o+".position",i,"pos",r),n(Ul,o+".quaternion",i,"rot",r),n(Gl,o+".scale",i,"scl",r)}}return 0===r.length?null:new this(i,s,r,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Hl(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Fl;case"vector":case"vector2":case"vector3":case"vector4":return Gl;case"color":return zl;case"quaternion":return Ul;case"bool":case"boolean":return kl;case"string":return Vl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];Ll.flattenJSON(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const ql={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Wl{constructor(t,e,n){const r=this;let i,o=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){s++,!1===o&&void 0!==r.onStart&&r.onStart(t,a,s),o=!0},this.itemEnd=function(t){a++,void 0!==r.onProgress&&r.onProgress(t,a,s),a===s&&(o=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)},this.resolveURL=function(t){return i?i(t):t},this.setURLModifier=function(t){return i=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],r=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return r}return null}}}const Xl=new Wl;class Zl{constructor(t){this.manager=void 0!==t?t:Xl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(r,i){n.load(t,r,e,i)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}const Yl={};class Jl extends Zl{constructor(t){super(t)}load(t,e,n,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,o=ql.get(t);if(void 0!==o)return i.manager.itemStart(t),setTimeout((function(){e&&e(o),i.manager.itemEnd(t)}),0),o;if(void 0!==Yl[t])return void Yl[t].push({onLoad:e,onProgress:n,onError:r});const a=t.match(/^data:(.*?)(;base64)?,(.*)$/);let s;if(a){const n=a[1],o=!!a[2];let s=a[3];s=decodeURIComponent(s),o&&(s=atob(s));try{let r;const o=(this.responseType||"").toLowerCase();switch(o){case"arraybuffer":case"blob":const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e);r="blob"===o?new Blob([t.buffer],{type:n}):t.buffer;break;case"document":const e=new DOMParser;r=e.parseFromString(s,n);break;case"json":r=JSON.parse(s);break;default:r=s}setTimeout((function(){e&&e(r),i.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}),0)}}else{Yl[t]=[],Yl[t].push({onLoad:e,onProgress:n,onError:r}),(s=new XMLHttpRequest).open("GET",t,!0),s.addEventListener("load",(function(e){const n=this.response,r=Yl[t];if(delete Yl[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),ql.add(t,n);for(let t=0,e=r.length;t<e;t++){const e=r[t];e.onLoad&&e.onLoad(n)}i.manager.itemEnd(t)}else{for(let t=0,n=r.length;t<n;t++){const n=r[t];n.onError&&n.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}}),!1),s.addEventListener("progress",(function(e){const n=Yl[t];for(let t=0,r=n.length;t<r;t++){const r=n[t];r.onProgress&&r.onProgress(e)}}),!1),s.addEventListener("error",(function(e){const n=Yl[t];delete Yl[t];for(let t=0,r=n.length;t<r;t++){const r=n[t];r.onError&&r.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}),!1),s.addEventListener("abort",(function(e){const n=Yl[t];delete Yl[t];for(let t=0,r=n.length;t<r;t++){const r=n[t];r.onError&&r.onError(e)}i.manager.itemError(t),i.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(s.responseType=this.responseType),void 0!==this.withCredentials&&(s.withCredentials=this.withCredentials),s.overrideMimeType&&s.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const t in this.requestHeader)s.setRequestHeader(t,this.requestHeader[t]);s.send(null)}return i.manager.itemStart(t),s}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Kl extends Zl{constructor(t){super(t)}load(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,o=ql.get(t);if(void 0!==o)return i.manager.itemStart(t),setTimeout((function(){e&&e(o),i.manager.itemEnd(t)}),0),o;const a=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1),ql.add(t,this),e&&e(this),i.manager.itemEnd(t)}function l(e){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1),r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),i.manager.itemStart(t),a.src=t,a}}class Ql extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=new Jn,o=new Kl(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function s(n){o.load(t[n],(function(t){i.images[n]=t,6==++a&&(i.needsUpdate=!0,e&&e(i))}),void 0,r)}for(let e=0;e<t.length;++e)s(e);return i}}class $l extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new wa,a=new Jl(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(i.withCredentials),a.load(t,(function(t){const n=i.parse(t);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:h,o.wrapT=void 0!==n.wrapT?n.wrapT:h,o.magFilter=void 0!==n.magFilter?n.magFilter:g,o.minFilter=void 0!==n.minFilter?n.minFilter:g,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(o.encoding=n.encoding),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=v),1===n.mipmapCount&&(o.minFilter=g),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,e&&e(o,n))}),n,r),o}}class tu extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=new bt,o=new Kl(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,(function(n){i.image=n;const r=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);i.format=r?M:T,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}class eu extends cs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ss(e,t))}getPoint(t){const e=t*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=e){const t=n[r]-e,i=this.curves[r],o=i.getLength(),a=0===o?0:1-t/o;return i.getPointAt(a)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const o=i[r],a=o&&o.isEllipseCurve?2*t:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a);for(let t=0;t<s.length;t++){const r=s[t];n&&n.equals(r)||(e.push(r),n=r)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new As[n.type]).fromJSON(n))}return this}}class nu extends eu{constructor(t){super(),this.type="Path",this.currentPoint=new gt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Ss(this.currentPoint.clone(),new gt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){const i=new Ts(this.currentPoint.clone(),new gt(t,e),new gt(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,i,o){const a=new ws(this.currentPoint.clone(),new gt(t,e),new gt(n,r),new gt(i,o));return this.curves.push(a),this.currentPoint.set(i,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Is(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,i,o){const a=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(t+a,e+s,n,r,i,o),this}absarc(t,e,n,r,i,o){return this.absellipse(t,e,n,n,r,i,o),this}ellipse(t,e,n,r,i,o,a,s){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,r,i,o,a,s),this}absellipse(t,e,n,r,i,o,a,s){const l=new hs(t,e,n,r,i,o,a,s);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class ru extends nu{constructor(t){super(t),this.uuid=lt(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new nu).fromJSON(n))}return this}}class iu extends Le{constructor(t,e=1){super(),this.type="Light",this.color=new Je(t),this.intensity=e}dispose(){}copy(t){return super.copy(t),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}iu.prototype.isLight=!0;class ou extends iu{constructor(t,e,n){super(t,n),this.type="HemisphereLight",this.position.copy(Le.DefaultUp),this.updateMatrix(),this.groundColor=new Je(e)}copy(t){return iu.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}ou.prototype.isHemisphereLight=!0;const au=new oe,su=new It,lu=new It;class uu{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new gt(512,512),this.map=null,this.mapPass=null,this.matrix=new oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ir,this._frameExtents=new gt(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;su.setFromMatrixPosition(t.matrixWorld),e.position.copy(su),lu.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(lu),e.updateMatrixWorld(),au.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(au),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(e.projectionMatrix),n.multiply(e.matrixWorldInverse)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class cu extends uu{constructor(){super(new Zn(50,1,.5,500)),this.focus=1}updateMatrices(t){const e=this.camera,n=2*st*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;n===e.fov&&r===e.aspect&&i===e.far||(e.fov=n,e.aspect=r,e.far=i,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}cu.prototype.isSpotLightShadow=!0;class hu extends iu{constructor(t,e,n=0,r=Math.PI/3,i=0,o=1){super(t,e),this.type="SpotLight",this.position.copy(Le.DefaultUp),this.updateMatrix(),this.target=new Le,this.distance=n,this.angle=r,this.penumbra=i,this.decay=o,this.shadow=new cu}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}hu.prototype.isSpotLight=!0;const pu=new oe,fu=new It,du=new It;class mu extends uu{constructor(){super(new Zn(90,1,.5,500)),this._frameExtents=new gt(4,2),this._viewportCount=6,this._viewports=[new Et(2,1,1,1),new Et(0,1,1,1),new Et(3,1,1,1),new Et(1,1,1,1),new Et(3,0,1,1),new Et(1,0,1,1)],this._cubeDirections=[new It(1,0,0),new It(-1,0,0),new It(0,0,1),new It(0,0,-1),new It(0,1,0),new It(0,-1,0)],this._cubeUps=[new It(0,1,0),new It(0,1,0),new It(0,1,0),new It(0,1,0),new It(0,0,1),new It(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,i=t.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),fu.setFromMatrixPosition(t.matrixWorld),n.position.copy(fu),du.copy(n.position),du.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(du),n.updateMatrixWorld(),r.makeTranslation(-fu.x,-fu.y,-fu.z),pu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pu)}}mu.prototype.isPointLightShadow=!0;class gu extends iu{constructor(t,e,n=0,r=1){super(t,e),this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new mu}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}gu.prototype.isPointLight=!0;class yu extends uu{constructor(){super(new yr(-5,5,5,-5,.5,500))}}yu.prototype.isDirectionalLightShadow=!0;class vu extends iu{constructor(t,e){super(t,e),this.type="DirectionalLight",this.position.copy(Le.DefaultUp),this.updateMatrix(),this.target=new Le,this.shadow=new yu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}vu.prototype.isDirectionalLight=!0;class _u extends iu{constructor(t,e){super(t,e),this.type="AmbientLight"}}_u.prototype.isAmbientLight=!0;class xu extends iu{constructor(t,e,n=10,r=10){super(t,e),this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}xu.prototype.isRectAreaLight=!0;class bu{constructor(){this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new It)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,r=t.y,i=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*r),e.addScaledVector(o[2],.488603*i),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],n*r*1.092548),e.addScaledVector(o[5],r*i*1.092548),e.addScaledVector(o[6],.315392*(3*i*i-1)),e.addScaledVector(o[7],n*i*1.092548),e.addScaledVector(o[8],.546274*(n*n-r*r)),e}getIrradianceAt(t,e){const n=t.x,r=t.y,i=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],1.023328*r),e.addScaledVector(o[2],1.023328*i),e.addScaledVector(o[3],1.023328*n),e.addScaledVector(o[4],.858086*n*r),e.addScaledVector(o[5],.858086*r*i),e.addScaledVector(o[6],.743125*i*i-.247708),e.addScaledVector(o[7],.858086*n*i),e.addScaledVector(o[8],.429043*(n*n-r*r)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(t,e+3*r);return this}toArray(t=[],e=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(t,e+3*r);return t}static getBasisAt(t,e){const n=t.x,r=t.y,i=t.z;e[0]=.282095,e[1]=.488603*r,e[2]=.488603*i,e[3]=.488603*n,e[4]=1.092548*n*r,e[5]=1.092548*r*i,e[6]=.315392*(3*i*i-1),e[7]=1.092548*n*i,e[8]=.546274*(n*n-r*r)}}bu.prototype.isSphericalHarmonics3=!0;class wu extends iu{constructor(t=new bu,e=1){super(void 0,e),this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}wu.prototype.isLightProbe=!0;class Eu extends Zl{constructor(t){super(t),this.textures={}}load(t,e,n,r){const i=this,o=new Jl(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const r=new Al[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&void 0!==r.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.sheenTint&&(r.sheenTint=(new Je).setHex(t.sheenTint)),void 0!==t.emissive&&void 0!==r.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==r.specular&&r.specular.setHex(t.specular),void 0!==t.specularIntensity&&(r.specularIntensity=t.specularIntensity),void 0!==t.specularTint&&void 0!==r.specularTint&&r.specularTint.setHex(t.specularTint),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearcoat&&(r.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(r.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.transmission&&(r.transmission=t.transmission),void 0!==t.thickness&&(r.thickness=t.thickness),void 0!==t.attenuationDistance&&(r.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationTint&&void 0!==r.attenuationTint&&r.attenuationTint.setHex(t.attenuationTint),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.flatShading&&(r.flatShading=t.flatShading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.combine&&(r.combine=t.combine),void 0!==t.side&&(r.side=t.side),void 0!==t.shadowSide&&(r.shadowSide=t.shadowSide),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.format&&(r.format=t.format),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(r.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(r.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(r.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(r.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(r.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(r.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(r.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(r.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(r.rotation=t.rotation),1!==t.linewidth&&(r.linewidth=t.linewidth),void 0!==t.dashSize&&(r.dashSize=t.dashSize),void 0!==t.gapSize&&(r.gapSize=t.gapSize),void 0!==t.scale&&(r.scale=t.scale),void 0!==t.polygonOffset&&(r.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(r.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(r.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(r.dithering=t.dithering),void 0!==t.alphaToCoverage&&(r.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(r.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.toneMapped&&(r.toneMapped=t.toneMapped),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?r.vertexColors=t.vertexColors>0:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const i=t.uniforms[e];switch(r.uniforms[e]={},i.type){case"t":r.uniforms[e].value=n(i.value);break;case"c":r.uniforms[e].value=(new Je).setHex(i.value);break;case"v2":r.uniforms[e].value=(new gt).fromArray(i.value);break;case"v3":r.uniforms[e].value=(new It).fromArray(i.value);break;case"v4":r.uniforms[e].value=(new Et).fromArray(i.value);break;case"m3":r.uniforms[e].value=(new yt).fromArray(i.value);break;case"m4":r.uniforms[e].value=(new oe).fromArray(i.value);break;default:r.uniforms[e].value=i.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)r.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=n(t.map)),void 0!==t.matcap&&(r.matcap=n(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),r.normalScale=(new gt).fromArray(e)}return void 0!==t.displacementMap&&(r.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(r.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularTintMap&&(r.specularTintMap=n(t.specularTintMap)),void 0!==t.envMap&&(r.envMap=n(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new gt).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(r.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(r.thicknessMap=n(t.thicknessMap)),r}setTextures(t){return this.textures=t,this}}class Su{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)}}class Mu extends wn{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const t=super.toJSON(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}Mu.prototype.isInstancedBufferGeometry=!0;class Tu extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}parse(t){const e={},n={};function r(t,r){if(void 0!==e[r])return e[r];const i=t.interleavedBuffers[r],o=function(t,e){if(void 0!==n[e])return n[e];const r=t.arrayBuffers[e],i=new Uint32Array(r).buffer;return n[e]=i,i}(t,i.buffer),a=dn(i.type,o),s=new Xo(a,i.stride);return s.uuid=i.uuid,e[r]=s,s}const i=t.isInstancedBufferGeometry?new Mu:new wn,o=t.data.index;if(void 0!==o){const t=dn(o.type,o.array);i.setIndex(new tn(t,1))}const a=t.data.attributes;for(const e in a){const n=a[e];let o;if(n.isInterleavedBufferAttribute){const e=r(t.data,n.data);o=new Yo(e,n.itemSize,n.offset,n.normalized)}else{const t=dn(n.type,n.array);o=new(n.isInstancedBufferAttribute?Ta:tn)(t,n.itemSize,n.normalized)}void 0!==n.name&&(o.name=n.name),void 0!==n.usage&&o.setUsage(n.usage),void 0!==n.updateRange&&(o.updateRange.offset=n.updateRange.offset,o.updateRange.count=n.updateRange.count),i.setAttribute(e,o)}const s=t.data.morphAttributes;if(s)for(const e in s){const n=s[e],o=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];let a;if(i.isInterleavedBufferAttribute){const e=r(t.data,i.data);a=new Yo(e,i.itemSize,i.offset,i.normalized)}else{const t=dn(i.type,i.array);a=new tn(t,i.itemSize,i.normalized)}void 0!==i.name&&(a.name=i.name),o.push(a)}i.morphAttributes[e]=o}t.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];i.addGroup(e.start,e.count,e.materialIndex)}const u=t.data.boundingSphere;if(void 0!==u){const t=new It;void 0!==u.center&&t.fromArray(u.center),i.boundingSphere=new Jt(t,u.radius)}return t.name&&(i.name=t.name),t.userData&&(i.userData=t.userData),i}}const Cu={UVMapping:r,CubeReflectionMapping:i,CubeRefractionMapping:o,EquirectangularReflectionMapping:a,EquirectangularRefractionMapping:s,CubeUVReflectionMapping:l,CubeUVRefractionMapping:u},Iu={RepeatWrapping:c,ClampToEdgeWrapping:h,MirroredRepeatWrapping:p},Au={NearestFilter:f,NearestMipmapNearestFilter:d,NearestMipmapLinearFilter:m,LinearFilter:g,LinearMipmapNearestFilter:y,LinearMipmapLinearFilter:v};class Lu extends Zl{constructor(t){super(t),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,o=ql.get(t);if(void 0!==o)return i.manager.itemStart(t),setTimeout((function(){e&&e(o),i.manager.itemEnd(t)}),0),o;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){ql.add(t,n),e&&e(n),i.manager.itemEnd(t)})).catch((function(e){r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)})),i.manager.itemStart(t)}}Lu.prototype.isImageBitmapLoader=!0;class Pu{constructor(){this.type="ShapePath",this.color=new Je,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new nu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,r){return this.currentPath.quadraticCurveTo(t,e,n,r),this}bezierCurveTo(t,e,n,r,i,o){return this.currentPath.bezierCurveTo(t,e,n,r,i,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t,e){function n(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n],i=new ru;i.curves=r.curves,e.push(i)}return e}function r(t,e){const n=e.length;let r=!1;for(let i=n-1,o=0;o<n;i=o++){let n=e[i],a=e[o],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[o],s=-s,a=e[i],l=-l),t.y<n.y||t.y>a.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-s*(t.y-n.y);if(0===e)return!0;if(e<0)continue;r=!r}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return r}const i=tl.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);let a,s,l;const u=[];if(1===o.length)return s=o[0],(l=new ru).curves=s.curves,u.push(l),u;let c=!i(o[0].getPoints());c=t?!c:c;const h=[],p=[];let f,d,m=[],g=0;p[g]=void 0,m[g]=[];for(let e=0,n=o.length;e<n;e++)a=i(f=(s=o[e]).getPoints()),(a=t?!a:a)?(!c&&p[g]&&g++,p[g]={s:new ru,p:f},p[g].s.curves=s.curves,c&&g++,m[g]=[]):m[g].push({h:s,p:f[0]});if(!p[0])return n(o);if(p.length>1){let t=!1;const e=[];for(let t=0,e=p.length;t<e;t++)h[t]=[];for(let n=0,i=p.length;n<i;n++){const i=m[n];for(let o=0;o<i.length;o++){const a=i[o];let s=!0;for(let i=0;i<p.length;i++)r(a.p,p[i].p)&&(n!==i&&e.push({froms:n,tos:i,hole:o}),s?(s=!1,h[i].push(a)):t=!0);s&&h[n].push(a)}}e.length>0&&(t||(m=h))}for(let t=0,e=p.length;t<e;t++){l=p[t].s,u.push(l),d=m[t];for(let t=0,e=d.length;t<e;t++)l.holes.push(d[t].h)}return u}}class Ru{constructor(t){this.type="Font",this.data=t}generateShapes(t,e=100){const n=[],r=function(t,e,n){const r=Array.from(t),i=e/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,a=[];let s=0,l=0;for(let t=0;t<r.length;t++){const e=r[t];if("\n"===e)s=0,l-=o;else{const t=Du(e,i,s,l,n);s+=t.offsetX,a.push(t.path)}}return a}(t,e,this.data);for(let t=0,e=r.length;t<e;t++)Array.prototype.push.apply(n,r[t].toShapes());return n}}function Du(t,e,n,r,i){const o=i.glyphs[t]||i.glyphs["?"];if(!o)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+i.familyName+".");const a=new Pu;let s,l,u,c,h,p,f,d;if(o.o){const t=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let i=0,o=t.length;i<o;)switch(t[i++]){case"m":s=t[i++]*e+n,l=t[i++]*e+r,a.moveTo(s,l);break;case"l":s=t[i++]*e+n,l=t[i++]*e+r,a.lineTo(s,l);break;case"q":u=t[i++]*e+n,c=t[i++]*e+r,h=t[i++]*e+n,p=t[i++]*e+r,a.quadraticCurveTo(h,p,u,c);break;case"b":u=t[i++]*e+n,c=t[i++]*e+r,h=t[i++]*e+n,p=t[i++]*e+r,f=t[i++]*e+n,d=t[i++]*e+r,a.bezierCurveTo(h,p,f,d,u,c)}}return{offsetX:o.ha*e,path:a}}let Nu;Ru.prototype.isFont=!0;const Ou={getContext:function(){return void 0===Nu&&(Nu=new(window.AudioContext||window.webkitAudioContext)),Nu},setContext:function(t){Nu=t}};class ku extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{const t=n.slice(0);Ou.getContext().decodeAudioData(t,(function(t){e(t)}))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}}class zu extends wu{constructor(t,e,n=1){super(void 0,n);const r=(new Je).set(t),i=(new Je).set(e),o=new It(r.r,r.g,r.b),a=new It(i.r,i.g,i.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}zu.prototype.isHemisphereLightProbe=!0;class Fu extends wu{constructor(t,e=1){super(void 0,e);const n=(new Je).set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}Fu.prototype.isAmbientLightProbe=!0;const Bu=new oe,Uu=new oe;class Vu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Gu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Gu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Gu(){return("undefined"==typeof performance?Date:performance).now()}const ju=new It,Hu=new Ct,qu=new It,Wu=new It;class Xu extends Le{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const Zu=new It,Yu=new Ct,Ju=new It,Ku=new It;class Qu{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class $u{constructor(t,e,n){let r,i,o;switch(this.binding=t,this.valueSize=n,e){case"quaternion":r=this._slerp,i=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,r=this.valueSize,i=t*r+r;let o=this.cumulativeWeight;if(0===o){for(let t=0;t!==r;++t)n[i+t]=n[t];o=e}else{const t=e/(o+=e);this._mixBufferRegion(n,i,0,t,r)}this.cumulativeWeight=o}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,r=t*e+e,i=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){const t=e*this._origIndex;this._mixBufferRegion(n,r,t,1-i,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let t=e,i=e+e;t!==i;++t)if(n[t]!==n[t+e]){a.setValue(n,r);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let t=n,i=r;t!==i;++t)e[t]=e[r+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,i){if(r>=.5)for(let r=0;r!==i;++r)t[e+r]=t[n+r]}_slerp(t,e,n,r){Ct.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,i){const o=this._workIndex*i;Ct.multiplyQuaternionsFlat(t,o,t,e,t,n),Ct.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,i){const o=1-r;for(let a=0;a!==i;++a){const i=e+a;t[i]=t[i]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,i){for(let o=0;o!==i;++o){const i=e+o;t[i]=t[i]+t[n+o]*r}}}const tc=new RegExp("[\\[\\]\\.:\\/]","g"),ec="[^\\[\\]\\.:\\/]",nc="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",rc=/((?:WC+[\/:])*)/.source.replace("WC",ec),ic=/(WCOD+)?/.source.replace("WCOD",nc),oc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ec),ac=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ec),sc=new RegExp("^"+rc+ic+oc+ac+"$"),lc=["material","materials","bones"];class uc{constructor(t,e,n){this.path=e,this.parsedPath=n||uc.parseTrackName(e),this.node=uc.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new uc.Composite(t,e,n):new uc(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(tc,"")}static parseTrackName(t){const e=sc.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const t=n.nodeName.substring(r+1);-1!==lc.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.name===e||i.uuid===e)return i;const o=n(i.children);if(o)return o}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,r=e.propertyName;let i=e.propertyIndex;if(t||(t=uc.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let r=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===r){r=e;break}break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==r){if(void 0===t[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[r]}}const o=t[r];if(void 0===o){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+r+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[i]&&(i=t.morphTargetDictionary[i])}s=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(s=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}uc.Composite=class{constructor(t,e,n){const r=n||uc.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},uc.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},uc.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},uc.prototype.GetterByBindingType=[uc.prototype._getValue_direct,uc.prototype._getValue_array,uc.prototype._getValue_arrayElement,uc.prototype._getValue_toArray],uc.prototype.SetterByBindingTypeAndVersioning=[[uc.prototype._setValue_direct,uc.prototype._setValue_direct_setNeedsUpdate,uc.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[uc.prototype._setValue_array,uc.prototype._setValue_array_setNeedsUpdate,uc.prototype._setValue_array_setMatrixWorldNeedsUpdate],[uc.prototype._setValue_arrayElement,uc.prototype._setValue_arrayElement_setNeedsUpdate,uc.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[uc.prototype._setValue_fromArray,uc.prototype._setValue_fromArray_setNeedsUpdate,uc.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class cc{constructor(){this.uuid=lt(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,o=i.length;let a,s=t.length,l=this.nCachedObjects_;for(let u=0,c=arguments.length;u!==c;++u){const c=arguments[u],h=c.uuid;let p=e[h];if(void 0===p){p=s++,e[h]=p,t.push(c);for(let t=0,e=o;t!==e;++t)i[t].push(new uc(c,n[t],r[t]))}else if(p<l){a=t[p];const s=--l,u=t[s];e[u.uuid]=p,t[p]=u,e[h]=s,t[s]=c;for(let t=0,e=o;t!==e;++t){const e=i[t],o=e[s];let a=e[p];e[p]=o,void 0===a&&(a=new uc(c,n[t],r[t])),e[s]=a}}else t[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o],s=a.uuid,l=e[s];if(void 0!==l&&l>=i){const o=i++,u=t[o];e[u.uuid]=l,t[l]=u,e[s]=o,t[o]=a;for(let t=0,e=r;t!==e;++t){const e=n[t],r=e[o],i=e[l];e[l]=r,e[o]=i}}}this.nCachedObjects_=i}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,o=t.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=e[s];if(void 0!==l)if(delete e[s],l<i){const a=--i,s=t[a],u=--o,c=t[u];e[s.uuid]=l,t[l]=s,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=r;t!==e;++t){const e=n[t],r=e[a],i=e[u];e[l]=r,e[a]=i,e.pop()}}else{const i=--o,a=t[i];i>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=r;t!==e;++t){const e=n[t];e[l]=e[i],e.pop()}}}this.nCachedObjects_=i}subscribe_(t,e){const n=this._bindingsIndicesByPath;let r=n[t];const i=this._bindings;if(void 0!==r)return i[r];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,u=this.nCachedObjects_,c=new Array(l);r=i.length,n[t]=r,o.push(t),a.push(e),i.push(c);for(let n=u,r=s.length;n!==r;++n){const r=s[n];c[n]=new uc(r,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const r=this._paths,i=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=n,o[n]=s,o.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}cc.prototype.isAnimationObjectGroup=!0;class hc{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;const i=e.tracks,o=i.length,a=new Array(o),s={endingStart:G,endingEnd:G};for(let t=0;t!==o;++t){const e=i[t].createInterpolant(null);a[t]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,r=t._clip.duration,i=r/n,o=n/r;t.warp(1,i,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const r=this._mixer,i=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled)return void this._updateWeight(t);const i=this._startTime;if(null!==i){const r=(t-i)*n;if(r<0||0===n)return;this._startTime=null,e=n*r}e*=this._updateTimeScale(t);const o=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===W)for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(o),e[n].accumulateAdditive(a);else for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(o),e[n].accumulate(r,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let r=this.time+t,i=this._loopCount;const o=2202===n;if(0===t)return-1===i?r:o&&1==(1&i)?e-r:r;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),r>=e||r<0){const n=Math.floor(r/e);r-=e*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(o&&1==(1&i))return e-r}return r}_setEndings(t,e,n){const r=this._interpolantSettings;n?(r.endingStart=j,r.endingEnd=j):(r.endingStart=t?this.zeroSlopeAtStart?j:G:H,r.endingEnd=e?this.zeroSlopeAtEnd?j:G:H)}_scheduleFading(t,e,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=n,this}}class pc extends rt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let u=l[s];void 0===u&&(u={},l[s]=u);for(let t=0;t!==i;++t){const i=r[t],l=i.name;let c=u[l];if(void 0!==c)o[t]=c;else{if(void 0!==(c=o[t])){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,s,l));continue}const r=e&&e._propertyBindings[t].binding.parsedPath;++(c=new $u(uc.create(n,l,r),i.ValueTypeName,i.getValueSize())).referenceCount,this._addInactiveBinding(c,s,l),o[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const r=this._actions,i=this._actionsByClip;let o=i[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,i[e]=o;else{const e=o.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;const i=t._clip.uuid,o=this._actionsByClip,a=o[i],s=a.knownActions,l=s[s.length-1],u=t._byClipCacheIndex;l._byClipCacheIndex=u,s[u]=l,s.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete o[i],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i}_addInactiveBinding(t,e,n){const r=this._bindingsByRootAndName,i=this._bindings;let o=r[e];void 0===o&&(o={},r[e]=o),o[n]=t,t._cacheIndex=i.length,i.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,r=n.rootNode.uuid,i=n.path,o=this._bindingsByRootAndName,a=o[r],s=e[e.length-1],l=t._cacheIndex;s._cacheIndex=l,e[l]=s,e.pop(),delete a[i],0===Object.keys(a).length&&delete o[r]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,i=e[r];t._cacheIndex=r,e[r]=t,i._cacheIndex=n,e[n]=i}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&((n=new Dl(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,i=e[r];t.__cacheIndex=r,e[r]=t,i.__cacheIndex=n,e[n]=i}clipAction(t,e,n){const r=e||this._root,i=r.uuid;let o="string"==typeof t?jl.findByName(r,t):t;const a=null!==o?o.uuid:t,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:q),void 0!==s){const t=s.actionByRoot[i];if(void 0!==t&&t.blendMode===n)return t;l=s.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const u=new hc(this,o,e,n);return this._bindAction(u,l),this._addInactiveAction(u,a,i),u}existingAction(t,e){const n=e||this._root,r=n.uuid,i="string"==typeof t?jl.findByName(n,t):t,o=i?i.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[r]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,r=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(r,t,i,o);const a=this._bindings,s=this._nActiveBindings;for(let t=0;t!==s;++t)a[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){const t=i.knownActions;for(let n=0,r=t.length;n!==r;++n){const r=t[n];this._deactivateAction(r);const i=r._cacheIndex,o=e[e.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,o._cacheIndex=i,e[i]=o,e.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const r=n[t].actionByRoot[e];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}const r=this._bindingsByRootAndName[e];if(void 0!==r)for(const t in r){const e=r[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}pc.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class fc{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new fc(void 0===this.value.clone?this.value:this.value.clone())}}class dc extends Xo{constructor(t,e,n=1){super(t,e),this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}dc.prototype.isInstancedInterleavedBuffer=!0;class mc{constructor(t,e,n,r,i){this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}function gc(t,e){return t.distance-e.distance}function yc(t,e,n,r){if(t.layers.test(e.layers)&&t.raycast(e,n),!0===r){const r=t.children;for(let t=0,i=r.length;t<i;t++)yc(r[t],e,n,!0)}}mc.prototype.isGLBufferAttribute=!0;const vc=new gt;class _c{constructor(t=new gt(1/0,1/0),e=new gt(-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=vc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return vc.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}_c.prototype.isBox2=!0;const xc=new It,bc=new It;class wc{constructor(t=new It,e=new It){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){xc.subVectors(t,this.start),bc.subVectors(this.end,this.start);const n=bc.dot(bc);let r=bc.dot(xc)/n;return e&&(r=ut(r,0,1)),r}closestPointToPoint(t,e,n){const r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}class Ec extends Le{constructor(t){super(),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}Ec.prototype.isImmediateRenderObject=!0;const Sc=new It,Mc=new It,Tc=new oe,Cc=new oe;class Ic extends Va{constructor(t){const e=function t(e){const n=[];e&&e.isBone&&n.push(e);for(let r=0;r<e.children.length;r++)n.push.apply(n,t(e.children[r]));return n}(t),n=new wn,r=[],i=[],o=new Je(0,0,1),a=new Je(0,1,0);for(let t=0;t<e.length;t++){const n=e[t];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(o.r,o.g,o.b),i.push(a.r,a.g,a.b))}n.setAttribute("position",new cn(r,3)),n.setAttribute("color",new cn(i,3)),super(n,new Ra({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,r=n.getAttribute("position");Cc.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(Tc.multiplyMatrices(Cc,i.matrixWorld),Mc.setFromMatrixPosition(Tc),r.setXYZ(n,Mc.x,Mc.y,Mc.z),Tc.multiplyMatrices(Cc,i.parent.matrixWorld),Mc.setFromMatrixPosition(Tc),r.setXYZ(n+1,Mc.x,Mc.y,Mc.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}}const Ac=new It,Lc=new Je,Pc=new Je;class Rc extends Va{constructor(t=10,e=10,n=4473924,r=8947848){n=new Je(n),r=new Je(r);const i=e/2,o=t/e,a=t/2,s=[],l=[];for(let t=0,u=0,c=-a;t<=e;t++,c+=o){s.push(-a,0,c,a,0,c),s.push(c,0,-a,c,0,a);const e=t===i?n:r;e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3}const u=new wn;u.setAttribute("position",new cn(s,3)),u.setAttribute("color",new cn(l,3)),super(u,new Ra({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}const Dc=new It,Nc=new It,Oc=new It,kc=new It,zc=new Xn;function Fc(t,e,n,r,i,o,a){kc.set(i,o,a).unproject(r);const s=e[t];if(void 0!==s){const t=n.getAttribute("position");for(let e=0,n=s.length;e<n;e++)t.setXYZ(s[e],kc.x,kc.y,kc.z)}}const Bc=new Pt;class Uc extends Va{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new wn;i.setIndex(new tn(n,1)),i.setAttribute("position",new tn(r,3)),super(i,new Ra({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Bc.setFromObject(this.object),Bc.isEmpty())return;const e=Bc.min,n=Bc.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=e.x,i[4]=n.y,i[5]=n.z,i[6]=e.x,i[7]=e.y,i[8]=n.z,i[9]=n.x,i[10]=e.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=e.z,i[15]=e.x,i[16]=n.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=n.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t){return Va.prototype.copy.call(this,t),this.object=t.object,this}}const Vc=new It;let Gc,jc;class Hc extends Va{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new wn;n.setAttribute("position",new cn(e,3)),n.setAttribute("color",new cn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Ra({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const r=new Je,i=this.geometry.attributes.color.array;return r.set(t),r.toArray(i,0),r.toArray(i,3),r.set(e),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}const qc=new Float32Array(1),Wc=new Int32Array(qc.buffer);cs.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(cs.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},nu.prototype.fromPoints=function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)},Rc.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},Ic.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Zl.prototype.extractUrlBase=function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Su.extractUrlBase(t)},Zl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},_c.prototype.center=function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},_c.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},_c.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},_c.prototype.size=function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)},Pt.prototype.center=function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Pt.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Pt.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},Pt.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},Pt.prototype.size=function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)},Jt.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},ir.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},wc.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},yt.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},yt.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},yt.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},yt.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},yt.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},yt.prototype.getInverse=function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},oe.prototype.extractPosition=function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},oe.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},oe.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new It).setFromMatrixColumn(this,3)},oe.prototype.setRotationFromQuaternion=function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},oe.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},oe.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},oe.prototype.multiplyVector4=function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},oe.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},oe.prototype.rotateAxis=function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},oe.prototype.crossVector=function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},oe.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},oe.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},oe.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},oe.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},oe.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},oe.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},oe.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},oe.prototype.makeFrustum=function(t,e,n,r,i,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,n,i,o)},oe.prototype.getInverse=function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},er.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Ct.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Ct.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},ie.prototype.isIntersectionBox=function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},ie.prototype.isIntersectionPlane=function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},ie.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},Ve.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},Ve.prototype.barycoordFromPoint=function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},Ve.prototype.midpoint=function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},Ve.prototypenormal=function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},Ve.prototype.plane=function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)},Ve.barycoordFromPoint=function(t,e,n,r,i){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Ve.getBarycoord(t,e,n,r,i)},Ve.normal=function(t,e,n,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Ve.getNormal(t,e,n,r)},ru.prototype.extractAllPoints=function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},ru.prototype.extrude=function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new rl(this,t)},ru.prototype.makeGeometry=function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new cl(this,t)},gt.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},gt.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},gt.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},It.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},It.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},It.prototype.getPositionFromMatrix=function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},It.prototype.getScaleFromMatrix=function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},It.prototype.getColumnFromMatrix=function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},It.prototype.applyProjection=function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},It.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},It.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},It.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Et.prototype.fromAttribute=function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},Et.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Le.prototype.getChildByName=function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},Le.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},Le.prototype.translate=function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},Le.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},Le.prototype.applyMatrix=function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Le.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Un.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(Un.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),xa.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Zn.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(iu.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(tn.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===et},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(et)}}}),tn.prototype.setDynamic=function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?et:tt),this},tn.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},tn.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},wn.prototype.addIndex=function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},wn.prototype.addAttribute=function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new tn(arguments[1],arguments[2])))},wn.prototype.addDrawCall=function(t,e,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},wn.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},wn.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},wn.prototype.removeAttribute=function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},wn.prototype.applyMatrix=function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(wn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Xo.prototype.setDynamic=function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?et:tt),this},Xo.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},rl.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},rl.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},rl.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Wo.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},fc.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(je.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Je}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(Wn.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Go.prototype.clearTarget=function(t,e,n,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,n,r)},Go.prototype.animate=function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},Go.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},Go.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},Go.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},Go.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},Go.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},Go.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},Go.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},Go.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},Go.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},Go.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},Go.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},Go.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},Go.prototype.enableScissorTest=function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},Go.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},Go.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},Go.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},Go.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},Go.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},Go.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},Go.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},Go.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},Go.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},Go.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(Go.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?Z:X}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ro.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(St.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Xu.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return(new ku).load(t,(function(t){e.setBuffer(t)})),this},Qu.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Yn.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},Yn.prototype.clear=function(t,e,n,r){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,n,r)},_t.crossOrigin=void 0,_t.loadTexture=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const i=new tu;i.setCrossOrigin(this.crossOrigin);const o=i.load(t,n,void 0,r);return e&&(o.mapping=e),o},_t.loadTextureCube=function(t,e,n,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const i=new Ql;i.setCrossOrigin(this.crossOrigin);const o=i.load(t,n,void 0,r);return e&&(o.mapping=e),o},_t.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},_t.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const Xc={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:e}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=e),t.ACESFilmicToneMapping=4,t.AddEquation=n,t.AddOperation=2,t.AdditiveAnimationBlendMode=W,t.AdditiveBlending=2,t.AlphaFormat=1021,t.AlwaysDepth=1,t.AlwaysStencilFunc=519,t.AmbientLight=_u,t.AmbientLightProbe=Fu,t.AnimationClip=jl,t.AnimationLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{e(i.parse(JSON.parse(n)))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}parse(t){const e=[];for(let n=0;n<t.length;n++){const r=jl.parse(t[n]);e.push(r)}return e}},t.AnimationMixer=pc,t.AnimationObjectGroup=cc,t.AnimationUtils=Ll,t.ArcCurve=ps,t.ArrayCamera=ko,t.ArrowHelper=class extends Le{constructor(t=new It(0,0,1),e=new It(0,0,0),n=1,r=16776960,i=.2*n,o=.2*i){super(),this.type="ArrowHelper",void 0===Gc&&((Gc=new wn).setAttribute("position",new cn([0,0,0,0,1,0],3)),(jc=new es(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(e),this.line=new Fa(Gc,new Ra({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Un(jc,new Ke({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,i,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Vc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Vc,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},t.Audio=Xu,t.AudioAnalyser=Qu,t.AudioContext=Ou,t.AudioListener=class extends Le{constructor(){super(),this.type="AudioListener",this.context=Ou.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ju,Hu,qu),Wu.set(0,0,-1).applyQuaternion(Hu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ju.x,t),e.positionY.linearRampToValueAtTime(ju.y,t),e.positionZ.linearRampToValueAtTime(ju.z,t),e.forwardX.linearRampToValueAtTime(Wu.x,t),e.forwardY.linearRampToValueAtTime(Wu.y,t),e.forwardZ.linearRampToValueAtTime(Wu.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(ju.x,ju.y,ju.z),e.setOrientation(Wu.x,Wu.y,Wu.z,n.x,n.y,n.z)}},t.AudioLoader=ku,t.AxesHelper=Hc,t.AxisHelper=function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Hc(t)},t.BackSide=1,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BinaryTextureLoader=function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new $l(t)},t.Bone=ba,t.BooleanKeyframeTrack=kl,t.BoundingBoxHelper=function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Uc(t,e)},t.Box2=_c,t.Box3=Pt,t.Box3Helper=class extends Va{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new wn;r.setIndex(new tn(n,1)),r.setAttribute("position",new cn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new Ra({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},t.BoxBufferGeometry=Gn,t.BoxGeometry=Gn,t.BoxHelper=Uc,t.BufferAttribute=tn,t.BufferGeometry=wn,t.BufferGeometryLoader=Tu,t.ByteType=1010,t.Cache=ql,t.Camera=Xn,t.CameraHelper=class extends Va{constructor(t){const e=new wn,n=new Ra({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={},a=new Je(16755200),s=new Je(16711680),l=new Je(43775),u=new Je(16777215),c=new Je(3355443);function h(t,e,n){p(t,n),p(e,n)}function p(t,e){r.push(0,0,0),i.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(r.length/3-1)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",u),h("p","c",c),h("cn1","cn2",c),h("cn3","cn4",c),h("cf1","cf2",c),h("cf3","cf4",c),e.setAttribute("position",new cn(r,3)),e.setAttribute("color",new cn(i,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const t=this.geometry,e=this.pointMap;zc.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Fc("c",e,t,zc,0,0,-1),Fc("t",e,t,zc,0,0,1),Fc("n1",e,t,zc,-1,-1,-1),Fc("n2",e,t,zc,1,-1,-1),Fc("n3",e,t,zc,-1,1,-1),Fc("n4",e,t,zc,1,1,-1),Fc("f1",e,t,zc,-1,-1,1),Fc("f2",e,t,zc,1,-1,1),Fc("f3",e,t,zc,-1,1,1),Fc("f4",e,t,zc,1,1,1),Fc("u1",e,t,zc,.7,1.1,-1),Fc("u2",e,t,zc,-.7,1.1,-1),Fc("u3",e,t,zc,0,2,-1),Fc("cf1",e,t,zc,-1,0,1),Fc("cf2",e,t,zc,1,0,1),Fc("cf3",e,t,zc,0,-1,1),Fc("cf4",e,t,zc,0,1,1),Fc("cn1",e,t,zc,-1,0,-1),Fc("cn2",e,t,zc,1,0,-1),Fc("cn3",e,t,zc,0,-1,-1),Fc("cn4",e,t,zc,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},t.CanvasTexture=Qa,t.CatmullRomCurve3=vs,t.CineonToneMapping=3,t.CircleBufferGeometry=ts,t.CircleGeometry=ts,t.ClampToEdgeWrapping=h,t.Clock=Vu,t.Color=Je,t.ColorKeyframeTrack=zl,t.CompressedTexture=Ka,t.CompressedTextureLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=[],a=new Ka,s=new Jl(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function u(u){s.load(t[u],(function(t){const n=i.parse(t,!0);o[u]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(l+=1)&&(1===n.mipmapCount&&(a.minFilter=g),a.image=o,a.format=n.format,a.needsUpdate=!0,e&&e(a))}),n,r)}if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)u(e);else s.load(t,(function(t){const n=i.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){o[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)o[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),o[e].format=n.format,o[e].width=n.width,o[e].height=n.height}a.image=o}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=g),a.format=n.format,a.needsUpdate=!0,e&&e(a)}),n,r);return a}},t.ConeBufferGeometry=ns,t.ConeGeometry=ns,t.CubeCamera=Yn,t.CubeReflectionMapping=i,t.CubeRefractionMapping=o,t.CubeTexture=Jn,t.CubeTextureLoader=Ql,t.CubeUVReflectionMapping=l,t.CubeUVRefractionMapping=u,t.CubicBezierCurve=ws,t.CubicBezierCurve3=Es,t.CubicInterpolant=Rl,t.CullFaceBack=1,t.CullFaceFront=2,t.CullFaceFrontBack=3,t.CullFaceNone=0,t.Curve=cs,t.CurvePath=eu,t.CustomBlending=5,t.CustomToneMapping=5,t.CylinderBufferGeometry=es,t.CylinderGeometry=es,t.Cylindrical=class{constructor(t=1,e=0,n=0){return this.radius=t,this.theta=e,this.y=n,this}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return(new this.constructor).copy(this)}},t.DataTexture=wa,t.DataTexture2DArray=Xr,t.DataTexture3D=Zr,t.DataTextureLoader=$l,t.DataUtils=class{static toHalfFloat(t){qc[0]=t;const e=Wc[0];let n=e>>16&32768,r=e>>12&2047;const i=e>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&e):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)}},t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=Xl,t.DepthFormat=C,t.DepthStencilFormat=I,t.DepthTexture=$a,t.DirectionalLight=vu,t.DirectionalLightHelper=class extends Le{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===e&&(e=1);let r=new wn;r.setAttribute("position",new cn([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const i=new Ra({fog:!1,toneMapped:!1});this.lightPlane=new Fa(r,i),this.add(this.lightPlane),(r=new wn).setAttribute("position",new cn([0,0,0,0,0,1],3)),this.targetLine=new Fa(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Dc.setFromMatrixPosition(this.light.matrixWorld),Nc.setFromMatrixPosition(this.light.target.matrixWorld),Oc.subVectors(Nc,Dc),this.lightPlane.lookAt(Nc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Nc),this.targetLine.scale.z=Oc.length()}},t.DiscreteInterpolant=Nl,t.DodecahedronBufferGeometry=is,t.DodecahedronGeometry=is,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicBufferAttribute=function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new tn(t,e).setUsage(et)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=et,t.DynamicReadUsage=35049,t.EdgesGeometry=us,t.EdgesHelper=function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Va(new us(t.geometry),new Ra({color:void 0!==e?e:16777215}))},t.EllipseCurve=hs,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=a,t.EquirectangularRefractionMapping=s,t.Euler=me,t.EventDispatcher=rt,t.ExtrudeBufferGeometry=rl,t.ExtrudeGeometry=rl,t.FaceColors=1,t.FileLoader=Jl,t.FlatShading=1,t.Float16BufferAttribute=un,t.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new cn(t,e)},t.Float32BufferAttribute=cn,t.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new hn(t,e)},t.Float64BufferAttribute=hn,t.FloatType=w,t.Fog=qo,t.FogExp2=Ho,t.Font=Ru,t.FontLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(i.withCredentials),o.load(t,(function(t){let n;try{n=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}const r=i.parse(n);e&&e(r)}),n,r)}parse(t){return new Ru(t)}},t.FrontSide=0,t.Frustum=ir,t.GLBufferAttribute=mc,t.GLSL1="100",t.GLSL3=nt,t.GammaEncoding=Y,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Rc,t.Group=zo,t.HalfFloatType=E,t.HemisphereLight=ou,t.HemisphereLightHelper=class extends Le{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new sl(e);r.rotateY(.5*Math.PI),this.material=new Ke({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),o=new Float32Array(3*i.count);r.setAttribute("color",new tn(o,3)),this.add(new Un(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Lc.copy(this.light.color),Pc.copy(this.light.groundColor);for(let t=0,n=e.count;t<n;t++){const r=t<n/2?Lc:Pc;e.setXYZ(t,r.r,r.g,r.b)}e.needsUpdate=!0}t.lookAt(Ac.setFromMatrixPosition(this.light.matrixWorld).negate())}},t.HemisphereLightProbe=zu,t.IcosahedronBufferGeometry=ol,t.IcosahedronGeometry=ol,t.ImageBitmapLoader=Lu,t.ImageLoader=Kl,t.ImageUtils=_t,t.ImmediateRenderObject=Ec,t.IncrementStencilOp=7682,t.IncrementWrapStencilOp=34055,t.InstancedBufferAttribute=Ta,t.InstancedBufferGeometry=Mu,t.InstancedInterleavedBuffer=dc,t.InstancedMesh=Pa,t.Int16Attribute=function(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new on(t,e)},t.Int16BufferAttribute=on,t.Int32Attribute=function(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new sn(t,e)},t.Int32BufferAttribute=sn,t.Int8Attribute=function(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new en(t,e)},t.Int8BufferAttribute=en,t.IntType=1013,t.InterleavedBuffer=Xo,t.InterleavedBufferAttribute=Yo,t.Interpolant=Pl,t.InterpolateDiscrete=B,t.InterpolateLinear=U,t.InterpolateSmooth=V,t.InvertStencilOp=5386,t.JSONLoader=function(){console.error("THREE.JSONLoader has been removed.")},t.KeepStencilOp=7680,t.KeyframeTrack=Ol,t.LOD=da,t.LatheBufferGeometry=al,t.LatheGeometry=al,t.Layers=ge,t.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")},t.LessDepth=2,t.LessEqualDepth=3,t.LessEqualStencilFunc=515,t.LessStencilFunc=513,t.Light=iu,t.LightProbe=wu,t.Line=Fa,t.Line3=wc,t.LineBasicMaterial=Ra,t.LineCurve=Ss,t.LineCurve3=Ms,t.LineDashedMaterial=Il,t.LineLoop=Ga,t.LinePieces=1,t.LineSegments=Va,t.LineStrip=0,t.LinearEncoding=X,t.LinearFilter=g,t.LinearInterpolant=Dl,t.LinearMipMapLinearFilter=1008,t.LinearMipMapNearestFilter=1007,t.LinearMipmapLinearFilter=v,t.LinearMipmapNearestFilter=y,t.LinearToneMapping=1,t.Loader=Zl,t.LoaderUtils=Su,t.LoadingManager=Wl,t.LogLuvEncoding=3003,t.LoopOnce=2200,t.LoopPingPong=2202,t.LoopRepeat=2201,t.LuminanceAlphaFormat=1025,t.LuminanceFormat=1024,t.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},t.Material=je,t.MaterialLoader=Eu,t.Math=mt,t.MathUtils=mt,t.Matrix3=yt,t.Matrix4=oe,t.MaxEquation=104,t.Mesh=Un,t.MeshBasicMaterial=Ke,t.MeshDepthMaterial=Lo,t.MeshDistanceMaterial=Po,t.MeshFaceMaterial=function(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t},t.MeshLambertMaterial=Tl,t.MeshMatcapMaterial=Cl,t.MeshNormalMaterial=Ml,t.MeshPhongMaterial=El,t.MeshPhysicalMaterial=wl,t.MeshStandardMaterial=bl,t.MeshToonMaterial=Sl,t.MinEquation=103,t.MirroredRepeatWrapping=p,t.MixOperation=1,t.MultiMaterial=function(t=[]){return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),t.isMultiMaterial=!0,t.materials=t,t.clone=function(){return t.slice()},t},t.MultiplyBlending=4,t.MultiplyOperation=0,t.NearestFilter=f,t.NearestMipMapLinearFilter=1005,t.NearestMipMapNearestFilter=1004,t.NearestMipmapLinearFilter=m,t.NearestMipmapNearestFilter=d,t.NeverDepth=0,t.NeverStencilFunc=512,t.NoBlending=0,t.NoColors=0,t.NoToneMapping=0,t.NormalAnimationBlendMode=q,t.NormalBlending=1,t.NotEqualDepth=7,t.NotEqualStencilFunc=517,t.NumberKeyframeTrack=Fl,t.Object3D=Le,t.ObjectLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=""===this.path?Su.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;const a=new Jl(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(n){let o=null;try{o=JSON.parse(n)}catch(e){return void 0!==r&&r(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?i.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t)}),n,r)}async loadAsync(t,e){const n=""===this.path?Su.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const r=new Jl(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const i=await r.loadAsync(t,e),o=JSON.parse(i),a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(o)}parse(t,e){const n=this.parseAnimations(t.animations),r=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,r),o=this.parseImages(t.images,(function(){void 0!==e&&e(l)})),a=this.parseTextures(t.textures,o),s=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,i,s,a,n),u=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,u),void 0!==e){let t=!1;for(const e in o)if(o[e]instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),i=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,i),a=this.parseMaterials(t.materials,o),s=this.parseObject(t.object,r,a,o,e),l=this.parseSkeletons(t.skeletons,s);return this.bindSkeletons(s,l),s}parseShapes(t){const e={};if(void 0!==t)for(let n=0,r=t.length;n<r;n++){const r=(new ru).fromJSON(t[n]);e[r.uuid]=r}return e}parseSkeletons(t,e){const n={},r={};if(e.traverse((function(t){t.isBone&&(r[t.uuid]=t)})),void 0!==t)for(let e=0,i=t.length;e<i;e++){const i=(new Ma).fromJSON(t[e],r);n[i.uuid]=i}return n}parseGeometries(t,e){const n={};if(void 0!==t){const r=new Tu;for(let i=0,o=t.length;i<o;i++){let o;const a=t[i];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(a);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:a.type in _l?o=_l[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),!0===o.isBufferGeometry&&void 0!==a.userData&&(o.userData=a.userData),n[a.uuid]=o}}return n}parseMaterials(t,e){const n={},r={};if(void 0!==t){const i=new Eu;i.setTextures(e);for(let e=0,o=t.length;e<o;e++){const o=t[e];if("MultiMaterial"===o.type){const t=[];for(let e=0;e<o.materials.length;e++){const r=o.materials[e];void 0===n[r.uuid]&&(n[r.uuid]=i.parse(r)),t.push(n[r.uuid])}r[o.uuid]=t}else void 0===n[o.uuid]&&(n[o.uuid]=i.parse(o)),r[o.uuid]=n[o.uuid]}}return r}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const r=t[n],i=jl.parse(r);e[i.uuid]=i}return e}parseImages(t,e){const n=this,r={};let i;function o(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),i.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemError(t),n.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:dn(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new Wl(e);(i=new Kl(n)).setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],i=n.url;if(Array.isArray(i)){r[n.uuid]=[];for(let t=0,e=i.length;t<e;t++){const e=o(i[t]);null!==e&&(e instanceof HTMLImageElement?r[n.uuid].push(e):r[n.uuid].push(new wa(e.data,e.width,e.height)))}}else{const t=o(n.url);null!==t&&(r[n.uuid]=t)}}}return r}async parseImagesAsync(t){const e=this,n={};let r;async function i(t){if("string"==typeof t){const n=t,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await r.loadAsync(i)}return t.data?{data:dn(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){(r=new Kl(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e<r;e++){const r=t[e],o=r.url;if(Array.isArray(o)){n[r.uuid]=[];for(let t=0,e=o.length;t<e;t++){const e=o[t],a=await i(e);null!==a&&(a instanceof HTMLImageElement?n[r.uuid].push(a):n[r.uuid].push(new wa(a.data,a.width,a.height)))}}else{const t=await i(r.url);null!==t&&(n[r.uuid]=t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const r={};if(void 0!==t)for(let i=0,o=t.length;i<o;i++){const o=t[i];let a;void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===e[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const s=e[o.image];Array.isArray(s)?(a=new Jn(s),6===s.length&&(a.needsUpdate=!0)):(a=s&&s.data?new wa(s.data,s.width,s.height):new bt(s),s&&(a.needsUpdate=!0)),a.uuid=o.uuid,void 0!==o.name&&(a.name=o.name),void 0!==o.mapping&&(a.mapping=n(o.mapping,Cu)),void 0!==o.offset&&a.offset.fromArray(o.offset),void 0!==o.repeat&&a.repeat.fromArray(o.repeat),void 0!==o.center&&a.center.fromArray(o.center),void 0!==o.rotation&&(a.rotation=o.rotation),void 0!==o.wrap&&(a.wrapS=n(o.wrap[0],Iu),a.wrapT=n(o.wrap[1],Iu)),void 0!==o.format&&(a.format=o.format),void 0!==o.type&&(a.type=o.type),void 0!==o.encoding&&(a.encoding=o.encoding),void 0!==o.minFilter&&(a.minFilter=n(o.minFilter,Au)),void 0!==o.magFilter&&(a.magFilter=n(o.magFilter,Au)),void 0!==o.anisotropy&&(a.anisotropy=o.anisotropy),void 0!==o.flipY&&(a.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(a.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(a.unpackAlignment=o.unpackAlignment),r[o.uuid]=a}return r}parseObject(t,e,n,r,i){let o,a,s;function l(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function u(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let r=0,i=t.length;r<i;r++){const i=t[r];void 0===n[i]&&console.warn("THREE.ObjectLoader: Undefined material",i),e.push(n[i])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}function c(t){return void 0===r[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),r[t]}switch(t.type){case"Scene":o=new Wo,void 0!==t.background&&(Number.isInteger(t.background)?o.background=new Je(t.background):o.background=c(t.background)),void 0!==t.environment&&(o.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?o.fog=new qo(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(o.fog=new Ho(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":o=new Zn(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(o.focus=t.focus),void 0!==t.zoom&&(o.zoom=t.zoom),void 0!==t.filmGauge&&(o.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(o.filmOffset=t.filmOffset),void 0!==t.view&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new yr(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(o.zoom=t.zoom),void 0!==t.view&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new _u(t.color,t.intensity);break;case"DirectionalLight":o=new vu(t.color,t.intensity);break;case"PointLight":o=new gu(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new xu(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new hu(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":o=new ou(t.color,t.groundColor,t.intensity);break;case"LightProbe":o=(new wu).fromJSON(t);break;case"SkinnedMesh":a=l(t.geometry),s=u(t.material),o=new xa(a,s),void 0!==t.bindMode&&(o.bindMode=t.bindMode),void 0!==t.bindMatrix&&o.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(o.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),s=u(t.material),o=new Un(a,s);break;case"InstancedMesh":a=l(t.geometry),s=u(t.material);const e=t.count,n=t.instanceMatrix,r=t.instanceColor;(o=new Pa(a,s,e)).instanceMatrix=new Ta(new Float32Array(n.array),16),void 0!==r&&(o.instanceColor=new Ta(new Float32Array(r.array),r.itemSize));break;case"LOD":o=new da;break;case"Line":o=new Fa(l(t.geometry),u(t.material));break;case"LineLoop":o=new Ga(l(t.geometry),u(t.material));break;case"LineSegments":o=new Va(l(t.geometry),u(t.material));break;case"PointCloud":case"Points":o=new Za(l(t.geometry),u(t.material));break;case"Sprite":o=new ca(u(t.material));break;case"Group":o=new zo;break;case"Bone":o=new ba;break;default:o=new Le}if(o.uuid=t.uuid,void 0!==t.name&&(o.name=t.name),void 0!==t.matrix?(o.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==t.position&&o.position.fromArray(t.position),void 0!==t.rotation&&o.rotation.fromArray(t.rotation),void 0!==t.quaternion&&o.quaternion.fromArray(t.quaternion),void 0!==t.scale&&o.scale.fromArray(t.scale)),void 0!==t.castShadow&&(o.castShadow=t.castShadow),void 0!==t.receiveShadow&&(o.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(o.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(o.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(o.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&o.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(o.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(o.visible=t.visible),void 0!==t.frustumCulled&&(o.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(o.renderOrder=t.renderOrder),void 0!==t.userData&&(o.userData=t.userData),void 0!==t.layers&&(o.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)o.add(this.parseObject(a[t],e,n,r,i))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];o.animations.push(i[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(o.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],r=o.getObjectByProperty("uuid",n.object);void 0!==r&&o.addLevel(r,n.distance)}}return o}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}}))}setTexturePath(t){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(t)}},t.ObjectSpaceNormalMap=1,t.OctahedronBufferGeometry=sl,t.OctahedronGeometry=sl,t.OneFactor=201,t.OneMinusDstAlphaFactor=207,t.OneMinusDstColorFactor=209,t.OneMinusSrcAlphaFactor=205,t.OneMinusSrcColorFactor=203,t.OrthographicCamera=yr,t.PCFShadowMap=1,t.PCFSoftShadowMap=2,t.PMREMGenerator=Rr,t.ParametricBufferGeometry=ll,t.ParametricGeometry=ll,t.Particle=function(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new ca(t)},t.ParticleBasicMaterial=function(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new ja(t)},t.ParticleSystem=function(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new Za(t,e)},t.ParticleSystemMaterial=function(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new ja(t)},t.Path=nu,t.PerspectiveCamera=Zn,t.Plane=er,t.PlaneBufferGeometry=sr,t.PlaneGeometry=sr,t.PlaneHelper=class extends Fa{constructor(t,e=1,n=16776960){const r=n,i=new wn;i.setAttribute("position",new cn([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),i.computeBoundingSphere(),super(i,new Ra({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const o=new wn;o.setAttribute("position",new cn([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new Un(o,new Ke({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){let e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.children[0].material.side=e<0?1:0,this.lookAt(this.plane.normal),super.updateMatrixWorld(t)}},t.PointCloud=function(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new Za(t,e)},t.PointCloudMaterial=function(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new ja(t)},t.PointLight=gu,t.PointLightHelper=class extends Un{constructor(t,e,n){super(new hl(e,4,2),new Ke({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},t.Points=Za,t.PointsMaterial=ja,t.PolarGridHelper=class extends Va{constructor(t=10,e=16,n=8,r=64,i=4473924,o=8947848){i=new Je(i),o=new Je(o);const a=[],s=[];for(let n=0;n<=e;n++){const r=n/e*(2*Math.PI),l=Math.sin(r)*t,u=Math.cos(r)*t;a.push(0,0,0),a.push(l,0,u);const c=1&n?i:o;s.push(c.r,c.g,c.b),s.push(c.r,c.g,c.b)}for(let e=0;e<=n;e++){const l=1&e?i:o,u=t-t/n*e;for(let t=0;t<r;t++){let e=t/r*(2*Math.PI),n=Math.sin(e)*u,i=Math.cos(e)*u;a.push(n,0,i),s.push(l.r,l.g,l.b),e=(t+1)/r*(2*Math.PI),n=Math.sin(e)*u,i=Math.cos(e)*u,a.push(n,0,i),s.push(l.r,l.g,l.b)}}const l=new wn;l.setAttribute("position",new cn(a,3)),l.setAttribute("color",new cn(s,3)),super(l,new Ra({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}},t.PolyhedronBufferGeometry=rs,t.PolyhedronGeometry=rs,t.PositionalAudio=class extends Xu{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Zu,Yu,Ju),Ku.set(0,0,1).applyQuaternion(Yu);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Zu.x,t),e.positionY.linearRampToValueAtTime(Zu.y,t),e.positionZ.linearRampToValueAtTime(Zu.z,t),e.orientationX.linearRampToValueAtTime(Ku.x,t),e.orientationY.linearRampToValueAtTime(Ku.y,t),e.orientationZ.linearRampToValueAtTime(Ku.z,t)}else e.setPosition(Zu.x,Zu.y,Zu.z),e.setOrientation(Ku.x,Ku.y,Ku.z)}},t.PropertyBinding=uc,t.PropertyMixer=$u,t.QuadraticBezierCurve=Ts,t.QuadraticBezierCurve3=Cs,t.Quaternion=Ct,t.QuaternionKeyframeTrack=Ul,t.QuaternionLinearInterpolant=Bl,t.REVISION=e,t.RGBADepthPacking=3201,t.RGBAFormat=T,t.RGBAIntegerFormat=1033,t.RGBA_ASTC_10x10_Format=37819,t.RGBA_ASTC_10x5_Format=37816,t.RGBA_ASTC_10x6_Format=37817,t.RGBA_ASTC_10x8_Format=37818,t.RGBA_ASTC_12x10_Format=37820,t.RGBA_ASTC_12x12_Format=37821,t.RGBA_ASTC_4x4_Format=37808,t.RGBA_ASTC_5x4_Format=37809,t.RGBA_ASTC_5x5_Format=37810,t.RGBA_ASTC_6x5_Format=37811,t.RGBA_ASTC_6x6_Format=37812,t.RGBA_ASTC_8x5_Format=37813,t.RGBA_ASTC_8x6_Format=37814,t.RGBA_ASTC_8x8_Format=37815,t.RGBA_BPTC_Format=36492,t.RGBA_ETC2_EAC_Format=F,t.RGBA_PVRTC_2BPPV1_Format=k,t.RGBA_PVRTC_4BPPV1_Format=O,t.RGBA_S3TC_DXT1_Format=L,t.RGBA_S3TC_DXT3_Format=P,t.RGBA_S3TC_DXT5_Format=R,t.RGBDEncoding=$,t.RGBEEncoding=J,t.RGBEFormat=1023,t.RGBFormat=M,t.RGBIntegerFormat=1032,t.RGBM16Encoding=Q,t.RGBM7Encoding=K,t.RGB_ETC1_Format=36196,t.RGB_ETC2_Format=z,t.RGB_PVRTC_2BPPV1_Format=N,t.RGB_PVRTC_4BPPV1_Format=D,t.RGB_S3TC_DXT1_Format=A,t.RGFormat=1030,t.RGIntegerFormat=1031,t.RawShaderMaterial=vr,t.Ray=ie,t.Raycaster=class{constructor(t,e,n=0,r=1/0){this.ray=new ie(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new ge,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!1,n=[]){return yc(t,this,n,e),n.sort(gc),n}intersectObjects(t,e=!1,n=[]){for(let r=0,i=t.length;r<i;r++)yc(t[r],this,n,e);return n.sort(gc),n}},t.RectAreaLight=xu,t.RedFormat=1028,t.RedIntegerFormat=1029,t.ReinhardToneMapping=2,t.RepeatWrapping=c,t.ReplaceStencilOp=7681,t.ReverseSubtractEquation=102,t.RingBufferGeometry=ul,t.RingGeometry=ul,t.SRGB8_ALPHA8_ASTC_10x10_Format=37851,t.SRGB8_ALPHA8_ASTC_10x5_Format=37848,t.SRGB8_ALPHA8_ASTC_10x6_Format=37849,t.SRGB8_ALPHA8_ASTC_10x8_Format=37850,t.SRGB8_ALPHA8_ASTC_12x10_Format=37852,t.SRGB8_ALPHA8_ASTC_12x12_Format=37853,t.SRGB8_ALPHA8_ASTC_4x4_Format=37840,t.SRGB8_ALPHA8_ASTC_5x4_Format=37841,t.SRGB8_ALPHA8_ASTC_5x5_Format=37842,t.SRGB8_ALPHA8_ASTC_6x5_Format=37843,t.SRGB8_ALPHA8_ASTC_6x6_Format=37844,t.SRGB8_ALPHA8_ASTC_8x5_Format=37845,t.SRGB8_ALPHA8_ASTC_8x6_Format=37846,t.SRGB8_ALPHA8_ASTC_8x8_Format=37847,t.Scene=Wo,t.SceneUtils=Xc,t.ShaderChunk=lr,t.ShaderLib=cr,t.ShaderMaterial=Wn,t.ShadowMaterial=xl,t.Shape=ru,t.ShapeBufferGeometry=cl,t.ShapeGeometry=cl,t.ShapePath=Pu,t.ShapeUtils=tl,t.ShortType=1011,t.Skeleton=Ma,t.SkeletonHelper=Ic,t.SkinnedMesh=xa,t.SmoothShading=2,t.Sphere=Jt,t.SphereBufferGeometry=hl,t.SphereGeometry=hl,t.Spherical=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(ut(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},t.SphericalHarmonics3=bu,t.SplineCurve=Is,t.SpotLight=hu,t.SpotLightHelper=class extends Le{constructor(t,e){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;const n=new wn,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t<n;t++,e++){const i=t/n*Math.PI*2,o=e/n*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(o),Math.sin(o),1)}n.setAttribute("position",new cn(r,3));const i=new Ra({fog:!1,toneMapped:!1});this.cone=new Va(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Sc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Sc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},t.Sprite=ca,t.SpriteMaterial=Jo,t.SrcAlphaFactor=204,t.SrcAlphaSaturateFactor=210,t.SrcColorFactor=202,t.StaticCopyUsage=35046,t.StaticDrawUsage=tt,t.StaticReadUsage=35045,t.StereoCamera=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Zn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Zn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;const n=t.projectionMatrix.clone(),r=e.eyeSep/2,i=r*e.near/e.focus,o=e.near*Math.tan(at*e.fov*.5)/e.zoom;let a,s;Uu.elements[12]=-r,Bu.elements[12]=r,a=-o*e.aspect+i,s=o*e.aspect+i,n.elements[0]=2*e.near/(s-a),n.elements[8]=(s+a)/(s-a),this.cameraL.projectionMatrix.copy(n),a=-o*e.aspect-i,s=o*e.aspect-i,n.elements[0]=2*e.near/(s-a),n.elements[8]=(s+a)/(s-a),this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Uu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Bu)}},t.StreamCopyUsage=35042,t.StreamDrawUsage=35040,t.StreamReadUsage=35041,t.StringKeyframeTrack=Vl,t.SubtractEquation=101,t.SubtractiveBlending=3,t.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},t.TangentSpaceNormalMap=0,t.TetrahedronBufferGeometry=pl,t.TetrahedronGeometry=pl,t.TextBufferGeometry=fl,t.TextGeometry=fl,t.Texture=bt,t.TextureLoader=tu,t.TorusBufferGeometry=dl,t.TorusGeometry=dl,t.TorusKnotBufferGeometry=ml,t.TorusKnotGeometry=ml,t.Triangle=Ve,t.TriangleFanDrawMode=2,t.TriangleStripDrawMode=1,t.TrianglesDrawMode=0,t.TubeBufferGeometry=gl,t.TubeGeometry=gl,t.UVMapping=r,t.Uint16Attribute=function(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new an(t,e)},t.Uint16BufferAttribute=an,t.Uint32Attribute=function(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ln(t,e)},t.Uint32BufferAttribute=ln,t.Uint8Attribute=function(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new nn(t,e)},t.Uint8BufferAttribute=nn,t.Uint8ClampedAttribute=function(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new rn(t,e)},t.Uint8ClampedBufferAttribute=rn,t.Uniform=fc,t.UniformsLib=ur,t.UniformsUtils=qn,t.UnsignedByteType=_,t.UnsignedInt248Type=S,t.UnsignedIntType=b,t.UnsignedShort4444Type=1017,t.UnsignedShort5551Type=1018,t.UnsignedShort565Type=1019,t.UnsignedShortType=x,t.VSMShadowMap=3,t.Vector2=gt,t.Vector3=It,t.Vector4=Et,t.VectorKeyframeTrack=Gl,t.Vertex=function(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new It(t,e,n)},t.VertexColors=2,t.VideoTexture=Ja,t.WebGL1Renderer=jo,t.WebGLCubeRenderTarget=Kn,t.WebGLMultipleRenderTargets=Mt,t.WebGLMultisampleRenderTarget=Tt,t.WebGLRenderTarget=St,t.WebGLRenderTargetCube=function(t,e,n){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new Kn(t,n)},t.WebGLRenderer=Go,t.WebGLUtils=Oo,t.WireframeGeometry=yl,t.WireframeHelper=function(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new Va(new yl(t.geometry),new Ra({color:void 0!==e?e:16777215}))},t.WrapAroundEnding=H,t.XHRLoader=function(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Jl(t)},t.ZeroCurvatureEnding=G,t.ZeroFactor=200,t.ZeroSlopeEnding=j,t.ZeroStencilOp=0,t.sRGBEncoding=Z,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof r.exports?e(r.exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={}),r=r.exports;var i={};const a=.1/180*Math.PI,s=Math.atan(.75);i=i={WORLD_SIZE:1024e3,PROJECTION_WORLD_SIZE:1024e3/(6371008.8*Math.PI*2),MERCATOR_A:6371008.8,DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,EARTH_RADIUS:6371008.8,EARTH_CIRCUMFERENCE:2*Math.PI*6371008.8,EARTH_CIRCUMFERENCE_EQUATOR:40075017,FOV_ORTHO:a,FOV:s,FOV_DEGREES:180*s/Math.PI,TILE_SIZE:512};var l={};function u(){}u.prototype={Coords:function(t){if(t.constructor===Array)if(t.length<2)console.error("Coords length must be at least 2");else{for(const e of t)if(e.constructor!==Number)return void console.error("Coords values must be numbers");if(!(Math.abs(t[1])>90))return t;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(t){if(t.constructor===Array){for(const e of t)if(!this.Coords(e))return void console.error("Each coordinate in a line must be a valid Coords type");return t}console.error("Line must be an array")},Rotation:function(t){if(t.constructor===Number)t={z:t};else{if(t.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Rotation parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return t},Scale:function(t){if(t.constructor===Number)t={x:t,y:t,z:t};else{if(t.constructor!==Object)return void console.error("Scale must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Scale parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return t}},l=l=u;var c={},h={prettyPrintMatrix:function(t){for(var e=0;e<4;e++){var n=[t[e],t[e+4],t[e+8],t[e+12]];console.log(n.map((function(t){return t.toFixed(4)})))}},makePerspectiveMatrix:function(t,e,n,i){var o=new r.Matrix4,a=1/Math.tan(t/2),s=1/(n-i),l=[a/e,0,0,0,0,a,0,0,0,0,(i+n)*s,-1,0,0,2*i*n*s,0];return o.elements=l,o},makeOrthographicMatrix:function(t,e,n,i,o,a){var s=new r.Matrix4;const l=1/(e-t),u=1/(n-i),c=1/(a-o);var h=[2*l,0,0,0,0,2*u,0,0,0,0,-1*c,0,-(e+t)*l,-(n+i)*u,-o*c,1];return s.elements=h,s},radify:function(t){function e(t){return t=t||0,2*Math.PI*t/360}return"object"==typeof t?t.length>0?t.map((function(t){return e(t)})):[e(t.x),e(t.y),e(t.z)]:e(t)},degreeify:function(t){function e(t){return 360*(t=t||0)/(2*Math.PI)}return"object"==typeof t?[e(t.x),e(t.y),e(t.z)]:e(t)},projectToWorld:function(t){var e=[-i.MERCATOR_A*i.DEG2RAD*t[0]*i.PROJECTION_WORLD_SIZE,-i.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*i.DEG2RAD*t[1]))*i.PROJECTION_WORLD_SIZE];if(t[2]){var n=this.projectedUnitsPerMeter(t[1]);e.push(t[2]*n)}else e.push(0);return new r.Vector3(e[0],e[1],e[2])},projectedUnitsPerMeter:function(t){return Math.abs(i.WORLD_SIZE/Math.cos(i.DEG2RAD*t)/i.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(t){return i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180)},mercatorZfromAltitude:function(t,e){return t/this._circumferenceAtLatitude(e)},_scaleVerticesToMeters:function(t,e){for(var n=this.projectedUnitsPerMeter(t[1]),r=(this.projectToWorld(t),0);r<e.length;r++)e[r].multiplyScalar(n);return e},projectToScreen:function(t){console.log("WARNING: Projecting to screen coordinates is not yet implemented")},unprojectFromScreen:function(t){console.log("WARNING: unproject is not yet implemented")},unprojectFromWorld:function(t){var e=[-t.x/(i.MERCATOR_A*i.DEG2RAD*i.PROJECTION_WORLD_SIZE),2*(Math.atan(Math.exp(t.y/(i.PROJECTION_WORLD_SIZE*-i.MERCATOR_A)))-Math.PI/4)/i.DEG2RAD],n=this.projectedUnitsPerMeter(e[1]),r=t.z||0;return e.push(r/n),e},toScreenPosition:function(t,e){var n=new r.Vector3,i=.5*renderer.context.canvas.width,o=.5*renderer.context.canvas.height;return t.updateMatrixWorld(),n.setFromMatrixPosition(t.matrixWorld),n.project(e),n.x=n.x*i+i,n.y=-n.y*o+o,{x:n.x,y:n.y}},getFeatureCenter:function(t,e,n){let r=[],i=0,o=0,a=0,s=[...t.geometry.coordinates[0]];return"Point"===t.geometry.type?r=[...s[0]]:("MultiPolygon"===t.geometry.type&&(s=s[0]),s.splice(-1,1),s.forEach((function(t){i+=t[0],o+=t[1]})),r=[i/s.length,o/s.length]),a=this.getObjectHeightOnFloor(t,e,n),r.length<3?r.push(a):r[2]=a,r},getObjectHeightOnFloor:function(t,e,n=t.properties.level||0){let r=n*(t.properties.levelHeight||0),i=t.properties.base_height||t.properties.min_height||0;return r+((e&&e.model?0:t.properties.height-i)+i)},_flipMaterialSides:function(t){},normalizeVertices(t){let e=new r.BufferGeometry,n=[];for(var i=0;i<t.length;i++){let e=t[i];n.push(e.x,e.y,e.z),n.push(e.x,e.y,e.z)}e.setAttribute("position",new r.BufferAttribute(new Float32Array(n),3)),e.computeBoundingSphere();var o=e.boundingSphere.center;return{vertices:t.map((function(t){return t.sub(o)})),position:o}},flattenVectors(t){var e=[];for(let n of t)e.push(n.x,n.y,n.z);return e},lnglatsToWorld:function(t){return t.map((function(t){var e=h.projectToWorld(t);return new r.Vector3(e.x,e.y,e.z)}))},extend:function(t,e){for(let n in e)t[n]=e[n]},clone:function(t){var e={};for(let n in t)e[n]=t[n];return e},clamp:function(t,e,n){return Math.min(n,Math.max(e,t))},types:{rotation:function(t,e){t||(t=0),"number"==typeof t&&(t={z:t});var n=this.applyDefault([t.x,t.y,t.z],e);return h.radify(n)},scale:function(t,e){return t||(t=1),"number"==typeof t?[t,t,t]:this.applyDefault([t.x,t.y,t.z],e)},applyDefault:function(t,e){return t.map((function(t,n){return t||e[n]}))}},toDecimal:function(t,e){return Number(t.toFixed(e))},equal:function(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;if(0==n.length&&0==r.length&&n!==r)return!1;for(const r of n){const n=t[r],i=e[r],o=this.isObject(n)&&this.isObject(i);if(o&&!equal(n,i)||!o&&n!==i)return!1}return!0},isObject:function(t){return null!=t&&"object"==typeof t},curveToLine:(t,e)=>{let{width:n,color:i}=e,o=(new r.BufferGeometry).setFromPoints(t.getPoints(100)),a=new r.LineBasicMaterial({color:i,linewidth:n});return new r.Line(o,a)},curvesToLines:t=>{var e=[16711680,2031360,2490623];return t.map(((t,n)=>curveToLine(t,{width:3,color:e[n]||"purple"})))},_validate:function(t,e){t=t||{};var n={};h.extend(n,t);for(let r of Object.keys(e))if(void 0===t[r]){if(null===e[r])return void console.error(r+" is required");n[r]=e[r]}else n[r]=t[r];return n},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};c=c=h;var p={};function f(t,e,n){this.map=t,this.camera=e,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new r.Group,this.world.position.x=this.world.position.y=i.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new r.Matrix4).makeTranslation(i.WORLD_SIZE/2,-i.WORLD_SIZE/2,0),worldSizeRatio:i.TILE_SIZE/i.WORLD_SIZE,worldSize:i.TILE_SIZE*this.map.transform.scale};let o=this;this.map.on("move",(function(){o.updateCamera()})).on("resize",(function(){o.setupCamera()})),this.setupCamera()}f.prototype={setupCamera:function(){const t=this.map.transform;this.camera.aspect=t.width/t.height,this.halfFov=t._fov/2,this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height;const e=t._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-e,this.updateCamera()},updateCamera:function(t){if(!this.camera)return void console.log("nocamera");const e=this.map.transform;this.camera.aspect=e.width/e.height;const n=e.centerOffset||new r.Vector3;let i=0,o=0;this.halfFov=e._fov/2;const a=Math.PI/2+e._pitch,s=Math.cos(Math.PI/2-e._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;let l=1;const u=this.worldSize();if(this.map.tb.mapboxVersion>=2){l=this.mercatorZfromAltitude(1,e.center.lat)*u;const t=e._fov*(.5+e.centerOffset.y/e.height),n=e.elevation?e.elevation.getMinElevationBelowMSL()*l:0,r=(e._camera.position[2]*u-n)/Math.cos(e._pitch);o=s*(Math.sin(t)*r/Math.sin(c.clamp(Math.PI-a-t,.01,Math.PI-.01)))+r;const h=r*(1/e._horizonShift);i=Math.min(1.01*o,h)}else i=1.01*(o=s*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-a-this.halfFov))+this.cameraToCenterDistance);this.cameraTranslateZ=(new r.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const h=e.height/50,p=Math.max(h*s,h),d=e.height,m=e.width;this.camera instanceof r.OrthographicCamera?this.camera.projectionMatrix=c.makeOrthographicMatrix(m/-2,m/2,d/2,d/-2,p,i):this.camera.projectionMatrix=c.makePerspectiveMatrix(e._fov,m/d,p,i),this.camera.projectionMatrix.elements[8]=2*-n.x/e.width,this.camera.projectionMatrix.elements[9]=2*n.y/e.height;let g=this.calcCameraMatrix(e._pitch,e.angle);e.elevation&&(g.elements[14]=e._camera.position[2]*u),this.camera.matrixWorld.copy(g);let y=e.scale*this.state.worldSizeRatio,v=new r.Matrix4,_=new r.Matrix4,x=new r.Matrix4;v.makeScale(y,y,y);let b=e.x||e.point.x,w=e.y||e.point.y;_.makeTranslation(-b,w,0),x.makeRotationZ(Math.PI),this.world.matrix=(new r.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(v).premultiply(_),this.map.fire("CameraSynced",{detail:{nearZ:p,farZ:i,pitch:e._pitch,angle:e.angle,furthestDistance:o,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:f}})},worldSize(){let t=this.map.transform;return t.tileSize*t.scale},worldSizeFromZoom(){let t=this.map.transform;return Math.pow(2,t.zoom)*t.tileSize},mercatorZfromAltitude(t,e){return t/this.circumferenceAtLatitude(e)},mercatorZfromZoom(){return this.cameraToCenterDistance/this.worldSizeFromZoom()},circumferenceAtLatitude:t=>i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180),calcCameraMatrix(t,e,n){const i=this.map.transform,o=void 0===t?i._pitch:t,a=void 0===e?i.angle:e,s=void 0===n?this.cameraTranslateZ:n;return(new r.Matrix4).premultiply(s).premultiply((new r.Matrix4).makeRotationX(o)).premultiply((new r.Matrix4).makeRotationZ(a))},updateCameraState(){let t=this.map.transform;if(!t.height)return;const e=t._camera.forward(),n=t.cameraToCenterDistance,r=t.point,i=(t._cameraZoom?t._cameraZoom:t._zoom,this.mercatorZfromZoom(t)-this.mercatorZfromAltitude(t._centerAltitude,t.center.lat)),o=t.cameraToCenterDistance/i;return[r.x/this.worldSize()-e[0]*n/o,r.y/this.worldSize()-e[1]*n/o,this.mercatorZfromAltitude(t._centerAltitude,t._center.lat)+-e[2]*n/o]},getWorldToCamera(t,e){let n=this.map.transform;const i=new r.Matrix4,o=new r.Matrix4,a=n._camera._orientation,s=n._camera.position,l=new r.Vector3(s[0],s[1],s[2]),u=new r.Quaternion;u.set(a[0],a[1],a[2],a[3]);const c=u.conjugate();return l.multiplyScalar(-t),o.makeTranslation(l.x,l.y,l.z),i.makeRotationFromQuaternion(c).premultiply(o),i.elements[1]*=-1,i.elements[5]*=-1,i.elements[9]*=-1,i.elements[13]*=-1,i.elements[8]*=e,i.elements[9]*=e,i.elements[10]*=e,i.elements[11]*=e,i},translate(t,e,n){let r,i,o,a,s,l,u,c,h,p,f,d,m=n[0]||n.x,g=n[1]||n.y,y=n[2]||n.z;return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*m+s*g+h*y+e[12],t[13]=i*m+l*g+p*y+e[13],t[14]=o*m+u*g+f*y+e[14],t[15]=a*m+c*g+d*y+e[15]),t}},p=p=f;var d={};!function(){"use strict";var t=Math.PI,e=Math.sin,n=Math.cos,r=Math.tan,i=Math.asin,o=Math.atan2,a=Math.acos,s=t/180;function l(t){return t.valueOf()/864e5-.5+2440588}function u(t){return new Date(864e5*(t+.5-2440588))}function c(t){return l(t)-2451545}var h=23.4397*s;function p(t,i){return o(e(t)*n(h)-r(i)*e(h),n(t))}function f(t,r){return i(e(r)*n(h)+n(r)*e(h)*e(t))}function m(t,i,a){return o(e(t),n(t)*e(i)-r(a)*n(i))}function g(t,r,o){return i(e(r)*e(o)+n(r)*n(o)*n(t))}function y(t,e){return s*(280.16+360.9856235*t)-e}function v(t){return s*(357.5291+.98560028*t)}function _(n){return n+s*(1.9148*e(n)+.02*e(2*n)+3e-4*e(3*n))+102.9372*s+t}function x(t){var e=_(v(t));return{dec:f(e,0),ra:p(e,0)}}var b={getPosition:function(t,e,n){var r=s*-n,i=s*e,o=c(t),a=x(o),l=y(o,r)-a.ra;return{azimuth:m(l,i,a.dec),altitude:g(l,i,a.dec)}},toJulian:function(t){return l(t)}},w=b.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];b.addTime=function(t,e,n){w.push([t,e,n])};function E(e,n,r){return 9e-4+(e+n)/(2*t)+r}function S(t,n,r){return 2451545+t+.0053*e(n)-.0069*e(2*r)}function M(t,r,i,o,s,l,u){return S(E(function(t,r,i){return a((e(t)-e(r)*e(i))/(n(r)*n(i)))}(t,i,o),r,s),l,u)}function T(t){var r=s*(134.963+13.064993*t),i=s*(93.272+13.22935*t),o=s*(218.316+13.176396*t)+6.289*s*e(r),a=5.128*s*e(i),l=385001-20905*n(r);return{ra:p(o,a),dec:f(o,a),dist:l}}function C(t,e){return new Date(t.valueOf()+864e5*e/24)}b.getTimes=function(e,n,r,i){var o,a,l,h,p,d=s*-r,m=s*n,g=function(t){return-2.076*Math.sqrt(t)/60}(i=i||0),y=function(e,n){return Math.round(e-9e-4-n/(2*t))}(c(e),d),x=E(0,d,y),b=v(x),T=_(b),C=f(T,0),I=S(x,b,T),A={solarNoon:u(I),nadir:u(I-.5)};for(o=0,a=w.length;o<a;o+=1)p=I-((h=M(((l=w[o])[0]+g)*s,d,m,C,y,b,T))-I),A[l[1]]=u(p),A[l[2]]=u(h);return A},b.getMoonPosition=function(t,i,a){var l=s*-a,u=s*i,h=c(t),p=T(h),f=y(h,l)-p.ra,d=g(f,u,p.dec),v=o(e(f),r(u)*n(p.dec)-e(p.dec)*n(f));return d+=function(t){return t<0&&(t=0),2967e-7/Math.tan(t+.00312536/(t+.08901179))}(d),{azimuth:m(f,u,p.dec),altitude:d,distance:p.dist,parallacticAngle:v}},b.getMoonIllumination=function(t){var r=c(t||new Date),i=x(r),s=T(r),l=a(e(i.dec)*e(s.dec)+n(i.dec)*n(s.dec)*n(i.ra-s.ra)),u=o(149598e3*e(l),s.dist-149598e3*n(l)),h=o(n(i.dec)*e(i.ra-s.ra),e(i.dec)*n(s.dec)-n(i.dec)*e(s.dec)*n(i.ra-s.ra));return{fraction:(1+n(u))/2,phase:.5+.5*u*(h<0?-1:1)/Math.PI,angle:h}},b.getMoonTimes=function(t,e,n,r){var i=new Date(t);r?i.setUTCHours(0,0,0,0):i.setHours(0,0,0,0);for(var o,a,l,u,c,h,p,f,d,m,g,y,v,_=.133*s,x=b.getMoonPosition(i,e,n).altitude-_,w=1;w<=24&&(o=b.getMoonPosition(C(i,w),e,n).altitude-_,f=((c=(x+(a=b.getMoonPosition(C(i,w+1),e,n).altitude-_))/2-o)*(p=-(h=(a-x)/2)/(2*c))+h)*p+o,m=0,(d=h*h-4*c*o)>=0&&(g=p-(v=Math.sqrt(d)/(2*Math.abs(c))),y=p+v,Math.abs(g)<=1&&m++,Math.abs(y)<=1&&m++,g<-1&&(g=y)),1===m?x<0?l=w+g:u=w+g:2===m&&(l=w+(f<0?y:g),u=w+(f<0?g:y)),!l||!u);w+=2)x=a;var E={};return l&&(E.rise=C(i,l)),u&&(E.set=C(i,u)),l||u||(E[f>0?"alwaysUp":"alwaysDown"]=!0),E},d=d=b}();var m={},g={material:"MeshBasicMaterial",color:"black",opacity:1};m=m=function(t){var e;function n(){return new r[g.material]({color:g.color})}return t?((e=(t=c._validate(t,g)).material&&t.material.isMaterial?t.material:t.material||t.color||t.opacity?new r[t.material]({color:t.color,transparent:t.opacity<1}):n()).opacity=t.opacity,t.side&&(e.side=t.side)):e=n(),e};var y={};function v(t){this.map=t,this.enrolledObjects=[],this.previousFrameTime}v.prototype={unenroll:function(t){this.enrolledObjects.splice(this.enrolledObjects.indexOf(t),1)},enroll:function(t){if(t.clock=new r.Clock,t.hasDefaultAnimation=!1,t.defaultAction,t.actions=[],t.mixer,t.animations&&t.animations.length>0){t.hasDefaultAnimation=!0;let n=t.userData.defaultAnimation?t.userData.defaultAnimation:0;t.mixer=new r.AnimationMixer(t),e(n)}function e(e){for(let n=0;n<t.animations.length;n++){e>t.animations.length&&console.log("The animation index "+e+" doesn't exist for this object");let r=t.animations[n],i=t.mixer.clipAction(r);t.actions.push(i),e===n?(t.defaultAction=i,i.setEffectiveWeight(1)):i.setEffectiveWeight(0),i.play()}}let n=!1;Object.defineProperty(t,"isPlaying",{get:()=>n,set(e){n!=e&&(n=e,t.dispatchEvent({type:"IsPlayingChanged",detail:t}))}}),this.enrolledObjects.push(t),t.animationQueue=[],t.set=function(e){if(e.duration>0){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};c.extend(e,n);let i=e.coords,o=e.rotation,a=e.scale||e.scaleX||e.scaleY||e.scaleZ;if(o){let n=t.rotation;e.startRotation=[n.x,n.y,n.z],e.endState.rotation=c.types.rotation(e.rotation,e.startRotation),e.rotationPerMs=e.endState.rotation.map((function(t,n){return(t-e.startRotation[n])/e.duration}))}if(a){let n=t.scale;e.startScale=[n.x,n.y,n.z],e.endState.scale=c.types.scale(e.scale,e.startScale),e.scalePerMs=e.endState.scale.map((function(t,n){return(t-e.startScale[n])/e.duration}))}i&&(e.pathCurve=new r.CatmullRomCurve3(c.lnglatsToWorld([t.coordinates,e.coords])));let s={type:"set",parameters:e};this.animationQueue.push(s),tb.map.repaint=!0}else this.stop(),e.rotation=c.radify(e.rotation),this._setObject(e);return this},t.animationMethod=null,t.stop=function(e){return t.mixer&&(t.isPlaying=!1,cancelAnimationFrame(t.animationMethod)),this.animationQueue=[],this},t.followPath=function(t,e){let n={type:"followPath",parameters:c._validate(t,_.followPath)};return c.extend(n.parameters,{pathCurve:new r.CatmullRomCurve3(c.lnglatsToWorld(t.path)),start:Date.now(),expiration:Date.now()+n.parameters.duration,cb:e}),this.animationQueue.push(n),tb.map.repaint=!0,this},t._setObject=function(e){t.setScale();let n=e.position,i=e.rotation,o=e.scale,a=e.worldCoordinates,s=e.quaternion,l=e.translate,u=e.worldTranslate;if(n){this.coordinates=n;let t=c.projectToWorld(n);this.position.copy(t)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let t=c.projectToWorld(l);this.position.copy(t),e.position=this.coordinates}if(u){this.translateX(u.x),this.translateY(u.y),this.translateZ(u.z);let t=c.unprojectFromWorld(this.position);this.coordinates=e.position=t}if(i&&(this.rotation.set(i[0],i[1],i[2]),e.rotation=new r.Vector3(i[0],i[1],i[2])),o&&(this.scale.set(o[0],o[1],o[2]),e.scale=this.scale),s&&(this.quaternion.setFromAxisAngle(s[0],s[1]),e.rotation=s[0].multiplyScalar(s[1])),a){this.position.copy(a);let t=c.unprojectFromWorld(a);this.coordinates=e.position=t}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:e.position,rotation:e.rotation,scale:e.scale}}};this.dispatchEvent(h)},t.playDefault=function(e){if(t.mixer&&t.hasDefaultAnimation){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};c.extend(e,n),t.mixer.timeScale=e.speed||1;let r={type:"playDefault",parameters:e};return this.animationQueue.push(r),tb.map.repaint=!0,this}},t.playAnimation=function(n){t.mixer&&(n.animation&&e(n.animation),t.playDefault(n))},t.pauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!0}))},t.unPauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!1}))},t.deactivateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.stop()}))},t.activateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.play()}))},t.idle=function(){return t.mixer&&t.mixer.update(.01),tb.map.repaint=!0,this}},update:function(t){if(void 0===this.previousFrameTime&&(this.previousFrameTime=t),!this.enrolledObjects)return!1;for(let e=this.enrolledObjects.length-1;e>=0;e--){let n=this.enrolledObjects[e];if(n.animationQueue&&0!==n.animationQueue.length)for(let e=n.animationQueue.length-1;e>=0;e--){let i=n.animationQueue[e];if(!i)continue;let o=i.parameters;if(!o.expiration)return n.animationQueue.splice(e,1),void(n.animationQueue[e]&&(n.animationQueue[e].parameters.start=t));if(t>=o.expiration)o.expiration=!1,"playDefault"===i.type?n.stop():(o.endState&&n._setObject(o.endState),void 0!==o.cb&&o.cb());else{let e=(t-o.start)/o.duration;if("set"===i.type){let t={};o.pathCurve&&(t.worldCoordinates=o.pathCurve.getPoint(e)),o.rotationPerMs&&(t.rotation=o.startRotation.map((function(t,n){return t+o.rotationPerMs[n]*e*o.duration}))),o.scalePerMs&&(t.scale=o.startScale.map((function(t,n){return t+o.scalePerMs[n]*e*o.duration}))),n._setObject(t)}if("followPath"===i.type){let t={worldCoordinates:o.pathCurve.getPointAt(e)};if(o.trackHeading){let n=o.pathCurve.getTangentAt(e).normalize(),i=new r.Vector3(0,0,0),a=new r.Vector3(0,1,0);i.crossVectors(a,n).normalize();let s=Math.acos(a.dot(n));t.quaternion=[i,s]}n._setObject(t)}"playDefault"===i.type&&(n.activateAllActions(),n.isPlaying=!0,n.animationMethod=requestAnimationFrame(this.update),n.mixer.update(n.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=t}};const _={followPath:{path:null,duration:1e3,trackHeading:!0}};y=y=v;var x={};!function(){class t extends r.Object3D{constructor(t){super(),this.element=t||document.createElement("div"),this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this}}t.prototype.isCSS2DObject=!0;const e=new r.Vector3,n=new r.Matrix4,i=new r.Matrix4,o=new r.Vector3,a=new r.Vector3;r.CSS2DObject=t,r.CSS2DRenderer=class{constructor(){const t=this;let r,s,l,u;const c={objects:new WeakMap,list:new Map};this.cacheList=c.list;const h=document.createElement("div");h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:r,height:s}},this.render=function(r,s){!0===r.autoUpdate&&r.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),n.copy(s.matrixWorldInverse),i.multiplyMatrices(s.projectionMatrix,n),function n(r,s,p){if(r.isCSS2DObject)if(r.visible){r.onBeforeRender(t,s,p),e.setFromMatrixPosition(r.matrixWorld),e.applyMatrix4(i);const n=r.element;var f;f=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(e.x*l+l)+"px,"+Math.round(-e.y*u+u)+"px)":"translate(-50%,-50%) translate("+(e.x*l+l)+"px,"+(-e.y*u+u)+"px)",n.style.WebkitTransform=f,n.style.MozTransform=f,n.style.oTransform=f,n.style.transform=f,n.style.display=r.visible&&e.z>=-1&&e.z<=1?"":"none";const g={distanceToCameraSquared:(d=p,m=r,o.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(m.matrixWorld),o.distanceToSquared(a))};c.objects.set({key:r.uuid},g),c.list.set(r.uuid,r),n.parentNode!==h&&h.appendChild(n),r.onAfterRender(t,s,p)}else c.objects.delete({key:r.uuid}),c.list.delete(r.uuid),r.remove();var d,m;for(let t=0,e=r.children.length;t<e;t++)n(r.children[t],s,p)}(r,r,s),function(t){const e=function(t){const e=[];return t.traverse((function(t){t.isCSS2DObject&&e.push(t)})),e}(t).sort((function(t,e){let n=c.objects.get({key:t.uuid}),r=c.objects.get({key:e.uuid});if(n&&r)return n.distanceToCameraSquared-r.distanceToCameraSquared})),n=e.length;for(let t=0,r=e.length;t<r;t++)e[t].element.style.zIndex=n-t}(r)},this.setSize=function(t,e){l=(r=t)/2,u=(s=e)/2,h.style.width=t+"px",h.style.height=e+"px"}}}}(),x=x={CSS2DRenderer:r.CSS2DRenderer,CSS2DObject:r.CSS2DObject};var b={};const w=r;function E(){}E.prototype={line:function(t){t=c._validate(t,this._defaults.line);var e=c.lnglatsToWorld(t.geometry),n=c.normalizeVertices(e),r=c.flattenVectors(n.vertices),i=new Float32Array(r),o=new w.BufferGeometry;o.setAttribute("position",new w.BufferAttribute(i,3));var a=new w.LineBasicMaterial({color:16711680,linewidth:21}),s=new w.Line(o,a);return s.options=options||{},s.position.copy(n.position),s},extrusion:function(t){},unenroll:function(t,e){e||this.animationManager.unenroll(t)},_addMethods:function(t,e){var n=this;if(e);else{function r(t,e,n,r){let i=c.radify(r);t.position.sub(e),t.position.applyAxisAngle(n,i),t.position.add(e),t.rotateOnAxis(n,i),tb.map.repaint=!0}t.coordinates||(t.coordinates=[0,0,0]),Object.defineProperty(t,"model",{get:()=>t.getObjectByName("model")}),Object.defineProperty(t,"animations",{get(){const e=t.model;return e?e.animations:null}}),n.animationManager.enroll(t),t.setCoords=function(e){return t.userData.topMargin&&t.userData.feature&&(e[2]+=((t.userData.feature.properties.height||0)-(t.userData.feature.properties.base_height||t.userData.feature.properties.min_height||0))*(t.userData.topMargin||0)),t.coordinates=e,t.set({position:e}),t},t.setTranslate=function(e){return t.set({translate:e}),t},t.setRotation=function(e){"number"==typeof e&&(e={z:e});var n={x:c.radify(e.x)||t.rotation.x,y:c.radify(e.y)||t.rotation.y,z:c.radify(e.z)||t.rotation.z};t._setObject({rotation:[n.x,n.y,n.z]})},t.calculateAdjustedPosition=function(e,n,r){let i=e.slice(),o=c.unprojectFromWorld(t.modelSize);return r?(i[0]-=0!=n.x?o[0]/n.x:0,i[1]-=0!=n.y?o[1]/n.y:0,i[2]-=0!=n.z?o[2]/n.z:0):(i[0]+=0!=n.x?o[0]/n.x:0,i[1]+=0!=n.y?o[1]/n.y:0,i[2]+=0!=n.z?o[2]/n.z:0),i},t.setRotationAxis=function(e){"number"==typeof e&&(e={z:e});let n=t.modelBox(),i=new w.Vector3(n.max.x,n.max.y,n.min.z);0!=e.x&&r(t,i,new w.Vector3(0,0,1),e.x),0!=e.y&&r(t,i,new w.Vector3(0,0,1),e.y),0!=e.z&&r(t,i,new w.Vector3(0,0,1),e.z)},Object.defineProperty(t,"scaleGroup",{get:()=>t.getObjectByName("scaleGroup")}),Object.defineProperty(t,"boxGroup",{get:()=>t.getObjectByName("boxGroup")}),Object.defineProperty(t,"boundingBox",{get:()=>t.getObjectByName("boxModel")}),Object.defineProperty(t,"boundingBoxShadow",{get:()=>t.getObjectByName("boxShadow")}),t.drawBoundingBox=function(){let e=t.box3(),n=new w.Group;n.name="boxGroup",n.updateMatrixWorld(!0);let r=new w.Box3Helper(e,E.prototype._defaults.colors.yellow);r.name="boxModel",n.add(r),r.layers.disable(0);let i=e.clone();i.max.z=i.min.z;let o=new w.Box3Helper(i,E.prototype._defaults.colors.black);o.name="boxShadow",n.add(o),o.layers.disable(0),n.visible=!1,t.scaleGroup.add(n),t.setBoundingBoxShadowFloor()},t.setBoundingBoxShadowFloor=function(){if(t.boundingBoxShadow){let e=-t.modelHeight,n=t.rotation,r=t.boundingBoxShadow;r.box.max.z=r.box.min.z=e,r.rotation.y=n.y,r.rotation.x=-n.x}},t.setAnchor=function(e){const n=t.box3(),r=n.getCenter(new w.Vector3);switch(t.none={x:0,y:0,z:0},t.center={x:r.x,y:r.y,z:n.min.z},t.bottom={x:r.x,y:n.max.y,z:n.min.z},t.bottomLeft={x:n.max.x,y:n.max.y,z:n.min.z},t.bottomRight={x:n.min.x,y:n.max.y,z:n.min.z},t.top={x:r.x,y:n.min.y,z:n.min.z},t.topLeft={x:n.max.x,y:n.min.y,z:n.min.z},t.topRight={x:n.min.x,y:n.min.y,z:n.min.z},t.left={x:n.max.x,y:r.y,z:n.min.z},t.right={x:n.min.x,y:r.y,z:n.min.z},e){case"center":t.anchor=t.center;break;case"top":t.anchor=t.top;break;case"top-left":t.anchor=t.topLeft;break;case"top-right":t.anchor=t.topRight;break;case"left":t.anchor=t.left;break;case"right":t.anchor=t.right;break;case"bottom":t.anchor=t.bottom;break;case"bottom-left":default:t.anchor=t.bottomLeft;break;case"bottom-right":t.anchor=t.bottomRight;break;case"auto":case"none":t.anchor=t.none}t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)},t.setCenter=function(e){if(e&&(0!=e.x||0!=e.y||0!=e.z)){let n=t.getSize();t.anchor={x:t.anchor.x-n.x*e.x,y:t.anchor.y-n.y*e.y,z:t.anchor.z-n.z*e.z},t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)}},Object.defineProperty(t,"label",{get:()=>t.getObjectByName("label")}),Object.defineProperty(t,"tooltip",{get:()=>t.getObjectByName("tooltip")}),Object.defineProperty(t,"help",{get:()=>t.getObjectByName("help")});let o=!1;Object.defineProperty(t,"hidden",{get:()=>o,set(e){o!=e&&(o=e,t.visibility=!o)}}),Object.defineProperty(t,"visibility",{get:()=>t.visible,set(e){let n=e;if("visible"==e||1==e)n=!0,t.label&&(t.label.visible=n);else{if("none"!=e&&0!=e)return;n=!1,t.label&&t.label.alwaysVisible&&(t.label.visible=n),t.tooltip&&(t.tooltip.visible=n)}if(t.visible!=n){if(t.hidden&&n)return;t.visible=n,t.model&&t.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(n&&t.raycasted?e.layers.enable(0):e.layers.disable(0)),"LineSegments"==e.type&&e.layers.disableAll()}))}}}),t.addLabel=function(e,n,r,i){e&&t.drawLabelHTML(e,n,r,i)},t.removeLabel=function(){t.removeCSS2D("label")},t.drawLabelHTML=function(e,r=!1,i=t.anchor,o=.5){let a=n.drawLabelHTML(e,E.prototype._defaults.label.cssClass),s=t.addCSS2D(a,"label",i,o);return s.alwaysVisible=r,s.visible=r,s},t.addTooltip=function(e,n,r,i=!0,o=1){let a=t.addHelp(e,"tooltip",n,r,o);a.visible=!1,a.custom=i},t.removeTooltip=function(){t.removeCSS2D("tooltip")},t.addHelp=function(e,r="help",i=!1,o=t.anchor,a=0){let s=n.drawTooltip(e,i),l=t.addCSS2D(s,r,o,a);return l.visible=!0,l},t.removeHelp=function(){t.removeCSS2D("help")},t.addCSS2D=function(e,n,r=t.anchor,i=1){if(e){const o=t.box3(),a=o.getSize(new w.Vector3);let s={x:o.max.x,y:o.max.y,z:o.min.z};t.removeCSS2D(n);let l=new x.CSS2DObject(e);return l.name=n,l.position.set(.5*-a.x-t.model.position.x-r.x+s.x,.5*-a.y-t.model.position.y-r.y+s.y,a.z*i),l.visible=!1,t.scaleGroup.add(l),l}},t.removeCSS2D=function(e){let n=t.getObjectByName(e);if(n){n.dispose();let e=t.scaleGroup.children;e.splice(e.indexOf(n),1)}},Object.defineProperty(t,"shadowPlane",{get:()=>t.getObjectByName("shadowPlane")});let a=!1;Object.defineProperty(t,"castShadow",{get:()=>a,set(e){if(t.model&&a!==e){if(t.model.traverse((function(t){t.isMesh&&(t.castShadow=!0)})),e){const n=t.modelSize,r=[n.x,n.y,n.z,t.modelHeight],i=10*Math.max(...r),o=new w.PlaneBufferGeometry(i,i),a=new w.ShadowMaterial;a.opacity=.5;let s=new w.Mesh(o,a);s.name="shadowPlane",s.layers.enable(1),s.layers.disable(0),s.receiveShadow=e,t.add(s)}else t.traverse((function(e){e.isMesh&&e.material instanceof w.ShadowMaterial&&t.remove(e)}));a=e}}}),t.setReceiveShadowFloor=function(){if(t.castShadow){let e=t.shadowPlane,n=e.position,r=e.rotation;if(n.z=-t.modelHeight,r.y=t.rotation.y,r.x=-t.rotation.x,"meters"===t.userData.units){const r=t.modelSize,i=[r.x,r.y,r.z,-n.z],o=10*Math.max(...i)/e.geometry.parameters.width;e.scale.set(o,o,o)}}};let s=!1;Object.defineProperty(t,"receiveShadow",{get:()=>s,set(e){t.model&&s!==e&&(t.model.traverse((function(t){t.isMesh&&(t.receiveShadow=!0)})),s=e)}});let l=!1;Object.defineProperty(t,"wireframe",{get:()=>l,set(e){t.model&&l!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=r.clone(),t.material.wireframe=t.material.transparent=e,t.material.opacity=.3):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null),e?(t.layers.disable(0),t.layers.enable(1)):(t.layers.disable(1),t.layers.enable(0))}"LineSegments"==t.type&&t.layers.disableAll()})),l=e,t.dispatchEvent({type:"Wireframed",detail:t}))}});let u=null;Object.defineProperty(t,"color",{get:()=>u,set(e){t.model&&u!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=new w.MeshStandardMaterial,t.material.color.setHex(e)):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null)}})),u=e)}});let h=!1;Object.defineProperty(t,"selected",{get:()=>h,set(e){e?(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.boxGroup&&(t.boundingBox.material=E.prototype._defaults.materials.boxSelectedMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1)),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0)):(t.boxGroup&&t.remove(t.boxGroup),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1),t.removeHelp()),t.tooltip&&(t.tooltip.visible=e),h!=e&&(h=e,t.dispatchEvent({type:"SelectedChange",detail:t}))}});let p=!0;Object.defineProperty(t,"raycasted",{get:()=>p,set(e){t.model&&p!==e&&(t.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(e?(t.layers.disable(1),t.layers.enable(0)):(t.layers.disable(0),t.layers.enable(1)))})),p=e)}});let f=!1;Object.defineProperty(t,"over",{get:()=>f,set(e){e?(t.selected||(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.userData.tooltip&&!t.tooltip&&t.addTooltip(t.uuid,!0,t.anchor,!1),t.boxGroup&&(t.boundingBox.material=E.prototype._defaults.materials.boxOverMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1))),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0),t.dispatchEvent({type:"ObjectMouseOver",detail:t})):(t.selected||(t.boxGroup&&(t.remove(t.boxGroup),t.tooltip&&!t.tooltip.custom&&t.removeTooltip()),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1)),t.dispatchEvent({type:"ObjectMouseOut",detail:t})),t.tooltip&&(t.tooltip.visible=e||t.selected),f=e}}),t.box3=function(){let e;if(t.updateMatrix(),t.updateMatrixWorld(!0,!0),t.model){let n=t.clone(!0),r=t.model.clone();if(e=(new w.Box3).setFromObject(r),t.parent){let i=new w.Matrix4,o=new w.Matrix4;t.matrix.extractRotation(i),o.copy(i).invert(),n.setRotationFromMatrix(o),e=(new w.Box3).setFromObject(r)}}return e},t.modelBox=function(){return t.box3()},t.getSize=function(){return t.box3().getSize(new w.Vector3(0,0,0))};let d=!1;Object.defineProperty(t,"modelSize",{get:()=>d=t.getSize(),set(t){d!=t&&(d=t)}}),Object.defineProperty(t,"modelHeight",{get(){let e=t.coordinates[2]||0;return"scene"===t.userData.units&&(e*=t.unitsPerMeter/t.scale.x),e}}),Object.defineProperty(t,"unitsPerMeter",{get:()=>Number(c.projectedUnitsPerMeter(t.coordinates[1]).toFixed(7))}),Object.defineProperty(t,"fixedZoom",{get:()=>t.userData.fixedZoom,set(e){t.userData.fixedZoom!==e&&(t.userData.fixedZoom=e,t.userData.units=e?"scene":"meters")}}),t.setFixedZoom=function(e){if(null!=t.fixedZoom&&0!=t.fixedZoom){e||(e=t.userData.mapScale);let r=(n=t.fixedZoom,Math.pow(2,n));if(r>e){let n=r/e;t.scale.set(n,n,n)}else t.scale.set(1,1,1)}var n},t.setScale=function(e){if("scene"!=t.userData.units){let e=t.unitsPerMeter;t.scale.set(e,e,e)}else t.fixedZoom?(e&&(t.userData.mapScale=e),t.setFixedZoom(t.userData.mapScale)):t.scale.set(1,1,1)},t.setObjectScale=function(e){t.setScale(e),t.setBoundingBoxShadowFloor(),t.setReceiveShadowFloor()}}t.add=function(e){return t.scaleGroup.add(e),e.position.z=t.coordinates[2]?-t.coordinates[2]:0,e},t.remove=function(e){e&&(e.traverse((t=>{if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()})),t.scaleGroup.remove(e),tb.map.repaint=!0)},t.duplicate=function(e){let r=t.clone(!0);if(r.getObjectByName("model").animations=t.animations,r.userData.feature&&(e&&e.feature&&(r.userData.feature=e.feature),r.userData.feature.properties.uuid=r.uuid),n._addMethods(r),!e||c.equal(e.scale,t.userData.scale))return r.copyAnchor(t),r;{r.userData=e,r.userData.isGeoGroup=!0,r.remove(r.boxGroup);const t=c.types.rotation(e.rotation,[0,0,0]),n=c.types.scale(e.scale,[1,1,1]);return r.model.position.set(0,0,0),r.model.rotation.set(t[0],t[1],t[2]),r.model.scale.set(n[0],n[1],n[2]),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r}},t.copyAnchor=function(e){t.anchor=e.anchor,t.none={x:0,y:0,z:0},t.center=e.center,t.bottom=e.bottom,t.bottomLeft=e.bottomLeft,t.bottomRight=e.bottomRight,t.top=e.top,t.topLeft=e.topLeft,t.topRight=e.topRight,t.left=e.left,t.right=e.right},t.dispose=function(){E.prototype.unenroll(t),t.traverse((t=>{if((!t.parent||"world"!=t.parent.name)&&"threeboxObject"!==t.name){if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()}})),t.children=[]};const i=t=>{t.dispose();for(const e of Object.keys(t)){const n=t[e];n&&"object"==typeof n&&"minFilter"in n&&n.dispose()}let e=t;(e.map||e.alphaMap||e.aoMap||e.bumpMap||e.displacementMap||e.emissiveMap||e.envMap||e.lightMap||e.metalnessMap||e.normalMap||e.roughnessMap)&&(e.map&&e.map.dispose(),e.alphaMap&&e.alphaMap.dispose(),e.aoMap&&e.aoMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.displacementMap&&e.displacementMap.dispose(),e.emissiveMap&&e.emissiveMap.dispose(),e.envMap&&e.envMap.dispose(),e.lightMap&&e.lightMap.dispose(),e.metalnessMap&&e.metalnessMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.roughnessMap&&e.roughnessMap.dispose())};return t},_makeGroup:function(t,e){let n=new w.Group;n.name="scaleGroup",n.add(t);var r=new w.Group;if(r.userData=e||{},r.userData.isGeoGroup=!0,r.userData.feature&&(r.userData.feature.properties.uuid=r.uuid),n.length)for(o of n)r.add(o);else r.add(n);return r.name="threeboxObject",r},animationManager:new y,drawTooltip:function(t,e=!1){if(t){let n;if(e){let e=document.createElement("div");e.className="mapboxgl-popup-content";let r=document.createElement("strong");r.innerHTML=t,e.appendChild(r);let i=document.createElement("div");i.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(i),o.appendChild(e),(n=document.createElement("div")).className+="label3D",n.appendChild(o)}else(n=document.createElement("span")).className=this._defaults.tooltip.cssClass,n.innerHTML=t;return n}},drawLabelHTML:function(t,e){let n=document.createElement("div");return n.className+=e,n.innerHTML="string"==typeof t?t:t.outerHTML,n},_defaults:{colors:{red:new w.Color(16711680),yellow:new w.Color(16776960),green:new w.Color(65280),black:new w.Color(0)},materials:{boxNormalMaterial:new w.LineBasicMaterial({color:new w.Color(16711680)}),boxOverMaterial:new w.LineBasicMaterial({color:new w.Color(16776960)}),boxSelectedMaterial:new w.LineBasicMaterial({color:new w.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0,clone:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:new w.MeshPhongMaterial({color:6684672,side:w.DoubleSide}),scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},b=b=E;var S={};S=S=function(t){let e=(t=c._validate(t,b.prototype._defaults.Object3D)).obj;const n=c.types.rotation(t.rotation,[0,0,0]),r=c.types.scale(t.scale,[1,1,1]);e.rotation.set(n[0],n[1],n[2]),e.scale.set(r[0],r[1],r[2]),e.name="model";let i=b.prototype._makeGroup(e,t);return t.obj.name="model",b.prototype._addMethods(i),i.setAnchor(t.anchor),i.setCenter(t.adjustment),i.raycasted=t.raycasted,i.visibility=!0,i};var M={};M=M=function(t){t=c._validate(t,b.prototype._defaults.sphere);let e=new r.SphereBufferGeometry(t.radius,t.sides,t.sides),n=m(t),i=new r.Mesh(e,n);return new S({obj:i,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var T={};function C(t){t=c._validate(t,b.prototype._defaults.extrusion);let e=C.prototype.buildShape(t.coordinates),n=C.prototype.buildGeometry(e,t.geometryOptions),i=new r.Mesh(n,t.materials);return t.obj=i,new S(t)}C.prototype={buildShape:function(t){if(t[0]instanceof(r.Vector2||r.Vector3))return new r.Shape(t);let e=new r.Shape;for(let n=0;n<t.length;n++)0===n?e=new r.Shape(this.buildPoints(t[0],t[0])):e.holes.push(new r.Path(this.buildPoints(t[n],t[0])));return e},buildPoints:function(t,e){const n=[];let i=c.projectToWorld([e[0][0],e[0][1],0]);for(let e=0;e<t.length;e++){let o=c.projectToWorld([t[e][0],t[e][1],0]);n.push(new r.Vector2(c.toDecimal(o.x-i.x,9),c.toDecimal(o.y-i.y,9)))}return n},buildGeometry:function(t,e){let n=new r.ExtrudeBufferGeometry(t,e);return n.computeBoundingBox(),n}},T=T=C;var I={};I=I=function(t){t=c._validate(t,b.prototype._defaults.label);let e=b.prototype.drawLabelHTML(t.htmlElement,t.cssClass),n=new x.CSS2DObject(e);n.name="label",n.visible=t.alwaysVisible,n.alwaysVisible=t.alwaysVisible;var r=b.prototype._makeGroup(n,t);return b.prototype._addMethods(r),r.visibility=t.alwaysVisible,r};var A={};A=A=function(t){if((t=c._validate(t,b.prototype._defaults.tooltip)).text){let n=b.prototype.drawTooltip(t.text,t.mapboxStyle),r=new x.CSS2DObject(n);r.visible=!1,r.name="tooltip";var e=b.prototype._makeGroup(r,t);return b.prototype._addMethods(e),e}};var L={};!function(){const t=/^[og]\s*(.+)?/,e=/^mtllib /,n=/^usemtl /,i=/^usemap /,o=new r.Vector3,a=new r.Vector3,s=new r.Vector3,l=new r.Vector3,u=new r.Vector3;function c(){const t={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);const n=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:t||"",fromDeclaration:!1!==e,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(t,e){const n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);const r={index:this.materials.length,name:t||"",mtllib:Array.isArray(e)&&e.length>0?e[e.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(t){const e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){const e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},n&&n.name&&"function"==typeof n.clone){const t=n.clone(0);t.inherited=!0,this.object.materials.push(t)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseNormalIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseUVIndex:function(t,e){const n=parseInt(t,10);return 2*(n>=0?n-1:n+e/2)},addVertex:function(t,e,n){const r=this.vertices,i=this.object.geometry.vertices;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,n){const r=this.normals,i=this.object.geometry.normals;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(t,e,n){const r=this.vertices,i=this.object.geometry.normals;o.fromArray(r,t),a.fromArray(r,e),s.fromArray(r,n),u.subVectors(s,a),l.subVectors(o,a),u.cross(l),u.normalize(),i.push(u.x,u.y,u.z),i.push(u.x,u.y,u.z),i.push(u.x,u.y,u.z)},addColor:function(t,e,n){const r=this.colors,i=this.object.geometry.colors;void 0!==r[t]&&i.push(r[t+0],r[t+1],r[t+2]),void 0!==r[e]&&i.push(r[e+0],r[e+1],r[e+2]),void 0!==r[n]&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(t,e,n){const r=this.uvs,i=this.object.geometry.uvs;i.push(r[t+0],r[t+1]),i.push(r[e+0],r[e+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){const t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){const e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,n,r,i,o,a,s,l){const u=this.vertices.length;let c=this.parseVertexIndex(t,u),h=this.parseVertexIndex(e,u),p=this.parseVertexIndex(n,u);if(this.addVertex(c,h,p),this.addColor(c,h,p),void 0!==a&&""!==a){const t=this.normals.length;c=this.parseNormalIndex(a,t),h=this.parseNormalIndex(s,t),p=this.parseNormalIndex(l,t),this.addNormal(c,h,p)}else this.addFaceNormal(c,h,p);if(void 0!==r&&""!==r){const t=this.uvs.length;c=this.parseUVIndex(r,t),h=this.parseUVIndex(i,t),p=this.parseUVIndex(o,t),this.addUV(c,h,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";const e=this.vertices.length;for(let n=0,r=t.length;n<r;n++){const r=this.parseVertexIndex(t[n],e);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(t,e){this.object.geometry.type="Line";const n=this.vertices.length,r=this.uvs.length;for(let e=0,r=t.length;e<r;e++)this.addVertexLine(this.parseVertexIndex(t[e],n));for(let t=0,n=e.length;t<n;t++)this.addUVLine(this.parseUVIndex(e[t],r))}};return t.startObject("",!1),t}r.OBJLoader=class extends r.Loader{constructor(t){super(t),this.materials=null}load(t,e,n,i){const o=this,a=new r.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(n){try{e(o.parse(n))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}setMaterials(t){return this.materials=t,this}parse(o){const a=new c;-1!==o.indexOf("\r\n")&&(o=o.replace(/\r\n/g,"\n")),-1!==o.indexOf("\\\n")&&(o=o.replace(/\\\n/g,""));const s=o.split("\n");let l="",u="",h=0,p=[];const f="function"==typeof"".trimLeft;for(let r=0,o=s.length;r<o;r++)if(l=s[r],0!==(h=(l=f?l.trimLeft():l.trim()).length)&&"#"!==(u=l.charAt(0)))if("v"===u){const t=l.split(/\s+/);switch(t[0]){case"v":a.vertices.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),t.length>=7?a.colors.push(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6])):a.colors.push(void 0,void 0,void 0);break;case"vn":a.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":a.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===u){const t=l.substr(1).trim().split(/\s+/),e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];if(r.length>0){const t=r.split("/");e.push(t)}}const n=e[0];for(let t=1,r=e.length-1;t<r;t++){const r=e[t],i=e[t+1];a.addFace(n[0],r[0],i[0],n[1],r[1],i[1],n[2],r[2],i[2])}}else if("l"===u){const t=l.substring(1).trim().split(" ");let e=[];const n=[];if(-1===l.indexOf("/"))e=t;else for(let r=0,i=t.length;r<i;r++){const i=t[r].split("/");""!==i[0]&&e.push(i[0]),""!==i[1]&&n.push(i[1])}a.addLineGeometry(e,n)}else if("p"===u){const t=l.substr(1).trim().split(" ");a.addPointGeometry(t)}else if(null!==(p=t.exec(l))){const t=(" "+p[0].substr(1).trim()).substr(1);a.startObject(t)}else if(n.test(l))a.object.startMaterial(l.substring(7).trim(),a.materialLibraries);else if(e.test(l))a.materialLibraries.push(l.substring(7).trim());else if(i.test(l))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===u){if((p=l.split(" ")).length>1){const t=p[1].trim().toLowerCase();a.object.smooth="0"!==t&&"off"!==t}else a.object.smooth=!0;const t=a.object.currentMaterial();t&&(t.smooth=a.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}a.finalize();const d=new r.Group;if(d.materialLibraries=[].concat(a.materialLibraries),1==!(1===a.objects.length&&0===a.objects[0].geometry.vertices.length))for(let t=0,e=a.objects.length;t<e;t++){const e=a.objects[t],n=e.geometry,i=e.materials,o="Line"===n.type,s="Points"===n.type;let l=!1;if(0===n.vertices.length)continue;const u=new r.BufferGeometry;u.setAttribute("position",new r.Float32BufferAttribute(n.vertices,3)),n.normals.length>0&&u.setAttribute("normal",new r.Float32BufferAttribute(n.normals,3)),n.colors.length>0&&(l=!0,u.setAttribute("color",new r.Float32BufferAttribute(n.colors,3))),!0===n.hasUVIndices&&u.setAttribute("uv",new r.Float32BufferAttribute(n.uvs,2));const c=[];for(let t=0,e=i.length;t<e;t++){const e=i[t],n=e.name+"_"+e.smooth+"_"+l;let u=a.materials[n];if(null!==this.materials)if(u=this.materials.create(e.name),!o||!u||u instanceof r.LineBasicMaterial){if(s&&u&&!(u instanceof r.PointsMaterial)){const t=new r.PointsMaterial({size:10,sizeAttenuation:!1});r.Material.prototype.copy.call(t,u),t.color.copy(u.color),t.map=u.map,u=t}}else{const t=new r.LineBasicMaterial;r.Material.prototype.copy.call(t,u),t.color.copy(u.color),u=t}void 0===u&&((u=o?new r.LineBasicMaterial:s?new r.PointsMaterial({size:1,sizeAttenuation:!1}):new r.MeshPhongMaterial).name=e.name,u.flatShading=!e.smooth,u.vertexColors=l,a.materials[n]=u),c.push(u)}let h;if(c.length>1){for(let t=0,e=i.length;t<e;t++){const e=i[t];u.addGroup(e.groupStart,e.groupCount,t)}h=o?new r.LineSegments(u,c):s?new r.Points(u,c):new r.Mesh(u,c)}else h=o?new r.LineSegments(u,c[0]):s?new r.Points(u,c[0]):new r.Mesh(u,c[0]);h.name=e.name,d.add(h)}else if(a.vertices.length>0){const t=new r.PointsMaterial({size:1,sizeAttenuation:!1}),e=new r.BufferGeometry;e.setAttribute("position",new r.Float32BufferAttribute(a.vertices,3)),a.colors.length>0&&void 0!==a.colors[0]&&(e.setAttribute("color",new r.Float32BufferAttribute(a.colors,3)),t.vertexColors=!0);const n=new r.Points(e,t);d.add(n)}return d}}}(),L=L=r.OBJLoader;var P={};!function(){class t{constructor(t="",e={}){this.baseUrl=t,this.options=e,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:r.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:r.RepeatWrapping}setCrossOrigin(t){return this.crossOrigin=t,this}setManager(t){this.manager=t}setMaterials(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(t){if(!this.options)return t;const e={};for(const n in t){const r=t[n],i={};e[n]=i;for(const t in r){let e=!0,n=r[t];const o=t.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(e=!1)}e&&(i[o]=n)}}return e}preload(){for(const t in this.materialsInfo)this.create(t)}getIndex(t){return this.nameLookup[t]}getAsArray(){let t=0;for(const e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray}create(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]}createMaterial_(t){const e=this,n=this.materialsInfo[t],i={name:t,side:this.side};function o(t,n){if(i[t])return;const r=e.getTextureParams(n,i),o=e.loadTexture((a=e.baseUrl,"string"!=typeof(s=r.url)||""===s?"":/^https?:\/\//i.test(s)?s:a+s));var a,s;o.repeat.copy(r.scale),o.offset.copy(r.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,i[t]=o}for(const t in n){const e=n[t];let a;if(""!==e)switch(t.toLowerCase()){case"kd":i.color=(new r.Color).fromArray(e);break;case"ks":i.specular=(new r.Color).fromArray(e);break;case"ke":i.emissive=(new r.Color).fromArray(e);break;case"map_kd":o("map",e);break;case"map_ks":o("specularMap",e);break;case"map_ke":o("emissiveMap",e);break;case"norm":o("normalMap",e);break;case"map_bump":case"bump":o("bumpMap",e);break;case"map_d":o("alphaMap",e),i.transparent=!0;break;case"ns":i.shininess=parseFloat(e);break;case"d":(a=parseFloat(e))<1&&(i.opacity=a,i.transparent=!0);break;case"tr":a=parseFloat(e),this.options&&this.options.invertTrProperty&&(a=1-a),a>0&&(i.opacity=1-a,i.transparent=!0)}}return this.materials[t]=new r.MeshPhongMaterial(i),this.materials[t]}getTextureParams(t,e){const n={scale:new r.Vector2(1,1),offset:new r.Vector2(0,0)},i=t.split(/\s+/);let o;return(o=i.indexOf("-bm"))>=0&&(e.bumpScale=parseFloat(i[o+1]),i.splice(o,2)),(o=i.indexOf("-s"))>=0&&(n.scale.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),(o=i.indexOf("-o"))>=0&&(n.offset.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),n.url=i.join(" ").trim(),n}loadTexture(t,e,n,i,o){const a=void 0!==this.manager?this.manager:r.DefaultLoadingManager;let s=a.getHandler(t);null===s&&(s=new r.TextureLoader(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);const l=s.load(t,n,i,o);return void 0!==e&&(l.mapping=e),l}}r.MTLLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===this.path?r.LoaderUtils.extractUrlBase(t||""):this.path,s=new r.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}setMaterialOptions(t){return this.materialOptions=t,this}parse(e,n){const r=e.split("\n");let i={};const o=/\s+/,a={};for(let t=0;t<r.length;t++){let e=r[t];if(0===(e=e.trim()).length||"#"===e.charAt(0))continue;const n=e.indexOf(" ");let s=n>=0?e.substring(0,n):e;s=s.toLowerCase();let l=n>=0?e.substring(n+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){const t=l.split(o,3);i[s]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else i[s]=l}const s=new t(this.resourcePath||n,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}}}(),P=P=r.MTLLoader;var R,D,N={},O=N={};function k(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function F(t){if(R===setTimeout)return setTimeout(t,0);if((R===k||!R)&&setTimeout)return R=setTimeout,setTimeout(t,0);try{return R(t,0)}catch(e){try{return R.call(null,t,0)}catch(e){return R.call(this,t,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:k}catch(t){R=k}try{D="function"==typeof clearTimeout?clearTimeout:z}catch(t){D=z}}();var B,U=[],V=!1,G=-1;function j(){V&&B&&(V=!1,B.length?U=B.concat(U):G=-1,U.length&&H())}function H(){if(!V){var t=F(j);V=!0;for(var e=U.length;e;){for(B=U,U=[];++G<e;)B&&B[G].run();G=-1,e=U.length}B=null,V=!1,function(t){if(D===clearTimeout)return clearTimeout(t);if((D===z||!D)&&clearTimeout)return D=clearTimeout,clearTimeout(t);try{D(t)}catch(e){try{return D.call(null,t)}catch(e){return D.call(this,t)}}}(t)}}function q(t,e){this.fun=t,this.array=e}function W(){}O.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];U.push(new q(t,e)),1!==U.length||V||F(H)},q.prototype.run=function(){this.fun.apply(null,this.array)},O.title="browser",O.browser=!0,O.env={},O.argv=[],O.version="",O.versions={},O.on=W,O.addListener=W,O.once=W,O.off=W,O.removeListener=W,O.removeAllListeners=W,O.emit=W,O.prependListener=W,O.prependOnceListener=W,O.listeners=function(t){return[]},O.binding=function(t){throw new Error("process.binding is not supported")},O.cwd=function(){return"/"},O.chdir=function(t){throw new Error("process.chdir is not supported")},O.umask=function(){return 0};var X={exports:{}};(function(t){(function(){!function(t){"object"==typeof X.exports?X.exports=t():"undefined"!=typeof define&&define.amd?define(["fflate",t]):("undefined"!=typeof self?self:this).fflate=t()}((function(){var e={__esModule:!0},n=("object"==typeof X.exports?function(e){"use strict";try{(void 0)("require('worker_threads')").Worker}catch(t){}return X.exports.default=function(e,n,r,i,o){t((function(){return o(Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)}));var a=function(){};return{terminate:a,postMessage:a}},e}:function(t){"use strict";var e=eval;return t.default=function(t,n,r,i,o){var a=e[n]||(e[n]=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))),s=new Worker(a);return s.onerror=function(t){return o(t.error,null)},s.onmessage=function(t){return o(null,t.data)},s.postMessage(r,i),s},t})({}),r=Uint8Array,i=Uint16Array,o=Uint32Array,a=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(t,e){for(var n=new i(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var a=new o(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)a[s]=s-n[r]<<5|r;return[n,a]},c=u(a,2),h=c[0],p=c[1];h[28]=258,p[258]=28;for(var f=u(s,0),d=f[0],m=f[1],g=new i(32768),y=0;y<32768;++y){var v=(43690&y)>>>1|(21845&y)<<1;g[y]=((65280&(v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4))>>>8|(255&v)<<8)>>>1}var _=function(t,e,n){for(var r=t.length,o=0,a=new i(e);o<r;++o)++a[t[o]-1];var s,l=new i(e);for(o=0;o<e;++o)l[o]=l[o-1]+a[o-1]<<1;if(n){s=new i(1<<e);var u=15-e;for(o=0;o<r;++o)if(t[o])for(var c=o<<4|t[o],h=e-t[o],p=l[t[o]-1]++<<h,f=p|(1<<h)-1;p<=f;++p)s[g[p]>>>u]=c}else for(s=new i(r),o=0;o<r;++o)t[o]&&(s[o]=g[l[t[o]-1]++]>>>15-t[o]);return s},x=new r(288);for(y=0;y<144;++y)x[y]=8;for(y=144;y<256;++y)x[y]=9;for(y=256;y<280;++y)x[y]=7;for(y=280;y<288;++y)x[y]=8;var b=new r(32);for(y=0;y<32;++y)b[y]=5;var w=_(x,9,0),E=_(x,9,1),S=_(b,5,0),M=_(b,5,1),T=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},C=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},I=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},A=function(t){return(t/8|0)+(7&t&&1)},L=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var a=new(t instanceof i?i:t instanceof o?o:r)(n-e);return a.set(t.subarray(e,n)),a},P=function(t,e,n){var i=t.length;if(!i||n&&!n.l&&i<5)return e||new r(0);var o=!e||n,u=!n||n.i;n||(n={}),e||(e=new r(3*i));var c=function(t){var n=e.length;if(t>n){var i=new r(Math.max(2*n,t));i.set(e),e=i}},p=n.f||0,f=n.p||0,m=n.b||0,g=n.l,y=n.d,v=n.m,x=n.n,b=8*i;do{if(!g){n.f=p=C(t,f,1);var w=C(t,f+1,3);if(f+=3,!w){var S=t[(V=A(f)+4)-4]|t[V-3]<<8,P=V+S;if(P>i){if(u)throw"unexpected EOF";break}o&&c(m+S),e.set(t.subarray(V,P),m),n.b=m+=S,n.p=f=8*P;continue}if(1==w)g=E,y=M,v=9,x=5;else{if(2!=w)throw"invalid block type";var R=C(t,f,31)+257,D=C(t,f+10,15)+4,N=R+C(t,f+5,31)+1;f+=14;for(var O=new r(N),k=new r(19),z=0;z<D;++z)k[l[z]]=C(t,f+3*z,7);f+=3*D;var F=T(k),B=(1<<F)-1;if(!u&&f+N*(F+7)>b)break;var U=_(k,F,1);for(z=0;z<N;){var V,G=U[C(t,f,B)];if(f+=15&G,(V=G>>>4)<16)O[z++]=V;else{var j=0,H=0;for(16==V?(H=3+C(t,f,3),f+=2,j=O[z-1]):17==V?(H=3+C(t,f,7),f+=3):18==V&&(H=11+C(t,f,127),f+=7);H--;)O[z++]=j}}var q=O.subarray(0,R),W=O.subarray(R);v=T(q),x=T(W),g=_(q,v,1),y=_(W,x,1)}if(f>b)throw"unexpected EOF"}o&&c(m+131072);for(var X=(1<<v)-1,Z=(1<<x)-1,Y=v+x+18;u||f+Y<b;){var J=(j=g[I(t,f)&X])>>>4;if((f+=15&j)>b)throw"unexpected EOF";if(!j)throw"invalid length/literal";if(J<256)e[m++]=J;else{if(256==J){g=null;break}var K=J-254;J>264&&(K=C(t,f,(1<<(tt=a[z=J-257]))-1)+h[z],f+=tt);var Q=y[I(t,f)&Z],$=Q>>>4;if(!Q)throw"invalid distance";if(f+=15&Q,W=d[$],$>3){var tt=s[$];W+=I(t,f)&(1<<tt)-1,f+=tt}if(f>b)throw"unexpected EOF";o&&c(m+131072);for(var et=m+K;m<et;m+=4)e[m]=e[m-W],e[m+1]=e[m+1-W],e[m+2]=e[m+2-W],e[m+3]=e[m+3-W];m=et}}n.l=g,n.p=f,n.b=m,g&&(p=1,n.m=v,n.d=y,n.n=x)}while(!p);return m==e.length?e:L(e,0,m)},R=function(t,e,n){var r=e/8|0;t[r]|=n<<=7&e,t[r+1]|=n>>>8},D=function(t,e,n){var r=e/8|0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},N=function(t,e){for(var n=[],o=0;o<t.length;++o)t[o]&&n.push({s:o,f:t[o]});var a=n.length,s=n.slice();if(!a)return[V,0];if(1==a){var l=new r(n[0].s+1);return l[n[0].s]=1,[l,1]}n.sort((function(t,e){return t.f-e.f})),n.push({s:-1,f:25001});var u=n[0],c=n[1],h=0,p=1,f=2;for(n[0]={s:-1,f:u.f+c.f,l:u,r:c};p!=a-1;)u=n[n[h].f<n[f].f?h++:f++],c=n[h!=p&&n[h].f<n[f].f?h++:f++],n[p++]={s:-1,f:u.f+c.f,l:u,r:c};var d=s[0].s;for(o=1;o<a;++o)s[o].s>d&&(d=s[o].s);var m=new i(d+1),g=O(n[p-1],m,0);if(g>e){o=0;var y=0,v=g-e,_=1<<v;for(s.sort((function(t,e){return m[e.s]-m[t.s]||t.f-e.f}));o<a;++o){var x=s[o].s;if(!(m[x]>e))break;y+=_-(1<<g-m[x]),m[x]=e}for(y>>>=v;y>0;){var b=s[o].s;m[b]<e?y-=1<<e-m[b]++-1:++o}for(;o>=0&&y;--o){var w=s[o].s;m[w]==e&&(--m[w],++y)}g=e}return[new r(m),g]},O=function(t,e,n){return-1==t.s?Math.max(O(t.l,e,n+1),O(t.r,e,n+1)):e[t.s]=n},k=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new i(++e),r=0,o=t[0],a=1,s=function(t){n[r++]=t},l=1;l<=e;++l)if(t[l]==o&&l!=e)++a;else{if(!o&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(o),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(o);a=1,o=t[l]}return[n.subarray(0,r),e]},z=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},F=function(t,e,n){var r=n.length,i=A(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o<r;++o)t[i+o+4]=n[o];return 8*(i+4+r)},B=function(t,e,n,r,o,u,c,h,p,f,d){R(e,d++,n),++o[256];for(var m=N(o,15),g=m[0],y=m[1],v=N(u,15),E=v[0],M=v[1],T=k(g),C=T[0],I=T[1],A=k(E),L=A[0],P=A[1],O=new i(19),B=0;B<C.length;++B)O[31&C[B]]++;for(B=0;B<L.length;++B)O[31&L[B]]++;for(var U=N(O,7),V=U[0],G=U[1],j=19;j>4&&!V[l[j-1]];--j);var H,q,W,X,Z=f+5<<3,Y=z(o,x)+z(u,b)+c,J=z(o,g)+z(u,E)+c+14+3*j+z(O,V)+(2*O[16]+3*O[17]+7*O[18]);if(Z<=Y&&Z<=J)return F(e,d,t.subarray(p,p+f));if(R(e,d,1+(J<Y)),d+=2,J<Y){H=_(g,y,0),q=g,W=_(E,M,0),X=E;var K=_(V,G,0);for(R(e,d,I-257),R(e,d+5,P-1),R(e,d+10,j-4),d+=14,B=0;B<j;++B)R(e,d+3*B,V[l[B]]);d+=3*j;for(var Q=[C,L],$=0;$<2;++$){var tt=Q[$];for(B=0;B<tt.length;++B)R(e,d,K[et=31&tt[B]]),d+=V[et],et>15&&(R(e,d,tt[B]>>>5&127),d+=tt[B]>>>12)}}else H=w,q=x,W=S,X=b;for(B=0;B<h;++B)if(r[B]>255){var et;D(e,d,H[257+(et=r[B]>>>18&31)]),d+=q[et+257],et>7&&(R(e,d,r[B]>>>23&31),d+=a[et]);var nt=31&r[B];D(e,d,W[nt]),d+=X[nt],nt>3&&(D(e,d,r[B]>>>5&8191),d+=s[nt])}else D(e,d,H[r[B]]),d+=q[r[B]];return D(e,d,H[256]),d+q[256]},U=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),V=new r(0),G=function(t,e,n,l,u,c){var h=t.length,f=new r(l+h+5*(1+Math.ceil(h/7e3))+u),d=f.subarray(l,f.length-u),g=0;if(!e||h<8)for(var y=0;y<=h;y+=65535){var v=y+65535;v<h?g=F(d,g,t.subarray(y,v)):(d[y]=c,g=F(d,g,t.subarray(y,h)))}else{for(var _=U[e-1],x=_>>>13,b=8191&_,w=(1<<n)-1,E=new i(32768),S=new i(w+1),M=Math.ceil(n/3),T=2*M,C=function(e){return(t[e]^t[e+1]<<M^t[e+2]<<T)&w},I=new o(25e3),P=new i(288),R=new i(32),D=0,N=0,O=(y=0,0),k=0,z=0;y<h;++y){var G=C(y),j=32767&y,H=S[G];if(E[j]=H,S[G]=j,k<=y){var q=h-y;if((D>7e3||O>24576)&&q>423){g=B(t,d,0,I,P,R,N,O,z,y-z,g),O=D=N=0,z=y;for(var W=0;W<286;++W)P[W]=0;for(W=0;W<30;++W)R[W]=0}var X=2,Z=0,Y=b,J=j-H&32767;if(q>2&&G==C(y-J))for(var K=Math.min(x,q)-1,Q=Math.min(32767,y),$=Math.min(258,q);J<=Q&&--Y&&j!=H;){if(t[y+X]==t[y+X-J]){for(var tt=0;tt<$&&t[y+tt]==t[y+tt-J];++tt);if(tt>X){if(X=tt,Z=J,tt>K)break;var et=Math.min(J,tt-2),nt=0;for(W=0;W<et;++W){var rt=y-J+W+32768&32767,it=rt-E[rt]+32768&32767;it>nt&&(nt=it,H=rt)}}}J+=(j=H)-(H=E[j])+32768&32767}if(Z){I[O++]=268435456|p[X]<<18|m[Z];var ot=31&p[X],at=31&m[Z];N+=a[ot]+s[at],++P[257+ot],++R[at],k=y+X,++D}else I[O++]=t[y],++P[t[y]]}}g=B(t,d,c,I,P,R,N,O,z,y-z,g),!c&&7&g&&(g=F(d,g+1,V))}return L(f,0,l+A(g)+u)},j=function(){for(var t=new o(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),H=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=j[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}},q=function(){var t=1,e=0;return{p:function(n){for(var r=t,i=e,o=n.length,a=0;a!=o;){for(var s=Math.min(a+2655,o);a<s;++a)i+=r+=n[a];r=(65535&r)+15*(r>>16),i=(65535&i)+15*(i>>16)}t=r,e=i},d:function(){return((t%=65521)>>>8<<16|(255&(e%=65521))<<8|e>>>8)+2*((255&t)<<23)}}},W=function(t,e,n,r,i){return G(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!i)},Z=function(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n},Y=function(t,e,n){for(var r=t(),i=""+t,o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<r.length;++a){var s=r[a],l=o[a];if("function"==typeof s){e+=";"+l+"=";var u=""+s;if(s.prototype)if(-1!=u.indexOf("[native code]")){var c=u.indexOf(" ",8)+1;e+=u.slice(c,u.indexOf("(",c))}else for(var h in e+=u,s.prototype)e+=";"+l+".prototype."+h+"="+s.prototype[h];else e+=u}else n[l]=s}return[e,n]},J=[],K=function(t){var e=[];for(var n in t)(t[n]instanceof r||t[n]instanceof i||t[n]instanceof o)&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e},Q=function(t,e,r,i){var o;if(!J[r]){for(var a="",s={},l=t.length-1,u=0;u<l;++u)a=(o=Y(t[u],a,s))[0],s=o[1];J[r]=Y(t[l],a,s)}var c=Z({},J[r][1]);return n.default(J[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e+"}",r,c,K(c),i)},$=function(){return[r,i,o,a,s,l,h,d,E,M,g,_,T,C,I,A,L,P,It,ot,at]},tt=function(){return[r,i,o,a,s,l,p,m,w,x,S,b,g,U,V,_,R,D,N,O,k,z,F,B,A,L,G,W,St,ot]},et=function(){return[dt,yt,ft,H,j]},nt=function(){return[mt,gt]},rt=function(){return[vt,ft,q]},it=function(){return[_t]},ot=function(t){return postMessage(t,[t.buffer])},at=function(t){return t&&t.size&&new r(t.size)},st=function(t,e,n,r,i,o){var a=Q(n,r,i,(function(t,e){a.terminate(),o(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},lt=function(t){return t.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(e){return t.push(e.data[0],e.data[1])}},ut=function(t,e,n,r,i){var o,a=Q(t,r,i,(function(t,n){t?(a.terminate(),e.ondata.call(e,t)):(n[1]&&a.terminate(),e.ondata.call(e,t,n[0],n[1]))}));a.postMessage(n),e.push=function(t,n){if(o)throw"stream finished";if(!e.ondata)throw"no stream handler";a.postMessage([t,o=n],[t.buffer])},e.terminate=function(){a.terminate()}},ct=function(t,e){return t[e]|t[e+1]<<8},ht=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+2*(t[e+3]<<23)},pt=function(t,e){return ht(t,e)|4294967296*ht(t,e)},ft=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},dt=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&ft(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},mt=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],n=10;4&e&&(n+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[n++]);return n+(2&e)},gt=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16)+2*(t[e-1]<<23)},yt=function(t){return 10+(t.filename&&t.filename.length+1||0)},vt=function(t,e){var n=e.level,r=0==n?0:n<6?1:9==n?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},_t=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function xt(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var bt=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(W(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=e,this.p(t,e||!1)},t}();e.Deflate=bt;var wt=function(t,e){ut([tt,function(){return[lt,bt]}],this,xt.call(this,t,e),(function(t){var e=new bt(t.data);onmessage=lt(e)}),6)};function Et(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt],(function(t){return ot(St(t.data[0],t.data[1]))}),0,n)}function St(t,e){return W(t,e||{},0,0)}e.AsyncDeflate=wt,e.deflate=Et,e.deflateSync=St;var Mt=function(){function t(t){this.s={},this.p=new r(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var e=this.p.length,n=new r(e+t.length);n.set(this.p),n.set(t,e),this.p=n},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=P(this.p,this.o,this.s);this.ondata(L(n,e,this.s.b),this.d),this.o=L(n,this.s.b-32768),this.s.b=this.o.length,this.p=L(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}();e.Inflate=Mt;var Tt=function(t){this.ondata=t,ut([$,function(){return[lt,Mt]}],this,0,(function(){var t=new Mt;onmessage=lt(t)}),7)};function Ct(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$],(function(t){return ot(It(t.data[0],at(t.data[1])))}),1,n)}function It(t,e){return P(t,e)}e.AsyncInflate=Tt,e.inflate=Ct,e.inflateSync=It;var At=function(){function t(t,e){this.c=H(),this.l=0,this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=W(t,this.o,this.v&&yt(this.o),e&&8,!e);this.v&&(dt(n,this.o),this.v=0),e&&(ft(n,n.length-8,this.c.d()),ft(n,n.length-4,this.l)),this.ondata(n,e)},t}();e.Gzip=At,e.Compress=At;var Lt=function(t,e){ut([tt,et,function(){return[lt,bt,At]}],this,xt.call(this,t,e),(function(t){var e=new At(t.data);onmessage=lt(e)}),8)};function Pt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,et,function(){return[Rt]}],(function(t){return ot(Rt(t.data[0],t.data[1]))}),2,n)}function Rt(t,e){e||(e={});var n=H(),r=t.length;n.p(t);var i=W(t,e,yt(e),8),o=i.length;return dt(i,e),ft(i,o-8,n.d()),ft(i,o-4,r),i}e.AsyncGzip=Lt,e.AsyncCompress=Lt,e.gzip=Pt,e.compress=Pt,e.gzipSync=Rt,e.compressSync=Rt;var Dt=function(){function t(t){this.v=1,Mt.call(this,t)}return t.prototype.push=function(t,e){if(Mt.prototype.e.call(this,t),this.v){var n=this.p.length>3?mt(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Mt.prototype.c.call(this,e)},t}();e.Gunzip=Dt;var Nt=function(t){this.ondata=t,ut([$,nt,function(){return[lt,Mt,Dt]}],this,0,(function(){var t=new Dt;onmessage=lt(t)}),9)};function Ot(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$,nt,function(){return[kt]}],(function(t){return ot(kt(t.data[0]))}),3,n)}function kt(t,e){return P(t.subarray(mt(t),-8),e||new r(gt(t)))}e.AsyncGunzip=Nt,e.gunzip=Ot,e.gunzipSync=kt;var zt=function(){function t(t,e){this.c=q(),this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=W(t,this.o,this.v&&2,e&&4,!e);this.v&&(vt(n,this.o),this.v=0),e&&ft(n,n.length-4,this.c.d()),this.ondata(n,e)},t}();e.Zlib=zt;function Ft(t,e){e||(e={});var n=q();n.p(t);var r=W(t,e,2,4);return vt(r,e),ft(r,r.length-4,n.d()),r}e.AsyncZlib=function(t,e){ut([tt,rt,function(){return[lt,bt,zt]}],this,xt.call(this,t,e),(function(t){var e=new zt(t.data);onmessage=lt(e)}),10)},e.zlib=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,rt,function(){return[Ft]}],(function(t){return ot(Ft(t.data[0],t.data[1]))}),4,n)},e.zlibSync=Ft;var Bt=function(){function t(t){this.v=1,Mt.call(this,t)}return t.prototype.push=function(t,e){if(Mt.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}if(e){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Mt.prototype.c.call(this,e)},t}();e.Unzlib=Bt;var Ut=function(t){this.ondata=t,ut([$,it,function(){return[lt,Mt,Bt]}],this,0,(function(){var t=new Bt;onmessage=lt(t)}),11)};function Vt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$,it,function(){return[Gt]}],(function(t){return ot(Gt(t.data[0],at(t.data[1])))}),5,n)}function Gt(t,e){return P((_t(t),t.subarray(2,-4)),e)}e.AsyncUnzlib=Ut,e.unzlib=Vt,e.unzlibSync=Gt;var jt=function(){function t(t){this.G=Dt,this.I=Mt,this.Z=Bt,this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var i=this,o=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(o):new this.Z(o),this.s.push(this.p,e),this.p=null}}},t}();e.Decompress=jt;var Ht=function(){function t(t){this.G=Nt,this.I=Tt,this.Z=Ut,this.ondata=t}return t.prototype.push=function(t,e){jt.prototype.push.call(this,t,e)},t}();e.AsyncDecompress=Ht,e.decompress=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Ot(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ct(t,e,n):Vt(t,e,n)},e.decompressSync=function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?kt(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?It(t,e):Gt(t,e)};var qt=function(t,e,n,i){for(var o in t){var a=t[o],s=e+o;a instanceof r?n[s]=[a,i]:Array.isArray(a)?n[s]=[a[0],Z(i,a[1])]:qt(a,s+"/",n,i)}},Wt="undefined"!=typeof TextEncoder&&new TextEncoder,Xt="undefined"!=typeof TextDecoder&&new TextDecoder,Zt=0;try{Xt.decode(V,{stream:!0}),Zt=1}catch(n){}var Yt=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return[e,L(t,n-1)];i?3==i?(r=((15&r)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=String.fromCharCode(1&i?(31&r)<<6|63&t[n++]:(15&r)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(r)}},Jt=function(){function t(t){this.ondata=t,Zt?this.t=new TextDecoder:this.p=V}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(e||(e=!1),this.t)return this.ondata(this.t.decode(t,{stream:!e}),e);var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=Yt(n),o=i[0],a=i[1];if(e&&a.length)throw"invalid utf-8 data";this.p=a,this.ondata(o,e)},t}();e.DecodeUTF8=Jt;var Kt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";this.ondata(Qt(t),e||!1)},t}();function Qt(t,e){if(e){for(var n=new r(t.length),i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}if(Wt)return Wt.encode(t);var o=t.length,a=new r(t.length+(t.length>>1)),s=0,l=function(t){a[s++]=t};for(i=0;i<o;++i){if(s+5>a.length){var u=new r(s+8+(o-i<<1));u.set(a),a=u}var c=t.charCodeAt(i);c<128||e?l(c):c<2048?(l(192|c>>>6),l(128|63&c)):c>55295&&c<57344?(l(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>>18),l(128|c>>>12&63),l(128|c>>>6&63),l(128|63&c)):(l(224|c>>>12),l(128|c>>>6&63),l(128|63&c))}return L(a,0,s)}function $t(t,e){if(e){for(var n="",r=0;r<t.length;r+=16384)n+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return n}if(Xt)return Xt.decode(t);var i=Yt(t);if(i[1].length)throw"invalid utf-8 data";return i[0]}e.EncodeUTF8=Kt,e.strToU8=Qt,e.strFromU8=$t;var te=function(t){return 1==t?3:t<6?2:9==t?1:0},ee=function(t,e){return e+30+ct(t,e+26)+ct(t,e+28)},ne=function(t,e,n){var r=ct(t,e+28),i=$t(t.subarray(e+46,e+46+r),!(2048&ct(t,e+8))),o=e+46+r,a=ht(t,e+20),s=n&&4294967295==a?re(t,o):[a,ht(t,e+24),ht(t,e+42)],l=s[0],u=s[1],c=s[2];return[ct(t,e+10),l,u,i,o+ct(t,e+30)+ct(t,e+32),c]},re=function(t,e){for(;1!=ct(t,e);e+=4+ct(t,e+2));return[pt(t,e+12),pt(t,e+4),pt(t,e+20)]},ie=function(t){var e=0;if(t)for(var n in t){var r=t[n].length;if(r>65535)throw"extra field too long";e+=r+4}return e},oe=function(t,e,n,r,i,o,a,s){var l=r.length,u=n.extra,c=s&&s.length,h=ie(u);ft(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(null==o&&8),t[e++]=i&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var p=new Date(null==n.mtime?Date.now():n.mtime),f=p.getFullYear()-1980;if(f<0||f>119)throw"date not in range 1980-2099";if(ft(t,e,2*(f<<24)|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,null!=o&&(ft(t,e,n.crc),ft(t,e+4,o),ft(t,e+8,n.size)),ft(t,e+12,l),ft(t,e+14,h),e+=16,null!=a&&(ft(t,e,c),ft(t,e+6,n.attrs),ft(t,e+10,a),e+=14),t.set(r,e),e+=l,h)for(var d in u){var m=u[d],g=m.length;ft(t,e,+d),ft(t,e+2,g),t.set(m,e+4),e+=4+g}return c&&(t.set(s,e),e+=c),e},ae=function(t,e,n,r,i){ft(t,e,101010256),ft(t,e+8,n),ft(t,e+10,n),ft(t,e+12,r),ft(t,e+16,i)},se=function(){function t(t){this.filename=t,this.c=H(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}();e.ZipPassThrough=se;var le=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new bt(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=te(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.ZipDeflate=le;var ue=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new wt(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=te(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.AsyncZipDeflate=ue;var ce=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(2&this.d)throw"stream finished";var n=Qt(t.filename),i=n.length,o=t.comment,a=o&&Qt(o),s=i!=t.filename.length||a&&o.length!=a.length,l=i+ie(t.extra)+30;if(i>65535)throw"filename too long";var u=new r(l);oe(u,0,t,n,s);var c=[u],h=function(){for(var t=0,n=c;t<n.length;t++)e.ondata(null,n[t],!1);c=[]},p=this.d;this.d=0;var f=this.u.length,d=Z(t,{f:n,u:s,o:a,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),p){var t=e.u[f+1];t?t.r():e.d=1}p=1}}),m=0;t.ondata=function(n,i,o){if(n)e.ondata(n,i,o),e.terminate();else if(m+=i.length,c.push(i),o){var a=new r(16);ft(a,0,134695760),ft(a,4,t.crc),ft(a,8,m),ft(a,12,t.size),c.push(a),d.c=m,d.b=l+m+16,d.crc=t.crc,d.size=t.size,p&&d.r(),p=1}else p&&h()},this.u.push(d)},t.prototype.end=function(){var t=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},t.prototype.e=function(){for(var t=0,e=0,n=0,i=0,o=this.u;i<o.length;i++)n+=46+(u=o[i]).f.length+ie(u.extra)+(u.o?u.o.length:0);for(var a=new r(n+22),s=0,l=this.u;s<l.length;s++){var u;oe(a,t,u=l[s],u.f,u.u,u.c,e,u.o),t+=46+u.f.length+ie(u.extra)+(u.o?u.o.length:0),e+=u.b}ae(a,t,this.u.length,n,e),this.ondata(null,a,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++)e[t].t();this.d=2},t}();e.Zip=ce,e.zip=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";var i={};qt(t,"",i,e);var o=Object.keys(i),a=o.length,s=0,l=0,u=a,c=Array(a),h=[],p=function(){for(var t=0;t<h.length;++t)h[t]()},f=function(){var t=new r(l+22),e=s,i=l-s;l=0;for(var o=0;o<u;++o){var a=c[o];try{var h=a.c.length;oe(t,l,a,a.f,a.u,h);var p=30+a.f.length+ie(a.extra),f=l+p;t.set(a.c,f),oe(t,s,a,a.f,a.u,h,l,a.m),s+=16+p+(a.m?a.m.length:0),l=f+h}catch(t){return n(t,null)}}ae(t,s,c.length,i,e),n(null,t)};a||f();for(var d=function(t){var e=o[t],r=i[e],u=r[0],d=r[1],m=H(),g=u.length;m.p(u);var y=Qt(e),v=y.length,_=d.comment,x=_&&Qt(_),b=x&&x.length,w=ie(d.extra),E=0==d.level?0:8,S=function(r,i){if(r)p(),n(r,null);else{var o=i.length;c[t]=Z(d,{size:g,crc:m.d(),c:i,f:y,m:x,u:v!=e.length||x&&_.length!=b,compression:E}),s+=30+v+w+o,l+=76+2*(v+w)+(b||0)+o,--a||f()}};if(v>65535&&S("filename too long",null),E)if(g<16e4)try{S(null,St(u,d))}catch(t){S(t,null)}else h.push(Et(u,d,S));else S(null,u)},m=0;m<u;++m)d(m);return p},e.zipSync=function(t,e){e||(e={});var n={},i=[];qt(t,"",n,e);var o=0,a=0;for(var s in n){var l=n[s],u=l[0],c=l[1],h=0==c.level?0:8,p=(S=Qt(s)).length,f=c.comment,d=f&&Qt(f),m=d&&d.length,g=ie(c.extra);if(p>65535)throw"filename too long";var y=h?St(u,c):u,v=y.length,_=H();_.p(u),i.push(Z(c,{size:u.length,crc:_.d(),c:y,f:S,m:d,u:p!=s.length||d&&f.length!=m,o:o,compression:h})),o+=30+p+g+v,a+=76+2*(p+g)+(m||0)+v}for(var x=new r(a+22),b=o,w=a-o,E=0;E<i.length;++E){var S;oe(x,(S=i[E]).o,S,S.f,S.u,S.c.length);var M=30+S.f.length+ie(S.extra);x.set(S.c,S.o+M),oe(x,o,S,S.f,S.u,S.c.length,S.o,S.m),o+=16+M+(S.m?S.m.length:0)}return ae(x,o,i.length,w,b),x};var he=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}();e.UnzipPassThrough=he;var pe=function(){function t(){var t=this;this.i=new Mt((function(e,n){t.ondata(null,e,n)}))}return t.prototype.push=function(t,e){try{this.i.push(t,e)}catch(n){this.ondata(n,t,e)}},t.compression=8,t}();e.UnzipInflate=pe;var fe=function(){function t(t,e){var n=this;e<32e4?this.i=new Mt((function(t,e){n.ondata(null,t,e)})):(this.i=new Tt((function(t,e,r){n.ondata(t,e,r)})),this.terminate=this.i.terminate)}return t.prototype.push=function(t,e){this.i.terminate&&(t=L(t,0)),this.i.push(t,e)},t.compression=8,t}();e.AsyncUnzipInflate=fe;var de=function(){function t(t){this.onfile=t,this.k=[],this.o={0:he},this.p=V}return t.prototype.push=function(t,e){var n=this;if(!this.onfile)throw"no callback";if(this.c>0){var i=Math.min(this.c,t.length),o=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(i)).length)return this.push(t,e)}else{var a=0,s=0,l=void 0,u=void 0;this.p.length?t.length?((u=new r(this.p.length+t.length)).set(this.p),u.set(t,this.p.length)):u=this.p:u=t;for(var c=u.length,h=this.c,p=h&&this.d,f=function(){var t,e=ht(u,s);if(67324752==e){a=1,l=s,d.d=null,d.c=0;var r=ct(u,s+6),i=ct(u,s+8),o=2048&r,p=8&r,f=ct(u,s+26),m=ct(u,s+28);if(c>s+30+f+m){var g=[];d.k.unshift(g),a=2;var y=ht(u,s+18),v=ht(u,s+22),_=$t(u.subarray(s+30,s+=30+f),!o);4294967295==y?(t=p?[-2]:re(u,s),y=t[0],v=t[1]):p&&(y=-1),s+=m,d.c=y;var x={name:_,compression:i,start:function(){if(!x.ondata)throw"no callback";if(y){var t=n.o[i];if(!t)throw"unknown compression type "+i;var e=y<0?new t(_):new t(_,y,v);e.ondata=function(t,e,n){x.ondata(t,e,n)};for(var r=0,o=g;r<o.length;r++)e.push(o[r],!1);n.k[0]==g?n.d=e:e.push(V,!0)}else x.ondata(null,V,!0)},terminate:function(){n.k[0]==g&&n.d.terminate&&n.d.terminate()}};y>=0&&(x.size=y,x.originalSize=v),d.onfile(x)}return"break"}if(h){if(134695760==e)return l=s+=12+(-2==h&&8),a=2,d.c=0,"break";if(33639248==e)return l=s-=4,a=2,d.c=0,"break"}},d=this;s<c-4&&"break"!==f();++s);if(this.p=V,h<0){var m=u.subarray(0,a?l-12-(-2==h&&8)-(134695760==ht(u,l-16)&&4):s);p?p.push(m,!!a):this.k[+(2==a)].push(m)}if(2&a)return this.push(u.subarray(s),e);this.p=u.subarray(s)}if(e&&this.c)throw"invalid zip file"},t.prototype.register=function(t){this.o[t.compression]=t},t}();return e.Unzip=de,e.unzip=function(t,e){if("function"!=typeof e)throw"no callback";for(var n=[],i=function(){for(var t=0;t<n.length;++t)n[t]()},o={},a=t.length-22;101010256!=ht(t,a);--a)if(!a||t.length-a>65558)return void e("invalid zip file",null);var s=ct(t,a+8);s||e(null,{});var l=s,u=ht(t,a+16),c=4294967295==u;if(c){if(a=ht(t,a-12),101075792!=ht(t,a))return void e("invalid zip file",null);l=s=ht(t,a+32),u=ht(t,a+48)}for(var h=function(a){var l=ne(t,u,c),h=l[0],p=l[1],f=l[2],d=l[3],m=l[4],g=ee(t,l[5]);u=m;var y=function(t,n){t?(i(),e(t,null)):(o[d]=n,--s||e(null,o))};if(h)if(8==h){var v=t.subarray(g,g+p);if(p<32e4)try{y(null,It(v,new r(f)))}catch(t){y(t,null)}else n.push(Ct(v,{size:f},y))}else y("unknown compression type "+h,null);else y(null,L(t,g,g+p))},p=0;p<l;++p)h();return i},e.unzipSync=function(t){for(var e={},n=t.length-22;101010256!=ht(t,n);--n)if(!n||t.length-n>65558)throw"invalid zip file";var i=ct(t,n+8);if(!i)return{};var o=ht(t,n+16),a=4294967295==o;if(a){if(n=ht(t,n-12),101075792!=ht(t,n))throw"invalid zip file";i=ht(t,n+32),o=ht(t,n+48)}for(var s=0;s<i;++s){var l=ne(t,o,a),u=l[0],c=l[1],h=l[2],p=l[3],f=l[4],d=ee(t,l[5]);if(o=f,u){if(8!=u)throw"unknown compression type "+u;e[p]=It(t.subarray(d,d+c),new r(h))}else e[p]=L(t,d,d+c)}return e},e}))}).call(this)}).call(this,n({}).setImmediate),X=X.exports;var Z={};!function(){let t,e,n;class i{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){e=this.parseConnections();const t=this.parseImages(),r=this.parseTextures(t),i=this.parseMaterials(r),a=this.parseDeformers(),s=(new o).parse(a);return this.parseScene(a,s,i),n}parseConnections(){const e=new Map;return"Connections"in t&&t.Connections.connections.forEach((function(t){const n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const o={ID:r,relationship:i};e.get(n).parents.push(o),e.has(r)||e.set(r,{parents:[],children:[]});const a={ID:n,relationship:i};e.get(r).children.push(a)})),e}parseImages(){const e={},n={};if("Video"in t.Objects){const r=t.Objects.Video;for(const t in r){const i=r[t];if(e[parseInt(t)]=i.RelativeFilename||i.Filename,"Content"in i){const e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,o="string"==typeof i.Content&&""!==i.Content;if(e||o){const e=this.parseImage(r[t]);n[i.RelativeFilename||i.Filename]=e}}}}for(const t in e){const r=e[t];void 0!==n[r]?e[t]=n[r]:e[t]=e[t].split("\\").pop()}return e}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+i+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:i}))}}parseTextures(e){const n=new Map;if("Texture"in t.Objects){const r=t.Objects.Texture;for(const t in r){const i=this.parseTexture(r[t],e);n.set(parseInt(t),i)}}return n}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const i=t.WrapModeU,o=t.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==o?o.value:0;if(n.wrapS=0===a?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=0===s?r.RepeatWrapping:r.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;n.repeat.x=e[0],n.repeat.y=e[1]}return n}loadTexture(t,n){let i;const o=this.textureLoader.path,a=e.get(t.id).children;let s;void 0!==a&&a.length>0&&void 0!==n[a[0].ID]&&(0!==(i=n[a[0].ID]).indexOf("blob:")&&0!==i.indexOf("data:")||this.textureLoader.setPath(void 0));const l=t.FileName.slice(-3).toLowerCase();if("tga"===l){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):(e.setPath(this.textureLoader.path),s=e.load(i))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):s=this.textureLoader.load(i);return this.textureLoader.setPath(o),s}parseMaterials(e){const n=new Map;if("Material"in t.Objects){const r=t.Objects.Material;for(const t in r){const i=this.parseMaterial(r[t],e);null!==i&&n.set(parseInt(t),i)}}return n}parseMaterial(t,n){const i=t.id,o=t.attrName;let a=t.ShadingModel;if("object"==typeof a&&(a=a.value),!e.has(i))return null;const s=this.parseParameters(t,n,i);let l;switch(a.toLowerCase()){case"phong":l=new r.MeshPhongMaterial;break;case"lambert":l=new r.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',a),l=new r.MeshPhongMaterial}return l.setValues(s),l.name=o,l}parseParameters(t,n,i){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new r.Color).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new r.Color).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new r.Color).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new r.Color).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=(new r.Color).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new r.Color).fromArray(t.SpecularColor.value));const a=this;return e.get(i).children.forEach((function(t){const e=t.relationship;switch(e){case"Bump":o.bumpMap=a.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=a.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=a.getTexture(n,t.ID),void 0!==o.map&&(o.map.encoding=r.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=a.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=a.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=r.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=a.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=a.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=r.EquirectangularReflectionMapping,o.envMap.encoding=r.sRGBEncoding);break;case"SpecularColor":o.specularMap=a.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.encoding=r.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=a.getTexture(n,t.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",e)}})),o}getTexture(n,r){return"LayeredTexture"in t.Objects&&r in t.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),r=e.get(r).children[0].ID),n.get(r)}parseDeformers(){const n={},r={};if("Deformer"in t.Objects){const i=t.Objects.Deformer;for(const t in i){const o=i[t],a=e.get(parseInt(t));if("Skin"===o.attrType){const e=this.parseSkeleton(a,i);e.ID=t,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=a.parents[0].ID,n[t]=e}else if("BlendShape"===o.attrType){const e={id:t};e.rawTargets=this.parseMorphTargets(a,i),e.id=t,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),r[t]=e}}}return{skeletons:n,morphTargets:r}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const i=e[t.ID];if("Cluster"!==i.attrType)return;const o={ID:t.ID,indices:[],weights:[],transformLink:(new r.Matrix4).fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),n.push(o)})),{rawBones:n,bones:[]}}parseMorphTargets(t,n){const r=[];for(let i=0;i<t.children.length;i++){const o=t.children[i],a=n[o.ID],s={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if("BlendShapeChannel"!==a.attrType)return;s.geoID=e.get(parseInt(o.ID)).children.filter((function(t){return void 0===t.relationship}))[0].ID,r.push(s)}return r}parseScene(i,o,s){n=new r.Group;const l=this.parseModels(i.skeletons,o,s),u=t.Objects.Model,c=this;l.forEach((function(t){const r=u[t.ID];c.setLookAtProperties(t,r),e.get(t.ID).parents.forEach((function(e){const n=l.get(e.ID);void 0!==n&&n.add(t)})),null===t.parent&&n.add(t)})),this.bindSkeleton(i.skeletons,o,l),this.createAmbientLight(),n.traverse((function(t){if(t.userData.transformData){t.parent&&(t.userData.transformData.parentMatrix=t.parent.matrix,t.userData.transformData.parentMatrixWorld=t.parent.matrixWorld);const e=y(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}}));const h=(new a).parse();1===n.children.length&&n.children[0].isGroup&&(n.children[0].animations=h,n=n.children[0]),n.animations=h}parseModels(n,i,o){const a=new Map,s=t.Objects.Model;for(const t in s){const l=parseInt(t),u=s[t],c=e.get(l);let h=this.buildSkeleton(c,n,l,u.attrName);if(!h){switch(u.attrType){case"Camera":h=this.createCamera(c);break;case"Light":h=this.createLight(c);break;case"Mesh":h=this.createMesh(c,i,o);break;case"NurbsCurve":h=this.createCurve(c,i);break;case"LimbNode":case"Root":h=new r.Bone;break;default:h=new r.Group}h.name=u.attrName?r.PropertyBinding.sanitizeNodeName(u.attrName):"",h.ID=l}this.getTransformData(h,u),a.set(l,h)}return a}buildSkeleton(t,e,n,i){let o=null;return t.parents.forEach((function(t){for(const a in e){const s=e[a];s.rawBones.forEach((function(e,a){if(e.ID===t.ID){const t=o;(o=new r.Bone).matrixWorld.copy(e.transformLink),o.name=i?r.PropertyBinding.sanitizeNodeName(i):"",o.ID=n,s.bones[a]=o,null!==t&&o.add(t)}}))}})),o}createCamera(e){let n,i;if(e.children.forEach((function(e){const n=t.Objects.NodeAttribute[e.ID];void 0!==n&&(i=n)})),void 0===i)n=new r.Object3D;else{let t=0;void 0!==i.CameraProjectionType&&1===i.CameraProjectionType.value&&(t=1);let e=1;void 0!==i.NearPlane&&(e=i.NearPlane.value/1e3);let o=1e3;void 0!==i.FarPlane&&(o=i.FarPlane.value/1e3);let a=window.innerWidth,s=window.innerHeight;void 0!==i.AspectWidth&&void 0!==i.AspectHeight&&(a=i.AspectWidth.value,s=i.AspectHeight.value);const l=a/s;let u=45;void 0!==i.FieldOfView&&(u=i.FieldOfView.value);const c=i.FocalLength?i.FocalLength.value:null;switch(t){case 0:n=new r.PerspectiveCamera(u,l,e,o),null!==c&&n.setFocalLength(c);break;case 1:n=new r.OrthographicCamera(-a/2,a/2,s/2,-s/2,e,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),n=new r.Object3D}}return n}createLight(e){let n,i;if(e.children.forEach((function(e){const n=t.Objects.NodeAttribute[e.ID];void 0!==n&&(i=n)})),void 0===i)n=new r.Object3D;else{let t;t=void 0===i.LightType?0:i.LightType.value;let e=16777215;void 0!==i.Color&&(e=(new r.Color).fromArray(i.Color.value));let o=void 0===i.Intensity?1:i.Intensity.value/100;void 0!==i.CastLightOnObject&&0===i.CastLightOnObject.value&&(o=0);let a=0;void 0!==i.FarAttenuationEnd&&(a=void 0!==i.EnableFarAttenuation&&0===i.EnableFarAttenuation.value?0:i.FarAttenuationEnd.value);const s=1;switch(t){case 0:n=new r.PointLight(e,o,a,s);break;case 1:n=new r.DirectionalLight(e,o);break;case 2:let t=Math.PI/3;void 0!==i.InnerAngle&&(t=r.MathUtils.degToRad(i.InnerAngle.value));let l=0;void 0!==i.OuterAngle&&(l=r.MathUtils.degToRad(i.OuterAngle.value),l=Math.max(l,1)),n=new r.SpotLight(e,o,a,t,l,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+i.LightType.value+", defaulting to a THREE.PointLight."),n=new r.PointLight(e,o)}void 0!==i.CastShadows&&1===i.CastShadows.value&&(n.castShadow=!0)}return n}createMesh(t,e,n){let i,o=null,a=null;const s=[];return t.children.forEach((function(t){e.has(t.ID)&&(o=e.get(t.ID)),n.has(t.ID)&&s.push(n.get(t.ID))})),s.length>1?a=s:s.length>0?a=s[0]:(a=new r.MeshPhongMaterial({color:13421772}),s.push(a)),"color"in o.attributes&&s.forEach((function(t){t.vertexColors=!0})),o.FBX_Deformer?(i=new r.SkinnedMesh(o,a)).normalizeSkinWeights():i=new r.Mesh(o,a),i}createCurve(t,e){const n=t.children.reduce((function(t,n){return e.has(n.ID)&&(t=e.get(n.ID)),t}),null),i=new r.LineBasicMaterial({color:3342591,linewidth:1});return new r.Line(n,i)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?v(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(i,o){"LookAtProperty"in o&&e.get(i.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const o=t.Objects.Model[e.ID];if("Lcl_Translation"in o){const t=o.Lcl_Translation.value;void 0!==i.target?(i.target.position.fromArray(t),n.add(i.target)):i.lookAt((new r.Vector3).fromArray(t))}}}))}bindSkeleton(t,n,i){const o=this.parsePoseNodes();for(const a in t){const s=t[a];e.get(parseInt(s.ID)).parents.forEach((function(t){if(n.has(t.ID)){const n=t.ID;e.get(n).parents.forEach((function(t){i.has(t.ID)&&i.get(t.ID).bind(new r.Skeleton(s.bones),o[t.ID])}))}}))}}parsePoseNodes(){const e={};if("Pose"in t.Objects){const n=t.Objects.Pose;for(const t in n)if("BindPose"===n[t].attrType){const i=n[t].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new r.Matrix4).fromArray(t.Matrix.a)})):e[i.Node]=(new r.Matrix4).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in t&&"AmbientColor"in t.GlobalSettings){const e=t.GlobalSettings.AmbientColor.value,i=e[0],o=e[1],a=e[2];if(0!==i||0!==o||0!==a){const t=new r.Color(i,o,a);n.add(new r.AmbientLight(t,1))}}}}class o{parse(n){const r=new Map;if("Geometry"in t.Objects){const i=t.Objects.Geometry;for(const t in i){const o=e.get(parseInt(t)),a=this.parseGeometry(o,i[t],n);r.set(parseInt(t),a)}}return r}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(e,n,r){const i=r.skeletons,o=[],a=e.parents.map((function(e){return t.Objects.Model[e.ID]}));if(0===a.length)return;const s=e.children.reduce((function(t,e){return void 0!==i[e.ID]&&(t=i[e.ID]),t}),null);e.children.forEach((function(t){void 0!==r.morphTargets[t.ID]&&o.push(r.morphTargets[t.ID])}));const l=a[0],u={};"RotationOrder"in l&&(u.eulerOrder=v(l.RotationOrder.value)),"InheritType"in l&&(u.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(u.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(u.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(u.scale=l.GeometricScaling.value);const c=y(u);return this.genGeometry(n,s,o,c)}genGeometry(t,e,n,i){const o=new r.BufferGeometry;t.attrName&&(o.name=t.attrName);const a=this.parseGeoNode(t,e),s=this.genBuffers(a),l=new r.Float32BufferAttribute(s.vertex,3);if(l.applyMatrix4(i),o.setAttribute("position",l),s.colors.length>0&&o.setAttribute("color",new r.Float32BufferAttribute(s.colors,3)),e&&(o.setAttribute("skinIndex",new r.Uint16BufferAttribute(s.weightsIndices,4)),o.setAttribute("skinWeight",new r.Float32BufferAttribute(s.vertexWeights,4)),o.FBX_Deformer=e),s.normal.length>0){const t=(new r.Matrix3).getNormalMatrix(i),e=new r.Float32BufferAttribute(s.normal,3);e.applyNormalMatrix(t),o.setAttribute("normal",e)}if(s.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),o.setAttribute(n,new r.Float32BufferAttribute(s.uvs[e],2))})),a.material&&"AllSame"!==a.material.mappingType){let t=s.materialIndex[0],e=0;if(s.materialIndex.forEach((function(n,r){n!==t&&(o.addGroup(e,r-e,t),t=n,e=r)})),o.groups.length>0){const e=o.groups[o.groups.length-1],n=e.start+e.count;n!==s.materialIndex.length&&o.addGroup(n,s.materialIndex.length-n,t)}0===o.groups.length&&o.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(o,t,n,i),o}parseGeoNode(t,e){const n={};if(n.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],n.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return n.weightTable={},null!==e&&(n.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:e,weight:t.weights[i]})}))}))),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,o=[],a=[],s=[],l=[],u=[],c=[];const h=this;return t.vertexIndices.forEach((function(p,f){let m,g=!1;p<0&&(p^=-1,g=!0);let y=[],v=[];if(o.push(3*p,3*p+1,3*p+2),t.color){const e=d(f,n,p,t.color);s.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[p]&&t.weightTable[p].forEach((function(t){v.push(t.weight),y.push(t.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(n,r){let i=n,o=y[r];e.forEach((function(e,n,r){if(i>e){r[n]=i,i=e;const a=t[n];t[n]=o,o=a}}))})),y=t,v=e}for(;v.length<4;)v.push(0),y.push(0);for(let t=0;t<4;++t)u.push(v[t]),c.push(y[t])}if(t.normal){const e=d(f,n,p,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(m=d(f,n,p,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=d(f,n,p,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,g&&(h.genFace(e,t,o,m,a,s,l,u,c,r),n++,r=0,o=[],a=[],s=[],l=[],u=[],c=[])})),e}genFace(t,e,n,r,i,o,a,s,l,u){for(let c=2;c<u;c++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[3*(c-1)]]),t.vertex.push(e.vertexPositions[n[3*(c-1)+1]]),t.vertex.push(e.vertexPositions[n[3*(c-1)+2]]),t.vertex.push(e.vertexPositions[n[3*c]]),t.vertex.push(e.vertexPositions[n[3*c+1]]),t.vertex.push(e.vertexPositions[n[3*c+2]]),e.skeleton&&(t.vertexWeights.push(s[0]),t.vertexWeights.push(s[1]),t.vertexWeights.push(s[2]),t.vertexWeights.push(s[3]),t.vertexWeights.push(s[4*(c-1)]),t.vertexWeights.push(s[4*(c-1)+1]),t.vertexWeights.push(s[4*(c-1)+2]),t.vertexWeights.push(s[4*(c-1)+3]),t.vertexWeights.push(s[4*c]),t.vertexWeights.push(s[4*c+1]),t.vertexWeights.push(s[4*c+2]),t.vertexWeights.push(s[4*c+3]),t.weightsIndices.push(l[0]),t.weightsIndices.push(l[1]),t.weightsIndices.push(l[2]),t.weightsIndices.push(l[3]),t.weightsIndices.push(l[4*(c-1)]),t.weightsIndices.push(l[4*(c-1)+1]),t.weightsIndices.push(l[4*(c-1)+2]),t.weightsIndices.push(l[4*(c-1)+3]),t.weightsIndices.push(l[4*c]),t.weightsIndices.push(l[4*c+1]),t.weightsIndices.push(l[4*c+2]),t.weightsIndices.push(l[4*c+3])),e.color&&(t.colors.push(o[0]),t.colors.push(o[1]),t.colors.push(o[2]),t.colors.push(o[3*(c-1)]),t.colors.push(o[3*(c-1)+1]),t.colors.push(o[3*(c-1)+2]),t.colors.push(o[3*c]),t.colors.push(o[3*c+1]),t.colors.push(o[3*c+2])),e.material&&"AllSame"!==e.material.mappingType&&(t.materialIndex.push(r),t.materialIndex.push(r),t.materialIndex.push(r)),e.normal&&(t.normal.push(i[0]),t.normal.push(i[1]),t.normal.push(i[2]),t.normal.push(i[3*(c-1)]),t.normal.push(i[3*(c-1)+1]),t.normal.push(i[3*(c-1)+2]),t.normal.push(i[3*c]),t.normal.push(i[3*c+1]),t.normal.push(i[3*c+2])),e.uv&&e.uv.forEach((function(e,n){void 0===t.uvs[n]&&(t.uvs[n]=[]),t.uvs[n].push(a[n][0]),t.uvs[n].push(a[n][1]),t.uvs[n].push(a[n][2*(c-1)]),t.uvs[n].push(a[n][2*(c-1)+1]),t.uvs[n].push(a[n][2*c]),t.uvs[n].push(a[n][2*c+1])}))}addMorphTargets(e,n,r,i){if(0===r.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;r.forEach((function(r){r.rawTargets.forEach((function(r){const a=t.Objects.Geometry[r.geoID];void 0!==a&&o.genMorphGeometry(e,n,a,i,r.name)}))}))}genMorphGeometry(t,e,n,i,o){const a=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],s=void 0!==n.Vertices?n.Vertices.a:[],l=void 0!==n.Indexes?n.Indexes.a:[],u=3*t.attributes.position.count,c=new Float32Array(u);for(let t=0;t<l.length;t++){const e=3*l[t];c[e]=s[3*t],c[e+1]=s[3*t+1],c[e+2]=s[3*t+2]}const h={vertexIndices:a,vertexPositions:c},p=this.genBuffers(h),f=new r.Float32BufferAttribute(p.vertex,3);f.name=o||n.attrName,f.applyMatrix4(i),t.morphAttributes.position.push(f)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in t?i=t.NormalIndex.a:"NormalsIndex"in t&&(i=t.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.UV.a;let i=[];return"IndexToDirect"===n&&(i=t.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Colors.a;let i=[];return"IndexToDirect"===n&&(i=t.ColorIndex.a),{dataSize:4,buffer:r,indices:i,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if("NoMappingInformation"===e)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=t.Materials.a,i=[];for(let t=0;t<r.length;++t)i.push(t);return{dataSize:1,buffer:r,indices:i,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(void 0===r.NURBSCurve)return console.error("THREE.FBXLoader: The loader relies on THREE.NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new r.BufferGeometry;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new r.BufferGeometry;const n=e-1,i=t.KnotVector.a,o=[],a=t.Points.a;for(let t=0,e=a.length;t<e;t+=4)o.push((new r.Vector4).fromArray(a,t));let s,l;if("Closed"===t.Form)o.push(o[0]);else if("Periodic"===t.Form){s=n,l=i.length-1-s;for(let t=0;t<n;++t)o.push(o[t])}const u=new r.NURBSCurve(n,i,o,s,l).getPoints(12*o.length);return(new r.BufferGeometry).setFromPoints(u)}}class a{parse(){const t=[],e=this.parseClips();if(void 0!==e)for(const n in e){const r=e[n],i=this.addClip(r);t.push(i)}return t}parseClips(){if(void 0===t.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const n=this.parseAnimationLayers(e);return this.parseAnimStacks(n)}parseAnimationCurveNodes(){const e=t.Objects.AnimationCurveNode,n=new Map;for(const t in e){const r=e[t];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const t={id:r.id,attr:r.attrName,curves:{}};n.set(t.id,t)}}return n}parseAnimationCurves(n){const r=t.Objects.AnimationCurve;for(const t in r){const i={id:r[t].id,times:r[t].KeyTime.a.map(p),values:r[t].KeyValueFloat.a},o=e.get(i.id);if(void 0!==o){const t=o.parents[0].ID,e=o.parents[0].relationship;e.match(/X/)?n.get(t).curves.x=i:e.match(/Y/)?n.get(t).curves.y=i:e.match(/Z/)?n.get(t).curves.z=i:e.match(/d|DeformPercent/)&&n.has(t)&&(n.get(t).curves.morph=i)}}}parseAnimationLayers(i){const o=t.Objects.AnimationLayer,a=new Map;for(const s in o){const o=[],l=e.get(parseInt(s));void 0!==l&&(l.children.forEach((function(a,s){if(i.has(a.ID)){const l=i.get(a.ID);if(void 0!==l.curves.x||void 0!==l.curves.y||void 0!==l.curves.z){if(void 0===o[s]){const i=e.get(a.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID;if(void 0!==i){const e=t.Objects.Model[i.toString()];if(void 0===e)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",a);const l={modelName:e.attrName?r.PropertyBinding.sanitizeNodeName(e.attrName):"",ID:e.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};n.traverse((function(t){t.ID===e.id&&(l.transform=t.matrix,t.userData.transformData&&(l.eulerOrder=t.userData.transformData.eulerOrder))})),l.transform||(l.transform=new r.Matrix4),"PreRotation"in e&&(l.preRotation=e.PreRotation.value),"PostRotation"in e&&(l.postRotation=e.PostRotation.value),o[s]=l}}o[s]&&(o[s][l.attr]=l)}else if(void 0!==l.curves.morph){if(void 0===o[s]){const n=e.get(a.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID,i=e.get(n).parents[0].ID,l=e.get(i).parents[0].ID,u=e.get(l).parents[0].ID,c=t.Objects.Model[u],h={modelName:c.attrName?r.PropertyBinding.sanitizeNodeName(c.attrName):"",morphName:t.Objects.Deformer[n].attrName};o[s]=h}o[s][l.attr]=l}}})),a.set(parseInt(s),o))}return a}parseAnimStacks(n){const r=t.Objects.AnimationStack,i={};for(const t in r){const o=e.get(parseInt(t)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=n.get(o[0].ID);i[t]={name:r[t].attrName,layer:a}}return i}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new r.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new r.Vector3,i=new r.Quaternion,o=new r.Vector3;if(t.transform&&t.transform.decompose(n,i,o),n=n.toArray(),i=(new r.Euler).setFromQuaternion(i,t.eulerOrder).toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const n=this.generateRotationTrack(t.modelName,t.R.curves,i,t.preRotation,t.postRotation,t.eulerOrder);void 0!==n&&e.push(n)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==n&&e.push(n)}if(void 0!==t.DeformPercent){const n=this.generateMorphTrack(t);void 0!==n&&e.push(n)}return e}generateVectorTrack(t,e,n,i){const o=this.getTimesForAllAxes(e),a=this.getKeyframeTrackValues(o,e,n);return new r.VectorKeyframeTrack(t+"."+i,o,a)}generateRotationTrack(t,e,n,i,o,a){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(r.MathUtils.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(r.MathUtils.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(r.MathUtils.degToRad));const s=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(s,e,n);void 0!==i&&((i=i.map(r.MathUtils.degToRad)).push(a),i=(new r.Euler).fromArray(i),i=(new r.Quaternion).setFromEuler(i)),void 0!==o&&((o=o.map(r.MathUtils.degToRad)).push(a),o=(new r.Euler).fromArray(o),o=(new r.Quaternion).setFromEuler(o).invert());const u=new r.Quaternion,c=new r.Euler,h=[];for(let t=0;t<l.length;t+=3)c.set(l[t],l[t+1],l[t+2],a),u.setFromEuler(c),void 0!==i&&u.premultiply(i),void 0!==o&&u.multiply(o),u.toArray(h,t/3*4);return new r.QuaternionKeyframeTrack(t+".quaternion",s,h)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,i=e.values.map((function(t){return t/100})),o=n.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new r.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+o+"]",e.times,i)}getTimesForAllAxes(t){let e=[];if(void 0!==t.x&&(e=e.concat(t.x.times)),void 0!==t.y&&(e=e.concat(t.y.times)),void 0!==t.z&&(e=e.concat(t.z.times)),(e=e.sort((function(t,e){return t-e}))).length>1){let t=1,n=e[0];for(let r=1;r<e.length;r++){const i=e[r];i!==n&&(e[t]=i,n=i,t++)}e=e.slice(0,t)}return e}getKeyframeTrackValues(t,e,n){const r=n,i=[];let o=-1,a=-1,s=-1;return t.forEach((function(t){if(e.x&&(o=e.x.times.indexOf(t)),e.y&&(a=e.y.times.indexOf(t)),e.z&&(s=e.z.times.indexOf(t)),-1!==o){const t=e.x.values[o];i.push(t),r[0]=t}else i.push(r[0]);if(-1!==a){const t=e.y.values[a];i.push(t),r[1]=t}else i.push(r[1]);if(-1!==s){const t=e.z.values[s];i.push(t),r[2]=t}else i.push(r[2])})),i}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],r=t.values[e]-n,i=Math.abs(r);if(i>=180){const o=i/180,a=r/o;let s=n+a;const l=t.times[e-1],u=(t.times[e]-l)/o;let c=l+u;const h=[],p=[];for(;c<t.times[e];)h.push(c),c+=u,p.push(s),s+=a;t.times=b(t.times,e,h),t.values=b(t.values,e,p)}}}}class s{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new c,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach((function(t,r){const i=t.match(/^[\s\t]*;/),o=t.match(/^[\s\t]*$/);if(i||o)return;const a=t.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),s=t.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=t.match("^\\t{"+(e.currentIndent-1)+"}}");a?e.parseNodeBegin(t,a):s?e.parseNodeProperty(t,s,n[++r]):l?e.popStack():t.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(t)})),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),r=e[2].split(",").map((function(t){return t.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},o=this.parseNodeAttr(r),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in a?("PoseNode"===n?a.PoseNode.push(i):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==o.id&&(a[n][o.id]=i)):"number"==typeof o.id?(a[n]={},a[n][o.id]=i):"Properties70"!==n&&(a[n]="PoseNode"===n?[i]:i),"number"==typeof o.id&&(i.id=o.id),""!==o.name&&(i.attrName=o.name),""!==o.type&&(i.attrType=o.type),this.pushStack(i)}parseNodeAttr(t){let e=t[0];""!==t[0]&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",r="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),i=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===r){const t=i.split(",").slice(1),e=parseInt(t[0]),n=parseInt(t[1]);let a=i.split(",").slice(3);r="connections",function(t,e){for(let n=0,r=t.length,i=e.length;n<i;n++,r++)t[r]=e[n]}(i=[e,n],a=a.map((function(t){return t.trim().replace(/^"/,"")}))),void 0===o[r]&&(o[r]=[])}"Node"===r&&(o.id=i),r in o&&Array.isArray(o[r])?o[r].push(i):"a"!==r?o[r]=i:o.a=i,this.setCurrentProp(o,r),"a"===r&&","!==i.slice(-1)&&(o.a=_(i))}else this.parseNodeSpecialProperty(t,r,i)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=_(e.a))}parseNodeSpecialProperty(t,e,n){const r=n.split('",').map((function(t){return t.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],o=r[1],a=r[2],s=r[3];let l=r[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=_(l)}this.getPrevNode()[i]={type:o,type2:a,flag:s,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class l{parse(t){const e=new u(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new c;for(;!this.endOfContent(e);){const t=this.parseNode(e,n);null!==t&&r.add(t.name,t)}return r}endOfContent(t){return t.size()%16==0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),i=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const o=t.getUint8(),a=t.getString(o);if(0===r)return null;const s=[];for(let e=0;e<i;e++)s.push(this.parseProperty(t));const l=s.length>0?s[0]:"",u=s.length>1?s[1]:"",c=s.length>2?s[2]:"";for(n.singleProperty=1===i&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=s,"number"==typeof l&&(n.id=l),""!==u&&(n.attrName=u),""!==c&&(n.attrType=c),""!==a&&(n.name=a),n}parseSubNode(t,e,n){if(!0===n.singleProperty){const t=n.propertyList[0];Array.isArray(t)?(e[n.name]=n,n.a=t):e[n.name]=t}else if("Connections"===t&&"C"===n.name){const t=[];n.propertyList.forEach((function(e,n){0!==n&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===n.name)Object.keys(n).forEach((function(t){e[t]=n[t]}));else if("Properties70"===t&&"P"===n.name){let t=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],o=n.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],e[t]={type:r,type2:i,flag:o,value:a}}else void 0===e[n.name]?"number"==typeof n.id?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:"PoseNode"===n.name?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):void 0===e[n.name][n.id]&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),i=t.getUint32(),o=t.getUint32();if(0===i)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===X&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=X.unzlibSync(new Uint8Array(t.getArrayBuffer(o))),s=new u(a.buffer);switch(e){case"b":case"c":return s.getBooleanArray(r);case"d":return s.getFloat64Array(r);case"f":return s.getFloat32Array(r);case"i":return s.getInt32Array(r);case"l":return s.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class u{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),2147483648&e?(e=4294967295&~e,4294967295==(t=4294967295&~t)&&(e=e+1&4294967295),-(4294967296*e+(t=t+1&4294967295))):4294967296*e+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),4294967296*e+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let n=0;n<t;n++)e[n]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),r.LoaderUtils.decodeText(new Uint8Array(e))}}class c{add(t,e){this[t]=e}}function h(t){const e=t.match(/FBXVersion: (\d+)/);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function p(t){return t/46186158e3}const f=[];function d(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const o=i*r.dataSize,a=o+r.dataSize;return function(t,e,n,r){for(let i=n,o=0;i<r;i++,o++)t[o]=e[i];return t}(f,r.buffer,o,a)}const m=new r.Euler,g=new r.Vector3;function y(t){const e=new r.Matrix4,n=new r.Matrix4,i=new r.Matrix4,o=new r.Matrix4,a=new r.Matrix4,s=new r.Matrix4,l=new r.Matrix4,u=new r.Matrix4,c=new r.Matrix4,h=new r.Matrix4,p=new r.Matrix4,f=new r.Matrix4,d=t.inheritType?t.inheritType:0;if(t.translation&&e.setPosition(g.fromArray(t.translation)),t.preRotation){const e=t.preRotation.map(r.MathUtils.degToRad);e.push(t.eulerOrder),n.makeRotationFromEuler(m.fromArray(e))}if(t.rotation){const e=t.rotation.map(r.MathUtils.degToRad);e.push(t.eulerOrder),i.makeRotationFromEuler(m.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(r.MathUtils.degToRad);e.push(t.eulerOrder),o.makeRotationFromEuler(m.fromArray(e)),o.invert()}t.scale&&a.scale(g.fromArray(t.scale)),t.scalingOffset&&l.setPosition(g.fromArray(t.scalingOffset)),t.scalingPivot&&s.setPosition(g.fromArray(t.scalingPivot)),t.rotationOffset&&u.setPosition(g.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(g.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(p.copy(t.parentMatrix),h.copy(t.parentMatrixWorld));const y=n.clone().multiply(i).multiply(o),v=new r.Matrix4;v.extractRotation(h);const _=new r.Matrix4;_.copyPosition(h);const x=_.clone().invert().multiply(h),b=v.clone().invert().multiply(x),w=a,E=new r.Matrix4;if(0===d)E.copy(v).multiply(y).multiply(b).multiply(w);else if(1===d)E.copy(v).multiply(b).multiply(y).multiply(w);else{const t=(new r.Matrix4).scale((new r.Vector3).setFromMatrixScale(p)).clone().invert(),e=b.clone().multiply(t);E.copy(v).multiply(y).multiply(e).multiply(w)}const S=c.clone().invert(),M=s.clone().invert();let T=e.clone().multiply(u).multiply(c).multiply(n).multiply(i).multiply(o).multiply(S).multiply(l).multiply(s).multiply(a).multiply(M);const C=(new r.Matrix4).copyPosition(T),I=h.clone().multiply(C);return f.copyPosition(I),(T=f.clone().multiply(E)).premultiply(h.invert()),T}function v(t){const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(t=t||0)?(console.warn("THREE.FBXLoader: unsupported THREE.Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[t]}function _(t){return t.split(",").map((function(t){return parseFloat(t)}))}function x(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=t.byteLength),r.LoaderUtils.decodeText(new Uint8Array(t,e,n))}function b(t,e,n){return t.slice(0,e).concat(n).concat(t.slice(e))}r.FBXLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(this.manager);s.setPath(o.path),s.setResponseType("arraybuffer"),s.setRequestHeader(o.requestHeader),s.setWithCredentials(o.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}parse(e,n){if(function(t){const e="Kaydara FBX Binary \0";return t.byteLength>=e.length&&e===x(t,0,e.length)}(e))t=(new l).parse(e);else{const n=x(e);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(e){const r=t[e-1];return t=t.slice(n+e),n++,r}for(let t=0;t<e.length;++t)if(r(1)===e[t])return!1;return!0}(n))throw new Error("THREE.FBXLoader: Unknown format.");if(h(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+h(n));t=(new s).parse(n)}const o=new r.TextureLoader(this.manager).setPath(this.resourcePath||n).setCrossOrigin(this.crossOrigin);return new i(o,this.manager).parse(t)}}}(),Z=Z=r.FBXLoader;var Y={};!function(){function t(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const e="KHR_binary_glTF",n="KHR_draco_mesh_compression",i="KHR_materials_pbrSpecularGlossiness",o="KHR_materials_unlit",a="KHR_texture_transform",s="KHR_mesh_quantization";class l{constructor(t){this.parser=t,this.name="KHR_lights_punctual",this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const o=e.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[t];let s;const l=new r.Color(16777215);void 0!==a.color&&l.fromArray(a.color);const u=void 0!==a.range?a.range:0;switch(a.type){case"directional":(s=new r.DirectionalLight(l)).target.position.set(0,0,-1),s.add(s.target);break;case"point":(s=new r.PointLight(l)).distance=u;break;case"spot":(s=new r.SpotLight(l)).distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,s.angle=a.spot.outerConeAngle,s.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return s.position.set(0,0,0),s.decay=2,void 0!==a.intensity&&(s.intensity=a.intensity),s.name=e.createUniqueName(a.name||"light_"+t),i=Promise.resolve(s),e.cache.add(n,i),i}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(t){return n._getNodeRef(e.cache,i,t)}))}}class u{constructor(){this.name=o}getMaterialType(){return r.MeshBasicMaterial}extendParams(t,e,n){const i=[];t.color=new r.Color(1,1,1),t.opacity=1;const o=e.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const e=o.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==o.baseColorTexture&&i.push(n.assignTexture(t,"map",o.baseColorTexture))}return Promise.all(i)}}class c{constructor(t){this.parser=t,this.name="KHR_materials_clearcoat"}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?r.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.extensions[this.name];if(void 0!==a.clearcoatFactor&&(e.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&o.push(n.assignTexture(e,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(e.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&o.push(n.assignTexture(e,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(o.push(n.assignTexture(e,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){const t=a.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new r.Vector2(t,-t)}return Promise.all(o)}}class h{constructor(t){this.parser=t,this.name="KHR_materials_transmission"}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?r.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.transmissionFactor&&(e.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&i.push(n.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class p{constructor(t){this.parser=t,this.name="KHR_materials_volume"}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?r.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.extensions[this.name];e.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&o.push(n.assignTexture(e,"thicknessMap",a.thicknessTexture)),e.attenuationDistance=a.attenuationDistance||0;const s=a.attenuationColor||[1,1,1];return e.attenuationTint=new r.Color(s[0],s[1],s[2]),Promise.all(o)}}class f{constructor(t){this.parser=t,this.name="KHR_materials_ior"}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?r.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class d{constructor(t){this.parser=t,this.name="KHR_materials_specular"}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?r.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.extensions[this.name];e.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&o.push(n.assignTexture(e,"specularIntensityMap",a.specularTexture));const s=a.specularColorFactor||[1,1,1];return e.specularTint=new r.Color(s[0],s[1],s[2]),void 0!==a.specularColorTexture&&o.push(n.assignTexture(e,"specularTintMap",a.specularColorTexture).then((function(t){t.encoding=r.sRGBEncoding}))),Promise.all(o)}}class m{constructor(t){this.parser=t,this.name="KHR_texture_basisu"}loadTexture(t){const e=this.parser,n=e.json,r=n.textures[t];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],o=n.images[i.source],a=e.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,o,a)}}class g{constructor(t){this.parser=t,this.name="EXT_texture_webp",this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,i=r.textures[t];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],a=r.images[o.source];let s=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(s=t)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(t,a,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class y{constructor(t){this.name="EXT_meshopt_compression",this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(e){const n=t.byteOffset||0,r=t.byteLength||0,o=t.count,a=t.byteStride,s=new ArrayBuffer(o*a),l=new Uint8Array(e[0],n,r);return i.decodeGltfBuffer(new Uint8Array(s),o,a,l,t.mode,t.filter),s}))}return null}}class v{constructor(t){this.name=e,this.content=null,this.body=null;const n=new DataView(t,0,12);if(this.header={magic:r.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},"glTF"!==this.header.magic)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,o=new DataView(t,12);let a=0;for(;a<i;){const e=o.getUint32(a,!0);a+=4;const n=o.getUint32(a,!0);if(a+=4,1313821514===n){const n=new Uint8Array(t,12+a,e);this.content=r.LoaderUtils.decodeText(n)}else if(5130562===n){const n=12+a;this.body=t.slice(n,n+e)}a+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=n,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,r=this.dracoLoader,i=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},s={},l={};for(const t in o){const e=P[t]||t.toLowerCase();a[e]=o[t]}for(const e in t.attributes){const r=P[e]||e.toLowerCase();if(void 0!==o[e]){const i=n.accessors[t.attributes[e]],o=C[i.componentType];l[r]=o,s[r]=!0===i.normalized}}return e.getDependency("bufferView",i).then((function(t){return new Promise((function(e){r.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=t.attributes[e],r=s[e];void 0!==r&&(n.normalized=r)}e(t)}),a,l)}))}))}}class x{constructor(){this.name=a}extendTexture(t,e){return void 0!==e.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class b extends r.MeshStandardMaterial{constructor(t){super(),this.isGLTFSpecularGlossinessMaterial=!0;const e=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),o=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),a=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),s={specular:{value:(new r.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=s,this.onBeforeCompile=function(t){for(const e in s)t.uniforms[e]=s[e];t.fragmentShader=t.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",e).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",o).replace("#include <lights_physical_fragment>",a)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(t){s.specular.value=t}},specularMap:{get:function(){return s.specularMap.value},set:function(t){s.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(t){s.glossiness.value=t}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(t){s.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class w{constructor(){this.name=i,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return b}extendParams(t,e,n){const i=e.extensions[this.name];t.color=new r.Color(1,1,1),t.opacity=1;const o=[];if(Array.isArray(i.diffuseFactor)){const e=i.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==i.diffuseTexture&&o.push(n.assignTexture(t,"map",i.diffuseTexture)),t.emissive=new r.Color(0,0,0),t.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,t.specular=new r.Color(1,1,1),Array.isArray(i.specularFactor)&&t.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const e=i.specularGlossinessTexture;o.push(n.assignTexture(t,"glossinessMap",e)),o.push(n.assignTexture(t,"specularMap",e))}return Promise.all(o)}createMaterial(t){const e=new b(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=r.TangentSpaceNormalMap,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class E{constructor(){this.name=s}}class S extends r.Interpolant{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r*3+r;for(let t=0;t!==r;t++)e[t]=n[i+t];return e}}S.prototype.beforeStart_=S.prototype.copySampleValue_,S.prototype.afterEnd_=S.prototype.copySampleValue_,S.prototype.interpolate_=function(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,u=r-e,c=(n-e)/u,h=c*c,p=h*c,f=t*l,d=f-l,m=-2*p+3*h,g=p-h,y=1-m,v=g-h+c;for(let t=0;t!==a;t++){const e=o[d+t+a],n=o[d+t+s]*u,r=o[f+t+a],l=o[f+t]*u;i[t]=y*e+v*n+m*r+g*l}return i};const M=new r.Quaternion;class T extends S{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return M.fromArray(i).normalize().toArray(i),i}}const C={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},I={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},A={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},L={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},P={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},D={CUBICSPLINE:void 0,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete};function N(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}function O(t,e,n){for(const r in n.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function k(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function z(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,r=e.weights.length;n<r;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,r=n.length;e<r;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function F(t){const e=t.extensions&&t.extensions[n];return e?"draco:"+e.bufferView+":"+e.indices+":"+B(e.attributes):t.indices+":"+B(t.attributes)+":"+t.mode}function B(t){let e="";const n=Object.keys(t).sort();for(let r=0,i=n.length;r<i;r++)e+=n[r]+":"+t[n[r]]+";";return e}function U(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class V{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new t,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new r.ImageBitmapLoader(this.options.manager):this.textureLoader=new r.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const o={scene:e[0][r.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:r.asset,parser:n,userData:{}};O(i,o,r),k(o,r),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(o)}))).then((function(){t(o)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n].joints;for(let e=0,n=r.length;e<n;e++)t[r[e]].isBone=!0}for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const r=n.clone();return r.name+="_instance_"+t.uses[e]++,r}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const r=t(e[n]);if(r)return r}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let r=0;r<e.length;r++){const i=t(e[r]);i&&n.push(i)}return n}getDependency(t,e){const n=t+":"+e;let r=this.cache.get(n);if(!r){switch(t){case"scene":r=this.loadScene(e);break;case"node":r=this.loadNode(e);break;case"mesh":r=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":r=this.loadAccessor(e);break;case"bufferView":r=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":r=this.loadBuffer(e);break;case"material":r=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":r=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":r=this.loadSkin(e);break;case"animation":r=this.loadAnimation(e);break;case"camera":r=this.loadCamera(e);break;default:throw new Error("Unknown type: "+t)}this.cache.add(n,r)}return r}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,r=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(r.map((function(e,r){return n.getDependency(t,r)}))),this.cache.add(t,e)}return e}loadBuffer(t){const n=this.json.buffers[t],r=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===t)return Promise.resolve(this.extensions[e].body);const i=this.options;return new Promise((function(t,e){r.load(N(n.uri,i.path),t,void 0,(function(){e(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteLength||0,r=e.byteOffset||0;return t.slice(r,r+n)}))}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const o=[];return void 0!==i.bufferView?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),void 0!==i.sparse&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then((function(t){const o=t[0],a=L[i.type],s=C[i.componentType],l=s.BYTES_PER_ELEMENT,u=l*a,c=i.byteOffset||0,h=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,p=!0===i.normalized;let f,d;if(h&&h!==u){const t=Math.floor(c/h),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let u=e.cache.get(n);u||(f=new s(o,t*h,i.count*h/l),u=new r.InterleavedBuffer(f,h/l),e.cache.add(n,u)),d=new r.InterleavedBufferAttribute(u,a,c%h/l,p)}else f=null===o?new s(i.count*a):new s(o,c,i.count*a),d=new r.BufferAttribute(f,a,p);if(void 0!==i.sparse){const e=L.SCALAR,n=C[i.sparse.indices.componentType],l=i.sparse.indices.byteOffset||0,u=i.sparse.values.byteOffset||0,c=new n(t[1],l,i.sparse.count*e),h=new s(t[2],u,i.sparse.count*a);null!==o&&(d=new r.BufferAttribute(d.array.slice(),d.itemSize,d.normalized));for(let t=0,e=c.length;t<e;t++){const e=c[t];if(d.setX(e,h[t*a]),a>=2&&d.setY(e,h[t*a+1]),a>=3&&d.setZ(e,h[t*a+2]),a>=4&&d.setW(e,h[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return d}))}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t],i=e.images[r.source];let o=this.textureLoader;if(i.uri){const t=n.manager.getHandler(i.uri);null!==t&&(o=t)}return this.loadTextureImage(t,i,o)}loadTextureImage(t,e,n){const i=this,o=this.json,a=this.options,s=o.textures[t],l=(e.uri||e.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const u=self.URL||self.webkitURL;let c=e.uri||"",h=!1,p=!0;const f=c.search(/\.jpe?g($|\?)/i)>0||0===c.search(/^data\:image\/jpeg/);if(("image/jpeg"===e.mimeType||f)&&(p=!1),void 0!==e.bufferView)c=i.getDependency("bufferView",e.bufferView).then((function(t){if("image/png"===e.mimeType){const e=new DataView(t,25,1).getUint8(0,!1);p=6===e||4===e||3===e}h=!0;const n=new Blob([t],{type:e.mimeType});return c=u.createObjectURL(n)}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const d=Promise.resolve(c).then((function(t){return new Promise((function(e,i){let o=e;!0===n.isImageBitmapLoader&&(o=function(t){const n=new r.Texture(t);n.needsUpdate=!0,e(n)}),n.load(N(t,a.path),o,void 0,i)}))})).then((function(e){!0===h&&u.revokeObjectURL(c),e.flipY=!1,s.name&&(e.name=s.name),p||(e.format=r.RGBFormat);const n=(o.samplers||{})[s.sampler]||{};return e.magFilter=I[n.magFilter]||r.LinearFilter,e.minFilter=I[n.minFilter]||r.LinearMipmapLinearFilter,e.wrapS=A[n.wrapS]||r.RepeatWrapping,e.wrapT=A[n.wrapT]||r.RepeatWrapping,i.associations.set(e,{type:"textures",index:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",c),null}));return this.textureCache[l]=d,d}assignTexture(t,e,n){const r=this;return this.getDependency("texture",n.index).then((function(i){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===e&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+e+" not yet supported."),r.extensions[a]){const t=void 0!==n.extensions?n.extensions[a]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[a].extendTexture(i,t),r.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0!==e.attributes.tangent,o=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.PointsMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.LineBasicMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(i||o||a){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),i&&(t+="vertex-tangents:"),o&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),o&&(e.vertexColors=!0),a&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,a=this.extensions,s=n.materials[t];let l;const u={},c=s.extensions||{},h=[];if(c[i]){const t=a[i];l=t.getMaterialType(),h.push(t.extendParams(u,s,e))}else if(c[o]){const t=a[o];l=t.getMaterialType(),h.push(t.extendParams(u,s,e))}else{const n=s.pbrMetallicRoughness||{};if(u.color=new r.Color(1,1,1),u.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;u.color.fromArray(t),u.opacity=t[3]}void 0!==n.baseColorTexture&&h.push(e.assignTexture(u,"map",n.baseColorTexture)),u.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,u.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(h.push(e.assignTexture(u,"metalnessMap",n.metallicRoughnessTexture)),h.push(e.assignTexture(u,"roughnessMap",n.metallicRoughnessTexture))),l=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),h.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,u)}))))}!0===s.doubleSided&&(u.side=r.DoubleSide);const p=s.alphaMode||"OPAQUE";return"BLEND"===p?(u.transparent=!0,u.depthWrite=!1):(u.format=r.RGBFormat,u.transparent=!1,"MASK"===p&&(u.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&l!==r.MeshBasicMaterial&&(h.push(e.assignTexture(u,"normalMap",s.normalTexture)),u.normalScale=new r.Vector2(1,-1),void 0!==s.normalTexture.scale&&u.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&l!==r.MeshBasicMaterial&&(h.push(e.assignTexture(u,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(u.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&l!==r.MeshBasicMaterial&&(u.emissive=(new r.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&l!==r.MeshBasicMaterial&&h.push(e.assignTexture(u,"emissiveMap",s.emissiveTexture)),Promise.all(h).then((function(){let n;return n=l===b?a[i].createMaterial(u):new l(u),s.name&&(n.name=s.name),n.map&&(n.map.encoding=r.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=r.sRGBEncoding),k(n,s),e.associations.set(n,{type:"materials",index:t}),s.extensions&&O(a,n,s),n}))}createUniqueName(t){const e=r.PropertyBinding.sanitizeNodeName(t||"");let n=e;for(let t=1;this.nodeNamesUsed[n];++t)n=e+"_"+t;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const e=this,i=this.extensions,o=this.primitiveCache;function a(t){return i[n].decodePrimitive(t,e).then((function(n){return j(n,t,e)}))}const s=[];for(let i=0,l=t.length;i<l;i++){const l=t[i],u=F(l),c=o[u];if(c)s.push(c.promise);else{let t;t=l.extensions&&l.extensions[n]?a(l):j(new r.BufferGeometry,l,e),o[u]={primitive:l,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,o=n.meshes[t],a=o.primitives,s=[];for(let t=0,e=a.length;t<e;t++){const e=void 0===a[t].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new r.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:r.FrontSide})),l.DefaultMaterial):this.getDependency("material",a[t].material);s.push(e)}var l;return s.push(e.loadGeometries(a)),Promise.all(s).then((function(n){const s=n.slice(0,n.length-1),l=n[n.length-1],u=[];for(let n=0,c=l.length;n<c;n++){const c=l[n],h=a[n];let p;const f=s[n];if(4===h.mode||5===h.mode||6===h.mode||void 0===h.mode)!0!==(p=!0===o.isSkinnedMesh?new r.SkinnedMesh(c,f):new r.Mesh(c,f)).isSkinnedMesh||p.geometry.attributes.skinWeight.normalized||p.normalizeSkinWeights(),5===h.mode?p.geometry=H(p.geometry,r.TriangleStripDrawMode):6===h.mode&&(p.geometry=H(p.geometry,r.TriangleFanDrawMode));else if(1===h.mode)p=new r.LineSegments(c,f);else if(3===h.mode)p=new r.Line(c,f);else if(2===h.mode)p=new r.LineLoop(c,f);else{if(0!==h.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);p=new r.Points(c,f)}Object.keys(p.geometry.morphAttributes).length>0&&z(p,o),p.name=e.createUniqueName(o.name||"mesh_"+t),k(p,o),h.extensions&&O(i,p,h),e.assignFinalMaterial(p),u.push(p)}if(1===u.length)return u[0];const c=new r.Group;for(let t=0,e=u.length;t<e;t++)c.add(u[t]);return c}))}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new r.PerspectiveCamera(r.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new r.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),k(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",e.inverseBindMatrices).then((function(t){return n.inverseBindMatrices=t,n}))}loadAnimation(t){const e=this.json.animations[t],n=[],i=[],o=[],a=[],s=[];for(let t=0,r=e.channels.length;t<r;t++){const r=e.channels[t],l=e.samplers[r.sampler],u=r.target,c=void 0!==u.node?u.node:u.id,h=void 0!==e.parameters?e.parameters[l.input]:l.input,p=void 0!==e.parameters?e.parameters[l.output]:l.output;n.push(this.getDependency("node",c)),i.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",p)),a.push(l),s.push(u)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(a),Promise.all(s)]).then((function(n){const i=n[0],o=n[1],a=n[2],s=n[3],l=n[4],u=[];for(let t=0,e=i.length;t<e;t++){const e=i[t],n=o[t],c=a[t],h=s[t],p=l[t];if(void 0===e)continue;let f;switch(e.updateMatrix(),e.matrixAutoUpdate=!0,R[p.path]){case R.weights:f=r.NumberKeyframeTrack;break;case R.rotation:f=r.QuaternionKeyframeTrack;break;default:f=r.VectorKeyframeTrack}const d=e.name?e.name:e.uuid,m=void 0!==h.interpolation?D[h.interpolation]:r.InterpolateLinear,g=[];R[p.path]===R.weights?e.traverse((function(t){!0===t.isMesh&&t.morphTargetInfluences&&g.push(t.name?t.name:t.uuid)})):g.push(d);let y=c.array;if(c.normalized){const t=U(y.constructor),e=new Float32Array(y.length);for(let n=0,r=y.length;n<r;n++)e[n]=y[n]*t;y=e}for(let t=0,e=g.length;t<e;t++){const e=new f(g[t]+"."+R[p.path],n.array,y,m);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof r.QuaternionKeyframeTrack?T:S)(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),u.push(e)}}const c=e.name?e.name:"animation_"+t;return new r.AnimationClip(c,void 0,u)}))}createNodeMesh(t){const e=this.json,n=this,r=e.nodes[t];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(t){const e=n._getNodeRef(n.meshCache,r.mesh,t);return void 0!==r.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,n=r.weights.length;e<n;e++)t.morphTargetInfluences[e]=r.weights[e]})),e}))}loadNode(t){const e=this.json,n=this.extensions,i=this,o=e.nodes[t],a=o.name?i.createUniqueName(o.name):"";return function(){const e=[],n=i._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return n&&e.push(n),void 0!==o.camera&&e.push(i.getDependency("camera",o.camera).then((function(t){return i._getNodeRef(i.cameraCache,o.camera,t)}))),i._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){e.push(t)})),Promise.all(e)}().then((function(e){let s;if((s=!0===o.isBone?new r.Bone:e.length>1?new r.Group:1===e.length?e[0]:new r.Object3D)!==e[0])for(let t=0,n=e.length;t<n;t++)s.add(e[t]);if(o.name&&(s.userData.name=o.name,s.name=a),k(s,o),o.extensions&&O(n,s,o),void 0!==o.matrix){const t=new r.Matrix4;t.fromArray(o.matrix),s.applyMatrix4(t)}else void 0!==o.translation&&s.position.fromArray(o.translation),void 0!==o.rotation&&s.quaternion.fromArray(o.rotation),void 0!==o.scale&&s.scale.fromArray(o.scale);return i.associations.set(s,{type:"nodes",index:t}),s}))}loadScene(t){const e=this.json,n=this.extensions,i=this.json.scenes[t],o=this,a=new r.Group;i.name&&(a.name=o.createUniqueName(i.name)),k(a,i),i.extensions&&O(n,a,i);const s=i.nodes||[],l=[];for(let t=0,n=s.length;t<n;t++)l.push(G(s[t],a,e,o));return Promise.all(l).then((function(){return a}))}}function G(t,e,n,i){const o=n.nodes[t];return i.getDependency("node",t).then((function(t){if(void 0===o.skin)return t;let e;return i.getDependency("skin",o.skin).then((function(t){const n=[];for(let r=0,o=(e=t).joints.length;r<o;r++)n.push(i.getDependency("node",e.joints[r]));return Promise.all(n)})).then((function(n){return t.traverse((function(t){if(!t.isMesh)return;const i=[],o=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];if(a){i.push(a);const n=new r.Matrix4;void 0!==e.inverseBindMatrices&&n.fromArray(e.inverseBindMatrices.array,16*t),o.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}t.bind(new r.Skeleton(i,o),t.matrixWorld)})),t}))})).then((function(t){e.add(t);const r=[];if(o.children){const e=o.children;for(let o=0,a=e.length;o<a;o++){const a=e[o];r.push(G(a,t,n,i))}}return Promise.all(r)}))}function j(t,e,n){const i=e.attributes,o=[];function a(e,r){return n.getDependency("accessor",e).then((function(e){t.setAttribute(r,e)}))}for(const e in i){const n=P[e]||e.toLowerCase();n in t.attributes||o.push(a(i[e],n))}if(void 0!==e.indices&&!t.index){const r=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));o.push(r)}return k(t,e),function(t,e,n){const i=e.attributes,o=new r.Box3;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],e=t.min,a=t.max;if(void 0===e||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new r.Vector3(e[0],e[1],e[2]),new r.Vector3(a[0],a[1],a[2])),t.normalized){const e=U(C[t.componentType]);o.min.multiplyScalar(e),o.max.multiplyScalar(e)}}const a=e.targets;if(void 0!==a){const t=new r.Vector3,e=new r.Vector3;for(let r=0,i=a.length;r<i;r++){const i=a[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],o=r.min,a=r.max;if(void 0!==o&&void 0!==a){if(e.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),r.normalized){const t=U(C[r.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(t)}t.boundingBox=o;const s=new r.Sphere;o.getCenter(s.center),s.radius=o.min.distanceTo(o.max)/2,t.boundingSphere=s}(t,e,n),Promise.all(o).then((function(){return void 0!==e.targets?function(t,e,n){let r=!1,i=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),r&&i)break}if(!r&&!i)return Promise.resolve(t);const o=[],a=[];for(let s=0,l=e.length;s<l;s++){const l=e[s];if(r){const e=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):t.attributes.position;o.push(e)}if(i){const e=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):t.attributes.normal;a.push(e)}}return Promise.all([Promise.all(o),Promise.all(a)]).then((function(e){const n=e[0],o=e[1];return r&&(t.morphAttributes.position=n),i&&(t.morphAttributes.normal=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,n):t}))}function H(t,e){let n=t.getIndex();if(null===n){const e=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<r.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,o=[];if(e===r.TriangleFanDrawMode)for(let t=1;t<=i;t++)o.push(n.getX(0)),o.push(n.getX(t)),o.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(o.push(n.getX(t)),o.push(n.getX(t+1)),o.push(n.getX(t+2))):(o.push(n.getX(t+2)),o.push(n.getX(t+1)),o.push(n.getX(t)));o.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=t.clone();return a.setIndex(o),a}r.GLTFLoader=class extends r.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new c(t)})),this.register((function(t){return new m(t)})),this.register((function(t){return new g(t)})),this.register((function(t){return new h(t)})),this.register((function(t){return new p(t)})),this.register((function(t){return new f(t)})),this.register((function(t){return new d(t)})),this.register((function(t){return new l(t)})),this.register((function(t){return new y(t)}))}load(t,e,n,i){const o=this;let a;a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:r.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const s=function(e){i?i(e):console.error(e),o.manager.itemError(t),o.manager.itemEnd(t)},l=new r.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(t,(function(n){try{o.parse(n,a,(function(n){e(n),o.manager.itemEnd(t)}),s)}catch(t){s(t)}}),n,s)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,l,c,h){let p;const f={},d={};if("string"==typeof t)p=t;else if("glTF"===r.LoaderUtils.decodeText(new Uint8Array(t,0,4))){try{f[e]=new v(t)}catch(t){return void(h&&h(t))}p=f[e].content}else p=r.LoaderUtils.decodeText(new Uint8Array(t));const m=JSON.parse(p);if(void 0===m.asset||m.asset.version[0]<2)return void(h&&h(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const g=new V(m,{path:l||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});g.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](g);d[e.name]=e,f[e.name]=!0}if(m.extensionsUsed)for(let t=0;t<m.extensionsUsed.length;++t){const e=m.extensionsUsed[t],r=m.extensionsRequired||[];switch(e){case o:f[e]=new u;break;case i:f[e]=new w;break;case n:f[e]=new _(m,this.dracoLoader);break;case a:f[e]=new x;break;case s:f[e]=new E;break;default:r.indexOf(e)>=0&&void 0===d[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}g.setExtensions(f),g.setPlugins(d),g.parse(c,h)}}}(),Y=Y=r.GLTFLoader;var J={};r.ColladaLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(o.manager);s.setPath(o.path),s.setRequestHeader(o.requestHeader),s.setWithCredentials(o.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}parse(t,e){function n(t,e){const n=[],r=t.childNodes;for(let t=0,i=r.length;t<i;t++){const i=r[t];i.nodeName===e&&n.push(i)}return n}function i(t){if(0===t.length)return[];const e=t.trim().split(/\s+/),n=new Array(e.length);for(let t=0,r=e.length;t<r;t++)n[t]=e[t];return n}function o(t){if(0===t.length)return[];const e=t.trim().split(/\s+/),n=new Array(e.length);for(let t=0,r=e.length;t<r;t++)n[t]=parseFloat(e[t]);return n}function a(t){if(0===t.length)return[];const e=t.trim().split(/\s+/),n=new Array(e.length);for(let t=0,r=e.length;t<r;t++)n[t]=parseInt(e[t]);return n}function s(t){return t.substring(1)}function l(t){return 0===Object.keys(t).length}function u(t){return void 0!==t&&!0===t.hasAttribute("meter")?parseFloat(t.getAttribute("meter")):1}function c(t){return void 0!==t?t.textContent:"Y_UP"}function h(t,e,r,i){const o=n(t,e)[0];if(void 0!==o){const t=n(o,r);for(let e=0;e<t.length;e++)i(t[e])}}function p(t,e){for(const n in t)t[n].build=e(t[n])}function f(t,e){return void 0!==t.build||(t.build=e(t)),t.build}function d(t){const e={inputs:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const t=s(r.getAttribute("source")),n=r.getAttribute("semantic");e.inputs[n]=t}}return e}function m(t){const e={};let n=t.getAttribute("target").split("/");const r=n.shift();let i=n.shift();const o=-1!==i.indexOf("("),a=-1!==i.indexOf(".");if(a)n=i.split("."),i=n.shift(),e.member=n.shift();else if(o){const t=i.split("(");i=t.shift();for(let e=0;e<t.length;e++)t[e]=parseInt(t[e].replace(/\)/,""));e.indices=t}return e.id=r,e.sid=i,e.arraySyntax=o,e.memberSyntax=a,e.sampler=s(t.getAttribute("source")),e}function g(t){const e=[],n=t.channels,r=t.samplers,i=t.sources;for(const t in n)if(n.hasOwnProperty(t)){const o=n[t],a=r[o.sampler],s=a.inputs.INPUT,l=a.inputs.OUTPUT;w(v(o,i[s],i[l]),e)}return e}function y(t){return f(Yt.animations[t],g)}function v(t,e,n){const r=Yt.nodes[t.id],i=kt(r.id),o=r.transforms[t.sid],a=r.matrix.clone().transpose();let s,l,u,c,h,p;const f={};switch(o){case"matrix":for(u=0,c=e.array.length;u<c;u++)if(s=e.array[u],l=u*n.stride,void 0===f[s]&&(f[s]={}),!0===t.arraySyntax){const e=n.array[l],r=t.indices[0]+4*t.indices[1];f[s][r]=e}else for(h=0,p=n.stride;h<p;h++)f[s][h]=n.array[l+h];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',o)}const d=function(t,e){const n=[];for(const e in t)n.push({time:parseFloat(e),value:t[e]});n.sort((function(t,e){return t.time-e.time}));for(let t=0;t<16;t++)E(n,t,e.elements[t]);return n}(f,a);return{name:i.uuid,keyframes:d}}const _=new r.Vector3,x=new r.Vector3,b=new r.Quaternion;function w(t,e){const n=t.keyframes,i=t.name,o=[],a=[],s=[],l=[];for(let t=0,e=n.length;t<e;t++){const e=n[t],r=e.time,i=e.value;Mt.fromArray(i).transpose(),Mt.decompose(_,b,x),o.push(r),a.push(_.x,_.y,_.z),s.push(b.x,b.y,b.z,b.w),l.push(x.x,x.y,x.z)}return a.length>0&&e.push(new r.VectorKeyframeTrack(i+".position",o,a)),s.length>0&&e.push(new r.QuaternionKeyframeTrack(i+".quaternion",o,s)),l.length>0&&e.push(new r.VectorKeyframeTrack(i+".scale",o,l)),e}function E(t,e,n){let r,i,o,a=!0;for(i=0,o=t.length;i<o;i++)void 0===(r=t[i]).value[e]?r.value[e]=null:a=!1;if(!0===a)for(i=0,o=t.length;i<o;i++)(r=t[i]).value[e]=n;else!function(t,e){let n,r;for(let i=0,o=t.length;i<o;i++){const o=t[i];if(null===o.value[e]){if(n=S(t,i,e),r=M(t,i,e),null===n){o.value[e]=r.value[e];continue}if(null===r){o.value[e]=n.value[e];continue}T(o,n,r,e)}}}(t,e)}function S(t,e,n){for(;e>=0;){const r=t[e];if(null!==r.value[n])return r;e--}return null}function M(t,e,n){for(;e<t.length;){const r=t[e];if(null!==r.value[n])return r;e++}return null}function T(t,e,n,r){n.time-e.time!=0?t.value[r]=(t.time-e.time)*(n.value[r]-e.value[r])/(n.time-e.time)+e.value[r]:t.value[r]=e.value[r]}function C(t){const e=[],n=t.name,i=t.end-t.start||-1,o=t.animations;for(let t=0,n=o.length;t<n;t++){const n=y(o[t]);for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return new r.AnimationClip(n,i,e)}function I(t){return f(Yt.clips[t],C)}function A(t){const e={sources:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":e.bindShapeMatrix=o(r.textContent);break;case"source":const t=r.getAttribute("id");e.sources[t]=ot(r);break;case"joints":e.joints=L(r);break;case"vertex_weights":e.vertexWeights=P(r)}}return e}function L(t){const e={inputs:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const t=r.getAttribute("semantic"),n=s(r.getAttribute("source"));e.inputs[t]=n}}return e}function P(t){const e={inputs:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const t=r.getAttribute("semantic"),n=s(r.getAttribute("source")),i=parseInt(r.getAttribute("offset"));e.inputs[t]={id:n,offset:i};break;case"vcount":e.vcount=a(r.textContent);break;case"v":e.v=a(r.textContent)}}return e}function R(t){const e={id:t.id},n=Yt.geometries[e.id];return void 0!==t.skin&&(e.skin=function(t){const e={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},n=t.sources,i=t.vertexWeights,o=i.vcount,a=i.v,s=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,u=t.sources[t.joints.inputs.JOINT],c=t.sources[t.joints.inputs.INV_BIND_MATRIX],h=n[i.inputs.WEIGHT.id].array;let p,f,d,m=0;for(p=0,d=o.length;p<d;p++){const t=o[p],n=[];for(f=0;f<t;f++){const t=a[m+s],e=h[a[m+l]];n.push({index:t,weight:e}),m+=2}for(n.sort(g),f=0;f<4;f++){const t=n[f];void 0!==t?(e.indices.array.push(t.index),e.weights.array.push(t.weight)):(e.indices.array.push(0),e.weights.array.push(0))}}for(t.bindShapeMatrix?e.bindMatrix=(new r.Matrix4).fromArray(t.bindShapeMatrix).transpose():e.bindMatrix=(new r.Matrix4).identity(),p=0,d=u.array.length;p<d;p++){const t=u.array[p],n=(new r.Matrix4).fromArray(c.array,p*c.stride).transpose();e.joints.push({name:t,boneInverse:n})}return e;function g(t,e){return e.weight-t.weight}}(t.skin),n.sources.skinIndices=e.skin.indices,n.sources.skinWeights=e.skin.weights),e}function D(t){return void 0!==t.build?t.build:t.init_from}function N(t){const e=Yt.images[t];return void 0!==e?f(e,D):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",t),null)}function O(t){const e={surfaces:{},samplers:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"newparam":k(r,e);break;case"technique":e.technique=B(r);break;case"extra":e.extra=q(r)}}return e}function k(t,e){const n=t.getAttribute("sid");for(let r=0,i=t.childNodes.length;r<i;r++){const i=t.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"surface":e.surfaces[n]=z(i);break;case"sampler2D":e.samplers[n]=F(i)}}}function z(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"init_from"===r.nodeName)e.init_from=r.textContent}return e}function F(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"source"===r.nodeName)e.source=r.textContent}return e}function B(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":e.type=r.nodeName,e.parameters=U(r)}}return e}function U(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":e[r.nodeName]=V(r);break;case"transparent":e[r.nodeName]={opaque:r.getAttribute("opaque"),data:V(r)}}}return e}function V(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":e[r.nodeName]=o(r.textContent);break;case"float":e[r.nodeName]=parseFloat(r.textContent);break;case"texture":e[r.nodeName]={id:r.getAttribute("texture"),extra:G(r)}}}return e}function G(t){const e={technique:{}};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"extra"===r.nodeName)j(r,e)}return e}function j(t,e){for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)H(r,e)}}function H(t,e){for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":e.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?e.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?e.technique[r.nodeName]=0:e.technique[r.nodeName]=parseInt(r.textContent)}}}function q(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)e.technique=W(r)}return e}function W(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"double_sided"===r.nodeName)e[r.nodeName]=parseInt(r.textContent)}return e}function X(t){return t}function Z(t){const e=(n=t.url,f(Yt.effects[n],X));var n;const i=e.profile.technique,o=e.profile.extra;let a;switch(i.type){case"phong":case"blinn":a=new r.MeshPhongMaterial;break;case"lambert":a=new r.MeshLambertMaterial;break;default:a=new r.MeshBasicMaterial}function s(t){const n=e.profile.samplers[t.id];let i=null;if(void 0!==n?i=N(e.profile.surfaces[n.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),i=N(t.id)),null!==i){const e=function(t){let e,n=t.slice(2+(t.lastIndexOf(".")-1>>>0));if("tga"===(n=n.toLowerCase()))e=qt;else e=Ht;return e}(i);if(void 0!==e){const n=e.load(i),o=t.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const t=o.technique;n.wrapS=t.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=t.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,n.offset.set(t.offsetU||0,t.offsetV||0),n.repeat.set(t.repeatU||1,t.repeatV||1)}else n.wrapS=r.RepeatWrapping,n.wrapT=r.RepeatWrapping;return n}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}a.name=t.name||"";const u=i.parameters;for(const t in u){const e=u[t];switch(t){case"diffuse":e.color&&a.color.fromArray(e.color),e.texture&&(a.map=s(e.texture));break;case"specular":e.color&&a.specular&&a.specular.fromArray(e.color),e.texture&&(a.specularMap=s(e.texture));break;case"bump":e.texture&&(a.normalMap=s(e.texture));break;case"ambient":e.texture&&(a.lightMap=s(e.texture));break;case"shininess":e.float&&a.shininess&&(a.shininess=e.float);break;case"emission":e.color&&a.emissive&&a.emissive.fromArray(e.color),e.texture&&(a.emissiveMap=s(e.texture))}}let c=u.transparent,h=u.transparency;if(void 0===h&&c&&(h={float:1}),void 0===c&&h&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&h)if(c.data.texture)a.transparent=!0;else{const t=c.data.color;switch(c.opaque){case"A_ONE":a.opacity=t[3]*h.float;break;case"RGB_ZERO":a.opacity=1-t[0]*h.float;break;case"A_ZERO":a.opacity=1-t[3]*h.float;break;case"RGB_ONE":a.opacity=t[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}a.opacity<1&&(a.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(a.side=r.DoubleSide),a}function Y(t){return f(Yt.materials[t],Z)}function J(t){for(let e=0;e<t.childNodes.length;e++){const n=t.childNodes[e];if("technique_common"===n.nodeName)return K(n)}return{}}function K(t){const e={};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];switch(r.nodeName){case"perspective":case"orthographic":e.technique=r.nodeName,e.parameters=Q(r)}}return e}function Q(t){const e={};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];switch(r.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":e[r.nodeName]=parseFloat(r.textContent)}}return e}function $(t){let e;switch(t.optics.technique){case"perspective":e=new r.PerspectiveCamera(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let n=t.optics.parameters.ymag,i=t.optics.parameters.xmag;const o=t.optics.parameters.aspect_ratio;i=void 0===i?n*o:i,n=void 0===n?i/o:n,i*=.5,n*=.5,e=new r.OrthographicCamera(-i,i,n,-n,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:e=new r.PerspectiveCamera}return e.name=t.name||"",e}function tt(t){const e=Yt.cameras[t];return void 0!==e?f(e,$):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",t),null)}function et(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":e.technique=r.nodeName,e.parameters=nt(r)}}return e}function nt(t){const e={};for(let n=0,i=t.childNodes.length;n<i;n++){const i=t.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"color":const t=o(i.textContent);e.color=(new r.Color).fromArray(t);break;case"falloff_angle":e.falloffAngle=parseFloat(i.textContent);break;case"quadratic_attenuation":const n=parseFloat(i.textContent);e.distance=n?Math.sqrt(1/n):0}}return e}function rt(t){let e;switch(t.technique){case"directional":e=new r.DirectionalLight;break;case"point":e=new r.PointLight;break;case"spot":e=new r.SpotLight;break;case"ambient":e=new r.AmbientLight}return t.parameters.color&&e.color.copy(t.parameters.color),t.parameters.distance&&(e.distance=t.parameters.distance),e}function it(t){const e=Yt.lights[t];return void 0!==e?f(e,rt):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",t),null)}function ot(t){const e={array:[],stride:3};for(let r=0;r<t.childNodes.length;r++){const a=t.childNodes[r];if(1===a.nodeType)switch(a.nodeName){case"float_array":e.array=o(a.textContent);break;case"Name_array":e.array=i(a.textContent);break;case"technique_common":const t=n(a,"accessor")[0];void 0!==t&&(e.stride=parseInt(t.getAttribute("stride")))}}return e}function at(t){const e={};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];1===r.nodeType&&(e[r.getAttribute("semantic")]=s(r.getAttribute("source")))}return e}function st(t){const e={type:t.nodeName,material:t.getAttribute("material"),count:parseInt(t.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const t=s(r.getAttribute("source")),n=r.getAttribute("semantic"),i=parseInt(r.getAttribute("offset")),o=parseInt(r.getAttribute("set")),l=o>0?n+o:n;e.inputs[l]={id:t,offset:i},e.stride=Math.max(e.stride,i+1),"TEXCOORD"===n&&(e.hasUV=!0);break;case"vcount":e.vcount=a(r.textContent);break;case"p":e.p=a(r.textContent)}}return e}function lt(t){let e=0;for(let n=0,r=t.length;n<r;n++)!0===t[n].hasUV&&e++;e>0&&e<t.length&&(t.uvsNeedsFix=!0)}function ut(t){const e={},n=t.sources,r=t.vertices,i=t.primitives;if(0===i.length)return{};const o=function(t){const e={};for(let n=0;n<t.length;n++){const r=t[n];void 0===e[r.type]&&(e[r.type]=[]),e[r.type].push(r)}return e}(i);for(const t in o){const i=o[t];lt(i),e[t]=ct(i,n,r)}return e}function ct(t,e,n){const i={},o={array:[],stride:0},a={array:[],stride:0},s={array:[],stride:0},l={array:[],stride:0},u={array:[],stride:0},c=[],h=[],p=new r.BufferGeometry,f=[];let d=0;for(let r=0;r<t.length;r++){const i=t[r],m=i.inputs;let g=0;switch(i.type){case"lines":case"linestrips":g=2*i.count;break;case"triangles":g=3*i.count;break;case"polylist":for(let t=0;t<i.count;t++){const e=i.vcount[t];switch(e){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(e-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",i.type)}p.addGroup(d,g,r),d+=g,i.material&&f.push(i.material);for(const r in m){const p=m[r];switch(r){case"VERTEX":for(const r in n){const f=n[r];switch(r){case"POSITION":const n=o.array.length;if(ht(i,e[f],p.offset,o.array),o.stride=e[f].stride,e.skinWeights&&e.skinIndices&&(ht(i,e.skinIndices,p.offset,c),ht(i,e.skinWeights,p.offset,h)),!1===i.hasUV&&!0===t.uvsNeedsFix){const t=(o.array.length-n)/o.stride;for(let e=0;e<t;e++)s.array.push(0,0)}break;case"NORMAL":ht(i,e[f],p.offset,a.array),a.stride=e[f].stride;break;case"COLOR":ht(i,e[f],p.offset,u.array),u.stride=e[f].stride;break;case"TEXCOORD":ht(i,e[f],p.offset,s.array),s.stride=e[f].stride;break;case"TEXCOORD1":ht(i,e[f],p.offset,l.array),s.stride=e[f].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',r)}}break;case"NORMAL":ht(i,e[p.id],p.offset,a.array),a.stride=e[p.id].stride;break;case"COLOR":ht(i,e[p.id],p.offset,u.array),u.stride=e[p.id].stride;break;case"TEXCOORD":ht(i,e[p.id],p.offset,s.array),s.stride=e[p.id].stride;break;case"TEXCOORD1":ht(i,e[p.id],p.offset,l.array),l.stride=e[p.id].stride}}}return o.array.length>0&&p.setAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),a.array.length>0&&p.setAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),u.array.length>0&&p.setAttribute("color",new r.Float32BufferAttribute(u.array,u.stride)),s.array.length>0&&p.setAttribute("uv",new r.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&p.setAttribute("uv2",new r.Float32BufferAttribute(l.array,l.stride)),c.length>0&&p.setAttribute("skinIndex",new r.Float32BufferAttribute(c,4)),h.length>0&&p.setAttribute("skinWeight",new r.Float32BufferAttribute(h,4)),i.data=p,i.type=t[0].type,i.materialKeys=f,i}function ht(t,e,n,r){const i=t.p,o=t.stride,a=t.vcount;function s(t){let e=i[t+n]*u;const o=e+u;for(;e<o;e++)r.push(l[e])}const l=e.array,u=e.stride;if(void 0!==t.vcount){let t=0;for(let e=0,n=a.length;e<n;e++){const n=a[e];if(4===n){const e=t+1*o,n=t+2*o,r=t+3*o;s(t+0*o),s(e),s(r),s(e),s(n),s(r)}else if(3===n){const e=t+1*o,n=t+2*o;s(t+0*o),s(e),s(n)}else if(n>4)for(let e=1,r=n-2;e<=r;e++){const n=t+o*e,r=t+o*(e+1);s(t+0*o),s(n),s(r)}t+=o*n}}else for(let t=0,e=i.length;t<e;t+=o)s(t)}function pt(t){return f(Yt.geometries[t],ut)}function ft(t){return void 0!==t.build?t.build:t}function dt(t,e){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"joint":e.joints[r.getAttribute("sid")]=mt(r);break;case"link":e.links.push(yt(r))}}}function mt(t){let e;for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"prismatic":case"revolute":e=gt(r)}}return e}function gt(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new r.Vector3,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"axis":const t=o(r.textContent);e.axis.fromArray(t);break;case"limits":const n=r.getElementsByTagName("max")[0],i=r.getElementsByTagName("min")[0];e.limits.max=parseFloat(n.textContent),e.limits.min=parseFloat(i.textContent)}}return e.limits.min>=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function yt(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"attachment_full":e.attachments.push(vt(r));break;case"matrix":case"translate":case"rotate":e.transforms.push(_t(r))}}return e}function vt(t){const e={joint:t.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"link":e.links.push(yt(r));break;case"matrix":case"translate":case"rotate":e.transforms.push(_t(r))}}return e}function _t(t){const e={type:t.nodeName},n=o(t.textContent);switch(e.type){case"matrix":e.obj=new r.Matrix4,e.obj.fromArray(n).transpose();break;case"translate":e.obj=new r.Vector3,e.obj.fromArray(n);break;case"rotate":e.obj=new r.Vector3,e.obj.fromArray(n),e.angle=r.MathUtils.degToRad(n[3])}return e}function xt(t,e){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)bt(r,e)}}function bt(t,e){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"inertia":e.inertia=o(r.textContent);break;case"mass":e.mass=o(r.textContent)[0]}}}function wt(t){const e={target:t.getAttribute("target").split("/").pop()};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType&&"axis"===r.nodeName){const t=r.getElementsByTagName("param")[0];e.axis=t.textContent;const n=e.axis.split("inst_").pop().split("axis")[0];e.jointIndex=n.substr(0,n.length-1)}}return e}function Et(t){return void 0!==t.build?t.build:t}function St(t){const e=[],n=Ut.querySelector('[id="'+t.id+'"]');for(let t=0;t<n.childNodes.length;t++){const i=n.childNodes[t];if(1!==i.nodeType)continue;let a,s;switch(i.nodeName){case"matrix":a=o(i.textContent);const t=(new r.Matrix4).fromArray(a).transpose();e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:t});break;case"translate":case"scale":a=o(i.textContent),s=(new r.Vector3).fromArray(a),e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:s});break;case"rotate":a=o(i.textContent),s=(new r.Vector3).fromArray(a);const n=r.MathUtils.degToRad(a[3]);e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:s,angle:n})}}return e}const Mt=new r.Matrix4,Tt=new r.Vector3;function Ct(t){const e={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new r.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<t.childNodes.length;n++){const i=t.childNodes[n];if(1!==i.nodeType)continue;let a;switch(i.nodeName){case"node":e.nodes.push(i.getAttribute("id")),Ct(i);break;case"instance_camera":e.instanceCameras.push(s(i.getAttribute("url")));break;case"instance_controller":e.instanceControllers.push(It(i));break;case"instance_light":e.instanceLights.push(s(i.getAttribute("url")));break;case"instance_geometry":e.instanceGeometries.push(It(i));break;case"instance_node":e.instanceNodes.push(s(i.getAttribute("url")));break;case"matrix":a=o(i.textContent),e.matrix.multiply(Mt.fromArray(a).transpose()),e.transforms[i.getAttribute("sid")]=i.nodeName;break;case"translate":a=o(i.textContent),Tt.fromArray(a),e.matrix.multiply(Mt.makeTranslation(Tt.x,Tt.y,Tt.z)),e.transforms[i.getAttribute("sid")]=i.nodeName;break;case"rotate":a=o(i.textContent);const t=r.MathUtils.degToRad(a[3]);e.matrix.multiply(Mt.makeRotationAxis(Tt.fromArray(a),t)),e.transforms[i.getAttribute("sid")]=i.nodeName;break;case"scale":a=o(i.textContent),e.matrix.scale(Tt.fromArray(a)),e.transforms[i.getAttribute("sid")]=i.nodeName;break;case"extra":break;default:console.log(i)}}return Ot(e.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",e.id):Yt.nodes[e.id]=e,e}function It(t){const e={id:s(t.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];switch(r.nodeName){case"bind_material":const t=r.getElementsByTagName("instance_material");for(let n=0;n<t.length;n++){const r=t[n],i=r.getAttribute("symbol"),o=r.getAttribute("target");e.materials[i]=s(o)}break;case"skeleton":e.skeletons.push(s(r.textContent))}}return e}function At(t,e){const n=[],i=[];let o,a,s;for(o=0;o<t.length;o++){const r=t[o];let i;if(Ot(r))Lt(i=kt(r),e,n);else if(l=r,void 0!==Yt.visualScenes[l]){const t=Yt.visualScenes[r].children;for(let r=0;r<t.length;r++){const i=t[r];"JOINT"===i.type&&Lt(kt(i.id),e,n)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}var l;for(o=0;o<e.length;o++)for(a=0;a<n.length;a++)if((s=n[a]).bone.name===e[o].name){i[o]=s,s.processed=!0;break}for(o=0;o<n.length;o++)!1===(s=n[o]).processed&&(i.push(s),s.processed=!0);const u=[],c=[];for(o=0;o<i.length;o++)s=i[o],u.push(s.bone),c.push(s.boneInverse);return new r.Skeleton(u,c)}function Lt(t,e,n){t.traverse((function(t){if(!0===t.isBone){let i;for(let n=0;n<e.length;n++){const r=e[n];if(r.name===t.name){i=r.boneInverse;break}}void 0===i&&(i=new r.Matrix4),n.push({bone:t,boneInverse:i,processed:!1})}}))}function Pt(t){const e=[],n=t.matrix,i=t.nodes,o=t.type,a=t.instanceCameras,s=t.instanceControllers,l=t.instanceLights,u=t.instanceGeometries,c=t.instanceNodes;for(let t=0,n=i.length;t<n;t++)e.push(kt(i[t]));for(let t=0,n=a.length;t<n;t++){const n=tt(a[t]);null!==n&&e.push(n.clone())}for(let t=0,n=s.length;t<n;t++){const n=s[t],r=(h=n.id,f(Yt.controllers[h],R)),i=Nt(pt(r.id),n.materials),o=At(n.skeletons,r.skin.joints);for(let t=0,n=i.length;t<n;t++){const n=i[t];n.isSkinnedMesh&&(n.bind(o,r.skin.bindMatrix),n.normalizeSkinWeights()),e.push(n)}}var h;for(let t=0,n=l.length;t<n;t++){const n=it(l[t]);null!==n&&e.push(n.clone())}for(let t=0,n=u.length;t<n;t++){const n=u[t],r=Nt(pt(n.id),n.materials);for(let t=0,n=r.length;t<n;t++)e.push(r[t])}for(let t=0,n=c.length;t<n;t++)e.push(kt(c[t]).clone());let p;if(0===i.length&&1===e.length)p=e[0];else{p="JOINT"===o?new r.Bone:new r.Group;for(let t=0;t<e.length;t++)p.add(e[t])}return p.name="JOINT"===o?t.sid:t.name,p.matrix.copy(n),p.matrix.decompose(p.position,p.quaternion,p.scale),p}const Rt=new r.MeshBasicMaterial({color:16711935});function Dt(t,e){const n=[];for(let r=0,i=t.length;r<i;r++){const i=e[t[r]];void 0===i?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",t[r]),n.push(Rt)):n.push(Y(i))}return n}function Nt(t,e){const n=[];for(const i in t){const o=t[i],a=Dt(o.materialKeys,e);0===a.length&&("lines"===i||"linestrips"===i?a.push(new r.LineBasicMaterial):a.push(new r.MeshPhongMaterial));const s=void 0!==o.data.attributes.skinIndex,l=1===a.length?a[0]:a;let u;switch(i){case"lines":u=new r.LineSegments(o.data,l);break;case"linestrips":u=new r.Line(o.data,l);break;case"triangles":case"polylist":u=s?new r.SkinnedMesh(o.data,l):new r.Mesh(o.data,l)}n.push(u)}return n}function Ot(t){return void 0!==Yt.nodes[t]}function kt(t){return f(Yt.nodes[t],Pt)}function zt(t){const e=new r.Group;e.name=t.name;const n=t.children;for(let t=0;t<n.length;t++){const r=n[t];e.add(kt(r.id))}return e}function Ft(t){return f(Yt.visualScenes[t],zt)}if(0===t.length)return{scene:new r.Scene};const Bt=(new DOMParser).parseFromString(t,"application/xml"),Ut=n(Bt,"COLLADA")[0],Vt=Bt.getElementsByTagName("parsererror")[0];if(void 0!==Vt){const t=n(Vt,"div")[0];let e;return e=t?t.textContent:function(t){let e="";const n=[t];for(;n.length;){const t=n.shift();t.nodeType===Node.TEXT_NODE?e+=t.textContent:(e+="\n",n.push.apply(n,t.childNodes))}return e.trim()}(Vt),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",e),null}const Gt=Ut.getAttribute("version");console.log("THREE.ColladaLoader: File version",Gt);const jt=function(t){return{unit:u(n(t,"unit")[0]),upAxis:c(n(t,"up_axis")[0])}}(n(Ut,"asset")[0]),Ht=new r.TextureLoader(this.manager);let qt;Ht.setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin),r.TGALoader&&(qt=new r.TGALoader(this.manager)).setPath(this.resourcePath||e);const Wt=[];let Xt={},Zt=0;const Yt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};h(Ut,"library_animations","animation",(function t(e){const n={sources:{},samplers:{},channels:{}};let i=!1;for(let r=0,o=e.childNodes.length;r<o;r++){const o=e.childNodes[r];if(1!==o.nodeType)continue;let a;switch(o.nodeName){case"source":a=o.getAttribute("id"),n.sources[a]=ot(o);break;case"sampler":a=o.getAttribute("id"),n.samplers[a]=d(o);break;case"channel":a=o.getAttribute("target"),n.channels[a]=m(o);break;case"animation":t(o),i=!0;break;default:console.log(o)}}!1===i&&(Yt.animations[e.getAttribute("id")||r.MathUtils.generateUUID()]=n)})),h(Ut,"library_animation_clips","animation_clip",(function(t){const e={name:t.getAttribute("id")||"default",start:parseFloat(t.getAttribute("start")||0),end:parseFloat(t.getAttribute("end")||0),animations:[]};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"instance_animation"===r.nodeName)e.animations.push(s(r.getAttribute("url")))}Yt.clips[t.getAttribute("id")]=e})),h(Ut,"library_controllers","controller",(function(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"skin":e.id=s(r.getAttribute("source")),e.skin=A(r);break;case"morph":e.id=s(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Yt.controllers[t.getAttribute("id")]=e})),h(Ut,"library_images","image",(function(t){const e={init_from:n(t,"init_from")[0].textContent};Yt.images[t.getAttribute("id")]=e})),h(Ut,"library_effects","effect",(function(t){const e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"profile_COMMON"===r.nodeName)e.profile=O(r)}Yt.effects[t.getAttribute("id")]=e})),h(Ut,"library_materials","material",(function(t){const e={name:t.getAttribute("name")};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"instance_effect"===r.nodeName)e.url=s(r.getAttribute("url"))}Yt.materials[t.getAttribute("id")]=e})),h(Ut,"library_cameras","camera",(function(t){const e={name:t.getAttribute("name")};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"optics"===r.nodeName)e.optics=J(r)}Yt.cameras[t.getAttribute("id")]=e})),h(Ut,"library_lights","light",(function(t){let e={};for(let n=0,r=t.childNodes.length;n<r;n++){const r=t.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)e=et(r)}Yt.lights[t.getAttribute("id")]=e})),h(Ut,"library_geometries","geometry",(function(t){const e={name:t.getAttribute("name"),sources:{},vertices:{},primitives:[]},r=n(t,"mesh")[0];if(void 0!==r){for(let t=0;t<r.childNodes.length;t++){const n=r.childNodes[t];if(1!==n.nodeType)continue;const i=n.getAttribute("id");switch(n.nodeName){case"source":e.sources[i]=ot(n);break;case"vertices":e.vertices=at(n);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":e.primitives.push(st(n));break;default:console.log(n)}}Yt.geometries[t.getAttribute("id")]=e}})),h(Ut,"library_nodes","node",Ct),h(Ut,"library_visual_scenes","visual_scene",(function(t){const e={name:t.getAttribute("name"),children:[]};!function(t){const e=t.getElementsByTagName("node");for(let t=0;t<e.length;t++){const n=e[t];!1===n.hasAttribute("id")&&n.setAttribute("id","three_default_"+Zt++)}}(t);const r=n(t,"node");for(let t=0;t<r.length;t++)e.children.push(Ct(r[t]));Yt.visualScenes[t.getAttribute("id")]=e})),h(Ut,"library_kinematics_models","kinematics_model",(function(t){const e={name:t.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)dt(r,e)}Yt.kinematicsModels[t.getAttribute("id")]=e})),h(Ut,"library_physics_models","physics_model",(function(t){const e={name:t.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType&&"rigid_body"===r.nodeName)e.rigidBodies[r.getAttribute("name")]={},xt(r,e.rigidBodies[r.getAttribute("name")])}Yt.physicsModels[t.getAttribute("id")]=e})),h(Ut,"scene","instance_kinematics_scene",(function(t){const e={bindJointAxis:[]};for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(1===r.nodeType&&"bind_joint_axis"===r.nodeName)e.bindJointAxis.push(wt(r))}Yt.kinematicsScenes[s(t.getAttribute("url"))]=e})),p(Yt.animations,g),p(Yt.clips,C),p(Yt.controllers,R),p(Yt.images,D),p(Yt.effects,X),p(Yt.materials,Z),p(Yt.cameras,$),p(Yt.lights,rt),p(Yt.geometries,ut),p(Yt.visualScenes,zt),function(){const t=Yt.clips;if(!0===l(t)){if(!1===l(Yt.animations)){const t=[];for(const e in Yt.animations){const n=y(e);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}Wt.push(new r.AnimationClip("default",-1,t))}}else for(const e in t)Wt.push(I(e))}(),function(){const t=Object.keys(Yt.kinematicsModels)[0],e=Object.keys(Yt.kinematicsScenes)[0],n=Object.keys(Yt.visualScenes)[0];if(void 0===t||void 0===e)return;const i=(o=t,f(Yt.kinematicsModels[o],ft));var o;const a=function(t){return f(Yt.kinematicsScenes[t],Et)}(e),s=Ft(n),l=a.bindJointAxis,u={};for(let t=0,e=l.length;t<e;t++){const e=l[t],n=Ut.querySelector('[sid="'+e.target+'"]');if(n){const t=n.parentElement;c(e.jointIndex,t)}}function c(t,e){const n=e.getAttribute("name"),r=i.joints[t];s.traverse((function(i){i.name===n&&(u[t]={object:i,transforms:St(e),joint:r,position:r.zeroPosition})}))}const h=new r.Matrix4;Xt={joints:i&&i.joints,getJointValue:function(t){const e=u[t];if(e)return e.position;console.warn("THREE.ColladaLoader: Joint "+t+" doesn't exist.")},setJointValue:function(t,e){const n=u[t];if(n){const i=n.joint;if(e>i.limits.max||e<i.limits.min)console.warn("THREE.ColladaLoader: Joint "+t+" value "+e+" outside of limits (min: "+i.limits.min+", max: "+i.limits.max+").");else if(i.static)console.warn("THREE.ColladaLoader: Joint "+t+" is static.");else{const o=n.object,a=i.axis,s=n.transforms;Mt.identity();for(let n=0;n<s.length;n++){const o=s[n];if(o.sid&&-1!==o.sid.indexOf(t))switch(i.type){case"revolute":Mt.multiply(h.makeRotationAxis(a,r.MathUtils.degToRad(e)));break;case"prismatic":Mt.multiply(h.makeTranslation(a.x*e,a.y*e,a.z*e));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+i.type)}else switch(o.type){case"matrix":Mt.multiply(o.obj);break;case"translate":Mt.multiply(h.makeTranslation(o.obj.x,o.obj.y,o.obj.z));break;case"scale":Mt.scale(o.obj);break;case"rotate":Mt.multiply(h.makeRotationAxis(o.obj,o.angle))}}o.matrix.copy(Mt),o.matrix.decompose(o.position,o.quaternion,o.scale),u[t].position=e}}else console.log("THREE.ColladaLoader: "+t+" does not exist.")}}}();const Jt=function(t){return Ft(s(n(t,"instance_visual_scene")[0].getAttribute("url")))}(n(Ut,"scene")[0]);return Jt.animations=Wt,"Z_UP"===jt.upAxis&&Jt.quaternion.setFromEuler(new r.Euler(-Math.PI/2,0,0)),Jt.scale.multiplyScalar(jt.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Wt},kinematics:Xt,library:Yt,scene:Jt}}},J=J=r.ColladaLoader;var K={};const Q=new L,$=new P,tt=new Y,et=new Z,nt=new J;K=K=function(t,e,n){if(void 0===t)return console.error("Invalid options provided to loadObj()");let r;switch((t=c._validate(t,b.prototype._defaults.loadObj)).type||(t.type="mtl"),t.type){case"mtl":r=Q;break;case"gltf":case"glb":r=tt;break;case"fbx":r=et;break;case"dae":r=nt}$.load(t.mtl,(function(i){i&&"mtl"==t.type&&(i.preload(),r.setMaterials(i)),r.load(t.obj,(r=>{let i=[];switch(t.type){case"mtl":r=r.children[0];break;case"gltf":case"glb":case"dae":i=r.animations,r=r.scene;break;case"fbx":i=r.animations}r.animations=i;const o=c.types.rotation(t.rotation,[0,0,0]),a=c.types.scale(t.scale,[1,1,1]);r.rotation.set(o[0],o[1],o[2]),r.scale.set(a[0],a[1],a[2]),t.normalize&&r.traverse((function(t){if(t.isMesh){let e;"MeshStandardMaterial"==t.material.type?(t.material.metalness&&(t.material.metalness*=.1),t.material.glossiness&&(t.material.glossiness*=.25),e=new THREE.Color(12,12,12)):"MeshPhongMaterial"==t.material.type&&(t.material.shininess=.1,e=new THREE.Color(20,20,20)),t.material.specular&&t.material.specular.isColor&&(t.material.specular=e)}})),r.name="model";let s=b.prototype._makeGroup(r,t);b.prototype._addMethods(s),s.setAnchor(t.anchor),s.setCenter(t.adjustment),s.raycasted=t.raycasted,n(s),e(s),s.setFixedZoom(t.mapScale),s.idle()}),(()=>null),(e=>{console.error("Could not load model file: "+t.obj+" \n "+e.stack),n("Error loading the model")}))}),(()=>null),(t=>{console.warn("No material file found "+t.stack)}))};var rt={};function it(t){t=c._validate(t,b.prototype._defaults.line);var e=c.lnglatsToWorld(t.geometry),n=c.normalizeVertices(e),i=c.flattenVectors(n.vertices),o=new r.LineGeometry;o.setPositions(i);let a=new r.LineMaterial({color:t.color,linewidth:t.width,dashed:!1,opacity:t.opacity});return a.resolution.set(window.innerWidth,window.innerHeight),a.isMaterial=!0,a.transparent=!0,a.depthWrite=!1,(it=new r.Line2(o,a)).position.copy(n.position),it.computeLineDistances(),it}rt=rt=it,function(){const t=new r.Box3,e=new r.Vector3;class n extends r.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new r.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new r.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new r.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new r.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new r.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new r.Box3);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;void 0!==e&&void 0!==n&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(n),this.boundingBox.union(t))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new r.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==t&&void 0!==n){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let o=0,a=t.count;o<a;o++)e.fromBufferAttribute(t,o),i=Math.max(i,r.distanceToSquared(e)),e.fromBufferAttribute(n,o),i=Math.max(i,r.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}n.prototype.isLineSegmentsGeometry=!0,r.LineSegmentsGeometry=n}(),function(){class t extends r.LineSegmentsGeometry{constructor(){super(),this.type="LineGeometry"}setPositions(t){for(var e=t.length-3,n=new Float32Array(2*e),r=0;r<e;r+=3)n[2*r]=t[r],n[2*r+1]=t[r+1],n[2*r+2]=t[r+2],n[2*r+3]=t[r+3],n[2*r+4]=t[r+4],n[2*r+5]=t[r+5];return super.setPositions(n),this}setColors(t){for(var e=t.length-3,n=new Float32Array(2*e),r=0;r<e;r+=3)n[2*r]=t[r],n[2*r+1]=t[r+1],n[2*r+2]=t[r+2],n[2*r+3]=t[r+3],n[2*r+4]=t[r+4],n[2*r+5]=t[r+5];return super.setColors(n),this}fromLine(t){var e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}}t.prototype.isLineGeometry=!0,r.LineGeometry=t}(),function(){class t extends r.LineSegmentsGeometry{constructor(t){super(),this.type="WireframeGeometry2",this.fromWireframeGeometry(new r.WireframeGeometry(t))}}t.prototype.isWireframeGeometry2=!0,r.WireframeGeometry2=t}(),function(){r.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new r.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},r.ShaderLib.line={uniforms:r.UniformsUtils.merge([r.UniformsLib.common,r.UniformsLib.fog,r.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\tworldStart = start.xyz;\n\t\t\tworldEnd = end.xyz;\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segements overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class t extends r.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:r.UniformsUtils.clone(r.ShaderLib.line.uniforms),vertexShader:r.ShaderLib.line.vertexShader,fragmentShader:r.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}t.prototype.isLineMaterial=!0,r.LineMaterial=t}(),function(){const t=new r.Vector3,e=new r.Vector3,n=new r.Vector4,i=new r.Vector4,o=new r.Vector4,a=new r.Vector3,s=new r.Matrix4,l=new r.Line3,u=new r.Vector3,c=new r.Box3,h=new r.Sphere,p=new r.Vector4;class f extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;n<s;n++,r+=2)t.fromBufferAttribute(i,n),e.fromBufferAttribute(o,n),a[r]=0===r?0:a[r-1],a[r+1]=a[r]+t.distanceTo(e);const s=new r.InstancedInterleavedBuffer(a,2,1);return n.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(s,1,0)),n.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(s,1,1)),this}raycast(t,e){null===t.camera&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');const f=void 0!==t.params.Line2&&t.params.Line2.threshold||0,d=t.ray,m=t.camera,g=m.projectionMatrix,y=this.matrixWorld,v=this.geometry,_=this.material,x=_.resolution,b=_.linewidth+f,w=v.attributes.instanceStart,E=v.attributes.instanceEnd,S=-m.near,M=2*Math.max(b/x.width,b/x.height);null===v.boundingSphere&&v.computeBoundingSphere(),h.copy(v.boundingSphere).applyMatrix4(y);const T=Math.max(m.near,h.distanceToPoint(d.origin));p.set(0,0,-T,1).applyMatrix4(m.projectionMatrix),p.multiplyScalar(1/p.w),p.applyMatrix4(m.projectionMatrixInverse);const C=.5*Math.abs(M/p.w);if(h.radius+=C,!1===t.ray.intersectsSphere(h))return;null===v.boundingBox&&v.computeBoundingBox(),c.copy(v.boundingBox).applyMatrix4(y);const I=Math.max(m.near,c.distanceToPoint(d.origin));p.set(0,0,-I,1).applyMatrix4(m.projectionMatrix),p.multiplyScalar(1/p.w),p.applyMatrix4(m.projectionMatrixInverse);const A=.5*Math.abs(M/p.w);if(c.max.x+=A,c.max.y+=A,c.max.z+=A,c.min.x-=A,c.min.y-=A,c.min.z-=A,!1!==t.ray.intersectsBox(c)){d.at(1,o),o.w=1,o.applyMatrix4(m.matrixWorldInverse),o.applyMatrix4(g),o.multiplyScalar(1/o.w),o.x*=x.x/2,o.y*=x.y/2,o.z=0,a.copy(o),s.multiplyMatrices(m.matrixWorldInverse,y);for(let t=0,o=w.count;t<o;t++){if(n.fromBufferAttribute(w,t),i.fromBufferAttribute(E,t),n.w=1,i.w=1,n.applyMatrix4(s),i.applyMatrix4(s),n.z>S&&i.z>S)continue;if(n.z>S){const t=n.z-i.z,e=(n.z-S)/t;n.lerp(i,e)}else if(i.z>S){const t=i.z-n.z,e=(i.z-S)/t;i.lerp(n,e)}n.applyMatrix4(g),i.applyMatrix4(g),n.multiplyScalar(1/n.w),i.multiplyScalar(1/i.w),n.x*=x.x/2,n.y*=x.y/2,i.x*=x.x/2,i.y*=x.y/2,l.start.copy(n),l.start.z=0,l.end.copy(i),l.end.z=0;const o=l.closestPointToPointParameter(a,!0);l.at(o,u);const c=r.MathUtils.lerp(n.z,i.z,o),h=c>=-1&&c<=1,p=a.distanceTo(u)<.5*b;if(h&&p){l.start.fromBufferAttribute(w,t),l.end.fromBufferAttribute(E,t),l.start.applyMatrix4(y),l.end.applyMatrix4(y);const n=new r.Vector3,i=new r.Vector3;d.distanceSqToSegment(l.start,l.end,i,n),e.push({point:i,pointOnLine:n,distance:d.origin.distanceTo(i),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}f.prototype.LineSegments2=!0,r.LineSegments2=f}(),function(){class t extends r.LineSegments2{constructor(t=new r.LineGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Line2"}}t.prototype.isLine2=!0,r.Line2=t}(),function(){const t=new r.Vector3,e=new r.Vector3;class n extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Wireframe"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;n<s;n++,r+=2)t.fromBufferAttribute(i,n),e.fromBufferAttribute(o,n),a[r]=0===r?0:a[r-1],a[r+1]=a[r]+t.distanceTo(e);const s=new r.InstancedInterleavedBuffer(a,2,1);return n.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(s,1,0)),n.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(s,1,1)),this}}n.prototype.isWireframe=!0,r.Wireframe=n}();var ot={};ot=ot=function(t,e){t=c._validate(t,b.prototype._defaults.tube);let n=[];t.geometry.forEach((t=>{n.push(new r.Vector3(t[0],t[1],t[2]))}));const i=new r.CatmullRomCurve3(n);let o=new r.TubeGeometry(i,n.length,t.radius,t.sides,!1),a=m(t),s=new r.Mesh(o,a);return new S({obj:s,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var at={};at=at=function(t){this.map=t,this.renderer=new x.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(t,e){this.renderer.setSize(t,e)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(t,e){return this.scene=t,this.camera=e,new Promise((n=>{n(this.renderer.render(t,e))}))},this.toggleLabels=async function(t,e){return new Promise((n=>{n(this.setVisibility(t,e,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(t,e,n,r,i){this.renderer.cacheList.forEach((function(o){o.visible!=e&&o.layer===t&&(e&&o.alwaysVisible||!e)&&(o.visible=e,i.renderObject(o,n,r))}))}};var st={};st=st=class{constructor(t,e){this.id=t.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=t.buildingsLayerId,this.minAltitude=t.minAltitude||.1,this.tb=e}onAdd(t,e){this.map=t;const n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),e.compileShader(n);const r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),e.compileShader(r),this.program=e.createProgram(),e.attachShader(this.program,n),e.attachShader(this.program,r),e.linkProgram(this.program),e.validateProgram(this.program),this.uMatrix=e.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=e.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=e.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=e.getUniformLocation(this.program,"u_azimuth"),this.aPos=e.getAttribLocation(this.program,"a_pos"),this.aNormal=e.getAttribLocation(this.program,"a_normal_ed"),this.aBase=e.getAttribLocation(this.program,"a_base"),this.aHeight=e.getAttribLocation(this.program,"a_height")}render(t,e){t.useProgram(this.program);const n=this.map.style.sourceCaches.composite,r=n.getVisibleCoordinates().reverse(),i=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:a,lat:s}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[a,s]);t.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),t.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.getExtension("EXT_blend_minmax"),t.disable(t.DEPTH_TEST);for(const e of r){const r=n.getTile(e),a=r.getBucket(i);if(!a)continue;const[s,l]=a.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;t.uniformMatrix4fv(this.uMatrix,!1,e.posMatrix),t.uniform1f(this.uHeightFactor,Math.pow(2,e.overscaledZ)/r.tileSize/8);for(const e of a.segments.get()){const n=o.currentNumAttributes||0,r=2;for(let e=r;e<n;e++)t.disableVertexAttribArray(e);const i=e.vertexOffset||0;t.enableVertexAttribArray(this.aPos),t.enableVertexAttribArray(this.aNormal),t.enableVertexAttribArray(this.aHeight),t.enableVertexAttribArray(this.aBase),a.layoutVertexBuffer.bind(),t.vertexAttribPointer(this.aPos,2,t.SHORT,!1,12,12*i),t.vertexAttribPointer(this.aNormal,4,t.SHORT,!1,12,4+12*i),s.bind(),t.vertexAttribPointer(this.aHeight,1,t.FLOAT,!1,4,4*i),l.bind(),t.vertexAttribPointer(this.aBase,1,t.FLOAT,!1,4,4*i),a.indexBuffer.bind(),o.currentNumAttributes=r,t.drawElements(t.TRIANGLES,3*e.primitiveLength,t.UNSIGNED_SHORT,3*e.primitiveOffset*2)}}}};var lt={};function ut(t,e,n){this.init(t,e,n)}ut.prototype={repaint:function(){this.map.repaint=!0},init:function(t,e,n){this.options=c._validate(n||{},ct),this.map=t,this.map.tb=this,this.objects=new b,this.mapboxVersion=parseFloat(this.map.version),this.renderer=new r.WebGLRenderer({alpha:!0,antialias:!0,preserveDrawingBuffer:n.preserveDrawingBuffer,canvas:t.getCanvas(),context:e}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.outputEncoding=r.sRGBEncoding,this.renderer.autoClear=!1,this.labelRenderer=new at(this.map),this.scene=new r.Scene,this.world=new r.Group,this.world.name="world",this.scene.add(this.world),this.objectsCache=new Map,this.zoomLayers=[],this.fov=this.options.fov,this.orthographic=this.options.orthographic||!1,this.raycaster=new r.Raycaster,this.raycaster.layers.set(0),this.mapCenter=this.map.getCenter(),this.mapCenterUnits=c.projectToWorld([this.mapCenter.lng,this.mapCenter.lat]),this.lightDateTime=new Date,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition,this.rotationStep=5,this.gridStep=6,this.altitudeStep=.1,this.defaultCursor="default",this.lights=this.initLights,this.options.defaultLights&&this.defaultLights(),this.options.realSunlight&&this.realSunlight(this.options.realSunlightHelper),this.skyLayerName="sky-layer",this.terrainSourceName="mapbox-dem",this.terrainExaggeration=1,this.terrainLayerName="",this.enableSelectingFeatures=this.options.enableSelectingFeatures||!1,this.enableSelectingObjects=this.options.enableSelectingObjects||!1,this.enableDraggingObjects=this.options.enableDraggingObjects||!1,this.enableRotatingObjects=this.options.enableRotatingObjects||!1,this.enableTooltips=this.options.enableTooltips||!1,this.multiLayer=this.options.multiLayer||!1,this.map.on("style.load",(function(){this.tb.zoomLayers=[],this.tb.options.multiLayer&&this.addLayer({id:"threebox_layer",type:"custom",renderingMode:"3d",map:this,onAdd:function(t,e){},render:function(t,e){this.map.tb.update()}}),this.once("idle",(()=>{this.tb.setObjectsScale()})),this.tb.options.sky&&(this.tb.sky=!0),this.tb.options.terrain&&(this.tb.terrain=!0),["satellite","mapbox-mapbox-satellite","satelliteLayer"].forEach((t=>{this.getLayer(t)&&(this.tb.terrainLayerName=t)}))})),this.map.on("load",(function(){let e;this.selectedObject,this.selectedFeature,this.draggedObject,this.overedObject,this.overedFeature;let n,r=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let i,o,a,s,l=[];function u(t){var e=r.getBoundingClientRect();return{x:t.originalEvent.clientX-e.left-r.clientLeft,y:t.originalEvent.clientY-e.top-r.clientTop}}this.unselectObject=function(){this.selectedObject.selected=!1,this.selectedObject=null},this.outObject=function(){this.overedObject.over=!1,this.overedObject=null},this.unselectFeature=function(t){void 0!==t.id&&(this.setFeatureState({source:t.source,sourceLayer:t.sourceLayer,id:t.id},{select:!1}),this.removeTooltip(t),(t=this.queryRenderedFeatures({layers:[t.layer.id],filter:["==",["id"],t.id]})[0])&&this.fire("SelectedFeatureChange",{detail:t}),this.selectedFeature=null)},this.selectFeature=function(t){this.selectedFeature=t,this.setFeatureState({source:this.selectedFeature.source,sourceLayer:this.selectedFeature.sourceLayer,id:this.selectedFeature.id},{select:!0}),this.selectedFeature=this.queryRenderedFeatures({layers:[this.selectedFeature.layer.id],filter:["==",["id"],this.selectedFeature.id]})[0],this.addTooltip(this.selectedFeature),this.fire("SelectedFeatureChange",{detail:this.selectedFeature})},this.outFeature=function(e){this.overedFeature&&void 0!==this.overedFeature&&this.overedFeature.id!=e&&(t.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!1}),this.removeTooltip(this.overedFeature),this.overedFeature=null)},this.addTooltip=function(t){if(!this.tb.enableTooltips)return;let e=this.tb.getFeatureCenter(t),n=this.tb.tooltip({text:t.properties.name||t.id||t.type,mapboxStyle:!0,feature:t});n.setCoords(e),this.tb.add(n,t.layer.id),t.tooltip=n,t.tooltip.tooltip.visible=!0},this.removeTooltip=function(t){t.tooltip&&(t.tooltip.visibility=!1,this.tb.remove(t.tooltip),t.tooltip=null)},t.onContextMenu=function(t){alert("contextMenu")},this.onClick=function(e){let n,r=[];if(t.tb.enableSelectingObjects&&(r=this.tb.queryRenderedFeatures(e.point)),n="object"==typeof r[0]){let t=ut.prototype.findParent3DObject(r[0]);if(t){if(this.selectedFeature&&this.unselectFeature(this.selectedFeature),this.selectedObject){if(this.selectedObject.uuid!=t.uuid)this.selectedObject.selected=!1,t.selected=!0,this.selectedObject=t;else if(this.selectedObject.uuid==t.uuid)return void this.unselectObject()}else this.selectedObject=t,this.selectedObject.selected=!0;this.selectedObject.dispatchEvent({type:"Wireframed",detail:this.selectedObject}),this.selectedObject.dispatchEvent({type:"IsPlayingChanged",detail:this.selectedObject}),this.repaint=!0,e.preventDefault()}}else{let n=[];if(t.tb.enableSelectingFeatures&&(n=this.queryRenderedFeatures(e.point)),n.length>0&&"fill-extrusion"==n[0].layer.type&&void 0!==n[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=n[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(n[0]);else if(this.selectedFeature.id==n[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(n[0])}},this.onMouseMove=function(r){let l,c=u(r);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,r.originalEvent.altKey&&this.draggedObject){if(!t.tb.enableRotatingObjects)return;e="rotate",this.getCanvasContainer().style.cursor="move",Math.min(n.x,c.x),Math.max(n.x,c.x),Math.min(n.y,c.y),Math.max(n.y,c.y);let r={x:0,y:0,z:Math.round(s[2]+~~((c.x-n.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(r),void this.draggedObject.addHelp("rot: "+r.z+"&#176;")}if(r.originalEvent.shiftKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="translate",this.getCanvasContainer().style.cursor="move";let n=r.lngLat,a=[Number((n.lng+i).toFixed(this.tb.gridStep)),Number((n.lat+o).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(a),void this.draggedObject.addHelp("lng: "+a[0]+"&#176;, lat: "+a[1]+"&#176;")}if(r.originalEvent.ctrlKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="altitude",this.getCanvasContainer().style.cursor="move";let n=r.point.y*this.tb.altitudeStep,i=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-n-a).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(i),void this.draggedObject.addHelp("alt: "+i[2]+"m")}let h=[];if(t.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(r.point)),l="object"==typeof h[0]){let t=ut.prototype.findParent3DObject(h[0]);t&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&t.uuid==this.selectedObject.uuid?this.selectedObject&&t.uuid==this.selectedObject.uuid&&(t.over=!0,this.overedObject=t):(this.overedObject&&this.overedObject.uuid!=t.uuid&&this.outObject(),t.over=!0,this.overedObject=t),this.repaint=!0,r.preventDefault())}else{this.overedObject&&this.outObject();let e=[];t.tb.enableSelectingFeatures&&(e=this.queryRenderedFeatures(r.point)),e.length>0&&(this.outFeature(e[0]),"fill-extrusion"==e[0].layer.type&&void 0!==e[0].id&&(this.selectedFeature&&this.selectedFeature.id==e[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=e[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=t.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(e){(e.originalEvent.shiftKey||e.originalEvent.altKey||e.originalEvent.ctrlKey)&&0===e.originalEvent.button&&this.selectedObject&&(t.tb.enableDraggingObjects||t.tb.enableRotatingObjects)&&(e.preventDefault(),t.getCanvasContainer().style.cursor="move",t.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,n=u(e),l=this.draggedObject.coordinates,s=c.degreeify(this.draggedObject.rotation),i=l[0]-e.lngLat.lng,o=l[1]-e.lngLat.lat,a=-this.draggedObject.modelHeight-e.point.y*this.tb.altitudeStep)},this.onMouseUp=function(t){this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:e}}),this.draggedObject.removeHelp(),this.draggedObject=null,e=null)},this.onMouseOut=function(t){if(this.overedFeature){let e=this.queryRenderedFeatures(t.point);e.length>0&&this.overedFeature.id!=e[0].id&&(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.outFeature(e[0]))}},this.onZoom=function(t){this.tb.zoomLayers.forEach((t=>{this.tb.toggleLayer(t)})),this.tb.setObjectsScale()};let h=!1,p=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),this.on("zoomend",this.onZoom),document.addEventListener("keydown",function(t){17!==t.which&&91!==t.which||(h=!0),16===t.which&&(p=!0);let e=this.selectedObject;if(p&&83===t.which&&e){let t=c.toDecimal;if(e.help)e.removeHelp();else{let n=e.modelSize,r=1;"meters"!==e.userData.units&&((r=c.projectedUnitsPerMeter(e.coordinates[1]))||(r=1),r=t(r,7)),e.addHelp("size(m): "+t(n.x/r,3)+" W, "+t(n.y/r,3)+" L, "+t(n.z/r,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(t){17!=t.which&&91!=t.which||(h=!1),16===t.which&&(p=!1)}.bind(this))}))},get sky(){return this.options.sky},set sky(t){t?this.createSkyLayer():this.removeLayer(this.skyLayerName),this.options.sky=t},get terrain(){return this.options.terrain},set terrain(t){if(this.terrainLayerName="",t)this.createTerrainLayer();else{if(this.mapboxVersion<2)return void console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0");this.map.getTerrain()&&(this.map.setTerrain(null),this.map.removeSource(this.terrainSourceName))}this.options.terrain=t},get fov(){return this.options.fov},set fov(t){this.camera instanceof r.PerspectiveCamera&&this.options.fov!==t&&(this.map.transform.fov=t,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=t)},get orthographic(){return this.options.orthographic},set orthographic(t){const e=this.map.getCanvas().clientHeight,n=this.map.getCanvas().clientWidth;t?(this.map.transform.fov=0,this.camera=new r.OrthographicCamera(n/-2,n/2,e/2,e/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new r.PerspectiveCamera(this.map.transform.fov,n/e,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new p(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=t},createSkyLayer:function(){if(this.mapboxVersion<2)return console.warn("Sky layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.sky=!1);this.map.getLayer(this.skyLayerName)||(this.map.addLayer({id:this.skyLayerName,type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-sun":this.getSunSky(this.lightDateTime),"sky-atmosphere-sun-intensity":10}}),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()})))},createTerrainLayer:function(){if(this.mapboxVersion<2)return console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.terrain=!1);this.map.getTerrain()||(this.map.addSource(this.terrainSourceName,{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14}),this.map.setTerrain({source:this.terrainSourceName,exaggeration:this.terrainExaggeration}),this.map.once("idle",(()=>{this.cameraSync.updateCamera(),this.repaint()})))},sphere:function(t){return this.setDefaultView(t,this.options),M(t,this.world)},line:rt,label:I,tooltip:A,tube:function(t){return this.setDefaultView(t,this.options),ot(t,this.world)},extrusion:function(t){return this.setDefaultView(t,this.options),T(t)},Object3D:function(t){return this.setDefaultView(t,this.options),S(t)},loadObj:async function(t,e){if(this.setDefaultView(t,this.options),!1===t.clone)return new Promise((async n=>{K(t,e,(async t=>{n(t)}))}));{let n=this.objectsCache.get(t.obj);n?n.promise.then((n=>{e(n.duplicate(t))})).catch((e=>{this.objectsCache.delete(t.obj),console.error("Could not load model file: "+t.obj)})):this.objectsCache.set(t.obj,{promise:new Promise((async(n,r)=>{K(t,e,(async t=>{t.duplicate?n(t.duplicate()):r(t)}))}))})}},material:function(t){return m(t)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:c,SunCalc:d,Constants:i,projectToWorld:function(t){return this.utils.projectToWorld(t)},unprojectFromWorld:function(t){return this.utils.unprojectFromWorld(t)},projectedUnitsPerMeter:function(t){return this.utils.projectedUnitsPerMeter(t)},getFeatureCenter:function(t,e,n){return c.getFeatureCenter(t,e,n)},getObjectHeightOnFloor:function(t,e,n){return c.getObjectHeightOnFloor(t,e,n)},queryRenderedFeatures:function(t){let e=new r.Vector2;return e.x=t.x/this.map.transform.width*2-1,e.y=1-t.y/this.map.transform.height*2,this.raycaster.setFromCamera(e,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(t){var e;return t.object.traverseAncestors((function(t){t.parent&&"Group"==t.parent.type&&t.userData.obj&&(e=t)})),e},setLayoutProperty:function(t,e,n){this.map.setLayoutProperty(t,e,n),null!=n&&"visibility"===e&&this.world.children.filter((e=>e.layer===t)).forEach((t=>{t.visibility=n}))},setLayerZoomRange:function(t,e,n){this.map.getLayer(t)&&(this.map.setLayerZoomRange(t,e,n),this.zoomLayers.includes(t)||this.zoomLayers.push(t),this.toggleLayer(t))},setLayerHeigthProperty:function(t,e){let n=this.map.getLayer(t);if(n)if("fill-extrusion"==n.type){let t=this.map.getStyle().sources[n.source].data;t.features.forEach((function(t){t.properties.level=e})),this.map.getSource(n.source).setData(t)}else"custom"==n.type&&this.world.children.forEach((function(n){let r=n.userData.feature;if(r&&r.layer===t){let t=this.tb.getFeatureCenter(r,n,e);n.setCoords(t)}}))},setObjectsScale:function(){this.world.children.filter((t=>null!=t.fixedZoom)).forEach((t=>{t.setObjectScale(this.map.transform.scale)}))},setStyle:function(t,e){this.clear().then((()=>{this.map.setStyle(t,e)}))},toggleLayer:function(t,e=!0){let n=this.map.getLayer(t);if(n){if(!e)return void this.toggle(n.id,!1);let t=this.map.getZoom();if(n.minzoom&&t<n.minzoom)return void this.toggle(n.id,!1);if(n.maxzoom&&t>=n.maxzoom)return void this.toggle(n.id,!1);this.toggle(n.id,!0)}},toggle:function(t,e){this.setLayoutProperty(t,"visibility",e?"visible":"none"),this.labelRenderer.toggleLabels(t,e)},update:function(){this.map.repaint&&(this.map.repaint=!1);var t=Date.now();this.objects.animationManager.update(t),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(t,e,n){if(!this.enableTooltips&&t.tooltip&&(t.tooltip.visibility=!1),this.world.add(t),e){t.layer=e,t.source=n;let r=this.map.getLayer(e);if(r){let e=r.visibility,n=void 0===e;t.visibility=!(!n&&"visible"!==e)}}},removeByName:function(t){let e=this.world.getObjectByName(t);e&&this.remove(e)},remove:function(t){this.map.selectedObject&&t.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&t.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),t.dispose&&t.dispose(),this.world.remove(t),t=null},clear:async function(t=null,e=!1){return new Promise(((n,r)=>{let i=[];this.world.children.forEach((function(t){i.push(t)}));for(let e=0;e<i.length;e++){let n=i[e];n.layer!==t&&t||this.remove(n)}e&&this.objectsCache.forEach((t=>{t.promise.then((t=>{t.dispose(),t=null}))})),n("clear")}))},removeLayer:function(t){this.clear(t,!0).then((()=>{this.map.removeLayer(t)}))},getSunPosition:function(t,e){return d.getPosition(t||Date.now(),e[1],e[0])},getSunTimes:function(t,e){return d.getTimes(t,e[1],e[0],e[2]?e[2]:0)},setBuildingShadows:function(t){if(this.map.getLayer(t.buildingsLayerId)){let e=new st(t,this);this.map.addLayer(e,t.buildingsLayerId)}else console.warn("The layer '"+t.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(t=new Date,e){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var n=new Date(t.getTime());if(e?e.lng&&e.lat?this.mapCenter=e:this.mapCenter={lng:e[0],lat:e[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===n.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=n,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(n,[this.mapCenter.lng,this.mapCenter.lat]);let r=this.sunPosition.altitude,o=Math.PI+this.sunPosition.azimuth,a=i.WORLD_SIZE/2,s=Math.sin(r),l=Math.cos(r),u=Math.cos(o)*l,c=Math.sin(o)*l;this.lights.dirLight.position.set(c,u,s),this.lights.dirLight.position.multiplyScalar(a),this.lights.dirLight.intensity=Math.max(s,0),this.lights.hemiLight.intensity=Math.max(1*s,.1),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&(this.updateSunGround(this.sunPosition),this.map.setLight({anchor:"map",position:[3,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],intensity:Math.cos(this.sunPosition.altitude),color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${Math.max(20,20+96*Math.sin(this.sunPosition.altitude))}%)`},{duration:0}),this.sky&&this.updateSunSky(this.getSunSky(n,this.sunPosition)))},getSunSky:function(t,e){if(!e){var n=this.map.getCenter();e=this.getSunPosition(t||Date.now(),[n.lng,n.lat])}return[180+180*e.azimuth/Math.PI,90-180*e.altitude/Math.PI]},updateSunSky:function(t){this.sky&&this.map.setPaintProperty(this.skyLayerName,"sky-atmosphere-sun",t)},updateSunGround:function(t){""!=this.terrainLayerName&&this.map.setPaintProperty(this.terrainLayerName,"raster-opacity",Math.max(Math.min(1,4*t.altitude),.25))},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise((t=>{t(this.clear(null,!0).then((t=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),t))))}))},defaultLights:function(){this.lights.ambientLight=new r.AmbientLight(new r.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(t=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new r.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),t&&(this.lights.dirLightHelper=new r.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new r.HemisphereLight(new r.Color(16777215),new r.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight(),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()}))},setDefaultView:function(t,e){t.bbox=(t.bbox||null==t.bbox)&&e.enableSelectingObjects,t.tooltip=(t.tooltip||null==t.tooltip)&&e.enableTooltips,t.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.6"};var ct={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:i.FOV_DEGREES,sky:!1,terrain:!1};lt=lt=ut,window.Threebox=lt,window.THREE=r}();!function(t){var e=!1,n=!1,r=!1;function i(e){let n=function(){let t=[0,0]
;return t}(),r=function(){let t=2;
;return t}();if(t(".mapster-map-submission-frontend").length){n=t(".mapster-front-submission-options").data("center");r=t(".mapster-front-submission-options").data("zoom")}let i={container:e,style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}},layers:[{id:"simple-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22}]},center:n,zoom:r}
let o=new maplibregl.Map(i);o.on("load",(()=>{o.resize();C();if(S().features.length>0){var t=turf.bbox(S());o.fitBounds(t,{padding:20,maxZoom:13,duration:0})}}));return o}function o(){if("location"===E()){"circle"===g()&&n.addLayer({id:"feature",type:"circle",source:"feature"});if("label"===g()||"marker"===g()){n.addLayer({id:"feature",type:"symbol",source:"feature"});"marker"===g()&&s()}}"line"===E()&&n.addLayer({id:"feature",type:"line",source:"feature"});"polygon"===E()&&"fill"===y()&&n.addLayer({id:"feature",type:"fill",source:"feature"});"polygon"===E()&&"fill-extrusion"===y()&&n.addLayer({id:"feature",type:"fill-extrusion",source:"feature"});c()}function a(){r&&r.remove()}function s(){if("location"===E()&&"marker"===g()){a();if(S().features.length>0){var t=v().marker,e=new maplibregl.Marker(t).setLngLat(S().features[0].geometry.coordinates);e.addTo(n);r=e}}}function l(){t('.acf-field[data-name="polygon_style"]').length&&t(document).on("change",'.acf-field[data-name="polygon_style"] :input',(function(){!function(){n.getLayer("feature")&&n.removeLayer("feature");o();h()}();c()}))}function u(){t('.acf-field[data-name="location_style"]').length&&t(document).on("change",'.acf-field[data-name="location_style"] :input',(function(){!function(){a();n.getLayer("feature")&&n.removeLayer("feature");o();h()}();c()}))}function c(){var t=v();if("location"===E()&&"marker"===g())s();else if("location"===E()&&"marker"!==g()&&"3d-model"!==g()||"line"===E()||"polygon"===E()){for(var e in t.paint)n.setPaintProperty("feature",`${_()}${e}`,t.paint[e]);for(var e in t.layout)n.setLayoutProperty("feature",`${_()}${e}`,t.layout[e])}else"location"===E()&&"3d-model"===g()&&x()}function h(){var e=v();for(var n in e)for(var r in e[n])t(document).on("change",`.acf-field[data-name="${r}"] :input`,(function(){c()}));if("line"===E()){["dashed_line","dash_length","gap_length"].forEach((e=>{t(document).on("change",`.acf-field[data-name="${e}"] :input`,(function(){c()}))}))}if("location"===E()&&"label"===g()){["label_on","icon_on","icon-image","icon-translate-x","icon-translate-y","text-translate-x","text-translate-y"].forEach((e=>{t(document).on("change",`.acf-field[data-name="${e}"] :input`,(function(){c()}))}))}
}function p(){let e=!1;t(document).on("click",".open-multigeom",(function(){t(".open-multigeom-a").trigger("click");if(!e){"line"===E()?t("#draw-single-line").show():"polygon"===E()&&t("#draw-single-polygon").show();!function(e){
}(i(b().attr("id")+"-multi"));e=!0}}))}function f(r){e=r;n=i(b().attr("id"));!function(){jQuery(document).on("click",".mapster-edit-full-width",(()=>{if("flex"===jQuery(".mapster-map-container").css("display")){jQuery(".mapster-map-container").css("display","block");jQuery(".mapster-map-container > div").css("width","100%");jQuery(".mapster-map-container > div").css("marginBottom","15px");jQuery(".mapster-edit-full-width").text("Collapse Map");n.resize()}else{jQuery(".mapster-map-container").css("display","flex");jQuery(".mapster-map-container > div").css("width","50%");jQuery(".mapster-map-container > div").css("marginBottom","0px");jQuery(".mapster-edit-full-width").text("Expand Map");n.resize()}}));let t=!1;jQuery(document).on("click",".mapster-simplify-shape",(()=>{if(jQuery(".mapster-simplify-shape-slider").length){jQuery(".mapster-simplify-shape").html("Simplify Shape");jQuery(".mapster-simplify-container").remove();d(t)}else{jQuery(".mapster-simplify-shape").html("Cancel Simplify Shape");jQuery(".mapster-map-container > div:first-child").append('\n\t\t\t\t\t<div class="mapster-simplify-container" style="margin-top: 30px; text-align: right;">\n\t\t\t\t\t\t<input class="mapster-simplify-shape-slider" type="range" min="1" max="100" value="1" />\n\t\t\t\t\t</div>\n\t\t\t\t');t=S()}}));jQuery(document).on("input",".mapster-simplify-shape-slider",(function(){let e=jQuery(this).val();d(turf.simplify(t,{tolerance:parseInt(e)/100}))}));jQuery(document).on("click",".mapster-download-geojson",(()=>{var t=document.createElement("a"),e=new Blob(["\ufeff",JSON.stringify(S())]),n=URL.createObjectURL(e);t.href=n;t.download="geojson-download.json";document.getElementById("acf-form-data").appendChild(t);t.click();document.getElementById("acf-form-data").removeChild(t)}));jQuery(document).on("click",".mapster-image-base",(()=>{
}))}();!function(){var e=M(),r=new MapboxDraw({displayControlsDefault:!1,controls:{point:e.pointAllowed,line_string:e.lineStringAllowed,polygon:e.polygonAllowed,trash:!0}});n.addControl(r,"top-left");n.on("draw.create",(e=>{var i=S();M().multipleAllowed?i.features.push(e.features[0]):i.features=[e.features[0]];n.setLayoutProperty("feature","visibility","visible");t("#finish-drawing div").fadeOut();r.deleteAll();d(i)}));n.on("draw.delete",(t=>{var e=S();e.features=[];n.setLayoutProperty("feature","visibility","visible");d(e)}));n.on("draw.update",(t=>{var e=S();e.features=[t.features[0]];d(e)}));n.on("load",(()=>{t(document).on("click","#draw-point",(()=>{n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();r.changeMode("draw_point")}));t(document).on("click","#draw-linestring",(()=>{n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();r.changeMode("draw_line_string")}));t(document).on("click","#edit-linestring",(()=>{if(S().features[0]){n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();var e=r.add(S());r.changeMode("direct_select",{featureId:e[0]})}}));t(document).on("click","#draw-polygon",(()=>{n.setLayoutProperty("feature","visibility","none");r.changeMode("draw_polygon")}));t(document).on("click","#edit-polygon",(()=>{if(S().features[0]){n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();var e=r.add(S());r.changeMode("direct_select",{featureId:e[0]})}}));t(document).on("click","#finish-drawing div",(()=>{var e=S(),i=r.getAll(),o=e.features.findIndex((t=>t.id===i.features[0].id));o>-1&&(e.features[o]=i.features[0]);n.setLayoutProperty("feature","visibility","visible");t("#finish-drawing div").fadeOut();r.deleteAll();d(e)}));t(document).on("click","#draw-delete",(()=>{r.deleteAll();n.setLayoutProperty("feature","visibility","none");d({type:"FeatureCollection",features:[]})}))}))}();!function(){"location"===E()&&T();v();n.on("load",(()=>{n.addSource("feature",{type:"geojson",data:S()});o()}))}();h();!function(){if(t("#mapster-map-geosearch").length){const e=new GeoSearch.OpenStreetMapProvider;t(document).on("click","#mapster-get-results",(async function(){var n=t("#mapster-map-geosearch").val();if(n.length>2){const o=await e.search({query:n});var i=r(o);t("#mapster-geocoder-results").empty().append(i)}else t("#mapster-geocoder-results").empty()}));t(document).on("keyup","#mapster-map-geosearch",(function(){t("#mapster-map-geosearch").val().length<=2&&t("#mapster-geocoder-results").empty()}));t(document).on("click","#mapster-geocoder-results li",(function(){var e=t(this).data("bounds");d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:t(this).data("center")}}]});n.fitBounds(e.map((t=>t.slice().reverse())),{padding:20});t("#mapster-geocoder-results").empty()}));const r=t=>{var e="";t.slice(0,5).forEach((t=>{e+=`<li data-center="${JSON.stringify([t.x,t.y])}" data-bounds="${JSON.stringify(t.bounds)}">${t.label}</li>`}));return e}}if(t("#mapster-geocoder-mapbox").length){const e=t("#mapster-geocoder-mapbox").data("access_token"),r=new MapboxGeocoder({accessToken:e,mapboxgl:maplibregl,marker:!1});r.on("result",(t=>{d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:t.result.center}}]})}));document.getElementById("mapster-geocoder-mapbox").appendChild(r.onAdd(n))}}();p();"line"!==E()&&"polygon"!==E()||function(){t("#mapster-map-upload").change((function(t){e(t)}));const e=async t=>{const e=await new Response(t.target.files[0]).json();n(e)},n=e=>{if(e){const r=geojsonhint.hint(e);if(0===r.length){if(n=e.features.find((e=>t("#mapster-map-upload").data("type").indexOf(e.geometry.type)>-1))){if(window.confirm("Are you sure you want to upload this geoJSON? It will overwrite all existing features.")){n.id||(n.id=parseInt(Math.random()*Math.random()*1e7));d({type:"FeatureCollection",features:[n]})}}else window.alert("Please double-check that your geoJSON has the right geometry type for this post.")}else{var n;if(n=e.features.find((e=>t("#mapster-map-upload").data("type").indexOf(e.geometry.type)>-1))){if(window.confirm("There was an error with your upload: "+JSON.stringify(r)+". Are you sure you want to upload this geoJSON? It will overwrite all existing features.")){n.id||(n.id=parseInt(Math.random()*Math.random()*1e7));d({type:"FeatureCollection",features:[n]})}}else window.alert("GeoJSON error: "+JSON.stringify(r))}}else window.alert("Please upload a file.")}}();if("location"===E()){u();t(document).on("click","#set-manual-point",(function(){let e=t("#mapster-map-point-longitude").val(),n=t("#mapster-map-point-latitude").val();d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:[parseFloat(e),parseFloat(n)]}}]})}))}"polygon"===E()&&l()}function d(e){!function(t){t.features.forEach((t=>{t.geometry.coordinates=t.geometry.coordinates.map(m)}))}(e);!function(e){t(`#mapster-map-geojson-${w()}`).attr("value",JSON.stringify(e))}(e);n.getSource("feature").setData(e);s();if("location"===E()){T();"3d-model"===g()&&x()}}function m(t){return isNaN(t)?t.map(m):Math.round(1e8*t)/1e8}function g(){return t(".mapster-map-submission-frontend").length?"marker":t('.acf-field[data-name="location_style"]').find("select").val()}function y(){return t('.acf-field[data-name="polygon_style"]').find("select").val()}function v(){if("location"===E()&&"circle"===g()){var e=t('.acf-field[data-name="circle"] .acf-field[data-name="color"]').find(":input").val(),r=t('.acf-field[data-name="circle"] .acf-field[data-name="opacity"]').find(":input").val(),i=t('.acf-field[data-name="circle"] .acf-field[data-name="radius"]').find(":input").val(),o=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-width"]').find(":input").val(),a=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-color"]').find(":input").val(),s=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-opacity"]').find(":input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,radius:""!==i?parseFloat(i):5,"stroke-width":""!==o?parseFloat(o):0,"stroke-color":""!==a?a:"#FFF","stroke-opacity":""!==s?parseFloat(s)/100:1}}}if("location"===E()&&"marker"===g()){e=t('.acf-field[data-name="marker"] .acf-field[data-name="color"]').find(":input").val();var l=t('.acf-field[data-name="marker"] .acf-field[data-name="scale"]').find(":input").val(),u=t('.acf-field[data-name="marker"] .acf-field[data-name="rotation"]').find(":input").val(),c=t('.acf-field[data-name="marker"] .acf-field[data-name="anchor"]').find(":input").val();return{marker:{color:""!==e?e:"#000",scale:""!==l?parseFloat(l)/100:1,rotation:""!==u?parseFloat(u):0,anchor:""!==c?c:"center"}}}if("location"===E()&&"label"===g()){var h=t('.acf-field[data-name="label"] .acf-field[data-name="label_on"]').find(":input").is(":checked"),p=t('.acf-field[data-name="label"] .acf-field[data-name="text-field"]').find(":input").val(),f=t('.acf-field[data-name="label"] .acf-field[data-name="text-font"]').find(":input").val(),d=t('.acf-field[data-name="label"] .acf-field[data-name="text-size"]').find(":input").val(),m=t('.acf-field[data-name="label"] .acf-field[data-name="text-color"]').find(":input").val(),v=t('.acf-field[data-name="label"] .acf-field[data-name="text-opacity"]').find(":input").val(),_=t('.acf-field[data-name="label"] .acf-field[data-name="text-rotate"]').find(":input").val(),x=t('.acf-field[data-name="label"] .acf-field[data-name="text-translate-x"]').find(":input").val(),b=t('.acf-field[data-name="label"] .acf-field[data-name="text-translate-y"]').find(":input").val(),w=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-width"]').find(":input").val(),S=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-color"]').find(":input").val(),M=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-blur"]').find(":input").val(),T=t('.acf-field[data-name="icon"] .acf-field[data-name="icon_on"]').find(":input").is(":checked"),C=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-image"] img').attr("src"),I=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-size"]').find(":input").val(),A=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-opacity"]').find(":input").val(),L=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-rotate"]').find(":input").val(),P=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-translate-x"]').find(":input").val(),R=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-translate-y"]').find(":input").val(),D=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-anchor"]').find(":input").val();""!==C&&function(t,e){t||e();"https:"===window.location.protocol&&t.indexOf("http://")>-1&&(t=t.replace("http","https"));n.loadImage(t,((t,r)=>{if(n.loaded()){n.hasImage("icon-image-location")?n.updateImage("icon-image-location",r):n.addImage("icon-image-location",r);e()}else n.once("idle",(()=>{n.hasImage("icon-image-location")?n.updateImage("icon-image-location",r):n.addImage("icon-image-location",r);e()}))}))}(C,(()=>{n.setLayoutProperty("feature","icon-image","icon-image-location")}));const e={layout:{"text-field":""!==p?p:"","text-font":[f],"text-rotate":""!==_?parseFloat(_):0,"text-size":""!==d?parseFloat(d):16,"icon-size":""!==I?parseFloat(I)/100:1,"icon-rotate":""!==L?parseFloat(L):0,"icon-anchor":""!==D?D:"center","icon-offset":""!==P&&""!==R?[parseFloat(P),parseFloat(R)]:[0,0],"text-offset":""!==x&&""!==b?[parseFloat(x),parseFloat(b)]:[0,0]},paint:{"text-color":""!==m?m:"#000000","text-halo-width":""!==w?parseFloat(w):1,"text-halo-color":""!==S?S:"#FFFFFF","text-halo-blur":""!==M?parseFloat(M)/100:.5,"text-opacity":""!==v?parseFloat(v)/100:1,"icon-opacity":""!==A?parseFloat(A)/100:1}};h||(e.layout["text-size"]=0);T||(e.layout["icon-size"]=0);return e}if("line"===E()){e=t('.acf-field[data-name="color"]').find(":input").val(),r=t('.acf-field[data-name="opacity"]').find(":input").val();var N=t('.acf-field[data-name="width"]').find(":input").val(),O=t('.acf-field[data-name="dashed_line"]').find(":input").is(":checked"),k=t('.acf-field[data-name="dash_length"]').find(":input").val(),z=t('.acf-field[data-name="gap_length"]').find(":input").val();const n={paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,width:""!==N?parseFloat(N):5}};n.paint.dasharray=O?""!==k&&""!==z?[parseFloat(k),parseFloat(z)]:[1,1]:[1,0];return n}if("polygon"===E()&&"fill"===y()){e=t('.acf-field[data-name="color"]').find("input").val(),r=t('.acf-field[data-name="opacity"]').find("input").val();var F=t('.acf-field[data-name="outline-color"]').find("input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,"outline-color":""!==F?F:"rgba(0, 0, 0, 0)"}}}if("polygon"===E()&&"fill-extrusion"===y()){e=t('.acf-field[data-name="color"]').find("input").val(),r=t('.acf-field[data-name="opacity"]').find("input").val();var B=t('.acf-field[data-name="base"]').find("input").val(),U=t('.acf-field[data-name="height"]').find("input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,base:""!==B?parseFloat(B):0,height:""!==U?parseFloat(U):0}}}}function _(){return"location"===E()&&"circle"===g()?"circle-":"location"===E()&&"label"===g()?"":"line"===E()?"line-":"polygon"===E()&&"fill"===y()?"fill-":"polygon"===E()&&"fill-extrusion"===y()?"fill-extrusion-":void 0}function x(){
}function b(){return t(e).find(".mapster-map")}function w(){return b().attr("id").replace("mapster-map-","")}function E(){if(t(".mapster-map-submission-frontend").length){let e=1===t(".mapster-submission-map").data("linestring")?"line":"";e=1===t(".mapster-submission-map").data("point")?"location":e;e=1===t(".mapster-submission-map").data("polygon")?"polygon":e;return e}var e=t("body").attr("class").split(/\s+/).find((t=>t.indexOf("post-type-mapster-wp-")>-1)).replace("post-type-mapster-wp-","");return e="user-sub"===e?"location":e}function S(){var e=t(`#mapster-map-geojson-${w()}`).val();if(e&&""!==e){return JSON.parse(e)}return{type:"FeatureCollection",features:[]}}function M(){return{pointAllowed:1===b().data("point"),lineStringAllowed:1===b().data("linestring"),polygonAllowed:1===b().data("polygon"),multipleAllowed:1===b().data("multiple")}}function T(){if(S().features[0]){var e=S().features[0].geometry.coordinates;t("#mapster-map-point-longitude").val(e[0]);t("#mapster-map-point-latitude").val(e[1])}else{t("#mapster-map-point-longitude").val("");t("#mapster-map-point-latitude").val("")}}function C(){
}if(void 0!==acf.add_action){acf.add_action("ready_field/type=mapster-map",f);acf.add_action("append_field/type=mapster-map",f);acf.add_action("show_field/type=mapster-map",f)}else t(document).on("acf/setup_fields",(function(e,n){t(n).find('.field[data-field_type="mapster-map"]').each((function(){f(t(this))}))}))}(jQuery);